1*4882a593SmuzhiyunSTMicroelectronics STM32 Reset and Clock Controller 2*4882a593Smuzhiyun=================================================== 3*4882a593Smuzhiyun 4*4882a593SmuzhiyunThe RCC IP is both a reset and a clock controller. 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunPlease refer to clock-bindings.txt for common clock controller binding usage. 7*4882a593SmuzhiyunPlease also refer to reset.txt for common reset controller binding usage. 8*4882a593Smuzhiyun 9*4882a593SmuzhiyunRequired properties: 10*4882a593Smuzhiyun- compatible: Should be: 11*4882a593Smuzhiyun "st,stm32f42xx-rcc" 12*4882a593Smuzhiyun "st,stm32f469-rcc" 13*4882a593Smuzhiyun- reg: should be register base and length as documented in the 14*4882a593Smuzhiyun datasheet 15*4882a593Smuzhiyun- #reset-cells: 1, see below 16*4882a593Smuzhiyun- #clock-cells: 2, device nodes should specify the clock in their "clocks" 17*4882a593Smuzhiyun property, containing a phandle to the clock device node, an index selecting 18*4882a593Smuzhiyun between gated clocks and other clocks and an index specifying the clock to 19*4882a593Smuzhiyun use. 20*4882a593Smuzhiyun 21*4882a593SmuzhiyunExample: 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun rcc: rcc@40023800 { 24*4882a593Smuzhiyun #reset-cells = <1>; 25*4882a593Smuzhiyun #clock-cells = <2> 26*4882a593Smuzhiyun compatible = "st,stm32f42xx-rcc", "st,stm32-rcc"; 27*4882a593Smuzhiyun reg = <0x40023800 0x400>; 28*4882a593Smuzhiyun }; 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunSpecifying gated clocks 31*4882a593Smuzhiyun======================= 32*4882a593Smuzhiyun 33*4882a593SmuzhiyunThe primary index must be set to 0. 34*4882a593Smuzhiyun 35*4882a593SmuzhiyunThe secondary index is the bit number within the RCC register bank, starting 36*4882a593Smuzhiyunfrom the first RCC clock enable register (RCC_AHB1ENR, address offset 0x30). 37*4882a593Smuzhiyun 38*4882a593SmuzhiyunIt is calculated as: index = register_offset / 4 * 32 + bit_offset. 39*4882a593SmuzhiyunWhere bit_offset is the bit offset within the register (LSB is 0, MSB is 31). 40*4882a593Smuzhiyun 41*4882a593SmuzhiyunTo simplify the usage and to share bit definition with the reset and clock 42*4882a593Smuzhiyundrivers of the RCC IP, macros are available to generate the index in 43*4882a593Smuzhiyunhuman-readble format. 44*4882a593Smuzhiyun 45*4882a593SmuzhiyunFor STM32F4 series, the macro are available here: 46*4882a593Smuzhiyun - include/dt-bindings/mfd/stm32f4-rcc.h 47*4882a593Smuzhiyun 48*4882a593SmuzhiyunExample: 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun /* Gated clock, AHB1 bit 0 (GPIOA) */ 51*4882a593Smuzhiyun ... { 52*4882a593Smuzhiyun clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)> 53*4882a593Smuzhiyun }; 54*4882a593Smuzhiyun 55*4882a593Smuzhiyun /* Gated clock, AHB2 bit 4 (CRYP) */ 56*4882a593Smuzhiyun ... { 57*4882a593Smuzhiyun clocks = <&rcc 0 STM32F4_AHB2_CLOCK(CRYP)> 58*4882a593Smuzhiyun }; 59*4882a593Smuzhiyun 60*4882a593SmuzhiyunSpecifying other clocks 61*4882a593Smuzhiyun======================= 62*4882a593Smuzhiyun 63*4882a593SmuzhiyunThe primary index must be set to 1. 64*4882a593Smuzhiyun 65*4882a593SmuzhiyunThe secondary index is bound with the following magic numbers: 66*4882a593Smuzhiyun 67*4882a593Smuzhiyun 0 SYSTICK 68*4882a593Smuzhiyun 1 FCLK 69*4882a593Smuzhiyun 70*4882a593SmuzhiyunExample: 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun /* Misc clock, FCLK */ 73*4882a593Smuzhiyun ... { 74*4882a593Smuzhiyun clocks = <&rcc 1 STM32F4_APB1_CLOCK(TIM2)> 75*4882a593Smuzhiyun }; 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun 78*4882a593SmuzhiyunSpecifying softreset control of devices 79*4882a593Smuzhiyun======================================= 80*4882a593Smuzhiyun 81*4882a593SmuzhiyunDevice nodes should specify the reset channel required in their "resets" 82*4882a593Smuzhiyunproperty, containing a phandle to the reset device node and an index specifying 83*4882a593Smuzhiyunwhich channel to use. 84*4882a593SmuzhiyunThe index is the bit number within the RCC registers bank, starting from RCC 85*4882a593Smuzhiyunbase address. 86*4882a593SmuzhiyunIt is calculated as: index = register_offset / 4 * 32 + bit_offset. 87*4882a593SmuzhiyunWhere bit_offset is the bit offset within the register. 88*4882a593SmuzhiyunFor example, for CRC reset: 89*4882a593Smuzhiyun crc = AHB1RSTR_offset / 4 * 32 + CRCRST_bit_offset = 0x10 / 4 * 32 + 12 = 140 90*4882a593Smuzhiyun 91*4882a593Smuzhiyunexample: 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun timer2 { 94*4882a593Smuzhiyun resets = <&rcc STM32F4_APB1_RESET(TIM2)>; 95*4882a593Smuzhiyun }; 96