]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/staging/brcm80211/brcmfmac/bcmsdh_sdmmc.c
staging: brcm80211: move sdio related suspend/resume code to bus interface layer
[mv-sheeva.git] / drivers / staging / brcm80211 / brcmfmac / bcmsdh_sdmmc.c
index c0ffbd35e0ca00e6b9ea24e301ad93bb048f7e2b..48527bb380e97344d02fdf41e551ac0c07debd29 100644 (file)
  */
 #include <linux/types.h>
 #include <linux/netdevice.h>
-#include <bcmdefs.h>
-#include <bcmdevs.h>
-#include <bcmutils.h>
-#include <sdio.h>              /* SDIO Device and Protocol Specs */
-#include <sdioh.h>             /* SDIO Host Controller Specification */
-#include <bcmsdbus.h>          /* bcmsdh to/from specific controller APIs */
-#include <sdiovar.h>           /* ioctl/iovars */
-
+#include <linux/mmc/sdio.h>
 #include <linux/mmc/core.h>
 #include <linux/mmc/sdio_func.h>
 #include <linux/mmc/sdio_ids.h>
 #include <linux/suspend.h>
 
-#include <dngl_stats.h>
-#include <dhd.h>
-
+#include <defs.h>
+#include <brcm_hw_ids.h>
+#include <brcmu_utils.h>
+#include <brcmu_wifi.h>
+#include "sdio_host.h"
+#include "bcmsdbus.h"          /* bcmsdh to/from specific controller APIs */
+#include "sdiovar.h"           /* ioctl/iovars */
+#include "dngl_stats.h"
+#include "dhd.h"
 #include "bcmsdh_sdmmc.h"
 
-extern int sdio_function_init(void);
-extern void sdio_function_cleanup(void);
+extern int brcmf_sdio_function_init(void);
+extern void brcmf_sdio_function_cleanup(void);
 
-#if !defined(OOB_INTR_ONLY)
-static void IRQHandler(struct sdio_func *func);
-static void IRQHandlerF2(struct sdio_func *func);
-#endif                         /* !defined(OOB_INTR_ONLY) */
-static int sdioh_sdmmc_get_cisaddr(sdioh_info_t *sd, u32 regaddr);
-extern int sdio_reset_comm(struct mmc_card *card);
+static void brcmf_sdioh_irqhandler(struct sdio_func *func);
+static void brcmf_sdioh_irqhandler_f2(struct sdio_func *func);
+static int brcmf_sdioh_get_cisaddr(struct sdioh_info *sd, u32 regaddr);
+extern int brcmf_sdioh_reset_comm(struct mmc_card *card);
 
 extern PBCMSDH_SDMMC_INSTANCE gInstance;
 
-uint sd_sdmode = SDIOH_MODE_SD4;       /* Use SD4 mode by default */
 uint sd_f2_blocksize = 512;    /* Default blocksize */
 
-uint sd_divisor = 2;           /* Default 48MHz/2 = 24MHz */
-
-uint sd_power = 1;             /* Default to SD Slot powered ON */
-uint sd_clock = 1;             /* Default to SD Clock turned ON */
-uint sd_hiok = false;          /* Don't use hi-speed mode by default */
 uint sd_msglevel = 0x01;
-uint sd_use_dma = true;
 DHD_PM_RESUME_WAIT_INIT(sdioh_request_byte_wait);
 DHD_PM_RESUME_WAIT_INIT(sdioh_request_word_wait);
 DHD_PM_RESUME_WAIT_INIT(sdioh_request_packet_wait);
@@ -62,17 +52,10 @@ DHD_PM_RESUME_WAIT_INIT(sdioh_request_buffer_wait);
 
 #define DMA_ALIGN_MASK 0x03
 
-int sdioh_sdmmc_card_regread(sdioh_info_t *sd, int func, u32 regaddr,
+int brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr,
                             int regsize, u32 *data);
 
-void sdioh_sdio_set_host_pm_flags(int flag)
-{
-       if (sdio_set_host_pm_flags(gInstance->func[1], flag))
-               printk(KERN_ERR "%s: Failed to set pm_flags 0x%08x\n",\
-                        __func__, (unsigned int)flag);
-}
-
-static int sdioh_sdmmc_card_enablefuncs(sdioh_info_t *sd)
+static int brcmf_sdioh_enablefuncs(struct sdioh_info *sd)
 {
        int err_ret;
        u32 fbraddr;
@@ -81,16 +64,16 @@ static int sdioh_sdmmc_card_enablefuncs(sdioh_info_t *sd)
        sd_trace(("%s\n", __func__));
 
        /* Get the Card's common CIS address */
-       sd->com_cis_ptr = sdioh_sdmmc_get_cisaddr(sd, SDIOD_CCCR_CISPTR_0);
+       sd->com_cis_ptr = brcmf_sdioh_get_cisaddr(sd, SDIO_CCCR_CIS);
        sd->func_cis_ptr[0] = sd->com_cis_ptr;
        sd_info(("%s: Card's Common CIS Ptr = 0x%x\n", __func__,
                 sd->com_cis_ptr));
 
        /* Get the Card's function CIS (for each function) */
-       for (fbraddr = SDIOD_FBR_STARTADDR, func = 1;
+       for (fbraddr = SDIO_FBR_BASE(1), func = 1;
             func <= sd->num_funcs; func++, fbraddr += SDIOD_FBR_SIZE) {
                sd->func_cis_ptr[func] =
-                   sdioh_sdmmc_get_cisaddr(sd, SDIOD_FBR_CISPTR_0 + fbraddr);
+                   brcmf_sdioh_get_cisaddr(sd, SDIO_FBR_CIS + fbraddr);
                sd_info(("%s: Function %d CIS Ptr = 0x%x\n", __func__, func,
                         sd->func_cis_ptr[func]));
        }
@@ -114,9 +97,9 @@ static int sdioh_sdmmc_card_enablefuncs(sdioh_info_t *sd)
 /*
  *     Public entry points & extern's
  */
-sdioh_info_t *sdioh_attach(void *bar0, uint irq)
+struct sdioh_info *brcmf_sdioh_attach(void *bar0, uint irq)
 {
-       sdioh_info_t *sd;
+       struct sdioh_info *sd;
        int err_ret;
 
        sd_trace(("%s\n", __func__));
@@ -126,19 +109,18 @@ sdioh_info_t *sdioh_attach(void *bar0, uint irq)
                return NULL;
        }
 
-       sd = kzalloc(sizeof(sdioh_info_t), GFP_ATOMIC);
+       sd = kzalloc(sizeof(struct sdioh_info), GFP_ATOMIC);
        if (sd == NULL) {
                sd_err(("sdioh_attach: out of memory\n"));
                return NULL;
        }
-       if (sdioh_sdmmc_osinit(sd) != 0) {
+       if (brcmf_sdioh_osinit(sd) != 0) {
                sd_err(("%s:sdioh_sdmmc_osinit() failed\n", __func__));
                kfree(sd);
                return NULL;
        }
 
        sd->num_funcs = 2;
-       sd->sd_blockmode = true;
        sd->use_client_ints = true;
        sd->client_block_size[0] = 64;
 
@@ -170,13 +152,13 @@ sdioh_info_t *sdioh_attach(void *bar0, uint irq)
                sdio_release_host(gInstance->func[2]);
        }
 
-       sdioh_sdmmc_card_enablefuncs(sd);
+       brcmf_sdioh_enablefuncs(sd);
 
        sd_trace(("%s: Done\n", __func__));
        return sd;
 }
 
-extern SDIOH_API_RC sdioh_detach(sdioh_info_t *sd)
+extern int brcmf_sdioh_detach(struct sdioh_info *sd)
 {
        sd_trace(("%s\n", __func__));
 
@@ -193,84 +175,17 @@ extern SDIOH_API_RC sdioh_detach(sdioh_info_t *sd)
                sdio_release_host(gInstance->func[1]);
 
                /* deregister irq */
-               sdioh_sdmmc_osfree(sd);
+               brcmf_sdioh_osfree(sd);
 
                kfree(sd);
        }
        return SDIOH_API_RC_SUCCESS;
 }
 
-#if defined(OOB_INTR_ONLY) && defined(HW_OOB)
-
-extern SDIOH_API_RC sdioh_enable_func_intr(void)
-{
-       u8 reg;
-       int err;
-
-       if (gInstance->func[0]) {
-               sdio_claim_host(gInstance->func[0]);
-
-               reg = sdio_readb(gInstance->func[0], SDIOD_CCCR_INTEN, &err);
-               if (err) {
-                       sd_err(("%s: error for read SDIO_CCCR_IENx : 0x%x\n",
-                               __func__, err));
-                       sdio_release_host(gInstance->func[0]);
-                       return SDIOH_API_RC_FAIL;
-               }
-
-               /* Enable F1 and F2 interrupts, set master enable */
-               reg |=
-                   (INTR_CTL_FUNC1_EN | INTR_CTL_FUNC2_EN |
-                    INTR_CTL_MASTER_EN);
-
-               sdio_writeb(gInstance->func[0], reg, SDIOD_CCCR_INTEN, &err);
-               sdio_release_host(gInstance->func[0]);
-
-               if (err) {
-                       sd_err(("%s: error for write SDIO_CCCR_IENx : 0x%x\n",
-                               __func__, err));
-                       return SDIOH_API_RC_FAIL;
-               }
-       }
-
-       return SDIOH_API_RC_SUCCESS;
-}
-
-extern SDIOH_API_RC sdioh_disable_func_intr(void)
-{
-       u8 reg;
-       int err;
-
-       if (gInstance->func[0]) {
-               sdio_claim_host(gInstance->func[0]);
-               reg = sdio_readb(gInstance->func[0], SDIOD_CCCR_INTEN, &err);
-               if (err) {
-                       sd_err(("%s: error for read SDIO_CCCR_IENx : 0x%x\n",
-                               __func__, err));
-                       sdio_release_host(gInstance->func[0]);
-                       return SDIOH_API_RC_FAIL;
-               }
-
-               reg &= ~(INTR_CTL_FUNC1_EN | INTR_CTL_FUNC2_EN);
-               /* Disable master interrupt with the last function interrupt */
-               if (!(reg & 0xFE))
-                       reg = 0;
-               sdio_writeb(gInstance->func[0], reg, SDIOD_CCCR_INTEN, &err);
-
-               sdio_release_host(gInstance->func[0]);
-               if (err) {
-                       sd_err(("%s: error for write SDIO_CCCR_IENx : 0x%x\n",
-                               __func__, err));
-                       return SDIOH_API_RC_FAIL;
-               }
-       }
-       return SDIOH_API_RC_SUCCESS;
-}
-#endif                         /* defined(OOB_INTR_ONLY) && defined(HW_OOB) */
-
 /* Configure callback to client when we receive client interrupt */
-extern SDIOH_API_RC
-sdioh_interrupt_register(sdioh_info_t *sd, sdioh_cb_fn_t fn, void *argh)
+extern int
+brcmf_sdioh_interrupt_register(struct sdioh_info *sd, sdioh_cb_fn_t fn,
+                              void *argh)
 {
        sd_trace(("%s: Entering\n", __func__));
        if (fn == NULL) {
@@ -278,7 +193,7 @@ sdioh_interrupt_register(sdioh_info_t *sd, sdioh_cb_fn_t fn, void *argh)
                        __func__));
                return SDIOH_API_RC_FAIL;
        }
-#if !defined(OOB_INTR_ONLY)
+
        sd->intr_handler = fn;
        sd->intr_handler_arg = argh;
        sd->intr_handler_valid = true;
@@ -286,26 +201,23 @@ sdioh_interrupt_register(sdioh_info_t *sd, sdioh_cb_fn_t fn, void *argh)
        /* register and unmask irq */
        if (gInstance->func[2]) {
                sdio_claim_host(gInstance->func[2]);
-               sdio_claim_irq(gInstance->func[2], IRQHandlerF2);
+               sdio_claim_irq(gInstance->func[2], brcmf_sdioh_irqhandler_f2);
                sdio_release_host(gInstance->func[2]);
        }
 
        if (gInstance->func[1]) {
                sdio_claim_host(gInstance->func[1]);
-               sdio_claim_irq(gInstance->func[1], IRQHandler);
+               sdio_claim_irq(gInstance->func[1], brcmf_sdioh_irqhandler);
                sdio_release_host(gInstance->func[1]);
        }
-#elif defined(HW_OOB)
-       sdioh_enable_func_intr();
-#endif                         /* defined(OOB_INTR_ONLY) */
+
        return SDIOH_API_RC_SUCCESS;
 }
 
-extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *sd)
+extern int brcmf_sdioh_interrupt_deregister(struct sdioh_info *sd)
 {
        sd_trace(("%s: Entering\n", __func__));
 
-#if !defined(OOB_INTR_ONLY)
        if (gInstance->func[1]) {
                /* register and unmask irq */
                sdio_claim_host(gInstance->func[1]);
@@ -324,27 +236,26 @@ extern SDIOH_API_RC sdioh_interrupt_deregister(sdioh_info_t *sd)
        sd->intr_handler_valid = false;
        sd->intr_handler = NULL;
        sd->intr_handler_arg = NULL;
-#elif defined(HW_OOB)
-       sdioh_disable_func_intr();
-#endif                         /*  !defined(OOB_INTR_ONLY) */
+
        return SDIOH_API_RC_SUCCESS;
 }
 
-extern SDIOH_API_RC sdioh_interrupt_query(sdioh_info_t *sd, bool *onoff)
+extern int
+brcmf_sdioh_interrupt_query(struct sdioh_info *sd, bool *onoff)
 {
        sd_trace(("%s: Entering\n", __func__));
        *onoff = sd->client_intr_enabled;
        return SDIOH_API_RC_SUCCESS;
 }
 
-#if defined(DHD_DEBUG)
-extern bool sdioh_interrupt_pending(sdioh_info_t *sd)
+#if defined(BCMDBG)
+extern bool brcmf_sdioh_interrupt_pending(struct sdioh_info *sd)
 {
        return 0;
 }
 #endif
 
-uint sdioh_query_iofnum(sdioh_info_t *sd)
+uint brcmf_sdioh_query_iofnum(struct sdioh_info *sd)
 {
        return sd->num_funcs;
 }
@@ -352,45 +263,21 @@ uint sdioh_query_iofnum(sdioh_info_t *sd)
 /* IOVar table */
 enum {
        IOV_MSGLEVEL = 1,
-       IOV_BLOCKMODE,
        IOV_BLOCKSIZE,
-       IOV_DMA,
        IOV_USEINTS,
        IOV_NUMINTS,
-       IOV_NUMLOCALINTS,
-       IOV_HOSTREG,
        IOV_DEVREG,
-       IOV_DIVISOR,
-       IOV_SDMODE,
-       IOV_HISPEED,
        IOV_HCIREGS,
-       IOV_POWER,
-       IOV_CLOCK,
        IOV_RXCHAIN
 };
 
-const bcm_iovar_t sdioh_iovars[] = {
+const struct brcmu_iovar sdioh_iovars[] = {
        {"sd_msglevel", IOV_MSGLEVEL, 0, IOVT_UINT32, 0},
-       {"sd_blockmode", IOV_BLOCKMODE, 0, IOVT_BOOL, 0},
        {"sd_blocksize", IOV_BLOCKSIZE, 0, IOVT_UINT32, 0},/* ((fn << 16) |
                                                                 size) */
-       {"sd_dma", IOV_DMA, 0, IOVT_BOOL, 0},
        {"sd_ints", IOV_USEINTS, 0, IOVT_BOOL, 0},
        {"sd_numints", IOV_NUMINTS, 0, IOVT_UINT32, 0},
-       {"sd_numlocalints", IOV_NUMLOCALINTS, 0, IOVT_UINT32, 0},
-       {"sd_hostreg", IOV_HOSTREG, 0, IOVT_BUFFER, sizeof(sdreg_t)}
-       ,
-       {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(sdreg_t)}
-       ,
-       {"sd_divisor", IOV_DIVISOR, 0, IOVT_UINT32, 0}
-       ,
-       {"sd_power", IOV_POWER, 0, IOVT_UINT32, 0}
-       ,
-       {"sd_clock", IOV_CLOCK, 0, IOVT_UINT32, 0}
-       ,
-       {"sd_mode", IOV_SDMODE, 0, IOVT_UINT32, 100}
-       ,
-       {"sd_highspeed", IOV_HISPEED, 0, IOVT_UINT32, 0}
+       {"sd_devreg", IOV_DEVREG, 0, IOVT_BUFFER, sizeof(struct brcmf_sdreg)}
        ,
        {"sd_rxchain", IOV_RXCHAIN, 0, IOVT_BOOL, 0}
        ,
@@ -398,10 +285,10 @@ const bcm_iovar_t sdioh_iovars[] = {
 };
 
 int
-sdioh_iovar_op(sdioh_info_t *si, const char *name,
-              void *params, int plen, void *arg, int len, bool set)
+brcmf_sdioh_iovar_op(struct sdioh_info *si, const char *name,
+                    void *params, int plen, void *arg, int len, bool set)
 {
-       const bcm_iovar_t *vi = NULL;
+       const struct brcmu_iovar *vi = NULL;
        int bcmerror = 0;
        int val_size;
        s32 int_val = 0;
@@ -418,13 +305,13 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
        sd_trace(("%s: Enter (%s %s)\n", __func__, (set ? "set" : "get"),
                  name));
 
-       vi = bcm_iovar_lookup(sdioh_iovars, name);
+       vi = brcmu_iovar_lookup(sdioh_iovars, name);
        if (vi == NULL) {
                bcmerror = -ENOTSUPP;
                goto exit;
        }
 
-       bcmerror = bcm_iovar_lencheck(vi, arg, len, set);
+       bcmerror = brcmu_iovar_lencheck(vi, arg, len, set);
        if (bcmerror != 0)
                goto exit;
 
@@ -457,16 +344,6 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
                sd_msglevel = int_val;
                break;
 
-       case IOV_GVAL(IOV_BLOCKMODE):
-               int_val = (s32) si->sd_blockmode;
-               memcpy(arg, &int_val, val_size);
-               break;
-
-       case IOV_SVAL(IOV_BLOCKMODE):
-               si->sd_blockmode = (bool) int_val;
-               /* Haven't figured out how to make non-block mode with DMA */
-               break;
-
        case IOV_GVAL(IOV_BLOCKSIZE):
                if ((u32) int_val > si->num_funcs) {
                        bcmerror = -EINVAL;
@@ -518,15 +395,6 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
                memcpy(arg, &int_val, val_size);
                break;
 
-       case IOV_GVAL(IOV_DMA):
-               int_val = (s32) si->sd_use_dma;
-               memcpy(arg, &int_val, val_size);
-               break;
-
-       case IOV_SVAL(IOV_DMA):
-               si->sd_use_dma = (bool) int_val;
-               break;
-
        case IOV_GVAL(IOV_USEINTS):
                int_val = (s32) si->use_client_ints;
                memcpy(arg, &int_val, val_size);
@@ -541,117 +409,18 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
 
                break;
 
-       case IOV_GVAL(IOV_DIVISOR):
-               int_val = (u32) sd_divisor;
-               memcpy(arg, &int_val, val_size);
-               break;
-
-       case IOV_SVAL(IOV_DIVISOR):
-               sd_divisor = int_val;
-               break;
-
-       case IOV_GVAL(IOV_POWER):
-               int_val = (u32) sd_power;
-               memcpy(arg, &int_val, val_size);
-               break;
-
-       case IOV_SVAL(IOV_POWER):
-               sd_power = int_val;
-               break;
-
-       case IOV_GVAL(IOV_CLOCK):
-               int_val = (u32) sd_clock;
-               memcpy(arg, &int_val, val_size);
-               break;
-
-       case IOV_SVAL(IOV_CLOCK):
-               sd_clock = int_val;
-               break;
-
-       case IOV_GVAL(IOV_SDMODE):
-               int_val = (u32) sd_sdmode;
-               memcpy(arg, &int_val, val_size);
-               break;
-
-       case IOV_SVAL(IOV_SDMODE):
-               sd_sdmode = int_val;
-               break;
-
-       case IOV_GVAL(IOV_HISPEED):
-               int_val = (u32) sd_hiok;
-               memcpy(arg, &int_val, val_size);
-               break;
-
-       case IOV_SVAL(IOV_HISPEED):
-               sd_hiok = int_val;
-               break;
-
        case IOV_GVAL(IOV_NUMINTS):
                int_val = (s32) si->intrcount;
                memcpy(arg, &int_val, val_size);
                break;
 
-       case IOV_GVAL(IOV_NUMLOCALINTS):
-               int_val = (s32) 0;
-               memcpy(arg, &int_val, val_size);
-               break;
-
-       case IOV_GVAL(IOV_HOSTREG):
-               {
-                       sdreg_t *sd_ptr = (sdreg_t *) params;
-
-                       if (sd_ptr->offset < SD_SysAddr
-                           || sd_ptr->offset > SD_MaxCurCap) {
-                               sd_err(("%s: bad offset 0x%x\n", __func__,
-                                       sd_ptr->offset));
-                               bcmerror = -EINVAL;
-                               break;
-                       }
-
-                       sd_trace(("%s: rreg%d at offset %d\n", __func__,
-                                 (sd_ptr->offset & 1) ? 8
-                                 : ((sd_ptr->offset & 2) ? 16 : 32),
-                                 sd_ptr->offset));
-                       if (sd_ptr->offset & 1)
-                               int_val = 8;    /* sdioh_sdmmc_rreg8(si,
-                                                sd_ptr->offset); */
-                       else if (sd_ptr->offset & 2)
-                               int_val = 16;   /* sdioh_sdmmc_rreg16(si,
-                                                sd_ptr->offset); */
-                       else
-                               int_val = 32;   /* sdioh_sdmmc_rreg(si,
-                                                sd_ptr->offset); */
-
-                       memcpy(arg, &int_val, sizeof(int_val));
-                       break;
-               }
-
-       case IOV_SVAL(IOV_HOSTREG):
-               {
-                       sdreg_t *sd_ptr = (sdreg_t *) params;
-
-                       if (sd_ptr->offset < SD_SysAddr
-                           || sd_ptr->offset > SD_MaxCurCap) {
-                               sd_err(("%s: bad offset 0x%x\n", __func__,
-                                       sd_ptr->offset));
-                               bcmerror = -EINVAL;
-                               break;
-                       }
-
-                       sd_trace(("%s: wreg%d value 0x%08x at offset %d\n",
-                                 __func__, sd_ptr->value,
-                                 (sd_ptr->offset & 1) ? 8
-                                 : ((sd_ptr->offset & 2) ? 16 : 32),
-                                 sd_ptr->offset));
-                       break;
-               }
-
        case IOV_GVAL(IOV_DEVREG):
                {
-                       sdreg_t *sd_ptr = (sdreg_t *) params;
+                       struct brcmf_sdreg *sd_ptr =
+                                       (struct brcmf_sdreg *) params;
                        u8 data = 0;
 
-                       if (sdioh_cfg_read
+                       if (brcmf_sdioh_cfg_read
                            (si, sd_ptr->func, sd_ptr->offset, &data)) {
                                bcmerror = -EIO;
                                break;
@@ -664,10 +433,11 @@ sdioh_iovar_op(sdioh_info_t *si, const char *name,
 
        case IOV_SVAL(IOV_DEVREG):
                {
-                       sdreg_t *sd_ptr = (sdreg_t *) params;
+                       struct brcmf_sdreg *sd_ptr =
+                                       (struct brcmf_sdreg *) params;
                        u8 data = (u8) sd_ptr->value;
 
-                       if (sdioh_cfg_write
+                       if (brcmf_sdioh_cfg_write
                            (si, sd_ptr->func, sd_ptr->offset, &data)) {
                                bcmerror = -EIO;
                                break;
@@ -684,50 +454,32 @@ exit:
        return bcmerror;
 }
 
-#if defined(OOB_INTR_ONLY) && defined(HW_OOB)
-
-SDIOH_API_RC sdioh_enable_hw_oob_intr(sdioh_info_t *sd, bool enable)
-{
-       SDIOH_API_RC status;
-       u8 data;
-
-       if (enable)
-               data = 3;       /* enable hw oob interrupt */
-       else
-               data = 4;       /* disable hw oob interrupt */
-       data |= 4;              /* Active HIGH */
-
-       status = sdioh_request_byte(sd, SDIOH_WRITE, 0, 0xf2, &data);
-       return status;
-}
-#endif                         /* defined(OOB_INTR_ONLY) && defined(HW_OOB) */
-
-extern SDIOH_API_RC
-sdioh_cfg_read(sdioh_info_t *sd, uint fnc_num, u32 addr, u8 *data)
+extern int
+brcmf_sdioh_cfg_read(struct sdioh_info *sd, uint fnc_num, u32 addr, u8 *data)
 {
-       SDIOH_API_RC status;
-       /* No lock needed since sdioh_request_byte does locking */
-       status = sdioh_request_byte(sd, SDIOH_READ, fnc_num, addr, data);
+       int status;
+       /* No lock needed since brcmf_sdioh_request_byte does locking */
+       status = brcmf_sdioh_request_byte(sd, SDIOH_READ, fnc_num, addr, data);
        return status;
 }
 
-extern SDIOH_API_RC
-sdioh_cfg_write(sdioh_info_t *sd, uint fnc_num, u32 addr, u8 *data)
+extern int
+brcmf_sdioh_cfg_write(struct sdioh_info *sd, uint fnc_num, u32 addr, u8 *data)
 {
-       /* No lock needed since sdioh_request_byte does locking */
-       SDIOH_API_RC status;
-       status = sdioh_request_byte(sd, SDIOH_WRITE, fnc_num, addr, data);
+       /* No lock needed since brcmf_sdioh_request_byte does locking */
+       int status;
+       status = brcmf_sdioh_request_byte(sd, SDIOH_WRITE, fnc_num, addr, data);
        return status;
 }
 
-static int sdioh_sdmmc_get_cisaddr(sdioh_info_t *sd, u32 regaddr)
+static int brcmf_sdioh_get_cisaddr(struct sdioh_info *sd, u32 regaddr)
 {
        /* read 24 bits and return valid 17 bit addr */
        int i;
        u32 scratch, regdata;
        u8 *ptr = (u8 *)&scratch;
        for (i = 0; i < 3; i++) {
-               if ((sdioh_sdmmc_card_regread(sd, 0, regaddr, 1, &regdata)) !=
+               if ((brcmf_sdioh_card_regread(sd, 0, regaddr, 1, &regdata)) !=
                    SUCCESS)
                        sd_err(("%s: Can't read!\n", __func__));
 
@@ -741,8 +493,8 @@ static int sdioh_sdmmc_get_cisaddr(sdioh_info_t *sd, u32 regaddr)
        return scratch;
 }
 
-extern SDIOH_API_RC
-sdioh_cis_read(sdioh_info_t *sd, uint func, u8 *cisd, u32 length)
+extern int
+brcmf_sdioh_cis_read(struct sdioh_info *sd, uint func, u8 *cisd, u32 length)
 {
        u32 count;
        int offset;
@@ -762,7 +514,7 @@ sdioh_cis_read(sdioh_info_t *sd, uint func, u8 *cisd, u32 length)
 
        for (count = 0; count < length; count++) {
                offset = sd->func_cis_ptr[func] + count;
-               if (sdioh_sdmmc_card_regread(sd, 0, offset, 1, &foo) < 0) {
+               if (brcmf_sdioh_card_regread(sd, 0, offset, 1, &foo) < 0) {
                        sd_err(("%s: regread failed: Can't read CIS\n",
                                __func__));
                        return SDIOH_API_RC_FAIL;
@@ -775,9 +527,9 @@ sdioh_cis_read(sdioh_info_t *sd, uint func, u8 *cisd, u32 length)
        return SDIOH_API_RC_SUCCESS;
 }
 
-extern SDIOH_API_RC
-sdioh_request_byte(sdioh_info_t *sd, uint rw, uint func, uint regaddr,
-                  u8 *byte)
+extern int
+brcmf_sdioh_request_byte(struct sdioh_info *sd, uint rw, uint func,
+                        uint regaddr, u8 *byte)
 {
        int err_ret;
 
@@ -792,7 +544,7 @@ sdioh_request_byte(sdioh_info_t *sd, uint rw, uint func, uint regaddr,
                         * Handle F2 enable
                         * as a special case.
                         */
-                       if (regaddr == SDIOD_CCCR_IOEN) {
+                       if (regaddr == SDIO_CCCR_IOEx) {
                                if (gInstance->func[2]) {
                                        sdio_claim_host(gInstance->func[2]);
                                        if (*byte & SDIO_FUNC_ENABLE_2) {
@@ -815,9 +567,8 @@ sdioh_request_byte(sdioh_info_t *sd, uint rw, uint func, uint regaddr,
                                        sdio_release_host(gInstance->func[2]);
                                }
                        }
-#if defined(MMC_SDIO_ABORT)
                        /* to allow abort command through F1 */
-                       else if (regaddr == SDIOD_CCCR_IOABORT) {
+                       else if (regaddr == SDIO_CCCR_ABORT) {
                                sdio_claim_host(gInstance->func[func]);
                                /*
                                 * this sdio_f0_writeb() can be replaced
@@ -829,7 +580,6 @@ sdioh_request_byte(sdioh_info_t *sd, uint rw, uint func, uint regaddr,
                                            regaddr, &err_ret);
                                sdio_release_host(gInstance->func[func]);
                        }
-#endif                         /* MMC_SDIO_ABORT */
                        else if (regaddr < 0xF0) {
                                sd_err(("bcmsdh_sdmmc: F0 Wr:0x%02x: write "
                                        "disallowed\n", regaddr));
@@ -874,9 +624,9 @@ sdioh_request_byte(sdioh_info_t *sd, uint rw, uint func, uint regaddr,
        return ((err_ret == 0) ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL);
 }
 
-extern SDIOH_API_RC
-sdioh_request_word(sdioh_info_t *sd, uint cmd_type, uint rw, uint func,
-                  uint addr, u32 *word, uint nbytes)
+extern int
+brcmf_sdioh_request_word(struct sdioh_info *sd, uint cmd_type, uint rw,
+                        uint func, uint addr, u32 *word, uint nbytes)
 {
        int err_ret = SDIOH_API_RC_FAIL;
 
@@ -927,9 +677,9 @@ sdioh_request_word(sdioh_info_t *sd, uint cmd_type, uint rw, uint func,
        return ((err_ret == 0) ? SDIOH_API_RC_SUCCESS : SDIOH_API_RC_FAIL);
 }
 
-static SDIOH_API_RC
-sdioh_request_packet(sdioh_info_t *sd, uint fix_inc, uint write, uint func,
-                    uint addr, struct sk_buff *pkt)
+static int
+brcmf_sdioh_request_packet(struct sdioh_info *sd, uint fix_inc, uint write,
+                          uint func, uint addr, struct sk_buff *pkt)
 {
        bool fifo = (fix_inc == SDIOH_DATA_FIX);
        u32 SGCount = 0;
@@ -950,16 +700,9 @@ sdioh_request_packet(sdioh_info_t *sd, uint fix_inc, uint write, uint func,
                pkt_len += 3;
                pkt_len &= 0xFFFFFFFC;
 
-#ifdef CONFIG_MMC_MSM7X00A
-               if ((pkt_len % 64) == 32) {
-                       sd_trace(("%s: Rounding up TX packet +=32\n",
-                                 __func__));
-                       pkt_len += 32;
-               }
-#endif                         /* CONFIG_MMC_MSM7X00A */
                /* Make sure the packet is aligned properly.
                 * If it isn't, then this
-                * is the fault of sdioh_request_buffer() which
+                * is the fault of brcmf_sdioh_request_buffer() which
                 * is supposed to give
                 * us something we can work with.
                 */
@@ -1023,12 +766,12 @@ sdioh_request_packet(sdioh_info_t *sd, uint fix_inc, uint write, uint func,
  * aligned packet.
  *
  */
-extern SDIOH_API_RC
-sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
-                    uint func, uint addr, uint reg_width, uint buflen_u,
-                    u8 *buffer, struct sk_buff *pkt)
+extern int
+brcmf_sdioh_request_buffer(struct sdioh_info *sd, uint pio_dma, uint fix_inc,
+                          uint write, uint func, uint addr, uint reg_width,
+                          uint buflen_u, u8 *buffer, struct sk_buff *pkt)
 {
-       SDIOH_API_RC Status;
+       int Status;
        struct sk_buff *mypkt = NULL;
 
        sd_trace(("%s: Enter\n", __func__));
@@ -1039,9 +782,9 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
        if (pkt == NULL) {
                sd_data(("%s: Creating new %s Packet, len=%d\n",
                         __func__, write ? "TX" : "RX", buflen_u));
-               mypkt = bcm_pkt_buf_get_skb(buflen_u);
+               mypkt = brcmu_pkt_buf_get_skb(buflen_u);
                if (!mypkt) {
-                       sd_err(("%s: bcm_pkt_buf_get_skb failed: len %d\n",
+                       sd_err(("%s: brcmu_pkt_buf_get_skb failed: len %d\n",
                                __func__, buflen_u));
                        return SDIOH_API_RC_FAIL;
                }
@@ -1050,14 +793,14 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
                if (write)
                        memcpy(mypkt->data, buffer, buflen_u);
 
-               Status =
-                   sdioh_request_packet(sd, fix_inc, write, func, addr, mypkt);
+               Status = brcmf_sdioh_request_packet(sd, fix_inc, write, func,
+                                                   addr, mypkt);
 
                /* For a read, copy the packet data back to the buffer. */
                if (!write)
                        memcpy(buffer, mypkt->data, buflen_u);
 
-               bcm_pkt_buf_free_skb(mypkt);
+               brcmu_pkt_buf_free_skb(mypkt);
        } else if (((u32) (pkt->data) & DMA_ALIGN_MASK) != 0) {
                /* Case 2: We have a packet, but it is unaligned. */
 
@@ -1066,9 +809,9 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
 
                sd_data(("%s: Creating aligned %s Packet, len=%d\n",
                         __func__, write ? "TX" : "RX", pkt->len));
-               mypkt = bcm_pkt_buf_get_skb(pkt->len);
+               mypkt = brcmu_pkt_buf_get_skb(pkt->len);
                if (!mypkt) {
-                       sd_err(("%s: bcm_pkt_buf_get_skb failed: len %d\n",
+                       sd_err(("%s: brcmu_pkt_buf_get_skb failed: len %d\n",
                                __func__, pkt->len));
                        return SDIOH_API_RC_FAIL;
                }
@@ -1077,45 +820,41 @@ sdioh_request_buffer(sdioh_info_t *sd, uint pio_dma, uint fix_inc, uint write,
                if (write)
                        memcpy(mypkt->data, pkt->data, pkt->len);
 
-               Status =
-                   sdioh_request_packet(sd, fix_inc, write, func, addr, mypkt);
+               Status = brcmf_sdioh_request_packet(sd, fix_inc, write, func,
+                                                   addr, mypkt);
 
                /* For a read, copy the packet data back to the buffer. */
                if (!write)
                        memcpy(pkt->data, mypkt->data, mypkt->len);
 
-               bcm_pkt_buf_free_skb(mypkt);
+               brcmu_pkt_buf_free_skb(mypkt);
        } else {                /* case 3: We have a packet and
                                 it is aligned. */
                sd_data(("%s: Aligned %s Packet, direct DMA\n",
                         __func__, write ? "Tx" : "Rx"));
-               Status =
-                   sdioh_request_packet(sd, fix_inc, write, func, addr, pkt);
+               Status = brcmf_sdioh_request_packet(sd, fix_inc, write, func,
+                                                   addr, pkt);
        }
 
        return Status;
 }
 
 /* this function performs "abort" for both of host & device */
-extern int sdioh_abort(sdioh_info_t *sd, uint func)
+extern int brcmf_sdioh_abort(struct sdioh_info *sd, uint func)
 {
-#if defined(MMC_SDIO_ABORT)
        char t_func = (char)func;
-#endif                         /* defined(MMC_SDIO_ABORT) */
        sd_trace(("%s: Enter\n", __func__));
 
-#if defined(MMC_SDIO_ABORT)
-       /* issue abort cmd52 command through F1 */
-       sdioh_request_byte(sd, SD_IO_OP_WRITE, SDIO_FUNC_0, SDIOD_CCCR_IOABORT,
+       /* issue abort cmd52 command through F0 */
+       brcmf_sdioh_request_byte(sd, SDIOH_WRITE, SDIO_FUNC_0, SDIO_CCCR_ABORT,
                           &t_func);
-#endif                         /* defined(MMC_SDIO_ABORT) */
 
        sd_trace(("%s: Exit\n", __func__));
        return SDIOH_API_RC_SUCCESS;
 }
 
 /* Reset and re-initialize the device */
-int sdioh_sdio_reset(sdioh_info_t *si)
+int brcmf_sdioh_reset(struct sdioh_info *si)
 {
        sd_trace(("%s: Enter\n", __func__));
        sd_trace(("%s: Exit\n", __func__));
@@ -1123,14 +862,14 @@ int sdioh_sdio_reset(sdioh_info_t *si)
 }
 
 /* Disable device interrupt */
-void sdioh_sdmmc_devintr_off(sdioh_info_t *sd)
+void brcmf_sdioh_dev_intr_off(struct sdioh_info *sd)
 {
        sd_trace(("%s: %d\n", __func__, sd->use_client_ints));
        sd->intmask &= ~CLIENT_INTR;
 }
 
 /* Enable device interrupt */
-void sdioh_sdmmc_devintr_on(sdioh_info_t *sd)
+void brcmf_sdioh_dev_intr_on(struct sdioh_info *sd)
 {
        sd_trace(("%s: %d\n", __func__, sd->use_client_ints));
        sd->intmask |= CLIENT_INTR;
@@ -1138,19 +877,19 @@ void sdioh_sdmmc_devintr_on(sdioh_info_t *sd)
 
 /* Read client card reg */
 int
-sdioh_sdmmc_card_regread(sdioh_info_t *sd, int func, u32 regaddr,
+brcmf_sdioh_card_regread(struct sdioh_info *sd, int func, u32 regaddr,
                         int regsize, u32 *data)
 {
 
        if ((func == 0) || (regsize == 1)) {
                u8 temp = 0;
 
-               sdioh_request_byte(sd, SDIOH_READ, func, regaddr, &temp);
+               brcmf_sdioh_request_byte(sd, SDIOH_READ, func, regaddr, &temp);
                *data = temp;
                *data &= 0xff;
                sd_data(("%s: byte read data=0x%02x\n", __func__, *data));
        } else {
-               sdioh_request_word(sd, 0, SDIOH_READ, func, regaddr, data,
+               brcmf_sdioh_request_word(sd, 0, SDIOH_READ, func, regaddr, data,
                                   regsize);
                if (regsize == 2)
                        *data &= 0xffff;
@@ -1161,11 +900,10 @@ sdioh_sdmmc_card_regread(sdioh_info_t *sd, int func, u32 regaddr,
        return SUCCESS;
 }
 
-#if !defined(OOB_INTR_ONLY)
 /* bcmsdh_sdmmc interrupt handler */
-static void IRQHandler(struct sdio_func *func)
+static void brcmf_sdioh_irqhandler(struct sdio_func *func)
 {
-       sdioh_info_t *sd;
+       struct sdioh_info *sd;
 
        sd_trace(("bcmsdh_sdmmc: ***IRQHandler\n"));
        sd = gInstance->sd;
@@ -1189,9 +927,9 @@ static void IRQHandler(struct sdio_func *func)
 }
 
 /* bcmsdh_sdmmc interrupt handler for F2 (dummy handler) */
-static void IRQHandlerF2(struct sdio_func *func)
+static void brcmf_sdioh_irqhandler_f2(struct sdio_func *func)
 {
-       sdioh_info_t *sd;
+       struct sdioh_info *sd;
 
        sd_trace(("bcmsdh_sdmmc: ***IRQHandlerF2\n"));
 
@@ -1199,41 +937,13 @@ static void IRQHandlerF2(struct sdio_func *func)
 
        ASSERT(sd != NULL);
 }
-#endif                         /* !defined(OOB_INTR_ONLY) */
-
-#ifdef NOTUSED
-/* Write client card reg */
-static int
-sdioh_sdmmc_card_regwrite(sdioh_info_t *sd, int func, u32 regaddr,
-                         int regsize, u32 data)
-{
-
-       if ((func == 0) || (regsize == 1)) {
-               u8 temp;
-
-               temp = data & 0xff;
-               sdioh_request_byte(sd, SDIOH_READ, func, regaddr, &temp);
-               sd_data(("%s: byte write data=0x%02x\n", __func__, data));
-       } else {
-               if (regsize == 2)
-                       data &= 0xffff;
-
-               sdioh_request_word(sd, 0, SDIOH_READ, func, regaddr, &data,
-                                  regsize);
-
-               sd_data(("%s: word write data=0x%08x\n", __func__, data));
-       }
-
-       return SUCCESS;
-}
-#endif                         /* NOTUSED */
 
-int sdioh_start(sdioh_info_t *si, int stage)
+int brcmf_sdioh_start(struct sdioh_info *si, int stage)
 {
        return 0;
 }
 
-int sdioh_stop(sdioh_info_t *si)
+int brcmf_sdioh_stop(struct sdioh_info *si)
 {
        return 0;
 }