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. | |
39 | * @txdata: send a data frame to the dongle (callee disposes skb). | |
40 | * @txctl: transmit a control request message to dongle. | |
41 | * @rxctl: receive a control response message from dongle. | |
42 | * | |
43 | * This structure provides an abstract interface towards the | |
44 | * bus specific driver. For control messages to common driver | |
45 | * will assure there is only one active transaction. | |
46 | */ | |
47 | struct brcmf_bus_ops { | |
48 | int (*init)(struct device *dev); | |
49 | void (*stop)(struct device *dev); | |
50 | int (*txdata)(struct device *dev, struct sk_buff *skb); | |
51 | int (*txctl)(struct device *dev, unsigned char *msg, uint len); | |
52 | int (*rxctl)(struct device *dev, unsigned char *msg, uint len); | |
53 | }; | |
54 | ||
55 | /** | |
56 | * struct brcmf_bus - interface structure between common and bus layer | |
57 | * | |
58 | * @bus_priv: pointer to private bus device. | |
59 | * @dev: device pointer of bus device. | |
60 | * @drvr: public driver information. | |
61 | * @state: operational state of the bus interface. | |
62 | * @maxctl: maximum size for rxctl request message. | |
d9cb2596 AS |
63 | * @tx_realloc: number of tx packets realloced for headroom. |
64 | * @dstats: dongle-based statistical data. | |
65 | * @align: alignment requirement for the bus. | |
66 | * @dcmd_list: bus/device specific dongle initialization commands. | |
75d907d3 AS |
67 | * @chip: device identifier of the dongle chip. |
68 | * @chiprev: revision of the dongle chip. | |
d9cb2596 | 69 | */ |
a8a363ac | 70 | struct brcmf_bus { |
0a332e46 | 71 | union { |
0a332e46 | 72 | struct brcmf_sdio_dev *sdio; |
71bb244b | 73 | struct brcmf_usbdev *usb; |
0a332e46 | 74 | } bus_priv; |
d9cb2596 AS |
75 | struct device *dev; |
76 | struct brcmf_pub *drvr; | |
a8a363ac | 77 | enum brcmf_bus_state state; |
d9cb2596 | 78 | uint maxctl; |
d9cb2596 | 79 | unsigned long tx_realloc; |
d9cb2596 | 80 | u8 align; |
75d907d3 AS |
81 | u32 chip; |
82 | u32 chiprev; | |
135e4c61 | 83 | struct list_head dcmd_list; |
a8a363ac | 84 | |
d9cb2596 | 85 | struct brcmf_bus_ops *ops; |
a8a363ac FL |
86 | }; |
87 | ||
d9cb2596 AS |
88 | /* |
89 | * callback wrappers | |
90 | */ | |
91 | static inline int brcmf_bus_init(struct brcmf_bus *bus) | |
92 | { | |
93 | return bus->ops->init(bus->dev); | |
94 | } | |
95 | ||
96 | static inline void brcmf_bus_stop(struct brcmf_bus *bus) | |
97 | { | |
98 | bus->ops->stop(bus->dev); | |
99 | } | |
100 | ||
101 | static inline int brcmf_bus_txdata(struct brcmf_bus *bus, struct sk_buff *skb) | |
102 | { | |
103 | return bus->ops->txdata(bus->dev, skb); | |
104 | } | |
105 | ||
106 | static inline | |
107 | int brcmf_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint len) | |
108 | { | |
109 | return bus->ops->txctl(bus->dev, msg, len); | |
110 | } | |
111 | ||
112 | static inline | |
113 | int brcmf_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint len) | |
114 | { | |
115 | return bus->ops->rxctl(bus->dev, msg, len); | |
116 | } | |
117 | ||
a8a363ac FL |
118 | /* |
119 | * interface functions from common layer | |
120 | */ | |
121 | ||
a8a363ac FL |
122 | extern bool brcmf_c_prec_enq(struct device *dev, struct pktq *q, |
123 | struct sk_buff *pkt, int prec); | |
124 | ||
125 | /* Receive frame for delivery to OS. Callee disposes of rxp. */ | |
a43af515 | 126 | extern void brcmf_rx_frames(struct device *dev, struct sk_buff_head *rxlist); |
a8a363ac FL |
127 | |
128 | /* Indication from bus module regarding presence/insertion of dongle. */ | |
129 | extern int brcmf_attach(uint bus_hdrlen, struct device *dev); | |
130 | /* Indication from bus module regarding removal/absence of dongle */ | |
131 | extern void brcmf_detach(struct device *dev); | |
81d5f1bb AS |
132 | /* Indication from bus module that dongle should be reset */ |
133 | extern void brcmf_dev_reset(struct device *dev); | |
a8a363ac | 134 | /* Indication from bus module to change flow-control state */ |
90d03ff7 | 135 | extern void brcmf_txflowblock(struct device *dev, bool state); |
a8a363ac FL |
136 | |
137 | /* Notify tx completion */ | |
138 | extern void brcmf_txcomplete(struct device *dev, struct sk_buff *txp, | |
139 | bool success); | |
140 | ||
141 | extern int brcmf_bus_start(struct device *dev); | |
142 | ||
f3d7cdc3 AS |
143 | #ifdef CONFIG_BRCMFMAC_SDIO |
144 | extern void brcmf_sdio_exit(void); | |
549040ab | 145 | extern void brcmf_sdio_init(void); |
f3d7cdc3 | 146 | #endif |
71bb244b AS |
147 | #ifdef CONFIG_BRCMFMAC_USB |
148 | extern void brcmf_usb_exit(void); | |
549040ab | 149 | extern void brcmf_usb_init(void); |
71bb244b | 150 | #endif |
f3d7cdc3 | 151 | |
5b435de0 | 152 | #endif /* _BRCMF_BUS_H_ */ |