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