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