2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* specialix.c -- specialix IO8+ multiport serial driver.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1997 Roger Wolff (R.E.Wolff@BitWizard.nl)
|
|
|
|
* Copyright (C) 1994-1996 Dmitry Gorodchanin (pgmdsg@ibi.com)
|
|
|
|
*
|
|
|
|
* Specialix pays for the development and support of this driver.
|
|
|
|
* Please DO contact io8-linux@specialix.co.uk if you require
|
|
|
|
* support. But please read the documentation (specialix.txt)
|
|
|
|
* first.
|
|
|
|
*
|
|
|
|
* This driver was developped in the BitWizard linux device
|
|
|
|
* driver service. If you require a linux device driver for your
|
|
|
|
* product, please contact devices@BitWizard.nl for a quote.
|
|
|
|
*
|
|
|
|
* This code is firmly based on the riscom/8 serial driver,
|
|
|
|
* written by Dmitry Gorodchanin. The specialix IO8+ card
|
|
|
|
* programming information was obtained from the CL-CD1865 Data
|
|
|
|
* Book, and Specialix document number 6200059: IO8+ Hardware
|
|
|
|
* Functional Specification.
|
|
|
|
*
|
|
|
|
* 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 history:
|
|
|
|
*
|
|
|
|
* Revision 1.0: April 1st 1997.
|
|
|
|
* Initial release for alpha testing.
|
2005-10-31 00:01:51 +01:00
|
|
|
* Revision 1.1: April 14th 1997.
|
|
|
|
* Incorporated Richard Hudsons suggestions,
|
2005-04-17 00:20:36 +02:00
|
|
|
* removed some debugging printk's.
|
|
|
|
* Revision 1.2: April 15th 1997.
|
|
|
|
* Ported to 2.1.x kernels.
|
2005-10-31 00:01:51 +01:00
|
|
|
* Revision 1.3: April 17th 1997
|
|
|
|
* Backported to 2.0. (Compatibility macros).
|
2005-04-17 00:20:36 +02:00
|
|
|
* Revision 1.4: April 18th 1997
|
2005-10-31 00:01:51 +01:00
|
|
|
* Fixed DTR/RTS bug that caused the card to indicate
|
|
|
|
* "don't send data" to a modem after the password prompt.
|
2005-04-17 00:20:36 +02:00
|
|
|
* Fixed bug for premature (fake) interrupts.
|
|
|
|
* Revision 1.5: April 19th 1997
|
2005-10-31 00:01:51 +01:00
|
|
|
* fixed a minor typo in the header file, cleanup a little.
|
2005-04-17 00:20:36 +02:00
|
|
|
* performance warnings are now MAXed at once per minute.
|
|
|
|
* Revision 1.6: May 23 1997
|
|
|
|
* Changed the specialix=... format to include interrupt.
|
|
|
|
* Revision 1.7: May 27 1997
|
|
|
|
* Made many more debug printk's a compile time option.
|
|
|
|
* Revision 1.8: Jul 1 1997
|
|
|
|
* port to linux-2.1.43 kernel.
|
|
|
|
* Revision 1.9: Oct 9 1998
|
|
|
|
* Added stuff for the IO8+/PCI version.
|
2005-10-31 00:01:51 +01:00
|
|
|
* Revision 1.10: Oct 22 1999 / Jan 21 2000.
|
|
|
|
* Added stuff for setserial.
|
2005-04-17 00:20:36 +02:00
|
|
|
* Nicolas Mailhot (Nicolas.Mailhot@email.enst.fr)
|
2005-10-31 00:01:51 +01:00
|
|
|
*
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define VERSION "1.11"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There is a bunch of documentation about the card, jumpers, config
|
|
|
|
* settings, restrictions, cables, device names and numbers in
|
2008-11-13 22:33:24 +01:00
|
|
|
* Documentation/serial/specialix.txt
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
#include <linux/io.h>
|
2005-04-17 00:20:36 +02: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>
|
[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 05:54:13 +01:00
|
|
|
#include <linux/tty_flip.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/serial.h>
|
2009-07-11 20:08:37 +02:00
|
|
|
#include <linux/smp_lock.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/fcntl.h>
|
|
|
|
#include <linux/major.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/init.h>
|
2008-07-22 12:17:05 +02:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#include "specialix_io8.h"
|
|
|
|
#include "cd1865.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
This driver can spew a whole lot of debugging output at you. If you
|
|
|
|
need maximum performance, you should disable the DEBUG define. To
|
|
|
|
aid in debugging in the field, I'm leaving the compile-time debug
|
|
|
|
features enabled, and disable them "runtime". That allows me to
|
|
|
|
instruct people with problems to enable debugging without requiring
|
|
|
|
them to recompile...
|
|
|
|
*/
|
|
|
|
#define DEBUG
|
|
|
|
|
|
|
|
static int sx_debug;
|
|
|
|
static int sx_rxfifo = SPECIALIX_RXFIFO;
|
2008-07-22 12:17:16 +02:00
|
|
|
static int sx_rtscts;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2008-07-22 12:17:05 +02:00
|
|
|
#define dprintk(f, str...) if (sx_debug & f) printk(str)
|
2005-04-17 00:20:36 +02:00
|
|
|
#else
|
|
|
|
#define dprintk(f, str...) /* nothing */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SX_DEBUG_FLOW 0x0001
|
|
|
|
#define SX_DEBUG_DATA 0x0002
|
|
|
|
#define SX_DEBUG_PROBE 0x0004
|
|
|
|
#define SX_DEBUG_CHAN 0x0008
|
|
|
|
#define SX_DEBUG_INIT 0x0010
|
|
|
|
#define SX_DEBUG_RX 0x0020
|
|
|
|
#define SX_DEBUG_TX 0x0040
|
|
|
|
#define SX_DEBUG_IRQ 0x0080
|
|
|
|
#define SX_DEBUG_OPEN 0x0100
|
|
|
|
#define SX_DEBUG_TERMIOS 0x0200
|
|
|
|
#define SX_DEBUG_SIGNALS 0x0400
|
|
|
|
#define SX_DEBUG_FIFO 0x0800
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
#define func_enter() dprintk(SX_DEBUG_FLOW, "io8: enter %s\n", __func__)
|
|
|
|
#define func_exit() dprintk(SX_DEBUG_FLOW, "io8: exit %s\n", __func__)
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Configurable options: */
|
|
|
|
|
|
|
|
/* Am I paranoid or not ? ;-) */
|
|
|
|
#define SPECIALIX_PARANOIA_CHECK
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
/*
|
2005-04-17 00:20:36 +02: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 SX_REPORT_FIFO
|
|
|
|
#undef SX_REPORT_OVERRUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SPECIALIX_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 *specialix_driver;
|
|
|
|
|
|
|
|
static struct specialix_board sx_board[SX_NBOARD] = {
|
|
|
|
{ 0, SX_IOBASE1, 9, },
|
|
|
|
{ 0, SX_IOBASE2, 11, },
|
|
|
|
{ 0, SX_IOBASE3, 12, },
|
|
|
|
{ 0, SX_IOBASE4, 15, },
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct specialix_port sx_port[SX_NBOARD * SX_NPORT];
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static int sx_paranoia_check(struct specialix_port const *port,
|
2005-04-17 00:20:36 +02:00
|
|
|
char *name, const char *routine)
|
|
|
|
{
|
|
|
|
#ifdef SPECIALIX_PARANOIA_CHECK
|
2008-07-22 12:17:05 +02:00
|
|
|
static const char *badmagic = KERN_ERR
|
|
|
|
"sx: Warning: bad specialix port magic number for device %s in %s\n";
|
|
|
|
static const char *badinfo = KERN_ERR
|
|
|
|
"sx: Warning: null specialix port for device %s in %s\n";
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (!port) {
|
|
|
|
printk(badinfo, name, routine);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (port->magic != SPECIALIX_MAGIC) {
|
|
|
|
printk(badmagic, name, routine);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2005-10-31 00:01:51 +01:00
|
|
|
*
|
2005-04-17 00:20:36 +02:00
|
|
|
* Service functions for specialix IO8+ driver.
|
2005-10-31 00:01:51 +01:00
|
|
|
*
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Get board number from pointer */
|
2008-07-22 12:17:05 +02:00
|
|
|
static inline int board_No(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
return bp - sx_board;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Get port number from pointer */
|
2008-07-22 12:17:05 +02:00
|
|
|
static inline int port_No(struct specialix_port const *port)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-10-31 00:01:51 +01:00
|
|
|
return SX_PORT(port - sx_port);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Get pointer to board from pointer to port */
|
2008-07-22 12:17:05 +02:00
|
|
|
static inline struct specialix_board *port_Board(
|
|
|
|
struct specialix_port const *port)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
return &sx_board[SX_BOARD(port - sx_port)];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Input Byte from CL CD186x register */
|
2008-07-22 12:17:05 +02:00
|
|
|
static inline unsigned char sx_in(struct specialix_board *bp,
|
|
|
|
unsigned short reg)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
bp->reg = reg | 0x80;
|
2008-07-22 12:17:05 +02:00
|
|
|
outb(reg | 0x80, bp->base + SX_ADDR_REG);
|
|
|
|
return inb(bp->base + SX_DATA_REG);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Output Byte to CL CD186x register */
|
2008-07-22 12:17:05 +02:00
|
|
|
static inline void sx_out(struct specialix_board *bp, unsigned short reg,
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned char val)
|
|
|
|
{
|
|
|
|
bp->reg = reg | 0x80;
|
2008-07-22 12:17:05 +02:00
|
|
|
outb(reg | 0x80, bp->base + SX_ADDR_REG);
|
|
|
|
outb(val, bp->base + SX_DATA_REG);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Input Byte from CL CD186x register */
|
2008-07-22 12:17:05 +02:00
|
|
|
static inline unsigned char sx_in_off(struct specialix_board *bp,
|
|
|
|
unsigned short reg)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
bp->reg = reg;
|
2008-07-22 12:17:05 +02:00
|
|
|
outb(reg, bp->base + SX_ADDR_REG);
|
|
|
|
return inb(bp->base + SX_DATA_REG);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Output Byte to CL CD186x register */
|
2008-07-22 12:17:05 +02:00
|
|
|
static inline void sx_out_off(struct specialix_board *bp,
|
|
|
|
unsigned short reg, unsigned char val)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
bp->reg = reg;
|
2008-07-22 12:17:05 +02:00
|
|
|
outb(reg, bp->base + SX_ADDR_REG);
|
|
|
|
outb(val, bp->base + SX_DATA_REG);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Wait for Channel Command Register ready */
|
2008-07-22 12:17:16 +02:00
|
|
|
static void sx_wait_CCR(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long delay, flags;
|
|
|
|
unsigned char ccr;
|
|
|
|
|
|
|
|
for (delay = SX_CCR_TIMEOUT; delay; delay--) {
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
ccr = sx_in(bp, CD186x_CCR);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
if (!ccr)
|
|
|
|
return;
|
2008-07-22 12:17:05 +02:00
|
|
|
udelay(1);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
printk(KERN_ERR "sx%d: Timeout waiting for CCR.\n", board_No(bp));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Wait for Channel Command Register ready */
|
2008-07-22 12:17:16 +02:00
|
|
|
static void sx_wait_CCR_off(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long delay;
|
|
|
|
unsigned char crr;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
for (delay = SX_CCR_TIMEOUT; delay; delay--) {
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
crr = sx_in_off(bp, CD186x_CCR);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
if (!crr)
|
|
|
|
return;
|
2008-07-22 12:17:05 +02:00
|
|
|
udelay(1);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
printk(KERN_ERR "sx%d: Timeout waiting for CCR.\n", board_No(bp));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* specialix IO8+ IO range functions.
|
|
|
|
*/
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static int sx_request_io_range(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2005-10-31 00:01:51 +01:00
|
|
|
return request_region(bp->base,
|
|
|
|
bp->flags & SX_BOARD_IS_PCI ? SX_PCI_IO_SPACE : SX_IO_SPACE,
|
|
|
|
"specialix IO8+") == NULL;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static void sx_release_io_range(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-07-22 12:17:05 +02:00
|
|
|
release_region(bp->base, bp->flags & SX_BOARD_IS_PCI ?
|
|
|
|
SX_PCI_IO_SPACE : SX_IO_SPACE);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Set the IRQ using the RTS lines that run to the PAL on the board.... */
|
2008-07-22 12:17:05 +02:00
|
|
|
static int sx_set_irq(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int virq;
|
|
|
|
int i;
|
|
|
|
unsigned long flags;
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
if (bp->flags & SX_BOARD_IS_PCI)
|
2005-04-17 00:20:36 +02:00
|
|
|
return 1;
|
|
|
|
switch (bp->irq) {
|
|
|
|
/* In the same order as in the docs... */
|
2008-07-22 12:17:05 +02:00
|
|
|
case 15:
|
|
|
|
virq = 0;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
virq = 1;
|
|
|
|
break;
|
|
|
|
case 11:
|
|
|
|
virq = 2;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
virq = 3;
|
|
|
|
break;
|
|
|
|
default:printk(KERN_ERR
|
|
|
|
"Speclialix: cannot set irq to %d.\n", bp->irq);
|
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
for (i = 0; i < 2; i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_out(bp, CD186x_CAR, i);
|
|
|
|
sx_out(bp, CD186x_MSVRTS, ((virq >> i) & 0x1)? MSVR_RTS:0);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Reset and setup CD186x chip */
|
2008-07-22 12:17:05 +02:00
|
|
|
static int sx_init_CD186x(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int scaler;
|
|
|
|
int rv = 1;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
sx_wait_CCR_off(bp); /* Wait for CCR ready */
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out_off(bp, CD186x_CCR, CCR_HARDRESET); /* Reset CD186x chip */
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
2007-07-17 13:05:19 +02:00
|
|
|
msleep(50); /* Delay 0.05 sec */
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out_off(bp, CD186x_GIVR, SX_ID); /* Set ID for this chip */
|
|
|
|
sx_out_off(bp, CD186x_GICR, 0); /* Clear all bits */
|
|
|
|
sx_out_off(bp, CD186x_PILR1, SX_ACK_MINT); /* Prio for modem intr */
|
|
|
|
sx_out_off(bp, CD186x_PILR2, SX_ACK_TINT); /* Prio for transmitter intr */
|
|
|
|
sx_out_off(bp, CD186x_PILR3, SX_ACK_RINT); /* Prio for receiver intr */
|
|
|
|
/* Set RegAckEn */
|
2008-07-22 12:17:05 +02:00
|
|
|
sx_out_off(bp, CD186x_SRCR, sx_in(bp, CD186x_SRCR) | SRCR_REGACKEN);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Setting up prescaler. We need 4 ticks per 1 ms */
|
|
|
|
scaler = SX_OSCFREQ/SPECIALIX_TPS;
|
|
|
|
|
|
|
|
sx_out_off(bp, CD186x_PPRH, scaler >> 8);
|
|
|
|
sx_out_off(bp, CD186x_PPRL, scaler & 0xff);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
if (!sx_set_irq(bp)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Figure out how to pass this along... */
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_ERR "Cannot set irq to %d.\n", bp->irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
rv = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static int read_cross_byte(struct specialix_board *bp, int reg, int bit)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int t;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
for (i = 0, t = 0; i < 8; i++) {
|
|
|
|
sx_out_off(bp, CD186x_CAR, i);
|
|
|
|
if (sx_in_off(bp, reg) & bit)
|
2005-04-17 00:20:36 +02:00
|
|
|
t |= 1 << i;
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Main probing routine, also sets irq. */
|
|
|
|
static int sx_probe(struct specialix_board *bp)
|
|
|
|
{
|
|
|
|
unsigned char val1, val2;
|
|
|
|
int rev;
|
|
|
|
int chip;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
if (sx_request_io_range(bp)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Are the I/O ports here ? */
|
|
|
|
sx_out_off(bp, CD186x_PPRL, 0x5a);
|
2008-07-22 12:17:16 +02:00
|
|
|
udelay(1);
|
2005-04-17 00:20:36 +02:00
|
|
|
val1 = sx_in_off(bp, CD186x_PPRL);
|
|
|
|
|
|
|
|
sx_out_off(bp, CD186x_PPRL, 0xa5);
|
2008-07-22 12:17:16 +02:00
|
|
|
udelay(1);
|
2005-04-17 00:20:36 +02:00
|
|
|
val2 = sx_in_off(bp, CD186x_PPRL);
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
if (val1 != 0x5a || val2 != 0xa5) {
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_INFO
|
|
|
|
"sx%d: specialix IO8+ Board at 0x%03x not found.\n",
|
|
|
|
board_No(bp), bp->base);
|
2005-10-31 00:01:51 +01:00
|
|
|
sx_release_io_range(bp);
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
/* Check the DSR lines that Specialix uses as board
|
2005-04-17 00:20:36 +02:00
|
|
|
identification */
|
2008-07-22 12:17:05 +02:00
|
|
|
val1 = read_cross_byte(bp, CD186x_MSVR, MSVR_DSR);
|
|
|
|
val2 = read_cross_byte(bp, CD186x_MSVR, MSVR_RTS);
|
|
|
|
dprintk(SX_DEBUG_INIT,
|
|
|
|
"sx%d: DSR lines are: %02x, rts lines are: %02x\n",
|
|
|
|
board_No(bp), val1, val2);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* They managed to switch the bit order between the docs and
|
|
|
|
the IO8+ card. The new PCI card now conforms to old docs.
|
|
|
|
They changed the PCI docs to reflect the situation on the
|
|
|
|
old card. */
|
|
|
|
val2 = (bp->flags & SX_BOARD_IS_PCI)?0x4d : 0xb2;
|
|
|
|
if (val1 != val2) {
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_INFO
|
|
|
|
"sx%d: specialix IO8+ ID %02x at 0x%03x not found (%02x).\n",
|
2005-04-17 00:20:36 +02:00
|
|
|
board_No(bp), val2, bp->base, val1);
|
2005-10-31 00:01:51 +01:00
|
|
|
sx_release_io_range(bp);
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Reset CD186x again */
|
|
|
|
if (!sx_init_CD186x(bp)) {
|
2005-10-31 00:01:51 +01:00
|
|
|
sx_release_io_range(bp);
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
2005-10-31 00:01:51 +01:00
|
|
|
return 1;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sx_request_io_range(bp);
|
|
|
|
bp->flags |= SX_BOARD_PRESENT;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Chip revcode pkgtype
|
2008-07-22 12:17:05 +02:00
|
|
|
GFRCR SRCR bit 7
|
2005-04-17 00:20:36 +02:00
|
|
|
CD180 rev B 0x81 0
|
|
|
|
CD180 rev C 0x82 0
|
|
|
|
CD1864 rev A 0x82 1
|
2005-10-31 00:01:51 +01:00
|
|
|
CD1865 rev A 0x83 1 -- Do not use!!! Does not work.
|
2005-04-17 00:20:36 +02:00
|
|
|
CD1865 rev B 0x84 1
|
|
|
|
-- Thanks to Gwen Wang, Cirrus Logic.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (sx_in_off(bp, CD186x_GFRCR)) {
|
2008-07-22 12:17:05 +02:00
|
|
|
case 0x82:
|
|
|
|
chip = 1864;
|
|
|
|
rev = 'A';
|
|
|
|
break;
|
|
|
|
case 0x83:
|
|
|
|
chip = 1865;
|
|
|
|
rev = 'A';
|
|
|
|
break;
|
|
|
|
case 0x84:
|
|
|
|
chip = 1865;
|
|
|
|
rev = 'B';
|
|
|
|
break;
|
|
|
|
case 0x85:
|
|
|
|
chip = 1865;
|
|
|
|
rev = 'C';
|
|
|
|
break; /* Does not exist at this time */
|
|
|
|
default:
|
|
|
|
chip = -1;
|
|
|
|
rev = 'x';
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_INIT, " GFCR = 0x%02x\n", sx_in_off(bp, CD186x_GFRCR));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_INFO
|
|
|
|
"sx%d: specialix IO8+ board detected at 0x%03x, IRQ %d, CD%d Rev. %c.\n",
|
|
|
|
board_No(bp), bp->base, bp->irq, chip, rev);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
/*
|
|
|
|
*
|
2005-04-17 00:20:36 +02:00
|
|
|
* Interrupt processing routines.
|
|
|
|
* */
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static struct specialix_port *sx_get_port(struct specialix_board *bp,
|
2008-07-22 12:17:05 +02:00
|
|
|
unsigned char const *what)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned char channel;
|
2008-07-22 12:17:05 +02:00
|
|
|
struct specialix_port *port = NULL;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
channel = sx_in(bp, CD186x_GICR) >> GICR_CHAN_OFF;
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_CHAN, "channel: %d\n", channel);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (channel < CD186x_NCH) {
|
|
|
|
port = &sx_port[board_No(bp) * SX_NPORT + channel];
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_CHAN, "port: %d %p flags: 0x%lx\n",
|
|
|
|
board_No(bp) * SX_NPORT + channel, port,
|
|
|
|
port->port.flags & ASYNC_INITIALIZED);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-07-16 22:57:18 +02:00
|
|
|
if (port->port.flags & ASYNC_INITIALIZED) {
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_CHAN, "port: %d %p\n", channel, port);
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return port;
|
|
|
|
}
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
printk(KERN_INFO "sx%d: %s interrupt from invalid port %d\n",
|
2005-04-17 00:20:36 +02:00
|
|
|
board_No(bp), what, channel);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static void sx_receive_exc(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct specialix_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 05:54:13 +01:00
|
|
|
unsigned char ch, flag;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
port = sx_get_port(bp, "Receive");
|
|
|
|
if (!port) {
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_RX, "Hmm, couldn't find port.\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2008-07-16 22:57:18 +02:00
|
|
|
tty = port->port.tty;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
status = sx_in(bp, CD186x_RCSR);
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_RX, "status: 0x%x\n", status);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (status & RCSR_OE) {
|
|
|
|
port->overrun++;
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_FIFO,
|
|
|
|
"sx%d: port %d: Overrun. Total %ld overruns.\n",
|
|
|
|
board_No(bp), port_No(port), port->overrun);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
status &= port->mark_mask;
|
|
|
|
|
|
|
|
/* This flip buffer check needs to be below the reading of the
|
|
|
|
status register to reset the chip's IRQ.... */
|
[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 05:54:13 +01:00
|
|
|
if (tty_buffer_request_room(tty, 1) == 0) {
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_FIFO,
|
|
|
|
"sx%d: port %d: Working around flip buffer overflow.\n",
|
|
|
|
board_No(bp), port_No(port));
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ch = sx_in(bp, CD186x_RDR);
|
|
|
|
if (!status) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (status & RCSR_TOUT) {
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_INFO
|
|
|
|
"sx%d: port %d: Receiver timeout. Hardware problems ?\n",
|
|
|
|
board_No(bp), port_No(port));
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
} else if (status & RCSR_BREAK) {
|
|
|
|
dprintk(SX_DEBUG_RX, "sx%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 05:54:13 +01:00
|
|
|
flag = TTY_BREAK;
|
2008-07-16 22:57:18 +02:00
|
|
|
if (port->port.flags & ASYNC_SAK)
|
2005-04-17 00:20:36 +02:00
|
|
|
do_SAK(tty);
|
2005-10-31 00:01:51 +01: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 05:54:13 +01:00
|
|
|
flag = TTY_PARITY;
|
2005-10-31 00:01:51 +01: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 05:54:13 +01:00
|
|
|
flag = TTY_FRAME;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02: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 05:54:13 +01:00
|
|
|
flag = TTY_OVERRUN;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02: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 05:54:13 +01:00
|
|
|
flag = TTY_NORMAL;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
if (tty_insert_flip_char(tty, ch, flag))
|
[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 05:54:13 +01:00
|
|
|
tty_flip_buffer_push(tty);
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static void sx_receive(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct specialix_port *port;
|
|
|
|
struct tty_struct *tty;
|
|
|
|
unsigned char count;
|
|
|
|
|
|
|
|
func_enter();
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
port = sx_get_port(bp, "Receive");
|
|
|
|
if (port == NULL) {
|
|
|
|
dprintk(SX_DEBUG_RX, "Hmm, couldn't find port.\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2008-07-16 22:57:18 +02:00
|
|
|
tty = port->port.tty;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
count = sx_in(bp, CD186x_RDCR);
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_RX, "port: %p: count: %d\n", port, count);
|
2005-04-17 00:20:36 +02:00
|
|
|
port->hits[count > 8 ? 9 : count]++;
|
2005-10-31 00:01:51 +01: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 05:54:13 +01:00
|
|
|
tty_buffer_request_room(tty, count);
|
2005-04-17 00:20:36 +02: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 05:54:13 +01:00
|
|
|
while (count--)
|
|
|
|
tty_insert_flip_char(tty, sx_in(bp, CD186x_RDR), TTY_NORMAL);
|
|
|
|
tty_flip_buffer_push(tty);
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static void sx_transmit(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct specialix_port *port;
|
|
|
|
struct tty_struct *tty;
|
|
|
|
unsigned char count;
|
|
|
|
|
|
|
|
func_enter();
|
2008-07-22 12:17:05 +02:00
|
|
|
port = sx_get_port(bp, "Transmit");
|
|
|
|
if (port == NULL) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_TX, "port: %p\n", port);
|
2008-07-16 22:57:18 +02:00
|
|
|
tty = port->port.tty;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (port->IER & IER_TXEMPTY) {
|
|
|
|
/* FIFO drained */
|
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
port->IER &= ~IER_TXEMPTY;
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if ((port->xmit_cnt <= 0 && !port->break_length)
|
|
|
|
|| tty->stopped || tty->hw_stopped) {
|
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (port->break_length) {
|
|
|
|
if (port->break_length > 0) {
|
|
|
|
if (port->COR2 & COR2_ETC) {
|
|
|
|
sx_out(bp, CD186x_TDR, CD186x_C_ESC);
|
|
|
|
sx_out(bp, CD186x_TDR, CD186x_C_SBRK);
|
|
|
|
port->COR2 &= ~COR2_ETC;
|
|
|
|
}
|
|
|
|
count = min_t(int, port->break_length, 0xff);
|
|
|
|
sx_out(bp, CD186x_TDR, CD186x_C_ESC);
|
|
|
|
sx_out(bp, CD186x_TDR, CD186x_C_DELAY);
|
|
|
|
sx_out(bp, CD186x_TDR, count);
|
2008-07-22 12:17:05 +02:00
|
|
|
port->break_length -= count;
|
|
|
|
if (port->break_length == 0)
|
2005-04-17 00:20:36 +02:00
|
|
|
port->break_length--;
|
|
|
|
} else {
|
|
|
|
sx_out(bp, CD186x_TDR, CD186x_C_ESC);
|
|
|
|
sx_out(bp, CD186x_TDR, CD186x_C_EBRK);
|
|
|
|
sx_out(bp, CD186x_COR2, port->COR2);
|
|
|
|
sx_wait_CCR(bp);
|
|
|
|
sx_out(bp, CD186x_CCR, CCR_CORCHG2);
|
|
|
|
port->break_length = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
count = CD186x_NFIFO;
|
|
|
|
do {
|
|
|
|
sx_out(bp, CD186x_TDR, port->xmit_buf[port->xmit_tail++]);
|
|
|
|
port->xmit_tail = port->xmit_tail & (SERIAL_XMIT_SIZE-1);
|
|
|
|
if (--port->xmit_cnt <= 0)
|
|
|
|
break;
|
|
|
|
} while (--count > 0);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (port->xmit_cnt <= 0) {
|
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
|
|
|
}
|
|
|
|
if (port->xmit_cnt <= port->wakeup_chars)
|
2008-07-22 12:17:05 +02:00
|
|
|
tty_wakeup(tty);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static void sx_check_modem(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct specialix_port *port;
|
|
|
|
struct tty_struct *tty;
|
|
|
|
unsigned char mcr;
|
|
|
|
int msvr_cd;
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_SIGNALS, "Modem intr. ");
|
|
|
|
port = sx_get_port(bp, "Modem");
|
|
|
|
if (port == NULL)
|
2005-04-17 00:20:36 +02:00
|
|
|
return;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2008-07-16 22:57:18 +02:00
|
|
|
tty = port->port.tty;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
mcr = sx_in(bp, CD186x_MCR);
|
|
|
|
|
|
|
|
if ((mcr & MCR_CDCHG)) {
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_SIGNALS, "CD just changed... ");
|
2005-04-17 00:20:36 +02:00
|
|
|
msvr_cd = sx_in(bp, CD186x_MSVR) & MSVR_CD;
|
|
|
|
if (msvr_cd) {
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_SIGNALS, "Waking up guys in open.\n");
|
2008-07-16 22:57:18 +02:00
|
|
|
wake_up_interruptible(&port->port.open_wait);
|
2005-04-17 00:20:36 +02:00
|
|
|
} else {
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_SIGNALS, "Sending HUP.\n");
|
2008-02-07 09:16:39 +01:00
|
|
|
tty_hangup(tty);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#ifdef SPECIALIX_BRAIN_DAMAGED_CTS
|
|
|
|
if (mcr & MCR_CTSCHG) {
|
|
|
|
if (sx_in(bp, CD186x_MSVR) & MSVR_CTS) {
|
|
|
|
tty->hw_stopped = 0;
|
|
|
|
port->IER |= IER_TXRDY;
|
|
|
|
if (port->xmit_cnt <= port->wakeup_chars)
|
2008-02-07 09:16:39 +01:00
|
|
|
tty_wakeup(tty);
|
2005-04-17 00:20:36 +02:00
|
|
|
} else {
|
|
|
|
tty->hw_stopped = 1;
|
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
}
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
|
|
|
}
|
|
|
|
if (mcr & MCR_DSSXHG) {
|
|
|
|
if (sx_in(bp, CD186x_MSVR) & MSVR_DSR) {
|
|
|
|
tty->hw_stopped = 0;
|
|
|
|
port->IER |= IER_TXRDY;
|
|
|
|
if (port->xmit_cnt <= port->wakeup_chars)
|
2008-02-07 09:16:39 +01:00
|
|
|
tty_wakeup(tty);
|
2005-04-17 00:20:36 +02:00
|
|
|
} else {
|
|
|
|
tty->hw_stopped = 1;
|
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
}
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
|
|
|
}
|
|
|
|
#endif /* SPECIALIX_BRAIN_DAMAGED_CTS */
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Clear change bits */
|
|
|
|
sx_out(bp, CD186x_MCR, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* The main interrupt processing routine */
|
2007-10-31 10:20:49 +01:00
|
|
|
static irqreturn_t sx_interrupt(int dummy, void *dev_id)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned char status;
|
|
|
|
unsigned char ack;
|
2007-10-31 10:20:49 +01:00
|
|
|
struct specialix_board *bp = dev_id;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long loop = 0;
|
|
|
|
int saved_reg;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_FLOW, "enter %s port %d room: %ld\n", __func__,
|
|
|
|
port_No(sx_get_port(bp, "INT")),
|
|
|
|
SERIAL_XMIT_SIZE - sx_get_port(bp, "ITN")->xmit_cnt - 1);
|
2006-10-06 21:00:58 +02:00
|
|
|
if (!(bp->flags & SX_BOARD_ACTIVE)) {
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_IRQ, "sx: False interrupt. irq %d.\n",
|
|
|
|
bp->irq);
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
func_exit();
|
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
saved_reg = bp->reg;
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
while (++loop < 16) {
|
|
|
|
status = sx_in(bp, CD186x_SRSR) &
|
|
|
|
(SRSR_RREQint | SRSR_TREQint | SRSR_MREQint);
|
|
|
|
if (status == 0)
|
|
|
|
break;
|
2005-04-17 00:20:36 +02:00
|
|
|
if (status & SRSR_RREQint) {
|
|
|
|
ack = sx_in(bp, CD186x_RRAR);
|
|
|
|
|
|
|
|
if (ack == (SX_ID | GIVR_IT_RCV))
|
|
|
|
sx_receive(bp);
|
|
|
|
else if (ack == (SX_ID | GIVR_IT_REXC))
|
|
|
|
sx_receive_exc(bp);
|
|
|
|
else
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_ERR
|
|
|
|
"sx%d: status: 0x%x Bad receive ack 0x%02x.\n",
|
|
|
|
board_No(bp), status, ack);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
} else if (status & SRSR_TREQint) {
|
|
|
|
ack = sx_in(bp, CD186x_TRAR);
|
|
|
|
|
|
|
|
if (ack == (SX_ID | GIVR_IT_TX))
|
|
|
|
sx_transmit(bp);
|
|
|
|
else
|
|
|
|
printk(KERN_ERR "sx%d: status: 0x%x Bad transmit ack 0x%02x. port: %d\n",
|
2008-07-22 12:17:05 +02:00
|
|
|
board_No(bp), status, ack,
|
|
|
|
port_No(sx_get_port(bp, "Int")));
|
2005-04-17 00:20:36 +02:00
|
|
|
} else if (status & SRSR_MREQint) {
|
|
|
|
ack = sx_in(bp, CD186x_MRAR);
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
if (ack == (SX_ID | GIVR_IT_MODEM))
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_check_modem(bp);
|
|
|
|
else
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_ERR
|
|
|
|
"sx%d: status: 0x%x Bad modem ack 0x%02x.\n",
|
2005-04-17 00:20:36 +02:00
|
|
|
board_No(bp), status, ack);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
sx_out(bp, CD186x_EOIR, 0); /* Mark end of interrupt */
|
|
|
|
}
|
|
|
|
bp->reg = saved_reg;
|
2008-07-22 12:17:05 +02:00
|
|
|
outb(bp->reg, bp->base + SX_ADDR_REG);
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
func_exit();
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Routines for open & close processing.
|
|
|
|
*/
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static void turn_ints_off(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
(void) sx_in_off(bp, 0); /* Turn off interrupts. */
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static void turn_ints_on(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
(void) sx_in(bp, 0); /* Turn ON interrupts. */
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Called with disabled interrupts */
|
2008-07-22 12:17:16 +02:00
|
|
|
static int sx_setup_board(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
if (bp->flags & SX_BOARD_ACTIVE)
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (bp->flags & SX_BOARD_IS_PCI)
|
2008-07-22 12:17:05 +02:00
|
|
|
error = request_irq(bp->irq, sx_interrupt,
|
|
|
|
IRQF_DISABLED | IRQF_SHARED, "specialix IO8+", bp);
|
2005-04-17 00:20:36 +02:00
|
|
|
else
|
2008-07-22 12:17:05 +02:00
|
|
|
error = request_irq(bp->irq, sx_interrupt,
|
|
|
|
IRQF_DISABLED, "specialix IO8+", bp);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
if (error)
|
2005-04-17 00:20:36 +02:00
|
|
|
return error;
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
turn_ints_on(bp);
|
2005-04-17 00:20:36 +02:00
|
|
|
bp->flags |= SX_BOARD_ACTIVE;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Called with disabled interrupts */
|
2008-07-22 12:17:16 +02:00
|
|
|
static void sx_shutdown_board(struct specialix_board *bp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
if (!(bp->flags & SX_BOARD_ACTIVE)) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bp->flags &= ~SX_BOARD_ACTIVE;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_IRQ, "Freeing IRQ%d for board %d.\n",
|
|
|
|
bp->irq, board_No(bp));
|
2005-04-17 00:20:36 +02:00
|
|
|
free_irq(bp->irq, bp);
|
2008-07-22 12:17:05 +02:00
|
|
|
turn_ints_off(bp);
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static unsigned int sx_crtscts(struct tty_struct *tty)
|
|
|
|
{
|
|
|
|
if (sx_rtscts)
|
|
|
|
return C_CRTSCTS(tty);
|
|
|
|
return 1;
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
2005-10-31 00:01:51 +01:00
|
|
|
* Setting up port characteristics.
|
2005-04-17 00:20:36 +02:00
|
|
|
* Must be called with disabled interrupts
|
|
|
|
*/
|
2008-07-22 12:17:05 +02:00
|
|
|
static void sx_change_speed(struct specialix_board *bp,
|
|
|
|
struct specialix_port *port)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct tty_struct *tty;
|
|
|
|
unsigned long baud;
|
|
|
|
long tmp;
|
|
|
|
unsigned char cor1 = 0, cor3 = 0;
|
|
|
|
unsigned char mcor1 = 0, mcor2 = 0;
|
|
|
|
static unsigned long again;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
tty = port->port.tty;
|
|
|
|
if (!tty || !tty->termios) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
port->IER = 0;
|
|
|
|
port->COR2 = 0;
|
|
|
|
/* Select port on the board */
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
|
|
|
|
/* The Specialix board doens't implement the RTS lines.
|
|
|
|
They are used to set the IRQ level. Don't touch them. */
|
2008-07-22 12:17:16 +02:00
|
|
|
if (sx_crtscts(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
port->MSVR = MSVR_DTR | (sx_in(bp, CD186x_MSVR) & MSVR_RTS);
|
|
|
|
else
|
|
|
|
port->MSVR = (sx_in(bp, CD186x_MSVR) & MSVR_RTS);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_TERMIOS, "sx: got MSVR=%02x.\n", port->MSVR);
|
2006-09-29 11:01:39 +02:00
|
|
|
baud = tty_get_baud_rate(tty);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2006-09-29 11:01:39 +02:00
|
|
|
if (baud == 38400) {
|
2008-07-16 22:57:18 +02:00
|
|
|
if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
|
2006-10-17 09:10:00 +02:00
|
|
|
baud = 57600;
|
2008-07-16 22:57:18 +02:00
|
|
|
if ((port->port.flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
|
2006-10-17 09:10:00 +02:00
|
|
|
baud = 115200;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2006-09-29 11:01:39 +02:00
|
|
|
if (!baud) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Drop DTR & exit */
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_TERMIOS, "Dropping DTR... Hmm....\n");
|
2008-07-22 12:17:16 +02:00
|
|
|
if (!sx_crtscts(tty)) {
|
2008-07-22 12:17:05 +02:00
|
|
|
port->MSVR &= ~MSVR_DTR;
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
sx_out(bp, CD186x_MSVR, port->MSVR);
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
} else
|
|
|
|
dprintk(SX_DEBUG_TERMIOS, "Can't drop DTR: no DTR.\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
/* Set DTR on */
|
2008-07-22 12:17:16 +02:00
|
|
|
if (!sx_crtscts(tty))
|
2008-07-22 12:17:05 +02:00
|
|
|
port->MSVR |= MSVR_DTR;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
2005-10-31 00:01:51 +01:00
|
|
|
* Now we must calculate some speed depended things
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Set baud rate for port */
|
|
|
|
tmp = port->custom_divisor ;
|
2008-07-22 12:17:05 +02:00
|
|
|
if (tmp)
|
|
|
|
printk(KERN_INFO
|
|
|
|
"sx%d: Using custom baud rate divisor %ld. \n"
|
|
|
|
"This is an untested option, please be careful.\n",
|
|
|
|
port_No(port), tmp);
|
2005-04-17 00:20:36 +02:00
|
|
|
else
|
2008-07-22 12:17:05 +02:00
|
|
|
tmp = (((SX_OSCFREQ + baud/2) / baud + CD186x_TPC/2) /
|
|
|
|
CD186x_TPC);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
if (tmp < 0x10 && time_before(again, jiffies)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
again = jiffies + HZ * 60;
|
|
|
|
/* Page 48 of version 2.0 of the CL-CD1865 databook */
|
|
|
|
if (tmp >= 12) {
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_INFO "sx%d: Baud rate divisor is %ld. \n"
|
|
|
|
"Performance degradation is possible.\n"
|
|
|
|
"Read specialix.txt for more info.\n",
|
|
|
|
port_No(port), tmp);
|
2005-04-17 00:20:36 +02:00
|
|
|
} else {
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_INFO "sx%d: Baud rate divisor is %ld. \n"
|
|
|
|
"Warning: overstressing Cirrus chip. This might not work.\n"
|
|
|
|
"Read specialix.txt for more info.\n", port_No(port), tmp);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
2005-10-31 00:01:51 +01:00
|
|
|
sx_out(bp, CD186x_RBPRH, (tmp >> 8) & 0xff);
|
|
|
|
sx_out(bp, CD186x_TBPRH, (tmp >> 8) & 0xff);
|
|
|
|
sx_out(bp, CD186x_RBPRL, tmp & 0xff);
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_out(bp, CD186x_TBPRL, tmp & 0xff);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
2006-10-17 09:10:00 +02:00
|
|
|
if (port->custom_divisor)
|
2008-07-22 12:17:05 +02:00
|
|
|
baud = (SX_OSCFREQ + port->custom_divisor/2) /
|
|
|
|
port->custom_divisor;
|
2006-10-17 09:10:00 +02:00
|
|
|
baud = (baud + 5) / 10; /* Estimated CPS */
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/* Two timer ticks seems enough to wakeup something like SLIP driver */
|
2005-10-31 00:01:51 +01:00
|
|
|
tmp = ((baud + HZ/2) / HZ) * 2 - CD186x_NFIFO;
|
2005-04-17 00:20:36 +02:00
|
|
|
port->wakeup_chars = (tmp < 0) ? 0 : ((tmp >= SERIAL_XMIT_SIZE) ?
|
|
|
|
SERIAL_XMIT_SIZE - 1 : tmp);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Receiver timeout will be transmission time for 1.5 chars */
|
|
|
|
tmp = (SPECIALIX_TPS + SPECIALIX_TPS/2 + baud/2) / baud;
|
|
|
|
tmp = (tmp > 0xff) ? 0xff : tmp;
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_RTPR, tmp);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
switch (C_CSIZE(tty)) {
|
2008-07-22 12:17:05 +02:00
|
|
|
case CS5:
|
2005-04-17 00:20:36 +02:00
|
|
|
cor1 |= COR1_5BITS;
|
|
|
|
break;
|
2008-07-22 12:17:05 +02:00
|
|
|
case CS6:
|
2005-04-17 00:20:36 +02:00
|
|
|
cor1 |= COR1_6BITS;
|
|
|
|
break;
|
2008-07-22 12:17:05 +02:00
|
|
|
case CS7:
|
2005-04-17 00:20:36 +02:00
|
|
|
cor1 |= COR1_7BITS;
|
|
|
|
break;
|
2008-07-22 12:17:05 +02:00
|
|
|
case CS8:
|
2005-04-17 00:20:36 +02:00
|
|
|
cor1 |= COR1_8BITS;
|
|
|
|
break;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
|
|
|
if (C_CSTOPB(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
cor1 |= COR1_2SB;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
cor1 |= COR1_IGNORE;
|
|
|
|
if (C_PARENB(tty)) {
|
|
|
|
cor1 |= COR1_NORMPAR;
|
2005-10-31 00:01:51 +01:00
|
|
|
if (C_PARODD(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
cor1 |= COR1_ODDP;
|
2005-10-31 00:01:51 +01:00
|
|
|
if (I_INPCK(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
cor1 &= ~COR1_IGNORE;
|
|
|
|
}
|
|
|
|
/* Set marking of some errors */
|
|
|
|
port->mark_mask = RCSR_OE | RCSR_TOUT;
|
2005-10-31 00:01:51 +01:00
|
|
|
if (I_INPCK(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
port->mark_mask |= RCSR_FE | RCSR_PE;
|
2005-10-31 00:01:51 +01:00
|
|
|
if (I_BRKINT(tty) || I_PARMRK(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
port->mark_mask |= RCSR_BREAK;
|
2005-10-31 00:01:51 +01:00
|
|
|
if (I_IGNPAR(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
port->mark_mask &= ~(RCSR_FE | RCSR_PE);
|
|
|
|
if (I_IGNBRK(tty)) {
|
|
|
|
port->mark_mask &= ~RCSR_BREAK;
|
2005-10-31 00:01:51 +01:00
|
|
|
if (I_IGNPAR(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Real raw mode. Ignore all */
|
|
|
|
port->mark_mask &= ~RCSR_OE;
|
|
|
|
}
|
|
|
|
/* Enable Hardware Flow Control */
|
|
|
|
if (C_CRTSCTS(tty)) {
|
|
|
|
#ifdef SPECIALIX_BRAIN_DAMAGED_CTS
|
|
|
|
port->IER |= IER_DSR | IER_CTS;
|
|
|
|
mcor1 |= MCOR1_DSRZD | MCOR1_CTSZD;
|
|
|
|
mcor2 |= MCOR2_DSROD | MCOR2_CTSOD;
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
tty->hw_stopped = !(sx_in(bp, CD186x_MSVR) &
|
|
|
|
(MSVR_CTS|MSVR_DSR));
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
#else
|
2005-10-31 00:01:51 +01:00
|
|
|
port->COR2 |= COR2_CTSAE;
|
2005-04-17 00:20:36 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
/* Enable Software Flow Control. FIXME: I'm not sure about this */
|
|
|
|
/* Some people reported that it works, but I still doubt it */
|
|
|
|
if (I_IXON(tty)) {
|
|
|
|
port->COR2 |= COR2_TXIBE;
|
|
|
|
cor3 |= (COR3_FCT | COR3_SCDE);
|
|
|
|
if (I_IXANY(tty))
|
|
|
|
port->COR2 |= COR2_IXM;
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_SCHR1, START_CHAR(tty));
|
|
|
|
sx_out(bp, CD186x_SCHR2, STOP_CHAR(tty));
|
|
|
|
sx_out(bp, CD186x_SCHR3, START_CHAR(tty));
|
|
|
|
sx_out(bp, CD186x_SCHR4, STOP_CHAR(tty));
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
}
|
|
|
|
if (!C_CLOCAL(tty)) {
|
|
|
|
/* Enable CD check */
|
|
|
|
port->IER |= IER_CD;
|
|
|
|
mcor1 |= MCOR1_CDZD;
|
|
|
|
mcor2 |= MCOR2_CDOD;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
|
|
|
if (C_CREAD(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Enable receiver */
|
|
|
|
port->IER |= IER_RXD;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Set input FIFO size (1-8 bytes) */
|
|
|
|
cor3 |= sx_rxfifo;
|
|
|
|
/* Setting up CD186x channel registers */
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_COR1, cor1);
|
|
|
|
sx_out(bp, CD186x_COR2, port->COR2);
|
|
|
|
sx_out(bp, CD186x_COR3, cor3);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
/* Make CD186x know about registers change */
|
|
|
|
sx_wait_CCR(bp);
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CCR, CCR_CORCHG1 | CCR_CORCHG2 | CCR_CORCHG3);
|
|
|
|
/* Setting up modem option registers */
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_TERMIOS, "Mcor1 = %02x, mcor2 = %02x.\n",
|
|
|
|
mcor1, mcor2);
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_out(bp, CD186x_MCOR1, mcor1);
|
|
|
|
sx_out(bp, CD186x_MCOR2, mcor2);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
/* Enable CD186x transmitter & receiver */
|
|
|
|
sx_wait_CCR(bp);
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CCR, CCR_TXEN | CCR_RXEN);
|
|
|
|
/* Enable interrupts */
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
|
|
|
/* And finally set the modem lines... */
|
|
|
|
sx_out(bp, CD186x_MSVR, port->MSVR);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Must be called with interrupts enabled */
|
2008-07-22 12:17:05 +02:00
|
|
|
static int sx_setup_port(struct specialix_board *bp,
|
|
|
|
struct specialix_port *port)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
2008-07-16 22:57:18 +02:00
|
|
|
if (port->port.flags & ASYNC_INITIALIZED) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (!port->xmit_buf) {
|
|
|
|
/* We may sleep in get_zeroed_page() */
|
|
|
|
unsigned long tmp;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
tmp = get_zeroed_page(GFP_KERNEL);
|
|
|
|
if (tmp == 0L) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (port->xmit_buf) {
|
|
|
|
free_page(tmp);
|
|
|
|
func_exit();
|
|
|
|
return -ERESTARTSYS;
|
|
|
|
}
|
|
|
|
port->xmit_buf = (unsigned char *) tmp;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
|
2008-07-16 22:57:18 +02:00
|
|
|
if (port->port.tty)
|
|
|
|
clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
|
|
|
|
sx_change_speed(bp, port);
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.flags |= ASYNC_INITIALIZED;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Must be called with interrupts disabled */
|
2008-07-22 12:17:05 +02:00
|
|
|
static void sx_shutdown_port(struct specialix_board *bp,
|
|
|
|
struct specialix_port *port)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct tty_struct *tty;
|
|
|
|
int i;
|
|
|
|
unsigned long flags;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
func_enter();
|
|
|
|
|
2008-07-16 22:57:18 +02:00
|
|
|
if (!(port->port.flags & ASYNC_INITIALIZED)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (sx_debug & SX_DEBUG_FIFO) {
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_FIFO,
|
|
|
|
"sx%d: port %d: %ld overruns, FIFO hits [ ",
|
|
|
|
board_No(bp), port_No(port), port->overrun);
|
|
|
|
for (i = 0; i < 10; i++)
|
2005-04-17 00:20:36 +02:00
|
|
|
dprintk(SX_DEBUG_FIFO, "%ld ", port->hits[i]);
|
|
|
|
dprintk(SX_DEBUG_FIFO, "].\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (port->xmit_buf) {
|
|
|
|
free_page((unsigned long) port->xmit_buf);
|
|
|
|
port->xmit_buf = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Select port */
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
tty = port->port.tty;
|
|
|
|
if (tty == NULL || C_HUPCL(tty)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Drop DTR */
|
|
|
|
sx_out(bp, CD186x_MSVDTR, 0);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
/* Reset port */
|
|
|
|
sx_wait_CCR(bp);
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CCR, CCR_SOFTRESET);
|
|
|
|
/* Disable all interrupts from this port */
|
|
|
|
port->IER = 0;
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
if (tty)
|
|
|
|
set_bit(TTY_IO_ERROR, &tty->flags);
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.flags &= ~ASYNC_INITIALIZED;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
|
|
|
if (!bp->count)
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_shutdown_board(bp);
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static int block_til_ready(struct tty_struct *tty, struct file *filp,
|
|
|
|
struct specialix_port *port)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
DECLARE_WAITQUEUE(wait, current);
|
|
|
|
struct specialix_board *bp = port_Board(port);
|
|
|
|
int retval;
|
|
|
|
int do_clocal = 0;
|
|
|
|
int CD;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the device is in the middle of being closed, then block
|
|
|
|
* until it's done, and then try again.
|
|
|
|
*/
|
2008-07-16 22:57:18 +02:00
|
|
|
if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) {
|
|
|
|
interruptible_sleep_on(&port->port.close_wait);
|
|
|
|
if (port->port.flags & ASYNC_HUP_NOTIFY) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return -EAGAIN;
|
|
|
|
} else {
|
|
|
|
func_exit();
|
|
|
|
return -ERESTARTSYS;
|
|
|
|
}
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* If non-blocking mode is set, or the port is not enabled,
|
|
|
|
* then make the check up front and then exit.
|
|
|
|
*/
|
|
|
|
if ((filp->f_flags & O_NONBLOCK) ||
|
|
|
|
(tty->flags & (1 << TTY_IO_ERROR))) {
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.flags |= ASYNC_NORMAL_ACTIVE;
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (C_CLOCAL(tty))
|
|
|
|
do_clocal = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Block waiting for the carrier detect and the line to become
|
|
|
|
* free (i.e., not in use by the callout). While we are in
|
|
|
|
* this loop, info->count is dropped by one, so that
|
|
|
|
* rs_close() knows when to free things. We restore it upon
|
|
|
|
* exit, either normal or abnormal.
|
|
|
|
*/
|
|
|
|
retval = 0;
|
2008-07-16 22:57:18 +02:00
|
|
|
add_wait_queue(&port->port.open_wait, &wait);
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
if (!tty_hung_up_p(filp))
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.count--;
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.blocked_open++;
|
2005-04-17 00:20:36 +02:00
|
|
|
while (1) {
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
CD = sx_in(bp, CD186x_MSVR) & MSVR_CD;
|
2008-07-22 12:17:16 +02:00
|
|
|
if (sx_crtscts(tty)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Activate RTS */
|
|
|
|
port->MSVR |= MSVR_DTR; /* WTF? */
|
2008-07-22 12:17:05 +02:00
|
|
|
sx_out(bp, CD186x_MSVR, port->MSVR);
|
2005-04-17 00:20:36 +02:00
|
|
|
} else {
|
|
|
|
/* Activate DTR */
|
|
|
|
port->MSVR |= MSVR_DTR;
|
2008-07-22 12:17:05 +02:00
|
|
|
sx_out(bp, CD186x_MSVR, port->MSVR);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
if (tty_hung_up_p(filp) ||
|
2008-07-16 22:57:18 +02:00
|
|
|
!(port->port.flags & ASYNC_INITIALIZED)) {
|
|
|
|
if (port->port.flags & ASYNC_HUP_NOTIFY)
|
2005-04-17 00:20:36 +02:00
|
|
|
retval = -EAGAIN;
|
|
|
|
else
|
2005-10-31 00:01:51 +01:00
|
|
|
retval = -ERESTARTSYS;
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
}
|
2008-07-16 22:57:18 +02:00
|
|
|
if (!(port->port.flags & ASYNC_CLOSING) &&
|
2005-04-17 00:20:36 +02:00
|
|
|
(do_clocal || CD))
|
|
|
|
break;
|
|
|
|
if (signal_pending(current)) {
|
|
|
|
retval = -ERESTARTSYS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
schedule();
|
|
|
|
}
|
|
|
|
|
|
|
|
set_current_state(TASK_RUNNING);
|
2008-07-16 22:57:18 +02:00
|
|
|
remove_wait_queue(&port->port.open_wait, &wait);
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
if (!tty_hung_up_p(filp))
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.count++;
|
|
|
|
port->port.blocked_open--;
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
if (retval) {
|
|
|
|
func_exit();
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.flags |= ASYNC_NORMAL_ACTIVE;
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return 0;
|
2005-10-31 00:01:51 +01:00
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static int sx_open(struct tty_struct *tty, struct file *filp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
int board;
|
|
|
|
int error;
|
2008-07-22 12:17:05 +02:00
|
|
|
struct specialix_port *port;
|
|
|
|
struct specialix_board *bp;
|
2005-04-17 00:20:36 +02:00
|
|
|
int i;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
board = SX_BOARD(tty->index);
|
|
|
|
|
|
|
|
if (board >= SX_NBOARD || !(sx_board[board].flags & SX_BOARD_PRESENT)) {
|
|
|
|
func_exit();
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
bp = &sx_board[board];
|
|
|
|
port = sx_port + board * SX_NPORT + SX_PORT(tty->index);
|
|
|
|
port->overrun = 0;
|
|
|
|
for (i = 0; i < 10; i++)
|
2008-07-22 12:17:05 +02:00
|
|
|
port->hits[i] = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_OPEN,
|
|
|
|
"Board = %d, bp = %p, port = %p, portno = %d.\n",
|
|
|
|
board, bp, port, SX_PORT(tty->index));
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_open")) {
|
|
|
|
func_enter();
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
error = sx_setup_board(bp);
|
|
|
|
if (error) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.count++;
|
2005-04-17 00:20:36 +02:00
|
|
|
bp->count++;
|
|
|
|
tty->driver_data = port;
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.tty = tty;
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
error = sx_setup_port(bp, port);
|
|
|
|
if (error) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_enter();
|
|
|
|
return error;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
error = block_til_ready(tty, filp, port);
|
|
|
|
if (error) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_enter();
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-30 09:53:59 +02:00
|
|
|
static void sx_flush_buffer(struct tty_struct *tty)
|
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2008-04-30 09:53:59 +02:00
|
|
|
unsigned long flags;
|
2008-07-22 12:17:05 +02:00
|
|
|
struct specialix_board *bp;
|
2008-04-30 09:53:59 +02:00
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_flush_buffer")) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bp = port_Board(port);
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
tty_wakeup(tty);
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static void sx_close(struct tty_struct *tty, struct file *filp)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct specialix_board *bp;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned long timeout;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
func_enter();
|
|
|
|
if (!port || sx_paranoia_check(port, tty->name, "close")) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
|
|
|
|
if (tty_hung_up_p(filp)) {
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
bp = port_Board(port);
|
2008-07-22 12:17:16 +02:00
|
|
|
if (tty->count == 1 && port->port.count != 1) {
|
2005-04-17 00:20:36 +02:00
|
|
|
printk(KERN_ERR "sx%d: sx_close: bad port count;"
|
|
|
|
" tty->count is 1, port count is %d\n",
|
2008-07-16 22:57:18 +02:00
|
|
|
board_No(bp), port->port.count);
|
|
|
|
port->port.count = 1;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-07-16 22:57:18 +02:00
|
|
|
if (port->port.count > 1) {
|
|
|
|
port->port.count--;
|
2005-04-17 00:20:36 +02:00
|
|
|
bp->count--;
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.flags |= ASYNC_CLOSING;
|
2005-04-17 00:20:36 +02:00
|
|
|
/*
|
2005-10-31 00:01:51 +01:00
|
|
|
* Now we wait for the transmit buffer to clear; and we notify
|
2005-04-17 00:20:36 +02:00
|
|
|
* the line discipline to only process XON/XOFF characters.
|
|
|
|
*/
|
|
|
|
tty->closing = 1;
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_OPEN, "Closing\n");
|
|
|
|
if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE)
|
2008-07-16 22:57:18 +02:00
|
|
|
tty_wait_until_sent(tty, port->port.closing_wait);
|
2005-04-17 00:20:36 +02: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.
|
|
|
|
*/
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_OPEN, "Closed\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
port->IER &= ~IER_RXD;
|
2008-07-16 22:57:18 +02:00
|
|
|
if (port->port.flags & ASYNC_INITIALIZED) {
|
2005-04-17 00:20:36 +02:00
|
|
|
port->IER &= ~IER_TXRDY;
|
|
|
|
port->IER |= IER_TXEMPTY;
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
/*
|
|
|
|
* Before we drop DTR, make sure the UART transmitter
|
|
|
|
* has completely drained; this is especially
|
|
|
|
* important if there is a transmit FIFO!
|
|
|
|
*/
|
|
|
|
timeout = jiffies+HZ;
|
2008-07-22 12:17:05 +02:00
|
|
|
while (port->IER & IER_TXEMPTY) {
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
2005-04-17 00:20:36 +02:00
|
|
|
msleep_interruptible(jiffies_to_msecs(port->timeout));
|
|
|
|
if (time_after(jiffies, timeout)) {
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_INFO "Timeout waiting for close\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (--bp->count < 0) {
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_ERR
|
|
|
|
"sx%d: sx_shutdown_port: bad board count: %d port: %d\n",
|
|
|
|
board_No(bp), bp->count, tty->index);
|
2005-04-17 00:20:36 +02:00
|
|
|
bp->count = 0;
|
|
|
|
}
|
2008-07-16 22:57:18 +02:00
|
|
|
if (--port->port.count < 0) {
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_ERR
|
|
|
|
"sx%d: sx_close: bad port count for tty%d: %d\n",
|
|
|
|
board_No(bp), port_No(port), port->port.count);
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.count = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sx_shutdown_port(bp, port);
|
2008-04-30 09:53:59 +02:00
|
|
|
sx_flush_buffer(tty);
|
2005-04-17 00:20:36 +02:00
|
|
|
tty_ldisc_flush(tty);
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
tty->closing = 0;
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.tty = NULL;
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
2008-07-16 22:57:18 +02:00
|
|
|
if (port->port.blocked_open) {
|
2008-07-22 12:17:05 +02:00
|
|
|
if (port->port.close_delay)
|
|
|
|
msleep_interruptible(
|
|
|
|
jiffies_to_msecs(port->port.close_delay));
|
2008-07-16 22:57:18 +02:00
|
|
|
wake_up_interruptible(&port->port.open_wait);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
|
|
|
|
wake_up_interruptible(&port->port.close_wait);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static int sx_write(struct tty_struct *tty,
|
|
|
|
const unsigned char *buf, int count)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct specialix_board *bp;
|
|
|
|
int c, total = 0;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_write")) {
|
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
bp = port_Board(port);
|
|
|
|
|
2006-10-01 08:28:11 +02:00
|
|
|
if (!port->xmit_buf) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
c = min_t(int, count, min(SERIAL_XMIT_SIZE - port->xmit_cnt - 1,
|
|
|
|
SERIAL_XMIT_SIZE - port->xmit_head));
|
|
|
|
if (c <= 0) {
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
memcpy(port->xmit_buf + port->xmit_head, buf, c);
|
|
|
|
port->xmit_head = (port->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
|
|
|
|
port->xmit_cnt += c;
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
|
|
|
|
buf += c;
|
|
|
|
count -= c;
|
|
|
|
total += c;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
if (port->xmit_cnt && !tty->stopped && !tty->hw_stopped &&
|
|
|
|
!(port->IER & IER_TXRDY)) {
|
|
|
|
port->IER |= IER_TXRDY;
|
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
func_exit();
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static int sx_put_char(struct tty_struct *tty, unsigned char ch)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
2008-07-22 12:17:05 +02:00
|
|
|
struct specialix_board *bp;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_put_char")) {
|
|
|
|
func_exit();
|
2008-04-30 09:54:07 +02:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_TX, "check tty: %p %p\n", tty, port->xmit_buf);
|
2006-06-25 14:48:48 +02:00
|
|
|
if (!port->xmit_buf) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
2008-04-30 09:54:07 +02:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
bp = port_Board(port);
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_TX, "xmit_cnt: %d xmit_buf: %p\n",
|
|
|
|
port->xmit_cnt, port->xmit_buf);
|
|
|
|
if (port->xmit_cnt >= SERIAL_XMIT_SIZE - 1 || !port->xmit_buf) {
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_TX, "Exit size\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
2008-04-30 09:54:07 +02:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_TX, "Handle xmit: %p %p\n", port, port->xmit_buf);
|
2005-04-17 00:20:36 +02:00
|
|
|
port->xmit_buf[port->xmit_head++] = ch;
|
|
|
|
port->xmit_head &= SERIAL_XMIT_SIZE - 1;
|
|
|
|
port->xmit_cnt++;
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
|
|
|
|
func_exit();
|
2008-04-30 09:54:07 +02:00
|
|
|
return 1;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static void sx_flush_chars(struct tty_struct *tty)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
2008-07-22 12:17:05 +02:00
|
|
|
struct specialix_board *bp = port_Board(port);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_flush_chars")) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (port->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
|
|
|
|
!port->xmit_buf) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
port->IER |= IER_TXRDY;
|
|
|
|
sx_out(port_Board(port), CD186x_CAR, port_No(port));
|
|
|
|
sx_out(port_Board(port), CD186x_IER, port->IER);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static int sx_write_room(struct tty_struct *tty)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_write_room")) {
|
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = SERIAL_XMIT_SIZE - port->xmit_cnt - 1;
|
|
|
|
if (ret < 0)
|
|
|
|
ret = 0;
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int sx_chars_in_buffer(struct tty_struct *tty)
|
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
func_enter();
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_chars_in_buffer")) {
|
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
func_exit();
|
|
|
|
return port->xmit_cnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sx_tiocmget(struct tty_struct *tty, struct file *file)
|
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2008-07-22 12:17:05 +02:00
|
|
|
struct specialix_board *bp;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned char status;
|
|
|
|
unsigned int result;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
2008-04-30 09:55:10 +02:00
|
|
|
if (sx_paranoia_check(port, tty->name, __func__)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
bp = port_Board(port);
|
2008-07-22 12:17:05 +02:00
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
status = sx_in(bp, CD186x_MSVR);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
2008-07-22 12:17:05 +02:00
|
|
|
dprintk(SX_DEBUG_INIT, "Got msvr[%d] = %02x, car = %d.\n",
|
|
|
|
port_No(port), status, sx_in(bp, CD186x_CAR));
|
|
|
|
dprintk(SX_DEBUG_INIT, "sx_port = %p, port = %p\n", sx_port, port);
|
2008-07-22 12:17:16 +02:00
|
|
|
if (sx_crtscts(port->port.tty)) {
|
|
|
|
result = TIOCM_DTR | TIOCM_DSR
|
2008-07-22 12:17:05 +02:00
|
|
|
| ((status & MSVR_DTR) ? TIOCM_RTS : 0)
|
|
|
|
| ((status & MSVR_CD) ? TIOCM_CAR : 0)
|
|
|
|
| ((status & MSVR_CTS) ? TIOCM_CTS : 0);
|
2005-04-17 00:20:36 +02:00
|
|
|
} else {
|
2008-07-22 12:17:16 +02:00
|
|
|
result = TIOCM_RTS | TIOCM_DSR
|
2008-07-22 12:17:05 +02:00
|
|
|
| ((status & MSVR_DTR) ? TIOCM_DTR : 0)
|
|
|
|
| ((status & MSVR_CD) ? TIOCM_CAR : 0)
|
|
|
|
| ((status & MSVR_CTS) ? TIOCM_CTS : 0);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int sx_tiocmset(struct tty_struct *tty, struct file *file,
|
|
|
|
unsigned int set, unsigned int clear)
|
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
|
|
|
struct specialix_board *bp;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
2008-04-30 09:55:10 +02:00
|
|
|
if (sx_paranoia_check(port, tty->name, __func__)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
bp = port_Board(port);
|
|
|
|
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
2008-07-22 12:17:16 +02:00
|
|
|
if (sx_crtscts(port->port.tty)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
if (set & TIOCM_RTS)
|
|
|
|
port->MSVR |= MSVR_DTR;
|
|
|
|
} else {
|
|
|
|
if (set & TIOCM_DTR)
|
|
|
|
port->MSVR |= MSVR_DTR;
|
|
|
|
}
|
2008-07-22 12:17:16 +02:00
|
|
|
if (sx_crtscts(port->port.tty)) {
|
2005-04-17 00:20:36 +02:00
|
|
|
if (clear & TIOCM_RTS)
|
|
|
|
port->MSVR &= ~MSVR_DTR;
|
|
|
|
} else {
|
|
|
|
if (clear & TIOCM_DTR)
|
|
|
|
port->MSVR &= ~MSVR_DTR;
|
|
|
|
}
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_lock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
sx_out(bp, CD186x_MSVR, port->MSVR);
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_unlock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:19:05 +02:00
|
|
|
static int sx_send_break(struct tty_struct *tty, int length)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct specialix_board *bp = port_Board(port);
|
|
|
|
unsigned long flags;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
func_enter();
|
2008-07-22 12:19:05 +02:00
|
|
|
if (length == 0 || length == -1)
|
|
|
|
return -EOPNOTSUPP;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
2005-04-17 00:20:36 +02:00
|
|
|
port->break_length = SPECIALIX_TPS / HZ * length;
|
|
|
|
port->COR2 |= COR2_ETC;
|
|
|
|
port->IER |= IER_TXRDY;
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_lock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
sx_out(bp, CD186x_COR2, port->COR2);
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_unlock(&bp->lock);
|
2008-07-22 12:17:05 +02:00
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_wait_CCR(bp);
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CCR, CCR_CORCHG2);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
sx_wait_CCR(bp);
|
|
|
|
|
|
|
|
func_exit();
|
2008-07-22 12:19:05 +02:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static int sx_set_serial_info(struct specialix_port *port,
|
2008-07-22 12:17:05 +02:00
|
|
|
struct serial_struct __user *newinfo)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct serial_struct tmp;
|
|
|
|
struct specialix_board *bp = port_Board(port);
|
|
|
|
int change_speed;
|
|
|
|
|
|
|
|
func_enter();
|
2008-04-30 09:53:22 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (copy_from_user(&tmp, newinfo, sizeof(tmp))) {
|
|
|
|
func_enter();
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2008-04-30 09:53:22 +02:00
|
|
|
lock_kernel();
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-07-16 22:57:18 +02:00
|
|
|
change_speed = ((port->port.flags & ASYNC_SPD_MASK) !=
|
2005-04-17 00:20:36 +02:00
|
|
|
(tmp.flags & ASYNC_SPD_MASK));
|
|
|
|
change_speed |= (tmp.custom_divisor != port->custom_divisor);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (!capable(CAP_SYS_ADMIN)) {
|
2008-07-16 22:57:18 +02:00
|
|
|
if ((tmp.close_delay != port->port.close_delay) ||
|
|
|
|
(tmp.closing_wait != port->port.closing_wait) ||
|
2005-04-17 00:20:36 +02:00
|
|
|
((tmp.flags & ~ASYNC_USR_MASK) !=
|
2008-07-16 22:57:18 +02:00
|
|
|
(port->port.flags & ~ASYNC_USR_MASK))) {
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
2008-04-30 09:53:22 +02:00
|
|
|
unlock_kernel();
|
2005-04-17 00:20:36 +02:00
|
|
|
return -EPERM;
|
|
|
|
}
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) |
|
2008-07-22 12:17:05 +02:00
|
|
|
(tmp.flags & ASYNC_USR_MASK));
|
2005-04-17 00:20:36 +02:00
|
|
|
port->custom_divisor = tmp.custom_divisor;
|
|
|
|
} else {
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.flags = ((port->port.flags & ~ASYNC_FLAGS) |
|
2008-07-22 12:17:05 +02:00
|
|
|
(tmp.flags & ASYNC_FLAGS));
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.close_delay = tmp.close_delay;
|
|
|
|
port->port.closing_wait = tmp.closing_wait;
|
2005-04-17 00:20:36 +02:00
|
|
|
port->custom_divisor = tmp.custom_divisor;
|
|
|
|
}
|
2008-07-22 12:17:05 +02:00
|
|
|
if (change_speed)
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_change_speed(bp, port);
|
2008-07-22 12:17:05 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
2008-04-30 09:53:22 +02:00
|
|
|
unlock_kernel();
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:16 +02:00
|
|
|
static int sx_get_serial_info(struct specialix_port *port,
|
2005-04-17 00:20:36 +02:00
|
|
|
struct serial_struct __user *retinfo)
|
|
|
|
{
|
|
|
|
struct serial_struct tmp;
|
|
|
|
struct specialix_board *bp = port_Board(port);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
func_enter();
|
|
|
|
|
|
|
|
memset(&tmp, 0, sizeof(tmp));
|
2008-04-30 09:53:22 +02:00
|
|
|
lock_kernel();
|
2005-04-17 00:20:36 +02:00
|
|
|
tmp.type = PORT_CIRRUS;
|
|
|
|
tmp.line = port - sx_port;
|
|
|
|
tmp.port = bp->base;
|
|
|
|
tmp.irq = bp->irq;
|
2008-07-16 22:57:18 +02:00
|
|
|
tmp.flags = port->port.flags;
|
2005-04-17 00:20:36 +02:00
|
|
|
tmp.baud_base = (SX_OSCFREQ + CD186x_TPC/2) / CD186x_TPC;
|
2008-07-16 22:57:18 +02:00
|
|
|
tmp.close_delay = port->port.close_delay * HZ/100;
|
|
|
|
tmp.closing_wait = port->port.closing_wait * HZ/100;
|
2005-04-17 00:20:36 +02:00
|
|
|
tmp.custom_divisor = port->custom_divisor;
|
|
|
|
tmp.xmit_fifo_size = CD186x_NFIFO;
|
2008-04-30 09:53:22 +02:00
|
|
|
unlock_kernel();
|
2005-04-17 00:20:36 +02:00
|
|
|
if (copy_to_user(retinfo, &tmp, sizeof(tmp))) {
|
|
|
|
func_exit();
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static int sx_ioctl(struct tty_struct *tty, struct file *filp,
|
|
|
|
unsigned int cmd, unsigned long arg)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
void __user *argp = (void __user *)arg;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_ioctl")) {
|
|
|
|
func_exit();
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
switch (cmd) {
|
2008-07-22 12:17:05 +02:00
|
|
|
case TIOCGSERIAL:
|
2008-07-22 12:19:05 +02:00
|
|
|
func_exit();
|
2005-04-17 00:20:36 +02:00
|
|
|
return sx_get_serial_info(port, argp);
|
2008-07-22 12:17:05 +02:00
|
|
|
case TIOCSSERIAL:
|
2008-07-22 12:19:05 +02:00
|
|
|
func_exit();
|
2005-04-17 00:20:36 +02:00
|
|
|
return sx_set_serial_info(port, argp);
|
2008-07-22 12:17:05 +02:00
|
|
|
default:
|
2008-07-22 12:19:05 +02:00
|
|
|
func_exit();
|
2005-04-17 00:20:36 +02:00
|
|
|
return -ENOIOCTLCMD;
|
|
|
|
}
|
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static void sx_throttle(struct tty_struct *tty)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct specialix_board *bp;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_throttle")) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
bp = port_Board(port);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* Use DTR instead of RTS ! */
|
2008-07-22 12:17:16 +02:00
|
|
|
if (sx_crtscts(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
port->MSVR &= ~MSVR_DTR;
|
|
|
|
else {
|
|
|
|
/* Auch!!! I think the system shouldn't call this then. */
|
|
|
|
/* Or maybe we're supposed (allowed?) to do our side of hw
|
2005-10-31 00:01:51 +01:00
|
|
|
handshake anyway, even when hardware handshake is off.
|
2005-04-17 00:20:36 +02:00
|
|
|
When you see this in your logs, please report.... */
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_ERR
|
|
|
|
"sx%d: Need to throttle, but can't (hardware hs is off)\n",
|
|
|
|
port_No(port));
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
if (I_IXOFF(tty)) {
|
|
|
|
sx_wait_CCR(bp);
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CCR, CCR_SSCH2);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
sx_wait_CCR(bp);
|
|
|
|
}
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_MSVR, port->MSVR);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static void sx_unthrottle(struct tty_struct *tty)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct specialix_board *bp;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_unthrottle")) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
bp = port_Board(port);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
/* XXXX Use DTR INSTEAD???? */
|
2008-07-22 12:17:16 +02:00
|
|
|
if (sx_crtscts(tty))
|
2005-04-17 00:20:36 +02:00
|
|
|
port->MSVR |= MSVR_DTR;
|
2008-07-22 12:17:05 +02:00
|
|
|
/* Else clause: see remark in "sx_throttle"... */
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_lock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_unlock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
if (I_IXOFF(tty)) {
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
sx_wait_CCR(bp);
|
|
|
|
spin_lock_irqsave(&bp->lock, flags);
|
|
|
|
sx_out(bp, CD186x_CCR, CCR_SSCH1);
|
|
|
|
spin_unlock_irqrestore(&bp->lock, flags);
|
|
|
|
sx_wait_CCR(bp);
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
}
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_lock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_out(bp, CD186x_MSVR, port->MSVR);
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_unlock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static void sx_stop(struct tty_struct *tty)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct specialix_board *bp;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_stop")) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bp = port_Board(port);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
port->IER &= ~IER_TXRDY;
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_lock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_unlock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static void sx_start(struct tty_struct *tty)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct specialix_board *bp;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_start")) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
bp = port_Board(port);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) {
|
|
|
|
port->IER |= IER_TXRDY;
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_lock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_out(bp, CD186x_CAR, port_No(port));
|
|
|
|
sx_out(bp, CD186x_IER, port->IER);
|
2009-07-20 17:05:07 +02:00
|
|
|
spin_unlock(&bp->lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static void sx_hangup(struct tty_struct *tty)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
struct specialix_board *bp;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_hangup")) {
|
|
|
|
func_exit();
|
|
|
|
return;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
bp = port_Board(port);
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_shutdown_port(bp, port);
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
2008-07-16 22:57:18 +02:00
|
|
|
bp->count -= port->port.count;
|
2005-04-17 00:20:36 +02:00
|
|
|
if (bp->count < 0) {
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_ERR
|
|
|
|
"sx%d: sx_hangup: bad board count: %d port: %d\n",
|
|
|
|
board_No(bp), bp->count, tty->index);
|
2005-04-17 00:20:36 +02:00
|
|
|
bp->count = 0;
|
|
|
|
}
|
2008-07-16 22:57:18 +02:00
|
|
|
port->port.count = 0;
|
|
|
|
port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
|
|
|
|
port->port.tty = NULL;
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
2008-07-16 22:57:18 +02:00
|
|
|
wake_up_interruptible(&port->port.open_wait);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
static void sx_set_termios(struct tty_struct *tty,
|
|
|
|
struct ktermios *old_termios)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2009-01-02 14:47:26 +01:00
|
|
|
struct specialix_port *port = tty->driver_data;
|
2005-04-17 00:20:36 +02:00
|
|
|
unsigned long flags;
|
2008-07-22 12:17:05 +02:00
|
|
|
struct specialix_board *bp;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
if (sx_paranoia_check(port, tty->name, "sx_set_termios"))
|
|
|
|
return;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
bp = port_Board(port);
|
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
sx_change_speed(port_Board(port), port);
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
|
|
|
|
|
|
|
if ((old_termios->c_cflag & CRTSCTS) &&
|
|
|
|
!(tty->termios->c_cflag & CRTSCTS)) {
|
|
|
|
tty->hw_stopped = 0;
|
|
|
|
sx_start(tty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-02 11:17:18 +02:00
|
|
|
static const struct tty_operations sx_ops = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.open = sx_open,
|
|
|
|
.close = sx_close,
|
|
|
|
.write = sx_write,
|
|
|
|
.put_char = sx_put_char,
|
|
|
|
.flush_chars = sx_flush_chars,
|
|
|
|
.write_room = sx_write_room,
|
|
|
|
.chars_in_buffer = sx_chars_in_buffer,
|
|
|
|
.flush_buffer = sx_flush_buffer,
|
|
|
|
.ioctl = sx_ioctl,
|
|
|
|
.throttle = sx_throttle,
|
|
|
|
.unthrottle = sx_unthrottle,
|
|
|
|
.set_termios = sx_set_termios,
|
|
|
|
.stop = sx_stop,
|
|
|
|
.start = sx_start,
|
|
|
|
.hangup = sx_hangup,
|
|
|
|
.tiocmget = sx_tiocmget,
|
|
|
|
.tiocmset = sx_tiocmset,
|
2008-07-22 12:19:05 +02:00
|
|
|
.break_ctl = sx_send_break,
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static int sx_init_drivers(void)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
specialix_driver = alloc_tty_driver(SX_NBOARD * SX_NPORT);
|
|
|
|
if (!specialix_driver) {
|
|
|
|
printk(KERN_ERR "sx: Couldn't allocate tty_driver.\n");
|
|
|
|
func_exit();
|
|
|
|
return 1;
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
specialix_driver->owner = THIS_MODULE;
|
|
|
|
specialix_driver->name = "ttyW";
|
|
|
|
specialix_driver->major = SPECIALIX_NORMAL_MAJOR;
|
|
|
|
specialix_driver->type = TTY_DRIVER_TYPE_SERIAL;
|
|
|
|
specialix_driver->subtype = SERIAL_TYPE_NORMAL;
|
|
|
|
specialix_driver->init_termios = tty_std_termios;
|
|
|
|
specialix_driver->init_termios.c_cflag =
|
|
|
|
B9600 | CS8 | CREAD | HUPCL | CLOCAL;
|
2006-12-08 11:38:45 +01:00
|
|
|
specialix_driver->init_termios.c_ispeed = 9600;
|
|
|
|
specialix_driver->init_termios.c_ospeed = 9600;
|
2008-07-22 12:19:05 +02:00
|
|
|
specialix_driver->flags = TTY_DRIVER_REAL_RAW |
|
|
|
|
TTY_DRIVER_HARDWARE_BREAK;
|
2005-04-17 00:20:36 +02:00
|
|
|
tty_set_operations(specialix_driver, &sx_ops);
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
error = tty_register_driver(specialix_driver);
|
|
|
|
if (error) {
|
2005-04-17 00:20:36 +02:00
|
|
|
put_tty_driver(specialix_driver);
|
2008-07-22 12:17:05 +02:00
|
|
|
printk(KERN_ERR
|
|
|
|
"sx: Couldn't register specialix IO8+ driver, error = %d\n",
|
|
|
|
error);
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
memset(sx_port, 0, sizeof(sx_port));
|
|
|
|
for (i = 0; i < SX_NPORT * SX_NBOARD; i++) {
|
|
|
|
sx_port[i].magic = SPECIALIX_MAGIC;
|
2008-07-16 22:57:18 +02:00
|
|
|
tty_port_init(&sx_port[i].port);
|
2005-04-17 00:20:36 +02:00
|
|
|
spin_lock_init(&sx_port[i].lock);
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sx_release_drivers(void)
|
|
|
|
{
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
tty_unregister_driver(specialix_driver);
|
|
|
|
put_tty_driver(specialix_driver);
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
/*
|
|
|
|
* This routine must be called by kernel at boot time
|
2005-04-17 00:20:36 +02:00
|
|
|
*/
|
|
|
|
static int __init specialix_init(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int found = 0;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
printk(KERN_INFO "sx: Specialix IO8+ driver v" VERSION ", (c) R.E.Wolff 1997/1998.\n");
|
|
|
|
printk(KERN_INFO "sx: derived from work (c) D.Gorodchanin 1994-1996.\n");
|
2008-07-22 12:17:16 +02:00
|
|
|
if (sx_rtscts)
|
|
|
|
printk(KERN_INFO
|
|
|
|
"sx: DTR/RTS pin is RTS when CRTSCTS is on.\n");
|
|
|
|
else
|
|
|
|
printk(KERN_INFO "sx: DTR/RTS pin is always RTS.\n");
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
for (i = 0; i < SX_NBOARD; i++)
|
2006-06-27 11:53:55 +02:00
|
|
|
spin_lock_init(&sx_board[i].lock);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (sx_init_drivers()) {
|
|
|
|
func_exit();
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
2005-10-31 00:01:51 +01:00
|
|
|
for (i = 0; i < SX_NBOARD; i++)
|
2005-04-17 00:20:36 +02:00
|
|
|
if (sx_board[i].base && !sx_probe(&sx_board[i]))
|
|
|
|
found++;
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
{
|
|
|
|
struct pci_dev *pdev = NULL;
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
i = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
while (i < SX_NBOARD) {
|
|
|
|
if (sx_board[i].flags & SX_BOARD_PRESENT) {
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
}
|
2008-07-22 12:17:05 +02:00
|
|
|
pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX,
|
|
|
|
PCI_DEVICE_ID_SPECIALIX_IO8, pdev);
|
|
|
|
if (!pdev)
|
|
|
|
break;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
if (pci_enable_device(pdev))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
sx_board[i].irq = pdev->irq;
|
|
|
|
|
2008-07-22 12:17:05 +02:00
|
|
|
sx_board[i].base = pci_resource_start(pdev, 2);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
sx_board[i].flags |= SX_BOARD_IS_PCI;
|
|
|
|
if (!sx_probe(&sx_board[i]))
|
2008-07-22 12:17:05 +02:00
|
|
|
found++;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
2006-12-08 11:38:45 +01:00
|
|
|
/* May exit pci_get sequence early with lots of boards */
|
|
|
|
if (pdev != NULL)
|
|
|
|
pci_dev_put(pdev);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
sx_release_drivers();
|
|
|
|
printk(KERN_INFO "sx: No specialix IO8+ boards detected.\n");
|
|
|
|
func_exit();
|
|
|
|
return -EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int iobase[SX_NBOARD] = {0,};
|
2008-07-22 12:17:16 +02:00
|
|
|
static int irq[SX_NBOARD] = {0,};
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
module_param_array(iobase, int, NULL, 0);
|
|
|
|
module_param_array(irq, int, NULL, 0);
|
|
|
|
module_param(sx_debug, int, 0);
|
2008-07-22 12:17:16 +02:00
|
|
|
module_param(sx_rtscts, int, 0);
|
2005-04-17 00:20:36 +02:00
|
|
|
module_param(sx_rxfifo, int, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* You can setup up to 4 boards.
|
|
|
|
* by specifying "iobase=0xXXX,0xXXX ..." as insmod parameter.
|
2005-10-31 00:01:51 +01:00
|
|
|
* You should specify the IRQs too in that case "irq=....,...".
|
|
|
|
*
|
2005-04-17 00:20:36 +02:00
|
|
|
* More than 4 boards in one computer is not possible, as the card can
|
2005-10-31 00:01:51 +01:00
|
|
|
* only use 4 different interrupts.
|
2005-04-17 00:20:36 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
static int __init specialix_init_module(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
func_enter();
|
|
|
|
|
|
|
|
if (iobase[0] || iobase[1] || iobase[2] || iobase[3]) {
|
2008-07-22 12:17:05 +02:00
|
|
|
for (i = 0; i < SX_NBOARD; i++) {
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_board[i].base = iobase[i];
|
|
|
|
sx_board[i].irq = irq[i];
|
2008-07-22 12:17:05 +02:00
|
|
|
sx_board[i].count = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func_exit();
|
|
|
|
|
|
|
|
return specialix_init();
|
|
|
|
}
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
static void __exit specialix_exit_module(void)
|
|
|
|
{
|
|
|
|
int i;
|
2005-10-31 00:01:51 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
func_enter();
|
|
|
|
|
|
|
|
sx_release_drivers();
|
|
|
|
for (i = 0; i < SX_NBOARD; i++)
|
2005-10-31 00:01:51 +01:00
|
|
|
if (sx_board[i].flags & SX_BOARD_PRESENT)
|
2005-04-17 00:20:36 +02:00
|
|
|
sx_release_io_range(&sx_board[i]);
|
|
|
|
func_exit();
|
|
|
|
}
|
|
|
|
|
2006-07-10 13:43:59 +02:00
|
|
|
static struct pci_device_id specialx_pci_tbl[] __devinitdata = {
|
|
|
|
{ PCI_DEVICE(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_IO8) },
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(pci, specialx_pci_tbl);
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
module_init(specialix_init_module);
|
|
|
|
module_exit(specialix_exit_module);
|
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|
2009-04-06 18:33:11 +02:00
|
|
|
MODULE_ALIAS_CHARDEV_MAJOR(SPECIALIX_NORMAL_MAJOR);
|