cyclades.c

来自「linux 内核源代码」· C语言 代码 · 共 2,048 行 · 第 1/5 页

C
2,048
字号
 * add missing break in modem control block in ioctl switch statement * (discovered by Michael Edward Chastain <mec@jobe.shell.portal.com>); * * Revision 1.36.1.2  1995/03/22  19:16:22  bentson * make sure CTS flow control is set as soon as possible (thanks * to note from David Lambert <lambert@chesapeake.rps.slb.com>); * * Revision 1.36.1.1  1995/03/13  15:44:43  bentson * initialize defaults for receive threshold and stale data timeout; * cosmetic changes; * * Revision 1.36  1995/03/10  23:33:53  bentson * added support of chips 4-7 in 32 port Cyclom-Ye; * fix cy_interrupt pointer dereference problem * (Joe Portman <baron@aa.net>); * give better error response if open is attempted on non-existent port * (Zachariah Vaum <jchryslr@netcom.com>); * correct command timeout (Kenneth Lerman <lerman@@seltd.newnet.com>); * conditional compilation for -16Y on systems with fast, noisy bus; * comment out diagnostic print function; * cleaned up table of base addresses; * set receiver time-out period register to correct value, * set receive threshold to better default values, * set chip timer to more accurate 200 Hz ticking, * add code to monitor and modify receive parameters * (Rik Faith <faith@cs.unc.edu> Nick Simicich * <njs@scifi.emi.net>); * * Revision 1.35  1994/12/16  13:54:18  steffen * additional patch by Marcio Saito for board detection * Accidently left out in 1.34 * * Revision 1.34  1994/12/10  12:37:12  steffen * This is the corrected version as suggested by Marcio Saito * * Revision 1.33  1994/12/01  22:41:18  bentson * add hooks to support more high speeds directly; add tytso * patch regarding CLOCAL wakeups * * Revision 1.32  1994/11/23  19:50:04  bentson * allow direct kernel control of higher signalling rates; * look for cards at additional locations * * Revision 1.31  1994/11/16  04:33:28  bentson * ANOTHER fix from Corey Minyard, minyard@wf-rch.cirr.com-- * a problem in chars_in_buffer has been resolved by some * small changes;  this should yield smoother output * * Revision 1.30  1994/11/16  04:28:05  bentson * Fix from Corey Minyard, Internet: minyard@metronet.com, * UUCP: minyard@wf-rch.cirr.com, WORK: minyardbnr.ca, to * cy_hangup that appears to clear up much (all?) of the * DTR glitches; also he's added/cleaned-up diagnostic messages * * Revision 1.29  1994/11/16  04:16:07  bentson * add change proposed by Ralph Sims, ralphs@halcyon.com, to * operate higher speeds in same way as other serial ports; * add more serial ports (for up to two 16-port muxes). * * Revision 1.28  1994/11/04  00:13:16  root * turn off diagnostic messages * * Revision 1.27  1994/11/03  23:46:37  root * bunch of changes to bring driver into greater conformance * with the serial.c driver (looking for missed fixes) * * Revision 1.26  1994/11/03  22:40:36  root * automatic interrupt probing fixed. * * Revision 1.25  1994/11/03  20:17:02  root * start to implement auto-irq * * Revision 1.24  1994/11/03  18:01:55  root * still working on modem signals--trying not to drop DTR * during the getty/login processes * * Revision 1.23  1994/11/03  17:51:36  root * extend baud rate support; set receive threshold as function * of baud rate; fix some problems with RTS/CTS; * * Revision 1.22  1994/11/02  18:05:35  root * changed arguments to udelay to type long to get * delays to be of correct duration * * Revision 1.21  1994/11/02  17:37:30  root * employ udelay (after calibrating loops_per_second earlier * in init/main.c) instead of using home-grown delay routines * * Revision 1.20  1994/11/02  03:11:38  root * cy_chars_in_buffer forces a return value of 0 to let * login work (don't know why it does); some functions * that were returning EFAULT, now executes the code; * more work on deciding when to disable xmit interrupts; * * Revision 1.19  1994/11/01  20:10:14  root * define routine to start transmission interrupts (by enabling * transmit interrupts); directly enable/disable modem interrupts; * * Revision 1.18  1994/11/01  18:40:45  bentson * Don't always enable transmit interrupts in startup; interrupt on * TxMpty instead of TxRdy to help characters get out before shutdown; * restructure xmit interrupt to check for chars first and quit if * none are ready to go; modem status (MXVRx) is upright, _not_ inverted * (to my view); * * Revision 1.17  1994/10/30  04:39:45  bentson * rename serial_driver and callout_driver to cy_serial_driver and * cy_callout_driver to avoid linkage interference; initialize * info->type to PORT_CIRRUS; ruggedize paranoia test; elide ->port * from cyclades_port structure; add paranoia check to cy_close; * * Revision 1.16  1994/10/30  01:14:33  bentson * change major numbers; add some _early_ return statements; * * Revision 1.15  1994/10/29  06:43:15  bentson * final tidying up for clean compile;  enable some error reporting * * Revision 1.14  1994/10/28  20:30:22  Bentson * lots of changes to drag the driver towards the new tty_io * structures and operation.  not expected to work, but may * compile cleanly. * * Revision 1.13  1994/07/21  23:08:57  Bentson * add some diagnostic cruft; support 24 lines (for testing * both -8Y and -16Y cards; be more thorough in servicing all * chips during interrupt; add "volatile" a few places to * circumvent compiler optimizations; fix base & offset * computations in block_til_ready (was causing chip 0 to * stop operation) * * Revision 1.12  1994/07/19  16:42:11  Bentson * add some hackery for kernel version 1.1.8; expand * error messages; refine timing for delay loops and * declare loop params volatile * * Revision 1.11  1994/06/11  21:53:10  bentson * get use of save_car right in transmit interrupt service * * Revision 1.10.1.1  1994/06/11  21:31:18  bentson * add some diagnostic printing; try to fix save_car stuff * * Revision 1.10  1994/06/11  20:36:08  bentson * clean up compiler warnings * * Revision 1.9  1994/06/11  19:42:46  bentson * added a bunch of code to support modem signalling * * Revision 1.8  1994/06/11  17:57:07  bentson * recognize break & parity error * * Revision 1.7  1994/06/05  05:51:34  bentson * Reorder baud table to be monotonic; add cli to CP; discard * incoming characters and status if the line isn't open; start to * fold code into cy_throttle; start to port get_serial_info, * set_serial_info, get_modem_info, set_modem_info, and send_break * from serial.c; expand cy_ioctl; relocate and expand config_setup; * get flow control characters from tty struct; invalidate ports w/o * hardware; * * Revision 1.6  1994/05/31  18:42:21  bentson * add a loop-breaker in the interrupt service routine; * note when port is initialized so that it can be shut * down under the right conditions; receive works without * any obvious errors * * Revision 1.5  1994/05/30  00:55:02  bentson * transmit works without obvious errors * * Revision 1.4  1994/05/27  18:46:27  bentson * incorporated more code from lib_y.c; can now print short * strings under interrupt control to port zero; seems to * select ports/channels/lines correctly * * Revision 1.3  1994/05/25  22:12:44  bentson * shifting from multi-port on a card to proper multiplexor * data structures;  added skeletons of most routines * * Revision 1.2  1994/05/19  13:21:43  bentson * start to crib from other sources * */#define CY_VERSION	"2.5"/* If you need to install more boards than NR_CARDS, change the constant   in the definition below. No other change is necessary to support up to   eight boards. Beyond that you'll have to extend cy_isa_addresses. */#define NR_CARDS	4/*   If the total number of ports is larger than NR_PORTS, change this   constant in the definition below. No other change is necessary to   support more boards/ports. */#define NR_PORTS	256#define ZE_V1_NPORTS	64#define ZO_V1	0#define ZO_V2	1#define ZE_V1	2#define	SERIAL_PARANOIA_CHECK#undef	CY_DEBUG_OPEN#undef	CY_DEBUG_THROTTLE#undef	CY_DEBUG_OTHER#undef	CY_DEBUG_IO#undef	CY_DEBUG_COUNT#undef	CY_DEBUG_DTR#undef	CY_DEBUG_WAIT_UNTIL_SENT#undef	CY_DEBUG_INTERRUPTS#undef	CY_16Y_HACK#undef	CY_ENABLE_MONITORING#undef	CY_PCI_DEBUG/* * Include section  */#include <linux/module.h>#include <linux/errno.h>#include <linux/signal.h>#include <linux/sched.h>#include <linux/timer.h>#include <linux/interrupt.h>#include <linux/tty.h>#include <linux/tty_flip.h>#include <linux/serial.h>#include <linux/major.h>#include <linux/string.h>#include <linux/fcntl.h>#include <linux/ptrace.h>#include <linux/cyclades.h>#include <linux/mm.h>#include <linux/ioport.h>#include <linux/init.h>#include <linux/delay.h>#include <linux/spinlock.h>#include <linux/bitops.h>#include <linux/firmware.h>#include <asm/system.h>#include <asm/io.h>#include <asm/irq.h>#include <asm/uaccess.h>#include <linux/kernel.h>#include <linux/pci.h>#include <linux/stat.h>#include <linux/proc_fs.h>static void cy_throttle(struct tty_struct *tty);static void cy_send_xchar(struct tty_struct *tty, char ch);#define IS_CYC_Z(card) ((card).num_chips == (unsigned int)-1)#define Z_FPGA_CHECK(card) \	((readl(&((struct RUNTIME_9060 __iomem *) \		((card).ctl_addr))->init_ctrl) & (1<<17)) != 0)#define ISZLOADED(card)	(((ZO_V1==readl(&((struct RUNTIME_9060 __iomem *) \			((card).ctl_addr))->mail_box_0)) || \			Z_FPGA_CHECK(card)) && \			(ZFIRM_ID==readl(&((struct FIRM_ID __iomem *) \			((card).base_addr+ID_ADDRESS))->signature)))#ifndef SERIAL_XMIT_SIZE#define	SERIAL_XMIT_SIZE	(min(PAGE_SIZE, 4096))#endif#define WAKEUP_CHARS		256#define STD_COM_FLAGS (0)/* firmware stuff */#define ZL_MAX_BLOCKS	16#define DRIVER_VERSION	0x02010203#define RAM_SIZE 0x80000#define Z_FPGA_LOADED(X)	((readl(&(X)->init_ctrl) & (1<<17)) != 0)enum zblock_type {	ZBLOCK_PRG = 0,	ZBLOCK_FPGA = 1};struct zfile_header {	char name[64];	char date[32];	char aux[32];	u32 n_config;	u32 config_offset;	u32 n_blocks;	u32 block_offset;	u32 reserved[9];} __attribute__ ((packed));struct zfile_config {	char name[64];	u32 mailbox;	u32 function;	u32 n_blocks;	u32 block_list[ZL_MAX_BLOCKS];} __attribute__ ((packed));struct zfile_block {	u32 type;	u32 file_offset;	u32 ram_offset;	u32 size;} __attribute__ ((packed));static struct tty_driver *cy_serial_driver;#ifdef CONFIG_ISA/* This is the address lookup table. The driver will probe for   Cyclom-Y/ISA boards at all addresses in here. If you want the   driver to probe addresses at a different address, add it to   this table.  If the driver is probing some other board and   causing problems, remove the offending address from this table.*/static unsigned int cy_isa_addresses[] = {	0xD0000,	0xD2000,	0xD4000,	0xD6000,	0xD8000,	0xDA000,	0xDC000,	0xDE000,	0, 0, 0, 0, 0, 0, 0, 0};#define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses)#ifdef MODULEstatic long maddr[NR_CARDS];static int irq[NR_CARDS];module_param_array(maddr, long, NULL, 0);module_param_array(irq, int, NULL, 0);#endif#endif				/* CONFIG_ISA *//* This is the per-card data structure containing address, irq, number of   channels, etc. This driver supports a maximum of NR_CARDS cards.*/static struct cyclades_card cy_card[NR_CARDS];static int cy_next_channel;	/* next minor available *//* * This is used to look up the divisor speeds and the timeouts * We're normally limited to 15 distinct baud rates.  The extra * are accessed via settings in info->flags. *      0,     1,     2,     3,     4,     5,     6,     7,     8,     9, *     10,    11,    12,    13,    14,    15,    16,    17,    18,    19, *                                               HI            VHI *     20 */static int baud_table[] = {	0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,	1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 150000,	230400, 0};static char baud_co_25[] = {	/* 25 MHz clock option table */	/* value =>    00    01   02    03    04 */	/* divide by    8    32   128   512  2048 */	0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,	0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};static char baud_bpr_25[] = {	/* 25 MHz baud rate period table */	0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,	0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15};static char baud_co_60[] = {	/* 60 MHz clock option table (CD1400 J) */	/* value =>    00    01   02    03    04 */	/* divide by    8    32   128   512  2048 */	0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03,	0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,	0x00};static char baud_bpr_60[] = {	/* 60 MHz baud rate period table (CD1400 J) */	0x00, 0x82, 0x21, 0xff, 0xdb, 0xc3, 0x92, 0x62, 0xc3, 0x62,	0x41, 0xc3, 0x62, 0xc3, 0x62, 0xc3, 0x82, 0x62, 0x41, 0x32,	0x21};static char baud_cor3[] = {	/* receive threshold */	0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,	0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07,	0x07};/* * The Cyclades driver implements HW flow control as any serial driver. * The cyclades_port structure member rflow and the vector rflow_thr  * allows us to take advantage of a special feature in the CD1400 to avoid  * data loss even when the system interrupt latency is too high. These flags  * are to be used only with very special applications. Setting these flags  * requires the use of a special cable (DTR and RTS reversed). In the new  * CD1400-based boards (rev. 6.00 or later), there is no need for special  * cables. */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?