clk-zx296718.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  1. /*
  2. * Copyright (C) 2015 - 2016 ZTE Corporation.
  3. * Copyright (C) 2016 Linaro Ltd.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/clk-provider.h>
  10. #include <linux/device.h>
  11. #include <linux/kernel.h>
  12. #include <linux/of_address.h>
  13. #include <linux/of_device.h>
  14. #include <linux/platform_device.h>
  15. #include <dt-bindings/clock/zx296718-clock.h>
  16. #include "clk.h"
  17. /* TOP CRM */
  18. #define TOP_CLK_MUX0 0x04
  19. #define TOP_CLK_MUX1 0x08
  20. #define TOP_CLK_MUX2 0x0c
  21. #define TOP_CLK_MUX3 0x10
  22. #define TOP_CLK_MUX4 0x14
  23. #define TOP_CLK_MUX5 0x18
  24. #define TOP_CLK_MUX6 0x1c
  25. #define TOP_CLK_MUX7 0x20
  26. #define TOP_CLK_MUX9 0x28
  27. #define TOP_CLK_GATE0 0x34
  28. #define TOP_CLK_GATE1 0x38
  29. #define TOP_CLK_GATE2 0x3c
  30. #define TOP_CLK_GATE3 0x40
  31. #define TOP_CLK_GATE4 0x44
  32. #define TOP_CLK_GATE5 0x48
  33. #define TOP_CLK_GATE6 0x4c
  34. #define TOP_CLK_DIV0 0x58
  35. #define PLL_CPU_REG 0x80
  36. #define PLL_VGA_REG 0xb0
  37. #define PLL_DDR_REG 0xa0
  38. /* LSP0 CRM */
  39. #define LSP0_TIMER3_CLK 0x4
  40. #define LSP0_TIMER4_CLK 0x8
  41. #define LSP0_TIMER5_CLK 0xc
  42. #define LSP0_UART3_CLK 0x10
  43. #define LSP0_UART1_CLK 0x14
  44. #define LSP0_UART2_CLK 0x18
  45. #define LSP0_SPIFC0_CLK 0x1c
  46. #define LSP0_I2C4_CLK 0x20
  47. #define LSP0_I2C5_CLK 0x24
  48. #define LSP0_SSP0_CLK 0x28
  49. #define LSP0_SSP1_CLK 0x2c
  50. #define LSP0_USIM0_CLK 0x30
  51. #define LSP0_GPIO_CLK 0x34
  52. #define LSP0_I2C3_CLK 0x38
  53. /* LSP1 CRM */
  54. #define LSP1_UART4_CLK 0x08
  55. #define LSP1_UART5_CLK 0x0c
  56. #define LSP1_PWM_CLK 0x10
  57. #define LSP1_I2C2_CLK 0x14
  58. #define LSP1_SSP2_CLK 0x1c
  59. #define LSP1_SSP3_CLK 0x20
  60. #define LSP1_SSP4_CLK 0x24
  61. #define LSP1_USIM1_CLK 0x28
  62. /* audio lsp */
  63. #define AUDIO_I2S0_DIV_CFG1 0x10
  64. #define AUDIO_I2S0_DIV_CFG2 0x14
  65. #define AUDIO_I2S0_CLK 0x18
  66. #define AUDIO_I2S1_DIV_CFG1 0x20
  67. #define AUDIO_I2S1_DIV_CFG2 0x24
  68. #define AUDIO_I2S1_CLK 0x28
  69. #define AUDIO_I2S2_DIV_CFG1 0x30
  70. #define AUDIO_I2S2_DIV_CFG2 0x34
  71. #define AUDIO_I2S2_CLK 0x38
  72. #define AUDIO_I2S3_DIV_CFG1 0x40
  73. #define AUDIO_I2S3_DIV_CFG2 0x44
  74. #define AUDIO_I2S3_CLK 0x48
  75. #define AUDIO_I2C0_CLK 0x50
  76. #define AUDIO_SPDIF0_DIV_CFG1 0x60
  77. #define AUDIO_SPDIF0_DIV_CFG2 0x64
  78. #define AUDIO_SPDIF0_CLK 0x68
  79. #define AUDIO_SPDIF1_DIV_CFG1 0x70
  80. #define AUDIO_SPDIF1_DIV_CFG2 0x74
  81. #define AUDIO_SPDIF1_CLK 0x78
  82. #define AUDIO_TIMER_CLK 0x80
  83. #define AUDIO_TDM_CLK 0x90
  84. #define AUDIO_TS_CLK 0xa0
  85. static DEFINE_SPINLOCK(clk_lock);
  86. static struct zx_pll_config pll_cpu_table[] = {
  87. PLL_RATE(1312000000, 0x00103621, 0x04aaaaaa),
  88. PLL_RATE(1407000000, 0x00103a21, 0x04aaaaaa),
  89. PLL_RATE(1503000000, 0x00103e21, 0x04aaaaaa),
  90. PLL_RATE(1600000000, 0x00104221, 0x04aaaaaa),
  91. };
  92. PNAME(osc) = {
  93. "osc24m",
  94. "osc32k",
  95. };
  96. PNAME(dbg_wclk_p) = {
  97. "clk334m",
  98. "clk466m",
  99. "clk396m",
  100. "clk250m",
  101. };
  102. PNAME(a72_coreclk_p) = {
  103. "osc24m",
  104. "pll_mm0_1188m",
  105. "pll_mm1_1296m",
  106. "clk1000m",
  107. "clk648m",
  108. "clk1600m",
  109. "pll_audio_1800m",
  110. "pll_vga_1800m",
  111. };
  112. PNAME(cpu_periclk_p) = {
  113. "osc24m",
  114. "clk500m",
  115. "clk594m",
  116. "clk466m",
  117. "clk294m",
  118. "clk334m",
  119. "clk250m",
  120. "clk125m",
  121. };
  122. PNAME(a53_coreclk_p) = {
  123. "osc24m",
  124. "clk1000m",
  125. "pll_mm0_1188m",
  126. "clk648m",
  127. "clk500m",
  128. "clk800m",
  129. "clk1600m",
  130. "pll_audio_1800m",
  131. };
  132. PNAME(sec_wclk_p) = {
  133. "osc24m",
  134. "clk396m",
  135. "clk334m",
  136. "clk297m",
  137. "clk250m",
  138. "clk198m",
  139. "clk148m5",
  140. "clk99m",
  141. };
  142. PNAME(sd_nand_wclk_p) = {
  143. "osc24m",
  144. "clk49m5",
  145. "clk99m",
  146. "clk198m",
  147. "clk167m",
  148. "clk148m5",
  149. "clk125m",
  150. "clk216m",
  151. };
  152. PNAME(emmc_wclk_p) = {
  153. "osc24m",
  154. "clk198m",
  155. "clk99m",
  156. "clk396m",
  157. "clk334m",
  158. "clk297m",
  159. "clk250m",
  160. "clk148m5",
  161. };
  162. PNAME(clk32_p) = {
  163. "osc32k",
  164. "clk32k768",
  165. };
  166. PNAME(usb_ref24m_p) = {
  167. "osc32k",
  168. "clk32k768",
  169. };
  170. PNAME(sys_noc_alck_p) = {
  171. "osc24m",
  172. "clk250m",
  173. "clk198m",
  174. "clk148m5",
  175. "clk108m",
  176. "clk54m",
  177. "clk216m",
  178. "clk240m",
  179. };
  180. PNAME(vde_aclk_p) = {
  181. "clk334m",
  182. "clk594m",
  183. "clk500m",
  184. "clk432m",
  185. "clk480m",
  186. "clk297m",
  187. "clk_vga", /*600MHz*/
  188. "clk294m",
  189. };
  190. PNAME(vce_aclk_p) = {
  191. "clk334m",
  192. "clk594m",
  193. "clk500m",
  194. "clk432m",
  195. "clk396m",
  196. "clk297m",
  197. "clk_vga", /*600MHz*/
  198. "clk294m",
  199. };
  200. PNAME(hde_aclk_p) = {
  201. "clk334m",
  202. "clk594m",
  203. "clk500m",
  204. "clk432m",
  205. "clk396m",
  206. "clk297m",
  207. "clk_vga", /*600MHz*/
  208. "clk294m",
  209. };
  210. PNAME(gpu_aclk_p) = {
  211. "clk334m",
  212. "clk648m",
  213. "clk594m",
  214. "clk500m",
  215. "clk396m",
  216. "clk297m",
  217. "clk_vga", /*600MHz*/
  218. "clk294m",
  219. };
  220. PNAME(sappu_aclk_p) = {
  221. "clk396m",
  222. "clk500m",
  223. "clk250m",
  224. "clk148m5",
  225. };
  226. PNAME(sappu_wclk_p) = {
  227. "clk198m",
  228. "clk396m",
  229. "clk334m",
  230. "clk297m",
  231. "clk250m",
  232. "clk148m5",
  233. "clk125m",
  234. "clk99m",
  235. };
  236. PNAME(vou_aclk_p) = {
  237. "clk334m",
  238. "clk594m",
  239. "clk500m",
  240. "clk432m",
  241. "clk396m",
  242. "clk297m",
  243. "clk_vga", /*600MHz*/
  244. "clk294m",
  245. };
  246. PNAME(vou_main_wclk_p) = {
  247. "clk108m",
  248. "clk594m",
  249. "clk297m",
  250. "clk148m5",
  251. "clk74m25",
  252. "clk54m",
  253. "clk27m",
  254. "clk_vga",
  255. };
  256. PNAME(vou_aux_wclk_p) = {
  257. "clk108m",
  258. "clk148m5",
  259. "clk74m25",
  260. "clk54m",
  261. "clk27m",
  262. "clk_vga",
  263. "clk54m_mm0",
  264. "clk"
  265. };
  266. PNAME(vou_ppu_wclk_p) = {
  267. "clk334m",
  268. "clk432m",
  269. "clk396m",
  270. "clk297m",
  271. "clk250m",
  272. "clk125m",
  273. "clk198m",
  274. "clk99m",
  275. };
  276. PNAME(vga_i2c_wclk_p) = {
  277. "osc24m",
  278. "clk99m",
  279. };
  280. PNAME(viu_m0_aclk_p) = {
  281. "clk334m",
  282. "clk432m",
  283. "clk396m",
  284. "clk297m",
  285. "clk250m",
  286. "clk125m",
  287. "clk198m",
  288. "osc24m",
  289. };
  290. PNAME(viu_m1_aclk_p) = {
  291. "clk198m",
  292. "clk250m",
  293. "clk297m",
  294. "clk125m",
  295. "clk396m",
  296. "clk334m",
  297. "clk148m5",
  298. "osc24m",
  299. };
  300. PNAME(viu_clk_p) = {
  301. "clk198m",
  302. "clk334m",
  303. "clk297m",
  304. "clk250m",
  305. "clk396m",
  306. "clk125m",
  307. "clk99m",
  308. "clk148m5",
  309. };
  310. PNAME(viu_jpeg_clk_p) = {
  311. "clk334m",
  312. "clk480m",
  313. "clk432m",
  314. "clk396m",
  315. "clk297m",
  316. "clk250m",
  317. "clk125m",
  318. "clk198m",
  319. };
  320. PNAME(ts_sys_clk_p) = {
  321. "clk192m",
  322. "clk167m",
  323. "clk125m",
  324. "clk99m",
  325. };
  326. PNAME(wdt_ares_p) = {
  327. "osc24m",
  328. "clk32k"
  329. };
  330. static struct clk_zx_pll zx296718_pll_clk[] = {
  331. ZX296718_PLL("pll_cpu", "osc24m", PLL_CPU_REG, pll_cpu_table),
  332. };
  333. static struct zx_clk_fixed_factor top_ffactor_clk[] = {
  334. FFACTOR(0, "clk4m", "osc24m", 1, 6, 0),
  335. FFACTOR(0, "clk2m", "osc24m", 1, 12, 0),
  336. /* pll cpu */
  337. FFACTOR(0, "clk1600m", "pll_cpu", 1, 1, CLK_SET_RATE_PARENT),
  338. FFACTOR(0, "clk800m", "pll_cpu", 1, 2, CLK_SET_RATE_PARENT),
  339. /* pll mac */
  340. FFACTOR(0, "clk25m", "pll_mac", 1, 40, 0),
  341. FFACTOR(0, "clk125m", "pll_mac", 1, 8, 0),
  342. FFACTOR(0, "clk250m", "pll_mac", 1, 4, 0),
  343. FFACTOR(0, "clk50m", "pll_mac", 1, 20, 0),
  344. FFACTOR(0, "clk500m", "pll_mac", 1, 2, 0),
  345. FFACTOR(0, "clk1000m", "pll_mac", 1, 1, 0),
  346. FFACTOR(0, "clk334m", "pll_mac", 1, 3, 0),
  347. FFACTOR(0, "clk167m", "pll_mac", 1, 6, 0),
  348. /* pll mm */
  349. FFACTOR(0, "clk54m_mm0", "pll_mm0", 1, 22, 0),
  350. FFACTOR(0, "clk74m25", "pll_mm0", 1, 16, 0),
  351. FFACTOR(0, "clk148m5", "pll_mm0", 1, 8, 0),
  352. FFACTOR(0, "clk297m", "pll_mm0", 1, 4, 0),
  353. FFACTOR(0, "clk594m", "pll_mm0", 1, 2, 0),
  354. FFACTOR(0, "pll_mm0_1188m", "pll_mm0", 1, 1, 0),
  355. FFACTOR(0, "clk396m", "pll_mm0", 1, 3, 0),
  356. FFACTOR(0, "clk198m", "pll_mm0", 1, 6, 0),
  357. FFACTOR(0, "clk99m", "pll_mm0", 1, 12, 0),
  358. FFACTOR(0, "clk49m5", "pll_mm0", 1, 24, 0),
  359. /* pll mm */
  360. FFACTOR(0, "clk324m", "pll_mm1", 1, 4, 0),
  361. FFACTOR(0, "clk648m", "pll_mm1", 1, 2, 0),
  362. FFACTOR(0, "pll_mm1_1296m", "pll_mm1", 1, 1, 0),
  363. FFACTOR(0, "clk216m", "pll_mm1", 1, 6, 0),
  364. FFACTOR(0, "clk432m", "pll_mm1", 1, 3, 0),
  365. FFACTOR(0, "clk108m", "pll_mm1", 1, 12, 0),
  366. FFACTOR(0, "clk72m", "pll_mm1", 1, 18, 0),
  367. FFACTOR(0, "clk27m", "pll_mm1", 1, 48, 0),
  368. FFACTOR(0, "clk54m", "pll_mm1", 1, 24, 0),
  369. /* vga */
  370. FFACTOR(0, "pll_vga_1800m", "pll_vga", 1, 1, 0),
  371. FFACTOR(0, "clk_vga", "pll_vga", 1, 2, 0),
  372. /* pll ddr */
  373. FFACTOR(0, "clk466m", "pll_ddr", 1, 2, 0),
  374. /* pll audio */
  375. FFACTOR(0, "pll_audio_1800m", "pll_audio", 1, 1, 0),
  376. FFACTOR(0, "clk32k768", "pll_audio", 1, 27000, 0),
  377. FFACTOR(0, "clk16m384", "pll_audio", 1, 54, 0),
  378. FFACTOR(0, "clk294m", "pll_audio", 1, 3, 0),
  379. /* pll hsic*/
  380. FFACTOR(0, "clk240m", "pll_hsic", 1, 4, 0),
  381. FFACTOR(0, "clk480m", "pll_hsic", 1, 2, 0),
  382. FFACTOR(0, "clk192m", "pll_hsic", 1, 5, 0),
  383. FFACTOR(0, "clk_pll_24m", "pll_hsic", 1, 40, 0),
  384. FFACTOR(0, "emmc_mux_div2", "emmc_mux", 1, 2, CLK_SET_RATE_PARENT),
  385. };
  386. static struct clk_div_table noc_div_table[] = {
  387. { .val = 1, .div = 2, },
  388. { .val = 3, .div = 4, },
  389. };
  390. static struct zx_clk_div top_div_clk[] = {
  391. DIV_T(0, "sys_noc_hclk", "sys_noc_aclk", TOP_CLK_DIV0, 0, 2, 0, noc_div_table),
  392. DIV_T(0, "sys_noc_pclk", "sys_noc_aclk", TOP_CLK_DIV0, 4, 2, 0, noc_div_table),
  393. };
  394. static struct zx_clk_mux top_mux_clk[] = {
  395. MUX(0, "dbg_mux", dbg_wclk_p, TOP_CLK_MUX0, 12, 2),
  396. MUX(0, "a72_mux", a72_coreclk_p, TOP_CLK_MUX0, 8, 3),
  397. MUX(0, "cpu_peri_mux", cpu_periclk_p, TOP_CLK_MUX0, 4, 3),
  398. MUX_F(0, "a53_mux", a53_coreclk_p, TOP_CLK_MUX0, 0, 3, CLK_SET_RATE_PARENT, 0),
  399. MUX(0, "sys_noc_aclk", sys_noc_alck_p, TOP_CLK_MUX1, 0, 3),
  400. MUX(0, "sec_mux", sec_wclk_p, TOP_CLK_MUX2, 16, 3),
  401. MUX(0, "sd1_mux", sd_nand_wclk_p, TOP_CLK_MUX2, 12, 3),
  402. MUX(0, "sd0_mux", sd_nand_wclk_p, TOP_CLK_MUX2, 8, 3),
  403. MUX(0, "emmc_mux", emmc_wclk_p, TOP_CLK_MUX2, 4, 3),
  404. MUX(0, "nand_mux", sd_nand_wclk_p, TOP_CLK_MUX2, 0, 3),
  405. MUX(0, "usb_ref24m_mux", usb_ref24m_p, TOP_CLK_MUX9, 16, 1),
  406. MUX(0, "clk32k", clk32_p, TOP_CLK_MUX9, 12, 1),
  407. MUX_F(0, "wdt_mux", wdt_ares_p, TOP_CLK_MUX9, 8, 1, CLK_SET_RATE_PARENT, 0),
  408. MUX(0, "timer_mux", osc, TOP_CLK_MUX9, 4, 1),
  409. MUX(0, "vde_mux", vde_aclk_p, TOP_CLK_MUX4, 0, 3),
  410. MUX(0, "vce_mux", vce_aclk_p, TOP_CLK_MUX4, 4, 3),
  411. MUX(0, "hde_mux", hde_aclk_p, TOP_CLK_MUX4, 8, 3),
  412. MUX(0, "gpu_mux", gpu_aclk_p, TOP_CLK_MUX5, 0, 3),
  413. MUX(0, "sappu_a_mux", sappu_aclk_p, TOP_CLK_MUX5, 4, 2),
  414. MUX(0, "sappu_w_mux", sappu_wclk_p, TOP_CLK_MUX5, 8, 3),
  415. MUX(0, "vou_a_mux", vou_aclk_p, TOP_CLK_MUX7, 0, 3),
  416. MUX(0, "vou_main_w_mux", vou_main_wclk_p, TOP_CLK_MUX7, 4, 3),
  417. MUX(0, "vou_aux_w_mux", vou_aux_wclk_p, TOP_CLK_MUX7, 8, 3),
  418. MUX(0, "vou_ppu_w_mux", vou_ppu_wclk_p, TOP_CLK_MUX7, 12, 3),
  419. MUX(0, "vga_i2c_mux", vga_i2c_wclk_p, TOP_CLK_MUX7, 16, 1),
  420. MUX(0, "viu_m0_a_mux", viu_m0_aclk_p, TOP_CLK_MUX6, 0, 3),
  421. MUX(0, "viu_m1_a_mux", viu_m1_aclk_p, TOP_CLK_MUX6, 4, 3),
  422. MUX(0, "viu_w_mux", viu_clk_p, TOP_CLK_MUX6, 8, 3),
  423. MUX(0, "viu_jpeg_w_mux", viu_jpeg_clk_p, TOP_CLK_MUX6, 12, 3),
  424. MUX(0, "ts_sys_mux", ts_sys_clk_p, TOP_CLK_MUX6, 16, 2),
  425. };
  426. static struct zx_clk_gate top_gate_clk[] = {
  427. GATE(CPU_DBG_GATE, "dbg_wclk", "dbg_mux", TOP_CLK_GATE0, 4, CLK_SET_RATE_PARENT, 0),
  428. GATE(A72_GATE, "a72_coreclk", "a72_mux", TOP_CLK_GATE0, 3, CLK_SET_RATE_PARENT, 0),
  429. GATE(CPU_PERI_GATE, "cpu_peri", "cpu_peri_mux", TOP_CLK_GATE0, 1, CLK_SET_RATE_PARENT, 0),
  430. GATE(A53_GATE, "a53_coreclk", "a53_mux", TOP_CLK_GATE0, 0, CLK_SET_RATE_PARENT, 0),
  431. GATE(SD1_WCLK, "sd1_wclk", "sd1_mux", TOP_CLK_GATE1, 13, CLK_SET_RATE_PARENT, 0),
  432. GATE(SD0_WCLK, "sd0_wclk", "sd0_mux", TOP_CLK_GATE1, 9, CLK_SET_RATE_PARENT, 0),
  433. GATE(EMMC_WCLK, "emmc_wclk", "emmc_mux_div2", TOP_CLK_GATE0, 5, CLK_SET_RATE_PARENT, 0),
  434. GATE(EMMC_NAND_AXI, "emmc_nand_aclk", "sys_noc_aclk", TOP_CLK_GATE1, 4, CLK_SET_RATE_PARENT, 0),
  435. GATE(NAND_WCLK, "nand_wclk", "nand_mux", TOP_CLK_GATE0, 1, CLK_SET_RATE_PARENT, 0),
  436. GATE(EMMC_NAND_AHB, "emmc_nand_hclk", "sys_noc_hclk", TOP_CLK_GATE1, 0, CLK_SET_RATE_PARENT, 0),
  437. GATE(0, "lsp1_pclk", "sys_noc_pclk", TOP_CLK_GATE2, 31, 0, 0),
  438. GATE(LSP1_148M5, "lsp1_148m5", "clk148m5", TOP_CLK_GATE2, 30, 0, 0),
  439. GATE(LSP1_99M, "lsp1_99m", "clk99m", TOP_CLK_GATE2, 29, 0, 0),
  440. GATE(LSP1_24M, "lsp1_24m", "osc24m", TOP_CLK_GATE2, 28, 0, 0),
  441. GATE(LSP0_74M25, "lsp0_74m25", "clk74m25", TOP_CLK_GATE2, 25, 0, 0),
  442. GATE(0, "lsp0_pclk", "sys_noc_pclk", TOP_CLK_GATE2, 24, 0, 0),
  443. GATE(LSP0_32K, "lsp0_32k", "osc32k", TOP_CLK_GATE2, 23, 0, 0),
  444. GATE(LSP0_148M5, "lsp0_148m5", "clk148m5", TOP_CLK_GATE2, 22, 0, 0),
  445. GATE(LSP0_99M, "lsp0_99m", "clk99m", TOP_CLK_GATE2, 21, 0, 0),
  446. GATE(LSP0_24M, "lsp0_24m", "osc24m", TOP_CLK_GATE2, 20, 0, 0),
  447. GATE(AUDIO_99M, "audio_99m", "clk99m", TOP_CLK_GATE5, 27, 0, 0),
  448. GATE(AUDIO_24M, "audio_24m", "osc24m", TOP_CLK_GATE5, 28, 0, 0),
  449. GATE(AUDIO_16M384, "audio_16m384", "clk16m384", TOP_CLK_GATE5, 29, 0, 0),
  450. GATE(AUDIO_32K, "audio_32k", "clk32k", TOP_CLK_GATE5, 30, 0, 0),
  451. GATE(WDT_WCLK, "wdt_wclk", "wdt_mux", TOP_CLK_GATE6, 9, CLK_SET_RATE_PARENT, 0),
  452. GATE(TIMER_WCLK, "timer_wclk", "timer_mux", TOP_CLK_GATE6, 5, CLK_SET_RATE_PARENT, 0),
  453. GATE(VDE_ACLK, "vde_aclk", "vde_mux", TOP_CLK_GATE3, 0, CLK_SET_RATE_PARENT, 0),
  454. GATE(VCE_ACLK, "vce_aclk", "vce_mux", TOP_CLK_GATE3, 4, CLK_SET_RATE_PARENT, 0),
  455. GATE(HDE_ACLK, "hde_aclk", "hde_mux", TOP_CLK_GATE3, 8, CLK_SET_RATE_PARENT, 0),
  456. GATE(GPU_ACLK, "gpu_aclk", "gpu_mux", TOP_CLK_GATE3, 16, CLK_SET_RATE_PARENT, 0),
  457. GATE(SAPPU_ACLK, "sappu_aclk", "sappu_a_mux", TOP_CLK_GATE3, 20, CLK_SET_RATE_PARENT, 0),
  458. GATE(SAPPU_WCLK, "sappu_wclk", "sappu_w_mux", TOP_CLK_GATE3, 22, CLK_SET_RATE_PARENT, 0),
  459. GATE(VOU_ACLK, "vou_aclk", "vou_a_mux", TOP_CLK_GATE4, 16, CLK_SET_RATE_PARENT, 0),
  460. GATE(VOU_MAIN_WCLK, "vou_main_wclk", "vou_main_w_mux", TOP_CLK_GATE4, 18, CLK_SET_RATE_PARENT, 0),
  461. GATE(VOU_AUX_WCLK, "vou_aux_wclk", "vou_aux_w_mux", TOP_CLK_GATE4, 19, CLK_SET_RATE_PARENT, 0),
  462. GATE(VOU_PPU_WCLK, "vou_ppu_wclk", "vou_ppu_w_mux", TOP_CLK_GATE4, 20, CLK_SET_RATE_PARENT, 0),
  463. GATE(MIPI_CFG_CLK, "mipi_cfg_clk", "osc24m", TOP_CLK_GATE4, 21, 0, 0),
  464. GATE(VGA_I2C_WCLK, "vga_i2c_wclk", "vga_i2c_mux", TOP_CLK_GATE4, 23, CLK_SET_RATE_PARENT, 0),
  465. GATE(MIPI_REF_CLK, "mipi_ref_clk", "clk27m", TOP_CLK_GATE4, 24, 0, 0),
  466. GATE(HDMI_OSC_CEC, "hdmi_osc_cec", "clk2m", TOP_CLK_GATE4, 22, 0, 0),
  467. GATE(HDMI_OSC_CLK, "hdmi_osc_clk", "clk240m", TOP_CLK_GATE4, 25, 0, 0),
  468. GATE(HDMI_XCLK, "hdmi_xclk", "osc24m", TOP_CLK_GATE4, 26, 0, 0),
  469. GATE(VIU_M0_ACLK, "viu_m0_aclk", "viu_m0_a_mux", TOP_CLK_GATE4, 0, CLK_SET_RATE_PARENT, 0),
  470. GATE(VIU_M1_ACLK, "viu_m1_aclk", "viu_m1_a_mux", TOP_CLK_GATE4, 1, CLK_SET_RATE_PARENT, 0),
  471. GATE(VIU_WCLK, "viu_wclk", "viu_w_mux", TOP_CLK_GATE4, 2, CLK_SET_RATE_PARENT, 0),
  472. GATE(VIU_JPEG_WCLK, "viu_jpeg_wclk", "viu_jpeg_w_mux", TOP_CLK_GATE4, 3, CLK_SET_RATE_PARENT, 0),
  473. GATE(VIU_CFG_CLK, "viu_cfg_clk", "osc24m", TOP_CLK_GATE4, 6, 0, 0),
  474. GATE(TS_SYS_WCLK, "ts_sys_wclk", "ts_sys_mux", TOP_CLK_GATE5, 2, CLK_SET_RATE_PARENT, 0),
  475. GATE(TS_SYS_108M, "ts_sys_108m", "clk108m", TOP_CLK_GATE5, 3, 0, 0),
  476. GATE(USB20_HCLK, "usb20_hclk", "sys_noc_hclk", TOP_CLK_GATE2, 12, 0, 0),
  477. GATE(USB20_PHY_CLK, "usb20_phy_clk", "usb_ref24m_mux", TOP_CLK_GATE2, 13, 0, 0),
  478. GATE(USB21_HCLK, "usb21_hclk", "sys_noc_hclk", TOP_CLK_GATE2, 14, 0, 0),
  479. GATE(USB21_PHY_CLK, "usb21_phy_clk", "usb_ref24m_mux", TOP_CLK_GATE2, 15, 0, 0),
  480. GATE(GMAC_RMIICLK, "gmac_rmii_clk", "clk50m", TOP_CLK_GATE2, 3, 0, 0),
  481. GATE(GMAC_PCLK, "gmac_pclk", "clk198m", TOP_CLK_GATE2, 1, 0, 0),
  482. GATE(GMAC_ACLK, "gmac_aclk", "clk49m5", TOP_CLK_GATE2, 0, 0, 0),
  483. GATE(GMAC_RFCLK, "gmac_refclk", "clk25m", TOP_CLK_GATE2, 4, 0, 0),
  484. GATE(SD1_AHB, "sd1_hclk", "sys_noc_hclk", TOP_CLK_GATE1, 12, 0, 0),
  485. GATE(SD0_AHB, "sd0_hclk", "sys_noc_hclk", TOP_CLK_GATE1, 8, 0, 0),
  486. GATE(TEMPSENSOR_GATE, "tempsensor_gate", "clk4m", TOP_CLK_GATE5, 31, 0, 0),
  487. };
  488. static struct clk_hw_onecell_data top_hw_onecell_data = {
  489. .num = TOP_NR_CLKS,
  490. .hws = {
  491. [TOP_NR_CLKS - 1] = NULL,
  492. },
  493. };
  494. static int __init top_clocks_init(struct device_node *np)
  495. {
  496. void __iomem *reg_base;
  497. int i, ret;
  498. reg_base = of_iomap(np, 0);
  499. if (!reg_base) {
  500. pr_err("%s: Unable to map clk base\n", __func__);
  501. return -ENXIO;
  502. }
  503. for (i = 0; i < ARRAY_SIZE(zx296718_pll_clk); i++) {
  504. zx296718_pll_clk[i].reg_base += (uintptr_t)reg_base;
  505. ret = clk_hw_register(NULL, &zx296718_pll_clk[i].hw);
  506. if (ret) {
  507. pr_warn("top clk %s init error!\n",
  508. zx296718_pll_clk[i].hw.init->name);
  509. }
  510. }
  511. for (i = 0; i < ARRAY_SIZE(top_ffactor_clk); i++) {
  512. if (top_ffactor_clk[i].id)
  513. top_hw_onecell_data.hws[top_ffactor_clk[i].id] =
  514. &top_ffactor_clk[i].factor.hw;
  515. ret = clk_hw_register(NULL, &top_ffactor_clk[i].factor.hw);
  516. if (ret) {
  517. pr_warn("top clk %s init error!\n",
  518. top_ffactor_clk[i].factor.hw.init->name);
  519. }
  520. }
  521. for (i = 0; i < ARRAY_SIZE(top_mux_clk); i++) {
  522. if (top_mux_clk[i].id)
  523. top_hw_onecell_data.hws[top_mux_clk[i].id] =
  524. &top_mux_clk[i].mux.hw;
  525. top_mux_clk[i].mux.reg += (uintptr_t)reg_base;
  526. ret = clk_hw_register(NULL, &top_mux_clk[i].mux.hw);
  527. if (ret) {
  528. pr_warn("top clk %s init error!\n",
  529. top_mux_clk[i].mux.hw.init->name);
  530. }
  531. }
  532. for (i = 0; i < ARRAY_SIZE(top_gate_clk); i++) {
  533. if (top_gate_clk[i].id)
  534. top_hw_onecell_data.hws[top_gate_clk[i].id] =
  535. &top_gate_clk[i].gate.hw;
  536. top_gate_clk[i].gate.reg += (uintptr_t)reg_base;
  537. ret = clk_hw_register(NULL, &top_gate_clk[i].gate.hw);
  538. if (ret) {
  539. pr_warn("top clk %s init error!\n",
  540. top_gate_clk[i].gate.hw.init->name);
  541. }
  542. }
  543. for (i = 0; i < ARRAY_SIZE(top_div_clk); i++) {
  544. if (top_div_clk[i].id)
  545. top_hw_onecell_data.hws[top_div_clk[i].id] =
  546. &top_div_clk[i].div.hw;
  547. top_div_clk[i].div.reg += (uintptr_t)reg_base;
  548. ret = clk_hw_register(NULL, &top_div_clk[i].div.hw);
  549. if (ret) {
  550. pr_warn("top clk %s init error!\n",
  551. top_div_clk[i].div.hw.init->name);
  552. }
  553. }
  554. if (of_clk_add_hw_provider(np, of_clk_hw_onecell_get, &top_hw_onecell_data))
  555. panic("could not register clk provider\n");
  556. pr_info("top clk init over, nr:%d\n", TOP_NR_CLKS);
  557. return 0;
  558. }
  559. static struct clk_div_table common_even_div_table[] = {
  560. { .val = 0, .div = 1, },
  561. { .val = 1, .div = 2, },
  562. { .val = 3, .div = 4, },
  563. { .val = 5, .div = 6, },
  564. { .val = 7, .div = 8, },
  565. { .val = 9, .div = 10, },
  566. { .val = 11, .div = 12, },
  567. { .val = 13, .div = 14, },
  568. { .val = 15, .div = 16, },
  569. };
  570. static struct clk_div_table common_div_table[] = {
  571. { .val = 0, .div = 1, },
  572. { .val = 1, .div = 2, },
  573. { .val = 2, .div = 3, },
  574. { .val = 3, .div = 4, },
  575. { .val = 4, .div = 5, },
  576. { .val = 5, .div = 6, },
  577. { .val = 6, .div = 7, },
  578. { .val = 7, .div = 8, },
  579. { .val = 8, .div = 9, },
  580. { .val = 9, .div = 10, },
  581. { .val = 10, .div = 11, },
  582. { .val = 11, .div = 12, },
  583. { .val = 12, .div = 13, },
  584. { .val = 13, .div = 14, },
  585. { .val = 14, .div = 15, },
  586. { .val = 15, .div = 16, },
  587. };
  588. PNAME(lsp0_wclk_common_p) = {
  589. "lsp0_24m",
  590. "lsp0_99m",
  591. };
  592. PNAME(lsp0_wclk_timer3_p) = {
  593. "timer3_div",
  594. "lsp0_32k"
  595. };
  596. PNAME(lsp0_wclk_timer4_p) = {
  597. "timer4_div",
  598. "lsp0_32k"
  599. };
  600. PNAME(lsp0_wclk_timer5_p) = {
  601. "timer5_div",
  602. "lsp0_32k"
  603. };
  604. PNAME(lsp0_wclk_spifc0_p) = {
  605. "lsp0_148m5",
  606. "lsp0_24m",
  607. "lsp0_99m",
  608. "lsp0_74m25"
  609. };
  610. PNAME(lsp0_wclk_ssp_p) = {
  611. "lsp0_148m5",
  612. "lsp0_99m",
  613. "lsp0_24m",
  614. };
  615. static struct zx_clk_mux lsp0_mux_clk[] = {
  616. MUX(0, "timer3_wclk_mux", lsp0_wclk_timer3_p, LSP0_TIMER3_CLK, 4, 1),
  617. MUX(0, "timer4_wclk_mux", lsp0_wclk_timer4_p, LSP0_TIMER4_CLK, 4, 1),
  618. MUX(0, "timer5_wclk_mux", lsp0_wclk_timer5_p, LSP0_TIMER5_CLK, 4, 1),
  619. MUX(0, "uart3_wclk_mux", lsp0_wclk_common_p, LSP0_UART3_CLK, 4, 1),
  620. MUX(0, "uart1_wclk_mux", lsp0_wclk_common_p, LSP0_UART1_CLK, 4, 1),
  621. MUX(0, "uart2_wclk_mux", lsp0_wclk_common_p, LSP0_UART2_CLK, 4, 1),
  622. MUX(0, "spifc0_wclk_mux", lsp0_wclk_spifc0_p, LSP0_SPIFC0_CLK, 4, 2),
  623. MUX(0, "i2c4_wclk_mux", lsp0_wclk_common_p, LSP0_I2C4_CLK, 4, 1),
  624. MUX(0, "i2c5_wclk_mux", lsp0_wclk_common_p, LSP0_I2C5_CLK, 4, 1),
  625. MUX(0, "ssp0_wclk_mux", lsp0_wclk_ssp_p, LSP0_SSP0_CLK, 4, 1),
  626. MUX(0, "ssp1_wclk_mux", lsp0_wclk_ssp_p, LSP0_SSP1_CLK, 4, 1),
  627. MUX(0, "i2c3_wclk_mux", lsp0_wclk_common_p, LSP0_I2C3_CLK, 4, 1),
  628. };
  629. static struct zx_clk_gate lsp0_gate_clk[] = {
  630. GATE(LSP0_TIMER3_WCLK, "timer3_wclk", "timer3_wclk_mux", LSP0_TIMER3_CLK, 1, CLK_SET_RATE_PARENT, 0),
  631. GATE(LSP0_TIMER4_WCLK, "timer4_wclk", "timer4_wclk_mux", LSP0_TIMER4_CLK, 1, CLK_SET_RATE_PARENT, 0),
  632. GATE(LSP0_TIMER5_WCLK, "timer5_wclk", "timer5_wclk_mux", LSP0_TIMER5_CLK, 1, CLK_SET_RATE_PARENT, 0),
  633. GATE(LSP0_UART3_WCLK, "uart3_wclk", "uart3_wclk_mux", LSP0_UART3_CLK, 1, CLK_SET_RATE_PARENT, 0),
  634. GATE(LSP0_UART1_WCLK, "uart1_wclk", "uart1_wclk_mux", LSP0_UART1_CLK, 1, CLK_SET_RATE_PARENT, 0),
  635. GATE(LSP0_UART2_WCLK, "uart2_wclk", "uart2_wclk_mux", LSP0_UART2_CLK, 1, CLK_SET_RATE_PARENT, 0),
  636. GATE(LSP0_SPIFC0_WCLK, "spifc0_wclk", "spifc0_wclk_mux", LSP0_SPIFC0_CLK, 1, CLK_SET_RATE_PARENT, 0),
  637. GATE(LSP0_I2C4_WCLK, "i2c4_wclk", "i2c4_wclk_mux", LSP0_I2C4_CLK, 1, CLK_SET_RATE_PARENT, 0),
  638. GATE(LSP0_I2C5_WCLK, "i2c5_wclk", "i2c5_wclk_mux", LSP0_I2C5_CLK, 1, CLK_SET_RATE_PARENT, 0),
  639. GATE(LSP0_SSP0_WCLK, "ssp0_wclk", "ssp0_div", LSP0_SSP0_CLK, 1, CLK_SET_RATE_PARENT, 0),
  640. GATE(LSP0_SSP1_WCLK, "ssp1_wclk", "ssp1_div", LSP0_SSP1_CLK, 1, CLK_SET_RATE_PARENT, 0),
  641. GATE(LSP0_I2C3_WCLK, "i2c3_wclk", "i2c3_wclk_mux", LSP0_I2C3_CLK, 1, CLK_SET_RATE_PARENT, 0),
  642. };
  643. static struct zx_clk_div lsp0_div_clk[] = {
  644. DIV_T(0, "timer3_div", "lsp0_24m", LSP0_TIMER3_CLK, 12, 4, 0, common_even_div_table),
  645. DIV_T(0, "timer4_div", "lsp0_24m", LSP0_TIMER4_CLK, 12, 4, 0, common_even_div_table),
  646. DIV_T(0, "timer5_div", "lsp0_24m", LSP0_TIMER5_CLK, 12, 4, 0, common_even_div_table),
  647. DIV_T(0, "ssp0_div", "ssp0_wclk_mux", LSP0_SSP0_CLK, 12, 4, 0, common_even_div_table),
  648. DIV_T(0, "ssp1_div", "ssp1_wclk_mux", LSP0_SSP1_CLK, 12, 4, 0, common_even_div_table),
  649. };
  650. static struct clk_hw_onecell_data lsp0_hw_onecell_data = {
  651. .num = LSP0_NR_CLKS,
  652. .hws = {
  653. [LSP0_NR_CLKS - 1] = NULL,
  654. },
  655. };
  656. static int __init lsp0_clocks_init(struct device_node *np)
  657. {
  658. void __iomem *reg_base;
  659. int i, ret;
  660. reg_base = of_iomap(np, 0);
  661. if (!reg_base) {
  662. pr_err("%s: Unable to map clk base\n", __func__);
  663. return -ENXIO;
  664. }
  665. for (i = 0; i < ARRAY_SIZE(lsp0_mux_clk); i++) {
  666. if (lsp0_mux_clk[i].id)
  667. lsp0_hw_onecell_data.hws[lsp0_mux_clk[i].id] =
  668. &lsp0_mux_clk[i].mux.hw;
  669. lsp0_mux_clk[i].mux.reg += (uintptr_t)reg_base;
  670. ret = clk_hw_register(NULL, &lsp0_mux_clk[i].mux.hw);
  671. if (ret) {
  672. pr_warn("lsp0 clk %s init error!\n",
  673. lsp0_mux_clk[i].mux.hw.init->name);
  674. }
  675. }
  676. for (i = 0; i < ARRAY_SIZE(lsp0_gate_clk); i++) {
  677. if (lsp0_gate_clk[i].id)
  678. lsp0_hw_onecell_data.hws[lsp0_gate_clk[i].id] =
  679. &lsp0_gate_clk[i].gate.hw;
  680. lsp0_gate_clk[i].gate.reg += (uintptr_t)reg_base;
  681. ret = clk_hw_register(NULL, &lsp0_gate_clk[i].gate.hw);
  682. if (ret) {
  683. pr_warn("lsp0 clk %s init error!\n",
  684. lsp0_gate_clk[i].gate.hw.init->name);
  685. }
  686. }
  687. for (i = 0; i < ARRAY_SIZE(lsp0_div_clk); i++) {
  688. if (lsp0_div_clk[i].id)
  689. lsp0_hw_onecell_data.hws[lsp0_div_clk[i].id] =
  690. &lsp0_div_clk[i].div.hw;
  691. lsp0_div_clk[i].div.reg += (uintptr_t)reg_base;
  692. ret = clk_hw_register(NULL, &lsp0_div_clk[i].div.hw);
  693. if (ret) {
  694. pr_warn("lsp0 clk %s init error!\n",
  695. lsp0_div_clk[i].div.hw.init->name);
  696. }
  697. }
  698. if (of_clk_add_hw_provider(np, of_clk_hw_onecell_get, &lsp0_hw_onecell_data))
  699. panic("could not register clk provider\n");
  700. pr_info("lsp0-clk init over:%d\n", LSP0_NR_CLKS);
  701. return 0;
  702. }
  703. PNAME(lsp1_wclk_common_p) = {
  704. "lsp1_24m",
  705. "lsp1_99m",
  706. };
  707. PNAME(lsp1_wclk_ssp_p) = {
  708. "lsp1_148m5",
  709. "lsp1_99m",
  710. "lsp1_24m",
  711. };
  712. static struct zx_clk_mux lsp1_mux_clk[] = {
  713. MUX(0, "uart4_wclk_mux", lsp1_wclk_common_p, LSP1_UART4_CLK, 4, 1),
  714. MUX(0, "uart5_wclk_mux", lsp1_wclk_common_p, LSP1_UART5_CLK, 4, 1),
  715. MUX(0, "pwm_wclk_mux", lsp1_wclk_common_p, LSP1_PWM_CLK, 4, 1),
  716. MUX(0, "i2c2_wclk_mux", lsp1_wclk_common_p, LSP1_I2C2_CLK, 4, 1),
  717. MUX(0, "ssp2_wclk_mux", lsp1_wclk_ssp_p, LSP1_SSP2_CLK, 4, 2),
  718. MUX(0, "ssp3_wclk_mux", lsp1_wclk_ssp_p, LSP1_SSP3_CLK, 4, 2),
  719. MUX(0, "ssp4_wclk_mux", lsp1_wclk_ssp_p, LSP1_SSP4_CLK, 4, 2),
  720. MUX(0, "usim1_wclk_mux", lsp1_wclk_common_p, LSP1_USIM1_CLK, 4, 1),
  721. };
  722. static struct zx_clk_div lsp1_div_clk[] = {
  723. DIV_T(0, "pwm_div", "pwm_wclk_mux", LSP1_PWM_CLK, 12, 4, CLK_SET_RATE_PARENT, common_div_table),
  724. DIV_T(0, "ssp2_div", "ssp2_wclk_mux", LSP1_SSP2_CLK, 12, 4, CLK_SET_RATE_PARENT, common_even_div_table),
  725. DIV_T(0, "ssp3_div", "ssp3_wclk_mux", LSP1_SSP3_CLK, 12, 4, CLK_SET_RATE_PARENT, common_even_div_table),
  726. DIV_T(0, "ssp4_div", "ssp4_wclk_mux", LSP1_SSP4_CLK, 12, 4, CLK_SET_RATE_PARENT, common_even_div_table),
  727. };
  728. static struct zx_clk_gate lsp1_gate_clk[] = {
  729. GATE(LSP1_UART4_WCLK, "lsp1_uart4_wclk", "uart4_wclk_mux", LSP1_UART4_CLK, 1, CLK_SET_RATE_PARENT, 0),
  730. GATE(LSP1_UART5_WCLK, "lsp1_uart5_wclk", "uart5_wclk_mux", LSP1_UART5_CLK, 1, CLK_SET_RATE_PARENT, 0),
  731. GATE(LSP1_PWM_WCLK, "lsp1_pwm_wclk", "pwm_div", LSP1_PWM_CLK, 1, CLK_SET_RATE_PARENT, 0),
  732. GATE(LSP1_PWM_PCLK, "lsp1_pwm_pclk", "lsp1_pclk", LSP1_PWM_CLK, 0, 0, 0),
  733. GATE(LSP1_I2C2_WCLK, "lsp1_i2c2_wclk", "i2c2_wclk_mux", LSP1_I2C2_CLK, 1, CLK_SET_RATE_PARENT, 0),
  734. GATE(LSP1_SSP2_WCLK, "lsp1_ssp2_wclk", "ssp2_div", LSP1_SSP2_CLK, 1, CLK_SET_RATE_PARENT, 0),
  735. GATE(LSP1_SSP3_WCLK, "lsp1_ssp3_wclk", "ssp3_div", LSP1_SSP3_CLK, 1, CLK_SET_RATE_PARENT, 0),
  736. GATE(LSP1_SSP4_WCLK, "lsp1_ssp4_wclk", "ssp4_div", LSP1_SSP4_CLK, 1, CLK_SET_RATE_PARENT, 0),
  737. GATE(LSP1_USIM1_WCLK, "lsp1_usim1_wclk", "usim1_wclk_mux", LSP1_USIM1_CLK, 1, CLK_SET_RATE_PARENT, 0),
  738. };
  739. static struct clk_hw_onecell_data lsp1_hw_onecell_data = {
  740. .num = LSP1_NR_CLKS,
  741. .hws = {
  742. [LSP1_NR_CLKS - 1] = NULL,
  743. },
  744. };
  745. static int __init lsp1_clocks_init(struct device_node *np)
  746. {
  747. void __iomem *reg_base;
  748. int i, ret;
  749. reg_base = of_iomap(np, 0);
  750. if (!reg_base) {
  751. pr_err("%s: Unable to map clk base\n", __func__);
  752. return -ENXIO;
  753. }
  754. for (i = 0; i < ARRAY_SIZE(lsp1_mux_clk); i++) {
  755. if (lsp1_mux_clk[i].id)
  756. lsp1_hw_onecell_data.hws[lsp1_mux_clk[i].id] =
  757. &lsp0_mux_clk[i].mux.hw;
  758. lsp1_mux_clk[i].mux.reg += (uintptr_t)reg_base;
  759. ret = clk_hw_register(NULL, &lsp1_mux_clk[i].mux.hw);
  760. if (ret) {
  761. pr_warn("lsp1 clk %s init error!\n",
  762. lsp1_mux_clk[i].mux.hw.init->name);
  763. }
  764. }
  765. for (i = 0; i < ARRAY_SIZE(lsp1_gate_clk); i++) {
  766. if (lsp1_gate_clk[i].id)
  767. lsp1_hw_onecell_data.hws[lsp1_gate_clk[i].id] =
  768. &lsp1_gate_clk[i].gate.hw;
  769. lsp1_gate_clk[i].gate.reg += (uintptr_t)reg_base;
  770. ret = clk_hw_register(NULL, &lsp1_gate_clk[i].gate.hw);
  771. if (ret) {
  772. pr_warn("lsp1 clk %s init error!\n",
  773. lsp1_gate_clk[i].gate.hw.init->name);
  774. }
  775. }
  776. for (i = 0; i < ARRAY_SIZE(lsp1_div_clk); i++) {
  777. if (lsp1_div_clk[i].id)
  778. lsp1_hw_onecell_data.hws[lsp1_div_clk[i].id] =
  779. &lsp1_div_clk[i].div.hw;
  780. lsp1_div_clk[i].div.reg += (uintptr_t)reg_base;
  781. ret = clk_hw_register(NULL, &lsp1_div_clk[i].div.hw);
  782. if (ret) {
  783. pr_warn("lsp1 clk %s init error!\n",
  784. lsp1_div_clk[i].div.hw.init->name);
  785. }
  786. }
  787. if (of_clk_add_hw_provider(np, of_clk_hw_onecell_get, &lsp1_hw_onecell_data))
  788. panic("could not register clk provider\n");
  789. pr_info("lsp1-clk init over, nr:%d\n", LSP1_NR_CLKS);
  790. return 0;
  791. }
  792. static const struct of_device_id zx_clkc_match_table[] = {
  793. { .compatible = "zte,zx296718-topcrm", .data = &top_clocks_init },
  794. { .compatible = "zte,zx296718-lsp0crm", .data = &lsp0_clocks_init },
  795. { .compatible = "zte,zx296718-lsp1crm", .data = &lsp1_clocks_init },
  796. { }
  797. };
  798. static int zx_clkc_probe(struct platform_device *pdev)
  799. {
  800. int (*init_fn)(struct device_node *np);
  801. struct device_node *np = pdev->dev.of_node;
  802. init_fn = of_device_get_match_data(&pdev->dev);
  803. if (!init_fn) {
  804. dev_err(&pdev->dev, "Error: No device match found\n");
  805. return -ENODEV;
  806. }
  807. return init_fn(np);
  808. }
  809. static struct platform_driver zx_clk_driver = {
  810. .probe = zx_clkc_probe,
  811. .driver = {
  812. .name = "zx296718-clkc",
  813. .of_match_table = zx_clkc_match_table,
  814. },
  815. };
  816. static int __init zx_clk_init(void)
  817. {
  818. return platform_driver_register(&zx_clk_driver);
  819. }
  820. core_initcall(zx_clk_init);