Skip to contentSkip to conversation

RPi: Properly handle dynamic serial configuration

PATCH New Alexander Graf 4 participants 37 messages Jan 25, 2018 – Jan 31, 2018

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

v3 cover RPi: Properly handle dynamic serial configuration

The RPi has proprietary firmware that can be configured (using config.txt) to expose either the PL11, Mini-UART or no serial device to the UART pins on the GPIO pin bar of the RPi.

So far we've only half-heartedly dealt with that, with lost of heuristics that ended up falling apart at times. For example the RPi3 CM uses PL011 when serial is enabled in config.txt, but we disabled PL11 support for BCM2837 because the RPi3 uses the Mini-UART with enable_uart=1 is set in config.txt.

This patch set always enables both serial outputs and determines at probe time whether a serial device is actually muxed to the UART pins on the board. Only in that case, it will be probed and thus used for in- and output in U-Boot.

With this patch set applied, I have successfully used the same U-Boot binary with CONFIG_OF_BOARD=y and a RPi firmware provided device tree with both enable_uart=1 and without on both a RPi3 and RPi3 CM.

This patch set depends on v3 of the patch set "Rpi: Add support for second sd host controller".

v1 -> v2:

- Make search logic easier to follow

v2 -> v3:

- Use bcm2835 specific serial devices to determine pinctrl state
- New: Convert PL01* to Kconfig
- New: Convert PL01* to dev_read
- New: Convert BCM2835_MU to Kconfig
- New: Add myself as maintainer
- Use pinctrl driver to determine pinctrl state

Alexander Graf (15):
serial: Use next serial device if probing fails
rpi: Remove runtime disabling support for serial
serial: bcm283x_mu: Remove support for post-init disabling
rpi: Determine PL011/Mini-UART availability at runtime
serial_bcm283x_mu: Convert to dev_read
serial_bcm283x_mu: Always skip init
serial_bcm283x_mu: Fail loading if not muxed
pl01x: Convert to dev_read
pl010: Convert CONFIG_PL010_SERIAL to Kconfig
pl011: Convert CONFIG_PL011_SERIAL to Kconfig
pl01x: Convert CONFIG_PL01X_SERIAL to Kconfig
bcm2835_mu_serial: Convert to Kconfig
MAINTAINERS: Take over BCM2835 maintainership
bcm2835_pl011_serial: Add BCM2835 specific serial driver
bcm2835_pinctrl: Probe pre-reloc

 MAINTAINERS                                  |  5 +-
 arch/arm/Kconfig                             | 31 ++++++++++++
 arch/arm/dts/bcm283x-uboot.dtsi              |  4 ++
 board/raspberrypi/rpi/rpi.c                  | 43 ----------------
 drivers/pinctrl/broadcom/pinctrl-bcm283x.c   |  3 +-
 drivers/serial/Kconfig                       | 34 +++++++++++++
 drivers/serial/Makefile                      |  1 +
 drivers/serial/serial-uclass.c               | 25 +++++++---
 drivers/serial/serial_bcm283x_mu.c           | 61 ++++++++++++++---------
 drivers/serial/serial_bcm283x_pl011.c        | 73 ++++++++++++++++++++++++++++
 drivers/serial/serial_pl01x.c                | 19 +++-----
 drivers/serial/serial_pl01x_internal.h       | 15 +++++-
 include/configs/edb93xx.h                    |  1 -
 include/configs/highbank.h                   |  1 -
 include/configs/hikey.h                      |  3 --
 include/configs/integrator-common.h          |  2 -
 include/configs/mxs.h                        |  1 -
 include/configs/poplar.h                     |  3 --
 include/configs/qemu-arm.h                   |  3 --
 include/configs/rpi.h                        |  7 ---
 include/configs/spear-common.h               |  1 -
 include/configs/stv0991.h                    |  3 --
 include/configs/thunderx_88xx.h              |  1 -
 include/configs/vexpress_aemv8a.h            |  2 -
 include/configs/vexpress_common.h            |  1 -
 include/configs/x600.h                       |  1 -
 include/dm/platform_data/serial_bcm283x_mu.h |  1 -
 scripts/config_whitelist.txt                 |  4 --
 28 files changed, 224 insertions(+), 125 deletions(-)
 create mode 100644 drivers/serial/serial_bcm283x_pl011.c
Signature · 1 line
2.12.3
#1 lore raw

PATCH v3 1/15 serial: Use next serial device if probing fails

Currently our serial device search chokes on the fact that the serial probe function could fail. If it does, instead of searching for the next usable serial device, it just quits.

This patch changes the fallback logic so that even when a serial device was not probed correctly, we just try the next ones until we find one that works.

---

v1 -> v2:

- Make search logic easier to follow

---
 drivers/serial/serial-uclass.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)
drivers/serial/serial-uclass.c +19 -6
index 2e5116f7ce..68ca2d09d1 100644
@@ -74,6 +74,7 @@ static void serial_find_console_or_panic(void)
 {
 	const void *blob = gd->fdt_blob;
 	struct udevice *dev;
+	int ret;
 
 	if (CONFIG_IS_ENABLED(OF_PLATDATA)) {
 		uclass_first_device(UCLASS_SERIAL, &dev);
@@ -104,8 +105,8 @@ static void serial_find_console_or_panic(void)
 		 * from 1!).
 		 *
 		 * Failing that, get the device with sequence number 0, or in
-		 * extremis just the first serial device we can find. But we
-		 * insist on having a console (even if it is silent).
+		 * extremis just the first working serial device we can find.
+		 * But we insist on having a console (even if it is silent).
 		 */
 #ifdef CONFIG_CONS_INDEX
 #define INDEX (CONFIG_CONS_INDEX - 1)
@@ -113,10 +114,22 @@ static void serial_find_console_or_panic(void)
 #define INDEX 0
 #endif
 		if (!uclass_get_device_by_seq(UCLASS_SERIAL, INDEX, &dev) ||
-		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev) ||
-		    (!uclass_first_device(UCLASS_SERIAL, &dev) && dev)) {
-			gd->cur_serial_dev = dev;
-			return;
+		    !uclass_get_device(UCLASS_SERIAL, INDEX, &dev)) {
+			if (dev->flags & DM_FLAG_ACTIVATED) {
+				gd->cur_serial_dev = dev;
+				return;
+			}
+		}
+
+		/* Search for any working device */
+		for (ret = uclass_first_device_check(UCLASS_SERIAL, &dev);
+		     dev;
+		     ret = uclass_next_device_check(&dev)) {
+			if (!ret) {
+				/* Device did succeed probing */
+				gd->cur_serial_dev = dev;
+				return;
+			}
 		}
 #undef INDEX
 	}
Signature · 1 line
2.12.3
#2 lore raw

PATCH v3 1/15 serial: Use next serial device if probing fails

Quoted 10 lines · Alexander Graf

Currently our serial device search chokes on the fact that the serial probe function could fail. If it does, instead of searching for the next usable serial device, it just quits.

This patch changes the fallback logic so that even when a serial device was not probed correctly, we just try the next ones until we find one that works.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/ce3c67fe/attachment.sig>
#3 lore raw

PATCH v3 1/15 serial: Use next serial device if probing fails

Quoted 6 lines · Tom Rini
Quoted 4 lines · Alexander Graf

Currently our serial device search chokes on the fact that the serial probe function could fail. If it does, instead of searching for the next usable serial device, it just quits.

Quoted 11 lines
Quoted 6 lines

This patch changes the fallback logic so that even when a serial device was not probed correctly, we just try the next ones until we find one that works.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom

Is there something, at the board level, that needs to be coded to support this patch? The omap3_evm fails to boot with this patch applied. Reverting it allows omap3_evm to boot again. I am testing with the base default config for omap3_evm.

Derald

#4 lore raw

PATCH v3 1/15 serial: Use next serial device if probing fails

Quoted 16 lines · Derald D. Woods
Quoted 15 lines · Tom Rini
Quoted 10 lines · Alexander Graf

Currently our serial device search chokes on the fact that the serial probe function could fail. If it does, instead of searching for the next usable serial device, it just quits.

This patch changes the fallback logic so that even when a serial device was not probed correctly, we just try the next ones until we find one that works.

Applied to u-boot/master, thanks!

Quoted 7 lines
Quoted 2 lines
Signature · 1 line
Tom

Is there something, at the board level, that needs to be coded to support this patch? The omap3_evm fails to boot with this patch applied. Reverting it allows omap3_evm to boot again. I am testing with the base default config for omap3_evm.

No, this should really be a nop for everyone who does not fail probe() in serial devices. I'll see if I can figure out what's causing the issue in the next hours.

If I don't get down to the root cause by tonight, I'll send a small patch that simply conditionalizes the new/old code based on a config variable and turn it on only for the Rpis, so we have a working -rc1.

Alex

#5 lore raw

PATCH v3 1/15 serial: Use next serial device if probing fails

In reply to Derald D. Woods
Quoted 16 lines · Derald D. Woods
Quoted 15 lines · Tom Rini
Quoted 10 lines · Alexander Graf

Currently our serial device search chokes on the fact that the serial probe function could fail. If it does, instead of searching for the next usable serial device, it just quits.

This patch changes the fallback logic so that even when a serial device was not probed correctly, we just try the next ones until we find one that works.

Applied to u-boot/master, thanks!

Quoted 7 lines
Quoted 2 lines
Signature · 1 line
Tom

Is there something, at the board level, that needs to be coded to support this patch? The omap3_evm fails to boot with this patch applied. Reverting it allows omap3_evm to boot again. I am testing with the base default config for omap3_evm.

I've tried to reproduce the failure on a beagleboard xM, but was unable to see it fail. Even with the beagleboard configured basically using the same mechanisms (SPL_DM, manually defining CONFIG_SYS_NS16550_COM1, etc) I don't see it fail with CONFIG_SERIAL_SEARCH_ALL=y.

Unfortunately I don't have an omap3 evm to test it on directly :(.

Can you maybe share a bit more of the failure details? What exactly fails? When does it fail? I assume you're not seeing serial output? Does it boot nevertheless, albeit without serial output?

Alex

#6 lore raw

PATCH v3 2/15 rpi: Remove runtime disabling support for serial

In reply to Alexander Graf

We are switching to a model where our board file can directly fail probing of serial devices when they're not usable, so remove the current runtime hack we have.

---
 board/raspberrypi/rpi/rpi.c | 43 -------------------------------------------
 1 file changed, 43 deletions(-)
board/raspberrypi/rpi/rpi.c +0 -43
index c8924d4362..177f4af265 100644
@@ -420,54 +420,11 @@ static void get_board_rev(void)
 	printf("RPI %s (0x%x)\n", model->name, revision);
 }
 
-#ifndef CONFIG_PL01X_SERIAL
-static bool rpi_is_serial_active(void)
-{
-	int serial_gpio = 15;
-	struct udevice *dev;
-
-	/*
-	 * The RPi3 disables the mini uart by default. The easiest way to find
-	 * out whether it is available is to check if the RX pin is muxed.
-	 */
-
-	if (uclass_first_device(UCLASS_PINCTRL, &dev) || !dev)
-		return true;
-
-	if (pinctrl_get_gpio_mux(dev, 0, serial_gpio) != BCM2835_GPIO_ALT5)
-		return false;
-
-	return true;
-}
-
-/* Disable mini-UART I/O if it's not pinmuxed to our pins.
- * The firmware only enables it if explicitly done in config.txt: enable_uart=1
- */
-static void rpi_disable_inactive_uart(void)
-{
-	struct udevice *dev;
-	struct bcm283x_mu_serial_platdata *plat;
-
-	if (uclass_get_device_by_driver(UCLASS_SERIAL,
-					DM_GET_DRIVER(serial_bcm283x_mu),
-					&dev) || !dev)
-		return;
-
-	if (!rpi_is_serial_active()) {
-		plat = dev_get_platdata(dev);
-		plat->disabled = true;
-	}
-}
-#endif
-
 int board_init(void)
 {
 #ifdef CONFIG_HW_WATCHDOG
 	hw_watchdog_init();
 #endif
-#ifndef CONFIG_PL01X_SERIAL
-	rpi_disable_inactive_uart();
-#endif
 
 	get_board_rev();
 
Signature · 1 line
2.12.3
#7 lore raw

PATCH v3 2/15 rpi: Remove runtime disabling support for serial

Quoted 5 lines · Alexander Graf

We are switching to a model where our board file can directly fail probing of serial devices when they're not usable, so remove the current runtime hack we have.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/d0051c11/attachment.sig>
#8 lore raw

PATCH v3 3/15 serial: bcm283x_mu: Remove support for post-init disabling

In reply to Alexander Graf

We are switching to a model where a serial device doesn't even get probed when it's not muxed properly, so we don't need device specific disabling functionality anymore.

---
 drivers/serial/serial_bcm283x_mu.c           | 18 +-----------------
 include/dm/platform_data/serial_bcm283x_mu.h |  1 -
 2 files changed, 1 insertion(+), 18 deletions(-)
drivers/serial/serial_bcm283x_mu.c +1 -17
index 41c26b3d93..7ce990b9b8 100644
@@ -59,7 +59,7 @@ static int bcm283x_mu_serial_setbrg(struct udevice *dev, int baudrate)
 	struct bcm283x_mu_regs *regs = priv->regs;
 	u32 divider;
 
-	if (plat->disabled || plat->skip_init)
+	if (plat->skip_init)
 		return 0;
 
 	divider = plat->clock / (baudrate * 8);
@@ -75,9 +75,6 @@ static int bcm283x_mu_serial_probe(struct udevice *dev)
 	struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
 	struct bcm283x_mu_priv *priv = dev_get_priv(dev);
 
-	if (plat->disabled)
-		return -ENODEV;
-
 	priv->regs = (struct bcm283x_mu_regs *)plat->base;
 
 	return 0;
@@ -85,14 +82,10 @@ static int bcm283x_mu_serial_probe(struct udevice *dev)
 
 static int bcm283x_mu_serial_getc(struct udevice *dev)
 {
-	struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
 	struct bcm283x_mu_priv *priv = dev_get_priv(dev);
 	struct bcm283x_mu_regs *regs = priv->regs;
 	u32 data;
 
-	if (plat->disabled)
-		return -EAGAIN;
-
 	/* Wait until there is data in the FIFO */
 	if (!(readl(&regs->lsr) & BCM283X_MU_LSR_RX_READY))
 		return -EAGAIN;
@@ -104,13 +97,9 @@ static int bcm283x_mu_serial_getc(struct udevice *dev)
 
 static int bcm283x_mu_serial_putc(struct udevice *dev, const char data)
 {
-	struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
 	struct bcm283x_mu_priv *priv = dev_get_priv(dev);
 	struct bcm283x_mu_regs *regs = priv->regs;
 
-	if (plat->disabled)
-		return 0;
-
 	/* Wait until there is space in the FIFO */
 	if (!(readl(&regs->lsr) & BCM283X_MU_LSR_TX_EMPTY))
 		return -EAGAIN;
@@ -123,14 +112,10 @@ static int bcm283x_mu_serial_putc(struct udevice *dev, const char data)
 
 static int bcm283x_mu_serial_pending(struct udevice *dev, bool input)
 {
-	struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
 	struct bcm283x_mu_priv *priv = dev_get_priv(dev);
 	struct bcm283x_mu_regs *regs = priv->regs;
 	unsigned int lsr;
 
-	if (plat->disabled)
-		return 0;
-
 	lsr = readl(&regs->lsr);
 
 	if (input) {
@@ -168,7 +153,6 @@ static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev)
 				     1);
 	plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
 	                                  "skip-init");
-	plat->disabled = false;
 	return 0;
 }
 #endif
include/dm/platform_data/serial_bcm283x_mu.h +0 -1
index c47d3c0e60..57ae6adc05 100644
@@ -19,7 +19,6 @@ struct bcm283x_mu_serial_platdata {
 	unsigned long base;
 	unsigned int clock;
 	bool skip_init;
-	bool disabled;
 };
 
 #endif
Signature · 1 line
2.12.3
#9 lore raw

PATCH v3 3/15 serial: bcm283x_mu: Remove support for post-init disabling

Quoted 5 lines · Alexander Graf

We are switching to a model where a serial device doesn't even get probed when it's not muxed properly, so we don't need device specific disabling functionality anymore.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/6500c048/attachment.sig>
#10 lore raw

PATCH v3 4/15 rpi: Determine PL011/Mini-UART availability at runtime

In reply to Alexander Graf

Firmware on the Raspberry Pi family of devices can dynamically configure either the PL011, Mini-UART or no device at all to be routed to the user accessible UART pins.

That means we need to always include both drivers, because we can never be sure which of the two serial devices firmware actually chooses to use.

---
 include/configs/rpi.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
include/configs/rpi.h +1 -4
index cab8661779..2c84cf9a49 100644
@@ -75,12 +75,9 @@
 #define CONFIG_MISC_INIT_R
 #endif
 
-/* Console UART */
-#if defined (CONFIG_BCM2837) || defined(CONFIG_TARGET_RPI_0_W)
+/* Console UART, can be configured dynamically in config.txt */
 #define CONFIG_BCM283X_MU_SERIAL
-#else
 #define CONFIG_PL01X_SERIAL
-#endif
 
 /* Console configuration */
 #define CONFIG_SYS_CBSIZE		1024
Signature · 1 line
2.12.3
#11 lore raw

PATCH v3 4/15 rpi: Determine PL011/Mini-UART availability at runtime

Quoted 8 lines · Alexander Graf

Firmware on the Raspberry Pi family of devices can dynamically configure either the PL011, Mini-UART or no device at all to be routed to the user accessible UART pins.

That means we need to always include both drivers, because we can never be sure which of the two serial devices firmware actually chooses to use.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/b6f53dbf/attachment.sig>
#12 lore raw

PATCH v3 5/15 serial_bcm283x_mu: Convert to dev_read

In reply to Alexander Graf

The fdtdec API got deprecated in favor of dev_read calls. Use those instead.

---
 drivers/serial/serial_bcm283x_mu.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/serial/serial_bcm283x_mu.c +3 -7
index 7ce990b9b8..20dc3defcc 100644
@@ -23,9 +23,6 @@
 #include <serial.h>
 #include <dm/platform_data/serial_bcm283x_mu.h>
 #include <linux/compiler.h>
-#include <fdtdec.h>
-
-DECLARE_GLOBAL_DATA_PTR;
 
 struct bcm283x_mu_regs {
 	u32 io;
@@ -149,10 +146,9 @@ static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev)
 		return -EINVAL;
 
 	plat->base = addr;
-	plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
-				     1);
-	plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
-	                                  "skip-init");
+	plat->clock = dev_read_u32_default(dev, "clock", 1);
+	plat->skip_init = dev_read_bool(dev, "skip-init");
+
 	return 0;
 }
 #endif
Signature · 1 line
2.12.3
#13 lore raw

PATCH v3 5/15 serial_bcm283x_mu: Convert to dev_read

Quoted 4 lines · Alexander Graf

The fdtdec API got deprecated in favor of dev_read calls. Use those instead.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/efb66efd/attachment.sig>
#14 lore raw

PATCH v3 6/15 serial_bcm283x_mu: Always skip init

In reply to Alexander Graf

The serial initialization doesn't always quite work for me, so let's always skip it for now. We know that firmware on the RPi initializes us properly already.

---
 drivers/serial/serial_bcm283x_mu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/serial/serial_bcm283x_mu.c +6 -1
index 20dc3defcc..c6132b4463 100644
@@ -147,7 +147,12 @@ static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev)
 
 	plat->base = addr;
 	plat->clock = dev_read_u32_default(dev, "clock", 1);
-	plat->skip_init = dev_read_bool(dev, "skip-init");
+
+	/*
+	 * TODO: Reinitialization doesn't always work for now, just skip
+	 *       init always - we know we're already initialized
+	 */
+	plat->skip_init = true;
 
 	return 0;
 }
Signature · 1 line
2.12.3
#15 lore raw

PATCH v3 6/15 serial_bcm283x_mu: Always skip init

Quoted 5 lines · Alexander Graf

The serial initialization doesn't always quite work for me, so let's always skip it for now. We know that firmware on the RPi initializes us properly already.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/f25af033/attachment.sig>
#16 lore raw

PATCH v3 7/15 serial_bcm283x_mu: Fail loading if not muxed

In reply to Alexander Graf

The bcm283x mini-uart is only really usable as U-Boot serial output when it is muxed to the UART pins of the RPi pin header.

So fail probing in case it is not muxed correctly, as in that case firmware did not initialize it properly either.

---
 drivers/serial/serial_bcm283x_mu.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
drivers/serial/serial_bcm283x_mu.c +28 -0
index c6132b4463..40029fadbc 100644
@@ -19,9 +19,11 @@
 #include <dm.h>
 #include <errno.h>
 #include <watchdog.h>
+#include <asm/gpio.h>
 #include <asm/io.h>
 #include <serial.h>
 #include <dm/platform_data/serial_bcm283x_mu.h>
+#include <dm/pinctrl.h>
 #include <linux/compiler.h>
 
 struct bcm283x_mu_regs {
@@ -136,11 +138,37 @@ static const struct udevice_id bcm283x_mu_serial_id[] = {
 	{}
 };
 
+/*
+ * Check if this serial device is muxed
+ *
+ * The serial device will only work properly if it has been muxed to the serial
+ * pins by firmware. Check whether that happened here.
+ *
+ * @return true if serial device is muxed, false if not
+ */
+static bool bcm283x_is_serial_muxed(void)
+{
+	int serial_gpio = 15;
+	struct udevice *dev;
+
+	if (uclass_first_device(UCLASS_PINCTRL, &dev) || !dev)
+		return false;
+
+	if (pinctrl_get_gpio_mux(dev, 0, serial_gpio) != BCM2835_GPIO_ALT5)
+		return false;
+
+	return true;
+}
+
 static int bcm283x_mu_serial_ofdata_to_platdata(struct udevice *dev)
 {
 	struct bcm283x_mu_serial_platdata *plat = dev_get_platdata(dev);
 	fdt_addr_t addr;
 
+	/* Don't spawn the device if it's not muxed */
+	if (!bcm283x_is_serial_muxed())
+		return -ENODEV;
+
 	addr = devfdt_get_addr(dev);
 	if (addr == FDT_ADDR_T_NONE)
 		return -EINVAL;
Signature · 1 line
2.12.3
#17 lore raw

PATCH v3 7/15 serial_bcm283x_mu: Fail loading if not muxed

Quoted 7 lines · Alexander Graf

The bcm283x mini-uart is only really usable as U-Boot serial output when it is muxed to the UART pins of the RPi pin header.

So fail probing in case it is not muxed correctly, as in that case firmware did not initialize it properly either.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/ad8f0f2b/attachment.sig>
#18 lore raw

PATCH v3 8/15 pl01x: Convert to dev_read

In reply to Alexander Graf

The fdtdec API is deprecated, convert the pl010 and pl011 devices to use the dev_read API instead.

---
 drivers/serial/serial_pl01x.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/serial/serial_pl01x.c +3 -5
index 4ec0f29c42..2cbc84c1b4 100644
@@ -20,7 +20,6 @@
 #include <dm/platform_data/serial_pl01x.h>
 #include <linux/compiler.h>
 #include "serial_pl01x_internal.h"
-#include <fdtdec.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -354,11 +353,10 @@ static int pl01x_serial_ofdata_to_platdata(struct udevice *dev)
 		return -EINVAL;
 
 	plat->base = addr;
-	plat->clock = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "clock",
-				     1);
+	plat->clock = dev_read_u32_default(dev, "clock", 1);
 	plat->type = dev_get_driver_data(dev);
-	plat->skip_init = fdtdec_get_bool(gd->fdt_blob, dev_of_offset(dev),
-	                                  "skip-init");
+	plat->skip_init = dev_read_bool(dev, "skip-init");
+
 	return 0;
 }
 #endif
Signature · 1 line
2.12.3
#19 lore raw

PATCH v3 8/15 pl01x: Convert to dev_read

Quoted 4 lines · Alexander Graf

The fdtdec API is deprecated, convert the pl010 and pl011 devices to use the dev_read API instead.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/288836ae/attachment.sig>
#20 lore raw

PATCH v3 9/15 pl010: Convert CONFIG_PL010_SERIAL to Kconfig

In reply to Alexander Graf

We want to use Kconfig logic to depend on whether pl01x devices are built in, so let's convert their inclusion selection to Kconfig.

This round goes to pl010.

---
 arch/arm/Kconfig             | 1 +
 drivers/serial/Kconfig       | 6 ++++++
 include/configs/edb93xx.h    | 1 -
 scripts/config_whitelist.txt | 1 -
 4 files changed, 7 insertions(+), 2 deletions(-)
arch/arm/Kconfig +1 -0
index f6d57f5505..97b8249432 100644
@@ -348,6 +348,7 @@ config ARCH_AT91
 config TARGET_EDB93XX
 	bool "Support edb93xx"
 	select CPU_ARM920T
+	select PL010_SERIAL
 
 config TARGET_ASPENITE
 	bool "Support aspenite"
drivers/serial/Kconfig +6 -0
index 7b20b47964..2816121dec 100644
@@ -447,6 +447,12 @@ config INTEL_MID_SERIAL
 	  Select this to enable a UART for Intel MID platforms.
 	  This uses the ns16550 driver as a library.
 
+config PL010_SERIAL
+	bool "ARM PL010 driver"
+	depends on !DM_SERIAL
+	help
+	  Select this to enable a UART for platforms using PL010.
+
 config ROCKCHIP_SERIAL
 	bool "Rockchip on-chip UART support"
 	depends on DM_SERIAL && SPL_OF_PLATDATA
include/configs/edb93xx.h +0 -1
index 8fcc791ab4..fcad7c46dd 100644
@@ -80,7 +80,6 @@
 #define CONFIG_SYS_CBSIZE		1024	/* Console I/O buffer size */
 
 /* Serial port hardware configuration */
-#define CONFIG_PL010_SERIAL
 #define CONFIG_CONS_INDEX		0
 #define CONFIG_SYS_BAUDRATE_TABLE	{9600, 19200, 38400, 57600, \
                         115200, 230400}
scripts/config_whitelist.txt +0 -1
index c98f262079..5ee6b07c6d 100644
@@ -1626,7 +1626,6 @@ CONFIG_PIXIS_BRDCFG1_SSI_TDM_MASK
 CONFIG_PIXIS_BRDCFG1_SSI_TDM_SSI
 CONFIG_PIXIS_BRDCFG1_TDM
 CONFIG_PIXIS_SGMII_CMD
-CONFIG_PL010_SERIAL
 CONFIG_PL011_CLOCK
 CONFIG_PL011_SERIAL
 CONFIG_PL011_SERIAL_RLCR
Signature · 1 line
2.12.3
#21 lore raw

PATCH v3 9/15 pl010: Convert CONFIG_PL010_SERIAL to Kconfig

Quoted 6 lines · Alexander Graf

We want to use Kconfig logic to depend on whether pl01x devices are built in, so let's convert their inclusion selection to Kconfig.

This round goes to pl010.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/11feccaa/attachment.sig>
#22 lore raw

PATCH v3 10/15 pl011: Convert CONFIG_PL011_SERIAL to Kconfig

In reply to Alexander Graf

We want to use Kconfig logic to depend on whether pl01x devices are built in, so let's convert their inclusion selection to Kconfig.

This round goes to pl011.

---
 arch/arm/Kconfig                  | 19 +++++++++++++++++++
 drivers/serial/Kconfig            |  6 ++++++
 include/configs/highbank.h        |  1 -
 include/configs/mxs.h             |  1 -
 include/configs/spear-common.h    |  1 -
 include/configs/vexpress_aemv8a.h |  1 -
 include/configs/vexpress_common.h |  1 -
 include/configs/x600.h            |  1 -
 scripts/config_whitelist.txt      |  1 -
 9 files changed, 25 insertions(+), 7 deletions(-)
arch/arm/Kconfig +19 -0
index 97b8249432..1557e7cfdf 100644
@@ -400,49 +400,58 @@ config TARGET_APX4DEVKIT
 	bool "Support apx4devkit"
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
+	select PL011_SERIAL
 
 config TARGET_XFI3
 	bool "Support xfi3"
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
+	select PL011_SERIAL
 
 config TARGET_M28EVK
 	bool "Support m28evk"
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
+	select PL011_SERIAL
 
 config TARGET_MX23EVK
 	bool "Support mx23evk"
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
 	select BOARD_EARLY_INIT_F
+	select PL011_SERIAL
 
 config TARGET_MX28EVK
 	bool "Support mx28evk"
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
 	select BOARD_EARLY_INIT_F
+	select PL011_SERIAL
 
 config TARGET_MX23_OLINUXINO
 	bool "Support mx23_olinuxino"
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
 	select BOARD_EARLY_INIT_F
+	select PL011_SERIAL
 
 config TARGET_BG0900
 	bool "Support bg0900"
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
+	select PL011_SERIAL
 
 config TARGET_SANSA_FUZE_PLUS
 	bool "Support sansa_fuze_plus"
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
+	select PL011_SERIAL
 
 config TARGET_SC_SPS_1
 	bool "Support sc_sps_1"
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
+	select PL011_SERIAL
 
 config ORION5X
 	bool "Marvell Orion"
@@ -453,24 +462,28 @@ config TARGET_SPEAR300
 	select CPU_ARM926EJS
 	select BOARD_EARLY_INIT_F
 	imply CMD_SAVES
+	select PL011_SERIAL
 
 config TARGET_SPEAR310
 	bool "Support spear310"
 	select CPU_ARM926EJS
 	select BOARD_EARLY_INIT_F
 	imply CMD_SAVES
+	select PL011_SERIAL
 
 config TARGET_SPEAR320
 	bool "Support spear320"
 	select CPU_ARM926EJS
 	select BOARD_EARLY_INIT_F
 	imply CMD_SAVES
+	select PL011_SERIAL
 
 config TARGET_SPEAR600
 	bool "Support spear600"
 	select CPU_ARM926EJS
 	select BOARD_EARLY_INIT_F
 	imply CMD_SAVES
+	select PL011_SERIAL
 
 config TARGET_STV0991
 	bool "Support stv0991"
@@ -486,6 +499,7 @@ config TARGET_X600
 	select BOARD_LATE_INIT
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
+	select PL011_SERIAL
 
 config TARGET_IMX31_PHYCORE
 	bool "Support imx31_phycore_eet"
@@ -541,14 +555,17 @@ config TARGET_VEXPRESS_CA15_TC2
 	select CPU_V7
 	select CPU_V7_HAS_NONSEC
 	select CPU_V7_HAS_VIRT
+	select PL011_SERIAL
 
 config TARGET_VEXPRESS_CA5X2
 	bool "Support vexpress_ca5x2"
 	select CPU_V7
+	select PL011_SERIAL
 
 config TARGET_VEXPRESS_CA9X4
 	bool "Support vexpress_ca9x4"
 	select CPU_V7
+	select PL011_SERIAL
 
 config TARGET_BCM23550_W1D
 	bool "Support bcm23550_w1d"
@@ -607,6 +624,7 @@ config ARCH_S5PC1XX
 config ARCH_HIGHBANK
 	bool "Calxeda Highbank"
 	select CPU_V7
+	select PL011_SERIAL
 
 config ARCH_INTEGRATOR
 	bool "ARM Ltd. Integrator family"
@@ -761,6 +779,7 @@ config TARGET_TS4600
 	bool "Support TS4600"
 	select CPU_ARM926EJS
 	select SUPPORT_SPL
+	select PL011_SERIAL
 
 config ARCH_VF610
 	bool "Freescale Vybrid"
drivers/serial/Kconfig +6 -0
index 2816121dec..99aa817e63 100644
@@ -453,6 +453,12 @@ config PL010_SERIAL
 	help
 	  Select this to enable a UART for platforms using PL010.
 
+config PL011_SERIAL
+	bool "ARM PL011 driver"
+	depends on !DM_SERIAL
+	help
+	  Select this to enable a UART for platforms using PL011.
+
 config ROCKCHIP_SERIAL
 	bool "Rockchip on-chip UART support"
 	depends on DM_SERIAL && SPL_OF_PLATDATA
include/configs/highbank.h +0 -1
index a5a524008b..726ae8a214 100644
@@ -22,7 +22,6 @@
  */
 #define CONFIG_SYS_MALLOC_LEN		(512 * 1024)
 
-#define CONFIG_PL011_SERIAL
 #define CONFIG_PL011_CLOCK		150000000
 #define CONFIG_PL01x_PORTS		{ (void *)(0xFFF36000) }
 #define CONFIG_CONS_INDEX		0
include/configs/mxs.h +0 -1
index 804b9e199c..3a27c15060 100644
@@ -108,7 +108,6 @@
  * DUART Serial Driver.
  * Conflicts with AUART driver which can be set by board.
  */
-#define CONFIG_PL011_SERIAL
 #define CONFIG_PL011_CLOCK		24000000
 #define CONFIG_PL01x_PORTS		{ (void *)MXS_UARTDBG_BASE }
 #define CONFIG_CONS_INDEX		0
include/configs/spear-common.h +0 -1
index 349232e1bf..c123e44d15 100644
@@ -76,7 +76,6 @@
  * Serial Configuration (PL011)
  * CONFIG_PL01x_PORTS is defined in specific files
  */
-#define CONFIG_PL011_SERIAL
 #define CONFIG_PL011_CLOCK			(48 * 1000 * 1000)
 #define CONFIG_CONS_INDEX			0
 #define CONFIG_SYS_BAUDRATE_TABLE		{ 9600, 19200, 38400, \
include/configs/vexpress_aemv8a.h +0 -1
index 6203e14135..f18e2ee068 100644
@@ -111,7 +111,6 @@
 /* PL011 Serial Configuration */
 #define CONFIG_CONS_INDEX		0
 #define CONFIG_PL01X_SERIAL
-#define CONFIG_PL011_SERIAL
 #ifdef CONFIG_TARGET_VEXPRESS64_JUNO
 #define CONFIG_PL011_CLOCK		7273800
 #else
include/configs/vexpress_common.h +0 -1
index 294ca18186..94a352fef7 100644
@@ -133,7 +133,6 @@
 #define CONFIG_SYS_TIMER_COUNTS_DOWN
 
 /* PL011 Serial Configuration */
-#define CONFIG_PL011_SERIAL
 #define CONFIG_PL011_CLOCK		24000000
 #define CONFIG_PL01x_PORTS		{(void *)CONFIG_SYS_SERIAL0, \
 					 (void *)CONFIG_SYS_SERIAL1}
include/configs/x600.h +0 -1
index 7363057a5c..9990890a9a 100644
@@ -38,7 +38,6 @@
 #define CONFIG_SYS_SERIAL1			0xD0080000
 #define CONFIG_PL01x_PORTS			{ (void *)CONFIG_SYS_SERIAL0, \
 						(void *)CONFIG_SYS_SERIAL1 }
-#define CONFIG_PL011_SERIAL
 #define CONFIG_PL011_CLOCK			(48 * 1000 * 1000)
 #define CONFIG_CONS_INDEX			0
 #define CONFIG_SYS_BAUDRATE_TABLE		{ 9600, 19200, 38400, \
scripts/config_whitelist.txt +0 -1
index 5ee6b07c6d..a4159ebb36 100644
@@ -1627,7 +1627,6 @@ CONFIG_PIXIS_BRDCFG1_SSI_TDM_SSI
 CONFIG_PIXIS_BRDCFG1_TDM
 CONFIG_PIXIS_SGMII_CMD
 CONFIG_PL011_CLOCK
-CONFIG_PL011_SERIAL
 CONFIG_PL011_SERIAL_RLCR
 CONFIG_PL01X_SERIAL
 CONFIG_PL01x_PORTS
Signature · 1 line
2.12.3
#23 lore raw

PATCH v3 10/15 pl011: Convert CONFIG_PL011_SERIAL to Kconfig

Quoted 6 lines · Alexander Graf

We want to use Kconfig logic to depend on whether pl01x devices are built in, so let's convert their inclusion selection to Kconfig.

This round goes to pl011.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/771cb661/attachment.sig>
#24 lore raw

PATCH v3 11/15 pl01x: Convert CONFIG_PL01X_SERIAL to Kconfig

In reply to Alexander Graf

We want to use Kconfig logic to depend on whether pl01x devices are built in, so let's convert their inclusion selection to Kconfig.

This round goes to pl01x.

---
 arch/arm/Kconfig                    | 11 +++++++++++
 drivers/serial/Kconfig              |  6 ++++++
 include/configs/hikey.h             |  3 ---
 include/configs/integrator-common.h |  2 --
 include/configs/poplar.h            |  3 ---
 include/configs/qemu-arm.h          |  3 ---
 include/configs/rpi.h               |  1 -
 include/configs/stv0991.h           |  3 ---
 include/configs/thunderx_88xx.h     |  1 -
 include/configs/vexpress_aemv8a.h   |  1 -
 scripts/config_whitelist.txt        |  1 -
 11 files changed, 17 insertions(+), 18 deletions(-)
arch/arm/Kconfig +11 -0
index 1557e7cfdf..b2345eaa26 100644
@@ -493,6 +493,7 @@ config TARGET_STV0991
 	select DM_SPI
 	select DM_SPI_FLASH
 	select SPI_FLASH
+	select PL01X_SERIAL
 
 config TARGET_X600
 	bool "Support x600"
@@ -548,6 +549,7 @@ config ARCH_BCM283X
 	select DM_SERIAL
 	select DM_GPIO
 	select OF_CONTROL
+	select PL01X_SERIAL
 	imply FAT_WRITE
 
 config TARGET_VEXPRESS_CA15_TC2
@@ -630,6 +632,7 @@ config ARCH_INTEGRATOR
 	bool "ARM Ltd. Integrator family"
 	select DM
 	select DM_SERIAL
+	select PL01X_SERIAL
 
 config ARCH_KEYSTONE
 	bool "TI Keystone"
@@ -697,6 +700,7 @@ config ARCH_QEMU
 	select DM
 	select DM_SERIAL
 	select OF_CONTROL
+	select PL01X_SERIAL
 
 config ARCH_RMOBILE
 	bool "Renesas ARM SoCs"
@@ -835,15 +839,18 @@ config TEGRA
 config TARGET_VEXPRESS64_AEMV8A
 	bool "Support vexpress_aemv8a"
 	select ARM64
+	select PL01X_SERIAL
 
 config TARGET_VEXPRESS64_BASE_FVP
 	bool "Support Versatile Express ARMv8a FVP BASE model"
 	select ARM64
 	select SEMIHOSTING
+	select PL01X_SERIAL
 
 config TARGET_VEXPRESS64_BASE_FVP_DRAM
 	bool "Support Versatile Express ARMv8a FVP BASE model booting from DRAM"
 	select ARM64
+	select PL01X_SERIAL
 	help
 	  This target is derived from TARGET_VEXPRESS64_BASE_FVP and over-rides
 	  the default config to allow the user to load the images directly into
@@ -853,6 +860,7 @@ config TARGET_VEXPRESS64_BASE_FVP_DRAM
 config TARGET_VEXPRESS64_JUNO
 	bool "Support Versatile Express Juno Development Platform"
 	select ARM64
+	select PL01X_SERIAL
 
 config TARGET_LS2080A_EMU
 	bool "Support ls2080a_emu"
@@ -945,6 +953,7 @@ config TARGET_HIKEY
 	select DM_GPIO
 	select DM_SERIAL
 	select OF_CONTROL
+	select PL01X_SERIAL
 	  help
 	  Support for HiKey 96boards platform. It features a HI6220
 	  SoC, with 8xA53 CPU, mali450 gpu, and 1GB RAM.
@@ -956,6 +965,7 @@ config TARGET_POPLAR
 	select OF_CONTROL
 	select DM_SERIAL
 	select DM_USB
+	select PL01X_SERIAL
 	  help
 	  Support for Poplar 96boards EE platform. It features a HI3798cv200
 	  SoC, with 4xA53 CPU, 1GB RAM and the high performance Mali T720 GPU
@@ -1211,6 +1221,7 @@ config TARGET_THUNDERX_88XX
 	select ARM64
 	select OF_CONTROL
 	select SYS_CACHE_SHIFT_7
+	select PL01X_SERIAL
 
 config ARCH_ASPEED
 	bool "Support Aspeed SoCs"
drivers/serial/Kconfig +6 -0
index 99aa817e63..4167683885 100644
@@ -459,6 +459,12 @@ config PL011_SERIAL
 	help
 	  Select this to enable a UART for platforms using PL011.
 
+config PL01X_SERIAL
+	bool "ARM PL010 and PL011 driver"
+	depends on DM_SERIAL
+	help
+	  Select this to enable a UART for platforms using PL010 or PL011.
+
 config ROCKCHIP_SERIAL
 	bool "Rockchip on-chip UART support"
 	depends on DM_SERIAL && SPL_OF_PLATDATA
include/configs/hikey.h +0 -3
index 7eaa6e4667..aaddf4c1f1 100644
@@ -50,9 +50,6 @@
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + SZ_8M)
 
-/* Serial port PL010/PL011 through the device model */
-#define CONFIG_PL01X_SERIAL
-
 #ifdef CONFIG_CMD_USB
 #define CONFIG_USB_DWC2_REG_ADDR 0xF72C0000
 /*#define CONFIG_DWC2_DFLT_SPEED_FULL*/
include/configs/integrator-common.h +0 -2
index edc798b117..f66d954748 100644
@@ -15,8 +15,6 @@
 #define CONFIG_SYS_LONGHELP
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 128*1024) /* Size of malloc() pool */
 
-/* Serial port PL010/PL011 through the device model */
-#define CONFIG_PL01X_SERIAL
 #define CONFIG_CONS_INDEX		0
 
 #define CONFIG_CMDLINE_TAG		/* enable passing of ATAGs  */
include/configs/poplar.h +0 -3
index 8a12b526a8..9641b27b1b 100644
@@ -26,9 +26,6 @@
 /* ATF bl33.bin load address (must match) */
 #define CONFIG_SYS_TEXT_BASE			0x37000000
 
-/* PL010/PL011 */
-#define CONFIG_PL01X_SERIAL
-
 /* USB configuration */
 #define CONFIG_USB_MAX_CONTROLLER_COUNT		2
 
include/configs/qemu-arm.h +0 -3
index c8852cef34..c8ba78d8aa 100644
@@ -20,9 +20,6 @@
 #define CONFIG_SYS_LOAD_ADDR		(CONFIG_SYS_SDRAM_BASE + SZ_2M)
 #define CONFIG_SYS_MALLOC_LEN		SZ_16M
 
-/* QEMU's PL011 serial port is detected via FDT using the device model */
-#define CONFIG_PL01X_SERIAL
-
 /* QEMU implements a 62.5MHz architected timer */
 /* FIXME: can we rely on CNTFREQ instead of hardcoding this fact here? */
 #define CONFIG_SYS_ARCH_TIMER
include/configs/rpi.h +0 -1
index 2c84cf9a49..5ffe98015f 100644
@@ -77,7 +77,6 @@
 
 /* Console UART, can be configured dynamically in config.txt */
 #define CONFIG_BCM283X_MU_SERIAL
-#define CONFIG_PL01X_SERIAL
 
 /* Console configuration */
 #define CONFIG_SYS_CBSIZE		1024
include/configs/stv0991.h +0 -3
index c99fb676cb..3e0b8a157f 100644
@@ -25,9 +25,6 @@
 	(PHYS_SDRAM_1_SIZE - CONFIG_ENV_SIZE)
 #define CONFIG_SYS_MALLOC_LEN			(CONFIG_ENV_SIZE + 16 * 1024)
 
-/* serial port (PL011) configuration */
-#define CONFIG_PL01X_SERIAL
-
 /* user interface */
 #define CONFIG_SYS_CBSIZE			1024
 
include/configs/thunderx_88xx.h +0 -1
index 209a7c3417..34940efb41 100644
@@ -35,7 +35,6 @@
 
 /* PL011 Serial Configuration */
 
-#define CONFIG_PL01X_SERIAL
 #define CONFIG_PL011_CLOCK		24000000
 #define CONFIG_CONS_INDEX		1
 
include/configs/vexpress_aemv8a.h +0 -1
index f18e2ee068..07cc92ce17 100644
@@ -110,7 +110,6 @@
 
 /* PL011 Serial Configuration */
 #define CONFIG_CONS_INDEX		0
-#define CONFIG_PL01X_SERIAL
 #ifdef CONFIG_TARGET_VEXPRESS64_JUNO
 #define CONFIG_PL011_CLOCK		7273800
 #else
scripts/config_whitelist.txt +0 -1
index a4159ebb36..6e4e322986 100644
@@ -1628,7 +1628,6 @@ CONFIG_PIXIS_BRDCFG1_TDM
 CONFIG_PIXIS_SGMII_CMD
 CONFIG_PL011_CLOCK
 CONFIG_PL011_SERIAL_RLCR
-CONFIG_PL01X_SERIAL
 CONFIG_PL01x_PORTS
 CONFIG_PLATFORM_ENV_SETTINGS
 CONFIG_PLATINUM_BOARD
Signature · 1 line
2.12.3
#25 lore raw

PATCH v3 11/15 pl01x: Convert CONFIG_PL01X_SERIAL to Kconfig

Quoted 6 lines · Alexander Graf

We want to use Kconfig logic to depend on whether pl01x devices are built in, so let's convert their inclusion selection to Kconfig.

This round goes to pl01x.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/b89d0da0/attachment.sig>
#26 lore raw

PATCH v3 12/15 bcm2835_mu_serial: Convert to Kconfig

In reply to Alexander Graf

Setting config options using headers is deprecated. This patch converts the BCM2835 Mini-UART to Kconfig.

---
 drivers/serial/Kconfig       | 7 +++++++
 include/configs/rpi.h        | 3 ---
 scripts/config_whitelist.txt | 1 -
 3 files changed, 7 insertions(+), 4 deletions(-)
drivers/serial/Kconfig +7 -0
index 4167683885..72281a7b64 100644
@@ -388,6 +388,13 @@ config ATMEL_USART
 	  configured in the device tree, and input clock frequency can
 	  be got from the clk node.
 
+config BCM283X_MU_SERIAL
+	bool "Support for BCM283x Mini-UART"
+	depends on DM_SERIAL && ARCH_BCM283X
+	default y
+	help
+	  Select this to enable Mini-UART support on BCM283X family of SoCs.
+
 config BCM6345_SERIAL
 	bool "Support for BCM6345 UART"
 	depends on DM_SERIAL && ARCH_BMIPS
include/configs/rpi.h +0 -3
index 5ffe98015f..f2d3646753 100644
@@ -75,9 +75,6 @@
 #define CONFIG_MISC_INIT_R
 #endif
 
-/* Console UART, can be configured dynamically in config.txt */
-#define CONFIG_BCM283X_MU_SERIAL
-
 /* Console configuration */
 #define CONFIG_SYS_CBSIZE		1024
 
scripts/config_whitelist.txt +0 -1
index 6e4e322986..5e02588066 100644
@@ -121,7 +121,6 @@ CONFIG_BCH_CONST_M
 CONFIG_BCH_CONST_PARAMS
 CONFIG_BCH_CONST_T
 CONFIG_BCM2835_GPIO
-CONFIG_BCM283X_MU_SERIAL
 CONFIG_BIOSEMU
 CONFIG_BITBANGMII_MULTI
 CONFIG_BL1_OFFSET
Signature · 1 line
2.12.3
#27 lore raw

PATCH v3 12/15 bcm2835_mu_serial: Convert to Kconfig

Quoted 4 lines · Alexander Graf

Setting config options using headers is deprecated. This patch converts the BCM2835 Mini-UART to Kconfig.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/6eddc551/attachment.sig>
#28 lore raw

PATCH v3 13/15 MAINTAINERS: Take over BCM2835 maintainership

In reply to Alexander Graf

It seems as if I have more interest in BCM2835 support than most others, so I'll bite the bullet and declare myself maintainer. It'd be a shame to leave that platform orphaned.

---
 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
MAINTAINERS +2 -2
index 728d38aebf..19f645d825 100644
@@ -92,8 +92,8 @@ T:	git git://git.denx.de/u-boot-atmel.git
 F:	arch/arm/mach-at91/
 
 ARM BROADCOM BCM283X
-#M:	Stephen Warren <[email protected]>
-S:	Orphaned (Since 2017-07)
+M:	Alexander Graf <[email protected]>
+S:	Maintained
 F:	arch/arm/mach-bcm283x/
 F:	drivers/gpio/bcm2835_gpio.c
 F:	drivers/mmc/bcm2835_sdhci.c
Signature · 1 line
2.12.3
#29 lore raw

PATCH v3 13/15 MAINTAINERS: Take over BCM2835 maintainership

Quoted 5 lines · Alexander Graf

It seems as if I have more interest in BCM2835 support than most others, so I'll bite the bullet and declare myself maintainer. It'd be a shame to leave that platform orphaned.

Thanks for taking this over and applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/b4f3eb6b/attachment.sig>
#30 lore raw

PATCH v3 13/15 MAINTAINERS: Take over BCM2835 maintainership

In reply to Alexander Graf

Dear Alex,

Quoted 3 lines · In message <[email protected]> you wrote:

It seems as if I have more interest in BCM2835 support than most others, so I'll bite the bullet and declare myself maintainer. It'd be a shame to leave that platform orphaned.

Thanks.

Shall I use the same SSH public key as used for the EFI repository to set up a BCM custodian repo for you?

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
All repairs tend to destroy the structure, to  increase  the  entropy
and  disorder  of the system. Less and less effort is spent on fixing
original design flaws; more and more is spent on fixing flaws  intro-
duced by earlier fixes.       - Fred Brooks, "The Mythical Man Month"
#31 lore raw

PATCH v3 13/15 MAINTAINERS: Take over BCM2835 maintainership

Quoted 11 lines · Wolfgang Denk

Dear Alex,

Quoted 3 lines · In message <[email protected]> you wrote:

It seems as if I have more interest in BCM2835 support than most others, so I'll bite the bullet and declare myself maintainer. It'd be a shame to leave that platform orphaned.

Thanks.

Shall I use the same SSH public key as used for the EFI repository to set up a BCM custodian repo for you?

If you want to set one up, sure :). I personally like the current flow of just keeping my git tree on github and sending signed pull requests.

Alex

#32 lore raw

PATCH v3 13/15 MAINTAINERS: Take over BCM2835 maintainership

Dear Alex,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 3 lines

Shall I use the same SSH public key as used for the EFI repository to set up a BCM custodian repo for you?

If you want to set one up, sure :).

Done.

Quoted 2 lines

I personally like the current flow
of just keeping my git tree on github and sending signed pull requests.

Having all custodian repositories in the same place so everybody knows where to search makes a lot of sense to me.

Thanks!

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I don't know if it's what you want, but it's what you get.  :-)
                      - Larry Wall in <[email protected]>
#33 lore raw

PATCH v3 14/15 bcm2835_pl011_serial: Add BCM2835 specific serial driver

In reply to Alexander Graf

On bcm2835 we need to ensure we only access serial devices that are muxed to the serial output pins of the pin header. To achieve this for the pl011 device, add a bcm2835 specific pl011 wrapper device that does this check but otherwise behaves like a pl011 device.

---
 MAINTAINERS                            |  1 +
 drivers/serial/Kconfig                 |  9 +++++
 drivers/serial/Makefile                |  1 +
 drivers/serial/serial_bcm283x_pl011.c  | 73 ++++++++++++++++++++++++++++++++++
 drivers/serial/serial_pl01x.c          | 11 ++---
 drivers/serial/serial_pl01x_internal.h | 15 ++++++-
 6 files changed, 101 insertions(+), 9 deletions(-)
 create mode 100644 drivers/serial/serial_bcm283x_pl011.c
MAINTAINERS +1 -0
index 19f645d825..c614ff2d5c 100644
@@ -99,6 +99,7 @@ F:	drivers/gpio/bcm2835_gpio.c
 F:	drivers/mmc/bcm2835_sdhci.c
 F:	drivers/mmc/bcm2835_sdhost.c
 F:	drivers/serial/serial_bcm283x_mu.c
+F:	drivers/serial/serial_bcm283x_pl011.c
 F:	drivers/video/bcm2835.c
 F:	include/dm/platform_data/serial_bcm283x_mu.h
 F:	drivers/pinctrl/broadcom/
drivers/serial/Kconfig +9 -0
index 72281a7b64..3ffedba525 100644
@@ -395,6 +395,15 @@ config BCM283X_MU_SERIAL
 	help
 	  Select this to enable Mini-UART support on BCM283X family of SoCs.
 
+config BCM283X_PL011_SERIAL
+	bool "Support for BCM283x PL011 UART"
+	depends on PL01X_SERIAL && ARCH_BCM283X
+	default y
+	help
+	  Select this to enable an overriding PL011 driver for BCM283X SoCs
+	  that supports automatic disable, so that it only gets used when
+	  the UART is actually muxed.
+
 config BCM6345_SERIAL
 	bool "Support for BCM6345 UART"
 	depends on DM_SERIAL && ARCH_BMIPS
drivers/serial/Makefile +1 -0
index 5ef603ab15..cac9a8b312 100644
@@ -46,6 +46,7 @@ obj-$(CONFIG_STI_ASC_SERIAL) += serial_sti_asc.o
 obj-$(CONFIG_PIC32_SERIAL) += serial_pic32.o
 obj-$(CONFIG_STM32_SERIAL) += serial_stm32.o
 obj-$(CONFIG_BCM283X_MU_SERIAL) += serial_bcm283x_mu.o
+obj-$(CONFIG_BCM283X_PL011_SERIAL) += serial_bcm283x_pl011.o
 obj-$(CONFIG_MSM_SERIAL) += serial_msm.o
 obj-$(CONFIG_MVEBU_A3700_UART) += serial_mvebu_a3700.o
 obj-$(CONFIG_MPC8XX_CONS) += serial_mpc8xx.o
drivers/serial/serial_bcm283x_pl011.c new file +73 -0

73 lines not on this page · raw message

drivers/serial/serial_pl01x.c +3 -8
index 2cbc84c1b4..23d9d839cb 100644
@@ -273,11 +273,6 @@ __weak struct serial_device *default_serial_console(void)
 
 #ifdef CONFIG_DM_SERIAL
 
-struct pl01x_priv {
-	struct pl01x_regs *regs;
-	enum pl01x_type type;
-};
-
 static int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
 {
 	struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
@@ -291,7 +286,7 @@ static int pl01x_serial_setbrg(struct udevice *dev, int baudrate)
 	return 0;
 }
 
-static int pl01x_serial_probe(struct udevice *dev)
+int pl01x_serial_probe(struct udevice *dev)
 {
 	struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
 	struct pl01x_priv *priv = dev_get_priv(dev);
@@ -329,7 +324,7 @@ static int pl01x_serial_pending(struct udevice *dev, bool input)
 		return fr & UART_PL01x_FR_TXFF ? 0 : 1;
 }
 
-static const struct dm_serial_ops pl01x_serial_ops = {
+const struct dm_serial_ops pl01x_serial_ops = {
 	.putc = pl01x_serial_putc,
 	.pending = pl01x_serial_pending,
 	.getc = pl01x_serial_getc,
@@ -343,7 +338,7 @@ static const struct udevice_id pl01x_serial_id[] ={
 	{}
 };
 
-static int pl01x_serial_ofdata_to_platdata(struct udevice *dev)
+int pl01x_serial_ofdata_to_platdata(struct udevice *dev)
 {
 	struct pl01x_serial_platdata *plat = dev_get_platdata(dev);
 	fdt_addr_t addr;
drivers/serial/serial_pl01x_internal.h +14 -1
index 288a4f19f5..c56dd54c7b 100644
@@ -38,7 +38,20 @@ struct pl01x_regs {
 	u32	pl011_lcrh;	/* 0x2C Line control register */
 	u32	pl011_cr;	/* 0x30 Control register */
 };
-#endif
+
+#ifdef CONFIG_DM_SERIAL
+
+int pl01x_serial_ofdata_to_platdata(struct udevice *dev);
+int pl01x_serial_probe(struct udevice *dev);
+extern const struct dm_serial_ops pl01x_serial_ops;
+
+struct pl01x_priv {
+	struct pl01x_regs *regs;
+	enum pl01x_type type;
+};
+
+#endif /* CONFIG_DM_SERIAL */
+#endif /* !__ASSEMBLY__ */
 
 #define UART_PL01x_RSR_OE               0x08
 #define UART_PL01x_RSR_BE               0x04
Signature · 1 line
2.12.3
#34 lore raw

PATCH v3 14/15 bcm2835_pl011_serial: Add BCM2835 specific serial driver

Quoted 6 lines · Alexander Graf

On bcm2835 we need to ensure we only access serial devices that are muxed to the serial output pins of the pin header. To achieve this for the pl011 device, add a bcm2835 specific pl011 wrapper device that does this check but otherwise behaves like a pl011 device.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/1f02360c/attachment.sig>
#35 lore raw

PATCH v3 15/15 bcm2835_pinctrl: Probe pre-reloc

In reply to Alexander Graf

The serial drivers now depend on the pinctrl driver to determine whether they are enabled. That means if a serial device wants to be used pre-reloc, we also need the pinctrl device pre-reloc.

Adapt the pinctrl driver as well as dts overlay accordingly.

---
 arch/arm/dts/bcm283x-uboot.dtsi            | 4 ++++
 drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)
arch/arm/dts/bcm283x-uboot.dtsi +4 -0
index 8e4231ae6c..21d038aebb 100644
@@ -20,3 +20,7 @@
 	skip-init;
 	u-boot,dm-pre-reloc;
 };
+
+&gpio {
+	u-boot,dm-pre-reloc;
+};
drivers/pinctrl/broadcom/pinctrl-bcm283x.c +2 -1
index 83dde2302e..6fbd6efbd2 100644
@@ -148,5 +148,6 @@ U_BOOT_DRIVER(pinctrl_bcm283x) = {
 	.of_match	= of_match_ptr(bcm2835_pinctrl_id),
 	.priv_auto_alloc_size = sizeof(struct bcm283x_pinctrl_priv),
 	.ops		= &bcm283x_pinctrl_ops,
-	.probe		= bcm283x_pinctl_probe
+	.probe		= bcm283x_pinctl_probe,
+	.flags		= DM_FLAG_PRE_RELOC,
 };
Signature · 1 line
2.12.3
#36 lore raw

PATCH v3 15/15 bcm2835_pinctrl: Probe pre-reloc

Quoted 7 lines · Alexander Graf

The serial drivers now depend on the pinctrl driver to determine whether they are enabled. That means if a serial device wants to be used pre-reloc, we also need the pinctrl device pre-reloc.

Adapt the pinctrl driver as well as dts overlay accordingly.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/238d810b/attachment-0001.sig>