1*c66ec88fSEmmanuel VadotSTMicroelectronics STM32 Reset and Clock Controller 2*c66ec88fSEmmanuel Vadot=================================================== 3*c66ec88fSEmmanuel Vadot 4*c66ec88fSEmmanuel VadotThe RCC IP is both a reset and a clock controller. 5*c66ec88fSEmmanuel Vadot 6*c66ec88fSEmmanuel VadotPlease refer to clock-bindings.txt for common clock controller binding usage. 7*c66ec88fSEmmanuel VadotPlease also refer to reset.txt for common reset controller binding usage. 8*c66ec88fSEmmanuel Vadot 9*c66ec88fSEmmanuel VadotRequired properties: 10*c66ec88fSEmmanuel Vadot- compatible: Should be: 11*c66ec88fSEmmanuel Vadot "st,stm32f42xx-rcc" 12*c66ec88fSEmmanuel Vadot "st,stm32f469-rcc" 13*c66ec88fSEmmanuel Vadot "st,stm32f746-rcc" 14*c66ec88fSEmmanuel Vadot "st,stm32f769-rcc" 15*c66ec88fSEmmanuel Vadot 16*c66ec88fSEmmanuel Vadot- reg: should be register base and length as documented in the 17*c66ec88fSEmmanuel Vadot datasheet 18*c66ec88fSEmmanuel Vadot- #reset-cells: 1, see below 19*c66ec88fSEmmanuel Vadot- #clock-cells: 2, device nodes should specify the clock in their "clocks" 20*c66ec88fSEmmanuel Vadot property, containing a phandle to the clock device node, an index selecting 21*c66ec88fSEmmanuel Vadot between gated clocks and other clocks and an index specifying the clock to 22*c66ec88fSEmmanuel Vadot use. 23*c66ec88fSEmmanuel Vadot- clocks: External oscillator clock phandle 24*c66ec88fSEmmanuel Vadot - high speed external clock signal (HSE) 25*c66ec88fSEmmanuel Vadot - external I2S clock (I2S_CKIN) 26*c66ec88fSEmmanuel Vadot 27*c66ec88fSEmmanuel VadotExample: 28*c66ec88fSEmmanuel Vadot 29*c66ec88fSEmmanuel Vadot rcc: rcc@40023800 { 30*c66ec88fSEmmanuel Vadot #reset-cells = <1>; 31*c66ec88fSEmmanuel Vadot #clock-cells = <2> 32*c66ec88fSEmmanuel Vadot compatible = "st,stm32f42xx-rcc", "st,stm32-rcc"; 33*c66ec88fSEmmanuel Vadot reg = <0x40023800 0x400>; 34*c66ec88fSEmmanuel Vadot clocks = <&clk_hse>, <&clk_i2s_ckin>; 35*c66ec88fSEmmanuel Vadot }; 36*c66ec88fSEmmanuel Vadot 37*c66ec88fSEmmanuel VadotSpecifying gated clocks 38*c66ec88fSEmmanuel Vadot======================= 39*c66ec88fSEmmanuel Vadot 40*c66ec88fSEmmanuel VadotThe primary index must be set to 0. 41*c66ec88fSEmmanuel Vadot 42*c66ec88fSEmmanuel VadotThe secondary index is the bit number within the RCC register bank, starting 43*c66ec88fSEmmanuel Vadotfrom the first RCC clock enable register (RCC_AHB1ENR, address offset 0x30). 44*c66ec88fSEmmanuel Vadot 45*c66ec88fSEmmanuel VadotIt is calculated as: index = register_offset / 4 * 32 + bit_offset. 46*c66ec88fSEmmanuel VadotWhere bit_offset is the bit offset within the register (LSB is 0, MSB is 31). 47*c66ec88fSEmmanuel Vadot 48*c66ec88fSEmmanuel VadotTo simplify the usage and to share bit definition with the reset and clock 49*c66ec88fSEmmanuel Vadotdrivers of the RCC IP, macros are available to generate the index in 50*c66ec88fSEmmanuel Vadothuman-readble format. 51*c66ec88fSEmmanuel Vadot 52*c66ec88fSEmmanuel VadotFor STM32F4 series, the macro are available here: 53*c66ec88fSEmmanuel Vadot - include/dt-bindings/mfd/stm32f4-rcc.h 54*c66ec88fSEmmanuel Vadot 55*c66ec88fSEmmanuel VadotExample: 56*c66ec88fSEmmanuel Vadot 57*c66ec88fSEmmanuel Vadot /* Gated clock, AHB1 bit 0 (GPIOA) */ 58*c66ec88fSEmmanuel Vadot ... { 59*c66ec88fSEmmanuel Vadot clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)> 60*c66ec88fSEmmanuel Vadot }; 61*c66ec88fSEmmanuel Vadot 62*c66ec88fSEmmanuel Vadot /* Gated clock, AHB2 bit 4 (CRYP) */ 63*c66ec88fSEmmanuel Vadot ... { 64*c66ec88fSEmmanuel Vadot clocks = <&rcc 0 STM32F4_AHB2_CLOCK(CRYP)> 65*c66ec88fSEmmanuel Vadot }; 66*c66ec88fSEmmanuel Vadot 67*c66ec88fSEmmanuel VadotSpecifying other clocks 68*c66ec88fSEmmanuel Vadot======================= 69*c66ec88fSEmmanuel Vadot 70*c66ec88fSEmmanuel VadotThe primary index must be set to 1. 71*c66ec88fSEmmanuel Vadot 72*c66ec88fSEmmanuel VadotThe secondary index is bound with the following magic numbers: 73*c66ec88fSEmmanuel Vadot 74*c66ec88fSEmmanuel Vadot 0 SYSTICK 75*c66ec88fSEmmanuel Vadot 1 FCLK 76*c66ec88fSEmmanuel Vadot 2 CLK_LSI (low-power clock source) 77*c66ec88fSEmmanuel Vadot 3 CLK_LSE (generated from a 32.768 kHz low-speed external 78*c66ec88fSEmmanuel Vadot crystal or ceramic resonator) 79*c66ec88fSEmmanuel Vadot 4 CLK_HSE_RTC (HSE division factor for RTC clock) 80*c66ec88fSEmmanuel Vadot 5 CLK_RTC (real-time clock) 81*c66ec88fSEmmanuel Vadot 6 PLL_VCO_I2S (vco frequency of I2S pll) 82*c66ec88fSEmmanuel Vadot 7 PLL_VCO_SAI (vco frequency of SAI pll) 83*c66ec88fSEmmanuel Vadot 8 CLK_LCD (LCD-TFT) 84*c66ec88fSEmmanuel Vadot 9 CLK_I2S (I2S clocks) 85*c66ec88fSEmmanuel Vadot 10 CLK_SAI1 (audio clocks) 86*c66ec88fSEmmanuel Vadot 11 CLK_SAI2 87*c66ec88fSEmmanuel Vadot 12 CLK_I2SQ_PDIV (post divisor of pll i2s q divisor) 88*c66ec88fSEmmanuel Vadot 13 CLK_SAIQ_PDIV (post divisor of pll sai q divisor) 89*c66ec88fSEmmanuel Vadot 90*c66ec88fSEmmanuel Vadot 14 CLK_HSI (Internal ocscillator clock) 91*c66ec88fSEmmanuel Vadot 15 CLK_SYSCLK (System Clock) 92*c66ec88fSEmmanuel Vadot 16 CLK_HDMI_CEC (HDMI-CEC clock) 93*c66ec88fSEmmanuel Vadot 17 CLK_SPDIF (SPDIF-Rx clock) 94*c66ec88fSEmmanuel Vadot 18 CLK_USART1 (U(s)arts clocks) 95*c66ec88fSEmmanuel Vadot 19 CLK_USART2 96*c66ec88fSEmmanuel Vadot 20 CLK_USART3 97*c66ec88fSEmmanuel Vadot 21 CLK_UART4 98*c66ec88fSEmmanuel Vadot 22 CLK_UART5 99*c66ec88fSEmmanuel Vadot 23 CLK_USART6 100*c66ec88fSEmmanuel Vadot 24 CLK_UART7 101*c66ec88fSEmmanuel Vadot 25 CLK_UART8 102*c66ec88fSEmmanuel Vadot 26 CLK_I2C1 (I2S clocks) 103*c66ec88fSEmmanuel Vadot 27 CLK_I2C2 104*c66ec88fSEmmanuel Vadot 28 CLK_I2C3 105*c66ec88fSEmmanuel Vadot 29 CLK_I2C4 106*c66ec88fSEmmanuel Vadot 30 CLK_LPTIMER (LPTimer1 clock) 107*c66ec88fSEmmanuel Vadot 31 CLK_PLL_SRC 108*c66ec88fSEmmanuel Vadot 32 CLK_DFSDM1 109*c66ec88fSEmmanuel Vadot 33 CLK_ADFSDM1 110*c66ec88fSEmmanuel Vadot 34 CLK_F769_DSI 111*c66ec88fSEmmanuel Vadot) 112*c66ec88fSEmmanuel Vadot 113*c66ec88fSEmmanuel VadotExample: 114*c66ec88fSEmmanuel Vadot 115*c66ec88fSEmmanuel Vadot /* Misc clock, FCLK */ 116*c66ec88fSEmmanuel Vadot ... { 117*c66ec88fSEmmanuel Vadot clocks = <&rcc 1 STM32F4_APB1_CLOCK(TIM2)> 118*c66ec88fSEmmanuel Vadot }; 119*c66ec88fSEmmanuel Vadot 120*c66ec88fSEmmanuel Vadot 121*c66ec88fSEmmanuel VadotSpecifying softreset control of devices 122*c66ec88fSEmmanuel Vadot======================================= 123*c66ec88fSEmmanuel Vadot 124*c66ec88fSEmmanuel VadotDevice nodes should specify the reset channel required in their "resets" 125*c66ec88fSEmmanuel Vadotproperty, containing a phandle to the reset device node and an index specifying 126*c66ec88fSEmmanuel Vadotwhich channel to use. 127*c66ec88fSEmmanuel VadotThe index is the bit number within the RCC registers bank, starting from RCC 128*c66ec88fSEmmanuel Vadotbase address. 129*c66ec88fSEmmanuel VadotIt is calculated as: index = register_offset / 4 * 32 + bit_offset. 130*c66ec88fSEmmanuel VadotWhere bit_offset is the bit offset within the register. 131*c66ec88fSEmmanuel VadotFor example, for CRC reset: 132*c66ec88fSEmmanuel Vadot crc = AHB1RSTR_offset / 4 * 32 + CRCRST_bit_offset = 0x10 / 4 * 32 + 12 = 140 133*c66ec88fSEmmanuel Vadot 134*c66ec88fSEmmanuel Vadotexample: 135*c66ec88fSEmmanuel Vadot 136*c66ec88fSEmmanuel Vadot timer2 { 137*c66ec88fSEmmanuel Vadot resets = <&rcc STM32F4_APB1_RESET(TIM2)>; 138*c66ec88fSEmmanuel Vadot }; 139