1 /*********************************************************************
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Fri Nov 13 14:37:40 1998
9 * Modified at: Sun Jan 23 17:47:00 2000
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (c) 1998-2000 Dag Brattli <dagb@cs.uit.no>
13 * Copyright (c) 1998 Lichen Wang, <lwang@actisys.com>
14 * Copyright (c) 1998 Actisys Corp., www.actisys.com
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 * Neither Dag Brattli nor University of Tromsø admit liability nor
23 * provide warranty for any of this software. This material is
24 * provided "AS-IS" and at no charge.
26 ********************************************************************/
31 #include <linux/time.h>
33 #include <linux/spinlock.h>
37 /* DMA modes needed */
38 #define DMA_TX_MODE 0x08 /* Mem to I/O, ++, demand. */
39 #define DMA_RX_MODE 0x04 /* I/O to mem, ++, demand. */
41 /* Config registers for the '108 */
42 #define CFG_108_BAIC 0x00
43 #define CFG_108_CSRT 0x01
44 #define CFG_108_MCTL 0x02
46 /* Config registers for the '338 */
47 #define CFG_338_FER 0x00
48 #define CFG_338_FAR 0x01
49 #define CFG_338_PTR 0x02
50 #define CFG_338_PNP0 0x1b
51 #define CFG_338_PNP1 0x1c
52 #define CFG_338_PNP3 0x4f
54 /* Config registers for the '39x (in the logical device bank) */
55 #define CFG_39X_LDN 0x07 /* Logical device number (Super I/O bank) */
56 #define CFG_39X_SIOCF1 0x21 /* SuperI/O Config */
57 #define CFG_39X_ACT 0x30 /* Device activation */
58 #define CFG_39X_BASEH 0x60 /* Device base address (high bits) */
59 #define CFG_39X_BASEL 0x61 /* Device base address (low bits) */
60 #define CFG_39X_IRQNUM 0x70 /* Interrupt number & wake up enable */
61 #define CFG_39X_IRQSEL 0x71 /* Interrupt select (edge/level + polarity) */
62 #define CFG_39X_DMA0 0x74 /* DMA 0 configuration */
63 #define CFG_39X_DMA1 0x75 /* DMA 1 configuration */
64 #define CFG_39X_SPC 0xF0 /* Serial port configuration register */
66 /* Flags for configuration register CRF0 */
71 #define TXD 0x00 /* Transmit data port */
72 #define RXD 0x00 /* Receive data port */
75 #define IER 0x01 /* Interrupt Enable Register*/
76 #define IER_RXHDL_IE 0x01 /* Receiver high data level interrupt */
77 #define IER_TXLDL_IE 0x02 /* Transeiver low data level interrupt */
78 #define IER_LS_IE 0x04//* Link Status Interrupt */
79 #define IER_ETXURI 0x04 /* Tx underrun */
80 #define IER_DMA_IE 0x10 /* DMA finished interrupt */
81 #define IER_TXEMP_IE 0x20
82 #define IER_SFIF_IE 0x40 /* Frame status FIFO intr */
83 #define IER_TMR_IE 0x80 /* Timer event */
85 #define FCR 0x02 /* (write only) */
86 #define FCR_FIFO_EN 0x01 /* Enable FIFO's */
87 #define FCR_RXSR 0x02 /* Rx FIFO soft reset */
88 #define FCR_TXSR 0x04 /* Tx FIFO soft reset */
89 #define FCR_RXTH 0x40 /* Rx FIFO threshold (set to 16) */
90 #define FCR_TXTH 0x20 /* Tx FIFO threshold (set to 17) */
92 #define EIR 0x02 /* (read only) */
93 #define EIR_RXHDL_EV 0x01
94 #define EIR_TXLDL_EV 0x02
95 #define EIR_LS_EV 0x04
96 #define EIR_DMA_EV 0x10
97 #define EIR_TXEMP_EV 0x20
98 #define EIR_SFIF_EV 0x40
99 #define EIR_TMR_EV 0x80
101 #define LCR 0x03 /* Link control register */
102 #define LCR_WLS_8 0x03 /* 8 bits */
104 #define BSR 0x03 /* Bank select register */
105 #define BSR_BKSE 0x80
106 #define BANK0 LCR_WLS_8 /* Must make sure that we set 8N1 */
115 #define MCR 0x04 /* Mode Control Register */
116 #define MCR_MODE_MASK ~(0xd0)
117 #define MCR_UART 0x00
118 #define MCR_RESERVED 0x20
119 #define MCR_SHARP_IR 0x40
123 #define MCR_CEIR 0xb0
124 #define MCR_IR_PLS 0x10
125 #define MCR_DMA_EN 0x04
126 #define MCR_EN_IRQ 0x08
127 #define MCR_TX_DFR 0x08
129 #define LSR 0x05 /* Link status register */
130 #define LSR_RXDA 0x01 /* Receiver data available */
131 #define LSR_TXRDY 0x20 /* Transmitter ready */
132 #define LSR_TXEMP 0x40 /* Transmitter empty */
134 #define ASCR 0x07 /* Auxillary Status and Control Register */
135 #define ASCR_RXF_TOUT 0x01 /* Rx FIFO timeout */
136 #define ASCR_FEND_INF 0x02 /* Frame end bytes in rx FIFO */
137 #define ASCR_S_EOT 0x04 /* Set end of transmission */
138 #define ASCT_RXBSY 0x20 /* Rx busy */
139 #define ASCR_TXUR 0x40 /* Transeiver underrun */
140 #define ASCR_CTE 0x80 /* Clear timer event */
143 #define BGDL 0x00 /* Baud Generator Divisor Port (Low Byte) */
144 #define BGDH 0x01 /* Baud Generator Divisor Port (High Byte) */
146 #define ECR1 0x02 /* Extended Control Register 1 */
147 #define ECR1_EXT_SL 0x01 /* Extended Mode Select */
148 #define ECR1_DMANF 0x02 /* DMA Fairness */
149 #define ECR1_DMATH 0x04 /* DMA Threshold */
150 #define ECR1_DMASWP 0x08 /* DMA Swap */
153 #define EXCR2_TFSIZ 0x01 /* Rx FIFO size = 32 */
154 #define EXCR2_RFSIZ 0x04 /* Tx FIFO size = 32 */
156 #define TXFLV 0x06 /* Tx FIFO level */
157 #define RXFLV 0x07 /* Rx FIFO level */
163 #define TMRL 0x00 /* Timer low byte */
164 #define TMRH 0x01 /* Timer high byte */
165 #define IRCR1 0x02 /* Infrared control register 1 */
166 #define IRCR1_TMR_EN 0x01 /* Timer enable */
174 #define IRCR2 0x04 /* Infrared control register 2 */
175 #define IRCR2_MDRS 0x04 /* MIR data rate select */
176 #define IRCR2_FEND_MD 0x20 /* */
178 #define FRM_ST 0x05 /* Frame status FIFO */
179 #define FRM_ST_VLD 0x80 /* Frame status FIFO data valid */
180 #define FRM_ST_ERR_MSK 0x5f
181 #define FRM_ST_LOST_FR 0x40 /* Frame lost */
182 #define FRM_ST_MAX_LEN 0x10 /* Max frame len exceeded */
183 #define FRM_ST_PHY_ERR 0x08 /* Physical layer error */
184 #define FRM_ST_BAD_CRC 0x04
185 #define FRM_ST_OVR1 0x02 /* Rx FIFO overrun */
186 #define FRM_ST_OVR2 0x01 /* Frame status FIFO overrun */
193 #define IR_CFG2_DIS_CRC 0x02
196 #define IRM_CR 0x07 /* Infrared module control register */
197 #define IRM_CR_IRX_MSL 0x40
198 #define IRM_CR_AF_MNT 0x80 /* Automatic format */
200 /* NSC chip information */
202 char *name; /* Name of chipset */
203 int cfg[3]; /* Config registers */
204 u_int8_t cid_index; /* Chip identification index reg */
205 u_int8_t cid_value; /* Chip identification expected value */
206 u_int8_t cid_mask; /* Chip identification revision mask */
208 /* Functions for probing and initializing the specific chip */
209 int (*probe)(struct nsc_chip *chip, chipio_t *info);
210 int (*init)(struct nsc_chip *chip, chipio_t *info);
212 typedef struct nsc_chip nsc_chip_t;
214 /* For storing entries in the status FIFO */
215 struct st_fifo_entry {
220 #define MAX_TX_WINDOW 7
221 #define MAX_RX_WINDOW 7
224 struct st_fifo_entry entries[MAX_RX_WINDOW];
232 void *start; /* Start of frame in DMA mem */
233 int len; /* Lenght of frame in DMA mem */
237 struct frame_cb queue[MAX_TX_WINDOW]; /* Info about frames in queue */
238 int ptr; /* Currently being sent */
239 int len; /* Lenght of queue */
240 int free; /* Next free slot */
241 void *tail; /* Next free start in DMA mem */
244 /* Private data for each instance */
246 struct st_fifo st_fifo; /* Info about received frames */
247 struct tx_fifo tx_fifo; /* Info about frames to be transmitted */
249 struct net_device *netdev; /* Yes! we are some kind of netdevice */
250 struct net_device_stats stats;
252 struct irlap_cb *irlap; /* The link layer we are binded to */
253 struct qos_info qos; /* QoS capabilities for this device */
255 chipio_t io; /* IrDA controller information */
256 iobuff_t tx_buff; /* Transmit buffer */
257 iobuff_t rx_buff; /* Receive buffer */
259 __u8 ier; /* Interrupt enable register */
261 struct timeval stamp;
264 spinlock_t lock; /* For serializing operations */
267 int index; /* Instance index */
272 static inline void switch_bank(int iobase, int bank)
274 outb(bank, iobase+BSR);
277 #endif /* NSC_IRCC_H */