donauboe.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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 controller 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. /* The documentation for this chip is allegedly released */
  52. /* However I have not seen it, not have I managed to contact */
  53. /* anyone who has. HOWEVER the chip bears a striking resemblance */
  54. /* to the IrDA controller in the Toshiba RISC TMPR3922 chip */
  55. /* the documentation for this is freely available at */
  56. /* http://www.madingley.org/james/resources/toshoboe/TMPR3922.pdf */
  57. /* The mapping between the registers in that document and the */
  58. /* Registers in the 701 oboe chip are as follows */
  59. /* 3922 reg 701 regs, by bit numbers */
  60. /* 7- 0 15- 8 24-16 31-25 */
  61. /* $28 0x0 0x1 */
  62. /* $2c SEE NOTE 1 */
  63. /* $30 0x6 0x7 */
  64. /* $34 0x8 0x9 SEE NOTE 2 */
  65. /* $38 0x10 0x11 */
  66. /* $3C 0xe SEE NOTE 3 */
  67. /* $40 0x12 0x13 */
  68. /* $44 0x14 0x15 */
  69. /* $48 0x16 0x17 */
  70. /* $4c 0x18 0x19 */
  71. /* $50 0x1a 0x1b */
  72. /* FIXME: could be 0x1b 0x1a here */
  73. /* $54 0x1d 0x1c */
  74. /* $5C 0xf SEE NOTE 4 */
  75. /* $130 SEE NOTE 5 */
  76. /* $134 SEE NOTE 6 */
  77. /* */
  78. /* NOTES: */
  79. /* 1. The pointer to ring is packed in most unceremoniusly */
  80. /* 701 Register Address bits (A9-A0 must be zero) */
  81. /* 0x4: A17 A16 A15 A14 A13 A12 A11 A10 */
  82. /* 0x5: A25 A24 A23 A22 A21 A20 A19 A18 */
  83. /* 0x2: 0 0 A31 A30 A29 A28 A27 A26 */
  84. /* */
  85. /* 2. The M$ drivers do a write 0x1 to 0x9, however the 3922 */
  86. /* documentation would suggest that a write of 0x1 to 0x8 */
  87. /* would be more appropriate. */
  88. /* */
  89. /* 3. This assignment is tenuous at best, register 0xe seems to */
  90. /* have bits arranged 0 0 0 R/W R/W R/W R/W R/W */
  91. /* if either of the lower two bits are set the chip seems to */
  92. /* switch off */
  93. /* */
  94. /* 4. Bits 7-4 seem to be different 4 seems just to be generic */
  95. /* receiver busy flag */
  96. /* */
  97. /* 5. and 6. The IER and ISR have a different bit assignment */
  98. /* The lower three bits of both read back as ones */
  99. /* ISR is register 0xc, IER is register 0xd */
  100. /* 7 6 5 4 3 2 1 0 */
  101. /* 0xc: TxDone RxDone TxUndr RxOver SipRcv 1 1 1 */
  102. /* 0xd: TxDone RxDone TxUndr RxOver SipRcv 1 1 1 */
  103. /* TxDone xmitt done (generated only if generate interrupt bit */
  104. /* is set in the ring) */
  105. /* RxDone recv completed (or other recv condition if you set it */
  106. /* up */
  107. /* TxUnder underflow in Transmit FIFO */
  108. /* RxOver overflow in Recv FIFO */
  109. /* SipRcv received serial gap (or other condition you set) */
  110. /* Interrupts are enabled by writing a one to the IER register */
  111. /* Interrupts are cleared by writing a one to the ISR register */
  112. /* */
  113. /* 6. The remaining registers: 0x6 and 0x3 appear to be */
  114. /* reserved parts of 16 or 32 bit registersthe remainder */
  115. /* 0xa 0xb 0x1e 0x1f could possibly be (by their behaviour) */
  116. /* the Unicast Filter register at $58. */
  117. /* */
  118. /* 7. While the core obviously expects 32 bit accesses all the */
  119. /* M$ drivers do 8 bit accesses, infact the Miniport ones */
  120. /* write and read back the byte serveral times (why?) */
  121. #ifndef TOSHOBOE_H
  122. #define TOSHOBOE_H
  123. /* Registers */
  124. #define OBOE_IO_EXTENT 0x1f
  125. /*Receive and transmit slot pointers */
  126. #define OBOE_REG(i) (i+(self->base))
  127. #define OBOE_RXSLOT OBOE_REG(0x0)
  128. #define OBOE_TXSLOT OBOE_REG(0x1)
  129. #define OBOE_SLOT_MASK 0x3f
  130. #define OBOE_TXRING_OFFSET 0x200
  131. #define OBOE_TXRING_OFFSET_IN_SLOTS 0x40
  132. /*pointer to the ring */
  133. #define OBOE_RING_BASE0 OBOE_REG(0x4)
  134. #define OBOE_RING_BASE1 OBOE_REG(0x5)
  135. #define OBOE_RING_BASE2 OBOE_REG(0x2)
  136. #define OBOE_RING_BASE3 OBOE_REG(0x3)
  137. /*Number of slots in the ring */
  138. #define OBOE_RING_SIZE OBOE_REG(0x7)
  139. #define OBOE_RING_SIZE_RX4 0x00
  140. #define OBOE_RING_SIZE_RX8 0x01
  141. #define OBOE_RING_SIZE_RX16 0x03
  142. #define OBOE_RING_SIZE_RX32 0x07
  143. #define OBOE_RING_SIZE_RX64 0x0f
  144. #define OBOE_RING_SIZE_TX4 0x00
  145. #define OBOE_RING_SIZE_TX8 0x10
  146. #define OBOE_RING_SIZE_TX16 0x30
  147. #define OBOE_RING_SIZE_TX32 0x70
  148. #define OBOE_RING_SIZE_TX64 0xf0
  149. #define OBOE_RING_MAX_SIZE 64
  150. /*Causes the gubbins to re-examine the ring */
  151. #define OBOE_PROMPT OBOE_REG(0x9)
  152. #define OBOE_PROMPT_BIT 0x1
  153. /* Interrupt Status Register */
  154. #define OBOE_ISR OBOE_REG(0xc)
  155. /* Interrupt Enable Register */
  156. #define OBOE_IER OBOE_REG(0xd)
  157. /* Interrupt bits for IER and ISR */
  158. #define OBOE_INT_TXDONE 0x80
  159. #define OBOE_INT_RXDONE 0x40
  160. #define OBOE_INT_TXUNDER 0x20
  161. #define OBOE_INT_RXOVER 0x10
  162. #define OBOE_INT_SIP 0x08
  163. #define OBOE_INT_MASK 0xf8
  164. /*Reset Register */
  165. #define OBOE_CONFIG1 OBOE_REG(0xe)
  166. #define OBOE_CONFIG1_RST 0x01
  167. #define OBOE_CONFIG1_DISABLE 0x02
  168. #define OBOE_CONFIG1_4 0x08
  169. #define OBOE_CONFIG1_8 0x08
  170. #define OBOE_CONFIG1_ON 0x8
  171. #define OBOE_CONFIG1_RESET 0xf
  172. #define OBOE_CONFIG1_OFF 0xe
  173. #define OBOE_STATUS OBOE_REG(0xf)
  174. #define OBOE_STATUS_RXBUSY 0x10
  175. #define OBOE_STATUS_FIRRX 0x04
  176. #define OBOE_STATUS_MIRRX 0x02
  177. #define OBOE_STATUS_SIRRX 0x01
  178. /*Speed control registers */
  179. #define OBOE_CONFIG0L OBOE_REG(0x10)
  180. #define OBOE_CONFIG0H OBOE_REG(0x11)
  181. #define OBOE_CONFIG0H_TXONLOOP 0x80 /*Transmit when looping (dangerous) */
  182. #define OBOE_CONFIG0H_LOOP 0x40 /*Loopback Tx->Rx */
  183. #define OBOE_CONFIG0H_ENTX 0x10 /*Enable Tx */
  184. #define OBOE_CONFIG0H_ENRX 0x08 /*Enable Rx */
  185. #define OBOE_CONFIG0H_ENDMAC 0x04 /*Enable/reset* the DMA controller */
  186. #define OBOE_CONFIG0H_RCVANY 0x02 /*DMA mode 1=bytes, 0=dwords */
  187. #define OBOE_CONFIG0L_CRC16 0x80 /*CRC 1=16 bit 0=32 bit */
  188. #define OBOE_CONFIG0L_ENFIR 0x40 /*Enable FIR */
  189. #define OBOE_CONFIG0L_ENMIR 0x20 /*Enable MIR */
  190. #define OBOE_CONFIG0L_ENSIR 0x10 /*Enable SIR */
  191. #define OBOE_CONFIG0L_ENSIRF 0x08 /*Enable SIR framer */
  192. #define OBOE_CONFIG0L_SIRTEST 0x04 /*Enable SIR framer in MIR and FIR */
  193. #define OBOE_CONFIG0L_INVERTTX 0x02 /*Invert Tx Line */
  194. #define OBOE_CONFIG0L_INVERTRX 0x01 /*Invert Rx Line */
  195. #define OBOE_BOF OBOE_REG(0x12)
  196. #define OBOE_EOF OBOE_REG(0x13)
  197. #define OBOE_ENABLEL OBOE_REG(0x14)
  198. #define OBOE_ENABLEH OBOE_REG(0x15)
  199. #define OBOE_ENABLEH_PHYANDCLOCK 0x80 /*Toggle low to copy config in */
  200. #define OBOE_ENABLEH_CONFIGERR 0x40
  201. #define OBOE_ENABLEH_FIRON 0x20
  202. #define OBOE_ENABLEH_MIRON 0x10
  203. #define OBOE_ENABLEH_SIRON 0x08
  204. #define OBOE_ENABLEH_ENTX 0x04
  205. #define OBOE_ENABLEH_ENRX 0x02
  206. #define OBOE_ENABLEH_CRC16 0x01
  207. #define OBOE_ENABLEL_BROADCAST 0x01
  208. #define OBOE_CURR_PCONFIGL OBOE_REG(0x16) /*Current config */
  209. #define OBOE_CURR_PCONFIGH OBOE_REG(0x17)
  210. #define OBOE_NEW_PCONFIGL OBOE_REG(0x18)
  211. #define OBOE_NEW_PCONFIGH OBOE_REG(0x19)
  212. #define OBOE_PCONFIGH_BAUDMASK 0xfc
  213. #define OBOE_PCONFIGH_WIDTHMASK 0x04
  214. #define OBOE_PCONFIGL_WIDTHMASK 0xe0
  215. #define OBOE_PCONFIGL_PREAMBLEMASK 0x1f
  216. #define OBOE_PCONFIG_BAUDMASK 0xfc00
  217. #define OBOE_PCONFIG_BAUDSHIFT 10
  218. #define OBOE_PCONFIG_WIDTHMASK 0x04e0
  219. #define OBOE_PCONFIG_WIDTHSHIFT 5
  220. #define OBOE_PCONFIG_PREAMBLEMASK 0x001f
  221. #define OBOE_PCONFIG_PREAMBLESHIFT 0
  222. #define OBOE_MAXLENL OBOE_REG(0x1a)
  223. #define OBOE_MAXLENH OBOE_REG(0x1b)
  224. #define OBOE_RXCOUNTH OBOE_REG(0x1c) /*Reset on recipt */
  225. #define OBOE_RXCOUNTL OBOE_REG(0x1d) /*of whole packet */
  226. /* The PCI ID of the OBOE chip */
  227. #ifndef PCI_DEVICE_ID_FIR701
  228. #define PCI_DEVICE_ID_FIR701 0x0701
  229. #endif
  230. #ifndef PCI_DEVICE_ID_FIRD01
  231. #define PCI_DEVICE_ID_FIRD01 0x0d01
  232. #endif
  233. struct OboeSlot
  234. {
  235. __u16 len; /*Tweleve bits of packet length */
  236. __u8 unused;
  237. __u8 control; /*Slot control/status see below */
  238. __u32 address; /*Slot buffer address */
  239. }
  240. __packed;
  241. #define OBOE_NTASKS OBOE_TXRING_OFFSET_IN_SLOTS
  242. struct OboeRing
  243. {
  244. struct OboeSlot rx[OBOE_NTASKS];
  245. struct OboeSlot tx[OBOE_NTASKS];
  246. };
  247. #define OBOE_RING_LEN (sizeof(struct OboeRing))
  248. #define OBOE_CTL_TX_HW_OWNS 0x80 /*W/R This slot owned by the hardware */
  249. #define OBOE_CTL_TX_DISTX_CRC 0x40 /*W Disable CRC generation for [FM]IR */
  250. #define OBOE_CTL_TX_BAD_CRC 0x20 /*W Generate bad CRC */
  251. #define OBOE_CTL_TX_SIP 0x10 /*W Generate an SIP after xmittion */
  252. #define OBOE_CTL_TX_MKUNDER 0x08 /*W Generate an underrun error */
  253. #define OBOE_CTL_TX_RTCENTX 0x04 /*W Enable receiver and generate TXdone */
  254. /* After this slot is processed */
  255. #define OBOE_CTL_TX_UNDER 0x01 /*R Set by hardware to indicate underrun */
  256. #define OBOE_CTL_RX_HW_OWNS 0x80 /*W/R This slot owned by hardware */
  257. #define OBOE_CTL_RX_PHYERR 0x40 /*R Decoder error on receiption */
  258. #define OBOE_CTL_RX_CRCERR 0x20 /*R CRC error only set for [FM]IR */
  259. #define OBOE_CTL_RX_LENGTH 0x10 /*R Packet > max Rx length */
  260. #define OBOE_CTL_RX_OVER 0x08 /*R set to indicate an overflow */
  261. #define OBOE_CTL_RX_SIRBAD 0x04 /*R SIR had BOF in packet or ABORT sequence */
  262. #define OBOE_CTL_RX_RXEOF 0x02 /*R Finished receiving on this slot */
  263. struct toshoboe_cb
  264. {
  265. struct net_device *netdev; /* Yes! we are some kind of netdevice */
  266. struct tty_driver ttydev;
  267. struct irlap_cb *irlap; /* The link layer we are binded to */
  268. chipio_t io; /* IrDA controller information */
  269. struct qos_info qos; /* QoS capabilities for this device */
  270. __u32 flags; /* Interface flags */
  271. struct pci_dev *pdev; /*PCI device */
  272. int base; /*IO base */
  273. int txpending; /*how many tx's are pending */
  274. int txs, rxs; /*Which slots are we at */
  275. int irdad; /*Driver under control of netdev end */
  276. int async; /*Driver under control of async end */
  277. int stopped; /*Stopped by some or other APM stuff */
  278. int filter; /*In SIR mode do we want to receive
  279. frames or byte ranges */
  280. void *ringbuf; /*The ring buffer */
  281. struct OboeRing *ring; /*The ring */
  282. void *tx_bufs[OBOE_RING_MAX_SIZE]; /*The buffers */
  283. void *rx_bufs[OBOE_RING_MAX_SIZE];
  284. int speed; /*Current setting of the speed */
  285. int new_speed; /*Set to request a speed change */
  286. /* The spinlock protect critical parts of the driver.
  287. * Locking is done like this :
  288. * spin_lock_irqsave(&self->spinlock, flags);
  289. * Releasing the lock :
  290. * spin_unlock_irqrestore(&self->spinlock, flags);
  291. */
  292. spinlock_t spinlock;
  293. /* Used for the probe and diagnostics code */
  294. int int_rx;
  295. int int_tx;
  296. int int_txunder;
  297. int int_rxover;
  298. int int_sip;
  299. };
  300. #endif