Skip to contentSkip to conversation

Add support to STMicroelectronics STM32 family

PATCH Applied Maxime Coquelin 3 participants 14 messages May 22, 2015 – Jun 10, 2015

Subsystems (7)
lore
Share & tools
lore

Maxime Coquelin

author maintainer
#0 lore raw

v9 cover Add support to STMicroelectronics STM32 family

This ninth round counts less patches as some have already been applied, and the reset driver will be part of another series because it will introduce a generic reset driver to be used by several SoCs (sunxi, socfpga). Main change in remaining patches is the rework of the STM32 clocksource Kconfig entry.

STM32 MCUs are Cortex-M CPU, used in various applications (consumer electronics, industrial applications, hobbyists...). Datasheets, user and programming manuals are publicly available on STMicroelectronics website.

Changes since v8:
-----------------
- Rework clocksource driver Kconfig entry.
- Remove reset driver from the series.

Changes since v7:
-----------------
- Add DT-bindings header file for RCC IP (Daniel)
- Fix uninitialized variables in serial driver
- Enable CONFIG_NO_HZ in stm32_defconfig

Changes since v6:
-----------------
- serial: Fix locking in case of sysrq (Vladimir)
- Rebase on top of v4.1-rc1
- Apply Acked-by and Reviewed-by
- Clean-up stm32_defconfig

Changes since v5:
-----------------
- Change st,hw-flow-ctrl property to auto-flow-control (Rob)
- Constify stm32_uart_ops (Joe)
- Propagate request_irq error in USART driver (Andy)
- Applies Acked-by and Reviewed-by (Rob, Peter)

Changes since v4:
-----------------
- Cosmetic changes in USART driver (Andy)
- Apply Acks on reset driver & bindings (Philipp & Rob)

Changes since v3:
-----------------
- Fix and simplify error path in ARMv7-M Systick driver (Daniel)
- Improve reset bindings documentation (Philipp)
- Fix trailing lines anf typos in reset driver & doc (Philipp & Chanwoo)
- Fix MODULE_LICENCE in USART driver (Paul)
- Refactor USART baudrate calculation (Peter & Andy)
- Fix error path in USART init (Peter & Russell)
- Fix HW flow control in USART driver (Peter)
- Fix serial port type number to unused one (Peter)
- Applies Chanwoo's Tested-by on the series

Changes since v2:
-----------------
- Remove pinctrl driver from the series.
- Remove reset_controller_of_init(), and reset the timers in the bootloader
- Add HW flow contrl property for serial driver
- Lots of changes in the DTS file, as per Andreas recommendations
- Some Kconfig clean-ups
- Adapt the config to be compatible with Andreas' bootwrapper, except UART port.
- Various fixes in documentation

Changes since v1:
-----------------
- Move bindings documentation in their own patches (Andreas)
- Rename ARM System timer to armv7m-systick (Rob)
- Add clock-frequency property handling in armv7m-systick (Rob)
- Re-factor the reset controllers into a single controller (Philipp)
- Add kerneldoc to reset_controller_of_init (Philipp)
- Add named constants in include/dt-bindings/reset/ (Philipp)
- Make pinctrl driver to depend on ARCH_STM32 or COMPILE_TEST (Geert)
- Introduce CPUV7M_NUM_IRQ config flag to indicate the number of interrupts
supported by the MCU, in order to limit memory waste in vectors' table (Uwe)

Maxime Coquelin (5):
dt-bindings: Document the STM32 timer bindings
clockevents/drivers: Add STM32 Timer driver
dt-bindings: Document the STM32 USART bindings
serial: stm32-usart: Add STM32 USART Driver
ARM: dts: Introduce STM32F429 MCU

 .../devicetree/bindings/serial/st,stm32-usart.txt  |  32 +
 .../devicetree/bindings/timer/st,stm32-timer.txt   |  22 +
 arch/arm/boot/dts/Makefile                         |   1 +
 arch/arm/boot/dts/stm32f429-disco.dts              |  71 ++
 arch/arm/boot/dts/stm32f429.dtsi                   | 214 ++++++
 drivers/clocksource/Kconfig                        |   5 +
 drivers/clocksource/Makefile                       |   1 +
 drivers/clocksource/timer-stm32.c                  | 184 +++++
 drivers/tty/serial/Kconfig                         |  17 +
 drivers/tty/serial/Makefile                        |   1 +
 drivers/tty/serial/stm32-usart.c                   | 739 +++++++++++++++++++++
 include/uapi/linux/serial_core.h                   |   3 +
 12 files changed, 1290 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/st,stm32-usart.txt
 create mode 100644 Documentation/devicetree/bindings/timer/st,stm32-timer.txt
 create mode 100644 arch/arm/boot/dts/stm32f429-disco.dts
 create mode 100644 arch/arm/boot/dts/stm32f429.dtsi
 create mode 100644 drivers/clocksource/timer-stm32.c
 create mode 100644 drivers/tty/serial/stm32-usart.c
Signature · 1 line
1.9.1
author maintainer
#1 lore raw

PATCH v9 1/5 dt-bindings: Document the STM32 timer bindings

This adds documentation of device tree bindings for the STM32 timer.

---
 .../devicetree/bindings/timer/st,stm32-timer.txt   | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/timer/st,stm32-timer.txt
Documentation/devicetree/bindings/timer/st,stm32-timer.txt new file +22 -0
new file mode 100644
index 0000000..8ef28e7
@@ -0,0 +1,22 @@
+. STMicroelectronics STM32 timer
+
+The STM32 MCUs family has several general-purpose 16 and 32 bits timers.
+
+Required properties:
+- compatible : Should be "st,stm32-timer"
+- reg : Address and length of the register set
+- clocks : Reference on the timer input clock
+- interrupts : Reference to the timer interrupt
+
+Optional properties:
+- resets: Reference to a reset controller asserting the timer
+
+Example:
+
+timer5: timer@40000c00 {
+	compatible = "st,stm32-timer";
+	reg = <0x40000c00 0x400>;
+	interrupts = <50>;
+	resets = <&rrc 259>;
+	clocks = <&clk_pmtr1>;
+};
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v9 1/5] dt-bindings: Document the STM32 timer bindings

Quoted 6 lines · Maxime Coquelin

This adds documentation of device tree bindings for the STM32 timer.

Applied to my tree for 4.2.

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
author maintainer
#3 lore raw

PATCH v9 2/5 clockevents/drivers: Add STM32 Timer driver

In reply to Maxime Coquelin

STM32 MCUs feature 16 and 32 bits general purpose timers with prescalers. The drivers detects whether the time is 16 or 32 bits, and applies a 1024 prescaler value if it is 16 bits.

---
 drivers/clocksource/Kconfig       |   5 ++
 drivers/clocksource/Makefile      |   1 +
 drivers/clocksource/timer-stm32.c | 184 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 190 insertions(+)
 create mode 100644 drivers/clocksource/timer-stm32.c
drivers/clocksource/Kconfig +5 -0
index 51d7865f..115e980 100644
@@ -106,6 +106,11 @@ config CLKSRC_EFM32
 	  Support to use the timers of EFM32 SoCs as clock source and clock
 	  event device.
 
+config CLKSRC_STM32
+	bool "Clocksource for STM32 SoCs" if COMPILE_TEST
+	depends on OF
+	select CLKSRC_MMIO
+
 config ARM_ARCH_TIMER
 	bool
 	select CLKSRC_OF if OF
drivers/clocksource/Makefile +1 -0
index 5b85f6a..3a4c2f1 100644
@@ -36,6 +36,7 @@ obj-$(CONFIG_ARCH_NSPIRE)	+= zevio-timer.o
 obj-$(CONFIG_ARCH_BCM_MOBILE)	+= bcm_kona_timer.o
 obj-$(CONFIG_CADENCE_TTC_TIMER)	+= cadence_ttc_timer.o
 obj-$(CONFIG_CLKSRC_EFM32)	+= time-efm32.o
+obj-$(CONFIG_CLKSRC_STM32)	+= timer-stm32.o
 obj-$(CONFIG_CLKSRC_EXYNOS_MCT)	+= exynos_mct.o
 obj-$(CONFIG_CLKSRC_SAMSUNG_PWM)	+= samsung_pwm_timer.o
 obj-$(CONFIG_FSL_FTM_TIMER)	+= fsl_ftm_timer.o
drivers/clocksource/timer-stm32.c new file +184 -0

184 lines not on this page · raw message

Signature · 1 line
1.9.1
#4 lore raw

Re: [PATCH v9 2/5] clockevents/drivers: Add STM32 Timer driver

Quoted 7 lines · Maxime Coquelin

STM32 MCUs feature 16 and 32 bits general purpose timers with prescalers. The drivers detects whether the time is 16 or 32 bits, and applies a 1024 prescaler value if it is 16 bits.

Applied to my tree for 4.2

Thanks !

-- Daniel

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
author maintainer
#5 lore raw

PATCH v9 3/5 dt-bindings: Document the STM32 USART bindings

In reply to Maxime Coquelin

This adds documentation of device tree bindings for the STM32 USART

---
 .../devicetree/bindings/serial/st,stm32-usart.txt  | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serial/st,stm32-usart.txt
Documentation/devicetree/bindings/serial/st,stm32-usart.txt new file +32 -0
new file mode 100644
index 0000000..8480a76
@@ -0,0 +1,32 @@
+* STMicroelectronics STM32 USART
+
+Required properties:
+- compatible: Can be either "st,stm32-usart" or "st,stm32-uart" depending on
+whether the device supports synchronous mode.
+- reg: The address and length of the peripheral registers space
+- interrupts: The interrupt line of the USART instance
+- clocks: The input clock of the USART instance
+
+Optional properties:
+- pinctrl: The reference on the pins configuration
+- auto-flow-control: bool flag to enable hardware flow control.
+
+Examples:
+usart4: serial@40004c00 {
+	compatible = "st,stm32-uart";
+	reg = <0x40004c00 0x400>;
+	interrupts = <52>;
+	clocks = <&clk_pclk1>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_usart4>;
+};
+
+usart2: serial@40004400 {
+	compatible = "st,stm32-usart", "st,stm32-uart";
+	reg = <0x40004400 0x400>;
+	interrupts = <38>;
+	clocks = <&clk_pclk1>;
+	auto-flow-control;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_usart2 &pinctrl_usart2_rtscts>;
+};
Signature · 1 line
1.9.1
author maintainer
#6 lore raw

PATCH v9 4/5 serial: stm32-usart: Add STM32 USART Driver

In reply to Maxime Coquelin

This drivers adds support to the STM32 USART controller, which is a standard serial driver.

---
 drivers/tty/serial/Kconfig       |  17 +
 drivers/tty/serial/Makefile      |   1 +
 drivers/tty/serial/stm32-usart.c | 739 +++++++++++++++++++++++++++++++++++++++
 include/uapi/linux/serial_core.h |   3 +
 4 files changed, 760 insertions(+)
 create mode 100644 drivers/tty/serial/stm32-usart.c
drivers/tty/serial/Kconfig +17 -0
index f8120c1..7eb62f1 100644
@@ -1589,6 +1589,23 @@ config SERIAL_SPRD_CONSOLE
 	  with "earlycon" on the kernel command line. The console is
 	  enabled when early_param is processed.
 
+config SERIAL_STM32
+	tristate "STMicroelectronics STM32 serial port support"
+	select SERIAL_CORE
+	depends on ARM || COMPILE_TEST
+	help
+	  This driver is for the on-chip Serial Controller on
+	  STMicroelectronics STM32 MCUs.
+	  USART supports Rx & Tx functionality.
+	  It support all industry standard baud rates.
+
+	  If unsure, say N.
+
+config SERIAL_STM32_CONSOLE
+	bool "Support for console on STM32"
+	depends on SERIAL_STM32=y
+	select SERIAL_CORE_CONSOLE
+
 endmenu
 
 config SERIAL_MCTRL_GPIO
drivers/tty/serial/Makefile +1 -0
index c3ac3d9..61979ce 100644
@@ -93,6 +93,7 @@ obj-$(CONFIG_SERIAL_FSL_LPUART)	+= fsl_lpuart.o
 obj-$(CONFIG_SERIAL_CONEXANT_DIGICOLOR)	+= digicolor-usart.o
 obj-$(CONFIG_SERIAL_MEN_Z135)	+= men_z135_uart.o
 obj-$(CONFIG_SERIAL_SPRD) += sprd_serial.o
+obj-$(CONFIG_SERIAL_STM32)	+= stm32-usart.o
 
 # GPIOLIB helpers for modem control lines
 obj-$(CONFIG_SERIAL_MCTRL_GPIO)	+= serial_mctrl_gpio.o
drivers/tty/serial/stm32-usart.c new file +739 -0

739 lines not on this page · raw message

include/uapi/linux/serial_core.h +3 -0
index b212281..93ba148 100644
@@ -258,4 +258,7 @@
 /* Cris v10 / v32 SoC */
 #define PORT_CRIS	112
 
+/* STM32 USART */
+#define PORT_STM32	113
+
 #endif /* _UAPILINUX_SERIAL_CORE_H */
Signature · 1 line
1.9.1
maintainer Acked-by on v9 4/5
#7 lore raw

Re: [PATCH v9 4/5] serial: stm32-usart: Add STM32 USART Driver

Quoted 8 lines · Maxime Coquelin

This drivers adds support to the STM32 USART controller, which is a standard serial driver.

author maintainer
#8 lore raw

Re: [PATCH v9 4/5] serial: stm32-usart: Add STM32 USART Driver

2015-05-31 23:52 GMT+02:00 Greg Kroah-Hartman <[email protected]>:

Quoted 11 lines · Maxime Coquelin
Quoted 8 lines

This drivers adds support to the STM32 USART controller, which is a standard serial driver.

Thanks Greg.

Will you apply it to your tty tree for v4.2? Or it should go in someone else tree?

Regards,
Maxime
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

Re: [PATCH v9 4/5] serial: stm32-usart: Add STM32 USART Driver

Quoted 11 lines · Maxime Coquelin

2015-05-31 23:52 GMT+02:00 Greg Kroah-Hartman <[email protected]>:

Quoted 10 lines · Maxime Coquelin
Quoted 8 lines

This drivers adds support to the STM32 USART controller, which is a standard serial driver.

Quoted 6 lines
Quoted 1 line

Thanks Greg.

Will you apply it to your tty tree for v4.2? Or it should go in someone else tree?

It's not in my queue, I'm guessing it goes in through some other tree as there are build dependancies here preventing me from taking it.

thanks,

greg k-h

author maintainer
#10 lore raw

Re: [PATCH v9 4/5] serial: stm32-usart: Add STM32 USART Driver

2015-06-10 17:42 GMT+02:00 Greg Kroah-Hartman <[email protected]>:

Quoted 14 lines · Maxime Coquelin
Quoted 13 lines

2015-05-31 23:52 GMT+02:00 Greg Kroah-Hartman <[email protected]>:

Quoted 11 lines · Maxime Coquelin
Quoted 8 lines

This drivers adds support to the STM32 USART controller, which is a standard serial driver.

Quoted 7 lines
Quoted 4 lines

Thanks Greg.

Will you apply it to your tty tree for v4.2? Or it should go in someone else tree?

It's not in my queue, I'm guessing it goes in through some other tree as there are build dependancies here preventing me from taking it.

There should not be any build dependencies.
I just tested it on my x86 machine with COMPILE_TEST on both v4.1-rc1 and tty-next branch.
In both case it compiles without warnings.

If you still think it should go through another tree, is arm_soc's next/drivers a good candidate?

Regards,
Maxime
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw

Re: [PATCH v9 4/5] serial: stm32-usart: Add STM32 USART Driver

Quoted 20 lines · Maxime Coquelin

2015-06-10 17:42 GMT+02:00 Greg Kroah-Hartman <[email protected]>:

Quoted 19 lines · Maxime Coquelin
Quoted 17 lines

2015-05-31 23:52 GMT+02:00 Greg Kroah-Hartman <[email protected]>:

Quoted 11 lines · Maxime Coquelin
Quoted 8 lines

This drivers adds support to the STM32 USART controller, which is a standard serial driver.

Thanks Greg.

Will you apply it to your tty tree for v4.2? Or it should go in someone else tree?

Quoted 7 lines
Quoted 2 lines

It's not in my queue, I'm guessing it goes in through some other tree as there are build dependancies here preventing me from taking it.

There should not be any build dependencies.
I just tested it on my x86 machine with COMPILE_TEST on both v4.1-rc1 and tty-next branch.
In both case it compiles without warnings.

Ok, then feel free to resend it as a stand-alone patch please and I will queue it up.

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#12 lore raw

Re: [PATCH v9 4/5] serial: stm32-usart: Add STM32 USART Driver

2015-06-10 19:49 GMT+02:00 Greg Kroah-Hartman <[email protected]>:

Quoted 24 lines · Maxime Coquelin
Quoted 23 lines

2015-06-10 17:42 GMT+02:00 Greg Kroah-Hartman <[email protected]>:

Quoted 21 lines · Maxime Coquelin
Quoted 11 lines

2015-05-31 23:52 GMT+02:00 Greg Kroah-Hartman <[email protected]>:

Quoted 10 lines · Maxime Coquelin
Quoted 8 lines

This drivers adds support to the STM32 USART controller, which is a standard serial driver.

Quoted 6 lines
Quoted 1 line

Thanks Greg.

Will you apply it to your tty tree for v4.2? Or it should go in someone else tree?

It's not in my queue, I'm guessing it goes in through some other tree as there are build dependancies here preventing me from taking it.

Quoted 7 lines
Quoted 4 lines

There should not be any build dependencies.
I just tested it on my x86 machine with COMPILE_TEST on both v4.1-rc1 and tty-next branch.
In both case it compiles without warnings.

Ok, then feel free to resend it as a stand-alone patch please and I will queue it up.

Patch resent as a standalone patch.

Thanks!
Maxime

author maintainer
#13 lore raw

PATCH v9 5/5 ARM: dts: Introduce STM32F429 MCU

In reply to Maxime Coquelin

The STMicrolectornics's STM32F429 MCU has the following main features:
- Cortex-M4 core running up to @180MHz
- 2MB internal flash, 256KBytes internal RAM
- FMC controller to connect SDRAM, NOR and NAND memories
- SD/MMC/SDIO support
- Ethernet controller
- USB OTFG FS & HS controllers
- I2C, SPI, CAN busses support
- Several 16 & 32 bits general purpose timers
- Serial Audio interface
- LCD controller

---
 arch/arm/boot/dts/Makefile            |   1 +
 arch/arm/boot/dts/stm32f429-disco.dts |  71 +++++++++++
 arch/arm/boot/dts/stm32f429.dtsi      | 214 ++++++++++++++++++++++++++++++++++
 3 files changed, 286 insertions(+)
 create mode 100644 arch/arm/boot/dts/stm32f429-disco.dts
 create mode 100644 arch/arm/boot/dts/stm32f429.dtsi
arch/arm/boot/dts/Makefile +1 -0
index 86217db..db1d8c6 100644
@@ -520,6 +520,7 @@ dtb-$(CONFIG_ARCH_STI) += \
 	stih416-b2020.dtb \
 	stih416-b2020e.dtb \
 	stih418-b2199.dtb
+dtb-$(CONFIG_ARCH_STM32)+= stm32f429-disco.dtb
 dtb-$(CONFIG_MACH_SUN4I) += \
 	sun4i-a10-a1000.dtb \
 	sun4i-a10-ba10-tvbox.dtb \
arch/arm/boot/dts/stm32f429-disco.dts new file +71 -0

71 lines not on this page · raw message

arch/arm/boot/dts/stm32f429.dtsi new file +214 -0

214 lines not on this page · raw message

Signature · 1 line
1.9.1