All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model
@ 2018-03-16 16:32 Christophe Leroy
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 1/6] board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL Christophe Leroy
                   ` (6 more replies)
  0 siblings, 7 replies; 11+ messages in thread
From: Christophe Leroy @ 2018-03-16 16:32 UTC (permalink / raw)
  To: u-boot

This serie is the beginning of MPC8xx migration to DM model.

It applies on top of the serie "[v4] Powerpc: mpc8xx: cleanup before migration to DM model"

Christophe Leroy (6):
  board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL
  drivers: watchdog: add a DM driver for the MPC8xx watchdog
  board: MCR3000: use new DM watchdog
  drivers: serial: migrate mpc8xx to DM
  board: MCR3000: migrate to DM_SERIAL
  drivers: serial: get rid of non DM mpc8xx driver

Change since initial RFC:
  Migrated serial driver in addition
  Few changes on the watchdog

 arch/powerpc/dts/Makefile      | 16 ++++++++++
 arch/powerpc/dts/mcr3000.dts   | 22 ++++++++++++++
 board/cssi/MCR3000/MCR3000.c   | 16 ++++++++++
 board/cssi/MCR3000/u-boot.lds  |  6 ++++
 configs/MCR3000_defconfig      |  6 ++++
 drivers/serial/serial.c        |  2 --
 drivers/serial/serial_mpc8xx.c | 66 ++++++++++++++++++++++--------------------
 drivers/watchdog/Kconfig       |  7 +++++
 drivers/watchdog/mpc8xx_wdt.c  | 51 ++++++++++++++++++++++++++++++++
 include/configs/MCR3000.h      |  1 +
 include/serial.h               |  1 -
 11 files changed, 159 insertions(+), 35 deletions(-)
 create mode 100644 arch/powerpc/dts/Makefile
 create mode 100644 arch/powerpc/dts/mcr3000.dts

-- 
2.13.3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH RFCv2 1/6] board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL
  2018-03-16 16:32 [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe Leroy
@ 2018-03-16 16:32 ` Christophe Leroy
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 2/6] drivers: watchdog: add a DM driver for the MPC8xx watchdog Christophe Leroy
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2018-03-16 16:32 UTC (permalink / raw)
  To: u-boot

Add mcr3000 device tree and activate CONFIG_DM and CONFIG_OF_CONTROL

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/dts/Makefile     | 16 ++++++++++++++++
 arch/powerpc/dts/mcr3000.dts  | 12 ++++++++++++
 board/cssi/MCR3000/u-boot.lds |  6 ++++++
 configs/MCR3000_defconfig     |  3 +++
 4 files changed, 37 insertions(+)
 create mode 100644 arch/powerpc/dts/Makefile
 create mode 100644 arch/powerpc/dts/mcr3000.dts

diff --git a/arch/powerpc/dts/Makefile b/arch/powerpc/dts/Makefile
new file mode 100644
index 00000000000..c1c5d9c6dd3
--- /dev/null
+++ b/arch/powerpc/dts/Makefile
@@ -0,0 +1,16 @@
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+dtb-$(CONFIG_MCR3000) += mcr3000.dtb
+
+targets += $(dtb-y)
+
+# Add any required device tree compiler flags here
+DTC_FLAGS +=
+
+PHONY += dtbs
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+	@:
+
+clean-files := *.dtb
diff --git a/arch/powerpc/dts/mcr3000.dts b/arch/powerpc/dts/mcr3000.dts
new file mode 100644
index 00000000000..e4b222857b5
--- /dev/null
+++ b/arch/powerpc/dts/mcr3000.dts
@@ -0,0 +1,12 @@
+/*
+ * MCR3000 Device Tree Source
+ *
+ * Copyright 2017 CS Systemes d'Information
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+/dts-v1/;
+
+/ {
+};
diff --git a/board/cssi/MCR3000/u-boot.lds b/board/cssi/MCR3000/u-boot.lds
index 990cca4ebb6..46cbbab6c4b 100644
--- a/board/cssi/MCR3000/u-boot.lds
+++ b/board/cssi/MCR3000/u-boot.lds
@@ -70,6 +70,12 @@ SECTIONS
 	__ex_table : { *(__ex_table) }
 	__stop___ex_table = .;
 
+	/*
+	 * _end - This is end of u-boot.bin image.
+	 * dtb will be appended here to make u-boot-dtb.bin
+	 */
+	_end = .;
+
 	. = ALIGN(4096);
 	__init_begin = .;
 	.text.init : { *(.text.init) }
diff --git a/configs/MCR3000_defconfig b/configs/MCR3000_defconfig
index df8ac064877..10667ab0218 100644
--- a/configs/MCR3000_defconfig
+++ b/configs/MCR3000_defconfig
@@ -71,3 +71,6 @@ CONFIG_LZMA=y
 CONFIG_OF_LIBFDT=y
 CONFIG_USE_BOOTCOMMAND=y
 CONFIG_BOOTCOMMAND="run flashboot"
+CONFIG_DM=y
+CONFIG_OF_CONTROL=y
+CONFIG_DEFAULT_DEVICE_TREE="mcr3000"
-- 
2.13.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH RFCv2 2/6] drivers: watchdog: add a DM driver for the MPC8xx watchdog
  2018-03-16 16:32 [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe Leroy
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 1/6] board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL Christophe Leroy
@ 2018-03-16 16:32 ` Christophe Leroy
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 3/6] board: MCR3000: use new DM watchdog Christophe Leroy
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2018-03-16 16:32 UTC (permalink / raw)
  To: u-boot

This patch adds a DM driver for the MPC8xx watchdog.
Basically, the watchdog is enabled by default from the start and
SYPCR register has to be writen once to set the timeout and/or
deactivate the watchdog. Once written, it cannot be written again.

It means that wdt_stop() can be called before wdt_start() to stop the
watchdog, but cannot be called if wdt_start() has been called.

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 drivers/watchdog/Kconfig      |  7 ++++++
 drivers/watchdog/mpc8xx_wdt.c | 51 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index fc46b6774d5..21c2c2498eb 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -78,4 +78,11 @@ config WDT_ORION
 	   Select this to enable Orion watchdog timer, which can be found on some
 	   Marvell Armada chips.
 
+config WDT_MPC8xx
+	bool "MPC8xx watchdog timer support"
+	depends on WDT && MPC8xx
+	select CONFIG_MPC8xx_WATCHDOG
+	help
+	   Select this to enable mpc8xx watchdog timer
+
 endmenu
diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c
index ded80c4d6a9..29b185f45b3 100644
--- a/drivers/watchdog/mpc8xx_wdt.c
+++ b/drivers/watchdog/mpc8xx_wdt.c
@@ -5,6 +5,8 @@
  */
 
 #include <common.h>
+#include <dm.h>
+#include <wdt.h>
 #include <mpc8xx.h>
 #include <asm/cpm_8xx.h>
 #include <asm/io.h>
@@ -19,3 +21,52 @@ void hw_watchdog_reset(void)
 	out_be16(&immap->im_siu_conf.sc_swsr, 0xaa39);	/* write magic2 */
 }
 
+#ifdef CONFIG_WDT_MPC8xx
+static int mpc8xx_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
+{
+	immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
+
+	out_be32(&immap->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR);
+
+	if (!(in_be32(&immap->im_siu_conf.sc_sypcr) & SYPCR_SWE))
+		return -EBUSY;
+	return 0;
+
+}
+
+static int mpc8xx_wdt_stop(struct udevice *dev)
+{
+	immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
+
+	out_be32(&immap->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR & ~SYPCR_SWE);
+
+	if (in_be32(&immap->im_siu_conf.sc_sypcr) & SYPCR_SWE)
+		return -EBUSY;
+	return 0;
+}
+
+static int mpc8xx_wdt_reset(struct udevice *dev)
+{
+	hw_watchdog_reset();
+
+	return 0;
+}
+
+static const struct wdt_ops mpc8xx_wdt_ops = {
+	.start = mpc8xx_wdt_start,
+	.reset = mpc8xx_wdt_reset,
+	.stop = mpc8xx_wdt_stop,
+};
+
+static const struct udevice_id mpc8xx_wdt_ids[] = {
+	{ .compatible = "fsl,pq1-wdt" },
+	{}
+};
+
+U_BOOT_DRIVER(wdt_mpc8xx) = {
+	.name = "wdt_mpc8xx",
+	.id = UCLASS_WDT,
+	.of_match = mpc8xx_wdt_ids,
+	.ops = &mpc8xx_wdt_ops,
+};
+#endif /* CONFIG_WDT_MPC8xx */
-- 
2.13.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH RFCv2 3/6] board: MCR3000: use new DM watchdog
  2018-03-16 16:32 [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe Leroy
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 1/6] board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL Christophe Leroy
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 2/6] drivers: watchdog: add a DM driver for the MPC8xx watchdog Christophe Leroy
@ 2018-03-16 16:32 ` Christophe Leroy
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 4/6] drivers: serial: migrate mpc8xx to DM Christophe Leroy
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2018-03-16 16:32 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/dts/mcr3000.dts |  3 +++
 board/cssi/MCR3000/MCR3000.c | 16 ++++++++++++++++
 configs/MCR3000_defconfig    |  2 ++
 include/configs/MCR3000.h    |  1 +
 4 files changed, 22 insertions(+)

diff --git a/arch/powerpc/dts/mcr3000.dts b/arch/powerpc/dts/mcr3000.dts
index e4b222857b5..ef423d73c20 100644
--- a/arch/powerpc/dts/mcr3000.dts
+++ b/arch/powerpc/dts/mcr3000.dts
@@ -9,4 +9,7 @@
 /dts-v1/;
 
 / {
+	WDT: watchdog at 0 {
+		compatible = "fsl,pq1-wdt";
+	};
 };
diff --git a/board/cssi/MCR3000/MCR3000.c b/board/cssi/MCR3000/MCR3000.c
index 6939a2cf617..15713484680 100644
--- a/board/cssi/MCR3000/MCR3000.c
+++ b/board/cssi/MCR3000/MCR3000.c
@@ -13,6 +13,8 @@
 #include <mpc8xx.h>
 #include <fdt_support.h>
 #include <asm/io.h>
+#include <dm/uclass.h>
+#include <wdt.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -144,3 +146,17 @@ int board_early_init_f(void)
 
 	return 0;
 }
+
+int board_early_init_r(void)
+{
+	struct udevice *watchdog_dev = NULL;
+
+	if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) {
+		puts("Cannot find watchdog!\n");
+	} else {
+		puts("Enabling watchdog.\n");
+		wdt_start(watchdog_dev, 0xffff, 0);
+	}
+
+	return 0;
+}
diff --git a/configs/MCR3000_defconfig b/configs/MCR3000_defconfig
index 10667ab0218..f3dc571be22 100644
--- a/configs/MCR3000_defconfig
+++ b/configs/MCR3000_defconfig
@@ -74,3 +74,5 @@ CONFIG_BOOTCOMMAND="run flashboot"
 CONFIG_DM=y
 CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="mcr3000"
+CONFIG_WDT=y
+CONFIG_WDT_MPC8xx=y
diff --git a/include/configs/MCR3000.h b/include/configs/MCR3000.h
index aeda4742aab..a35caa661db 100644
--- a/include/configs/MCR3000.h
+++ b/include/configs/MCR3000.h
@@ -10,6 +10,7 @@
 
 /* High Level Configuration Options */
 #define CONFIG_MISC_INIT_R		1	/* Call misc_init_r	*/
+#define CONFIG_BOARD_EARLY_INIT_R	1
 
 #define CONFIG_EXTRA_ENV_SETTINGS					\
 	"sdram_type=SDRAM\0"						\
-- 
2.13.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH RFCv2 4/6] drivers: serial: migrate mpc8xx to DM
  2018-03-16 16:32 [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe Leroy
                   ` (2 preceding siblings ...)
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 3/6] board: MCR3000: use new DM watchdog Christophe Leroy
@ 2018-03-16 16:32 ` Christophe Leroy
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 5/6] board: MCR3000: migrate to DM_SERIAL Christophe Leroy
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2018-03-16 16:32 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 drivers/serial/serial_mpc8xx.c | 77 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 74 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/serial_mpc8xx.c b/drivers/serial/serial_mpc8xx.c
index 7a5908f4645..b568e14328f 100644
--- a/drivers/serial/serial_mpc8xx.c
+++ b/drivers/serial/serial_mpc8xx.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <dm.h>
 #include <serial.h>
 #include <watchdog.h>
 #include <asm/cpm_8xx.h>
@@ -36,9 +37,9 @@ struct serialbuffer {
 	uchar	txbuf;	/* tx buffers */
 };
 
-static void serial_setdivisor(cpm8xx_t __iomem *cp)
+static void serial_setdivisor(cpm8xx_t __iomem *cp, int baudrate)
 {
-	int divisor = (gd->cpu_clk + 8 * gd->baudrate) / 16 / gd->baudrate;
+	int divisor = (gd->cpu_clk + 8 * baudrate) / 16 / baudrate;
 
 	if (divisor / 16 > 0x1000) {
 		/* bad divisor, assume 50MHz clock and 9600 baud */
@@ -72,7 +73,7 @@ static void smc_setbrg(void)
 
 	out_be32(&cp->cp_simode, 0);
 
-	serial_setdivisor(cp);
+	serial_setdivisor(cp, gd->baudrate);
 }
 
 static int smc_init(void)
@@ -187,11 +188,13 @@ static void smc_putc(const char c)
 		WATCHDOG_RESET();
 }
 
+#ifndef CONFIG_DM_SERIAL
 static void smc_puts(const char *s)
 {
 	while (*s)
 		smc_putc(*s++);
 }
+#endif
 
 static int smc_getc(void)
 {
@@ -234,6 +237,7 @@ static int smc_tstc(void)
 	return !(in_be16(&rtx->rxbd.cbd_sc) & BD_SC_EMPTY);
 }
 
+#ifndef CONFIG_DM_SERIAL
 struct serial_device serial_smc_device = {
 	.name	= "serial_smc",
 	.start	= smc_init,
@@ -254,3 +258,70 @@ void mpc8xx_serial_initialize(void)
 {
 	serial_register(&serial_smc_device);
 }
+#endif
+
+#ifdef CONFIG_DM_SERIAL
+static int serial_mpc8xx_setbrg(struct udevice *dev, int baudrate)
+{
+	immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR;
+	cpm8xx_t __iomem *cp = &(im->im_cpm);
+
+	/* Set up the baud rate generator.
+	 * See 8xx_io/commproc.c for details.
+	 *
+	 * Wire BRG1 to SMCx
+	 */
+
+	out_be32(&cp->cp_simode, 0);
+
+	serial_setdivisor(cp, baudrate);
+
+	return 0;
+}
+
+static int serial_mpc8xx_probe(struct udevice *dev)
+{
+	return smc_init();
+}
+
+static int serial_mpc8xx_putc(struct udevice *dev, const char ch)
+{
+	smc_putc(ch);
+
+	return 0;
+}
+
+static int serial_mpc8xx_getc(struct udevice *dev)
+{
+	return smc_getc();
+}
+
+static int serial_mpc8xx_pending(struct udevice *dev, bool input)
+{
+	if (input)
+		return smc_tstc();
+
+	return 0;
+}
+
+static const struct dm_serial_ops serial_mpc8xx_ops = {
+	.putc = serial_mpc8xx_putc,
+	.pending = serial_mpc8xx_pending,
+	.getc = serial_mpc8xx_getc,
+	.setbrg = serial_mpc8xx_setbrg,
+};
+
+static const struct udevice_id serial_mpc8xx_ids[] = {
+	{ .compatible = "fsl,pq1-smc" },
+	{ }
+};
+
+U_BOOT_DRIVER(serial_mpc8xx) = {
+	.name	= "serial_mpc8xx",
+	.id	= UCLASS_SERIAL,
+	.of_match = serial_mpc8xx_ids,
+	.probe = serial_mpc8xx_probe,
+	.ops	= &serial_mpc8xx_ops,
+	.flags = DM_FLAG_PRE_RELOC,
+};
+#endif
-- 
2.13.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH RFCv2 5/6] board: MCR3000: migrate to DM_SERIAL
  2018-03-16 16:32 [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe Leroy
                   ` (3 preceding siblings ...)
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 4/6] drivers: serial: migrate mpc8xx to DM Christophe Leroy
@ 2018-03-16 16:32 ` Christophe Leroy
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 6/6] drivers: serial: get rid of non DM mpc8xx driver Christophe Leroy
  2018-05-04  5:20 ` [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe LEROY
  6 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2018-03-16 16:32 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/powerpc/dts/mcr3000.dts | 7 +++++++
 configs/MCR3000_defconfig    | 1 +
 2 files changed, 8 insertions(+)

diff --git a/arch/powerpc/dts/mcr3000.dts b/arch/powerpc/dts/mcr3000.dts
index ef423d73c20..5abf111dc5f 100644
--- a/arch/powerpc/dts/mcr3000.dts
+++ b/arch/powerpc/dts/mcr3000.dts
@@ -12,4 +12,11 @@
 	WDT: watchdog at 0 {
 		compatible = "fsl,pq1-wdt";
 	};
+	SERIAL: smc at 0 {
+		compatible = "fsl,pq1-smc";
+	};
+
+	chosen {
+		stdout-path = &SERIAL;
+	};
 };
diff --git a/configs/MCR3000_defconfig b/configs/MCR3000_defconfig
index f3dc571be22..402a299b3cd 100644
--- a/configs/MCR3000_defconfig
+++ b/configs/MCR3000_defconfig
@@ -76,3 +76,4 @@ CONFIG_OF_CONTROL=y
 CONFIG_DEFAULT_DEVICE_TREE="mcr3000"
 CONFIG_WDT=y
 CONFIG_WDT_MPC8xx=y
+CONFIG_DM_SERIAL=y
-- 
2.13.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH RFCv2 6/6] drivers: serial: get rid of non DM mpc8xx driver
  2018-03-16 16:32 [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe Leroy
                   ` (4 preceding siblings ...)
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 5/6] board: MCR3000: migrate to DM_SERIAL Christophe Leroy
@ 2018-03-16 16:32 ` Christophe Leroy
  2018-05-04  5:20 ` [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe LEROY
  6 siblings, 0 replies; 11+ messages in thread
From: Christophe Leroy @ 2018-03-16 16:32 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 drivers/serial/serial.c        |  2 -
 drivers/serial/serial_mpc8xx.c | 97 ++++++------------------------------------
 include/serial.h               |  1 -
 3 files changed, 14 insertions(+), 86 deletions(-)

diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index 397c6f52030..7ca61317bee 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -113,7 +113,6 @@ serial_initfunc(atmel_serial_initialize);
 serial_initfunc(au1x00_serial_initialize);
 serial_initfunc(mcf_serial_initialize);
 serial_initfunc(mpc85xx_serial_initialize);
-serial_initfunc(mpc8xx_serial_initialize);
 serial_initfunc(mxc_serial_initialize);
 serial_initfunc(ns16550_serial_initialize);
 serial_initfunc(pl01x_serial_initialize);
@@ -168,7 +167,6 @@ void serial_initialize(void)
 	au1x00_serial_initialize();
 	mcf_serial_initialize();
 	mpc85xx_serial_initialize();
-	mpc8xx_serial_initialize();
 	mxc_serial_initialize();
 	ns16550_serial_initialize();
 	pl01x_serial_initialize();
diff --git a/drivers/serial/serial_mpc8xx.c b/drivers/serial/serial_mpc8xx.c
index b568e14328f..6d3c01a0306 100644
--- a/drivers/serial/serial_mpc8xx.c
+++ b/drivers/serial/serial_mpc8xx.c
@@ -60,7 +60,7 @@ static void serial_setdivisor(cpm8xx_t __iomem *cp, int baudrate)
  * as serial console interface.
  */
 
-static void smc_setbrg(void)
+static int serial_mpc8xx_setbrg(struct udevice *dev, int baudrate)
 {
 	immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR;
 	cpm8xx_t __iomem *cp = &(im->im_cpm);
@@ -73,10 +73,12 @@ static void smc_setbrg(void)
 
 	out_be32(&cp->cp_simode, 0);
 
-	serial_setdivisor(cp, gd->baudrate);
+	serial_setdivisor(cp, baudrate);
+
+	return 0;
 }
 
-static int smc_init(void)
+static int serial_mpc8xx_probe(struct udevice *dev)
 {
 	immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR;
 	smc_t __iomem *sp;
@@ -141,7 +143,7 @@ static int smc_init(void)
 	out_8(&sp->smc_smce, 0xff);
 
 	/* Set up the baud rate generator */
-	smc_setbrg();
+	serial_mpc8xx_setbrg(dev, gd->baudrate);
 
 	/* Make the first buffer the only buffer. */
 	setbits_be16(&rtx->txbd.cbd_sc, BD_SC_WRAP);
@@ -168,14 +170,14 @@ static int smc_init(void)
 	return 0;
 }
 
-static void smc_putc(const char c)
+static int serial_mpc8xx_putc(struct udevice *dev, const char c)
 {
 	immap_t	__iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR;
 	cpm8xx_t	__iomem *cpmp = &(im->im_cpm);
 	struct serialbuffer	__iomem *rtx;
 
 	if (c == '\n')
-		smc_putc('\r');
+		serial_mpc8xx_putc(dev, '\r');
 
 	rtx = (struct serialbuffer __iomem *)&cpmp->cp_dpmem[CPM_SERIAL_BASE];
 
@@ -186,17 +188,11 @@ static void smc_putc(const char c)
 
 	while (in_be16(&rtx->txbd.cbd_sc) & BD_SC_READY)
 		WATCHDOG_RESET();
-}
 
-#ifndef CONFIG_DM_SERIAL
-static void smc_puts(const char *s)
-{
-	while (*s)
-		smc_putc(*s++);
+	return 0;
 }
-#endif
 
-static int smc_getc(void)
+static int serial_mpc8xx_getc(struct udevice *dev)
 {
 	immap_t	__iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR;
 	cpm8xx_t	__iomem *cpmp = &(im->im_cpm);
@@ -226,84 +222,20 @@ static int smc_getc(void)
 	return c;
 }
 
-static int smc_tstc(void)
+static int serial_mpc8xx_pending(struct udevice *dev, bool input)
 {
 	immap_t	__iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR;
 	cpm8xx_t	__iomem *cpmp = &(im->im_cpm);
 	struct serialbuffer	__iomem *rtx;
 
+	if (!input)
+		return 0;
+
 	rtx = (struct serialbuffer __iomem *)&cpmp->cp_dpmem[CPM_SERIAL_BASE];
 
 	return !(in_be16(&rtx->rxbd.cbd_sc) & BD_SC_EMPTY);
 }
 
-#ifndef CONFIG_DM_SERIAL
-struct serial_device serial_smc_device = {
-	.name	= "serial_smc",
-	.start	= smc_init,
-	.stop	= NULL,
-	.setbrg	= smc_setbrg,
-	.getc	= smc_getc,
-	.tstc	= smc_tstc,
-	.putc	= smc_putc,
-	.puts	= smc_puts,
-};
-
-__weak struct serial_device *default_serial_console(void)
-{
-	return &serial_smc_device;
-}
-
-void mpc8xx_serial_initialize(void)
-{
-	serial_register(&serial_smc_device);
-}
-#endif
-
-#ifdef CONFIG_DM_SERIAL
-static int serial_mpc8xx_setbrg(struct udevice *dev, int baudrate)
-{
-	immap_t __iomem *im = (immap_t __iomem *)CONFIG_SYS_IMMR;
-	cpm8xx_t __iomem *cp = &(im->im_cpm);
-
-	/* Set up the baud rate generator.
-	 * See 8xx_io/commproc.c for details.
-	 *
-	 * Wire BRG1 to SMCx
-	 */
-
-	out_be32(&cp->cp_simode, 0);
-
-	serial_setdivisor(cp, baudrate);
-
-	return 0;
-}
-
-static int serial_mpc8xx_probe(struct udevice *dev)
-{
-	return smc_init();
-}
-
-static int serial_mpc8xx_putc(struct udevice *dev, const char ch)
-{
-	smc_putc(ch);
-
-	return 0;
-}
-
-static int serial_mpc8xx_getc(struct udevice *dev)
-{
-	return smc_getc();
-}
-
-static int serial_mpc8xx_pending(struct udevice *dev, bool input)
-{
-	if (input)
-		return smc_tstc();
-
-	return 0;
-}
-
 static const struct dm_serial_ops serial_mpc8xx_ops = {
 	.putc = serial_mpc8xx_putc,
 	.pending = serial_mpc8xx_pending,
@@ -324,4 +256,3 @@ U_BOOT_DRIVER(serial_mpc8xx) = {
 	.ops	= &serial_mpc8xx_ops,
 	.flags = DM_FLAG_PRE_RELOC,
 };
-#endif
diff --git a/include/serial.h b/include/serial.h
index 384df94ed0b..06d15317026 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -169,7 +169,6 @@ void atmel_serial_initialize(void);
 void au1x00_serial_initialize(void);
 void mcf_serial_initialize(void);
 void mpc85xx_serial_initialize(void);
-void mpc8xx_serial_initialize(void);
 void mxc_serial_initialize(void);
 void ns16550_serial_initialize(void);
 void pl01x_serial_initialize(void);
-- 
2.13.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model
  2018-03-16 16:32 [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe Leroy
                   ` (5 preceding siblings ...)
  2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 6/6] drivers: serial: get rid of non DM mpc8xx driver Christophe Leroy
@ 2018-05-04  5:20 ` Christophe LEROY
  2018-05-04  9:56   ` Mario Six
  6 siblings, 1 reply; 11+ messages in thread
From: Christophe LEROY @ 2018-05-04  5:20 UTC (permalink / raw)
  To: u-boot

Hello,


Le 16/03/2018 à 17:32, Christophe Leroy a écrit :
> This serie is the beginning of MPC8xx migration to DM model.

I didn't get any feedback on this serie. I don't feel totally 
confortable as it is my first implementation of DM and also the first 
time powerpc uses DT for U-boot.

I'd rather someone look at it.

Thanks
Christophe


> 
> It applies on top of the serie "[v4] Powerpc: mpc8xx: cleanup before migration to DM model"
> 
> Christophe Leroy (6):
>    board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL
>    drivers: watchdog: add a DM driver for the MPC8xx watchdog
>    board: MCR3000: use new DM watchdog
>    drivers: serial: migrate mpc8xx to DM
>    board: MCR3000: migrate to DM_SERIAL
>    drivers: serial: get rid of non DM mpc8xx driver
> 
> Change since initial RFC:
>    Migrated serial driver in addition
>    Few changes on the watchdog
> 
>   arch/powerpc/dts/Makefile      | 16 ++++++++++
>   arch/powerpc/dts/mcr3000.dts   | 22 ++++++++++++++
>   board/cssi/MCR3000/MCR3000.c   | 16 ++++++++++
>   board/cssi/MCR3000/u-boot.lds  |  6 ++++
>   configs/MCR3000_defconfig      |  6 ++++
>   drivers/serial/serial.c        |  2 --
>   drivers/serial/serial_mpc8xx.c | 66 ++++++++++++++++++++++--------------------
>   drivers/watchdog/Kconfig       |  7 +++++
>   drivers/watchdog/mpc8xx_wdt.c  | 51 ++++++++++++++++++++++++++++++++
>   include/configs/MCR3000.h      |  1 +
>   include/serial.h               |  1 -
>   11 files changed, 159 insertions(+), 35 deletions(-)
>   create mode 100644 arch/powerpc/dts/Makefile
>   create mode 100644 arch/powerpc/dts/mcr3000.dts
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model
  2018-05-04  5:20 ` [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe LEROY
@ 2018-05-04  9:56   ` Mario Six
  2018-05-04 10:33     ` Christophe LEROY
  0 siblings, 1 reply; 11+ messages in thread
From: Mario Six @ 2018-05-04  9:56 UTC (permalink / raw)
  To: u-boot

Hi Christophe,

On Fri, May 4, 2018 at 7:20 AM, Christophe LEROY
<christophe.leroy@c-s.fr> wrote:
> Hello,
>
>
> Le 16/03/2018 à 17:32, Christophe Leroy a écrit :
>>
>> This serie is the beginning of MPC8xx migration to DM model.
>
>
> I didn't get any feedback on this serie. I don't feel totally confortable as
> it is my first implementation of DM and also the first time powerpc uses DT
> for U-boot.
>
> I'd rather someone look at it.
>

One thing I'm noticing: Are you setting up pre-relocation malloc? Since MPC8xx
is another old powerpc platform, I suspect that the start.S doesn't do it, and
DM needs it to function correctly.

Maybe you can model the case of MPC8xx similarly to the ones for MPC83xx and
MPC85xx (those are pretty similar):

dbcb2c0e2ba28 ("powerpc: mpc83xx: Enable pre-relocation malloc")
50689461205e0 ("powerpc: mpc85xx: Enable pre-relocation malloc for MPC85xx")

> Thanks
> Christophe
>

Best regards,
Mario

>
>
>>
>> It applies on top of the serie "[v4] Powerpc: mpc8xx: cleanup before
>> migration to DM model"
>>
>> Christophe Leroy (6):
>>    board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL
>>    drivers: watchdog: add a DM driver for the MPC8xx watchdog
>>    board: MCR3000: use new DM watchdog
>>    drivers: serial: migrate mpc8xx to DM
>>    board: MCR3000: migrate to DM_SERIAL
>>    drivers: serial: get rid of non DM mpc8xx driver
>>
>> Change since initial RFC:
>>    Migrated serial driver in addition
>>    Few changes on the watchdog
>>
>>   arch/powerpc/dts/Makefile      | 16 ++++++++++
>>   arch/powerpc/dts/mcr3000.dts   | 22 ++++++++++++++
>>   board/cssi/MCR3000/MCR3000.c   | 16 ++++++++++
>>   board/cssi/MCR3000/u-boot.lds  |  6 ++++
>>   configs/MCR3000_defconfig      |  6 ++++
>>   drivers/serial/serial.c        |  2 --
>>   drivers/serial/serial_mpc8xx.c | 66
>> ++++++++++++++++++++++--------------------
>>   drivers/watchdog/Kconfig       |  7 +++++
>>   drivers/watchdog/mpc8xx_wdt.c  | 51 ++++++++++++++++++++++++++++++++
>>   include/configs/MCR3000.h      |  1 +
>>   include/serial.h               |  1 -
>>   11 files changed, 159 insertions(+), 35 deletions(-)
>>   create mode 100644 arch/powerpc/dts/Makefile
>>   create mode 100644 arch/powerpc/dts/mcr3000.dts
>>
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model
  2018-05-04  9:56   ` Mario Six
@ 2018-05-04 10:33     ` Christophe LEROY
  2018-05-04 11:40       ` Joakim Tjernlund
  0 siblings, 1 reply; 11+ messages in thread
From: Christophe LEROY @ 2018-05-04 10:33 UTC (permalink / raw)
  To: u-boot

Hi Mario,

Le 04/05/2018 à 11:56, Mario Six a écrit :
> Hi Christophe,
> 
> On Fri, May 4, 2018 at 7:20 AM, Christophe LEROY
> <christophe.leroy@c-s.fr> wrote:
>> Hello,
>>
>>
>> Le 16/03/2018 à 17:32, Christophe Leroy a écrit :
>>>
>>> This serie is the beginning of MPC8xx migration to DM model.
>>
>>
>> I didn't get any feedback on this serie. I don't feel totally confortable as
>> it is my first implementation of DM and also the first time powerpc uses DT
>> for U-boot.
>>
>> I'd rather someone look at it.
>>
> 
> One thing I'm noticing: Are you setting up pre-relocation malloc? Since MPC8xx
> is another old powerpc platform, I suspect that the start.S doesn't do it, and
> DM needs it to function correctly.

Yes, I did it with the following patch:

https://patchwork.ozlabs.org/patch/886980/

Best regards
Christophe

> 
> Maybe you can model the case of MPC8xx similarly to the ones for MPC83xx and
> MPC85xx (those are pretty similar):
> 
> dbcb2c0e2ba28 ("powerpc: mpc83xx: Enable pre-relocation malloc")
> 50689461205e0 ("powerpc: mpc85xx: Enable pre-relocation malloc for MPC85xx")
> 
>> Thanks
>> Christophe
>>
> 
> Best regards,
> Mario
> 
>>
>>
>>>
>>> It applies on top of the serie "[v4] Powerpc: mpc8xx: cleanup before
>>> migration to DM model"
>>>
>>> Christophe Leroy (6):
>>>     board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL
>>>     drivers: watchdog: add a DM driver for the MPC8xx watchdog
>>>     board: MCR3000: use new DM watchdog
>>>     drivers: serial: migrate mpc8xx to DM
>>>     board: MCR3000: migrate to DM_SERIAL
>>>     drivers: serial: get rid of non DM mpc8xx driver
>>>
>>> Change since initial RFC:
>>>     Migrated serial driver in addition
>>>     Few changes on the watchdog
>>>
>>>    arch/powerpc/dts/Makefile      | 16 ++++++++++
>>>    arch/powerpc/dts/mcr3000.dts   | 22 ++++++++++++++
>>>    board/cssi/MCR3000/MCR3000.c   | 16 ++++++++++
>>>    board/cssi/MCR3000/u-boot.lds  |  6 ++++
>>>    configs/MCR3000_defconfig      |  6 ++++
>>>    drivers/serial/serial.c        |  2 --
>>>    drivers/serial/serial_mpc8xx.c | 66
>>> ++++++++++++++++++++++--------------------
>>>    drivers/watchdog/Kconfig       |  7 +++++
>>>    drivers/watchdog/mpc8xx_wdt.c  | 51 ++++++++++++++++++++++++++++++++
>>>    include/configs/MCR3000.h      |  1 +
>>>    include/serial.h               |  1 -
>>>    11 files changed, 159 insertions(+), 35 deletions(-)
>>>    create mode 100644 arch/powerpc/dts/Makefile
>>>    create mode 100644 arch/powerpc/dts/mcr3000.dts
>>>
>>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model
  2018-05-04 10:33     ` Christophe LEROY
@ 2018-05-04 11:40       ` Joakim Tjernlund
  0 siblings, 0 replies; 11+ messages in thread
From: Joakim Tjernlund @ 2018-05-04 11:40 UTC (permalink / raw)
  To: u-boot

On Fri, 2018-05-04 at 12:33 +0200, Christophe LEROY wrote:
> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> 
> 
> Hi Mario,
> 
> Le 04/05/2018 à 11:56, Mario Six a écrit :
> > Hi Christophe,
> > 
> > On Fri, May 4, 2018 at 7:20 AM, Christophe LEROY
> > <christophe.leroy@c-s.fr> wrote:
> > > Hello,
> > > 
> > > 
> > > Le 16/03/2018 à 17:32, Christophe Leroy a écrit :
> > > > 
> > > > This serie is the beginning of MPC8xx migration to DM model.
> > > 
> > > 
> > > I didn't get any feedback on this serie. I don't feel totally confortable as
> > > it is my first implementation of DM and also the first time powerpc uses DT
> > > for U-boot.
> > > 
> > > I'd rather someone look at it.
> > > 
> > 
> > One thing I'm noticing: Are you setting up pre-relocation malloc? Since MPC8xx
> > is another old powerpc platform, I suspect that the start.S doesn't do it, and
> > DM needs it to function correctly.
> 
> Yes, I did it with the following patch:
> 
> https://patchwork.ozlabs.org/patch/886980/

Hi 

Had a quick look at that patch and it looks like you lost zeroing the
stack frame (stwu	r0, -4(r1) ...) ?

Also, don't use touch r1 until the stack is ready, otherwise gdb will
try accessing the stack if you single step over this part.

 Jocke

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-05-04 11:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-16 16:32 [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe Leroy
2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 1/6] board: MCR3000: Activate CONFIG_DM and CONFIG_OF_CONTROL Christophe Leroy
2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 2/6] drivers: watchdog: add a DM driver for the MPC8xx watchdog Christophe Leroy
2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 3/6] board: MCR3000: use new DM watchdog Christophe Leroy
2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 4/6] drivers: serial: migrate mpc8xx to DM Christophe Leroy
2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 5/6] board: MCR3000: migrate to DM_SERIAL Christophe Leroy
2018-03-16 16:32 ` [U-Boot] [PATCH RFCv2 6/6] drivers: serial: get rid of non DM mpc8xx driver Christophe Leroy
2018-05-04  5:20 ` [U-Boot] [PATCH RFCv2 0/6] Beginning of migration of MPC8xx to DM model Christophe LEROY
2018-05-04  9:56   ` Mario Six
2018-05-04 10:33     ` Christophe LEROY
2018-05-04 11:40       ` Joakim Tjernlund

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.