Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright 2019 NXP |
| 4 | * Peng Fan <peng.fan@nxp.com> |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <clk.h> |
| 9 | #include <clk-uclass.h> |
| 10 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 11 | #include <log.h> |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 12 | #include <asm/arch/clock.h> |
| 13 | #include <asm/arch/imx-regs.h> |
| 14 | #include <dt-bindings/clock/imx8mn-clock.h> |
| 15 | |
| 16 | #include "clk.h" |
| 17 | |
| 18 | #define PLL_1416X_RATE(_rate, _m, _p, _s) \ |
| 19 | { \ |
| 20 | .rate = (_rate), \ |
| 21 | .mdiv = (_m), \ |
| 22 | .pdiv = (_p), \ |
| 23 | .sdiv = (_s), \ |
| 24 | } |
| 25 | |
| 26 | #define PLL_1443X_RATE(_rate, _m, _p, _s, _k) \ |
| 27 | { \ |
| 28 | .rate = (_rate), \ |
| 29 | .mdiv = (_m), \ |
| 30 | .pdiv = (_p), \ |
| 31 | .sdiv = (_s), \ |
| 32 | .kdiv = (_k), \ |
| 33 | } |
| 34 | |
| 35 | static const struct imx_pll14xx_rate_table imx8mn_pll1416x_tbl[] = { |
| 36 | PLL_1416X_RATE(1800000000U, 225, 3, 0), |
| 37 | PLL_1416X_RATE(1600000000U, 200, 3, 0), |
| 38 | PLL_1416X_RATE(1200000000U, 300, 3, 1), |
| 39 | PLL_1416X_RATE(1000000000U, 250, 3, 1), |
| 40 | PLL_1416X_RATE(800000000U, 200, 3, 1), |
| 41 | PLL_1416X_RATE(750000000U, 250, 2, 2), |
| 42 | PLL_1416X_RATE(700000000U, 350, 3, 2), |
| 43 | PLL_1416X_RATE(600000000U, 300, 3, 2), |
| 44 | }; |
| 45 | |
| 46 | static const struct imx_pll14xx_rate_table imx8mn_drampll_tbl[] = { |
| 47 | PLL_1443X_RATE(650000000U, 325, 3, 2, 0), |
| 48 | }; |
| 49 | |
| 50 | static struct imx_pll14xx_clk imx8mn_dram_pll __initdata = { |
| 51 | .type = PLL_1443X, |
| 52 | .rate_table = imx8mn_drampll_tbl, |
| 53 | .rate_count = ARRAY_SIZE(imx8mn_drampll_tbl), |
| 54 | }; |
| 55 | |
| 56 | static struct imx_pll14xx_clk imx8mn_arm_pll __initdata = { |
| 57 | .type = PLL_1416X, |
| 58 | .rate_table = imx8mn_pll1416x_tbl, |
| 59 | .rate_count = ARRAY_SIZE(imx8mn_pll1416x_tbl), |
| 60 | }; |
| 61 | |
| 62 | static struct imx_pll14xx_clk imx8mn_sys_pll __initdata = { |
| 63 | .type = PLL_1416X, |
| 64 | .rate_table = imx8mn_pll1416x_tbl, |
| 65 | .rate_count = ARRAY_SIZE(imx8mn_pll1416x_tbl), |
| 66 | }; |
| 67 | |
| 68 | static const char *pll_ref_sels[] = { "clock-osc-24m", "dummy", "dummy", "dummy", }; |
| 69 | static const char *dram_pll_bypass_sels[] = {"dram_pll", "dram_pll_ref_sel", }; |
| 70 | static const char *arm_pll_bypass_sels[] = {"arm_pll", "arm_pll_ref_sel", }; |
| 71 | static const char *sys_pll1_bypass_sels[] = {"sys_pll1", "sys_pll1_ref_sel", }; |
| 72 | static const char *sys_pll2_bypass_sels[] = {"sys_pll2", "sys_pll2_ref_sel", }; |
| 73 | static const char *sys_pll3_bypass_sels[] = {"sys_pll3", "sys_pll3_ref_sel", }; |
| 74 | |
| 75 | static const char *imx8mn_a53_sels[] = {"clock-osc-24m", "arm_pll_out", "sys_pll2_500m", "sys_pll2_1000m", |
| 76 | "sys_pll1_800m", "sys_pll1_400m", "audio_pll1_out", "sys_pll3_out", }; |
| 77 | |
| 78 | static const char *imx8mn_ahb_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_800m", "sys_pll1_400m", |
| 79 | "sys_pll2_125m", "sys_pll3_out", "audio_pll1_out", "video_pll1_out", }; |
| 80 | |
| 81 | static const char *imx8mn_enet_axi_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m", "sys_pll2_250m", |
| 82 | "sys_pll2_200m", "audio_pll1_out", "video_pll1_out", "sys_pll3_out", }; |
| 83 | |
Ye Li | 418c1fc | 2020-04-18 08:19:12 -0700 | [diff] [blame] | 84 | #ifndef CONFIG_SPL_BUILD |
| 85 | static const char *imx8mn_enet_ref_sels[] = {"clock-osc-24m", "sys_pll2_125m", "sys_pll2_50m", "sys_pll2_100m", |
| 86 | "sys_pll1_160m", "audio_pll1_out", "video_pll1_out", "clk_ext4", }; |
| 87 | |
| 88 | static const char *imx8mn_enet_timer_sels[] = {"clock-osc-24m", "sys_pll2_100m", "audio_pll1_out", "clk_ext1", "clk_ext2", |
| 89 | "clk_ext3", "clk_ext4", "video_pll1_out", }; |
| 90 | |
| 91 | static const char *imx8mn_enet_phy_sels[] = {"clock-osc-24m", "sys_pll2_50m", "sys_pll2_125m", "sys_pll2_200m", |
| 92 | "sys_pll2_500m", "video_pll1_out", "audio_pll2_out", }; |
| 93 | #endif |
| 94 | |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 95 | static const char *imx8mn_nand_usdhc_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m", "sys_pll2_200m", |
| 96 | "sys_pll1_133m", "sys_pll3_out", "sys_pll2_250m", "audio_pll1_out", }; |
| 97 | |
Ye Li | 0321edb | 2020-04-19 02:22:09 -0700 | [diff] [blame] | 98 | static const char * const imx8mn_usb_bus_sels[] = {"clock-osc-24m", "sys_pll2_500m", "sys_pll1_800m", |
| 99 | "sys_pll2_100m", "sys_pll2_200m", "clk_ext2", |
| 100 | "clk_ext4", "audio_pll2_out", }; |
| 101 | |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 102 | static const char *imx8mn_usdhc1_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m", "sys_pll2_500m", |
| 103 | "sys_pll3_out", "sys_pll1_266m", "audio_pll2_out", "sys_pll1_100m", }; |
| 104 | |
| 105 | static const char *imx8mn_usdhc2_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m", "sys_pll2_500m", |
| 106 | "sys_pll3_out", "sys_pll1_266m", "audio_pll2_out", "sys_pll1_100m", }; |
| 107 | |
Marek Vasut | b1a8bb0 | 2021-01-19 00:58:31 +0100 | [diff] [blame] | 108 | #if CONFIG_IS_ENABLED(DM_SPI) |
| 109 | static const char *imx8mn_ecspi1_sels[] = {"osc_24m", "sys_pll2_200m", "sys_pll1_40m", |
| 110 | "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out", |
| 111 | "sys_pll2_250m", "audio_pll2_out", }; |
| 112 | |
| 113 | static const char *imx8mn_ecspi2_sels[] = {"osc_24m", "sys_pll2_200m", "sys_pll1_40m", |
| 114 | "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out", |
| 115 | "sys_pll2_250m", "audio_pll2_out", }; |
| 116 | |
| 117 | static const char *imx8mn_ecspi3_sels[] = {"osc_24m", "sys_pll2_200m", "sys_pll1_40m", |
| 118 | "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out", |
| 119 | "sys_pll2_250m", "audio_pll2_out", }; |
| 120 | #endif |
| 121 | |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 122 | static const char *imx8mn_i2c1_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out", |
| 123 | "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", }; |
| 124 | |
| 125 | static const char *imx8mn_i2c2_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out", |
| 126 | "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", }; |
| 127 | |
| 128 | static const char *imx8mn_i2c3_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out", |
| 129 | "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", }; |
| 130 | |
| 131 | static const char *imx8mn_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out", |
| 132 | "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", }; |
| 133 | |
| 134 | static const char *imx8mn_wdog_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_160m", "vpu_pll_out", |
| 135 | "sys_pll2_125m", "sys_pll3_out", "sys_pll1_80m", "sys_pll2_166m", }; |
| 136 | |
| 137 | static const char *imx8mn_usdhc3_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m", "sys_pll2_500m", |
| 138 | "sys_pll3_out", "sys_pll1_266m", "audio_pll2_clk", "sys_pll1_100m", }; |
| 139 | |
Ye Li | 418c1fc | 2020-04-18 08:19:12 -0700 | [diff] [blame] | 140 | static const char *imx8mn_qspi_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll2_333m", "sys_pll2_500m", |
| 141 | "audio_pll2_out", "sys_pll1_266m", "sys_pll3_out", "sys_pll1_100m", }; |
| 142 | |
Ye Li | 0321edb | 2020-04-19 02:22:09 -0700 | [diff] [blame] | 143 | static const char * const imx8mn_usb_core_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m", |
| 144 | "sys_pll2_100m", "sys_pll2_200m", "clk_ext2", |
| 145 | "clk_ext3", "audio_pll2_out", }; |
| 146 | |
| 147 | static const char * const imx8mn_usb_phy_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m", |
| 148 | "sys_pll2_100m", "sys_pll2_200m", "clk_ext2", |
| 149 | "clk_ext3", "audio_pll2_out", }; |
| 150 | |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 151 | static int imx8mn_clk_probe(struct udevice *dev) |
| 152 | { |
| 153 | void __iomem *base; |
| 154 | |
| 155 | base = (void *)ANATOP_BASE_ADDR; |
| 156 | |
| 157 | clk_dm(IMX8MN_DRAM_PLL_REF_SEL, |
| 158 | imx_clk_mux("dram_pll_ref_sel", base + 0x50, 0, 2, |
| 159 | pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 160 | clk_dm(IMX8MN_ARM_PLL_REF_SEL, |
| 161 | imx_clk_mux("arm_pll_ref_sel", base + 0x84, 0, 2, |
| 162 | pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 163 | clk_dm(IMX8MN_SYS_PLL1_REF_SEL, |
| 164 | imx_clk_mux("sys_pll1_ref_sel", base + 0x94, 0, 2, |
| 165 | pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 166 | clk_dm(IMX8MN_SYS_PLL2_REF_SEL, |
| 167 | imx_clk_mux("sys_pll2_ref_sel", base + 0x104, 0, 2, |
| 168 | pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 169 | clk_dm(IMX8MN_SYS_PLL3_REF_SEL, |
| 170 | imx_clk_mux("sys_pll3_ref_sel", base + 0x114, 0, 2, |
| 171 | pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 172 | |
| 173 | clk_dm(IMX8MN_DRAM_PLL, |
| 174 | imx_clk_pll14xx("dram_pll", "dram_pll_ref_sel", |
| 175 | base + 0x50, &imx8mn_dram_pll)); |
| 176 | clk_dm(IMX8MN_ARM_PLL, |
| 177 | imx_clk_pll14xx("arm_pll", "arm_pll_ref_sel", |
| 178 | base + 0x84, &imx8mn_arm_pll)); |
| 179 | clk_dm(IMX8MN_SYS_PLL1, |
| 180 | imx_clk_pll14xx("sys_pll1", "sys_pll1_ref_sel", |
| 181 | base + 0x94, &imx8mn_sys_pll)); |
| 182 | clk_dm(IMX8MN_SYS_PLL2, |
| 183 | imx_clk_pll14xx("sys_pll2", "sys_pll2_ref_sel", |
| 184 | base + 0x104, &imx8mn_sys_pll)); |
| 185 | clk_dm(IMX8MN_SYS_PLL3, |
| 186 | imx_clk_pll14xx("sys_pll3", "sys_pll3_ref_sel", |
| 187 | base + 0x114, &imx8mn_sys_pll)); |
| 188 | |
| 189 | /* PLL bypass out */ |
| 190 | clk_dm(IMX8MN_DRAM_PLL_BYPASS, |
| 191 | imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 4, 1, |
| 192 | dram_pll_bypass_sels, |
| 193 | ARRAY_SIZE(dram_pll_bypass_sels), |
| 194 | CLK_SET_RATE_PARENT)); |
| 195 | clk_dm(IMX8MN_ARM_PLL_BYPASS, |
| 196 | imx_clk_mux_flags("arm_pll_bypass", base + 0x84, 4, 1, |
| 197 | arm_pll_bypass_sels, |
| 198 | ARRAY_SIZE(arm_pll_bypass_sels), |
| 199 | CLK_SET_RATE_PARENT)); |
| 200 | clk_dm(IMX8MN_SYS_PLL1_BYPASS, |
| 201 | imx_clk_mux_flags("sys_pll1_bypass", base + 0x94, 4, 1, |
| 202 | sys_pll1_bypass_sels, |
| 203 | ARRAY_SIZE(sys_pll1_bypass_sels), |
| 204 | CLK_SET_RATE_PARENT)); |
| 205 | clk_dm(IMX8MN_SYS_PLL2_BYPASS, |
| 206 | imx_clk_mux_flags("sys_pll2_bypass", base + 0x104, 4, 1, |
| 207 | sys_pll2_bypass_sels, |
| 208 | ARRAY_SIZE(sys_pll2_bypass_sels), |
| 209 | CLK_SET_RATE_PARENT)); |
| 210 | clk_dm(IMX8MN_SYS_PLL3_BYPASS, |
| 211 | imx_clk_mux_flags("sys_pll3_bypass", base + 0x114, 4, 1, |
| 212 | sys_pll3_bypass_sels, |
| 213 | ARRAY_SIZE(sys_pll3_bypass_sels), |
| 214 | CLK_SET_RATE_PARENT)); |
| 215 | |
| 216 | /* PLL out gate */ |
| 217 | clk_dm(IMX8MN_DRAM_PLL_OUT, |
| 218 | imx_clk_gate("dram_pll_out", "dram_pll_bypass", |
| 219 | base + 0x50, 13)); |
| 220 | clk_dm(IMX8MN_ARM_PLL_OUT, |
| 221 | imx_clk_gate("arm_pll_out", "arm_pll_bypass", |
| 222 | base + 0x84, 11)); |
| 223 | clk_dm(IMX8MN_SYS_PLL1_OUT, |
| 224 | imx_clk_gate("sys_pll1_out", "sys_pll1_bypass", |
| 225 | base + 0x94, 11)); |
| 226 | clk_dm(IMX8MN_SYS_PLL2_OUT, |
| 227 | imx_clk_gate("sys_pll2_out", "sys_pll2_bypass", |
| 228 | base + 0x104, 11)); |
| 229 | clk_dm(IMX8MN_SYS_PLL3_OUT, |
| 230 | imx_clk_gate("sys_pll3_out", "sys_pll3_bypass", |
| 231 | base + 0x114, 11)); |
| 232 | |
| 233 | /* SYS PLL fixed output */ |
| 234 | clk_dm(IMX8MN_SYS_PLL1_40M, |
| 235 | imx_clk_fixed_factor("sys_pll1_40m", "sys_pll1_out", 1, 20)); |
| 236 | clk_dm(IMX8MN_SYS_PLL1_80M, |
| 237 | imx_clk_fixed_factor("sys_pll1_80m", "sys_pll1_out", 1, 10)); |
| 238 | clk_dm(IMX8MN_SYS_PLL1_100M, |
| 239 | imx_clk_fixed_factor("sys_pll1_100m", "sys_pll1_out", 1, 8)); |
| 240 | clk_dm(IMX8MN_SYS_PLL1_133M, |
| 241 | imx_clk_fixed_factor("sys_pll1_133m", "sys_pll1_out", 1, 6)); |
| 242 | clk_dm(IMX8MN_SYS_PLL1_160M, |
| 243 | imx_clk_fixed_factor("sys_pll1_160m", "sys_pll1_out", 1, 5)); |
| 244 | clk_dm(IMX8MN_SYS_PLL1_200M, |
| 245 | imx_clk_fixed_factor("sys_pll1_200m", "sys_pll1_out", 1, 4)); |
| 246 | clk_dm(IMX8MN_SYS_PLL1_266M, |
| 247 | imx_clk_fixed_factor("sys_pll1_266m", "sys_pll1_out", 1, 3)); |
| 248 | clk_dm(IMX8MN_SYS_PLL1_400M, |
| 249 | imx_clk_fixed_factor("sys_pll1_400m", "sys_pll1_out", 1, 2)); |
| 250 | clk_dm(IMX8MN_SYS_PLL1_800M, |
| 251 | imx_clk_fixed_factor("sys_pll1_800m", "sys_pll1_out", 1, 1)); |
| 252 | |
| 253 | clk_dm(IMX8MN_SYS_PLL2_50M, |
| 254 | imx_clk_fixed_factor("sys_pll2_50m", "sys_pll2_out", 1, 20)); |
| 255 | clk_dm(IMX8MN_SYS_PLL2_100M, |
| 256 | imx_clk_fixed_factor("sys_pll2_100m", "sys_pll2_out", 1, 10)); |
| 257 | clk_dm(IMX8MN_SYS_PLL2_125M, |
| 258 | imx_clk_fixed_factor("sys_pll2_125m", "sys_pll2_out", 1, 8)); |
| 259 | clk_dm(IMX8MN_SYS_PLL2_166M, |
| 260 | imx_clk_fixed_factor("sys_pll2_166m", "sys_pll2_out", 1, 6)); |
| 261 | clk_dm(IMX8MN_SYS_PLL2_200M, |
| 262 | imx_clk_fixed_factor("sys_pll2_200m", "sys_pll2_out", 1, 5)); |
| 263 | clk_dm(IMX8MN_SYS_PLL2_250M, |
| 264 | imx_clk_fixed_factor("sys_pll2_250m", "sys_pll2_out", 1, 4)); |
| 265 | clk_dm(IMX8MN_SYS_PLL2_333M, |
| 266 | imx_clk_fixed_factor("sys_pll2_333m", "sys_pll2_out", 1, 3)); |
| 267 | clk_dm(IMX8MN_SYS_PLL2_500M, |
| 268 | imx_clk_fixed_factor("sys_pll2_500m", "sys_pll2_out", 1, 2)); |
| 269 | clk_dm(IMX8MN_SYS_PLL2_1000M, |
| 270 | imx_clk_fixed_factor("sys_pll2_1000m", "sys_pll2_out", 1, 1)); |
| 271 | |
| 272 | base = dev_read_addr_ptr(dev); |
Sean Anderson | b58106d | 2019-12-24 23:57:47 -0500 | [diff] [blame] | 273 | if (!base) |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 274 | return -EINVAL; |
| 275 | |
| 276 | clk_dm(IMX8MN_CLK_A53_SRC, |
| 277 | imx_clk_mux2("arm_a53_src", base + 0x8000, 24, 3, |
| 278 | imx8mn_a53_sels, ARRAY_SIZE(imx8mn_a53_sels))); |
| 279 | clk_dm(IMX8MN_CLK_A53_CG, |
| 280 | imx_clk_gate3("arm_a53_cg", "arm_a53_src", base + 0x8000, 28)); |
| 281 | clk_dm(IMX8MN_CLK_A53_DIV, |
| 282 | imx_clk_divider2("arm_a53_div", "arm_a53_cg", |
| 283 | base + 0x8000, 0, 3)); |
| 284 | |
| 285 | clk_dm(IMX8MN_CLK_AHB, |
| 286 | imx8m_clk_composite_critical("ahb", imx8mn_ahb_sels, |
| 287 | base + 0x9000)); |
| 288 | clk_dm(IMX8MN_CLK_IPG_ROOT, |
| 289 | imx_clk_divider2("ipg_root", "ahb", base + 0x9080, 0, 1)); |
| 290 | |
| 291 | clk_dm(IMX8MN_CLK_ENET_AXI, |
| 292 | imx8m_clk_composite("enet_axi", imx8mn_enet_axi_sels, |
| 293 | base + 0x8880)); |
| 294 | clk_dm(IMX8MN_CLK_NAND_USDHC_BUS, |
| 295 | imx8m_clk_composite_critical("nand_usdhc_bus", |
| 296 | imx8mn_nand_usdhc_sels, |
| 297 | base + 0x8900)); |
Ye Li | 0321edb | 2020-04-19 02:22:09 -0700 | [diff] [blame] | 298 | clk_dm(IMX8MN_CLK_USB_BUS, |
| 299 | imx8m_clk_composite("usb_bus", imx8mn_usb_bus_sels, base + 0x8b80)); |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 300 | |
| 301 | /* IP */ |
| 302 | clk_dm(IMX8MN_CLK_USDHC1, |
| 303 | imx8m_clk_composite("usdhc1", imx8mn_usdhc1_sels, |
| 304 | base + 0xac00)); |
| 305 | clk_dm(IMX8MN_CLK_USDHC2, |
| 306 | imx8m_clk_composite("usdhc2", imx8mn_usdhc2_sels, |
| 307 | base + 0xac80)); |
| 308 | clk_dm(IMX8MN_CLK_I2C1, |
| 309 | imx8m_clk_composite("i2c1", imx8mn_i2c1_sels, base + 0xad00)); |
| 310 | clk_dm(IMX8MN_CLK_I2C2, |
| 311 | imx8m_clk_composite("i2c2", imx8mn_i2c2_sels, base + 0xad80)); |
| 312 | clk_dm(IMX8MN_CLK_I2C3, |
| 313 | imx8m_clk_composite("i2c3", imx8mn_i2c3_sels, base + 0xae00)); |
| 314 | clk_dm(IMX8MN_CLK_I2C4, |
| 315 | imx8m_clk_composite("i2c4", imx8mn_i2c4_sels, base + 0xae80)); |
| 316 | clk_dm(IMX8MN_CLK_WDOG, |
| 317 | imx8m_clk_composite("wdog", imx8mn_wdog_sels, base + 0xb900)); |
| 318 | clk_dm(IMX8MN_CLK_USDHC3, |
| 319 | imx8m_clk_composite("usdhc3", imx8mn_usdhc3_sels, |
| 320 | base + 0xbc80)); |
Ye Li | 418c1fc | 2020-04-18 08:19:12 -0700 | [diff] [blame] | 321 | clk_dm(IMX8MN_CLK_QSPI, |
| 322 | imx8m_clk_composite("qspi", imx8mn_qspi_sels, base + 0xab80)); |
Ye Li | 0321edb | 2020-04-19 02:22:09 -0700 | [diff] [blame] | 323 | clk_dm(IMX8MN_CLK_USB_CORE_REF, |
| 324 | imx8m_clk_composite("usb_core_ref", imx8mn_usb_core_sels, base + 0xb100)); |
| 325 | clk_dm(IMX8MN_CLK_USB_PHY_REF, |
| 326 | imx8m_clk_composite("usb_phy_ref", imx8mn_usb_phy_sels, base + 0xb180)); |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 327 | |
| 328 | clk_dm(IMX8MN_CLK_I2C1_ROOT, |
| 329 | imx_clk_gate4("i2c1_root_clk", "i2c1", base + 0x4170, 0)); |
| 330 | clk_dm(IMX8MN_CLK_I2C2_ROOT, |
| 331 | imx_clk_gate4("i2c2_root_clk", "i2c2", base + 0x4180, 0)); |
| 332 | clk_dm(IMX8MN_CLK_I2C3_ROOT, |
| 333 | imx_clk_gate4("i2c3_root_clk", "i2c3", base + 0x4190, 0)); |
| 334 | clk_dm(IMX8MN_CLK_I2C4_ROOT, |
| 335 | imx_clk_gate4("i2c4_root_clk", "i2c4", base + 0x41a0, 0)); |
| 336 | clk_dm(IMX8MN_CLK_OCOTP_ROOT, |
| 337 | imx_clk_gate4("ocotp_root_clk", "ipg_root", base + 0x4220, 0)); |
| 338 | clk_dm(IMX8MN_CLK_USDHC1_ROOT, |
| 339 | imx_clk_gate4("usdhc1_root_clk", "usdhc1", base + 0x4510, 0)); |
| 340 | clk_dm(IMX8MN_CLK_USDHC2_ROOT, |
| 341 | imx_clk_gate4("usdhc2_root_clk", "usdhc2", base + 0x4520, 0)); |
| 342 | clk_dm(IMX8MN_CLK_WDOG1_ROOT, |
| 343 | imx_clk_gate4("wdog1_root_clk", "wdog", base + 0x4530, 0)); |
| 344 | clk_dm(IMX8MN_CLK_WDOG2_ROOT, |
| 345 | imx_clk_gate4("wdog2_root_clk", "wdog", base + 0x4540, 0)); |
| 346 | clk_dm(IMX8MN_CLK_WDOG3_ROOT, |
| 347 | imx_clk_gate4("wdog3_root_clk", "wdog", base + 0x4550, 0)); |
| 348 | clk_dm(IMX8MN_CLK_USDHC3_ROOT, |
| 349 | imx_clk_gate4("usdhc3_root_clk", "usdhc3", base + 0x45e0, 0)); |
Ye Li | 418c1fc | 2020-04-18 08:19:12 -0700 | [diff] [blame] | 350 | clk_dm(IMX8MN_CLK_QSPI_ROOT, |
| 351 | imx_clk_gate4("qspi_root_clk", "qspi", base + 0x42f0, 0)); |
Ye Li | 0321edb | 2020-04-19 02:22:09 -0700 | [diff] [blame] | 352 | clk_dm(IMX8MN_CLK_USB1_CTRL_ROOT, |
| 353 | imx_clk_gate4("usb1_ctrl_root_clk", "usb_bus", base + 0x44d0, 0)); |
Ye Li | 418c1fc | 2020-04-18 08:19:12 -0700 | [diff] [blame] | 354 | |
| 355 | /* clks not needed in SPL stage */ |
| 356 | #ifndef CONFIG_SPL_BUILD |
| 357 | clk_dm(IMX8MN_CLK_ENET_REF, |
| 358 | imx8m_clk_composite("enet_ref", imx8mn_enet_ref_sels, |
| 359 | base + 0xa980)); |
| 360 | clk_dm(IMX8MN_CLK_ENET_TIMER, |
| 361 | imx8m_clk_composite("enet_timer", imx8mn_enet_timer_sels, |
| 362 | base + 0xaa00)); |
| 363 | clk_dm(IMX8MN_CLK_ENET_PHY_REF, |
| 364 | imx8m_clk_composite("enet_phy", imx8mn_enet_phy_sels, |
| 365 | base + 0xaa80)); |
| 366 | clk_dm(IMX8MN_CLK_ENET1_ROOT, |
| 367 | imx_clk_gate4("enet1_root_clk", "enet_axi", |
| 368 | base + 0x40a0, 0)); |
| 369 | #endif |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 370 | |
Marek Vasut | b1a8bb0 | 2021-01-19 00:58:31 +0100 | [diff] [blame] | 371 | #if CONFIG_IS_ENABLED(DM_SPI) |
| 372 | clk_dm(IMX8MN_CLK_ECSPI1, |
| 373 | imx8m_clk_composite("ecspi1", imx8mn_ecspi1_sels, base + 0xb280)); |
| 374 | clk_dm(IMX8MN_CLK_ECSPI2, |
| 375 | imx8m_clk_composite("ecspi2", imx8mn_ecspi2_sels, base + 0xb300)); |
| 376 | clk_dm(IMX8MN_CLK_ECSPI3, |
| 377 | imx8m_clk_composite("ecspi3", imx8mn_ecspi3_sels, base + 0xc180)); |
| 378 | clk_dm(IMX8MN_CLK_ECSPI1_ROOT, |
| 379 | imx_clk_gate4("ecspi1_root_clk", "ecspi1", base + 0x4070, 0)); |
| 380 | clk_dm(IMX8MN_CLK_ECSPI2_ROOT, |
| 381 | imx_clk_gate4("ecspi2_root_clk", "ecspi2", base + 0x4080, 0)); |
| 382 | clk_dm(IMX8MN_CLK_ECSPI3_ROOT, |
| 383 | imx_clk_gate4("ecspi3_root_clk", "ecspi3", base + 0x4090, 0)); |
| 384 | #endif |
| 385 | |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 386 | return 0; |
| 387 | } |
| 388 | |
| 389 | static const struct udevice_id imx8mn_clk_ids[] = { |
| 390 | { .compatible = "fsl,imx8mn-ccm" }, |
| 391 | { }, |
| 392 | }; |
| 393 | |
| 394 | U_BOOT_DRIVER(imx8mn_clk) = { |
| 395 | .name = "clk_imx8mn", |
| 396 | .id = UCLASS_CLK, |
| 397 | .of_match = imx8mn_clk_ids, |
Sean Anderson | 35c8464 | 2022-03-20 16:34:46 -0400 | [diff] [blame^] | 398 | .ops = &ccf_clk_ops, |
Peng Fan | e2f674d | 2019-09-16 03:09:47 +0000 | [diff] [blame] | 399 | .probe = imx8mn_clk_probe, |
| 400 | .flags = DM_FLAG_PRE_RELOC, |
| 401 | }; |