xref: /linux/Documentation/devicetree/bindings/clock/st,stm32-rcc.txt (revision c39f2d9db0fd81ea20bb5cce9b3f082ca63753e2)
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"
1352af8557SGabriel Fernandez  "st,stm32f746-rcc"
14*936289f0SGabriel Fernandez  "st,stm32f769-rcc"
15*936289f0SGabriel Fernandez
1641655239SDaniel Thompson- reg: should be register base and length as documented in the
1741655239SDaniel Thompson  datasheet
1857bd63a4SMaxime Coquelin- #reset-cells: 1, see below
1941655239SDaniel Thompson- #clock-cells: 2, device nodes should specify the clock in their "clocks"
2041655239SDaniel Thompson  property, containing a phandle to the clock device node, an index selecting
2141655239SDaniel Thompson  between gated clocks and other clocks and an index specifying the clock to
2241655239SDaniel Thompson  use.
23f8b50363SGabriel Fernandez- clocks: External oscillator clock phandle
24f8b50363SGabriel Fernandez  - high speed external clock signal (HSE)
25f8b50363SGabriel Fernandez  - external I2S clock (I2S_CKIN)
2641655239SDaniel Thompson
2741655239SDaniel ThompsonExample:
2841655239SDaniel Thompson
2941655239SDaniel Thompson	rcc: rcc@40023800 {
3057bd63a4SMaxime Coquelin		#reset-cells = <1>;
3141655239SDaniel Thompson		#clock-cells = <2>
3241655239SDaniel Thompson		compatible = "st,stm32f42xx-rcc", "st,stm32-rcc";
3341655239SDaniel Thompson		reg = <0x40023800 0x400>;
34f8b50363SGabriel Fernandez		clocks = <&clk_hse>, <&clk_i2s_ckin>;
3541655239SDaniel Thompson	};
3641655239SDaniel Thompson
3741655239SDaniel ThompsonSpecifying gated clocks
3841655239SDaniel Thompson=======================
3941655239SDaniel Thompson
4041655239SDaniel ThompsonThe primary index must be set to 0.
4141655239SDaniel Thompson
4241655239SDaniel ThompsonThe secondary index is the bit number within the RCC register bank, starting
4341655239SDaniel Thompsonfrom the first RCC clock enable register (RCC_AHB1ENR, address offset 0x30).
4441655239SDaniel Thompson
4541655239SDaniel ThompsonIt is calculated as: index = register_offset / 4 * 32 + bit_offset.
4641655239SDaniel ThompsonWhere bit_offset is the bit offset within the register (LSB is 0, MSB is 31).
4741655239SDaniel Thompson
4857bd63a4SMaxime CoquelinTo simplify the usage and to share bit definition with the reset and clock
4957bd63a4SMaxime Coquelindrivers of the RCC IP, macros are available to generate the index in
5057bd63a4SMaxime Coquelinhuman-readble format.
5157bd63a4SMaxime Coquelin
5257bd63a4SMaxime CoquelinFor STM32F4 series, the macro are available here:
5357bd63a4SMaxime Coquelin - include/dt-bindings/mfd/stm32f4-rcc.h
5457bd63a4SMaxime Coquelin
5541655239SDaniel ThompsonExample:
5641655239SDaniel Thompson
5741655239SDaniel Thompson	/* Gated clock, AHB1 bit 0 (GPIOA) */
5841655239SDaniel Thompson	... {
5957bd63a4SMaxime Coquelin		clocks = <&rcc 0 STM32F4_AHB1_CLOCK(GPIOA)>
6041655239SDaniel Thompson	};
6141655239SDaniel Thompson
6241655239SDaniel Thompson	/* Gated clock, AHB2 bit 4 (CRYP) */
6341655239SDaniel Thompson	... {
6457bd63a4SMaxime Coquelin		clocks = <&rcc 0 STM32F4_AHB2_CLOCK(CRYP)>
6541655239SDaniel Thompson	};
6641655239SDaniel Thompson
6741655239SDaniel ThompsonSpecifying other clocks
6841655239SDaniel Thompson=======================
6941655239SDaniel Thompson
7041655239SDaniel ThompsonThe primary index must be set to 1.
7141655239SDaniel Thompson
7241655239SDaniel ThompsonThe secondary index is bound with the following magic numbers:
7341655239SDaniel Thompson
7441655239SDaniel Thompson	0	SYSTICK
7541655239SDaniel Thompson	1	FCLK
76f8b50363SGabriel Fernandez	2	CLK_LSI		(low-power clock source)
77f8b50363SGabriel Fernandez	3	CLK_LSE		(generated from a 32.768 kHz low-speed external
78f8b50363SGabriel Fernandez				 crystal or ceramic resonator)
79f8b50363SGabriel Fernandez	4	CLK_HSE_RTC	(HSE division factor for RTC clock)
80f8b50363SGabriel Fernandez	5	CLK_RTC		(real-time clock)
81f8b50363SGabriel Fernandez	6	PLL_VCO_I2S	(vco frequency of I2S pll)
82f8b50363SGabriel Fernandez	7	PLL_VCO_SAI	(vco frequency of SAI pll)
83f8b50363SGabriel Fernandez	8	CLK_LCD		(LCD-TFT)
84f8b50363SGabriel Fernandez	9	CLK_I2S		(I2S clocks)
85f8b50363SGabriel Fernandez	10	CLK_SAI1	(audio clocks)
86f8b50363SGabriel Fernandez	11	CLK_SAI2
87f8b50363SGabriel Fernandez	12	CLK_I2SQ_PDIV	(post divisor of pll i2s q divisor)
88f8b50363SGabriel Fernandez	13	CLK_SAIQ_PDIV	(post divisor of pll sai q divisor)
8941655239SDaniel Thompson
9052af8557SGabriel Fernandez	14	CLK_HSI		(Internal ocscillator clock)
9152af8557SGabriel Fernandez	15	CLK_SYSCLK	(System Clock)
9252af8557SGabriel Fernandez	16	CLK_HDMI_CEC	(HDMI-CEC clock)
9352af8557SGabriel Fernandez	17	CLK_SPDIF	(SPDIF-Rx clock)
9452af8557SGabriel Fernandez	18	CLK_USART1	(U(s)arts clocks)
9552af8557SGabriel Fernandez	19	CLK_USART2
9652af8557SGabriel Fernandez	20	CLK_USART3
9752af8557SGabriel Fernandez	21	CLK_UART4
9852af8557SGabriel Fernandez	22	CLK_UART5
9952af8557SGabriel Fernandez	23	CLK_USART6
10052af8557SGabriel Fernandez	24	CLK_UART7
10152af8557SGabriel Fernandez	25	CLK_UART8
10252af8557SGabriel Fernandez	26	CLK_I2C1	(I2S clocks)
10352af8557SGabriel Fernandez	27	CLK_I2C2
10452af8557SGabriel Fernandez	28	CLK_I2C3
10552af8557SGabriel Fernandez	29	CLK_I2C4
10652af8557SGabriel Fernandez	30	CLK_LPTIMER	(LPTimer1 clock)
107*936289f0SGabriel Fernandez	31	CLK_PLL_SRC
108*936289f0SGabriel Fernandez	32	CLK_DFSDM1
109*936289f0SGabriel Fernandez	33	CLK_ADFSDM1
110*936289f0SGabriel Fernandez	34	CLK_F769_DSI
11152af8557SGabriel Fernandez)
11252af8557SGabriel Fernandez
11341655239SDaniel ThompsonExample:
11441655239SDaniel Thompson
11541655239SDaniel Thompson	/* Misc clock, FCLK */
11641655239SDaniel Thompson	... {
11757bd63a4SMaxime Coquelin		clocks = <&rcc 1 STM32F4_APB1_CLOCK(TIM2)>
11857bd63a4SMaxime Coquelin	};
11957bd63a4SMaxime Coquelin
12057bd63a4SMaxime Coquelin
12157bd63a4SMaxime CoquelinSpecifying softreset control of devices
12257bd63a4SMaxime Coquelin=======================================
12357bd63a4SMaxime Coquelin
12457bd63a4SMaxime CoquelinDevice nodes should specify the reset channel required in their "resets"
12557bd63a4SMaxime Coquelinproperty, containing a phandle to the reset device node and an index specifying
12657bd63a4SMaxime Coquelinwhich channel to use.
12757bd63a4SMaxime CoquelinThe index is the bit number within the RCC registers bank, starting from RCC
12857bd63a4SMaxime Coquelinbase address.
12957bd63a4SMaxime CoquelinIt is calculated as: index = register_offset / 4 * 32 + bit_offset.
13057bd63a4SMaxime CoquelinWhere bit_offset is the bit offset within the register.
13157bd63a4SMaxime CoquelinFor example, for CRC reset:
13257bd63a4SMaxime Coquelin  crc = AHB1RSTR_offset / 4 * 32 + CRCRST_bit_offset = 0x10 / 4 * 32 + 12 = 140
13357bd63a4SMaxime Coquelin
13457bd63a4SMaxime Coquelinexample:
13557bd63a4SMaxime Coquelin
13657bd63a4SMaxime Coquelin	timer2 {
13757bd63a4SMaxime Coquelin		resets	= <&rcc STM32F4_APB1_RESET(TIM2)>;
13841655239SDaniel Thompson	};
139