2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* linux/drivers/char/riscom.c -- RISCom/8 multiport serial driver.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1994-1996 Dmitry Gorodchanin (pgmdsg@ibi.com)
|
|
|
|
*
|
|
|
|
* This code is loosely based on the Linux serial driver, written by
|
2008-04-30 11:54:15 +04:00
|
|
|
* Linus Torvalds, Theodore T'so and others. The RISCom/8 card
|
|
|
|
* programming info was obtained from various drivers for other OSes
|
|
|
|
* (FreeBSD, ISC, etc), but no source code from those drivers were
|
2005-04-17 02:20:36 +04:00
|
|
|
* directly included in this driver.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 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 program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* Revision 1.1
|
|
|
|
*
|
|
|
|
* ChangeLog:
|
|
|
|
* Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 27-Jun-2001
|
|
|
|
* - get rid of check_region and several cleanups
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
#include <linux/io.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/serial.h>
|
|
|
|
#include <linux/fcntl.h>
|
|
|
|
#include <linux/major.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/delay.h>
|
[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 07:54:13 +03:00
|
|
|
#include <linux/tty_flip.h>
|
2008-02-06 12:36:11 +03:00
|
|
|
#include <linux/spinlock.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#include "riscom8.h"
|
|
|
|
#include "riscom8_reg.h"
|
|
|
|
|
|
|
|
/* Am I paranoid or not ? ;-) */
|
|
|
|
#define RISCOM_PARANOIA_CHECK
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
/*
|
|
|
|
* Crazy InteliCom/8 boards sometimes have swapped CTS & DSR signals.
|
2005-04-17 02:20:36 +04:00
|
|
|
* You can slightly speed up things by #undefing the following option,
|
2008-04-30 11:54:15 +04:00
|
|
|
* if you are REALLY sure that your board is correct one.
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define RISCOM_BRAIN_DAMAGED_CTS
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
/*
|
2005-04-17 02:20:36 +04:00
|
|
|
* The following defines are mostly for testing purposes. But if you need
|
|
|
|
* some nice reporting in your syslog, you can define them also.
|
|
|
|
*/
|
|
|
|
#undef RC_REPORT_FIFO
|
|
|
|
#undef RC_REPORT_OVERRUN
|
|
|
|
|
|
|
|
|
|
|
|
#define RISCOM_LEGAL_FLAGS \
|
|
|
|
(ASYNC_HUP_NOTIFY | ASYNC_SAK | ASYNC_SPLIT_TERMIOS | \
|
|
|
|
ASYNC_SPD_HI | ASYNC_SPEED_VHI | ASYNC_SESSION_LOCKOUT | \
|
|
|
|
ASYNC_PGRP_LOCKOUT | ASYNC_CALLOUT_NOHUP)
|
|
|
|
|
|
|
|
static struct tty_driver *riscom_driver;
|
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
static DEFINE_SPINLOCK(riscom_lock);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
static struct riscom_board rc_board[RC_NBOARD] = {
|
|
|
|
{
|
|
|
|
.base = RC_IOBASE1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.base = RC_IOBASE2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.base = RC_IOBASE3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.base = RC_IOBASE4,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct riscom_port rc_port[RC_NBOARD * RC_NPORT];
|
|
|
|
|
|
|
|
/* RISCom/8 I/O ports addresses (without address translation) */
|
|
|
|
static unsigned short rc_ioport[] = {
|
2006-01-10 07:54:02 +03:00
|
|
|
#if 1
|
2005-04-17 02:20:36 +04:00
|
|
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c,
|
2006-01-10 07:54:02 +03:00
|
|
|
#else
|
2005-04-17 02:20:36 +04:00
|
|
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0b, 0x0c, 0x10,
|
|
|
|
0x11, 0x12, 0x18, 0x28, 0x31, 0x32, 0x39, 0x3a, 0x40, 0x41, 0x61, 0x62,
|
|
|
|
0x63, 0x64, 0x6b, 0x70, 0x71, 0x78, 0x7a, 0x7b, 0x7f, 0x100, 0x101
|
2006-01-10 07:54:02 +03:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
2006-01-10 07:54:02 +03:00
|
|
|
#define RC_NIOPORT ARRAY_SIZE(rc_ioport)
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static int rc_paranoia_check(struct riscom_port const *port,
|
2005-04-17 02:20:36 +04:00
|
|
|
char *name, const char *routine)
|
|
|
|
{
|
|
|
|
#ifdef RISCOM_PARANOIA_CHECK
|
|
|
|
static const char badmagic[] = KERN_INFO
|
|
|
|
"rc: Warning: bad riscom port magic number for device %s in %s\n";
|
|
|
|
static const char badinfo[] = KERN_INFO
|
|
|
|
"rc: Warning: null riscom port for device %s in %s\n";
|
|
|
|
|
|
|
|
if (!port) {
|
|
|
|
printk(badinfo, name, routine);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (port->magic != RISCOM8_MAGIC) {
|
|
|
|
printk(badmagic, name, routine);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-04-30 11:54:15 +04:00
|
|
|
*
|
2005-04-17 02:20:36 +04:00
|
|
|
* Service functions for RISCom/8 driver.
|
2008-04-30 11:54:15 +04:00
|
|
|
*
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get board number from pointer */
|
2008-04-30 11:54:15 +04:00
|
|
|
static inline int board_No(struct riscom_board const *bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return bp - rc_board;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get port number from pointer */
|
2008-04-30 11:54:15 +04:00
|
|
|
static inline int port_No(struct riscom_port const *port)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-04-30 11:54:15 +04:00
|
|
|
return RC_PORT(port - rc_port);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get pointer to board from pointer to port */
|
2008-04-30 11:54:15 +04:00
|
|
|
static inline struct riscom_board *port_Board(struct riscom_port const *port)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return &rc_board[RC_BOARD(port - rc_port)];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Input Byte from CL CD180 register */
|
2008-04-30 11:54:15 +04:00
|
|
|
static inline unsigned char rc_in(struct riscom_board const *bp,
|
|
|
|
unsigned short reg)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
return inb(bp->base + RC_TO_ISA(reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Output Byte to CL CD180 register */
|
2008-04-30 11:54:15 +04:00
|
|
|
static inline void rc_out(struct riscom_board const *bp, unsigned short reg,
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned char val)
|
|
|
|
{
|
|
|
|
outb(val, bp->base + RC_TO_ISA(reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait for Channel Command Register ready */
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_wait_CCR(struct riscom_board const *bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned long delay;
|
|
|
|
|
|
|
|
/* FIXME: need something more descriptive then 100000 :) */
|
2008-04-30 11:54:15 +04:00
|
|
|
for (delay = 100000; delay; delay--)
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!rc_in(bp, CD180_CCR))
|
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
printk(KERN_INFO "rc%d: Timeout waiting for CCR.\n", board_No(bp));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RISCom/8 probe functions.
|
|
|
|
*/
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static int rc_request_io_range(struct riscom_board * const bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int i;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
for (i = 0; i < RC_NIOPORT; i++)
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!request_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1,
|
|
|
|
"RISCom/8")) {
|
|
|
|
goto out_release;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
out_release:
|
|
|
|
printk(KERN_INFO "rc%d: Skipping probe at 0x%03x. IO address in use.\n",
|
|
|
|
board_No(bp), bp->base);
|
2008-04-30 11:54:15 +04:00
|
|
|
while (--i >= 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_release_io_range(struct riscom_board * const bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int i;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
for (i = 0; i < RC_NIOPORT; i++)
|
2005-04-17 02:20:36 +04:00
|
|
|
release_region(RC_TO_ISA(rc_ioport[i]) + bp->base, 1);
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Reset and setup CD180 chip */
|
2008-04-30 11:54:15 +04:00
|
|
|
static void __init rc_init_CD180(struct riscom_board const *bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
rc_out(bp, RC_CTOUT, 0); /* Clear timeout */
|
|
|
|
rc_wait_CCR(bp); /* Wait for CCR ready */
|
|
|
|
rc_out(bp, CD180_CCR, CCR_HARDRESET); /* Reset CD180 chip */
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2008-04-30 11:54:15 +04:00
|
|
|
msleep(50); /* Delay 0.05 sec */
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
2008-04-30 11:54:15 +04:00
|
|
|
rc_out(bp, CD180_GIVR, RC_ID); /* Set ID for this chip */
|
|
|
|
rc_out(bp, CD180_GICR, 0); /* Clear all bits */
|
|
|
|
rc_out(bp, CD180_PILR1, RC_ACK_MINT); /* Prio for modem intr */
|
|
|
|
rc_out(bp, CD180_PILR2, RC_ACK_TINT); /* Prio for tx intr */
|
|
|
|
rc_out(bp, CD180_PILR3, RC_ACK_RINT); /* Prio for rx intr */
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Setting up prescaler. We need 4 ticks per 1 ms */
|
|
|
|
rc_out(bp, CD180_PPRH, (RC_OSCFREQ/(1000000/RISCOM_TPS)) >> 8);
|
|
|
|
rc_out(bp, CD180_PPRL, (RC_OSCFREQ/(1000000/RISCOM_TPS)) & 0xff);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Main probing routine, also sets irq. */
|
|
|
|
static int __init rc_probe(struct riscom_board *bp)
|
|
|
|
{
|
|
|
|
unsigned char val1, val2;
|
|
|
|
int irqs = 0;
|
|
|
|
int retries;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
bp->irq = 0;
|
|
|
|
|
|
|
|
if (rc_request_io_range(bp))
|
|
|
|
return 1;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Are the I/O ports here ? */
|
|
|
|
rc_out(bp, CD180_PPRL, 0x5a);
|
|
|
|
outb(0xff, 0x80);
|
|
|
|
val1 = rc_in(bp, CD180_PPRL);
|
|
|
|
rc_out(bp, CD180_PPRL, 0xa5);
|
|
|
|
outb(0x00, 0x80);
|
|
|
|
val2 = rc_in(bp, CD180_PPRL);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if ((val1 != 0x5a) || (val2 != 0xa5)) {
|
|
|
|
printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not found.\n",
|
|
|
|
board_No(bp), bp->base);
|
|
|
|
goto out_release;
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* It's time to find IRQ for this board */
|
2008-04-30 11:54:15 +04:00
|
|
|
for (retries = 0; retries < 5 && irqs <= 0; retries++) {
|
2005-04-17 02:20:36 +04:00
|
|
|
irqs = probe_irq_on();
|
2008-04-30 11:54:15 +04:00
|
|
|
rc_init_CD180(bp); /* Reset CD180 chip */
|
|
|
|
rc_out(bp, CD180_CAR, 2); /* Select port 2 */
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_wait_CCR(bp);
|
2008-04-30 11:54:15 +04:00
|
|
|
rc_out(bp, CD180_CCR, CCR_TXEN); /* Enable transmitter */
|
|
|
|
rc_out(bp, CD180_IER, IER_TXRDY);/* Enable tx empty intr */
|
2007-07-17 15:05:20 +04:00
|
|
|
msleep(50);
|
2005-04-17 02:20:36 +04:00
|
|
|
irqs = probe_irq_off(irqs);
|
2008-04-30 11:54:15 +04:00
|
|
|
val1 = rc_in(bp, RC_BSR); /* Get Board Status reg */
|
|
|
|
val2 = rc_in(bp, RC_ACK_TINT); /* ACK interrupt */
|
|
|
|
rc_init_CD180(bp); /* Reset CD180 again */
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if ((val1 & RC_BSR_TINT) || (val2 != (RC_ID | GIVR_IT_TX))) {
|
|
|
|
printk(KERN_ERR "rc%d: RISCom/8 Board at 0x%03x not "
|
|
|
|
"found.\n", board_No(bp), bp->base);
|
|
|
|
goto out_release;
|
|
|
|
}
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (irqs <= 0) {
|
|
|
|
printk(KERN_ERR "rc%d: Can't find IRQ for RISCom/8 board "
|
|
|
|
"at 0x%03x.\n", board_No(bp), bp->base);
|
|
|
|
goto out_release;
|
|
|
|
}
|
|
|
|
bp->irq = irqs;
|
|
|
|
bp->flags |= RC_BOARD_PRESENT;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
printk(KERN_INFO "rc%d: RISCom/8 Rev. %c board detected at "
|
|
|
|
"0x%03x, IRQ %d.\n",
|
|
|
|
board_No(bp),
|
|
|
|
(rc_in(bp, CD180_GFRCR) & 0x0f) + 'A', /* Board revision */
|
|
|
|
bp->base, bp->irq);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
out_release:
|
|
|
|
rc_release_io_range(bp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
/*
|
|
|
|
*
|
2005-04-17 02:20:36 +04:00
|
|
|
* Interrupt processing routines.
|
2008-04-30 11:54:15 +04:00
|
|
|
*
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static struct riscom_port *rc_get_port(struct riscom_board const *bp,
|
|
|
|
unsigned char const *what)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned char channel;
|
2008-04-30 11:54:15 +04:00
|
|
|
struct riscom_port *port;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
channel = rc_in(bp, CD180_GICR) >> GICR_CHAN_OFF;
|
|
|
|
if (channel < CD180_NCH) {
|
|
|
|
port = &rc_port[board_No(bp) * RC_NPORT + channel];
|
2008-07-17 00:55:29 +04:00
|
|
|
if (port->port.flags & ASYNC_INITIALIZED)
|
2005-04-17 02:20:36 +04:00
|
|
|
return port;
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
printk(KERN_ERR "rc%d: %s interrupt from invalid port %d\n",
|
2005-04-17 02:20:36 +04:00
|
|
|
board_No(bp), what, channel);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_receive_exc(struct riscom_board const *bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct riscom_port *port;
|
|
|
|
struct tty_struct *tty;
|
|
|
|
unsigned char status;
|
[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 07:54:13 +03:00
|
|
|
unsigned char ch, flag;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
port = rc_get_port(bp, "Receive");
|
|
|
|
if (port == NULL)
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
tty = port->port.tty;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
#ifdef RC_REPORT_OVERRUN
|
2005-04-17 02:20:36 +04:00
|
|
|
status = rc_in(bp, CD180_RCSR);
|
[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 07:54:13 +03:00
|
|
|
if (status & RCSR_OE)
|
2005-04-17 02:20:36 +04:00
|
|
|
port->overrun++;
|
|
|
|
status &= port->mark_mask;
|
2008-04-30 11:54:15 +04:00
|
|
|
#else
|
2005-04-17 02:20:36 +04:00
|
|
|
status = rc_in(bp, CD180_RCSR) & port->mark_mask;
|
2008-04-30 11:54:15 +04:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
ch = rc_in(bp, CD180_RDR);
|
2008-04-30 11:54:15 +04:00
|
|
|
if (!status)
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
|
|
|
if (status & RCSR_TOUT) {
|
|
|
|
printk(KERN_WARNING "rc%d: port %d: Receiver timeout. "
|
2008-04-30 11:54:15 +04:00
|
|
|
"Hardware problems ?\n",
|
2005-04-17 02:20:36 +04:00
|
|
|
board_No(bp), port_No(port));
|
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
} else if (status & RCSR_BREAK) {
|
|
|
|
printk(KERN_INFO "rc%d: port %d: Handling break...\n",
|
|
|
|
board_No(bp), port_No(port));
|
[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 07:54:13 +03:00
|
|
|
flag = TTY_BREAK;
|
2008-07-17 00:55:29 +04:00
|
|
|
if (port->port.flags & ASYNC_SAK)
|
2005-04-17 02:20:36 +04:00
|
|
|
do_SAK(tty);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
} else if (status & RCSR_PE)
|
[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 07:54:13 +03:00
|
|
|
flag = TTY_PARITY;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
else if (status & RCSR_FE)
|
[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 07:54:13 +03:00
|
|
|
flag = TTY_FRAME;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
else if (status & RCSR_OE)
|
[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 07:54:13 +03:00
|
|
|
flag = TTY_OVERRUN;
|
2005-04-17 02:20:36 +04:00
|
|
|
else
|
[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 07:54:13 +03:00
|
|
|
flag = TTY_NORMAL;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
[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 07:54:13 +03:00
|
|
|
tty_insert_flip_char(tty, ch, flag);
|
|
|
|
tty_flip_buffer_push(tty);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_receive(struct riscom_board const *bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct riscom_port *port;
|
|
|
|
struct tty_struct *tty;
|
|
|
|
unsigned char count;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
port = rc_get_port(bp, "Receive");
|
|
|
|
if (port == NULL)
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
tty = port->port.tty;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
count = rc_in(bp, CD180_RDCR);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef RC_REPORT_FIFO
|
|
|
|
port->hits[count > 8 ? 9 : count]++;
|
2008-04-30 11:54:15 +04:00
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
while (count--) {
|
[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 07:54:13 +03:00
|
|
|
if (tty_buffer_request_room(tty, 1) == 0) {
|
2005-04-17 02:20:36 +04:00
|
|
|
printk(KERN_WARNING "rc%d: port %d: Working around "
|
|
|
|
"flip buffer overflow.\n",
|
|
|
|
board_No(bp), port_No(port));
|
|
|
|
break;
|
|
|
|
}
|
[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 07:54:13 +03:00
|
|
|
tty_insert_flip_char(tty, rc_in(bp, CD180_RDR), TTY_NORMAL);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
[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 07:54:13 +03:00
|
|
|
tty_flip_buffer_push(tty);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_transmit(struct riscom_board const *bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct riscom_port *port;
|
|
|
|
struct tty_struct *tty;
|
|
|
|
unsigned char count;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
port = rc_get_port(bp, "Transmit");
|
|
|
|
if (port == NULL)
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
tty = port->port.tty;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
if (port->IER & IER_TXEMPTY) {
|
2005-04-17 02:20:36 +04:00
|
|
|
/* FIFO drained */
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
port->IER &= ~IER_TXEMPTY;
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
|
|
|
return;
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if ((port->xmit_cnt <= 0 && !port->break_length)
|
|
|
|
|| tty->stopped || tty->hw_stopped) {
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
|
|
|
return;
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (port->break_length) {
|
|
|
|
if (port->break_length > 0) {
|
|
|
|
if (port->COR2 & COR2_ETC) {
|
|
|
|
rc_out(bp, CD180_TDR, CD180_C_ESC);
|
|
|
|
rc_out(bp, CD180_TDR, CD180_C_SBRK);
|
|
|
|
port->COR2 &= ~COR2_ETC;
|
|
|
|
}
|
|
|
|
count = min_t(int, port->break_length, 0xff);
|
|
|
|
rc_out(bp, CD180_TDR, CD180_C_ESC);
|
|
|
|
rc_out(bp, CD180_TDR, CD180_C_DELAY);
|
|
|
|
rc_out(bp, CD180_TDR, count);
|
2008-04-30 11:54:15 +04:00
|
|
|
port->break_length -= count;
|
|
|
|
if (port->break_length == 0)
|
2005-04-17 02:20:36 +04:00
|
|
|
port->break_length--;
|
|
|
|
} else {
|
|
|
|
rc_out(bp, CD180_TDR, CD180_C_ESC);
|
|
|
|
rc_out(bp, CD180_TDR, CD180_C_EBRK);
|
|
|
|
rc_out(bp, CD180_COR2, port->COR2);
|
|
|
|
rc_wait_CCR(bp);
|
|
|
|
rc_out(bp, CD180_CCR, CCR_CORCHG2);
|
|
|
|
port->break_length = 0;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
count = CD180_NFIFO;
|
|
|
|
do {
|
2008-07-17 00:55:29 +04:00
|
|
|
rc_out(bp, CD180_TDR, port->port.xmit_buf[port->xmit_tail++]);
|
2005-04-17 02:20:36 +04:00
|
|
|
port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1);
|
|
|
|
if (--port->xmit_cnt <= 0)
|
|
|
|
break;
|
|
|
|
} while (--count > 0);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (port->xmit_cnt <= 0) {
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
|
|
|
}
|
|
|
|
if (port->xmit_cnt <= port->wakeup_chars)
|
2008-02-07 11:16:41 +03:00
|
|
|
tty_wakeup(tty);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_check_modem(struct riscom_board const *bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct riscom_port *port;
|
|
|
|
struct tty_struct *tty;
|
|
|
|
unsigned char mcr;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
port = rc_get_port(bp, "Modem");
|
|
|
|
if (port == NULL)
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
tty = port->port.tty;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
mcr = rc_in(bp, CD180_MCR);
|
2008-04-30 11:54:15 +04:00
|
|
|
if (mcr & MCR_CDCHG) {
|
|
|
|
if (rc_in(bp, CD180_MSVR) & MSVR_CD)
|
2008-07-17 00:55:29 +04:00
|
|
|
wake_up_interruptible(&port->port.open_wait);
|
2005-04-17 02:20:36 +04:00
|
|
|
else
|
2008-02-07 11:16:41 +03:00
|
|
|
tty_hangup(tty);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef RISCOM_BRAIN_DAMAGED_CTS
|
|
|
|
if (mcr & MCR_CTSCHG) {
|
|
|
|
if (rc_in(bp, CD180_MSVR) & MSVR_CTS) {
|
|
|
|
tty->hw_stopped = 0;
|
|
|
|
port->IER |= IER_TXRDY;
|
|
|
|
if (port->xmit_cnt <= port->wakeup_chars)
|
2008-02-07 11:16:41 +03:00
|
|
|
tty_wakeup(tty);
|
2005-04-17 02:20:36 +04:00
|
|
|
} else {
|
|
|
|
tty->hw_stopped = 1;
|
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
}
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
|
|
|
}
|
|
|
|
if (mcr & MCR_DSRCHG) {
|
|
|
|
if (rc_in(bp, CD180_MSVR) & MSVR_DSR) {
|
|
|
|
tty->hw_stopped = 0;
|
|
|
|
port->IER |= IER_TXRDY;
|
|
|
|
if (port->xmit_cnt <= port->wakeup_chars)
|
2008-02-07 11:16:41 +03:00
|
|
|
tty_wakeup(tty);
|
2005-04-17 02:20:36 +04:00
|
|
|
} else {
|
|
|
|
tty->hw_stopped = 1;
|
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
}
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
|
|
|
}
|
|
|
|
#endif /* RISCOM_BRAIN_DAMAGED_CTS */
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Clear change bits */
|
|
|
|
rc_out(bp, CD180_MCR, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The main interrupt processing routine */
|
2008-04-30 11:54:15 +04:00
|
|
|
static irqreturn_t rc_interrupt(int dummy, void *dev_id)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
unsigned char status;
|
|
|
|
unsigned char ack;
|
2007-10-24 03:12:11 +04:00
|
|
|
struct riscom_board *bp = dev_id;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned long loop = 0;
|
|
|
|
int handled = 0;
|
|
|
|
|
2006-10-06 23:00:58 +04:00
|
|
|
if (!(bp->flags & RC_BOARD_ACTIVE))
|
2005-04-17 02:20:36 +04:00
|
|
|
return IRQ_NONE;
|
2006-10-06 23:00:58 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
while ((++loop < 16) && ((status = ~(rc_in(bp, RC_BSR))) &
|
|
|
|
(RC_BSR_TOUT | RC_BSR_TINT |
|
|
|
|
RC_BSR_MINT | RC_BSR_RINT))) {
|
|
|
|
handled = 1;
|
2008-04-30 11:54:15 +04:00
|
|
|
if (status & RC_BSR_TOUT)
|
2005-04-17 02:20:36 +04:00
|
|
|
printk(KERN_WARNING "rc%d: Got timeout. Hardware "
|
|
|
|
"error?\n", board_No(bp));
|
|
|
|
else if (status & RC_BSR_RINT) {
|
|
|
|
ack = rc_in(bp, RC_ACK_RINT);
|
|
|
|
if (ack == (RC_ID | GIVR_IT_RCV))
|
|
|
|
rc_receive(bp);
|
|
|
|
else if (ack == (RC_ID | GIVR_IT_REXC))
|
|
|
|
rc_receive_exc(bp);
|
|
|
|
else
|
|
|
|
printk(KERN_WARNING "rc%d: Bad receive ack "
|
|
|
|
"0x%02x.\n",
|
|
|
|
board_No(bp), ack);
|
|
|
|
} else if (status & RC_BSR_TINT) {
|
|
|
|
ack = rc_in(bp, RC_ACK_TINT);
|
|
|
|
if (ack == (RC_ID | GIVR_IT_TX))
|
|
|
|
rc_transmit(bp);
|
|
|
|
else
|
|
|
|
printk(KERN_WARNING "rc%d: Bad transmit ack "
|
|
|
|
"0x%02x.\n",
|
|
|
|
board_No(bp), ack);
|
|
|
|
} else /* if (status & RC_BSR_MINT) */ {
|
|
|
|
ack = rc_in(bp, RC_ACK_MINT);
|
2008-04-30 11:54:15 +04:00
|
|
|
if (ack == (RC_ID | GIVR_IT_MODEM))
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_check_modem(bp);
|
|
|
|
else
|
|
|
|
printk(KERN_WARNING "rc%d: Bad modem ack "
|
|
|
|
"0x%02x.\n",
|
|
|
|
board_No(bp), ack);
|
2008-04-30 11:54:15 +04:00
|
|
|
}
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_out(bp, CD180_EOIR, 0); /* Mark end of interrupt */
|
|
|
|
rc_out(bp, RC_CTOUT, 0); /* Clear timeout flag */
|
|
|
|
}
|
|
|
|
return IRQ_RETVAL(handled);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Routines for open & close processing.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Called with disabled interrupts */
|
2008-04-30 11:54:15 +04:00
|
|
|
static int rc_setup_board(struct riscom_board *bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
if (bp->flags & RC_BOARD_ACTIVE)
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2006-07-02 06:29:33 +04:00
|
|
|
error = request_irq(bp->irq, rc_interrupt, IRQF_DISABLED,
|
2007-10-24 03:12:11 +04:00
|
|
|
"RISCom/8", bp);
|
2008-04-30 11:54:15 +04:00
|
|
|
if (error)
|
2005-04-17 02:20:36 +04:00
|
|
|
return error;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_out(bp, RC_CTOUT, 0); /* Just in case */
|
|
|
|
bp->DTR = ~0;
|
|
|
|
rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
bp->flags |= RC_BOARD_ACTIVE;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called with disabled interrupts */
|
2007-10-24 03:12:11 +04:00
|
|
|
static void rc_shutdown_board(struct riscom_board *bp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
if (!(bp->flags & RC_BOARD_ACTIVE))
|
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
bp->flags &= ~RC_BOARD_ACTIVE;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
free_irq(bp->irq, NULL);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
bp->DTR = ~0;
|
|
|
|
rc_out(bp, RC_DTR, bp->DTR); /* Drop DTR on all ports */
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-04-30 11:54:15 +04:00
|
|
|
* Setting up port characteristics.
|
2005-04-17 02:20:36 +04:00
|
|
|
* Must be called with disabled interrupts
|
|
|
|
*/
|
|
|
|
static void rc_change_speed(struct riscom_board *bp, struct riscom_port *port)
|
|
|
|
{
|
2008-07-17 00:55:29 +04:00
|
|
|
struct tty_struct *tty = port->port.tty;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned long baud;
|
|
|
|
long tmp;
|
|
|
|
unsigned char cor1 = 0, cor3 = 0;
|
|
|
|
unsigned char mcor1 = 0, mcor2 = 0;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
port->IER = 0;
|
|
|
|
port->COR2 = 0;
|
|
|
|
port->MSVR = MSVR_RTS;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2006-10-01 10:27:24 +04:00
|
|
|
baud = tty_get_baud_rate(tty);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Select port on the board */
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2006-10-01 10:27:24 +04:00
|
|
|
if (!baud) {
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Drop DTR & exit */
|
|
|
|
bp->DTR |= (1u << port_No(port));
|
|
|
|
rc_out(bp, RC_DTR, bp->DTR);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
/* Set DTR on */
|
|
|
|
bp->DTR &= ~(1u << port_No(port));
|
|
|
|
rc_out(bp, RC_DTR, bp->DTR);
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
2008-04-30 11:54:15 +04:00
|
|
|
* Now we must calculate some speed depended things
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Set baud rate for port */
|
2006-10-01 10:27:24 +04:00
|
|
|
tmp = (((RC_OSCFREQ + baud/2) / baud +
|
2005-04-17 02:20:36 +04:00
|
|
|
CD180_TPC/2) / CD180_TPC);
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
rc_out(bp, CD180_RBPRH, (tmp >> 8) & 0xff);
|
|
|
|
rc_out(bp, CD180_TBPRH, (tmp >> 8) & 0xff);
|
|
|
|
rc_out(bp, CD180_RBPRL, tmp & 0xff);
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_out(bp, CD180_TBPRL, tmp & 0xff);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2006-10-01 10:27:24 +04:00
|
|
|
baud = (baud + 5) / 10; /* Estimated CPS */
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Two timer ticks seems enough to wakeup something like SLIP driver */
|
2008-04-30 11:54:15 +04:00
|
|
|
tmp = ((baud + HZ/2) / HZ) * 2 - CD180_NFIFO;
|
2005-04-17 02:20:36 +04:00
|
|
|
port->wakeup_chars = (tmp < 0) ? 0 : ((tmp >= SERIAL_XMIT_SIZE) ?
|
|
|
|
SERIAL_XMIT_SIZE - 1 : tmp);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Receiver timeout will be transmission time for 1.5 chars */
|
|
|
|
tmp = (RISCOM_TPS + RISCOM_TPS/2 + baud/2) / baud;
|
|
|
|
tmp = (tmp > 0xff) ? 0xff : tmp;
|
|
|
|
rc_out(bp, CD180_RTPR, tmp);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
switch (C_CSIZE(tty)) {
|
|
|
|
case CS5:
|
2005-04-17 02:20:36 +04:00
|
|
|
cor1 |= COR1_5BITS;
|
|
|
|
break;
|
2008-04-30 11:54:15 +04:00
|
|
|
case CS6:
|
2005-04-17 02:20:36 +04:00
|
|
|
cor1 |= COR1_6BITS;
|
|
|
|
break;
|
2008-04-30 11:54:15 +04:00
|
|
|
case CS7:
|
2005-04-17 02:20:36 +04:00
|
|
|
cor1 |= COR1_7BITS;
|
|
|
|
break;
|
2008-04-30 11:54:15 +04:00
|
|
|
case CS8:
|
2005-04-17 02:20:36 +04:00
|
|
|
cor1 |= COR1_8BITS;
|
|
|
|
break;
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
if (C_CSTOPB(tty))
|
2005-04-17 02:20:36 +04:00
|
|
|
cor1 |= COR1_2SB;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
cor1 |= COR1_IGNORE;
|
2008-04-30 11:54:15 +04:00
|
|
|
if (C_PARENB(tty)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
cor1 |= COR1_NORMPAR;
|
2008-04-30 11:54:15 +04:00
|
|
|
if (C_PARODD(tty))
|
2005-04-17 02:20:36 +04:00
|
|
|
cor1 |= COR1_ODDP;
|
2008-04-30 11:54:15 +04:00
|
|
|
if (I_INPCK(tty))
|
2005-04-17 02:20:36 +04:00
|
|
|
cor1 &= ~COR1_IGNORE;
|
|
|
|
}
|
|
|
|
/* Set marking of some errors */
|
|
|
|
port->mark_mask = RCSR_OE | RCSR_TOUT;
|
2008-04-30 11:54:15 +04:00
|
|
|
if (I_INPCK(tty))
|
2005-04-17 02:20:36 +04:00
|
|
|
port->mark_mask |= RCSR_FE | RCSR_PE;
|
2008-04-30 11:54:15 +04:00
|
|
|
if (I_BRKINT(tty) || I_PARMRK(tty))
|
2005-04-17 02:20:36 +04:00
|
|
|
port->mark_mask |= RCSR_BREAK;
|
2008-04-30 11:54:15 +04:00
|
|
|
if (I_IGNPAR(tty))
|
2005-04-17 02:20:36 +04:00
|
|
|
port->mark_mask &= ~(RCSR_FE | RCSR_PE);
|
2008-04-30 11:54:15 +04:00
|
|
|
if (I_IGNBRK(tty)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
port->mark_mask &= ~RCSR_BREAK;
|
2008-04-30 11:54:15 +04:00
|
|
|
if (I_IGNPAR(tty))
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Real raw mode. Ignore all */
|
|
|
|
port->mark_mask &= ~RCSR_OE;
|
|
|
|
}
|
|
|
|
/* Enable Hardware Flow Control */
|
|
|
|
if (C_CRTSCTS(tty)) {
|
|
|
|
#ifdef RISCOM_BRAIN_DAMAGED_CTS
|
|
|
|
port->IER |= IER_DSR | IER_CTS;
|
|
|
|
mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
|
|
|
|
mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
|
2008-04-30 11:54:15 +04:00
|
|
|
tty->hw_stopped = !(rc_in(bp, CD180_MSVR) &
|
|
|
|
(MSVR_CTS|MSVR_DSR));
|
2005-04-17 02:20:36 +04:00
|
|
|
#else
|
|
|
|
port->COR2 |= COR2_CTSAE;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/* Enable Software Flow Control. FIXME: I'm not sure about this */
|
|
|
|
/* Some people reported that it works, but I still doubt */
|
|
|
|
if (I_IXON(tty)) {
|
|
|
|
port->COR2 |= COR2_TXIBE;
|
|
|
|
cor3 |= (COR3_FCT | COR3_SCDE);
|
|
|
|
if (I_IXANY(tty))
|
|
|
|
port->COR2 |= COR2_IXM;
|
|
|
|
rc_out(bp, CD180_SCHR1, START_CHAR(tty));
|
|
|
|
rc_out(bp, CD180_SCHR2, STOP_CHAR(tty));
|
|
|
|
rc_out(bp, CD180_SCHR3, START_CHAR(tty));
|
|
|
|
rc_out(bp, CD180_SCHR4, STOP_CHAR(tty));
|
|
|
|
}
|
|
|
|
if (!C_CLOCAL(tty)) {
|
|
|
|
/* Enable CD check */
|
|
|
|
port->IER |= IER_CD;
|
|
|
|
mcor1 |= MCOR1_CDZD;
|
|
|
|
mcor2 |= MCOR2_CDOD;
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
if (C_CREAD(tty))
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Enable receiver */
|
|
|
|
port->IER |= IER_RXD;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Set input FIFO size (1-8 bytes) */
|
2008-04-30 11:54:15 +04:00
|
|
|
cor3 |= RISCOM_RXFIFO;
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Setting up CD180 channel registers */
|
|
|
|
rc_out(bp, CD180_COR1, cor1);
|
|
|
|
rc_out(bp, CD180_COR2, port->COR2);
|
|
|
|
rc_out(bp, CD180_COR3, cor3);
|
|
|
|
/* Make CD180 know about registers change */
|
|
|
|
rc_wait_CCR(bp);
|
|
|
|
rc_out(bp, CD180_CCR, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
|
|
|
|
/* Setting up modem option registers */
|
|
|
|
rc_out(bp, CD180_MCOR1, mcor1);
|
|
|
|
rc_out(bp, CD180_MCOR2, mcor2);
|
|
|
|
/* Enable CD180 transmitter & receiver */
|
|
|
|
rc_wait_CCR(bp);
|
|
|
|
rc_out(bp, CD180_CCR, CCR_TXEN | CCR_RXEN);
|
|
|
|
/* Enable interrupts */
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
|
|
|
/* And finally set RTS on */
|
|
|
|
rc_out(bp, CD180_MSVR, port->MSVR);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Must be called with interrupts enabled */
|
|
|
|
static int rc_setup_port(struct riscom_board *bp, struct riscom_port *port)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
if (port->port.flags & ASYNC_INITIALIZED)
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
if (tty_port_alloc_xmit_buf(&port->port) < 0)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
|
|
|
|
2008-07-17 00:55:37 +04:00
|
|
|
clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
|
2008-07-17 00:55:29 +04:00
|
|
|
if (port->port.count == 1)
|
2005-04-17 02:20:36 +04:00
|
|
|
bp->count++;
|
|
|
|
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
|
|
|
|
rc_change_speed(bp, port);
|
2008-07-17 00:55:29 +04:00
|
|
|
port->port.flags |= ASYNC_INITIALIZED;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Must be called with interrupts disabled */
|
2008-07-17 00:55:37 +04:00
|
|
|
static void rc_shutdown_port(struct tty_struct *tty,
|
|
|
|
struct riscom_board *bp, struct riscom_port *port)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2008-07-17 00:55:29 +04:00
|
|
|
if (!(port->port.flags & ASYNC_INITIALIZED))
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef RC_REPORT_OVERRUN
|
|
|
|
printk(KERN_INFO "rc%d: port %d: Total %ld overruns were detected.\n",
|
|
|
|
board_No(bp), port_No(port), port->overrun);
|
2008-04-30 11:54:15 +04:00
|
|
|
#endif
|
2005-04-17 02:20:36 +04:00
|
|
|
#ifdef RC_REPORT_FIFO
|
|
|
|
{
|
|
|
|
int i;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
printk(KERN_INFO "rc%d: port %d: FIFO hits [ ",
|
|
|
|
board_No(bp), port_No(port));
|
2008-04-30 11:54:15 +04:00
|
|
|
for (i = 0; i < 10; i++)
|
2005-04-17 02:20:36 +04:00
|
|
|
printk("%ld ", port->hits[i]);
|
|
|
|
printk("].\n");
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
#endif
|
2008-07-17 00:55:29 +04:00
|
|
|
tty_port_free_xmit_buf(&port->port);
|
2008-07-17 00:55:37 +04:00
|
|
|
if (C_HUPCL(tty)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
/* Drop DTR */
|
|
|
|
bp->DTR |= (1u << port_No(port));
|
|
|
|
rc_out(bp, RC_DTR, bp->DTR);
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
/* Select port */
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
/* Reset port */
|
|
|
|
rc_wait_CCR(bp);
|
|
|
|
rc_out(bp, CD180_CCR, CCR_SOFTRESET);
|
|
|
|
/* Disable all interrupts from this port */
|
|
|
|
port->IER = 0;
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-07-17 00:55:37 +04:00
|
|
|
set_bit(TTY_IO_ERROR, &tty->flags);
|
2008-07-17 00:55:29 +04:00
|
|
|
port->port.flags &= ~ASYNC_INITIALIZED;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (--bp->count < 0) {
|
|
|
|
printk(KERN_INFO "rc%d: rc_shutdown_port: "
|
|
|
|
"bad board count: %d\n",
|
|
|
|
board_No(bp), bp->count);
|
|
|
|
bp->count = 0;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If this is the last opened port on the board
|
|
|
|
* shutdown whole board
|
|
|
|
*/
|
2008-04-30 11:54:15 +04:00
|
|
|
if (!bp->count)
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_shutdown_board(bp);
|
|
|
|
}
|
|
|
|
|
2009-01-02 16:45:05 +03:00
|
|
|
static int carrier_raised(struct tty_port *port)
|
|
|
|
{
|
|
|
|
struct riscom_port *p = container_of(port, struct riscom_port, port);
|
|
|
|
struct riscom_board *bp = port_Board(p);
|
|
|
|
unsigned long flags;
|
|
|
|
int CD;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
|
|
|
rc_out(bp, CD180_CAR, port_No(p));
|
|
|
|
CD = rc_in(bp, CD180_MSVR) & MSVR_CD;
|
|
|
|
rc_out(bp, CD180_MSVR, MSVR_RTS);
|
|
|
|
bp->DTR &= ~(1u << port_No(p));
|
|
|
|
rc_out(bp, RC_DTR, bp->DTR);
|
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
|
|
|
return CD;
|
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static int rc_open(struct tty_struct *tty, struct file *filp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int board;
|
|
|
|
int error;
|
2008-04-30 11:54:15 +04:00
|
|
|
struct riscom_port *port;
|
|
|
|
struct riscom_board *bp;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
board = RC_BOARD(tty->index);
|
|
|
|
if (board >= RC_NBOARD || !(rc_board[board].flags & RC_BOARD_PRESENT))
|
|
|
|
return -ENODEV;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
bp = &rc_board[board];
|
|
|
|
port = rc_port + board * RC_NPORT + RC_PORT(tty->index);
|
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_open"))
|
|
|
|
return -ENODEV;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
error = rc_setup_board(bp);
|
|
|
|
if (error)
|
2005-04-17 02:20:36 +04:00
|
|
|
return error;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
port->port.count++;
|
2005-04-17 02:20:36 +04:00
|
|
|
tty->driver_data = port;
|
2008-07-17 00:55:29 +04:00
|
|
|
port->port.tty = tty;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
error = rc_setup_port(bp, port);
|
|
|
|
if (error == 0)
|
2009-01-02 16:46:10 +03:00
|
|
|
error = tty_port_block_til_ready(&port->port, tty, filp);
|
2008-04-30 11:54:15 +04:00
|
|
|
return error;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:53:59 +04:00
|
|
|
static void rc_flush_buffer(struct tty_struct *tty)
|
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2008-04-30 11:53:59 +04:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
|
|
|
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
|
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
|
|
|
|
|
|
|
tty_wakeup(tty);
|
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_close(struct tty_struct *tty, struct file *filp)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct riscom_board *bp;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long timeout;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!port || rc_paranoia_check(port, tty->name, "close"))
|
|
|
|
return;
|
2008-02-06 12:36:11 +03:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
bp = port_Board(port);
|
2009-01-02 16:46:50 +03:00
|
|
|
|
|
|
|
if (tty_port_close_start(&port->port, tty, filp) == 0)
|
|
|
|
return;
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2009-01-02 16:45:50 +03:00
|
|
|
|
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
port->IER &= ~IER_RXD;
|
2008-07-17 00:55:29 +04:00
|
|
|
if (port->port.flags & ASYNC_INITIALIZED) {
|
2005-04-17 02:20:36 +04:00
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
port->IER |= IER_TXEMPTY;
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
|
|
|
/*
|
|
|
|
* Before we drop DTR, make sure the UART transmitter
|
|
|
|
* has completely drained; this is especially
|
|
|
|
* important if there is a transmit FIFO!
|
|
|
|
*/
|
2008-04-30 11:54:15 +04:00
|
|
|
timeout = jiffies + HZ;
|
|
|
|
while (port->IER & IER_TXEMPTY) {
|
2009-01-02 16:45:50 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
msleep_interruptible(jiffies_to_msecs(port->timeout));
|
2009-01-02 16:45:50 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
if (time_after(jiffies, timeout))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-07-17 00:55:37 +04:00
|
|
|
rc_shutdown_port(tty, bp, port);
|
2008-04-30 11:53:59 +04:00
|
|
|
rc_flush_buffer(tty);
|
2009-01-02 16:45:50 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2008-02-06 12:36:11 +03:00
|
|
|
|
2009-01-02 16:46:50 +03:00
|
|
|
tty_port_close_end(&port->port, tty);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static int rc_write(struct tty_struct *tty,
|
2005-04-17 02:20:36 +04:00
|
|
|
const unsigned char *buf, int count)
|
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct riscom_board *bp;
|
|
|
|
int c, total = 0;
|
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_write"))
|
|
|
|
return 0;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
bp = port_Board(port);
|
|
|
|
|
|
|
|
while (1) {
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
|
|
|
|
SERIAL_XMIT_SIZE - port->xmit_head));
|
2008-02-06 12:36:11 +03:00
|
|
|
if (c <= 0)
|
|
|
|
break; /* lock continues to be held */
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
memcpy(port->port.xmit_buf + port->xmit_head, buf, c);
|
2005-04-17 02:20:36 +04:00
|
|
|
port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
|
|
|
|
port->xmit_cnt += c;
|
2008-02-06 12:36:11 +03:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
buf += c;
|
|
|
|
count -= c;
|
|
|
|
total += c;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
|
|
|
|
!(port->IER & IER_TXRDY)) {
|
|
|
|
port->IER |= IER_TXRDY;
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
|
|
|
}
|
2008-02-06 12:36:11 +03:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static int rc_put_char(struct tty_struct *tty, unsigned char ch)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned long flags;
|
2008-04-30 11:54:05 +04:00
|
|
|
int ret = 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_put_char"))
|
2008-04-30 11:54:05 +04:00
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1)
|
|
|
|
goto out;
|
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
port->port.xmit_buf[port->xmit_head++] = ch;
|
2005-04-17 02:20:36 +04:00
|
|
|
port->xmit_head &= SERIAL_XMIT_SIZE - 1;
|
|
|
|
port->xmit_cnt++;
|
2008-04-30 11:54:05 +04:00
|
|
|
ret = 1;
|
2008-02-06 12:36:11 +03:00
|
|
|
|
|
|
|
out:
|
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2008-04-30 11:54:05 +04:00
|
|
|
return ret;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_flush_chars(struct tty_struct *tty)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_flush_chars"))
|
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-07-17 00:55:37 +04:00
|
|
|
if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped)
|
2005-04-17 02:20:36 +04:00
|
|
|
return;
|
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
port->IER |= IER_TXRDY;
|
|
|
|
rc_out(port_Board(port), CD180_CAR, port_No(port));
|
|
|
|
rc_out(port_Board(port), CD180_IER, port->IER);
|
2008-02-06 12:36:11 +03:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static int rc_write_room(struct tty_struct *tty)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
int ret;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_write_room"))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
|
|
|
|
if (ret < 0)
|
|
|
|
ret = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rc_chars_in_buffer(struct tty_struct *tty)
|
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer"))
|
|
|
|
return 0;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
return port->xmit_cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rc_tiocmget(struct tty_struct *tty, struct file *file)
|
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2008-04-30 11:54:15 +04:00
|
|
|
struct riscom_board *bp;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned char status;
|
|
|
|
unsigned int result;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2008-04-30 11:55:10 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, __func__))
|
2005-04-17 02:20:36 +04:00
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
bp = port_Board(port);
|
2008-02-06 12:36:11 +03:00
|
|
|
|
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
status = rc_in(bp, CD180_MSVR);
|
|
|
|
result = rc_in(bp, RC_RI) & (1u << port_No(port)) ? 0 : TIOCM_RNG;
|
2008-02-06 12:36:11 +03:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
result |= ((status & MSVR_RTS) ? TIOCM_RTS : 0)
|
|
|
|
| ((status & MSVR_DTR) ? TIOCM_DTR : 0)
|
|
|
|
| ((status & MSVR_CD) ? TIOCM_CAR : 0)
|
|
|
|
| ((status & MSVR_DSR) ? TIOCM_DSR : 0)
|
|
|
|
| ((status & MSVR_CTS) ? TIOCM_CTS : 0);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rc_tiocmset(struct tty_struct *tty, struct file *file,
|
|
|
|
unsigned int set, unsigned int clear)
|
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned long flags;
|
|
|
|
struct riscom_board *bp;
|
|
|
|
|
2008-04-30 11:55:10 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, __func__))
|
2005-04-17 02:20:36 +04:00
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
bp = port_Board(port);
|
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (set & TIOCM_RTS)
|
|
|
|
port->MSVR |= MSVR_RTS;
|
|
|
|
if (set & TIOCM_DTR)
|
|
|
|
bp->DTR &= ~(1u << port_No(port));
|
|
|
|
|
|
|
|
if (clear & TIOCM_RTS)
|
|
|
|
port->MSVR &= ~MSVR_RTS;
|
|
|
|
if (clear & TIOCM_DTR)
|
|
|
|
bp->DTR |= (1u << port_No(port));
|
|
|
|
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
rc_out(bp, CD180_MSVR, port->MSVR);
|
|
|
|
rc_out(bp, RC_DTR, bp->DTR);
|
2008-02-06 12:36:11 +03:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-07-22 14:18:30 +04:00
|
|
|
static int rc_send_break(struct tty_struct *tty, int length)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct riscom_board *bp = port_Board(port);
|
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-07-22 14:18:30 +04:00
|
|
|
if (length == 0 || length == -1)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
port->break_length = RISCOM_TPS / HZ * length;
|
|
|
|
port->COR2 |= COR2_ETC;
|
|
|
|
port->IER |= IER_TXRDY;
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
rc_out(bp, CD180_COR2, port->COR2);
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
|
|
|
rc_wait_CCR(bp);
|
|
|
|
rc_out(bp, CD180_CCR, CCR_CORCHG2);
|
|
|
|
rc_wait_CCR(bp);
|
2008-02-06 12:36:11 +03:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2008-07-22 14:18:30 +04:00
|
|
|
return 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static int rc_set_serial_info(struct riscom_port *port,
|
|
|
|
struct serial_struct __user *newinfo)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct serial_struct tmp;
|
|
|
|
struct riscom_board *bp = port_Board(port);
|
|
|
|
int change_speed;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (copy_from_user(&tmp, newinfo, sizeof(tmp)))
|
|
|
|
return -EFAULT;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
#if 0
|
2005-04-17 02:20:36 +04:00
|
|
|
if ((tmp.irq != bp->irq) ||
|
|
|
|
(tmp.port != bp->base) ||
|
|
|
|
(tmp.type != PORT_CIRRUS) ||
|
|
|
|
(tmp.baud_base != (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC) ||
|
|
|
|
(tmp.custom_divisor != 0) ||
|
|
|
|
(tmp.xmit_fifo_size != CD180_NFIFO) ||
|
|
|
|
(tmp.flags & ~RISCOM_LEGAL_FLAGS))
|
|
|
|
return -EINVAL;
|
2008-04-30 11:54:15 +04:00
|
|
|
#endif
|
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
change_speed = ((port->port.flags & ASYNC_SPD_MASK) !=
|
2005-04-17 02:20:36 +04:00
|
|
|
(tmp.flags & ASYNC_SPD_MASK));
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (!capable(CAP_SYS_ADMIN)) {
|
2008-07-17 00:57:18 +04:00
|
|
|
if ((tmp.close_delay != port->port.close_delay) ||
|
|
|
|
(tmp.closing_wait != port->port.closing_wait) ||
|
2005-04-17 02:20:36 +04:00
|
|
|
((tmp.flags & ~ASYNC_USR_MASK) !=
|
2008-07-17 00:55:29 +04:00
|
|
|
(port->port.flags & ~ASYNC_USR_MASK)))
|
2005-04-17 02:20:36 +04:00
|
|
|
return -EPERM;
|
2008-07-17 00:55:29 +04:00
|
|
|
port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
|
2005-04-17 02:20:36 +04:00
|
|
|
(tmp.flags & ASYNC_USR_MASK));
|
|
|
|
} else {
|
2008-07-17 00:55:29 +04:00
|
|
|
port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
|
2005-04-17 02:20:36 +04:00
|
|
|
(tmp.flags & ASYNC_FLAGS));
|
2008-07-17 00:57:18 +04:00
|
|
|
port->port.close_delay = tmp.close_delay;
|
|
|
|
port->port.closing_wait = tmp.closing_wait;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
if (change_speed) {
|
2008-02-06 12:36:11 +03:00
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_change_speed(bp, port);
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static int rc_get_serial_info(struct riscom_port *port,
|
2005-04-17 02:20:36 +04:00
|
|
|
struct serial_struct __user *retinfo)
|
|
|
|
{
|
|
|
|
struct serial_struct tmp;
|
|
|
|
struct riscom_board *bp = port_Board(port);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
memset(&tmp, 0, sizeof(tmp));
|
|
|
|
tmp.type = PORT_CIRRUS;
|
|
|
|
tmp.line = port - rc_port;
|
|
|
|
tmp.port = bp->base;
|
|
|
|
tmp.irq = bp->irq;
|
2008-07-17 00:55:29 +04:00
|
|
|
tmp.flags = port->port.flags;
|
2005-04-17 02:20:36 +04:00
|
|
|
tmp.baud_base = (RC_OSCFREQ + CD180_TPC/2) / CD180_TPC;
|
2008-07-17 00:57:18 +04:00
|
|
|
tmp.close_delay = port->port.close_delay * HZ/100;
|
|
|
|
tmp.closing_wait = port->port.closing_wait * HZ/100;
|
2005-04-17 02:20:36 +04:00
|
|
|
tmp.xmit_fifo_size = CD180_NFIFO;
|
|
|
|
return copy_to_user(retinfo, &tmp, sizeof(tmp)) ? -EFAULT : 0;
|
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static int rc_ioctl(struct tty_struct *tty, struct file *filp,
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int cmd, unsigned long arg)
|
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
void __user *argp = (void __user *)arg;
|
2008-07-22 14:18:30 +04:00
|
|
|
int retval;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
|
|
|
|
return -ENODEV;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
switch (cmd) {
|
2008-04-30 11:54:15 +04:00
|
|
|
case TIOCGSERIAL:
|
|
|
|
lock_kernel();
|
2008-04-30 11:53:21 +04:00
|
|
|
retval = rc_get_serial_info(port, argp);
|
|
|
|
unlock_kernel();
|
2005-04-17 02:20:36 +04:00
|
|
|
break;
|
2008-04-30 11:54:15 +04:00
|
|
|
case TIOCSSERIAL:
|
|
|
|
lock_kernel();
|
2008-04-30 11:53:21 +04:00
|
|
|
retval = rc_set_serial_info(port, argp);
|
|
|
|
unlock_kernel();
|
|
|
|
break;
|
2008-04-30 11:54:15 +04:00
|
|
|
default:
|
2008-04-30 11:53:21 +04:00
|
|
|
retval = -ENOIOCTLCMD;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
2008-04-30 11:53:21 +04:00
|
|
|
return retval;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_throttle(struct tty_struct *tty)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct riscom_board *bp;
|
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_throttle"))
|
|
|
|
return;
|
|
|
|
bp = port_Board(port);
|
2008-02-06 12:36:11 +03:00
|
|
|
|
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
port->MSVR &= ~MSVR_RTS;
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
2008-02-06 12:36:11 +03:00
|
|
|
if (I_IXOFF(tty)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_wait_CCR(bp);
|
|
|
|
rc_out(bp, CD180_CCR, CCR_SSCH2);
|
|
|
|
rc_wait_CCR(bp);
|
|
|
|
}
|
|
|
|
rc_out(bp, CD180_MSVR, port->MSVR);
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_unthrottle(struct tty_struct *tty)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct riscom_board *bp;
|
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_unthrottle"))
|
|
|
|
return;
|
|
|
|
bp = port_Board(port);
|
2008-02-06 12:36:11 +03:00
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
port->MSVR |= MSVR_RTS;
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
if (I_IXOFF(tty)) {
|
|
|
|
rc_wait_CCR(bp);
|
|
|
|
rc_out(bp, CD180_CCR, CCR_SSCH1);
|
|
|
|
rc_wait_CCR(bp);
|
|
|
|
}
|
|
|
|
rc_out(bp, CD180_MSVR, port->MSVR);
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_stop(struct tty_struct *tty)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct riscom_board *bp;
|
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_stop"))
|
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
bp = port_Board(port);
|
2008-02-06 12:36:11 +03:00
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_start(struct tty_struct *tty)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct riscom_board *bp;
|
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_start"))
|
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
bp = port_Board(port);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
|
|
|
|
2008-07-17 00:55:29 +04:00
|
|
|
if (port->xmit_cnt && port->port.xmit_buf && !(port->IER & IER_TXRDY)) {
|
2005-04-17 02:20:36 +04:00
|
|
|
port->IER |= IER_TXRDY;
|
|
|
|
rc_out(bp, CD180_CAR, port_No(port));
|
|
|
|
rc_out(bp, CD180_IER, port->IER);
|
|
|
|
}
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_hangup(struct tty_struct *tty)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct riscom_board *bp;
|
2009-01-02 16:45:50 +03:00
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_hangup"))
|
|
|
|
return;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
bp = port_Board(port);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2008-07-17 00:55:37 +04:00
|
|
|
rc_shutdown_port(tty, bp, port);
|
2009-01-02 16:45:50 +03:00
|
|
|
spin_lock_irqsave(&port->port.lock, flags);
|
2008-07-17 00:55:29 +04:00
|
|
|
port->port.count = 0;
|
|
|
|
port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
|
|
|
|
port->port.tty = NULL;
|
|
|
|
wake_up_interruptible(&port->port.open_wait);
|
2009-01-02 16:45:50 +03:00
|
|
|
spin_unlock_irqrestore(&port->port.lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
static void rc_set_termios(struct tty_struct *tty,
|
|
|
|
struct ktermios *old_termios)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2009-01-02 16:47:26 +03:00
|
|
|
struct riscom_port *port = tty->driver_data;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned long flags;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
if (rc_paranoia_check(port, tty->name, "rc_set_termios"))
|
|
|
|
return;
|
|
|
|
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_lock_irqsave(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_change_speed(port_Board(port), port);
|
2008-02-06 12:36:11 +03:00
|
|
|
spin_unlock_irqrestore(&riscom_lock, flags);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
if ((old_termios->c_cflag & CRTSCTS) &&
|
|
|
|
!(tty->termios->c_cflag & CRTSCTS)) {
|
|
|
|
tty->hw_stopped = 0;
|
|
|
|
rc_start(tty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-02 13:17:18 +04:00
|
|
|
static const struct tty_operations riscom_ops = {
|
2005-04-17 02:20:36 +04:00
|
|
|
.open = rc_open,
|
|
|
|
.close = rc_close,
|
|
|
|
.write = rc_write,
|
|
|
|
.put_char = rc_put_char,
|
|
|
|
.flush_chars = rc_flush_chars,
|
|
|
|
.write_room = rc_write_room,
|
|
|
|
.chars_in_buffer = rc_chars_in_buffer,
|
|
|
|
.flush_buffer = rc_flush_buffer,
|
|
|
|
.ioctl = rc_ioctl,
|
|
|
|
.throttle = rc_throttle,
|
|
|
|
.unthrottle = rc_unthrottle,
|
|
|
|
.set_termios = rc_set_termios,
|
|
|
|
.stop = rc_stop,
|
|
|
|
.start = rc_start,
|
|
|
|
.hangup = rc_hangup,
|
|
|
|
.tiocmget = rc_tiocmget,
|
|
|
|
.tiocmset = rc_tiocmset,
|
2008-07-22 14:18:30 +04:00
|
|
|
.break_ctl = rc_send_break,
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
2009-01-02 16:45:05 +03:00
|
|
|
static const struct tty_port_operations riscom_port_ops = {
|
|
|
|
.carrier_raised = carrier_raised,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-02-07 11:16:36 +03:00
|
|
|
static int __init rc_init_drivers(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
riscom_driver = alloc_tty_driver(RC_NBOARD * RC_NPORT);
|
2008-04-30 11:54:15 +04:00
|
|
|
if (!riscom_driver)
|
2005-04-17 02:20:36 +04:00
|
|
|
return -ENOMEM;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
riscom_driver->owner = THIS_MODULE;
|
|
|
|
riscom_driver->name = "ttyL";
|
|
|
|
riscom_driver->major = RISCOM8_NORMAL_MAJOR;
|
|
|
|
riscom_driver->type = TTY_DRIVER_TYPE_SERIAL;
|
|
|
|
riscom_driver->subtype = SERIAL_TYPE_NORMAL;
|
|
|
|
riscom_driver->init_termios = tty_std_termios;
|
|
|
|
riscom_driver->init_termios.c_cflag =
|
|
|
|
B9600 | CS8 | CREAD | HUPCL | CLOCAL;
|
2006-12-08 13:38:45 +03:00
|
|
|
riscom_driver->init_termios.c_ispeed = 9600;
|
|
|
|
riscom_driver->init_termios.c_ospeed = 9600;
|
2008-07-22 14:18:30 +04:00
|
|
|
riscom_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_HARDWARE_BREAK;
|
2005-04-17 02:20:36 +04:00
|
|
|
tty_set_operations(riscom_driver, &riscom_ops);
|
2008-04-30 11:54:15 +04:00
|
|
|
error = tty_register_driver(riscom_driver);
|
|
|
|
if (error != 0) {
|
2005-04-17 02:20:36 +04:00
|
|
|
put_tty_driver(riscom_driver);
|
|
|
|
printk(KERN_ERR "rc: Couldn't register RISCom/8 driver, "
|
2008-04-30 11:54:15 +04:00
|
|
|
"error = %d\n", error);
|
2005-04-17 02:20:36 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
memset(rc_port, 0, sizeof(rc_port));
|
|
|
|
for (i = 0; i < RC_NPORT * RC_NBOARD; i++) {
|
2008-07-17 00:55:29 +04:00
|
|
|
tty_port_init(&rc_port[i].port);
|
2009-01-02 16:45:05 +03:00
|
|
|
rc_port[i].port.ops = &riscom_port_ops;
|
2008-07-17 00:57:18 +04:00
|
|
|
rc_port[i].magic = RISCOM8_MAGIC;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rc_release_drivers(void)
|
|
|
|
{
|
|
|
|
tty_unregister_driver(riscom_driver);
|
|
|
|
put_tty_driver(riscom_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef MODULE
|
|
|
|
/*
|
|
|
|
* Called at boot time.
|
2008-04-30 11:54:15 +04:00
|
|
|
*
|
2005-04-17 02:20:36 +04:00
|
|
|
* You can specify IO base for up to RC_NBOARD cards,
|
|
|
|
* using line "riscom8=0xiobase1,0xiobase2,.." at LILO prompt.
|
|
|
|
* Note that there will be no probing at default
|
|
|
|
* addresses in this case.
|
|
|
|
*
|
2008-04-30 11:54:15 +04:00
|
|
|
*/
|
2005-04-17 02:20:36 +04:00
|
|
|
static int __init riscom8_setup(char *str)
|
|
|
|
{
|
|
|
|
int ints[RC_NBOARD];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
str = get_options(str, ARRAY_SIZE(ints), ints);
|
|
|
|
|
|
|
|
for (i = 0; i < RC_NBOARD; i++) {
|
|
|
|
if (i < ints[0])
|
|
|
|
rc_board[i].base = ints[i+1];
|
2008-04-30 11:54:15 +04:00
|
|
|
else
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_board[i].base = 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__setup("riscom8=", riscom8_setup);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static char banner[] __initdata =
|
|
|
|
KERN_INFO "rc: SDL RISCom/8 card driver v1.1, (c) D.Gorodchanin "
|
|
|
|
"1994-1996.\n";
|
|
|
|
static char no_boards_msg[] __initdata =
|
|
|
|
KERN_INFO "rc: No RISCom/8 boards detected.\n";
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
/*
|
|
|
|
* This routine must be called by kernel at boot time
|
2005-04-17 02:20:36 +04:00
|
|
|
*/
|
|
|
|
static int __init riscom8_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
printk(banner);
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
if (rc_init_drivers())
|
2005-04-17 02:20:36 +04:00
|
|
|
return -EIO;
|
|
|
|
|
2008-04-30 11:54:15 +04:00
|
|
|
for (i = 0; i < RC_NBOARD; i++)
|
|
|
|
if (rc_board[i].base && !rc_probe(&rc_board[i]))
|
2005-04-17 02:20:36 +04:00
|
|
|
found++;
|
|
|
|
if (!found) {
|
|
|
|
rc_release_drivers();
|
|
|
|
printk(no_boards_msg);
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MODULE
|
|
|
|
static int iobase;
|
|
|
|
static int iobase1;
|
|
|
|
static int iobase2;
|
|
|
|
static int iobase3;
|
2006-03-25 14:07:05 +03:00
|
|
|
module_param(iobase, int, 0);
|
|
|
|
module_param(iobase1, int, 0);
|
|
|
|
module_param(iobase2, int, 0);
|
|
|
|
module_param(iobase3, int, 0);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
#endif /* MODULE */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* You can setup up to 4 boards (current value of RC_NBOARD)
|
|
|
|
* by specifying "iobase=0xXXX iobase1=0xXXX ..." as insmod parameter.
|
|
|
|
*
|
|
|
|
*/
|
2008-04-30 11:54:15 +04:00
|
|
|
static int __init riscom8_init_module(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
#ifdef MODULE
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (iobase || iobase1 || iobase2 || iobase3) {
|
2008-04-30 11:54:15 +04:00
|
|
|
for (i = 0; i < RC_NBOARD; i++)
|
2008-03-13 22:32:39 +03:00
|
|
|
rc_board[i].base = 0;
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (iobase)
|
|
|
|
rc_board[0].base = iobase;
|
|
|
|
if (iobase1)
|
|
|
|
rc_board[1].base = iobase1;
|
|
|
|
if (iobase2)
|
|
|
|
rc_board[2].base = iobase2;
|
|
|
|
if (iobase3)
|
|
|
|
rc_board[3].base = iobase3;
|
|
|
|
#endif /* MODULE */
|
|
|
|
|
|
|
|
return riscom8_init();
|
|
|
|
}
|
2008-04-30 11:54:15 +04:00
|
|
|
|
|
|
|
static void __exit riscom8_exit_module(void)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
int i;
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_release_drivers();
|
2008-04-30 11:54:15 +04:00
|
|
|
for (i = 0; i < RC_NBOARD; i++)
|
|
|
|
if (rc_board[i].flags & RC_BOARD_PRESENT)
|
2005-04-17 02:20:36 +04:00
|
|
|
rc_release_io_range(&rc_board[i]);
|
2008-04-30 11:54:15 +04:00
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(riscom8_init_module);
|
|
|
|
module_exit(riscom8_exit_module);
|