From d30c7209dfb4c6e4f38f8b42354e44885b53f301 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 22 Dec 2020 19:30:18 -0700 Subject: [PATCH] serial: Update NS16550_t and struct NS16550 Typedefs should not be used in U-Boot and structs should be lower case. Update the code to use struct ns16550 consistently. Put a header guard on the file while we are here. Signed-off-by: Simon Glass Reviewed-by: Andy Shevchenko --- arch/arm/mach-davinci/da850_lowlevel.c | 4 +- arch/arm/mach-davinci/spl.c | 4 +- arch/arm/mach-keystone/init.c | 2 +- arch/x86/cpu/apollolake/uart.c | 2 +- arch/x86/cpu/slimbootloader/serial.c | 2 +- board/Arcturus/ucp1020/spl.c | 2 +- board/Arcturus/ucp1020/spl_minimal.c | 6 +-- board/Synology/ds109/ds109.c | 8 ++-- board/freescale/mpc8313erdb/mpc8313erdb.c | 6 +-- board/freescale/mpc8315erdb/mpc8315erdb.c | 6 +-- board/freescale/p1010rdb/spl.c | 2 +- board/freescale/p1010rdb/spl_minimal.c | 8 ++-- board/freescale/p1_p2_rdb_pc/spl.c | 2 +- board/freescale/p1_p2_rdb_pc/spl_minimal.c | 8 ++-- board/freescale/t102xrdb/spl.c | 2 +- board/freescale/t104xrdb/spl.c | 2 +- board/freescale/t208xqds/spl.c | 2 +- board/freescale/t208xrdb/spl.c | 2 +- board/freescale/t4rdb/spl.c | 2 +- drivers/serial/ns16550.c | 44 +++++++++++----------- drivers/serial/serial_coreboot.c | 2 +- drivers/serial/serial_intel_mid.c | 2 +- drivers/serial/serial_ns16550.c | 14 +++---- drivers/serial/serial_omap.c | 6 +-- drivers/serial/serial_rockchip.c | 4 +- include/ns16550.h | 21 ++++++----- lib/efi/efi_stub.c | 2 +- 27 files changed, 85 insertions(+), 82 deletions(-) diff --git a/arch/arm/mach-davinci/da850_lowlevel.c b/arch/arm/mach-davinci/da850_lowlevel.c index 07bf19b5e4..6994ded2c6 100644 --- a/arch/arm/mach-davinci/da850_lowlevel.c +++ b/arch/arm/mach-davinci/da850_lowlevel.c @@ -290,8 +290,8 @@ int arch_cpu_init(void) board_gpio_init(); #if !CONFIG_IS_ENABLED(DM_SERIAL) - NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM1), - CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); + NS16550_init((struct ns16550 *)(CONFIG_SYS_NS16550_COM1), + CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); #endif /* * Fix Power and Emulation Management Register diff --git a/arch/arm/mach-davinci/spl.c b/arch/arm/mach-davinci/spl.c index 5fea935d6e..3c8330b47f 100644 --- a/arch/arm/mach-davinci/spl.c +++ b/arch/arm/mach-davinci/spl.c @@ -27,9 +27,9 @@ void puts(const char *str) void putc(char c) { if (c == '\n') - NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), '\r'); + NS16550_putc((struct ns16550 *)(CONFIG_SYS_NS16550_COM1), '\r'); - NS16550_putc((NS16550_t)(CONFIG_SYS_NS16550_COM1), c); + NS16550_putc((struct ns16550 *)(CONFIG_SYS_NS16550_COM1), c); } #endif /* CONFIG_SPL_LIBCOMMON_SUPPORT */ diff --git a/arch/arm/mach-keystone/init.c b/arch/arm/mach-keystone/init.c index 88e8912959..f4edaaaaac 100644 --- a/arch/arm/mach-keystone/init.c +++ b/arch/arm/mach-keystone/init.c @@ -185,7 +185,7 @@ int arch_cpu_init(void) * driver doesn't handle this. */ #ifndef CONFIG_DM_SERIAL - NS16550_init((NS16550_t)(CONFIG_SYS_NS16550_COM2), + NS16550_init((struct ns16550 *)(CONFIG_SYS_NS16550_COM2), CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); #endif diff --git a/arch/x86/cpu/apollolake/uart.c b/arch/x86/cpu/apollolake/uart.c index 26aef655be..8e6dfdb630 100644 --- a/arch/x86/cpu/apollolake/uart.c +++ b/arch/x86/cpu/apollolake/uart.c @@ -127,7 +127,7 @@ U_BOOT_DRIVER(intel_apl_ns16550) = { .id = UCLASS_SERIAL, .of_match = apl_ns16550_serial_ids, .plat_auto = sizeof(struct ns16550_plat), - .priv_auto = sizeof(struct NS16550), + .priv_auto = sizeof(struct ns16550), .ops = &ns16550_serial_ops, .of_to_plat = apl_ns16550_of_to_plat, .probe = apl_ns16550_probe, diff --git a/arch/x86/cpu/slimbootloader/serial.c b/arch/x86/cpu/slimbootloader/serial.c index 5d8963220d..ebbd2c552f 100644 --- a/arch/x86/cpu/slimbootloader/serial.c +++ b/arch/x86/cpu/slimbootloader/serial.c @@ -59,7 +59,7 @@ U_BOOT_DRIVER(serial_slimbootloader) = { .of_match = slimbootloader_serial_ids, .of_to_plat = slimbootloader_serial_of_to_plat, .plat_auto = sizeof(struct ns16550_plat), - .priv_auto = sizeof(struct NS16550), + .priv_auto = sizeof(struct ns16550), .probe = ns16550_serial_probe, .ops = &ns16550_serial_ops, }; diff --git a/board/Arcturus/ucp1020/spl.c b/board/Arcturus/ucp1020/spl.c index 0fd9532d74..8e607558f4 100644 --- a/board/Arcturus/ucp1020/spl.c +++ b/board/Arcturus/ucp1020/spl.c @@ -58,7 +58,7 @@ void board_init_f(ulong bootflag) bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; gd->bus_clk = bus_clk; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, bus_clk / 16 / CONFIG_BAUDRATE); #ifdef CONFIG_SPL_MMC_BOOT puts("\nSD boot...\n"); diff --git a/board/Arcturus/ucp1020/spl_minimal.c b/board/Arcturus/ucp1020/spl_minimal.c index cd0022a73e..38d84afc9e 100644 --- a/board/Arcturus/ucp1020/spl_minimal.c +++ b/board/Arcturus/ucp1020/spl_minimal.c @@ -34,7 +34,7 @@ void board_init_f(ulong bootflag) plat_ratio >>= 1; gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, gd->bus_clk / 16 / CONFIG_BAUDRATE); puts("\nNAND boot... "); @@ -55,9 +55,9 @@ void board_init_r(gd_t *gd, ulong dest_addr) void putc(char c) { if (c == '\n') - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r'); + NS16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r'); - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c); + NS16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c); } void puts(const char *str) diff --git a/board/Synology/ds109/ds109.c b/board/Synology/ds109/ds109.c index aa2987d924..c36e4d37fc 100644 --- a/board/Synology/ds109/ds109.c +++ b/board/Synology/ds109/ds109.c @@ -106,10 +106,10 @@ void reset_misc(void) printf("Synology reset..."); udelay(50000); - b_d = ns16550_calc_divisor((NS16550_t)CONFIG_SYS_NS16550_COM2, - CONFIG_SYS_NS16550_CLK, 9600); - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM2, b_d); - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM2, SOFTWARE_REBOOT); + b_d = ns16550_calc_divisor((struct ns16550 *)CONFIG_SYS_NS16550_COM2, + CONFIG_SYS_NS16550_CLK, 9600); + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM2, b_d); + NS16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM2, SOFTWARE_REBOOT); } /* Support old kernels */ diff --git a/board/freescale/mpc8313erdb/mpc8313erdb.c b/board/freescale/mpc8313erdb/mpc8313erdb.c index 65a10c345a..69fa89146d 100644 --- a/board/freescale/mpc8313erdb/mpc8313erdb.c +++ b/board/freescale/mpc8313erdb/mpc8313erdb.c @@ -132,7 +132,7 @@ int ft_board_setup(void *blob, struct bd_info *bd) void board_init_f(ulong bootflag) { board_early_init_f(); - NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), + NS16550_init((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); puts("NAND boot... "); timer_init(); @@ -152,8 +152,8 @@ void putc(char c) return; if (c == '\n') - NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r'); + NS16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), '\r'); - NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c); + NS16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), c); } #endif diff --git a/board/freescale/mpc8315erdb/mpc8315erdb.c b/board/freescale/mpc8315erdb/mpc8315erdb.c index f8e4599f13..fff8699d61 100644 --- a/board/freescale/mpc8315erdb/mpc8315erdb.c +++ b/board/freescale/mpc8315erdb/mpc8315erdb.c @@ -220,7 +220,7 @@ int checkboard(void) void board_init_f(ulong bootflag) { board_early_init_f(); - NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), + NS16550_init((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); puts("NAND boot... "); timer_init(); @@ -240,9 +240,9 @@ void putc(char c) return; if (c == '\n') - NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r'); + NS16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), '\r'); - NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c); + NS16550_putc((struct ns16550 *)(CONFIG_SYS_IMMR + 0x4500), c); } #endif /* CONFIG_NAND_SPL */ diff --git a/board/freescale/p1010rdb/spl.c b/board/freescale/p1010rdb/spl.c index fbaa6a6514..c015a6bf36 100644 --- a/board/freescale/p1010rdb/spl.c +++ b/board/freescale/p1010rdb/spl.c @@ -44,7 +44,7 @@ void board_init_f(ulong bootflag) plat_ratio >>= 1; gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, gd->bus_clk / 16 / CONFIG_BAUDRATE); #ifdef CONFIG_SPL_MMC_BOOT diff --git a/board/freescale/p1010rdb/spl_minimal.c b/board/freescale/p1010rdb/spl_minimal.c index 0bb2c83872..4cc70ea352 100644 --- a/board/freescale/p1010rdb/spl_minimal.c +++ b/board/freescale/p1010rdb/spl_minimal.c @@ -31,8 +31,8 @@ void board_init_f(ulong bootflag) plat_ratio >>= 1; gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, - gd->bus_clk / 16 / CONFIG_BAUDRATE); + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, + gd->bus_clk / 16 / CONFIG_BAUDRATE); puts("\nNAND boot... "); @@ -53,9 +53,9 @@ void board_init_r(gd_t *gd, ulong dest_addr) void putc(char c) { if (c == '\n') - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r'); + NS16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r'); - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c); + NS16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c); } void puts(const char *str) diff --git a/board/freescale/p1_p2_rdb_pc/spl.c b/board/freescale/p1_p2_rdb_pc/spl.c index 8aceceb56a..0b8b8a7575 100644 --- a/board/freescale/p1_p2_rdb_pc/spl.c +++ b/board/freescale/p1_p2_rdb_pc/spl.c @@ -50,7 +50,7 @@ void board_init_f(ulong bootflag) bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; gd->bus_clk = bus_clk; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, bus_clk / 16 / CONFIG_BAUDRATE); #ifdef CONFIG_SPL_MMC_BOOT puts("\nSD boot...\n"); diff --git a/board/freescale/p1_p2_rdb_pc/spl_minimal.c b/board/freescale/p1_p2_rdb_pc/spl_minimal.c index ced5f3c3b5..7068e94a2d 100644 --- a/board/freescale/p1_p2_rdb_pc/spl_minimal.c +++ b/board/freescale/p1_p2_rdb_pc/spl_minimal.c @@ -30,8 +30,8 @@ void board_init_f(ulong bootflag) plat_ratio >>= 1; gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, - gd->bus_clk / 16 / CONFIG_BAUDRATE); + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, + gd->bus_clk / 16 / CONFIG_BAUDRATE); puts("\nNAND boot... "); @@ -51,9 +51,9 @@ void board_init_r(gd_t *gd, ulong dest_addr) void putc(char c) { if (c == '\n') - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, '\r'); + NS16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, '\r'); - NS16550_putc((NS16550_t)CONFIG_SYS_NS16550_COM1, c); + NS16550_putc((struct ns16550 *)CONFIG_SYS_NS16550_COM1, c); } void puts(const char *str) diff --git a/board/freescale/t102xrdb/spl.c b/board/freescale/t102xrdb/spl.c index 09dd88ac4e..d23b2f5fde 100644 --- a/board/freescale/t102xrdb/spl.c +++ b/board/freescale/t102xrdb/spl.c @@ -82,7 +82,7 @@ void board_init_f(ulong bootflag) plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; ccb_clk = sys_clk * plat_ratio / 2; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, ccb_clk / 16 / CONFIG_BAUDRATE); #if defined(CONFIG_SPL_MMC_BOOT) diff --git a/board/freescale/t104xrdb/spl.c b/board/freescale/t104xrdb/spl.c index e7922954de..a93cc38450 100644 --- a/board/freescale/t104xrdb/spl.c +++ b/board/freescale/t104xrdb/spl.c @@ -81,7 +81,7 @@ void board_init_f(ulong bootflag) plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; uart_clk = sys_clk * plat_ratio / 2; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, uart_clk / 16 / CONFIG_BAUDRATE); relocate_code(CONFIG_SPL_RELOC_STACK, (gd_t *)CONFIG_SPL_GD_ADDR, 0x0); diff --git a/board/freescale/t208xqds/spl.c b/board/freescale/t208xqds/spl.c index d8c2bbe28d..c6b23e4c69 100644 --- a/board/freescale/t208xqds/spl.c +++ b/board/freescale/t208xqds/spl.c @@ -81,7 +81,7 @@ void board_init_f(ulong bootflag) plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; ccb_clk = sys_clk * plat_ratio / 2; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, ccb_clk / 16 / CONFIG_BAUDRATE); #if defined(CONFIG_SPL_MMC_BOOT) diff --git a/board/freescale/t208xrdb/spl.c b/board/freescale/t208xrdb/spl.c index c64bd87115..4b84383016 100644 --- a/board/freescale/t208xrdb/spl.c +++ b/board/freescale/t208xrdb/spl.c @@ -51,7 +51,7 @@ void board_init_f(ulong bootflag) plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; ccb_clk = sys_clk * plat_ratio / 2; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, ccb_clk / 16 / CONFIG_BAUDRATE); #if defined(CONFIG_SPL_MMC_BOOT) diff --git a/board/freescale/t4rdb/spl.c b/board/freescale/t4rdb/spl.c index 9aa0a9b052..efe2b4eb95 100644 --- a/board/freescale/t4rdb/spl.c +++ b/board/freescale/t4rdb/spl.c @@ -60,7 +60,7 @@ void board_init_f(ulong bootflag) plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f; ccb_clk = sys_clk * plat_ratio / 2; - NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1, + NS16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1, ccb_clk / 16 / CONFIG_BAUDRATE); puts("\nSD boot...\n"); diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 8dd81ad794..d529b1b807 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -156,7 +156,7 @@ static inline int serial_in_dynamic(struct ns16550_plat *plat, u8 *addr) #endif /* CONFIG_NS16550_DYNAMIC */ -static void ns16550_writeb(NS16550_t port, int offset, int value) +static void ns16550_writeb(struct ns16550 *port, int offset, int value) { struct ns16550_plat *plat = port->plat; unsigned char *addr; @@ -170,7 +170,7 @@ static void ns16550_writeb(NS16550_t port, int offset, int value) serial_out_shift(addr, plat->reg_shift, value); } -static int ns16550_readb(NS16550_t port, int offset) +static int ns16550_readb(struct ns16550 *port, int offset) { struct ns16550_plat *plat = port->plat; unsigned char *addr; @@ -184,7 +184,7 @@ static int ns16550_readb(NS16550_t port, int offset) return serial_in_shift(addr, plat->reg_shift); } -static u32 ns16550_getfcr(NS16550_t port) +static u32 ns16550_getfcr(struct ns16550 *port) { struct ns16550_plat *plat = port->plat; @@ -199,20 +199,20 @@ static u32 ns16550_getfcr(NS16550_t port) ns16550_readb(com_port, \ (unsigned char *)addr - (unsigned char *)com_port) #else -static u32 ns16550_getfcr(NS16550_t port) +static u32 ns16550_getfcr(struct ns16550 *port) { return UART_FCR_DEFVAL; } #endif -int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate) +int ns16550_calc_divisor(struct ns16550 *port, int clock, int baudrate) { const unsigned int mode_x_div = 16; return DIV_ROUND_CLOSEST(clock, mode_x_div * baudrate); } -static void NS16550_setbrg(NS16550_t com_port, int baud_divisor) +static void NS16550_setbrg(struct ns16550 *com_port, int baud_divisor) { /* to keep serial format, read lcr before writing BKSE */ int lcr_val = serial_in(&com_port->lcr) & ~UART_LCR_BKSE; @@ -223,7 +223,7 @@ static void NS16550_setbrg(NS16550_t com_port, int baud_divisor) serial_out(lcr_val, &com_port->lcr); } -void NS16550_init(NS16550_t com_port, int baud_divisor) +void NS16550_init(struct ns16550 *com_port, int baud_divisor) { #if (defined(CONFIG_SPL_BUILD) && \ (defined(CONFIG_OMAP34XX) || defined(CONFIG_OMAP44XX))) @@ -272,7 +272,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor) } #ifndef CONFIG_NS16550_MIN_FUNCTIONS -void NS16550_reinit(NS16550_t com_port, int baud_divisor) +void NS16550_reinit(struct ns16550 *com_port, int baud_divisor) { serial_out(CONFIG_SYS_NS16550_IER, &com_port->ier); NS16550_setbrg(com_port, 0); @@ -282,7 +282,7 @@ void NS16550_reinit(NS16550_t com_port, int baud_divisor) } #endif /* CONFIG_NS16550_MIN_FUNCTIONS */ -void NS16550_putc(NS16550_t com_port, char c) +void NS16550_putc(struct ns16550 *com_port, char c) { while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0) ; @@ -299,7 +299,7 @@ void NS16550_putc(NS16550_t com_port, char c) } #ifndef CONFIG_NS16550_MIN_FUNCTIONS -char NS16550_getc(NS16550_t com_port) +char NS16550_getc(struct ns16550 *com_port) { while ((serial_in(&com_port->lsr) & UART_LSR_DR) == 0) { #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_USB_TTY) @@ -311,7 +311,7 @@ char NS16550_getc(NS16550_t com_port) return serial_in(&com_port->rbr); } -int NS16550_tstc(NS16550_t com_port) +int NS16550_tstc(struct ns16550 *com_port) { return (serial_in(&com_port->lsr) & UART_LSR_DR) != 0; } @@ -324,7 +324,7 @@ int NS16550_tstc(NS16550_t com_port) static inline void _debug_uart_init(void) { - struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; + struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE; int baud_divisor; /* @@ -345,7 +345,7 @@ static inline void _debug_uart_init(void) serial_dout(&com_port->lcr, UART_LCRVAL); } -static inline int NS16550_read_baud_divisor(struct NS16550 *com_port) +static inline int NS16550_read_baud_divisor(struct ns16550 *com_port) { int ret; @@ -359,7 +359,7 @@ static inline int NS16550_read_baud_divisor(struct NS16550 *com_port) static inline void _debug_uart_putc(int ch) { - struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; + struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE; while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) { #ifdef CONFIG_DEBUG_UART_NS16550_CHECK_ENABLED @@ -377,7 +377,7 @@ DEBUG_UART_FUNCS #if CONFIG_IS_ENABLED(DM_SERIAL) static int ns16550_serial_putc(struct udevice *dev, const char ch) { - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); if (!(serial_in(&com_port->lsr) & UART_LSR_THRE)) return -EAGAIN; @@ -397,7 +397,7 @@ static int ns16550_serial_putc(struct udevice *dev, const char ch) static int ns16550_serial_pending(struct udevice *dev, bool input) { - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); if (input) return (serial_in(&com_port->lsr) & UART_LSR_DR) ? 1 : 0; @@ -407,7 +407,7 @@ static int ns16550_serial_pending(struct udevice *dev, bool input) static int ns16550_serial_getc(struct udevice *dev) { - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); if (!(serial_in(&com_port->lsr) & UART_LSR_DR)) return -EAGAIN; @@ -417,7 +417,7 @@ static int ns16550_serial_getc(struct udevice *dev) static int ns16550_serial_setbrg(struct udevice *dev, int baudrate) { - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); struct ns16550_plat *plat = com_port->plat; int clock_divisor; @@ -430,7 +430,7 @@ static int ns16550_serial_setbrg(struct udevice *dev, int baudrate) static int ns16550_serial_setconfig(struct udevice *dev, uint serial_config) { - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); int lcr_val = UART_LCR_WLS_8; uint parity = SERIAL_GET_PARITY(serial_config); uint bits = SERIAL_GET_BITS(serial_config); @@ -464,7 +464,7 @@ static int ns16550_serial_setconfig(struct udevice *dev, uint serial_config) static int ns16550_serial_getinfo(struct udevice *dev, struct serial_device_info *info) { - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); struct ns16550_plat *plat = com_port->plat; info->type = SERIAL_CHIP_16550_COMPATIBLE; @@ -499,7 +499,7 @@ static int ns16550_serial_assign_base(struct ns16550_plat *plat, ulong base) int ns16550_serial_probe(struct udevice *dev) { struct ns16550_plat *plat = dev->plat; - struct NS16550 *const com_port = dev_get_priv(dev); + struct ns16550 *const com_port = dev_get_priv(dev); struct reset_ctl_bulk reset_bulk; fdt_addr_t addr; int ret; @@ -613,7 +613,7 @@ U_BOOT_DRIVER(ns16550_serial) = { .of_to_plat = ns16550_serial_of_to_plat, .plat_auto = sizeof(struct ns16550_plat), #endif - .priv_auto = sizeof(struct NS16550), + .priv_auto = sizeof(struct ns16550), .probe = ns16550_serial_probe, .ops = &ns16550_serial_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) diff --git a/drivers/serial/serial_coreboot.c b/drivers/serial/serial_coreboot.c index 904e1b306e..88c8209c5d 100644 --- a/drivers/serial/serial_coreboot.c +++ b/drivers/serial/serial_coreboot.c @@ -37,7 +37,7 @@ U_BOOT_DRIVER(coreboot_uart) = { .name = "coreboot_uart", .id = UCLASS_SERIAL, .of_match = coreboot_serial_ids, - .priv_auto = sizeof(struct NS16550), + .priv_auto = sizeof(struct ns16550), .plat_auto = sizeof(struct ns16550_plat), .of_to_plat = coreboot_of_to_plat, .probe = ns16550_serial_probe, diff --git a/drivers/serial/serial_intel_mid.c b/drivers/serial/serial_intel_mid.c index be9bf662fd..bbf19057c4 100644 --- a/drivers/serial/serial_intel_mid.c +++ b/drivers/serial/serial_intel_mid.c @@ -61,7 +61,7 @@ U_BOOT_DRIVER(serial_intel_mid) = { .of_match = mid_serial_ids, .of_to_plat = ns16550_serial_of_to_plat, .plat_auto = sizeof(struct ns16550_plat), - .priv_auto = sizeof(struct NS16550), + .priv_auto = sizeof(struct ns16550), .probe = mid_serial_probe, .ops = &ns16550_serial_ops, }; diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c index ef394b7235..a8d3602e9b 100644 --- a/drivers/serial/serial_ns16550.c +++ b/drivers/serial/serial_ns16550.c @@ -36,34 +36,34 @@ DECLARE_GLOBAL_DATA_PTR; /* Note: The port number specified in the functions is 1 based. * the array is 0 based. */ -static NS16550_t serial_ports[6] = { +static struct ns16550 *serial_ports[6] = { #ifdef CONFIG_SYS_NS16550_COM1 - (NS16550_t)CONFIG_SYS_NS16550_COM1, + (struct ns16550 *)CONFIG_SYS_NS16550_COM1, #else NULL, #endif #ifdef CONFIG_SYS_NS16550_COM2 - (NS16550_t)CONFIG_SYS_NS16550_COM2, + (struct ns16550 *)CONFIG_SYS_NS16550_COM2, #else NULL, #endif #ifdef CONFIG_SYS_NS16550_COM3 - (NS16550_t)CONFIG_SYS_NS16550_COM3, + (struct ns16550 *)CONFIG_SYS_NS16550_COM3, #else NULL, #endif #ifdef CONFIG_SYS_NS16550_COM4 - (NS16550_t)CONFIG_SYS_NS16550_COM4, + (struct ns16550 *)CONFIG_SYS_NS16550_COM4, #else NULL, #endif #ifdef CONFIG_SYS_NS16550_COM5 - (NS16550_t)CONFIG_SYS_NS16550_COM5, + (struct ns16550 *)CONFIG_SYS_NS16550_COM5, #else NULL, #endif #ifdef CONFIG_SYS_NS16550_COM6 - (NS16550_t)CONFIG_SYS_NS16550_COM6 + (struct ns16550 *)CONFIG_SYS_NS16550_COM6 #else NULL #endif diff --git a/drivers/serial/serial_omap.c b/drivers/serial/serial_omap.c index 2f38e1b890..c235215541 100644 --- a/drivers/serial/serial_omap.c +++ b/drivers/serial/serial_omap.c @@ -66,7 +66,7 @@ static inline int serial_in_shift(void *addr, int shift) static inline void _debug_uart_init(void) { - struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; + struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE; int baud_divisor; baud_divisor = ns16550_calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK, @@ -85,7 +85,7 @@ static inline void _debug_uart_init(void) static inline void _debug_uart_putc(int ch) { - struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; + struct ns16550 *com_port = (struct ns16550 *)CONFIG_DEBUG_UART_BASE; while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) ; @@ -160,7 +160,7 @@ U_BOOT_DRIVER(omap_serial) = { .of_to_plat = omap_serial_of_to_plat, .plat_auto = sizeof(struct ns16550_plat), #endif - .priv_auto = sizeof(struct NS16550), + .priv_auto = sizeof(struct ns16550), .probe = ns16550_serial_probe, .ops = &ns16550_serial_ops, #if !CONFIG_IS_ENABLED(OF_CONTROL) diff --git a/drivers/serial/serial_rockchip.c b/drivers/serial/serial_rockchip.c index 4c0548ed0f..036c07262b 100644 --- a/drivers/serial/serial_rockchip.c +++ b/drivers/serial/serial_rockchip.c @@ -42,7 +42,7 @@ static int rockchip_serial_probe(struct udevice *dev) U_BOOT_DRIVER(rockchip_rk3188_uart) = { .name = "rockchip_rk3188_uart", .id = UCLASS_SERIAL, - .priv_auto = sizeof(struct NS16550), + .priv_auto = sizeof(struct ns16550), .plat_auto = sizeof(struct rockchip_uart_plat), .probe = rockchip_serial_probe, .ops = &ns16550_serial_ops, @@ -52,7 +52,7 @@ U_BOOT_DRIVER(rockchip_rk3188_uart) = { U_BOOT_DRIVER(rockchip_rk3288_uart) = { .name = "rockchip_rk3288_uart", .id = UCLASS_SERIAL, - .priv_auto = sizeof(struct NS16550), + .priv_auto = sizeof(struct ns16550), .plat_auto = sizeof(struct rockchip_uart_plat), .probe = rockchip_serial_probe, .ops = &ns16550_serial_ops, diff --git a/include/ns16550.h b/include/ns16550.h index bef2961032..75c5bf61fd 100644 --- a/include/ns16550.h +++ b/include/ns16550.h @@ -21,6 +21,9 @@ * will not allocate storage for arrays of size 0 */ +#ifndef __ns16550_h +#define __ns16550_h + #include #ifdef CONFIG_DM_SERIAL @@ -82,7 +85,7 @@ struct ns16550_plat { struct udevice; -struct NS16550 { +struct ns16550 { UART_REG(rbr); /* 0 */ UART_REG(ier); /* 1 */ UART_REG(fcr); /* 2 */ @@ -120,8 +123,6 @@ struct NS16550 { #define dll rbr #define dlm ier -typedef struct NS16550 *NS16550_t; - /* * These are the definitions for the FIFO Control Register */ @@ -221,11 +222,11 @@ typedef struct NS16550 *NS16550_t; /* useful defaults for LCR */ #define UART_LCR_8N1 0x03 -void NS16550_init(NS16550_t com_port, int baud_divisor); -void NS16550_putc(NS16550_t com_port, char c); -char NS16550_getc(NS16550_t com_port); -int NS16550_tstc(NS16550_t com_port); -void NS16550_reinit(NS16550_t com_port, int baud_divisor); +void NS16550_init(struct ns16550 *com_port, int baud_divisor); +void NS16550_putc(struct ns16550 *com_port, char c); +char NS16550_getc(struct ns16550 *com_port); +int NS16550_tstc(struct ns16550 *com_port); +void NS16550_reinit(struct ns16550 *com_port, int baud_divisor); /** * ns16550_calc_divisor() - calculate the divisor given clock and baud rate @@ -238,7 +239,7 @@ void NS16550_reinit(NS16550_t com_port, int baud_divisor); * @baudrate: Required baud rate * @return baud rate divisor that should be used */ -int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate); +int ns16550_calc_divisor(struct ns16550 *port, int clock, int baudrate); /** * ns16550_serial_of_to_plat() - convert DT to platform data @@ -266,3 +267,5 @@ int ns16550_serial_probe(struct udevice *dev); * These should be used by the client driver for the driver's 'ops' member */ extern const struct dm_serial_ops ns16550_serial_ops; + +#endif /* __ns16550_h */ diff --git a/lib/efi/efi_stub.c b/lib/efi/efi_stub.c index 7d650d512e..b3393e47fa 100644 --- a/lib/efi/efi_stub.c +++ b/lib/efi/efi_stub.c @@ -67,7 +67,7 @@ void putc(const char ch) putc('\r'); if (use_uart) { - NS16550_t com_port = (NS16550_t)0x3f8; + struct ns16550 *com_port = (struct ns16550 *)0x3f8; while ((inb((ulong)&com_port->lsr) & UART_LSR_THRE) == 0) ; -- 2.39.5