debugcc-sm6150.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #define pr_fmt(fmt) "clk: %s: " fmt, __func__
  7. #include <linux/clk.h>
  8. #include <linux/clk-provider.h>
  9. #include <linux/err.h>
  10. #include <linux/kernel.h>
  11. #include <linux/mfd/syscon.h>
  12. #include <linux/module.h>
  13. #include <linux/of.h>
  14. #include <linux/of_device.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/regmap.h>
  17. #include "clk-debug.h"
  18. #include "common.h"
  19. static struct measure_clk_data debug_mux_priv = {
  20. .ctl_reg = 0x62038,
  21. .status_reg = 0x6203C,
  22. .xo_div4_cbcr = 0x43008,
  23. };
  24. static const char *const apss_cc_debug_mux_parent_names[] = {
  25. "measure_only_apcs_gold_post_acd_clk",
  26. "measure_only_apcs_l3_post_acd_clk",
  27. "measure_only_apcs_silver_post_acd_clk",
  28. };
  29. static int apss_cc_debug_mux_sels[] = {
  30. 0x25, /* measure_only_apcs_gold_post_acd_clk */
  31. 0x41, /* measure_only_apcs_l3_post_acd_clk */
  32. 0x21, /* measure_only_apcs_silver_post_acd_clk */
  33. };
  34. static int apss_cc_debug_mux_pre_divs[] = {
  35. 0x8, /* measure_only_apcs_gold_post_acd_clk */
  36. 0x4, /* measure_only_apcs_l3_post_acd_clk */
  37. 0x4, /* measure_only_apcs_silver_post_acd_clk */
  38. };
  39. static struct clk_debug_mux apss_cc_debug_mux = {
  40. .priv = &debug_mux_priv,
  41. .debug_offset = 0x18,
  42. .post_div_offset = 0x18,
  43. .cbcr_offset = 0x0,
  44. .src_sel_mask = 0x7F0,
  45. .src_sel_shift = 4,
  46. .post_div_mask = 0x7800,
  47. .post_div_shift = 11,
  48. .post_div_val = 1,
  49. .mux_sels = apss_cc_debug_mux_sels,
  50. .num_mux_sels = ARRAY_SIZE(apss_cc_debug_mux_sels),
  51. .pre_div_vals = apss_cc_debug_mux_pre_divs,
  52. .hw.init = &(struct clk_init_data){
  53. .name = "apss_cc_debug_mux",
  54. .ops = &clk_debug_mux_ops,
  55. .parent_names = apss_cc_debug_mux_parent_names,
  56. .num_parents = ARRAY_SIZE(apss_cc_debug_mux_parent_names),
  57. },
  58. };
  59. static const char *const cam_cc_debug_mux_parent_names[] = {
  60. "cam_cc_bps_ahb_clk",
  61. "cam_cc_bps_areg_clk",
  62. "cam_cc_bps_axi_clk",
  63. "cam_cc_bps_clk",
  64. "cam_cc_camnoc_axi_clk",
  65. "cam_cc_cci_clk",
  66. "cam_cc_core_ahb_clk",
  67. "cam_cc_cpas_ahb_clk",
  68. "cam_cc_csi0phytimer_clk",
  69. "cam_cc_csi1phytimer_clk",
  70. "cam_cc_csi2phytimer_clk",
  71. "cam_cc_csiphy0_clk",
  72. "cam_cc_csiphy1_clk",
  73. "cam_cc_csiphy2_clk",
  74. "cam_cc_icp_clk",
  75. "cam_cc_ife_0_axi_clk",
  76. "cam_cc_ife_0_clk",
  77. "cam_cc_ife_0_cphy_rx_clk",
  78. "cam_cc_ife_0_csid_clk",
  79. "cam_cc_ife_0_dsp_clk",
  80. "cam_cc_ife_1_axi_clk",
  81. "cam_cc_ife_1_clk",
  82. "cam_cc_ife_1_cphy_rx_clk",
  83. "cam_cc_ife_1_csid_clk",
  84. "cam_cc_ife_1_dsp_clk",
  85. "cam_cc_ife_lite_clk",
  86. "cam_cc_ife_lite_cphy_rx_clk",
  87. "cam_cc_ife_lite_csid_clk",
  88. "cam_cc_ipe_0_ahb_clk",
  89. "cam_cc_ipe_0_areg_clk",
  90. "cam_cc_ipe_0_axi_clk",
  91. "cam_cc_ipe_0_clk",
  92. "cam_cc_jpeg_clk",
  93. "cam_cc_lrme_clk",
  94. "cam_cc_mclk0_clk",
  95. "cam_cc_mclk1_clk",
  96. "cam_cc_mclk2_clk",
  97. "cam_cc_mclk3_clk",
  98. "cam_cc_soc_ahb_clk",
  99. "cam_cc_sys_tmr_clk",
  100. };
  101. static int cam_cc_debug_mux_sels[] = {
  102. 0xE, /* cam_cc_bps_ahb_clk */
  103. 0xD, /* cam_cc_bps_areg_clk */
  104. 0xC, /* cam_cc_bps_axi_clk */
  105. 0xB, /* cam_cc_bps_clk */
  106. 0x2D, /* cam_cc_camnoc_axi_clk */
  107. 0x2A, /* cam_cc_cci_clk */
  108. 0x3A, /* cam_cc_core_ahb_clk */
  109. 0x2C, /* cam_cc_cpas_ahb_clk */
  110. 0x5, /* cam_cc_csi0phytimer_clk */
  111. 0x7, /* cam_cc_csi1phytimer_clk */
  112. 0x9, /* cam_cc_csi2phytimer_clk */
  113. 0x6, /* cam_cc_csiphy0_clk */
  114. 0x8, /* cam_cc_csiphy1_clk */
  115. 0xA, /* cam_cc_csiphy2_clk */
  116. 0x26, /* cam_cc_icp_clk */
  117. 0x1B, /* cam_cc_ife_0_axi_clk */
  118. 0x17, /* cam_cc_ife_0_clk */
  119. 0x1A, /* cam_cc_ife_0_cphy_rx_clk */
  120. 0x19, /* cam_cc_ife_0_csid_clk */
  121. 0x18, /* cam_cc_ife_0_dsp_clk */
  122. 0x21, /* cam_cc_ife_1_axi_clk */
  123. 0x1D, /* cam_cc_ife_1_clk */
  124. 0x20, /* cam_cc_ife_1_cphy_rx_clk */
  125. 0x1F, /* cam_cc_ife_1_csid_clk */
  126. 0x1E, /* cam_cc_ife_1_dsp_clk */
  127. 0x22, /* cam_cc_ife_lite_clk */
  128. 0x24, /* cam_cc_ife_lite_cphy_rx_clk */
  129. 0x23, /* cam_cc_ife_lite_csid_clk */
  130. 0x12, /* cam_cc_ipe_0_ahb_clk */
  131. 0x11, /* cam_cc_ipe_0_areg_clk */
  132. 0x10, /* cam_cc_ipe_0_axi_clk */
  133. 0xF, /* cam_cc_ipe_0_clk */
  134. 0x25, /* cam_cc_jpeg_clk */
  135. 0x2B, /* cam_cc_lrme_clk */
  136. 0x1, /* cam_cc_mclk0_clk */
  137. 0x2, /* cam_cc_mclk1_clk */
  138. 0x3, /* cam_cc_mclk2_clk */
  139. 0x4, /* cam_cc_mclk3_clk */
  140. 0x2E, /* cam_cc_soc_ahb_clk */
  141. 0x33, /* cam_cc_sys_tmr_clk */
  142. };
  143. static struct clk_debug_mux cam_cc_debug_mux = {
  144. .priv = &debug_mux_priv,
  145. .debug_offset = 0xC000,
  146. .post_div_offset = 0xC004,
  147. .cbcr_offset = 0xC008,
  148. .src_sel_mask = 0xFF,
  149. .src_sel_shift = 0,
  150. .post_div_mask = 0x3,
  151. .post_div_shift = 0,
  152. .post_div_val = 2,
  153. .mux_sels = cam_cc_debug_mux_sels,
  154. .num_mux_sels = ARRAY_SIZE(cam_cc_debug_mux_sels),
  155. .hw.init = &(struct clk_init_data){
  156. .name = "cam_cc_debug_mux",
  157. .ops = &clk_debug_mux_ops,
  158. .parent_names = cam_cc_debug_mux_parent_names,
  159. .num_parents = ARRAY_SIZE(cam_cc_debug_mux_parent_names),
  160. },
  161. };
  162. static const char *const disp_cc_debug_mux_parent_names[] = {
  163. "disp_cc_mdss_ahb_clk",
  164. "disp_cc_mdss_byte0_clk",
  165. "disp_cc_mdss_byte0_intf_clk",
  166. "disp_cc_mdss_dp_aux_clk",
  167. "disp_cc_mdss_dp_crypto_clk",
  168. "disp_cc_mdss_dp_link_clk",
  169. "disp_cc_mdss_dp_link_intf_clk",
  170. "disp_cc_mdss_dp_pixel1_clk",
  171. "disp_cc_mdss_dp_pixel_clk",
  172. "disp_cc_mdss_esc0_clk",
  173. "disp_cc_mdss_mdp_clk",
  174. "disp_cc_mdss_mdp_lut_clk",
  175. "disp_cc_mdss_non_gdsc_ahb_clk",
  176. "disp_cc_mdss_pclk0_clk",
  177. "disp_cc_mdss_rot_clk",
  178. "disp_cc_mdss_rscc_ahb_clk",
  179. "disp_cc_mdss_rscc_vsync_clk",
  180. "disp_cc_mdss_vsync_clk",
  181. };
  182. static int disp_cc_debug_mux_sels[] = {
  183. 0x1B, /* disp_cc_mdss_ahb_clk */
  184. 0x12, /* disp_cc_mdss_byte0_clk */
  185. 0x13, /* disp_cc_mdss_byte0_intf_clk */
  186. 0x1A, /* disp_cc_mdss_dp_aux_clk */
  187. 0x17, /* disp_cc_mdss_dp_crypto_clk */
  188. 0x15, /* disp_cc_mdss_dp_link_clk */
  189. 0x16, /* disp_cc_mdss_dp_link_intf_clk */
  190. 0x19, /* disp_cc_mdss_dp_pixel1_clk */
  191. 0x18, /* disp_cc_mdss_dp_pixel_clk */
  192. 0x14, /* disp_cc_mdss_esc0_clk */
  193. 0xE, /* disp_cc_mdss_mdp_clk */
  194. 0x10, /* disp_cc_mdss_mdp_lut_clk */
  195. 0x1C, /* disp_cc_mdss_non_gdsc_ahb_clk */
  196. 0xD, /* disp_cc_mdss_pclk0_clk */
  197. 0xF, /* disp_cc_mdss_rot_clk */
  198. 0x1E, /* disp_cc_mdss_rscc_ahb_clk */
  199. 0x1D, /* disp_cc_mdss_rscc_vsync_clk */
  200. 0x11, /* disp_cc_mdss_vsync_clk */
  201. };
  202. static struct clk_debug_mux disp_cc_debug_mux = {
  203. .priv = &debug_mux_priv,
  204. .debug_offset = 0x7000,
  205. .post_div_offset = 0x5008,
  206. .cbcr_offset = 0x500C,
  207. .src_sel_mask = 0xFF,
  208. .src_sel_shift = 0,
  209. .post_div_mask = 0x3,
  210. .post_div_shift = 0,
  211. .post_div_val = 4,
  212. .mux_sels = disp_cc_debug_mux_sels,
  213. .num_mux_sels = ARRAY_SIZE(disp_cc_debug_mux_sels),
  214. .hw.init = &(struct clk_init_data){
  215. .name = "disp_cc_debug_mux",
  216. .ops = &clk_debug_mux_ops,
  217. .parent_names = disp_cc_debug_mux_parent_names,
  218. .num_parents = ARRAY_SIZE(disp_cc_debug_mux_parent_names),
  219. },
  220. };
  221. static const char *const gcc_debug_mux_parent_names[] = {
  222. "apss_cc_debug_mux",
  223. "cam_cc_debug_mux",
  224. "disp_cc_debug_mux",
  225. "gcc_aggre_ufs_phy_axi_clk",
  226. "gcc_aggre_usb2_sec_axi_clk",
  227. "gcc_aggre_usb3_prim_axi_clk",
  228. "gcc_ahb2phy_east_clk",
  229. "gcc_ahb2phy_west_clk",
  230. "gcc_boot_rom_ahb_clk",
  231. "gcc_camera_hf_axi_clk",
  232. "gcc_ce1_ahb_clk",
  233. "gcc_ce1_axi_clk",
  234. "gcc_ce1_clk",
  235. "gcc_cfg_noc_usb2_sec_axi_clk",
  236. "gcc_cfg_noc_usb3_prim_axi_clk",
  237. "gcc_cpuss_ahb_clk",
  238. "gcc_ddrss_gpu_axi_clk",
  239. "gcc_disp_gpll0_div_clk_src",
  240. "gcc_disp_hf_axi_clk",
  241. "gcc_emac_axi_clk",
  242. "gcc_emac_ptp_clk",
  243. "gcc_emac_rgmii_clk",
  244. "gcc_emac_slv_ahb_clk",
  245. "gcc_gp1_clk",
  246. "gcc_gp2_clk",
  247. "gcc_gp3_clk",
  248. "gcc_gpu_gpll0_clk_src",
  249. "gcc_gpu_gpll0_div_clk_src",
  250. "gcc_gpu_memnoc_gfx_clk",
  251. "gcc_gpu_snoc_dvm_gfx_clk",
  252. "gcc_pcie0_phy_refgen_clk",
  253. "gcc_pcie_0_aux_clk",
  254. "gcc_pcie_0_cfg_ahb_clk",
  255. "gcc_pcie_0_mstr_axi_clk",
  256. "gcc_pcie_0_pipe_clk",
  257. "gcc_pcie_0_slv_axi_clk",
  258. "gcc_pcie_0_slv_q2a_axi_clk",
  259. "gcc_pcie_phy_aux_clk",
  260. "gcc_pdm2_clk",
  261. "gcc_pdm_ahb_clk",
  262. "gcc_pdm_xo4_clk",
  263. "gcc_prng_ahb_clk",
  264. "gcc_qmip_camera_nrt_ahb_clk",
  265. "gcc_qmip_disp_ahb_clk",
  266. "gcc_qmip_pcie_ahb_clk",
  267. "gcc_qmip_video_vcodec_ahb_clk",
  268. "gcc_qspi_cnoc_periph_ahb_clk",
  269. "gcc_qspi_core_clk",
  270. "gcc_qupv3_wrap0_core_2x_clk",
  271. "gcc_qupv3_wrap0_core_clk",
  272. "gcc_qupv3_wrap0_s0_clk",
  273. "gcc_qupv3_wrap0_s1_clk",
  274. "gcc_qupv3_wrap0_s2_clk",
  275. "gcc_qupv3_wrap0_s3_clk",
  276. "gcc_qupv3_wrap0_s4_clk",
  277. "gcc_qupv3_wrap0_s5_clk",
  278. "gcc_qupv3_wrap1_core_2x_clk",
  279. "gcc_qupv3_wrap1_core_clk",
  280. "gcc_qupv3_wrap1_s0_clk",
  281. "gcc_qupv3_wrap1_s1_clk",
  282. "gcc_qupv3_wrap1_s2_clk",
  283. "gcc_qupv3_wrap1_s3_clk",
  284. "gcc_qupv3_wrap1_s4_clk",
  285. "gcc_qupv3_wrap1_s5_clk",
  286. "gcc_qupv3_wrap_0_m_ahb_clk",
  287. "gcc_qupv3_wrap_0_s_ahb_clk",
  288. "gcc_qupv3_wrap_1_m_ahb_clk",
  289. "gcc_qupv3_wrap_1_s_ahb_clk",
  290. "gcc_sdcc1_ahb_clk",
  291. "gcc_sdcc1_apps_clk",
  292. "gcc_sdcc1_ice_core_clk",
  293. "gcc_sdcc2_ahb_clk",
  294. "gcc_sdcc2_apps_clk",
  295. "gcc_sdr_core_clk",
  296. "gcc_sdr_csr_hclk",
  297. "gcc_sdr_pri_mi2s_clk",
  298. "gcc_sdr_sec_mi2s_clk",
  299. "gcc_sdr_wr0_mem_clk",
  300. "gcc_sdr_wr1_mem_clk",
  301. "gcc_sdr_wr2_mem_clk",
  302. "gcc_sys_noc_cpuss_ahb_clk",
  303. "gcc_ufs_phy_ahb_clk",
  304. "gcc_ufs_phy_axi_clk",
  305. "gcc_ufs_phy_ice_core_clk",
  306. "gcc_ufs_phy_phy_aux_clk",
  307. "gcc_ufs_phy_rx_symbol_0_clk",
  308. "gcc_ufs_phy_tx_symbol_0_clk",
  309. "gcc_ufs_phy_unipro_core_clk",
  310. "gcc_usb20_sec_master_clk",
  311. "gcc_usb20_sec_mock_utmi_clk",
  312. "gcc_usb20_sec_sleep_clk",
  313. "gcc_usb2_sec_phy_aux_clk",
  314. "gcc_usb2_sec_phy_com_aux_clk",
  315. "gcc_usb2_sec_phy_pipe_clk",
  316. "gcc_usb30_prim_master_clk",
  317. "gcc_usb30_prim_mock_utmi_clk",
  318. "gcc_usb30_prim_sleep_clk",
  319. "gcc_usb3_prim_phy_aux_clk",
  320. "gcc_usb3_prim_phy_com_aux_clk",
  321. "gcc_usb3_prim_phy_pipe_clk",
  322. "gcc_video_axi0_clk",
  323. "gpu_cc_debug_mux",
  324. "measure_only_cnoc_clk",
  325. "measure_only_ipa_2x_clk",
  326. "mc_cc_debug_mux",
  327. "measure_only_snoc_clk",
  328. "video_cc_debug_mux",
  329. };
  330. static int gcc_debug_mux_sels[] = {
  331. 0xD6, /* apss_cc_debug_mux */
  332. 0x46, /* cam_cc_debug_mux */
  333. 0x47, /* disp_cc_debug_mux */
  334. 0x11D, /* gcc_aggre_ufs_phy_axi_clk */
  335. 0x1C8, /* gcc_aggre_usb2_sec_axi_clk */
  336. 0x11B, /* gcc_aggre_usb3_prim_axi_clk */
  337. 0x73, /* gcc_ahb2phy_east_clk */
  338. 0x6F, /* gcc_ahb2phy_west_clk */
  339. 0x94, /* gcc_boot_rom_ahb_clk */
  340. 0x40, /* gcc_camera_hf_axi_clk */
  341. 0xA9, /* gcc_ce1_ahb_clk */
  342. 0xA8, /* gcc_ce1_axi_clk */
  343. 0xA7, /* gcc_ce1_clk */
  344. 0x1C7, /* gcc_cfg_noc_usb2_sec_axi_clk */
  345. 0x1D, /* gcc_cfg_noc_usb3_prim_axi_clk */
  346. 0xCE, /* gcc_cpuss_ahb_clk */
  347. 0xBB, /* gcc_ddrss_gpu_axi_clk */
  348. 0x152, /* gcc_disp_gpll0_div_clk_src */
  349. 0x41, /* gcc_disp_hf_axi_clk */
  350. 0x16D, /* gcc_emac_axi_clk */
  351. 0x1D3, /* gcc_emac_ptp_clk */
  352. 0x16A, /* gcc_emac_rgmii_clk */
  353. 0x16C, /* gcc_emac_slv_ahb_clk */
  354. 0xDE, /* gcc_gp1_clk */
  355. 0xDF, /* gcc_gp2_clk */
  356. 0xE0, /* gcc_gp3_clk */
  357. 0x148, /* gcc_gpu_gpll0_clk_src */
  358. 0x149, /* gcc_gpu_gpll0_div_clk_src */
  359. 0x145, /* gcc_gpu_memnoc_gfx_clk */
  360. 0x147, /* gcc_gpu_snoc_dvm_gfx_clk */
  361. 0x1F3, /* gcc_pcie0_phy_refgen_clk */
  362. 0xE5, /* gcc_pcie_0_aux_clk */
  363. 0xE4, /* gcc_pcie_0_cfg_ahb_clk */
  364. 0xE3, /* gcc_pcie_0_mstr_axi_clk */
  365. 0xE6, /* gcc_pcie_0_pipe_clk */
  366. 0xE2, /* gcc_pcie_0_slv_axi_clk */
  367. 0xE1, /* gcc_pcie_0_slv_q2a_axi_clk */
  368. 0xEF, /* gcc_pcie_phy_aux_clk */
  369. 0x8E, /* gcc_pdm2_clk */
  370. 0x8C, /* gcc_pdm_ahb_clk */
  371. 0x8D, /* gcc_pdm_xo4_clk */
  372. 0x8F, /* gcc_prng_ahb_clk */
  373. 0x3D, /* gcc_qmip_camera_nrt_ahb_clk */
  374. 0x3E, /* gcc_qmip_disp_ahb_clk */
  375. 0xE8, /* gcc_qmip_pcie_ahb_clk */
  376. 0x15C, /* gcc_qmip_video_vcodec_ahb_clk */
  377. 0x168, /* gcc_qspi_cnoc_periph_ahb_clk */
  378. 0x169, /* gcc_qspi_core_clk */
  379. 0x77, /* gcc_qupv3_wrap0_core_2x_clk */
  380. 0x76, /* gcc_qupv3_wrap0_core_clk */
  381. 0x78, /* gcc_qupv3_wrap0_s0_clk */
  382. 0x79, /* gcc_qupv3_wrap0_s1_clk */
  383. 0x7A, /* gcc_qupv3_wrap0_s2_clk */
  384. 0x7B, /* gcc_qupv3_wrap0_s3_clk */
  385. 0x7C, /* gcc_qupv3_wrap0_s4_clk */
  386. 0x7D, /* gcc_qupv3_wrap0_s5_clk */
  387. 0x194, /* gcc_qupv3_wrap1_core_2x_clk */
  388. 0x193, /* gcc_qupv3_wrap1_core_clk */
  389. 0x195, /* gcc_qupv3_wrap1_s0_clk */
  390. 0x196, /* gcc_qupv3_wrap1_s1_clk */
  391. 0x197, /* gcc_qupv3_wrap1_s2_clk */
  392. 0x198, /* gcc_qupv3_wrap1_s3_clk */
  393. 0x199, /* gcc_qupv3_wrap1_s4_clk */
  394. 0x19A, /* gcc_qupv3_wrap1_s5_clk */
  395. 0x74, /* gcc_qupv3_wrap_0_m_ahb_clk */
  396. 0x75, /* gcc_qupv3_wrap_0_s_ahb_clk */
  397. 0x191, /* gcc_qupv3_wrap_1_m_ahb_clk */
  398. 0x192, /* gcc_qupv3_wrap_1_s_ahb_clk */
  399. 0x1F0, /* gcc_sdcc1_ahb_clk */
  400. 0x1CB, /* gcc_sdcc1_apps_clk */
  401. 0x185, /* gcc_sdcc1_ice_core_clk */
  402. 0x71, /* gcc_sdcc2_ahb_clk */
  403. 0x70, /* gcc_sdcc2_apps_clk */
  404. 0x65, /* gcc_sdr_core_clk */
  405. 0x69, /* gcc_sdr_csr_hclk */
  406. 0x1A1, /* gcc_sdr_pri_mi2s_clk */
  407. 0x1A2, /* gcc_sdr_sec_mi2s_clk */
  408. 0x66, /* gcc_sdr_wr0_mem_clk */
  409. 0x67, /* gcc_sdr_wr1_mem_clk */
  410. 0x68, /* gcc_sdr_wr2_mem_clk */
  411. 0xC, /* gcc_sys_noc_cpuss_ahb_clk */
  412. 0xFC, /* gcc_ufs_phy_ahb_clk */
  413. 0xFB, /* gcc_ufs_phy_axi_clk */
  414. 0x102, /* gcc_ufs_phy_ice_core_clk */
  415. 0x103, /* gcc_ufs_phy_phy_aux_clk */
  416. 0xFE, /* gcc_ufs_phy_rx_symbol_0_clk */
  417. 0xFD, /* gcc_ufs_phy_tx_symbol_0_clk */
  418. 0x101, /* gcc_ufs_phy_unipro_core_clk */
  419. 0x1AF, /* gcc_usb20_sec_master_clk */
  420. 0x1B1, /* gcc_usb20_sec_mock_utmi_clk */
  421. 0x1B0, /* gcc_usb20_sec_sleep_clk */
  422. 0x1BD, /* gcc_usb2_sec_phy_aux_clk */
  423. 0x1BE, /* gcc_usb2_sec_phy_com_aux_clk */
  424. 0x1BF, /* gcc_usb2_sec_phy_pipe_clk */
  425. 0x5F, /* gcc_usb30_prim_master_clk */
  426. 0x61, /* gcc_usb30_prim_mock_utmi_clk */
  427. 0x60, /* gcc_usb30_prim_sleep_clk */
  428. 0x62, /* gcc_usb3_prim_phy_aux_clk */
  429. 0x63, /* gcc_usb3_prim_phy_com_aux_clk */
  430. 0x64, /* gcc_usb3_prim_phy_pipe_clk */
  431. 0x3F, /* gcc_video_axi0_clk */
  432. 0x144, /* gpu_cc_debug_mux */
  433. 0x15, /* measure_only_cnoc_clk */
  434. 0x128, /* measure_only_ipa_2x_clk */
  435. 0xC2, /* mc_cc_debug_mux */
  436. 0x7, /* measure_only_snoc_clk */
  437. 0x48, /* video_cc_debug_mux */
  438. };
  439. static struct clk_debug_mux gcc_debug_mux = {
  440. .priv = &debug_mux_priv,
  441. .debug_offset = 0x62000,
  442. .post_div_offset = 0x62004,
  443. .cbcr_offset = 0x62008,
  444. .src_sel_mask = 0x3FF,
  445. .src_sel_shift = 0,
  446. .post_div_mask = 0xF,
  447. .post_div_shift = 0,
  448. .post_div_val = 1,
  449. .mux_sels = gcc_debug_mux_sels,
  450. .num_mux_sels = ARRAY_SIZE(gcc_debug_mux_sels),
  451. .hw.init = &(struct clk_init_data){
  452. .name = "gcc_debug_mux",
  453. .ops = &clk_debug_mux_ops,
  454. .parent_names = gcc_debug_mux_parent_names,
  455. .num_parents = ARRAY_SIZE(gcc_debug_mux_parent_names),
  456. },
  457. };
  458. static const char *const gpu_cc_debug_mux_parent_names[] = {
  459. "gpu_cc_crc_ahb_clk",
  460. "gpu_cc_cx_gfx3d_clk",
  461. "gpu_cc_cx_gmu_clk",
  462. "gpu_cc_cx_snoc_dvm_clk",
  463. "gpu_cc_cxo_aon_clk",
  464. "gpu_cc_cxo_clk",
  465. "gpu_cc_gx_gfx3d_clk",
  466. "gpu_cc_gx_gmu_clk",
  467. "gpu_cc_sleep_clk",
  468. };
  469. static int gpu_cc_debug_mux_sels[] = {
  470. 0x11, /* gpu_cc_crc_ahb_clk */
  471. 0x1A, /* gpu_cc_cx_gfx3d_clk */
  472. 0x18, /* gpu_cc_cx_gmu_clk */
  473. 0x15, /* gpu_cc_cx_snoc_dvm_clk */
  474. 0xA, /* gpu_cc_cxo_aon_clk */
  475. 0x19, /* gpu_cc_cxo_clk */
  476. 0xB, /* gpu_cc_gx_gfx3d_clk */
  477. 0xF, /* gpu_cc_gx_gmu_clk */
  478. 0x16, /* gpu_cc_sleep_clk */
  479. };
  480. static struct clk_debug_mux gpu_cc_debug_mux = {
  481. .priv = &debug_mux_priv,
  482. .debug_offset = 0x1568,
  483. .post_div_offset = 0x10FC,
  484. .cbcr_offset = 0x1100,
  485. .src_sel_mask = 0xFF,
  486. .src_sel_shift = 0,
  487. .post_div_mask = 0x3,
  488. .post_div_shift = 0,
  489. .post_div_val = 2,
  490. .mux_sels = gpu_cc_debug_mux_sels,
  491. .num_mux_sels = ARRAY_SIZE(gpu_cc_debug_mux_sels),
  492. .hw.init = &(struct clk_init_data){
  493. .name = "gpu_cc_debug_mux",
  494. .ops = &clk_debug_mux_ops,
  495. .parent_names = gpu_cc_debug_mux_parent_names,
  496. .num_parents = ARRAY_SIZE(gpu_cc_debug_mux_parent_names),
  497. },
  498. };
  499. static const char *const video_cc_debug_mux_parent_names[] = {
  500. "video_cc_sleep_clk",
  501. "video_cc_vcodec0_axi_clk",
  502. "video_cc_vcodec0_core_clk",
  503. "video_cc_venus_ahb_clk",
  504. "video_cc_venus_ctl_axi_clk",
  505. "video_cc_venus_ctl_core_clk",
  506. };
  507. static int video_cc_debug_mux_sels[] = {
  508. 0xD, /* video_cc_sleep_clk */
  509. 0x6, /* video_cc_vcodec0_axi_clk */
  510. 0x3, /* video_cc_vcodec0_core_clk */
  511. 0x9, /* video_cc_venus_ahb_clk */
  512. 0x5, /* video_cc_venus_ctl_axi_clk */
  513. 0x1, /* video_cc_venus_ctl_core_clk */
  514. };
  515. static struct clk_debug_mux video_cc_debug_mux = {
  516. .priv = &debug_mux_priv,
  517. .debug_offset = 0xA4C,
  518. .post_div_offset = 0xA30,
  519. .cbcr_offset = 0xA38,
  520. .src_sel_mask = 0x3F,
  521. .src_sel_shift = 0,
  522. .post_div_mask = 0x7,
  523. .post_div_shift = 0,
  524. .post_div_val = 5,
  525. .mux_sels = video_cc_debug_mux_sels,
  526. .num_mux_sels = ARRAY_SIZE(video_cc_debug_mux_sels),
  527. .hw.init = &(struct clk_init_data){
  528. .name = "video_cc_debug_mux",
  529. .ops = &clk_debug_mux_ops,
  530. .parent_names = video_cc_debug_mux_parent_names,
  531. .num_parents = ARRAY_SIZE(video_cc_debug_mux_parent_names),
  532. },
  533. };
  534. static const char *const mc_cc_debug_mux_parent_names[] = {
  535. "measure_only_mccc_clk",
  536. };
  537. static struct clk_debug_mux mc_cc_debug_mux = {
  538. .period_offset = 0x50,
  539. .hw.init = &(struct clk_init_data){
  540. .name = "mc_cc_debug_mux",
  541. .ops = &clk_debug_mux_ops,
  542. .parent_names = mc_cc_debug_mux_parent_names,
  543. .num_parents = ARRAY_SIZE(mc_cc_debug_mux_parent_names),
  544. },
  545. };
  546. static struct mux_regmap_names mux_list[] = {
  547. { .mux = &apss_cc_debug_mux, .regmap_name = "qcom,apsscc" },
  548. { .mux = &cam_cc_debug_mux, .regmap_name = "qcom,camcc" },
  549. { .mux = &disp_cc_debug_mux, .regmap_name = "qcom,dispcc" },
  550. { .mux = &gpu_cc_debug_mux, .regmap_name = "qcom,gpucc" },
  551. { .mux = &mc_cc_debug_mux, .regmap_name = "qcom,mccc" },
  552. { .mux = &video_cc_debug_mux, .regmap_name = "qcom,videocc" },
  553. { .mux = &gcc_debug_mux, .regmap_name = "qcom,gcc" },
  554. };
  555. static struct clk_dummy measure_only_apcs_gold_post_acd_clk = {
  556. .rrate = 1000,
  557. .hw.init = &(struct clk_init_data){
  558. .name = "measure_only_apcs_gold_post_acd_clk",
  559. .ops = &clk_dummy_ops,
  560. },
  561. };
  562. static struct clk_dummy measure_only_apcs_l3_post_acd_clk = {
  563. .rrate = 1000,
  564. .hw.init = &(struct clk_init_data){
  565. .name = "measure_only_apcs_l3_post_acd_clk",
  566. .ops = &clk_dummy_ops,
  567. },
  568. };
  569. static struct clk_dummy measure_only_apcs_silver_post_acd_clk = {
  570. .rrate = 1000,
  571. .hw.init = &(struct clk_init_data){
  572. .name = "measure_only_apcs_silver_post_acd_clk",
  573. .ops = &clk_dummy_ops,
  574. },
  575. };
  576. static struct clk_dummy measure_only_cnoc_clk = {
  577. .rrate = 1000,
  578. .hw.init = &(struct clk_init_data){
  579. .name = "measure_only_cnoc_clk",
  580. .ops = &clk_dummy_ops,
  581. },
  582. };
  583. static struct clk_dummy measure_only_ipa_2x_clk = {
  584. .rrate = 1000,
  585. .hw.init = &(struct clk_init_data){
  586. .name = "measure_only_ipa_2x_clk",
  587. .ops = &clk_dummy_ops,
  588. },
  589. };
  590. static struct clk_dummy measure_only_mccc_clk = {
  591. .rrate = 1000,
  592. .hw.init = &(struct clk_init_data){
  593. .name = "measure_only_mccc_clk",
  594. .ops = &clk_dummy_ops,
  595. },
  596. };
  597. static struct clk_dummy measure_only_snoc_clk = {
  598. .rrate = 1000,
  599. .hw.init = &(struct clk_init_data){
  600. .name = "measure_only_snoc_clk",
  601. .ops = &clk_dummy_ops,
  602. },
  603. };
  604. static struct clk_hw *debugcc_sm6150_hws[] = {
  605. &measure_only_apcs_gold_post_acd_clk.hw,
  606. &measure_only_apcs_l3_post_acd_clk.hw,
  607. &measure_only_apcs_silver_post_acd_clk.hw,
  608. &measure_only_cnoc_clk.hw,
  609. &measure_only_ipa_2x_clk.hw,
  610. &measure_only_mccc_clk.hw,
  611. &measure_only_snoc_clk.hw,
  612. };
  613. static const struct of_device_id clk_debug_match_table[] = {
  614. { .compatible = "qcom,sm6150-debugcc" },
  615. { }
  616. };
  617. static int clk_debug_sm6150_probe(struct platform_device *pdev)
  618. {
  619. struct clk *clk;
  620. int ret = 0, i;
  621. BUILD_BUG_ON(ARRAY_SIZE(apss_cc_debug_mux_parent_names) !=
  622. ARRAY_SIZE(apss_cc_debug_mux_sels));
  623. BUILD_BUG_ON(ARRAY_SIZE(cam_cc_debug_mux_parent_names) !=
  624. ARRAY_SIZE(cam_cc_debug_mux_sels));
  625. BUILD_BUG_ON(ARRAY_SIZE(disp_cc_debug_mux_parent_names) !=
  626. ARRAY_SIZE(disp_cc_debug_mux_sels));
  627. BUILD_BUG_ON(ARRAY_SIZE(gcc_debug_mux_parent_names) !=
  628. ARRAY_SIZE(gcc_debug_mux_sels));
  629. BUILD_BUG_ON(ARRAY_SIZE(gpu_cc_debug_mux_parent_names) !=
  630. ARRAY_SIZE(gpu_cc_debug_mux_sels));
  631. BUILD_BUG_ON(ARRAY_SIZE(video_cc_debug_mux_parent_names) !=
  632. ARRAY_SIZE(video_cc_debug_mux_sels));
  633. clk = devm_clk_get(&pdev->dev, "xo_clk_src");
  634. if (IS_ERR(clk)) {
  635. if (PTR_ERR(clk) != -EPROBE_DEFER)
  636. dev_err(&pdev->dev, "Unable to get xo clock\n");
  637. return PTR_ERR(clk);
  638. }
  639. debug_mux_priv.cxo = clk;
  640. for (i = 0; i < ARRAY_SIZE(mux_list); i++) {
  641. if (IS_ERR_OR_NULL(mux_list[i].mux->regmap)) {
  642. ret = map_debug_bases(pdev, mux_list[i].regmap_name,
  643. mux_list[i].mux);
  644. if (ret == -EBADR)
  645. continue;
  646. else if (ret)
  647. return ret;
  648. }
  649. }
  650. for (i = 0; i < ARRAY_SIZE(debugcc_sm6150_hws); i++) {
  651. clk = devm_clk_register(&pdev->dev, debugcc_sm6150_hws[i]);
  652. if (IS_ERR(clk)) {
  653. dev_err(&pdev->dev, "Unable to register %s, err:(%d)\n",
  654. clk_hw_get_name(debugcc_sm6150_hws[i]),
  655. PTR_ERR(clk));
  656. return PTR_ERR(clk);
  657. }
  658. }
  659. for (i = 0; i < ARRAY_SIZE(mux_list); i++) {
  660. ret = devm_clk_register_debug_mux(&pdev->dev, mux_list[i].mux);
  661. if (ret) {
  662. dev_err(&pdev->dev, "Unable to register mux clk %s, err:(%d)\n",
  663. qcom_clk_hw_get_name(&mux_list[i].mux->hw),
  664. ret);
  665. return ret;
  666. }
  667. }
  668. ret = clk_debug_measure_register(&gcc_debug_mux.hw);
  669. if (ret) {
  670. dev_err(&pdev->dev, "Could not register Measure clocks\n");
  671. return ret;
  672. }
  673. dev_info(&pdev->dev, "Registered debug measure clocks\n");
  674. return ret;
  675. }
  676. static struct platform_driver clk_debug_driver = {
  677. .probe = clk_debug_sm6150_probe,
  678. .driver = {
  679. .name = "sm6150-debugcc",
  680. .of_match_table = clk_debug_match_table,
  681. },
  682. };
  683. static int __init clk_debug_sm6150_init(void)
  684. {
  685. return platform_driver_register(&clk_debug_driver);
  686. }
  687. fs_initcall(clk_debug_sm6150_init);
  688. MODULE_DESCRIPTION("QTI DEBUG CC SM6150 Driver");
  689. MODULE_LICENSE("GPL");