141655239SDaniel ThompsonSTMicroelectronics STM32 Reset and Clock Controller 241655239SDaniel Thompson=================================================== 341655239SDaniel Thompson 457bd63a4SMaxime CoquelinThe RCC IP is both a reset and a clock controller. 541655239SDaniel Thompson 657bd63a4SMaxime CoquelinPlease refer to clock-bindings.txt for common clock controller binding usage. 757bd63a4SMaxime CoquelinPlease also refer to reset.txt for common reset controller binding usage. 841655239SDaniel Thompson 941655239SDaniel ThompsonRequired properties: 10a064a07fSGabriel Fernandez- compatible: Should be: 11a064a07fSGabriel Fernandez "st,stm32f42xx-rcc" 12a064a07fSGabriel Fernandez "st,stm32f469-rcc" 1341655239SDaniel Thompson- reg: should be register base and length as documented in the 1441655239SDaniel Thompson datasheet 1557bd63a4SMaxime Coquelin- #reset-cells: 1, see below 1641655239SDaniel Thompson- #clock-cells: 2, device nodes should specify the clock in their "clocks" 1741655239SDaniel Thompson property, containing a phandle to the clock device node, an index selecting 1841655239SDaniel Thompson between gated clocks and other clocks and an index specifying the clock to 1941655239SDaniel Thompson use. 20*f8b50363SGabriel Fernandez- clocks: External oscillator clock phandle 21*f8b50363SGabriel Fernandez - high speed external clock signal (HSE) 22*f8b50363SGabriel Fernandez - external I2S clock (I2S_CKIN) 2341655239SDaniel Thompson 2441655239SDaniel ThompsonExample: 2541655239SDaniel Thompson 2641655239SDaniel Thompson rcc: rcc@40023800 { 2757bd63a4SMaxime Coquelin #reset-cells = <1>; 2841655239SDaniel Thompson #clock-cells = <2> 2941655239SDaniel Thompson compatible = "st,stm32f42xx-rcc", "st,stm32-rcc"; 3041655239SDaniel Thompson reg = <0x40023800 0x400>; 31*f8b50363SGabriel Fernandez clocks = <&clk_hse>, <&clk_i2s_ckin>; 3241655239SDaniel Thompson }; 3341655239SDaniel Thompson 3441655239SDaniel ThompsonSpecifying gated clocks 3541655239SDaniel Thompson======================= 3641655239SDaniel Thompson 3741655239SDaniel ThompsonThe primary index must be set to 0. 3841655239SDaniel Thompson 3941655239SDaniel ThompsonThe secondary index is the bit number within the RCC register bank, starting 4041655239SDaniel Thompsonfrom the first RCC clock enable register (RCC_AHB1ENR, address offset 0x30). 4141655239SDaniel Thompson 4241655239SDaniel ThompsonIt is calculated as: index = register_offset / 4 * 32 + bit_offset. 4341655239SDaniel ThompsonWhere bit_offset is the bit offset within the register (LSB is 0, MSB is 31). 4441655239SDaniel Thompson 4557bd63a4SMaxime CoquelinTo simplify the usage and to share bit definition with the reset and clock 4657bd63a4SMaxime Coquelindrivers of the RCC IP, macros are available to generate the index in 4757bd63a4SMaxime Coquelinhuman-readble format. 4857bd63a4SMaxime Coquelin 4957bd63a4SMaxime CoquelinFor STM32F4 series, the macro are available here: 5057bd63a4SMaxime Coquelin - include/dt-bindings/mfd/stm32f4-rcc.h 5157bd63a4SMaxime Coquelin 5241655239SDaniel ThompsonExample: 5341655239SDaniel Thompson 5441655239SDaniel Thompson /* Gated clock, AHB1 bit 0 (GPIOA) */ 5541655239SDaniel Thompson ... { 5657bd63a4SMaxime Coquelin clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)> 5741655239SDaniel Thompson }; 5841655239SDaniel Thompson 5941655239SDaniel Thompson /* Gated clock, AHB2 bit 4 (CRYP) */ 6041655239SDaniel Thompson ... { 6157bd63a4SMaxime Coquelin clocks = <&rcc 0 STM32F4_AHB2_CLOCK(CRYP)> 6241655239SDaniel Thompson }; 6341655239SDaniel Thompson 6441655239SDaniel ThompsonSpecifying other clocks 6541655239SDaniel Thompson======================= 6641655239SDaniel Thompson 6741655239SDaniel ThompsonThe primary index must be set to 1. 6841655239SDaniel Thompson 6941655239SDaniel ThompsonThe secondary index is bound with the following magic numbers: 7041655239SDaniel Thompson 7141655239SDaniel Thompson 0 SYSTICK 7241655239SDaniel Thompson 1 FCLK 73*f8b50363SGabriel Fernandez 2 CLK_LSI (low-power clock source) 74*f8b50363SGabriel Fernandez 3 CLK_LSE (generated from a 32.768 kHz low-speed external 75*f8b50363SGabriel Fernandez crystal or ceramic resonator) 76*f8b50363SGabriel Fernandez 4 CLK_HSE_RTC (HSE division factor for RTC clock) 77*f8b50363SGabriel Fernandez 5 CLK_RTC (real-time clock) 78*f8b50363SGabriel Fernandez 6 PLL_VCO_I2S (vco frequency of I2S pll) 79*f8b50363SGabriel Fernandez 7 PLL_VCO_SAI (vco frequency of SAI pll) 80*f8b50363SGabriel Fernandez 8 CLK_LCD (LCD-TFT) 81*f8b50363SGabriel Fernandez 9 CLK_I2S (I2S clocks) 82*f8b50363SGabriel Fernandez 10 CLK_SAI1 (audio clocks) 83*f8b50363SGabriel Fernandez 11 CLK_SAI2 84*f8b50363SGabriel Fernandez 12 CLK_I2SQ_PDIV (post divisor of pll i2s q divisor) 85*f8b50363SGabriel Fernandez 13 CLK_SAIQ_PDIV (post divisor of pll sai q divisor) 8641655239SDaniel Thompson 8741655239SDaniel ThompsonExample: 8841655239SDaniel Thompson 8941655239SDaniel Thompson /* Misc clock, FCLK */ 9041655239SDaniel Thompson ... { 9157bd63a4SMaxime Coquelin clocks = <&rcc 1 STM32F4_APB1_CLOCK(TIM2)> 9257bd63a4SMaxime Coquelin }; 9357bd63a4SMaxime Coquelin 9457bd63a4SMaxime Coquelin 9557bd63a4SMaxime CoquelinSpecifying softreset control of devices 9657bd63a4SMaxime Coquelin======================================= 9757bd63a4SMaxime Coquelin 9857bd63a4SMaxime CoquelinDevice nodes should specify the reset channel required in their "resets" 9957bd63a4SMaxime Coquelinproperty, containing a phandle to the reset device node and an index specifying 10057bd63a4SMaxime Coquelinwhich channel to use. 10157bd63a4SMaxime CoquelinThe index is the bit number within the RCC registers bank, starting from RCC 10257bd63a4SMaxime Coquelinbase address. 10357bd63a4SMaxime CoquelinIt is calculated as: index = register_offset / 4 * 32 + bit_offset. 10457bd63a4SMaxime CoquelinWhere bit_offset is the bit offset within the register. 10557bd63a4SMaxime CoquelinFor example, for CRC reset: 10657bd63a4SMaxime Coquelin crc = AHB1RSTR_offset / 4 * 32 + CRCRST_bit_offset = 0x10 / 4 * 32 + 12 = 140 10757bd63a4SMaxime Coquelin 10857bd63a4SMaxime Coquelinexample: 10957bd63a4SMaxime Coquelin 11057bd63a4SMaxime Coquelin timer2 { 11157bd63a4SMaxime Coquelin resets = <&rcc STM32F4_APB1_RESET(TIM2)>; 11241655239SDaniel Thompson }; 113