18c2ecf20Sopenharmony_ciSTMicroelectronics STM32 Reset and Clock Controller
28c2ecf20Sopenharmony_ci===================================================
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ciThe RCC IP is both a reset and a clock controller.
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciPlease refer to clock-bindings.txt for common clock controller binding usage.
78c2ecf20Sopenharmony_ciPlease also refer to reset.txt for common reset controller binding usage.
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciRequired properties:
108c2ecf20Sopenharmony_ci- compatible: Should be:
118c2ecf20Sopenharmony_ci  "st,stm32f42xx-rcc"
128c2ecf20Sopenharmony_ci  "st,stm32f469-rcc"
138c2ecf20Sopenharmony_ci  "st,stm32f746-rcc"
148c2ecf20Sopenharmony_ci  "st,stm32f769-rcc"
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci- reg: should be register base and length as documented in the
178c2ecf20Sopenharmony_ci  datasheet
188c2ecf20Sopenharmony_ci- #reset-cells: 1, see below
198c2ecf20Sopenharmony_ci- #clock-cells: 2, device nodes should specify the clock in their "clocks"
208c2ecf20Sopenharmony_ci  property, containing a phandle to the clock device node, an index selecting
218c2ecf20Sopenharmony_ci  between gated clocks and other clocks and an index specifying the clock to
228c2ecf20Sopenharmony_ci  use.
238c2ecf20Sopenharmony_ci- clocks: External oscillator clock phandle
248c2ecf20Sopenharmony_ci  - high speed external clock signal (HSE)
258c2ecf20Sopenharmony_ci  - external I2S clock (I2S_CKIN)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciExample:
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci	rcc: rcc@40023800 {
308c2ecf20Sopenharmony_ci		#reset-cells = <1>;
318c2ecf20Sopenharmony_ci		#clock-cells = <2>
328c2ecf20Sopenharmony_ci		compatible = "st,stm32f42xx-rcc", "st,stm32-rcc";
338c2ecf20Sopenharmony_ci		reg = <0x40023800 0x400>;
348c2ecf20Sopenharmony_ci		clocks = <&clk_hse>, <&clk_i2s_ckin>;
358c2ecf20Sopenharmony_ci	};
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ciSpecifying gated clocks
388c2ecf20Sopenharmony_ci=======================
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ciThe primary index must be set to 0.
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ciThe secondary index is the bit number within the RCC register bank, starting
438c2ecf20Sopenharmony_cifrom the first RCC clock enable register (RCC_AHB1ENR, address offset 0x30).
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ciIt is calculated as: index = register_offset / 4 * 32 + bit_offset.
468c2ecf20Sopenharmony_ciWhere bit_offset is the bit offset within the register (LSB is 0, MSB is 31).
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciTo simplify the usage and to share bit definition with the reset and clock
498c2ecf20Sopenharmony_cidrivers of the RCC IP, macros are available to generate the index in
508c2ecf20Sopenharmony_cihuman-readble format.
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciFor STM32F4 series, the macro are available here:
538c2ecf20Sopenharmony_ci - include/dt-bindings/mfd/stm32f4-rcc.h
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciExample:
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	/* Gated clock, AHB1 bit 0 (GPIOA) */
588c2ecf20Sopenharmony_ci	... {
598c2ecf20Sopenharmony_ci		clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)>
608c2ecf20Sopenharmony_ci	};
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci	/* Gated clock, AHB2 bit 4 (CRYP) */
638c2ecf20Sopenharmony_ci	... {
648c2ecf20Sopenharmony_ci		clocks = <&rcc 0 STM32F4_AHB2_CLOCK(CRYP)>
658c2ecf20Sopenharmony_ci	};
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ciSpecifying other clocks
688c2ecf20Sopenharmony_ci=======================
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ciThe primary index must be set to 1.
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ciThe secondary index is bound with the following magic numbers:
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	0	SYSTICK
758c2ecf20Sopenharmony_ci	1	FCLK
768c2ecf20Sopenharmony_ci	2	CLK_LSI		(low-power clock source)
778c2ecf20Sopenharmony_ci	3	CLK_LSE		(generated from a 32.768 kHz low-speed external
788c2ecf20Sopenharmony_ci				 crystal or ceramic resonator)
798c2ecf20Sopenharmony_ci	4	CLK_HSE_RTC	(HSE division factor for RTC clock)
808c2ecf20Sopenharmony_ci	5	CLK_RTC		(real-time clock)
818c2ecf20Sopenharmony_ci	6	PLL_VCO_I2S	(vco frequency of I2S pll)
828c2ecf20Sopenharmony_ci	7	PLL_VCO_SAI	(vco frequency of SAI pll)
838c2ecf20Sopenharmony_ci	8	CLK_LCD		(LCD-TFT)
848c2ecf20Sopenharmony_ci	9	CLK_I2S		(I2S clocks)
858c2ecf20Sopenharmony_ci	10	CLK_SAI1	(audio clocks)
868c2ecf20Sopenharmony_ci	11	CLK_SAI2
878c2ecf20Sopenharmony_ci	12	CLK_I2SQ_PDIV	(post divisor of pll i2s q divisor)
888c2ecf20Sopenharmony_ci	13	CLK_SAIQ_PDIV	(post divisor of pll sai q divisor)
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci	14	CLK_HSI		(Internal ocscillator clock)
918c2ecf20Sopenharmony_ci	15	CLK_SYSCLK	(System Clock)
928c2ecf20Sopenharmony_ci	16	CLK_HDMI_CEC	(HDMI-CEC clock)
938c2ecf20Sopenharmony_ci	17	CLK_SPDIF	(SPDIF-Rx clock)
948c2ecf20Sopenharmony_ci	18	CLK_USART1	(U(s)arts clocks)
958c2ecf20Sopenharmony_ci	19	CLK_USART2
968c2ecf20Sopenharmony_ci	20	CLK_USART3
978c2ecf20Sopenharmony_ci	21	CLK_UART4
988c2ecf20Sopenharmony_ci	22	CLK_UART5
998c2ecf20Sopenharmony_ci	23	CLK_USART6
1008c2ecf20Sopenharmony_ci	24	CLK_UART7
1018c2ecf20Sopenharmony_ci	25	CLK_UART8
1028c2ecf20Sopenharmony_ci	26	CLK_I2C1	(I2S clocks)
1038c2ecf20Sopenharmony_ci	27	CLK_I2C2
1048c2ecf20Sopenharmony_ci	28	CLK_I2C3
1058c2ecf20Sopenharmony_ci	29	CLK_I2C4
1068c2ecf20Sopenharmony_ci	30	CLK_LPTIMER	(LPTimer1 clock)
1078c2ecf20Sopenharmony_ci	31	CLK_PLL_SRC
1088c2ecf20Sopenharmony_ci	32	CLK_DFSDM1
1098c2ecf20Sopenharmony_ci	33	CLK_ADFSDM1
1108c2ecf20Sopenharmony_ci	34	CLK_F769_DSI
1118c2ecf20Sopenharmony_ci)
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ciExample:
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci	/* Misc clock, FCLK */
1168c2ecf20Sopenharmony_ci	... {
1178c2ecf20Sopenharmony_ci		clocks = <&rcc 1 STM32F4_APB1_CLOCK(TIM2)>
1188c2ecf20Sopenharmony_ci	};
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ciSpecifying softreset control of devices
1228c2ecf20Sopenharmony_ci=======================================
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ciDevice nodes should specify the reset channel required in their "resets"
1258c2ecf20Sopenharmony_ciproperty, containing a phandle to the reset device node and an index specifying
1268c2ecf20Sopenharmony_ciwhich channel to use.
1278c2ecf20Sopenharmony_ciThe index is the bit number within the RCC registers bank, starting from RCC
1288c2ecf20Sopenharmony_cibase address.
1298c2ecf20Sopenharmony_ciIt is calculated as: index = register_offset / 4 * 32 + bit_offset.
1308c2ecf20Sopenharmony_ciWhere bit_offset is the bit offset within the register.
1318c2ecf20Sopenharmony_ciFor example, for CRC reset:
1328c2ecf20Sopenharmony_ci  crc = AHB1RSTR_offset / 4 * 32 + CRCRST_bit_offset = 0x10 / 4 * 32 + 12 = 140
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ciexample:
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	timer2 {
1378c2ecf20Sopenharmony_ci		resets	= <&rcc STM32F4_APB1_RESET(TIM2)>;
1388c2ecf20Sopenharmony_ci	};
139