From nobody Sat Apr 18 07:43:56 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0443C433EF for ; Fri, 15 Jul 2022 14:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbiGOODq (ORCPT ); Fri, 15 Jul 2022 10:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235102AbiGOODd (ORCPT ); Fri, 15 Jul 2022 10:03:33 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1158C6465; Fri, 15 Jul 2022 07:03:30 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B31A0337E4; Fri, 15 Jul 2022 14:03:28 +0000 (UTC) Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 94E732C141; Fri, 15 Jul 2022 14:03:28 +0000 (UTC) From: Thomas Bogendoerfer To: Greg Kroah-Hartman , Jiri Slaby , linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org Subject: [PATCH] serial: remove VR41XX serial driver Date: Fri, 15 Jul 2022 16:03:22 +0200 Message-Id: <20220715140322.135825-1-tsbogend@alpha.franken.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Commit d3164e2f3b0a ("MIPS: Remove VR41xx support") removed support for MIPS VR41xx platform, so remove exclusive drivers for this platform, too. Signed-off-by: Thomas Bogendoerfer Acked-by: Jiri Slaby --- drivers/tty/serial/Kconfig | 17 - drivers/tty/serial/Makefile | 1 - drivers/tty/serial/vr41xx_siu.c | 932 ------------------------------- include/uapi/linux/serial_core.h | 4 - 4 files changed, 954 deletions(-) delete mode 100644 drivers/tty/serial/vr41xx_siu.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index e3279544b03c..877173907c53 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -890,23 +890,6 @@ config SERIAL_TXX9_STDSERIAL bool "TX39XX/49XX SIO act as standard serial" depends on !SERIAL_8250 && SERIAL_TXX9 =20 -config SERIAL_VR41XX - tristate "NEC VR4100 series Serial Interface Unit support" - depends on CPU_VR41XX - select SERIAL_CORE - help - If you have a NEC VR4100 series processor and you want to use - Serial Interface Unit(SIU) or Debug Serial Interface Unit(DSIU) - (not include VR4111/VR4121 DSIU), say Y. Otherwise, say N. - -config SERIAL_VR41XX_CONSOLE - bool "Enable NEC VR4100 series Serial Interface Unit console" - depends on SERIAL_VR41XX=3Dy - select SERIAL_CORE_CONSOLE - help - If you have a NEC VR4100 series processor and you want to use - a console on a serial port, say Y. Otherwise, say N. - config SERIAL_JSM tristate "Digi International NEO and Classic PCI Support" depends on PCI diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 61cc8de95571..238a9557b487 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -51,7 +51,6 @@ obj-$(CONFIG_SERIAL_SCCNXP) +=3D sccnxp.o obj-$(CONFIG_SERIAL_SC16IS7XX_CORE) +=3D sc16is7xx.o obj-$(CONFIG_SERIAL_JSM) +=3D jsm/ obj-$(CONFIG_SERIAL_TXX9) +=3D serial_txx9.o -obj-$(CONFIG_SERIAL_VR41XX) +=3D vr41xx_siu.o obj-$(CONFIG_SERIAL_ATMEL) +=3D atmel_serial.o obj-$(CONFIG_SERIAL_UARTLITE) +=3D uartlite.o obj-$(CONFIG_SERIAL_MSM) +=3D msm_serial.o diff --git a/drivers/tty/serial/vr41xx_siu.c b/drivers/tty/serial/vr41xx_si= u.c deleted file mode 100644 index 1ba689a81abd..000000000000 --- a/drivers/tty/serial/vr41xx_siu.c +++ /dev/null @@ -1,932 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * Driver for NEC VR4100 series Serial Interface Unit. - * - * Copyright (C) 2004-2008 Yoichi Yuasa - * - * Based on drivers/serial/8250.c, by Russell King. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#define SIU_BAUD_BASE 1152000 -#define SIU_MAJOR 204 -#define SIU_MINOR_BASE 82 - -#define RX_MAX_COUNT 256 -#define TX_MAX_COUNT 15 - -#define SIUIRSEL 0x08 - #define TMICMODE 0x20 - #define TMICTX 0x10 - #define IRMSEL 0x0c - #define IRMSEL_HP 0x08 - #define IRMSEL_TEMIC 0x04 - #define IRMSEL_SHARP 0x00 - #define IRUSESEL 0x02 - #define SIRSEL 0x01 - -static struct uart_port siu_uart_ports[SIU_PORTS_MAX] =3D { - [0 ... SIU_PORTS_MAX-1] =3D { - .lock =3D __SPIN_LOCK_UNLOCKED(siu_uart_ports->lock), - .irq =3D 0, - }, -}; - -#ifdef CONFIG_SERIAL_VR41XX_CONSOLE -static uint8_t lsr_break_flag[SIU_PORTS_MAX]; -#endif - -#define siu_read(port, offset) readb((port)->membase + (offset)) -#define siu_write(port, offset, value) writeb((value), (port)->membase + (= offset)) - -void vr41xx_select_siu_interface(siu_interface_t interface) -{ - struct uart_port *port; - unsigned long flags; - uint8_t irsel; - - port =3D &siu_uart_ports[0]; - - spin_lock_irqsave(&port->lock, flags); - - irsel =3D siu_read(port, SIUIRSEL); - if (interface =3D=3D SIU_INTERFACE_IRDA) - irsel |=3D SIRSEL; - else - irsel &=3D ~SIRSEL; - siu_write(port, SIUIRSEL, irsel); - - spin_unlock_irqrestore(&port->lock, flags); -} -EXPORT_SYMBOL_GPL(vr41xx_select_siu_interface); - -void vr41xx_use_irda(irda_use_t use) -{ - struct uart_port *port; - unsigned long flags; - uint8_t irsel; - - port =3D &siu_uart_ports[0]; - - spin_lock_irqsave(&port->lock, flags); - - irsel =3D siu_read(port, SIUIRSEL); - if (use =3D=3D FIR_USE_IRDA) - irsel |=3D IRUSESEL; - else - irsel &=3D ~IRUSESEL; - siu_write(port, SIUIRSEL, irsel); - - spin_unlock_irqrestore(&port->lock, flags); -} -EXPORT_SYMBOL_GPL(vr41xx_use_irda); - -void vr41xx_select_irda_module(irda_module_t module, irda_speed_t speed) -{ - struct uart_port *port; - unsigned long flags; - uint8_t irsel; - - port =3D &siu_uart_ports[0]; - - spin_lock_irqsave(&port->lock, flags); - - irsel =3D siu_read(port, SIUIRSEL); - irsel &=3D ~(IRMSEL | TMICTX | TMICMODE); - switch (module) { - case SHARP_IRDA: - irsel |=3D IRMSEL_SHARP; - break; - case TEMIC_IRDA: - irsel |=3D IRMSEL_TEMIC | TMICMODE; - if (speed =3D=3D IRDA_TX_4MBPS) - irsel |=3D TMICTX; - break; - case HP_IRDA: - irsel |=3D IRMSEL_HP; - break; - default: - break; - } - siu_write(port, SIUIRSEL, irsel); - - spin_unlock_irqrestore(&port->lock, flags); -} -EXPORT_SYMBOL_GPL(vr41xx_select_irda_module); - -static inline void siu_clear_fifo(struct uart_port *port) -{ - siu_write(port, UART_FCR, UART_FCR_ENABLE_FIFO); - siu_write(port, UART_FCR, UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR | - UART_FCR_CLEAR_XMIT); - siu_write(port, UART_FCR, 0); -} - -static inline unsigned long siu_port_size(struct uart_port *port) -{ - switch (port->type) { - case PORT_VR41XX_SIU: - return 11UL; - case PORT_VR41XX_DSIU: - return 8UL; - } - - return 0; -} - -static inline unsigned int siu_check_type(struct uart_port *port) -{ - if (port->line =3D=3D 0) - return PORT_VR41XX_SIU; - if (port->line =3D=3D 1 && port->irq) - return PORT_VR41XX_DSIU; - - return PORT_UNKNOWN; -} - -static inline const char *siu_type_name(struct uart_port *port) -{ - switch (port->type) { - case PORT_VR41XX_SIU: - return "SIU"; - case PORT_VR41XX_DSIU: - return "DSIU"; - } - - return NULL; -} - -static unsigned int siu_tx_empty(struct uart_port *port) -{ - uint8_t lsr; - - lsr =3D siu_read(port, UART_LSR); - if (lsr & UART_LSR_TEMT) - return TIOCSER_TEMT; - - return 0; -} - -static void siu_set_mctrl(struct uart_port *port, unsigned int mctrl) -{ - uint8_t mcr =3D 0; - - if (mctrl & TIOCM_DTR) - mcr |=3D UART_MCR_DTR; - if (mctrl & TIOCM_RTS) - mcr |=3D UART_MCR_RTS; - if (mctrl & TIOCM_OUT1) - mcr |=3D UART_MCR_OUT1; - if (mctrl & TIOCM_OUT2) - mcr |=3D UART_MCR_OUT2; - if (mctrl & TIOCM_LOOP) - mcr |=3D UART_MCR_LOOP; - - siu_write(port, UART_MCR, mcr); -} - -static unsigned int siu_get_mctrl(struct uart_port *port) -{ - uint8_t msr; - unsigned int mctrl =3D 0; - - msr =3D siu_read(port, UART_MSR); - if (msr & UART_MSR_DCD) - mctrl |=3D TIOCM_CAR; - if (msr & UART_MSR_RI) - mctrl |=3D TIOCM_RNG; - if (msr & UART_MSR_DSR) - mctrl |=3D TIOCM_DSR; - if (msr & UART_MSR_CTS) - mctrl |=3D TIOCM_CTS; - - return mctrl; -} - -static void siu_stop_tx(struct uart_port *port) -{ - unsigned long flags; - uint8_t ier; - - spin_lock_irqsave(&port->lock, flags); - - ier =3D siu_read(port, UART_IER); - ier &=3D ~UART_IER_THRI; - siu_write(port, UART_IER, ier); - - spin_unlock_irqrestore(&port->lock, flags); -} - -static void siu_start_tx(struct uart_port *port) -{ - unsigned long flags; - uint8_t ier; - - spin_lock_irqsave(&port->lock, flags); - - ier =3D siu_read(port, UART_IER); - ier |=3D UART_IER_THRI; - siu_write(port, UART_IER, ier); - - spin_unlock_irqrestore(&port->lock, flags); -} - -static void siu_stop_rx(struct uart_port *port) -{ - unsigned long flags; - uint8_t ier; - - spin_lock_irqsave(&port->lock, flags); - - ier =3D siu_read(port, UART_IER); - ier &=3D ~UART_IER_RLSI; - siu_write(port, UART_IER, ier); - - port->read_status_mask &=3D ~UART_LSR_DR; - - spin_unlock_irqrestore(&port->lock, flags); -} - -static void siu_enable_ms(struct uart_port *port) -{ - unsigned long flags; - uint8_t ier; - - spin_lock_irqsave(&port->lock, flags); - - ier =3D siu_read(port, UART_IER); - ier |=3D UART_IER_MSI; - siu_write(port, UART_IER, ier); - - spin_unlock_irqrestore(&port->lock, flags); -} - -static void siu_break_ctl(struct uart_port *port, int ctl) -{ - unsigned long flags; - uint8_t lcr; - - spin_lock_irqsave(&port->lock, flags); - - lcr =3D siu_read(port, UART_LCR); - if (ctl =3D=3D -1) - lcr |=3D UART_LCR_SBC; - else - lcr &=3D ~UART_LCR_SBC; - siu_write(port, UART_LCR, lcr); - - spin_unlock_irqrestore(&port->lock, flags); -} - -static inline void receive_chars(struct uart_port *port, uint8_t *status) -{ - uint8_t lsr, ch; - char flag; - int max_count =3D RX_MAX_COUNT; - - lsr =3D *status; - - do { - ch =3D siu_read(port, UART_RX); - port->icount.rx++; - flag =3D TTY_NORMAL; - -#ifdef CONFIG_SERIAL_VR41XX_CONSOLE - lsr |=3D lsr_break_flag[port->line]; - lsr_break_flag[port->line] =3D 0; -#endif - if (unlikely(lsr & (UART_LSR_BI | UART_LSR_FE | - UART_LSR_PE | UART_LSR_OE))) { - if (lsr & UART_LSR_BI) { - lsr &=3D ~(UART_LSR_FE | UART_LSR_PE); - port->icount.brk++; - - if (uart_handle_break(port)) - goto ignore_char; - } - - if (lsr & UART_LSR_FE) - port->icount.frame++; - if (lsr & UART_LSR_PE) - port->icount.parity++; - if (lsr & UART_LSR_OE) - port->icount.overrun++; - - lsr &=3D port->read_status_mask; - if (lsr & UART_LSR_BI) - flag =3D TTY_BREAK; - if (lsr & UART_LSR_FE) - flag =3D TTY_FRAME; - if (lsr & UART_LSR_PE) - flag =3D TTY_PARITY; - } - - if (uart_handle_sysrq_char(port, ch)) - goto ignore_char; - - uart_insert_char(port, lsr, UART_LSR_OE, ch, flag); - - ignore_char: - lsr =3D siu_read(port, UART_LSR); - } while ((lsr & UART_LSR_DR) && (max_count-- > 0)); - - tty_flip_buffer_push(&port->state->port); - - *status =3D lsr; -} - -static inline void check_modem_status(struct uart_port *port) -{ - uint8_t msr; - - msr =3D siu_read(port, UART_MSR); - if ((msr & UART_MSR_ANY_DELTA) =3D=3D 0) - return; - if (msr & UART_MSR_DDCD) - uart_handle_dcd_change(port, msr & UART_MSR_DCD); - if (msr & UART_MSR_TERI) - port->icount.rng++; - if (msr & UART_MSR_DDSR) - port->icount.dsr++; - if (msr & UART_MSR_DCTS) - uart_handle_cts_change(port, msr & UART_MSR_CTS); - - wake_up_interruptible(&port->state->port.delta_msr_wait); -} - -static inline void transmit_chars(struct uart_port *port) -{ - struct circ_buf *xmit; - int max_count =3D TX_MAX_COUNT; - - xmit =3D &port->state->xmit; - - if (port->x_char) { - siu_write(port, UART_TX, port->x_char); - port->icount.tx++; - port->x_char =3D 0; - return; - } - - if (uart_circ_empty(xmit) || uart_tx_stopped(port)) { - siu_stop_tx(port); - return; - } - - do { - siu_write(port, UART_TX, xmit->buf[xmit->tail]); - xmit->tail =3D (xmit->tail + 1) & (UART_XMIT_SIZE - 1); - port->icount.tx++; - if (uart_circ_empty(xmit)) - break; - } while (max_count-- > 0); - - if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) - uart_write_wakeup(port); - - if (uart_circ_empty(xmit)) - siu_stop_tx(port); -} - -static irqreturn_t siu_interrupt(int irq, void *dev_id) -{ - struct uart_port *port; - uint8_t iir, lsr; - - port =3D (struct uart_port *)dev_id; - - iir =3D siu_read(port, UART_IIR); - if (iir & UART_IIR_NO_INT) - return IRQ_NONE; - - lsr =3D siu_read(port, UART_LSR); - if (lsr & UART_LSR_DR) - receive_chars(port, &lsr); - - check_modem_status(port); - - if (lsr & UART_LSR_THRE) - transmit_chars(port); - - return IRQ_HANDLED; -} - -static int siu_startup(struct uart_port *port) -{ - int retval; - - if (port->membase =3D=3D NULL) - return -ENODEV; - - siu_clear_fifo(port); - - (void)siu_read(port, UART_LSR); - (void)siu_read(port, UART_RX); - (void)siu_read(port, UART_IIR); - (void)siu_read(port, UART_MSR); - - if (siu_read(port, UART_LSR) =3D=3D 0xff) - return -ENODEV; - - retval =3D request_irq(port->irq, siu_interrupt, 0, siu_type_name(port), = port); - if (retval) - return retval; - - if (port->type =3D=3D PORT_VR41XX_DSIU) - vr41xx_enable_dsiuint(DSIUINT_ALL); - - siu_write(port, UART_LCR, UART_LCR_WLEN8); - - spin_lock_irq(&port->lock); - siu_set_mctrl(port, port->mctrl); - spin_unlock_irq(&port->lock); - - siu_write(port, UART_IER, UART_IER_RLSI | UART_IER_RDI); - - (void)siu_read(port, UART_LSR); - (void)siu_read(port, UART_RX); - (void)siu_read(port, UART_IIR); - (void)siu_read(port, UART_MSR); - - return 0; -} - -static void siu_shutdown(struct uart_port *port) -{ - unsigned long flags; - uint8_t lcr; - - siu_write(port, UART_IER, 0); - - spin_lock_irqsave(&port->lock, flags); - - port->mctrl &=3D ~TIOCM_OUT2; - siu_set_mctrl(port, port->mctrl); - - spin_unlock_irqrestore(&port->lock, flags); - - lcr =3D siu_read(port, UART_LCR); - lcr &=3D ~UART_LCR_SBC; - siu_write(port, UART_LCR, lcr); - - siu_clear_fifo(port); - - (void)siu_read(port, UART_RX); - - if (port->type =3D=3D PORT_VR41XX_DSIU) - vr41xx_disable_dsiuint(DSIUINT_ALL); - - free_irq(port->irq, port); -} - -static void siu_set_termios(struct uart_port *port, struct ktermios *new, - struct ktermios *old) -{ - tcflag_t c_cflag, c_iflag; - uint8_t lcr, fcr, ier; - unsigned int baud, quot; - unsigned long flags; - - c_cflag =3D new->c_cflag; - lcr =3D UART_LCR_WLEN(tty_get_char_size(c_cflag)); - - if (c_cflag & CSTOPB) - lcr |=3D UART_LCR_STOP; - if (c_cflag & PARENB) - lcr |=3D UART_LCR_PARITY; - if ((c_cflag & PARODD) !=3D PARODD) - lcr |=3D UART_LCR_EPAR; - if (c_cflag & CMSPAR) - lcr |=3D UART_LCR_SPAR; - - baud =3D uart_get_baud_rate(port, new, old, 0, port->uartclk/16); - quot =3D uart_get_divisor(port, baud); - - fcr =3D UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10; - - spin_lock_irqsave(&port->lock, flags); - - uart_update_timeout(port, c_cflag, baud); - - c_iflag =3D new->c_iflag; - - port->read_status_mask =3D UART_LSR_THRE | UART_LSR_OE | UART_LSR_DR; - if (c_iflag & INPCK) - port->read_status_mask |=3D UART_LSR_FE | UART_LSR_PE; - if (c_iflag & (IGNBRK | BRKINT | PARMRK)) - port->read_status_mask |=3D UART_LSR_BI; - - port->ignore_status_mask =3D 0; - if (c_iflag & IGNPAR) - port->ignore_status_mask |=3D UART_LSR_FE | UART_LSR_PE; - if (c_iflag & IGNBRK) { - port->ignore_status_mask |=3D UART_LSR_BI; - if (c_iflag & IGNPAR) - port->ignore_status_mask |=3D UART_LSR_OE; - } - - if ((c_cflag & CREAD) =3D=3D 0) - port->ignore_status_mask |=3D UART_LSR_DR; - - ier =3D siu_read(port, UART_IER); - ier &=3D ~UART_IER_MSI; - if (UART_ENABLE_MS(port, c_cflag)) - ier |=3D UART_IER_MSI; - siu_write(port, UART_IER, ier); - - siu_write(port, UART_LCR, lcr | UART_LCR_DLAB); - - siu_write(port, UART_DLL, (uint8_t)quot); - siu_write(port, UART_DLM, (uint8_t)(quot >> 8)); - - siu_write(port, UART_LCR, lcr); - - siu_write(port, UART_FCR, fcr); - - siu_set_mctrl(port, port->mctrl); - - spin_unlock_irqrestore(&port->lock, flags); -} - -static void siu_pm(struct uart_port *port, unsigned int state, unsigned in= t oldstate) -{ - switch (state) { - case 0: - switch (port->type) { - case PORT_VR41XX_SIU: - vr41xx_supply_clock(SIU_CLOCK); - break; - case PORT_VR41XX_DSIU: - vr41xx_supply_clock(DSIU_CLOCK); - break; - } - break; - case 3: - switch (port->type) { - case PORT_VR41XX_SIU: - vr41xx_mask_clock(SIU_CLOCK); - break; - case PORT_VR41XX_DSIU: - vr41xx_mask_clock(DSIU_CLOCK); - break; - } - break; - } -} - -static const char *siu_type(struct uart_port *port) -{ - return siu_type_name(port); -} - -static void siu_release_port(struct uart_port *port) -{ - unsigned long size; - - if (port->flags & UPF_IOREMAP) { - iounmap(port->membase); - port->membase =3D NULL; - } - - size =3D siu_port_size(port); - release_mem_region(port->mapbase, size); -} - -static int siu_request_port(struct uart_port *port) -{ - unsigned long size; - struct resource *res; - - size =3D siu_port_size(port); - res =3D request_mem_region(port->mapbase, size, siu_type_name(port)); - if (res =3D=3D NULL) - return -EBUSY; - - if (port->flags & UPF_IOREMAP) { - port->membase =3D ioremap(port->mapbase, size); - if (port->membase =3D=3D NULL) { - release_resource(res); - return -ENOMEM; - } - } - - return 0; -} - -static void siu_config_port(struct uart_port *port, int flags) -{ - if (flags & UART_CONFIG_TYPE) { - port->type =3D siu_check_type(port); - (void)siu_request_port(port); - } -} - -static int siu_verify_port(struct uart_port *port, struct serial_struct *s= erial) -{ - if (port->type !=3D PORT_VR41XX_SIU && port->type !=3D PORT_VR41XX_DSIU) - return -EINVAL; - if (port->irq !=3D serial->irq) - return -EINVAL; - if (port->iotype !=3D serial->io_type) - return -EINVAL; - if (port->mapbase !=3D (unsigned long)serial->iomem_base) - return -EINVAL; - - return 0; -} - -static const struct uart_ops siu_uart_ops =3D { - .tx_empty =3D siu_tx_empty, - .set_mctrl =3D siu_set_mctrl, - .get_mctrl =3D siu_get_mctrl, - .stop_tx =3D siu_stop_tx, - .start_tx =3D siu_start_tx, - .stop_rx =3D siu_stop_rx, - .enable_ms =3D siu_enable_ms, - .break_ctl =3D siu_break_ctl, - .startup =3D siu_startup, - .shutdown =3D siu_shutdown, - .set_termios =3D siu_set_termios, - .pm =3D siu_pm, - .type =3D siu_type, - .release_port =3D siu_release_port, - .request_port =3D siu_request_port, - .config_port =3D siu_config_port, - .verify_port =3D siu_verify_port, -}; - -static int siu_init_ports(struct platform_device *pdev) -{ - struct uart_port *port; - struct resource *res; - int *type =3D dev_get_platdata(&pdev->dev); - int i; - - if (!type) - return 0; - - port =3D siu_uart_ports; - for (i =3D 0; i < SIU_PORTS_MAX; i++) { - port->type =3D type[i]; - if (port->type =3D=3D PORT_UNKNOWN) - continue; - port->irq =3D platform_get_irq(pdev, i); - port->uartclk =3D SIU_BAUD_BASE * 16; - port->fifosize =3D 16; - port->regshift =3D 0; - port->iotype =3D UPIO_MEM; - port->flags =3D UPF_IOREMAP | UPF_BOOT_AUTOCONF; - port->line =3D i; - res =3D platform_get_resource(pdev, IORESOURCE_MEM, i); - port->mapbase =3D res->start; - port++; - } - - return i; -} - -#ifdef CONFIG_SERIAL_VR41XX_CONSOLE - -static void wait_for_xmitr(struct uart_port *port) -{ - int timeout =3D 10000; - uint8_t lsr, msr; - - do { - lsr =3D siu_read(port, UART_LSR); - if (lsr & UART_LSR_BI) - lsr_break_flag[port->line] =3D UART_LSR_BI; - - if (uart_lsr_tx_empty(lsr)) - break; - } while (timeout-- > 0); - - if (port->flags & UPF_CONS_FLOW) { - timeout =3D 1000000; - - do { - msr =3D siu_read(port, UART_MSR); - if ((msr & UART_MSR_CTS) !=3D 0) - break; - } while (timeout-- > 0); - } -} - -static void siu_console_putchar(struct uart_port *port, unsigned char ch) -{ - wait_for_xmitr(port); - siu_write(port, UART_TX, ch); -} - -static void siu_console_write(struct console *con, const char *s, unsigned= count) -{ - struct uart_port *port; - uint8_t ier; - - port =3D &siu_uart_ports[con->index]; - - ier =3D siu_read(port, UART_IER); - siu_write(port, UART_IER, 0); - - uart_console_write(port, s, count, siu_console_putchar); - - wait_for_xmitr(port); - siu_write(port, UART_IER, ier); -} - -static int __init siu_console_setup(struct console *con, char *options) -{ - struct uart_port *port; - int baud =3D 9600; - int parity =3D 'n'; - int bits =3D 8; - int flow =3D 'n'; - - if (con->index >=3D SIU_PORTS_MAX) - con->index =3D 0; - - port =3D &siu_uart_ports[con->index]; - if (port->membase =3D=3D NULL) { - if (port->mapbase =3D=3D 0) - return -ENODEV; - port->membase =3D ioremap(port->mapbase, siu_port_size(port)); - } - - if (port->type =3D=3D PORT_VR41XX_SIU) - vr41xx_select_siu_interface(SIU_INTERFACE_RS232C); - - if (options !=3D NULL) - uart_parse_options(options, &baud, &parity, &bits, &flow); - - return uart_set_options(port, con, baud, parity, bits, flow); -} - -static struct uart_driver siu_uart_driver; - -static struct console siu_console =3D { - .name =3D "ttyVR", - .write =3D siu_console_write, - .device =3D uart_console_device, - .setup =3D siu_console_setup, - .flags =3D CON_PRINTBUFFER, - .index =3D -1, - .data =3D &siu_uart_driver, -}; - -static int siu_console_init(void) -{ - struct uart_port *port; - int i; - - for (i =3D 0; i < SIU_PORTS_MAX; i++) { - port =3D &siu_uart_ports[i]; - port->ops =3D &siu_uart_ops; - } - - register_console(&siu_console); - - return 0; -} - -console_initcall(siu_console_init); - -void __init vr41xx_siu_early_setup(struct uart_port *port) -{ - if (port->type =3D=3D PORT_UNKNOWN) - return; - - siu_uart_ports[port->line].line =3D port->line; - siu_uart_ports[port->line].type =3D port->type; - siu_uart_ports[port->line].uartclk =3D SIU_BAUD_BASE * 16; - siu_uart_ports[port->line].mapbase =3D port->mapbase; - siu_uart_ports[port->line].ops =3D &siu_uart_ops; -} - -#define SERIAL_VR41XX_CONSOLE &siu_console -#else -#define SERIAL_VR41XX_CONSOLE NULL -#endif - -static struct uart_driver siu_uart_driver =3D { - .owner =3D THIS_MODULE, - .driver_name =3D "SIU", - .dev_name =3D "ttyVR", - .major =3D SIU_MAJOR, - .minor =3D SIU_MINOR_BASE, - .cons =3D SERIAL_VR41XX_CONSOLE, -}; - -static int siu_probe(struct platform_device *dev) -{ - struct uart_port *port; - int num, i, retval; - - num =3D siu_init_ports(dev); - if (num <=3D 0) - return -ENODEV; - - siu_uart_driver.nr =3D num; - retval =3D uart_register_driver(&siu_uart_driver); - if (retval) - return retval; - - for (i =3D 0; i < num; i++) { - port =3D &siu_uart_ports[i]; - port->ops =3D &siu_uart_ops; - port->dev =3D &dev->dev; - port->has_sysrq =3D IS_ENABLED(CONFIG_SERIAL_VR41XX_CONSOLE); - - retval =3D uart_add_one_port(&siu_uart_driver, port); - if (retval < 0) { - port->dev =3D NULL; - break; - } - } - - if (i =3D=3D 0 && retval < 0) { - uart_unregister_driver(&siu_uart_driver); - return retval; - } - - return 0; -} - -static int siu_remove(struct platform_device *dev) -{ - struct uart_port *port; - int i; - - for (i =3D 0; i < siu_uart_driver.nr; i++) { - port =3D &siu_uart_ports[i]; - if (port->dev =3D=3D &dev->dev) { - uart_remove_one_port(&siu_uart_driver, port); - port->dev =3D NULL; - } - } - - uart_unregister_driver(&siu_uart_driver); - - return 0; -} - -static int siu_suspend(struct platform_device *dev, pm_message_t state) -{ - struct uart_port *port; - int i; - - for (i =3D 0; i < siu_uart_driver.nr; i++) { - port =3D &siu_uart_ports[i]; - if ((port->type =3D=3D PORT_VR41XX_SIU || - port->type =3D=3D PORT_VR41XX_DSIU) && port->dev =3D=3D &dev->dev) - uart_suspend_port(&siu_uart_driver, port); - - } - - return 0; -} - -static int siu_resume(struct platform_device *dev) -{ - struct uart_port *port; - int i; - - for (i =3D 0; i < siu_uart_driver.nr; i++) { - port =3D &siu_uart_ports[i]; - if ((port->type =3D=3D PORT_VR41XX_SIU || - port->type =3D=3D PORT_VR41XX_DSIU) && port->dev =3D=3D &dev->dev) - uart_resume_port(&siu_uart_driver, port); - } - - return 0; -} - -static struct platform_driver siu_device_driver =3D { - .probe =3D siu_probe, - .remove =3D siu_remove, - .suspend =3D siu_suspend, - .resume =3D siu_resume, - .driver =3D { - .name =3D "SIU", - }, -}; - -module_platform_driver(siu_device_driver); - -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:SIU"); diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_c= ore.h index 6faf502b7860..3ba34d8378bd 100644 --- a/include/uapi/linux/serial_core.h +++ b/include/uapi/linux/serial_core.h @@ -124,10 +124,6 @@ /* TXX9 type number */ #define PORT_TXX9 64 =20 -/* NEC VR4100 series SIU/DSIU */ -#define PORT_VR41XX_SIU 65 -#define PORT_VR41XX_DSIU 66 - /* Samsung S3C2400 SoC */ #define PORT_S3C2400 67 =20 --=20 2.29.2