mirror of https://gitee.com/openkylin/linux.git
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: Roland Vossen <rvossen@broadcom.com> Reviewed-by: Arend van Spriel <arend@broadcom.com> Reviewed-by: Franky Lin <frankyl@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
62dd656d34
commit
127aa5cfd9
|
@ -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 @@
|
||||||
* 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 @@
|
||||||
#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 {
|
||||||
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)
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
__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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
__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)
|
||||||
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)
|
||||||
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)
|
||||||
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,15 +420,16 @@ 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,
|
||||||
u8 *buf, uint nbytes, struct sk_buff *pkt,
|
uint flags,
|
||||||
brcmf_sdio_cmplt_fn_t complete, void *handle)
|
u8 *buf, uint nbytes, struct sk_buff *pkt,
|
||||||
|
brcmf_sdio_cmplt_fn_t complete, void *handle)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
uint incr_fix;
|
uint incr_fix;
|
||||||
|
@ -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,
|
||||||
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)
|
||||||
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 {
|
||||||
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)
|
||||||
{
|
{
|
||||||
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)
|
||||||
}
|
}
|
||||||
sdhc->dev = (void *)dev;
|
sdhc->dev = (void *)dev;
|
||||||
|
|
||||||
sdh = brcmf_sdcard_attach((void *)0, (void **)®s, irq);
|
card = brcmf_sdcard_attach((void *)0, (void **)®s, 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)
|
||||||
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)
|
||||||
/* 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)
|
||||||
|
|
||||||
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) {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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 *);
|
||||||
* 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,15 +112,19 @@ 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);
|
||||||
u32 data, int *err);
|
|
||||||
|
extern void brcmf_sdcard_cfg_write_word(struct brcmf_sdio_card *card,
|
||||||
|
uint fnc_num, u32 addr,
|
||||||
|
u32 data, int *err);
|
||||||
|
|
||||||
/* Read CIS content for specified function.
|
/* Read CIS content for specified function.
|
||||||
* fn: function whose CIS is being requested (0 is common CIS)
|
* fn: function whose CIS is being requested (0 is common CIS)
|
||||||
|
@ -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,12 +165,14 @@ 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,
|
||||||
brcmf_sdio_cmplt_fn_t complete, void *handle);
|
uint flags, u8 *buf, uint nbytes, void *pkt,
|
||||||
extern int brcmf_sdcard_recv_buf(struct brcmf_sdio *sdh, u32 addr, uint fn,
|
brcmf_sdio_cmplt_fn_t complete, void *handle);
|
||||||
uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt,
|
extern int
|
||||||
brcmf_sdio_cmplt_fn_t complete, void *handle);
|
brcmf_sdcard_recv_buf(struct brcmf_sdio_card *card, u32 addr, uint fn,
|
||||||
|
uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt,
|
||||||
|
brcmf_sdio_cmplt_fn_t complete, void *handle);
|
||||||
|
|
||||||
/* Flags bits */
|
/* Flags bits */
|
||||||
#define SDIO_REQ_4BYTE 0x1 /* Four-byte target (backplane) width (vs. two-byte) */
|
#define SDIO_REQ_4BYTE 0x1 /* Four-byte target (backplane) width (vs. two-byte) */
|
||||||
|
@ -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);
|
||||||
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);
|
||||||
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_ */
|
||||||
|
|
Loading…
Reference in New Issue