kirin_ade_reg.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*
  2. * Copyright (c) 2016 Linaro Limited.
  3. * Copyright (c) 2014-2016 Hisilicon Limited.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. */
  10. #ifndef __KIRIN_ADE_REG_H__
  11. #define __KIRIN_ADE_REG_H__
  12. /*
  13. * ADE Registers
  14. */
  15. #define MASK(x) (BIT(x) - 1)
  16. #define ADE_CTRL 0x0004
  17. #define FRM_END_START_OFST 0
  18. #define FRM_END_START_MASK MASK(2)
  19. #define AUTO_CLK_GATE_EN_OFST 0
  20. #define AUTO_CLK_GATE_EN BIT(0)
  21. #define ADE_DISP_SRC_CFG 0x0018
  22. #define ADE_CTRL1 0x008C
  23. #define ADE_EN 0x0100
  24. #define ADE_DISABLE 0
  25. #define ADE_ENABLE 1
  26. /* reset and reload regs */
  27. #define ADE_SOFT_RST_SEL(x) (0x0078 + (x) * 0x4)
  28. #define ADE_RELOAD_DIS(x) (0x00AC + (x) * 0x4)
  29. #define RDMA_OFST 0
  30. #define CLIP_OFST 15
  31. #define SCL_OFST 21
  32. #define CTRAN_OFST 24
  33. #define OVLY_OFST 37 /* 32+5 */
  34. /* channel regs */
  35. #define RD_CH_CTRL(x) (0x1004 + (x) * 0x80)
  36. #define RD_CH_ADDR(x) (0x1008 + (x) * 0x80)
  37. #define RD_CH_SIZE(x) (0x100C + (x) * 0x80)
  38. #define RD_CH_STRIDE(x) (0x1010 + (x) * 0x80)
  39. #define RD_CH_SPACE(x) (0x1014 + (x) * 0x80)
  40. #define RD_CH_EN(x) (0x1020 + (x) * 0x80)
  41. /* overlay regs */
  42. #define ADE_OVLY1_TRANS_CFG 0x002C
  43. #define ADE_OVLY_CTL 0x0098
  44. #define ADE_OVLY_CH_XY0(x) (0x2004 + (x) * 4)
  45. #define ADE_OVLY_CH_XY1(x) (0x2024 + (x) * 4)
  46. #define ADE_OVLY_CH_CTL(x) (0x204C + (x) * 4)
  47. #define ADE_OVLY_OUTPUT_SIZE(x) (0x2070 + (x) * 8)
  48. #define OUTPUT_XSIZE_OFST 16
  49. #define ADE_OVLYX_CTL(x) (0x209C + (x) * 4)
  50. #define CH_OVLY_SEL_OFST(x) ((x) * 4)
  51. #define CH_OVLY_SEL_MASK MASK(2)
  52. #define CH_OVLY_SEL_VAL(x) ((x) + 1)
  53. #define CH_ALP_MODE_OFST 0
  54. #define CH_ALP_SEL_OFST 2
  55. #define CH_UNDER_ALP_SEL_OFST 4
  56. #define CH_EN_OFST 6
  57. #define CH_ALP_GBL_OFST 15
  58. #define CH_SEL_OFST 28
  59. /* ctran regs */
  60. #define ADE_CTRAN_DIS(x) (0x5004 + (x) * 0x100)
  61. #define CTRAN_BYPASS_ON 1
  62. #define CTRAN_BYPASS_OFF 0
  63. #define ADE_CTRAN_IMAGE_SIZE(x) (0x503C + (x) * 0x100)
  64. /* clip regs */
  65. #define ADE_CLIP_DISABLE(x) (0x6800 + (x) * 0x100)
  66. #define ADE_CLIP_SIZE0(x) (0x6804 + (x) * 0x100)
  67. #define ADE_CLIP_SIZE1(x) (0x6808 + (x) * 0x100)
  68. /*
  69. * LDI Registers
  70. */
  71. #define LDI_HRZ_CTRL0 0x7400
  72. #define HBP_OFST 20
  73. #define LDI_HRZ_CTRL1 0x7404
  74. #define LDI_VRT_CTRL0 0x7408
  75. #define VBP_OFST 20
  76. #define LDI_VRT_CTRL1 0x740C
  77. #define LDI_PLR_CTRL 0x7410
  78. #define FLAG_NVSYNC BIT(0)
  79. #define FLAG_NHSYNC BIT(1)
  80. #define FLAG_NPIXCLK BIT(2)
  81. #define FLAG_NDE BIT(3)
  82. #define LDI_DSP_SIZE 0x7414
  83. #define VSIZE_OFST 20
  84. #define LDI_INT_EN 0x741C
  85. #define FRAME_END_INT_EN_OFST 1
  86. #define LDI_CTRL 0x7420
  87. #define BPP_OFST 3
  88. #define DATA_GATE_EN BIT(2)
  89. #define LDI_EN BIT(0)
  90. #define LDI_MSK_INT 0x7428
  91. #define LDI_INT_CLR 0x742C
  92. #define LDI_WORK_MODE 0x7430
  93. #define LDI_HDMI_DSI_GT 0x7434
  94. /*
  95. * ADE media bus service regs
  96. */
  97. #define ADE0_QOSGENERATOR_MODE 0x010C
  98. #define QOSGENERATOR_MODE_MASK MASK(2)
  99. #define ADE0_QOSGENERATOR_EXTCONTROL 0x0118
  100. #define SOCKET_QOS_EN BIT(0)
  101. #define ADE1_QOSGENERATOR_MODE 0x020C
  102. #define ADE1_QOSGENERATOR_EXTCONTROL 0x0218
  103. /*
  104. * ADE regs relevant enums
  105. */
  106. enum frame_end_start {
  107. /* regs take effect in every vsync */
  108. REG_EFFECTIVE_IN_VSYNC = 0,
  109. /* regs take effect in fist ade en and every frame end */
  110. REG_EFFECTIVE_IN_ADEEN_FRMEND,
  111. /* regs take effect in ade en immediately */
  112. REG_EFFECTIVE_IN_ADEEN,
  113. /* regs take effect in first vsync and every frame end */
  114. REG_EFFECTIVE_IN_VSYNC_FRMEND
  115. };
  116. enum ade_fb_format {
  117. ADE_RGB_565 = 0,
  118. ADE_BGR_565,
  119. ADE_XRGB_8888,
  120. ADE_XBGR_8888,
  121. ADE_ARGB_8888,
  122. ADE_ABGR_8888,
  123. ADE_RGBA_8888,
  124. ADE_BGRA_8888,
  125. ADE_RGB_888,
  126. ADE_BGR_888 = 9,
  127. ADE_FORMAT_UNSUPPORT = 800
  128. };
  129. enum ade_channel {
  130. ADE_CH1 = 0, /* channel 1 for primary plane */
  131. ADE_CH_NUM
  132. };
  133. enum ade_scale {
  134. ADE_SCL1 = 0,
  135. ADE_SCL2,
  136. ADE_SCL3,
  137. ADE_SCL_NUM
  138. };
  139. enum ade_ctran {
  140. ADE_CTRAN1 = 0,
  141. ADE_CTRAN2,
  142. ADE_CTRAN3,
  143. ADE_CTRAN4,
  144. ADE_CTRAN5,
  145. ADE_CTRAN6,
  146. ADE_CTRAN_NUM
  147. };
  148. enum ade_overlay {
  149. ADE_OVLY1 = 0,
  150. ADE_OVLY2,
  151. ADE_OVLY3,
  152. ADE_OVLY_NUM
  153. };
  154. enum ade_alpha_mode {
  155. ADE_ALP_GLOBAL = 0,
  156. ADE_ALP_PIXEL,
  157. ADE_ALP_PIXEL_AND_GLB
  158. };
  159. enum ade_alpha_blending_mode {
  160. ADE_ALP_MUL_COEFF_0 = 0, /* alpha */
  161. ADE_ALP_MUL_COEFF_1, /* 1-alpha */
  162. ADE_ALP_MUL_COEFF_2, /* 0 */
  163. ADE_ALP_MUL_COEFF_3 /* 1 */
  164. };
  165. /*
  166. * LDI regs relevant enums
  167. */
  168. enum dsi_pclk_en {
  169. DSI_PCLK_ON = 0,
  170. DSI_PCLK_OFF
  171. };
  172. enum ldi_output_format {
  173. LDI_OUT_RGB_565 = 0,
  174. LDI_OUT_RGB_666,
  175. LDI_OUT_RGB_888
  176. };
  177. enum ldi_work_mode {
  178. TEST_MODE = 0,
  179. NORMAL_MODE
  180. };
  181. enum ldi_input_source {
  182. DISP_SRC_NONE = 0,
  183. DISP_SRC_OVLY2,
  184. DISP_SRC_DISP,
  185. DISP_SRC_ROT,
  186. DISP_SRC_SCL2
  187. };
  188. /*
  189. * ADE media bus service relevant enums
  190. */
  191. enum qos_generator_mode {
  192. FIXED_MODE = 0,
  193. LIMITER_MODE,
  194. BYPASS_MODE,
  195. REGULATOR_MODE
  196. };
  197. /*
  198. * Register Write/Read Helper functions
  199. */
  200. static inline void ade_update_bits(void __iomem *addr, u32 bit_start,
  201. u32 mask, u32 val)
  202. {
  203. u32 tmp, orig;
  204. orig = readl(addr);
  205. tmp = orig & ~(mask << bit_start);
  206. tmp |= (val & mask) << bit_start;
  207. writel(tmp, addr);
  208. }
  209. #endif