developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 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 | |
| 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/mt7986-clk.h> |
| 14 | #include <linux/bitops.h> |
| 15 | |
| 16 | #include "clk-mtk.h" |
| 17 | |
| 18 | #define MT7986_CLK_PDN 0x250 |
| 19 | #define MT7986_CLK_PDN_EN_WRITE BIT(31) |
| 20 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 21 | #define APMIXED_PARENT(_id) PARENT(_id, CLK_PARENT_APMIXED) |
| 22 | #define INFRA_PARENT(_id) PARENT(_id, CLK_PARENT_INFRASYS) |
| 23 | #define TOP_PARENT(_id) PARENT(_id, CLK_PARENT_TOPCKGEN) |
| 24 | #define VOID_PARENT PARENT(-1, 0) |
| 25 | |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 26 | #define PLL_FACTOR(_id, _name, _parent, _mult, _div) \ |
| 27 | FACTOR(_id, _parent, _mult, _div, CLK_PARENT_APMIXED) |
| 28 | |
| 29 | #define TOP_FACTOR(_id, _name, _parent, _mult, _div) \ |
| 30 | FACTOR(_id, _parent, _mult, _div, CLK_PARENT_TOPCKGEN) |
| 31 | |
| 32 | #define INFRA_FACTOR(_id, _name, _parent, _mult, _div) \ |
| 33 | FACTOR(_id, _parent, _mult, _div, CLK_PARENT_INFRASYS) |
| 34 | |
| 35 | /* FIXED PLLS */ |
| 36 | static const struct mtk_fixed_clk fixed_pll_clks[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 37 | FIXED_CLK(CLK_APMIXED_ARMPLL, CLK_XTAL, 2000000000), |
| 38 | FIXED_CLK(CLK_APMIXED_NET2PLL, CLK_XTAL, 800000000), |
| 39 | FIXED_CLK(CLK_APMIXED_MMPLL, CLK_XTAL, 1440000000), |
| 40 | FIXED_CLK(CLK_APMIXED_SGMPLL, CLK_XTAL, 325000000), |
| 41 | FIXED_CLK(CLK_APMIXED_WEDMCUPLL, CLK_XTAL, 760000000), |
| 42 | FIXED_CLK(CLK_APMIXED_NET1PLL, CLK_XTAL, 2500000000), |
| 43 | FIXED_CLK(CLK_APMIXED_MPLL, CLK_XTAL, 416000000), |
| 44 | FIXED_CLK(CLK_APMIXED_APLL2, CLK_XTAL, 196608000), |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | /* TOPCKGEN FIXED CLK */ |
| 48 | static const struct mtk_fixed_clk top_fixed_clks[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 49 | FIXED_CLK(CLK_TOP_XTAL, CLK_XTAL, 40000000), |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | /* TOPCKGEN FIXED DIV */ |
| 53 | static const struct mtk_fixed_factor top_fixed_divs[] = { |
Christian Marangi | 83b17ec | 2024-08-03 10:40:42 +0200 | [diff] [blame] | 54 | /* TOP Factors */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 55 | TOP_FACTOR(CLK_TOP_XTAL_D2, "xtal_d2", CLK_TOP_XTAL, |
Christian Marangi | 83b17ec | 2024-08-03 10:40:42 +0200 | [diff] [blame] | 56 | 1, 2), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 57 | TOP_FACTOR(CLK_TOP_RTC_32K, "rtc_32k", CLK_TOP_XTAL, 1, |
Christian Marangi | 83b17ec | 2024-08-03 10:40:42 +0200 | [diff] [blame] | 58 | 1250), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 59 | TOP_FACTOR(CLK_TOP_RTC_32P7K, "rtc_32p7k", CLK_TOP_XTAL, 1, |
Christian Marangi | 83b17ec | 2024-08-03 10:40:42 +0200 | [diff] [blame] | 60 | 1220), |
Christian Marangi | efc33e4 | 2024-08-03 10:40:44 +0200 | [diff] [blame] | 61 | /* Not defined upstream and not used */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 62 | /* TOP_FACTOR(CLK_TOP_A_TUNER, "a_tuner", CLK_TOP_A_TUNER_SEL, 2, 1), */ |
Christian Marangi | 9276f07 | 2024-08-03 10:40:41 +0200 | [diff] [blame] | 63 | /* MPLL */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 64 | PLL_FACTOR(CLK_TOP_MPLL_D2, "mpll_d2", CLK_APMIXED_MPLL, 1, 2), |
| 65 | PLL_FACTOR(CLK_TOP_MPLL_D4, "mpll_d4", CLK_APMIXED_MPLL, 1, 4), |
| 66 | PLL_FACTOR(CLK_TOP_MPLL_D8, "mpll_d8", CLK_APMIXED_MPLL, 1, 8), |
| 67 | PLL_FACTOR(CLK_TOP_MPLL_D8_D2, "mpll_d8_d2", CLK_APMIXED_MPLL, 1, 16), |
| 68 | PLL_FACTOR(CLK_TOP_MPLL_D3_D2, "mpll_d3_d2", CLK_APMIXED_MPLL, 1, 2), |
Christian Marangi | 9276f07 | 2024-08-03 10:40:41 +0200 | [diff] [blame] | 69 | /* MMPLL */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 70 | PLL_FACTOR(CLK_TOP_MMPLL_D2, "mmpll_d2", CLK_APMIXED_MMPLL, 1, 2), |
| 71 | PLL_FACTOR(CLK_TOP_MMPLL_D4, "mmpll_d4", CLK_APMIXED_MMPLL, 1, 4), |
| 72 | PLL_FACTOR(CLK_TOP_MMPLL_D8, "mmpll_d8", CLK_APMIXED_MMPLL, 1, 8), |
| 73 | PLL_FACTOR(CLK_TOP_MMPLL_D8_D2, "mmpll_d8_d2", CLK_APMIXED_MMPLL, 1, 16), |
| 74 | PLL_FACTOR(CLK_TOP_MMPLL_D3_D8, "mmpll_d3_d8", CLK_APMIXED_MMPLL, 1, 8), |
| 75 | PLL_FACTOR(CLK_TOP_MMPLL_U2PHYD, "mmpll_u2phy", CLK_APMIXED_MMPLL, 1, 30), |
Christian Marangi | 9276f07 | 2024-08-03 10:40:41 +0200 | [diff] [blame] | 76 | /* APLL2 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 77 | PLL_FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", CLK_APMIXED_APLL2, 1, 4), |
Christian Marangi | 9276f07 | 2024-08-03 10:40:41 +0200 | [diff] [blame] | 78 | /* NET1PLL */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 79 | PLL_FACTOR(CLK_TOP_NET1PLL_D4, "net1pll_d4", CLK_APMIXED_NET1PLL, 1, 4), |
| 80 | PLL_FACTOR(CLK_TOP_NET1PLL_D5, "net1pll_d5", CLK_APMIXED_NET1PLL, 1, 5), |
| 81 | PLL_FACTOR(CLK_TOP_NET1PLL_D5_D2, "net1pll_d5_d2", CLK_APMIXED_NET1PLL, 1, 10), |
| 82 | PLL_FACTOR(CLK_TOP_NET1PLL_D5_D4, "net1pll_d5_d4", CLK_APMIXED_NET1PLL, 1, 20), |
| 83 | PLL_FACTOR(CLK_TOP_NET1PLL_D8_D2, "net1pll_d8_d2", CLK_APMIXED_NET1PLL, 1, 16), |
| 84 | PLL_FACTOR(CLK_TOP_NET1PLL_D8_D4, "net1pll_d8_d4", CLK_APMIXED_NET1PLL, 1, 32), |
Christian Marangi | 9276f07 | 2024-08-03 10:40:41 +0200 | [diff] [blame] | 85 | /* NET2PLL */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 86 | PLL_FACTOR(CLK_TOP_NET2PLL_D4, "net2pll_d4", CLK_APMIXED_NET2PLL, 1, 4), |
| 87 | PLL_FACTOR(CLK_TOP_NET2PLL_D4_D2, "net2pll_d4_d2", CLK_APMIXED_NET2PLL, 1, 8), |
| 88 | PLL_FACTOR(CLK_TOP_NET2PLL_D3_D2, "net2pll_d3_d2", CLK_APMIXED_NET2PLL, 1, 2), |
Christian Marangi | 9276f07 | 2024-08-03 10:40:41 +0200 | [diff] [blame] | 89 | /* WEDMCUPLL */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 90 | PLL_FACTOR(CLK_TOP_WEDMCUPLL_D5_D2, "wedmcupll_d5_d2", CLK_APMIXED_WEDMCUPLL, 1, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 91 | 10), |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | /* TOPCKGEN MUX PARENTS */ |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 95 | static const struct mtk_parent nfi1x_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 96 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MMPLL_D8), |
| 97 | TOP_PARENT(CLK_TOP_NET1PLL_D8_D2), TOP_PARENT(CLK_TOP_NET2PLL_D3_D2), |
| 98 | TOP_PARENT(CLK_TOP_MPLL_D4), TOP_PARENT(CLK_TOP_MMPLL_D8_D2), |
| 99 | TOP_PARENT(CLK_TOP_WEDMCUPLL_D5_D2), TOP_PARENT(CLK_TOP_MPLL_D8), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 100 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 101 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 102 | static const struct mtk_parent spinfi_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 103 | TOP_PARENT(CLK_TOP_XTAL_D2), TOP_PARENT(CLK_TOP_XTAL), |
| 104 | TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), TOP_PARENT(CLK_TOP_MPLL_D4), |
| 105 | TOP_PARENT(CLK_TOP_MMPLL_D8_D2), TOP_PARENT(CLK_TOP_WEDMCUPLL_D5_D2), |
| 106 | TOP_PARENT(CLK_TOP_MMPLL_D3_D8), TOP_PARENT(CLK_TOP_MPLL_D8), |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 107 | }; |
| 108 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 109 | static const struct mtk_parent spi_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 110 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MPLL_D2), |
| 111 | TOP_PARENT(CLK_TOP_MMPLL_D8), TOP_PARENT(CLK_TOP_NET1PLL_D8_D2), |
| 112 | TOP_PARENT(CLK_TOP_NET2PLL_D3_D2), TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), |
| 113 | TOP_PARENT(CLK_TOP_MPLL_D4), TOP_PARENT(CLK_TOP_WEDMCUPLL_D5_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 114 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 115 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 116 | static const struct mtk_parent uart_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 117 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MPLL_D8), |
| 118 | TOP_PARENT(CLK_TOP_MPLL_D8_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 119 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 120 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 121 | static const struct mtk_parent pwm_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 122 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D8_D2), |
| 123 | TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), TOP_PARENT(CLK_TOP_MPLL_D4), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 124 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 125 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 126 | static const struct mtk_parent i2c_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 127 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), |
| 128 | TOP_PARENT(CLK_TOP_MPLL_D4), TOP_PARENT(CLK_TOP_NET1PLL_D8_D4), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 129 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 130 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 131 | static const struct mtk_parent pextp_tl_ck_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 132 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), |
| 133 | TOP_PARENT(CLK_TOP_NET2PLL_D4_D2), TOP_PARENT(CLK_TOP_RTC_32K), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 134 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 135 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 136 | static const struct mtk_parent emmc_250m_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 137 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 138 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 139 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 140 | static const struct mtk_parent emmc_416m_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 141 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_MPLL), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 142 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 143 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 144 | static const struct mtk_parent f_26m_adc_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 145 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MPLL_D8_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 146 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 147 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 148 | static const struct mtk_parent dramc_md32_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 149 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MPLL_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 150 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 151 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 152 | static const struct mtk_parent sysaxi_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 153 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D8_D2), |
| 154 | TOP_PARENT(CLK_TOP_NET2PLL_D4), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 155 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 156 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 157 | static const struct mtk_parent sysapb_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 158 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MPLL_D3_D2), |
| 159 | TOP_PARENT(CLK_TOP_NET2PLL_D4_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 160 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 161 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 162 | static const struct mtk_parent arm_db_main_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 163 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET2PLL_D3_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 164 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 165 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 166 | static const struct mtk_parent arm_db_jtsel_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 167 | VOID_PARENT, TOP_PARENT(CLK_TOP_XTAL), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 168 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 169 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 170 | static const struct mtk_parent netsys_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 171 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MMPLL_D4), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 172 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 173 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 174 | static const struct mtk_parent netsys_500m_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 175 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 176 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 177 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 178 | static const struct mtk_parent netsys_mcu_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 179 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_WEDMCUPLL), |
| 180 | TOP_PARENT(CLK_TOP_MMPLL_D2), TOP_PARENT(CLK_TOP_NET1PLL_D4), |
| 181 | TOP_PARENT(CLK_TOP_NET1PLL_D5), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 182 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 183 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 184 | static const struct mtk_parent netsys_2x_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 185 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_APMIXED_NET2PLL), |
| 186 | APMIXED_PARENT(CLK_APMIXED_WEDMCUPLL), TOP_PARENT(CLK_TOP_MMPLL_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 187 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 188 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 189 | static const struct mtk_parent sgm_325m_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 190 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_SGMPLL), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 191 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 192 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 193 | static const struct mtk_parent sgm_reg_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 194 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D8_D4), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 195 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 196 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 197 | static const struct mtk_parent a1sys_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 198 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_APLL2_D4), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 199 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 200 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 201 | static const struct mtk_parent conn_mcusys_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 202 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MMPLL_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 203 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 204 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 205 | static const struct mtk_parent eip_b_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 206 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_NET2PLL), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 207 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 208 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 209 | static const struct mtk_parent aud_l_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 210 | TOP_PARENT(CLK_TOP_XTAL), APMIXED_PARENT(CLK_APMIXED_APLL2), |
| 211 | TOP_PARENT(CLK_TOP_MPLL_D8_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 212 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 213 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 214 | static const struct mtk_parent a_tuner_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 215 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_APLL2_D4), |
| 216 | TOP_PARENT(CLK_TOP_MPLL_D8_D2), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 217 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 218 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 219 | static const struct mtk_parent u2u3_sys_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 220 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_NET1PLL_D5_D4), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 221 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 222 | |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 223 | static const struct mtk_parent da_u2_refsel_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 224 | TOP_PARENT(CLK_TOP_XTAL), TOP_PARENT(CLK_TOP_MMPLL_U2PHYD), |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 225 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 226 | |
| 227 | #define TOP_MUX(_id, _name, _parents, _mux_ofs, _mux_set_ofs, _mux_clr_ofs, \ |
| 228 | _shift, _width, _gate, _upd_ofs, _upd) \ |
| 229 | { \ |
| 230 | .id = _id, .mux_reg = _mux_ofs, .mux_set_reg = _mux_set_ofs, \ |
| 231 | .mux_clr_reg = _mux_clr_ofs, .upd_reg = _upd_ofs, \ |
| 232 | .upd_shift = _upd, .mux_shift = _shift, \ |
| 233 | .mux_mask = BIT(_width) - 1, .gate_reg = _mux_ofs, \ |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 234 | .gate_shift = _gate, .parent_flags = _parents, \ |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 235 | .num_parents = ARRAY_SIZE(_parents), \ |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 236 | .flags = CLK_MUX_SETCLR_UPD | CLK_PARENT_MIXED, \ |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | /* TOPCKGEN MUX_GATE */ |
| 240 | static const struct mtk_composite top_muxes[] = { |
| 241 | /* CLK_CFG_0 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 242 | TOP_MUX(CLK_TOP_NFI1X_SEL, "nfi1x_sel", nfi1x_parents, 0x000, 0x004, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 243 | 0x008, 0, 3, 7, 0x1C0, 0), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 244 | TOP_MUX(CLK_TOP_SPINFI_SEL, "spinfi_sel", spinfi_parents, 0x000, 0x004, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 245 | 0x008, 8, 3, 15, 0x1C0, 1), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 246 | TOP_MUX(CLK_TOP_SPI_SEL, "spi_sel", spi_parents, 0x000, 0x004, 0x008, 16, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 247 | 3, 23, 0x1C0, 2), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 248 | TOP_MUX(CLK_TOP_SPIM_MST_SEL, "spim_mst_sel", spi_parents, 0x000, 0x004, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 249 | 0x008, 24, 3, 31, 0x1C0, 3), |
| 250 | /* CLK_CFG_1 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 251 | TOP_MUX(CLK_TOP_UART_SEL, "uart_sel", uart_parents, 0x010, 0x014, 0x018, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 252 | 0, 2, 7, 0x1C0, 4), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 253 | TOP_MUX(CLK_TOP_PWM_SEL, "pwm_sel", pwm_parents, 0x010, 0x014, 0x018, 8, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 254 | 2, 15, 0x1C0, 5), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 255 | TOP_MUX(CLK_TOP_I2C_SEL, "i2c_sel", i2c_parents, 0x010, 0x014, 0x018, 16, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 256 | 2, 23, 0x1C0, 6), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 257 | TOP_MUX(CLK_TOP_PEXTP_TL_SEL, "pextp_tl_ck_sel", pextp_tl_ck_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 258 | 0x010, 0x014, 0x018, 24, 2, 31, 0x1C0, 7), |
| 259 | /* CLK_CFG_2 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 260 | TOP_MUX(CLK_TOP_EMMC_250M_SEL, "emmc_250m_sel", emmc_250m_parents, 0x020, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 261 | 0x024, 0x028, 0, 1, 7, 0x1C0, 8), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 262 | TOP_MUX(CLK_TOP_EMMC_416M_SEL, "emmc_416m_sel", emmc_416m_parents, 0x020, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 263 | 0x024, 0x028, 8, 1, 15, 0x1C0, 9), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 264 | TOP_MUX(CLK_TOP_F_26M_ADC_SEL, "f_26m_adc_sel", f_26m_adc_parents, 0x020, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 265 | 0x024, 0x028, 16, 1, 23, 0x1C0, 10), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 266 | TOP_MUX(CLK_TOP_DRAMC_SEL, "dramc_sel", f_26m_adc_parents, 0x020, 0x024, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 267 | 0x028, 24, 1, 31, 0x1C0, 11), |
| 268 | /* CLK_CFG_3 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 269 | TOP_MUX(CLK_TOP_DRAMC_MD32_SEL, "dramc_md32_sel", dramc_md32_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 270 | 0x030, 0x034, 0x038, 0, 1, 7, 0x1C0, 12), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 271 | TOP_MUX(CLK_TOP_SYSAXI_SEL, "sysaxi_sel", sysaxi_parents, 0x030, 0x034, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 272 | 0x038, 8, 2, 15, 0x1C0, 13), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 273 | TOP_MUX(CLK_TOP_SYSAPB_SEL, "sysapb_sel", sysapb_parents, 0x030, 0x034, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 274 | 0x038, 16, 2, 23, 0x1C0, 14), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 275 | TOP_MUX(CLK_TOP_ARM_DB_MAIN_SEL, "arm_db_main_sel", arm_db_main_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 276 | 0x030, 0x034, 0x038, 24, 1, 31, 0x1C0, 15), |
| 277 | /* CLK_CFG_4 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 278 | TOP_MUX(CLK_TOP_ARM_DB_JTSEL, "arm_db_jtsel", arm_db_jtsel_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 279 | 0x040, 0x044, 0x048, 0, 1, 7, 0x1C0, 16), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 280 | TOP_MUX(CLK_TOP_NETSYS_SEL, "netsys_sel", netsys_parents, 0x040, 0x044, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 281 | 0x048, 8, 1, 15, 0x1C0, 17), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 282 | TOP_MUX(CLK_TOP_NETSYS_500M_SEL, "netsys_500m_sel", netsys_500m_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 283 | 0x040, 0x044, 0x048, 16, 1, 23, 0x1C0, 18), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 284 | TOP_MUX(CLK_TOP_NETSYS_MCU_SEL, "netsys_mcu_sel", netsys_mcu_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 285 | 0x040, 0x044, 0x048, 24, 3, 31, 0x1C0, 19), |
| 286 | /* CLK_CFG_5 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 287 | TOP_MUX(CLK_TOP_NETSYS_2X_SEL, "netsys_2x_sel", netsys_2x_parents, 0x050, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 288 | 0x054, 0x058, 0, 2, 7, 0x1C0, 20), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 289 | TOP_MUX(CLK_TOP_SGM_325M_SEL, "sgm_325m_sel", sgm_325m_parents, 0x050, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 290 | 0x054, 0x058, 8, 1, 15, 0x1C0, 21), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 291 | TOP_MUX(CLK_TOP_SGM_REG_SEL, "sgm_reg_sel", sgm_reg_parents, 0x050, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 292 | 0x054, 0x058, 16, 1, 23, 0x1C0, 22), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 293 | TOP_MUX(CLK_TOP_A1SYS_SEL, "a1sys_sel", a1sys_parents, 0x050, 0x054, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 294 | 0x058, 24, 1, 31, 0x1C0, 23), |
| 295 | /* CLK_CFG_6 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 296 | TOP_MUX(CLK_TOP_CONN_MCUSYS_SEL, "conn_mcusys_sel", conn_mcusys_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 297 | 0x060, 0x064, 0x068, 0, 1, 7, 0x1C0, 24), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 298 | TOP_MUX(CLK_TOP_EIP_B_SEL, "eip_b_sel", eip_b_parents, 0x060, 0x064, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 299 | 0x068, 8, 1, 15, 0x1C0, 25), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 300 | TOP_MUX(CLK_TOP_PCIE_PHY_SEL, "pcie_phy_sel", f_26m_adc_parents, 0x060, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 301 | 0x064, 0x068, 16, 1, 23, 0x1C0, 26), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 302 | TOP_MUX(CLK_TOP_USB3_PHY_SEL, "usb3_phy_sel", f_26m_adc_parents, 0x060, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 303 | 0x064, 0x068, 24, 1, 31, 0x1C0, 27), |
| 304 | /* CLK_CFG_7 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 305 | TOP_MUX(CLK_TOP_F26M_SEL, "csw_f26m_sel", f_26m_adc_parents, 0x070, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 306 | 0x074, 0x078, 0, 1, 7, 0x1C0, 28), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 307 | TOP_MUX(CLK_TOP_AUD_L_SEL, "aud_l_sel", aud_l_parents, 0x070, 0x074, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 308 | 0x078, 8, 2, 15, 0x1C0, 29), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 309 | TOP_MUX(CLK_TOP_A_TUNER_SEL, "a_tuner_sel", a_tuner_parents, 0x070, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 310 | 0x074, 0x078, 16, 2, 23, 0x1C0, 30), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 311 | TOP_MUX(CLK_TOP_U2U3_SEL, "u2u3_sel", f_26m_adc_parents, 0x070, 0x074, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 312 | 0x078, 24, 1, 31, 0x1C4, 0), |
| 313 | /* CLK_CFG_8 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 314 | TOP_MUX(CLK_TOP_U2U3_SYS_SEL, "u2u3_sys_sel", u2u3_sys_parents, 0x080, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 315 | 0x084, 0x088, 0, 1, 7, 0x1C4, 1), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 316 | TOP_MUX(CLK_TOP_U2U3_XHCI_SEL, "u2u3_xhci_sel", u2u3_sys_parents, 0x080, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 317 | 0x084, 0x088, 8, 1, 15, 0x1C4, 2), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 318 | TOP_MUX(CLK_TOP_DA_U2_REFSEL, "da_u2_refsel", da_u2_refsel_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 319 | 0x080, 0x084, 0x088, 16, 1, 23, 0x1C4, 3), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 320 | TOP_MUX(CLK_TOP_DA_U2_CK_1P_SEL, "da_u2_ck_1p_sel", da_u2_refsel_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 321 | 0x080, 0x084, 0x088, 24, 1, 31, 0x1C4, 4), |
| 322 | /* CLK_CFG_9 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 323 | TOP_MUX(CLK_TOP_AP2CNN_HOST_SEL, "ap2cnn_host_sel", sgm_reg_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 324 | 0x090, 0x094, 0x098, 0, 1, 7, 0x1C4, 5), |
| 325 | }; |
| 326 | |
| 327 | /* INFRA FIXED DIV */ |
| 328 | static const struct mtk_fixed_factor infra_fixed_divs[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 329 | TOP_FACTOR(CLK_INFRA_SYSAXI_D2, "infra_sysaxi_d2", CLK_TOP_SYSAXI_SEL, 1, 2), |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 330 | }; |
| 331 | |
| 332 | /* INFRASYS MUX PARENTS */ |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 333 | |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 334 | |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 335 | static const struct mtk_parent infra_uart0_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 336 | TOP_PARENT(CLK_TOP_F26M_SEL), |
| 337 | TOP_PARENT(CLK_TOP_UART_SEL) |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 338 | }; |
| 339 | |
| 340 | static const struct mtk_parent infra_spi0_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 341 | TOP_PARENT(CLK_TOP_I2C_SEL), |
| 342 | TOP_PARENT(CLK_TOP_SPI_SEL) |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 343 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 344 | |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 345 | static const struct mtk_parent infra_spi1_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 346 | TOP_PARENT(CLK_TOP_I2C_SEL), |
| 347 | TOP_PARENT(CLK_TOP_SPINFI_SEL) |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 348 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 349 | |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 350 | static const struct mtk_parent infra_pwm_bsel_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 351 | TOP_PARENT(CLK_TOP_RTC_32P7K), |
| 352 | TOP_PARENT(CLK_TOP_F26M_SEL), |
| 353 | INFRA_PARENT(CLK_INFRA_SYSAXI_D2), |
| 354 | TOP_PARENT(CLK_TOP_PWM_SEL) |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 355 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 356 | |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 357 | static const struct mtk_parent infra_pcie_parents[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 358 | TOP_PARENT(CLK_TOP_RTC_32P7K), |
| 359 | TOP_PARENT(CLK_TOP_F26M_SEL), |
| 360 | TOP_PARENT(CLK_TOP_XTAL), |
| 361 | TOP_PARENT(CLK_TOP_PEXTP_TL_SEL) |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 362 | }; |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 363 | |
| 364 | #define INFRA_MUX(_id, _name, _parents, _reg, _shift, _width) \ |
| 365 | { \ |
| 366 | .id = _id, .mux_reg = (_reg) + 0x8, \ |
| 367 | .mux_set_reg = (_reg) + 0x0, .mux_clr_reg = (_reg) + 0x4, \ |
| 368 | .mux_shift = _shift, .mux_mask = BIT(_width) - 1, \ |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 369 | .parent_flags = _parents, .num_parents = ARRAY_SIZE(_parents), \ |
| 370 | .flags = CLK_MUX_SETCLR_UPD | CLK_PARENT_MIXED, \ |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | /* INFRA MUX */ |
| 374 | |
| 375 | static const struct mtk_composite infra_muxes[] = { |
| 376 | /* MODULE_CLK_SEL_0 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 377 | INFRA_MUX(CLK_INFRA_UART0_SEL, "infra_uart0_sel", infra_uart0_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 378 | 0x10, 0, 1), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 379 | INFRA_MUX(CLK_INFRA_UART1_SEL, "infra_uart1_sel", infra_uart0_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 380 | 0x10, 1, 1), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 381 | INFRA_MUX(CLK_INFRA_UART2_SEL, "infra_uart2_sel", infra_uart0_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 382 | 0x10, 2, 1), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 383 | INFRA_MUX(CLK_INFRA_SPI0_SEL, "infra_spi0_sel", infra_spi0_parents, 0x10, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 384 | 4, 1), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 385 | INFRA_MUX(CLK_INFRA_SPI1_SEL, "infra_spi1_sel", infra_spi1_parents, 0x10, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 386 | 5, 1), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 387 | INFRA_MUX(CLK_INFRA_PWM1_SEL, "infra_pwm1_sel", infra_pwm_bsel_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 388 | 0x10, 9, 2), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 389 | INFRA_MUX(CLK_INFRA_PWM2_SEL, "infra_pwm2_sel", infra_pwm_bsel_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 390 | 0x10, 11, 2), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 391 | INFRA_MUX(CLK_INFRA_PWM_BSEL, "infra_pwm_bsel", infra_pwm_bsel_parents, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 392 | 0x10, 13, 2), |
| 393 | /* MODULE_CLK_SEL_1 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 394 | INFRA_MUX(CLK_INFRA_PCIE_SEL, "infra_pcie_sel", infra_pcie_parents, 0x20, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 395 | 0, 2), |
| 396 | }; |
| 397 | |
| 398 | static const struct mtk_gate_regs infra_0_cg_regs = { |
| 399 | .set_ofs = 0x40, |
| 400 | .clr_ofs = 0x44, |
| 401 | .sta_ofs = 0x48, |
| 402 | }; |
| 403 | |
| 404 | static const struct mtk_gate_regs infra_1_cg_regs = { |
| 405 | .set_ofs = 0x50, |
| 406 | .clr_ofs = 0x54, |
| 407 | .sta_ofs = 0x58, |
| 408 | }; |
| 409 | |
| 410 | static const struct mtk_gate_regs infra_2_cg_regs = { |
| 411 | .set_ofs = 0x60, |
| 412 | .clr_ofs = 0x64, |
| 413 | .sta_ofs = 0x68, |
| 414 | }; |
| 415 | |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 416 | #define GATE_INFRA0(_id, _name, _parent, _shift, _flags) \ |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 417 | { \ |
| 418 | .id = _id, .parent = _parent, .regs = &infra_0_cg_regs, \ |
| 419 | .shift = _shift, \ |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 420 | .flags = _flags, \ |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 421 | } |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 422 | #define GATE_INFRA0_INFRA(_id, _name, _parent, _shift) \ |
| 423 | GATE_INFRA0(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_INFRASYS) |
| 424 | #define GATE_INFRA0_TOP(_id, _name, _parent, _shift) \ |
| 425 | GATE_INFRA0(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN) |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 426 | |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 427 | #define GATE_INFRA1(_id, _name, _parent, _shift, _flags) \ |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 428 | { \ |
| 429 | .id = _id, .parent = _parent, .regs = &infra_1_cg_regs, \ |
| 430 | .shift = _shift, \ |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 431 | .flags = _flags, \ |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 432 | } |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 433 | #define GATE_INFRA1_INFRA(_id, _name, _parent, _shift) \ |
| 434 | GATE_INFRA1(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_INFRASYS) |
| 435 | #define GATE_INFRA1_TOP(_id, _name, _parent, _shift) \ |
| 436 | GATE_INFRA1(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN) |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 437 | |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 438 | #define GATE_INFRA2(_id, _name, _parent, _shift, _flags) \ |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 439 | { \ |
| 440 | .id = _id, .parent = _parent, .regs = &infra_2_cg_regs, \ |
| 441 | .shift = _shift, \ |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 442 | .flags = _flags, \ |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 443 | } |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 444 | #define GATE_INFRA2_INFRA(_id, _name, _parent, _shift) \ |
| 445 | GATE_INFRA2(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_INFRASYS) |
| 446 | #define GATE_INFRA2_TOP(_id, _name, _parent, _shift) \ |
| 447 | GATE_INFRA2(_id, _name, _parent, _shift, CLK_GATE_SETCLR | CLK_PARENT_TOPCKGEN) |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 448 | |
| 449 | /* INFRA GATE */ |
| 450 | |
Christian Marangi | bf79ce0 | 2024-08-03 10:40:47 +0200 | [diff] [blame] | 451 | static const struct mtk_gate infracfg_gates[] = { |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 452 | /* INFRA0 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 453 | GATE_INFRA0_INFRA(CLK_INFRA_GPT_STA, "infra_gpt_sta", CLK_INFRA_SYSAXI_D2, 0), |
| 454 | GATE_INFRA0_INFRA(CLK_INFRA_PWM_HCK, "infra_pwm_hck", CLK_INFRA_SYSAXI_D2, 1), |
| 455 | GATE_INFRA0_INFRA(CLK_INFRA_PWM_STA, "infra_pwm_sta", CLK_INFRA_PWM_BSEL, 2), |
| 456 | GATE_INFRA0_INFRA(CLK_INFRA_PWM1_CK, "infra_pwm1", CLK_INFRA_PWM1_SEL, 3), |
| 457 | GATE_INFRA0_INFRA(CLK_INFRA_PWM2_CK, "infra_pwm2", CLK_INFRA_PWM2_SEL, 4), |
| 458 | GATE_INFRA0_TOP(CLK_INFRA_CQ_DMA_CK, "infra_cq_dma", CLK_TOP_SYSAXI_SEL, 6), |
| 459 | GATE_INFRA0_TOP(CLK_INFRA_EIP97_CK, "infra_eip97", CLK_TOP_EIP_B_SEL, 7), |
| 460 | GATE_INFRA0_TOP(CLK_INFRA_AUD_BUS_CK, "infra_aud_bus", CLK_TOP_SYSAXI_SEL, 8), |
| 461 | GATE_INFRA0_TOP(CLK_INFRA_AUD_26M_CK, "infra_aud_26m", CLK_TOP_F26M_SEL, 9), |
| 462 | GATE_INFRA0_TOP(CLK_INFRA_AUD_L_CK, "infra_aud_l", CLK_TOP_AUD_L_SEL, 10), |
| 463 | GATE_INFRA0_TOP(CLK_INFRA_AUD_AUD_CK, "infra_aud_aud", CLK_TOP_A1SYS_SEL, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 464 | 11), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 465 | GATE_INFRA0_TOP(CLK_INFRA_AUD_EG2_CK, "infra_aud_eg2", CLK_TOP_A_TUNER_SEL, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 466 | 13), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 467 | GATE_INFRA0_TOP(CLK_INFRA_DRAMC_26M_CK, "infra_dramc_26m", CLK_TOP_F26M_SEL, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 468 | 14), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 469 | GATE_INFRA0_INFRA(CLK_INFRA_DBG_CK, "infra_dbg", CLK_INFRA_SYSAXI_D2, 15), |
| 470 | GATE_INFRA0_INFRA(CLK_INFRA_AP_DMA_CK, "infra_ap_dma", CLK_INFRA_SYSAXI_D2, 16), |
| 471 | GATE_INFRA0_INFRA(CLK_INFRA_SEJ_CK, "infra_sej", CLK_INFRA_SYSAXI_D2, 24), |
| 472 | GATE_INFRA0_TOP(CLK_INFRA_SEJ_13M_CK, "infra_sej_13m", CLK_TOP_F26M_SEL, 25), |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 473 | /* INFRA1 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 474 | GATE_INFRA1_TOP(CLK_INFRA_THERM_CK, "infra_therm", CLK_TOP_F26M_SEL, 0), |
| 475 | GATE_INFRA1_TOP(CLK_INFRA_I2C0_CK, "infra_i2co", CLK_TOP_I2C_SEL, 1), |
| 476 | GATE_INFRA1_INFRA(CLK_INFRA_UART0_CK, "infra_uart0", CLK_INFRA_UART0_SEL, 2), |
| 477 | GATE_INFRA1_INFRA(CLK_INFRA_UART1_CK, "infra_uart1", CLK_INFRA_UART1_SEL, 3), |
| 478 | GATE_INFRA1_INFRA(CLK_INFRA_UART2_CK, "infra_uart2", CLK_INFRA_UART2_SEL, 4), |
| 479 | GATE_INFRA1_TOP(CLK_INFRA_NFI1_CK, "infra_nfi1", CLK_TOP_NFI1X_SEL, 8), |
| 480 | GATE_INFRA1_TOP(CLK_INFRA_SPINFI1_CK, "infra_spinfi1", CLK_TOP_SPINFI_SEL, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 481 | 9), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 482 | GATE_INFRA1_INFRA(CLK_INFRA_NFI_HCK_CK, "infra_nfi_hck", CLK_INFRA_SYSAXI_D2, 10), |
| 483 | GATE_INFRA1_INFRA(CLK_INFRA_SPI0_CK, "infra_spi0", CLK_INFRA_SPI0_SEL, 11), |
| 484 | GATE_INFRA1_INFRA(CLK_INFRA_SPI1_CK, "infra_spi1", CLK_INFRA_SPI1_SEL, 12), |
| 485 | GATE_INFRA1_INFRA(CLK_INFRA_SPI0_HCK_CK, "infra_spi0_hck", CLK_INFRA_SYSAXI_D2, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 486 | 13), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 487 | GATE_INFRA1_INFRA(CLK_INFRA_SPI1_HCK_CK, "infra_spi1_hck", CLK_INFRA_SYSAXI_D2, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 488 | 14), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 489 | GATE_INFRA1_TOP(CLK_INFRA_FRTC_CK, "infra_frtc", CLK_TOP_RTC_32K, 15), |
| 490 | GATE_INFRA1_TOP(CLK_INFRA_MSDC_CK, "infra_msdc", CLK_TOP_EMMC_416M_SEL, 16), |
| 491 | GATE_INFRA1_TOP(CLK_INFRA_MSDC_HCK_CK, "infra_msdc_hck", |
| 492 | CLK_TOP_EMMC_250M_SEL, 17), |
| 493 | GATE_INFRA1_TOP(CLK_INFRA_MSDC_133M_CK, "infra_msdc_133m", |
| 494 | CLK_TOP_SYSAXI_SEL, 18), |
| 495 | GATE_INFRA1_INFRA(CLK_INFRA_MSDC_66M_CK, "infra_msdc_66m", CLK_INFRA_SYSAXI_D2, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 496 | 19), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 497 | GATE_INFRA1_INFRA(CLK_INFRA_ADC_26M_CK, "infra_adc_26m", CLK_INFRA_ADC_FRC_CK, 20), |
| 498 | GATE_INFRA1_TOP(CLK_INFRA_ADC_FRC_CK, "infra_adc_frc", CLK_TOP_F26M_SEL, 21), |
| 499 | GATE_INFRA1_TOP(CLK_INFRA_FBIST2FPC_CK, "infra_fbist2fpc", CLK_TOP_NFI1X_SEL, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 500 | 23), |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 501 | /* INFRA2 */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 502 | GATE_INFRA2_TOP(CLK_INFRA_IUSB_133_CK, "infra_iusb_133", CLK_TOP_SYSAXI_SEL, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 503 | 0), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 504 | GATE_INFRA2_INFRA(CLK_INFRA_IUSB_66M_CK, "infra_iusb_66m", CLK_INFRA_SYSAXI_D2, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 505 | 1), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 506 | GATE_INFRA2_TOP(CLK_INFRA_IUSB_SYS_CK, "infra_iusb_sys", CLK_TOP_U2U3_SYS_SEL, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 507 | 2), |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 508 | GATE_INFRA2_TOP(CLK_INFRA_IUSB_CK, "infra_iusb", CLK_TOP_U2U3_SEL, 3), |
| 509 | GATE_INFRA2_TOP(CLK_INFRA_IPCIE_CK, "infra_ipcie", CLK_TOP_PEXTP_TL_SEL, 12), |
| 510 | GATE_INFRA2_TOP(CLK_INFRA_IPCIE_PIPE_CK, "infra_ipcie_pipe", CLK_TOP_XTAL, 13), |
| 511 | GATE_INFRA2_TOP(CLK_INFRA_IPCIER_CK, "infra_ipcier", CLK_TOP_F26M_SEL, 14), |
| 512 | GATE_INFRA2_TOP(CLK_INFRA_IPCIEB_CK, "infra_ipcieb", CLK_TOP_SYSAXI_SEL, 15), |
Christian Marangi | 6698b4d | 2024-08-03 10:40:45 +0200 | [diff] [blame] | 513 | /* upstream linux unordered */ |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 514 | GATE_INFRA0_TOP(CLK_INFRA_TRNG_CK, "infra_trng", CLK_TOP_SYSAXI_SEL, 26), |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 515 | }; |
| 516 | |
| 517 | static const struct mtk_clk_tree mt7986_fixed_pll_clk_tree = { |
| 518 | .fdivs_offs = CLK_APMIXED_NR_CLK, |
| 519 | .xtal_rate = 40 * MHZ, |
| 520 | .fclks = fixed_pll_clks, |
Christian Marangi | 0fc50e7 | 2024-08-03 10:40:43 +0200 | [diff] [blame] | 521 | .flags = CLK_APMIXED, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 522 | }; |
| 523 | |
| 524 | static const struct mtk_clk_tree mt7986_topckgen_clk_tree = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 525 | .fdivs_offs = CLK_TOP_XTAL_D2, |
| 526 | .muxes_offs = CLK_TOP_NFI1X_SEL, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 527 | .fclks = top_fixed_clks, |
| 528 | .fdivs = top_fixed_divs, |
| 529 | .muxes = top_muxes, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 530 | .flags = CLK_BYPASS_XTAL | CLK_TOPCKGEN, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 531 | }; |
| 532 | |
| 533 | static const struct mtk_clk_tree mt7986_infracfg_clk_tree = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 534 | .fdivs_offs = CLK_INFRA_SYSAXI_D2, |
| 535 | .muxes_offs = CLK_INFRA_UART0_SEL, |
| 536 | .gates_offs = CLK_INFRA_GPT_STA, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 537 | .fdivs = infra_fixed_divs, |
| 538 | .muxes = infra_muxes, |
Christian Marangi | bf79ce0 | 2024-08-03 10:40:47 +0200 | [diff] [blame] | 539 | .gates = infracfg_gates, |
Christian Marangi | ab4de13 | 2024-08-03 10:40:38 +0200 | [diff] [blame] | 540 | .flags = CLK_INFRASYS, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 541 | }; |
| 542 | |
| 543 | static const struct udevice_id mt7986_fixed_pll_compat[] = { |
| 544 | { .compatible = "mediatek,mt7986-fixed-plls" }, |
Christian Marangi | 4dd4a28 | 2024-06-24 23:03:40 +0200 | [diff] [blame] | 545 | { .compatible = "mediatek,mt7986-apmixedsys" }, |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 546 | {} |
| 547 | }; |
| 548 | |
| 549 | static const struct udevice_id mt7986_topckgen_compat[] = { |
| 550 | { .compatible = "mediatek,mt7986-topckgen" }, |
| 551 | {} |
| 552 | }; |
| 553 | |
| 554 | static int mt7986_fixed_pll_probe(struct udevice *dev) |
| 555 | { |
| 556 | return mtk_common_clk_init(dev, &mt7986_fixed_pll_clk_tree); |
| 557 | } |
| 558 | |
| 559 | static int mt7986_topckgen_probe(struct udevice *dev) |
| 560 | { |
| 561 | struct mtk_clk_priv *priv = dev_get_priv(dev); |
| 562 | |
| 563 | priv->base = dev_read_addr_ptr(dev); |
| 564 | writel(MT7986_CLK_PDN_EN_WRITE, priv->base + MT7986_CLK_PDN); |
| 565 | |
| 566 | return mtk_common_clk_init(dev, &mt7986_topckgen_clk_tree); |
| 567 | } |
| 568 | |
| 569 | U_BOOT_DRIVER(mtk_clk_apmixedsys) = { |
| 570 | .name = "mt7986-clock-fixed-pll", |
| 571 | .id = UCLASS_CLK, |
| 572 | .of_match = mt7986_fixed_pll_compat, |
| 573 | .probe = mt7986_fixed_pll_probe, |
| 574 | .priv_auto = sizeof(struct mtk_clk_priv), |
| 575 | .ops = &mtk_clk_topckgen_ops, |
| 576 | .flags = DM_FLAG_PRE_RELOC, |
| 577 | }; |
| 578 | |
| 579 | U_BOOT_DRIVER(mtk_clk_topckgen) = { |
| 580 | .name = "mt7986-clock-topckgen", |
| 581 | .id = UCLASS_CLK, |
| 582 | .of_match = mt7986_topckgen_compat, |
| 583 | .probe = mt7986_topckgen_probe, |
| 584 | .priv_auto = sizeof(struct mtk_clk_priv), |
| 585 | .ops = &mtk_clk_topckgen_ops, |
| 586 | .flags = DM_FLAG_PRE_RELOC, |
| 587 | }; |
| 588 | |
| 589 | static const struct udevice_id mt7986_infracfg_compat[] = { |
| 590 | { .compatible = "mediatek,mt7986-infracfg" }, |
| 591 | {} |
| 592 | }; |
| 593 | |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 594 | static int mt7986_infracfg_probe(struct udevice *dev) |
| 595 | { |
Christian Marangi | bf79ce0 | 2024-08-03 10:40:47 +0200 | [diff] [blame] | 596 | return mtk_common_clk_infrasys_init(dev, &mt7986_infracfg_clk_tree); |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | U_BOOT_DRIVER(mtk_clk_infracfg) = { |
| 600 | .name = "mt7986-clock-infracfg", |
| 601 | .id = UCLASS_CLK, |
| 602 | .of_match = mt7986_infracfg_compat, |
| 603 | .probe = mt7986_infracfg_probe, |
| 604 | .priv_auto = sizeof(struct mtk_clk_priv), |
| 605 | .ops = &mtk_clk_infrasys_ops, |
| 606 | .flags = DM_FLAG_PRE_RELOC, |
| 607 | }; |
| 608 | |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 609 | /* ethsys */ |
| 610 | static const struct mtk_gate_regs eth_cg_regs = { |
| 611 | .sta_ofs = 0x30, |
| 612 | }; |
| 613 | |
| 614 | #define GATE_ETH(_id, _name, _parent, _shift) \ |
| 615 | { \ |
| 616 | .id = _id, .parent = _parent, .regs = ð_cg_regs, \ |
| 617 | .shift = _shift, \ |
| 618 | .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ |
| 619 | } |
| 620 | |
| 621 | static const struct mtk_gate eth_cgs[] = { |
Christian Marangi | 07603e4 | 2024-08-03 10:40:48 +0200 | [diff] [blame] | 622 | GATE_ETH(CLK_ETH_FE_EN, "eth_fe_en", CLK_TOP_NETSYS_2X_SEL, 7), |
| 623 | GATE_ETH(CLK_ETH_GP2_EN, "eth_gp2_en", CLK_TOP_SGM_325M_SEL, 8), |
| 624 | GATE_ETH(CLK_ETH_GP1_EN, "eth_gp1_en", CLK_TOP_SGM_325M_SEL, 8), |
| 625 | GATE_ETH(CLK_ETH_WOCPU1_EN, "eth_wocpu1_en", CLK_TOP_NETSYS_MCU_SEL, 14), |
| 626 | GATE_ETH(CLK_ETH_WOCPU0_EN, "eth_wocpu0_en", CLK_TOP_NETSYS_MCU_SEL, 15), |
developer | 37161fe | 2022-09-09 20:00:09 +0800 | [diff] [blame] | 627 | }; |
| 628 | |
| 629 | static int mt7986_ethsys_probe(struct udevice *dev) |
| 630 | { |
| 631 | return mtk_common_clk_gate_init(dev, &mt7986_topckgen_clk_tree, |
| 632 | eth_cgs); |
| 633 | } |
| 634 | |
| 635 | static int mt7986_ethsys_bind(struct udevice *dev) |
| 636 | { |
| 637 | int ret = 0; |
| 638 | |
| 639 | if (CONFIG_IS_ENABLED(RESET_MEDIATEK)) { |
| 640 | ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1); |
| 641 | if (ret) |
| 642 | debug("Warning: failed to bind reset controller\n"); |
| 643 | } |
| 644 | |
| 645 | return ret; |
| 646 | } |
| 647 | |
| 648 | static const struct udevice_id mt7986_ethsys_compat[] = { |
| 649 | { .compatible = "mediatek,mt7986-ethsys" }, |
| 650 | { } |
| 651 | }; |
| 652 | |
| 653 | U_BOOT_DRIVER(mtk_clk_ethsys) = { |
| 654 | .name = "mt7986-clock-ethsys", |
| 655 | .id = UCLASS_CLK, |
| 656 | .of_match = mt7986_ethsys_compat, |
| 657 | .probe = mt7986_ethsys_probe, |
| 658 | .bind = mt7986_ethsys_bind, |
| 659 | .priv_auto = sizeof(struct mtk_cg_priv), |
| 660 | .ops = &mtk_clk_gate_ops, |
| 661 | }; |