Skip to content

Commit

Permalink
driver: uart: ns16550: convert to DT_INST_*
Browse files Browse the repository at this point in the history
Change to code to use the automatically generated DT_INST_*
defines and remove the now unneeded configs and fixups.

Signed-off-by: Timo Teräs <[email protected]>
  • Loading branch information
fabled authored and andrewboie committed Mar 14, 2020
1 parent e740818 commit 6fd168e
Show file tree
Hide file tree
Showing 49 changed files with 94 additions and 505 deletions.
2 changes: 1 addition & 1 deletion arch/x86/core/early_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

/* Super-primitive 8250/16550 serial output-only driver, 115200 8n1 */

#define PORT ((io_port_t)DT_UART_NS16550_PORT_0_BASE_ADDR)
#define PORT ((io_port_t)DT_INST_0_NS16550_BASE_ADDRESS)

#define REG_IER 0x01 /* Interrupt enable reg. */
#define REG_LCR 0x03 /* Line control reg. */
Expand Down
4 changes: 0 additions & 4 deletions boards/arc/em_starterkit/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ config UART_NS16550
default y
depends on SERIAL

config UART_NS16550_PORT_1
default y
depends on UART_CONSOLE

if SPI

config SPI_DW
Expand Down
4 changes: 0 additions & 4 deletions boards/arc/emsdp/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,4 @@ config UART_NS16550
default y
depends on SERIAL

config UART_NS16550_PORT_0
default y
depends on UART_CONSOLE

endif # BOARD_EMSDP
1 change: 0 additions & 1 deletion boards/arm/bcm958401m2/bcm958401m2_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_NS16550=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_NS16550_PORT_1=y
CONFIG_CORTEX_M_SYSTICK=y
CONFIG_FLASH_SIZE=0
CONFIG_FLASH_BASE_ADDRESS=0x0
4 changes: 0 additions & 4 deletions boards/arm/mec1501modular_assy6885/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ if BOARD_MEC1501MODULAR_ASSY6885
config BOARD
default "mec1501modular_assy6885"

config UART_NS16550_PORT_1
default y if UART_CONSOLE
depends on UART_NS16550

if PINMUX_XEC

config PINMUX_XEC_GPIO000_036
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/mec1501modular_assy6885/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int board_pinmux_init(struct device *dev)
pinmux_pin_set(portf, MCHP_GPIO_250, MCHP_GPIO_CTRL_MUX_F0);

/* See table 2-4 from the data sheet for pin multiplexing*/
#ifdef CONFIG_UART_NS16550_PORT_1
#ifdef DT_NS16550_400F2800_BASE_ADDRESS
/* Set muxing, for UART 1 TX/RX and power up */
mchp_pcr_periph_slp_ctrl(PCR_UART1, MCHP_PCR_SLEEP_DIS);

Expand Down
4 changes: 0 additions & 4 deletions boards/arm/mec15xxevb_assy6853/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ if BOARD_MEC15XXEVB_ASSY6853
config BOARD
default "mec15xxevb_assy6853"

config UART_NS16550_PORT_2
default y if UART_CONSOLE
depends on UART_NS16550

if PINMUX_XEC

config PINMUX_XEC_GPIO000_036
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/mec15xxevb_assy6853/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ static int board_pinmux_init(struct device *dev)
pinmux_pin_set(portf, MCHP_GPIO_250, MCHP_GPIO_CTRL_MUX_F0);

/* See table 2-4 from the data sheet for pin multiplexing*/
#ifdef CONFIG_UART_NS16550_PORT_2
#ifdef DT_NS16550_400F2C00_BASE_ADDRESS
/* Set muxing, for UART 2 TX/RX and power up */
mchp_pcr_periph_slp_ctrl(PCR_UART2, MCHP_PCR_SLEEP_DIS);

Expand Down
4 changes: 0 additions & 4 deletions boards/arm/mec2016evb_assy6797/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ if BOARD_MEC2016EVB_ASSY6797
config BOARD
default "mec2016evb_assy6797"

config UART_NS16550_PORT_0
default y if UART_CONSOLE
depends on UART_NS16550

endif # BOARD_MEC2016EVB_ASSY6797
4 changes: 2 additions & 2 deletions boards/arm/mec2016evb_assy6797/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static int board_pinmux_init(struct device *dev)
ARG_UNUSED(dev);

/* See table 2-4 from the Data sheet*/
#ifdef CONFIG_UART_NS16550_PORT_0
#ifdef DT_NS16550_400F2400_BASE_ADDRESS
/* Set muxing, for UART 0 and power up */
PCR_INST->CLK_REQ_2_b.UART_0_CLK_REQ = 1;
UART0_INST->CONFIG = 0;
Expand All @@ -24,7 +24,7 @@ static int board_pinmux_init(struct device *dev)
GPIO_100_137_INST->GPIO_105_PIN_CONTROL_b.MUX_CONTROL = 1;
#endif

#ifdef CONFIG_UART_NS16550_PORT_1
#ifdef DT_NS16550_400F2800_BASE_ADDRESS
/* Set muxing, for UART 1 and power up */
PCR_INST->CLK_REQ_2_b.UART_1_CLK_REQ = 1;
UART1_INST->CONFIG = 0;
Expand Down
1 change: 0 additions & 1 deletion boards/nios2/qemu_nios2/qemu_nios2_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ CONFIG_PRINTK=y
CONFIG_SERIAL=y
CONFIG_UART_ALTERA_JTAG=y
CONFIG_UART_NS16550=y
CONFIG_UART_NS16550_PORT_0=y
CONFIG_UART_CONSOLE=y
CONFIG_INCLUDE_RESET_VECTOR=n
CONFIG_EXTRA_EXCEPTION_INFO=y
16 changes: 0 additions & 16 deletions boards/x86/gpmrb/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,6 @@ config BOARD
config BUILD_OUTPUT_STRIPPED
default y

if UART_NS16550

config UART_NS16550_PORT_0
default y

config UART_NS16550_PORT_1
default y

config UART_NS16550_PORT_2
default y

config UART_NS16550_PORT_3
default y

endif # UART_NS16550

if I2C

config I2C_0
Expand Down
10 changes: 0 additions & 10 deletions boards/x86/up_squared/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ config BOARD
config BUILD_OUTPUT_STRIPPED
default y

if UART_NS16550

config UART_NS16550_PORT_0
default y

config UART_NS16550_PORT_1
default y

endif # UART_NS16550

if I2C

config I2C_0
Expand Down
11 changes: 2 additions & 9 deletions boards/xtensa/intel_s1000_crb/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,12 @@ config USB_DEVICE_PRODUCT

endif # USB

if UART_NS16550

config UART_NS16550_PORT_0
default y

if UART_NS16550_PORT_0
if SERIAL

config UART_INTERRUPT_DRIVEN
default y

endif # UART_NS16550_PORT_0

endif # UART_NS16550
endif # SERIAL

if I2C

Expand Down
12 changes: 5 additions & 7 deletions drivers/serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ zephyr_library_sources_ifdef(CONFIG_USERSPACE uart_handlers.c)
if(CONFIG_UART_NS16550)
zephyr_library_sources(uart_ns16550.c)
foreach(NUM RANGE 0 3)
if (CONFIG_UART_NS16550_PORT_${NUM})
configure_file(
uart_ns16550_port_x.h
${PROJECT_BINARY_DIR}/include/generated/uart_ns16550_port_${NUM}.h
@ONLY
)
endif()
configure_file(
uart_ns16550_port_x.h
${PROJECT_BINARY_DIR}/include/generated/uart_ns16550_port_${NUM}.h
@ONLY
)
endforeach(NUM)
endif()

Expand Down
24 changes: 0 additions & 24 deletions drivers/serial/Kconfig.ns16550
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,3 @@ config UART_NS16550_ACCESS_WORD_ONLY
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.

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.

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.

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.

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.
40 changes: 15 additions & 25 deletions drivers/serial/uart_ns16550.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@
* Ditto for DLF and PCI(e).
*/

#if defined(DT_UART_NS16550_PORT_0_PCP) || \
defined(DT_UART_NS16550_PORT_1_PCP) || \
defined(DT_UART_NS16550_PORT_2_PCP) || \
defined(DT_UART_NS16550_PORT_3_PCP)
#if defined(DT_INST_0_NS16550_PCP) || \
defined(DT_INST_1_NS16550_PCP) || \
defined(DT_INST_2_NS16550_PCP) || \
defined(DT_INST_3_NS16550_PCP)
#define UART_NS16550_PCP_ENABLED
#endif

#if defined(DT_UART_NS16550_PORT_0_DLF) || \
defined(DT_UART_NS16550_PORT_1_DLF) || \
defined(DT_UART_NS16550_PORT_2_DLF) || \
defined(DT_UART_NS16550_PORT_3_DLF)
#if defined(DT_INST_0_NS16550_DLF) || \
defined(DT_INST_1_NS16550_DLF) || \
defined(DT_INST_2_NS16550_DLF) || \
defined(DT_INST_3_NS16550_DLF)
#define UART_NS16550_DLF_ENABLED
#endif

#if DT_UART_NS16550_PORT_0_PCIE || \
DT_UART_NS16550_PORT_1_PCIE || \
DT_UART_NS16550_PORT_2_PCIE || \
DT_UART_NS16550_PORT_3_PCIE
#if DT_INST_0_NS16550_PCIE || \
DT_INST_1_NS16550_PCIE || \
DT_INST_2_NS16550_PCIE || \
DT_INST_3_NS16550_PCIE
BUILD_ASSERT_MSG(IS_ENABLED(CONFIG_PCIE), "NS16550(s) in DT need CONFIG_PCIE");
#define UART_NS16550_PCIE_ENABLED
#include <drivers/pcie/pcie.h>
Expand Down Expand Up @@ -222,8 +222,8 @@ BUILD_ASSERT_MSG(IS_ENABLED(CONFIG_PCIE), "NS16550(s) in DT need CONFIG_PCIE");

#define IIRC(dev) (DEV_DATA(dev)->iir_cache)

#ifdef DT_NS16550_REG_SHIFT
#define UART_REG_ADDR_INTERVAL (1<<DT_NS16550_REG_SHIFT)
#ifdef DT_INST_0_NS16550_REG_SHIFT
#define UART_REG_ADDR_INTERVAL (1<<DT_INST_0_NS16550_REG_SHIFT)
#endif

#ifdef UART_NS16550_ACCESS_IOPORT
Expand Down Expand Up @@ -319,6 +319,7 @@ static int uart_ns16550_configure(struct device *dev,
unsigned int old_level; /* old interrupt lock level */
u8_t mdc = 0U;

ARG_UNUSED(dev_data);
ARG_UNUSED(dev_cfg);

#ifdef UART_NS16550_PCIE_ENABLED
Expand Down Expand Up @@ -843,18 +844,7 @@ static const struct uart_driver_api uart_ns16550_driver_api = {
#endif
};

#ifdef CONFIG_UART_NS16550_PORT_0
#include <uart_ns16550_port_0.h>
#endif

#ifdef CONFIG_UART_NS16550_PORT_1
#include <uart_ns16550_port_1.h>
#endif

#ifdef CONFIG_UART_NS16550_PORT_2
#include <uart_ns16550_port_2.h>
#endif

#ifdef CONFIG_UART_NS16550_PORT_3
#include <uart_ns16550_port_3.h>
#endif
Loading

0 comments on commit 6fd168e

Please sign in to comment.