]>
Commit | Line | Data |
---|---|---|
5b435de0 AS |
1 | /* |
2 | * Copyright (c) 2010 Broadcom Corporation | |
3 | * | |
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. | |
7 | * | |
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. | |
15 | */ | |
16 | ||
17 | #ifndef _BRCMF_BUS_H_ | |
18 | #define _BRCMF_BUS_H_ | |
19 | ||
a8a363ac FL |
20 | /* The level of bus communication with the dongle */ |
21 | enum brcmf_bus_state { | |
22 | BRCMF_BUS_DOWN, /* Not ready for frame transfers */ | |
23 | BRCMF_BUS_LOAD, /* Download access only (CPU reset) */ | |
24 | BRCMF_BUS_DATA /* Ready for frame transfers */ | |
25 | }; | |
26 | ||
135e4c61 FL |
27 | struct brcmf_bus_dcmd { |
28 | char *name; | |
29 | char *param; | |
30 | int param_len; | |
31 | struct list_head list; | |
32 | }; | |
33 | ||
d9cb2596 AS |
34 | /** |
35 | * struct brcmf_bus_ops - bus callback operations. | |
36 | * | |
37 | * @init: prepare for communication with dongle. | |
38 | * @stop: clear pending frames, disable data flow. | |
4061f895 AS |
39 | * @txdata: send a data frame to the dongle. When the data |
40 | * has been transferred, the common driver must be | |
41 | * notified using brcmf_txcomplete(). The common | |
42 | * driver calls this function with interrupts | |
43 | * disabled. | |
d9cb2596 AS |
44 | * @txctl: transmit a control request message to dongle. |
45 | * @rxctl: receive a control response message from dongle. | |
e2432b67 | 46 | * @gettxq: obtain a reference of bus transmit queue (optional). |
d9cb2596 AS |
47 | * |
48 | * This structure provides an abstract interface towards the | |
49 | * bus specific driver. For control messages to common driver | |
e2432b67 AS |
50 | * will assure there is only one active transaction. Unless |
51 | * indicated otherwise these callbacks are mandatory. | |
d9cb2596 AS |
52 | */ |
53 | struct brcmf_bus_ops { | |
54 | int (*init)(struct device *dev); | |
55 | void (*stop)(struct device *dev); | |
56 | int (*txdata)(struct device *dev, struct sk_buff *skb); | |
57 | int (*txctl)(struct device *dev, unsigned char *msg, uint len); | |
58 | int (*rxctl)(struct device *dev, unsigned char *msg, uint len); | |
e2432b67 | 59 | struct pktq * (*gettxq)(struct device *dev); |
d9cb2596 AS |
60 | }; |
61 | ||
62 | /** | |
63 | * struct brcmf_bus - interface structure between common and bus layer | |
64 | * | |
65 | * @bus_priv: pointer to private bus device. | |
66 | * @dev: device pointer of bus device. | |
67 | * @drvr: public driver information. | |
68 | * @state: operational state of the bus interface. | |
69 | * @maxctl: maximum size for rxctl request message. | |
d9cb2596 AS |
70 | * @tx_realloc: number of tx packets realloced for headroom. |
71 | * @dstats: dongle-based statistical data. | |
d9cb2596 | 72 | * @dcmd_list: bus/device specific dongle initialization commands. |
75d907d3 AS |
73 | * @chip: device identifier of the dongle chip. |
74 | * @chiprev: revision of the dongle chip. | |
d9cb2596 | 75 | */ |
a8a363ac | 76 | struct brcmf_bus { |
0a332e46 | 77 | union { |
0a332e46 | 78 | struct brcmf_sdio_dev *sdio; |
71bb244b | 79 | struct brcmf_usbdev *usb; |
0a332e46 | 80 | } bus_priv; |
d9cb2596 AS |
81 | struct device *dev; |
82 | struct brcmf_pub *drvr; | |
a8a363ac | 83 | enum brcmf_bus_state state; |
d9cb2596 | 84 | uint maxctl; |
d9cb2596 | 85 | unsigned long tx_realloc; |
75d907d3 AS |
86 | u32 chip; |
87 | u32 chiprev; | |
135e4c61 | 88 | struct list_head dcmd_list; |
a8a363ac | 89 | |
d9cb2596 | 90 | struct brcmf_bus_ops *ops; |
a8a363ac FL |
91 | }; |
92 | ||
d9cb2596 AS |
93 | /* |
94 | * callback wrappers | |
95 | */ | |
96 | static inline int brcmf_bus_init(struct brcmf_bus *bus) | |
97 | { | |
98 | return bus->ops->init(bus->dev); | |
99 | } | |
100 | ||
101 | static inline void brcmf_bus_stop(struct brcmf_bus *bus) | |
102 | { | |
103 | bus->ops->stop(bus->dev); | |
104 | } | |
105 | ||
106 | static inline int brcmf_bus_txdata(struct brcmf_bus *bus, struct sk_buff *skb) | |
107 | { | |
108 | return bus->ops->txdata(bus->dev, skb); | |
109 | } | |
110 | ||
111 | static inline | |
112 | int brcmf_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint len) | |
113 | { | |
114 | return bus->ops->txctl(bus->dev, msg, len); | |
115 | } | |
116 | ||
117 | static inline | |
118 | int brcmf_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint len) | |
119 | { | |
120 | return bus->ops->rxctl(bus->dev, msg, len); | |
121 | } | |
122 | ||
e2432b67 AS |
123 | static inline |
124 | struct pktq *brcmf_bus_gettxq(struct brcmf_bus *bus) | |
125 | { | |
126 | if (!bus->ops->gettxq) | |
127 | return ERR_PTR(-ENOENT); | |
128 | ||
129 | return bus->ops->gettxq(bus->dev); | |
130 | } | |
a8a363ac FL |
131 | /* |
132 | * interface functions from common layer | |
133 | */ | |
134 | ||
a8a363ac FL |
135 | extern bool brcmf_c_prec_enq(struct device *dev, struct pktq *q, |
136 | struct sk_buff *pkt, int prec); | |
137 | ||
138 | /* Receive frame for delivery to OS. Callee disposes of rxp. */ | |
a43af515 | 139 | extern void brcmf_rx_frames(struct device *dev, struct sk_buff_head *rxlist); |
a8a363ac FL |
140 | |
141 | /* Indication from bus module regarding presence/insertion of dongle. */ | |
142 | extern int brcmf_attach(uint bus_hdrlen, struct device *dev); | |
143 | /* Indication from bus module regarding removal/absence of dongle */ | |
144 | extern void brcmf_detach(struct device *dev); | |
81d5f1bb AS |
145 | /* Indication from bus module that dongle should be reset */ |
146 | extern void brcmf_dev_reset(struct device *dev); | |
a8a363ac | 147 | /* Indication from bus module to change flow-control state */ |
90d03ff7 | 148 | extern void brcmf_txflowblock(struct device *dev, bool state); |
a8a363ac | 149 | |
7f4bceec | 150 | /* Notify the bus has transferred the tx packet to firmware */ |
a8a363ac FL |
151 | extern void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, |
152 | bool success); | |
153 | ||
154 | extern int brcmf_bus_start(struct device *dev); | |
155 | ||
f3d7cdc3 AS |
156 | #ifdef CONFIG_BRCMFMAC_SDIO |
157 | extern void brcmf_sdio_exit(void); | |
549040ab | 158 | extern void brcmf_sdio_init(void); |
db4efbbe | 159 | extern void brcmf_sdio_register(void); |
f3d7cdc3 | 160 | #endif |
71bb244b AS |
161 | #ifdef CONFIG_BRCMFMAC_USB |
162 | extern void brcmf_usb_exit(void); | |
db4efbbe | 163 | extern void brcmf_usb_register(void); |
71bb244b | 164 | #endif |
f3d7cdc3 | 165 | |
5b435de0 | 166 | #endif /* _BRCMF_BUS_H_ */ |