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