Add STM32H7 SoC, Discovery and Evaluation board support
Subsystems (10)
v2 cover Add STM32H7 SoC, Discovery and Evaluation board support
From: Patrice Chotard <[email protected]>
This series adds support for STM32H7 SoCs series and its Discovery and Evaluation board
For more detailed information please visit:
www.st.com/en/microcontrollers/stm32h7-series.html
v2:_ add stm32h743 Evaluation board support
_ squash all DTS patches which did specific adpatation for U-boot _ reword the board description in patches 6 and 7
_ use separate file stm32h7-u-boot.dtsi for "u-boot,dm-pre-reloc" property _ get memory address and size from DT in board file
_ rework clock driver for stm32h743:
_ merge peripheral and kernel clocks arrays
_ add voltage scaling support needed for evaluation board
Christophe Kerello (1):
dm: misc: add stm32 rcc driver
Patrice Chotard (8):
pinctrl: stm32: add stm32h743-pinctrl compatible
serial: stm32x7: add STM32H7 support
dm: clk: add clk driver support for stm32h7 SoCs
dm: reset: add stm32 reset driver
ARM: DTS: stm32: add stm32h743i-disco files
ARM: DTS: stm32: add stm32h743i-eval files
ARM: DTS: stm32: adapt stm32h7 dts files for U-boot
board: Add stm32h7 SoC, discovery and evaluation boards support
arch/arm/dts/Makefile | 2 + arch/arm/dts/stm32h7-u-boot.dtsi | 88 ++ arch/arm/dts/stm32h743-pinctrl.dtsi | 249 ++++ arch/arm/dts/stm32h743.dtsi | 129 ++ arch/arm/dts/stm32h743i-disco.dts | 100 ++ arch/arm/dts/stm32h743i-eval.dts | 100 ++ arch/arm/include/asm/arch-stm32h7/gpio.h | 126 ++ arch/arm/include/asm/arch-stm32h7/stm32.h | 21 + arch/arm/mach-stm32/Kconfig | 17 + arch/arm/mach-stm32/Makefile | 1 + arch/arm/mach-stm32/stm32h7/Kconfig | 12 + arch/arm/mach-stm32/stm32h7/Makefile | 8 + arch/arm/mach-stm32/stm32h7/soc.c | 59 + board/st/stm32h743-disco/Kconfig | 19 + board/st/stm32h743-disco/MAINTAINERS | 7 + board/st/stm32h743-disco/Makefile | 8 + board/st/stm32h743-disco/stm32h743-disco.c | 56 + board/st/stm32h743-eval/Kconfig | 19 + board/st/stm32h743-eval/MAINTAINERS | 6 + board/st/stm32h743-eval/Makefile | 8 + board/st/stm32h743-eval/stm32h743-eval.c | 56 + configs/stm32h743-disco_defconfig | 30 + configs/stm32h743-eval_defconfig | 30 + doc/device-tree-bindings/clock/st,stm32h7-rcc.txt | 152 ++ doc/device-tree-bindings/reset/st,stm32-rcc.txt | 6 + drivers/clk/Makefile | 1 + drivers/clk/clk_stm32h7.c | 802 ++++++++++ drivers/misc/Kconfig | 9 + drivers/misc/Makefile | 1 + drivers/misc/stm32_rcc.c | 45 + drivers/pinctrl/pinctrl_stm32.c | 1 + drivers/reset/Kconfig | 7 + drivers/reset/Makefile | 1 + drivers/reset/stm32-reset.c | 80 + drivers/serial/Kconfig | 7 +- drivers/serial/serial_stm32x7.c | 2 + include/configs/stm32h743-disco.h | 51 + include/configs/stm32h743-eval.h | 51 + include/dt-bindings/clock/stm32h7-clks.h | 167 +++ include/dt-bindings/memory/stm32-sdram.h | 7 + include/dt-bindings/mfd/stm32h7-rcc.h | 138 ++ include/dt-bindings/pinctrl/stm32h7-pinfunc.h | 1612 +++++++++++++++++++++ 42 files changed, 4288 insertions(+), 3 deletions(-) create mode 100644 arch/arm/dts/stm32h7-u-boot.dtsi create mode 100644 arch/arm/dts/stm32h743-pinctrl.dtsi create mode 100644 arch/arm/dts/stm32h743.dtsi create mode 100644 arch/arm/dts/stm32h743i-disco.dts create mode 100644 arch/arm/dts/stm32h743i-eval.dts create mode 100644 arch/arm/include/asm/arch-stm32h7/gpio.h create mode 100644 arch/arm/include/asm/arch-stm32h7/stm32.h create mode 100644 arch/arm/mach-stm32/stm32h7/Kconfig create mode 100644 arch/arm/mach-stm32/stm32h7/Makefile create mode 100644 arch/arm/mach-stm32/stm32h7/soc.c create mode 100644 board/st/stm32h743-disco/Kconfig create mode 100644 board/st/stm32h743-disco/MAINTAINERS create mode 100644 board/st/stm32h743-disco/Makefile create mode 100644 board/st/stm32h743-disco/stm32h743-disco.c create mode 100644 board/st/stm32h743-eval/Kconfig create mode 100644 board/st/stm32h743-eval/MAINTAINERS create mode 100644 board/st/stm32h743-eval/Makefile create mode 100644 board/st/stm32h743-eval/stm32h743-eval.c create mode 100644 configs/stm32h743-disco_defconfig create mode 100644 configs/stm32h743-eval_defconfig create mode 100644 doc/device-tree-bindings/clock/st,stm32h7-rcc.txt create mode 100644 doc/device-tree-bindings/reset/st,stm32-rcc.txt create mode 100644 drivers/clk/clk_stm32h7.c create mode 100644 drivers/misc/stm32_rcc.c create mode 100644 drivers/reset/stm32-reset.c create mode 100644 include/configs/stm32h743-disco.h create mode 100644 include/configs/stm32h743-eval.h create mode 100644 include/dt-bindings/clock/stm32h7-clks.h create mode 100644 include/dt-bindings/mfd/stm32h7-rcc.h create mode 100644 include/dt-bindings/pinctrl/stm32h7-pinfunc.h
Signature · 1 line
1.9.1
PATCH v2 1/9 pinctrl: stm32: add stm32h743-pinctrl compatible
From: Patrice Chotard <[email protected]>
STM32H7 SoCs uses the same pinctrl block as found into STM32F7 SoCs
--- drivers/pinctrl/pinctrl_stm32.c | 1 + 1 file changed, 1 insertion(+)
drivers/pinctrl/pinctrl_stm32.c +1 -0
@@ -183,6 +183,7 @@ static struct pinctrl_ops stm32_pinctrl_ops = {static const struct udevice_id stm32_pinctrl_ids[] = { { .compatible ="st,stm32f746-pinctrl" }, + { .compatible ="st,stm32h743-pinctrl" }, { } };
Signature · 1 line
1.9.1
PATCH v2 1/9 pinctrl: stm32: add stm32h743-pinctrl compatible
Quoted 9 lines · On 13 September 2017 at 10:00, <[email protected]> wrote:
From: Patrice Chotard <[email protected]>
STM32H7 SoCs uses the same pinctrl block as found into STM32F7 SoCs
Signed-off-by Patrice Chotard <[email protected]>--- drivers/pinctrl/pinctrl_stm32.c | 1 + 1 file changed, 1 insertion(+)
PATCH v2 1/9 pinctrl: stm32: add stm32h743-pinctrl compatible
In reply to patrice.chotard at st.comQuoted 10 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
STM32H7 SoCs uses the same pinctrl block as found into STM32F7 SoCs
Signed-off-by Patrice Chotard <[email protected]>--- drivers/pinctrl/pinctrl_stm32.c | 1 + 1 file changed, 1 insertion(+)
Quoted 13 lines
drivers/pinctrl/pinctrl_stm32.c +1
-0@@ -183,6 +183,7 @@ static struct pinctrl_ops stm32_pinctrl_ops = {static const struct udevice_id stm32_pinctrl_ids[] = { { .compatible ="st,stm32f746-pinctrl" }, + { .compatible ="st,stm32h743-pinctrl" }, { } };
PATCH v2 1/9 pinctrl: stm32: add stm32h743-pinctrl compatible
In reply to patrice.chotard at st.comQuoted 8 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
STM32H7 SoCs uses the same pinctrl block as found into STM32F7 SoCs
Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>Reviewed-by Vikas Manocha <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170922/84d49d1e/attachment.sig>
PATCH v2 2/9 serial: stm32x7: add STM32H7 support
In reply to patrice.chotard at st.comFrom: Patrice Chotard <[email protected]>
STM32F7 and STM32H7 shares the same UART block, add STM32H7 compatible string.
--- drivers/serial/Kconfig | 7 ++++--- drivers/serial/serial_stm32x7.c | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/serial/Kconfig +4 -3
@@ -524,10 +524,11 @@ config STI_ASC_SERIAL config STM32X7_SERIAL bool "STMicroelectronics STM32 SoCs on-chip UART" - depends on DM_SERIAL && STM32F7 + depends on DM_SERIAL && (STM32F7 || STM32H7) help - If you have a machine based on a STM32 F7 you can enable its - onboard serial ports, say Y to this option. If unsure, say N. + If you have a machine based on a STM32 F7 or H7 SoC you can + enable its onboard serial ports, say Y to this option. + If unsure, say N. config MPC8XX_CONS bool "Console driver for MPC8XX"
drivers/serial/serial_stm32x7.c +2 -0
@@ -112,6 +112,8 @@ static int stm32_serial_probe(struct udevice *dev)static const struct udevice_id stm32_serial_id[] = { {.compatible ="st,stm32f7-usart" }, {.compatible ="st,stm32f7-uart" }, + {.compatible ="st,stm32h7-usart" }, + {.compatible ="st,stm32h7-uart" }, {} };
Signature · 1 line
1.9.1
PATCH v2 2/9 serial: stm32x7: add STM32H7 support
Quoted 10 lines · On 13 September 2017 at 10:00, <[email protected]> wrote:
From: Patrice Chotard <[email protected]>
STM32F7 and STM32H7 shares the same UART block, add STM32H7 compatible string.
Signed-off-by Patrice Chotard <[email protected]>--- drivers/serial/Kconfig | 7 ++++--- drivers/serial/serial_stm32x7.c | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-)
PATCH v2 2/9 serial: stm32x7: add STM32H7 support
In reply to patrice.chotard at st.comHi Patrice,
Quoted 35 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
STM32F7 and STM32H7 shares the same UART block, add STM32H7 compatible string.
Signed-off-by Patrice Chotard <[email protected]>--- drivers/serial/Kconfig | 7 ++++--- drivers/serial/serial_stm32x7.c | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-)drivers/serial/Kconfig +4
-3@@ -524,10 +524,11 @@ config STI_ASC_SERIAL config STM32X7_SERIAL bool "STMicroelectronics STM32 SoCs on-chip UART" - depends on DM_SERIAL && STM32F7 + depends on DM_SERIAL && (STM32F7 || STM32H7) help - If you have a machine based on a STM32 F7 you can enable its - onboard serial ports, say Y to this option. If unsure, say N. + If you have a machine based on a STM32 F7 or H7 SoC you can + enable its onboard serial ports, say Y to this option. + If unsure, say N. config MPC8XX_CONS bool "Console driver for MPC8XX"drivers/serial/serial_stm32x7.c +0
-0
drivers/serial/serial_stm32x7.c static int stm32_serial_probe(struct udevice *dev) · line 116
Quoted 5 lines
drivers/serial/serial_stm32x7.c +2
-0@@ -112,6 +112,8 @@ static int stm32_serial_probe(struct udevice *dev)static const struct udevice_id stm32_serial_id[] = { {.compatible ="st,stm32f7-usart" }, {.compatible ="st,stm32f7-uart" }, + {.compatible ="st,stm32h7-usart" }, + {.compatible ="st,stm32h7-uart" },
two compatibles are consuming space & time without adding any value.
Cheers,
Vikas
Quoted 4 lines
drivers/serial/serial_stm32x7.c +0
-0{} };
PATCH v2 2/9 serial: stm32x7: add STM32H7 support
Hi Vikas
Quoted 31 lines · Vikas Manocha
Hi Patrice,
Quoted 28 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
STM32F7 and STM32H7 shares the same UART block, add STM32H7 compatible string.
Signed-off-by Patrice Chotard <[email protected]>--- drivers/serial/Kconfig | 7 ++++--- drivers/serial/serial_stm32x7.c | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-)drivers/serial/Kconfig +4
-3@@ -524,10 +524,11 @@ config STI_ASC_SERIAL config STM32X7_SERIAL bool "STMicroelectronics STM32 SoCs on-chip UART" - depends on DM_SERIAL && STM32F7 + depends on DM_SERIAL && (STM32F7 || STM32H7) help - If you have a machine based on a STM32 F7 you can enable its - onboard serial ports, say Y to this option. If unsure, say N. + If you have a machine based on a STM32 F7 or H7 SoC you can + enable its onboard serial ports, say Y to this option. + If unsure, say N.
Quoted 14 lines
drivers/serial/serial_stm32x7.c static int stm32_serial_probe(struct udevice *dev) · line 116
Quoted 12 lines
drivers/serial/Kconfig +0
-0config MPC8XX_CONS bool "Console driver for MPC8XX"drivers/serial/serial_stm32x7.c +2
-0@@ -112,6 +112,8 @@ static int stm32_serial_probe(struct udevice *dev)static const struct udevice_id stm32_serial_id[] = { {.compatible ="st,stm32f7-usart" }, {.compatible ="st,stm32f7-uart" }, + {.compatible ="st,stm32h7-usart" }, + {.compatible ="st,stm32h7-uart" },two compatibles are consuming space & time without adding any value.
Agree, i will send a series to remove the "usart" compatible as this series has been already merged in u-boot/master
Thanks
Patrice
Quoted 8 lines
Cheers,
VikasQuoted 4 lines
drivers/serial/serial_stm32x7.c +0
-0{} };
PATCH v2 2/9 serial: stm32x7: add STM32H7 support
In reply to patrice.chotard at st.comQuoted 7 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
STM32F7 and STM32H7 shares the same UART block, add STM32H7 compatible string.
Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170922/1a1722a1/attachment.sig>
PATCH v2 3/9 dm: clk: add clk driver support for stm32h7 SoCs
In reply to patrice.chotard at st.comFrom: Patrice Chotard <[email protected]>
This driver implements basic clock setup, only clock gating is implemented.
This driver doesn't implement .of_match as it's binded by MFD RCC driver.
Files include/dt-bindings/clock/stm32h7-clks.h and doc/device-tree-bindings/clock/st,stm32h7-rcc.txt will be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].
[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
--- doc/device-tree-bindings/clock/st,stm32h7-rcc.txt | 152 ++++ drivers/clk/Makefile | 1 + drivers/clk/clk_stm32h7.c | 802 ++++++++++++++++++++++ include/dt-bindings/clock/stm32h7-clks.h | 167 +++++ 4 files changed, 1122 insertions(+) create mode 100644 doc/device-tree-bindings/clock/st,stm32h7-rcc.txt create mode 100644 drivers/clk/clk_stm32h7.c create mode 100644 include/dt-bindings/clock/stm32h7-clks.h
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +152 -0
@@ -0,0 +1,152 @@ +STMicroelectronics STM32H7 Reset and Clock Controller +===================================================== + +The RCC IP is both a reset and a clock controller. + +Please refer to clock-bindings.txt for common clock controller binding usage. +Please also refer to reset.txt for common reset controller binding usage. + +Required properties: +- compatible: Should be: + "st,stm32h743-rcc" + +- reg: should be register base and length as documented in the + datasheet + +- #reset-cells: 1, see below + +- #clock-cells : from common clock binding; shall be set to 1 + +- clocks: External oscillator clock phandle + - high speed external clock signal (HSE) + - low speed external clock signal (LSE) + - external I2S clock (I2S_CKIN) + +- st,syscfg: phandle for pwrcfg, mandatory to disable/enable backup domain + write protection (RTC clock). + +- pll x node: Allow to register a pll with specific parameters. + Please see PLL section below. + +Example: + + rcc: rcc at 58024400 { + #reset-cells = <1>; + #clock-cells = <2> + compatible = "st,stm32h743-rcc", "st,stm32-rcc"; + reg = <0x58024400 0x400>; + clocks = <&clk_hse>, <&clk_lse>, <&clk_i2s_ckin>; + + st,syscfg = <&pwrcfg>; + + #address-cells = <1>; + #size-cells = <0>; + + vco1 at 58024430 { + #clock-cells = <0>; + compatible = "stm32,pll"; + reg = <0>; + }; + + vco2 at 58024438 { + #clock-cells = <0>; + compatible = "stm32,pll"; + reg = <1>; + st,clock-div = <2>; + st,clock-mult = <40>; + st,frac-status = <0>; + st,frac = <0>; + st,vcosel = <1>; + st,pllrge = <2>; + }; + }; + + +STM32H7 PLL +----------- + +The VCO of STM32 PLL could be reprensented like this: + + Vref --------- -------- + ---->| / DIVM |---->| x DIVN | ------> VCO + --------- -------- + ^ + | + ------- + | FRACN | + ------- + +When the PLL is configured in integer mode: +- VCO = ( Vref / DIVM ) * DIVN + +When the PLL is configured in fractional mode: +- VCO = ( Vref / DIVM ) * ( DIVN + FRACN / 2^13) + + +Required properties for pll node: +- compatible: Should be: + "stm32,pll" + +- #clock-cells: from common clock binding; shall be set to 0 +- reg: Should be the pll number. + +Optional properties: +- st,clock-div: DIVM division factor : <1..63> +- st,clock-mult: DIVN multiplication factor : <4..512> + +- st,frac-status: + - 0 Pll is configured in integer mode + - 1 Pll is configure in fractional mode + +- st,frac: Fractional part of the multiplication factor : <0..8191> + +- st,vcosel: VCO selection + - 0: Wide VCO range:192 to 836 MHz + - 1: Medium VCO range:150 to 420 MHz + +- st,pllrge: PLL input frequency range + - 0: The PLL input (Vref / DIVM) clock range frequency is between 1 and 2 MHz + - 1: The PLL input (Vref / DIVM) clock range frequency is between 2 and 4 MHz + - 2: The PLL input (Vref / DIVM) clock range frequency is between 4 and 8 MHz + - 3: The PLL input (Vref / DIVM) clock range frequency is between 8 and 16 MHz + + +The peripheral clock consumer should specify the desired clock by +having the clock ID in its "clocks" phandle cell. + +All available clocks are defined as preprocessor macros in +dt-bindings/clock/stm32h7-clks.h header and can be used in device +tree sources. + +Example: + + timer5: timer at 40000c00 { + compatible = "st,stm32-timer"; + reg = <0x40000c00 0x400>; + interrupts = <50>; + clocks = <&rcc TIM5_CK>; + + }; + +Specifying softreset control of devices +======================================= + +Device nodes should specify the reset channel required in their "resets" +property, containing a phandle to the reset device node and an index specifying +which channel to use. +The index is the bit number within the RCC registers bank, starting from RCC +base address. +It is calculated as: index = register_offset / 4 * 32 + bit_offset. +Where bit_offset is the bit offset within the register. + +For example, for CRC reset: + crc = AHB4RSTR_offset / 4 * 32 + CRCRST_bit_offset = 0x88 / 4 * 32 + 19 = 1107 + +All available preprocessor macros for reset are defined dt-bindings//mfd/stm32h7-rcc.h +header and can be used in device tree sources. + +example: + + timer2 { + resets = <&rcc STM32H7_APB1L_RESET(TIM2)>; + };
drivers/clk/Makefile +1 -0
@@ -22,3 +22,4 @@ obj-$(CONFIG_CLK_BCM6345) += clk_bcm6345.o obj-$(CONFIG_CLK_BOSTON) += clk_boston.o obj-$(CONFIG_ARCH_ASPEED) += aspeed/ obj-$(CONFIG_STM32F7) += clk_stm32f7.o +obj-$(CONFIG_STM32H7) += clk_stm32h7.o
drivers/clk/clk_stm32h7.c new file +802 -0
802 lines not on this page · raw message
include/dt-bindings/clock/stm32h7-clks.h new file +167 -0
167 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 3/9 dm: clk: add clk driver support for stm32h7 SoCs
Quoted 16 lines · On 13 September 2017 at 10:00, <[email protected]> wrote:
From: Patrice Chotard <[email protected]>
This driver implements basic clock setup, only clock gating is implemented.
This driver doesn't implement .of_match as it's binded by MFD RCC driver.
Files
include/dt-bindings/clock/stm32h7-clks.handdoc/device-tree-bindings/clock/st,stm32h7-rcc.txtwill be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
Signed-off-by Patrice Chotard <[email protected]>
Quoted 9 lines
--- doc/device-tree-bindings/clock/st,stm32h7-rcc.txt | 152 ++++ drivers/clk/Makefile | 1 + drivers/clk/clk_stm32h7.c | 802 ++++++++++++++++++++++ include/dt-bindings/clock/stm32h7-clks.h | 167 +++++ 4 files changed, 1122 insertions(+) create mode 100644 doc/device-tree-bindings/clock/st,stm32h7-rcc.txt create mode 100644 drivers/clk/clk_stm32h7.c create mode 100644 include/dt-bindings/clock/stm32h7-clks.h
PATCH v2 3/9 dm: clk: add clk driver support for stm32h7 SoCs
In reply to patrice.chotard at st.comHi Patrice,
Quoted 48 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
This driver implements basic clock setup, only clock gating is implemented.
This driver doesn't implement .of_match as it's binded by MFD RCC driver.
Files
include/dt-bindings/clock/stm32h7-clks.handdoc/device-tree-bindings/clock/st,stm32h7-rcc.txtwill be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
Signed-off-by Patrice Chotard <[email protected]>--- doc/device-tree-bindings/clock/st,stm32h7-rcc.txt | 152 ++++ drivers/clk/Makefile | 1 + drivers/clk/clk_stm32h7.c | 802 ++++++++++++++++++++++ include/dt-bindings/clock/stm32h7-clks.h | 167 +++++ 4 files changed, 1122 insertions(+) create mode 100644 doc/device-tree-bindings/clock/st,stm32h7-rcc.txt create mode 100644 drivers/clk/clk_stm32h7.c create mode 100644 include/dt-bindings/clock/stm32h7-clks.hdoc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +16
-0@@ -0,0 +1,152 @@ +STMicroelectronics STM32H7 Reset and Clock Controller +===================================================== + +The RCC IP is both a reset and a clock controller. + +Please refer to clock-bindings.txt for common clock controller binding usage. +Please also refer to reset.txt for common reset controller binding usage. + +Required properties: +- compatible: Should be: + "st,stm32h743-rcc" + +- reg: should be register base and length as documented in the + datasheet + +- #reset-cells: 1, see below
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt line 26
Quoted 10 lines
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +10
-0+ +- #clock-cells : from common clock binding; shall be set to 1 + +- clocks: External oscillator clock phandle + - high speed external clock signal (HSE) + - low speed external clock signal (LSE) + - external I2S clock (I2S_CKIN) + +- st,syscfg: phandle for pwrcfg, mandatory to disable/enable backup domain + write protection (RTC clock).
st,syscfg is confusing if we are using it for PWR or SYSCFG peripheral of the device.
Also why company name to reference the phandle, it can just be syscfg or better something like pwr_xxx as we it pointing to pwrcfg phandle.
Quoted 4 lines
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +4
-0+ +- pll x node: Allow to register a pll with specific parameters. + Please see PLL section below. +
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt line 40
Quoted 10 lines
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +10
-0+Example: + + rcc: rcc at 58024400 { + #reset-cells = <1>; + #clock-cells = <2> + compatible = "st,stm32h743-rcc", "st,stm32-rcc"; + reg = <0x58024400 0x400>; + clocks = <&clk_hse>, <&clk_lse>, <&clk_i2s_ckin>; + + st,syscfg = <&pwrcfg>;
see above.
Quoted 229 lines
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +112
-0+ + #address-cells = <1>; + #size-cells = <0>; + + vco1 at 58024430 { + #clock-cells = <0>; + compatible = "stm32,pll"; + reg = <0>; + }; + + vco2 at 58024438 { + #clock-cells = <0>; + compatible = "stm32,pll"; + reg = <1>; + st,clock-div = <2>; + st,clock-mult = <40>; + st,frac-status = <0>; + st,frac = <0>; + st,vcosel = <1>; + st,pllrge = <2>; + }; + }; + + +STM32H7 PLL +----------- + +The VCO of STM32 PLL could be reprensented like this: + + Vref --------- -------- + ---->| / DIVM |---->| x DIVN | ------> VCO + --------- -------- + ^ + | + ------- + | FRACN | + ------- + +When the PLL is configured in integer mode: +- VCO = ( Vref / DIVM ) * DIVN + +When the PLL is configured in fractional mode: +- VCO = ( Vref / DIVM ) * ( DIVN + FRACN / 2^13) + + +Required properties for pll node: +- compatible: Should be: + "stm32,pll" + +- #clock-cells: from common clock binding; shall be set to 0 +- reg: Should be the pll number. + +Optional properties: +- st,clock-div: DIVM division factor : <1..63> +- st,clock-mult: DIVN multiplication factor : <4..512> + +- st,frac-status: + - 0 Pll is configured in integer mode + - 1 Pll is configure in fractional mode + +- st,frac: Fractional part of the multiplication factor : <0..8191> + +- st,vcosel: VCO selection + - 0: Wide VCO range:192 to 836 MHz + - 1: Medium VCO range:150 to 420 MHz + +- st,pllrge: PLL input frequency range + - 0: The PLL input (Vref / DIVM) clock range frequency is between 1 and 2 MHz + - 1: The PLL input (Vref / DIVM) clock range frequency is between 2 and 4 MHz + - 2: The PLL input (Vref / DIVM) clock range frequency is between 4 and 8 MHz + - 3: The PLL input (Vref / DIVM) clock range frequency is between 8 and 16 MHz + + +The peripheral clock consumer should specify the desired clock by +having the clock ID in its "clocks" phandle cell. + +All available clocks are defined as preprocessor macros in +dt-bindings/clock/stm32h7-clks.h header and can be used in device +tree sources. + +Example: + + timer5: timer at 40000c00 { + compatible = "st,stm32-timer"; + reg = <0x40000c00 0x400>; + interrupts = <50>; + clocks = <&rcc TIM5_CK>; + + }; + +Specifying softreset control of devices +======================================= + +Device nodes should specify the reset channel required in their "resets" +property, containing a phandle to the reset device node and an index specifying +which channel to use. +The index is the bit number within the RCC registers bank, starting from RCC +base address. +It is calculated as: index = register_offset / 4 * 32 + bit_offset. +Where bit_offset is the bit offset within the register. + +For example, for CRC reset: + crc = AHB4RSTR_offset / 4 * 32 + CRCRST_bit_offset = 0x88 / 4 * 32 + 19 = 1107 + +All available preprocessor macros for reset are defined dt-bindings//mfd/stm32h7-rcc.h +header and can be used in device tree sources. + +example: + + timer2 { + resets = <&rcc STM32H7_APB1L_RESET(TIM2)>; + };drivers/clk/Makefile +1
-0@@ -22,3 +22,4 @@ obj-$(CONFIG_CLK_BCM6345) += clk_bcm6345.o obj-$(CONFIG_CLK_BOSTON) += clk_boston.o obj-$(CONFIG_ARCH_ASPEED) += aspeed/ obj-$(CONFIG_STM32F7) += clk_stm32f7.o +obj-$(CONFIG_STM32H7) += clk_stm32h7.odrivers/clk/clk_stm32h7.c new file +102
-0@@ -0,0 +1,802 @@ +/* +* Copyright (C) STMicroelectronics SA 2017 +* Author(s): Patrice CHOTARD, <[email protected]> for STMicroelectronics. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <clk-uclass.h> +#include <dm.h> +#include <regmap.h> +#include <syscon.h> +#include <asm/io.h> +#include <dm/root.h> + +#include <dt-bindings/clock/stm32h7-clks.h> + +DECLARE_GLOBAL_DATA_PTR ; + +/* RCC CR specific definitions */ +#define RCC_CR_HSION BIT(0) +#define RCC_CR_HSIRDY BIT(2) + +#define RCC_CR_HSEON BIT(16) +#define RCC_CR_HSERDY BIT(17) +#define RCC_CR_HSEBYP BIT(18) +#define RCC_CR_PLL1ON BIT(24) +#define RCC_CR_PLL1RDY BIT(25) + +#define RCC_CR_HSIDIV_MASK GENMASK(4, 3) +#define RCC_CR_HSIDIV_SHIFT 3 + +#define RCC_CFGR_SW_MASK GENMASK(2, 0) +#define RCC_CFGR_SW_HSI 0 +#define RCC_CFGR_SW_CSI 1 +#define RCC_CFGR_SW_HSE 2 +#define RCC_CFGR_SW_PLL1 3 + +#define RCC_PLLCKSELR_PLLSRC_HSI 0 +#define RCC_PLLCKSELR_PLLSRC_CSI 1 +#define RCC_PLLCKSELR_PLLSRC_HSE 2 +#define RCC_PLLCKSELR_PLLSRC_NO_CLK 3 + +#define RCC_PLLCKSELR_PLLSRC_MASK GENMASK(1, 0) + +#define RCC_PLLCKSELR_DIVM1_SHIFT 4 +#define RCC_PLLCKSELR_DIVM1_MASK GENMASK(9, 4) + +#define RCC_PLL1DIVR_DIVN1_MASK GENMASK(8, 0) + +#define RCC_PLL1DIVR_DIVP1_SHIFT 9 +#define RCC_PLL1DIVR_DIVP1_MASK GENMASK(15, 9) + +#define RCC_PLL1DIVR_DIVQ1_SHIFT 16 +#define RCC_PLL1DIVR_DIVQ1_MASK GENMASK(22, 16) + +#define RCC_PLL1DIVR_DIVR1_SHIFT 24 +#define RCC_PLL1DIVR_DIVR1_MASK GENMASK(30, 24) + +#define RCC_PLL1FRACR_FRACN1_SHIFT 3 +#define RCC_PLL1FRACR_FRACN1_MASK GENMASK(15, 3) + +#define RCC_PLLCFGR_PLL1RGE_SHIFT 2 +#define PLL1RGE_1_2_MHZ 0 +#define PLL1RGE_2_4_MHZ 1 +#define PLL1RGE_4_8_MHZ 2 +#define PLL1RGE_8_16_MHZ 3 +#define RCC_PLLCFGR_DIVP1EN BIT(16) +#define RCC_PLLCFGR_DIVQ1EN BIT(17) +#define RCC_PLLCFGR_DIVR1EN BIT(18) + +#define RCC_D1CFGR_HPRE_MASK GENMASK(3, 0) +#define RCC_D1CFGR_HPRE_DIVIDED BIT(3) +#define RCC_D1CFGR_HPRE_DIVIDER GENMASK(2, 0) + +#define RCC_D1CFGR_HPRE_DIV2 8 + +#define RCC_D1CFGR_D1PPRE_SHIFT 4 +#define RCC_D1CFGR_D1PPRE_DIVIDED BIT(6) +#define RCC_D1CFGR_D1PPRE_DIVIDER GENMASK(5, 4) + +#define RCC_D1CFGR_D1CPRE_SHIFT 8 +#define RCC_D1CFGR_D1CPRE_DIVIDER GENMASK(10, 8) +#define RCC_D1CFGR_D1CPRE_DIVIDED BIT(11) + +#define RCC_D2CFGR_D2PPRE1_SHIFT 4 +#define RCC_D2CFGR_D2PPRE1_DIVIDED BIT(6) +#define RCC_D2CFGR_D2PPRE1_DIVIDER GENMASK(5, 4) + +#define RCC_D2CFGR_D2PPRE2_SHIFT 8 +#define RCC_D2CFGR_D2PPRE2_DIVIDED BIT(10) +#define RCC_D2CFGR_D2PPRE2_DIVIDER GENMASK(9, 8) + +#define RCC_D3CFGR_D3PPRE_SHIFT 4 +#define RCC_D3CFGR_D3PPRE_DIVIDED BIT(6) +#define RCC_D3CFGR_D3PPRE_DIVIDER GENMASK(5, 4) + +#define RCC_D1CCIPR_FMCSRC_MASK GENMASK(1, 0) +#define FMCSRC_HCLKD1 0 +#define FMCSRC_PLL1_Q_CK 1 +#define FMCSRC_PLL2_R_CK 2 +#define FMCSRC_PER_CK 3
drivers/clk/clk_stm32h7.c line 112
Quoted 10 lines
drivers/clk/clk_stm32h7.c new file +10
-0+ +#define RCC_D1CCIPR_QSPISRC_MASK GENMASK(5, 4) +#define RCC_D1CCIPR_QSPISRC_SHIFT 4 +#define QSPISRC_HCLKD1 0 +#define QSPISRC_PLL1_Q_CK 1 +#define QSPISRC_PLL2_R_CK 2 +#define QSPISRC_PER_CK 3 + +#define PWR_CR3 0x0c +#define PWR_CR3_SDEN BIT(2)
Can we use SCUEN suffix to match the Ref Manual.
Quoted 88 lines
drivers/clk/clk_stm32h7.c new file +88
-0+#define PWR_D3CR 0x18 +#define PWR_D3CR_VOS_MASK GENMASK(15, 14) +#define PWR_D3CR_VOS_SHIFT 14 +#define VOS_SCALE_3 1 +#define VOS_SCALE_2 2 +#define VOS_SCALE_1 3 +#define PWR_D3CR_VOSREADY BIT(13) + +struct stm32_rcc_regs { +u32 cr;/* 0x00 Source Control Register */ +u32 icscr;/* 0x04 Internal Clock Source Calibration Register */ +u32 crrcr;/* 0x08 Clock Recovery RC Register */ +u32 reserved1;/* 0x0c reserved */ +u32 cfgr;/* 0x10 Clock Configuration Register */ +u32 reserved2;/* 0x14 reserved */ +u32 d1cfgr;/* 0x18 Domain 1 Clock Configuration Register */ +u32 d2cfgr;/* 0x1c Domain 2 Clock Configuration Register */ +u32 d3cfgr;/* 0x20 Domain 3 Clock Configuration Register */ +u32 reserved3;/* 0x24 reserved */ +u32 pllckselr;/* 0x28 PLLs Clock Source Selection Register */ +u32 pllcfgr;/* 0x2c PLLs Configuration Register */ +u32 pll1divr;/* 0x30 PLL1 Dividers Configuration Register */ +u32 pll1fracr;/* 0x34 PLL1 Fractional Divider Register */ +u32 pll2divr;/* 0x38 PLL2 Dividers Configuration Register */ +u32 pll2fracr;/* 0x3c PLL2 Fractional Divider Register */ +u32 pll3divr;/* 0x40 PLL3 Dividers Configuration Register */ +u32 pll3fracr;/* 0x44 PLL3 Fractional Divider Register */ +u32 reserved4;/* 0x48 reserved */ +u32 d1ccipr;/* 0x4c Domain 1 Kernel Clock Configuration Register */ +u32 d2ccip1r;/* 0x50 Domain 2 Kernel Clock Configuration Register */ +u32 d2ccip2r;/* 0x54 Domain 2 Kernel Clock Configuration Register */ +u32 d3ccipr;/* 0x58 Domain 3 Kernel Clock Configuration Register */ +u32 reserved5;/* 0x5c reserved */ +u32 cier;/* 0x60 Clock Source Interrupt Enable Register */ +u32 cifr;/* 0x64 Clock Source Interrupt Flag Register */ +u32 cicr;/* 0x68 Clock Source Interrupt Clear Register */ +u32 reserved6;/* 0x6c reserved */ +u32 bdcr;/* 0x70 Backup Domain Control Register */ +u32 csr;/* 0x74 Clock Control and Status Register */ +u32 reserved7;/* 0x78 reserved */ + +u32 ahb3rstr;/* 0x7c AHB3 Peripheral Reset Register */ +u32 ahb1rstr;/* 0x80 AHB1 Peripheral Reset Register */ +u32 ahb2rstr;/* 0x84 AHB2 Peripheral Reset Register */ +u32 ahb4rstr;/* 0x88 AHB4 Peripheral Reset Register */ + +u32 apb3rstr;/* 0x8c APB3 Peripheral Reset Register */ +u32 apb1lrstr;/* 0x90 APB1 low Peripheral Reset Register */ +u32 apb1hrstr;/* 0x94 APB1 high Peripheral Reset Register */ +u32 apb2rstr;/* 0x98 APB2 Clock Register */ +u32 apb4rstr;/* 0x9c APB4 Clock Register */ + +u32 gcr;/* 0xa0 Global Control Register */ +u32 reserved8;/* 0xa4 reserved */ +u32 d3amr;/* 0xa8 D3 Autonomous mode Register */ +u32 reserved9[9 ];/* 0xac to 0xcc reserved */ +u32 rsr;/* 0xd0 Reset Status Register */ +u32 ahb3enr;/* 0xd4 AHB3 Clock Register */ +u32 ahb1enr;/* 0xd8 AHB1 Clock Register */ +u32 ahb2enr;/* 0xdc AHB2 Clock Register */ +u32 ahb4enr;/* 0xe0 AHB4 Clock Register */ + +u32 apb3enr;/* 0xe4 APB3 Clock Register */ +u32 apb1lenr;/* 0xe8 APB1 low Clock Register */ +u32 apb1henr;/* 0xec APB1 high Clock Register */ +u32 apb2enr;/* 0xf0 APB2 Clock Register */ +u32 apb4enr;/* 0xf4 APB4 Clock Register */ +}; + +#define RCC_AHB3ENR offsetof(struct stm32_rcc_regs, ahb3enr) +#define RCC_AHB1ENR offsetof(struct stm32_rcc_regs, ahb1enr) +#define RCC_AHB2ENR offsetof(struct stm32_rcc_regs, ahb2enr) +#define RCC_AHB4ENR offsetof(struct stm32_rcc_regs, ahb4enr) +#define RCC_APB3ENR offsetof(struct stm32_rcc_regs, apb3enr) +#define RCC_APB1LENR offsetof(struct stm32_rcc_regs, apb1lenr) +#define RCC_APB1HENR offsetof(struct stm32_rcc_regs, apb1henr) +#define RCC_APB2ENR offsetof(struct stm32_rcc_regs, apb2enr) +#define RCC_APB4ENR offsetof(struct stm32_rcc_regs, apb4enr) + +struct clk_cfg { +u32 gate_offset; +u8 gate_bit_idx; +const char *name; +}; + +#define CLK (_gate_offset, _bit_idx, _name) \ +{ \ + .gate_offset = _gate_offset,\
drivers/clk/clk_stm32h7.c line 210
Quoted 10 lines
drivers/clk/clk_stm32h7.c new file +10
-0+ .gate_bit_idx = _bit_idx,\ + .name = _name,\ +} + +/* +* the way all these entries are sorted in this array could seem +* unlogical, but we are dependant of kernel DT_bindings, +* where clocks are separate in 2 banks, peripheral clocks and +* kernel clocks. +*/
it destroys the purpose of device tree if we are embedding all the info in the structure array. In addition expensive in terms of memory usage.
drivers/clk/clk_stm32h7.c line 213
Quoted 3 lines
drivers/clk/clk_stm32h7.c new file +3
-0+ +static const struct clk_cfg clk_map[] = { +CLK (RCC_AHB3ENR ,31 ,"d1sram1" ),/* peripheral clocks */
Do we need CLK Macro, {RCC_AHB3ENR, 31, "d1sram1"} should work fine.
Quoted 148 lines
drivers/clk/clk_stm32h7.c new file +148
-0+CLK (RCC_AHB3ENR ,30 ,"itcm" ), +CLK (RCC_AHB3ENR ,29 ,"dtcm2" ), +CLK (RCC_AHB3ENR ,28 ,"dtcm1" ), +CLK (RCC_AHB3ENR ,8 ,"flitf" ), +CLK (RCC_AHB3ENR ,5 ,"jpgdec" ), +CLK (RCC_AHB3ENR ,4 ,"dma2d" ), +CLK (RCC_AHB3ENR ,0 ,"mdma" ), +CLK (RCC_AHB1ENR ,28 ,"usb2ulpi" ), +CLK (RCC_AHB1ENR ,17 ,"eth1rx" ), +CLK (RCC_AHB1ENR ,16 ,"eth1tx" ), +CLK (RCC_AHB1ENR ,15 ,"eth1mac" ), +CLK (RCC_AHB1ENR ,14 ,"art" ), +CLK (RCC_AHB1ENR ,26 ,"usb1ulpi" ), +CLK (RCC_AHB1ENR ,1 ,"dma2" ), +CLK (RCC_AHB1ENR ,0 ,"dma1" ), +CLK (RCC_AHB2ENR ,31 ,"d2sram3" ), +CLK (RCC_AHB2ENR ,30 ,"d2sram2" ), +CLK (RCC_AHB2ENR ,29 ,"d2sram1" ), +CLK (RCC_AHB2ENR ,5 ,"hash" ), +CLK (RCC_AHB2ENR ,4 ,"crypt" ), +CLK (RCC_AHB2ENR ,0 ,"camitf" ), +CLK (RCC_AHB4ENR ,28 ,"bkpram" ), +CLK (RCC_AHB4ENR ,25 ,"hsem" ), +CLK (RCC_AHB4ENR ,21 ,"bdma" ), +CLK (RCC_AHB4ENR ,19 ,"crc" ), +CLK (RCC_AHB4ENR ,10 ,"gpiok" ), +CLK (RCC_AHB4ENR ,9 ,"gpioj" ), +CLK (RCC_AHB4ENR ,8 ,"gpioi" ), +CLK (RCC_AHB4ENR ,7 ,"gpioh" ), +CLK (RCC_AHB4ENR ,6 ,"gpiog" ), +CLK (RCC_AHB4ENR ,5 ,"gpiof" ), +CLK (RCC_AHB4ENR ,4 ,"gpioe" ), +CLK (RCC_AHB4ENR ,3 ,"gpiod" ), +CLK (RCC_AHB4ENR ,2 ,"gpioc" ), +CLK (RCC_AHB4ENR ,1 ,"gpiob" ), +CLK (RCC_AHB4ENR ,0 ,"gpioa" ), +CLK (RCC_APB3ENR ,6 ,"wwdg1" ), +CLK (RCC_APB1LENR ,29 ,"dac12" ), +CLK (RCC_APB1LENR ,11 ,"wwdg2" ), +CLK (RCC_APB1LENR ,8 ,"tim14" ), +CLK (RCC_APB1LENR ,7 ,"tim13" ), +CLK (RCC_APB1LENR ,6 ,"tim12" ), +CLK (RCC_APB1LENR ,5 ,"tim7" ), +CLK (RCC_APB1LENR ,4 ,"tim6" ), +CLK (RCC_APB1LENR ,3 ,"tim5" ), +CLK (RCC_APB1LENR ,2 ,"tim4" ), +CLK (RCC_APB1LENR ,1 ,"tim3" ), +CLK (RCC_APB1LENR ,0 ,"tim2" ), +CLK (RCC_APB1HENR ,5 ,"mdios" ), +CLK (RCC_APB1HENR ,4 ,"opamp" ), +CLK (RCC_APB1HENR ,1 ,"crs" ), +CLK (RCC_APB2ENR ,18 ,"tim17" ), +CLK (RCC_APB2ENR ,17 ,"tim16" ), +CLK (RCC_APB2ENR ,16 ,"tim15" ), +CLK (RCC_APB2ENR ,1 ,"tim8" ), +CLK (RCC_APB2ENR ,0 ,"tim1" ), +CLK (RCC_APB4ENR ,26 ,"tmpsens" ), +CLK (RCC_APB4ENR ,16 ,"rtcapb" ), +CLK (RCC_APB4ENR ,15 ,"vref" ), +CLK (RCC_APB4ENR ,14 ,"comp12" ), +CLK (RCC_APB4ENR ,1 ,"syscfg" ), +CLK (RCC_AHB3ENR ,16 ,"sdmmc1" ),/* kernel clocks */ +CLK (RCC_AHB3ENR ,14 ,"quadspi" ), +CLK (RCC_AHB3ENR ,12 ,"fmc" ), +CLK (RCC_AHB1ENR ,27 ,"usb2otg" ), +CLK (RCC_AHB1ENR ,25 ,"usb1otg" ), +CLK (RCC_AHB1ENR ,5 ,"adc12" ), +CLK (RCC_AHB2ENR ,9 ,"sdmmc2" ), +CLK (RCC_AHB2ENR ,6 ,"rng" ), +CLK (RCC_AHB4ENR ,24 ,"adc3" ), +CLK (RCC_APB3ENR ,4 ,"dsi" ), +CLK (RCC_APB3ENR ,3 ,"ltdc" ), +CLK (RCC_APB1LENR ,31 ,"usart8" ), +CLK (RCC_APB1LENR ,30 ,"usart7" ), +CLK (RCC_APB1LENR ,27 ,"hdmicec" ), +CLK (RCC_APB1LENR ,23 ,"i2c3" ), +CLK (RCC_APB1LENR ,22 ,"i2c2" ), +CLK (RCC_APB1LENR ,21 ,"i2c1" ), +CLK (RCC_APB1LENR ,20 ,"uart5" ), +CLK (RCC_APB1LENR ,19 ,"uart4" ), +CLK (RCC_APB1LENR ,18 ,"usart3" ), +CLK (RCC_APB1LENR ,17 ,"usart2" ), +CLK (RCC_APB1LENR ,16 ,"spdifrx" ), +CLK (RCC_APB1LENR ,15 ,"spi3" ), +CLK (RCC_APB1LENR ,14 ,"spi2" ), +CLK (RCC_APB1LENR ,9 ,"lptim1" ), +CLK (RCC_APB1HENR ,8 ,"fdcan" ), +CLK (RCC_APB1HENR ,2 ,"swp" ), +CLK (RCC_APB2ENR ,29 ,"hrtim" ), +CLK (RCC_APB2ENR ,28 ,"dfsdm1" ), +CLK (RCC_APB2ENR ,24 ,"sai3" ), +CLK (RCC_APB2ENR ,23 ,"sai2" ), +CLK (RCC_APB2ENR ,22 ,"sai1" ), +CLK (RCC_APB2ENR ,20 ,"spi5" ), +CLK (RCC_APB2ENR ,13 ,"spi4" ), +CLK (RCC_APB2ENR ,12 ,"spi1" ), +CLK (RCC_APB2ENR ,5 ,"usart6" ), +CLK (RCC_APB2ENR ,4 ,"usart1" ), +CLK (RCC_APB4ENR ,21 ,"sai4a" ), +CLK (RCC_APB4ENR ,21 ,"sai4b" ), +CLK (RCC_APB4ENR ,12 ,"lptim5" ), +CLK (RCC_APB4ENR ,11 ,"lptim4" ), +CLK (RCC_APB4ENR ,10 ,"lptim3" ), +CLK (RCC_APB4ENR ,9 ,"lptim2" ), +CLK (RCC_APB4ENR ,7 ,"i2c4" ), +CLK (RCC_APB4ENR ,5 ,"spi6" ), + CLK(RCC_APB4ENR, 3, "lpuart1"), +}; + +struct stm32_clk { +struct stm32_rcc_regs *rcc_base; +struct regmap *pwr_regmap; +}; + +struct pll_psc { +u8 divm; +u16 divn; +u8 divp; +u8 divq; +u8 divr; +}; + +/* +* OSC_HSE = 25 MHz +* VCO = 500MHz +* pll1_p = 250MHz / pll1_q = 250MHz pll1_r = 250Mhz +*/ +struct pll_psc sys_pll_psc = { + .divm =4 , + .divn =80 , + .divp =2 , + .divq =2 , + .divr =2 , +}; + +int configure_clocks (struct udevice *dev) +{ +struct stm32_clk *priv =dev_get_priv (dev); +struct stm32_rcc_regs *regs = priv->rcc_base; +uint8_t *pwr_base = (uint8_t *)regmap_get_range (priv->pwr_regmap,0 ); +uint32_t pllckselr =0 ; +uint32_t pll1divr =0 ; +uint32_t pllcfgr =0 ; + +/* Switch on HSI */ +setbits_le32 (®s->cr,RCC_CR_HSION ); +while (!(readl (®s->cr) &RCC_CR_HSIRDY )) + ;
drivers/clk/clk_stm32h7.c line 371
Quoted 10 lines
drivers/clk/clk_stm32h7.c new file +10
-0+ +/* Reset CFGR, now HSI is the default system clock */ +writel (0 , ®s->cfgr); + +/* Set all kernel domain clock registers to reset value*/ +writel (0x0 , ®s->d1ccipr); +writel (0x0 , ®s->d2ccip1r); +writel (0x0 , ®s->d2ccip2r); + +/* Set voltage scaling at scale 1 */
pls add info what is scale1
drivers/clk/clk_stm32h7.c line 374
Quoted 3 lines
drivers/clk/clk_stm32h7.c new file +3
-0+clrsetbits_le32 (pwr_base +PWR_D3CR ,PWR_D3CR_VOS_MASK , +VOS_SCALE_1 <<PWR_D3CR_VOS_SHIFT ); +/* disable step down converter */
is this comment correct ?
Quoted 362 lines
drivers/clk/clk_stm32h7.c new file +362
-0+clrbits_le32 (pwr_base +PWR_CR3 ,PWR_CR3_SDEN ); +while (!(readl (pwr_base +PWR_D3CR ) &PWR_D3CR_VOSREADY )) + ; + +/* disable HSE to configure it */ +clrbits_le32 (®s->cr,RCC_CR_HSEON ); +while ((readl (®s->cr) &RCC_CR_HSERDY )) + ; + +/* clear HSE bypass and set it ON */ +clrbits_le32 (®s->cr,RCC_CR_HSEBYP ); +/* Switch on HSE */ +setbits_le32 (®s->cr,RCC_CR_HSEON ); +while (!(readl (®s->cr) &RCC_CR_HSERDY )) + ; + +/* pll setup, disable it */ +clrbits_le32 (®s->cr,RCC_CR_PLL1ON ); +while ((readl (®s->cr) &RCC_CR_PLL1RDY )) + ; + +/* Select HSE as PLL clock source */ + pllckselr |=RCC_PLLCKSELR_PLLSRC_HSE ; + pllckselr |= sys_pll_psc.divm <<RCC_PLLCKSELR_DIVM1_SHIFT ; +writel (pllckselr, ®s->pllckselr); + + pll1divr |= (sys_pll_psc.divr -1 ) <<RCC_PLL1DIVR_DIVR1_SHIFT ; + pll1divr |= (sys_pll_psc.divq -1 ) <<RCC_PLL1DIVR_DIVQ1_SHIFT ; + pll1divr |= (sys_pll_psc.divp -1 ) <<RCC_PLL1DIVR_DIVP1_SHIFT ; + pll1divr |= (sys_pll_psc.divn -1 ); +writel (pll1divr, ®s->pll1divr); + + pllcfgr |=PLL1RGE_4_8_MHZ <<RCC_PLLCFGR_PLL1RGE_SHIFT ; + pllcfgr |=RCC_PLLCFGR_DIVP1EN ; + pllcfgr |=RCC_PLLCFGR_DIVQ1EN ; + pllcfgr |=RCC_PLLCFGR_DIVR1EN ; +writel (pllcfgr, ®s->pllcfgr); + +/* pll setup, enable it */ +setbits_le32 (®s->cr,RCC_CR_PLL1ON ); + +/* set HPRE (/2) DI clk --> 125MHz */ +clrsetbits_le32 (®s->d1cfgr,RCC_D1CFGR_HPRE_MASK , +RCC_D1CFGR_HPRE_DIV2 ); + +/* select PLL1 as system clock source (sys_ck)*/ +clrsetbits_le32 (®s->cfgr,RCC_CFGR_SW_MASK ,RCC_CFGR_SW_PLL1 ); +while ((readl (®s->cfgr) &RCC_CFGR_SW_MASK ) !=RCC_CFGR_SW_PLL1 ) + ; + +/* sdram: use pll1_q as fmc_k clk */ +clrsetbits_le32 (®s->d1ccipr,RCC_D1CCIPR_FMCSRC_MASK , +FMCSRC_PLL1_Q_CK ); + +return 0 ; +} + +static u32 stm32_get_HSI_divider (struct stm32_rcc_regs *regs) +{ +u32 divider; + +/* get HSI divider value */ + divider =readl (®s->cr) &RCC_CR_HSIDIV_MASK ; + divider = divider >>RCC_CR_HSIDIV_SHIFT ; + +return divider; +}; + +enum pllsrc { +HSE , +LSE , +HSI , +CSI , +I2S , +TIMER , +PLLSRC_NB , +}; + +static const char *const pllsrc_name[PLLSRC_NB ] = { + [HSE ] ="clk-hse" , + [LSE ] ="clk-lse" , + [HSI ] ="clk-hsi" , + [CSI ] ="clk-csi" , + [I2S ] ="clk-i2s" , + [TIMER ] ="timer-clk" +}; + +static ulong stm32_get_rate (struct stm32_rcc_regs *regs,enum pllsrc pllsrc) +{ +struct clk clk; +struct udevice *fixed_clock_dev =NULL ; +u32 divider; +int ret; +const char *name = pllsrc_name[pllsrc]; + +debug ("%s name %s\n" , __func__, name); + + clk.id =0 ; + ret =uclass_get_device_by_name (UCLASS_CLK , name, &fixed_clock_dev); +if (ret) { +error ("Can't find clk %s (%d)" , name, ret); +return 0 ; + } + + ret =clk_request (fixed_clock_dev, &clk); +if (ret) { +error ("Can't request %s clk (%d)" , name, ret); +return 0 ; + } + + divider =0 ; +if (pllsrc ==HSI ) + divider =stm32_get_HSI_divider (regs); + +debug ("%s divider %d rate %ld\n" , __func__, + divider,clk_get_rate (&clk)); + +return clk_get_rate (&clk) >> divider; +}; + +enum pll1_output { +PLL1_P_CK , +PLL1_Q_CK , +PLL1_R_CK , +}; + +static u32 stm32_get_PLL1_rate (struct stm32_rcc_regs *regs, +enum pll1_output output) +{ +ulong pllsrc =0 ; +u32 divm1, divn1, divp1, divq1, divr1, fracn1; +ulong vco, rate; + +/* get the PLLSRC */ +switch (readl (®s->pllckselr) &RCC_PLLCKSELR_PLLSRC_MASK ) { +case RCC_PLLCKSELR_PLLSRC_HSI : + pllsrc =stm32_get_rate (regs,HSI ); +break ; +case RCC_PLLCKSELR_PLLSRC_CSI : + pllsrc =stm32_get_rate (regs,CSI ); +break ; +case RCC_PLLCKSELR_PLLSRC_HSE : + pllsrc =stm32_get_rate (regs,HSE ); +break ; +case RCC_PLLCKSELR_PLLSRC_NO_CLK : +/* shouldn't happen */ +error ("wrong value for RCC_PLLCKSELR register\n" ); + pllsrc =0 ; +break ; + } + +/* pllsrc = 0 ? no need to go ahead */ +if (!pllsrc) +return pllsrc; + +/* get divm1, divp1, divn1 and divr1 */ + divm1 =readl (®s->pllckselr) &RCC_PLLCKSELR_DIVM1_MASK ; + divm1 = divm1 >>RCC_PLLCKSELR_DIVM1_SHIFT ; + + divn1 = (readl (®s->pll1divr) &RCC_PLL1DIVR_DIVN1_MASK ) +1 ; + + divp1 =readl (®s->pll1divr) &RCC_PLL1DIVR_DIVP1_MASK ; + divp1 = (divp1 >>RCC_PLL1DIVR_DIVP1_SHIFT ) +1 ; + + divq1 =readl (®s->pll1divr) &RCC_PLL1DIVR_DIVQ1_MASK ; + divq1 = (divq1 >>RCC_PLL1DIVR_DIVQ1_SHIFT ) +1 ; + + divr1 =readl (®s->pll1divr) &RCC_PLL1DIVR_DIVR1_MASK ; + divr1 = (divr1 >>RCC_PLL1DIVR_DIVR1_SHIFT ) +1 ; + + fracn1 =readl (®s->pll1fracr) &RCC_PLL1DIVR_DIVR1_MASK ; + fracn1 = fracn1 &RCC_PLL1DIVR_DIVR1_SHIFT ; + + vco = (pllsrc / divm1) * divn1; + rate = (pllsrc * fracn1) / (divm1 *8192 ); + +debug ("%s divm1 = %d divn1 = %d divp1 = %d divq1 = %d divr1 = %d\n" , + __func__, divm1, divn1, divp1, divq1, divr1); +debug ("%s fracn1 = %d vco = %ld rate = %ld\n" , + __func__, fracn1, vco, rate); + +switch (output) { +case PLL1_P_CK : +return (vco + rate) / divp1; +break ; +case PLL1_Q_CK : +return (vco + rate) / divq1; +break ; + +case PLL1_R_CK : +return (vco + rate) / divr1; +break ; + } + +return -EINVAL ; +} + +static ulong stm32_clk_get_rate (struct clk *clk) +{ +struct stm32_clk *priv =dev_get_priv (clk->dev); +struct stm32_rcc_regs *regs = priv->rcc_base; +ulong sysclk =0 ; +u32 gate_offset; +u32 d1cfgr; +/* prescaler table lookups for clock computation */ +u16 prescaler_table[8 ] = {2 ,4 ,8 ,16 ,64 ,128 ,256 ,512 }; +u8 source, idx; + +/* +* get system clock (sys_ck) source +* can be HSI_CK, CSI_CK, HSE_CK or pll1_p_ck +*/ + source =readl (®s->cfgr) &RCC_CFGR_SW_MASK ; +switch (source) { +case RCC_CFGR_SW_PLL1 : + sysclk =stm32_get_PLL1_rate (regs,PLL1_P_CK ); +break ; +case RCC_CFGR_SW_HSE : + sysclk =stm32_get_rate (regs,HSE ); +break ; + +case RCC_CFGR_SW_CSI : + sysclk =stm32_get_rate (regs,CSI ); +break ; + +case RCC_CFGR_SW_HSI : + sysclk =stm32_get_rate (regs,HSI ); +break ; + } + +/* sysclk = 0 ? no need to go ahead */ +if (!sysclk) +return sysclk; + +debug ("%s system clock: source = %d freq = %ld\n" , + __func__, source, sysclk); + + d1cfgr =readl (®s->d1cfgr); + +if (d1cfgr &RCC_D1CFGR_D1CPRE_DIVIDED ) { +/* get D1 domain Core prescaler */ + idx = (d1cfgr &RCC_D1CFGR_D1CPRE_DIVIDER ) >> +RCC_D1CFGR_D1CPRE_SHIFT ; + sysclk = sysclk / prescaler_table[idx]; + } + +if (d1cfgr &RCC_D1CFGR_HPRE_DIVIDED ) { +/* get D1 domain AHB prescaler */ + idx = d1cfgr &RCC_D1CFGR_HPRE_DIVIDER ; + sysclk = sysclk / prescaler_table[idx]; + } + + gate_offset = clk_map[clk->id].gate_offset; + +debug ("%s clk->id=%ld gate_offset=0x%x sysclk=%ld\n" , + __func__, clk->id, gate_offset, sysclk); + +switch (gate_offset) { +case RCC_AHB3ENR : +case RCC_AHB1ENR : +case RCC_AHB2ENR : +case RCC_AHB4ENR : +return sysclk; +break ; + +case RCC_APB3ENR : +if (d1cfgr &RCC_D1CFGR_D1PPRE_DIVIDED ) { +/* get D1 domain APB3 prescaler */ + idx = (d1cfgr &RCC_D1CFGR_D1PPRE_DIVIDER ) >> +RCC_D1CFGR_D1PPRE_SHIFT ; + sysclk = sysclk / prescaler_table[idx]; + } + +debug ("%s system clock: freq after APB3 prescaler = %ld\n" , + __func__, sysclk); + +return sysclk; +break ; + +case RCC_APB4ENR : +if (d1cfgr &RCC_D3CFGR_D3PPRE_DIVIDED ) { +/* get D3 domain APB4 prescaler */ + idx = (d1cfgr &RCC_D3CFGR_D3PPRE_DIVIDER ) >> +RCC_D3CFGR_D3PPRE_SHIFT ; + sysclk = sysclk / prescaler_table[idx]; + } + +debug ("%s system clock: freq after APB4 prescaler = %ld\n" , + __func__, sysclk); + +return sysclk; +break ; + +case RCC_APB1LENR : +case RCC_APB1HENR : +if (d1cfgr &RCC_D2CFGR_D2PPRE1_DIVIDED ) { +/* get D2 domain APB1 prescaler */ + idx = (d1cfgr &RCC_D2CFGR_D2PPRE1_DIVIDER ) >> +RCC_D2CFGR_D2PPRE1_SHIFT ; + sysclk = sysclk / prescaler_table[idx]; + } + +debug ("%s system clock: freq after APB1 prescaler = %ld\n" , + __func__, sysclk); + +return sysclk; +break ; + +case RCC_APB2ENR : +if (d1cfgr &RCC_D2CFGR_D2PPRE2_DIVIDED ) { +/* get D2 domain APB1 prescaler */ + idx = (d1cfgr &RCC_D2CFGR_D2PPRE2_DIVIDER ) >> +RCC_D2CFGR_D2PPRE2_SHIFT ; + sysclk = sysclk / prescaler_table[idx]; + } + +debug ("%s system clock: freq after APB2 prescaler = %ld\n" , + __func__, sysclk); + +return sysclk; +break ; + +default : +error ("unexpected gate_offset value (0x%x)\n" , gate_offset); +return -EINVAL ; +break ; + } +} + +static int stm32_clk_enable (struct clk *clk) +{ +struct stm32_clk *priv =dev_get_priv (clk->dev); +struct stm32_rcc_regs *regs = priv->rcc_base; +u32 gate_offset; +u32 gate_bit_index; +unsigned long clk_id = clk->id; + + gate_offset = clk_map[clk_id].gate_offset; + gate_bit_index = clk_map[clk_id].gate_bit_idx; + +debug ("%s: clkid=%ld gate offset=0x%x bit_index=%d name=%s\n" , + __func__, clk->id, gate_offset, gate_bit_index, + clk_map[clk_id].name); + +setbits_le32 (®s->cr + (gate_offset /4 ),BIT (gate_bit_index)); + +return 0 ; +} + +static int stm32_clk_probe (struct udevice *dev) +{ +struct stm32_clk *priv =dev_get_priv (dev); +struct udevice *syscon; +fdt_addr_t addr; +int err; + + addr =dev_read_addr (dev); +if (addr ==FDT_ADDR_T_NONE ) +return -EINVAL ; + + priv->rcc_base = (struct stm32_rcc_regs *)addr; +
drivers/clk/clk_stm32h7.c line 746
Quoted 10 lines
drivers/clk/clk_stm32h7.c new file +10
-0+/* get corresponding syscon phandle */ + err =uclass_get_device_by_phandle (UCLASS_SYSCON , dev, +"st,syscfg" , &syscon); + +if (err) { +error ("unable to find syscon device\n" ); +return err; + } + + priv->pwr_regmap =syscon_get_regmap (syscon);
why SYSCON_UCLASS...It is used just to get the base address of power control block ? It can be done directly from the phandle also, e.g. fdt_node_offset_by_phandle() or similar.
Cheers,
Vikas
Quoted 230 lines
drivers/clk/clk_stm32h7.c new file +56
-0+if (!priv->pwr_regmap) { +error ("unable to find regmap\n" ); +return -ENODEV ; + } + +configure_clocks (dev); + +return 0 ; +} + +static int stm32_clk_of_xlate (struct clk *clk, +struct ofnode_phandle_args *args) +{ +if (args->args_count !=1 ) { +debug ("Invaild args_count: %d\n" , args->args_count); +return -EINVAL ; + } + +if (args->args_count) { + clk->id = args->args[0 ]; +/* +* this computation convert DT clock index which is used to +* point into 2 separate clock arrays (peripheral and kernel +* clocks bank) (see include/dt-bindings/clock/stm32h7-clks.h) +* into index to point into only one array where peripheral +* and kernel clocks are consecutive +*/ +if (clk->id >=KERN_BANK ) { + clk->id -=KERN_BANK ; + clk->id +=LAST_PERIF_BANK -PERIF_BANK +1 ; + }else { + clk->id -=PERIF_BANK ; + } + }else { + clk->id =0 ; + } + +debug ("%s clk->id %ld\n" , __func__, clk->id); + +return 0 ; +} + +static struct clk_ops stm32_clk_ops = { + .of_xlate = stm32_clk_of_xlate, + .enable = stm32_clk_enable, + .get_rate = stm32_clk_get_rate, +}; + +U_BOOT_DRIVER (stm32h7_clk) = { + .name ="stm32h7_rcc_clock" , + .id =UCLASS_CLK , + .ops = &stm32_clk_ops, + .probe = stm32_clk_probe, + .priv_auto_alloc_size =sizeof (struct stm32_clk ), + .flags =DM_FLAG_PRE_RELOC , +};include/dt-bindings/clock/stm32h7-clks.h new file +167
-0@@ -0,0 +1,167 @@ +/* SYS, CORE AND BUS CLOCKS */ +#define SYS_D1CPRE 0 +#define HCLK 1 +#define PCLK1 2 +#define PCLK2 3 +#define PCLK3 4 +#define PCLK4 5 +#define HSI_DIV 6 +#define HSE_1M 7 +#define I2S_CKIN 8 +#define CK_DSI_PHY 9 +#define HSE_CK 10 +#define LSE_CK 11 +#define CSI_KER_DIV122 12 +#define RTC_CK 13 +#define CPU_SYSTICK 14 + +/* OSCILLATOR BANK */ +#define OSC_BANK 18 +#define HSI_CK 18 +#define HSI_KER_CK 19 +#define CSI_CK 20 +#define CSI_KER_CK 21 +#define RC48_CK 22 +#define LSI_CK 23 + +/* MCLOCK BANK */ +#define MCLK_BANK 28 +#define PER_CK 28 +#define PLLSRC 29 +#define SYS_CK 30 +#define TRACEIN_CK 31 + +/* ODF BANK */ +#define ODF_BANK 32 +#define PLL1_P 32 +#define PLL1_Q 33 +#define PLL1_R 34 +#define PLL2_P 35 +#define PLL2_Q 36 +#define PLL2_R 37 +#define PLL3_P 38 +#define PLL3_Q 39 +#define PLL3_R 40 + +/* MCO BANK */ +#define MCO_BANK 41 +#define MCO1 41 +#define MCO2 42 + +/* PERIF BANK */ +#define PERIF_BANK 50 +#define D1SRAM1_CK 50 +#define ITCM_CK 51 +#define DTCM2_CK 52 +#define DTCM1_CK 53 +#define FLITF_CK 54 +#define JPGDEC_CK 55 +#define DMA2D_CK 56 +#define MDMA_CK 57 +#define USB2ULPI_CK 58 +#define USB1ULPI_CK 59 +#define ETH1RX_CK 60 +#define ETH1TX_CK 61 +#define ETH1MAC_CK 62 +#define ART_CK 63 +#define DMA2_CK 64 +#define DMA1_CK 65 +#define D2SRAM3_CK 66 +#define D2SRAM2_CK 67 +#define D2SRAM1_CK 68 +#define HASH_CK 69 +#define CRYPT_CK 70 +#define CAMITF_CK 71 +#define BKPRAM_CK 72 +#define HSEM_CK 73 +#define BDMA_CK 74 +#define CRC_CK 75 +#define GPIOK_CK 76 +#define GPIOJ_CK 77 +#define GPIOI_CK 78 +#define GPIOH_CK 79 +#define GPIOG_CK 80 +#define GPIOF_CK 81 +#define GPIOE_CK 82 +#define GPIOD_CK 83 +#define GPIOC_CK 84 +#define GPIOB_CK 85 +#define GPIOA_CK 86 +#define WWDG1_CK 87 +#define DAC12_CK 88 +#define WWDG2_CK 89 +#define TIM14_CK 90 +#define TIM13_CK 91 +#define TIM12_CK 92 +#define TIM7_CK 93 +#define TIM6_CK 94 +#define TIM5_CK 95 +#define TIM4_CK 96 +#define TIM3_CK 97 +#define TIM2_CK 98 +#define MDIOS_CK 99 +#define OPAMP_CK 100 +#define CRS_CK 101 +#define TIM17_CK 102 +#define TIM16_CK 103 +#define TIM15_CK 104 +#define TIM8_CK 105 +#define TIM1_CK 106 +#define TMPSENS_CK 107 +#define RTCAPB_CK 108 +#define VREF_CK 109 +#define COMP12_CK 110 +#define SYSCFG_CK 111 +/* must be equal to last peripheral clock index */ +#define LAST_PERIF_BANK SYSCFG_CK + +/* KERNEL BANK */ +#define KERN_BANK 120 +#define SDMMC1_CK 120 +#define QUADSPI_CK 121 +#define FMC_CK 122 +#define USB2OTG_CK 123 +#define USB1OTG_CK 124 +#define ADC12_CK 125 +#define SDMMC2_CK 126 +#define RNG_CK 127 +#define ADC3_CK 128 +#define DSI_CK 129 +#define LTDC_CK 130 +#define USART8_CK 131 +#define USART7_CK 132 +#define HDMICEC_CK 133 +#define I2C3_CK 134 +#define I2C2_CK 135 +#define I2C1_CK 136 +#define UART5_CK 137 +#define UART4_CK 138 +#define USART3_CK 139 +#define USART2_CK 140 +#define SPDIFRX_CK 141 +#define SPI3_CK 142 +#define SPI2_CK 143 +#define LPTIM1_CK 144 +#define FDCAN_CK 145 +#define SWP_CK 146 +#define HRTIM_CK 147 +#define DFSDM1_CK 148 +#define SAI3_CK 149 +#define SAI2_CK 150 +#define SAI1_CK 151 +#define SPI5_CK 152 +#define SPI4_CK 153 +#define SPI1_CK 154 +#define USART6_CK 155 +#define USART1_CK 156 +#define SAI4B_CK 157 +#define SAI4A_CK 158 +#define LPTIM5_CK 159 +#define LPTIM4_CK 160 +#define LPTIM3_CK 161 +#define LPTIM2_CK 162 +#define I2C4_CK 163 +#define SPI6_CK 164 +#define LPUART1_CK 165 + +#define STM32H7_MAX_CLKS 166
PATCH v2 3/9 dm: clk: add clk driver support for stm32h7 SoCs
Hi Vikas
Quoted 56 lines · Vikas Manocha
Hi Patrice,
Quoted 53 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
This driver implements basic clock setup, only clock gating is implemented.
This driver doesn't implement .of_match as it's binded by MFD RCC driver.
Files
include/dt-bindings/clock/stm32h7-clks.handdoc/device-tree-bindings/clock/st,stm32h7-rcc.txtwill be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
Signed-off-by Patrice Chotard <[email protected]>--- doc/device-tree-bindings/clock/st,stm32h7-rcc.txt | 152 ++++ drivers/clk/Makefile | 1 + drivers/clk/clk_stm32h7.c | 802 ++++++++++++++++++++++ include/dt-bindings/clock/stm32h7-clks.h | 167 +++++ 4 files changed, 1122 insertions(+)create mode 100644
doc/device-tree-bindings/clock/st,stm32h7-rcc.txtcreate mode 100644drivers/clk/clk_stm32h7.c
create mode 100644include/dt-bindings/clock/stm32h7-clks.hdoc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +21
-0@@ -0,0 +1,152 @@ +STMicroelectronics STM32H7 Reset and Clock Controller +===================================================== + +The RCC IP is both a reset and a clock controller. + +Please refer to clock-bindings.txt for common clock controller binding usage. +Please also refer to reset.txt for common reset controller binding usage. + +Required properties: +- compatible: Should be: + "st,stm32h743-rcc" + +- reg: should be register base and length as documented in the + datasheet + +- #reset-cells: 1, see below + +- #clock-cells : from common clock binding; shall be set to 1 + +- clocks: External oscillator clock phandle + - high speed external clock signal (HSE)
Quoted 8 lines
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt line 26
Quoted 5 lines
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +5
-0+ - low speed external clock signal (LSE) + - external I2S clock (I2S_CKIN) + +- st,syscfg: phandle for pwrcfg, mandatory to disable/enable backup domain + write protection (RTC clock).st,syscfg is confusing if we are using it for PWR or SYSCFG peripheral of the device.
Also why company name to reference the phandle, it can just be syscfg or better something likepwr_xxxas we it pointing to pwrcfg phandle.
I didn't get the history of this compatible string, we heritate it from kernel.
Quoted 251 lines
Quoted 5 lines
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +4
-0+ +- pll x node: Allow to register a pll with specific parameters. + Please see PLL section below. +doc/device-tree-bindings/clock/st,stm32h7-rcc.txt line 40
Quoted 10 lines
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +10
-0+Example: + + rcc: rcc at 58024400 { + #reset-cells = <1>; + #clock-cells = <2> + compatible = "st,stm32h743-rcc", "st,stm32-rcc"; + reg = <0x58024400 0x400>; + clocks = <&clk_hse>, <&clk_lse>, <&clk_i2s_ckin>; + + st,syscfg = <&pwrcfg>;see above.
Quoted 233 lines
doc/device-tree-bindings/clock/st,stm32h7-rcc.txt new file +112
-0+ + #address-cells = <1>; + #size-cells = <0>; + + vco1 at 58024430 { + #clock-cells = <0>; + compatible = "stm32,pll"; + reg = <0>; + }; + + vco2 at 58024438 { + #clock-cells = <0>; + compatible = "stm32,pll"; + reg = <1>; + st,clock-div = <2>; + st,clock-mult = <40>; + st,frac-status = <0>; + st,frac = <0>; + st,vcosel = <1>; + st,pllrge = <2>; + }; + }; + + +STM32H7 PLL +----------- + +The VCO of STM32 PLL could be reprensented like this: + + Vref --------- -------- + ---->| / DIVM |---->| x DIVN | ------> VCO + --------- -------- + ^ + | + ------- + | FRACN | + ------- + +When the PLL is configured in integer mode: +- VCO = ( Vref / DIVM ) * DIVN + +When the PLL is configured in fractional mode: +- VCO = ( Vref / DIVM ) * ( DIVN + FRACN / 2^13) + + +Required properties for pll node: +- compatible: Should be: + "stm32,pll" + +- #clock-cells: from common clock binding; shall be set to 0 +- reg: Should be the pll number. + +Optional properties: +- st,clock-div: DIVM division factor : <1..63> +- st,clock-mult: DIVN multiplication factor : <4..512> + +- st,frac-status: + - 0 Pll is configured in integer mode + - 1 Pll is configure in fractional mode + +- st,frac: Fractional part of the multiplication factor : <0..8191> + +- st,vcosel: VCO selection + - 0: Wide VCO range:192 to 836 MHz + - 1: Medium VCO range:150 to 420 MHz + +- st,pllrge: PLL input frequency range + - 0: The PLL input (Vref / DIVM) clock range frequency is between 1 and 2 MHz + - 1: The PLL input (Vref / DIVM) clock range frequency is between 2 and 4 MHz + - 2: The PLL input (Vref / DIVM) clock range frequency is between 4 and 8 MHz + - 3: The PLL input (Vref / DIVM) clock range frequency is between 8 and 16 MHz + + +The peripheral clock consumer should specify the desired clock by +having the clock ID in its "clocks" phandle cell. + +All available clocks are defined as preprocessor macros in +dt-bindings/clock/stm32h7-clks.h header and can be used in device +tree sources. + +Example: + + timer5: timer at 40000c00 { + compatible = "st,stm32-timer"; + reg = <0x40000c00 0x400>; + interrupts = <50>; + clocks = <&rcc TIM5_CK>; + + }; + +Specifying softreset control of devices +======================================= + +Device nodes should specify the reset channel required in their "resets" +property, containing a phandle to the reset device node and an index specifying +which channel to use. +The index is the bit number within the RCC registers bank, starting from RCC +base address. +It is calculated as: index = register_offset / 4 * 32 + bit_offset. +Where bit_offset is the bit offset within the register. + +For example, for CRC reset: + crc = AHB4RSTR_offset / 4 * 32 + CRCRST_bit_offset = 0x88 / 4 * 32 + 19 = 1107 + +All available preprocessor macros for reset are defined dt-bindings//mfd/stm32h7-rcc.h +header and can be used in device tree sources. + +example: + + timer2 { + resets = <&rcc STM32H7_APB1L_RESET(TIM2)>; + };drivers/clk/Makefile +1
-0@@ -22,3 +22,4 @@ obj-$(CONFIG_CLK_BCM6345) += clk_bcm6345.o obj-$(CONFIG_CLK_BOSTON) += clk_boston.o obj-$(CONFIG_ARCH_ASPEED) += aspeed/ obj-$(CONFIG_STM32F7) += clk_stm32f7.o +obj-$(CONFIG_STM32H7) += clk_stm32h7.odrivers/clk/clk_stm32h7.c new file +106
-0@@ -0,0 +1,802 @@ +/* +* Copyright (C) STMicroelectronics SA 2017 +* Author(s): Patrice CHOTARD, <[email protected]> for STMicroelectronics. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#include <common.h> +#include <clk-uclass.h> +#include <dm.h> +#include <regmap.h> +#include <syscon.h> +#include <asm/io.h> +#include <dm/root.h> + +#include <dt-bindings/clock/stm32h7-clks.h> + +DECLARE_GLOBAL_DATA_PTR ; + +/* RCC CR specific definitions */ +#define RCC_CR_HSION BIT(0) +#define RCC_CR_HSIRDY BIT(2) + +#define RCC_CR_HSEON BIT(16) +#define RCC_CR_HSERDY BIT(17) +#define RCC_CR_HSEBYP BIT(18) +#define RCC_CR_PLL1ON BIT(24) +#define RCC_CR_PLL1RDY BIT(25) + +#define RCC_CR_HSIDIV_MASK GENMASK(4, 3) +#define RCC_CR_HSIDIV_SHIFT 3 + +#define RCC_CFGR_SW_MASK GENMASK(2, 0) +#define RCC_CFGR_SW_HSI 0 +#define RCC_CFGR_SW_CSI 1 +#define RCC_CFGR_SW_HSE 2 +#define RCC_CFGR_SW_PLL1 3 + +#define RCC_PLLCKSELR_PLLSRC_HSI 0 +#define RCC_PLLCKSELR_PLLSRC_CSI 1 +#define RCC_PLLCKSELR_PLLSRC_HSE 2 +#define RCC_PLLCKSELR_PLLSRC_NO_CLK 3 + +#define RCC_PLLCKSELR_PLLSRC_MASK GENMASK(1, 0) + +#define RCC_PLLCKSELR_DIVM1_SHIFT 4 +#define RCC_PLLCKSELR_DIVM1_MASK GENMASK(9, 4) + +#define RCC_PLL1DIVR_DIVN1_MASK GENMASK(8, 0) + +#define RCC_PLL1DIVR_DIVP1_SHIFT 9 +#define RCC_PLL1DIVR_DIVP1_MASK GENMASK(15, 9) + +#define RCC_PLL1DIVR_DIVQ1_SHIFT 16 +#define RCC_PLL1DIVR_DIVQ1_MASK GENMASK(22, 16) + +#define RCC_PLL1DIVR_DIVR1_SHIFT 24 +#define RCC_PLL1DIVR_DIVR1_MASK GENMASK(30, 24) + +#define RCC_PLL1FRACR_FRACN1_SHIFT 3 +#define RCC_PLL1FRACR_FRACN1_MASK GENMASK(15, 3) + +#define RCC_PLLCFGR_PLL1RGE_SHIFT 2 +#define PLL1RGE_1_2_MHZ 0 +#define PLL1RGE_2_4_MHZ 1 +#define PLL1RGE_4_8_MHZ 2 +#define PLL1RGE_8_16_MHZ 3 +#define RCC_PLLCFGR_DIVP1EN BIT(16) +#define RCC_PLLCFGR_DIVQ1EN BIT(17) +#define RCC_PLLCFGR_DIVR1EN BIT(18) + +#define RCC_D1CFGR_HPRE_MASK GENMASK(3, 0) +#define RCC_D1CFGR_HPRE_DIVIDED BIT(3) +#define RCC_D1CFGR_HPRE_DIVIDER GENMASK(2, 0) + +#define RCC_D1CFGR_HPRE_DIV2 8 + +#define RCC_D1CFGR_D1PPRE_SHIFT 4 +#define RCC_D1CFGR_D1PPRE_DIVIDED BIT(6) +#define RCC_D1CFGR_D1PPRE_DIVIDER GENMASK(5, 4) + +#define RCC_D1CFGR_D1CPRE_SHIFT 8 +#define RCC_D1CFGR_D1CPRE_DIVIDER GENMASK(10, 8) +#define RCC_D1CFGR_D1CPRE_DIVIDED BIT(11) + +#define RCC_D2CFGR_D2PPRE1_SHIFT 4 +#define RCC_D2CFGR_D2PPRE1_DIVIDED BIT(6) +#define RCC_D2CFGR_D2PPRE1_DIVIDER GENMASK(5, 4) + +#define RCC_D2CFGR_D2PPRE2_SHIFT 8 +#define RCC_D2CFGR_D2PPRE2_DIVIDED BIT(10) +#define RCC_D2CFGR_D2PPRE2_DIVIDER GENMASK(9, 8) + +#define RCC_D3CFGR_D3PPRE_SHIFT 4 +#define RCC_D3CFGR_D3PPRE_DIVIDED BIT(6) +#define RCC_D3CFGR_D3PPRE_DIVIDER GENMASK(5, 4) + +#define RCC_D1CCIPR_FMCSRC_MASK GENMASK(1, 0) +#define FMCSRC_HCLKD1 0 +#define FMCSRC_PLL1_Q_CK 1 +#define FMCSRC_PLL2_R_CK 2 +#define FMCSRC_PER_CK 3 + +#define RCC_D1CCIPR_QSPISRC_MASK GENMASK(5, 4) +#define RCC_D1CCIPR_QSPISRC_SHIFT 4 +#define QSPISRC_HCLKD1 0
Quoted 8 lines
drivers/clk/clk_stm32h7.c line 112
Quoted 6 lines
drivers/clk/clk_stm32h7.c new file +6
-0+#define QSPISRC_PLL1_Q_CK 1 +#define QSPISRC_PLL2_R_CK 2 +#define QSPISRC_PER_CK 3 + +#define PWR_CR3 0x0c +#define PWR_CR3_SDEN BIT(2)Can we use SCUEN suffix to match the Ref Manual.
Which version of reference manual do you use ? in mine its SDEN, but i propably use a too old ref manual.
Quoted 103 lines
Quoted 89 lines
drivers/clk/clk_stm32h7.c new file +88
-0+#define PWR_D3CR 0x18 +#define PWR_D3CR_VOS_MASK GENMASK(15, 14) +#define PWR_D3CR_VOS_SHIFT 14 +#define VOS_SCALE_3 1 +#define VOS_SCALE_2 2 +#define VOS_SCALE_1 3 +#define PWR_D3CR_VOSREADY BIT(13) + +struct stm32_rcc_regs { +u32 cr;/* 0x00 Source Control Register */ +u32 icscr;/* 0x04 Internal Clock Source Calibration Register */ +u32 crrcr;/* 0x08 Clock Recovery RC Register */ +u32 reserved1;/* 0x0c reserved */ +u32 cfgr;/* 0x10 Clock Configuration Register */ +u32 reserved2;/* 0x14 reserved */ +u32 d1cfgr;/* 0x18 Domain 1 Clock Configuration Register */ +u32 d2cfgr;/* 0x1c Domain 2 Clock Configuration Register */ +u32 d3cfgr;/* 0x20 Domain 3 Clock Configuration Register */ +u32 reserved3;/* 0x24 reserved */ +u32 pllckselr;/* 0x28 PLLs Clock Source Selection Register */ +u32 pllcfgr;/* 0x2c PLLs Configuration Register */ +u32 pll1divr;/* 0x30 PLL1 Dividers Configuration Register */ +u32 pll1fracr;/* 0x34 PLL1 Fractional Divider Register */ +u32 pll2divr;/* 0x38 PLL2 Dividers Configuration Register */ +u32 pll2fracr;/* 0x3c PLL2 Fractional Divider Register */ +u32 pll3divr;/* 0x40 PLL3 Dividers Configuration Register */ +u32 pll3fracr;/* 0x44 PLL3 Fractional Divider Register */ +u32 reserved4;/* 0x48 reserved */ +u32 d1ccipr;/* 0x4c Domain 1 Kernel Clock Configuration Register */ +u32 d2ccip1r;/* 0x50 Domain 2 Kernel Clock Configuration Register */ +u32 d2ccip2r;/* 0x54 Domain 2 Kernel Clock Configuration Register */ +u32 d3ccipr;/* 0x58 Domain 3 Kernel Clock Configuration Register */ +u32 reserved5;/* 0x5c reserved */ +u32 cier;/* 0x60 Clock Source Interrupt Enable Register */ +u32 cifr;/* 0x64 Clock Source Interrupt Flag Register */ +u32 cicr;/* 0x68 Clock Source Interrupt Clear Register */ +u32 reserved6;/* 0x6c reserved */ +u32 bdcr;/* 0x70 Backup Domain Control Register */ +u32 csr;/* 0x74 Clock Control and Status Register */ +u32 reserved7;/* 0x78 reserved */ + +u32 ahb3rstr;/* 0x7c AHB3 Peripheral Reset Register */ +u32 ahb1rstr;/* 0x80 AHB1 Peripheral Reset Register */ +u32 ahb2rstr;/* 0x84 AHB2 Peripheral Reset Register */ +u32 ahb4rstr;/* 0x88 AHB4 Peripheral Reset Register */ + +u32 apb3rstr;/* 0x8c APB3 Peripheral Reset Register */ +u32 apb1lrstr;/* 0x90 APB1 low Peripheral Reset Register */ +u32 apb1hrstr;/* 0x94 APB1 high Peripheral Reset Register */ +u32 apb2rstr;/* 0x98 APB2 Clock Register */ +u32 apb4rstr;/* 0x9c APB4 Clock Register */ + +u32 gcr;/* 0xa0 Global Control Register */ +u32 reserved8;/* 0xa4 reserved */ +u32 d3amr;/* 0xa8 D3 Autonomous mode Register */ +u32 reserved9[9 ];/* 0xac to 0xcc reserved */ +u32 rsr;/* 0xd0 Reset Status Register */ +u32 ahb3enr;/* 0xd4 AHB3 Clock Register */ +u32 ahb1enr;/* 0xd8 AHB1 Clock Register */ +u32 ahb2enr;/* 0xdc AHB2 Clock Register */ +u32 ahb4enr;/* 0xe0 AHB4 Clock Register */ + +u32 apb3enr;/* 0xe4 APB3 Clock Register */ +u32 apb1lenr;/* 0xe8 APB1 low Clock Register */ +u32 apb1henr;/* 0xec APB1 high Clock Register */ +u32 apb2enr;/* 0xf0 APB2 Clock Register */ +u32 apb4enr;/* 0xf4 APB4 Clock Register */ +}; + +#define RCC_AHB3ENR offsetof(struct stm32_rcc_regs, ahb3enr) +#define RCC_AHB1ENR offsetof(struct stm32_rcc_regs, ahb1enr) +#define RCC_AHB2ENR offsetof(struct stm32_rcc_regs, ahb2enr) +#define RCC_AHB4ENR offsetof(struct stm32_rcc_regs, ahb4enr) +#define RCC_APB3ENR offsetof(struct stm32_rcc_regs, apb3enr) +#define RCC_APB1LENR offsetof(struct stm32_rcc_regs, apb1lenr) +#define RCC_APB1HENR offsetof(struct stm32_rcc_regs, apb1henr) +#define RCC_APB2ENR offsetof(struct stm32_rcc_regs, apb2enr) +#define RCC_APB4ENR offsetof(struct stm32_rcc_regs, apb4enr) + +struct clk_cfg { +u32 gate_offset; +u8 gate_bit_idx; +const char *name; +}; + +#define CLK (_gate_offset, _bit_idx, _name) \ +{ \ + .gate_offset = _gate_offset,\drivers/clk/clk_stm32h7.c line 210
Quoted 10 lines
drivers/clk/clk_stm32h7.c new file +10
-0+ .gate_bit_idx = _bit_idx,\ + .name = _name,\ +} + +/* +* the way all these entries are sorted in this array could seem +* unlogical, but we are dependant of kernel DT_bindings, +* where clocks are separate in 2 banks, peripheral clocks and +* kernel clocks. +*/ it destroys the purpose of device tree if we are embedding all the info in the structure array. In addition expensive in terms of memory usage.
Quoted 5 lines
drivers/clk/clk_stm32h7.c line 213
Quoted 3 lines
drivers/clk/clk_stm32h7.c new file +3
-0+ +static const struct clk_cfg clk_map[] = { +CLK (RCC_AHB3ENR ,31 ,"d1sram1" ),/* peripheral clocks */ Do we need CLK Macro, {
RCC_AHB3ENR, 31, "d1sram1"} should work fine.
Agree, it's a residue of my rework, i will send a fix for this
Quoted 153 lines
Quoted 153 lines
drivers/clk/clk_stm32h7.c new file +152
-0+CLK (RCC_AHB3ENR ,30 ,"itcm" ), +CLK (RCC_AHB3ENR ,29 ,"dtcm2" ), +CLK (RCC_AHB3ENR ,28 ,"dtcm1" ), +CLK (RCC_AHB3ENR ,8 ,"flitf" ), +CLK (RCC_AHB3ENR ,5 ,"jpgdec" ), +CLK (RCC_AHB3ENR ,4 ,"dma2d" ), +CLK (RCC_AHB3ENR ,0 ,"mdma" ), +CLK (RCC_AHB1ENR ,28 ,"usb2ulpi" ), +CLK (RCC_AHB1ENR ,17 ,"eth1rx" ), +CLK (RCC_AHB1ENR ,16 ,"eth1tx" ), +CLK (RCC_AHB1ENR ,15 ,"eth1mac" ), +CLK (RCC_AHB1ENR ,14 ,"art" ), +CLK (RCC_AHB1ENR ,26 ,"usb1ulpi" ), +CLK (RCC_AHB1ENR ,1 ,"dma2" ), +CLK (RCC_AHB1ENR ,0 ,"dma1" ), +CLK (RCC_AHB2ENR ,31 ,"d2sram3" ), +CLK (RCC_AHB2ENR ,30 ,"d2sram2" ), +CLK (RCC_AHB2ENR ,29 ,"d2sram1" ), +CLK (RCC_AHB2ENR ,5 ,"hash" ), +CLK (RCC_AHB2ENR ,4 ,"crypt" ), +CLK (RCC_AHB2ENR ,0 ,"camitf" ), +CLK (RCC_AHB4ENR ,28 ,"bkpram" ), +CLK (RCC_AHB4ENR ,25 ,"hsem" ), +CLK (RCC_AHB4ENR ,21 ,"bdma" ), +CLK (RCC_AHB4ENR ,19 ,"crc" ), +CLK (RCC_AHB4ENR ,10 ,"gpiok" ), +CLK (RCC_AHB4ENR ,9 ,"gpioj" ), +CLK (RCC_AHB4ENR ,8 ,"gpioi" ), +CLK (RCC_AHB4ENR ,7 ,"gpioh" ), +CLK (RCC_AHB4ENR ,6 ,"gpiog" ), +CLK (RCC_AHB4ENR ,5 ,"gpiof" ), +CLK (RCC_AHB4ENR ,4 ,"gpioe" ), +CLK (RCC_AHB4ENR ,3 ,"gpiod" ), +CLK (RCC_AHB4ENR ,2 ,"gpioc" ), +CLK (RCC_AHB4ENR ,1 ,"gpiob" ), +CLK (RCC_AHB4ENR ,0 ,"gpioa" ), +CLK (RCC_APB3ENR ,6 ,"wwdg1" ), +CLK (RCC_APB1LENR ,29 ,"dac12" ), +CLK (RCC_APB1LENR ,11 ,"wwdg2" ), +CLK (RCC_APB1LENR ,8 ,"tim14" ), +CLK (RCC_APB1LENR ,7 ,"tim13" ), +CLK (RCC_APB1LENR ,6 ,"tim12" ), +CLK (RCC_APB1LENR ,5 ,"tim7" ), +CLK (RCC_APB1LENR ,4 ,"tim6" ), +CLK (RCC_APB1LENR ,3 ,"tim5" ), +CLK (RCC_APB1LENR ,2 ,"tim4" ), +CLK (RCC_APB1LENR ,1 ,"tim3" ), +CLK (RCC_APB1LENR ,0 ,"tim2" ), +CLK (RCC_APB1HENR ,5 ,"mdios" ), +CLK (RCC_APB1HENR ,4 ,"opamp" ), +CLK (RCC_APB1HENR ,1 ,"crs" ), +CLK (RCC_APB2ENR ,18 ,"tim17" ), +CLK (RCC_APB2ENR ,17 ,"tim16" ), +CLK (RCC_APB2ENR ,16 ,"tim15" ), +CLK (RCC_APB2ENR ,1 ,"tim8" ), +CLK (RCC_APB2ENR ,0 ,"tim1" ), +CLK (RCC_APB4ENR ,26 ,"tmpsens" ), +CLK (RCC_APB4ENR ,16 ,"rtcapb" ), +CLK (RCC_APB4ENR ,15 ,"vref" ), +CLK (RCC_APB4ENR ,14 ,"comp12" ), +CLK (RCC_APB4ENR ,1 ,"syscfg" ), +CLK (RCC_AHB3ENR ,16 ,"sdmmc1" ),/* kernel clocks */ +CLK (RCC_AHB3ENR ,14 ,"quadspi" ), +CLK (RCC_AHB3ENR ,12 ,"fmc" ), +CLK (RCC_AHB1ENR ,27 ,"usb2otg" ), +CLK (RCC_AHB1ENR ,25 ,"usb1otg" ), +CLK (RCC_AHB1ENR ,5 ,"adc12" ), +CLK (RCC_AHB2ENR ,9 ,"sdmmc2" ), +CLK (RCC_AHB2ENR ,6 ,"rng" ), +CLK (RCC_AHB4ENR ,24 ,"adc3" ), +CLK (RCC_APB3ENR ,4 ,"dsi" ), +CLK (RCC_APB3ENR ,3 ,"ltdc" ), +CLK (RCC_APB1LENR ,31 ,"usart8" ), +CLK (RCC_APB1LENR ,30 ,"usart7" ), +CLK (RCC_APB1LENR ,27 ,"hdmicec" ), +CLK (RCC_APB1LENR ,23 ,"i2c3" ), +CLK (RCC_APB1LENR ,22 ,"i2c2" ), +CLK (RCC_APB1LENR ,21 ,"i2c1" ), +CLK (RCC_APB1LENR ,20 ,"uart5" ), +CLK (RCC_APB1LENR ,19 ,"uart4" ), +CLK (RCC_APB1LENR ,18 ,"usart3" ), +CLK (RCC_APB1LENR ,17 ,"usart2" ), +CLK (RCC_APB1LENR ,16 ,"spdifrx" ), +CLK (RCC_APB1LENR ,15 ,"spi3" ), +CLK (RCC_APB1LENR ,14 ,"spi2" ), +CLK (RCC_APB1LENR ,9 ,"lptim1" ), +CLK (RCC_APB1HENR ,8 ,"fdcan" ), +CLK (RCC_APB1HENR ,2 ,"swp" ), +CLK (RCC_APB2ENR ,29 ,"hrtim" ), +CLK (RCC_APB2ENR ,28 ,"dfsdm1" ), +CLK (RCC_APB2ENR ,24 ,"sai3" ), +CLK (RCC_APB2ENR ,23 ,"sai2" ), +CLK (RCC_APB2ENR ,22 ,"sai1" ), +CLK (RCC_APB2ENR ,20 ,"spi5" ), +CLK (RCC_APB2ENR ,13 ,"spi4" ), +CLK (RCC_APB2ENR ,12 ,"spi1" ), +CLK (RCC_APB2ENR ,5 ,"usart6" ), +CLK (RCC_APB2ENR ,4 ,"usart1" ), +CLK (RCC_APB4ENR ,21 ,"sai4a" ), +CLK (RCC_APB4ENR ,21 ,"sai4b" ), +CLK (RCC_APB4ENR ,12 ,"lptim5" ), +CLK (RCC_APB4ENR ,11 ,"lptim4" ), +CLK (RCC_APB4ENR ,10 ,"lptim3" ), +CLK (RCC_APB4ENR ,9 ,"lptim2" ), +CLK (RCC_APB4ENR ,7 ,"i2c4" ), +CLK (RCC_APB4ENR ,5 ,"spi6" ), + CLK(RCC_APB4ENR, 3, "lpuart1"), +}; + +struct stm32_clk { +struct stm32_rcc_regs *rcc_base; +struct regmap *pwr_regmap; +}; + +struct pll_psc { +u8 divm; +u16 divn; +u8 divp; +u8 divq; +u8 divr; +}; + +/* +* OSC_HSE = 25 MHz +* VCO = 500MHz +* pll1_p = 250MHz / pll1_q = 250MHz pll1_r = 250Mhz +*/ +struct pll_psc sys_pll_psc = { + .divm =4 , + .divn =80 , + .divp =2 , + .divq =2 , + .divr =2 , +}; + +int configure_clocks (struct udevice *dev) +{ +struct stm32_clk *priv =dev_get_priv (dev); +struct stm32_rcc_regs *regs = priv->rcc_base; +uint8_t *pwr_base = (uint8_t *)regmap_get_range (priv->pwr_regmap,0 ); +uint32_t pllckselr =0 ; +uint32_t pll1divr =0 ; +uint32_t pllcfgr =0 ; + +/* Switch on HSI */ +setbits_le32 (®s->cr,RCC_CR_HSION ); +while (!(readl (®s->cr) &RCC_CR_HSIRDY )) + ; + +/* Reset CFGR, now HSI is the default system clock */ +writel (0 , ®s->cfgr); +
Quoted 8 lines
drivers/clk/clk_stm32h7.c line 371
Quoted 6 lines
drivers/clk/clk_stm32h7.c new file +6
-0+/* Set all kernel domain clock registers to reset value*/ +writel (0x0 , ®s->d1ccipr); +writel (0x0 , ®s->d2ccip1r); +writel (0x0 , ®s->d2ccip2r); + +/* Set voltage scaling at scale 1 */ pls add info what is scale1
ok
Quoted 6 lines
drivers/clk/clk_stm32h7.c line 374
Quoted 4 lines
drivers/clk/clk_stm32h7.c new file +3
-0+clrsetbits_le32 (pwr_base +PWR_D3CR ,PWR_D3CR_VOS_MASK , +VOS_SCALE_1 <<PWR_D3CR_VOS_SHIFT ); +/* disable step down converter */ is this comment correct ?
Yes, in ref manual, SDEN bit description is for "Step down converter"
Quoted 368 lines
Quoted 368 lines
drivers/clk/clk_stm32h7.c new file +367
-0+clrbits_le32 (pwr_base +PWR_CR3 ,PWR_CR3_SDEN ); +while (!(readl (pwr_base +PWR_D3CR ) &PWR_D3CR_VOSREADY )) + ; + +/* disable HSE to configure it */ +clrbits_le32 (®s->cr,RCC_CR_HSEON ); +while ((readl (®s->cr) &RCC_CR_HSERDY )) + ; + +/* clear HSE bypass and set it ON */ +clrbits_le32 (®s->cr,RCC_CR_HSEBYP ); +/* Switch on HSE */ +setbits_le32 (®s->cr,RCC_CR_HSEON ); +while (!(readl (®s->cr) &RCC_CR_HSERDY )) + ; + +/* pll setup, disable it */ +clrbits_le32 (®s->cr,RCC_CR_PLL1ON ); +while ((readl (®s->cr) &RCC_CR_PLL1RDY )) + ; + +/* Select HSE as PLL clock source */ + pllckselr |=RCC_PLLCKSELR_PLLSRC_HSE ; + pllckselr |= sys_pll_psc.divm <<RCC_PLLCKSELR_DIVM1_SHIFT ; +writel (pllckselr, ®s->pllckselr); + + pll1divr |= (sys_pll_psc.divr -1 ) <<RCC_PLL1DIVR_DIVR1_SHIFT ; + pll1divr |= (sys_pll_psc.divq -1 ) <<RCC_PLL1DIVR_DIVQ1_SHIFT ; + pll1divr |= (sys_pll_psc.divp -1 ) <<RCC_PLL1DIVR_DIVP1_SHIFT ; + pll1divr |= (sys_pll_psc.divn -1 ); +writel (pll1divr, ®s->pll1divr); + + pllcfgr |=PLL1RGE_4_8_MHZ <<RCC_PLLCFGR_PLL1RGE_SHIFT ; + pllcfgr |=RCC_PLLCFGR_DIVP1EN ; + pllcfgr |=RCC_PLLCFGR_DIVQ1EN ; + pllcfgr |=RCC_PLLCFGR_DIVR1EN ; +writel (pllcfgr, ®s->pllcfgr); + +/* pll setup, enable it */ +setbits_le32 (®s->cr,RCC_CR_PLL1ON ); + +/* set HPRE (/2) DI clk --> 125MHz */ +clrsetbits_le32 (®s->d1cfgr,RCC_D1CFGR_HPRE_MASK , +RCC_D1CFGR_HPRE_DIV2 ); + +/* select PLL1 as system clock source (sys_ck)*/ +clrsetbits_le32 (®s->cfgr,RCC_CFGR_SW_MASK ,RCC_CFGR_SW_PLL1 ); +while ((readl (®s->cfgr) &RCC_CFGR_SW_MASK ) !=RCC_CFGR_SW_PLL1 ) + ; + +/* sdram: use pll1_q as fmc_k clk */ +clrsetbits_le32 (®s->d1ccipr,RCC_D1CCIPR_FMCSRC_MASK , +FMCSRC_PLL1_Q_CK ); + +return 0 ; +} + +static u32 stm32_get_HSI_divider (struct stm32_rcc_regs *regs) +{ +u32 divider; + +/* get HSI divider value */ + divider =readl (®s->cr) &RCC_CR_HSIDIV_MASK ; + divider = divider >>RCC_CR_HSIDIV_SHIFT ; + +return divider; +}; + +enum pllsrc { +HSE , +LSE , +HSI , +CSI , +I2S , +TIMER , +PLLSRC_NB , +}; + +static const char *const pllsrc_name[PLLSRC_NB ] = { + [HSE ] ="clk-hse" , + [LSE ] ="clk-lse" , + [HSI ] ="clk-hsi" , + [CSI ] ="clk-csi" , + [I2S ] ="clk-i2s" , + [TIMER ] ="timer-clk" +}; + +static ulong stm32_get_rate (struct stm32_rcc_regs *regs,enum pllsrc pllsrc) +{ +struct clk clk; +struct udevice *fixed_clock_dev =NULL ; +u32 divider; +int ret; +const char *name = pllsrc_name[pllsrc]; + +debug ("%s name %s\n" , __func__, name); + + clk.id =0 ; + ret =uclass_get_device_by_name (UCLASS_CLK , name, &fixed_clock_dev); +if (ret) { +error ("Can't find clk %s (%d)" , name, ret); +return 0 ; + } + + ret =clk_request (fixed_clock_dev, &clk); +if (ret) { +error ("Can't request %s clk (%d)" , name, ret); +return 0 ; + } + + divider =0 ; +if (pllsrc ==HSI ) + divider =stm32_get_HSI_divider (regs); + +debug ("%s divider %d rate %ld\n" , __func__, + divider,clk_get_rate (&clk)); + +return clk_get_rate (&clk) >> divider; +}; + +enum pll1_output { +PLL1_P_CK , +PLL1_Q_CK , +PLL1_R_CK , +}; + +static u32 stm32_get_PLL1_rate (struct stm32_rcc_regs *regs, +enum pll1_output output) +{ +ulong pllsrc =0 ; +u32 divm1, divn1, divp1, divq1, divr1, fracn1; +ulong vco, rate; + +/* get the PLLSRC */ +switch (readl (®s->pllckselr) &RCC_PLLCKSELR_PLLSRC_MASK ) { +case RCC_PLLCKSELR_PLLSRC_HSI : + pllsrc =stm32_get_rate (regs,HSI ); +break ; +case RCC_PLLCKSELR_PLLSRC_CSI : + pllsrc =stm32_get_rate (regs,CSI ); +break ; +case RCC_PLLCKSELR_PLLSRC_HSE : + pllsrc =stm32_get_rate (regs,HSE ); +break ; +case RCC_PLLCKSELR_PLLSRC_NO_CLK : +/* shouldn't happen */ +error ("wrong value for RCC_PLLCKSELR register\n" ); + pllsrc =0 ; +break ; + } + +/* pllsrc = 0 ? no need to go ahead */ +if (!pllsrc) +return pllsrc; + +/* get divm1, divp1, divn1 and divr1 */ + divm1 =readl (®s->pllckselr) &RCC_PLLCKSELR_DIVM1_MASK ; + divm1 = divm1 >>RCC_PLLCKSELR_DIVM1_SHIFT ; + + divn1 = (readl (®s->pll1divr) &RCC_PLL1DIVR_DIVN1_MASK ) +1 ; + + divp1 =readl (®s->pll1divr) &RCC_PLL1DIVR_DIVP1_MASK ; + divp1 = (divp1 >>RCC_PLL1DIVR_DIVP1_SHIFT ) +1 ; + + divq1 =readl (®s->pll1divr) &RCC_PLL1DIVR_DIVQ1_MASK ; + divq1 = (divq1 >>RCC_PLL1DIVR_DIVQ1_SHIFT ) +1 ; + + divr1 =readl (®s->pll1divr) &RCC_PLL1DIVR_DIVR1_MASK ; + divr1 = (divr1 >>RCC_PLL1DIVR_DIVR1_SHIFT ) +1 ; + + fracn1 =readl (®s->pll1fracr) &RCC_PLL1DIVR_DIVR1_MASK ; + fracn1 = fracn1 &RCC_PLL1DIVR_DIVR1_SHIFT ; + + vco = (pllsrc / divm1) * divn1; + rate = (pllsrc * fracn1) / (divm1 *8192 ); + +debug ("%s divm1 = %d divn1 = %d divp1 = %d divq1 = %d divr1 = %d\n" , + __func__, divm1, divn1, divp1, divq1, divr1); +debug ("%s fracn1 = %d vco = %ld rate = %ld\n" , + __func__, fracn1, vco, rate); + +switch (output) { +case PLL1_P_CK : +return (vco + rate) / divp1; +break ; +case PLL1_Q_CK : +return (vco + rate) / divq1; +break ; + +case PLL1_R_CK : +return (vco + rate) / divr1; +break ; + } + +return -EINVAL ; +} + +static ulong stm32_clk_get_rate (struct clk *clk) +{ +struct stm32_clk *priv =dev_get_priv (clk->dev); +struct stm32_rcc_regs *regs = priv->rcc_base; +ulong sysclk =0 ; +u32 gate_offset; +u32 d1cfgr; +/* prescaler table lookups for clock computation */ +u16 prescaler_table[8 ] = {2 ,4 ,8 ,16 ,64 ,128 ,256 ,512 }; +u8 source, idx; + +/* +* get system clock (sys_ck) source +* can be HSI_CK, CSI_CK, HSE_CK or pll1_p_ck +*/ + source =readl (®s->cfgr) &RCC_CFGR_SW_MASK ; +switch (source) { +case RCC_CFGR_SW_PLL1 : + sysclk =stm32_get_PLL1_rate (regs,PLL1_P_CK ); +break ; +case RCC_CFGR_SW_HSE : + sysclk =stm32_get_rate (regs,HSE ); +break ; + +case RCC_CFGR_SW_CSI : + sysclk =stm32_get_rate (regs,CSI ); +break ; + +case RCC_CFGR_SW_HSI : + sysclk =stm32_get_rate (regs,HSI ); +break ; + } + +/* sysclk = 0 ? no need to go ahead */ +if (!sysclk) +return sysclk; + +debug ("%s system clock: source = %d freq = %ld\n" , + __func__, source, sysclk); + + d1cfgr =readl (®s->d1cfgr); + +if (d1cfgr &RCC_D1CFGR_D1CPRE_DIVIDED ) { +/* get D1 domain Core prescaler */ + idx = (d1cfgr &RCC_D1CFGR_D1CPRE_DIVIDER ) >> +RCC_D1CFGR_D1CPRE_SHIFT ; + sysclk = sysclk / prescaler_table[idx]; + } + +if (d1cfgr &RCC_D1CFGR_HPRE_DIVIDED ) { +/* get D1 domain AHB prescaler */ + idx = d1cfgr &RCC_D1CFGR_HPRE_DIVIDER ; + sysclk = sysclk / prescaler_table[idx]; + } + + gate_offset = clk_map[clk->id].gate_offset; + +debug ("%s clk->id=%ld gate_offset=0x%x sysclk=%ld\n" , + __func__, clk->id, gate_offset, sysclk); + +switch (gate_offset) { +case RCC_AHB3ENR : +case RCC_AHB1ENR : +case RCC_AHB2ENR : +case RCC_AHB4ENR : +return sysclk; +break ; + +case RCC_APB3ENR : +if (d1cfgr &RCC_D1CFGR_D1PPRE_DIVIDED ) { +/* get D1 domain APB3 prescaler */ + idx = (d1cfgr &RCC_D1CFGR_D1PPRE_DIVIDER ) >> +RCC_D1CFGR_D1PPRE_SHIFT ; + sysclk = sysclk / prescaler_table[idx]; + } + +debug ("%s system clock: freq after APB3 prescaler = %ld\n" , + __func__, sysclk); + +return sysclk; +break ; + +case RCC_APB4ENR : +if (d1cfgr &RCC_D3CFGR_D3PPRE_DIVIDED ) { +/* get D3 domain APB4 prescaler */ + idx = (d1cfgr &RCC_D3CFGR_D3PPRE_DIVIDER ) >> +RCC_D3CFGR_D3PPRE_SHIFT ; + sysclk = sysclk / prescaler_table[idx]; + } + +debug ("%s system clock: freq after APB4 prescaler = %ld\n" , + __func__, sysclk); + +return sysclk; +break ; + +case RCC_APB1LENR : +case RCC_APB1HENR : +if (d1cfgr &RCC_D2CFGR_D2PPRE1_DIVIDED ) { +/* get D2 domain APB1 prescaler */ + idx = (d1cfgr &RCC_D2CFGR_D2PPRE1_DIVIDER ) >> +RCC_D2CFGR_D2PPRE1_SHIFT ; + sysclk = sysclk / prescaler_table[idx]; + } + +debug ("%s system clock: freq after APB1 prescaler = %ld\n" , + __func__, sysclk); + +return sysclk; +break ; + +case RCC_APB2ENR : +if (d1cfgr &RCC_D2CFGR_D2PPRE2_DIVIDED ) { +/* get D2 domain APB1 prescaler */ + idx = (d1cfgr &RCC_D2CFGR_D2PPRE2_DIVIDER ) >> +RCC_D2CFGR_D2PPRE2_SHIFT ; + sysclk = sysclk / prescaler_table[idx]; + } + +debug ("%s system clock: freq after APB2 prescaler = %ld\n" , + __func__, sysclk); + +return sysclk; +break ; + +default : +error ("unexpected gate_offset value (0x%x)\n" , gate_offset); +return -EINVAL ; +break ; + } +} + +static int stm32_clk_enable (struct clk *clk) +{ +struct stm32_clk *priv =dev_get_priv (clk->dev); +struct stm32_rcc_regs *regs = priv->rcc_base; +u32 gate_offset; +u32 gate_bit_index; +unsigned long clk_id = clk->id; + + gate_offset = clk_map[clk_id].gate_offset; + gate_bit_index = clk_map[clk_id].gate_bit_idx; + +debug ("%s: clkid=%ld gate offset=0x%x bit_index=%d name=%s\n" , + __func__, clk->id, gate_offset, gate_bit_index, + clk_map[clk_id].name); + +setbits_le32 (®s->cr + (gate_offset /4 ),BIT (gate_bit_index)); + +return 0 ; +} + +static int stm32_clk_probe (struct udevice *dev) +{ +struct stm32_clk *priv =dev_get_priv (dev); +struct udevice *syscon; +fdt_addr_t addr; +int err; + + addr =dev_read_addr (dev); +if (addr ==FDT_ADDR_T_NONE ) +return -EINVAL ; + + priv->rcc_base = (struct stm32_rcc_regs *)addr; + +/* get corresponding syscon phandle */ + err =uclass_get_device_by_phandle (UCLASS_SYSCON , dev, +"st,syscfg" , &syscon); + +if (err) {
Quoted 8 lines
drivers/clk/clk_stm32h7.c line 746
Quoted 5 lines
drivers/clk/clk_stm32h7.c new file +5
-0+error ("unable to find syscon device\n" ); +return err; + } + + priv->pwr_regmap =syscon_get_regmap (syscon);why SYSCON_UCLASS...It is used just to get the base address of power control block ? It can be done directly from the phandle also, e.g.
fdt_node_offset_by_phandle()or similar.
Agree, i will fix this too
Thanks
Patrice
Quoted 235 lines
Cheers,
VikasQuoted 230 lines
drivers/clk/clk_stm32h7.c new file +56
-0+if (!priv->pwr_regmap) { +error ("unable to find regmap\n" ); +return -ENODEV ; + } + +configure_clocks (dev); + +return 0 ; +} + +static int stm32_clk_of_xlate (struct clk *clk, +struct ofnode_phandle_args *args) +{ +if (args->args_count !=1 ) { +debug ("Invaild args_count: %d\n" , args->args_count); +return -EINVAL ; + } + +if (args->args_count) { + clk->id = args->args[0 ]; +/* +* this computation convert DT clock index which is used to +* point into 2 separate clock arrays (peripheral and kernel +* clocks bank) (see include/dt-bindings/clock/stm32h7-clks.h) +* into index to point into only one array where peripheral +* and kernel clocks are consecutive +*/ +if (clk->id >=KERN_BANK ) { + clk->id -=KERN_BANK ; + clk->id +=LAST_PERIF_BANK -PERIF_BANK +1 ; + }else { + clk->id -=PERIF_BANK ; + } + }else { + clk->id =0 ; + } + +debug ("%s clk->id %ld\n" , __func__, clk->id); + +return 0 ; +} + +static struct clk_ops stm32_clk_ops = { + .of_xlate = stm32_clk_of_xlate, + .enable = stm32_clk_enable, + .get_rate = stm32_clk_get_rate, +}; + +U_BOOT_DRIVER (stm32h7_clk) = { + .name ="stm32h7_rcc_clock" , + .id =UCLASS_CLK , + .ops = &stm32_clk_ops, + .probe = stm32_clk_probe, + .priv_auto_alloc_size =sizeof (struct stm32_clk ), + .flags =DM_FLAG_PRE_RELOC , +};include/dt-bindings/clock/stm32h7-clks.h new file +167
-0@@ -0,0 +1,167 @@ +/* SYS, CORE AND BUS CLOCKS */ +#define SYS_D1CPRE 0 +#define HCLK 1 +#define PCLK1 2 +#define PCLK2 3 +#define PCLK3 4 +#define PCLK4 5 +#define HSI_DIV 6 +#define HSE_1M 7 +#define I2S_CKIN 8 +#define CK_DSI_PHY 9 +#define HSE_CK 10 +#define LSE_CK 11 +#define CSI_KER_DIV122 12 +#define RTC_CK 13 +#define CPU_SYSTICK 14 + +/* OSCILLATOR BANK */ +#define OSC_BANK 18 +#define HSI_CK 18 +#define HSI_KER_CK 19 +#define CSI_CK 20 +#define CSI_KER_CK 21 +#define RC48_CK 22 +#define LSI_CK 23 + +/* MCLOCK BANK */ +#define MCLK_BANK 28 +#define PER_CK 28 +#define PLLSRC 29 +#define SYS_CK 30 +#define TRACEIN_CK 31 + +/* ODF BANK */ +#define ODF_BANK 32 +#define PLL1_P 32 +#define PLL1_Q 33 +#define PLL1_R 34 +#define PLL2_P 35 +#define PLL2_Q 36 +#define PLL2_R 37 +#define PLL3_P 38 +#define PLL3_Q 39 +#define PLL3_R 40 + +/* MCO BANK */ +#define MCO_BANK 41 +#define MCO1 41 +#define MCO2 42 + +/* PERIF BANK */ +#define PERIF_BANK 50 +#define D1SRAM1_CK 50 +#define ITCM_CK 51 +#define DTCM2_CK 52 +#define DTCM1_CK 53 +#define FLITF_CK 54 +#define JPGDEC_CK 55 +#define DMA2D_CK 56 +#define MDMA_CK 57 +#define USB2ULPI_CK 58 +#define USB1ULPI_CK 59 +#define ETH1RX_CK 60 +#define ETH1TX_CK 61 +#define ETH1MAC_CK 62 +#define ART_CK 63 +#define DMA2_CK 64 +#define DMA1_CK 65 +#define D2SRAM3_CK 66 +#define D2SRAM2_CK 67 +#define D2SRAM1_CK 68 +#define HASH_CK 69 +#define CRYPT_CK 70 +#define CAMITF_CK 71 +#define BKPRAM_CK 72 +#define HSEM_CK 73 +#define BDMA_CK 74 +#define CRC_CK 75 +#define GPIOK_CK 76 +#define GPIOJ_CK 77 +#define GPIOI_CK 78 +#define GPIOH_CK 79 +#define GPIOG_CK 80 +#define GPIOF_CK 81 +#define GPIOE_CK 82 +#define GPIOD_CK 83 +#define GPIOC_CK 84 +#define GPIOB_CK 85 +#define GPIOA_CK 86 +#define WWDG1_CK 87 +#define DAC12_CK 88 +#define WWDG2_CK 89 +#define TIM14_CK 90 +#define TIM13_CK 91 +#define TIM12_CK 92 +#define TIM7_CK 93 +#define TIM6_CK 94 +#define TIM5_CK 95 +#define TIM4_CK 96 +#define TIM3_CK 97 +#define TIM2_CK 98 +#define MDIOS_CK 99 +#define OPAMP_CK 100 +#define CRS_CK 101 +#define TIM17_CK 102 +#define TIM16_CK 103 +#define TIM15_CK 104 +#define TIM8_CK 105 +#define TIM1_CK 106 +#define TMPSENS_CK 107 +#define RTCAPB_CK 108 +#define VREF_CK 109 +#define COMP12_CK 110 +#define SYSCFG_CK 111 +/* must be equal to last peripheral clock index */ +#define LAST_PERIF_BANK SYSCFG_CK + +/* KERNEL BANK */ +#define KERN_BANK 120 +#define SDMMC1_CK 120 +#define QUADSPI_CK 121 +#define FMC_CK 122 +#define USB2OTG_CK 123 +#define USB1OTG_CK 124 +#define ADC12_CK 125 +#define SDMMC2_CK 126 +#define RNG_CK 127 +#define ADC3_CK 128 +#define DSI_CK 129 +#define LTDC_CK 130 +#define USART8_CK 131 +#define USART7_CK 132 +#define HDMICEC_CK 133 +#define I2C3_CK 134 +#define I2C2_CK 135 +#define I2C1_CK 136 +#define UART5_CK 137 +#define UART4_CK 138 +#define USART3_CK 139 +#define USART2_CK 140 +#define SPDIFRX_CK 141 +#define SPI3_CK 142 +#define SPI2_CK 143 +#define LPTIM1_CK 144 +#define FDCAN_CK 145 +#define SWP_CK 146 +#define HRTIM_CK 147 +#define DFSDM1_CK 148 +#define SAI3_CK 149 +#define SAI2_CK 150 +#define SAI1_CK 151 +#define SPI5_CK 152 +#define SPI4_CK 153 +#define SPI1_CK 154 +#define USART6_CK 155 +#define USART1_CK 156 +#define SAI4B_CK 157 +#define SAI4A_CK 158 +#define LPTIM5_CK 159 +#define LPTIM4_CK 160 +#define LPTIM3_CK 161 +#define LPTIM2_CK 162 +#define I2C4_CK 163 +#define SPI6_CK 164 +#define LPUART1_CK 165 + +#define STM32H7_MAX_CLKS 166
PATCH v2 3/9 dm: clk: add clk driver support for stm32h7 SoCs
Hi Vikas
Quoted 23 lines · Patrice CHOTARD
Hi Vikas
Quoted 20 lines · Vikas Manocha
Hi Patrice,
Quoted 17 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
This driver implements basic clock setup, only clock gating is implemented.
This driver doesn't implement .of_match as it's binded by MFD RCC driver.
Files
include/dt-bindings/clock/stm32h7-clks.handdoc/device-tree-bindings/clock/st,stm32h7-rcc.txtwill be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
Signed-off-by Patrice Chotard <[email protected]>---
[...]
Quoted 9 lines
Quoted 5 lines
drivers/clk/clk_stm32h7.c line 112
Quoted 3 lines
drivers/clk/clk_stm32h7.c new file +3
-0+ +#define PWR_CR3 0x0c +#define PWR_CR3_SDEN BIT(2)Can we use SCUEN suffix to match the Ref Manual.
Which version of reference manual do you use ? in mine its SDEN, but i propably use a too old ref manual.
I have found the last version of STM32H7 ref manual, mine was too old, ok i will update the PWR_CR3_SDEN to PWR_CR3_SCUEN
thanks
Patrice
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/clk/clk_stm32h7.c new file +7
-0+#define PWR_D3CR 0x18 +#define PWR_D3CR_VOS_MASK GENMASK(15, 14) +#define PWR_D3CR_VOS_SHIFT 14 +#define VOS_SCALE_3 1 +#define VOS_SCALE_2 2 +#define VOS_SCALE_1 3 +#define PWR_D3CR_VOSREADY BIT(13)
PATCH v2 3/9 dm: clk: add clk driver support for stm32h7 SoCs
Hi Vikas
Quoted 35 lines · Patrice CHOTARD
Hi Vikas
Quoted 23 lines · Patrice CHOTARD
Hi Vikas
Quoted 20 lines · Vikas Manocha
Hi Patrice,
Quoted 17 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
This driver implements basic clock setup, only clock gating is implemented.
This driver doesn't implement .of_match as it's binded by MFD RCC driver.
Files
include/dt-bindings/clock/stm32h7-clks.handdoc/device-tree-bindings/clock/st,stm32h7-rcc.txtwill be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
Signed-off-by Patrice Chotard <[email protected]>---
[...]
Quoted 6 lines
Quoted 5 lines
drivers/clk/clk_stm32h7.c line 112
Quoted 3 lines
drivers/clk/clk_stm32h7.c new file +3
-0+ +#define PWR_CR3 0x0c +#define PWR_CR3_SDEN BIT(2)Can we use SCUEN suffix to match the Ref Manual.
Quoted 6 lines
Quoted 3 lines
Which version of reference manual do you use ? in mine its SDEN, but i propably use a too old ref manual.
I have found the last version of STM32H7 ref manual, mine was too old, ok i will update the
PWR_CR3_SDENtoPWR_CR3_SCUEN
After double check, in the STM32H7x3 reference manual available on st.com (DocID029587 Rev 2), bit 2 of PWR_CR3 reg is described as following:
"Bit 2 SCUEN: Supply configuration update enable
This bit is read-only:
0: Supply configuration update locked.
1: Single write enabled to Supply configuration (LDOEN and BYPASS)"
Whereas in the one i used, bit 2 of PWR_CR3 is described as:
"Bit 2 SDEN (1)(2) : SD converter Enable
0: Step down converter disabled
1: Step down converter enabled. (Default)"
If i follow ref manual DocID029587 Rev 2, this bit is read-only, so the write access of PWR_CR3 bit(2) in clk_stm32h7.c is useless. But after write access removal, the both STM32H7 disco and eval board doesn't boot.
The reference manual is wrong regarding with at least this bit. I will contact PWR architect to solve this point.
Patrice
Quoted 13 lines
thanks
Patrice
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/clk/clk_stm32h7.c new file +7
-0+#define PWR_D3CR 0x18 +#define PWR_D3CR_VOS_MASK GENMASK(15, 14) +#define PWR_D3CR_VOS_SHIFT 14 +#define VOS_SCALE_3 1 +#define VOS_SCALE_2 2 +#define VOS_SCALE_1 3 +#define PWR_D3CR_VOSREADY BIT(13)
PATCH v2 3/9 dm: clk: add clk driver support for stm32h7 SoCs
Thanks Patrice,
Quoted 61 lines
-----Original Message-----
From: Patrice CHOTARD
Sent: Tuesday, September 26, 2017 5:27 AM
To: Vikas MANOCHA <[email protected]>; u-boot at lists.denx.de; albert.u.boot at aribaud.net; sjg at chromium.org
Cc: Patrick DELAUNAY <[email protected]>; Christophe KERELLO <[email protected]>
Subject: Re: [PATCH v2 3/9] dm: clk: add clk driver support for stm32h7 SoCsHi Vikas
Quoted 35 lines · Patrice CHOTARD
Hi Vikas
Quoted 23 lines · Patrice CHOTARD
Hi Vikas
Quoted 20 lines · Vikas Manocha
Hi Patrice,
Quoted 17 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
This driver implements basic clock setup, only clock gating is implemented.
This driver doesn't implement .of_match as it's binded by MFD RCC driver.
Files
include/dt-bindings/clock/stm32h7-clks.handdoc/device-tree-bindings/clock/st,stm32h7-rcc.txt
will be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
Signed-off-by Patrice Chotard <[email protected]>---
[...]
Quoted 6 lines
Quoted 5 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ +#define PWR_CR3 0x0c #define PWR_CR3_SDEN +BIT(2)Can we use SCUEN suffix to match the Ref Manual.
Quoted 6 lines
Quoted 3 lines
Which version of reference manual do you use ? in mine its SDEN, but i propably use a too old ref manual.
I have found the last version of STM32H7 ref manual, mine was too old, ok i will update the
PWR_CR3_SDENtoPWR_CR3_SCUENAfter double check, in the STM32H7x3 reference manual available on st.com (DocID029587 Rev 2), bit 2 of
PWR_CR3reg is described as following:"Bit 2 SCUEN: Supply configuration update enable This bit is read-only:
0: Supply configuration update locked.
1: Single write enabled to Supply configuration (LDOEN and BYPASS)"Whereas in the one i used, bit 2 of
PWR_CR3is described as:
Quoted 8 lines
"Bit 2 SDEN (1)(2) : SD converter Enable
0: Step down converter disabled
1: Step down converter enabled. (Default)"If i follow ref manual DocID029587 Rev 2, this bit is read-only, so the write access of
PWR_CR3bit(2) inclk_stm32h7.cis useless. But after write access removal, the both STM32H7 disco and eval board doesn't boot.The reference manual is wrong regarding with at least this bit. I will contact PWR architect to solve this point.
Ok, By the Rev3 of the Ref manual is also available online but does not matter for this bit. Even the explanation for this bit does not make sense if system does not boot without it.
Cheers,
Vikas
Quoted 15 lines
Patrice
Quoted 11 lines
thanks
Patrice
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
(quoted diff) +5
-0+#define PWR_D3CR 0x18 +#define PWR_D3CR_VOS_MASK GENMASK(15, 14) #define +PWR_D3CR_VOS_SHIFT 14 #define VOS_SCALE_3 1 +#define VOS_SCALE_2 2 #define VOS_SCALE_1 +3 #define PWR_D3CR_VOSREADY BIT(13)
PATCH v2 3/9 dm: clk: add clk driver support for stm32h7 SoCs
In reply to patrice.chotard at st.comQuoted 13 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
This driver implements basic clock setup, only clock gating is implemented.
This driver doesn't implement .of_match as it's binded by MFD RCC driver.
Files
include/dt-bindings/clock/stm32h7-clks.handdoc/device-tree-bindings/clock/st,stm32h7-rcc.txtwill be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].
Quoted 4 lines
[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170922/3adffd4a/attachment.sig>
PATCH v2 4/9 dm: reset: add stm32 reset driver
In reply to patrice.chotard at st.comFrom: Patrice Chotard <[email protected]>
This driver is adapted from linux drivers/reset/reset-stm32.c It's compatible with STM32 F4/F7/H7 SoCs.
This driver doesn't implement .of_match as it's binded by MFD RCC driver.
To add support for each SoC family, a SoC's specific include/dt-binfings/mfd/stm32xx-rcc.h file must be added.
This patch only includes stm32h7-rcc.h dedicated for STM32H7 SoCs. Other SoCs support will be added in the future.
--- doc/device-tree-bindings/reset/st,stm32-rcc.txt | 6 ++ drivers/reset/Kconfig | 7 ++ drivers/reset/Makefile | 1 + drivers/reset/stm32-reset.c | 80 ++++++++++++++ include/dt-bindings/mfd/stm32h7-rcc.h | 138 ++++++++++++++++++++++++ 5 files changed, 232 insertions(+) create mode 100644 doc/device-tree-bindings/reset/st,stm32-rcc.txt create mode 100644 drivers/reset/stm32-reset.c create mode 100644 include/dt-bindings/mfd/stm32h7-rcc.h
doc/device-tree-bindings/reset/st,stm32-rcc.txt new file +6 -0
@@ -0,0 +1,6 @@ +STMicroelectronics STM32 Peripheral Reset Controller +==================================================== + +The RCC IP is both a reset and a clock controller. + +Please see Documentation/devicetree/bindings/clock/st,stm32-rcc.txt
drivers/reset/Kconfig +7 -0
@@ -28,6 +28,13 @@ config STI_RESET Say Y if you want to control reset signals provided by system config block. +config STM32_RESET + bool "Enable the STM32 reset" + depends on STM32 + help + Support for reset controllers on STMicroelectronics STM32 family SoCs. + This resset driver is compatible with STM32 F4/F7 and H7 SoCs. + config TEGRA_CAR_RESET bool "Enable Tegra CAR-based reset driver" depends on TEGRA_CAR
drivers/reset/Makefile +1 -0
@@ -6,6 +6,7 @@ obj-$(CONFIG_DM_RESET) += reset-uclass.o obj-$(CONFIG_SANDBOX_MBOX) += sandbox-reset.o obj-$(CONFIG_SANDBOX_MBOX) += sandbox-reset-test.o obj-$(CONFIG_STI_RESET) += sti-reset.o +obj-$(CONFIG_STM32_RESET) += stm32-reset.o obj-$(CONFIG_TEGRA_CAR_RESET) += tegra-car-reset.o obj-$(CONFIG_TEGRA186_RESET) += tegra186-reset.o obj-$(CONFIG_RESET_BCM6345) += reset-bcm6345.o
drivers/reset/stm32-reset.c new file +80 -0
80 lines not on this page · raw message
include/dt-bindings/mfd/stm32h7-rcc.h new file +138 -0
138 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 4/9 dm: reset: add stm32 reset driver
Quoted 15 lines · On 13 September 2017 at 10:00, <[email protected]> wrote:
From: Patrice Chotard <[email protected]>
This driver is adapted from linux
drivers/reset/reset-stm32.cIt's compatible with STM32 F4/F7/H7 SoCs.This driver doesn't implement .of_match as it's binded by MFD RCC driver.
To add support for each SoC family, a SoC's specific
include/dt-binfings/mfd/stm32xx-rcc.hfile must be added.This patch only includes
stm32h7-rcc.hdedicated for STM32H7 SoCs. Other SoCs support will be added in the future.Signed-off-by Patrice Chotard <[email protected]>
Quoted 10 lines
--- doc/device-tree-bindings/reset/st,stm32-rcc.txt | 6 ++ drivers/reset/Kconfig | 7 ++ drivers/reset/Makefile | 1 + drivers/reset/stm32-reset.c | 80 ++++++++++++++ include/dt-bindings/mfd/stm32h7-rcc.h | 138 ++++++++++++++++++++++++ 5 files changed, 232 insertions(+) create mode 100644 doc/device-tree-bindings/reset/st,stm32-rcc.txt create mode 100644 drivers/reset/stm32-reset.c create mode 100644 include/dt-bindings/mfd/stm32h7-rcc.h
PATCH v2 4/9 dm: reset: add stm32 reset driver
In reply to patrice.chotard at st.comQuoted 8 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
This driver is adapted from linux
drivers/reset/reset-stm32.cIt's compatible with STM32 F4/F7/H7 SoCs.This driver doesn't implement .of_match as it's binded by MFD RCC driver.
Quoted 8 lines
To add support for each SoC family, a SoC's specific
include/dt-binfings/mfd/stm32xx-rcc.hfile must be added.This patch only includes
stm32h7-rcc.hdedicated for STM32H7 SoCs. Other SoCs support will be added in the future.Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170922/5c3f9a88/attachment.sig>
PATCH v2 5/9 dm: misc: add stm32 rcc driver
In reply to patrice.chotard at st.comFrom: Christophe Kerello <[email protected]>
This patch adds the support of reset and clock control block (rcc) found on STM32 SoCs.
This driver is similar to a MFD linux driver.
This driver supports currently STM32H7 only.
STM32F4 and STM32F7 will be migrated to this rcc MFD driver in the future to uniformize all STM32 SoCs already upstreamed.
---
v2: _ merge peripheral and kernel clocks arrays
_ add voltage scaling support needed for Evaluation board
drivers/misc/Kconfig | 9 +++++++++ drivers/misc/Makefile | 1 + drivers/misc/stm32_rcc.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 drivers/misc/stm32_rcc.c
drivers/misc/Kconfig +9 -0
@@ -158,6 +158,15 @@ config PCA9551_I2C_ADDR help The I2C address of the PCA9551 LED controller. +config STM32_RCC + bool "Enable RCC driver for the STM32 SoC's family" + depends on STM32 && MISC + help + Enable the STM32 RCC driver. The RCC block (Reset and Clock Control + block) is responsible of the management of the clock and reset + generation. + This driver is similar to an MFD driver in the Linux kernel. + config TEGRA_CAR bool "Enable support for the Tegra CAR driver" depends on TEGRA_NO_BPMP
drivers/misc/Makefile +1 -0
@@ -52,3 +52,4 @@ obj-$(CONFIG_FSL_DEVICE_DISABLE) += fsl_devdis.o obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o obj-$(CONFIG_QFW) += qfw.o obj-$(CONFIG_ROCKCHIP_EFUSE) += rockchip-efuse.o +obj-$(CONFIG_STM32_RCC) += stm32_rcc.o
drivers/misc/stm32_rcc.c new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 5/9 dm: misc: add stm32 rcc driver
Quoted 15 lines · On 13 September 2017 at 10:00, <[email protected]> wrote:
From: Christophe Kerello <[email protected]>
This patch adds the support of reset and clock control block (rcc) found on STM32 SoCs.
This driver is similar to a MFD linux driver.This driver supports currently STM32H7 only.
STM32F4 and STM32F7 will be migrated to this rcc MFD driver in the future to uniformize all STM32 SoCs already upstreamed.Signed-off-by Christophe Kerello <[email protected]>Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Vikas Manocha <[email protected]>---
Quoted 8 lines
v2: _ merge peripheral and kernel clocks arrays
_ add voltage scaling support needed for Evaluation boarddrivers/misc/Kconfig | 9 +++++++++ drivers/misc/Makefile | 1 + drivers/misc/stm32_rcc.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 drivers/misc/stm32_rcc.c
PATCH v2 5/9 dm: misc: add stm32 rcc driver
In reply to patrice.chotard at st.comQuoted 6 lines · patrice.chotard at st.com
From: Christophe Kerello <[email protected]>
This patch adds the support of reset and clock control block (rcc) found on STM32 SoCs.
This driver is similar to a MFD linux driver.
Quoted 8 lines
This driver supports currently STM32H7 only.
STM32F4 and STM32F7 will be migrated to this rcc MFD driver in the future to uniformize all STM32 SoCs already upstreamed.Signed-off-by Christophe Kerello <[email protected]>Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Vikas Manocha <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170922/d3b739ef/attachment.sig>
PATCH v2 6/9 ARM: DTS: stm32: add stm32h743i-disco files
In reply to patrice.chotard at st.comFrom: Patrice Chotard <[email protected]>
All these files are imported from linux kernel v4.13
Add device tree support for STM32H743 SoC and discovery board. This board offers :
_ STM32H743XIH6 microcontroller with 2 Mbytes of
Flash memory and 1 Mbyte of RAM in TFBGA240+25 package
_ 5.7” 640x480 TFT color LCD with touch screen
_ Ethernet compliant with IEEE-802.3-2002
_ USB OTG HS
_ I2 C compatible serial interface
_ ST-MEMS digital microphones
_ 8-Gbyte (or more) SDIO3.0 interface microSD™ card
_ 8Mx32bit SDRAM
_ 1-Gbit Twin Quad-SPI NOR Flash
_ Reset, wakeup, or key buttons
_ Joystick with 4-direction control and selector
_ Board connectors :
1 USB with Micro-AB
Ethernet RJ45
Stereo headset jack including analog microphone input microSD™ card
RCA connector
JTAG/SWD and ETM trace
_ Expansion connectors:
Arduino Uno compatible Connectors
2 x PIO connectors (PMOD and PMOD+)
_ On-board ST-LINK/V2-1 debugger/programmer with USB re-enumeration
capability: mass storage, virtual COM port and debug port
---
v2: _ reword the board description
arch/arm/dts/Makefile | 1 + arch/arm/dts/stm32h743-pinctrl.dtsi | 169 +++ arch/arm/dts/stm32h743.dtsi | 91 ++ arch/arm/dts/stm32h743i-disco.dts | 73 ++ include/dt-bindings/pinctrl/stm32h7-pinfunc.h | 1612 +++++++++++++++++++++++++ 5 files changed, 1946 insertions(+) create mode 100644 arch/arm/dts/stm32h743-pinctrl.dtsi create mode 100644 arch/arm/dts/stm32h743.dtsi create mode 100644 arch/arm/dts/stm32h743i-disco.dts create mode 100644 include/dt-bindings/pinctrl/stm32h7-pinfunc.h
arch/arm/dts/Makefile +1 -0
@@ -205,6 +205,7 @@ dtb-$(CONFIG_ARCH_SNAPDRAGON) += dragonboard410c.dtb dtb-$(CONFIG_STM32F7) += stm32f746-disco.dtb \ stm32f769-disco.dtb +dtb-$(CONFIG_STM32H7) += stm32h743i-disco.dtb dtb-$(CONFIG_MACH_SUN4I) += \ sun4i-a10-a1000.dtb \
arch/arm/dts/stm32h743-pinctrl.dtsi new file +169 -0
169 lines not on this page · raw message
arch/arm/dts/stm32h743.dtsi new file +91 -0
91 lines not on this page · raw message
arch/arm/dts/stm32h743i-disco.dts new file +73 -0
73 lines not on this page · raw message
include/dt-bindings/pinctrl/stm32h7-pinfunc.h new file +1612 -0
1,612 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 6/9 ARM: DTS: stm32: add stm32h743i-disco files
Quoted 37 lines · On 13 September 2017 at 10:00, <[email protected]> wrote:
From: Patrice Chotard <[email protected]>
All these files are imported from linux kernel v4.13
Add device tree support for STM32H743 SoC and discovery board. This board offers :
_ STM32H743XIH6 microcontroller with 2 Mbytes of
Flash memory and 1 Mbyte of RAM in TFBGA240+25 package
_ 5.7” 640x480 TFT color LCD with touch screen
_ Ethernet compliant with IEEE-802.3-2002
_ USB OTG HS
_ I2 C compatible serial interface
_ ST-MEMS digital microphones
_ 8-Gbyte (or more) SDIO3.0 interface microSD™ card
_ 8Mx32bit SDRAM
_ 1-Gbit Twin Quad-SPI NOR Flash
_ Reset, wakeup, or key buttons
_ Joystick with 4-direction control and selector
_ Board connectors :
1 USB with Micro-AB
Ethernet RJ45
Stereo headset jack including analog microphone input microSD™ card
RCA connector
JTAG/SWD and ETM trace
_ Expansion connectors:
Arduino Uno compatible Connectors
2 x PIO connectors (PMOD and PMOD+)
_ On-board ST-LINK/V2-1 debugger/programmer with USB re-enumeration
capability: mass storage, virtual COM port and debug portSigned-off-by Patrice Chotard <[email protected]>Reviewed-by Vikas Manocha <[email protected]>---
v2: _ reword the board description
Quoted 10 lines
arch/arm/dts/Makefile | 1 + arch/arm/dts/stm32h743-pinctrl.dtsi | 169 +++ arch/arm/dts/stm32h743.dtsi | 91 ++ arch/arm/dts/stm32h743i-disco.dts | 73 ++ include/dt-bindings/pinctrl/stm32h7-pinfunc.h | 1612 +++++++++++++++++++++++++ 5 files changed, 1946 insertions(+) create mode 100644 arch/arm/dts/stm32h743-pinctrl.dtsi create mode 100644 arch/arm/dts/stm32h743.dtsi create mode 100644 arch/arm/dts/stm32h743i-disco.dts create mode 100644 include/dt-bindings/pinctrl/stm32h7-pinfunc.h
PATCH v2 6/9 ARM: DTS: stm32: add stm32h743i-disco files
In reply to patrice.chotard at st.comQuoted 31 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
All these files are imported from linux kernel v4.13
Add device tree support for STM32H743 SoC and discovery board. This board offers :
_ STM32H743XIH6 microcontroller with 2 Mbytes of
Flash memory and 1 Mbyte of RAM in TFBGA240+25 package
_ 5.7” 640x480 TFT color LCD with touch screen
_ Ethernet compliant with IEEE-802.3-2002
_ USB OTG HS
_ I2 C compatible serial interface
_ ST-MEMS digital microphones
_ 8-Gbyte (or more) SDIO3.0 interface microSD™ card
_ 8Mx32bit SDRAM
_ 1-Gbit Twin Quad-SPI NOR Flash
_ Reset, wakeup, or key buttons
_ Joystick with 4-direction control and selector
_ Board connectors :
1 USB with Micro-AB
Ethernet RJ45
Stereo headset jack including analog microphone input microSD™ card
RCA connector
JTAG/SWD and ETM trace
_ Expansion connectors:
Arduino Uno compatible Connectors
2 x PIO connectors (PMOD and PMOD+)
_ On-board ST-LINK/V2-1 debugger/programmer with USB re-enumeration
capability: mass storage, virtual COM port and debug port
Quoted 3 lines
Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Vikas Manocha <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170922/ecb9a1f4/attachment.sig>
PATCH v2 7/9 ARM: DTS: stm32: add stm32h743i-eval files
In reply to patrice.chotard at st.comFrom: Patrice Chotard <[email protected]>
This file is imported from linux kernel v4.13
Add device tree support for STM32H743 evaluation board. This board offers :
_ STM32H743XIH6 microcontroller with 2 Mbytes of
Flash memory and 1 Mbyte of RAM in TFBGA240+25 package
_ 5.7” 640x480 TFT color LCD with touch screen
_ Ethernet compliant with IEEE-802.3-2002
_ USB OTG HS and FS
_ I2 C compatible serial interface
_ RTC with rechargeable backup battery
_ SAI Audio DAC
_ ST-MEMS digital microphones
_ 8-Gbyte (or more) SDIO3.0 interface microSD™ card
_ 8Mx32bit SDRAM, 1Mx16bit SRAM and 8Mx16bit NOR Flash
_ 1-Gbit Twin Quad-SPI NOR Flash
_ Potentiometer
_ 4 colored user LEDs
_ Reset, wakeup, tamper or key buttons
_ Joystick with 4-direction control and selector
_ Board connectors :
Power jack
3 USB with Micro-AB
RS-232 communications
Ethernet RJ45
FD-CAN compliant connection
Stereo headset jack including analog microphone input 2 audio jacks for external speakers
microSD™ card
JTAG/SWD and ETM trace
_ Expansion connectors:
Extension connectors and memory connectors for daughterboard or wire-wrap board
_ Flexible power-supply options: ST-LINK USB VBUS or external
sources
_ On-board ST-LINK/V2-1 debugger/programmer with USB re-enumeration
capability: mass storage, virtual COM port and debug port
--- arch/arm/dts/Makefile | 3 +- arch/arm/dts/stm32h743i-eval.dts | 74 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/stm32h743i-eval.dts
arch/arm/dts/Makefile +2 -1
@@ -205,7 +205,8 @@ dtb-$(CONFIG_ARCH_SNAPDRAGON) += dragonboard410c.dtb dtb-$(CONFIG_STM32F7) += stm32f746-disco.dtb \ stm32f769-disco.dtb -dtb-$(CONFIG_STM32H7) += stm32h743i-disco.dtb +dtb-$(CONFIG_STM32H7) += stm32h743i-disco.dtb \ + stm32h743i-eval.dtb dtb-$(CONFIG_MACH_SUN4I) += \ sun4i-a10-a1000.dtb \
arch/arm/dts/stm32h743i-eval.dts new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 7/9 ARM: DTS: stm32: add stm32h743i-eval files
Quoted 40 lines · On 13 September 2017 at 10:00, <[email protected]> wrote:
From: Patrice Chotard <[email protected]>
This file is imported from linux kernel v4.13
Add device tree support for STM32H743 evaluation board. This board offers :
_ STM32H743XIH6 microcontroller with 2 Mbytes of
Flash memory and 1 Mbyte of RAM in TFBGA240+25 package
_ 5.7” 640x480 TFT color LCD with touch screen
_ Ethernet compliant with IEEE-802.3-2002
_ USB OTG HS and FS
_ I2 C compatible serial interface
_ RTC with rechargeable backup battery
_ SAI Audio DAC
_ ST-MEMS digital microphones
_ 8-Gbyte (or more) SDIO3.0 interface microSD™ card
_ 8Mx32bit SDRAM, 1Mx16bit SRAM and 8Mx16bit NOR Flash
_ 1-Gbit Twin Quad-SPI NOR Flash
_ Potentiometer
_ 4 colored user LEDs
_ Reset, wakeup, tamper or key buttons
_ Joystick with 4-direction control and selector
_ Board connectors :
Power jack
3 USB with Micro-AB
RS-232 communications
Ethernet RJ45
FD-CAN compliant connection
Stereo headset jack including analog microphone input 2 audio jacks for external speakers
microSD™ card
JTAG/SWD and ETM trace
_ Expansion connectors:
Extension connectors and memory connectors for daughterboard or wire-wrap board
_ Flexible power-supply options: ST-LINK USB VBUS or external
sources
_ On-board ST-LINK/V2-1 debugger/programmer with USB re-enumeration
capability: mass storage, virtual COM port and debug port
Quoted 7 lines
Signed-off-by Patrice Chotard <[email protected]>--- arch/arm/dts/Makefile | 3 +- arch/arm/dts/stm32h743i-eval.dts | 74 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 arch/arm/dts/stm32h743i-eval.dts
PATCH v2 7/9 ARM: DTS: stm32: add stm32h743i-eval files
In reply to patrice.chotard at st.comQuoted 40 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
This file is imported from linux kernel v4.13
Add device tree support for STM32H743 evaluation board. This board offers :
_ STM32H743XIH6 microcontroller with 2 Mbytes of
Flash memory and 1 Mbyte of RAM in TFBGA240+25 package
_ 5.7” 640x480 TFT color LCD with touch screen
_ Ethernet compliant with IEEE-802.3-2002
_ USB OTG HS and FS
_ I2 C compatible serial interface
_ RTC with rechargeable backup battery
_ SAI Audio DAC
_ ST-MEMS digital microphones
_ 8-Gbyte (or more) SDIO3.0 interface microSD™ card
_ 8Mx32bit SDRAM, 1Mx16bit SRAM and 8Mx16bit NOR Flash
_ 1-Gbit Twin Quad-SPI NOR Flash
_ Potentiometer
_ 4 colored user LEDs
_ Reset, wakeup, tamper or key buttons
_ Joystick with 4-direction control and selector
_ Board connectors :
Power jack
3 USB with Micro-AB
RS-232 communications
Ethernet RJ45
FD-CAN compliant connection
Stereo headset jack including analog microphone input 2 audio jacks for external speakers
microSD™ card
JTAG/SWD and ETM trace
_ Expansion connectors:
Extension connectors and memory connectors for daughterboard or wire-wrap board
_ Flexible power-supply options: ST-LINK USB VBUS or external
sources
_ On-board ST-LINK/V2-1 debugger/programmer with USB re-enumeration
capability: mass storage, virtual COM port and debug port
Quoted 2 lines
Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170922/2e46685e/attachment.sig>
PATCH v2 8/9 ARM: DTS: stm32: adapt stm32h7 dts files for U-boot
In reply to patrice.chotard at st.comFrom: Patrice Chotard <[email protected]>
This patch adapts stm32h743 disco and eval dts files to match with U-boot requirements or add features wich are not yet upstreamed on kernel side :
_ Add RCC clock driver node and update all clocks phandle
accordingly.
By default, on kernel side, all clocks was temporarly configured as a phandle to timer_clk waiting for a RCC clock driver to be available.
On U-boot side, we now have a dedicated RCC clock driver, we can configured all clocks as phandle to this driver.
All this binding update will be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].
[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
_ Align STM32H7 serial compatible string with the one which will be
available in next kernel tag. The bindings has been acked by Rob Herring [2].
This compatible string will be usefull to add stm32h7 specific feature for this serial driver.
[2] https://lkml.org/lkml/2017/7/17/739
_ Add gpio compatible and aliases for stm32h743
_ Add FMC sdram node with associated new bindings value to
manage second bank (ie bank 1).
_ Add missing HSI and CSI oscillators nodes needed
by STM32H7 RCC clock driver.
Clock sources could be:
_ HSE (High Speed External)
_ HSI (High Speed Internal)
_ CSI (Low Power Internal)
These clocks can be used as clocksource in some configuration. By default, HSE is selected as clock source.
_ Set HSE to 25Mhz for stm32h743i-disco and eval board
By default, the external oscillator frequency is defined at 25 Mhz in SoC stm32h743.dtsi file.
It has been set at 125 Mhz in kernel DT temporarly waiting for RCC clock driver becomes available.
As in U-boot we got a RCC clock driver, the real value of HSE clock can be used.
_ Add "u-boot,dm-pre-reloc" for rcc, fmc, fixed-clock, pinctrl,
pwrcfg and gpio nodes.
--- arch/arm/dts/stm32h7-u-boot.dtsi | 88 ++++++++++++++++++++++++++ arch/arm/dts/stm32h743-pinctrl.dtsi | 102 +++++++++++++++++++++++++++---- arch/arm/dts/stm32h743.dtsi | 56 ++++++++++++++--- arch/arm/dts/stm32h743i-disco.dts | 35 +++++++++-- arch/arm/dts/stm32h743i-eval.dts | 34 +++++++++-- include/dt-bindings/memory/stm32-sdram.h | 7 +++ 6 files changed, 294 insertions(+), 28 deletions(-) create mode 100644 arch/arm/dts/stm32h7-u-boot.dtsi
arch/arm/dts/stm32h7-u-boot.dtsi new file +88 -0
@@ -0,0 +1,88 @@ +/{ + clocks { + u-boot,dm-pre-reloc; + }; + + soc { + u-boot,dm-pre-reloc; + pin-controller { + u-boot,dm-pre-reloc; + }; + }; +}; + +&clk_hse { + u-boot,dm-pre-reloc; +}; + +&clk_lse { + u-boot,dm-pre-reloc; +}; + +&clk_i2s { + u-boot,dm-pre-reloc; +}; + +&pwrcfg { + u-boot,dm-pre-reloc; +}; + +&rcc { + u-boot,dm-pre-reloc; +}; + +&fmc { + u-boot,dm-pre-reloc; +}; + +&clk_hsi { + u-boot,dm-pre-reloc; +}; + +&clk_csi { + u-boot,dm-pre-reloc; +}; + +&gpioa { + u-boot,dm-pre-reloc; +}; + +&gpiob { + u-boot,dm-pre-reloc; +}; + +&gpioc { + u-boot,dm-pre-reloc; +}; + +&gpiod { + u-boot,dm-pre-reloc; +}; + +&gpioe { + u-boot,dm-pre-reloc; +}; + +&gpiof { + u-boot,dm-pre-reloc; +}; + +&gpiog { + u-boot,dm-pre-reloc; +}; + +&gpioh { + u-boot,dm-pre-reloc; +}; + +&gpioi { + u-boot,dm-pre-reloc; +}; + +&gpioj { + u-boot,dm-pre-reloc; +}; + +&gpiok { + u-boot,dm-pre-reloc; +};
arch/arm/dts/stm32h743-pinctrl.dtsi +91 -11
185 lines not on this page · raw message
arch/arm/dts/stm32h743.dtsi +47 -9
92 lines not on this page · raw message
arch/arm/dts/stm32h743i-disco.dts +31 -4
@@ -43,6 +43,7 @@ /dts-v1/; #include "stm32h743.dtsi" #include "stm32h743-pinctrl.dtsi" +#include <dt-bindings/memory/stm32-sdram.h> / { model = "STMicroelectronics STM32H743i-Discovery board";
@@ -59,15 +60,41 @@ aliases { serial0 = &usart2; + gpio0 = &gpioa; + gpio1 = &gpiob; + gpio2 = &gpioc; + gpio3 = &gpiod; + gpio4 = &gpioe; + gpio5 = &gpiof; + gpio6 = &gpiog; + gpio7 = &gpioh; + gpio8 = &gpioi; + gpio9 = &gpioj; + gpio10 = &gpiok; }; }; -&clk_hse { - clock-frequency = <125000000>; -}; - &usart2 { pinctrl-0 = <&usart2_pins>; pinctrl-names = "default"; status = "okay"; }; + +&fmc { + pinctrl-0 = <&fmc_pins>; + pinctrl-names = "default"; + status = "okay"; + + /* + * Memory configuration from sdram datasheet IS42S32800G-6BLI + * firsct bank is bank at 0 + * second bank is bank at 1 + */ + bank1: bank at 1 { + st,sdram-control = /bits/ 8 <NO_COL_9 NO_ROW_12 MWIDTH_32 BANKS_4 + CAS_2 SDCLK_3 RD_BURST_EN RD_PIPE_DL_0>; + st,sdram-timing = /bits/ 8 <TMRD_1 TXSR_1 TRAS_1 TRC_6 TRP_2 + TWR_1 TRCD_1>; + st,sdram-refcount = <1539>; + }; +};
arch/arm/dts/stm32h743i-eval.dts +30 -4
@@ -43,6 +43,7 @@ /dts-v1/; #include "stm32h743.dtsi" #include "stm32h743-pinctrl.dtsi" +#include <dt-bindings/memory/stm32-sdram.h> / { model = "STMicroelectronics STM32H743i-EVAL board";
@@ -59,16 +60,41 @@ aliases { serial0 = &usart1; + gpio0 = &gpioa; + gpio1 = &gpiob; + gpio2 = &gpioc; + gpio3 = &gpiod; + gpio4 = &gpioe; + gpio5 = &gpiof; + gpio6 = &gpiog; + gpio7 = &gpioh; + gpio8 = &gpioi; + gpio9 = &gpioj; + gpio10 = &gpiok; }; }; -&clk_hse { - clock-frequency = <125000000>; -}; - &usart1 { pinctrl-0 = <&usart1_pins>; pinctrl-names = "default"; status = "okay"; }; +&fmc { + pinctrl-0 = <&fmc_pins>; + pinctrl-names = "default"; + status = "okay"; + + /* + * Memory configuration from sdram datasheet IS42S32800G-6BLI + * firsct bank is bank at 0 + * second bank is bank at 1 + */ + bank2: bank at 1 { + st,sdram-control = /bits/ 8 <NO_COL_9 NO_ROW_12 MWIDTH_32 BANKS_4 + CAS_2 SDCLK_3 RD_BURST_EN RD_PIPE_DL_0>; + st,sdram-timing = /bits/ 8 <TMRD_1 TXSR_1 TRAS_1 TRC_6 TRP_2 + TWR_1 TRCD_1>; + st,sdram-refcount = <1539>; + }; +};
include/dt-bindings/memory/stm32-sdram.h +7 -0
@@ -18,7 +18,9 @@#define CAS_1 0x1#define CAS_2 0x2#define CAS_3 0x3 +#define SDCLK_DIS 0x0#define SDCLK_2 0x2 +#define SDCLK_3 0x3#define RD_BURST_EN 0x1#define RD_BURST_DIS 0x0#define RD_PIPE_DL_0 0x0
@@ -26,12 +28,17 @@#define RD_PIPE_DL_2 0x2/* Timing = value +1 cycles */ +#define TMRD_1 (1 - 1)#define TMRD_2 (2 - 1) +#define TXSR_1 (1 - 1)#define TXSR_6 (6 - 1) +#define TRAS_1 (1 - 1)#define TRAS_4 (4 - 1)#define TRC_6 (6 - 1) +#define TWR_1 (1 - 1)#define TWR_2 (2 - 1)#define TRP_2 (2 - 1) +#define TRCD_1 (1 - 1)#define TRCD_2 (2 - 1)#endif
Signature · 1 line
1.9.1
PATCH v2 8/9 ARM: DTS: stm32: adapt stm32h7 dts files for U-boot
Quoted 4 lines · On 13 September 2017 at 10:00, <[email protected]> wrote:
From: Patrice Chotard <[email protected]>
This patch adapts stm32h743 disco and eval dts files to match with U-boot requirements or add features wich are not yet
U-Boot (and below)
Quoted 54 lines
upstreamed on kernel side :
_ Add RCC clock driver node and update all clocks phandle
accordingly.By default, on kernel side, all clocks was temporarly configured as a phandle to
timer_clkwaiting for a RCC clock driver to be available.
On U-boot side, we now have a dedicated RCC clock driver, we can configured all clocks as phandle to this driver.All this binding update will be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].
[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
_ Align STM32H7 serial compatible string with the one which will be
available in next kernel tag. The bindings has been acked by Rob Herring [2].
This compatible string will be usefull to add stm32h7 specific feature for this serial driver.[2] https://lkml.org/lkml/2017/7/17/739
_ Add gpio compatible and aliases for stm32h743
_ Add FMC sdram node with associated new bindings value to
manage second bank (ie bank 1)._ Add missing HSI and CSI oscillators nodes needed
by STM32H7 RCC clock driver.Clock sources could be:
_ HSE (High Speed External)
_ HSI (High Speed Internal)
_ CSI (Low Power Internal)These clocks can be used as clocksource in some configuration. By default, HSE is selected as clock source.
_ Set HSE to 25Mhz for stm32h743i-disco and eval board
By default, the external oscillator frequency is defined at 25 Mhz in SoC
stm32h743.dtsifile.
It has been set at 125 Mhz in kernel DT temporarly waiting for RCC clock driver becomes available.As in U-boot we got a RCC clock driver, the real value of HSE clock can be used.
_ Add "u-boot,dm-pre-reloc" for rcc, fmc, fixed-clock, pinctrl,
pwrcfg and gpio nodes.Signed-off-by Patrice Chotard <[email protected]>
Quoted 9 lines
--- arch/arm/dts/stm32h7-u-boot.dtsi | 88 ++++++++++++++++++++++++++ arch/arm/dts/stm32h743-pinctrl.dtsi | 102 +++++++++++++++++++++++++++---- arch/arm/dts/stm32h743.dtsi | 56 ++++++++++++++--- arch/arm/dts/stm32h743i-disco.dts | 35 +++++++++-- arch/arm/dts/stm32h743i-eval.dts | 34 +++++++++-- include/dt-bindings/memory/stm32-sdram.h | 7 +++ 6 files changed, 294 insertions(+), 28 deletions(-) create mode 100644 arch/arm/dts/stm32h7-u-boot.dtsi
PATCH v2 8/9 ARM: DTS: stm32: adapt stm32h7 dts files for U-boot
In reply to patrice.chotard at st.comQuoted 51 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
This patch adapts stm32h743 disco and eval dts files to match with U-boot requirements or add features wich are not yet upstreamed on kernel side :
_ Add RCC clock driver node and update all clocks phandle
accordingly.By default, on kernel side, all clocks was temporarly configured as a phandle to
timer_clkwaiting for a RCC clock driver to be available.
On U-boot side, we now have a dedicated RCC clock driver, we can configured all clocks as phandle to this driver.All this binding update will be available soon in a kernel tag, as all the bindings have been acked by Rob Herring [1].
[1] http://lkml.iu.edu/hypermail/linux/kernel/1704.0/00935.html
_ Align STM32H7 serial compatible string with the one which will be
available in next kernel tag. The bindings has been acked by Rob Herring [2].
This compatible string will be usefull to add stm32h7 specific feature for this serial driver.[2] https://lkml.org/lkml/2017/7/17/739
_ Add gpio compatible and aliases for stm32h743
_ Add FMC sdram node with associated new bindings value to
manage second bank (ie bank 1)._ Add missing HSI and CSI oscillators nodes needed
by STM32H7 RCC clock driver.Clock sources could be:
_ HSE (High Speed External)
_ HSI (High Speed Internal)
_ CSI (Low Power Internal)These clocks can be used as clocksource in some configuration. By default, HSE is selected as clock source.
_ Set HSE to 25Mhz for stm32h743i-disco and eval board
By default, the external oscillator frequency is defined at 25 Mhz in SoC
stm32h743.dtsifile.
It has been set at 125 Mhz in kernel DT temporarly waiting for RCC clock driver becomes available.
Quoted 8 lines
As in U-boot we got a RCC clock driver, the real value of HSE clock can be used.
_ Add "u-boot,dm-pre-reloc" for rcc, fmc, fixed-clock, pinctrl,
pwrcfg and gpio nodes.Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170922/d5b8b263/attachment.sig>
PATCH v2 9/9 board: Add stm32h7 SoC, discovery and evaluation boards support
In reply to patrice.chotard at st.comFrom: Patrice Chotard <[email protected]>
This patch adds support for stm32h7 soc family, stm32h743 discovery and evaluation boards.
For more information about STM32H7 series, please visit:
http://www.st.com/en/microcontrollers/stm32h7-series.html
---
v2: _ get memory address and size from DT in board file
arch/arm/include/asm/arch-stm32h7/gpio.h | 126 +++++++++++++++++++++++++++++ arch/arm/include/asm/arch-stm32h7/stm32.h | 21 +++++ arch/arm/mach-stm32/Kconfig | 17 ++++ arch/arm/mach-stm32/Makefile | 1 + arch/arm/mach-stm32/stm32h7/Kconfig | 12 +++ arch/arm/mach-stm32/stm32h7/Makefile | 8 ++ arch/arm/mach-stm32/stm32h7/soc.c | 59 ++++++++++++++ board/st/stm32h743-disco/Kconfig | 19 +++++ board/st/stm32h743-disco/MAINTAINERS | 7 ++ board/st/stm32h743-disco/Makefile | 8 ++ board/st/stm32h743-disco/stm32h743-disco.c | 56 +++++++++++++ board/st/stm32h743-eval/Kconfig | 19 +++++ board/st/stm32h743-eval/MAINTAINERS | 6 ++ board/st/stm32h743-eval/Makefile | 8 ++ board/st/stm32h743-eval/stm32h743-eval.c | 56 +++++++++++++ configs/stm32h743-disco_defconfig | 30 +++++++ configs/stm32h743-eval_defconfig | 30 +++++++ include/configs/stm32h743-disco.h | 51 ++++++++++++ include/configs/stm32h743-eval.h | 51 ++++++++++++ 19 files changed, 585 insertions(+) create mode 100644 arch/arm/include/asm/arch-stm32h7/gpio.h create mode 100644 arch/arm/include/asm/arch-stm32h7/stm32.h create mode 100644 arch/arm/mach-stm32/stm32h7/Kconfig create mode 100644 arch/arm/mach-stm32/stm32h7/Makefile create mode 100644 arch/arm/mach-stm32/stm32h7/soc.c create mode 100644 board/st/stm32h743-disco/Kconfig create mode 100644 board/st/stm32h743-disco/MAINTAINERS create mode 100644 board/st/stm32h743-disco/Makefile create mode 100644 board/st/stm32h743-disco/stm32h743-disco.c create mode 100644 board/st/stm32h743-eval/Kconfig create mode 100644 board/st/stm32h743-eval/MAINTAINERS create mode 100644 board/st/stm32h743-eval/Makefile create mode 100644 board/st/stm32h743-eval/stm32h743-eval.c create mode 100644 configs/stm32h743-disco_defconfig create mode 100644 configs/stm32h743-eval_defconfig create mode 100644 include/configs/stm32h743-disco.h create mode 100644 include/configs/stm32h743-eval.h
arch/arm/include/asm/arch-stm32h7/gpio.h new file +126 -0
@@ -0,0 +1,126 @@ +/* +* Copyright (C) STMicroelectronics SA 2017 +* Author(s): Patrice CHOTARD, <[email protected]> for STMicroelectronics. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _STM32_GPIO_H_ +#define _STM32_GPIO_H_ +#include <asm/gpio.h> + +enum stm32_gpio_port { +STM32_GPIO_PORT_A =0 , +STM32_GPIO_PORT_B , +STM32_GPIO_PORT_C , +STM32_GPIO_PORT_D , +STM32_GPIO_PORT_E , +STM32_GPIO_PORT_F , +STM32_GPIO_PORT_G , +STM32_GPIO_PORT_H , +STM32_GPIO_PORT_I +}; + +enum stm32_gpio_pin { +STM32_GPIO_PIN_0 =0 , +STM32_GPIO_PIN_1 , +STM32_GPIO_PIN_2 , +STM32_GPIO_PIN_3 , +STM32_GPIO_PIN_4 , +STM32_GPIO_PIN_5 , +STM32_GPIO_PIN_6 , +STM32_GPIO_PIN_7 , +STM32_GPIO_PIN_8 , +STM32_GPIO_PIN_9 , +STM32_GPIO_PIN_10 , +STM32_GPIO_PIN_11 , +STM32_GPIO_PIN_12 , +STM32_GPIO_PIN_13 , +STM32_GPIO_PIN_14 , +STM32_GPIO_PIN_15 +}; + +enum stm32_gpio_mode { +STM32_GPIO_MODE_IN =0 , +STM32_GPIO_MODE_OUT , +STM32_GPIO_MODE_AF , +STM32_GPIO_MODE_AN +}; + +enum stm32_gpio_otype { +STM32_GPIO_OTYPE_PP =0 , +STM32_GPIO_OTYPE_OD +}; + +enum stm32_gpio_speed { +STM32_GPIO_SPEED_2M =0 , +STM32_GPIO_SPEED_25M , +STM32_GPIO_SPEED_50M , +STM32_GPIO_SPEED_100M +}; + +enum stm32_gpio_pupd { +STM32_GPIO_PUPD_NO =0 , +STM32_GPIO_PUPD_UP , +STM32_GPIO_PUPD_DOWN +}; + +enum stm32_gpio_af { +STM32_GPIO_AF0 =0 , +STM32_GPIO_AF1 , +STM32_GPIO_AF2 , +STM32_GPIO_AF3 , +STM32_GPIO_AF4 , +STM32_GPIO_AF5 , +STM32_GPIO_AF6 , +STM32_GPIO_AF7 , +STM32_GPIO_AF8 , +STM32_GPIO_AF9 , +STM32_GPIO_AF10 , +STM32_GPIO_AF11 , +STM32_GPIO_AF12 , +STM32_GPIO_AF13 , +STM32_GPIO_AF14 , +STM32_GPIO_AF15 +}; + +struct stm32_gpio_dsc { +enum stm32_gpio_port port; +enum stm32_gpio_pin pin; +}; + +struct stm32_gpio_ctl { +enum stm32_gpio_mode mode; +enum stm32_gpio_otype otype; +enum stm32_gpio_speed speed; +enum stm32_gpio_pupd pupd; +enum stm32_gpio_af af; +}; + +struct stm32_gpio_regs { +u32 moder;/* GPIO port mode */ +u32 otyper;/* GPIO port output type */ +u32 ospeedr;/* GPIO port output speed */ +u32 pupdr;/* GPIO port pull-up/pull-down */ +u32 idr;/* GPIO port input data */ +u32 odr;/* GPIO port output data */ +u32 bsrr;/* GPIO port bit set/reset */ +u32 lckr;/* GPIO port configuration lock */ +u32 afr[2 ];/* GPIO alternate function */ +}; + +struct stm32_gpio_priv { +struct stm32_gpio_regs *regs; +}; + +static inline unsigned stm32_gpio_to_port (unsigned gpio) +{ +return gpio /16 ; +} + +static inline unsigned stm32_gpio_to_pin (unsigned gpio) +{ +return gpio %16 ; +} + +#endif /* _STM32_GPIO_H_ */
arch/arm/include/asm/arch-stm32h7/stm32.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Copyright (C) STMicroelectronics SA 2017 +* Author(s): Patrice CHOTARD, <[email protected]> for STMicroelectronics. +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +#ifndef _ASM_ARCH_HARDWARE_H +#define _ASM_ARCH_HARDWARE_H + +/* +* This empty files is needed to not break compilation +* Some common drivers to STM32F4/F7 and H7 include a stm32.h file +* Some cleanup need to be done to communalize all the following +* stm32.h files: +* +* arch/arm/include/asm/arch-stm32f1/stm32.h +* arch/arm/include/asm/arch-stm32f4/stm32.h +* arch/arm/include/asm/arch-stm32f7/stm32.h +*/ +#endif /* _ASM_ARCH_HARDWARE_H */
arch/arm/mach-stm32/Kconfig +17 -0
@@ -25,7 +25,24 @@ config STM32F7 select SPL_SYS_MALLOC_SIMPLE select SPL_XIP_SUPPORT +config STM32H7 + bool "stm32h7 family" + select CLK + select DM_GPIO + select DM_RESET + select MISC + select PINCTRL + select PINCTRL_STM32 + select RAM + select REGMAP + select STM32_SDRAM + select STM32_RCC + select STM32_RESET + select STM32X7_SERIAL + select SYSCON + source "arch/arm/mach-stm32/stm32f4/Kconfig" source "arch/arm/mach-stm32/stm32f7/Kconfig" +source "arch/arm/mach-stm32/stm32h7/Kconfig" endif
arch/arm/mach-stm32/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_STM32F4) += stm32f4/ obj-$(CONFIG_STM32F7) += stm32f7/ +obj-$(CONFIG_STM32H7) += stm32h7/
arch/arm/mach-stm32/stm32h7/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +if STM32H7 + +config TARGET_STM32H743_DISCO + bool "STM32H743 Discovery board" + +config TARGET_STM32H743_EVAL + bool "STM32H743 Evaluation board" + +source "board/st/stm32h743-eval/Kconfig" +source "board/st/stm32h743-disco/Kconfig" + +endif
arch/arm/mach-stm32/stm32h7/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Copyright (c) 2017 +# Patrice Chotard <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += soc.o
arch/arm/mach-stm32/stm32h7/soc.c new file +59 -0
59 lines not on this page · raw message
board/st/stm32h743-disco/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +if TARGET_STM32H743_DISCO + +config SYS_BOARD + string + default "stm32h743-disco" + +config SYS_VENDOR + string + default "st" + +config SYS_SOC + string + default "stm32h7" + +config SYS_CONFIG_NAME + string + default "stm32h743-disco" + +endif
board/st/stm32h743-disco/MAINTAINERS new file +7 -0
@@ -0,0 +1,7 @@ +STM32H743 DISCOVERY BOARD +M: Patrice Chotard <[email protected]> +S: Maintained +F: board/st/stm32h743-disco +F: include/configs/stm32h743-disco.h +F: configs/stm32h743-disco_defconfig +F: arch/arm/dts/stm32h7*
board/st/stm32h743-disco/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Copyright (C) STMicroelectronics SA 2017 +# Author(s): Patrice CHOTARD, <[email protected]> for STMicroelectronics.# +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y := stm32h743-disco.o
board/st/stm32h743-disco/stm32h743-disco.c new file +56 -0
56 lines not on this page · raw message
board/st/stm32h743-eval/Kconfig new file +19 -0
@@ -0,0 +1,19 @@ +if TARGET_STM32H743_EVAL + +config SYS_BOARD + string + default "stm32h743-eval" + +config SYS_VENDOR + string + default "st" + +config SYS_SOC + string + default "stm32h7" + +config SYS_CONFIG_NAME + string + default "stm32h743-eval" + +endif
board/st/stm32h743-eval/MAINTAINERS new file +6 -0
@@ -0,0 +1,6 @@ +STM32H743 EVALUATION BOARD +M: Patrice Chotard <[email protected]> +S: Maintained +F: board/st/stm32h743-eval +F: include/configs/stm32h743-eval.h +F: configs/stm32h743-eval_defconfig
board/st/stm32h743-eval/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# (C) Copyright 2017 +# Patrice Chotard, <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y := stm32h743-eval.o
board/st/stm32h743-eval/stm32h743-eval.c new file +56 -0
56 lines not on this page · raw message
configs/stm32h743-disco_defconfig new file +30 -0
@@ -0,0 +1,30 @@ +CONFIG_ARM=y +CONFIG_STM32=y +CONFIG_SYS_MALLOC_F_LEN=0xF00 +CONFIG_STM32H7=y +CONFIG_TARGET_STM32H743_DISCO=y +CONFIG_DEFAULT_DEVICE_TREE="stm32h743i-disco" +CONFIG_BOOTDELAY=3 +CONFIG_DEFAULT_FDT_FILE="stm32h743i-disco" +# CONFIG_DISPLAY_CPUINFO is not set +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_HUSH_PARSER=y +CONFIG_SYS_PROMPT="U-Boot > " +CONFIG_AUTOBOOT_KEYED=y +CONFIG_AUTOBOOT_PROMPT="Hit SPACE in %d seconds to stop autoboot.\n" +CONFIG_AUTOBOOT_STOP_STR=" " +CONFIG_CMD_BOOTZ=y +# CONFIG_CMD_IMLS is not set +# CONFIG_CMD_FPGA is not set +# CONFIG_CMD_SETEXPR is not set +# CONFIG_CMD_NET is not set +# CONFIG_CMD_NFS is not set +CONFIG_CMD_TIMER=y +CONFIG_OF_CONTROL=y +CONFIG_OF_EMBED=y +# CONFIG_PINCTRL_FULL is not set +# CONFIG_SPL_SERIAL_PRESENT is not set +CONFIG_REGEX=y +CONFIG_LIB_RAND=y +CONFIG_OF_LIBFDT_OVERLAY=y +# CONFIG_EFI_LOADER is not set
configs/stm32h743-eval_defconfig new file +30 -0
@@ -0,0 +1,30 @@ +CONFIG_ARM=y +CONFIG_STM32=y +CONFIG_SYS_MALLOC_F_LEN=0xF00 +CONFIG_STM32H7=y +CONFIG_TARGET_STM32H743_EVAL=y +CONFIG_DEFAULT_DEVICE_TREE="stm32h743i-eval" +CONFIG_BOOTDELAY=3 +CONFIG_DEFAULT_FDT_FILE="stm32h743i-eval" +# CONFIG_DISPLAY_CPUINFO is not set +CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_HUSH_PARSER=y +CONFIG_SYS_PROMPT="U-Boot > " +CONFIG_AUTOBOOT_KEYED=y +CONFIG_AUTOBOOT_PROMPT="Hit SPACE in %d seconds to stop autoboot.\n" +CONFIG_AUTOBOOT_STOP_STR=" " +CONFIG_CMD_BOOTZ=y +# CONFIG_CMD_IMLS is not set +# CONFIG_CMD_FPGA is not set +# CONFIG_CMD_SETEXPR is not set +# CONFIG_CMD_NET is not set +# CONFIG_CMD_NFS is not set +CONFIG_CMD_TIMER=y +CONFIG_OF_CONTROL=y +CONFIG_OF_EMBED=y +# CONFIG_PINCTRL_FULL is not set +# CONFIG_SPL_SERIAL_PRESENT is not set +CONFIG_REGEX=y +CONFIG_LIB_RAND=y +CONFIG_OF_LIBFDT_OVERLAY=y +# CONFIG_EFI_LOADER is not set
include/configs/stm32h743-disco.h new file +51 -0
51 lines not on this page · raw message
include/configs/stm32h743-eval.h new file +51 -0
51 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 9/9 board: Add stm32h7 SoC, discovery and evaluation boards support
Quoted 43 lines · On 13 September 2017 at 10:00, <[email protected]> wrote:
From: Patrice Chotard <[email protected]>
This patch adds support for stm32h7 soc family, stm32h743 discovery and evaluation boards.
For more information about STM32H7 series, please visit:
http://www.st.com/en/microcontrollers/stm32h7-series.htmlSigned-off-by Patrice Chotard <[email protected]>---
v2: _ get memory address and size from DT in board file
arch/arm/include/asm/arch-stm32h7/gpio.h | 126 +++++++++++++++++++++++++++++ arch/arm/include/asm/arch-stm32h7/stm32.h | 21 +++++ arch/arm/mach-stm32/Kconfig | 17 ++++ arch/arm/mach-stm32/Makefile | 1 + arch/arm/mach-stm32/stm32h7/Kconfig | 12 +++ arch/arm/mach-stm32/stm32h7/Makefile | 8 ++ arch/arm/mach-stm32/stm32h7/soc.c | 59 ++++++++++++++ board/st/stm32h743-disco/Kconfig | 19 +++++ board/st/stm32h743-disco/MAINTAINERS | 7 ++ board/st/stm32h743-disco/Makefile | 8 ++ board/st/stm32h743-disco/stm32h743-disco.c | 56 +++++++++++++ board/st/stm32h743-eval/Kconfig | 19 +++++ board/st/stm32h743-eval/MAINTAINERS | 6 ++ board/st/stm32h743-eval/Makefile | 8 ++ board/st/stm32h743-eval/stm32h743-eval.c | 56 +++++++++++++ configs/stm32h743-disco_defconfig | 30 +++++++ configs/stm32h743-eval_defconfig | 30 +++++++ include/configs/stm32h743-disco.h | 51 ++++++++++++ include/configs/stm32h743-eval.h | 51 ++++++++++++ 19 files changed, 585 insertions(+) create mode 100644 arch/arm/include/asm/arch-stm32h7/gpio.h create mode 100644 arch/arm/include/asm/arch-stm32h7/stm32.h create mode 100644 arch/arm/mach-stm32/stm32h7/Kconfig create mode 100644 arch/arm/mach-stm32/stm32h7/Makefile create mode 100644 arch/arm/mach-stm32/stm32h7/soc.c create mode 100644 board/st/stm32h743-disco/Kconfig create mode 100644 board/st/stm32h743-disco/MAINTAINERS create mode 100644 board/st/stm32h743-disco/Makefile create mode 100644 board/st/stm32h743-disco/stm32h743-disco.c
Quoted 8 lines
create mode 100644 board/st/stm32h743-eval/Kconfig create mode 100644 board/st/stm32h743-eval/MAINTAINERS create mode 100644 board/st/stm32h743-eval/Makefile create mode 100644 board/st/stm32h743-eval/stm32h743-eval.c create mode 100644 configs/stm32h743-disco_defconfig create mode 100644 configs/stm32h743-eval_defconfig create mode 100644 include/configs/stm32h743-disco.h create mode 100644 include/configs/stm32h743-eval.h
PATCH v2 9/9 board: Add stm32h7 SoC, discovery and evaluation boards support
In reply to patrice.chotard at st.comQuoted 10 lines · patrice.chotard at st.com
From: Patrice Chotard <[email protected]>
This patch adds support for stm32h7 soc family, stm32h743 discovery and evaluation boards.
For more information about STM32H7 series, please visit:
http://www.st.com/en/microcontrollers/stm32h7-series.htmlSigned-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170922/5a10aff8/attachment.sig>