]> bbs.cooldavid.org Git - net-next-2.6.git/blob - drivers/staging/brcm80211/sys/wlc_phy_shim.c
Staging: brcm80211: s/uint16/u16/
[net-next-2.6.git] / drivers / staging / brcm80211 / sys / wlc_phy_shim.c
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 /*
18  * This is "two-way" interface, acting as the SHIM layer between WL and PHY layer.
19  *   WL driver can optinally call this translation layer to do some preprocessing, then reach PHY.
20  *   On the PHY->WL driver direction, all calls go through this layer since PHY doesn't have the
21  *   access to wlc_hw pointer.
22  */
23
24 #include <wlc_cfg.h>
25 #include <typedefs.h>
26 #include <linuxver.h>
27 #include <linux/kernel.h>
28 #include <bcmutils.h>
29 #include <bcmdefs.h>
30 #include <osl.h>
31
32 #include <proto/802.11.h>
33 #include <bcmwifi.h>
34 #include <siutils.h>
35 #include <bcmendian.h>
36 #include <wlioctl.h>
37 #include <sbconfig.h>
38 #include <sbchipc.h>
39 #include <pcicfg.h>
40 #include <sbhndpio.h>
41 #include <sbhnddma.h>
42 #include <hnddma.h>
43 #include <hndpmu.h>
44 #include <d11.h>
45 #include <wlc_rate.h>
46 #include <wlc_pub.h>
47 #include <wlc_channel.h>
48 #include <bcmsrom.h>
49 #include <wlc_key.h>
50
51 #include <wlc_mac80211.h>
52
53 #include <wlc_bmac.h>
54 #include <wlc_phy_shim.h>
55 #include <wlc_phy_hal.h>
56 #include <wl_export.h>
57
58 /* PHY SHIM module specific state */
59 struct wlc_phy_shim_info {
60         wlc_hw_info_t *wlc_hw;  /* pointer to main wlc_hw structure */
61         void *wlc;              /* pointer to main wlc structure */
62         void *wl;               /* pointer to os-specific private state */
63 };
64
65 wlc_phy_shim_info_t *BCMATTACHFN(wlc_phy_shim_attach) (wlc_hw_info_t *wlc_hw,
66                                                        void *wl, void *wlc) {
67         wlc_phy_shim_info_t *physhim = NULL;
68
69         physhim = (wlc_phy_shim_info_t *)MALLOC(wlc_hw->osh,
70                 sizeof(wlc_phy_shim_info_t));
71         if (!physhim) {
72                 WL_ERROR(("wl%d: wlc_phy_shim_attach: out of mem, malloced %d bytes\n", wlc_hw->unit, MALLOCED(wlc_hw->osh)));
73                 return NULL;
74         }
75         bzero((char *)physhim, sizeof(wlc_phy_shim_info_t));
76         physhim->wlc_hw = wlc_hw;
77         physhim->wlc = wlc;
78         physhim->wl = wl;
79
80         return physhim;
81 }
82
83 void BCMATTACHFN(wlc_phy_shim_detach) (wlc_phy_shim_info_t *physhim)
84 {
85         if (!physhim)
86                 return;
87
88         MFREE(physhim->wlc_hw->osh, physhim, sizeof(wlc_phy_shim_info_t));
89 }
90
91 struct wlapi_timer *wlapi_init_timer(wlc_phy_shim_info_t *physhim,
92                                      void (*fn) (void *arg), void *arg,
93                                      const char *name)
94 {
95         return (struct wlapi_timer *)wl_init_timer(physhim->wl, fn, arg, name);
96 }
97
98 void wlapi_free_timer(wlc_phy_shim_info_t *physhim, struct wlapi_timer *t)
99 {
100         wl_free_timer(physhim->wl, (struct wl_timer *)t);
101 }
102
103 void
104 wlapi_add_timer(wlc_phy_shim_info_t *physhim, struct wlapi_timer *t, uint ms,
105                 int periodic)
106 {
107         wl_add_timer(physhim->wl, (struct wl_timer *)t, ms, periodic);
108 }
109
110 bool wlapi_del_timer(wlc_phy_shim_info_t *physhim, struct wlapi_timer *t)
111 {
112         return wl_del_timer(physhim->wl, (struct wl_timer *)t);
113 }
114
115 void wlapi_intrson(wlc_phy_shim_info_t *physhim)
116 {
117         wl_intrson(physhim->wl);
118 }
119
120 uint32 wlapi_intrsoff(wlc_phy_shim_info_t *physhim)
121 {
122         return wl_intrsoff(physhim->wl);
123 }
124
125 void wlapi_intrsrestore(wlc_phy_shim_info_t *physhim, uint32 macintmask)
126 {
127         wl_intrsrestore(physhim->wl, macintmask);
128 }
129
130 void wlapi_bmac_write_shm(wlc_phy_shim_info_t *physhim, uint offset, u16 v)
131 {
132         wlc_bmac_write_shm(physhim->wlc_hw, offset, v);
133 }
134
135 u16 wlapi_bmac_read_shm(wlc_phy_shim_info_t *physhim, uint offset)
136 {
137         return wlc_bmac_read_shm(physhim->wlc_hw, offset);
138 }
139
140 void
141 wlapi_bmac_mhf(wlc_phy_shim_info_t *physhim, u8 idx, u16 mask,
142                u16 val, int bands)
143 {
144         wlc_bmac_mhf(physhim->wlc_hw, idx, mask, val, bands);
145 }
146
147 void wlapi_bmac_corereset(wlc_phy_shim_info_t *physhim, uint32 flags)
148 {
149         wlc_bmac_corereset(physhim->wlc_hw, flags);
150 }
151
152 void wlapi_suspend_mac_and_wait(wlc_phy_shim_info_t *physhim)
153 {
154         wlc_suspend_mac_and_wait(physhim->wlc);
155 }
156
157 void wlapi_switch_macfreq(wlc_phy_shim_info_t *physhim, u8 spurmode)
158 {
159         wlc_bmac_switch_macfreq(physhim->wlc_hw, spurmode);
160 }
161
162 void wlapi_enable_mac(wlc_phy_shim_info_t *physhim)
163 {
164         wlc_enable_mac(physhim->wlc);
165 }
166
167 void wlapi_bmac_mctrl(wlc_phy_shim_info_t *physhim, uint32 mask, uint32 val)
168 {
169         wlc_bmac_mctrl(physhim->wlc_hw, mask, val);
170 }
171
172 void wlapi_bmac_phy_reset(wlc_phy_shim_info_t *physhim)
173 {
174         wlc_bmac_phy_reset(physhim->wlc_hw);
175 }
176
177 void wlapi_bmac_bw_set(wlc_phy_shim_info_t *physhim, u16 bw)
178 {
179         wlc_bmac_bw_set(physhim->wlc_hw, bw);
180 }
181
182 u16 wlapi_bmac_get_txant(wlc_phy_shim_info_t *physhim)
183 {
184         return wlc_bmac_get_txant(physhim->wlc_hw);
185 }
186
187 void wlapi_bmac_phyclk_fgc(wlc_phy_shim_info_t *physhim, bool clk)
188 {
189         wlc_bmac_phyclk_fgc(physhim->wlc_hw, clk);
190 }
191
192 void wlapi_bmac_macphyclk_set(wlc_phy_shim_info_t *physhim, bool clk)
193 {
194         wlc_bmac_macphyclk_set(physhim->wlc_hw, clk);
195 }
196
197 void wlapi_bmac_core_phypll_ctl(wlc_phy_shim_info_t *physhim, bool on)
198 {
199         wlc_bmac_core_phypll_ctl(physhim->wlc_hw, on);
200 }
201
202 void wlapi_bmac_core_phypll_reset(wlc_phy_shim_info_t *physhim)
203 {
204         wlc_bmac_core_phypll_reset(physhim->wlc_hw);
205 }
206
207 void wlapi_bmac_ucode_wake_override_phyreg_set(wlc_phy_shim_info_t *physhim)
208 {
209         wlc_ucode_wake_override_set(physhim->wlc_hw, WLC_WAKE_OVERRIDE_PHYREG);
210 }
211
212 void wlapi_bmac_ucode_wake_override_phyreg_clear(wlc_phy_shim_info_t *physhim)
213 {
214         wlc_ucode_wake_override_clear(physhim->wlc_hw,
215                                       WLC_WAKE_OVERRIDE_PHYREG);
216 }
217
218 void
219 wlapi_bmac_write_template_ram(wlc_phy_shim_info_t *physhim, int offset,
220                               int len, void *buf)
221 {
222         wlc_bmac_write_template_ram(physhim->wlc_hw, offset, len, buf);
223 }
224
225 u16 wlapi_bmac_rate_shm_offset(wlc_phy_shim_info_t *physhim, u8 rate)
226 {
227         return wlc_bmac_rate_shm_offset(physhim->wlc_hw, rate);
228 }
229
230 void wlapi_ucode_sample_init(wlc_phy_shim_info_t *physhim)
231 {
232 }
233
234 void
235 wlapi_copyfrom_objmem(wlc_phy_shim_info_t *physhim, uint offset, void *buf,
236                       int len, uint32 sel)
237 {
238         wlc_bmac_copyfrom_objmem(physhim->wlc_hw, offset, buf, len, sel);
239 }
240
241 void
242 wlapi_copyto_objmem(wlc_phy_shim_info_t *physhim, uint offset, const void *buf,
243                     int l, uint32 sel)
244 {
245         wlc_bmac_copyto_objmem(physhim->wlc_hw, offset, buf, l, sel);
246 }
247
248 void
249 wlapi_bmac_pktengtx(wlc_phy_shim_info_t *physhim, wl_pkteng_t *pkteng,
250                     u8 rate, struct ether_addr *sa, uint32 wait_delay)
251 {
252         wlc_pktengtx(physhim->wlc, pkteng, rate, sa, wait_delay);
253 }