Skip to contentSkip to conversation

stm32: Convert serial driver to DM

PATCH New Kamil Lulko 3 participants 3 messages Dec 1, 2015 – Dec 14, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 stm32: Convert serial driver to DM

---
Changes for v2:
- Use -EINVAL instead of -1 retvals
- Correct stm32_serial_pending function
- Use 32-bit instead of 8-bit variable in probe function

 arch/arm/Kconfig                                   |   2 +
 arch/arm/include/asm/arch-stm32f4/stm32.h          |  10 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c |  13 +-
 doc/driver-model/serial-howto.txt                  |   1 -
 drivers/serial/serial_stm32.c                      | 203 ++++++++++-----------
 include/configs/stm32f429-discovery.h              |  10 +-
 include/dm/platform_data/serial_stm32.h            |  16 ++
 7 files changed, 136 insertions(+), 119 deletions(-)
 create mode 100644 include/dm/platform_data/serial_stm32.h
arch/arm/Kconfig +2 -0
index 408e4ff..4f54b0e 100644
@@ -692,6 +692,8 @@ config ARCH_UNIPHIER
 config TARGET_STM32F429_DISCOVERY
 	bool "Support STM32F429 Discovery"
 	select CPU_V7M
+	select DM
+	select DM_SERIAL
 
 config ARCH_ROCKCHIP
 	bool "Support Rockchip SoCs"
arch/arm/include/asm/arch-stm32f4/stm32.h +9 -1
index 7ca6dc3..6b64d03 100644
@@ -3,7 +3,7 @@
  * Yuri Tikhonov, Emcraft Systems, yur at emcraft.com
  *
  * (C) Copyright 2015
- * Kamil Lulko, <[email protected]>
+ * Kamil Lulko, <[email protected]>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -106,6 +106,14 @@ struct stm32_flash_regs {
 #define STM32_FLASH_CR_SNB_OFFSET	3
 #define STM32_FLASH_CR_SNB_MASK		(15 << STM32_FLASH_CR_SNB_OFFSET)
 
+/*
+ * Peripheral base addresses
+ */
+#define STM32_USART1_BASE	(STM32_APB2PERIPH_BASE + 0x1000)
+#define STM32_USART2_BASE	(STM32_APB1PERIPH_BASE + 0x4400)
+#define STM32_USART3_BASE	(STM32_APB1PERIPH_BASE + 0x4800)
+#define STM32_USART6_BASE	(STM32_APB2PERIPH_BASE + 0x1400)
+
 enum clock {
 	CLOCK_CORE,
 	CLOCK_AHB,
board/st/stm32f429-discovery/stm32f429-discovery.c +12 -1
index f418186..8bc2d9e 100644
@@ -6,7 +6,7 @@
  * Pavel Boldin, Emcraft Systems, paboldin at emcraft.com
  *
  * (C) Copyright 2015
- * Kamil Lulko, <[email protected]>
+ * Kamil Lulko, <[email protected]>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -17,6 +17,8 @@
 #include <asm/arch/stm32.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/fmc.h>
+#include <dm/platdata.h>
+#include <dm/platform_data/serial_stm32.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -263,6 +265,15 @@ int dram_init(void)
 	return rv;
 }
 
+static const struct stm32_serial_platdata serial_platdata = {
+	.base = (struct stm32_usart *)STM32_USART1_BASE,
+};
+
+U_BOOT_DEVICE(stm32_serials) = {
+	.name = "serial_stm32",
+	.platdata = &serial_platdata,
+};
+
 u32 get_board_rev(void)
 {
 	return 0;
doc/driver-model/serial-howto.txt +0 -1
index 60483a4..76ad629 100644
@@ -18,7 +18,6 @@ is time for maintainers to start converting over the remaining serial drivers:
    serial_pxa.c
    serial_s3c24x0.c
    serial_sa1100.c
-   serial_stm32.c
    serial_xuartlite.c
    usbtty.c
 
drivers/serial/serial_stm32.c +96 -107

261 lines not on this page · raw message

include/configs/stm32f429-discovery.h +1 -9
index 8191fb2..3e80861 100644
@@ -1,6 +1,6 @@
 /*
  * (C) Copyright 2015
- * Kamil Lulko, <[email protected]>
+ * Kamil Lulko, <[email protected]>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -51,14 +51,6 @@
 
 #define CONFIG_STM32_GPIO
 #define CONFIG_STM32_SERIAL
-/*
- * Configuration of the USART
- * 1:   TX:PA9  RX:PA10
- * 2:   TX:PD5  RX:PD6
- * 3:   TX:PC10 RX:PC11
- * 6:   TX:PG14 RX:PG9
- */
-#define CONFIG_STM32_USART		1
 
 #define CONFIG_STM32_HSE_HZ		8000000
 
include/dm/platform_data/serial_stm32.h new file +16 -0
new file mode 100644
index 0000000..d1cfcbe
@@ -0,0 +1,16 @@
+/*
+ * (C) Copyright 2015
+ * Kamil Lulko, <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __SERIAL_STM32_H
+#define __SERIAL_STM32_H
+
+/* Information about a serial port */
+struct stm32_serial_platdata {
+	struct stm32_usart *base;  /* address of registers in physical memory */
+};
+
+#endif /* __SERIAL_STM32_H */
Signature · 1 line
2.5.0
#1 lore raw

PATCH v2 1/1 stm32: Convert serial driver to DM

Quoted 8 lines · Kamil Lulko

---
Changes for v2:
- Use -EINVAL instead of -1 retvals
- Correct stm32_serial_pending function
- Use 32-bit instead of 8-bit variable in probe function

Quoted 9 lines
 arch/arm/Kconfig                                   |   2 +
 arch/arm/include/asm/arch-stm32f4/stm32.h          |  10 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c |  13 +-
 doc/driver-model/serial-howto.txt                  |   1 -
 drivers/serial/serial_stm32.c                      | 203 ++++++++++-----------
 include/configs/stm32f429-discovery.h              |  10 +-
 include/dm/platform_data/serial_stm32.h            |  16 ++
 7 files changed, 136 insertions(+), 119 deletions(-)
 create mode 100644 include/dm/platform_data/serial_stm32.h
#2 lore raw

PATCH v2 1/1 stm32: Convert serial driver to DM

In reply to Kamil Lulko
Quoted 3 lines · Kamil Lulko

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: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151214/857af3c8/attachment.sig>