debugcc-blair.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2021, 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 = 0xF,
  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_cci_0_clk",
  121. "gcc_camss_cci_1_clk",
  122. "gcc_camss_cphy_0_clk",
  123. "gcc_camss_cphy_1_clk",
  124. "gcc_camss_cphy_2_clk",
  125. "gcc_camss_cphy_3_clk",
  126. "gcc_camss_csi0phytimer_clk",
  127. "gcc_camss_csi1phytimer_clk",
  128. "gcc_camss_csi2phytimer_clk",
  129. "gcc_camss_csi3phytimer_clk",
  130. "gcc_camss_mclk0_clk",
  131. "gcc_camss_mclk1_clk",
  132. "gcc_camss_mclk2_clk",
  133. "gcc_camss_mclk3_clk",
  134. "gcc_camss_mclk4_clk",
  135. "gcc_camss_nrt_axi_clk",
  136. "gcc_camss_ope_ahb_clk",
  137. "gcc_camss_ope_clk",
  138. "gcc_camss_rt_axi_clk",
  139. "gcc_camss_tfe_0_clk",
  140. "gcc_camss_tfe_0_cphy_rx_clk",
  141. "gcc_camss_tfe_0_csid_clk",
  142. "gcc_camss_tfe_1_clk",
  143. "gcc_camss_tfe_1_cphy_rx_clk",
  144. "gcc_camss_tfe_1_csid_clk",
  145. "gcc_camss_tfe_2_clk",
  146. "gcc_camss_tfe_2_cphy_rx_clk",
  147. "gcc_camss_tfe_2_csid_clk",
  148. "gcc_camss_top_ahb_clk",
  149. "gcc_cfg_noc_usb3_prim_axi_clk",
  150. "gcc_disp_gpll0_div_clk_src",
  151. "gcc_disp_hf_axi_clk",
  152. "gcc_disp_sleep_clk",
  153. "gcc_disp_throttle_core_clk",
  154. "gcc_gp1_clk",
  155. "gcc_gp2_clk",
  156. "gcc_gp3_clk",
  157. "gcc_gpu_gpll0_clk_src",
  158. "gcc_gpu_gpll0_div_clk_src",
  159. "gcc_gpu_memnoc_gfx_clk",
  160. "gcc_gpu_snoc_dvm_gfx_clk",
  161. "gcc_gpu_throttle_core_clk",
  162. "gcc_pdm2_clk",
  163. "gcc_pdm_ahb_clk",
  164. "gcc_pdm_xo4_clk",
  165. "gcc_prng_ahb_clk",
  166. "gcc_qmip_camera_nrt_ahb_clk",
  167. "gcc_qmip_camera_rt_ahb_clk",
  168. "gcc_qmip_disp_ahb_clk",
  169. "gcc_qmip_gpu_cfg_ahb_clk",
  170. "gcc_qmip_video_vcodec_ahb_clk",
  171. "gcc_qupv3_wrap0_core_2x_clk",
  172. "gcc_qupv3_wrap0_core_clk",
  173. "gcc_qupv3_wrap0_s0_clk",
  174. "gcc_qupv3_wrap0_s1_clk",
  175. "gcc_qupv3_wrap0_s2_clk",
  176. "gcc_qupv3_wrap0_s3_clk",
  177. "gcc_qupv3_wrap0_s4_clk",
  178. "gcc_qupv3_wrap0_s5_clk",
  179. "gcc_qupv3_wrap1_core_2x_clk",
  180. "gcc_qupv3_wrap1_core_clk",
  181. "gcc_qupv3_wrap1_s0_clk",
  182. "gcc_qupv3_wrap1_s1_clk",
  183. "gcc_qupv3_wrap1_s2_clk",
  184. "gcc_qupv3_wrap1_s3_clk",
  185. "gcc_qupv3_wrap1_s5_clk",
  186. "gcc_qupv3_wrap_0_m_ahb_clk",
  187. "gcc_qupv3_wrap_0_s_ahb_clk",
  188. "gcc_sdcc1_ahb_clk",
  189. "gcc_sdcc1_apps_clk",
  190. "gcc_sdcc1_ice_core_clk",
  191. "gcc_sdcc2_ahb_clk",
  192. "gcc_sdcc2_apps_clk",
  193. "gcc_sys_noc_cpuss_ahb_clk",
  194. "gcc_sys_noc_ufs_phy_axi_clk",
  195. "gcc_sys_noc_usb3_prim_axi_clk",
  196. "gcc_ufs_phy_ahb_clk",
  197. "gcc_ufs_phy_axi_clk",
  198. "gcc_ufs_phy_ice_core_clk",
  199. "gcc_ufs_phy_phy_aux_clk",
  200. "gcc_ufs_phy_rx_symbol_0_clk",
  201. "gcc_ufs_phy_tx_symbol_0_clk",
  202. "gcc_ufs_phy_unipro_core_clk",
  203. "gcc_usb30_prim_master_clk",
  204. "gcc_usb30_prim_mock_utmi_clk",
  205. "gcc_usb30_prim_sleep_clk",
  206. "gcc_usb3_prim_phy_com_aux_clk",
  207. "gcc_usb3_prim_phy_pipe_clk",
  208. "gcc_vcodec0_axi_clk",
  209. "gcc_venus_ahb_clk",
  210. "gcc_venus_ctl_axi_clk",
  211. "gcc_video_axi0_clk",
  212. "gcc_video_throttle_core_clk",
  213. "gcc_video_vcodec0_sys_clk",
  214. "gcc_video_venus_ctl_clk",
  215. "gcc_video_xo_clk",
  216. "gpu_cc_debug_mux",
  217. "mc_cc_debug_mux",
  218. "measure_only_cnoc_clk",
  219. "measure_only_gcc_camera_ahb_clk",
  220. "measure_only_gcc_camera_xo_clk",
  221. "measure_only_gcc_cpuss_gnoc_clk",
  222. "measure_only_gcc_disp_ahb_clk",
  223. "measure_only_gcc_disp_xo_clk",
  224. "measure_only_gcc_gpu_cfg_ahb_clk",
  225. "measure_only_gcc_qupv3_wrap1_s4_clk",
  226. "measure_only_gcc_qupv3_wrap_1_m_ahb_clk",
  227. "measure_only_gcc_qupv3_wrap_1_s_ahb_clk",
  228. "measure_only_gcc_video_ahb_clk",
  229. "measure_only_hwkm_ahb_clk",
  230. "measure_only_hwkm_km_core_clk",
  231. "measure_only_ipa_2x_clk",
  232. "measure_only_pka_ahb_clk",
  233. "measure_only_pka_core_clk",
  234. "measure_only_snoc_clk",
  235. };
  236. static int gcc_debug_mux_sels[] = {
  237. 0xBF, /* cpu_cc_debug_mux */
  238. 0x43, /* disp_cc_debug_mux */
  239. 0x67, /* gcc_ahb2phy_csi_clk */
  240. 0x68, /* gcc_ahb2phy_usb_clk */
  241. 0x9D, /* gcc_bimc_gpu_axi_clk */
  242. 0x84, /* gcc_boot_rom_ahb_clk */
  243. 0x4D, /* gcc_cam_throttle_nrt_clk */
  244. 0x4C, /* gcc_cam_throttle_rt_clk */
  245. 0x154, /* gcc_camss_axi_clk */
  246. 0x151, /* gcc_camss_cci_0_clk */
  247. 0x152, /* gcc_camss_cci_1_clk */
  248. 0x140, /* gcc_camss_cphy_0_clk */
  249. 0x141, /* gcc_camss_cphy_1_clk */
  250. 0x142, /* gcc_camss_cphy_2_clk */
  251. 0x143, /* gcc_camss_cphy_3_clk */
  252. 0x130, /* gcc_camss_csi0phytimer_clk */
  253. 0x131, /* gcc_camss_csi1phytimer_clk */
  254. 0x132, /* gcc_camss_csi2phytimer_clk */
  255. 0x133, /* gcc_camss_csi3phytimer_clk */
  256. 0x134, /* gcc_camss_mclk0_clk */
  257. 0x135, /* gcc_camss_mclk1_clk */
  258. 0x136, /* gcc_camss_mclk2_clk */
  259. 0x137, /* gcc_camss_mclk3_clk */
  260. 0x138, /* gcc_camss_mclk4_clk */
  261. 0x158, /* gcc_camss_nrt_axi_clk */
  262. 0x150, /* gcc_camss_ope_ahb_clk */
  263. 0x14E, /* gcc_camss_ope_clk */
  264. 0x15A, /* gcc_camss_rt_axi_clk */
  265. 0x139, /* gcc_camss_tfe_0_clk */
  266. 0x13D, /* gcc_camss_tfe_0_cphy_rx_clk */
  267. 0x144, /* gcc_camss_tfe_0_csid_clk */
  268. 0x13A, /* gcc_camss_tfe_1_clk */
  269. 0x13E, /* gcc_camss_tfe_1_cphy_rx_clk */
  270. 0x146, /* gcc_camss_tfe_1_csid_clk */
  271. 0x13B, /* gcc_camss_tfe_2_clk */
  272. 0x13F, /* gcc_camss_tfe_2_cphy_rx_clk */
  273. 0x148, /* gcc_camss_tfe_2_csid_clk */
  274. 0x153, /* gcc_camss_top_ahb_clk */
  275. 0x1F, /* gcc_cfg_noc_usb3_prim_axi_clk */
  276. 0x48, /* gcc_disp_gpll0_div_clk_src */
  277. 0x3E, /* gcc_disp_hf_axi_clk */
  278. 0x4E, /* gcc_disp_sleep_clk */
  279. 0x4A, /* gcc_disp_throttle_core_clk */
  280. 0xCA, /* gcc_gp1_clk */
  281. 0xCB, /* gcc_gp2_clk */
  282. 0xCC, /* gcc_gp3_clk */
  283. 0xFF, /* gcc_gpu_gpll0_clk_src */
  284. 0x100, /* gcc_gpu_gpll0_div_clk_src */
  285. 0xFC, /* gcc_gpu_memnoc_gfx_clk */
  286. 0xFE, /* gcc_gpu_snoc_dvm_gfx_clk */
  287. 0x103, /* gcc_gpu_throttle_core_clk */
  288. 0x81, /* gcc_pdm2_clk */
  289. 0x7F, /* gcc_pdm_ahb_clk */
  290. 0x80, /* gcc_pdm_xo4_clk */
  291. 0x82, /* gcc_prng_ahb_clk */
  292. 0x3B, /* gcc_qmip_camera_nrt_ahb_clk */
  293. 0x49, /* gcc_qmip_camera_rt_ahb_clk */
  294. 0x3C, /* gcc_qmip_disp_ahb_clk */
  295. 0x101, /* gcc_qmip_gpu_cfg_ahb_clk */
  296. 0x3A, /* gcc_qmip_video_vcodec_ahb_clk */
  297. 0x6E, /* gcc_qupv3_wrap0_core_2x_clk */
  298. 0x6D, /* gcc_qupv3_wrap0_core_clk */
  299. 0x6F, /* gcc_qupv3_wrap0_s0_clk */
  300. 0x70, /* gcc_qupv3_wrap0_s1_clk */
  301. 0x71, /* gcc_qupv3_wrap0_s2_clk */
  302. 0x72, /* gcc_qupv3_wrap0_s3_clk */
  303. 0x73, /* gcc_qupv3_wrap0_s4_clk */
  304. 0x74, /* gcc_qupv3_wrap0_s5_clk */
  305. 0x78, /* gcc_qupv3_wrap1_core_2x_clk */
  306. 0x77, /* gcc_qupv3_wrap1_core_clk */
  307. 0x79, /* gcc_qupv3_wrap1_s0_clk */
  308. 0x7A, /* gcc_qupv3_wrap1_s1_clk */
  309. 0x7B, /* gcc_qupv3_wrap1_s2_clk */
  310. 0x7C, /* gcc_qupv3_wrap1_s3_clk */
  311. 0x7E, /* gcc_qupv3_wrap1_s5_clk */
  312. 0x6B, /* gcc_qupv3_wrap_0_m_ahb_clk */
  313. 0x6C, /* gcc_qupv3_wrap_0_s_ahb_clk */
  314. 0x108, /* gcc_sdcc1_ahb_clk */
  315. 0x107, /* gcc_sdcc1_apps_clk */
  316. 0x109, /* gcc_sdcc1_ice_core_clk */
  317. 0x6A, /* gcc_sdcc2_ahb_clk */
  318. 0x69, /* gcc_sdcc2_apps_clk */
  319. 0x9, /* gcc_sys_noc_cpuss_ahb_clk */
  320. 0x1B, /* gcc_sys_noc_ufs_phy_axi_clk */
  321. 0x1A, /* gcc_sys_noc_usb3_prim_axi_clk */
  322. 0x127, /* gcc_ufs_phy_ahb_clk */
  323. 0x126, /* gcc_ufs_phy_axi_clk */
  324. 0x12D, /* gcc_ufs_phy_ice_core_clk */
  325. 0x12E, /* gcc_ufs_phy_phy_aux_clk */
  326. 0x129, /* gcc_ufs_phy_rx_symbol_0_clk */
  327. 0x128, /* gcc_ufs_phy_tx_symbol_0_clk */
  328. 0x12C, /* gcc_ufs_phy_unipro_core_clk */
  329. 0x5E, /* gcc_usb30_prim_master_clk */
  330. 0x60, /* gcc_usb30_prim_mock_utmi_clk */
  331. 0x5F, /* gcc_usb30_prim_sleep_clk */
  332. 0x61, /* gcc_usb3_prim_phy_com_aux_clk */
  333. 0x62, /* gcc_usb3_prim_phy_pipe_clk */
  334. 0x160, /* gcc_vcodec0_axi_clk */
  335. 0x161, /* gcc_venus_ahb_clk */
  336. 0x15F, /* gcc_venus_ctl_axi_clk */
  337. 0x3D, /* gcc_video_axi0_clk */
  338. 0x4B, /* gcc_video_throttle_core_clk */
  339. 0x15D, /* gcc_video_vcodec0_sys_clk */
  340. 0x15B, /* gcc_video_venus_ctl_clk */
  341. 0x3F, /* gcc_video_xo_clk */
  342. 0xFB, /* gpu_cc_debug_mux */
  343. 0xAE, /* mc_cc_debug_mux */
  344. 0x1D, /* measure_only_cnoc_clk */
  345. 0x38, /* measure_only_gcc_camera_ahb_clk */
  346. 0x40, /* measure_only_gcc_camera_xo_clk */
  347. 0xBA, /* measure_only_gcc_cpuss_gnoc_clk */
  348. 0x39, /* measure_only_gcc_disp_ahb_clk */
  349. 0x41, /* measure_only_gcc_disp_xo_clk */
  350. 0xF9, /* measure_only_gcc_gpu_cfg_ahb_clk */
  351. 0x7D, /* measure_only_gcc_qupv3_wrap1_s4_clk */
  352. 0x75, /* measure_only_gcc_qupv3_wrap_1_m_ahb_clk */
  353. 0x76, /* measure_only_gcc_qupv3_wrap_1_s_ahb_clk */
  354. 0x37, /* measure_only_gcc_video_ahb_clk */
  355. 0x166, /* measure_only_hwkm_ahb_clk */
  356. 0x167, /* measure_only_hwkm_km_core_clk */
  357. 0xD7, /* measure_only_ipa_2x_clk */
  358. 0x162, /* measure_only_pka_ahb_clk */
  359. 0x163, /* measure_only_pka_core_clk */
  360. 0x7, /* measure_only_snoc_clk */
  361. };
  362. static struct clk_debug_mux gcc_debug_mux = {
  363. .priv = &debug_mux_priv,
  364. .debug_offset = 0x62000,
  365. .post_div_offset = 0x30000,
  366. .cbcr_offset = 0x30004,
  367. .src_sel_mask = 0x3FF,
  368. .src_sel_shift = 0,
  369. .post_div_mask = 0xF,
  370. .post_div_shift = 0,
  371. .post_div_val = 1,
  372. .mux_sels = gcc_debug_mux_sels,
  373. .num_mux_sels = ARRAY_SIZE(gcc_debug_mux_sels),
  374. .hw.init = &(const struct clk_init_data){
  375. .name = "gcc_debug_mux",
  376. .ops = &clk_debug_mux_ops,
  377. .parent_names = gcc_debug_mux_parent_names,
  378. .num_parents = ARRAY_SIZE(gcc_debug_mux_parent_names),
  379. },
  380. };
  381. static const char *const gpu_cc_debug_mux_parent_names[] = {
  382. "gpu_cc_cx_gfx3d_clk",
  383. "gpu_cc_cx_gfx3d_slv_clk",
  384. "gpu_cc_cx_gmu_clk",
  385. "gpu_cc_cx_snoc_dvm_clk",
  386. "gpu_cc_cxo_aon_clk",
  387. "gpu_cc_cxo_clk",
  388. "gpu_cc_gx_gfx3d_clk",
  389. "gpu_cc_gx_gmu_clk",
  390. "gpu_cc_sleep_clk",
  391. "measure_only_gpu_cc_ahb_clk",
  392. "measure_only_gpu_cc_gx_cxo_clk",
  393. };
  394. static int gpu_cc_debug_mux_sels[] = {
  395. 0x1A, /* gpu_cc_cx_gfx3d_clk */
  396. 0x1B, /* gpu_cc_cx_gfx3d_slv_clk */
  397. 0x19, /* gpu_cc_cx_gmu_clk */
  398. 0x16, /* gpu_cc_cx_snoc_dvm_clk */
  399. 0xB, /* gpu_cc_cxo_aon_clk */
  400. 0xA, /* gpu_cc_cxo_clk */
  401. 0xC, /* gpu_cc_gx_gfx3d_clk */
  402. 0x10, /* gpu_cc_gx_gmu_clk */
  403. 0x17, /* gpu_cc_sleep_clk */
  404. 0x11, /* measure_only_gpu_cc_ahb_clk */
  405. 0xF, /* measure_only_gpu_cc_gx_cxo_clk */
  406. };
  407. static struct clk_debug_mux gpu_cc_debug_mux = {
  408. .priv = &debug_mux_priv,
  409. .debug_offset = 0x1568,
  410. .post_div_offset = 0x10FC,
  411. .cbcr_offset = 0x1100,
  412. .src_sel_mask = 0xFF,
  413. .src_sel_shift = 0,
  414. .post_div_mask = 0xF,
  415. .post_div_shift = 0,
  416. .post_div_val = 2,
  417. .mux_sels = gpu_cc_debug_mux_sels,
  418. .num_mux_sels = ARRAY_SIZE(gpu_cc_debug_mux_sels),
  419. .hw.init = &(const struct clk_init_data){
  420. .name = "gpu_cc_debug_mux",
  421. .ops = &clk_debug_mux_ops,
  422. .parent_names = gpu_cc_debug_mux_parent_names,
  423. .num_parents = ARRAY_SIZE(gpu_cc_debug_mux_parent_names),
  424. },
  425. };
  426. static const char *const mc_cc_debug_mux_parent_names[] = {
  427. "measure_only_mccc_clk",
  428. };
  429. static struct clk_debug_mux mc_cc_debug_mux = {
  430. .period_offset = 0x20,
  431. .hw.init = &(const struct clk_init_data){
  432. .name = "mc_cc_debug_mux",
  433. .ops = &clk_debug_mux_ops,
  434. .parent_names = mc_cc_debug_mux_parent_names,
  435. .num_parents = ARRAY_SIZE(mc_cc_debug_mux_parent_names),
  436. },
  437. };
  438. static struct mux_regmap_names mux_list[] = {
  439. { .mux = &cpu_cc_debug_mux, .regmap_name = "qcom,cpucc" },
  440. { .mux = &disp_cc_debug_mux, .regmap_name = "qcom,dispcc" },
  441. { .mux = &gpu_cc_debug_mux, .regmap_name = "qcom,gpucc" },
  442. { .mux = &mc_cc_debug_mux, .regmap_name = "qcom,mccc" },
  443. { .mux = &gcc_debug_mux, .regmap_name = "qcom,gcc" },
  444. };
  445. static struct clk_dummy measure_only_cnoc_clk = {
  446. .rrate = 1000,
  447. .hw.init = &(const struct clk_init_data){
  448. .name = "measure_only_cnoc_clk",
  449. .ops = &clk_dummy_ops,
  450. },
  451. };
  452. static struct clk_dummy measure_only_mccc_clk = {
  453. .rrate = 1000,
  454. .hw.init = &(const struct clk_init_data){
  455. .name = "measure_only_mccc_clk",
  456. .ops = &clk_dummy_ops,
  457. },
  458. };
  459. static struct clk_dummy measure_only_disp_cc_sleep_clk = {
  460. .rrate = 1000,
  461. .hw.init = &(const struct clk_init_data){
  462. .name = "measure_only_disp_cc_sleep_clk",
  463. .ops = &clk_dummy_ops,
  464. },
  465. };
  466. static struct clk_dummy measure_only_disp_cc_xo_clk = {
  467. .rrate = 1000,
  468. .hw.init = &(const struct clk_init_data){
  469. .name = "measure_only_disp_cc_xo_clk",
  470. .ops = &clk_dummy_ops,
  471. },
  472. };
  473. static struct clk_dummy measure_only_gcc_camera_ahb_clk = {
  474. .rrate = 1000,
  475. .hw.init = &(const struct clk_init_data){
  476. .name = "measure_only_gcc_camera_ahb_clk",
  477. .ops = &clk_dummy_ops,
  478. },
  479. };
  480. static struct clk_dummy measure_only_gcc_camera_xo_clk = {
  481. .rrate = 1000,
  482. .hw.init = &(const struct clk_init_data){
  483. .name = "measure_only_gcc_camera_xo_clk",
  484. .ops = &clk_dummy_ops,
  485. },
  486. };
  487. static struct clk_dummy measure_only_gcc_cpuss_gnoc_clk = {
  488. .rrate = 1000,
  489. .hw.init = &(const struct clk_init_data){
  490. .name = "measure_only_gcc_cpuss_gnoc_clk",
  491. .ops = &clk_dummy_ops,
  492. },
  493. };
  494. static struct clk_dummy measure_only_gcc_disp_ahb_clk = {
  495. .rrate = 1000,
  496. .hw.init = &(const struct clk_init_data){
  497. .name = "measure_only_gcc_disp_ahb_clk",
  498. .ops = &clk_dummy_ops,
  499. },
  500. };
  501. static struct clk_dummy measure_only_gcc_disp_xo_clk = {
  502. .rrate = 1000,
  503. .hw.init = &(const struct clk_init_data){
  504. .name = "measure_only_gcc_disp_xo_clk",
  505. .ops = &clk_dummy_ops,
  506. },
  507. };
  508. static struct clk_dummy measure_only_gcc_gpu_cfg_ahb_clk = {
  509. .rrate = 1000,
  510. .hw.init = &(const struct clk_init_data){
  511. .name = "measure_only_gcc_gpu_cfg_ahb_clk",
  512. .ops = &clk_dummy_ops,
  513. },
  514. };
  515. static struct clk_dummy measure_only_gcc_qupv3_wrap1_s4_clk = {
  516. .rrate = 1000,
  517. .hw.init = &(const struct clk_init_data){
  518. .name = "measure_only_gcc_qupv3_wrap1_s4_clk",
  519. .ops = &clk_dummy_ops,
  520. },
  521. };
  522. static struct clk_dummy measure_only_gcc_qupv3_wrap_1_m_ahb_clk = {
  523. .rrate = 1000,
  524. .hw.init = &(const struct clk_init_data){
  525. .name = "measure_only_gcc_qupv3_wrap_1_m_ahb_clk",
  526. .ops = &clk_dummy_ops,
  527. },
  528. };
  529. static struct clk_dummy measure_only_gcc_qupv3_wrap_1_s_ahb_clk = {
  530. .rrate = 1000,
  531. .hw.init = &(const struct clk_init_data){
  532. .name = "measure_only_gcc_qupv3_wrap_1_s_ahb_clk",
  533. .ops = &clk_dummy_ops,
  534. },
  535. };
  536. static struct clk_dummy measure_only_gcc_video_ahb_clk = {
  537. .rrate = 1000,
  538. .hw.init = &(const struct clk_init_data){
  539. .name = "measure_only_gcc_video_ahb_clk",
  540. .ops = &clk_dummy_ops,
  541. },
  542. };
  543. static struct clk_dummy measure_only_gpu_cc_ahb_clk = {
  544. .rrate = 1000,
  545. .hw.init = &(const struct clk_init_data){
  546. .name = "measure_only_gpu_cc_ahb_clk",
  547. .ops = &clk_dummy_ops,
  548. },
  549. };
  550. static struct clk_dummy measure_only_gpu_cc_gx_cxo_clk = {
  551. .rrate = 1000,
  552. .hw.init = &(const struct clk_init_data){
  553. .name = "measure_only_gpu_cc_gx_cxo_clk",
  554. .ops = &clk_dummy_ops,
  555. },
  556. };
  557. static struct clk_dummy measure_only_hwkm_ahb_clk = {
  558. .rrate = 1000,
  559. .hw.init = &(const struct clk_init_data){
  560. .name = "measure_only_hwkm_ahb_clk",
  561. .ops = &clk_dummy_ops,
  562. },
  563. };
  564. static struct clk_dummy measure_only_hwkm_km_core_clk = {
  565. .rrate = 1000,
  566. .hw.init = &(const struct clk_init_data){
  567. .name = "measure_only_hwkm_km_core_clk",
  568. .ops = &clk_dummy_ops,
  569. },
  570. };
  571. static struct clk_dummy measure_only_ipa_2x_clk = {
  572. .rrate = 1000,
  573. .hw.init = &(const struct clk_init_data){
  574. .name = "measure_only_ipa_2x_clk",
  575. .ops = &clk_dummy_ops,
  576. },
  577. };
  578. static struct clk_dummy measure_only_pka_ahb_clk = {
  579. .rrate = 1000,
  580. .hw.init = &(const struct clk_init_data){
  581. .name = "measure_only_pka_ahb_clk",
  582. .ops = &clk_dummy_ops,
  583. },
  584. };
  585. static struct clk_dummy measure_only_pka_core_clk = {
  586. .rrate = 1000,
  587. .hw.init = &(const struct clk_init_data){
  588. .name = "measure_only_pka_core_clk",
  589. .ops = &clk_dummy_ops,
  590. },
  591. };
  592. static struct clk_dummy measure_only_snoc_clk = {
  593. .rrate = 1000,
  594. .hw.init = &(const struct clk_init_data){
  595. .name = "measure_only_snoc_clk",
  596. .ops = &clk_dummy_ops,
  597. },
  598. };
  599. static struct clk_dummy perfcl_clk = {
  600. .rrate = 1000,
  601. .hw.init = &(const struct clk_init_data){
  602. .name = "perfcl_clk",
  603. .ops = &clk_dummy_ops,
  604. },
  605. };
  606. static struct clk_dummy pwrcl_clk = {
  607. .rrate = 1000,
  608. .hw.init = &(const struct clk_init_data){
  609. .name = "pwrcl_clk",
  610. .ops = &clk_dummy_ops,
  611. },
  612. };
  613. static struct clk_dummy l3_clk = {
  614. .rrate = 1000,
  615. .hw.init = &(const struct clk_init_data){
  616. .name = "l3_clk",
  617. .ops = &clk_dummy_ops,
  618. },
  619. };
  620. static struct clk_hw *debugcc_blair_hws[] = {
  621. &measure_only_cnoc_clk.hw,
  622. &measure_only_disp_cc_sleep_clk.hw,
  623. &measure_only_disp_cc_xo_clk.hw,
  624. &measure_only_gcc_camera_ahb_clk.hw,
  625. &measure_only_gcc_camera_xo_clk.hw,
  626. &measure_only_gcc_cpuss_gnoc_clk.hw,
  627. &measure_only_gcc_disp_ahb_clk.hw,
  628. &measure_only_gcc_disp_xo_clk.hw,
  629. &measure_only_gcc_gpu_cfg_ahb_clk.hw,
  630. &measure_only_gcc_qupv3_wrap1_s4_clk.hw,
  631. &measure_only_gcc_qupv3_wrap_1_m_ahb_clk.hw,
  632. &measure_only_gcc_qupv3_wrap_1_s_ahb_clk.hw,
  633. &measure_only_gcc_video_ahb_clk.hw,
  634. &measure_only_gpu_cc_ahb_clk.hw,
  635. &measure_only_gpu_cc_gx_cxo_clk.hw,
  636. &measure_only_ipa_2x_clk.hw,
  637. &measure_only_mccc_clk.hw,
  638. &measure_only_snoc_clk.hw,
  639. &measure_only_hwkm_km_core_clk.hw,
  640. &measure_only_hwkm_ahb_clk.hw,
  641. &measure_only_pka_core_clk.hw,
  642. &measure_only_pka_ahb_clk.hw,
  643. &perfcl_clk.hw,
  644. &pwrcl_clk.hw,
  645. &l3_clk.hw,
  646. };
  647. static const struct of_device_id clk_debug_match_table[] = {
  648. { .compatible = "qcom,blair-debugcc" },
  649. { }
  650. };
  651. static int clk_debug_blair_probe(struct platform_device *pdev)
  652. {
  653. struct clk *clk;
  654. int ret = 0, i;
  655. BUILD_BUG_ON(ARRAY_SIZE(disp_cc_debug_mux_parent_names) !=
  656. ARRAY_SIZE(disp_cc_debug_mux_sels));
  657. BUILD_BUG_ON(ARRAY_SIZE(gcc_debug_mux_parent_names) !=
  658. ARRAY_SIZE(gcc_debug_mux_sels));
  659. BUILD_BUG_ON(ARRAY_SIZE(gpu_cc_debug_mux_parent_names) !=
  660. ARRAY_SIZE(gpu_cc_debug_mux_sels));
  661. clk = devm_clk_get(&pdev->dev, "xo_clk_src");
  662. if (IS_ERR(clk)) {
  663. if (PTR_ERR(clk) != -EPROBE_DEFER)
  664. dev_err(&pdev->dev, "Unable to get xo clock\n");
  665. return PTR_ERR(clk);
  666. }
  667. debug_mux_priv.cxo = clk;
  668. for (i = 0; i < ARRAY_SIZE(mux_list); i++) {
  669. if (IS_ERR_OR_NULL(mux_list[i].mux->regmap)) {
  670. ret = map_debug_bases(pdev,
  671. mux_list[i].regmap_name, mux_list[i].mux);
  672. if (ret == -EBADR)
  673. continue;
  674. else if (ret)
  675. return ret;
  676. }
  677. }
  678. for (i = 0; i < ARRAY_SIZE(debugcc_blair_hws); i++) {
  679. clk = devm_clk_register(&pdev->dev, debugcc_blair_hws[i]);
  680. if (IS_ERR(clk)) {
  681. dev_err(&pdev->dev, "Unable to register %s, err:(%d)\n",
  682. clk_hw_get_name(debugcc_blair_hws[i]),
  683. PTR_ERR(clk));
  684. return PTR_ERR(clk);
  685. }
  686. }
  687. for (i = 0; i < ARRAY_SIZE(mux_list); i++) {
  688. ret = devm_clk_register_debug_mux(&pdev->dev, mux_list[i].mux);
  689. if (ret) {
  690. dev_err(&pdev->dev, "Unable to register mux clk %s, err:(%d)\n",
  691. qcom_clk_hw_get_name(&mux_list[i].mux->hw),
  692. ret);
  693. return ret;
  694. }
  695. }
  696. ret = clk_debug_measure_register(&gcc_debug_mux.hw);
  697. if (ret) {
  698. dev_err(&pdev->dev, "Could not register Measure clocks\n");
  699. return ret;
  700. }
  701. dev_info(&pdev->dev, "Registered debug measure clocks\n");
  702. return ret;
  703. }
  704. static struct platform_driver clk_debug_driver = {
  705. .probe = clk_debug_blair_probe,
  706. .driver = {
  707. .name = "blair-debugcc",
  708. .of_match_table = clk_debug_match_table,
  709. },
  710. };
  711. static int __init clk_debug_blair_init(void)
  712. {
  713. return platform_driver_register(&clk_debug_driver);
  714. }
  715. fs_initcall(clk_debug_blair_init);
  716. MODULE_DESCRIPTION("QTI DEBUG CC BLAIR Driver");
  717. MODULE_LICENSE("GPL");