staging: dgnc: add dgnc digi driver

This patch adds the DGNC driver. This is a TTY Serial Port
Driver for the Digi International Neo and Classic PCI based product
line by Digi International <http://www.digi.com>.

This driver isn't hooked up to the build system because it doesn't
build, it merely adds the driver written by Digi to the kernel tree so
that it can be cleaned up and fixed up properly over time.

Cc: Mark Hounschell <markh@compro.net>
Signed-off-by: Lidza Louina <lidza.louina@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Lidza Louina 2013-08-01 17:00:20 -04:00 коммит произвёл Greg Kroah-Hartman
Родитель b9cc16c03d
Коммит 0b99d58902
24 изменённых файлов: 12894 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,6 @@
config DGNC
tristate "Digi Neo and Classic PCI Products"
default n
depends on TTY
---help---
Driver for the Digi International Neo and Classic PCI based product line.

Просмотреть файл

@ -0,0 +1,7 @@
EXTRA_CFLAGS += -DDG_NAME=\"dgnc-1.3-16\" -DDG_PART=\"40002369_F\"
obj-$(CONFIG_DGNC) += dgnc.o
dgnc-objs := dgnc_cls.o dgnc_driver.o\
dgnc_mgmt.o dgnc_neo.o\
dgnc_proc.o dgnc_trace.o dgnc_tty.o dgnc_sysfs.o

Просмотреть файл

@ -0,0 +1,133 @@
#
# From Makefile.inc
#
#
# Common definitions go here.
#
#
# TRUE_VERSION is the version string used in the driver build,
# it is intended to be in the form:
#
# 2.0-0
#
# A string noting a particular special modification could be
# used as well. This string will be reported when the driver
# is loaded, and will be exposed by its /proc/dgnc/info
# interface.
#
TRUE_VERSION="1.3-16"
#
# DGNC_PART_NUM is the part number string for the driver package.
# It should be in the form:
#
# 40002369_A
#
DGNC_PART_NUM=40002369_F
#
# DGNC_REL_NOTE is the part number string for the driver release
# notes. It should be in the form:
#
# 93000517_A
#
DGNC_REL_NOTE=93000517_F
#
# DGNC_PKG_VER is the "version" number string included in the
# various documentation and packaging files. It should be
# in the form:
#
# 1.0
#
DGNC_PKG_VER=1.3
#
# DGNC_PKG_REV is the "revision" of this version. Together,
# a linux module revision is built with:
#
# ${DGNC_PKG_VER}-${DGNC_PKG_REV}
#
DGNC_PKG_REV=16
#
# DRP_PKG_DATE is the "date" string included in (for now) the
# release notes. It should be in the form:
#
# 11/04/2003
#
DGNC_PKG_DATE=10/17/2008
INIT_DIR= $(shell \
if [ -d /etc/rc.d/init.d ]; \
then echo "$(RPM_BUILD_ROOT)/etc/rc.d/init.d"; \
else echo "$(RPM_BUILD_ROOT)/etc/init.d"; fi)
#
# Miscelaneous path macro's
#
PACKAGE= dgnc
DEVDIR= /dev/dg/$(PACKAGE)
SRCDIR= /usr/src/dg/$(PACKAGE)
BINDIR= /usr/bin
DRVLIBDIR= /etc/$(PACKAGE)
MANDIR= /usr/man
USRLIBDIR= /usr/lib
DGNCDIR= /etc/dgnc
INIT_DIR= $(shell \
if [ -d /etc/rc.d/init.d ]; \
then echo "/etc/rc.d/init.d"; \
else echo "/etc/init.d"; fi)
#
# From Makefile
#
ifndef MYPWD
MYPWD = $(shell pwd)
endif
ifeq ($(KERNDIR),)
KERNVERS := $(shell uname -r)
KERNDIR :=/lib/modules/${KERNVERS}/
endif
# Grab version and other important stuff
RPMNAME := $(PACKAGE)-$(TRUE_VERSION)
PARTNUM := $(DGNC_PART_NUM)
RELNOTES := $(DGNC_REL_NOTE)
MODDIR = $(shell echo $(BUILDROOT)/lib/modules/3.4.36-lcrs/misc)
LSMOD = /sbin/lsmod
RMMOD = /sbin/rmmod
INSMOD = /sbin/insmod
NEW_TTY_LOCKING = No
NEW_TTY_BUFFERING = No
REGISTER_TTYS_WITH_SYSFS = No
# Send in some extra things...
EXTRA_CFLAGS += -I${MYPWD} -I${MYPWD}/include -I${MYPWD}/../../commoninc\
-I${MYPWD}/../../dpa -DLINUX -DDG_NAME=\"$(RPMNAME)\"\
-DDG_PART=\"$(PARTNUM)\" -DDGNC_TRACER
ifeq ($(NEW_TTY_LOCKING),Yes)
EXTRA_CFLAGS += -DNEW_TTY_LOCKING
endif
ifeq ($(NEW_TTY_BUFFERING),Yes)
EXTRA_CFLAGS += -DNEW_TTY_BUFFERING
endif
ifeq ($(REGISTER_TTYS_WITH_SYSFS),Yes)
EXTRA_CFLAGS += -DREGISTER_TTYS_WITH_SYSFS
endif
# Conform to correct kbuild conventions...

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,90 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*
*/
#ifndef __DGNC_CLS_H
#define __DGNC_CLS_H
#include "dgnc_types.h"
/************************************************************************
* Per channel/port Classic UART structure *
************************************************************************
* Base Structure Entries Usage Meanings to Host *
* *
* W = read write R = read only *
* U = Unused. *
************************************************************************/
struct cls_uart_struct {
volatile uchar txrx; /* WR RHR/THR - Holding Reg */
volatile uchar ier; /* WR IER - Interrupt Enable Reg */
volatile uchar isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg */
volatile uchar lcr; /* WR LCR - Line Control Reg */
volatile uchar mcr; /* WR MCR - Modem Control Reg */
volatile uchar lsr; /* WR LSR - Line Status Reg */
volatile uchar msr; /* WR MSR - Modem Status Reg */
volatile uchar spr; /* WR SPR - Scratch Pad Reg */
};
/* Where to read the interrupt register (8bits) */
#define UART_CLASSIC_POLL_ADDR_OFFSET 0x40
#define UART_EXAR654_ENHANCED_REGISTER_SET 0xBF
#define UART_16654_FCR_TXTRIGGER_8 0x0
#define UART_16654_FCR_TXTRIGGER_16 0x10
#define UART_16654_FCR_TXTRIGGER_32 0x20
#define UART_16654_FCR_TXTRIGGER_56 0x30
#define UART_16654_FCR_RXTRIGGER_8 0x0
#define UART_16654_FCR_RXTRIGGER_16 0x40
#define UART_16654_FCR_RXTRIGGER_56 0x80
#define UART_16654_FCR_RXTRIGGER_60 0xC0
#define UART_IIR_XOFF 0x10 /* Received Xoff signal/Special character */
#define UART_IIR_CTSRTS 0x20 /* Received CTS/RTS change of state */
#define UART_IIR_RDI_TIMEOUT 0x0C /* Receiver data TIMEOUT */
/*
* These are the EXTENDED definitions for the Exar 654's Interrupt
* Enable Register.
*/
#define UART_EXAR654_EFR_ECB 0x10 /* Enhanced control bit */
#define UART_EXAR654_EFR_IXON 0x2 /* Receiver compares Xon1/Xoff1 */
#define UART_EXAR654_EFR_IXOFF 0x8 /* Transmit Xon1/Xoff1 */
#define UART_EXAR654_EFR_RTSDTR 0x40 /* Auto RTS/DTR Flow Control Enable */
#define UART_EXAR654_EFR_CTSDSR 0x80 /* Auto CTS/DSR Flow COntrol Enable */
#define UART_EXAR654_XOFF_DETECT 0x1 /* Indicates whether chip saw an incoming XOFF char */
#define UART_EXAR654_XON_DETECT 0x2 /* Indicates whether chip saw an incoming XON char */
#define UART_EXAR654_IER_XOFF 0x20 /* Xoff Interrupt Enable */
#define UART_EXAR654_IER_RTSDTR 0x40 /* Output Interrupt Enable */
#define UART_EXAR654_IER_CTSDSR 0x80 /* Input Interrupt Enable */
/*
* Our Global Variables
*/
extern struct board_ops dgnc_cls_ops;
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,566 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*
*************************************************************************
*
* Driver includes
*
*************************************************************************/
#ifndef __DGNC_DRIVER_H
#define __DGNC_DRIVER_H
#include <linux/version.h> /* To get the current Linux version */
#include <linux/types.h> /* To pick up the varions Linux types */
#include <linux/tty.h> /* To pick up the various tty structs/defines */
#include <linux/interrupt.h> /* For irqreturn_t type */
#include "dgnc_types.h" /* Additional types needed by the Digi header files */
#include "digi.h" /* Digi specific ioctl header */
#include "dgnc_kcompat.h" /* Kernel 2.4/2.6 compat includes */
#include "dgnc_sysfs.h" /* Support for SYSFS */
/*************************************************************************
*
* Driver defines
*
*************************************************************************/
/*
* Driver identification, error and debugging statments
*
* In theory, you can change all occurances of "digi" in the next
* three lines, and the driver printk's will all automagically change.
*
* APR((fmt, args, ...)); Always prints message
* DPR((fmt, args, ...)); Only prints if DGNC_TRACER is defined at
* compile time and dgnc_debug!=0
*/
#define PROCSTR "dgnc" /* /proc entries */
#define DEVSTR "/dev/dg/dgnc" /* /dev entries */
#define DRVSTR "dgnc" /* Driver name string
* displayed by APR */
#define APR(args) do { PRINTF_TO_KMEM(args); printk(DRVSTR": "); printk args; \
} while (0)
#define RAPR(args) do { PRINTF_TO_KMEM(args); printk args; } while (0)
#define TRC_TO_CONSOLE 1
/*
* Debugging levels can be set using debug insmod variable
* They can also be compiled out completely.
*/
#define DBG_INIT (dgnc_debug & 0x01)
#define DBG_BASIC (dgnc_debug & 0x02)
#define DBG_CORE (dgnc_debug & 0x04)
#define DBG_OPEN (dgnc_debug & 0x08)
#define DBG_CLOSE (dgnc_debug & 0x10)
#define DBG_READ (dgnc_debug & 0x20)
#define DBG_WRITE (dgnc_debug & 0x40)
#define DBG_IOCTL (dgnc_debug & 0x80)
#define DBG_PROC (dgnc_debug & 0x100)
#define DBG_PARAM (dgnc_debug & 0x200)
#define DBG_PSCAN (dgnc_debug & 0x400)
#define DBG_EVENT (dgnc_debug & 0x800)
#define DBG_DRAIN (dgnc_debug & 0x1000)
#define DBG_MSIGS (dgnc_debug & 0x2000)
#define DBG_MGMT (dgnc_debug & 0x4000)
#define DBG_INTR (dgnc_debug & 0x8000)
#define DBG_CARR (dgnc_debug & 0x10000)
#if defined(DGNC_TRACER)
# if defined(TRC_TO_KMEM)
/* Choose one: */
# define TRC_ON_OVERFLOW_WRAP_AROUND
# undef TRC_ON_OVERFLOW_SHIFT_BUFFER
# endif //TRC_TO_KMEM
# define TRC_MAXMSG 1024
# define TRC_OVERFLOW "(OVERFLOW)"
# define TRC_DTRC "/usr/bin/dtrc"
#if defined TRC_TO_CONSOLE
#define PRINTF_TO_CONSOLE(args) { printk(DRVSTR": "); printk args; }
#else //!defined TRACE_TO_CONSOLE
#define PRINTF_TO_CONSOLE(args)
#endif
#if defined TRC_TO_KMEM
#define PRINTF_TO_KMEM(args) dgnc_tracef args
#else //!defined TRC_TO_KMEM
#define PRINTF_TO_KMEM(args)
#endif
#define TRC(args) { PRINTF_TO_KMEM(args); PRINTF_TO_CONSOLE(args) }
# define DPR_INIT(ARGS) if (DBG_INIT) TRC(ARGS)
# define DPR_BASIC(ARGS) if (DBG_BASIC) TRC(ARGS)
# define DPR_CORE(ARGS) if (DBG_CORE) TRC(ARGS)
# define DPR_OPEN(ARGS) if (DBG_OPEN) TRC(ARGS)
# define DPR_CLOSE(ARGS) if (DBG_CLOSE) TRC(ARGS)
# define DPR_READ(ARGS) if (DBG_READ) TRC(ARGS)
# define DPR_WRITE(ARGS) if (DBG_WRITE) TRC(ARGS)
# define DPR_IOCTL(ARGS) if (DBG_IOCTL) TRC(ARGS)
# define DPR_PROC(ARGS) if (DBG_PROC) TRC(ARGS)
# define DPR_PARAM(ARGS) if (DBG_PARAM) TRC(ARGS)
# define DPR_PSCAN(ARGS) if (DBG_PSCAN) TRC(ARGS)
# define DPR_EVENT(ARGS) if (DBG_EVENT) TRC(ARGS)
# define DPR_DRAIN(ARGS) if (DBG_DRAIN) TRC(ARGS)
# define DPR_CARR(ARGS) if (DBG_CARR) TRC(ARGS)
# define DPR_MGMT(ARGS) if (DBG_MGMT) TRC(ARGS)
# define DPR_INTR(ARGS) if (DBG_INTR) TRC(ARGS)
# define DPR_MSIGS(ARGS) if (DBG_MSIGS) TRC(ARGS)
# define DPR(ARGS) if (dgnc_debug) TRC(ARGS)
# define P(X) dgnc_tracef(#X "=%p\n", X)
# define X(X) dgnc_tracef(#X "=%x\n", X)
#else//!defined DGNC_TRACER
#define PRINTF_TO_KMEM(args)
# define TRC(ARGS)
# define DPR_INIT(ARGS)
# define DPR_BASIC(ARGS)
# define DPR_CORE(ARGS)
# define DPR_OPEN(ARGS)
# define DPR_CLOSE(ARGS)
# define DPR_READ(ARGS)
# define DPR_WRITE(ARGS)
# define DPR_IOCTL(ARGS)
# define DPR_PROC(ARGS)
# define DPR_PARAM(ARGS)
# define DPR_PSCAN(ARGS)
# define DPR_EVENT(ARGS)
# define DPR_DRAIN(ARGS)
# define DPR_CARR(ARGS)
# define DPR_MGMT(ARGS)
# define DPR_INTR(ARGS)
# define DPR_MSIGS(ARGS)
# define DPR(args)
#endif//DGNC_TRACER
/* Number of boards we support at once. */
#define MAXBOARDS 20
#define MAXPORTS 8
#define MAXTTYNAMELEN 200
/* Our 3 magic numbers for our board, channel and unit structs */
#define DGNC_BOARD_MAGIC 0x5c6df104
#define DGNC_CHANNEL_MAGIC 0x6c6df104
#define DGNC_UNIT_MAGIC 0x7c6df104
/* Serial port types */
#define DGNC_SERIAL 0
#define DGNC_PRINT 1
#define SERIAL_TYPE_NORMAL 1
#define PORT_NUM(dev) ((dev) & 0x7f)
#define IS_PRINT(dev) (((dev) & 0xff) >= 0x80)
/* MAX number of stop characters we will send when our read queue is getting full */
#define MAX_STOPS_SENT 5
/* 4 extra for alignment play space */
#define WRITEBUFLEN ((4096) + 4)
#define MYFLIPLEN N_TTY_BUF_SIZE
#define dgnc_jiffies_from_ms(a) (((a) * HZ) / 1000)
/*
* Define a local default termios struct. All ports will be created
* with this termios initially. This is the same structure that is defined
* as the default in tty_io.c with the same settings overriden as in serial.c
*
* In short, this should match the internal serial ports' defaults.
*/
#define DEFAULT_IFLAGS (ICRNL | IXON)
#define DEFAULT_OFLAGS (OPOST | ONLCR)
#define DEFAULT_CFLAGS (B9600 | CS8 | CREAD | HUPCL | CLOCAL)
#define DEFAULT_LFLAGS (ISIG | ICANON | ECHO | ECHOE | ECHOK | \
ECHOCTL | ECHOKE | IEXTEN)
#ifndef _POSIX_VDISABLE
#define _POSIX_VDISABLE '\0'
#endif
#define SNIFF_MAX 65536 /* Sniff buffer size (2^n) */
#define SNIFF_MASK (SNIFF_MAX - 1) /* Sniff wrap mask */
/*
* Lock function/defines.
* Makes spotting lock/unlock locations easier.
*/
# define DGNC_SPINLOCK_INIT(x) spin_lock_init(&(x))
# define DGNC_LOCK(x,y) spin_lock_irqsave(&(x), y)
# define DGNC_UNLOCK(x,y) spin_unlock_irqrestore(&(x), y)
/*
* All the possible states the driver can be while being loaded.
*/
enum {
DRIVER_INITIALIZED = 0,
DRIVER_READY
};
/*
* All the possible states the board can be while booting up.
*/
enum {
BOARD_FAILED = 0,
BOARD_FOUND,
BOARD_READY
};
/*************************************************************************
*
* Structures and closely related defines.
*
*************************************************************************/
struct board_t;
struct channel_t;
/************************************************************************
* Per board operations structure *
************************************************************************/
struct board_ops {
void (*tasklet) (unsigned long data);
irqreturn_t (*intr) (int irq, void *voidbrd);
void (*uart_init) (struct channel_t *ch);
void (*uart_off) (struct channel_t *ch);
int (*drain) (struct tty_struct *tty, uint seconds);
void (*param) (struct tty_struct *tty);
void (*vpd) (struct board_t *brd);
void (*assert_modem_signals) (struct channel_t *ch);
void (*flush_uart_write) (struct channel_t *ch);
void (*flush_uart_read) (struct channel_t *ch);
void (*disable_receiver) (struct channel_t *ch);
void (*enable_receiver) (struct channel_t *ch);
void (*send_break) (struct channel_t *ch, int);
void (*send_start_character) (struct channel_t *ch);
void (*send_stop_character) (struct channel_t *ch);
void (*copy_data_from_queue_to_uart) (struct channel_t *ch);
uint (*get_uart_bytes_left) (struct channel_t *ch);
void (*send_immediate_char) (struct channel_t *ch, unsigned char);
};
/************************************************************************
* Device flag definitions for bd_flags.
************************************************************************/
#define BD_IS_PCI_EXPRESS 0x0001 /* Is a PCI Express board */
/*
* Per-board information
*/
struct board_t
{
int magic; /* Board Magic number. */
int boardnum; /* Board number: 0-32 */
int type; /* Type of board */
char *name; /* Product Name */
struct pci_dev *pdev; /* Pointer to the pci_dev struct */
unsigned long bd_flags; /* Board flags */
u16 vendor; /* PCI vendor ID */
u16 device; /* PCI device ID */
u16 subvendor; /* PCI subsystem vendor ID */
u16 subdevice; /* PCI subsystem device ID */
uchar rev; /* PCI revision ID */
uint pci_bus; /* PCI bus value */
uint pci_slot; /* PCI slot value */
uint maxports; /* MAX ports this board can handle */
uchar dvid; /* Board specific device id */
uchar vpd[128]; /* VPD of board, if found */
uchar serial_num[20]; /* Serial number of board, if found in VPD */
spinlock_t bd_lock; /* Used to protect board */
spinlock_t bd_intr_lock; /* Used to protect the poller tasklet and
* the interrupt routine from each other.
*/
uint state; /* State of card. */
wait_queue_head_t state_wait; /* Place to sleep on for state change */
struct tasklet_struct helper_tasklet; /* Poll helper tasklet */
uint nasync; /* Number of ports on card */
uint irq; /* Interrupt request number */
ulong intr_count; /* Count of interrupts */
ulong intr_modem; /* Count of interrupts */
ulong intr_tx; /* Count of interrupts */
ulong intr_rx; /* Count of interrupts */
ulong membase; /* Start of base memory of the card */
ulong membase_end; /* End of base memory of the card */
uchar *re_map_membase;/* Remapped memory of the card */
ulong iobase; /* Start of io base of the card */
ulong iobase_end; /* End of io base of the card */
uint bd_uart_offset; /* Space between each UART */
struct channel_t *channels[MAXPORTS]; /* array of pointers to our channels. */
struct tty_driver SerialDriver;
char SerialName[200];
struct tty_driver PrintDriver;
char PrintName[200];
uint dgnc_Major_Serial_Registered;
uint dgnc_Major_TransparentPrint_Registered;
uint dgnc_Serial_Major;
uint dgnc_TransparentPrint_Major;
uint TtyRefCnt;
char *flipbuf; /* Our flip buffer, alloced if board is found */
u16 dpatype; /* The board "type", as defined by DPA */
u16 dpastatus; /* The board "status", as defined by DPA */
/*
* Mgmt data.
*/
char *msgbuf_head;
char *msgbuf;
uint bd_dividend; /* Board/UARTs specific dividend */
struct board_ops *bd_ops;
/* /proc/<board> entries */
struct proc_dir_entry *proc_entry_pointer;
struct dgnc_proc_entry *dgnc_board_table;
};
/************************************************************************
* Unit flag definitions for un_flags.
************************************************************************/
#define UN_ISOPEN 0x0001 /* Device is open */
#define UN_CLOSING 0x0002 /* Line is being closed */
#define UN_IMM 0x0004 /* Service immediately */
#define UN_BUSY 0x0008 /* Some work this channel */
#define UN_BREAKI 0x0010 /* Input break received */
#define UN_PWAIT 0x0020 /* Printer waiting for terminal */
#define UN_TIME 0x0040 /* Waiting on time */
#define UN_EMPTY 0x0080 /* Waiting output queue empty */
#define UN_LOW 0x0100 /* Waiting output low water mark*/
#define UN_EXCL_OPEN 0x0200 /* Open for exclusive use */
#define UN_WOPEN 0x0400 /* Device waiting for open */
#define UN_WIOCTL 0x0800 /* Device waiting for open */
#define UN_HANGUP 0x8000 /* Carrier lost */
struct device;
/************************************************************************
* Structure for terminal or printer unit.
************************************************************************/
struct un_t {
int magic; /* Unit Magic Number. */
struct channel_t *un_ch;
ulong un_time;
uint un_type;
uint un_open_count; /* Counter of opens to port */
struct tty_struct *un_tty;/* Pointer to unit tty structure */
uint un_flags; /* Unit flags */
wait_queue_head_t un_flags_wait; /* Place to sleep to wait on unit */
uint un_dev; /* Minor device number */
struct device *un_sysfs;
};
/************************************************************************
* Device flag definitions for ch_flags.
************************************************************************/
#define CH_PRON 0x0001 /* Printer on string */
#define CH_STOP 0x0002 /* Output is stopped */
#define CH_STOPI 0x0004 /* Input is stopped */
#define CH_CD 0x0008 /* Carrier is present */
#define CH_FCAR 0x0010 /* Carrier forced on */
#define CH_HANGUP 0x0020 /* Hangup received */
#define CH_RECEIVER_OFF 0x0040 /* Receiver is off */
#define CH_OPENING 0x0080 /* Port in fragile open state */
#define CH_CLOSING 0x0100 /* Port in fragile close state */
#define CH_FIFO_ENABLED 0x0200 /* Port has FIFOs enabled */
#define CH_TX_FIFO_EMPTY 0x0400 /* TX Fifo is completely empty */
#define CH_TX_FIFO_LWM 0x0800 /* TX Fifo is below Low Water */
#define CH_BREAK_SENDING 0x1000 /* Break is being sent */
#define CH_LOOPBACK 0x2000 /* Channel is in lookback mode */
#define CH_FLIPBUF_IN_USE 0x4000 /* Channel's flipbuf is in use */
#define CH_BAUD0 0x08000 /* Used for checking B0 transitions */
#define CH_FORCED_STOP 0x20000 /* Output is forcibly stopped */
#define CH_FORCED_STOPI 0x40000 /* Input is forcibly stopped */
/*
* Definitions for ch_sniff_flags
*/
#define SNIFF_OPEN 0x1
#define SNIFF_WAIT_DATA 0x2
#define SNIFF_WAIT_SPACE 0x4
/* Our Read/Error/Write queue sizes */
#define RQUEUEMASK 0x1FFF /* 8 K - 1 */
#define EQUEUEMASK 0x1FFF /* 8 K - 1 */
#define WQUEUEMASK 0x0FFF /* 4 K - 1 */
#define RQUEUESIZE (RQUEUEMASK + 1)
#define EQUEUESIZE RQUEUESIZE
#define WQUEUESIZE (WQUEUEMASK + 1)
/************************************************************************
* Channel information structure.
************************************************************************/
struct channel_t {
int magic; /* Channel Magic Number */
struct board_t *ch_bd; /* Board structure pointer */
struct digi_t ch_digi; /* Transparent Print structure */
struct un_t ch_tun; /* Terminal unit info */
struct un_t ch_pun; /* Printer unit info */
spinlock_t ch_lock; /* provide for serialization */
wait_queue_head_t ch_flags_wait;
uint ch_portnum; /* Port number, 0 offset. */
uint ch_open_count; /* open count */
uint ch_flags; /* Channel flags */
ulong ch_close_delay; /* How long we should drop RTS/DTR for */
ulong ch_cpstime; /* Time for CPS calculations */
tcflag_t ch_c_iflag; /* channel iflags */
tcflag_t ch_c_cflag; /* channel cflags */
tcflag_t ch_c_oflag; /* channel oflags */
tcflag_t ch_c_lflag; /* channel lflags */
uchar ch_stopc; /* Stop character */
uchar ch_startc; /* Start character */
uint ch_old_baud; /* Cache of the current baud */
uint ch_custom_speed;/* Custom baud, if set */
uint ch_wopen; /* Waiting for open process cnt */
uchar ch_mostat; /* FEP output modem status */
uchar ch_mistat; /* FEP input modem status */
struct neo_uart_struct *ch_neo_uart; /* Pointer to the "mapped" UART struct */
struct cls_uart_struct *ch_cls_uart; /* Pointer to the "mapped" UART struct */
uchar ch_cached_lsr; /* Cached value of the LSR register */
uchar *ch_rqueue; /* Our read queue buffer - malloc'ed */
ushort ch_r_head; /* Head location of the read queue */
ushort ch_r_tail; /* Tail location of the read queue */
uchar *ch_equeue; /* Our error queue buffer - malloc'ed */
ushort ch_e_head; /* Head location of the error queue */
ushort ch_e_tail; /* Tail location of the error queue */
uchar *ch_wqueue; /* Our write queue buffer - malloc'ed */
ushort ch_w_head; /* Head location of the write queue */
ushort ch_w_tail; /* Tail location of the write queue */
ulong ch_rxcount; /* total of data received so far */
ulong ch_txcount; /* total of data transmitted so far */
uchar ch_r_tlevel; /* Receive Trigger level */
uchar ch_t_tlevel; /* Transmit Trigger level */
uchar ch_r_watermark; /* Receive Watermark */
ulong ch_stop_sending_break; /* Time we should STOP sending a break */
uint ch_stops_sent; /* How many times I have sent a stop character
* to try to stop the other guy sending.
*/
ulong ch_err_parity; /* Count of parity errors on channel */
ulong ch_err_frame; /* Count of framing errors on channel */
ulong ch_err_break; /* Count of breaks on channel */
ulong ch_err_overrun; /* Count of overruns on channel */
ulong ch_xon_sends; /* Count of xons transmitted */
ulong ch_xoff_sends; /* Count of xoffs transmitted */
ulong ch_intr_modem; /* Count of interrupts */
ulong ch_intr_tx; /* Count of interrupts */
ulong ch_intr_rx; /* Count of interrupts */
/* /proc/<board>/<channel> entries */
struct proc_dir_entry *proc_entry_pointer;
struct dgnc_proc_entry *dgnc_channel_table;
uint ch_sniff_in;
uint ch_sniff_out;
char *ch_sniff_buf; /* Sniff buffer for proc */
ulong ch_sniff_flags; /* Channel flags */
wait_queue_head_t ch_sniff_wait;
};
/*************************************************************************
*
* Prototypes for non-static functions used in more than one module
*
*************************************************************************/
extern int dgnc_ms_sleep(ulong ms);
extern void *dgnc_driver_kzmalloc(size_t size, int priority);
extern char *dgnc_ioctl_name(int cmd);
/*
* Our Global Variables.
*/
extern int dgnc_driver_state; /* The state of the driver */
extern uint dgnc_Major; /* Our driver/mgmt major */
extern int dgnc_debug; /* Debug variable */
extern int dgnc_rawreadok; /* Set if user wants rawreads */
extern int dgnc_poll_tick; /* Poll interval - 20 ms */
extern int dgnc_trcbuf_size; /* Size of the ringbuffer */
extern spinlock_t dgnc_global_lock; /* Driver global spinlock */
extern uint dgnc_NumBoards; /* Total number of boards */
extern struct board_t *dgnc_Board[MAXBOARDS]; /* Array of board structs */
extern ulong dgnc_poll_counter; /* Times the poller has run */
extern char *dgnc_state_text[]; /* Array of state text */
extern char *dgnc_driver_state_text[];/* Array of driver state text */
#endif

Просмотреть файл

@ -0,0 +1,91 @@
/*
* Copyright 2004 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*
*************************************************************************
*
* This file is intended to contain all the kernel "differences" between the
* various kernels that we support.
*
*************************************************************************/
#ifndef __DGNC_KCOMPAT_H
#define __DGNC_KCOMPAT_H
# ifndef KERNEL_VERSION
# define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
# endif
#if !defined(TTY_FLIPBUF_SIZE)
# define TTY_FLIPBUF_SIZE 512
#endif
/* Sparse stuff */
# ifndef __user
# define __user
# define __kernel
# define __safe
# define __force
# define __chk_user_ptr(x) (void)0
# endif
# define PARM_STR(VAR, INIT, PERM, DESC) \
static char *VAR = INIT; \
char *dgnc_##VAR; \
module_param(VAR, charp, PERM); \
MODULE_PARM_DESC(VAR, DESC);
# define PARM_INT(VAR, INIT, PERM, DESC) \
static int VAR = INIT; \
int dgnc_##VAR; \
module_param(VAR, int, PERM); \
MODULE_PARM_DESC(VAR, DESC);
# define PARM_ULONG(VAR, INIT, PERM, DESC) \
static ulong VAR = INIT; \
ulong dgnc_##VAR; \
module_param(VAR, long, PERM); \
MODULE_PARM_DESC(VAR, DESC);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
/* NOTHING YET */
# else
# error "this driver does not support anything below the 2.6.27 kernel series."
# endif
#endif /* ! __DGNC_KCOMPAT_H */

Просмотреть файл

@ -0,0 +1,313 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
*
* NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE!
*
* This is shared code between Digi's CVS archive and the
* Linux Kernel sources.
* Changing the source just for reformatting needlessly breaks
* our CVS diff history.
*
* Send any bug fixes/changes to: Eng.Linux at digi dot com.
* Thank you.
*
*/
/************************************************************************
*
* This file implements the mgmt functionality for the
* Neo and ClassicBoard based product lines.
*
************************************************************************
* $Id: dgnc_mgmt.c,v 1.2 2010/12/14 20:08:29 markh Exp $
*/
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/ctype.h>
#include <linux/sched.h> /* For jiffies, task states */
#include <linux/interrupt.h> /* For tasklet and interrupt structs/defines */
#include <linux/serial_reg.h>
#include <linux/termios.h>
#include <asm/uaccess.h> /* For copy_from_user/copy_to_user */
#include "dgnc_driver.h"
#include "dgnc_pci.h"
#include "dgnc_proc.h"
#include "dgnc_kcompat.h" /* Kernel 2.4/2.6 compat includes */
#include "dgnc_mgmt.h"
#include "dpacompat.h"
/* Our "in use" variables, to enforce 1 open only */
static int dgnc_mgmt_in_use[MAXMGMTDEVICES];
/*
* dgnc_mgmt_open()
*
* Open the mgmt/downld/dpa device
*/
int dgnc_mgmt_open(struct inode *inode, struct file *file)
{
unsigned long lock_flags;
unsigned int minor = iminor(inode);
DPR_MGMT(("dgnc_mgmt_open start.\n"));
DGNC_LOCK(dgnc_global_lock, lock_flags);
/* mgmt device */
if (minor < MAXMGMTDEVICES) {
/* Only allow 1 open at a time on mgmt device */
if (dgnc_mgmt_in_use[minor]) {
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
return (-EBUSY);
}
dgnc_mgmt_in_use[minor]++;
}
else {
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
return (-ENXIO);
}
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
DPR_MGMT(("dgnc_mgmt_open finish.\n"));
return 0;
}
/*
* dgnc_mgmt_close()
*
* Open the mgmt/dpa device
*/
int dgnc_mgmt_close(struct inode *inode, struct file *file)
{
unsigned long lock_flags;
unsigned int minor = iminor(inode);
DPR_MGMT(("dgnc_mgmt_close start.\n"));
DGNC_LOCK(dgnc_global_lock, lock_flags);
/* mgmt device */
if (minor < MAXMGMTDEVICES) {
if (dgnc_mgmt_in_use[minor]) {
dgnc_mgmt_in_use[minor] = 0;
}
}
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
DPR_MGMT(("dgnc_mgmt_close finish.\n"));
return 0;
}
/*
* dgnc_mgmt_ioctl()
*
* ioctl the mgmt/dpa device
*/
#ifdef HAVE_UNLOCKED_IOCTL
long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct inode *inode = file->f_dentry->d_inode;
#else
int dgnc_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
{
#endif
unsigned long lock_flags;
void __user *uarg = (void __user *) arg;
DPR_MGMT(("dgnc_mgmt_ioctl start.\n"));
switch (cmd) {
case DIGI_GETDD:
{
/*
* This returns the total number of boards
* in the system, as well as driver version
* and has space for a reserved entry
*/
struct digi_dinfo ddi;
DGNC_LOCK(dgnc_global_lock, lock_flags);
ddi.dinfo_nboards = dgnc_NumBoards;
sprintf(ddi.dinfo_version, "%s", DG_PART);
DGNC_UNLOCK(dgnc_global_lock, lock_flags);
DPR_MGMT(("DIGI_GETDD returning numboards: %d version: %s\n",
ddi.dinfo_nboards, ddi.dinfo_version));
if (copy_to_user(uarg, &ddi, sizeof (ddi)))
return(-EFAULT);
break;
}
case DIGI_GETBD:
{
int brd;
struct digi_info di;
if (copy_from_user(&brd, uarg, sizeof(int))) {
return(-EFAULT);
}
DPR_MGMT(("DIGI_GETBD asking about board: %d\n", brd));
if ((brd < 0) || (brd > dgnc_NumBoards) || (dgnc_NumBoards == 0))
return (-ENODEV);
memset(&di, 0, sizeof(di));
di.info_bdnum = brd;
DGNC_LOCK(dgnc_Board[brd]->bd_lock, lock_flags);
di.info_bdtype = dgnc_Board[brd]->dpatype;
di.info_bdstate = dgnc_Board[brd]->dpastatus;
di.info_ioport = 0;
di.info_physaddr = (ulong) dgnc_Board[brd]->membase;
di.info_physsize = (ulong) dgnc_Board[brd]->membase - dgnc_Board[brd]->membase_end;
if (dgnc_Board[brd]->state != BOARD_FAILED)
di.info_nports = dgnc_Board[brd]->nasync;
else
di.info_nports = 0;
DGNC_UNLOCK(dgnc_Board[brd]->bd_lock, lock_flags);
DPR_MGMT(("DIGI_GETBD returning type: %x state: %x ports: %x size: %x\n",
di.info_bdtype, di.info_bdstate, di.info_nports, di.info_physsize));
if (copy_to_user(uarg, &di, sizeof (di)))
return (-EFAULT);
break;
}
case DIGI_GET_NI_INFO:
{
struct channel_t *ch;
struct ni_info ni;
uchar mstat = 0;
uint board = 0;
uint channel = 0;
if (copy_from_user(&ni, uarg, sizeof(struct ni_info))) {
return(-EFAULT);
}
DPR_MGMT(("DIGI_GETBD asking about board: %d channel: %d\n",
ni.board, ni.channel));
board = ni.board;
channel = ni.channel;
/* Verify boundaries on board */
if ((board < 0) || (board > dgnc_NumBoards) || (dgnc_NumBoards == 0))
return (-ENODEV);
/* Verify boundaries on channel */
if ((channel < 0) || (channel > dgnc_Board[board]->nasync))
return (-ENODEV);
ch = dgnc_Board[board]->channels[channel];
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (-ENODEV);
memset(&ni, 0, sizeof(ni));
ni.board = board;
ni.channel = channel;
DGNC_LOCK(ch->ch_lock, lock_flags);
mstat = (ch->ch_mostat | ch->ch_mistat);
if (mstat & UART_MCR_DTR) {
ni.mstat |= TIOCM_DTR;
ni.dtr = TIOCM_DTR;
}
if (mstat & UART_MCR_RTS) {
ni.mstat |= TIOCM_RTS;
ni.rts = TIOCM_RTS;
}
if (mstat & UART_MSR_CTS) {
ni.mstat |= TIOCM_CTS;
ni.cts = TIOCM_CTS;
}
if (mstat & UART_MSR_RI) {
ni.mstat |= TIOCM_RI;
ni.ri = TIOCM_RI;
}
if (mstat & UART_MSR_DCD) {
ni.mstat |= TIOCM_CD;
ni.dcd = TIOCM_CD;
}
if (mstat & UART_MSR_DSR)
ni.mstat |= TIOCM_DSR;
ni.iflag = ch->ch_c_iflag;
ni.oflag = ch->ch_c_oflag;
ni.cflag = ch->ch_c_cflag;
ni.lflag = ch->ch_c_lflag;
if (ch->ch_digi.digi_flags & CTSPACE || ch->ch_c_cflag & CRTSCTS)
ni.hflow = 1;
else
ni.hflow = 0;
if ((ch->ch_flags & CH_STOPI) || (ch->ch_flags & CH_FORCED_STOPI))
ni.recv_stopped = 1;
else
ni.recv_stopped = 0;
if ((ch->ch_flags & CH_STOP) || (ch->ch_flags & CH_FORCED_STOP))
ni.xmit_stopped = 1;
else
ni.xmit_stopped = 0;
ni.curtx = ch->ch_txcount;
ni.currx = ch->ch_rxcount;
ni.baud = ch->ch_old_baud;
DGNC_UNLOCK(ch->ch_lock, lock_flags);
if (copy_to_user(uarg, &ni, sizeof(ni)))
return (-EFAULT);
break;
}
}
DPR_MGMT(("dgnc_mgmt_ioctl finish.\n"));
return 0;
}

Просмотреть файл

@ -0,0 +1,37 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*/
#ifndef __DGNC_MGMT_H
#define __DGNC_MGMT_H
#define MAXMGMTDEVICES 8
int dgnc_mgmt_open(struct inode *inode, struct file *file);
int dgnc_mgmt_close(struct inode *inode, struct file *file);
#ifdef HAVE_UNLOCKED_IOCTL
long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
#else
int dgnc_mgmt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg);
#endif
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,157 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*
*/
#ifndef __DGNC_NEO_H
#define __DGNC_NEO_H
#include "dgnc_types.h"
#include "dgnc_driver.h"
/************************************************************************
* Per channel/port NEO UART structure *
************************************************************************
* Base Structure Entries Usage Meanings to Host *
* *
* W = read write R = read only *
* U = Unused. *
************************************************************************/
struct neo_uart_struct {
volatile uchar txrx; /* WR RHR/THR - Holding Reg */
volatile uchar ier; /* WR IER - Interrupt Enable Reg */
volatile uchar isr_fcr; /* WR ISR/FCR - Interrupt Status Reg/Fifo Control Reg */
volatile uchar lcr; /* WR LCR - Line Control Reg */
volatile uchar mcr; /* WR MCR - Modem Control Reg */
volatile uchar lsr; /* WR LSR - Line Status Reg */
volatile uchar msr; /* WR MSR - Modem Status Reg */
volatile uchar spr; /* WR SPR - Scratch Pad Reg */
volatile uchar fctr; /* WR FCTR - Feature Control Reg */
volatile uchar efr; /* WR EFR - Enhanced Function Reg */
volatile uchar tfifo; /* WR TXCNT/TXTRG - Transmit FIFO Reg */
volatile uchar rfifo; /* WR RXCNT/RXTRG - Recieve FIFO Reg */
volatile uchar xoffchar1; /* WR XOFF 1 - XOff Character 1 Reg */
volatile uchar xoffchar2; /* WR XOFF 2 - XOff Character 2 Reg */
volatile uchar xonchar1; /* WR XON 1 - Xon Character 1 Reg */
volatile uchar xonchar2; /* WR XON 2 - XOn Character 2 Reg */
volatile uchar reserved1[0x2ff - 0x200]; /* U Reserved by Exar */
volatile uchar txrxburst[64]; /* RW 64 bytes of RX/TX FIFO Data */
volatile uchar reserved2[0x37f - 0x340]; /* U Reserved by Exar */
volatile uchar rxburst_with_errors[64]; /* R 64 bytes of RX FIFO Data + LSR */
};
/* Where to read the extended interrupt register (32bits instead of 8bits) */
#define UART_17158_POLL_ADDR_OFFSET 0x80
/* These are the current dvid's of the Neo boards */
#define UART_XR17C158_DVID 0x20
#define UART_XR17D158_DVID 0x20
#define UART_XR17E158_DVID 0x40
#define NEO_EECK 0x10 /* Clock */
#define NEO_EECS 0x20 /* Chip Select */
#define NEO_EEDI 0x40 /* Data In is an Output Pin */
#define NEO_EEDO 0x80 /* Data Out is an Input Pin */
#define NEO_EEREG 0x8E /* offset to EEPROM control reg */
#define NEO_VPD_IMAGESIZE 0x40 /* size of image to read from EEPROM in words */
#define NEO_VPD_IMAGEBYTES (NEO_VPD_IMAGESIZE * 2)
/*
* These are the redefinitions for the FCTR on the XR17C158, since
* Exar made them different than their earlier design. (XR16C854)
*/
/* These are only applicable when table D is selected */
#define UART_17158_FCTR_RTS_NODELAY 0x00
#define UART_17158_FCTR_RTS_4DELAY 0x01
#define UART_17158_FCTR_RTS_6DELAY 0x02
#define UART_17158_FCTR_RTS_8DELAY 0x03
#define UART_17158_FCTR_RTS_12DELAY 0x12
#define UART_17158_FCTR_RTS_16DELAY 0x05
#define UART_17158_FCTR_RTS_20DELAY 0x13
#define UART_17158_FCTR_RTS_24DELAY 0x06
#define UART_17158_FCTR_RTS_28DELAY 0x14
#define UART_17158_FCTR_RTS_32DELAY 0x07
#define UART_17158_FCTR_RTS_36DELAY 0x16
#define UART_17158_FCTR_RTS_40DELAY 0x08
#define UART_17158_FCTR_RTS_44DELAY 0x09
#define UART_17158_FCTR_RTS_48DELAY 0x10
#define UART_17158_FCTR_RTS_52DELAY 0x11
#define UART_17158_FCTR_RTS_IRDA 0x10
#define UART_17158_FCTR_RS485 0x20
#define UART_17158_FCTR_TRGA 0x00
#define UART_17158_FCTR_TRGB 0x40
#define UART_17158_FCTR_TRGC 0x80
#define UART_17158_FCTR_TRGD 0xC0
/* 17158 trigger table selects.. */
#define UART_17158_FCTR_BIT6 0x40
#define UART_17158_FCTR_BIT7 0x80
/* 17158 TX/RX memmapped buffer offsets */
#define UART_17158_RX_FIFOSIZE 64
#define UART_17158_TX_FIFOSIZE 64
/* 17158 Extended IIR's */
#define UART_17158_IIR_RDI_TIMEOUT 0x0C /* Receiver data TIMEOUT */
#define UART_17158_IIR_XONXOFF 0x10 /* Received an XON/XOFF char */
#define UART_17158_IIR_HWFLOW_STATE_CHANGE 0x20 /* CTS/DSR or RTS/DTR state change */
#define UART_17158_IIR_FIFO_ENABLED 0xC0 /* 16550 FIFOs are Enabled */
/*
* These are the extended interrupts that get sent
* back to us from the UART's 32bit interrupt register
*/
#define UART_17158_RX_LINE_STATUS 0x1 /* RX Ready */
#define UART_17158_RXRDY_TIMEOUT 0x2 /* RX Ready Timeout */
#define UART_17158_TXRDY 0x3 /* TX Ready */
#define UART_17158_MSR 0x4 /* Modem State Change */
#define UART_17158_TX_AND_FIFO_CLR 0x40 /* Transmitter Holding Reg Empty */
#define UART_17158_RX_FIFO_DATA_ERROR 0x80 /* UART detected an RX FIFO Data error */
/*
* These are the EXTENDED definitions for the 17C158's Interrupt
* Enable Register.
*/
#define UART_17158_EFR_ECB 0x10 /* Enhanced control bit */
#define UART_17158_EFR_IXON 0x2 /* Receiver compares Xon1/Xoff1 */
#define UART_17158_EFR_IXOFF 0x8 /* Transmit Xon1/Xoff1 */
#define UART_17158_EFR_RTSDTR 0x40 /* Auto RTS/DTR Flow Control Enable */
#define UART_17158_EFR_CTSDSR 0x80 /* Auto CTS/DSR Flow COntrol Enable */
#define UART_17158_XOFF_DETECT 0x1 /* Indicates whether chip saw an incoming XOFF char */
#define UART_17158_XON_DETECT 0x2 /* Indicates whether chip saw an incoming XON char */
#define UART_17158_IER_RSVD1 0x10 /* Reserved by Exar */
#define UART_17158_IER_XOFF 0x20 /* Xoff Interrupt Enable */
#define UART_17158_IER_RTSDTR 0x40 /* Output Interrupt Enable */
#define UART_17158_IER_CTSDSR 0x80 /* Input Interrupt Enable */
/*
* Our Global Variables
*/
extern struct board_ops dgnc_neo_ops;
#endif

Просмотреть файл

@ -0,0 +1,77 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*/
/* $Id: dgnc_pci.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */
#ifndef __DGNC_PCI_H
#define __DGNC_PCI_H
#define PCIMAX 32 /* maximum number of PCI boards */
#define DIGI_VID 0x114F
#define PCI_DEVICE_CLASSIC_4_DID 0x0028
#define PCI_DEVICE_CLASSIC_8_DID 0x0029
#define PCI_DEVICE_CLASSIC_4_422_DID 0x00D0
#define PCI_DEVICE_CLASSIC_8_422_DID 0x00D1
#define PCI_DEVICE_NEO_4_DID 0x00B0
#define PCI_DEVICE_NEO_8_DID 0x00B1
#define PCI_DEVICE_NEO_2DB9_DID 0x00C8
#define PCI_DEVICE_NEO_2DB9PRI_DID 0x00C9
#define PCI_DEVICE_NEO_2RJ45_DID 0x00CA
#define PCI_DEVICE_NEO_2RJ45PRI_DID 0x00CB
#define PCI_DEVICE_NEO_1_422_DID 0x00CC
#define PCI_DEVICE_NEO_1_422_485_DID 0x00CD
#define PCI_DEVICE_NEO_2_422_485_DID 0x00CE
#define PCI_DEVICE_NEO_EXPRESS_8_DID 0x00F0
#define PCI_DEVICE_NEO_EXPRESS_4_DID 0x00F1
#define PCI_DEVICE_NEO_EXPRESS_4RJ45_DID 0x00F2
#define PCI_DEVICE_NEO_EXPRESS_8RJ45_DID 0x00F3
#define PCI_DEVICE_NEO_EXPRESS_4_IBM_DID 0x00F4
#define PCI_DEVICE_CLASSIC_4_PCI_NAME "ClassicBoard 4 PCI"
#define PCI_DEVICE_CLASSIC_8_PCI_NAME "ClassicBoard 8 PCI"
#define PCI_DEVICE_CLASSIC_4_422_PCI_NAME "ClassicBoard 4 422 PCI"
#define PCI_DEVICE_CLASSIC_8_422_PCI_NAME "ClassicBoard 8 422 PCI"
#define PCI_DEVICE_NEO_4_PCI_NAME "Neo 4 PCI"
#define PCI_DEVICE_NEO_8_PCI_NAME "Neo 8 PCI"
#define PCI_DEVICE_NEO_2DB9_PCI_NAME "Neo 2 - DB9 Universal PCI"
#define PCI_DEVICE_NEO_2DB9PRI_PCI_NAME "Neo 2 - DB9 Universal PCI - Powered Ring Indicator"
#define PCI_DEVICE_NEO_2RJ45_PCI_NAME "Neo 2 - RJ45 Universal PCI"
#define PCI_DEVICE_NEO_2RJ45PRI_PCI_NAME "Neo 2 - RJ45 Universal PCI - Powered Ring Indicator"
#define PCI_DEVICE_NEO_1_422_PCI_NAME "Neo 1 422 PCI"
#define PCI_DEVICE_NEO_1_422_485_PCI_NAME "Neo 1 422/485 PCI"
#define PCI_DEVICE_NEO_2_422_485_PCI_NAME "Neo 2 422/485 PCI"
#define PCI_DEVICE_NEO_EXPRESS_8_PCI_NAME "Neo 8 PCI Express"
#define PCI_DEVICE_NEO_EXPRESS_4_PCI_NAME "Neo 4 PCI Express"
#define PCI_DEVICE_NEO_EXPRESS_4RJ45_PCI_NAME "Neo 4 PCI Express RJ45"
#define PCI_DEVICE_NEO_EXPRESS_8RJ45_PCI_NAME "Neo 8 PCI Express RJ45"
#define PCI_DEVICE_NEO_EXPRESS_4_IBM_PCI_NAME "Neo 4 PCI Express IBM"
/* Size of Memory and I/O for PCI (4 K) */
#define PCI_RAM_SIZE 0x1000
/* Size of Memory (2MB) */
#define PCI_MEM_SIZE 0x1000
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,147 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*
*
* $Id: dgnc_proc.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $
*
* Description:
*
* Describes the private structures used to manipulate the "special"
* proc constructs (not read-only) used by the Digi Neo software.
* The concept is borrowed heavily from the "sysctl" interface of
* the kernel. I decided not to use the structures and functions
* provided by the kernel for two reasons:
*
* 1. Due to the planned use of "/proc" in the Neo driver, many
* of the functions of the "sysctl" interface would go unused.
* A simpler interface will be easier to maintain.
*
* 2. I'd rather divorce our "added package" from the kernel internals.
* If the "sysctl" structures should change, I will be insulated
* from those changes. These "/proc" entries won't be under the
* "sys" tree anyway, so there is no need to maintain a strict
* dependence relationship.
*
* Author:
*
* Scott H Kilau
*
*/
#ifndef _DGNC_RW_PROC_H
#define _DGNC_RW_PROC_H
/*
* The list of DGNC entries with r/w capabilities.
* These magic numbers are used for identification purposes.
*/
enum {
DGNC_INFO = 1, /* Get info about the running module */
DGNC_MKNOD = 2, /* Get info about driver devices */
DGNC_BOARD_INFO = 3, /* Get info about the specific board */
DGNC_BOARD_VPD = 4, /* Get info about the board's VPD */
DGNC_BOARD_TTYSTATS = 5, /* Get info about the board's tty stats */
DGNC_BOARD_TTYINTR = 6, /* Get info about the board's tty intrs */
DGNC_BOARD_TTYFLAGS = 7, /* Get info about the board's tty flags */
DGNC_BOARD_MKNOD = 8, /* Get info about board devices */
DGNC_PORT_INFO = 9, /* Get info about the specific port */
DGNC_PORT_SNIFF = 10, /* Sniff data in/out of specific port */
DGNC_PORT_CUSTOM_TTYNAME = 11, /* Get info about UDEV tty name */
DGNC_PORT_CUSTOM_PRNAME = 12, /* Get info about UDEV pr name */
};
/*
* Directions for proc handlers
*/
enum {
INBOUND = 1, /* Data being written to kernel */
OUTBOUND = 2, /* Data being read from the kernel */
};
/*
* Each entry in a DGNC proc directory is described with a
* "dgnc_proc_entry" structure. A collection of these
* entries (in an array) represents the members associated
* with a particular "/proc" directory, and is referred to
* as a table. All "tables" are terminated by an entry with
* zeros for every member.
*
* The structure members are as follows:
*
* int magic -- ID number associated with this particular
* entry. Should be unique across all of
* DGNC.
*
* const char *name -- ASCII name associated with the /proc entry.
*
* mode_t mode -- File access permisssions for the /proc entry.
*
* dgnc_proc_entry *child -- When set, this entry refers to a directory,
* and points to the table which describes the
* entries in the subdirectory
*
* dgnc_proc_handler *open_handler -- When set, points to the fxn which
* does any "extra" open stuff.
*
* dgnc_proc_handler *close_handler -- When set, points to the fxn which
* does any "extra" close stuff.
*
* dgnc_proc_handler *read_handler -- When set, points to the fxn which
* handle outbound data flow
*
* dgnc_proc_handler *write_handler -- When set, points to the fxn which
* handles inbound data flow
*
* struct proc_dir_entry *de -- Pointer to the directory entry for this
* object once registered. Used to grab
* the handle of the object for
* unregistration
*
* void *data; When set, points to the parent structure
*
*/
struct dgnc_proc_entry {
int magic; /* Integer identifier */
const char *name; /* ASCII identifier */
mode_t mode; /* File access permissions */
struct dgnc_proc_entry *child; /* Child pointer */
int (*open_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp,
void *buffer, ssize_t *lenp, loff_t *ppos);
int (*close_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp,
void *buffer, ssize_t *lenp, loff_t *ppos);
int (*read_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp,
char __user *buffer, ssize_t *lenp, loff_t *ppos);
int (*write_handler) (struct dgnc_proc_entry *table, int dir, struct file *filp,
const char __user *buffer, ssize_t *lenp, loff_t *ppos);
struct proc_dir_entry *de; /* proc entry pointer */
struct semaphore excl_sem; /* Protects exclusive access var */
int excl_cnt; /* Counts number of curr accesses */
void *data; /* Allows storing a pointer to parent */
};
void dgnc_proc_register_basic_prescan(void);
void dgnc_proc_register_basic_postscan(int board_num);
void dgnc_proc_unregister_all(void);
#endif /* _DGNC_RW_PROC_H */

Просмотреть файл

@ -0,0 +1,761 @@
/*
* Copyright 2004 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
*
* NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE!
*
* This is shared code between Digi's CVS archive and the
* Linux Kernel sources.
* Changing the source just for reformatting needlessly breaks
* our CVS diff history.
*
* Send any bug fixes/changes to: Eng.Linux at digi dot com.
* Thank you.
*
*
*
* $Id: dgnc_sysfs.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $
*/
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/module.h>
#include <linux/ctype.h>
#include <linux/string.h>
#include <linux/serial_reg.h>
#include <linux/device.h>
#include <linux/pci.h>
#include <linux/kdev_t.h>
#include "dgnc_driver.h"
#include "dgnc_proc.h"
#include "dgnc_mgmt.h"
static ssize_t dgnc_driver_version_show(struct device_driver *ddp, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%s\n", DG_PART);
}
static DRIVER_ATTR(version, S_IRUSR, dgnc_driver_version_show, NULL);
static ssize_t dgnc_driver_boards_show(struct device_driver *ddp, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", dgnc_NumBoards);
}
static DRIVER_ATTR(boards, S_IRUSR, dgnc_driver_boards_show, NULL);
static ssize_t dgnc_driver_maxboards_show(struct device_driver *ddp, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", MAXBOARDS);
}
static DRIVER_ATTR(maxboards, S_IRUSR, dgnc_driver_maxboards_show, NULL);
static ssize_t dgnc_driver_pollcounter_show(struct device_driver *ddp, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%ld\n", dgnc_poll_counter);
}
static DRIVER_ATTR(pollcounter, S_IRUSR, dgnc_driver_pollcounter_show, NULL);
static ssize_t dgnc_driver_state_show(struct device_driver *ddp, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%s\n", dgnc_driver_state_text[dgnc_driver_state]);
}
static DRIVER_ATTR(state, S_IRUSR, dgnc_driver_state_show, NULL);
static ssize_t dgnc_driver_debug_show(struct device_driver *ddp, char *buf)
{
return snprintf(buf, PAGE_SIZE, "0x%x\n", dgnc_debug);
}
static ssize_t dgnc_driver_debug_store(struct device_driver *ddp, const char *buf, size_t count)
{
sscanf(buf, "0x%x\n", &dgnc_debug);
return count;
}
static DRIVER_ATTR(debug, (S_IRUSR | S_IWUSR), dgnc_driver_debug_show, dgnc_driver_debug_store);
static ssize_t dgnc_driver_rawreadok_show(struct device_driver *ddp, char *buf)
{
return snprintf(buf, PAGE_SIZE, "0x%x\n", dgnc_rawreadok);
}
static ssize_t dgnc_driver_rawreadok_store(struct device_driver *ddp, const char *buf, size_t count)
{
sscanf(buf, "0x%x\n", &dgnc_rawreadok);
return count;
}
static DRIVER_ATTR(rawreadok, (S_IRUSR | S_IWUSR), dgnc_driver_rawreadok_show, dgnc_driver_rawreadok_store);
static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%dms\n", dgnc_poll_tick);
}
static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count)
{
sscanf(buf, "%d\n", &dgnc_poll_tick);
return count;
}
static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgnc_driver_pollrate_show, dgnc_driver_pollrate_store);
void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver)
{
int rc = 0;
struct device_driver *driverfs = &dgnc_driver->driver;
rc |= driver_create_file(driverfs, &driver_attr_version);
rc |= driver_create_file(driverfs, &driver_attr_boards);
rc |= driver_create_file(driverfs, &driver_attr_maxboards);
rc |= driver_create_file(driverfs, &driver_attr_debug);
rc |= driver_create_file(driverfs, &driver_attr_rawreadok);
rc |= driver_create_file(driverfs, &driver_attr_pollrate);
rc |= driver_create_file(driverfs, &driver_attr_pollcounter);
rc |= driver_create_file(driverfs, &driver_attr_state);
if (rc) {
printk(KERN_ERR "DGNC: sysfs driver_create_file failed!\n");
}
}
void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver)
{
struct device_driver *driverfs = &dgnc_driver->driver;
driver_remove_file(driverfs, &driver_attr_version);
driver_remove_file(driverfs, &driver_attr_boards);
driver_remove_file(driverfs, &driver_attr_maxboards);
driver_remove_file(driverfs, &driver_attr_debug);
driver_remove_file(driverfs, &driver_attr_rawreadok);
driver_remove_file(driverfs, &driver_attr_pollrate);
driver_remove_file(driverfs, &driver_attr_pollcounter);
driver_remove_file(driverfs, &driver_attr_state);
}
#define DGNC_VERIFY_BOARD(p, bd) \
if (!p) \
return (0); \
\
bd = dev_get_drvdata(p); \
if (!bd || bd->magic != DGNC_BOARD_MAGIC) \
return (0); \
if (bd->state != BOARD_READY) \
return (0); \
static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
count += sprintf(buf + count, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F");
for (i = 0; i < 0x40 * 2; i++) {
if (!(i % 16))
count += sprintf(buf + count, "\n%04X ", i * 2);
count += sprintf(buf + count, "%02X ", bd->vpd[i]);
}
count += sprintf(buf + count, "\n");
return count;
}
static DEVICE_ATTR(vpd, S_IRUSR, dgnc_vpd_show, NULL);
static ssize_t dgnc_serial_number_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
DGNC_VERIFY_BOARD(p, bd);
if (bd->serial_num[0] == '\0')
count += sprintf(buf + count, "<UNKNOWN>\n");
else
count += sprintf(buf + count, "%s\n", bd->serial_num);
return count;
}
static DEVICE_ATTR(serial_number, S_IRUSR, dgnc_serial_number_show, NULL);
static ssize_t dgnc_ports_state_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count,
"%d %s\n", bd->channels[i]->ch_portnum,
bd->channels[i]->ch_open_count ? "Open" : "Closed");
}
return count;
}
static DEVICE_ATTR(ports_state, S_IRUSR, dgnc_ports_state_show, NULL);
static ssize_t dgnc_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count,
"%d %d\n", bd->channels[i]->ch_portnum, bd->channels[i]->ch_old_baud);
}
return count;
}
static DEVICE_ATTR(ports_baud, S_IRUSR, dgnc_ports_baud_show, NULL);
static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
for (i = 0; i < bd->nasync; i++) {
if (bd->channels[i]->ch_open_count) {
count += snprintf(buf + count, PAGE_SIZE - count,
"%d %s %s %s %s %s %s\n", bd->channels[i]->ch_portnum,
(bd->channels[i]->ch_mostat & UART_MCR_RTS) ? "RTS" : "",
(bd->channels[i]->ch_mistat & UART_MSR_CTS) ? "CTS" : "",
(bd->channels[i]->ch_mostat & UART_MCR_DTR) ? "DTR" : "",
(bd->channels[i]->ch_mistat & UART_MSR_DSR) ? "DSR" : "",
(bd->channels[i]->ch_mistat & UART_MSR_DCD) ? "DCD" : "",
(bd->channels[i]->ch_mistat & UART_MSR_RI) ? "RI" : "");
} else {
count += snprintf(buf + count, PAGE_SIZE - count,
"%d\n", bd->channels[i]->ch_portnum);
}
}
return count;
}
static DEVICE_ATTR(ports_msignals, S_IRUSR, dgnc_ports_msignals_show, NULL);
static ssize_t dgnc_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_iflag);
}
return count;
}
static DEVICE_ATTR(ports_iflag, S_IRUSR, dgnc_ports_iflag_show, NULL);
static ssize_t dgnc_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_cflag);
}
return count;
}
static DEVICE_ATTR(ports_cflag, S_IRUSR, dgnc_ports_cflag_show, NULL);
static ssize_t dgnc_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_oflag);
}
return count;
}
static DEVICE_ATTR(ports_oflag, S_IRUSR, dgnc_ports_oflag_show, NULL);
static ssize_t dgnc_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_lflag);
}
return count;
}
static DEVICE_ATTR(ports_lflag, S_IRUSR, dgnc_ports_lflag_show, NULL);
static ssize_t dgnc_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_digi.digi_flags);
}
return count;
}
static DEVICE_ATTR(ports_digi_flag, S_IRUSR, dgnc_ports_digi_flag_show, NULL);
static ssize_t dgnc_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_rxcount);
}
return count;
}
static DEVICE_ATTR(ports_rxcount, S_IRUSR, dgnc_ports_rxcount_show, NULL);
static ssize_t dgnc_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
int count = 0;
int i = 0;
DGNC_VERIFY_BOARD(p, bd);
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n",
bd->channels[i]->ch_portnum, bd->channels[i]->ch_txcount);
}
return count;
}
static DEVICE_ATTR(ports_txcount, S_IRUSR, dgnc_ports_txcount_show, NULL);
/* this function creates the sys files that will export each signal status
* to sysfs each value will be put in a separate filename
*/
void dgnc_create_ports_sysfiles(struct board_t *bd)
{
int rc = 0;
dev_set_drvdata(&bd->pdev->dev, bd);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_state);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_baud);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_msignals);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_iflag);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_cflag);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_oflag);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_lflag);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_rxcount);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_ports_txcount);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_vpd);
rc |= device_create_file(&(bd->pdev->dev), &dev_attr_serial_number);
if (rc) {
printk(KERN_ERR "DGNC: sysfs device_create_file failed!\n");
}
}
/* removes all the sys files created for that port */
void dgnc_remove_ports_sysfiles(struct board_t *bd)
{
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_state);
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_baud);
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_msignals);
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_iflag);
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_cflag);
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_oflag);
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_lflag);
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_digi_flag);
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_rxcount);
device_remove_file(&(bd->pdev->dev), &dev_attr_ports_txcount);
device_remove_file(&(bd->pdev->dev), &dev_attr_vpd);
device_remove_file(&(bd->pdev->dev), &dev_attr_serial_number);
}
static ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? "Open" : "Closed");
}
static DEVICE_ATTR(state, S_IRUSR, dgnc_tty_state_show, NULL);
static ssize_t dgnc_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
return snprintf(buf, PAGE_SIZE, "%d\n", ch->ch_old_baud);
}
static DEVICE_ATTR(baud, S_IRUSR, dgnc_tty_baud_show, NULL);
static ssize_t dgnc_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
if (ch->ch_open_count) {
return snprintf(buf, PAGE_SIZE, "%s %s %s %s %s %s\n",
(ch->ch_mostat & UART_MCR_RTS) ? "RTS" : "",
(ch->ch_mistat & UART_MSR_CTS) ? "CTS" : "",
(ch->ch_mostat & UART_MCR_DTR) ? "DTR" : "",
(ch->ch_mistat & UART_MSR_DSR) ? "DSR" : "",
(ch->ch_mistat & UART_MSR_DCD) ? "DCD" : "",
(ch->ch_mistat & UART_MSR_RI) ? "RI" : "");
}
return 0;
}
static DEVICE_ATTR(msignals, S_IRUSR, dgnc_tty_msignals_show, NULL);
static ssize_t dgnc_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_iflag);
}
static DEVICE_ATTR(iflag, S_IRUSR, dgnc_tty_iflag_show, NULL);
static ssize_t dgnc_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_cflag);
}
static DEVICE_ATTR(cflag, S_IRUSR, dgnc_tty_cflag_show, NULL);
static ssize_t dgnc_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_oflag);
}
static DEVICE_ATTR(oflag, S_IRUSR, dgnc_tty_oflag_show, NULL);
static ssize_t dgnc_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_c_lflag);
}
static DEVICE_ATTR(lflag, S_IRUSR, dgnc_tty_lflag_show, NULL);
static ssize_t dgnc_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
return snprintf(buf, PAGE_SIZE, "%x\n", ch->ch_digi.digi_flags);
}
static DEVICE_ATTR(digi_flag, S_IRUSR, dgnc_tty_digi_flag_show, NULL);
static ssize_t dgnc_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_rxcount);
}
static DEVICE_ATTR(rxcount, S_IRUSR, dgnc_tty_rxcount_show, NULL);
static ssize_t dgnc_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
return snprintf(buf, PAGE_SIZE, "%ld\n", ch->ch_txcount);
}
static DEVICE_ATTR(txcount, S_IRUSR, dgnc_tty_txcount_show, NULL);
static ssize_t dgnc_tty_name_show(struct device *d, struct device_attribute *attr, char *buf)
{
struct board_t *bd;
struct channel_t *ch;
struct un_t *un;
if (!d)
return (0);
un = (struct un_t *) dev_get_drvdata(d);
if (!un || un->magic != DGNC_UNIT_MAGIC)
return (0);
ch = un->un_ch;
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
return (0);
bd = ch->ch_bd;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (0);
if (bd->state != BOARD_READY)
return (0);
return snprintf(buf, PAGE_SIZE, "%sn%d%c\n",
(un->un_type == DGNC_PRINT) ? "pr" : "tty",
bd->boardnum + 1, 'a' + ch->ch_portnum);
}
static DEVICE_ATTR(custom_name, S_IRUSR, dgnc_tty_name_show, NULL);
static struct attribute *dgnc_sysfs_tty_entries[] = {
&dev_attr_state.attr,
&dev_attr_baud.attr,
&dev_attr_msignals.attr,
&dev_attr_iflag.attr,
&dev_attr_cflag.attr,
&dev_attr_oflag.attr,
&dev_attr_lflag.attr,
&dev_attr_digi_flag.attr,
&dev_attr_rxcount.attr,
&dev_attr_txcount.attr,
&dev_attr_custom_name.attr,
NULL
};
static struct attribute_group dgnc_tty_attribute_group = {
.name = NULL,
.attrs = dgnc_sysfs_tty_entries,
};
void dgnc_create_tty_sysfs(struct un_t *un, struct device *c)
{
int ret;
ret = sysfs_create_group(&c->kobj, &dgnc_tty_attribute_group);
if (ret) {
printk(KERN_ERR "dgnc: failed to create sysfs tty device attributes.\n");
sysfs_remove_group(&c->kobj, &dgnc_tty_attribute_group);
return;
}
dev_set_drvdata(c, un);
}
void dgnc_remove_tty_sysfs(struct device *c)
{
sysfs_remove_group(&c->kobj, &dgnc_tty_attribute_group);
}

Просмотреть файл

@ -0,0 +1,49 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*/
#ifndef __DGNC_SYSFS_H
#define __DGNC_SYSFS_H
#include "dgnc_driver.h"
#include <linux/device.h>
struct board_t;
struct channel_t;
struct un_t;
struct pci_driver;
struct class_device;
extern void dgnc_create_ports_sysfiles(struct board_t *bd);
extern void dgnc_remove_ports_sysfiles(struct board_t *bd);
extern void dgnc_create_driver_sysfiles(struct pci_driver *);
extern void dgnc_remove_driver_sysfiles(struct pci_driver *);
extern int dgnc_tty_class_init(void);
extern int dgnc_tty_class_destroy(void);
extern void dgnc_create_tty_sysfs(struct un_t *un, struct device *c);
extern void dgnc_remove_tty_sysfs(struct device *c);
#endif

Просмотреть файл

@ -0,0 +1,187 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
*
* NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE!
*
* This is shared code between Digi's CVS archive and the
* Linux Kernel sources.
* Changing the source just for reformatting needlessly breaks
* our CVS diff history.
*
* Send any bug fixes/changes to: Eng.Linux at digi dot com.
* Thank you.
*
*/
/* $Id: dgnc_trace.c,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $ */
#include <linux/kernel.h>
#include <linux/version.h>
#include <linux/sched.h> /* For jiffies, task states */
#include <linux/interrupt.h> /* For tasklet and interrupt structs/defines */
#include <linux/vmalloc.h>
#include "dgnc_driver.h"
#define TRC_TO_CONSOLE 1
/* file level globals */
static char *dgnc_trcbuf; /* the ringbuffer */
#if defined(TRC_TO_KMEM)
static int dgnc_trcbufi = 0; /* index of the tilde at the end of */
#endif
#if defined(TRC_TO_KMEM)
static DEFINE_SPINLOCK(dgnc_tracef_lock);
#endif
#if 0
#if !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE)
void dgnc_tracef(const char *fmt, ...)
{
return;
}
#else /* !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) */
void dgnc_tracef(const char *fmt, ...)
{
va_list ap;
char buf[TRC_MAXMSG+1];
size_t lenbuf;
int i;
static int failed = FALSE;
# if defined(TRC_TO_KMEM)
unsigned long flags;
#endif
if(failed)
return;
# if defined(TRC_TO_KMEM)
DGNC_LOCK(dgnc_tracef_lock, flags);
#endif
/* Format buf using fmt and arguments contained in ap. */
va_start(ap, fmt);
i = vsprintf(buf, fmt, ap);
va_end(ap);
lenbuf = strlen(buf);
# if defined(TRC_TO_KMEM)
{
static int initd=0;
/*
* Now, in addition to (or instead of) printing this stuff out
* (which is a buffered operation), also tuck it away into a
* corner of memory which can be examined post-crash in kdb.
*/
if (!initd) {
dgnc_trcbuf = (char *) vmalloc(dgnc_trcbuf_size);
if(!dgnc_trcbuf) {
failed = TRUE;
printk("dgnc: tracing init failed!\n");
return;
}
memset(dgnc_trcbuf, '\0', dgnc_trcbuf_size);
dgnc_trcbufi = 0;
initd++;
printk("dgnc: tracing enabled - " TRC_DTRC
" 0x%lx 0x%x\n",
(unsigned long)dgnc_trcbuf,
dgnc_trcbuf_size);
}
# if defined(TRC_ON_OVERFLOW_WRAP_AROUND)
/*
* This is the less CPU-intensive way to do things. We simply
* wrap around before we fall off the end of the buffer. A
* tilde (~) demarcates the current end of the trace.
*
* This method should be used if you are concerned about race
* conditions as it is less likely to affect the timing of
* things.
*/
if (dgnc_trcbufi + lenbuf >= dgnc_trcbuf_size) {
/* We are wrapping, so wipe out the last tilde. */
dgnc_trcbuf[dgnc_trcbufi] = '\0';
/* put the new string at the beginning of the buffer */
dgnc_trcbufi = 0;
}
strcpy(&dgnc_trcbuf[dgnc_trcbufi], buf);
dgnc_trcbufi += lenbuf;
dgnc_trcbuf[dgnc_trcbufi] = '~';
# elif defined(TRC_ON_OVERFLOW_SHIFT_BUFFER)
/*
* This is the more CPU-intensive way to do things. If we
* venture into the last 1/8 of the buffer, we shift the
* last 7/8 of the buffer forward, wiping out the first 1/8.
* Advantage: No wrap-around, only truncation from the
* beginning.
*
* This method should not be used if you are concerned about
* timing changes affecting the behaviour of the driver (ie,
* race conditions).
*/
strcpy(&dgnc_trcbuf[dgnc_trcbufi], buf);
dgnc_trcbufi += lenbuf;
dgnc_trcbuf[dgnc_trcbufi] = '~';
dgnc_trcbuf[dgnc_trcbufi+1] = '\0';
/* If we're near the end of the trace buffer... */
if (dgnc_trcbufi > (dgnc_trcbuf_size/8)*7) {
/* Wipe out the first eighth to make some more room. */
strcpy(dgnc_trcbuf, &dgnc_trcbuf[dgnc_trcbuf_size/8]);
dgnc_trcbufi = strlen(dgnc_trcbuf)-1;
/* Plop overflow message at the top of the buffer. */
bcopy(TRC_OVERFLOW, dgnc_trcbuf, strlen(TRC_OVERFLOW));
}
# else
# error "TRC_ON_OVERFLOW_WRAP_AROUND or TRC_ON_OVERFLOW_SHIFT_BUFFER?"
# endif
}
DGNC_UNLOCK(dgnc_tracef_lock, flags);
# endif /* defined(TRC_TO_KMEM) */
}
#endif /* !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE) */
#endif
/*
* dgnc_tracer_free()
*
*
*/
void dgnc_tracer_free(void)
{
if(dgnc_trcbuf)
vfree(dgnc_trcbuf);
}

Просмотреть файл

@ -0,0 +1,45 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*
*****************************************************************************
* Header file for dgnc_trace.c
*
* $Id: dgnc_trace.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $
*/
#ifndef __DGNC_TRACE_H
#define __DGNC_TRACE_H
#include "dgnc_driver.h"
#if 0
# if !defined(TRC_TO_KMEM) && !defined(TRC_TO_CONSOLE)
void dgnc_tracef(const char *fmt, ...);
# else
void dgnc_tracef(const char *fmt, ...);
# endif
#endif
void dgnc_tracer_free(void);
#endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,42 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*/
#ifndef __DGNC_TTY_H
#define __DGNC_TTY_H
#include "dgnc_driver.h"
int dgnc_tty_register(struct board_t *brd);
int dgnc_tty_preinit(void);
int dgnc_tty_init(struct board_t *);
void dgnc_tty_post_uninit(void);
void dgnc_tty_uninit(struct board_t *);
void dgnc_input(struct channel_t *ch);
void dgnc_carrier(struct channel_t *ch);
void dgnc_wakeup_writes(struct channel_t *ch);
void dgnc_check_queue_flow_control(struct channel_t *ch);
void dgnc_sniff_nowait_nolock(struct channel_t *ch, uchar *text, uchar *buf, int nbuf);
#endif

Просмотреть файл

@ -0,0 +1,36 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*/
#ifndef __DGNC_TYPES_H
#define __DGNC_TYPES_H
#ifndef TRUE
# define TRUE 1
#endif
#ifndef FALSE
# define FALSE 0
#endif
/* Required for our shared headers! */
typedef unsigned char uchar;
#endif

419
drivers/staging/dgnc/digi.h Normal file
Просмотреть файл

@ -0,0 +1,419 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* $Id: digi.h,v 1.1.1.1 2009/05/20 12:19:19 markh Exp $
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*/
#ifndef __DIGI_H
#define __DIGI_H
/************************************************************************
*** Definitions for Digi ditty(1) command.
************************************************************************/
/*
* Copyright (c) 1988-96 Digi International Inc., All Rights Reserved.
*/
/************************************************************************
* This module provides application access to special Digi
* serial line enhancements which are not standard UNIX(tm) features.
************************************************************************/
#if !defined(TIOCMODG)
#define TIOCMODG ('d'<<8) | 250 /* get modem ctrl state */
#define TIOCMODS ('d'<<8) | 251 /* set modem ctrl state */
#ifndef TIOCM_LE
#define TIOCM_LE 0x01 /* line enable */
#define TIOCM_DTR 0x02 /* data terminal ready */
#define TIOCM_RTS 0x04 /* request to send */
#define TIOCM_ST 0x08 /* secondary transmit */
#define TIOCM_SR 0x10 /* secondary receive */
#define TIOCM_CTS 0x20 /* clear to send */
#define TIOCM_CAR 0x40 /* carrier detect */
#define TIOCM_RNG 0x80 /* ring indicator */
#define TIOCM_DSR 0x100 /* data set ready */
#define TIOCM_RI TIOCM_RNG /* ring (alternate) */
#define TIOCM_CD TIOCM_CAR /* carrier detect (alt) */
#endif
#endif
#if !defined(TIOCMSET)
#define TIOCMSET ('d'<<8) | 252 /* set modem ctrl state */
#define TIOCMGET ('d'<<8) | 253 /* set modem ctrl state */
#endif
#if !defined(TIOCMBIC)
#define TIOCMBIC ('d'<<8) | 254 /* set modem ctrl state */
#define TIOCMBIS ('d'<<8) | 255 /* set modem ctrl state */
#endif
#if !defined(TIOCSDTR)
#define TIOCSDTR ('e'<<8) | 0 /* set DTR */
#define TIOCCDTR ('e'<<8) | 1 /* clear DTR */
#endif
/************************************************************************
* Ioctl command arguments for DIGI parameters.
************************************************************************/
#define DIGI_GETA ('e'<<8) | 94 /* Read params */
#define DIGI_SETA ('e'<<8) | 95 /* Set params */
#define DIGI_SETAW ('e'<<8) | 96 /* Drain & set params */
#define DIGI_SETAF ('e'<<8) | 97 /* Drain, flush & set params */
#define DIGI_KME ('e'<<8) | 98 /* Read/Write Host */
/* Adapter Memory */
#define DIGI_GETFLOW ('e'<<8) | 99 /* Get startc/stopc flow */
/* control characters */
#define DIGI_SETFLOW ('e'<<8) | 100 /* Set startc/stopc flow */
/* control characters */
#define DIGI_GETAFLOW ('e'<<8) | 101 /* Get Aux. startc/stopc */
/* flow control chars */
#define DIGI_SETAFLOW ('e'<<8) | 102 /* Set Aux. startc/stopc */
/* flow control chars */
#define DIGI_GEDELAY ('d'<<8) | 246 /* Get edelay */
#define DIGI_SEDELAY ('d'<<8) | 247 /* Set edelay */
struct digiflow_t {
unsigned char startc; /* flow cntl start char */
unsigned char stopc; /* flow cntl stop char */
};
#ifdef FLOW_2200
#define F2200_GETA ('e'<<8) | 104 /* Get 2x36 flow cntl flags */
#define F2200_SETAW ('e'<<8) | 105 /* Set 2x36 flow cntl flags */
#define F2200_MASK 0x03 /* 2200 flow cntl bit mask */
#define FCNTL_2200 0x01 /* 2x36 terminal flow cntl */
#define PCNTL_2200 0x02 /* 2x36 printer flow cntl */
#define F2200_XON 0xf8
#define P2200_XON 0xf9
#define F2200_XOFF 0xfa
#define P2200_XOFF 0xfb
#define FXOFF_MASK 0x03 /* 2200 flow status mask */
#define RCVD_FXOFF 0x01 /* 2x36 Terminal XOFF rcvd */
#define RCVD_PXOFF 0x02 /* 2x36 Printer XOFF rcvd */
#endif
/************************************************************************
* Values for digi_flags
************************************************************************/
#define DIGI_IXON 0x0001 /* Handle IXON in the FEP */
#define DIGI_FAST 0x0002 /* Fast baud rates */
#define RTSPACE 0x0004 /* RTS input flow control */
#define CTSPACE 0x0008 /* CTS output flow control */
#define DSRPACE 0x0010 /* DSR output flow control */
#define DCDPACE 0x0020 /* DCD output flow control */
#define DTRPACE 0x0040 /* DTR input flow control */
#define DIGI_COOK 0x0080 /* Cooked processing done in FEP */
#define DIGI_FORCEDCD 0x0100 /* Force carrier */
#define DIGI_ALTPIN 0x0200 /* Alternate RJ-45 pin config */
#define DIGI_AIXON 0x0400 /* Aux flow control in fep */
#define DIGI_PRINTER 0x0800 /* Hold port open for flow cntrl*/
#define DIGI_PP_INPUT 0x1000 /* Change parallel port to input*/
#define DIGI_DTR_TOGGLE 0x2000 /* Support DTR Toggle */
#define DIGI_422 0x4000 /* for 422/232 selectable panel */
#define DIGI_RTS_TOGGLE 0x8000 /* Support RTS Toggle */
/************************************************************************
* These options are not supported on the comxi.
************************************************************************/
#define DIGI_COMXI (DIGI_FAST|DIGI_COOK|DSRPACE|DCDPACE|DTRPACE)
#define DIGI_PLEN 28 /* String length */
#define DIGI_TSIZ 10 /* Terminal string len */
/************************************************************************
* Structure used with ioctl commands for DIGI parameters.
************************************************************************/
struct digi_t {
unsigned short digi_flags; /* Flags (see above) */
unsigned short digi_maxcps; /* Max printer CPS */
unsigned short digi_maxchar; /* Max chars in print queue */
unsigned short digi_bufsize; /* Buffer size */
unsigned char digi_onlen; /* Length of ON string */
unsigned char digi_offlen; /* Length of OFF string */
char digi_onstr[DIGI_PLEN]; /* Printer on string */
char digi_offstr[DIGI_PLEN]; /* Printer off string */
char digi_term[DIGI_TSIZ]; /* terminal string */
};
/************************************************************************
* KME definitions and structures.
************************************************************************/
#define RW_IDLE 0 /* Operation complete */
#define RW_READ 1 /* Read Concentrator Memory */
#define RW_WRITE 2 /* Write Concentrator Memory */
struct rw_t {
unsigned char rw_req; /* Request type */
unsigned char rw_board; /* Host Adapter board number */
unsigned char rw_conc; /* Concentrator number */
unsigned char rw_reserved; /* Reserved for expansion */
unsigned int rw_addr; /* Address in concentrator */
unsigned short rw_size; /* Read/write request length */
unsigned char rw_data[128]; /* Data to read/write */
};
/***********************************************************************
* Shrink Buffer and Board Information definitions and structures.
************************************************************************/
/* Board type return codes */
#define PCXI_TYPE 1 /* Board type at the designated port is a PC/Xi */
#define PCXM_TYPE 2 /* Board type at the designated port is a PC/Xm */
#define PCXE_TYPE 3 /* Board type at the designated port is a PC/Xe */
#define MCXI_TYPE 4 /* Board type at the designated port is a MC/Xi */
#define COMXI_TYPE 5 /* Board type at the designated port is a COM/Xi */
/* Non-Zero Result codes. */
#define RESULT_NOBDFND 1 /* A Digi product at that port is not config installed */
#define RESULT_NODESCT 2 /* A memory descriptor was not obtainable */
#define RESULT_NOOSSIG 3 /* FEP/OS signature was not detected on the board */
#define RESULT_TOOSML 4 /* Too small an area to shrink. */
#define RESULT_NOCHAN 5 /* Channel structure for the board was not found */
struct shrink_buf_struct {
unsigned int shrink_buf_vaddr; /* Virtual address of board */
unsigned int shrink_buf_phys; /* Physical address of board */
unsigned int shrink_buf_bseg; /* Amount of board memory */
unsigned int shrink_buf_hseg; /* '186 Begining of Dual-Port */
unsigned int shrink_buf_lseg; /* '186 Begining of freed memory */
unsigned int shrink_buf_mseg; /* Linear address from start of
dual-port were freed memory
begins, host viewpoint. */
unsigned int shrink_buf_bdparam; /* Parameter for xxmemon and
xxmemoff */
unsigned int shrink_buf_reserva; /* Reserved */
unsigned int shrink_buf_reservb; /* Reserved */
unsigned int shrink_buf_reservc; /* Reserved */
unsigned int shrink_buf_reservd; /* Reserved */
unsigned char shrink_buf_result; /* Reason for call failing
Zero is Good return */
unsigned char shrink_buf_init; /* Non-Zero if it caused an
xxinit call. */
unsigned char shrink_buf_anports; /* Number of async ports */
unsigned char shrink_buf_snports; /* Number of sync ports */
unsigned char shrink_buf_type; /* Board type 1 = PC/Xi,
2 = PC/Xm,
3 = PC/Xe
4 = MC/Xi
5 = COMX/i */
unsigned char shrink_buf_card; /* Card number */
};
/************************************************************************
* Structure to get driver status information
************************************************************************/
struct digi_dinfo {
unsigned int dinfo_nboards; /* # boards configured */
char dinfo_reserved[12]; /* for future expansion */
char dinfo_version[16]; /* driver version */
};
#define DIGI_GETDD ('d'<<8) | 248 /* get driver info */
/************************************************************************
* Structure used with ioctl commands for per-board information
*
* physsize and memsize differ when board has "windowed" memory
************************************************************************/
struct digi_info {
unsigned int info_bdnum; /* Board number (0 based) */
unsigned int info_ioport; /* io port address */
unsigned int info_physaddr; /* memory address */
unsigned int info_physsize; /* Size of host mem window */
unsigned int info_memsize; /* Amount of dual-port mem */
/* on board */
unsigned short info_bdtype; /* Board type */
unsigned short info_nports; /* number of ports */
char info_bdstate; /* board state */
char info_reserved[7]; /* for future expansion */
};
#define DIGI_GETBD ('d'<<8) | 249 /* get board info */
struct digi_stat {
unsigned int info_chan; /* Channel number (0 based) */
unsigned int info_brd; /* Board number (0 based) */
unsigned int info_cflag; /* cflag for channel */
unsigned int info_iflag; /* iflag for channel */
unsigned int info_oflag; /* oflag for channel */
unsigned int info_mstat; /* mstat for channel */
unsigned int info_tx_data; /* tx_data for channel */
unsigned int info_rx_data; /* rx_data for channel */
unsigned int info_hflow; /* hflow for channel */
unsigned int info_reserved[8]; /* for future expansion */
};
#define DIGI_GETSTAT ('d'<<8) | 244 /* get board info */
/************************************************************************
*
* Structure used with ioctl commands for per-channel information
*
************************************************************************/
struct digi_ch {
unsigned int info_bdnum; /* Board number (0 based) */
unsigned int info_channel; /* Channel index number */
unsigned int info_ch_cflag; /* Channel cflag */
unsigned int info_ch_iflag; /* Channel iflag */
unsigned int info_ch_oflag; /* Channel oflag */
unsigned int info_chsize; /* Channel structure size */
unsigned int info_sleep_stat; /* sleep status */
dev_t info_dev; /* device number */
unsigned char info_initstate; /* Channel init state */
unsigned char info_running; /* Channel running state */
int reserved[8]; /* reserved for future use */
};
/*
* This structure is used with the DIGI_FEPCMD ioctl to
* tell the driver which port to send the command for.
*/
struct digi_cmd {
int cmd;
int word;
int ncmds;
int chan; /* channel index (zero based) */
int bdid; /* board index (zero based) */
};
struct digi_getbuffer /* Struct for holding buffer use counts */
{
unsigned long tIn;
unsigned long tOut;
unsigned long rxbuf;
unsigned long txbuf;
unsigned long txdone;
};
struct digi_getcounter
{
unsigned long norun; /* number of UART overrun errors */
unsigned long noflow; /* number of buffer overflow errors */
unsigned long nframe; /* number of framing errors */
unsigned long nparity; /* number of parity errors */
unsigned long nbreak; /* number of breaks received */
unsigned long rbytes; /* number of received bytes */
unsigned long tbytes; /* number of bytes transmitted fully */
};
/*
* info_sleep_stat defines
*/
#define INFO_RUNWAIT 0x0001
#define INFO_WOPEN 0x0002
#define INFO_TTIOW 0x0004
#define INFO_CH_RWAIT 0x0008
#define INFO_CH_WEMPTY 0x0010
#define INFO_CH_WLOW 0x0020
#define INFO_XXBUF_BUSY 0x0040
#define DIGI_GETCH ('d'<<8) | 245 /* get board info */
/* Board type definitions */
#define SUBTYPE 0007
#define T_PCXI 0000
#define T_PCXM 0001
#define T_PCXE 0002
#define T_PCXR 0003
#define T_SP 0004
#define T_SP_PLUS 0005
# define T_HERC 0000
# define T_HOU 0001
# define T_LON 0002
# define T_CHA 0003
#define FAMILY 0070
#define T_COMXI 0000
#define T_PCXX 0010
#define T_CX 0020
#define T_EPC 0030
#define T_PCLITE 0040
#define T_SPXX 0050
#define T_AVXX 0060
#define T_DXB 0070
#define T_A2K_4_8 0070
#define BUSTYPE 0700
#define T_ISABUS 0000
#define T_MCBUS 0100
#define T_EISABUS 0200
#define T_PCIBUS 0400
/* Board State Definitions */
#define BD_RUNNING 0x0
#define BD_REASON 0x7f
#define BD_NOTFOUND 0x1
#define BD_NOIOPORT 0x2
#define BD_NOMEM 0x3
#define BD_NOBIOS 0x4
#define BD_NOFEP 0x5
#define BD_FAILED 0x6
#define BD_ALLOCATED 0x7
#define BD_TRIBOOT 0x8
#define BD_BADKME 0x80
#define DIGI_SPOLL ('d'<<8) | 254 /* change poller rate */
#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */
#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */
#define DIGI_REALPORT_GETBUFFERS ('e'<<8 ) | 108
#define DIGI_REALPORT_SENDIMMEDIATE ('e'<<8 ) | 109
#define DIGI_REALPORT_GETCOUNTERS ('e'<<8 ) | 110
#define DIGI_REALPORT_GETEVENTS ('e'<<8 ) | 111
#define EV_OPU 0x0001 //!<Output paused by client
#define EV_OPS 0x0002 //!<Output paused by reqular sw flowctrl
#define EV_OPX 0x0004 //!<Output paused by extra sw flowctrl
#define EV_OPH 0x0008 //!<Output paused by hw flowctrl
#define EV_OPT 0x0800 //!<Output paused for RTS Toggle predelay
#define EV_IPU 0x0010 //!<Input paused unconditionally by user
#define EV_IPS 0x0020 //!<Input paused by high/low water marks
//#define EV_IPH 0x0040 //!<Input paused w/ hardware
#define EV_IPA 0x0400 //!<Input paused by pattern alarm module
#define EV_TXB 0x0040 //!<Transmit break pending
#define EV_TXI 0x0080 //!<Transmit immediate pending
#define EV_TXF 0x0100 //!<Transmit flowctrl char pending
#define EV_RXB 0x0200 //!<Break received
#define EV_OPALL 0x080f //!<Output pause flags
#define EV_IPALL 0x0430 //!<Input pause flags
#endif /* DIGI_H */

Просмотреть файл

@ -0,0 +1,115 @@
/*
* Copyright 2003 Digi International (www.digi.com)
* Scott H Kilau <Scott_Kilau at digi dot com>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; 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.
*
* NOTE: THIS IS A SHARED HEADER. DO NOT CHANGE CODING STYLE!!!
*/
/*
* This structure holds data needed for the intelligent <--> nonintelligent
* DPA translation
*/
struct ni_info {
int board;
int channel;
int dtr;
int rts;
int cts;
int dsr;
int ri;
int dcd;
int curtx;
int currx;
unsigned short iflag;
unsigned short oflag;
unsigned short cflag;
unsigned short lflag;
unsigned int mstat;
unsigned char hflow;
unsigned char xmit_stopped;
unsigned char recv_stopped;
unsigned int baud;
};
#define RW_READ 1
#define RW_WRITE 2
#define DIGI_KME ('e'<<8) | 98 /* Read/Write Host */
#define SUBTYPE 0007
#define T_PCXI 0000
#define T_PCXEM 0001
#define T_PCXE 0002
#define T_PCXR 0003
#define T_SP 0004
#define T_SP_PLUS 0005
#define T_HERC 0000
#define T_HOU 0001
#define T_LON 0002
#define T_CHA 0003
#define T_NEO 0000
#define T_NEO_EXPRESS 0001
#define T_CLASSIC 0002
#define FAMILY 0070
#define T_COMXI 0000
#define T_NI 0000
#define T_PCXX 0010
#define T_CX 0020
#define T_EPC 0030
#define T_PCLITE 0040
#define T_SPXX 0050
#define T_AVXX 0060
#define T_DXB 0070
#define T_A2K_4_8 0070
#define BUSTYPE 0700
#define T_ISABUS 0000
#define T_MCBUS 0100
#define T_EISABUS 0200
#define T_PCIBUS 0400
/* Board State Definitions */
#define BD_RUNNING 0x0
#define BD_REASON 0x7f
#define BD_NOTFOUND 0x1
#define BD_NOIOPORT 0x2
#define BD_NOMEM 0x3
#define BD_NOBIOS 0x4
#define BD_NOFEP 0x5
#define BD_FAILED 0x6
#define BD_ALLOCATED 0x7
#define BD_TRIBOOT 0x8
#define BD_BADKME 0x80
#define DIGI_AIXON 0x0400 /* Aux flow control in fep */
/* Ioctls needed for dpa operation */
#define DIGI_GETDD ('d'<<8) | 248 /* get driver info */
#define DIGI_GETBD ('d'<<8) | 249 /* get board info */
#define DIGI_GET_NI_INFO ('d'<<8) | 250 /* nonintelligent state snfo */
/* Other special ioctls */
#define DIGI_TIMERIRQ ('d'<<8) | 251 /* Enable/disable RS_TIMER use */
#define DIGI_LOOPBACK ('d'<<8) | 252 /* Enable/disable UART internal loopback */