clk-atlas7.c 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683
  1. /*
  2. * Clock tree for CSR SiRFAtlas7
  3. *
  4. * Copyright (c) 2014 Cambridge Silicon Radio Limited, a CSR plc group company.
  5. *
  6. * Licensed under GPLv2 or later.
  7. */
  8. #include <linux/bitops.h>
  9. #include <linux/io.h>
  10. #include <linux/clk-provider.h>
  11. #include <linux/delay.h>
  12. #include <linux/of_address.h>
  13. #include <linux/reset-controller.h>
  14. #include <linux/slab.h>
  15. #define SIRFSOC_CLKC_MEMPLL_AB_FREQ 0x0000
  16. #define SIRFSOC_CLKC_MEMPLL_AB_SSC 0x0004
  17. #define SIRFSOC_CLKC_MEMPLL_AB_CTRL0 0x0008
  18. #define SIRFSOC_CLKC_MEMPLL_AB_CTRL1 0x000c
  19. #define SIRFSOC_CLKC_MEMPLL_AB_STATUS 0x0010
  20. #define SIRFSOC_CLKC_MEMPLL_AB_SSRAM_ADDR 0x0014
  21. #define SIRFSOC_CLKC_MEMPLL_AB_SSRAM_DATA 0x0018
  22. #define SIRFSOC_CLKC_CPUPLL_AB_FREQ 0x001c
  23. #define SIRFSOC_CLKC_CPUPLL_AB_SSC 0x0020
  24. #define SIRFSOC_CLKC_CPUPLL_AB_CTRL0 0x0024
  25. #define SIRFSOC_CLKC_CPUPLL_AB_CTRL1 0x0028
  26. #define SIRFSOC_CLKC_CPUPLL_AB_STATUS 0x002c
  27. #define SIRFSOC_CLKC_SYS0PLL_AB_FREQ 0x0030
  28. #define SIRFSOC_CLKC_SYS0PLL_AB_SSC 0x0034
  29. #define SIRFSOC_CLKC_SYS0PLL_AB_CTRL0 0x0038
  30. #define SIRFSOC_CLKC_SYS0PLL_AB_CTRL1 0x003c
  31. #define SIRFSOC_CLKC_SYS0PLL_AB_STATUS 0x0040
  32. #define SIRFSOC_CLKC_SYS1PLL_AB_FREQ 0x0044
  33. #define SIRFSOC_CLKC_SYS1PLL_AB_SSC 0x0048
  34. #define SIRFSOC_CLKC_SYS1PLL_AB_CTRL0 0x004c
  35. #define SIRFSOC_CLKC_SYS1PLL_AB_CTRL1 0x0050
  36. #define SIRFSOC_CLKC_SYS1PLL_AB_STATUS 0x0054
  37. #define SIRFSOC_CLKC_SYS2PLL_AB_FREQ 0x0058
  38. #define SIRFSOC_CLKC_SYS2PLL_AB_SSC 0x005c
  39. #define SIRFSOC_CLKC_SYS2PLL_AB_CTRL0 0x0060
  40. #define SIRFSOC_CLKC_SYS2PLL_AB_CTRL1 0x0064
  41. #define SIRFSOC_CLKC_SYS2PLL_AB_STATUS 0x0068
  42. #define SIRFSOC_CLKC_SYS3PLL_AB_FREQ 0x006c
  43. #define SIRFSOC_CLKC_SYS3PLL_AB_SSC 0x0070
  44. #define SIRFSOC_CLKC_SYS3PLL_AB_CTRL0 0x0074
  45. #define SIRFSOC_CLKC_SYS3PLL_AB_CTRL1 0x0078
  46. #define SIRFSOC_CLKC_SYS3PLL_AB_STATUS 0x007c
  47. #define SIRFSOC_ABPLL_CTRL0_SSEN 0x00001000
  48. #define SIRFSOC_ABPLL_CTRL0_BYPASS 0x00000010
  49. #define SIRFSOC_ABPLL_CTRL0_RESET 0x00000001
  50. #define SIRFSOC_CLKC_AUDIO_DTO_INC 0x0088
  51. #define SIRFSOC_CLKC_DISP0_DTO_INC 0x008c
  52. #define SIRFSOC_CLKC_DISP1_DTO_INC 0x0090
  53. #define SIRFSOC_CLKC_AUDIO_DTO_SRC 0x0094
  54. #define SIRFSOC_CLKC_AUDIO_DTO_ENA 0x0098
  55. #define SIRFSOC_CLKC_AUDIO_DTO_DROFF 0x009c
  56. #define SIRFSOC_CLKC_DISP0_DTO_SRC 0x00a0
  57. #define SIRFSOC_CLKC_DISP0_DTO_ENA 0x00a4
  58. #define SIRFSOC_CLKC_DISP0_DTO_DROFF 0x00a8
  59. #define SIRFSOC_CLKC_DISP1_DTO_SRC 0x00ac
  60. #define SIRFSOC_CLKC_DISP1_DTO_ENA 0x00b0
  61. #define SIRFSOC_CLKC_DISP1_DTO_DROFF 0x00b4
  62. #define SIRFSOC_CLKC_I2S_CLK_SEL 0x00b8
  63. #define SIRFSOC_CLKC_I2S_SEL_STAT 0x00bc
  64. #define SIRFSOC_CLKC_USBPHY_CLKDIV_CFG 0x00c0
  65. #define SIRFSOC_CLKC_USBPHY_CLKDIV_ENA 0x00c4
  66. #define SIRFSOC_CLKC_USBPHY_CLK_SEL 0x00c8
  67. #define SIRFSOC_CLKC_USBPHY_CLK_SEL_STAT 0x00cc
  68. #define SIRFSOC_CLKC_BTSS_CLKDIV_CFG 0x00d0
  69. #define SIRFSOC_CLKC_BTSS_CLKDIV_ENA 0x00d4
  70. #define SIRFSOC_CLKC_BTSS_CLK_SEL 0x00d8
  71. #define SIRFSOC_CLKC_BTSS_CLK_SEL_STAT 0x00dc
  72. #define SIRFSOC_CLKC_RGMII_CLKDIV_CFG 0x00e0
  73. #define SIRFSOC_CLKC_RGMII_CLKDIV_ENA 0x00e4
  74. #define SIRFSOC_CLKC_RGMII_CLK_SEL 0x00e8
  75. #define SIRFSOC_CLKC_RGMII_CLK_SEL_STAT 0x00ec
  76. #define SIRFSOC_CLKC_CPU_CLKDIV_CFG 0x00f0
  77. #define SIRFSOC_CLKC_CPU_CLKDIV_ENA 0x00f4
  78. #define SIRFSOC_CLKC_CPU_CLK_SEL 0x00f8
  79. #define SIRFSOC_CLKC_CPU_CLK_SEL_STAT 0x00fc
  80. #define SIRFSOC_CLKC_SDPHY01_CLKDIV_CFG 0x0100
  81. #define SIRFSOC_CLKC_SDPHY01_CLKDIV_ENA 0x0104
  82. #define SIRFSOC_CLKC_SDPHY01_CLK_SEL 0x0108
  83. #define SIRFSOC_CLKC_SDPHY01_CLK_SEL_STAT 0x010c
  84. #define SIRFSOC_CLKC_SDPHY23_CLKDIV_CFG 0x0110
  85. #define SIRFSOC_CLKC_SDPHY23_CLKDIV_ENA 0x0114
  86. #define SIRFSOC_CLKC_SDPHY23_CLK_SEL 0x0118
  87. #define SIRFSOC_CLKC_SDPHY23_CLK_SEL_STAT 0x011c
  88. #define SIRFSOC_CLKC_SDPHY45_CLKDIV_CFG 0x0120
  89. #define SIRFSOC_CLKC_SDPHY45_CLKDIV_ENA 0x0124
  90. #define SIRFSOC_CLKC_SDPHY45_CLK_SEL 0x0128
  91. #define SIRFSOC_CLKC_SDPHY45_CLK_SEL_STAT 0x012c
  92. #define SIRFSOC_CLKC_SDPHY67_CLKDIV_CFG 0x0130
  93. #define SIRFSOC_CLKC_SDPHY67_CLKDIV_ENA 0x0134
  94. #define SIRFSOC_CLKC_SDPHY67_CLK_SEL 0x0138
  95. #define SIRFSOC_CLKC_SDPHY67_CLK_SEL_STAT 0x013c
  96. #define SIRFSOC_CLKC_CAN_CLKDIV_CFG 0x0140
  97. #define SIRFSOC_CLKC_CAN_CLKDIV_ENA 0x0144
  98. #define SIRFSOC_CLKC_CAN_CLK_SEL 0x0148
  99. #define SIRFSOC_CLKC_CAN_CLK_SEL_STAT 0x014c
  100. #define SIRFSOC_CLKC_DEINT_CLKDIV_CFG 0x0150
  101. #define SIRFSOC_CLKC_DEINT_CLKDIV_ENA 0x0154
  102. #define SIRFSOC_CLKC_DEINT_CLK_SEL 0x0158
  103. #define SIRFSOC_CLKC_DEINT_CLK_SEL_STAT 0x015c
  104. #define SIRFSOC_CLKC_NAND_CLKDIV_CFG 0x0160
  105. #define SIRFSOC_CLKC_NAND_CLKDIV_ENA 0x0164
  106. #define SIRFSOC_CLKC_NAND_CLK_SEL 0x0168
  107. #define SIRFSOC_CLKC_NAND_CLK_SEL_STAT 0x016c
  108. #define SIRFSOC_CLKC_DISP0_CLKDIV_CFG 0x0170
  109. #define SIRFSOC_CLKC_DISP0_CLKDIV_ENA 0x0174
  110. #define SIRFSOC_CLKC_DISP0_CLK_SEL 0x0178
  111. #define SIRFSOC_CLKC_DISP0_CLK_SEL_STAT 0x017c
  112. #define SIRFSOC_CLKC_DISP1_CLKDIV_CFG 0x0180
  113. #define SIRFSOC_CLKC_DISP1_CLKDIV_ENA 0x0184
  114. #define SIRFSOC_CLKC_DISP1_CLK_SEL 0x0188
  115. #define SIRFSOC_CLKC_DISP1_CLK_SEL_STAT 0x018c
  116. #define SIRFSOC_CLKC_GPU_CLKDIV_CFG 0x0190
  117. #define SIRFSOC_CLKC_GPU_CLKDIV_ENA 0x0194
  118. #define SIRFSOC_CLKC_GPU_CLK_SEL 0x0198
  119. #define SIRFSOC_CLKC_GPU_CLK_SEL_STAT 0x019c
  120. #define SIRFSOC_CLKC_GNSS_CLKDIV_CFG 0x01a0
  121. #define SIRFSOC_CLKC_GNSS_CLKDIV_ENA 0x01a4
  122. #define SIRFSOC_CLKC_GNSS_CLK_SEL 0x01a8
  123. #define SIRFSOC_CLKC_GNSS_CLK_SEL_STAT 0x01ac
  124. #define SIRFSOC_CLKC_SHARED_DIVIDER_CFG0 0x01b0
  125. #define SIRFSOC_CLKC_SHARED_DIVIDER_CFG1 0x01b4
  126. #define SIRFSOC_CLKC_SHARED_DIVIDER_ENA 0x01b8
  127. #define SIRFSOC_CLKC_SYS_CLK_SEL 0x01bc
  128. #define SIRFSOC_CLKC_SYS_CLK_SEL_STAT 0x01c0
  129. #define SIRFSOC_CLKC_IO_CLK_SEL 0x01c4
  130. #define SIRFSOC_CLKC_IO_CLK_SEL_STAT 0x01c8
  131. #define SIRFSOC_CLKC_G2D_CLK_SEL 0x01cc
  132. #define SIRFSOC_CLKC_G2D_CLK_SEL_STAT 0x01d0
  133. #define SIRFSOC_CLKC_JPENC_CLK_SEL 0x01d4
  134. #define SIRFSOC_CLKC_JPENC_CLK_SEL_STAT 0x01d8
  135. #define SIRFSOC_CLKC_VDEC_CLK_SEL 0x01dc
  136. #define SIRFSOC_CLKC_VDEC_CLK_SEL_STAT 0x01e0
  137. #define SIRFSOC_CLKC_GMAC_CLK_SEL 0x01e4
  138. #define SIRFSOC_CLKC_GMAC_CLK_SEL_STAT 0x01e8
  139. #define SIRFSOC_CLKC_USB_CLK_SEL 0x01ec
  140. #define SIRFSOC_CLKC_USB_CLK_SEL_STAT 0x01f0
  141. #define SIRFSOC_CLKC_KAS_CLK_SEL 0x01f4
  142. #define SIRFSOC_CLKC_KAS_CLK_SEL_STAT 0x01f8
  143. #define SIRFSOC_CLKC_SEC_CLK_SEL 0x01fc
  144. #define SIRFSOC_CLKC_SEC_CLK_SEL_STAT 0x0200
  145. #define SIRFSOC_CLKC_SDR_CLK_SEL 0x0204
  146. #define SIRFSOC_CLKC_SDR_CLK_SEL_STAT 0x0208
  147. #define SIRFSOC_CLKC_VIP_CLK_SEL 0x020c
  148. #define SIRFSOC_CLKC_VIP_CLK_SEL_STAT 0x0210
  149. #define SIRFSOC_CLKC_NOCD_CLK_SEL 0x0214
  150. #define SIRFSOC_CLKC_NOCD_CLK_SEL_STAT 0x0218
  151. #define SIRFSOC_CLKC_NOCR_CLK_SEL 0x021c
  152. #define SIRFSOC_CLKC_NOCR_CLK_SEL_STAT 0x0220
  153. #define SIRFSOC_CLKC_TPIU_CLK_SEL 0x0224
  154. #define SIRFSOC_CLKC_TPIU_CLK_SEL_STAT 0x0228
  155. #define SIRFSOC_CLKC_ROOT_CLK_EN0_SET 0x022c
  156. #define SIRFSOC_CLKC_ROOT_CLK_EN0_CLR 0x0230
  157. #define SIRFSOC_CLKC_ROOT_CLK_EN0_STAT 0x0234
  158. #define SIRFSOC_CLKC_ROOT_CLK_EN1_SET 0x0238
  159. #define SIRFSOC_CLKC_ROOT_CLK_EN1_CLR 0x023c
  160. #define SIRFSOC_CLKC_ROOT_CLK_EN1_STAT 0x0240
  161. #define SIRFSOC_CLKC_LEAF_CLK_EN0_SET 0x0244
  162. #define SIRFSOC_CLKC_LEAF_CLK_EN0_CLR 0x0248
  163. #define SIRFSOC_CLKC_LEAF_CLK_EN0_STAT 0x024c
  164. #define SIRFSOC_CLKC_RSTC_A7_SW_RST 0x0308
  165. #define SIRFSOC_CLKC_LEAF_CLK_EN1_SET 0x04a0
  166. #define SIRFSOC_CLKC_LEAF_CLK_EN2_SET 0x04b8
  167. #define SIRFSOC_CLKC_LEAF_CLK_EN3_SET 0x04d0
  168. #define SIRFSOC_CLKC_LEAF_CLK_EN4_SET 0x04e8
  169. #define SIRFSOC_CLKC_LEAF_CLK_EN5_SET 0x0500
  170. #define SIRFSOC_CLKC_LEAF_CLK_EN6_SET 0x0518
  171. #define SIRFSOC_CLKC_LEAF_CLK_EN7_SET 0x0530
  172. #define SIRFSOC_CLKC_LEAF_CLK_EN8_SET 0x0548
  173. #define SIRFSOC_NOC_CLK_IDLEREQ_SET 0x02D0
  174. #define SIRFSOC_NOC_CLK_IDLEREQ_CLR 0x02D4
  175. #define SIRFSOC_NOC_CLK_SLVRDY_SET 0x02E8
  176. #define SIRFSOC_NOC_CLK_SLVRDY_CLR 0x02EC
  177. #define SIRFSOC_NOC_CLK_IDLE_STATUS 0x02F4
  178. struct clk_pll {
  179. struct clk_hw hw;
  180. u16 regofs; /* register offset */
  181. };
  182. #define to_pllclk(_hw) container_of(_hw, struct clk_pll, hw)
  183. struct clk_dto {
  184. struct clk_hw hw;
  185. u16 inc_offset; /* dto increment offset */
  186. u16 src_offset; /* dto src offset */
  187. };
  188. #define to_dtoclk(_hw) container_of(_hw, struct clk_dto, hw)
  189. enum clk_unit_type {
  190. CLK_UNIT_NOC_OTHER,
  191. CLK_UNIT_NOC_CLOCK,
  192. CLK_UNIT_NOC_SOCKET,
  193. };
  194. struct clk_unit {
  195. struct clk_hw hw;
  196. u16 regofs;
  197. u16 bit;
  198. u32 type;
  199. u8 idle_bit;
  200. spinlock_t *lock;
  201. };
  202. #define to_unitclk(_hw) container_of(_hw, struct clk_unit, hw)
  203. struct atlas7_div_init_data {
  204. const char *div_name;
  205. const char *parent_name;
  206. const char *gate_name;
  207. unsigned long flags;
  208. u8 divider_flags;
  209. u8 gate_flags;
  210. u32 div_offset;
  211. u8 shift;
  212. u8 width;
  213. u32 gate_offset;
  214. u8 gate_bit;
  215. spinlock_t *lock;
  216. };
  217. struct atlas7_mux_init_data {
  218. const char *mux_name;
  219. const char * const *parent_names;
  220. u8 parent_num;
  221. unsigned long flags;
  222. u8 mux_flags;
  223. u32 mux_offset;
  224. u8 shift;
  225. u8 width;
  226. };
  227. struct atlas7_unit_init_data {
  228. u32 index;
  229. const char *unit_name;
  230. const char *parent_name;
  231. unsigned long flags;
  232. u32 regofs;
  233. u8 bit;
  234. u32 type;
  235. u8 idle_bit;
  236. spinlock_t *lock;
  237. };
  238. struct atlas7_reset_desc {
  239. const char *name;
  240. u32 clk_ofs;
  241. u8 clk_bit;
  242. u32 rst_ofs;
  243. u8 rst_bit;
  244. spinlock_t *lock;
  245. };
  246. static void __iomem *sirfsoc_clk_vbase;
  247. static struct clk_onecell_data clk_data;
  248. static const struct clk_div_table pll_div_table[] = {
  249. { .val = 0, .div = 1 },
  250. { .val = 1, .div = 2 },
  251. { .val = 2, .div = 4 },
  252. { .val = 3, .div = 8 },
  253. { .val = 4, .div = 16 },
  254. { .val = 5, .div = 32 },
  255. };
  256. static DEFINE_SPINLOCK(cpupll_ctrl1_lock);
  257. static DEFINE_SPINLOCK(mempll_ctrl1_lock);
  258. static DEFINE_SPINLOCK(sys0pll_ctrl1_lock);
  259. static DEFINE_SPINLOCK(sys1pll_ctrl1_lock);
  260. static DEFINE_SPINLOCK(sys2pll_ctrl1_lock);
  261. static DEFINE_SPINLOCK(sys3pll_ctrl1_lock);
  262. static DEFINE_SPINLOCK(usbphy_div_lock);
  263. static DEFINE_SPINLOCK(btss_div_lock);
  264. static DEFINE_SPINLOCK(rgmii_div_lock);
  265. static DEFINE_SPINLOCK(cpu_div_lock);
  266. static DEFINE_SPINLOCK(sdphy01_div_lock);
  267. static DEFINE_SPINLOCK(sdphy23_div_lock);
  268. static DEFINE_SPINLOCK(sdphy45_div_lock);
  269. static DEFINE_SPINLOCK(sdphy67_div_lock);
  270. static DEFINE_SPINLOCK(can_div_lock);
  271. static DEFINE_SPINLOCK(deint_div_lock);
  272. static DEFINE_SPINLOCK(nand_div_lock);
  273. static DEFINE_SPINLOCK(disp0_div_lock);
  274. static DEFINE_SPINLOCK(disp1_div_lock);
  275. static DEFINE_SPINLOCK(gpu_div_lock);
  276. static DEFINE_SPINLOCK(gnss_div_lock);
  277. /* gate register shared */
  278. static DEFINE_SPINLOCK(share_div_lock);
  279. static DEFINE_SPINLOCK(root0_gate_lock);
  280. static DEFINE_SPINLOCK(root1_gate_lock);
  281. static DEFINE_SPINLOCK(leaf0_gate_lock);
  282. static DEFINE_SPINLOCK(leaf1_gate_lock);
  283. static DEFINE_SPINLOCK(leaf2_gate_lock);
  284. static DEFINE_SPINLOCK(leaf3_gate_lock);
  285. static DEFINE_SPINLOCK(leaf4_gate_lock);
  286. static DEFINE_SPINLOCK(leaf5_gate_lock);
  287. static DEFINE_SPINLOCK(leaf6_gate_lock);
  288. static DEFINE_SPINLOCK(leaf7_gate_lock);
  289. static DEFINE_SPINLOCK(leaf8_gate_lock);
  290. static inline unsigned long clkc_readl(unsigned reg)
  291. {
  292. return readl(sirfsoc_clk_vbase + reg);
  293. }
  294. static inline void clkc_writel(u32 val, unsigned reg)
  295. {
  296. writel(val, sirfsoc_clk_vbase + reg);
  297. }
  298. /*
  299. * ABPLL
  300. * integer mode: Fvco = Fin * 2 * NF / NR
  301. * Spread Spectrum mode: Fvco = Fin * SSN / NR
  302. * SSN = 2^24 / (256 * ((ssdiv >> ssdepth) << ssdepth) + (ssmod << ssdepth))
  303. */
  304. static unsigned long pll_clk_recalc_rate(struct clk_hw *hw,
  305. unsigned long parent_rate)
  306. {
  307. unsigned long fin = parent_rate;
  308. struct clk_pll *clk = to_pllclk(hw);
  309. u64 rate;
  310. u32 regctrl0 = clkc_readl(clk->regofs + SIRFSOC_CLKC_MEMPLL_AB_CTRL0 -
  311. SIRFSOC_CLKC_MEMPLL_AB_FREQ);
  312. u32 regfreq = clkc_readl(clk->regofs);
  313. u32 regssc = clkc_readl(clk->regofs + SIRFSOC_CLKC_MEMPLL_AB_SSC -
  314. SIRFSOC_CLKC_MEMPLL_AB_FREQ);
  315. u32 nr = (regfreq >> 16 & (BIT(3) - 1)) + 1;
  316. u32 nf = (regfreq & (BIT(9) - 1)) + 1;
  317. u32 ssdiv = regssc >> 8 & (BIT(12) - 1);
  318. u32 ssdepth = regssc >> 20 & (BIT(2) - 1);
  319. u32 ssmod = regssc & (BIT(8) - 1);
  320. if (regctrl0 & SIRFSOC_ABPLL_CTRL0_BYPASS)
  321. return fin;
  322. if (regctrl0 & SIRFSOC_ABPLL_CTRL0_SSEN) {
  323. rate = fin;
  324. rate *= 1 << 24;
  325. do_div(rate, nr);
  326. do_div(rate, (256 * ((ssdiv >> ssdepth) << ssdepth)
  327. + (ssmod << ssdepth)));
  328. } else {
  329. rate = 2 * fin;
  330. rate *= nf;
  331. do_div(rate, nr);
  332. }
  333. return rate;
  334. }
  335. static const struct clk_ops ab_pll_ops = {
  336. .recalc_rate = pll_clk_recalc_rate,
  337. };
  338. static const char * const pll_clk_parents[] = {
  339. "xin",
  340. };
  341. static struct clk_init_data clk_cpupll_init = {
  342. .name = "cpupll_vco",
  343. .ops = &ab_pll_ops,
  344. .parent_names = pll_clk_parents,
  345. .num_parents = ARRAY_SIZE(pll_clk_parents),
  346. };
  347. static struct clk_pll clk_cpupll = {
  348. .regofs = SIRFSOC_CLKC_CPUPLL_AB_FREQ,
  349. .hw = {
  350. .init = &clk_cpupll_init,
  351. },
  352. };
  353. static struct clk_init_data clk_mempll_init = {
  354. .name = "mempll_vco",
  355. .ops = &ab_pll_ops,
  356. .parent_names = pll_clk_parents,
  357. .num_parents = ARRAY_SIZE(pll_clk_parents),
  358. };
  359. static struct clk_pll clk_mempll = {
  360. .regofs = SIRFSOC_CLKC_MEMPLL_AB_FREQ,
  361. .hw = {
  362. .init = &clk_mempll_init,
  363. },
  364. };
  365. static struct clk_init_data clk_sys0pll_init = {
  366. .name = "sys0pll_vco",
  367. .ops = &ab_pll_ops,
  368. .parent_names = pll_clk_parents,
  369. .num_parents = ARRAY_SIZE(pll_clk_parents),
  370. };
  371. static struct clk_pll clk_sys0pll = {
  372. .regofs = SIRFSOC_CLKC_SYS0PLL_AB_FREQ,
  373. .hw = {
  374. .init = &clk_sys0pll_init,
  375. },
  376. };
  377. static struct clk_init_data clk_sys1pll_init = {
  378. .name = "sys1pll_vco",
  379. .ops = &ab_pll_ops,
  380. .parent_names = pll_clk_parents,
  381. .num_parents = ARRAY_SIZE(pll_clk_parents),
  382. };
  383. static struct clk_pll clk_sys1pll = {
  384. .regofs = SIRFSOC_CLKC_SYS1PLL_AB_FREQ,
  385. .hw = {
  386. .init = &clk_sys1pll_init,
  387. },
  388. };
  389. static struct clk_init_data clk_sys2pll_init = {
  390. .name = "sys2pll_vco",
  391. .ops = &ab_pll_ops,
  392. .parent_names = pll_clk_parents,
  393. .num_parents = ARRAY_SIZE(pll_clk_parents),
  394. };
  395. static struct clk_pll clk_sys2pll = {
  396. .regofs = SIRFSOC_CLKC_SYS2PLL_AB_FREQ,
  397. .hw = {
  398. .init = &clk_sys2pll_init,
  399. },
  400. };
  401. static struct clk_init_data clk_sys3pll_init = {
  402. .name = "sys3pll_vco",
  403. .ops = &ab_pll_ops,
  404. .parent_names = pll_clk_parents,
  405. .num_parents = ARRAY_SIZE(pll_clk_parents),
  406. };
  407. static struct clk_pll clk_sys3pll = {
  408. .regofs = SIRFSOC_CLKC_SYS3PLL_AB_FREQ,
  409. .hw = {
  410. .init = &clk_sys3pll_init,
  411. },
  412. };
  413. /*
  414. * DTO in clkc, default enable double resolution mode
  415. * double resolution mode:fout = fin * finc / 2^29
  416. * normal mode:fout = fin * finc / 2^28
  417. */
  418. #define DTO_RESL_DOUBLE (1ULL << 29)
  419. #define DTO_RESL_NORMAL (1ULL << 28)
  420. static int dto_clk_is_enabled(struct clk_hw *hw)
  421. {
  422. struct clk_dto *clk = to_dtoclk(hw);
  423. int reg;
  424. reg = clk->src_offset + SIRFSOC_CLKC_AUDIO_DTO_ENA - SIRFSOC_CLKC_AUDIO_DTO_SRC;
  425. return !!(clkc_readl(reg) & BIT(0));
  426. }
  427. static int dto_clk_enable(struct clk_hw *hw)
  428. {
  429. u32 val, reg;
  430. struct clk_dto *clk = to_dtoclk(hw);
  431. reg = clk->src_offset + SIRFSOC_CLKC_AUDIO_DTO_ENA - SIRFSOC_CLKC_AUDIO_DTO_SRC;
  432. val = clkc_readl(reg) | BIT(0);
  433. clkc_writel(val, reg);
  434. return 0;
  435. }
  436. static void dto_clk_disable(struct clk_hw *hw)
  437. {
  438. u32 val, reg;
  439. struct clk_dto *clk = to_dtoclk(hw);
  440. reg = clk->src_offset + SIRFSOC_CLKC_AUDIO_DTO_ENA - SIRFSOC_CLKC_AUDIO_DTO_SRC;
  441. val = clkc_readl(reg) & ~BIT(0);
  442. clkc_writel(val, reg);
  443. }
  444. static unsigned long dto_clk_recalc_rate(struct clk_hw *hw,
  445. unsigned long parent_rate)
  446. {
  447. u64 rate = parent_rate;
  448. struct clk_dto *clk = to_dtoclk(hw);
  449. u32 finc = clkc_readl(clk->inc_offset);
  450. u32 droff = clkc_readl(clk->src_offset + SIRFSOC_CLKC_AUDIO_DTO_DROFF - SIRFSOC_CLKC_AUDIO_DTO_SRC);
  451. rate *= finc;
  452. if (droff & BIT(0))
  453. /* Double resolution off */
  454. do_div(rate, DTO_RESL_NORMAL);
  455. else
  456. do_div(rate, DTO_RESL_DOUBLE);
  457. return rate;
  458. }
  459. static long dto_clk_round_rate(struct clk_hw *hw, unsigned long rate,
  460. unsigned long *parent_rate)
  461. {
  462. u64 dividend = rate * DTO_RESL_DOUBLE;
  463. do_div(dividend, *parent_rate);
  464. dividend *= *parent_rate;
  465. do_div(dividend, DTO_RESL_DOUBLE);
  466. return dividend;
  467. }
  468. static int dto_clk_set_rate(struct clk_hw *hw, unsigned long rate,
  469. unsigned long parent_rate)
  470. {
  471. u64 dividend = rate * DTO_RESL_DOUBLE;
  472. struct clk_dto *clk = to_dtoclk(hw);
  473. do_div(dividend, parent_rate);
  474. clkc_writel(0, clk->src_offset + SIRFSOC_CLKC_AUDIO_DTO_DROFF - SIRFSOC_CLKC_AUDIO_DTO_SRC);
  475. clkc_writel(dividend, clk->inc_offset);
  476. return 0;
  477. }
  478. static u8 dto_clk_get_parent(struct clk_hw *hw)
  479. {
  480. struct clk_dto *clk = to_dtoclk(hw);
  481. return clkc_readl(clk->src_offset);
  482. }
  483. /*
  484. * dto need CLK_SET_PARENT_GATE
  485. */
  486. static int dto_clk_set_parent(struct clk_hw *hw, u8 index)
  487. {
  488. struct clk_dto *clk = to_dtoclk(hw);
  489. clkc_writel(index, clk->src_offset);
  490. return 0;
  491. }
  492. static const struct clk_ops dto_ops = {
  493. .is_enabled = dto_clk_is_enabled,
  494. .enable = dto_clk_enable,
  495. .disable = dto_clk_disable,
  496. .recalc_rate = dto_clk_recalc_rate,
  497. .round_rate = dto_clk_round_rate,
  498. .set_rate = dto_clk_set_rate,
  499. .get_parent = dto_clk_get_parent,
  500. .set_parent = dto_clk_set_parent,
  501. };
  502. /* dto parent clock as syspllvco/clk1 */
  503. static const char * const audiodto_clk_parents[] = {
  504. "sys0pll_clk1",
  505. "sys1pll_clk1",
  506. "sys3pll_clk1",
  507. };
  508. static struct clk_init_data clk_audiodto_init = {
  509. .name = "audio_dto",
  510. .ops = &dto_ops,
  511. .parent_names = audiodto_clk_parents,
  512. .num_parents = ARRAY_SIZE(audiodto_clk_parents),
  513. };
  514. static struct clk_dto clk_audio_dto = {
  515. .inc_offset = SIRFSOC_CLKC_AUDIO_DTO_INC,
  516. .src_offset = SIRFSOC_CLKC_AUDIO_DTO_SRC,
  517. .hw = {
  518. .init = &clk_audiodto_init,
  519. },
  520. };
  521. static const char * const disp0dto_clk_parents[] = {
  522. "sys0pll_clk1",
  523. "sys1pll_clk1",
  524. "sys3pll_clk1",
  525. };
  526. static struct clk_init_data clk_disp0dto_init = {
  527. .name = "disp0_dto",
  528. .ops = &dto_ops,
  529. .parent_names = disp0dto_clk_parents,
  530. .num_parents = ARRAY_SIZE(disp0dto_clk_parents),
  531. };
  532. static struct clk_dto clk_disp0_dto = {
  533. .inc_offset = SIRFSOC_CLKC_DISP0_DTO_INC,
  534. .src_offset = SIRFSOC_CLKC_DISP0_DTO_SRC,
  535. .hw = {
  536. .init = &clk_disp0dto_init,
  537. },
  538. };
  539. static const char * const disp1dto_clk_parents[] = {
  540. "sys0pll_clk1",
  541. "sys1pll_clk1",
  542. "sys3pll_clk1",
  543. };
  544. static struct clk_init_data clk_disp1dto_init = {
  545. .name = "disp1_dto",
  546. .ops = &dto_ops,
  547. .parent_names = disp1dto_clk_parents,
  548. .num_parents = ARRAY_SIZE(disp1dto_clk_parents),
  549. };
  550. static struct clk_dto clk_disp1_dto = {
  551. .inc_offset = SIRFSOC_CLKC_DISP1_DTO_INC,
  552. .src_offset = SIRFSOC_CLKC_DISP1_DTO_SRC,
  553. .hw = {
  554. .init = &clk_disp1dto_init,
  555. },
  556. };
  557. static struct atlas7_div_init_data divider_list[] __initdata = {
  558. /* div_name, parent_name, gate_name, clk_flag, divider_flag, gate_flag, div_offset, shift, wdith, gate_offset, bit_enable, lock */
  559. { "sys0pll_qa1", "sys0pll_fixdiv", "sys0pll_a1", 0, 0, 0, SIRFSOC_CLKC_USBPHY_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_USBPHY_CLKDIV_ENA, 0, &usbphy_div_lock },
  560. { "sys1pll_qa1", "sys1pll_fixdiv", "sys1pll_a1", 0, 0, 0, SIRFSOC_CLKC_USBPHY_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_USBPHY_CLKDIV_ENA, 4, &usbphy_div_lock },
  561. { "sys2pll_qa1", "sys2pll_fixdiv", "sys2pll_a1", 0, 0, 0, SIRFSOC_CLKC_USBPHY_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_USBPHY_CLKDIV_ENA, 8, &usbphy_div_lock },
  562. { "sys3pll_qa1", "sys3pll_fixdiv", "sys3pll_a1", 0, 0, 0, SIRFSOC_CLKC_USBPHY_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_USBPHY_CLKDIV_ENA, 12, &usbphy_div_lock },
  563. { "sys0pll_qa2", "sys0pll_fixdiv", "sys0pll_a2", 0, 0, 0, SIRFSOC_CLKC_BTSS_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_BTSS_CLKDIV_ENA, 0, &btss_div_lock },
  564. { "sys1pll_qa2", "sys1pll_fixdiv", "sys1pll_a2", 0, 0, 0, SIRFSOC_CLKC_BTSS_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_BTSS_CLKDIV_ENA, 4, &btss_div_lock },
  565. { "sys2pll_qa2", "sys2pll_fixdiv", "sys2pll_a2", 0, 0, 0, SIRFSOC_CLKC_BTSS_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_BTSS_CLKDIV_ENA, 8, &btss_div_lock },
  566. { "sys3pll_qa2", "sys3pll_fixdiv", "sys3pll_a2", 0, 0, 0, SIRFSOC_CLKC_BTSS_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_BTSS_CLKDIV_ENA, 12, &btss_div_lock },
  567. { "sys0pll_qa3", "sys0pll_fixdiv", "sys0pll_a3", 0, 0, 0, SIRFSOC_CLKC_RGMII_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_RGMII_CLKDIV_ENA, 0, &rgmii_div_lock },
  568. { "sys1pll_qa3", "sys1pll_fixdiv", "sys1pll_a3", 0, 0, 0, SIRFSOC_CLKC_RGMII_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_RGMII_CLKDIV_ENA, 4, &rgmii_div_lock },
  569. { "sys2pll_qa3", "sys2pll_fixdiv", "sys2pll_a3", 0, 0, 0, SIRFSOC_CLKC_RGMII_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_RGMII_CLKDIV_ENA, 8, &rgmii_div_lock },
  570. { "sys3pll_qa3", "sys3pll_fixdiv", "sys3pll_a3", 0, 0, 0, SIRFSOC_CLKC_RGMII_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_RGMII_CLKDIV_ENA, 12, &rgmii_div_lock },
  571. { "sys0pll_qa4", "sys0pll_fixdiv", "sys0pll_a4", 0, 0, 0, SIRFSOC_CLKC_CPU_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_CPU_CLKDIV_ENA, 0, &cpu_div_lock },
  572. { "sys1pll_qa4", "sys1pll_fixdiv", "sys1pll_a4", 0, 0, CLK_IGNORE_UNUSED, SIRFSOC_CLKC_CPU_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_CPU_CLKDIV_ENA, 4, &cpu_div_lock },
  573. { "sys0pll_qa5", "sys0pll_fixdiv", "sys0pll_a5", 0, 0, 0, SIRFSOC_CLKC_SDPHY01_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_SDPHY01_CLKDIV_ENA, 0, &sdphy01_div_lock },
  574. { "sys1pll_qa5", "sys1pll_fixdiv", "sys1pll_a5", 0, 0, 0, SIRFSOC_CLKC_SDPHY01_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_SDPHY01_CLKDIV_ENA, 4, &sdphy01_div_lock },
  575. { "sys2pll_qa5", "sys2pll_fixdiv", "sys2pll_a5", 0, 0, 0, SIRFSOC_CLKC_SDPHY01_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_SDPHY01_CLKDIV_ENA, 8, &sdphy01_div_lock },
  576. { "sys3pll_qa5", "sys3pll_fixdiv", "sys3pll_a5", 0, 0, 0, SIRFSOC_CLKC_SDPHY01_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_SDPHY01_CLKDIV_ENA, 12, &sdphy01_div_lock },
  577. { "sys0pll_qa6", "sys0pll_fixdiv", "sys0pll_a6", 0, 0, 0, SIRFSOC_CLKC_SDPHY23_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_SDPHY23_CLKDIV_ENA, 0, &sdphy23_div_lock },
  578. { "sys1pll_qa6", "sys1pll_fixdiv", "sys1pll_a6", 0, 0, 0, SIRFSOC_CLKC_SDPHY23_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_SDPHY23_CLKDIV_ENA, 4, &sdphy23_div_lock },
  579. { "sys2pll_qa6", "sys2pll_fixdiv", "sys2pll_a6", 0, 0, 0, SIRFSOC_CLKC_SDPHY23_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_SDPHY23_CLKDIV_ENA, 8, &sdphy23_div_lock },
  580. { "sys3pll_qa6", "sys3pll_fixdiv", "sys3pll_a6", 0, 0, 0, SIRFSOC_CLKC_SDPHY23_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_SDPHY23_CLKDIV_ENA, 12, &sdphy23_div_lock },
  581. { "sys0pll_qa7", "sys0pll_fixdiv", "sys0pll_a7", 0, 0, 0, SIRFSOC_CLKC_SDPHY45_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_SDPHY45_CLKDIV_ENA, 0, &sdphy45_div_lock },
  582. { "sys1pll_qa7", "sys1pll_fixdiv", "sys1pll_a7", 0, 0, 0, SIRFSOC_CLKC_SDPHY45_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_SDPHY45_CLKDIV_ENA, 4, &sdphy45_div_lock },
  583. { "sys2pll_qa7", "sys2pll_fixdiv", "sys2pll_a7", 0, 0, 0, SIRFSOC_CLKC_SDPHY45_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_SDPHY45_CLKDIV_ENA, 8, &sdphy45_div_lock },
  584. { "sys3pll_qa7", "sys3pll_fixdiv", "sys3pll_a7", 0, 0, 0, SIRFSOC_CLKC_SDPHY45_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_SDPHY45_CLKDIV_ENA, 12, &sdphy45_div_lock },
  585. { "sys0pll_qa8", "sys0pll_fixdiv", "sys0pll_a8", 0, 0, 0, SIRFSOC_CLKC_SDPHY67_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_SDPHY67_CLKDIV_ENA, 0, &sdphy67_div_lock },
  586. { "sys1pll_qa8", "sys1pll_fixdiv", "sys1pll_a8", 0, 0, 0, SIRFSOC_CLKC_SDPHY67_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_SDPHY67_CLKDIV_ENA, 4, &sdphy67_div_lock },
  587. { "sys2pll_qa8", "sys2pll_fixdiv", "sys2pll_a8", 0, 0, 0, SIRFSOC_CLKC_SDPHY67_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_SDPHY67_CLKDIV_ENA, 8, &sdphy67_div_lock },
  588. { "sys3pll_qa8", "sys3pll_fixdiv", "sys3pll_a8", 0, 0, 0, SIRFSOC_CLKC_SDPHY67_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_SDPHY67_CLKDIV_ENA, 12, &sdphy67_div_lock },
  589. { "sys0pll_qa9", "sys0pll_fixdiv", "sys0pll_a9", 0, 0, 0, SIRFSOC_CLKC_CAN_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_CAN_CLKDIV_ENA, 0, &can_div_lock },
  590. { "sys1pll_qa9", "sys1pll_fixdiv", "sys1pll_a9", 0, 0, 0, SIRFSOC_CLKC_CAN_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_CAN_CLKDIV_ENA, 4, &can_div_lock },
  591. { "sys2pll_qa9", "sys2pll_fixdiv", "sys2pll_a9", 0, 0, 0, SIRFSOC_CLKC_CAN_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_CAN_CLKDIV_ENA, 8, &can_div_lock },
  592. { "sys3pll_qa9", "sys3pll_fixdiv", "sys3pll_a9", 0, 0, 0, SIRFSOC_CLKC_CAN_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_CAN_CLKDIV_ENA, 12, &can_div_lock },
  593. { "sys0pll_qa10", "sys0pll_fixdiv", "sys0pll_a10", 0, 0, 0, SIRFSOC_CLKC_DEINT_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_DEINT_CLKDIV_ENA, 0, &deint_div_lock },
  594. { "sys1pll_qa10", "sys1pll_fixdiv", "sys1pll_a10", 0, 0, 0, SIRFSOC_CLKC_DEINT_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_DEINT_CLKDIV_ENA, 4, &deint_div_lock },
  595. { "sys2pll_qa10", "sys2pll_fixdiv", "sys2pll_a10", 0, 0, 0, SIRFSOC_CLKC_DEINT_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_DEINT_CLKDIV_ENA, 8, &deint_div_lock },
  596. { "sys3pll_qa10", "sys3pll_fixdiv", "sys3pll_a10", 0, 0, 0, SIRFSOC_CLKC_DEINT_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_DEINT_CLKDIV_ENA, 12, &deint_div_lock },
  597. { "sys0pll_qa11", "sys0pll_fixdiv", "sys0pll_a11", 0, 0, 0, SIRFSOC_CLKC_NAND_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_NAND_CLKDIV_ENA, 0, &nand_div_lock },
  598. { "sys1pll_qa11", "sys1pll_fixdiv", "sys1pll_a11", 0, 0, 0, SIRFSOC_CLKC_NAND_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_NAND_CLKDIV_ENA, 4, &nand_div_lock },
  599. { "sys2pll_qa11", "sys2pll_fixdiv", "sys2pll_a11", 0, 0, 0, SIRFSOC_CLKC_NAND_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_NAND_CLKDIV_ENA, 8, &nand_div_lock },
  600. { "sys3pll_qa11", "sys3pll_fixdiv", "sys3pll_a11", 0, 0, 0, SIRFSOC_CLKC_NAND_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_NAND_CLKDIV_ENA, 12, &nand_div_lock },
  601. { "sys0pll_qa12", "sys0pll_fixdiv", "sys0pll_a12", 0, 0, 0, SIRFSOC_CLKC_DISP0_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_DISP0_CLKDIV_ENA, 0, &disp0_div_lock },
  602. { "sys1pll_qa12", "sys1pll_fixdiv", "sys1pll_a12", 0, 0, 0, SIRFSOC_CLKC_DISP0_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_DISP0_CLKDIV_ENA, 4, &disp0_div_lock },
  603. { "sys2pll_qa12", "sys2pll_fixdiv", "sys2pll_a12", 0, 0, 0, SIRFSOC_CLKC_DISP0_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_DISP0_CLKDIV_ENA, 8, &disp0_div_lock },
  604. { "sys3pll_qa12", "sys3pll_fixdiv", "sys3pll_a12", 0, 0, 0, SIRFSOC_CLKC_DISP0_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_DISP0_CLKDIV_ENA, 12, &disp0_div_lock },
  605. { "sys0pll_qa13", "sys0pll_fixdiv", "sys0pll_a13", 0, 0, 0, SIRFSOC_CLKC_DISP1_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_DISP1_CLKDIV_ENA, 0, &disp1_div_lock },
  606. { "sys1pll_qa13", "sys1pll_fixdiv", "sys1pll_a13", 0, 0, 0, SIRFSOC_CLKC_DISP1_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_DISP1_CLKDIV_ENA, 4, &disp1_div_lock },
  607. { "sys2pll_qa13", "sys2pll_fixdiv", "sys2pll_a13", 0, 0, 0, SIRFSOC_CLKC_DISP1_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_DISP1_CLKDIV_ENA, 8, &disp1_div_lock },
  608. { "sys3pll_qa13", "sys3pll_fixdiv", "sys3pll_a13", 0, 0, 0, SIRFSOC_CLKC_DISP1_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_DISP1_CLKDIV_ENA, 12, &disp1_div_lock },
  609. { "sys0pll_qa14", "sys0pll_fixdiv", "sys0pll_a14", 0, 0, 0, SIRFSOC_CLKC_GPU_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_GPU_CLKDIV_ENA, 0, &gpu_div_lock },
  610. { "sys1pll_qa14", "sys1pll_fixdiv", "sys1pll_a14", 0, 0, 0, SIRFSOC_CLKC_GPU_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_GPU_CLKDIV_ENA, 4, &gpu_div_lock },
  611. { "sys2pll_qa14", "sys2pll_fixdiv", "sys2pll_a14", 0, 0, 0, SIRFSOC_CLKC_GPU_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_GPU_CLKDIV_ENA, 8, &gpu_div_lock },
  612. { "sys3pll_qa14", "sys3pll_fixdiv", "sys3pll_a14", 0, 0, 0, SIRFSOC_CLKC_GPU_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_GPU_CLKDIV_ENA, 12, &gpu_div_lock },
  613. { "sys0pll_qa15", "sys0pll_fixdiv", "sys0pll_a15", 0, 0, 0, SIRFSOC_CLKC_GNSS_CLKDIV_CFG, 0, 6, SIRFSOC_CLKC_GNSS_CLKDIV_ENA, 0, &gnss_div_lock },
  614. { "sys1pll_qa15", "sys1pll_fixdiv", "sys1pll_a15", 0, 0, 0, SIRFSOC_CLKC_GNSS_CLKDIV_CFG, 8, 6, SIRFSOC_CLKC_GNSS_CLKDIV_ENA, 4, &gnss_div_lock },
  615. { "sys2pll_qa15", "sys2pll_fixdiv", "sys2pll_a15", 0, 0, 0, SIRFSOC_CLKC_GNSS_CLKDIV_CFG, 16, 6, SIRFSOC_CLKC_GNSS_CLKDIV_ENA, 8, &gnss_div_lock },
  616. { "sys3pll_qa15", "sys3pll_fixdiv", "sys3pll_a15", 0, 0, 0, SIRFSOC_CLKC_GNSS_CLKDIV_CFG, 24, 6, SIRFSOC_CLKC_GNSS_CLKDIV_ENA, 12, &gnss_div_lock },
  617. { "sys1pll_qa18", "sys1pll_fixdiv", "sys1pll_a18", 0, 0, 0, SIRFSOC_CLKC_SHARED_DIVIDER_CFG0, 24, 6, SIRFSOC_CLKC_SHARED_DIVIDER_ENA, 12, &share_div_lock },
  618. { "sys1pll_qa19", "sys1pll_fixdiv", "sys1pll_a19", 0, 0, CLK_IGNORE_UNUSED, SIRFSOC_CLKC_SHARED_DIVIDER_CFG0, 16, 6, SIRFSOC_CLKC_SHARED_DIVIDER_ENA, 8, &share_div_lock },
  619. { "sys1pll_qa20", "sys1pll_fixdiv", "sys1pll_a20", 0, 0, 0, SIRFSOC_CLKC_SHARED_DIVIDER_CFG0, 8, 6, SIRFSOC_CLKC_SHARED_DIVIDER_ENA, 4, &share_div_lock },
  620. { "sys2pll_qa20", "sys2pll_fixdiv", "sys2pll_a20", 0, 0, 0, SIRFSOC_CLKC_SHARED_DIVIDER_CFG0, 0, 6, SIRFSOC_CLKC_SHARED_DIVIDER_ENA, 0, &share_div_lock },
  621. { "sys1pll_qa17", "sys1pll_fixdiv", "sys1pll_a17", 0, 0, CLK_IGNORE_UNUSED, SIRFSOC_CLKC_SHARED_DIVIDER_CFG1, 8, 6, SIRFSOC_CLKC_SHARED_DIVIDER_ENA, 20, &share_div_lock },
  622. { "sys0pll_qa20", "sys0pll_fixdiv", "sys0pll_a20", 0, 0, 0, SIRFSOC_CLKC_SHARED_DIVIDER_CFG1, 0, 6, SIRFSOC_CLKC_SHARED_DIVIDER_ENA, 16, &share_div_lock },
  623. };
  624. static const char * const i2s_clk_parents[] = {
  625. "xin",
  626. "xinw",
  627. "audio_dto",
  628. /* "pwm_i2s01" */
  629. };
  630. static const char * const usbphy_clk_parents[] = {
  631. "xin",
  632. "xinw",
  633. "sys0pll_a1",
  634. "sys1pll_a1",
  635. "sys2pll_a1",
  636. "sys3pll_a1",
  637. };
  638. static const char * const btss_clk_parents[] = {
  639. "xin",
  640. "xinw",
  641. "sys0pll_a2",
  642. "sys1pll_a2",
  643. "sys2pll_a2",
  644. "sys3pll_a2",
  645. };
  646. static const char * const rgmii_clk_parents[] = {
  647. "xin",
  648. "xinw",
  649. "sys0pll_a3",
  650. "sys1pll_a3",
  651. "sys2pll_a3",
  652. "sys3pll_a3",
  653. };
  654. static const char * const cpu_clk_parents[] = {
  655. "xin",
  656. "xinw",
  657. "sys0pll_a4",
  658. "sys1pll_a4",
  659. "cpupll_clk1",
  660. };
  661. static const char * const sdphy01_clk_parents[] = {
  662. "xin",
  663. "xinw",
  664. "sys0pll_a5",
  665. "sys1pll_a5",
  666. "sys2pll_a5",
  667. "sys3pll_a5",
  668. };
  669. static const char * const sdphy23_clk_parents[] = {
  670. "xin",
  671. "xinw",
  672. "sys0pll_a6",
  673. "sys1pll_a6",
  674. "sys2pll_a6",
  675. "sys3pll_a6",
  676. };
  677. static const char * const sdphy45_clk_parents[] = {
  678. "xin",
  679. "xinw",
  680. "sys0pll_a7",
  681. "sys1pll_a7",
  682. "sys2pll_a7",
  683. "sys3pll_a7",
  684. };
  685. static const char * const sdphy67_clk_parents[] = {
  686. "xin",
  687. "xinw",
  688. "sys0pll_a8",
  689. "sys1pll_a8",
  690. "sys2pll_a8",
  691. "sys3pll_a8",
  692. };
  693. static const char * const can_clk_parents[] = {
  694. "xin",
  695. "xinw",
  696. "sys0pll_a9",
  697. "sys1pll_a9",
  698. "sys2pll_a9",
  699. "sys3pll_a9",
  700. };
  701. static const char * const deint_clk_parents[] = {
  702. "xin",
  703. "xinw",
  704. "sys0pll_a10",
  705. "sys1pll_a10",
  706. "sys2pll_a10",
  707. "sys3pll_a10",
  708. };
  709. static const char * const nand_clk_parents[] = {
  710. "xin",
  711. "xinw",
  712. "sys0pll_a11",
  713. "sys1pll_a11",
  714. "sys2pll_a11",
  715. "sys3pll_a11",
  716. };
  717. static const char * const disp0_clk_parents[] = {
  718. "xin",
  719. "xinw",
  720. "sys0pll_a12",
  721. "sys1pll_a12",
  722. "sys2pll_a12",
  723. "sys3pll_a12",
  724. "disp0_dto",
  725. };
  726. static const char * const disp1_clk_parents[] = {
  727. "xin",
  728. "xinw",
  729. "sys0pll_a13",
  730. "sys1pll_a13",
  731. "sys2pll_a13",
  732. "sys3pll_a13",
  733. "disp1_dto",
  734. };
  735. static const char * const gpu_clk_parents[] = {
  736. "xin",
  737. "xinw",
  738. "sys0pll_a14",
  739. "sys1pll_a14",
  740. "sys2pll_a14",
  741. "sys3pll_a14",
  742. };
  743. static const char * const gnss_clk_parents[] = {
  744. "xin",
  745. "xinw",
  746. "sys0pll_a15",
  747. "sys1pll_a15",
  748. "sys2pll_a15",
  749. "sys3pll_a15",
  750. };
  751. static const char * const sys_clk_parents[] = {
  752. "xin",
  753. "xinw",
  754. "sys2pll_a20",
  755. "sys1pll_a20",
  756. "sys1pll_a19",
  757. "sys1pll_a18",
  758. "sys0pll_a20",
  759. "sys1pll_a17",
  760. };
  761. static const char * const io_clk_parents[] = {
  762. "xin",
  763. "xinw",
  764. "sys2pll_a20",
  765. "sys1pll_a20",
  766. "sys1pll_a19",
  767. "sys1pll_a18",
  768. "sys0pll_a20",
  769. "sys1pll_a17",
  770. };
  771. static const char * const g2d_clk_parents[] = {
  772. "xin",
  773. "xinw",
  774. "sys2pll_a20",
  775. "sys1pll_a20",
  776. "sys1pll_a19",
  777. "sys1pll_a18",
  778. "sys0pll_a20",
  779. "sys1pll_a17",
  780. };
  781. static const char * const jpenc_clk_parents[] = {
  782. "xin",
  783. "xinw",
  784. "sys2pll_a20",
  785. "sys1pll_a20",
  786. "sys1pll_a19",
  787. "sys1pll_a18",
  788. "sys0pll_a20",
  789. "sys1pll_a17",
  790. };
  791. static const char * const vdec_clk_parents[] = {
  792. "xin",
  793. "xinw",
  794. "sys2pll_a20",
  795. "sys1pll_a20",
  796. "sys1pll_a19",
  797. "sys1pll_a18",
  798. "sys0pll_a20",
  799. "sys1pll_a17",
  800. };
  801. static const char * const gmac_clk_parents[] = {
  802. "xin",
  803. "xinw",
  804. "sys2pll_a20",
  805. "sys1pll_a20",
  806. "sys1pll_a19",
  807. "sys1pll_a18",
  808. "sys0pll_a20",
  809. "sys1pll_a17",
  810. };
  811. static const char * const usb_clk_parents[] = {
  812. "xin",
  813. "xinw",
  814. "sys2pll_a20",
  815. "sys1pll_a20",
  816. "sys1pll_a19",
  817. "sys1pll_a18",
  818. "sys0pll_a20",
  819. "sys1pll_a17",
  820. };
  821. static const char * const kas_clk_parents[] = {
  822. "xin",
  823. "xinw",
  824. "sys2pll_a20",
  825. "sys1pll_a20",
  826. "sys1pll_a19",
  827. "sys1pll_a18",
  828. "sys0pll_a20",
  829. "sys1pll_a17",
  830. };
  831. static const char * const sec_clk_parents[] = {
  832. "xin",
  833. "xinw",
  834. "sys2pll_a20",
  835. "sys1pll_a20",
  836. "sys1pll_a19",
  837. "sys1pll_a18",
  838. "sys0pll_a20",
  839. "sys1pll_a17",
  840. };
  841. static const char * const sdr_clk_parents[] = {
  842. "xin",
  843. "xinw",
  844. "sys2pll_a20",
  845. "sys1pll_a20",
  846. "sys1pll_a19",
  847. "sys1pll_a18",
  848. "sys0pll_a20",
  849. "sys1pll_a17",
  850. };
  851. static const char * const vip_clk_parents[] = {
  852. "xin",
  853. "xinw",
  854. "sys2pll_a20",
  855. "sys1pll_a20",
  856. "sys1pll_a19",
  857. "sys1pll_a18",
  858. "sys0pll_a20",
  859. "sys1pll_a17",
  860. };
  861. static const char * const nocd_clk_parents[] = {
  862. "xin",
  863. "xinw",
  864. "sys2pll_a20",
  865. "sys1pll_a20",
  866. "sys1pll_a19",
  867. "sys1pll_a18",
  868. "sys0pll_a20",
  869. "sys1pll_a17",
  870. };
  871. static const char * const nocr_clk_parents[] = {
  872. "xin",
  873. "xinw",
  874. "sys2pll_a20",
  875. "sys1pll_a20",
  876. "sys1pll_a19",
  877. "sys1pll_a18",
  878. "sys0pll_a20",
  879. "sys1pll_a17",
  880. };
  881. static const char * const tpiu_clk_parents[] = {
  882. "xin",
  883. "xinw",
  884. "sys2pll_a20",
  885. "sys1pll_a20",
  886. "sys1pll_a19",
  887. "sys1pll_a18",
  888. "sys0pll_a20",
  889. "sys1pll_a17",
  890. };
  891. static struct atlas7_mux_init_data mux_list[] __initdata = {
  892. /* mux_name, parent_names, parent_num, flags, mux_flags, mux_offset, shift, width */
  893. { "i2s_mux", i2s_clk_parents, ARRAY_SIZE(i2s_clk_parents), 0, 0, SIRFSOC_CLKC_I2S_CLK_SEL, 0, 2 },
  894. { "usbphy_mux", usbphy_clk_parents, ARRAY_SIZE(usbphy_clk_parents), 0, 0, SIRFSOC_CLKC_I2S_CLK_SEL, 0, 3 },
  895. { "btss_mux", btss_clk_parents, ARRAY_SIZE(btss_clk_parents), 0, 0, SIRFSOC_CLKC_BTSS_CLK_SEL, 0, 3 },
  896. { "rgmii_mux", rgmii_clk_parents, ARRAY_SIZE(rgmii_clk_parents), 0, 0, SIRFSOC_CLKC_RGMII_CLK_SEL, 0, 3 },
  897. { "cpu_mux", cpu_clk_parents, ARRAY_SIZE(cpu_clk_parents), 0, 0, SIRFSOC_CLKC_CPU_CLK_SEL, 0, 3 },
  898. { "sdphy01_mux", sdphy01_clk_parents, ARRAY_SIZE(sdphy01_clk_parents), 0, 0, SIRFSOC_CLKC_SDPHY01_CLK_SEL, 0, 3 },
  899. { "sdphy23_mux", sdphy23_clk_parents, ARRAY_SIZE(sdphy23_clk_parents), 0, 0, SIRFSOC_CLKC_SDPHY23_CLK_SEL, 0, 3 },
  900. { "sdphy45_mux", sdphy45_clk_parents, ARRAY_SIZE(sdphy45_clk_parents), 0, 0, SIRFSOC_CLKC_SDPHY45_CLK_SEL, 0, 3 },
  901. { "sdphy67_mux", sdphy67_clk_parents, ARRAY_SIZE(sdphy67_clk_parents), 0, 0, SIRFSOC_CLKC_SDPHY67_CLK_SEL, 0, 3 },
  902. { "can_mux", can_clk_parents, ARRAY_SIZE(can_clk_parents), 0, 0, SIRFSOC_CLKC_CAN_CLK_SEL, 0, 3 },
  903. { "deint_mux", deint_clk_parents, ARRAY_SIZE(deint_clk_parents), 0, 0, SIRFSOC_CLKC_DEINT_CLK_SEL, 0, 3 },
  904. { "nand_mux", nand_clk_parents, ARRAY_SIZE(nand_clk_parents), 0, 0, SIRFSOC_CLKC_NAND_CLK_SEL, 0, 3 },
  905. { "disp0_mux", disp0_clk_parents, ARRAY_SIZE(disp0_clk_parents), 0, 0, SIRFSOC_CLKC_DISP0_CLK_SEL, 0, 3 },
  906. { "disp1_mux", disp1_clk_parents, ARRAY_SIZE(disp1_clk_parents), 0, 0, SIRFSOC_CLKC_DISP1_CLK_SEL, 0, 3 },
  907. { "gpu_mux", gpu_clk_parents, ARRAY_SIZE(gpu_clk_parents), 0, 0, SIRFSOC_CLKC_GPU_CLK_SEL, 0, 3 },
  908. { "gnss_mux", gnss_clk_parents, ARRAY_SIZE(gnss_clk_parents), 0, 0, SIRFSOC_CLKC_GNSS_CLK_SEL, 0, 3 },
  909. { "sys_mux", sys_clk_parents, ARRAY_SIZE(sys_clk_parents), 0, 0, SIRFSOC_CLKC_SYS_CLK_SEL, 0, 3 },
  910. { "io_mux", io_clk_parents, ARRAY_SIZE(io_clk_parents), 0, 0, SIRFSOC_CLKC_IO_CLK_SEL, 0, 3 },
  911. { "g2d_mux", g2d_clk_parents, ARRAY_SIZE(g2d_clk_parents), 0, 0, SIRFSOC_CLKC_G2D_CLK_SEL, 0, 3 },
  912. { "jpenc_mux", jpenc_clk_parents, ARRAY_SIZE(jpenc_clk_parents), 0, 0, SIRFSOC_CLKC_JPENC_CLK_SEL, 0, 3 },
  913. { "vdec_mux", vdec_clk_parents, ARRAY_SIZE(vdec_clk_parents), 0, 0, SIRFSOC_CLKC_VDEC_CLK_SEL, 0, 3 },
  914. { "gmac_mux", gmac_clk_parents, ARRAY_SIZE(gmac_clk_parents), 0, 0, SIRFSOC_CLKC_GMAC_CLK_SEL, 0, 3 },
  915. { "usb_mux", usb_clk_parents, ARRAY_SIZE(usb_clk_parents), 0, 0, SIRFSOC_CLKC_USB_CLK_SEL, 0, 3 },
  916. { "kas_mux", kas_clk_parents, ARRAY_SIZE(kas_clk_parents), 0, 0, SIRFSOC_CLKC_KAS_CLK_SEL, 0, 3 },
  917. { "sec_mux", sec_clk_parents, ARRAY_SIZE(sec_clk_parents), 0, 0, SIRFSOC_CLKC_SEC_CLK_SEL, 0, 3 },
  918. { "sdr_mux", sdr_clk_parents, ARRAY_SIZE(sdr_clk_parents), 0, 0, SIRFSOC_CLKC_SDR_CLK_SEL, 0, 3 },
  919. { "vip_mux", vip_clk_parents, ARRAY_SIZE(vip_clk_parents), 0, 0, SIRFSOC_CLKC_VIP_CLK_SEL, 0, 3 },
  920. { "nocd_mux", nocd_clk_parents, ARRAY_SIZE(nocd_clk_parents), 0, 0, SIRFSOC_CLKC_NOCD_CLK_SEL, 0, 3 },
  921. { "nocr_mux", nocr_clk_parents, ARRAY_SIZE(nocr_clk_parents), 0, 0, SIRFSOC_CLKC_NOCR_CLK_SEL, 0, 3 },
  922. { "tpiu_mux", tpiu_clk_parents, ARRAY_SIZE(tpiu_clk_parents), 0, 0, SIRFSOC_CLKC_TPIU_CLK_SEL, 0, 3 },
  923. };
  924. /* new unit should add start from the tail of list */
  925. static struct atlas7_unit_init_data unit_list[] __initdata = {
  926. /* unit_name, parent_name, flags, regofs, bit, lock */
  927. { 0, "audmscm_kas", "kas_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 0, 0, 0, &root0_gate_lock },
  928. { 1, "gnssm_gnss", "gnss_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 1, 0, 0, &root0_gate_lock },
  929. { 2, "gpum_gpu", "gpu_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 2, 0, 0, &root0_gate_lock },
  930. { 3, "mediam_g2d", "g2d_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 3, 0, 0, &root0_gate_lock },
  931. { 4, "mediam_jpenc", "jpenc_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 4, 0, 0, &root0_gate_lock },
  932. { 5, "vdifm_disp0", "disp0_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 5, 0, 0, &root0_gate_lock },
  933. { 6, "vdifm_disp1", "disp1_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 6, 0, 0, &root0_gate_lock },
  934. { 7, "audmscm_i2s", "i2s_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 8, 0, 0, &root0_gate_lock },
  935. { 8, "audmscm_io", "io_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 11, 0, 0, &root0_gate_lock },
  936. { 9, "vdifm_io", "io_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 12, 0, 0, &root0_gate_lock },
  937. { 10, "gnssm_io", "io_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 13, 0, 0, &root0_gate_lock },
  938. { 11, "mediam_io", "io_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 14, 0, 0, &root0_gate_lock },
  939. { 12, "btm_io", "io_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 17, 0, 0, &root0_gate_lock },
  940. { 13, "mediam_sdphy01", "sdphy01_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 18, 0, 0, &root0_gate_lock },
  941. { 14, "vdifm_sdphy23", "sdphy23_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 19, 0, 0, &root0_gate_lock },
  942. { 15, "vdifm_sdphy45", "sdphy45_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 20, 0, 0, &root0_gate_lock },
  943. { 16, "vdifm_sdphy67", "sdphy67_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 21, 0, 0, &root0_gate_lock },
  944. { 17, "audmscm_xin", "xin", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 22, 0, 0, &root0_gate_lock },
  945. { 18, "mediam_nand", "nand_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 27, 0, 0, &root0_gate_lock },
  946. { 19, "gnssm_sec", "sec_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 28, 0, 0, &root0_gate_lock },
  947. { 20, "cpum_cpu", "cpu_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 29, 0, 0, &root0_gate_lock },
  948. { 21, "gnssm_xin", "xin", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 30, 0, 0, &root0_gate_lock },
  949. { 22, "vdifm_vip", "vip_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN0_SET, 31, 0, 0, &root0_gate_lock },
  950. { 23, "btm_btss", "btss_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 0, 0, 0, &root1_gate_lock },
  951. { 24, "mediam_usbphy", "usbphy_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 1, 0, 0, &root1_gate_lock },
  952. { 25, "rtcm_kas", "kas_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 2, 0, 0, &root1_gate_lock },
  953. { 26, "audmscm_nocd", "nocd_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 3, 0, 0, &root1_gate_lock },
  954. { 27, "vdifm_nocd", "nocd_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 4, 0, 0, &root1_gate_lock },
  955. { 28, "gnssm_nocd", "nocd_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 5, 0, 0, &root1_gate_lock },
  956. { 29, "mediam_nocd", "nocd_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 6, 0, 0, &root1_gate_lock },
  957. { 30, "cpum_nocd", "nocd_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 8, 0, 0, &root1_gate_lock },
  958. { 31, "gpum_nocd", "nocd_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 9, 0, 0, &root1_gate_lock },
  959. { 32, "audmscm_nocr", "nocr_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 11, 0, 0, &root1_gate_lock },
  960. { 33, "vdifm_nocr", "nocr_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 12, 0, 0, &root1_gate_lock },
  961. { 34, "gnssm_nocr", "nocr_mux", CLK_IGNORE_UNUSED, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 13, 0, 0, &root1_gate_lock },
  962. { 35, "mediam_nocr", "nocr_mux", CLK_IGNORE_UNUSED, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 14, 0, 0, &root1_gate_lock },
  963. { 36, "ddrm_nocr", "nocr_mux", CLK_IGNORE_UNUSED, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 15, 0, 0, &root1_gate_lock },
  964. { 37, "cpum_tpiu", "tpiu_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 16, 0, 0, &root1_gate_lock },
  965. { 38, "gpum_nocr", "nocr_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 17, 0, 0, &root1_gate_lock },
  966. { 39, "gnssm_rgmii", "rgmii_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 20, 0, 0, &root1_gate_lock },
  967. { 40, "mediam_vdec", "vdec_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 21, 0, 0, &root1_gate_lock },
  968. { 41, "gpum_sdr", "sdr_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 22, 0, 0, &root1_gate_lock },
  969. { 42, "vdifm_deint", "deint_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 23, 0, 0, &root1_gate_lock },
  970. { 43, "gnssm_can", "can_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 26, 0, 0, &root1_gate_lock },
  971. { 44, "mediam_usb", "usb_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 28, 0, 0, &root1_gate_lock },
  972. { 45, "gnssm_gmac", "gmac_mux", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 29, 0, 0, &root1_gate_lock },
  973. { 46, "cvd_io", "audmscm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 0, CLK_UNIT_NOC_CLOCK, 4, &leaf1_gate_lock },
  974. { 47, "timer_io", "audmscm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 1, 0, 0, &leaf1_gate_lock },
  975. { 48, "pulse_io", "audmscm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 2, 0, 0, &leaf1_gate_lock },
  976. { 49, "tsc_io", "audmscm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 3, 0, 0, &leaf1_gate_lock },
  977. { 50, "tsc_xin", "audmscm_xin", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 21, 0, 0, &leaf1_gate_lock },
  978. { 51, "ioctop_io", "audmscm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 4, 0, 0, &leaf1_gate_lock },
  979. { 52, "rsc_io", "audmscm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 5, 0, 0, &leaf1_gate_lock },
  980. { 53, "dvm_io", "audmscm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 6, CLK_UNIT_NOC_SOCKET, 7, &leaf1_gate_lock },
  981. { 54, "lvds_xin", "audmscm_xin", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 7, CLK_UNIT_NOC_SOCKET, 8, &leaf1_gate_lock },
  982. { 55, "kas_kas", "audmscm_kas", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 8, CLK_UNIT_NOC_CLOCK, 2, &leaf1_gate_lock },
  983. { 56, "ac97_kas", "audmscm_kas", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 9, 0, 0, &leaf1_gate_lock },
  984. { 57, "usp0_kas", "audmscm_kas", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 10, CLK_UNIT_NOC_SOCKET, 4, &leaf1_gate_lock },
  985. { 58, "usp1_kas", "audmscm_kas", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 11, CLK_UNIT_NOC_SOCKET, 5, &leaf1_gate_lock },
  986. { 59, "usp2_kas", "audmscm_kas", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 12, CLK_UNIT_NOC_SOCKET, 6, &leaf1_gate_lock },
  987. { 60, "dmac2_kas", "audmscm_kas", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 13, CLK_UNIT_NOC_SOCKET, 1, &leaf1_gate_lock },
  988. { 61, "dmac3_kas", "audmscm_kas", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 14, CLK_UNIT_NOC_SOCKET, 2, &leaf1_gate_lock },
  989. { 62, "audioif_kas", "audmscm_kas", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 15, CLK_UNIT_NOC_SOCKET, 0, &leaf1_gate_lock },
  990. { 63, "i2s1_kas", "audmscm_kas", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 17, CLK_UNIT_NOC_CLOCK, 2, &leaf1_gate_lock },
  991. { 64, "thaudmscm_io", "audmscm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 22, 0, 0, &leaf1_gate_lock },
  992. { 65, "analogtest_xin", "audmscm_xin", 0, SIRFSOC_CLKC_LEAF_CLK_EN1_SET, 23, 0, 0, &leaf1_gate_lock },
  993. { 66, "sys2pci_io", "vdifm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 0, CLK_UNIT_NOC_CLOCK, 20, &leaf2_gate_lock },
  994. { 67, "pciarb_io", "vdifm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 1, 0, 0, &leaf2_gate_lock },
  995. { 68, "pcicopy_io", "vdifm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 2, 0, 0, &leaf2_gate_lock },
  996. { 69, "rom_io", "vdifm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 3, 0, 0, &leaf2_gate_lock },
  997. { 70, "sdio23_io", "vdifm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 4, 0, 0, &leaf2_gate_lock },
  998. { 71, "sdio45_io", "vdifm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 5, 0, 0, &leaf2_gate_lock },
  999. { 72, "sdio67_io", "vdifm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 6, 0, 0, &leaf2_gate_lock },
  1000. { 73, "vip1_io", "vdifm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 7, 0, 0, &leaf2_gate_lock },
  1001. { 74, "vip1_vip", "vdifm_vip", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 16, CLK_UNIT_NOC_CLOCK, 21, &leaf2_gate_lock },
  1002. { 75, "sdio23_sdphy23", "vdifm_sdphy23", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 8, 0, 0, &leaf2_gate_lock },
  1003. { 76, "sdio45_sdphy45", "vdifm_sdphy45", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 9, 0, 0, &leaf2_gate_lock },
  1004. { 77, "sdio67_sdphy67", "vdifm_sdphy67", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 10, 0, 0, &leaf2_gate_lock },
  1005. { 78, "vpp0_disp0", "vdifm_disp0", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 11, CLK_UNIT_NOC_CLOCK, 22, &leaf2_gate_lock },
  1006. { 79, "lcd0_disp0", "vdifm_disp0", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 12, CLK_UNIT_NOC_CLOCK, 18, &leaf2_gate_lock },
  1007. { 80, "vpp1_disp1", "vdifm_disp1", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 13, CLK_UNIT_NOC_CLOCK, 23, &leaf2_gate_lock },
  1008. { 81, "lcd1_disp1", "vdifm_disp1", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 14, CLK_UNIT_NOC_CLOCK, 19, &leaf2_gate_lock },
  1009. { 82, "dcu_deint", "vdifm_deint", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 15, CLK_UNIT_NOC_CLOCK, 17, &leaf2_gate_lock },
  1010. { 83, "vdifm_dapa_r_nocr", "vdifm_nocr", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 17, 0, 0, &leaf2_gate_lock },
  1011. { 84, "gpio1_io", "vdifm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 18, 0, 0, &leaf2_gate_lock },
  1012. { 85, "thvdifm_io", "vdifm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN2_SET, 19, 0, 0, &leaf2_gate_lock },
  1013. { 86, "gmac_rgmii", "gnssm_rgmii", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 0, 0, 0, &leaf3_gate_lock },
  1014. { 87, "gmac_gmac", "gnssm_gmac", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 1, CLK_UNIT_NOC_CLOCK, 10, &leaf3_gate_lock },
  1015. { 88, "uart1_io", "gnssm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 2, CLK_UNIT_NOC_SOCKET, 14, &leaf3_gate_lock },
  1016. { 89, "dmac0_io", "gnssm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 3, CLK_UNIT_NOC_SOCKET, 11, &leaf3_gate_lock },
  1017. { 90, "uart0_io", "gnssm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 4, CLK_UNIT_NOC_SOCKET, 13, &leaf3_gate_lock },
  1018. { 91, "uart2_io", "gnssm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 5, CLK_UNIT_NOC_SOCKET, 15, &leaf3_gate_lock },
  1019. { 92, "uart3_io", "gnssm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 6, CLK_UNIT_NOC_SOCKET, 16, &leaf3_gate_lock },
  1020. { 93, "uart4_io", "gnssm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 7, CLK_UNIT_NOC_SOCKET, 17, &leaf3_gate_lock },
  1021. { 94, "uart5_io", "gnssm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 8, CLK_UNIT_NOC_SOCKET, 18, &leaf3_gate_lock },
  1022. { 95, "spi1_io", "gnssm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 9, CLK_UNIT_NOC_SOCKET, 12, &leaf3_gate_lock },
  1023. { 96, "gnss_gnss", "gnssm_gnss", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 10, 0, 0, &leaf3_gate_lock },
  1024. { 97, "canbus1_can", "gnssm_can", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 12, CLK_UNIT_NOC_CLOCK, 7, &leaf3_gate_lock },
  1025. { 98, "ccsec_sec", "gnssm_sec", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 15, CLK_UNIT_NOC_CLOCK, 9, &leaf3_gate_lock },
  1026. { 99, "ccpub_sec", "gnssm_sec", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 16, CLK_UNIT_NOC_CLOCK, 8, &leaf3_gate_lock },
  1027. { 100, "gnssm_dapa_r_nocr", "gnssm_nocr", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 13, 0, 0, &leaf3_gate_lock },
  1028. { 101, "thgnssm_io", "gnssm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN3_SET, 14, 0, 0, &leaf3_gate_lock },
  1029. { 102, "media_vdec", "mediam_vdec", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 0, CLK_UNIT_NOC_CLOCK, 3, &leaf4_gate_lock },
  1030. { 103, "media_jpenc", "mediam_jpenc", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 1, CLK_UNIT_NOC_CLOCK, 1, &leaf4_gate_lock },
  1031. { 104, "g2d_g2d", "mediam_g2d", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 2, CLK_UNIT_NOC_CLOCK, 12, &leaf4_gate_lock },
  1032. { 105, "i2c0_io", "mediam_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 3, CLK_UNIT_NOC_SOCKET, 21, &leaf4_gate_lock },
  1033. { 106, "i2c1_io", "mediam_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 4, CLK_UNIT_NOC_SOCKET, 20, &leaf4_gate_lock },
  1034. { 107, "gpio0_io", "mediam_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 5, CLK_UNIT_NOC_SOCKET, 19, &leaf4_gate_lock },
  1035. { 108, "nand_io", "mediam_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 6, 0, 0, &leaf4_gate_lock },
  1036. { 109, "sdio01_io", "mediam_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 7, 0, 0, &leaf4_gate_lock },
  1037. { 110, "sys2pci2_io", "mediam_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 8, CLK_UNIT_NOC_CLOCK, 13, &leaf4_gate_lock },
  1038. { 111, "sdio01_sdphy01", "mediam_sdphy01", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 9, 0, 0, &leaf4_gate_lock },
  1039. { 112, "nand_nand", "mediam_nand", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 10, CLK_UNIT_NOC_CLOCK, 14, &leaf4_gate_lock },
  1040. { 113, "usb0_usb", "mediam_usb", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 11, CLK_UNIT_NOC_CLOCK, 15, &leaf4_gate_lock },
  1041. { 114, "usb1_usb", "mediam_usb", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 12, CLK_UNIT_NOC_CLOCK, 16, &leaf4_gate_lock },
  1042. { 115, "usbphy0_usbphy", "mediam_usbphy", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 13, 0, 0, &leaf4_gate_lock },
  1043. { 116, "usbphy1_usbphy", "mediam_usbphy", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 14, 0, 0, &leaf4_gate_lock },
  1044. { 117, "thmediam_io", "mediam_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN4_SET, 15, 0, 0, &leaf4_gate_lock },
  1045. { 118, "memc_mem", "mempll_clk1", CLK_IGNORE_UNUSED, SIRFSOC_CLKC_LEAF_CLK_EN5_SET, 0, 0, 0, &leaf5_gate_lock },
  1046. { 119, "dapa_mem", "mempll_clk1", 0, SIRFSOC_CLKC_LEAF_CLK_EN5_SET, 1, 0, 0, &leaf5_gate_lock },
  1047. { 120, "nocddrm_nocr", "ddrm_nocr", 0, SIRFSOC_CLKC_LEAF_CLK_EN5_SET, 2, 0, 0, &leaf5_gate_lock },
  1048. { 121, "thddrm_nocr", "ddrm_nocr", 0, SIRFSOC_CLKC_LEAF_CLK_EN5_SET, 3, 0, 0, &leaf5_gate_lock },
  1049. { 122, "spram1_cpudiv2", "cpum_cpu", 0, SIRFSOC_CLKC_LEAF_CLK_EN6_SET, 0, CLK_UNIT_NOC_SOCKET, 9, &leaf6_gate_lock },
  1050. { 123, "spram2_cpudiv2", "cpum_cpu", 0, SIRFSOC_CLKC_LEAF_CLK_EN6_SET, 1, CLK_UNIT_NOC_SOCKET, 10, &leaf6_gate_lock },
  1051. { 124, "coresight_cpudiv2", "cpum_cpu", 0, SIRFSOC_CLKC_LEAF_CLK_EN6_SET, 2, 0, 0, &leaf6_gate_lock },
  1052. { 125, "coresight_tpiu", "cpum_tpiu", 0, SIRFSOC_CLKC_LEAF_CLK_EN6_SET, 3, 0, 0, &leaf6_gate_lock },
  1053. { 126, "graphic_gpu", "gpum_gpu", 0, SIRFSOC_CLKC_LEAF_CLK_EN7_SET, 0, CLK_UNIT_NOC_CLOCK, 0, &leaf7_gate_lock },
  1054. { 127, "vss_sdr", "gpum_sdr", 0, SIRFSOC_CLKC_LEAF_CLK_EN7_SET, 1, CLK_UNIT_NOC_CLOCK, 11, &leaf7_gate_lock },
  1055. { 128, "thgpum_nocr", "gpum_nocr", 0, SIRFSOC_CLKC_LEAF_CLK_EN7_SET, 2, 0, 0, &leaf7_gate_lock },
  1056. { 129, "a7ca_btss", "btm_btss", 0, SIRFSOC_CLKC_LEAF_CLK_EN8_SET, 1, 0, 0, &leaf8_gate_lock },
  1057. { 130, "dmac4_io", "a7ca_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN8_SET, 2, 0, 0, &leaf8_gate_lock },
  1058. { 131, "uart6_io", "dmac4_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN8_SET, 3, 0, 0, &leaf8_gate_lock },
  1059. { 132, "usp3_io", "dmac4_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN8_SET, 4, 0, 0, &leaf8_gate_lock },
  1060. { 133, "a7ca_io", "noc_btm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN8_SET, 5, 0, 0, &leaf8_gate_lock },
  1061. { 134, "noc_btm_io", "btm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN8_SET, 6, 0, 0, &leaf8_gate_lock },
  1062. { 135, "thbtm_io", "btm_io", 0, SIRFSOC_CLKC_LEAF_CLK_EN8_SET, 7, 0, 0, &leaf8_gate_lock },
  1063. { 136, "btslow", "xinw_fixdiv_btslow", 0, SIRFSOC_CLKC_ROOT_CLK_EN1_SET, 25, 0, 0, &root1_gate_lock },
  1064. { 137, "a7ca_btslow", "btslow", 0, SIRFSOC_CLKC_LEAF_CLK_EN8_SET, 0, 0, 0, &leaf8_gate_lock },
  1065. { 138, "pwm_io", "io_mux", 0, SIRFSOC_CLKC_LEAF_CLK_EN0_SET, 0, 0, 0, &leaf0_gate_lock },
  1066. { 139, "pwm_xin", "xin", 0, SIRFSOC_CLKC_LEAF_CLK_EN0_SET, 1, 0, 0, &leaf0_gate_lock },
  1067. { 140, "pwm_xinw", "xinw", 0, SIRFSOC_CLKC_LEAF_CLK_EN0_SET, 2, 0, 0, &leaf0_gate_lock },
  1068. { 141, "thcgum_sys", "sys_mux", 0, SIRFSOC_CLKC_LEAF_CLK_EN0_SET, 3, 0, 0, &leaf0_gate_lock },
  1069. };
  1070. static struct clk *atlas7_clks[ARRAY_SIZE(unit_list) + ARRAY_SIZE(mux_list)];
  1071. static int unit_clk_is_enabled(struct clk_hw *hw)
  1072. {
  1073. struct clk_unit *clk = to_unitclk(hw);
  1074. u32 reg;
  1075. reg = clk->regofs + SIRFSOC_CLKC_ROOT_CLK_EN0_STAT - SIRFSOC_CLKC_ROOT_CLK_EN0_SET;
  1076. return !!(clkc_readl(reg) & BIT(clk->bit));
  1077. }
  1078. static int unit_clk_enable(struct clk_hw *hw)
  1079. {
  1080. u32 reg;
  1081. struct clk_unit *clk = to_unitclk(hw);
  1082. unsigned long flags;
  1083. reg = clk->regofs;
  1084. spin_lock_irqsave(clk->lock, flags);
  1085. clkc_writel(BIT(clk->bit), reg);
  1086. if (clk->type == CLK_UNIT_NOC_CLOCK)
  1087. clkc_writel(BIT(clk->idle_bit), SIRFSOC_NOC_CLK_IDLEREQ_CLR);
  1088. else if (clk->type == CLK_UNIT_NOC_SOCKET)
  1089. clkc_writel(BIT(clk->idle_bit), SIRFSOC_NOC_CLK_SLVRDY_SET);
  1090. spin_unlock_irqrestore(clk->lock, flags);
  1091. return 0;
  1092. }
  1093. static void unit_clk_disable(struct clk_hw *hw)
  1094. {
  1095. u32 reg;
  1096. u32 i = 0;
  1097. struct clk_unit *clk = to_unitclk(hw);
  1098. unsigned long flags;
  1099. reg = clk->regofs + SIRFSOC_CLKC_ROOT_CLK_EN0_CLR - SIRFSOC_CLKC_ROOT_CLK_EN0_SET;
  1100. spin_lock_irqsave(clk->lock, flags);
  1101. if (clk->type == CLK_UNIT_NOC_CLOCK) {
  1102. clkc_writel(BIT(clk->idle_bit), SIRFSOC_NOC_CLK_IDLEREQ_SET);
  1103. while (!(clkc_readl(SIRFSOC_NOC_CLK_IDLE_STATUS) &
  1104. BIT(clk->idle_bit)) && (i++ < 100)) {
  1105. cpu_relax();
  1106. udelay(10);
  1107. }
  1108. if (i == 100) {
  1109. pr_err("unit NoC Clock disconnect Error:timeout\n");
  1110. /*once timeout, undo idlereq by CLR*/
  1111. clkc_writel(BIT(clk->idle_bit), SIRFSOC_NOC_CLK_IDLEREQ_CLR);
  1112. goto err;
  1113. }
  1114. } else if (clk->type == CLK_UNIT_NOC_SOCKET)
  1115. clkc_writel(BIT(clk->idle_bit), SIRFSOC_NOC_CLK_SLVRDY_CLR);
  1116. clkc_writel(BIT(clk->bit), reg);
  1117. err:
  1118. spin_unlock_irqrestore(clk->lock, flags);
  1119. }
  1120. static const struct clk_ops unit_clk_ops = {
  1121. .is_enabled = unit_clk_is_enabled,
  1122. .enable = unit_clk_enable,
  1123. .disable = unit_clk_disable,
  1124. };
  1125. static struct clk * __init
  1126. atlas7_unit_clk_register(struct device *dev, const char *name,
  1127. const char * const parent_name, unsigned long flags,
  1128. u32 regofs, u8 bit, u32 type, u8 idle_bit, spinlock_t *lock)
  1129. {
  1130. struct clk *clk;
  1131. struct clk_unit *unit;
  1132. struct clk_init_data init;
  1133. unit = kzalloc(sizeof(*unit), GFP_KERNEL);
  1134. if (!unit)
  1135. return ERR_PTR(-ENOMEM);
  1136. init.name = name;
  1137. init.parent_names = &parent_name;
  1138. init.num_parents = 1;
  1139. init.ops = &unit_clk_ops;
  1140. init.flags = flags;
  1141. unit->hw.init = &init;
  1142. unit->regofs = regofs;
  1143. unit->bit = bit;
  1144. unit->type = type;
  1145. unit->idle_bit = idle_bit;
  1146. unit->lock = lock;
  1147. clk = clk_register(dev, &unit->hw);
  1148. if (IS_ERR(clk))
  1149. kfree(unit);
  1150. return clk;
  1151. }
  1152. static struct atlas7_reset_desc atlas7_reset_unit[] = {
  1153. { "PWM", 0x0244, 0, 0x0320, 0, &leaf0_gate_lock }, /* 0-5 */
  1154. { "THCGUM", 0x0244, 3, 0x0320, 1, &leaf0_gate_lock },
  1155. { "CVD", 0x04A0, 0, 0x032C, 0, &leaf1_gate_lock },
  1156. { "TIMER", 0x04A0, 1, 0x032C, 1, &leaf1_gate_lock },
  1157. { "PULSEC", 0x04A0, 2, 0x032C, 2, &leaf1_gate_lock },
  1158. { "TSC", 0x04A0, 3, 0x032C, 3, &leaf1_gate_lock },
  1159. { "IOCTOP", 0x04A0, 4, 0x032C, 4, &leaf1_gate_lock }, /* 6-10 */
  1160. { "RSC", 0x04A0, 5, 0x032C, 5, &leaf1_gate_lock },
  1161. { "DVM", 0x04A0, 6, 0x032C, 6, &leaf1_gate_lock },
  1162. { "LVDS", 0x04A0, 7, 0x032C, 7, &leaf1_gate_lock },
  1163. { "KAS", 0x04A0, 8, 0x032C, 8, &leaf1_gate_lock },
  1164. { "AC97", 0x04A0, 9, 0x032C, 9, &leaf1_gate_lock }, /* 11-15 */
  1165. { "USP0", 0x04A0, 10, 0x032C, 10, &leaf1_gate_lock },
  1166. { "USP1", 0x04A0, 11, 0x032C, 11, &leaf1_gate_lock },
  1167. { "USP2", 0x04A0, 12, 0x032C, 12, &leaf1_gate_lock },
  1168. { "DMAC2", 0x04A0, 13, 0x032C, 13, &leaf1_gate_lock },
  1169. { "DMAC3", 0x04A0, 14, 0x032C, 14, &leaf1_gate_lock }, /* 16-20 */
  1170. { "AUDIO", 0x04A0, 15, 0x032C, 15, &leaf1_gate_lock },
  1171. { "I2S1", 0x04A0, 17, 0x032C, 16, &leaf1_gate_lock },
  1172. { "PMU_AUDIO", 0x04A0, 22, 0x032C, 17, &leaf1_gate_lock },
  1173. { "THAUDMSCM", 0x04A0, 23, 0x032C, 18, &leaf1_gate_lock },
  1174. { "SYS2PCI", 0x04B8, 0, 0x0338, 0, &leaf2_gate_lock }, /* 21-25 */
  1175. { "PCIARB", 0x04B8, 1, 0x0338, 1, &leaf2_gate_lock },
  1176. { "PCICOPY", 0x04B8, 2, 0x0338, 2, &leaf2_gate_lock },
  1177. { "ROM", 0x04B8, 3, 0x0338, 3, &leaf2_gate_lock },
  1178. { "SDIO23", 0x04B8, 4, 0x0338, 4, &leaf2_gate_lock },
  1179. { "SDIO45", 0x04B8, 5, 0x0338, 5, &leaf2_gate_lock }, /* 26-30 */
  1180. { "SDIO67", 0x04B8, 6, 0x0338, 6, &leaf2_gate_lock },
  1181. { "VIP1", 0x04B8, 7, 0x0338, 7, &leaf2_gate_lock },
  1182. { "VPP0", 0x04B8, 11, 0x0338, 8, &leaf2_gate_lock },
  1183. { "LCD0", 0x04B8, 12, 0x0338, 9, &leaf2_gate_lock },
  1184. { "VPP1", 0x04B8, 13, 0x0338, 10, &leaf2_gate_lock }, /* 31-35 */
  1185. { "LCD1", 0x04B8, 14, 0x0338, 11, &leaf2_gate_lock },
  1186. { "DCU", 0x04B8, 15, 0x0338, 12, &leaf2_gate_lock },
  1187. { "GPIO", 0x04B8, 18, 0x0338, 13, &leaf2_gate_lock },
  1188. { "DAPA_VDIFM", 0x04B8, 17, 0x0338, 15, &leaf2_gate_lock },
  1189. { "THVDIFM", 0x04B8, 19, 0x0338, 16, &leaf2_gate_lock }, /* 36-40 */
  1190. { "RGMII", 0x04D0, 0, 0x0344, 0, &leaf3_gate_lock },
  1191. { "GMAC", 0x04D0, 1, 0x0344, 1, &leaf3_gate_lock },
  1192. { "UART1", 0x04D0, 2, 0x0344, 2, &leaf3_gate_lock },
  1193. { "DMAC0", 0x04D0, 3, 0x0344, 3, &leaf3_gate_lock },
  1194. { "UART0", 0x04D0, 4, 0x0344, 4, &leaf3_gate_lock }, /* 41-45 */
  1195. { "UART2", 0x04D0, 5, 0x0344, 5, &leaf3_gate_lock },
  1196. { "UART3", 0x04D0, 6, 0x0344, 6, &leaf3_gate_lock },
  1197. { "UART4", 0x04D0, 7, 0x0344, 7, &leaf3_gate_lock },
  1198. { "UART5", 0x04D0, 8, 0x0344, 8, &leaf3_gate_lock },
  1199. { "SPI1", 0x04D0, 9, 0x0344, 9, &leaf3_gate_lock }, /* 46-50 */
  1200. { "GNSS_SYS_M0", 0x04D0, 10, 0x0344, 10, &leaf3_gate_lock },
  1201. { "CANBUS1", 0x04D0, 12, 0x0344, 11, &leaf3_gate_lock },
  1202. { "CCSEC", 0x04D0, 15, 0x0344, 12, &leaf3_gate_lock },
  1203. { "CCPUB", 0x04D0, 16, 0x0344, 13, &leaf3_gate_lock },
  1204. { "DAPA_GNSSM", 0x04D0, 13, 0x0344, 14, &leaf3_gate_lock }, /* 51-55 */
  1205. { "THGNSSM", 0x04D0, 14, 0x0344, 15, &leaf3_gate_lock },
  1206. { "VDEC", 0x04E8, 0, 0x0350, 0, &leaf4_gate_lock },
  1207. { "JPENC", 0x04E8, 1, 0x0350, 1, &leaf4_gate_lock },
  1208. { "G2D", 0x04E8, 2, 0x0350, 2, &leaf4_gate_lock },
  1209. { "I2C0", 0x04E8, 3, 0x0350, 3, &leaf4_gate_lock }, /* 56-60 */
  1210. { "I2C1", 0x04E8, 4, 0x0350, 4, &leaf4_gate_lock },
  1211. { "GPIO0", 0x04E8, 5, 0x0350, 5, &leaf4_gate_lock },
  1212. { "NAND", 0x04E8, 6, 0x0350, 6, &leaf4_gate_lock },
  1213. { "SDIO01", 0x04E8, 7, 0x0350, 7, &leaf4_gate_lock },
  1214. { "SYS2PCI2", 0x04E8, 8, 0x0350, 8, &leaf4_gate_lock }, /* 61-65 */
  1215. { "USB0", 0x04E8, 11, 0x0350, 9, &leaf4_gate_lock },
  1216. { "USB1", 0x04E8, 12, 0x0350, 10, &leaf4_gate_lock },
  1217. { "THMEDIAM", 0x04E8, 15, 0x0350, 11, &leaf4_gate_lock },
  1218. { "MEMC_DDRPHY", 0x0500, 0, 0x035C, 0, &leaf5_gate_lock },
  1219. { "MEMC_UPCTL", 0x0500, 0, 0x035C, 1, &leaf5_gate_lock }, /* 66-70 */
  1220. { "DAPA_MEM", 0x0500, 1, 0x035C, 2, &leaf5_gate_lock },
  1221. { "MEMC_MEMDIV", 0x0500, 0, 0x035C, 3, &leaf5_gate_lock },
  1222. { "THDDRM", 0x0500, 3, 0x035C, 4, &leaf5_gate_lock },
  1223. { "CORESIGHT", 0x0518, 3, 0x0368, 13, &leaf6_gate_lock },
  1224. { "THCPUM", 0x0518, 4, 0x0368, 17, &leaf6_gate_lock }, /* 71-75 */
  1225. { "GRAPHIC", 0x0530, 0, 0x0374, 0, &leaf7_gate_lock },
  1226. { "VSS_SDR", 0x0530, 1, 0x0374, 1, &leaf7_gate_lock },
  1227. { "THGPUM", 0x0530, 2, 0x0374, 2, &leaf7_gate_lock },
  1228. { "DMAC4", 0x0548, 2, 0x0380, 1, &leaf8_gate_lock },
  1229. { "UART6", 0x0548, 3, 0x0380, 2, &leaf8_gate_lock }, /* 76- */
  1230. { "USP3", 0x0548, 4, 0x0380, 3, &leaf8_gate_lock },
  1231. { "THBTM", 0x0548, 5, 0x0380, 5, &leaf8_gate_lock },
  1232. { "A7CA", 0x0548, 1, 0x0380, 0, &leaf8_gate_lock },
  1233. { "A7CA_APB", 0x0548, 5, 0x0380, 4, &leaf8_gate_lock },
  1234. };
  1235. static int atlas7_reset_module(struct reset_controller_dev *rcdev,
  1236. unsigned long reset_idx)
  1237. {
  1238. struct atlas7_reset_desc *reset = &atlas7_reset_unit[reset_idx];
  1239. unsigned long flags;
  1240. /*
  1241. * HW suggest unit reset sequence:
  1242. * assert sw reset (0)
  1243. * setting sw clk_en to if the clock was disabled before reset
  1244. * delay 16 clocks
  1245. * disable clock (sw clk_en = 0)
  1246. * de-assert reset (1)
  1247. * after this sequence, restore clock or not is decided by SW
  1248. */
  1249. spin_lock_irqsave(reset->lock, flags);
  1250. /* clock enable or not */
  1251. if (clkc_readl(reset->clk_ofs + 8) & (1 << reset->clk_bit)) {
  1252. clkc_writel(1 << reset->rst_bit, reset->rst_ofs + 4);
  1253. udelay(2);
  1254. clkc_writel(1 << reset->clk_bit, reset->clk_ofs + 4);
  1255. clkc_writel(1 << reset->rst_bit, reset->rst_ofs);
  1256. /* restore clock enable */
  1257. clkc_writel(1 << reset->clk_bit, reset->clk_ofs);
  1258. } else {
  1259. clkc_writel(1 << reset->rst_bit, reset->rst_ofs + 4);
  1260. clkc_writel(1 << reset->clk_bit, reset->clk_ofs);
  1261. udelay(2);
  1262. clkc_writel(1 << reset->clk_bit, reset->clk_ofs + 4);
  1263. clkc_writel(1 << reset->rst_bit, reset->rst_ofs);
  1264. }
  1265. spin_unlock_irqrestore(reset->lock, flags);
  1266. return 0;
  1267. }
  1268. static struct reset_control_ops atlas7_rst_ops = {
  1269. .reset = atlas7_reset_module,
  1270. };
  1271. static struct reset_controller_dev atlas7_rst_ctlr = {
  1272. .ops = &atlas7_rst_ops,
  1273. .owner = THIS_MODULE,
  1274. .of_reset_n_cells = 1,
  1275. };
  1276. static void __init atlas7_clk_init(struct device_node *np)
  1277. {
  1278. struct clk *clk;
  1279. struct atlas7_div_init_data *div;
  1280. struct atlas7_mux_init_data *mux;
  1281. struct atlas7_unit_init_data *unit;
  1282. int i;
  1283. int ret;
  1284. sirfsoc_clk_vbase = of_iomap(np, 0);
  1285. if (!sirfsoc_clk_vbase)
  1286. panic("unable to map clkc registers\n");
  1287. of_node_put(np);
  1288. clk = clk_register(NULL, &clk_cpupll.hw);
  1289. BUG_ON(!clk);
  1290. clk = clk_register(NULL, &clk_mempll.hw);
  1291. BUG_ON(!clk);
  1292. clk = clk_register(NULL, &clk_sys0pll.hw);
  1293. BUG_ON(!clk);
  1294. clk = clk_register(NULL, &clk_sys1pll.hw);
  1295. BUG_ON(!clk);
  1296. clk = clk_register(NULL, &clk_sys2pll.hw);
  1297. BUG_ON(!clk);
  1298. clk = clk_register(NULL, &clk_sys3pll.hw);
  1299. BUG_ON(!clk);
  1300. clk = clk_register_divider_table(NULL, "cpupll_div1", "cpupll_vco", 0,
  1301. sirfsoc_clk_vbase + SIRFSOC_CLKC_CPUPLL_AB_CTRL1, 0, 3, 0,
  1302. pll_div_table, &cpupll_ctrl1_lock);
  1303. BUG_ON(!clk);
  1304. clk = clk_register_divider_table(NULL, "cpupll_div2", "cpupll_vco", 0,
  1305. sirfsoc_clk_vbase + SIRFSOC_CLKC_CPUPLL_AB_CTRL1, 4, 3, 0,
  1306. pll_div_table, &cpupll_ctrl1_lock);
  1307. BUG_ON(!clk);
  1308. clk = clk_register_divider_table(NULL, "cpupll_div3", "cpupll_vco", 0,
  1309. sirfsoc_clk_vbase + SIRFSOC_CLKC_CPUPLL_AB_CTRL1, 8, 3, 0,
  1310. pll_div_table, &cpupll_ctrl1_lock);
  1311. BUG_ON(!clk);
  1312. clk = clk_register_divider_table(NULL, "mempll_div1", "mempll_vco", 0,
  1313. sirfsoc_clk_vbase + SIRFSOC_CLKC_MEMPLL_AB_CTRL1, 0, 3, 0,
  1314. pll_div_table, &mempll_ctrl1_lock);
  1315. BUG_ON(!clk);
  1316. clk = clk_register_divider_table(NULL, "mempll_div2", "mempll_vco", 0,
  1317. sirfsoc_clk_vbase + SIRFSOC_CLKC_MEMPLL_AB_CTRL1, 4, 3, 0,
  1318. pll_div_table, &mempll_ctrl1_lock);
  1319. BUG_ON(!clk);
  1320. clk = clk_register_divider_table(NULL, "mempll_div3", "mempll_vco", 0,
  1321. sirfsoc_clk_vbase + SIRFSOC_CLKC_MEMPLL_AB_CTRL1, 8, 3, 0,
  1322. pll_div_table, &mempll_ctrl1_lock);
  1323. BUG_ON(!clk);
  1324. clk = clk_register_divider_table(NULL, "sys0pll_div1", "sys0pll_vco", 0,
  1325. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS0PLL_AB_CTRL1, 0, 3, 0,
  1326. pll_div_table, &sys0pll_ctrl1_lock);
  1327. BUG_ON(!clk);
  1328. clk = clk_register_divider_table(NULL, "sys0pll_div2", "sys0pll_vco", 0,
  1329. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS0PLL_AB_CTRL1, 4, 3, 0,
  1330. pll_div_table, &sys0pll_ctrl1_lock);
  1331. BUG_ON(!clk);
  1332. clk = clk_register_divider_table(NULL, "sys0pll_div3", "sys0pll_vco", 0,
  1333. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS0PLL_AB_CTRL1, 8, 3, 0,
  1334. pll_div_table, &sys0pll_ctrl1_lock);
  1335. BUG_ON(!clk);
  1336. clk = clk_register_fixed_factor(NULL, "sys0pll_fixdiv", "sys0pll_vco",
  1337. CLK_SET_RATE_PARENT, 1, 2);
  1338. clk = clk_register_divider_table(NULL, "sys1pll_div1", "sys1pll_vco", 0,
  1339. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS1PLL_AB_CTRL1, 0, 3, 0,
  1340. pll_div_table, &sys1pll_ctrl1_lock);
  1341. BUG_ON(!clk);
  1342. clk = clk_register_divider_table(NULL, "sys1pll_div2", "sys1pll_vco", 0,
  1343. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS1PLL_AB_CTRL1, 4, 3, 0,
  1344. pll_div_table, &sys1pll_ctrl1_lock);
  1345. BUG_ON(!clk);
  1346. clk = clk_register_divider_table(NULL, "sys1pll_div3", "sys1pll_vco", 0,
  1347. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS1PLL_AB_CTRL1, 8, 3, 0,
  1348. pll_div_table, &sys1pll_ctrl1_lock);
  1349. BUG_ON(!clk);
  1350. clk = clk_register_fixed_factor(NULL, "sys1pll_fixdiv", "sys1pll_vco",
  1351. CLK_SET_RATE_PARENT, 1, 2);
  1352. clk = clk_register_divider_table(NULL, "sys2pll_div1", "sys2pll_vco", 0,
  1353. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS2PLL_AB_CTRL1, 0, 3, 0,
  1354. pll_div_table, &sys2pll_ctrl1_lock);
  1355. BUG_ON(!clk);
  1356. clk = clk_register_divider_table(NULL, "sys2pll_div2", "sys2pll_vco", 0,
  1357. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS2PLL_AB_CTRL1, 4, 3, 0,
  1358. pll_div_table, &sys2pll_ctrl1_lock);
  1359. BUG_ON(!clk);
  1360. clk = clk_register_divider_table(NULL, "sys2pll_div3", "sys2pll_vco", 0,
  1361. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS2PLL_AB_CTRL1, 8, 3, 0,
  1362. pll_div_table, &sys2pll_ctrl1_lock);
  1363. BUG_ON(!clk);
  1364. clk = clk_register_fixed_factor(NULL, "sys2pll_fixdiv", "sys2pll_vco",
  1365. CLK_SET_RATE_PARENT, 1, 2);
  1366. clk = clk_register_divider_table(NULL, "sys3pll_div1", "sys3pll_vco", 0,
  1367. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS3PLL_AB_CTRL1, 0, 3, 0,
  1368. pll_div_table, &sys3pll_ctrl1_lock);
  1369. BUG_ON(!clk);
  1370. clk = clk_register_divider_table(NULL, "sys3pll_div2", "sys3pll_vco", 0,
  1371. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS3PLL_AB_CTRL1, 4, 3, 0,
  1372. pll_div_table, &sys3pll_ctrl1_lock);
  1373. BUG_ON(!clk);
  1374. clk = clk_register_divider_table(NULL, "sys3pll_div3", "sys3pll_vco", 0,
  1375. sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS3PLL_AB_CTRL1, 8, 3, 0,
  1376. pll_div_table, &sys3pll_ctrl1_lock);
  1377. BUG_ON(!clk);
  1378. clk = clk_register_fixed_factor(NULL, "sys3pll_fixdiv", "sys3pll_vco",
  1379. CLK_SET_RATE_PARENT, 1, 2);
  1380. BUG_ON(!clk);
  1381. clk = clk_register_fixed_factor(NULL, "xinw_fixdiv_btslow", "xinw",
  1382. CLK_SET_RATE_PARENT, 1, 4);
  1383. BUG_ON(!clk);
  1384. clk = clk_register_gate(NULL, "cpupll_clk1", "cpupll_div1",
  1385. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_CPUPLL_AB_CTRL1,
  1386. 12, 0, &cpupll_ctrl1_lock);
  1387. BUG_ON(!clk);
  1388. clk = clk_register_gate(NULL, "cpupll_clk2", "cpupll_div2",
  1389. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_CPUPLL_AB_CTRL1,
  1390. 13, 0, &cpupll_ctrl1_lock);
  1391. BUG_ON(!clk);
  1392. clk = clk_register_gate(NULL, "cpupll_clk3", "cpupll_div3",
  1393. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_CPUPLL_AB_CTRL1,
  1394. 14, 0, &cpupll_ctrl1_lock);
  1395. BUG_ON(!clk);
  1396. clk = clk_register_gate(NULL, "mempll_clk1", "mempll_div1",
  1397. CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
  1398. sirfsoc_clk_vbase + SIRFSOC_CLKC_MEMPLL_AB_CTRL1,
  1399. 12, 0, &mempll_ctrl1_lock);
  1400. BUG_ON(!clk);
  1401. clk = clk_register_gate(NULL, "mempll_clk2", "mempll_div2",
  1402. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_MEMPLL_AB_CTRL1,
  1403. 13, 0, &mempll_ctrl1_lock);
  1404. BUG_ON(!clk);
  1405. clk = clk_register_gate(NULL, "mempll_clk3", "mempll_div3",
  1406. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_MEMPLL_AB_CTRL1,
  1407. 14, 0, &mempll_ctrl1_lock);
  1408. BUG_ON(!clk);
  1409. clk = clk_register_gate(NULL, "sys0pll_clk1", "sys0pll_div1",
  1410. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS0PLL_AB_CTRL1,
  1411. 12, 0, &sys0pll_ctrl1_lock);
  1412. BUG_ON(!clk);
  1413. clk = clk_register_gate(NULL, "sys0pll_clk2", "sys0pll_div2",
  1414. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS0PLL_AB_CTRL1,
  1415. 13, 0, &sys0pll_ctrl1_lock);
  1416. BUG_ON(!clk);
  1417. clk = clk_register_gate(NULL, "sys0pll_clk3", "sys0pll_div3",
  1418. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS0PLL_AB_CTRL1,
  1419. 14, 0, &sys0pll_ctrl1_lock);
  1420. BUG_ON(!clk);
  1421. clk = clk_register_gate(NULL, "sys1pll_clk1", "sys1pll_div1",
  1422. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS1PLL_AB_CTRL1,
  1423. 12, 0, &sys1pll_ctrl1_lock);
  1424. BUG_ON(!clk);
  1425. clk = clk_register_gate(NULL, "sys1pll_clk2", "sys1pll_div2",
  1426. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS1PLL_AB_CTRL1,
  1427. 13, 0, &sys1pll_ctrl1_lock);
  1428. BUG_ON(!clk);
  1429. clk = clk_register_gate(NULL, "sys1pll_clk3", "sys1pll_div3",
  1430. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS1PLL_AB_CTRL1,
  1431. 14, 0, &sys1pll_ctrl1_lock);
  1432. BUG_ON(!clk);
  1433. clk = clk_register_gate(NULL, "sys2pll_clk1", "sys2pll_div1",
  1434. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS2PLL_AB_CTRL1,
  1435. 12, 0, &sys2pll_ctrl1_lock);
  1436. BUG_ON(!clk);
  1437. clk = clk_register_gate(NULL, "sys2pll_clk2", "sys2pll_div2",
  1438. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS2PLL_AB_CTRL1,
  1439. 13, 0, &sys2pll_ctrl1_lock);
  1440. BUG_ON(!clk);
  1441. clk = clk_register_gate(NULL, "sys2pll_clk3", "sys2pll_div3",
  1442. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS2PLL_AB_CTRL1,
  1443. 14, 0, &sys2pll_ctrl1_lock);
  1444. BUG_ON(!clk);
  1445. clk = clk_register_gate(NULL, "sys3pll_clk1", "sys3pll_div1",
  1446. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS3PLL_AB_CTRL1,
  1447. 12, 0, &sys3pll_ctrl1_lock);
  1448. BUG_ON(!clk);
  1449. clk = clk_register_gate(NULL, "sys3pll_clk2", "sys3pll_div2",
  1450. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS3PLL_AB_CTRL1,
  1451. 13, 0, &sys3pll_ctrl1_lock);
  1452. BUG_ON(!clk);
  1453. clk = clk_register_gate(NULL, "sys3pll_clk3", "sys3pll_div3",
  1454. CLK_SET_RATE_PARENT, sirfsoc_clk_vbase + SIRFSOC_CLKC_SYS3PLL_AB_CTRL1,
  1455. 14, 0, &sys3pll_ctrl1_lock);
  1456. BUG_ON(!clk);
  1457. clk = clk_register(NULL, &clk_audio_dto.hw);
  1458. BUG_ON(!clk);
  1459. clk = clk_register(NULL, &clk_disp0_dto.hw);
  1460. BUG_ON(!clk);
  1461. clk = clk_register(NULL, &clk_disp1_dto.hw);
  1462. BUG_ON(!clk);
  1463. for (i = 0; i < ARRAY_SIZE(divider_list); i++) {
  1464. div = &divider_list[i];
  1465. clk = clk_register_divider(NULL, div->div_name,
  1466. div->parent_name, div->divider_flags, sirfsoc_clk_vbase + div->div_offset,
  1467. div->shift, div->width, 0, div->lock);
  1468. BUG_ON(!clk);
  1469. clk = clk_register_gate(NULL, div->gate_name, div->div_name,
  1470. div->gate_flags, sirfsoc_clk_vbase + div->gate_offset,
  1471. div->gate_bit, 0, div->lock);
  1472. BUG_ON(!clk);
  1473. }
  1474. /* ignore selector status register check */
  1475. for (i = 0; i < ARRAY_SIZE(mux_list); i++) {
  1476. mux = &mux_list[i];
  1477. clk = clk_register_mux(NULL, mux->mux_name, mux->parent_names,
  1478. mux->parent_num, mux->flags,
  1479. sirfsoc_clk_vbase + mux->mux_offset,
  1480. mux->shift, mux->width,
  1481. mux->mux_flags, NULL);
  1482. atlas7_clks[ARRAY_SIZE(unit_list) + i] = clk;
  1483. BUG_ON(!clk);
  1484. }
  1485. for (i = 0; i < ARRAY_SIZE(unit_list); i++) {
  1486. unit = &unit_list[i];
  1487. atlas7_clks[i] = atlas7_unit_clk_register(NULL, unit->unit_name, unit->parent_name,
  1488. unit->flags, unit->regofs, unit->bit, unit->type, unit->idle_bit, unit->lock);
  1489. BUG_ON(!atlas7_clks[i]);
  1490. }
  1491. clk_data.clks = atlas7_clks;
  1492. clk_data.clk_num = ARRAY_SIZE(unit_list) + ARRAY_SIZE(mux_list);
  1493. ret = of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
  1494. BUG_ON(ret);
  1495. atlas7_rst_ctlr.of_node = np;
  1496. atlas7_rst_ctlr.nr_resets = ARRAY_SIZE(atlas7_reset_unit);
  1497. reset_controller_register(&atlas7_rst_ctlr);
  1498. }
  1499. CLK_OF_DECLARE(atlas7_clk, "sirf,atlas7-car", atlas7_clk_init);