Commit 127aa5cf authored by Roland Vossen's avatar Roland Vossen Committed by Greg Kroah-Hartman

staging: brcm80211: sdh related code cleanup

Gave struct brcmf_sdio the more applicable name 'brcmf_sdio_card'. Enforced
stronger type checking by replacing void *sdh by struct brcmf_sdio_card *.
Signed-off-by: default avatarRoland Vossen <rvossen@broadcom.com>
Reviewed-by: default avatarArend van Spriel <arend@broadcom.com>
Reviewed-by: default avatarFranky Lin <frankyl@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 62dd656d
...@@ -105,7 +105,7 @@ extern int brcmf_sdioh_stop(struct sdioh_info *si); ...@@ -105,7 +105,7 @@ extern int brcmf_sdioh_stop(struct sdioh_info *si);
extern int brcmf_sdioh_reset(struct sdioh_info *si); extern int brcmf_sdioh_reset(struct sdioh_info *si);
/* Helper function */ /* Helper function */
void *brcmf_sdcard_get_sdioh(struct brcmf_sdio *sdh); void *brcmf_sdcard_get_sdioh(struct brcmf_sdio_card *card);
/* Watchdog timer interface for pm ops */ /* Watchdog timer interface for pm ops */
extern void brcmf_sdio_wdtmr_enable(bool enable); extern void brcmf_sdio_wdtmr_enable(bool enable);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
/* ****************** SDIOCARD Interface Functions ***************************/ /* ****************** SDIO CARD Interface Functions **************************/
#include <linux/types.h> #include <linux/types.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#define SDIOH_API_ACCESS_RETRY_LIMIT 2 #define SDIOH_API_ACCESS_RETRY_LIMIT 2
const uint brcmf_sdio_msglevel = BRCMF_SD_ERROR_VAL; const uint brcmf_sdio_msglevel = BRCMF_SD_ERROR_VAL;
struct brcmf_sdio { struct brcmf_sdio_card {
bool init_success; /* underlying driver successfully attached */ bool init_success; /* underlying driver successfully attached */
void *sdioh; /* handler for sdioh */ void *sdioh; /* handler for sdioh */
u32 vendevid; /* Target Vendor and Device ID on SD bus */ u32 vendevid; /* Target Vendor and Device ID on SD bus */
...@@ -42,13 +42,14 @@ struct brcmf_sdio { ...@@ -42,13 +42,14 @@ struct brcmf_sdio {
u32 sbwad; /* Save backplane window address */ u32 sbwad; /* Save backplane window address */
}; };
/* local copy of bcm sd handler */ /* local copy of bcm sd handler */
static struct brcmf_sdio *l_card; static struct brcmf_sdio_card *l_card;
struct brcmf_sdio *brcmf_sdcard_attach(void *cfghdl, void **regsva, uint irq) struct brcmf_sdio_card*
brcmf_sdcard_attach(void *cfghdl, void **regsva, uint irq)
{ {
struct brcmf_sdio *card; struct brcmf_sdio_card *card;
card = kzalloc(sizeof(struct brcmf_sdio), GFP_ATOMIC); card = kzalloc(sizeof(struct brcmf_sdio_card), GFP_ATOMIC);
if (card == NULL) { if (card == NULL) {
BRCMF_SD_ERROR(("sdcard_attach: out of memory")); BRCMF_SD_ERROR(("sdcard_attach: out of memory"));
return NULL; return NULL;
...@@ -72,10 +73,8 @@ struct brcmf_sdio *brcmf_sdcard_attach(void *cfghdl, void **regsva, uint irq) ...@@ -72,10 +73,8 @@ struct brcmf_sdio *brcmf_sdcard_attach(void *cfghdl, void **regsva, uint irq)
return card; return card;
} }
int brcmf_sdcard_detach(void *sdh) int brcmf_sdcard_detach(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
if (card != NULL) { if (card != NULL) {
if (card->sdioh) { if (card->sdioh) {
brcmf_sdioh_detach(card->sdioh); brcmf_sdioh_detach(card->sdioh);
...@@ -89,17 +88,15 @@ int brcmf_sdcard_detach(void *sdh) ...@@ -89,17 +88,15 @@ int brcmf_sdcard_detach(void *sdh)
} }
int int
brcmf_sdcard_iovar_op(void *sdh, const char *name, brcmf_sdcard_iovar_op(struct brcmf_sdio_card *card, const char *name,
void *params, int plen, void *arg, int len, bool set) void *params, int plen, void *arg, int len, bool set)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
return brcmf_sdioh_iovar_op(card->sdioh, name, params, plen, arg, return brcmf_sdioh_iovar_op(card->sdioh, name, params, plen, arg,
len, set); len, set);
} }
bool brcmf_sdcard_intr_query(void *sdh) bool brcmf_sdcard_intr_query(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
int status; int status;
bool on; bool on;
...@@ -111,59 +108,57 @@ bool brcmf_sdcard_intr_query(void *sdh) ...@@ -111,59 +108,57 @@ bool brcmf_sdcard_intr_query(void *sdh)
return on; return on;
} }
int brcmf_sdcard_intr_enable(void *sdh) int brcmf_sdcard_intr_enable(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
ASSERT(card); ASSERT(card);
return brcmf_sdioh_interrupt_set(card->sdioh, true); return brcmf_sdioh_interrupt_set(card->sdioh, true);
} }
int brcmf_sdcard_intr_disable(void *sdh) int brcmf_sdcard_intr_disable(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
ASSERT(card); ASSERT(card);
return brcmf_sdioh_interrupt_set(card->sdioh, false); return brcmf_sdioh_interrupt_set(card->sdioh, false);
} }
int brcmf_sdcard_intr_reg(void *sdh, brcmf_sdiocard_cb_fn_t fn, void *argh) int brcmf_sdcard_intr_reg(struct brcmf_sdio_card *card,
brcmf_sdiocard_cb_fn_t fn,
void *argh)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
ASSERT(card); ASSERT(card);
return brcmf_sdioh_interrupt_register(card->sdioh, fn, argh); return brcmf_sdioh_interrupt_register(card->sdioh, fn, argh);
} }
int brcmf_sdcard_intr_dereg(void *sdh) int brcmf_sdcard_intr_dereg(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
ASSERT(card); ASSERT(card);
return brcmf_sdioh_interrupt_deregister(card->sdioh); return brcmf_sdioh_interrupt_deregister(card->sdioh);
} }
#if defined(BCMDBG) #if defined(BCMDBG)
bool brcmf_sdcard_intr_pending(void *sdh) bool brcmf_sdcard_intr_pending(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh; ASSERT(card);
ASSERT(sdh);
return brcmf_sdioh_interrupt_pending(card->sdioh); return brcmf_sdioh_interrupt_pending(card->sdioh);
} }
#endif #endif
int brcmf_sdcard_devremove_reg(void *sdh, brcmf_sdiocard_cb_fn_t fn, void *argh) int brcmf_sdcard_devremove_reg(struct brcmf_sdio_card *card,
brcmf_sdiocard_cb_fn_t fn,
void *argh)
{ {
ASSERT(sdh); ASSERT(card);
/* don't support yet */ /* don't support yet */
return -ENOTSUPP; return -ENOTSUPP;
} }
u8 brcmf_sdcard_cfg_read(void *sdh, uint fnc_num, u32 addr, int *err) u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_card *card, uint fnc_num, u32 addr,
int *err)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
int status; int status;
#ifdef SDIOH_API_ACCESS_RETRY_LIMIT #ifdef SDIOH_API_ACCESS_RETRY_LIMIT
s32 retry = 0; s32 retry = 0;
...@@ -197,9 +192,9 @@ u8 brcmf_sdcard_cfg_read(void *sdh, uint fnc_num, u32 addr, int *err) ...@@ -197,9 +192,9 @@ u8 brcmf_sdcard_cfg_read(void *sdh, uint fnc_num, u32 addr, int *err)
} }
void void
brcmf_sdcard_cfg_write(void *sdh, uint fnc_num, u32 addr, u8 data, int *err) brcmf_sdcard_cfg_write(struct brcmf_sdio_card *card, uint fnc_num, u32 addr,
u8 data, int *err)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
int status; int status;
#ifdef SDIOH_API_ACCESS_RETRY_LIMIT #ifdef SDIOH_API_ACCESS_RETRY_LIMIT
s32 retry = 0; s32 retry = 0;
...@@ -229,9 +224,9 @@ brcmf_sdcard_cfg_write(void *sdh, uint fnc_num, u32 addr, u8 data, int *err) ...@@ -229,9 +224,9 @@ brcmf_sdcard_cfg_write(void *sdh, uint fnc_num, u32 addr, u8 data, int *err)
__func__, fnc_num, addr, data)); __func__, fnc_num, addr, data));
} }
u32 brcmf_sdcard_cfg_read_word(void *sdh, uint fnc_num, u32 addr, int *err) u32 brcmf_sdcard_cfg_read_word(struct brcmf_sdio_card *card, uint fnc_num,
u32 addr, int *err)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
int status; int status;
u32 data = 0; u32 data = 0;
...@@ -253,10 +248,9 @@ u32 brcmf_sdcard_cfg_read_word(void *sdh, uint fnc_num, u32 addr, int *err) ...@@ -253,10 +248,9 @@ u32 brcmf_sdcard_cfg_read_word(void *sdh, uint fnc_num, u32 addr, int *err)
} }
void void
brcmf_sdcard_cfg_write_word(void *sdh, uint fnc_num, u32 addr, u32 data, brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card, uint fnc_num,
int *err) u32 addr, u32 data, int *err)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
int status; int status;
if (!card) if (!card)
...@@ -275,9 +269,9 @@ brcmf_sdcard_cfg_write_word(void *sdh, uint fnc_num, u32 addr, u32 data, ...@@ -275,9 +269,9 @@ brcmf_sdcard_cfg_write_word(void *sdh, uint fnc_num, u32 addr, u32 data,
__func__, fnc_num, addr, data)); __func__, fnc_num, addr, data));
} }
int brcmf_sdcard_cis_read(void *sdh, uint func, u8 * cis, uint length) int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func, u8 * cis,
uint length)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
int status; int status;
u8 *tmp_buf, *tmp_ptr; u8 *tmp_buf, *tmp_ptr;
...@@ -315,10 +309,10 @@ int brcmf_sdcard_cis_read(void *sdh, uint func, u8 * cis, uint length) ...@@ -315,10 +309,10 @@ int brcmf_sdcard_cis_read(void *sdh, uint func, u8 * cis, uint length)
return status; return status;
} }
static int brcmf_sdcard_set_sbaddr_window(void *sdh, u32 address) static int
brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_card *card, u32 address)
{ {
int err = 0; int err = 0;
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW,
(address >> 8) & SBSDIO_SBADDRLOW_MASK, &err); (address >> 8) & SBSDIO_SBADDRLOW_MASK, &err);
if (!err) if (!err)
...@@ -335,9 +329,8 @@ static int brcmf_sdcard_set_sbaddr_window(void *sdh, u32 address) ...@@ -335,9 +329,8 @@ static int brcmf_sdcard_set_sbaddr_window(void *sdh, u32 address)
return err; return err;
} }
u32 brcmf_sdcard_reg_read(void *sdh, u32 addr, uint size) u32 brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
int status; int status;
u32 word = 0; u32 word = 0;
uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
...@@ -388,9 +381,9 @@ u32 brcmf_sdcard_reg_read(void *sdh, u32 addr, uint size) ...@@ -388,9 +381,9 @@ u32 brcmf_sdcard_reg_read(void *sdh, u32 addr, uint size)
return 0xFFFFFFFF; return 0xFFFFFFFF;
} }
u32 brcmf_sdcard_reg_write(void *sdh, u32 addr, uint size, u32 data) u32 brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size,
u32 data)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
int status; int status;
uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
int err = 0; int err = 0;
...@@ -427,13 +420,14 @@ u32 brcmf_sdcard_reg_write(void *sdh, u32 addr, uint size, u32 data) ...@@ -427,13 +420,14 @@ u32 brcmf_sdcard_reg_write(void *sdh, u32 addr, uint size, u32 data)
return 0xFFFFFFFF; return 0xFFFFFFFF;
} }
bool brcmf_sdcard_regfail(void *sdh) bool brcmf_sdcard_regfail(struct brcmf_sdio_card *card)
{ {
return ((struct brcmf_sdio *) sdh)->regfail; return card->regfail;
} }
int int
brcmf_sdcard_recv_buf(struct brcmf_sdio *card, u32 addr, uint fn, uint flags, brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn,
uint flags,
u8 *buf, uint nbytes, struct sk_buff *pkt, u8 *buf, uint nbytes, struct sk_buff *pkt,
brcmf_sdio_cmplt_fn_t complete, void *handle) brcmf_sdio_cmplt_fn_t complete, void *handle)
{ {
...@@ -476,11 +470,10 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio *card, u32 addr, uint fn, uint flags, ...@@ -476,11 +470,10 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio *card, u32 addr, uint fn, uint flags,
} }
int int
brcmf_sdcard_send_buf(void *sdh, u32 addr, uint fn, uint flags, brcmf_sdcard_send_buf(struct brcmf_sdio_card *card, u32 addr, uint fn,
u8 *buf, uint nbytes, void *pkt, uint flags, u8 *buf, uint nbytes, void *pkt,
brcmf_sdio_cmplt_fn_t complete, void *handle) brcmf_sdio_cmplt_fn_t complete, void *handle)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
uint incr_fix; uint incr_fix;
uint width; uint width;
uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK;
...@@ -516,10 +509,9 @@ brcmf_sdcard_send_buf(void *sdh, u32 addr, uint fn, uint flags, ...@@ -516,10 +509,9 @@ brcmf_sdcard_send_buf(void *sdh, u32 addr, uint fn, uint flags,
incr_fix, SDIOH_WRITE, fn, addr, width, nbytes, buf, pkt); incr_fix, SDIOH_WRITE, fn, addr, width, nbytes, buf, pkt);
} }
int brcmf_sdcard_rwdata(void *sdh, uint rw, u32 addr, u8 *buf, uint nbytes) int brcmf_sdcard_rwdata(struct brcmf_sdio_card *card, uint rw, u32 addr,
u8 *buf, uint nbytes)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
ASSERT(card); ASSERT(card);
ASSERT(card->init_success); ASSERT(card->init_success);
ASSERT((addr & SBSDIO_SBWINDOW_MASK) == 0); ASSERT((addr & SBSDIO_SBWINDOW_MASK) == 0);
...@@ -532,74 +524,61 @@ int brcmf_sdcard_rwdata(void *sdh, uint rw, u32 addr, u8 *buf, uint nbytes) ...@@ -532,74 +524,61 @@ int brcmf_sdcard_rwdata(void *sdh, uint rw, u32 addr, u8 *buf, uint nbytes)
addr, 4, nbytes, buf, NULL); addr, 4, nbytes, buf, NULL);
} }
int brcmf_sdcard_abort(void *sdh, uint fn) int brcmf_sdcard_abort(struct brcmf_sdio_card *card, uint fn)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
return brcmf_sdioh_abort(card->sdioh, fn); return brcmf_sdioh_abort(card->sdioh, fn);
} }
int brcmf_sdcard_start(void *sdh, int stage) int brcmf_sdcard_start(struct brcmf_sdio_card *card, int stage)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
return brcmf_sdioh_start(card->sdioh, stage); return brcmf_sdioh_start(card->sdioh, stage);
} }
int brcmf_sdcard_stop(void *sdh) int brcmf_sdcard_stop(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
return brcmf_sdioh_stop(card->sdioh); return brcmf_sdioh_stop(card->sdioh);
} }
int brcmf_sdcard_query_device(void *sdh) int brcmf_sdcard_query_device(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
card->vendevid = (PCI_VENDOR_ID_BROADCOM << 16) | 0; card->vendevid = (PCI_VENDOR_ID_BROADCOM << 16) | 0;
return card->vendevid; return card->vendevid;
} }
uint brcmf_sdcard_query_iofnum(void *sdh) uint brcmf_sdcard_query_iofnum(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
if (!card) if (!card)
card = l_card; card = l_card;
return brcmf_sdioh_query_iofnum(card->sdioh); return brcmf_sdioh_query_iofnum(card->sdioh);
} }
int brcmf_sdcard_reset(struct brcmf_sdio *sdh) int brcmf_sdcard_reset(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
return brcmf_sdioh_reset(card->sdioh); return brcmf_sdioh_reset(card->sdioh);
} }
void *brcmf_sdcard_get_sdioh(struct brcmf_sdio *sdh) void *brcmf_sdcard_get_sdioh(struct brcmf_sdio_card *card)
{ {
ASSERT(sdh); ASSERT(card);
return sdh->sdioh; return card->sdioh;
} }
/* Function to pass device-status bits to DHD. */ /* Function to pass device-status bits to DHD. */
u32 brcmf_sdcard_get_dstatus(void *sdh) u32 brcmf_sdcard_get_dstatus(struct brcmf_sdio_card *card)
{ {
return 0; return 0;
} }
u32 brcmf_sdcard_cur_sbwad(void *sdh) u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card)
{ {
struct brcmf_sdio *card = (struct brcmf_sdio *) sdh;
if (!card) if (!card)
card = l_card; card = l_card;
return card->sbwad; return card->sbwad;
} }
void brcmf_sdcard_chipinfo(void *sdh, u32 chip, u32 chiprev) void brcmf_sdcard_chipinfo(struct brcmf_sdio_card *card, u32 chip, u32 chiprev)
{ {
return; return;
} }
...@@ -42,7 +42,7 @@ struct sdio_hc { ...@@ -42,7 +42,7 @@ struct sdio_hc {
struct sdio_hc *next; struct sdio_hc *next;
struct device *dev; /* platform device handle */ struct device *dev; /* platform device handle */
void *regs; /* SDIO Host Controller address */ void *regs; /* SDIO Host Controller address */
struct brcmf_sdio *sdh; /* SDIO Host Controller handle */ struct brcmf_sdio_card *card;
void *ch; void *ch;
unsigned int oob_irq; unsigned int oob_irq;
unsigned long oob_flags; /* OOB Host specifiction unsigned long oob_flags; /* OOB Host specifiction
...@@ -113,7 +113,7 @@ int brcmf_sdio_probe(struct device *dev) ...@@ -113,7 +113,7 @@ int brcmf_sdio_probe(struct device *dev)
{ {
struct sdio_hc *sdhc = NULL; struct sdio_hc *sdhc = NULL;
unsigned long regs = 0; unsigned long regs = 0;
struct brcmf_sdio *sdh = NULL; struct brcmf_sdio_card *card = NULL;
int irq = 0; int irq = 0;
u32 vendevid; u32 vendevid;
unsigned long irq_flags = 0; unsigned long irq_flags = 0;
...@@ -126,13 +126,13 @@ int brcmf_sdio_probe(struct device *dev) ...@@ -126,13 +126,13 @@ int brcmf_sdio_probe(struct device *dev)
} }
sdhc->dev = (void *)dev; sdhc->dev = (void *)dev;
sdh = brcmf_sdcard_attach((void *)0, (void **)&regs, irq); card = brcmf_sdcard_attach((void *)0, (void **)&regs, irq);
if (!sdh) { if (!card) {
SDLX_MSG(("%s: attach failed\n", __func__)); SDLX_MSG(("%s: attach failed\n", __func__));
goto err; goto err;
} }
sdhc->sdh = sdh; sdhc->card = card;
sdhc->oob_irq = irq; sdhc->oob_irq = irq;
sdhc->oob_flags = irq_flags; sdhc->oob_flags = irq_flags;
sdhc->oob_irq_registered = false; /* to make sure.. */ sdhc->oob_irq_registered = false; /* to make sure.. */
...@@ -141,11 +141,11 @@ int brcmf_sdio_probe(struct device *dev) ...@@ -141,11 +141,11 @@ int brcmf_sdio_probe(struct device *dev)
sdhc->next = sdhcinfo; sdhc->next = sdhcinfo;
sdhcinfo = sdhc; sdhcinfo = sdhc;
/* Read the vendor/device ID from the CIS */ /* Read the vendor/device ID from the CIS */
vendevid = brcmf_sdcard_query_device(sdh); vendevid = brcmf_sdcard_query_device(card);
/* try to attach to the target device */ /* try to attach to the target device */
sdhc->ch = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF), sdhc->ch = drvinfo.attach((vendevid >> 16), (vendevid & 0xFFFF),
0, 0, 0, 0, (void *)regs, sdh); 0, 0, 0, 0, (void *)regs, card);
if (!sdhc->ch) { if (!sdhc->ch) {
SDLX_MSG(("%s: device attach failed\n", __func__)); SDLX_MSG(("%s: device attach failed\n", __func__));
goto err; goto err;
...@@ -156,8 +156,8 @@ int brcmf_sdio_probe(struct device *dev) ...@@ -156,8 +156,8 @@ int brcmf_sdio_probe(struct device *dev)
/* error handling */ /* error handling */
err: err:
if (sdhc) { if (sdhc) {
if (sdhc->sdh) if (sdhc->card)
brcmf_sdcard_detach(sdhc->sdh); brcmf_sdcard_detach(sdhc->card);
kfree(sdhc); kfree(sdhc);
} }
...@@ -170,7 +170,7 @@ int brcmf_sdio_remove(struct device *dev) ...@@ -170,7 +170,7 @@ int brcmf_sdio_remove(struct device *dev)
sdhc = sdhcinfo; sdhc = sdhcinfo;
drvinfo.detach(sdhc->ch); drvinfo.detach(sdhc->ch);
brcmf_sdcard_detach(sdhc->sdh); brcmf_sdcard_detach(sdhc->card);
/* find the SDIO Host Controller state for this pdev /* find the SDIO Host Controller state for this pdev
and take it out from the list */ and take it out from the list */
for (sdhc = sdhcinfo, prev = NULL; sdhc; sdhc = sdhc->next) { for (sdhc = sdhcinfo, prev = NULL; sdhc; sdhc = sdhc->next) {
......
...@@ -458,7 +458,7 @@ struct chip_info { ...@@ -458,7 +458,7 @@ struct chip_info {
typedef struct dhd_bus { typedef struct dhd_bus {
struct brcmf_pub *dhd; struct brcmf_pub *dhd;
struct brcmf_sdio *sdh; /* Handle for sdio card calls */ struct brcmf_sdio_card *card; /* Handle for sdio card calls */
struct chip_info *ci; /* Chip info struct */ struct chip_info *ci; /* Chip info struct */
char *vars; /* Variables (from CIS and/or other) */ char *vars; /* Variables (from CIS and/or other) */
uint varsz; /* Size of variables buffer */ uint varsz; /* Size of variables buffer */
...@@ -744,7 +744,7 @@ do { \ ...@@ -744,7 +744,7 @@ do { \
retryvar = 0; \ retryvar = 0; \
do { \ do { \
regvar = R_REG(regaddr); \ regvar = R_REG(regaddr); \
} while (brcmf_sdcard_regfail(bus->sdh) && \ } while (brcmf_sdcard_regfail(bus->card) && \
(++retryvar <= retry_limit)); \ (++retryvar <= retry_limit)); \
if (retryvar) { \ if (retryvar) { \
bus->regfails += (retryvar-1); \ bus->regfails += (retryvar-1); \
...@@ -761,7 +761,7 @@ do { \ ...@@ -761,7 +761,7 @@ do { \
retryvar = 0; \ retryvar = 0; \
do { \ do { \
W_REG(regaddr, regval); \ W_REG(regaddr, regval); \
} while (brcmf_sdcard_regfail(bus->sdh) && \ } while (brcmf_sdcard_regfail(bus->card) && \
(++retryvar <= retry_limit)); \ (++retryvar <= retry_limit)); \
if (retryvar) { \ if (retryvar) { \
bus->regfails += (retryvar-1); \ bus->regfails += (retryvar-1); \
...@@ -794,10 +794,10 @@ static void brcmf_sdbrcm_release(dhd_bus_t *bus); ...@@ -794,10 +794,10 @@ static void brcmf_sdbrcm_release(dhd_bus_t *bus);
static void brcmf_sdbrcm_release_malloc(dhd_bus_t *bus); static void brcmf_sdbrcm_release_malloc(dhd_bus_t *bus);
static void brcmf_sdbrcm_disconnect(void *ptr); static void brcmf_sdbrcm_disconnect(void *ptr);
static bool brcmf_sdbrcm_chipmatch(u16 chipid); static bool brcmf_sdbrcm_chipmatch(u16 chipid);
static bool brcmf_sdbrcm_probe_attach(dhd_bus_t *bus, void *sdh, static bool brcmf_sdbrcm_probe_attach(dhd_bus_t *bus, void *card,
void *regsva, u16 devid); void *regsva, u16 devid);
static bool brcmf_sdbrcm_probe_malloc(dhd_bus_t *bus, void *sdh); static bool brcmf_sdbrcm_probe_malloc(dhd_bus_t *bus, void *card);
static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh); static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *card);
static void brcmf_sdbrcm_release_dongle(dhd_bus_t *bus); static void brcmf_sdbrcm_release_dongle(dhd_bus_t *bus);
static uint brcmf_process_nvram_vars(char *varbuf, uint len); static uint brcmf_process_nvram_vars(char *varbuf, uint len);
...@@ -808,14 +808,20 @@ static int brcmf_sdbrcm_send_buf(dhd_bus_t *bus, u32 addr, uint fn, ...@@ -808,14 +808,20 @@ static int brcmf_sdbrcm_send_buf(dhd_bus_t *bus, u32 addr, uint fn,
struct sk_buff *pkt, struct sk_buff *pkt,
brcmf_sdio_cmplt_fn_t complete, void *handle); brcmf_sdio_cmplt_fn_t complete, void *handle);
static bool brcmf_sdbrcm_download_firmware(struct dhd_bus *bus, void *sdh); static bool brcmf_sdbrcm_download_firmware(struct dhd_bus *bus, void *card);
static int _brcmf_sdbrcm_download_firmware(struct dhd_bus *bus); static int _brcmf_sdbrcm_download_firmware(struct dhd_bus *bus);
static int brcmf_sdbrcm_download_code_file(struct dhd_bus *bus); static int brcmf_sdbrcm_download_code_file(struct dhd_bus *bus);
static int brcmf_sdbrcm_download_nvram(struct dhd_bus *bus); static int brcmf_sdbrcm_download_nvram(struct dhd_bus *bus);
static void brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio *sdh, u32 corebase);
static void
brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_card *card, u32 corebase);
static int brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs); static int brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs);
static void brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio *sdh, u32 corebase);
static void
brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_card *card, u32 corebase);
static void brcmf_sdbrcm_sdiod_drive_strength_init(struct dhd_bus *bus, static void brcmf_sdbrcm_sdiod_drive_strength_init(struct dhd_bus *bus,
u32 drivestrength); u32 drivestrength);
static void brcmf_sdbrcm_chip_detach(struct dhd_bus *bus); static void brcmf_sdbrcm_chip_detach(struct dhd_bus *bus);
...@@ -853,14 +859,14 @@ static void brcmf_sdbrcm_setmemsize(struct dhd_bus *bus, int mem_size) ...@@ -853,14 +859,14 @@ static void brcmf_sdbrcm_setmemsize(struct dhd_bus *bus, int mem_size)
static int brcmf_sdbrcm_set_siaddr_window(dhd_bus_t *bus, u32 address) static int brcmf_sdbrcm_set_siaddr_window(dhd_bus_t *bus, u32 address)
{ {
int err = 0; int err = 0;
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW,
(address >> 8) & SBSDIO_SBADDRLOW_MASK, &err); (address >> 8) & SBSDIO_SBADDRLOW_MASK, &err);
if (!err) if (!err)
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1,
SBSDIO_FUNC1_SBADDRMID, SBSDIO_FUNC1_SBADDRMID,
(address >> 16) & SBSDIO_SBADDRMID_MASK, &err); (address >> 16) & SBSDIO_SBADDRMID_MASK, &err);
if (!err) if (!err)
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1,
SBSDIO_FUNC1_SBADDRHIGH, SBSDIO_FUNC1_SBADDRHIGH,
(address >> 24) & SBSDIO_SBADDRHIGH_MASK, (address >> 24) & SBSDIO_SBADDRHIGH_MASK,
&err); &err);
...@@ -872,12 +878,12 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok) ...@@ -872,12 +878,12 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok)
{ {
int err; int err;
u8 clkctl, clkreq, devctl; u8 clkctl, clkreq, devctl;
struct brcmf_sdio *sdh; struct brcmf_sdio_card *card;
DHD_TRACE(("%s: Enter\n", __func__)); DHD_TRACE(("%s: Enter\n", __func__));
clkctl = 0; clkctl = 0;
sdh = bus->sdh; card = bus->card;
if (on) { if (on) {
/* Request HT Avail */ /* Request HT Avail */
...@@ -888,7 +894,7 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok) ...@@ -888,7 +894,7 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok)
&& (bus->ci->chiprev == 0)) && (bus->ci->chiprev == 0))
clkreq |= SBSDIO_FORCE_ALP; clkreq |= SBSDIO_FORCE_ALP;
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err);
if (err) { if (err) {
DHD_ERROR(("%s: HT Avail request error: %d\n", DHD_ERROR(("%s: HT Avail request error: %d\n",
...@@ -903,7 +909,7 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok) ...@@ -903,7 +909,7 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok)
} }
/* Check current status */ /* Check current status */
clkctl = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, clkctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, &err); SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (err) { if (err) {
DHD_ERROR(("%s: HT Avail read error: %d\n", DHD_ERROR(("%s: HT Avail read error: %d\n",
...@@ -914,7 +920,7 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok) ...@@ -914,7 +920,7 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok)
/* Go to pending and await interrupt if appropriate */ /* Go to pending and await interrupt if appropriate */
if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) { if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) {
/* Allow only clock-available interrupt */ /* Allow only clock-available interrupt */
devctl = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, devctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, &err); SBSDIO_DEVICE_CTL, &err);
if (err) { if (err) {
DHD_ERROR(("%s: Devctl error setting CA: %d\n", DHD_ERROR(("%s: Devctl error setting CA: %d\n",
...@@ -923,7 +929,7 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok) ...@@ -923,7 +929,7 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok)
} }
devctl |= SBSDIO_DEVCTL_CA_INT_ONLY; devctl |= SBSDIO_DEVCTL_CA_INT_ONLY;
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, devctl, &err); SBSDIO_DEVICE_CTL, devctl, &err);
DHD_INFO(("CLKCTL: set PENDING\n")); DHD_INFO(("CLKCTL: set PENDING\n"));
bus->clkstate = CLK_PENDING; bus->clkstate = CLK_PENDING;
...@@ -932,10 +938,10 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok) ...@@ -932,10 +938,10 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok)
} else if (bus->clkstate == CLK_PENDING) { } else if (bus->clkstate == CLK_PENDING) {
/* Cancel CA-only interrupt filter */ /* Cancel CA-only interrupt filter */
devctl = devctl =
brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, &err); SBSDIO_DEVICE_CTL, &err);
devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, devctl, &err); SBSDIO_DEVICE_CTL, devctl, &err);
} }
...@@ -943,7 +949,7 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok) ...@@ -943,7 +949,7 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok)
if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) {
BRCMF_SPINWAIT_SLEEP(sdioh_spinwait_sleep, BRCMF_SPINWAIT_SLEEP(sdioh_spinwait_sleep,
((clkctl = ((clkctl =
brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, SBSDIO_FUNC1_CHIPCLKCSR,
&err)), &err)),
!SBSDIO_CLKAV(clkctl, bus->alp_only)), !SBSDIO_CLKAV(clkctl, bus->alp_only)),
...@@ -979,15 +985,15 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok) ...@@ -979,15 +985,15 @@ static int brcmf_sdbrcm_htclk(dhd_bus_t *bus, bool on, bool pendok)
if (bus->clkstate == CLK_PENDING) { if (bus->clkstate == CLK_PENDING) {
/* Cancel CA-only interrupt filter */ /* Cancel CA-only interrupt filter */
devctl = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, devctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, &err); SBSDIO_DEVICE_CTL, &err);
devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, devctl, &err); SBSDIO_DEVICE_CTL, devctl, &err);
} }
bus->clkstate = CLK_SDONLY; bus->clkstate = CLK_SDONLY;
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err); SBSDIO_FUNC1_CHIPCLKCSR, clkreq, &err);
DHD_INFO(("CLKCTL: turned OFF\n")); DHD_INFO(("CLKCTL: turned OFF\n"));
if (err) { if (err) {
...@@ -1071,7 +1077,7 @@ static int brcmf_sdbrcm_clkctl(dhd_bus_t *bus, uint target, bool pendok) ...@@ -1071,7 +1077,7 @@ static int brcmf_sdbrcm_clkctl(dhd_bus_t *bus, uint target, bool pendok)
int brcmf_sdbrcm_bussleep(dhd_bus_t *bus, bool sleep) int brcmf_sdbrcm_bussleep(dhd_bus_t *bus, bool sleep)
{ {
struct brcmf_sdio *sdh = bus->sdh; struct brcmf_sdio_card *card = bus->card;
struct sdpcmd_regs *regs = bus->regs; struct sdpcmd_regs *regs = bus->regs;
uint retries = 0; uint retries = 0;
...@@ -1090,7 +1096,7 @@ int brcmf_sdbrcm_bussleep(dhd_bus_t *bus, bool sleep) ...@@ -1090,7 +1096,7 @@ int brcmf_sdbrcm_bussleep(dhd_bus_t *bus, bool sleep)
return -EBUSY; return -EBUSY;
/* Disable SDIO interrupts (no longer interested) */ /* Disable SDIO interrupts (no longer interested) */
brcmf_sdcard_intr_disable(bus->sdh); brcmf_sdcard_intr_disable(bus->card);
/* Make sure the controller has the bus up */ /* Make sure the controller has the bus up */
brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false);
...@@ -1103,14 +1109,14 @@ int brcmf_sdbrcm_bussleep(dhd_bus_t *bus, bool sleep) ...@@ -1103,14 +1109,14 @@ int brcmf_sdbrcm_bussleep(dhd_bus_t *bus, bool sleep)
/* Turn off our contribution to the HT clock request */ /* Turn off our contribution to the HT clock request */
brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false); brcmf_sdbrcm_clkctl(bus, CLK_SDONLY, false);
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, SBSDIO_FUNC1_CHIPCLKCSR,
SBSDIO_FORCE_HW_CLKREQ_OFF, NULL); SBSDIO_FORCE_HW_CLKREQ_OFF, NULL);
/* Isolate the bus */ /* Isolate the bus */
if (bus->ci->chip != BCM4329_CHIP_ID if (bus->ci->chip != BCM4329_CHIP_ID
&& bus->ci->chip != BCM4319_CHIP_ID) { && bus->ci->chip != BCM4319_CHIP_ID) {
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, SBSDIO_DEVICE_CTL,
SBSDIO_DEVCTL_PADS_ISO, NULL); SBSDIO_DEVCTL_PADS_ISO, NULL);
} }
...@@ -1121,14 +1127,14 @@ int brcmf_sdbrcm_bussleep(dhd_bus_t *bus, bool sleep) ...@@ -1121,14 +1127,14 @@ int brcmf_sdbrcm_bussleep(dhd_bus_t *bus, bool sleep)
} else { } else {
/* Waking up: bus power up is ok, set local state */ /* Waking up: bus power up is ok, set local state */
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL);
/* Force pad isolation off if possible /* Force pad isolation off if possible
(in case power never toggled) */ (in case power never toggled) */
if ((bus->ci->buscoretype == PCMCIA_CORE_ID) if ((bus->ci->buscoretype == PCMCIA_CORE_ID)
&& (bus->ci->buscorerev >= 10)) && (bus->ci->buscorerev >= 10))
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, 0, NULL); SBSDIO_DEVICE_CTL, 0, NULL);
/* Make sure the controller has the bus up */ /* Make sure the controller has the bus up */
...@@ -1151,7 +1157,7 @@ int brcmf_sdbrcm_bussleep(dhd_bus_t *bus, bool sleep) ...@@ -1151,7 +1157,7 @@ int brcmf_sdbrcm_bussleep(dhd_bus_t *bus, bool sleep)
/* Enable interrupts again */ /* Enable interrupts again */
if (bus->intr && (bus->dhd->busstate == DHD_BUS_DATA)) { if (bus->intr && (bus->dhd->busstate == DHD_BUS_DATA)) {
bus->intdis = false; bus->intdis = false;
brcmf_sdcard_intr_enable(bus->sdh); brcmf_sdcard_intr_enable(bus->card);
} }
} }
...@@ -1174,13 +1180,13 @@ static int brcmf_sdbrcm_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, ...@@ -1174,13 +1180,13 @@ static int brcmf_sdbrcm_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
u16 len, pad = 0; u16 len, pad = 0;
u32 swheader; u32 swheader;
uint retries = 0; uint retries = 0;
struct brcmf_sdio *sdh; struct brcmf_sdio_card *card;
struct sk_buff *new; struct sk_buff *new;
int i; int i;
DHD_TRACE(("%s: Enter\n", __func__)); DHD_TRACE(("%s: Enter\n", __func__));
sdh = bus->sdh; card = bus->card;
if (bus->dhd->dongle_reset) { if (bus->dhd->dongle_reset) {
ret = -EPERM; ret = -EPERM;
...@@ -1268,7 +1274,7 @@ static int brcmf_sdbrcm_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, ...@@ -1268,7 +1274,7 @@ static int brcmf_sdbrcm_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
} }
do { do {
ret = brcmf_sdbrcm_send_buf(bus, brcmf_sdcard_cur_sbwad(sdh), ret = brcmf_sdbrcm_send_buf(bus, brcmf_sdcard_cur_sbwad(card),
SDIO_FUNC_2, F2SYNC, frame, len, pkt, NULL, NULL); SDIO_FUNC_2, F2SYNC, frame, len, pkt, NULL, NULL);
bus->f2txdata++; bus->f2txdata++;
ASSERT(ret != -BCME_PENDING); ASSERT(ret != -BCME_PENDING);
...@@ -1280,18 +1286,18 @@ static int brcmf_sdbrcm_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan, ...@@ -1280,18 +1286,18 @@ static int brcmf_sdbrcm_txpkt(dhd_bus_t *bus, struct sk_buff *pkt, uint chan,
"terminate frame.\n", __func__, ret)); "terminate frame.\n", __func__, ret));
bus->tx_sderrs++; bus->tx_sderrs++;
brcmf_sdcard_abort(sdh, SDIO_FUNC_2); brcmf_sdcard_abort(card, SDIO_FUNC_2);
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM,
NULL); NULL);
bus->f1regdata++; bus->f1regdata++;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
u8 hi, lo; u8 hi, lo;
hi = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, hi = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_FUNC1_WFRAMEBCHI, SBSDIO_FUNC1_WFRAMEBCHI,
NULL); NULL);
lo = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, lo = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_FUNC1_WFRAMEBCLO, SBSDIO_FUNC1_WFRAMEBCLO,
NULL); NULL);
bus->f1regdata += 2; bus->f1regdata += 2;
...@@ -1461,7 +1467,7 @@ static uint brcmf_sdbrcm_sendfromq(dhd_bus_t *bus, uint maxframes) ...@@ -1461,7 +1467,7 @@ static uint brcmf_sdbrcm_sendfromq(dhd_bus_t *bus, uint maxframes)
/* Check device status, signal pending interrupt */ /* Check device status, signal pending interrupt */
R_SDREG(intstatus, &regs->intstatus, retries); R_SDREG(intstatus, &regs->intstatus, retries);
bus->f2txdata++; bus->f2txdata++;
if (brcmf_sdcard_regfail(bus->sdh)) if (brcmf_sdcard_regfail(bus->card))
break; break;
if (intstatus & bus->hostintmask) if (intstatus & bus->hostintmask)
bus->ipend = true; bus->ipend = true;
...@@ -1483,7 +1489,7 @@ brcmf_sdbrcm_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen) ...@@ -1483,7 +1489,7 @@ brcmf_sdbrcm_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
u16 len; u16 len;
u32 swheader; u32 swheader;
uint retries = 0; uint retries = 0;
struct brcmf_sdio *sdh = bus->sdh; struct brcmf_sdio_card *card = bus->card;
u8 doff = 0; u8 doff = 0;
int ret = -1; int ret = -1;
int i; int i;
...@@ -1581,7 +1587,7 @@ brcmf_sdbrcm_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen) ...@@ -1581,7 +1587,7 @@ brcmf_sdbrcm_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
do { do {
bus->ctrl_frame_stat = false; bus->ctrl_frame_stat = false;
ret = brcmf_sdbrcm_send_buf(bus, ret = brcmf_sdbrcm_send_buf(bus,
brcmf_sdcard_cur_sbwad(sdh), SDIO_FUNC_2, brcmf_sdcard_cur_sbwad(card), SDIO_FUNC_2,
F2SYNC, frame, len, NULL, NULL, NULL); F2SYNC, frame, len, NULL, NULL, NULL);
ASSERT(ret != -BCME_PENDING); ASSERT(ret != -BCME_PENDING);
...@@ -1593,20 +1599,20 @@ brcmf_sdbrcm_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen) ...@@ -1593,20 +1599,20 @@ brcmf_sdbrcm_bus_txctl(struct dhd_bus *bus, unsigned char *msg, uint msglen)
__func__, ret)); __func__, ret));
bus->tx_sderrs++; bus->tx_sderrs++;
brcmf_sdcard_abort(sdh, SDIO_FUNC_2); brcmf_sdcard_abort(card, SDIO_FUNC_2);
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_FUNC1_FRAMECTRL, SBSDIO_FUNC1_FRAMECTRL,
SFC_WF_TERM, NULL); SFC_WF_TERM, NULL);
bus->f1regdata++; bus->f1regdata++;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
u8 hi, lo; u8 hi, lo;
hi = brcmf_sdcard_cfg_read(sdh, hi = brcmf_sdcard_cfg_read(card,
SDIO_FUNC_1, SDIO_FUNC_1,
SBSDIO_FUNC1_WFRAMEBCHI, SBSDIO_FUNC1_WFRAMEBCHI,
NULL); NULL);
lo = brcmf_sdcard_cfg_read(sdh, lo = brcmf_sdcard_cfg_read(card,
SDIO_FUNC_1, SDIO_FUNC_1,
SBSDIO_FUNC1_WFRAMEBCLO, SBSDIO_FUNC1_WFRAMEBCLO,
NULL); NULL);
...@@ -1884,7 +1890,7 @@ void brcmf_sdbrcm_bus_dump(struct brcmf_pub *dhdp, struct brcmu_strbuf *strbuf) ...@@ -1884,7 +1890,7 @@ void brcmf_sdbrcm_bus_dump(struct brcmf_pub *dhdp, struct brcmu_strbuf *strbuf)
#ifdef BCMDBG #ifdef BCMDBG
brcmu_bprintf(strbuf, "dpc_sched %d host interrupt%spending\n", brcmu_bprintf(strbuf, "dpc_sched %d host interrupt%spending\n",
bus->dpc_sched, bus->dpc_sched,
(brcmf_sdcard_intr_pending(bus->sdh) ? " " : " not ")); (brcmf_sdcard_intr_pending(bus->card) ? " " : " not "));
brcmu_bprintf(strbuf, "blocksize %d roundup %d\n", bus->blocksize, brcmu_bprintf(strbuf, "blocksize %d roundup %d\n", bus->blocksize,
bus->roundup); bus->roundup);
#endif /* BCMDBG */ #endif /* BCMDBG */
...@@ -1990,7 +1996,7 @@ brcmf_sdbrcm_membytes(dhd_bus_t *bus, bool write, u32 address, u8 *data, ...@@ -1990,7 +1996,7 @@ brcmf_sdbrcm_membytes(dhd_bus_t *bus, bool write, u32 address, u8 *data,
__func__, (write ? "write" : "read"), dsize, __func__, (write ? "write" : "read"), dsize,
sdaddr, (address & SBSDIO_SBWINDOW_MASK))); sdaddr, (address & SBSDIO_SBWINDOW_MASK)));
bcmerror = bcmerror =
brcmf_sdcard_rwdata(bus->sdh, write, sdaddr, data, dsize); brcmf_sdcard_rwdata(bus->card, write, sdaddr, data, dsize);
if (bcmerror) { if (bcmerror) {
DHD_ERROR(("%s: membytes transfer failed\n", __func__)); DHD_ERROR(("%s: membytes transfer failed\n", __func__));
break; break;
...@@ -2015,9 +2021,9 @@ brcmf_sdbrcm_membytes(dhd_bus_t *bus, bool write, u32 address, u8 *data, ...@@ -2015,9 +2021,9 @@ brcmf_sdbrcm_membytes(dhd_bus_t *bus, bool write, u32 address, u8 *data,
xfer_done: xfer_done:
/* Return the window to backplane enumeration space for core access */ /* Return the window to backplane enumeration space for core access */
if (brcmf_sdbrcm_set_siaddr_window(bus, if (brcmf_sdbrcm_set_siaddr_window(bus,
brcmf_sdcard_cur_sbwad(bus->sdh))) { brcmf_sdcard_cur_sbwad(bus->card))) {
DHD_ERROR(("%s: FAILED to set window back to 0x%x\n", DHD_ERROR(("%s: FAILED to set window back to 0x%x\n",
__func__, brcmf_sdcard_cur_sbwad(bus->sdh))); __func__, brcmf_sdcard_cur_sbwad(bus->card)));
} }
return bcmerror; return bcmerror;
...@@ -2426,11 +2432,11 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid, ...@@ -2426,11 +2432,11 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid,
if (bus->intr) { if (bus->intr) {
DHD_INTR(("%s: enable SDIO device interrupts\n", DHD_INTR(("%s: enable SDIO device interrupts\n",
__func__)); __func__));
brcmf_sdcard_intr_enable(bus->sdh); brcmf_sdcard_intr_enable(bus->card);
} else { } else {
DHD_INTR(("%s: disable SDIO interrupts\n", DHD_INTR(("%s: disable SDIO interrupts\n",
__func__)); __func__));
brcmf_sdcard_intr_disable(bus->sdh); brcmf_sdcard_intr_disable(bus->card);
} }
} }
break; break;
...@@ -2623,9 +2629,9 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid, ...@@ -2623,9 +2629,9 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid,
addr = (unsigned long)bus->regs + sd_ptr->offset; addr = (unsigned long)bus->regs + sd_ptr->offset;
size = sd_ptr->func; size = sd_ptr->func;
int_val = (s32) brcmf_sdcard_reg_read(bus->sdh, addr, int_val = (s32) brcmf_sdcard_reg_read(bus->card, addr,
size); size);
if (brcmf_sdcard_regfail(bus->sdh)) if (brcmf_sdcard_regfail(bus->card))
bcmerror = -EIO; bcmerror = -EIO;
memcpy(arg, &int_val, sizeof(s32)); memcpy(arg, &int_val, sizeof(s32));
break; break;
...@@ -2640,9 +2646,9 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid, ...@@ -2640,9 +2646,9 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid,
addr = (unsigned long)bus->regs + sd_ptr->offset; addr = (unsigned long)bus->regs + sd_ptr->offset;
size = sd_ptr->func; size = sd_ptr->func;
brcmf_sdcard_reg_write(bus->sdh, addr, size, brcmf_sdcard_reg_write(bus->card, addr, size,
sd_ptr->value); sd_ptr->value);
if (brcmf_sdcard_regfail(bus->sdh)) if (brcmf_sdcard_regfail(bus->card))
bcmerror = -EIO; bcmerror = -EIO;
break; break;
} }
...@@ -2658,9 +2664,9 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid, ...@@ -2658,9 +2664,9 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid,
addr = SI_ENUM_BASE + sdreg.offset; addr = SI_ENUM_BASE + sdreg.offset;
size = sdreg.func; size = sdreg.func;
int_val = (s32) brcmf_sdcard_reg_read(bus->sdh, addr, int_val = (s32) brcmf_sdcard_reg_read(bus->card, addr,
size); size);
if (brcmf_sdcard_regfail(bus->sdh)) if (brcmf_sdcard_regfail(bus->card))
bcmerror = -EIO; bcmerror = -EIO;
memcpy(arg, &int_val, sizeof(s32)); memcpy(arg, &int_val, sizeof(s32));
break; break;
...@@ -2675,9 +2681,9 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid, ...@@ -2675,9 +2681,9 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid,
addr = SI_ENUM_BASE + sdreg.offset; addr = SI_ENUM_BASE + sdreg.offset;
size = sdreg.func; size = sdreg.func;
brcmf_sdcard_reg_write(bus->sdh, addr, size, brcmf_sdcard_reg_write(bus->card, addr, size,
sdreg.value); sdreg.value);
if (brcmf_sdcard_regfail(bus->sdh)) if (brcmf_sdcard_regfail(bus->card))
bcmerror = -EIO; bcmerror = -EIO;
break; break;
} }
...@@ -2687,15 +2693,15 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid, ...@@ -2687,15 +2693,15 @@ brcmf_sdbrcm_doiovar(dhd_bus_t *bus, const struct brcmu_iovar *vi, u32 actionid,
*(char *)arg = 0; *(char *)arg = 0;
strcat(arg, "\nFunc 0\n"); strcat(arg, "\nFunc 0\n");
brcmf_sdcard_cis_read(bus->sdh, 0x10, brcmf_sdcard_cis_read(bus->card, 0x10,
(u8 *) arg + strlen(arg), (u8 *) arg + strlen(arg),
SBSDIO_CIS_SIZE_LIMIT); SBSDIO_CIS_SIZE_LIMIT);
strcat(arg, "\nFunc 1\n"); strcat(arg, "\nFunc 1\n");
brcmf_sdcard_cis_read(bus->sdh, 0x11, brcmf_sdcard_cis_read(bus->card, 0x11,
(u8 *) arg + strlen(arg), (u8 *) arg + strlen(arg),
SBSDIO_CIS_SIZE_LIMIT); SBSDIO_CIS_SIZE_LIMIT);
strcat(arg, "\nFunc 2\n"); strcat(arg, "\nFunc 2\n");
brcmf_sdcard_cis_read(bus->sdh, 0x12, brcmf_sdcard_cis_read(bus->card, 0x12,
(u8 *) arg + strlen(arg), (u8 *) arg + strlen(arg),
SBSDIO_CIS_SIZE_LIMIT); SBSDIO_CIS_SIZE_LIMIT);
break; break;
...@@ -2907,9 +2913,9 @@ static int brcmf_sdbrcm_download_state(dhd_bus_t *bus, bool enter) ...@@ -2907,9 +2913,9 @@ static int brcmf_sdbrcm_download_state(dhd_bus_t *bus, bool enter)
if (enter) { if (enter) {
bus->alp_only = true; bus->alp_only = true;
brcmf_sdbrcm_chip_disablecore(bus->sdh, bus->ci->armcorebase); brcmf_sdbrcm_chip_disablecore(bus->card, bus->ci->armcorebase);
brcmf_sdbrcm_chip_resetcore(bus->sdh, bus->ci->ramcorebase); brcmf_sdbrcm_chip_resetcore(bus->card, bus->ci->ramcorebase);
/* Clear the top bit of memory */ /* Clear the top bit of memory */
if (bus->ramsize) { if (bus->ramsize) {
...@@ -2918,7 +2924,7 @@ static int brcmf_sdbrcm_download_state(dhd_bus_t *bus, bool enter) ...@@ -2918,7 +2924,7 @@ static int brcmf_sdbrcm_download_state(dhd_bus_t *bus, bool enter)
(u8 *)&zeros, 4); (u8 *)&zeros, 4);
} }
} else { } else {
regdata = brcmf_sdcard_reg_read(bus->sdh, regdata = brcmf_sdcard_reg_read(bus->card,
CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4); CORE_SB(bus->ci->ramcorebase, sbtmstatelow), 4);
regdata &= (SBTML_RESET | SBTML_REJ_MASK | regdata &= (SBTML_RESET | SBTML_REJ_MASK |
(SICF_CLOCK_EN << SBTML_SICF_SHIFT)); (SICF_CLOCK_EN << SBTML_SICF_SHIFT));
...@@ -2937,7 +2943,7 @@ static int brcmf_sdbrcm_download_state(dhd_bus_t *bus, bool enter) ...@@ -2937,7 +2943,7 @@ static int brcmf_sdbrcm_download_state(dhd_bus_t *bus, bool enter)
W_SDREG(0xFFFFFFFF, &bus->regs->intstatus, retries); W_SDREG(0xFFFFFFFF, &bus->regs->intstatus, retries);
brcmf_sdbrcm_chip_resetcore(bus->sdh, bus->ci->armcorebase); brcmf_sdbrcm_chip_resetcore(bus->card, bus->ci->armcorebase);
/* Allow HT Clock now that the ARM is running. */ /* Allow HT Clock now that the ARM is running. */
bus->alp_only = false; bus->alp_only = false;
...@@ -2979,14 +2985,14 @@ brcmf_sdbrcm_bus_iovar_op(struct brcmf_pub *dhdp, const char *name, ...@@ -2979,14 +2985,14 @@ brcmf_sdbrcm_bus_iovar_op(struct brcmf_pub *dhdp, const char *name,
/* Turn on clock in case SD command needs backplane */ /* Turn on clock in case SD command needs backplane */
brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false); brcmf_sdbrcm_clkctl(bus, CLK_AVAIL, false);
bcmerror = brcmf_sdcard_iovar_op(bus->sdh, name, params, plen, bcmerror = brcmf_sdcard_iovar_op(bus->card, name, params, plen,
arg, len, set); arg, len, set);
/* Similar check for blocksize change */ /* Similar check for blocksize change */
if (set && strcmp(name, "sd_blocksize") == 0) { if (set && strcmp(name, "sd_blocksize") == 0) {
s32 fnum = 2; s32 fnum = 2;
if (brcmf_sdcard_iovar_op if (brcmf_sdcard_iovar_op
(bus->sdh, "sd_blocksize", &fnum, sizeof(s32), (bus->card, "sd_blocksize", &fnum, sizeof(s32),
&bus->blocksize, sizeof(s32), &bus->blocksize, sizeof(s32),
false) != 0) { false) != 0) {
bus->blocksize = 0; bus->blocksize = 0;
...@@ -3076,10 +3082,10 @@ void brcmf_sdbrcm_bus_stop(struct dhd_bus *bus, bool enforce_mutex) ...@@ -3076,10 +3082,10 @@ void brcmf_sdbrcm_bus_stop(struct dhd_bus *bus, bool enforce_mutex)
bus->dhd->busstate = DHD_BUS_DOWN; bus->dhd->busstate = DHD_BUS_DOWN;
/* Force clocks on backplane to be sure F2 interrupt propagates */ /* Force clocks on backplane to be sure F2 interrupt propagates */
saveclk = brcmf_sdcard_cfg_read(bus->sdh, SDIO_FUNC_1, saveclk = brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, &err); SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (!err) { if (!err) {
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, SBSDIO_FUNC1_CHIPCLKCSR,
(saveclk | SBSDIO_FORCE_HT), &err); (saveclk | SBSDIO_FORCE_HT), &err);
} }
...@@ -3090,8 +3096,8 @@ void brcmf_sdbrcm_bus_stop(struct dhd_bus *bus, bool enforce_mutex) ...@@ -3090,8 +3096,8 @@ void brcmf_sdbrcm_bus_stop(struct dhd_bus *bus, bool enforce_mutex)
/* Turn off the bus (F2), free any pending packets */ /* Turn off the bus (F2), free any pending packets */
DHD_INTR(("%s: disable SDIO interrupts\n", __func__)); DHD_INTR(("%s: disable SDIO interrupts\n", __func__));
brcmf_sdcard_intr_disable(bus->sdh); brcmf_sdcard_intr_disable(bus->card);
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_0, SDIO_CCCR_IOEx, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_0, SDIO_CCCR_IOEx,
SDIO_FUNC_ENABLE_1, NULL); SDIO_FUNC_ENABLE_1, NULL);
/* Clear any pending interrupts now that F2 is disabled */ /* Clear any pending interrupts now that F2 is disabled */
...@@ -3141,7 +3147,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex) ...@@ -3141,7 +3147,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex)
/* try to download image and nvram to the dongle */ /* try to download image and nvram to the dongle */
if (dhdp->busstate == DHD_BUS_DOWN) { if (dhdp->busstate == DHD_BUS_DOWN) {
if (!(brcmf_sdbrcm_download_firmware(bus, bus->sdh))) if (!(brcmf_sdbrcm_download_firmware(bus, bus->card)))
return -1; return -1;
} }
...@@ -3163,10 +3169,10 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex) ...@@ -3163,10 +3169,10 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex)
/* Force clocks on backplane to be sure F2 interrupt propagates */ /* Force clocks on backplane to be sure F2 interrupt propagates */
saveclk = saveclk =
brcmf_sdcard_cfg_read(bus->sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, &err); SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (!err) { if (!err) {
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, SBSDIO_FUNC1_CHIPCLKCSR,
(saveclk | SBSDIO_FORCE_HT), &err); (saveclk | SBSDIO_FORCE_HT), &err);
} }
...@@ -3181,7 +3187,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex) ...@@ -3181,7 +3187,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex)
&bus->regs->tosbmailboxdata, retries); &bus->regs->tosbmailboxdata, retries);
enable = (SDIO_FUNC_ENABLE_1 | SDIO_FUNC_ENABLE_2); enable = (SDIO_FUNC_ENABLE_1 | SDIO_FUNC_ENABLE_2);
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_0, SDIO_CCCR_IOEx, enable, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_0, SDIO_CCCR_IOEx, enable,
NULL); NULL);
/* Give the dongle some time to do its thing and set IOR2 */ /* Give the dongle some time to do its thing and set IOR2 */
...@@ -3189,9 +3195,8 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex) ...@@ -3189,9 +3195,8 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex)
ready = 0; ready = 0;
while (ready != enable && !brcmf_timeout_expired(&tmo)) while (ready != enable && !brcmf_timeout_expired(&tmo))
ready = ready = brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_0,
brcmf_sdcard_cfg_read(bus->sdh, SDIO_FUNC_0, SDIO_CCCR_IORx, SDIO_CCCR_IORx, NULL);
NULL);
DHD_INFO(("%s: enable 0x%02x, ready 0x%02x (waited %uus)\n", DHD_INFO(("%s: enable 0x%02x, ready 0x%02x (waited %uus)\n",
__func__, enable, ready, tmo.elapsed)); __func__, enable, ready, tmo.elapsed));
...@@ -3204,7 +3209,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex) ...@@ -3204,7 +3209,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex)
(unsigned int *)CORE_BUS_REG(bus->ci->buscorebase, (unsigned int *)CORE_BUS_REG(bus->ci->buscorebase,
hostintmask), retries); hostintmask), retries);
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_WATERMARK, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_WATERMARK,
(u8) watermark, &err); (u8) watermark, &err);
/* Set bus state according to enable result */ /* Set bus state according to enable result */
...@@ -3214,10 +3219,10 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex) ...@@ -3214,10 +3219,10 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex)
if (bus->intr) { if (bus->intr) {
DHD_INTR(("%s: enable SDIO device interrupts\n", DHD_INTR(("%s: enable SDIO device interrupts\n",
__func__)); __func__));
brcmf_sdcard_intr_enable(bus->sdh); brcmf_sdcard_intr_enable(bus->card);
} else { } else {
DHD_INTR(("%s: disable SDIO interrupts\n", __func__)); DHD_INTR(("%s: disable SDIO interrupts\n", __func__));
brcmf_sdcard_intr_disable(bus->sdh); brcmf_sdcard_intr_disable(bus->card);
} }
} }
...@@ -3225,12 +3230,12 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex) ...@@ -3225,12 +3230,12 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex)
else { else {
/* Disable F2 again */ /* Disable F2 again */
enable = SDIO_FUNC_ENABLE_1; enable = SDIO_FUNC_ENABLE_1;
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_0, SDIO_CCCR_IOEx, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_0, SDIO_CCCR_IOEx,
enable, NULL); enable, NULL);
} }
/* Restore previous clock setting */ /* Restore previous clock setting */
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
saveclk, &err); saveclk, &err);
#if defined(OOB_INTR_ONLY) #if defined(OOB_INTR_ONLY)
...@@ -3259,7 +3264,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex) ...@@ -3259,7 +3264,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *dhdp, bool enforce_mutex)
static void brcmf_sdbrcm_rxfail(dhd_bus_t *bus, bool abort, bool rtx) static void brcmf_sdbrcm_rxfail(dhd_bus_t *bus, bool abort, bool rtx)
{ {
struct brcmf_sdio *sdh = bus->sdh; struct brcmf_sdio_card *card = bus->card;
struct sdpcmd_regs *regs = bus->regs; struct sdpcmd_regs *regs = bus->regs;
uint retries = 0; uint retries = 0;
u16 lastrbc; u16 lastrbc;
...@@ -3271,17 +3276,17 @@ static void brcmf_sdbrcm_rxfail(dhd_bus_t *bus, bool abort, bool rtx) ...@@ -3271,17 +3276,17 @@ static void brcmf_sdbrcm_rxfail(dhd_bus_t *bus, bool abort, bool rtx)
(rtx ? ", send NAK" : ""))); (rtx ? ", send NAK" : "")));
if (abort) if (abort)
brcmf_sdcard_abort(sdh, SDIO_FUNC_2); brcmf_sdcard_abort(card, SDIO_FUNC_2);
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_FRAMECTRL, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, SBSDIO_FUNC1_FRAMECTRL,
SFC_RF_TERM, &err); SFC_RF_TERM, &err);
bus->f1regdata++; bus->f1regdata++;
/* Wait until the packet has been flushed (device/FIFO stable) */ /* Wait until the packet has been flushed (device/FIFO stable) */
for (lastrbc = retries = 0xffff; retries > 0; retries--) { for (lastrbc = retries = 0xffff; retries > 0; retries--) {
hi = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, hi = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_FUNC1_RFRAMEBCHI, NULL); SBSDIO_FUNC1_RFRAMEBCHI, NULL);
lo = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, lo = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_FUNC1_RFRAMEBCLO, NULL); SBSDIO_FUNC1_RFRAMEBCLO, NULL);
bus->f1regdata += 2; bus->f1regdata += 2;
...@@ -3316,14 +3321,14 @@ static void brcmf_sdbrcm_rxfail(dhd_bus_t *bus, bool abort, bool rtx) ...@@ -3316,14 +3321,14 @@ static void brcmf_sdbrcm_rxfail(dhd_bus_t *bus, bool abort, bool rtx)
bus->nextlen = 0; bus->nextlen = 0;
/* If we can't reach the device, signal failure */ /* If we can't reach the device, signal failure */
if (err || brcmf_sdcard_regfail(sdh)) if (err || brcmf_sdcard_regfail(card))
bus->dhd->busstate = DHD_BUS_DOWN; bus->dhd->busstate = DHD_BUS_DOWN;
} }
static void static void
brcmf_sdbrcm_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff) brcmf_sdbrcm_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff)
{ {
struct brcmf_sdio *sdh = bus->sdh; struct brcmf_sdio_card *card = bus->card;
uint rdlen, pad; uint rdlen, pad;
int sdret; int sdret;
...@@ -3392,7 +3397,7 @@ brcmf_sdbrcm_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff) ...@@ -3392,7 +3397,7 @@ brcmf_sdbrcm_read_control(dhd_bus_t *bus, u8 *hdr, uint len, uint doff)
} }
/* Read remainder of frame body into the rxctl buffer */ /* Read remainder of frame body into the rxctl buffer */
sdret = brcmf_sdcard_recv_buf(sdh, brcmf_sdcard_cur_sbwad(sdh), sdret = brcmf_sdcard_recv_buf(card, brcmf_sdcard_cur_sbwad(card),
SDIO_FUNC_2, SDIO_FUNC_2,
F2SYNC, (bus->rxctl + firstread), rdlen, F2SYNC, (bus->rxctl + firstread), rdlen,
NULL, NULL, NULL); NULL, NULL, NULL);
...@@ -3555,14 +3560,14 @@ static u8 brcmf_sdbrcm_rxglom(dhd_bus_t *bus, u8 rxseq) ...@@ -3555,14 +3560,14 @@ static u8 brcmf_sdbrcm_rxglom(dhd_bus_t *bus, u8 rxseq)
* packet and and copy into the chain. * packet and and copy into the chain.
*/ */
if (usechain) { if (usechain) {
errcode = brcmf_sdcard_recv_buf(bus->sdh, errcode = brcmf_sdcard_recv_buf(bus->card,
brcmf_sdcard_cur_sbwad(bus->sdh), brcmf_sdcard_cur_sbwad(bus->card),
SDIO_FUNC_2, SDIO_FUNC_2,
F2SYNC, (u8 *) pfirst->data, dlen, F2SYNC, (u8 *) pfirst->data, dlen,
pfirst, NULL, NULL); pfirst, NULL, NULL);
} else if (bus->dataptr) { } else if (bus->dataptr) {
errcode = brcmf_sdcard_recv_buf(bus->sdh, errcode = brcmf_sdcard_recv_buf(bus->card,
brcmf_sdcard_cur_sbwad(bus->sdh), brcmf_sdcard_cur_sbwad(bus->card),
SDIO_FUNC_2, SDIO_FUNC_2,
F2SYNC, bus->dataptr, dlen, F2SYNC, bus->dataptr, dlen,
NULL, NULL, NULL); NULL, NULL, NULL);
...@@ -3831,7 +3836,7 @@ static u8 brcmf_sdbrcm_rxglom(dhd_bus_t *bus, u8 rxseq) ...@@ -3831,7 +3836,7 @@ static u8 brcmf_sdbrcm_rxglom(dhd_bus_t *bus, u8 rxseq)
static uint static uint
brcmf_sdbrcm_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) brcmf_sdbrcm_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
{ {
struct brcmf_sdio *sdh = bus->sdh; struct brcmf_sdio_card *card = bus->card;
u16 len, check; /* Extracted hardware header fields */ u16 len, check; /* Extracted hardware header fields */
u8 chan, seq, doff; /* Extracted software header fields */ u8 chan, seq, doff; /* Extracted software header fields */
...@@ -3940,8 +3945,8 @@ brcmf_sdbrcm_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) ...@@ -3940,8 +3945,8 @@ brcmf_sdbrcm_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
ASSERT(bus->rxctl >= bus->rxbuf); ASSERT(bus->rxctl >= bus->rxbuf);
rxbuf = bus->rxctl; rxbuf = bus->rxctl;
/* Read the entire frame */ /* Read the entire frame */
sdret = brcmf_sdcard_recv_buf(sdh, sdret = brcmf_sdcard_recv_buf(card,
brcmf_sdcard_cur_sbwad(sdh), brcmf_sdcard_cur_sbwad(card),
SDIO_FUNC_2, F2SYNC, SDIO_FUNC_2, F2SYNC,
rxbuf, rdlen, rxbuf, rdlen,
NULL, NULL, NULL); NULL, NULL, NULL);
...@@ -3981,8 +3986,8 @@ brcmf_sdbrcm_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) ...@@ -3981,8 +3986,8 @@ brcmf_sdbrcm_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
PKTALIGN(pkt, rdlen, BRCMF_SDALIGN); PKTALIGN(pkt, rdlen, BRCMF_SDALIGN);
rxbuf = (u8 *) (pkt->data); rxbuf = (u8 *) (pkt->data);
/* Read the entire frame */ /* Read the entire frame */
sdret = brcmf_sdcard_recv_buf(sdh, sdret = brcmf_sdcard_recv_buf(card,
brcmf_sdcard_cur_sbwad(sdh), brcmf_sdcard_cur_sbwad(card),
SDIO_FUNC_2, F2SYNC, SDIO_FUNC_2, F2SYNC,
rxbuf, rdlen, rxbuf, rdlen,
pkt, NULL, NULL); pkt, NULL, NULL);
...@@ -4160,7 +4165,8 @@ brcmf_sdbrcm_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) ...@@ -4160,7 +4165,8 @@ brcmf_sdbrcm_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
break; break;
/* Read frame header (hardware and software) */ /* Read frame header (hardware and software) */
sdret = brcmf_sdcard_recv_buf(sdh, brcmf_sdcard_cur_sbwad(sdh), sdret = brcmf_sdcard_recv_buf(card,
brcmf_sdcard_cur_sbwad(card),
SDIO_FUNC_2, F2SYNC, bus->rxhdr, firstread, SDIO_FUNC_2, F2SYNC, bus->rxhdr, firstread,
NULL, NULL, NULL); NULL, NULL, NULL);
bus->f2rxhdrs++; bus->f2rxhdrs++;
...@@ -4321,7 +4327,8 @@ brcmf_sdbrcm_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) ...@@ -4321,7 +4327,8 @@ brcmf_sdbrcm_readframes(dhd_bus_t *bus, uint maxframes, bool *finished)
PKTALIGN(pkt, rdlen, BRCMF_SDALIGN); PKTALIGN(pkt, rdlen, BRCMF_SDALIGN);
/* Read the remaining frame data */ /* Read the remaining frame data */
sdret = brcmf_sdcard_recv_buf(sdh, brcmf_sdcard_cur_sbwad(sdh), sdret = brcmf_sdcard_recv_buf(card,
brcmf_sdcard_cur_sbwad(card),
SDIO_FUNC_2, F2SYNC, ((u8 *) (pkt->data)), SDIO_FUNC_2, F2SYNC, ((u8 *) (pkt->data)),
rdlen, pkt, NULL, NULL); rdlen, pkt, NULL, NULL);
bus->f2rxdata++; bus->f2rxdata++;
...@@ -4499,7 +4506,7 @@ static u32 brcmf_sdbrcm_hostmail(dhd_bus_t *bus) ...@@ -4499,7 +4506,7 @@ static u32 brcmf_sdbrcm_hostmail(dhd_bus_t *bus)
static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus) static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus)
{ {
struct brcmf_sdio *sdh = bus->sdh; struct brcmf_sdio_card *card = bus->card;
struct sdpcmd_regs *regs = bus->regs; struct sdpcmd_regs *regs = bus->regs;
u32 intstatus, newstatus = 0; u32 intstatus, newstatus = 0;
uint retries = 0; uint retries = 0;
...@@ -4523,7 +4530,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus) ...@@ -4523,7 +4530,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus)
#ifdef BCMDBG #ifdef BCMDBG
/* Check for inconsistent device control */ /* Check for inconsistent device control */
devctl = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, devctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, &err); SBSDIO_DEVICE_CTL, &err);
if (err) { if (err) {
DHD_ERROR(("%s: error reading DEVCTL: %d\n", DHD_ERROR(("%s: error reading DEVCTL: %d\n",
...@@ -4535,7 +4542,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus) ...@@ -4535,7 +4542,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus)
#endif /* BCMDBG */ #endif /* BCMDBG */
/* Read CSR, if clock on switch to AVAIL, else ignore */ /* Read CSR, if clock on switch to AVAIL, else ignore */
clkctl = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, clkctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, &err); SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (err) { if (err) {
DHD_ERROR(("%s: error reading CSR: %d\n", __func__, DHD_ERROR(("%s: error reading CSR: %d\n", __func__,
...@@ -4547,7 +4554,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus) ...@@ -4547,7 +4554,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus)
clkctl)); clkctl));
if (SBSDIO_HTAV(clkctl)) { if (SBSDIO_HTAV(clkctl)) {
devctl = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, devctl = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, &err); SBSDIO_DEVICE_CTL, &err);
if (err) { if (err) {
DHD_ERROR(("%s: error reading DEVCTL: %d\n", DHD_ERROR(("%s: error reading DEVCTL: %d\n",
...@@ -4555,7 +4562,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus) ...@@ -4555,7 +4562,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus)
bus->dhd->busstate = DHD_BUS_DOWN; bus->dhd->busstate = DHD_BUS_DOWN;
} }
devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY;
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_DEVICE_CTL, devctl, &err); SBSDIO_DEVICE_CTL, devctl, &err);
if (err) { if (err) {
DHD_ERROR(("%s: error writing DEVCTL: %d\n", DHD_ERROR(("%s: error writing DEVCTL: %d\n",
...@@ -4580,7 +4587,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus) ...@@ -4580,7 +4587,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus)
bus->ipend = false; bus->ipend = false;
R_SDREG(newstatus, &regs->intstatus, retries); R_SDREG(newstatus, &regs->intstatus, retries);
bus->f1regdata++; bus->f1regdata++;
if (brcmf_sdcard_regfail(bus->sdh)) if (brcmf_sdcard_regfail(bus->card))
newstatus = 0; newstatus = 0;
newstatus &= bus->hostintmask; newstatus &= bus->hostintmask;
bus->fcstate = !!(newstatus & I_HMB_FC_STATE); bus->fcstate = !!(newstatus & I_HMB_FC_STATE);
...@@ -4656,18 +4663,18 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus) ...@@ -4656,18 +4663,18 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus)
* or clock availability. (Allows tx loop to check ipend if desired.) * or clock availability. (Allows tx loop to check ipend if desired.)
* (Unless register access seems hosed, as we may not be able to ACK...) * (Unless register access seems hosed, as we may not be able to ACK...)
*/ */
if (bus->intr && bus->intdis && !brcmf_sdcard_regfail(sdh)) { if (bus->intr && bus->intdis && !brcmf_sdcard_regfail(card)) {
DHD_INTR(("%s: enable SDIO interrupts, rxdone %d framecnt %d\n", DHD_INTR(("%s: enable SDIO interrupts, rxdone %d framecnt %d\n",
__func__, rxdone, framecnt)); __func__, rxdone, framecnt));
bus->intdis = false; bus->intdis = false;
brcmf_sdcard_intr_enable(sdh); brcmf_sdcard_intr_enable(card);
} }
if (DATAOK(bus) && bus->ctrl_frame_stat && if (DATAOK(bus) && bus->ctrl_frame_stat &&
(bus->clkstate == CLK_AVAIL)) { (bus->clkstate == CLK_AVAIL)) {
int ret, i; int ret, i;
ret = brcmf_sdbrcm_send_buf(bus, brcmf_sdcard_cur_sbwad(sdh), ret = brcmf_sdbrcm_send_buf(bus, brcmf_sdcard_cur_sbwad(card),
SDIO_FUNC_2, F2SYNC, (u8 *) bus->ctrl_frame_buf, SDIO_FUNC_2, F2SYNC, (u8 *) bus->ctrl_frame_buf,
(u32) bus->ctrl_frame_len, NULL, NULL, NULL); (u32) bus->ctrl_frame_len, NULL, NULL, NULL);
ASSERT(ret != -BCME_PENDING); ASSERT(ret != -BCME_PENDING);
...@@ -4679,19 +4686,19 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus) ...@@ -4679,19 +4686,19 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus)
"terminate frame.\n", __func__, ret)); "terminate frame.\n", __func__, ret));
bus->tx_sderrs++; bus->tx_sderrs++;
brcmf_sdcard_abort(sdh, SDIO_FUNC_2); brcmf_sdcard_abort(card, SDIO_FUNC_2);
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1,
SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM, SBSDIO_FUNC1_FRAMECTRL, SFC_WF_TERM,
NULL); NULL);
bus->f1regdata++; bus->f1regdata++;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
u8 hi, lo; u8 hi, lo;
hi = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, hi = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_FUNC1_WFRAMEBCHI, SBSDIO_FUNC1_WFRAMEBCHI,
NULL); NULL);
lo = brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, lo = brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_FUNC1_WFRAMEBCLO, SBSDIO_FUNC1_WFRAMEBCLO,
NULL); NULL);
bus->f1regdata += 2; bus->f1regdata += 2;
...@@ -4720,9 +4727,11 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus) ...@@ -4720,9 +4727,11 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus)
else await next interrupt */ else await next interrupt */
/* On failed register access, all bets are off: /* On failed register access, all bets are off:
no resched or interrupts */ no resched or interrupts */
if ((bus->dhd->busstate == DHD_BUS_DOWN) || brcmf_sdcard_regfail(sdh)) { if ((bus->dhd->busstate == DHD_BUS_DOWN) ||
brcmf_sdcard_regfail(card)) {
DHD_ERROR(("%s: failed backplane access over SDIO, halting " DHD_ERROR(("%s: failed backplane access over SDIO, halting "
"operation %d\n", __func__, brcmf_sdcard_regfail(sdh))); "operation %d\n", __func__,
brcmf_sdcard_regfail(card)));
bus->dhd->busstate = DHD_BUS_DOWN; bus->dhd->busstate = DHD_BUS_DOWN;
bus->intstatus = 0; bus->intstatus = 0;
} else if (bus->clkstate == CLK_PENDING) { } else if (bus->clkstate == CLK_PENDING) {
...@@ -4752,7 +4761,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus) ...@@ -4752,7 +4761,7 @@ static bool brcmf_sdbrcm_dpc(dhd_bus_t *bus)
void brcmf_sdbrcm_isr(void *arg) void brcmf_sdbrcm_isr(void *arg)
{ {
dhd_bus_t *bus = (dhd_bus_t *) arg; dhd_bus_t *bus = (dhd_bus_t *) arg;
struct brcmf_sdio *sdh; struct brcmf_sdio_card *card;
DHD_TRACE(("%s: Enter\n", __func__)); DHD_TRACE(("%s: Enter\n", __func__));
...@@ -4760,7 +4769,7 @@ void brcmf_sdbrcm_isr(void *arg) ...@@ -4760,7 +4769,7 @@ void brcmf_sdbrcm_isr(void *arg)
DHD_ERROR(("%s : bus is null pointer , exit\n", __func__)); DHD_ERROR(("%s : bus is null pointer , exit\n", __func__));
return; return;
} }
sdh = bus->sdh; card = bus->card;
if (bus->dhd->busstate == DHD_BUS_DOWN) { if (bus->dhd->busstate == DHD_BUS_DOWN) {
DHD_ERROR(("%s : bus is down. we have nothing to do\n", DHD_ERROR(("%s : bus is down. we have nothing to do\n",
...@@ -4783,7 +4792,7 @@ void brcmf_sdbrcm_isr(void *arg) ...@@ -4783,7 +4792,7 @@ void brcmf_sdbrcm_isr(void *arg)
else else
DHD_ERROR(("brcmf_sdbrcm_isr() w/o interrupt configured!\n")); DHD_ERROR(("brcmf_sdbrcm_isr() w/o interrupt configured!\n"));
brcmf_sdcard_intr_disable(sdh); brcmf_sdcard_intr_disable(card);
bus->intdis = true; bus->intdis = true;
#if defined(SDIO_ISR_THREAD) #if defined(SDIO_ISR_THREAD)
...@@ -5087,7 +5096,7 @@ extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *dhdp) ...@@ -5087,7 +5096,7 @@ extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *dhdp)
if (!bus->dpc_sched) { if (!bus->dpc_sched) {
u8 devpend; u8 devpend;
devpend = brcmf_sdcard_cfg_read(bus->sdh, devpend = brcmf_sdcard_cfg_read(bus->card,
SDIO_FUNC_0, SDIO_CCCR_INTx, SDIO_FUNC_0, SDIO_CCCR_INTx,
NULL); NULL);
intstatus = intstatus =
...@@ -5101,7 +5110,7 @@ extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *dhdp) ...@@ -5101,7 +5110,7 @@ extern bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *dhdp)
bus->pollcnt++; bus->pollcnt++;
bus->ipend = true; bus->ipend = true;
if (bus->intr) if (bus->intr)
brcmf_sdcard_intr_disable(bus->sdh); brcmf_sdcard_intr_disable(bus->card);
bus->dpc_sched = true; bus->dpc_sched = true;
brcmf_sdbrcm_sched_dpc(bus); brcmf_sdbrcm_sched_dpc(bus);
...@@ -5234,7 +5243,7 @@ static bool brcmf_sdbrcm_chipmatch(u16 chipid) ...@@ -5234,7 +5243,7 @@ static bool brcmf_sdbrcm_chipmatch(u16 chipid)
static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no,
u16 slot, u16 func, uint bustype, void *regsva, u16 slot, u16 func, uint bustype, void *regsva,
void *sdh) void *card)
{ {
int ret; int ret;
dhd_bus_t *bus; dhd_bus_t *bus;
...@@ -5316,7 +5325,7 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, ...@@ -5316,7 +5325,7 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no,
DHD_ERROR(("%s: kmalloc of dhd_bus_t failed\n", __func__)); DHD_ERROR(("%s: kmalloc of dhd_bus_t failed\n", __func__));
goto fail; goto fail;
} }
bus->sdh = sdh; bus->card = card;
bus->cl_devid = (u16) devid; bus->cl_devid = (u16) devid;
bus->bus = DHD_BUS; bus->bus = DHD_BUS;
bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1;
...@@ -5324,7 +5333,7 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, ...@@ -5324,7 +5333,7 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no,
else use locally malloced rxbuf */ else use locally malloced rxbuf */
/* attempt to attach to the dongle */ /* attempt to attach to the dongle */
if (!(brcmf_sdbrcm_probe_attach(bus, sdh, regsva, devid))) { if (!(brcmf_sdbrcm_probe_attach(bus, card, regsva, devid))) {
DHD_ERROR(("%s: brcmf_sdbrcm_probe_attach failed\n", __func__)); DHD_ERROR(("%s: brcmf_sdbrcm_probe_attach failed\n", __func__));
goto fail; goto fail;
} }
...@@ -5384,12 +5393,12 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, ...@@ -5384,12 +5393,12 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no,
} }
/* Allocate buffers */ /* Allocate buffers */
if (!(brcmf_sdbrcm_probe_malloc(bus, sdh))) { if (!(brcmf_sdbrcm_probe_malloc(bus, card))) {
DHD_ERROR(("%s: brcmf_sdbrcm_probe_malloc failed\n", __func__)); DHD_ERROR(("%s: brcmf_sdbrcm_probe_malloc failed\n", __func__));
goto fail; goto fail;
} }
if (!(brcmf_sdbrcm_probe_init(bus, sdh))) { if (!(brcmf_sdbrcm_probe_init(bus, card))) {
DHD_ERROR(("%s: brcmf_sdbrcm_probe_init failed\n", __func__)); DHD_ERROR(("%s: brcmf_sdbrcm_probe_init failed\n", __func__));
goto fail; goto fail;
} }
...@@ -5397,8 +5406,8 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, ...@@ -5397,8 +5406,8 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no,
/* Register interrupt callback, but mask it (not operational yet). */ /* Register interrupt callback, but mask it (not operational yet). */
DHD_INTR(("%s: disable SDIO interrupts (not interested yet)\n", DHD_INTR(("%s: disable SDIO interrupts (not interested yet)\n",
__func__)); __func__));
brcmf_sdcard_intr_disable(sdh); brcmf_sdcard_intr_disable(card);
ret = brcmf_sdcard_intr_reg(sdh, brcmf_sdbrcm_isr, bus); ret = brcmf_sdcard_intr_reg(card, brcmf_sdbrcm_isr, bus);
if (ret != 0) { if (ret != 0) {
DHD_ERROR(("%s: FAILED: sdcard_intr_reg returned %d\n", DHD_ERROR(("%s: FAILED: sdcard_intr_reg returned %d\n",
__func__, ret)); __func__, ret));
...@@ -5430,7 +5439,7 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no, ...@@ -5430,7 +5439,7 @@ static void *brcmf_sdbrcm_probe(u16 venid, u16 devid, u16 bus_no,
} }
static bool static bool
brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *card, void *regsva,
u16 devid) u16 devid)
{ {
u8 clkctl = 0; u8 clkctl = 0;
...@@ -5444,7 +5453,7 @@ brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, ...@@ -5444,7 +5453,7 @@ brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva,
#ifdef BCMDBG #ifdef BCMDBG
printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n", printk(KERN_DEBUG "F1 signature read @0x18000000=0x%4x\n",
brcmf_sdcard_reg_read(bus->sdh, SI_ENUM_BASE, 4)); brcmf_sdcard_reg_read(bus->card, SI_ENUM_BASE, 4));
#endif /* BCMDBG */ #endif /* BCMDBG */
...@@ -5453,11 +5462,11 @@ brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, ...@@ -5453,11 +5462,11 @@ brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva,
* programs PLL control regs * programs PLL control regs
*/ */
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
DHD_INIT_CLKCTL1, &err); DHD_INIT_CLKCTL1, &err);
if (!err) if (!err)
clkctl = clkctl =
brcmf_sdcard_cfg_read(sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_read(card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, &err); SBSDIO_FUNC1_CHIPCLKCSR, &err);
if (err || ((clkctl & ~SBSDIO_AVBITS) != DHD_INIT_CLKCTL1)) { if (err || ((clkctl & ~SBSDIO_AVBITS) != DHD_INIT_CLKCTL1)) {
...@@ -5472,7 +5481,7 @@ brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, ...@@ -5472,7 +5481,7 @@ brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva,
goto fail; goto fail;
} }
brcmf_sdcard_chipinfo(sdh, bus->ci->chip, bus->ci->chiprev); brcmf_sdcard_chipinfo(card, bus->ci->chip, bus->ci->chiprev);
if (!brcmf_sdbrcm_chipmatch((u16) bus->ci->chip)) { if (!brcmf_sdbrcm_chipmatch((u16) bus->ci->chip)) {
DHD_ERROR(("%s: unsupported chip: 0x%04x\n", DHD_ERROR(("%s: unsupported chip: 0x%04x\n",
...@@ -5484,7 +5493,7 @@ brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, ...@@ -5484,7 +5493,7 @@ brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva,
/* Get info on the ARM and SOCRAM cores... */ /* Get info on the ARM and SOCRAM cores... */
if (!DHD_NOPMU(bus)) { if (!DHD_NOPMU(bus)) {
bus->armrev = SBCOREREV(brcmf_sdcard_reg_read(bus->sdh, bus->armrev = SBCOREREV(brcmf_sdcard_reg_read(bus->card,
CORE_SB(bus->ci->armcorebase, sbidhigh), 4)); CORE_SB(bus->ci->armcorebase, sbidhigh), 4));
bus->orig_ramsize = bus->ci->ramsize; bus->orig_ramsize = bus->ci->ramsize;
if (!(bus->orig_ramsize)) { if (!(bus->orig_ramsize)) {
...@@ -5523,7 +5532,7 @@ brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva, ...@@ -5523,7 +5532,7 @@ brcmf_sdbrcm_probe_attach(struct dhd_bus *bus, void *sdh, void *regsva,
return false; return false;
} }
static bool brcmf_sdbrcm_probe_malloc(dhd_bus_t *bus, void *sdh) static bool brcmf_sdbrcm_probe_malloc(dhd_bus_t *bus, void *card)
{ {
DHD_TRACE(("%s: Enter\n", __func__)); DHD_TRACE(("%s: Enter\n", __func__));
...@@ -5563,7 +5572,7 @@ static bool brcmf_sdbrcm_probe_malloc(dhd_bus_t *bus, void *sdh) ...@@ -5563,7 +5572,7 @@ static bool brcmf_sdbrcm_probe_malloc(dhd_bus_t *bus, void *sdh)
return false; return false;
} }
static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh) static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *card)
{ {
s32 fnum; s32 fnum;
...@@ -5574,7 +5583,7 @@ static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh) ...@@ -5574,7 +5583,7 @@ static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh)
#endif /* SDTEST */ #endif /* SDTEST */
/* Disable F2 to clear any intermediate frame state on the dongle */ /* Disable F2 to clear any intermediate frame state on the dongle */
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_0, SDIO_CCCR_IOEx, brcmf_sdcard_cfg_write(card, SDIO_FUNC_0, SDIO_CCCR_IOEx,
SDIO_FUNC_ENABLE_1, NULL); SDIO_FUNC_ENABLE_1, NULL);
bus->dhd->busstate = DHD_BUS_DOWN; bus->dhd->busstate = DHD_BUS_DOWN;
...@@ -5583,7 +5592,7 @@ static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh) ...@@ -5583,7 +5592,7 @@ static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh)
bus->prev_rxlim_hit = 0; bus->prev_rxlim_hit = 0;
/* Done with backplane-dependent accesses, can drop clock... */ /* Done with backplane-dependent accesses, can drop clock... */
brcmf_sdcard_cfg_write(sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, 0, brcmf_sdcard_cfg_write(card, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, 0,
NULL); NULL);
/* ...and initialize clock/power states */ /* ...and initialize clock/power states */
...@@ -5593,7 +5602,7 @@ static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh) ...@@ -5593,7 +5602,7 @@ static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh)
/* Query the F2 block size, set roundup accordingly */ /* Query the F2 block size, set roundup accordingly */
fnum = 2; fnum = 2;
if (brcmf_sdcard_iovar_op(sdh, "sd_blocksize", &fnum, sizeof(s32), if (brcmf_sdcard_iovar_op(card, "sd_blocksize", &fnum, sizeof(s32),
&bus->blocksize, sizeof(s32), false) != 0) { &bus->blocksize, sizeof(s32), false) != 0) {
bus->blocksize = 0; bus->blocksize = 0;
DHD_ERROR(("%s: fail on %s get\n", __func__, "sd_blocksize")); DHD_ERROR(("%s: fail on %s get\n", __func__, "sd_blocksize"));
...@@ -5605,7 +5614,7 @@ static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh) ...@@ -5605,7 +5614,7 @@ static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh)
/* Query if bus module supports packet chaining, /* Query if bus module supports packet chaining,
default to use if supported */ default to use if supported */
if (brcmf_sdcard_iovar_op(sdh, "sd_rxchain", NULL, 0, if (brcmf_sdcard_iovar_op(card, "sd_rxchain", NULL, 0,
&bus->sd_rxchain, sizeof(s32), &bus->sd_rxchain, sizeof(s32),
false) != 0) { false) != 0) {
bus->sd_rxchain = false; bus->sd_rxchain = false;
...@@ -5620,7 +5629,7 @@ static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh) ...@@ -5620,7 +5629,7 @@ static bool brcmf_sdbrcm_probe_init(dhd_bus_t *bus, void *sdh)
} }
static bool static bool
brcmf_sdbrcm_download_firmware(struct dhd_bus *bus, void *sdh) brcmf_sdbrcm_download_firmware(struct dhd_bus *bus, void *card)
{ {
bool ret; bool ret;
...@@ -5641,8 +5650,8 @@ static void brcmf_sdbrcm_release(dhd_bus_t *bus) ...@@ -5641,8 +5650,8 @@ static void brcmf_sdbrcm_release(dhd_bus_t *bus)
if (bus) { if (bus) {
/* De-register interrupt handler */ /* De-register interrupt handler */
brcmf_sdcard_intr_disable(bus->sdh); brcmf_sdcard_intr_disable(bus->card);
brcmf_sdcard_intr_dereg(bus->sdh); brcmf_sdcard_intr_dereg(bus->card);
if (bus->dhd) { if (bus->dhd) {
brcmf_detach(bus->dhd); brcmf_detach(bus->dhd);
...@@ -5947,7 +5956,7 @@ brcmf_sdbrcm_send_buf(dhd_bus_t *bus, u32 addr, uint fn, uint flags, ...@@ -5947,7 +5956,7 @@ brcmf_sdbrcm_send_buf(dhd_bus_t *bus, u32 addr, uint fn, uint flags,
brcmf_sdio_cmplt_fn_t complete, void *handle) brcmf_sdio_cmplt_fn_t complete, void *handle)
{ {
return brcmf_sdcard_send_buf return brcmf_sdcard_send_buf
(bus->sdh, addr, fn, flags, buf, nbytes, pkt, complete, (bus->card, addr, fn, flags, buf, nbytes, pkt, complete,
handle); handle);
} }
...@@ -6006,14 +6015,14 @@ int brcmf_bus_devreset(struct brcmf_pub *dhdp, u8 flag) ...@@ -6006,14 +6015,14 @@ int brcmf_bus_devreset(struct brcmf_pub *dhdp, u8 flag)
if (bus->dhd->dongle_reset) { if (bus->dhd->dongle_reset) {
/* Turn on WLAN */ /* Turn on WLAN */
/* Reset SD client */ /* Reset SD client */
brcmf_sdcard_reset(bus->sdh); brcmf_sdcard_reset(bus->card);
/* Attempt to re-attach & download */ /* Attempt to re-attach & download */
if (brcmf_sdbrcm_probe_attach(bus, bus->sdh, if (brcmf_sdbrcm_probe_attach(bus, bus->card,
(u32 *) SI_ENUM_BASE, (u32 *) SI_ENUM_BASE,
bus->cl_devid)) { bus->cl_devid)) {
/* Attempt to download binary to the dongle */ /* Attempt to download binary to the dongle */
if (brcmf_sdbrcm_probe_init(bus, bus->sdh)) { if (brcmf_sdbrcm_probe_init(bus, bus->card)) {
/* Re-init bus, enable F2 transfer */ /* Re-init bus, enable F2 transfer */
brcmf_sdbrcm_bus_init( brcmf_sdbrcm_bus_init(
(struct brcmf_pub *) bus->dhd, (struct brcmf_pub *) bus->dhd,
...@@ -6040,8 +6049,8 @@ int brcmf_bus_devreset(struct brcmf_pub *dhdp, u8 flag) ...@@ -6040,8 +6049,8 @@ int brcmf_bus_devreset(struct brcmf_pub *dhdp, u8 flag)
} }
static int static int
brcmf_sdbrcm_chip_recognition(struct brcmf_sdio *sdh, struct chip_info *ci, brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_card *card,
void *regs) struct chip_info *ci, void *regs)
{ {
u32 regdata; u32 regdata;
...@@ -6052,7 +6061,7 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio *sdh, struct chip_info *ci, ...@@ -6052,7 +6061,7 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio *sdh, struct chip_info *ci,
* other ways of recognition should be added here. * other ways of recognition should be added here.
*/ */
ci->cccorebase = (u32)regs; ci->cccorebase = (u32)regs;
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_CC_REG(ci->cccorebase, chipid), 4); CORE_CC_REG(ci->cccorebase, chipid), 4);
ci->chip = regdata & CID_ID_MASK; ci->chip = regdata & CID_ID_MASK;
ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT;
...@@ -6074,15 +6083,15 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio *sdh, struct chip_info *ci, ...@@ -6074,15 +6083,15 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio *sdh, struct chip_info *ci,
return -ENODEV; return -ENODEV;
} }
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(ci->cccorebase, sbidhigh), 4); CORE_SB(ci->cccorebase, sbidhigh), 4);
ci->ccrev = SBCOREREV(regdata); ci->ccrev = SBCOREREV(regdata);
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); CORE_CC_REG(ci->cccorebase, pmucapabilities), 4);
ci->pmurev = regdata & PCAP_REV_MASK; ci->pmurev = regdata & PCAP_REV_MASK;
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(ci->buscorebase, sbidhigh), 4); CORE_SB(ci->buscorebase, sbidhigh), 4);
ci->buscorerev = SBCOREREV(regdata); ci->buscorerev = SBCOREREV(regdata);
ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT;
...@@ -6092,87 +6101,87 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio *sdh, struct chip_info *ci, ...@@ -6092,87 +6101,87 @@ brcmf_sdbrcm_chip_recognition(struct brcmf_sdio *sdh, struct chip_info *ci,
ci->buscorerev, ci->buscoretype)); ci->buscorerev, ci->buscoretype));
/* get chipcommon capabilites */ /* get chipcommon capabilites */
ci->cccaps = brcmf_sdcard_reg_read(sdh, ci->cccaps = brcmf_sdcard_reg_read(card,
CORE_CC_REG(ci->cccorebase, capabilities), 4); CORE_CC_REG(ci->cccorebase, capabilities), 4);
return 0; return 0;
} }
static void static void
brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio *sdh, u32 corebase) brcmf_sdbrcm_chip_disablecore(struct brcmf_sdio_card *card, u32 corebase)
{ {
u32 regdata; u32 regdata;
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbtmstatelow), 4); CORE_SB(corebase, sbtmstatelow), 4);
if (regdata & SBTML_RESET) if (regdata & SBTML_RESET)
return; return;
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbtmstatelow), 4); CORE_SB(corebase, sbtmstatelow), 4);
if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) { if ((regdata & (SICF_CLOCK_EN << SBTML_SICF_SHIFT)) != 0) {
/* /*
* set target reject and spin until busy is clear * set target reject and spin until busy is clear
* (preserve core-specific bits) * (preserve core-specific bits)
*/ */
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbtmstatelow), 4); CORE_SB(corebase, sbtmstatelow), 4);
brcmf_sdcard_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4, brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatelow), 4,
regdata | SBTML_REJ); regdata | SBTML_REJ);
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbtmstatelow), 4); CORE_SB(corebase, sbtmstatelow), 4);
udelay(1); udelay(1);
SPINWAIT((brcmf_sdcard_reg_read(sdh, SPINWAIT((brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbtmstatehigh), 4) & CORE_SB(corebase, sbtmstatehigh), 4) &
SBTMH_BUSY), 100000); SBTMH_BUSY), 100000);
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbtmstatehigh), 4); CORE_SB(corebase, sbtmstatehigh), 4);
if (regdata & SBTMH_BUSY) if (regdata & SBTMH_BUSY)
DHD_ERROR(("%s: ARM core still busy\n", __func__)); DHD_ERROR(("%s: ARM core still busy\n", __func__));
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbidlow), 4); CORE_SB(corebase, sbidlow), 4);
if (regdata & SBIDL_INIT) { if (regdata & SBIDL_INIT) {
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbimstate), 4) | CORE_SB(corebase, sbimstate), 4) |
SBIM_RJ; SBIM_RJ;
brcmf_sdcard_reg_write(sdh, brcmf_sdcard_reg_write(card,
CORE_SB(corebase, sbimstate), 4, CORE_SB(corebase, sbimstate), 4,
regdata); regdata);
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbimstate), 4); CORE_SB(corebase, sbimstate), 4);
udelay(1); udelay(1);
SPINWAIT((brcmf_sdcard_reg_read(sdh, SPINWAIT((brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbimstate), 4) & CORE_SB(corebase, sbimstate), 4) &
SBIM_BY), 100000); SBIM_BY), 100000);
} }
/* set reset and reject while enabling the clocks */ /* set reset and reject while enabling the clocks */
brcmf_sdcard_reg_write(sdh, brcmf_sdcard_reg_write(card,
CORE_SB(corebase, sbtmstatelow), 4, CORE_SB(corebase, sbtmstatelow), 4,
(((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | (((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) |
SBTML_REJ | SBTML_RESET)); SBTML_REJ | SBTML_RESET));
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbtmstatelow), 4); CORE_SB(corebase, sbtmstatelow), 4);
udelay(10); udelay(10);
/* clear the initiator reject bit */ /* clear the initiator reject bit */
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbidlow), 4); CORE_SB(corebase, sbidlow), 4);
if (regdata & SBIDL_INIT) { if (regdata & SBIDL_INIT) {
regdata = brcmf_sdcard_reg_read(sdh, regdata = brcmf_sdcard_reg_read(card,
CORE_SB(corebase, sbimstate), 4) & CORE_SB(corebase, sbimstate), 4) &
~SBIM_RJ; ~SBIM_RJ;
brcmf_sdcard_reg_write(sdh, brcmf_sdcard_reg_write(card,
CORE_SB(corebase, sbimstate), 4, CORE_SB(corebase, sbimstate), 4,
regdata); regdata);
} }
} }
/* leave reset and reject asserted */ /* leave reset and reject asserted */
brcmf_sdcard_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4, brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatelow), 4,
(SBTML_REJ | SBTML_RESET)); (SBTML_REJ | SBTML_RESET));
udelay(1); udelay(1);
} }
...@@ -6198,7 +6207,7 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs) ...@@ -6198,7 +6207,7 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs)
/* bus/core/clk setup for register access */ /* bus/core/clk setup for register access */
/* Try forcing SDIO core to do ALPAvail request only */ /* Try forcing SDIO core to do ALPAvail request only */
clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ; clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | SBSDIO_ALP_AVAIL_REQ;
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
clkset, &err); clkset, &err);
if (err) { if (err) {
DHD_ERROR(("%s: error writing for HT off\n", __func__)); DHD_ERROR(("%s: error writing for HT off\n", __func__));
...@@ -6207,11 +6216,11 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs) ...@@ -6207,11 +6216,11 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs)
/* If register supported, wait for ALPAvail and then force ALP */ /* If register supported, wait for ALPAvail and then force ALP */
/* This may take up to 15 milliseconds */ /* This may take up to 15 milliseconds */
clkval = brcmf_sdcard_cfg_read(bus->sdh, SDIO_FUNC_1, clkval = brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, NULL); SBSDIO_FUNC1_CHIPCLKCSR, NULL);
if ((clkval & ~SBSDIO_AVBITS) == clkset) { if ((clkval & ~SBSDIO_AVBITS) == clkset) {
SPINWAIT(((clkval = SPINWAIT(((clkval =
brcmf_sdcard_cfg_read(bus->sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, SBSDIO_FUNC1_CHIPCLKCSR,
NULL)), NULL)),
!SBSDIO_ALPAV(clkval)), !SBSDIO_ALPAV(clkval)),
...@@ -6224,7 +6233,7 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs) ...@@ -6224,7 +6233,7 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs)
} }
clkset = SBSDIO_FORCE_HW_CLKREQ_OFF | clkset = SBSDIO_FORCE_HW_CLKREQ_OFF |
SBSDIO_FORCE_ALP; SBSDIO_FORCE_ALP;
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1,
SBSDIO_FUNC1_CHIPCLKCSR, SBSDIO_FUNC1_CHIPCLKCSR,
clkset, &err); clkset, &err);
udelay(65); udelay(65);
...@@ -6236,10 +6245,10 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs) ...@@ -6236,10 +6245,10 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs)
} }
/* Also, disable the extra SDIO pull-ups */ /* Also, disable the extra SDIO pull-ups */
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SDIOPULLUP, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_FUNC1_SDIOPULLUP,
0, NULL); 0, NULL);
err = brcmf_sdbrcm_chip_recognition(bus->sdh, ci, regs); err = brcmf_sdbrcm_chip_recognition(bus->card, ci, regs);
if (err) if (err)
goto fail; goto fail;
...@@ -6247,23 +6256,23 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs) ...@@ -6247,23 +6256,23 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs)
* Make sure any on-chip ARM is off (in case strapping is wrong), * Make sure any on-chip ARM is off (in case strapping is wrong),
* or downloaded code was already running. * or downloaded code was already running.
*/ */
brcmf_sdbrcm_chip_disablecore(bus->sdh, ci->armcorebase); brcmf_sdbrcm_chip_disablecore(bus->card, ci->armcorebase);
brcmf_sdcard_reg_write(bus->sdh, brcmf_sdcard_reg_write(bus->card,
CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0); CORE_CC_REG(ci->cccorebase, gpiopullup), 4, 0);
brcmf_sdcard_reg_write(bus->sdh, brcmf_sdcard_reg_write(bus->card,
CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0); CORE_CC_REG(ci->cccorebase, gpiopulldown), 4, 0);
/* Disable F2 to clear any intermediate frame state on the dongle */ /* Disable F2 to clear any intermediate frame state on the dongle */
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_0, SDIO_CCCR_IOEx, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_0, SDIO_CCCR_IOEx,
SDIO_FUNC_ENABLE_1, NULL); SDIO_FUNC_ENABLE_1, NULL);
/* WAR: cmd52 backplane read so core HW will drop ALPReq */ /* WAR: cmd52 backplane read so core HW will drop ALPReq */
clkval = brcmf_sdcard_cfg_read(bus->sdh, SDIO_FUNC_1, clkval = brcmf_sdcard_cfg_read(bus->card, SDIO_FUNC_1,
0, NULL); 0, NULL);
/* Done with backplane-dependent accesses, can drop clock... */ /* Done with backplane-dependent accesses, can drop clock... */
brcmf_sdcard_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, brcmf_sdcard_cfg_write(bus->card, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR,
0, NULL); 0, NULL);
bus->ci = ci; bus->ci = ci;
...@@ -6275,7 +6284,7 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs) ...@@ -6275,7 +6284,7 @@ brcmf_sdbrcm_chip_attach(struct dhd_bus *bus, void *regs)
} }
static void static void
brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio *sdh, u32 corebase) brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio_card *card, u32 corebase)
{ {
u32 regdata; u32 regdata;
...@@ -6283,37 +6292,37 @@ brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio *sdh, u32 corebase) ...@@ -6283,37 +6292,37 @@ brcmf_sdbrcm_chip_resetcore(struct brcmf_sdio *sdh, u32 corebase)
* Must do the disable sequence first to work for * Must do the disable sequence first to work for
* arbitrary current core state. * arbitrary current core state.
*/ */
brcmf_sdbrcm_chip_disablecore(sdh, corebase); brcmf_sdbrcm_chip_disablecore(card, corebase);
/* /*
* Now do the initialization sequence. * Now do the initialization sequence.
* set reset while enabling the clock and * set reset while enabling the clock and
* forcing them on throughout the core * forcing them on throughout the core
*/ */
brcmf_sdcard_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4, brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatelow), 4,
((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) | ((SICF_FGC | SICF_CLOCK_EN) << SBTML_SICF_SHIFT) |
SBTML_RESET); SBTML_RESET);
udelay(1); udelay(1);
regdata = brcmf_sdcard_reg_read(sdh, CORE_SB(corebase, sbtmstatehigh), regdata = brcmf_sdcard_reg_read(card, CORE_SB(corebase, sbtmstatehigh),
4); 4);
if (regdata & SBTMH_SERR) if (regdata & SBTMH_SERR)
brcmf_sdcard_reg_write(sdh, CORE_SB(corebase, sbtmstatehigh), brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatehigh),
4, 0); 4, 0);
regdata = brcmf_sdcard_reg_read(sdh, CORE_SB(corebase, sbimstate), 4); regdata = brcmf_sdcard_reg_read(card, CORE_SB(corebase, sbimstate), 4);
if (regdata & (SBIM_IBE | SBIM_TO)) if (regdata & (SBIM_IBE | SBIM_TO))
brcmf_sdcard_reg_write(sdh, CORE_SB(corebase, sbimstate), 4, brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbimstate), 4,
regdata & ~(SBIM_IBE | SBIM_TO)); regdata & ~(SBIM_IBE | SBIM_TO));
/* clear reset and allow it to propagate throughout the core */ /* clear reset and allow it to propagate throughout the core */
brcmf_sdcard_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4, brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatelow), 4,
(SICF_FGC << SBTML_SICF_SHIFT) | (SICF_FGC << SBTML_SICF_SHIFT) |
(SICF_CLOCK_EN << SBTML_SICF_SHIFT)); (SICF_CLOCK_EN << SBTML_SICF_SHIFT));
udelay(1); udelay(1);
/* leave clock enabled */ /* leave clock enabled */
brcmf_sdcard_reg_write(sdh, CORE_SB(corebase, sbtmstatelow), 4, brcmf_sdcard_reg_write(card, CORE_SB(corebase, sbtmstatelow), 4,
(SICF_CLOCK_EN << SBTML_SICF_SHIFT)); (SICF_CLOCK_EN << SBTML_SICF_SHIFT));
udelay(1); udelay(1);
} }
...@@ -6407,15 +6416,15 @@ brcmf_sdbrcm_sdiod_drive_strength_init(struct dhd_bus *bus, u32 drivestrength) { ...@@ -6407,15 +6416,15 @@ brcmf_sdbrcm_sdiod_drive_strength_init(struct dhd_bus *bus, u32 drivestrength) {
} }
} }
brcmf_sdcard_reg_write(bus->sdh, brcmf_sdcard_reg_write(bus->card,
CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr),
4, 1); 4, 1);
cc_data_temp = brcmf_sdcard_reg_read(bus->sdh, cc_data_temp = brcmf_sdcard_reg_read(bus->card,
CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4); CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), 4);
cc_data_temp &= ~str_mask; cc_data_temp &= ~str_mask;
drivestrength_sel <<= str_shift; drivestrength_sel <<= str_shift;
cc_data_temp |= drivestrength_sel; cc_data_temp |= drivestrength_sel;
brcmf_sdcard_reg_write(bus->sdh, brcmf_sdcard_reg_write(bus->card,
CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr), CORE_CC_REG(bus->ci->cccorebase, chipcontrol_addr),
4, cc_data_temp); 4, cc_data_temp);
......
...@@ -62,7 +62,7 @@ extern const uint brcmf_sdio_msglevel; ...@@ -62,7 +62,7 @@ extern const uint brcmf_sdio_msglevel;
#define SDIOD_MAX_IOFUNCS 7 #define SDIOD_MAX_IOFUNCS 7
/* forward declarations */ /* forward declarations */
struct brcmf_sdio; struct brcmf_sdio_card;
typedef void (*brcmf_sdiocard_cb_fn_t) (void *); typedef void (*brcmf_sdiocard_cb_fn_t) (void *);
/* Attach and build an interface to the underlying SD host driver. /* Attach and build an interface to the underlying SD host driver.
...@@ -73,35 +73,38 @@ typedef void (*brcmf_sdiocard_cb_fn_t) (void *); ...@@ -73,35 +73,38 @@ typedef void (*brcmf_sdiocard_cb_fn_t) (void *);
* implementation may maintain a single "default" handle (e.g. the first or * implementation may maintain a single "default" handle (e.g. the first or
* most recent one) to enable single-instance implementations to pass NULL. * most recent one) to enable single-instance implementations to pass NULL.
*/ */
extern struct brcmf_sdio *brcmf_sdcard_attach(void *cfghdl, void **regsva, extern struct brcmf_sdio_card *brcmf_sdcard_attach(void *cfghdl, void **regsva,
uint irq); uint irq);
/* Detach - freeup resources allocated in attach */ /* Detach - freeup resources allocated in attach */
extern int brcmf_sdcard_detach(void *sdh); extern int brcmf_sdcard_detach(struct brcmf_sdio_card *card);
/* Query if SD device interrupts are enabled */ /* Query if SD device interrupts are enabled */
extern bool brcmf_sdcard_intr_query(void *sdh); extern bool brcmf_sdcard_intr_query(struct brcmf_sdio_card *card);
/* Enable/disable SD interrupt */ /* Enable/disable SD interrupt */
extern int brcmf_sdcard_intr_enable(void *sdh); extern int brcmf_sdcard_intr_enable(struct brcmf_sdio_card *card);
extern int brcmf_sdcard_intr_disable(void *sdh); extern int brcmf_sdcard_intr_disable(struct brcmf_sdio_card *card);
/* Register/deregister device interrupt handler. */ /* Register/deregister device interrupt handler. */
extern int extern int
brcmf_sdcard_intr_reg(void *sdh, brcmf_sdiocard_cb_fn_t fn, void *argh); brcmf_sdcard_intr_reg(struct brcmf_sdio_card *card, brcmf_sdiocard_cb_fn_t fn,
void *argh);
extern int brcmf_sdcard_intr_dereg(void *sdh); extern int brcmf_sdcard_intr_dereg(struct brcmf_sdio_card *card);
#if defined(BCMDBG) #if defined(BCMDBG)
/* Query pending interrupt status from the host controller */ /* Query pending interrupt status from the host controller */
extern bool brcmf_sdcard_intr_pending(void *sdh); extern bool brcmf_sdcard_intr_pending(struct brcmf_sdio_card *card);
#endif #endif
/* Register a callback to be called on device removal. /* Register a callback to be called on device removal.
* No-op in the case of non-removable/hardwired devices. * No-op in the case of non-removable/hardwired devices.
*/ */
extern int extern int
brcmf_sdcard_devremove_reg(void *sdh, brcmf_sdiocard_cb_fn_t fn, void *argh); brcmf_sdcard_devremove_reg(struct brcmf_sdio_card *card,
brcmf_sdiocard_cb_fn_t fn,
void *argh);
/* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface). /* Access SDIO address space (e.g. CCCR) using CMD52 (single-byte interface).
* fn: function number * fn: function number
...@@ -109,14 +112,18 @@ brcmf_sdcard_devremove_reg(void *sdh, brcmf_sdiocard_cb_fn_t fn, void *argh); ...@@ -109,14 +112,18 @@ brcmf_sdcard_devremove_reg(void *sdh, brcmf_sdiocard_cb_fn_t fn, void *argh);
* data: data byte to write * data: data byte to write
* err: pointer to error code (or NULL) * err: pointer to error code (or NULL)
*/ */
extern u8 brcmf_sdcard_cfg_read(void *sdh, uint func, u32 addr, int *err); extern u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_card *card, uint func,
extern void brcmf_sdcard_cfg_write(void *sdh, uint func, u32 addr, u8 data, u32 addr, int *err);
int *err); extern void brcmf_sdcard_cfg_write(struct brcmf_sdio_card *card, uint func,
u32 addr, u8 data, int *err);
/* Read/Write 4bytes from/to cfg space */ /* Read/Write 4bytes from/to cfg space */
extern u32 brcmf_sdcard_cfg_read_word(void *sdh, uint fnc_num, u32 addr, extern u32
int *err); brcmf_sdcard_cfg_read_word(struct brcmf_sdio_card *card, uint fnc_num,
extern void brcmf_sdcard_cfg_write_word(void *sdh, uint fnc_num, u32 addr, u32 addr, int *err);
extern void brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card,
uint fnc_num, u32 addr,
u32 data, int *err); u32 data, int *err);
/* Read CIS content for specified function. /* Read CIS content for specified function.
...@@ -126,18 +133,23 @@ extern void brcmf_sdcard_cfg_write_word(void *sdh, uint fnc_num, u32 addr, ...@@ -126,18 +133,23 @@ extern void brcmf_sdcard_cfg_write_word(void *sdh, uint fnc_num, u32 addr,
* Internally, this routine uses the values from the cis base regs (0x9-0xB) * Internally, this routine uses the values from the cis base regs (0x9-0xB)
* to form an SDIO-space address to read the data from. * to form an SDIO-space address to read the data from.
*/ */
extern int brcmf_sdcard_cis_read(void *sdh, uint func, u8 *cis, uint length); extern int brcmf_sdcard_cis_read(struct brcmf_sdio_card *card, uint func,
u8 *cis, uint length);
/* Synchronous access to device (client) core registers via CMD53 to F1. /* Synchronous access to device (client) core registers via CMD53 to F1.
* addr: backplane address (i.e. >= regsva from attach) * addr: backplane address (i.e. >= regsva from attach)
* size: register width in bytes (2 or 4) * size: register width in bytes (2 or 4)
* data: data for register write * data: data for register write
*/ */
extern u32 brcmf_sdcard_reg_read(void *sdh, u32 addr, uint size); extern u32
extern u32 brcmf_sdcard_reg_write(void *sdh, u32 addr, uint size, u32 data); brcmf_sdcard_reg_read(struct brcmf_sdio_card *card, u32 addr, uint size);
extern u32
brcmf_sdcard_reg_write(struct brcmf_sdio_card *card, u32 addr, uint size,
u32 data);
/* Indicate if last reg read/write failed */ /* Indicate if last reg read/write failed */
extern bool brcmf_sdcard_regfail(void *sdh); extern bool brcmf_sdcard_regfail(struct brcmf_sdio_card *card);
/* Buffer transfer to/from device (client) core via cmd53. /* Buffer transfer to/from device (client) core via cmd53.
* fn: function number * fn: function number
...@@ -153,10 +165,12 @@ extern bool brcmf_sdcard_regfail(void *sdh); ...@@ -153,10 +165,12 @@ extern bool brcmf_sdcard_regfail(void *sdh);
*/ */
typedef void (*brcmf_sdio_cmplt_fn_t) typedef void (*brcmf_sdio_cmplt_fn_t)
(void *handle, int status, bool sync_waiting); (void *handle, int status, bool sync_waiting);
extern int brcmf_sdcard_send_buf(void *sdh, u32 addr, uint fn, uint flags, extern int
u8 *buf, uint nbytes, void *pkt, brcmf_sdcard_send_buf(struct brcmf_sdio_card *card, u32 addr, uint fn,
uint flags, u8 *buf, uint nbytes, void *pkt,
brcmf_sdio_cmplt_fn_t complete, void *handle); brcmf_sdio_cmplt_fn_t complete, void *handle);
extern int brcmf_sdcard_recv_buf(struct brcmf_sdio *sdh, u32 addr, uint fn, extern int
brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn,
uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt, uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt,
brcmf_sdio_cmplt_fn_t complete, void *handle); brcmf_sdio_cmplt_fn_t complete, void *handle);
...@@ -175,35 +189,35 @@ extern int brcmf_sdcard_recv_buf(struct brcmf_sdio *sdh, u32 addr, uint fn, ...@@ -175,35 +189,35 @@ extern int brcmf_sdcard_recv_buf(struct brcmf_sdio *sdh, u32 addr, uint fn,
* nbytes: number of bytes to transfer to/from buf * nbytes: number of bytes to transfer to/from buf
* Returns 0 or error code. * Returns 0 or error code.
*/ */
extern int brcmf_sdcard_rwdata(void *sdh, uint rw, u32 addr, u8 *buf, extern int brcmf_sdcard_rwdata(struct brcmf_sdio_card *card, uint rw, u32 addr,
uint nbytes); u8 *buf, uint nbytes);
/* Issue an abort to the specified function */ /* Issue an abort to the specified function */
extern int brcmf_sdcard_abort(void *sdh, uint fn); extern int brcmf_sdcard_abort(struct brcmf_sdio_card *card, uint fn);
/* Start SDIO Host Controller communication */ /* Start SDIO Host Controller communication */
extern int brcmf_sdcard_start(void *sdh, int stage); extern int brcmf_sdcard_start(struct brcmf_sdio_card *card, int stage);
/* Stop SDIO Host Controller communication */ /* Stop SDIO Host Controller communication */
extern int brcmf_sdcard_stop(void *sdh); extern int brcmf_sdcard_stop(struct brcmf_sdio_card *card);
/* Returns the "Device ID" of target device on the SDIO bus. */ /* Returns the "Device ID" of target device on the SDIO bus. */
extern int brcmf_sdcard_query_device(void *sdh); extern int brcmf_sdcard_query_device(struct brcmf_sdio_card *card);
/* Returns the number of IO functions reported by the device */ /* Returns the number of IO functions reported by the device */
extern uint brcmf_sdcard_query_iofnum(void *sdh); extern uint brcmf_sdcard_query_iofnum(struct brcmf_sdio_card *card);
/* Miscellaneous knob tweaker. */ /* Miscellaneous knob tweaker. */
extern int brcmf_sdcard_iovar_op(void *sdh, const char *name, extern int brcmf_sdcard_iovar_op(struct brcmf_sdio_card *card, const char *name,
void *params, int plen, void *arg, int len, void *params, int plen, void *arg, int len,
bool set); bool set);
/* Reset and reinitialize the device */ /* Reset and reinitialize the device */
extern int brcmf_sdcard_reset(struct brcmf_sdio *sdh); extern int brcmf_sdcard_reset(struct brcmf_sdio_card *card);
/* helper functions */ /* helper functions */
extern void *brcmf_sdcard_get_sdioh(struct brcmf_sdio *sdh); extern void *brcmf_sdcard_get_sdioh(struct brcmf_sdio_card *card);
/* callback functions */ /* callback functions */
struct brcmf_sdioh_driver { struct brcmf_sdioh_driver {
...@@ -221,7 +235,7 @@ extern int brcmf_sdio_function_init(void); ...@@ -221,7 +235,7 @@ extern int brcmf_sdio_function_init(void);
extern int brcmf_sdio_register(struct brcmf_sdioh_driver *driver); extern int brcmf_sdio_register(struct brcmf_sdioh_driver *driver);
extern void brcmf_sdio_unregister(void); extern void brcmf_sdio_unregister(void);
extern bool brcmf_sdio_chipmatch(u16 vendor, u16 device); extern bool brcmf_sdio_chipmatch(u16 vendor, u16 device);
extern void brcmf_sdio_device_remove(void *sdh); extern void brcmf_sdio_device_remove(void *card);
extern void brcmf_sdio_function_cleanup(void); extern void brcmf_sdio_function_cleanup(void);
extern void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd); extern void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd);
...@@ -230,12 +244,13 @@ extern int brcmf_sdio_probe(struct device *dev); ...@@ -230,12 +244,13 @@ extern int brcmf_sdio_probe(struct device *dev);
extern int brcmf_sdio_remove(struct device *dev); extern int brcmf_sdio_remove(struct device *dev);
/* Function to pass device-status bits to DHD. */ /* Function to pass device-status bits to DHD. */
extern u32 brcmf_sdcard_get_dstatus(void *sdh); extern u32 brcmf_sdcard_get_dstatus(struct brcmf_sdio_card *card);
/* Function to return current window addr */ /* Function to return current window addr */
extern u32 brcmf_sdcard_cur_sbwad(void *sdh); extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_card *card);
/* Function to pass chipid and rev to lower layers for controlling pr's */ /* Function to pass chipid and rev to lower layers for controlling pr's */
extern void brcmf_sdcard_chipinfo(void *sdh, u32 chip, u32 chiprev); extern void brcmf_sdcard_chipinfo(struct brcmf_sdio_card *card, u32 chip,
u32 chiprev);
#endif /* _BRCM_SDH_H_ */ #endif /* _BRCM_SDH_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment