forked from pool/u-boot
36c65f2eed
1 OBS-URL: https://build.opensuse.org/request/show/419605 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/u-boot?expand=0&rev=78
104 lines
3.1 KiB
Diff
104 lines
3.1 KiB
Diff
From 44febd54d6cd3b5d8c2957fc30c1d17d79bebf56 Mon Sep 17 00:00:00 2001
|
|
From: Alexander Graf <agraf@suse.de>
|
|
Date: Thu, 4 Aug 2016 09:04:18 +0200
|
|
Subject: [PATCH] serial: bcm283x_mu: Detect disabled serial device
|
|
|
|
On the raspberry pi, you can disable the serial port to gain dynamic frequency
|
|
scaling which can get handy at times.
|
|
|
|
However, in such a configuration the serial controller gets its rx queue filled
|
|
up with zero bytes which then happily get transmitted on to whoever calls
|
|
getc() today.
|
|
|
|
This patch adds detection logic for that case by checking whether the RX pin is
|
|
mapped to GPIO15 and disables the mini uart if it is not mapped properly.
|
|
|
|
That way we can leave the driver enabled in the tree and can determine during
|
|
runtime whether serial is usable or not, having a single binary that allows for
|
|
uart and non-uart operation.
|
|
|
|
Signed-off-by: Alexander Graf <agraf@suse.de>
|
|
|
|
---
|
|
|
|
v2 -> v3:
|
|
|
|
- Disable and detect pinmux in board file
|
|
---
|
|
board/raspberrypi/rpi/rpi.c | 29 +++++++++++++++++++++++++++++
|
|
configs/rpi_3_32b_defconfig | 1 +
|
|
configs/rpi_3_defconfig | 1 +
|
|
include/configs/rpi.h | 1 +
|
|
4 files changed, 32 insertions(+)
|
|
|
|
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
|
|
index a2336fc..feaa21e 100644
|
|
--- a/board/raspberrypi/rpi/rpi.c
|
|
+++ b/board/raspberrypi/rpi/rpi.c
|
|
@@ -451,6 +451,35 @@ int board_init(void)
|
|
return power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
|
|
}
|
|
|
|
+static bool rpi_is_serial_active(void)
|
|
+{
|
|
+#ifndef CONFIG_PL01X_SERIAL
|
|
+ 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 pin is muxed.
|
|
+ */
|
|
+ if (uclass_first_device(UCLASS_GPIO, &dev) || !dev)
|
|
+ return true;
|
|
+
|
|
+ if (bcm2835_gpio_get_func_id(dev, serial_gpio) != BCM2835_GPIO_ALT5)
|
|
+ return false;
|
|
+#endif
|
|
+
|
|
+ return true;
|
|
+}
|
|
+
|
|
+int board_late_init(void)
|
|
+{
|
|
+ /* Disable mini-UART I/O if it's not pinmuxed to our pins */
|
|
+ if (!rpi_is_serial_active())
|
|
+ gd->cur_serial_dev = NULL;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
int board_mmc_init(bd_t *bis)
|
|
{
|
|
ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1);
|
|
diff --git a/configs/rpi_3_32b_defconfig b/configs/rpi_3_32b_defconfig
|
|
index 922e01b..4c2f106 100644
|
|
--- a/configs/rpi_3_32b_defconfig
|
|
+++ b/configs/rpi_3_32b_defconfig
|
|
@@ -20,3 +20,4 @@ CONFIG_CMD_FAT=y
|
|
CONFIG_CMD_FS_GENERIC=y
|
|
CONFIG_PHYS_TO_BUS=y
|
|
CONFIG_OF_LIBFDT=y
|
|
+# CONFIG_REQUIRE_SERIAL_CONSOLE is not set
|
|
diff --git a/configs/rpi_3_defconfig b/configs/rpi_3_defconfig
|
|
index bff92df..288214c 100644
|
|
--- a/configs/rpi_3_defconfig
|
|
+++ b/configs/rpi_3_defconfig
|
|
@@ -19,3 +19,4 @@ CONFIG_CMD_FAT=y
|
|
CONFIG_CMD_FS_GENERIC=y
|
|
CONFIG_PHYS_TO_BUS=y
|
|
CONFIG_OF_LIBFDT=y
|
|
+# CONFIG_REQUIRE_SERIAL_CONSOLE is not set
|
|
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
|
|
index b5543f4..e3b890a 100644
|
|
--- a/include/configs/rpi.h
|
|
+++ b/include/configs/rpi.h
|
|
@@ -22,6 +22,7 @@
|
|
|
|
/* Architecture, CPU, etc.*/
|
|
#define CONFIG_ARCH_CPU_INIT
|
|
+#define CONFIG_BOARD_LATE_INIT
|
|
|
|
/* Use SoC timer for AArch32, but architected timer for AArch64 */
|
|
#ifndef CONFIG_ARM64
|