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