18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2018 Texas Instruments Incorporated - https://www.ti.com/ 48c2ecf20Sopenharmony_ci * Author: Tomi Valkeinen <tomi.valkeinen@ti.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef __TIDSS_IRQ_H__ 88c2ecf20Sopenharmony_ci#define __TIDSS_IRQ_H__ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <linux/types.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include "tidss_drv.h" 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* 158c2ecf20Sopenharmony_ci * The IRQ status from various DISPC IRQ registers are packed into a single 168c2ecf20Sopenharmony_ci * value, where the bits are defined as follows: 178c2ecf20Sopenharmony_ci * 188c2ecf20Sopenharmony_ci * bit group |dev|wb |mrg0|mrg1|mrg2|mrg3|plane0-3| <unused> | 198c2ecf20Sopenharmony_ci * bit use |D |fou|FEOL|FEOL|FEOL|FEOL| UUUU | | 208c2ecf20Sopenharmony_ci * bit number|0 |1-3|4-7 |8-11| 12-19 | 20-23 | 24-31 | 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci * device bits: D = OCP error 238c2ecf20Sopenharmony_ci * WB bits: f = frame done wb, o = wb buffer overflow, 248c2ecf20Sopenharmony_ci * u = wb buffer uncomplete 258c2ecf20Sopenharmony_ci * vp bits: F = frame done, E = vsync even, O = vsync odd, L = sync lost 268c2ecf20Sopenharmony_ci * plane bits: U = fifo underflow 278c2ecf20Sopenharmony_ci */ 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define DSS_IRQ_DEVICE_OCP_ERR BIT(0) 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define DSS_IRQ_DEVICE_FRAMEDONEWB BIT(1) 328c2ecf20Sopenharmony_ci#define DSS_IRQ_DEVICE_WBBUFFEROVERFLOW BIT(2) 338c2ecf20Sopenharmony_ci#define DSS_IRQ_DEVICE_WBUNCOMPLETEERROR BIT(3) 348c2ecf20Sopenharmony_ci#define DSS_IRQ_DEVICE_WB_MASK GENMASK(3, 1) 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define DSS_IRQ_VP_BIT_N(ch, bit) (4 + 4 * (ch) + (bit)) 378c2ecf20Sopenharmony_ci#define DSS_IRQ_PLANE_BIT_N(plane, bit) \ 388c2ecf20Sopenharmony_ci (DSS_IRQ_VP_BIT_N(TIDSS_MAX_PORTS, 0) + 1 * (plane) + (bit)) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define DSS_IRQ_VP_BIT(ch, bit) BIT(DSS_IRQ_VP_BIT_N((ch), (bit))) 418c2ecf20Sopenharmony_ci#define DSS_IRQ_PLANE_BIT(plane, bit) \ 428c2ecf20Sopenharmony_ci BIT(DSS_IRQ_PLANE_BIT_N((plane), (bit))) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistatic inline dispc_irq_t DSS_IRQ_VP_MASK(u32 ch) 458c2ecf20Sopenharmony_ci{ 468c2ecf20Sopenharmony_ci return GENMASK(DSS_IRQ_VP_BIT_N((ch), 3), DSS_IRQ_VP_BIT_N((ch), 0)); 478c2ecf20Sopenharmony_ci} 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistatic inline dispc_irq_t DSS_IRQ_PLANE_MASK(u32 plane) 508c2ecf20Sopenharmony_ci{ 518c2ecf20Sopenharmony_ci return GENMASK(DSS_IRQ_PLANE_BIT_N((plane), 0), 528c2ecf20Sopenharmony_ci DSS_IRQ_PLANE_BIT_N((plane), 0)); 538c2ecf20Sopenharmony_ci} 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define DSS_IRQ_VP_FRAME_DONE(ch) DSS_IRQ_VP_BIT((ch), 0) 568c2ecf20Sopenharmony_ci#define DSS_IRQ_VP_VSYNC_EVEN(ch) DSS_IRQ_VP_BIT((ch), 1) 578c2ecf20Sopenharmony_ci#define DSS_IRQ_VP_VSYNC_ODD(ch) DSS_IRQ_VP_BIT((ch), 2) 588c2ecf20Sopenharmony_ci#define DSS_IRQ_VP_SYNC_LOST(ch) DSS_IRQ_VP_BIT((ch), 3) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#define DSS_IRQ_PLANE_FIFO_UNDERFLOW(plane) DSS_IRQ_PLANE_BIT((plane), 0) 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistruct drm_crtc; 638c2ecf20Sopenharmony_cistruct drm_device; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct tidss_device; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_civoid tidss_irq_enable_vblank(struct drm_crtc *crtc); 688c2ecf20Sopenharmony_civoid tidss_irq_disable_vblank(struct drm_crtc *crtc); 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_civoid tidss_irq_preinstall(struct drm_device *ddev); 718c2ecf20Sopenharmony_ciint tidss_irq_postinstall(struct drm_device *ddev); 728c2ecf20Sopenharmony_civoid tidss_irq_uninstall(struct drm_device *ddev); 738c2ecf20Sopenharmony_ciirqreturn_t tidss_irq_handler(int irq, void *arg); 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_civoid tidss_irq_resume(struct tidss_device *tidss); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#endif 78