Re: [PATCH 4/4] TTY: serial, move 68360 driver to staging

From: Geert Uytterhoeven
Date: Wed Aug 31 2011 - 15:52:40 EST


On Wed, Aug 31, 2011 at 21:24, Jiri Slaby <jslaby@xxxxxxx> wrote:
> This driver has been broken at least since 2008. At that time,
> a88487c79b (Fix compile errors in SGI console drivers) broke this
> driver completely.
>
> And since nobody noticed for the past 3 years, move it into staging. I
> think this will rot there and we will throw it away completely after
> some time. Or maybe someone will volunteer to fix it ;).
>
> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
> Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
> Cc: Alan Cox <alan@xxxxxxxxxxxxxxx>
> ---
> Cc: linux-m68k@xxxxxxxxxxxxxxxxxxxx

This is a uClinux driver.

> Âdrivers/staging/Kconfig       Â|  Â2 +
> Âdrivers/staging/Makefile       |  Â1 +
> Âdrivers/staging/serial/68360serial.c | 2979 ++++++++++++++++++++++++++++++++++
> Âdrivers/staging/serial/Kconfig    |  16 +
> Âdrivers/staging/serial/Makefile   Â|  Â1 +
> Âdrivers/staging/serial/TODO Â Â Â Â Â| Â Â6 +
> Âdrivers/tty/serial/68360serial.c   | 2979 ----------------------------------
> Âdrivers/tty/serial/Kconfig      |  17 -
> Âdrivers/tty/serial/Makefile     Â|  Â1 -
> Â9 files changed, 3005 insertions(+), 2997 deletions(-)
> Âcreate mode 100644 drivers/staging/serial/68360serial.c
> Âcreate mode 100644 drivers/staging/serial/Kconfig
> Âcreate mode 100644 drivers/staging/serial/Makefile
> Âcreate mode 100644 drivers/staging/serial/TODO
> Âdelete mode 100644 drivers/tty/serial/68360serial.c
>
> diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
> index eac0a7f..cb3b60d 100644
> --- a/drivers/staging/Kconfig
> +++ b/drivers/staging/Kconfig
> @@ -24,6 +24,8 @@ menuconfig STAGING
>
> Âif STAGING
>
> +source "drivers/staging/serial/Kconfig"
> +
> Âsource "drivers/staging/et131x/Kconfig"
>
> Âsource "drivers/staging/slicoss/Kconfig"
> diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
> index 20be112..1d865d2 100644
> --- a/drivers/staging/Makefile
> +++ b/drivers/staging/Makefile
> @@ -3,6 +3,7 @@
> Â# fix for build system bug...
> Âobj-$(CONFIG_STAGING) Â Â Â Â Â+= staging.o
>
> +obj-y             Â+= serial/
> Âobj-$(CONFIG_ET131X) Â Â Â Â Â += et131x/
> Âobj-$(CONFIG_SLICOSS) Â Â Â Â Â+= slicoss/
> Âobj-$(CONFIG_VIDEO_GO7007) Â Â += go7007/
> diff --git a/drivers/staging/serial/68360serial.c b/drivers/staging/serial/68360serial.c
> new file mode 100644
> index 0000000..0a3e878
> --- /dev/null
> +++ b/drivers/staging/serial/68360serial.c
> @@ -0,0 +1,2979 @@
> +/*
> + * ÂUART driver for 68360 CPM SCC or SMC
> + * ÂCopyright (c) 2000 D. Jeff Dionne <jeff@xxxxxxxxxxx>,
> + * ÂCopyright (c) 2000 Michael Leslie <mleslie@xxxxxxxx>
> + * ÂCopyright (c) 1997 Dan Malek <dmalek@xxxxxxx>
> + *
> + * I used the serial.c driver as the framework for this driver.
> + * Give credit to those guys.
> + * The original code was written for the MBX860 board. ÂI tried to make
> + * it generic, but there may be some assumptions in the structures that
> + * have to be fixed later.
> + * To save porting time, I did not bother to change any object names
> + * that are not accessed outside of this file.
> + * It still needs lots of work........When it was easy, I included code
> + * to support the SCCs, but this has never been tested, nor is it complete.
> + * Only the SCCs support modem control, so that is not complete either.
> + *
> + * This module exports the following rs232 io functions:
> + *
> + * Â Â int rs_360_init(void);
> + */
> +
> +#include <linux/module.h>
> +#include <linux/errno.h>
> +#include <linux/signal.h>
> +#include <linux/sched.h>
> +#include <linux/timer.h>
> +#include <linux/interrupt.h>
> +#include <linux/tty.h>
> +#include <linux/tty_flip.h>
> +#include <linux/serial.h>
> +#include <linux/serialP.h>
> +#include <linux/major.h>
> +#include <linux/string.h>
> +#include <linux/fcntl.h>
> +#include <linux/ptrace.h>
> +#include <linux/mm.h>
> +#include <linux/init.h>
> +#include <linux/delay.h>
> +#include <asm/irq.h>
> +#include <asm/m68360.h>
> +#include <asm/commproc.h>
> +
> +
> +#ifdef CONFIG_KGDB
> +extern void breakpoint(void);
> +extern void set_debug_traps(void);
> +extern int Âkgdb_output_string (const char* s, unsigned int count);
> +#endif
> +
> +
> +/* #ifdef CONFIG_SERIAL_CONSOLE */ /* This seems to be a post 2.0 thing - mles */
> +#include <linux/console.h>
> +#include <linux/jiffies.h>
> +
> +/* this defines the index into rs_table for the port to use
> + */
> +#ifndef CONFIG_SERIAL_CONSOLE_PORT
> +#define CONFIG_SERIAL_CONSOLE_PORT Â Â 1 /* ie SMC2 - note USE_SMC2 must be defined */
> +#endif
> +/* #endif */
> +
> +#if 0
> +/* SCC2 for console
> + */
> +#undef CONFIG_SERIAL_CONSOLE_PORT
> +#define CONFIG_SERIAL_CONSOLE_PORT Â Â 2
> +#endif
> +
> +
> +#define TX_WAKEUP Â Â ÂASYNC_SHARE_IRQ
> +
> +static char *serial_name = "CPM UART driver";
> +static char *serial_version = "0.03";
> +
> +static struct tty_driver *serial_driver;
> +int serial_console_setup(struct console *co, char *options);
> +
> +/*
> + * Serial driver configuration section. ÂHere are the various options:
> + */
> +#define SERIAL_PARANOIA_CHECK
> +#define CONFIG_SERIAL_NOPAUSE_IO
> +#define SERIAL_DO_RESTART
> +
> +/* Set of debugging defines */
> +
> +#undef SERIAL_DEBUG_INTR
> +#undef SERIAL_DEBUG_OPEN
> +#undef SERIAL_DEBUG_FLOW
> +#undef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
> +
> +#define _INLINE_ inline
> +
> +#define DBG_CNT(s)
> +
> +/* We overload some of the items in the data structure to meet our
> + * needs. ÂFor example, the port address is the CPM parameter ram
> + * offset for the SCC or SMC. ÂThe maximum number of ports is 4 SCCs and
> + * 2 SMCs. ÂThe "hub6" field is used to indicate the channel number, with
> + * a flag indicating SCC or SMC, and the number is used as an index into
> + * the CPM parameter area for this device.
> + * The "type" field is currently set to 0, for PORT_UNKNOWN. ÂIt is
> + * not currently used. ÂI should probably use it to indicate the port
> + * type of SMC or SCC.
> + * The SMCs do not support any modem control signals.
> + */
> +#define smc_scc_num  Âhub6
> +#define NUM_IS_SCC Â Â ((int)0x00010000)
> +#define PORT_NUM(P) Â Â((P) & 0x0000ffff)
> +
> +
> +#if defined (CONFIG_UCQUICC)
> +
> +volatile extern void *_periph_base;
> +/* sipex transceiver
> + *  mode bits for    are on pins
> + *
> + * Â ÂSCC2 Â Â Â Â Â Â Â Âd16..19
> + * Â ÂSCC3 Â Â Â Â Â Â Â Âd20..23
> + * Â ÂSCC4 Â Â Â Â Â Â Â Âd24..27
> + */
> +#define SIPEX_MODE(n,m) ((m & 0x0f)<<(16+4*(n-1)))
> +
> +static uint sipex_mode_bits = 0x00000000;
> +
> +#endif
> +
> +/* There is no `serial_state' defined back here in 2.0.
> + * Try to get by with serial_struct
> + */
> +/* #define serial_state serial_struct */
> +
> +/* 2.4 -> 2.0 portability problem: async_icount in 2.4 has a few
> + * extras: */
> +
> +#if 0
> +struct async_icount_24 {
> + Â Â Â __u32 Â cts, dsr, rng, dcd, tx, rx;
> + Â Â Â __u32 Â frame, parity, overrun, brk;
> + Â Â Â __u32 Â buf_overrun;
> +} icount;
> +#endif
> +
> +#if 0
> +
> +struct serial_state {
> +    Âint   magic;
> +    Âint   baud_base;
> +    Âunsigned long  port;
> +    Âint   irq;
> +    Âint   flags;
> +    Âint   hub6;
> +    Âint   type;
> +    Âint   line;
> +    Âint   revision;    /* Chip revision (950) */
> +    Âint   xmit_fifo_size;
> +    Âint   custom_divisor;
> +    Âint   count;
> + Â Â Â Âu8 Â Â Â*iomem_base;
> + Â Â Â Âu16 Â Â iomem_reg_shift;
> + Â Â Â Âunsigned short Âclose_delay;
> + Â Â Â Âunsigned short Âclosing_wait; /* time to wait before closing */
> + Â Â Â Âstruct async_icount_24 Â Â icount;
> +    Âint   io_type;
> + Â Â Â Âstruct async_struct *info;
> +};
> +#endif
> +
> +#define SSTATE_MAGIC 0x5302
> +
> +
> +
> +/* SMC2 is sometimes used for low performance TDM interfaces. ÂDefine
> + * this as 1 if you want SMC2 as a serial port UART managed by this driver.
> + * Define this as 0 if you wish to use SMC2 for something else.
> + */
> +#define USE_SMC2 1
> +
> +#if 0
> +/* Define SCC to ttySx mapping. */
> +#define SCC_NUM_BASE Â (USE_SMC2 + 1) Â/* SCC base tty "number" */
> +
> +/* Define which SCC is the first one to use for a serial port. ÂThese
> + * are 0-based numbers, i.e. this assumes the first SCC (SCC1) is used
> + * for Ethernet, and the first available SCC for serial UART is SCC2.
> + * NOTE: ÂIF YOU CHANGE THIS, you have to change the PROFF_xxx and
> + * interrupt vectors in the table below to match.
> + */
> +#define SCC_IDX_BASE Â 1 Â Â Â /* table index */
> +#endif
> +
> +
> +/* Processors other than the 860 only get SMCs configured by default.
> + * Either they don't have SCCs or they are allocated somewhere else.
> + * Of course, there are now 860s without some SCCs, so we will need to
> + * address that someday.
> + * The Embedded Planet Multimedia I/O cards use TDM interfaces to the
> + * stereo codec parts, and we use SMC2 to help support that.
> + */
> +static struct serial_state rs_table[] = {
> +/* Âtype  line  PORT      IRQ    FLAGS Âsmc_scc_num (F.K.A. hub6) */
> + Â Â Â { Â0, Â Â 0, PRSLOT_SMC1, CPMVEC_SMC1, Â 0, Â Â0 } Â Â/* SMC1 ttyS0 */
> +#if USE_SMC2
> + Â Â Â ,{ 0, Â Â 0, PRSLOT_SMC2, CPMVEC_SMC2, Â 0, Â Â1 } Â Â /* SMC2 ttyS1 */
> +#endif
> +
> +#if defined(CONFIG_SERIAL_68360_SCC)
> + Â Â Â ,{ 0, Â Â 0, PRSLOT_SCC2, CPMVEC_SCC2, Â 0, (NUM_IS_SCC | 1) } Â Â/* SCC2 ttyS2 */
> + Â Â Â ,{ 0, Â Â 0, PRSLOT_SCC3, CPMVEC_SCC3, Â 0, (NUM_IS_SCC | 2) } Â Â/* SCC3 ttyS3 */
> + Â Â Â ,{ 0, Â Â 0, PRSLOT_SCC4, CPMVEC_SCC4, Â 0, (NUM_IS_SCC | 3) } Â Â/* SCC4 ttyS4 */
> +#endif
> +};
> +
> +#define NR_PORTS Â Â Â (sizeof(rs_table)/sizeof(struct serial_state))
> +
> +/* The number of buffer descriptors and their sizes.
> + */
> +#define RX_NUM_FIFO Â Â4
> +#define RX_BUF_SIZE Â Â32
> +#define TX_NUM_FIFO Â Â4
> +#define TX_BUF_SIZE Â Â32
> +
> +#define CONSOLE_NUM_FIFO 2
> +#define CONSOLE_BUF_SIZE 4
> +
> +char *console_fifos[CONSOLE_NUM_FIFO * CONSOLE_BUF_SIZE];
> +
> +/* The async_struct in serial.h does not really give us what we
> + * need, so define our own here.
> + */
> +typedef struct serial_info {
> +    int           magic;
> +    int           flags;
> +
> +    struct serial_state   *state;
> + Â Â Â /* struct serial_struct *state; */
> + Â Â Â /* struct async_struct Â*state; */
> +
> +    struct tty_struct    *tty;
> +    int           read_status_mask;
> +    int           ignore_status_mask;
> +    int           timeout;
> +    int           line;
> +    int           x_char; /* xon/xoff character */
> +    int           close_delay;
> +    unsigned short     Âclosing_wait;
> +    unsigned short     Âclosing_wait2;
> +    unsigned long      event;
> +    unsigned long      last_active;
> +    int           blocked_open; /* # of blocked opens */
> +    struct work_struct   Âtqueue;
> +    struct work_struct   Âtqueue_hangup;
> +    wait_queue_head_t    open_wait;
> +    wait_queue_head_t    close_wait;
> +
> +
> +/* CPM Buffer Descriptor pointers.
> + Â Â Â */
> + Â Â Â QUICC_BD Â Â Â Â Â Â Â Â Â Â Â Â*rx_bd_base;
> + Â Â Â QUICC_BD Â Â Â Â Â Â Â Â Â Â Â Â*rx_cur;
> + Â Â Â QUICC_BD Â Â Â Â Â Â Â Â Â Â Â Â*tx_bd_base;
> + Â Â Â QUICC_BD Â Â Â Â Â Â Â Â Â Â Â Â*tx_cur;
> +} ser_info_t;
> +
> +
> +/* since kmalloc_init() does not get called until much after this initialization: */
> +static ser_info_t Âquicc_ser_info[NR_PORTS];
> +static char rx_buf_pool[NR_PORTS * RX_NUM_FIFO * RX_BUF_SIZE];
> +static char tx_buf_pool[NR_PORTS * TX_NUM_FIFO * TX_BUF_SIZE];
> +
> +static void change_speed(ser_info_t *info);
> +static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout);
> +
> +static inline int serial_paranoia_check(ser_info_t *info,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â char *name, const char *routine)
> +{
> +#ifdef SERIAL_PARANOIA_CHECK
> + Â Â Â static const char *badmagic =
> + Â Â Â Â Â Â Â "Warning: bad magic number for serial struct (%s) in %s\n";
> + Â Â Â static const char *badinfo =
> + Â Â Â Â Â Â Â "Warning: null async_struct for (%s) in %s\n";
> +
> + Â Â Â if (!info) {
> + Â Â Â Â Â Â Â printk(badinfo, name, routine);
> + Â Â Â Â Â Â Â return 1;
> + Â Â Â }
> + Â Â Â if (info->magic != SERIAL_MAGIC) {
> + Â Â Â Â Â Â Â printk(badmagic, name, routine);
> + Â Â Â Â Â Â Â return 1;
> + Â Â Â }
> +#endif
> + Â Â Â return 0;
> +}
> +
> +/*
> + * This is used to figure out the divisor speeds and the timeouts,
> + * indexed by the termio value. ÂThe generic CPM functions are responsible
> + * for setting and assigning baud rate generators for us.
> + */
> +static int baud_table[] = {
> + Â Â Â 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
> + Â Â Â 9600, 19200, 38400, 57600, 115200, 230400, 460800, 0 };
> +
> +/* This sucks. There is a better way: */
> +#if defined(CONFIG_CONSOLE_9600)
> + Â#define CONSOLE_BAUDRATE 9600
> +#elif defined(CONFIG_CONSOLE_19200)
> + Â#define CONSOLE_BAUDRATE 19200
> +#elif defined(CONFIG_CONSOLE_115200)
> + Â#define CONSOLE_BAUDRATE 115200
> +#else
> + Â#warning "console baud rate undefined"
> + Â#define CONSOLE_BAUDRATE 9600
> +#endif
> +
> +/*
> + * ------------------------------------------------------------
> + * rs_stop() and rs_start()
> + *
> + * This routines are called before setting or resetting tty->stopped.
> + * They enable or disable transmitter interrupts, as necessary.
> + * ------------------------------------------------------------
> + */
> +static void rs_360_stop(struct tty_struct *tty)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> +    int   idx;
> + Â Â Â unsigned long flags;
> + Â Â Â volatile struct scc_regs *sccp;
> + Â Â Â volatile struct smc_regs *smcp;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_stop"))
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â local_irq_save(flags);
> + Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> + Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> + Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> + Â Â Â Â Â Â Â sccp->scc_sccm &= ~UART_SCCM_TX;
> + Â Â Â } else {
> + Â Â Â Â Â Â Â /* smcp = &cpmp->cp_smc[idx]; */
> + Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> + Â Â Â Â Â Â Â smcp->smc_smcm &= ~SMCM_TX;
> + Â Â Â }
> + Â Â Â local_irq_restore(flags);
> +}
> +
> +
> +static void rs_360_start(struct tty_struct *tty)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> +    int   idx;
> + Â Â Â unsigned long flags;
> + Â Â Â volatile struct scc_regs *sccp;
> + Â Â Â volatile struct smc_regs *smcp;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_stop"))
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â local_irq_save(flags);
> + Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> + Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> + Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> + Â Â Â Â Â Â Â sccp->scc_sccm |= UART_SCCM_TX;
> + Â Â Â } else {
> + Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> + Â Â Â Â Â Â Â smcp->smc_smcm |= SMCM_TX;
> + Â Â Â }
> + Â Â Â local_irq_restore(flags);
> +}
> +
> +/*
> + * ----------------------------------------------------------------------
> + *
> + * Here starts the interrupt handling routines. ÂAll of the following
> + * subroutines are declared as inline and are folded into
> + * rs_interrupt(). ÂThey were separated out for readability's sake.
> + *
> + * Note: rs_interrupt() is a "fast" interrupt, which means that it
> + * runs with interrupts turned off. ÂPeople who may want to modify
> + * rs_interrupt() should try to keep the interrupt handler as fast as
> + * possible. ÂAfter you are done making modifications, it is not a bad
> + * idea to do:
> + *
> + * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
> + *
> + * and look at the resulting assemble code in serial.s.
> + *
> + * Â Â Â Â Â Â Â Â Â Â Â Â Â Â - Ted Ts'o (tytso@xxxxxxx), 7-Mar-93
> + * -----------------------------------------------------------------------
> + */
> +
> +static _INLINE_ void receive_chars(ser_info_t *info)
> +{
> + Â Â Â struct tty_struct *tty = info->port.tty;
> + Â Â Â unsigned char ch, flag, *cp;
> +    /*int  ignored = 0;*/
> +    int   i;
> + Â Â Â ushort Âstatus;
> + Â Â Â Âstruct async_icount *icount;
> +    /* struct    async_icount_24 *icount; */
> + Â Â Â volatile QUICC_BD Â Â Â *bdp;
> +
> + Â Â Â icount = &info->state->icount;
> +
> + Â Â Â /* Just loop through the closed BDs and copy the characters into
> + Â Â Â Â* the buffer.
> + Â Â Â Â*/
> + Â Â Â bdp = info->rx_cur;
> + Â Â Â for (;;) {
> + Â Â Â Â Â Â Â if (bdp->status & BD_SC_EMPTY) Â/* If this one is empty */
> + Â Â Â Â Â Â Â Â Â Â Â break; Â Â Â Â Â Â Â Â Â/* Â we are all done */
> +
> + Â Â Â Â Â Â Â /* The read status mask tell us what we should do with
> + Â Â Â Â Â Â Â Â* incoming characters, especially if errors occur.
> + Â Â Â Â Â Â Â Â* One special case is the use of BD_SC_EMPTY. ÂIf
> + Â Â Â Â Â Â Â Â* this is not set, we are supposed to be ignoring
> + Â Â Â Â Â Â Â Â* inputs. ÂIn this case, just mark the buffer empty and
> + Â Â Â Â Â Â Â Â* continue.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â if (!(info->read_status_mask & BD_SC_EMPTY)) {
> + Â Â Â Â Â Â Â Â Â Â Â bdp->status |= BD_SC_EMPTY;
> + Â Â Â Â Â Â Â Â Â Â Â bdp->status &=
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
> +
> + Â Â Â Â Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp = info->rx_bd_base;
> + Â Â Â Â Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp++;
> + Â Â Â Â Â Â Â Â Â Â Â continue;
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â /* Get the number of characters and the buffer pointer.
> + Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â i = bdp->length;
> + Â Â Â Â Â Â Â /* cp = (unsigned char *)__va(bdp->buf); */
> + Â Â Â Â Â Â Â cp = (char *)bdp->buf;
> + Â Â Â Â Â Â Â status = bdp->status;
> +
> + Â Â Â Â Â Â Â while (i-- > 0) {
> + Â Â Â Â Â Â Â Â Â Â Â ch = *cp++;
> + Â Â Â Â Â Â Â Â Â Â Â icount->rx++;
> +
> +#ifdef SERIAL_DEBUG_INTR
> + Â Â Â Â Â Â Â Â Â Â Â printk("DR%02x:%02x...", ch, status);
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â flag = TTY_NORMAL;
> +
> + Â Â Â Â Â Â Â Â Â Â Â if (status & (BD_SC_BR | BD_SC_FR |
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂBD_SC_PR | BD_SC_OV)) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* For statistics only
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (status & BD_SC_BR)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â icount->brk++;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else if (status & BD_SC_PR)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â icount->parity++;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else if (status & BD_SC_FR)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â icount->frame++;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (status & BD_SC_OV)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â icount->overrun++;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* Now check to see if character should be
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* ignored, and mask off conditions which
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* should be ignored.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (status & info->ignore_status_mask) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (++ignored > 100)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â status &= info->read_status_mask;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (status & (BD_SC_BR)) {
> +#ifdef SERIAL_DEBUG_INTR
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk("handling break....");
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â *tty->flip.flag_buf_ptr = TTY_BREAK;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (info->flags & ASYNC_SAK)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â do_SAK(tty);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } else if (status & BD_SC_PR)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â flag = TTY_PARITY;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else if (status & BD_SC_FR)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â flag = TTY_FRAME;
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â tty_insert_flip_char(tty, ch, flag);
> + Â Â Â Â Â Â Â Â Â Â Â if (status & BD_SC_OV)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* Overrun is special, since it's
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* reported immediately, and doesn't
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* affect the current character
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tty_insert_flip_char(tty, 0, TTY_OVERRUN);
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â /* This BD is ready to be used again. ÂClear status.
> + Â Â Â Â Â Â Â Â* Get next BD.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â bdp->status |= BD_SC_EMPTY;
> + Â Â Â Â Â Â Â bdp->status &= ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
> +
> + Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP)
> + Â Â Â Â Â Â Â Â Â Â Â bdp = info->rx_bd_base;
> + Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â bdp++;
> + Â Â Â }
> +
> + Â Â Â info->rx_cur = (QUICC_BD *)bdp;
> +
> + Â Â Â tty_schedule_flip(tty);
> +}
> +
> +static _INLINE_ void receive_break(ser_info_t *info)
> +{
> + Â Â Â struct tty_struct *tty = info->port.tty;
> +
> + Â Â Â info->state->icount.brk++;
> + Â Â Â /* Check to see if there is room in the tty buffer for
> + Â Â Â Â* the break. ÂIf not, we exit now, losing the break. ÂFIXME
> + Â Â Â Â*/
> + Â Â Â tty_insert_flip_char(tty, 0, TTY_BREAK);
> + Â Â Â tty_schedule_flip(tty);
> +}
> +
> +static _INLINE_ void transmit_chars(ser_info_t *info)
> +{
> +
> + Â Â Â if ((info->flags & TX_WAKEUP) ||
> + Â Â Â Â Â (info->port.tty->flags & (1 << TTY_DO_WRITE_WAKEUP))) {
> + Â Â Â Â Â Â Â schedule_work(&info->tqueue);
> + Â Â Â }
> +
> +#ifdef SERIAL_DEBUG_INTR
> + Â Â Â printk("THRE...");
> +#endif
> +}
> +
> +#ifdef notdef
> + Â Â Â /* I need to do this for the SCCs, so it is left as a reminder.
> + Â Â Â */
> +static _INLINE_ void check_modem_status(struct async_struct *info)
> +{
> +    int   status;
> +    /* struct    async_icount *icount; */
> + Â Â Â struct Âasync_icount_24 *icount;
> +
> + Â Â Â status = serial_in(info, UART_MSR);
> +
> + Â Â Â if (status & UART_MSR_ANY_DELTA) {
> + Â Â Â Â Â Â Â icount = &info->state->icount;
> + Â Â Â Â Â Â Â /* update input line counters */
> + Â Â Â Â Â Â Â if (status & UART_MSR_TERI)
> + Â Â Â Â Â Â Â Â Â Â Â icount->rng++;
> + Â Â Â Â Â Â Â if (status & UART_MSR_DDSR)
> + Â Â Â Â Â Â Â Â Â Â Â icount->dsr++;
> + Â Â Â Â Â Â Â if (status & UART_MSR_DDCD) {
> + Â Â Â Â Â Â Â Â Â Â Â icount->dcd++;
> +#ifdef CONFIG_HARD_PPS
> + Â Â Â Â Â Â Â Â Â Â Â if ((info->flags & ASYNC_HARDPPS_CD) &&
> + Â Â Â Â Â Â Â Â Â Â Â Â Â (status & UART_MSR_DCD))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â hardpps();
> +#endif
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â if (status & UART_MSR_DCTS)
> + Â Â Â Â Â Â Â Â Â Â Â icount->cts++;
> + Â Â Â Â Â Â Â wake_up_interruptible(&info->delta_msr_wait);
> + Â Â Â }
> +
> + Â Â Â if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
> +#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
> + Â Â Â Â Â Â Â printk("ttys%d CD now %s...", info->line,
> + Â Â Â Â Â Â Â Â Â Â Â(status & UART_MSR_DCD) ? "on" : "off");
> +#endif
> + Â Â Â Â Â Â Â if (status & UART_MSR_DCD)
> + Â Â Â Â Â Â Â Â Â Â Â wake_up_interruptible(&info->open_wait);
> + Â Â Â Â Â Â Â else {
> +#ifdef SERIAL_DEBUG_OPEN
> + Â Â Â Â Â Â Â Â Â Â Â printk("scheduling hangup...");
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â queue_task(&info->tqueue_hangup,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â&tq_scheduler);
> + Â Â Â Â Â Â Â }
> + Â Â Â }
> + Â Â Â if (info->flags & ASYNC_CTS_FLOW) {
> + Â Â Â Â Â Â Â if (info->port.tty->hw_stopped) {
> + Â Â Â Â Â Â Â Â Â Â Â if (status & UART_MSR_CTS) {
> +#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk("CTS tx start...");
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info->port.tty->hw_stopped = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info->IER |= UART_IER_THRI;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â serial_out(info, UART_IER, info->IER);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return;
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â } else {
> + Â Â Â Â Â Â Â Â Â Â Â if (!(status & UART_MSR_CTS)) {
> +#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk("CTS tx stop...");
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info->port.tty->hw_stopped = 1;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info->IER &= ~UART_IER_THRI;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â serial_out(info, UART_IER, info->IER);
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â }
> + Â Â Â }
> +}
> +#endif
> +
> +/*
> + * This is the serial driver's interrupt routine for a single port
> + */
> +/* static void rs_360_interrupt(void *dev_id) */ /* until and if we start servicing irqs here */
> +static void rs_360_interrupt(int vec, void *dev_id)
> +{
> + Â Â Â u_char Âevents;
> +    int   idx;
> + Â Â Â ser_info_t *info;
> + Â Â Â volatile struct smc_regs *smcp;
> + Â Â Â volatile struct scc_regs *sccp;
> +
> + Â Â Â info = dev_id;
> +
> + Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> + Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> + Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> + Â Â Â Â Â Â Â events = sccp->scc_scce;
> + Â Â Â Â Â Â Â if (events & SCCM_RX)
> + Â Â Â Â Â Â Â Â Â Â Â receive_chars(info);
> + Â Â Â Â Â Â Â if (events & SCCM_TX)
> + Â Â Â Â Â Â Â Â Â Â Â transmit_chars(info);
> + Â Â Â Â Â Â Â sccp->scc_scce = events;
> + Â Â Â } else {
> + Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> + Â Â Â Â Â Â Â events = smcp->smc_smce;
> + Â Â Â Â Â Â Â if (events & SMCM_BRKE)
> + Â Â Â Â Â Â Â Â Â Â Â receive_break(info);
> + Â Â Â Â Â Â Â if (events & SMCM_RX)
> + Â Â Â Â Â Â Â Â Â Â Â receive_chars(info);
> + Â Â Â Â Â Â Â if (events & SMCM_TX)
> + Â Â Â Â Â Â Â Â Â Â Â transmit_chars(info);
> + Â Â Â Â Â Â Â smcp->smc_smce = events;
> + Â Â Â }
> +
> +#ifdef SERIAL_DEBUG_INTR
> + Â Â Â printk("rs_interrupt_single(%d, %x)...",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info->state->smc_scc_num, events);
> +#endif
> +#ifdef modem_control
> + Â Â Â check_modem_status(info);
> +#endif
> + Â Â Â info->last_active = jiffies;
> +#ifdef SERIAL_DEBUG_INTR
> + Â Â Â printk("end.\n");
> +#endif
> +}
> +
> +
> +/*
> + * -------------------------------------------------------------------
> + * Here ends the serial interrupt routines.
> + * -------------------------------------------------------------------
> + */
> +
> +
> +static void do_softint(void *private_)
> +{
> +    ser_info_t   Â*info = (ser_info_t *) private_;
> +    struct tty_struct    *tty;
> +
> + Â Â Â tty = info->port.tty;
> + Â Â Â if (!tty)
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
> + Â Â Â Â Â Â Â tty_wakeup(tty);
> +}
> +
> +
> +/*
> + * This routine is called from the scheduler tqueue when the interrupt
> + * routine has signalled that a hangup has occurred. ÂThe path of
> + * hangup processing is:
> + *
> + * Â Â serial interrupt routine -> (scheduler tqueue) ->
> + * Â Â do_serial_hangup() -> tty->hangup() -> rs_hangup()
> + *
> + */
> +static void do_serial_hangup(void *private_)
> +{
> +    struct async_struct   *info = (struct async_struct *) private_;
> +    struct tty_struct    *tty;
> +
> + Â Â Â tty = info->port.tty;
> + Â Â Â if (!tty)
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â tty_hangup(tty);
> +}
> +
> +
> +static int startup(ser_info_t *info)
> +{
> + Â Â Â unsigned long flags;
> +    int   retval=0;
> +    int   idx;
> + Â Â Â /*struct serial_state *state = info->state;*/
> + Â Â Â volatile struct smc_regs *smcp;
> + Â Â Â volatile struct scc_regs *sccp;
> +    volatile struct smc_uart_pram  *up;
> +    volatile struct uart_pram      *scup;
> +
> +
> + Â Â Â local_irq_save(flags);
> +
> + Â Â Â if (info->flags & ASYNC_INITIALIZED) {
> + Â Â Â Â Â Â Â goto errout;
> + Â Â Â }
> +
> +#ifdef maybe
> + Â Â Â if (!state->port || !state->type) {
> + Â Â Â Â Â Â Â if (info->port.tty)
> + Â Â Â Â Â Â Â Â Â Â Â set_bit(TTY_IO_ERROR, &info->port.tty->flags);
> + Â Â Â Â Â Â Â goto errout;
> + Â Â Â }
> +#endif
> +
> +#ifdef SERIAL_DEBUG_OPEN
> + Â Â Â printk("starting up ttys%d (irq %d)...", info->line, state->irq);
> +#endif
> +
> +
> +#ifdef modem_control
> + Â Â Â info->MCR = 0;
> + Â Â Â if (info->port.tty->termios->c_cflag & CBAUD)
> + Â Â Â Â Â Â Â info->MCR = UART_MCR_DTR | UART_MCR_RTS;
> +#endif
> +
> + Â Â Â if (info->port.tty)
> + Â Â Â Â Â Â Â clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
> +
> + Â Â Â /*
> + Â Â Â Â* and set the speed of the serial port
> + Â Â Â Â*/
> + Â Â Â change_speed(info);
> +
> + Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> + Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> + Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> + Â Â Â Â Â Â Â scup = &pquicc->pram[info->state->port].scc.pscc.u;
> +
> + Â Â Â Â Â Â Â scup->mrblr = RX_BUF_SIZE;
> + Â Â Â Â Â Â Â scup->max_idl = RX_BUF_SIZE;
> +
> + Â Â Â Â Â Â Â sccp->scc_sccm |= (UART_SCCM_TX | UART_SCCM_RX);
> + Â Â Â Â Â Â Â sccp->scc_gsmr.w.low |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
> +
> + Â Â Â } else {
> + Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> +
> + Â Â Â Â Â Â Â /* Enable interrupts and I/O.
> + Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
> + Â Â Â Â Â Â Â smcp->smc_smcmr |= (SMCMR_REN | SMCMR_TEN);
> +
> + Â Â Â Â Â Â Â /* We can tune the buffer length and idle characters
> + Â Â Â Â Â Â Â Â* to take advantage of the entire incoming buffer size.
> + Â Â Â Â Â Â Â Â* If mrblr is something other than 1, maxidl has to be
> + Â Â Â Â Â Â Â Â* non-zero or we never get an interrupt. ÂThe maxidl
> + Â Â Â Â Â Â Â Â* is the number of character times we wait after reception
> + Â Â Â Â Â Â Â Â* of the last character before we decide no more characters
> + Â Â Â Â Â Â Â Â* are coming.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â /* up = (smc_uart_t *)&pquicc->cp_dparam[state->port]; */
> + Â Â Â Â Â Â Â /* holy unionized structures, Batman: */
> + Â Â Â Â Â Â Â up = &pquicc->pram[info->state->port].scc.pothers.idma_smc.psmc.u;
> +
> + Â Â Â Â Â Â Â up->mrblr = RX_BUF_SIZE;
> + Â Â Â Â Â Â Â up->max_idl = RX_BUF_SIZE;
> +
> + Â Â Â Â Â Â Â up->brkcr = 1; Â/* number of break chars */
> + Â Â Â }
> +
> + Â Â Â info->flags |= ASYNC_INITIALIZED;
> + Â Â Â local_irq_restore(flags);
> + Â Â Â return 0;
> +
> +errout:
> + Â Â Â local_irq_restore(flags);
> + Â Â Â return retval;
> +}
> +
> +/*
> + * This routine will shutdown a serial port; interrupts are disabled, and
> + * DTR is dropped if the hangup on close termio flag is on.
> + */
> +static void shutdown(ser_info_t *info)
> +{
> +    unsigned long  flags;
> + Â Â Â struct serial_state *state;
> +    int       idx;
> +    volatile struct smc_regs    Â*smcp;
> +    volatile struct scc_regs    Â*sccp;
> +
> + Â Â Â if (!(info->flags & ASYNC_INITIALIZED))
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â state = info->state;
> +
> +#ifdef SERIAL_DEBUG_OPEN
> + Â Â Â printk("Shutting down serial port %d (irq %d)....", info->line,
> + Â Â Â Â Â Â Âstate->irq);
> +#endif
> +
> + Â Â Â local_irq_save(flags);
> +
> + Â Â Â idx = PORT_NUM(state->smc_scc_num);
> + Â Â Â if (state->smc_scc_num & NUM_IS_SCC) {
> + Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> + Â Â Â Â Â Â Â sccp->scc_gsmr.w.low &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
> +#ifdef CONFIG_SERIAL_CONSOLE
> + Â Â Â Â Â Â Â /* We can't disable the transmitter if this is the
> + Â Â Â Â Â Â Â Â* system console.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â if ((state - rs_table) != CONFIG_SERIAL_CONSOLE_PORT)
> +#endif
> + Â Â Â Â Â Â Â sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
> + Â Â Â } else {
> + Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> +
> + Â Â Â Â Â Â Â /* Disable interrupts and I/O.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
> +#ifdef CONFIG_SERIAL_CONSOLE
> + Â Â Â Â Â Â Â /* We can't disable the transmitter if this is the
> + Â Â Â Â Â Â Â Â* system console.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â if ((state - rs_table) != CONFIG_SERIAL_CONSOLE_PORT)
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
> + Â Â Â }
> +
> + Â Â Â if (info->port.tty)
> + Â Â Â Â Â Â Â set_bit(TTY_IO_ERROR, &info->port.tty->flags);
> +
> + Â Â Â info->flags &= ~ASYNC_INITIALIZED;
> + Â Â Â local_irq_restore(flags);
> +}
> +
> +/*
> + * This routine is called to set the UART divisor registers to match
> + * the specified baud rate for a serial port.
> + */
> +static void change_speed(ser_info_t *info)
> +{
> +    int   baud_rate;
> + Â Â Â unsigned cflag, cval, scval, prev_mode;
> +    int   i, bits, sbits, idx;
> +    unsigned long  flags;
> + Â Â Â struct serial_state *state;
> +    volatile struct smc_regs    Â*smcp;
> +    volatile struct scc_regs    Â*sccp;
> +
> + Â Â Â if (!info->port.tty || !info->port.tty->termios)
> + Â Â Â Â Â Â Â return;
> + Â Â Â cflag = info->port.tty->termios->c_cflag;
> +
> + Â Â Â state = info->state;
> +
> + Â Â Â /* Character length programmed into the mode register is the
> + Â Â Â Â* sum of: 1 start bit, number of data bits, 0 or 1 parity bit,
> + Â Â Â Â* 1 or 2 stop bits, minus 1.
> + Â Â Â Â* The value 'bits' counts this for us.
> + Â Â Â Â*/
> + Â Â Â cval = 0;
> + Â Â Â scval = 0;
> +
> + Â Â Â /* byte size and parity */
> + Â Â Â switch (cflag & CSIZE) {
> + Â Â Â Â Â Â case CS5: bits = 5; break;
> + Â Â Â Â Â Â case CS6: bits = 6; break;
> + Â Â Â Â Â Â case CS7: bits = 7; break;
> + Â Â Â Â Â Â case CS8: bits = 8; break;
> + Â Â Â Â Â Â /* Never happens, but GCC is too dumb to figure it out */
> + Â Â Â Â Â Â default: Âbits = 8; break;
> + Â Â Â }
> + Â Â Â sbits = bits - 5;
> +
> + Â Â Â if (cflag & CSTOPB) {
> + Â Â Â Â Â Â Â cval |= SMCMR_SL; Â Â Â /* Two stops */
> + Â Â Â Â Â Â Â scval |= SCU_PMSR_SL;
> + Â Â Â Â Â Â Â bits++;
> + Â Â Â }
> + Â Â Â if (cflag & PARENB) {
> + Â Â Â Â Â Â Â cval |= SMCMR_PEN;
> + Â Â Â Â Â Â Â scval |= SCU_PMSR_PEN;
> + Â Â Â Â Â Â Â bits++;
> + Â Â Â }
> + Â Â Â if (!(cflag & PARODD)) {
> + Â Â Â Â Â Â Â cval |= SMCMR_PM_EVEN;
> + Â Â Â Â Â Â Â scval |= (SCU_PMSR_REVP | SCU_PMSR_TEVP);
> + Â Â Â }
> +
> + Â Â Â /* Determine divisor based on baud rate */
> + Â Â Â i = cflag & CBAUD;
> + Â Â Â if (i >= (sizeof(baud_table)/sizeof(int)))
> + Â Â Â Â Â Â Â baud_rate = 9600;
> + Â Â Â else
> + Â Â Â Â Â Â Â baud_rate = baud_table[i];
> +
> + Â Â Â info->timeout = (TX_BUF_SIZE*HZ*bits);
> + Â Â Â info->timeout += HZ/50; Â Â Â Â /* Add .02 seconds of slop */
> +
> +#ifdef modem_control
> + Â Â Â /* CTS flow control flag and modem status interrupts */
> + Â Â Â info->IER &= ~UART_IER_MSI;
> + Â Â Â if (info->flags & ASYNC_HARDPPS_CD)
> + Â Â Â Â Â Â Â info->IER |= UART_IER_MSI;
> + Â Â Â if (cflag & CRTSCTS) {
> + Â Â Â Â Â Â Â info->flags |= ASYNC_CTS_FLOW;
> + Â Â Â Â Â Â Â info->IER |= UART_IER_MSI;
> + Â Â Â } else
> + Â Â Â Â Â Â Â info->flags &= ~ASYNC_CTS_FLOW;
> + Â Â Â if (cflag & CLOCAL)
> + Â Â Â Â Â Â Â info->flags &= ~ASYNC_CHECK_CD;
> + Â Â Â else {
> + Â Â Â Â Â Â Â info->flags |= ASYNC_CHECK_CD;
> + Â Â Â Â Â Â Â info->IER |= UART_IER_MSI;
> + Â Â Â }
> + Â Â Â serial_out(info, UART_IER, info->IER);
> +#endif
> +
> + Â Â Â /*
> + Â Â Â Â* Set up parity check flag
> + Â Â Â Â*/
> + Â Â Â info->read_status_mask = (BD_SC_EMPTY | BD_SC_OV);
> + Â Â Â if (I_INPCK(info->port.tty))
> + Â Â Â Â Â Â Â info->read_status_mask |= BD_SC_FR | BD_SC_PR;
> + Â Â Â if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
> + Â Â Â Â Â Â Â info->read_status_mask |= BD_SC_BR;
> +
> + Â Â Â /*
> + Â Â Â Â* Characters to ignore
> + Â Â Â Â*/
> + Â Â Â info->ignore_status_mask = 0;
> + Â Â Â if (I_IGNPAR(info->port.tty))
> + Â Â Â Â Â Â Â info->ignore_status_mask |= BD_SC_PR | BD_SC_FR;
> + Â Â Â if (I_IGNBRK(info->port.tty)) {
> + Â Â Â Â Â Â Â info->ignore_status_mask |= BD_SC_BR;
> + Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â* If we're ignore parity and break indicators, ignore
> + Â Â Â Â Â Â Â Â* overruns too. Â(For real raw support).
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â if (I_IGNPAR(info->port.tty))
> + Â Â Â Â Â Â Â Â Â Â Â info->ignore_status_mask |= BD_SC_OV;
> + Â Â Â }
> + Â Â Â /*
> + Â Â Â Â* !!! ignore all characters if CREAD is not set
> + Â Â Â Â*/
> + Â Â Â if ((cflag & CREAD) == 0)
> + Â Â Â Âinfo->read_status_mask &= ~BD_SC_EMPTY;
> + Â Â Â Âlocal_irq_save(flags);
> +
> + Â Â Â Â/* Start bit has not been added (so don't, because we would just
> + Â Â Â Â * subtract it later), and we need to add one for the number of
> + Â Â Â Â * stops bits (there is always at least one).
> + Â Â Â Â */
> + Â Â Â Âbits++;
> + Â Â Â Âidx = PORT_NUM(state->smc_scc_num);
> + Â Â Â Âif (state->smc_scc_num & NUM_IS_SCC) {
> + Â Â Â Â sccp = &pquicc->scc_regs[idx];
> + Â Â Â Â sccp->scc_psmr = (sbits << 12) | scval;
> + Â Â } else {
> + Â Â Â Â smcp = &pquicc->smc_regs[idx];
> +
> + Â Â Â Â Â Â Â /* Set the mode register. ÂWe want to keep a copy of the
> + Â Â Â Â Â Â Â Â* enables, because we want to put them back if they were
> + Â Â Â Â Â Â Â Â* present.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â prev_mode = smcp->smc_smcmr;
> + Â Â Â Â Â Â Â smcp->smc_smcmr = smcr_mk_clen(bits) | cval | ÂSMCMR_SM_UART;
> + Â Â Â Â Â Â Â smcp->smc_smcmr |= (prev_mode & (SMCMR_REN | SMCMR_TEN));
> + Â Â Â }
> +
> + Â Â Â m360_cpm_setbrg((state - rs_table), baud_rate);
> +
> + Â Â Â local_irq_restore(flags);
> +}
> +
> +static void rs_360_put_char(struct tty_struct *tty, unsigned char ch)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> + Â Â Â volatile QUICC_BD Â Â Â *bdp;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_put_char"))
> + Â Â Â Â Â Â Â return 0;
> +
> + Â Â Â if (!tty)
> + Â Â Â Â Â Â Â return 0;
> +
> + Â Â Â bdp = info->tx_cur;
> + Â Â Â while (bdp->status & BD_SC_READY);
> +
> + Â Â Â /* *((char *)__va(bdp->buf)) = ch; */
> + Â Â Â *((char *)bdp->buf) = ch;
> + Â Â Â bdp->length = 1;
> + Â Â Â bdp->status |= BD_SC_READY;
> +
> + Â Â Â /* Get next BD.
> + Â Â Â */
> + Â Â Â if (bdp->status & BD_SC_WRAP)
> + Â Â Â Â Â Â Â bdp = info->tx_bd_base;
> + Â Â Â else
> + Â Â Â Â Â Â Â bdp++;
> +
> + Â Â Â info->tx_cur = (QUICC_BD *)bdp;
> + Â Â Â return 1;
> +
> +}
> +
> +static int rs_360_write(struct tty_struct * tty,
> + Â Â Â Â Â Â Â Â Â const unsigned char *buf, int count)
> +{
> +    int   c, ret = 0;
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> + Â Â Â volatile QUICC_BD *bdp;
> +
> +#ifdef CONFIG_KGDB
> + Â Â Â /* Try to let stub handle output. Returns true if it did. */
> + Â Â Â if (kgdb_output_string(buf, count))
> + Â Â Â Â Â Â Â return ret;
> +#endif
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_write"))
> + Â Â Â Â Â Â Â return 0;
> +
> + Â Â Â if (!tty)
> + Â Â Â Â Â Â Â return 0;
> +
> + Â Â Â bdp = info->tx_cur;
> +
> + Â Â Â while (1) {
> + Â Â Â Â Â Â Â c = min(count, TX_BUF_SIZE);
> +
> + Â Â Â Â Â Â Â if (c <= 0)
> + Â Â Â Â Â Â Â Â Â Â Â break;
> +
> + Â Â Â Â Â Â Â if (bdp->status & BD_SC_READY) {
> + Â Â Â Â Â Â Â Â Â Â Â info->flags |= TX_WAKEUP;
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â /* memcpy(__va(bdp->buf), buf, c); */
> + Â Â Â Â Â Â Â memcpy((void *)bdp->buf, buf, c);
> +
> + Â Â Â Â Â Â Â bdp->length = c;
> + Â Â Â Â Â Â Â bdp->status |= BD_SC_READY;
> +
> + Â Â Â Â Â Â Â buf += c;
> + Â Â Â Â Â Â Â count -= c;
> + Â Â Â Â Â Â Â ret += c;
> +
> + Â Â Â Â Â Â Â /* Get next BD.
> + Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP)
> + Â Â Â Â Â Â Â Â Â Â Â bdp = info->tx_bd_base;
> + Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â bdp++;
> + Â Â Â Â Â Â Â info->tx_cur = (QUICC_BD *)bdp;
> + Â Â Â }
> + Â Â Â return ret;
> +}
> +
> +static int rs_360_write_room(struct tty_struct *tty)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> +    int   ret;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_write_room"))
> + Â Â Â Â Â Â Â return 0;
> +
> + Â Â Â if ((info->tx_cur->status & BD_SC_READY) == 0) {
> + Â Â Â Â Â Â Â info->flags &= ~TX_WAKEUP;
> + Â Â Â Â Â Â Â ret = TX_BUF_SIZE;
> + Â Â Â }
> + Â Â Â else {
> + Â Â Â Â Â Â Â info->flags |= TX_WAKEUP;
> + Â Â Â Â Â Â Â ret = 0;
> + Â Â Â }
> + Â Â Â return ret;
> +}
> +
> +/* I could track this with transmit counters....maybe later.
> +*/
> +static int rs_360_chars_in_buffer(struct tty_struct *tty)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â return 0;
> +}
> +
> +static void rs_360_flush_buffer(struct tty_struct *tty)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â /* There is nothing to "flush", whatever we gave the CPM
> + Â Â Â Â* is on its way out.
> + Â Â Â Â*/
> + Â Â Â tty_wakeup(tty);
> + Â Â Â info->flags &= ~TX_WAKEUP;
> +}
> +
> +/*
> + * This function is used to send a high-priority XON/XOFF character to
> + * the device
> + */
> +static void rs_360_send_xchar(struct tty_struct *tty, char ch)
> +{
> + Â Â Â volatile QUICC_BD Â Â Â *bdp;
> +
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_send_char"))
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â bdp = info->tx_cur;
> + Â Â Â while (bdp->status & BD_SC_READY);
> +
> + Â Â Â /* *((char *)__va(bdp->buf)) = ch; */
> + Â Â Â *((char *)bdp->buf) = ch;
> + Â Â Â bdp->length = 1;
> + Â Â Â bdp->status |= BD_SC_READY;
> +
> + Â Â Â /* Get next BD.
> + Â Â Â */
> + Â Â Â if (bdp->status & BD_SC_WRAP)
> + Â Â Â Â Â Â Â bdp = info->tx_bd_base;
> + Â Â Â else
> + Â Â Â Â Â Â Â bdp++;
> +
> + Â Â Â info->tx_cur = (QUICC_BD *)bdp;
> +}
> +
> +/*
> + * ------------------------------------------------------------
> + * rs_throttle()
> + *
> + * This routine is called by the upper-layer tty layer to signal that
> + * incoming characters should be throttled.
> + * ------------------------------------------------------------
> + */
> +static void rs_360_throttle(struct tty_struct * tty)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> +#ifdef SERIAL_DEBUG_THROTTLE
> +    char  Âbuf[64];
> +
> + Â Â Â printk("throttle %s: %d....\n", _tty_name(tty, buf),
> + Â Â Â Â Â Â Âtty->ldisc.chars_in_buffer(tty));
> +#endif
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_throttle"))
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â if (I_IXOFF(tty))
> + Â Â Â Â Â Â Â rs_360_send_xchar(tty, STOP_CHAR(tty));
> +
> +#ifdef modem_control
> + Â Â Â if (tty->termios->c_cflag & CRTSCTS)
> + Â Â Â Â Â Â Â info->MCR &= ~UART_MCR_RTS;
> +
> + Â Â Â local_irq_disable();
> + Â Â Â serial_out(info, UART_MCR, info->MCR);
> + Â Â Â local_irq_enable();
> +#endif
> +}
> +
> +static void rs_360_unthrottle(struct tty_struct * tty)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> +#ifdef SERIAL_DEBUG_THROTTLE
> +    char  Âbuf[64];
> +
> + Â Â Â printk("unthrottle %s: %d....\n", _tty_name(tty, buf),
> + Â Â Â Â Â Â Âtty->ldisc.chars_in_buffer(tty));
> +#endif
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â if (I_IXOFF(tty)) {
> + Â Â Â Â Â Â Â if (info->x_char)
> + Â Â Â Â Â Â Â Â Â Â Â info->x_char = 0;
> + Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â rs_360_send_xchar(tty, START_CHAR(tty));
> + Â Â Â }
> +#ifdef modem_control
> + Â Â Â if (tty->termios->c_cflag & CRTSCTS)
> + Â Â Â Â Â Â Â info->MCR |= UART_MCR_RTS;
> + Â Â Â local_irq_disable();
> + Â Â Â serial_out(info, UART_MCR, info->MCR);
> + Â Â Â local_irq_enable();
> +#endif
> +}
> +
> +/*
> + * ------------------------------------------------------------
> + * rs_ioctl() and friends
> + * ------------------------------------------------------------
> + */
> +
> +#ifdef maybe
> +/*
> + * get_lsr_info - get line status register info
> + *
> + * Purpose: Let user call ioctl() to get info when the UART physically
> + * Â Â Â Â is emptied. ÂOn bus types like RS485, the transmitter must
> + * Â Â Â Â release the bus after transmitting. This must be done when
> + * Â Â Â Â the transmit shift register is empty, not be done when the
> + * Â Â Â Â transmit holding register is empty. ÂThis functionality
> + * Â Â Â Â allows an RS485 driver to be written in user space.
> + */
> +static int get_lsr_info(struct async_struct * info, unsigned int *value)
> +{
> + Â Â Â unsigned char status;
> + Â Â Â unsigned int result;
> +
> + Â Â Â local_irq_disable();
> + Â Â Â status = serial_in(info, UART_LSR);
> + Â Â Â local_irq_enable();
> + Â Â Â result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
> + Â Â Â return put_user(result,value);
> +}
> +#endif
> +
> +static int rs_360_tiocmget(struct tty_struct *tty)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> + Â Â Â unsigned int result = 0;
> +#ifdef modem_control
> + Â Â Â unsigned char control, status;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, __func__))
> + Â Â Â Â Â Â Â return -ENODEV;
> +
> + Â Â Â if (tty->flags & (1 << TTY_IO_ERROR))
> + Â Â Â Â Â Â Â return -EIO;
> +
> + Â Â Â control = info->MCR;
> + Â Â Â local_irq_disable();
> + Â Â Â status = serial_in(info, UART_MSR);
> + Â Â Â local_irq_enable();
> + Â Â Â result = Â((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
> + Â Â Â Â Â Â Â | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
> +#ifdef TIOCM_OUT1
> + Â Â Â Â Â Â Â | ((control & UART_MCR_OUT1) ? TIOCM_OUT1 : 0)
> + Â Â Â Â Â Â Â | ((control & UART_MCR_OUT2) ? TIOCM_OUT2 : 0)
> +#endif
> + Â Â Â Â Â Â Â | ((status Â& UART_MSR_DCD) ? TIOCM_CAR : 0)
> + Â Â Â Â Â Â Â | ((status Â& UART_MSR_RI) ? TIOCM_RNG : 0)
> + Â Â Â Â Â Â Â | ((status Â& UART_MSR_DSR) ? TIOCM_DSR : 0)
> + Â Â Â Â Â Â Â | ((status Â& UART_MSR_CTS) ? TIOCM_CTS : 0);
> +#endif
> + Â Â Â return result;
> +}
> +
> +static int rs_360_tiocmset(struct tty_struct *tty,
> + Â Â Â Â Â Â Â Â Â Â Â Â Âunsigned int set, unsigned int clear)
> +{
> +#ifdef modem_control
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> + Â Â Â unsigned int arg;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, __func__))
> + Â Â Â Â Â Â Â return -ENODEV;
> +
> + Â Â Â if (tty->flags & (1 << TTY_IO_ERROR))
> + Â Â Â Â Â Â Â return -EIO;
> + Â Â Â /* FIXME: locking on info->mcr */
> + Â Â Â if (set & TIOCM_RTS)
> + Â Â Â Â Â Â Â info->mcr |= UART_MCR_RTS;
> + Â Â Â if (set & TIOCM_DTR)
> + Â Â Â Â Â Â Â info->mcr |= UART_MCR_DTR;
> + Â Â Â if (clear & TIOCM_RTS)
> + Â Â Â Â Â Â Â info->MCR &= ~UART_MCR_RTS;
> + Â Â Â if (clear & TIOCM_DTR)
> + Â Â Â Â Â Â Â info->MCR &= ~UART_MCR_DTR;
> +
> +#ifdef TIOCM_OUT1
> + Â Â Â if (set & TIOCM_OUT1)
> + Â Â Â Â Â Â Â info->MCR |= UART_MCR_OUT1;
> + Â Â Â if (set & TIOCM_OUT2)
> + Â Â Â Â Â Â Â info->MCR |= UART_MCR_OUT2;
> + Â Â Â if (clear & TIOCM_OUT1)
> + Â Â Â Â Â Â Â info->MCR &= ~UART_MCR_OUT1;
> + Â Â Â if (clear & TIOCM_OUT2)
> + Â Â Â Â Â Â Â info->MCR &= ~UART_MCR_OUT2;
> +#endif
> +
> + Â Â Â local_irq_disable();
> + Â Â Â serial_out(info, UART_MCR, info->MCR);
> + Â Â Â local_irq_enable();
> +#endif
> + Â Â Â return 0;
> +}
> +
> +/* Sending a break is a two step process on the SMC/SCC. ÂIt is accomplished
> + * by sending a STOP TRANSMIT command followed by a RESTART TRANSMIT
> + * command. ÂWe take advantage of the begin/end functions to make this
> + * happen.
> + */
> +static ushort Âsmc_chan_map[] = {
> + Â Â Â CPM_CR_CH_SMC1,
> + Â Â Â CPM_CR_CH_SMC2
> +};
> +
> +static ushort Âscc_chan_map[] = {
> + Â Â Â CPM_CR_CH_SCC1,
> + Â Â Â CPM_CR_CH_SCC2,
> + Â Â Â CPM_CR_CH_SCC3,
> + Â Â Â CPM_CR_CH_SCC4
> +};
> +
> +static void begin_break(ser_info_t *info)
> +{
> + Â Â Â volatile QUICC *cp;
> + Â Â Â ushort Âchan;
> +    int   idx;
> +
> + Â Â Â cp = pquicc;
> +
> + Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> + Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC)
> + Â Â Â Â Â Â Â chan = scc_chan_map[idx];
> + Â Â Â else
> + Â Â Â Â Â Â Â chan = smc_chan_map[idx];
> +
> + Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_STOP_TX) | CPM_CR_FLG;
> + Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> +}
> +
> +static void end_break(ser_info_t *info)
> +{
> + Â Â Â volatile QUICC *cp;
> + Â Â Â ushort Âchan;
> + Â Â Â int idx;
> +
> + Â Â Â cp = pquicc;
> +
> + Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> + Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC)
> + Â Â Â Â Â Â Â chan = scc_chan_map[idx];
> + Â Â Â else
> + Â Â Â Â Â Â Â chan = smc_chan_map[idx];
> +
> + Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_RESTART_TX) | CPM_CR_FLG;
> + Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> +}
> +
> +/*
> + * This routine sends a break character out the serial port.
> + */
> +static void send_break(ser_info_t *info, unsigned int duration)
> +{
> +#ifdef SERIAL_DEBUG_SEND_BREAK
> + Â Â Â printk("rs_send_break(%d) jiff=%lu...", duration, jiffies);
> +#endif
> + Â Â Â begin_break(info);
> + Â Â Â msleep_interruptible(duration);
> + Â Â Â end_break(info);
> +#ifdef SERIAL_DEBUG_SEND_BREAK
> + Â Â Â printk("done jiffies=%lu\n", jiffies);
> +#endif
> +}
> +
> +
> +/*
> + * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
> + * Return: write counters to the user passed counter struct
> + * NB: both 1->0 and 0->1 transitions are counted except for
> + * Â Â RI where only 0->1 is counted.
> + */
> +static int rs_360_get_icount(struct tty_struct *tty,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct serial_icounter_struct *icount)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> + Â Â Â struct async_icount cnow;
> +
> + Â Â Â local_irq_disable();
> + Â Â Â cnow = info->state->icount;
> + Â Â Â local_irq_enable();
> +
> + Â Â Â icount->cts = cnow.cts;
> + Â Â Â icount->dsr = cnow.dsr;
> + Â Â Â icount->rng = cnow.rng;
> + Â Â Â icount->dcd = cnow.dcd;
> +
> + Â Â Â return 0;
> +}
> +
> +static int rs_360_ioctl(struct tty_struct *tty,
> + Â Â Â Â Â Â Â Â Â unsigned int cmd, unsigned long arg)
> +{
> + Â Â Â int error;
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> + Â Â Â int retval;
> + Â Â Â struct async_icount cnow;
> + Â Â Â /* struct async_icount_24 cnow;*/ Â Â Â /* kernel counter temps */
> + Â Â Â struct serial_icounter_struct *p_cuser; /* user space */
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
> + Â Â Â Â Â Â Â return -ENODEV;
> +
> + Â Â Â if (cmd != TIOCMIWAIT) {
> + Â Â Â Â Â Â Â if (tty->flags & (1 << TTY_IO_ERROR))
> + Â Â Â Â Â Â Â Â Â return -EIO;
> + Â Â Â }
> +
> + Â Â Â switch (cmd) {
> + Â Â Â Â Â Â Â case TCSBRK: Â Â/* SVID version: non-zero arg --> no break */
> + Â Â Â Â Â Â Â Â Â Â Â retval = tty_check_change(tty);
> + Â Â Â Â Â Â Â Â Â Â Â if (retval)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return retval;
> + Â Â Â Â Â Â Â Â Â Â Â tty_wait_until_sent(tty, 0);
> + Â Â Â Â Â Â Â Â Â Â Â if (signal_pending(current))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EINTR;
> + Â Â Â Â Â Â Â Â Â Â Â if (!arg) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â send_break(info, 250); Â/* 1/4 second */
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (signal_pending(current))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EINTR;
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â return 0;
> + Â Â Â Â Â Â Â case TCSBRKP: Â /* support for POSIX tcsendbreak() */
> + Â Â Â Â Â Â Â Â Â Â Â retval = tty_check_change(tty);
> + Â Â Â Â Â Â Â Â Â Â Â if (retval)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return retval;
> + Â Â Â Â Â Â Â Â Â Â Â tty_wait_until_sent(tty, 0);
> + Â Â Â Â Â Â Â Â Â Â Â if (signal_pending(current))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EINTR;
> + Â Â Â Â Â Â Â Â Â Â Â send_break(info, arg ? arg*100 : 250);
> + Â Â Â Â Â Â Â Â Â Â Â if (signal_pending(current))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EINTR;
> + Â Â Â Â Â Â Â Â Â Â Â return 0;
> + Â Â Â Â Â Â Â case TIOCSBRK:
> + Â Â Â Â Â Â Â Â Â Â Â retval = tty_check_change(tty);
> + Â Â Â Â Â Â Â Â Â Â Â if (retval)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return retval;
> + Â Â Â Â Â Â Â Â Â Â Â tty_wait_until_sent(tty, 0);
> + Â Â Â Â Â Â Â Â Â Â Â begin_break(info);
> + Â Â Â Â Â Â Â Â Â Â Â return 0;
> + Â Â Â Â Â Â Â case TIOCCBRK:
> + Â Â Â Â Â Â Â Â Â Â Â retval = tty_check_change(tty);
> + Â Â Â Â Â Â Â Â Â Â Â if (retval)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return retval;
> + Â Â Â Â Â Â Â Â Â Â Â end_break(info);
> + Â Â Â Â Â Â Â Â Â Â Â return 0;
> +#ifdef maybe
> + Â Â Â Â Â Â Â case TIOCSERGETLSR: /* Get line status register */
> + Â Â Â Â Â Â Â Â Â Â Â return get_lsr_info(info, (unsigned int *) arg);
> +#endif
> + Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â* Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
> + Â Â Â Â Â Â Â Â* - mask passed in arg for lines of interest
> + Â Â Â Â Â Â Â Â* Â (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
> + Â Â Â Â Â Â Â Â* Caller should use TIOCGICOUNT to see which one it was
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Âcase TIOCMIWAIT:
> +#ifdef modem_control
> + Â Â Â Â Â Â Â Â Â Â Â local_irq_disable();
> + Â Â Â Â Â Â Â Â Â Â Â /* note the counters on entry */
> + Â Â Â Â Â Â Â Â Â Â Â cprev = info->state->icount;
> + Â Â Â Â Â Â Â Â Â Â Â local_irq_enable();
> + Â Â Â Â Â Â Â Â Â Â Â while (1) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â interruptible_sleep_on(&info->delta_msr_wait);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* see if a signal did it */
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (signal_pending(current))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -ERESTARTSYS;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â local_irq_disable();
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cnow = info->state->icount; /* atomic copy */
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â local_irq_enable();
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EIO; /* no change => error */
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â((arg & TIOCM_CD) Â&& (cnow.dcd != cprev.dcd)) ||
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cprev = cnow;
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â /* NOTREACHED */
> +#else
> + Â Â Â Â Â Â Â Â Â Â Â return 0;
> +#endif
> +
> +
> + Â Â Â Â Â Â Â default:
> + Â Â Â Â Â Â Â Â Â Â Â return -ENOIOCTLCMD;
> + Â Â Â Â Â Â Â }
> + Â Â Â return 0;
> +}
> +
> +/* FIX UP modem control here someday......
> +*/
> +static void rs_360_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> +
> + Â Â Â change_speed(info);
> +
> +#ifdef modem_control
> + Â Â Â /* Handle transition to B0 status */
> + Â Â Â if ((old_termios->c_cflag & CBAUD) &&
> + Â Â Â Â Â !(tty->termios->c_cflag & CBAUD)) {
> + Â Â Â Â Â Â Â info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
> + Â Â Â Â Â Â Â local_irq_disable();
> + Â Â Â Â Â Â Â serial_out(info, UART_MCR, info->MCR);
> + Â Â Â Â Â Â Â local_irq_enable();
> + Â Â Â }
> +
> + Â Â Â /* Handle transition away from B0 status */
> + Â Â Â if (!(old_termios->c_cflag & CBAUD) &&
> + Â Â Â Â Â (tty->termios->c_cflag & CBAUD)) {
> + Â Â Â Â Â Â Â info->MCR |= UART_MCR_DTR;
> + Â Â Â Â Â Â Â if (!tty->hw_stopped ||
> + Â Â Â Â Â Â Â Â Â !(tty->termios->c_cflag & CRTSCTS)) {
> + Â Â Â Â Â Â Â Â Â Â Â info->MCR |= UART_MCR_RTS;
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â local_irq_disable();
> + Â Â Â Â Â Â Â serial_out(info, UART_MCR, info->MCR);
> + Â Â Â Â Â Â Â local_irq_enable();
> + Â Â Â }
> +
> + Â Â Â /* Handle turning off CRTSCTS */
> + Â Â Â if ((old_termios->c_cflag & CRTSCTS) &&
> + Â Â Â Â Â !(tty->termios->c_cflag & CRTSCTS)) {
> + Â Â Â Â Â Â Â tty->hw_stopped = 0;
> + Â Â Â Â Â Â Â rs_360_start(tty);
> + Â Â Â }
> +#endif
> +
> +#if 0
> + Â Â Â /*
> + Â Â Â Â* No need to wake up processes in open wait, since they
> + Â Â Â Â* sample the CLOCAL flag once, and don't recheck it.
> + Â Â Â Â* XXX ÂIt's not clear whether the current behavior is correct
> + Â Â Â Â* or not. ÂHence, this may change.....
> + Â Â Â Â*/
> + Â Â Â if (!(old_termios->c_cflag & CLOCAL) &&
> + Â Â Â Â Â (tty->termios->c_cflag & CLOCAL))
> + Â Â Â Â Â Â Â wake_up_interruptible(&info->open_wait);
> +#endif
> +}
> +
> +/*
> + * ------------------------------------------------------------
> + * rs_close()
> + *
> + * This routine is called when the serial port gets closed. ÂFirst, we
> + * wait for the last remaining data to be sent. ÂThen, we unlink its
> + * async structure from the interrupt chain if necessary, and we free
> + * that IRQ if nothing is left in the chain.
> + * ------------------------------------------------------------
> + */
> +static void rs_360_close(struct tty_struct *tty, struct file * filp)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> + Â Â Â /* struct async_state *state; */
> + Â Â Â struct serial_state *state;
> +    unsigned long  flags;
> +    int       idx;
> +    volatile struct smc_regs    Â*smcp;
> +    volatile struct scc_regs    Â*sccp;
> +
> + Â Â Â if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â state = info->state;
> +
> + Â Â Â local_irq_save(flags);
> +
> + Â Â Â if (tty_hung_up_p(filp)) {
> + Â Â Â Â Â Â Â DBG_CNT("before DEC-hung");
> + Â Â Â Â Â Â Â local_irq_restore(flags);
> + Â Â Â Â Â Â Â return;
> + Â Â Â }
> +
> +#ifdef SERIAL_DEBUG_OPEN
> + Â Â Â printk("rs_close ttys%d, count = %d\n", info->line, state->count);
> +#endif
> + Â Â Â if ((tty->count == 1) && (state->count != 1)) {
> + Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â* Uh, oh. Âtty->count is 1, which means that the tty
> + Â Â Â Â Â Â Â Â* structure will be freed. Âstate->count should always
> + Â Â Â Â Â Â Â Â* be one in these conditions. ÂIf it's greater than
> + Â Â Â Â Â Â Â Â* one, we've got real problems, since it means the
> + Â Â Â Â Â Â Â Â* serial port won't be shutdown.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â printk("rs_close: bad serial port count; tty->count is 1, "
> + Â Â Â Â Â Â Â Â Â Â Â"state->count is %d\n", state->count);
> + Â Â Â Â Â Â Â state->count = 1;
> + Â Â Â }
> + Â Â Â if (--state->count < 0) {
> + Â Â Â Â Â Â Â printk("rs_close: bad serial port count for ttys%d: %d\n",
> + Â Â Â Â Â Â Â Â Â Â Âinfo->line, state->count);
> + Â Â Â Â Â Â Â state->count = 0;
> + Â Â Â }
> + Â Â Â if (state->count) {
> + Â Â Â Â Â Â Â DBG_CNT("before DEC-2");
> + Â Â Â Â Â Â Â local_irq_restore(flags);
> + Â Â Â Â Â Â Â return;
> + Â Â Â }
> + Â Â Â info->flags |= ASYNC_CLOSING;
> + Â Â Â /*
> + Â Â Â Â* Now we wait for the transmit buffer to clear; and we notify
> + Â Â Â Â* the line discipline to only process XON/XOFF characters.
> + Â Â Â Â*/
> + Â Â Â tty->closing = 1;
> + Â Â Â if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE)
> + Â Â Â Â Â Â Â tty_wait_until_sent(tty, info->closing_wait);
> + Â Â Â /*
> + Â Â Â Â* At this point we stop accepting input. ÂTo do this, we
> + Â Â Â Â* disable the receive line status interrupts, and tell the
> + Â Â Â Â* interrupt driver to stop checking the data ready bit in the
> + Â Â Â Â* line status register.
> + Â Â Â Â*/
> + Â Â Â info->read_status_mask &= ~BD_SC_EMPTY;
> + Â Â Â if (info->flags & ASYNC_INITIALIZED) {
> +
> + Â Â Â Â Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> + Â Â Â Â Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> + Â Â Â Â Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> + Â Â Â Â Â Â Â Â Â Â Â sccp->scc_sccm &= ~UART_SCCM_RX;
> + Â Â Â Â Â Â Â Â Â Â Â sccp->scc_gsmr.w.low &= ~SCC_GSMRL_ENR;
> + Â Â Â Â Â Â Â } else {
> + Â Â Â Â Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> + Â Â Â Â Â Â Â Â Â Â Â smcp->smc_smcm &= ~SMCM_RX;
> + Â Â Â Â Â Â Â Â Â Â Â smcp->smc_smcmr &= ~SMCMR_REN;
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â /*
> + Â Â Â Â Â Â Â Â* Before we drop DTR, make sure the UART transmitter
> + Â Â Â Â Â Â Â Â* has completely drained; this is especially
> + Â Â Â Â Â Â Â Â* important if there is a transmit FIFO!
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â rs_360_wait_until_sent(tty, info->timeout);
> + Â Â Â }
> + Â Â Â shutdown(info);
> + Â Â Â rs_360_flush_buffer(tty);
> + Â Â Â tty_ldisc_flush(tty);
> + Â Â Â tty->closing = 0;
> + Â Â Â info->event = 0;
> + Â Â Â info->port.tty = NULL;
> + Â Â Â if (info->blocked_open) {
> + Â Â Â Â Â Â Â if (info->close_delay) {
> + Â Â Â Â Â Â Â Â Â Â Â msleep_interruptible(jiffies_to_msecs(info->close_delay));
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â wake_up_interruptible(&info->open_wait);
> + Â Â Â }
> + Â Â Â info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
> + Â Â Â wake_up_interruptible(&info->close_wait);
> + Â Â Â local_irq_restore(flags);
> +}
> +
> +/*
> + * rs_wait_until_sent() --- wait until the transmitter is empty
> + */
> +static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> + Â Â Â unsigned long orig_jiffies, char_time;
> + Â Â Â /*int lsr;*/
> + Â Â Â volatile QUICC_BD *bdp;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
> + Â Â Â Â Â Â Â return;
> +
> +#ifdef maybe
> + Â Â Â if (info->state->type == PORT_UNKNOWN)
> + Â Â Â Â Â Â Â return;
> +#endif
> +
> + Â Â Â orig_jiffies = jiffies;
> + Â Â Â /*
> + Â Â Â Â* Set the check interval to be 1/5 of the estimated time to
> + Â Â Â Â* send a single character, and make it at least 1. ÂThe check
> + Â Â Â Â* interval should also be less than the timeout.
> + Â Â Â Â*
> + Â Â Â Â* Note: we have to use pretty tight timings here to satisfy
> + Â Â Â Â* the NIST-PCTS.
> + Â Â Â Â*/
> + Â Â Â char_time = 1;
> + Â Â Â if (timeout)
> + Â Â Â Â Â Â Â char_time = min(char_time, (unsigned long)timeout);
> +#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
> + Â Â Â printk("In rs_wait_until_sent(%d) check=%lu...", timeout, char_time);
> + Â Â Â printk("jiff=%lu...", jiffies);
> +#endif
> +
> + Â Â Â /* We go through the loop at least once because we can't tell
> + Â Â Â Â* exactly when the last character exits the shifter. ÂThere can
> + Â Â Â Â* be at least two characters waiting to be sent after the buffers
> + Â Â Â Â* are empty.
> + Â Â Â Â*/
> + Â Â Â do {
> +#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
> + Â Â Â Â Â Â Â printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
> +#endif
> +/* Â Â Â Â Â Â current->counter = 0; Â Âmake us low-priority */
> + Â Â Â Â Â Â Â msleep_interruptible(jiffies_to_msecs(char_time));
> + Â Â Â Â Â Â Â if (signal_pending(current))
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â if (timeout && (time_after(jiffies, orig_jiffies + timeout)))
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â /* The 'tx_cur' is really the next buffer to send. ÂWe
> + Â Â Â Â Â Â Â Â* have to back up to the previous BD and wait for it
> + Â Â Â Â Â Â Â Â* to go. ÂThis isn't perfect, because all this indicates
> + Â Â Â Â Â Â Â Â* is the buffer is available. ÂThere are still characters
> + Â Â Â Â Â Â Â Â* in the CPM FIFO.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â bdp = info->tx_cur;
> + Â Â Â Â Â Â Â if (bdp == info->tx_bd_base)
> + Â Â Â Â Â Â Â Â Â Â Â bdp += (TX_NUM_FIFO-1);
> + Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â bdp--;
> + Â Â Â } while (bdp->status & BD_SC_READY);
> + Â Â Â current->state = TASK_RUNNING;
> +#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
> + Â Â Â printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
> +#endif
> +}
> +
> +/*
> + * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
> + */
> +static void rs_360_hangup(struct tty_struct *tty)
> +{
> + Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> + Â Â Â struct serial_state *state = info->state;
> +
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_hangup"))
> + Â Â Â Â Â Â Â return;
> +
> + Â Â Â state = info->state;
> +
> + Â Â Â rs_360_flush_buffer(tty);
> + Â Â Â shutdown(info);
> + Â Â Â info->event = 0;
> + Â Â Â state->count = 0;
> + Â Â Â info->flags &= ~ASYNC_NORMAL_ACTIVE;
> + Â Â Â info->port.tty = NULL;
> + Â Â Â wake_up_interruptible(&info->open_wait);
> +}
> +
> +/*
> + * ------------------------------------------------------------
> + * rs_open() and friends
> + * ------------------------------------------------------------
> + */
> +static int block_til_ready(struct tty_struct *tty, struct file * filp,
> + Â Â Â Â Â Â Â Â Â Â Â Â Âser_info_t *info)
> +{
> +#ifdef DO_THIS_LATER
> + Â Â Â DECLARE_WAITQUEUE(wait, current);
> +#endif
> + Â Â Â struct serial_state *state = info->state;
> +    int       retval;
> +    int       do_clocal = 0;
> +
> + Â Â Â /*
> + Â Â Â Â* If the device is in the middle of being closed, then block
> + Â Â Â Â* until it's done, and then try again.
> + Â Â Â Â*/
> + Â Â Â if (tty_hung_up_p(filp) ||
> + Â Â Â Â Â (info->flags & ASYNC_CLOSING)) {
> + Â Â Â Â Â Â Â if (info->flags & ASYNC_CLOSING)
> + Â Â Â Â Â Â Â Â Â Â Â interruptible_sleep_on(&info->close_wait);
> +#ifdef SERIAL_DO_RESTART
> + Â Â Â Â Â Â Â if (info->flags & ASYNC_HUP_NOTIFY)
> + Â Â Â Â Â Â Â Â Â Â Â return -EAGAIN;
> + Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â return -ERESTARTSYS;
> +#else
> + Â Â Â Â Â Â Â return -EAGAIN;
> +#endif
> + Â Â Â }
> +
> + Â Â Â /*
> + Â Â Â Â* If non-blocking mode is set, or the port is not enabled,
> + Â Â Â Â* then make the check up front and then exit.
> + Â Â Â Â* If this is an SMC port, we don't have modem control to wait
> + Â Â Â Â* for, so just get out here.
> + Â Â Â Â*/
> + Â Â Â if ((filp->f_flags & O_NONBLOCK) ||
> + Â Â Â Â Â (tty->flags & (1 << TTY_IO_ERROR)) ||
> + Â Â Â Â Â !(info->state->smc_scc_num & NUM_IS_SCC)) {
> + Â Â Â Â Â Â Â info->flags |= ASYNC_NORMAL_ACTIVE;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â }
> +
> + Â Â Â if (tty->termios->c_cflag & CLOCAL)
> + Â Â Â Â Â Â Â do_clocal = 1;
> +
> + Â Â Â /*
> + Â Â Â Â* Block waiting for the carrier detect and the line to become
> + Â Â Â Â* free (i.e., not in use by the callout). ÂWhile we are in
> + Â Â Â Â* this loop, state->count is dropped by one, so that
> + Â Â Â Â* rs_close() knows when to free things. ÂWe restore it upon
> + Â Â Â Â* exit, either normal or abnormal.
> + Â Â Â Â*/
> + Â Â Â retval = 0;
> +#ifdef DO_THIS_LATER
> + Â Â Â add_wait_queue(&info->open_wait, &wait);
> +#ifdef SERIAL_DEBUG_OPEN
> + Â Â Â printk("block_til_ready before block: ttys%d, count = %d\n",
> + Â Â Â Â Â Â Âstate->line, state->count);
> +#endif
> + Â Â Â local_irq_disable();
> + Â Â Â if (!tty_hung_up_p(filp))
> + Â Â Â Â Â Â Â state->count--;
> + Â Â Â local_irq_enable();
> + Â Â Â info->blocked_open++;
> + Â Â Â while (1) {
> + Â Â Â Â Â Â Â local_irq_disable();
> + Â Â Â Â Â Â Â if (tty->termios->c_cflag & CBAUD)
> + Â Â Â Â Â Â Â Â Â Â Â serial_out(info, UART_MCR,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âserial_inp(info, UART_MCR) |
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(UART_MCR_DTR | UART_MCR_RTS));
> + Â Â Â Â Â Â Â local_irq_enable();
> + Â Â Â Â Â Â Â set_current_state(TASK_INTERRUPTIBLE);
> + Â Â Â Â Â Â Â if (tty_hung_up_p(filp) ||
> + Â Â Â Â Â Â Â Â Â !(info->flags & ASYNC_INITIALIZED)) {
> +#ifdef SERIAL_DO_RESTART
> + Â Â Â Â Â Â Â Â Â Â Â if (info->flags & ASYNC_HUP_NOTIFY)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â retval = -EAGAIN;
> + Â Â Â Â Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â retval = -ERESTARTSYS;
> +#else
> + Â Â Â Â Â Â Â Â Â Â Â retval = -EAGAIN;
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â if (!(info->flags & ASYNC_CLOSING) &&
> + Â Â Â Â Â Â Â Â Â (do_clocal || (serial_in(info, UART_MSR) &
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂUART_MSR_DCD)))
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â if (signal_pending(current)) {
> + Â Â Â Â Â Â Â Â Â Â Â retval = -ERESTARTSYS;
> + Â Â Â Â Â Â Â Â Â Â Â break;
> + Â Â Â Â Â Â Â }
> +#ifdef SERIAL_DEBUG_OPEN
> + Â Â Â Â Â Â Â printk("block_til_ready blocking: ttys%d, count = %d\n",
> + Â Â Â Â Â Â Â Â Â Â Âinfo->line, state->count);
> +#endif
> + Â Â Â Â Â Â Â tty_unlock();
> + Â Â Â Â Â Â Â schedule();
> + Â Â Â Â Â Â Â tty_lock();
> + Â Â Â }
> + Â Â Â current->state = TASK_RUNNING;
> + Â Â Â remove_wait_queue(&info->open_wait, &wait);
> + Â Â Â if (!tty_hung_up_p(filp))
> + Â Â Â Â Â Â Â state->count++;
> + Â Â Â info->blocked_open--;
> +#ifdef SERIAL_DEBUG_OPEN
> + Â Â Â printk("block_til_ready after blocking: ttys%d, count = %d\n",
> + Â Â Â Â Â Â Âinfo->line, state->count);
> +#endif
> +#endif /* DO_THIS_LATER */
> + Â Â Â if (retval)
> + Â Â Â Â Â Â Â return retval;
> + Â Â Â info->flags |= ASYNC_NORMAL_ACTIVE;
> + Â Â Â return 0;
> +}
> +
> +static int get_async_struct(int line, ser_info_t **ret_info)
> +{
> + Â Â Â struct serial_state *sstate;
> +
> + Â Â Â sstate = rs_table + line;
> + Â Â Â if (sstate->info) {
> + Â Â Â Â Â Â Â sstate->count++;
> + Â Â Â Â Â Â Â *ret_info = (ser_info_t *)sstate->info;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â }
> + Â Â Â else {
> + Â Â Â Â Â Â Â return -ENOMEM;
> + Â Â Â }
> +}
> +
> +/*
> + * This routine is called whenever a serial port is opened. ÂIt
> + * enables interrupts for a serial port, linking in its async structure into
> + * the IRQ chain. Â It also performs the serial-specific
> + * initialization for the tty structure.
> + */
> +static int rs_360_open(struct tty_struct *tty, struct file * filp)
> +{
> +    ser_info_t   Â*info;
> +    int       retval, line;
> +
> + Â Â Â line = tty->index;
> + Â Â Â if ((line < 0) || (line >= NR_PORTS))
> + Â Â Â Â Â Â Â return -ENODEV;
> + Â Â Â retval = get_async_struct(line, &info);
> + Â Â Â if (retval)
> + Â Â Â Â Â Â Â return retval;
> + Â Â Â if (serial_paranoia_check(info, tty->name, "rs_open"))
> + Â Â Â Â Â Â Â return -ENODEV;
> +
> +#ifdef SERIAL_DEBUG_OPEN
> + Â Â Â printk("rs_open %s, count = %d\n", tty->name, info->state->count);
> +#endif
> + Â Â Â tty->driver_data = info;
> + Â Â Â info->port.tty = tty;
> +
> + Â Â Â /*
> + Â Â Â Â* Start up serial port
> + Â Â Â Â*/
> + Â Â Â retval = startup(info);
> + Â Â Â if (retval)
> + Â Â Â Â Â Â Â return retval;
> +
> + Â Â Â retval = block_til_ready(tty, filp, info);
> + Â Â Â if (retval) {
> +#ifdef SERIAL_DEBUG_OPEN
> + Â Â Â Â Â Â Â printk("rs_open returning after block_til_ready with %d\n",
> + Â Â Â Â Â Â Â Â Â Â Âretval);
> +#endif
> + Â Â Â Â Â Â Â return retval;
> + Â Â Â }
> +
> +#ifdef SERIAL_DEBUG_OPEN
> + Â Â Â printk("rs_open %s successful...", tty->name);
> +#endif
> + Â Â Â return 0;
> +}
> +
> +/*
> + * /proc fs routines....
> + */
> +
> +static inline int line_info(char *buf, struct serial_state *state)
> +{
> +#ifdef notdef
> + Â Â Â struct async_struct *info = state->info, scr_info;
> +    char  Âstat_buf[30], control, status;
> +#endif
> +    int   ret;
> +
> + Â Â Â ret = sprintf(buf, "%d: uart:%s port:%X irq:%d",
> + Â Â Â Â Â Â Â Â Â Â state->line,
> + Â Â Â Â Â Â Â Â Â Â (state->smc_scc_num & NUM_IS_SCC) ? "SCC" : "SMC",
> + Â Â Â Â Â Â Â Â Â Â (unsigned int)(state->port), state->irq);
> +
> + Â Â Â if (!state->port || (state->type == PORT_UNKNOWN)) {
> + Â Â Â Â Â Â Â ret += sprintf(buf+ret, "\n");
> + Â Â Â Â Â Â Â return ret;
> + Â Â Â }
> +
> +#ifdef notdef
> + Â Â Â /*
> + Â Â Â Â* Figure out the current RS-232 lines
> + Â Â Â Â*/
> + Â Â Â if (!info) {
> + Â Â Â Â Â Â Â info = &scr_info; Â Â Â /* This is just for serial_{in,out} */
> +
> + Â Â Â Â Â Â Â info->magic = SERIAL_MAGIC;
> + Â Â Â Â Â Â Â info->port = state->port;
> + Â Â Â Â Â Â Â info->flags = state->flags;
> + Â Â Â Â Â Â Â info->quot = 0;
> + Â Â Â Â Â Â Â info->port.tty = NULL;
> + Â Â Â }
> + Â Â Â local_irq_disable();
> + Â Â Â status = serial_in(info, UART_MSR);
> + Â Â Â control = info ? info->MCR : serial_in(info, UART_MCR);
> + Â Â Â local_irq_enable();
> +
> + Â Â Â stat_buf[0] = 0;
> + Â Â Â stat_buf[1] = 0;
> + Â Â Â if (control & UART_MCR_RTS)
> + Â Â Â Â Â Â Â strcat(stat_buf, "|RTS");
> + Â Â Â if (status & UART_MSR_CTS)
> + Â Â Â Â Â Â Â strcat(stat_buf, "|CTS");
> + Â Â Â if (control & UART_MCR_DTR)
> + Â Â Â Â Â Â Â strcat(stat_buf, "|DTR");
> + Â Â Â if (status & UART_MSR_DSR)
> + Â Â Â Â Â Â Â strcat(stat_buf, "|DSR");
> + Â Â Â if (status & UART_MSR_DCD)
> + Â Â Â Â Â Â Â strcat(stat_buf, "|CD");
> + Â Â Â if (status & UART_MSR_RI)
> + Â Â Â Â Â Â Â strcat(stat_buf, "|RI");
> +
> + Â Â Â if (info->quot) {
> + Â Â Â Â Â Â Â ret += sprintf(buf+ret, " baud:%d",
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstate->baud_base / info->quot);
> + Â Â Â }
> +
> + Â Â Â ret += sprintf(buf+ret, " tx:%d rx:%d",
> + Â Â Â Â Â Â Â Â Â Â state->icount.tx, state->icount.rx);
> +
> + Â Â Â if (state->icount.frame)
> + Â Â Â Â Â Â Â ret += sprintf(buf+ret, " fe:%d", state->icount.frame);
> +
> + Â Â Â if (state->icount.parity)
> + Â Â Â Â Â Â Â ret += sprintf(buf+ret, " pe:%d", state->icount.parity);
> +
> + Â Â Â if (state->icount.brk)
> + Â Â Â Â Â Â Â ret += sprintf(buf+ret, " brk:%d", state->icount.brk);
> +
> + Â Â Â if (state->icount.overrun)
> + Â Â Â Â Â Â Â ret += sprintf(buf+ret, " oe:%d", state->icount.overrun);
> +
> + Â Â Â /*
> + Â Â Â Â* Last thing is the RS-232 status lines
> + Â Â Â Â*/
> + Â Â Â ret += sprintf(buf+ret, " %s\n", stat_buf+1);
> +#endif
> + Â Â Â return ret;
> +}
> +
> +int rs_360_read_proc(char *page, char **start, off_t off, int count,
> + Â Â Â Â Â Â Â Âint *eof, void *data)
> +{
> + Â Â Â int i, len = 0;
> +    off_t  begin = 0;
> +
> + Â Â Â len += sprintf(page, "serinfo:1.0 driver:%s\n", serial_version);
> + Â Â Â for (i = 0; i < NR_PORTS && len < 4000; i++) {
> + Â Â Â Â Â Â Â len += line_info(page + len, &rs_table[i]);
> + Â Â Â Â Â Â Â if (len+begin > off+count)
> + Â Â Â Â Â Â Â Â Â Â Â goto done;
> + Â Â Â Â Â Â Â if (len+begin < off) {
> + Â Â Â Â Â Â Â Â Â Â Â begin += len;
> + Â Â Â Â Â Â Â Â Â Â Â len = 0;
> + Â Â Â Â Â Â Â }
> + Â Â Â }
> + Â Â Â *eof = 1;
> +done:
> + Â Â Â if (off >= len+begin)
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â *start = page + (begin-off);
> + Â Â Â return ((count < begin+len-off) ? count : begin+len-off);
> +}
> +
> +/*
> + * ---------------------------------------------------------------------
> + * rs_init() and friends
> + *
> + * rs_init() is called at boot-time to initialize the serial driver.
> + * ---------------------------------------------------------------------
> + */
> +
> +/*
> + * This routine prints out the appropriate serial driver version
> + * number, and identifies which options were configured into this
> + * driver.
> + */
> +static _INLINE_ void show_serial_version(void)
> +{
> + Â Â Â printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
> +}
> +
> +
> +/*
> + * The serial console driver used during boot. ÂNote that these names
> + * clash with those found in "serial.c", so we currently can't support
> + * the 16xxx uarts and these at the same time. ÂI will fix this to become
> + * an indirect function call from tty_io.c (or something).
> + */
> +
> +#ifdef CONFIG_SERIAL_CONSOLE
> +
> +/*
> + * Print a string to the serial port trying not to disturb any possible
> + * real use of the port...
> + */
> +static void my_console_write(int idx, const char *s,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned count)
> +{
> +    struct     Âserial_state  Â*ser;
> +    ser_info_t       Â*info;
> +    unsigned        Âi;
> + Â Â Â QUICC_BD Â Â Â Â Â Â Â Â*bdp, *bdbase;
> +    volatile struct smc_uart_pram  *up;
> +    volatile    Âu_char     Â*cp;
> +
> + Â Â Â ser = rs_table + idx;
> +
> +
> + Â Â Â /* If the port has been initialized for general use, we have
> + Â Â Â Â* to use the buffer descriptors allocated there. ÂOtherwise,
> + Â Â Â Â* we simply use the single buffer allocated.
> + Â Â Â Â*/
> + Â Â Â if ((info = (ser_info_t *)ser->info) != NULL) {
> + Â Â Â Â Â Â Â bdp = info->tx_cur;
> + Â Â Â Â Â Â Â bdbase = info->tx_bd_base;
> + Â Â Â }
> + Â Â Â else {
> + Â Â Â Â Â Â Â /* Pointer to UART in parameter ram.
> + Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â /* up = (smc_uart_t *)&cpmp->cp_dparam[ser->port]; */
> + Â Â Â Â Â Â Â up = &pquicc->pram[ser->port].scc.pothers.idma_smc.psmc.u;
> +
> + Â Â Â Â Â Â Â /* Get the address of the host memory buffer.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â bdp = bdbase = (QUICC_BD *)((uint)pquicc + (uint)up->tbase);
> + Â Â Â }
> +
> + Â Â Â /*
> + Â Â Â Â* We need to gracefully shut down the transmitter, disable
> + Â Â Â Â* interrupts, then send our bytes out.
> + Â Â Â Â*/
> +
> + Â Â Â /*
> + Â Â Â Â* Now, do each character. ÂThis is not as bad as it looks
> + Â Â Â Â* since this is a holding FIFO and not a transmitting FIFO.
> + Â Â Â Â* We could add the complexity of filling the entire transmit
> + Â Â Â Â* buffer, but we would just wait longer between accesses......
> + Â Â Â Â*/
> + Â Â Â for (i = 0; i < count; i++, s++) {
> + Â Â Â Â Â Â Â /* Wait for transmitter fifo to empty.
> + Â Â Â Â Â Â Â Â* Ready indicates output is ready, and xmt is doing
> + Â Â Â Â Â Â Â Â* that, not that it is ready for us to send.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â while (bdp->status & BD_SC_READY);
> +
> + Â Â Â Â Â Â Â /* Send the character out.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â cp = bdp->buf;
> + Â Â Â Â Â Â Â *cp = *s;
> +
> + Â Â Â Â Â Â Â bdp->length = 1;
> + Â Â Â Â Â Â Â bdp->status |= BD_SC_READY;
> +
> + Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP)
> + Â Â Â Â Â Â Â Â Â Â Â bdp = bdbase;
> + Â Â Â Â Â Â Â else
> + Â Â Â Â Â Â Â Â Â Â Â bdp++;
> +
> + Â Â Â Â Â Â Â /* if a LF, also do CR... */
> + Â Â Â Â Â Â Â if (*s == 10) {
> + Â Â Â Â Â Â Â Â Â Â Â while (bdp->status & BD_SC_READY);
> + Â Â Â Â Â Â Â Â Â Â Â /* cp = __va(bdp->buf); */
> + Â Â Â Â Â Â Â Â Â Â Â cp = bdp->buf;
> + Â Â Â Â Â Â Â Â Â Â Â *cp = 13;
> + Â Â Â Â Â Â Â Â Â Â Â bdp->length = 1;
> + Â Â Â Â Â Â Â Â Â Â Â bdp->status |= BD_SC_READY;
> +
> + Â Â Â Â Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp = bdbase;
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â else {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp++;
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â }
> + Â Â Â }
> +
> + Â Â Â /*
> + Â Â Â Â* Finally, Wait for transmitter & holding register to empty
> + Â Â Â Â* Âand restore the IER
> + Â Â Â Â*/
> + Â Â Â while (bdp->status & BD_SC_READY);
> +
> + Â Â Â if (info)
> + Â Â Â Â Â Â Â info->tx_cur = (QUICC_BD *)bdp;
> +}
> +
> +static void serial_console_write(struct console *c, const char *s,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned count)
> +{
> +#ifdef CONFIG_KGDB
> + Â Â Â /* Try to let stub handle output. Returns true if it did. */
> + Â Â Â if (kgdb_output_string(s, count))
> + Â Â Â Â Â Â Â return;
> +#endif
> + Â Â Â my_console_write(c->index, s, count);
> +}
> +
> +
> +
> +/*void console_print_68360(const char *p)
> +{
> + Â Â Â const char *cp = p;
> + Â Â Â int i;
> +
> + Â Â Â for (i=0;cp[i]!=0;i++);
> +
> + Â Â Â serial_console_write (p, i);
> +
> + Â Â Â //Comment this if you want to have a strict interrupt-driven output
> + Â Â Â //rs_fair_output();
> +
> + Â Â Â return;
> +}*/
> +
> +
> +
> +
> +
> +
> +#ifdef CONFIG_XMON
> +int
> +xmon_360_write(const char *s, unsigned count)
> +{
> + Â Â Â my_console_write(0, s, count);
> + Â Â Â return(count);
> +}
> +#endif
> +
> +#ifdef CONFIG_KGDB
> +void
> +putDebugChar(char ch)
> +{
> + Â Â Â my_console_write(0, &ch, 1);
> +}
> +#endif
> +
> +/*
> + * Receive character from the serial port. ÂThis only works well
> + * before the port is initialized for real use.
> + */
> +static int my_console_wait_key(int idx, int xmon, char *obuf)
> +{
> +    struct serial_state       *ser;
> +    u_char         Âc, *cp;
> +    ser_info_t       Â*info;
> + Â Â Â QUICC_BD Â Â Â Â Â Â Â Â*bdp;
> +    volatile struct smc_uart_pram  *up;
> +    int               i;
> +
> + Â Â Â ser = rs_table + idx;
> +
> + Â Â Â /* Get the address of the host memory buffer.
> + Â Â Â Â* If the port has been initialized for general use, we must
> + Â Â Â Â* use information from the port structure.
> + Â Â Â Â*/
> + Â Â Â if ((info = (ser_info_t *)ser->info))
> + Â Â Â Â Â Â Â bdp = info->rx_cur;
> + Â Â Â else
> + Â Â Â Â Â Â Â /* bdp = (QUICC_BD *)&cpmp->cp_dpmem[up->smc_rbase]; */
> + Â Â Â Â Â Â Â bdp = (QUICC_BD *)((uint)pquicc + (uint)up->tbase);
> +
> + Â Â Â /* Pointer to UART in parameter ram.
> + Â Â Â Â*/
> + Â Â Â /* up = (smc_uart_t *)&cpmp->cp_dparam[ser->port]; */
> + Â Â Â up = &pquicc->pram[info->state->port].scc.pothers.idma_smc.psmc.u;
> +
> + Â Â Â /*
> + Â Â Â Â* We need to gracefully shut down the receiver, disable
> + Â Â Â Â* interrupts, then read the input.
> + Â Â Â Â* XMON just wants a poll. ÂIf no character, return -1, else
> + Â Â Â Â* return the character.
> + Â Â Â Â*/
> + Â Â Â if (!xmon) {
> + Â Â Â Â Â Â Â while (bdp->status & BD_SC_EMPTY);
> + Â Â Â }
> + Â Â Â else {
> + Â Â Â Â Â Â Â if (bdp->status & BD_SC_EMPTY)
> + Â Â Â Â Â Â Â Â Â Â Â return -1;
> + Â Â Â }
> +
> + Â Â Â cp = (char *)bdp->buf;
> +
> + Â Â Â if (obuf) {
> + Â Â Â Â Â Â Â i = c = bdp->length;
> + Â Â Â Â Â Â Â while (i-- > 0)
> + Â Â Â Â Â Â Â Â Â Â Â *obuf++ = *cp++;
> + Â Â Â }
> + Â Â Â else {
> + Â Â Â Â Â Â Â c = *cp;
> + Â Â Â }
> + Â Â Â bdp->status |= BD_SC_EMPTY;
> +
> + Â Â Â if (info) {
> + Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP) {
> + Â Â Â Â Â Â Â Â Â Â Â bdp = info->rx_bd_base;
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â else {
> + Â Â Â Â Â Â Â Â Â Â Â bdp++;
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â info->rx_cur = (QUICC_BD *)bdp;
> + Â Â Â }
> +
> + Â Â Â return((int)c);
> +}
> +
> +static int serial_console_wait_key(struct console *co)
> +{
> + Â Â Â return(my_console_wait_key(co->index, 0, NULL));
> +}
> +
> +#ifdef CONFIG_XMON
> +int
> +xmon_360_read_poll(void)
> +{
> + Â Â Â return(my_console_wait_key(0, 1, NULL));
> +}
> +
> +int
> +xmon_360_read_char(void)
> +{
> + Â Â Â return(my_console_wait_key(0, 0, NULL));
> +}
> +#endif
> +
> +#ifdef CONFIG_KGDB
> +static char kgdb_buf[RX_BUF_SIZE], *kgdp;
> +static int kgdb_chars;
> +
> +unsigned char
> +getDebugChar(void)
> +{
> + Â Â Â if (kgdb_chars <= 0) {
> + Â Â Â Â Â Â Â kgdb_chars = my_console_wait_key(0, 0, kgdb_buf);
> + Â Â Â Â Â Â Â kgdp = kgdb_buf;
> + Â Â Â }
> + Â Â Â kgdb_chars--;
> +
> + Â Â Â return(*kgdp++);
> +}
> +
> +void kgdb_interruptible(int state)
> +{
> +}
> +void kgdb_map_scc(void)
> +{
> +    struct     Âserial_state *ser;
> +    uint      Âmem_addr;
> +    volatile    ÂQUICC_BD        Â*bdp;
> +    volatile    Âsmc_uart_t   Â*up;
> +
> + Â Â Â cpmp = (cpm360_t *)&(((immap_t *)IMAP_ADDR)->im_cpm);
> +
> + Â Â Â /* To avoid data cache CPM DMA coherency problems, allocate a
> + Â Â Â Â* buffer in the CPM DPRAM. ÂThis will work until the CPM and
> + Â Â Â Â* serial ports are initialized. ÂAt that time a memory buffer
> + Â Â Â Â* will be allocated.
> + Â Â Â Â* The port is already initialized from the boot procedure, all
> + Â Â Â Â* we do here is give it a different buffer and make it a FIFO.
> + Â Â Â Â*/
> +
> + Â Â Â ser = rs_table;
> +
> + Â Â Â /* Right now, assume we are using SMCs.
> + Â Â Â */
> + Â Â Â up = (smc_uart_t *)&cpmp->cp_dparam[ser->port];
> +
> + Â Â Â /* Allocate space for an input FIFO, plus a few bytes for output.
> + Â Â Â Â* Allocate bytes to maintain word alignment.
> + Â Â Â Â*/
> + Â Â Â mem_addr = (uint)(&cpmp->cp_dpmem[0x1000]);
> +
> + Â Â Â /* Set the physical address of the host memory buffers in
> + Â Â Â Â* the buffer descriptors.
> + Â Â Â Â*/
> + Â Â Â bdp = (QUICC_BD *)&cpmp->cp_dpmem[up->smc_rbase];
> + Â Â Â bdp->buf = mem_addr;
> +
> + Â Â Â bdp = (QUICC_BD *)&cpmp->cp_dpmem[up->smc_tbase];
> + Â Â Â bdp->buf = mem_addr+RX_BUF_SIZE;
> +
> + Â Â Â up->smc_mrblr = RX_BUF_SIZE; Â Â Â Â Â Â/* receive buffer length */
> + Â Â Â up->smc_maxidl = RX_BUF_SIZE;
> +}
> +#endif
> +
> +static struct tty_struct *serial_console_device(struct console *c, int *index)
> +{
> + Â Â Â *index = c->index;
> + Â Â Â return serial_driver;
> +}
> +
> +
> +struct console sercons = {
> +    .name      = "ttyS",
> +    .write     Â= serial_console_write,
> +    .device     = serial_console_device,
> +    .wait_key    = serial_console_wait_key,
> +    .setup     Â= serial_console_setup,
> +    .flags     Â= CON_PRINTBUFFER,
> +    .index     Â= CONFIG_SERIAL_CONSOLE_PORT,
> +};
> +
> +
> +
> +/*
> + * Â Â Register console.
> + */
> +long console_360_init(long kmem_start, long kmem_end)
> +{
> + Â Â Â register_console(&sercons);
> + Â Â Â /*register_console (console_print_68360); - 2.0.38 only required a write
> + Â Â Âfunction pointer. */
> + Â Â Â return kmem_start;
> +}
> +
> +#endif
> +
> +/* Index in baud rate table of the default console baud rate.
> +*/
> +static int   baud_idx;
> +
> +static const struct tty_operations rs_360_ops = {
> + Â Â Â .owner = THIS_MODULE,
> + Â Â Â .open = rs_360_open,
> + Â Â Â .close = rs_360_close,
> + Â Â Â .write = rs_360_write,
> + Â Â Â .put_char = rs_360_put_char,
> + Â Â Â .write_room = rs_360_write_room,
> + Â Â Â .chars_in_buffer = rs_360_chars_in_buffer,
> + Â Â Â .flush_buffer = rs_360_flush_buffer,
> + Â Â Â .ioctl = rs_360_ioctl,
> + Â Â Â .throttle = rs_360_throttle,
> + Â Â Â .unthrottle = rs_360_unthrottle,
> + Â Â Â /* .send_xchar = rs_360_send_xchar, */
> + Â Â Â .set_termios = rs_360_set_termios,
> + Â Â Â .stop = rs_360_stop,
> + Â Â Â .start = rs_360_start,
> + Â Â Â .hangup = rs_360_hangup,
> + Â Â Â /* .wait_until_sent = rs_360_wait_until_sent, */
> + Â Â Â /* .read_proc = rs_360_read_proc, */
> + Â Â Â .tiocmget = rs_360_tiocmget,
> + Â Â Â .tiocmset = rs_360_tiocmset,
> + Â Â Â .get_icount = rs_360_get_icount,
> +};
> +
> +static int __init rs_360_init(void)
> +{
> + Â Â Â struct serial_state * state;
> +    ser_info_t   Â*info;
> +    void    *mem_addr;
> +    uint      Âdp_addr, iobits;
> +    int         i, j, idx;
> +    ushort     Âchan;
> + Â Â Â QUICC_BD Â Â Â Â*bdp;
> +    volatile    ÂQUICC      *cp;
> +    volatile    Âstruct smc_regs *sp;
> +    volatile    Âstruct smc_uart_pram  Â*up;
> +    volatile    Âstruct scc_regs *scp;
> +    volatile    Âstruct uart_pram    Â*sup;
> +    /* volatile   immap_t     *immap; */
> +
> + Â Â Â serial_driver = alloc_tty_driver(NR_PORTS);
> + Â Â Â if (!serial_driver)
> + Â Â Â Â Â Â Â return -1;
> +
> + Â Â Â show_serial_version();
> +
> + Â Â Â serial_driver->name = "ttyS";
> + Â Â Â serial_driver->major = TTY_MAJOR;
> + Â Â Â serial_driver->minor_start = 64;
> + Â Â Â serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
> + Â Â Â serial_driver->subtype = SERIAL_TYPE_NORMAL;
> + Â Â Â serial_driver->init_termios = tty_std_termios;
> + Â Â Â serial_driver->init_termios.c_cflag =
> + Â Â Â Â Â Â Â baud_idx | CS8 | CREAD | HUPCL | CLOCAL;
> + Â Â Â serial_driver->flags = TTY_DRIVER_REAL_RAW;
> + Â Â Â tty_set_operations(serial_driver, &rs_360_ops);
> +
> + Â Â Â if (tty_register_driver(serial_driver))
> + Â Â Â Â Â Â Â panic("Couldn't register serial driver\n");
> +
> + Â Â Â cp = pquicc; Â Â/* Get pointer to Communication Processor */
> + Â Â Â /* immap = (immap_t *)IMAP_ADDR; */ Â Â /* and to internal registers */
> +
> +
> + Â Â Â /* Configure SCC2, SCC3, and SCC4 instead of port A parallel I/O.
> + Â Â Â Â*/
> + Â Â Â /* The "standard" configuration through the 860.
> + Â Â Â */
> +/* Â Â immap->im_ioport.iop_papar |= 0x00fc; */
> +/* Â Â immap->im_ioport.iop_padir &= ~0x00fc; */
> +/* Â Â immap->im_ioport.iop_paodr &= ~0x00fc; */
> + Â Â Â cp->pio_papar |= 0x00fc;
> + Â Â Â cp->pio_padir &= ~0x00fc;
> + Â Â Â /* cp->pio_paodr &= ~0x00fc; */
> +
> +
> + Â Â Â /* Since we don't yet do modem control, connect the port C pins
> + Â Â Â Â* as general purpose I/O. ÂThis will assert CTS and CD for the
> + Â Â Â Â* SCC ports.
> + Â Â Â Â*/
> + Â Â Â /* FIXME: see 360um p.7-365 and 860um p.34-12
> + Â Â Â Â* I can't make sense of these bits - mleslie*/
> +/* Â Â immap->im_ioport.iop_pcdir |= 0x03c6; */
> +/* Â Â immap->im_ioport.iop_pcpar &= ~0x03c6; */
> +
> +/* Â Â cp->pio_pcdir |= 0x03c6; */
> +/* Â Â cp->pio_pcpar &= ~0x03c6; */
> +
> +
> +
> + Â Â Â /* Connect SCC2 and SCC3 to NMSI. ÂConnect BRG3 to SCC2 and
> + Â Â Â Â* BRG4 to SCC3.
> + Â Â Â Â*/
> + Â Â Â cp->si_sicr &= ~0x00ffff00;
> + Â Â Â cp->si_sicr |= Â0x001b1200;
> +
> +#ifdef CONFIG_PP04
> + Â Â Â /* Frequentis PP04 forced to RS-232 until we know better.
> + Â Â Â Â* Port C 12 and 13 low enables RS-232 on SCC3 and SCC4.
> + Â Â Â Â*/
> + Â Â Â immap->im_ioport.iop_pcdir |= 0x000c;
> + Â Â Â immap->im_ioport.iop_pcpar &= ~0x000c;
> + Â Â Â immap->im_ioport.iop_pcdat &= ~0x000c;
> +
> + Â Â Â /* This enables the TX driver.
> + Â Â Â */
> + Â Â Â cp->cp_pbpar &= ~0x6000;
> + Â Â Â cp->cp_pbdat &= ~0x6000;
> +#endif
> +
> + Â Â Â for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
> + Â Â Â Â Â Â Â state->magic = SSTATE_MAGIC;
> + Â Â Â Â Â Â Â state->line = i;
> + Â Â Â Â Â Â Â state->type = PORT_UNKNOWN;
> + Â Â Â Â Â Â Â state->custom_divisor = 0;
> + Â Â Â Â Â Â Â state->close_delay = 5*HZ/10;
> + Â Â Â Â Â Â Â state->closing_wait = 30*HZ;
> + Â Â Â Â Â Â Â state->icount.cts = state->icount.dsr =
> + Â Â Â Â Â Â Â Â Â Â Â state->icount.rng = state->icount.dcd = 0;
> + Â Â Â Â Â Â Â state->icount.rx = state->icount.tx = 0;
> + Â Â Â Â Â Â Â state->icount.frame = state->icount.parity = 0;
> + Â Â Â Â Â Â Â state->icount.overrun = state->icount.brk = 0;
> + Â Â Â Â Â Â Â printk(KERN_INFO "ttyS%d at irq 0x%02x is an %s\n",
> + Â Â Â Â Â Â Â Â Â Â Âi, (unsigned int)(state->irq),
> + Â Â Â Â Â Â Â Â Â Â Â(state->smc_scc_num & NUM_IS_SCC) ? "SCC" : "SMC");
> +
> +#ifdef CONFIG_SERIAL_CONSOLE
> + Â Â Â Â Â Â Â /* If we just printed the message on the console port, and
> + Â Â Â Â Â Â Â Â* we are about to initialize it for general use, we have
> + Â Â Â Â Â Â Â Â* to wait a couple of character times for the CR/NL to
> + Â Â Â Â Â Â Â Â* make it out of the transmit buffer.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â if (i == CONFIG_SERIAL_CONSOLE_PORT)
> + Â Â Â Â Â Â Â Â Â Â Â mdelay(8);
> +
> +
> +/* Â Â Â Â Â Â idx = PORT_NUM(info->state->smc_scc_num); */
> +/* Â Â Â Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) */
> +/* Â Â Â Â Â Â Â Â Â Â chan = scc_chan_map[idx]; */
> +/* Â Â Â Â Â Â else */
> +/* Â Â Â Â Â Â Â Â Â Â chan = smc_chan_map[idx]; */
> +
> +/* Â Â Â Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_STOP_TX) | CPM_CR_FLG; */
> +/* Â Â Â Â Â Â while (cp->cp_cr & CPM_CR_FLG); */
> +
> +#endif
> + Â Â Â Â Â Â Â /* info = kmalloc(sizeof(ser_info_t), GFP_KERNEL); */
> + Â Â Â Â Â Â Â info = &quicc_ser_info[i];
> + Â Â Â Â Â Â Â if (info) {
> + Â Â Â Â Â Â Â Â Â Â Â memset (info, 0, sizeof(ser_info_t));
> + Â Â Â Â Â Â Â Â Â Â Â info->magic = SERIAL_MAGIC;
> + Â Â Â Â Â Â Â Â Â Â Â info->line = i;
> + Â Â Â Â Â Â Â Â Â Â Â info->flags = state->flags;
> + Â Â Â Â Â Â Â Â Â Â Â INIT_WORK(&info->tqueue, do_softint, info);
> + Â Â Â Â Â Â Â Â Â Â Â INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info);
> + Â Â Â Â Â Â Â Â Â Â Â init_waitqueue_head(&info->open_wait);
> + Â Â Â Â Â Â Â Â Â Â Â init_waitqueue_head(&info->close_wait);
> + Â Â Â Â Â Â Â Â Â Â Â info->state = state;
> + Â Â Â Â Â Â Â Â Â Â Â state->info = (struct async_struct *)info;
> +
> + Â Â Â Â Â Â Â Â Â Â Â /* We need to allocate a transmit and receive buffer
> + Â Â Â Â Â Â Â Â Â Â Â Â* descriptors from dual port ram, and a character
> + Â Â Â Â Â Â Â Â Â Â Â Â* buffer area from host mem.
> + Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â dp_addr = m360_cpm_dpalloc(sizeof(QUICC_BD) * RX_NUM_FIFO);
> +
> + Â Â Â Â Â Â Â Â Â Â Â /* Allocate space for FIFOs in the host memory.
> + Â Â Â Â Â Â Â Â Â Â Â Â* Â(for now this is from a static array of buffers :(
> + Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â /* mem_addr = m360_cpm_hostalloc(RX_NUM_FIFO * RX_BUF_SIZE); */
> + Â Â Â Â Â Â Â Â Â Â Â /* mem_addr = kmalloc (RX_NUM_FIFO * RX_BUF_SIZE, GFP_BUFFER); */
> + Â Â Â Â Â Â Â Â Â Â Â mem_addr = &rx_buf_pool[i * RX_NUM_FIFO * RX_BUF_SIZE];
> +
> + Â Â Â Â Â Â Â Â Â Â Â /* Set the physical address of the host memory
> + Â Â Â Â Â Â Â Â Â Â Â Â* buffers in the buffer descriptors, and the
> + Â Â Â Â Â Â Â Â Â Â Â Â* virtual address for us to work with.
> + Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â bdp = (QUICC_BD *)((uint)pquicc + dp_addr);
> + Â Â Â Â Â Â Â Â Â Â Â info->rx_cur = info->rx_bd_base = bdp;
> +
> + Â Â Â Â Â Â Â Â Â Â Â /* initialize rx buffer descriptors */
> + Â Â Â Â Â Â Â Â Â Â Â for (j=0; j<(RX_NUM_FIFO-1); j++) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp->buf = &rx_buf_pool[(i * RX_NUM_FIFO + j ) * RX_BUF_SIZE];
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp->status = BD_SC_EMPTY | BD_SC_INTRPT;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â mem_addr += RX_BUF_SIZE;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp++;
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â bdp->buf = &rx_buf_pool[(i * RX_NUM_FIFO + j ) * RX_BUF_SIZE];
> + Â Â Â Â Â Â Â Â Â Â Â bdp->status = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT;
> +
> +
> + Â Â Â Â Â Â Â Â Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> + Â Â Â Â Â Â Â Â Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> +
> +#if defined (CONFIG_UCQUICC) && 1
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* set the transceiver mode to RS232 */
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sipex_mode_bits &= ~(uint)SIPEX_MODE(idx,0x0f); /* clear current mode */
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sipex_mode_bits |= (uint)SIPEX_MODE(idx,0x02);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â *(uint *)_periph_base = sipex_mode_bits;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* printk ("sipex bits = 0x%08x\n", sipex_mode_bits); */
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â Â Â Â Â dp_addr = m360_cpm_dpalloc(sizeof(QUICC_BD) * TX_NUM_FIFO);
> +
> + Â Â Â Â Â Â Â Â Â Â Â /* Allocate space for FIFOs in the host memory.
> + Â Â Â Â Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â Â Â Â Â /* mem_addr = m360_cpm_hostalloc(TX_NUM_FIFO * TX_BUF_SIZE); */
> + Â Â Â Â Â Â Â Â Â Â Â /* mem_addr = kmalloc (TX_NUM_FIFO * TX_BUF_SIZE, GFP_BUFFER); */
> + Â Â Â Â Â Â Â Â Â Â Â mem_addr = &tx_buf_pool[i * TX_NUM_FIFO * TX_BUF_SIZE];
> +
> + Â Â Â Â Â Â Â Â Â Â Â /* Set the physical address of the host memory
> + Â Â Â Â Â Â Â Â Â Â Â Â* buffers in the buffer descriptors, and the
> + Â Â Â Â Â Â Â Â Â Â Â Â* virtual address for us to work with.
> + Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â /* bdp = (QUICC_BD *)&cp->cp_dpmem[dp_addr]; */
> + Â Â Â Â Â Â Â Â Â Â Â bdp = (QUICC_BD *)((uint)pquicc + dp_addr);
> + Â Â Â Â Â Â Â Â Â Â Â info->tx_cur = info->tx_bd_base = (QUICC_BD *)bdp;
> +
> + Â Â Â Â Â Â Â Â Â Â Â /* initialize tx buffer descriptors */
> + Â Â Â Â Â Â Â Â Â Â Â for (j=0; j<(TX_NUM_FIFO-1); j++) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp->buf = &tx_buf_pool[(i * TX_NUM_FIFO + j ) * TX_BUF_SIZE];
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp->status = BD_SC_INTRPT;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â mem_addr += TX_BUF_SIZE;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp++;
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â bdp->buf = &tx_buf_pool[(i * TX_NUM_FIFO + j ) * TX_BUF_SIZE];
> + Â Â Â Â Â Â Â Â Â Â Â bdp->status = (BD_SC_WRAP | BD_SC_INTRPT);
> +
> + Â Â Â Â Â Â Â Â Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp = &pquicc->scc_regs[idx];
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup = &pquicc->pram[info->state->port].scc.pscc.u;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->rbase = dp_addr;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->tbase = dp_addr;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set up the uart parameters in the
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* parameter ram.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->rfcr = SMC_EB;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->tfcr = SMC_EB;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set this to 1 for now, so we get single
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* character interrupts. ÂUsing idle character
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* time requires some additional tuning.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->mrblr = 1;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->max_idl = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->brkcr = 1;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->parec = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->frmer = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->nosec = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->brkec = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->uaddr1 = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->uaddr2 = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->toseq = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int i;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â for (i=0;i<8;i++)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->cc[i] = 0x8000;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->rccm = 0xc0ff;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Send the CPM an initialize command.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â chan = scc_chan_map[idx];
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* execute the INIT RX & TX PARAMS command for this channel. */
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set UART mode, 8 bit, no parity, one stop.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* Enable receive and transmit.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_gsmr.w.high = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_gsmr.w.low =
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Disable all interrupts and clear all pending
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* events.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_sccm = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_scce = 0xffff;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_dsr = 0x7e7e;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_psmr = 0x3000;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* If the port is the console, enable Rx and Tx.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */
> +#ifdef CONFIG_SERIAL_CONSOLE
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (i == CONFIG_SERIAL_CONSOLE_PORT)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_gsmr.w.low |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â Â Â Â Â else {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Configure SMCs Tx/Rx instead of port B
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* parallel I/O.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up = &pquicc->pram[info->state->port].scc.pothers.idma_smc.psmc.u;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->rbase = dp_addr;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iobits = 0xc0 << (idx * 4);
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->pip_pbpar |= iobits;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->pip_pbdir &= ~iobits;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->pip_pbodr &= ~iobits;
> +
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Connect the baud rate generator to the
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* SMC based upon index in rs_table. ÂAlso
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* make sure it is connected to NMSI.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->si_simode &= ~(0xffff << (idx * 16));
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->si_simode |= (i << ((idx * 16) + 12));
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->tbase = dp_addr;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set up the uart parameters in the
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* parameter ram.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->rfcr = SMC_EB;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->tfcr = SMC_EB;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set this to 1 for now, so we get single
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* character interrupts. ÂUsing idle character
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* time requires some additional tuning.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->mrblr = 1;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->max_idl = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->brkcr = 1;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Send the CPM an initialize command.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â chan = smc_chan_map[idx];
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->cp_cr = mk_cr_cmd(chan,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CPM_CR_INIT_TRX) | CPM_CR_FLG;
> +#ifdef CONFIG_SERIAL_CONSOLE
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (i == CONFIG_SERIAL_CONSOLE_PORT)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk("");
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set UART mode, 8 bit, no parity, one stop.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* Enable receive and transmit.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sp = &cp->smc_regs[idx];
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Disable all interrupts and clear all pending
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* events.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sp->smc_smcm = 0;
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sp->smc_smce = 0xff;
> +
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* If the port is the console, enable Rx and Tx.
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */
> +#ifdef CONFIG_SERIAL_CONSOLE
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (i == CONFIG_SERIAL_CONSOLE_PORT)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
> +#endif
> + Â Â Â Â Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â Â Â Â Â /* Install interrupt handler.
> + Â Â Â Â Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â Â Â Â Â /* cpm_install_handler(IRQ_MACHSPEC | state->irq, rs_360_interrupt, info); Â*/
> + Â Â Â Â Â Â Â Â Â Â Â /*request_irq(IRQ_MACHSPEC | state->irq, rs_360_interrupt, */
> + Â Â Â Â Â Â Â Â Â Â Â request_irq(state->irq, rs_360_interrupt,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IRQ_FLG_LOCK, "ttyS", (void *)info);
> +
> + Â Â Â Â Â Â Â Â Â Â Â /* Set up the baud rate generator.
> + Â Â Â Â Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â Â Â Â Â m360_cpm_setbrg(i, baud_table[baud_idx]);
> +
> + Â Â Â Â Â Â Â }
> + Â Â Â }
> +
> + Â Â Â return 0;
> +}
> +module_init(rs_360_init);
> +
> +/* This must always be called before the rs_360_init() function, otherwise
> + * it blows away the port control information.
> + */
> +//static int __init serial_console_setup( struct console *co, char *options)
> +int serial_console_setup( struct console *co, char *options)
> +{
> +    struct     Âserial_state  Â*ser;
> +    uint      Âmem_addr, dp_addr, bidx, idx, iobits;
> +    ushort     Âchan;
> + Â Â Â QUICC_BD Â Â Â Â*bdp;
> +    volatile    ÂQUICC          *cp;
> +    volatile    Âstruct smc_regs *sp;
> +    volatile    Âstruct scc_regs *scp;
> +    volatile    Âstruct smc_uart_pram  Â*up;
> +    volatile    Âstruct uart_pram        Â*sup;
> +
> +/* mleslie TODO:
> + * add something to the 68k bootloader to store a desired initial console baud rate */
> +
> +/*   bd_t                      Â*bd; */ /* a board info struct used by EPPC-bug */
> +/* Â Â bd = (bd_t *)__res; */
> +
> + Â Â Â for (bidx = 0; bidx < (sizeof(baud_table) / sizeof(int)); bidx++)
> + Â Â Â Â/* if (bd->bi_baudrate == baud_table[bidx]) */
> + Â Â Â Â Â Â Â if (CONSOLE_BAUDRATE == baud_table[bidx])
> + Â Â Â Â Â Â Â Â Â Â Â break;
> +
> + Â Â Â /* co->cflag = CREAD|CLOCAL|bidx|CS8; */
> + Â Â Â baud_idx = bidx;
> +
> + Â Â Â ser = rs_table + CONFIG_SERIAL_CONSOLE_PORT;
> +
> + Â Â Â cp = pquicc; Â Â/* Get pointer to Communication Processor */
> +
> + Â Â Â idx = PORT_NUM(ser->smc_scc_num);
> + Â Â Â if (ser->smc_scc_num & NUM_IS_SCC) {
> +
> + Â Â Â Â Â Â Â /* TODO: need to set up SCC pin assignment etc. here */
> +
> + Â Â Â }
> + Â Â Â else {
> + Â Â Â Â Â Â Â iobits = 0xc0 << (idx * 4);
> + Â Â Â Â Â Â Â cp->pip_pbpar |= iobits;
> + Â Â Â Â Â Â Â cp->pip_pbdir &= ~iobits;
> + Â Â Â Â Â Â Â cp->pip_pbodr &= ~iobits;
> +
> + Â Â Â Â Â Â Â /* Connect the baud rate generator to the
> + Â Â Â Â Â Â Â Â* SMC based upon index in rs_table. ÂAlso
> + Â Â Â Â Â Â Â Â* make sure it is connected to NMSI.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â cp->si_simode &= ~(0xffff << (idx * 16));
> + Â Â Â Â Â Â Â cp->si_simode |= (idx << ((idx * 16) + 12));
> + Â Â Â }
> +
> + Â Â Â /* When we get here, the CPM has been reset, so we need
> + Â Â Â Â* to configure the port.
> + Â Â Â Â* We need to allocate a transmit and receive buffer descriptor
> + Â Â Â Â* from dual port ram, and a character buffer area from host mem.
> + Â Â Â Â*/
> +
> + Â Â Â /* Allocate space for two buffer descriptors in the DP ram.
> + Â Â Â */
> + Â Â Â dp_addr = m360_cpm_dpalloc(sizeof(QUICC_BD) * CONSOLE_NUM_FIFO);
> +
> + Â Â Â /* Allocate space for two 2 byte FIFOs in the host memory.
> + Â Â Â Â*/
> + Â Â Â /* mem_addr = m360_cpm_hostalloc(8); */
> + Â Â Â mem_addr = (uint)console_fifos;
> +
> +
> + Â Â Â /* Set the physical address of the host memory buffers in
> + Â Â Â Â* the buffer descriptors.
> + Â Â Â Â*/
> + Â Â Â /* bdp = (QUICC_BD *)&cp->cp_dpmem[dp_addr]; */
> + Â Â Â bdp = (QUICC_BD *)((uint)pquicc + dp_addr);
> + Â Â Â bdp->buf = (char *)mem_addr;
> + Â Â Â (bdp+1)->buf = (char *)(mem_addr+4);
> +
> + Â Â Â /* For the receive, set empty and wrap.
> + Â Â Â Â* For transmit, set wrap.
> + Â Â Â Â*/
> + Â Â Â bdp->status = BD_SC_EMPTY | BD_SC_WRAP;
> + Â Â Â (bdp+1)->status = BD_SC_WRAP;
> +
> + Â Â Â /* Set up the uart parameters in the parameter ram.
> + Â Â Â Â*/
> + Â Â Â if (ser->smc_scc_num & NUM_IS_SCC) {
> + Â Â Â Â Â Â Â scp = &cp->scc_regs[idx];
> + Â Â Â Â Â Â Â /* sup = (scc_uart_t *)&cp->cp_dparam[ser->port]; */
> + Â Â Â Â Â Â Â sup = &pquicc->pram[ser->port].scc.pscc.u;
> +
> + Â Â Â Â Â Â Â sup->rbase = dp_addr;
> + Â Â Â Â Â Â Â sup->tbase = dp_addr + sizeof(QUICC_BD);
> +
> + Â Â Â Â Â Â Â /* Set up the uart parameters in the
> + Â Â Â Â Â Â Â Â* parameter ram.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â sup->rfcr = SMC_EB;
> + Â Â Â Â Â Â Â sup->tfcr = SMC_EB;
> +
> + Â Â Â Â Â Â Â /* Set this to 1 for now, so we get single
> + Â Â Â Â Â Â Â Â* character interrupts. ÂUsing idle character
> + Â Â Â Â Â Â Â Â* time requires some additional tuning.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â sup->mrblr = 1;
> + Â Â Â Â Â Â Â sup->max_idl = 0;
> + Â Â Â Â Â Â Â sup->brkcr = 1;
> + Â Â Â Â Â Â Â sup->parec = 0;
> + Â Â Â Â Â Â Â sup->frmer = 0;
> + Â Â Â Â Â Â Â sup->nosec = 0;
> + Â Â Â Â Â Â Â sup->brkec = 0;
> + Â Â Â Â Â Â Â sup->uaddr1 = 0;
> + Â Â Â Â Â Â Â sup->uaddr2 = 0;
> + Â Â Â Â Â Â Â sup->toseq = 0;
> + Â Â Â Â Â Â Â {
> + Â Â Â Â Â Â Â Â Â Â Â int i;
> + Â Â Â Â Â Â Â Â Â Â Â for (i=0;i<8;i++)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->cc[i] = 0x8000;
> + Â Â Â Â Â Â Â }
> + Â Â Â Â Â Â Â sup->rccm = 0xc0ff;
> +
> + Â Â Â Â Â Â Â /* Send the CPM an initialize command.
> + Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â chan = scc_chan_map[idx];
> +
> + Â Â Â Â Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
> + Â Â Â Â Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> +
> + Â Â Â Â Â Â Â /* Set UART mode, 8 bit, no parity, one stop.
> + Â Â Â Â Â Â Â Â* Enable receive and transmit.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â scp->scc_gsmr.w.high = 0;
> + Â Â Â Â Â Â Â scp->scc_gsmr.w.low =
> + Â Â Â Â Â Â Â Â Â Â Â (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
> +
> + Â Â Â Â Â Â Â /* Disable all interrupts and clear all pending
> + Â Â Â Â Â Â Â Â* events.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â scp->scc_sccm = 0;
> + Â Â Â Â Â Â Â scp->scc_scce = 0xffff;
> + Â Â Â Â Â Â Â scp->scc_dsr = 0x7e7e;
> + Â Â Â Â Â Â Â scp->scc_psmr = 0x3000;
> +
> + Â Â Â Â Â Â Â scp->scc_gsmr.w.low |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
> +
> + Â Â Â }
> + Â Â Â else {
> + Â Â Â Â Â Â Â /* up = (smc_uart_t *)&cp->cp_dparam[ser->port]; */
> + Â Â Â Â Â Â Â up = &pquicc->pram[ser->port].scc.pothers.idma_smc.psmc.u;
> +
> + Â Â Â Â Â Â Â up->rbase = dp_addr; Â Â/* Base of receive buffer desc. */
> + Â Â Â Â Â Â Â up->tbase = dp_addr+sizeof(QUICC_BD); Â /* Base of xmt buffer desc. */
> + Â Â Â Â Â Â Â up->rfcr = SMC_EB;
> + Â Â Â Â Â Â Â up->tfcr = SMC_EB;
> +
> + Â Â Â Â Â Â Â /* Set this to 1 for now, so we get single character interrupts.
> + Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â up->mrblr = 1; Â Â Â Â Â/* receive buffer length */
> + Â Â Â Â Â Â Â up->max_idl = 0; Â Â Â Â Â Â Â Â/* wait forever for next char */
> +
> + Â Â Â Â Â Â Â /* Send the CPM an initialize command.
> + Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â chan = smc_chan_map[idx];
> + Â Â Â Â Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
> + Â Â Â Â Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> +
> + Â Â Â Â Â Â Â /* Set UART mode, 8 bit, no parity, one stop.
> + Â Â Â Â Â Â Â Â* Enable receive and transmit.
> + Â Â Â Â Â Â Â Â*/
> + Â Â Â Â Â Â Â sp = &cp->smc_regs[idx];
> + Â Â Â Â Â Â Â sp->smc_smcmr = smcr_mk_clen(9) | ÂSMCMR_SM_UART;
> +
> + Â Â Â Â Â Â Â /* And finally, enable Rx and Tx.
> + Â Â Â Â Â Â Â */
> + Â Â Â Â Â Â Â sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
> + Â Â Â }
> +
> + Â Â Â /* Set up the baud rate generator.
> + Â Â Â */
> + Â Â Â /* m360_cpm_setbrg((ser - rs_table), bd->bi_baudrate); */
> + Â Â Â m360_cpm_setbrg((ser - rs_table), CONSOLE_BAUDRATE);
> +
> + Â Â Â return 0;
> +}
> +
> +/*
> + * Local variables:
> + * Âc-indent-level: 4
> + * Âc-basic-offset: 4
> + * Âtab-width: 4
> + * End:
> + */
> diff --git a/drivers/staging/serial/Kconfig b/drivers/staging/serial/Kconfig
> new file mode 100644
> index 0000000..9489688
> --- /dev/null
> +++ b/drivers/staging/serial/Kconfig
> @@ -0,0 +1,16 @@
> +config SERIAL_68360_SMC
> + Â Â Â bool "68360 SMC uart support"
> + Â Â Â depends on M68360
> + Â Â Â help
> + Â Â Â Â This driver supports the SMC serial ports of the Motorola 68360 CPU.
> +
> +config SERIAL_68360_SCC
> + Â Â Â bool "68360 SCC uart support"
> + Â Â Â depends on M68360
> + Â Â Â help
> + Â Â Â Â This driver supports the SCC serial ports of the Motorola 68360 CPU.
> +
> +config SERIAL_68360
> + Â Â Â bool
> + Â Â Â depends on SERIAL_68360_SMC || SERIAL_68360_SCC
> + Â Â Â default y
> diff --git a/drivers/staging/serial/Makefile b/drivers/staging/serial/Makefile
> new file mode 100644
> index 0000000..37a6a0b
> --- /dev/null
> +++ b/drivers/staging/serial/Makefile
> @@ -0,0 +1 @@
> +obj-$(CONFIG_SERIAL_68360) += 68360serial.o
> diff --git a/drivers/staging/serial/TODO b/drivers/staging/serial/TODO
> new file mode 100644
> index 0000000..a19cda8
> --- /dev/null
> +++ b/drivers/staging/serial/TODO
> @@ -0,0 +1,6 @@
> +These are a few serial drivers that either do not build, or do not work if they
> +do build, or if they seem to work, are for obsolete hardware, or are full of
> +unfixable races and no one uses them anymore.
> +
> +If no one steps up to adopt any of these drivers, they will be removed
> +in the 3.4 release.
> diff --git a/drivers/tty/serial/68360serial.c b/drivers/tty/serial/68360serial.c
> deleted file mode 100644
> index 0a3e878..0000000
> --- a/drivers/tty/serial/68360serial.c
> +++ /dev/null
> @@ -1,2979 +0,0 @@
> -/*
> - * ÂUART driver for 68360 CPM SCC or SMC
> - * ÂCopyright (c) 2000 D. Jeff Dionne <jeff@xxxxxxxxxxx>,
> - * ÂCopyright (c) 2000 Michael Leslie <mleslie@xxxxxxxx>
> - * ÂCopyright (c) 1997 Dan Malek <dmalek@xxxxxxx>
> - *
> - * I used the serial.c driver as the framework for this driver.
> - * Give credit to those guys.
> - * The original code was written for the MBX860 board. ÂI tried to make
> - * it generic, but there may be some assumptions in the structures that
> - * have to be fixed later.
> - * To save porting time, I did not bother to change any object names
> - * that are not accessed outside of this file.
> - * It still needs lots of work........When it was easy, I included code
> - * to support the SCCs, but this has never been tested, nor is it complete.
> - * Only the SCCs support modem control, so that is not complete either.
> - *
> - * This module exports the following rs232 io functions:
> - *
> - * Â Â int rs_360_init(void);
> - */
> -
> -#include <linux/module.h>
> -#include <linux/errno.h>
> -#include <linux/signal.h>
> -#include <linux/sched.h>
> -#include <linux/timer.h>
> -#include <linux/interrupt.h>
> -#include <linux/tty.h>
> -#include <linux/tty_flip.h>
> -#include <linux/serial.h>
> -#include <linux/serialP.h>
> -#include <linux/major.h>
> -#include <linux/string.h>
> -#include <linux/fcntl.h>
> -#include <linux/ptrace.h>
> -#include <linux/mm.h>
> -#include <linux/init.h>
> -#include <linux/delay.h>
> -#include <asm/irq.h>
> -#include <asm/m68360.h>
> -#include <asm/commproc.h>
> -
> -
> -#ifdef CONFIG_KGDB
> -extern void breakpoint(void);
> -extern void set_debug_traps(void);
> -extern int Âkgdb_output_string (const char* s, unsigned int count);
> -#endif
> -
> -
> -/* #ifdef CONFIG_SERIAL_CONSOLE */ /* This seems to be a post 2.0 thing - mles */
> -#include <linux/console.h>
> -#include <linux/jiffies.h>
> -
> -/* this defines the index into rs_table for the port to use
> - */
> -#ifndef CONFIG_SERIAL_CONSOLE_PORT
> -#define CONFIG_SERIAL_CONSOLE_PORT Â Â 1 /* ie SMC2 - note USE_SMC2 must be defined */
> -#endif
> -/* #endif */
> -
> -#if 0
> -/* SCC2 for console
> - */
> -#undef CONFIG_SERIAL_CONSOLE_PORT
> -#define CONFIG_SERIAL_CONSOLE_PORT Â Â 2
> -#endif
> -
> -
> -#define TX_WAKEUP Â Â ÂASYNC_SHARE_IRQ
> -
> -static char *serial_name = "CPM UART driver";
> -static char *serial_version = "0.03";
> -
> -static struct tty_driver *serial_driver;
> -int serial_console_setup(struct console *co, char *options);
> -
> -/*
> - * Serial driver configuration section. ÂHere are the various options:
> - */
> -#define SERIAL_PARANOIA_CHECK
> -#define CONFIG_SERIAL_NOPAUSE_IO
> -#define SERIAL_DO_RESTART
> -
> -/* Set of debugging defines */
> -
> -#undef SERIAL_DEBUG_INTR
> -#undef SERIAL_DEBUG_OPEN
> -#undef SERIAL_DEBUG_FLOW
> -#undef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
> -
> -#define _INLINE_ inline
> -
> -#define DBG_CNT(s)
> -
> -/* We overload some of the items in the data structure to meet our
> - * needs. ÂFor example, the port address is the CPM parameter ram
> - * offset for the SCC or SMC. ÂThe maximum number of ports is 4 SCCs and
> - * 2 SMCs. ÂThe "hub6" field is used to indicate the channel number, with
> - * a flag indicating SCC or SMC, and the number is used as an index into
> - * the CPM parameter area for this device.
> - * The "type" field is currently set to 0, for PORT_UNKNOWN. ÂIt is
> - * not currently used. ÂI should probably use it to indicate the port
> - * type of SMC or SCC.
> - * The SMCs do not support any modem control signals.
> - */
> -#define smc_scc_num  Âhub6
> -#define NUM_IS_SCC Â Â ((int)0x00010000)
> -#define PORT_NUM(P) Â Â((P) & 0x0000ffff)
> -
> -
> -#if defined (CONFIG_UCQUICC)
> -
> -volatile extern void *_periph_base;
> -/* sipex transceiver
> - *  mode bits for    are on pins
> - *
> - * Â ÂSCC2 Â Â Â Â Â Â Â Âd16..19
> - * Â ÂSCC3 Â Â Â Â Â Â Â Âd20..23
> - * Â ÂSCC4 Â Â Â Â Â Â Â Âd24..27
> - */
> -#define SIPEX_MODE(n,m) ((m & 0x0f)<<(16+4*(n-1)))
> -
> -static uint sipex_mode_bits = 0x00000000;
> -
> -#endif
> -
> -/* There is no `serial_state' defined back here in 2.0.
> - * Try to get by with serial_struct
> - */
> -/* #define serial_state serial_struct */
> -
> -/* 2.4 -> 2.0 portability problem: async_icount in 2.4 has a few
> - * extras: */
> -
> -#if 0
> -struct async_icount_24 {
> - Â Â Â __u32 Â cts, dsr, rng, dcd, tx, rx;
> - Â Â Â __u32 Â frame, parity, overrun, brk;
> - Â Â Â __u32 Â buf_overrun;
> -} icount;
> -#endif
> -
> -#if 0
> -
> -struct serial_state {
> -    Âint   magic;
> -    Âint   baud_base;
> -    Âunsigned long  port;
> -    Âint   irq;
> -    Âint   flags;
> -    Âint   hub6;
> -    Âint   type;
> -    Âint   line;
> -    Âint   revision;    /* Chip revision (950) */
> -    Âint   xmit_fifo_size;
> -    Âint   custom_divisor;
> -    Âint   count;
> - Â Â Â Âu8 Â Â Â*iomem_base;
> - Â Â Â Âu16 Â Â iomem_reg_shift;
> - Â Â Â Âunsigned short Âclose_delay;
> - Â Â Â Âunsigned short Âclosing_wait; /* time to wait before closing */
> - Â Â Â Âstruct async_icount_24 Â Â icount;
> -    Âint   io_type;
> - Â Â Â Âstruct async_struct *info;
> -};
> -#endif
> -
> -#define SSTATE_MAGIC 0x5302
> -
> -
> -
> -/* SMC2 is sometimes used for low performance TDM interfaces. ÂDefine
> - * this as 1 if you want SMC2 as a serial port UART managed by this driver.
> - * Define this as 0 if you wish to use SMC2 for something else.
> - */
> -#define USE_SMC2 1
> -
> -#if 0
> -/* Define SCC to ttySx mapping. */
> -#define SCC_NUM_BASE Â (USE_SMC2 + 1) Â/* SCC base tty "number" */
> -
> -/* Define which SCC is the first one to use for a serial port. ÂThese
> - * are 0-based numbers, i.e. this assumes the first SCC (SCC1) is used
> - * for Ethernet, and the first available SCC for serial UART is SCC2.
> - * NOTE: ÂIF YOU CHANGE THIS, you have to change the PROFF_xxx and
> - * interrupt vectors in the table below to match.
> - */
> -#define SCC_IDX_BASE Â 1 Â Â Â /* table index */
> -#endif
> -
> -
> -/* Processors other than the 860 only get SMCs configured by default.
> - * Either they don't have SCCs or they are allocated somewhere else.
> - * Of course, there are now 860s without some SCCs, so we will need to
> - * address that someday.
> - * The Embedded Planet Multimedia I/O cards use TDM interfaces to the
> - * stereo codec parts, and we use SMC2 to help support that.
> - */
> -static struct serial_state rs_table[] = {
> -/* Âtype  line  PORT      IRQ    FLAGS Âsmc_scc_num (F.K.A. hub6) */
> - Â Â Â { Â0, Â Â 0, PRSLOT_SMC1, CPMVEC_SMC1, Â 0, Â Â0 } Â Â/* SMC1 ttyS0 */
> -#if USE_SMC2
> - Â Â Â ,{ 0, Â Â 0, PRSLOT_SMC2, CPMVEC_SMC2, Â 0, Â Â1 } Â Â /* SMC2 ttyS1 */
> -#endif
> -
> -#if defined(CONFIG_SERIAL_68360_SCC)
> - Â Â Â ,{ 0, Â Â 0, PRSLOT_SCC2, CPMVEC_SCC2, Â 0, (NUM_IS_SCC | 1) } Â Â/* SCC2 ttyS2 */
> - Â Â Â ,{ 0, Â Â 0, PRSLOT_SCC3, CPMVEC_SCC3, Â 0, (NUM_IS_SCC | 2) } Â Â/* SCC3 ttyS3 */
> - Â Â Â ,{ 0, Â Â 0, PRSLOT_SCC4, CPMVEC_SCC4, Â 0, (NUM_IS_SCC | 3) } Â Â/* SCC4 ttyS4 */
> -#endif
> -};
> -
> -#define NR_PORTS Â Â Â (sizeof(rs_table)/sizeof(struct serial_state))
> -
> -/* The number of buffer descriptors and their sizes.
> - */
> -#define RX_NUM_FIFO Â Â4
> -#define RX_BUF_SIZE Â Â32
> -#define TX_NUM_FIFO Â Â4
> -#define TX_BUF_SIZE Â Â32
> -
> -#define CONSOLE_NUM_FIFO 2
> -#define CONSOLE_BUF_SIZE 4
> -
> -char *console_fifos[CONSOLE_NUM_FIFO * CONSOLE_BUF_SIZE];
> -
> -/* The async_struct in serial.h does not really give us what we
> - * need, so define our own here.
> - */
> -typedef struct serial_info {
> -    int           magic;
> -    int           flags;
> -
> -    struct serial_state   *state;
> - Â Â Â /* struct serial_struct *state; */
> - Â Â Â /* struct async_struct Â*state; */
> -
> -    struct tty_struct    *tty;
> -    int           read_status_mask;
> -    int           ignore_status_mask;
> -    int           timeout;
> -    int           line;
> -    int           x_char; /* xon/xoff character */
> -    int           close_delay;
> -    unsigned short     Âclosing_wait;
> -    unsigned short     Âclosing_wait2;
> -    unsigned long      event;
> -    unsigned long      last_active;
> -    int           blocked_open; /* # of blocked opens */
> -    struct work_struct   Âtqueue;
> -    struct work_struct   Âtqueue_hangup;
> -    wait_queue_head_t    open_wait;
> -    wait_queue_head_t    close_wait;
> -
> -
> -/* CPM Buffer Descriptor pointers.
> - Â Â Â */
> - Â Â Â QUICC_BD Â Â Â Â Â Â Â Â Â Â Â Â*rx_bd_base;
> - Â Â Â QUICC_BD Â Â Â Â Â Â Â Â Â Â Â Â*rx_cur;
> - Â Â Â QUICC_BD Â Â Â Â Â Â Â Â Â Â Â Â*tx_bd_base;
> - Â Â Â QUICC_BD Â Â Â Â Â Â Â Â Â Â Â Â*tx_cur;
> -} ser_info_t;
> -
> -
> -/* since kmalloc_init() does not get called until much after this initialization: */
> -static ser_info_t Âquicc_ser_info[NR_PORTS];
> -static char rx_buf_pool[NR_PORTS * RX_NUM_FIFO * RX_BUF_SIZE];
> -static char tx_buf_pool[NR_PORTS * TX_NUM_FIFO * TX_BUF_SIZE];
> -
> -static void change_speed(ser_info_t *info);
> -static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout);
> -
> -static inline int serial_paranoia_check(ser_info_t *info,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â char *name, const char *routine)
> -{
> -#ifdef SERIAL_PARANOIA_CHECK
> - Â Â Â static const char *badmagic =
> - Â Â Â Â Â Â Â "Warning: bad magic number for serial struct (%s) in %s\n";
> - Â Â Â static const char *badinfo =
> - Â Â Â Â Â Â Â "Warning: null async_struct for (%s) in %s\n";
> -
> - Â Â Â if (!info) {
> - Â Â Â Â Â Â Â printk(badinfo, name, routine);
> - Â Â Â Â Â Â Â return 1;
> - Â Â Â }
> - Â Â Â if (info->magic != SERIAL_MAGIC) {
> - Â Â Â Â Â Â Â printk(badmagic, name, routine);
> - Â Â Â Â Â Â Â return 1;
> - Â Â Â }
> -#endif
> - Â Â Â return 0;
> -}
> -
> -/*
> - * This is used to figure out the divisor speeds and the timeouts,
> - * indexed by the termio value. ÂThe generic CPM functions are responsible
> - * for setting and assigning baud rate generators for us.
> - */
> -static int baud_table[] = {
> - Â Â Â 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
> - Â Â Â 9600, 19200, 38400, 57600, 115200, 230400, 460800, 0 };
> -
> -/* This sucks. There is a better way: */
> -#if defined(CONFIG_CONSOLE_9600)
> - Â#define CONSOLE_BAUDRATE 9600
> -#elif defined(CONFIG_CONSOLE_19200)
> - Â#define CONSOLE_BAUDRATE 19200
> -#elif defined(CONFIG_CONSOLE_115200)
> - Â#define CONSOLE_BAUDRATE 115200
> -#else
> - Â#warning "console baud rate undefined"
> - Â#define CONSOLE_BAUDRATE 9600
> -#endif
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_stop() and rs_start()
> - *
> - * This routines are called before setting or resetting tty->stopped.
> - * They enable or disable transmitter interrupts, as necessary.
> - * ------------------------------------------------------------
> - */
> -static void rs_360_stop(struct tty_struct *tty)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> -    int   idx;
> - Â Â Â unsigned long flags;
> - Â Â Â volatile struct scc_regs *sccp;
> - Â Â Â volatile struct smc_regs *smcp;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_stop"))
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â local_irq_save(flags);
> - Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> - Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> - Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> - Â Â Â Â Â Â Â sccp->scc_sccm &= ~UART_SCCM_TX;
> - Â Â Â } else {
> - Â Â Â Â Â Â Â /* smcp = &cpmp->cp_smc[idx]; */
> - Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> - Â Â Â Â Â Â Â smcp->smc_smcm &= ~SMCM_TX;
> - Â Â Â }
> - Â Â Â local_irq_restore(flags);
> -}
> -
> -
> -static void rs_360_start(struct tty_struct *tty)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> -    int   idx;
> - Â Â Â unsigned long flags;
> - Â Â Â volatile struct scc_regs *sccp;
> - Â Â Â volatile struct smc_regs *smcp;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_stop"))
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â local_irq_save(flags);
> - Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> - Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> - Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> - Â Â Â Â Â Â Â sccp->scc_sccm |= UART_SCCM_TX;
> - Â Â Â } else {
> - Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> - Â Â Â Â Â Â Â smcp->smc_smcm |= SMCM_TX;
> - Â Â Â }
> - Â Â Â local_irq_restore(flags);
> -}
> -
> -/*
> - * ----------------------------------------------------------------------
> - *
> - * Here starts the interrupt handling routines. ÂAll of the following
> - * subroutines are declared as inline and are folded into
> - * rs_interrupt(). ÂThey were separated out for readability's sake.
> - *
> - * Note: rs_interrupt() is a "fast" interrupt, which means that it
> - * runs with interrupts turned off. ÂPeople who may want to modify
> - * rs_interrupt() should try to keep the interrupt handler as fast as
> - * possible. ÂAfter you are done making modifications, it is not a bad
> - * idea to do:
> - *
> - * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c
> - *
> - * and look at the resulting assemble code in serial.s.
> - *
> - * Â Â Â Â Â Â Â Â Â Â Â Â Â Â - Ted Ts'o (tytso@xxxxxxx), 7-Mar-93
> - * -----------------------------------------------------------------------
> - */
> -
> -static _INLINE_ void receive_chars(ser_info_t *info)
> -{
> - Â Â Â struct tty_struct *tty = info->port.tty;
> - Â Â Â unsigned char ch, flag, *cp;
> -    /*int  ignored = 0;*/
> -    int   i;
> - Â Â Â ushort Âstatus;
> - Â Â Â Âstruct async_icount *icount;
> -    /* struct    async_icount_24 *icount; */
> - Â Â Â volatile QUICC_BD Â Â Â *bdp;
> -
> - Â Â Â icount = &info->state->icount;
> -
> - Â Â Â /* Just loop through the closed BDs and copy the characters into
> - Â Â Â Â* the buffer.
> - Â Â Â Â*/
> - Â Â Â bdp = info->rx_cur;
> - Â Â Â for (;;) {
> - Â Â Â Â Â Â Â if (bdp->status & BD_SC_EMPTY) Â/* If this one is empty */
> - Â Â Â Â Â Â Â Â Â Â Â break; Â Â Â Â Â Â Â Â Â/* Â we are all done */
> -
> - Â Â Â Â Â Â Â /* The read status mask tell us what we should do with
> - Â Â Â Â Â Â Â Â* incoming characters, especially if errors occur.
> - Â Â Â Â Â Â Â Â* One special case is the use of BD_SC_EMPTY. ÂIf
> - Â Â Â Â Â Â Â Â* this is not set, we are supposed to be ignoring
> - Â Â Â Â Â Â Â Â* inputs. ÂIn this case, just mark the buffer empty and
> - Â Â Â Â Â Â Â Â* continue.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â if (!(info->read_status_mask & BD_SC_EMPTY)) {
> - Â Â Â Â Â Â Â Â Â Â Â bdp->status |= BD_SC_EMPTY;
> - Â Â Â Â Â Â Â Â Â Â Â bdp->status &=
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
> -
> - Â Â Â Â Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp = info->rx_bd_base;
> - Â Â Â Â Â Â Â Â Â Â Â else
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp++;
> - Â Â Â Â Â Â Â Â Â Â Â continue;
> - Â Â Â Â Â Â Â }
> -
> - Â Â Â Â Â Â Â /* Get the number of characters and the buffer pointer.
> - Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â i = bdp->length;
> - Â Â Â Â Â Â Â /* cp = (unsigned char *)__va(bdp->buf); */
> - Â Â Â Â Â Â Â cp = (char *)bdp->buf;
> - Â Â Â Â Â Â Â status = bdp->status;
> -
> - Â Â Â Â Â Â Â while (i-- > 0) {
> - Â Â Â Â Â Â Â Â Â Â Â ch = *cp++;
> - Â Â Â Â Â Â Â Â Â Â Â icount->rx++;
> -
> -#ifdef SERIAL_DEBUG_INTR
> - Â Â Â Â Â Â Â Â Â Â Â printk("DR%02x:%02x...", ch, status);
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â flag = TTY_NORMAL;
> -
> - Â Â Â Â Â Â Â Â Â Â Â if (status & (BD_SC_BR | BD_SC_FR |
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂBD_SC_PR | BD_SC_OV)) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* For statistics only
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (status & BD_SC_BR)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â icount->brk++;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else if (status & BD_SC_PR)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â icount->parity++;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else if (status & BD_SC_FR)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â icount->frame++;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (status & BD_SC_OV)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â icount->overrun++;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* Now check to see if character should be
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* ignored, and mask off conditions which
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* should be ignored.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (status & info->ignore_status_mask) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (++ignored > 100)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â continue;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â status &= info->read_status_mask;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (status & (BD_SC_BR)) {
> -#ifdef SERIAL_DEBUG_INTR
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk("handling break....");
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â *tty->flip.flag_buf_ptr = TTY_BREAK;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (info->flags & ASYNC_SAK)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â do_SAK(tty);
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } else if (status & BD_SC_PR)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â flag = TTY_PARITY;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â else if (status & BD_SC_FR)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â flag = TTY_FRAME;
> - Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â Â Â Â Â tty_insert_flip_char(tty, ch, flag);
> - Â Â Â Â Â Â Â Â Â Â Â if (status & BD_SC_OV)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* Overrun is special, since it's
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* reported immediately, and doesn't
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* affect the current character
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â tty_insert_flip_char(tty, 0, TTY_OVERRUN);
> - Â Â Â Â Â Â Â }
> -
> - Â Â Â Â Â Â Â /* This BD is ready to be used again. ÂClear status.
> - Â Â Â Â Â Â Â Â* Get next BD.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â bdp->status |= BD_SC_EMPTY;
> - Â Â Â Â Â Â Â bdp->status &= ~(BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_OV);
> -
> - Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP)
> - Â Â Â Â Â Â Â Â Â Â Â bdp = info->rx_bd_base;
> - Â Â Â Â Â Â Â else
> - Â Â Â Â Â Â Â Â Â Â Â bdp++;
> - Â Â Â }
> -
> - Â Â Â info->rx_cur = (QUICC_BD *)bdp;
> -
> - Â Â Â tty_schedule_flip(tty);
> -}
> -
> -static _INLINE_ void receive_break(ser_info_t *info)
> -{
> - Â Â Â struct tty_struct *tty = info->port.tty;
> -
> - Â Â Â info->state->icount.brk++;
> - Â Â Â /* Check to see if there is room in the tty buffer for
> - Â Â Â Â* the break. ÂIf not, we exit now, losing the break. ÂFIXME
> - Â Â Â Â*/
> - Â Â Â tty_insert_flip_char(tty, 0, TTY_BREAK);
> - Â Â Â tty_schedule_flip(tty);
> -}
> -
> -static _INLINE_ void transmit_chars(ser_info_t *info)
> -{
> -
> - Â Â Â if ((info->flags & TX_WAKEUP) ||
> - Â Â Â Â Â (info->port.tty->flags & (1 << TTY_DO_WRITE_WAKEUP))) {
> - Â Â Â Â Â Â Â schedule_work(&info->tqueue);
> - Â Â Â }
> -
> -#ifdef SERIAL_DEBUG_INTR
> - Â Â Â printk("THRE...");
> -#endif
> -}
> -
> -#ifdef notdef
> - Â Â Â /* I need to do this for the SCCs, so it is left as a reminder.
> - Â Â Â */
> -static _INLINE_ void check_modem_status(struct async_struct *info)
> -{
> -    int   status;
> -    /* struct    async_icount *icount; */
> - Â Â Â struct Âasync_icount_24 *icount;
> -
> - Â Â Â status = serial_in(info, UART_MSR);
> -
> - Â Â Â if (status & UART_MSR_ANY_DELTA) {
> - Â Â Â Â Â Â Â icount = &info->state->icount;
> - Â Â Â Â Â Â Â /* update input line counters */
> - Â Â Â Â Â Â Â if (status & UART_MSR_TERI)
> - Â Â Â Â Â Â Â Â Â Â Â icount->rng++;
> - Â Â Â Â Â Â Â if (status & UART_MSR_DDSR)
> - Â Â Â Â Â Â Â Â Â Â Â icount->dsr++;
> - Â Â Â Â Â Â Â if (status & UART_MSR_DDCD) {
> - Â Â Â Â Â Â Â Â Â Â Â icount->dcd++;
> -#ifdef CONFIG_HARD_PPS
> - Â Â Â Â Â Â Â Â Â Â Â if ((info->flags & ASYNC_HARDPPS_CD) &&
> - Â Â Â Â Â Â Â Â Â Â Â Â Â (status & UART_MSR_DCD))
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â hardpps();
> -#endif
> - Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â if (status & UART_MSR_DCTS)
> - Â Â Â Â Â Â Â Â Â Â Â icount->cts++;
> - Â Â Â Â Â Â Â wake_up_interruptible(&info->delta_msr_wait);
> - Â Â Â }
> -
> - Â Â Â if ((info->flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
> -#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
> - Â Â Â Â Â Â Â printk("ttys%d CD now %s...", info->line,
> - Â Â Â Â Â Â Â Â Â Â Â(status & UART_MSR_DCD) ? "on" : "off");
> -#endif
> - Â Â Â Â Â Â Â if (status & UART_MSR_DCD)
> - Â Â Â Â Â Â Â Â Â Â Â wake_up_interruptible(&info->open_wait);
> - Â Â Â Â Â Â Â else {
> -#ifdef SERIAL_DEBUG_OPEN
> - Â Â Â Â Â Â Â Â Â Â Â printk("scheduling hangup...");
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â queue_task(&info->tqueue_hangup,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â&tq_scheduler);
> - Â Â Â Â Â Â Â }
> - Â Â Â }
> - Â Â Â if (info->flags & ASYNC_CTS_FLOW) {
> - Â Â Â Â Â Â Â if (info->port.tty->hw_stopped) {
> - Â Â Â Â Â Â Â Â Â Â Â if (status & UART_MSR_CTS) {
> -#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk("CTS tx start...");
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info->port.tty->hw_stopped = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info->IER |= UART_IER_THRI;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â serial_out(info, UART_IER, info->IER);
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return;
> - Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â } else {
> - Â Â Â Â Â Â Â Â Â Â Â if (!(status & UART_MSR_CTS)) {
> -#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk("CTS tx stop...");
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info->port.tty->hw_stopped = 1;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info->IER &= ~UART_IER_THRI;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â serial_out(info, UART_IER, info->IER);
> - Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â }
> - Â Â Â }
> -}
> -#endif
> -
> -/*
> - * This is the serial driver's interrupt routine for a single port
> - */
> -/* static void rs_360_interrupt(void *dev_id) */ /* until and if we start servicing irqs here */
> -static void rs_360_interrupt(int vec, void *dev_id)
> -{
> - Â Â Â u_char Âevents;
> -    int   idx;
> - Â Â Â ser_info_t *info;
> - Â Â Â volatile struct smc_regs *smcp;
> - Â Â Â volatile struct scc_regs *sccp;
> -
> - Â Â Â info = dev_id;
> -
> - Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> - Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> - Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> - Â Â Â Â Â Â Â events = sccp->scc_scce;
> - Â Â Â Â Â Â Â if (events & SCCM_RX)
> - Â Â Â Â Â Â Â Â Â Â Â receive_chars(info);
> - Â Â Â Â Â Â Â if (events & SCCM_TX)
> - Â Â Â Â Â Â Â Â Â Â Â transmit_chars(info);
> - Â Â Â Â Â Â Â sccp->scc_scce = events;
> - Â Â Â } else {
> - Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> - Â Â Â Â Â Â Â events = smcp->smc_smce;
> - Â Â Â Â Â Â Â if (events & SMCM_BRKE)
> - Â Â Â Â Â Â Â Â Â Â Â receive_break(info);
> - Â Â Â Â Â Â Â if (events & SMCM_RX)
> - Â Â Â Â Â Â Â Â Â Â Â receive_chars(info);
> - Â Â Â Â Â Â Â if (events & SMCM_TX)
> - Â Â Â Â Â Â Â Â Â Â Â transmit_chars(info);
> - Â Â Â Â Â Â Â smcp->smc_smce = events;
> - Â Â Â }
> -
> -#ifdef SERIAL_DEBUG_INTR
> - Â Â Â printk("rs_interrupt_single(%d, %x)...",
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â info->state->smc_scc_num, events);
> -#endif
> -#ifdef modem_control
> - Â Â Â check_modem_status(info);
> -#endif
> - Â Â Â info->last_active = jiffies;
> -#ifdef SERIAL_DEBUG_INTR
> - Â Â Â printk("end.\n");
> -#endif
> -}
> -
> -
> -/*
> - * -------------------------------------------------------------------
> - * Here ends the serial interrupt routines.
> - * -------------------------------------------------------------------
> - */
> -
> -
> -static void do_softint(void *private_)
> -{
> -    ser_info_t   Â*info = (ser_info_t *) private_;
> -    struct tty_struct    *tty;
> -
> - Â Â Â tty = info->port.tty;
> - Â Â Â if (!tty)
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event))
> - Â Â Â Â Â Â Â tty_wakeup(tty);
> -}
> -
> -
> -/*
> - * This routine is called from the scheduler tqueue when the interrupt
> - * routine has signalled that a hangup has occurred. ÂThe path of
> - * hangup processing is:
> - *
> - * Â Â serial interrupt routine -> (scheduler tqueue) ->
> - * Â Â do_serial_hangup() -> tty->hangup() -> rs_hangup()
> - *
> - */
> -static void do_serial_hangup(void *private_)
> -{
> -    struct async_struct   *info = (struct async_struct *) private_;
> -    struct tty_struct    *tty;
> -
> - Â Â Â tty = info->port.tty;
> - Â Â Â if (!tty)
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â tty_hangup(tty);
> -}
> -
> -
> -static int startup(ser_info_t *info)
> -{
> - Â Â Â unsigned long flags;
> -    int   retval=0;
> -    int   idx;
> - Â Â Â /*struct serial_state *state = info->state;*/
> - Â Â Â volatile struct smc_regs *smcp;
> - Â Â Â volatile struct scc_regs *sccp;
> -    volatile struct smc_uart_pram  *up;
> -    volatile struct uart_pram      *scup;
> -
> -
> - Â Â Â local_irq_save(flags);
> -
> - Â Â Â if (info->flags & ASYNC_INITIALIZED) {
> - Â Â Â Â Â Â Â goto errout;
> - Â Â Â }
> -
> -#ifdef maybe
> - Â Â Â if (!state->port || !state->type) {
> - Â Â Â Â Â Â Â if (info->port.tty)
> - Â Â Â Â Â Â Â Â Â Â Â set_bit(TTY_IO_ERROR, &info->port.tty->flags);
> - Â Â Â Â Â Â Â goto errout;
> - Â Â Â }
> -#endif
> -
> -#ifdef SERIAL_DEBUG_OPEN
> - Â Â Â printk("starting up ttys%d (irq %d)...", info->line, state->irq);
> -#endif
> -
> -
> -#ifdef modem_control
> - Â Â Â info->MCR = 0;
> - Â Â Â if (info->port.tty->termios->c_cflag & CBAUD)
> - Â Â Â Â Â Â Â info->MCR = UART_MCR_DTR | UART_MCR_RTS;
> -#endif
> -
> - Â Â Â if (info->port.tty)
> - Â Â Â Â Â Â Â clear_bit(TTY_IO_ERROR, &info->port.tty->flags);
> -
> - Â Â Â /*
> - Â Â Â Â* and set the speed of the serial port
> - Â Â Â Â*/
> - Â Â Â change_speed(info);
> -
> - Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> - Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> - Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> - Â Â Â Â Â Â Â scup = &pquicc->pram[info->state->port].scc.pscc.u;
> -
> - Â Â Â Â Â Â Â scup->mrblr = RX_BUF_SIZE;
> - Â Â Â Â Â Â Â scup->max_idl = RX_BUF_SIZE;
> -
> - Â Â Â Â Â Â Â sccp->scc_sccm |= (UART_SCCM_TX | UART_SCCM_RX);
> - Â Â Â Â Â Â Â sccp->scc_gsmr.w.low |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
> -
> - Â Â Â } else {
> - Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> -
> - Â Â Â Â Â Â Â /* Enable interrupts and I/O.
> - Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â smcp->smc_smcm |= (SMCM_RX | SMCM_TX);
> - Â Â Â Â Â Â Â smcp->smc_smcmr |= (SMCMR_REN | SMCMR_TEN);
> -
> - Â Â Â Â Â Â Â /* We can tune the buffer length and idle characters
> - Â Â Â Â Â Â Â Â* to take advantage of the entire incoming buffer size.
> - Â Â Â Â Â Â Â Â* If mrblr is something other than 1, maxidl has to be
> - Â Â Â Â Â Â Â Â* non-zero or we never get an interrupt. ÂThe maxidl
> - Â Â Â Â Â Â Â Â* is the number of character times we wait after reception
> - Â Â Â Â Â Â Â Â* of the last character before we decide no more characters
> - Â Â Â Â Â Â Â Â* are coming.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â /* up = (smc_uart_t *)&pquicc->cp_dparam[state->port]; */
> - Â Â Â Â Â Â Â /* holy unionized structures, Batman: */
> - Â Â Â Â Â Â Â up = &pquicc->pram[info->state->port].scc.pothers.idma_smc.psmc.u;
> -
> - Â Â Â Â Â Â Â up->mrblr = RX_BUF_SIZE;
> - Â Â Â Â Â Â Â up->max_idl = RX_BUF_SIZE;
> -
> - Â Â Â Â Â Â Â up->brkcr = 1; Â/* number of break chars */
> - Â Â Â }
> -
> - Â Â Â info->flags |= ASYNC_INITIALIZED;
> - Â Â Â local_irq_restore(flags);
> - Â Â Â return 0;
> -
> -errout:
> - Â Â Â local_irq_restore(flags);
> - Â Â Â return retval;
> -}
> -
> -/*
> - * This routine will shutdown a serial port; interrupts are disabled, and
> - * DTR is dropped if the hangup on close termio flag is on.
> - */
> -static void shutdown(ser_info_t *info)
> -{
> -    unsigned long  flags;
> - Â Â Â struct serial_state *state;
> -    int       idx;
> -    volatile struct smc_regs    Â*smcp;
> -    volatile struct scc_regs    Â*sccp;
> -
> - Â Â Â if (!(info->flags & ASYNC_INITIALIZED))
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â state = info->state;
> -
> -#ifdef SERIAL_DEBUG_OPEN
> - Â Â Â printk("Shutting down serial port %d (irq %d)....", info->line,
> - Â Â Â Â Â Â Âstate->irq);
> -#endif
> -
> - Â Â Â local_irq_save(flags);
> -
> - Â Â Â idx = PORT_NUM(state->smc_scc_num);
> - Â Â Â if (state->smc_scc_num & NUM_IS_SCC) {
> - Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> - Â Â Â Â Â Â Â sccp->scc_gsmr.w.low &= ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT);
> -#ifdef CONFIG_SERIAL_CONSOLE
> - Â Â Â Â Â Â Â /* We can't disable the transmitter if this is the
> - Â Â Â Â Â Â Â Â* system console.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â if ((state - rs_table) != CONFIG_SERIAL_CONSOLE_PORT)
> -#endif
> - Â Â Â Â Â Â Â sccp->scc_sccm &= ~(UART_SCCM_TX | UART_SCCM_RX);
> - Â Â Â } else {
> - Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> -
> - Â Â Â Â Â Â Â /* Disable interrupts and I/O.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX);
> -#ifdef CONFIG_SERIAL_CONSOLE
> - Â Â Â Â Â Â Â /* We can't disable the transmitter if this is the
> - Â Â Â Â Â Â Â Â* system console.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â if ((state - rs_table) != CONFIG_SERIAL_CONSOLE_PORT)
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
> - Â Â Â }
> -
> - Â Â Â if (info->port.tty)
> - Â Â Â Â Â Â Â set_bit(TTY_IO_ERROR, &info->port.tty->flags);
> -
> - Â Â Â info->flags &= ~ASYNC_INITIALIZED;
> - Â Â Â local_irq_restore(flags);
> -}
> -
> -/*
> - * This routine is called to set the UART divisor registers to match
> - * the specified baud rate for a serial port.
> - */
> -static void change_speed(ser_info_t *info)
> -{
> -    int   baud_rate;
> - Â Â Â unsigned cflag, cval, scval, prev_mode;
> -    int   i, bits, sbits, idx;
> -    unsigned long  flags;
> - Â Â Â struct serial_state *state;
> -    volatile struct smc_regs    Â*smcp;
> -    volatile struct scc_regs    Â*sccp;
> -
> - Â Â Â if (!info->port.tty || !info->port.tty->termios)
> - Â Â Â Â Â Â Â return;
> - Â Â Â cflag = info->port.tty->termios->c_cflag;
> -
> - Â Â Â state = info->state;
> -
> - Â Â Â /* Character length programmed into the mode register is the
> - Â Â Â Â* sum of: 1 start bit, number of data bits, 0 or 1 parity bit,
> - Â Â Â Â* 1 or 2 stop bits, minus 1.
> - Â Â Â Â* The value 'bits' counts this for us.
> - Â Â Â Â*/
> - Â Â Â cval = 0;
> - Â Â Â scval = 0;
> -
> - Â Â Â /* byte size and parity */
> - Â Â Â switch (cflag & CSIZE) {
> - Â Â Â Â Â Â case CS5: bits = 5; break;
> - Â Â Â Â Â Â case CS6: bits = 6; break;
> - Â Â Â Â Â Â case CS7: bits = 7; break;
> - Â Â Â Â Â Â case CS8: bits = 8; break;
> - Â Â Â Â Â Â /* Never happens, but GCC is too dumb to figure it out */
> - Â Â Â Â Â Â default: Âbits = 8; break;
> - Â Â Â }
> - Â Â Â sbits = bits - 5;
> -
> - Â Â Â if (cflag & CSTOPB) {
> - Â Â Â Â Â Â Â cval |= SMCMR_SL; Â Â Â /* Two stops */
> - Â Â Â Â Â Â Â scval |= SCU_PMSR_SL;
> - Â Â Â Â Â Â Â bits++;
> - Â Â Â }
> - Â Â Â if (cflag & PARENB) {
> - Â Â Â Â Â Â Â cval |= SMCMR_PEN;
> - Â Â Â Â Â Â Â scval |= SCU_PMSR_PEN;
> - Â Â Â Â Â Â Â bits++;
> - Â Â Â }
> - Â Â Â if (!(cflag & PARODD)) {
> - Â Â Â Â Â Â Â cval |= SMCMR_PM_EVEN;
> - Â Â Â Â Â Â Â scval |= (SCU_PMSR_REVP | SCU_PMSR_TEVP);
> - Â Â Â }
> -
> - Â Â Â /* Determine divisor based on baud rate */
> - Â Â Â i = cflag & CBAUD;
> - Â Â Â if (i >= (sizeof(baud_table)/sizeof(int)))
> - Â Â Â Â Â Â Â baud_rate = 9600;
> - Â Â Â else
> - Â Â Â Â Â Â Â baud_rate = baud_table[i];
> -
> - Â Â Â info->timeout = (TX_BUF_SIZE*HZ*bits);
> - Â Â Â info->timeout += HZ/50; Â Â Â Â /* Add .02 seconds of slop */
> -
> -#ifdef modem_control
> - Â Â Â /* CTS flow control flag and modem status interrupts */
> - Â Â Â info->IER &= ~UART_IER_MSI;
> - Â Â Â if (info->flags & ASYNC_HARDPPS_CD)
> - Â Â Â Â Â Â Â info->IER |= UART_IER_MSI;
> - Â Â Â if (cflag & CRTSCTS) {
> - Â Â Â Â Â Â Â info->flags |= ASYNC_CTS_FLOW;
> - Â Â Â Â Â Â Â info->IER |= UART_IER_MSI;
> - Â Â Â } else
> - Â Â Â Â Â Â Â info->flags &= ~ASYNC_CTS_FLOW;
> - Â Â Â if (cflag & CLOCAL)
> - Â Â Â Â Â Â Â info->flags &= ~ASYNC_CHECK_CD;
> - Â Â Â else {
> - Â Â Â Â Â Â Â info->flags |= ASYNC_CHECK_CD;
> - Â Â Â Â Â Â Â info->IER |= UART_IER_MSI;
> - Â Â Â }
> - Â Â Â serial_out(info, UART_IER, info->IER);
> -#endif
> -
> - Â Â Â /*
> - Â Â Â Â* Set up parity check flag
> - Â Â Â Â*/
> - Â Â Â info->read_status_mask = (BD_SC_EMPTY | BD_SC_OV);
> - Â Â Â if (I_INPCK(info->port.tty))
> - Â Â Â Â Â Â Â info->read_status_mask |= BD_SC_FR | BD_SC_PR;
> - Â Â Â if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty))
> - Â Â Â Â Â Â Â info->read_status_mask |= BD_SC_BR;
> -
> - Â Â Â /*
> - Â Â Â Â* Characters to ignore
> - Â Â Â Â*/
> - Â Â Â info->ignore_status_mask = 0;
> - Â Â Â if (I_IGNPAR(info->port.tty))
> - Â Â Â Â Â Â Â info->ignore_status_mask |= BD_SC_PR | BD_SC_FR;
> - Â Â Â if (I_IGNBRK(info->port.tty)) {
> - Â Â Â Â Â Â Â info->ignore_status_mask |= BD_SC_BR;
> - Â Â Â Â Â Â Â /*
> - Â Â Â Â Â Â Â Â* If we're ignore parity and break indicators, ignore
> - Â Â Â Â Â Â Â Â* overruns too. Â(For real raw support).
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â if (I_IGNPAR(info->port.tty))
> - Â Â Â Â Â Â Â Â Â Â Â info->ignore_status_mask |= BD_SC_OV;
> - Â Â Â }
> - Â Â Â /*
> - Â Â Â Â* !!! ignore all characters if CREAD is not set
> - Â Â Â Â*/
> - Â Â Â if ((cflag & CREAD) == 0)
> - Â Â Â Âinfo->read_status_mask &= ~BD_SC_EMPTY;
> - Â Â Â Âlocal_irq_save(flags);
> -
> - Â Â Â Â/* Start bit has not been added (so don't, because we would just
> - Â Â Â Â * subtract it later), and we need to add one for the number of
> - Â Â Â Â * stops bits (there is always at least one).
> - Â Â Â Â */
> - Â Â Â Âbits++;
> - Â Â Â Âidx = PORT_NUM(state->smc_scc_num);
> - Â Â Â Âif (state->smc_scc_num & NUM_IS_SCC) {
> - Â Â Â Â sccp = &pquicc->scc_regs[idx];
> - Â Â Â Â sccp->scc_psmr = (sbits << 12) | scval;
> - Â Â } else {
> - Â Â Â Â smcp = &pquicc->smc_regs[idx];
> -
> - Â Â Â Â Â Â Â /* Set the mode register. ÂWe want to keep a copy of the
> - Â Â Â Â Â Â Â Â* enables, because we want to put them back if they were
> - Â Â Â Â Â Â Â Â* present.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â prev_mode = smcp->smc_smcmr;
> - Â Â Â Â Â Â Â smcp->smc_smcmr = smcr_mk_clen(bits) | cval | ÂSMCMR_SM_UART;
> - Â Â Â Â Â Â Â smcp->smc_smcmr |= (prev_mode & (SMCMR_REN | SMCMR_TEN));
> - Â Â Â }
> -
> - Â Â Â m360_cpm_setbrg((state - rs_table), baud_rate);
> -
> - Â Â Â local_irq_restore(flags);
> -}
> -
> -static void rs_360_put_char(struct tty_struct *tty, unsigned char ch)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> - Â Â Â volatile QUICC_BD Â Â Â *bdp;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_put_char"))
> - Â Â Â Â Â Â Â return 0;
> -
> - Â Â Â if (!tty)
> - Â Â Â Â Â Â Â return 0;
> -
> - Â Â Â bdp = info->tx_cur;
> - Â Â Â while (bdp->status & BD_SC_READY);
> -
> - Â Â Â /* *((char *)__va(bdp->buf)) = ch; */
> - Â Â Â *((char *)bdp->buf) = ch;
> - Â Â Â bdp->length = 1;
> - Â Â Â bdp->status |= BD_SC_READY;
> -
> - Â Â Â /* Get next BD.
> - Â Â Â */
> - Â Â Â if (bdp->status & BD_SC_WRAP)
> - Â Â Â Â Â Â Â bdp = info->tx_bd_base;
> - Â Â Â else
> - Â Â Â Â Â Â Â bdp++;
> -
> - Â Â Â info->tx_cur = (QUICC_BD *)bdp;
> - Â Â Â return 1;
> -
> -}
> -
> -static int rs_360_write(struct tty_struct * tty,
> - Â Â Â Â Â Â Â Â Â const unsigned char *buf, int count)
> -{
> -    int   c, ret = 0;
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> - Â Â Â volatile QUICC_BD *bdp;
> -
> -#ifdef CONFIG_KGDB
> - Â Â Â /* Try to let stub handle output. Returns true if it did. */
> - Â Â Â if (kgdb_output_string(buf, count))
> - Â Â Â Â Â Â Â return ret;
> -#endif
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_write"))
> - Â Â Â Â Â Â Â return 0;
> -
> - Â Â Â if (!tty)
> - Â Â Â Â Â Â Â return 0;
> -
> - Â Â Â bdp = info->tx_cur;
> -
> - Â Â Â while (1) {
> - Â Â Â Â Â Â Â c = min(count, TX_BUF_SIZE);
> -
> - Â Â Â Â Â Â Â if (c <= 0)
> - Â Â Â Â Â Â Â Â Â Â Â break;
> -
> - Â Â Â Â Â Â Â if (bdp->status & BD_SC_READY) {
> - Â Â Â Â Â Â Â Â Â Â Â info->flags |= TX_WAKEUP;
> - Â Â Â Â Â Â Â Â Â Â Â break;
> - Â Â Â Â Â Â Â }
> -
> - Â Â Â Â Â Â Â /* memcpy(__va(bdp->buf), buf, c); */
> - Â Â Â Â Â Â Â memcpy((void *)bdp->buf, buf, c);
> -
> - Â Â Â Â Â Â Â bdp->length = c;
> - Â Â Â Â Â Â Â bdp->status |= BD_SC_READY;
> -
> - Â Â Â Â Â Â Â buf += c;
> - Â Â Â Â Â Â Â count -= c;
> - Â Â Â Â Â Â Â ret += c;
> -
> - Â Â Â Â Â Â Â /* Get next BD.
> - Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP)
> - Â Â Â Â Â Â Â Â Â Â Â bdp = info->tx_bd_base;
> - Â Â Â Â Â Â Â else
> - Â Â Â Â Â Â Â Â Â Â Â bdp++;
> - Â Â Â Â Â Â Â info->tx_cur = (QUICC_BD *)bdp;
> - Â Â Â }
> - Â Â Â return ret;
> -}
> -
> -static int rs_360_write_room(struct tty_struct *tty)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> -    int   ret;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_write_room"))
> - Â Â Â Â Â Â Â return 0;
> -
> - Â Â Â if ((info->tx_cur->status & BD_SC_READY) == 0) {
> - Â Â Â Â Â Â Â info->flags &= ~TX_WAKEUP;
> - Â Â Â Â Â Â Â ret = TX_BUF_SIZE;
> - Â Â Â }
> - Â Â Â else {
> - Â Â Â Â Â Â Â info->flags |= TX_WAKEUP;
> - Â Â Â Â Â Â Â ret = 0;
> - Â Â Â }
> - Â Â Â return ret;
> -}
> -
> -/* I could track this with transmit counters....maybe later.
> -*/
> -static int rs_360_chars_in_buffer(struct tty_struct *tty)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
> - Â Â Â Â Â Â Â return 0;
> - Â Â Â return 0;
> -}
> -
> -static void rs_360_flush_buffer(struct tty_struct *tty)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â /* There is nothing to "flush", whatever we gave the CPM
> - Â Â Â Â* is on its way out.
> - Â Â Â Â*/
> - Â Â Â tty_wakeup(tty);
> - Â Â Â info->flags &= ~TX_WAKEUP;
> -}
> -
> -/*
> - * This function is used to send a high-priority XON/XOFF character to
> - * the device
> - */
> -static void rs_360_send_xchar(struct tty_struct *tty, char ch)
> -{
> - Â Â Â volatile QUICC_BD Â Â Â *bdp;
> -
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_send_char"))
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â bdp = info->tx_cur;
> - Â Â Â while (bdp->status & BD_SC_READY);
> -
> - Â Â Â /* *((char *)__va(bdp->buf)) = ch; */
> - Â Â Â *((char *)bdp->buf) = ch;
> - Â Â Â bdp->length = 1;
> - Â Â Â bdp->status |= BD_SC_READY;
> -
> - Â Â Â /* Get next BD.
> - Â Â Â */
> - Â Â Â if (bdp->status & BD_SC_WRAP)
> - Â Â Â Â Â Â Â bdp = info->tx_bd_base;
> - Â Â Â else
> - Â Â Â Â Â Â Â bdp++;
> -
> - Â Â Â info->tx_cur = (QUICC_BD *)bdp;
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_throttle()
> - *
> - * This routine is called by the upper-layer tty layer to signal that
> - * incoming characters should be throttled.
> - * ------------------------------------------------------------
> - */
> -static void rs_360_throttle(struct tty_struct * tty)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> -#ifdef SERIAL_DEBUG_THROTTLE
> -    char  Âbuf[64];
> -
> - Â Â Â printk("throttle %s: %d....\n", _tty_name(tty, buf),
> - Â Â Â Â Â Â Âtty->ldisc.chars_in_buffer(tty));
> -#endif
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_throttle"))
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â if (I_IXOFF(tty))
> - Â Â Â Â Â Â Â rs_360_send_xchar(tty, STOP_CHAR(tty));
> -
> -#ifdef modem_control
> - Â Â Â if (tty->termios->c_cflag & CRTSCTS)
> - Â Â Â Â Â Â Â info->MCR &= ~UART_MCR_RTS;
> -
> - Â Â Â local_irq_disable();
> - Â Â Â serial_out(info, UART_MCR, info->MCR);
> - Â Â Â local_irq_enable();
> -#endif
> -}
> -
> -static void rs_360_unthrottle(struct tty_struct * tty)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> -#ifdef SERIAL_DEBUG_THROTTLE
> -    char  Âbuf[64];
> -
> - Â Â Â printk("unthrottle %s: %d....\n", _tty_name(tty, buf),
> - Â Â Â Â Â Â Âtty->ldisc.chars_in_buffer(tty));
> -#endif
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â if (I_IXOFF(tty)) {
> - Â Â Â Â Â Â Â if (info->x_char)
> - Â Â Â Â Â Â Â Â Â Â Â info->x_char = 0;
> - Â Â Â Â Â Â Â else
> - Â Â Â Â Â Â Â Â Â Â Â rs_360_send_xchar(tty, START_CHAR(tty));
> - Â Â Â }
> -#ifdef modem_control
> - Â Â Â if (tty->termios->c_cflag & CRTSCTS)
> - Â Â Â Â Â Â Â info->MCR |= UART_MCR_RTS;
> - Â Â Â local_irq_disable();
> - Â Â Â serial_out(info, UART_MCR, info->MCR);
> - Â Â Â local_irq_enable();
> -#endif
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_ioctl() and friends
> - * ------------------------------------------------------------
> - */
> -
> -#ifdef maybe
> -/*
> - * get_lsr_info - get line status register info
> - *
> - * Purpose: Let user call ioctl() to get info when the UART physically
> - * Â Â Â Â is emptied. ÂOn bus types like RS485, the transmitter must
> - * Â Â Â Â release the bus after transmitting. This must be done when
> - * Â Â Â Â the transmit shift register is empty, not be done when the
> - * Â Â Â Â transmit holding register is empty. ÂThis functionality
> - * Â Â Â Â allows an RS485 driver to be written in user space.
> - */
> -static int get_lsr_info(struct async_struct * info, unsigned int *value)
> -{
> - Â Â Â unsigned char status;
> - Â Â Â unsigned int result;
> -
> - Â Â Â local_irq_disable();
> - Â Â Â status = serial_in(info, UART_LSR);
> - Â Â Â local_irq_enable();
> - Â Â Â result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
> - Â Â Â return put_user(result,value);
> -}
> -#endif
> -
> -static int rs_360_tiocmget(struct tty_struct *tty)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> - Â Â Â unsigned int result = 0;
> -#ifdef modem_control
> - Â Â Â unsigned char control, status;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, __func__))
> - Â Â Â Â Â Â Â return -ENODEV;
> -
> - Â Â Â if (tty->flags & (1 << TTY_IO_ERROR))
> - Â Â Â Â Â Â Â return -EIO;
> -
> - Â Â Â control = info->MCR;
> - Â Â Â local_irq_disable();
> - Â Â Â status = serial_in(info, UART_MSR);
> - Â Â Â local_irq_enable();
> - Â Â Â result = Â((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
> - Â Â Â Â Â Â Â | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
> -#ifdef TIOCM_OUT1
> - Â Â Â Â Â Â Â | ((control & UART_MCR_OUT1) ? TIOCM_OUT1 : 0)
> - Â Â Â Â Â Â Â | ((control & UART_MCR_OUT2) ? TIOCM_OUT2 : 0)
> -#endif
> - Â Â Â Â Â Â Â | ((status Â& UART_MSR_DCD) ? TIOCM_CAR : 0)
> - Â Â Â Â Â Â Â | ((status Â& UART_MSR_RI) ? TIOCM_RNG : 0)
> - Â Â Â Â Â Â Â | ((status Â& UART_MSR_DSR) ? TIOCM_DSR : 0)
> - Â Â Â Â Â Â Â | ((status Â& UART_MSR_CTS) ? TIOCM_CTS : 0);
> -#endif
> - Â Â Â return result;
> -}
> -
> -static int rs_360_tiocmset(struct tty_struct *tty,
> - Â Â Â Â Â Â Â Â Â Â Â Â Âunsigned int set, unsigned int clear)
> -{
> -#ifdef modem_control
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> - Â Â Â unsigned int arg;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, __func__))
> - Â Â Â Â Â Â Â return -ENODEV;
> -
> - Â Â Â if (tty->flags & (1 << TTY_IO_ERROR))
> - Â Â Â Â Â Â Â return -EIO;
> - Â Â Â /* FIXME: locking on info->mcr */
> - Â Â Â if (set & TIOCM_RTS)
> - Â Â Â Â Â Â Â info->mcr |= UART_MCR_RTS;
> - Â Â Â if (set & TIOCM_DTR)
> - Â Â Â Â Â Â Â info->mcr |= UART_MCR_DTR;
> - Â Â Â if (clear & TIOCM_RTS)
> - Â Â Â Â Â Â Â info->MCR &= ~UART_MCR_RTS;
> - Â Â Â if (clear & TIOCM_DTR)
> - Â Â Â Â Â Â Â info->MCR &= ~UART_MCR_DTR;
> -
> -#ifdef TIOCM_OUT1
> - Â Â Â if (set & TIOCM_OUT1)
> - Â Â Â Â Â Â Â info->MCR |= UART_MCR_OUT1;
> - Â Â Â if (set & TIOCM_OUT2)
> - Â Â Â Â Â Â Â info->MCR |= UART_MCR_OUT2;
> - Â Â Â if (clear & TIOCM_OUT1)
> - Â Â Â Â Â Â Â info->MCR &= ~UART_MCR_OUT1;
> - Â Â Â if (clear & TIOCM_OUT2)
> - Â Â Â Â Â Â Â info->MCR &= ~UART_MCR_OUT2;
> -#endif
> -
> - Â Â Â local_irq_disable();
> - Â Â Â serial_out(info, UART_MCR, info->MCR);
> - Â Â Â local_irq_enable();
> -#endif
> - Â Â Â return 0;
> -}
> -
> -/* Sending a break is a two step process on the SMC/SCC. ÂIt is accomplished
> - * by sending a STOP TRANSMIT command followed by a RESTART TRANSMIT
> - * command. ÂWe take advantage of the begin/end functions to make this
> - * happen.
> - */
> -static ushort Âsmc_chan_map[] = {
> - Â Â Â CPM_CR_CH_SMC1,
> - Â Â Â CPM_CR_CH_SMC2
> -};
> -
> -static ushort Âscc_chan_map[] = {
> - Â Â Â CPM_CR_CH_SCC1,
> - Â Â Â CPM_CR_CH_SCC2,
> - Â Â Â CPM_CR_CH_SCC3,
> - Â Â Â CPM_CR_CH_SCC4
> -};
> -
> -static void begin_break(ser_info_t *info)
> -{
> - Â Â Â volatile QUICC *cp;
> - Â Â Â ushort Âchan;
> -    int   idx;
> -
> - Â Â Â cp = pquicc;
> -
> - Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> - Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC)
> - Â Â Â Â Â Â Â chan = scc_chan_map[idx];
> - Â Â Â else
> - Â Â Â Â Â Â Â chan = smc_chan_map[idx];
> -
> - Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_STOP_TX) | CPM_CR_FLG;
> - Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> -}
> -
> -static void end_break(ser_info_t *info)
> -{
> - Â Â Â volatile QUICC *cp;
> - Â Â Â ushort Âchan;
> - Â Â Â int idx;
> -
> - Â Â Â cp = pquicc;
> -
> - Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> - Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC)
> - Â Â Â Â Â Â Â chan = scc_chan_map[idx];
> - Â Â Â else
> - Â Â Â Â Â Â Â chan = smc_chan_map[idx];
> -
> - Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_RESTART_TX) | CPM_CR_FLG;
> - Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> -}
> -
> -/*
> - * This routine sends a break character out the serial port.
> - */
> -static void send_break(ser_info_t *info, unsigned int duration)
> -{
> -#ifdef SERIAL_DEBUG_SEND_BREAK
> - Â Â Â printk("rs_send_break(%d) jiff=%lu...", duration, jiffies);
> -#endif
> - Â Â Â begin_break(info);
> - Â Â Â msleep_interruptible(duration);
> - Â Â Â end_break(info);
> -#ifdef SERIAL_DEBUG_SEND_BREAK
> - Â Â Â printk("done jiffies=%lu\n", jiffies);
> -#endif
> -}
> -
> -
> -/*
> - * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
> - * Return: write counters to the user passed counter struct
> - * NB: both 1->0 and 0->1 transitions are counted except for
> - * Â Â RI where only 0->1 is counted.
> - */
> -static int rs_360_get_icount(struct tty_struct *tty,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct serial_icounter_struct *icount)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> - Â Â Â struct async_icount cnow;
> -
> - Â Â Â local_irq_disable();
> - Â Â Â cnow = info->state->icount;
> - Â Â Â local_irq_enable();
> -
> - Â Â Â icount->cts = cnow.cts;
> - Â Â Â icount->dsr = cnow.dsr;
> - Â Â Â icount->rng = cnow.rng;
> - Â Â Â icount->dcd = cnow.dcd;
> -
> - Â Â Â return 0;
> -}
> -
> -static int rs_360_ioctl(struct tty_struct *tty,
> - Â Â Â Â Â Â Â Â Â unsigned int cmd, unsigned long arg)
> -{
> - Â Â Â int error;
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> - Â Â Â int retval;
> - Â Â Â struct async_icount cnow;
> - Â Â Â /* struct async_icount_24 cnow;*/ Â Â Â /* kernel counter temps */
> - Â Â Â struct serial_icounter_struct *p_cuser; /* user space */
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
> - Â Â Â Â Â Â Â return -ENODEV;
> -
> - Â Â Â if (cmd != TIOCMIWAIT) {
> - Â Â Â Â Â Â Â if (tty->flags & (1 << TTY_IO_ERROR))
> - Â Â Â Â Â Â Â Â Â return -EIO;
> - Â Â Â }
> -
> - Â Â Â switch (cmd) {
> - Â Â Â Â Â Â Â case TCSBRK: Â Â/* SVID version: non-zero arg --> no break */
> - Â Â Â Â Â Â Â Â Â Â Â retval = tty_check_change(tty);
> - Â Â Â Â Â Â Â Â Â Â Â if (retval)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return retval;
> - Â Â Â Â Â Â Â Â Â Â Â tty_wait_until_sent(tty, 0);
> - Â Â Â Â Â Â Â Â Â Â Â if (signal_pending(current))
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EINTR;
> - Â Â Â Â Â Â Â Â Â Â Â if (!arg) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â send_break(info, 250); Â/* 1/4 second */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (signal_pending(current))
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EINTR;
> - Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â Â Â Â Â return 0;
> - Â Â Â Â Â Â Â case TCSBRKP: Â /* support for POSIX tcsendbreak() */
> - Â Â Â Â Â Â Â Â Â Â Â retval = tty_check_change(tty);
> - Â Â Â Â Â Â Â Â Â Â Â if (retval)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return retval;
> - Â Â Â Â Â Â Â Â Â Â Â tty_wait_until_sent(tty, 0);
> - Â Â Â Â Â Â Â Â Â Â Â if (signal_pending(current))
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EINTR;
> - Â Â Â Â Â Â Â Â Â Â Â send_break(info, arg ? arg*100 : 250);
> - Â Â Â Â Â Â Â Â Â Â Â if (signal_pending(current))
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EINTR;
> - Â Â Â Â Â Â Â Â Â Â Â return 0;
> - Â Â Â Â Â Â Â case TIOCSBRK:
> - Â Â Â Â Â Â Â Â Â Â Â retval = tty_check_change(tty);
> - Â Â Â Â Â Â Â Â Â Â Â if (retval)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return retval;
> - Â Â Â Â Â Â Â Â Â Â Â tty_wait_until_sent(tty, 0);
> - Â Â Â Â Â Â Â Â Â Â Â begin_break(info);
> - Â Â Â Â Â Â Â Â Â Â Â return 0;
> - Â Â Â Â Â Â Â case TIOCCBRK:
> - Â Â Â Â Â Â Â Â Â Â Â retval = tty_check_change(tty);
> - Â Â Â Â Â Â Â Â Â Â Â if (retval)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return retval;
> - Â Â Â Â Â Â Â Â Â Â Â end_break(info);
> - Â Â Â Â Â Â Â Â Â Â Â return 0;
> -#ifdef maybe
> - Â Â Â Â Â Â Â case TIOCSERGETLSR: /* Get line status register */
> - Â Â Â Â Â Â Â Â Â Â Â return get_lsr_info(info, (unsigned int *) arg);
> -#endif
> - Â Â Â Â Â Â Â /*
> - Â Â Â Â Â Â Â Â* Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
> - Â Â Â Â Â Â Â Â* - mask passed in arg for lines of interest
> - Â Â Â Â Â Â Â Â* Â (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
> - Â Â Â Â Â Â Â Â* Caller should use TIOCGICOUNT to see which one it was
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Âcase TIOCMIWAIT:
> -#ifdef modem_control
> - Â Â Â Â Â Â Â Â Â Â Â local_irq_disable();
> - Â Â Â Â Â Â Â Â Â Â Â /* note the counters on entry */
> - Â Â Â Â Â Â Â Â Â Â Â cprev = info->state->icount;
> - Â Â Â Â Â Â Â Â Â Â Â local_irq_enable();
> - Â Â Â Â Â Â Â Â Â Â Â while (1) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â interruptible_sleep_on(&info->delta_msr_wait);
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* see if a signal did it */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (signal_pending(current))
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -ERESTARTSYS;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â local_irq_disable();
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cnow = info->state->icount; /* atomic copy */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â local_irq_enable();
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return -EIO; /* no change => error */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â((arg & TIOCM_CD) Â&& (cnow.dcd != cprev.dcd)) ||
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â return 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cprev = cnow;
> - Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â Â Â Â Â /* NOTREACHED */
> -#else
> - Â Â Â Â Â Â Â Â Â Â Â return 0;
> -#endif
> -
> -
> - Â Â Â Â Â Â Â default:
> - Â Â Â Â Â Â Â Â Â Â Â return -ENOIOCTLCMD;
> - Â Â Â Â Â Â Â }
> - Â Â Â return 0;
> -}
> -
> -/* FIX UP modem control here someday......
> -*/
> -static void rs_360_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> -
> - Â Â Â change_speed(info);
> -
> -#ifdef modem_control
> - Â Â Â /* Handle transition to B0 status */
> - Â Â Â if ((old_termios->c_cflag & CBAUD) &&
> - Â Â Â Â Â !(tty->termios->c_cflag & CBAUD)) {
> - Â Â Â Â Â Â Â info->MCR &= ~(UART_MCR_DTR|UART_MCR_RTS);
> - Â Â Â Â Â Â Â local_irq_disable();
> - Â Â Â Â Â Â Â serial_out(info, UART_MCR, info->MCR);
> - Â Â Â Â Â Â Â local_irq_enable();
> - Â Â Â }
> -
> - Â Â Â /* Handle transition away from B0 status */
> - Â Â Â if (!(old_termios->c_cflag & CBAUD) &&
> - Â Â Â Â Â (tty->termios->c_cflag & CBAUD)) {
> - Â Â Â Â Â Â Â info->MCR |= UART_MCR_DTR;
> - Â Â Â Â Â Â Â if (!tty->hw_stopped ||
> - Â Â Â Â Â Â Â Â Â !(tty->termios->c_cflag & CRTSCTS)) {
> - Â Â Â Â Â Â Â Â Â Â Â info->MCR |= UART_MCR_RTS;
> - Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â local_irq_disable();
> - Â Â Â Â Â Â Â serial_out(info, UART_MCR, info->MCR);
> - Â Â Â Â Â Â Â local_irq_enable();
> - Â Â Â }
> -
> - Â Â Â /* Handle turning off CRTSCTS */
> - Â Â Â if ((old_termios->c_cflag & CRTSCTS) &&
> - Â Â Â Â Â !(tty->termios->c_cflag & CRTSCTS)) {
> - Â Â Â Â Â Â Â tty->hw_stopped = 0;
> - Â Â Â Â Â Â Â rs_360_start(tty);
> - Â Â Â }
> -#endif
> -
> -#if 0
> - Â Â Â /*
> - Â Â Â Â* No need to wake up processes in open wait, since they
> - Â Â Â Â* sample the CLOCAL flag once, and don't recheck it.
> - Â Â Â Â* XXX ÂIt's not clear whether the current behavior is correct
> - Â Â Â Â* or not. ÂHence, this may change.....
> - Â Â Â Â*/
> - Â Â Â if (!(old_termios->c_cflag & CLOCAL) &&
> - Â Â Â Â Â (tty->termios->c_cflag & CLOCAL))
> - Â Â Â Â Â Â Â wake_up_interruptible(&info->open_wait);
> -#endif
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_close()
> - *
> - * This routine is called when the serial port gets closed. ÂFirst, we
> - * wait for the last remaining data to be sent. ÂThen, we unlink its
> - * async structure from the interrupt chain if necessary, and we free
> - * that IRQ if nothing is left in the chain.
> - * ------------------------------------------------------------
> - */
> -static void rs_360_close(struct tty_struct *tty, struct file * filp)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> - Â Â Â /* struct async_state *state; */
> - Â Â Â struct serial_state *state;
> -    unsigned long  flags;
> -    int       idx;
> -    volatile struct smc_regs    Â*smcp;
> -    volatile struct scc_regs    Â*sccp;
> -
> - Â Â Â if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â state = info->state;
> -
> - Â Â Â local_irq_save(flags);
> -
> - Â Â Â if (tty_hung_up_p(filp)) {
> - Â Â Â Â Â Â Â DBG_CNT("before DEC-hung");
> - Â Â Â Â Â Â Â local_irq_restore(flags);
> - Â Â Â Â Â Â Â return;
> - Â Â Â }
> -
> -#ifdef SERIAL_DEBUG_OPEN
> - Â Â Â printk("rs_close ttys%d, count = %d\n", info->line, state->count);
> -#endif
> - Â Â Â if ((tty->count == 1) && (state->count != 1)) {
> - Â Â Â Â Â Â Â /*
> - Â Â Â Â Â Â Â Â* Uh, oh. Âtty->count is 1, which means that the tty
> - Â Â Â Â Â Â Â Â* structure will be freed. Âstate->count should always
> - Â Â Â Â Â Â Â Â* be one in these conditions. ÂIf it's greater than
> - Â Â Â Â Â Â Â Â* one, we've got real problems, since it means the
> - Â Â Â Â Â Â Â Â* serial port won't be shutdown.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â printk("rs_close: bad serial port count; tty->count is 1, "
> - Â Â Â Â Â Â Â Â Â Â Â"state->count is %d\n", state->count);
> - Â Â Â Â Â Â Â state->count = 1;
> - Â Â Â }
> - Â Â Â if (--state->count < 0) {
> - Â Â Â Â Â Â Â printk("rs_close: bad serial port count for ttys%d: %d\n",
> - Â Â Â Â Â Â Â Â Â Â Âinfo->line, state->count);
> - Â Â Â Â Â Â Â state->count = 0;
> - Â Â Â }
> - Â Â Â if (state->count) {
> - Â Â Â Â Â Â Â DBG_CNT("before DEC-2");
> - Â Â Â Â Â Â Â local_irq_restore(flags);
> - Â Â Â Â Â Â Â return;
> - Â Â Â }
> - Â Â Â info->flags |= ASYNC_CLOSING;
> - Â Â Â /*
> - Â Â Â Â* Now we wait for the transmit buffer to clear; and we notify
> - Â Â Â Â* the line discipline to only process XON/XOFF characters.
> - Â Â Â Â*/
> - Â Â Â tty->closing = 1;
> - Â Â Â if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE)
> - Â Â Â Â Â Â Â tty_wait_until_sent(tty, info->closing_wait);
> - Â Â Â /*
> - Â Â Â Â* At this point we stop accepting input. ÂTo do this, we
> - Â Â Â Â* disable the receive line status interrupts, and tell the
> - Â Â Â Â* interrupt driver to stop checking the data ready bit in the
> - Â Â Â Â* line status register.
> - Â Â Â Â*/
> - Â Â Â info->read_status_mask &= ~BD_SC_EMPTY;
> - Â Â Â if (info->flags & ASYNC_INITIALIZED) {
> -
> - Â Â Â Â Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> - Â Â Â Â Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> - Â Â Â Â Â Â Â Â Â Â Â sccp = &pquicc->scc_regs[idx];
> - Â Â Â Â Â Â Â Â Â Â Â sccp->scc_sccm &= ~UART_SCCM_RX;
> - Â Â Â Â Â Â Â Â Â Â Â sccp->scc_gsmr.w.low &= ~SCC_GSMRL_ENR;
> - Â Â Â Â Â Â Â } else {
> - Â Â Â Â Â Â Â Â Â Â Â smcp = &pquicc->smc_regs[idx];
> - Â Â Â Â Â Â Â Â Â Â Â smcp->smc_smcm &= ~SMCM_RX;
> - Â Â Â Â Â Â Â Â Â Â Â smcp->smc_smcmr &= ~SMCMR_REN;
> - Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â /*
> - Â Â Â Â Â Â Â Â* Before we drop DTR, make sure the UART transmitter
> - Â Â Â Â Â Â Â Â* has completely drained; this is especially
> - Â Â Â Â Â Â Â Â* important if there is a transmit FIFO!
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â rs_360_wait_until_sent(tty, info->timeout);
> - Â Â Â }
> - Â Â Â shutdown(info);
> - Â Â Â rs_360_flush_buffer(tty);
> - Â Â Â tty_ldisc_flush(tty);
> - Â Â Â tty->closing = 0;
> - Â Â Â info->event = 0;
> - Â Â Â info->port.tty = NULL;
> - Â Â Â if (info->blocked_open) {
> - Â Â Â Â Â Â Â if (info->close_delay) {
> - Â Â Â Â Â Â Â Â Â Â Â msleep_interruptible(jiffies_to_msecs(info->close_delay));
> - Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â wake_up_interruptible(&info->open_wait);
> - Â Â Â }
> - Â Â Â info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
> - Â Â Â wake_up_interruptible(&info->close_wait);
> - Â Â Â local_irq_restore(flags);
> -}
> -
> -/*
> - * rs_wait_until_sent() --- wait until the transmitter is empty
> - */
> -static void rs_360_wait_until_sent(struct tty_struct *tty, int timeout)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> - Â Â Â unsigned long orig_jiffies, char_time;
> - Â Â Â /*int lsr;*/
> - Â Â Â volatile QUICC_BD *bdp;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_wait_until_sent"))
> - Â Â Â Â Â Â Â return;
> -
> -#ifdef maybe
> - Â Â Â if (info->state->type == PORT_UNKNOWN)
> - Â Â Â Â Â Â Â return;
> -#endif
> -
> - Â Â Â orig_jiffies = jiffies;
> - Â Â Â /*
> - Â Â Â Â* Set the check interval to be 1/5 of the estimated time to
> - Â Â Â Â* send a single character, and make it at least 1. ÂThe check
> - Â Â Â Â* interval should also be less than the timeout.
> - Â Â Â Â*
> - Â Â Â Â* Note: we have to use pretty tight timings here to satisfy
> - Â Â Â Â* the NIST-PCTS.
> - Â Â Â Â*/
> - Â Â Â char_time = 1;
> - Â Â Â if (timeout)
> - Â Â Â Â Â Â Â char_time = min(char_time, (unsigned long)timeout);
> -#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
> - Â Â Â printk("In rs_wait_until_sent(%d) check=%lu...", timeout, char_time);
> - Â Â Â printk("jiff=%lu...", jiffies);
> -#endif
> -
> - Â Â Â /* We go through the loop at least once because we can't tell
> - Â Â Â Â* exactly when the last character exits the shifter. ÂThere can
> - Â Â Â Â* be at least two characters waiting to be sent after the buffers
> - Â Â Â Â* are empty.
> - Â Â Â Â*/
> - Â Â Â do {
> -#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
> - Â Â Â Â Â Â Â printk("lsr = %d (jiff=%lu)...", lsr, jiffies);
> -#endif
> -/* Â Â Â Â Â Â current->counter = 0; Â Âmake us low-priority */
> - Â Â Â Â Â Â Â msleep_interruptible(jiffies_to_msecs(char_time));
> - Â Â Â Â Â Â Â if (signal_pending(current))
> - Â Â Â Â Â Â Â Â Â Â Â break;
> - Â Â Â Â Â Â Â if (timeout && (time_after(jiffies, orig_jiffies + timeout)))
> - Â Â Â Â Â Â Â Â Â Â Â break;
> - Â Â Â Â Â Â Â /* The 'tx_cur' is really the next buffer to send. ÂWe
> - Â Â Â Â Â Â Â Â* have to back up to the previous BD and wait for it
> - Â Â Â Â Â Â Â Â* to go. ÂThis isn't perfect, because all this indicates
> - Â Â Â Â Â Â Â Â* is the buffer is available. ÂThere are still characters
> - Â Â Â Â Â Â Â Â* in the CPM FIFO.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â bdp = info->tx_cur;
> - Â Â Â Â Â Â Â if (bdp == info->tx_bd_base)
> - Â Â Â Â Â Â Â Â Â Â Â bdp += (TX_NUM_FIFO-1);
> - Â Â Â Â Â Â Â else
> - Â Â Â Â Â Â Â Â Â Â Â bdp--;
> - Â Â Â } while (bdp->status & BD_SC_READY);
> - Â Â Â current->state = TASK_RUNNING;
> -#ifdef SERIAL_DEBUG_RS_WAIT_UNTIL_SENT
> - Â Â Â printk("lsr = %d (jiff=%lu)...done\n", lsr, jiffies);
> -#endif
> -}
> -
> -/*
> - * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
> - */
> -static void rs_360_hangup(struct tty_struct *tty)
> -{
> - Â Â Â ser_info_t *info = (ser_info_t *)tty->driver_data;
> - Â Â Â struct serial_state *state = info->state;
> -
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_hangup"))
> - Â Â Â Â Â Â Â return;
> -
> - Â Â Â state = info->state;
> -
> - Â Â Â rs_360_flush_buffer(tty);
> - Â Â Â shutdown(info);
> - Â Â Â info->event = 0;
> - Â Â Â state->count = 0;
> - Â Â Â info->flags &= ~ASYNC_NORMAL_ACTIVE;
> - Â Â Â info->port.tty = NULL;
> - Â Â Â wake_up_interruptible(&info->open_wait);
> -}
> -
> -/*
> - * ------------------------------------------------------------
> - * rs_open() and friends
> - * ------------------------------------------------------------
> - */
> -static int block_til_ready(struct tty_struct *tty, struct file * filp,
> - Â Â Â Â Â Â Â Â Â Â Â Â Âser_info_t *info)
> -{
> -#ifdef DO_THIS_LATER
> - Â Â Â DECLARE_WAITQUEUE(wait, current);
> -#endif
> - Â Â Â struct serial_state *state = info->state;
> -    int       retval;
> -    int       do_clocal = 0;
> -
> - Â Â Â /*
> - Â Â Â Â* If the device is in the middle of being closed, then block
> - Â Â Â Â* until it's done, and then try again.
> - Â Â Â Â*/
> - Â Â Â if (tty_hung_up_p(filp) ||
> - Â Â Â Â Â (info->flags & ASYNC_CLOSING)) {
> - Â Â Â Â Â Â Â if (info->flags & ASYNC_CLOSING)
> - Â Â Â Â Â Â Â Â Â Â Â interruptible_sleep_on(&info->close_wait);
> -#ifdef SERIAL_DO_RESTART
> - Â Â Â Â Â Â Â if (info->flags & ASYNC_HUP_NOTIFY)
> - Â Â Â Â Â Â Â Â Â Â Â return -EAGAIN;
> - Â Â Â Â Â Â Â else
> - Â Â Â Â Â Â Â Â Â Â Â return -ERESTARTSYS;
> -#else
> - Â Â Â Â Â Â Â return -EAGAIN;
> -#endif
> - Â Â Â }
> -
> - Â Â Â /*
> - Â Â Â Â* If non-blocking mode is set, or the port is not enabled,
> - Â Â Â Â* then make the check up front and then exit.
> - Â Â Â Â* If this is an SMC port, we don't have modem control to wait
> - Â Â Â Â* for, so just get out here.
> - Â Â Â Â*/
> - Â Â Â if ((filp->f_flags & O_NONBLOCK) ||
> - Â Â Â Â Â (tty->flags & (1 << TTY_IO_ERROR)) ||
> - Â Â Â Â Â !(info->state->smc_scc_num & NUM_IS_SCC)) {
> - Â Â Â Â Â Â Â info->flags |= ASYNC_NORMAL_ACTIVE;
> - Â Â Â Â Â Â Â return 0;
> - Â Â Â }
> -
> - Â Â Â if (tty->termios->c_cflag & CLOCAL)
> - Â Â Â Â Â Â Â do_clocal = 1;
> -
> - Â Â Â /*
> - Â Â Â Â* Block waiting for the carrier detect and the line to become
> - Â Â Â Â* free (i.e., not in use by the callout). ÂWhile we are in
> - Â Â Â Â* this loop, state->count is dropped by one, so that
> - Â Â Â Â* rs_close() knows when to free things. ÂWe restore it upon
> - Â Â Â Â* exit, either normal or abnormal.
> - Â Â Â Â*/
> - Â Â Â retval = 0;
> -#ifdef DO_THIS_LATER
> - Â Â Â add_wait_queue(&info->open_wait, &wait);
> -#ifdef SERIAL_DEBUG_OPEN
> - Â Â Â printk("block_til_ready before block: ttys%d, count = %d\n",
> - Â Â Â Â Â Â Âstate->line, state->count);
> -#endif
> - Â Â Â local_irq_disable();
> - Â Â Â if (!tty_hung_up_p(filp))
> - Â Â Â Â Â Â Â state->count--;
> - Â Â Â local_irq_enable();
> - Â Â Â info->blocked_open++;
> - Â Â Â while (1) {
> - Â Â Â Â Â Â Â local_irq_disable();
> - Â Â Â Â Â Â Â if (tty->termios->c_cflag & CBAUD)
> - Â Â Â Â Â Â Â Â Â Â Â serial_out(info, UART_MCR,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âserial_inp(info, UART_MCR) |
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â(UART_MCR_DTR | UART_MCR_RTS));
> - Â Â Â Â Â Â Â local_irq_enable();
> - Â Â Â Â Â Â Â set_current_state(TASK_INTERRUPTIBLE);
> - Â Â Â Â Â Â Â if (tty_hung_up_p(filp) ||
> - Â Â Â Â Â Â Â Â Â !(info->flags & ASYNC_INITIALIZED)) {
> -#ifdef SERIAL_DO_RESTART
> - Â Â Â Â Â Â Â Â Â Â Â if (info->flags & ASYNC_HUP_NOTIFY)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â retval = -EAGAIN;
> - Â Â Â Â Â Â Â Â Â Â Â else
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â retval = -ERESTARTSYS;
> -#else
> - Â Â Â Â Â Â Â Â Â Â Â retval = -EAGAIN;
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â break;
> - Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â if (!(info->flags & ASYNC_CLOSING) &&
> - Â Â Â Â Â Â Â Â Â (do_clocal || (serial_in(info, UART_MSR) &
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂUART_MSR_DCD)))
> - Â Â Â Â Â Â Â Â Â Â Â break;
> - Â Â Â Â Â Â Â if (signal_pending(current)) {
> - Â Â Â Â Â Â Â Â Â Â Â retval = -ERESTARTSYS;
> - Â Â Â Â Â Â Â Â Â Â Â break;
> - Â Â Â Â Â Â Â }
> -#ifdef SERIAL_DEBUG_OPEN
> - Â Â Â Â Â Â Â printk("block_til_ready blocking: ttys%d, count = %d\n",
> - Â Â Â Â Â Â Â Â Â Â Âinfo->line, state->count);
> -#endif
> - Â Â Â Â Â Â Â tty_unlock();
> - Â Â Â Â Â Â Â schedule();
> - Â Â Â Â Â Â Â tty_lock();
> - Â Â Â }
> - Â Â Â current->state = TASK_RUNNING;
> - Â Â Â remove_wait_queue(&info->open_wait, &wait);
> - Â Â Â if (!tty_hung_up_p(filp))
> - Â Â Â Â Â Â Â state->count++;
> - Â Â Â info->blocked_open--;
> -#ifdef SERIAL_DEBUG_OPEN
> - Â Â Â printk("block_til_ready after blocking: ttys%d, count = %d\n",
> - Â Â Â Â Â Â Âinfo->line, state->count);
> -#endif
> -#endif /* DO_THIS_LATER */
> - Â Â Â if (retval)
> - Â Â Â Â Â Â Â return retval;
> - Â Â Â info->flags |= ASYNC_NORMAL_ACTIVE;
> - Â Â Â return 0;
> -}
> -
> -static int get_async_struct(int line, ser_info_t **ret_info)
> -{
> - Â Â Â struct serial_state *sstate;
> -
> - Â Â Â sstate = rs_table + line;
> - Â Â Â if (sstate->info) {
> - Â Â Â Â Â Â Â sstate->count++;
> - Â Â Â Â Â Â Â *ret_info = (ser_info_t *)sstate->info;
> - Â Â Â Â Â Â Â return 0;
> - Â Â Â }
> - Â Â Â else {
> - Â Â Â Â Â Â Â return -ENOMEM;
> - Â Â Â }
> -}
> -
> -/*
> - * This routine is called whenever a serial port is opened. ÂIt
> - * enables interrupts for a serial port, linking in its async structure into
> - * the IRQ chain. Â It also performs the serial-specific
> - * initialization for the tty structure.
> - */
> -static int rs_360_open(struct tty_struct *tty, struct file * filp)
> -{
> -    ser_info_t   Â*info;
> -    int       retval, line;
> -
> - Â Â Â line = tty->index;
> - Â Â Â if ((line < 0) || (line >= NR_PORTS))
> - Â Â Â Â Â Â Â return -ENODEV;
> - Â Â Â retval = get_async_struct(line, &info);
> - Â Â Â if (retval)
> - Â Â Â Â Â Â Â return retval;
> - Â Â Â if (serial_paranoia_check(info, tty->name, "rs_open"))
> - Â Â Â Â Â Â Â return -ENODEV;
> -
> -#ifdef SERIAL_DEBUG_OPEN
> - Â Â Â printk("rs_open %s, count = %d\n", tty->name, info->state->count);
> -#endif
> - Â Â Â tty->driver_data = info;
> - Â Â Â info->port.tty = tty;
> -
> - Â Â Â /*
> - Â Â Â Â* Start up serial port
> - Â Â Â Â*/
> - Â Â Â retval = startup(info);
> - Â Â Â if (retval)
> - Â Â Â Â Â Â Â return retval;
> -
> - Â Â Â retval = block_til_ready(tty, filp, info);
> - Â Â Â if (retval) {
> -#ifdef SERIAL_DEBUG_OPEN
> - Â Â Â Â Â Â Â printk("rs_open returning after block_til_ready with %d\n",
> - Â Â Â Â Â Â Â Â Â Â Âretval);
> -#endif
> - Â Â Â Â Â Â Â return retval;
> - Â Â Â }
> -
> -#ifdef SERIAL_DEBUG_OPEN
> - Â Â Â printk("rs_open %s successful...", tty->name);
> -#endif
> - Â Â Â return 0;
> -}
> -
> -/*
> - * /proc fs routines....
> - */
> -
> -static inline int line_info(char *buf, struct serial_state *state)
> -{
> -#ifdef notdef
> - Â Â Â struct async_struct *info = state->info, scr_info;
> -    char  Âstat_buf[30], control, status;
> -#endif
> -    int   ret;
> -
> - Â Â Â ret = sprintf(buf, "%d: uart:%s port:%X irq:%d",
> - Â Â Â Â Â Â Â Â Â Â state->line,
> - Â Â Â Â Â Â Â Â Â Â (state->smc_scc_num & NUM_IS_SCC) ? "SCC" : "SMC",
> - Â Â Â Â Â Â Â Â Â Â (unsigned int)(state->port), state->irq);
> -
> - Â Â Â if (!state->port || (state->type == PORT_UNKNOWN)) {
> - Â Â Â Â Â Â Â ret += sprintf(buf+ret, "\n");
> - Â Â Â Â Â Â Â return ret;
> - Â Â Â }
> -
> -#ifdef notdef
> - Â Â Â /*
> - Â Â Â Â* Figure out the current RS-232 lines
> - Â Â Â Â*/
> - Â Â Â if (!info) {
> - Â Â Â Â Â Â Â info = &scr_info; Â Â Â /* This is just for serial_{in,out} */
> -
> - Â Â Â Â Â Â Â info->magic = SERIAL_MAGIC;
> - Â Â Â Â Â Â Â info->port = state->port;
> - Â Â Â Â Â Â Â info->flags = state->flags;
> - Â Â Â Â Â Â Â info->quot = 0;
> - Â Â Â Â Â Â Â info->port.tty = NULL;
> - Â Â Â }
> - Â Â Â local_irq_disable();
> - Â Â Â status = serial_in(info, UART_MSR);
> - Â Â Â control = info ? info->MCR : serial_in(info, UART_MCR);
> - Â Â Â local_irq_enable();
> -
> - Â Â Â stat_buf[0] = 0;
> - Â Â Â stat_buf[1] = 0;
> - Â Â Â if (control & UART_MCR_RTS)
> - Â Â Â Â Â Â Â strcat(stat_buf, "|RTS");
> - Â Â Â if (status & UART_MSR_CTS)
> - Â Â Â Â Â Â Â strcat(stat_buf, "|CTS");
> - Â Â Â if (control & UART_MCR_DTR)
> - Â Â Â Â Â Â Â strcat(stat_buf, "|DTR");
> - Â Â Â if (status & UART_MSR_DSR)
> - Â Â Â Â Â Â Â strcat(stat_buf, "|DSR");
> - Â Â Â if (status & UART_MSR_DCD)
> - Â Â Â Â Â Â Â strcat(stat_buf, "|CD");
> - Â Â Â if (status & UART_MSR_RI)
> - Â Â Â Â Â Â Â strcat(stat_buf, "|RI");
> -
> - Â Â Â if (info->quot) {
> - Â Â Â Â Â Â Â ret += sprintf(buf+ret, " baud:%d",
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstate->baud_base / info->quot);
> - Â Â Â }
> -
> - Â Â Â ret += sprintf(buf+ret, " tx:%d rx:%d",
> - Â Â Â Â Â Â Â Â Â Â state->icount.tx, state->icount.rx);
> -
> - Â Â Â if (state->icount.frame)
> - Â Â Â Â Â Â Â ret += sprintf(buf+ret, " fe:%d", state->icount.frame);
> -
> - Â Â Â if (state->icount.parity)
> - Â Â Â Â Â Â Â ret += sprintf(buf+ret, " pe:%d", state->icount.parity);
> -
> - Â Â Â if (state->icount.brk)
> - Â Â Â Â Â Â Â ret += sprintf(buf+ret, " brk:%d", state->icount.brk);
> -
> - Â Â Â if (state->icount.overrun)
> - Â Â Â Â Â Â Â ret += sprintf(buf+ret, " oe:%d", state->icount.overrun);
> -
> - Â Â Â /*
> - Â Â Â Â* Last thing is the RS-232 status lines
> - Â Â Â Â*/
> - Â Â Â ret += sprintf(buf+ret, " %s\n", stat_buf+1);
> -#endif
> - Â Â Â return ret;
> -}
> -
> -int rs_360_read_proc(char *page, char **start, off_t off, int count,
> - Â Â Â Â Â Â Â Âint *eof, void *data)
> -{
> - Â Â Â int i, len = 0;
> -    off_t  begin = 0;
> -
> - Â Â Â len += sprintf(page, "serinfo:1.0 driver:%s\n", serial_version);
> - Â Â Â for (i = 0; i < NR_PORTS && len < 4000; i++) {
> - Â Â Â Â Â Â Â len += line_info(page + len, &rs_table[i]);
> - Â Â Â Â Â Â Â if (len+begin > off+count)
> - Â Â Â Â Â Â Â Â Â Â Â goto done;
> - Â Â Â Â Â Â Â if (len+begin < off) {
> - Â Â Â Â Â Â Â Â Â Â Â begin += len;
> - Â Â Â Â Â Â Â Â Â Â Â len = 0;
> - Â Â Â Â Â Â Â }
> - Â Â Â }
> - Â Â Â *eof = 1;
> -done:
> - Â Â Â if (off >= len+begin)
> - Â Â Â Â Â Â Â return 0;
> - Â Â Â *start = page + (begin-off);
> - Â Â Â return ((count < begin+len-off) ? count : begin+len-off);
> -}
> -
> -/*
> - * ---------------------------------------------------------------------
> - * rs_init() and friends
> - *
> - * rs_init() is called at boot-time to initialize the serial driver.
> - * ---------------------------------------------------------------------
> - */
> -
> -/*
> - * This routine prints out the appropriate serial driver version
> - * number, and identifies which options were configured into this
> - * driver.
> - */
> -static _INLINE_ void show_serial_version(void)
> -{
> - Â Â Â printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
> -}
> -
> -
> -/*
> - * The serial console driver used during boot. ÂNote that these names
> - * clash with those found in "serial.c", so we currently can't support
> - * the 16xxx uarts and these at the same time. ÂI will fix this to become
> - * an indirect function call from tty_io.c (or something).
> - */
> -
> -#ifdef CONFIG_SERIAL_CONSOLE
> -
> -/*
> - * Print a string to the serial port trying not to disturb any possible
> - * real use of the port...
> - */
> -static void my_console_write(int idx, const char *s,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned count)
> -{
> -    struct     Âserial_state  Â*ser;
> -    ser_info_t       Â*info;
> -    unsigned        Âi;
> - Â Â Â QUICC_BD Â Â Â Â Â Â Â Â*bdp, *bdbase;
> -    volatile struct smc_uart_pram  *up;
> -    volatile    Âu_char     Â*cp;
> -
> - Â Â Â ser = rs_table + idx;
> -
> -
> - Â Â Â /* If the port has been initialized for general use, we have
> - Â Â Â Â* to use the buffer descriptors allocated there. ÂOtherwise,
> - Â Â Â Â* we simply use the single buffer allocated.
> - Â Â Â Â*/
> - Â Â Â if ((info = (ser_info_t *)ser->info) != NULL) {
> - Â Â Â Â Â Â Â bdp = info->tx_cur;
> - Â Â Â Â Â Â Â bdbase = info->tx_bd_base;
> - Â Â Â }
> - Â Â Â else {
> - Â Â Â Â Â Â Â /* Pointer to UART in parameter ram.
> - Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â /* up = (smc_uart_t *)&cpmp->cp_dparam[ser->port]; */
> - Â Â Â Â Â Â Â up = &pquicc->pram[ser->port].scc.pothers.idma_smc.psmc.u;
> -
> - Â Â Â Â Â Â Â /* Get the address of the host memory buffer.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â bdp = bdbase = (QUICC_BD *)((uint)pquicc + (uint)up->tbase);
> - Â Â Â }
> -
> - Â Â Â /*
> - Â Â Â Â* We need to gracefully shut down the transmitter, disable
> - Â Â Â Â* interrupts, then send our bytes out.
> - Â Â Â Â*/
> -
> - Â Â Â /*
> - Â Â Â Â* Now, do each character. ÂThis is not as bad as it looks
> - Â Â Â Â* since this is a holding FIFO and not a transmitting FIFO.
> - Â Â Â Â* We could add the complexity of filling the entire transmit
> - Â Â Â Â* buffer, but we would just wait longer between accesses......
> - Â Â Â Â*/
> - Â Â Â for (i = 0; i < count; i++, s++) {
> - Â Â Â Â Â Â Â /* Wait for transmitter fifo to empty.
> - Â Â Â Â Â Â Â Â* Ready indicates output is ready, and xmt is doing
> - Â Â Â Â Â Â Â Â* that, not that it is ready for us to send.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â while (bdp->status & BD_SC_READY);
> -
> - Â Â Â Â Â Â Â /* Send the character out.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â cp = bdp->buf;
> - Â Â Â Â Â Â Â *cp = *s;
> -
> - Â Â Â Â Â Â Â bdp->length = 1;
> - Â Â Â Â Â Â Â bdp->status |= BD_SC_READY;
> -
> - Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP)
> - Â Â Â Â Â Â Â Â Â Â Â bdp = bdbase;
> - Â Â Â Â Â Â Â else
> - Â Â Â Â Â Â Â Â Â Â Â bdp++;
> -
> - Â Â Â Â Â Â Â /* if a LF, also do CR... */
> - Â Â Â Â Â Â Â if (*s == 10) {
> - Â Â Â Â Â Â Â Â Â Â Â while (bdp->status & BD_SC_READY);
> - Â Â Â Â Â Â Â Â Â Â Â /* cp = __va(bdp->buf); */
> - Â Â Â Â Â Â Â Â Â Â Â cp = bdp->buf;
> - Â Â Â Â Â Â Â Â Â Â Â *cp = 13;
> - Â Â Â Â Â Â Â Â Â Â Â bdp->length = 1;
> - Â Â Â Â Â Â Â Â Â Â Â bdp->status |= BD_SC_READY;
> -
> - Â Â Â Â Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp = bdbase;
> - Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â Â Â Â Â else {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp++;
> - Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â }
> - Â Â Â }
> -
> - Â Â Â /*
> - Â Â Â Â* Finally, Wait for transmitter & holding register to empty
> - Â Â Â Â* Âand restore the IER
> - Â Â Â Â*/
> - Â Â Â while (bdp->status & BD_SC_READY);
> -
> - Â Â Â if (info)
> - Â Â Â Â Â Â Â info->tx_cur = (QUICC_BD *)bdp;
> -}
> -
> -static void serial_console_write(struct console *c, const char *s,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â unsigned count)
> -{
> -#ifdef CONFIG_KGDB
> - Â Â Â /* Try to let stub handle output. Returns true if it did. */
> - Â Â Â if (kgdb_output_string(s, count))
> - Â Â Â Â Â Â Â return;
> -#endif
> - Â Â Â my_console_write(c->index, s, count);
> -}
> -
> -
> -
> -/*void console_print_68360(const char *p)
> -{
> - Â Â Â const char *cp = p;
> - Â Â Â int i;
> -
> - Â Â Â for (i=0;cp[i]!=0;i++);
> -
> - Â Â Â serial_console_write (p, i);
> -
> - Â Â Â //Comment this if you want to have a strict interrupt-driven output
> - Â Â Â //rs_fair_output();
> -
> - Â Â Â return;
> -}*/
> -
> -
> -
> -
> -
> -
> -#ifdef CONFIG_XMON
> -int
> -xmon_360_write(const char *s, unsigned count)
> -{
> - Â Â Â my_console_write(0, s, count);
> - Â Â Â return(count);
> -}
> -#endif
> -
> -#ifdef CONFIG_KGDB
> -void
> -putDebugChar(char ch)
> -{
> - Â Â Â my_console_write(0, &ch, 1);
> -}
> -#endif
> -
> -/*
> - * Receive character from the serial port. ÂThis only works well
> - * before the port is initialized for real use.
> - */
> -static int my_console_wait_key(int idx, int xmon, char *obuf)
> -{
> -    struct serial_state       *ser;
> -    u_char         Âc, *cp;
> -    ser_info_t       Â*info;
> - Â Â Â QUICC_BD Â Â Â Â Â Â Â Â*bdp;
> -    volatile struct smc_uart_pram  *up;
> -    int               i;
> -
> - Â Â Â ser = rs_table + idx;
> -
> - Â Â Â /* Get the address of the host memory buffer.
> - Â Â Â Â* If the port has been initialized for general use, we must
> - Â Â Â Â* use information from the port structure.
> - Â Â Â Â*/
> - Â Â Â if ((info = (ser_info_t *)ser->info))
> - Â Â Â Â Â Â Â bdp = info->rx_cur;
> - Â Â Â else
> - Â Â Â Â Â Â Â /* bdp = (QUICC_BD *)&cpmp->cp_dpmem[up->smc_rbase]; */
> - Â Â Â Â Â Â Â bdp = (QUICC_BD *)((uint)pquicc + (uint)up->tbase);
> -
> - Â Â Â /* Pointer to UART in parameter ram.
> - Â Â Â Â*/
> - Â Â Â /* up = (smc_uart_t *)&cpmp->cp_dparam[ser->port]; */
> - Â Â Â up = &pquicc->pram[info->state->port].scc.pothers.idma_smc.psmc.u;
> -
> - Â Â Â /*
> - Â Â Â Â* We need to gracefully shut down the receiver, disable
> - Â Â Â Â* interrupts, then read the input.
> - Â Â Â Â* XMON just wants a poll. ÂIf no character, return -1, else
> - Â Â Â Â* return the character.
> - Â Â Â Â*/
> - Â Â Â if (!xmon) {
> - Â Â Â Â Â Â Â while (bdp->status & BD_SC_EMPTY);
> - Â Â Â }
> - Â Â Â else {
> - Â Â Â Â Â Â Â if (bdp->status & BD_SC_EMPTY)
> - Â Â Â Â Â Â Â Â Â Â Â return -1;
> - Â Â Â }
> -
> - Â Â Â cp = (char *)bdp->buf;
> -
> - Â Â Â if (obuf) {
> - Â Â Â Â Â Â Â i = c = bdp->length;
> - Â Â Â Â Â Â Â while (i-- > 0)
> - Â Â Â Â Â Â Â Â Â Â Â *obuf++ = *cp++;
> - Â Â Â }
> - Â Â Â else {
> - Â Â Â Â Â Â Â c = *cp;
> - Â Â Â }
> - Â Â Â bdp->status |= BD_SC_EMPTY;
> -
> - Â Â Â if (info) {
> - Â Â Â Â Â Â Â if (bdp->status & BD_SC_WRAP) {
> - Â Â Â Â Â Â Â Â Â Â Â bdp = info->rx_bd_base;
> - Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â else {
> - Â Â Â Â Â Â Â Â Â Â Â bdp++;
> - Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â info->rx_cur = (QUICC_BD *)bdp;
> - Â Â Â }
> -
> - Â Â Â return((int)c);
> -}
> -
> -static int serial_console_wait_key(struct console *co)
> -{
> - Â Â Â return(my_console_wait_key(co->index, 0, NULL));
> -}
> -
> -#ifdef CONFIG_XMON
> -int
> -xmon_360_read_poll(void)
> -{
> - Â Â Â return(my_console_wait_key(0, 1, NULL));
> -}
> -
> -int
> -xmon_360_read_char(void)
> -{
> - Â Â Â return(my_console_wait_key(0, 0, NULL));
> -}
> -#endif
> -
> -#ifdef CONFIG_KGDB
> -static char kgdb_buf[RX_BUF_SIZE], *kgdp;
> -static int kgdb_chars;
> -
> -unsigned char
> -getDebugChar(void)
> -{
> - Â Â Â if (kgdb_chars <= 0) {
> - Â Â Â Â Â Â Â kgdb_chars = my_console_wait_key(0, 0, kgdb_buf);
> - Â Â Â Â Â Â Â kgdp = kgdb_buf;
> - Â Â Â }
> - Â Â Â kgdb_chars--;
> -
> - Â Â Â return(*kgdp++);
> -}
> -
> -void kgdb_interruptible(int state)
> -{
> -}
> -void kgdb_map_scc(void)
> -{
> -    struct     Âserial_state *ser;
> -    uint      Âmem_addr;
> -    volatile    ÂQUICC_BD        Â*bdp;
> -    volatile    Âsmc_uart_t   Â*up;
> -
> - Â Â Â cpmp = (cpm360_t *)&(((immap_t *)IMAP_ADDR)->im_cpm);
> -
> - Â Â Â /* To avoid data cache CPM DMA coherency problems, allocate a
> - Â Â Â Â* buffer in the CPM DPRAM. ÂThis will work until the CPM and
> - Â Â Â Â* serial ports are initialized. ÂAt that time a memory buffer
> - Â Â Â Â* will be allocated.
> - Â Â Â Â* The port is already initialized from the boot procedure, all
> - Â Â Â Â* we do here is give it a different buffer and make it a FIFO.
> - Â Â Â Â*/
> -
> - Â Â Â ser = rs_table;
> -
> - Â Â Â /* Right now, assume we are using SMCs.
> - Â Â Â */
> - Â Â Â up = (smc_uart_t *)&cpmp->cp_dparam[ser->port];
> -
> - Â Â Â /* Allocate space for an input FIFO, plus a few bytes for output.
> - Â Â Â Â* Allocate bytes to maintain word alignment.
> - Â Â Â Â*/
> - Â Â Â mem_addr = (uint)(&cpmp->cp_dpmem[0x1000]);
> -
> - Â Â Â /* Set the physical address of the host memory buffers in
> - Â Â Â Â* the buffer descriptors.
> - Â Â Â Â*/
> - Â Â Â bdp = (QUICC_BD *)&cpmp->cp_dpmem[up->smc_rbase];
> - Â Â Â bdp->buf = mem_addr;
> -
> - Â Â Â bdp = (QUICC_BD *)&cpmp->cp_dpmem[up->smc_tbase];
> - Â Â Â bdp->buf = mem_addr+RX_BUF_SIZE;
> -
> - Â Â Â up->smc_mrblr = RX_BUF_SIZE; Â Â Â Â Â Â/* receive buffer length */
> - Â Â Â up->smc_maxidl = RX_BUF_SIZE;
> -}
> -#endif
> -
> -static struct tty_struct *serial_console_device(struct console *c, int *index)
> -{
> - Â Â Â *index = c->index;
> - Â Â Â return serial_driver;
> -}
> -
> -
> -struct console sercons = {
> -    .name      = "ttyS",
> -    .write     Â= serial_console_write,
> -    .device     = serial_console_device,
> -    .wait_key    = serial_console_wait_key,
> -    .setup     Â= serial_console_setup,
> -    .flags     Â= CON_PRINTBUFFER,
> -    .index     Â= CONFIG_SERIAL_CONSOLE_PORT,
> -};
> -
> -
> -
> -/*
> - * Â Â Register console.
> - */
> -long console_360_init(long kmem_start, long kmem_end)
> -{
> - Â Â Â register_console(&sercons);
> - Â Â Â /*register_console (console_print_68360); - 2.0.38 only required a write
> - Â Â Âfunction pointer. */
> - Â Â Â return kmem_start;
> -}
> -
> -#endif
> -
> -/* Index in baud rate table of the default console baud rate.
> -*/
> -static int   baud_idx;
> -
> -static const struct tty_operations rs_360_ops = {
> - Â Â Â .owner = THIS_MODULE,
> - Â Â Â .open = rs_360_open,
> - Â Â Â .close = rs_360_close,
> - Â Â Â .write = rs_360_write,
> - Â Â Â .put_char = rs_360_put_char,
> - Â Â Â .write_room = rs_360_write_room,
> - Â Â Â .chars_in_buffer = rs_360_chars_in_buffer,
> - Â Â Â .flush_buffer = rs_360_flush_buffer,
> - Â Â Â .ioctl = rs_360_ioctl,
> - Â Â Â .throttle = rs_360_throttle,
> - Â Â Â .unthrottle = rs_360_unthrottle,
> - Â Â Â /* .send_xchar = rs_360_send_xchar, */
> - Â Â Â .set_termios = rs_360_set_termios,
> - Â Â Â .stop = rs_360_stop,
> - Â Â Â .start = rs_360_start,
> - Â Â Â .hangup = rs_360_hangup,
> - Â Â Â /* .wait_until_sent = rs_360_wait_until_sent, */
> - Â Â Â /* .read_proc = rs_360_read_proc, */
> - Â Â Â .tiocmget = rs_360_tiocmget,
> - Â Â Â .tiocmset = rs_360_tiocmset,
> - Â Â Â .get_icount = rs_360_get_icount,
> -};
> -
> -static int __init rs_360_init(void)
> -{
> - Â Â Â struct serial_state * state;
> -    ser_info_t   Â*info;
> -    void    *mem_addr;
> -    uint      Âdp_addr, iobits;
> -    int         i, j, idx;
> -    ushort     Âchan;
> - Â Â Â QUICC_BD Â Â Â Â*bdp;
> -    volatile    ÂQUICC      *cp;
> -    volatile    Âstruct smc_regs *sp;
> -    volatile    Âstruct smc_uart_pram  Â*up;
> -    volatile    Âstruct scc_regs *scp;
> -    volatile    Âstruct uart_pram    Â*sup;
> -    /* volatile   immap_t     *immap; */
> -
> - Â Â Â serial_driver = alloc_tty_driver(NR_PORTS);
> - Â Â Â if (!serial_driver)
> - Â Â Â Â Â Â Â return -1;
> -
> - Â Â Â show_serial_version();
> -
> - Â Â Â serial_driver->name = "ttyS";
> - Â Â Â serial_driver->major = TTY_MAJOR;
> - Â Â Â serial_driver->minor_start = 64;
> - Â Â Â serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
> - Â Â Â serial_driver->subtype = SERIAL_TYPE_NORMAL;
> - Â Â Â serial_driver->init_termios = tty_std_termios;
> - Â Â Â serial_driver->init_termios.c_cflag =
> - Â Â Â Â Â Â Â baud_idx | CS8 | CREAD | HUPCL | CLOCAL;
> - Â Â Â serial_driver->flags = TTY_DRIVER_REAL_RAW;
> - Â Â Â tty_set_operations(serial_driver, &rs_360_ops);
> -
> - Â Â Â if (tty_register_driver(serial_driver))
> - Â Â Â Â Â Â Â panic("Couldn't register serial driver\n");
> -
> - Â Â Â cp = pquicc; Â Â/* Get pointer to Communication Processor */
> - Â Â Â /* immap = (immap_t *)IMAP_ADDR; */ Â Â /* and to internal registers */
> -
> -
> - Â Â Â /* Configure SCC2, SCC3, and SCC4 instead of port A parallel I/O.
> - Â Â Â Â*/
> - Â Â Â /* The "standard" configuration through the 860.
> - Â Â Â */
> -/* Â Â immap->im_ioport.iop_papar |= 0x00fc; */
> -/* Â Â immap->im_ioport.iop_padir &= ~0x00fc; */
> -/* Â Â immap->im_ioport.iop_paodr &= ~0x00fc; */
> - Â Â Â cp->pio_papar |= 0x00fc;
> - Â Â Â cp->pio_padir &= ~0x00fc;
> - Â Â Â /* cp->pio_paodr &= ~0x00fc; */
> -
> -
> - Â Â Â /* Since we don't yet do modem control, connect the port C pins
> - Â Â Â Â* as general purpose I/O. ÂThis will assert CTS and CD for the
> - Â Â Â Â* SCC ports.
> - Â Â Â Â*/
> - Â Â Â /* FIXME: see 360um p.7-365 and 860um p.34-12
> - Â Â Â Â* I can't make sense of these bits - mleslie*/
> -/* Â Â immap->im_ioport.iop_pcdir |= 0x03c6; */
> -/* Â Â immap->im_ioport.iop_pcpar &= ~0x03c6; */
> -
> -/* Â Â cp->pio_pcdir |= 0x03c6; */
> -/* Â Â cp->pio_pcpar &= ~0x03c6; */
> -
> -
> -
> - Â Â Â /* Connect SCC2 and SCC3 to NMSI. ÂConnect BRG3 to SCC2 and
> - Â Â Â Â* BRG4 to SCC3.
> - Â Â Â Â*/
> - Â Â Â cp->si_sicr &= ~0x00ffff00;
> - Â Â Â cp->si_sicr |= Â0x001b1200;
> -
> -#ifdef CONFIG_PP04
> - Â Â Â /* Frequentis PP04 forced to RS-232 until we know better.
> - Â Â Â Â* Port C 12 and 13 low enables RS-232 on SCC3 and SCC4.
> - Â Â Â Â*/
> - Â Â Â immap->im_ioport.iop_pcdir |= 0x000c;
> - Â Â Â immap->im_ioport.iop_pcpar &= ~0x000c;
> - Â Â Â immap->im_ioport.iop_pcdat &= ~0x000c;
> -
> - Â Â Â /* This enables the TX driver.
> - Â Â Â */
> - Â Â Â cp->cp_pbpar &= ~0x6000;
> - Â Â Â cp->cp_pbdat &= ~0x6000;
> -#endif
> -
> - Â Â Â for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
> - Â Â Â Â Â Â Â state->magic = SSTATE_MAGIC;
> - Â Â Â Â Â Â Â state->line = i;
> - Â Â Â Â Â Â Â state->type = PORT_UNKNOWN;
> - Â Â Â Â Â Â Â state->custom_divisor = 0;
> - Â Â Â Â Â Â Â state->close_delay = 5*HZ/10;
> - Â Â Â Â Â Â Â state->closing_wait = 30*HZ;
> - Â Â Â Â Â Â Â state->icount.cts = state->icount.dsr =
> - Â Â Â Â Â Â Â Â Â Â Â state->icount.rng = state->icount.dcd = 0;
> - Â Â Â Â Â Â Â state->icount.rx = state->icount.tx = 0;
> - Â Â Â Â Â Â Â state->icount.frame = state->icount.parity = 0;
> - Â Â Â Â Â Â Â state->icount.overrun = state->icount.brk = 0;
> - Â Â Â Â Â Â Â printk(KERN_INFO "ttyS%d at irq 0x%02x is an %s\n",
> - Â Â Â Â Â Â Â Â Â Â Âi, (unsigned int)(state->irq),
> - Â Â Â Â Â Â Â Â Â Â Â(state->smc_scc_num & NUM_IS_SCC) ? "SCC" : "SMC");
> -
> -#ifdef CONFIG_SERIAL_CONSOLE
> - Â Â Â Â Â Â Â /* If we just printed the message on the console port, and
> - Â Â Â Â Â Â Â Â* we are about to initialize it for general use, we have
> - Â Â Â Â Â Â Â Â* to wait a couple of character times for the CR/NL to
> - Â Â Â Â Â Â Â Â* make it out of the transmit buffer.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â if (i == CONFIG_SERIAL_CONSOLE_PORT)
> - Â Â Â Â Â Â Â Â Â Â Â mdelay(8);
> -
> -
> -/* Â Â Â Â Â Â idx = PORT_NUM(info->state->smc_scc_num); */
> -/* Â Â Â Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) */
> -/* Â Â Â Â Â Â Â Â Â Â chan = scc_chan_map[idx]; */
> -/* Â Â Â Â Â Â else */
> -/* Â Â Â Â Â Â Â Â Â Â chan = smc_chan_map[idx]; */
> -
> -/* Â Â Â Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_STOP_TX) | CPM_CR_FLG; */
> -/* Â Â Â Â Â Â while (cp->cp_cr & CPM_CR_FLG); */
> -
> -#endif
> - Â Â Â Â Â Â Â /* info = kmalloc(sizeof(ser_info_t), GFP_KERNEL); */
> - Â Â Â Â Â Â Â info = &quicc_ser_info[i];
> - Â Â Â Â Â Â Â if (info) {
> - Â Â Â Â Â Â Â Â Â Â Â memset (info, 0, sizeof(ser_info_t));
> - Â Â Â Â Â Â Â Â Â Â Â info->magic = SERIAL_MAGIC;
> - Â Â Â Â Â Â Â Â Â Â Â info->line = i;
> - Â Â Â Â Â Â Â Â Â Â Â info->flags = state->flags;
> - Â Â Â Â Â Â Â Â Â Â Â INIT_WORK(&info->tqueue, do_softint, info);
> - Â Â Â Â Â Â Â Â Â Â Â INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info);
> - Â Â Â Â Â Â Â Â Â Â Â init_waitqueue_head(&info->open_wait);
> - Â Â Â Â Â Â Â Â Â Â Â init_waitqueue_head(&info->close_wait);
> - Â Â Â Â Â Â Â Â Â Â Â info->state = state;
> - Â Â Â Â Â Â Â Â Â Â Â state->info = (struct async_struct *)info;
> -
> - Â Â Â Â Â Â Â Â Â Â Â /* We need to allocate a transmit and receive buffer
> - Â Â Â Â Â Â Â Â Â Â Â Â* descriptors from dual port ram, and a character
> - Â Â Â Â Â Â Â Â Â Â Â Â* buffer area from host mem.
> - Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â dp_addr = m360_cpm_dpalloc(sizeof(QUICC_BD) * RX_NUM_FIFO);
> -
> - Â Â Â Â Â Â Â Â Â Â Â /* Allocate space for FIFOs in the host memory.
> - Â Â Â Â Â Â Â Â Â Â Â Â* Â(for now this is from a static array of buffers :(
> - Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â /* mem_addr = m360_cpm_hostalloc(RX_NUM_FIFO * RX_BUF_SIZE); */
> - Â Â Â Â Â Â Â Â Â Â Â /* mem_addr = kmalloc (RX_NUM_FIFO * RX_BUF_SIZE, GFP_BUFFER); */
> - Â Â Â Â Â Â Â Â Â Â Â mem_addr = &rx_buf_pool[i * RX_NUM_FIFO * RX_BUF_SIZE];
> -
> - Â Â Â Â Â Â Â Â Â Â Â /* Set the physical address of the host memory
> - Â Â Â Â Â Â Â Â Â Â Â Â* buffers in the buffer descriptors, and the
> - Â Â Â Â Â Â Â Â Â Â Â Â* virtual address for us to work with.
> - Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â bdp = (QUICC_BD *)((uint)pquicc + dp_addr);
> - Â Â Â Â Â Â Â Â Â Â Â info->rx_cur = info->rx_bd_base = bdp;
> -
> - Â Â Â Â Â Â Â Â Â Â Â /* initialize rx buffer descriptors */
> - Â Â Â Â Â Â Â Â Â Â Â for (j=0; j<(RX_NUM_FIFO-1); j++) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp->buf = &rx_buf_pool[(i * RX_NUM_FIFO + j ) * RX_BUF_SIZE];
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp->status = BD_SC_EMPTY | BD_SC_INTRPT;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â mem_addr += RX_BUF_SIZE;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp++;
> - Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â Â Â Â Â bdp->buf = &rx_buf_pool[(i * RX_NUM_FIFO + j ) * RX_BUF_SIZE];
> - Â Â Â Â Â Â Â Â Â Â Â bdp->status = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT;
> -
> -
> - Â Â Â Â Â Â Â Â Â Â Â idx = PORT_NUM(info->state->smc_scc_num);
> - Â Â Â Â Â Â Â Â Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> -
> -#if defined (CONFIG_UCQUICC) && 1
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* set the transceiver mode to RS232 */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sipex_mode_bits &= ~(uint)SIPEX_MODE(idx,0x0f); /* clear current mode */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sipex_mode_bits |= (uint)SIPEX_MODE(idx,0x02);
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â *(uint *)_periph_base = sipex_mode_bits;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* printk ("sipex bits = 0x%08x\n", sipex_mode_bits); */
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â }
> -
> - Â Â Â Â Â Â Â Â Â Â Â dp_addr = m360_cpm_dpalloc(sizeof(QUICC_BD) * TX_NUM_FIFO);
> -
> - Â Â Â Â Â Â Â Â Â Â Â /* Allocate space for FIFOs in the host memory.
> - Â Â Â Â Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â Â Â Â Â /* mem_addr = m360_cpm_hostalloc(TX_NUM_FIFO * TX_BUF_SIZE); */
> - Â Â Â Â Â Â Â Â Â Â Â /* mem_addr = kmalloc (TX_NUM_FIFO * TX_BUF_SIZE, GFP_BUFFER); */
> - Â Â Â Â Â Â Â Â Â Â Â mem_addr = &tx_buf_pool[i * TX_NUM_FIFO * TX_BUF_SIZE];
> -
> - Â Â Â Â Â Â Â Â Â Â Â /* Set the physical address of the host memory
> - Â Â Â Â Â Â Â Â Â Â Â Â* buffers in the buffer descriptors, and the
> - Â Â Â Â Â Â Â Â Â Â Â Â* virtual address for us to work with.
> - Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â /* bdp = (QUICC_BD *)&cp->cp_dpmem[dp_addr]; */
> - Â Â Â Â Â Â Â Â Â Â Â bdp = (QUICC_BD *)((uint)pquicc + dp_addr);
> - Â Â Â Â Â Â Â Â Â Â Â info->tx_cur = info->tx_bd_base = (QUICC_BD *)bdp;
> -
> - Â Â Â Â Â Â Â Â Â Â Â /* initialize tx buffer descriptors */
> - Â Â Â Â Â Â Â Â Â Â Â for (j=0; j<(TX_NUM_FIFO-1); j++) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp->buf = &tx_buf_pool[(i * TX_NUM_FIFO + j ) * TX_BUF_SIZE];
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp->status = BD_SC_INTRPT;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â mem_addr += TX_BUF_SIZE;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bdp++;
> - Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â Â Â Â Â bdp->buf = &tx_buf_pool[(i * TX_NUM_FIFO + j ) * TX_BUF_SIZE];
> - Â Â Â Â Â Â Â Â Â Â Â bdp->status = (BD_SC_WRAP | BD_SC_INTRPT);
> -
> - Â Â Â Â Â Â Â Â Â Â Â if (info->state->smc_scc_num & NUM_IS_SCC) {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp = &pquicc->scc_regs[idx];
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup = &pquicc->pram[info->state->port].scc.pscc.u;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->rbase = dp_addr;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->tbase = dp_addr;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set up the uart parameters in the
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* parameter ram.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->rfcr = SMC_EB;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->tfcr = SMC_EB;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set this to 1 for now, so we get single
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* character interrupts. ÂUsing idle character
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* time requires some additional tuning.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->mrblr = 1;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->max_idl = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->brkcr = 1;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->parec = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->frmer = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->nosec = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->brkec = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->uaddr1 = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->uaddr2 = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->toseq = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â int i;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â for (i=0;i<8;i++)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->cc[i] = 0x8000;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->rccm = 0xc0ff;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Send the CPM an initialize command.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â chan = scc_chan_map[idx];
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* execute the INIT RX & TX PARAMS command for this channel. */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set UART mode, 8 bit, no parity, one stop.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* Enable receive and transmit.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_gsmr.w.high = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_gsmr.w.low =
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Disable all interrupts and clear all pending
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* events.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_sccm = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_scce = 0xffff;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_dsr = 0x7e7e;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_psmr = 0x3000;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* If the port is the console, enable Rx and Tx.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */
> -#ifdef CONFIG_SERIAL_CONSOLE
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (i == CONFIG_SERIAL_CONSOLE_PORT)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â scp->scc_gsmr.w.low |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â Â Â Â Â else {
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Configure SMCs Tx/Rx instead of port B
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* parallel I/O.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up = &pquicc->pram[info->state->port].scc.pothers.idma_smc.psmc.u;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->rbase = dp_addr;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â iobits = 0xc0 << (idx * 4);
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->pip_pbpar |= iobits;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->pip_pbdir &= ~iobits;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->pip_pbodr &= ~iobits;
> -
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Connect the baud rate generator to the
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* SMC based upon index in rs_table. ÂAlso
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* make sure it is connected to NMSI.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->si_simode &= ~(0xffff << (idx * 16));
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->si_simode |= (i << ((idx * 16) + 12));
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->tbase = dp_addr;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set up the uart parameters in the
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* parameter ram.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->rfcr = SMC_EB;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->tfcr = SMC_EB;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set this to 1 for now, so we get single
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* character interrupts. ÂUsing idle character
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* time requires some additional tuning.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->mrblr = 1;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->max_idl = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â up->brkcr = 1;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Send the CPM an initialize command.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â chan = smc_chan_map[idx];
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â cp->cp_cr = mk_cr_cmd(chan,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â CPM_CR_INIT_TRX) | CPM_CR_FLG;
> -#ifdef CONFIG_SERIAL_CONSOLE
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (i == CONFIG_SERIAL_CONSOLE_PORT)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â printk("");
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Set UART mode, 8 bit, no parity, one stop.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* Enable receive and transmit.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sp = &cp->smc_regs[idx];
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sp->smc_smcmr = smcr_mk_clen(9) | SMCMR_SM_UART;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* Disable all interrupts and clear all pending
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* events.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sp->smc_smcm = 0;
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sp->smc_smce = 0xff;
> -
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /* If the port is the console, enable Rx and Tx.
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â */
> -#ifdef CONFIG_SERIAL_CONSOLE
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â if (i == CONFIG_SERIAL_CONSOLE_PORT)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
> -#endif
> - Â Â Â Â Â Â Â Â Â Â Â }
> -
> - Â Â Â Â Â Â Â Â Â Â Â /* Install interrupt handler.
> - Â Â Â Â Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â Â Â Â Â /* cpm_install_handler(IRQ_MACHSPEC | state->irq, rs_360_interrupt, info); Â*/
> - Â Â Â Â Â Â Â Â Â Â Â /*request_irq(IRQ_MACHSPEC | state->irq, rs_360_interrupt, */
> - Â Â Â Â Â Â Â Â Â Â Â request_irq(state->irq, rs_360_interrupt,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â IRQ_FLG_LOCK, "ttyS", (void *)info);
> -
> - Â Â Â Â Â Â Â Â Â Â Â /* Set up the baud rate generator.
> - Â Â Â Â Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â Â Â Â Â m360_cpm_setbrg(i, baud_table[baud_idx]);
> -
> - Â Â Â Â Â Â Â }
> - Â Â Â }
> -
> - Â Â Â return 0;
> -}
> -module_init(rs_360_init);
> -
> -/* This must always be called before the rs_360_init() function, otherwise
> - * it blows away the port control information.
> - */
> -//static int __init serial_console_setup( struct console *co, char *options)
> -int serial_console_setup( struct console *co, char *options)
> -{
> -    struct     Âserial_state  Â*ser;
> -    uint      Âmem_addr, dp_addr, bidx, idx, iobits;
> -    ushort     Âchan;
> - Â Â Â QUICC_BD Â Â Â Â*bdp;
> -    volatile    ÂQUICC          *cp;
> -    volatile    Âstruct smc_regs *sp;
> -    volatile    Âstruct scc_regs *scp;
> -    volatile    Âstruct smc_uart_pram  Â*up;
> -    volatile    Âstruct uart_pram        Â*sup;
> -
> -/* mleslie TODO:
> - * add something to the 68k bootloader to store a desired initial console baud rate */
> -
> -/*   bd_t                      Â*bd; */ /* a board info struct used by EPPC-bug */
> -/* Â Â bd = (bd_t *)__res; */
> -
> - Â Â Â for (bidx = 0; bidx < (sizeof(baud_table) / sizeof(int)); bidx++)
> - Â Â Â Â/* if (bd->bi_baudrate == baud_table[bidx]) */
> - Â Â Â Â Â Â Â if (CONSOLE_BAUDRATE == baud_table[bidx])
> - Â Â Â Â Â Â Â Â Â Â Â break;
> -
> - Â Â Â /* co->cflag = CREAD|CLOCAL|bidx|CS8; */
> - Â Â Â baud_idx = bidx;
> -
> - Â Â Â ser = rs_table + CONFIG_SERIAL_CONSOLE_PORT;
> -
> - Â Â Â cp = pquicc; Â Â/* Get pointer to Communication Processor */
> -
> - Â Â Â idx = PORT_NUM(ser->smc_scc_num);
> - Â Â Â if (ser->smc_scc_num & NUM_IS_SCC) {
> -
> - Â Â Â Â Â Â Â /* TODO: need to set up SCC pin assignment etc. here */
> -
> - Â Â Â }
> - Â Â Â else {
> - Â Â Â Â Â Â Â iobits = 0xc0 << (idx * 4);
> - Â Â Â Â Â Â Â cp->pip_pbpar |= iobits;
> - Â Â Â Â Â Â Â cp->pip_pbdir &= ~iobits;
> - Â Â Â Â Â Â Â cp->pip_pbodr &= ~iobits;
> -
> - Â Â Â Â Â Â Â /* Connect the baud rate generator to the
> - Â Â Â Â Â Â Â Â* SMC based upon index in rs_table. ÂAlso
> - Â Â Â Â Â Â Â Â* make sure it is connected to NMSI.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â cp->si_simode &= ~(0xffff << (idx * 16));
> - Â Â Â Â Â Â Â cp->si_simode |= (idx << ((idx * 16) + 12));
> - Â Â Â }
> -
> - Â Â Â /* When we get here, the CPM has been reset, so we need
> - Â Â Â Â* to configure the port.
> - Â Â Â Â* We need to allocate a transmit and receive buffer descriptor
> - Â Â Â Â* from dual port ram, and a character buffer area from host mem.
> - Â Â Â Â*/
> -
> - Â Â Â /* Allocate space for two buffer descriptors in the DP ram.
> - Â Â Â */
> - Â Â Â dp_addr = m360_cpm_dpalloc(sizeof(QUICC_BD) * CONSOLE_NUM_FIFO);
> -
> - Â Â Â /* Allocate space for two 2 byte FIFOs in the host memory.
> - Â Â Â Â*/
> - Â Â Â /* mem_addr = m360_cpm_hostalloc(8); */
> - Â Â Â mem_addr = (uint)console_fifos;
> -
> -
> - Â Â Â /* Set the physical address of the host memory buffers in
> - Â Â Â Â* the buffer descriptors.
> - Â Â Â Â*/
> - Â Â Â /* bdp = (QUICC_BD *)&cp->cp_dpmem[dp_addr]; */
> - Â Â Â bdp = (QUICC_BD *)((uint)pquicc + dp_addr);
> - Â Â Â bdp->buf = (char *)mem_addr;
> - Â Â Â (bdp+1)->buf = (char *)(mem_addr+4);
> -
> - Â Â Â /* For the receive, set empty and wrap.
> - Â Â Â Â* For transmit, set wrap.
> - Â Â Â Â*/
> - Â Â Â bdp->status = BD_SC_EMPTY | BD_SC_WRAP;
> - Â Â Â (bdp+1)->status = BD_SC_WRAP;
> -
> - Â Â Â /* Set up the uart parameters in the parameter ram.
> - Â Â Â Â*/
> - Â Â Â if (ser->smc_scc_num & NUM_IS_SCC) {
> - Â Â Â Â Â Â Â scp = &cp->scc_regs[idx];
> - Â Â Â Â Â Â Â /* sup = (scc_uart_t *)&cp->cp_dparam[ser->port]; */
> - Â Â Â Â Â Â Â sup = &pquicc->pram[ser->port].scc.pscc.u;
> -
> - Â Â Â Â Â Â Â sup->rbase = dp_addr;
> - Â Â Â Â Â Â Â sup->tbase = dp_addr + sizeof(QUICC_BD);
> -
> - Â Â Â Â Â Â Â /* Set up the uart parameters in the
> - Â Â Â Â Â Â Â Â* parameter ram.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â sup->rfcr = SMC_EB;
> - Â Â Â Â Â Â Â sup->tfcr = SMC_EB;
> -
> - Â Â Â Â Â Â Â /* Set this to 1 for now, so we get single
> - Â Â Â Â Â Â Â Â* character interrupts. ÂUsing idle character
> - Â Â Â Â Â Â Â Â* time requires some additional tuning.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â sup->mrblr = 1;
> - Â Â Â Â Â Â Â sup->max_idl = 0;
> - Â Â Â Â Â Â Â sup->brkcr = 1;
> - Â Â Â Â Â Â Â sup->parec = 0;
> - Â Â Â Â Â Â Â sup->frmer = 0;
> - Â Â Â Â Â Â Â sup->nosec = 0;
> - Â Â Â Â Â Â Â sup->brkec = 0;
> - Â Â Â Â Â Â Â sup->uaddr1 = 0;
> - Â Â Â Â Â Â Â sup->uaddr2 = 0;
> - Â Â Â Â Â Â Â sup->toseq = 0;
> - Â Â Â Â Â Â Â {
> - Â Â Â Â Â Â Â Â Â Â Â int i;
> - Â Â Â Â Â Â Â Â Â Â Â for (i=0;i<8;i++)
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sup->cc[i] = 0x8000;
> - Â Â Â Â Â Â Â }
> - Â Â Â Â Â Â Â sup->rccm = 0xc0ff;
> -
> - Â Â Â Â Â Â Â /* Send the CPM an initialize command.
> - Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â chan = scc_chan_map[idx];
> -
> - Â Â Â Â Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
> - Â Â Â Â Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> -
> - Â Â Â Â Â Â Â /* Set UART mode, 8 bit, no parity, one stop.
> - Â Â Â Â Â Â Â Â* Enable receive and transmit.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â scp->scc_gsmr.w.high = 0;
> - Â Â Â Â Â Â Â scp->scc_gsmr.w.low =
> - Â Â Â Â Â Â Â Â Â Â Â (SCC_GSMRL_MODE_UART | SCC_GSMRL_TDCR_16 | SCC_GSMRL_RDCR_16);
> -
> - Â Â Â Â Â Â Â /* Disable all interrupts and clear all pending
> - Â Â Â Â Â Â Â Â* events.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â scp->scc_sccm = 0;
> - Â Â Â Â Â Â Â scp->scc_scce = 0xffff;
> - Â Â Â Â Â Â Â scp->scc_dsr = 0x7e7e;
> - Â Â Â Â Â Â Â scp->scc_psmr = 0x3000;
> -
> - Â Â Â Â Â Â Â scp->scc_gsmr.w.low |= (SCC_GSMRL_ENR | SCC_GSMRL_ENT);
> -
> - Â Â Â }
> - Â Â Â else {
> - Â Â Â Â Â Â Â /* up = (smc_uart_t *)&cp->cp_dparam[ser->port]; */
> - Â Â Â Â Â Â Â up = &pquicc->pram[ser->port].scc.pothers.idma_smc.psmc.u;
> -
> - Â Â Â Â Â Â Â up->rbase = dp_addr; Â Â/* Base of receive buffer desc. */
> - Â Â Â Â Â Â Â up->tbase = dp_addr+sizeof(QUICC_BD); Â /* Base of xmt buffer desc. */
> - Â Â Â Â Â Â Â up->rfcr = SMC_EB;
> - Â Â Â Â Â Â Â up->tfcr = SMC_EB;
> -
> - Â Â Â Â Â Â Â /* Set this to 1 for now, so we get single character interrupts.
> - Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â up->mrblr = 1; Â Â Â Â Â/* receive buffer length */
> - Â Â Â Â Â Â Â up->max_idl = 0; Â Â Â Â Â Â Â Â/* wait forever for next char */
> -
> - Â Â Â Â Â Â Â /* Send the CPM an initialize command.
> - Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â chan = smc_chan_map[idx];
> - Â Â Â Â Â Â Â cp->cp_cr = mk_cr_cmd(chan, CPM_CR_INIT_TRX) | CPM_CR_FLG;
> - Â Â Â Â Â Â Â while (cp->cp_cr & CPM_CR_FLG);
> -
> - Â Â Â Â Â Â Â /* Set UART mode, 8 bit, no parity, one stop.
> - Â Â Â Â Â Â Â Â* Enable receive and transmit.
> - Â Â Â Â Â Â Â Â*/
> - Â Â Â Â Â Â Â sp = &cp->smc_regs[idx];
> - Â Â Â Â Â Â Â sp->smc_smcmr = smcr_mk_clen(9) | ÂSMCMR_SM_UART;
> -
> - Â Â Â Â Â Â Â /* And finally, enable Rx and Tx.
> - Â Â Â Â Â Â Â */
> - Â Â Â Â Â Â Â sp->smc_smcmr |= SMCMR_REN | SMCMR_TEN;
> - Â Â Â }
> -
> - Â Â Â /* Set up the baud rate generator.
> - Â Â Â */
> - Â Â Â /* m360_cpm_setbrg((ser - rs_table), bd->bi_baudrate); */
> - Â Â Â m360_cpm_setbrg((ser - rs_table), CONSOLE_BAUDRATE);
> -
> - Â Â Â return 0;
> -}
> -
> -/*
> - * Local variables:
> - * Âc-indent-level: 4
> - * Âc-basic-offset: 4
> - * Âtab-width: 4
> - * End:
> - */
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index 10babe2..4cbb5a5 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -1035,23 +1035,6 @@ config SERIAL_MCF_CONSOLE
> Â Â Â Âhelp
> Â Â Â Â ÂEnable a ColdFire internal serial port to be the system console.
>
> -config SERIAL_68360_SMC
> - Â Â Â bool "68360 SMC uart support"
> - Â Â Â depends on M68360
> - Â Â Â help
> - Â Â Â Â This driver supports the SMC serial ports of the Motorola 68360 CPU.
> -
> -config SERIAL_68360_SCC
> - Â Â Â bool "68360 SCC uart support"
> - Â Â Â depends on M68360
> - Â Â Â help
> - Â Â Â Â This driver supports the SCC serial ports of the Motorola 68360 CPU.
> -
> -config SERIAL_68360
> - Â Â Â bool
> - Â Â Â depends on SERIAL_68360_SMC || SERIAL_68360_SCC
> - Â Â Â default y
> -
> Âconfig SERIAL_PMACZILOG
> Â Â Â Âtristate "Mac or PowerMac z85c30 ESCC support"
> Â Â Â Âdepends on (M68K && MAC) || (PPC_OF && PPC_PMAC)
> diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
> index 7874813..3644de5 100644
> --- a/drivers/tty/serial/Makefile
> +++ b/drivers/tty/serial/Makefile
> @@ -49,7 +49,6 @@ obj-$(CONFIG_SERIAL_MAX3107_AAVA) += max3107-aava.o
> Âobj-$(CONFIG_SERIAL_IP22_ZILOG) += ip22zilog.o
> Âobj-$(CONFIG_SERIAL_MUX) += mux.o
> Âobj-$(CONFIG_SERIAL_68328) += 68328serial.o
> -obj-$(CONFIG_SERIAL_68360) += 68360serial.o
> Âobj-$(CONFIG_SERIAL_MCF) += mcf.o
> Âobj-$(CONFIG_SERIAL_PMACZILOG) += pmac_zilog.o
> Âobj-$(CONFIG_SERIAL_DZ) += dz.o
> --
> 1.7.6.1

Gr{oetje,eeting}s,

            Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
             Â Â -- Linus Torvalds
èº{.nÇ+‰·Ÿ®‰­†+%ŠËlzwm…ébëæìr¸›zX§»®w¥Š{ayºÊÚë,j­¢f£¢·hš‹àz¹®w¥¢¸ ¢·¦j:+v‰¨ŠwèjØm¶Ÿÿ¾«‘êçzZ+ƒùšŽŠÝj"ú!¶iO•æ¬z·švØ^¶m§ÿðà nÆàþY&—