Skip to contentSkip to conversation

dm-serial: bug fix and refactoring and conversion of Uniphier serial

PATCH New Masahiro Yamada 2 participants 22 messages Oct 23, 2014 – Oct 24, 2014

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

v2 cover dm-serial: bug fix and refactoring and conversion of Uniphier serial

1/8: cleanup
2/8: bug fix
3/8 - 4/8: cleanup
5/8: prepare some Kconfig entries
7/8 - 8/8: convert UniPhier serial driver and some cleanups

Masahiro Yamada (8):
serial: add static directive to local functions
dm: serial: fix console putc
dm: serial: remove unnecessary casting
dm: serial: consolidate common code more
dm: add entries to Kconfig
dm: serial: use Driver Model for UniPhier serial driver
serial: uniphier: move CONFIG_UNIPHIER_SERIAL to Kconfig
serial: remove uniphier_serial_initialize() call

 arch/arm/cpu/armv7/uniphier/ph1-ld4/Makefile      |   1 +
 arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c  |  15 ++
 arch/arm/cpu/armv7/uniphier/ph1-pro4/Makefile     |   1 +
 arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c |  15 ++
 arch/arm/cpu/armv7/uniphier/ph1-sld8/Makefile     |   1 +
 arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c |  15 ++
 arch/arm/include/asm/arch-uniphier/platdevice.h   |  24 +++
 configs/ph1_ld4_defconfig                         |   3 +
 configs/ph1_pro4_defconfig                        |   3 +
 configs/ph1_sld8_defconfig                        |   3 +
 drivers/core/Kconfig                              |   6 +
 drivers/gpio/Kconfig                              |   6 +
 drivers/serial/Kconfig                            |  12 ++
 drivers/serial/serial-uclass.c                    |  83 +++++----
 drivers/serial/serial.c                           |   2 -
 drivers/serial/serial_ns16550.c                   |  21 +--
 drivers/serial/serial_s3c24x0.c                   |  10 +-
 drivers/serial/serial_uniphier.c                  | 199 ++++++++--------------
 drivers/spi/Kconfig                               |   6 +
 include/common.h                                  |   7 -
 include/configs/ph1_ld4.h                         |   6 +-
 include/configs/ph1_pro4.h                        |   6 +-
 include/configs/ph1_sld8.h                        |   6 +-
 include/configs/uniphier-common.h                 |   7 +-
 include/dm/platform_data/serial-uniphier.h        |  18 ++
 25 files changed, 261 insertions(+), 215 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c
 create mode 100644 arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c
 create mode 100644 arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c
 create mode 100644 arch/arm/include/asm/arch-uniphier/platdevice.h
 create mode 100644 include/dm/platform_data/serial-uniphier.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/8 serial: add static directive to local functions

The functions _serial_putc, _serial_putc_raw, _serial_puts, _serial_getc, _serial_tstc, _serial_setbrg are defined and used locally in each of serial_ns16550.c and serial_s3c24x0.c.

Add static directive to them and remove declarations from include/common.h.

---

Changes in v2: None

 drivers/serial/serial_ns16550.c | 21 +++++++--------------
 drivers/serial/serial_s3c24x0.c | 10 +++++-----
 include/common.h                |  7 -------
 3 files changed, 12 insertions(+), 26 deletions(-)
drivers/serial/serial_ns16550.c +7 -14
index 632da4c..799ef6a 100644
@@ -119,8 +119,7 @@ static NS16550_t serial_ports[6] = {
 	.puts	= eserial##port##_puts,		\
 }
 
-void
-_serial_putc(const char c,const int port)
+static void _serial_putc(const char c, const int port)
 {
 	if (c == '\n')
 		NS16550_putc(PORT, '\r');
@@ -128,35 +127,29 @@ _serial_putc(const char c,const int port)
 	NS16550_putc(PORT, c);
 }
 
-void
-_serial_putc_raw(const char c,const int port)
+static void _serial_putc_raw(const char c, const int port)
 {
 	NS16550_putc(PORT, c);
 }
 
-void
-_serial_puts (const char *s,const int port)
+static void _serial_puts(const char *s, const int port)
 {
 	while (*s) {
-		_serial_putc (*s++,port);
+		_serial_putc(*s++, port);
 	}
 }
 
-
-int
-_serial_getc(const int port)
+static int _serial_getc(const int port)
 {
 	return NS16550_getc(PORT);
 }
 
-int
-_serial_tstc(const int port)
+static int _serial_tstc(const int port)
 {
 	return NS16550_tstc(PORT);
 }
 
-void
-_serial_setbrg (const int port)
+static void _serial_setbrg(const int port)
 {
 	int clock_divisor;
 
drivers/serial/serial_s3c24x0.c +5 -5
index c07f4c9..7afc504 100644
@@ -69,7 +69,7 @@ DECLARE_GLOBAL_DATA_PTR;
 static int hwflow;
 #endif
 
-void _serial_setbrg(const int dev_index)
+static void _serial_setbrg(const int dev_index)
 {
 	struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
 	unsigned int reg = 0;
@@ -131,7 +131,7 @@ static int serial_init_dev(const int dev_index)
  * otherwise. When the function is succesfull, the character read is
  * written into its argument c.
  */
-int _serial_getc(const int dev_index)
+static int _serial_getc(const int dev_index)
 {
 	struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
 
@@ -181,7 +181,7 @@ void enable_putc(void)
 /*
  * Output a single byte to the serial port.
  */
-void _serial_putc(const char c, const int dev_index)
+static void _serial_putc(const char c, const int dev_index)
 {
 	struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
 #ifdef CONFIG_MODEM_SUPPORT
@@ -212,7 +212,7 @@ static inline void serial_putc_dev(unsigned int dev_index, const char c)
 /*
  * Test whether a character is in the RX buffer
  */
-int _serial_tstc(const int dev_index)
+static int _serial_tstc(const int dev_index)
 {
 	struct s3c24x0_uart *uart = s3c24x0_get_base_uart(dev_index);
 
@@ -224,7 +224,7 @@ static inline int serial_tstc_dev(unsigned int dev_index)
 	return _serial_tstc(dev_index);
 }
 
-void _serial_puts(const char *s, const int dev_index)
+static void _serial_puts(const char *s, const int dev_index)
 {
 	while (*s) {
 		_serial_putc(*s++, dev_index);
include/common.h +0 -7
index d5020c8..bcf6c7e 100644
@@ -636,13 +636,6 @@ struct stdio_dev;
 int serial_stub_getc(struct stdio_dev *sdev);
 int serial_stub_tstc(struct stdio_dev *sdev);
 
-void	_serial_setbrg (const int);
-void	_serial_putc   (const char, const int);
-void	_serial_putc_raw(const char, const int);
-void	_serial_puts   (const char *, const int);
-int	_serial_getc   (const int);
-int	_serial_tstc   (const int);
-
 /* $(CPU)/speed.c */
 int	get_clocks (void);
 int	get_clocks_866 (void);
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 1/8 serial: add static directive to local functions

Quoted 9 lines · Masahiro Yamada

The functions _serial_putc, _serial_putc_raw, _serial_puts, _serial_getc, _serial_tstc, _serial_setbrg are defined and used locally in each of serial_ns16550.c and serial_s3c24x0.c.

Add static directive to them and remove declarations from include/common.h.

Quoted 8 lines

---

Changes in v2: None

 drivers/serial/serial_ns16550.c | 21 +++++++--------------
 drivers/serial/serial_s3c24x0.c | 10 +++++-----
 include/common.h                |  7 -------
 3 files changed, 12 insertions(+), 26 deletions(-)

Applied to u-boot-dm/master, thanks!

#3 lore raw

PATCH v2 2/8 dm: serial: fix console putc

In reply to Masahiro Yamada

Commit b8893327e9d2 (dm: serial: Put common code into separate functions) consolidated getc() correctly, but introduced another bug to putc(); serial_stub_putc() passes sdev->priv to serial_putc_dev(), but serial_putc_dev() uses cur_dev instead of the given argument.

---

Changes in v2:
- Newly added

 drivers/serial/serial-uclass.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/serial/serial-uclass.c +3 -3
index 1a75950..f2bc4d8 100644
@@ -73,14 +73,14 @@ void serial_initialize(void)
 
 static void serial_putc_dev(struct udevice *dev, char ch)
 {
-	struct dm_serial_ops *ops = serial_get_ops(cur_dev);
+	struct dm_serial_ops *ops = serial_get_ops(dev);
 	int err;
 
 	do {
-		err = ops->putc(cur_dev, ch);
+		err = ops->putc(dev, ch);
 	} while (err == -EAGAIN);
 	if (ch == '\n')
-		serial_putc('\r');
+		serial_putc_dev(dev, '\r');
 }
 
 void serial_putc(char ch)
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 2/8 dm: serial: fix console putc

Quoted 6 lines · Masahiro Yamada

Commit b8893327e9d2 (dm: serial: Put common code into separate functions) consolidated getc() correctly, but introduced another bug to putc(); serial_stub_putc() passes sdev->priv to serial_putc_dev(), but serial_putc_dev() uses cur_dev instead of the given argument.

#5 lore raw

PATCH v2 2/8 dm: serial: fix console putc

Quoted 9 lines · Simon Glass
Quoted 6 lines · Masahiro Yamada

Commit b8893327e9d2 (dm: serial: Put common code into separate functions) consolidated getc() correctly, but introduced another bug to putc(); serial_stub_putc() passes sdev->priv to serial_putc_dev(), but serial_putc_dev() uses cur_dev instead of the given argument.

Applied to u-boot-dm/master, thanks!

#6 lore raw

PATCH v2 3/8 dm: serial: remove unnecessary casting

In reply to Masahiro Yamada

The type (void *) can be directly passed to a function that takes a specific pointer type.

---

Changes in v2:
- Rebase

 drivers/serial/serial-uclass.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/serial/serial-uclass.c +2 -6
index f2bc4d8..5767312 100644
@@ -135,9 +135,7 @@ void serial_stdio_init(void)
 
 static void serial_stub_putc(struct stdio_dev *sdev, const char ch)
 {
-	struct udevice *dev = sdev->priv;
-
-	serial_putc_dev(dev, ch);
+	serial_putc_dev(sdev->priv, ch);
 }
 
 void serial_stub_puts(struct stdio_dev *sdev, const char *str)
@@ -148,9 +146,7 @@ void serial_stub_puts(struct stdio_dev *sdev, const char *str)
 
 int serial_stub_getc(struct stdio_dev *sdev)
 {
-	struct udevice *dev = sdev->priv;
-
-	return serial_getc_dev(dev);
+	return serial_getc_dev(sdev->priv);
 }
 
 int serial_stub_tstc(struct stdio_dev *sdev)
Signature · 1 line
1.9.1
#7 lore raw

PATCH v2 3/8 dm: serial: remove unnecessary casting

Hi Masahiro,

Quoted 17 lines · Masahiro Yamada

The type (void *) can be directly passed to a function that takes a specific pointer type.

---

Changes in v2:
- Rebase

 drivers/serial/serial-uclass.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/serial/serial-uclass.c +0 -0
index f2bc4d8..5767312 100644

drivers/serial/serial-uclass.c void serial_stdio_init(void) · line 139

Quoted 8 lines
drivers/serial/serial-uclass.c +1 -3
@@ -135,9 +135,7 @@ void serial_stdio_init(void)
 
 static void serial_stub_putc(struct stdio_dev *sdev, const char ch)
 {
-       struct udevice *dev = sdev->priv;
-
-       serial_putc_dev(dev, ch);
+       serial_putc_dev(sdev->priv, ch);
 }

There isn't really any casting going on, at least not explicitly. The purpose of the local variable is to show the type which would otherwise not be obvious from the context.

I'm OK to take this patch if you really want it, but I'm also OK with the code as it is. Let me know.

Quoted 14 lines
drivers/serial/serial-uclass.c +1 -4
 void serial_stub_puts(struct stdio_dev *sdev, const char *str)
@@ -148,9 +146,7 @@ void serial_stub_puts(struct stdio_dev *sdev, const char *str)
 
 int serial_stub_getc(struct stdio_dev *sdev)
 {
-       struct udevice *dev = sdev->priv;
-
-       return serial_getc_dev(dev);
+       return serial_getc_dev(sdev->priv);
 }
 
 int serial_stub_tstc(struct stdio_dev *sdev)
--
Quoted 2 lines

1.9.1

Regards,
Simon

#8 lore raw

PATCH v2 3/8 dm: serial: remove unnecessary casting

Hi,

Quoted 7 lines · Simon Glass

Hi Masahiro,

Quoted 4 lines · Masahiro Yamada

The type (void *) can be directly passed to a function that takes a specific pointer type.

Thinking a bit more we may as well take this, the value of the explicit type is very small.

Regards,
Simon

#9 lore raw

PATCH v2 3/8 dm: serial: remove unnecessary casting

Hi Simon,

2014-10-24 4:03 GMT+09:00 Simon Glass <[email protected]>:

Quoted 9 lines

Hi,

Quoted 6 lines · Simon Glass

Hi Masahiro,

Quoted 3 lines · Masahiro Yamada

The type (void *) can be directly passed to a function that takes a specific pointer type.

Quoted 6 lines
Quoted 1 line
Quoted 1 line

Thinking a bit more we may as well take this, the value of the explicit type is very small.

Setting aside my comments in the log, I like at least this code chage.

I admit the description was not nice as you pointed out.

If you like, you can rephrase the comments
or squash 3/8 and 4/8 into a single patch removing comments in this patch. Of course, it is OK to leave it as is.
Up to you.

Signature · 2 lines
Best Regards
Masahiro Yamada
#10 lore raw

PATCH v2 3/8 dm: serial: remove unnecessary casting

Quoted 23 lines · Masahiro YAMADA

Hi Simon,

2014-10-24 4:03 GMT+09:00 Simon Glass <[email protected]>:

Quoted 9 lines

Hi,

Quoted 6 lines · Simon Glass

Hi Masahiro,

Quoted 3 lines · Masahiro Yamada

The type (void *) can be directly passed to a function that takes a specific pointer type.

Quoted 6 lines
Quoted 1 line
Quoted 1 line

Thinking a bit more we may as well take this, the value of the explicit type is very small.

Setting aside my comments in the log, I like at least this code chage.

Quoted 7 lines

I admit the description was not nice as you pointed out.

If you like, you can rephrase the comments
or squash 3/8 and 4/8 into a single patch removing comments in this patch. Of course, it is OK to leave it as is.
Up to you.

I think it is fairly clear what is going on.

Applied to u-boot-dm/master, thanks!

#11 lore raw

PATCH v2 4/8 dm: serial: consolidate common code more

In reply to Masahiro Yamada

Commit b8893327e9d2 (dm: serial: Put common code into separate functions) consolidated getc() and putc(). This commit does more puts() and tsts().

Also rename locally used functions to _serial_*() for clarification because we have similar functions names here are there in this file.

---

Changes in v2:
- Rebase

 drivers/serial/serial-uclass.c | 75 ++++++++++++++++++++++--------------------
 1 file changed, 39 insertions(+), 36 deletions(-)
drivers/serial/serial-uclass.c +39 -36
index 5767312..8764194 100644
@@ -71,7 +71,7 @@ void serial_initialize(void)
 	serial_find_console_or_panic();
 }
 
-static void serial_putc_dev(struct udevice *dev, char ch)
+static void _serial_putc(struct udevice *dev, char ch)
 {
 	struct dm_serial_ops *ops = serial_get_ops(dev);
 	int err;
@@ -80,53 +80,63 @@ static void serial_putc_dev(struct udevice *dev, char ch)
 		err = ops->putc(dev, ch);
 	} while (err == -EAGAIN);
 	if (ch == '\n')
-		serial_putc_dev(dev, '\r');
+		_serial_putc(dev, '\r');
 }
 
-void serial_putc(char ch)
+static void _serial_puts(struct udevice *dev, const char *str)
 {
-	serial_putc_dev(cur_dev, ch);
+	while (*str)
+		_serial_putc(dev, *str++);
 }
 
-void serial_setbrg(void)
+static int _serial_getc(struct udevice *dev)
 {
-	struct dm_serial_ops *ops = serial_get_ops(cur_dev);
+	struct dm_serial_ops *ops = serial_get_ops(dev);
+	int err;
 
-	if (ops->setbrg)
-		ops->setbrg(cur_dev, gd->baudrate);
-}
+	do {
+		err = ops->getc(dev);
+	} while (err == -EAGAIN);
 
-void serial_puts(const char *str)
-{
-	while (*str)
-		serial_putc(*str++);
+	return err >= 0 ? err : 0;
 }
 
-int serial_tstc(void)
+static int _serial_tstc(struct udevice *dev)
 {
-	struct dm_serial_ops *ops = serial_get_ops(cur_dev);
+	struct dm_serial_ops *ops = serial_get_ops(dev);
 
 	if (ops->pending)
-		return ops->pending(cur_dev, true);
+		return ops->pending(dev, true);
 
 	return 1;
 }
 
-static int serial_getc_dev(struct udevice *dev)
+void serial_putc(char ch)
 {
-	struct dm_serial_ops *ops = serial_get_ops(dev);
-	int err;
-
-	do {
-		err = ops->getc(dev);
-	} while (err == -EAGAIN);
+	_serial_putc(cur_dev, ch);
+}
 
-	return err >= 0 ? err : 0;
+void serial_puts(const char *str)
+{
+	_serial_puts(cur_dev, str);
 }
 
 int serial_getc(void)
 {
-	return serial_getc_dev(cur_dev);
+	return _serial_getc(cur_dev);
+}
+
+int serial_tstc(void)
+{
+	return _serial_tstc(cur_dev);
+}
+
+void serial_setbrg(void)
+{
+	struct dm_serial_ops *ops = serial_get_ops(cur_dev);
+
+	if (ops->setbrg)
+		ops->setbrg(cur_dev, gd->baudrate);
 }
 
 void serial_stdio_init(void)
@@ -135,29 +145,22 @@ void serial_stdio_init(void)
 
 static void serial_stub_putc(struct stdio_dev *sdev, const char ch)
 {
-	serial_putc_dev(sdev->priv, ch);
+	_serial_putc(sdev->priv, ch);
 }
 
 void serial_stub_puts(struct stdio_dev *sdev, const char *str)
 {
-	while (*str)
-		serial_stub_putc(sdev, *str++);
+	_serial_puts(sdev->priv, str);
 }
 
 int serial_stub_getc(struct stdio_dev *sdev)
 {
-	return serial_getc_dev(sdev->priv);
+	return _serial_getc(sdev->priv);
 }
 
 int serial_stub_tstc(struct stdio_dev *sdev)
 {
-	struct udevice *dev = sdev->priv;
-	struct dm_serial_ops *ops = serial_get_ops(dev);
-
-	if (ops->pending)
-		return ops->pending(dev, true);
-
-	return 1;
+	return _serial_tstc(sdev->priv);
 }
 
 static int serial_post_probe(struct udevice *dev)
Signature · 1 line
1.9.1
#12 lore raw

PATCH v2 4/8 dm: serial: consolidate common code more

Quoted 7 lines · Masahiro Yamada

Commit b8893327e9d2 (dm: serial: Put common code into separate functions) consolidated getc() and putc(). This commit does more puts() and tsts().

Also rename locally used functions to _serial_*() for clarification because we have similar functions names here are there in this file.

#13 lore raw

PATCH v2 4/8 dm: serial: consolidate common code more

Quoted 10 lines · Simon Glass
Quoted 7 lines · Masahiro Yamada

Commit b8893327e9d2 (dm: serial: Put common code into separate functions) consolidated getc() and putc(). This commit does more puts() and tsts().

Also rename locally used functions to _serial_*() for clarification because we have similar functions names here are there in this file.

Applied to u-boot-dm/master, thanks!

(with merge)

#14 lore raw

PATCH v2 5/8 dm: add entries to Kconfig

In reply to Masahiro Yamada

Create entries of CONFIG_DM, CONFIG_DM_SERIAL, CONFIG_DM_GPIO and CONFIG_DM_SPI.

---

Changes in v2:
- Add CONFIG_DM_SPI

 drivers/core/Kconfig   | 6 ++++++
 drivers/gpio/Kconfig   | 6 ++++++
 drivers/serial/Kconfig | 6 ++++++
 drivers/spi/Kconfig    | 6 ++++++
 4 files changed, 24 insertions(+)
drivers/core/Kconfig +6 -0
index e69de29..d2799dc 100644
@@ -0,0 +1,6 @@
+config DM
+	bool "Enable Driver Model"
+	depends on !SPL_BUILD
+	help
+	  This config option enables Driver Model.
+	  To use legacy drivers, say N.
drivers/gpio/Kconfig +6 -0
index e69de29..d21302f 100644
@@ -0,0 +1,6 @@
+config DM_GPIO
+	bool "Enable Driver Model for GPIO drivers"
+	depends on DM
+	help
+	  If you want to use driver model for GPIO drivers, say Y.
+	  To use legacy GPIO drivers, say N.
drivers/serial/Kconfig +6 -0
index e69de29..6a392ba 100644
@@ -0,0 +1,6 @@
+config DM_SERIAL
+	bool "Enable Driver Model for serial drivers"
+	depends on DM
+	help
+	  If you want to use driver model for serial drivers, say Y.
+	  To use legacy serial drivers, say N.
drivers/spi/Kconfig +6 -0
index e69de29..e1678e6 100644
@@ -0,0 +1,6 @@
+config DM_SPI
+	bool "Enable Driver Model for SPI drivers"
+	depends on DM
+	help
+	  If you want to use driver model for SPI drivers, say Y.
+	  To use legacy SPI drivers, say N.
Signature · 1 line
1.9.1
#15 lore raw

PATCH v2 5/8 dm: add entries to Kconfig

Quoted 7 lines · Masahiro Yamada

Create entries of CONFIG_DM, CONFIG_DM_SERIAL, CONFIG_DM_GPIO and CONFIG_DM_SPI.

---

Quoted 8 lines

Changes in v2:
- Add CONFIG_DM_SPI

 drivers/core/Kconfig   | 6 ++++++
 drivers/gpio/Kconfig   | 6 ++++++
 drivers/serial/Kconfig | 6 ++++++
 drivers/spi/Kconfig    | 6 ++++++
 4 files changed, 24 insertions(+)

Applied to u-boot-dm/master, thanks!

#16 lore raw

PATCH v2 6/8 dm: serial: use Driver Model for UniPhier serial driver

In reply to Masahiro Yamada

This commit converts UniPhier on-chip serial driver to driver model.

Since UniPhier SoCs do not have Device Tree support, some board files should be added under arch/arm/cpu/armv7/uniphier/ph1-*/ directories. (Device Tree support for UniPhier platform is still under way.)

Now the base address and master clock frequency are passed from platform data, so CONFIG_SYS_UNIPHIER_SERIAL_BASE* and CONFIG_SYS_UNIPHIER_UART_CLK should be removed.

Tested on UniPhier PH1-LD4 ref board.

---

Changes in v2: None

 arch/arm/cpu/armv7/uniphier/ph1-ld4/Makefile      |   1 +
 arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c  |  15 ++
 arch/arm/cpu/armv7/uniphier/ph1-pro4/Makefile     |   1 +
 arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c |  15 ++
 arch/arm/cpu/armv7/uniphier/ph1-sld8/Makefile     |   1 +
 arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c |  15 ++
 arch/arm/include/asm/arch-uniphier/platdevice.h   |  24 +++
 configs/ph1_ld4_defconfig                         |   2 +
 configs/ph1_pro4_defconfig                        |   2 +
 configs/ph1_sld8_defconfig                        |   2 +
 drivers/serial/serial_uniphier.c                  | 199 ++++++++--------------
 include/configs/ph1_ld4.h                         |   2 -
 include/configs/ph1_pro4.h                        |   2 -
 include/configs/ph1_sld8.h                        |   2 -
 include/configs/uniphier-common.h                 |   7 +-
 include/dm/platform_data/serial-uniphier.h        |  18 ++
 16 files changed, 172 insertions(+), 136 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c
 create mode 100644 arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c
 create mode 100644 arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c
 create mode 100644 arch/arm/include/asm/arch-uniphier/platdevice.h
 create mode 100644 include/dm/platform_data/serial-uniphier.h
arch/arm/cpu/armv7/uniphier/ph1-ld4/Makefile +1 -0
index b385e19..781b511 100644
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
+obj-y += platdevice.o
 obj-y += boot-mode.o
 obj-$(CONFIG_BOARD_POSTCLK_INIT) += board_postclk_init.o bcu_init.o \
 		sbc_init.o sg_init.o pll_init.o clkrst_init.o pinctrl.o
arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c new file +15 -0
new file mode 100644
index 0000000..0047223
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <asm/arch/platdevice.h>
+
+#define UART_MASTER_CLK		36864000
+
+SERIAL_DEVICE(0, 0x54006800, UART_MASTER_CLK)
+SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK)
+SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK)
+SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK)
arch/arm/cpu/armv7/uniphier/ph1-pro4/Makefile +1 -0
index 712afd1..e11f4f6 100644
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
+obj-y += platdevice.o
 obj-y += boot-mode.o
 obj-$(CONFIG_BOARD_POSTCLK_INIT) += board_postclk_init.o sbc_init.o \
 				sg_init.o pll_init.o clkrst_init.o pinctrl.o
arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c new file +15 -0
new file mode 100644
index 0000000..6da921e
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <asm/arch/platdevice.h>
+
+#define UART_MASTER_CLK		73728000
+
+SERIAL_DEVICE(0, 0x54006800, UART_MASTER_CLK)
+SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK)
+SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK)
+SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK)
arch/arm/cpu/armv7/uniphier/ph1-sld8/Makefile +1 -0
index b385e19..781b511 100644
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
+obj-y += platdevice.o
 obj-y += boot-mode.o
 obj-$(CONFIG_BOARD_POSTCLK_INIT) += board_postclk_init.o bcu_init.o \
 		sbc_init.o sg_init.o pll_init.o clkrst_init.o pinctrl.o
arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c new file +15 -0
new file mode 100644
index 0000000..59d054a
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <asm/arch/platdevice.h>
+
+#define UART_MASTER_CLK		80000000
+
+SERIAL_DEVICE(0, 0x54006800, UART_MASTER_CLK)
+SERIAL_DEVICE(1, 0x54006900, UART_MASTER_CLK)
+SERIAL_DEVICE(2, 0x54006a00, UART_MASTER_CLK)
+SERIAL_DEVICE(3, 0x54006b00, UART_MASTER_CLK)
arch/arm/include/asm/arch-uniphier/platdevice.h new file +24 -0
new file mode 100644
index 0000000..cdf7d13
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef ARCH_PLATDEVICE_H
+#define ARCH_PLATDEVICE_H
+
+#include <dm/platdata.h>
+#include <dm/platform_data/serial-uniphier.h>
+
+#define SERIAL_DEVICE(n, ba, clk)					\
+static struct uniphier_serial_platform_data serial_device##n = {	\
+	.base = ba,							\
+	.uartclk = clk							\
+};									\
+U_BOOT_DEVICE(serial##n) = {						\
+	.name = DRIVER_NAME,						\
+	.platdata = &serial_device##n					\
+};
+
+#endif /* ARCH_PLATDEVICE_H */
configs/ph1_ld4_defconfig +2 -0
index 53f3126..c8404f8 100644
@@ -2,7 +2,9 @@ CONFIG_SPL=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_UNIPHIER=y
 +S:CONFIG_MACH_PH1_LD4=y
+CONFIG_DM=y
 CONFIG_NAND_DENALI=y
 CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
+CONFIG_DM_SERIAL=y
 S:CONFIG_SPL_NAND_DENALI=y
configs/ph1_pro4_defconfig +2 -0
index 209466e..5c051e3 100644
@@ -2,7 +2,9 @@ CONFIG_SPL=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_UNIPHIER=y
 +S:CONFIG_MACH_PH1_PRO4=y
+CONFIG_DM=y
 CONFIG_NAND_DENALI=y
 CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
+CONFIG_DM_SERIAL=y
 S:CONFIG_SPL_NAND_DENALI=y
configs/ph1_sld8_defconfig +2 -0
index 658977b..2c636e6 100644
@@ -2,7 +2,9 @@ CONFIG_SPL=y
 +S:CONFIG_ARM=y
 +S:CONFIG_ARCH_UNIPHIER=y
 +S:CONFIG_MACH_PH1_SLD8=y
+CONFIG_DM=y
 CONFIG_NAND_DENALI=y
 CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
+CONFIG_DM_SERIAL=y
 S:CONFIG_SPL_NAND_DENALI=y
drivers/serial/serial_uniphier.c +73 -126

244 lines not on this page · raw message

include/configs/ph1_ld4.h +0 -2
index a28d7b5..a546865 100644
@@ -34,8 +34,6 @@
 #define CONFIG_SYS_NS16550_SERIAL
 #endif
 
-#define CONFIG_SYS_UNIPHIER_UART_CLK    36864000
-
 #define CONFIG_SMC911X
 
 #define CONFIG_DDR_NUM_CH0 1
include/configs/ph1_pro4.h +0 -2
index b79967f..85c14ba 100644
@@ -34,8 +34,6 @@
 #define CONFIG_SYS_NS16550_SERIAL
 #endif
 
-#define CONFIG_SYS_UNIPHIER_UART_CLK    73728000
-
 #define CONFIG_SMC911X
 
 #define CONFIG_DDR_NUM_CH0 2
include/configs/ph1_sld8.h +0 -2
index 9d391f1..41e2299 100644
@@ -34,8 +34,6 @@
 #define CONFIG_SYS_NS16550_SERIAL
 #endif
 
-#define CONFIG_SYS_UNIPHIER_UART_CLK    80000000
-
 #define CONFIG_SMC911X
 
 #define CONFIG_DDR_NUM_CH0 1
include/configs/uniphier-common.h +3 -4
index 18fe277..b18ae6d 100644
@@ -33,18 +33,17 @@ are defined. Select only one of them."
 # define CONFIG_SUPPORT_CARD_UART_BASE	(CONFIG_SUPPORT_CARD_BASE + 0x00200000)
 #endif
 
+#ifdef CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550
 #define CONFIG_SYS_NS16550_COM1		CONFIG_SUPPORT_CARD_UART_BASE
 #define CONFIG_SYS_NS16550_CLK		12288000
 #define CONFIG_SYS_NS16550_REG_SIZE	-2
+#endif
 
 #define CONFIG_SMC911X_BASE		CONFIG_SUPPORT_CARD_ETHER_BASE
 #define CONFIG_SMC911X_32_BIT
 
-#define CONFIG_SYS_UNIPHIER_SERIAL_BASE0 0x54006800
-#define CONFIG_SYS_UNIPHIER_SERIAL_BASE1 0x54006900
-#define CONFIG_SYS_UNIPHIER_SERIAL_BASE2 0x54006a00
-#define CONFIG_SYS_UNIPHIER_SERIAL_BASE3 0x54006b00
+#define CONFIG_SYS_MALLOC_F_LEN  0x7000
 
 /*-----------------------------------------------------------------------
  * MMU and Cache Setting
include/dm/platform_data/serial-uniphier.h new file +18 -0
new file mode 100644
index 0000000..52343e3
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2014 Panasonic Corporation
+ *   Author: Masahiro Yamada <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __PLAT_UNIPHIER_SERIAL_H
+#define __PLAT_UNIPHIER_SERIAL_H
+
+#define DRIVER_NAME	"uniphier-uart"
+
+struct uniphier_serial_platform_data {
+	unsigned long base;
+	unsigned int uartclk;
+};
+
+#endif /* __PLAT_UNIPHIER_SERIAL_H */
Signature · 1 line
1.9.1
#17 lore raw

PATCH v2 6/8 dm: serial: use Driver Model for UniPhier serial driver

Quoted 32 lines · Masahiro Yamada

This commit converts UniPhier on-chip serial driver to driver model.

Since UniPhier SoCs do not have Device Tree support, some board files should be added under arch/arm/cpu/armv7/uniphier/ph1-*/ directories. (Device Tree support for UniPhier platform is still under way.)

Now the base address and master clock frequency are passed from platform data, so CONFIG_SYS_UNIPHIER_SERIAL_BASE* and CONFIG_SYS_UNIPHIER_UART_CLK should be removed.

Tested on UniPhier PH1-LD4 ref board.

---

Changes in v2: None

 arch/arm/cpu/armv7/uniphier/ph1-ld4/Makefile      |   1 +
 arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c  |  15 ++
 arch/arm/cpu/armv7/uniphier/ph1-pro4/Makefile     |   1 +
 arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c |  15 ++
 arch/arm/cpu/armv7/uniphier/ph1-sld8/Makefile     |   1 +
 arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c |  15 ++
 arch/arm/include/asm/arch-uniphier/platdevice.h   |  24 +++
 configs/ph1_ld4_defconfig                         |   2 +
 configs/ph1_pro4_defconfig                        |   2 +
 configs/ph1_sld8_defconfig                        |   2 +
 drivers/serial/serial_uniphier.c                  | 199 ++++++++--------------
 include/configs/ph1_ld4.h                         |   2 -
 include/configs/ph1_pro4.h                        |   2 -
 include/configs/ph1_sld8.h                        |   2 -
Quoted 8 lines
 include/configs/uniphier-common.h                 |   7 +-
 include/dm/platform_data/serial-uniphier.h        |  18 ++
 16 files changed, 172 insertions(+), 136 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c
 create mode 100644 arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c
 create mode 100644 arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c
 create mode 100644 arch/arm/include/asm/arch-uniphier/platdevice.h
 create mode 100644 include/dm/platform_data/serial-uniphier.h

Applied to u-boot-dm/master, thanks!

#18 lore raw

PATCH v2 7/8 serial: uniphier: move CONFIG_UNIPHIER_SERIAL to Kconfig

In reply to Masahiro Yamada

---

Changes in v2: None

 configs/ph1_ld4_defconfig  | 1 +
 configs/ph1_pro4_defconfig | 1 +
 configs/ph1_sld8_defconfig | 1 +
 drivers/serial/Kconfig     | 6 ++++++
 include/configs/ph1_ld4.h  | 4 +---
 include/configs/ph1_pro4.h | 4 +---
 include/configs/ph1_sld8.h | 4 +---
 7 files changed, 12 insertions(+), 9 deletions(-)
configs/ph1_ld4_defconfig +1 -0
index c8404f8..e6aba42 100644
@@ -7,4 +7,5 @@ CONFIG_NAND_DENALI=y
 CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
 CONFIG_DM_SERIAL=y
+CONFIG_UNIPHIER_SERIAL=y
 S:CONFIG_SPL_NAND_DENALI=y
configs/ph1_pro4_defconfig +1 -0
index 5c051e3..334ec4b 100644
@@ -7,4 +7,5 @@ CONFIG_NAND_DENALI=y
 CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
 CONFIG_DM_SERIAL=y
+CONFIG_UNIPHIER_SERIAL=y
 S:CONFIG_SPL_NAND_DENALI=y
configs/ph1_sld8_defconfig +1 -0
index 2c636e6..4e8f354 100644
@@ -7,4 +7,5 @@ CONFIG_NAND_DENALI=y
 CONFIG_SYS_NAND_DENALI_64BIT=y
 CONFIG_NAND_DENALI_SPARE_AREA_SKIP_BYTES=8
 CONFIG_DM_SERIAL=y
+CONFIG_UNIPHIER_SERIAL=y
 S:CONFIG_SPL_NAND_DENALI=y
drivers/serial/Kconfig +6 -0
index 6a392ba..a0b6e02 100644
@@ -4,3 +4,9 @@ config DM_SERIAL
 	help
 	  If you want to use driver model for serial drivers, say Y.
 	  To use legacy serial drivers, say N.
+
+config UNIPHIER_SERIAL
+	bool "UniPhier on-chip UART support"
+	depends on ARCH_UNIPHIER && DM_SERIAL
+	help
+	  Support for the on-chip UARTs on the Panasonic UniPhier platform.
include/configs/ph1_ld4.h +1 -3
index a546865..005a853 100644
@@ -28,9 +28,7 @@
  *   SoC UART     : enable CONFIG_UNIPHIER_SERIAL
  *   On-board UART: enable CONFIG_SYS_NS16550_SERIAL
  */
-#if 1
-#define CONFIG_UNIPHIER_SERIAL
-#else
+#if 0
 #define CONFIG_SYS_NS16550_SERIAL
 #endif
 
include/configs/ph1_pro4.h +1 -3
index 85c14ba..7dd6fd2 100644
@@ -28,9 +28,7 @@
  *   SoC UART     : enable CONFIG_UNIPHIER_SERIAL
  *   On-board UART: enable CONFIG_SYS_NS16550_SERIAL
  */
-#if 1
-#define CONFIG_UNIPHIER_SERIAL
-#else
+#if 0
 #define CONFIG_SYS_NS16550_SERIAL
 #endif
 
include/configs/ph1_sld8.h +1 -3
index 41e2299..1062aac 100644
@@ -28,9 +28,7 @@
  *   SoC UART     : enable CONFIG_UNIPHIER_SERIAL
  *   On-board UART: enable CONFIG_SYS_NS16550_SERIAL
  */
-#if 1
-#define CONFIG_UNIPHIER_SERIAL
-#else
+#if 0
 #define CONFIG_SYS_NS16550_SERIAL
 #endif
 
Signature · 1 line
1.9.1
#19 lore raw

PATCH v2 7/8 serial: uniphier: move CONFIG_UNIPHIER_SERIAL to Kconfig

Quoted 6 lines · Masahiro Yamada

---

Changes in v2: None

Quoted 8 lines
 configs/ph1_ld4_defconfig  | 1 +
 configs/ph1_pro4_defconfig | 1 +
 configs/ph1_sld8_defconfig | 1 +
 drivers/serial/Kconfig     | 6 ++++++
 include/configs/ph1_ld4.h  | 4 +---
 include/configs/ph1_pro4.h | 4 +---
 include/configs/ph1_sld8.h | 4 +---
 7 files changed, 12 insertions(+), 9 deletions(-)

Applied to u-boot-dm/master, thanks!

#20 lore raw

PATCH v2 8/8 serial: remove uniphier_serial_initialize() call

In reply to Masahiro Yamada

The UniPhier serial driver has been converted to driver model. Let's remove uniphier_serial_initialize() call from the old serial driver framework.

---

Changes in v2: None

 drivers/serial/serial.c | 2 --
 1 file changed, 2 deletions(-)
drivers/serial/serial.c +0 -2
index 82fbbd9..bbe60af 100644
@@ -157,7 +157,6 @@ serial_initfunc(sh_serial_initialize);
 serial_initfunc(arm_dcc_initialize);
 serial_initfunc(mxs_auart_initialize);
 serial_initfunc(arc_serial_initialize);
-serial_initfunc(uniphier_serial_initialize);
 
 /**
  * serial_register() - Register serial driver with serial driver core
@@ -251,7 +250,6 @@ void serial_initialize(void)
 	arm_dcc_initialize();
 	mxs_auart_initialize();
 	arc_serial_initialize();
-	uniphier_serial_initialize();
 
 	serial_assign(default_serial_console()->name);
 }
Signature · 1 line
1.9.1
#21 lore raw

PATCH v2 8/8 serial: remove uniphier_serial_initialize() call

Quoted 4 lines · Masahiro Yamada

The UniPhier serial driver has been converted to driver model. Let's remove uniphier_serial_initialize() call from the old serial driver framework.

Quoted 8 lines

---

Changes in v2: None

 drivers/serial/serial.c | 2 --
 1 file changed, 2 deletions(-)

Applied to u-boot-dm/master, thanks!