clk-mt2712.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2017 MediaTek Inc.
  4. * Author: Weiyi Lu <weiyi.lu@mediatek.com>
  5. */
  6. #include <linux/clk.h>
  7. #include <linux/delay.h>
  8. #include <linux/mfd/syscon.h>
  9. #include <linux/mod_devicetable.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/slab.h>
  12. #include "clk-gate.h"
  13. #include "clk-mtk.h"
  14. #include <dt-bindings/clock/mt2712-clk.h>
  15. static DEFINE_SPINLOCK(mt2712_clk_lock);
  16. static const struct mtk_fixed_clk top_fixed_clks[] = {
  17. FIXED_CLK(CLK_TOP_VPLL3_DPIX, "vpll3_dpix", NULL, 200000000),
  18. FIXED_CLK(CLK_TOP_VPLL_DPIX, "vpll_dpix", NULL, 200000000),
  19. FIXED_CLK(CLK_TOP_LTEPLL_FS26M, "ltepll_fs26m", NULL, 26000000),
  20. FIXED_CLK(CLK_TOP_DMPLL, "dmpll_ck", NULL, 350000000),
  21. FIXED_CLK(CLK_TOP_DSI0_LNTC, "dsi0_lntc", NULL, 143000000),
  22. FIXED_CLK(CLK_TOP_DSI1_LNTC, "dsi1_lntc", NULL, 143000000),
  23. FIXED_CLK(CLK_TOP_LVDSTX3_CLKDIG_CTS, "lvdstx3", NULL, 140000000),
  24. FIXED_CLK(CLK_TOP_LVDSTX_CLKDIG_CTS, "lvdstx", NULL, 140000000),
  25. FIXED_CLK(CLK_TOP_CLKRTC_EXT, "clkrtc_ext", NULL, 32768),
  26. FIXED_CLK(CLK_TOP_CLKRTC_INT, "clkrtc_int", NULL, 32747),
  27. FIXED_CLK(CLK_TOP_CSI0, "csi0", NULL, 26000000),
  28. FIXED_CLK(CLK_TOP_CVBSPLL, "cvbspll", NULL, 108000000),
  29. };
  30. static const struct mtk_fixed_factor top_divs[] = {
  31. FACTOR(CLK_TOP_SYS_26M, "sys_26m", "clk26m", 1, 1),
  32. FACTOR(CLK_TOP_CLK26M_D2, "clk26m_d2", "sys_26m", 1, 2),
  33. FACTOR(CLK_TOP_ARMCA35PLL, "armca35pll_ck", "armca35pll", 1, 1),
  34. FACTOR(CLK_TOP_ARMCA35PLL_600M, "armca35pll_600m", "armca35pll_ck", 1, 2),
  35. FACTOR(CLK_TOP_ARMCA35PLL_400M, "armca35pll_400m", "armca35pll_ck", 1, 3),
  36. FACTOR(CLK_TOP_ARMCA72PLL, "armca72pll_ck", "armca72pll", 1, 1),
  37. FACTOR(CLK_TOP_SYSPLL, "syspll_ck", "mainpll", 1, 1),
  38. FACTOR(CLK_TOP_SYSPLL_D2, "syspll_d2", "syspll_ck", 1, 2),
  39. FACTOR(CLK_TOP_SYSPLL1_D2, "syspll1_d2", "syspll_d2", 1, 2),
  40. FACTOR(CLK_TOP_SYSPLL1_D4, "syspll1_d4", "syspll_d2", 1, 4),
  41. FACTOR(CLK_TOP_SYSPLL1_D8, "syspll1_d8", "syspll_d2", 1, 8),
  42. FACTOR(CLK_TOP_SYSPLL1_D16, "syspll1_d16", "syspll_d2", 1, 16),
  43. FACTOR(CLK_TOP_SYSPLL_D3, "syspll_d3", "syspll_ck", 1, 3),
  44. FACTOR(CLK_TOP_SYSPLL2_D2, "syspll2_d2", "syspll_d3", 1, 2),
  45. FACTOR(CLK_TOP_SYSPLL2_D4, "syspll2_d4", "syspll_d3", 1, 4),
  46. FACTOR(CLK_TOP_SYSPLL_D5, "syspll_d5", "syspll_ck", 1, 5),
  47. FACTOR(CLK_TOP_SYSPLL3_D2, "syspll3_d2", "syspll_d5", 1, 2),
  48. FACTOR(CLK_TOP_SYSPLL3_D4, "syspll3_d4", "syspll_d5", 1, 4),
  49. FACTOR(CLK_TOP_SYSPLL_D7, "syspll_d7", "syspll_ck", 1, 7),
  50. FACTOR(CLK_TOP_SYSPLL4_D2, "syspll4_d2", "syspll_d7", 1, 2),
  51. FACTOR(CLK_TOP_SYSPLL4_D4, "syspll4_d4", "syspll_d7", 1, 4),
  52. FACTOR(CLK_TOP_UNIVPLL, "univpll_ck", "univpll", 1, 1),
  53. FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll_ck", 1, 7),
  54. FACTOR(CLK_TOP_UNIVPLL_D26, "univpll_d26", "univpll_ck", 1, 26),
  55. FACTOR(CLK_TOP_UNIVPLL_D52, "univpll_d52", "univpll_ck", 1, 52),
  56. FACTOR(CLK_TOP_UNIVPLL_D104, "univpll_d104", "univpll_ck", 1, 104),
  57. FACTOR(CLK_TOP_UNIVPLL_D208, "univpll_d208", "univpll_ck", 1, 208),
  58. FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll_ck", 1, 2),
  59. FACTOR(CLK_TOP_UNIVPLL1_D2, "univpll1_d2", "univpll_d2", 1, 2),
  60. FACTOR(CLK_TOP_UNIVPLL1_D4, "univpll1_d4", "univpll_d2", 1, 4),
  61. FACTOR(CLK_TOP_UNIVPLL1_D8, "univpll1_d8", "univpll_d2", 1, 8),
  62. FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll_ck", 1, 3),
  63. FACTOR(CLK_TOP_UNIVPLL2_D2, "univpll2_d2", "univpll_d3", 1, 2),
  64. FACTOR(CLK_TOP_UNIVPLL2_D4, "univpll2_d4", "univpll_d3", 1, 4),
  65. FACTOR(CLK_TOP_UNIVPLL2_D8, "univpll2_d8", "univpll_d3", 1, 8),
  66. FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll_ck", 1, 5),
  67. FACTOR(CLK_TOP_UNIVPLL3_D2, "univpll3_d2", "univpll_d5", 1, 2),
  68. FACTOR(CLK_TOP_UNIVPLL3_D4, "univpll3_d4", "univpll_d5", 1, 4),
  69. FACTOR(CLK_TOP_UNIVPLL3_D8, "univpll3_d8", "univpll_d5", 1, 8),
  70. FACTOR(CLK_TOP_F_MP0_PLL1, "f_mp0_pll1_ck", "univpll_d2", 1, 1),
  71. FACTOR(CLK_TOP_F_MP0_PLL2, "f_mp0_pll2_ck", "univpll1_d2", 1, 1),
  72. FACTOR(CLK_TOP_F_BIG_PLL1, "f_big_pll1_ck", "univpll_d2", 1, 1),
  73. FACTOR(CLK_TOP_F_BIG_PLL2, "f_big_pll2_ck", "univpll1_d2", 1, 1),
  74. FACTOR(CLK_TOP_F_BUS_PLL1, "f_bus_pll1_ck", "univpll_d2", 1, 1),
  75. FACTOR(CLK_TOP_F_BUS_PLL2, "f_bus_pll2_ck", "univpll1_d2", 1, 1),
  76. FACTOR(CLK_TOP_APLL1, "apll1_ck", "apll1", 1, 1),
  77. FACTOR(CLK_TOP_APLL1_D2, "apll1_d2", "apll1_ck", 1, 2),
  78. FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1_ck", 1, 4),
  79. FACTOR(CLK_TOP_APLL1_D8, "apll1_d8", "apll1_ck", 1, 8),
  80. FACTOR(CLK_TOP_APLL1_D16, "apll1_d16", "apll1_ck", 1, 16),
  81. FACTOR(CLK_TOP_APLL2, "apll2_ck", "apll2", 1, 1),
  82. FACTOR(CLK_TOP_APLL2_D2, "apll2_d2", "apll2_ck", 1, 2),
  83. FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2_ck", 1, 4),
  84. FACTOR(CLK_TOP_APLL2_D8, "apll2_d8", "apll2_ck", 1, 8),
  85. FACTOR(CLK_TOP_APLL2_D16, "apll2_d16", "apll2_ck", 1, 16),
  86. FACTOR(CLK_TOP_LVDSPLL, "lvdspll_ck", "lvdspll", 1, 1),
  87. FACTOR(CLK_TOP_LVDSPLL_D2, "lvdspll_d2", "lvdspll_ck", 1, 2),
  88. FACTOR(CLK_TOP_LVDSPLL_D4, "lvdspll_d4", "lvdspll_ck", 1, 4),
  89. FACTOR(CLK_TOP_LVDSPLL_D8, "lvdspll_d8", "lvdspll_ck", 1, 8),
  90. FACTOR(CLK_TOP_LVDSPLL2, "lvdspll2_ck", "lvdspll2", 1, 1),
  91. FACTOR(CLK_TOP_LVDSPLL2_D2, "lvdspll2_d2", "lvdspll2_ck", 1, 2),
  92. FACTOR(CLK_TOP_LVDSPLL2_D4, "lvdspll2_d4", "lvdspll2_ck", 1, 4),
  93. FACTOR(CLK_TOP_LVDSPLL2_D8, "lvdspll2_d8", "lvdspll2_ck", 1, 8),
  94. FACTOR(CLK_TOP_ETHERPLL_125M, "etherpll_125m", "etherpll", 1, 1),
  95. FACTOR(CLK_TOP_ETHERPLL_50M, "etherpll_50m", "etherpll", 1, 1),
  96. FACTOR(CLK_TOP_CVBS, "cvbs", "cvbspll", 1, 1),
  97. FACTOR(CLK_TOP_CVBS_D2, "cvbs_d2", "cvbs", 1, 2),
  98. FACTOR(CLK_TOP_MMPLL, "mmpll_ck", "mmpll", 1, 1),
  99. FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", "mmpll_ck", 1, 2),
  100. FACTOR(CLK_TOP_VENCPLL, "vencpll_ck", "vencpll", 1, 1),
  101. FACTOR(CLK_TOP_VENCPLL_D2, "vencpll_d2", "vencpll_ck", 1, 2),
  102. FACTOR(CLK_TOP_VCODECPLL, "vcodecpll_ck", "vcodecpll", 1, 1),
  103. FACTOR(CLK_TOP_VCODECPLL_D2, "vcodecpll_d2", "vcodecpll_ck", 1, 2),
  104. FACTOR(CLK_TOP_TVDPLL, "tvdpll_ck", "tvdpll", 1, 1),
  105. FACTOR(CLK_TOP_TVDPLL_D2, "tvdpll_d2", "tvdpll_ck", 1, 2),
  106. FACTOR(CLK_TOP_TVDPLL_D4, "tvdpll_d4", "tvdpll_ck", 1, 4),
  107. FACTOR(CLK_TOP_TVDPLL_D8, "tvdpll_d8", "tvdpll_ck", 1, 8),
  108. FACTOR(CLK_TOP_TVDPLL_429M, "tvdpll_429m", "tvdpll", 1, 1),
  109. FACTOR(CLK_TOP_TVDPLL_429M_D2, "tvdpll_429m_d2", "tvdpll_429m", 1, 2),
  110. FACTOR(CLK_TOP_TVDPLL_429M_D4, "tvdpll_429m_d4", "tvdpll_429m", 1, 4),
  111. FACTOR(CLK_TOP_MSDCPLL, "msdcpll_ck", "msdcpll", 1, 1),
  112. FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll_ck", 1, 2),
  113. FACTOR(CLK_TOP_MSDCPLL_D4, "msdcpll_d4", "msdcpll_ck", 1, 4),
  114. FACTOR(CLK_TOP_MSDCPLL2, "msdcpll2_ck", "msdcpll2", 1, 1),
  115. FACTOR(CLK_TOP_MSDCPLL2_D2, "msdcpll2_d2", "msdcpll2_ck", 1, 2),
  116. FACTOR(CLK_TOP_MSDCPLL2_D4, "msdcpll2_d4", "msdcpll2_ck", 1, 4),
  117. FACTOR(CLK_TOP_D2A_ULCLK_6P5M, "d2a_ulclk_6p5m", "clk26m", 1, 4),
  118. FACTOR(CLK_TOP_APLL1_D3, "apll1_d3", "apll1_ck", 1, 3),
  119. FACTOR(CLK_TOP_APLL2_D3, "apll2_d3", "apll2_ck", 1, 3),
  120. };
  121. static const char * const axi_parents[] = {
  122. "clk26m",
  123. "syspll1_d2",
  124. "syspll_d5",
  125. "syspll1_d4",
  126. "univpll_d5",
  127. "univpll2_d2",
  128. "msdcpll2_ck"
  129. };
  130. static const char * const mem_parents[] = {
  131. "clk26m",
  132. "dmpll_ck"
  133. };
  134. static const char * const mm_parents[] = {
  135. "clk26m",
  136. "vencpll_ck",
  137. "syspll_d3",
  138. "syspll1_d2",
  139. "syspll_d5",
  140. "syspll1_d4",
  141. "univpll1_d2",
  142. "univpll2_d2"
  143. };
  144. static const char * const pwm_parents[] = {
  145. "clk26m",
  146. "univpll2_d4",
  147. "univpll3_d2",
  148. "univpll1_d4"
  149. };
  150. static const char * const vdec_parents[] = {
  151. "clk26m",
  152. "vcodecpll_ck",
  153. "tvdpll_429m",
  154. "univpll_d3",
  155. "vencpll_ck",
  156. "syspll_d3",
  157. "univpll1_d2",
  158. "mmpll_d2",
  159. "syspll3_d2",
  160. "tvdpll_ck"
  161. };
  162. static const char * const venc_parents[] = {
  163. "clk26m",
  164. "univpll1_d2",
  165. "mmpll_d2",
  166. "tvdpll_d2",
  167. "syspll1_d2",
  168. "univpll_d5",
  169. "vcodecpll_d2",
  170. "univpll2_d2",
  171. "syspll3_d2"
  172. };
  173. static const char * const mfg_parents[] = {
  174. "clk26m",
  175. "mmpll_ck",
  176. "univpll_d3",
  177. "clk26m",
  178. "clk26m",
  179. "clk26m",
  180. "clk26m",
  181. "clk26m",
  182. "clk26m",
  183. "syspll_d3",
  184. "syspll1_d2",
  185. "syspll_d5",
  186. "univpll_d3",
  187. "univpll1_d2",
  188. "univpll_d5",
  189. "univpll2_d2"
  190. };
  191. static const char * const camtg_parents[] = {
  192. "clk26m",
  193. "univpll_d52",
  194. "univpll_d208",
  195. "univpll_d104",
  196. "clk26m_d2",
  197. "univpll_d26",
  198. "univpll2_d8",
  199. "syspll3_d4",
  200. "syspll3_d2",
  201. "univpll1_d4",
  202. "univpll2_d2"
  203. };
  204. static const char * const uart_parents[] = {
  205. "clk26m",
  206. "univpll2_d8"
  207. };
  208. static const char * const spi_parents[] = {
  209. "clk26m",
  210. "univpll2_d4",
  211. "univpll1_d4",
  212. "univpll2_d2",
  213. "univpll3_d2",
  214. "univpll1_d8"
  215. };
  216. static const char * const usb20_parents[] = {
  217. "clk26m",
  218. "univpll1_d8",
  219. "univpll3_d4"
  220. };
  221. static const char * const usb30_parents[] = {
  222. "clk26m",
  223. "univpll3_d2",
  224. "univpll3_d4",
  225. "univpll2_d4"
  226. };
  227. static const char * const msdc50_0_h_parents[] = {
  228. "clk26m",
  229. "syspll1_d2",
  230. "syspll2_d2",
  231. "syspll4_d2",
  232. "univpll_d5",
  233. "univpll1_d4"
  234. };
  235. static const char * const msdc50_0_parents[] = {
  236. "clk26m",
  237. "msdcpll_ck",
  238. "msdcpll_d2",
  239. "univpll1_d4",
  240. "syspll2_d2",
  241. "msdcpll_d4",
  242. "vencpll_d2",
  243. "univpll1_d2",
  244. "msdcpll2_ck",
  245. "msdcpll2_d2",
  246. "msdcpll2_d4"
  247. };
  248. static const char * const msdc30_1_parents[] = {
  249. "clk26m",
  250. "univpll2_d2",
  251. "msdcpll_d2",
  252. "univpll1_d4",
  253. "syspll2_d2",
  254. "univpll_d7",
  255. "vencpll_d2"
  256. };
  257. static const char * const msdc30_3_parents[] = {
  258. "clk26m",
  259. "msdcpll2_ck",
  260. "msdcpll2_d2",
  261. "univpll2_d2",
  262. "msdcpll2_d4",
  263. "univpll1_d4",
  264. "syspll2_d2",
  265. "syspll_d7",
  266. "univpll_d7",
  267. "vencpll_d2",
  268. "msdcpll_ck",
  269. "msdcpll_d2",
  270. "msdcpll_d4"
  271. };
  272. static const char * const audio_parents[] = {
  273. "clk26m",
  274. "syspll3_d4",
  275. "syspll4_d4",
  276. "syspll1_d16"
  277. };
  278. static const char * const aud_intbus_parents[] = {
  279. "clk26m",
  280. "syspll1_d4",
  281. "syspll4_d2",
  282. "univpll3_d2",
  283. "univpll2_d8",
  284. "syspll3_d2",
  285. "syspll3_d4"
  286. };
  287. static const char * const pmicspi_parents[] = {
  288. "clk26m",
  289. "syspll1_d8",
  290. "syspll3_d4",
  291. "syspll1_d16",
  292. "univpll3_d4",
  293. "univpll_d26",
  294. "syspll3_d4"
  295. };
  296. static const char * const dpilvds1_parents[] = {
  297. "clk26m",
  298. "lvdspll2_ck",
  299. "lvdspll2_d2",
  300. "lvdspll2_d4",
  301. "lvdspll2_d8",
  302. "clkfpc"
  303. };
  304. static const char * const atb_parents[] = {
  305. "clk26m",
  306. "syspll1_d2",
  307. "univpll_d5",
  308. "syspll_d5"
  309. };
  310. static const char * const nr_parents[] = {
  311. "clk26m",
  312. "univpll1_d4",
  313. "syspll2_d2",
  314. "syspll1_d4",
  315. "univpll1_d8",
  316. "univpll3_d2",
  317. "univpll2_d2",
  318. "syspll_d5"
  319. };
  320. static const char * const nfi2x_parents[] = {
  321. "clk26m",
  322. "syspll4_d4",
  323. "univpll3_d4",
  324. "univpll1_d8",
  325. "syspll2_d4",
  326. "univpll3_d2",
  327. "syspll_d7",
  328. "syspll2_d2",
  329. "univpll2_d2",
  330. "syspll_d5",
  331. "syspll1_d2"
  332. };
  333. static const char * const irda_parents[] = {
  334. "clk26m",
  335. "univpll2_d4",
  336. "syspll2_d4",
  337. "univpll2_d8"
  338. };
  339. static const char * const cci400_parents[] = {
  340. "clk26m",
  341. "vencpll_ck",
  342. "armca35pll_600m",
  343. "armca35pll_400m",
  344. "univpll_d2",
  345. "syspll_d2",
  346. "msdcpll_ck",
  347. "univpll_d3"
  348. };
  349. static const char * const aud_1_parents[] = {
  350. "clk26m",
  351. "apll1_ck",
  352. "univpll2_d4",
  353. "univpll2_d8"
  354. };
  355. static const char * const aud_2_parents[] = {
  356. "clk26m",
  357. "apll2_ck",
  358. "univpll2_d4",
  359. "univpll2_d8"
  360. };
  361. static const char * const mem_mfg_parents[] = {
  362. "clk26m",
  363. "mmpll_ck",
  364. "univpll_d3"
  365. };
  366. static const char * const axi_mfg_parents[] = {
  367. "clk26m",
  368. "axi_sel",
  369. "univpll_d5"
  370. };
  371. static const char * const scam_parents[] = {
  372. "clk26m",
  373. "syspll3_d2",
  374. "univpll2_d4",
  375. "syspll2_d4"
  376. };
  377. static const char * const nfiecc_parents[] = {
  378. "clk26m",
  379. "nfi2x_sel",
  380. "syspll_d7",
  381. "syspll2_d2",
  382. "univpll2_d2",
  383. "univpll_d5",
  384. "syspll1_d2"
  385. };
  386. static const char * const pe2_mac_p0_parents[] = {
  387. "clk26m",
  388. "syspll1_d8",
  389. "syspll4_d2",
  390. "syspll2_d4",
  391. "univpll2_d4",
  392. "syspll3_d2"
  393. };
  394. static const char * const dpilvds_parents[] = {
  395. "clk26m",
  396. "lvdspll_ck",
  397. "lvdspll_d2",
  398. "lvdspll_d4",
  399. "lvdspll_d8",
  400. "clkfpc"
  401. };
  402. static const char * const hdcp_parents[] = {
  403. "clk26m",
  404. "syspll4_d2",
  405. "syspll3_d4",
  406. "univpll2_d4"
  407. };
  408. static const char * const hdcp_24m_parents[] = {
  409. "clk26m",
  410. "univpll_d26",
  411. "univpll_d52",
  412. "univpll2_d8"
  413. };
  414. static const char * const rtc_parents[] = {
  415. "clkrtc_int",
  416. "clkrtc_ext",
  417. "clk26m",
  418. "univpll3_d8"
  419. };
  420. static const char * const spinor_parents[] = {
  421. "clk26m",
  422. "clk26m_d2",
  423. "syspll4_d4",
  424. "univpll2_d8",
  425. "univpll3_d4",
  426. "syspll4_d2",
  427. "syspll2_d4",
  428. "univpll2_d4",
  429. "etherpll_125m",
  430. "syspll1_d4"
  431. };
  432. static const char * const apll_parents[] = {
  433. "clk26m",
  434. "apll1_ck",
  435. "apll1_d2",
  436. "apll1_d4",
  437. "apll1_d8",
  438. "apll1_d16",
  439. "apll2_ck",
  440. "apll2_d2",
  441. "apll2_d4",
  442. "apll2_d8",
  443. "apll2_d16",
  444. "clk26m",
  445. "clk26m"
  446. };
  447. static const char * const a1sys_hp_parents[] = {
  448. "clk26m",
  449. "apll1_ck",
  450. "apll1_d2",
  451. "apll1_d4",
  452. "apll1_d8",
  453. "apll1_d3"
  454. };
  455. static const char * const a2sys_hp_parents[] = {
  456. "clk26m",
  457. "apll2_ck",
  458. "apll2_d2",
  459. "apll2_d4",
  460. "apll2_d8",
  461. "apll2_d3"
  462. };
  463. static const char * const asm_l_parents[] = {
  464. "clk26m",
  465. "univpll2_d4",
  466. "univpll2_d2",
  467. "syspll_d5"
  468. };
  469. static const char * const i2so1_parents[] = {
  470. "clk26m",
  471. "apll1_ck",
  472. "apll2_ck"
  473. };
  474. static const char * const ether_125m_parents[] = {
  475. "clk26m",
  476. "etherpll_125m",
  477. "univpll3_d2"
  478. };
  479. static const char * const ether_50m_parents[] = {
  480. "clk26m",
  481. "etherpll_50m",
  482. "apll1_d3",
  483. "univpll3_d4"
  484. };
  485. static const char * const jpgdec_parents[] = {
  486. "clk26m",
  487. "univpll_d3",
  488. "tvdpll_429m",
  489. "vencpll_ck",
  490. "syspll_d3",
  491. "vcodecpll_ck",
  492. "univpll1_d2",
  493. "armca35pll_400m",
  494. "tvdpll_429m_d2",
  495. "tvdpll_429m_d4"
  496. };
  497. static const char * const spislv_parents[] = {
  498. "clk26m",
  499. "univpll2_d4",
  500. "univpll1_d4",
  501. "univpll2_d2",
  502. "univpll3_d2",
  503. "univpll1_d8",
  504. "univpll1_d2",
  505. "univpll_d5"
  506. };
  507. static const char * const ether_parents[] = {
  508. "clk26m",
  509. "etherpll_50m",
  510. "univpll_d26"
  511. };
  512. static const char * const di_parents[] = {
  513. "clk26m",
  514. "tvdpll_d2",
  515. "tvdpll_d4",
  516. "tvdpll_d8",
  517. "vencpll_ck",
  518. "vencpll_d2",
  519. "cvbs",
  520. "cvbs_d2"
  521. };
  522. static const char * const tvd_parents[] = {
  523. "clk26m",
  524. "cvbs_d2",
  525. "univpll2_d8"
  526. };
  527. static const char * const i2c_parents[] = {
  528. "clk26m",
  529. "univpll_d26",
  530. "univpll2_d4",
  531. "univpll3_d2",
  532. "univpll1_d4"
  533. };
  534. static const char * const msdc0p_aes_parents[] = {
  535. "clk26m",
  536. "syspll_d2",
  537. "univpll_d3",
  538. "vcodecpll_ck"
  539. };
  540. static const char * const cmsys_parents[] = {
  541. "clk26m",
  542. "univpll_d3",
  543. "syspll_d3",
  544. "syspll1_d2",
  545. "syspll2_d2"
  546. };
  547. static const char * const gcpu_parents[] = {
  548. "clk26m",
  549. "syspll_d3",
  550. "syspll1_d2",
  551. "univpll1_d2",
  552. "univpll_d5",
  553. "univpll3_d2",
  554. "univpll_d3"
  555. };
  556. static const char * const aud_apll1_parents[] = {
  557. "apll1",
  558. "clkaud_ext_i_1"
  559. };
  560. static const char * const aud_apll2_parents[] = {
  561. "apll2",
  562. "clkaud_ext_i_2"
  563. };
  564. static const char * const apll1_ref_parents[] = {
  565. "clkaud_ext_i_2",
  566. "clkaud_ext_i_1",
  567. "clki2si0_mck_i",
  568. "clki2si1_mck_i",
  569. "clki2si2_mck_i",
  570. "clktdmin_mclk_i",
  571. "clki2si2_mck_i",
  572. "clktdmin_mclk_i"
  573. };
  574. static const char * const audull_vtx_parents[] = {
  575. "d2a_ulclk_6p5m",
  576. "clkaud_ext_i_0"
  577. };
  578. static struct mtk_composite top_muxes[] = {
  579. /* CLK_CFG_0 */
  580. MUX_GATE_FLAGS(CLK_TOP_AXI_SEL, "axi_sel", axi_parents, 0x040, 0, 3,
  581. 7, CLK_IS_CRITICAL),
  582. MUX_GATE_FLAGS(CLK_TOP_MEM_SEL, "mem_sel", mem_parents, 0x040, 8, 1,
  583. 15, CLK_IS_CRITICAL),
  584. MUX_GATE(CLK_TOP_MM_SEL, "mm_sel", mm_parents, 0x040, 24, 3, 31),
  585. /* CLK_CFG_1 */
  586. MUX_GATE(CLK_TOP_PWM_SEL, "pwm_sel", pwm_parents, 0x050, 0, 2, 7),
  587. MUX_GATE(CLK_TOP_VDEC_SEL, "vdec_sel", vdec_parents, 0x050, 8, 4, 15),
  588. MUX_GATE(CLK_TOP_VENC_SEL, "venc_sel", venc_parents, 0x050, 16, 4, 23),
  589. MUX_GATE(CLK_TOP_MFG_SEL, "mfg_sel", mfg_parents, 0x050, 24, 4, 31),
  590. /* CLK_CFG_2 */
  591. MUX_GATE(CLK_TOP_CAMTG_SEL, "camtg_sel", camtg_parents, 0x060, 0, 4, 7),
  592. MUX_GATE(CLK_TOP_UART_SEL, "uart_sel", uart_parents, 0x060, 8, 1, 15),
  593. MUX_GATE(CLK_TOP_SPI_SEL, "spi_sel", spi_parents, 0x060, 16, 3, 23),
  594. MUX_GATE(CLK_TOP_USB20_SEL, "usb20_sel", usb20_parents, 0x060, 24, 2, 31),
  595. /* CLK_CFG_3 */
  596. MUX_GATE(CLK_TOP_USB30_SEL, "usb30_sel", usb30_parents, 0x070, 0, 2, 7),
  597. MUX_GATE(CLK_TOP_MSDC50_0_HCLK_SEL, "msdc50_0_h_sel", msdc50_0_h_parents,
  598. 0x070, 8, 3, 15),
  599. MUX_GATE(CLK_TOP_MSDC50_0_SEL, "msdc50_0_sel", msdc50_0_parents,
  600. 0x070, 16, 4, 23),
  601. MUX_GATE(CLK_TOP_MSDC30_1_SEL, "msdc30_1_sel", msdc30_1_parents,
  602. 0x070, 24, 3, 31),
  603. /* CLK_CFG_4 */
  604. MUX_GATE(CLK_TOP_MSDC30_2_SEL, "msdc30_2_sel", msdc30_1_parents,
  605. 0x080, 0, 3, 7),
  606. MUX_GATE(CLK_TOP_MSDC30_3_SEL, "msdc30_3_sel", msdc30_3_parents,
  607. 0x080, 8, 4, 15),
  608. MUX_GATE(CLK_TOP_AUDIO_SEL, "audio_sel", audio_parents,
  609. 0x080, 16, 2, 23),
  610. MUX_GATE(CLK_TOP_AUD_INTBUS_SEL, "aud_intbus_sel", aud_intbus_parents,
  611. 0x080, 24, 3, 31),
  612. /* CLK_CFG_5 */
  613. MUX_GATE(CLK_TOP_PMICSPI_SEL, "pmicspi_sel", pmicspi_parents, 0x090, 0, 3, 7),
  614. MUX_GATE(CLK_TOP_DPILVDS1_SEL, "dpilvds1_sel", dpilvds1_parents,
  615. 0x090, 8, 3, 15),
  616. MUX_GATE(CLK_TOP_ATB_SEL, "atb_sel", atb_parents, 0x090, 16, 2, 23),
  617. MUX_GATE(CLK_TOP_NR_SEL, "nr_sel", nr_parents, 0x090, 24, 3, 31),
  618. /* CLK_CFG_6 */
  619. MUX_GATE(CLK_TOP_NFI2X_SEL, "nfi2x_sel", nfi2x_parents, 0x0a0, 0, 4, 7),
  620. MUX_GATE(CLK_TOP_IRDA_SEL, "irda_sel", irda_parents, 0x0a0, 8, 2, 15),
  621. MUX_GATE(CLK_TOP_CCI400_SEL, "cci400_sel", cci400_parents, 0x0a0, 16, 3, 23),
  622. MUX_GATE(CLK_TOP_AUD_1_SEL, "aud_1_sel", aud_1_parents, 0x0a0, 24, 2, 31),
  623. /* CLK_CFG_7 */
  624. MUX_GATE(CLK_TOP_AUD_2_SEL, "aud_2_sel", aud_2_parents, 0x0b0, 0, 2, 7),
  625. MUX_GATE(CLK_TOP_MEM_MFG_IN_AS_SEL, "mem_mfg_sel", mem_mfg_parents,
  626. 0x0b0, 8, 2, 15),
  627. MUX_GATE(CLK_TOP_AXI_MFG_IN_AS_SEL, "axi_mfg_sel", axi_mfg_parents,
  628. 0x0b0, 16, 2, 23),
  629. MUX_GATE(CLK_TOP_SCAM_SEL, "scam_sel", scam_parents, 0x0b0, 24, 2, 31),
  630. /* CLK_CFG_8 */
  631. MUX_GATE(CLK_TOP_NFIECC_SEL, "nfiecc_sel", nfiecc_parents, 0x0c0, 0, 3, 7),
  632. MUX_GATE(CLK_TOP_PE2_MAC_P0_SEL, "pe2_mac_p0_sel", pe2_mac_p0_parents,
  633. 0x0c0, 8, 3, 15),
  634. MUX_GATE(CLK_TOP_PE2_MAC_P1_SEL, "pe2_mac_p1_sel", pe2_mac_p0_parents,
  635. 0x0c0, 16, 3, 23),
  636. MUX_GATE(CLK_TOP_DPILVDS_SEL, "dpilvds_sel", dpilvds_parents, 0x0c0, 24, 3, 31),
  637. /* CLK_CFG_9 */
  638. MUX_GATE(CLK_TOP_MSDC50_3_HCLK_SEL, "msdc50_3_h_sel", msdc50_0_h_parents,
  639. 0x0d0, 0, 3, 7),
  640. MUX_GATE(CLK_TOP_HDCP_SEL, "hdcp_sel", hdcp_parents, 0x0d0, 8, 2, 15),
  641. MUX_GATE(CLK_TOP_HDCP_24M_SEL, "hdcp_24m_sel", hdcp_24m_parents,
  642. 0x0d0, 16, 2, 23),
  643. MUX_GATE_FLAGS(CLK_TOP_RTC_SEL, "rtc_sel", rtc_parents,
  644. 0x0d0, 24, 2, 31, CLK_IS_CRITICAL),
  645. /* CLK_CFG_10 */
  646. MUX_GATE(CLK_TOP_SPINOR_SEL, "spinor_sel", spinor_parents, 0x500, 0, 4, 7),
  647. MUX_GATE(CLK_TOP_APLL_SEL, "apll_sel", apll_parents, 0x500, 8, 4, 15),
  648. MUX_GATE(CLK_TOP_APLL2_SEL, "apll2_sel", apll_parents, 0x500, 16, 4, 23),
  649. MUX_GATE(CLK_TOP_A1SYS_HP_SEL, "a1sys_hp_sel", a1sys_hp_parents,
  650. 0x500, 24, 3, 31),
  651. /* CLK_CFG_11 */
  652. MUX_GATE(CLK_TOP_A2SYS_HP_SEL, "a2sys_hp_sel", a2sys_hp_parents, 0x510, 0, 3, 7),
  653. MUX_GATE(CLK_TOP_ASM_L_SEL, "asm_l_sel", asm_l_parents, 0x510, 8, 2, 15),
  654. MUX_GATE(CLK_TOP_ASM_M_SEL, "asm_m_sel", asm_l_parents, 0x510, 16, 2, 23),
  655. MUX_GATE(CLK_TOP_ASM_H_SEL, "asm_h_sel", asm_l_parents, 0x510, 24, 2, 31),
  656. /* CLK_CFG_12 */
  657. MUX_GATE(CLK_TOP_I2SO1_SEL, "i2so1_sel", i2so1_parents, 0x520, 0, 2, 7),
  658. MUX_GATE(CLK_TOP_I2SO2_SEL, "i2so2_sel", i2so1_parents, 0x520, 8, 2, 15),
  659. MUX_GATE(CLK_TOP_I2SO3_SEL, "i2so3_sel", i2so1_parents, 0x520, 16, 2, 23),
  660. MUX_GATE(CLK_TOP_TDMO0_SEL, "tdmo0_sel", i2so1_parents, 0x520, 24, 2, 31),
  661. /* CLK_CFG_13 */
  662. MUX_GATE(CLK_TOP_TDMO1_SEL, "tdmo1_sel", i2so1_parents, 0x530, 0, 2, 7),
  663. MUX_GATE(CLK_TOP_I2SI1_SEL, "i2si1_sel", i2so1_parents, 0x530, 8, 2, 15),
  664. MUX_GATE(CLK_TOP_I2SI2_SEL, "i2si2_sel", i2so1_parents, 0x530, 16, 2, 23),
  665. MUX_GATE(CLK_TOP_I2SI3_SEL, "i2si3_sel", i2so1_parents, 0x530, 24, 2, 31),
  666. /* CLK_CFG_14 */
  667. MUX_GATE(CLK_TOP_ETHER_125M_SEL, "ether_125m_sel", ether_125m_parents,
  668. 0x540, 0, 2, 7),
  669. MUX_GATE(CLK_TOP_ETHER_50M_SEL, "ether_50m_sel", ether_50m_parents,
  670. 0x540, 8, 2, 15),
  671. MUX_GATE(CLK_TOP_JPGDEC_SEL, "jpgdec_sel", jpgdec_parents, 0x540, 16, 4, 23),
  672. MUX_GATE(CLK_TOP_SPISLV_SEL, "spislv_sel", spislv_parents, 0x540, 24, 3, 31),
  673. /* CLK_CFG_15 */
  674. MUX_GATE(CLK_TOP_ETHER_50M_RMII_SEL, "ether_sel", ether_parents, 0x550, 0, 2, 7),
  675. MUX_GATE(CLK_TOP_CAM2TG_SEL, "cam2tg_sel", camtg_parents, 0x550, 8, 4, 15),
  676. MUX_GATE(CLK_TOP_DI_SEL, "di_sel", di_parents, 0x550, 16, 3, 23),
  677. MUX_GATE(CLK_TOP_TVD_SEL, "tvd_sel", tvd_parents, 0x550, 24, 2, 31),
  678. /* CLK_CFG_16 */
  679. MUX_GATE(CLK_TOP_I2C_SEL, "i2c_sel", i2c_parents, 0x560, 0, 3, 7),
  680. MUX_GATE(CLK_TOP_PWM_INFRA_SEL, "pwm_infra_sel", pwm_parents, 0x560, 8, 2, 15),
  681. MUX_GATE(CLK_TOP_MSDC0P_AES_SEL, "msdc0p_aes_sel", msdc0p_aes_parents,
  682. 0x560, 16, 2, 23),
  683. MUX_GATE(CLK_TOP_CMSYS_SEL, "cmsys_sel", cmsys_parents, 0x560, 24, 3, 31),
  684. /* CLK_CFG_17 */
  685. MUX_GATE(CLK_TOP_GCPU_SEL, "gcpu_sel", gcpu_parents, 0x570, 0, 3, 7),
  686. /* CLK_AUDDIV_4 */
  687. MUX(CLK_TOP_AUD_APLL1_SEL, "aud_apll1_sel", aud_apll1_parents, 0x134, 0, 1),
  688. MUX(CLK_TOP_AUD_APLL2_SEL, "aud_apll2_sel", aud_apll2_parents, 0x134, 1, 1),
  689. MUX(CLK_TOP_DA_AUDULL_VTX_6P5M_SEL, "audull_vtx_sel", audull_vtx_parents,
  690. 0x134, 31, 1),
  691. MUX(CLK_TOP_APLL1_REF_SEL, "apll1_ref_sel", apll1_ref_parents, 0x134, 4, 3),
  692. MUX(CLK_TOP_APLL2_REF_SEL, "apll2_ref_sel", apll1_ref_parents, 0x134, 7, 3),
  693. };
  694. static const char * const mcu_mp0_parents[] = {
  695. "clk26m",
  696. "armca35pll_ck",
  697. "f_mp0_pll1_ck",
  698. "f_mp0_pll2_ck"
  699. };
  700. static const char * const mcu_mp2_parents[] = {
  701. "clk26m",
  702. "armca72pll_ck",
  703. "f_big_pll1_ck",
  704. "f_big_pll2_ck"
  705. };
  706. static const char * const mcu_bus_parents[] = {
  707. "clk26m",
  708. "cci400_sel",
  709. "f_bus_pll1_ck",
  710. "f_bus_pll2_ck"
  711. };
  712. static struct mtk_composite mcu_muxes[] = {
  713. /* mp0_pll_divider_cfg */
  714. MUX_GATE_FLAGS(CLK_MCU_MP0_SEL, "mcu_mp0_sel", mcu_mp0_parents, 0x7A0,
  715. 9, 2, -1, CLK_IS_CRITICAL),
  716. /* mp2_pll_divider_cfg */
  717. MUX_GATE_FLAGS(CLK_MCU_MP2_SEL, "mcu_mp2_sel", mcu_mp2_parents, 0x7A8,
  718. 9, 2, -1, CLK_IS_CRITICAL),
  719. /* bus_pll_divider_cfg */
  720. MUX_GATE_FLAGS(CLK_MCU_BUS_SEL, "mcu_bus_sel", mcu_bus_parents, 0x7C0,
  721. 9, 2, -1, CLK_IS_CRITICAL),
  722. };
  723. static const struct mtk_clk_divider top_adj_divs[] = {
  724. DIV_ADJ(CLK_TOP_APLL_DIV0, "apll_div0", "i2so1_sel", 0x124, 0, 8),
  725. DIV_ADJ(CLK_TOP_APLL_DIV1, "apll_div1", "i2so2_sel", 0x124, 8, 8),
  726. DIV_ADJ(CLK_TOP_APLL_DIV2, "apll_div2", "i2so3_sel", 0x124, 16, 8),
  727. DIV_ADJ(CLK_TOP_APLL_DIV3, "apll_div3", "tdmo0_sel", 0x124, 24, 8),
  728. DIV_ADJ(CLK_TOP_APLL_DIV4, "apll_div4", "tdmo1_sel", 0x128, 0, 8),
  729. DIV_ADJ(CLK_TOP_APLL_DIV5, "apll_div5", "i2si1_sel", 0x128, 8, 8),
  730. DIV_ADJ(CLK_TOP_APLL_DIV6, "apll_div6", "i2si2_sel", 0x128, 16, 8),
  731. DIV_ADJ(CLK_TOP_APLL_DIV7, "apll_div7", "i2si3_sel", 0x128, 24, 8),
  732. };
  733. static const struct mtk_gate_regs top0_cg_regs = {
  734. .set_ofs = 0x120,
  735. .clr_ofs = 0x120,
  736. .sta_ofs = 0x120,
  737. };
  738. static const struct mtk_gate_regs top1_cg_regs = {
  739. .set_ofs = 0x424,
  740. .clr_ofs = 0x424,
  741. .sta_ofs = 0x424,
  742. };
  743. #define GATE_TOP0(_id, _name, _parent, _shift) \
  744. GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr)
  745. #define GATE_TOP1(_id, _name, _parent, _shift) \
  746. GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
  747. static const struct mtk_gate top_clks[] = {
  748. /* TOP0 */
  749. GATE_TOP0(CLK_TOP_APLL_DIV_PDN0, "apll_div_pdn0", "i2so1_sel", 0),
  750. GATE_TOP0(CLK_TOP_APLL_DIV_PDN1, "apll_div_pdn1", "i2so2_sel", 1),
  751. GATE_TOP0(CLK_TOP_APLL_DIV_PDN2, "apll_div_pdn2", "i2so3_sel", 2),
  752. GATE_TOP0(CLK_TOP_APLL_DIV_PDN3, "apll_div_pdn3", "tdmo0_sel", 3),
  753. GATE_TOP0(CLK_TOP_APLL_DIV_PDN4, "apll_div_pdn4", "tdmo1_sel", 4),
  754. GATE_TOP0(CLK_TOP_APLL_DIV_PDN5, "apll_div_pdn5", "i2si1_sel", 5),
  755. GATE_TOP0(CLK_TOP_APLL_DIV_PDN6, "apll_div_pdn6", "i2si2_sel", 6),
  756. GATE_TOP0(CLK_TOP_APLL_DIV_PDN7, "apll_div_pdn7", "i2si3_sel", 7),
  757. /* TOP1 */
  758. GATE_TOP1(CLK_TOP_NFI2X_EN, "nfi2x_en", "nfi2x_sel", 0),
  759. GATE_TOP1(CLK_TOP_NFIECC_EN, "nfiecc_en", "nfiecc_sel", 1),
  760. GATE_TOP1(CLK_TOP_NFI1X_CK_EN, "nfi1x_ck_en", "nfi2x_sel", 2),
  761. };
  762. static const struct mtk_gate_regs infra_cg_regs = {
  763. .set_ofs = 0x40,
  764. .clr_ofs = 0x44,
  765. .sta_ofs = 0x48,
  766. };
  767. #define GATE_INFRA(_id, _name, _parent, _shift) \
  768. GATE_MTK(_id, _name, _parent, &infra_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
  769. static const struct mtk_gate infra_clks[] = {
  770. GATE_INFRA(CLK_INFRA_DBGCLK, "infra_dbgclk", "axi_sel", 0),
  771. GATE_INFRA(CLK_INFRA_GCE, "infra_gce", "axi_sel", 6),
  772. GATE_INFRA(CLK_INFRA_M4U, "infra_m4u", "mem_sel", 8),
  773. GATE_INFRA(CLK_INFRA_KP, "infra_kp", "axi_sel", 16),
  774. GATE_INFRA(CLK_INFRA_AO_SPI0, "infra_ao_spi0", "spi_sel", 24),
  775. GATE_INFRA(CLK_INFRA_AO_SPI1, "infra_ao_spi1", "spislv_sel", 25),
  776. GATE_INFRA(CLK_INFRA_AO_UART5, "infra_ao_uart5", "axi_sel", 26),
  777. };
  778. static const struct mtk_gate_regs peri0_cg_regs = {
  779. .set_ofs = 0x8,
  780. .clr_ofs = 0x10,
  781. .sta_ofs = 0x18,
  782. };
  783. static const struct mtk_gate_regs peri1_cg_regs = {
  784. .set_ofs = 0xc,
  785. .clr_ofs = 0x14,
  786. .sta_ofs = 0x1c,
  787. };
  788. static const struct mtk_gate_regs peri2_cg_regs = {
  789. .set_ofs = 0x42c,
  790. .clr_ofs = 0x42c,
  791. .sta_ofs = 0x42c,
  792. };
  793. #define GATE_PERI0(_id, _name, _parent, _shift) \
  794. GATE_MTK(_id, _name, _parent, &peri0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
  795. #define GATE_PERI1(_id, _name, _parent, _shift) \
  796. GATE_MTK(_id, _name, _parent, &peri1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
  797. #define GATE_PERI2(_id, _name, _parent, _shift) \
  798. GATE_MTK(_id, _name, _parent, &peri2_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
  799. static const struct mtk_gate peri_clks[] = {
  800. /* PERI0 */
  801. GATE_PERI0(CLK_PERI_NFI, "per_nfi", "axi_sel", 0),
  802. GATE_PERI0(CLK_PERI_THERM, "per_therm", "axi_sel", 1),
  803. GATE_PERI0(CLK_PERI_PWM0, "per_pwm0", "pwm_sel", 2),
  804. GATE_PERI0(CLK_PERI_PWM1, "per_pwm1", "pwm_sel", 3),
  805. GATE_PERI0(CLK_PERI_PWM2, "per_pwm2", "pwm_sel", 4),
  806. GATE_PERI0(CLK_PERI_PWM3, "per_pwm3", "pwm_sel", 5),
  807. GATE_PERI0(CLK_PERI_PWM4, "per_pwm4", "pwm_sel", 6),
  808. GATE_PERI0(CLK_PERI_PWM5, "per_pwm5", "pwm_sel", 7),
  809. GATE_PERI0(CLK_PERI_PWM6, "per_pwm6", "pwm_sel", 8),
  810. GATE_PERI0(CLK_PERI_PWM7, "per_pwm7", "pwm_sel", 9),
  811. GATE_PERI0(CLK_PERI_PWM, "per_pwm", "pwm_sel", 10),
  812. GATE_PERI0(CLK_PERI_AP_DMA, "per_ap_dma", "axi_sel", 13),
  813. GATE_PERI0(CLK_PERI_MSDC30_0, "per_msdc30_0", "msdc50_0_sel", 14),
  814. GATE_PERI0(CLK_PERI_MSDC30_1, "per_msdc30_1", "msdc30_1_sel", 15),
  815. GATE_PERI0(CLK_PERI_MSDC30_2, "per_msdc30_2", "msdc30_2_sel", 16),
  816. GATE_PERI0(CLK_PERI_MSDC30_3, "per_msdc30_3", "msdc30_3_sel", 17),
  817. GATE_PERI0(CLK_PERI_UART0, "per_uart0", "uart_sel", 20),
  818. GATE_PERI0(CLK_PERI_UART1, "per_uart1", "uart_sel", 21),
  819. GATE_PERI0(CLK_PERI_UART2, "per_uart2", "uart_sel", 22),
  820. GATE_PERI0(CLK_PERI_UART3, "per_uart3", "uart_sel", 23),
  821. GATE_PERI0(CLK_PERI_I2C0, "per_i2c0", "axi_sel", 24),
  822. GATE_PERI0(CLK_PERI_I2C1, "per_i2c1", "axi_sel", 25),
  823. GATE_PERI0(CLK_PERI_I2C2, "per_i2c2", "axi_sel", 26),
  824. GATE_PERI0(CLK_PERI_I2C3, "per_i2c3", "axi_sel", 27),
  825. GATE_PERI0(CLK_PERI_I2C4, "per_i2c4", "axi_sel", 28),
  826. GATE_PERI0(CLK_PERI_AUXADC, "per_auxadc", "ltepll_fs26m", 29),
  827. GATE_PERI0(CLK_PERI_SPI0, "per_spi0", "spi_sel", 30),
  828. /* PERI1 */
  829. GATE_PERI1(CLK_PERI_SPI, "per_spi", "spinor_sel", 1),
  830. GATE_PERI1(CLK_PERI_I2C5, "per_i2c5", "axi_sel", 3),
  831. GATE_PERI1(CLK_PERI_SPI2, "per_spi2", "spi_sel", 5),
  832. GATE_PERI1(CLK_PERI_SPI3, "per_spi3", "spi_sel", 6),
  833. GATE_PERI1(CLK_PERI_SPI5, "per_spi5", "spi_sel", 8),
  834. GATE_PERI1(CLK_PERI_UART4, "per_uart4", "uart_sel", 9),
  835. GATE_PERI1(CLK_PERI_SFLASH, "per_sflash", "uart_sel", 11),
  836. GATE_PERI1(CLK_PERI_GMAC, "per_gmac", "uart_sel", 12),
  837. GATE_PERI1(CLK_PERI_PCIE0, "per_pcie0", "uart_sel", 14),
  838. GATE_PERI1(CLK_PERI_PCIE1, "per_pcie1", "uart_sel", 15),
  839. GATE_PERI1(CLK_PERI_GMAC_PCLK, "per_gmac_pclk", "uart_sel", 16),
  840. /* PERI2 */
  841. GATE_PERI2(CLK_PERI_MSDC50_0_EN, "per_msdc50_0_en", "msdc50_0_sel", 0),
  842. GATE_PERI2(CLK_PERI_MSDC30_1_EN, "per_msdc30_1_en", "msdc30_1_sel", 1),
  843. GATE_PERI2(CLK_PERI_MSDC30_2_EN, "per_msdc30_2_en", "msdc30_2_sel", 2),
  844. GATE_PERI2(CLK_PERI_MSDC30_3_EN, "per_msdc30_3_en", "msdc30_3_sel", 3),
  845. GATE_PERI2(CLK_PERI_MSDC50_0_HCLK_EN, "per_msdc50_0_h", "msdc50_0_h_sel", 4),
  846. GATE_PERI2(CLK_PERI_MSDC50_3_HCLK_EN, "per_msdc50_3_h", "msdc50_3_h_sel", 5),
  847. GATE_PERI2(CLK_PERI_MSDC30_0_QTR_EN, "per_msdc30_0_q", "axi_sel", 6),
  848. GATE_PERI2(CLK_PERI_MSDC30_3_QTR_EN, "per_msdc30_3_q", "mem_sel", 7),
  849. };
  850. static u16 infrasys_rst_ofs[] = { 0x30, 0x34, };
  851. static u16 pericfg_rst_ofs[] = { 0x0, 0x4, };
  852. static const struct mtk_clk_rst_desc clk_rst_desc[] = {
  853. /* infra */
  854. {
  855. .version = MTK_RST_SIMPLE,
  856. .rst_bank_ofs = infrasys_rst_ofs,
  857. .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs),
  858. },
  859. /* peri */
  860. {
  861. .version = MTK_RST_SIMPLE,
  862. .rst_bank_ofs = pericfg_rst_ofs,
  863. .rst_bank_nr = ARRAY_SIZE(pericfg_rst_ofs),
  864. },
  865. };
  866. static const struct mtk_clk_desc topck_desc = {
  867. .clks = top_clks,
  868. .num_clks = ARRAY_SIZE(top_clks),
  869. .fixed_clks = top_fixed_clks,
  870. .num_fixed_clks = ARRAY_SIZE(top_fixed_clks),
  871. .factor_clks = top_divs,
  872. .num_factor_clks = ARRAY_SIZE(top_divs),
  873. .composite_clks = top_muxes,
  874. .num_composite_clks = ARRAY_SIZE(top_muxes),
  875. .divider_clks = top_adj_divs,
  876. .num_divider_clks = ARRAY_SIZE(top_adj_divs),
  877. .clk_lock = &mt2712_clk_lock,
  878. };
  879. static const struct mtk_clk_desc mcu_desc = {
  880. .composite_clks = mcu_muxes,
  881. .num_composite_clks = ARRAY_SIZE(mcu_muxes),
  882. .clk_lock = &mt2712_clk_lock,
  883. };
  884. static const struct mtk_clk_desc infra_desc = {
  885. .clks = infra_clks,
  886. .num_clks = ARRAY_SIZE(infra_clks),
  887. .rst_desc = &clk_rst_desc[0],
  888. };
  889. static const struct mtk_clk_desc peri_desc = {
  890. .clks = peri_clks,
  891. .num_clks = ARRAY_SIZE(peri_clks),
  892. .rst_desc = &clk_rst_desc[1],
  893. };
  894. static const struct of_device_id of_match_clk_mt2712[] = {
  895. { .compatible = "mediatek,mt2712-infracfg", .data = &infra_desc },
  896. { .compatible = "mediatek,mt2712-mcucfg", .data = &mcu_desc },
  897. { .compatible = "mediatek,mt2712-pericfg", .data = &peri_desc, },
  898. { .compatible = "mediatek,mt2712-topckgen", .data = &topck_desc },
  899. { /* sentinel */ }
  900. };
  901. MODULE_DEVICE_TABLE(of, of_match_clk_mt2712);
  902. static struct platform_driver clk_mt2712_drv = {
  903. .probe = mtk_clk_simple_probe,
  904. .remove = mtk_clk_simple_remove,
  905. .driver = {
  906. .name = "clk-mt2712",
  907. .of_match_table = of_match_clk_mt2712,
  908. },
  909. };
  910. module_platform_driver(clk_mt2712_drv);
  911. MODULE_DESCRIPTION("MediaTek MT2712 main clocks driver");
  912. MODULE_LICENSE("GPL");