staging: brcm80211: replaced wlc_ by brcms_c_, part 2
[deliverable/linux.git] / drivers / staging / brcm80211 / brcmsmac / phy_shim.c
CommitLineData
a9533e7e
HP
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 */
3bec7bb9
RV
23#include <linux/slab.h>
24#include <net/mac80211.h>
a9533e7e 25
225fa52c 26#include "bmac.h"
cc3cea5a 27#include "main.h"
cc3cea5a 28#include "mac80211_if.h"
3bec7bb9 29#include "phy_shim.h"
a9533e7e
HP
30
31/* PHY SHIM module specific state */
32struct wlc_phy_shim_info {
fe741e5e 33 struct brcms_c_hw_info *wlc_hw; /* pointer to main wlc_hw structure */
a9533e7e
HP
34 void *wlc; /* pointer to main wlc structure */
35 void *wl; /* pointer to os-specific private state */
36};
37
fe741e5e 38wlc_phy_shim_info_t *wlc_phy_shim_attach(struct brcms_c_hw_info *wlc_hw,
a9533e7e
HP
39 void *wl, void *wlc) {
40 wlc_phy_shim_info_t *physhim = NULL;
41
5fcc1fcb 42 physhim = kzalloc(sizeof(wlc_phy_shim_info_t), GFP_ATOMIC);
ca8c1e59 43 if (!physhim) {
09a48470
RV
44 wiphy_err(wlc_hw->wlc->wiphy,
45 "wl%d: wlc_phy_shim_attach: out of mem\n",
46 wlc_hw->unit);
a9533e7e
HP
47 return NULL;
48 }
a9533e7e
HP
49 physhim->wlc_hw = wlc_hw;
50 physhim->wlc = wlc;
51 physhim->wl = wl;
52
53 return physhim;
54}
55
0d2f0724 56void wlc_phy_shim_detach(wlc_phy_shim_info_t *physhim)
a2627bc0 57{
182acb3c 58 kfree(physhim);
a9533e7e
HP
59}
60
7cc4a4c0 61struct wlapi_timer *wlapi_init_timer(wlc_phy_shim_info_t *physhim,
a9533e7e
HP
62 void (*fn) (void *arg), void *arg,
63 const char *name)
64{
8817f754
RV
65 return (struct wlapi_timer *)
66 brcms_init_timer(physhim->wl, fn, arg, name);
a9533e7e
HP
67}
68
7cc4a4c0 69void wlapi_free_timer(wlc_phy_shim_info_t *physhim, struct wlapi_timer *t)
a9533e7e 70{
8817f754 71 brcms_free_timer(physhim->wl, (struct brcms_timer *)t);
a9533e7e
HP
72}
73
74void
7cc4a4c0 75wlapi_add_timer(wlc_phy_shim_info_t *physhim, struct wlapi_timer *t, uint ms,
a9533e7e
HP
76 int periodic)
77{
8817f754 78 brcms_add_timer(physhim->wl, (struct brcms_timer *)t, ms, periodic);
a9533e7e
HP
79}
80
7cc4a4c0 81bool wlapi_del_timer(wlc_phy_shim_info_t *physhim, struct wlapi_timer *t)
a9533e7e 82{
8817f754 83 return brcms_del_timer(physhim->wl, (struct brcms_timer *)t);
a9533e7e
HP
84}
85
7cc4a4c0 86void wlapi_intrson(wlc_phy_shim_info_t *physhim)
a9533e7e 87{
8817f754 88 brcms_intrson(physhim->wl);
a9533e7e
HP
89}
90
66cbd3ab 91u32 wlapi_intrsoff(wlc_phy_shim_info_t *physhim)
a9533e7e 92{
8817f754 93 return brcms_intrsoff(physhim->wl);
a9533e7e
HP
94}
95
66cbd3ab 96void wlapi_intrsrestore(wlc_phy_shim_info_t *physhim, u32 macintmask)
a9533e7e 97{
8817f754 98 brcms_intrsrestore(physhim->wl, macintmask);
a9533e7e
HP
99}
100
7d4df48e 101void wlapi_bmac_write_shm(wlc_phy_shim_info_t *physhim, uint offset, u16 v)
a9533e7e 102{
c654fce6 103 brcms_b_write_shm(physhim->wlc_hw, offset, v);
a9533e7e
HP
104}
105
7d4df48e 106u16 wlapi_bmac_read_shm(wlc_phy_shim_info_t *physhim, uint offset)
a9533e7e 107{
c654fce6 108 return brcms_b_read_shm(physhim->wlc_hw, offset);
a9533e7e
HP
109}
110
111void
7d4df48e
GKH
112wlapi_bmac_mhf(wlc_phy_shim_info_t *physhim, u8 idx, u16 mask,
113 u16 val, int bands)
a9533e7e 114{
c654fce6 115 brcms_b_mhf(physhim->wlc_hw, idx, mask, val, bands);
a9533e7e
HP
116}
117
66cbd3ab 118void wlapi_bmac_corereset(wlc_phy_shim_info_t *physhim, u32 flags)
a9533e7e 119{
c654fce6 120 brcms_b_corereset(physhim->wlc_hw, flags);
a9533e7e
HP
121}
122
7cc4a4c0 123void wlapi_suspend_mac_and_wait(wlc_phy_shim_info_t *physhim)
a9533e7e 124{
fe741e5e 125 brcms_c_suspend_mac_and_wait(physhim->wlc);
a9533e7e
HP
126}
127
41feb5ed 128void wlapi_switch_macfreq(wlc_phy_shim_info_t *physhim, u8 spurmode)
a9533e7e 129{
c654fce6 130 brcms_b_switch_macfreq(physhim->wlc_hw, spurmode);
a9533e7e
HP
131}
132
7cc4a4c0 133void wlapi_enable_mac(wlc_phy_shim_info_t *physhim)
a9533e7e 134{
fe741e5e 135 brcms_c_enable_mac(physhim->wlc);
a9533e7e
HP
136}
137
66cbd3ab 138void wlapi_bmac_mctrl(wlc_phy_shim_info_t *physhim, u32 mask, u32 val)
a9533e7e 139{
c654fce6 140 brcms_b_mctrl(physhim->wlc_hw, mask, val);
a9533e7e
HP
141}
142
7cc4a4c0 143void wlapi_bmac_phy_reset(wlc_phy_shim_info_t *physhim)
a9533e7e 144{
c654fce6 145 brcms_b_phy_reset(physhim->wlc_hw);
a9533e7e
HP
146}
147
7d4df48e 148void wlapi_bmac_bw_set(wlc_phy_shim_info_t *physhim, u16 bw)
a9533e7e 149{
c654fce6 150 brcms_b_bw_set(physhim->wlc_hw, bw);
a9533e7e
HP
151}
152
7d4df48e 153u16 wlapi_bmac_get_txant(wlc_phy_shim_info_t *physhim)
a9533e7e 154{
c654fce6 155 return brcms_b_get_txant(physhim->wlc_hw);
a9533e7e
HP
156}
157
7cc4a4c0 158void wlapi_bmac_phyclk_fgc(wlc_phy_shim_info_t *physhim, bool clk)
a9533e7e 159{
c654fce6 160 brcms_b_phyclk_fgc(physhim->wlc_hw, clk);
a9533e7e
HP
161}
162
7cc4a4c0 163void wlapi_bmac_macphyclk_set(wlc_phy_shim_info_t *physhim, bool clk)
a9533e7e 164{
c654fce6 165 brcms_b_macphyclk_set(physhim->wlc_hw, clk);
a9533e7e
HP
166}
167
7cc4a4c0 168void wlapi_bmac_core_phypll_ctl(wlc_phy_shim_info_t *physhim, bool on)
a9533e7e 169{
c654fce6 170 brcms_b_core_phypll_ctl(physhim->wlc_hw, on);
a9533e7e
HP
171}
172
7cc4a4c0 173void wlapi_bmac_core_phypll_reset(wlc_phy_shim_info_t *physhim)
a9533e7e 174{
c654fce6 175 brcms_b_core_phypll_reset(physhim->wlc_hw);
a9533e7e
HP
176}
177
7cc4a4c0 178void wlapi_bmac_ucode_wake_override_phyreg_set(wlc_phy_shim_info_t *physhim)
a9533e7e 179{
1c4c54ba
RV
180 brcms_c_ucode_wake_override_set(physhim->wlc_hw,
181 WLC_WAKE_OVERRIDE_PHYREG);
a9533e7e
HP
182}
183
7cc4a4c0 184void wlapi_bmac_ucode_wake_override_phyreg_clear(wlc_phy_shim_info_t *physhim)
a9533e7e 185{
1c4c54ba
RV
186 brcms_c_ucode_wake_override_clear(physhim->wlc_hw,
187 WLC_WAKE_OVERRIDE_PHYREG);
a9533e7e
HP
188}
189
190void
7cc4a4c0 191wlapi_bmac_write_template_ram(wlc_phy_shim_info_t *physhim, int offset,
a9533e7e
HP
192 int len, void *buf)
193{
c654fce6 194 brcms_b_write_template_ram(physhim->wlc_hw, offset, len, buf);
a9533e7e
HP
195}
196
7d4df48e 197u16 wlapi_bmac_rate_shm_offset(wlc_phy_shim_info_t *physhim, u8 rate)
a9533e7e 198{
c654fce6 199 return brcms_b_rate_shm_offset(physhim->wlc_hw, rate);
a9533e7e
HP
200}
201
7cc4a4c0 202void wlapi_ucode_sample_init(wlc_phy_shim_info_t *physhim)
a9533e7e
HP
203{
204}
205
206void
7cc4a4c0 207wlapi_copyfrom_objmem(wlc_phy_shim_info_t *physhim, uint offset, void *buf,
66cbd3ab 208 int len, u32 sel)
a9533e7e 209{
c654fce6 210 brcms_b_copyfrom_objmem(physhim->wlc_hw, offset, buf, len, sel);
a9533e7e
HP
211}
212
213void
7cc4a4c0 214wlapi_copyto_objmem(wlc_phy_shim_info_t *physhim, uint offset, const void *buf,
66cbd3ab 215 int l, u32 sel)
a9533e7e 216{
c654fce6 217 brcms_b_copyto_objmem(physhim->wlc_hw, offset, buf, l, sel);
a9533e7e 218}
This page took 0.158367 seconds and 5 git commands to generate.