blob: e638bcef7bc80b9f30ae8d18342974ba05cc85b0 [file] [log] [blame]
Patrick Delaunayf11398e2018-03-12 10:46:16 +01001STMicroelectronics STM32MP1 clock tree initialization
2=====================================================
3
Patrick Delaunay09e1f602019-04-18 17:32:41 +02004The STM32MP1 clock tree initialization is based on device tree information
5for RCC IP node (st,stm32mp1-rcc) and on fixed-clock nodes.
Patrick Delaunayf11398e2018-03-12 10:46:16 +01006
Patrick Delaunay09e1f602019-04-18 17:32:41 +02007RCC IP = st,stm32mp1-rcc
8========================
Patrick Delaunayf11398e2018-03-12 10:46:16 +01009
10The RCC IP is both a reset and a clock controller but this documentation only
11describes the fields added for clock tree initialization which are not present
Patrick Delaunay09e1f602019-04-18 17:32:41 +020012in Linux binding for compatible "st,stm32mp1-rcc" defined in st,stm32mp1-rcc.txt
13file.
Patrick Delaunayf11398e2018-03-12 10:46:16 +010014
Patrick Delaunayc22caac2020-01-28 10:11:03 +010015This parent node may optionally have additional children nodes which define
16specific init values for RCC elements.
17
Patrick Delaunay09e1f602019-04-18 17:32:41 +020018The added properties for clock tree initialization are:
Patrick Delaunayf11398e2018-03-12 10:46:16 +010019
20Required properties:
Patrick Delaunay09e1f602019-04-18 17:32:41 +020021- st,clksrc : The clock sources configuration array in a platform specific
22 order.
Patrick Delaunayf11398e2018-03-12 10:46:16 +010023
Patrick Delaunay09e1f602019-04-18 17:32:41 +020024 For the STM32MP15x family there are 9 clock sources selector which are
25 configured in the following order:
26 MPU AXI MCU PLL12 PLL3 PLL4 RTC MCO1 MCO2
Patrick Delaunayf11398e2018-03-12 10:46:16 +010027
Patrick Delaunay09e1f602019-04-18 17:32:41 +020028 Clock source configuration values are defined by macros CLK_<NAME>_<SOURCE>
29 from dt-bindings/clock/stm32mp1-clksrc.h.
Patrick Delaunayf11398e2018-03-12 10:46:16 +010030
Patrick Delaunay09e1f602019-04-18 17:32:41 +020031 Example:
32 st,clksrc = <
33 CLK_MPU_PLL1P
34 CLK_AXI_PLL2P
35 CLK_MCU_PLL3P
36 CLK_PLL12_HSE
37 CLK_PLL3_HSE
38 CLK_PLL4_HSE
39 CLK_RTC_LSE
40 CLK_MCO1_DISABLED
41 CLK_MCO2_DISABLED
42 >;
Patrick Delaunayf11398e2018-03-12 10:46:16 +010043
Patrick Delaunay09e1f602019-04-18 17:32:41 +020044- st,clkdiv : The clock main dividers value specified in an array
45 in a platform specific order.
Patrick Delaunayf11398e2018-03-12 10:46:16 +010046
Patrick Delaunay09e1f602019-04-18 17:32:41 +020047 When used, it shall describe the whole clock dividers tree.
Patrick Delaunayf11398e2018-03-12 10:46:16 +010048
Patrick Delaunay09e1f602019-04-18 17:32:41 +020049 For the STM32MP15x family there are 11 dividers values expected.
50 They shall be configured in the following order:
51 MPU AXI MCU APB1 APB2 APB3 APB4 APB5 RTC MCO1 MCO2
Patrick Delaunayf11398e2018-03-12 10:46:16 +010052
Patrick Delaunay09e1f602019-04-18 17:32:41 +020053 The each divider value uses the DIV coding defined in RCC associated
54 register RCC_xxxDIVR. In most the case, it is:
Patrick Delaunayf11398e2018-03-12 10:46:16 +010055 0x0: not divided
56 0x1: division by 2
57 0x2: division by 4
58 0x3: division by 8
59 ...
60
Patrick Delaunay09e1f602019-04-18 17:32:41 +020061 Note that for RTC MCO1 MCO2, the coding is different:
Patrick Delaunayf11398e2018-03-12 10:46:16 +010062 0x0: not divided
63 0x1: division by 2
64 0x2: division by 3
65 0x3: division by 4
66 ...
67
Patrick Delaunay09e1f602019-04-18 17:32:41 +020068 Example:
69 st,clkdiv = <
70 1 /*MPU*/
71 0 /*AXI*/
72 0 /*MCU*/
73 1 /*APB1*/
74 1 /*APB2*/
75 1 /*APB3*/
76 1 /*APB4*/
77 2 /*APB5*/
78 23 /*RTC*/
79 0 /*MCO1*/
80 0 /*MCO2*/
81 >;
Patrick Delaunayf11398e2018-03-12 10:46:16 +010082
Patrick Delaunay09e1f602019-04-18 17:32:41 +020083Optional Properties:
Patrick Delaunayc22caac2020-01-28 10:11:03 +010084- children for a PLL configuration with "st,stm32mp1-pll" compatible
Patrick Delaunayf11398e2018-03-12 10:46:16 +010085
Patrick Delaunayc22caac2020-01-28 10:11:03 +010086 each PLL children nodes for PLL1 to PLL4 (see ref manual for details)
87 are listed with associated reg 0 to 3.
88 PLLx is off when the associated node is absent or deactivated.
Patrick Delaunayf11398e2018-03-12 10:46:16 +010089
Patrick Delaunay885bdc22020-05-25 12:19:44 +020090 For PLL1, when the node is absent, the frequency of the OPP node is used
91 to compute the PLL setting (see compatible "operating-points-v2" in
92 opp/opp.txt for details).
93
Patrick Delaunay09e1f602019-04-18 17:32:41 +020094 Here are the available properties for each PLL node:
Patrick Delaunayc22caac2020-01-28 10:11:03 +010095 - compatible: should be "st,stm32mp1-pll"
96
97 - reg: index of the pll instance
Patrick Delaunayf11398e2018-03-12 10:46:16 +010098
Patrick Delaunay09e1f602019-04-18 17:32:41 +020099 - cfg: The parameters for PLL configuration in the following order:
100 DIVM DIVN DIVP DIVQ DIVR Output.
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100101
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200102 DIVx values are defined as in RCC spec:
103 0x0: bypass (division by 1)
104 0x1: division by 2
105 0x2: division by 3
106 0x3: division by 4
107 ...
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100108
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200109 Output contains a bitfield for each output value (1:ON/0:OFF)
110 BIT(0) => output P : DIVPEN
111 BIT(1) => output Q : DIVQEN
112 BIT(2) => output R : DIVREN
113 NB: macro PQR(p,q,r) can be used to build this value
114 with p,q,r = 0 or 1.
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100115
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200116 - frac : Fractional part of the multiplication factor
117 (optional, PLL is in integer mode when absent).
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100118
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200119 - csg : Clock Spreading Generator (optional) with parameters in the
120 following order: MOD_PER INC_STEP SSCG_MODE.
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100121
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200122 MOD_PER: Modulation Period Adjustment
123 INC_STEP: Modulation Depth Adjustment
124 SSCG_MODE: Spread spectrum clock generator mode, with associated
125 defined from stm32mp1-clksrc.h:
126 - SSCG_MODE_CENTER_SPREAD = 0
127 - SSCG_MODE_DOWN_SPREAD = 1
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100128
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200129 Example:
130 st,pll@0 {
Patrick Delaunayc22caac2020-01-28 10:11:03 +0100131 compatible = "st,stm32mp1-pll";
132 reg = <0>;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200133 cfg = < 1 53 0 0 0 1 >;
134 frac = < 0x810 >;
135 };
136 st,pll@1 {
Patrick Delaunayc22caac2020-01-28 10:11:03 +0100137 compatible = "st,stm32mp1-pll";
138 reg = <1>;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200139 cfg = < 1 43 1 0 0 PQR(0,1,1) >;
140 csg = < 10 20 1 >;
141 };
142 st,pll@2 {
Patrick Delaunayc22caac2020-01-28 10:11:03 +0100143 compatible = "st,stm32mp1-pll";
144 reg = <2>;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200145 cfg = < 2 85 3 13 3 0 >;
146 csg = < 10 20 SSCG_MODE_CENTER_SPREAD >;
147 };
148 st,pll@3 {
Patrick Delaunayc22caac2020-01-28 10:11:03 +0100149 compatible = "st,stm32mp1-pll";
150 reg = <3>;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200151 cfg = < 2 78 4 7 9 3 >;
152 };
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100153
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200154- st,pkcs : used to configure the peripherals kernel clock selection.
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100155
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200156 The property is a list of peripheral kernel clock source identifiers defined
157 by macros CLK_<KERNEL-CLOCK>_<PARENT-CLOCK> as defined by header file
158 dt-bindings/clock/stm32mp1-clksrc.h.
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100159
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200160 st,pkcs may not list all the kernel clocks and has no ordering requirements.
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100161
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200162 Example:
163 st,pkcs = <
164 CLK_STGEN_HSE
165 CLK_CKPER_HSI
166 CLK_USBPHY_PLL2P
167 CLK_DSI_PLL2Q
168 CLK_I2C46_HSI
169 CLK_UART1_HSI
170 CLK_UART24_HSI
171 >;
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100172
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100173other clocks = fixed-clock
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200174==========================
175
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100176The clock tree is also based on 5 fixed-clock in clocks node
177used to define the state of associated ST32MP1 oscillators:
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200178 - clk-lsi
179 - clk-lse
180 - clk-hsi
181 - clk-hse
182 - clk-csi
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100183
184At boot the clock tree initialization will
Patrick Delaunaycaba1452019-07-30 19:16:19 +0200185 - enable oscillators present in device tree and not disabled
186 (node with status="disabled"),
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200187 - disable HSI oscillator if the node is absent (always activated by bootrom)
Patrick Delaunaycaba1452019-07-30 19:16:19 +0200188 and not disabled (node with status="disabled").
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100189
190Optional properties :
191
192a) for external oscillator: "clk-lse", "clk-hse"
193
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200194 4 optional fields are managed
195 - "st,bypass" configures the oscillator bypass mode (HSEBYP, LSEBYP)
196 - "st,digbypass" configures the bypass mode as full-swing digital
197 signal (DIGBYP)
198 - "st,css" activates the clock security system (HSECSSON, LSECSSON)
199 - "st,drive" (only for LSE) contains the value of the drive for the
200 oscillator (see LSEDRV_ defined in the file
201 dt-bindings/clock/stm32mp1-clksrc.h)
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100202
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200203 Example board file:
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100204 / {
205 clocks {
206 clk_hse: clk-hse {
207 #clock-cells = <0>;
208 compatible = "fixed-clock";
209 clock-frequency = <64000000>;
210 st,bypass;
211 };
212
213 clk_lse: clk-lse {
214 #clock-cells = <0>;
215 compatible = "fixed-clock";
216 clock-frequency = <32768>;
217 st,css;
218 st,drive = <LSEDRV_LOWEST>;
219 };
220 };
221
222b) for internal oscillator: "clk-hsi"
223
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200224 Internally HSI clock is fixed to 64MHz for STM32MP157 SoC.
225 In device tree, clk-hsi is the clock after HSIDIV (clk_hsi in RCC
226 doc). So this clock frequency is used to compute the expected HSI_DIV
227 for the clock tree initialization.
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100228
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200229 Example with HSIDIV = /1:
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100230 / {
231 clocks {
232 clk_hsi: clk-hsi {
233 #clock-cells = <0>;
234 compatible = "fixed-clock";
235 clock-frequency = <64000000>;
236 };
237 };
238
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200239 Example with HSIDIV = /2
Patrick Delaunayf11398e2018-03-12 10:46:16 +0100240 / {
241 clocks {
242 clk_hsi: clk-hsi {
243 #clock-cells = <0>;
244 compatible = "fixed-clock";
245 clock-frequency = <32000000>;
246 };
247 };
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200248
249Example of clock tree initialization
250====================================
251
252/ {
253 clocks {
Simon Glass07a8b622023-02-13 08:56:35 -0700254 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200255 clk_hse: clk-hse {
Simon Glass07a8b622023-02-13 08:56:35 -0700256 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200257 #clock-cells = <0>;
258 compatible = "fixed-clock";
259 clock-frequency = <24000000>;
260 st,digbypass;
261 };
262
263 clk_hsi: clk-hsi {
Simon Glass07a8b622023-02-13 08:56:35 -0700264 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200265 #clock-cells = <0>;
266 compatible = "fixed-clock";
267 clock-frequency = <64000000>;
268 };
269
270 clk_lse: clk-lse {
Simon Glass07a8b622023-02-13 08:56:35 -0700271 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200272 #clock-cells = <0>;
273 compatible = "fixed-clock";
274 clock-frequency = <32768>;
275 };
276
277 clk_lsi: clk-lsi {
Simon Glass07a8b622023-02-13 08:56:35 -0700278 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200279 #clock-cells = <0>;
280 compatible = "fixed-clock";
281 clock-frequency = <32000>;
282 };
283
284 clk_csi: clk-csi {
Simon Glass07a8b622023-02-13 08:56:35 -0700285 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200286 #clock-cells = <0>;
287 compatible = "fixed-clock";
288 clock-frequency = <4000000>;
289 };
290 };
291
292 soc {
293
294 rcc: rcc@50000000 {
Simon Glass07a8b622023-02-13 08:56:35 -0700295 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200296 compatible = "st,stm32mp1-rcc", "syscon";
297 reg = <0x50000000 0x1000>;
Patrick Delaunayc22caac2020-01-28 10:11:03 +0100298 #address-cells = <1>;
299 #size-cells = <0>;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200300 #clock-cells = <1>;
301 #reset-cells = <1>;
302 interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
303
304 st,clksrc = <
305 CLK_MPU_PLL1P
306 CLK_AXI_PLL2P
307 CLK_MCU_PLL3P
308 CLK_PLL12_HSE
309 CLK_PLL3_HSE
310 CLK_PLL4_HSE
311 CLK_RTC_LSE
312 CLK_MCO1_DISABLED
313 CLK_MCO2_DISABLED
314 >;
315
316 st,clkdiv = <
317 1 /*MPU*/
318 0 /*AXI*/
319 0 /*MCU*/
320 1 /*APB1*/
321 1 /*APB2*/
322 1 /*APB3*/
323 1 /*APB4*/
324 2 /*APB5*/
325 23 /*RTC*/
326 0 /*MCO1*/
327 0 /*MCO2*/
328 >;
329
330 st,pkcs = <
331 CLK_CKPER_HSE
332 CLK_FMC_ACLK
333 CLK_QSPI_ACLK
334 CLK_ETH_DISABLED
335 CLK_SDMMC12_PLL4P
336 CLK_DSI_DSIPLL
337 CLK_STGEN_HSE
338 CLK_USBPHY_HSE
339 CLK_SPI2S1_PLL3Q
340 CLK_SPI2S23_PLL3Q
341 CLK_SPI45_HSI
342 CLK_SPI6_HSI
343 CLK_I2C46_HSI
344 CLK_SDMMC3_PLL4P
345 CLK_USBO_USBPHY
346 CLK_ADC_CKPER
347 CLK_CEC_LSE
348 CLK_I2C12_HSI
349 CLK_I2C35_HSI
350 CLK_UART1_HSI
351 CLK_UART24_HSI
352 CLK_UART35_HSI
353 CLK_UART6_HSI
354 CLK_UART78_HSI
355 CLK_SPDIF_PLL4P
356 CLK_FDCAN_PLL4Q
357 CLK_SAI1_PLL3Q
358 CLK_SAI2_PLL3Q
359 CLK_SAI3_PLL3Q
360 CLK_SAI4_PLL3Q
361 CLK_RNG1_LSI
362 CLK_RNG2_LSI
363 CLK_LPTIM1_PCLK1
364 CLK_LPTIM23_PCLK3
365 CLK_LPTIM45_LSE
366 >;
367
368 /* VCO = 1300.0 MHz => P = 650 (CPU) */
369 pll1: st,pll@0 {
Patrick Delaunayc22caac2020-01-28 10:11:03 +0100370 compatible = "st,stm32mp1-pll";
371 reg = <0>;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200372 cfg = < 2 80 0 0 0 PQR(1,0,0) >;
373 frac = < 0x800 >;
Simon Glass07a8b622023-02-13 08:56:35 -0700374 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200375 };
376
377 /* VCO = 1066.0 MHz => P = 266 (AXI), Q = 533 (GPU),
378 R = 533 (DDR) */
379 pll2: st,pll@1 {
Patrick Delaunayc22caac2020-01-28 10:11:03 +0100380 compatible = "st,stm32mp1-pll";
381 reg = <1>;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200382 cfg = < 2 65 1 0 0 PQR(1,1,1) >;
383 frac = < 0x1400 >;
Simon Glass07a8b622023-02-13 08:56:35 -0700384 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200385 };
386
387 /* VCO = 417.8 MHz => P = 209, Q = 24, R = 11 */
388 pll3: st,pll@2 {
Patrick Delaunayc22caac2020-01-28 10:11:03 +0100389 compatible = "st,stm32mp1-pll";
390 reg = <2>;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200391 cfg = < 1 33 1 16 36 PQR(1,1,1) >;
392 frac = < 0x1a04 >;
Simon Glass07a8b622023-02-13 08:56:35 -0700393 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200394 };
395
396 /* VCO = 594.0 MHz => P = 99, Q = 74, R = 74 */
397 pll4: st,pll@3 {
Patrick Delaunayc22caac2020-01-28 10:11:03 +0100398 compatible = "st,stm32mp1-pll";
399 reg = <3>;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200400 cfg = < 3 98 5 7 7 PQR(1,1,1) >;
Simon Glass07a8b622023-02-13 08:56:35 -0700401 bootph-all;
Patrick Delaunay09e1f602019-04-18 17:32:41 +0200402 };
403 };
404 };
405};