smi_variant_config_8127.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. #include <linux/of.h>
  2. #include <linux/of_irq.h>
  3. #include <linux/of_address.h>
  4. #include <linux/kobject.h>
  5. #include <linux/uaccess.h>
  6. #include <linux/module.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/cdev.h>
  9. #include <linux/mm.h>
  10. #include <linux/vmalloc.h>
  11. #include <linux/slab.h>
  12. #include <linux/clk.h>
  13. #include <linux/io.h>
  14. #include "smi_reg.h"
  15. #include "smi_common.h"
  16. #include "smi_priv.h"
  17. #define SMI_LARB0_PORT_NUM 10
  18. #define SMI_LARB1_PORT_NUM 7
  19. #define SMI_LARB2_PORT_NUM 17
  20. static void initSetting(struct mtk_smi_data *smidev, bool *default_saved,
  21. u32 *default_smi_val, unsigned int larbid)
  22. {
  23. SMIMSG("Current Setting: GPU - new");
  24. if (!SMI_COMMON_EXT_BASE || !LARB0_BASE) {
  25. SMIMSG("smi and smi_larb should have been probe first\n");
  26. return;
  27. }
  28. /* 2 non-ultra write, 3 write command , 4 non-ultra read , 5 ultra read */
  29. M4U_WriteReg32(REG_SMI_M4U_TH, 0, ((0x3 << 15) + (0x4 << 10) + (0x4 << 5) + 0x5));
  30. /*
  31. * Level 1 LARB, apply new outstanding control method, 1/4 bandwidth
  32. * limiter overshoot control , enable warb channel
  33. */
  34. M4U_WriteReg32(REG_SMI_L1LEN, 0, 0xB);
  35. /*
  36. * total 8 commnads between smi common to M4U, 12 non ultra commands
  37. * between smi common to M4U, 1 commnads can in write AXI slice for all LARBs
  38. */
  39. M4U_WriteReg32(REG_SMI_READ_FIFO_TH, 0, ((0x7 << 11) + (0x8 << 6) + 0x3F));
  40. M4U_WriteReg32(LARB0_BASE, 0x200, 0xC); /* DISP_OVL_0 */
  41. M4U_WriteReg32(LARB0_BASE, 0x204, 0x1); /* DISP_RDMA_1 */
  42. M4U_WriteReg32(LARB0_BASE, 0x208, 0x1); /* DISP_RDMA */
  43. M4U_WriteReg32(LARB0_BASE, 0x20C, 0x2); /* DISP_WDMA */
  44. M4U_WriteReg32(LARB0_BASE, 0x210, 0x1); /* MM_CMDQ */
  45. M4U_WriteReg32(LARB0_BASE, 0x214, 0x5); /* MDP_RDMA */
  46. M4U_WriteReg32(LARB0_BASE, 0x218, 0x1); /* MDP_WDMA */
  47. M4U_WriteReg32(LARB0_BASE, 0x21C, 0x3); /* MDP_ROT */
  48. M4U_WriteReg32(LARB0_BASE, 0x220, 0x1); /* MDP_ROTCO */
  49. M4U_WriteReg32(LARB0_BASE, 0x224, 0x1); /* MDP ROTVO */
  50. M4U_WriteReg32(LARB1_BASE, 0x200, 0x1); /* HW_VDEC_MC_EXT */
  51. M4U_WriteReg32(LARB1_BASE, 0x204, 0x1); /* HW_VDEC_PP_EXT */
  52. M4U_WriteReg32(LARB1_BASE, 0x208, 0x1); /* HW_VDEC_AVC_MV-EXT */
  53. M4U_WriteReg32(LARB1_BASE, 0x20C, 0x1); /* HW_VDEC_PRED_RD_EXT */
  54. M4U_WriteReg32(LARB1_BASE, 0x210, 0x1); /* HW_VDEC_PRED_WR_EXT */
  55. M4U_WriteReg32(LARB1_BASE, 0x214, 0x1); /* HW_VDEC_VLD_EXT */
  56. M4U_WriteReg32(LARB1_BASE, 0x218, 0x1); /* HW_VDEC_PP_INT */
  57. M4U_WriteReg32(LARB2_BASE, 0x200, 0x1); /* CAM_IMGO */
  58. M4U_WriteReg32(LARB2_BASE, 0x204, 0x1); /* CAM_IMG2O */
  59. M4U_WriteReg32(LARB2_BASE, 0x208, 0x1); /* CAM_LSCI */
  60. M4U_WriteReg32(LARB2_BASE, 0x20C, 0x1); /* CAM_IMGI */
  61. M4U_WriteReg32(LARB2_BASE, 0x210, 0x1); /* CAM_ESFKO */
  62. M4U_WriteReg32(LARB2_BASE, 0x214, 0x1); /* CAM_AAO */
  63. M4U_WriteReg32(LARB2_BASE, 0x218, 0x1); /* CAM_LCEI */
  64. M4U_WriteReg32(LARB2_BASE, 0x21C, 0x1); /* CAM_LCSO */
  65. M4U_WriteReg32(LARB2_BASE, 0x220, 0x1); /* JPGENC_RDMA */
  66. M4U_WriteReg32(LARB2_BASE, 0x224, 0x1); /* JPGENC_BSDMA */
  67. M4U_WriteReg32(LARB2_BASE, 0x228, 0x1); /* VENC_SV_COMV */
  68. M4U_WriteReg32(LARB2_BASE, 0x22C, 0x1); /* VENC_RD_COMV */
  69. M4U_WriteReg32(LARB2_BASE, 0x230, 0x1); /* VENC_RCPU */
  70. M4U_WriteReg32(LARB2_BASE, 0x234, 0x1); /* VENC_REC_FRM */
  71. M4U_WriteReg32(LARB2_BASE, 0x238, 0x1); /* VENC_REF_LUMA */
  72. M4U_WriteReg32(LARB2_BASE, 0x23C, 0x1); /* VENC_REF_CHROMA */
  73. M4U_WriteReg32(LARB2_BASE, 0x244, 0x1); /* VENC_BSDMA */
  74. M4U_WriteReg32(LARB2_BASE, 0x248, 0x1); /* VENC_CUR_LUMA */
  75. M4U_WriteReg32(LARB2_BASE, 0x24C, 0x1); /* VENC_CUR_CHROMA */
  76. }
  77. static void vpSetting(struct mtk_smi_data *smidev)
  78. {
  79. /* 2 non-ultra write, 3 write command , 4 non-ultra read , 5 ultra read */
  80. M4U_WriteReg32(REG_SMI_M4U_TH, 0, ((0x2 << 15) + (0x3 << 10) + (0x4 << 5) + 0x5));
  81. /*
  82. * Level 1 LARB, apply new outstanding control method, 1/4 bandwidth limiter
  83. * overshoot control , enable warb channel
  84. */
  85. M4U_WriteReg32(REG_SMI_L1LEN, 0, 0x1B);
  86. /*
  87. * total 8 commnads between smi common to M4U, 12 non ultra commands
  88. * between smi common to M4U, 1 commnads can in write AXI slice for all LARBs
  89. */
  90. M4U_WriteReg32(REG_SMI_READ_FIFO_TH, 0, 0x323F);
  91. M4U_WriteReg32(REG_SMI_L1ARB0, 0, 0xC3A); /* 1111/4096 maximum grant counts, soft limiter */
  92. M4U_WriteReg32(REG_SMI_L1ARB1, 0, 0x9E8); /* 503/4096 maximum grant counts, soft limiter */
  93. M4U_WriteReg32(REG_SMI_L1ARB2, 0, 0x943); /* 353/4096 maximum grant counts, soft limiter */
  94. M4U_WriteReg32(LARB0_BASE, 0x200, 0xC); /* DISP_OVL_0 */
  95. M4U_WriteReg32(LARB0_BASE, 0x204, 0x1); /* DISP_RDMA_1 */
  96. M4U_WriteReg32(LARB0_BASE, 0x208, 0x1); /* DISP_RDMA */
  97. M4U_WriteReg32(LARB0_BASE, 0x20C, 0x2); /* DISP_WDMA */
  98. M4U_WriteReg32(LARB0_BASE, 0x210, 0x1); /* MM_CMDQ */
  99. M4U_WriteReg32(LARB0_BASE, 0x214, 0x5); /* MDP_RDMA */
  100. M4U_WriteReg32(LARB0_BASE, 0x218, 0x1); /* MDP_WDMA */
  101. M4U_WriteReg32(LARB0_BASE, 0x21C, 0x3); /* MDP_ROT */
  102. M4U_WriteReg32(LARB0_BASE, 0x220, 0x1); /* MDP_ROTCO */
  103. M4U_WriteReg32(LARB0_BASE, 0x224, 0x1); /* MDP ROTVO */
  104. M4U_WriteReg32(LARB1_BASE, 0x200, 0x6); /* HW_VDEC_MC_EXT */
  105. M4U_WriteReg32(LARB1_BASE, 0x204, 0x2); /* HW_VDEC_PP_EXT */
  106. M4U_WriteReg32(LARB1_BASE, 0x208, 0x1); /* HW_VDEC_AVC_MV-EXT */
  107. M4U_WriteReg32(LARB1_BASE, 0x20C, 0x3); /* HW_VDEC_PRED_RD_EXT */
  108. M4U_WriteReg32(LARB1_BASE, 0x210, 0x3); /* HW_VDEC_PRED_WR_EXT */
  109. M4U_WriteReg32(LARB1_BASE, 0x214, 0x1); /* HW_VDEC_VLD_EXT */
  110. M4U_WriteReg32(LARB1_BASE, 0x218, 0x1); /* HW_VDEC_PP_INT */
  111. M4U_WriteReg32(LARB2_BASE, 0x200, 0x1); /* CAM_IMGO */
  112. M4U_WriteReg32(LARB2_BASE, 0x204, 0x1); /* CAM_IMG2O */
  113. M4U_WriteReg32(LARB2_BASE, 0x208, 0x1); /* CAM_LSCI */
  114. M4U_WriteReg32(LARB2_BASE, 0x20C, 0x1); /* CAM_IMGI */
  115. M4U_WriteReg32(LARB2_BASE, 0x210, 0x1); /* CAM_ESFKO */
  116. M4U_WriteReg32(LARB2_BASE, 0x214, 0x1); /* CAM_AAO */
  117. M4U_WriteReg32(LARB2_BASE, 0x218, 0x1); /* CAM_LCEI */
  118. M4U_WriteReg32(LARB2_BASE, 0x21C, 0x1); /* CAM_LCSO */
  119. M4U_WriteReg32(LARB2_BASE, 0x220, 0x1); /* JPGENC_RDMA */
  120. M4U_WriteReg32(LARB2_BASE, 0x224, 0x1); /* JPGENC_BSDMA */
  121. M4U_WriteReg32(LARB2_BASE, 0x228, 0x1); /* VENC_SV_COMV */
  122. M4U_WriteReg32(LARB2_BASE, 0x22C, 0x1); /* VENC_RD_COMV */
  123. M4U_WriteReg32(LARB2_BASE, 0x230, 0x1); /* VENC_RCPU */
  124. M4U_WriteReg32(LARB2_BASE, 0x234, 0x1); /* VENC_REC_FRM */
  125. M4U_WriteReg32(LARB2_BASE, 0x238, 0x1); /* VENC_REF_LUMA */
  126. M4U_WriteReg32(LARB2_BASE, 0x23C, 0x1); /* VENC_REF_CHROMA */
  127. M4U_WriteReg32(LARB2_BASE, 0x244, 0x1); /* VENC_BSDMA */
  128. M4U_WriteReg32(LARB2_BASE, 0x248, 0x1); /* VENC_CUR_LUMA */
  129. M4U_WriteReg32(LARB2_BASE, 0x24C, 0x1); /* VENC_CUR_CHROMA */
  130. }
  131. static void vrSetting(struct mtk_smi_data *smidev)
  132. {
  133. /* 2 non-ultra write, 3 write command , 4 non-ultra read , 5 ultra read */
  134. M4U_WriteReg32(REG_SMI_M4U_TH, 0, ((0x2 << 15) + (0x3 << 10) + (0x4 << 5) + 0x5));
  135. /*
  136. * Level 1 LARB, apply new outstanding control method, 1/4 bandwidth limiter
  137. * overshoot control , enable warb channel
  138. */
  139. M4U_WriteReg32(REG_SMI_L1LEN, 0, 0xB);
  140. /*
  141. * total 8 commnads between smi common to M4U, 12 non ultra commands between smi common
  142. * to M4U, 1 commnads can in write AXI slice for all LARBs
  143. */
  144. M4U_WriteReg32(REG_SMI_READ_FIFO_TH, 0, ((0x6 << 11) + (0x8 << 6) + 0x3F));
  145. M4U_WriteReg32(REG_SMI_L1ARB0, 0, 0xC26); /* 1111/4096 maximum grant counts, soft limiter */
  146. M4U_WriteReg32(REG_SMI_L1ARB1, 0, 0x943); /* 503/4096 maximum grant counts, soft limiter */
  147. M4U_WriteReg32(REG_SMI_L1ARB2, 0, 0xD4F); /* 1359/4096 maximum grant counts, soft limiter */
  148. M4U_WriteReg32(LARB0_BASE, 0x200, 0xC); /* DISP_OVL_0 */
  149. M4U_WriteReg32(LARB0_BASE, 0x204, 0x1); /* DISP_RDMA_1 */
  150. M4U_WriteReg32(LARB0_BASE, 0x208, 0x1); /* DISP_RDMA */
  151. M4U_WriteReg32(LARB0_BASE, 0x20C, 0x1); /* DISP_WDMA */
  152. M4U_WriteReg32(LARB0_BASE, 0x210, 0x1); /* MM_CMDQ */
  153. M4U_WriteReg32(LARB0_BASE, 0x214, 0x2); /* MDP_RDMA */
  154. M4U_WriteReg32(LARB0_BASE, 0x218, 0x2); /* MDP_WDMA */
  155. M4U_WriteReg32(LARB0_BASE, 0x21C, 0x4); /* MDP_ROT */
  156. M4U_WriteReg32(LARB0_BASE, 0x220, 0x2); /* MDP_ROTCO */
  157. M4U_WriteReg32(LARB0_BASE, 0x224, 0x2); /* MDP ROTVO */
  158. M4U_WriteReg32(LARB1_BASE, 0x200, 0x1); /* HW_VDEC_MC_EXT */
  159. M4U_WriteReg32(LARB1_BASE, 0x204, 0x1); /* HW_VDEC_PP_EXT */
  160. M4U_WriteReg32(LARB1_BASE, 0x208, 0x1); /* HW_VDEC_AVC_MV-EXT */
  161. M4U_WriteReg32(LARB1_BASE, 0x20C, 0x1); /* HW_VDEC_PRED_RD_EXT */
  162. M4U_WriteReg32(LARB1_BASE, 0x210, 0x1); /* HW_VDEC_PRED_WR_EXT */
  163. M4U_WriteReg32(LARB1_BASE, 0x214, 0x1); /* HW_VDEC_VLD_EXT */
  164. M4U_WriteReg32(LARB1_BASE, 0x218, 0x1); /* HW_VDEC_PP_INT */
  165. M4U_WriteReg32(LARB2_BASE, 0x200, 0x6); /* CAM_IMGO */
  166. M4U_WriteReg32(LARB2_BASE, 0x204, 0x1); /* CAM_IMG2O */
  167. M4U_WriteReg32(LARB2_BASE, 0x208, 0x1); /* CAM_LSCI */
  168. M4U_WriteReg32(LARB2_BASE, 0x20C, 0x4); /* CAM_IMGI */
  169. M4U_WriteReg32(LARB2_BASE, 0x210, 0x1); /* CAM_ESFKO */
  170. M4U_WriteReg32(LARB2_BASE, 0x214, 0x1); /* CAM_AAO */
  171. M4U_WriteReg32(LARB2_BASE, 0x218, 0x1); /* CAM_LCEI */
  172. M4U_WriteReg32(LARB2_BASE, 0x21C, 0x1); /* CAM_LCSO */
  173. M4U_WriteReg32(LARB2_BASE, 0x220, 0x1); /* JPGENC_RDMA */
  174. M4U_WriteReg32(LARB2_BASE, 0x224, 0x1); /* JPGENC_BSDMA */
  175. M4U_WriteReg32(LARB2_BASE, 0x228, 0x1); /* VENC_SV_COMV */
  176. M4U_WriteReg32(LARB2_BASE, 0x22C, 0x1); /* VENC_RD_COMV */
  177. M4U_WriteReg32(LARB2_BASE, 0x230, 0x1); /* VENC_RCPU */
  178. M4U_WriteReg32(LARB2_BASE, 0x234, 0x2); /* VENC_REC_FRM */
  179. M4U_WriteReg32(LARB2_BASE, 0x238, 0x4); /* VENC_REF_LUMA */
  180. M4U_WriteReg32(LARB2_BASE, 0x23C, 0x2); /* VENC_REF_CHROMA */
  181. M4U_WriteReg32(LARB2_BASE, 0x244, 0x1); /* VENC_BSDMA */
  182. M4U_WriteReg32(LARB2_BASE, 0x248, 0x2); /* VENC_CUR_LUMA */
  183. M4U_WriteReg32(LARB2_BASE, 0x24C, 0x1); /* VENC_CUR_CHROMA */
  184. }
  185. static void hdmiSetting(struct mtk_smi_data *smidev)
  186. {
  187. }
  188. static void hdmi4kSetting(struct mtk_smi_data *smidev)
  189. {
  190. }
  191. const struct mtk_smi_priv smi_mt8127_priv = {
  192. .larb_port_num = { SMI_LARB0_PORT_NUM, SMI_LARB1_PORT_NUM, SMI_LARB2_PORT_NUM },
  193. .init_setting = initSetting,
  194. .vp_setting = vpSetting,
  195. .vr_setting = vrSetting,
  196. .hdmi_setting = hdmiSetting,
  197. .hdmi_4k_setting = hdmi4kSetting,
  198. };