1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef B43legacy_PIO_H_
3 #define B43legacy_PIO_H_
7 #include <linux/interrupt.h>
8 #include <linux/list.h>
9 #include <linux/skbuff.h>
12 #define B43legacy_PIO_TXCTL 0x00
13 #define B43legacy_PIO_TXDATA 0x02
14 #define B43legacy_PIO_TXQBUFSIZE 0x04
15 #define B43legacy_PIO_RXCTL 0x08
16 #define B43legacy_PIO_RXDATA 0x0A
18 #define B43legacy_PIO_TXCTL_WRITELO (1 << 0)
19 #define B43legacy_PIO_TXCTL_WRITEHI (1 << 1)
20 #define B43legacy_PIO_TXCTL_COMPLETE (1 << 2)
21 #define B43legacy_PIO_TXCTL_INIT (1 << 3)
22 #define B43legacy_PIO_TXCTL_SUSPEND (1 << 7)
24 #define B43legacy_PIO_RXCTL_DATAAVAILABLE (1 << 0)
25 #define B43legacy_PIO_RXCTL_READY (1 << 1)
28 #define B43legacy_PIO_MAXTXDEVQPACKETS 31
29 #define B43legacy_PIO_TXQADJUST 80
31 /* PIO tuning knobs */
32 #define B43legacy_PIO_MAXTXPACKETS 256
36 #ifdef CONFIG_B43LEGACY_PIO
39 struct b43legacy_pioqueue
;
40 struct b43legacy_xmitstatus
;
42 struct b43legacy_pio_txpacket
{
43 struct b43legacy_pioqueue
*queue
;
45 struct list_head list
;
48 #define pio_txpacket_getindex(packet) ((int)((packet) - \
49 (packet)->queue->tx_packets_cache))
51 struct b43legacy_pioqueue
{
52 struct b43legacy_wldev
*dev
;
57 bool need_workarounds
; /* Workarounds needed for core.rev < 3 */
59 /* Adjusted size of the device internal TX buffer. */
61 /* Used octets of the device internal TX buffer. */
63 /* Used packet slots in the device internal TX buffer. */
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 struct tasklet_struct txtask
;
79 struct b43legacy_pio_txpacket
80 tx_packets_cache
[B43legacy_PIO_MAXTXPACKETS
];
84 u16
b43legacy_pio_read(struct b43legacy_pioqueue
*queue
,
87 return b43legacy_read16(queue
->dev
, queue
->mmio_base
+ offset
);
91 void b43legacy_pio_write(struct b43legacy_pioqueue
*queue
,
92 u16 offset
, u16 value
)
94 b43legacy_write16(queue
->dev
, queue
->mmio_base
+ offset
, value
);
98 int b43legacy_pio_init(struct b43legacy_wldev
*dev
);
99 void b43legacy_pio_free(struct b43legacy_wldev
*dev
);
101 int b43legacy_pio_tx(struct b43legacy_wldev
*dev
,
102 struct sk_buff
*skb
);
103 void b43legacy_pio_handle_txstatus(struct b43legacy_wldev
*dev
,
104 const struct b43legacy_txstatus
*status
);
105 void b43legacy_pio_rx(struct b43legacy_pioqueue
*queue
);
107 /* Suspend TX queue in hardware. */
108 void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue
*queue
);
109 void b43legacy_pio_tx_resume(struct b43legacy_pioqueue
*queue
);
110 /* Suspend (freeze) the TX tasklet (software level). */
111 void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev
*dev
);
112 void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev
*dev
);
114 #else /* CONFIG_B43LEGACY_PIO */
117 int b43legacy_pio_init(struct b43legacy_wldev
*dev
)
122 void b43legacy_pio_free(struct b43legacy_wldev
*dev
)
126 int b43legacy_pio_tx(struct b43legacy_wldev
*dev
,
132 void b43legacy_pio_handle_txstatus(struct b43legacy_wldev
*dev
,
133 const struct b43legacy_txstatus
*status
)
137 void b43legacy_pio_rx(struct b43legacy_pioqueue
*queue
)
141 void b43legacy_pio_tx_suspend(struct b43legacy_pioqueue
*queue
)
145 void b43legacy_pio_tx_resume(struct b43legacy_pioqueue
*queue
)
149 void b43legacy_pio_freeze_txqueues(struct b43legacy_wldev
*dev
)
153 void b43legacy_pio_thaw_txqueues(struct b43legacy_wldev
*dev
)
157 #endif /* CONFIG_B43LEGACY_PIO */
158 #endif /* B43legacy_PIO_H_ */