2011-11-04 21:23:28 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011 Broadcom Corporation
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
|
|
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
/* ***** SDIO interface chip backplane handle functions ***** */
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/mmc/card.h>
|
2013-09-25 11:05:41 +00:00
|
|
|
#include <linux/mmc/sdio_func.h>
|
2014-01-06 11:40:50 +00:00
|
|
|
#include <linux/mmc/sdio_ids.h>
|
2011-11-04 21:23:41 +00:00
|
|
|
#include <linux/ssb/ssb_regs.h>
|
2011-11-04 21:23:42 +00:00
|
|
|
#include <linux/bcma/bcma.h>
|
2011-11-04 21:23:41 +00:00
|
|
|
|
2011-11-04 21:23:28 +00:00
|
|
|
#include <chipcommon.h>
|
|
|
|
#include <brcm_hw_ids.h>
|
|
|
|
#include <brcmu_wifi.h>
|
|
|
|
#include <brcmu_utils.h>
|
2011-11-04 21:23:31 +00:00
|
|
|
#include <soc.h>
|
2011-11-04 21:23:28 +00:00
|
|
|
#include "dhd_dbg.h"
|
|
|
|
#include "sdio_host.h"
|
|
|
|
#include "sdio_chip.h"
|
|
|
|
|
|
|
|
/* chip core base & ramsize */
|
|
|
|
/* bcm4329 */
|
|
|
|
/* SDIO device core, ID 0x829 */
|
|
|
|
#define BCM4329_CORE_BUS_BASE 0x18011000
|
|
|
|
/* internal memory core, ID 0x80e */
|
|
|
|
#define BCM4329_CORE_SOCRAM_BASE 0x18003000
|
|
|
|
/* ARM Cortex M3 core, ID 0x82a */
|
|
|
|
#define BCM4329_CORE_ARM_BASE 0x18002000
|
|
|
|
#define BCM4329_RAMSIZE 0x48000
|
|
|
|
|
2013-04-11 11:28:54 +00:00
|
|
|
/* bcm43143 */
|
|
|
|
/* SDIO device core */
|
|
|
|
#define BCM43143_CORE_BUS_BASE 0x18002000
|
|
|
|
/* internal memory core */
|
|
|
|
#define BCM43143_CORE_SOCRAM_BASE 0x18004000
|
|
|
|
/* ARM Cortex M3 core, ID 0x82a */
|
|
|
|
#define BCM43143_CORE_ARM_BASE 0x18003000
|
|
|
|
#define BCM43143_RAMSIZE 0x70000
|
|
|
|
|
2014-01-13 21:20:23 +00:00
|
|
|
/* All D11 cores, ID 0x812 */
|
|
|
|
#define BCM43xx_CORE_D11_BASE 0x18001000
|
|
|
|
|
2011-11-04 21:23:28 +00:00
|
|
|
#define SBCOREREV(sbidh) \
|
2011-11-04 21:23:41 +00:00
|
|
|
((((sbidh) & SSB_IDHIGH_RCHI) >> SSB_IDHIGH_RCHI_SHIFT) | \
|
|
|
|
((sbidh) & SSB_IDHIGH_RCLO))
|
2011-11-04 21:23:28 +00:00
|
|
|
|
2011-11-10 19:30:21 +00:00
|
|
|
/* SOC Interconnect types (aka chip types) */
|
|
|
|
#define SOCI_SB 0
|
|
|
|
#define SOCI_AI 1
|
|
|
|
|
2011-11-10 19:30:22 +00:00
|
|
|
/* EROM CompIdentB */
|
|
|
|
#define CIB_REV_MASK 0xff000000
|
|
|
|
#define CIB_REV_SHIFT 24
|
|
|
|
|
2013-04-11 11:28:51 +00:00
|
|
|
/* ARM CR4 core specific control flag bits */
|
|
|
|
#define ARMCR4_BCMA_IOCTL_CPUHALT 0x0020
|
|
|
|
|
2014-01-13 21:20:23 +00:00
|
|
|
/* D11 core specific control flag bits */
|
|
|
|
#define D11_BCMA_IOCTL_PHYCLOCKEN 0x0004
|
|
|
|
#define D11_BCMA_IOCTL_PHYRESET 0x0008
|
|
|
|
|
2011-11-04 21:23:42 +00:00
|
|
|
u8
|
2014-01-13 21:20:27 +00:00
|
|
|
brcmf_sdio_chip_getinfidx(struct brcmf_chip *ci, u16 coreid)
|
2011-11-04 21:23:42 +00:00
|
|
|
{
|
|
|
|
u8 idx;
|
|
|
|
|
|
|
|
for (idx = 0; idx < BRCMF_MAX_CORENUM; idx++)
|
|
|
|
if (coreid == ci->c_inf[idx].id)
|
|
|
|
return idx;
|
|
|
|
|
|
|
|
return BRCMF_MAX_CORENUM;
|
|
|
|
}
|
|
|
|
|
2011-11-04 21:23:37 +00:00
|
|
|
static u32
|
2011-11-10 19:30:22 +00:00
|
|
|
brcmf_sdio_sb_corerev(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci, u16 coreid)
|
2011-11-04 21:23:37 +00:00
|
|
|
{
|
|
|
|
u32 regdata;
|
2011-11-10 19:30:22 +00:00
|
|
|
u8 idx;
|
|
|
|
|
|
|
|
idx = brcmf_sdio_chip_getinfidx(ci, coreid);
|
2011-11-04 21:23:37 +00:00
|
|
|
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(ci->c_inf[idx].base, sbidhigh),
|
|
|
|
NULL);
|
2011-11-04 21:23:37 +00:00
|
|
|
return SBCOREREV(regdata);
|
|
|
|
}
|
|
|
|
|
2011-11-10 19:30:22 +00:00
|
|
|
static u32
|
|
|
|
brcmf_sdio_ai_corerev(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci, u16 coreid)
|
2011-11-10 19:30:22 +00:00
|
|
|
{
|
|
|
|
u8 idx;
|
|
|
|
|
|
|
|
idx = brcmf_sdio_chip_getinfidx(ci, coreid);
|
|
|
|
|
|
|
|
return (ci->c_inf[idx].cib & CIB_REV_MASK) >> CIB_REV_SHIFT;
|
|
|
|
}
|
|
|
|
|
2011-11-10 19:30:21 +00:00
|
|
|
static bool
|
|
|
|
brcmf_sdio_sb_iscoreup(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci, u16 coreid)
|
2011-11-04 21:23:36 +00:00
|
|
|
{
|
|
|
|
u32 regdata;
|
2011-11-10 19:30:21 +00:00
|
|
|
u8 idx;
|
|
|
|
|
|
|
|
idx = brcmf_sdio_chip_getinfidx(ci, coreid);
|
2013-09-25 11:05:42 +00:00
|
|
|
if (idx == BRCMF_MAX_CORENUM)
|
|
|
|
return false;
|
2011-11-04 21:23:36 +00:00
|
|
|
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
|
|
|
NULL);
|
2011-11-04 21:23:41 +00:00
|
|
|
regdata &= (SSB_TMSLOW_RESET | SSB_TMSLOW_REJECT |
|
|
|
|
SSB_IMSTATE_REJECT | SSB_TMSLOW_CLOCK);
|
|
|
|
return (SSB_TMSLOW_CLOCK == regdata);
|
2011-11-04 21:23:36 +00:00
|
|
|
}
|
|
|
|
|
2011-11-10 19:30:21 +00:00
|
|
|
static bool
|
|
|
|
brcmf_sdio_ai_iscoreup(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci, u16 coreid)
|
2011-11-10 19:30:21 +00:00
|
|
|
{
|
|
|
|
u32 regdata;
|
|
|
|
u8 idx;
|
|
|
|
bool ret;
|
|
|
|
|
|
|
|
idx = brcmf_sdio_chip_getinfidx(ci, coreid);
|
2013-09-25 11:05:42 +00:00
|
|
|
if (idx == BRCMF_MAX_CORENUM)
|
|
|
|
return false;
|
2011-11-10 19:30:21 +00:00
|
|
|
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev, ci->c_inf[idx].wrapbase+BCMA_IOCTL,
|
|
|
|
NULL);
|
2011-11-10 19:30:21 +00:00
|
|
|
ret = (regdata & (BCMA_IOCTL_FGC | BCMA_IOCTL_CLK)) == BCMA_IOCTL_CLK;
|
|
|
|
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
ci->c_inf[idx].wrapbase+BCMA_RESET_CTL,
|
|
|
|
NULL);
|
2011-11-10 19:30:21 +00:00
|
|
|
ret = ret && ((regdata & BCMA_RESET_CTL_RESET) == 0);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-11-10 19:30:23 +00:00
|
|
|
static void
|
|
|
|
brcmf_sdio_sb_coredisable(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits,
|
2014-01-13 21:20:23 +00:00
|
|
|
u32 in_resetbits)
|
2011-11-04 21:23:31 +00:00
|
|
|
{
|
2012-05-05 01:27:34 +00:00
|
|
|
u32 regdata, base;
|
2011-11-10 19:30:23 +00:00
|
|
|
u8 idx;
|
|
|
|
|
|
|
|
idx = brcmf_sdio_chip_getinfidx(ci, coreid);
|
2012-05-05 01:27:34 +00:00
|
|
|
base = ci->c_inf[idx].base;
|
2011-11-04 21:23:31 +00:00
|
|
|
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev, CORE_SB(base, sbtmstatelow), NULL);
|
2011-11-04 21:23:41 +00:00
|
|
|
if (regdata & SSB_TMSLOW_RESET)
|
2011-11-04 21:23:31 +00:00
|
|
|
return;
|
|
|
|
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev, CORE_SB(base, sbtmstatelow), NULL);
|
2011-11-04 21:23:41 +00:00
|
|
|
if ((regdata & SSB_TMSLOW_CLOCK) != 0) {
|
2011-11-04 21:23:31 +00:00
|
|
|
/*
|
|
|
|
* set target reject and spin until busy is clear
|
|
|
|
* (preserve core-specific bits)
|
|
|
|
*/
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(base, sbtmstatelow), NULL);
|
|
|
|
brcmf_sdiod_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
|
|
|
|
regdata | SSB_TMSLOW_REJECT, NULL);
|
2011-11-04 21:23:31 +00:00
|
|
|
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(base, sbtmstatelow), NULL);
|
2011-11-04 21:23:31 +00:00
|
|
|
udelay(1);
|
2013-12-12 10:58:58 +00:00
|
|
|
SPINWAIT((brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(base, sbtmstatehigh),
|
|
|
|
NULL) &
|
|
|
|
SSB_TMSHIGH_BUSY), 100000);
|
|
|
|
|
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(base, sbtmstatehigh),
|
|
|
|
NULL);
|
2011-11-04 21:23:41 +00:00
|
|
|
if (regdata & SSB_TMSHIGH_BUSY)
|
2012-12-07 09:49:57 +00:00
|
|
|
brcmf_err("core state still busy\n");
|
2011-11-04 21:23:31 +00:00
|
|
|
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev, CORE_SB(base, sbidlow),
|
|
|
|
NULL);
|
2011-11-04 21:23:41 +00:00
|
|
|
if (regdata & SSB_IDLOW_INITIATOR) {
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(base, sbimstate),
|
|
|
|
NULL);
|
2012-05-05 01:27:34 +00:00
|
|
|
regdata |= SSB_IMSTATE_REJECT;
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev, CORE_SB(base, sbimstate),
|
|
|
|
regdata, NULL);
|
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(base, sbimstate),
|
|
|
|
NULL);
|
2011-11-04 21:23:31 +00:00
|
|
|
udelay(1);
|
2013-12-12 10:58:58 +00:00
|
|
|
SPINWAIT((brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(base, sbimstate),
|
|
|
|
NULL) &
|
|
|
|
SSB_IMSTATE_BUSY), 100000);
|
2011-11-04 21:23:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set reset and reject while enabling the clocks */
|
2012-05-05 01:27:35 +00:00
|
|
|
regdata = SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK |
|
|
|
|
SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET;
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
|
|
|
|
regdata, NULL);
|
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(base, sbtmstatelow), NULL);
|
2011-11-04 21:23:31 +00:00
|
|
|
udelay(10);
|
|
|
|
|
|
|
|
/* clear the initiator reject bit */
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev, CORE_SB(base, sbidlow),
|
|
|
|
NULL);
|
2011-11-04 21:23:41 +00:00
|
|
|
if (regdata & SSB_IDLOW_INITIATOR) {
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(base, sbimstate),
|
|
|
|
NULL);
|
2012-05-05 01:27:34 +00:00
|
|
|
regdata &= ~SSB_IMSTATE_REJECT;
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev, CORE_SB(base, sbimstate),
|
|
|
|
regdata, NULL);
|
2011-11-04 21:23:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* leave reset and reject asserted */
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev, CORE_SB(base, sbtmstatelow),
|
|
|
|
(SSB_TMSLOW_REJECT | SSB_TMSLOW_RESET), NULL);
|
2011-11-04 21:23:31 +00:00
|
|
|
udelay(1);
|
|
|
|
}
|
|
|
|
|
2011-11-10 19:30:23 +00:00
|
|
|
static void
|
|
|
|
brcmf_sdio_ai_coredisable(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits,
|
2014-01-13 21:20:23 +00:00
|
|
|
u32 in_resetbits)
|
2011-11-10 19:30:23 +00:00
|
|
|
{
|
|
|
|
u8 idx;
|
|
|
|
u32 regdata;
|
2014-01-13 21:20:23 +00:00
|
|
|
u32 wrapbase;
|
2011-11-10 19:30:23 +00:00
|
|
|
|
|
|
|
idx = brcmf_sdio_chip_getinfidx(ci, coreid);
|
2013-09-25 11:05:42 +00:00
|
|
|
if (idx == BRCMF_MAX_CORENUM)
|
|
|
|
return;
|
2011-11-10 19:30:23 +00:00
|
|
|
|
2014-01-13 21:20:23 +00:00
|
|
|
wrapbase = ci->c_inf[idx].wrapbase;
|
|
|
|
|
2011-11-10 19:30:23 +00:00
|
|
|
/* if core is already in reset, just return */
|
2014-01-13 21:20:23 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_RESET_CTL, NULL);
|
2011-11-10 19:30:23 +00:00
|
|
|
if ((regdata & BCMA_RESET_CTL_RESET) != 0)
|
|
|
|
return;
|
|
|
|
|
2014-01-13 21:20:23 +00:00
|
|
|
/* configure reset */
|
|
|
|
brcmf_sdiod_regwl(sdiodev, wrapbase + BCMA_IOCTL, pre_resetbits |
|
|
|
|
BCMA_IOCTL_FGC | BCMA_IOCTL_CLK, NULL);
|
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_IOCTL, NULL);
|
2011-11-10 19:30:23 +00:00
|
|
|
|
2014-01-13 21:20:23 +00:00
|
|
|
/* put in reset */
|
|
|
|
brcmf_sdiod_regwl(sdiodev, wrapbase + BCMA_RESET_CTL,
|
2013-12-12 10:58:58 +00:00
|
|
|
BCMA_RESET_CTL_RESET, NULL);
|
2013-04-11 11:28:51 +00:00
|
|
|
usleep_range(10, 20);
|
|
|
|
|
2014-01-13 21:20:23 +00:00
|
|
|
/* wait till reset is 1 */
|
|
|
|
SPINWAIT(brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_RESET_CTL, NULL) !=
|
|
|
|
BCMA_RESET_CTL_RESET, 300);
|
|
|
|
|
|
|
|
/* post reset configure */
|
|
|
|
brcmf_sdiod_regwl(sdiodev, wrapbase + BCMA_IOCTL, pre_resetbits |
|
|
|
|
BCMA_IOCTL_FGC | BCMA_IOCTL_CLK, NULL);
|
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_IOCTL, NULL);
|
2011-11-10 19:30:23 +00:00
|
|
|
}
|
|
|
|
|
2011-11-10 19:30:24 +00:00
|
|
|
static void
|
|
|
|
brcmf_sdio_sb_resetcore(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits,
|
2014-01-13 21:20:23 +00:00
|
|
|
u32 in_resetbits, u32 post_resetbits)
|
2011-11-04 21:23:38 +00:00
|
|
|
{
|
|
|
|
u32 regdata;
|
2011-11-10 19:30:23 +00:00
|
|
|
u8 idx;
|
|
|
|
|
|
|
|
idx = brcmf_sdio_chip_getinfidx(ci, coreid);
|
2013-09-25 11:05:42 +00:00
|
|
|
if (idx == BRCMF_MAX_CORENUM)
|
|
|
|
return;
|
2011-11-04 21:23:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Must do the disable sequence first to work for
|
|
|
|
* arbitrary current core state.
|
|
|
|
*/
|
2014-01-13 21:20:23 +00:00
|
|
|
brcmf_sdio_sb_coredisable(sdiodev, ci, coreid, pre_resetbits,
|
|
|
|
in_resetbits);
|
2011-11-04 21:23:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now do the initialization sequence.
|
|
|
|
* set reset while enabling the clock and
|
|
|
|
* forcing them on throughout the core
|
|
|
|
*/
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev,
|
|
|
|
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
|
|
|
SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK | SSB_TMSLOW_RESET,
|
|
|
|
NULL);
|
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
|
|
|
NULL);
|
2011-11-04 21:23:38 +00:00
|
|
|
udelay(1);
|
|
|
|
|
2011-11-10 19:30:24 +00:00
|
|
|
/* clear any serror */
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
|
|
|
|
NULL);
|
2011-11-04 21:23:41 +00:00
|
|
|
if (regdata & SSB_TMSHIGH_SERR)
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev,
|
|
|
|
CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
|
|
|
|
0, NULL);
|
2011-11-04 21:23:38 +00:00
|
|
|
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(ci->c_inf[idx].base, sbimstate),
|
|
|
|
NULL);
|
2011-11-04 21:23:41 +00:00
|
|
|
if (regdata & (SSB_IMSTATE_IBE | SSB_IMSTATE_TO))
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev,
|
|
|
|
CORE_SB(ci->c_inf[idx].base, sbimstate),
|
|
|
|
regdata & ~(SSB_IMSTATE_IBE | SSB_IMSTATE_TO),
|
|
|
|
NULL);
|
2011-11-04 21:23:38 +00:00
|
|
|
|
|
|
|
/* clear reset and allow it to propagate throughout the core */
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
|
|
|
SSB_TMSLOW_FGC | SSB_TMSLOW_CLOCK, NULL);
|
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
|
|
|
NULL);
|
2011-11-04 21:23:38 +00:00
|
|
|
udelay(1);
|
|
|
|
|
|
|
|
/* leave clock enabled */
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev, CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
|
|
|
SSB_TMSLOW_CLOCK, NULL);
|
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
|
|
|
|
NULL);
|
2011-11-10 19:30:24 +00:00
|
|
|
udelay(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
brcmf_sdio_ai_resetcore(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci, u16 coreid, u32 pre_resetbits,
|
2014-01-13 21:20:23 +00:00
|
|
|
u32 in_resetbits, u32 post_resetbits)
|
2011-11-10 19:30:24 +00:00
|
|
|
{
|
|
|
|
u8 idx;
|
|
|
|
u32 regdata;
|
2014-01-13 21:20:23 +00:00
|
|
|
u32 wrapbase;
|
2011-11-10 19:30:24 +00:00
|
|
|
|
|
|
|
idx = brcmf_sdio_chip_getinfidx(ci, coreid);
|
2013-09-25 11:05:42 +00:00
|
|
|
if (idx == BRCMF_MAX_CORENUM)
|
|
|
|
return;
|
2011-11-10 19:30:24 +00:00
|
|
|
|
2014-01-13 21:20:23 +00:00
|
|
|
wrapbase = ci->c_inf[idx].wrapbase;
|
|
|
|
|
2011-11-10 19:30:24 +00:00
|
|
|
/* must disable first to work for arbitrary current core state */
|
2014-01-13 21:20:23 +00:00
|
|
|
brcmf_sdio_ai_coredisable(sdiodev, ci, coreid, pre_resetbits,
|
|
|
|
in_resetbits);
|
2011-11-10 19:30:24 +00:00
|
|
|
|
2014-01-13 21:20:23 +00:00
|
|
|
while (brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_RESET_CTL, NULL) &
|
|
|
|
BCMA_RESET_CTL_RESET) {
|
|
|
|
brcmf_sdiod_regwl(sdiodev, wrapbase + BCMA_RESET_CTL, 0, NULL);
|
|
|
|
usleep_range(40, 60);
|
|
|
|
}
|
2011-11-10 19:30:24 +00:00
|
|
|
|
2014-01-13 21:20:23 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev, wrapbase + BCMA_IOCTL, post_resetbits |
|
|
|
|
BCMA_IOCTL_CLK, NULL);
|
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_IOCTL, NULL);
|
2011-11-04 21:23:38 +00:00
|
|
|
}
|
|
|
|
|
2013-04-11 11:28:51 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* safety check for chipinfo */
|
2014-01-13 21:20:27 +00:00
|
|
|
static int brcmf_sdio_chip_cichk(struct brcmf_chip *ci)
|
2013-04-11 11:28:51 +00:00
|
|
|
{
|
|
|
|
u8 core_idx;
|
|
|
|
|
|
|
|
/* check RAM core presence for ARM CM3 core */
|
|
|
|
core_idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CM3);
|
|
|
|
if (BRCMF_MAX_CORENUM != core_idx) {
|
|
|
|
core_idx = brcmf_sdio_chip_getinfidx(ci,
|
|
|
|
BCMA_CORE_INTERNAL_MEM);
|
|
|
|
if (BRCMF_MAX_CORENUM == core_idx) {
|
|
|
|
brcmf_err("RAM core not provided with ARM CM3 core\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check RAM base for ARM CR4 core */
|
|
|
|
core_idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CR4);
|
|
|
|
if (BRCMF_MAX_CORENUM != core_idx) {
|
|
|
|
if (ci->rambase == 0) {
|
|
|
|
brcmf_err("RAM base not provided with ARM CR4 core\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else /* DEBUG */
|
2014-01-13 21:20:27 +00:00
|
|
|
static inline int brcmf_sdio_chip_cichk(struct brcmf_chip *ci)
|
2013-04-11 11:28:51 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-11-04 21:23:28 +00:00
|
|
|
static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci)
|
2011-11-04 21:23:28 +00:00
|
|
|
{
|
|
|
|
u32 regdata;
|
2014-01-13 21:20:26 +00:00
|
|
|
u32 socitype;
|
2011-11-04 21:23:28 +00:00
|
|
|
|
2013-04-11 11:28:48 +00:00
|
|
|
/* Get CC core rev
|
2014-01-13 21:20:26 +00:00
|
|
|
* Chipid is assume to be at offset 0 from SI_ENUM_BASE
|
2011-11-04 21:23:28 +00:00
|
|
|
* For different chiptypes or old sdio hosts w/o chipcommon,
|
|
|
|
* other ways of recognition should be added here.
|
|
|
|
*/
|
2013-12-12 10:58:58 +00:00
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev,
|
2014-01-13 21:20:26 +00:00
|
|
|
CORE_CC_REG(SI_ENUM_BASE, chipid),
|
2013-12-12 10:58:58 +00:00
|
|
|
NULL);
|
2011-11-04 21:23:28 +00:00
|
|
|
ci->chip = regdata & CID_ID_MASK;
|
|
|
|
ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT;
|
2013-09-25 11:05:41 +00:00
|
|
|
if (sdiodev->func[0]->device == SDIO_DEVICE_ID_BROADCOM_4335_4339 &&
|
|
|
|
ci->chiprev >= 2)
|
|
|
|
ci->chip = BCM4339_CHIP_ID;
|
2014-01-13 21:20:26 +00:00
|
|
|
socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
|
2011-11-04 21:23:28 +00:00
|
|
|
|
2014-01-13 21:20:26 +00:00
|
|
|
brcmf_dbg(INFO, "found %s chip: id=0x%x, rev=%d\n",
|
|
|
|
socitype == SOCI_SB ? "SB" : "AXI", ci->chip, ci->chiprev);
|
2011-11-04 21:23:28 +00:00
|
|
|
|
2014-01-13 21:20:26 +00:00
|
|
|
if (socitype == SOCI_SB) {
|
|
|
|
if (ci->chip != BCM4329_CHIP_ID) {
|
|
|
|
brcmf_err("SB chip is not supported\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
ci->iscoreup = brcmf_sdio_sb_iscoreup;
|
|
|
|
ci->corerev = brcmf_sdio_sb_corerev;
|
|
|
|
ci->coredisable = brcmf_sdio_sb_coredisable;
|
|
|
|
ci->resetcore = brcmf_sdio_sb_resetcore;
|
|
|
|
|
|
|
|
ci->c_inf[0].id = BCMA_CORE_CHIPCOMMON;
|
|
|
|
ci->c_inf[0].base = SI_ENUM_BASE;
|
2011-11-04 21:23:42 +00:00
|
|
|
ci->c_inf[1].id = BCMA_CORE_SDIO_DEV;
|
|
|
|
ci->c_inf[1].base = BCM4329_CORE_BUS_BASE;
|
|
|
|
ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM;
|
|
|
|
ci->c_inf[2].base = BCM4329_CORE_SOCRAM_BASE;
|
|
|
|
ci->c_inf[3].id = BCMA_CORE_ARM_CM3;
|
|
|
|
ci->c_inf[3].base = BCM4329_CORE_ARM_BASE;
|
2014-01-13 21:20:23 +00:00
|
|
|
ci->c_inf[4].id = BCMA_CORE_80211;
|
|
|
|
ci->c_inf[4].base = BCM43xx_CORE_D11_BASE;
|
2011-11-04 21:23:28 +00:00
|
|
|
ci->ramsize = BCM4329_RAMSIZE;
|
2014-01-13 21:20:26 +00:00
|
|
|
} else if (socitype == SOCI_AI) {
|
2011-11-10 19:30:21 +00:00
|
|
|
ci->iscoreup = brcmf_sdio_ai_iscoreup;
|
2011-11-10 19:30:22 +00:00
|
|
|
ci->corerev = brcmf_sdio_ai_corerev;
|
2011-11-10 19:30:23 +00:00
|
|
|
ci->coredisable = brcmf_sdio_ai_coredisable;
|
2011-11-10 19:30:24 +00:00
|
|
|
ci->resetcore = brcmf_sdio_ai_resetcore;
|
2014-01-13 21:20:26 +00:00
|
|
|
|
|
|
|
ci->c_inf[0].id = BCMA_CORE_CHIPCOMMON;
|
|
|
|
ci->c_inf[0].base = SI_ENUM_BASE;
|
|
|
|
|
|
|
|
/* Address of cores for new chips should be added here */
|
|
|
|
switch (ci->chip) {
|
|
|
|
case BCM43143_CHIP_ID:
|
|
|
|
ci->c_inf[0].wrapbase = ci->c_inf[0].base + 0x00100000;
|
|
|
|
ci->c_inf[0].cib = 0x2b000000;
|
|
|
|
ci->c_inf[1].id = BCMA_CORE_SDIO_DEV;
|
|
|
|
ci->c_inf[1].base = BCM43143_CORE_BUS_BASE;
|
|
|
|
ci->c_inf[1].wrapbase = ci->c_inf[1].base + 0x00100000;
|
|
|
|
ci->c_inf[1].cib = 0x18000000;
|
|
|
|
ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM;
|
|
|
|
ci->c_inf[2].base = BCM43143_CORE_SOCRAM_BASE;
|
|
|
|
ci->c_inf[2].wrapbase = ci->c_inf[2].base + 0x00100000;
|
|
|
|
ci->c_inf[2].cib = 0x14000000;
|
|
|
|
ci->c_inf[3].id = BCMA_CORE_ARM_CM3;
|
|
|
|
ci->c_inf[3].base = BCM43143_CORE_ARM_BASE;
|
|
|
|
ci->c_inf[3].wrapbase = ci->c_inf[3].base + 0x00100000;
|
|
|
|
ci->c_inf[3].cib = 0x07000000;
|
|
|
|
ci->c_inf[4].id = BCMA_CORE_80211;
|
|
|
|
ci->c_inf[4].base = BCM43xx_CORE_D11_BASE;
|
|
|
|
ci->c_inf[4].wrapbase = ci->c_inf[4].base + 0x00100000;
|
|
|
|
ci->ramsize = BCM43143_RAMSIZE;
|
|
|
|
break;
|
|
|
|
case BCM43241_CHIP_ID:
|
|
|
|
ci->c_inf[0].wrapbase = 0x18100000;
|
|
|
|
ci->c_inf[0].cib = 0x2a084411;
|
|
|
|
ci->c_inf[1].id = BCMA_CORE_SDIO_DEV;
|
|
|
|
ci->c_inf[1].base = 0x18002000;
|
|
|
|
ci->c_inf[1].wrapbase = 0x18102000;
|
|
|
|
ci->c_inf[1].cib = 0x0e004211;
|
|
|
|
ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM;
|
|
|
|
ci->c_inf[2].base = 0x18004000;
|
|
|
|
ci->c_inf[2].wrapbase = 0x18104000;
|
|
|
|
ci->c_inf[2].cib = 0x14080401;
|
|
|
|
ci->c_inf[3].id = BCMA_CORE_ARM_CM3;
|
|
|
|
ci->c_inf[3].base = 0x18003000;
|
|
|
|
ci->c_inf[3].wrapbase = 0x18103000;
|
|
|
|
ci->c_inf[3].cib = 0x07004211;
|
|
|
|
ci->c_inf[4].id = BCMA_CORE_80211;
|
|
|
|
ci->c_inf[4].base = BCM43xx_CORE_D11_BASE;
|
|
|
|
ci->c_inf[4].wrapbase = ci->c_inf[4].base + 0x00100000;
|
|
|
|
ci->ramsize = 0x90000;
|
|
|
|
break;
|
|
|
|
case BCM4330_CHIP_ID:
|
|
|
|
ci->c_inf[0].wrapbase = 0x18100000;
|
|
|
|
ci->c_inf[0].cib = 0x27004211;
|
|
|
|
ci->c_inf[1].id = BCMA_CORE_SDIO_DEV;
|
|
|
|
ci->c_inf[1].base = 0x18002000;
|
|
|
|
ci->c_inf[1].wrapbase = 0x18102000;
|
|
|
|
ci->c_inf[1].cib = 0x07004211;
|
|
|
|
ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM;
|
|
|
|
ci->c_inf[2].base = 0x18004000;
|
|
|
|
ci->c_inf[2].wrapbase = 0x18104000;
|
|
|
|
ci->c_inf[2].cib = 0x0d080401;
|
|
|
|
ci->c_inf[3].id = BCMA_CORE_ARM_CM3;
|
|
|
|
ci->c_inf[3].base = 0x18003000;
|
|
|
|
ci->c_inf[3].wrapbase = 0x18103000;
|
|
|
|
ci->c_inf[3].cib = 0x03004211;
|
|
|
|
ci->c_inf[4].id = BCMA_CORE_80211;
|
|
|
|
ci->c_inf[4].base = BCM43xx_CORE_D11_BASE;
|
|
|
|
ci->c_inf[4].wrapbase = ci->c_inf[4].base + 0x00100000;
|
|
|
|
ci->ramsize = 0x48000;
|
|
|
|
break;
|
|
|
|
case BCM4334_CHIP_ID:
|
|
|
|
ci->c_inf[0].wrapbase = 0x18100000;
|
|
|
|
ci->c_inf[0].cib = 0x29004211;
|
|
|
|
ci->c_inf[1].id = BCMA_CORE_SDIO_DEV;
|
|
|
|
ci->c_inf[1].base = 0x18002000;
|
|
|
|
ci->c_inf[1].wrapbase = 0x18102000;
|
|
|
|
ci->c_inf[1].cib = 0x0d004211;
|
|
|
|
ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM;
|
|
|
|
ci->c_inf[2].base = 0x18004000;
|
|
|
|
ci->c_inf[2].wrapbase = 0x18104000;
|
|
|
|
ci->c_inf[2].cib = 0x13080401;
|
|
|
|
ci->c_inf[3].id = BCMA_CORE_ARM_CM3;
|
|
|
|
ci->c_inf[3].base = 0x18003000;
|
|
|
|
ci->c_inf[3].wrapbase = 0x18103000;
|
|
|
|
ci->c_inf[3].cib = 0x07004211;
|
|
|
|
ci->c_inf[4].id = BCMA_CORE_80211;
|
|
|
|
ci->c_inf[4].base = BCM43xx_CORE_D11_BASE;
|
|
|
|
ci->c_inf[4].wrapbase = ci->c_inf[4].base + 0x00100000;
|
|
|
|
ci->ramsize = 0x80000;
|
|
|
|
break;
|
|
|
|
case BCM4335_CHIP_ID:
|
|
|
|
ci->c_inf[0].wrapbase = 0x18100000;
|
|
|
|
ci->c_inf[0].cib = 0x2b084411;
|
|
|
|
ci->c_inf[1].id = BCMA_CORE_SDIO_DEV;
|
|
|
|
ci->c_inf[1].base = 0x18005000;
|
|
|
|
ci->c_inf[1].wrapbase = 0x18105000;
|
|
|
|
ci->c_inf[1].cib = 0x0f004211;
|
|
|
|
ci->c_inf[2].id = BCMA_CORE_ARM_CR4;
|
|
|
|
ci->c_inf[2].base = 0x18002000;
|
|
|
|
ci->c_inf[2].wrapbase = 0x18102000;
|
|
|
|
ci->c_inf[2].cib = 0x01084411;
|
|
|
|
ci->c_inf[3].id = BCMA_CORE_80211;
|
|
|
|
ci->c_inf[3].base = BCM43xx_CORE_D11_BASE;
|
|
|
|
ci->c_inf[3].wrapbase = ci->c_inf[3].base + 0x00100000;
|
|
|
|
ci->ramsize = 0xc0000;
|
|
|
|
ci->rambase = 0x180000;
|
|
|
|
break;
|
|
|
|
case BCM43362_CHIP_ID:
|
|
|
|
ci->c_inf[0].wrapbase = 0x18100000;
|
|
|
|
ci->c_inf[0].cib = 0x27004211;
|
|
|
|
ci->c_inf[1].id = BCMA_CORE_SDIO_DEV;
|
|
|
|
ci->c_inf[1].base = 0x18002000;
|
|
|
|
ci->c_inf[1].wrapbase = 0x18102000;
|
|
|
|
ci->c_inf[1].cib = 0x0a004211;
|
|
|
|
ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM;
|
|
|
|
ci->c_inf[2].base = 0x18004000;
|
|
|
|
ci->c_inf[2].wrapbase = 0x18104000;
|
|
|
|
ci->c_inf[2].cib = 0x08080401;
|
|
|
|
ci->c_inf[3].id = BCMA_CORE_ARM_CM3;
|
|
|
|
ci->c_inf[3].base = 0x18003000;
|
|
|
|
ci->c_inf[3].wrapbase = 0x18103000;
|
|
|
|
ci->c_inf[3].cib = 0x03004211;
|
|
|
|
ci->c_inf[4].id = BCMA_CORE_80211;
|
|
|
|
ci->c_inf[4].base = BCM43xx_CORE_D11_BASE;
|
|
|
|
ci->c_inf[4].wrapbase = ci->c_inf[4].base + 0x00100000;
|
|
|
|
ci->ramsize = 0x3C000;
|
|
|
|
break;
|
|
|
|
case BCM4339_CHIP_ID:
|
|
|
|
ci->c_inf[0].wrapbase = 0x18100000;
|
|
|
|
ci->c_inf[0].cib = 0x2e084411;
|
|
|
|
ci->c_inf[1].id = BCMA_CORE_SDIO_DEV;
|
|
|
|
ci->c_inf[1].base = 0x18005000;
|
|
|
|
ci->c_inf[1].wrapbase = 0x18105000;
|
|
|
|
ci->c_inf[1].cib = 0x15004211;
|
|
|
|
ci->c_inf[2].id = BCMA_CORE_ARM_CR4;
|
|
|
|
ci->c_inf[2].base = 0x18002000;
|
|
|
|
ci->c_inf[2].wrapbase = 0x18102000;
|
|
|
|
ci->c_inf[2].cib = 0x04084411;
|
|
|
|
ci->c_inf[3].id = BCMA_CORE_80211;
|
|
|
|
ci->c_inf[3].base = BCM43xx_CORE_D11_BASE;
|
|
|
|
ci->c_inf[3].wrapbase = ci->c_inf[3].base + 0x00100000;
|
|
|
|
ci->ramsize = 0xc0000;
|
|
|
|
ci->rambase = 0x180000;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
brcmf_err("AXI chip is not supported\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
brcmf_err("chip backplane type %u is not supported\n",
|
|
|
|
socitype);
|
2011-11-10 19:30:21 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2014-01-13 21:20:26 +00:00
|
|
|
return brcmf_sdio_chip_cichk(ci);
|
2011-11-04 21:23:28 +00:00
|
|
|
}
|
|
|
|
|
2011-11-04 21:23:30 +00:00
|
|
|
static void
|
|
|
|
brcmf_sdio_chip_buscoresetup(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci)
|
2011-11-04 21:23:30 +00:00
|
|
|
{
|
2012-05-05 01:27:34 +00:00
|
|
|
u32 base = ci->c_inf[0].base;
|
|
|
|
|
2011-11-04 21:23:30 +00:00
|
|
|
/* get chipcommon rev */
|
2011-11-10 19:30:22 +00:00
|
|
|
ci->c_inf[0].rev = ci->corerev(sdiodev, ci, ci->c_inf[0].id);
|
2011-11-04 21:23:30 +00:00
|
|
|
|
|
|
|
/* get chipcommon capabilites */
|
2013-12-12 10:58:58 +00:00
|
|
|
ci->c_inf[0].caps = brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_CC_REG(base, capabilities),
|
|
|
|
NULL);
|
2011-11-04 21:23:30 +00:00
|
|
|
|
|
|
|
/* get pmu caps & rev */
|
2011-11-04 21:23:42 +00:00
|
|
|
if (ci->c_inf[0].caps & CC_CAP_PMU) {
|
2012-05-05 01:27:34 +00:00
|
|
|
ci->pmucaps =
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regrl(sdiodev,
|
|
|
|
CORE_CC_REG(base, pmucapabilities),
|
|
|
|
NULL);
|
2011-11-04 21:23:30 +00:00
|
|
|
ci->pmurev = ci->pmucaps & PCAP_REV_MASK;
|
|
|
|
}
|
|
|
|
|
2011-11-10 19:30:22 +00:00
|
|
|
ci->c_inf[1].rev = ci->corerev(sdiodev, ci, ci->c_inf[1].id);
|
2011-11-04 21:23:30 +00:00
|
|
|
|
|
|
|
brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n",
|
2011-11-04 21:23:42 +00:00
|
|
|
ci->c_inf[0].rev, ci->pmurev,
|
|
|
|
ci->c_inf[1].rev, ci->c_inf[1].id);
|
2011-11-04 21:23:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure any on-chip ARM is off (in case strapping is wrong),
|
|
|
|
* or downloaded code was already running.
|
|
|
|
*/
|
2014-01-13 21:20:23 +00:00
|
|
|
ci->coredisable(sdiodev, ci, BCMA_CORE_ARM_CM3, 0, 0);
|
2011-11-04 21:23:30 +00:00
|
|
|
}
|
|
|
|
|
2011-11-04 21:23:28 +00:00
|
|
|
int brcmf_sdio_chip_attach(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip **ci_ptr)
|
2011-11-04 21:23:28 +00:00
|
|
|
{
|
2011-11-04 21:23:35 +00:00
|
|
|
int ret;
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci;
|
2011-11-04 21:23:35 +00:00
|
|
|
|
|
|
|
brcmf_dbg(TRACE, "Enter\n");
|
|
|
|
|
2014-01-13 21:20:27 +00:00
|
|
|
ci = kzalloc(sizeof(*ci), GFP_ATOMIC);
|
2011-11-04 21:23:35 +00:00
|
|
|
if (!ci)
|
|
|
|
return -ENOMEM;
|
2011-11-04 21:23:28 +00:00
|
|
|
|
2014-01-29 14:32:14 +00:00
|
|
|
ret = brcmf_sdio_buscoreprep(sdiodev);
|
2011-11-04 21:23:29 +00:00
|
|
|
if (ret != 0)
|
2011-11-04 21:23:35 +00:00
|
|
|
goto err;
|
2011-11-04 21:23:29 +00:00
|
|
|
|
2013-12-12 10:58:55 +00:00
|
|
|
ret = brcmf_sdio_chip_recognition(sdiodev, ci);
|
2011-11-04 21:23:28 +00:00
|
|
|
if (ret != 0)
|
2011-11-04 21:23:35 +00:00
|
|
|
goto err;
|
2011-11-04 21:23:28 +00:00
|
|
|
|
2011-11-04 21:23:30 +00:00
|
|
|
brcmf_sdio_chip_buscoresetup(sdiodev, ci);
|
|
|
|
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev, CORE_CC_REG(ci->c_inf[0].base, gpiopullup),
|
|
|
|
0, NULL);
|
|
|
|
brcmf_sdiod_regwl(sdiodev, CORE_CC_REG(ci->c_inf[0].base, gpiopulldown),
|
|
|
|
0, NULL);
|
2011-11-04 21:23:33 +00:00
|
|
|
|
2011-11-04 21:23:35 +00:00
|
|
|
*ci_ptr = ci;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
err:
|
|
|
|
kfree(ci);
|
2011-11-04 21:23:28 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2011-11-04 21:23:39 +00:00
|
|
|
|
|
|
|
void
|
2014-01-13 21:20:27 +00:00
|
|
|
brcmf_sdio_chip_detach(struct brcmf_chip **ci_ptr)
|
2011-11-04 21:23:39 +00:00
|
|
|
{
|
|
|
|
brcmf_dbg(TRACE, "Enter\n");
|
|
|
|
|
|
|
|
kfree(*ci_ptr);
|
|
|
|
*ci_ptr = NULL;
|
|
|
|
}
|
2011-11-04 21:23:40 +00:00
|
|
|
|
2013-04-11 11:28:48 +00:00
|
|
|
static void
|
|
|
|
brcmf_sdio_chip_cm3_enterdl(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci)
|
2013-04-11 11:28:48 +00:00
|
|
|
{
|
2014-01-13 21:20:23 +00:00
|
|
|
ci->coredisable(sdiodev, ci, BCMA_CORE_ARM_CM3, 0, 0);
|
|
|
|
ci->resetcore(sdiodev, ci, BCMA_CORE_80211,
|
|
|
|
D11_BCMA_IOCTL_PHYRESET | D11_BCMA_IOCTL_PHYCLOCKEN,
|
|
|
|
D11_BCMA_IOCTL_PHYCLOCKEN, D11_BCMA_IOCTL_PHYCLOCKEN);
|
|
|
|
ci->resetcore(sdiodev, ci, BCMA_CORE_INTERNAL_MEM, 0, 0, 0);
|
2013-04-11 11:28:48 +00:00
|
|
|
}
|
|
|
|
|
2014-01-13 21:20:27 +00:00
|
|
|
static bool brcmf_sdio_chip_cm3_exitdl(struct brcmf_sdio_dev *sdiodev,
|
|
|
|
struct brcmf_chip *ci)
|
2013-04-11 11:28:48 +00:00
|
|
|
{
|
|
|
|
u8 core_idx;
|
|
|
|
u32 reg_addr;
|
|
|
|
|
|
|
|
if (!ci->iscoreup(sdiodev, ci, BCMA_CORE_INTERNAL_MEM)) {
|
|
|
|
brcmf_err("SOCRAM core is down after reset?\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clear all interrupts */
|
|
|
|
core_idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_SDIO_DEV);
|
|
|
|
reg_addr = ci->c_inf[core_idx].base;
|
|
|
|
reg_addr += offsetof(struct sdpcmd_regs, intstatus);
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev, reg_addr, 0xFFFFFFFF, NULL);
|
2013-04-11 11:28:48 +00:00
|
|
|
|
2014-01-13 21:20:23 +00:00
|
|
|
ci->resetcore(sdiodev, ci, BCMA_CORE_ARM_CM3, 0, 0, 0);
|
2013-04-11 11:28:51 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
brcmf_sdio_chip_cr4_enterdl(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci)
|
2013-04-11 11:28:51 +00:00
|
|
|
{
|
2014-01-13 21:20:23 +00:00
|
|
|
u8 idx;
|
|
|
|
u32 regdata;
|
|
|
|
u32 wrapbase;
|
|
|
|
idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CR4);
|
|
|
|
|
|
|
|
if (idx == BRCMF_MAX_CORENUM)
|
|
|
|
return;
|
|
|
|
|
|
|
|
wrapbase = ci->c_inf[idx].wrapbase;
|
|
|
|
regdata = brcmf_sdiod_regrl(sdiodev, wrapbase + BCMA_IOCTL, NULL);
|
|
|
|
regdata &= ARMCR4_BCMA_IOCTL_CPUHALT;
|
|
|
|
ci->resetcore(sdiodev, ci, BCMA_CORE_ARM_CR4, regdata,
|
|
|
|
ARMCR4_BCMA_IOCTL_CPUHALT, ARMCR4_BCMA_IOCTL_CPUHALT);
|
|
|
|
ci->resetcore(sdiodev, ci, BCMA_CORE_80211,
|
|
|
|
D11_BCMA_IOCTL_PHYRESET | D11_BCMA_IOCTL_PHYCLOCKEN,
|
|
|
|
D11_BCMA_IOCTL_PHYCLOCKEN, D11_BCMA_IOCTL_PHYCLOCKEN);
|
2013-04-11 11:28:51 +00:00
|
|
|
}
|
|
|
|
|
2014-01-13 21:20:27 +00:00
|
|
|
static bool brcmf_sdio_chip_cr4_exitdl(struct brcmf_sdio_dev *sdiodev,
|
|
|
|
struct brcmf_chip *ci, u32 rstvec)
|
2013-04-11 11:28:51 +00:00
|
|
|
{
|
|
|
|
u8 core_idx;
|
|
|
|
u32 reg_addr;
|
|
|
|
|
|
|
|
/* clear all interrupts */
|
|
|
|
core_idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_SDIO_DEV);
|
|
|
|
reg_addr = ci->c_inf[core_idx].base;
|
|
|
|
reg_addr += offsetof(struct sdpcmd_regs, intstatus);
|
2013-12-12 10:58:58 +00:00
|
|
|
brcmf_sdiod_regwl(sdiodev, reg_addr, 0xFFFFFFFF, NULL);
|
2013-04-11 11:28:51 +00:00
|
|
|
|
|
|
|
/* Write reset vector to address 0 */
|
2014-01-13 21:20:25 +00:00
|
|
|
brcmf_sdiod_ramrw(sdiodev, true, 0, (void *)&rstvec,
|
|
|
|
sizeof(rstvec));
|
2013-04-11 11:28:51 +00:00
|
|
|
|
|
|
|
/* restore ARM */
|
2014-01-13 21:20:23 +00:00
|
|
|
ci->resetcore(sdiodev, ci, BCMA_CORE_ARM_CR4, ARMCR4_BCMA_IOCTL_CPUHALT,
|
|
|
|
0, 0);
|
2013-04-11 11:28:48 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void brcmf_sdio_chip_enter_download(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci)
|
2013-04-11 11:28:48 +00:00
|
|
|
{
|
2013-04-11 11:28:51 +00:00
|
|
|
u8 arm_core_idx;
|
|
|
|
|
|
|
|
arm_core_idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CM3);
|
|
|
|
if (BRCMF_MAX_CORENUM != arm_core_idx) {
|
|
|
|
brcmf_sdio_chip_cm3_enterdl(sdiodev, ci);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
brcmf_sdio_chip_cr4_enterdl(sdiodev, ci);
|
2013-04-11 11:28:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool brcmf_sdio_chip_exit_download(struct brcmf_sdio_dev *sdiodev,
|
2014-01-13 21:20:27 +00:00
|
|
|
struct brcmf_chip *ci, u32 rstvec)
|
2013-04-11 11:28:48 +00:00
|
|
|
{
|
2013-04-11 11:28:51 +00:00
|
|
|
u8 arm_core_idx;
|
|
|
|
|
|
|
|
arm_core_idx = brcmf_sdio_chip_getinfidx(ci, BCMA_CORE_ARM_CM3);
|
|
|
|
if (BRCMF_MAX_CORENUM != arm_core_idx)
|
2014-01-13 21:20:22 +00:00
|
|
|
return brcmf_sdio_chip_cm3_exitdl(sdiodev, ci);
|
2013-04-11 11:28:51 +00:00
|
|
|
|
2014-01-13 21:20:25 +00:00
|
|
|
return brcmf_sdio_chip_cr4_exitdl(sdiodev, ci, rstvec);
|
2013-04-11 11:28:48 +00:00
|
|
|
}
|