John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 1 | #ifndef BCM43xx_PIO_H_ |
| 2 | #define BCM43xx_PIO_H_ |
| 3 | |
| 4 | #include "bcm43xx.h" |
| 5 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 6 | #include <linux/interrupt.h> |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 7 | #include <linux/list.h> |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 8 | #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 Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 17 | #define BCM43xx_PIO_TXCTL_WRITELO (1 << 0) |
| 18 | #define BCM43xx_PIO_TXCTL_WRITEHI (1 << 1) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 19 | #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 Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 34 | |
| 35 | #ifdef CONFIG_BCM43XX_PIO |
| 36 | |
| 37 | |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 38 | struct bcm43xx_pioqueue; |
| 39 | struct bcm43xx_xmitstatus; |
| 40 | |
| 41 | struct 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 Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 50 | #define pio_txpacket_getindex(packet) ((int)((packet) - (packet)->queue->tx_packets_cache)) |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 51 | |
| 52 | struct bcm43xx_pioqueue { |
| 53 | struct bcm43xx_private *bcm; |
| 54 | u16 mmio_base; |
| 55 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 56 | u8 tx_suspended:1, |
Michael Buesch | 91769e7 | 2006-06-05 20:24:21 +0200 | [diff] [blame] | 57 | tx_frozen:1, |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 58 | need_workarounds:1; /* Workarounds needed for core.rev < 3 */ |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 59 | |
| 60 | /* Adjusted size of the device internal TX buffer. */ |
| 61 | u16 tx_devq_size; |
| 62 | /* Used octets of the device internal TX buffer. */ |
| 63 | u16 tx_devq_used; |
| 64 | /* Used packet slots in the device internal TX buffer. */ |
| 65 | u8 tx_devq_packets; |
| 66 | /* Packets from the txfree list can |
| 67 | * be taken on incoming TX requests. |
| 68 | */ |
| 69 | struct list_head txfree; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 70 | unsigned int nr_txfree; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 71 | /* Packets on the txqueue are queued, |
| 72 | * but not completely written to the chip, yet. |
| 73 | */ |
| 74 | struct list_head txqueue; |
| 75 | /* Packets on the txrunning queue are completely |
| 76 | * posted to the device. We are waiting for the txstatus. |
| 77 | */ |
| 78 | struct list_head txrunning; |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 79 | /* Total number or packets sent. |
| 80 | * (This counter can obviously wrap). |
| 81 | */ |
| 82 | unsigned int nr_tx_packets; |
| 83 | struct tasklet_struct txtask; |
| 84 | struct bcm43xx_pio_txpacket tx_packets_cache[BCM43xx_PIO_MAXTXPACKETS]; |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 85 | }; |
| 86 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 87 | static inline |
| 88 | u16 bcm43xx_pio_read(struct bcm43xx_pioqueue *queue, |
| 89 | u16 offset) |
| 90 | { |
| 91 | return bcm43xx_read16(queue->bcm, queue->mmio_base + offset); |
| 92 | } |
| 93 | |
| 94 | static inline |
| 95 | void bcm43xx_pio_write(struct bcm43xx_pioqueue *queue, |
| 96 | u16 offset, u16 value) |
| 97 | { |
| 98 | bcm43xx_write16(queue->bcm, queue->mmio_base + offset, value); |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 99 | mmiowb(); |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 103 | int bcm43xx_pio_init(struct bcm43xx_private *bcm); |
| 104 | void bcm43xx_pio_free(struct bcm43xx_private *bcm); |
| 105 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 106 | int bcm43xx_pio_tx(struct bcm43xx_private *bcm, |
| 107 | struct ieee80211_txb *txb); |
| 108 | void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm, |
| 109 | struct bcm43xx_xmitstatus *status); |
| 110 | void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue); |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 111 | |
Michael Buesch | 91769e7 | 2006-06-05 20:24:21 +0200 | [diff] [blame] | 112 | /* Suspend a TX queue on hardware level. */ |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 113 | void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue *queue); |
| 114 | void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue *queue); |
Michael Buesch | 91769e7 | 2006-06-05 20:24:21 +0200 | [diff] [blame] | 115 | /* Suspend (freeze) the TX tasklet (software level). */ |
| 116 | void bcm43xx_pio_freeze_txqueues(struct bcm43xx_private *bcm); |
| 117 | void bcm43xx_pio_thaw_txqueues(struct bcm43xx_private *bcm); |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 118 | |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 119 | #else /* CONFIG_BCM43XX_PIO */ |
| 120 | |
| 121 | static inline |
| 122 | int bcm43xx_pio_init(struct bcm43xx_private *bcm) |
| 123 | { |
| 124 | return 0; |
| 125 | } |
| 126 | static inline |
| 127 | void bcm43xx_pio_free(struct bcm43xx_private *bcm) |
| 128 | { |
| 129 | } |
| 130 | static inline |
| 131 | int bcm43xx_pio_tx(struct bcm43xx_private *bcm, |
| 132 | struct ieee80211_txb *txb) |
| 133 | { |
| 134 | return 0; |
| 135 | } |
| 136 | static inline |
| 137 | void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm, |
| 138 | struct bcm43xx_xmitstatus *status) |
| 139 | { |
| 140 | } |
| 141 | static inline |
| 142 | void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue) |
| 143 | { |
| 144 | } |
Michael Buesch | 7c241d3 | 2006-04-23 13:23:10 +0200 | [diff] [blame] | 145 | static inline |
| 146 | void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue *queue) |
| 147 | { |
| 148 | } |
| 149 | static inline |
| 150 | void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue *queue) |
| 151 | { |
| 152 | } |
Michael Buesch | 91769e7 | 2006-06-05 20:24:21 +0200 | [diff] [blame] | 153 | static inline |
| 154 | void bcm43xx_pio_freeze_txqueues(struct bcm43xx_private *bcm) |
| 155 | { |
| 156 | } |
| 157 | static inline |
| 158 | void bcm43xx_pio_thaw_txqueues(struct bcm43xx_private *bcm) |
| 159 | { |
| 160 | } |
Michael Buesch | 77db31e | 2006-02-12 16:47:44 +0100 | [diff] [blame] | 161 | |
| 162 | #endif /* CONFIG_BCM43XX_PIO */ |
John W. Linville | f222313 | 2006-01-23 16:59:58 -0500 | [diff] [blame] | 163 | #endif /* BCM43xx_PIO_H_ */ |