Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later OR BSD-3-Clause |
| 2 | /* |
| 3 | * Copyright (C) 2022, STMicroelectronics - All Rights Reserved |
| 4 | */ |
| 5 | |
| 6 | #include <clk-uclass.h> |
| 7 | #include <dm.h> |
| 8 | #include <dt-bindings/clock/st,stm32mp25-rcc.h> |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 9 | #include <linux/bitfield.h> |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 10 | #include <linux/clk-provider.h> |
| 11 | #include <linux/io.h> |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 12 | #include <mach/rif.h> |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 13 | |
| 14 | #include "clk-stm32-core.h" |
| 15 | #include "stm32mp25_rcc.h" |
| 16 | |
| 17 | /* Clock security definition */ |
| 18 | #define SECF_NONE -1 |
| 19 | |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 20 | #define RCC_REG_SIZE 32 |
| 21 | #define RCC_SECCFGR(x) (((x) / RCC_REG_SIZE) * 0x4 + RCC_SECCFGR0) |
| 22 | #define RCC_CIDCFGR(x) ((x) * 0x8 + RCC_R0CIDCFGR) |
| 23 | #define RCC_SEMCR(x) ((x) * 0x8 + RCC_R0SEMCR) |
| 24 | #define RCC_CID1 1 |
| 25 | |
| 26 | /* Register: RIFSC_CIDCFGR */ |
| 27 | #define RCC_CIDCFGR_CFEN BIT(0) |
| 28 | #define RCC_CIDCFGR_SEM_EN BIT(1) |
| 29 | #define RCC_CIDCFGR_SEMWLC1_EN BIT(17) |
| 30 | #define RCC_CIDCFGR_SCID_MASK GENMASK(6, 4) |
| 31 | |
| 32 | /* Register: RIFSC_SEMCR */ |
| 33 | #define RCC_SEMCR_SEMCID_MASK GENMASK(6, 4) |
| 34 | |
| 35 | #define STM32MP25_RIFRCC_DBG_ID 73 |
| 36 | #define STM32MP25_RIFRCC_IS2M_ID 107 |
| 37 | #define STM32MP25_RIFRCC_MCO1_ID 108 |
| 38 | #define STM32MP25_RIFRCC_MCO2_ID 109 |
| 39 | #define STM32MP25_RIFRCC_OSPI1_ID 110 |
| 40 | #define STM32MP25_RIFRCC_OSPI2_ID 111 |
| 41 | |
| 42 | #define SEC_RIFSC_FLAG BIT(31) |
| 43 | #define SEC_RIFRCC(_id) (STM32MP25_RIFRCC_##_id##_ID) |
| 44 | #define SEC_RIFSC(_id) ((_id) | SEC_RIFSC_FLAG) |
| 45 | |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 46 | static const char * const adc12_src[] = { |
| 47 | "ck_flexgen_46", "ck_icn_ls_mcu" |
| 48 | }; |
| 49 | |
| 50 | static const char * const adc3_src[] = { |
| 51 | "ck_flexgen_47", "ck_icn_ls_mcu", "ck_flexgen_46" |
| 52 | }; |
| 53 | |
| 54 | static const char * const usb2phy1_src[] = { |
| 55 | "ck_flexgen_57", "hse_div2_ck" |
| 56 | }; |
| 57 | |
| 58 | static const char * const usb2phy2_src[] = { |
| 59 | "ck_flexgen_58", "hse_div2_ck" |
| 60 | }; |
| 61 | |
| 62 | static const char * const usb3pciphy_src[] = { |
| 63 | "ck_flexgen_34", "hse_div2_ck" |
| 64 | }; |
| 65 | |
| 66 | static const char * const dsiblane_src[] = { |
| 67 | "txbyteclk", "ck_ker_ltdc" |
| 68 | }; |
| 69 | |
| 70 | static const char * const dsiphy_src[] = { |
| 71 | "ck_flexgen_28", "hse_ck" |
| 72 | }; |
| 73 | |
| 74 | static const char * const lvdsphy_src[] = { |
| 75 | "ck_flexgen_32", "hse_ck" |
| 76 | }; |
| 77 | |
| 78 | static const char * const dts_src[] = { |
| 79 | "hsi_ck", "hse_ck", "msi_ck" |
| 80 | }; |
| 81 | |
| 82 | static const char * const mco1_src[] = { |
| 83 | "ck_flexgen_61", "ck_obs0" |
| 84 | }; |
| 85 | |
| 86 | static const char * const mco2_src[] = { |
| 87 | "ck_flexgen_62", "ck_obs1" |
| 88 | }; |
| 89 | |
| 90 | enum enum_mux_cfg { |
| 91 | MUX_MCO1, |
| 92 | MUX_MCO2, |
| 93 | MUX_ADC12, |
| 94 | MUX_ADC3, |
| 95 | MUX_USB2PHY1, |
| 96 | MUX_USB2PHY2, |
| 97 | MUX_USB3PCIEPHY, |
| 98 | MUX_DSIBLANE, |
| 99 | MUX_DSIPHY, |
| 100 | MUX_LVDSPHY, |
| 101 | MUX_DTS, |
| 102 | MUX_NB |
| 103 | }; |
| 104 | |
| 105 | #define MUX_CFG(id, src, _offset, _shift, _witdh)[id] = {\ |
| 106 | .num_parents = ARRAY_SIZE(src),\ |
| 107 | .parent_names = src,\ |
| 108 | .reg_off = (_offset),\ |
| 109 | .shift = (_shift),\ |
| 110 | .width = (_witdh),\ |
| 111 | } |
| 112 | |
| 113 | static const struct stm32_mux_cfg stm32mp25_muxes[MUX_NB] = { |
| 114 | MUX_CFG(MUX_ADC12, adc12_src, RCC_ADC12CFGR, 12, 1), |
| 115 | MUX_CFG(MUX_ADC3, adc3_src, RCC_ADC3CFGR, 12, 2), |
| 116 | MUX_CFG(MUX_DSIBLANE, dsiblane_src, RCC_DSICFGR, 12, 1), |
| 117 | MUX_CFG(MUX_DSIPHY, dsiphy_src, RCC_DSICFGR, 15, 1), |
| 118 | MUX_CFG(MUX_DTS, dts_src, RCC_DTSCFGR, 12, 2), |
| 119 | MUX_CFG(MUX_MCO1, mco1_src, RCC_MCO1CFGR, 0, 1), |
| 120 | MUX_CFG(MUX_MCO2, mco2_src, RCC_MCO2CFGR, 0, 1), |
| 121 | MUX_CFG(MUX_LVDSPHY, lvdsphy_src, RCC_LVDSCFGR, 15, 1), |
| 122 | MUX_CFG(MUX_USB2PHY1, usb2phy1_src, RCC_USB2PHY1CFGR, 15, 1), |
| 123 | MUX_CFG(MUX_USB2PHY2, usb2phy2_src, RCC_USB2PHY2CFGR, 15, 1), |
| 124 | MUX_CFG(MUX_USB3PCIEPHY, usb3pciphy_src, RCC_USB3PCIEPHYCFGR, 15, 1), |
| 125 | }; |
| 126 | |
| 127 | enum enum_gate_cfg { |
| 128 | GATE_ADC12, |
| 129 | GATE_ADC3, |
| 130 | GATE_ADF1, |
| 131 | GATE_CCI, |
| 132 | GATE_CRC, |
| 133 | GATE_CRYP1, |
| 134 | GATE_CRYP2, |
| 135 | GATE_CSI, |
| 136 | GATE_DBG, |
| 137 | GATE_DCMIPP, |
| 138 | GATE_DSI, |
| 139 | GATE_DTS, |
| 140 | GATE_ETH1, |
| 141 | GATE_ETH1MAC, |
| 142 | GATE_ETH1RX, |
| 143 | GATE_ETH1STP, |
| 144 | GATE_ETH1TX, |
| 145 | GATE_ETH2, |
| 146 | GATE_ETH2MAC, |
| 147 | GATE_ETH2RX, |
| 148 | GATE_ETH2STP, |
| 149 | GATE_ETH2TX, |
| 150 | GATE_ETHSW, |
| 151 | GATE_ETHSWMAC, |
| 152 | GATE_ETHSWREF, |
| 153 | GATE_ETR, |
| 154 | GATE_FDCAN, |
| 155 | GATE_GPU, |
| 156 | GATE_HASH, |
| 157 | GATE_HDP, |
| 158 | GATE_I2C1, |
| 159 | GATE_I2C2, |
| 160 | GATE_I2C3, |
| 161 | GATE_I2C4, |
| 162 | GATE_I2C5, |
| 163 | GATE_I2C6, |
| 164 | GATE_I2C7, |
| 165 | GATE_I2C8, |
| 166 | GATE_I3C1, |
| 167 | GATE_I3C2, |
| 168 | GATE_I3C3, |
| 169 | GATE_I3C4, |
| 170 | GATE_IS2M, |
| 171 | GATE_IWDG1, |
| 172 | GATE_IWDG2, |
| 173 | GATE_IWDG3, |
| 174 | GATE_IWDG4, |
| 175 | GATE_IWDG5, |
| 176 | GATE_LPTIM1, |
| 177 | GATE_LPTIM2, |
| 178 | GATE_LPTIM3, |
| 179 | GATE_LPTIM4, |
| 180 | GATE_LPTIM5, |
| 181 | GATE_LPUART1, |
| 182 | GATE_LTDC, |
| 183 | GATE_LVDS, |
| 184 | GATE_MCO1, |
| 185 | GATE_MCO2, |
| 186 | GATE_MDF1, |
| 187 | GATE_OSPI1, |
| 188 | GATE_OSPI2, |
| 189 | GATE_OSPIIOM, |
| 190 | GATE_PCIE, |
| 191 | GATE_PKA, |
| 192 | GATE_RNG, |
| 193 | GATE_SAES, |
| 194 | GATE_SAI1, |
| 195 | GATE_SAI2, |
| 196 | GATE_SAI3, |
| 197 | GATE_SAI4, |
| 198 | GATE_SDMMC1, |
| 199 | GATE_SDMMC2, |
| 200 | GATE_SDMMC3, |
| 201 | GATE_SERC, |
| 202 | GATE_SPDIFRX, |
| 203 | GATE_SPI1, |
| 204 | GATE_SPI2, |
| 205 | GATE_SPI3, |
| 206 | GATE_SPI4, |
| 207 | GATE_SPI5, |
| 208 | GATE_SPI6, |
| 209 | GATE_SPI7, |
| 210 | GATE_SPI8, |
| 211 | GATE_STGEN, |
| 212 | GATE_STM500, |
| 213 | GATE_TIM1, |
| 214 | GATE_TIM2, |
| 215 | GATE_TIM3, |
| 216 | GATE_TIM4, |
| 217 | GATE_TIM5, |
| 218 | GATE_TIM6, |
| 219 | GATE_TIM7, |
| 220 | GATE_TIM8, |
| 221 | GATE_TIM10, |
| 222 | GATE_TIM11, |
| 223 | GATE_TIM12, |
| 224 | GATE_TIM13, |
| 225 | GATE_TIM14, |
| 226 | GATE_TIM15, |
| 227 | GATE_TIM16, |
| 228 | GATE_TIM17, |
| 229 | GATE_TIM20, |
| 230 | GATE_TRACE, |
| 231 | GATE_UART4, |
| 232 | GATE_UART5, |
| 233 | GATE_UART7, |
| 234 | GATE_UART8, |
| 235 | GATE_UART9, |
| 236 | GATE_USART1, |
| 237 | GATE_USART2, |
| 238 | GATE_USART3, |
| 239 | GATE_USART6, |
| 240 | GATE_USBH, |
| 241 | GATE_USB2PHY1, |
| 242 | GATE_USB2PHY2, |
| 243 | GATE_USB3DR, |
| 244 | GATE_USB3PCIEPHY, |
| 245 | GATE_USBTC, |
| 246 | GATE_VDEC, |
| 247 | GATE_VENC, |
| 248 | GATE_VREF, |
| 249 | GATE_WWDG1, |
| 250 | GATE_WWDG2, |
| 251 | GATE_NB |
| 252 | }; |
| 253 | |
| 254 | #define GATE_CFG(id, _offset, _bit_idx, _offset_clr)[id] = {\ |
| 255 | .reg_off = (_offset),\ |
| 256 | .bit_idx = (_bit_idx),\ |
| 257 | .set_clr = (_offset_clr),\ |
| 258 | } |
| 259 | |
| 260 | static const struct stm32_gate_cfg stm32mp25_gates[GATE_NB] = { |
| 261 | GATE_CFG(GATE_MCO1, RCC_MCO1CFGR, 8, 0), |
| 262 | GATE_CFG(GATE_MCO2, RCC_MCO2CFGR, 8, 0), |
| 263 | GATE_CFG(GATE_OSPI1, RCC_OSPI1CFGR, 1, 0), |
| 264 | GATE_CFG(GATE_OSPI2, RCC_OSPI2CFGR, 1, 0), |
| 265 | GATE_CFG(GATE_DBG, RCC_DBGCFGR, 8, 0), |
| 266 | GATE_CFG(GATE_TRACE, RCC_DBGCFGR, 9, 0), |
| 267 | GATE_CFG(GATE_STM500, RCC_STM500CFGR, 1, 0), |
| 268 | GATE_CFG(GATE_ETR, RCC_ETRCFGR, 1, 0), |
| 269 | GATE_CFG(GATE_IS2M, RCC_IS2MCFGR, 1, 0), |
| 270 | GATE_CFG(GATE_TIM1, RCC_TIM1CFGR, 1, 0), |
| 271 | GATE_CFG(GATE_TIM2, RCC_TIM2CFGR, 1, 0), |
| 272 | GATE_CFG(GATE_TIM3, RCC_TIM3CFGR, 1, 0), |
| 273 | GATE_CFG(GATE_TIM4, RCC_TIM4CFGR, 1, 0), |
| 274 | GATE_CFG(GATE_TIM5, RCC_TIM5CFGR, 1, 0), |
| 275 | GATE_CFG(GATE_TIM6, RCC_TIM6CFGR, 1, 0), |
| 276 | GATE_CFG(GATE_TIM7, RCC_TIM7CFGR, 1, 0), |
| 277 | GATE_CFG(GATE_TIM8, RCC_TIM8CFGR, 1, 0), |
| 278 | GATE_CFG(GATE_TIM10, RCC_TIM10CFGR, 1, 0), |
| 279 | GATE_CFG(GATE_TIM11, RCC_TIM11CFGR, 1, 0), |
| 280 | GATE_CFG(GATE_TIM12, RCC_TIM12CFGR, 1, 0), |
| 281 | GATE_CFG(GATE_TIM13, RCC_TIM13CFGR, 1, 0), |
| 282 | GATE_CFG(GATE_TIM14, RCC_TIM14CFGR, 1, 0), |
| 283 | GATE_CFG(GATE_TIM15, RCC_TIM15CFGR, 1, 0), |
| 284 | GATE_CFG(GATE_TIM16, RCC_TIM16CFGR, 1, 0), |
| 285 | GATE_CFG(GATE_TIM17, RCC_TIM17CFGR, 1, 0), |
| 286 | GATE_CFG(GATE_TIM20, RCC_TIM20CFGR, 1, 0), |
| 287 | GATE_CFG(GATE_LPTIM1, RCC_LPTIM1CFGR, 1, 0), |
| 288 | GATE_CFG(GATE_LPTIM2, RCC_LPTIM2CFGR, 1, 0), |
| 289 | GATE_CFG(GATE_LPTIM3, RCC_LPTIM3CFGR, 1, 0), |
| 290 | GATE_CFG(GATE_LPTIM4, RCC_LPTIM4CFGR, 1, 0), |
| 291 | GATE_CFG(GATE_LPTIM5, RCC_LPTIM5CFGR, 1, 0), |
| 292 | GATE_CFG(GATE_SPI1, RCC_SPI1CFGR, 1, 0), |
| 293 | GATE_CFG(GATE_SPI2, RCC_SPI2CFGR, 1, 0), |
| 294 | GATE_CFG(GATE_SPI3, RCC_SPI3CFGR, 1, 0), |
| 295 | GATE_CFG(GATE_SPI4, RCC_SPI4CFGR, 1, 0), |
| 296 | GATE_CFG(GATE_SPI5, RCC_SPI5CFGR, 1, 0), |
| 297 | GATE_CFG(GATE_SPI6, RCC_SPI6CFGR, 1, 0), |
| 298 | GATE_CFG(GATE_SPI7, RCC_SPI7CFGR, 1, 0), |
| 299 | GATE_CFG(GATE_SPI8, RCC_SPI8CFGR, 1, 0), |
| 300 | GATE_CFG(GATE_SPDIFRX, RCC_SPDIFRXCFGR, 1, 0), |
| 301 | GATE_CFG(GATE_USART1, RCC_USART1CFGR, 1, 0), |
| 302 | GATE_CFG(GATE_USART2, RCC_USART2CFGR, 1, 0), |
| 303 | GATE_CFG(GATE_USART3, RCC_USART3CFGR, 1, 0), |
| 304 | GATE_CFG(GATE_UART4, RCC_UART4CFGR, 1, 0), |
| 305 | GATE_CFG(GATE_UART5, RCC_UART5CFGR, 1, 0), |
| 306 | GATE_CFG(GATE_USART6, RCC_USART6CFGR, 1, 0), |
| 307 | GATE_CFG(GATE_UART7, RCC_UART7CFGR, 1, 0), |
| 308 | GATE_CFG(GATE_UART8, RCC_UART8CFGR, 1, 0), |
| 309 | GATE_CFG(GATE_UART9, RCC_UART9CFGR, 1, 0), |
| 310 | GATE_CFG(GATE_LPUART1, RCC_LPUART1CFGR, 1, 0), |
| 311 | GATE_CFG(GATE_I2C1, RCC_I2C1CFGR, 1, 0), |
| 312 | GATE_CFG(GATE_I2C2, RCC_I2C2CFGR, 1, 0), |
| 313 | GATE_CFG(GATE_I2C3, RCC_I2C3CFGR, 1, 0), |
| 314 | GATE_CFG(GATE_I2C4, RCC_I2C4CFGR, 1, 0), |
| 315 | GATE_CFG(GATE_I2C5, RCC_I2C5CFGR, 1, 0), |
| 316 | GATE_CFG(GATE_I2C6, RCC_I2C6CFGR, 1, 0), |
| 317 | GATE_CFG(GATE_I2C7, RCC_I2C7CFGR, 1, 0), |
| 318 | GATE_CFG(GATE_I2C8, RCC_I2C8CFGR, 1, 0), |
| 319 | GATE_CFG(GATE_SAI1, RCC_SAI1CFGR, 1, 0), |
| 320 | GATE_CFG(GATE_SAI2, RCC_SAI2CFGR, 1, 0), |
| 321 | GATE_CFG(GATE_SAI3, RCC_SAI3CFGR, 1, 0), |
| 322 | GATE_CFG(GATE_SAI4, RCC_SAI4CFGR, 1, 0), |
| 323 | GATE_CFG(GATE_MDF1, RCC_MDF1CFGR, 1, 0), |
| 324 | GATE_CFG(GATE_ADF1, RCC_ADF1CFGR, 1, 0), |
| 325 | GATE_CFG(GATE_FDCAN, RCC_FDCANCFGR, 1, 0), |
| 326 | GATE_CFG(GATE_HDP, RCC_HDPCFGR, 1, 0), |
| 327 | GATE_CFG(GATE_ADC12, RCC_ADC12CFGR, 1, 0), |
| 328 | GATE_CFG(GATE_ADC3, RCC_ADC3CFGR, 1, 0), |
| 329 | GATE_CFG(GATE_ETH1MAC, RCC_ETH1CFGR, 1, 0), |
| 330 | GATE_CFG(GATE_ETH1STP, RCC_ETH1CFGR, 4, 0), |
| 331 | GATE_CFG(GATE_ETH1, RCC_ETH1CFGR, 5, 0), |
| 332 | GATE_CFG(GATE_ETH1TX, RCC_ETH1CFGR, 8, 0), |
| 333 | GATE_CFG(GATE_ETH1RX, RCC_ETH1CFGR, 10, 0), |
| 334 | GATE_CFG(GATE_ETH2MAC, RCC_ETH2CFGR, 1, 0), |
| 335 | GATE_CFG(GATE_ETH2STP, RCC_ETH2CFGR, 4, 0), |
| 336 | GATE_CFG(GATE_ETH2, RCC_ETH2CFGR, 5, 0), |
| 337 | GATE_CFG(GATE_ETH2TX, RCC_ETH2CFGR, 8, 0), |
| 338 | GATE_CFG(GATE_ETH2RX, RCC_ETH2CFGR, 10, 0), |
| 339 | GATE_CFG(GATE_USBH, RCC_USBHCFGR, 1, 0), |
| 340 | GATE_CFG(GATE_USB2PHY1, RCC_USB2PHY1CFGR, 1, 0), |
| 341 | GATE_CFG(GATE_USB2PHY2, RCC_USB2PHY2CFGR, 1, 0), |
| 342 | GATE_CFG(GATE_USB3DR, RCC_USB3DRCFGR, 1, 0), |
| 343 | GATE_CFG(GATE_USB3PCIEPHY, RCC_USB3PCIEPHYCFGR, 1, 0), |
| 344 | GATE_CFG(GATE_PCIE, RCC_PCIECFGR, 1, 0), |
| 345 | GATE_CFG(GATE_USBTC, RCC_UCPDCFGR, 1, 0), |
| 346 | GATE_CFG(GATE_ETHSWMAC, RCC_ETHSWCFGR, 1, 0), |
| 347 | GATE_CFG(GATE_ETHSW, RCC_ETHSWCFGR, 5, 0), |
| 348 | GATE_CFG(GATE_ETHSWREF, RCC_ETHSWCFGR, 21, 0), |
| 349 | GATE_CFG(GATE_STGEN, RCC_STGENCFGR, 1, 0), |
| 350 | GATE_CFG(GATE_SDMMC1, RCC_SDMMC1CFGR, 1, 0), |
| 351 | GATE_CFG(GATE_SDMMC2, RCC_SDMMC2CFGR, 1, 0), |
| 352 | GATE_CFG(GATE_SDMMC3, RCC_SDMMC3CFGR, 1, 0), |
| 353 | GATE_CFG(GATE_GPU, RCC_GPUCFGR, 1, 0), |
| 354 | GATE_CFG(GATE_LTDC, RCC_LTDCCFGR, 1, 0), |
| 355 | GATE_CFG(GATE_DSI, RCC_DSICFGR, 1, 0), |
| 356 | GATE_CFG(GATE_LVDS, RCC_LVDSCFGR, 1, 0), |
| 357 | GATE_CFG(GATE_CSI, RCC_CSICFGR, 1, 0), |
| 358 | GATE_CFG(GATE_DCMIPP, RCC_DCMIPPCFGR, 1, 0), |
| 359 | GATE_CFG(GATE_CCI, RCC_CCICFGR, 1, 0), |
| 360 | GATE_CFG(GATE_VDEC, RCC_VDECCFGR, 1, 0), |
| 361 | GATE_CFG(GATE_VENC, RCC_VENCCFGR, 1, 0), |
| 362 | GATE_CFG(GATE_RNG, RCC_RNGCFGR, 1, 0), |
| 363 | GATE_CFG(GATE_PKA, RCC_PKACFGR, 1, 0), |
| 364 | GATE_CFG(GATE_SAES, RCC_SAESCFGR, 1, 0), |
| 365 | GATE_CFG(GATE_HASH, RCC_HASHCFGR, 1, 0), |
| 366 | GATE_CFG(GATE_CRYP1, RCC_CRYP1CFGR, 1, 0), |
| 367 | GATE_CFG(GATE_CRYP2, RCC_CRYP2CFGR, 1, 0), |
| 368 | GATE_CFG(GATE_IWDG1, RCC_IWDG1CFGR, 1, 0), |
| 369 | GATE_CFG(GATE_IWDG2, RCC_IWDG2CFGR, 1, 0), |
| 370 | GATE_CFG(GATE_IWDG3, RCC_IWDG3CFGR, 1, 0), |
| 371 | GATE_CFG(GATE_IWDG4, RCC_IWDG4CFGR, 1, 0), |
| 372 | GATE_CFG(GATE_IWDG5, RCC_IWDG5CFGR, 1, 0), |
| 373 | GATE_CFG(GATE_WWDG1, RCC_WWDG1CFGR, 1, 0), |
| 374 | GATE_CFG(GATE_WWDG2, RCC_WWDG2CFGR, 1, 0), |
| 375 | GATE_CFG(GATE_VREF, RCC_VREFCFGR, 1, 0), |
| 376 | GATE_CFG(GATE_DTS, RCC_DTSCFGR, 1, 0), |
| 377 | GATE_CFG(GATE_CRC, RCC_CRCCFGR, 1, 0), |
| 378 | GATE_CFG(GATE_SERC, RCC_SERCCFGR, 1, 0), |
| 379 | GATE_CFG(GATE_OSPIIOM, RCC_OSPIIOMCFGR, 1, 0), |
| 380 | GATE_CFG(GATE_I3C1, RCC_I3C1CFGR, 1, 0), |
| 381 | GATE_CFG(GATE_I3C2, RCC_I3C2CFGR, 1, 0), |
| 382 | GATE_CFG(GATE_I3C3, RCC_I3C3CFGR, 1, 0), |
| 383 | GATE_CFG(GATE_I3C4, RCC_I3C4CFGR, 1, 0), |
| 384 | }; |
| 385 | |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 386 | static int stm32_rcc_get_access(struct udevice *dev, u32 index) |
| 387 | { |
| 388 | fdt_addr_t rcc_base = dev_read_addr(dev->parent); |
| 389 | u32 seccfgr, cidcfgr, semcr; |
| 390 | int bit, cid; |
| 391 | |
| 392 | bit = index % RCC_REG_SIZE; |
| 393 | |
| 394 | seccfgr = readl(rcc_base + RCC_SECCFGR(index)); |
| 395 | if (seccfgr & BIT(bit)) |
| 396 | return -EACCES; |
| 397 | |
| 398 | cidcfgr = readl(rcc_base + RCC_CIDCFGR(index)); |
| 399 | if (!(cidcfgr & RCC_CIDCFGR_CFEN)) |
| 400 | /* CID filtering is turned off: access granted */ |
| 401 | return 0; |
| 402 | |
| 403 | if (!(cidcfgr & RCC_CIDCFGR_SEM_EN)) { |
| 404 | /* Static CID mode */ |
| 405 | cid = FIELD_GET(RCC_CIDCFGR_SCID_MASK, cidcfgr); |
| 406 | if (cid != RCC_CID1) |
| 407 | return -EACCES; |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | /* Pass-list with semaphore mode */ |
| 412 | if (!(cidcfgr & RCC_CIDCFGR_SEMWLC1_EN)) |
| 413 | return -EACCES; |
| 414 | |
| 415 | semcr = readl(rcc_base + RCC_SEMCR(index)); |
| 416 | |
| 417 | cid = FIELD_GET(RCC_SEMCR_SEMCID_MASK, semcr); |
| 418 | if (cid != RCC_CID1) |
| 419 | return -EACCES; |
| 420 | |
| 421 | return 0; |
| 422 | } |
| 423 | |
| 424 | static int stm32mp25_check_security(struct udevice *dev, void __iomem *base, |
| 425 | const struct clock_config *cfg) |
| 426 | { |
| 427 | int ret = 0; |
| 428 | |
| 429 | if (cfg->sec_id != SECF_NONE) { |
| 430 | u32 index = (u32)cfg->sec_id; |
| 431 | |
| 432 | if (index & SEC_RIFSC_FLAG) |
| 433 | ret = stm32_rifsc_check_access_by_id(dev_ofnode(dev), |
| 434 | index & ~SEC_RIFSC_FLAG); |
| 435 | else |
| 436 | ret = stm32_rcc_get_access(dev, index); |
| 437 | } |
| 438 | |
| 439 | return ret; |
| 440 | } |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 441 | #define STM32_COMPOSITE_NODIV(_id, _name, _flags, _sec_id, _gate_id, _mux_id)\ |
| 442 | STM32_COMPOSITE(_id, _name, _flags, _sec_id, _gate_id, _mux_id, NO_STM32_DIV) |
| 443 | |
| 444 | static const struct clock_config stm32mp25_clock_cfg[] = { |
| 445 | /* ADC */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 446 | STM32_GATE(CK_BUS_ADC12, "ck_icn_p_adc12", "ck_icn_ls_mcu", 0, GATE_ADC12, |
| 447 | SEC_RIFSC(58)), |
| 448 | STM32_COMPOSITE_NODIV(CK_KER_ADC12, "ck_ker_adc12", 0, SEC_RIFSC(58), |
| 449 | GATE_ADC12, MUX_ADC12), |
| 450 | STM32_GATE(CK_BUS_ADC3, "ck_icn_p_adc3", "ck_icn_ls_mcu", 0, GATE_ADC3, SEC_RIFSC(59)), |
| 451 | STM32_COMPOSITE_NODIV(CK_KER_ADC3, "ck_ker_adc3", 0, SEC_RIFSC(59), GATE_ADC3, MUX_ADC3), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 452 | |
| 453 | /* ADF */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 454 | STM32_GATE(CK_BUS_ADF1, "ck_icn_p_adf1", "ck_icn_ls_mcu", 0, GATE_ADF1, SEC_RIFSC(55)), |
| 455 | STM32_GATE(CK_KER_ADF1, "ck_ker_adf1", "ck_flexgen_42", 0, GATE_ADF1, SEC_RIFSC(55)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 456 | |
| 457 | /* Camera */ |
| 458 | /* DCMI */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 459 | STM32_GATE(CK_BUS_CCI, "ck_icn_p_cci", "ck_icn_ls_mcu", 0, GATE_CCI, SEC_RIFSC(88)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 460 | |
| 461 | /* CSI-HOST */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 462 | STM32_GATE(CK_BUS_CSI, "ck_icn_p_csi", "ck_icn_apb4", 0, GATE_CSI, SEC_RIFSC(86)), |
| 463 | STM32_GATE(CK_KER_CSI, "ck_ker_csi", "ck_flexgen_29", 0, GATE_CSI, SEC_RIFSC(86)), |
| 464 | STM32_GATE(CK_KER_CSITXESC, "ck_ker_csitxesc", "ck_flexgen_30", 0, GATE_CSI, |
| 465 | SEC_RIFSC(86)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 466 | |
| 467 | /* CSI-PHY */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 468 | STM32_GATE(CK_KER_CSIPHY, "ck_ker_csiphy", "ck_flexgen_31", 0, GATE_CSI, |
| 469 | SEC_RIFSC(86)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 470 | |
| 471 | /* DCMIPP */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 472 | STM32_GATE(CK_BUS_DCMIPP, "ck_icn_p_dcmipp", "ck_icn_apb4", 0, GATE_DCMIPP, |
| 473 | SEC_RIFSC(87)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 474 | |
| 475 | /* CRC */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 476 | STM32_GATE(CK_BUS_CRC, "ck_icn_p_crc", "ck_icn_ls_mcu", 0, GATE_CRC, SEC_RIFSC(109)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 477 | |
| 478 | /* CRYP */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 479 | STM32_GATE(CK_BUS_CRYP1, "ck_icn_p_cryp1", "ck_icn_ls_mcu", 0, GATE_CRYP1, |
| 480 | SEC_RIFSC(96)), |
| 481 | STM32_GATE(CK_BUS_CRYP2, "ck_icn_p_cryp2", "ck_icn_ls_mcu", 0, GATE_CRYP2, |
| 482 | SEC_RIFSC(97)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 483 | |
| 484 | /* DBG & TRACE*/ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 485 | /* Trace and debug clocks are managed by SCMI */ |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 486 | |
| 487 | /* Display subsystem */ |
| 488 | /* LTDC */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 489 | STM32_GATE(CK_BUS_LTDC, "ck_icn_p_ltdc", "ck_icn_apb4", 0, GATE_LTDC, SEC_RIFSC(80)), |
| 490 | STM32_GATE(CK_KER_LTDC, "ck_ker_ltdc", "ck_flexgen_27", CLK_SET_RATE_PARENT, GATE_LTDC, |
| 491 | SEC_RIFSC(80)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 492 | |
| 493 | /* DSI */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 494 | STM32_GATE(CK_BUS_DSI, "ck_icn_p_dsi", "ck_icn_apb4", 0, GATE_DSI, SEC_RIFSC(81)), |
| 495 | STM32_COMPOSITE_NODIV(CK_KER_DSIBLANE, "clk_lanebyte", 0, SEC_RIFSC(81), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 496 | GATE_DSI, MUX_DSIBLANE), |
| 497 | |
| 498 | /* LVDS */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 499 | STM32_GATE(CK_BUS_LVDS, "ck_icn_p_lvds", "ck_icn_apb4", 0, GATE_LVDS, SEC_RIFSC(84)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 500 | |
| 501 | /* DSI PHY */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 502 | STM32_COMPOSITE_NODIV(CK_KER_DSIPHY, "ck_ker_dsiphy", 0, SEC_RIFSC(81), |
| 503 | GATE_DSI, MUX_DSIPHY), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 504 | |
| 505 | /* LVDS PHY */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 506 | STM32_COMPOSITE_NODIV(CK_KER_LVDSPHY, "ck_ker_lvdsphy", 0, SEC_RIFSC(84), |
| 507 | GATE_LVDS, MUX_LVDSPHY), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 508 | |
| 509 | /* DTS */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 510 | STM32_COMPOSITE_NODIV(CK_KER_DTS, "ck_ker_dts", 0, SEC_RIFSC(107), GATE_DTS, MUX_DTS), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 511 | |
| 512 | /* ETHERNET */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 513 | STM32_GATE(CK_BUS_ETH1, "ck_icn_p_eth1", "ck_icn_ls_mcu", 0, GATE_ETH1, SEC_RIFSC(60)), |
| 514 | STM32_GATE(CK_ETH1_STP, "ck_ker_eth1stp", "ck_icn_ls_mcu", 0, GATE_ETH1STP, |
| 515 | SEC_RIFSC(60)), |
| 516 | STM32_GATE(CK_KER_ETH1, "ck_ker_eth1", "ck_flexgen_54", 0, GATE_ETH1, SEC_RIFSC(60)), |
| 517 | STM32_GATE(CK_KER_ETH1, "ck_ker_eth1ptp", "ck_flexgen_56", 0, GATE_ETH1, SEC_RIFSC(60)), |
| 518 | STM32_GATE(CK_ETH1_MAC, "ck_ker_eth1mac", "ck_icn_ls_mcu", 0, GATE_ETH1MAC, |
| 519 | SEC_RIFSC(60)), |
| 520 | STM32_GATE(CK_ETH1_TX, "ck_ker_eth1tx", "ck_icn_ls_mcu", 0, GATE_ETH1TX, SEC_RIFSC(60)), |
| 521 | STM32_GATE(CK_ETH1_RX, "ck_ker_eth1rx", "ck_icn_ls_mcu", 0, GATE_ETH1RX, SEC_RIFSC(60)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 522 | |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 523 | STM32_GATE(CK_BUS_ETH2, "ck_icn_p_eth2", "ck_icn_ls_mcu", 0, GATE_ETH2, SEC_RIFSC(61)), |
| 524 | STM32_GATE(CK_ETH2_STP, "ck_ker_eth2stp", "ck_icn_ls_mcu", 0, GATE_ETH2STP, |
| 525 | SEC_RIFSC(61)), |
| 526 | STM32_GATE(CK_KER_ETH2, "ck_ker_eth2", "ck_flexgen_54", 0, GATE_ETH2, SEC_RIFSC(61)), |
| 527 | STM32_GATE(CK_KER_ETH2, "ck_ker_eth2ptp", "ck_flexgen_56", 0, GATE_ETH2, SEC_RIFSC(61)), |
| 528 | STM32_GATE(CK_ETH2_MAC, "ck_ker_eth2mac", "ck_icn_ls_mcu", 0, GATE_ETH2MAC, |
| 529 | SEC_RIFSC(61)), |
| 530 | STM32_GATE(CK_ETH2_TX, "ck_ker_eth2tx", "ck_icn_ls_mcu", 0, GATE_ETH2TX, SEC_RIFSC(61)), |
| 531 | STM32_GATE(CK_ETH2_RX, "ck_ker_eth2rx", "ck_icn_ls_mcu", 0, GATE_ETH2RX, SEC_RIFSC(61)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 532 | |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 533 | STM32_GATE(CK_BUS_ETHSW, "ck_icn_p_ethsw", "ck_icn_ls_mcu", 0, GATE_ETHSWMAC, |
| 534 | SEC_RIFSC(70)), |
| 535 | STM32_GATE(CK_KER_ETHSW, "ck_ker_ethsw", "ck_flexgen_54", 0, GATE_ETHSW, |
| 536 | SEC_RIFSC(70)), |
| 537 | STM32_GATE(CK_KER_ETHSWREF, "ck_ker_ethswref", "ck_flexgen_60", 0, GATE_ETHSWREF, |
| 538 | SEC_RIFSC(70)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 539 | |
| 540 | /* FDCAN */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 541 | STM32_GATE(CK_BUS_FDCAN, "ck_icn_p_fdcan", "ck_icn_apb2", 0, GATE_FDCAN, SEC_RIFSC(56)), |
| 542 | STM32_GATE(CK_KER_FDCAN, "ck_ker_fdcan", "ck_flexgen_26", 0, GATE_FDCAN, SEC_RIFSC(56)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 543 | |
| 544 | /* GPU */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 545 | STM32_GATE(CK_BUS_GPU, "ck_icn_m_gpu", "ck_flexgen_59", 0, GATE_GPU, SEC_RIFSC(79)), |
| 546 | STM32_GATE(CK_KER_GPU, "ck_ker_gpu", "ck_pll3", 0, GATE_GPU, SEC_RIFSC(79)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 547 | |
| 548 | /* HASH */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 549 | STM32_GATE(CK_BUS_HASH, "ck_icn_p_hash", "ck_icn_ls_mcu", 0, GATE_HASH, SEC_RIFSC(95)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 550 | |
| 551 | /* HDP */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 552 | STM32_GATE(CK_BUS_HDP, "ck_icn_p_hdp", "ck_icn_apb3", 0, GATE_HDP, SEC_RIFSC(57)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 553 | |
| 554 | /* I2C */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 555 | STM32_GATE(CK_KER_I2C1, "ck_ker_i2c1", "ck_flexgen_12", 0, GATE_I2C1, SEC_RIFSC(41)), |
| 556 | STM32_GATE(CK_KER_I2C2, "ck_ker_i2c2", "ck_flexgen_12", 0, GATE_I2C2, SEC_RIFSC(42)), |
| 557 | STM32_GATE(CK_KER_I2C3, "ck_ker_i2c3", "ck_flexgen_13", 0, GATE_I2C3, SEC_RIFSC(43)), |
| 558 | STM32_GATE(CK_KER_I2C5, "ck_ker_i2c5", "ck_flexgen_13", 0, GATE_I2C5, SEC_RIFSC(45)), |
| 559 | STM32_GATE(CK_KER_I2C4, "ck_ker_i2c4", "ck_flexgen_14", 0, GATE_I2C4, SEC_RIFSC(44)), |
| 560 | STM32_GATE(CK_KER_I2C6, "ck_ker_i2c6", "ck_flexgen_14", 0, GATE_I2C6, SEC_RIFSC(46)), |
| 561 | STM32_GATE(CK_KER_I2C7, "ck_ker_i2c7", "ck_flexgen_15", 0, GATE_I2C7, SEC_RIFSC(47)), |
| 562 | STM32_GATE(CK_KER_I2C8, "ck_ker_i2c8", "ck_flexgen_38", 0, GATE_I2C8, SEC_RIFSC(48)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 563 | |
| 564 | /* I3C */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 565 | STM32_GATE(CK_KER_I3C1, "ck_ker_i3c1", "ck_flexgen_12", 0, GATE_I3C1, SEC_RIFSC(114)), |
| 566 | STM32_GATE(CK_KER_I3C2, "ck_ker_i3c2", "ck_flexgen_12", 0, GATE_I3C2, SEC_RIFSC(115)), |
| 567 | STM32_GATE(CK_KER_I3C3, "ck_ker_i3c3", "ck_flexgen_13", 0, GATE_I3C3, SEC_RIFSC(116)), |
| 568 | STM32_GATE(CK_KER_I3C4, "ck_ker_i3c4", "ck_flexgen_36", 0, GATE_I3C4, SEC_RIFSC(117)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 569 | |
| 570 | /* I2S */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 571 | STM32_GATE(CK_BUS_IS2M, "ck_icn_p_is2m", "ck_icn_apb3", 0, GATE_IS2M, SEC_RIFRCC(IS2M)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 572 | |
| 573 | /* IWDG */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 574 | STM32_GATE(CK_BUS_IWDG1, "ck_icn_p_iwdg1", "ck_icn_apb3", 0, GATE_IWDG1, SEC_RIFSC(98)), |
| 575 | STM32_GATE(CK_BUS_IWDG2, "ck_icn_p_iwdg2", "ck_icn_apb3", 0, GATE_IWDG2, SEC_RIFSC(99)), |
| 576 | STM32_GATE(CK_BUS_IWDG3, "ck_icn_p_iwdg3", "ck_icn_apb3", 0, GATE_IWDG3, SEC_RIFSC(100)), |
| 577 | STM32_GATE(CK_BUS_IWDG4, "ck_icn_p_iwdg4", "ck_icn_apb3", 0, GATE_IWDG4, SEC_RIFSC(101)), |
| 578 | STM32_GATE(CK_BUS_IWDG5, "ck_icn_p_iwdg5", "ck_icn_ls_mcu", 0, GATE_IWDG5, |
| 579 | SEC_RIFSC(102)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 580 | |
| 581 | /* LPTIM */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 582 | STM32_GATE(CK_KER_LPTIM1, "ck_ker_lptim1", "ck_flexgen_07", 0, GATE_LPTIM1, |
| 583 | SEC_RIFSC(17)), |
| 584 | STM32_GATE(CK_KER_LPTIM2, "ck_ker_lptim2", "ck_flexgen_07", 0, GATE_LPTIM2, |
| 585 | SEC_RIFSC(18)), |
| 586 | STM32_GATE(CK_KER_LPTIM3, "ck_ker_lptim3", "ck_flexgen_40", 0, GATE_LPTIM3, |
| 587 | SEC_RIFSC(19)), |
| 588 | STM32_GATE(CK_KER_LPTIM4, "ck_ker_lptim4", "ck_flexgen_41", 0, GATE_LPTIM4, |
| 589 | SEC_RIFSC(20)), |
| 590 | STM32_GATE(CK_KER_LPTIM5, "ck_ker_lptim5", "ck_flexgen_41", 0, GATE_LPTIM5, |
| 591 | SEC_RIFSC(21)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 592 | |
| 593 | /* LPUART */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 594 | STM32_GATE(CK_KER_LPUART1, "ck_ker_lpuart1", "ck_flexgen_39", 0, GATE_LPUART1, |
| 595 | SEC_RIFSC(40)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 596 | |
| 597 | /* MCO1 & MCO2 */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 598 | STM32_COMPOSITE_NODIV(CK_MCO1, "ck_mco1", 0, SEC_RIFRCC(MCO1), GATE_MCO1, MUX_MCO1), |
| 599 | STM32_COMPOSITE_NODIV(CK_MCO2, "ck_mco2", 0, SEC_RIFRCC(MCO2), GATE_MCO2, MUX_MCO2), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 600 | |
| 601 | /* MDF */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 602 | STM32_GATE(CK_KER_MDF1, "ck_ker_mdf1", "ck_flexgen_23", 0, GATE_MDF1, SEC_RIFSC(54)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 603 | |
| 604 | /* OCTOSPI */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 605 | STM32_GATE(CK_BUS_OSPIIOM, "ck_icn_p_ospiiom", "ck_icn_ls_mcu", 0, GATE_OSPIIOM, |
| 606 | SEC_RIFSC(111)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 607 | |
| 608 | /* PCIE */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 609 | STM32_GATE(CK_BUS_PCIE, "ck_icn_p_pcie", "ck_icn_ls_mcu", 0, GATE_PCIE, SEC_RIFSC(68)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 610 | |
| 611 | /* PKA */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 612 | STM32_GATE(CK_BUS_PKA, "ck_icn_p_pka", "ck_icn_ls_mcu", 0, GATE_PKA, SEC_RIFSC(93)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 613 | |
| 614 | /* RNG */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 615 | STM32_GATE(CK_BUS_RNG, "ck_icn_p_rng", "ck_icn_ls_mcu", CLK_IGNORE_UNUSED, GATE_RNG, |
| 616 | SEC_RIFSC(92)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 617 | |
| 618 | /* SAES */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 619 | STM32_GATE(CK_BUS_SAES, "ck_icn_p_saes", "ck_icn_ls_mcu", 0, GATE_SAES, SEC_RIFSC(94)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 620 | |
| 621 | /* SAI [1..4] */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 622 | STM32_GATE(CK_BUS_SAI1, "ck_icn_p_sai1", "ck_icn_apb2", 0, GATE_SAI1, SEC_RIFSC(49)), |
| 623 | STM32_GATE(CK_BUS_SAI2, "ck_icn_p_sai2", "ck_icn_apb2", 0, GATE_SAI2, SEC_RIFSC(50)), |
| 624 | STM32_GATE(CK_BUS_SAI3, "ck_icn_p_sai3", "ck_icn_apb2", 0, GATE_SAI3, SEC_RIFSC(51)), |
| 625 | STM32_GATE(CK_BUS_SAI4, "ck_icn_p_sai4", "ck_icn_apb2", 0, GATE_SAI4, SEC_RIFSC(52)), |
| 626 | STM32_GATE(CK_KER_SAI1, "ck_ker_sai1", "ck_flexgen_23", 0, GATE_SAI1, SEC_RIFSC(49)), |
| 627 | STM32_GATE(CK_KER_SAI2, "ck_ker_sai2", "ck_flexgen_24", 0, GATE_SAI2, SEC_RIFSC(50)), |
| 628 | STM32_GATE(CK_KER_SAI3, "ck_ker_sai3", "ck_flexgen_25", 0, GATE_SAI3, SEC_RIFSC(51)), |
| 629 | STM32_GATE(CK_KER_SAI4, "ck_ker_sai4", "ck_flexgen_25", 0, GATE_SAI4, SEC_RIFSC(52)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 630 | |
| 631 | /* SDMMC */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 632 | STM32_GATE(CK_KER_SDMMC1, "ck_ker_sdmmc1", "ck_flexgen_51", 0, GATE_SDMMC1, |
| 633 | SEC_RIFSC(76)), |
| 634 | STM32_GATE(CK_KER_SDMMC2, "ck_ker_sdmmc2", "ck_flexgen_52", 0, GATE_SDMMC2, |
| 635 | SEC_RIFSC(77)), |
| 636 | STM32_GATE(CK_KER_SDMMC3, "ck_ker_sdmmc3", "ck_flexgen_53", 0, GATE_SDMMC3, |
| 637 | SEC_RIFSC(78)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 638 | |
| 639 | /* SERC */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 640 | STM32_GATE(CK_BUS_SERC, "ck_icn_p_serc", "ck_icn_apb3", 0, GATE_SERC, SEC_RIFSC(110)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 641 | |
| 642 | /* SPDIF */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 643 | STM32_GATE(CK_KER_SPDIFRX, "ck_ker_spdifrx", "ck_flexgen_11", 0, GATE_SPDIFRX, |
| 644 | SEC_RIFSC(30)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 645 | |
| 646 | /* SPI */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 647 | STM32_GATE(CK_KER_SPI1, "ck_ker_spi1", "ck_flexgen_16", 0, GATE_SPI1, SEC_RIFSC(22)), |
| 648 | STM32_GATE(CK_KER_SPI2, "ck_ker_spi2", "ck_flexgen_10", 0, GATE_SPI2, SEC_RIFSC(23)), |
| 649 | STM32_GATE(CK_KER_SPI3, "ck_ker_spi3", "ck_flexgen_10", 0, GATE_SPI3, SEC_RIFSC(24)), |
| 650 | STM32_GATE(CK_KER_SPI4, "ck_ker_spi4", "ck_flexgen_17", 0, GATE_SPI4, SEC_RIFSC(25)), |
| 651 | STM32_GATE(CK_KER_SPI5, "ck_ker_spi5", "ck_flexgen_17", 0, GATE_SPI5, SEC_RIFSC(26)), |
| 652 | STM32_GATE(CK_KER_SPI6, "ck_ker_spi6", "ck_flexgen_18", 0, GATE_SPI6, SEC_RIFSC(27)), |
| 653 | STM32_GATE(CK_KER_SPI7, "ck_ker_spi7", "ck_flexgen_18", 0, GATE_SPI7, SEC_RIFSC(28)), |
| 654 | STM32_GATE(CK_KER_SPI8, "ck_ker_spi8", "ck_flexgen_37", 0, GATE_SPI8, SEC_RIFSC(29)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 655 | |
| 656 | /* STGEN */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 657 | STM32_GATE(CK_KER_STGEN, "ck_ker_stgen", "ck_flexgen_33", CLK_IGNORE_UNUSED, GATE_STGEN, |
| 658 | SEC_RIFSC(73)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 659 | |
| 660 | /* Timers */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 661 | STM32_GATE(CK_KER_TIM2, "ck_ker_tim2", "timg1_ck", 0, GATE_TIM2, SEC_RIFSC(1)), |
| 662 | STM32_GATE(CK_KER_TIM3, "ck_ker_tim3", "timg1_ck", 0, GATE_TIM3, SEC_RIFSC(2)), |
| 663 | STM32_GATE(CK_KER_TIM4, "ck_ker_tim4", "timg1_ck", 0, GATE_TIM4, SEC_RIFSC(3)), |
| 664 | STM32_GATE(CK_KER_TIM5, "ck_ker_tim5", "timg1_ck", 0, GATE_TIM5, SEC_RIFSC(4)), |
| 665 | STM32_GATE(CK_KER_TIM6, "ck_ker_tim6", "timg1_ck", 0, GATE_TIM6, SEC_RIFSC(5)), |
| 666 | STM32_GATE(CK_KER_TIM7, "ck_ker_tim7", "timg1_ck", 0, GATE_TIM7, SEC_RIFSC(6)), |
| 667 | STM32_GATE(CK_KER_TIM10, "ck_ker_tim10", "timg1_ck", 0, GATE_TIM10, SEC_RIFSC(8)), |
| 668 | STM32_GATE(CK_KER_TIM11, "ck_ker_tim11", "timg1_ck", 0, GATE_TIM11, SEC_RIFSC(9)), |
| 669 | STM32_GATE(CK_KER_TIM12, "ck_ker_tim12", "timg1_ck", 0, GATE_TIM12, SEC_RIFSC(10)), |
| 670 | STM32_GATE(CK_KER_TIM13, "ck_ker_tim13", "timg1_ck", 0, GATE_TIM13, SEC_RIFSC(11)), |
| 671 | STM32_GATE(CK_KER_TIM14, "ck_ker_tim14", "timg1_ck", 0, GATE_TIM14, SEC_RIFSC(12)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 672 | |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 673 | STM32_GATE(CK_KER_TIM1, "ck_ker_tim1", "timg2_ck", 0, GATE_TIM1, SEC_RIFSC(0)), |
| 674 | STM32_GATE(CK_KER_TIM8, "ck_ker_tim8", "timg2_ck", 0, GATE_TIM8, SEC_RIFSC(7)), |
| 675 | STM32_GATE(CK_KER_TIM15, "ck_ker_tim15", "timg2_ck", 0, GATE_TIM15, SEC_RIFSC(13)), |
| 676 | STM32_GATE(CK_KER_TIM16, "ck_ker_tim16", "timg2_ck", 0, GATE_TIM16, SEC_RIFSC(14)), |
| 677 | STM32_GATE(CK_KER_TIM17, "ck_ker_tim17", "timg2_ck", 0, GATE_TIM17, SEC_RIFSC(15)), |
| 678 | STM32_GATE(CK_KER_TIM20, "ck_ker_tim20", "timg2_ck", 0, GATE_TIM20, SEC_RIFSC(20)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 679 | |
| 680 | /* UART/USART */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 681 | STM32_GATE(CK_KER_USART2, "ck_ker_usart2", "ck_flexgen_08", 0, GATE_USART2, |
| 682 | SEC_RIFSC(32)), |
| 683 | STM32_GATE(CK_KER_UART4, "ck_ker_uart4", "ck_flexgen_08", 0, GATE_UART4, |
| 684 | SEC_RIFSC(34)), |
| 685 | STM32_GATE(CK_KER_USART3, "ck_ker_usart3", "ck_flexgen_09", 0, GATE_USART3, |
| 686 | SEC_RIFSC(33)), |
| 687 | STM32_GATE(CK_KER_UART5, "ck_ker_uart5", "ck_flexgen_09", 0, GATE_UART5, |
| 688 | SEC_RIFSC(35)), |
| 689 | STM32_GATE(CK_KER_USART1, "ck_ker_usart1", "ck_flexgen_19", 0, GATE_USART1, |
| 690 | SEC_RIFSC(31)), |
| 691 | STM32_GATE(CK_KER_USART6, "ck_ker_usart6", "ck_flexgen_20", 0, GATE_USART6, |
| 692 | SEC_RIFSC(36)), |
| 693 | STM32_GATE(CK_KER_UART7, "ck_ker_uart7", "ck_flexgen_21", 0, GATE_UART7, |
| 694 | SEC_RIFSC(37)), |
| 695 | STM32_GATE(CK_KER_UART8, "ck_ker_uart8", "ck_flexgen_21", 0, GATE_UART8, |
| 696 | SEC_RIFSC(38)), |
| 697 | STM32_GATE(CK_KER_UART9, "ck_ker_uart9", "ck_flexgen_22", 0, GATE_UART9, |
| 698 | SEC_RIFSC(39)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 699 | |
| 700 | /* USB2PHY1 */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 701 | STM32_COMPOSITE_NODIV(CK_KER_USB2PHY1, "ck_ker_usb2phy1", 0, SEC_RIFSC(63), |
| 702 | GATE_USB2PHY1, MUX_USB2PHY1), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 703 | |
| 704 | /* USBH */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 705 | STM32_GATE(CK_BUS_USB2OHCI, "ck_icn_m_usb2ohci", "ck_icn_hsl", 0, GATE_USBH, |
| 706 | SEC_RIFSC(63)), |
| 707 | STM32_GATE(CK_BUS_USB2EHCI, "ck_icn_m_usb2ehci", "ck_icn_hsl", 0, GATE_USBH, |
| 708 | SEC_RIFSC(63)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 709 | |
| 710 | /* USB2PHY2 */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 711 | STM32_COMPOSITE_NODIV(CK_KER_USB2PHY2EN, "ck_ker_usb2phy2_en", 0, SEC_RIFSC(66), |
| 712 | GATE_USB2PHY2, MUX_USB2PHY2), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 713 | |
| 714 | /* USB3 PCIe COMBOPHY */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 715 | STM32_GATE(CK_BUS_USB3PCIEPHY, "ck_icn_p_usb3pciephy", "ck_icn_apb4", 0, GATE_USB3PCIEPHY, |
| 716 | SEC_RIFSC(67)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 717 | |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 718 | STM32_COMPOSITE_NODIV(CK_KER_USB3PCIEPHY, "ck_ker_usb3pciephy", 0, SEC_RIFSC(67), |
| 719 | GATE_USB3PCIEPHY, MUX_USB3PCIEPHY), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 720 | |
| 721 | /* USB3 DRD */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 722 | STM32_GATE(CK_BUS_USB3DR, "ck_icn_m_usb3dr", "ck_icn_hsl", 0, GATE_USB3DR, |
| 723 | SEC_RIFSC(66)), |
| 724 | STM32_GATE(CK_KER_USB2PHY2, "ck_ker_usb2phy2", "ck_flexgen_58", 0, GATE_USB3DR, |
| 725 | SEC_RIFSC(66)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 726 | |
| 727 | /* UCPD */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 728 | STM32_GATE(CK_BUS_USBTC, "ck_icn_p_usbtc", "ck_flexgen_35", 0, GATE_USBTC, |
| 729 | SEC_RIFSC(69)), |
| 730 | STM32_GATE(CK_KER_USBTC, "ck_ker_usbtc", "ck_flexgen_35", 0, GATE_USBTC, |
| 731 | SEC_RIFSC(69)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 732 | |
| 733 | /* VDEC / VENC */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 734 | STM32_GATE(CK_BUS_VDEC, "ck_icn_p_vdec", "ck_icn_apb4", 0, GATE_VDEC, SEC_RIFSC(89)), |
| 735 | STM32_GATE(CK_BUS_VENC, "ck_icn_p_venc", "ck_icn_apb4", 0, GATE_VENC, SEC_RIFSC(90)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 736 | |
| 737 | /* VREF */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 738 | STM32_GATE(CK_BUS_VREF, "ck_icn_p_vref", "ck_icn_apb3", 0, RCC_VREFCFGR, |
| 739 | SEC_RIFSC(106)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 740 | |
| 741 | /* WWDG */ |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 742 | STM32_GATE(CK_BUS_WWDG1, "ck_icn_p_wwdg1", "ck_icn_apb3", 0, GATE_WWDG1, |
| 743 | SEC_RIFSC(103)), |
| 744 | STM32_GATE(CK_BUS_WWDG2, "ck_icn_p_wwdg2", "ck_icn_ls_mcu", 0, GATE_WWDG2, |
| 745 | SEC_RIFSC(104)), |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 746 | }; |
| 747 | |
| 748 | static const struct stm32_clock_match_data stm32mp25_data = { |
| 749 | .tab_clocks = stm32mp25_clock_cfg, |
| 750 | .num_clocks = ARRAY_SIZE(stm32mp25_clock_cfg), |
| 751 | .clock_data = &(const struct clk_stm32_clock_data) { |
| 752 | .num_gates = ARRAY_SIZE(stm32mp25_gates), |
| 753 | .gates = stm32mp25_gates, |
| 754 | .muxes = stm32mp25_muxes, |
| 755 | }, |
Gabriel Fernandez | 299487c | 2025-05-27 15:27:45 +0200 | [diff] [blame^] | 756 | .check_security = stm32mp25_check_security, |
| 757 | |
Gabriel Fernandez | b676af2 | 2025-05-27 15:27:44 +0200 | [diff] [blame] | 758 | }; |
| 759 | |
| 760 | static int stm32mp25_clk_probe(struct udevice *dev) |
| 761 | { |
| 762 | fdt_addr_t base = dev_read_addr(dev->parent); |
| 763 | struct udevice *scmi; |
| 764 | |
| 765 | if (base == FDT_ADDR_T_NONE) |
| 766 | return -EINVAL; |
| 767 | |
| 768 | /* force SCMI probe to register all SCMI clocks */ |
| 769 | uclass_get_device_by_driver(UCLASS_CLK, DM_DRIVER_GET(scmi_clock), &scmi); |
| 770 | |
| 771 | stm32_rcc_init(dev, &stm32mp25_data); |
| 772 | |
| 773 | return 0; |
| 774 | } |
| 775 | |
| 776 | U_BOOT_DRIVER(stm32mp25_clock) = { |
| 777 | .name = "stm32mp25_clk", |
| 778 | .id = UCLASS_CLK, |
| 779 | .ops = &stm32_clk_ops, |
| 780 | .priv_auto = sizeof(struct stm32mp_rcc_priv), |
| 781 | .probe = stm32mp25_clk_probe, |
| 782 | }; |