From e740818093c40551d03dcedb858552b2f255beff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Tue, 3 Mar 2020 22:25:52 +0200 Subject: [PATCH] driver: uart: ns16550: convert custom init options to DTS flow control MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sole purpose of init options has been to enable hardware flow control on NS16750 when asked. Use the proper DTS tags for this. Signed-off-by: Timo Teräs --- .../xtensa/intel_s1000_crb/Kconfig.defconfig | 2 - drivers/serial/Kconfig.ns16550 | 54 +++---------------- drivers/serial/uart_ns16550.c | 5 +- drivers/serial/uart_ns16550_port_x.h | 6 ++- include/drivers/uart.h | 5 -- soc/nios2/nios2f-zephyr/Kconfig.defconfig | 4 -- soc/x86/atom/Kconfig.defconfig | 8 --- soc/x86/ia32/Kconfig.defconfig | 8 --- 8 files changed, 14 insertions(+), 78 deletions(-) diff --git a/boards/xtensa/intel_s1000_crb/Kconfig.defconfig b/boards/xtensa/intel_s1000_crb/Kconfig.defconfig index 803d0860061..fbead968776 100644 --- a/boards/xtensa/intel_s1000_crb/Kconfig.defconfig +++ b/boards/xtensa/intel_s1000_crb/Kconfig.defconfig @@ -92,8 +92,6 @@ config UART_NS16550_PORT_0 if UART_NS16550_PORT_0 -config UART_NS16550_PORT_0_OPTIONS - default 0 config UART_INTERRUPT_DRIVEN default y diff --git a/drivers/serial/Kconfig.ns16550 b/drivers/serial/Kconfig.ns16550 index 0dd71c3764d..07c0631b0f2 100644 --- a/drivers/serial/Kconfig.ns16550 +++ b/drivers/serial/Kconfig.ns16550 @@ -27,10 +27,11 @@ config UART_NS16550_DRV_CMD Says n if not sure. config UART_NS16750 - bool "Enable 64-bytes FIFO for UART 16750" + bool "Enable UART 16750 (64-bytes FIFO and auto flow control)" depends on UART_NS16550 help - This enables support for 64-bytes FIFO if UART controller is 16750. + This enables support for 64-bytes FIFO and automatic hardware + flow control if UART controller is 16750. config UART_NS16550_ACCESS_WORD_ONLY bool "NS16550 only allows word access" @@ -40,67 +41,26 @@ config UART_NS16550_ACCESS_WORD_ONLY 16550 (DesignWare UART) only allows word access, byte access will raise exception. -# ---------- Port 0 ---------- - menuconfig UART_NS16550_PORT_0 bool "Enable NS16550 Port 0" depends on UART_NS16550 help - This tells the driver to configure the UART port at boot, depending on - the additional configure options below. - -config UART_NS16550_PORT_0_OPTIONS - int "Port 0 Options" - default 0 - depends on UART_NS16550_PORT_0 - help - Options used for port initialization. - -# ---------- Port 1 ---------- + This tells the driver to configure the UART port at boot. menuconfig UART_NS16550_PORT_1 bool "Enable NS16550 Port 1" depends on UART_NS16550 help - This tells the driver to configure the UART port at boot, depending on - the additional configure options below. - -config UART_NS16550_PORT_1_OPTIONS - int "Port 1 Options" - default 0 - depends on UART_NS16550_PORT_1 - help - Options used for port initialization. - -# ---------- Port 2 ---------- + This tells the driver to configure the UART port at boot. menuconfig UART_NS16550_PORT_2 bool "Enable NS16550 Port 2" depends on UART_NS16550 help - This tells the driver to configure the UART port at boot, depending on - the additional configure options below. - - -config UART_NS16550_PORT_2_OPTIONS - int "Port 2 Options" - default 0 - depends on UART_NS16550_PORT_2 - help - Options used for port initialization. - -# ---------- Port 3 ---------- + This tells the driver to configure the UART port at boot. menuconfig UART_NS16550_PORT_3 bool "Enable NS16550 Port 3" depends on UART_NS16550 help - This tells the driver to configure the UART port at boot, depending on - the additional configure options below. - -config UART_NS16550_PORT_3_OPTIONS - int "Port 3 Options" - default 0 - depends on UART_NS16550_PORT_3 - help - Options used for port initialization. + This tells the driver to configure the UART port at boot. diff --git a/drivers/serial/uart_ns16550.c b/drivers/serial/uart_ns16550.c index 605d867fc95..05cf78efa6d 100644 --- a/drivers/serial/uart_ns16550.c +++ b/drivers/serial/uart_ns16550.c @@ -268,7 +268,6 @@ struct uart_ns16550_device_config { /** Device data structure */ struct uart_ns16550_dev_data_t { struct uart_config uart_config; - u8_t options; /**< Serial port options */ #ifdef CONFIG_UART_INTERRUPT_DRIVEN u8_t iir_cache; /**< cache of IIR since it clears when read */ @@ -402,9 +401,11 @@ static int uart_ns16550_configure(struct device *dev, uart_cfg.data_bits | uart_cfg.stop_bits | uart_cfg.parity); mdc = MCR_OUT2 | MCR_RTS | MCR_DTR; - if ((dev_data->options & UART_OPTION_AFCE) == UART_OPTION_AFCE) { +#ifdef CONFIG_UART_NS16750 + if (cfg->flow_ctrl == UART_CFG_FLOW_CTRL_RTS_CTS) { mdc |= MCR_AFCE; } +#endif OUTBYTE(MDC(dev), mdc); diff --git a/drivers/serial/uart_ns16550_port_x.h b/drivers/serial/uart_ns16550_port_x.h index 103bfaa0b0e..28b9f44500a 100644 --- a/drivers/serial/uart_ns16550_port_x.h +++ b/drivers/serial/uart_ns16550_port_x.h @@ -35,9 +35,11 @@ static struct uart_ns16550_dev_data_t uart_ns16550_dev_data_@NUM@ = { .uart_config.parity = UART_CFG_PARITY_NONE, .uart_config.stop_bits = UART_CFG_STOP_BITS_1, .uart_config.data_bits = UART_CFG_DATA_BITS_8, +#if DT_UART_NS16550_PORT_@NUM@_HW_FLOW_CONTROL + .uart_config.flow_ctrl = UART_CFG_FLOW_CTRL_RTS_CTS, +#else .uart_config.flow_ctrl = UART_CFG_FLOW_CTRL_NONE, - .options = CONFIG_UART_NS16550_PORT_@NUM@_OPTIONS, - +#endif #ifdef DT_UART_NS16550_PORT_@NUM@_DLF .dlf = DT_UART_NS16550_PORT_@NUM@_DLF, #endif diff --git a/include/drivers/uart.h b/include/drivers/uart.h index 06715d0c726..da05b100fbb 100644 --- a/include/drivers/uart.h +++ b/include/drivers/uart.h @@ -232,11 +232,6 @@ struct uart_event { */ typedef void (*uart_callback_t)(struct uart_event *evt, void *user_data); -/** - * @brief Options for @a UART initialization. - */ -#define UART_OPTION_AFCE 0x01 - /** * @brief UART controller configuration structure * diff --git a/soc/nios2/nios2f-zephyr/Kconfig.defconfig b/soc/nios2/nios2f-zephyr/Kconfig.defconfig index 90aa62a0f36..6cc21e38cf0 100644 --- a/soc/nios2/nios2f-zephyr/Kconfig.defconfig +++ b/soc/nios2/nios2f-zephyr/Kconfig.defconfig @@ -28,10 +28,6 @@ if UART_NS16550 config UART_NS16550_PORT_0 default y -config UART_NS16550_PORT_0_OPTIONS - default 0 - depends on UART_NS16550_PORT_0 - endif # UART_NS16550 endif # SOC_NIOS2F_ZEPHYR diff --git a/soc/x86/atom/Kconfig.defconfig b/soc/x86/atom/Kconfig.defconfig index 406dc6a51b5..43077a4f5c3 100644 --- a/soc/x86/atom/Kconfig.defconfig +++ b/soc/x86/atom/Kconfig.defconfig @@ -20,17 +20,9 @@ if UART_NS16550 config UART_NS16550_PORT_0 default y -config UART_NS16550_PORT_0_OPTIONS - default 0 - depends on UART_NS16550_PORT_0 - config UART_NS16550_PORT_1 default y -config UART_NS16550_PORT_1_OPTIONS - default 0 - depends on UART_NS16550_PORT_1 - endif # UART_NS16550 if BT_UART diff --git a/soc/x86/ia32/Kconfig.defconfig b/soc/x86/ia32/Kconfig.defconfig index c7f49022b98..e9f831c8790 100644 --- a/soc/x86/ia32/Kconfig.defconfig +++ b/soc/x86/ia32/Kconfig.defconfig @@ -20,17 +20,9 @@ if UART_NS16550 config UART_NS16550_PORT_0 default y -config UART_NS16550_PORT_0_OPTIONS - default 0 - depends on UART_NS16550_PORT_0 - config UART_NS16550_PORT_1 default y -config UART_NS16550_PORT_1_OPTIONS - default 0 - depends on UART_NS16550_PORT_1 - endif # UART_NS16550 endif