--- zzzz-none-000/linux-5.15.111/drivers/tty/serial/8250/8250_port.c 2023-05-11 14:00:40.000000000 +0000 +++ puma7-arm-6670-761/linux-5.15.111/drivers/tty/serial/8250/8250_port.c 2024-02-07 09:28:02.000000000 +0000 @@ -10,7 +10,10 @@ * mapbase is the physical address of the IO port. * membase is an 'ioremapped' cookie. */ - +/* + * Includes Intel Corporation's changes/modifications dated: 2017, 2018. + * Changed/modified portions - Copyright (c) 2017-2018, Intel Corporation. + */ #include #include #include @@ -42,6 +45,14 @@ #define UART_NPCM_TOR 7 #define UART_NPCM_TOIE BIT(7) /* Timeout Interrupt Enable */ +#ifdef CONFIG_MACH_PUMA6 +#include +#endif + +#if CONFIG_MACH_PUMA7 +#include +#endif + /* * Debugging. */ @@ -253,6 +264,13 @@ .rxtrig_bytes = {1, 32, 64, 126}, .flags = UART_CAP_FIFO | UART_CAP_AFE, }, + [PORT_TI_16550A] = { + .name = "TI 16550A", + .fifo_size = 16, + .tx_loadsz = 16, + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, + .flags = UART_CAP_FIFO | UART_CAP_UUE, + }, /* * tx_loadsz is set to 63-bytes instead of 64-bytes to implement * workaround of errata A-008006 which states that tx_loadsz should @@ -1148,6 +1166,15 @@ * already a 1 and maybe locked there before we even start start. */ iersave = serial_in(up, UART_IER); + + /* TI default UART_IER upper nibble to 0 */ + if((iersave & 0xF0) == 0) { + DEBUG_AUTOCONF("TI 16550A"); + up->port.type = PORT_TI_16550A; + up->capabilities |= UART_CAP_UUE; + return; + } + serial_out(up, UART_IER, iersave & ~UART_IER_UUE); if (!(serial_in(up, UART_IER) & UART_IER_UUE)) { /* @@ -1791,6 +1818,14 @@ break; lsr = serial_in(up, UART_LSR); } while (lsr & (UART_LSR_DR | UART_LSR_BI)); + if (256 - max_count > 15) + { + up->port.histogram_RX_stats[15]++; + } + else + { + up->port.histogram_RX_stats[256 - max_count]++; + } tty_flip_buffer_push(&port->state->port); return lsr; @@ -2786,6 +2821,20 @@ up->fcr &= ~UART_FCR_TRIGGER_MASK; up->fcr |= UART_FCR_TRIGGER_1; } + else +#if defined (CONFIG_MACH_PUMA6) || defined (CONFIG_MACH_PUMA7) + { + if (up->port.irq == AVALANCHE_UART1_INT) + { + up->fcr &= ~UART_FCR_TRIGGER_MASK; + up->fcr |= UART_FCR_TRIGGER_1; + } + else +#endif + { + up->fcr = uart_config[up->port.type].fcr; + } + } } /* @@ -2798,7 +2847,10 @@ if (termios->c_cflag & CRTSCTS) up->mcr |= UART_MCR_AFE; } - + if (termios->c_cflag & CRTSCTS) + { + up->mcr |= UART_MCR_AFE; + } /* * Update the per-port timeout. */ @@ -3313,7 +3365,7 @@ { struct uart_8250_port *up = up_to_u8250p(port); - wait_for_xmitr(up, UART_LSR_THRE); + wait_for_xmitr(up, BOTH_EMPTY); serial_port_out(port, UART_TX, ch); } @@ -3352,7 +3404,7 @@ * Doing runtime PM is really a bad idea for the kernel console. * Thus, we assume the function is called when device is powered up. */ -void serial8250_console_write(struct uart_8250_port *up, const char *s, +static void serial8250_console_write1(struct uart_8250_port *up, const char *s, unsigned int count) { struct uart_8250_em485 *em485 = up->em485; @@ -3420,6 +3472,16 @@ spin_unlock_irqrestore(&port->lock, flags); } +void serial8250_console_write(struct uart_8250_port *up, const char *s, + unsigned int count) +{ + int i; + for (i = 0; i < count; i++) + { + serial8250_console_write1(up, &s[i], 1); + } +} + static unsigned int probe_baud(struct uart_port *port) { unsigned char lcr, dll, dlm;