vlsi_ir.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:20k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*********************************************************************
  2.  *
  3.  * vlsi_ir.h: VLSI82C147 PCI IrDA controller driver for Linux
  4.  *
  5.  * Version: 0.3, Sep 30, 2001
  6.  *
  7.  * Copyright (c) 2001 Martin Diehl
  8.  *
  9.  * This program is free software; you can redistribute it and/or 
  10.  * modify it under the terms of the GNU General Public License as 
  11.  * published by the Free Software Foundation; either version 2 of 
  12.  * the License, or (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License 
  20.  * along with this program; if not, write to the Free Software 
  21.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
  22.  * MA 02111-1307 USA
  23.  *
  24.  ********************************************************************/
  25. #ifndef IRDA_VLSI_FIR_H
  26. #define IRDA_VLSI_FIR_H
  27. /* ================================================================ */
  28. /* non-standard PCI registers */
  29. enum vlsi_pci_regs {
  30. VLSI_PCI_CLKCTL = 0x40, /* chip clock input control */
  31. VLSI_PCI_MSTRPAGE = 0x41, /* addr [31:24] for all busmaster cycles */
  32. VLSI_PCI_IRMISC = 0x42 /* mainly legacy UART related */
  33. };
  34. /* ------------------------------------------ */
  35. /* VLSI_PCI_CLKCTL: Clock Control Register (u8, rw) */
  36. /* Three possible clock sources: either on-chip 48MHz PLL or
  37.  * external clock applied to EXTCLK pin. External clock may
  38.  * be either 48MHz or 40MHz, which is indicated by XCKSEL.
  39.  * CLKSTP controls whether the selected clock source gets
  40.  * connected to the IrDA block.
  41.  *
  42.  * On my HP OB-800 the BIOS sets external 40MHz clock as source
  43.  * when IrDA enabled and I've never detected any PLL lock success.
  44.  * Apparently the 14.3...MHz OSC input required for the PLL to work
  45.  * is not connected and the 40MHz EXTCLK is provided externally.
  46.  * At least this is what makes the driver working for me.
  47.  */
  48. enum vlsi_pci_clkctl {
  49. /* PLL control */
  50. CLKCTL_NO_PD = 0x04, /* PD# (inverted power down) signal,
  51.  * i.e. PLL is powered, if NO_PD set */
  52. CLKCTL_LOCK = 0x40, /* (ro) set, if PLL is locked */
  53. /* clock source selection */
  54. CLKCTL_EXTCLK = 0x20, /* set to select external clock input */
  55. CLKCTL_XCKSEL = 0x10, /* set to indicate 40MHz EXTCLK, not 48MHz */
  56. /* IrDA block control */
  57. CLKCTL_CLKSTP = 0x80, /* set to disconnect from selected clock source */
  58. CLKCTL_WAKE = 0x08 /* set to enable wakeup feature: whenever IR activity
  59.  * is detected, NO_PD gets set and CLKSTP cleared */
  60. };
  61. /* ------------------------------------------ */
  62. /* VLSI_PCI_MSTRPAGE: Master Page Register (u8, rw) and busmastering stuff */
  63. #define DMA_MASK_USED_BY_HW 0xffffffff
  64. #define DMA_MASK_MSTRPAGE 0x00ffffff
  65. #define MSTRPAGE_VALUE (DMA_MASK_MSTRPAGE >> 24)
  66. /* PCI busmastering is somewhat special for this guy - in short:
  67.  *
  68.  * We select to operate using MSTRPAGE=0 fixed, use ISA DMA
  69.  * address restrictions to make the PCI BM api aware of this,
  70.  * but ensure the hardware is dealing with real 32bit access.
  71.  *
  72.  * In detail:
  73.  * The chip executes normal 32bit busmaster cycles, i.e.
  74.  * drives all 32 address lines. These addresses however are
  75.  * composed of [0:23] taken from various busaddr-pointers
  76.  * and [24:31] taken from the MSTRPAGE register in the VLSI82C147
  77.  * config space. Therefore _all_ busmastering must be
  78.  * targeted to/from one single 16MB (busaddr-) superpage!
  79.  * The point is to make sure all the allocations for memory
  80.  * locations with busmaster access (ring descriptors, buffers)
  81.  * are indeed bus-mappable to the same 16MB range (for x86 this
  82.  * means they must reside in the same 16MB physical memory address
  83.  * range). The only constraint we have which supports "several objects
  84.  * mappable to common 16MB range" paradigma, is the old ISA DMA
  85.  * restriction to the first 16MB of physical address range.
  86.  * Hence the approach here is to enable PCI busmaster support using
  87.  * the correct 32bit dma-mask used by the chip. Afterwards the device's
  88.  * dma-mask gets restricted to 24bit, which must be honoured somehow by
  89.  * all allocations for memory areas to be exposed to the chip ...
  90.  *
  91.  * Note:
  92.  * Don't be surprised to get "Setting latency timer..." messages every
  93.  * time when PCI busmastering is enabled for the chip.
  94.  * The chip has its PCI latency timer RO fixed at 0 - which is not a
  95.  * problem here, because it is never requesting _burst_ transactions.
  96.  */
  97. /* ------------------------------------------ */
  98. /* VLSI_PCIIRMISC: IR Miscellaneous Register (u8, rw) */
  99. /* legacy UART emulation - not used by this driver - would require:
  100.  * (see below for some register-value definitions)
  101.  *
  102.  * - IRMISC_UARTEN must be set to enable UART address decoding
  103.  * - IRMISC_UARTSEL configured
  104.  * - IRCFG_MASTER must be cleared
  105.  * - IRCFG_SIR must be set
  106.  * - IRENABLE_IREN must be asserted 0->1 (and hence IRENABLE_SIR_ON)
  107.  */
  108. enum vlsi_pci_irmisc {
  109. /* IR transceiver control */
  110. IRMISC_IRRAIL = 0x40, /* (ro?) IR rail power indication (and control?)
  111.  * 0=3.3V / 1=5V. Probably set during power-on?
  112.  * unclear - not touched by driver */
  113. IRMISC_IRPD = 0x08, /* transceiver power down, if set */
  114. /* legacy UART control */
  115. IRMISC_UARTTST = 0x80, /* UART test mode - "always write 0" */
  116. IRMISC_UARTEN = 0x04, /* enable UART address decoding */
  117. /* bits [1:0] IRMISC_UARTSEL to select legacy UART address */
  118. IRMISC_UARTSEL_3f8 = 0x00,
  119. IRMISC_UARTSEL_2f8 = 0x01,
  120. IRMISC_UARTSEL_3e8 = 0x02,
  121. IRMISC_UARTSEL_2e8 = 0x03
  122. };
  123. /* ================================================================ */
  124. /* registers mapped to 32 byte PCI IO space */
  125. /* note: better access all registers at the indicated u8/u16 size
  126.  *  although some of them contain only 1 byte of information.
  127.  *  some of them (particaluarly PROMPT and IRCFG) ignore
  128.  *  access when using the wrong addressing mode!
  129.  */
  130. enum vlsi_pio_regs {
  131. VLSI_PIO_IRINTR = 0x00, /* interrupt enable/request (u8, rw) */
  132. VLSI_PIO_RINGPTR = 0x02, /* rx/tx ring pointer (u16, ro) */
  133. VLSI_PIO_RINGBASE = 0x04, /* [23:10] of ring address (u16, rw) */
  134. VLSI_PIO_RINGSIZE = 0x06, /* rx/tx ring size (u16, rw) */
  135. VLSI_PIO_PROMPT = 0x08,  /* triggers ring processing (u16, wo) */
  136. /* 0x0a-0x0f: reserved / duplicated UART regs */
  137. VLSI_PIO_IRCFG = 0x10, /* configuration select (u16, rw) */
  138. VLSI_PIO_SIRFLAG = 0x12, /* BOF/EOF for filtered SIR (u16, ro) */
  139. VLSI_PIO_IRENABLE = 0x14, /* enable and status register (u16, rw/ro) */
  140. VLSI_PIO_PHYCTL = 0x16, /* physical layer current status (u16, ro) */
  141. VLSI_PIO_NPHYCTL = 0x18, /* next physical layer select (u16, rw) */
  142. VLSI_PIO_MAXPKT = 0x1a, /* [11:0] max len for packet receive (u16, rw) */
  143. VLSI_PIO_RCVBCNT = 0x1c /* current receive-FIFO byte count (u16, ro) */
  144. /* 0x1e-0x1f: reserved / duplicated UART regs */
  145. };
  146. /* ------------------------------------------ */
  147. /* VLSI_PIO_IRINTR: Interrupt Register (u8, rw) */
  148. /* enable-bits:
  149.  * 1 = enable / 0 = disable
  150.  * interrupt condition bits:
  151.  *  set according to corresponding interrupt source
  152.  * (regardless of the state of the enable bits)
  153.  * enable bit status indicates whether interrupt gets raised
  154.  * write-to-clear
  155.  * note: RPKTINT and TPKTINT behave different in legacy UART mode (which we don't use :-)
  156.  */
  157. enum vlsi_pio_irintr {
  158. IRINTR_ACTEN = 0x80, /* activity interrupt enable */
  159. IRINTR_ACTIVITY = 0x40, /* activity monitor (traffic detected) */
  160. IRINTR_RPKTEN = 0x20, /* receive packet interrupt enable*/
  161. IRINTR_RPKTINT = 0x10, /* rx-packet transfered from fifo to memory finished */
  162. IRINTR_TPKTEN = 0x08, /* transmit packet interrupt enable */
  163. IRINTR_TPKTINT = 0x04, /* last bit of tx-packet+crc shifted to ir-pulser */
  164. IRINTR_OE_EN = 0x02, /* UART rx fifo overrun error interrupt enable */
  165. IRINTR_OE_INT = 0x01 /* UART rx fifo overrun error (read LSR to clear) */
  166. };
  167. /* we use this mask to check whether the (shared PCI) interrupt is ours */
  168. #define IRINTR_INT_MASK (IRINTR_ACTIVITY|IRINTR_RPKTINT|IRINTR_TPKTINT)
  169. /* ------------------------------------------ */
  170. /* VLSI_PIO_RINGPTR: Ring Pointer Read-Back Register (u16, ro) */
  171. /* _both_ ring pointers are indices relative to the _entire_ rx,tx-ring!
  172.  * i.e. the referenced descriptor is located
  173.  * at RINGBASE + PTR * sizeof(descr) for rx and tx
  174.  * therefore, the tx-pointer has offset MAX_RING_DESCR
  175.  */
  176. #define MAX_RING_DESCR 64 /* tx, rx rings may contain up to 64 descr each */
  177. #define RINGPTR_RX_MASK (MAX_RING_DESCR-1)
  178. #define RINGPTR_TX_MASK ((MAX_RING_DESCR-1)<<8)
  179. #define RINGPTR_GET_RX(p) ((p)&RINGPTR_RX_MASK)
  180. #define RINGPTR_GET_TX(p) (((p)&RINGPTR_TX_MASK)>>8)
  181. /* ------------------------------------------ */
  182. /* VLSI_PIO_RINGBASE: Ring Pointer Base Address Register (u16, ro) */
  183. /* Contains [23:10] part of the ring base (bus-) address
  184.  * which must be 1k-alinged. [31:24] is taken from
  185.  * VLSI_PCI_MSTRPAGE above.
  186.  * The controller initiates non-burst PCI BM cycles to
  187.  * fetch and update the descriptors in the ring.
  188.  * Once fetched, the descriptor remains cached onchip
  189.  * until it gets closed and updated due to the ring
  190.  * processing state machine.
  191.  * The entire ring area is split in rx and tx areas with each
  192.  * area consisting of 64 descriptors of 8 bytes each.
  193.  * The rx(tx) ring is located at ringbase+0 (ringbase+64*8).
  194.  */
  195. #define BUS_TO_RINGBASE(p) (((p)>>10)&0x3fff)
  196. /* ------------------------------------------ */
  197. /* VLSI_PIO_RINGSIZE: Ring Size Register (u16, rw) */
  198. /* bit mask to indicate the ring size to be used for rx and tx.
  199.  *  possible values encoded bits
  200.  *  4    0000
  201.  *  8    0001
  202.  * 16    0011
  203.  * 32    0111
  204.  * 64    1111
  205.  * located at [15:12] for tx and [11:8] for rx ([7:0] unused)
  206.  *
  207.  * note: probably a good idea to have IRCFG_MSTR cleared when writing
  208.  *  this so the state machines are stopped and the RINGPTR is reset!
  209.  */
  210. #define SIZE_TO_BITS(num) ((((num)-1)>>2)&0x0f)
  211. #define TX_RX_TO_RINGSIZE(tx,rx) ((SIZE_TO_BITS(tx)<<12)|(SIZE_TO_BITS(rx)<<8))
  212. #define RINGSIZE_TO_RXSIZE(rs) ((((rs)&0x0f00)>>6)+4)
  213. #define RINGSIZE_TO_TXSIZE(rs) ((((rs)&0xf000)>>10)+4)
  214. /* ------------------------------------------ */
  215. /* VLSI_PIO_PROMPT: Ring Prompting Register (u16, write-to-start) */
  216. /* writing any value kicks the ring processing state machines
  217.  * for both tx, rx rings as follows:
  218.  *  - active rings (currently owning an active descriptor)
  219.  *   ignore the prompt and continue
  220.  * - idle rings fetch the next descr from the ring and start
  221.  *   their processing
  222.  */
  223. /* ------------------------------------------ */
  224. /* VLSI_PIO_IRCFG: IR Config Register (u16, rw) */
  225. /* notes:
  226.  * - not more than one SIR/MIR/FIR bit must be set at any time
  227.  * - SIR, MIR, FIR and CRC16 select the configuration which will
  228.  *   be applied on next 0->1 transition of IRENABLE_IREN (see below).
  229.  * - besides allowing the PCI interface to execute busmaster cycles
  230.  *   and therefore the ring SM to operate, the MSTR bit has side-effects:
  231.  *   when MSTR is cleared, the RINGPTR's get reset and the legacy UART mode
  232.  *   (in contrast to busmaster access mode) gets enabled.
  233.  * - clearing ENRX or setting ENTX while data is received may stall the
  234.  *   receive fifo until ENRX reenabled _and_ another packet arrives
  235.  * - SIRFILT means the chip performs the required unwrapping of hardware
  236.  *   headers (XBOF's, BOF/EOF) and un-escaping in the _receive_ direction.
  237.  *   Only the resulting IrLAP payload is copied to the receive buffers -
  238.  *   but with the 16bit FCS still encluded. Question remains, whether it
  239.  *   was already checked or we should do it before passing the packet to IrLAP?
  240.  */
  241. enum vlsi_pio_ircfg {
  242. IRCFG_LOOP = 0x4000, /* enable loopback test mode */
  243. IRCFG_ENTX = 0x1000, /* transmit enable */
  244. IRCFG_ENRX = 0x0800, /* receive enable */
  245. IRCFG_MSTR = 0x0400, /* master enable */
  246. IRCFG_RXANY = 0x0200, /* receive any packet */
  247. IRCFG_CRC16 = 0x0080, /* 16bit (not 32bit) CRC select for MIR/FIR */
  248. IRCFG_FIR = 0x0040, /* FIR 4PPM encoding mode enable */
  249. IRCFG_MIR = 0x0020, /* MIR HDLC encoding mode enable */
  250. IRCFG_SIR = 0x0010, /* SIR encoding mode enable */
  251. IRCFG_SIRFILT = 0x0008, /* enable SIR decode filter (receiver unwrapping) */
  252. IRCFG_SIRTEST = 0x0004, /* allow SIR decode filter when not in SIR mode */
  253. IRCFG_TXPOL = 0x0002, /* invert tx polarity when set */
  254. IRCFG_RXPOL = 0x0001 /* invert rx polarity when set */
  255. };
  256. /* ------------------------------------------ */
  257. /* VLSI_PIO_SIRFLAG: SIR Flag Register (u16, ro) */
  258. /* register contains hardcoded BOF=0xc0 at [7:0] and EOF=0xc1 at [15:8]
  259.  * which is used for unwrapping received frames in SIR decode-filter mode
  260.  */
  261. /* ------------------------------------------ */
  262. /* VLSI_PIO_IRENABLE: IR Enable Register (u16, rw/ro) */
  263. /* notes:
  264.  * - IREN acts as gate for latching the configured IR mode information
  265.  *   from IRCFG and IRPHYCTL when IREN=reset and applying them when
  266.  *   IREN gets set afterwards.
  267.  * - ENTXST reflects IRCFG_ENTX
  268.  * - ENRXST = IRCFG_ENRX && (!IRCFG_ENTX || IRCFG_LOOP)
  269.  */
  270. enum vlsi_pio_irenable {
  271. IRENABLE_IREN = 0x8000,  /* enable IR phy and gate the mode config (rw) */
  272. IRENABLE_CFGER = 0x4000,  /* mode configuration error (ro) */
  273. IRENABLE_FIR_ON = 0x2000,  /* FIR on status (ro) */
  274. IRENABLE_MIR_ON = 0x1000,  /* MIR on status (ro) */
  275. IRENABLE_SIR_ON = 0x0800,  /* SIR on status (ro) */
  276. IRENABLE_ENTXST = 0x0400,  /* transmit enable status (ro) */
  277. IRENABLE_ENRXST = 0x0200,  /* Receive enable status (ro) */
  278. IRENABLE_CRC16_ON = 0x0100   /* 16bit (not 32bit) CRC enabled status (ro) */
  279. };
  280. #define   IRENABLE_MASK     0xff00  /* Read mask */
  281. /* ------------------------------------------ */
  282. /* VLSI_PIO_PHYCTL: IR Physical Layer Current Control Register (u16, ro) */
  283. /* read-back of the currently applied physical layer status.
  284.  * applied from VLSI_PIO_NPHYCTL at rising edge of IRENABLE_IREN
  285.  * contents identical to VLSI_PIO_NPHYCTL (see below)
  286.  */
  287. /* ------------------------------------------ */
  288. /* VLSI_PIO_NPHYCTL: IR Physical Layer Next Control Register (u16, rw) */
  289. /* latched during IRENABLE_IREN=0 and applied at 0-1 transition
  290.  *
  291.  * consists of BAUD[15:10], PLSWID[9:5] and PREAMB[4:0] bits defined as follows:
  292.  *
  293.  * SIR-mode: BAUD = (115.2kHz / baudrate) - 1
  294.  * PLSWID = (pulsetime * freq / (BAUD+1)) - 1
  295.  * where pulsetime is the requested IrPHY pulse width
  296.  * and freq is 8(16)MHz for 40(48)MHz primary input clock
  297.  * PREAMB: dont care for SIR
  298.  *
  299.  * The nominal SIR pulse width is 3/16 bit time so we have PLSWID=12
  300.  * fixed for all SIR speeds at 40MHz input clock (PLSWID=24 at 48MHz).
  301.  * IrPHY also allows shorter pulses down to the nominal pulse duration
  302.  * at 115.2kbaud (minus some tolerance) which is 1.41 usec.
  303.  * Using the expression PLSWID = 12/(BAUD+1)-1 (multiplied by to for 48MHz)
  304.  * we get the minimum acceptable PLSWID values according to the VLSI
  305.  * specification, which provides 1.5 usec pulse width for all speeds (except
  306.  * for 2.4kbaud getting 6usec). This is well inside IrPHY v1.3 specs and
  307.  * reduces the transceiver power which drains the battery. At 9.6kbaud for
  308.  * example this amounts to more than 90% battery power saving!
  309.  *
  310.  * MIR-mode: BAUD = 0
  311.  * PLSWID = 9(10) for 40(48) MHz input clock
  312.  * to get nominal MIR pulse width
  313.  * PREAMB = 1
  314.  *
  315.  * FIR-mode: BAUD = 0
  316.  * PLSWID: dont care
  317.  * PREAMB = 15
  318.  */
  319. #define BWP_TO_PHYCTL(B,W,P) ((((B)&0x3f)<<10) | (((W)&0x1f)<<5) | (((P)&0x1f)<<0))
  320. #define BAUD_BITS(br) ((115200/(br))-1)
  321. static inline unsigned
  322. calc_width_bits(unsigned baudrate, unsigned widthselect, unsigned clockselect)
  323. {
  324. unsigned tmp;
  325. if (widthselect) /* nominal 3/16 puls width */
  326. return (clockselect) ? 12 : 24;
  327. tmp = ((clockselect) ? 12 : 24) / (BAUD_BITS(baudrate)+1);
  328. /* intermediate result of integer division needed here */
  329. return (tmp>0) ? (tmp-1) : 0;
  330. }
  331. #define PHYCTL_SIR(br,ws,cs) BWP_TO_PHYCTL(BAUD_BITS(br),calc_width_bits((br),(ws),(cs)),0)
  332. #define PHYCTL_MIR(cs) BWP_TO_PHYCTL(0,((cs)?9:10),1)
  333. #define PHYCTL_FIR BWP_TO_PHYCTL(0,0,15)
  334. /* quite ugly, I know. But implementing these calculations here avoids
  335.  * having magic numbers in the code and allows some playing with pulsewidths
  336.  * without risk to violate the standards.
  337.  * FWIW, here is the table for reference:
  338.  *
  339.  * baudrate BAUD min-PLSWID nom-PLSWID PREAMB
  340.  *     2400   47    0(0)    12(24)    0
  341.  *     9600   11    0(0)    12(24)    0
  342.  *    19200    5    1(2)    12(24)    0
  343.  *    38400    2    3(6)            12(24)    0
  344.  *    57600    1    5(10)    12(24)    0
  345.  *   115200    0   11(22)    12(24)    0
  346.  * MIR    0     -     9(10)    1
  347.  * FIR    0        -               0   15
  348.  *
  349.  * note: x(y) means x-value for 40MHz / y-value for 48MHz primary input clock
  350.  */
  351. /* ------------------------------------------ */
  352. /* VLSI_PIO_MAXPKT: Maximum Packet Length register (u16, rw) */
  353. /* specifies the maximum legth (up to 4k - or (4k-1)? - bytes), which a
  354.  * received frame may have - i.e. the size of the corresponding
  355.  * receive buffers. For simplicity we use the same length for
  356.  * receive and submit buffers and increase transfer buffer size
  357.  * byond IrDA-MTU = 2048 so we have sufficient space left when
  358.  * packet size increases during wrapping due to XBOFs and CE's.
  359.  * Even for receiving unwrapped frames we need >MAX_PACKET_LEN
  360.  * space since the controller appends FCS/CRC (2 or 4 bytes)
  361.  * so we use 2*IrDA-MTU for both directions and cover even the
  362.  * worst case, where all data bytes have to be escaped when wrapping.
  363.  * well, this wastes some memory - anyway, later we will
  364.  * either map skb's directly or use pci_pool allocator...
  365.  */
  366.  
  367. #define IRDA_MTU 2048 /* seems to be undefined elsewhere */
  368.  
  369. #define XFER_BUF_SIZE (2*IRDA_MTU)
  370. #define MAX_PACKET_LENGTH (XFER_BUF_SIZE-1) /* register uses only [11:0] */
  371. /* ------------------------------------------ */
  372. /* VLSI_PIO_RCVBCNT: Receive Byte Count Register (u16, ro) */
  373. /* recive packet counter gets incremented on every non-filtered
  374.  * byte which was put in the receive fifo and reset for each
  375.  * new packet. Used to decide whether we are just in the middle
  376.  * of receiving
  377.  */
  378. #define RCVBCNT_MASK 0x0fff
  379. /* ================================================================ */
  380. /* descriptors for rx/tx ring
  381.  *
  382.  * accessed by hardware - don't change!
  383.  *
  384.  * the descriptor is owned by hardware, when the ACTIVE status bit
  385.  * is set and nothing (besides reading status to test the bit)
  386.  * shall be done. The bit gets cleared by hw, when the descriptor
  387.  * gets closed. Premature reaping of descriptors owned be the chip
  388.  * can be achieved by disabling IRCFG_MSTR
  389.  *
  390.  * Attention: Writing addr overwrites status!
  391.  *
  392.  * ### FIXME: we depend on endianess here
  393.  */
  394. struct ring_descr {
  395. volatile u16 rd_count; /* tx/rx count [11:0] */
  396. u16 reserved;
  397. union {
  398. u32 addr; /* [23:0] of the buffer's busaddress */
  399. struct {
  400. u8 addr_res[3];
  401. volatile u8 status; /* descriptor status */
  402. } rd_s;
  403. } rd_u;
  404. };
  405. #define rd_addr rd_u.addr
  406. #define rd_status rd_u.rd_s.status
  407. /* ring descriptor status bits */
  408. #define RD_STAT_ACTIVE 0x80 /* descriptor owned by hw (both TX,RX) */
  409. /* TX ring descriptor status */
  410. #define TX_STAT_DISCRC 0x40 /* do not send CRC (for SIR) */
  411. #define TX_STAT_BADCRC 0x20 /* force a bad CRC */
  412. #define TX_STAT_PULSE 0x10 /* send indication pulse after this frame (MIR/FIR) */
  413. #define TX_STAT_FRCEUND 0x08 /* force underrun */
  414. #define TX_STAT_CLRENTX 0x04 /* clear ENTX after this frame */
  415. #define TX_STAT_UNDRN 0x01 /* TX fifo underrun (probably PCI problem) */
  416. /* RX ring descriptor status */
  417. #define RX_STAT_PHYERR 0x40 /* physical encoding error */
  418. #define RX_STAT_CRCERR 0x20 /* CRC error (MIR/FIR) */
  419. #define RX_STAT_LENGTH 0x10 /* frame exceeds buffer length */
  420. #define RX_STAT_OVER 0x08 /* RX fifo overrun (probably PCI problem) */
  421. #define RX_STAT_SIRBAD 0x04 /* EOF missing: BOF follows BOF (SIR, filtered) */
  422. #define RX_STAT_ERROR 0x7c /* any error in frame */
  423. /* ------------------------------------------ */
  424. /* contains the objects we've put into the ring descriptors
  425.  * static buffers for now - probably skb's later
  426.  */
  427. struct ring_entry {
  428. struct sk_buff *skb;
  429. void *data;
  430. };
  431. struct vlsi_ring {
  432. unsigned size;
  433. unsigned mask;
  434. unsigned head, tail;
  435. struct ring_descr *hw;
  436. struct ring_entry buf[MAX_RING_DESCR];
  437. };
  438. /* ------------------------------------------ */
  439. /* our private compound VLSI-PCI-IRDA device information */
  440. typedef struct vlsi_irda_dev {
  441. struct pci_dev *pdev;
  442. struct net_device_stats stats;
  443. struct irlap_cb *irlap;
  444. struct qos_info qos;
  445. unsigned mode;
  446. int baud, new_baud;
  447. dma_addr_t busaddr;
  448. void *virtaddr;
  449. struct vlsi_ring tx_ring, rx_ring;
  450. struct timeval last_rx;
  451. spinlock_t lock;
  452. } vlsi_irda_dev_t;
  453. /********************************************************/
  454. #endif /* IRDA_VLSI_FIR_H */