1/********************************************************************* 2 * 3 * Filename: toshoboe.h 4 * Version: 2.16 5 * Description: Driver for the Toshiba OBOE (or type-O or 701) 6 * FIR Chipset, also supports the DONAUOBOE (type-DO 7 * or d01) FIR chipset which as far as I know is 8 * register compatible. 9 * Status: Experimental. 10 * Author: James McKenzie <james@fishsoup.dhs.org> 11 * Created at: Sat May 8 12:35:27 1999 12 * Modified: 2.16 Martin Lucina <mato@kotelna.sk> 13 * Modified: 2.16 Sat Jun 22 18:54:29 2002 (sync headers) 14 * Modified: 2.17 Christian Gennerat <christian.gennerat@polytechnique.org> 15 * Modified: 2.17 jeu sep 12 08:50:20 2002 (add lock to be used by spinlocks) 16 * 17 * Copyright (c) 1999 James McKenzie, All Rights Reserved. 18 * 19 * This program is free software; you can redistribute it and/or 20 * modify it under the terms of the GNU General Public License as 21 * published by the Free Software Foundation; either version 2 of 22 * the License, or (at your option) any later version. 23 * 24 * Neither James McKenzie nor Cambridge University admit liability nor 25 * provide warranty for any of this software. This material is 26 * provided "AS-IS" and at no charge. 27 * 28 * Applicable Models : Libretto 100/110CT and many more. 29 * Toshiba refers to this chip as the type-O IR port, 30 * or the type-DO IR port. 31 * 32 * IrDA chip set list from Toshiba Computer Engineering Corp. 33 * model method maker controler Version 34 * Portege 320CT FIR,SIR Toshiba Oboe(Triangle) 35 * Portege 3010CT FIR,SIR Toshiba Oboe(Sydney) 36 * Portege 3015CT FIR,SIR Toshiba Oboe(Sydney) 37 * Portege 3020CT FIR,SIR Toshiba Oboe(Sydney) 38 * Portege 7020CT FIR,SIR ? ? 39 * 40 * Satell. 4090XCDT FIR,SIR ? ? 41 * 42 * Libretto 100CT FIR,SIR Toshiba Oboe 43 * Libretto 1000CT FIR,SIR Toshiba Oboe 44 * 45 * TECRA750DVD FIR,SIR Toshiba Oboe(Triangle) REV ID=14h 46 * TECRA780 FIR,SIR Toshiba Oboe(Sandlot) REV ID=32h,33h 47 * TECRA750CDT FIR,SIR Toshiba Oboe(Triangle) REV ID=13h,14h 48 * TECRA8000 FIR,SIR Toshiba Oboe(ISKUR) REV ID=23h 49 * 50 ********************************************************************/ 51 52/* The documentation for this chip is allegedly released */ 53/* However I have not seen it, not have I managed to contact */ 54/* anyone who has. HOWEVER the chip bears a striking resemblence */ 55/* to the IrDA controller in the Toshiba RISC TMPR3922 chip */ 56/* the documentation for this is freely available at */ 57/* http://www.toshiba.com/taec/components/Generic/TMPR3922.shtml */ 58/* The mapping between the registers in that document and the */ 59/* Registers in the 701 oboe chip are as follows */ 60 61 62/* 3922 reg 701 regs, by bit numbers */ 63/* 7- 0 15- 8 24-16 31-25 */ 64/* $28 0x0 0x1 */ 65/* $2c SEE NOTE 1 */ 66/* $30 0x6 0x7 */ 67/* $34 0x8 0x9 SEE NOTE 2 */ 68/* $38 0x10 0x11 */ 69/* $3C 0xe SEE NOTE 3 */ 70/* $40 0x12 0x13 */ 71/* $44 0x14 0x15 */ 72/* $48 0x16 0x17 */ 73/* $4c 0x18 0x19 */ 74/* $50 0x1a 0x1b */ 75 76 77/* $54 0x1d 0x1c */ 78/* $5C 0xf SEE NOTE 4 */ 79/* $130 SEE NOTE 5 */ 80/* $134 SEE NOTE 6 */ 81/* */ 82/* NOTES: */ 83/* 1. The pointer to ring is packed in most unceremoniusly */ 84/* 701 Register Address bits (A9-A0 must be zero) */ 85/* 0x4: A17 A16 A15 A14 A13 A12 A11 A10 */ 86/* 0x5: A25 A24 A23 A22 A21 A20 A19 A18 */ 87/* 0x2: 0 0 A31 A30 A29 A28 A27 A26 */ 88/* */ 89/* 2. The M$ drivers do a write 0x1 to 0x9, however the 3922 */ 90/* documentation would suggest that a write of 0x1 to 0x8 */ 91/* would be more appropriate. */ 92/* */ 93/* 3. This assignment is tenuous at best, register 0xe seems to */ 94/* have bits arranged 0 0 0 R/W R/W R/W R/W R/W */ 95/* if either of the lower two bits are set the chip seems to */ 96/* switch off */ 97/* */ 98/* 4. Bits 7-4 seem to be different 4 seems just to be generic */ 99/* receiver busy flag */ 100/* */ 101/* 5. and 6. The IER and ISR have a different bit assignment */ 102/* The lower three bits of both read back as ones */ 103/* ISR is register 0xc, IER is register 0xd */ 104/* 7 6 5 4 3 2 1 0 */ 105/* 0xc: TxDone RxDone TxUndr RxOver SipRcv 1 1 1 */ 106/* 0xd: TxDone RxDone TxUndr RxOver SipRcv 1 1 1 */ 107/* TxDone xmitt done (generated only if generate interrupt bit */ 108/* is set in the ring) */ 109/* RxDone recv completed (or other recv condition if you set it */ 110/* up */ 111/* TxUnder underflow in Transmit FIFO */ 112/* RxOver overflow in Recv FIFO */ 113/* SipRcv received serial gap (or other condition you set) */ 114/* Interrupts are enabled by writing a one to the IER register */ 115/* Interrupts are cleared by writing a one to the ISR register */ 116/* */ 117/* 6. The remaining registers: 0x6 and 0x3 appear to be */ 118/* reserved parts of 16 or 32 bit registersthe remainder */ 119/* 0xa 0xb 0x1e 0x1f could possibly be (by their behaviour) */ 120/* the Unicast Filter register at $58. */ 121/* */ 122/* 7. While the core obviously expects 32 bit accesses all the */ 123/* M$ drivers do 8 bit accesses, infact the Miniport ones */ 124/* write and read back the byte serveral times (why?) */ 125 126 127#ifndef TOSHOBOE_H 128#define TOSHOBOE_H 129 130/* Registers */ 131 132#define OBOE_IO_EXTENT 0x1f 133 134/*Receive and transmit slot pointers */ 135#define OBOE_REG(i) (i+(self->base)) 136#define OBOE_RXSLOT OBOE_REG(0x0) 137#define OBOE_TXSLOT OBOE_REG(0x1) 138#define OBOE_SLOT_MASK 0x3f 139 140#define OBOE_TXRING_OFFSET 0x200 141#define OBOE_TXRING_OFFSET_IN_SLOTS 0x40 142 143/*pointer to the ring */ 144#define OBOE_RING_BASE0 OBOE_REG(0x4) 145#define OBOE_RING_BASE1 OBOE_REG(0x5) 146#define OBOE_RING_BASE2 OBOE_REG(0x2) 147#define OBOE_RING_BASE3 OBOE_REG(0x3) 148 149/*Number of slots in the ring */ 150#define OBOE_RING_SIZE OBOE_REG(0x7) 151#define OBOE_RING_SIZE_RX4 0x00 152#define OBOE_RING_SIZE_RX8 0x01 153#define OBOE_RING_SIZE_RX16 0x03 154#define OBOE_RING_SIZE_RX32 0x07 155#define OBOE_RING_SIZE_RX64 0x0f 156#define OBOE_RING_SIZE_TX4 0x00 157#define OBOE_RING_SIZE_TX8 0x10 158#define OBOE_RING_SIZE_TX16 0x30 159#define OBOE_RING_SIZE_TX32 0x70 160#define OBOE_RING_SIZE_TX64 0xf0 161 162#define OBOE_RING_MAX_SIZE 64 163 164/*Causes the gubbins to re-examine the ring */ 165#define OBOE_PROMPT OBOE_REG(0x9) 166#define OBOE_PROMPT_BIT 0x1 167 168/* Interrupt Status Register */ 169#define OBOE_ISR OBOE_REG(0xc) 170/* Interrupt Enable Register */ 171#define OBOE_IER OBOE_REG(0xd) 172/* Interrupt bits for IER and ISR */ 173#define OBOE_INT_TXDONE 0x80 174#define OBOE_INT_RXDONE 0x40 175#define OBOE_INT_TXUNDER 0x20 176#define OBOE_INT_RXOVER 0x10 177#define OBOE_INT_SIP 0x08 178#define OBOE_INT_MASK 0xf8 179 180/*Reset Register */ 181#define OBOE_CONFIG1 OBOE_REG(0xe) 182#define OBOE_CONFIG1_RST 0x01 183#define OBOE_CONFIG1_DISABLE 0x02 184#define OBOE_CONFIG1_4 0x08 185#define OBOE_CONFIG1_8 0x08 186 187#define OBOE_CONFIG1_ON 0x8 188#define OBOE_CONFIG1_RESET 0xf 189#define OBOE_CONFIG1_OFF 0xe 190 191#define OBOE_STATUS OBOE_REG(0xf) 192#define OBOE_STATUS_RXBUSY 0x10 193#define OBOE_STATUS_FIRRX 0x04 194#define OBOE_STATUS_MIRRX 0x02 195#define OBOE_STATUS_SIRRX 0x01 196 197 198/*Speed control registers */ 199#define OBOE_CONFIG0L OBOE_REG(0x10) 200#define OBOE_CONFIG0H OBOE_REG(0x11) 201 202#define OBOE_CONFIG0H_TXONLOOP 0x80 /*Transmit when looping (dangerous) */ 203#define OBOE_CONFIG0H_LOOP 0x40 /*Loopback Tx->Rx */ 204#define OBOE_CONFIG0H_ENTX 0x10 /*Enable Tx */ 205#define OBOE_CONFIG0H_ENRX 0x08 /*Enable Rx */ 206#define OBOE_CONFIG0H_ENDMAC 0x04 /*Enable/reset* the DMA controller */ 207#define OBOE_CONFIG0H_RCVANY 0x02 /*DMA mode 1=bytes, 0=dwords */ 208 209#define OBOE_CONFIG0L_CRC16 0x80 /*CRC 1=16 bit 0=32 bit */ 210#define OBOE_CONFIG0L_ENFIR 0x40 /*Enable FIR */ 211#define OBOE_CONFIG0L_ENMIR 0x20 /*Enable MIR */ 212#define OBOE_CONFIG0L_ENSIR 0x10 /*Enable SIR */ 213#define OBOE_CONFIG0L_ENSIRF 0x08 /*Enable SIR framer */ 214#define OBOE_CONFIG0L_SIRTEST 0x04 /*Enable SIR framer in MIR and FIR */ 215#define OBOE_CONFIG0L_INVERTTX 0x02 /*Invert Tx Line */ 216#define OBOE_CONFIG0L_INVERTRX 0x01 /*Invert Rx Line */ 217 218#define OBOE_BOF OBOE_REG(0x12) 219#define OBOE_EOF OBOE_REG(0x13) 220 221#define OBOE_ENABLEL OBOE_REG(0x14) 222#define OBOE_ENABLEH OBOE_REG(0x15) 223 224#define OBOE_ENABLEH_PHYANDCLOCK 0x80 /*Toggle low to copy config in */ 225#define OBOE_ENABLEH_CONFIGERR 0x40 226#define OBOE_ENABLEH_FIRON 0x20 227#define OBOE_ENABLEH_MIRON 0x10 228#define OBOE_ENABLEH_SIRON 0x08 229#define OBOE_ENABLEH_ENTX 0x04 230#define OBOE_ENABLEH_ENRX 0x02 231#define OBOE_ENABLEH_CRC16 0x01 232 233#define OBOE_ENABLEL_BROADCAST 0x01 234 235#define OBOE_CURR_PCONFIGL OBOE_REG(0x16) /*Current config */ 236#define OBOE_CURR_PCONFIGH OBOE_REG(0x17) 237 238#define OBOE_NEW_PCONFIGL OBOE_REG(0x18) 239#define OBOE_NEW_PCONFIGH OBOE_REG(0x19) 240 241#define OBOE_PCONFIGH_BAUDMASK 0xfc 242#define OBOE_PCONFIGH_WIDTHMASK 0x04 243#define OBOE_PCONFIGL_WIDTHMASK 0xe0 244#define OBOE_PCONFIGL_PREAMBLEMASK 0x1f 245 246#define OBOE_PCONFIG_BAUDMASK 0xfc00 247#define OBOE_PCONFIG_BAUDSHIFT 10 248#define OBOE_PCONFIG_WIDTHMASK 0x04e0 249#define OBOE_PCONFIG_WIDTHSHIFT 5 250#define OBOE_PCONFIG_PREAMBLEMASK 0x001f 251#define OBOE_PCONFIG_PREAMBLESHIFT 0 252 253#define OBOE_MAXLENL OBOE_REG(0x1a) 254#define OBOE_MAXLENH OBOE_REG(0x1b) 255 256#define OBOE_RXCOUNTH OBOE_REG(0x1c) /*Reset on recipt */ 257#define OBOE_RXCOUNTL OBOE_REG(0x1d) /*of whole packet */ 258 259/* The PCI ID of the OBOE chip */ 260#ifndef PCI_DEVICE_ID_FIR701 261#define PCI_DEVICE_ID_FIR701 0x0701 262#endif 263 264#ifndef PCI_DEVICE_ID_FIRD01 265#define PCI_DEVICE_ID_FIRD01 0x0d01 266#endif 267 268struct OboeSlot 269{ 270 __u16 len; /*Tweleve bits of packet length */ 271 __u8 unused; 272 __u8 control; /*Slot control/status see below */ 273 __u32 address; /*Slot buffer address */ 274} 275__attribute__ ((packed)); 276 277#define OBOE_NTASKS OBOE_TXRING_OFFSET_IN_SLOTS 278 279struct OboeRing 280{ 281 struct OboeSlot rx[OBOE_NTASKS]; 282 struct OboeSlot tx[OBOE_NTASKS]; 283}; 284 285#define OBOE_RING_LEN (sizeof(struct OboeRing)) 286 287 288#define OBOE_CTL_TX_HW_OWNS 0x80 /*W/R This slot owned by the hardware */ 289#define OBOE_CTL_TX_DISTX_CRC 0x40 /*W Disable CRC generation for [FM]IR */ 290#define OBOE_CTL_TX_BAD_CRC 0x20 /*W Generate bad CRC */ 291#define OBOE_CTL_TX_SIP 0x10 /*W Generate an SIP after xmittion */ 292#define OBOE_CTL_TX_MKUNDER 0x08 /*W Generate an underrun error */ 293#define OBOE_CTL_TX_RTCENTX 0x04 /*W Enable receiver and generate TXdone */ 294 /* After this slot is processed */ 295#define OBOE_CTL_TX_UNDER 0x01 /*R Set by hardware to indicate underrun */ 296 297 298#define OBOE_CTL_RX_HW_OWNS 0x80 /*W/R This slot owned by hardware */ 299#define OBOE_CTL_RX_PHYERR 0x40 /*R Decoder error on receiption */ 300#define OBOE_CTL_RX_CRCERR 0x20 /*R CRC error only set for [FM]IR */ 301#define OBOE_CTL_RX_LENGTH 0x10 /*R Packet > max Rx length */ 302#define OBOE_CTL_RX_OVER 0x08 /*R set to indicate an overflow */ 303#define OBOE_CTL_RX_SIRBAD 0x04 /*R SIR had BOF in packet or ABORT sequence */ 304#define OBOE_CTL_RX_RXEOF 0x02 /*R Finished receiving on this slot */ 305 306 307struct toshoboe_cb 308{ 309 struct net_device *netdev; /* Yes! we are some kind of netdevice */ 310 struct net_device_stats stats; 311 struct tty_driver ttydev; 312 313 struct irlap_cb *irlap; /* The link layer we are binded to */ 314 315 chipio_t io; /* IrDA controller information */ 316 struct qos_info qos; /* QoS capabilities for this device */ 317 318 __u32 flags; /* Interface flags */ 319 320 struct pci_dev *pdev; /*PCI device */ 321 int base; /*IO base */ 322 323 324 int txpending; /*how many tx's are pending */ 325 int txs, rxs; /*Which slots are we at */ 326 327 int irdad; /*Driver under control of netdev end */ 328 int async; /*Driver under control of async end */ 329 330 331 int stopped; /*Stopped by some or other APM stuff */ 332 333 int filter; /*In SIR mode do we want to receive 334 frames or byte ranges */ 335 336 void *ringbuf; /*The ring buffer */ 337 struct OboeRing *ring; /*The ring */ 338 339 void *tx_bufs[OBOE_RING_MAX_SIZE]; /*The buffers */ 340 void *rx_bufs[OBOE_RING_MAX_SIZE]; 341 342 343 int speed; /*Current setting of the speed */ 344 int new_speed; /*Set to request a speed change */ 345 346/* The spinlock protect critical parts of the driver. 347 * Locking is done like this : 348 * spin_lock_irqsave(&self->spinlock, flags); 349 * Releasing the lock : 350 * spin_unlock_irqrestore(&self->spinlock, flags); 351 */ 352 spinlock_t spinlock; 353 /* Used for the probe and diagnostics code */ 354 int int_rx; 355 int int_tx; 356 int int_txunder; 357 int int_rxover; 358 int int_sip; 359}; 360 361 362#endif 363