[U-Boot] [PATCH 0/7] dm-serial: bug fix and refactoring and conversion of Uniphier serial

1/7: bug fix of console serial 2/7 - 3/7: cleanup 4/7: prepare some Kconfig entries 5/7 - 7/7: convert UniPhier serial driver and some cleanups
Simon, As I promised before, here is the conversion of driver/serial/serial_uniphier.c into driver model.
It has taken some time because I have had a hard time to find 1/7 bug.
BTW, lowlevel-debug patches were really helpful to debug driver-model serial. http://patchwork.ozlabs.org/patch/384612/ http://patchwork.ozlabs.org/patch/384615/ http://patchwork.ozlabs.org/patch/384613/ http://patchwork.ozlabs.org/patch/384611/
It is generally very difficult to test our boards in situations where UART is not working.
This series uses: http://patchwork.ozlabs.org/patch/397088/ as a prerequisite.
Masahiro Yamada (7): dm: serial: fix a bug of console putc serial: add static directive to local functions dm: serial: consolidate common code 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 | 93 +++++----- drivers/serial/serial.c | 2 - drivers/serial/serial_ns16550.c | 21 +-- drivers/serial/serial_s3c24x0.c | 10 +- drivers/serial/serial_uniphier.c | 199 ++++++++-------------- 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 ++ 24 files changed, 261 insertions(+), 219 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

Without this commit, functions such as printf(), puts() stop working after the console is ready (= after GD_FLG_DEVINIT is set in console_init_r() function).
The function serial_putc() is called to print a character before the console is available, while serial_stub_putc() is used on the console.
The cause of the problem is that the error handling of ops->putc handler is missing from serial_stub_putc(); it should behave like serial_putc().
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
drivers/serial/serial-uclass.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 6dde4ea..163308b 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -127,8 +127,13 @@ void serial_stub_putc(struct stdio_dev *sdev, const char ch) { struct udevice *dev = sdev->priv; struct dm_serial_ops *ops = serial_get_ops(dev); + int err;
- ops->putc(dev, ch); + do { + err = ops->putc(cur_dev, ch); + } while (err == -EAGAIN); + if (ch == '\n') + serial_putc('\r'); }
void serial_stub_puts(struct stdio_dev *sdev, const char *str)

Hi Masahiro,
On 22 October 2014 03:13, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
Without this commit, functions such as printf(), puts() stop working after the console is ready (= after GD_FLG_DEVINIT is set in console_init_r() function).
The function serial_putc() is called to print a character before the console is available, while serial_stub_putc() is used on the console.
The cause of the problem is that the error handling of ops->putc handler is missing from serial_stub_putc(); it should behave like serial_putc().
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com
drivers/serial/serial-uclass.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 6dde4ea..163308b 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -127,8 +127,13 @@ void serial_stub_putc(struct stdio_dev *sdev, const char ch) { struct udevice *dev = sdev->priv; struct dm_serial_ops *ops = serial_get_ops(dev);
int err;
ops->putc(dev, ch);
do {
err = ops->putc(cur_dev, ch);
} while (err == -EAGAIN);
if (ch == '\n')
serial_putc('\r');
}
void serial_stub_puts(struct stdio_dev *sdev, const char *str)
1.9.1
Sorry for the bug, but I did fix it some weeks OK. Please see this patch:
http://patchwork.ozlabs.org/patch/395725/
I recommend basing on dm/working if you are sending new patches because code there is generally on its way upstream ahead of your patch.
I will see if I can start using dm/testing more, as that is really its intended purpose.
Regards, Simon

Hi Simon,
On Wed, 22 Oct 2014 17:36:06 -0600 Simon Glass sjg@chromium.org wrote:
drivers/serial/serial-uclass.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 6dde4ea..163308b 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -127,8 +127,13 @@ void serial_stub_putc(struct stdio_dev *sdev, const char ch) { struct udevice *dev = sdev->priv; struct dm_serial_ops *ops = serial_get_ops(dev);
int err;
ops->putc(dev, ch);
do {
err = ops->putc(cur_dev, ch);
} while (err == -EAGAIN);
if (ch == '\n')
serial_putc('\r');
}
void serial_stub_puts(struct stdio_dev *sdev, const char *str)
1.9.1
Sorry for the bug, but I did fix it some weeks OK. Please see this patch:
Hmm, I checked it out, but I am afraid serial_stub_putc() is still buggy.
Please check this: http://patchwork.ozlabs.org/patch/402479/
Best Regards 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.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
drivers/serial/serial_ns16550.c | 21 +++++++-------------- drivers/serial/serial_s3c24x0.c | 10 +++++----- include/common.h | 7 ------- 3 files changed, 12 insertions(+), 26 deletions(-)
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c index 632da4c..799ef6a 100644 --- a/drivers/serial/serial_ns16550.c +++ b/drivers/serial/serial_ns16550.c @@ -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;
diff --git a/drivers/serial/serial_s3c24x0.c b/drivers/serial/serial_s3c24x0.c index c07f4c9..7afc504 100644 --- a/drivers/serial/serial_s3c24x0.c +++ b/drivers/serial/serial_s3c24x0.c @@ -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); diff --git a/include/common.h b/include/common.h index d5020c8..bcf6c7e 100644 --- a/include/common.h +++ b/include/common.h @@ -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);

On 22 October 2014 03:13, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
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.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com
Acked-by: Simon Glass sjg@chromium.org

Before the console is available, the functions serial_*() are used, while serial_stub_*() are called after the console is ready.
Functions in those two groups are almost the same except how udevice is passed; serial_*() pass "cur_dev" whereas serial_stub_*() pass sdev->priv.
This commit merges the duplicated code; common lines are put into _serlal_*().
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
drivers/serial/serial-uclass.c | 98 ++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 51 deletions(-)
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 163308b..6ee097d 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -71,52 +71,72 @@ void serial_initialize(void) serial_find_console_or_panic(); }
-void serial_putc(char ch) +static void _serial_putc(struct udevice *dev, const char ch) { - struct dm_serial_ops *ops = serial_get_ops(cur_dev); - int err; + struct dm_serial_ops *ops = serial_get_ops(dev); + int res;
do { - err = ops->putc(cur_dev, ch); - } while (err == -EAGAIN); + res = ops->putc(cur_dev, ch); + } while (res == -EAGAIN); if (ch == '\n') - serial_putc('\r'); + _serial_putc(dev, '\r'); }
-void serial_setbrg(void) +static void _serial_puts(struct udevice *dev, const char *str) { - struct dm_serial_ops *ops = serial_get_ops(cur_dev); - - if (ops->setbrg) - ops->setbrg(cur_dev, gd->baudrate); + while (*str) + _serial_putc(dev, *str++); }
-void serial_puts(const char *str) +static int _serial_getc(struct udevice *dev) { - while (*str) - serial_putc(*str++); + struct dm_serial_ops *ops = serial_get_ops(dev); + int res; + + do { + res = ops->getc(dev); + } while (res == -EAGAIN); + + return res >= 0 ? res : 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; }
+void serial_putc(char ch) +{ + _serial_putc(cur_dev, ch); +} + +void serial_puts(const char *str) +{ + _serial_puts(cur_dev, str); +} + int serial_getc(void) { - struct dm_serial_ops *ops = serial_get_ops(cur_dev); - int err; + return _serial_getc(cur_dev); +}
- do { - err = ops->getc(cur_dev); - } while (err == -EAGAIN); +int serial_tstc(void) +{ + return _serial_tstc(cur_dev); +} + +void serial_setbrg(void) +{ + struct dm_serial_ops *ops = serial_get_ops(cur_dev);
- return err >= 0 ? err : 0; + if (ops->setbrg) + ops->setbrg(cur_dev, gd->baudrate); }
void serial_stdio_init(void) @@ -125,46 +145,22 @@ void serial_stdio_init(void)
void serial_stub_putc(struct stdio_dev *sdev, const char ch) { - struct udevice *dev = sdev->priv; - struct dm_serial_ops *ops = serial_get_ops(dev); - int err; - - do { - err = ops->putc(cur_dev, ch); - } while (err == -EAGAIN); - if (ch == '\n') - serial_putc('\r'); + _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) { - struct udevice *dev = sdev->priv; - struct dm_serial_ops *ops = serial_get_ops(dev); - - int err; - - do { - err = ops->getc(dev); - } while (err == -EAGAIN); - - return err >= 0 ? err : 0; + 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)

Hi Masahiro,
On 22 October 2014 03:13, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
Before the console is available, the functions serial_*() are used, while serial_stub_*() are called after the console is ready.
Functions in those two groups are almost the same except how udevice is passed; serial_*() pass "cur_dev" whereas serial_stub_*() pass sdev->priv.
This commit merges the duplicated code; common lines are put into _serlal_*().
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com
Can you please take a look at dm/master and rebase?
Regards, Simon

Create entries of CONFIG_DM, CONFIG_DM_SERIAL, CONFIG_DM_GPIO.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
drivers/core/Kconfig | 6 ++++++ drivers/gpio/Kconfig | 6 ++++++ drivers/serial/Kconfig | 6 ++++++ 3 files changed, 18 insertions(+)
diff --git a/drivers/core/Kconfig b/drivers/core/Kconfig index e69de29..d2799dc 100644 --- a/drivers/core/Kconfig +++ b/drivers/core/Kconfig @@ -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. diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index e69de29..d21302f 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -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. diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index e69de29..6a392ba 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -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.

On 22 October 2014 03:13, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
Create entries of CONFIG_DM, CONFIG_DM_SERIAL, CONFIG_DM_GPIO.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com
Acked-by: Simon Glass sjg@chromium.org

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.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
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
diff --git a/arch/arm/cpu/armv7/uniphier/ph1-ld4/Makefile b/arch/arm/cpu/armv7/uniphier/ph1-ld4/Makefile index b385e19..781b511 100644 --- a/arch/arm/cpu/armv7/uniphier/ph1-ld4/Makefile +++ b/arch/arm/cpu/armv7/uniphier/ph1-ld4/Makefile @@ -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 diff --git a/arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c b/arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c new file mode 100644 index 0000000..0047223 --- /dev/null +++ b/arch/arm/cpu/armv7/uniphier/ph1-ld4/platdevice.c @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2014 Panasonic Corporation + * Author: Masahiro Yamada yamada.m@jp.panasonic.com + * + * 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) diff --git a/arch/arm/cpu/armv7/uniphier/ph1-pro4/Makefile b/arch/arm/cpu/armv7/uniphier/ph1-pro4/Makefile index 712afd1..e11f4f6 100644 --- a/arch/arm/cpu/armv7/uniphier/ph1-pro4/Makefile +++ b/arch/arm/cpu/armv7/uniphier/ph1-pro4/Makefile @@ -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 diff --git a/arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c b/arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c new file mode 100644 index 0000000..6da921e --- /dev/null +++ b/arch/arm/cpu/armv7/uniphier/ph1-pro4/platdevice.c @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2014 Panasonic Corporation + * Author: Masahiro Yamada yamada.m@jp.panasonic.com + * + * 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) diff --git a/arch/arm/cpu/armv7/uniphier/ph1-sld8/Makefile b/arch/arm/cpu/armv7/uniphier/ph1-sld8/Makefile index b385e19..781b511 100644 --- a/arch/arm/cpu/armv7/uniphier/ph1-sld8/Makefile +++ b/arch/arm/cpu/armv7/uniphier/ph1-sld8/Makefile @@ -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 diff --git a/arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c b/arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c new file mode 100644 index 0000000..59d054a --- /dev/null +++ b/arch/arm/cpu/armv7/uniphier/ph1-sld8/platdevice.c @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2014 Panasonic Corporation + * Author: Masahiro Yamada yamada.m@jp.panasonic.com + * + * 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) diff --git a/arch/arm/include/asm/arch-uniphier/platdevice.h b/arch/arm/include/asm/arch-uniphier/platdevice.h new file mode 100644 index 0000000..cdf7d13 --- /dev/null +++ b/arch/arm/include/asm/arch-uniphier/platdevice.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2014 Panasonic Corporation + * Author: Masahiro Yamada yamada.m@jp.panasonic.com + * + * 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 */ diff --git a/configs/ph1_ld4_defconfig b/configs/ph1_ld4_defconfig index 53f3126..c8404f8 100644 --- a/configs/ph1_ld4_defconfig +++ b/configs/ph1_ld4_defconfig @@ -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 diff --git a/configs/ph1_pro4_defconfig b/configs/ph1_pro4_defconfig index 209466e..5c051e3 100644 --- a/configs/ph1_pro4_defconfig +++ b/configs/ph1_pro4_defconfig @@ -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 diff --git a/configs/ph1_sld8_defconfig b/configs/ph1_sld8_defconfig index 658977b..2c636e6 100644 --- a/configs/ph1_sld8_defconfig +++ b/configs/ph1_sld8_defconfig @@ -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 diff --git a/drivers/serial/serial_uniphier.c b/drivers/serial/serial_uniphier.c index f8c9d92..9114b3e 100644 --- a/drivers/serial/serial_uniphier.c +++ b/drivers/serial/serial_uniphier.c @@ -2,14 +2,14 @@ * Copyright (C) 2012-2014 Panasonic Corporation * Author: Masahiro Yamada yamada.m@jp.panasonic.com * - * Based on serial_ns16550.c - * (C) Copyright 2000 - * Rob Taylor, Flying Pig Systems. robt@flyingpig.com. - * * SPDX-License-Identifier: GPL-2.0+ */
#include <common.h> +#include <asm/io.h> +#include <asm/errno.h> +#include <dm/device.h> +#include <dm/platform_data/serial-uniphier.h> #include <serial.h>
#define UART_REG(x) \ @@ -48,157 +48,104 @@ struct uniphier_serial { #define UART_LSR_DR 0x01 /* Data ready */ #define UART_LSR_THRE 0x20 /* Xmit holding register empty */
-DECLARE_GLOBAL_DATA_PTR; +struct uniphier_serial_private_data { + struct uniphier_serial __iomem *membase; +}; + +#define uniphier_serial_port(dev) \ + ((struct uniphier_serial_private_data *)dev_get_priv(dev))->membase
-static void uniphier_serial_init(struct uniphier_serial *port) +int uniphier_serial_setbrg(struct udevice *dev, int baudrate) { + struct uniphier_serial_platform_data *plat = dev_get_platdata(dev); + struct uniphier_serial __iomem *port = uniphier_serial_port(dev); const unsigned int mode_x_div = 16; unsigned int divisor;
writeb(UART_LCR_WLS_8, &port->lcr);
- divisor = DIV_ROUND_CLOSEST(CONFIG_SYS_UNIPHIER_UART_CLK, - mode_x_div * gd->baudrate); + divisor = DIV_ROUND_CLOSEST(plat->uartclk, mode_x_div * baudrate);
writew(divisor, &port->dlr); -}
-static void uniphier_serial_setbrg(struct uniphier_serial *port) -{ - uniphier_serial_init(port); + return 0; }
-static int uniphier_serial_tstc(struct uniphier_serial *port) +static int uniphier_serial_getc(struct udevice *dev) { - return (readb(&port->lsr) & UART_LSR_DR) != 0; -} + struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
-static int uniphier_serial_getc(struct uniphier_serial *port) -{ - while (!uniphier_serial_tstc(port)) - ; + if (!(readb(&port->lsr) & UART_LSR_DR)) + return -EAGAIN;
return readb(&port->rbr); }
-static void uniphier_serial_putc(struct uniphier_serial *port, const char c) +static int uniphier_serial_putc(struct udevice *dev, const char c) { - if (c == '\n') - uniphier_serial_putc(port, '\r'); + struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
- while (!(readb(&port->lsr) & UART_LSR_THRE)) - ; + if (!(readb(&port->lsr) & UART_LSR_THRE)) + return -EAGAIN;
writeb(c, &port->thr); + + return 0; }
-static struct uniphier_serial *serial_ports[4] = { -#ifdef CONFIG_SYS_UNIPHIER_SERIAL_BASE0 - (struct uniphier_serial *)CONFIG_SYS_UNIPHIER_SERIAL_BASE0, -#else - NULL, -#endif -#ifdef CONFIG_SYS_UNIPHIER_SERIAL_BASE1 - (struct uniphier_serial *)CONFIG_SYS_UNIPHIER_SERIAL_BASE1, -#else - NULL, -#endif -#ifdef CONFIG_SYS_UNIPHIER_SERIAL_BASE2 - (struct uniphier_serial *)CONFIG_SYS_UNIPHIER_SERIAL_BASE2, -#else - NULL, -#endif -#ifdef CONFIG_SYS_UNIPHIER_SERIAL_BASE3 - (struct uniphier_serial *)CONFIG_SYS_UNIPHIER_SERIAL_BASE3, -#else - NULL, -#endif -}; +int uniphier_serial_probe(struct udevice *dev) +{ + struct uniphier_serial_private_data *priv = dev_get_priv(dev); + struct uniphier_serial_platform_data *plat = dev_get_platdata(dev);
-/* Multi serial device functions */ -#define DECLARE_ESERIAL_FUNCTIONS(port) \ - static int eserial##port##_init(void) \ - { \ - uniphier_serial_init(serial_ports[port]); \ - return 0 ; \ - } \ - static void eserial##port##_setbrg(void) \ - { \ - uniphier_serial_setbrg(serial_ports[port]); \ - } \ - static int eserial##port##_getc(void) \ - { \ - return uniphier_serial_getc(serial_ports[port]); \ - } \ - static int eserial##port##_tstc(void) \ - { \ - return uniphier_serial_tstc(serial_ports[port]); \ - } \ - static void eserial##port##_putc(const char c) \ - { \ - uniphier_serial_putc(serial_ports[port], c); \ - } - -/* Serial device descriptor */ -#define INIT_ESERIAL_STRUCTURE(port, __name) { \ - .name = __name, \ - .start = eserial##port##_init, \ - .stop = NULL, \ - .setbrg = eserial##port##_setbrg, \ - .getc = eserial##port##_getc, \ - .tstc = eserial##port##_tstc, \ - .putc = eserial##port##_putc, \ - .puts = default_serial_puts, \ -} + priv->membase = map_sysmem(plat->base, sizeof(struct uniphier_serial));
-#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE0) -DECLARE_ESERIAL_FUNCTIONS(0); -struct serial_device uniphier_serial0_device = - INIT_ESERIAL_STRUCTURE(0, "ttyS0"); -#endif -#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE1) -DECLARE_ESERIAL_FUNCTIONS(1); -struct serial_device uniphier_serial1_device = - INIT_ESERIAL_STRUCTURE(1, "ttyS1"); -#endif -#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE2) -DECLARE_ESERIAL_FUNCTIONS(2); -struct serial_device uniphier_serial2_device = - INIT_ESERIAL_STRUCTURE(2, "ttyS2"); -#endif -#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE3) -DECLARE_ESERIAL_FUNCTIONS(3); -struct serial_device uniphier_serial3_device = - INIT_ESERIAL_STRUCTURE(3, "ttyS3"); -#endif + if (!priv->membase) + return -ENOMEM;
-__weak struct serial_device *default_serial_console(void) + return 0; +} + +int uniphier_serial_remove(struct udevice *dev) { -#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE0) - return &uniphier_serial0_device; -#elif defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE1) - return &uniphier_serial1_device; -#elif defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE2) - return &uniphier_serial2_device; -#elif defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE3) - return &uniphier_serial3_device; -#else -#error "No uniphier serial ports configured." -#endif + unmap_sysmem(uniphier_serial_port(dev)); + + return 0; }
-void uniphier_serial_initialize(void) +#ifdef CONFIG_OF_CONTROL +static const struct udevice_id uniphier_uart_of_match = { + { .compatible = "panasonic,uniphier-uart"}, + {}, +}; + +static int uniphier_serial_ofdata_to_platdata(struct udevice *dev) { -#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE0) - serial_register(&uniphier_serial0_device); -#endif -#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE1) - serial_register(&uniphier_serial1_device); -#endif -#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE2) - serial_register(&uniphier_serial2_device); -#endif -#if defined(CONFIG_SYS_UNIPHIER_SERIAL_BASE3) - serial_register(&uniphier_serial3_device); -#endif + /* + * TODO: Masahiro Yamada (yamada.m@jp.panasonic.com) + * + * Implement conversion code from DTB to platform data + * when supporting CONFIG_OF_CONTROL on UniPhir platform. + */ } +#endif + +static const struct dm_serial_ops uniphier_serial_ops = { + .setbrg = uniphier_serial_setbrg, + .getc = uniphier_serial_getc, + .putc = uniphier_serial_putc, +}; + +U_BOOT_DRIVER(uniphier_serial) = { + .name = DRIVER_NAME, + .id = UCLASS_SERIAL, + .of_match = of_match_ptr(uniphier_uart_of_match), + .ofdata_to_platdata = of_match_ptr(uniphier_serial_ofdata_to_platdata), + .probe = uniphier_serial_probe, + .remove = uniphier_serial_remove, + .priv_auto_alloc_size = sizeof(struct uniphier_serial_private_data), + .platdata_auto_alloc_size = + sizeof(struct uniphier_serial_platform_data), + .ops = &uniphier_serial_ops, + .flags = DM_FLAG_PRE_RELOC, +}; diff --git a/include/configs/ph1_ld4.h b/include/configs/ph1_ld4.h index a28d7b5..a546865 100644 --- a/include/configs/ph1_ld4.h +++ b/include/configs/ph1_ld4.h @@ -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 diff --git a/include/configs/ph1_pro4.h b/include/configs/ph1_pro4.h index b79967f..85c14ba 100644 --- a/include/configs/ph1_pro4.h +++ b/include/configs/ph1_pro4.h @@ -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 diff --git a/include/configs/ph1_sld8.h b/include/configs/ph1_sld8.h index 9d391f1..41e2299 100644 --- a/include/configs/ph1_sld8.h +++ b/include/configs/ph1_sld8.h @@ -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 diff --git a/include/configs/uniphier-common.h b/include/configs/uniphier-common.h index 18fe277..b18ae6d 100644 --- a/include/configs/uniphier-common.h +++ b/include/configs/uniphier-common.h @@ -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 diff --git a/include/dm/platform_data/serial-uniphier.h b/include/dm/platform_data/serial-uniphier.h new file mode 100644 index 0000000..52343e3 --- /dev/null +++ b/include/dm/platform_data/serial-uniphier.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2014 Panasonic Corporation + * Author: Masahiro Yamada yamada.m@jp.panasonic.com + * + * 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 */

HI Masahiro,
On 22 October 2014 03:14, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
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.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com
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 ++
I'm not 100% sure about that directory, but it seems reasonable.
Acked-by: Simon Glass sjg@chromium.org
Regards, Simon

Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
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(-)
diff --git a/configs/ph1_ld4_defconfig b/configs/ph1_ld4_defconfig index c8404f8..e6aba42 100644 --- a/configs/ph1_ld4_defconfig +++ b/configs/ph1_ld4_defconfig @@ -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 diff --git a/configs/ph1_pro4_defconfig b/configs/ph1_pro4_defconfig index 5c051e3..334ec4b 100644 --- a/configs/ph1_pro4_defconfig +++ b/configs/ph1_pro4_defconfig @@ -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 diff --git a/configs/ph1_sld8_defconfig b/configs/ph1_sld8_defconfig index 2c636e6..4e8f354 100644 --- a/configs/ph1_sld8_defconfig +++ b/configs/ph1_sld8_defconfig @@ -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 diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 6a392ba..a0b6e02 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -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. diff --git a/include/configs/ph1_ld4.h b/include/configs/ph1_ld4.h index a546865..005a853 100644 --- a/include/configs/ph1_ld4.h +++ b/include/configs/ph1_ld4.h @@ -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
diff --git a/include/configs/ph1_pro4.h b/include/configs/ph1_pro4.h index 85c14ba..7dd6fd2 100644 --- a/include/configs/ph1_pro4.h +++ b/include/configs/ph1_pro4.h @@ -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
diff --git a/include/configs/ph1_sld8.h b/include/configs/ph1_sld8.h index 41e2299..1062aac 100644 --- a/include/configs/ph1_sld8.h +++ b/include/configs/ph1_sld8.h @@ -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

On 22 October 2014 03:14, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com
Acked-by: Simon Glass sjg@chromium.org
See below for query:
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(-)
diff --git a/configs/ph1_ld4_defconfig b/configs/ph1_ld4_defconfig index c8404f8..e6aba42 100644 --- a/configs/ph1_ld4_defconfig +++ b/configs/ph1_ld4_defconfig @@ -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 diff --git a/configs/ph1_pro4_defconfig b/configs/ph1_pro4_defconfig index 5c051e3..334ec4b 100644 --- a/configs/ph1_pro4_defconfig +++ b/configs/ph1_pro4_defconfig @@ -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 diff --git a/configs/ph1_sld8_defconfig b/configs/ph1_sld8_defconfig index 2c636e6..4e8f354 100644 --- a/configs/ph1_sld8_defconfig +++ b/configs/ph1_sld8_defconfig @@ -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 diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 6a392ba..a0b6e02 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -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.
diff --git a/include/configs/ph1_ld4.h b/include/configs/ph1_ld4.h index a546865..005a853 100644 --- a/include/configs/ph1_ld4.h +++ b/include/configs/ph1_ld4.h @@ -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
diff --git a/include/configs/ph1_pro4.h b/include/configs/ph1_pro4.h index 85c14ba..7dd6fd2 100644 --- a/include/configs/ph1_pro4.h +++ b/include/configs/ph1_pro4.h @@ -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
diff --git a/include/configs/ph1_sld8.h b/include/configs/ph1_sld8.h index 41e2299..1062aac 100644 --- a/include/configs/ph1_sld8.h +++ b/include/configs/ph1_sld8.h @@ -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
Why not just remove this code?
Regards, Simon

Hi Simon,
On Wed, 22 Oct 2014 21:31:22 -0600 Simon Glass sjg@chromium.org wrote:
diff --git a/include/configs/ph1_sld8.h b/include/configs/ph1_sld8.h index 41e2299..1062aac 100644 --- a/include/configs/ph1_sld8.h +++ b/include/configs/ph1_sld8.h @@ -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
Why not just remove this code?
There are two types of UART ports on our boards
- On-chip UART core - Some of our boards also have a on-board 16550 UART.
For those boards, user can select a favorate UART port.
In the future, CONFIG_SYS_NS16550_SERIAL also should be moved to Kconfig to allow users to enable/disable each UART driver.
I know this code is silly. The only excuse I could find was just a reminder of TODO item for me.
Best Regards 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.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
drivers/serial/serial.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 82fbbd9..bbe60af 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -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); }

On 22 October 2014 03:14, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
The UniPhier serial driver has been converted to driver model. Let's remove uniphier_serial_initialize() call from the old serial driver framework.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com
Acked-by: Simon Glass sjg@chromium.org

HI Masahiro,
On 22 October 2014 03:13, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
1/7: bug fix of console serial 2/7 - 3/7: cleanup 4/7: prepare some Kconfig entries 5/7 - 7/7: convert UniPhier serial driver and some cleanups
Simon, As I promised before, here is the conversion of driver/serial/serial_uniphier.c into driver model.
It has taken some time because I have had a hard time to find 1/7 bug.
BTW, lowlevel-debug patches were really helpful to debug driver-model serial. http://patchwork.ozlabs.org/patch/384612/ http://patchwork.ozlabs.org/patch/384615/ http://patchwork.ozlabs.org/patch/384613/ http://patchwork.ozlabs.org/patch/384611/
Did you take a look at the idea of having standard names for the 'init' and 'putc' functions in the UART drivers? We could make that with with DM at least. This would require each driver to have a low-level 'init' function which just takes a UART address, and a 'putc' function that takes an address and a character.
Regards, Simon

Hi Simon,
On Wed, 22 Oct 2014 21:24:22 -0600 Simon Glass sjg@chromium.org wrote:
HI Masahiro,
On 22 October 2014 03:13, Masahiro Yamada yamada.m@jp.panasonic.com wrote:
1/7: bug fix of console serial 2/7 - 3/7: cleanup 4/7: prepare some Kconfig entries 5/7 - 7/7: convert UniPhier serial driver and some cleanups
Simon, As I promised before, here is the conversion of driver/serial/serial_uniphier.c into driver model.
It has taken some time because I have had a hard time to find 1/7 bug.
BTW, lowlevel-debug patches were really helpful to debug driver-model serial. http://patchwork.ozlabs.org/patch/384612/ http://patchwork.ozlabs.org/patch/384615/ http://patchwork.ozlabs.org/patch/384613/ http://patchwork.ozlabs.org/patch/384611/
Did you take a look at the idea of having standard names for the 'init' and 'putc' functions in the UART drivers? We could make that with with DM at least. This would require each driver to have a low-level 'init' function which just takes a UART address, and a 'putc' function that takes an address and a character.
Do you mean 'putc' handler should be splited up into some low-level fragments and remove 'static' directive so that we can call it directly?
Best Regards Masahiro Yamada
participants (2)
-
Masahiro Yamada
-
Simon Glass