debugcc-pitti.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #define pr_fmt(fmt) "clk: %s: " fmt, __func__
  6. #include <linux/clk.h>
  7. #include <linux/clk-provider.h>
  8. #include <linux/err.h>
  9. #include <linux/kernel.h>
  10. #include <linux/mfd/syscon.h>
  11. #include <linux/module.h>
  12. #include <linux/of.h>
  13. #include <linux/of_device.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/regmap.h>
  16. #include "clk-debug.h"
  17. #include "common.h"
  18. static struct measure_clk_data debug_mux_priv = {
  19. .ctl_reg = 0x62038,
  20. .status_reg = 0x6203C,
  21. .xo_div4_cbcr = 0x28008,
  22. };
  23. static const char *const apss_cc_debug_mux_parent_names[] = {
  24. "measure_only_apcs_gold_post_acd_clk",
  25. "measure_only_apcs_l3_post_acd_clk",
  26. "measure_only_apcs_silver_post_acd_clk",
  27. };
  28. static int apss_cc_debug_mux_sels[] = {
  29. 0x25, /* measure_only_apcs_gold_post_acd_clk */
  30. 0x41, /* measure_only_apcs_l3_post_acd_clk */
  31. 0x21, /* measure_only_apcs_silver_post_acd_clk */
  32. };
  33. static int apss_cc_debug_mux_pre_divs[] = {
  34. 0x8, /* measure_only_apcs_gold_post_acd_clk */
  35. 0x4, /* measure_only_apcs_l3_post_acd_clk */
  36. 0x4, /* measure_only_apcs_silver_post_acd_clk */
  37. };
  38. static struct clk_debug_mux apss_cc_debug_mux = {
  39. .priv = &debug_mux_priv,
  40. .debug_offset = 0x18,
  41. .post_div_offset = 0x18,
  42. .cbcr_offset = 0x0,
  43. .src_sel_mask = 0x7F0,
  44. .src_sel_shift = 4,
  45. .post_div_mask = 0x7800,
  46. .post_div_shift = 11,
  47. .post_div_val = 1,
  48. .mux_sels = apss_cc_debug_mux_sels,
  49. .num_mux_sels = ARRAY_SIZE(apss_cc_debug_mux_sels),
  50. .pre_div_vals = apss_cc_debug_mux_pre_divs,
  51. .hw.init = &(const struct clk_init_data){
  52. .name = "apss_cc_debug_mux",
  53. .ops = &clk_debug_mux_ops,
  54. .parent_names = apss_cc_debug_mux_parent_names,
  55. .num_parents = ARRAY_SIZE(apss_cc_debug_mux_parent_names),
  56. },
  57. };
  58. static const char *const disp_cc_debug_mux_parent_names[] = {
  59. "disp_cc_mdss_accu_clk",
  60. "disp_cc_mdss_ahb1_clk",
  61. "disp_cc_mdss_ahb_clk",
  62. "disp_cc_mdss_byte0_clk",
  63. "disp_cc_mdss_byte0_intf_clk",
  64. "disp_cc_mdss_esc0_clk",
  65. "disp_cc_mdss_mdp1_clk",
  66. "disp_cc_mdss_mdp_clk",
  67. "disp_cc_mdss_mdp_lut1_clk",
  68. "disp_cc_mdss_mdp_lut_clk",
  69. "disp_cc_mdss_non_gdsc_ahb_clk",
  70. "disp_cc_mdss_pclk0_clk",
  71. "disp_cc_mdss_rot1_clk",
  72. "disp_cc_mdss_rot_clk",
  73. "disp_cc_mdss_rscc_ahb_clk",
  74. "disp_cc_mdss_rscc_vsync_clk",
  75. "disp_cc_mdss_vsync1_clk",
  76. "disp_cc_mdss_vsync_clk",
  77. "disp_cc_sleep_clk",
  78. "measure_only_disp_cc_xo_clk",
  79. };
  80. static int disp_cc_debug_mux_sels[] = {
  81. 0x46, /* disp_cc_mdss_accu_clk */
  82. 0x39, /* disp_cc_mdss_ahb1_clk */
  83. 0x34, /* disp_cc_mdss_ahb_clk */
  84. 0x14, /* disp_cc_mdss_byte0_clk */
  85. 0x15, /* disp_cc_mdss_byte0_intf_clk */
  86. 0x16, /* disp_cc_mdss_esc0_clk */
  87. 0x35, /* disp_cc_mdss_mdp1_clk */
  88. 0x10, /* disp_cc_mdss_mdp_clk */
  89. 0x37, /* disp_cc_mdss_mdp_lut1_clk */
  90. 0x12, /* disp_cc_mdss_mdp_lut_clk */
  91. 0x3A, /* disp_cc_mdss_non_gdsc_ahb_clk */
  92. 0xF, /* disp_cc_mdss_pclk0_clk */
  93. 0x36, /* disp_cc_mdss_rot1_clk */
  94. 0x11, /* disp_cc_mdss_rot_clk */
  95. 0x3C, /* disp_cc_mdss_rscc_ahb_clk */
  96. 0x3B, /* disp_cc_mdss_rscc_vsync_clk */
  97. 0x38, /* disp_cc_mdss_vsync1_clk */
  98. 0x13, /* disp_cc_mdss_vsync_clk */
  99. 0x4A, /* disp_cc_sleep_clk */
  100. 0x49, /* measure_only_disp_cc_xo_clk */
  101. };
  102. static struct clk_debug_mux disp_cc_debug_mux = {
  103. .priv = &debug_mux_priv,
  104. .debug_offset = 0x11000,
  105. .post_div_offset = 0xD000,
  106. .cbcr_offset = 0xD004,
  107. .src_sel_mask = 0x1FF,
  108. .src_sel_shift = 0,
  109. .post_div_mask = 0xF,
  110. .post_div_shift = 0,
  111. .post_div_val = 4,
  112. .mux_sels = disp_cc_debug_mux_sels,
  113. .num_mux_sels = ARRAY_SIZE(disp_cc_debug_mux_sels),
  114. .hw.init = &(const struct clk_init_data){
  115. .name = "disp_cc_debug_mux",
  116. .ops = &clk_debug_mux_ops,
  117. .parent_names = disp_cc_debug_mux_parent_names,
  118. .num_parents = ARRAY_SIZE(disp_cc_debug_mux_parent_names),
  119. },
  120. };
  121. static const char *const gcc_debug_mux_parent_names[] = {
  122. "apss_cc_debug_mux",
  123. "disp_cc_debug_mux",
  124. "gcc_ahb2phy_csi_clk",
  125. "gcc_ahb2phy_usb_clk",
  126. "gcc_bimc_gpu_axi_clk",
  127. "gcc_boot_rom_ahb_clk",
  128. "gcc_cam_throttle_nrt_clk",
  129. "gcc_cam_throttle_rt_clk",
  130. "gcc_camss_axi_clk",
  131. "gcc_camss_cci_0_clk",
  132. "gcc_camss_cci_1_clk",
  133. "gcc_camss_cphy_0_clk",
  134. "gcc_camss_cphy_1_clk",
  135. "gcc_camss_cphy_2_clk",
  136. "gcc_camss_csi0phytimer_clk",
  137. "gcc_camss_csi1phytimer_clk",
  138. "gcc_camss_csi2phytimer_clk",
  139. "gcc_camss_mclk0_clk",
  140. "gcc_camss_mclk1_clk",
  141. "gcc_camss_mclk2_clk",
  142. "gcc_camss_mclk3_clk",
  143. "gcc_camss_nrt_axi_clk",
  144. "gcc_camss_ope_ahb_clk",
  145. "gcc_camss_ope_clk",
  146. "gcc_camss_rt_axi_clk",
  147. "gcc_camss_tfe_0_clk",
  148. "gcc_camss_tfe_0_cphy_rx_clk",
  149. "gcc_camss_tfe_0_csid_clk",
  150. "gcc_camss_tfe_1_clk",
  151. "gcc_camss_tfe_1_cphy_rx_clk",
  152. "gcc_camss_tfe_1_csid_clk",
  153. "gcc_camss_top_ahb_clk",
  154. "gcc_camss_top_shift_clk",
  155. "gcc_cfg_noc_usb3_prim_axi_clk",
  156. "gcc_disp_gpll0_div_clk_src",
  157. "gcc_disp_hf_axi_clk",
  158. "gcc_disp_sleep_clk",
  159. "gcc_disp_throttle_core_clk",
  160. "gcc_gp1_clk",
  161. "gcc_gp2_clk",
  162. "gcc_gp3_clk",
  163. "gcc_gpu_gpll0_clk_src",
  164. "gcc_gpu_gpll0_div_clk_src",
  165. "gcc_gpu_memnoc_gfx_clk",
  166. "gcc_pdm2_clk",
  167. "gcc_pdm_ahb_clk",
  168. "gcc_pdm_xo4_clk",
  169. "gcc_prng_ahb_clk",
  170. "gcc_qmip_camera_nrt_ahb_clk",
  171. "gcc_qmip_camera_rt_ahb_clk",
  172. "gcc_qmip_disp_ahb_clk",
  173. "gcc_qmip_gpu_cfg_ahb_clk",
  174. "gcc_qmip_video_vcodec_ahb_clk",
  175. "gcc_qupv3_wrap0_core_2x_clk",
  176. "gcc_qupv3_wrap0_core_clk",
  177. "gcc_qupv3_wrap0_s0_clk",
  178. "gcc_qupv3_wrap0_s1_clk",
  179. "gcc_qupv3_wrap0_s2_clk",
  180. "gcc_qupv3_wrap0_s3_clk",
  181. "gcc_qupv3_wrap0_s4_clk",
  182. "gcc_qupv3_wrap1_core_2x_clk",
  183. "gcc_qupv3_wrap1_core_clk",
  184. "gcc_qupv3_wrap1_s0_clk",
  185. "gcc_qupv3_wrap1_s1_clk",
  186. "gcc_qupv3_wrap1_s2_clk",
  187. "gcc_qupv3_wrap1_s3_clk",
  188. "gcc_qupv3_wrap1_s4_clk",
  189. "gcc_qupv3_wrap_0_m_ahb_clk",
  190. "gcc_qupv3_wrap_0_s_ahb_clk",
  191. "gcc_qupv3_wrap_1_m_ahb_clk",
  192. "gcc_qupv3_wrap_1_s_ahb_clk",
  193. "gcc_sdcc1_ahb_clk",
  194. "gcc_sdcc1_apps_clk",
  195. "gcc_sdcc1_ice_core_clk",
  196. "gcc_sdcc2_ahb_clk",
  197. "gcc_sdcc2_apps_clk",
  198. "gcc_sys_noc_ufs_phy_axi_clk",
  199. "gcc_sys_noc_usb3_prim_axi_clk",
  200. "gcc_ufs_phy_ahb_clk",
  201. "gcc_ufs_phy_axi_clk",
  202. "gcc_ufs_phy_ice_core_clk",
  203. "gcc_ufs_phy_phy_aux_clk",
  204. "gcc_ufs_phy_rx_symbol_0_clk",
  205. "gcc_ufs_phy_rx_symbol_1_clk",
  206. "gcc_ufs_phy_tx_symbol_0_clk",
  207. "gcc_ufs_phy_unipro_core_clk",
  208. "gcc_usb30_prim_atb_clk",
  209. "gcc_usb30_prim_master_clk",
  210. "gcc_usb30_prim_mock_utmi_clk",
  211. "gcc_usb30_prim_sleep_clk",
  212. "gcc_usb3_prim_phy_com_aux_clk",
  213. "gcc_usb3_prim_phy_pipe_clk",
  214. "gcc_vcodec0_axi_clk",
  215. "gcc_venus_ahb_clk",
  216. "gcc_venus_ctl_axi_clk",
  217. "gcc_video_axi0_clk",
  218. "gcc_video_throttle_core_clk",
  219. "gcc_video_vcodec0_sys_clk",
  220. "gcc_video_venus_ctl_clk",
  221. "gpu_cc_debug_mux",
  222. "mc_cc_debug_mux",
  223. "measure_only_cnoc_clk",
  224. "measure_only_gcc_camera_ahb_clk",
  225. "measure_only_gcc_camera_xo_clk",
  226. "measure_only_gcc_cpuss_gnoc_clk",
  227. "measure_only_gcc_disp_ahb_clk",
  228. "measure_only_gcc_disp_xo_clk",
  229. "measure_only_gcc_gpu_cfg_ahb_clk",
  230. "measure_only_gcc_sys_noc_cpuss_ahb_clk",
  231. "measure_only_gcc_video_ahb_clk",
  232. "measure_only_gcc_video_xo_clk",
  233. "measure_only_ipa_2x_clk",
  234. "measure_only_snoc_clk",
  235. "measure_only_ufs_phy_rx_symbol_0_clk",
  236. "measure_only_ufs_phy_rx_symbol_1_clk",
  237. "measure_only_ufs_phy_tx_symbol_0_clk",
  238. "measure_only_usb3_phy_wrapper_gcc_usb30_pipe_clk",
  239. };
  240. static int gcc_debug_mux_sels[] = {
  241. 0xC8, /* apss_cc_debug_mux */
  242. 0x4C, /* disp_cc_debug_mux */
  243. 0x77, /* gcc_ahb2phy_csi_clk */
  244. 0x78, /* gcc_ahb2phy_usb_clk */
  245. 0xAF, /* gcc_bimc_gpu_axi_clk */
  246. 0x94, /* gcc_boot_rom_ahb_clk */
  247. 0x56, /* gcc_cam_throttle_nrt_clk */
  248. 0x55, /* gcc_cam_throttle_rt_clk */
  249. 0x153, /* gcc_camss_axi_clk */
  250. 0x150, /* gcc_camss_cci_0_clk */
  251. 0x151, /* gcc_camss_cci_1_clk */
  252. 0x143, /* gcc_camss_cphy_0_clk */
  253. 0x144, /* gcc_camss_cphy_1_clk */
  254. 0x145, /* gcc_camss_cphy_2_clk */
  255. 0x136, /* gcc_camss_csi0phytimer_clk */
  256. 0x137, /* gcc_camss_csi1phytimer_clk */
  257. 0x138, /* gcc_camss_csi2phytimer_clk */
  258. 0x139, /* gcc_camss_mclk0_clk */
  259. 0x13A, /* gcc_camss_mclk1_clk */
  260. 0x13B, /* gcc_camss_mclk2_clk */
  261. 0x13C, /* gcc_camss_mclk3_clk */
  262. 0x159, /* gcc_camss_nrt_axi_clk */
  263. 0x14F, /* gcc_camss_ope_ahb_clk */
  264. 0x14D, /* gcc_camss_ope_clk */
  265. 0x15B, /* gcc_camss_rt_axi_clk */
  266. 0x13D, /* gcc_camss_tfe_0_clk */
  267. 0x141, /* gcc_camss_tfe_0_cphy_rx_clk */
  268. 0x146, /* gcc_camss_tfe_0_csid_clk */
  269. 0x13F, /* gcc_camss_tfe_1_clk */
  270. 0x142, /* gcc_camss_tfe_1_cphy_rx_clk */
  271. 0x148, /* gcc_camss_tfe_1_csid_clk */
  272. 0x152, /* gcc_camss_top_ahb_clk */
  273. 0x157, /* gcc_camss_top_shift_clk */
  274. 0x20, /* gcc_cfg_noc_usb3_prim_axi_clk */
  275. 0x51, /* gcc_disp_gpll0_div_clk_src */
  276. 0x47, /* gcc_disp_hf_axi_clk */
  277. 0x57, /* gcc_disp_sleep_clk */
  278. 0x53, /* gcc_disp_throttle_core_clk */
  279. 0xD2, /* gcc_gp1_clk */
  280. 0xD3, /* gcc_gp2_clk */
  281. 0xD4, /* gcc_gp3_clk */
  282. 0x106, /* gcc_gpu_gpll0_clk_src */
  283. 0x107, /* gcc_gpu_gpll0_div_clk_src */
  284. 0x104, /* gcc_gpu_memnoc_gfx_clk */
  285. 0x90, /* gcc_pdm2_clk */
  286. 0x8E, /* gcc_pdm_ahb_clk */
  287. 0x8F, /* gcc_pdm_xo4_clk */
  288. 0x91, /* gcc_prng_ahb_clk */
  289. 0x44, /* gcc_qmip_camera_nrt_ahb_clk */
  290. 0x52, /* gcc_qmip_camera_rt_ahb_clk */
  291. 0x45, /* gcc_qmip_disp_ahb_clk */
  292. 0x108, /* gcc_qmip_gpu_cfg_ahb_clk */
  293. 0x43, /* gcc_qmip_video_vcodec_ahb_clk */
  294. 0x7F, /* gcc_qupv3_wrap0_core_2x_clk */
  295. 0x7E, /* gcc_qupv3_wrap0_core_clk */
  296. 0x80, /* gcc_qupv3_wrap0_s0_clk */
  297. 0x81, /* gcc_qupv3_wrap0_s1_clk */
  298. 0x82, /* gcc_qupv3_wrap0_s2_clk */
  299. 0x83, /* gcc_qupv3_wrap0_s3_clk */
  300. 0x84, /* gcc_qupv3_wrap0_s4_clk */
  301. 0x88, /* gcc_qupv3_wrap1_core_2x_clk */
  302. 0x87, /* gcc_qupv3_wrap1_core_clk */
  303. 0x89, /* gcc_qupv3_wrap1_s0_clk */
  304. 0x8A, /* gcc_qupv3_wrap1_s1_clk */
  305. 0x8B, /* gcc_qupv3_wrap1_s2_clk */
  306. 0x8C, /* gcc_qupv3_wrap1_s3_clk */
  307. 0x8D, /* gcc_qupv3_wrap1_s4_clk */
  308. 0x7C, /* gcc_qupv3_wrap_0_m_ahb_clk */
  309. 0x7D, /* gcc_qupv3_wrap_0_s_ahb_clk */
  310. 0x85, /* gcc_qupv3_wrap_1_m_ahb_clk */
  311. 0x86, /* gcc_qupv3_wrap_1_s_ahb_clk */
  312. 0x10D, /* gcc_sdcc1_ahb_clk */
  313. 0x10C, /* gcc_sdcc1_apps_clk */
  314. 0x10E, /* gcc_sdcc1_ice_core_clk */
  315. 0x7A, /* gcc_sdcc2_ahb_clk */
  316. 0x79, /* gcc_sdcc2_apps_clk */
  317. 0x18, /* gcc_sys_noc_ufs_phy_axi_clk */
  318. 0x17, /* gcc_sys_noc_usb3_prim_axi_clk */
  319. 0x12B, /* gcc_ufs_phy_ahb_clk */
  320. 0x12A, /* gcc_ufs_phy_axi_clk */
  321. 0x131, /* gcc_ufs_phy_ice_core_clk */
  322. 0x132, /* gcc_ufs_phy_phy_aux_clk */
  323. 0x12D, /* gcc_ufs_phy_rx_symbol_0_clk */
  324. 0x135, /* gcc_ufs_phy_rx_symbol_1_clk */
  325. 0x12C, /* gcc_ufs_phy_tx_symbol_0_clk */
  326. 0x130, /* gcc_ufs_phy_unipro_core_clk */
  327. 0x74, /* gcc_usb30_prim_atb_clk */
  328. 0x6C, /* gcc_usb30_prim_master_clk */
  329. 0x6E, /* gcc_usb30_prim_mock_utmi_clk */
  330. 0x6D, /* gcc_usb30_prim_sleep_clk */
  331. 0x6F, /* gcc_usb3_prim_phy_com_aux_clk */
  332. 0x70, /* gcc_usb3_prim_phy_pipe_clk */
  333. 0x161, /* gcc_vcodec0_axi_clk */
  334. 0x162, /* gcc_venus_ahb_clk */
  335. 0x160, /* gcc_venus_ctl_axi_clk */
  336. 0x46, /* gcc_video_axi0_clk */
  337. 0x54, /* gcc_video_throttle_core_clk */
  338. 0x15E, /* gcc_video_vcodec0_sys_clk */
  339. 0x15C, /* gcc_video_venus_ctl_clk */
  340. 0x103, /* gpu_cc_debug_mux */
  341. 0xC1, /* mc_cc_debug_mux */
  342. 0x1E, /* measure_only_cnoc_clk */
  343. 0x41, /* measure_only_gcc_camera_ahb_clk */
  344. 0x49, /* measure_only_gcc_camera_xo_clk */
  345. 0xC3, /* measure_only_gcc_cpuss_gnoc_clk */
  346. 0x42, /* measure_only_gcc_disp_ahb_clk */
  347. 0x4A, /* measure_only_gcc_disp_xo_clk */
  348. 0x101, /* measure_only_gcc_gpu_cfg_ahb_clk */
  349. 0x9, /* measure_only_gcc_sys_noc_cpuss_ahb_clk */
  350. 0x40, /* measure_only_gcc_video_ahb_clk */
  351. 0x48, /* measure_only_gcc_video_xo_clk */
  352. 0xDE, /* measure_only_ipa_2x_clk */
  353. 0x7, /* measure_only_snoc_clk */
  354. 0x12F, /* measure_only_ufs_phy_rx_symbol_0_clk */
  355. 0x134, /* measure_only_ufs_phy_rx_symbol_1_clk */
  356. 0x12E, /* measure_only_ufs_phy_tx_symbol_0_clk */
  357. 0x75, /* measure_only_usb3_phy_wrapper_gcc_usb30_pipe_clk */
  358. };
  359. static struct clk_debug_mux gcc_debug_mux = {
  360. .priv = &debug_mux_priv,
  361. .debug_offset = 0x62000,
  362. .post_div_offset = 0x30000,
  363. .cbcr_offset = 0x30004,
  364. .src_sel_mask = 0x3FF,
  365. .src_sel_shift = 0,
  366. .post_div_mask = 0xF,
  367. .post_div_shift = 0,
  368. .post_div_val = 1,
  369. .mux_sels = gcc_debug_mux_sels,
  370. .num_mux_sels = ARRAY_SIZE(gcc_debug_mux_sels),
  371. .hw.init = &(const struct clk_init_data){
  372. .name = "gcc_debug_mux",
  373. .ops = &clk_debug_mux_ops,
  374. .parent_names = gcc_debug_mux_parent_names,
  375. .num_parents = ARRAY_SIZE(gcc_debug_mux_parent_names),
  376. },
  377. };
  378. static const char *const gpu_cc_debug_mux_parent_names[] = {
  379. "gpu_cc_crc_ahb_clk",
  380. "gpu_cc_cx_accu_shift_clk",
  381. "gpu_cc_cx_gfx3d_clk",
  382. "gpu_cc_cx_gmu_clk",
  383. "gpu_cc_cxo_clk",
  384. "gpu_cc_gx_accu_shift_clk",
  385. "gpu_cc_gx_gfx3d_clk",
  386. "gpu_cc_memnoc_gfx_clk",
  387. "measure_only_gpu_cc_ahb_clk",
  388. "measure_only_gpu_cc_cxo_aon_clk",
  389. "measure_only_gpu_cc_demet_clk",
  390. "measure_only_gpu_cc_gx_cxo_clk",
  391. "measure_only_gpu_cc_sleep_clk",
  392. };
  393. static int gpu_cc_debug_mux_sels[] = {
  394. 0x11, /* gpu_cc_crc_ahb_clk */
  395. 0x1F, /* gpu_cc_cx_accu_shift_clk */
  396. 0x1A, /* gpu_cc_cx_gfx3d_clk */
  397. 0x18, /* gpu_cc_cx_gmu_clk */
  398. 0x19, /* gpu_cc_cxo_clk */
  399. 0x1D, /* gpu_cc_gx_accu_shift_clk */
  400. 0xB, /* gpu_cc_gx_gfx3d_clk */
  401. 0xF, /* gpu_cc_memnoc_gfx_clk */
  402. 0x10, /* measure_only_gpu_cc_ahb_clk */
  403. 0xA, /* measure_only_gpu_cc_cxo_aon_clk */
  404. 0x9, /* measure_only_gpu_cc_demet_clk */
  405. 0xE, /* measure_only_gpu_cc_gx_cxo_clk */
  406. 0x16, /* measure_only_gpu_cc_sleep_clk */
  407. };
  408. static struct clk_debug_mux gpu_cc_debug_mux = {
  409. .priv = &debug_mux_priv,
  410. .debug_offset = 0x91DC,
  411. .post_div_offset = 0x913C,
  412. .cbcr_offset = 0x9140,
  413. .src_sel_mask = 0xFF,
  414. .src_sel_shift = 0,
  415. .post_div_mask = 0xF,
  416. .post_div_shift = 0,
  417. .post_div_val = 2,
  418. .mux_sels = gpu_cc_debug_mux_sels,
  419. .num_mux_sels = ARRAY_SIZE(gpu_cc_debug_mux_sels),
  420. .hw.init = &(const struct clk_init_data){
  421. .name = "gpu_cc_debug_mux",
  422. .ops = &clk_debug_mux_ops,
  423. .parent_names = gpu_cc_debug_mux_parent_names,
  424. .num_parents = ARRAY_SIZE(gpu_cc_debug_mux_parent_names),
  425. },
  426. };
  427. static const char *const mc_cc_debug_mux_parent_names[] = {
  428. "measure_only_mccc_clk",
  429. };
  430. static struct clk_debug_mux mc_cc_debug_mux = {
  431. .period_offset = 0x20,
  432. .hw.init = &(struct clk_init_data){
  433. .name = "mc_cc_debug_mux",
  434. .ops = &clk_debug_mux_ops,
  435. .parent_names = mc_cc_debug_mux_parent_names,
  436. .num_parents = ARRAY_SIZE(mc_cc_debug_mux_parent_names),
  437. },
  438. };
  439. static struct mux_regmap_names mux_list[] = {
  440. { .mux = &mc_cc_debug_mux, .regmap_name = "qcom,mccc" },
  441. { .mux = &gpu_cc_debug_mux, .regmap_name = "qcom,gpucc" },
  442. { .mux = &disp_cc_debug_mux, .regmap_name = "qcom,dispcc" },
  443. { .mux = &apss_cc_debug_mux, .regmap_name = "qcom,apsscc" },
  444. { .mux = &gcc_debug_mux, .regmap_name = "qcom,gcc" },
  445. };
  446. static struct clk_dummy measure_only_apcs_gold_post_acd_clk = {
  447. .rrate = 1000,
  448. .hw.init = &(const struct clk_init_data){
  449. .name = "measure_only_apcs_gold_post_acd_clk",
  450. .ops = &clk_dummy_ops,
  451. },
  452. };
  453. static struct clk_dummy measure_only_apcs_l3_post_acd_clk = {
  454. .rrate = 1000,
  455. .hw.init = &(const struct clk_init_data){
  456. .name = "measure_only_apcs_l3_post_acd_clk",
  457. .ops = &clk_dummy_ops,
  458. },
  459. };
  460. static struct clk_dummy measure_only_apcs_silver_post_acd_clk = {
  461. .rrate = 1000,
  462. .hw.init = &(const struct clk_init_data){
  463. .name = "measure_only_apcs_silver_post_acd_clk",
  464. .ops = &clk_dummy_ops,
  465. },
  466. };
  467. static struct clk_dummy measure_only_cnoc_clk = {
  468. .rrate = 1000,
  469. .hw.init = &(const struct clk_init_data){
  470. .name = "measure_only_cnoc_clk",
  471. .ops = &clk_dummy_ops,
  472. },
  473. };
  474. static struct clk_dummy measure_only_disp_cc_xo_clk = {
  475. .rrate = 1000,
  476. .hw.init = &(const struct clk_init_data){
  477. .name = "measure_only_disp_cc_xo_clk",
  478. .ops = &clk_dummy_ops,
  479. },
  480. };
  481. static struct clk_dummy measure_only_gcc_camera_ahb_clk = {
  482. .rrate = 1000,
  483. .hw.init = &(const struct clk_init_data){
  484. .name = "measure_only_gcc_camera_ahb_clk",
  485. .ops = &clk_dummy_ops,
  486. },
  487. };
  488. static struct clk_dummy measure_only_gcc_camera_xo_clk = {
  489. .rrate = 1000,
  490. .hw.init = &(const struct clk_init_data){
  491. .name = "measure_only_gcc_camera_xo_clk",
  492. .ops = &clk_dummy_ops,
  493. },
  494. };
  495. static struct clk_dummy measure_only_gcc_cpuss_gnoc_clk = {
  496. .rrate = 1000,
  497. .hw.init = &(const struct clk_init_data){
  498. .name = "measure_only_gcc_cpuss_gnoc_clk",
  499. .ops = &clk_dummy_ops,
  500. },
  501. };
  502. static struct clk_dummy measure_only_gcc_disp_ahb_clk = {
  503. .rrate = 1000,
  504. .hw.init = &(const struct clk_init_data){
  505. .name = "measure_only_gcc_disp_ahb_clk",
  506. .ops = &clk_dummy_ops,
  507. },
  508. };
  509. static struct clk_dummy measure_only_gcc_disp_xo_clk = {
  510. .rrate = 1000,
  511. .hw.init = &(const struct clk_init_data){
  512. .name = "measure_only_gcc_disp_xo_clk",
  513. .ops = &clk_dummy_ops,
  514. },
  515. };
  516. static struct clk_dummy measure_only_gcc_gpu_cfg_ahb_clk = {
  517. .rrate = 1000,
  518. .hw.init = &(const struct clk_init_data){
  519. .name = "measure_only_gcc_gpu_cfg_ahb_clk",
  520. .ops = &clk_dummy_ops,
  521. },
  522. };
  523. static struct clk_dummy measure_only_gcc_sys_noc_cpuss_ahb_clk = {
  524. .rrate = 1000,
  525. .hw.init = &(const struct clk_init_data){
  526. .name = "measure_only_gcc_sys_noc_cpuss_ahb_clk",
  527. .ops = &clk_dummy_ops,
  528. },
  529. };
  530. static struct clk_dummy measure_only_gcc_video_ahb_clk = {
  531. .rrate = 1000,
  532. .hw.init = &(const struct clk_init_data){
  533. .name = "measure_only_gcc_video_ahb_clk",
  534. .ops = &clk_dummy_ops,
  535. },
  536. };
  537. static struct clk_dummy measure_only_gcc_video_xo_clk = {
  538. .rrate = 1000,
  539. .hw.init = &(const struct clk_init_data){
  540. .name = "measure_only_gcc_video_xo_clk",
  541. .ops = &clk_dummy_ops,
  542. },
  543. };
  544. static struct clk_dummy measure_only_gpu_cc_ahb_clk = {
  545. .rrate = 1000,
  546. .hw.init = &(const struct clk_init_data){
  547. .name = "measure_only_gpu_cc_ahb_clk",
  548. .ops = &clk_dummy_ops,
  549. },
  550. };
  551. static struct clk_dummy measure_only_gpu_cc_cxo_aon_clk = {
  552. .rrate = 1000,
  553. .hw.init = &(const struct clk_init_data){
  554. .name = "measure_only_gpu_cc_cxo_aon_clk",
  555. .ops = &clk_dummy_ops,
  556. },
  557. };
  558. static struct clk_dummy measure_only_gpu_cc_demet_clk = {
  559. .rrate = 1000,
  560. .hw.init = &(const struct clk_init_data){
  561. .name = "measure_only_gpu_cc_demet_clk",
  562. .ops = &clk_dummy_ops,
  563. },
  564. };
  565. static struct clk_dummy measure_only_gpu_cc_gx_cxo_clk = {
  566. .rrate = 1000,
  567. .hw.init = &(const struct clk_init_data){
  568. .name = "measure_only_gpu_cc_gx_cxo_clk",
  569. .ops = &clk_dummy_ops,
  570. },
  571. };
  572. static struct clk_dummy measure_only_gpu_cc_sleep_clk = {
  573. .rrate = 1000,
  574. .hw.init = &(const struct clk_init_data){
  575. .name = "measure_only_gpu_cc_sleep_clk",
  576. .ops = &clk_dummy_ops,
  577. },
  578. };
  579. static struct clk_dummy measure_only_ipa_2x_clk = {
  580. .rrate = 1000,
  581. .hw.init = &(const struct clk_init_data){
  582. .name = "measure_only_ipa_2x_clk",
  583. .ops = &clk_dummy_ops,
  584. },
  585. };
  586. static struct clk_dummy measure_only_mccc_clk = {
  587. .rrate = 1000,
  588. .hw.init = &(const struct clk_init_data){
  589. .name = "measure_only_mccc_clk",
  590. .ops = &clk_dummy_ops,
  591. },
  592. };
  593. static struct clk_dummy measure_only_snoc_clk = {
  594. .rrate = 1000,
  595. .hw.init = &(const struct clk_init_data){
  596. .name = "measure_only_snoc_clk",
  597. .ops = &clk_dummy_ops,
  598. },
  599. };
  600. static struct clk_dummy measure_only_ufs_phy_rx_symbol_0_clk = {
  601. .rrate = 1000,
  602. .hw.init = &(const struct clk_init_data){
  603. .name = "measure_only_ufs_phy_rx_symbol_0_clk",
  604. .ops = &clk_dummy_ops,
  605. },
  606. };
  607. static struct clk_dummy measure_only_ufs_phy_rx_symbol_1_clk = {
  608. .rrate = 1000,
  609. .hw.init = &(const struct clk_init_data){
  610. .name = "measure_only_ufs_phy_rx_symbol_1_clk",
  611. .ops = &clk_dummy_ops,
  612. },
  613. };
  614. static struct clk_dummy measure_only_ufs_phy_tx_symbol_0_clk = {
  615. .rrate = 1000,
  616. .hw.init = &(const struct clk_init_data){
  617. .name = "measure_only_ufs_phy_tx_symbol_0_clk",
  618. .ops = &clk_dummy_ops,
  619. },
  620. };
  621. static struct clk_dummy measure_only_usb3_phy_wrapper_gcc_usb30_pipe_clk = {
  622. .rrate = 1000,
  623. .hw.init = &(const struct clk_init_data){
  624. .name = "measure_only_usb3_phy_wrapper_gcc_usb30_pipe_clk",
  625. .ops = &clk_dummy_ops,
  626. },
  627. };
  628. static struct clk_hw *debugcc_pitti_hws[] = {
  629. &measure_only_apcs_gold_post_acd_clk.hw,
  630. &measure_only_apcs_l3_post_acd_clk.hw,
  631. &measure_only_apcs_silver_post_acd_clk.hw,
  632. &measure_only_cnoc_clk.hw,
  633. &measure_only_disp_cc_xo_clk.hw,
  634. &measure_only_gcc_camera_ahb_clk.hw,
  635. &measure_only_gcc_camera_xo_clk.hw,
  636. &measure_only_gcc_cpuss_gnoc_clk.hw,
  637. &measure_only_gcc_disp_ahb_clk.hw,
  638. &measure_only_gcc_disp_xo_clk.hw,
  639. &measure_only_gcc_gpu_cfg_ahb_clk.hw,
  640. &measure_only_gcc_sys_noc_cpuss_ahb_clk.hw,
  641. &measure_only_gcc_video_ahb_clk.hw,
  642. &measure_only_gcc_video_xo_clk.hw,
  643. &measure_only_gpu_cc_ahb_clk.hw,
  644. &measure_only_gpu_cc_cxo_aon_clk.hw,
  645. &measure_only_gpu_cc_demet_clk.hw,
  646. &measure_only_gpu_cc_gx_cxo_clk.hw,
  647. &measure_only_gpu_cc_sleep_clk.hw,
  648. &measure_only_ipa_2x_clk.hw,
  649. &measure_only_mccc_clk.hw,
  650. &measure_only_snoc_clk.hw,
  651. &measure_only_ufs_phy_rx_symbol_0_clk.hw,
  652. &measure_only_ufs_phy_rx_symbol_1_clk.hw,
  653. &measure_only_ufs_phy_tx_symbol_0_clk.hw,
  654. &measure_only_usb3_phy_wrapper_gcc_usb30_pipe_clk.hw,
  655. };
  656. static const struct of_device_id clk_debug_match_table[] = {
  657. { .compatible = "qcom,pitti-debugcc" },
  658. { }
  659. };
  660. static int clk_debug_pitti_probe(struct platform_device *pdev)
  661. {
  662. struct clk *clk;
  663. int ret = 0, i;
  664. BUILD_BUG_ON(ARRAY_SIZE(apss_cc_debug_mux_parent_names) !=
  665. ARRAY_SIZE(apss_cc_debug_mux_sels));
  666. BUILD_BUG_ON(ARRAY_SIZE(disp_cc_debug_mux_parent_names) !=
  667. ARRAY_SIZE(disp_cc_debug_mux_sels));
  668. BUILD_BUG_ON(ARRAY_SIZE(gcc_debug_mux_parent_names) != ARRAY_SIZE(gcc_debug_mux_sels));
  669. BUILD_BUG_ON(ARRAY_SIZE(gpu_cc_debug_mux_parent_names) !=
  670. ARRAY_SIZE(gpu_cc_debug_mux_sels));
  671. clk = devm_clk_get(&pdev->dev, "xo_clk_src");
  672. if (IS_ERR(clk)) {
  673. if (PTR_ERR(clk) != -EPROBE_DEFER)
  674. dev_err(&pdev->dev, "Unable to get xo clock\n");
  675. return PTR_ERR(clk);
  676. }
  677. debug_mux_priv.cxo = clk;
  678. for (i = 0; i < ARRAY_SIZE(mux_list); i++) {
  679. if (IS_ERR_OR_NULL(mux_list[i].mux->regmap)) {
  680. ret = map_debug_bases(pdev, mux_list[i].regmap_name,
  681. mux_list[i].mux);
  682. if (ret == -EBADR)
  683. continue;
  684. else if (ret)
  685. return ret;
  686. }
  687. }
  688. for (i = 0; i < ARRAY_SIZE(debugcc_pitti_hws); i++) {
  689. clk = devm_clk_register(&pdev->dev, debugcc_pitti_hws[i]);
  690. if (IS_ERR(clk)) {
  691. dev_err(&pdev->dev, "Unable to register %s, err:(%ld)\n",
  692. qcom_clk_hw_get_name(debugcc_pitti_hws[i]),
  693. PTR_ERR(clk));
  694. return PTR_ERR(clk);
  695. }
  696. }
  697. for (i = 0; i < ARRAY_SIZE(mux_list); i++) {
  698. ret = devm_clk_register_debug_mux(&pdev->dev, mux_list[i].mux);
  699. if (ret) {
  700. dev_err(&pdev->dev, "Unable to register mux clk %s, err:(%d)\n",
  701. qcom_clk_hw_get_name(&mux_list[i].mux->hw),
  702. ret);
  703. return ret;
  704. }
  705. }
  706. ret = clk_debug_measure_register(&gcc_debug_mux.hw);
  707. if (ret) {
  708. dev_err(&pdev->dev, "Could not register Measure clocks\n");
  709. return ret;
  710. }
  711. dev_info(&pdev->dev, "Registered debug measure clocks\n");
  712. return ret;
  713. }
  714. static struct platform_driver clk_debug_driver = {
  715. .probe = clk_debug_pitti_probe,
  716. .driver = {
  717. .name = "pitti-debugcc",
  718. .of_match_table = clk_debug_match_table,
  719. },
  720. };
  721. static int __init clk_debug_pitti_init(void)
  722. {
  723. return platform_driver_register(&clk_debug_driver);
  724. }
  725. fs_initcall(clk_debug_pitti_init);
  726. MODULE_DESCRIPTION("QTI DEBUG CC PITTI Driver");
  727. MODULE_LICENSE("GPL");