diff options
author | Tom Rini <trini@konsulko.com> | 2020-07-27 21:40:26 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-07-27 21:40:26 -0400 |
commit | 6b7937821dfdd53a7a733b3f723de1d84500247d (patch) | |
tree | b9b50ac92509f7e7728fb4e829af607769337275 /drivers/serial/serial_meson.c | |
parent | 8d1fc6fb89826efb6bbbedb57862496e18737877 (diff) | |
parent | 95ca2df3fd8f7b2cc995bccb2b46cd5650c4a9a7 (diff) | |
download | u-boot-6b7937821dfdd53a7a733b3f723de1d84500247d.tar.gz |
Merge tag 'u-boot-amlogic-20200727' of https://gitlab.denx.de/u-boot/custodians/u-boot-amlogic
- Handle errors in Meson serial driver
- Enable HDMI, keyboard and ADC for Odroid-C2
Diffstat (limited to 'drivers/serial/serial_meson.c')
-rw-r--r-- | drivers/serial/serial_meson.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/drivers/serial/serial_meson.c b/drivers/serial/serial_meson.c index 8cf849f8fe..496a2ca2c3 100644 --- a/drivers/serial/serial_meson.c +++ b/drivers/serial/serial_meson.c @@ -65,14 +65,36 @@ static int meson_serial_probe(struct udevice *dev) return 0; } +static void meson_serial_rx_error(struct udevice *dev) +{ + struct meson_serial_platdata *plat = dev->platdata; + struct meson_uart *const uart = plat->reg; + u32 val = readl(&uart->control); + + /* Clear error */ + val |= AML_UART_CLR_ERR; + writel(val, &uart->control); + val &= ~AML_UART_CLR_ERR; + writel(val, &uart->control); + + /* Remove spurious byte from fifo */ + readl(&uart->rfifo); +} + static int meson_serial_getc(struct udevice *dev) { struct meson_serial_platdata *plat = dev->platdata; struct meson_uart *const uart = plat->reg; + uint32_t status = readl(&uart->status); - if (readl(&uart->status) & AML_UART_RX_EMPTY) + if (status & AML_UART_RX_EMPTY) return -EAGAIN; + if (status & AML_UART_ERR) { + meson_serial_rx_error(dev); + return -EIO; + } + return readl(&uart->rfifo) & 0xff; } @@ -95,10 +117,23 @@ static int meson_serial_pending(struct udevice *dev, bool input) struct meson_uart *const uart = plat->reg; uint32_t status = readl(&uart->status); - if (input) - return !(status & AML_UART_RX_EMPTY); - else + if (input) { + if (status & AML_UART_RX_EMPTY) + return false; + + /* + * Handle and drop any RX error here to avoid + * returning true here when an error byte is in the FIFO + */ + if (status & AML_UART_ERR) { + meson_serial_rx_error(dev); + return false; + } + + return true; + } else { return !(status & AML_UART_TX_FULL); + } } static int meson_serial_ofdata_to_platdata(struct udevice *dev) |