blob: dfc78209e3a392feb33347f798345c338dc0917c [file] [log] [blame]
John W. Linvillef2223132006-01-23 16:59:58 -05001#ifndef BCM43xx_PIO_H_
2#define BCM43xx_PIO_H_
3
4#include "bcm43xx.h"
5
Michael Buesch77db31e2006-02-12 16:47:44 +01006#include <linux/interrupt.h>
John W. Linvillef2223132006-01-23 16:59:58 -05007#include <linux/list.h>
John W. Linvillef2223132006-01-23 16:59:58 -05008#include <linux/skbuff.h>
9
10
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
16
Michael Buesch7c241d32006-04-23 13:23:10 +020017#define BCM43xx_PIO_TXCTL_WRITELO (1 << 0)
18#define BCM43xx_PIO_TXCTL_WRITEHI (1 << 1)
John W. Linvillef2223132006-01-23 16:59:58 -050019#define BCM43xx_PIO_TXCTL_COMPLETE (1 << 2)
20#define BCM43xx_PIO_TXCTL_INIT (1 << 3)
21#define BCM43xx_PIO_TXCTL_SUSPEND (1 << 7)
22
23#define BCM43xx_PIO_RXCTL_DATAAVAILABLE (1 << 0)
24#define BCM43xx_PIO_RXCTL_READY (1 << 1)
25
26/* PIO constants */
27#define BCM43xx_PIO_MAXTXDEVQPACKETS 31
28#define BCM43xx_PIO_TXQADJUST 80
29
30/* PIO tuning knobs */
31#define BCM43xx_PIO_MAXTXPACKETS 256
32
33
Michael Buesch77db31e2006-02-12 16:47:44 +010034
35#ifdef CONFIG_BCM43XX_PIO
36
37
John W. Linvillef2223132006-01-23 16:59:58 -050038struct bcm43xx_pioqueue;
39struct bcm43xx_xmitstatus;
40
41struct bcm43xx_pio_txpacket {
42 struct bcm43xx_pioqueue *queue;
43 struct ieee80211_txb *txb;
44 struct list_head list;
45
46 u8 xmitted_frags;
47 u16 xmitted_octets;
48};
49
Michael Buesch77db31e2006-02-12 16:47:44 +010050#define pio_txpacket_getindex(packet) ((int)((packet) - (packet)->queue->tx_packets_cache))
John W. Linvillef2223132006-01-23 16:59:58 -050051
52struct bcm43xx_pioqueue {
53 struct bcm43xx_private *bcm;
54 u16 mmio_base;
55
Michael Buesch77db31e2006-02-12 16:47:44 +010056 u8 tx_suspended:1,
57 need_workarounds:1; /* Workarounds needed for core.rev < 3 */
John W. Linvillef2223132006-01-23 16:59:58 -050058
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.
67 */
68 struct list_head txfree;
Michael Buesch77db31e2006-02-12 16:47:44 +010069 unsigned int nr_txfree;
John W. Linvillef2223132006-01-23 16:59:58 -050070 /* Packets on the txqueue are queued,
71 * but not completely written to the chip, yet.
72 */
73 struct list_head txqueue;
74 /* Packets on the txrunning queue are completely
75 * posted to the device. We are waiting for the txstatus.
76 */
77 struct list_head txrunning;
Michael Buesch77db31e2006-02-12 16:47:44 +010078 /* Total number or packets sent.
79 * (This counter can obviously wrap).
80 */
81 unsigned int nr_tx_packets;
82 struct tasklet_struct txtask;
83 struct bcm43xx_pio_txpacket tx_packets_cache[BCM43xx_PIO_MAXTXPACKETS];
John W. Linvillef2223132006-01-23 16:59:58 -050084};
85
Michael Buesch77db31e2006-02-12 16:47:44 +010086static inline
87u16 bcm43xx_pio_read(struct bcm43xx_pioqueue *queue,
88 u16 offset)
89{
90 return bcm43xx_read16(queue->bcm, queue->mmio_base + offset);
91}
92
93static inline
94void bcm43xx_pio_write(struct bcm43xx_pioqueue *queue,
95 u16 offset, u16 value)
96{
97 bcm43xx_write16(queue->bcm, queue->mmio_base + offset, value);
Michael Buesch7c241d32006-04-23 13:23:10 +020098 mmiowb();
Michael Buesch77db31e2006-02-12 16:47:44 +010099}
100
101
John W. Linvillef2223132006-01-23 16:59:58 -0500102int bcm43xx_pio_init(struct bcm43xx_private *bcm);
103void bcm43xx_pio_free(struct bcm43xx_private *bcm);
104
Michael Buesch77db31e2006-02-12 16:47:44 +0100105int bcm43xx_pio_tx(struct bcm43xx_private *bcm,
106 struct ieee80211_txb *txb);
107void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm,
108 struct bcm43xx_xmitstatus *status);
109void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue);
John W. Linvillef2223132006-01-23 16:59:58 -0500110
Michael Buesch7c241d32006-04-23 13:23:10 +0200111void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue *queue);
112void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue *queue);
113
Michael Buesch77db31e2006-02-12 16:47:44 +0100114#else /* CONFIG_BCM43XX_PIO */
115
116static inline
117int bcm43xx_pio_init(struct bcm43xx_private *bcm)
118{
119 return 0;
120}
121static inline
122void bcm43xx_pio_free(struct bcm43xx_private *bcm)
123{
124}
125static inline
126int bcm43xx_pio_tx(struct bcm43xx_private *bcm,
127 struct ieee80211_txb *txb)
128{
129 return 0;
130}
131static inline
132void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm,
133 struct bcm43xx_xmitstatus *status)
134{
135}
136static inline
137void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue)
138{
139}
Michael Buesch7c241d32006-04-23 13:23:10 +0200140static inline
141void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue *queue)
142{
143}
144static inline
145void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue *queue)
146{
147}
Michael Buesch77db31e2006-02-12 16:47:44 +0100148
149#endif /* CONFIG_BCM43XX_PIO */
John W. Linvillef2223132006-01-23 16:59:58 -0500150#endif /* BCM43xx_PIO_H_ */