Staging: unisys: Remove RETINT macro
[linux/fpc-iii.git] / drivers / net / wireless / brcm80211 / brcmfmac / dhd_bus.h
blobc4535616064e8389125b238a50fcc74d3c6d47da
1 /*
2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef _BRCMF_BUS_H_
18 #define _BRCMF_BUS_H_
20 #include "dhd_dbg.h"
22 /* The level of bus communication with the dongle */
23 enum brcmf_bus_state {
24 BRCMF_BUS_UNKNOWN, /* Not determined yet */
25 BRCMF_BUS_NOMEDIUM, /* No medium access to dongle */
26 BRCMF_BUS_DOWN, /* Not ready for frame transfers */
27 BRCMF_BUS_LOAD, /* Download access only (CPU reset) */
28 BRCMF_BUS_DATA /* Ready for frame transfers */
31 /* The level of bus communication with the dongle */
32 enum brcmf_bus_protocol_type {
33 BRCMF_PROTO_BCDC,
34 BRCMF_PROTO_MSGBUF
37 struct brcmf_bus_dcmd {
38 char *name;
39 char *param;
40 int param_len;
41 struct list_head list;
44 /**
45 * struct brcmf_bus_ops - bus callback operations.
47 * @preinit: execute bus/device specific dongle init commands (optional).
48 * @init: prepare for communication with dongle.
49 * @stop: clear pending frames, disable data flow.
50 * @txdata: send a data frame to the dongle. When the data
51 * has been transferred, the common driver must be
52 * notified using brcmf_txcomplete(). The common
53 * driver calls this function with interrupts
54 * disabled.
55 * @txctl: transmit a control request message to dongle.
56 * @rxctl: receive a control response message from dongle.
57 * @gettxq: obtain a reference of bus transmit queue (optional).
59 * This structure provides an abstract interface towards the
60 * bus specific driver. For control messages to common driver
61 * will assure there is only one active transaction. Unless
62 * indicated otherwise these callbacks are mandatory.
64 struct brcmf_bus_ops {
65 int (*preinit)(struct device *dev);
66 int (*init)(struct device *dev);
67 void (*stop)(struct device *dev);
68 int (*txdata)(struct device *dev, struct sk_buff *skb);
69 int (*txctl)(struct device *dev, unsigned char *msg, uint len);
70 int (*rxctl)(struct device *dev, unsigned char *msg, uint len);
71 struct pktq * (*gettxq)(struct device *dev);
74 /**
75 * struct brcmf_bus - interface structure between common and bus layer
77 * @bus_priv: pointer to private bus device.
78 * @proto_type: protocol type, bcdc or msgbuf
79 * @dev: device pointer of bus device.
80 * @drvr: public driver information.
81 * @state: operational state of the bus interface.
82 * @maxctl: maximum size for rxctl request message.
83 * @tx_realloc: number of tx packets realloced for headroom.
84 * @dstats: dongle-based statistical data.
85 * @dcmd_list: bus/device specific dongle initialization commands.
86 * @chip: device identifier of the dongle chip.
87 * @chiprev: revision of the dongle chip.
89 struct brcmf_bus {
90 union {
91 struct brcmf_sdio_dev *sdio;
92 struct brcmf_usbdev *usb;
93 } bus_priv;
94 enum brcmf_bus_protocol_type proto_type;
95 struct device *dev;
96 struct brcmf_pub *drvr;
97 enum brcmf_bus_state state;
98 uint maxctl;
99 unsigned long tx_realloc;
100 u32 chip;
101 u32 chiprev;
103 struct brcmf_bus_ops *ops;
107 * callback wrappers
109 static inline int brcmf_bus_preinit(struct brcmf_bus *bus)
111 if (!bus->ops->preinit)
112 return 0;
113 return bus->ops->preinit(bus->dev);
116 static inline int brcmf_bus_init(struct brcmf_bus *bus)
118 return bus->ops->init(bus->dev);
121 static inline void brcmf_bus_stop(struct brcmf_bus *bus)
123 bus->ops->stop(bus->dev);
126 static inline int brcmf_bus_txdata(struct brcmf_bus *bus, struct sk_buff *skb)
128 return bus->ops->txdata(bus->dev, skb);
131 static inline
132 int brcmf_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
134 return bus->ops->txctl(bus->dev, msg, len);
137 static inline
138 int brcmf_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
140 return bus->ops->rxctl(bus->dev, msg, len);
143 static inline
144 struct pktq *brcmf_bus_gettxq(struct brcmf_bus *bus)
146 if (!bus->ops->gettxq)
147 return ERR_PTR(-ENOENT);
149 return bus->ops->gettxq(bus->dev);
152 static inline bool brcmf_bus_ready(struct brcmf_bus *bus)
154 return bus->state == BRCMF_BUS_LOAD || bus->state == BRCMF_BUS_DATA;
157 static inline void brcmf_bus_change_state(struct brcmf_bus *bus,
158 enum brcmf_bus_state new_state)
160 /* NOMEDIUM is permanent */
161 if (bus->state == BRCMF_BUS_NOMEDIUM)
162 return;
164 brcmf_dbg(TRACE, "%d -> %d\n", bus->state, new_state);
165 bus->state = new_state;
169 * interface functions from common layer
172 bool brcmf_c_prec_enq(struct device *dev, struct pktq *q, struct sk_buff *pkt,
173 int prec);
175 /* Receive frame for delivery to OS. Callee disposes of rxp. */
176 void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp);
178 /* Indication from bus module regarding presence/insertion of dongle. */
179 int brcmf_attach(struct device *dev);
180 /* Indication from bus module regarding removal/absence of dongle */
181 void brcmf_detach(struct device *dev);
182 /* Indication from bus module that dongle should be reset */
183 void brcmf_dev_reset(struct device *dev);
184 /* Indication from bus module to change flow-control state */
185 void brcmf_txflowblock(struct device *dev, bool state);
187 /* Notify the bus has transferred the tx packet to firmware */
188 void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, bool success);
190 int brcmf_bus_start(struct device *dev);
191 s32 brcmf_iovar_data_set(struct device *dev, char *name, void *data,
192 u32 len);
193 void brcmf_bus_add_txhdrlen(struct device *dev, uint len);
195 #ifdef CONFIG_BRCMFMAC_SDIO
196 void brcmf_sdio_exit(void);
197 void brcmf_sdio_init(void);
198 void brcmf_sdio_register(void);
199 #endif
200 #ifdef CONFIG_BRCMFMAC_USB
201 void brcmf_usb_exit(void);
202 void brcmf_usb_register(void);
203 #endif
205 #endif /* _BRCMF_BUS_H_ */