Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Peng Fan | 88057bc | 2018-01-10 13:20:22 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2017 NXP |
| 4 | * |
| 5 | * Peng Fan <peng.fan@nxp.com> |
Peng Fan | 88057bc | 2018-01-10 13:20:22 +0800 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <asm/arch/clock.h> |
| 10 | #include <asm/arch/imx-regs.h> |
| 11 | #include <asm/io.h> |
| 12 | #include <errno.h> |
| 13 | |
Peng Fan | 88057bc | 2018-01-10 13:20:22 +0800 | [diff] [blame] | 14 | static struct ccm_reg *ccm_reg = (struct ccm_reg *)CCM_BASE_ADDR; |
| 15 | |
Peng Fan | 9987846 | 2019-08-27 06:25:51 +0000 | [diff] [blame] | 16 | #ifdef CONFIG_IMX8MQ |
Peng Fan | 88057bc | 2018-01-10 13:20:22 +0800 | [diff] [blame] | 17 | static struct clk_root_map root_array[] = { |
| 18 | {ARM_A53_CLK_ROOT, CORE_CLOCK_SLICE, 0, |
| 19 | {OSC_25M_CLK, ARM_PLL_CLK, SYSTEM_PLL2_500M_CLK, |
| 20 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL1_800M_CLK, |
| 21 | SYSTEM_PLL1_400M_CLK, AUDIO_PLL1_CLK, SYSTEM_PLL3_CLK} |
| 22 | }, |
| 23 | {ARM_M4_CLK_ROOT, CORE_CLOCK_SLICE, 1, |
| 24 | {OSC_25M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL2_250M_CLK, |
| 25 | SYSTEM_PLL1_266M_CLK, SYSTEM_PLL1_800M_CLK, |
| 26 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, SYSTEM_PLL3_CLK} |
| 27 | }, |
| 28 | {VPU_A53_CLK_ROOT, CORE_CLOCK_SLICE, 2, |
| 29 | {OSC_25M_CLK, ARM_PLL_CLK, SYSTEM_PLL2_500M_CLK, |
| 30 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL1_800M_CLK, |
| 31 | SYSTEM_PLL1_400M_CLK, AUDIO_PLL1_CLK, VPU_PLL_CLK} |
| 32 | }, |
| 33 | {GPU_CORE_CLK_ROOT, CORE_CLOCK_SLICE, 3, |
| 34 | {OSC_25M_CLK, GPU_PLL_CLK, SYSTEM_PLL1_800M_CLK, |
| 35 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_1000M_CLK, |
| 36 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, AUDIO_PLL2_CLK} |
| 37 | }, |
| 38 | {GPU_SHADER_CLK_ROOT, CORE_CLOCK_SLICE, 4, |
| 39 | {OSC_25M_CLK, GPU_PLL_CLK, SYSTEM_PLL1_800M_CLK, |
| 40 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_1000M_CLK, |
| 41 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, AUDIO_PLL2_CLK} |
| 42 | }, |
| 43 | {MAIN_AXI_CLK_ROOT, BUS_CLOCK_SLICE, 0, |
| 44 | {OSC_25M_CLK, SYSTEM_PLL2_333M_CLK, SYSTEM_PLL1_800M_CLK, |
| 45 | SYSTEM_PLL2_250M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 46 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, SYSTEM_PLL1_100M_CLK} |
| 47 | }, |
| 48 | {ENET_AXI_CLK_ROOT, BUS_CLOCK_SLICE, 1, |
| 49 | {OSC_25M_CLK, SYSTEM_PLL1_266M_CLK, SYSTEM_PLL1_800M_CLK, |
| 50 | SYSTEM_PLL2_250M_CLK, SYSTEM_PLL2_200M_CLK, |
| 51 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, SYSTEM_PLL3_CLK} |
| 52 | }, |
| 53 | {NAND_USDHC_BUS_CLK_ROOT, BUS_CLOCK_SLICE, 2, |
| 54 | {OSC_25M_CLK, SYSTEM_PLL1_266M_CLK, SYSTEM_PLL1_800M_CLK, |
| 55 | SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_133M_CLK, |
| 56 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_250M_CLK, AUDIO_PLL1_CLK} |
| 57 | }, |
| 58 | {VPU_BUS_CLK_ROOT, BUS_CLOCK_SLICE, 3, |
| 59 | {OSC_25M_CLK, SYSTEM_PLL1_800M_CLK, VPU_PLL_CLK, |
| 60 | AUDIO_PLL2_CLK, SYSTEM_PLL3_CLK, SYSTEM_PLL2_1000M_CLK, |
| 61 | SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_100M_CLK} |
| 62 | }, |
| 63 | {DISPLAY_AXI_CLK_ROOT, BUS_CLOCK_SLICE, 4, |
| 64 | {OSC_25M_CLK, SYSTEM_PLL2_125M_CLK, SYSTEM_PLL1_800M_CLK, |
| 65 | SYSTEM_PLL3_CLK, SYSTEM_PLL1_400M_CLK, AUDIO_PLL2_CLK, |
| 66 | EXT_CLK_1, EXT_CLK_4} |
| 67 | }, |
| 68 | {DISPLAY_APB_CLK_ROOT, BUS_CLOCK_SLICE, 5, |
| 69 | {OSC_25M_CLK, SYSTEM_PLL2_125M_CLK, SYSTEM_PLL1_800M_CLK, |
| 70 | SYSTEM_PLL3_CLK, SYSTEM_PLL1_400M_CLK, AUDIO_PLL2_CLK, |
| 71 | EXT_CLK_1, EXT_CLK_3} |
| 72 | }, |
| 73 | {DISPLAY_RTRM_CLK_ROOT, BUS_CLOCK_SLICE, 6, |
| 74 | {OSC_25M_CLK, SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_200M_CLK, |
| 75 | SYSTEM_PLL1_400M_CLK, AUDIO_PLL1_CLK, VIDEO_PLL_CLK, |
| 76 | EXT_CLK_2, EXT_CLK_3} |
| 77 | }, |
| 78 | {USB_BUS_CLK_ROOT, BUS_CLOCK_SLICE, 7, |
| 79 | {OSC_25M_CLK, SYSTEM_PLL2_500M_CLK, SYSTEM_PLL1_800M_CLK, |
| 80 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL2_200M_CLK, |
| 81 | EXT_CLK_2, EXT_CLK_4, AUDIO_PLL2_CLK} |
| 82 | }, |
| 83 | {GPU_AXI_CLK_ROOT, BUS_CLOCK_SLICE, 8, |
| 84 | {OSC_25M_CLK, SYSTEM_PLL1_800M_CLK, GPU_PLL_CLK, |
| 85 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_1000M_CLK, |
| 86 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, AUDIO_PLL2_CLK} |
| 87 | }, |
| 88 | {GPU_AHB_CLK_ROOT, BUS_CLOCK_SLICE, 9, |
| 89 | {OSC_25M_CLK, SYSTEM_PLL1_800M_CLK, GPU_PLL_CLK, |
| 90 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_1000M_CLK, |
| 91 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, AUDIO_PLL2_CLK} |
| 92 | }, |
| 93 | {NOC_CLK_ROOT, BUS_CLOCK_SLICE, 10, |
| 94 | {OSC_25M_CLK, SYSTEM_PLL1_800M_CLK, SYSTEM_PLL3_CLK, |
| 95 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL2_500M_CLK, |
| 96 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, AUDIO_PLL2_CLK} |
| 97 | }, |
| 98 | {NOC_APB_CLK_ROOT, BUS_CLOCK_SLICE, 11, |
| 99 | {OSC_25M_CLK, SYSTEM_PLL1_400M_CLK, SYSTEM_PLL3_CLK, |
| 100 | SYSTEM_PLL2_333M_CLK, SYSTEM_PLL2_200M_CLK, |
| 101 | SYSTEM_PLL1_800M_CLK, AUDIO_PLL1_CLK, VIDEO_PLL_CLK} |
| 102 | }, |
| 103 | {AHB_CLK_ROOT, AHB_CLOCK_SLICE, 0, |
| 104 | {OSC_25M_CLK, SYSTEM_PLL1_133M_CLK, SYSTEM_PLL1_800M_CLK, |
| 105 | SYSTEM_PLL1_400M_CLK, SYSTEM_PLL2_125M_CLK, |
| 106 | SYSTEM_PLL3_CLK, AUDIO_PLL1_CLK, VIDEO_PLL_CLK} |
| 107 | }, |
| 108 | {IPG_CLK_ROOT, IPG_CLOCK_SLICE, 0, |
| 109 | {} |
| 110 | }, |
| 111 | {AUDIO_AHB_CLK_ROOT, AHB_CLOCK_SLICE, 1, |
| 112 | {OSC_25M_CLK, SYSTEM_PLL2_500M_CLK, SYSTEM_PLL1_800M_CLK, |
| 113 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL2_166M_CLK, |
| 114 | SYSTEM_PLL3_CLK, AUDIO_PLL1_CLK, VIDEO_PLL_CLK} |
| 115 | }, |
| 116 | {MIPI_DSI_ESC_RX_CLK_ROOT, AHB_CLOCK_SLICE, 2, |
| 117 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_40M_CLK, |
| 118 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 119 | SYSTEM_PLL3_CLK, EXT_CLK_3, AUDIO_PLL1_CLK }, |
| 120 | }, |
| 121 | {DRAM_ALT_CLK_ROOT, IP_CLOCK_SLICE, 0, |
| 122 | {OSC_25M_CLK, SYSTEM_PLL1_800M_CLK, SYSTEM_PLL1_100M_CLK, |
| 123 | SYSTEM_PLL2_500M_CLK, SYSTEM_PLL2_250M_CLK, |
| 124 | SYSTEM_PLL1_400M_CLK, AUDIO_PLL1_CLK, SYSTEM_PLL1_266M_CLK} |
| 125 | }, |
| 126 | {DRAM_APB_CLK_ROOT, IP_CLOCK_SLICE, 1, |
| 127 | {OSC_25M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_40M_CLK, |
| 128 | SYSTEM_PLL1_160M_CLK, SYSTEM_PLL1_800M_CLK, |
| 129 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_250M_CLK, AUDIO_PLL2_CLK} |
| 130 | }, |
| 131 | {VPU_G1_CLK_ROOT, IP_CLOCK_SLICE, 2, |
| 132 | {OSC_25M_CLK, VPU_PLL_CLK, SYSTEM_PLL1_800M_CLK, |
| 133 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL1_100M_CLK, |
| 134 | SYSTEM_PLL2_125M_CLK, SYSTEM_PLL3_CLK, AUDIO_PLL1_CLK} |
| 135 | }, |
| 136 | {VPU_G2_CLK_ROOT, IP_CLOCK_SLICE, 3, |
| 137 | {OSC_25M_CLK, VPU_PLL_CLK, SYSTEM_PLL1_800M_CLK, |
| 138 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL1_100M_CLK, |
| 139 | SYSTEM_PLL2_125M_CLK, SYSTEM_PLL3_CLK, AUDIO_PLL1_CLK} |
| 140 | }, |
| 141 | {DISPLAY_DTRC_CLK_ROOT, IP_CLOCK_SLICE, 4, |
| 142 | {OSC_25M_CLK, VPU_PLL_CLK, SYSTEM_PLL1_800M_CLK, |
| 143 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL1_160M_CLK, |
| 144 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL3_CLK, AUDIO_PLL2_CLK} |
| 145 | }, |
| 146 | {DISPLAY_DC8000_CLK_ROOT, IP_CLOCK_SLICE, 5, |
| 147 | {OSC_25M_CLK, VPU_PLL_CLK, SYSTEM_PLL1_800M_CLK, |
| 148 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL1_160M_CLK, |
| 149 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL3_CLK, AUDIO_PLL2_CLK} |
| 150 | }, |
| 151 | {PCIE1_CTRL_CLK_ROOT, IP_CLOCK_SLICE, 6, |
| 152 | {OSC_25M_CLK, SYSTEM_PLL2_250M_CLK, SYSTEM_PLL2_200M_CLK, |
| 153 | SYSTEM_PLL1_266M_CLK, SYSTEM_PLL1_800M_CLK, |
| 154 | SYSTEM_PLL2_500M_CLK, SYSTEM_PLL2_333M_CLK, SYSTEM_PLL3_CLK} |
| 155 | }, |
| 156 | {PCIE1_PHY_CLK_ROOT, IP_CLOCK_SLICE, 7, |
| 157 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL2_500M_CLK, |
| 158 | EXT_CLK_1, EXT_CLK_2, EXT_CLK_3, EXT_CLK_4, |
| 159 | SYSTEM_PLL1_400M_CLK} |
| 160 | }, |
| 161 | {PCIE1_AUX_CLK_ROOT, IP_CLOCK_SLICE, 8, |
| 162 | {OSC_25M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL2_50M_CLK, |
| 163 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_80M_CLK, |
| 164 | SYSTEM_PLL1_160M_CLK, SYSTEM_PLL1_200M_CLK} |
| 165 | }, |
| 166 | {DC_PIXEL_CLK_ROOT, IP_CLOCK_SLICE, 9, |
| 167 | {OSC_25M_CLK, VIDEO_PLL_CLK, AUDIO_PLL2_CLK, |
| 168 | AUDIO_PLL1_CLK, SYSTEM_PLL1_800M_CLK, |
| 169 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL3_CLK, EXT_CLK_4} |
| 170 | }, |
| 171 | {LCDIF_PIXEL_CLK_ROOT, IP_CLOCK_SLICE, 10, |
| 172 | {OSC_25M_CLK, VIDEO_PLL_CLK, AUDIO_PLL2_CLK, |
| 173 | AUDIO_PLL1_CLK, SYSTEM_PLL1_800M_CLK, |
| 174 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL3_CLK, EXT_CLK_4} |
| 175 | }, |
| 176 | {SAI1_CLK_ROOT, IP_CLOCK_SLICE, 11, |
| 177 | {OSC_25M_CLK, AUDIO_PLL1_CLK, AUDIO_PLL2_CLK, |
| 178 | VIDEO_PLL_CLK, SYSTEM_PLL1_133M_CLK, |
| 179 | OSC_27M_CLK, EXT_CLK_1, EXT_CLK_2} |
| 180 | }, |
| 181 | {SAI2_CLK_ROOT, IP_CLOCK_SLICE, 12, |
| 182 | {OSC_25M_CLK, AUDIO_PLL1_CLK, AUDIO_PLL2_CLK, |
| 183 | VIDEO_PLL_CLK, SYSTEM_PLL1_133M_CLK, |
| 184 | OSC_27M_CLK, EXT_CLK_2, EXT_CLK_3} |
| 185 | }, |
| 186 | {SAI3_CLK_ROOT, IP_CLOCK_SLICE, 13, |
| 187 | {OSC_25M_CLK, AUDIO_PLL1_CLK, AUDIO_PLL2_CLK, |
| 188 | VIDEO_PLL_CLK, SYSTEM_PLL1_133M_CLK, |
| 189 | OSC_27M_CLK, EXT_CLK_3, EXT_CLK_4} |
| 190 | }, |
| 191 | {SAI4_CLK_ROOT, IP_CLOCK_SLICE, 14, |
| 192 | {OSC_25M_CLK, AUDIO_PLL1_CLK, AUDIO_PLL2_CLK, |
| 193 | VIDEO_PLL_CLK, SYSTEM_PLL1_133M_CLK, |
| 194 | OSC_27M_CLK, EXT_CLK_1, EXT_CLK_2} |
| 195 | }, |
| 196 | {SAI5_CLK_ROOT, IP_CLOCK_SLICE, 15, |
| 197 | {OSC_25M_CLK, AUDIO_PLL1_CLK, AUDIO_PLL2_CLK, |
| 198 | VIDEO_PLL_CLK, SYSTEM_PLL1_133M_CLK, |
| 199 | OSC_27M_CLK, EXT_CLK_2, EXT_CLK_3} |
| 200 | }, |
| 201 | {SAI6_CLK_ROOT, IP_CLOCK_SLICE, 16, |
| 202 | {OSC_25M_CLK, AUDIO_PLL1_CLK, AUDIO_PLL2_CLK, |
| 203 | VIDEO_PLL_CLK, SYSTEM_PLL1_133M_CLK, |
| 204 | OSC_27M_CLK, EXT_CLK_3, EXT_CLK_4} |
| 205 | }, |
| 206 | {SPDIF1_CLK_ROOT, IP_CLOCK_SLICE, 17, |
| 207 | {OSC_25M_CLK, AUDIO_PLL1_CLK, AUDIO_PLL2_CLK, |
| 208 | VIDEO_PLL_CLK, SYSTEM_PLL1_133M_CLK, |
| 209 | OSC_27M_CLK, EXT_CLK_2, EXT_CLK_3} |
| 210 | }, |
| 211 | {SPDIF2_CLK_ROOT, IP_CLOCK_SLICE, 18, |
| 212 | {OSC_25M_CLK, AUDIO_PLL1_CLK, AUDIO_PLL2_CLK, |
| 213 | VIDEO_PLL_CLK, SYSTEM_PLL1_133M_CLK, |
| 214 | OSC_27M_CLK, EXT_CLK_3, EXT_CLK_4} |
| 215 | }, |
| 216 | {ENET_REF_CLK_ROOT, IP_CLOCK_SLICE, 19, |
| 217 | {OSC_25M_CLK, SYSTEM_PLL2_125M_CLK, SYSTEM_PLL2_50M_CLK, |
| 218 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_160M_CLK, |
| 219 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, EXT_CLK_4} |
| 220 | }, |
| 221 | {ENET_TIMER_CLK_ROOT, IP_CLOCK_SLICE, 20, |
| 222 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, AUDIO_PLL1_CLK, |
| 223 | EXT_CLK_1, EXT_CLK_2, EXT_CLK_3, EXT_CLK_4, |
| 224 | VIDEO_PLL_CLK} |
| 225 | }, |
| 226 | {ENET_PHY_REF_CLK_ROOT, IP_CLOCK_SLICE, 21, |
| 227 | {OSC_25M_CLK, SYSTEM_PLL2_50M_CLK, SYSTEM_PLL2_125M_CLK, |
| 228 | SYSTEM_PLL2_200M_CLK, SYSTEM_PLL2_500M_CLK, |
| 229 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, AUDIO_PLL2_CLK} |
| 230 | }, |
| 231 | {NAND_CLK_ROOT, IP_CLOCK_SLICE, 22, |
| 232 | {OSC_25M_CLK, SYSTEM_PLL2_500M_CLK, AUDIO_PLL1_CLK, |
| 233 | SYSTEM_PLL1_400M_CLK, AUDIO_PLL2_CLK, SYSTEM_PLL3_CLK, |
| 234 | SYSTEM_PLL2_250M_CLK, VIDEO_PLL_CLK} |
| 235 | }, |
| 236 | {QSPI_CLK_ROOT, IP_CLOCK_SLICE, 23, |
| 237 | {OSC_25M_CLK, SYSTEM_PLL1_400M_CLK, SYSTEM_PLL1_800M_CLK, |
| 238 | SYSTEM_PLL2_500M_CLK, AUDIO_PLL2_CLK, |
| 239 | SYSTEM_PLL1_266M_CLK, SYSTEM_PLL3_CLK, SYSTEM_PLL1_100M_CLK} |
| 240 | }, |
| 241 | {USDHC1_CLK_ROOT, IP_CLOCK_SLICE, 24, |
| 242 | {OSC_25M_CLK, SYSTEM_PLL1_400M_CLK, SYSTEM_PLL1_800M_CLK, |
| 243 | SYSTEM_PLL2_500M_CLK, AUDIO_PLL2_CLK, |
| 244 | SYSTEM_PLL1_266M_CLK, SYSTEM_PLL3_CLK, SYSTEM_PLL1_100M_CLK} |
| 245 | }, |
| 246 | {USDHC2_CLK_ROOT, IP_CLOCK_SLICE, 25, |
| 247 | {OSC_25M_CLK, SYSTEM_PLL1_400M_CLK, SYSTEM_PLL1_800M_CLK, |
| 248 | SYSTEM_PLL2_500M_CLK, AUDIO_PLL2_CLK, |
| 249 | SYSTEM_PLL1_266M_CLK, SYSTEM_PLL3_CLK, SYSTEM_PLL1_100M_CLK} |
| 250 | }, |
| 251 | {I2C1_CLK_ROOT, IP_CLOCK_SLICE, 26, |
| 252 | {OSC_25M_CLK, SYSTEM_PLL1_160M_CLK, SYSTEM_PLL2_50M_CLK, |
| 253 | SYSTEM_PLL3_CLK, AUDIO_PLL1_CLK, VIDEO_PLL_CLK, |
| 254 | AUDIO_PLL2_CLK, SYSTEM_PLL1_133M_CLK} |
| 255 | }, |
| 256 | {I2C2_CLK_ROOT, IP_CLOCK_SLICE, 27, |
| 257 | {OSC_25M_CLK, SYSTEM_PLL1_160M_CLK, SYSTEM_PLL2_50M_CLK, |
| 258 | SYSTEM_PLL3_CLK, AUDIO_PLL1_CLK, VIDEO_PLL_CLK, |
| 259 | AUDIO_PLL2_CLK, SYSTEM_PLL1_133M_CLK} |
| 260 | }, |
| 261 | {I2C3_CLK_ROOT, IP_CLOCK_SLICE, 28, |
| 262 | {OSC_25M_CLK, SYSTEM_PLL1_160M_CLK, SYSTEM_PLL2_50M_CLK, |
| 263 | SYSTEM_PLL3_CLK, AUDIO_PLL1_CLK, VIDEO_PLL_CLK, |
| 264 | AUDIO_PLL2_CLK, SYSTEM_PLL1_133M_CLK} |
| 265 | }, |
| 266 | {I2C4_CLK_ROOT, IP_CLOCK_SLICE, 29, |
| 267 | {OSC_25M_CLK, SYSTEM_PLL1_160M_CLK, SYSTEM_PLL2_50M_CLK, |
| 268 | SYSTEM_PLL3_CLK, AUDIO_PLL1_CLK, VIDEO_PLL_CLK, |
| 269 | AUDIO_PLL2_CLK, SYSTEM_PLL1_133M_CLK} |
| 270 | }, |
| 271 | {UART1_CLK_ROOT, IP_CLOCK_SLICE, 30, |
| 272 | {OSC_25M_CLK, SYSTEM_PLL1_80M_CLK, SYSTEM_PLL2_200M_CLK, |
| 273 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL3_CLK, |
| 274 | EXT_CLK_2, EXT_CLK_4, AUDIO_PLL2_CLK} |
| 275 | }, |
| 276 | {UART2_CLK_ROOT, IP_CLOCK_SLICE, 31, |
| 277 | {OSC_25M_CLK, SYSTEM_PLL1_80M_CLK, SYSTEM_PLL2_200M_CLK, |
| 278 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL3_CLK, |
| 279 | EXT_CLK_2, EXT_CLK_3, AUDIO_PLL2_CLK} |
| 280 | }, |
| 281 | {UART3_CLK_ROOT, IP_CLOCK_SLICE, 32, |
| 282 | {OSC_25M_CLK, SYSTEM_PLL1_80M_CLK, SYSTEM_PLL2_200M_CLK, |
| 283 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL3_CLK, |
| 284 | EXT_CLK_2, EXT_CLK_4, AUDIO_PLL2_CLK} |
| 285 | }, |
| 286 | {UART4_CLK_ROOT, IP_CLOCK_SLICE, 33, |
| 287 | {OSC_25M_CLK, SYSTEM_PLL1_80M_CLK, SYSTEM_PLL2_200M_CLK, |
| 288 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL3_CLK, |
| 289 | EXT_CLK_2, EXT_CLK_3, AUDIO_PLL2_CLK} |
| 290 | }, |
| 291 | {USB_CORE_REF_CLK_ROOT, IP_CLOCK_SLICE, 34, |
| 292 | {OSC_25M_CLK, SYSTEM_PLL1_100M_CLK, SYSTEM_PLL1_40M_CLK, |
| 293 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL2_200M_CLK, |
| 294 | EXT_CLK_2, EXT_CLK_3, AUDIO_PLL2_CLK} |
| 295 | }, |
| 296 | {USB_PHY_REF_CLK_ROOT, IP_CLOCK_SLICE, 35, |
| 297 | {OSC_25M_CLK, SYSTEM_PLL1_100M_CLK, SYSTEM_PLL1_40M_CLK, |
| 298 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL2_200M_CLK, |
| 299 | EXT_CLK_2, EXT_CLK_3, AUDIO_PLL2_CLK} |
| 300 | }, |
| 301 | {GIC_CLK_ROOT, IP_CLOCK_SLICE, 36, |
| 302 | {OSC_25M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_40M_CLK, |
| 303 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_800M_CLK, |
| 304 | EXT_CLK_2, EXT_CLK_4, AUDIO_PLL2_CLK} |
| 305 | }, |
| 306 | {ECSPI1_CLK_ROOT, IP_CLOCK_SLICE, 37, |
| 307 | {OSC_25M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_40M_CLK, |
| 308 | SYSTEM_PLL1_160M_CLK, SYSTEM_PLL1_800M_CLK, |
| 309 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_250M_CLK, AUDIO_PLL2_CLK} |
| 310 | }, |
| 311 | {ECSPI2_CLK_ROOT, IP_CLOCK_SLICE, 38, |
| 312 | {OSC_25M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_40M_CLK, |
| 313 | SYSTEM_PLL1_160M_CLK, SYSTEM_PLL1_800M_CLK, |
| 314 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_250M_CLK, AUDIO_PLL2_CLK} |
| 315 | }, |
| 316 | {PWM1_CLK_ROOT, IP_CLOCK_SLICE, 39, |
| 317 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_160M_CLK, |
| 318 | SYSTEM_PLL1_40M_CLK, SYSTEM_PLL3_CLK, EXT_CLK_1, |
| 319 | SYSTEM_PLL1_80M_CLK, VIDEO_PLL_CLK} |
| 320 | }, |
| 321 | {PWM2_CLK_ROOT, IP_CLOCK_SLICE, 40, |
| 322 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_160M_CLK, |
| 323 | SYSTEM_PLL1_40M_CLK, SYSTEM_PLL3_CLK, EXT_CLK_1, |
| 324 | SYSTEM_PLL1_80M_CLK, VIDEO_PLL_CLK} |
| 325 | }, |
| 326 | {PWM3_CLK_ROOT, IP_CLOCK_SLICE, 41, |
| 327 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_160M_CLK, |
| 328 | SYSTEM_PLL1_40M_CLK, SYSTEM_PLL3_CLK, EXT_CLK_1, |
| 329 | SYSTEM_PLL1_80M_CLK, VIDEO_PLL_CLK} |
| 330 | }, |
| 331 | {PWM4_CLK_ROOT, IP_CLOCK_SLICE, 42, |
| 332 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_160M_CLK, |
| 333 | SYSTEM_PLL1_40M_CLK, SYSTEM_PLL3_CLK, EXT_CLK_1, |
| 334 | SYSTEM_PLL1_80M_CLK, VIDEO_PLL_CLK} |
| 335 | }, |
| 336 | {GPT1_CLK_ROOT, IP_CLOCK_SLICE, 43, |
| 337 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_400M_CLK, |
| 338 | SYSTEM_PLL1_40M_CLK, VIDEO_PLL_CLK, |
| 339 | SYSTEM_PLL1_80M_CLK, AUDIO_PLL1_CLK, EXT_CLK_1} |
| 340 | }, |
| 341 | {GPT2_CLK_ROOT, IP_CLOCK_SLICE, 44, |
| 342 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_400M_CLK, |
| 343 | SYSTEM_PLL1_40M_CLK, VIDEO_PLL_CLK, |
| 344 | SYSTEM_PLL1_80M_CLK, AUDIO_PLL1_CLK, EXT_CLK_2} |
| 345 | }, |
| 346 | {GPT3_CLK_ROOT, IP_CLOCK_SLICE, 45, |
| 347 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_400M_CLK, |
| 348 | SYSTEM_PLL1_40M_CLK, VIDEO_PLL_CLK, |
| 349 | SYSTEM_PLL1_80M_CLK, AUDIO_PLL1_CLK, EXT_CLK_3} |
| 350 | }, |
| 351 | {GPT4_CLK_ROOT, IP_CLOCK_SLICE, 46, |
| 352 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_400M_CLK, |
| 353 | SYSTEM_PLL1_40M_CLK, VIDEO_PLL_CLK, |
| 354 | SYSTEM_PLL1_80M_CLK, AUDIO_PLL1_CLK, EXT_CLK_1} |
| 355 | }, |
| 356 | {GPT5_CLK_ROOT, IP_CLOCK_SLICE, 47, |
| 357 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_400M_CLK, |
| 358 | SYSTEM_PLL1_40M_CLK, VIDEO_PLL_CLK, |
| 359 | SYSTEM_PLL1_80M_CLK, AUDIO_PLL1_CLK, EXT_CLK_2} |
| 360 | }, |
| 361 | {GPT6_CLK_ROOT, IP_CLOCK_SLICE, 48, |
| 362 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_400M_CLK, |
| 363 | SYSTEM_PLL1_40M_CLK, VIDEO_PLL_CLK, |
| 364 | SYSTEM_PLL1_80M_CLK, AUDIO_PLL1_CLK, EXT_CLK_3} |
| 365 | }, |
| 366 | {TRACE_CLK_ROOT, IP_CLOCK_SLICE, 49, |
| 367 | {OSC_25M_CLK, SYSTEM_PLL1_133M_CLK, SYSTEM_PLL1_160M_CLK, |
| 368 | VPU_PLL_CLK, SYSTEM_PLL2_125M_CLK, |
| 369 | SYSTEM_PLL3_CLK, EXT_CLK_1, EXT_CLK_3} |
| 370 | }, |
| 371 | {WDOG_CLK_ROOT, IP_CLOCK_SLICE, 50, |
| 372 | {OSC_25M_CLK, SYSTEM_PLL1_133M_CLK, SYSTEM_PLL1_160M_CLK, |
| 373 | VPU_PLL_CLK, SYSTEM_PLL2_125M_CLK, |
| 374 | SYSTEM_PLL3_CLK, SYSTEM_PLL1_80M_CLK, SYSTEM_PLL2_166M_CLK} |
| 375 | }, |
| 376 | {WRCLK_CLK_ROOT, IP_CLOCK_SLICE, 51, |
| 377 | {OSC_25M_CLK, SYSTEM_PLL1_40M_CLK, VPU_PLL_CLK, |
| 378 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_200M_CLK, |
| 379 | SYSTEM_PLL1_266M_CLK, SYSTEM_PLL2_500M_CLK, SYSTEM_PLL1_100M_CLK} |
| 380 | }, |
| 381 | {IPP_DO_CLKO1, IP_CLOCK_SLICE, 52, |
| 382 | {OSC_25M_CLK, SYSTEM_PLL1_800M_CLK, OSC_27M_CLK, |
| 383 | SYSTEM_PLL1_200M_CLK, AUDIO_PLL2_CLK, |
| 384 | SYSTEM_PLL2_500M_CLK, VPU_PLL_CLK, SYSTEM_PLL1_80M_CLK} |
| 385 | }, |
| 386 | {IPP_DO_CLKO2, IP_CLOCK_SLICE, 53, |
| 387 | {OSC_25M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_400M_CLK, |
| 388 | SYSTEM_PLL2_166M_CLK, SYSTEM_PLL3_CLK, |
| 389 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, OSC_32K_CLK} |
| 390 | }, |
| 391 | {MIPI_DSI_CORE_CLK_ROOT, IP_CLOCK_SLICE, 54, |
| 392 | {OSC_25M_CLK, SYSTEM_PLL1_266M_CLK, SYSTEM_PLL2_250M_CLK, |
| 393 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 394 | SYSTEM_PLL3_CLK, AUDIO_PLL2_CLK, VIDEO_PLL_CLK} |
| 395 | }, |
| 396 | {MIPI_DSI_PHY_REF_CLK_ROOT, IP_CLOCK_SLICE, 55, |
| 397 | {OSC_25M_CLK, SYSTEM_PLL2_125M_CLK, SYSTEM_PLL2_100M_CLK, |
| 398 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 399 | EXT_CLK_2, AUDIO_PLL2_CLK, VIDEO_PLL_CLK} |
| 400 | }, |
| 401 | {MIPI_DSI_DBI_CLK_ROOT, IP_CLOCK_SLICE, 56, |
| 402 | {OSC_25M_CLK, SYSTEM_PLL1_266M_CLK, SYSTEM_PLL2_100M_CLK, |
| 403 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 404 | SYSTEM_PLL3_CLK, AUDIO_PLL2_CLK, VIDEO_PLL_CLK} |
| 405 | }, |
| 406 | {OLD_MIPI_DSI_ESC_CLK_ROOT, IP_CLOCK_SLICE, 57, |
| 407 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_80M_CLK, |
| 408 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 409 | SYSTEM_PLL3_CLK, EXT_CLK_3, AUDIO_PLL2_CLK} |
| 410 | }, |
| 411 | {MIPI_CSI1_CORE_CLK_ROOT, IP_CLOCK_SLICE, 58, |
| 412 | {OSC_25M_CLK, SYSTEM_PLL1_266M_CLK, SYSTEM_PLL2_250M_CLK, |
| 413 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 414 | SYSTEM_PLL3_CLK, AUDIO_PLL2_CLK, VIDEO_PLL_CLK} |
| 415 | }, |
| 416 | {MIPI_CSI1_PHY_REF_CLK_ROOT, IP_CLOCK_SLICE, 59, |
| 417 | {OSC_25M_CLK, SYSTEM_PLL2_125M_CLK, SYSTEM_PLL2_100M_CLK, |
| 418 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 419 | EXT_CLK_2, AUDIO_PLL2_CLK, VIDEO_PLL_CLK} |
| 420 | }, |
| 421 | {MIPI_CSI1_ESC_CLK_ROOT, IP_CLOCK_SLICE, 60, |
| 422 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_80M_CLK, |
| 423 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 424 | SYSTEM_PLL3_CLK, EXT_CLK_3, AUDIO_PLL2_CLK} |
| 425 | }, |
| 426 | {MIPI_CSI2_CORE_CLK_ROOT, IP_CLOCK_SLICE, 61, |
| 427 | {OSC_25M_CLK, SYSTEM_PLL1_266M_CLK, SYSTEM_PLL2_250M_CLK, |
| 428 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 429 | SYSTEM_PLL3_CLK, AUDIO_PLL2_CLK, VIDEO_PLL_CLK} |
| 430 | }, |
| 431 | {MIPI_CSI2_PHY_REF_CLK_ROOT, IP_CLOCK_SLICE, 62, |
| 432 | {OSC_25M_CLK, SYSTEM_PLL2_125M_CLK, SYSTEM_PLL2_100M_CLK, |
| 433 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 434 | EXT_CLK_2, AUDIO_PLL2_CLK, VIDEO_PLL_CLK} |
| 435 | }, |
| 436 | {MIPI_CSI2_ESC_CLK_ROOT, IP_CLOCK_SLICE, 63, |
| 437 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_80M_CLK, |
| 438 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 439 | SYSTEM_PLL3_CLK, EXT_CLK_3, AUDIO_PLL2_CLK} |
| 440 | }, |
| 441 | {PCIE2_CTRL_CLK_ROOT, IP_CLOCK_SLICE, 64, |
| 442 | {OSC_25M_CLK, SYSTEM_PLL2_250M_CLK, SYSTEM_PLL2_200M_CLK, |
| 443 | SYSTEM_PLL1_266M_CLK, SYSTEM_PLL1_800M_CLK, |
| 444 | SYSTEM_PLL2_500M_CLK, SYSTEM_PLL2_333M_CLK, SYSTEM_PLL3_CLK} |
| 445 | }, |
| 446 | {PCIE2_PHY_CLK_ROOT, IP_CLOCK_SLICE, 65, |
| 447 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL2_500M_CLK, |
| 448 | EXT_CLK_1, EXT_CLK_2, EXT_CLK_3, |
| 449 | EXT_CLK_4, SYSTEM_PLL1_400M_CLK} |
| 450 | }, |
| 451 | {PCIE2_AUX_CLK_ROOT, IP_CLOCK_SLICE, 66, |
| 452 | {OSC_25M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL2_50M_CLK, |
| 453 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_100M_CLK, |
| 454 | SYSTEM_PLL1_80M_CLK, SYSTEM_PLL1_160M_CLK, SYSTEM_PLL1_200M_CLK} |
| 455 | }, |
| 456 | {ECSPI3_CLK_ROOT, IP_CLOCK_SLICE, 67, |
| 457 | {OSC_25M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_40M_CLK, |
| 458 | SYSTEM_PLL1_160M_CLK, SYSTEM_PLL1_800M_CLK, |
| 459 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_250M_CLK, AUDIO_PLL2_CLK} |
| 460 | }, |
| 461 | {OLD_MIPI_DSI_ESC_RX_ROOT, IP_CLOCK_SLICE, 68, |
| 462 | {OSC_25M_CLK, SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_80M_CLK, |
| 463 | SYSTEM_PLL1_800M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 464 | SYSTEM_PLL3_CLK, EXT_CLK_3, AUDIO_PLL2_CLK}, |
| 465 | }, |
| 466 | {DISPLAY_HDMI_CLK_ROOT, IP_CLOCK_SLICE, 69, |
| 467 | {OSC_25M_CLK, SYSTEM_PLL1_200M_CLK, SYSTEM_PLL2_200M_CLK, |
| 468 | VPU_PLL_CLK, SYSTEM_PLL1_800M_CLK, |
| 469 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL3_CLK, EXT_CLK_4} |
| 470 | }, |
| 471 | {DRAM_SEL_CFG, DRAM_SEL_CLOCK_SLICE, 0, |
| 472 | {DRAM_PLL1_CLK} |
| 473 | }, |
| 474 | {CORE_SEL_CFG, CORE_SEL_CLOCK_SLICE, 0, |
| 475 | {DRAM_PLL1_CLK} |
| 476 | }, |
| 477 | }; |
Peng Fan | 0ee1c13 | 2019-09-16 03:09:17 +0000 | [diff] [blame] | 478 | #elif defined(CONFIG_IMX8MM) || defined(CONFIG_IMX8MN) |
Peng Fan | 9987846 | 2019-08-27 06:25:51 +0000 | [diff] [blame] | 479 | static struct clk_root_map root_array[] = { |
| 480 | {NAND_USDHC_BUS_CLK_ROOT, BUS_CLOCK_SLICE, 2, |
| 481 | {OSC_24M_CLK, SYSTEM_PLL1_266M_CLK, SYSTEM_PLL1_800M_CLK, |
| 482 | SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_133M_CLK, |
| 483 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_250M_CLK, AUDIO_PLL1_CLK} |
| 484 | }, |
| 485 | {NOC_CLK_ROOT, BUS_CLOCK_SLICE, 10, |
| 486 | {OSC_24M_CLK, SYSTEM_PLL1_800M_CLK, SYSTEM_PLL3_CLK, |
| 487 | SYSTEM_PLL2_1000M_CLK, SYSTEM_PLL2_500M_CLK, |
| 488 | AUDIO_PLL1_CLK, VIDEO_PLL_CLK, AUDIO_PLL2_CLK} |
| 489 | }, |
Peng Fan | 0ee1c13 | 2019-09-16 03:09:17 +0000 | [diff] [blame] | 490 | #ifdef CONFIG_IMX8MM |
Peng Fan | 9987846 | 2019-08-27 06:25:51 +0000 | [diff] [blame] | 491 | {NOC_APB_CLK_ROOT, BUS_CLOCK_SLICE, 11, |
| 492 | {OSC_24M_CLK, SYSTEM_PLL1_400M_CLK, SYSTEM_PLL3_CLK, |
| 493 | SYSTEM_PLL2_333M_CLK, SYSTEM_PLL2_200M_CLK, |
| 494 | SYSTEM_PLL1_800M_CLK, AUDIO_PLL1_CLK, VIDEO_PLL_CLK} |
| 495 | }, |
Peng Fan | 0ee1c13 | 2019-09-16 03:09:17 +0000 | [diff] [blame] | 496 | #endif |
Peng Fan | 9987846 | 2019-08-27 06:25:51 +0000 | [diff] [blame] | 497 | {DRAM_ALT_CLK_ROOT, IP_CLOCK_SLICE, 0, |
| 498 | {OSC_24M_CLK, SYSTEM_PLL1_800M_CLK, SYSTEM_PLL1_100M_CLK, |
| 499 | SYSTEM_PLL2_500M_CLK, SYSTEM_PLL2_1000M_CLK, |
| 500 | SYSTEM_PLL3_CLK, AUDIO_PLL1_CLK, SYSTEM_PLL1_266M_CLK} |
| 501 | }, |
| 502 | {DRAM_APB_CLK_ROOT, IP_CLOCK_SLICE, 1, |
| 503 | {OSC_24M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_40M_CLK, |
| 504 | SYSTEM_PLL1_160M_CLK, SYSTEM_PLL1_800M_CLK, |
| 505 | SYSTEM_PLL3_CLK, SYSTEM_PLL2_250M_CLK, AUDIO_PLL2_CLK} |
| 506 | }, |
| 507 | {UART1_CLK_ROOT, IP_CLOCK_SLICE, 30, |
| 508 | {OSC_24M_CLK, SYSTEM_PLL1_80M_CLK, SYSTEM_PLL2_200M_CLK, |
| 509 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL3_CLK, |
| 510 | EXT_CLK_2, EXT_CLK_4, AUDIO_PLL2_CLK} |
| 511 | }, |
| 512 | {UART2_CLK_ROOT, IP_CLOCK_SLICE, 31, |
| 513 | {OSC_24M_CLK, SYSTEM_PLL1_80M_CLK, SYSTEM_PLL2_200M_CLK, |
| 514 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL3_CLK, |
| 515 | EXT_CLK_2, EXT_CLK_3, AUDIO_PLL2_CLK} |
| 516 | }, |
| 517 | {UART3_CLK_ROOT, IP_CLOCK_SLICE, 32, |
| 518 | {OSC_24M_CLK, SYSTEM_PLL1_80M_CLK, SYSTEM_PLL2_200M_CLK, |
| 519 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL3_CLK, |
| 520 | EXT_CLK_2, EXT_CLK_4, AUDIO_PLL2_CLK} |
| 521 | }, |
| 522 | {UART4_CLK_ROOT, IP_CLOCK_SLICE, 33, |
| 523 | {OSC_24M_CLK, SYSTEM_PLL1_80M_CLK, SYSTEM_PLL2_200M_CLK, |
| 524 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL3_CLK, |
| 525 | EXT_CLK_2, EXT_CLK_3, AUDIO_PLL2_CLK} |
| 526 | }, |
| 527 | {GIC_CLK_ROOT, IP_CLOCK_SLICE, 36, |
| 528 | {OSC_24M_CLK, SYSTEM_PLL2_200M_CLK, SYSTEM_PLL1_40M_CLK, |
| 529 | SYSTEM_PLL2_100M_CLK, SYSTEM_PLL1_800M_CLK, |
| 530 | EXT_CLK_2, EXT_CLK_4, AUDIO_PLL2_CLK} |
| 531 | }, |
| 532 | {WDOG_CLK_ROOT, IP_CLOCK_SLICE, 50, |
| 533 | {OSC_24M_CLK, SYSTEM_PLL1_133M_CLK, SYSTEM_PLL1_160M_CLK, |
| 534 | VPU_PLL_CLK, SYSTEM_PLL2_125M_CLK, |
| 535 | SYSTEM_PLL3_CLK, SYSTEM_PLL1_80M_CLK, SYSTEM_PLL2_166M_CLK} |
| 536 | }, |
| 537 | {DRAM_SEL_CFG, DRAM_SEL_CLOCK_SLICE, 0, |
| 538 | {DRAM_PLL1_CLK} |
| 539 | }, |
| 540 | }; |
| 541 | #endif |
Peng Fan | 88057bc | 2018-01-10 13:20:22 +0800 | [diff] [blame] | 542 | |
| 543 | static int select(enum clk_root_index clock_id) |
| 544 | { |
| 545 | int i, size; |
| 546 | struct clk_root_map *p = root_array; |
| 547 | |
| 548 | size = ARRAY_SIZE(root_array); |
| 549 | |
| 550 | for (i = 0; i < size; i++, p++) { |
| 551 | if (clock_id == p->entry) |
| 552 | return i; |
| 553 | } |
| 554 | |
| 555 | return -EINVAL; |
| 556 | } |
| 557 | |
| 558 | static void __iomem *get_clk_root_target(enum clk_slice_type slice_type, |
| 559 | u32 slice_index) |
| 560 | { |
| 561 | void __iomem *clk_root_target; |
| 562 | |
| 563 | switch (slice_type) { |
| 564 | case CORE_CLOCK_SLICE: |
| 565 | clk_root_target = |
| 566 | (void __iomem *)&ccm_reg->core_root[slice_index]; |
| 567 | break; |
| 568 | case BUS_CLOCK_SLICE: |
| 569 | clk_root_target = |
| 570 | (void __iomem *)&ccm_reg->bus_root[slice_index]; |
| 571 | break; |
| 572 | case IP_CLOCK_SLICE: |
| 573 | clk_root_target = |
| 574 | (void __iomem *)&ccm_reg->ip_root[slice_index]; |
| 575 | break; |
| 576 | case AHB_CLOCK_SLICE: |
| 577 | clk_root_target = |
| 578 | (void __iomem *)&ccm_reg->ahb_ipg_root[slice_index * 2]; |
| 579 | break; |
| 580 | case IPG_CLOCK_SLICE: |
| 581 | clk_root_target = |
| 582 | (void __iomem *)&ccm_reg->ahb_ipg_root[slice_index * 2 + 1]; |
| 583 | break; |
| 584 | case CORE_SEL_CLOCK_SLICE: |
| 585 | clk_root_target = (void __iomem *)&ccm_reg->core_sel; |
| 586 | break; |
| 587 | case DRAM_SEL_CLOCK_SLICE: |
| 588 | clk_root_target = (void __iomem *)&ccm_reg->dram_sel; |
| 589 | break; |
| 590 | default: |
| 591 | return NULL; |
| 592 | } |
| 593 | |
| 594 | return clk_root_target; |
| 595 | } |
| 596 | |
| 597 | int clock_get_target_val(enum clk_root_index clock_id, u32 *val) |
| 598 | { |
| 599 | int root_entry; |
| 600 | struct clk_root_map *p; |
| 601 | void __iomem *clk_root_target; |
| 602 | |
| 603 | if (clock_id >= CLK_ROOT_MAX) |
| 604 | return -EINVAL; |
| 605 | |
| 606 | root_entry = select(clock_id); |
| 607 | if (root_entry < 0) |
| 608 | return -EINVAL; |
| 609 | |
| 610 | p = &root_array[root_entry]; |
| 611 | clk_root_target = get_clk_root_target(p->slice_type, p->slice_index); |
| 612 | if (!clk_root_target) |
| 613 | return -EINVAL; |
| 614 | |
| 615 | *val = readl(clk_root_target); |
| 616 | |
| 617 | return 0; |
| 618 | } |
| 619 | |
| 620 | int clock_set_target_val(enum clk_root_index clock_id, u32 val) |
| 621 | { |
| 622 | int root_entry; |
| 623 | struct clk_root_map *p; |
| 624 | void __iomem *clk_root_target; |
| 625 | |
| 626 | if (clock_id >= CLK_ROOT_MAX) |
| 627 | return -EINVAL; |
| 628 | |
| 629 | root_entry = select(clock_id); |
| 630 | if (root_entry < 0) |
| 631 | return -EINVAL; |
| 632 | |
| 633 | p = &root_array[root_entry]; |
| 634 | clk_root_target = get_clk_root_target(p->slice_type, p->slice_index); |
| 635 | if (!clk_root_target) |
| 636 | return -EINVAL; |
| 637 | |
| 638 | writel(val, clk_root_target); |
| 639 | |
| 640 | return 0; |
| 641 | } |
| 642 | |
| 643 | int clock_root_enabled(enum clk_root_index clock_id) |
| 644 | { |
| 645 | void __iomem *clk_root_target; |
| 646 | u32 slice_index, slice_type; |
| 647 | u32 val; |
| 648 | int root_entry; |
| 649 | |
| 650 | if (clock_id >= CLK_ROOT_MAX) |
| 651 | return -EINVAL; |
| 652 | |
| 653 | root_entry = select(clock_id); |
| 654 | if (root_entry < 0) |
| 655 | return -EINVAL; |
| 656 | |
| 657 | slice_type = root_array[root_entry].slice_type; |
| 658 | slice_index = root_array[root_entry].slice_index; |
| 659 | |
| 660 | if ((slice_type == IPG_CLOCK_SLICE) || |
| 661 | (slice_type == DRAM_SEL_CLOCK_SLICE) || |
| 662 | (slice_type == CORE_SEL_CLOCK_SLICE)) { |
| 663 | /* |
| 664 | * Not supported, from CCM doc |
| 665 | * TODO |
| 666 | */ |
| 667 | return 0; |
| 668 | } |
| 669 | |
| 670 | clk_root_target = get_clk_root_target(slice_type, slice_index); |
| 671 | if (!clk_root_target) |
| 672 | return -EINVAL; |
| 673 | |
| 674 | val = readl(clk_root_target); |
| 675 | |
| 676 | return (val & CLK_ROOT_ON) ? 1 : 0; |
| 677 | } |
| 678 | |
| 679 | /* CCGR CLK gate operation */ |
| 680 | int clock_enable(enum clk_ccgr_index index, bool enable) |
| 681 | { |
| 682 | void __iomem *ccgr; |
| 683 | |
| 684 | if (index >= CCGR_MAX) |
| 685 | return -EINVAL; |
| 686 | |
| 687 | if (enable) |
| 688 | ccgr = (void __iomem *)&ccm_reg->ccgr_array[index].ccgr_set; |
| 689 | else |
| 690 | ccgr = (void __iomem *)&ccm_reg->ccgr_array[index].ccgr_clr; |
| 691 | |
| 692 | writel(CCGR_CLK_ON_MASK, ccgr); |
| 693 | |
| 694 | return 0; |
| 695 | } |
| 696 | |
| 697 | int clock_get_prediv(enum clk_root_index clock_id, enum root_pre_div *pre_div) |
| 698 | { |
| 699 | u32 val; |
| 700 | int root_entry; |
| 701 | struct clk_root_map *p; |
| 702 | void __iomem *clk_root_target; |
| 703 | |
| 704 | if (clock_id >= CLK_ROOT_MAX) |
| 705 | return -EINVAL; |
| 706 | |
| 707 | root_entry = select(clock_id); |
| 708 | if (root_entry < 0) |
| 709 | return -EINVAL; |
| 710 | |
| 711 | p = &root_array[root_entry]; |
| 712 | |
| 713 | if ((p->slice_type == CORE_CLOCK_SLICE) || |
| 714 | (p->slice_type == IPG_CLOCK_SLICE) || |
| 715 | (p->slice_type == CORE_SEL_CLOCK_SLICE) || |
| 716 | (p->slice_type == DRAM_SEL_CLOCK_SLICE)) { |
| 717 | *pre_div = 0; |
| 718 | return 0; |
| 719 | } |
| 720 | |
| 721 | clk_root_target = get_clk_root_target(p->slice_type, p->slice_index); |
| 722 | if (!clk_root_target) |
| 723 | return -EINVAL; |
| 724 | |
| 725 | val = readl(clk_root_target); |
| 726 | val &= CLK_ROOT_PRE_DIV_MASK; |
| 727 | val >>= CLK_ROOT_PRE_DIV_SHIFT; |
| 728 | |
| 729 | *pre_div = val; |
| 730 | |
| 731 | return 0; |
| 732 | } |
| 733 | |
| 734 | int clock_get_postdiv(enum clk_root_index clock_id, |
| 735 | enum root_post_div *post_div) |
| 736 | { |
| 737 | u32 val, mask; |
| 738 | int root_entry; |
| 739 | struct clk_root_map *p; |
| 740 | void __iomem *clk_root_target; |
| 741 | |
| 742 | if (clock_id >= CLK_ROOT_MAX) |
| 743 | return -EINVAL; |
| 744 | |
| 745 | root_entry = select(clock_id); |
| 746 | if (root_entry < 0) |
| 747 | return -EINVAL; |
| 748 | |
| 749 | p = &root_array[root_entry]; |
| 750 | |
| 751 | if ((p->slice_type == CORE_SEL_CLOCK_SLICE) || |
| 752 | (p->slice_type == DRAM_SEL_CLOCK_SLICE)) { |
| 753 | *post_div = 0; |
| 754 | return 0; |
| 755 | } |
| 756 | |
| 757 | clk_root_target = get_clk_root_target(p->slice_type, p->slice_index); |
| 758 | if (!clk_root_target) |
| 759 | return -EINVAL; |
| 760 | |
| 761 | if (p->slice_type == IPG_CLOCK_SLICE) |
| 762 | mask = CLK_ROOT_IPG_POST_DIV_MASK; |
| 763 | else if (p->slice_type == CORE_CLOCK_SLICE) |
| 764 | mask = CLK_ROOT_CORE_POST_DIV_MASK; |
| 765 | else |
| 766 | mask = CLK_ROOT_POST_DIV_MASK; |
| 767 | |
| 768 | val = readl(clk_root_target); |
| 769 | val &= mask; |
| 770 | val >>= CLK_ROOT_POST_DIV_SHIFT; |
| 771 | |
| 772 | *post_div = val; |
| 773 | |
| 774 | return 0; |
| 775 | } |
| 776 | |
| 777 | int clock_get_src(enum clk_root_index clock_id, enum clk_root_src *p_clock_src) |
| 778 | { |
| 779 | u32 val; |
| 780 | int root_entry; |
| 781 | struct clk_root_map *p; |
| 782 | void __iomem *clk_root_target; |
| 783 | |
| 784 | if (clock_id >= CLK_ROOT_MAX) |
| 785 | return -EINVAL; |
| 786 | |
| 787 | root_entry = select(clock_id); |
| 788 | if (root_entry < 0) |
| 789 | return -EINVAL; |
| 790 | |
| 791 | p = &root_array[root_entry]; |
| 792 | |
| 793 | clk_root_target = get_clk_root_target(p->slice_type, p->slice_index); |
| 794 | if (!clk_root_target) |
| 795 | return -EINVAL; |
| 796 | |
| 797 | val = readl(clk_root_target); |
| 798 | val &= CLK_ROOT_SRC_MUX_MASK; |
| 799 | val >>= CLK_ROOT_SRC_MUX_SHIFT; |
| 800 | |
| 801 | *p_clock_src = p->src_mux[val]; |
| 802 | |
| 803 | return 0; |
| 804 | } |