Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [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 | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 12 | #include <asm/arch/clock.h> |
| 13 | #include <asm/arch/imx-regs.h> |
| 14 | #include <dt-bindings/clock/imx8mp-clock.h> |
| 15 | |
| 16 | #include "clk.h" |
| 17 | |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [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 *imx8mp_a53_sels[] = {"clock-osc-24m", "arm_pll_out", "sys_pll2_500m", |
| 26 | "sys_pll2_1000m", "sys_pll1_800m", "sys_pll1_400m", |
| 27 | "audio_pll1_out", "sys_pll3_out", }; |
| 28 | |
Marek Vasut | 55452b6 | 2022-04-01 03:17:29 +0200 | [diff] [blame] | 29 | static const char *imx8mp_hsio_axi_sels[] = {"clock-osc-24m", "sys_pll2_500m", "sys_pll1_800m", |
| 30 | "sys_pll2_100m", "sys_pll2_200m", "clk_ext2", |
| 31 | "clk_ext4", "audio_pll2_out", }; |
| 32 | |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 33 | static const char *imx8mp_main_axi_sels[] = {"clock-osc-24m", "sys_pll2_333m", "sys_pll1_800m", |
| 34 | "sys_pll2_250m", "sys_pll2_1000m", "audio_pll1_out", |
| 35 | "video_pll1_out", "sys_pll1_100m",}; |
| 36 | |
Ye Li | ee9c213 | 2020-04-21 20:19:24 -0700 | [diff] [blame] | 37 | static const char *imx8mp_enet_axi_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m", |
| 38 | "sys_pll2_250m", "sys_pll2_200m", "audio_pll1_out", |
| 39 | "video_pll1_out", "sys_pll3_out", }; |
| 40 | |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 41 | static const char *imx8mp_nand_usdhc_sels[] = {"clock-osc-24m", "sys_pll1_266m", "sys_pll1_800m", |
| 42 | "sys_pll2_200m", "sys_pll1_133m", "sys_pll3_out", |
| 43 | "sys_pll2_250m", "audio_pll1_out", }; |
| 44 | |
| 45 | static const char *imx8mp_noc_sels[] = {"clock-osc-24m", "sys_pll1_800m", "sys_pll3_out", |
| 46 | "sys_pll2_1000m", "sys_pll2_500m", "audio_pll1_out", |
| 47 | "video_pll1_out", "audio_pll2_out", }; |
| 48 | |
| 49 | static const char *imx8mp_noc_io_sels[] = {"clock-osc-24m", "sys_pll1_800m", "sys_pll3_out", |
| 50 | "sys_pll2_1000m", "sys_pll2_500m", "audio_pll1_out", |
| 51 | "video_pll1_out", "audio_pll2_out", }; |
| 52 | |
| 53 | static const char *imx8mp_ahb_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_800m", |
| 54 | "sys_pll1_400m", "sys_pll2_125m", "sys_pll3_out", |
| 55 | "audio_pll1_out", "video_pll1_out", }; |
| 56 | |
| 57 | static const char *imx8mp_dram_alt_sels[] = {"clock-osc-24m", "sys_pll1_800m", "sys_pll1_100m", |
| 58 | "sys_pll2_500m", "sys_pll2_1000m", "sys_pll3_out", |
| 59 | "audio_pll1_out", "sys_pll1_266m", }; |
| 60 | |
| 61 | static const char *imx8mp_dram_apb_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m", |
| 62 | "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out", |
| 63 | "sys_pll2_250m", "audio_pll2_out", }; |
| 64 | |
| 65 | static const char *imx8mp_i2c5_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", |
| 66 | "sys_pll3_out", "audio_pll1_out", "video_pll1_out", |
| 67 | "audio_pll2_out", "sys_pll1_133m", }; |
| 68 | |
| 69 | static const char *imx8mp_i2c6_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", |
| 70 | "sys_pll3_out", "audio_pll1_out", "video_pll1_out", |
| 71 | "audio_pll2_out", "sys_pll1_133m", }; |
| 72 | |
Marek Vasut | d4e448d | 2023-03-06 15:53:41 +0100 | [diff] [blame] | 73 | static const char *imx8mp_enet_qos_sels[] = {"clock-osc-24m", "sys_pll2_125m", "sys_pll2_50m", |
| 74 | "sys_pll2_100m", "sys_pll1_160m", "audio_pll1_out", |
| 75 | "video_pll1_out", "clk_ext4", }; |
| 76 | |
| 77 | static const char *imx8mp_enet_qos_timer_sels[] = {"clock-osc-24m", "sys_pll2_100m", "audio_pll1_out", |
| 78 | "clk_ext1", "clk_ext2", "clk_ext3", |
| 79 | "clk_ext4", "video_pll1_out", }; |
| 80 | |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 81 | static const char *imx8mp_usdhc1_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m", |
| 82 | "sys_pll2_500m", "sys_pll3_out", "sys_pll1_266m", |
| 83 | "audio_pll2_out", "sys_pll1_100m", }; |
| 84 | |
| 85 | static const char *imx8mp_usdhc2_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m", |
| 86 | "sys_pll2_500m", "sys_pll3_out", "sys_pll1_266m", |
| 87 | "audio_pll2_out", "sys_pll1_100m", }; |
| 88 | |
| 89 | static const char *imx8mp_i2c1_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", |
| 90 | "sys_pll3_out", "audio_pll1_out", "video_pll1_out", |
| 91 | "audio_pll2_out", "sys_pll1_133m", }; |
| 92 | |
| 93 | static const char *imx8mp_i2c2_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", |
| 94 | "sys_pll3_out", "audio_pll1_out", "video_pll1_out", |
| 95 | "audio_pll2_out", "sys_pll1_133m", }; |
| 96 | |
| 97 | static const char *imx8mp_i2c3_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", |
| 98 | "sys_pll3_out", "audio_pll1_out", "video_pll1_out", |
| 99 | "audio_pll2_out", "sys_pll1_133m", }; |
| 100 | |
| 101 | static const char *imx8mp_i2c4_sels[] = {"clock-osc-24m", "sys_pll1_160m", "sys_pll2_50m", |
| 102 | "sys_pll3_out", "audio_pll1_out", "video_pll1_out", |
| 103 | "audio_pll2_out", "sys_pll1_133m", }; |
| 104 | |
| 105 | static const char *imx8mp_uart1_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m", |
| 106 | "sys_pll2_100m", "sys_pll3_out", "clk_ext2", |
| 107 | "clk_ext4", "audio_pll2_out", }; |
| 108 | |
| 109 | static const char *imx8mp_uart2_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m", |
| 110 | "sys_pll2_100m", "sys_pll3_out", "clk_ext2", |
| 111 | "clk_ext3", "audio_pll2_out", }; |
| 112 | |
| 113 | static const char *imx8mp_uart3_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m", |
| 114 | "sys_pll2_100m", "sys_pll3_out", "clk_ext2", |
| 115 | "clk_ext4", "audio_pll2_out", }; |
| 116 | |
| 117 | static const char *imx8mp_uart4_sels[] = {"clock-osc-24m", "sys_pll1_80m", "sys_pll2_200m", |
| 118 | "sys_pll2_100m", "sys_pll3_out", "clk_ext2", |
| 119 | "clk_ext3", "audio_pll2_out", }; |
| 120 | |
Marek Vasut | 55452b6 | 2022-04-01 03:17:29 +0200 | [diff] [blame] | 121 | static const char *imx8mp_usb_core_ref_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m", |
| 122 | "sys_pll2_100m", "sys_pll2_200m", "clk_ext2", |
| 123 | "clk_ext3", "audio_pll2_out", }; |
| 124 | |
| 125 | static const char *imx8mp_usb_phy_ref_sels[] = {"clock-osc-24m", "sys_pll1_100m", "sys_pll1_40m", |
| 126 | "sys_pll2_100m", "sys_pll2_200m", "clk_ext2", |
| 127 | "clk_ext3", "audio_pll2_out", }; |
| 128 | |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 129 | static const char *imx8mp_gic_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m", |
| 130 | "sys_pll2_100m", "sys_pll1_800m", |
| 131 | "sys_pll2_500m", "clk_ext4", "audio_pll2_out" }; |
| 132 | |
Tommaso Merciai | d65085a | 2023-03-10 16:24:24 +0100 | [diff] [blame] | 133 | static const char *imx8mp_pwm1_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m", |
| 134 | "sys_pll1_40m", "sys_pll3_out", "clk_ext1", |
| 135 | "sys_pll1_80m", "video_pll1_out", }; |
| 136 | |
| 137 | static const char *imx8mp_pwm2_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m", |
| 138 | "sys_pll1_40m", "sys_pll3_out", "clk_ext1", |
| 139 | "sys_pll1_80m", "video_pll1_out", }; |
| 140 | |
| 141 | static const char *imx8mp_pwm3_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m", |
| 142 | "sys_pll1_40m", "sys_pll3_out", "clk_ext2", |
| 143 | "sys_pll1_80m", "video_pll1_out", }; |
| 144 | |
| 145 | static const char *imx8mp_pwm4_sels[] = {"clock-osc-24m", "sys_pll2_100m", "sys_pll1_160m", |
| 146 | "sys_pll1_40m", "sys_pll3_out", "clk_ext2", |
| 147 | "sys_pll1_80m", "video_pll1_out", }; |
| 148 | |
Andrey Zhizhikin | fa9087c | 2022-06-03 17:15:21 +0200 | [diff] [blame] | 149 | static const char *imx8mp_ecspi1_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m", |
Elmar Albert | 81528d1 | 2022-04-06 13:39:50 +0200 | [diff] [blame] | 150 | "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out", |
| 151 | "sys_pll2_250m", "audio_pll2_out", }; |
| 152 | |
Andrey Zhizhikin | fa9087c | 2022-06-03 17:15:21 +0200 | [diff] [blame] | 153 | static const char *imx8mp_ecspi2_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m", |
Elmar Albert | 81528d1 | 2022-04-06 13:39:50 +0200 | [diff] [blame] | 154 | "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out", |
| 155 | "sys_pll2_250m", "audio_pll2_out", }; |
| 156 | |
Andrey Zhizhikin | fa9087c | 2022-06-03 17:15:21 +0200 | [diff] [blame] | 157 | static const char *imx8mp_ecspi3_sels[] = {"clock-osc-24m", "sys_pll2_200m", "sys_pll1_40m", |
Elmar Albert | 81528d1 | 2022-04-06 13:39:50 +0200 | [diff] [blame] | 158 | "sys_pll1_160m", "sys_pll1_800m", "sys_pll3_out", |
| 159 | "sys_pll2_250m", "audio_pll2_out", }; |
| 160 | |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 161 | static const char *imx8mp_wdog_sels[] = {"clock-osc-24m", "sys_pll1_133m", "sys_pll1_160m", |
| 162 | "vpu_pll_out", "sys_pll2_125m", "sys_pll3_out", |
| 163 | "sys_pll1_80m", "sys_pll2_166m" }; |
| 164 | |
Ye Li | ee9c213 | 2020-04-21 20:19:24 -0700 | [diff] [blame] | 165 | static const char *imx8mp_qspi_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll2_333m", |
| 166 | "sys_pll2_500m", "audio_pll2_out", "sys_pll1_266m", |
| 167 | "sys_pll3_out", "sys_pll1_100m", }; |
| 168 | |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 169 | static const char *imx8mp_usdhc3_sels[] = {"clock-osc-24m", "sys_pll1_400m", "sys_pll1_800m", |
| 170 | "sys_pll2_500m", "sys_pll3_out", "sys_pll1_266m", |
| 171 | "audio_pll2_out", "sys_pll1_100m", }; |
| 172 | |
Ye Li | ee9c213 | 2020-04-21 20:19:24 -0700 | [diff] [blame] | 173 | static const char *imx8mp_enet_ref_sels[] = {"clock-osc-24m", "sys_pll2_125m", "sys_pll2_50m", |
| 174 | "sys_pll2_100m", "sys_pll1_160m", "audio_pll1_out", |
| 175 | "video_pll1_out", "clk_ext4", }; |
| 176 | |
| 177 | static const char *imx8mp_enet_timer_sels[] = {"clock-osc-24m", "sys_pll2_100m", "audio_pll1_out", |
| 178 | "clk_ext1", "clk_ext2", "clk_ext3", |
| 179 | "clk_ext4", "video_pll1_out", }; |
| 180 | |
| 181 | static const char *imx8mp_enet_phy_ref_sels[] = {"clock-osc-24m", "sys_pll2_50m", "sys_pll2_125m", |
| 182 | "sys_pll2_200m", "sys_pll2_500m", "audio_pll1_out", |
| 183 | "video_pll1_out", "audio_pll2_out", }; |
| 184 | |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 185 | static const char *imx8mp_dram_core_sels[] = {"dram_pll_out", "dram_alt_root", }; |
| 186 | |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 187 | static int imx8mp_clk_probe(struct udevice *dev) |
| 188 | { |
Marek Vasut | 3c2d27a | 2022-04-13 00:41:10 +0200 | [diff] [blame] | 189 | struct clk osc_24m_clk, osc_32k_clk; |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 190 | void __iomem *base; |
Marek Vasut | 3c2d27a | 2022-04-13 00:41:10 +0200 | [diff] [blame] | 191 | int ret; |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 192 | |
| 193 | base = (void *)ANATOP_BASE_ADDR; |
| 194 | |
| 195 | clk_dm(IMX8MP_DRAM_PLL_REF_SEL, imx_clk_mux("dram_pll_ref_sel", base + 0x50, 0, 2, pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 196 | clk_dm(IMX8MP_ARM_PLL_REF_SEL, imx_clk_mux("arm_pll_ref_sel", base + 0x84, 0, 2, pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 197 | clk_dm(IMX8MP_SYS_PLL1_REF_SEL, imx_clk_mux("sys_pll1_ref_sel", base + 0x94, 0, 2, pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 198 | clk_dm(IMX8MP_SYS_PLL2_REF_SEL, imx_clk_mux("sys_pll2_ref_sel", base + 0x104, 0, 2, pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 199 | clk_dm(IMX8MP_SYS_PLL3_REF_SEL, imx_clk_mux("sys_pll3_ref_sel", base + 0x114, 0, 2, pll_ref_sels, ARRAY_SIZE(pll_ref_sels))); |
| 200 | |
Angus Ainslie | 73d75ec | 2022-03-29 07:02:40 -0700 | [diff] [blame] | 201 | clk_dm(IMX8MP_DRAM_PLL, imx_clk_pll14xx("dram_pll", "dram_pll_ref_sel", base + 0x50, |
| 202 | &imx_1443x_dram_pll)); |
| 203 | clk_dm(IMX8MP_ARM_PLL, imx_clk_pll14xx("arm_pll", "arm_pll_ref_sel", base + 0x84, |
| 204 | &imx_1416x_pll)); |
| 205 | clk_dm(IMX8MP_SYS_PLL1, imx_clk_pll14xx("sys_pll1", "sys_pll1_ref_sel", base + 0x94, |
| 206 | &imx_1416x_pll)); |
| 207 | clk_dm(IMX8MP_SYS_PLL2, imx_clk_pll14xx("sys_pll2", "sys_pll2_ref_sel", base + 0x104, |
| 208 | &imx_1416x_pll)); |
| 209 | clk_dm(IMX8MP_SYS_PLL3, imx_clk_pll14xx("sys_pll3", "sys_pll3_ref_sel", base + 0x114, |
| 210 | &imx_1416x_pll)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 211 | |
| 212 | clk_dm(IMX8MP_DRAM_PLL_BYPASS, imx_clk_mux_flags("dram_pll_bypass", base + 0x50, 4, 1, dram_pll_bypass_sels, ARRAY_SIZE(dram_pll_bypass_sels), CLK_SET_RATE_PARENT)); |
| 213 | clk_dm(IMX8MP_ARM_PLL_BYPASS, imx_clk_mux_flags("arm_pll_bypass", base + 0x84, 4, 1, arm_pll_bypass_sels, ARRAY_SIZE(arm_pll_bypass_sels), CLK_SET_RATE_PARENT)); |
| 214 | clk_dm(IMX8MP_SYS_PLL1_BYPASS, imx_clk_mux_flags("sys_pll1_bypass", base + 0x94, 4, 1, sys_pll1_bypass_sels, ARRAY_SIZE(sys_pll1_bypass_sels), CLK_SET_RATE_PARENT)); |
| 215 | clk_dm(IMX8MP_SYS_PLL2_BYPASS, imx_clk_mux_flags("sys_pll2_bypass", base + 0x104, 4, 1, sys_pll2_bypass_sels, ARRAY_SIZE(sys_pll2_bypass_sels), CLK_SET_RATE_PARENT)); |
| 216 | clk_dm(IMX8MP_SYS_PLL3_BYPASS, imx_clk_mux_flags("sys_pll3_bypass", base + 0x114, 4, 1, sys_pll3_bypass_sels, ARRAY_SIZE(sys_pll3_bypass_sels), CLK_SET_RATE_PARENT)); |
| 217 | |
| 218 | clk_dm(IMX8MP_DRAM_PLL_OUT, imx_clk_gate("dram_pll_out", "dram_pll_bypass", base + 0x50, 13)); |
| 219 | clk_dm(IMX8MP_ARM_PLL_OUT, imx_clk_gate("arm_pll_out", "arm_pll_bypass", base + 0x84, 11)); |
| 220 | clk_dm(IMX8MP_SYS_PLL1_OUT, imx_clk_gate("sys_pll1_out", "sys_pll1_bypass", base + 0x94, 11)); |
| 221 | clk_dm(IMX8MP_SYS_PLL2_OUT, imx_clk_gate("sys_pll2_out", "sys_pll2_bypass", base + 0x104, 11)); |
| 222 | clk_dm(IMX8MP_SYS_PLL3_OUT, imx_clk_gate("sys_pll3_out", "sys_pll3_bypass", base + 0x114, 11)); |
| 223 | |
| 224 | clk_dm(IMX8MP_SYS_PLL1_40M, imx_clk_fixed_factor("sys_pll1_40m", "sys_pll1_out", 1, 20)); |
| 225 | clk_dm(IMX8MP_SYS_PLL1_80M, imx_clk_fixed_factor("sys_pll1_80m", "sys_pll1_out", 1, 10)); |
| 226 | clk_dm(IMX8MP_SYS_PLL1_100M, imx_clk_fixed_factor("sys_pll1_100m", "sys_pll1_out", 1, 8)); |
| 227 | clk_dm(IMX8MP_SYS_PLL1_133M, imx_clk_fixed_factor("sys_pll1_133m", "sys_pll1_out", 1, 6)); |
| 228 | clk_dm(IMX8MP_SYS_PLL1_160M, imx_clk_fixed_factor("sys_pll1_160m", "sys_pll1_out", 1, 5)); |
| 229 | clk_dm(IMX8MP_SYS_PLL1_200M, imx_clk_fixed_factor("sys_pll1_200m", "sys_pll1_out", 1, 4)); |
| 230 | clk_dm(IMX8MP_SYS_PLL1_266M, imx_clk_fixed_factor("sys_pll1_266m", "sys_pll1_out", 1, 3)); |
| 231 | clk_dm(IMX8MP_SYS_PLL1_400M, imx_clk_fixed_factor("sys_pll1_400m", "sys_pll1_out", 1, 2)); |
| 232 | clk_dm(IMX8MP_SYS_PLL1_800M, imx_clk_fixed_factor("sys_pll1_800m", "sys_pll1_out", 1, 1)); |
| 233 | |
| 234 | clk_dm(IMX8MP_SYS_PLL2_50M, imx_clk_fixed_factor("sys_pll2_50m", "sys_pll2_out", 1, 20)); |
| 235 | clk_dm(IMX8MP_SYS_PLL2_100M, imx_clk_fixed_factor("sys_pll2_100m", "sys_pll2_out", 1, 10)); |
| 236 | clk_dm(IMX8MP_SYS_PLL2_125M, imx_clk_fixed_factor("sys_pll2_125m", "sys_pll2_out", 1, 8)); |
| 237 | clk_dm(IMX8MP_SYS_PLL2_166M, imx_clk_fixed_factor("sys_pll2_166m", "sys_pll2_out", 1, 6)); |
| 238 | clk_dm(IMX8MP_SYS_PLL2_200M, imx_clk_fixed_factor("sys_pll2_200m", "sys_pll2_out", 1, 5)); |
| 239 | clk_dm(IMX8MP_SYS_PLL2_250M, imx_clk_fixed_factor("sys_pll2_250m", "sys_pll2_out", 1, 4)); |
| 240 | clk_dm(IMX8MP_SYS_PLL2_333M, imx_clk_fixed_factor("sys_pll2_333m", "sys_pll2_out", 1, 3)); |
| 241 | clk_dm(IMX8MP_SYS_PLL2_500M, imx_clk_fixed_factor("sys_pll2_500m", "sys_pll2_out", 1, 2)); |
| 242 | clk_dm(IMX8MP_SYS_PLL2_1000M, imx_clk_fixed_factor("sys_pll2_1000m", "sys_pll2_out", 1, 1)); |
| 243 | |
Marek Vasut | 3c2d27a | 2022-04-13 00:41:10 +0200 | [diff] [blame] | 244 | ret = clk_get_by_name(dev, "osc_24m", &osc_24m_clk); |
| 245 | if (ret) |
| 246 | return ret; |
| 247 | clk_dm(IMX8MP_CLK_24M, dev_get_clk_ptr(osc_24m_clk.dev)); |
| 248 | |
| 249 | ret = clk_get_by_name(dev, "osc_32k", &osc_32k_clk); |
| 250 | if (ret) |
| 251 | return ret; |
| 252 | clk_dm(IMX8MP_CLK_32K, dev_get_clk_ptr(osc_32k_clk.dev)); |
Marek Vasut | 55452b6 | 2022-04-01 03:17:29 +0200 | [diff] [blame] | 253 | |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 254 | base = dev_read_addr_ptr(dev); |
Sean Anderson | 42db70b | 2020-06-24 06:41:13 -0400 | [diff] [blame] | 255 | if (!base) |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 256 | return -EINVAL; |
| 257 | |
| 258 | clk_dm(IMX8MP_CLK_A53_SRC, imx_clk_mux2("arm_a53_src", base + 0x8000, 24, 3, imx8mp_a53_sels, ARRAY_SIZE(imx8mp_a53_sels))); |
| 259 | clk_dm(IMX8MP_CLK_A53_CG, imx_clk_gate3("arm_a53_cg", "arm_a53_src", base + 0x8000, 28)); |
| 260 | clk_dm(IMX8MP_CLK_A53_DIV, imx_clk_divider2("arm_a53_div", "arm_a53_cg", base + 0x8000, 0, 3)); |
| 261 | |
Marek Vasut | 55452b6 | 2022-04-01 03:17:29 +0200 | [diff] [blame] | 262 | clk_dm(IMX8MP_CLK_HSIO_AXI, imx8m_clk_composite("hsio_axi", imx8mp_hsio_axi_sels, base + 0x8380)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 263 | clk_dm(IMX8MP_CLK_MAIN_AXI, imx8m_clk_composite_critical("main_axi", imx8mp_main_axi_sels, base + 0x8800)); |
Ye Li | ee9c213 | 2020-04-21 20:19:24 -0700 | [diff] [blame] | 264 | clk_dm(IMX8MP_CLK_ENET_AXI, imx8m_clk_composite_critical("enet_axi", imx8mp_enet_axi_sels, base + 0x8880)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 265 | clk_dm(IMX8MP_CLK_NAND_USDHC_BUS, imx8m_clk_composite_critical("nand_usdhc_bus", imx8mp_nand_usdhc_sels, base + 0x8900)); |
| 266 | clk_dm(IMX8MP_CLK_NOC, imx8m_clk_composite_critical("noc", imx8mp_noc_sels, base + 0x8d00)); |
| 267 | clk_dm(IMX8MP_CLK_NOC_IO, imx8m_clk_composite_critical("noc_io", imx8mp_noc_io_sels, base + 0x8d80)); |
| 268 | |
| 269 | clk_dm(IMX8MP_CLK_AHB, imx8m_clk_composite_critical("ahb_root", imx8mp_ahb_sels, base + 0x9000)); |
| 270 | |
| 271 | clk_dm(IMX8MP_CLK_IPG_ROOT, imx_clk_divider2("ipg_root", "ahb_root", base + 0x9080, 0, 1)); |
| 272 | |
| 273 | clk_dm(IMX8MP_CLK_DRAM_ALT, imx8m_clk_composite("dram_alt", imx8mp_dram_alt_sels, base + 0xa000)); |
| 274 | clk_dm(IMX8MP_CLK_DRAM_APB, imx8m_clk_composite_critical("dram_apb", imx8mp_dram_apb_sels, base + 0xa080)); |
| 275 | clk_dm(IMX8MP_CLK_I2C5, imx8m_clk_composite("i2c5", imx8mp_i2c5_sels, base + 0xa480)); |
| 276 | clk_dm(IMX8MP_CLK_I2C6, imx8m_clk_composite("i2c6", imx8mp_i2c6_sels, base + 0xa500)); |
Marek Vasut | d4e448d | 2023-03-06 15:53:41 +0100 | [diff] [blame] | 277 | clk_dm(IMX8MP_CLK_ENET_QOS, imx8m_clk_composite("enet_qos", imx8mp_enet_qos_sels, base + 0xa880)); |
| 278 | clk_dm(IMX8MP_CLK_ENET_QOS_TIMER, imx8m_clk_composite("enet_qos_timer", imx8mp_enet_qos_timer_sels, base + 0xa900)); |
Ye Li | ee9c213 | 2020-04-21 20:19:24 -0700 | [diff] [blame] | 279 | clk_dm(IMX8MP_CLK_ENET_REF, imx8m_clk_composite("enet_ref", imx8mp_enet_ref_sels, base + 0xa980)); |
| 280 | clk_dm(IMX8MP_CLK_ENET_TIMER, imx8m_clk_composite("enet_timer", imx8mp_enet_timer_sels, base + 0xaa00)); |
| 281 | clk_dm(IMX8MP_CLK_ENET_PHY_REF, imx8m_clk_composite("enet_phy_ref", imx8mp_enet_phy_ref_sels, base + 0xaa80)); |
| 282 | clk_dm(IMX8MP_CLK_QSPI, imx8m_clk_composite("qspi", imx8mp_qspi_sels, base + 0xab80)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 283 | clk_dm(IMX8MP_CLK_USDHC1, imx8m_clk_composite("usdhc1", imx8mp_usdhc1_sels, base + 0xac00)); |
| 284 | clk_dm(IMX8MP_CLK_USDHC2, imx8m_clk_composite("usdhc2", imx8mp_usdhc2_sels, base + 0xac80)); |
| 285 | clk_dm(IMX8MP_CLK_I2C1, imx8m_clk_composite("i2c1", imx8mp_i2c1_sels, base + 0xad00)); |
| 286 | clk_dm(IMX8MP_CLK_I2C2, imx8m_clk_composite("i2c2", imx8mp_i2c2_sels, base + 0xad80)); |
| 287 | clk_dm(IMX8MP_CLK_I2C3, imx8m_clk_composite("i2c3", imx8mp_i2c3_sels, base + 0xae00)); |
| 288 | clk_dm(IMX8MP_CLK_I2C4, imx8m_clk_composite("i2c4", imx8mp_i2c4_sels, base + 0xae80)); |
| 289 | |
| 290 | clk_dm(IMX8MP_CLK_UART1, imx8m_clk_composite("uart1", imx8mp_uart1_sels, base + 0xaf00)); |
| 291 | clk_dm(IMX8MP_CLK_UART2, imx8m_clk_composite("uart2", imx8mp_uart2_sels, base + 0xaf80)); |
| 292 | clk_dm(IMX8MP_CLK_UART3, imx8m_clk_composite("uart3", imx8mp_uart3_sels, base + 0xb000)); |
| 293 | clk_dm(IMX8MP_CLK_UART4, imx8m_clk_composite("uart4", imx8mp_uart4_sels, base + 0xb080)); |
Marek Vasut | 55452b6 | 2022-04-01 03:17:29 +0200 | [diff] [blame] | 294 | clk_dm(IMX8MP_CLK_USB_CORE_REF, imx8m_clk_composite("usb_core_ref", imx8mp_usb_core_ref_sels, base + 0xb100)); |
| 295 | clk_dm(IMX8MP_CLK_USB_PHY_REF, imx8m_clk_composite("usb_phy_ref", imx8mp_usb_phy_ref_sels, base + 0xb180)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 296 | clk_dm(IMX8MP_CLK_GIC, imx8m_clk_composite_critical("gic", imx8mp_gic_sels, base + 0xb200)); |
Elmar Albert | 81528d1 | 2022-04-06 13:39:50 +0200 | [diff] [blame] | 297 | clk_dm(IMX8MP_CLK_ECSPI1, imx8m_clk_composite("ecspi1", imx8mp_ecspi1_sels, base + 0xb280)); |
| 298 | clk_dm(IMX8MP_CLK_ECSPI2, imx8m_clk_composite("ecspi2", imx8mp_ecspi2_sels, base + 0xb300)); |
Tommaso Merciai | d65085a | 2023-03-10 16:24:24 +0100 | [diff] [blame] | 299 | clk_dm(IMX8MP_CLK_PWM1, imx8m_clk_composite_critical("pwm1", imx8mp_pwm1_sels, base + 0xb380)); |
| 300 | clk_dm(IMX8MP_CLK_PWM2, imx8m_clk_composite_critical("pwm2", imx8mp_pwm2_sels, base + 0xb400)); |
| 301 | clk_dm(IMX8MP_CLK_PWM3, imx8m_clk_composite_critical("pwm3", imx8mp_pwm3_sels, base + 0xb480)); |
| 302 | clk_dm(IMX8MP_CLK_PWM4, imx8m_clk_composite_critical("pwm4", imx8mp_pwm4_sels, base + 0xb500)); |
Elmar Albert | 81528d1 | 2022-04-06 13:39:50 +0200 | [diff] [blame] | 303 | clk_dm(IMX8MP_CLK_ECSPI3, imx8m_clk_composite("ecspi3", imx8mp_ecspi3_sels, base + 0xc180)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 304 | |
| 305 | clk_dm(IMX8MP_CLK_WDOG, imx8m_clk_composite("wdog", imx8mp_wdog_sels, base + 0xb900)); |
| 306 | clk_dm(IMX8MP_CLK_USDHC3, imx8m_clk_composite("usdhc3", imx8mp_usdhc3_sels, base + 0xbc80)); |
| 307 | |
| 308 | clk_dm(IMX8MP_CLK_DRAM_ALT_ROOT, imx_clk_fixed_factor("dram_alt_root", "dram_alt", 1, 4)); |
| 309 | clk_dm(IMX8MP_CLK_DRAM_CORE, imx_clk_mux2_flags("dram_core_clk", base + 0x9800, 24, 1, imx8mp_dram_core_sels, ARRAY_SIZE(imx8mp_dram_core_sels), CLK_IS_CRITICAL)); |
| 310 | |
| 311 | clk_dm(IMX8MP_CLK_DRAM1_ROOT, imx_clk_gate4_flags("dram1_root_clk", "dram_core_clk", base + 0x4050, 0, CLK_IS_CRITICAL)); |
Elmar Albert | 81528d1 | 2022-04-06 13:39:50 +0200 | [diff] [blame] | 312 | clk_dm(IMX8MP_CLK_ECSPI1_ROOT, imx_clk_gate4("ecspi1_root_clk", "ecspi1", base + 0x4070, 0)); |
| 313 | clk_dm(IMX8MP_CLK_ECSPI2_ROOT, imx_clk_gate4("ecspi2_root_clk", "ecspi2", base + 0x4080, 0)); |
| 314 | clk_dm(IMX8MP_CLK_ECSPI3_ROOT, imx_clk_gate4("ecspi3_root_clk", "ecspi3", base + 0x4090, 0)); |
Ye Li | ee9c213 | 2020-04-21 20:19:24 -0700 | [diff] [blame] | 315 | clk_dm(IMX8MP_CLK_ENET1_ROOT, imx_clk_gate4("enet1_root_clk", "enet_axi", base + 0x40a0, 0)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 316 | clk_dm(IMX8MP_CLK_GPIO1_ROOT, imx_clk_gate4("gpio1_root_clk", "ipg_root", base + 0x40b0, 0)); |
| 317 | clk_dm(IMX8MP_CLK_GPIO2_ROOT, imx_clk_gate4("gpio2_root_clk", "ipg_root", base + 0x40c0, 0)); |
| 318 | clk_dm(IMX8MP_CLK_GPIO3_ROOT, imx_clk_gate4("gpio3_root_clk", "ipg_root", base + 0x40d0, 0)); |
| 319 | clk_dm(IMX8MP_CLK_GPIO4_ROOT, imx_clk_gate4("gpio4_root_clk", "ipg_root", base + 0x40e0, 0)); |
| 320 | clk_dm(IMX8MP_CLK_GPIO5_ROOT, imx_clk_gate4("gpio5_root_clk", "ipg_root", base + 0x40f0, 0)); |
| 321 | clk_dm(IMX8MP_CLK_I2C1_ROOT, imx_clk_gate4("i2c1_root_clk", "i2c1", base + 0x4170, 0)); |
| 322 | clk_dm(IMX8MP_CLK_I2C2_ROOT, imx_clk_gate4("i2c2_root_clk", "i2c2", base + 0x4180, 0)); |
| 323 | clk_dm(IMX8MP_CLK_I2C3_ROOT, imx_clk_gate4("i2c3_root_clk", "i2c3", base + 0x4190, 0)); |
| 324 | clk_dm(IMX8MP_CLK_I2C4_ROOT, imx_clk_gate4("i2c4_root_clk", "i2c4", base + 0x41a0, 0)); |
Tommaso Merciai | d65085a | 2023-03-10 16:24:24 +0100 | [diff] [blame] | 325 | clk_dm(IMX8MP_CLK_PWM1_ROOT, imx_clk_gate4("pwm1_root_clk", "pwm1", base + 0x4280, 0)); |
| 326 | clk_dm(IMX8MP_CLK_PWM2_ROOT, imx_clk_gate4("pwm2_root_clk", "pwm2", base + 0x4290, 0)); |
| 327 | clk_dm(IMX8MP_CLK_PWM3_ROOT, imx_clk_gate4("pwm3_root_clk", "pwm3", base + 0x42a0, 0)); |
| 328 | clk_dm(IMX8MP_CLK_PWM4_ROOT, imx_clk_gate4("pwm4_root_clk", "pwm4", base + 0x42b0, 0)); |
Marek Vasut | d4e448d | 2023-03-06 15:53:41 +0100 | [diff] [blame] | 329 | clk_dm(IMX8MP_CLK_QOS_ROOT, imx_clk_gate4("qos_root_clk", "ipg_root", base + 0x42c0, 0)); |
| 330 | clk_dm(IMX8MP_CLK_QOS_ENET_ROOT, imx_clk_gate4("qos_enet_root_clk", "ipg_root", base + 0x42e0, 0)); |
Ye Li | ee9c213 | 2020-04-21 20:19:24 -0700 | [diff] [blame] | 331 | clk_dm(IMX8MP_CLK_QSPI_ROOT, imx_clk_gate4("qspi_root_clk", "qspi", base + 0x42f0, 0)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 332 | clk_dm(IMX8MP_CLK_I2C5_ROOT, imx_clk_gate2("i2c5_root_clk", "i2c5", base + 0x4330, 0)); |
| 333 | clk_dm(IMX8MP_CLK_I2C6_ROOT, imx_clk_gate2("i2c6_root_clk", "i2c6", base + 0x4340, 0)); |
Ye Li | ee9c213 | 2020-04-21 20:19:24 -0700 | [diff] [blame] | 334 | clk_dm(IMX8MP_CLK_SIM_ENET_ROOT, imx_clk_gate4("sim_enet_root_clk", "enet_axi", base + 0x4400, 0)); |
Marek Vasut | d4e448d | 2023-03-06 15:53:41 +0100 | [diff] [blame] | 335 | clk_dm(IMX8MP_CLK_ENET_QOS_ROOT, imx_clk_gate4("enet_qos_root_clk", "sim_enet_root_clk", base + 0x43b0, 0)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 336 | clk_dm(IMX8MP_CLK_UART1_ROOT, imx_clk_gate4("uart1_root_clk", "uart1", base + 0x4490, 0)); |
| 337 | clk_dm(IMX8MP_CLK_UART2_ROOT, imx_clk_gate4("uart2_root_clk", "uart2", base + 0x44a0, 0)); |
| 338 | clk_dm(IMX8MP_CLK_UART3_ROOT, imx_clk_gate4("uart3_root_clk", "uart3", base + 0x44b0, 0)); |
| 339 | clk_dm(IMX8MP_CLK_UART4_ROOT, imx_clk_gate4("uart4_root_clk", "uart4", base + 0x44c0, 0)); |
Andrey Zhizhikin | b1452ea | 2022-06-03 17:15:22 +0200 | [diff] [blame] | 340 | clk_dm(IMX8MP_CLK_USB_ROOT, imx_clk_gate4("usb_root_clk", "usb_core_ref", base + 0x44d0, 0)); |
Marek Vasut | 55452b6 | 2022-04-01 03:17:29 +0200 | [diff] [blame] | 341 | clk_dm(IMX8MP_CLK_USB_PHY_ROOT, imx_clk_gate4("usb_phy_root_clk", "usb_phy_ref", base + 0x44f0, 0)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 342 | clk_dm(IMX8MP_CLK_USDHC1_ROOT, imx_clk_gate4("usdhc1_root_clk", "usdhc1", base + 0x4510, 0)); |
| 343 | clk_dm(IMX8MP_CLK_USDHC2_ROOT, imx_clk_gate4("usdhc2_root_clk", "usdhc2", base + 0x4520, 0)); |
| 344 | clk_dm(IMX8MP_CLK_WDOG1_ROOT, imx_clk_gate4("wdog1_root_clk", "wdog", base + 0x4530, 0)); |
| 345 | clk_dm(IMX8MP_CLK_WDOG2_ROOT, imx_clk_gate4("wdog2_root_clk", "wdog", base + 0x4540, 0)); |
| 346 | clk_dm(IMX8MP_CLK_WDOG3_ROOT, imx_clk_gate4("wdog3_root_clk", "wdog", base + 0x4550, 0)); |
Marek Vasut | 55452b6 | 2022-04-01 03:17:29 +0200 | [diff] [blame] | 347 | clk_dm(IMX8MP_CLK_HSIO_ROOT, imx_clk_gate4("hsio_root_clk", "ipg_root", base + 0x45c0, 0)); |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 348 | |
| 349 | clk_dm(IMX8MP_CLK_USDHC3_ROOT, imx_clk_gate4("usdhc3_root_clk", "usdhc3", base + 0x45e0, 0)); |
| 350 | |
| 351 | return 0; |
| 352 | } |
| 353 | |
| 354 | static const struct udevice_id imx8mp_clk_ids[] = { |
| 355 | { .compatible = "fsl,imx8mp-ccm" }, |
| 356 | { }, |
| 357 | }; |
| 358 | |
| 359 | U_BOOT_DRIVER(imx8mp_clk) = { |
| 360 | .name = "clk_imx8mp", |
| 361 | .id = UCLASS_CLK, |
| 362 | .of_match = imx8mp_clk_ids, |
Sean Anderson | 35c8464 | 2022-03-20 16:34:46 -0400 | [diff] [blame] | 363 | .ops = &ccf_clk_ops, |
Peng Fan | 3fe8c8d | 2019-12-30 17:39:18 +0800 | [diff] [blame] | 364 | .probe = imx8mp_clk_probe, |
| 365 | .flags = DM_FLAG_PRE_RELOC, |
| 366 | }; |