From 4fb8bf61c02a5c9534201e5aefa50abeecb7393d Mon Sep 17 00:00:00 2001 From: Wayne Ren Date: Wed, 29 May 2019 14:58:02 +0800 Subject: [PATCH] drivers: ns16550: add WORD only access support In some hardware,e.g. ARC HS Development kit,the peripheral space of ns16550 only allowes WORD access, byte acess will raise bus error. This commit adds support for this case Signed-off-by: Wayne Ren --- drivers/serial/Kconfig.ns16550 | 9 +++++++++ drivers/serial/uart_ns16550.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/serial/Kconfig.ns16550 b/drivers/serial/Kconfig.ns16550 index 9cd88d08a1b..a46c52b62fe 100644 --- a/drivers/serial/Kconfig.ns16550 +++ b/drivers/serial/Kconfig.ns16550 @@ -32,6 +32,15 @@ config UART_NS16750 help This enables support for 64-bytes FIFO if UART controller is 16750. +config UART_NS16550_ACCESS_WORD_ONLY + bool "NS16550 only allows word access" + default n + depends on UART_NS16550 + help + In some case, e.g. ARC HS Development kit, the peripheral space of ns + 16550 (DesignWare UART) only allows word access, byte access will raise + exception. + # ---------- Port 0 ---------- menuconfig UART_NS16550_PORT_0 diff --git a/drivers/serial/uart_ns16550.c b/drivers/serial/uart_ns16550.c index 575c3399fd8..2cc1114640f 100644 --- a/drivers/serial/uart_ns16550.c +++ b/drivers/serial/uart_ns16550.c @@ -241,6 +241,13 @@ BUILD_ASSERT_MSG(IS_ENABLED(CONFIG_PCIE), "NS16550(s) in DT need CONFIG_PCIE"); #endif #endif /* UART_NS16550_ACCESS_IOPORT */ +#ifdef CONFIG_UART_NS16550_ACCESS_WORD_ONLY +#undef INBYTE +#define INBYTE(x) INWORD(x) +#undef OUTBYTE +#define OUTBYTE(x, d) OUTWORD(x, d) +#endif + struct uart_ns16550_device_config { u32_t sys_clk_freq;