dsi_cfg.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * Copyright (c) 2015, The Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #include "dsi_cfg.h"
  14. static const char * const dsi_v2_bus_clk_names[] = {
  15. "core_mmss", "iface", "bus",
  16. };
  17. static const struct msm_dsi_config apq8064_dsi_cfg = {
  18. .io_offset = 0,
  19. .reg_cfg = {
  20. .num = 3,
  21. .regs = {
  22. {"vdda", 100000, 100}, /* 1.2 V */
  23. {"avdd", 10000, 100}, /* 3.0 V */
  24. {"vddio", 100000, 100}, /* 1.8 V */
  25. },
  26. },
  27. .bus_clk_names = dsi_v2_bus_clk_names,
  28. .num_bus_clks = ARRAY_SIZE(dsi_v2_bus_clk_names),
  29. .io_start = { 0x4700000, 0x5800000 },
  30. .num_dsi = 2,
  31. };
  32. static const char * const dsi_6g_bus_clk_names[] = {
  33. "mdp_core", "iface", "bus", "core_mmss",
  34. };
  35. static const struct msm_dsi_config msm8974_apq8084_dsi_cfg = {
  36. .io_offset = DSI_6G_REG_SHIFT,
  37. .reg_cfg = {
  38. .num = 4,
  39. .regs = {
  40. {"gdsc", -1, -1},
  41. {"vdd", 150000, 100}, /* 3.0 V */
  42. {"vdda", 100000, 100}, /* 1.2 V */
  43. {"vddio", 100000, 100}, /* 1.8 V */
  44. },
  45. },
  46. .bus_clk_names = dsi_6g_bus_clk_names,
  47. .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
  48. .io_start = { 0xfd922800, 0xfd922b00 },
  49. .num_dsi = 2,
  50. };
  51. static const char * const dsi_8916_bus_clk_names[] = {
  52. "mdp_core", "iface", "bus",
  53. };
  54. static const struct msm_dsi_config msm8916_dsi_cfg = {
  55. .io_offset = DSI_6G_REG_SHIFT,
  56. .reg_cfg = {
  57. .num = 3,
  58. .regs = {
  59. {"gdsc", -1, -1},
  60. {"vdda", 100000, 100}, /* 1.2 V */
  61. {"vddio", 100000, 100}, /* 1.8 V */
  62. },
  63. },
  64. .bus_clk_names = dsi_8916_bus_clk_names,
  65. .num_bus_clks = ARRAY_SIZE(dsi_8916_bus_clk_names),
  66. .io_start = { 0x1a98000 },
  67. .num_dsi = 1,
  68. };
  69. static const struct msm_dsi_config msm8994_dsi_cfg = {
  70. .io_offset = DSI_6G_REG_SHIFT,
  71. .reg_cfg = {
  72. .num = 7,
  73. .regs = {
  74. {"gdsc", -1, -1},
  75. {"vdda", 100000, 100}, /* 1.25 V */
  76. {"vddio", 100000, 100}, /* 1.8 V */
  77. {"vcca", 10000, 100}, /* 1.0 V */
  78. {"vdd", 100000, 100}, /* 1.8 V */
  79. {"lab_reg", -1, -1},
  80. {"ibb_reg", -1, -1},
  81. },
  82. },
  83. .bus_clk_names = dsi_6g_bus_clk_names,
  84. .num_bus_clks = ARRAY_SIZE(dsi_6g_bus_clk_names),
  85. .io_start = { 0xfd998000, 0xfd9a0000 },
  86. .num_dsi = 2,
  87. };
  88. /*
  89. * TODO: core_mmss_clk fails to enable for some reason, but things work fine
  90. * without it too. Figure out why it doesn't enable and uncomment below
  91. */
  92. static const char * const dsi_8996_bus_clk_names[] = {
  93. "mdp_core", "iface", "bus", /* "core_mmss", */
  94. };
  95. static const struct msm_dsi_config msm8996_dsi_cfg = {
  96. .io_offset = DSI_6G_REG_SHIFT,
  97. .reg_cfg = {
  98. .num = 2,
  99. .regs = {
  100. {"vdda", 18160, 1 }, /* 1.25 V */
  101. {"vcca", 17000, 32 }, /* 0.925 V */
  102. {"vddio", 100000, 100 },/* 1.8 V */
  103. },
  104. },
  105. .bus_clk_names = dsi_8996_bus_clk_names,
  106. .num_bus_clks = ARRAY_SIZE(dsi_8996_bus_clk_names),
  107. .io_start = { 0x994000, 0x996000 },
  108. .num_dsi = 2,
  109. };
  110. static const char * const dsi_sdm845_bus_clk_names[] = {
  111. "iface", "bus",
  112. };
  113. static const struct msm_dsi_config sdm845_dsi_cfg = {
  114. .io_offset = DSI_6G_REG_SHIFT,
  115. .reg_cfg = {
  116. .num = 1,
  117. .regs = {
  118. {"vdda", 21800, 4 }, /* 1.2 V */
  119. },
  120. },
  121. .bus_clk_names = dsi_sdm845_bus_clk_names,
  122. .num_bus_clks = ARRAY_SIZE(dsi_sdm845_bus_clk_names),
  123. .io_start = { 0xae94000, 0xae96000 },
  124. .num_dsi = 2,
  125. };
  126. const static struct msm_dsi_host_cfg_ops msm_dsi_v2_host_ops = {
  127. .link_clk_enable = dsi_link_clk_enable_v2,
  128. .link_clk_disable = dsi_link_clk_disable_v2,
  129. .clk_init_ver = dsi_clk_init_v2,
  130. .tx_buf_alloc = dsi_tx_buf_alloc_v2,
  131. .tx_buf_get = dsi_tx_buf_get_v2,
  132. .tx_buf_put = NULL,
  133. .dma_base_get = dsi_dma_base_get_v2,
  134. .calc_clk_rate = dsi_calc_clk_rate_v2,
  135. };
  136. const static struct msm_dsi_host_cfg_ops msm_dsi_6g_host_ops = {
  137. .link_clk_enable = dsi_link_clk_enable_6g,
  138. .link_clk_disable = dsi_link_clk_disable_6g,
  139. .clk_init_ver = NULL,
  140. .tx_buf_alloc = dsi_tx_buf_alloc_6g,
  141. .tx_buf_get = dsi_tx_buf_get_6g,
  142. .tx_buf_put = dsi_tx_buf_put_6g,
  143. .dma_base_get = dsi_dma_base_get_6g,
  144. .calc_clk_rate = dsi_calc_clk_rate_6g,
  145. };
  146. const static struct msm_dsi_host_cfg_ops msm_dsi_6g_v2_host_ops = {
  147. .link_clk_enable = dsi_link_clk_enable_6g,
  148. .link_clk_disable = dsi_link_clk_disable_6g,
  149. .clk_init_ver = dsi_clk_init_6g_v2,
  150. .tx_buf_alloc = dsi_tx_buf_alloc_6g,
  151. .tx_buf_get = dsi_tx_buf_get_6g,
  152. .tx_buf_put = dsi_tx_buf_put_6g,
  153. .dma_base_get = dsi_dma_base_get_6g,
  154. .calc_clk_rate = dsi_calc_clk_rate_6g,
  155. };
  156. static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = {
  157. {MSM_DSI_VER_MAJOR_V2, MSM_DSI_V2_VER_MINOR_8064,
  158. &apq8064_dsi_cfg, &msm_dsi_v2_host_ops},
  159. {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_0,
  160. &msm8974_apq8084_dsi_cfg, &msm_dsi_6g_host_ops},
  161. {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_1,
  162. &msm8974_apq8084_dsi_cfg, &msm_dsi_6g_host_ops},
  163. {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_1_1,
  164. &msm8974_apq8084_dsi_cfg, &msm_dsi_6g_host_ops},
  165. {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_2,
  166. &msm8974_apq8084_dsi_cfg, &msm_dsi_6g_host_ops},
  167. {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_3,
  168. &msm8994_dsi_cfg, &msm_dsi_6g_host_ops},
  169. {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_3_1,
  170. &msm8916_dsi_cfg, &msm_dsi_6g_host_ops},
  171. {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V1_4_1,
  172. &msm8996_dsi_cfg, &msm_dsi_6g_host_ops},
  173. {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_2_1,
  174. &sdm845_dsi_cfg, &msm_dsi_6g_v2_host_ops},
  175. };
  176. const struct msm_dsi_cfg_handler *msm_dsi_cfg_get(u32 major, u32 minor)
  177. {
  178. const struct msm_dsi_cfg_handler *cfg_hnd = NULL;
  179. int i;
  180. for (i = ARRAY_SIZE(dsi_cfg_handlers) - 1; i >= 0; i--) {
  181. if ((dsi_cfg_handlers[i].major == major) &&
  182. (dsi_cfg_handlers[i].minor == minor)) {
  183. cfg_hnd = &dsi_cfg_handlers[i];
  184. break;
  185. }
  186. }
  187. return cfg_hnd;
  188. }