2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996 Digi International.
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
For technical support please email digiLinux@dgii.com or
|
|
|
|
call Digi tech support at (612) 912-3456
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
** This driver is no longer supported by Digi **
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
Much of this design and code came from epca.c which was
|
|
|
|
copyright (C) 1994, 1995 Troy De Jongh, and subsquently
|
|
|
|
modified by David Nugent, Christoph Lameter, Mike McLagan.
|
|
|
|
|
|
|
|
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.
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
/* See README.epca for change history --DAT*/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/init.h>
|
2009-10-07 21:09:06 +08:00
|
|
|
#include <linux/sched.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/serial.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/tty_flip.h>
|
|
|
|
#include <linux/slab.h>
|
2009-07-12 02:08:37 +08:00
|
|
|
#include <linux/smp_lock.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/interrupt.h>
|
2008-04-30 15:54:16 +08:00
|
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <linux/io.h>
|
2005-09-07 06:16:44 +08:00
|
|
|
#include <linux/spinlock.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/pci.h>
|
|
|
|
#include "digiPCI.h"
|
2005-09-07 06:16:44 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include "digi1.h"
|
|
|
|
#include "digiFep1.h"
|
|
|
|
#include "epca.h"
|
|
|
|
#include "epcaconfig.h"
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
#define VERSION "1.3.0.1-LK2.6"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* This major needs to be submitted to Linux to join the majors list */
|
2007-10-17 14:26:37 +08:00
|
|
|
#define DIGIINFOMAJOR 35 /* For Digi specific ioctl */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
#define MAXCARDS 7
|
|
|
|
#define epcaassert(x, msg) if (!(x)) epca_error(__LINE__, msg)
|
|
|
|
|
|
|
|
#define PFX "epca: "
|
|
|
|
|
|
|
|
static int nbdevs, num_cards, liloconfig;
|
|
|
|
static int digi_poller_inhibited = 1 ;
|
|
|
|
|
|
|
|
static int setup_error_code;
|
|
|
|
static int invalid_lilo_config;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The ISA boards do window flipping into the same spaces so its only sane with
|
2009-01-02 21:47:58 +08:00
|
|
|
* a single lock. It's still pretty efficient. This lock guards the hardware
|
|
|
|
* and the tty_port lock guards the kernel side stuff like use counts. Take
|
|
|
|
* this lock inside the port lock if you must take both.
|
2007-10-17 14:26:37 +08:00
|
|
|
*/
|
2006-06-27 17:53:55 +08:00
|
|
|
static DEFINE_SPINLOCK(epca_lock);
|
2005-09-07 06:16:44 +08:00
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
/* MAXBOARDS is typically 12, but ISA and EISA cards are restricted
|
|
|
|
to 7 below. */
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct board_info boards[MAXBOARDS];
|
|
|
|
|
|
|
|
static struct tty_driver *pc_driver;
|
|
|
|
static struct tty_driver *pc_info;
|
|
|
|
|
|
|
|
/* ------------------ Begin Digi specific structures -------------------- */
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* digi_channels represents an array of structures that keep track of each
|
|
|
|
* channel of the Digi product. Information such as transmit and receive
|
|
|
|
* pointers, termio data, and signal definitions (DTR, CTS, etc ...) are stored
|
|
|
|
* here. This structure is NOT used to overlay the cards physical channel
|
|
|
|
* structure.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct channel digi_channels[MAX_ALLOC];
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* card_ptr is an array used to hold the address of the first channel structure
|
|
|
|
* of each card. This array will hold the addresses of various channels located
|
|
|
|
* in digi_channels.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
static struct channel *card_ptr[MAXCARDS];
|
|
|
|
|
|
|
|
static struct timer_list epca_timer;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Begin generic memory functions. These functions will be alias (point at)
|
|
|
|
* more specific functions dependent on the board being configured.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
static void memwinon(struct board_info *b, unsigned int win);
|
|
|
|
static void memwinoff(struct board_info *b, unsigned int win);
|
|
|
|
static void globalwinon(struct channel *ch);
|
|
|
|
static void rxwinon(struct channel *ch);
|
|
|
|
static void txwinon(struct channel *ch);
|
|
|
|
static void memoff(struct channel *ch);
|
|
|
|
static void assertgwinon(struct channel *ch);
|
|
|
|
static void assertmemoff(struct channel *ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* ---- Begin more 'specific' memory functions for cx_like products --- */
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxem_memwinon(struct board_info *b, unsigned int win);
|
|
|
|
static void pcxem_memwinoff(struct board_info *b, unsigned int win);
|
|
|
|
static void pcxem_globalwinon(struct channel *ch);
|
|
|
|
static void pcxem_rxwinon(struct channel *ch);
|
|
|
|
static void pcxem_txwinon(struct channel *ch);
|
|
|
|
static void pcxem_memoff(struct channel *ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* ------ Begin more 'specific' memory functions for the pcxe ------- */
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxe_memwinon(struct board_info *b, unsigned int win);
|
|
|
|
static void pcxe_memwinoff(struct board_info *b, unsigned int win);
|
|
|
|
static void pcxe_globalwinon(struct channel *ch);
|
|
|
|
static void pcxe_rxwinon(struct channel *ch);
|
|
|
|
static void pcxe_txwinon(struct channel *ch);
|
|
|
|
static void pcxe_memoff(struct channel *ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* ---- Begin more 'specific' memory functions for the pc64xe and pcxi ---- */
|
|
|
|
/* Note : pc64xe and pcxi share the same windowing routines */
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxi_memwinon(struct board_info *b, unsigned int win);
|
|
|
|
static void pcxi_memwinoff(struct board_info *b, unsigned int win);
|
|
|
|
static void pcxi_globalwinon(struct channel *ch);
|
|
|
|
static void pcxi_rxwinon(struct channel *ch);
|
|
|
|
static void pcxi_txwinon(struct channel *ch);
|
|
|
|
static void pcxi_memoff(struct channel *ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* - Begin 'specific' do nothing memory functions needed for some cards - */
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void dummy_memwinon(struct board_info *b, unsigned int win);
|
|
|
|
static void dummy_memwinoff(struct board_info *b, unsigned int win);
|
|
|
|
static void dummy_globalwinon(struct channel *ch);
|
|
|
|
static void dummy_rxwinon(struct channel *ch);
|
|
|
|
static void dummy_txwinon(struct channel *ch);
|
|
|
|
static void dummy_memoff(struct channel *ch);
|
|
|
|
static void dummy_assertgwinon(struct channel *ch);
|
|
|
|
static void dummy_assertmemoff(struct channel *ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static struct channel *verifyChannel(struct tty_struct *);
|
|
|
|
static void pc_sched_event(struct channel *, int);
|
2005-04-17 06:20:36 +08:00
|
|
|
static void epca_error(int, char *);
|
|
|
|
static void pc_close(struct tty_struct *, struct file *);
|
2009-01-02 21:47:58 +08:00
|
|
|
static void shutdown(struct channel *, struct tty_struct *tty);
|
2005-04-17 06:20:36 +08:00
|
|
|
static void pc_hangup(struct tty_struct *);
|
|
|
|
static int pc_write_room(struct tty_struct *);
|
|
|
|
static int pc_chars_in_buffer(struct tty_struct *);
|
|
|
|
static void pc_flush_buffer(struct tty_struct *);
|
|
|
|
static void pc_flush_chars(struct tty_struct *);
|
|
|
|
static int pc_open(struct tty_struct *, struct file *);
|
|
|
|
static void post_fep_init(unsigned int crd);
|
|
|
|
static void epcapoll(unsigned long);
|
|
|
|
static void doevent(int);
|
|
|
|
static void fepcmd(struct channel *, int, int, int, int, int);
|
|
|
|
static unsigned termios2digi_h(struct channel *ch, unsigned);
|
|
|
|
static unsigned termios2digi_i(struct channel *ch, unsigned);
|
|
|
|
static unsigned termios2digi_c(struct channel *ch, unsigned);
|
|
|
|
static void epcaparam(struct tty_struct *, struct channel *);
|
2009-01-02 21:48:04 +08:00
|
|
|
static void receive_data(struct channel *, struct tty_struct *tty);
|
2005-04-17 06:20:36 +08:00
|
|
|
static int pc_ioctl(struct tty_struct *, struct file *,
|
2008-04-30 15:54:16 +08:00
|
|
|
unsigned int, unsigned long);
|
2005-04-17 06:20:36 +08:00
|
|
|
static int info_ioctl(struct tty_struct *, struct file *,
|
2008-04-30 15:54:16 +08:00
|
|
|
unsigned int, unsigned long);
|
2006-12-08 18:38:45 +08:00
|
|
|
static void pc_set_termios(struct tty_struct *, struct ktermios *);
|
2006-11-22 22:57:56 +08:00
|
|
|
static void do_softint(struct work_struct *work);
|
2005-04-17 06:20:36 +08:00
|
|
|
static void pc_stop(struct tty_struct *);
|
|
|
|
static void pc_start(struct tty_struct *);
|
2008-04-30 15:54:16 +08:00
|
|
|
static void pc_throttle(struct tty_struct *tty);
|
2005-04-17 06:20:36 +08:00
|
|
|
static void pc_unthrottle(struct tty_struct *tty);
|
2008-07-22 18:18:12 +08:00
|
|
|
static int pc_send_break(struct tty_struct *tty, int msec);
|
2005-04-17 06:20:36 +08:00
|
|
|
static void setup_empty_event(struct tty_struct *tty, struct channel *ch);
|
|
|
|
|
|
|
|
static int pc_write(struct tty_struct *, const unsigned char *, int);
|
2005-09-07 06:16:44 +08:00
|
|
|
static int pc_init(void);
|
2005-04-17 06:20:36 +08:00
|
|
|
static int init_PCI(void);
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Table of functions for each board to handle memory. Mantaining parallelism
|
|
|
|
* is a *very* good idea here. The idea is for the runtime code to blindly call
|
|
|
|
* these functions, not knowing/caring about the underlying hardware. This
|
|
|
|
* stuff should contain no conditionals; if more functionality is needed a
|
|
|
|
* different entry should be established. These calls are the interface calls
|
|
|
|
* and are the only functions that should be accessed. Anyone caught making
|
|
|
|
* direct calls deserves what they get.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
static void memwinon(struct board_info *b, unsigned int win)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
b->memwinon(b, win);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void memwinoff(struct board_info *b, unsigned int win)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
b->memwinoff(b, win);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void globalwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->board->globalwinon(ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void rxwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->board->rxwinon(ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void txwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->board->txwinon(ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void memoff(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->board->memoff(ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-09-07 06:16:44 +08:00
|
|
|
static void assertgwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->board->assertgwinon(ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void assertmemoff(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->board->assertmemoff(ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/* PCXEM windowing is the same as that used in the PCXR and CX series cards. */
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxem_memwinon(struct board_info *b, unsigned int win)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-04-30 15:54:16 +08:00
|
|
|
outb_p(FEPWIN | win, b->port + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxem_memwinoff(struct board_info *b, unsigned int win)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-09-07 06:16:44 +08:00
|
|
|
outb_p(0, b->port + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxem_globalwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2008-04-30 15:54:16 +08:00
|
|
|
outb_p(FEPWIN, (int)ch->board->port + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxem_rxwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
outb_p(ch->rxwin, (int)ch->board->port + 1);
|
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxem_txwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
outb_p(ch->txwin, (int)ch->board->port + 1);
|
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxem_memoff(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
outb_p(0, (int)ch->board->port + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------------- Begin pcxe memory window stuff ------------------ */
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxe_memwinon(struct board_info *b, unsigned int win)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
outb_p(FEPWIN | win, b->port + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxe_memwinoff(struct board_info *b, unsigned int win)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
outb_p(inb(b->port) & ~FEPMEM, b->port + 1);
|
2005-09-07 06:16:44 +08:00
|
|
|
outb_p(0, b->port + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxe_globalwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
outb_p(FEPWIN, (int)ch->board->port + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxe_rxwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
outb_p(ch->rxwin, (int)ch->board->port + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxe_txwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
outb_p(ch->txwin, (int)ch->board->port + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxe_memoff(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
outb_p(0, (int)ch->board->port);
|
|
|
|
outb_p(0, (int)ch->board->port + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------- Begin pc64xe and pcxi memory window stuff -------------- */
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxi_memwinon(struct board_info *b, unsigned int win)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
outb_p(inb(b->port) | FEPMEM, b->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxi_memwinoff(struct board_info *b, unsigned int win)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-09-07 06:16:44 +08:00
|
|
|
outb_p(inb(b->port) & ~FEPMEM, b->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxi_globalwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-09-07 06:16:44 +08:00
|
|
|
outb_p(FEPMEM, ch->board->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxi_rxwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
outb_p(FEPMEM, ch->board->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxi_txwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
outb_p(FEPMEM, ch->board->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxi_memoff(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-09-07 06:16:44 +08:00
|
|
|
outb_p(0, ch->board->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxi_assertgwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-09-07 06:16:44 +08:00
|
|
|
epcaassert(inb(ch->board->port) & FEPMEM, "Global memory off");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pcxi_assertmemoff(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2005-09-07 06:16:44 +08:00
|
|
|
epcaassert(!(inb(ch->board->port) & FEPMEM), "Memory on");
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Not all of the cards need specific memory windowing routines. Some cards
|
|
|
|
* (Such as PCI) needs no windowing routines at all. We provide these do
|
|
|
|
* nothing routines so that the same code base can be used. The driver will
|
|
|
|
* ALWAYS call a windowing routine if it thinks it needs to; regardless of the
|
|
|
|
* card. However, dependent on the card the routine may or may not do anything.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
static void dummy_memwinon(struct board_info *b, unsigned int win)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void dummy_memwinoff(struct board_info *b, unsigned int win)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void dummy_globalwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void dummy_rxwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void dummy_txwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void dummy_memoff(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void dummy_assertgwinon(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void dummy_assertmemoff(struct channel *ch)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static struct channel *verifyChannel(struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This routine basically provides a sanity check. It insures that the
|
|
|
|
* channel returned is within the proper range of addresses as well as
|
|
|
|
* properly initialized. If some bogus info gets passed in
|
|
|
|
* through tty->driver_data this should catch it.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
if (tty) {
|
2009-01-02 21:47:26 +08:00
|
|
|
struct channel *ch = tty->driver_data;
|
2008-04-30 15:54:16 +08:00
|
|
|
if (ch >= &digi_channels[0] && ch < &digi_channels[nbdevs]) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ch->magic == EPCA_MAGIC)
|
|
|
|
return ch;
|
|
|
|
}
|
2005-09-07 06:16:44 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
return NULL;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static void pc_sched_event(struct channel *ch, int event)
|
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* We call this to schedule interrupt processing on some event. The
|
|
|
|
* kernel sees our request and calls the related routine in OUR driver.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->event |= 1 << event;
|
|
|
|
schedule_work(&ch->tqueue);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void epca_error(int line, char *msg)
|
2005-09-07 06:16:44 +08:00
|
|
|
{
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_ERR "epca_error (Digi): line = %d %s\n", line, msg);
|
2005-09-07 06:16:44 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
static void pc_close(struct tty_struct *tty, struct file *filp)
|
2005-09-07 06:16:44 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
2009-01-02 21:47:58 +08:00
|
|
|
struct tty_port *port;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
2009-01-02 21:47:58 +08:00
|
|
|
if (ch == NULL)
|
|
|
|
return;
|
|
|
|
port = &ch->port;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-02 21:48:11 +08:00
|
|
|
if (tty_port_close_start(port, tty, filp) == 0)
|
2009-01-02 21:47:58 +08:00
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-02 21:47:58 +08:00
|
|
|
pc_flush_buffer(tty);
|
|
|
|
shutdown(ch, tty);
|
|
|
|
|
2009-01-02 21:48:11 +08:00
|
|
|
tty_port_close_end(port, tty);
|
|
|
|
ch->event = 0; /* FIXME: review ch->event locking */
|
2009-01-02 21:48:04 +08:00
|
|
|
tty_port_tty_set(port, NULL);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-02 21:47:58 +08:00
|
|
|
static void shutdown(struct channel *ch, struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2009-01-02 21:47:58 +08:00
|
|
|
struct tty_port *port = &ch->port;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-02 21:47:58 +08:00
|
|
|
if (!(port->flags & ASYNC_INITIALIZED))
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
globalwinon(ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
bc = ch->brdchan;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* In order for an event to be generated on the receipt of data the
|
|
|
|
* idata flag must be set. Since we are shutting down, this is not
|
|
|
|
* necessary clear this flag.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (bc)
|
2005-09-07 06:16:44 +08:00
|
|
|
writeb(0, &bc->idata);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/* If we're a modem control device and HUPCL is on, drop RTS & DTR. */
|
2005-09-07 06:16:44 +08:00
|
|
|
if (tty->termios->c_cflag & HUPCL) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->omodem &= ~(ch->m_rts | ch->m_dtr);
|
|
|
|
fepcmd(ch, SETMODEM, 0, ch->m_dtr | ch->m_rts, 10, 1);
|
|
|
|
}
|
|
|
|
memoff(ch);
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The channel has officialy been closed. The next time it is opened it
|
|
|
|
* will have to reinitialized. Set a flag to indicate this.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Prevent future Digi programmed interrupts from coming active */
|
2009-01-02 21:47:58 +08:00
|
|
|
port->flags &= ~ASYNC_INITIALIZED;
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void pc_hangup(struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
2009-01-02 21:47:58 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
if (ch != NULL) {
|
2008-04-30 15:53:59 +08:00
|
|
|
pc_flush_buffer(tty);
|
2005-04-17 06:20:36 +08:00
|
|
|
tty_ldisc_flush(tty);
|
2009-01-02 21:47:58 +08:00
|
|
|
shutdown(ch, tty);
|
|
|
|
|
|
|
|
ch->event = 0; /* FIXME: review locking of ch->event */
|
2009-01-02 21:48:11 +08:00
|
|
|
tty_port_hangup(&ch->port);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
static int pc_write(struct tty_struct *tty,
|
2008-04-30 15:54:16 +08:00
|
|
|
const unsigned char *buf, int bytesAvailable)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-09-07 06:16:44 +08:00
|
|
|
unsigned int head, tail;
|
|
|
|
int dataLen;
|
|
|
|
int size;
|
|
|
|
int amountCopied;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
|
|
|
unsigned long flags;
|
|
|
|
int remain;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* pc_write is primarily called directly by the kernel routine
|
|
|
|
* tty_write (Though it can also be called by put_char) found in
|
|
|
|
* tty_io.c. pc_write is passed a line discipline buffer where the data
|
|
|
|
* to be written out is stored. The line discipline implementation
|
|
|
|
* itself is done at the kernel level and is not brought into the
|
|
|
|
* driver.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
if (ch == NULL)
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Make a pointer to the channel data structure found on the board. */
|
|
|
|
bc = ch->brdchan;
|
|
|
|
size = ch->txbufsize;
|
|
|
|
amountCopied = 0;
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
head = readw(&bc->tin) & (size - 1);
|
|
|
|
tail = readw(&bc->tout);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (tail != readw(&bc->tout))
|
|
|
|
tail = readw(&bc->tout);
|
2005-04-17 06:20:36 +08:00
|
|
|
tail &= (size - 1);
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
if (head >= tail) {
|
|
|
|
/* head has not wrapped */
|
|
|
|
/*
|
|
|
|
* remain (much like dataLen above) represents the total amount
|
|
|
|
* of space available on the card for data. Here dataLen
|
|
|
|
* represents the space existing between the head pointer and
|
|
|
|
* the end of buffer. This is important because a memcpy cannot
|
|
|
|
* be told to automatically wrap around when it hits the buffer
|
|
|
|
* end.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
dataLen = size - head;
|
|
|
|
remain = size - (head - tail) - 1;
|
2007-10-17 14:26:37 +08:00
|
|
|
} else {
|
|
|
|
/* head has wrapped around */
|
2005-04-17 06:20:36 +08:00
|
|
|
remain = tail - head - 1;
|
|
|
|
dataLen = remain;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Check the space on the card. If we have more data than space; reduce
|
|
|
|
* the amount of data to fit the space.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
bytesAvailable = min(remain, bytesAvailable);
|
|
|
|
txwinon(ch);
|
2007-10-17 14:26:37 +08:00
|
|
|
while (bytesAvailable > 0) {
|
|
|
|
/* there is data to copy onto card */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* If head is not wrapped, the below will make sure the first
|
|
|
|
* data copy fills to the end of card buffer.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
dataLen = min(bytesAvailable, dataLen);
|
2005-09-16 05:53:28 +08:00
|
|
|
memcpy_toio(ch->txptr + head, buf, dataLen);
|
2005-04-17 06:20:36 +08:00
|
|
|
buf += dataLen;
|
|
|
|
head += dataLen;
|
|
|
|
amountCopied += dataLen;
|
|
|
|
bytesAvailable -= dataLen;
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (head >= size) {
|
2005-04-17 06:20:36 +08:00
|
|
|
head = 0;
|
|
|
|
dataLen = tail;
|
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->statusflags |= TXBUSY;
|
|
|
|
globalwinon(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
writew(head, &bc->tin);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if ((ch->statusflags & LOWWAIT) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->statusflags |= LOWWAIT;
|
2005-09-07 06:16:44 +08:00
|
|
|
writeb(1, &bc->ilow);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
memoff(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
return amountCopied;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int pc_write_room(struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2008-04-30 15:54:16 +08:00
|
|
|
int remain = 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int head, tail;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
if (ch != NULL) {
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
|
|
|
|
bc = ch->brdchan;
|
2005-09-07 06:16:44 +08:00
|
|
|
head = readw(&bc->tin) & (ch->txbufsize - 1);
|
|
|
|
tail = readw(&bc->tout);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (tail != readw(&bc->tout))
|
|
|
|
tail = readw(&bc->tout);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Wrap tail if necessary */
|
|
|
|
tail &= (ch->txbufsize - 1);
|
2008-04-30 15:54:16 +08:00
|
|
|
remain = tail - head - 1;
|
|
|
|
if (remain < 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
remain += ch->txbufsize;
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (remain && (ch->statusflags & LOWWAIT) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->statusflags |= LOWWAIT;
|
2005-09-07 06:16:44 +08:00
|
|
|
writeb(1, &bc->ilow);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
memoff(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
/* Return how much room is left on card */
|
|
|
|
return remain;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int pc_chars_in_buffer(struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
int chars;
|
|
|
|
unsigned int ctail, head, tail;
|
|
|
|
int remain;
|
|
|
|
unsigned long flags;
|
|
|
|
struct channel *ch;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
if (ch == NULL)
|
2007-10-17 14:26:37 +08:00
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
|
|
|
|
bc = ch->brdchan;
|
2005-09-07 06:16:44 +08:00
|
|
|
tail = readw(&bc->tout);
|
|
|
|
head = readw(&bc->tin);
|
|
|
|
ctail = readw(&ch->mailbox->cout);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
if (tail == head && readw(&ch->mailbox->cin) == ctail &&
|
|
|
|
readb(&bc->tbusy) == 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
chars = 0;
|
2005-09-07 06:16:44 +08:00
|
|
|
else { /* Begin if some space on the card has been used */
|
|
|
|
head = readw(&bc->tin) & (ch->txbufsize - 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
tail &= (ch->txbufsize - 1);
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The logic here is basically opposite of the above
|
|
|
|
* pc_write_room here we are finding the amount of bytes in the
|
|
|
|
* buffer filled. Not the amount of bytes empty.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
remain = tail - head - 1;
|
|
|
|
if (remain < 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
remain += ch->txbufsize;
|
|
|
|
chars = (int)(ch->txbufsize - remain);
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Make it possible to wakeup anything waiting for output in
|
|
|
|
* tty_ioctl.c, etc.
|
|
|
|
*
|
|
|
|
* If not already set. Setup an event to indicate when the
|
|
|
|
* transmit buffer empties.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!(ch->statusflags & EMPTYWAIT))
|
2008-04-30 15:54:16 +08:00
|
|
|
setup_empty_event(tty, ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
} /* End if some space on the card has been used */
|
|
|
|
memoff(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Return number of characters residing on card. */
|
2007-10-17 14:26:37 +08:00
|
|
|
return chars;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void pc_flush_buffer(struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int tail;
|
|
|
|
unsigned long flags;
|
|
|
|
struct channel *ch;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
if (ch == NULL)
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
bc = ch->brdchan;
|
2005-09-07 06:16:44 +08:00
|
|
|
tail = readw(&bc->tout);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Have FEP move tout pointer; effectively flushing transmit buffer */
|
|
|
|
fepcmd(ch, STOUT, (unsigned) tail, 0, 0, 0);
|
|
|
|
memoff(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
tty_wakeup(tty);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void pc_flush_chars(struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
|
|
|
struct channel *ch;
|
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
if (ch != NULL) {
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* If not already set and the transmitter is busy setup an
|
|
|
|
* event to indicate when the transmit empties.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
if ((ch->statusflags & TXBUSY) &&
|
|
|
|
!(ch->statusflags & EMPTYWAIT))
|
|
|
|
setup_empty_event(tty, ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-02 21:48:11 +08:00
|
|
|
static int epca_carrier_raised(struct tty_port *port)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2009-01-02 21:48:11 +08:00
|
|
|
struct channel *ch = container_of(port, struct channel, port);
|
|
|
|
if (ch->imodem & ch->dcd)
|
|
|
|
return 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-06-11 19:24:17 +08:00
|
|
|
static void epca_dtr_rts(struct tty_port *port, int onoff)
|
2009-01-02 21:48:11 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
static int pc_open(struct tty_struct *tty, struct file *filp)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
2009-01-02 21:47:58 +08:00
|
|
|
struct tty_port *port;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
|
|
|
int line, retval, boardnum;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2005-09-07 06:16:44 +08:00
|
|
|
unsigned int head;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
line = tty->index;
|
2005-09-07 06:16:44 +08:00
|
|
|
if (line < 0 || line >= nbdevs)
|
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ch = &digi_channels[line];
|
2009-01-02 21:47:58 +08:00
|
|
|
port = &ch->port;
|
2005-04-17 06:20:36 +08:00
|
|
|
boardnum = ch->boardnum;
|
|
|
|
|
|
|
|
/* Check status of board configured in system. */
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
2008-12-30 05:14:56 +08:00
|
|
|
* I check to see if the epca_setup routine detected a user error. It
|
2007-10-17 14:26:37 +08:00
|
|
|
* might be better to put this in pc_init, but for the moment it goes
|
|
|
|
* here.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
if (invalid_lilo_config) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (setup_error_code & INVALID_BOARD_TYPE)
|
2005-09-07 06:16:44 +08:00
|
|
|
printk(KERN_ERR "epca: pc_open: Invalid board type specified in kernel options.\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
if (setup_error_code & INVALID_NUM_PORTS)
|
2005-09-07 06:16:44 +08:00
|
|
|
printk(KERN_ERR "epca: pc_open: Invalid number of ports specified in kernel options.\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
if (setup_error_code & INVALID_MEM_BASE)
|
2005-09-07 06:16:44 +08:00
|
|
|
printk(KERN_ERR "epca: pc_open: Invalid board memory address specified in kernel options.\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
if (setup_error_code & INVALID_PORT_BASE)
|
2005-09-07 06:16:44 +08:00
|
|
|
printk(KERN_ERR "epca; pc_open: Invalid board port address specified in kernel options.\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
if (setup_error_code & INVALID_BOARD_STATUS)
|
2005-09-07 06:16:44 +08:00
|
|
|
printk(KERN_ERR "epca: pc_open: Invalid board status specified in kernel options.\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
if (setup_error_code & INVALID_ALTPIN)
|
2005-09-07 06:16:44 +08:00
|
|
|
printk(KERN_ERR "epca: pc_open: Invalid board altpin specified in kernel options;\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
tty->driver_data = NULL; /* Mark this device as 'down' */
|
2005-09-07 06:16:44 +08:00
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2005-09-07 06:16:44 +08:00
|
|
|
if (boardnum >= num_cards || boards[boardnum].status == DISABLED) {
|
2005-04-17 06:20:36 +08:00
|
|
|
tty->driver_data = NULL; /* Mark this device as 'down' */
|
|
|
|
return(-ENODEV);
|
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2008-04-30 15:53:52 +08:00
|
|
|
bc = ch->brdchan;
|
|
|
|
if (bc == NULL) {
|
2005-04-17 06:20:36 +08:00
|
|
|
tty->driver_data = NULL;
|
2005-09-07 06:16:44 +08:00
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2009-01-02 21:47:58 +08:00
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Every time a channel is opened, increment a counter. This is
|
|
|
|
* necessary because we do not wish to flush and shutdown the channel
|
|
|
|
* until the last app holding the channel open, closes it.
|
|
|
|
*/
|
2009-01-02 21:47:58 +08:00
|
|
|
port->count++;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Set a kernel structures pointer to our local channel structure. This
|
|
|
|
* way we can get to it when passed only a tty struct.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
tty->driver_data = ch;
|
2009-01-02 21:47:58 +08:00
|
|
|
port->tty = tty;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* If this is the first time the channel has been opened, initialize
|
|
|
|
* the tty->termios struct otherwise let pc_close handle it.
|
|
|
|
*/
|
2009-01-02 21:47:58 +08:00
|
|
|
spin_lock(&epca_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
ch->statusflags = 0;
|
|
|
|
|
|
|
|
/* Save boards current modem status */
|
2005-09-16 05:53:28 +08:00
|
|
|
ch->imodem = readb(&bc->mstat);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Set receive head and tail ptrs to each other. This indicates no data
|
|
|
|
* available to read.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
head = readw(&bc->rin);
|
|
|
|
writew(head, &bc->rout);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Set the channels associated tty structure */
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The below routine generally sets up parity, baud, flow control
|
|
|
|
* issues, etc.... It effect both control flags and input flags.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
epcaparam(tty, ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
memoff(ch);
|
2009-01-02 21:47:58 +08:00
|
|
|
spin_unlock(&epca_lock);
|
|
|
|
port->flags |= ASYNC_INITIALIZED;
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-01-02 21:48:11 +08:00
|
|
|
retval = tty_port_block_til_ready(port, tty, filp);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (retval)
|
|
|
|
return retval;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Set this again in case a hangup set it to zero while this open() was
|
|
|
|
* waiting for the line...
|
|
|
|
*/
|
2009-01-02 21:47:58 +08:00
|
|
|
spin_lock_irqsave(&port->lock, flags);
|
|
|
|
port->tty = tty;
|
|
|
|
spin_lock(&epca_lock);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
/* Enable Digi Data events */
|
2005-09-07 06:16:44 +08:00
|
|
|
writeb(1, &bc->idata);
|
2005-04-17 06:20:36 +08:00
|
|
|
memoff(ch);
|
2009-01-02 21:47:58 +08:00
|
|
|
spin_unlock(&epca_lock);
|
|
|
|
spin_unlock_irqrestore(&port->lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static int __init epca_module_init(void)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-09-07 06:16:44 +08:00
|
|
|
return pc_init();
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
module_init(epca_module_init);
|
|
|
|
|
|
|
|
static struct pci_driver epca_driver;
|
|
|
|
|
|
|
|
static void __exit epca_module_exit(void)
|
|
|
|
{
|
|
|
|
int count, crd;
|
|
|
|
struct board_info *bd;
|
|
|
|
struct channel *ch;
|
|
|
|
|
|
|
|
del_timer_sync(&epca_timer);
|
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
if (tty_unregister_driver(pc_driver) ||
|
|
|
|
tty_unregister_driver(pc_info)) {
|
2005-09-07 06:16:44 +08:00
|
|
|
printk(KERN_WARNING "epca: cleanup_module failed to un-register tty driver\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
put_tty_driver(pc_driver);
|
|
|
|
put_tty_driver(pc_info);
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
for (crd = 0; crd < num_cards; crd++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
bd = &boards[crd];
|
2007-10-17 14:26:37 +08:00
|
|
|
if (!bd) { /* sanity check */
|
2005-04-17 06:20:36 +08:00
|
|
|
printk(KERN_ERR "<Error> - Digi : cleanup_module failed\n");
|
|
|
|
return;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-09-07 06:16:44 +08:00
|
|
|
ch = card_ptr[crd];
|
2007-10-17 14:26:37 +08:00
|
|
|
for (count = 0; count < bd->numports; count++, ch++) {
|
2009-01-02 21:48:04 +08:00
|
|
|
struct tty_struct *tty = tty_port_tty_get(&ch->port);
|
|
|
|
if (tty) {
|
|
|
|
tty_hangup(tty);
|
|
|
|
tty_kref_put(tty);
|
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pci_unregister_driver(&epca_driver);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
module_exit(epca_module_exit);
|
|
|
|
|
2006-10-02 17:17:18 +08:00
|
|
|
static const struct tty_operations pc_ops = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.open = pc_open,
|
|
|
|
.close = pc_close,
|
|
|
|
.write = pc_write,
|
|
|
|
.write_room = pc_write_room,
|
|
|
|
.flush_buffer = pc_flush_buffer,
|
|
|
|
.chars_in_buffer = pc_chars_in_buffer,
|
|
|
|
.flush_chars = pc_flush_chars,
|
|
|
|
.ioctl = pc_ioctl,
|
|
|
|
.set_termios = pc_set_termios,
|
|
|
|
.stop = pc_stop,
|
|
|
|
.start = pc_start,
|
|
|
|
.throttle = pc_throttle,
|
|
|
|
.unthrottle = pc_unthrottle,
|
|
|
|
.hangup = pc_hangup,
|
2008-07-22 18:18:12 +08:00
|
|
|
.break_ctl = pc_send_break
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
2009-01-02 21:48:11 +08:00
|
|
|
static const struct tty_port_operations epca_port_ops = {
|
|
|
|
.carrier_raised = epca_carrier_raised,
|
2009-06-11 19:24:17 +08:00
|
|
|
.dtr_rts = epca_dtr_rts,
|
2009-01-02 21:48:11 +08:00
|
|
|
};
|
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
static int info_open(struct tty_struct *tty, struct file *filp)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-03 04:12:06 +08:00
|
|
|
static const struct tty_operations info_ops = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.open = info_open,
|
|
|
|
.ioctl = info_ioctl,
|
|
|
|
};
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
static int __init pc_init(void)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
int crd;
|
|
|
|
struct board_info *bd;
|
|
|
|
unsigned char board_id = 0;
|
2006-10-17 15:10:28 +08:00
|
|
|
int err = -ENOMEM;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
int pci_boards_found, pci_count;
|
|
|
|
|
|
|
|
pci_count = 0;
|
|
|
|
|
|
|
|
pc_driver = alloc_tty_driver(MAX_ALLOC);
|
|
|
|
if (!pc_driver)
|
2006-10-17 15:10:28 +08:00
|
|
|
goto out1;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
pc_info = alloc_tty_driver(MAX_ALLOC);
|
2006-10-17 15:10:28 +08:00
|
|
|
if (!pc_info)
|
|
|
|
goto out2;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* If epca_setup has not been ran by LILO set num_cards to defaults;
|
|
|
|
* copy board structure defined by digiConfig into drivers board
|
|
|
|
* structure. Note : If LILO has ran epca_setup then epca_setup will
|
|
|
|
* handle defining num_cards as well as copying the data into the board
|
|
|
|
* structure.
|
|
|
|
*/
|
|
|
|
if (!liloconfig) {
|
|
|
|
/* driver has been configured via. epcaconfig */
|
2005-04-17 06:20:36 +08:00
|
|
|
nbdevs = NBDEVS;
|
|
|
|
num_cards = NUMCARDS;
|
2007-10-17 14:26:37 +08:00
|
|
|
memcpy(&boards, &static_boards,
|
|
|
|
sizeof(struct board_info) * NUMCARDS);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Note : If lilo was used to configure the driver and the ignore
|
|
|
|
* epcaconfig option was choosen (digiepca=2) then nbdevs and num_cards
|
|
|
|
* will equal 0 at this point. This is okay; PCI cards will still be
|
|
|
|
* picked up if detected.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Set up interrupt, we will worry about memory allocation in
|
|
|
|
* post_fep_init.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_INFO "DIGI epca driver version %s loaded.\n", VERSION);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* NOTE : This code assumes that the number of ports found in the
|
|
|
|
* boards array is correct. This could be wrong if the card in question
|
|
|
|
* is PCI (And therefore has no ports entry in the boards structure.)
|
|
|
|
* The rest of the information will be valid for PCI because the
|
|
|
|
* beginning of pc_init scans for PCI and determines i/o and base
|
|
|
|
* memory addresses. I am not sure if it is possible to read the number
|
|
|
|
* of ports supported by the card prior to it being booted (Since that
|
|
|
|
* is the state it is in when pc_init is run). Because it is not
|
|
|
|
* possible to query the number of supported ports until after the card
|
|
|
|
* has booted; we are required to calculate the card_ptrs as the card
|
|
|
|
* is initialized (Inside post_fep_init). The negative thing about this
|
|
|
|
* approach is that digiDload's call to GET_INFO will have a bad port
|
|
|
|
* value. (Since this is called prior to post_fep_init.)
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_boards_found = 0;
|
2007-10-17 14:26:37 +08:00
|
|
|
if (num_cards < MAXBOARDS)
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_boards_found += init_PCI();
|
|
|
|
num_cards += pci_boards_found;
|
|
|
|
|
|
|
|
pc_driver->owner = THIS_MODULE;
|
2007-10-17 14:26:37 +08:00
|
|
|
pc_driver->name = "ttyD";
|
|
|
|
pc_driver->major = DIGI_MAJOR;
|
2005-04-17 06:20:36 +08:00
|
|
|
pc_driver->minor_start = 0;
|
|
|
|
pc_driver->type = TTY_DRIVER_TYPE_SERIAL;
|
|
|
|
pc_driver->subtype = SERIAL_TYPE_NORMAL;
|
|
|
|
pc_driver->init_termios = tty_std_termios;
|
|
|
|
pc_driver->init_termios.c_iflag = 0;
|
|
|
|
pc_driver->init_termios.c_oflag = 0;
|
|
|
|
pc_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL;
|
|
|
|
pc_driver->init_termios.c_lflag = 0;
|
2006-12-08 18:38:45 +08:00
|
|
|
pc_driver->init_termios.c_ispeed = 9600;
|
|
|
|
pc_driver->init_termios.c_ospeed = 9600;
|
2008-07-22 18:18:12 +08:00
|
|
|
pc_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_HARDWARE_BREAK;
|
2005-04-17 06:20:36 +08:00
|
|
|
tty_set_operations(pc_driver, &pc_ops);
|
|
|
|
|
|
|
|
pc_info->owner = THIS_MODULE;
|
|
|
|
pc_info->name = "digi_ctl";
|
|
|
|
pc_info->major = DIGIINFOMAJOR;
|
|
|
|
pc_info->minor_start = 0;
|
|
|
|
pc_info->type = TTY_DRIVER_TYPE_SERIAL;
|
|
|
|
pc_info->subtype = SERIAL_TYPE_INFO;
|
|
|
|
pc_info->init_termios = tty_std_termios;
|
|
|
|
pc_info->init_termios.c_iflag = 0;
|
|
|
|
pc_info->init_termios.c_oflag = 0;
|
|
|
|
pc_info->init_termios.c_lflag = 0;
|
|
|
|
pc_info->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL;
|
2006-12-08 18:38:45 +08:00
|
|
|
pc_info->init_termios.c_ispeed = 9600;
|
|
|
|
pc_info->init_termios.c_ospeed = 9600;
|
2005-04-17 06:20:36 +08:00
|
|
|
pc_info->flags = TTY_DRIVER_REAL_RAW;
|
|
|
|
tty_set_operations(pc_info, &info_ops);
|
|
|
|
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
for (crd = 0; crd < num_cards; crd++) {
|
|
|
|
/*
|
|
|
|
* This is where the appropriate memory handlers for the
|
|
|
|
* hardware is set. Everything at runtime blindly jumps through
|
|
|
|
* these vectors.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* defined in epcaconfig.h */
|
|
|
|
bd = &boards[crd];
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
switch (bd->type) {
|
|
|
|
case PCXEM:
|
|
|
|
case EISAXEM:
|
|
|
|
bd->memwinon = pcxem_memwinon;
|
|
|
|
bd->memwinoff = pcxem_memwinoff;
|
|
|
|
bd->globalwinon = pcxem_globalwinon;
|
|
|
|
bd->txwinon = pcxem_txwinon;
|
|
|
|
bd->rxwinon = pcxem_rxwinon;
|
|
|
|
bd->memoff = pcxem_memoff;
|
|
|
|
bd->assertgwinon = dummy_assertgwinon;
|
|
|
|
bd->assertmemoff = dummy_assertmemoff;
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
case PCIXEM:
|
|
|
|
case PCIXRJ:
|
|
|
|
case PCIXR:
|
|
|
|
bd->memwinon = dummy_memwinon;
|
|
|
|
bd->memwinoff = dummy_memwinoff;
|
|
|
|
bd->globalwinon = dummy_globalwinon;
|
|
|
|
bd->txwinon = dummy_txwinon;
|
|
|
|
bd->rxwinon = dummy_rxwinon;
|
|
|
|
bd->memoff = dummy_memoff;
|
|
|
|
bd->assertgwinon = dummy_assertgwinon;
|
|
|
|
bd->assertmemoff = dummy_assertmemoff;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
case PCXE:
|
|
|
|
case PCXEVE:
|
|
|
|
bd->memwinon = pcxe_memwinon;
|
|
|
|
bd->memwinoff = pcxe_memwinoff;
|
|
|
|
bd->globalwinon = pcxe_globalwinon;
|
|
|
|
bd->txwinon = pcxe_txwinon;
|
|
|
|
bd->rxwinon = pcxe_rxwinon;
|
|
|
|
bd->memoff = pcxe_memoff;
|
|
|
|
bd->assertgwinon = dummy_assertgwinon;
|
|
|
|
bd->assertmemoff = dummy_assertmemoff;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
case PCXI:
|
|
|
|
case PC64XE:
|
|
|
|
bd->memwinon = pcxi_memwinon;
|
|
|
|
bd->memwinoff = pcxi_memwinoff;
|
|
|
|
bd->globalwinon = pcxi_globalwinon;
|
|
|
|
bd->txwinon = pcxi_txwinon;
|
|
|
|
bd->rxwinon = pcxi_rxwinon;
|
|
|
|
bd->memoff = pcxi_memoff;
|
|
|
|
bd->assertgwinon = pcxi_assertgwinon;
|
|
|
|
bd->assertmemoff = pcxi_assertmemoff;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
default:
|
2005-04-17 06:20:36 +08:00
|
|
|
break;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Some cards need a memory segment to be defined for use in
|
|
|
|
* transmit and receive windowing operations. These boards are
|
|
|
|
* listed in the below switch. In the case of the XI the amount
|
|
|
|
* of memory on the board is variable so the memory_seg is also
|
|
|
|
* variable. This code determines what they segment should be.
|
|
|
|
*/
|
|
|
|
switch (bd->type) {
|
|
|
|
case PCXE:
|
|
|
|
case PCXEVE:
|
|
|
|
case PC64XE:
|
|
|
|
bd->memory_seg = 0xf000;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
case PCXI:
|
|
|
|
board_id = inb((int)bd->port);
|
|
|
|
if ((board_id & 0x1) == 0x1) {
|
|
|
|
/* it's an XI card */
|
|
|
|
/* Is it a 64K board */
|
|
|
|
if ((board_id & 0x30) == 0)
|
|
|
|
bd->memory_seg = 0xf000;
|
|
|
|
|
|
|
|
/* Is it a 128K board */
|
|
|
|
if ((board_id & 0x30) == 0x10)
|
|
|
|
bd->memory_seg = 0xe000;
|
|
|
|
|
|
|
|
/* Is is a 256K board */
|
|
|
|
if ((board_id & 0x30) == 0x20)
|
|
|
|
bd->memory_seg = 0xc000;
|
|
|
|
|
|
|
|
/* Is it a 512K board */
|
|
|
|
if ((board_id & 0x30) == 0x30)
|
|
|
|
bd->memory_seg = 0x8000;
|
|
|
|
} else
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_ERR "epca: Board at 0x%x doesn't appear to be an XI\n", (int)bd->port);
|
2007-10-17 14:26:37 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-10-17 15:10:28 +08:00
|
|
|
err = tty_register_driver(pc_driver);
|
|
|
|
if (err) {
|
|
|
|
printk(KERN_ERR "Couldn't register Digi PC/ driver");
|
|
|
|
goto out3;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-10-17 15:10:28 +08:00
|
|
|
err = tty_register_driver(pc_info);
|
|
|
|
if (err) {
|
|
|
|
printk(KERN_ERR "Couldn't register Digi PC/ info ");
|
|
|
|
goto out4;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/* Start up the poller to check for events on all enabled boards */
|
2005-04-17 06:20:36 +08:00
|
|
|
init_timer(&epca_timer);
|
|
|
|
epca_timer.function = epcapoll;
|
|
|
|
mod_timer(&epca_timer, jiffies + HZ/25);
|
|
|
|
return 0;
|
|
|
|
|
2006-10-17 15:10:28 +08:00
|
|
|
out4:
|
|
|
|
tty_unregister_driver(pc_driver);
|
|
|
|
out3:
|
|
|
|
put_tty_driver(pc_info);
|
|
|
|
out2:
|
|
|
|
put_tty_driver(pc_driver);
|
|
|
|
out1:
|
|
|
|
return err;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void post_fep_init(unsigned int crd)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
int i;
|
2005-09-16 05:53:28 +08:00
|
|
|
void __iomem *memaddr;
|
|
|
|
struct global_data __iomem *gd;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct board_info *bd;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2007-10-17 14:26:37 +08:00
|
|
|
struct channel *ch;
|
|
|
|
int shrinkmem = 0, lowwater;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* This call is made by the user via. the ioctl call DIGI_INIT. It is
|
|
|
|
* responsible for setting up all the card specific stuff.
|
|
|
|
*/
|
|
|
|
bd = &boards[crd];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* If this is a PCI board, get the port info. Remember PCI cards do not
|
|
|
|
* have entries into the epcaconfig.h file, so we can't get the number
|
|
|
|
* of ports from it. Unfortunetly, this means that anyone doing a
|
|
|
|
* DIGI_GETINFO before the board has booted will get an invalid number
|
|
|
|
* of ports returned (It should return 0). Calls to DIGI_GETINFO after
|
|
|
|
* DIGI_INIT has been called will return the proper values.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
if (bd->type >= PCIXEM) { /* Begin get PCI number of ports */
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Below we use XEMPORTS as a memory offset regardless of which
|
|
|
|
* PCI card it is. This is because all of the supported PCI
|
|
|
|
* cards have the same memory offset for the channel data. This
|
|
|
|
* will have to be changed if we ever develop a PCI/XE card.
|
|
|
|
* NOTE : The FEP manual states that the port offset is 0xC22
|
|
|
|
* as opposed to 0xC02. This is only true for PC/XE, and PC/XI
|
|
|
|
* cards; not for the XEM, or CX series. On the PCI cards the
|
|
|
|
* number of ports is determined by reading a ID PROM located
|
|
|
|
* in the box attached to the card. The card can then determine
|
|
|
|
* the index the id to determine the number of ports available.
|
|
|
|
* (FYI - The id should be located at 0x1ac (And may use up to
|
|
|
|
* 4 bytes if the box in question is a XEM or CX)).
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
/* PCI cards are already remapped at this point ISA are not */
|
|
|
|
bd->numports = readw(bd->re_map_membase + XEMPORTS);
|
2008-04-30 15:54:16 +08:00
|
|
|
epcaassert(bd->numports <= 64, "PCI returned a invalid number of ports");
|
2005-04-17 06:20:36 +08:00
|
|
|
nbdevs += (bd->numports);
|
2005-09-07 06:16:44 +08:00
|
|
|
} else {
|
|
|
|
/* Fix up the mappings for ISA/EISA etc */
|
|
|
|
/* FIXME: 64K - can we be smarter ? */
|
2008-04-30 15:54:16 +08:00
|
|
|
bd->re_map_membase = ioremap_nocache(bd->membase, 0x10000);
|
2005-09-07 06:16:44 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (crd != 0)
|
|
|
|
card_ptr[crd] = card_ptr[crd-1] + boards[crd-1].numports;
|
|
|
|
else
|
|
|
|
card_ptr[crd] = &digi_channels[crd]; /* <- For card 0 only */
|
|
|
|
|
|
|
|
ch = card_ptr[crd];
|
|
|
|
epcaassert(ch <= &digi_channels[nbdevs - 1], "ch out of range");
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
memaddr = bd->re_map_membase;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The below assignment will set bc to point at the BEGINING of the
|
|
|
|
* cards channel structures. For 1 card there will be between 8 and 64
|
|
|
|
* of these structures.
|
|
|
|
*/
|
2005-09-16 05:53:28 +08:00
|
|
|
bc = memaddr + CHANSTRUCT;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The below assignment will set gd to point at the BEGINING of global
|
|
|
|
* memory address 0xc00. The first data in that global memory actually
|
|
|
|
* starts at address 0xc1a. The command in pointer begins at 0xd10.
|
|
|
|
*/
|
2005-09-16 05:53:28 +08:00
|
|
|
gd = memaddr + GLOBAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* XEPORTS (address 0xc22) points at the number of channels the card
|
|
|
|
* supports. (For 64XE, XI, XEM, and XR use 0xc02)
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
if ((bd->type == PCXEVE || bd->type == PCXE) &&
|
|
|
|
(readw(memaddr + XEPORTS) < 3))
|
2005-04-17 06:20:36 +08:00
|
|
|
shrinkmem = 1;
|
|
|
|
if (bd->type < PCIXEM)
|
|
|
|
if (!request_region((int)bd->port, 4, board_desc[bd->type]))
|
2007-10-17 14:26:37 +08:00
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
memwinon(bd, 0);
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Remember ch is the main drivers channels structure, while bc is the
|
|
|
|
* cards channel structure.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < bd->numports; i++, ch++, bc++) {
|
2005-09-07 06:16:44 +08:00
|
|
|
unsigned long flags;
|
2005-09-16 05:53:28 +08:00
|
|
|
u16 tseg, rseg;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-10-13 17:32:09 +08:00
|
|
|
tty_port_init(&ch->port);
|
2009-01-02 21:48:17 +08:00
|
|
|
ch->port.ops = &epca_port_ops;
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->brdchan = bc;
|
|
|
|
ch->mailbox = gd;
|
2006-11-22 22:57:56 +08:00
|
|
|
INIT_WORK(&ch->tqueue, do_softint);
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->board = &boards[crd];
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
|
|
|
switch (bd->type) {
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Since some of the boards use different bitmaps for
|
|
|
|
* their control signals we cannot hard code these
|
|
|
|
* values and retain portability. We virtualize this
|
|
|
|
* data here.
|
|
|
|
*/
|
|
|
|
case EISAXEM:
|
|
|
|
case PCXEM:
|
|
|
|
case PCIXEM:
|
|
|
|
case PCIXRJ:
|
|
|
|
case PCIXR:
|
|
|
|
ch->m_rts = 0x02;
|
|
|
|
ch->m_dcd = 0x80;
|
|
|
|
ch->m_dsr = 0x20;
|
|
|
|
ch->m_cts = 0x10;
|
|
|
|
ch->m_ri = 0x40;
|
|
|
|
ch->m_dtr = 0x01;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCXE:
|
|
|
|
case PCXEVE:
|
|
|
|
case PCXI:
|
|
|
|
case PC64XE:
|
|
|
|
ch->m_rts = 0x02;
|
|
|
|
ch->m_dcd = 0x08;
|
|
|
|
ch->m_dsr = 0x10;
|
|
|
|
ch->m_cts = 0x20;
|
|
|
|
ch->m_ri = 0x40;
|
|
|
|
ch->m_dtr = 0x80;
|
|
|
|
break;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (boards[crd].altpin) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->dsr = ch->m_dcd;
|
|
|
|
ch->dcd = ch->m_dsr;
|
|
|
|
ch->digiext.digi_flags |= DIGI_ALTPIN;
|
2007-10-17 14:26:37 +08:00
|
|
|
} else {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->dcd = ch->m_dcd;
|
|
|
|
ch->dsr = ch->m_dsr;
|
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->boardnum = crd;
|
|
|
|
ch->channelnum = i;
|
|
|
|
ch->magic = EPCA_MAGIC;
|
2009-01-02 21:48:04 +08:00
|
|
|
tty_port_tty_set(&ch->port, NULL);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (shrinkmem) {
|
2005-04-17 06:20:36 +08:00
|
|
|
fepcmd(ch, SETBUFFER, 32, 0, 0, 0);
|
|
|
|
shrinkmem = 0;
|
|
|
|
}
|
|
|
|
|
2005-09-16 05:53:28 +08:00
|
|
|
tseg = readw(&bc->tseg);
|
|
|
|
rseg = readw(&bc->rseg);
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
switch (bd->type) {
|
2007-10-17 14:26:37 +08:00
|
|
|
case PCIXEM:
|
|
|
|
case PCIXRJ:
|
|
|
|
case PCIXR:
|
|
|
|
/* Cover all the 2MEG cards */
|
|
|
|
ch->txptr = memaddr + ((tseg << 4) & 0x1fffff);
|
|
|
|
ch->rxptr = memaddr + ((rseg << 4) & 0x1fffff);
|
|
|
|
ch->txwin = FEPWIN | (tseg >> 11);
|
|
|
|
ch->rxwin = FEPWIN | (rseg >> 11);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCXEM:
|
|
|
|
case EISAXEM:
|
|
|
|
/* Cover all the 32K windowed cards */
|
|
|
|
/* Mask equal to window size - 1 */
|
|
|
|
ch->txptr = memaddr + ((tseg << 4) & 0x7fff);
|
|
|
|
ch->rxptr = memaddr + ((rseg << 4) & 0x7fff);
|
|
|
|
ch->txwin = FEPWIN | (tseg >> 11);
|
|
|
|
ch->rxwin = FEPWIN | (rseg >> 11);
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
case PCXEVE:
|
|
|
|
case PCXE:
|
2008-04-30 15:54:16 +08:00
|
|
|
ch->txptr = memaddr + (((tseg - bd->memory_seg) << 4)
|
|
|
|
& 0x1fff);
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->txwin = FEPWIN | ((tseg - bd->memory_seg) >> 9);
|
2008-04-30 15:54:16 +08:00
|
|
|
ch->rxptr = memaddr + (((rseg - bd->memory_seg) << 4)
|
|
|
|
& 0x1fff);
|
|
|
|
ch->rxwin = FEPWIN | ((rseg - bd->memory_seg) >> 9);
|
2007-10-17 14:26:37 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PCXI:
|
|
|
|
case PC64XE:
|
|
|
|
ch->txptr = memaddr + ((tseg - bd->memory_seg) << 4);
|
|
|
|
ch->rxptr = memaddr + ((rseg - bd->memory_seg) << 4);
|
|
|
|
ch->txwin = ch->rxwin = 0;
|
|
|
|
break;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ch->txbufhead = 0;
|
2005-09-16 05:53:28 +08:00
|
|
|
ch->txbufsize = readw(&bc->tmax) + 1;
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->rxbufhead = 0;
|
2005-09-16 05:53:28 +08:00
|
|
|
ch->rxbufsize = readw(&bc->rmax) + 1;
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
lowwater = ch->txbufsize >= 2000 ? 1024 : (ch->txbufsize / 2);
|
|
|
|
|
|
|
|
/* Set transmitter low water mark */
|
|
|
|
fepcmd(ch, STXLWATER, lowwater, 0, 10, 0);
|
|
|
|
|
|
|
|
/* Set receiver low water mark */
|
|
|
|
fepcmd(ch, SRXLWATER, (ch->rxbufsize / 4), 0, 10, 0);
|
|
|
|
|
|
|
|
/* Set receiver high water mark */
|
|
|
|
fepcmd(ch, SRXHWATER, (3 * ch->rxbufsize / 4), 0, 10, 0);
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
writew(100, &bc->edelay);
|
|
|
|
writeb(1, &bc->idata);
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
ch->startc = readb(&bc->startc);
|
|
|
|
ch->stopc = readb(&bc->stopc);
|
|
|
|
ch->startca = readb(&bc->startca);
|
|
|
|
ch->stopca = readb(&bc->stopca);
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->fepcflag = 0;
|
|
|
|
ch->fepiflag = 0;
|
|
|
|
ch->fepoflag = 0;
|
|
|
|
ch->fepstartc = 0;
|
|
|
|
ch->fepstopc = 0;
|
|
|
|
ch->fepstartca = 0;
|
|
|
|
ch->fepstopca = 0;
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2009-01-02 21:48:11 +08:00
|
|
|
ch->port.close_delay = 50;
|
2005-09-07 06:16:44 +08:00
|
|
|
|
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
printk(KERN_INFO
|
2008-04-30 15:54:16 +08:00
|
|
|
"Digi PC/Xx Driver V%s: %s I/O = 0x%lx Mem = 0x%lx Ports = %d\n",
|
|
|
|
VERSION, board_desc[bd->type], (long)bd->port,
|
|
|
|
(long)bd->membase, bd->numports);
|
2005-04-17 06:20:36 +08:00
|
|
|
memwinoff(bd, 0);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void epcapoll(unsigned long ignored)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
|
|
|
int crd;
|
2008-04-30 15:54:16 +08:00
|
|
|
unsigned int head, tail;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
|
|
|
struct board_info *bd;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* This routine is called upon every timer interrupt. Even though the
|
|
|
|
* Digi series cards are capable of generating interrupts this method
|
|
|
|
* of non-looping polling is more efficient. This routine checks for
|
|
|
|
* card generated events (Such as receive data, are transmit buffer
|
|
|
|
* empty) and acts on those events.
|
|
|
|
*/
|
|
|
|
for (crd = 0; crd < num_cards; crd++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
bd = &boards[crd];
|
|
|
|
ch = card_ptr[crd];
|
|
|
|
|
|
|
|
if ((bd->status == DISABLED) || digi_poller_inhibited)
|
2007-10-17 14:26:37 +08:00
|
|
|
continue;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* assertmemoff is not needed here; indeed it is an empty
|
|
|
|
* subroutine. It is being kept because future boards may need
|
|
|
|
* this as well as some legacy boards.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
assertmemoff(ch);
|
|
|
|
|
|
|
|
globalwinon(ch);
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* In this case head and tail actually refer to the event queue
|
|
|
|
* not the transmit or receive queue.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
head = readw(&ch->mailbox->ein);
|
|
|
|
tail = readw(&ch->mailbox->eout);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/* If head isn't equal to tail we have an event */
|
2005-04-17 06:20:36 +08:00
|
|
|
if (head != tail)
|
|
|
|
doevent(crd);
|
|
|
|
memoff(ch);
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
|
|
|
} /* End for each card */
|
2005-04-17 06:20:36 +08:00
|
|
|
mod_timer(&epca_timer, jiffies + (HZ / 25));
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void doevent(int crd)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-09-16 05:53:28 +08:00
|
|
|
void __iomem *eventbuf;
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch, *chan0;
|
|
|
|
static struct tty_struct *tty;
|
2005-09-07 06:16:44 +08:00
|
|
|
struct board_info *bd;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2005-09-07 06:16:44 +08:00
|
|
|
unsigned int tail, head;
|
|
|
|
int event, channel;
|
|
|
|
int mstat, lstat;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* This subroutine is called by epcapoll when an event is detected
|
|
|
|
* in the event queue. This routine responds to those events.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
bd = &boards[crd];
|
|
|
|
|
|
|
|
chan0 = card_ptr[crd];
|
|
|
|
epcaassert(chan0 <= &digi_channels[nbdevs - 1], "ch out of range");
|
|
|
|
assertgwinon(chan0);
|
2008-04-30 15:54:16 +08:00
|
|
|
while ((tail = readw(&chan0->mailbox->eout)) !=
|
|
|
|
(head = readw(&chan0->mailbox->ein))) {
|
|
|
|
/* Begin while something in event queue */
|
2005-04-17 06:20:36 +08:00
|
|
|
assertgwinon(chan0);
|
2005-09-07 06:16:44 +08:00
|
|
|
eventbuf = bd->re_map_membase + tail + ISTART;
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Get the channel the event occurred on */
|
2005-09-07 06:16:44 +08:00
|
|
|
channel = readb(eventbuf);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Get the actual event code that occurred */
|
2005-09-07 06:16:44 +08:00
|
|
|
event = readb(eventbuf + 1);
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The two assignments below get the current modem status
|
|
|
|
* (mstat) and the previous modem status (lstat). These are
|
|
|
|
* useful becuase an event could signal a change in modem
|
|
|
|
* signals itself.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
mstat = readb(eventbuf + 2);
|
|
|
|
lstat = readb(eventbuf + 3);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
ch = chan0 + channel;
|
2005-09-07 06:16:44 +08:00
|
|
|
if ((unsigned)channel >= bd->numports || !ch) {
|
2005-04-17 06:20:36 +08:00
|
|
|
if (channel >= bd->numports)
|
|
|
|
ch = chan0;
|
|
|
|
bc = ch->brdchan;
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
bc = ch->brdchan;
|
|
|
|
if (bc == NULL)
|
2005-04-17 06:20:36 +08:00
|
|
|
goto next;
|
|
|
|
|
2009-01-02 21:48:04 +08:00
|
|
|
tty = tty_port_tty_get(&ch->port);
|
2005-09-07 06:16:44 +08:00
|
|
|
if (event & DATA_IND) { /* Begin DATA_IND */
|
2009-01-02 21:48:04 +08:00
|
|
|
receive_data(ch, tty);
|
2005-04-17 06:20:36 +08:00
|
|
|
assertgwinon(ch);
|
|
|
|
} /* End DATA_IND */
|
|
|
|
/* else *//* Fix for DCD transition missed bug */
|
2007-10-17 14:26:37 +08:00
|
|
|
if (event & MODEMCHG_IND) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* A modem signal change has been indicated */
|
|
|
|
ch->imodem = mstat;
|
2009-06-11 19:41:05 +08:00
|
|
|
if (test_bit(ASYNCB_CHECK_CD, &ch->port.flags)) {
|
2008-04-30 15:54:16 +08:00
|
|
|
/* We are now receiving dcd */
|
|
|
|
if (mstat & ch->dcd)
|
2008-07-17 04:55:02 +08:00
|
|
|
wake_up_interruptible(&ch->port.open_wait);
|
2008-04-30 15:54:16 +08:00
|
|
|
else /* No dcd; hangup */
|
|
|
|
pc_sched_event(ch, EPCA_EVENT_HANGUP);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
if (tty) {
|
|
|
|
if (event & BREAK_IND) {
|
2005-04-17 06:20:36 +08:00
|
|
|
/* A break has been indicated */
|
[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 12:54:13 +08:00
|
|
|
tty_insert_flip_char(tty, 0, TTY_BREAK);
|
2007-10-17 14:26:37 +08:00
|
|
|
tty_schedule_flip(tty);
|
|
|
|
} else if (event & LOWTX_IND) {
|
|
|
|
if (ch->statusflags & LOWWAIT) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->statusflags &= ~LOWWAIT;
|
|
|
|
tty_wakeup(tty);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
} else if (event & EMPTYTX_IND) {
|
2008-04-30 15:54:16 +08:00
|
|
|
/* This event is generated by
|
|
|
|
setup_empty_event */
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->statusflags &= ~TXBUSY;
|
2007-10-17 14:26:37 +08:00
|
|
|
if (ch->statusflags & EMPTYWAIT) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->statusflags &= ~EMPTYWAIT;
|
|
|
|
tty_wakeup(tty);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
}
|
2009-01-02 21:48:04 +08:00
|
|
|
tty_kref_put(tty);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2008-04-30 15:54:16 +08:00
|
|
|
next:
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
BUG_ON(!bc);
|
|
|
|
writew(1, &bc->idata);
|
|
|
|
writew((tail + 4) & (IMAX - ISTART - 4), &chan0->mailbox->eout);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(chan0);
|
|
|
|
} /* End while something in event queue */
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void fepcmd(struct channel *ch, int cmd, int word_or_byte,
|
2008-04-30 15:54:16 +08:00
|
|
|
int byte2, int ncmds, int bytecmd)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-09-16 05:53:28 +08:00
|
|
|
unchar __iomem *memaddr;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int head, cmdTail, cmdStart, cmdMax;
|
|
|
|
long count;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
/* This is the routine in which commands may be passed to the card. */
|
|
|
|
|
|
|
|
if (ch->board->status == DISABLED)
|
|
|
|
return;
|
|
|
|
assertgwinon(ch);
|
|
|
|
/* Remember head (As well as max) is just an offset not a base addr */
|
2005-09-07 06:16:44 +08:00
|
|
|
head = readw(&ch->mailbox->cin);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* cmdStart is a base address */
|
2005-09-07 06:16:44 +08:00
|
|
|
cmdStart = readw(&ch->mailbox->cstart);
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* We do the addition below because we do not want a max pointer
|
|
|
|
* relative to cmdStart. We want a max pointer that points at the
|
|
|
|
* physical end of the command queue.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
cmdMax = (cmdStart + 4 + readw(&ch->mailbox->cmax));
|
2005-04-17 06:20:36 +08:00
|
|
|
memaddr = ch->board->re_map_membase;
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (head >= (cmdMax - cmdStart) || (head & 03)) {
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_ERR "line %d: Out of range, cmd = %x, head = %x\n",
|
|
|
|
__LINE__, cmd, head);
|
|
|
|
printk(KERN_ERR "line %d: Out of range, cmdMax = %x, cmdStart = %x\n",
|
|
|
|
__LINE__, cmdMax, cmdStart);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
2005-09-07 06:16:44 +08:00
|
|
|
if (bytecmd) {
|
|
|
|
writeb(cmd, memaddr + head + cmdStart + 0);
|
|
|
|
writeb(ch->channelnum, memaddr + head + cmdStart + 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Below word_or_byte is bits to set */
|
2005-09-07 06:16:44 +08:00
|
|
|
writeb(word_or_byte, memaddr + head + cmdStart + 2);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Below byte2 is bits to reset */
|
2005-09-07 06:16:44 +08:00
|
|
|
writeb(byte2, memaddr + head + cmdStart + 3);
|
|
|
|
} else {
|
|
|
|
writeb(cmd, memaddr + head + cmdStart + 0);
|
|
|
|
writeb(ch->channelnum, memaddr + head + cmdStart + 1);
|
|
|
|
writeb(word_or_byte, memaddr + head + cmdStart + 2);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
head = (head + 4) & (cmdMax - cmdStart - 4);
|
2005-09-07 06:16:44 +08:00
|
|
|
writew(head, &ch->mailbox->cin);
|
2005-04-17 06:20:36 +08:00
|
|
|
count = FEPTIMEOUT;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
for (;;) {
|
2005-04-17 06:20:36 +08:00
|
|
|
count--;
|
2005-09-07 06:16:44 +08:00
|
|
|
if (count == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
printk(KERN_ERR "<Error> - Fep not responding in fepcmd()\n");
|
|
|
|
return;
|
|
|
|
}
|
2005-09-07 06:16:44 +08:00
|
|
|
head = readw(&ch->mailbox->cin);
|
|
|
|
cmdTail = readw(&ch->mailbox->cout);
|
2005-04-17 06:20:36 +08:00
|
|
|
n = (head - cmdTail) & (cmdMax - cmdStart - 4);
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Basically this will break when the FEP acknowledges the
|
|
|
|
* command by incrementing cmdTail (Making it equal to head).
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (n <= ncmds * (sizeof(short) * 4))
|
2007-10-17 14:26:37 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Digi products use fields in their channels structures that are very similar
|
|
|
|
* to the c_cflag and c_iflag fields typically found in UNIX termios
|
|
|
|
* structures. The below three routines allow mappings between these hardware
|
|
|
|
* "flags" and their respective Linux flags.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
static unsigned termios2digi_h(struct channel *ch, unsigned cflag)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned res = 0;
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (cflag & CRTSCTS) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->digiext.digi_flags |= (RTSPACE | CTSPACE);
|
|
|
|
res |= ((ch->m_cts) | (ch->m_rts));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch->digiext.digi_flags & RTSPACE)
|
|
|
|
res |= ch->m_rts;
|
|
|
|
|
|
|
|
if (ch->digiext.digi_flags & DTRPACE)
|
|
|
|
res |= ch->m_dtr;
|
|
|
|
|
|
|
|
if (ch->digiext.digi_flags & CTSPACE)
|
|
|
|
res |= ch->m_cts;
|
|
|
|
|
|
|
|
if (ch->digiext.digi_flags & DSRPACE)
|
|
|
|
res |= ch->dsr;
|
|
|
|
|
|
|
|
if (ch->digiext.digi_flags & DCDPACE)
|
|
|
|
res |= ch->dcd;
|
|
|
|
|
|
|
|
if (res & (ch->m_rts))
|
|
|
|
ch->digiext.digi_flags |= RTSPACE;
|
|
|
|
|
|
|
|
if (res & (ch->m_cts))
|
|
|
|
ch->digiext.digi_flags |= CTSPACE;
|
|
|
|
|
|
|
|
return res;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static unsigned termios2digi_i(struct channel *ch, unsigned iflag)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
|
|
|
unsigned res = iflag & (IGNBRK | BRKINT | IGNPAR | PARMRK |
|
2008-04-30 15:54:16 +08:00
|
|
|
INPCK | ISTRIP | IXON | IXANY | IXOFF);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ch->digiext.digi_flags & DIGI_AIXON)
|
|
|
|
res |= IAIXON;
|
|
|
|
return res;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static unsigned termios2digi_c(struct channel *ch, unsigned cflag)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned res = 0;
|
2007-10-17 14:26:37 +08:00
|
|
|
if (cflag & CBAUDEX) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->digiext.digi_flags |= DIGI_FAST;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* HUPCL bit is used by FEP to indicate fast baud table is to
|
|
|
|
* be used.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
res |= FEP_HUPCL;
|
2007-10-17 14:26:37 +08:00
|
|
|
} else
|
|
|
|
ch->digiext.digi_flags &= ~DIGI_FAST;
|
|
|
|
/*
|
|
|
|
* CBAUD has bit position 0x1000 set these days to indicate Linux
|
|
|
|
* baud rate remap. Digi hardware can't handle the bit assignment.
|
|
|
|
* (We use a different bit assignment for high speed.). Clear this
|
|
|
|
* bit out.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
res |= cflag & ((CBAUD ^ CBAUDEX) | PARODD | PARENB | CSTOPB | CSIZE);
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* This gets a little confusing. The Digi cards have their own
|
2008-02-03 23:11:42 +08:00
|
|
|
* representation of c_cflags controlling baud rate. For the most part
|
2007-10-17 14:26:37 +08:00
|
|
|
* this is identical to the Linux implementation. However; Digi
|
|
|
|
* supports one rate (76800) that Linux doesn't. This means that the
|
|
|
|
* c_cflag entry that would normally mean 76800 for Digi actually means
|
|
|
|
* 115200 under Linux. Without the below mapping, a stty 115200 would
|
|
|
|
* only drive the board at 76800. Since the rate 230400 is also found
|
|
|
|
* after 76800, the same problem afflicts us when we choose a rate of
|
|
|
|
* 230400. Without the below modificiation stty 230400 would actually
|
|
|
|
* give us 115200.
|
|
|
|
*
|
|
|
|
* There are two additional differences. The Linux value for CLOCAL
|
|
|
|
* (0x800; 0004000) has no meaning to the Digi hardware. Also in later
|
|
|
|
* releases of Linux; the CBAUD define has CBAUDEX (0x1000; 0010000)
|
|
|
|
* ored into it (CBAUD = 0x100f as opposed to 0xf). CBAUDEX should be
|
|
|
|
* checked for a screened out prior to termios2digi_c returning. Since
|
|
|
|
* CLOCAL isn't used by the board this can be ignored as long as the
|
|
|
|
* returned value is used only by Digi hardware.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
if (cflag & CBAUDEX) {
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The below code is trying to guarantee that only baud rates
|
|
|
|
* 115200 and 230400 are remapped. We use exclusive or because
|
|
|
|
* the various baud rates share common bit positions and
|
|
|
|
* therefore can't be tested for easily.
|
|
|
|
*/
|
|
|
|
if ((!((cflag & 0x7) ^ (B115200 & ~CBAUDEX))) ||
|
2005-04-17 06:20:36 +08:00
|
|
|
(!((cflag & 0x7) ^ (B230400 & ~CBAUDEX))))
|
|
|
|
res += 1;
|
|
|
|
}
|
|
|
|
return res;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
/* Caller must hold the locks */
|
2005-04-17 06:20:36 +08:00
|
|
|
static void epcaparam(struct tty_struct *tty, struct channel *ch)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int cmdHead;
|
2006-12-08 18:38:45 +08:00
|
|
|
struct ktermios *ts;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned mval, hflow, cflag, iflag;
|
|
|
|
|
|
|
|
bc = ch->brdchan;
|
2008-04-30 15:53:52 +08:00
|
|
|
epcaassert(bc != NULL, "bc out of range");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
assertgwinon(ch);
|
|
|
|
ts = tty->termios;
|
2005-09-07 06:16:44 +08:00
|
|
|
if ((ts->c_cflag & CBAUD) == 0) { /* Begin CBAUD detected */
|
|
|
|
cmdHead = readw(&bc->rin);
|
2005-09-16 05:53:28 +08:00
|
|
|
writew(cmdHead, &bc->rout);
|
2005-09-07 06:16:44 +08:00
|
|
|
cmdHead = readw(&bc->tin);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Changing baud in mid-stream transmission can be wonderful */
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Flush current transmit buffer by setting cmdTail pointer
|
|
|
|
* (tout) to cmdHead pointer (tin). Hopefully the transmit
|
|
|
|
* buffer is empty.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
fepcmd(ch, STOUT, (unsigned) cmdHead, 0, 0, 0);
|
|
|
|
mval = 0;
|
2007-10-17 14:26:37 +08:00
|
|
|
} else { /* Begin CBAUD not detected */
|
|
|
|
/*
|
|
|
|
* c_cflags have changed but that change had nothing to do with
|
|
|
|
* BAUD. Propagate the change to the card.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
cflag = termios2digi_c(ch, ts->c_cflag);
|
2005-09-07 06:16:44 +08:00
|
|
|
if (cflag != ch->fepcflag) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->fepcflag = cflag;
|
|
|
|
/* Set baud rate, char size, stop bits, parity */
|
|
|
|
fepcmd(ch, SETCTRLFLAGS, (unsigned) cflag, 0, 0, 0);
|
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* If the user has not forced CLOCAL and if the device is not a
|
|
|
|
* CALLOUT device (Which is always CLOCAL) we set flags such
|
|
|
|
* that the driver will wait on carrier detect.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ts->c_cflag & CLOCAL)
|
2009-06-11 19:41:05 +08:00
|
|
|
clear_bit(ASYNCB_CHECK_CD, &ch->port.flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
else
|
2009-06-11 19:41:05 +08:00
|
|
|
set_bit(ASYNCB_CHECK_CD, &ch->port.flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
mval = ch->m_dtr | ch->m_rts;
|
|
|
|
} /* End CBAUD not detected */
|
|
|
|
iflag = termios2digi_i(ch, ts->c_iflag);
|
|
|
|
/* Check input mode flags */
|
2005-09-07 06:16:44 +08:00
|
|
|
if (iflag != ch->fepiflag) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->fepiflag = iflag;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Command sets channels iflag structure on the board. Such
|
|
|
|
* things as input soft flow control, handling of parity
|
|
|
|
* errors, and break handling are all set here.
|
2008-04-30 15:54:16 +08:00
|
|
|
*
|
|
|
|
* break handling, parity handling, input stripping,
|
|
|
|
* flow control chars
|
2007-10-17 14:26:37 +08:00
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
fepcmd(ch, SETIFLAGS, (unsigned int) ch->fepiflag, 0, 0, 0);
|
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Set the board mint value for this channel. This will cause hardware
|
|
|
|
* events to be generated each time the DCD signal (Described in mint)
|
|
|
|
* changes.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
writeb(ch->dcd, &bc->mint);
|
2005-04-17 06:20:36 +08:00
|
|
|
if ((ts->c_cflag & CLOCAL) || (ch->digiext.digi_flags & DIGI_FORCEDCD))
|
|
|
|
if (ch->digiext.digi_flags & DIGI_FORCEDCD)
|
2005-09-07 06:16:44 +08:00
|
|
|
writeb(0, &bc->mint);
|
|
|
|
ch->imodem = readb(&bc->mstat);
|
2005-04-17 06:20:36 +08:00
|
|
|
hflow = termios2digi_h(ch, ts->c_cflag);
|
2005-09-07 06:16:44 +08:00
|
|
|
if (hflow != ch->hflow) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->hflow = hflow;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Hard flow control has been selected but the board is not
|
|
|
|
* using it. Activate hard flow control now.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
fepcmd(ch, SETHFLOW, hflow, 0xff, 0, 1);
|
|
|
|
}
|
|
|
|
mval ^= ch->modemfake & (mval ^ ch->modem);
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (ch->omodem ^ mval) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->omodem = mval;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The below command sets the DTR and RTS mstat structure. If
|
|
|
|
* hard flow control is NOT active these changes will drive the
|
|
|
|
* output of the actual DTR and RTS lines. If hard flow control
|
|
|
|
* is active, the changes will be saved in the mstat structure
|
|
|
|
* and only asserted when hard flow control is turned off.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* First reset DTR & RTS; then set them */
|
|
|
|
fepcmd(ch, SETMODEM, 0, ((ch->m_dtr)|(ch->m_rts)), 0, 1);
|
|
|
|
fepcmd(ch, SETMODEM, mval, 0, 0, 1);
|
|
|
|
}
|
2005-09-07 06:16:44 +08:00
|
|
|
if (ch->startc != ch->fepstartc || ch->stopc != ch->fepstopc) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->fepstartc = ch->startc;
|
|
|
|
ch->fepstopc = ch->stopc;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The XON / XOFF characters have changed; propagate these
|
|
|
|
* changes to the card.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
fepcmd(ch, SONOFFC, ch->fepstartc, ch->fepstopc, 0, 1);
|
|
|
|
}
|
2005-09-07 06:16:44 +08:00
|
|
|
if (ch->startca != ch->fepstartca || ch->stopca != ch->fepstopca) {
|
2005-04-17 06:20:36 +08:00
|
|
|
ch->fepstartca = ch->startca;
|
|
|
|
ch->fepstopca = ch->stopca;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Similar to the above, this time the auxilarly XON / XOFF
|
|
|
|
* characters have changed; propagate these changes to the card.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
fepcmd(ch, SAUXONOFFC, ch->fepstartca, ch->fepstopca, 0, 1);
|
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
/* Caller holds lock */
|
2009-01-02 21:48:04 +08:00
|
|
|
static void receive_data(struct channel *ch, struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
unchar *rptr;
|
2006-12-08 18:38:45 +08:00
|
|
|
struct ktermios *ts = NULL;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2005-09-07 06:16:44 +08:00
|
|
|
int dataToRead, wrapgap, bytesAvailable;
|
|
|
|
unsigned int tail, head;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int wrapmask;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* This routine is called by doint when a receive data event has taken
|
|
|
|
* place.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
if (ch->statusflags & RXSTOPPED)
|
|
|
|
return;
|
|
|
|
if (tty)
|
|
|
|
ts = tty->termios;
|
|
|
|
bc = ch->brdchan;
|
2005-09-07 06:16:44 +08:00
|
|
|
BUG_ON(!bc);
|
2005-04-17 06:20:36 +08:00
|
|
|
wrapmask = ch->rxbufsize - 1;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Get the head and tail pointers to the receiver queue. Wrap the head
|
|
|
|
* pointer if it has reached the end of the buffer.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
head = readw(&bc->rin);
|
2005-04-17 06:20:36 +08:00
|
|
|
head &= wrapmask;
|
2005-09-07 06:16:44 +08:00
|
|
|
tail = readw(&bc->rout) & wrapmask;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
bytesAvailable = (head - tail) & wrapmask;
|
|
|
|
if (bytesAvailable == 0)
|
|
|
|
return;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/* If CREAD bit is off or device not open, set TX tail to head */
|
2008-04-30 15:54:16 +08:00
|
|
|
if (!tty || !ts || !(ts->c_cflag & CREAD)) {
|
2005-09-16 05:53:28 +08:00
|
|
|
writew(head, &bc->rout);
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[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 12:54:13 +08:00
|
|
|
if (tty_buffer_request_room(tty, bytesAvailable + 1) == 0)
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (readb(&bc->orun)) {
|
|
|
|
writeb(0, &bc->orun);
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_WARNING "epca; overrun! DigiBoard device %s\n",
|
|
|
|
tty->name);
|
[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 12:54:13 +08:00
|
|
|
tty_insert_flip_char(tty, 0, TTY_OVERRUN);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
rxwinon(ch);
|
2008-04-30 15:54:16 +08:00
|
|
|
while (bytesAvailable > 0) {
|
|
|
|
/* Begin while there is data on the card */
|
2005-04-17 06:20:36 +08:00
|
|
|
wrapgap = (head >= tail) ? head - tail : ch->rxbufsize - tail;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Even if head has wrapped around only report the amount of
|
|
|
|
* data to be equal to the size - tail. Remember memcpy can't
|
|
|
|
* automaticly wrap around the receive buffer.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
dataToRead = (wrapgap < bytesAvailable) ? wrapgap
|
|
|
|
: bytesAvailable;
|
2007-10-17 14:26:37 +08:00
|
|
|
/* Make sure we don't overflow the buffer */
|
[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 12:54:13 +08:00
|
|
|
dataToRead = tty_prepare_flip_string(tty, &rptr, dataToRead);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (dataToRead == 0)
|
|
|
|
break;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Move data read from our card into the line disciplines
|
|
|
|
* buffer for translation if necessary.
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
memcpy_fromio(rptr, ch->rxptr + tail, dataToRead);
|
2005-04-17 06:20:36 +08:00
|
|
|
tail = (tail + dataToRead) & wrapmask;
|
|
|
|
bytesAvailable -= dataToRead;
|
|
|
|
} /* End while there is data on the card */
|
|
|
|
globalwinon(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
writew(tail, &bc->rout);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Must be called with global data */
|
2009-01-02 21:48:04 +08:00
|
|
|
tty_schedule_flip(tty);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
static int info_ioctl(struct tty_struct *tty, struct file *file,
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int cmd, unsigned long arg)
|
|
|
|
{
|
2007-10-17 14:26:37 +08:00
|
|
|
switch (cmd) {
|
|
|
|
case DIGI_GETINFO:
|
|
|
|
{
|
|
|
|
struct digi_info di;
|
2005-04-17 06:20:36 +08:00
|
|
|
int brd;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
if (get_user(brd, (unsigned int __user *)arg))
|
2005-09-07 06:16:44 +08:00
|
|
|
return -EFAULT;
|
|
|
|
if (brd < 0 || brd >= num_cards || num_cards == 0)
|
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
memset(&di, 0, sizeof(di));
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
di.board = brd;
|
2005-04-17 06:20:36 +08:00
|
|
|
di.status = boards[brd].status;
|
|
|
|
di.type = boards[brd].type ;
|
|
|
|
di.numports = boards[brd].numports ;
|
2005-09-07 06:16:44 +08:00
|
|
|
/* Legacy fixups - just move along nothing to see */
|
|
|
|
di.port = (unsigned char *)boards[brd].port ;
|
|
|
|
di.membase = (unsigned char *)boards[brd].membase ;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
if (copy_to_user((void __user *)arg, &di, sizeof(di)))
|
2005-04-17 06:20:36 +08:00
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
case DIGI_POLLER:
|
|
|
|
{
|
|
|
|
int brd = arg & 0xff000000 >> 16;
|
|
|
|
unsigned char state = arg & 0xff;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (brd < 0 || brd >= num_cards) {
|
|
|
|
printk(KERN_ERR "epca: DIGI POLLER : brd not valid!\n");
|
2007-10-17 14:26:37 +08:00
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
digi_poller_inhibited = state;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case DIGI_INIT:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This call is made by the apps to complete the
|
2008-02-03 23:11:42 +08:00
|
|
|
* initialization of the board(s). This routine is
|
2007-10-17 14:26:37 +08:00
|
|
|
* responsible for setting the card to its initial
|
|
|
|
* state and setting the drivers control fields to the
|
|
|
|
* sutianle settings for the card in question.
|
|
|
|
*/
|
|
|
|
int crd;
|
|
|
|
for (crd = 0; crd < num_cards; crd++)
|
|
|
|
post_fep_init(crd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return -ENOTTY;
|
|
|
|
}
|
|
|
|
return 0;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int pc_tiocmget(struct tty_struct *tty, struct file *file)
|
|
|
|
{
|
2009-01-02 21:47:26 +08:00
|
|
|
struct channel *ch = tty->driver_data;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned int mstat, mflag = 0;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (ch)
|
|
|
|
bc = ch->brdchan;
|
|
|
|
else
|
2005-09-07 06:16:44 +08:00
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
mstat = readb(&bc->mstat);
|
2005-04-17 06:20:36 +08:00
|
|
|
memoff(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if (mstat & ch->m_dtr)
|
|
|
|
mflag |= TIOCM_DTR;
|
|
|
|
if (mstat & ch->m_rts)
|
|
|
|
mflag |= TIOCM_RTS;
|
|
|
|
if (mstat & ch->m_cts)
|
|
|
|
mflag |= TIOCM_CTS;
|
|
|
|
if (mstat & ch->dsr)
|
|
|
|
mflag |= TIOCM_DSR;
|
|
|
|
if (mstat & ch->m_ri)
|
|
|
|
mflag |= TIOCM_RI;
|
|
|
|
if (mstat & ch->dcd)
|
|
|
|
mflag |= TIOCM_CD;
|
|
|
|
return mflag;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pc_tiocmset(struct tty_struct *tty, struct file *file,
|
|
|
|
unsigned int set, unsigned int clear)
|
|
|
|
{
|
2009-01-02 21:47:26 +08:00
|
|
|
struct channel *ch = tty->driver_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (!ch)
|
|
|
|
return -EINVAL;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2007-10-17 14:26:37 +08:00
|
|
|
* I think this modemfake stuff is broken. It doesn't correctly reflect
|
|
|
|
* the behaviour desired by the TIOCM* ioctls. Therefore this is
|
|
|
|
* probably broken.
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
if (set & TIOCM_RTS) {
|
|
|
|
ch->modemfake |= ch->m_rts;
|
|
|
|
ch->modem |= ch->m_rts;
|
|
|
|
}
|
|
|
|
if (set & TIOCM_DTR) {
|
|
|
|
ch->modemfake |= ch->m_dtr;
|
|
|
|
ch->modem |= ch->m_dtr;
|
|
|
|
}
|
|
|
|
if (clear & TIOCM_RTS) {
|
|
|
|
ch->modemfake |= ch->m_rts;
|
|
|
|
ch->modem &= ~ch->m_rts;
|
|
|
|
}
|
|
|
|
if (clear & TIOCM_DTR) {
|
|
|
|
ch->modemfake |= ch->m_dtr;
|
|
|
|
ch->modem &= ~ch->m_dtr;
|
|
|
|
}
|
|
|
|
globalwinon(ch);
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The below routine generally sets up parity, baud, flow control
|
|
|
|
* issues, etc.... It effect both control flags and input flags.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
epcaparam(tty, ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
memoff(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
static int pc_ioctl(struct tty_struct *tty, struct file *file,
|
|
|
|
unsigned int cmd, unsigned long arg)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
digiflow_t dflow;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int mflag, mstat;
|
|
|
|
unsigned char startc, stopc;
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2009-01-02 21:47:26 +08:00
|
|
|
struct channel *ch = tty->driver_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
void __user *argp = (void __user *)arg;
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
if (ch)
|
|
|
|
bc = ch->brdchan;
|
2007-10-17 14:26:37 +08:00
|
|
|
else
|
2005-09-07 06:16:44 +08:00
|
|
|
return -EINVAL;
|
2007-10-17 14:26:37 +08:00
|
|
|
switch (cmd) {
|
|
|
|
case TIOCMODG:
|
|
|
|
mflag = pc_tiocmget(tty, file);
|
|
|
|
if (put_user(mflag, (unsigned long __user *)argp))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
case TIOCMODS:
|
|
|
|
if (get_user(mstat, (unsigned __user *)argp))
|
|
|
|
return -EFAULT;
|
|
|
|
return pc_tiocmset(tty, file, mstat, ~mstat);
|
|
|
|
case TIOCSDTR:
|
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
|
|
|
ch->omodem |= ch->m_dtr;
|
|
|
|
globalwinon(ch);
|
|
|
|
fepcmd(ch, SETMODEM, ch->m_dtr, 0, 10, 1);
|
|
|
|
memoff(ch);
|
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
case TIOCCDTR:
|
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
|
|
|
ch->omodem &= ~ch->m_dtr;
|
|
|
|
globalwinon(ch);
|
|
|
|
fepcmd(ch, SETMODEM, 0, ch->m_dtr, 10, 1);
|
|
|
|
memoff(ch);
|
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
|
|
|
break;
|
|
|
|
case DIGI_GETA:
|
|
|
|
if (copy_to_user(argp, &ch->digiext, sizeof(digi_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
case DIGI_SETAW:
|
|
|
|
case DIGI_SETAF:
|
2008-04-30 15:53:17 +08:00
|
|
|
lock_kernel();
|
2007-10-17 14:26:37 +08:00
|
|
|
if (cmd == DIGI_SETAW) {
|
2008-04-30 15:54:16 +08:00
|
|
|
/* Setup an event to indicate when the transmit
|
|
|
|
buffer empties */
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2008-04-30 15:54:16 +08:00
|
|
|
setup_empty_event(tty, ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
tty_wait_until_sent(tty, 0);
|
|
|
|
} else {
|
|
|
|
/* ldisc lock already held in ioctl */
|
2009-06-11 19:50:12 +08:00
|
|
|
if (tty->ldisc->ops->flush_buffer)
|
|
|
|
tty->ldisc->ops->flush_buffer(tty);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2008-04-30 15:53:17 +08:00
|
|
|
unlock_kernel();
|
2007-10-17 14:26:37 +08:00
|
|
|
/* Fall Thru */
|
|
|
|
case DIGI_SETA:
|
|
|
|
if (copy_from_user(&ch->digiext, argp, sizeof(digi_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
if (ch->digiext.digi_flags & DIGI_ALTPIN) {
|
|
|
|
ch->dcd = ch->m_dsr;
|
|
|
|
ch->dsr = ch->m_dcd;
|
|
|
|
} else {
|
|
|
|
ch->dcd = ch->m_dcd;
|
|
|
|
ch->dsr = ch->m_dsr;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
|
|
|
globalwinon(ch);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* The below routine generally sets up parity, baud, flow
|
|
|
|
* control issues, etc.... It effect both control flags and
|
|
|
|
* input flags.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
epcaparam(tty, ch);
|
2007-10-17 14:26:37 +08:00
|
|
|
memoff(ch);
|
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIGI_GETFLOW:
|
|
|
|
case DIGI_GETAFLOW:
|
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
|
|
|
globalwinon(ch);
|
|
|
|
if (cmd == DIGI_GETFLOW) {
|
|
|
|
dflow.startc = readb(&bc->startc);
|
|
|
|
dflow.stopc = readb(&bc->stopc);
|
|
|
|
} else {
|
|
|
|
dflow.startc = readb(&bc->startca);
|
|
|
|
dflow.stopc = readb(&bc->stopca);
|
|
|
|
}
|
|
|
|
memoff(ch);
|
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
|
|
|
|
|
|
|
if (copy_to_user(argp, &dflow, sizeof(dflow)))
|
|
|
|
return -EFAULT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DIGI_SETAFLOW:
|
|
|
|
case DIGI_SETFLOW:
|
|
|
|
if (cmd == DIGI_SETFLOW) {
|
|
|
|
startc = ch->startc;
|
|
|
|
stopc = ch->stopc;
|
|
|
|
} else {
|
|
|
|
startc = ch->startca;
|
|
|
|
stopc = ch->stopca;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
if (copy_from_user(&dflow, argp, sizeof(dflow)))
|
|
|
|
return -EFAULT;
|
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
if (dflow.startc != startc || dflow.stopc != stopc) {
|
|
|
|
/* Begin if setflow toggled */
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (cmd == DIGI_SETFLOW) {
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->fepstartc = ch->startc = dflow.startc;
|
|
|
|
ch->fepstopc = ch->stopc = dflow.stopc;
|
2008-04-30 15:54:16 +08:00
|
|
|
fepcmd(ch, SONOFFC, ch->fepstartc,
|
|
|
|
ch->fepstopc, 0, 1);
|
2005-09-07 06:16:44 +08:00
|
|
|
} else {
|
2007-10-17 14:26:37 +08:00
|
|
|
ch->fepstartca = ch->startca = dflow.startc;
|
|
|
|
ch->fepstopca = ch->stopca = dflow.stopc;
|
2008-04-30 15:54:16 +08:00
|
|
|
fepcmd(ch, SAUXONOFFC, ch->fepstartca,
|
|
|
|
ch->fepstopca, 0, 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
if (ch->statusflags & TXSTOPPED)
|
|
|
|
pc_start(tty);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
memoff(ch);
|
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
|
|
|
} /* End if setflow toggled */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -ENOIOCTLCMD;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-12-08 18:38:45 +08:00
|
|
|
static void pc_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
|
|
|
unsigned long flags;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
|
|
|
|
if (ch != NULL) { /* Begin if channel valid */
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
epcaparam(tty, ch);
|
|
|
|
memoff(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if ((old_termios->c_cflag & CRTSCTS) &&
|
|
|
|
((tty->termios->c_cflag & CRTSCTS) == 0))
|
|
|
|
tty->hw_stopped = 0;
|
|
|
|
|
|
|
|
if (!(old_termios->c_cflag & CLOCAL) &&
|
|
|
|
(tty->termios->c_cflag & CLOCAL))
|
2008-07-17 04:55:02 +08:00
|
|
|
wake_up_interruptible(&ch->port.open_wait);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
} /* End if channel valid */
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-11-22 22:57:56 +08:00
|
|
|
static void do_softint(struct work_struct *work)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2006-11-22 22:57:56 +08:00
|
|
|
struct channel *ch = container_of(work, struct channel, tqueue);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Called in response to a modem change event */
|
2007-10-17 14:26:37 +08:00
|
|
|
if (ch && ch->magic == EPCA_MAGIC) {
|
2009-08-19 02:18:35 +08:00
|
|
|
struct tty_struct *tty = tty_port_tty_get(&ch->port);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (tty && tty->driver_data) {
|
2007-10-17 14:26:37 +08:00
|
|
|
if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) {
|
2008-04-30 15:54:16 +08:00
|
|
|
tty_hangup(tty);
|
2008-07-17 04:55:02 +08:00
|
|
|
wake_up_interruptible(&ch->port.open_wait);
|
2009-06-11 19:41:05 +08:00
|
|
|
clear_bit(ASYNCB_NORMAL_ACTIVE,
|
|
|
|
&ch->port.flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
2009-01-02 21:48:04 +08:00
|
|
|
tty_kref_put(tty);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* pc_stop and pc_start provide software flow control to the routine and the
|
|
|
|
* pc_ioctl routine.
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
static void pc_stop(struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
|
|
|
unsigned long flags;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
if (ch != NULL) {
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2008-04-30 15:54:16 +08:00
|
|
|
if ((ch->statusflags & TXSTOPPED) == 0) {
|
|
|
|
/* Begin if transmit stop requested */
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
/* STOP transmitting now !! */
|
|
|
|
fepcmd(ch, PAUSETX, 0, 0, 0, 0);
|
|
|
|
ch->statusflags |= TXSTOPPED;
|
|
|
|
memoff(ch);
|
|
|
|
} /* End if transmit stop requested */
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void pc_start(struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
if (ch != NULL) {
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2008-04-30 15:54:16 +08:00
|
|
|
/* Just in case output was resumed because of a change
|
|
|
|
in Digi-flow */
|
|
|
|
if (ch->statusflags & TXSTOPPED) {
|
|
|
|
/* Begin transmit resume requested */
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc;
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
bc = ch->brdchan;
|
|
|
|
if (ch->statusflags & LOWWAIT)
|
2005-09-07 06:16:44 +08:00
|
|
|
writeb(1, &bc->ilow);
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Okay, you can start transmitting again... */
|
|
|
|
fepcmd(ch, RESUMETX, 0, 0, 0, 0);
|
|
|
|
ch->statusflags &= ~TXSTOPPED;
|
|
|
|
memoff(ch);
|
|
|
|
} /* End transmit resume requested */
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The below routines pc_throttle and pc_unthrottle are used to slow (And
|
|
|
|
* resume) the receipt of data into the kernels receive buffers. The exact
|
|
|
|
* occurrence of this depends on the size of the kernels receive buffer and
|
|
|
|
* what the 'watermarks' are set to for that buffer. See the n_ttys.c file for
|
|
|
|
* more details.
|
|
|
|
*/
|
|
|
|
static void pc_throttle(struct tty_struct *tty)
|
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
|
|
|
unsigned long flags;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
if (ch != NULL) {
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
|
|
|
if ((ch->statusflags & RXSTOPPED) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
fepcmd(ch, PAUSERX, 0, 0, 0, 0);
|
|
|
|
ch->statusflags |= RXSTOPPED;
|
|
|
|
memoff(ch);
|
|
|
|
}
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
static void pc_unthrottle(struct tty_struct *tty)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
struct channel *ch;
|
|
|
|
unsigned long flags;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* verifyChannel returns the channel from the tty struct if it is
|
|
|
|
* valid. This serves as a sanity check.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
ch = verifyChannel(tty);
|
|
|
|
if (ch != NULL) {
|
|
|
|
/* Just in case output was resumed because of a change
|
|
|
|
in Digi-flow */
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
|
|
|
if (ch->statusflags & RXSTOPPED) {
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
|
|
|
fepcmd(ch, RESUMERX, 0, 0, 0, 0);
|
|
|
|
ch->statusflags &= ~RXSTOPPED;
|
|
|
|
memoff(ch);
|
|
|
|
}
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:18:12 +08:00
|
|
|
static int pc_send_break(struct tty_struct *tty, int msec)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2009-01-02 21:47:26 +08:00
|
|
|
struct channel *ch = tty->driver_data;
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long flags;
|
|
|
|
|
2008-07-22 18:18:12 +08:00
|
|
|
if (msec == -1)
|
2008-10-18 03:28:25 +08:00
|
|
|
msec = 0xFFFF;
|
|
|
|
else if (msec > 0xFFFE)
|
|
|
|
msec = 0xFFFE;
|
|
|
|
else if (msec < 1)
|
|
|
|
msec = 1;
|
2008-07-22 18:18:12 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_lock_irqsave(&epca_lock, flags);
|
2005-04-17 06:20:36 +08:00
|
|
|
globalwinon(ch);
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* Maybe I should send an infinite break here, schedule() for msec
|
|
|
|
* amount of time, and then stop the break. This way, the user can't
|
|
|
|
* screw up the FEP by causing digi_send_break() to be called (i.e. via
|
|
|
|
* an ioctl()) more than once in msec amount of time.
|
|
|
|
* Try this for now...
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
fepcmd(ch, SENDBREAK, msec, 0, 10, 0);
|
|
|
|
memoff(ch);
|
2005-09-07 06:16:44 +08:00
|
|
|
spin_unlock_irqrestore(&epca_lock, flags);
|
2008-07-22 18:18:12 +08:00
|
|
|
return 0;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
/* Caller MUST hold the lock */
|
2005-04-17 06:20:36 +08:00
|
|
|
static void setup_empty_event(struct tty_struct *tty, struct channel *ch)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-09-16 05:53:28 +08:00
|
|
|
struct board_chan __iomem *bc = ch->brdchan;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
globalwinon(ch);
|
|
|
|
ch->statusflags |= EMPTYWAIT;
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* When set the iempty flag request a event to be generated when the
|
|
|
|
* transmit buffer is empty (If there is no BREAK in progress).
|
|
|
|
*/
|
2005-09-07 06:16:44 +08:00
|
|
|
writeb(1, &bc->iempty);
|
2005-04-17 06:20:36 +08:00
|
|
|
memoff(ch);
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:20:45 +08:00
|
|
|
#ifndef MODULE
|
|
|
|
static void __init epca_setup(char *str, int *ints)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2005-04-17 06:20:36 +08:00
|
|
|
struct board_info board;
|
|
|
|
int index, loop, last;
|
|
|
|
char *temp, *t2;
|
|
|
|
unsigned len;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* If this routine looks a little strange it is because it is only
|
|
|
|
* called if a LILO append command is given to boot the kernel with
|
|
|
|
* parameters. In this way, we can provide the user a method of
|
|
|
|
* changing his board configuration without rebuilding the kernel.
|
|
|
|
*/
|
|
|
|
if (!liloconfig)
|
|
|
|
liloconfig = 1;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
memset(&board, 0, sizeof(board));
|
|
|
|
|
|
|
|
/* Assume the data is int first, later we can change it */
|
|
|
|
/* I think that array position 0 of ints holds the number of args */
|
|
|
|
for (last = 0, index = 1; index <= ints[0]; index++)
|
2007-10-17 14:26:37 +08:00
|
|
|
switch (index) { /* Begin parse switch */
|
|
|
|
case 1:
|
|
|
|
board.status = ints[index];
|
|
|
|
/*
|
|
|
|
* We check for 2 (As opposed to 1; because 2 is a flag
|
|
|
|
* instructing the driver to ignore epcaconfig.) For
|
|
|
|
* this reason we check for 2.
|
|
|
|
*/
|
2008-04-30 15:54:16 +08:00
|
|
|
if (board.status == 2) {
|
|
|
|
/* Begin ignore epcaconfig as well as lilo cmd line */
|
2007-10-17 14:26:37 +08:00
|
|
|
nbdevs = 0;
|
|
|
|
num_cards = 0;
|
|
|
|
return;
|
|
|
|
} /* End ignore epcaconfig as well as lilo cmd line */
|
|
|
|
|
|
|
|
if (board.status > 2) {
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_ERR "epca_setup: Invalid board status 0x%x\n",
|
|
|
|
board.status);
|
2007-10-17 14:26:37 +08:00
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_BOARD_STATUS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last = index;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
board.type = ints[index];
|
|
|
|
if (board.type >= PCIXEM) {
|
|
|
|
printk(KERN_ERR "epca_setup: Invalid board type 0x%x\n", board.type);
|
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_BOARD_TYPE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last = index;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
board.altpin = ints[index];
|
|
|
|
if (board.altpin > 1) {
|
|
|
|
printk(KERN_ERR "epca_setup: Invalid board altpin 0x%x\n", board.altpin);
|
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_ALTPIN;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last = index;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
board.numports = ints[index];
|
|
|
|
if (board.numports < 2 || board.numports > 256) {
|
|
|
|
printk(KERN_ERR "epca_setup: Invalid board numports 0x%x\n", board.numports);
|
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_NUM_PORTS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nbdevs += board.numports;
|
|
|
|
last = index;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
case 5:
|
|
|
|
board.port = ints[index];
|
|
|
|
if (ints[index] <= 0) {
|
|
|
|
printk(KERN_ERR "epca_setup: Invalid io port 0x%x\n", (unsigned int)board.port);
|
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_PORT_BASE;
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
last = index;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
board.membase = ints[index];
|
|
|
|
if (ints[index] <= 0) {
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_ERR "epca_setup: Invalid memory base 0x%x\n",
|
|
|
|
(unsigned int)board.membase);
|
2007-10-17 14:26:37 +08:00
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_MEM_BASE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last = index;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printk(KERN_ERR "<Error> - epca_setup: Too many integer parms\n");
|
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
} /* End parse switch */
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
while (str && *str) { /* Begin while there is a string arg */
|
2005-04-17 06:20:36 +08:00
|
|
|
/* find the next comma or terminator */
|
|
|
|
temp = str;
|
|
|
|
/* While string is not null, and a comma hasn't been found */
|
|
|
|
while (*temp && (*temp != ','))
|
|
|
|
temp++;
|
|
|
|
if (!*temp)
|
|
|
|
temp = NULL;
|
|
|
|
else
|
|
|
|
*temp++ = 0;
|
|
|
|
/* Set index to the number of args + 1 */
|
|
|
|
index = last + 1;
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
switch (index) {
|
|
|
|
case 1:
|
|
|
|
len = strlen(str);
|
|
|
|
if (strncmp("Disable", str, len) == 0)
|
|
|
|
board.status = 0;
|
|
|
|
else if (strncmp("Enable", str, len) == 0)
|
|
|
|
board.status = 1;
|
|
|
|
else {
|
|
|
|
printk(KERN_ERR "epca_setup: Invalid status %s\n", str);
|
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_BOARD_STATUS;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last = index;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
case 2:
|
|
|
|
for (loop = 0; loop < EPCA_NUM_TYPES; loop++)
|
|
|
|
if (strcmp(board_desc[loop], str) == 0)
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* If the index incremented above refers to a
|
|
|
|
* legitamate board type set it here.
|
|
|
|
*/
|
|
|
|
if (index < EPCA_NUM_TYPES)
|
|
|
|
board.type = loop;
|
|
|
|
else {
|
|
|
|
printk(KERN_ERR "epca_setup: Invalid board type: %s\n", str);
|
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_BOARD_TYPE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last = index;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
len = strlen(str);
|
|
|
|
if (strncmp("Disable", str, len) == 0)
|
|
|
|
board.altpin = 0;
|
|
|
|
else if (strncmp("Enable", str, len) == 0)
|
|
|
|
board.altpin = 1;
|
|
|
|
else {
|
|
|
|
printk(KERN_ERR "epca_setup: Invalid altpin %s\n", str);
|
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_ALTPIN;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
last = index;
|
|
|
|
break;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
case 4:
|
|
|
|
t2 = str;
|
|
|
|
while (isdigit(*t2))
|
|
|
|
t2++;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
if (*t2) {
|
|
|
|
printk(KERN_ERR "epca_setup: Invalid port count %s\n", str);
|
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_NUM_PORTS;
|
|
|
|
return;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* There is not a man page for simple_strtoul but the
|
|
|
|
* code can be found in vsprintf.c. The first argument
|
|
|
|
* is the string to translate (To an unsigned long
|
|
|
|
* obviously), the second argument can be the address
|
|
|
|
* of any character variable or a NULL. If a variable
|
|
|
|
* is given, the end pointer of the string will be
|
|
|
|
* stored in that variable; if a NULL is given the end
|
|
|
|
* pointer will not be returned. The last argument is
|
|
|
|
* the base to use. If a 0 is indicated, the routine
|
|
|
|
* will attempt to determine the proper base by looking
|
|
|
|
* at the values prefix (A '0' for octal, a 'x' for
|
|
|
|
* hex, etc ... If a value is given it will use that
|
|
|
|
* value as the base.
|
|
|
|
*/
|
|
|
|
board.numports = simple_strtoul(str, NULL, 0);
|
|
|
|
nbdevs += board.numports;
|
|
|
|
last = index;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
t2 = str;
|
|
|
|
while (isxdigit(*t2))
|
|
|
|
t2++;
|
|
|
|
|
|
|
|
if (*t2) {
|
|
|
|
printk(KERN_ERR "epca_setup: Invalid i/o address %s\n", str);
|
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_PORT_BASE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
board.port = simple_strtoul(str, NULL, 16);
|
|
|
|
last = index;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
t2 = str;
|
|
|
|
while (isxdigit(*t2))
|
|
|
|
t2++;
|
|
|
|
|
|
|
|
if (*t2) {
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_ERR "epca_setup: Invalid memory base %s\n", str);
|
2007-10-17 14:26:37 +08:00
|
|
|
invalid_lilo_config = 1;
|
|
|
|
setup_error_code |= INVALID_MEM_BASE;
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
|
|
|
board.membase = simple_strtoul(str, NULL, 16);
|
|
|
|
last = index;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk(KERN_ERR "epca: Too many string parms\n");
|
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
str = temp;
|
|
|
|
} /* End while there is a string arg */
|
|
|
|
|
2005-09-07 06:16:44 +08:00
|
|
|
if (last < 6) {
|
|
|
|
printk(KERN_ERR "epca: Insufficient parms specified\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
return;
|
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* I should REALLY validate the stuff here */
|
|
|
|
/* Copies our local copy of board into boards */
|
2008-04-30 15:54:16 +08:00
|
|
|
memcpy((void *)&boards[num_cards], (void *)&board, sizeof(board));
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Does this get called once per lilo arg are what ? */
|
2007-10-17 14:26:37 +08:00
|
|
|
printk(KERN_INFO "PC/Xx: Added board %i, %s %i ports at 0x%4.4X base 0x%6.6X\n",
|
|
|
|
num_cards, board_desc[board.type],
|
2005-04-17 06:20:36 +08:00
|
|
|
board.numports, (int)board.port, (unsigned int) board.membase);
|
|
|
|
num_cards++;
|
2007-10-17 14:26:37 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-22 18:20:45 +08:00
|
|
|
static int __init epca_real_setup(char *str)
|
|
|
|
{
|
|
|
|
int ints[11];
|
|
|
|
|
|
|
|
epca_setup(get_options(str, 11, ints), ints);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
__setup("digiepca", epca_real_setup);
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
enum epic_board_types {
|
|
|
|
brd_xr = 0,
|
|
|
|
brd_xem,
|
|
|
|
brd_cx,
|
|
|
|
brd_xrj,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* indexed directly by epic_board_types enum */
|
|
|
|
static struct {
|
|
|
|
unsigned char board_type;
|
|
|
|
unsigned bar_idx; /* PCI base address region */
|
|
|
|
} epca_info_tbl[] = {
|
|
|
|
{ PCIXR, 0, },
|
|
|
|
{ PCIXEM, 0, },
|
|
|
|
{ PCICX, 0, },
|
|
|
|
{ PCIXRJ, 2, },
|
|
|
|
};
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
static int __devinit epca_init_one(struct pci_dev *pdev,
|
2005-04-17 06:20:36 +08:00
|
|
|
const struct pci_device_id *ent)
|
|
|
|
{
|
|
|
|
static int board_num = -1;
|
|
|
|
int board_idx, info_idx = ent->driver_data;
|
|
|
|
unsigned long addr;
|
|
|
|
|
|
|
|
if (pci_enable_device(pdev))
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
board_num++;
|
|
|
|
board_idx = board_num + num_cards;
|
|
|
|
if (board_idx >= MAXBOARDS)
|
|
|
|
goto err_out;
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
addr = pci_resource_start(pdev, epca_info_tbl[info_idx].bar_idx);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!addr) {
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_ERR PFX "PCI region #%d not available (size 0)\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
epca_info_tbl[info_idx].bar_idx);
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
boards[board_idx].status = ENABLED;
|
|
|
|
boards[board_idx].type = epca_info_tbl[info_idx].board_type;
|
|
|
|
boards[board_idx].numports = 0x0;
|
2005-09-07 06:16:44 +08:00
|
|
|
boards[board_idx].port = addr + PCI_IO_OFFSET;
|
|
|
|
boards[board_idx].membase = addr;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
if (!request_mem_region(addr + PCI_IO_OFFSET, 0x200000, "epca")) {
|
|
|
|
printk(KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
0x200000, addr + PCI_IO_OFFSET);
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
boards[board_idx].re_map_port = ioremap_nocache(addr + PCI_IO_OFFSET,
|
|
|
|
0x200000);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!boards[board_idx].re_map_port) {
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
0x200000, addr + PCI_IO_OFFSET);
|
|
|
|
goto err_out_free_pciio;
|
|
|
|
}
|
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
if (!request_mem_region(addr, 0x200000, "epca")) {
|
|
|
|
printk(KERN_ERR PFX "resource 0x%x @ 0x%lx unavailable\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
0x200000, addr);
|
|
|
|
goto err_out_free_iounmap;
|
|
|
|
}
|
|
|
|
|
2008-04-30 15:54:16 +08:00
|
|
|
boards[board_idx].re_map_membase = ioremap_nocache(addr, 0x200000);
|
2005-04-17 06:20:36 +08:00
|
|
|
if (!boards[board_idx].re_map_membase) {
|
2008-04-30 15:54:16 +08:00
|
|
|
printk(KERN_ERR PFX "cannot map 0x%x @ 0x%lx\n",
|
2005-04-17 06:20:36 +08:00
|
|
|
0x200000, addr + PCI_IO_OFFSET);
|
|
|
|
goto err_out_free_memregion;
|
|
|
|
}
|
|
|
|
|
2007-10-17 14:26:37 +08:00
|
|
|
/*
|
|
|
|
* I don't know what the below does, but the hardware guys say its
|
|
|
|
* required on everything except PLX (In this case XRJ).
|
|
|
|
*/
|
2005-04-17 06:20:36 +08:00
|
|
|
if (info_idx != brd_xrj) {
|
2007-10-17 14:26:37 +08:00
|
|
|
pci_write_config_byte(pdev, 0x40, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
pci_write_config_byte(pdev, 0x46, 0);
|
|
|
|
}
|
2007-10-17 14:26:37 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
err_out_free_memregion:
|
2008-04-30 15:54:16 +08:00
|
|
|
release_mem_region(addr, 0x200000);
|
2005-04-17 06:20:36 +08:00
|
|
|
err_out_free_iounmap:
|
2008-04-30 15:54:16 +08:00
|
|
|
iounmap(boards[board_idx].re_map_port);
|
2005-04-17 06:20:36 +08:00
|
|
|
err_out_free_pciio:
|
2008-04-30 15:54:16 +08:00
|
|
|
release_mem_region(addr + PCI_IO_OFFSET, 0x200000);
|
2005-04-17 06:20:36 +08:00
|
|
|
err_out:
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct pci_device_id epca_pci_tbl[] = {
|
|
|
|
{ PCI_VENDOR_DIGI, PCI_DEVICE_XR, PCI_ANY_ID, PCI_ANY_ID, 0, 0, brd_xr },
|
|
|
|
{ PCI_VENDOR_DIGI, PCI_DEVICE_XEM, PCI_ANY_ID, PCI_ANY_ID, 0, 0, brd_xem },
|
|
|
|
{ PCI_VENDOR_DIGI, PCI_DEVICE_CX, PCI_ANY_ID, PCI_ANY_ID, 0, 0, brd_cx },
|
|
|
|
{ PCI_VENDOR_DIGI, PCI_DEVICE_XRJ, PCI_ANY_ID, PCI_ANY_ID, 0, 0, brd_xrj },
|
|
|
|
{ 0, }
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, epca_pci_tbl);
|
|
|
|
|
2008-04-30 15:53:52 +08:00
|
|
|
static int __init init_PCI(void)
|
2007-10-17 14:26:37 +08:00
|
|
|
{
|
2008-04-30 15:54:16 +08:00
|
|
|
memset(&epca_driver, 0, sizeof(epca_driver));
|
2005-04-17 06:20:36 +08:00
|
|
|
epca_driver.name = "epca";
|
|
|
|
epca_driver.id_table = epca_pci_tbl;
|
|
|
|
epca_driver.probe = epca_init_one;
|
|
|
|
|
|
|
|
return pci_register_driver(&epca_driver);
|
2005-09-07 06:16:44 +08:00
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
MODULE_LICENSE("GPL");
|