sifive.c (2e21dee6a46a66e4c2ced778485e1044101edee4) | sifive.c (32c694ec3efc2b7cdf921da50371297ba70e7d50) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * SiFive UART driver 4 * Copyright (C) 2018 Paul Walmsley <paul@pwsan.com> 5 * Copyright (C) 2018-2019 SiFive 6 * 7 * Based partially on: 8 * - drivers/tty/serial/pxa.c --- 398 unchanged lines hidden (view full) --- 407 u8 ch; 408 409 for (c = SIFIVE_RX_FIFO_DEPTH; c > 0; --c) { 410 ch = __ssp_receive_char(ssp, &is_empty); 411 if (is_empty) 412 break; 413 414 ssp->port.icount.rx++; | 1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * SiFive UART driver 4 * Copyright (C) 2018 Paul Walmsley <paul@pwsan.com> 5 * Copyright (C) 2018-2019 SiFive 6 * 7 * Based partially on: 8 * - drivers/tty/serial/pxa.c --- 398 unchanged lines hidden (view full) --- 407 u8 ch; 408 409 for (c = SIFIVE_RX_FIFO_DEPTH; c > 0; --c) { 410 ch = __ssp_receive_char(ssp, &is_empty); 411 if (is_empty) 412 break; 413 414 ssp->port.icount.rx++; |
415 uart_insert_char(&ssp->port, 0, 0, ch, TTY_NORMAL); | 415 if (!uart_prepare_sysrq_char(&ssp->port, ch)) 416 uart_insert_char(&ssp->port, 0, 0, ch, TTY_NORMAL); |
416 } 417 418 tty_flip_buffer_push(&ssp->port.state->port); 419} 420 421/** 422 * __ssp_update_div() - calculate the divisor setting by the line rate 423 * @ssp: pointer to a struct sifive_serial_port --- 105 unchanged lines hidden (view full) --- 529 return IRQ_NONE; 530 } 531 532 if (ip & SIFIVE_SERIAL_IP_RXWM_MASK) 533 __ssp_receive_chars(ssp); 534 if (ip & SIFIVE_SERIAL_IP_TXWM_MASK) 535 __ssp_transmit_chars(ssp); 536 | 417 } 418 419 tty_flip_buffer_push(&ssp->port.state->port); 420} 421 422/** 423 * __ssp_update_div() - calculate the divisor setting by the line rate 424 * @ssp: pointer to a struct sifive_serial_port --- 105 unchanged lines hidden (view full) --- 530 return IRQ_NONE; 531 } 532 533 if (ip & SIFIVE_SERIAL_IP_RXWM_MASK) 534 __ssp_receive_chars(ssp); 535 if (ip & SIFIVE_SERIAL_IP_TXWM_MASK) 536 __ssp_transmit_chars(ssp); 537 |
537 uart_port_unlock(&ssp->port); | 538 uart_unlock_and_check_sysrq(&ssp->port); |
538 539 return IRQ_HANDLED; 540} 541 542static unsigned int sifive_serial_tx_empty(struct uart_port *port) 543{ 544 return TIOCSER_TEMT; 545} --- 240 unchanged lines hidden (view full) --- 786 struct sifive_serial_port *ssp = sifive_serial_console_ports[co->index]; 787 unsigned long flags; 788 unsigned int ier; 789 int locked = 1; 790 791 if (!ssp) 792 return; 793 | 539 540 return IRQ_HANDLED; 541} 542 543static unsigned int sifive_serial_tx_empty(struct uart_port *port) 544{ 545 return TIOCSER_TEMT; 546} --- 240 unchanged lines hidden (view full) --- 787 struct sifive_serial_port *ssp = sifive_serial_console_ports[co->index]; 788 unsigned long flags; 789 unsigned int ier; 790 int locked = 1; 791 792 if (!ssp) 793 return; 794 |
794 local_irq_save(flags); 795 if (ssp->port.sysrq) 796 locked = 0; 797 else if (oops_in_progress) 798 locked = uart_port_trylock(&ssp->port); | 795 if (oops_in_progress) 796 locked = uart_port_trylock_irqsave(&ssp->port, &flags); |
799 else | 797 else |
800 uart_port_lock(&ssp->port); | 798 uart_port_lock_irqsave(&ssp->port, &flags); |
801 802 ier = __ssp_readl(ssp, SIFIVE_SERIAL_IE_OFFS); 803 __ssp_writel(0, SIFIVE_SERIAL_IE_OFFS, ssp); 804 805 uart_console_write(&ssp->port, s, count, sifive_serial_console_putchar); 806 807 __ssp_writel(ier, SIFIVE_SERIAL_IE_OFFS, ssp); 808 809 if (locked) | 799 800 ier = __ssp_readl(ssp, SIFIVE_SERIAL_IE_OFFS); 801 __ssp_writel(0, SIFIVE_SERIAL_IE_OFFS, ssp); 802 803 uart_console_write(&ssp->port, s, count, sifive_serial_console_putchar); 804 805 __ssp_writel(ier, SIFIVE_SERIAL_IE_OFFS, ssp); 806 807 if (locked) |
810 uart_port_unlock(&ssp->port); 811 local_irq_restore(flags); | 808 uart_port_unlock_irqrestore(&ssp->port, flags); |
812} 813 814static int sifive_serial_console_setup(struct console *co, char *options) 815{ 816 struct sifive_serial_port *ssp; 817 int baud = SIFIVE_DEFAULT_BAUD_RATE; 818 int bits = 8; 819 int parity = 'n'; --- 266 unchanged lines hidden --- | 809} 810 811static int sifive_serial_console_setup(struct console *co, char *options) 812{ 813 struct sifive_serial_port *ssp; 814 int baud = SIFIVE_DEFAULT_BAUD_RATE; 815 int bits = 8; 816 int parity = 'n'; --- 266 unchanged lines hidden --- |