clk-mt7986.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * MediaTek clock driver for MT7986 SoC
  4. *
  5. * Copyright (C) 2022 MediaTek Inc.
  6. * Author: Sam Shih <sam.shih@mediatek.com>
  7. */
  8. #include <dm.h>
  9. #include <log.h>
  10. #include <asm/arch-mediatek/reset.h>
  11. #include <asm/io.h>
  12. #include <dt-bindings/clock/mt7986-clk.h>
  13. #include <linux/bitops.h>
  14. #include "clk-mtk.h"
  15. #define MT7986_CLK_PDN 0x250
  16. #define MT7986_CLK_PDN_EN_WRITE BIT(31)
  17. #define PLL_FACTOR(_id, _name, _parent, _mult, _div) \
  18. FACTOR(_id, _parent, _mult, _div, CLK_PARENT_APMIXED)
  19. #define TOP_FACTOR(_id, _name, _parent, _mult, _div) \
  20. FACTOR(_id, _parent, _mult, _div, CLK_PARENT_TOPCKGEN)
  21. #define INFRA_FACTOR(_id, _name, _parent, _mult, _div) \
  22. FACTOR(_id, _parent, _mult, _div, CLK_PARENT_INFRASYS)
  23. /* FIXED PLLS */
  24. static const struct mtk_fixed_clk fixed_pll_clks[] = {
  25. FIXED_CLK(CK_APMIXED_ARMPLL, CLK_XTAL, 2000000000),
  26. FIXED_CLK(CK_APMIXED_NET2PLL, CLK_XTAL, 800000000),
  27. FIXED_CLK(CK_APMIXED_MMPLL, CLK_XTAL, 1440000000),
  28. FIXED_CLK(CK_APMIXED_SGMPLL, CLK_XTAL, 325000000),
  29. FIXED_CLK(CK_APMIXED_WEDMCUPLL, CLK_XTAL, 760000000),
  30. FIXED_CLK(CK_APMIXED_NET1PLL, CLK_XTAL, 2500000000),
  31. FIXED_CLK(CK_APMIXED_MPLL, CLK_XTAL, 416000000),
  32. FIXED_CLK(CK_APMIXED_APLL2, CLK_XTAL, 196608000),
  33. };
  34. /* TOPCKGEN FIXED CLK */
  35. static const struct mtk_fixed_clk top_fixed_clks[] = {
  36. FIXED_CLK(CK_TOP_CB_CKSQ_40M, CLK_XTAL, 40000000),
  37. };
  38. /* TOPCKGEN FIXED DIV */
  39. static const struct mtk_fixed_factor top_fixed_divs[] = {
  40. PLL_FACTOR(CK_TOP_CB_M_416M, "cb_m_416m", CK_APMIXED_MPLL, 1, 1),
  41. PLL_FACTOR(CK_TOP_CB_M_D2, "cb_m_d2", CK_APMIXED_MPLL, 1, 2),
  42. PLL_FACTOR(CK_TOP_CB_M_D4, "cb_m_d4", CK_APMIXED_MPLL, 1, 4),
  43. PLL_FACTOR(CK_TOP_CB_M_D8, "cb_m_d8", CK_APMIXED_MPLL, 1, 8),
  44. PLL_FACTOR(CK_TOP_M_D8_D2, "m_d8_d2", CK_APMIXED_MPLL, 1, 16),
  45. PLL_FACTOR(CK_TOP_M_D3_D2, "m_d3_d2", CK_APMIXED_MPLL, 1, 2),
  46. PLL_FACTOR(CK_TOP_CB_MM_D2, "cb_mm_d2", CK_APMIXED_MMPLL, 1, 2),
  47. PLL_FACTOR(CK_TOP_CB_MM_D4, "cb_mm_d4", CK_APMIXED_MMPLL, 1, 4),
  48. PLL_FACTOR(CK_TOP_CB_MM_D8, "cb_mm_d8", CK_APMIXED_MMPLL, 1, 8),
  49. PLL_FACTOR(CK_TOP_MM_D8_D2, "mm_d8_d2", CK_APMIXED_MMPLL, 1, 16),
  50. PLL_FACTOR(CK_TOP_MM_D3_D8, "mm_d3_d8", CK_APMIXED_MMPLL, 1, 8),
  51. PLL_FACTOR(CK_TOP_CB_U2_PHYD_CK, "cb_u2_phyd", CK_APMIXED_MMPLL, 1, 30),
  52. PLL_FACTOR(CK_TOP_CB_APLL2_196M, "cb_apll2_196m", CK_APMIXED_APLL2, 1,
  53. 1),
  54. PLL_FACTOR(CK_TOP_APLL2_D4, "apll2_d4", CK_APMIXED_APLL2, 1, 4),
  55. PLL_FACTOR(CK_TOP_CB_NET1_D4, "cb_net1_d4", CK_APMIXED_NET1PLL, 1, 4),
  56. PLL_FACTOR(CK_TOP_CB_NET1_D5, "cb_net1_d5", CK_APMIXED_NET1PLL, 1, 5),
  57. PLL_FACTOR(CK_TOP_NET1_D5_D2, "net1_d5_d2", CK_APMIXED_NET1PLL, 1, 10),
  58. PLL_FACTOR(CK_TOP_NET1_D5_D4, "net1_d5_d4", CK_APMIXED_NET1PLL, 1, 20),
  59. PLL_FACTOR(CK_TOP_NET1_D8_D2, "net1_d8_d2", CK_APMIXED_NET1PLL, 1, 16),
  60. PLL_FACTOR(CK_TOP_NET1_D8_D4, "net1_d8_d4", CK_APMIXED_NET1PLL, 1, 32),
  61. PLL_FACTOR(CK_TOP_CB_NET2_800M, "cb_net2_800m", CK_APMIXED_NET2PLL, 1,
  62. 1),
  63. PLL_FACTOR(CK_TOP_CB_NET2_D4, "cb_net2_d4", CK_APMIXED_NET2PLL, 1, 4),
  64. PLL_FACTOR(CK_TOP_NET2_D4_D2, "net2_d4_d2", CK_APMIXED_NET2PLL, 1, 8),
  65. PLL_FACTOR(CK_TOP_NET2_D3_D2, "net2_d3_d2", CK_APMIXED_NET2PLL, 1, 2),
  66. PLL_FACTOR(CK_TOP_CB_WEDMCU_760M, "cb_wedmcu_760m",
  67. CK_APMIXED_WEDMCUPLL, 1, 1),
  68. PLL_FACTOR(CK_TOP_WEDMCU_D5_D2, "wedmcu_d5_d2", CK_APMIXED_WEDMCUPLL, 1,
  69. 10),
  70. PLL_FACTOR(CK_TOP_CB_SGM_325M, "cb_sgm_325m", CK_APMIXED_SGMPLL, 1, 1),
  71. TOP_FACTOR(CK_TOP_CB_CKSQ_40M_D2, "cb_cksq_40m_d2", CK_TOP_CB_CKSQ_40M,
  72. 1, 2),
  73. TOP_FACTOR(CK_TOP_CB_RTC_32K, "cb_rtc_32k", CK_TOP_CB_CKSQ_40M, 1,
  74. 1250),
  75. TOP_FACTOR(CK_TOP_CB_RTC_32P7K, "cb_rtc_32p7k", CK_TOP_CB_CKSQ_40M, 1,
  76. 1220),
  77. TOP_FACTOR(CK_TOP_NFI1X, "nfi1x", CK_TOP_NFI1X_SEL, 1, 1),
  78. TOP_FACTOR(CK_TOP_USB_EQ_RX250M, "usb_eq_rx250m", CK_TOP_CB_CKSQ_40M, 1,
  79. 1),
  80. TOP_FACTOR(CK_TOP_USB_TX250M, "usb_tx250m", CK_TOP_CB_CKSQ_40M, 1, 1),
  81. TOP_FACTOR(CK_TOP_USB_LN0_CK, "usb_ln0", CK_TOP_CB_CKSQ_40M, 1, 1),
  82. TOP_FACTOR(CK_TOP_USB_CDR_CK, "usb_cdr", CK_TOP_CB_CKSQ_40M, 1, 1),
  83. TOP_FACTOR(CK_TOP_SPINFI_BCK, "spinfi_bck", CK_TOP_SPINFI_SEL, 1, 1),
  84. TOP_FACTOR(CK_TOP_I2C_BCK, "i2c_bck", CK_TOP_I2C_SEL, 1, 1),
  85. TOP_FACTOR(CK_TOP_PEXTP_TL, "pextp_tl", CK_TOP_PEXTP_TL_SEL, 1, 1),
  86. TOP_FACTOR(CK_TOP_EMMC_250M, "emmc_250m", CK_TOP_EMMC_250M_SEL, 1, 1),
  87. TOP_FACTOR(CK_TOP_EMMC_416M, "emmc_416m", CK_TOP_EMMC_416M_SEL, 1, 1),
  88. TOP_FACTOR(CK_TOP_F_26M_ADC_CK, "f_26m_adc", CK_TOP_F_26M_ADC_SEL, 1,
  89. 1),
  90. TOP_FACTOR(CK_TOP_SYSAXI, "sysaxi", CK_TOP_SYSAXI_SEL, 1, 1),
  91. TOP_FACTOR(CK_TOP_NETSYS_WED_MCU, "netsys_wed_mcu",
  92. CK_TOP_NETSYS_MCU_SEL, 1, 1),
  93. TOP_FACTOR(CK_TOP_NETSYS_2X, "netsys_2x", CK_TOP_NETSYS_2X_SEL, 1, 1),
  94. TOP_FACTOR(CK_TOP_SGM_325M, "sgm_325m", CK_TOP_SGM_325M_SEL, 1, 1),
  95. TOP_FACTOR(CK_TOP_A1SYS, "a1sys", CK_TOP_A1SYS_SEL, 1, 1),
  96. TOP_FACTOR(CK_TOP_EIP_B, "eip_b", CK_TOP_EIP_B_SEL, 1, 1),
  97. TOP_FACTOR(CK_TOP_F26M, "csw_f26m", CK_TOP_F26M_SEL, 1, 1),
  98. TOP_FACTOR(CK_TOP_AUD_L, "aud_l", CK_TOP_AUD_L_SEL, 1, 1),
  99. TOP_FACTOR(CK_TOP_A_TUNER, "a_tuner", CK_TOP_A_TUNER_SEL, 2, 1),
  100. TOP_FACTOR(CK_TOP_U2U3_REF, "u2u3_ref", CK_TOP_U2U3_SEL, 1, 1),
  101. TOP_FACTOR(CK_TOP_U2U3_SYS, "u2u3_sys", CK_TOP_U2U3_SYS_SEL, 1, 1),
  102. TOP_FACTOR(CK_TOP_U2U3_XHCI, "u2u3_xhci", CK_TOP_U2U3_XHCI_SEL, 1, 1),
  103. TOP_FACTOR(CK_TOP_AP2CNN_HOST, "ap2cnn_host", CK_TOP_AP2CNN_HOST_SEL, 1,
  104. 1),
  105. };
  106. /* TOPCKGEN MUX PARENTS */
  107. static const int nfi1x_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_MM_D8,
  108. CK_TOP_NET1_D8_D2, CK_TOP_NET2_D3_D2,
  109. CK_TOP_CB_M_D4, CK_TOP_MM_D8_D2,
  110. CK_TOP_WEDMCU_D5_D2, CK_TOP_CB_M_D8 };
  111. static const int spinfi_parents[] = {
  112. CK_TOP_CB_CKSQ_40M_D2, CK_TOP_CB_CKSQ_40M, CK_TOP_NET1_D5_D4,
  113. CK_TOP_CB_M_D4, CK_TOP_MM_D8_D2, CK_TOP_WEDMCU_D5_D2,
  114. CK_TOP_MM_D3_D8, CK_TOP_CB_M_D8
  115. };
  116. static const int spi_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_M_D2,
  117. CK_TOP_CB_MM_D8, CK_TOP_NET1_D8_D2,
  118. CK_TOP_NET2_D3_D2, CK_TOP_NET1_D5_D4,
  119. CK_TOP_CB_M_D4, CK_TOP_WEDMCU_D5_D2 };
  120. static const int uart_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_M_D8,
  121. CK_TOP_M_D8_D2 };
  122. static const int pwm_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_NET1_D8_D2,
  123. CK_TOP_NET1_D5_D4, CK_TOP_CB_M_D4 };
  124. static const int i2c_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_NET1_D5_D4,
  125. CK_TOP_CB_M_D4, CK_TOP_NET1_D8_D4 };
  126. static const int pextp_tl_ck_parents[] = { CK_TOP_CB_CKSQ_40M,
  127. CK_TOP_NET1_D5_D4, CK_TOP_NET2_D4_D2,
  128. CK_TOP_CB_RTC_32K };
  129. static const int emmc_250m_parents[] = { CK_TOP_CB_CKSQ_40M,
  130. CK_TOP_NET1_D5_D2 };
  131. static const int emmc_416m_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_M_416M };
  132. static const int f_26m_adc_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_M_D8_D2 };
  133. static const int dramc_md32_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_M_D2 };
  134. static const int sysaxi_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_NET1_D8_D2,
  135. CK_TOP_CB_NET2_D4 };
  136. static const int sysapb_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_M_D3_D2,
  137. CK_TOP_NET2_D4_D2 };
  138. static const int arm_db_main_parents[] = { CK_TOP_CB_CKSQ_40M,
  139. CK_TOP_NET2_D3_D2 };
  140. static const int arm_db_jtsel_parents[] = { -1, CK_TOP_CB_CKSQ_40M };
  141. static const int netsys_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_MM_D4 };
  142. static const int netsys_500m_parents[] = { CK_TOP_CB_CKSQ_40M,
  143. CK_TOP_CB_NET1_D5 };
  144. static const int netsys_mcu_parents[] = { CK_TOP_CB_CKSQ_40M,
  145. CK_TOP_CB_WEDMCU_760M,
  146. CK_TOP_CB_MM_D2, CK_TOP_CB_NET1_D4,
  147. CK_TOP_CB_NET1_D5 };
  148. static const int netsys_2x_parents[] = { CK_TOP_CB_CKSQ_40M,
  149. CK_TOP_CB_NET2_800M,
  150. CK_TOP_CB_WEDMCU_760M,
  151. CK_TOP_CB_MM_D2 };
  152. static const int sgm_325m_parents[] = { CK_TOP_CB_CKSQ_40M,
  153. CK_TOP_CB_SGM_325M };
  154. static const int sgm_reg_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_NET1_D8_D4 };
  155. static const int a1sys_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_APLL2_D4 };
  156. static const int conn_mcusys_parents[] = { CK_TOP_CB_CKSQ_40M,
  157. CK_TOP_CB_MM_D2 };
  158. static const int eip_b_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_NET2_800M };
  159. static const int aud_l_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_CB_APLL2_196M,
  160. CK_TOP_M_D8_D2 };
  161. static const int a_tuner_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_APLL2_D4,
  162. CK_TOP_M_D8_D2 };
  163. static const int u2u3_sys_parents[] = { CK_TOP_CB_CKSQ_40M, CK_TOP_NET1_D5_D4 };
  164. static const int da_u2_refsel_parents[] = { CK_TOP_CB_CKSQ_40M,
  165. CK_TOP_CB_U2_PHYD_CK };
  166. #define TOP_MUX(_id, _name, _parents, _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \
  167. _shift, _width, _gate, _upd_ofs, _upd) \
  168. { \
  169. .id = _id, .mux_reg = _mux_ofs, .mux_set_reg = _mux_set_ofs, \
  170. .mux_clr_reg = _mux_clr_ofs, .upd_reg = _upd_ofs, \
  171. .upd_shift = _upd, .mux_shift = _shift, \
  172. .mux_mask = BIT(_width) - 1, .gate_reg = _mux_ofs, \
  173. .gate_shift = _gate, .parent = _parents, \
  174. .num_parents = ARRAY_SIZE(_parents), \
  175. .flags = CLK_MUX_SETCLR_UPD, \
  176. }
  177. /* TOPCKGEN MUX_GATE */
  178. static const struct mtk_composite top_muxes[] = {
  179. /* CLK_CFG_0 */
  180. TOP_MUX(CK_TOP_NFI1X_SEL, "nfi1x_sel", nfi1x_parents, 0x000, 0x004,
  181. 0x008, 0, 3, 7, 0x1C0, 0),
  182. TOP_MUX(CK_TOP_SPINFI_SEL, "spinfi_sel", spinfi_parents, 0x000, 0x004,
  183. 0x008, 8, 3, 15, 0x1C0, 1),
  184. TOP_MUX(CK_TOP_SPI_SEL, "spi_sel", spi_parents, 0x000, 0x004, 0x008, 16,
  185. 3, 23, 0x1C0, 2),
  186. TOP_MUX(CK_TOP_SPIM_MST_SEL, "spim_mst_sel", spi_parents, 0x000, 0x004,
  187. 0x008, 24, 3, 31, 0x1C0, 3),
  188. /* CLK_CFG_1 */
  189. TOP_MUX(CK_TOP_UART_SEL, "uart_sel", uart_parents, 0x010, 0x014, 0x018,
  190. 0, 2, 7, 0x1C0, 4),
  191. TOP_MUX(CK_TOP_PWM_SEL, "pwm_sel", pwm_parents, 0x010, 0x014, 0x018, 8,
  192. 2, 15, 0x1C0, 5),
  193. TOP_MUX(CK_TOP_I2C_SEL, "i2c_sel", i2c_parents, 0x010, 0x014, 0x018, 16,
  194. 2, 23, 0x1C0, 6),
  195. TOP_MUX(CK_TOP_PEXTP_TL_SEL, "pextp_tl_ck_sel", pextp_tl_ck_parents,
  196. 0x010, 0x014, 0x018, 24, 2, 31, 0x1C0, 7),
  197. /* CLK_CFG_2 */
  198. TOP_MUX(CK_TOP_EMMC_250M_SEL, "emmc_250m_sel", emmc_250m_parents, 0x020,
  199. 0x024, 0x028, 0, 1, 7, 0x1C0, 8),
  200. TOP_MUX(CK_TOP_EMMC_416M_SEL, "emmc_416m_sel", emmc_416m_parents, 0x020,
  201. 0x024, 0x028, 8, 1, 15, 0x1C0, 9),
  202. TOP_MUX(CK_TOP_F_26M_ADC_SEL, "f_26m_adc_sel", f_26m_adc_parents, 0x020,
  203. 0x024, 0x028, 16, 1, 23, 0x1C0, 10),
  204. TOP_MUX(CK_TOP_DRAMC_SEL, "dramc_sel", f_26m_adc_parents, 0x020, 0x024,
  205. 0x028, 24, 1, 31, 0x1C0, 11),
  206. /* CLK_CFG_3 */
  207. TOP_MUX(CK_TOP_DRAMC_MD32_SEL, "dramc_md32_sel", dramc_md32_parents,
  208. 0x030, 0x034, 0x038, 0, 1, 7, 0x1C0, 12),
  209. TOP_MUX(CK_TOP_SYSAXI_SEL, "sysaxi_sel", sysaxi_parents, 0x030, 0x034,
  210. 0x038, 8, 2, 15, 0x1C0, 13),
  211. TOP_MUX(CK_TOP_SYSAPB_SEL, "sysapb_sel", sysapb_parents, 0x030, 0x034,
  212. 0x038, 16, 2, 23, 0x1C0, 14),
  213. TOP_MUX(CK_TOP_ARM_DB_MAIN_SEL, "arm_db_main_sel", arm_db_main_parents,
  214. 0x030, 0x034, 0x038, 24, 1, 31, 0x1C0, 15),
  215. /* CLK_CFG_4 */
  216. TOP_MUX(CK_TOP_ARM_DB_JTSEL, "arm_db_jtsel", arm_db_jtsel_parents,
  217. 0x040, 0x044, 0x048, 0, 1, 7, 0x1C0, 16),
  218. TOP_MUX(CK_TOP_NETSYS_SEL, "netsys_sel", netsys_parents, 0x040, 0x044,
  219. 0x048, 8, 1, 15, 0x1C0, 17),
  220. TOP_MUX(CK_TOP_NETSYS_500M_SEL, "netsys_500m_sel", netsys_500m_parents,
  221. 0x040, 0x044, 0x048, 16, 1, 23, 0x1C0, 18),
  222. TOP_MUX(CK_TOP_NETSYS_MCU_SEL, "netsys_mcu_sel", netsys_mcu_parents,
  223. 0x040, 0x044, 0x048, 24, 3, 31, 0x1C0, 19),
  224. /* CLK_CFG_5 */
  225. TOP_MUX(CK_TOP_NETSYS_2X_SEL, "netsys_2x_sel", netsys_2x_parents, 0x050,
  226. 0x054, 0x058, 0, 2, 7, 0x1C0, 20),
  227. TOP_MUX(CK_TOP_SGM_325M_SEL, "sgm_325m_sel", sgm_325m_parents, 0x050,
  228. 0x054, 0x058, 8, 1, 15, 0x1C0, 21),
  229. TOP_MUX(CK_TOP_SGM_REG_SEL, "sgm_reg_sel", sgm_reg_parents, 0x050,
  230. 0x054, 0x058, 16, 1, 23, 0x1C0, 22),
  231. TOP_MUX(CK_TOP_A1SYS_SEL, "a1sys_sel", a1sys_parents, 0x050, 0x054,
  232. 0x058, 24, 1, 31, 0x1C0, 23),
  233. /* CLK_CFG_6 */
  234. TOP_MUX(CK_TOP_CONN_MCUSYS_SEL, "conn_mcusys_sel", conn_mcusys_parents,
  235. 0x060, 0x064, 0x068, 0, 1, 7, 0x1C0, 24),
  236. TOP_MUX(CK_TOP_EIP_B_SEL, "eip_b_sel", eip_b_parents, 0x060, 0x064,
  237. 0x068, 8, 1, 15, 0x1C0, 25),
  238. TOP_MUX(CK_TOP_PCIE_PHY_SEL, "pcie_phy_sel", f_26m_adc_parents, 0x060,
  239. 0x064, 0x068, 16, 1, 23, 0x1C0, 26),
  240. TOP_MUX(CK_TOP_USB3_PHY_SEL, "usb3_phy_sel", f_26m_adc_parents, 0x060,
  241. 0x064, 0x068, 24, 1, 31, 0x1C0, 27),
  242. /* CLK_CFG_7 */
  243. TOP_MUX(CK_TOP_F26M_SEL, "csw_f26m_sel", f_26m_adc_parents, 0x070,
  244. 0x074, 0x078, 0, 1, 7, 0x1C0, 28),
  245. TOP_MUX(CK_TOP_AUD_L_SEL, "aud_l_sel", aud_l_parents, 0x070, 0x074,
  246. 0x078, 8, 2, 15, 0x1C0, 29),
  247. TOP_MUX(CK_TOP_A_TUNER_SEL, "a_tuner_sel", a_tuner_parents, 0x070,
  248. 0x074, 0x078, 16, 2, 23, 0x1C0, 30),
  249. TOP_MUX(CK_TOP_U2U3_SEL, "u2u3_sel", f_26m_adc_parents, 0x070, 0x074,
  250. 0x078, 24, 1, 31, 0x1C4, 0),
  251. /* CLK_CFG_8 */
  252. TOP_MUX(CK_TOP_U2U3_SYS_SEL, "u2u3_sys_sel", u2u3_sys_parents, 0x080,
  253. 0x084, 0x088, 0, 1, 7, 0x1C4, 1),
  254. TOP_MUX(CK_TOP_U2U3_XHCI_SEL, "u2u3_xhci_sel", u2u3_sys_parents, 0x080,
  255. 0x084, 0x088, 8, 1, 15, 0x1C4, 2),
  256. TOP_MUX(CK_TOP_DA_U2_REFSEL, "da_u2_refsel", da_u2_refsel_parents,
  257. 0x080, 0x084, 0x088, 16, 1, 23, 0x1C4, 3),
  258. TOP_MUX(CK_TOP_DA_U2_CK_1P_SEL, "da_u2_ck_1p_sel", da_u2_refsel_parents,
  259. 0x080, 0x084, 0x088, 24, 1, 31, 0x1C4, 4),
  260. /* CLK_CFG_9 */
  261. TOP_MUX(CK_TOP_AP2CNN_HOST_SEL, "ap2cnn_host_sel", sgm_reg_parents,
  262. 0x090, 0x094, 0x098, 0, 1, 7, 0x1C4, 5),
  263. };
  264. /* INFRA FIXED DIV */
  265. static const struct mtk_fixed_factor infra_fixed_divs[] = {
  266. TOP_FACTOR(CK_INFRA_CK_F26M, "infra_ck_f26m", CK_TOP_F26M_SEL, 1, 1),
  267. TOP_FACTOR(CK_INFRA_UART, "infra_uart", CK_TOP_UART_SEL, 1, 1),
  268. TOP_FACTOR(CK_INFRA_ISPI0, "infra_ispi0", CK_TOP_SPI_SEL, 1, 1),
  269. TOP_FACTOR(CK_INFRA_I2C, "infra_i2c", CK_TOP_I2C_SEL, 1, 1),
  270. TOP_FACTOR(CK_INFRA_ISPI1, "infra_ispi1", CK_TOP_SPINFI_SEL, 1, 1),
  271. TOP_FACTOR(CK_INFRA_PWM, "infra_pwm", CK_TOP_PWM_SEL, 1, 1),
  272. TOP_FACTOR(CK_INFRA_66M_MCK, "infra_66m_mck", CK_TOP_SYSAXI_SEL, 1, 2),
  273. TOP_FACTOR(CK_INFRA_CK_F32K, "infra_ck_f32k", CK_TOP_CB_RTC_32P7K, 1,
  274. 1),
  275. TOP_FACTOR(CK_INFRA_PCIE_CK, "infra_pcie", CK_TOP_PEXTP_TL_SEL, 1, 1),
  276. INFRA_FACTOR(CK_INFRA_PWM_BCK, "infra_pwm_bck", CK_INFRA_PWM_BSEL, 1,
  277. 1),
  278. INFRA_FACTOR(CK_INFRA_PWM_CK1, "infra_pwm_ck1", CK_INFRA_PWM1_SEL, 1,
  279. 1),
  280. INFRA_FACTOR(CK_INFRA_PWM_CK2, "infra_pwm_ck2", CK_INFRA_PWM2_SEL, 1,
  281. 1),
  282. TOP_FACTOR(CK_INFRA_133M_HCK, "infra_133m_hck", CK_TOP_SYSAXI, 1, 1),
  283. TOP_FACTOR(CK_INFRA_EIP_CK, "infra_eip", CK_TOP_EIP_B, 1, 1),
  284. INFRA_FACTOR(CK_INFRA_66M_PHCK, "infra_66m_phck", CK_INFRA_133M_HCK, 1,
  285. 1),
  286. TOP_FACTOR(CK_INFRA_FAUD_L_CK, "infra_faud_l", CK_TOP_AUD_L, 1, 1),
  287. TOP_FACTOR(CK_INFRA_FAUD_AUD_CK, "infra_faud_aud", CK_TOP_A1SYS, 1, 1),
  288. TOP_FACTOR(CK_INFRA_FAUD_EG2_CK, "infra_faud_eg2", CK_TOP_A_TUNER, 1,
  289. 1),
  290. TOP_FACTOR(CK_INFRA_I2CS_CK, "infra_i2cs", CK_TOP_I2C_BCK, 1, 1),
  291. INFRA_FACTOR(CK_INFRA_MUX_UART0, "infra_mux_uart0", CK_INFRA_UART0_SEL,
  292. 1, 1),
  293. INFRA_FACTOR(CK_INFRA_MUX_UART1, "infra_mux_uart1", CK_INFRA_UART1_SEL,
  294. 1, 1),
  295. INFRA_FACTOR(CK_INFRA_MUX_UART2, "infra_mux_uart2", CK_INFRA_UART2_SEL,
  296. 1, 1),
  297. TOP_FACTOR(CK_INFRA_NFI_CK, "infra_nfi", CK_TOP_NFI1X, 1, 1),
  298. TOP_FACTOR(CK_INFRA_SPINFI_CK, "infra_spinfi", CK_TOP_SPINFI_BCK, 1, 1),
  299. INFRA_FACTOR(CK_INFRA_MUX_SPI0, "infra_mux_spi0", CK_INFRA_SPI0_SEL, 1,
  300. 1),
  301. INFRA_FACTOR(CK_INFRA_MUX_SPI1, "infra_mux_spi1", CK_INFRA_SPI1_SEL, 1,
  302. 1),
  303. TOP_FACTOR(CK_INFRA_RTC_32K, "infra_rtc_32k", CK_TOP_CB_RTC_32K, 1, 1),
  304. TOP_FACTOR(CK_INFRA_FMSDC_CK, "infra_fmsdc", CK_TOP_EMMC_416M, 1, 1),
  305. TOP_FACTOR(CK_INFRA_FMSDC_HCK_CK, "infra_fmsdc_hck", CK_TOP_EMMC_250M,
  306. 1, 1),
  307. TOP_FACTOR(CK_INFRA_PERI_133M, "infra_peri_133m", CK_TOP_SYSAXI, 1, 1),
  308. TOP_FACTOR(CK_INFRA_133M_PHCK, "infra_133m_phck", CK_TOP_SYSAXI, 1, 1),
  309. TOP_FACTOR(CK_INFRA_USB_SYS_CK, "infra_usb_sys", CK_TOP_U2U3_SYS, 1, 1),
  310. TOP_FACTOR(CK_INFRA_USB_CK, "infra_usb", CK_TOP_U2U3_REF, 1, 1),
  311. TOP_FACTOR(CK_INFRA_USB_XHCI_CK, "infra_usb_xhci", CK_TOP_U2U3_XHCI, 1,
  312. 1),
  313. TOP_FACTOR(CK_INFRA_PCIE_GFMUX_TL_O_PRE, "infra_pcie_mux",
  314. CK_TOP_PEXTP_TL, 1, 1),
  315. TOP_FACTOR(CK_INFRA_F26M_CK0, "infra_f26m_ck0", CK_TOP_F26M, 1, 1),
  316. TOP_FACTOR(CK_INFRA_HD_133M, "infra_hd_133m", CK_TOP_SYSAXI, 1, 1),
  317. };
  318. /* INFRASYS MUX PARENTS */
  319. static const int infra_uart0_parents[] = { CK_INFRA_CK_F26M, CK_INFRA_UART };
  320. static const int infra_spi0_parents[] = { CK_INFRA_I2C, CK_INFRA_ISPI0 };
  321. static const int infra_spi1_parents[] = { CK_INFRA_I2C, CK_INFRA_ISPI1 };
  322. static const int infra_pwm_bsel_parents[] = { CK_INFRA_CK_F32K,
  323. CK_INFRA_CK_F26M,
  324. CK_INFRA_66M_MCK, CK_INFRA_PWM };
  325. static const int infra_pcie_parents[] = { CK_INFRA_CK_F32K, CK_INFRA_CK_F26M,
  326. -1, CK_INFRA_PCIE_CK };
  327. #define INFRA_MUX(_id, _name, _parents, _reg, _shift, _width) \
  328. { \
  329. .id = _id, .mux_reg = (_reg) + 0x8, \
  330. .mux_set_reg = (_reg) + 0x0, .mux_clr_reg = (_reg) + 0x4, \
  331. .mux_shift = _shift, .mux_mask = BIT(_width) - 1, \
  332. .parent = _parents, .num_parents = ARRAY_SIZE(_parents), \
  333. .flags = CLK_MUX_SETCLR_UPD | CLK_PARENT_INFRASYS, \
  334. }
  335. /* INFRA MUX */
  336. static const struct mtk_composite infra_muxes[] = {
  337. /* MODULE_CLK_SEL_0 */
  338. INFRA_MUX(CK_INFRA_UART0_SEL, "infra_uart0_sel", infra_uart0_parents,
  339. 0x10, 0, 1),
  340. INFRA_MUX(CK_INFRA_UART1_SEL, "infra_uart1_sel", infra_uart0_parents,
  341. 0x10, 1, 1),
  342. INFRA_MUX(CK_INFRA_UART2_SEL, "infra_uart2_sel", infra_uart0_parents,
  343. 0x10, 2, 1),
  344. INFRA_MUX(CK_INFRA_SPI0_SEL, "infra_spi0_sel", infra_spi0_parents, 0x10,
  345. 4, 1),
  346. INFRA_MUX(CK_INFRA_SPI1_SEL, "infra_spi1_sel", infra_spi1_parents, 0x10,
  347. 5, 1),
  348. INFRA_MUX(CK_INFRA_PWM1_SEL, "infra_pwm1_sel", infra_pwm_bsel_parents,
  349. 0x10, 9, 2),
  350. INFRA_MUX(CK_INFRA_PWM2_SEL, "infra_pwm2_sel", infra_pwm_bsel_parents,
  351. 0x10, 11, 2),
  352. INFRA_MUX(CK_INFRA_PWM_BSEL, "infra_pwm_bsel", infra_pwm_bsel_parents,
  353. 0x10, 13, 2),
  354. /* MODULE_CLK_SEL_1 */
  355. INFRA_MUX(CK_INFRA_PCIE_SEL, "infra_pcie_sel", infra_pcie_parents, 0x20,
  356. 0, 2),
  357. };
  358. static const struct mtk_gate_regs infra_0_cg_regs = {
  359. .set_ofs = 0x40,
  360. .clr_ofs = 0x44,
  361. .sta_ofs = 0x48,
  362. };
  363. static const struct mtk_gate_regs infra_1_cg_regs = {
  364. .set_ofs = 0x50,
  365. .clr_ofs = 0x54,
  366. .sta_ofs = 0x58,
  367. };
  368. static const struct mtk_gate_regs infra_2_cg_regs = {
  369. .set_ofs = 0x60,
  370. .clr_ofs = 0x64,
  371. .sta_ofs = 0x68,
  372. };
  373. #define GATE_INFRA0(_id, _name, _parent, _shift) \
  374. { \
  375. .id = _id, .parent = _parent, .regs = &infra_0_cg_regs, \
  376. .shift = _shift, \
  377. .flags = CLK_GATE_SETCLR | CLK_PARENT_INFRASYS, \
  378. }
  379. #define GATE_INFRA1(_id, _name, _parent, _shift) \
  380. { \
  381. .id = _id, .parent = _parent, .regs = &infra_1_cg_regs, \
  382. .shift = _shift, \
  383. .flags = CLK_GATE_SETCLR | CLK_PARENT_INFRASYS, \
  384. }
  385. #define GATE_INFRA2(_id, _name, _parent, _shift) \
  386. { \
  387. .id = _id, .parent = _parent, .regs = &infra_2_cg_regs, \
  388. .shift = _shift, \
  389. .flags = CLK_GATE_SETCLR | CLK_PARENT_INFRASYS, \
  390. }
  391. /* INFRA GATE */
  392. static const struct mtk_gate infracfg_ao_gates[] = {
  393. /* INFRA0 */
  394. GATE_INFRA0(CK_INFRA_GPT_STA, "infra_gpt_sta", CK_INFRA_66M_MCK, 0),
  395. GATE_INFRA0(CK_INFRA_PWM_HCK, "infra_pwm_hck", CK_INFRA_66M_MCK, 1),
  396. GATE_INFRA0(CK_INFRA_PWM_STA, "infra_pwm_sta", CK_INFRA_PWM_BCK, 2),
  397. GATE_INFRA0(CK_INFRA_PWM1_CK, "infra_pwm1", CK_INFRA_PWM_CK1, 3),
  398. GATE_INFRA0(CK_INFRA_PWM2_CK, "infra_pwm2", CK_INFRA_PWM_CK2, 4),
  399. GATE_INFRA0(CK_INFRA_CQ_DMA_CK, "infra_cq_dma", CK_INFRA_133M_HCK, 6),
  400. GATE_INFRA0(CK_INFRA_EIP97_CK, "infra_eip97", CK_INFRA_EIP_CK, 7),
  401. GATE_INFRA0(CK_INFRA_AUD_BUS_CK, "infra_aud_bus", CK_INFRA_66M_PHCK, 8),
  402. GATE_INFRA0(CK_INFRA_AUD_26M_CK, "infra_aud_26m", CK_INFRA_CK_F26M, 9),
  403. GATE_INFRA0(CK_INFRA_AUD_L_CK, "infra_aud_l", CK_INFRA_FAUD_L_CK, 10),
  404. GATE_INFRA0(CK_INFRA_AUD_AUD_CK, "infra_aud_aud", CK_INFRA_FAUD_AUD_CK,
  405. 11),
  406. GATE_INFRA0(CK_INFRA_AUD_EG2_CK, "infra_aud_eg2", CK_INFRA_FAUD_EG2_CK,
  407. 13),
  408. GATE_INFRA0(CK_INFRA_DRAMC_26M_CK, "infra_dramc_26m", CK_INFRA_CK_F26M,
  409. 14),
  410. GATE_INFRA0(CK_INFRA_DBG_CK, "infra_dbg", CK_INFRA_66M_MCK, 15),
  411. GATE_INFRA0(CK_INFRA_AP_DMA_CK, "infra_ap_dma", CK_INFRA_66M_MCK, 16),
  412. GATE_INFRA0(CK_INFRA_SEJ_CK, "infra_sej", CK_INFRA_66M_MCK, 24),
  413. GATE_INFRA0(CK_INFRA_SEJ_13M_CK, "infra_sej_13m", CK_INFRA_CK_F26M, 25),
  414. GATE_INFRA0(CK_INFRA_TRNG_CK, "infra_trng", CK_INFRA_HD_133M, 26),
  415. /* INFRA1 */
  416. GATE_INFRA1(CK_INFRA_THERM_CK, "infra_therm", CK_INFRA_CK_F26M, 0),
  417. GATE_INFRA1(CK_INFRA_I2CO_CK, "infra_i2co", CK_INFRA_I2CS_CK, 1),
  418. GATE_INFRA1(CK_INFRA_UART0_CK, "infra_uart0", CK_INFRA_MUX_UART0, 2),
  419. GATE_INFRA1(CK_INFRA_UART1_CK, "infra_uart1", CK_INFRA_MUX_UART1, 3),
  420. GATE_INFRA1(CK_INFRA_UART2_CK, "infra_uart2", CK_INFRA_MUX_UART2, 4),
  421. GATE_INFRA1(CK_INFRA_NFI1_CK, "infra_nfi1", CK_INFRA_NFI_CK, 8),
  422. GATE_INFRA1(CK_INFRA_SPINFI1_CK, "infra_spinfi1", CK_INFRA_SPINFI_CK,
  423. 9),
  424. GATE_INFRA1(CK_INFRA_NFI_HCK_CK, "infra_nfi_hck", CK_INFRA_66M_MCK, 10),
  425. GATE_INFRA1(CK_INFRA_SPI0_CK, "infra_spi0", CK_INFRA_MUX_SPI0, 11),
  426. GATE_INFRA1(CK_INFRA_SPI1_CK, "infra_spi1", CK_INFRA_MUX_SPI1, 12),
  427. GATE_INFRA1(CK_INFRA_SPI0_HCK_CK, "infra_spi0_hck", CK_INFRA_66M_MCK,
  428. 13),
  429. GATE_INFRA1(CK_INFRA_SPI1_HCK_CK, "infra_spi1_hck", CK_INFRA_66M_MCK,
  430. 14),
  431. GATE_INFRA1(CK_INFRA_FRTC_CK, "infra_frtc", CK_INFRA_RTC_32K, 15),
  432. GATE_INFRA1(CK_INFRA_MSDC_CK, "infra_msdc", CK_INFRA_FMSDC_CK, 16),
  433. GATE_INFRA1(CK_INFRA_MSDC_HCK_CK, "infra_msdc_hck",
  434. CK_INFRA_FMSDC_HCK_CK, 17),
  435. GATE_INFRA1(CK_INFRA_MSDC_133M_CK, "infra_msdc_133m",
  436. CK_INFRA_PERI_133M, 18),
  437. GATE_INFRA1(CK_INFRA_MSDC_66M_CK, "infra_msdc_66m", CK_INFRA_66M_PHCK,
  438. 19),
  439. GATE_INFRA1(CK_INFRA_ADC_26M_CK, "infra_adc_26m", CK_INFRA_CK_F26M, 20),
  440. GATE_INFRA1(CK_INFRA_ADC_FRC_CK, "infra_adc_frc", CK_INFRA_CK_F26M, 21),
  441. GATE_INFRA1(CK_INFRA_FBIST2FPC_CK, "infra_fbist2fpc", CK_INFRA_NFI_CK,
  442. 23),
  443. /* INFRA2 */
  444. GATE_INFRA2(CK_INFRA_IUSB_133_CK, "infra_iusb_133", CK_INFRA_133M_PHCK,
  445. 0),
  446. GATE_INFRA2(CK_INFRA_IUSB_66M_CK, "infra_iusb_66m", CK_INFRA_66M_PHCK,
  447. 1),
  448. GATE_INFRA2(CK_INFRA_IUSB_SYS_CK, "infra_iusb_sys", CK_INFRA_USB_SYS_CK,
  449. 2),
  450. GATE_INFRA2(CK_INFRA_IUSB_CK, "infra_iusb", CK_INFRA_USB_CK, 3),
  451. GATE_INFRA2(CK_INFRA_IPCIE_CK, "infra_ipcie", CK_INFRA_PCIE_CK, 13),
  452. GATE_INFRA2(CK_INFRA_IPCIER_CK, "infra_ipcier", CK_INFRA_F26M_CK0, 15),
  453. GATE_INFRA2(CK_INFRA_IPCIEB_CK, "infra_ipcieb", CK_INFRA_133M_PHCK, 15),
  454. };
  455. static const struct mtk_clk_tree mt7986_fixed_pll_clk_tree = {
  456. .fdivs_offs = CLK_APMIXED_NR_CLK,
  457. .xtal_rate = 40 * MHZ,
  458. .fclks = fixed_pll_clks,
  459. };
  460. static const struct mtk_clk_tree mt7986_topckgen_clk_tree = {
  461. .fdivs_offs = CK_TOP_CB_M_416M,
  462. .muxes_offs = CK_TOP_NFI1X_SEL,
  463. .fclks = top_fixed_clks,
  464. .fdivs = top_fixed_divs,
  465. .muxes = top_muxes,
  466. .flags = CLK_BYPASS_XTAL,
  467. };
  468. static const struct mtk_clk_tree mt7986_infracfg_clk_tree = {
  469. .fdivs_offs = CK_INFRA_CK_F26M,
  470. .muxes_offs = CK_INFRA_UART0_SEL,
  471. .fdivs = infra_fixed_divs,
  472. .muxes = infra_muxes,
  473. };
  474. static const struct udevice_id mt7986_fixed_pll_compat[] = {
  475. { .compatible = "mediatek,mt7986-fixed-plls" },
  476. {}
  477. };
  478. static const struct udevice_id mt7986_topckgen_compat[] = {
  479. { .compatible = "mediatek,mt7986-topckgen" },
  480. {}
  481. };
  482. static int mt7986_fixed_pll_probe(struct udevice *dev)
  483. {
  484. return mtk_common_clk_init(dev, &mt7986_fixed_pll_clk_tree);
  485. }
  486. static int mt7986_topckgen_probe(struct udevice *dev)
  487. {
  488. struct mtk_clk_priv *priv = dev_get_priv(dev);
  489. priv->base = dev_read_addr_ptr(dev);
  490. writel(MT7986_CLK_PDN_EN_WRITE, priv->base + MT7986_CLK_PDN);
  491. return mtk_common_clk_init(dev, &mt7986_topckgen_clk_tree);
  492. }
  493. U_BOOT_DRIVER(mtk_clk_apmixedsys) = {
  494. .name = "mt7986-clock-fixed-pll",
  495. .id = UCLASS_CLK,
  496. .of_match = mt7986_fixed_pll_compat,
  497. .probe = mt7986_fixed_pll_probe,
  498. .priv_auto = sizeof(struct mtk_clk_priv),
  499. .ops = &mtk_clk_topckgen_ops,
  500. .flags = DM_FLAG_PRE_RELOC,
  501. };
  502. U_BOOT_DRIVER(mtk_clk_topckgen) = {
  503. .name = "mt7986-clock-topckgen",
  504. .id = UCLASS_CLK,
  505. .of_match = mt7986_topckgen_compat,
  506. .probe = mt7986_topckgen_probe,
  507. .priv_auto = sizeof(struct mtk_clk_priv),
  508. .ops = &mtk_clk_topckgen_ops,
  509. .flags = DM_FLAG_PRE_RELOC,
  510. };
  511. static const struct udevice_id mt7986_infracfg_compat[] = {
  512. { .compatible = "mediatek,mt7986-infracfg" },
  513. {}
  514. };
  515. static const struct udevice_id mt7986_infracfg_ao_compat[] = {
  516. { .compatible = "mediatek,mt7986-infracfg_ao" },
  517. {}
  518. };
  519. static int mt7986_infracfg_probe(struct udevice *dev)
  520. {
  521. return mtk_common_clk_init(dev, &mt7986_infracfg_clk_tree);
  522. }
  523. static int mt7986_infracfg_ao_probe(struct udevice *dev)
  524. {
  525. return mtk_common_clk_gate_init(dev, &mt7986_infracfg_clk_tree,
  526. infracfg_ao_gates);
  527. }
  528. U_BOOT_DRIVER(mtk_clk_infracfg) = {
  529. .name = "mt7986-clock-infracfg",
  530. .id = UCLASS_CLK,
  531. .of_match = mt7986_infracfg_compat,
  532. .probe = mt7986_infracfg_probe,
  533. .priv_auto = sizeof(struct mtk_clk_priv),
  534. .ops = &mtk_clk_infrasys_ops,
  535. .flags = DM_FLAG_PRE_RELOC,
  536. };
  537. U_BOOT_DRIVER(mtk_clk_infracfg_ao) = {
  538. .name = "mt7986-clock-infracfg-ao",
  539. .id = UCLASS_CLK,
  540. .of_match = mt7986_infracfg_ao_compat,
  541. .probe = mt7986_infracfg_ao_probe,
  542. .priv_auto = sizeof(struct mtk_cg_priv),
  543. .ops = &mtk_clk_gate_ops,
  544. .flags = DM_FLAG_PRE_RELOC,
  545. };
  546. /* ethsys */
  547. static const struct mtk_gate_regs eth_cg_regs = {
  548. .sta_ofs = 0x30,
  549. };
  550. #define GATE_ETH(_id, _name, _parent, _shift) \
  551. { \
  552. .id = _id, .parent = _parent, .regs = &eth_cg_regs, \
  553. .shift = _shift, \
  554. .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \
  555. }
  556. static const struct mtk_gate eth_cgs[] = {
  557. GATE_ETH(CK_ETH_FE_EN, "eth_fe_en", CK_TOP_NETSYS_2X, 7),
  558. GATE_ETH(CK_ETH_GP2_EN, "eth_gp2_en", CK_TOP_SGM_325M, 8),
  559. GATE_ETH(CK_ETH_GP1_EN, "eth_gp1_en", CK_TOP_SGM_325M, 8),
  560. GATE_ETH(CK_ETH_WOCPU1_EN, "eth_wocpu1_en", CK_TOP_NETSYS_WED_MCU, 14),
  561. GATE_ETH(CK_ETH_WOCPU0_EN, "eth_wocpu0_en", CK_TOP_NETSYS_WED_MCU, 15),
  562. };
  563. static int mt7986_ethsys_probe(struct udevice *dev)
  564. {
  565. return mtk_common_clk_gate_init(dev, &mt7986_topckgen_clk_tree,
  566. eth_cgs);
  567. }
  568. static int mt7986_ethsys_bind(struct udevice *dev)
  569. {
  570. int ret = 0;
  571. if (CONFIG_IS_ENABLED(RESET_MEDIATEK)) {
  572. ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1);
  573. if (ret)
  574. debug("Warning: failed to bind reset controller\n");
  575. }
  576. return ret;
  577. }
  578. static const struct udevice_id mt7986_ethsys_compat[] = {
  579. { .compatible = "mediatek,mt7986-ethsys" },
  580. { }
  581. };
  582. U_BOOT_DRIVER(mtk_clk_ethsys) = {
  583. .name = "mt7986-clock-ethsys",
  584. .id = UCLASS_CLK,
  585. .of_match = mt7986_ethsys_compat,
  586. .probe = mt7986_ethsys_probe,
  587. .bind = mt7986_ethsys_bind,
  588. .priv_auto = sizeof(struct mtk_cg_priv),
  589. .ops = &mtk_clk_gate_ops,
  590. };