sh_mobile_lcdc.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_SH_MOBILE_LCDC_H__
  3. #define __ASM_SH_MOBILE_LCDC_H__
  4. #include <linux/fb.h>
  5. #include <video/sh_mobile_meram.h>
  6. /* Register definitions */
  7. #define _LDDCKR 0x410
  8. #define LDDCKR_ICKSEL_BUS (0 << 16)
  9. #define LDDCKR_ICKSEL_MIPI (1 << 16)
  10. #define LDDCKR_ICKSEL_HDMI (2 << 16)
  11. #define LDDCKR_ICKSEL_EXT (3 << 16)
  12. #define LDDCKR_ICKSEL_MASK (7 << 16)
  13. #define LDDCKR_MOSEL (1 << 6)
  14. #define _LDDCKSTPR 0x414
  15. #define _LDINTR 0x468
  16. #define LDINTR_FE (1 << 10)
  17. #define LDINTR_VSE (1 << 9)
  18. #define LDINTR_VEE (1 << 8)
  19. #define LDINTR_FS (1 << 2)
  20. #define LDINTR_VSS (1 << 1)
  21. #define LDINTR_VES (1 << 0)
  22. #define LDINTR_STATUS_MASK (0xff << 0)
  23. #define _LDSR 0x46c
  24. #define LDSR_MSS (1 << 10)
  25. #define LDSR_MRS (1 << 8)
  26. #define LDSR_AS (1 << 1)
  27. #define _LDCNT1R 0x470
  28. #define LDCNT1R_DE (1 << 0)
  29. #define _LDCNT2R 0x474
  30. #define LDCNT2R_BR (1 << 8)
  31. #define LDCNT2R_MD (1 << 3)
  32. #define LDCNT2R_SE (1 << 2)
  33. #define LDCNT2R_ME (1 << 1)
  34. #define LDCNT2R_DO (1 << 0)
  35. #define _LDRCNTR 0x478
  36. #define LDRCNTR_SRS (1 << 17)
  37. #define LDRCNTR_SRC (1 << 16)
  38. #define LDRCNTR_MRS (1 << 1)
  39. #define LDRCNTR_MRC (1 << 0)
  40. #define _LDDDSR 0x47c
  41. #define LDDDSR_LS (1 << 2)
  42. #define LDDDSR_WS (1 << 1)
  43. #define LDDDSR_BS (1 << 0)
  44. #define LDMT1R_VPOL (1 << 28)
  45. #define LDMT1R_HPOL (1 << 27)
  46. #define LDMT1R_DWPOL (1 << 26)
  47. #define LDMT1R_DIPOL (1 << 25)
  48. #define LDMT1R_DAPOL (1 << 24)
  49. #define LDMT1R_HSCNT (1 << 17)
  50. #define LDMT1R_DWCNT (1 << 16)
  51. #define LDMT1R_IFM (1 << 12)
  52. #define LDMT1R_MIFTYP_RGB8 (0x0 << 0)
  53. #define LDMT1R_MIFTYP_RGB9 (0x4 << 0)
  54. #define LDMT1R_MIFTYP_RGB12A (0x5 << 0)
  55. #define LDMT1R_MIFTYP_RGB12B (0x6 << 0)
  56. #define LDMT1R_MIFTYP_RGB16 (0x7 << 0)
  57. #define LDMT1R_MIFTYP_RGB18 (0xa << 0)
  58. #define LDMT1R_MIFTYP_RGB24 (0xb << 0)
  59. #define LDMT1R_MIFTYP_YCBCR (0xf << 0)
  60. #define LDMT1R_MIFTYP_SYS8A (0x0 << 0)
  61. #define LDMT1R_MIFTYP_SYS8B (0x1 << 0)
  62. #define LDMT1R_MIFTYP_SYS8C (0x2 << 0)
  63. #define LDMT1R_MIFTYP_SYS8D (0x3 << 0)
  64. #define LDMT1R_MIFTYP_SYS9 (0x4 << 0)
  65. #define LDMT1R_MIFTYP_SYS12 (0x5 << 0)
  66. #define LDMT1R_MIFTYP_SYS16A (0x7 << 0)
  67. #define LDMT1R_MIFTYP_SYS16B (0x8 << 0)
  68. #define LDMT1R_MIFTYP_SYS16C (0x9 << 0)
  69. #define LDMT1R_MIFTYP_SYS18 (0xa << 0)
  70. #define LDMT1R_MIFTYP_SYS24 (0xb << 0)
  71. #define LDMT1R_MIFTYP_MASK (0xf << 0)
  72. #define LDDFR_CF1 (1 << 18)
  73. #define LDDFR_CF0 (1 << 17)
  74. #define LDDFR_CC (1 << 16)
  75. #define LDDFR_YF_420 (0 << 8)
  76. #define LDDFR_YF_422 (1 << 8)
  77. #define LDDFR_YF_444 (2 << 8)
  78. #define LDDFR_YF_MASK (3 << 8)
  79. #define LDDFR_PKF_ARGB32 (0x00 << 0)
  80. #define LDDFR_PKF_RGB16 (0x03 << 0)
  81. #define LDDFR_PKF_RGB24 (0x0b << 0)
  82. #define LDDFR_PKF_MASK (0x1f << 0)
  83. #define LDSM1R_OS (1 << 0)
  84. #define LDSM2R_OSTRG (1 << 0)
  85. #define LDPMR_LPS (3 << 0)
  86. #define _LDDWD0R 0x800
  87. #define LDDWDxR_WDACT (1 << 28)
  88. #define LDDWDxR_RSW (1 << 24)
  89. #define _LDDRDR 0x840
  90. #define LDDRDR_RSR (1 << 24)
  91. #define LDDRDR_DRD_MASK (0x3ffff << 0)
  92. #define _LDDWAR 0x900
  93. #define LDDWAR_WA (1 << 0)
  94. #define _LDDRAR 0x904
  95. #define LDDRAR_RA (1 << 0)
  96. enum {
  97. RGB8 = LDMT1R_MIFTYP_RGB8, /* 24bpp, 8:8:8 */
  98. RGB9 = LDMT1R_MIFTYP_RGB9, /* 18bpp, 9:9 */
  99. RGB12A = LDMT1R_MIFTYP_RGB12A, /* 24bpp, 12:12 */
  100. RGB12B = LDMT1R_MIFTYP_RGB12B, /* 12bpp */
  101. RGB16 = LDMT1R_MIFTYP_RGB16, /* 16bpp */
  102. RGB18 = LDMT1R_MIFTYP_RGB18, /* 18bpp */
  103. RGB24 = LDMT1R_MIFTYP_RGB24, /* 24bpp */
  104. YUV422 = LDMT1R_MIFTYP_YCBCR, /* 16bpp */
  105. SYS8A = LDMT1R_IFM | LDMT1R_MIFTYP_SYS8A, /* 24bpp, 8:8:8 */
  106. SYS8B = LDMT1R_IFM | LDMT1R_MIFTYP_SYS8B, /* 18bpp, 8:8:2 */
  107. SYS8C = LDMT1R_IFM | LDMT1R_MIFTYP_SYS8C, /* 18bpp, 2:8:8 */
  108. SYS8D = LDMT1R_IFM | LDMT1R_MIFTYP_SYS8D, /* 16bpp, 8:8 */
  109. SYS9 = LDMT1R_IFM | LDMT1R_MIFTYP_SYS9, /* 18bpp, 9:9 */
  110. SYS12 = LDMT1R_IFM | LDMT1R_MIFTYP_SYS12, /* 24bpp, 12:12 */
  111. SYS16A = LDMT1R_IFM | LDMT1R_MIFTYP_SYS16A, /* 16bpp */
  112. SYS16B = LDMT1R_IFM | LDMT1R_MIFTYP_SYS16B, /* 18bpp, 16:2 */
  113. SYS16C = LDMT1R_IFM | LDMT1R_MIFTYP_SYS16C, /* 18bpp, 2:16 */
  114. SYS18 = LDMT1R_IFM | LDMT1R_MIFTYP_SYS18, /* 18bpp */
  115. SYS24 = LDMT1R_IFM | LDMT1R_MIFTYP_SYS24, /* 24bpp */
  116. };
  117. enum { LCDC_CHAN_DISABLED = 0,
  118. LCDC_CHAN_MAINLCD,
  119. LCDC_CHAN_SUBLCD };
  120. enum { LCDC_CLK_BUS, LCDC_CLK_PERIPHERAL, LCDC_CLK_EXTERNAL };
  121. #define LCDC_FLAGS_DWPOL (1 << 0) /* Rising edge dot clock data latch */
  122. #define LCDC_FLAGS_DIPOL (1 << 1) /* Active low display enable polarity */
  123. #define LCDC_FLAGS_DAPOL (1 << 2) /* Active low display data polarity */
  124. #define LCDC_FLAGS_HSCNT (1 << 3) /* Disable HSYNC during VBLANK */
  125. #define LCDC_FLAGS_DWCNT (1 << 4) /* Disable dotclock during blanking */
  126. struct sh_mobile_lcdc_sys_bus_cfg {
  127. unsigned long ldmt2r;
  128. unsigned long ldmt3r;
  129. unsigned long deferred_io_msec;
  130. };
  131. struct sh_mobile_lcdc_sys_bus_ops {
  132. void (*write_index)(void *handle, unsigned long data);
  133. void (*write_data)(void *handle, unsigned long data);
  134. unsigned long (*read_data)(void *handle);
  135. };
  136. struct sh_mobile_lcdc_panel_cfg {
  137. unsigned long width; /* Panel width in mm */
  138. unsigned long height; /* Panel height in mm */
  139. int (*setup_sys)(void *sys_ops_handle,
  140. struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
  141. void (*start_transfer)(void *sys_ops_handle,
  142. struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
  143. void (*display_on)(void);
  144. void (*display_off)(void);
  145. };
  146. /* backlight info */
  147. struct sh_mobile_lcdc_bl_info {
  148. const char *name;
  149. int max_brightness;
  150. int (*set_brightness)(int brightness);
  151. };
  152. struct sh_mobile_lcdc_overlay_cfg {
  153. int fourcc;
  154. unsigned int max_xres;
  155. unsigned int max_yres;
  156. };
  157. struct sh_mobile_lcdc_chan_cfg {
  158. int chan;
  159. int fourcc;
  160. int colorspace;
  161. int interface_type; /* selects RGBn or SYSn I/F, see above */
  162. int clock_divider;
  163. unsigned long flags; /* LCDC_FLAGS_... */
  164. const struct fb_videomode *lcd_modes;
  165. int num_modes;
  166. struct sh_mobile_lcdc_panel_cfg panel_cfg;
  167. struct sh_mobile_lcdc_bl_info bl_info;
  168. struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */
  169. const struct sh_mobile_meram_cfg *meram_cfg;
  170. struct platform_device *tx_dev; /* HDMI/DSI transmitter device */
  171. };
  172. struct sh_mobile_lcdc_info {
  173. int clock_source;
  174. struct sh_mobile_lcdc_chan_cfg ch[2];
  175. struct sh_mobile_lcdc_overlay_cfg overlays[4];
  176. struct sh_mobile_meram_info *meram_dev;
  177. };
  178. #endif /* __ASM_SH_MOBILE_LCDC_H__ */