summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2016-08-15 17:48:51 +0200
committerTom Rini <trini@konsulko.com>2016-09-06 13:18:19 -0400
commit601147b06a708900c5352dc3dcc5d64271bf0d62 (patch)
tree6edb09d09ac433ea4b296a7c1a8dcc3482c0972e /board
parent04a993fe116604b8c81fb116857dbc78e2500133 (diff)
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> Acked-by: Stephen Warren <swarren@wwwdotorg.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'board')
-rw-r--r--board/raspberrypi/rpi/rpi.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index fbfbf6cbbc..6245b3678f 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -50,7 +50,7 @@ U_BOOT_DEVICE(bcm2835_serials) = {
.platdata = &serial_platdata,
};
#else
-static const struct bcm283x_mu_serial_platdata serial_platdata = {
+static struct bcm283x_mu_serial_platdata serial_platdata = {
.base = 0x3f215040,
.clock = 250000000,
.skip_init = true,
@@ -452,6 +452,38 @@ int board_init(void)
return power_on_module(BCM2835_MBOX_POWER_DEVID_USB_HCD);
}
+#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_GPIO, &dev) || !dev)
+ return true;
+
+ if (bcm2835_gpio_get_func_id(dev, serial_gpio) != BCM2835_GPIO_ALT5)
+ return false;
+
+ return true;
+}
+#endif
+
+int board_early_init_f(void)
+{
+#ifndef CONFIG_PL01X_SERIAL
+ /* Disable mini-UART I/O if it's not pinmuxed to our pins */
+ if (!rpi_is_serial_active())
+ serial_platdata.disabled = true;
+#endif
+
+ return 0;
+}
+
int board_mmc_init(bd_t *bis)
{
ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_clock_rate, msg_clk, 1);