shmob_drm_regs.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /*
  2. * shmob_drm_regs.h -- SH Mobile DRM registers
  3. *
  4. * Copyright (C) 2012 Renesas Electronics Corporation
  5. *
  6. * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #ifndef __SHMOB_DRM_REGS_H__
  14. #define __SHMOB_DRM_REGS_H__
  15. #include <linux/io.h>
  16. /* Register definitions */
  17. #define LDDCKPAT1R 0x400
  18. #define LDDCKPAT2R 0x404
  19. #define LDDCKR 0x410
  20. #define LDDCKR_ICKSEL_BUS (0 << 16)
  21. #define LDDCKR_ICKSEL_MIPI (1 << 16)
  22. #define LDDCKR_ICKSEL_HDMI (2 << 16)
  23. #define LDDCKR_ICKSEL_EXT (3 << 16)
  24. #define LDDCKR_ICKSEL_MASK (7 << 16)
  25. #define LDDCKR_MOSEL (1 << 6)
  26. #define LDDCKSTPR 0x414
  27. #define LDDCKSTPR_DCKSTS (1 << 16)
  28. #define LDDCKSTPR_DCKSTP (1 << 0)
  29. #define LDMT1R 0x418
  30. #define LDMT1R_VPOL (1 << 28)
  31. #define LDMT1R_HPOL (1 << 27)
  32. #define LDMT1R_DWPOL (1 << 26)
  33. #define LDMT1R_DIPOL (1 << 25)
  34. #define LDMT1R_DAPOL (1 << 24)
  35. #define LDMT1R_HSCNT (1 << 17)
  36. #define LDMT1R_DWCNT (1 << 16)
  37. #define LDMT1R_IFM (1 << 12)
  38. #define LDMT1R_MIFTYP_RGB8 (0x0 << 0)
  39. #define LDMT1R_MIFTYP_RGB9 (0x4 << 0)
  40. #define LDMT1R_MIFTYP_RGB12A (0x5 << 0)
  41. #define LDMT1R_MIFTYP_RGB12B (0x6 << 0)
  42. #define LDMT1R_MIFTYP_RGB16 (0x7 << 0)
  43. #define LDMT1R_MIFTYP_RGB18 (0xa << 0)
  44. #define LDMT1R_MIFTYP_RGB24 (0xb << 0)
  45. #define LDMT1R_MIFTYP_YCBCR (0xf << 0)
  46. #define LDMT1R_MIFTYP_SYS8A (0x0 << 0)
  47. #define LDMT1R_MIFTYP_SYS8B (0x1 << 0)
  48. #define LDMT1R_MIFTYP_SYS8C (0x2 << 0)
  49. #define LDMT1R_MIFTYP_SYS8D (0x3 << 0)
  50. #define LDMT1R_MIFTYP_SYS9 (0x4 << 0)
  51. #define LDMT1R_MIFTYP_SYS12 (0x5 << 0)
  52. #define LDMT1R_MIFTYP_SYS16A (0x7 << 0)
  53. #define LDMT1R_MIFTYP_SYS16B (0x8 << 0)
  54. #define LDMT1R_MIFTYP_SYS16C (0x9 << 0)
  55. #define LDMT1R_MIFTYP_SYS18 (0xa << 0)
  56. #define LDMT1R_MIFTYP_SYS24 (0xb << 0)
  57. #define LDMT1R_MIFTYP_MASK (0xf << 0)
  58. #define LDMT2R 0x41c
  59. #define LDMT2R_CSUP_MASK (7 << 26)
  60. #define LDMT2R_CSUP_SHIFT 26
  61. #define LDMT2R_RSV (1 << 25)
  62. #define LDMT2R_VSEL (1 << 24)
  63. #define LDMT2R_WCSC_MASK (0xff << 16)
  64. #define LDMT2R_WCSC_SHIFT 16
  65. #define LDMT2R_WCEC_MASK (0xff << 8)
  66. #define LDMT2R_WCEC_SHIFT 8
  67. #define LDMT2R_WCLW_MASK (0xff << 0)
  68. #define LDMT2R_WCLW_SHIFT 0
  69. #define LDMT3R 0x420
  70. #define LDMT3R_RDLC_MASK (0x3f << 24)
  71. #define LDMT3R_RDLC_SHIFT 24
  72. #define LDMT3R_RCSC_MASK (0xff << 16)
  73. #define LDMT3R_RCSC_SHIFT 16
  74. #define LDMT3R_RCEC_MASK (0xff << 8)
  75. #define LDMT3R_RCEC_SHIFT 8
  76. #define LDMT3R_RCLW_MASK (0xff << 0)
  77. #define LDMT3R_RCLW_SHIFT 0
  78. #define LDDFR 0x424
  79. #define LDDFR_CF1 (1 << 18)
  80. #define LDDFR_CF0 (1 << 17)
  81. #define LDDFR_CC (1 << 16)
  82. #define LDDFR_YF_420 (0 << 8)
  83. #define LDDFR_YF_422 (1 << 8)
  84. #define LDDFR_YF_444 (2 << 8)
  85. #define LDDFR_YF_MASK (3 << 8)
  86. #define LDDFR_PKF_ARGB32 (0x00 << 0)
  87. #define LDDFR_PKF_RGB16 (0x03 << 0)
  88. #define LDDFR_PKF_RGB24 (0x0b << 0)
  89. #define LDDFR_PKF_MASK (0x1f << 0)
  90. #define LDSM1R 0x428
  91. #define LDSM1R_OS (1 << 0)
  92. #define LDSM2R 0x42c
  93. #define LDSM2R_OSTRG (1 << 0)
  94. #define LDSA1R 0x430
  95. #define LDSA2R 0x434
  96. #define LDMLSR 0x438
  97. #define LDWBFR 0x43c
  98. #define LDWBCNTR 0x440
  99. #define LDWBAR 0x444
  100. #define LDHCNR 0x448
  101. #define LDHSYNR 0x44c
  102. #define LDVLNR 0x450
  103. #define LDVSYNR 0x454
  104. #define LDHPDR 0x458
  105. #define LDVPDR 0x45c
  106. #define LDPMR 0x460
  107. #define LDPMR_LPS (3 << 0)
  108. #define LDINTR 0x468
  109. #define LDINTR_FE (1 << 10)
  110. #define LDINTR_VSE (1 << 9)
  111. #define LDINTR_VEE (1 << 8)
  112. #define LDINTR_FS (1 << 2)
  113. #define LDINTR_VSS (1 << 1)
  114. #define LDINTR_VES (1 << 0)
  115. #define LDINTR_STATUS_MASK (0xff << 0)
  116. #define LDSR 0x46c
  117. #define LDSR_MSS (1 << 10)
  118. #define LDSR_MRS (1 << 8)
  119. #define LDSR_AS (1 << 1)
  120. #define LDCNT1R 0x470
  121. #define LDCNT1R_DE (1 << 0)
  122. #define LDCNT2R 0x474
  123. #define LDCNT2R_BR (1 << 8)
  124. #define LDCNT2R_MD (1 << 3)
  125. #define LDCNT2R_SE (1 << 2)
  126. #define LDCNT2R_ME (1 << 1)
  127. #define LDCNT2R_DO (1 << 0)
  128. #define LDRCNTR 0x478
  129. #define LDRCNTR_SRS (1 << 17)
  130. #define LDRCNTR_SRC (1 << 16)
  131. #define LDRCNTR_MRS (1 << 1)
  132. #define LDRCNTR_MRC (1 << 0)
  133. #define LDDDSR 0x47c
  134. #define LDDDSR_LS (1 << 2)
  135. #define LDDDSR_WS (1 << 1)
  136. #define LDDDSR_BS (1 << 0)
  137. #define LDHAJR 0x4a0
  138. #define LDDWD0R 0x800
  139. #define LDDWDxR_WDACT (1 << 28)
  140. #define LDDWDxR_RSW (1 << 24)
  141. #define LDDRDR 0x840
  142. #define LDDRDR_RSR (1 << 24)
  143. #define LDDRDR_DRD_MASK (0x3ffff << 0)
  144. #define LDDWAR 0x900
  145. #define LDDWAR_WA (1 << 0)
  146. #define LDDRAR 0x904
  147. #define LDDRAR_RA (1 << 0)
  148. #define LDBCR 0xb00
  149. #define LDBCR_UPC(n) (1 << ((n) + 16))
  150. #define LDBCR_UPF(n) (1 << ((n) + 8))
  151. #define LDBCR_UPD(n) (1 << ((n) + 0))
  152. #define LDBnBSIFR(n) (0xb20 + (n) * 0x20 + 0x00)
  153. #define LDBBSIFR_EN (1 << 31)
  154. #define LDBBSIFR_VS (1 << 29)
  155. #define LDBBSIFR_BRSEL (1 << 28)
  156. #define LDBBSIFR_MX (1 << 27)
  157. #define LDBBSIFR_MY (1 << 26)
  158. #define LDBBSIFR_CV3 (3 << 24)
  159. #define LDBBSIFR_CV2 (2 << 24)
  160. #define LDBBSIFR_CV1 (1 << 24)
  161. #define LDBBSIFR_CV0 (0 << 24)
  162. #define LDBBSIFR_CV_MASK (3 << 24)
  163. #define LDBBSIFR_LAY_MASK (0xff << 16)
  164. #define LDBBSIFR_LAY_SHIFT 16
  165. #define LDBBSIFR_ROP3_MASK (0xff << 16)
  166. #define LDBBSIFR_ROP3_SHIFT 16
  167. #define LDBBSIFR_AL_PL8 (3 << 14)
  168. #define LDBBSIFR_AL_PL1 (2 << 14)
  169. #define LDBBSIFR_AL_PK (1 << 14)
  170. #define LDBBSIFR_AL_1 (0 << 14)
  171. #define LDBBSIFR_AL_MASK (3 << 14)
  172. #define LDBBSIFR_SWPL (1 << 10)
  173. #define LDBBSIFR_SWPW (1 << 9)
  174. #define LDBBSIFR_SWPB (1 << 8)
  175. #define LDBBSIFR_RY (1 << 7)
  176. #define LDBBSIFR_CHRR_420 (2 << 0)
  177. #define LDBBSIFR_CHRR_422 (1 << 0)
  178. #define LDBBSIFR_CHRR_444 (0 << 0)
  179. #define LDBBSIFR_RPKF_ARGB32 (0x00 << 0)
  180. #define LDBBSIFR_RPKF_RGB16 (0x03 << 0)
  181. #define LDBBSIFR_RPKF_RGB24 (0x0b << 0)
  182. #define LDBBSIFR_RPKF_MASK (0x1f << 0)
  183. #define LDBnBSSZR(n) (0xb20 + (n) * 0x20 + 0x04)
  184. #define LDBBSSZR_BVSS_MASK (0xfff << 16)
  185. #define LDBBSSZR_BVSS_SHIFT 16
  186. #define LDBBSSZR_BHSS_MASK (0xfff << 0)
  187. #define LDBBSSZR_BHSS_SHIFT 0
  188. #define LDBnBLOCR(n) (0xb20 + (n) * 0x20 + 0x08)
  189. #define LDBBLOCR_CVLC_MASK (0xfff << 16)
  190. #define LDBBLOCR_CVLC_SHIFT 16
  191. #define LDBBLOCR_CHLC_MASK (0xfff << 0)
  192. #define LDBBLOCR_CHLC_SHIFT 0
  193. #define LDBnBSMWR(n) (0xb20 + (n) * 0x20 + 0x0c)
  194. #define LDBBSMWR_BSMWA_MASK (0xffff << 16)
  195. #define LDBBSMWR_BSMWA_SHIFT 16
  196. #define LDBBSMWR_BSMW_MASK (0xffff << 0)
  197. #define LDBBSMWR_BSMW_SHIFT 0
  198. #define LDBnBSAYR(n) (0xb20 + (n) * 0x20 + 0x10)
  199. #define LDBBSAYR_FG1A_MASK (0xff << 24)
  200. #define LDBBSAYR_FG1A_SHIFT 24
  201. #define LDBBSAYR_FG1R_MASK (0xff << 16)
  202. #define LDBBSAYR_FG1R_SHIFT 16
  203. #define LDBBSAYR_FG1G_MASK (0xff << 8)
  204. #define LDBBSAYR_FG1G_SHIFT 8
  205. #define LDBBSAYR_FG1B_MASK (0xff << 0)
  206. #define LDBBSAYR_FG1B_SHIFT 0
  207. #define LDBnBSACR(n) (0xb20 + (n) * 0x20 + 0x14)
  208. #define LDBBSACR_FG2A_MASK (0xff << 24)
  209. #define LDBBSACR_FG2A_SHIFT 24
  210. #define LDBBSACR_FG2R_MASK (0xff << 16)
  211. #define LDBBSACR_FG2R_SHIFT 16
  212. #define LDBBSACR_FG2G_MASK (0xff << 8)
  213. #define LDBBSACR_FG2G_SHIFT 8
  214. #define LDBBSACR_FG2B_MASK (0xff << 0)
  215. #define LDBBSACR_FG2B_SHIFT 0
  216. #define LDBnBSAAR(n) (0xb20 + (n) * 0x20 + 0x18)
  217. #define LDBBSAAR_AP_MASK (0xff << 24)
  218. #define LDBBSAAR_AP_SHIFT 24
  219. #define LDBBSAAR_R_MASK (0xff << 16)
  220. #define LDBBSAAR_R_SHIFT 16
  221. #define LDBBSAAR_GY_MASK (0xff << 8)
  222. #define LDBBSAAR_GY_SHIFT 8
  223. #define LDBBSAAR_B_MASK (0xff << 0)
  224. #define LDBBSAAR_B_SHIFT 0
  225. #define LDBnBPPCR(n) (0xb20 + (n) * 0x20 + 0x1c)
  226. #define LDBBPPCR_AP_MASK (0xff << 24)
  227. #define LDBBPPCR_AP_SHIFT 24
  228. #define LDBBPPCR_R_MASK (0xff << 16)
  229. #define LDBBPPCR_R_SHIFT 16
  230. #define LDBBPPCR_GY_MASK (0xff << 8)
  231. #define LDBBPPCR_GY_SHIFT 8
  232. #define LDBBPPCR_B_MASK (0xff << 0)
  233. #define LDBBPPCR_B_SHIFT 0
  234. #define LDBnBBGCL(n) (0xb10 + (n) * 0x04)
  235. #define LDBBBGCL_BGA_MASK (0xff << 24)
  236. #define LDBBBGCL_BGA_SHIFT 24
  237. #define LDBBBGCL_BGR_MASK (0xff << 16)
  238. #define LDBBBGCL_BGR_SHIFT 16
  239. #define LDBBBGCL_BGG_MASK (0xff << 8)
  240. #define LDBBBGCL_BGG_SHIFT 8
  241. #define LDBBBGCL_BGB_MASK (0xff << 0)
  242. #define LDBBBGCL_BGB_SHIFT 0
  243. #define LCDC_SIDE_B_OFFSET 0x1000
  244. #define LCDC_MIRROR_OFFSET 0x2000
  245. static inline bool lcdc_is_banked(u32 reg)
  246. {
  247. switch (reg) {
  248. case LDMT1R:
  249. case LDMT2R:
  250. case LDMT3R:
  251. case LDDFR:
  252. case LDSM1R:
  253. case LDSA1R:
  254. case LDSA2R:
  255. case LDMLSR:
  256. case LDWBFR:
  257. case LDWBCNTR:
  258. case LDWBAR:
  259. case LDHCNR:
  260. case LDHSYNR:
  261. case LDVLNR:
  262. case LDVSYNR:
  263. case LDHPDR:
  264. case LDVPDR:
  265. case LDHAJR:
  266. return true;
  267. default:
  268. return reg >= LDBnBBGCL(0) && reg <= LDBnBPPCR(3);
  269. }
  270. }
  271. static inline void lcdc_write_mirror(struct shmob_drm_device *sdev, u32 reg,
  272. u32 data)
  273. {
  274. iowrite32(data, sdev->mmio + reg + LCDC_MIRROR_OFFSET);
  275. }
  276. static inline void lcdc_write(struct shmob_drm_device *sdev, u32 reg, u32 data)
  277. {
  278. iowrite32(data, sdev->mmio + reg);
  279. if (lcdc_is_banked(reg))
  280. iowrite32(data, sdev->mmio + reg + LCDC_SIDE_B_OFFSET);
  281. }
  282. static inline u32 lcdc_read(struct shmob_drm_device *sdev, u32 reg)
  283. {
  284. return ioread32(sdev->mmio + reg);
  285. }
  286. static inline int lcdc_wait_bit(struct shmob_drm_device *sdev, u32 reg,
  287. u32 mask, u32 until)
  288. {
  289. unsigned long timeout = jiffies + msecs_to_jiffies(5);
  290. while ((lcdc_read(sdev, reg) & mask) != until) {
  291. if (time_after(jiffies, timeout))
  292. return -ETIMEDOUT;
  293. cpu_relax();
  294. }
  295. return 0;
  296. }
  297. #endif /* __SHMOB_DRM_REGS_H__ */