18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __ASM_SH_MOBILE_LCDC_H__ 38c2ecf20Sopenharmony_ci#define __ASM_SH_MOBILE_LCDC_H__ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/fb.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/* Register definitions */ 88c2ecf20Sopenharmony_ci#define _LDDCKR 0x410 98c2ecf20Sopenharmony_ci#define LDDCKR_ICKSEL_BUS (0 << 16) 108c2ecf20Sopenharmony_ci#define LDDCKR_ICKSEL_MIPI (1 << 16) 118c2ecf20Sopenharmony_ci#define LDDCKR_ICKSEL_HDMI (2 << 16) 128c2ecf20Sopenharmony_ci#define LDDCKR_ICKSEL_EXT (3 << 16) 138c2ecf20Sopenharmony_ci#define LDDCKR_ICKSEL_MASK (7 << 16) 148c2ecf20Sopenharmony_ci#define LDDCKR_MOSEL (1 << 6) 158c2ecf20Sopenharmony_ci#define _LDDCKSTPR 0x414 168c2ecf20Sopenharmony_ci#define _LDINTR 0x468 178c2ecf20Sopenharmony_ci#define LDINTR_FE (1 << 10) 188c2ecf20Sopenharmony_ci#define LDINTR_VSE (1 << 9) 198c2ecf20Sopenharmony_ci#define LDINTR_VEE (1 << 8) 208c2ecf20Sopenharmony_ci#define LDINTR_FS (1 << 2) 218c2ecf20Sopenharmony_ci#define LDINTR_VSS (1 << 1) 228c2ecf20Sopenharmony_ci#define LDINTR_VES (1 << 0) 238c2ecf20Sopenharmony_ci#define LDINTR_STATUS_MASK (0xff << 0) 248c2ecf20Sopenharmony_ci#define _LDSR 0x46c 258c2ecf20Sopenharmony_ci#define LDSR_MSS (1 << 10) 268c2ecf20Sopenharmony_ci#define LDSR_MRS (1 << 8) 278c2ecf20Sopenharmony_ci#define LDSR_AS (1 << 1) 288c2ecf20Sopenharmony_ci#define _LDCNT1R 0x470 298c2ecf20Sopenharmony_ci#define LDCNT1R_DE (1 << 0) 308c2ecf20Sopenharmony_ci#define _LDCNT2R 0x474 318c2ecf20Sopenharmony_ci#define LDCNT2R_BR (1 << 8) 328c2ecf20Sopenharmony_ci#define LDCNT2R_MD (1 << 3) 338c2ecf20Sopenharmony_ci#define LDCNT2R_SE (1 << 2) 348c2ecf20Sopenharmony_ci#define LDCNT2R_ME (1 << 1) 358c2ecf20Sopenharmony_ci#define LDCNT2R_DO (1 << 0) 368c2ecf20Sopenharmony_ci#define _LDRCNTR 0x478 378c2ecf20Sopenharmony_ci#define LDRCNTR_SRS (1 << 17) 388c2ecf20Sopenharmony_ci#define LDRCNTR_SRC (1 << 16) 398c2ecf20Sopenharmony_ci#define LDRCNTR_MRS (1 << 1) 408c2ecf20Sopenharmony_ci#define LDRCNTR_MRC (1 << 0) 418c2ecf20Sopenharmony_ci#define _LDDDSR 0x47c 428c2ecf20Sopenharmony_ci#define LDDDSR_LS (1 << 2) 438c2ecf20Sopenharmony_ci#define LDDDSR_WS (1 << 1) 448c2ecf20Sopenharmony_ci#define LDDDSR_BS (1 << 0) 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define LDMT1R_VPOL (1 << 28) 478c2ecf20Sopenharmony_ci#define LDMT1R_HPOL (1 << 27) 488c2ecf20Sopenharmony_ci#define LDMT1R_DWPOL (1 << 26) 498c2ecf20Sopenharmony_ci#define LDMT1R_DIPOL (1 << 25) 508c2ecf20Sopenharmony_ci#define LDMT1R_DAPOL (1 << 24) 518c2ecf20Sopenharmony_ci#define LDMT1R_HSCNT (1 << 17) 528c2ecf20Sopenharmony_ci#define LDMT1R_DWCNT (1 << 16) 538c2ecf20Sopenharmony_ci#define LDMT1R_IFM (1 << 12) 548c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_RGB8 (0x0 << 0) 558c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_RGB9 (0x4 << 0) 568c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_RGB12A (0x5 << 0) 578c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_RGB12B (0x6 << 0) 588c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_RGB16 (0x7 << 0) 598c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_RGB18 (0xa << 0) 608c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_RGB24 (0xb << 0) 618c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_YCBCR (0xf << 0) 628c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS8A (0x0 << 0) 638c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS8B (0x1 << 0) 648c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS8C (0x2 << 0) 658c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS8D (0x3 << 0) 668c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS9 (0x4 << 0) 678c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS12 (0x5 << 0) 688c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS16A (0x7 << 0) 698c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS16B (0x8 << 0) 708c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS16C (0x9 << 0) 718c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS18 (0xa << 0) 728c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_SYS24 (0xb << 0) 738c2ecf20Sopenharmony_ci#define LDMT1R_MIFTYP_MASK (0xf << 0) 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci#define LDDFR_CF1 (1 << 18) 768c2ecf20Sopenharmony_ci#define LDDFR_CF0 (1 << 17) 778c2ecf20Sopenharmony_ci#define LDDFR_CC (1 << 16) 788c2ecf20Sopenharmony_ci#define LDDFR_YF_420 (0 << 8) 798c2ecf20Sopenharmony_ci#define LDDFR_YF_422 (1 << 8) 808c2ecf20Sopenharmony_ci#define LDDFR_YF_444 (2 << 8) 818c2ecf20Sopenharmony_ci#define LDDFR_YF_MASK (3 << 8) 828c2ecf20Sopenharmony_ci#define LDDFR_PKF_ARGB32 (0x00 << 0) 838c2ecf20Sopenharmony_ci#define LDDFR_PKF_RGB16 (0x03 << 0) 848c2ecf20Sopenharmony_ci#define LDDFR_PKF_RGB24 (0x0b << 0) 858c2ecf20Sopenharmony_ci#define LDDFR_PKF_MASK (0x1f << 0) 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci#define LDSM1R_OS (1 << 0) 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define LDSM2R_OSTRG (1 << 0) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define LDPMR_LPS (3 << 0) 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci#define _LDDWD0R 0x800 948c2ecf20Sopenharmony_ci#define LDDWDxR_WDACT (1 << 28) 958c2ecf20Sopenharmony_ci#define LDDWDxR_RSW (1 << 24) 968c2ecf20Sopenharmony_ci#define _LDDRDR 0x840 978c2ecf20Sopenharmony_ci#define LDDRDR_RSR (1 << 24) 988c2ecf20Sopenharmony_ci#define LDDRDR_DRD_MASK (0x3ffff << 0) 998c2ecf20Sopenharmony_ci#define _LDDWAR 0x900 1008c2ecf20Sopenharmony_ci#define LDDWAR_WA (1 << 0) 1018c2ecf20Sopenharmony_ci#define _LDDRAR 0x904 1028c2ecf20Sopenharmony_ci#define LDDRAR_RA (1 << 0) 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cienum { 1058c2ecf20Sopenharmony_ci RGB8 = LDMT1R_MIFTYP_RGB8, /* 24bpp, 8:8:8 */ 1068c2ecf20Sopenharmony_ci RGB9 = LDMT1R_MIFTYP_RGB9, /* 18bpp, 9:9 */ 1078c2ecf20Sopenharmony_ci RGB12A = LDMT1R_MIFTYP_RGB12A, /* 24bpp, 12:12 */ 1088c2ecf20Sopenharmony_ci RGB12B = LDMT1R_MIFTYP_RGB12B, /* 12bpp */ 1098c2ecf20Sopenharmony_ci RGB16 = LDMT1R_MIFTYP_RGB16, /* 16bpp */ 1108c2ecf20Sopenharmony_ci RGB18 = LDMT1R_MIFTYP_RGB18, /* 18bpp */ 1118c2ecf20Sopenharmony_ci RGB24 = LDMT1R_MIFTYP_RGB24, /* 24bpp */ 1128c2ecf20Sopenharmony_ci YUV422 = LDMT1R_MIFTYP_YCBCR, /* 16bpp */ 1138c2ecf20Sopenharmony_ci SYS8A = LDMT1R_IFM | LDMT1R_MIFTYP_SYS8A, /* 24bpp, 8:8:8 */ 1148c2ecf20Sopenharmony_ci SYS8B = LDMT1R_IFM | LDMT1R_MIFTYP_SYS8B, /* 18bpp, 8:8:2 */ 1158c2ecf20Sopenharmony_ci SYS8C = LDMT1R_IFM | LDMT1R_MIFTYP_SYS8C, /* 18bpp, 2:8:8 */ 1168c2ecf20Sopenharmony_ci SYS8D = LDMT1R_IFM | LDMT1R_MIFTYP_SYS8D, /* 16bpp, 8:8 */ 1178c2ecf20Sopenharmony_ci SYS9 = LDMT1R_IFM | LDMT1R_MIFTYP_SYS9, /* 18bpp, 9:9 */ 1188c2ecf20Sopenharmony_ci SYS12 = LDMT1R_IFM | LDMT1R_MIFTYP_SYS12, /* 24bpp, 12:12 */ 1198c2ecf20Sopenharmony_ci SYS16A = LDMT1R_IFM | LDMT1R_MIFTYP_SYS16A, /* 16bpp */ 1208c2ecf20Sopenharmony_ci SYS16B = LDMT1R_IFM | LDMT1R_MIFTYP_SYS16B, /* 18bpp, 16:2 */ 1218c2ecf20Sopenharmony_ci SYS16C = LDMT1R_IFM | LDMT1R_MIFTYP_SYS16C, /* 18bpp, 2:16 */ 1228c2ecf20Sopenharmony_ci SYS18 = LDMT1R_IFM | LDMT1R_MIFTYP_SYS18, /* 18bpp */ 1238c2ecf20Sopenharmony_ci SYS24 = LDMT1R_IFM | LDMT1R_MIFTYP_SYS24, /* 24bpp */ 1248c2ecf20Sopenharmony_ci}; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_cienum { LCDC_CHAN_DISABLED = 0, 1278c2ecf20Sopenharmony_ci LCDC_CHAN_MAINLCD, 1288c2ecf20Sopenharmony_ci LCDC_CHAN_SUBLCD }; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cienum { LCDC_CLK_BUS, LCDC_CLK_PERIPHERAL, LCDC_CLK_EXTERNAL }; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci#define LCDC_FLAGS_DWPOL (1 << 0) /* Rising edge dot clock data latch */ 1338c2ecf20Sopenharmony_ci#define LCDC_FLAGS_DIPOL (1 << 1) /* Active low display enable polarity */ 1348c2ecf20Sopenharmony_ci#define LCDC_FLAGS_DAPOL (1 << 2) /* Active low display data polarity */ 1358c2ecf20Sopenharmony_ci#define LCDC_FLAGS_HSCNT (1 << 3) /* Disable HSYNC during VBLANK */ 1368c2ecf20Sopenharmony_ci#define LCDC_FLAGS_DWCNT (1 << 4) /* Disable dotclock during blanking */ 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_cistruct sh_mobile_lcdc_sys_bus_cfg { 1398c2ecf20Sopenharmony_ci unsigned long ldmt2r; 1408c2ecf20Sopenharmony_ci unsigned long ldmt3r; 1418c2ecf20Sopenharmony_ci unsigned long deferred_io_msec; 1428c2ecf20Sopenharmony_ci}; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_cistruct sh_mobile_lcdc_sys_bus_ops { 1458c2ecf20Sopenharmony_ci void (*write_index)(void *handle, unsigned long data); 1468c2ecf20Sopenharmony_ci void (*write_data)(void *handle, unsigned long data); 1478c2ecf20Sopenharmony_ci unsigned long (*read_data)(void *handle); 1488c2ecf20Sopenharmony_ci}; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_cistruct sh_mobile_lcdc_panel_cfg { 1518c2ecf20Sopenharmony_ci unsigned long width; /* Panel width in mm */ 1528c2ecf20Sopenharmony_ci unsigned long height; /* Panel height in mm */ 1538c2ecf20Sopenharmony_ci int (*setup_sys)(void *sys_ops_handle, 1548c2ecf20Sopenharmony_ci struct sh_mobile_lcdc_sys_bus_ops *sys_ops); 1558c2ecf20Sopenharmony_ci void (*start_transfer)(void *sys_ops_handle, 1568c2ecf20Sopenharmony_ci struct sh_mobile_lcdc_sys_bus_ops *sys_ops); 1578c2ecf20Sopenharmony_ci void (*display_on)(void); 1588c2ecf20Sopenharmony_ci void (*display_off)(void); 1598c2ecf20Sopenharmony_ci}; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci/* backlight info */ 1628c2ecf20Sopenharmony_cistruct sh_mobile_lcdc_bl_info { 1638c2ecf20Sopenharmony_ci const char *name; 1648c2ecf20Sopenharmony_ci int max_brightness; 1658c2ecf20Sopenharmony_ci int (*set_brightness)(int brightness); 1668c2ecf20Sopenharmony_ci}; 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_cistruct sh_mobile_lcdc_overlay_cfg { 1698c2ecf20Sopenharmony_ci int fourcc; 1708c2ecf20Sopenharmony_ci unsigned int max_xres; 1718c2ecf20Sopenharmony_ci unsigned int max_yres; 1728c2ecf20Sopenharmony_ci}; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_cistruct sh_mobile_lcdc_chan_cfg { 1758c2ecf20Sopenharmony_ci int chan; 1768c2ecf20Sopenharmony_ci int fourcc; 1778c2ecf20Sopenharmony_ci int colorspace; 1788c2ecf20Sopenharmony_ci int interface_type; /* selects RGBn or SYSn I/F, see above */ 1798c2ecf20Sopenharmony_ci int clock_divider; 1808c2ecf20Sopenharmony_ci unsigned long flags; /* LCDC_FLAGS_... */ 1818c2ecf20Sopenharmony_ci const struct fb_videomode *lcd_modes; 1828c2ecf20Sopenharmony_ci int num_modes; 1838c2ecf20Sopenharmony_ci struct sh_mobile_lcdc_panel_cfg panel_cfg; 1848c2ecf20Sopenharmony_ci struct sh_mobile_lcdc_bl_info bl_info; 1858c2ecf20Sopenharmony_ci struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */ 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci struct platform_device *tx_dev; /* HDMI/DSI transmitter device */ 1888c2ecf20Sopenharmony_ci}; 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_cistruct sh_mobile_lcdc_info { 1918c2ecf20Sopenharmony_ci int clock_source; 1928c2ecf20Sopenharmony_ci struct sh_mobile_lcdc_chan_cfg ch[2]; 1938c2ecf20Sopenharmony_ci struct sh_mobile_lcdc_overlay_cfg overlays[4]; 1948c2ecf20Sopenharmony_ci}; 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci#endif /* __ASM_SH_MOBILE_LCDC_H__ */ 197