Peng Fan | 525c876 | 2019-08-19 07:54:04 +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 | 525c876 | 2019-08-19 07:54:04 +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 | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 11 | #include <asm/arch/clock.h> |
| 12 | #include <asm/arch/imx-regs.h> |
| 13 | #include <dt-bindings/clock/imx8mm-clock.h> |
| 14 | |
| 15 | #include "clk.h" |
| 16 | |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 17 | static const char *pll_ref_sels[] = { "clock-osc-24m", "dummy", "dummy", "dummy", }; |
| 18 | static const char *dram_pll_bypass_sels[] = {"dram_pll", "dram_pll_ref_sel", }; |
| 19 | static const char *arm_pll_bypass_sels[] = {"arm_pll", "arm_pll_ref_sel", }; |
| 20 | static const char *sys_pll1_bypass_sels[] = {"sys_pll1", "sys_pll1_ref_sel", }; |
| 21 | static const char *sys_pll2_bypass_sels[] = {"sys_pll2", "sys_pll2_ref_sel", }; |
| 22 | static const char *sys_pll3_bypass_sels[] = {"sys_pll3", "sys_pll3_ref_sel", }; |
| 23 | |
| 24 | static const char *imx8mm_a53_sels[] = {"clock-osc-24m", "arm_pll_out", "sys_pll2_500m", "sys_pll2_1000m", |
| 25 | "sys_pll1_800m", "sys_pll1_400m", "audio_pll1_out", "sys_pll3_out", }; |
| 26 | |
Frieder Schrempf | 2d82cf8 | 2019-10-23 16:36:44 +0000 | [diff] [blame] | 27 | static const char *imx8mm_ahb_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_800m", "sys_pll1_400m", |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 28 | "sys_pll2_125m", "sys_pll3_out", "audio_pll1_out", "video_pll1_out", }; |
| 29 | |
Fabio Estevam | 704aa87 | 2022-09-26 13:40:09 -0300 | [diff] [blame] | 30 | #ifndef CONFIG_SPL_BUILD |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 31 | static const char *imx8mm_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 | |
Peng Fan | ee5515d | 2019-10-22 03:29:48 +0000 | [diff] [blame] | 34 | static const char *imx8mm_enet_ref_sels[] = {"clock-osc-24m", "sys_pll2_125m", "sys_pll2_50m", "sys_pll2_100m", |
| 35 | "sys_pll1_160m", "audio_pll1_out", "video_pll1_out", "clk_ext4", }; |
| 36 | |
| 37 | static const char *imx8mm_enet_timer_sels[] = {"clock-osc-24m", "sys_pll2_100m", "audio_pll1_out", "clk_ext1", "clk_ext2", |
| 38 | "clk_ext3", "clk_ext4", "video_pll1_out", }; |
| 39 | |
| 40 | static const char *imx8mm_enet_phy_sels[] = {"clock-osc-24m", "sys_pll2_50m", "sys_pll2_125m", "sys_pll2_200m", |
| 41 | "sys_pll2_500m", "video_pll1_out", "audio_pll2_out", }; |
| 42 | #endif |
| 43 | |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 44 | static const char *imx8mm_nand_usdhc_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m", "sys_pll2_200m", |
| 45 | "sys_pll1_133m", "sys_pll3_out", "sys_pll2_250m", "audio_pll1_out", }; |
| 46 | |
Ye Li | 0321edb | 2020-04-19 02:22:09 -0700 | [diff] [blame] | 47 | static const char *imx8mm_usb_bus_sels[] = {"clock-osc-24m", "sys_pll2_500m", "sys_pll1_800m", "sys_pll2_100m", |
| 48 | "sys_pll2_200m", "clk_ext2", "clk_ext4", "audio_pll2_out", }; |
| 49 | |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 50 | static const char *imx8mm_usdhc1_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m", "sys_pll2_500m", |
| 51 | "sys_pll3_out", "sys_pll1_266m", "audio_pll2_out", "sys_pll1_100m", }; |
| 52 | |
| 53 | static const char *imx8mm_usdhc2_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 *imx8mm_i2c1_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out", |
| 57 | "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", }; |
| 58 | |
| 59 | static const char *imx8mm_i2c2_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out", |
| 60 | "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", }; |
| 61 | |
| 62 | static const char *imx8mm_i2c3_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out", |
| 63 | "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", }; |
| 64 | |
| 65 | static const char *imx8mm_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", "sys_pll3_out", "audio_pll1_out", |
| 66 | "video_pll1_out", "audio_pll2_out", "sys_pll1_133m", }; |
| 67 | |
Tim Harvey | ff46558 | 2024-04-19 08:29:00 -0700 | [diff] [blame] | 68 | #if CONFIG_IS_ENABLED(PCIE_DW_IMX) |
| 69 | static const char *imx8mm_pcie1_ctrl_sels[] = {"clock-osc-24m", "sys_pll2_250m", "sys_pll2_200m", "sys_pll1_266m", |
| 70 | "sys_pll1_800m", "sys_pll2_500m", "sys_pll2_333m", "sys_pll3_out", }; |
| 71 | |
| 72 | static const char *imx8mm_pcie1_phy_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll2_500m", "clk_ext1", "clk_ext2", |
| 73 | "clk_ext3", "clk_ext4", "sys_pll1_400m", }; |
| 74 | |
| 75 | static const char *imx8mm_pcie1_aux_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll2_50m", "sys_pll3_out", |
| 76 | "sys_pll2_100m", "sys_pll1_80m", "sys_pll1_160m", "sys_pll1_200m", }; |
| 77 | #endif |
| 78 | |
Fabio Estevam | 60896e0 | 2022-09-26 13:40:08 -0300 | [diff] [blame] | 79 | #ifndef CONFIG_SPL_BUILD |
Tommaso Merciai | 4c1a718 | 2022-03-26 12:19:04 +0100 | [diff] [blame] | 80 | static const char *imx8mm_pwm1_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m", "sys_pll1_40m", |
| 81 | "sys_pll3_out", "clk_ext1", "sys_pll1_80m", "video_pll1_out", }; |
| 82 | |
| 83 | static const char *imx8mm_pwm2_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m", "sys_pll1_40m", |
| 84 | "sys_pll3_out", "clk_ext1", "sys_pll1_80m", "video_pll1_out", }; |
| 85 | |
| 86 | static const char *imx8mm_pwm3_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m", "sys_pll1_40m", |
| 87 | "sys_pll3_out", "clk_ext2", "sys_pll1_80m", "video_pll1_out", }; |
| 88 | |
| 89 | static const char *imx8mm_pwm4_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m", "sys_pll1_40m", |
| 90 | "sys_pll3_out", "clk_ext2", "sys_pll1_80m", "video_pll1_out", }; |
Fabio Estevam | 60896e0 | 2022-09-26 13:40:08 -0300 | [diff] [blame] | 91 | #endif |
Tommaso Merciai | 4c1a718 | 2022-03-26 12:19:04 +0100 | [diff] [blame] | 92 | |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 93 | static const char *imx8mm_wdog_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_160m", "vpu_pll_out", |
| 94 | "sys_pll2_125m", "sys_pll3_out", "sys_pll1_80m", "sys_pll2_166m", }; |
| 95 | |
| 96 | static const char *imx8mm_usdhc3_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m", "sys_pll2_500m", |
| 97 | "sys_pll3_out", "sys_pll1_266m", "audio_pll2_clk", "sys_pll1_100m", }; |
| 98 | |
Fabio Estevam | 3e5255c | 2022-09-26 13:40:11 -0300 | [diff] [blame] | 99 | #if CONFIG_IS_ENABLED(NXP_FSPI) |
Peng Fan | 2dff879 | 2020-06-27 15:49:28 +0800 | [diff] [blame] | 100 | static const char *imx8mm_qspi_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll2_333m", "sys_pll2_500m", |
| 101 | "audio_pll2_out", "sys_pll1_266m", "sys_pll3_out", "sys_pll1_100m", }; |
Fabio Estevam | 3e5255c | 2022-09-26 13:40:11 -0300 | [diff] [blame] | 102 | #endif |
Peng Fan | 2dff879 | 2020-06-27 15:49:28 +0800 | [diff] [blame] | 103 | |
Ye Li | 0321edb | 2020-04-19 02:22:09 -0700 | [diff] [blame] | 104 | static const char *imx8mm_usb_core_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m", "sys_pll2_100m", |
| 105 | "sys_pll2_200m", "clk_ext2", "clk_ext3", "audio_pll2_out", }; |
| 106 | |
| 107 | static const char *imx8mm_usb_phy_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m", "sys_pll2_100m", |
| 108 | "sys_pll2_200m", "clk_ext2", "clk_ext3", "audio_pll2_out", }; |
| 109 | |
Fabio Estevam | 0b3fa1b | 2022-09-26 13:40:10 -0300 | [diff] [blame] | 110 | #if CONFIG_IS_ENABLED(DM_SPI) |
Frieder Schrempf | 339beba | 2021-06-07 14:36:43 +0200 | [diff] [blame] | 111 | static const char *imx8mm_ecspi1_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m", "sys_pll1_160m", |
| 112 | "sys_pll1_800m", "sys_pll3_out", "sys_pll2_250m", "audio_pll2_out", }; |
| 113 | |
| 114 | static const char *imx8mm_ecspi2_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m", "sys_pll1_160m", |
| 115 | "sys_pll1_800m", "sys_pll3_out", "sys_pll2_250m", "audio_pll2_out", }; |
| 116 | |
| 117 | static const char *imx8mm_ecspi3_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m", "sys_pll1_160m", |
| 118 | "sys_pll1_800m", "sys_pll3_out", "sys_pll2_250m", "audio_pll2_out", }; |
Fabio Estevam | 0b3fa1b | 2022-09-26 13:40:10 -0300 | [diff] [blame] | 119 | #endif |
Frieder Schrempf | 339beba | 2021-06-07 14:36:43 +0200 | [diff] [blame] | 120 | |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 121 | static int imx8mm_clk_probe(struct udevice *dev) |
| 122 | { |
| 123 | void __iomem *base; |
| 124 | |
| 125 | base = (void *)ANATOP_BASE_ADDR; |
| 126 | |
| 127 | clk_dm(IMX8MM_DRAM_PLL_REF_SEL, |
| 128 | imx_clk_mux("dram_pll_ref_sel", base + 0x50, 0, 2, |
| 129 | pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 130 | clk_dm(IMX8MM_ARM_PLL_REF_SEL, |
| 131 | imx_clk_mux("arm_pll_ref_sel", base + 0x84, 0, 2, |
| 132 | pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 133 | clk_dm(IMX8MM_SYS_PLL1_REF_SEL, |
| 134 | imx_clk_mux("sys_pll1_ref_sel", base + 0x94, 0, 2, |
| 135 | pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 136 | clk_dm(IMX8MM_SYS_PLL2_REF_SEL, |
| 137 | imx_clk_mux("sys_pll2_ref_sel", base + 0x104, 0, 2, |
| 138 | pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 139 | clk_dm(IMX8MM_SYS_PLL3_REF_SEL, |
| 140 | imx_clk_mux("sys_pll3_ref_sel", base + 0x114, 0, 2, |
| 141 | pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 142 | |
| 143 | clk_dm(IMX8MM_DRAM_PLL, |
| 144 | imx_clk_pll14xx("dram_pll", "dram_pll_ref_sel", |
Angus Ainslie | 73d75ec | 2022-03-29 07:02:40 -0700 | [diff] [blame] | 145 | base + 0x50, &imx_1443x_dram_pll)); |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 146 | clk_dm(IMX8MM_ARM_PLL, |
| 147 | imx_clk_pll14xx("arm_pll", "arm_pll_ref_sel", |
Angus Ainslie | 73d75ec | 2022-03-29 07:02:40 -0700 | [diff] [blame] | 148 | base + 0x84, &imx_1416x_pll)); |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 149 | clk_dm(IMX8MM_SYS_PLL1, |
| 150 | imx_clk_pll14xx("sys_pll1", "sys_pll1_ref_sel", |
Angus Ainslie | 73d75ec | 2022-03-29 07:02:40 -0700 | [diff] [blame] | 151 | base + 0x94, &imx_1416x_pll)); |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 152 | clk_dm(IMX8MM_SYS_PLL2, |
| 153 | imx_clk_pll14xx("sys_pll2", "sys_pll2_ref_sel", |
Angus Ainslie | 73d75ec | 2022-03-29 07:02:40 -0700 | [diff] [blame] | 154 | base + 0x104, &imx_1416x_pll)); |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 155 | clk_dm(IMX8MM_SYS_PLL3, |
| 156 | imx_clk_pll14xx("sys_pll3", "sys_pll3_ref_sel", |
Angus Ainslie | 73d75ec | 2022-03-29 07:02:40 -0700 | [diff] [blame] | 157 | base + 0x114, &imx_1416x_pll)); |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 158 | |
| 159 | /* PLL bypass out */ |
| 160 | clk_dm(IMX8MM_DRAM_PLL_BYPASS, |
| 161 | imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 4, 1, |
| 162 | dram_pll_bypass_sels, |
| 163 | ARRAY_SIZE(dram_pll_bypass_sels), |
| 164 | CLK_SET_RATE_PARENT)); |
| 165 | clk_dm(IMX8MM_ARM_PLL_BYPASS, |
| 166 | imx_clk_mux_flags("arm_pll_bypass", base + 0x84, 4, 1, |
| 167 | arm_pll_bypass_sels, |
| 168 | ARRAY_SIZE(arm_pll_bypass_sels), |
| 169 | CLK_SET_RATE_PARENT)); |
| 170 | clk_dm(IMX8MM_SYS_PLL1_BYPASS, |
| 171 | imx_clk_mux_flags("sys_pll1_bypass", base + 0x94, 4, 1, |
| 172 | sys_pll1_bypass_sels, |
| 173 | ARRAY_SIZE(sys_pll1_bypass_sels), |
| 174 | CLK_SET_RATE_PARENT)); |
| 175 | clk_dm(IMX8MM_SYS_PLL2_BYPASS, |
| 176 | imx_clk_mux_flags("sys_pll2_bypass", base + 0x104, 4, 1, |
| 177 | sys_pll2_bypass_sels, |
| 178 | ARRAY_SIZE(sys_pll2_bypass_sels), |
| 179 | CLK_SET_RATE_PARENT)); |
| 180 | clk_dm(IMX8MM_SYS_PLL3_BYPASS, |
| 181 | imx_clk_mux_flags("sys_pll3_bypass", base + 0x114, 4, 1, |
| 182 | sys_pll3_bypass_sels, |
| 183 | ARRAY_SIZE(sys_pll3_bypass_sels), |
| 184 | CLK_SET_RATE_PARENT)); |
| 185 | |
| 186 | /* PLL out gate */ |
| 187 | clk_dm(IMX8MM_DRAM_PLL_OUT, |
| 188 | imx_clk_gate("dram_pll_out", "dram_pll_bypass", |
| 189 | base + 0x50, 13)); |
| 190 | clk_dm(IMX8MM_ARM_PLL_OUT, |
| 191 | imx_clk_gate("arm_pll_out", "arm_pll_bypass", |
| 192 | base + 0x84, 11)); |
| 193 | clk_dm(IMX8MM_SYS_PLL1_OUT, |
| 194 | imx_clk_gate("sys_pll1_out", "sys_pll1_bypass", |
| 195 | base + 0x94, 11)); |
| 196 | clk_dm(IMX8MM_SYS_PLL2_OUT, |
| 197 | imx_clk_gate("sys_pll2_out", "sys_pll2_bypass", |
| 198 | base + 0x104, 11)); |
| 199 | clk_dm(IMX8MM_SYS_PLL3_OUT, |
| 200 | imx_clk_gate("sys_pll3_out", "sys_pll3_bypass", |
| 201 | base + 0x114, 11)); |
| 202 | |
| 203 | /* SYS PLL fixed output */ |
| 204 | clk_dm(IMX8MM_SYS_PLL1_40M, |
| 205 | imx_clk_fixed_factor("sys_pll1_40m", "sys_pll1_out", 1, 20)); |
| 206 | clk_dm(IMX8MM_SYS_PLL1_80M, |
| 207 | imx_clk_fixed_factor("sys_pll1_80m", "sys_pll1_out", 1, 10)); |
| 208 | clk_dm(IMX8MM_SYS_PLL1_100M, |
| 209 | imx_clk_fixed_factor("sys_pll1_100m", "sys_pll1_out", 1, 8)); |
| 210 | clk_dm(IMX8MM_SYS_PLL1_133M, |
| 211 | imx_clk_fixed_factor("sys_pll1_133m", "sys_pll1_out", 1, 6)); |
| 212 | clk_dm(IMX8MM_SYS_PLL1_160M, |
| 213 | imx_clk_fixed_factor("sys_pll1_160m", "sys_pll1_out", 1, 5)); |
| 214 | clk_dm(IMX8MM_SYS_PLL1_200M, |
| 215 | imx_clk_fixed_factor("sys_pll1_200m", "sys_pll1_out", 1, 4)); |
| 216 | clk_dm(IMX8MM_SYS_PLL1_266M, |
| 217 | imx_clk_fixed_factor("sys_pll1_266m", "sys_pll1_out", 1, 3)); |
| 218 | clk_dm(IMX8MM_SYS_PLL1_400M, |
| 219 | imx_clk_fixed_factor("sys_pll1_400m", "sys_pll1_out", 1, 2)); |
| 220 | clk_dm(IMX8MM_SYS_PLL1_800M, |
| 221 | imx_clk_fixed_factor("sys_pll1_800m", "sys_pll1_out", 1, 1)); |
| 222 | |
| 223 | clk_dm(IMX8MM_SYS_PLL2_50M, |
| 224 | imx_clk_fixed_factor("sys_pll2_50m", "sys_pll2_out", 1, 20)); |
| 225 | clk_dm(IMX8MM_SYS_PLL2_100M, |
| 226 | imx_clk_fixed_factor("sys_pll2_100m", "sys_pll2_out", 1, 10)); |
| 227 | clk_dm(IMX8MM_SYS_PLL2_125M, |
| 228 | imx_clk_fixed_factor("sys_pll2_125m", "sys_pll2_out", 1, 8)); |
| 229 | clk_dm(IMX8MM_SYS_PLL2_166M, |
| 230 | imx_clk_fixed_factor("sys_pll2_166m", "sys_pll2_out", 1, 6)); |
| 231 | clk_dm(IMX8MM_SYS_PLL2_200M, |
| 232 | imx_clk_fixed_factor("sys_pll2_200m", "sys_pll2_out", 1, 5)); |
| 233 | clk_dm(IMX8MM_SYS_PLL2_250M, |
| 234 | imx_clk_fixed_factor("sys_pll2_250m", "sys_pll2_out", 1, 4)); |
| 235 | clk_dm(IMX8MM_SYS_PLL2_333M, |
| 236 | imx_clk_fixed_factor("sys_pll2_333m", "sys_pll2_out", 1, 3)); |
| 237 | clk_dm(IMX8MM_SYS_PLL2_500M, |
| 238 | imx_clk_fixed_factor("sys_pll2_500m", "sys_pll2_out", 1, 2)); |
| 239 | clk_dm(IMX8MM_SYS_PLL2_1000M, |
| 240 | imx_clk_fixed_factor("sys_pll2_1000m", "sys_pll2_out", 1, 1)); |
| 241 | |
| 242 | base = dev_read_addr_ptr(dev); |
Sean Anderson | b58106d | 2019-12-24 23:57:47 -0500 | [diff] [blame] | 243 | if (!base) |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 244 | return -EINVAL; |
| 245 | |
| 246 | clk_dm(IMX8MM_CLK_A53_SRC, |
| 247 | imx_clk_mux2("arm_a53_src", base + 0x8000, 24, 3, |
| 248 | imx8mm_a53_sels, ARRAY_SIZE(imx8mm_a53_sels))); |
| 249 | clk_dm(IMX8MM_CLK_A53_CG, |
| 250 | imx_clk_gate3("arm_a53_cg", "arm_a53_src", base + 0x8000, 28)); |
| 251 | clk_dm(IMX8MM_CLK_A53_DIV, |
| 252 | imx_clk_divider2("arm_a53_div", "arm_a53_cg", |
| 253 | base + 0x8000, 0, 3)); |
| 254 | |
| 255 | clk_dm(IMX8MM_CLK_AHB, |
| 256 | imx8m_clk_composite_critical("ahb", imx8mm_ahb_sels, |
| 257 | base + 0x9000)); |
| 258 | clk_dm(IMX8MM_CLK_IPG_ROOT, |
| 259 | imx_clk_divider2("ipg_root", "ahb", base + 0x9080, 0, 1)); |
| 260 | |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 261 | clk_dm(IMX8MM_CLK_NAND_USDHC_BUS, |
| 262 | imx8m_clk_composite_critical("nand_usdhc_bus", |
| 263 | imx8mm_nand_usdhc_sels, |
| 264 | base + 0x8900)); |
Ye Li | 0321edb | 2020-04-19 02:22:09 -0700 | [diff] [blame] | 265 | clk_dm(IMX8MM_CLK_USB_BUS, |
| 266 | imx8m_clk_composite("usb_bus", imx8mm_usb_bus_sels, base + 0x8b80)); |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 267 | |
| 268 | /* IP */ |
Tim Harvey | ff46558 | 2024-04-19 08:29:00 -0700 | [diff] [blame] | 269 | #if CONFIG_IS_ENABLED(PCIE_DW_IMX) |
| 270 | clk_dm(IMX8MM_CLK_PCIE1_CTRL, |
| 271 | imx8m_clk_composite("pcie1_ctrl", imx8mm_pcie1_ctrl_sels, |
| 272 | base + 0xa300)); |
| 273 | clk_dm(IMX8MM_CLK_PCIE1_PHY, |
| 274 | imx8m_clk_composite("pcie1_phy", imx8mm_pcie1_phy_sels, |
| 275 | base + 0xa380)); |
| 276 | clk_dm(IMX8MM_CLK_PCIE1_AUX, |
| 277 | imx8m_clk_composite("pcie1_aux", imx8mm_pcie1_aux_sels, |
| 278 | base + 0xa400)); |
| 279 | #endif |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 280 | clk_dm(IMX8MM_CLK_USDHC1, |
| 281 | imx8m_clk_composite("usdhc1", imx8mm_usdhc1_sels, |
| 282 | base + 0xac00)); |
| 283 | clk_dm(IMX8MM_CLK_USDHC2, |
| 284 | imx8m_clk_composite("usdhc2", imx8mm_usdhc2_sels, |
| 285 | base + 0xac80)); |
| 286 | clk_dm(IMX8MM_CLK_I2C1, |
| 287 | imx8m_clk_composite("i2c1", imx8mm_i2c1_sels, base + 0xad00)); |
| 288 | clk_dm(IMX8MM_CLK_I2C2, |
| 289 | imx8m_clk_composite("i2c2", imx8mm_i2c2_sels, base + 0xad80)); |
| 290 | clk_dm(IMX8MM_CLK_I2C3, |
| 291 | imx8m_clk_composite("i2c3", imx8mm_i2c3_sels, base + 0xae00)); |
| 292 | clk_dm(IMX8MM_CLK_I2C4, |
| 293 | imx8m_clk_composite("i2c4", imx8mm_i2c4_sels, base + 0xae80)); |
| 294 | clk_dm(IMX8MM_CLK_WDOG, |
| 295 | imx8m_clk_composite("wdog", imx8mm_wdog_sels, base + 0xb900)); |
| 296 | clk_dm(IMX8MM_CLK_USDHC3, |
| 297 | imx8m_clk_composite("usdhc3", imx8mm_usdhc3_sels, |
| 298 | base + 0xbc80)); |
Ye Li | 0321edb | 2020-04-19 02:22:09 -0700 | [diff] [blame] | 299 | clk_dm(IMX8MM_CLK_USB_CORE_REF, |
| 300 | imx8m_clk_composite("usb_core_ref", imx8mm_usb_core_sels, base + 0xb100)); |
| 301 | clk_dm(IMX8MM_CLK_USB_PHY_REF, |
| 302 | imx8m_clk_composite("usb_phy_ref", imx8mm_usb_phy_sels, base + 0xb180)); |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 303 | clk_dm(IMX8MM_CLK_I2C1_ROOT, |
| 304 | imx_clk_gate4("i2c1_root_clk", "i2c1", base + 0x4170, 0)); |
| 305 | clk_dm(IMX8MM_CLK_I2C2_ROOT, |
| 306 | imx_clk_gate4("i2c2_root_clk", "i2c2", base + 0x4180, 0)); |
| 307 | clk_dm(IMX8MM_CLK_I2C3_ROOT, |
| 308 | imx_clk_gate4("i2c3_root_clk", "i2c3", base + 0x4190, 0)); |
| 309 | clk_dm(IMX8MM_CLK_I2C4_ROOT, |
| 310 | imx_clk_gate4("i2c4_root_clk", "i2c4", base + 0x41a0, 0)); |
| 311 | clk_dm(IMX8MM_CLK_OCOTP_ROOT, |
| 312 | imx_clk_gate4("ocotp_root_clk", "ipg_root", base + 0x4220, 0)); |
| 313 | clk_dm(IMX8MM_CLK_USDHC1_ROOT, |
| 314 | imx_clk_gate4("usdhc1_root_clk", "usdhc1", base + 0x4510, 0)); |
| 315 | clk_dm(IMX8MM_CLK_USDHC2_ROOT, |
| 316 | imx_clk_gate4("usdhc2_root_clk", "usdhc2", base + 0x4520, 0)); |
| 317 | clk_dm(IMX8MM_CLK_WDOG1_ROOT, |
| 318 | imx_clk_gate4("wdog1_root_clk", "wdog", base + 0x4530, 0)); |
| 319 | clk_dm(IMX8MM_CLK_WDOG2_ROOT, |
| 320 | imx_clk_gate4("wdog2_root_clk", "wdog", base + 0x4540, 0)); |
| 321 | clk_dm(IMX8MM_CLK_WDOG3_ROOT, |
| 322 | imx_clk_gate4("wdog3_root_clk", "wdog", base + 0x4550, 0)); |
| 323 | clk_dm(IMX8MM_CLK_USDHC3_ROOT, |
| 324 | imx_clk_gate4("usdhc3_root_clk", "usdhc3", base + 0x45e0, 0)); |
Ye Li | 0321edb | 2020-04-19 02:22:09 -0700 | [diff] [blame] | 325 | clk_dm(IMX8MM_CLK_USB1_CTRL_ROOT, |
| 326 | imx_clk_gate4("usb1_ctrl_root_clk", "usb_bus", base + 0x44d0, 0)); |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 327 | |
Peng Fan | ee5515d | 2019-10-22 03:29:48 +0000 | [diff] [blame] | 328 | /* clks not needed in SPL stage */ |
| 329 | #ifndef CONFIG_SPL_BUILD |
Fabio Estevam | 704aa87 | 2022-09-26 13:40:09 -0300 | [diff] [blame] | 330 | clk_dm(IMX8MM_CLK_ENET_AXI, |
| 331 | imx8m_clk_composite("enet_axi", imx8mm_enet_axi_sels, |
| 332 | base + 0x8880)); |
Peng Fan | ee5515d | 2019-10-22 03:29:48 +0000 | [diff] [blame] | 333 | clk_dm(IMX8MM_CLK_ENET_REF, |
| 334 | imx8m_clk_composite("enet_ref", imx8mm_enet_ref_sels, |
| 335 | base + 0xa980)); |
| 336 | clk_dm(IMX8MM_CLK_ENET_TIMER, |
| 337 | imx8m_clk_composite("enet_timer", imx8mm_enet_timer_sels, |
| 338 | base + 0xaa00)); |
| 339 | clk_dm(IMX8MM_CLK_ENET_PHY_REF, |
| 340 | imx8m_clk_composite("enet_phy", imx8mm_enet_phy_sels, |
| 341 | base + 0xaa80)); |
| 342 | clk_dm(IMX8MM_CLK_ENET1_ROOT, |
| 343 | imx_clk_gate4("enet1_root_clk", "enet_axi", |
| 344 | base + 0x40a0, 0)); |
Fabio Estevam | 60896e0 | 2022-09-26 13:40:08 -0300 | [diff] [blame] | 345 | clk_dm(IMX8MM_CLK_PWM1, |
| 346 | imx8m_clk_composite("pwm1", imx8mm_pwm1_sels, base + 0xb380)); |
| 347 | clk_dm(IMX8MM_CLK_PWM2, |
| 348 | imx8m_clk_composite("pwm2", imx8mm_pwm2_sels, base + 0xb400)); |
| 349 | clk_dm(IMX8MM_CLK_PWM3, |
| 350 | imx8m_clk_composite("pwm3", imx8mm_pwm3_sels, base + 0xb480)); |
| 351 | clk_dm(IMX8MM_CLK_PWM4, |
| 352 | imx8m_clk_composite("pwm4", imx8mm_pwm4_sels, base + 0xb500)); |
| 353 | clk_dm(IMX8MM_CLK_PWM1_ROOT, |
| 354 | imx_clk_gate4("pwm1_root_clk", "pwm1", base + 0x4280, 0)); |
| 355 | clk_dm(IMX8MM_CLK_PWM2_ROOT, |
| 356 | imx_clk_gate4("pwm2_root_clk", "pwm2", base + 0x4290, 0)); |
| 357 | clk_dm(IMX8MM_CLK_PWM3_ROOT, |
| 358 | imx_clk_gate4("pwm3_root_clk", "pwm3", base + 0x42a0, 0)); |
| 359 | clk_dm(IMX8MM_CLK_PWM4_ROOT, |
| 360 | imx_clk_gate4("pwm4_root_clk", "pwm4", base + 0x42b0, 0)); |
Peng Fan | ee5515d | 2019-10-22 03:29:48 +0000 | [diff] [blame] | 361 | #endif |
| 362 | |
Tim Harvey | ff46558 | 2024-04-19 08:29:00 -0700 | [diff] [blame] | 363 | #if CONFIG_IS_ENABLED(PCIE_DW_IMX) |
| 364 | clk_dm(IMX8MM_CLK_PCIE1_ROOT, |
| 365 | imx_clk_gate4("pcie1_root_clk", "pcie1_ctrl", base + 0x4250, 0)); |
| 366 | #endif |
| 367 | |
Fabio Estevam | 0b3fa1b | 2022-09-26 13:40:10 -0300 | [diff] [blame] | 368 | #if CONFIG_IS_ENABLED(DM_SPI) |
| 369 | clk_dm(IMX8MM_CLK_ECSPI1, |
| 370 | imx8m_clk_composite("ecspi1", imx8mm_ecspi1_sels, base + 0xb280)); |
| 371 | clk_dm(IMX8MM_CLK_ECSPI2, |
| 372 | imx8m_clk_composite("ecspi2", imx8mm_ecspi2_sels, base + 0xb300)); |
| 373 | clk_dm(IMX8MM_CLK_ECSPI3, |
| 374 | imx8m_clk_composite("ecspi3", imx8mm_ecspi3_sels, base + 0xc180)); |
| 375 | |
| 376 | clk_dm(IMX8MM_CLK_ECSPI1_ROOT, |
| 377 | imx_clk_gate4("ecspi1_root_clk", "ecspi1", base + 0x4070, 0)); |
| 378 | clk_dm(IMX8MM_CLK_ECSPI2_ROOT, |
| 379 | imx_clk_gate4("ecspi2_root_clk", "ecspi2", base + 0x4080, 0)); |
| 380 | clk_dm(IMX8MM_CLK_ECSPI3_ROOT, |
| 381 | imx_clk_gate4("ecspi3_root_clk", "ecspi3", base + 0x4090, 0)); |
| 382 | #endif |
| 383 | |
Fabio Estevam | 3e5255c | 2022-09-26 13:40:11 -0300 | [diff] [blame] | 384 | #if CONFIG_IS_ENABLED(NXP_FSPI) |
| 385 | clk_dm(IMX8MM_CLK_QSPI, |
| 386 | imx8m_clk_composite("qspi", imx8mm_qspi_sels, base + 0xab80)); |
| 387 | clk_dm(IMX8MM_CLK_QSPI_ROOT, |
| 388 | imx_clk_gate4("qspi_root_clk", "qspi", base + 0x42f0, 0)); |
| 389 | #endif |
| 390 | |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 391 | return 0; |
| 392 | } |
| 393 | |
| 394 | static const struct udevice_id imx8mm_clk_ids[] = { |
| 395 | { .compatible = "fsl,imx8mm-ccm" }, |
| 396 | { }, |
| 397 | }; |
| 398 | |
| 399 | U_BOOT_DRIVER(imx8mm_clk) = { |
| 400 | .name = "clk_imx8mm", |
| 401 | .id = UCLASS_CLK, |
| 402 | .of_match = imx8mm_clk_ids, |
Sean Anderson | 35c8464 | 2022-03-20 16:34:46 -0400 | [diff] [blame] | 403 | .ops = &ccf_clk_ops, |
Peng Fan | 525c876 | 2019-08-19 07:54:04 +0000 | [diff] [blame] | 404 | .probe = imx8mm_clk_probe, |
| 405 | .flags = DM_FLAG_PRE_RELOC, |
| 406 | }; |