Path: blob/main/sys/contrib/dev/broadcom/brcm80211/brcmsmac/phy_shim.c
178665 views
/*1* Copyright (c) 2010 Broadcom Corporation2*3* Permission to use, copy, modify, and/or distribute this software for any4* purpose with or without fee is hereby granted, provided that the above5* copyright notice and this permission notice appear in all copies.6*7* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES8* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF9* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY10* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES11* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION12* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN13* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.14*/1516/*17* This is "two-way" interface, acting as the SHIM layer between driver18* and PHY layer. The driver can optionally call this translation layer19* to do some preprocessing, then reach PHY. On the PHY->driver direction,20* all calls go through this layer since PHY doesn't have access to the21* driver's brcms_hardware pointer.22*/23#include <linux/slab.h>24#include <net/mac80211.h>2526#include "main.h"27#include "mac80211_if.h"28#include "phy_shim.h"2930/* PHY SHIM module specific state */31struct phy_shim_info {32struct brcms_hardware *wlc_hw; /* pointer to main wlc_hw structure */33struct brcms_c_info *wlc; /* pointer to main wlc structure */34struct brcms_info *wl; /* pointer to os-specific private state */35};3637struct phy_shim_info *wlc_phy_shim_attach(struct brcms_hardware *wlc_hw,38struct brcms_info *wl,39struct brcms_c_info *wlc) {40struct phy_shim_info *physhim;4142physhim = kzalloc(sizeof(*physhim), GFP_ATOMIC);43if (!physhim)44return NULL;4546physhim->wlc_hw = wlc_hw;47physhim->wlc = wlc;48physhim->wl = wl;4950return physhim;51}5253void wlc_phy_shim_detach(struct phy_shim_info *physhim)54{55kfree(physhim);56}5758struct wlapi_timer *wlapi_init_timer(struct phy_shim_info *physhim,59void (*fn)(void *pi),60void *arg, const char *name)61{62return (struct wlapi_timer *)63brcms_init_timer(physhim->wl, fn, arg, name);64}6566void wlapi_free_timer(struct wlapi_timer *t)67{68brcms_free_timer((struct brcms_timer *)t);69}7071void72wlapi_add_timer(struct wlapi_timer *t, uint ms, int periodic)73{74brcms_add_timer((struct brcms_timer *)t, ms, periodic);75}7677bool wlapi_del_timer(struct wlapi_timer *t)78{79return brcms_del_timer((struct brcms_timer *)t);80}8182void wlapi_intrson(struct phy_shim_info *physhim)83{84brcms_intrson(physhim->wl);85}8687u32 wlapi_intrsoff(struct phy_shim_info *physhim)88{89return brcms_intrsoff(physhim->wl);90}9192void wlapi_intrsrestore(struct phy_shim_info *physhim, u32 macintmask)93{94brcms_intrsrestore(physhim->wl, macintmask);95}9697void wlapi_bmac_write_shm(struct phy_shim_info *physhim, uint offset, u16 v)98{99brcms_b_write_shm(physhim->wlc_hw, offset, v);100}101102u16 wlapi_bmac_read_shm(struct phy_shim_info *physhim, uint offset)103{104return brcms_b_read_shm(physhim->wlc_hw, offset);105}106107void108wlapi_bmac_mhf(struct phy_shim_info *physhim, u8 idx, u16 mask,109u16 val, int bands)110{111brcms_b_mhf(physhim->wlc_hw, idx, mask, val, bands);112}113114void wlapi_bmac_corereset(struct phy_shim_info *physhim, u32 flags)115{116brcms_b_corereset(physhim->wlc_hw, flags);117}118119void wlapi_suspend_mac_and_wait(struct phy_shim_info *physhim)120{121brcms_c_suspend_mac_and_wait(physhim->wlc);122}123124void wlapi_switch_macfreq(struct phy_shim_info *physhim, u8 spurmode)125{126brcms_b_switch_macfreq(physhim->wlc_hw, spurmode);127}128129void wlapi_enable_mac(struct phy_shim_info *physhim)130{131brcms_c_enable_mac(physhim->wlc);132}133134void wlapi_bmac_mctrl(struct phy_shim_info *physhim, u32 mask, u32 val)135{136brcms_b_mctrl(physhim->wlc_hw, mask, val);137}138139void wlapi_bmac_phy_reset(struct phy_shim_info *physhim)140{141brcms_b_phy_reset(physhim->wlc_hw);142}143144void wlapi_bmac_bw_set(struct phy_shim_info *physhim, u16 bw)145{146brcms_b_bw_set(physhim->wlc_hw, bw);147}148149u16 wlapi_bmac_get_txant(struct phy_shim_info *physhim)150{151return brcms_b_get_txant(physhim->wlc_hw);152}153154void wlapi_bmac_phyclk_fgc(struct phy_shim_info *physhim, bool clk)155{156brcms_b_phyclk_fgc(physhim->wlc_hw, clk);157}158159void wlapi_bmac_macphyclk_set(struct phy_shim_info *physhim, bool clk)160{161brcms_b_macphyclk_set(physhim->wlc_hw, clk);162}163164void wlapi_bmac_core_phypll_ctl(struct phy_shim_info *physhim, bool on)165{166brcms_b_core_phypll_ctl(physhim->wlc_hw, on);167}168169void wlapi_bmac_core_phypll_reset(struct phy_shim_info *physhim)170{171brcms_b_core_phypll_reset(physhim->wlc_hw);172}173174void wlapi_bmac_ucode_wake_override_phyreg_set(struct phy_shim_info *physhim)175{176brcms_c_ucode_wake_override_set(physhim->wlc_hw,177BRCMS_WAKE_OVERRIDE_PHYREG);178}179180void wlapi_bmac_ucode_wake_override_phyreg_clear(struct phy_shim_info *physhim)181{182brcms_c_ucode_wake_override_clear(physhim->wlc_hw,183BRCMS_WAKE_OVERRIDE_PHYREG);184}185186void187wlapi_bmac_write_template_ram(struct phy_shim_info *physhim, int offset,188int len, void *buf)189{190brcms_b_write_template_ram(physhim->wlc_hw, offset, len, buf);191}192193u16 wlapi_bmac_rate_shm_offset(struct phy_shim_info *physhim, u8 rate)194{195return brcms_b_rate_shm_offset(physhim->wlc_hw, rate);196}197198void wlapi_ucode_sample_init(struct phy_shim_info *physhim)199{200}201202void203wlapi_copyfrom_objmem(struct phy_shim_info *physhim, uint offset, void *buf,204int len, u32 sel)205{206brcms_b_copyfrom_objmem(physhim->wlc_hw, offset, buf, len, sel);207}208209void210wlapi_copyto_objmem(struct phy_shim_info *physhim, uint offset, const void *buf,211int l, u32 sel)212{213brcms_b_copyto_objmem(physhim->wlc_hw, offset, buf, l, sel);214}215216217