2005-04-17 00:20:36 +02:00
|
|
|
/*
|
2006-12-07 05:38:59 +01:00
|
|
|
* dz.c: Serial port driver for DECstations equipped
|
2005-04-17 00:20:36 +02:00
|
|
|
* with the DZ chipset.
|
|
|
|
*
|
2005-11-12 22:59:59 +01:00
|
|
|
* Copyright (C) 1998 Olivier A. D. Lebaillif
|
|
|
|
*
|
2005-04-17 00:20:36 +02:00
|
|
|
* Email: olivier.lebaillif@ifrsys.com
|
|
|
|
*
|
2008-02-07 09:15:09 +01:00
|
|
|
* Copyright (C) 2004, 2006, 2007 Maciej W. Rozycki
|
2006-12-07 05:38:59 +01:00
|
|
|
*
|
2005-04-17 00:20:36 +02:00
|
|
|
* [31-AUG-98] triemer
|
|
|
|
* Changed IRQ to use Harald's dec internals interrupts.h
|
|
|
|
* removed base_addr code - moving address assignment to setup.c
|
|
|
|
* Changed name of dz_init to rs_init to be consistent with tc code
|
|
|
|
* [13-NOV-98] triemer fixed code to receive characters
|
2005-11-12 22:59:59 +01:00
|
|
|
* after patches by harald to irq code.
|
2005-04-17 00:20:36 +02:00
|
|
|
* [09-JAN-99] triemer minor fix for schedule - due to removal of timeout
|
|
|
|
* field from "current" - somewhere between 2.1.121 and 2.1.131
|
|
|
|
Qua Jun 27 15:02:26 BRT 2001
|
|
|
|
* [27-JUN-2001] Arnaldo Carvalho de Melo <acme@conectiva.com.br> - cleanups
|
2005-11-12 22:59:59 +01:00
|
|
|
*
|
|
|
|
* Parts (C) 1999 David Airlie, airlied@linux.ie
|
|
|
|
* [07-SEP-99] Bugfixes
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
* [06-Jan-2002] Russell King <rmk@arm.linux.org.uk>
|
|
|
|
* Converted to new serial core
|
|
|
|
*/
|
|
|
|
|
|
|
|
#undef DEBUG_DZ
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
#if defined(CONFIG_SERIAL_DZ_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
|
|
|
|
#define SUPPORT_SYSRQ
|
|
|
|
#endif
|
|
|
|
|
2008-02-07 09:15:09 +01:00
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/console.h>
|
2006-12-07 05:38:59 +01:00
|
|
|
#include <linux/delay.h>
|
2008-02-07 09:15:09 +01:00
|
|
|
#include <linux/errno.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/init.h>
|
2008-02-07 09:15:09 +01:00
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/major.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/serial.h>
|
|
|
|
#include <linux/serial_core.h>
|
2006-12-07 05:38:59 +01:00
|
|
|
#include <linux/sysrq.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/tty.h>
|
|
|
|
|
|
|
|
#include <asm/bootinfo.h>
|
2008-02-07 09:15:09 +01:00
|
|
|
#include <asm/system.h>
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/dec/interrupts.h>
|
|
|
|
#include <asm/dec/kn01.h>
|
|
|
|
#include <asm/dec/kn02.h>
|
|
|
|
#include <asm/dec/machtype.h>
|
|
|
|
#include <asm/dec/prom.h>
|
|
|
|
|
|
|
|
#include "dz.h"
|
|
|
|
|
|
|
|
static char *dz_name = "DECstation DZ serial driver version ";
|
2006-12-07 05:38:59 +01:00
|
|
|
static char *dz_version = "1.03";
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
struct dz_port {
|
|
|
|
struct uart_port port;
|
|
|
|
unsigned int cflag;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct dz_port dz_ports[DZ_NB_PORT];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
* dz_in () and dz_out ()
|
|
|
|
*
|
2005-11-12 22:59:59 +01:00
|
|
|
* These routines are used to access the registers of the DZ
|
2005-04-17 00:20:36 +02:00
|
|
|
* chip, hiding relocation differences between implementation.
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline unsigned short dz_in(struct dz_port *dport, unsigned offset)
|
|
|
|
{
|
|
|
|
volatile unsigned short *addr =
|
|
|
|
(volatile unsigned short *) (dport->port.membase + offset);
|
2006-12-07 05:38:59 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
return *addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void dz_out(struct dz_port *dport, unsigned offset,
|
|
|
|
unsigned short value)
|
|
|
|
{
|
|
|
|
volatile unsigned short *addr =
|
|
|
|
(volatile unsigned short *) (dport->port.membase + offset);
|
2006-12-07 05:38:59 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
*addr = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
* rs_stop () and rs_start ()
|
|
|
|
*
|
2005-11-12 22:59:59 +01:00
|
|
|
* These routines are called before setting or resetting
|
|
|
|
* tty->stopped. They enable or disable transmitter interrupts,
|
2005-04-17 00:20:36 +02:00
|
|
|
* as necessary.
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2005-08-31 11:12:14 +02:00
|
|
|
static void dz_stop_tx(struct uart_port *uport)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
|
|
|
unsigned short tmp, mask = 1 << dport->port.line;
|
|
|
|
|
|
|
|
tmp = dz_in(dport, DZ_TCR); /* read the TX flag */
|
|
|
|
tmp &= ~mask; /* clear the TX flag */
|
|
|
|
dz_out(dport, DZ_TCR, tmp);
|
|
|
|
}
|
|
|
|
|
2005-08-31 11:12:14 +02:00
|
|
|
static void dz_start_tx(struct uart_port *uport)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
|
|
|
unsigned short tmp, mask = 1 << dport->port.line;
|
|
|
|
|
|
|
|
tmp = dz_in(dport, DZ_TCR); /* read the TX flag */
|
|
|
|
tmp |= mask; /* set the TX flag */
|
|
|
|
dz_out(dport, DZ_TCR, tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dz_stop_rx(struct uart_port *uport)
|
|
|
|
{
|
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
|
|
|
|
2008-02-07 09:15:14 +01:00
|
|
|
dport->cflag &= ~DZ_RXENAB;
|
|
|
|
dz_out(dport, DZ_LPR, dport->cflag);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dz_enable_ms(struct uart_port *port)
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
*
|
2006-12-07 05:38:59 +01:00
|
|
|
* Here start the interrupt handling routines. All of the following
|
|
|
|
* subroutines are declared as inline and are folded into
|
|
|
|
* dz_interrupt. They were separated out for readability's sake.
|
|
|
|
*
|
|
|
|
* Note: dz_interrupt() is a "fast" interrupt, which means that it
|
2005-04-17 00:20:36 +02:00
|
|
|
* runs with interrupts turned off. People who may want to modify
|
2006-12-07 05:38:59 +01:00
|
|
|
* dz_interrupt() should try to keep the interrupt handler as fast as
|
2005-04-17 00:20:36 +02:00
|
|
|
* possible. After you are done making modifications, it is not a bad
|
|
|
|
* idea to do:
|
2005-11-12 22:59:59 +01:00
|
|
|
*
|
2005-04-17 00:20:36 +02:00
|
|
|
* make drivers/serial/dz.s
|
|
|
|
*
|
|
|
|
* and look at the resulting assemble code in dz.s.
|
|
|
|
*
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
* receive_char ()
|
|
|
|
*
|
|
|
|
* This routine deals with inputs from any lines.
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
*/
|
2007-03-05 09:30:26 +01:00
|
|
|
static inline void dz_receive_chars(struct dz_port *dport_in)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-02-07 09:15:12 +01:00
|
|
|
struct uart_port *uport;
|
2006-12-07 05:38:59 +01:00
|
|
|
struct dz_port *dport;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct tty_struct *tty = NULL;
|
|
|
|
struct uart_icount *icount;
|
2006-12-07 05:38:59 +01:00
|
|
|
int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 };
|
|
|
|
unsigned short status;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned char ch, flag;
|
2006-12-07 05:38:59 +01:00
|
|
|
int i;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
while ((status = dz_in(dport_in, DZ_RBUF)) & DZ_DVAL) {
|
|
|
|
dport = &dz_ports[LINE(status)];
|
2008-02-07 09:15:12 +01:00
|
|
|
uport = &dport->port;
|
|
|
|
tty = uport->info->tty; /* point to the proper dev */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
ch = UCHAR(status); /* grab the char */
|
2008-02-07 09:15:12 +01:00
|
|
|
flag = TTY_NORMAL;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-07 09:15:12 +01:00
|
|
|
icount = &uport->icount;
|
2005-04-17 00:20:36 +02:00
|
|
|
icount->rx++;
|
|
|
|
|
2008-02-07 09:15:12 +01:00
|
|
|
if (unlikely(status & (DZ_OERR | DZ_FERR | DZ_PERR))) {
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
/*
|
2008-02-07 09:15:12 +01:00
|
|
|
* There is no separate BREAK status bit, so treat
|
|
|
|
* null characters with framing errors as BREAKs;
|
|
|
|
* normally, otherwise. For this move the Framing
|
|
|
|
* Error bit to a simulated BREAK bit.
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
2008-02-07 09:15:12 +01:00
|
|
|
if (!ch) {
|
|
|
|
status |= (status & DZ_FERR) >>
|
|
|
|
(ffs(DZ_FERR) - ffs(DZ_BREAK));
|
|
|
|
status &= ~DZ_FERR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle SysRq/SAK & keep track of the statistics. */
|
|
|
|
if (status & DZ_BREAK) {
|
|
|
|
icount->brk++;
|
|
|
|
if (uart_handle_break(uport))
|
|
|
|
continue;
|
|
|
|
} else if (status & DZ_FERR)
|
|
|
|
icount->frame++;
|
|
|
|
else if (status & DZ_PERR)
|
|
|
|
icount->parity++;
|
|
|
|
if (status & DZ_OERR)
|
|
|
|
icount->overrun++;
|
|
|
|
|
|
|
|
status &= uport->read_status_mask;
|
|
|
|
if (status & DZ_BREAK)
|
2006-12-07 05:38:59 +01:00
|
|
|
flag = TTY_BREAK;
|
2008-02-07 09:15:12 +01:00
|
|
|
else if (status & DZ_FERR)
|
2005-04-17 00:20:36 +02:00
|
|
|
flag = TTY_FRAME;
|
2008-02-07 09:15:12 +01:00
|
|
|
else if (status & DZ_PERR)
|
|
|
|
flag = TTY_PARITY;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-02-07 09:15:12 +01:00
|
|
|
if (uart_handle_sysrq_char(uport, ch))
|
2006-12-07 05:38:59 +01:00
|
|
|
continue;
|
|
|
|
|
2008-02-07 09:15:12 +01:00
|
|
|
uart_insert_char(uport, status, DZ_OERR, ch, flag);
|
|
|
|
lines_rx[LINE(status)] = 1;
|
2006-12-07 05:38:59 +01:00
|
|
|
}
|
|
|
|
for (i = 0; i < DZ_NB_PORT; i++)
|
|
|
|
if (lines_rx[i])
|
|
|
|
tty_flip_buffer_push(dz_ports[i].port.info->tty);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
* transmit_char ()
|
|
|
|
*
|
|
|
|
* This routine deals with outputs to any lines.
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
*/
|
2006-12-07 05:38:59 +01:00
|
|
|
static inline void dz_transmit_chars(struct dz_port *dport_in)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2006-12-07 05:38:59 +01:00
|
|
|
struct dz_port *dport;
|
|
|
|
struct circ_buf *xmit;
|
|
|
|
unsigned short status;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned char tmp;
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
status = dz_in(dport_in, DZ_CSR);
|
|
|
|
dport = &dz_ports[LINE(status)];
|
|
|
|
xmit = &dport->port.info->xmit;
|
|
|
|
|
|
|
|
if (dport->port.x_char) { /* XON/XOFF chars */
|
2005-04-17 00:20:36 +02:00
|
|
|
dz_out(dport, DZ_TDR, dport->port.x_char);
|
|
|
|
dport->port.icount.tx++;
|
|
|
|
dport->port.x_char = 0;
|
|
|
|
return;
|
|
|
|
}
|
2006-12-07 05:38:59 +01:00
|
|
|
/* If nothing to do or stopped or hardware stopped. */
|
2005-04-17 00:20:36 +02:00
|
|
|
if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) {
|
2008-02-07 09:15:11 +01:00
|
|
|
spin_lock(&dport->port.lock);
|
2005-08-31 11:12:14 +02:00
|
|
|
dz_stop_tx(&dport->port);
|
2008-02-07 09:15:11 +01:00
|
|
|
spin_unlock(&dport->port.lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-12-07 05:38:59 +01:00
|
|
|
* If something to do... (remember the dz has no output fifo,
|
|
|
|
* so we go one char at a time) :-<
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
tmp = xmit->buf[xmit->tail];
|
|
|
|
xmit->tail = (xmit->tail + 1) & (DZ_XMIT_SIZE - 1);
|
|
|
|
dz_out(dport, DZ_TDR, tmp);
|
|
|
|
dport->port.icount.tx++;
|
|
|
|
|
|
|
|
if (uart_circ_chars_pending(xmit) < DZ_WAKEUP_CHARS)
|
|
|
|
uart_write_wakeup(&dport->port);
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
/* Are we are done. */
|
2008-02-07 09:15:11 +01:00
|
|
|
if (uart_circ_empty(xmit)) {
|
|
|
|
spin_lock(&dport->port.lock);
|
2005-08-31 11:12:14 +02:00
|
|
|
dz_stop_tx(&dport->port);
|
2008-02-07 09:15:11 +01:00
|
|
|
spin_unlock(&dport->port.lock);
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ------------------------------------------------------------
|
2006-12-07 05:38:59 +01:00
|
|
|
* check_modem_status()
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
2006-12-07 05:38:59 +01:00
|
|
|
* DS 3100 & 5100: Only valid for the MODEM line, duh!
|
|
|
|
* DS 5000/200: Valid for the MODEM and PRINTER line.
|
2005-04-17 00:20:36 +02:00
|
|
|
* ------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
static inline void check_modem_status(struct dz_port *dport)
|
|
|
|
{
|
2006-12-07 05:38:59 +01:00
|
|
|
/*
|
|
|
|
* FIXME:
|
|
|
|
* 1. No status change interrupt; use a timer.
|
|
|
|
* 2. Handle the 3100/5000 as appropriate. --macro
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned short status;
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
/* If not the modem line just return. */
|
2005-04-17 00:20:36 +02:00
|
|
|
if (dport->port.line != DZ_MODEM)
|
|
|
|
return;
|
|
|
|
|
|
|
|
status = dz_in(dport, DZ_MSR);
|
|
|
|
|
|
|
|
/* it's easy, since DSR2 is the only bit in the register */
|
|
|
|
if (status)
|
|
|
|
dport->port.icount.dsr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
* dz_interrupt ()
|
|
|
|
*
|
|
|
|
* this is the main interrupt routine for the DZ chip.
|
|
|
|
* It deals with the multiple ports.
|
|
|
|
* ------------------------------------------------------------
|
|
|
|
*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 15:55:46 +02:00
|
|
|
static irqreturn_t dz_interrupt(int irq, void *dev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-02-06 10:36:20 +01:00
|
|
|
struct dz_port *dport = dev;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned short status;
|
|
|
|
|
|
|
|
/* get the reason why we just got an irq */
|
2006-12-07 05:38:59 +01:00
|
|
|
status = dz_in(dport, DZ_CSR);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
if ((status & (DZ_RDONE | DZ_RIE)) == (DZ_RDONE | DZ_RIE))
|
2007-03-05 09:30:26 +01:00
|
|
|
dz_receive_chars(dport);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
if ((status & (DZ_TRDY | DZ_TIE)) == (DZ_TRDY | DZ_TIE))
|
2005-04-17 00:20:36 +02:00
|
|
|
dz_transmit_chars(dport);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* -------------------------------------------------------------------
|
|
|
|
* Here ends the DZ interrupt routines.
|
|
|
|
* -------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
static unsigned int dz_get_mctrl(struct uart_port *uport)
|
|
|
|
{
|
2006-12-07 05:38:59 +01:00
|
|
|
/*
|
|
|
|
* FIXME: Handle the 3100/5000 as appropriate. --macro
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
|
|
|
unsigned int mctrl = TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
|
|
|
|
|
|
|
|
if (dport->port.line == DZ_MODEM) {
|
|
|
|
if (dz_in(dport, DZ_MSR) & DZ_MODEM_DSR)
|
|
|
|
mctrl &= ~TIOCM_DSR;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mctrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl)
|
|
|
|
{
|
2006-12-07 05:38:59 +01:00
|
|
|
/*
|
|
|
|
* FIXME: Handle the 3100/5000 as appropriate. --macro
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
|
|
|
unsigned short tmp;
|
|
|
|
|
|
|
|
if (dport->port.line == DZ_MODEM) {
|
|
|
|
tmp = dz_in(dport, DZ_TCR);
|
|
|
|
if (mctrl & TIOCM_DTR)
|
|
|
|
tmp &= ~DZ_MODEM_DTR;
|
|
|
|
else
|
|
|
|
tmp |= DZ_MODEM_DTR;
|
|
|
|
dz_out(dport, DZ_TCR, tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* -------------------------------------------------------------------
|
|
|
|
* startup ()
|
|
|
|
*
|
|
|
|
* various initialization tasks
|
2005-11-12 22:59:59 +01:00
|
|
|
* -------------------------------------------------------------------
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static int dz_startup(struct uart_port *uport)
|
|
|
|
{
|
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned short tmp;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dport->port.lock, flags);
|
|
|
|
|
|
|
|
/* enable the interrupt and the scanning */
|
|
|
|
tmp = dz_in(dport, DZ_CSR);
|
|
|
|
tmp |= DZ_RIE | DZ_TIE | DZ_MSE;
|
|
|
|
dz_out(dport, DZ_CSR, tmp);
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&dport->port.lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-12 22:59:59 +01:00
|
|
|
/*
|
2005-04-17 00:20:36 +02:00
|
|
|
* -------------------------------------------------------------------
|
|
|
|
* shutdown ()
|
|
|
|
*
|
|
|
|
* This routine will shutdown a serial port; interrupts are disabled, and
|
|
|
|
* DTR is dropped if the hangup on close termio flag is on.
|
2005-11-12 22:59:59 +01:00
|
|
|
* -------------------------------------------------------------------
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static void dz_shutdown(struct uart_port *uport)
|
|
|
|
{
|
2008-02-07 09:15:11 +01:00
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dport->port.lock, flags);
|
|
|
|
dz_stop_tx(&dport->port);
|
|
|
|
spin_unlock_irqrestore(&dport->port.lock, flags);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-12-07 05:38:59 +01:00
|
|
|
* -------------------------------------------------------------------
|
|
|
|
* dz_tx_empty() -- get the transmitter empty status
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
* 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
|
2005-11-12 22:59:59 +01:00
|
|
|
* allows an RS485 driver to be written in user space.
|
2006-12-07 05:38:59 +01:00
|
|
|
* -------------------------------------------------------------------
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static unsigned int dz_tx_empty(struct uart_port *uport)
|
|
|
|
{
|
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
2006-12-07 05:38:59 +01:00
|
|
|
unsigned short tmp, mask = 1 << dport->port.line;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
tmp = dz_in(dport, DZ_TCR);
|
|
|
|
tmp &= mask;
|
|
|
|
|
|
|
|
return tmp ? 0 : TIOCSER_TEMT;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void dz_break_ctl(struct uart_port *uport, int break_state)
|
|
|
|
{
|
2006-12-07 05:38:59 +01:00
|
|
|
/*
|
|
|
|
* FIXME: Can't access BREAK bits in TDR easily;
|
|
|
|
* reuse the code for polled TX. --macro
|
|
|
|
*/
|
2005-04-17 00:20:36 +02:00
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
|
|
|
unsigned long flags;
|
2006-12-07 05:38:59 +01:00
|
|
|
unsigned short tmp, mask = 1 << dport->port.line;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
spin_lock_irqsave(&uport->lock, flags);
|
|
|
|
tmp = dz_in(dport, DZ_TCR);
|
|
|
|
if (break_state)
|
|
|
|
tmp |= mask;
|
|
|
|
else
|
|
|
|
tmp &= ~mask;
|
|
|
|
dz_out(dport, DZ_TCR, tmp);
|
|
|
|
spin_unlock_irqrestore(&uport->lock, flags);
|
|
|
|
}
|
|
|
|
|
2008-02-07 09:15:14 +01:00
|
|
|
static int dz_encode_baud_rate(unsigned int baud)
|
|
|
|
{
|
|
|
|
switch (baud) {
|
|
|
|
case 50:
|
|
|
|
return DZ_B50;
|
|
|
|
case 75:
|
|
|
|
return DZ_B75;
|
|
|
|
case 110:
|
|
|
|
return DZ_B110;
|
|
|
|
case 134:
|
|
|
|
return DZ_B134;
|
|
|
|
case 150:
|
|
|
|
return DZ_B150;
|
|
|
|
case 300:
|
|
|
|
return DZ_B300;
|
|
|
|
case 600:
|
|
|
|
return DZ_B600;
|
|
|
|
case 1200:
|
|
|
|
return DZ_B1200;
|
|
|
|
case 1800:
|
|
|
|
return DZ_B1800;
|
|
|
|
case 2000:
|
|
|
|
return DZ_B2000;
|
|
|
|
case 2400:
|
|
|
|
return DZ_B2400;
|
|
|
|
case 3600:
|
|
|
|
return DZ_B3600;
|
|
|
|
case 4800:
|
|
|
|
return DZ_B4800;
|
|
|
|
case 7200:
|
|
|
|
return DZ_B7200;
|
|
|
|
case 9600:
|
|
|
|
return DZ_B9600;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-08 11:38:45 +01:00
|
|
|
static void dz_set_termios(struct uart_port *uport, struct ktermios *termios,
|
|
|
|
struct ktermios *old_termios)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int cflag, baud;
|
2008-02-07 09:15:14 +01:00
|
|
|
int bflag;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
cflag = dport->port.line;
|
|
|
|
|
|
|
|
switch (termios->c_cflag & CSIZE) {
|
|
|
|
case CS5:
|
|
|
|
cflag |= DZ_CS5;
|
|
|
|
break;
|
|
|
|
case CS6:
|
|
|
|
cflag |= DZ_CS6;
|
|
|
|
break;
|
|
|
|
case CS7:
|
|
|
|
cflag |= DZ_CS7;
|
|
|
|
break;
|
|
|
|
case CS8:
|
|
|
|
default:
|
|
|
|
cflag |= DZ_CS8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (termios->c_cflag & CSTOPB)
|
|
|
|
cflag |= DZ_CSTOPB;
|
|
|
|
if (termios->c_cflag & PARENB)
|
|
|
|
cflag |= DZ_PARENB;
|
|
|
|
if (termios->c_cflag & PARODD)
|
|
|
|
cflag |= DZ_PARODD;
|
|
|
|
|
|
|
|
baud = uart_get_baud_rate(uport, termios, old_termios, 50, 9600);
|
2008-02-07 09:15:14 +01:00
|
|
|
bflag = dz_encode_baud_rate(baud);
|
|
|
|
if (bflag < 0) { /* Try to keep unchanged. */
|
|
|
|
baud = uart_get_baud_rate(uport, old_termios, NULL, 50, 9600);
|
|
|
|
bflag = dz_encode_baud_rate(baud);
|
|
|
|
if (bflag < 0) { /* Resort to 9600. */
|
|
|
|
baud = 9600;
|
|
|
|
bflag = DZ_B9600;
|
|
|
|
}
|
|
|
|
tty_termios_encode_baud_rate(termios, baud, baud);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2008-02-07 09:15:14 +01:00
|
|
|
cflag |= bflag;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (termios->c_cflag & CREAD)
|
|
|
|
cflag |= DZ_RXENAB;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&dport->port.lock, flags);
|
|
|
|
|
2008-02-07 09:15:14 +01:00
|
|
|
uart_update_timeout(uport, termios->c_cflag, baud);
|
|
|
|
|
|
|
|
dz_out(dport, DZ_LPR, cflag);
|
2005-04-17 00:20:36 +02:00
|
|
|
dport->cflag = cflag;
|
|
|
|
|
|
|
|
/* setup accept flag */
|
|
|
|
dport->port.read_status_mask = DZ_OERR;
|
|
|
|
if (termios->c_iflag & INPCK)
|
|
|
|
dport->port.read_status_mask |= DZ_FERR | DZ_PERR;
|
2008-02-07 09:15:12 +01:00
|
|
|
if (termios->c_iflag & (BRKINT | PARMRK))
|
|
|
|
dport->port.read_status_mask |= DZ_BREAK;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* characters to ignore */
|
|
|
|
uport->ignore_status_mask = 0;
|
2008-02-07 09:15:12 +01:00
|
|
|
if ((termios->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK))
|
|
|
|
dport->port.ignore_status_mask |= DZ_OERR;
|
2005-04-17 00:20:36 +02:00
|
|
|
if (termios->c_iflag & IGNPAR)
|
|
|
|
dport->port.ignore_status_mask |= DZ_FERR | DZ_PERR;
|
2008-02-07 09:15:12 +01:00
|
|
|
if (termios->c_iflag & IGNBRK)
|
|
|
|
dport->port.ignore_status_mask |= DZ_BREAK;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&dport->port.lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *dz_type(struct uart_port *port)
|
|
|
|
{
|
|
|
|
return "DZ";
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dz_release_port(struct uart_port *port)
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
}
|
|
|
|
|
|
|
|
static int dz_request_port(struct uart_port *port)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dz_config_port(struct uart_port *port, int flags)
|
|
|
|
{
|
|
|
|
if (flags & UART_CONFIG_TYPE)
|
|
|
|
port->type = PORT_DZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* verify the new serial_struct (for TIOCSSERIAL).
|
|
|
|
*/
|
|
|
|
static int dz_verify_port(struct uart_port *port, struct serial_struct *ser)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
if (ser->type != PORT_UNKNOWN && ser->type != PORT_DZ)
|
|
|
|
ret = -EINVAL;
|
|
|
|
if (ser->irq != port->irq)
|
|
|
|
ret = -EINVAL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct uart_ops dz_ops = {
|
|
|
|
.tx_empty = dz_tx_empty,
|
|
|
|
.get_mctrl = dz_get_mctrl,
|
|
|
|
.set_mctrl = dz_set_mctrl,
|
|
|
|
.stop_tx = dz_stop_tx,
|
|
|
|
.start_tx = dz_start_tx,
|
|
|
|
.stop_rx = dz_stop_rx,
|
|
|
|
.enable_ms = dz_enable_ms,
|
|
|
|
.break_ctl = dz_break_ctl,
|
|
|
|
.startup = dz_startup,
|
|
|
|
.shutdown = dz_shutdown,
|
|
|
|
.set_termios = dz_set_termios,
|
|
|
|
.type = dz_type,
|
|
|
|
.release_port = dz_release_port,
|
|
|
|
.request_port = dz_request_port,
|
|
|
|
.config_port = dz_config_port,
|
|
|
|
.verify_port = dz_verify_port,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void __init dz_init_ports(void)
|
|
|
|
{
|
|
|
|
static int first = 1;
|
|
|
|
struct dz_port *dport;
|
|
|
|
unsigned long base;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!first)
|
|
|
|
return;
|
|
|
|
first = 0;
|
|
|
|
|
|
|
|
if (mips_machtype == MACH_DS23100 ||
|
|
|
|
mips_machtype == MACH_DS5100)
|
2005-11-12 23:00:27 +01:00
|
|
|
base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_DZ11);
|
2005-04-17 00:20:36 +02:00
|
|
|
else
|
2005-11-12 23:00:27 +01:00
|
|
|
base = CKSEG1ADDR(KN02_SLOT_BASE + KN02_DZ11);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) {
|
|
|
|
spin_lock_init(&dport->port.lock);
|
|
|
|
dport->port.membase = (char *) base;
|
2006-12-07 05:38:59 +01:00
|
|
|
dport->port.iotype = UPIO_MEM;
|
2005-04-17 00:20:36 +02:00
|
|
|
dport->port.irq = dec_interrupt[DEC_IRQ_DZ11];
|
|
|
|
dport->port.line = i;
|
|
|
|
dport->port.fifosize = 1;
|
|
|
|
dport->port.ops = &dz_ops;
|
|
|
|
dport->port.flags = UPF_BOOT_AUTOCONF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dz_reset(struct dz_port *dport)
|
|
|
|
{
|
|
|
|
dz_out(dport, DZ_CSR, DZ_CLR);
|
|
|
|
while (dz_in(dport, DZ_CSR) & DZ_CLR);
|
|
|
|
iob();
|
|
|
|
|
|
|
|
/* enable scanning */
|
|
|
|
dz_out(dport, DZ_CSR, DZ_MSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_SERIAL_DZ_CONSOLE
|
2006-12-07 05:38:59 +01:00
|
|
|
/*
|
|
|
|
* -------------------------------------------------------------------
|
|
|
|
* dz_console_putchar() -- transmit a character
|
|
|
|
*
|
|
|
|
* Polled transmission. This is tricky. We need to mask transmit
|
|
|
|
* interrupts so that they do not interfere, enable the transmitter
|
|
|
|
* for the line requested and then wait till the transmit scanner
|
|
|
|
* requests data for this line. But it may request data for another
|
|
|
|
* line first, in which case we have to disable its transmitter and
|
|
|
|
* repeat waiting till our line pops up. Only then the character may
|
|
|
|
* be transmitted. Finally, the state of the transmitter mask is
|
|
|
|
* restored. Welcome to the world of PDP-11!
|
|
|
|
* -------------------------------------------------------------------
|
|
|
|
*/
|
2006-06-26 18:18:11 +02:00
|
|
|
static void dz_console_putchar(struct uart_port *uport, int ch)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2006-03-20 21:00:09 +01:00
|
|
|
struct dz_port *dport = (struct dz_port *)uport;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
2006-12-07 05:38:59 +01:00
|
|
|
unsigned short csr, tcr, trdy, mask;
|
|
|
|
int loops = 10000;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
spin_lock_irqsave(&dport->port.lock, flags);
|
2006-12-07 05:38:59 +01:00
|
|
|
csr = dz_in(dport, DZ_CSR);
|
|
|
|
dz_out(dport, DZ_CSR, csr & ~DZ_TIE);
|
|
|
|
tcr = dz_in(dport, DZ_TCR);
|
|
|
|
tcr |= 1 << dport->port.line;
|
|
|
|
mask = tcr;
|
|
|
|
dz_out(dport, DZ_TCR, mask);
|
|
|
|
iob();
|
|
|
|
spin_unlock_irqrestore(&dport->port.lock, flags);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-02-07 09:15:07 +01:00
|
|
|
do {
|
2006-12-07 05:38:59 +01:00
|
|
|
trdy = dz_in(dport, DZ_CSR);
|
|
|
|
if (!(trdy & DZ_TRDY))
|
|
|
|
continue;
|
|
|
|
trdy = (trdy & DZ_TLINE) >> 8;
|
|
|
|
if (trdy == dport->port.line)
|
|
|
|
break;
|
|
|
|
mask &= ~(1 << trdy);
|
|
|
|
dz_out(dport, DZ_TCR, mask);
|
|
|
|
iob();
|
|
|
|
udelay(2);
|
2008-02-07 09:15:07 +01:00
|
|
|
} while (loops--);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
if (loops) /* Cannot send otherwise. */
|
|
|
|
dz_out(dport, DZ_TDR, ch);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
dz_out(dport, DZ_TCR, tcr);
|
|
|
|
dz_out(dport, DZ_CSR, csr);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2006-03-20 21:00:09 +01:00
|
|
|
|
2005-11-12 22:59:59 +01:00
|
|
|
/*
|
2005-04-17 00:20:36 +02:00
|
|
|
* -------------------------------------------------------------------
|
|
|
|
* dz_console_print ()
|
|
|
|
*
|
|
|
|
* dz_console_print is registered for printk.
|
|
|
|
* The console must be locked when we get here.
|
2005-11-12 22:59:59 +01:00
|
|
|
* -------------------------------------------------------------------
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
2006-12-07 05:38:59 +01:00
|
|
|
static void dz_console_print(struct console *co,
|
2005-04-17 00:20:36 +02:00
|
|
|
const char *str,
|
|
|
|
unsigned int count)
|
|
|
|
{
|
2006-12-07 05:38:59 +01:00
|
|
|
struct dz_port *dport = &dz_ports[co->index];
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifdef DEBUG_DZ
|
|
|
|
prom_printf((char *) str);
|
|
|
|
#endif
|
2006-03-20 21:00:09 +01:00
|
|
|
uart_console_write(&dport->port, str, count, dz_console_putchar);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init dz_console_setup(struct console *co, char *options)
|
|
|
|
{
|
2006-12-07 05:38:59 +01:00
|
|
|
struct dz_port *dport = &dz_ports[co->index];
|
2005-04-17 00:20:36 +02:00
|
|
|
int baud = 9600;
|
|
|
|
int bits = 8;
|
|
|
|
int parity = 'n';
|
|
|
|
int flow = 'n';
|
|
|
|
|
|
|
|
if (options)
|
|
|
|
uart_parse_options(options, &baud, &parity, &bits, &flow);
|
|
|
|
|
|
|
|
dz_reset(dport);
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
return uart_set_options(&dport->port, co, baud, parity, bits, flow);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
static struct uart_driver dz_reg;
|
2008-02-07 09:15:10 +01:00
|
|
|
static struct console dz_console = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.name = "ttyS",
|
|
|
|
.write = dz_console_print,
|
|
|
|
.device = uart_console_device,
|
|
|
|
.setup = dz_console_setup,
|
2006-12-07 05:38:59 +01:00
|
|
|
.flags = CON_PRINTBUFFER,
|
|
|
|
.index = -1,
|
|
|
|
.data = &dz_reg,
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
static int __init dz_serial_console_init(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2006-12-07 05:38:59 +01:00
|
|
|
if (!IOASIC) {
|
|
|
|
dz_init_ports();
|
2008-02-07 09:15:10 +01:00
|
|
|
register_console(&dz_console);
|
2006-12-07 05:38:59 +01:00
|
|
|
return 0;
|
|
|
|
} else
|
|
|
|
return -ENXIO;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
console_initcall(dz_serial_console_init);
|
|
|
|
|
2008-02-07 09:15:10 +01:00
|
|
|
#define SERIAL_DZ_CONSOLE &dz_console
|
2005-04-17 00:20:36 +02:00
|
|
|
#else
|
|
|
|
#define SERIAL_DZ_CONSOLE NULL
|
|
|
|
#endif /* CONFIG_SERIAL_DZ_CONSOLE */
|
|
|
|
|
|
|
|
static struct uart_driver dz_reg = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.driver_name = "serial",
|
2006-12-07 05:38:59 +01:00
|
|
|
.dev_name = "ttyS",
|
2005-04-17 00:20:36 +02:00
|
|
|
.major = TTY_MAJOR,
|
|
|
|
.minor = 64,
|
|
|
|
.nr = DZ_NB_PORT,
|
|
|
|
.cons = SERIAL_DZ_CONSOLE,
|
|
|
|
};
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
static int __init dz_init(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int ret, i;
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
if (IOASIC)
|
|
|
|
return -ENXIO;
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
printk("%s%s\n", dz_name, dz_version);
|
|
|
|
|
|
|
|
dz_init_ports();
|
|
|
|
|
|
|
|
#ifndef CONFIG_SERIAL_DZ_CONSOLE
|
|
|
|
/* reset the chip */
|
|
|
|
dz_reset(&dz_ports[0]);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ret = uart_register_driver(&dz_reg);
|
|
|
|
if (ret != 0)
|
2008-02-07 09:15:08 +01:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
ret = request_irq(dz_ports[0].port.irq, dz_interrupt, IRQF_DISABLED,
|
|
|
|
"DZ", &dz_ports[0]);
|
|
|
|
if (ret != 0) {
|
|
|
|
printk(KERN_ERR "dz: Cannot get IRQ %d!\n",
|
|
|
|
dz_ports[0].port.irq);
|
|
|
|
goto out_unregister;
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
for (i = 0; i < DZ_NB_PORT; i++)
|
|
|
|
uart_add_one_port(&dz_reg, &dz_ports[i].port);
|
|
|
|
|
|
|
|
return ret;
|
2008-02-07 09:15:08 +01:00
|
|
|
|
|
|
|
out_unregister:
|
|
|
|
uart_unregister_driver(&dz_reg);
|
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2006-12-07 05:38:59 +01:00
|
|
|
module_init(dz_init);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
MODULE_DESCRIPTION("DECstation DZ serial driver");
|
|
|
|
MODULE_LICENSE("GPL");
|