2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
** mux.c:
|
|
|
|
** serial driver for the Mux console found in some PA-RISC servers.
|
|
|
|
**
|
|
|
|
** (c) Copyright 2002 Ryan Bradetich
|
|
|
|
** (c) Copyright 2002 Hewlett-Packard Company
|
|
|
|
**
|
|
|
|
** This program is free software; you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation; either version 2 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This Driver currently only supports the console (port 0) on the MUX.
|
|
|
|
** Additional work will be needed on this driver to enable the full
|
|
|
|
** functionality of the MUX.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/serial.h>
|
|
|
|
#include <linux/console.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/delay.h> /* for udelay */
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <asm/io.h>
|
2005-10-22 02:58:03 +00:00
|
|
|
#include <asm/irq.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/parisc-device.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_MAGIC_SYSRQ
|
|
|
|
#include <linux/sysrq.h>
|
|
|
|
#define SUPPORT_SYSRQ
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <linux/serial_core.h>
|
|
|
|
|
|
|
|
#define MUX_OFFSET 0x800
|
|
|
|
#define MUX_LINE_OFFSET 0x80
|
|
|
|
|
|
|
|
#define MUX_FIFO_SIZE 255
|
|
|
|
#define MUX_POLL_DELAY (30 * HZ / 1000)
|
|
|
|
|
|
|
|
#define IO_DATA_REG_OFFSET 0x3c
|
|
|
|
#define IO_DCOUNT_REG_OFFSET 0x40
|
|
|
|
|
|
|
|
#define MUX_EOFIFO(status) ((status & 0xF000) == 0xF000)
|
|
|
|
#define MUX_STATUS(status) ((status & 0xF000) == 0x8000)
|
|
|
|
#define MUX_BREAK(status) ((status & 0xF000) == 0x2000)
|
|
|
|
|
|
|
|
#define MUX_NR 256
|
2006-03-27 19:52:15 +00:00
|
|
|
static unsigned int port_cnt __read_mostly;
|
2005-04-16 22:20:36 +00:00
|
|
|
static struct uart_port mux_ports[MUX_NR];
|
|
|
|
|
|
|
|
static struct uart_driver mux_driver = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.driver_name = "ttyB",
|
|
|
|
.dev_name = "ttyB",
|
|
|
|
.major = MUX_MAJOR,
|
|
|
|
.minor = 0,
|
|
|
|
.nr = MUX_NR,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct timer_list mux_timer;
|
|
|
|
|
2005-11-17 21:36:52 +00:00
|
|
|
#define UART_PUT_CHAR(p, c) __raw_writel((c), (p)->membase + IO_DATA_REG_OFFSET)
|
|
|
|
#define UART_GET_FIFO_CNT(p) __raw_readl((p)->membase + IO_DCOUNT_REG_OFFSET)
|
2005-04-16 22:20:36 +00:00
|
|
|
#define GET_MUX_PORTS(iodc_data) ((((iodc_data)[4] & 0xf0) >> 4) * 8) + 8
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_tx_empty - Check if the transmitter fifo is empty.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* This function test if the transmitter fifo for the port
|
|
|
|
* described by 'port' is empty. If it is empty, this function
|
|
|
|
* should return TIOCSER_TEMT, otherwise return 0.
|
|
|
|
*/
|
|
|
|
static unsigned int mux_tx_empty(struct uart_port *port)
|
|
|
|
{
|
2005-11-17 21:36:52 +00:00
|
|
|
return UART_GET_FIFO_CNT(port) ? 0 : TIOCSER_TEMT;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_set_mctrl - Set the current state of the modem control inputs.
|
|
|
|
* @ports: Ptr to the uart_port.
|
|
|
|
* @mctrl: Modem control bits.
|
|
|
|
*
|
|
|
|
* The Serial MUX does not support CTS, DCD or DSR so this function
|
|
|
|
* is ignored.
|
|
|
|
*/
|
|
|
|
static void mux_set_mctrl(struct uart_port *port, unsigned int mctrl)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_get_mctrl - Returns the current state of modem control inputs.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* The Serial MUX does not support CTS, DCD or DSR so these lines are
|
|
|
|
* treated as permanently active.
|
|
|
|
*/
|
|
|
|
static unsigned int mux_get_mctrl(struct uart_port *port)
|
|
|
|
{
|
|
|
|
return TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_stop_tx - Stop transmitting characters.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* The Serial MUX does not support this function.
|
|
|
|
*/
|
2005-08-31 09:12:14 +00:00
|
|
|
static void mux_stop_tx(struct uart_port *port)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_start_tx - Start transmitting characters.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* The Serial Mux does not support this function.
|
|
|
|
*/
|
2005-08-31 09:12:14 +00:00
|
|
|
static void mux_start_tx(struct uart_port *port)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_stop_rx - Stop receiving characters.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* The Serial Mux does not support this function.
|
|
|
|
*/
|
|
|
|
static void mux_stop_rx(struct uart_port *port)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_enable_ms - Enable modum status interrupts.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* The Serial Mux does not support this function.
|
|
|
|
*/
|
|
|
|
static void mux_enable_ms(struct uart_port *port)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_break_ctl - Control the transmitssion of a break signal.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
* @break_state: Raise/Lower the break signal.
|
|
|
|
*
|
|
|
|
* The Serial Mux does not support this function.
|
|
|
|
*/
|
|
|
|
static void mux_break_ctl(struct uart_port *port, int break_state)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_write - Write chars to the mux fifo.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* This function writes all the data from the uart buffer to
|
|
|
|
* the mux fifo.
|
|
|
|
*/
|
|
|
|
static void mux_write(struct uart_port *port)
|
|
|
|
{
|
|
|
|
int count;
|
|
|
|
struct circ_buf *xmit = &port->info->xmit;
|
|
|
|
|
|
|
|
if(port->x_char) {
|
|
|
|
UART_PUT_CHAR(port, port->x_char);
|
|
|
|
port->icount.tx++;
|
|
|
|
port->x_char = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(uart_circ_empty(xmit) || uart_tx_stopped(port)) {
|
2005-08-31 09:12:14 +00:00
|
|
|
mux_stop_tx(port);
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
count = (port->fifosize) - UART_GET_FIFO_CNT(port);
|
|
|
|
do {
|
|
|
|
UART_PUT_CHAR(port, xmit->buf[xmit->tail]);
|
|
|
|
xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
|
|
|
|
port->icount.tx++;
|
|
|
|
if(uart_circ_empty(xmit))
|
|
|
|
break;
|
|
|
|
|
|
|
|
} while(--count > 0);
|
|
|
|
|
|
|
|
while(UART_GET_FIFO_CNT(port))
|
|
|
|
udelay(1);
|
|
|
|
|
|
|
|
if(uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
|
|
|
|
uart_write_wakeup(port);
|
|
|
|
|
|
|
|
if (uart_circ_empty(xmit))
|
2005-08-31 09:12:14 +00:00
|
|
|
mux_stop_tx(port);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_read - Read chars from the mux fifo.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* This reads all available data from the mux's fifo and pushes
|
|
|
|
* the data to the tty layer.
|
|
|
|
*/
|
|
|
|
static void mux_read(struct uart_port *port)
|
|
|
|
{
|
|
|
|
int data;
|
|
|
|
struct tty_struct *tty = port->info->tty;
|
|
|
|
__u32 start_count = port->icount.rx;
|
|
|
|
|
|
|
|
while(1) {
|
2005-11-17 21:36:52 +00:00
|
|
|
data = __raw_readl(port->membase + IO_DATA_REG_OFFSET);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (MUX_STATUS(data))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (MUX_EOFIFO(data))
|
|
|
|
break;
|
|
|
|
|
|
|
|
port->icount.rx++;
|
|
|
|
|
|
|
|
if (MUX_BREAK(data)) {
|
|
|
|
port->icount.brk++;
|
|
|
|
if(uart_handle_break(port))
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-10-07 02:47:23 +00:00
|
|
|
if (uart_handle_sysrq_char(port, data & 0xffu))
|
2005-04-16 22:20:36 +00:00
|
|
|
continue;
|
|
|
|
|
[PATCH] TTY layer buffering revamp
The API and code have been through various bits of initial review by
serial driver people but they definitely need to live somewhere for a
while so the unconverted drivers can get knocked into shape, existing
drivers that have been updated can be better tuned and bugs whacked out.
This replaces the tty flip buffers with kmalloc objects in rings. In the
normal situation for an IRQ driven serial port at typical speeds the
behaviour is pretty much the same, two buffers end up allocated and the
kernel cycles between them as before.
When there are delays or at high speed we now behave far better as the
buffer pool can grow a bit rather than lose characters. This also means
that we can operate at higher speeds reliably.
For drivers that receive characters in blocks (DMA based, USB and
especially virtualisation) the layer allows a lot of driver specific
code that works around the tty layer with private secondary queues to be
removed. The IBM folks need this sort of layer, the smart serial port
people do, the virtualisers do (because a virtualised tty typically
operates at infinite speed rather than emulating 9600 baud).
Finally many drivers had invalid and unsafe attempts to avoid buffer
overflows by directly invoking tty methods extracted out of the innards
of work queue structs. These are no longer needed and all go away. That
fixes various random hangs with serial ports on overflow.
The other change in here is to optimise the receive_room path that is
used by some callers. It turns out that only one ldisc uses receive room
except asa constant and it updates it far far less than the value is
read. We thus make it a variable not a function call.
I expect the code to contain bugs due to the size alone but I'll be
watching and squashing them and feeding out new patches as it goes.
Because the buffers now dynamically expand you should only run out of
buffering when the kernel runs out of memory for real. That means a lot of
the horrible hacks high performance drivers used to do just aren't needed any
more.
Description:
tty_insert_flip_char is an old API and continues to work as before, as does
tty_flip_buffer_push() [this is why many drivers dont need modification]. It
does now also return the number of chars inserted
There are also
tty_buffer_request_room(tty, len)
which asks for a buffer block of the length requested and returns the space
found. This improves efficiency with hardware that knows how much to
transfer.
and tty_insert_flip_string_flags(tty, str, flags, len)
to insert a string of characters and flags
For a smart interface the usual code is
len = tty_request_buffer_room(tty, amount_hardware_says);
tty_insert_flip_string(tty, buffer_from_card, len);
More description!
At the moment tty buffers are attached directly to the tty. This is causing a
lot of the problems related to tty layer locking, also problems at high speed
and also with bursty data (such as occurs in virtualised environments)
I'm working on ripping out the flip buffers and replacing them with a pool of
dynamically allocated buffers. This allows both for old style "byte I/O"
devices and also helps virtualisation and smart devices where large blocks of
data suddenely materialise and need storing.
So far so good. Lots of drivers reference tty->flip.*. Several of them also
call directly and unsafely into function pointers it provides. This will all
break. Most drivers can use tty_insert_flip_char which can be kept as an API
but others need more.
At the moment I've added the following interfaces, if people think more will
be needed now is a good time to say
int tty_buffer_request_room(tty, size)
Try and ensure at least size bytes are available, returns actual room (may be
zero). At the moment it just uses the flipbuf space but that will change.
Repeated calls without characters being added are not cumulative. (ie if you
call it with 1, 1, 1, and then 4 you'll have four characters of space. The
other functions will also try and grow buffers in future but this will be a
more efficient way when you know block sizes.
int tty_insert_flip_char(tty, ch, flag)
As before insert a character if there is room. Now returns 1 for success, 0
for failure.
int tty_insert_flip_string(tty, str, len)
Insert a block of non error characters. Returns the number inserted.
int tty_prepare_flip_string(tty, strptr, len)
Adjust the buffer to allow len characters to be added. Returns a buffer
pointer in strptr and the length available. This allows for hardware that
needs to use functions like insl or mencpy_fromio.
Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Paul Fulghum <paulkf@microgate.com>
Signed-off-by: Hirokazu Takata <takata@linux-m32r.org>
Signed-off-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: John Hawkes <hawkes@sgi.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-10 04:54:13 +00:00
|
|
|
tty_insert_flip_char(tty, data & 0xFF, TTY_NORMAL);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (start_count != port->icount.rx) {
|
|
|
|
tty_flip_buffer_push(tty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_startup - Initialize the port.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* Grab any resources needed for this port and start the
|
|
|
|
* mux timer.
|
|
|
|
*/
|
|
|
|
static int mux_startup(struct uart_port *port)
|
|
|
|
{
|
|
|
|
mod_timer(&mux_timer, jiffies + MUX_POLL_DELAY);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_shutdown - Disable the port.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* Release any resources needed for the port.
|
|
|
|
*/
|
|
|
|
static void mux_shutdown(struct uart_port *port)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_set_termios - Chane port parameters.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
* @termios: new termios settings.
|
|
|
|
* @old: old termios settings.
|
|
|
|
*
|
|
|
|
* The Serial Mux does not support this function.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
mux_set_termios(struct uart_port *port, struct termios *termios,
|
|
|
|
struct termios *old)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_type - Describe the port.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* Return a pointer to a string constant describing the
|
|
|
|
* specified port.
|
|
|
|
*/
|
|
|
|
static const char *mux_type(struct uart_port *port)
|
|
|
|
{
|
|
|
|
return "Mux";
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_release_port - Release memory and IO regions.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* Release any memory and IO region resources currently in use by
|
|
|
|
* the port.
|
|
|
|
*/
|
|
|
|
static void mux_release_port(struct uart_port *port)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_request_port - Request memory and IO regions.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
*
|
|
|
|
* Request any memory and IO region resources required by the port.
|
|
|
|
* If any fail, no resources should be registered when this function
|
|
|
|
* returns, and it should return -EBUSY on failure.
|
|
|
|
*/
|
|
|
|
static int mux_request_port(struct uart_port *port)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_config_port - Perform port autoconfiguration.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
* @type: Bitmask of required configurations.
|
|
|
|
*
|
|
|
|
* Perform any autoconfiguration steps for the port. This functino is
|
|
|
|
* called if the UPF_BOOT_AUTOCONF flag is specified for the port.
|
|
|
|
* [Note: This is required for now because of a bug in the Serial core.
|
|
|
|
* rmk has already submitted a patch to linus, should be available for
|
|
|
|
* 2.5.47.]
|
|
|
|
*/
|
|
|
|
static void mux_config_port(struct uart_port *port, int type)
|
|
|
|
{
|
|
|
|
port->type = PORT_MUX;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_verify_port - Verify the port information.
|
|
|
|
* @port: Ptr to the uart_port.
|
|
|
|
* @ser: Ptr to the serial information.
|
|
|
|
*
|
|
|
|
* Verify the new serial port information contained within serinfo is
|
|
|
|
* suitable for this port type.
|
|
|
|
*/
|
|
|
|
static int mux_verify_port(struct uart_port *port, struct serial_struct *ser)
|
|
|
|
{
|
|
|
|
if(port->membase == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_drv_poll - Mux poll function.
|
|
|
|
* @unused: Unused variable
|
|
|
|
*
|
|
|
|
* This function periodically polls the Serial MUX to check for new data.
|
|
|
|
*/
|
|
|
|
static void mux_poll(unsigned long unused)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < port_cnt; ++i) {
|
|
|
|
if(!mux_ports[i].info)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
mux_read(&mux_ports[i]);
|
|
|
|
mux_write(&mux_ports[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
mod_timer(&mux_timer, jiffies + MUX_POLL_DELAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_SERIAL_MUX_CONSOLE
|
|
|
|
static void mux_console_write(struct console *co, const char *s, unsigned count)
|
|
|
|
{
|
|
|
|
while(count--)
|
|
|
|
pdc_iodc_putc(*s++);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mux_console_setup(struct console *co, char *options)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct tty_driver *mux_console_device(struct console *co, int *index)
|
|
|
|
{
|
|
|
|
*index = co->index;
|
|
|
|
return mux_driver.tty_driver;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct console mux_console = {
|
|
|
|
.name = "ttyB",
|
|
|
|
.write = mux_console_write,
|
|
|
|
.device = mux_console_device,
|
|
|
|
.setup = mux_console_setup,
|
|
|
|
.flags = CON_ENABLED | CON_PRINTBUFFER,
|
|
|
|
.index = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MUX_CONSOLE &mux_console
|
|
|
|
#else
|
|
|
|
#define MUX_CONSOLE NULL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static struct uart_ops mux_pops = {
|
|
|
|
.tx_empty = mux_tx_empty,
|
|
|
|
.set_mctrl = mux_set_mctrl,
|
|
|
|
.get_mctrl = mux_get_mctrl,
|
|
|
|
.stop_tx = mux_stop_tx,
|
|
|
|
.start_tx = mux_start_tx,
|
|
|
|
.stop_rx = mux_stop_rx,
|
|
|
|
.enable_ms = mux_enable_ms,
|
|
|
|
.break_ctl = mux_break_ctl,
|
|
|
|
.startup = mux_startup,
|
|
|
|
.shutdown = mux_shutdown,
|
|
|
|
.set_termios = mux_set_termios,
|
|
|
|
.type = mux_type,
|
|
|
|
.release_port = mux_release_port,
|
|
|
|
.request_port = mux_request_port,
|
|
|
|
.config_port = mux_config_port,
|
|
|
|
.verify_port = mux_verify_port,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_probe - Determine if the Serial Mux should claim this device.
|
|
|
|
* @dev: The parisc device.
|
|
|
|
*
|
|
|
|
* Deterimine if the Serial Mux should claim this chip (return 0)
|
|
|
|
* or not (return 1).
|
|
|
|
*/
|
|
|
|
static int __init mux_probe(struct parisc_device *dev)
|
|
|
|
{
|
|
|
|
int i, status, ports;
|
|
|
|
u8 iodc_data[32];
|
|
|
|
unsigned long bytecnt;
|
|
|
|
struct uart_port *port;
|
|
|
|
|
2005-10-22 02:36:40 +00:00
|
|
|
status = pdc_iodc_read(&bytecnt, dev->hpa.start, 0, iodc_data, 32);
|
2005-04-16 22:20:36 +00:00
|
|
|
if(status != PDC_OK) {
|
|
|
|
printk(KERN_ERR "Serial mux: Unable to read IODC.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ports = GET_MUX_PORTS(iodc_data);
|
|
|
|
printk(KERN_INFO "Serial mux driver (%d ports) Revision: 0.3\n", ports);
|
|
|
|
|
|
|
|
if(!port_cnt) {
|
|
|
|
mux_driver.cons = MUX_CONSOLE;
|
|
|
|
|
|
|
|
status = uart_register_driver(&mux_driver);
|
|
|
|
if(status) {
|
|
|
|
printk(KERN_ERR "Serial mux: Unable to register driver.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
init_timer(&mux_timer);
|
|
|
|
mux_timer.function = mux_poll;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i < ports; ++i, ++port_cnt) {
|
|
|
|
port = &mux_ports[port_cnt];
|
|
|
|
port->iobase = 0;
|
2005-10-22 02:58:03 +00:00
|
|
|
port->mapbase = dev->hpa.start + MUX_OFFSET +
|
|
|
|
(i * MUX_LINE_OFFSET);
|
2006-03-27 19:52:15 +00:00
|
|
|
port->membase = ioremap_nocache(port->mapbase, MUX_LINE_OFFSET);
|
2006-02-05 10:48:10 +00:00
|
|
|
port->iotype = UPIO_MEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
port->type = PORT_MUX;
|
2005-10-22 02:58:03 +00:00
|
|
|
port->irq = NO_IRQ;
|
2005-04-16 22:20:36 +00:00
|
|
|
port->uartclk = 0;
|
|
|
|
port->fifosize = MUX_FIFO_SIZE;
|
|
|
|
port->ops = &mux_pops;
|
|
|
|
port->flags = UPF_BOOT_AUTOCONF;
|
|
|
|
port->line = port_cnt;
|
2005-11-17 21:38:28 +00:00
|
|
|
|
|
|
|
/* The port->timeout needs to match what is present in
|
|
|
|
* uart_wait_until_sent in serial_core.c. Otherwise
|
|
|
|
* the time spent in msleep_interruptable will be very
|
|
|
|
* long, causing the appearance of a console hang.
|
|
|
|
*/
|
|
|
|
port->timeout = HZ / 50;
|
2005-10-22 02:58:03 +00:00
|
|
|
spin_lock_init(&port->lock);
|
2005-04-16 22:20:36 +00:00
|
|
|
status = uart_add_one_port(&mux_driver, port);
|
|
|
|
BUG_ON(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SERIAL_MUX_CONSOLE
|
|
|
|
register_console(&mux_console);
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct parisc_device_id mux_tbl[] = {
|
|
|
|
{ HPHW_A_DIRECT, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0000D },
|
|
|
|
{ 0, }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(parisc, mux_tbl);
|
|
|
|
|
|
|
|
static struct parisc_driver serial_mux_driver = {
|
2005-10-22 02:36:23 +00:00
|
|
|
.name = "serial_mux",
|
2005-04-16 22:20:36 +00:00
|
|
|
.id_table = mux_tbl,
|
|
|
|
.probe = mux_probe,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_init - Serial MUX initalization procedure.
|
|
|
|
*
|
|
|
|
* Register the Serial MUX driver.
|
|
|
|
*/
|
|
|
|
static int __init mux_init(void)
|
|
|
|
{
|
|
|
|
return register_parisc_driver(&serial_mux_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mux_exit - Serial MUX cleanup procedure.
|
|
|
|
*
|
|
|
|
* Unregister the Serial MUX driver from the tty layer.
|
|
|
|
*/
|
|
|
|
static void __exit mux_exit(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < port_cnt; i++) {
|
|
|
|
uart_remove_one_port(&mux_driver, &mux_ports[i]);
|
2006-10-01 06:29:25 +00:00
|
|
|
if (mux_ports[i].membase)
|
|
|
|
iounmap(mux_ports[i].membase);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uart_unregister_driver(&mux_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(mux_init);
|
|
|
|
module_exit(mux_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Ryan Bradetich");
|
|
|
|
MODULE_DESCRIPTION("Serial MUX driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_ALIAS_CHARDEV_MAJOR(MUX_MAJOR);
|