Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * MediaTek clock driver for MT7988 SoC |
| 4 | * |
| 5 | * Copyright (C) 2022 MediaTek Inc. |
| 6 | * Author: Sam Shih <sam.shih@mediatek.com> |
| 7 | */ |
| 8 | |
| 9 | #include <dm.h> |
| 10 | #include <log.h> |
| 11 | #include <asm/arch-mediatek/reset.h> |
| 12 | #include <asm/io.h> |
| 13 | #include <dt-bindings/clock/mt7988-clk.h> |
| 14 | #include <linux/bitops.h> |
| 15 | |
| 16 | #include "clk-mtk.h" |
| 17 | |
| 18 | #define MT7988_CLK_PDN 0x250 |
| 19 | #define MT7988_CLK_PDN_EN_WRITE BIT(31) |
| 20 | |
| 21 | #define MT7988_ETHDMA_RST_CTRL_OFS 0x34 |
| 22 | #define MT7988_ETHWARP_RST_CTRL_OFS 0x8 |
| 23 | |
| 24 | #define XTAL_FACTOR(_id, _name, _parent, _mult, _div) \ |
| 25 | FACTOR(_id, _parent, _mult, _div, CLK_PARENT_XTAL) |
| 26 | |
| 27 | #define PLL_FACTOR(_id, _name, _parent, _mult, _div) \ |
| 28 | FACTOR(_id, _parent, _mult, _div, CLK_PARENT_APMIXED) |
| 29 | |
| 30 | #define TOP_FACTOR(_id, _name, _parent, _mult, _div) \ |
| 31 | FACTOR(_id, _parent, _mult, _div, CLK_PARENT_TOPCKGEN) |
| 32 | |
| 33 | #define INFRA_FACTOR(_id, _name, _parent, _mult, _div) \ |
| 34 | FACTOR(_id, _parent, _mult, _div, CLK_PARENT_INFRASYS) |
| 35 | |
| 36 | /* FIXED PLLS */ |
| 37 | static const struct mtk_fixed_clk apmixedsys_mtk_plls[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 38 | FIXED_CLK(CLK_APMIXED_NETSYSPLL, CLK_XTAL, 850000000), |
| 39 | FIXED_CLK(CLK_APMIXED_MPLL, CLK_XTAL, 416000000), |
| 40 | FIXED_CLK(CLK_APMIXED_MMPLL, CLK_XTAL, 720000000), |
| 41 | FIXED_CLK(CLK_APMIXED_APLL2, CLK_XTAL, 196608000), |
| 42 | FIXED_CLK(CLK_APMIXED_NET1PLL, CLK_XTAL, 2500000000), |
| 43 | FIXED_CLK(CLK_APMIXED_NET2PLL, CLK_XTAL, 800000000), |
| 44 | FIXED_CLK(CLK_APMIXED_WEDMCUPLL, CLK_XTAL, 208000000), |
| 45 | FIXED_CLK(CLK_APMIXED_SGMPLL, CLK_XTAL, 325000000), |
| 46 | FIXED_CLK(CLK_APMIXED_ARM_B, CLK_XTAL, 1500000000), |
| 47 | FIXED_CLK(CLK_APMIXED_CCIPLL2_B, CLK_XTAL, 960000000), |
| 48 | FIXED_CLK(CLK_APMIXED_USXGMIIPLL, CLK_XTAL, 644533000), |
| 49 | FIXED_CLK(CLK_APMIXED_MSDCPLL, CLK_XTAL, 400000000), |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 50 | }; |
| 51 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 52 | /* TOPCKGEN FIXED CLK */ |
| 53 | static const struct mtk_fixed_clk topckgen_mtk_fixed_clks[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 54 | FIXED_CLK(CLK_TOP_XTAL, CLK_XTAL, 40000000), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 55 | }; |
| 56 | |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 57 | /* TOPCKGEN FIXED DIV */ |
| 58 | static const struct mtk_fixed_factor topckgen_mtk_fixed_factors[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 59 | TOP_FACTOR(CLK_TOP_XTAL_D2, "xtal_d2", CLK_TOP_XTAL, 1, 2), |
| 60 | TOP_FACTOR(CLK_TOP_RTC_32K, "rtc_32k", CLK_TOP_XTAL, 1, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 61 | 1250), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 62 | TOP_FACTOR(CLK_TOP_RTC_32P7K, "rtc_32p7k", CLK_TOP_XTAL, 1, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 63 | 1220), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 64 | PLL_FACTOR(CLK_TOP_MPLL_D2, "mpll_d2", CLK_APMIXED_MPLL, 1, 2), |
| 65 | PLL_FACTOR(CLK_TOP_MPLL_D3_D2, "mpll_d3_d2", CLK_APMIXED_MPLL, 1, 2), |
| 66 | PLL_FACTOR(CLK_TOP_MPLL_D4, "mpll_d4", CLK_APMIXED_MPLL, 1, 4), |
| 67 | PLL_FACTOR(CLK_TOP_MPLL_D8, "mpll_d8", CLK_APMIXED_MPLL, 1, 8), |
| 68 | PLL_FACTOR(CLK_TOP_MPLL_D8_D2, "mpll_d8_d2", CLK_APMIXED_MPLL, 1, 16), |
| 69 | PLL_FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", CLK_APMIXED_MMPLL, 1, 2), |
| 70 | PLL_FACTOR(CLK_TOP_MMPLL_D3_D5, "mmpll_d3_d5", CLK_APMIXED_MMPLL, 1, 15), |
| 71 | PLL_FACTOR(CLK_TOP_MMPLL_D4, "mmpll_d4", CLK_APMIXED_MMPLL, 1, 4), |
| 72 | PLL_FACTOR(CLK_TOP_MMPLL_D6_D2, "mmpll_d6_d2", CLK_APMIXED_MMPLL, 1, 12), |
| 73 | PLL_FACTOR(CLK_TOP_MMPLL_D8, "mmpll_d8", CLK_APMIXED_MMPLL, 1, 8), |
| 74 | PLL_FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", CLK_APMIXED_APLL2, 1, 4), |
| 75 | PLL_FACTOR(CLK_TOP_NET1PLL_D4, "net1pll_d4", CLK_APMIXED_NET1PLL, 1, 4), |
| 76 | PLL_FACTOR(CLK_TOP_NET1PLL_D5, "net1pll_d5", CLK_APMIXED_NET1PLL, 1, 5), |
| 77 | PLL_FACTOR(CLK_TOP_NET1PLL_D5_D2, "net1pll_d5_d2", CLK_APMIXED_NET1PLL, 1, 10), |
| 78 | PLL_FACTOR(CLK_TOP_NET1PLL_D5_D4, "net1pll_d5_d4", CLK_APMIXED_NET1PLL, 1, 20), |
| 79 | PLL_FACTOR(CLK_TOP_NET1PLL_D8, "net1pll_d8", CLK_APMIXED_NET1PLL, 1, 8), |
| 80 | PLL_FACTOR(CLK_TOP_NET1PLL_D8_D2, "net1pll_d8_d2", CLK_APMIXED_NET1PLL, 1, 16), |
| 81 | PLL_FACTOR(CLK_TOP_NET1PLL_D8_D4, "net1pll_d8_d4", CLK_APMIXED_NET1PLL, 1, 32), |
| 82 | PLL_FACTOR(CLK_TOP_NET1PLL_D8_D8, "net1pll_d8_d8", CLK_APMIXED_NET1PLL, 1, 64), |
| 83 | PLL_FACTOR(CLK_TOP_NET1PLL_D8_D16, "net1pll_d8_d16", CLK_APMIXED_NET1PLL, 1, |
Christian Marangi | 1bafda9 | 2024-08-03 10:32:57 +0200 | [diff] [blame] | 84 | 128), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 85 | PLL_FACTOR(CLK_TOP_NET2PLL_D2, "net2pll_d2", CLK_APMIXED_NET2PLL, 1, 2), |
| 86 | PLL_FACTOR(CLK_TOP_NET2PLL_D4, "net2pll_d4", CLK_APMIXED_NET2PLL, 1, 4), |
| 87 | PLL_FACTOR(CLK_TOP_NET2PLL_D4_D4, "net2pll_d4_d4", CLK_APMIXED_NET2PLL, 1, 16), |
| 88 | PLL_FACTOR(CLK_TOP_NET2PLL_D4_D8, "net2pll_d4_d8", CLK_APMIXED_NET2PLL, 1, 32), |
| 89 | PLL_FACTOR(CLK_TOP_NET2PLL_D6, "net2pll_d6", CLK_APMIXED_NET2PLL, 1, 6), |
| 90 | PLL_FACTOR(CLK_TOP_NET2PLL_D8, "net2pll_d8", CLK_APMIXED_NET2PLL, 1, 8), |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 91 | }; |
| 92 | |
| 93 | /* TOPCKGEN MUX PARENTS */ |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 94 | #define APMIXED_PARENT(_id) PARENT(_id, CLK_PARENT_APMIXED) |
| 95 | #define TOP_PARENT(_id) PARENT(_id, CLK_PARENT_TOPCKGEN) |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 96 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 97 | static const struct mtk_parent netsys_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 98 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET2PLL_D2), |
| 99 | TOP_PARENT(CLK_TOP_MMPLL_D2), |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 100 | }; |
| 101 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 102 | static const struct mtk_parent netsys_500m_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 103 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5), |
| 104 | TOP_PARENT(CLK_TOP_NET1PLL_D5_D2), |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 105 | }; |
| 106 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 107 | static const struct mtk_parent netsys_2x_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 108 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_NET2PLL), |
| 109 | APMIXED_PARENT(CLK_APMIXED_MMPLL), |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 110 | }; |
| 111 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 112 | static const struct mtk_parent netsys_gsw_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 113 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D4), |
| 114 | TOP_PARENT(CLK_TOP_NET1PLL_D5), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 115 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 116 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 117 | static const struct mtk_parent eth_gmii_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 118 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 119 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 120 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 121 | static const struct mtk_parent netsys_mcu_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 122 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_NET2PLL), |
| 123 | APMIXED_PARENT(CLK_APMIXED_MMPLL), TOP_PARENT(CLK_TOP_NET1PLL_D4), |
| 124 | TOP_PARENT(CLK_TOP_NET1PLL_D5), APMIXED_PARENT(CLK_APMIXED_MPLL), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 125 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 126 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 127 | static const struct mtk_parent eip197_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 128 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_NETSYSPLL), |
| 129 | APMIXED_PARENT(CLK_APMIXED_NET2PLL), APMIXED_PARENT(CLK_APMIXED_MMPLL), |
| 130 | TOP_PARENT(CLK_TOP_NET1PLL_D4), TOP_PARENT(CLK_TOP_NET1PLL_D5), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 131 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 132 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 133 | static const struct mtk_parent axi_infra_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 134 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D8_D2), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 135 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 136 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 137 | static const struct mtk_parent uart_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 138 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MPLL_D8), |
| 139 | TOP_PARENT(CLK_TOP_MPLL_D8_D2), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 140 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 141 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 142 | static const struct mtk_parent emmc_250m_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 143 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5_D2), |
| 144 | TOP_PARENT(CLK_TOP_MMPLL_D4), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 145 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 146 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 147 | static const struct mtk_parent emmc_400m_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 148 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_MSDCPLL), |
| 149 | TOP_PARENT(CLK_TOP_MMPLL_D2), TOP_PARENT(CLK_TOP_MPLL_D2), |
| 150 | TOP_PARENT(CLK_TOP_MMPLL_D4), TOP_PARENT(CLK_TOP_NET1PLL_D8_D2), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 151 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 152 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 153 | static const struct mtk_parent spi_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 154 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MPLL_D2), |
| 155 | TOP_PARENT(CLK_TOP_MMPLL_D4), TOP_PARENT(CLK_TOP_NET1PLL_D8_D2), |
| 156 | TOP_PARENT(CLK_TOP_NET2PLL_D6), TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), |
| 157 | TOP_PARENT(CLK_TOP_MPLL_D4), TOP_PARENT(CLK_TOP_NET1PLL_D8_D4), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 158 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 159 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 160 | static const struct mtk_parent nfi1x_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 161 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MMPLL_D4), |
| 162 | TOP_PARENT(CLK_TOP_NET1PLL_D8_D2), TOP_PARENT(CLK_TOP_NET2PLL_D6), |
| 163 | TOP_PARENT(CLK_TOP_MPLL_D4), TOP_PARENT(CLK_TOP_MMPLL_D8), |
| 164 | TOP_PARENT(CLK_TOP_NET1PLL_D8_D4), TOP_PARENT(CLK_TOP_MPLL_D8), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 165 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 166 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 167 | static const struct mtk_parent spinfi_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 168 | TOP_PARENT(CLK_TOP_XTAL_D2), TOP_PARENT(CLK_TOP_XTAL), |
| 169 | TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), TOP_PARENT(CLK_TOP_MPLL_D4), |
| 170 | TOP_PARENT(CLK_TOP_MMPLL_D8), TOP_PARENT(CLK_TOP_NET1PLL_D8_D4), |
| 171 | TOP_PARENT(CLK_TOP_MMPLL_D6_D2), TOP_PARENT(CLK_TOP_MPLL_D8), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 172 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 173 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 174 | static const struct mtk_parent pwm_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 175 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D8_D2), |
| 176 | TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), TOP_PARENT(CLK_TOP_MPLL_D4), |
| 177 | TOP_PARENT(CLK_TOP_MPLL_D8_D2), TOP_PARENT(CLK_TOP_RTC_32K), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 178 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 179 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 180 | static const struct mtk_parent i2c_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 181 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), |
| 182 | TOP_PARENT(CLK_TOP_MPLL_D4), TOP_PARENT(CLK_TOP_NET1PLL_D8_D4), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 183 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 184 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 185 | static const struct mtk_parent pcie_mbist_250m_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 186 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5_D2), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 187 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 188 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 189 | static const struct mtk_parent pextp_tl_ck_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 190 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET2PLL_D6), |
| 191 | TOP_PARENT(CLK_TOP_MMPLL_D8), TOP_PARENT(CLK_TOP_MPLL_D8_D2), |
| 192 | TOP_PARENT(CLK_TOP_RTC_32K), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 193 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 194 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 195 | static const struct mtk_parent usb_frmcnt_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 196 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MMPLL_D3_D5), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 197 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 198 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 199 | static const struct mtk_parent aud_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 200 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_APLL2), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 201 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 202 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 203 | static const struct mtk_parent a1sys_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 204 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_APLL2_D4), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 205 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 206 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 207 | static const struct mtk_parent aud_l_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 208 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_APLL2), |
| 209 | TOP_PARENT(CLK_TOP_MPLL_D8_D2), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 210 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 211 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 212 | static const struct mtk_parent sspxtp_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 213 | TOP_PARENT(CLK_TOP_XTAL_D2), TOP_PARENT(CLK_TOP_MPLL_D8_D2), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 214 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 215 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 216 | static const struct mtk_parent usxgmii_sbus_0_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 217 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D8_D4), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 218 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 219 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 220 | static const struct mtk_parent sgm_0_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 221 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_SGMPLL), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 222 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 223 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 224 | static const struct mtk_parent sysapb_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 225 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MPLL_D3_D2), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 226 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 227 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 228 | static const struct mtk_parent eth_refck_50m_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 229 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET2PLL_D4_D4), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 230 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 231 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 232 | static const struct mtk_parent eth_sys_200m_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 233 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET2PLL_D4), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 234 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 235 | |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 236 | static const struct mtk_parent eth_xgmii_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 237 | TOP_PARENT(CLK_TOP_XTAL_D2), TOP_PARENT(CLK_TOP_NET1PLL_D8_D8), |
| 238 | TOP_PARENT(CLK_TOP_NET1PLL_D8_D16), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 239 | }; |
| 240 | |
| 241 | static const struct mtk_parent bus_tops_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 242 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5), |
| 243 | TOP_PARENT(CLK_TOP_NET2PLL_D2), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 244 | }; |
| 245 | |
| 246 | static const struct mtk_parent npu_tops_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 247 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_NET2PLL), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 248 | }; |
| 249 | |
| 250 | static const struct mtk_parent dramc_md32_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 251 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MPLL_D2), |
| 252 | APMIXED_PARENT(CLK_APMIXED_WEDMCUPLL), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 253 | }; |
| 254 | |
| 255 | static const struct mtk_parent da_xtp_glb_p0_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 256 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET2PLL_D8), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 257 | }; |
| 258 | |
| 259 | static const struct mtk_parent mcusys_backup_625m_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 260 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D4), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 261 | }; |
| 262 | |
| 263 | static const struct mtk_parent macsec_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 264 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_SGMPLL), |
| 265 | TOP_PARENT(CLK_TOP_NET1PLL_D8), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 266 | }; |
| 267 | |
| 268 | static const struct mtk_parent netsys_tops_400m_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 269 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET2PLL_D2), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 270 | }; |
| 271 | |
| 272 | static const struct mtk_parent eth_mii_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 273 | TOP_PARENT(CLK_TOP_XTAL_D2), TOP_PARENT(CLK_TOP_NET2PLL_D4_D8), |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 274 | }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 275 | |
| 276 | #define TOP_MUX(_id, _name, _parents, _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ |
| 277 | _shift, _width, _gate, _upd_ofs, _upd) \ |
| 278 | { \ |
| 279 | .id = _id, .mux_reg = _mux_ofs, .mux_set_reg = _mux_set_ofs, \ |
| 280 | .mux_clr_reg = _mux_clr_ofs, .upd_reg = _upd_ofs, \ |
| 281 | .upd_shift = _upd, .mux_shift = _shift, \ |
| 282 | .mux_mask = BIT(_width) - 1, .gate_reg = _mux_ofs, \ |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 283 | .gate_shift = _gate, .parent_flags = _parents, \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 284 | .num_parents = ARRAY_SIZE(_parents), \ |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 285 | .flags = CLK_MUX_SETCLR_UPD | CLK_PARENT_MIXED, \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | /* TOPCKGEN MUX_GATE */ |
| 289 | static const struct mtk_composite topckgen_mtk_muxes[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 290 | TOP_MUX(CLK_TOP_NETSYS_SEL, "netsys_sel", netsys_parents, 0x0, 0x4, 0x8, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 291 | 0, 2, 7, 0x1c0, 0), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 292 | TOP_MUX(CLK_TOP_NETSYS_500M_SEL, "netsys_500m_sel", netsys_500m_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 293 | 0x0, 0x4, 0x8, 8, 2, 15, 0x1c0, 1), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 294 | TOP_MUX(CLK_TOP_NETSYS_2X_SEL, "netsys_2x_sel", netsys_2x_parents, 0x0, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 295 | 0x4, 0x8, 16, 2, 23, 0x1c0, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 296 | TOP_MUX(CLK_TOP_NETSYS_GSW_SEL, "netsys_gsw_sel", netsys_gsw_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 297 | 0x0, 0x4, 0x8, 24, 2, 31, 0x1c0, 3), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 298 | TOP_MUX(CLK_TOP_ETH_GMII_SEL, "eth_gmii_sel", eth_gmii_parents, 0x10, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 299 | 0x14, 0x18, 0, 1, 7, 0x1c0, 4), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 300 | TOP_MUX(CLK_TOP_NETSYS_MCU_SEL, "netsys_mcu_sel", netsys_mcu_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 301 | 0x10, 0x14, 0x18, 8, 3, 15, 0x1c0, 5), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 302 | TOP_MUX(CLK_TOP_NETSYS_PAO_2X_SEL, "netsys_pao_2x_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 303 | netsys_mcu_parents, 0x10, 0x14, 0x18, 16, 3, 23, 0x1c0, 6), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 304 | TOP_MUX(CLK_TOP_EIP197_SEL, "eip197_sel", eip197_parents, 0x10, 0x14, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 305 | 0x18, 24, 3, 31, 0x1c0, 7), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 306 | TOP_MUX(CLK_TOP_AXI_INFRA_SEL, "axi_infra_sel", axi_infra_parents, 0x20, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 307 | 0x24, 0x28, 0, 1, 7, 0x1c0, 8), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 308 | TOP_MUX(CLK_TOP_UART_SEL, "uart_sel", uart_parents, 0x20, 0x24, 0x28, 8, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 309 | 2, 15, 0x1c0, 9), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 310 | TOP_MUX(CLK_TOP_EMMC_250M_SEL, "emmc_250m_sel", emmc_250m_parents, 0x20, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 311 | 0x24, 0x28, 16, 2, 23, 0x1c0, 10), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 312 | TOP_MUX(CLK_TOP_EMMC_400M_SEL, "emmc_400m_sel", emmc_400m_parents, 0x20, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 313 | 0x24, 0x28, 24, 3, 31, 0x1c0, 11), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 314 | TOP_MUX(CLK_TOP_SPI_SEL, "spi_sel", spi_parents, 0x30, 0x34, 0x38, 0, 3, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 315 | 7, 0x1c0, 12), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 316 | TOP_MUX(CLK_TOP_SPIM_MST_SEL, "spim_mst_sel", spi_parents, 0x30, 0x34, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 317 | 0x38, 8, 3, 15, 0x1c0, 13), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 318 | TOP_MUX(CLK_TOP_NFI1X_SEL, "nfi1x_sel", nfi1x_parents, 0x30, 0x34, 0x38, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 319 | 16, 3, 23, 0x1c0, 14), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 320 | TOP_MUX(CLK_TOP_SPINFI_SEL, "spinfi_sel", spinfi_parents, 0x30, 0x34, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 321 | 0x38, 24, 3, 31, 0x1c0, 15), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 322 | TOP_MUX(CLK_TOP_PWM_SEL, "pwm_sel", pwm_parents, 0x40, 0x44, 0x48, 0, 3, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 323 | 7, 0x1c0, 16), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 324 | TOP_MUX(CLK_TOP_I2C_SEL, "i2c_sel", i2c_parents, 0x40, 0x44, 0x48, 8, 2, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 325 | 15, 0x1c0, 17), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 326 | TOP_MUX(CLK_TOP_PCIE_MBIST_250M_SEL, "pcie_mbist_250m_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 327 | pcie_mbist_250m_parents, 0x40, 0x44, 0x48, 16, 1, 23, 0x1c0, |
| 328 | 18), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 329 | TOP_MUX(CLK_TOP_PEXTP_TL_SEL, "pextp_tl_ck_sel", pextp_tl_ck_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 330 | 0x40, 0x44, 0x48, 24, 3, 31, 0x1c0, 19), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 331 | TOP_MUX(CLK_TOP_PEXTP_TL_P1_SEL, "pextp_tl_ck_p1_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 332 | pextp_tl_ck_parents, 0x50, 0x54, 0x58, 0, 3, 7, 0x1c0, 20), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 333 | TOP_MUX(CLK_TOP_PEXTP_TL_P2_SEL, "pextp_tl_ck_p2_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 334 | pextp_tl_ck_parents, 0x50, 0x54, 0x58, 8, 3, 15, 0x1c0, 21), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 335 | TOP_MUX(CLK_TOP_PEXTP_TL_P3_SEL, "pextp_tl_ck_p3_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 336 | pextp_tl_ck_parents, 0x50, 0x54, 0x58, 16, 3, 23, 0x1c0, 22), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 337 | TOP_MUX(CLK_TOP_USB_SYS_SEL, "usb_sys_sel", eth_gmii_parents, 0x50, 0x54, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 338 | 0x58, 24, 1, 31, 0x1c0, 23), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 339 | TOP_MUX(CLK_TOP_USB_SYS_P1_SEL, "usb_sys_p1_sel", eth_gmii_parents, 0x60, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 340 | 0x64, 0x68, 0, 1, 7, 0x1c0, 24), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 341 | TOP_MUX(CLK_TOP_USB_XHCI_SEL, "usb_xhci_sel", eth_gmii_parents, 0x60, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 342 | 0x64, 0x68, 8, 1, 15, 0x1c0, 25), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 343 | TOP_MUX(CLK_TOP_USB_XHCI_P1_SEL, "usb_xhci_p1_sel", eth_gmii_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 344 | 0x60, 0x64, 0x68, 16, 1, 23, 0x1c0, 26), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 345 | TOP_MUX(CLK_TOP_USB_FRMCNT_SEL, "usb_frmcnt_sel", usb_frmcnt_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 346 | 0x60, 0x64, 0x68, 24, 1, 31, 0x1c0, 27), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 347 | TOP_MUX(CLK_TOP_USB_FRMCNT_P1_SEL, "usb_frmcnt_p1_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 348 | usb_frmcnt_parents, 0x70, 0x74, 0x78, 0, 1, 7, 0x1c0, 28), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 349 | TOP_MUX(CLK_TOP_AUD_SEL, "aud_sel", aud_parents, 0x70, 0x74, 0x78, 8, 1, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 350 | 15, 0x1c0, 29), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 351 | TOP_MUX(CLK_TOP_A1SYS_SEL, "a1sys_sel", a1sys_parents, 0x70, 0x74, 0x78, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 352 | 16, 1, 23, 0x1c0, 30), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 353 | TOP_MUX(CLK_TOP_AUD_L_SEL, "aud_l_sel", aud_l_parents, 0x70, 0x74, 0x78, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 354 | 24, 2, 31, 0x1c4, 0), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 355 | TOP_MUX(CLK_TOP_A_TUNER_SEL, "a_tuner_sel", a1sys_parents, 0x80, 0x84, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 356 | 0x88, 0, 1, 7, 0x1c4, 1), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 357 | TOP_MUX(CLK_TOP_SSPXTP_SEL, "sspxtp_sel", sspxtp_parents, 0x80, 0x84, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 358 | 0x88, 8, 1, 15, 0x1c4, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 359 | TOP_MUX(CLK_TOP_USB_PHY_SEL, "usb_phy_sel", sspxtp_parents, 0x80, 0x84, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 360 | 0x88, 16, 1, 23, 0x1c4, 3), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 361 | TOP_MUX(CLK_TOP_USXGMII_SBUS_0_SEL, "usxgmii_sbus_0_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 362 | usxgmii_sbus_0_parents, 0x80, 0x84, 0x88, 24, 1, 31, 0x1c4, 4), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 363 | TOP_MUX(CLK_TOP_USXGMII_SBUS_1_SEL, "usxgmii_sbus_1_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 364 | usxgmii_sbus_0_parents, 0x90, 0x94, 0x98, 0, 1, 7, 0x1c4, 5), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 365 | TOP_MUX(CLK_TOP_SGM_0_SEL, "sgm_0_sel", sgm_0_parents, 0x90, 0x94, 0x98, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 366 | 8, 1, 15, 0x1c4, 6), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 367 | TOP_MUX(CLK_TOP_SGM_SBUS_0_SEL, "sgm_sbus_0_sel", usxgmii_sbus_0_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 368 | 0x90, 0x94, 0x98, 16, 1, 23, 0x1c4, 7), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 369 | TOP_MUX(CLK_TOP_SGM_1_SEL, "sgm_1_sel", sgm_0_parents, 0x90, 0x94, 0x98, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 370 | 24, 1, 31, 0x1c4, 8), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 371 | TOP_MUX(CLK_TOP_SGM_SBUS_1_SEL, "sgm_sbus_1_sel", usxgmii_sbus_0_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 372 | 0xa0, 0xa4, 0xa8, 0, 1, 7, 0x1c4, 9), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 373 | TOP_MUX(CLK_TOP_XFI_PHY_0_XTAL_SEL, "xfi_phy_0_xtal_sel", sspxtp_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 374 | 0xa0, 0xa4, 0xa8, 8, 1, 15, 0x1c4, 10), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 375 | TOP_MUX(CLK_TOP_XFI_PHY_1_XTAL_SEL, "xfi_phy_1_xtal_sel", sspxtp_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 376 | 0xa0, 0xa4, 0xa8, 16, 1, 23, 0x1c4, 11), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 377 | TOP_MUX(CLK_TOP_SYSAXI_SEL, "sysaxi_sel", axi_infra_parents, 0xa0, 0xa4, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 378 | 0xa8, 24, 1, 31, 0x1c4, 12), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 379 | TOP_MUX(CLK_TOP_SYSAPB_SEL, "sysapb_sel", sysapb_parents, 0xb0, 0xb4, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 380 | 0xb8, 0, 1, 7, 0x1c4, 13), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 381 | TOP_MUX(CLK_TOP_ETH_REFCK_50M_SEL, "eth_refck_50m_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 382 | eth_refck_50m_parents, 0xb0, 0xb4, 0xb8, 8, 1, 15, 0x1c4, 14), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 383 | TOP_MUX(CLK_TOP_ETH_SYS_200M_SEL, "eth_sys_200m_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 384 | eth_sys_200m_parents, 0xb0, 0xb4, 0xb8, 16, 1, 23, 0x1c4, 15), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 385 | TOP_MUX(CLK_TOP_ETH_SYS_SEL, "eth_sys_sel", pcie_mbist_250m_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 386 | 0xb0, 0xb4, 0xb8, 24, 1, 31, 0x1c4, 16), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 387 | TOP_MUX(CLK_TOP_ETH_XGMII_SEL, "eth_xgmii_sel", eth_xgmii_parents, 0xc0, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 388 | 0xc4, 0xc8, 0, 2, 7, 0x1c4, 17), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 389 | TOP_MUX(CLK_TOP_BUS_TOPS_SEL, "bus_tops_sel", bus_tops_parents, 0xc0, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 390 | 0xc4, 0xc8, 8, 2, 15, 0x1c4, 18), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 391 | TOP_MUX(CLK_TOP_NPU_TOPS_SEL, "npu_tops_sel", npu_tops_parents, 0xc0, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 392 | 0xc4, 0xc8, 16, 1, 23, 0x1c4, 19), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 393 | TOP_MUX(CLK_TOP_DRAMC_SEL, "dramc_sel", sspxtp_parents, 0xc0, 0xc4, 0xc8, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 394 | 24, 1, 31, 0x1c4, 20), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 395 | TOP_MUX(CLK_TOP_DRAMC_MD32_SEL, "dramc_md32_sel", dramc_md32_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 396 | 0xd0, 0xd4, 0xd8, 0, 2, 7, 0x1c4, 21), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 397 | TOP_MUX(CLK_TOP_INFRA_F26M_SEL, "csw_infra_f26m_sel", sspxtp_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 398 | 0xd0, 0xd4, 0xd8, 8, 1, 15, 0x1c4, 22), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 399 | TOP_MUX(CLK_TOP_PEXTP_P0_SEL, "pextp_p0_sel", sspxtp_parents, 0xd0, 0xd4, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 400 | 0xd8, 16, 1, 23, 0x1c4, 23), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 401 | TOP_MUX(CLK_TOP_PEXTP_P1_SEL, "pextp_p1_sel", sspxtp_parents, 0xd0, 0xd4, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 402 | 0xd8, 24, 1, 31, 0x1c4, 24), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 403 | TOP_MUX(CLK_TOP_PEXTP_P2_SEL, "pextp_p2_sel", sspxtp_parents, 0xe0, 0xe4, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 404 | 0xe8, 0, 1, 7, 0x1c4, 25), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 405 | TOP_MUX(CLK_TOP_PEXTP_P3_SEL, "pextp_p3_sel", sspxtp_parents, 0xe0, 0xe4, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 406 | 0xe8, 8, 1, 15, 0x1c4, 26), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 407 | TOP_MUX(CLK_TOP_DA_XTP_GLB_P0_SEL, "da_xtp_glb_p0_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 408 | da_xtp_glb_p0_parents, 0xe0, 0xe4, 0xe8, 16, 1, 23, 0x1c4, 27), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 409 | TOP_MUX(CLK_TOP_DA_XTP_GLB_P1_SEL, "da_xtp_glb_p1_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 410 | da_xtp_glb_p0_parents, 0xe0, 0xe4, 0xe8, 24, 1, 31, 0x1c4, 28), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 411 | TOP_MUX(CLK_TOP_DA_XTP_GLB_P2_SEL, "da_xtp_glb_p2_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 412 | da_xtp_glb_p0_parents, 0xf0, 0xf4, 0xf8, 0, 1, 7, 0x1c4, 29), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 413 | TOP_MUX(CLK_TOP_DA_XTP_GLB_P3_SEL, "da_xtp_glb_p3_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 414 | da_xtp_glb_p0_parents, 0xf0, 0xf4, 0xf8, 8, 1, 15, 0x1c4, 30), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 415 | TOP_MUX(CLK_TOP_CKM_SEL, "ckm_sel", sspxtp_parents, 0xf0, 0xf4, 0xf8, 16, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 416 | 1, 23, 0x1c8, 0), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 417 | TOP_MUX(CLK_TOP_DA_SEL, "da_sel", sspxtp_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 418 | 0xf0, 0xf4, 0xf8, 24, 1, 31, 0x1c8, 1), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 419 | TOP_MUX(CLK_TOP_PEXTP_SEL, "pextp_sel", sspxtp_parents, 0x100, 0x104, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 420 | 0x108, 0, 1, 7, 0x1c8, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 421 | TOP_MUX(CLK_TOP_TOPS_P2_26M_SEL, "tops_p2_26m_sel", sspxtp_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 422 | 0x100, 0x104, 0x108, 8, 1, 15, 0x1c8, 3), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 423 | TOP_MUX(CLK_TOP_MCUSYS_BACKUP_625M_SEL, "mcusys_backup_625m_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 424 | mcusys_backup_625m_parents, 0x100, 0x104, 0x108, 16, 1, 23, |
| 425 | 0x1c8, 4), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 426 | TOP_MUX(CLK_TOP_NETSYS_SYNC_250M_SEL, "netsys_sync_250m_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 427 | pcie_mbist_250m_parents, 0x100, 0x104, 0x108, 24, 1, 31, 0x1c8, |
| 428 | 5), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 429 | TOP_MUX(CLK_TOP_MACSEC_SEL, "macsec_sel", macsec_parents, 0x110, 0x114, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 430 | 0x118, 0, 2, 7, 0x1c8, 6), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 431 | TOP_MUX(CLK_TOP_NETSYS_TOPS_400M_SEL, "netsys_tops_400m_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 432 | netsys_tops_400m_parents, 0x110, 0x114, 0x118, 8, 1, 15, 0x1c8, |
| 433 | 7), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 434 | TOP_MUX(CLK_TOP_NETSYS_PPEFB_250M_SEL, "netsys_ppefb_250m_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 435 | pcie_mbist_250m_parents, 0x110, 0x114, 0x118, 16, 1, 23, 0x1c8, |
| 436 | 8), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 437 | TOP_MUX(CLK_TOP_NETSYS_WARP_SEL, "netsys_warp_sel", netsys_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 438 | 0x110, 0x114, 0x118, 24, 2, 31, 0x1c8, 9), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 439 | TOP_MUX(CLK_TOP_ETH_MII_SEL, "eth_mii_sel", eth_mii_parents, 0x120, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 440 | 0x124, 0x128, 0, 1, 7, 0x1c8, 10), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 441 | TOP_MUX(CLK_TOP_NPU_SEL, "ck_npu_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 442 | netsys_2x_parents, 0x120, 0x124, 0x128, 8, 2, 15, 0x1c8, 11), |
| 443 | }; |
| 444 | |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 445 | /* INFRASYS MUX PARENTS */ |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 446 | static const int infra_mux_uart0_parents[] = { CLK_TOP_INFRA_F26M_SEL, |
| 447 | CLK_TOP_UART_SEL }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 448 | |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 449 | static const int infra_mux_uart1_parents[] = { CLK_TOP_INFRA_F26M_SEL, |
| 450 | CLK_TOP_UART_SEL }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 451 | |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 452 | static const int infra_mux_uart2_parents[] = { CLK_TOP_INFRA_F26M_SEL, |
| 453 | CLK_TOP_UART_SEL }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 454 | |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 455 | static const int infra_mux_spi0_parents[] = { CLK_TOP_I2C_SEL, CLK_TOP_SPI_SEL }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 456 | |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 457 | static const int infra_mux_spi1_parents[] = { CLK_TOP_I2C_SEL, CLK_TOP_SPIM_MST_SEL }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 458 | |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 459 | static const int infra_pwm_bck_parents[] = { CLK_TOP_RTC_32P7K, |
| 460 | CLK_TOP_INFRA_F26M_SEL, CLK_TOP_SYSAXI_SEL, |
| 461 | CLK_TOP_PWM_SEL }; |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 462 | |
| 463 | static const int infra_pcie_gfmux_tl_ck_o_p0_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 464 | CLK_TOP_RTC_32P7K, CLK_TOP_INFRA_F26M_SEL, CLK_TOP_INFRA_F26M_SEL, |
| 465 | CLK_TOP_PEXTP_TL_SEL |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 466 | }; |
| 467 | |
| 468 | static const int infra_pcie_gfmux_tl_ck_o_p1_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 469 | CLK_TOP_RTC_32P7K, CLK_TOP_INFRA_F26M_SEL, CLK_TOP_INFRA_F26M_SEL, |
| 470 | CLK_TOP_PEXTP_TL_P1_SEL |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 471 | }; |
| 472 | |
| 473 | static const int infra_pcie_gfmux_tl_ck_o_p2_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 474 | CLK_TOP_RTC_32P7K, CLK_TOP_INFRA_F26M_SEL, CLK_TOP_INFRA_F26M_SEL, |
| 475 | CLK_TOP_PEXTP_TL_P2_SEL |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 476 | }; |
| 477 | |
| 478 | static const int infra_pcie_gfmux_tl_ck_o_p3_parents[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 479 | CLK_TOP_RTC_32P7K, CLK_TOP_INFRA_F26M_SEL, CLK_TOP_INFRA_F26M_SEL, |
| 480 | CLK_TOP_PEXTP_TL_P3_SEL |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 481 | }; |
| 482 | |
| 483 | #define INFRA_MUX(_id, _name, _parents, _reg, _shift, _width) \ |
| 484 | { \ |
| 485 | .id = _id, .mux_reg = _reg + 0x8, .mux_set_reg = _reg + 0x0, \ |
| 486 | .mux_clr_reg = _reg + 0x4, .mux_shift = _shift, \ |
| 487 | .mux_mask = BIT(_width) - 1, .parent = _parents, \ |
| 488 | .num_parents = ARRAY_SIZE(_parents), \ |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 489 | .flags = CLK_MUX_SETCLR_UPD | CLK_PARENT_TOPCKGEN, \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 490 | } |
| 491 | |
| 492 | /* INFRA MUX */ |
| 493 | static const struct mtk_composite infracfg_mtk_mux[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 494 | INFRA_MUX(CLK_INFRA_MUX_UART0_SEL, "infra_mux_uart0_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 495 | infra_mux_uart0_parents, 0x10, 0, 1), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 496 | INFRA_MUX(CLK_INFRA_MUX_UART1_SEL, "infra_mux_uart1_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 497 | infra_mux_uart1_parents, 0x10, 1, 1), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 498 | INFRA_MUX(CLK_INFRA_MUX_UART2_SEL, "infra_mux_uart2_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 499 | infra_mux_uart2_parents, 0x10, 2, 1), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 500 | INFRA_MUX(CLK_INFRA_MUX_SPI0_SEL, "infra_mux_spi0_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 501 | infra_mux_spi0_parents, 0x10, 4, 1), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 502 | INFRA_MUX(CLK_INFRA_MUX_SPI1_SEL, "infra_mux_spi1_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 503 | infra_mux_spi1_parents, 0x10, 5, 1), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 504 | INFRA_MUX(CLK_INFRA_MUX_SPI2_SEL, "infra_mux_spi2_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 505 | infra_mux_spi0_parents, 0x10, 6, 1), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 506 | INFRA_MUX(CLK_INFRA_PWM_SEL, "infra_pwm_sel", infra_pwm_bck_parents, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 507 | 0x10, 14, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 508 | INFRA_MUX(CLK_INFRA_PWM_CK1_SEL, "infra_pwm_ck1_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 509 | infra_pwm_bck_parents, 0x10, 16, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 510 | INFRA_MUX(CLK_INFRA_PWM_CK2_SEL, "infra_pwm_ck2_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 511 | infra_pwm_bck_parents, 0x10, 18, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 512 | INFRA_MUX(CLK_INFRA_PWM_CK3_SEL, "infra_pwm_ck3_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 513 | infra_pwm_bck_parents, 0x10, 20, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 514 | INFRA_MUX(CLK_INFRA_PWM_CK4_SEL, "infra_pwm_ck4_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 515 | infra_pwm_bck_parents, 0x10, 22, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 516 | INFRA_MUX(CLK_INFRA_PWM_CK5_SEL, "infra_pwm_ck5_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 517 | infra_pwm_bck_parents, 0x10, 24, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 518 | INFRA_MUX(CLK_INFRA_PWM_CK6_SEL, "infra_pwm_ck6_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 519 | infra_pwm_bck_parents, 0x10, 26, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 520 | INFRA_MUX(CLK_INFRA_PWM_CK7_SEL, "infra_pwm_ck7_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 521 | infra_pwm_bck_parents, 0x10, 28, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 522 | INFRA_MUX(CLK_INFRA_PWM_CK8_SEL, "infra_pwm_ck8_sel", |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 523 | infra_pwm_bck_parents, 0x10, 30, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 524 | INFRA_MUX(CLK_INFRA_PCIE_GFMUX_TL_O_P0_SEL, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 525 | "infra_pcie_gfmux_tl_o_p0_sel", |
| 526 | infra_pcie_gfmux_tl_ck_o_p0_parents, 0x20, 0, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 527 | INFRA_MUX(CLK_INFRA_PCIE_GFMUX_TL_O_P1_SEL, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 528 | "infra_pcie_gfmux_tl_o_p1_sel", |
| 529 | infra_pcie_gfmux_tl_ck_o_p1_parents, 0x20, 2, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 530 | INFRA_MUX(CLK_INFRA_PCIE_GFMUX_TL_O_P2_SEL, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 531 | "infra_pcie_gfmux_tl_o_p2_sel", |
| 532 | infra_pcie_gfmux_tl_ck_o_p2_parents, 0x20, 4, 2), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 533 | INFRA_MUX(CLK_INFRA_PCIE_GFMUX_TL_O_P3_SEL, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 534 | "infra_pcie_gfmux_tl_o_p3_sel", |
| 535 | infra_pcie_gfmux_tl_ck_o_p3_parents, 0x20, 6, 2), |
| 536 | }; |
| 537 | |
| 538 | static const struct mtk_gate_regs infra_0_cg_regs = { |
| 539 | .set_ofs = 0x10, |
| 540 | .clr_ofs = 0x14, |
| 541 | .sta_ofs = 0x18, |
| 542 | }; |
| 543 | |
| 544 | static const struct mtk_gate_regs infra_1_cg_regs = { |
| 545 | .set_ofs = 0x40, |
| 546 | .clr_ofs = 0x44, |
| 547 | .sta_ofs = 0x48, |
| 548 | }; |
| 549 | |
| 550 | static const struct mtk_gate_regs infra_2_cg_regs = { |
| 551 | .set_ofs = 0x50, |
| 552 | .clr_ofs = 0x54, |
| 553 | .sta_ofs = 0x58, |
| 554 | }; |
| 555 | |
| 556 | static const struct mtk_gate_regs infra_3_cg_regs = { |
| 557 | .set_ofs = 0x60, |
| 558 | .clr_ofs = 0x64, |
| 559 | .sta_ofs = 0x68, |
| 560 | }; |
| 561 | |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 562 | #define GATE_INFRA0(_id, _name, _parent, _shift, _flags) \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 563 | { \ |
| 564 | .id = _id, .parent = _parent, .regs = &infra_0_cg_regs, \ |
| 565 | .shift = _shift, \ |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 566 | .flags = _flags, \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 567 | } |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 568 | #define GATE_INFRA0_INFRA(_id, _name, _parent, _shift) \ |
| 569 | GATE_INFRA0(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_INFRASYS) |
| 570 | #define GATE_INFRA0_TOP(_id, _name, _parent, _shift) \ |
| 571 | GATE_INFRA0(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN) |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 572 | |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 573 | #define GATE_INFRA1(_id, _name, _parent, _shift, _flags) \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 574 | { \ |
| 575 | .id = _id, .parent = _parent, .regs = &infra_1_cg_regs, \ |
| 576 | .shift = _shift, \ |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 577 | .flags = _flags, \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 578 | } |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 579 | #define GATE_INFRA1_INFRA(_id, _name, _parent, _shift) \ |
| 580 | GATE_INFRA1(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_INFRASYS) |
| 581 | #define GATE_INFRA1_TOP(_id, _name, _parent, _shift) \ |
| 582 | GATE_INFRA1(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN) |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 583 | |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 584 | #define GATE_INFRA2(_id, _name, _parent, _shift, _flags) \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 585 | { \ |
| 586 | .id = _id, .parent = _parent, .regs = &infra_2_cg_regs, \ |
| 587 | .shift = _shift, \ |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 588 | .flags = _flags, \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 589 | } |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 590 | #define GATE_INFRA2_INFRA(_id, _name, _parent, _shift) \ |
| 591 | GATE_INFRA2(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_INFRASYS) |
| 592 | #define GATE_INFRA2_TOP(_id, _name, _parent, _shift) \ |
| 593 | GATE_INFRA2(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN) |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 594 | |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 595 | #define GATE_INFRA3(_id, _name, _parent, _shift, _flags) \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 596 | { \ |
| 597 | .id = _id, .parent = _parent, .regs = &infra_3_cg_regs, \ |
| 598 | .shift = _shift, \ |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 599 | .flags = _flags, \ |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 600 | } |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 601 | #define GATE_INFRA3_INFRA(_id, _name, _parent, _shift) \ |
| 602 | GATE_INFRA3(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_INFRASYS) |
| 603 | #define GATE_INFRA3_TOP(_id, _name, _parent, _shift) \ |
| 604 | GATE_INFRA3(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN) |
| 605 | #define GATE_INFRA3_XTAL(_id, _name, _parent, _shift) \ |
| 606 | GATE_INFRA3(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_XTAL) |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 607 | |
| 608 | /* INFRA GATE */ |
| 609 | static const struct mtk_gate infracfg_mtk_gates[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 610 | GATE_INFRA0_TOP(CLK_INFRA_PCIE_PERI_26M_CK_P0, |
| 611 | "infra_pcie_peri_ck_26m_ck_p0", CLK_TOP_INFRA_F26M_SEL, 7), |
| 612 | GATE_INFRA0_TOP(CLK_INFRA_PCIE_PERI_26M_CK_P1, |
| 613 | "infra_pcie_peri_ck_26m_ck_p1", CLK_TOP_INFRA_F26M_SEL, 8), |
| 614 | GATE_INFRA0_INFRA(CLK_INFRA_PCIE_PERI_26M_CK_P2, |
| 615 | "infra_pcie_peri_ck_26m_ck_p2", CLK_INFRA_PCIE_PERI_26M_CK_P3, 9), |
| 616 | GATE_INFRA0_TOP(CLK_INFRA_PCIE_PERI_26M_CK_P3, |
| 617 | "infra_pcie_peri_ck_26m_ck_p3", CLK_TOP_INFRA_F26M_SEL, 10), |
| 618 | GATE_INFRA1_TOP(CLK_INFRA_66M_GPT_BCK, "infra_hf_66m_gpt_bck", |
| 619 | CLK_TOP_SYSAXI_SEL, 0), |
| 620 | GATE_INFRA1_TOP(CLK_INFRA_66M_PWM_HCK, "infra_hf_66m_pwm_hck", |
| 621 | CLK_TOP_SYSAXI_SEL, 1), |
| 622 | GATE_INFRA1_INFRA(CLK_INFRA_66M_PWM_BCK, "infra_hf_66m_pwm_bck", |
| 623 | CLK_INFRA_PWM_SEL, 2), |
| 624 | GATE_INFRA1_INFRA(CLK_INFRA_66M_PWM_CK1, "infra_hf_66m_pwm_ck1", |
| 625 | CLK_INFRA_PWM_CK1_SEL, 3), |
| 626 | GATE_INFRA1_INFRA(CLK_INFRA_66M_PWM_CK2, "infra_hf_66m_pwm_ck2", |
| 627 | CLK_INFRA_PWM_CK2_SEL, 4), |
| 628 | GATE_INFRA1_INFRA(CLK_INFRA_66M_PWM_CK3, "infra_hf_66m_pwm_ck3", |
| 629 | CLK_INFRA_PWM_CK3_SEL, 5), |
| 630 | GATE_INFRA1_INFRA(CLK_INFRA_66M_PWM_CK4, "infra_hf_66m_pwm_ck4", |
| 631 | CLK_INFRA_PWM_CK4_SEL, 6), |
| 632 | GATE_INFRA1_INFRA(CLK_INFRA_66M_PWM_CK5, "infra_hf_66m_pwm_ck5", |
| 633 | CLK_INFRA_PWM_CK5_SEL, 7), |
| 634 | GATE_INFRA1_INFRA(CLK_INFRA_66M_PWM_CK6, "infra_hf_66m_pwm_ck6", |
| 635 | CLK_INFRA_PWM_CK6_SEL, 8), |
| 636 | GATE_INFRA1_INFRA(CLK_INFRA_66M_PWM_CK7, "infra_hf_66m_pwm_ck7", |
| 637 | CLK_INFRA_PWM_CK7_SEL, 9), |
| 638 | GATE_INFRA1_INFRA(CLK_INFRA_66M_PWM_CK8, "infra_hf_66m_pwm_ck8", |
| 639 | CLK_INFRA_PWM_CK8_SEL, 10), |
| 640 | GATE_INFRA1_TOP(CLK_INFRA_133M_CQDMA_BCK, "infra_hf_133m_cqdma_bck", |
| 641 | CLK_TOP_SYSAXI_SEL, 12), |
| 642 | GATE_INFRA1_TOP(CLK_INFRA_66M_AUD_SLV_BCK, "infra_66m_aud_slv_bck", |
| 643 | CLK_TOP_SYSAXI_SEL, 13), |
| 644 | GATE_INFRA1_TOP(CLK_INFRA_AUD_26M, "infra_f_faud_26m", CLK_TOP_INFRA_F26M_SEL, 14), |
| 645 | GATE_INFRA1_TOP(CLK_INFRA_AUD_L, "infra_f_faud_l", CLK_TOP_AUD_L_SEL, 15), |
| 646 | GATE_INFRA1_TOP(CLK_INFRA_AUD_AUD, "infra_f_aud_aud", CLK_TOP_A1SYS_SEL, |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 647 | 16), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 648 | GATE_INFRA1_TOP(CLK_INFRA_AUD_EG2, "infra_f_faud_eg2", CLK_TOP_A_TUNER_SEL, |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 649 | 18), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 650 | GATE_INFRA1_TOP(CLK_INFRA_DRAMC_F26M, "infra_dramc_f26m", CLK_TOP_INFRA_F26M_SEL, |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 651 | 19), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 652 | GATE_INFRA1_TOP(CLK_INFRA_133M_DBG_ACKM, "infra_hf_133m_dbg_ackm", |
| 653 | CLK_TOP_SYSAXI_SEL, 20), |
| 654 | GATE_INFRA1_TOP(CLK_INFRA_66M_AP_DMA_BCK, "infra_66m_ap_dma_bck", |
| 655 | CLK_TOP_SYSAXI_SEL, 21), |
| 656 | GATE_INFRA1_TOP(CLK_INFRA_66M_SEJ_BCK, "infra_hf_66m_sej_bck", |
| 657 | CLK_TOP_SYSAXI_SEL, 29), |
| 658 | GATE_INFRA1_TOP(CLK_INFRA_PRE_CK_SEJ_F13M, "infra_pre_ck_sej_f13m", |
| 659 | CLK_TOP_INFRA_F26M_SEL, 30), |
| 660 | /* GATE_INFRA1_TOP(CLK_INFRA_66M_TRNG, "infra_hf_66m_trng", CLK_TOP_SYSAXI_SEL, |
Christian Marangi | 6e54f03 | 2024-08-03 10:32:59 +0200 | [diff] [blame] | 661 | 31), */ |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 662 | GATE_INFRA2_TOP(CLK_INFRA_26M_THERM_SYSTEM, "infra_hf_26m_therm_system", |
| 663 | CLK_TOP_INFRA_F26M_SEL, 0), |
| 664 | GATE_INFRA2_TOP(CLK_INFRA_I2C_BCK, "infra_i2c_bck", CLK_TOP_I2C_SEL, 1), |
| 665 | /* GATE_INFRA2_TOP(CLK_INFRA_66M_UART0_PCK, "infra_hf_66m_uart0_pck", |
| 666 | CLK_TOP_SYSAXI_SEL, 3), */ |
| 667 | /* GATE_INFRA2_TOP(CLK_INFRA_66M_UART1_PCK, "infra_hf_66m_uart1_pck", |
| 668 | CLK_TOP_SYSAXI_SEL, 4), */ |
| 669 | /* GATE_INFRA2_TOP(CLK_INFRA_66M_UART2_PCK, "infra_hf_66m_uart2_pck", |
| 670 | CLK_TOP_SYSAXI_SEL, 5), */ |
| 671 | GATE_INFRA2_INFRA(CLK_INFRA_52M_UART0_CK, "infra_f_52m_uart0", |
| 672 | CLK_INFRA_MUX_UART0_SEL, 3), |
| 673 | GATE_INFRA2_INFRA(CLK_INFRA_52M_UART1_CK, "infra_f_52m_uart1", |
| 674 | CLK_INFRA_MUX_UART1_SEL, 4), |
| 675 | GATE_INFRA2_INFRA(CLK_INFRA_52M_UART2_CK, "infra_f_52m_uart2", |
| 676 | CLK_INFRA_MUX_UART2_SEL, 5), |
| 677 | GATE_INFRA2_TOP(CLK_INFRA_NFI, "infra_f_fnfi", CLK_TOP_NFI1X_SEL, 9), |
| 678 | GATE_INFRA2_TOP(CLK_INFRA_SPINFI, "infra_f_fspinfi", CLK_TOP_SPINFI_SEL, 10), |
| 679 | GATE_INFRA2_TOP(CLK_INFRA_66M_NFI_HCK, "infra_hf_66m_nfi_hck", |
| 680 | CLK_TOP_SYSAXI_SEL, 11), |
| 681 | GATE_INFRA2_INFRA(CLK_INFRA_104M_SPI0, "infra_hf_104m_spi0", |
| 682 | CLK_INFRA_MUX_SPI0_SEL, 12), |
| 683 | GATE_INFRA2_INFRA(CLK_INFRA_104M_SPI1, "infra_hf_104m_spi1", |
| 684 | CLK_INFRA_MUX_SPI1_SEL, 13), |
| 685 | GATE_INFRA2_INFRA(CLK_INFRA_104M_SPI2_BCK, "infra_hf_104m_spi2_bck", |
| 686 | CLK_INFRA_MUX_SPI2_SEL, 14), |
| 687 | GATE_INFRA2_TOP(CLK_INFRA_66M_SPI0_HCK, "infra_hf_66m_spi0_hck", |
| 688 | CLK_TOP_SYSAXI_SEL, 15), |
| 689 | GATE_INFRA2_TOP(CLK_INFRA_66M_SPI1_HCK, "infra_hf_66m_spi1_hck", |
| 690 | CLK_TOP_SYSAXI_SEL, 16), |
| 691 | GATE_INFRA2_TOP(CLK_INFRA_66M_SPI2_HCK, "infra_hf_66m_spi2_hck", |
| 692 | CLK_TOP_SYSAXI_SEL, 17), |
| 693 | GATE_INFRA2_TOP(CLK_INFRA_66M_FLASHIF_AXI, "infra_hf_66m_flashif_axi", |
| 694 | CLK_TOP_SYSAXI_SEL, 18), |
| 695 | GATE_INFRA2_TOP(CLK_INFRA_RTC, "infra_f_frtc", CLK_TOP_RTC_32K, 19), |
| 696 | GATE_INFRA2_TOP(CLK_INFRA_26M_ADC_BCK, "infra_f_26m_adc_bck", |
| 697 | CLK_TOP_INFRA_F26M_SEL, 20), |
| 698 | GATE_INFRA2_INFRA(CLK_INFRA_RC_ADC, "infra_f_frc_adc", CLK_INFRA_26M_ADC_BCK, |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 699 | 21), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 700 | GATE_INFRA2_TOP(CLK_INFRA_MSDC400, "infra_f_fmsdc400", CLK_TOP_EMMC_400M_SEL, |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 701 | 22), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 702 | GATE_INFRA2_TOP(CLK_INFRA_MSDC2_HCK, "infra_f_fmsdc2_hck", |
| 703 | CLK_TOP_EMMC_250M_SEL, 23), |
| 704 | GATE_INFRA2_TOP(CLK_INFRA_133M_MSDC_0_HCK, "infra_hf_133m_msdc_0_hck", |
| 705 | CLK_TOP_SYSAXI_SEL, 24), |
| 706 | GATE_INFRA2_TOP(CLK_INFRA_66M_MSDC_0_HCK, "infra_66m_msdc_0_hck", |
| 707 | CLK_TOP_SYSAXI_SEL, 25), |
| 708 | GATE_INFRA2_TOP(CLK_INFRA_133M_CPUM_BCK, "infra_hf_133m_cpum_bck", |
| 709 | CLK_TOP_SYSAXI_SEL, 26), |
| 710 | GATE_INFRA2_TOP(CLK_INFRA_BIST2FPC, "infra_hf_fbist2fpc", CLK_TOP_NFI1X_SEL, |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 711 | 27), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 712 | GATE_INFRA2_TOP(CLK_INFRA_I2C_X16W_MCK_CK_P1, "infra_hf_i2c_x16w_mck_ck_p1", |
| 713 | CLK_TOP_SYSAXI_SEL, 29), |
| 714 | GATE_INFRA2_TOP(CLK_INFRA_I2C_X16W_PCK_CK_P1, "infra_hf_i2c_x16w_pck_ck_p1", |
| 715 | CLK_TOP_SYSAXI_SEL, 31), |
| 716 | GATE_INFRA3_TOP(CLK_INFRA_133M_USB_HCK, "infra_133m_usb_hck", |
| 717 | CLK_TOP_SYSAXI_SEL, 0), |
| 718 | GATE_INFRA3_TOP(CLK_INFRA_133M_USB_HCK_CK_P1, "infra_133m_usb_hck_ck_p1", |
| 719 | CLK_TOP_SYSAXI_SEL, 1), |
| 720 | GATE_INFRA3_TOP(CLK_INFRA_66M_USB_HCK, "infra_66m_usb_hck", |
| 721 | CLK_TOP_SYSAXI_SEL, 2), |
| 722 | GATE_INFRA3_TOP(CLK_INFRA_66M_USB_HCK_CK_P1, "infra_66m_usb_hck_ck_p1", |
| 723 | CLK_TOP_SYSAXI_SEL, 3), |
| 724 | GATE_INFRA3_TOP(CLK_INFRA_USB_SYS, "infra_usb_sys", CLK_TOP_USB_SYS_SEL, 4), |
| 725 | GATE_INFRA3_TOP(CLK_INFRA_USB_SYS_CK_P1, "infra_usb_sys_ck_p1", |
| 726 | CLK_TOP_USB_SYS_P1_SEL, 5), |
| 727 | GATE_INFRA3_XTAL(CLK_INFRA_USB_REF, "infra_usb_ref", CLK_XTAL, 6), |
| 728 | GATE_INFRA3_XTAL(CLK_INFRA_USB_CK_P1, "infra_usb_ck_p1", CLK_XTAL, |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 729 | 7), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 730 | GATE_INFRA3_TOP(CLK_INFRA_USB_FRMCNT, "infra_usb_frmcnt", |
| 731 | CLK_TOP_USB_FRMCNT_SEL, 8), |
| 732 | GATE_INFRA3_TOP(CLK_INFRA_USB_FRMCNT_CK_P1, "infra_usb_frmcnt_ck_p1", |
| 733 | CLK_TOP_USB_FRMCNT_P1_SEL, 9), |
| 734 | GATE_INFRA3_XTAL(CLK_INFRA_USB_PIPE, "infra_usb_pipe", CLK_XTAL, |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 735 | 10), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 736 | GATE_INFRA3_XTAL(CLK_INFRA_USB_PIPE_CK_P1, "infra_usb_pipe_ck_p1", |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 737 | CLK_XTAL, 11), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 738 | GATE_INFRA3_XTAL(CLK_INFRA_USB_UTMI, "infra_usb_utmi", CLK_XTAL, |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 739 | 12), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 740 | GATE_INFRA3_XTAL(CLK_INFRA_USB_UTMI_CK_P1, "infra_usb_utmi_ck_p1", |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 741 | CLK_XTAL, 13), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 742 | GATE_INFRA3_TOP(CLK_INFRA_USB_XHCI, "infra_usb_xhci", CLK_TOP_USB_XHCI_SEL, |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 743 | 14), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 744 | GATE_INFRA3_TOP(CLK_INFRA_USB_XHCI_CK_P1, "infra_usb_xhci_ck_p1", |
| 745 | CLK_TOP_USB_XHCI_P1_SEL, 15), |
| 746 | GATE_INFRA3_INFRA(CLK_INFRA_PCIE_GFMUX_TL_P0, "infra_pcie_gfmux_tl_ck_p0", |
| 747 | CLK_INFRA_PCIE_GFMUX_TL_O_P0_SEL, 20), |
| 748 | GATE_INFRA3_INFRA(CLK_INFRA_PCIE_GFMUX_TL_P1, "infra_pcie_gfmux_tl_ck_p1", |
| 749 | CLK_INFRA_PCIE_GFMUX_TL_O_P1_SEL, 21), |
| 750 | GATE_INFRA3_INFRA(CLK_INFRA_PCIE_GFMUX_TL_P2, "infra_pcie_gfmux_tl_ck_p2", |
| 751 | CLK_INFRA_PCIE_GFMUX_TL_O_P2_SEL, 22), |
| 752 | GATE_INFRA3_INFRA(CLK_INFRA_PCIE_GFMUX_TL_P3, "infra_pcie_gfmux_tl_ck_p3", |
| 753 | CLK_INFRA_PCIE_GFMUX_TL_O_P3_SEL, 23), |
| 754 | GATE_INFRA3_XTAL(CLK_INFRA_PCIE_PIPE_P0, "infra_pcie_pipe_ck_p0", |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 755 | CLK_XTAL, 24), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 756 | GATE_INFRA3_XTAL(CLK_INFRA_PCIE_PIPE_P1, "infra_pcie_pipe_ck_p1", |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 757 | CLK_XTAL, 25), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 758 | GATE_INFRA3_XTAL(CLK_INFRA_PCIE_PIPE_P2, "infra_pcie_pipe_ck_p2", |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 759 | CLK_XTAL, 26), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 760 | GATE_INFRA3_XTAL(CLK_INFRA_PCIE_PIPE_P3, "infra_pcie_pipe_ck_p3", |
Christian Marangi | 78507c3 | 2024-08-03 10:32:55 +0200 | [diff] [blame] | 761 | CLK_XTAL, 27), |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 762 | GATE_INFRA3_TOP(CLK_INFRA_133M_PCIE_CK_P0, "infra_133m_pcie_ck_p0", |
| 763 | CLK_TOP_SYSAXI_SEL, 28), |
| 764 | GATE_INFRA3_TOP(CLK_INFRA_133M_PCIE_CK_P1, "infra_133m_pcie_ck_p1", |
| 765 | CLK_TOP_SYSAXI_SEL, 29), |
| 766 | GATE_INFRA3_TOP(CLK_INFRA_133M_PCIE_CK_P2, "infra_133m_pcie_ck_p2", |
| 767 | CLK_TOP_SYSAXI_SEL, 30), |
| 768 | GATE_INFRA3_TOP(CLK_INFRA_133M_PCIE_CK_P3, "infra_133m_pcie_ck_p3", |
| 769 | CLK_TOP_SYSAXI_SEL, 31), |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 770 | }; |
| 771 | |
| 772 | static const struct mtk_clk_tree mt7988_fixed_pll_clk_tree = { |
| 773 | .fdivs_offs = ARRAY_SIZE(apmixedsys_mtk_plls), |
| 774 | .fclks = apmixedsys_mtk_plls, |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 775 | .flags = CLK_APMIXED, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 776 | .xtal_rate = 40 * MHZ, |
| 777 | }; |
| 778 | |
| 779 | static const struct mtk_clk_tree mt7988_topckgen_clk_tree = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 780 | .fdivs_offs = CLK_TOP_XTAL_D2, |
| 781 | .muxes_offs = CLK_TOP_NETSYS_SEL, |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 782 | .fclks = topckgen_mtk_fixed_clks, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 783 | .fdivs = topckgen_mtk_fixed_factors, |
| 784 | .muxes = topckgen_mtk_muxes, |
Christian Marangi | d061f73 | 2024-08-03 10:32:58 +0200 | [diff] [blame] | 785 | .flags = CLK_BYPASS_XTAL | CLK_TOPCKGEN, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 786 | .xtal_rate = 40 * MHZ, |
| 787 | }; |
| 788 | |
| 789 | static const struct mtk_clk_tree mt7988_infracfg_clk_tree = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 790 | .muxes_offs = CLK_INFRA_MUX_UART0_SEL, |
| 791 | .gates_offs = CLK_INFRA_PCIE_PERI_26M_CK_P0, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 792 | .muxes = infracfg_mtk_mux, |
Christian Marangi | ef4a648 | 2024-08-03 10:33:01 +0200 | [diff] [blame] | 793 | .gates = infracfg_mtk_gates, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 794 | .flags = CLK_BYPASS_XTAL, |
| 795 | .xtal_rate = 40 * MHZ, |
| 796 | }; |
| 797 | |
| 798 | static const struct udevice_id mt7988_fixed_pll_compat[] = { |
| 799 | { .compatible = "mediatek,mt7988-fixed-plls" }, |
Christian Marangi | 2fa520c | 2024-06-24 23:03:39 +0200 | [diff] [blame] | 800 | { .compatible = "mediatek,mt7988-apmixedsys" }, |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 801 | {} |
| 802 | }; |
| 803 | |
| 804 | static const struct udevice_id mt7988_topckgen_compat[] = { |
| 805 | { .compatible = "mediatek,mt7988-topckgen" }, |
| 806 | {} |
| 807 | }; |
| 808 | |
| 809 | static int mt7988_fixed_pll_probe(struct udevice *dev) |
| 810 | { |
| 811 | return mtk_common_clk_init(dev, &mt7988_fixed_pll_clk_tree); |
| 812 | } |
| 813 | |
| 814 | static int mt7988_topckgen_probe(struct udevice *dev) |
| 815 | { |
| 816 | struct mtk_clk_priv *priv = dev_get_priv(dev); |
| 817 | |
| 818 | priv->base = dev_read_addr_ptr(dev); |
| 819 | if (!priv->base) |
| 820 | return -ENOENT; |
| 821 | |
| 822 | writel(MT7988_CLK_PDN_EN_WRITE, priv->base + MT7988_CLK_PDN); |
| 823 | return mtk_common_clk_init(dev, &mt7988_topckgen_clk_tree); |
| 824 | } |
| 825 | |
| 826 | U_BOOT_DRIVER(mtk_clk_apmixedsys) = { |
| 827 | .name = "mt7988-clock-fixed-pll", |
| 828 | .id = UCLASS_CLK, |
| 829 | .of_match = mt7988_fixed_pll_compat, |
| 830 | .probe = mt7988_fixed_pll_probe, |
| 831 | .priv_auto = sizeof(struct mtk_clk_priv), |
| 832 | .ops = &mtk_clk_topckgen_ops, |
| 833 | .flags = DM_FLAG_PRE_RELOC, |
| 834 | }; |
| 835 | |
| 836 | U_BOOT_DRIVER(mtk_clk_topckgen) = { |
| 837 | .name = "mt7988-clock-topckgen", |
| 838 | .id = UCLASS_CLK, |
| 839 | .of_match = mt7988_topckgen_compat, |
| 840 | .probe = mt7988_topckgen_probe, |
| 841 | .priv_auto = sizeof(struct mtk_clk_priv), |
| 842 | .ops = &mtk_clk_topckgen_ops, |
| 843 | .flags = DM_FLAG_PRE_RELOC, |
| 844 | }; |
| 845 | |
| 846 | static const struct udevice_id mt7988_infracfg_compat[] = { |
| 847 | { .compatible = "mediatek,mt7988-infracfg" }, |
| 848 | {} |
| 849 | }; |
| 850 | |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 851 | static int mt7988_infracfg_probe(struct udevice *dev) |
| 852 | { |
Christian Marangi | ef4a648 | 2024-08-03 10:33:01 +0200 | [diff] [blame] | 853 | return mtk_common_clk_infrasys_init(dev, &mt7988_infracfg_clk_tree); |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | U_BOOT_DRIVER(mtk_clk_infracfg) = { |
| 857 | .name = "mt7988-clock-infracfg", |
| 858 | .id = UCLASS_CLK, |
| 859 | .of_match = mt7988_infracfg_compat, |
| 860 | .probe = mt7988_infracfg_probe, |
| 861 | .priv_auto = sizeof(struct mtk_clk_priv), |
| 862 | .ops = &mtk_clk_infrasys_ops, |
| 863 | .flags = DM_FLAG_PRE_RELOC, |
| 864 | }; |
| 865 | |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 866 | /* ETHDMA */ |
| 867 | |
| 868 | static const struct mtk_gate_regs ethdma_cg_regs = { |
| 869 | .set_ofs = 0x30, |
| 870 | .clr_ofs = 0x30, |
| 871 | .sta_ofs = 0x30, |
| 872 | }; |
| 873 | |
| 874 | #define GATE_ETHDMA(_id, _name, _parent, _shift) \ |
| 875 | { \ |
| 876 | .id = _id, .parent = _parent, .regs = ðdma_cg_regs, \ |
| 877 | .shift = _shift, \ |
| 878 | .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ |
| 879 | } |
| 880 | |
| 881 | static const struct mtk_gate ethdma_mtk_gate[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 882 | GATE_ETHDMA(CLK_ETHDMA_FE_EN, "ethdma_fe_en", CLK_TOP_NETSYS_2X_SEL, 6), |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 883 | }; |
| 884 | |
| 885 | static int mt7988_ethdma_probe(struct udevice *dev) |
| 886 | { |
| 887 | return mtk_common_clk_gate_init(dev, &mt7988_topckgen_clk_tree, |
| 888 | ethdma_mtk_gate); |
| 889 | } |
| 890 | |
| 891 | static int mt7988_ethdma_bind(struct udevice *dev) |
| 892 | { |
| 893 | int ret = 0; |
| 894 | |
| 895 | if (CONFIG_IS_ENABLED(RESET_MEDIATEK)) { |
| 896 | ret = mediatek_reset_bind(dev, MT7988_ETHDMA_RST_CTRL_OFS, 1); |
| 897 | if (ret) |
| 898 | debug("Warning: failed to bind reset controller\n"); |
| 899 | } |
| 900 | |
| 901 | return ret; |
| 902 | } |
| 903 | |
| 904 | static const struct udevice_id mt7988_ethdma_compat[] = { |
| 905 | { |
| 906 | .compatible = "mediatek,mt7988-ethdma", |
| 907 | }, |
| 908 | {} |
| 909 | }; |
| 910 | |
| 911 | U_BOOT_DRIVER(mtk_clk_ethdma) = { |
| 912 | .name = "mt7988-clock-ethdma", |
| 913 | .id = UCLASS_CLK, |
| 914 | .of_match = mt7988_ethdma_compat, |
| 915 | .probe = mt7988_ethdma_probe, |
| 916 | .bind = mt7988_ethdma_bind, |
| 917 | .priv_auto = sizeof(struct mtk_cg_priv), |
| 918 | .ops = &mtk_clk_gate_ops, |
| 919 | }; |
| 920 | |
| 921 | /* SGMIISYS_0 */ |
| 922 | |
| 923 | static const struct mtk_gate_regs sgmii0_cg_regs = { |
| 924 | .set_ofs = 0xE4, |
| 925 | .clr_ofs = 0xE4, |
| 926 | .sta_ofs = 0xE4, |
| 927 | }; |
| 928 | |
| 929 | #define GATE_SGMII0(_id, _name, _parent, _shift) \ |
| 930 | { \ |
| 931 | .id = _id, .parent = _parent, .regs = &sgmii0_cg_regs, \ |
| 932 | .shift = _shift, \ |
| 933 | .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ |
| 934 | } |
| 935 | |
| 936 | static const struct mtk_gate sgmiisys_0_mtk_gate[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 937 | /* connect to fake clock, so use CLK_TOP_XTAL as the clock parent */ |
| 938 | GATE_SGMII0(CLK_SGM0_TX_EN, "sgm0_tx_en", CLK_TOP_XTAL, 2), |
| 939 | /* connect to fake clock, so use CLK_TOP_XTAL as the clock parent */ |
| 940 | GATE_SGMII0(CLK_SGM0_RX_EN, "sgm0_rx_en", CLK_TOP_XTAL, 3), |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 941 | }; |
| 942 | |
| 943 | static int mt7988_sgmiisys_0_probe(struct udevice *dev) |
| 944 | { |
| 945 | return mtk_common_clk_gate_init(dev, &mt7988_topckgen_clk_tree, |
| 946 | sgmiisys_0_mtk_gate); |
| 947 | } |
| 948 | |
| 949 | static const struct udevice_id mt7988_sgmiisys_0_compat[] = { |
| 950 | { |
| 951 | .compatible = "mediatek,mt7988-sgmiisys_0", |
| 952 | }, |
| 953 | {} |
| 954 | }; |
| 955 | |
| 956 | U_BOOT_DRIVER(mtk_clk_sgmiisys_0) = { |
| 957 | .name = "mt7988-clock-sgmiisys_0", |
| 958 | .id = UCLASS_CLK, |
| 959 | .of_match = mt7988_sgmiisys_0_compat, |
| 960 | .probe = mt7988_sgmiisys_0_probe, |
| 961 | .priv_auto = sizeof(struct mtk_cg_priv), |
| 962 | .ops = &mtk_clk_gate_ops, |
| 963 | }; |
| 964 | |
| 965 | /* SGMIISYS_1 */ |
| 966 | |
| 967 | static const struct mtk_gate_regs sgmii1_cg_regs = { |
| 968 | .set_ofs = 0xE4, |
| 969 | .clr_ofs = 0xE4, |
| 970 | .sta_ofs = 0xE4, |
| 971 | }; |
| 972 | |
| 973 | #define GATE_SGMII1(_id, _name, _parent, _shift) \ |
| 974 | { \ |
| 975 | .id = _id, .parent = _parent, .regs = &sgmii1_cg_regs, \ |
| 976 | .shift = _shift, \ |
| 977 | .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ |
| 978 | } |
| 979 | |
| 980 | static const struct mtk_gate sgmiisys_1_mtk_gate[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 981 | /* connect to fake clock, so use CLK_TOP_XTAL as the clock parent */ |
| 982 | GATE_SGMII1(CLK_SGM1_TX_EN, "sgm1_tx_en", CLK_TOP_XTAL, 2), |
| 983 | /* connect to fake clock, so use CLK_TOP_XTAL as the clock parent */ |
| 984 | GATE_SGMII1(CLK_SGM1_RX_EN, "sgm1_rx_en", CLK_TOP_XTAL, 3), |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 985 | }; |
| 986 | |
| 987 | static int mt7988_sgmiisys_1_probe(struct udevice *dev) |
| 988 | { |
| 989 | return mtk_common_clk_gate_init(dev, &mt7988_topckgen_clk_tree, |
| 990 | sgmiisys_1_mtk_gate); |
| 991 | } |
| 992 | |
| 993 | static const struct udevice_id mt7988_sgmiisys_1_compat[] = { |
| 994 | { |
| 995 | .compatible = "mediatek,mt7988-sgmiisys_1", |
| 996 | }, |
| 997 | {} |
| 998 | }; |
| 999 | |
| 1000 | U_BOOT_DRIVER(mtk_clk_sgmiisys_1) = { |
| 1001 | .name = "mt7988-clock-sgmiisys_1", |
| 1002 | .id = UCLASS_CLK, |
| 1003 | .of_match = mt7988_sgmiisys_1_compat, |
| 1004 | .probe = mt7988_sgmiisys_1_probe, |
| 1005 | .priv_auto = sizeof(struct mtk_cg_priv), |
| 1006 | .ops = &mtk_clk_gate_ops, |
| 1007 | }; |
| 1008 | |
| 1009 | /* ETHWARP */ |
| 1010 | |
| 1011 | static const struct mtk_gate_regs ethwarp_cg_regs = { |
| 1012 | .set_ofs = 0x14, |
| 1013 | .clr_ofs = 0x14, |
| 1014 | .sta_ofs = 0x14, |
| 1015 | }; |
| 1016 | |
| 1017 | #define GATE_ETHWARP(_id, _name, _parent, _shift) \ |
| 1018 | { \ |
| 1019 | .id = _id, .parent = _parent, .regs = ðwarp_cg_regs, \ |
| 1020 | .shift = _shift, \ |
| 1021 | .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ |
| 1022 | } |
| 1023 | |
| 1024 | static const struct mtk_gate ethwarp_mtk_gate[] = { |
Christian Marangi | 99c5fa1 | 2024-08-03 10:33:02 +0200 | [diff] [blame] | 1025 | GATE_ETHWARP(CLK_ETHWARP_WOCPU2_EN, "ethwarp_wocpu2_en", |
| 1026 | CLK_TOP_NETSYS_MCU_SEL, 13), |
| 1027 | GATE_ETHWARP(CLK_ETHWARP_WOCPU1_EN, "ethwarp_wocpu1_en", |
| 1028 | CLK_TOP_NETSYS_MCU_SEL, 14), |
| 1029 | GATE_ETHWARP(CLK_ETHWARP_WOCPU0_EN, "ethwarp_wocpu0_en", |
| 1030 | CLK_TOP_NETSYS_MCU_SEL, 15), |
Weijie Gao | 4214369 | 2023-07-19 17:16:28 +0800 | [diff] [blame] | 1031 | }; |
| 1032 | |
| 1033 | static int mt7988_ethwarp_probe(struct udevice *dev) |
| 1034 | { |
| 1035 | return mtk_common_clk_gate_init(dev, &mt7988_topckgen_clk_tree, |
| 1036 | ethwarp_mtk_gate); |
| 1037 | } |
| 1038 | |
| 1039 | static int mt7988_ethwarp_bind(struct udevice *dev) |
| 1040 | { |
| 1041 | int ret = 0; |
| 1042 | |
| 1043 | if (CONFIG_IS_ENABLED(RESET_MEDIATEK)) { |
| 1044 | ret = mediatek_reset_bind(dev, MT7988_ETHWARP_RST_CTRL_OFS, 2); |
| 1045 | if (ret) |
| 1046 | debug("Warning: failed to bind reset controller\n"); |
| 1047 | } |
| 1048 | |
| 1049 | return ret; |
| 1050 | } |
| 1051 | |
| 1052 | static const struct udevice_id mt7988_ethwarp_compat[] = { |
| 1053 | { |
| 1054 | .compatible = "mediatek,mt7988-ethwarp", |
| 1055 | }, |
| 1056 | {} |
| 1057 | }; |
| 1058 | |
| 1059 | U_BOOT_DRIVER(mtk_clk_ethwarp) = { |
| 1060 | .name = "mt7988-clock-ethwarp", |
| 1061 | .id = UCLASS_CLK, |
| 1062 | .of_match = mt7988_ethwarp_compat, |
| 1063 | .probe = mt7988_ethwarp_probe, |
| 1064 | .bind = mt7988_ethwarp_bind, |
| 1065 | .priv_auto = sizeof(struct mtk_cg_priv), |
| 1066 | .ops = &mtk_clk_gate_ops, |
| 1067 | }; |