debugcc-holi.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  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 = 0x28008,
  23. };
  24. static const char *const cpu_cc_debug_mux_parent_names[] = {
  25. "l3_clk",
  26. "perfcl_clk",
  27. "pwrcl_clk",
  28. };
  29. static int cpu_cc_debug_mux_sels[] = {
  30. 0x41, /* l3_clk */
  31. 0x25, /* perfcl_clk */
  32. 0x21, /* pwrcl_clk */
  33. };
  34. static int apss_cc_debug_mux_pre_divs[] = {
  35. 0x4, /* l3_clk */
  36. 0x8, /* perfcl_clk */
  37. 0x4, /* pwrcl_clk */
  38. };
  39. static struct clk_debug_mux cpu_cc_debug_mux = {
  40. .priv = &debug_mux_priv,
  41. .debug_offset = 0x0,
  42. .post_div_offset = 0x0,
  43. .cbcr_offset = 0,
  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 = cpu_cc_debug_mux_sels,
  50. .num_mux_sels = ARRAY_SIZE(cpu_cc_debug_mux_sels),
  51. .pre_div_vals = apss_cc_debug_mux_pre_divs,
  52. .hw.init = &(const struct clk_init_data){
  53. .name = "cpu_cc_debug_mux",
  54. .ops = &clk_debug_mux_ops,
  55. .parent_names = cpu_cc_debug_mux_parent_names,
  56. .num_parents = ARRAY_SIZE(cpu_cc_debug_mux_parent_names),
  57. },
  58. };
  59. static const char *const disp_cc_debug_mux_parent_names[] = {
  60. "disp_cc_mdss_ahb_clk",
  61. "disp_cc_mdss_byte0_clk",
  62. "disp_cc_mdss_byte0_intf_clk",
  63. "disp_cc_mdss_esc0_clk",
  64. "disp_cc_mdss_mdp_clk",
  65. "disp_cc_mdss_mdp_lut_clk",
  66. "disp_cc_mdss_non_gdsc_ahb_clk",
  67. "disp_cc_mdss_pclk0_clk",
  68. "disp_cc_mdss_rot_clk",
  69. "disp_cc_mdss_rscc_ahb_clk",
  70. "disp_cc_mdss_rscc_vsync_clk",
  71. "disp_cc_mdss_vsync_clk",
  72. "measure_only_disp_cc_sleep_clk",
  73. "measure_only_disp_cc_xo_clk",
  74. };
  75. static int disp_cc_debug_mux_sels[] = {
  76. 0x14, /* disp_cc_mdss_ahb_clk */
  77. 0xC, /* disp_cc_mdss_byte0_clk */
  78. 0xD, /* disp_cc_mdss_byte0_intf_clk */
  79. 0xE, /* disp_cc_mdss_esc0_clk */
  80. 0x8, /* disp_cc_mdss_mdp_clk */
  81. 0xA, /* disp_cc_mdss_mdp_lut_clk */
  82. 0x15, /* disp_cc_mdss_non_gdsc_ahb_clk */
  83. 0x7, /* disp_cc_mdss_pclk0_clk */
  84. 0x9, /* disp_cc_mdss_rot_clk */
  85. 0x17, /* disp_cc_mdss_rscc_ahb_clk */
  86. 0x16, /* disp_cc_mdss_rscc_vsync_clk */
  87. 0xB, /* disp_cc_mdss_vsync_clk */
  88. 0x1D, /* measure_only_disp_cc_sleep_clk */
  89. 0x1E, /* measure_only_disp_cc_xo_clk */
  90. };
  91. static struct clk_debug_mux disp_cc_debug_mux = {
  92. .priv = &debug_mux_priv,
  93. .debug_offset = 0x7000,
  94. .post_div_offset = 0x3000,
  95. .cbcr_offset = 0x3004,
  96. .src_sel_mask = 0xFF,
  97. .src_sel_shift = 0,
  98. .post_div_mask = 0x3,
  99. .post_div_shift = 0,
  100. .post_div_val = 4,
  101. .mux_sels = disp_cc_debug_mux_sels,
  102. .num_mux_sels = ARRAY_SIZE(disp_cc_debug_mux_sels),
  103. .hw.init = &(const struct clk_init_data){
  104. .name = "disp_cc_debug_mux",
  105. .ops = &clk_debug_mux_ops,
  106. .parent_names = disp_cc_debug_mux_parent_names,
  107. .num_parents = ARRAY_SIZE(disp_cc_debug_mux_parent_names),
  108. },
  109. };
  110. static const char *const gcc_debug_mux_parent_names[] = {
  111. "cpu_cc_debug_mux",
  112. "disp_cc_debug_mux",
  113. "gcc_ahb2phy_csi_clk",
  114. "gcc_ahb2phy_usb_clk",
  115. "gcc_bimc_gpu_axi_clk",
  116. "gcc_boot_rom_ahb_clk",
  117. "gcc_cam_throttle_nrt_clk",
  118. "gcc_cam_throttle_rt_clk",
  119. "gcc_camss_axi_clk",
  120. "gcc_camss_camnoc_atb_clk",
  121. "gcc_camss_camnoc_nts_xo_clk",
  122. "gcc_camss_cci_0_clk",
  123. "gcc_camss_cci_1_clk",
  124. "gcc_camss_cphy_0_clk",
  125. "gcc_camss_cphy_1_clk",
  126. "gcc_camss_cphy_2_clk",
  127. "gcc_camss_cphy_3_clk",
  128. "gcc_camss_csi0phytimer_clk",
  129. "gcc_camss_csi1phytimer_clk",
  130. "gcc_camss_csi2phytimer_clk",
  131. "gcc_camss_csi3phytimer_clk",
  132. "gcc_camss_mclk0_clk",
  133. "gcc_camss_mclk1_clk",
  134. "gcc_camss_mclk2_clk",
  135. "gcc_camss_mclk3_clk",
  136. "gcc_camss_mclk4_clk",
  137. "gcc_camss_nrt_axi_clk",
  138. "gcc_camss_ope_ahb_clk",
  139. "gcc_camss_ope_clk",
  140. "gcc_camss_rt_axi_clk",
  141. "gcc_camss_tfe_0_clk",
  142. "gcc_camss_tfe_0_cphy_rx_clk",
  143. "gcc_camss_tfe_0_csid_clk",
  144. "gcc_camss_tfe_1_clk",
  145. "gcc_camss_tfe_1_cphy_rx_clk",
  146. "gcc_camss_tfe_1_csid_clk",
  147. "gcc_camss_tfe_2_clk",
  148. "gcc_camss_tfe_2_cphy_rx_clk",
  149. "gcc_camss_tfe_2_csid_clk",
  150. "gcc_camss_top_ahb_clk",
  151. "gcc_cfg_noc_usb3_prim_axi_clk",
  152. "gcc_disp_gpll0_div_clk_src",
  153. "gcc_disp_hf_axi_clk",
  154. "gcc_disp_sleep_clk",
  155. "gcc_disp_throttle_core_clk",
  156. "gcc_gp1_clk",
  157. "gcc_gp2_clk",
  158. "gcc_gp3_clk",
  159. "gcc_gpu_gpll0_clk_src",
  160. "gcc_gpu_gpll0_div_clk_src",
  161. "gcc_gpu_memnoc_gfx_clk",
  162. "gcc_gpu_snoc_dvm_gfx_clk",
  163. "gcc_gpu_throttle_core_clk",
  164. "gcc_pdm2_clk",
  165. "gcc_pdm_ahb_clk",
  166. "gcc_pdm_xo4_clk",
  167. "gcc_prng_ahb_clk",
  168. "gcc_qmip_camera_nrt_ahb_clk",
  169. "gcc_qmip_camera_rt_ahb_clk",
  170. "gcc_qmip_disp_ahb_clk",
  171. "gcc_qmip_gpu_cfg_ahb_clk",
  172. "gcc_qmip_video_vcodec_ahb_clk",
  173. "gcc_qupv3_wrap0_core_2x_clk",
  174. "gcc_qupv3_wrap0_core_clk",
  175. "gcc_qupv3_wrap0_s0_clk",
  176. "gcc_qupv3_wrap0_s1_clk",
  177. "gcc_qupv3_wrap0_s2_clk",
  178. "gcc_qupv3_wrap0_s3_clk",
  179. "gcc_qupv3_wrap0_s4_clk",
  180. "gcc_qupv3_wrap0_s5_clk",
  181. "gcc_qupv3_wrap1_core_2x_clk",
  182. "gcc_qupv3_wrap1_core_clk",
  183. "gcc_qupv3_wrap1_s0_clk",
  184. "gcc_qupv3_wrap1_s1_clk",
  185. "gcc_qupv3_wrap1_s2_clk",
  186. "gcc_qupv3_wrap1_s3_clk",
  187. "gcc_qupv3_wrap1_s5_clk",
  188. "gcc_qupv3_wrap_0_m_ahb_clk",
  189. "gcc_qupv3_wrap_0_s_ahb_clk",
  190. "gcc_sdcc1_ahb_clk",
  191. "gcc_sdcc1_apps_clk",
  192. "gcc_sdcc1_ice_core_clk",
  193. "gcc_sdcc2_ahb_clk",
  194. "gcc_sdcc2_apps_clk",
  195. "gcc_sys_noc_cpuss_ahb_clk",
  196. "gcc_sys_noc_ufs_phy_axi_clk",
  197. "gcc_sys_noc_usb3_prim_axi_clk",
  198. "gcc_ufs_phy_ahb_clk",
  199. "gcc_ufs_phy_axi_clk",
  200. "gcc_ufs_phy_ice_core_clk",
  201. "gcc_ufs_phy_phy_aux_clk",
  202. "gcc_ufs_phy_rx_symbol_0_clk",
  203. "gcc_ufs_phy_tx_symbol_0_clk",
  204. "gcc_ufs_phy_unipro_core_clk",
  205. "gcc_usb30_prim_master_clk",
  206. "gcc_usb30_prim_mock_utmi_clk",
  207. "gcc_usb30_prim_sleep_clk",
  208. "gcc_usb3_prim_phy_com_aux_clk",
  209. "gcc_usb3_prim_phy_pipe_clk",
  210. "gcc_vcodec0_axi_clk",
  211. "gcc_venus_ahb_clk",
  212. "gcc_venus_ctl_axi_clk",
  213. "gcc_video_axi0_clk",
  214. "gcc_video_throttle_core_clk",
  215. "gcc_video_vcodec0_sys_clk",
  216. "gcc_video_venus_ctl_clk",
  217. "gcc_video_xo_clk",
  218. "gpu_cc_debug_mux",
  219. "mc_cc_debug_mux",
  220. "measure_only_cnoc_clk",
  221. "measure_only_gcc_camera_ahb_clk",
  222. "measure_only_gcc_camera_xo_clk",
  223. "measure_only_gcc_cpuss_gnoc_clk",
  224. "measure_only_gcc_disp_ahb_clk",
  225. "measure_only_gcc_disp_xo_clk",
  226. "measure_only_gcc_gpu_cfg_ahb_clk",
  227. "measure_only_gcc_video_ahb_clk",
  228. "measure_only_ipa_2x_clk",
  229. "measure_only_snoc_clk",
  230. "measure_only_hwkm_km_core_clk",
  231. "measure_only_hwkm_ahb_clk",
  232. "measure_only_pka_core_clk",
  233. "measure_only_pka_ahb_clk",
  234. };
  235. static int gcc_debug_mux_sels[] = {
  236. 0xBA, /* cpu_cc_debug_mux */
  237. 0x41, /* disp_cc_debug_mux */
  238. 0x63, /* gcc_ahb2phy_csi_clk */
  239. 0x64, /* gcc_ahb2phy_usb_clk */
  240. 0x99, /* gcc_bimc_gpu_axi_clk */
  241. 0x80, /* gcc_boot_rom_ahb_clk */
  242. 0x4B, /* gcc_cam_throttle_nrt_clk */
  243. 0x4A, /* gcc_cam_throttle_rt_clk */
  244. 0x14F, /* gcc_camss_axi_clk */
  245. 0x151, /* gcc_camss_camnoc_atb_clk */
  246. 0x152, /* gcc_camss_camnoc_nts_xo_clk */
  247. 0x14C, /* gcc_camss_cci_0_clk */
  248. 0x14D, /* gcc_camss_cci_1_clk */
  249. 0x13B, /* gcc_camss_cphy_0_clk */
  250. 0x13C, /* gcc_camss_cphy_1_clk */
  251. 0x13D, /* gcc_camss_cphy_2_clk */
  252. 0x13E, /* gcc_camss_cphy_3_clk */
  253. 0x12B, /* gcc_camss_csi0phytimer_clk */
  254. 0x12C, /* gcc_camss_csi1phytimer_clk */
  255. 0x12D, /* gcc_camss_csi2phytimer_clk */
  256. 0x12E, /* gcc_camss_csi3phytimer_clk */
  257. 0x12F, /* gcc_camss_mclk0_clk */
  258. 0x130, /* gcc_camss_mclk1_clk */
  259. 0x131, /* gcc_camss_mclk2_clk */
  260. 0x132, /* gcc_camss_mclk3_clk */
  261. 0x133, /* gcc_camss_mclk4_clk */
  262. 0x153, /* gcc_camss_nrt_axi_clk */
  263. 0x14B, /* gcc_camss_ope_ahb_clk */
  264. 0x149, /* gcc_camss_ope_clk */
  265. 0x155, /* gcc_camss_rt_axi_clk */
  266. 0x134, /* gcc_camss_tfe_0_clk */
  267. 0x138, /* gcc_camss_tfe_0_cphy_rx_clk */
  268. 0x13F, /* gcc_camss_tfe_0_csid_clk */
  269. 0x135, /* gcc_camss_tfe_1_clk */
  270. 0x139, /* gcc_camss_tfe_1_cphy_rx_clk */
  271. 0x141, /* gcc_camss_tfe_1_csid_clk */
  272. 0x136, /* gcc_camss_tfe_2_clk */
  273. 0x13A, /* gcc_camss_tfe_2_cphy_rx_clk */
  274. 0x143, /* gcc_camss_tfe_2_csid_clk */
  275. 0x14E, /* gcc_camss_top_ahb_clk */
  276. 0x1E, /* gcc_cfg_noc_usb3_prim_axi_clk */
  277. 0x46, /* gcc_disp_gpll0_div_clk_src */
  278. 0x3C, /* gcc_disp_hf_axi_clk */
  279. 0x4C, /* gcc_disp_sleep_clk */
  280. 0x48, /* gcc_disp_throttle_core_clk */
  281. 0xC5, /* gcc_gp1_clk */
  282. 0xC6, /* gcc_gp2_clk */
  283. 0xC7, /* gcc_gp3_clk */
  284. 0xFB, /* gcc_gpu_gpll0_clk_src */
  285. 0xFC, /* gcc_gpu_gpll0_div_clk_src */
  286. 0xF8, /* gcc_gpu_memnoc_gfx_clk */
  287. 0xFA, /* gcc_gpu_snoc_dvm_gfx_clk */
  288. 0xFF, /* gcc_gpu_throttle_core_clk */
  289. 0x7D, /* gcc_pdm2_clk */
  290. 0x7B, /* gcc_pdm_ahb_clk */
  291. 0x7C, /* gcc_pdm_xo4_clk */
  292. 0x7E, /* gcc_prng_ahb_clk */
  293. 0x39, /* gcc_qmip_camera_nrt_ahb_clk */
  294. 0x47, /* gcc_qmip_camera_rt_ahb_clk */
  295. 0x3A, /* gcc_qmip_disp_ahb_clk */
  296. 0xFD, /* gcc_qmip_gpu_cfg_ahb_clk */
  297. 0x38, /* gcc_qmip_video_vcodec_ahb_clk */
  298. 0x6A, /* gcc_qupv3_wrap0_core_2x_clk */
  299. 0x69, /* gcc_qupv3_wrap0_core_clk */
  300. 0x6B, /* gcc_qupv3_wrap0_s0_clk */
  301. 0x6C, /* gcc_qupv3_wrap0_s1_clk */
  302. 0x6D, /* gcc_qupv3_wrap0_s2_clk */
  303. 0x6E, /* gcc_qupv3_wrap0_s3_clk */
  304. 0x6F, /* gcc_qupv3_wrap0_s4_clk */
  305. 0x70, /* gcc_qupv3_wrap0_s5_clk */
  306. 0x74, /* gcc_qupv3_wrap1_core_2x_clk */
  307. 0x73, /* gcc_qupv3_wrap1_core_clk */
  308. 0x75, /* gcc_qupv3_wrap1_s0_clk */
  309. 0x76, /* gcc_qupv3_wrap1_s1_clk */
  310. 0x77, /* gcc_qupv3_wrap1_s2_clk */
  311. 0x78, /* gcc_qupv3_wrap1_s3_clk */
  312. 0x7A, /* gcc_qupv3_wrap1_s5_clk */
  313. 0x67, /* gcc_qupv3_wrap_0_m_ahb_clk */
  314. 0x68, /* gcc_qupv3_wrap_0_s_ahb_clk */
  315. 0x103, /* gcc_sdcc1_ahb_clk */
  316. 0x102, /* gcc_sdcc1_apps_clk */
  317. 0x104, /* gcc_sdcc1_ice_core_clk */
  318. 0x66, /* gcc_sdcc2_ahb_clk */
  319. 0x65, /* gcc_sdcc2_apps_clk */
  320. 0x9, /* gcc_sys_noc_cpuss_ahb_clk */
  321. 0x1B, /* gcc_sys_noc_ufs_phy_axi_clk */
  322. 0x1A, /* gcc_sys_noc_usb3_prim_axi_clk */
  323. 0x122, /* gcc_ufs_phy_ahb_clk */
  324. 0x121, /* gcc_ufs_phy_axi_clk */
  325. 0x128, /* gcc_ufs_phy_ice_core_clk */
  326. 0x129, /* gcc_ufs_phy_phy_aux_clk */
  327. 0x124, /* gcc_ufs_phy_rx_symbol_0_clk */
  328. 0x123, /* gcc_ufs_phy_tx_symbol_0_clk */
  329. 0x127, /* gcc_ufs_phy_unipro_core_clk */
  330. 0x5C, /* gcc_usb30_prim_master_clk */
  331. 0x5E, /* gcc_usb30_prim_mock_utmi_clk */
  332. 0x5D, /* gcc_usb30_prim_sleep_clk */
  333. 0x5F, /* gcc_usb3_prim_phy_com_aux_clk */
  334. 0x60, /* gcc_usb3_prim_phy_pipe_clk */
  335. 0x15B, /* gcc_vcodec0_axi_clk */
  336. 0x15C, /* gcc_venus_ahb_clk */
  337. 0x15A, /* gcc_venus_ctl_axi_clk */
  338. 0x3B, /* gcc_video_axi0_clk */
  339. 0x49, /* gcc_video_throttle_core_clk */
  340. 0x158, /* gcc_video_vcodec0_sys_clk */
  341. 0x156, /* gcc_video_venus_ctl_clk */
  342. 0x3D, /* gcc_video_xo_clk */
  343. 0xF7, /* gpu_cc_debug_mux */
  344. 0xA9, /* mc_cc_debug_mux */
  345. 0x1C, /* measure_only_cnoc_clk */
  346. 0x36, /* measure_only_gcc_camera_ahb_clk */
  347. 0x3E, /* measure_only_gcc_camera_xo_clk */
  348. 0xB5, /* measure_only_gcc_cpuss_gnoc_clk */
  349. 0x37, /* measure_only_gcc_disp_ahb_clk */
  350. 0x3F, /* measure_only_gcc_disp_xo_clk */
  351. 0xF5, /* measure_only_gcc_gpu_cfg_ahb_clk */
  352. 0x35, /* measure_only_gcc_video_ahb_clk */
  353. 0xD2, /* measure_only_ipa_2x_clk */
  354. 0x7, /* measure_only_snoc_clk */
  355. 0x162, /* measure_only_hwkm_km_core_clk */
  356. 0x161, /* measure_only_hwkm_ahb_clk */
  357. 0x15E, /* measure_only_pka_core_clk */
  358. 0x15D, /* measure_only_pka_ahb_clk */
  359. };
  360. static struct clk_debug_mux gcc_debug_mux = {
  361. .priv = &debug_mux_priv,
  362. .debug_offset = 0x62000,
  363. .post_div_offset = 0x30000,
  364. .cbcr_offset = 0x30004,
  365. .src_sel_mask = 0x3FF,
  366. .src_sel_shift = 0,
  367. .post_div_mask = 0xF,
  368. .post_div_shift = 0,
  369. .post_div_val = 1,
  370. .mux_sels = gcc_debug_mux_sels,
  371. .num_mux_sels = ARRAY_SIZE(gcc_debug_mux_sels),
  372. .hw.init = &(const struct clk_init_data){
  373. .name = "gcc_debug_mux",
  374. .ops = &clk_debug_mux_ops,
  375. .parent_names = gcc_debug_mux_parent_names,
  376. .num_parents = ARRAY_SIZE(gcc_debug_mux_parent_names),
  377. },
  378. };
  379. static const char *const gpu_cc_debug_mux_parent_names[] = {
  380. "gpu_cc_cx_gfx3d_clk",
  381. "gpu_cc_cx_gfx3d_slv_clk",
  382. "gpu_cc_cx_gmu_clk",
  383. "gpu_cc_cx_snoc_dvm_clk",
  384. "gpu_cc_cxo_aon_clk",
  385. "gpu_cc_cxo_clk",
  386. "gpu_cc_gx_gfx3d_clk",
  387. "gpu_cc_gx_gmu_clk",
  388. "gpu_cc_sleep_clk",
  389. "measure_only_gpu_cc_ahb_clk",
  390. "measure_only_gpu_cc_gx_cxo_clk",
  391. };
  392. static int gpu_cc_debug_mux_sels[] = {
  393. 0x1A, /* gpu_cc_cx_gfx3d_clk */
  394. 0x1B, /* gpu_cc_cx_gfx3d_slv_clk */
  395. 0x19, /* gpu_cc_cx_gmu_clk */
  396. 0x16, /* gpu_cc_cx_snoc_dvm_clk */
  397. 0xB, /* gpu_cc_cxo_aon_clk */
  398. 0xA, /* gpu_cc_cxo_clk */
  399. 0xC, /* gpu_cc_gx_gfx3d_clk */
  400. 0x10, /* gpu_cc_gx_gmu_clk */
  401. 0x17, /* gpu_cc_sleep_clk */
  402. 0x11, /* measure_only_gpu_cc_ahb_clk */
  403. 0xF, /* measure_only_gpu_cc_gx_cxo_clk */
  404. };
  405. static struct clk_debug_mux gpu_cc_debug_mux = {
  406. .priv = &debug_mux_priv,
  407. .debug_offset = 0x1568,
  408. .post_div_offset = 0x10FC,
  409. .cbcr_offset = 0x1100,
  410. .src_sel_mask = 0xFF,
  411. .src_sel_shift = 0,
  412. .post_div_mask = 0x3,
  413. .post_div_shift = 0,
  414. .post_div_val = 2,
  415. .mux_sels = gpu_cc_debug_mux_sels,
  416. .num_mux_sels = ARRAY_SIZE(gpu_cc_debug_mux_sels),
  417. .hw.init = &(const struct clk_init_data){
  418. .name = "gpu_cc_debug_mux",
  419. .ops = &clk_debug_mux_ops,
  420. .parent_names = gpu_cc_debug_mux_parent_names,
  421. .num_parents = ARRAY_SIZE(gpu_cc_debug_mux_parent_names),
  422. },
  423. };
  424. static const char *const mc_cc_debug_mux_parent_names[] = {
  425. "measure_only_mccc_clk",
  426. };
  427. static struct clk_debug_mux mc_cc_debug_mux = {
  428. .period_offset = 0x20,
  429. .hw.init = &(const struct clk_init_data){
  430. .name = "mc_cc_debug_mux",
  431. .ops = &clk_debug_mux_ops,
  432. .parent_names = mc_cc_debug_mux_parent_names,
  433. .num_parents = ARRAY_SIZE(mc_cc_debug_mux_parent_names),
  434. },
  435. };
  436. static struct mux_regmap_names mux_list[] = {
  437. { .mux = &cpu_cc_debug_mux, .regmap_name = "qcom,cpucc" },
  438. { .mux = &disp_cc_debug_mux, .regmap_name = "qcom,dispcc" },
  439. { .mux = &gpu_cc_debug_mux, .regmap_name = "qcom,gpucc" },
  440. { .mux = &mc_cc_debug_mux, .regmap_name = "qcom,mccc" },
  441. { .mux = &gcc_debug_mux, .regmap_name = "qcom,gcc" },
  442. };
  443. static struct clk_dummy measure_only_mccc_clk = {
  444. .rrate = 1000,
  445. .hw.init = &(const struct clk_init_data){
  446. .name = "measure_only_mccc_clk",
  447. .ops = &clk_dummy_ops,
  448. },
  449. };
  450. static struct clk_dummy measure_only_cnoc_clk = {
  451. .rrate = 1000,
  452. .hw.init = &(const struct clk_init_data){
  453. .name = "measure_only_cnoc_clk",
  454. .ops = &clk_dummy_ops,
  455. },
  456. };
  457. static struct clk_dummy measure_only_disp_cc_sleep_clk = {
  458. .rrate = 1000,
  459. .hw.init = &(const struct clk_init_data){
  460. .name = "measure_only_disp_cc_sleep_clk",
  461. .ops = &clk_dummy_ops,
  462. },
  463. };
  464. static struct clk_dummy measure_only_disp_cc_xo_clk = {
  465. .rrate = 1000,
  466. .hw.init = &(const struct clk_init_data){
  467. .name = "measure_only_disp_cc_xo_clk",
  468. .ops = &clk_dummy_ops,
  469. },
  470. };
  471. static struct clk_dummy measure_only_gcc_camera_ahb_clk = {
  472. .rrate = 1000,
  473. .hw.init = &(const struct clk_init_data){
  474. .name = "measure_only_gcc_camera_ahb_clk",
  475. .ops = &clk_dummy_ops,
  476. },
  477. };
  478. static struct clk_dummy measure_only_gcc_camera_xo_clk = {
  479. .rrate = 1000,
  480. .hw.init = &(const struct clk_init_data){
  481. .name = "measure_only_gcc_camera_xo_clk",
  482. .ops = &clk_dummy_ops,
  483. },
  484. };
  485. static struct clk_dummy measure_only_gcc_cpuss_gnoc_clk = {
  486. .rrate = 1000,
  487. .hw.init = &(const struct clk_init_data){
  488. .name = "measure_only_gcc_cpuss_gnoc_clk",
  489. .ops = &clk_dummy_ops,
  490. },
  491. };
  492. static struct clk_dummy measure_only_gcc_disp_ahb_clk = {
  493. .rrate = 1000,
  494. .hw.init = &(const struct clk_init_data){
  495. .name = "measure_only_gcc_disp_ahb_clk",
  496. .ops = &clk_dummy_ops,
  497. },
  498. };
  499. static struct clk_dummy measure_only_gcc_disp_xo_clk = {
  500. .rrate = 1000,
  501. .hw.init = &(const struct clk_init_data){
  502. .name = "measure_only_gcc_disp_xo_clk",
  503. .ops = &clk_dummy_ops,
  504. },
  505. };
  506. static struct clk_dummy measure_only_gcc_gpu_cfg_ahb_clk = {
  507. .rrate = 1000,
  508. .hw.init = &(const struct clk_init_data){
  509. .name = "measure_only_gcc_gpu_cfg_ahb_clk",
  510. .ops = &clk_dummy_ops,
  511. },
  512. };
  513. static struct clk_dummy measure_only_gcc_video_ahb_clk = {
  514. .rrate = 1000,
  515. .hw.init = &(const struct clk_init_data){
  516. .name = "measure_only_gcc_video_ahb_clk",
  517. .ops = &clk_dummy_ops,
  518. },
  519. };
  520. static struct clk_dummy measure_only_gpu_cc_ahb_clk = {
  521. .rrate = 1000,
  522. .hw.init = &(const struct clk_init_data){
  523. .name = "measure_only_gpu_cc_ahb_clk",
  524. .ops = &clk_dummy_ops,
  525. },
  526. };
  527. static struct clk_dummy measure_only_gpu_cc_gx_cxo_clk = {
  528. .rrate = 1000,
  529. .hw.init = &(const struct clk_init_data){
  530. .name = "measure_only_gpu_cc_gx_cxo_clk",
  531. .ops = &clk_dummy_ops,
  532. },
  533. };
  534. static struct clk_dummy measure_only_ipa_2x_clk = {
  535. .rrate = 1000,
  536. .hw.init = &(const struct clk_init_data){
  537. .name = "measure_only_ipa_2x_clk",
  538. .ops = &clk_dummy_ops,
  539. },
  540. };
  541. static struct clk_dummy measure_only_snoc_clk = {
  542. .rrate = 1000,
  543. .hw.init = &(const struct clk_init_data){
  544. .name = "measure_only_snoc_clk",
  545. .ops = &clk_dummy_ops,
  546. },
  547. };
  548. static struct clk_dummy measure_only_hwkm_km_core_clk = {
  549. .rrate = 1000,
  550. .hw.init = &(const struct clk_init_data){
  551. .name = "measure_only_hwkm_km_core_clk",
  552. .ops = &clk_dummy_ops,
  553. },
  554. };
  555. static struct clk_dummy measure_only_hwkm_ahb_clk = {
  556. .rrate = 1000,
  557. .hw.init = &(const struct clk_init_data){
  558. .name = "measure_only_hwkm_ahb_clk",
  559. .ops = &clk_dummy_ops,
  560. },
  561. };
  562. static struct clk_dummy measure_only_pka_core_clk = {
  563. .rrate = 1000,
  564. .hw.init = &(const struct clk_init_data){
  565. .name = "measure_only_pka_core_clk",
  566. .ops = &clk_dummy_ops,
  567. },
  568. };
  569. static struct clk_dummy measure_only_pka_ahb_clk = {
  570. .rrate = 1000,
  571. .hw.init = &(const struct clk_init_data){
  572. .name = "measure_only_pka_ahb_clk",
  573. .ops = &clk_dummy_ops,
  574. },
  575. };
  576. static struct clk_dummy perfcl_clk = {
  577. .rrate = 1000,
  578. .hw.init = &(const struct clk_init_data){
  579. .name = "perfcl_clk",
  580. .ops = &clk_dummy_ops,
  581. },
  582. };
  583. static struct clk_dummy pwrcl_clk = {
  584. .rrate = 1000,
  585. .hw.init = &(const struct clk_init_data){
  586. .name = "pwrcl_clk",
  587. .ops = &clk_dummy_ops,
  588. },
  589. };
  590. static struct clk_dummy l3_clk = {
  591. .rrate = 1000,
  592. .hw.init = &(const struct clk_init_data){
  593. .name = "l3_clk",
  594. .ops = &clk_dummy_ops,
  595. },
  596. };
  597. struct clk_hw *debugcc_holi_hws[] = {
  598. &measure_only_cnoc_clk.hw,
  599. &measure_only_disp_cc_sleep_clk.hw,
  600. &measure_only_disp_cc_xo_clk.hw,
  601. &measure_only_gcc_camera_ahb_clk.hw,
  602. &measure_only_gcc_camera_xo_clk.hw,
  603. &measure_only_gcc_cpuss_gnoc_clk.hw,
  604. &measure_only_gcc_disp_ahb_clk.hw,
  605. &measure_only_gcc_disp_xo_clk.hw,
  606. &measure_only_gcc_gpu_cfg_ahb_clk.hw,
  607. &measure_only_gcc_video_ahb_clk.hw,
  608. &measure_only_gpu_cc_ahb_clk.hw,
  609. &measure_only_gpu_cc_gx_cxo_clk.hw,
  610. &measure_only_ipa_2x_clk.hw,
  611. &measure_only_mccc_clk.hw,
  612. &measure_only_snoc_clk.hw,
  613. &measure_only_hwkm_km_core_clk.hw,
  614. &measure_only_hwkm_ahb_clk.hw,
  615. &measure_only_pka_core_clk.hw,
  616. &measure_only_pka_ahb_clk.hw,
  617. &perfcl_clk.hw,
  618. &pwrcl_clk.hw,
  619. &l3_clk.hw,
  620. };
  621. static const struct of_device_id clk_debug_match_table[] = {
  622. { .compatible = "qcom,holi-debugcc" },
  623. { }
  624. };
  625. static int clk_debug_holi_probe(struct platform_device *pdev)
  626. {
  627. struct clk *clk;
  628. int ret = 0, i;
  629. BUILD_BUG_ON(ARRAY_SIZE(disp_cc_debug_mux_parent_names) !=
  630. ARRAY_SIZE(disp_cc_debug_mux_sels));
  631. BUILD_BUG_ON(ARRAY_SIZE(gcc_debug_mux_parent_names) !=
  632. ARRAY_SIZE(gcc_debug_mux_sels));
  633. BUILD_BUG_ON(ARRAY_SIZE(gpu_cc_debug_mux_parent_names) !=
  634. ARRAY_SIZE(gpu_cc_debug_mux_sels));
  635. clk = devm_clk_get(&pdev->dev, "xo_clk_src");
  636. if (IS_ERR(clk)) {
  637. if (PTR_ERR(clk) != -EPROBE_DEFER)
  638. dev_err(&pdev->dev, "Unable to get xo clock\n");
  639. return PTR_ERR(clk);
  640. }
  641. debug_mux_priv.cxo = clk;
  642. for (i = 0; i < ARRAY_SIZE(mux_list); i++) {
  643. if (IS_ERR_OR_NULL(mux_list[i].mux->regmap)) {
  644. ret = map_debug_bases(pdev,
  645. mux_list[i].regmap_name, mux_list[i].mux);
  646. if (ret == -EBADR)
  647. continue;
  648. else if (ret)
  649. return ret;
  650. }
  651. }
  652. for (i = 0; i < ARRAY_SIZE(debugcc_holi_hws); i++) {
  653. clk = devm_clk_register(&pdev->dev, debugcc_holi_hws[i]);
  654. if (IS_ERR(clk)) {
  655. dev_err(&pdev->dev, "Unable to register %s, err:(%d)\n",
  656. clk_hw_get_name(debugcc_holi_hws[i]),
  657. PTR_ERR(clk));
  658. return PTR_ERR(clk);
  659. }
  660. }
  661. for (i = 0; i < ARRAY_SIZE(mux_list); i++) {
  662. ret = devm_clk_register_debug_mux(&pdev->dev, mux_list[i].mux);
  663. if (ret) {
  664. dev_err(&pdev->dev, "Unable to register mux clk %s, err:(%d)\n",
  665. qcom_clk_hw_get_name(&mux_list[i].mux->hw),
  666. ret);
  667. return ret;
  668. }
  669. }
  670. ret = clk_debug_measure_register(&gcc_debug_mux.hw);
  671. if (ret) {
  672. dev_err(&pdev->dev, "Could not register Measure clocks\n");
  673. return ret;
  674. }
  675. dev_info(&pdev->dev, "Registered debug measure clocks\n");
  676. return ret;
  677. }
  678. static struct platform_driver clk_debug_driver = {
  679. .probe = clk_debug_holi_probe,
  680. .driver = {
  681. .name = "holi-debugcc",
  682. .of_match_table = clk_debug_match_table,
  683. },
  684. };
  685. static int __init clk_debug_holi_init(void)
  686. {
  687. return platform_driver_register(&clk_debug_driver);
  688. }
  689. arch_initcall(clk_debug_holi_init);
  690. MODULE_DESCRIPTION("QTI DEBUG CC HOLI Driver");
  691. MODULE_LICENSE("GPL");