[U-Boot] [PATCH v3 00/15] 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

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.
Signed-off-by: Alexander Graf agraf@suse.de Reviewed-by: Simon Glass sjg@chromium.org
---
v1 -> v2:
- Make search logic easier to follow --- drivers/serial/serial-uclass.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 2e5116f7ce..68ca2d09d1 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -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 }

On Thu, Jan 25, 2018 at 12:05:42PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

On Sun, Jan 28, 2018 at 01:54:50PM -0500, Tom Rini wrote:
On Thu, Jan 25, 2018 at 12:05:42PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
-- 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

On 29.01.18 04:27, Derald D. Woods wrote:
On Sun, Jan 28, 2018 at 01:54:50PM -0500, Tom Rini wrote:
On Thu, Jan 25, 2018 at 12:05:42PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
-- 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

On 29.01.18 04:27, Derald D. Woods wrote:
On Sun, Jan 28, 2018 at 01:54:50PM -0500, Tom Rini wrote:
On Thu, Jan 25, 2018 at 12:05:42PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
-- 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

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.
Signed-off-by: Alexander Graf agraf@suse.de --- board/raspberrypi/rpi/rpi.c | 43 ------------------------------------------- 1 file changed, 43 deletions(-)
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c index c8924d4362..177f4af265 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -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();

On Thu, Jan 25, 2018 at 12:05:43PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

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.
Signed-off-by: Alexander Graf agraf@suse.de --- drivers/serial/serial_bcm283x_mu.c | 18 +----------------- include/dm/platform_data/serial_bcm283x_mu.h | 1 - 2 files changed, 1 insertion(+), 18 deletions(-)
diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index 41c26b3d93..7ce990b9b8 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -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(®s->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(®s->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(®s->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 diff --git a/include/dm/platform_data/serial_bcm283x_mu.h b/include/dm/platform_data/serial_bcm283x_mu.h index c47d3c0e60..57ae6adc05 100644 --- a/include/dm/platform_data/serial_bcm283x_mu.h +++ b/include/dm/platform_data/serial_bcm283x_mu.h @@ -19,7 +19,6 @@ struct bcm283x_mu_serial_platdata { unsigned long base; unsigned int clock; bool skip_init; - bool disabled; };
#endif

On Thu, Jan 25, 2018 at 12:05:44PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

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.
Signed-off-by: Alexander Graf agraf@suse.de --- include/configs/rpi.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/include/configs/rpi.h b/include/configs/rpi.h index cab8661779..2c84cf9a49 100644 --- a/include/configs/rpi.h +++ b/include/configs/rpi.h @@ -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

On Thu, Jan 25, 2018 at 12:05:45PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

The fdtdec API got deprecated in favor of dev_read calls. Use those instead.
Signed-off-by: Alexander Graf agraf@suse.de --- drivers/serial/serial_bcm283x_mu.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index 7ce990b9b8..20dc3defcc 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -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

On Thu, Jan 25, 2018 at 12:05:46PM +0100, Alexander Graf wrote:
The fdtdec API got deprecated in favor of dev_read calls. Use those instead.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

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.
Signed-off-by: Alexander Graf agraf@suse.de --- drivers/serial/serial_bcm283x_mu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index 20dc3defcc..c6132b4463 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -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; }

On Thu, Jan 25, 2018 at 12:05:47PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

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.
Signed-off-by: Alexander Graf agraf@suse.de --- drivers/serial/serial_bcm283x_mu.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/drivers/serial/serial_bcm283x_mu.c b/drivers/serial/serial_bcm283x_mu.c index c6132b4463..40029fadbc 100644 --- a/drivers/serial/serial_bcm283x_mu.c +++ b/drivers/serial/serial_bcm283x_mu.c @@ -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;

On Thu, Jan 25, 2018 at 12:05:48PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

The fdtdec API is deprecated, convert the pl010 and pl011 devices to use the dev_read API instead.
Signed-off-by: Alexander Graf agraf@suse.de --- drivers/serial/serial_pl01x.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 4ec0f29c42..2cbc84c1b4 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -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

On Thu, Jan 25, 2018 at 12:05:49PM +0100, Alexander Graf wrote:
The fdtdec API is deprecated, convert the pl010 and pl011 devices to use the dev_read API instead.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

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.
Signed-off-by: Alexander Graf agraf@suse.de --- 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(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index f6d57f5505..97b8249432 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -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" diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 7b20b47964..2816121dec 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -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 diff --git a/include/configs/edb93xx.h b/include/configs/edb93xx.h index 8fcc791ab4..fcad7c46dd 100644 --- a/include/configs/edb93xx.h +++ b/include/configs/edb93xx.h @@ -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} diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index c98f262079..5ee6b07c6d 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -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

On Thu, Jan 25, 2018 at 12:05:50PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

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.
Signed-off-by: Alexander Graf agraf@suse.de --- 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(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 97b8249432..1557e7cfdf 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -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" diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 2816121dec..99aa817e63 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -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 diff --git a/include/configs/highbank.h b/include/configs/highbank.h index a5a524008b..726ae8a214 100644 --- a/include/configs/highbank.h +++ b/include/configs/highbank.h @@ -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 diff --git a/include/configs/mxs.h b/include/configs/mxs.h index 804b9e199c..3a27c15060 100644 --- a/include/configs/mxs.h +++ b/include/configs/mxs.h @@ -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 diff --git a/include/configs/spear-common.h b/include/configs/spear-common.h index 349232e1bf..c123e44d15 100644 --- a/include/configs/spear-common.h +++ b/include/configs/spear-common.h @@ -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, \ diff --git a/include/configs/vexpress_aemv8a.h b/include/configs/vexpress_aemv8a.h index 6203e14135..f18e2ee068 100644 --- a/include/configs/vexpress_aemv8a.h +++ b/include/configs/vexpress_aemv8a.h @@ -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 diff --git a/include/configs/vexpress_common.h b/include/configs/vexpress_common.h index 294ca18186..94a352fef7 100644 --- a/include/configs/vexpress_common.h +++ b/include/configs/vexpress_common.h @@ -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} diff --git a/include/configs/x600.h b/include/configs/x600.h index 7363057a5c..9990890a9a 100644 --- a/include/configs/x600.h +++ b/include/configs/x600.h @@ -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, \ diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 5ee6b07c6d..a4159ebb36 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -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

On Thu, Jan 25, 2018 at 12:05:51PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

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.
Signed-off-by: Alexander Graf agraf@suse.de --- 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(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 1557e7cfdf..b2345eaa26 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -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" diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 99aa817e63..4167683885 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -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 diff --git a/include/configs/hikey.h b/include/configs/hikey.h index 7eaa6e4667..aaddf4c1f1 100644 --- a/include/configs/hikey.h +++ b/include/configs/hikey.h @@ -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*/ diff --git a/include/configs/integrator-common.h b/include/configs/integrator-common.h index edc798b117..f66d954748 100644 --- a/include/configs/integrator-common.h +++ b/include/configs/integrator-common.h @@ -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 */ diff --git a/include/configs/poplar.h b/include/configs/poplar.h index 8a12b526a8..9641b27b1b 100644 --- a/include/configs/poplar.h +++ b/include/configs/poplar.h @@ -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
diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index c8852cef34..c8ba78d8aa 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -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 diff --git a/include/configs/rpi.h b/include/configs/rpi.h index 2c84cf9a49..5ffe98015f 100644 --- a/include/configs/rpi.h +++ b/include/configs/rpi.h @@ -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 diff --git a/include/configs/stv0991.h b/include/configs/stv0991.h index c99fb676cb..3e0b8a157f 100644 --- a/include/configs/stv0991.h +++ b/include/configs/stv0991.h @@ -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
diff --git a/include/configs/thunderx_88xx.h b/include/configs/thunderx_88xx.h index 209a7c3417..34940efb41 100644 --- a/include/configs/thunderx_88xx.h +++ b/include/configs/thunderx_88xx.h @@ -35,7 +35,6 @@
/* PL011 Serial Configuration */
-#define CONFIG_PL01X_SERIAL #define CONFIG_PL011_CLOCK 24000000 #define CONFIG_CONS_INDEX 1
diff --git a/include/configs/vexpress_aemv8a.h b/include/configs/vexpress_aemv8a.h index f18e2ee068..07cc92ce17 100644 --- a/include/configs/vexpress_aemv8a.h +++ b/include/configs/vexpress_aemv8a.h @@ -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 diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index a4159ebb36..6e4e322986 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -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

On Thu, Jan 25, 2018 at 12:05:52PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

Setting config options using headers is deprecated. This patch converts the BCM2835 Mini-UART to Kconfig.
Signed-off-by: Alexander Graf agraf@suse.de --- drivers/serial/Kconfig | 7 +++++++ include/configs/rpi.h | 3 --- scripts/config_whitelist.txt | 1 - 3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 4167683885..72281a7b64 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -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 diff --git a/include/configs/rpi.h b/include/configs/rpi.h index 5ffe98015f..f2d3646753 100644 --- a/include/configs/rpi.h +++ b/include/configs/rpi.h @@ -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
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 6e4e322986..5e02588066 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -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

On Thu, Jan 25, 2018 at 12:05:53PM +0100, Alexander Graf wrote:
Setting config options using headers is deprecated. This patch converts the BCM2835 Mini-UART to Kconfig.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

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.
Signed-off-by: Alexander Graf agraf@suse.de --- MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS index 728d38aebf..19f645d825 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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 swarren@wwwdotorg.org -S: Orphaned (Since 2017-07) +M: Alexander Graf agraf@suse.de +S: Maintained F: arch/arm/mach-bcm283x/ F: drivers/gpio/bcm2835_gpio.c F: drivers/mmc/bcm2835_sdhci.c

On Thu, Jan 25, 2018 at 12:05:54PM +0100, Alexander Graf 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.
Signed-off-by: Alexander Graf agraf@suse.de
Thanks for taking this over and applied to u-boot/master, thanks!

Dear Alex,
In message 20180125110556.76352-14-agraf@suse.de 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

On 31.01.18 09:34, Wolfgang Denk wrote:
Dear Alex,
In message 20180125110556.76352-14-agraf@suse.de 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

Dear Alex,
In message 626a8254-a615-dece-e7e6-ee205699dd97@suse.de you wrote:
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.
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

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.
Signed-off-by: Alexander Graf agraf@suse.de --- 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
diff --git a/MAINTAINERS b/MAINTAINERS index 19f645d825..c614ff2d5c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -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/ diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 72281a7b64..3ffedba525 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -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 diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 5ef603ab15..cac9a8b312 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -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 diff --git a/drivers/serial/serial_bcm283x_pl011.c b/drivers/serial/serial_bcm283x_pl011.c new file mode 100644 index 0000000000..bfd39f84f3 --- /dev/null +++ b/drivers/serial/serial_bcm283x_pl011.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2018 Alexander Graf agraf@suse.de + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <dm.h> +#include <asm/gpio.h> +#include <dm/pinctrl.h> +#include <dm/platform_data/serial_pl01x.h> +#include "serial_pl01x_internal.h" + +/* + * 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_ALT0) + return false; + + return true; +} + +static int bcm283x_pl011_serial_ofdata_to_platdata(struct udevice *dev) +{ + struct pl01x_serial_platdata *plat = dev_get_platdata(dev); + int ret; + + /* Don't spawn the device if it's not muxed */ + if (!bcm283x_is_serial_muxed()) + return -ENODEV; + + ret = pl01x_serial_ofdata_to_platdata(dev); + if (ret) + return ret; + + /* + * TODO: Reinitialization doesn't always work for now, just skip + * init always - we know we're already initialized + */ + plat->skip_init = true; + + return 0; +} + +static const struct udevice_id bcm283x_pl011_serial_id[] = { + {.compatible = "brcm,bcm2835-pl011", .data = TYPE_PL011}, + {} +}; + +U_BOOT_DRIVER(bcm283x_pl011_uart) = { + .name = "bcm283x_pl011", + .id = UCLASS_SERIAL, + .of_match = of_match_ptr(bcm283x_pl011_serial_id), + .ofdata_to_platdata = of_match_ptr(bcm283x_pl011_serial_ofdata_to_platdata), + .platdata_auto_alloc_size = sizeof(struct pl01x_serial_platdata), + .probe = pl01x_serial_probe, + .ops = &pl01x_serial_ops, + .flags = DM_FLAG_PRE_RELOC, + .priv_auto_alloc_size = sizeof(struct pl01x_priv), +}; diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 2cbc84c1b4..23d9d839cb 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -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; diff --git a/drivers/serial/serial_pl01x_internal.h b/drivers/serial/serial_pl01x_internal.h index 288a4f19f5..c56dd54c7b 100644 --- a/drivers/serial/serial_pl01x_internal.h +++ b/drivers/serial/serial_pl01x_internal.h @@ -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

On Thu, Jan 25, 2018 at 12:05:55PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!

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.
Signed-off-by: Alexander Graf agraf@suse.de --- arch/arm/dts/bcm283x-uboot.dtsi | 4 ++++ drivers/pinctrl/broadcom/pinctrl-bcm283x.c | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/arm/dts/bcm283x-uboot.dtsi b/arch/arm/dts/bcm283x-uboot.dtsi index 8e4231ae6c..21d038aebb 100644 --- a/arch/arm/dts/bcm283x-uboot.dtsi +++ b/arch/arm/dts/bcm283x-uboot.dtsi @@ -20,3 +20,7 @@ skip-init; u-boot,dm-pre-reloc; }; + +&gpio { + u-boot,dm-pre-reloc; +}; diff --git a/drivers/pinctrl/broadcom/pinctrl-bcm283x.c b/drivers/pinctrl/broadcom/pinctrl-bcm283x.c index 83dde2302e..6fbd6efbd2 100644 --- a/drivers/pinctrl/broadcom/pinctrl-bcm283x.c +++ b/drivers/pinctrl/broadcom/pinctrl-bcm283x.c @@ -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, };

On Thu, Jan 25, 2018 at 12:05:56PM +0100, Alexander Graf wrote:
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.
Signed-off-by: Alexander Graf agraf@suse.de
Applied to u-boot/master, thanks!
participants (4)
-
Alexander Graf
-
Derald D. Woods
-
Tom Rini
-
Wolfgang Denk