[PATCH] bcm43xx: Partially fix PIO code. Add Kconfig option for PIO or DMA mode ...
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / net / wireless / bcm43xx / bcm43xx_pio.h
blob970627bc1769acc285adc0ee04f33dcf6b2f6d94
1 #ifndef BCM43xx_PIO_H_
2 #define BCM43xx_PIO_H_
4 #include "bcm43xx.h"
6 #include <linux/interrupt.h>
7 #include <linux/list.h>
8 #include <linux/skbuff.h>
11 #define BCM43xx_PIO_TXCTL 0x00
12 #define BCM43xx_PIO_TXDATA 0x02
13 #define BCM43xx_PIO_TXQBUFSIZE 0x04
14 #define BCM43xx_PIO_RXCTL 0x08
15 #define BCM43xx_PIO_RXDATA 0x0A
17 #define BCM43xx_PIO_TXCTL_WRITEHI (1 << 0)
18 #define BCM43xx_PIO_TXCTL_WRITELO (1 << 1)
19 #define BCM43xx_PIO_TXCTL_COMPLETE (1 << 2)
20 #define BCM43xx_PIO_TXCTL_INIT (1 << 3)
21 #define BCM43xx_PIO_TXCTL_SUSPEND (1 << 7)
23 #define BCM43xx_PIO_RXCTL_DATAAVAILABLE (1 << 0)
24 #define BCM43xx_PIO_RXCTL_READY (1 << 1)
26 /* PIO constants */
27 #define BCM43xx_PIO_MAXTXDEVQPACKETS 31
28 #define BCM43xx_PIO_TXQADJUST 80
30 /* PIO tuning knobs */
31 #define BCM43xx_PIO_MAXTXPACKETS 256
35 #ifdef CONFIG_BCM43XX_PIO
38 struct bcm43xx_pioqueue;
39 struct bcm43xx_xmitstatus;
41 struct bcm43xx_pio_txpacket {
42 struct bcm43xx_pioqueue *queue;
43 struct ieee80211_txb *txb;
44 struct list_head list;
46 u8 xmitted_frags;
47 u16 xmitted_octets;
50 #define pio_txpacket_getindex(packet) ((int)((packet) - (packet)->queue->tx_packets_cache))
52 struct bcm43xx_pioqueue {
53 struct bcm43xx_private *bcm;
54 u16 mmio_base;
56 u8 tx_suspended:1,
57 need_workarounds:1; /* Workarounds needed for core.rev < 3 */
59 /* Adjusted size of the device internal TX buffer. */
60 u16 tx_devq_size;
61 /* Used octets of the device internal TX buffer. */
62 u16 tx_devq_used;
63 /* Used packet slots in the device internal TX buffer. */
64 u8 tx_devq_packets;
65 /* Packets from the txfree list can
66 * be taken on incoming TX requests.
68 struct list_head txfree;
69 unsigned int nr_txfree;
70 /* Packets on the txqueue are queued,
71 * but not completely written to the chip, yet.
73 struct list_head txqueue;
74 /* Packets on the txrunning queue are completely
75 * posted to the device. We are waiting for the txstatus.
77 struct list_head txrunning;
78 /* Total number or packets sent.
79 * (This counter can obviously wrap).
81 unsigned int nr_tx_packets;
82 struct tasklet_struct txtask;
83 struct bcm43xx_pio_txpacket tx_packets_cache[BCM43xx_PIO_MAXTXPACKETS];
86 static inline
87 u16 bcm43xx_pio_read(struct bcm43xx_pioqueue *queue,
88 u16 offset)
90 return bcm43xx_read16(queue->bcm, queue->mmio_base + offset);
93 static inline
94 void bcm43xx_pio_write(struct bcm43xx_pioqueue *queue,
95 u16 offset, u16 value)
97 bcm43xx_write16(queue->bcm, queue->mmio_base + offset, value);
101 int bcm43xx_pio_init(struct bcm43xx_private *bcm);
102 void bcm43xx_pio_free(struct bcm43xx_private *bcm);
104 int bcm43xx_pio_tx(struct bcm43xx_private *bcm,
105 struct ieee80211_txb *txb);
106 void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm,
107 struct bcm43xx_xmitstatus *status);
108 void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue);
110 #else /* CONFIG_BCM43XX_PIO */
112 static inline
113 int bcm43xx_pio_init(struct bcm43xx_private *bcm)
115 return 0;
117 static inline
118 void bcm43xx_pio_free(struct bcm43xx_private *bcm)
121 static inline
122 int bcm43xx_pio_tx(struct bcm43xx_private *bcm,
123 struct ieee80211_txb *txb)
125 return 0;
127 static inline
128 void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm,
129 struct bcm43xx_xmitstatus *status)
132 static inline
133 void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue)
137 #endif /* CONFIG_BCM43XX_PIO */
138 #endif /* BCM43xx_PIO_H_ */