xref: /freebsd/sys/contrib/dev/broadcom/brcm80211/brcmfmac/bus.h (revision b4c3e9b5b09c829b4135aff738bd2893ed052377)
1*b4c3e9b5SBjoern A. Zeeb // SPDX-License-Identifier: ISC
2*b4c3e9b5SBjoern A. Zeeb /*
3*b4c3e9b5SBjoern A. Zeeb  * Copyright (c) 2010 Broadcom Corporation
4*b4c3e9b5SBjoern A. Zeeb  */
5*b4c3e9b5SBjoern A. Zeeb 
6*b4c3e9b5SBjoern A. Zeeb #ifndef BRCMFMAC_BUS_H
7*b4c3e9b5SBjoern A. Zeeb #define BRCMFMAC_BUS_H
8*b4c3e9b5SBjoern A. Zeeb 
9*b4c3e9b5SBjoern A. Zeeb #include <linux/kernel.h>
10*b4c3e9b5SBjoern A. Zeeb #include <linux/firmware.h>
11*b4c3e9b5SBjoern A. Zeeb #include <linux/device.h>
12*b4c3e9b5SBjoern A. Zeeb #include "debug.h"
13*b4c3e9b5SBjoern A. Zeeb 
14*b4c3e9b5SBjoern A. Zeeb /* IDs of the 6 default common rings of msgbuf protocol */
15*b4c3e9b5SBjoern A. Zeeb #define BRCMF_H2D_MSGRING_CONTROL_SUBMIT	0
16*b4c3e9b5SBjoern A. Zeeb #define BRCMF_H2D_MSGRING_RXPOST_SUBMIT		1
17*b4c3e9b5SBjoern A. Zeeb #define BRCMF_H2D_MSGRING_FLOWRING_IDSTART	2
18*b4c3e9b5SBjoern A. Zeeb #define BRCMF_D2H_MSGRING_CONTROL_COMPLETE	2
19*b4c3e9b5SBjoern A. Zeeb #define BRCMF_D2H_MSGRING_TX_COMPLETE		3
20*b4c3e9b5SBjoern A. Zeeb #define BRCMF_D2H_MSGRING_RX_COMPLETE		4
21*b4c3e9b5SBjoern A. Zeeb 
22*b4c3e9b5SBjoern A. Zeeb 
23*b4c3e9b5SBjoern A. Zeeb #define BRCMF_NROF_H2D_COMMON_MSGRINGS		2
24*b4c3e9b5SBjoern A. Zeeb #define BRCMF_NROF_D2H_COMMON_MSGRINGS		3
25*b4c3e9b5SBjoern A. Zeeb #define BRCMF_NROF_COMMON_MSGRINGS	(BRCMF_NROF_H2D_COMMON_MSGRINGS + \
26*b4c3e9b5SBjoern A. Zeeb 					 BRCMF_NROF_D2H_COMMON_MSGRINGS)
27*b4c3e9b5SBjoern A. Zeeb 
28*b4c3e9b5SBjoern A. Zeeb /* The interval to poll console */
29*b4c3e9b5SBjoern A. Zeeb #define BRCMF_CONSOLE	10
30*b4c3e9b5SBjoern A. Zeeb 
31*b4c3e9b5SBjoern A. Zeeb /* The maximum console interval value (5 mins) */
32*b4c3e9b5SBjoern A. Zeeb #define MAX_CONSOLE_INTERVAL	(5 * 60)
33*b4c3e9b5SBjoern A. Zeeb 
34*b4c3e9b5SBjoern A. Zeeb enum brcmf_fwvendor {
35*b4c3e9b5SBjoern A. Zeeb 	BRCMF_FWVENDOR_WCC,
36*b4c3e9b5SBjoern A. Zeeb 	BRCMF_FWVENDOR_CYW,
37*b4c3e9b5SBjoern A. Zeeb 	BRCMF_FWVENDOR_BCA,
38*b4c3e9b5SBjoern A. Zeeb 	/* keep last */
39*b4c3e9b5SBjoern A. Zeeb 	BRCMF_FWVENDOR_NUM,
40*b4c3e9b5SBjoern A. Zeeb 	BRCMF_FWVENDOR_INVALID
41*b4c3e9b5SBjoern A. Zeeb };
42*b4c3e9b5SBjoern A. Zeeb 
43*b4c3e9b5SBjoern A. Zeeb /* The level of bus communication with the dongle */
44*b4c3e9b5SBjoern A. Zeeb enum brcmf_bus_state {
45*b4c3e9b5SBjoern A. Zeeb 	BRCMF_BUS_DOWN,		/* Not ready for frame transfers */
46*b4c3e9b5SBjoern A. Zeeb 	BRCMF_BUS_UP		/* Ready for frame transfers */
47*b4c3e9b5SBjoern A. Zeeb };
48*b4c3e9b5SBjoern A. Zeeb 
49*b4c3e9b5SBjoern A. Zeeb /* The level of bus communication with the dongle */
50*b4c3e9b5SBjoern A. Zeeb enum brcmf_bus_protocol_type {
51*b4c3e9b5SBjoern A. Zeeb 	BRCMF_PROTO_BCDC,
52*b4c3e9b5SBjoern A. Zeeb 	BRCMF_PROTO_MSGBUF
53*b4c3e9b5SBjoern A. Zeeb };
54*b4c3e9b5SBjoern A. Zeeb 
55*b4c3e9b5SBjoern A. Zeeb /* Firmware blobs that may be available */
56*b4c3e9b5SBjoern A. Zeeb enum brcmf_blob_type {
57*b4c3e9b5SBjoern A. Zeeb 	BRCMF_BLOB_CLM,
58*b4c3e9b5SBjoern A. Zeeb 	BRCMF_BLOB_TXCAP,
59*b4c3e9b5SBjoern A. Zeeb };
60*b4c3e9b5SBjoern A. Zeeb 
61*b4c3e9b5SBjoern A. Zeeb struct brcmf_mp_device;
62*b4c3e9b5SBjoern A. Zeeb 
63*b4c3e9b5SBjoern A. Zeeb struct brcmf_bus_dcmd {
64*b4c3e9b5SBjoern A. Zeeb 	char *name;
65*b4c3e9b5SBjoern A. Zeeb 	char *param;
66*b4c3e9b5SBjoern A. Zeeb 	int param_len;
67*b4c3e9b5SBjoern A. Zeeb 	struct list_head list;
68*b4c3e9b5SBjoern A. Zeeb };
69*b4c3e9b5SBjoern A. Zeeb 
70*b4c3e9b5SBjoern A. Zeeb /**
71*b4c3e9b5SBjoern A. Zeeb  * struct brcmf_bus_ops - bus callback operations.
72*b4c3e9b5SBjoern A. Zeeb  *
73*b4c3e9b5SBjoern A. Zeeb  * @preinit: execute bus/device specific dongle init commands (optional).
74*b4c3e9b5SBjoern A. Zeeb  * @init: prepare for communication with dongle.
75*b4c3e9b5SBjoern A. Zeeb  * @stop: clear pending frames, disable data flow.
76*b4c3e9b5SBjoern A. Zeeb  * @txdata: send a data frame to the dongle. When the data
77*b4c3e9b5SBjoern A. Zeeb  *	has been transferred, the common driver must be
78*b4c3e9b5SBjoern A. Zeeb  *	notified using brcmf_txcomplete(). The common
79*b4c3e9b5SBjoern A. Zeeb  *	driver calls this function with interrupts
80*b4c3e9b5SBjoern A. Zeeb  *	disabled.
81*b4c3e9b5SBjoern A. Zeeb  * @txctl: transmit a control request message to dongle.
82*b4c3e9b5SBjoern A. Zeeb  * @rxctl: receive a control response message from dongle.
83*b4c3e9b5SBjoern A. Zeeb  * @gettxq: obtain a reference of bus transmit queue (optional).
84*b4c3e9b5SBjoern A. Zeeb  * @wowl_config: specify if dongle is configured for wowl when going to suspend
85*b4c3e9b5SBjoern A. Zeeb  * @get_ramsize: obtain size of device memory.
86*b4c3e9b5SBjoern A. Zeeb  * @get_memdump: obtain device memory dump in provided buffer.
87*b4c3e9b5SBjoern A. Zeeb  * @get_blob: obtain a firmware blob.
88*b4c3e9b5SBjoern A. Zeeb  * @remove: initiate unbind of the device.
89*b4c3e9b5SBjoern A. Zeeb  *
90*b4c3e9b5SBjoern A. Zeeb  * This structure provides an abstract interface towards the
91*b4c3e9b5SBjoern A. Zeeb  * bus specific driver. For control messages to common driver
92*b4c3e9b5SBjoern A. Zeeb  * will assure there is only one active transaction. Unless
93*b4c3e9b5SBjoern A. Zeeb  * indicated otherwise these callbacks are mandatory.
94*b4c3e9b5SBjoern A. Zeeb  */
95*b4c3e9b5SBjoern A. Zeeb struct brcmf_bus_ops {
96*b4c3e9b5SBjoern A. Zeeb 	int (*preinit)(struct device *dev);
97*b4c3e9b5SBjoern A. Zeeb 	void (*stop)(struct device *dev);
98*b4c3e9b5SBjoern A. Zeeb 	int (*txdata)(struct device *dev, struct sk_buff *skb);
99*b4c3e9b5SBjoern A. Zeeb 	int (*txctl)(struct device *dev, unsigned char *msg, uint len);
100*b4c3e9b5SBjoern A. Zeeb 	int (*rxctl)(struct device *dev, unsigned char *msg, uint len);
101*b4c3e9b5SBjoern A. Zeeb 	struct pktq * (*gettxq)(struct device *dev);
102*b4c3e9b5SBjoern A. Zeeb 	void (*wowl_config)(struct device *dev, bool enabled);
103*b4c3e9b5SBjoern A. Zeeb 	size_t (*get_ramsize)(struct device *dev);
104*b4c3e9b5SBjoern A. Zeeb 	int (*get_memdump)(struct device *dev, void *data, size_t len);
105*b4c3e9b5SBjoern A. Zeeb 	int (*get_blob)(struct device *dev, const struct firmware **fw,
106*b4c3e9b5SBjoern A. Zeeb 			enum brcmf_blob_type type);
107*b4c3e9b5SBjoern A. Zeeb 	void (*debugfs_create)(struct device *dev);
108*b4c3e9b5SBjoern A. Zeeb 	int (*reset)(struct device *dev);
109*b4c3e9b5SBjoern A. Zeeb 	void (*remove)(struct device *dev);
110*b4c3e9b5SBjoern A. Zeeb };
111*b4c3e9b5SBjoern A. Zeeb 
112*b4c3e9b5SBjoern A. Zeeb 
113*b4c3e9b5SBjoern A. Zeeb /**
114*b4c3e9b5SBjoern A. Zeeb  * struct brcmf_bus_msgbuf - bus ringbuf if in case of msgbuf.
115*b4c3e9b5SBjoern A. Zeeb  *
116*b4c3e9b5SBjoern A. Zeeb  * @commonrings: commonrings which are always there.
117*b4c3e9b5SBjoern A. Zeeb  * @flowrings: commonrings which are dynamically created and destroyed for data.
118*b4c3e9b5SBjoern A. Zeeb  * @rx_dataoffset: if set then all rx data has this offset.
119*b4c3e9b5SBjoern A. Zeeb  * @max_rxbufpost: maximum number of buffers to post for rx.
120*b4c3e9b5SBjoern A. Zeeb  * @max_flowrings: maximum number of tx flow rings supported.
121*b4c3e9b5SBjoern A. Zeeb  * @max_submissionrings: maximum number of submission rings(h2d) supported.
122*b4c3e9b5SBjoern A. Zeeb  * @max_completionrings: maximum number of completion rings(d2h) supported.
123*b4c3e9b5SBjoern A. Zeeb  */
124*b4c3e9b5SBjoern A. Zeeb struct brcmf_bus_msgbuf {
125*b4c3e9b5SBjoern A. Zeeb 	struct brcmf_commonring *commonrings[BRCMF_NROF_COMMON_MSGRINGS];
126*b4c3e9b5SBjoern A. Zeeb 	struct brcmf_commonring **flowrings;
127*b4c3e9b5SBjoern A. Zeeb 	u32 rx_dataoffset;
128*b4c3e9b5SBjoern A. Zeeb 	u32 max_rxbufpost;
129*b4c3e9b5SBjoern A. Zeeb 	u16 max_flowrings;
130*b4c3e9b5SBjoern A. Zeeb 	u16 max_submissionrings;
131*b4c3e9b5SBjoern A. Zeeb 	u16 max_completionrings;
132*b4c3e9b5SBjoern A. Zeeb };
133*b4c3e9b5SBjoern A. Zeeb 
134*b4c3e9b5SBjoern A. Zeeb 
135*b4c3e9b5SBjoern A. Zeeb /**
136*b4c3e9b5SBjoern A. Zeeb  * struct brcmf_bus_stats - bus statistic counters.
137*b4c3e9b5SBjoern A. Zeeb  *
138*b4c3e9b5SBjoern A. Zeeb  * @pktcowed: packets cowed for extra headroom/unorphan.
139*b4c3e9b5SBjoern A. Zeeb  * @pktcow_failed: packets dropped due to failed cow-ing.
140*b4c3e9b5SBjoern A. Zeeb  */
141*b4c3e9b5SBjoern A. Zeeb struct brcmf_bus_stats {
142*b4c3e9b5SBjoern A. Zeeb 	atomic_t pktcowed;
143*b4c3e9b5SBjoern A. Zeeb 	atomic_t pktcow_failed;
144*b4c3e9b5SBjoern A. Zeeb };
145*b4c3e9b5SBjoern A. Zeeb 
146*b4c3e9b5SBjoern A. Zeeb /**
147*b4c3e9b5SBjoern A. Zeeb  * struct brcmf_bus - interface structure between common and bus layer
148*b4c3e9b5SBjoern A. Zeeb  *
149*b4c3e9b5SBjoern A. Zeeb  * @bus_priv: pointer to private bus device.
150*b4c3e9b5SBjoern A. Zeeb  * @proto_type: protocol type, bcdc or msgbuf
151*b4c3e9b5SBjoern A. Zeeb  * @dev: device pointer of bus device.
152*b4c3e9b5SBjoern A. Zeeb  * @drvr: public driver information.
153*b4c3e9b5SBjoern A. Zeeb  * @state: operational state of the bus interface.
154*b4c3e9b5SBjoern A. Zeeb  * @stats: statistics shared between common and bus layer.
155*b4c3e9b5SBjoern A. Zeeb  * @maxctl: maximum size for rxctl request message.
156*b4c3e9b5SBjoern A. Zeeb  * @chip: device identifier of the dongle chip.
157*b4c3e9b5SBjoern A. Zeeb  * @chiprev: revision of the dongle chip.
158*b4c3e9b5SBjoern A. Zeeb  * @fwvid: firmware vendor-support identifier of the device.
159*b4c3e9b5SBjoern A. Zeeb  * @always_use_fws_queue: bus wants use queue also when fwsignal is inactive.
160*b4c3e9b5SBjoern A. Zeeb  * @wowl_supported: is wowl supported by bus driver.
161*b4c3e9b5SBjoern A. Zeeb  * @ops: callbacks for this bus instance.
162*b4c3e9b5SBjoern A. Zeeb  * @msgbuf: msgbuf protocol parameters provided by bus layer.
163*b4c3e9b5SBjoern A. Zeeb  * @list: member used to add this bus instance to linked list.
164*b4c3e9b5SBjoern A. Zeeb  */
165*b4c3e9b5SBjoern A. Zeeb struct brcmf_bus {
166*b4c3e9b5SBjoern A. Zeeb 	union {
167*b4c3e9b5SBjoern A. Zeeb 		struct brcmf_sdio_dev *sdio;
168*b4c3e9b5SBjoern A. Zeeb 		struct brcmf_usbdev *usb;
169*b4c3e9b5SBjoern A. Zeeb 		struct brcmf_pciedev *pcie;
170*b4c3e9b5SBjoern A. Zeeb 	} bus_priv;
171*b4c3e9b5SBjoern A. Zeeb 	enum brcmf_bus_protocol_type proto_type;
172*b4c3e9b5SBjoern A. Zeeb 	struct device *dev;
173*b4c3e9b5SBjoern A. Zeeb 	struct brcmf_pub *drvr;
174*b4c3e9b5SBjoern A. Zeeb 	enum brcmf_bus_state state;
175*b4c3e9b5SBjoern A. Zeeb 	struct brcmf_bus_stats stats;
176*b4c3e9b5SBjoern A. Zeeb 	uint maxctl;
177*b4c3e9b5SBjoern A. Zeeb 	u32 chip;
178*b4c3e9b5SBjoern A. Zeeb 	u32 chiprev;
179*b4c3e9b5SBjoern A. Zeeb 	enum brcmf_fwvendor fwvid;
180*b4c3e9b5SBjoern A. Zeeb 	bool always_use_fws_queue;
181*b4c3e9b5SBjoern A. Zeeb 	bool wowl_supported;
182*b4c3e9b5SBjoern A. Zeeb 
183*b4c3e9b5SBjoern A. Zeeb 	const struct brcmf_bus_ops *ops;
184*b4c3e9b5SBjoern A. Zeeb 	struct brcmf_bus_msgbuf *msgbuf;
185*b4c3e9b5SBjoern A. Zeeb 
186*b4c3e9b5SBjoern A. Zeeb 	struct list_head list;
187*b4c3e9b5SBjoern A. Zeeb };
188*b4c3e9b5SBjoern A. Zeeb 
189*b4c3e9b5SBjoern A. Zeeb /*
190*b4c3e9b5SBjoern A. Zeeb  * callback wrappers
191*b4c3e9b5SBjoern A. Zeeb  */
brcmf_bus_preinit(struct brcmf_bus * bus)192*b4c3e9b5SBjoern A. Zeeb static inline int brcmf_bus_preinit(struct brcmf_bus *bus)
193*b4c3e9b5SBjoern A. Zeeb {
194*b4c3e9b5SBjoern A. Zeeb 	if (!bus->ops->preinit)
195*b4c3e9b5SBjoern A. Zeeb 		return 0;
196*b4c3e9b5SBjoern A. Zeeb 	return bus->ops->preinit(bus->dev);
197*b4c3e9b5SBjoern A. Zeeb }
198*b4c3e9b5SBjoern A. Zeeb 
brcmf_bus_stop(struct brcmf_bus * bus)199*b4c3e9b5SBjoern A. Zeeb static inline void brcmf_bus_stop(struct brcmf_bus *bus)
200*b4c3e9b5SBjoern A. Zeeb {
201*b4c3e9b5SBjoern A. Zeeb 	bus->ops->stop(bus->dev);
202*b4c3e9b5SBjoern A. Zeeb }
203*b4c3e9b5SBjoern A. Zeeb 
brcmf_bus_txdata(struct brcmf_bus * bus,struct sk_buff * skb)204*b4c3e9b5SBjoern A. Zeeb static inline int brcmf_bus_txdata(struct brcmf_bus *bus, struct sk_buff *skb)
205*b4c3e9b5SBjoern A. Zeeb {
206*b4c3e9b5SBjoern A. Zeeb 	return bus->ops->txdata(bus->dev, skb);
207*b4c3e9b5SBjoern A. Zeeb }
208*b4c3e9b5SBjoern A. Zeeb 
209*b4c3e9b5SBjoern A. Zeeb static inline
brcmf_bus_txctl(struct brcmf_bus * bus,unsigned char * msg,uint len)210*b4c3e9b5SBjoern A. Zeeb int brcmf_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
211*b4c3e9b5SBjoern A. Zeeb {
212*b4c3e9b5SBjoern A. Zeeb 	return bus->ops->txctl(bus->dev, msg, len);
213*b4c3e9b5SBjoern A. Zeeb }
214*b4c3e9b5SBjoern A. Zeeb 
215*b4c3e9b5SBjoern A. Zeeb static inline
brcmf_bus_rxctl(struct brcmf_bus * bus,unsigned char * msg,uint len)216*b4c3e9b5SBjoern A. Zeeb int brcmf_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint len)
217*b4c3e9b5SBjoern A. Zeeb {
218*b4c3e9b5SBjoern A. Zeeb 	return bus->ops->rxctl(bus->dev, msg, len);
219*b4c3e9b5SBjoern A. Zeeb }
220*b4c3e9b5SBjoern A. Zeeb 
221*b4c3e9b5SBjoern A. Zeeb static inline
brcmf_bus_gettxq(struct brcmf_bus * bus)222*b4c3e9b5SBjoern A. Zeeb struct pktq *brcmf_bus_gettxq(struct brcmf_bus *bus)
223*b4c3e9b5SBjoern A. Zeeb {
224*b4c3e9b5SBjoern A. Zeeb 	if (!bus->ops->gettxq)
225*b4c3e9b5SBjoern A. Zeeb 		return ERR_PTR(-ENOENT);
226*b4c3e9b5SBjoern A. Zeeb 
227*b4c3e9b5SBjoern A. Zeeb 	return bus->ops->gettxq(bus->dev);
228*b4c3e9b5SBjoern A. Zeeb }
229*b4c3e9b5SBjoern A. Zeeb 
230*b4c3e9b5SBjoern A. Zeeb static inline
brcmf_bus_wowl_config(struct brcmf_bus * bus,bool enabled)231*b4c3e9b5SBjoern A. Zeeb void brcmf_bus_wowl_config(struct brcmf_bus *bus, bool enabled)
232*b4c3e9b5SBjoern A. Zeeb {
233*b4c3e9b5SBjoern A. Zeeb 	if (bus->ops->wowl_config)
234*b4c3e9b5SBjoern A. Zeeb 		bus->ops->wowl_config(bus->dev, enabled);
235*b4c3e9b5SBjoern A. Zeeb }
236*b4c3e9b5SBjoern A. Zeeb 
brcmf_bus_get_ramsize(struct brcmf_bus * bus)237*b4c3e9b5SBjoern A. Zeeb static inline size_t brcmf_bus_get_ramsize(struct brcmf_bus *bus)
238*b4c3e9b5SBjoern A. Zeeb {
239*b4c3e9b5SBjoern A. Zeeb 	if (!bus->ops->get_ramsize)
240*b4c3e9b5SBjoern A. Zeeb 		return 0;
241*b4c3e9b5SBjoern A. Zeeb 
242*b4c3e9b5SBjoern A. Zeeb 	return bus->ops->get_ramsize(bus->dev);
243*b4c3e9b5SBjoern A. Zeeb }
244*b4c3e9b5SBjoern A. Zeeb 
245*b4c3e9b5SBjoern A. Zeeb static inline
brcmf_bus_get_memdump(struct brcmf_bus * bus,void * data,size_t len)246*b4c3e9b5SBjoern A. Zeeb int brcmf_bus_get_memdump(struct brcmf_bus *bus, void *data, size_t len)
247*b4c3e9b5SBjoern A. Zeeb {
248*b4c3e9b5SBjoern A. Zeeb 	if (!bus->ops->get_memdump)
249*b4c3e9b5SBjoern A. Zeeb 		return -EOPNOTSUPP;
250*b4c3e9b5SBjoern A. Zeeb 
251*b4c3e9b5SBjoern A. Zeeb 	return bus->ops->get_memdump(bus->dev, data, len);
252*b4c3e9b5SBjoern A. Zeeb }
253*b4c3e9b5SBjoern A. Zeeb 
254*b4c3e9b5SBjoern A. Zeeb static inline
brcmf_bus_get_blob(struct brcmf_bus * bus,const struct firmware ** fw,enum brcmf_blob_type type)255*b4c3e9b5SBjoern A. Zeeb int brcmf_bus_get_blob(struct brcmf_bus *bus, const struct firmware **fw,
256*b4c3e9b5SBjoern A. Zeeb 		       enum brcmf_blob_type type)
257*b4c3e9b5SBjoern A. Zeeb {
258*b4c3e9b5SBjoern A. Zeeb 	return bus->ops->get_blob(bus->dev, fw, type);
259*b4c3e9b5SBjoern A. Zeeb }
260*b4c3e9b5SBjoern A. Zeeb 
261*b4c3e9b5SBjoern A. Zeeb static inline
brcmf_bus_debugfs_create(struct brcmf_bus * bus)262*b4c3e9b5SBjoern A. Zeeb void brcmf_bus_debugfs_create(struct brcmf_bus *bus)
263*b4c3e9b5SBjoern A. Zeeb {
264*b4c3e9b5SBjoern A. Zeeb 	if (!bus->ops->debugfs_create)
265*b4c3e9b5SBjoern A. Zeeb 		return;
266*b4c3e9b5SBjoern A. Zeeb 
267*b4c3e9b5SBjoern A. Zeeb 	return bus->ops->debugfs_create(bus->dev);
268*b4c3e9b5SBjoern A. Zeeb }
269*b4c3e9b5SBjoern A. Zeeb 
270*b4c3e9b5SBjoern A. Zeeb static inline
brcmf_bus_reset(struct brcmf_bus * bus)271*b4c3e9b5SBjoern A. Zeeb int brcmf_bus_reset(struct brcmf_bus *bus)
272*b4c3e9b5SBjoern A. Zeeb {
273*b4c3e9b5SBjoern A. Zeeb 	if (!bus->ops->reset)
274*b4c3e9b5SBjoern A. Zeeb 		return -EOPNOTSUPP;
275*b4c3e9b5SBjoern A. Zeeb 
276*b4c3e9b5SBjoern A. Zeeb 	return bus->ops->reset(bus->dev);
277*b4c3e9b5SBjoern A. Zeeb }
278*b4c3e9b5SBjoern A. Zeeb 
brcmf_bus_remove(struct brcmf_bus * bus)279*b4c3e9b5SBjoern A. Zeeb static inline void brcmf_bus_remove(struct brcmf_bus *bus)
280*b4c3e9b5SBjoern A. Zeeb {
281*b4c3e9b5SBjoern A. Zeeb 	if (!bus->ops->remove) {
282*b4c3e9b5SBjoern A. Zeeb 		device_release_driver(bus->dev);
283*b4c3e9b5SBjoern A. Zeeb 		return;
284*b4c3e9b5SBjoern A. Zeeb 	}
285*b4c3e9b5SBjoern A. Zeeb 
286*b4c3e9b5SBjoern A. Zeeb 	bus->ops->remove(bus->dev);
287*b4c3e9b5SBjoern A. Zeeb }
288*b4c3e9b5SBjoern A. Zeeb 
289*b4c3e9b5SBjoern A. Zeeb /*
290*b4c3e9b5SBjoern A. Zeeb  * interface functions from common layer
291*b4c3e9b5SBjoern A. Zeeb  */
292*b4c3e9b5SBjoern A. Zeeb 
293*b4c3e9b5SBjoern A. Zeeb /* Receive frame for delivery to OS.  Callee disposes of rxp. */
294*b4c3e9b5SBjoern A. Zeeb void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp, bool handle_event,
295*b4c3e9b5SBjoern A. Zeeb 		    bool inirq);
296*b4c3e9b5SBjoern A. Zeeb /* Receive async event packet from firmware. Callee disposes of rxp. */
297*b4c3e9b5SBjoern A. Zeeb void brcmf_rx_event(struct device *dev, struct sk_buff *rxp);
298*b4c3e9b5SBjoern A. Zeeb 
299*b4c3e9b5SBjoern A. Zeeb int brcmf_alloc(struct device *dev, struct brcmf_mp_device *settings);
300*b4c3e9b5SBjoern A. Zeeb /* Indication from bus module regarding presence/insertion of dongle. */
301*b4c3e9b5SBjoern A. Zeeb int brcmf_attach(struct device *dev);
302*b4c3e9b5SBjoern A. Zeeb /* Indication from bus module regarding removal/absence of dongle */
303*b4c3e9b5SBjoern A. Zeeb void brcmf_detach(struct device *dev);
304*b4c3e9b5SBjoern A. Zeeb void brcmf_free(struct device *dev);
305*b4c3e9b5SBjoern A. Zeeb /* Indication from bus module that dongle should be reset */
306*b4c3e9b5SBjoern A. Zeeb void brcmf_dev_reset(struct device *dev);
307*b4c3e9b5SBjoern A. Zeeb /* Request from bus module to initiate a coredump */
308*b4c3e9b5SBjoern A. Zeeb void brcmf_dev_coredump(struct device *dev);
309*b4c3e9b5SBjoern A. Zeeb /* Indication that firmware has halted or crashed */
310*b4c3e9b5SBjoern A. Zeeb void brcmf_fw_crashed(struct device *dev);
311*b4c3e9b5SBjoern A. Zeeb 
312*b4c3e9b5SBjoern A. Zeeb /* Configure the "global" bus state used by upper layers */
313*b4c3e9b5SBjoern A. Zeeb void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state);
314*b4c3e9b5SBjoern A. Zeeb 
315*b4c3e9b5SBjoern A. Zeeb s32 brcmf_iovar_data_set(struct device *dev, char *name, void *data, u32 len);
316*b4c3e9b5SBjoern A. Zeeb void brcmf_bus_add_txhdrlen(struct device *dev, uint len);
317*b4c3e9b5SBjoern A. Zeeb 
318*b4c3e9b5SBjoern A. Zeeb #ifdef CONFIG_BRCMFMAC_SDIO
319*b4c3e9b5SBjoern A. Zeeb void brcmf_sdio_exit(void);
320*b4c3e9b5SBjoern A. Zeeb int brcmf_sdio_register(void);
321*b4c3e9b5SBjoern A. Zeeb #else
brcmf_sdio_exit(void)322*b4c3e9b5SBjoern A. Zeeb static inline void brcmf_sdio_exit(void) { }
brcmf_sdio_register(void)323*b4c3e9b5SBjoern A. Zeeb static inline int brcmf_sdio_register(void) { return 0; }
324*b4c3e9b5SBjoern A. Zeeb #endif
325*b4c3e9b5SBjoern A. Zeeb 
326*b4c3e9b5SBjoern A. Zeeb #ifdef CONFIG_BRCMFMAC_USB
327*b4c3e9b5SBjoern A. Zeeb void brcmf_usb_exit(void);
328*b4c3e9b5SBjoern A. Zeeb int brcmf_usb_register(void);
329*b4c3e9b5SBjoern A. Zeeb #else
brcmf_usb_exit(void)330*b4c3e9b5SBjoern A. Zeeb static inline void brcmf_usb_exit(void) { }
brcmf_usb_register(void)331*b4c3e9b5SBjoern A. Zeeb static inline int brcmf_usb_register(void) { return 0; }
332*b4c3e9b5SBjoern A. Zeeb #endif
333*b4c3e9b5SBjoern A. Zeeb 
334*b4c3e9b5SBjoern A. Zeeb #ifdef CONFIG_BRCMFMAC_PCIE
335*b4c3e9b5SBjoern A. Zeeb void brcmf_pcie_exit(void);
336*b4c3e9b5SBjoern A. Zeeb int brcmf_pcie_register(void);
337*b4c3e9b5SBjoern A. Zeeb #else
brcmf_pcie_exit(void)338*b4c3e9b5SBjoern A. Zeeb static inline void brcmf_pcie_exit(void) { }
brcmf_pcie_register(void)339*b4c3e9b5SBjoern A. Zeeb static inline int brcmf_pcie_register(void) { return 0; }
340*b4c3e9b5SBjoern A. Zeeb #endif
341*b4c3e9b5SBjoern A. Zeeb 
342*b4c3e9b5SBjoern A. Zeeb #endif /* BRCMFMAC_BUS_H */
343