
Am 12.08.2016 um 00:38 schrieb Simon Glass sjg@chromium.org:
Hi Alex,
On 11 August 2016 at 05:38, Alexander Graf agraf@suse.de wrote: 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 4c8253d..20b0d1b 100644 --- a/board/raspberrypi/rpi/rpi.c +++ b/board/raspberrypi/rpi/rpi.c @@ -453,6 +453,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;
Do you mean gpio_get_function()?
That only tells me whether it's in/out/other, but I need to know whether the pin is configured to exactly function 5.
Alex