gcc-mdm9615.c 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755
  1. /*
  2. * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
  3. * Copyright (c) BayLibre, SAS.
  4. * Author : Neil Armstrong <narmstrong@baylibre.com>
  5. *
  6. * This software is licensed under the terms of the GNU General Public
  7. * License version 2, as published by the Free Software Foundation, and
  8. * may be copied, distributed, and modified under those terms.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/bitops.h>
  17. #include <linux/err.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/module.h>
  20. #include <linux/of.h>
  21. #include <linux/of_device.h>
  22. #include <linux/clk-provider.h>
  23. #include <linux/regmap.h>
  24. #include <linux/reset-controller.h>
  25. #include <dt-bindings/clock/qcom,gcc-mdm9615.h>
  26. #include <dt-bindings/reset/qcom,gcc-mdm9615.h>
  27. #include "common.h"
  28. #include "clk-regmap.h"
  29. #include "clk-pll.h"
  30. #include "clk-rcg.h"
  31. #include "clk-branch.h"
  32. #include "reset.h"
  33. static struct clk_fixed_factor cxo = {
  34. .mult = 1,
  35. .div = 1,
  36. .hw.init = &(struct clk_init_data){
  37. .name = "cxo",
  38. .parent_names = (const char *[]){ "cxo_board" },
  39. .num_parents = 1,
  40. .ops = &clk_fixed_factor_ops,
  41. },
  42. };
  43. static struct clk_pll pll0 = {
  44. .l_reg = 0x30c4,
  45. .m_reg = 0x30c8,
  46. .n_reg = 0x30cc,
  47. .config_reg = 0x30d4,
  48. .mode_reg = 0x30c0,
  49. .status_reg = 0x30d8,
  50. .status_bit = 16,
  51. .clkr.hw.init = &(struct clk_init_data){
  52. .name = "pll0",
  53. .parent_names = (const char *[]){ "cxo" },
  54. .num_parents = 1,
  55. .ops = &clk_pll_ops,
  56. },
  57. };
  58. static struct clk_regmap pll0_vote = {
  59. .enable_reg = 0x34c0,
  60. .enable_mask = BIT(0),
  61. .hw.init = &(struct clk_init_data){
  62. .name = "pll0_vote",
  63. .parent_names = (const char *[]){ "pll8" },
  64. .num_parents = 1,
  65. .ops = &clk_pll_vote_ops,
  66. },
  67. };
  68. static struct clk_regmap pll4_vote = {
  69. .enable_reg = 0x34c0,
  70. .enable_mask = BIT(4),
  71. .hw.init = &(struct clk_init_data){
  72. .name = "pll4_vote",
  73. .parent_names = (const char *[]){ "pll4" },
  74. .num_parents = 1,
  75. .ops = &clk_pll_vote_ops,
  76. },
  77. };
  78. static struct clk_pll pll8 = {
  79. .l_reg = 0x3144,
  80. .m_reg = 0x3148,
  81. .n_reg = 0x314c,
  82. .config_reg = 0x3154,
  83. .mode_reg = 0x3140,
  84. .status_reg = 0x3158,
  85. .status_bit = 16,
  86. .clkr.hw.init = &(struct clk_init_data){
  87. .name = "pll8",
  88. .parent_names = (const char *[]){ "cxo" },
  89. .num_parents = 1,
  90. .ops = &clk_pll_ops,
  91. },
  92. };
  93. static struct clk_regmap pll8_vote = {
  94. .enable_reg = 0x34c0,
  95. .enable_mask = BIT(8),
  96. .hw.init = &(struct clk_init_data){
  97. .name = "pll8_vote",
  98. .parent_names = (const char *[]){ "pll8" },
  99. .num_parents = 1,
  100. .ops = &clk_pll_vote_ops,
  101. },
  102. };
  103. static struct clk_pll pll14 = {
  104. .l_reg = 0x31c4,
  105. .m_reg = 0x31c8,
  106. .n_reg = 0x31cc,
  107. .config_reg = 0x31d4,
  108. .mode_reg = 0x31c0,
  109. .status_reg = 0x31d8,
  110. .status_bit = 16,
  111. .clkr.hw.init = &(struct clk_init_data){
  112. .name = "pll14",
  113. .parent_names = (const char *[]){ "cxo" },
  114. .num_parents = 1,
  115. .ops = &clk_pll_ops,
  116. },
  117. };
  118. static struct clk_regmap pll14_vote = {
  119. .enable_reg = 0x34c0,
  120. .enable_mask = BIT(11),
  121. .hw.init = &(struct clk_init_data){
  122. .name = "pll14_vote",
  123. .parent_names = (const char *[]){ "pll14" },
  124. .num_parents = 1,
  125. .ops = &clk_pll_vote_ops,
  126. },
  127. };
  128. enum {
  129. P_CXO,
  130. P_PLL8,
  131. P_PLL14,
  132. };
  133. static const struct parent_map gcc_cxo_pll8_map[] = {
  134. { P_CXO, 0 },
  135. { P_PLL8, 3 }
  136. };
  137. static const char * const gcc_cxo_pll8[] = {
  138. "cxo",
  139. "pll8_vote",
  140. };
  141. static const struct parent_map gcc_cxo_pll14_map[] = {
  142. { P_CXO, 0 },
  143. { P_PLL14, 4 }
  144. };
  145. static const char * const gcc_cxo_pll14[] = {
  146. "cxo",
  147. "pll14_vote",
  148. };
  149. static const struct parent_map gcc_cxo_map[] = {
  150. { P_CXO, 0 },
  151. };
  152. static const char * const gcc_cxo[] = {
  153. "cxo",
  154. };
  155. static struct freq_tbl clk_tbl_gsbi_uart[] = {
  156. { 1843200, P_PLL8, 2, 6, 625 },
  157. { 3686400, P_PLL8, 2, 12, 625 },
  158. { 7372800, P_PLL8, 2, 24, 625 },
  159. { 14745600, P_PLL8, 2, 48, 625 },
  160. { 16000000, P_PLL8, 4, 1, 6 },
  161. { 24000000, P_PLL8, 4, 1, 4 },
  162. { 32000000, P_PLL8, 4, 1, 3 },
  163. { 40000000, P_PLL8, 1, 5, 48 },
  164. { 46400000, P_PLL8, 1, 29, 240 },
  165. { 48000000, P_PLL8, 4, 1, 2 },
  166. { 51200000, P_PLL8, 1, 2, 15 },
  167. { 56000000, P_PLL8, 1, 7, 48 },
  168. { 58982400, P_PLL8, 1, 96, 625 },
  169. { 64000000, P_PLL8, 2, 1, 3 },
  170. { }
  171. };
  172. static struct clk_rcg gsbi1_uart_src = {
  173. .ns_reg = 0x29d4,
  174. .md_reg = 0x29d0,
  175. .mn = {
  176. .mnctr_en_bit = 8,
  177. .mnctr_reset_bit = 7,
  178. .mnctr_mode_shift = 5,
  179. .n_val_shift = 16,
  180. .m_val_shift = 16,
  181. .width = 16,
  182. },
  183. .p = {
  184. .pre_div_shift = 3,
  185. .pre_div_width = 2,
  186. },
  187. .s = {
  188. .src_sel_shift = 0,
  189. .parent_map = gcc_cxo_pll8_map,
  190. },
  191. .freq_tbl = clk_tbl_gsbi_uart,
  192. .clkr = {
  193. .enable_reg = 0x29d4,
  194. .enable_mask = BIT(11),
  195. .hw.init = &(struct clk_init_data){
  196. .name = "gsbi1_uart_src",
  197. .parent_names = gcc_cxo_pll8,
  198. .num_parents = 2,
  199. .ops = &clk_rcg_ops,
  200. .flags = CLK_SET_PARENT_GATE,
  201. },
  202. },
  203. };
  204. static struct clk_branch gsbi1_uart_clk = {
  205. .halt_reg = 0x2fcc,
  206. .halt_bit = 10,
  207. .clkr = {
  208. .enable_reg = 0x29d4,
  209. .enable_mask = BIT(9),
  210. .hw.init = &(struct clk_init_data){
  211. .name = "gsbi1_uart_clk",
  212. .parent_names = (const char *[]){
  213. "gsbi1_uart_src",
  214. },
  215. .num_parents = 1,
  216. .ops = &clk_branch_ops,
  217. .flags = CLK_SET_RATE_PARENT,
  218. },
  219. },
  220. };
  221. static struct clk_rcg gsbi2_uart_src = {
  222. .ns_reg = 0x29f4,
  223. .md_reg = 0x29f0,
  224. .mn = {
  225. .mnctr_en_bit = 8,
  226. .mnctr_reset_bit = 7,
  227. .mnctr_mode_shift = 5,
  228. .n_val_shift = 16,
  229. .m_val_shift = 16,
  230. .width = 16,
  231. },
  232. .p = {
  233. .pre_div_shift = 3,
  234. .pre_div_width = 2,
  235. },
  236. .s = {
  237. .src_sel_shift = 0,
  238. .parent_map = gcc_cxo_pll8_map,
  239. },
  240. .freq_tbl = clk_tbl_gsbi_uart,
  241. .clkr = {
  242. .enable_reg = 0x29f4,
  243. .enable_mask = BIT(11),
  244. .hw.init = &(struct clk_init_data){
  245. .name = "gsbi2_uart_src",
  246. .parent_names = gcc_cxo_pll8,
  247. .num_parents = 2,
  248. .ops = &clk_rcg_ops,
  249. .flags = CLK_SET_PARENT_GATE,
  250. },
  251. },
  252. };
  253. static struct clk_branch gsbi2_uart_clk = {
  254. .halt_reg = 0x2fcc,
  255. .halt_bit = 6,
  256. .clkr = {
  257. .enable_reg = 0x29f4,
  258. .enable_mask = BIT(9),
  259. .hw.init = &(struct clk_init_data){
  260. .name = "gsbi2_uart_clk",
  261. .parent_names = (const char *[]){
  262. "gsbi2_uart_src",
  263. },
  264. .num_parents = 1,
  265. .ops = &clk_branch_ops,
  266. .flags = CLK_SET_RATE_PARENT,
  267. },
  268. },
  269. };
  270. static struct clk_rcg gsbi3_uart_src = {
  271. .ns_reg = 0x2a14,
  272. .md_reg = 0x2a10,
  273. .mn = {
  274. .mnctr_en_bit = 8,
  275. .mnctr_reset_bit = 7,
  276. .mnctr_mode_shift = 5,
  277. .n_val_shift = 16,
  278. .m_val_shift = 16,
  279. .width = 16,
  280. },
  281. .p = {
  282. .pre_div_shift = 3,
  283. .pre_div_width = 2,
  284. },
  285. .s = {
  286. .src_sel_shift = 0,
  287. .parent_map = gcc_cxo_pll8_map,
  288. },
  289. .freq_tbl = clk_tbl_gsbi_uart,
  290. .clkr = {
  291. .enable_reg = 0x2a14,
  292. .enable_mask = BIT(11),
  293. .hw.init = &(struct clk_init_data){
  294. .name = "gsbi3_uart_src",
  295. .parent_names = gcc_cxo_pll8,
  296. .num_parents = 2,
  297. .ops = &clk_rcg_ops,
  298. .flags = CLK_SET_PARENT_GATE,
  299. },
  300. },
  301. };
  302. static struct clk_branch gsbi3_uart_clk = {
  303. .halt_reg = 0x2fcc,
  304. .halt_bit = 2,
  305. .clkr = {
  306. .enable_reg = 0x2a14,
  307. .enable_mask = BIT(9),
  308. .hw.init = &(struct clk_init_data){
  309. .name = "gsbi3_uart_clk",
  310. .parent_names = (const char *[]){
  311. "gsbi3_uart_src",
  312. },
  313. .num_parents = 1,
  314. .ops = &clk_branch_ops,
  315. .flags = CLK_SET_RATE_PARENT,
  316. },
  317. },
  318. };
  319. static struct clk_rcg gsbi4_uart_src = {
  320. .ns_reg = 0x2a34,
  321. .md_reg = 0x2a30,
  322. .mn = {
  323. .mnctr_en_bit = 8,
  324. .mnctr_reset_bit = 7,
  325. .mnctr_mode_shift = 5,
  326. .n_val_shift = 16,
  327. .m_val_shift = 16,
  328. .width = 16,
  329. },
  330. .p = {
  331. .pre_div_shift = 3,
  332. .pre_div_width = 2,
  333. },
  334. .s = {
  335. .src_sel_shift = 0,
  336. .parent_map = gcc_cxo_pll8_map,
  337. },
  338. .freq_tbl = clk_tbl_gsbi_uart,
  339. .clkr = {
  340. .enable_reg = 0x2a34,
  341. .enable_mask = BIT(11),
  342. .hw.init = &(struct clk_init_data){
  343. .name = "gsbi4_uart_src",
  344. .parent_names = gcc_cxo_pll8,
  345. .num_parents = 2,
  346. .ops = &clk_rcg_ops,
  347. .flags = CLK_SET_PARENT_GATE,
  348. },
  349. },
  350. };
  351. static struct clk_branch gsbi4_uart_clk = {
  352. .halt_reg = 0x2fd0,
  353. .halt_bit = 26,
  354. .clkr = {
  355. .enable_reg = 0x2a34,
  356. .enable_mask = BIT(9),
  357. .hw.init = &(struct clk_init_data){
  358. .name = "gsbi4_uart_clk",
  359. .parent_names = (const char *[]){
  360. "gsbi4_uart_src",
  361. },
  362. .num_parents = 1,
  363. .ops = &clk_branch_ops,
  364. .flags = CLK_SET_RATE_PARENT,
  365. },
  366. },
  367. };
  368. static struct clk_rcg gsbi5_uart_src = {
  369. .ns_reg = 0x2a54,
  370. .md_reg = 0x2a50,
  371. .mn = {
  372. .mnctr_en_bit = 8,
  373. .mnctr_reset_bit = 7,
  374. .mnctr_mode_shift = 5,
  375. .n_val_shift = 16,
  376. .m_val_shift = 16,
  377. .width = 16,
  378. },
  379. .p = {
  380. .pre_div_shift = 3,
  381. .pre_div_width = 2,
  382. },
  383. .s = {
  384. .src_sel_shift = 0,
  385. .parent_map = gcc_cxo_pll8_map,
  386. },
  387. .freq_tbl = clk_tbl_gsbi_uart,
  388. .clkr = {
  389. .enable_reg = 0x2a54,
  390. .enable_mask = BIT(11),
  391. .hw.init = &(struct clk_init_data){
  392. .name = "gsbi5_uart_src",
  393. .parent_names = gcc_cxo_pll8,
  394. .num_parents = 2,
  395. .ops = &clk_rcg_ops,
  396. .flags = CLK_SET_PARENT_GATE,
  397. },
  398. },
  399. };
  400. static struct clk_branch gsbi5_uart_clk = {
  401. .halt_reg = 0x2fd0,
  402. .halt_bit = 22,
  403. .clkr = {
  404. .enable_reg = 0x2a54,
  405. .enable_mask = BIT(9),
  406. .hw.init = &(struct clk_init_data){
  407. .name = "gsbi5_uart_clk",
  408. .parent_names = (const char *[]){
  409. "gsbi5_uart_src",
  410. },
  411. .num_parents = 1,
  412. .ops = &clk_branch_ops,
  413. .flags = CLK_SET_RATE_PARENT,
  414. },
  415. },
  416. };
  417. static struct freq_tbl clk_tbl_gsbi_qup[] = {
  418. { 960000, P_CXO, 4, 1, 5 },
  419. { 4800000, P_CXO, 4, 0, 1 },
  420. { 9600000, P_CXO, 2, 0, 1 },
  421. { 15060000, P_PLL8, 1, 2, 51 },
  422. { 24000000, P_PLL8, 4, 1, 4 },
  423. { 25600000, P_PLL8, 1, 1, 15 },
  424. { 48000000, P_PLL8, 4, 1, 2 },
  425. { 51200000, P_PLL8, 1, 2, 15 },
  426. { }
  427. };
  428. static struct clk_rcg gsbi1_qup_src = {
  429. .ns_reg = 0x29cc,
  430. .md_reg = 0x29c8,
  431. .mn = {
  432. .mnctr_en_bit = 8,
  433. .mnctr_reset_bit = 7,
  434. .mnctr_mode_shift = 5,
  435. .n_val_shift = 16,
  436. .m_val_shift = 16,
  437. .width = 8,
  438. },
  439. .p = {
  440. .pre_div_shift = 3,
  441. .pre_div_width = 2,
  442. },
  443. .s = {
  444. .src_sel_shift = 0,
  445. .parent_map = gcc_cxo_pll8_map,
  446. },
  447. .freq_tbl = clk_tbl_gsbi_qup,
  448. .clkr = {
  449. .enable_reg = 0x29cc,
  450. .enable_mask = BIT(11),
  451. .hw.init = &(struct clk_init_data){
  452. .name = "gsbi1_qup_src",
  453. .parent_names = gcc_cxo_pll8,
  454. .num_parents = 2,
  455. .ops = &clk_rcg_ops,
  456. .flags = CLK_SET_PARENT_GATE,
  457. },
  458. },
  459. };
  460. static struct clk_branch gsbi1_qup_clk = {
  461. .halt_reg = 0x2fcc,
  462. .halt_bit = 9,
  463. .clkr = {
  464. .enable_reg = 0x29cc,
  465. .enable_mask = BIT(9),
  466. .hw.init = &(struct clk_init_data){
  467. .name = "gsbi1_qup_clk",
  468. .parent_names = (const char *[]){ "gsbi1_qup_src" },
  469. .num_parents = 1,
  470. .ops = &clk_branch_ops,
  471. .flags = CLK_SET_RATE_PARENT,
  472. },
  473. },
  474. };
  475. static struct clk_rcg gsbi2_qup_src = {
  476. .ns_reg = 0x29ec,
  477. .md_reg = 0x29e8,
  478. .mn = {
  479. .mnctr_en_bit = 8,
  480. .mnctr_reset_bit = 7,
  481. .mnctr_mode_shift = 5,
  482. .n_val_shift = 16,
  483. .m_val_shift = 16,
  484. .width = 8,
  485. },
  486. .p = {
  487. .pre_div_shift = 3,
  488. .pre_div_width = 2,
  489. },
  490. .s = {
  491. .src_sel_shift = 0,
  492. .parent_map = gcc_cxo_pll8_map,
  493. },
  494. .freq_tbl = clk_tbl_gsbi_qup,
  495. .clkr = {
  496. .enable_reg = 0x29ec,
  497. .enable_mask = BIT(11),
  498. .hw.init = &(struct clk_init_data){
  499. .name = "gsbi2_qup_src",
  500. .parent_names = gcc_cxo_pll8,
  501. .num_parents = 2,
  502. .ops = &clk_rcg_ops,
  503. .flags = CLK_SET_PARENT_GATE,
  504. },
  505. },
  506. };
  507. static struct clk_branch gsbi2_qup_clk = {
  508. .halt_reg = 0x2fcc,
  509. .halt_bit = 4,
  510. .clkr = {
  511. .enable_reg = 0x29ec,
  512. .enable_mask = BIT(9),
  513. .hw.init = &(struct clk_init_data){
  514. .name = "gsbi2_qup_clk",
  515. .parent_names = (const char *[]){ "gsbi2_qup_src" },
  516. .num_parents = 1,
  517. .ops = &clk_branch_ops,
  518. .flags = CLK_SET_RATE_PARENT,
  519. },
  520. },
  521. };
  522. static struct clk_rcg gsbi3_qup_src = {
  523. .ns_reg = 0x2a0c,
  524. .md_reg = 0x2a08,
  525. .mn = {
  526. .mnctr_en_bit = 8,
  527. .mnctr_reset_bit = 7,
  528. .mnctr_mode_shift = 5,
  529. .n_val_shift = 16,
  530. .m_val_shift = 16,
  531. .width = 8,
  532. },
  533. .p = {
  534. .pre_div_shift = 3,
  535. .pre_div_width = 2,
  536. },
  537. .s = {
  538. .src_sel_shift = 0,
  539. .parent_map = gcc_cxo_pll8_map,
  540. },
  541. .freq_tbl = clk_tbl_gsbi_qup,
  542. .clkr = {
  543. .enable_reg = 0x2a0c,
  544. .enable_mask = BIT(11),
  545. .hw.init = &(struct clk_init_data){
  546. .name = "gsbi3_qup_src",
  547. .parent_names = gcc_cxo_pll8,
  548. .num_parents = 2,
  549. .ops = &clk_rcg_ops,
  550. .flags = CLK_SET_PARENT_GATE,
  551. },
  552. },
  553. };
  554. static struct clk_branch gsbi3_qup_clk = {
  555. .halt_reg = 0x2fcc,
  556. .halt_bit = 0,
  557. .clkr = {
  558. .enable_reg = 0x2a0c,
  559. .enable_mask = BIT(9),
  560. .hw.init = &(struct clk_init_data){
  561. .name = "gsbi3_qup_clk",
  562. .parent_names = (const char *[]){ "gsbi3_qup_src" },
  563. .num_parents = 1,
  564. .ops = &clk_branch_ops,
  565. .flags = CLK_SET_RATE_PARENT,
  566. },
  567. },
  568. };
  569. static struct clk_rcg gsbi4_qup_src = {
  570. .ns_reg = 0x2a2c,
  571. .md_reg = 0x2a28,
  572. .mn = {
  573. .mnctr_en_bit = 8,
  574. .mnctr_reset_bit = 7,
  575. .mnctr_mode_shift = 5,
  576. .n_val_shift = 16,
  577. .m_val_shift = 16,
  578. .width = 8,
  579. },
  580. .p = {
  581. .pre_div_shift = 3,
  582. .pre_div_width = 2,
  583. },
  584. .s = {
  585. .src_sel_shift = 0,
  586. .parent_map = gcc_cxo_pll8_map,
  587. },
  588. .freq_tbl = clk_tbl_gsbi_qup,
  589. .clkr = {
  590. .enable_reg = 0x2a2c,
  591. .enable_mask = BIT(11),
  592. .hw.init = &(struct clk_init_data){
  593. .name = "gsbi4_qup_src",
  594. .parent_names = gcc_cxo_pll8,
  595. .num_parents = 2,
  596. .ops = &clk_rcg_ops,
  597. .flags = CLK_SET_PARENT_GATE,
  598. },
  599. },
  600. };
  601. static struct clk_branch gsbi4_qup_clk = {
  602. .halt_reg = 0x2fd0,
  603. .halt_bit = 24,
  604. .clkr = {
  605. .enable_reg = 0x2a2c,
  606. .enable_mask = BIT(9),
  607. .hw.init = &(struct clk_init_data){
  608. .name = "gsbi4_qup_clk",
  609. .parent_names = (const char *[]){ "gsbi4_qup_src" },
  610. .num_parents = 1,
  611. .ops = &clk_branch_ops,
  612. .flags = CLK_SET_RATE_PARENT,
  613. },
  614. },
  615. };
  616. static struct clk_rcg gsbi5_qup_src = {
  617. .ns_reg = 0x2a4c,
  618. .md_reg = 0x2a48,
  619. .mn = {
  620. .mnctr_en_bit = 8,
  621. .mnctr_reset_bit = 7,
  622. .mnctr_mode_shift = 5,
  623. .n_val_shift = 16,
  624. .m_val_shift = 16,
  625. .width = 8,
  626. },
  627. .p = {
  628. .pre_div_shift = 3,
  629. .pre_div_width = 2,
  630. },
  631. .s = {
  632. .src_sel_shift = 0,
  633. .parent_map = gcc_cxo_pll8_map,
  634. },
  635. .freq_tbl = clk_tbl_gsbi_qup,
  636. .clkr = {
  637. .enable_reg = 0x2a4c,
  638. .enable_mask = BIT(11),
  639. .hw.init = &(struct clk_init_data){
  640. .name = "gsbi5_qup_src",
  641. .parent_names = gcc_cxo_pll8,
  642. .num_parents = 2,
  643. .ops = &clk_rcg_ops,
  644. .flags = CLK_SET_PARENT_GATE,
  645. },
  646. },
  647. };
  648. static struct clk_branch gsbi5_qup_clk = {
  649. .halt_reg = 0x2fd0,
  650. .halt_bit = 20,
  651. .clkr = {
  652. .enable_reg = 0x2a4c,
  653. .enable_mask = BIT(9),
  654. .hw.init = &(struct clk_init_data){
  655. .name = "gsbi5_qup_clk",
  656. .parent_names = (const char *[]){ "gsbi5_qup_src" },
  657. .num_parents = 1,
  658. .ops = &clk_branch_ops,
  659. .flags = CLK_SET_RATE_PARENT,
  660. },
  661. },
  662. };
  663. static const struct freq_tbl clk_tbl_gp[] = {
  664. { 9600000, P_CXO, 2, 0, 0 },
  665. { 19200000, P_CXO, 1, 0, 0 },
  666. { }
  667. };
  668. static struct clk_rcg gp0_src = {
  669. .ns_reg = 0x2d24,
  670. .md_reg = 0x2d00,
  671. .mn = {
  672. .mnctr_en_bit = 8,
  673. .mnctr_reset_bit = 7,
  674. .mnctr_mode_shift = 5,
  675. .n_val_shift = 16,
  676. .m_val_shift = 16,
  677. .width = 8,
  678. },
  679. .p = {
  680. .pre_div_shift = 3,
  681. .pre_div_width = 2,
  682. },
  683. .s = {
  684. .src_sel_shift = 0,
  685. .parent_map = gcc_cxo_map,
  686. },
  687. .freq_tbl = clk_tbl_gp,
  688. .clkr = {
  689. .enable_reg = 0x2d24,
  690. .enable_mask = BIT(11),
  691. .hw.init = &(struct clk_init_data){
  692. .name = "gp0_src",
  693. .parent_names = gcc_cxo,
  694. .num_parents = 1,
  695. .ops = &clk_rcg_ops,
  696. .flags = CLK_SET_PARENT_GATE,
  697. },
  698. }
  699. };
  700. static struct clk_branch gp0_clk = {
  701. .halt_reg = 0x2fd8,
  702. .halt_bit = 7,
  703. .clkr = {
  704. .enable_reg = 0x2d24,
  705. .enable_mask = BIT(9),
  706. .hw.init = &(struct clk_init_data){
  707. .name = "gp0_clk",
  708. .parent_names = (const char *[]){ "gp0_src" },
  709. .num_parents = 1,
  710. .ops = &clk_branch_ops,
  711. .flags = CLK_SET_RATE_PARENT,
  712. },
  713. },
  714. };
  715. static struct clk_rcg gp1_src = {
  716. .ns_reg = 0x2d44,
  717. .md_reg = 0x2d40,
  718. .mn = {
  719. .mnctr_en_bit = 8,
  720. .mnctr_reset_bit = 7,
  721. .mnctr_mode_shift = 5,
  722. .n_val_shift = 16,
  723. .m_val_shift = 16,
  724. .width = 8,
  725. },
  726. .p = {
  727. .pre_div_shift = 3,
  728. .pre_div_width = 2,
  729. },
  730. .s = {
  731. .src_sel_shift = 0,
  732. .parent_map = gcc_cxo_map,
  733. },
  734. .freq_tbl = clk_tbl_gp,
  735. .clkr = {
  736. .enable_reg = 0x2d44,
  737. .enable_mask = BIT(11),
  738. .hw.init = &(struct clk_init_data){
  739. .name = "gp1_src",
  740. .parent_names = gcc_cxo,
  741. .num_parents = 1,
  742. .ops = &clk_rcg_ops,
  743. .flags = CLK_SET_RATE_GATE,
  744. },
  745. }
  746. };
  747. static struct clk_branch gp1_clk = {
  748. .halt_reg = 0x2fd8,
  749. .halt_bit = 6,
  750. .clkr = {
  751. .enable_reg = 0x2d44,
  752. .enable_mask = BIT(9),
  753. .hw.init = &(struct clk_init_data){
  754. .name = "gp1_clk",
  755. .parent_names = (const char *[]){ "gp1_src" },
  756. .num_parents = 1,
  757. .ops = &clk_branch_ops,
  758. .flags = CLK_SET_RATE_PARENT,
  759. },
  760. },
  761. };
  762. static struct clk_rcg gp2_src = {
  763. .ns_reg = 0x2d64,
  764. .md_reg = 0x2d60,
  765. .mn = {
  766. .mnctr_en_bit = 8,
  767. .mnctr_reset_bit = 7,
  768. .mnctr_mode_shift = 5,
  769. .n_val_shift = 16,
  770. .m_val_shift = 16,
  771. .width = 8,
  772. },
  773. .p = {
  774. .pre_div_shift = 3,
  775. .pre_div_width = 2,
  776. },
  777. .s = {
  778. .src_sel_shift = 0,
  779. .parent_map = gcc_cxo_map,
  780. },
  781. .freq_tbl = clk_tbl_gp,
  782. .clkr = {
  783. .enable_reg = 0x2d64,
  784. .enable_mask = BIT(11),
  785. .hw.init = &(struct clk_init_data){
  786. .name = "gp2_src",
  787. .parent_names = gcc_cxo,
  788. .num_parents = 1,
  789. .ops = &clk_rcg_ops,
  790. .flags = CLK_SET_RATE_GATE,
  791. },
  792. }
  793. };
  794. static struct clk_branch gp2_clk = {
  795. .halt_reg = 0x2fd8,
  796. .halt_bit = 5,
  797. .clkr = {
  798. .enable_reg = 0x2d64,
  799. .enable_mask = BIT(9),
  800. .hw.init = &(struct clk_init_data){
  801. .name = "gp2_clk",
  802. .parent_names = (const char *[]){ "gp2_src" },
  803. .num_parents = 1,
  804. .ops = &clk_branch_ops,
  805. .flags = CLK_SET_RATE_PARENT,
  806. },
  807. },
  808. };
  809. static struct clk_branch pmem_clk = {
  810. .hwcg_reg = 0x25a0,
  811. .hwcg_bit = 6,
  812. .halt_reg = 0x2fc8,
  813. .halt_bit = 20,
  814. .clkr = {
  815. .enable_reg = 0x25a0,
  816. .enable_mask = BIT(4),
  817. .hw.init = &(struct clk_init_data){
  818. .name = "pmem_clk",
  819. .ops = &clk_branch_ops,
  820. },
  821. },
  822. };
  823. static struct clk_rcg prng_src = {
  824. .ns_reg = 0x2e80,
  825. .p = {
  826. .pre_div_shift = 3,
  827. .pre_div_width = 4,
  828. },
  829. .s = {
  830. .src_sel_shift = 0,
  831. .parent_map = gcc_cxo_pll8_map,
  832. },
  833. .clkr = {
  834. .hw.init = &(struct clk_init_data){
  835. .name = "prng_src",
  836. .parent_names = gcc_cxo_pll8,
  837. .num_parents = 2,
  838. .ops = &clk_rcg_ops,
  839. },
  840. },
  841. };
  842. static struct clk_branch prng_clk = {
  843. .halt_reg = 0x2fd8,
  844. .halt_check = BRANCH_HALT_VOTED,
  845. .halt_bit = 10,
  846. .clkr = {
  847. .enable_reg = 0x3080,
  848. .enable_mask = BIT(10),
  849. .hw.init = &(struct clk_init_data){
  850. .name = "prng_clk",
  851. .parent_names = (const char *[]){ "prng_src" },
  852. .num_parents = 1,
  853. .ops = &clk_branch_ops,
  854. },
  855. },
  856. };
  857. static const struct freq_tbl clk_tbl_sdc[] = {
  858. { 144000, P_CXO, 1, 1, 133 },
  859. { 400000, P_PLL8, 4, 1, 240 },
  860. { 16000000, P_PLL8, 4, 1, 6 },
  861. { 17070000, P_PLL8, 1, 2, 45 },
  862. { 20210000, P_PLL8, 1, 1, 19 },
  863. { 24000000, P_PLL8, 4, 1, 4 },
  864. { 38400000, P_PLL8, 2, 1, 5 },
  865. { 48000000, P_PLL8, 4, 1, 2 },
  866. { 64000000, P_PLL8, 3, 1, 2 },
  867. { 76800000, P_PLL8, 1, 1, 5 },
  868. { }
  869. };
  870. static struct clk_rcg sdc1_src = {
  871. .ns_reg = 0x282c,
  872. .md_reg = 0x2828,
  873. .mn = {
  874. .mnctr_en_bit = 8,
  875. .mnctr_reset_bit = 7,
  876. .mnctr_mode_shift = 5,
  877. .n_val_shift = 16,
  878. .m_val_shift = 16,
  879. .width = 8,
  880. },
  881. .p = {
  882. .pre_div_shift = 3,
  883. .pre_div_width = 2,
  884. },
  885. .s = {
  886. .src_sel_shift = 0,
  887. .parent_map = gcc_cxo_pll8_map,
  888. },
  889. .freq_tbl = clk_tbl_sdc,
  890. .clkr = {
  891. .enable_reg = 0x282c,
  892. .enable_mask = BIT(11),
  893. .hw.init = &(struct clk_init_data){
  894. .name = "sdc1_src",
  895. .parent_names = gcc_cxo_pll8,
  896. .num_parents = 2,
  897. .ops = &clk_rcg_ops,
  898. },
  899. }
  900. };
  901. static struct clk_branch sdc1_clk = {
  902. .halt_reg = 0x2fc8,
  903. .halt_bit = 6,
  904. .clkr = {
  905. .enable_reg = 0x282c,
  906. .enable_mask = BIT(9),
  907. .hw.init = &(struct clk_init_data){
  908. .name = "sdc1_clk",
  909. .parent_names = (const char *[]){ "sdc1_src" },
  910. .num_parents = 1,
  911. .ops = &clk_branch_ops,
  912. .flags = CLK_SET_RATE_PARENT,
  913. },
  914. },
  915. };
  916. static struct clk_rcg sdc2_src = {
  917. .ns_reg = 0x284c,
  918. .md_reg = 0x2848,
  919. .mn = {
  920. .mnctr_en_bit = 8,
  921. .mnctr_reset_bit = 7,
  922. .mnctr_mode_shift = 5,
  923. .n_val_shift = 16,
  924. .m_val_shift = 16,
  925. .width = 8,
  926. },
  927. .p = {
  928. .pre_div_shift = 3,
  929. .pre_div_width = 2,
  930. },
  931. .s = {
  932. .src_sel_shift = 0,
  933. .parent_map = gcc_cxo_pll8_map,
  934. },
  935. .freq_tbl = clk_tbl_sdc,
  936. .clkr = {
  937. .enable_reg = 0x284c,
  938. .enable_mask = BIT(11),
  939. .hw.init = &(struct clk_init_data){
  940. .name = "sdc2_src",
  941. .parent_names = gcc_cxo_pll8,
  942. .num_parents = 2,
  943. .ops = &clk_rcg_ops,
  944. },
  945. }
  946. };
  947. static struct clk_branch sdc2_clk = {
  948. .halt_reg = 0x2fc8,
  949. .halt_bit = 5,
  950. .clkr = {
  951. .enable_reg = 0x284c,
  952. .enable_mask = BIT(9),
  953. .hw.init = &(struct clk_init_data){
  954. .name = "sdc2_clk",
  955. .parent_names = (const char *[]){ "sdc2_src" },
  956. .num_parents = 1,
  957. .ops = &clk_branch_ops,
  958. .flags = CLK_SET_RATE_PARENT,
  959. },
  960. },
  961. };
  962. static const struct freq_tbl clk_tbl_usb[] = {
  963. { 60000000, P_PLL8, 1, 5, 32 },
  964. { }
  965. };
  966. static struct clk_rcg usb_hs1_xcvr_src = {
  967. .ns_reg = 0x290c,
  968. .md_reg = 0x2908,
  969. .mn = {
  970. .mnctr_en_bit = 8,
  971. .mnctr_reset_bit = 7,
  972. .mnctr_mode_shift = 5,
  973. .n_val_shift = 16,
  974. .m_val_shift = 16,
  975. .width = 8,
  976. },
  977. .p = {
  978. .pre_div_shift = 3,
  979. .pre_div_width = 2,
  980. },
  981. .s = {
  982. .src_sel_shift = 0,
  983. .parent_map = gcc_cxo_pll8_map,
  984. },
  985. .freq_tbl = clk_tbl_usb,
  986. .clkr = {
  987. .enable_reg = 0x290c,
  988. .enable_mask = BIT(11),
  989. .hw.init = &(struct clk_init_data){
  990. .name = "usb_hs1_xcvr_src",
  991. .parent_names = gcc_cxo_pll8,
  992. .num_parents = 2,
  993. .ops = &clk_rcg_ops,
  994. .flags = CLK_SET_RATE_GATE,
  995. },
  996. }
  997. };
  998. static struct clk_branch usb_hs1_xcvr_clk = {
  999. .halt_reg = 0x2fc8,
  1000. .halt_bit = 0,
  1001. .clkr = {
  1002. .enable_reg = 0x290c,
  1003. .enable_mask = BIT(9),
  1004. .hw.init = &(struct clk_init_data){
  1005. .name = "usb_hs1_xcvr_clk",
  1006. .parent_names = (const char *[]){ "usb_hs1_xcvr_src" },
  1007. .num_parents = 1,
  1008. .ops = &clk_branch_ops,
  1009. .flags = CLK_SET_RATE_PARENT,
  1010. },
  1011. },
  1012. };
  1013. static struct clk_rcg usb_hsic_xcvr_fs_src = {
  1014. .ns_reg = 0x2928,
  1015. .md_reg = 0x2924,
  1016. .mn = {
  1017. .mnctr_en_bit = 8,
  1018. .mnctr_reset_bit = 7,
  1019. .mnctr_mode_shift = 5,
  1020. .n_val_shift = 16,
  1021. .m_val_shift = 16,
  1022. .width = 8,
  1023. },
  1024. .p = {
  1025. .pre_div_shift = 3,
  1026. .pre_div_width = 2,
  1027. },
  1028. .s = {
  1029. .src_sel_shift = 0,
  1030. .parent_map = gcc_cxo_pll8_map,
  1031. },
  1032. .freq_tbl = clk_tbl_usb,
  1033. .clkr = {
  1034. .enable_reg = 0x2928,
  1035. .enable_mask = BIT(11),
  1036. .hw.init = &(struct clk_init_data){
  1037. .name = "usb_hsic_xcvr_fs_src",
  1038. .parent_names = gcc_cxo_pll8,
  1039. .num_parents = 2,
  1040. .ops = &clk_rcg_ops,
  1041. .flags = CLK_SET_RATE_GATE,
  1042. },
  1043. }
  1044. };
  1045. static struct clk_branch usb_hsic_xcvr_fs_clk = {
  1046. .halt_reg = 0x2fc8,
  1047. .halt_bit = 9,
  1048. .clkr = {
  1049. .enable_reg = 0x2928,
  1050. .enable_mask = BIT(9),
  1051. .hw.init = &(struct clk_init_data){
  1052. .name = "usb_hsic_xcvr_fs_clk",
  1053. .parent_names =
  1054. (const char *[]){ "usb_hsic_xcvr_fs_src" },
  1055. .num_parents = 1,
  1056. .ops = &clk_branch_ops,
  1057. .flags = CLK_SET_RATE_PARENT,
  1058. },
  1059. },
  1060. };
  1061. static const struct freq_tbl clk_tbl_usb_hs1_system[] = {
  1062. { 60000000, P_PLL8, 1, 5, 32 },
  1063. { }
  1064. };
  1065. static struct clk_rcg usb_hs1_system_src = {
  1066. .ns_reg = 0x36a4,
  1067. .md_reg = 0x36a0,
  1068. .mn = {
  1069. .mnctr_en_bit = 8,
  1070. .mnctr_reset_bit = 7,
  1071. .mnctr_mode_shift = 5,
  1072. .n_val_shift = 16,
  1073. .m_val_shift = 16,
  1074. .width = 8,
  1075. },
  1076. .p = {
  1077. .pre_div_shift = 3,
  1078. .pre_div_width = 2,
  1079. },
  1080. .s = {
  1081. .src_sel_shift = 0,
  1082. .parent_map = gcc_cxo_pll8_map,
  1083. },
  1084. .freq_tbl = clk_tbl_usb_hs1_system,
  1085. .clkr = {
  1086. .enable_reg = 0x36a4,
  1087. .enable_mask = BIT(11),
  1088. .hw.init = &(struct clk_init_data){
  1089. .name = "usb_hs1_system_src",
  1090. .parent_names = gcc_cxo_pll8,
  1091. .num_parents = 2,
  1092. .ops = &clk_rcg_ops,
  1093. .flags = CLK_SET_RATE_GATE,
  1094. },
  1095. }
  1096. };
  1097. static struct clk_branch usb_hs1_system_clk = {
  1098. .halt_reg = 0x2fc8,
  1099. .halt_bit = 4,
  1100. .clkr = {
  1101. .enable_reg = 0x36a4,
  1102. .enable_mask = BIT(9),
  1103. .hw.init = &(struct clk_init_data){
  1104. .parent_names =
  1105. (const char *[]){ "usb_hs1_system_src" },
  1106. .num_parents = 1,
  1107. .name = "usb_hs1_system_clk",
  1108. .ops = &clk_branch_ops,
  1109. .flags = CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
  1110. },
  1111. },
  1112. };
  1113. static const struct freq_tbl clk_tbl_usb_hsic_system[] = {
  1114. { 64000000, P_PLL8, 1, 1, 6 },
  1115. { }
  1116. };
  1117. static struct clk_rcg usb_hsic_system_src = {
  1118. .ns_reg = 0x2b58,
  1119. .md_reg = 0x2b54,
  1120. .mn = {
  1121. .mnctr_en_bit = 8,
  1122. .mnctr_reset_bit = 7,
  1123. .mnctr_mode_shift = 5,
  1124. .n_val_shift = 16,
  1125. .m_val_shift = 16,
  1126. .width = 8,
  1127. },
  1128. .p = {
  1129. .pre_div_shift = 3,
  1130. .pre_div_width = 2,
  1131. },
  1132. .s = {
  1133. .src_sel_shift = 0,
  1134. .parent_map = gcc_cxo_pll8_map,
  1135. },
  1136. .freq_tbl = clk_tbl_usb_hsic_system,
  1137. .clkr = {
  1138. .enable_reg = 0x2b58,
  1139. .enable_mask = BIT(11),
  1140. .hw.init = &(struct clk_init_data){
  1141. .name = "usb_hsic_system_src",
  1142. .parent_names = gcc_cxo_pll8,
  1143. .num_parents = 2,
  1144. .ops = &clk_rcg_ops,
  1145. .flags = CLK_SET_RATE_GATE,
  1146. },
  1147. }
  1148. };
  1149. static struct clk_branch usb_hsic_system_clk = {
  1150. .halt_reg = 0x2fc8,
  1151. .halt_bit = 7,
  1152. .clkr = {
  1153. .enable_reg = 0x2b58,
  1154. .enable_mask = BIT(9),
  1155. .hw.init = &(struct clk_init_data){
  1156. .parent_names =
  1157. (const char *[]){ "usb_hsic_system_src" },
  1158. .num_parents = 1,
  1159. .name = "usb_hsic_system_clk",
  1160. .ops = &clk_branch_ops,
  1161. .flags = CLK_SET_RATE_PARENT,
  1162. },
  1163. },
  1164. };
  1165. static const struct freq_tbl clk_tbl_usb_hsic_hsic[] = {
  1166. { 48000000, P_PLL14, 1, 0, 0 },
  1167. { }
  1168. };
  1169. static struct clk_rcg usb_hsic_hsic_src = {
  1170. .ns_reg = 0x2b50,
  1171. .md_reg = 0x2b4c,
  1172. .mn = {
  1173. .mnctr_en_bit = 8,
  1174. .mnctr_reset_bit = 7,
  1175. .mnctr_mode_shift = 5,
  1176. .n_val_shift = 16,
  1177. .m_val_shift = 16,
  1178. .width = 8,
  1179. },
  1180. .p = {
  1181. .pre_div_shift = 3,
  1182. .pre_div_width = 2,
  1183. },
  1184. .s = {
  1185. .src_sel_shift = 0,
  1186. .parent_map = gcc_cxo_pll14_map,
  1187. },
  1188. .freq_tbl = clk_tbl_usb_hsic_hsic,
  1189. .clkr = {
  1190. .enable_reg = 0x2b50,
  1191. .enable_mask = BIT(11),
  1192. .hw.init = &(struct clk_init_data){
  1193. .name = "usb_hsic_hsic_src",
  1194. .parent_names = gcc_cxo_pll14,
  1195. .num_parents = 2,
  1196. .ops = &clk_rcg_ops,
  1197. .flags = CLK_SET_RATE_GATE,
  1198. },
  1199. }
  1200. };
  1201. static struct clk_branch usb_hsic_hsic_clk = {
  1202. .halt_check = BRANCH_HALT_DELAY,
  1203. .clkr = {
  1204. .enable_reg = 0x2b50,
  1205. .enable_mask = BIT(9),
  1206. .hw.init = &(struct clk_init_data){
  1207. .parent_names = (const char *[]){ "usb_hsic_hsic_src" },
  1208. .num_parents = 1,
  1209. .name = "usb_hsic_hsic_clk",
  1210. .ops = &clk_branch_ops,
  1211. .flags = CLK_SET_RATE_PARENT,
  1212. },
  1213. },
  1214. };
  1215. static struct clk_branch usb_hsic_hsio_cal_clk = {
  1216. .halt_reg = 0x2fc8,
  1217. .halt_bit = 8,
  1218. .clkr = {
  1219. .enable_reg = 0x2b48,
  1220. .enable_mask = BIT(0),
  1221. .hw.init = &(struct clk_init_data){
  1222. .parent_names = (const char *[]){ "cxo" },
  1223. .num_parents = 1,
  1224. .name = "usb_hsic_hsio_cal_clk",
  1225. .ops = &clk_branch_ops,
  1226. },
  1227. },
  1228. };
  1229. static struct clk_branch ce1_core_clk = {
  1230. .hwcg_reg = 0x2724,
  1231. .hwcg_bit = 6,
  1232. .halt_reg = 0x2fd4,
  1233. .halt_bit = 27,
  1234. .clkr = {
  1235. .enable_reg = 0x2724,
  1236. .enable_mask = BIT(4),
  1237. .hw.init = &(struct clk_init_data){
  1238. .name = "ce1_core_clk",
  1239. .ops = &clk_branch_ops,
  1240. },
  1241. },
  1242. };
  1243. static struct clk_branch ce1_h_clk = {
  1244. .halt_reg = 0x2fd4,
  1245. .halt_bit = 1,
  1246. .clkr = {
  1247. .enable_reg = 0x2720,
  1248. .enable_mask = BIT(4),
  1249. .hw.init = &(struct clk_init_data){
  1250. .name = "ce1_h_clk",
  1251. .ops = &clk_branch_ops,
  1252. },
  1253. },
  1254. };
  1255. static struct clk_branch dma_bam_h_clk = {
  1256. .hwcg_reg = 0x25c0,
  1257. .hwcg_bit = 6,
  1258. .halt_reg = 0x2fc8,
  1259. .halt_bit = 12,
  1260. .clkr = {
  1261. .enable_reg = 0x25c0,
  1262. .enable_mask = BIT(4),
  1263. .hw.init = &(struct clk_init_data){
  1264. .name = "dma_bam_h_clk",
  1265. .ops = &clk_branch_ops,
  1266. },
  1267. },
  1268. };
  1269. static struct clk_branch gsbi1_h_clk = {
  1270. .hwcg_reg = 0x29c0,
  1271. .hwcg_bit = 6,
  1272. .halt_reg = 0x2fcc,
  1273. .halt_bit = 11,
  1274. .clkr = {
  1275. .enable_reg = 0x29c0,
  1276. .enable_mask = BIT(4),
  1277. .hw.init = &(struct clk_init_data){
  1278. .name = "gsbi1_h_clk",
  1279. .ops = &clk_branch_ops,
  1280. },
  1281. },
  1282. };
  1283. static struct clk_branch gsbi2_h_clk = {
  1284. .hwcg_reg = 0x29e0,
  1285. .hwcg_bit = 6,
  1286. .halt_reg = 0x2fcc,
  1287. .halt_bit = 7,
  1288. .clkr = {
  1289. .enable_reg = 0x29e0,
  1290. .enable_mask = BIT(4),
  1291. .hw.init = &(struct clk_init_data){
  1292. .name = "gsbi2_h_clk",
  1293. .ops = &clk_branch_ops,
  1294. },
  1295. },
  1296. };
  1297. static struct clk_branch gsbi3_h_clk = {
  1298. .hwcg_reg = 0x2a00,
  1299. .hwcg_bit = 6,
  1300. .halt_reg = 0x2fcc,
  1301. .halt_bit = 3,
  1302. .clkr = {
  1303. .enable_reg = 0x2a00,
  1304. .enable_mask = BIT(4),
  1305. .hw.init = &(struct clk_init_data){
  1306. .name = "gsbi3_h_clk",
  1307. .ops = &clk_branch_ops,
  1308. },
  1309. },
  1310. };
  1311. static struct clk_branch gsbi4_h_clk = {
  1312. .hwcg_reg = 0x2a20,
  1313. .hwcg_bit = 6,
  1314. .halt_reg = 0x2fd0,
  1315. .halt_bit = 27,
  1316. .clkr = {
  1317. .enable_reg = 0x2a20,
  1318. .enable_mask = BIT(4),
  1319. .hw.init = &(struct clk_init_data){
  1320. .name = "gsbi4_h_clk",
  1321. .ops = &clk_branch_ops,
  1322. },
  1323. },
  1324. };
  1325. static struct clk_branch gsbi5_h_clk = {
  1326. .hwcg_reg = 0x2a40,
  1327. .hwcg_bit = 6,
  1328. .halt_reg = 0x2fd0,
  1329. .halt_bit = 23,
  1330. .clkr = {
  1331. .enable_reg = 0x2a40,
  1332. .enable_mask = BIT(4),
  1333. .hw.init = &(struct clk_init_data){
  1334. .name = "gsbi5_h_clk",
  1335. .ops = &clk_branch_ops,
  1336. },
  1337. },
  1338. };
  1339. static struct clk_branch usb_hs1_h_clk = {
  1340. .hwcg_reg = 0x2900,
  1341. .hwcg_bit = 6,
  1342. .halt_reg = 0x2fc8,
  1343. .halt_bit = 1,
  1344. .clkr = {
  1345. .enable_reg = 0x2900,
  1346. .enable_mask = BIT(4),
  1347. .hw.init = &(struct clk_init_data){
  1348. .name = "usb_hs1_h_clk",
  1349. .ops = &clk_branch_ops,
  1350. },
  1351. },
  1352. };
  1353. static struct clk_branch usb_hsic_h_clk = {
  1354. .halt_reg = 0x2fcc,
  1355. .halt_bit = 28,
  1356. .clkr = {
  1357. .enable_reg = 0x2920,
  1358. .enable_mask = BIT(4),
  1359. .hw.init = &(struct clk_init_data){
  1360. .name = "usb_hsic_h_clk",
  1361. .ops = &clk_branch_ops,
  1362. },
  1363. },
  1364. };
  1365. static struct clk_branch sdc1_h_clk = {
  1366. .hwcg_reg = 0x2820,
  1367. .hwcg_bit = 6,
  1368. .halt_reg = 0x2fc8,
  1369. .halt_bit = 11,
  1370. .clkr = {
  1371. .enable_reg = 0x2820,
  1372. .enable_mask = BIT(4),
  1373. .hw.init = &(struct clk_init_data){
  1374. .name = "sdc1_h_clk",
  1375. .ops = &clk_branch_ops,
  1376. },
  1377. },
  1378. };
  1379. static struct clk_branch sdc2_h_clk = {
  1380. .hwcg_reg = 0x2840,
  1381. .hwcg_bit = 6,
  1382. .halt_reg = 0x2fc8,
  1383. .halt_bit = 10,
  1384. .clkr = {
  1385. .enable_reg = 0x2840,
  1386. .enable_mask = BIT(4),
  1387. .hw.init = &(struct clk_init_data){
  1388. .name = "sdc2_h_clk",
  1389. .ops = &clk_branch_ops,
  1390. },
  1391. },
  1392. };
  1393. static struct clk_branch adm0_clk = {
  1394. .halt_reg = 0x2fdc,
  1395. .halt_check = BRANCH_HALT_VOTED,
  1396. .halt_bit = 14,
  1397. .clkr = {
  1398. .enable_reg = 0x3080,
  1399. .enable_mask = BIT(2),
  1400. .hw.init = &(struct clk_init_data){
  1401. .name = "adm0_clk",
  1402. .ops = &clk_branch_ops,
  1403. },
  1404. },
  1405. };
  1406. static struct clk_branch adm0_pbus_clk = {
  1407. .hwcg_reg = 0x2208,
  1408. .hwcg_bit = 6,
  1409. .halt_reg = 0x2fdc,
  1410. .halt_check = BRANCH_HALT_VOTED,
  1411. .halt_bit = 13,
  1412. .clkr = {
  1413. .enable_reg = 0x3080,
  1414. .enable_mask = BIT(3),
  1415. .hw.init = &(struct clk_init_data){
  1416. .name = "adm0_pbus_clk",
  1417. .ops = &clk_branch_ops,
  1418. },
  1419. },
  1420. };
  1421. static struct clk_branch pmic_arb0_h_clk = {
  1422. .halt_reg = 0x2fd8,
  1423. .halt_check = BRANCH_HALT_VOTED,
  1424. .halt_bit = 22,
  1425. .clkr = {
  1426. .enable_reg = 0x3080,
  1427. .enable_mask = BIT(8),
  1428. .hw.init = &(struct clk_init_data){
  1429. .name = "pmic_arb0_h_clk",
  1430. .ops = &clk_branch_ops,
  1431. },
  1432. },
  1433. };
  1434. static struct clk_branch pmic_arb1_h_clk = {
  1435. .halt_reg = 0x2fd8,
  1436. .halt_check = BRANCH_HALT_VOTED,
  1437. .halt_bit = 21,
  1438. .clkr = {
  1439. .enable_reg = 0x3080,
  1440. .enable_mask = BIT(9),
  1441. .hw.init = &(struct clk_init_data){
  1442. .name = "pmic_arb1_h_clk",
  1443. .ops = &clk_branch_ops,
  1444. },
  1445. },
  1446. };
  1447. static struct clk_branch pmic_ssbi2_clk = {
  1448. .halt_reg = 0x2fd8,
  1449. .halt_check = BRANCH_HALT_VOTED,
  1450. .halt_bit = 23,
  1451. .clkr = {
  1452. .enable_reg = 0x3080,
  1453. .enable_mask = BIT(7),
  1454. .hw.init = &(struct clk_init_data){
  1455. .name = "pmic_ssbi2_clk",
  1456. .ops = &clk_branch_ops,
  1457. },
  1458. },
  1459. };
  1460. static struct clk_branch rpm_msg_ram_h_clk = {
  1461. .hwcg_reg = 0x27e0,
  1462. .hwcg_bit = 6,
  1463. .halt_reg = 0x2fd8,
  1464. .halt_check = BRANCH_HALT_VOTED,
  1465. .halt_bit = 12,
  1466. .clkr = {
  1467. .enable_reg = 0x3080,
  1468. .enable_mask = BIT(6),
  1469. .hw.init = &(struct clk_init_data){
  1470. .name = "rpm_msg_ram_h_clk",
  1471. .ops = &clk_branch_ops,
  1472. },
  1473. },
  1474. };
  1475. static struct clk_branch ebi2_clk = {
  1476. .hwcg_reg = 0x2664,
  1477. .hwcg_bit = 6,
  1478. .halt_reg = 0x2fcc,
  1479. .halt_bit = 24,
  1480. .clkr = {
  1481. .enable_reg = 0x2664,
  1482. .enable_mask = BIT(6) | BIT(4),
  1483. .hw.init = &(struct clk_init_data){
  1484. .name = "ebi2_clk",
  1485. .ops = &clk_branch_ops,
  1486. },
  1487. },
  1488. };
  1489. static struct clk_branch ebi2_aon_clk = {
  1490. .halt_reg = 0x2fcc,
  1491. .halt_bit = 23,
  1492. .clkr = {
  1493. .enable_reg = 0x2664,
  1494. .enable_mask = BIT(8),
  1495. .hw.init = &(struct clk_init_data){
  1496. .name = "ebi2_aon_clk",
  1497. .ops = &clk_branch_ops,
  1498. },
  1499. },
  1500. };
  1501. static struct clk_hw *gcc_mdm9615_hws[] = {
  1502. &cxo.hw,
  1503. };
  1504. static struct clk_regmap *gcc_mdm9615_clks[] = {
  1505. [PLL0] = &pll0.clkr,
  1506. [PLL0_VOTE] = &pll0_vote,
  1507. [PLL4_VOTE] = &pll4_vote,
  1508. [PLL8] = &pll8.clkr,
  1509. [PLL8_VOTE] = &pll8_vote,
  1510. [PLL14] = &pll14.clkr,
  1511. [PLL14_VOTE] = &pll14_vote,
  1512. [GSBI1_UART_SRC] = &gsbi1_uart_src.clkr,
  1513. [GSBI1_UART_CLK] = &gsbi1_uart_clk.clkr,
  1514. [GSBI2_UART_SRC] = &gsbi2_uart_src.clkr,
  1515. [GSBI2_UART_CLK] = &gsbi2_uart_clk.clkr,
  1516. [GSBI3_UART_SRC] = &gsbi3_uart_src.clkr,
  1517. [GSBI3_UART_CLK] = &gsbi3_uart_clk.clkr,
  1518. [GSBI4_UART_SRC] = &gsbi4_uart_src.clkr,
  1519. [GSBI4_UART_CLK] = &gsbi4_uart_clk.clkr,
  1520. [GSBI5_UART_SRC] = &gsbi5_uart_src.clkr,
  1521. [GSBI5_UART_CLK] = &gsbi5_uart_clk.clkr,
  1522. [GSBI1_QUP_SRC] = &gsbi1_qup_src.clkr,
  1523. [GSBI1_QUP_CLK] = &gsbi1_qup_clk.clkr,
  1524. [GSBI2_QUP_SRC] = &gsbi2_qup_src.clkr,
  1525. [GSBI2_QUP_CLK] = &gsbi2_qup_clk.clkr,
  1526. [GSBI3_QUP_SRC] = &gsbi3_qup_src.clkr,
  1527. [GSBI3_QUP_CLK] = &gsbi3_qup_clk.clkr,
  1528. [GSBI4_QUP_SRC] = &gsbi4_qup_src.clkr,
  1529. [GSBI4_QUP_CLK] = &gsbi4_qup_clk.clkr,
  1530. [GSBI5_QUP_SRC] = &gsbi5_qup_src.clkr,
  1531. [GSBI5_QUP_CLK] = &gsbi5_qup_clk.clkr,
  1532. [GP0_SRC] = &gp0_src.clkr,
  1533. [GP0_CLK] = &gp0_clk.clkr,
  1534. [GP1_SRC] = &gp1_src.clkr,
  1535. [GP1_CLK] = &gp1_clk.clkr,
  1536. [GP2_SRC] = &gp2_src.clkr,
  1537. [GP2_CLK] = &gp2_clk.clkr,
  1538. [PMEM_A_CLK] = &pmem_clk.clkr,
  1539. [PRNG_SRC] = &prng_src.clkr,
  1540. [PRNG_CLK] = &prng_clk.clkr,
  1541. [SDC1_SRC] = &sdc1_src.clkr,
  1542. [SDC1_CLK] = &sdc1_clk.clkr,
  1543. [SDC2_SRC] = &sdc2_src.clkr,
  1544. [SDC2_CLK] = &sdc2_clk.clkr,
  1545. [USB_HS1_XCVR_SRC] = &usb_hs1_xcvr_src.clkr,
  1546. [USB_HS1_XCVR_CLK] = &usb_hs1_xcvr_clk.clkr,
  1547. [USB_HS1_SYSTEM_CLK_SRC] = &usb_hs1_system_src.clkr,
  1548. [USB_HS1_SYSTEM_CLK] = &usb_hs1_system_clk.clkr,
  1549. [USB_HSIC_XCVR_FS_SRC] = &usb_hsic_xcvr_fs_src.clkr,
  1550. [USB_HSIC_XCVR_FS_CLK] = &usb_hsic_xcvr_fs_clk.clkr,
  1551. [USB_HSIC_SYSTEM_CLK_SRC] = &usb_hsic_system_src.clkr,
  1552. [USB_HSIC_SYSTEM_CLK] = &usb_hsic_system_clk.clkr,
  1553. [USB_HSIC_HSIC_CLK_SRC] = &usb_hsic_hsic_src.clkr,
  1554. [USB_HSIC_HSIC_CLK] = &usb_hsic_hsic_clk.clkr,
  1555. [USB_HSIC_HSIO_CAL_CLK] = &usb_hsic_hsio_cal_clk.clkr,
  1556. [CE1_CORE_CLK] = &ce1_core_clk.clkr,
  1557. [CE1_H_CLK] = &ce1_h_clk.clkr,
  1558. [DMA_BAM_H_CLK] = &dma_bam_h_clk.clkr,
  1559. [GSBI1_H_CLK] = &gsbi1_h_clk.clkr,
  1560. [GSBI2_H_CLK] = &gsbi2_h_clk.clkr,
  1561. [GSBI3_H_CLK] = &gsbi3_h_clk.clkr,
  1562. [GSBI4_H_CLK] = &gsbi4_h_clk.clkr,
  1563. [GSBI5_H_CLK] = &gsbi5_h_clk.clkr,
  1564. [USB_HS1_H_CLK] = &usb_hs1_h_clk.clkr,
  1565. [USB_HSIC_H_CLK] = &usb_hsic_h_clk.clkr,
  1566. [SDC1_H_CLK] = &sdc1_h_clk.clkr,
  1567. [SDC2_H_CLK] = &sdc2_h_clk.clkr,
  1568. [ADM0_CLK] = &adm0_clk.clkr,
  1569. [ADM0_PBUS_CLK] = &adm0_pbus_clk.clkr,
  1570. [PMIC_ARB0_H_CLK] = &pmic_arb0_h_clk.clkr,
  1571. [PMIC_ARB1_H_CLK] = &pmic_arb1_h_clk.clkr,
  1572. [PMIC_SSBI2_CLK] = &pmic_ssbi2_clk.clkr,
  1573. [RPM_MSG_RAM_H_CLK] = &rpm_msg_ram_h_clk.clkr,
  1574. [EBI2_CLK] = &ebi2_clk.clkr,
  1575. [EBI2_AON_CLK] = &ebi2_aon_clk.clkr,
  1576. };
  1577. static const struct qcom_reset_map gcc_mdm9615_resets[] = {
  1578. [DMA_BAM_RESET] = { 0x25c0, 7 },
  1579. [CE1_H_RESET] = { 0x2720, 7 },
  1580. [CE1_CORE_RESET] = { 0x2724, 7 },
  1581. [SDC1_RESET] = { 0x2830 },
  1582. [SDC2_RESET] = { 0x2850 },
  1583. [ADM0_C2_RESET] = { 0x220c, 4 },
  1584. [ADM0_C1_RESET] = { 0x220c, 3 },
  1585. [ADM0_C0_RESET] = { 0x220c, 2 },
  1586. [ADM0_PBUS_RESET] = { 0x220c, 1 },
  1587. [ADM0_RESET] = { 0x220c },
  1588. [USB_HS1_RESET] = { 0x2910 },
  1589. [USB_HSIC_RESET] = { 0x2934 },
  1590. [GSBI1_RESET] = { 0x29dc },
  1591. [GSBI2_RESET] = { 0x29fc },
  1592. [GSBI3_RESET] = { 0x2a1c },
  1593. [GSBI4_RESET] = { 0x2a3c },
  1594. [GSBI5_RESET] = { 0x2a5c },
  1595. [PDM_RESET] = { 0x2CC0, 12 },
  1596. };
  1597. static const struct regmap_config gcc_mdm9615_regmap_config = {
  1598. .reg_bits = 32,
  1599. .reg_stride = 4,
  1600. .val_bits = 32,
  1601. .max_register = 0x3660,
  1602. .fast_io = true,
  1603. };
  1604. static const struct qcom_cc_desc gcc_mdm9615_desc = {
  1605. .config = &gcc_mdm9615_regmap_config,
  1606. .clks = gcc_mdm9615_clks,
  1607. .num_clks = ARRAY_SIZE(gcc_mdm9615_clks),
  1608. .resets = gcc_mdm9615_resets,
  1609. .num_resets = ARRAY_SIZE(gcc_mdm9615_resets),
  1610. };
  1611. static const struct of_device_id gcc_mdm9615_match_table[] = {
  1612. { .compatible = "qcom,gcc-mdm9615" },
  1613. { }
  1614. };
  1615. MODULE_DEVICE_TABLE(of, gcc_mdm9615_match_table);
  1616. static int gcc_mdm9615_probe(struct platform_device *pdev)
  1617. {
  1618. struct device *dev = &pdev->dev;
  1619. struct regmap *regmap;
  1620. int ret;
  1621. int i;
  1622. regmap = qcom_cc_map(pdev, &gcc_mdm9615_desc);
  1623. if (IS_ERR(regmap))
  1624. return PTR_ERR(regmap);
  1625. for (i = 0; i < ARRAY_SIZE(gcc_mdm9615_hws); i++) {
  1626. ret = devm_clk_hw_register(dev, gcc_mdm9615_hws[i]);
  1627. if (ret)
  1628. return ret;
  1629. }
  1630. return qcom_cc_really_probe(pdev, &gcc_mdm9615_desc, regmap);
  1631. }
  1632. static struct platform_driver gcc_mdm9615_driver = {
  1633. .probe = gcc_mdm9615_probe,
  1634. .driver = {
  1635. .name = "gcc-mdm9615",
  1636. .of_match_table = gcc_mdm9615_match_table,
  1637. },
  1638. };
  1639. static int __init gcc_mdm9615_init(void)
  1640. {
  1641. return platform_driver_register(&gcc_mdm9615_driver);
  1642. }
  1643. core_initcall(gcc_mdm9615_init);
  1644. static void __exit gcc_mdm9615_exit(void)
  1645. {
  1646. platform_driver_unregister(&gcc_mdm9615_driver);
  1647. }
  1648. module_exit(gcc_mdm9615_exit);
  1649. MODULE_DESCRIPTION("QCOM GCC MDM9615 Driver");
  1650. MODULE_LICENSE("GPL v2");
  1651. MODULE_ALIAS("platform:gcc-mdm9615");