0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include <linux/slab.h>
0025 #include <net/mac80211.h>
0026
0027 #include "main.h"
0028 #include "mac80211_if.h"
0029 #include "phy_shim.h"
0030
0031
0032 struct phy_shim_info {
0033 struct brcms_hardware *wlc_hw;
0034 struct brcms_c_info *wlc;
0035 struct brcms_info *wl;
0036 };
0037
0038 struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw,
0039 struct brcms_info *wl,
0040 struct brcms_c_info *wlc) {
0041 struct phy_shim_info *physhim = NULL;
0042
0043 physhim = kzalloc(sizeof(struct phy_shim_info), GFP_ATOMIC);
0044 if (!physhim)
0045 return NULL;
0046
0047 physhim->wlc_hw = wlc_hw;
0048 physhim->wlc = wlc;
0049 physhim->wl = wl;
0050
0051 return physhim;
0052 }
0053
0054 void wlc_phy_shim_detach(struct phy_shim_info *physhim)
0055 {
0056 kfree(physhim);
0057 }
0058
0059 struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim,
0060 void (*fn)(struct brcms_phy *pi),
0061 void *arg, const char *name)
0062 {
0063 return (struct wlapi_timer *)
0064 brcms_init_timer(physhim->wl, (void (*)(void *))fn,
0065 arg, name);
0066 }
0067
0068 void wlapi_free_timer(struct wlapi_timer *t)
0069 {
0070 brcms_free_timer((struct brcms_timer *)t);
0071 }
0072
0073 void
0074 wlapi_add_timer(struct wlapi_timer *t, uint ms, int periodic)
0075 {
0076 brcms_add_timer((struct brcms_timer *)t, ms, periodic);
0077 }
0078
0079 bool wlapi_del_timer(struct wlapi_timer *t)
0080 {
0081 return brcms_del_timer((struct brcms_timer *)t);
0082 }
0083
0084 void wlapi_intrson(struct phy_shim_info *physhim)
0085 {
0086 brcms_intrson(physhim->wl);
0087 }
0088
0089 u32 wlapi_intrsoff(struct phy_shim_info *physhim)
0090 {
0091 return brcms_intrsoff(physhim->wl);
0092 }
0093
0094 void wlapi_intrsrestore(struct phy_shim_info *physhim, u32 macintmask)
0095 {
0096 brcms_intrsrestore(physhim->wl, macintmask);
0097 }
0098
0099 void wlapi_bmac_write_shm(struct phy_shim_info *physhim, uint offset, u16 v)
0100 {
0101 brcms_b_write_shm(physhim->wlc_hw, offset, v);
0102 }
0103
0104 u16 wlapi_bmac_read_shm(struct phy_shim_info *physhim, uint offset)
0105 {
0106 return brcms_b_read_shm(physhim->wlc_hw, offset);
0107 }
0108
0109 void
0110 wlapi_bmac_mhf(struct phy_shim_info *physhim, u8 idx, u16 mask,
0111 u16 val, int bands)
0112 {
0113 brcms_b_mhf(physhim->wlc_hw, idx, mask, val, bands);
0114 }
0115
0116 void wlapi_bmac_corereset(struct phy_shim_info *physhim, u32 flags)
0117 {
0118 brcms_b_corereset(physhim->wlc_hw, flags);
0119 }
0120
0121 void wlapi_suspend_mac_and_wait(struct phy_shim_info *physhim)
0122 {
0123 brcms_c_suspend_mac_and_wait(physhim->wlc);
0124 }
0125
0126 void wlapi_switch_macfreq(struct phy_shim_info *physhim, u8 spurmode)
0127 {
0128 brcms_b_switch_macfreq(physhim->wlc_hw, spurmode);
0129 }
0130
0131 void wlapi_enable_mac(struct phy_shim_info *physhim)
0132 {
0133 brcms_c_enable_mac(physhim->wlc);
0134 }
0135
0136 void wlapi_bmac_mctrl(struct phy_shim_info *physhim, u32 mask, u32 val)
0137 {
0138 brcms_b_mctrl(physhim->wlc_hw, mask, val);
0139 }
0140
0141 void wlapi_bmac_phy_reset(struct phy_shim_info *physhim)
0142 {
0143 brcms_b_phy_reset(physhim->wlc_hw);
0144 }
0145
0146 void wlapi_bmac_bw_set(struct phy_shim_info *physhim, u16 bw)
0147 {
0148 brcms_b_bw_set(physhim->wlc_hw, bw);
0149 }
0150
0151 u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim)
0152 {
0153 return brcms_b_get_txant(physhim->wlc_hw);
0154 }
0155
0156 void wlapi_bmac_phyclk_fgc(struct phy_shim_info *physhim, bool clk)
0157 {
0158 brcms_b_phyclk_fgc(physhim->wlc_hw, clk);
0159 }
0160
0161 void wlapi_bmac_macphyclk_set(struct phy_shim_info *physhim, bool clk)
0162 {
0163 brcms_b_macphyclk_set(physhim->wlc_hw, clk);
0164 }
0165
0166 void wlapi_bmac_core_phypll_ctl(struct phy_shim_info *physhim, bool on)
0167 {
0168 brcms_b_core_phypll_ctl(physhim->wlc_hw, on);
0169 }
0170
0171 void wlapi_bmac_core_phypll_reset(struct phy_shim_info *physhim)
0172 {
0173 brcms_b_core_phypll_reset(physhim->wlc_hw);
0174 }
0175
0176 void wlapi_bmac_ucode_wake_override_phyreg_set(struct phy_shim_info *physhim)
0177 {
0178 brcms_c_ucode_wake_override_set(physhim->wlc_hw,
0179 BRCMS_WAKE_OVERRIDE_PHYREG);
0180 }
0181
0182 void wlapi_bmac_ucode_wake_override_phyreg_clear(struct phy_shim_info *physhim)
0183 {
0184 brcms_c_ucode_wake_override_clear(physhim->wlc_hw,
0185 BRCMS_WAKE_OVERRIDE_PHYREG);
0186 }
0187
0188 void
0189 wlapi_bmac_write_template_ram(struct phy_shim_info *physhim, int offset,
0190 int len, void *buf)
0191 {
0192 brcms_b_write_template_ram(physhim->wlc_hw, offset, len, buf);
0193 }
0194
0195 u16 wlapi_bmac_rate_shm_offset(struct phy_shim_info *physhim, u8 rate)
0196 {
0197 return brcms_b_rate_shm_offset(physhim->wlc_hw, rate);
0198 }
0199
0200 void wlapi_ucode_sample_init(struct phy_shim_info *physhim)
0201 {
0202 }
0203
0204 void
0205 wlapi_copyfrom_objmem(struct phy_shim_info *physhim, uint offset, void *buf,
0206 int len, u32 sel)
0207 {
0208 brcms_b_copyfrom_objmem(physhim->wlc_hw, offset, buf, len, sel);
0209 }
0210
0211 void
0212 wlapi_copyto_objmem(struct phy_shim_info *physhim, uint offset, const void *buf,
0213 int l, u32 sel)
0214 {
0215 brcms_b_copyto_objmem(physhim->wlc_hw, offset, buf, l, sel);
0216 }