diff options
author | Franky Lin <frankyl@broadcom.com> | 2011-11-04 17:23:28 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2011-11-09 16:13:56 -0500 |
commit | a83369b6e1e7285edd5217601a0618b9a43bdc4b (patch) | |
tree | 882387f8faeacdd589a6e1fef1baf8a1adcc152b /drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | |
parent | 718897eb3f90a47a56acb504762d521388a3231c (diff) |
brcm80211: fmac: move chip recognition function to sdio_chip.c
Currently backplane handle code is scatterd around dhd_sdio.c which
is not good for maintenance and adding new backplane interconnect
type support. This patch and the follow up patches are going to
abstract all chip backplane control code specific for sdio bus
into this new sdio_chip.c
Reviewed-by: Arend van Spriel <arend@broadcom.com>
Reviewed-by: Roland Vossen <rvossen@broadcom.com>
Signed-off-by: Franky Lin <frankyl@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c')
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 137 |
1 files changed, 2 insertions, 135 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 2c409ca68ea7..e12e99b7b774 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <brcm_hw_ids.h> | 35 | #include <brcm_hw_ids.h> |
36 | #include <soc.h> | 36 | #include <soc.h> |
37 | #include "sdio_host.h" | 37 | #include "sdio_host.h" |
38 | #include "sdio_chip.h" | ||
38 | 39 | ||
39 | #define DCMD_RESP_TIMEOUT 2000 /* In milli second */ | 40 | #define DCMD_RESP_TIMEOUT 2000 /* In milli second */ |
40 | 41 | ||
@@ -367,18 +368,6 @@ struct rte_console { | |||
367 | /* sbidlow */ | 368 | /* sbidlow */ |
368 | #define SBIDL_INIT 0x80 /* initiator */ | 369 | #define SBIDL_INIT 0x80 /* initiator */ |
369 | 370 | ||
370 | /* sbidhigh */ | ||
371 | #define SBIDH_RC_MASK 0x000f /* revision code */ | ||
372 | #define SBIDH_RCE_MASK 0x7000 /* revision code extension field */ | ||
373 | #define SBIDH_RCE_SHIFT 8 | ||
374 | #define SBCOREREV(sbidh) \ | ||
375 | ((((sbidh) & SBIDH_RCE_MASK) >> SBIDH_RCE_SHIFT) | \ | ||
376 | ((sbidh) & SBIDH_RC_MASK)) | ||
377 | #define SBIDH_CC_MASK 0x8ff0 /* core code */ | ||
378 | #define SBIDH_CC_SHIFT 4 | ||
379 | #define SBIDH_VC_MASK 0xffff0000 /* vendor code */ | ||
380 | #define SBIDH_VC_SHIFT 16 | ||
381 | |||
382 | /* | 371 | /* |
383 | * Conversion of 802.1D priority to precedence level | 372 | * Conversion of 802.1D priority to precedence level |
384 | */ | 373 | */ |
@@ -388,17 +377,6 @@ static uint prio2prec(u32 prio) | |||
388 | (prio^2) : prio; | 377 | (prio^2) : prio; |
389 | } | 378 | } |
390 | 379 | ||
391 | /* | ||
392 | * Core reg address translation. | ||
393 | * Both macro's returns a 32 bits byte address on the backplane bus. | ||
394 | */ | ||
395 | #define CORE_CC_REG(base, field) \ | ||
396 | (base + offsetof(struct chipcregs, field)) | ||
397 | #define CORE_BUS_REG(base, field) \ | ||
398 | (base + offsetof(struct sdpcmd_regs, field)) | ||
399 | #define CORE_SB(base, field) \ | ||
400 | (base + SBCONFIGOFF + offsetof(struct sbconfig, field)) | ||
401 | |||
402 | /* core registers */ | 380 | /* core registers */ |
403 | struct sdpcmd_regs { | 381 | struct sdpcmd_regs { |
404 | u32 corecontrol; /* 0x00, rev8 */ | 382 | u32 corecontrol; /* 0x00, rev8 */ |
@@ -524,21 +502,6 @@ struct sdpcm_shared_le { | |||
524 | 502 | ||
525 | 503 | ||
526 | /* misc chip info needed by some of the routines */ | 504 | /* misc chip info needed by some of the routines */ |
527 | struct chip_info { | ||
528 | u32 chip; | ||
529 | u32 chiprev; | ||
530 | u32 cccorebase; | ||
531 | u32 ccrev; | ||
532 | u32 cccaps; | ||
533 | u32 buscorebase; /* 32 bits backplane bus address */ | ||
534 | u32 buscorerev; | ||
535 | u32 buscoretype; | ||
536 | u32 ramcorebase; | ||
537 | u32 armcorebase; | ||
538 | u32 pmurev; | ||
539 | u32 ramsize; | ||
540 | }; | ||
541 | |||
542 | /* Private data for SDIO bus interaction */ | 505 | /* Private data for SDIO bus interaction */ |
543 | struct brcmf_bus { | 506 | struct brcmf_bus { |
544 | struct brcmf_pub *drvr; | 507 | struct brcmf_pub *drvr; |
@@ -663,46 +626,6 @@ struct brcmf_bus { | |||
663 | u32 fw_ptr; | 626 | u32 fw_ptr; |
664 | }; | 627 | }; |
665 | 628 | ||
666 | struct sbconfig { | ||
667 | u32 PAD[2]; | ||
668 | u32 sbipsflag; /* initiator port ocp slave flag */ | ||
669 | u32 PAD[3]; | ||
670 | u32 sbtpsflag; /* target port ocp slave flag */ | ||
671 | u32 PAD[11]; | ||
672 | u32 sbtmerrloga; /* (sonics >= 2.3) */ | ||
673 | u32 PAD; | ||
674 | u32 sbtmerrlog; /* (sonics >= 2.3) */ | ||
675 | u32 PAD[3]; | ||
676 | u32 sbadmatch3; /* address match3 */ | ||
677 | u32 PAD; | ||
678 | u32 sbadmatch2; /* address match2 */ | ||
679 | u32 PAD; | ||
680 | u32 sbadmatch1; /* address match1 */ | ||
681 | u32 PAD[7]; | ||
682 | u32 sbimstate; /* initiator agent state */ | ||
683 | u32 sbintvec; /* interrupt mask */ | ||
684 | u32 sbtmstatelow; /* target state */ | ||
685 | u32 sbtmstatehigh; /* target state */ | ||
686 | u32 sbbwa0; /* bandwidth allocation table0 */ | ||
687 | u32 PAD; | ||
688 | u32 sbimconfiglow; /* initiator configuration */ | ||
689 | u32 sbimconfighigh; /* initiator configuration */ | ||
690 | u32 sbadmatch0; /* address match0 */ | ||
691 | u32 PAD; | ||
692 | u32 sbtmconfiglow; /* target configuration */ | ||
693 | u32 sbtmconfighigh; /* target configuration */ | ||
694 | u32 sbbconfig; /* broadcast configuration */ | ||
695 | u32 PAD; | ||
696 | u32 sbbstate; /* broadcast state */ | ||
697 | u32 PAD[3]; | ||
698 | u32 sbactcnfg; /* activate configuration */ | ||
699 | u32 PAD[3]; | ||
700 | u32 sbflagst; /* current sbflags */ | ||
701 | u32 PAD[3]; | ||
702 | u32 sbidlow; /* identification */ | ||
703 | u32 sbidhigh; /* identification */ | ||
704 | }; | ||
705 | |||
706 | /* clkstate */ | 629 | /* clkstate */ |
707 | #define CLK_NONE 0 | 630 | #define CLK_NONE 0 |
708 | #define CLK_SDONLY 1 | 631 | #define CLK_SDONLY 1 |
@@ -4083,62 +4006,6 @@ static void brcmf_sdbrcm_sdiod_drive_strength_init(struct brcmf_bus *bus, | |||
4083 | } | 4006 | } |
4084 | 4007 | ||
4085 | static int | 4008 | static int |
4086 | brcmf_sdbrcm_chip_recognition(struct brcmf_sdio_dev *sdiodev, | ||
4087 | struct chip_info *ci, u32 regs) | ||
4088 | { | ||
4089 | u32 regdata; | ||
4090 | |||
4091 | /* | ||
4092 | * Get CC core rev | ||
4093 | * Chipid is assume to be at offset 0 from regs arg | ||
4094 | * For different chiptypes or old sdio hosts w/o chipcommon, | ||
4095 | * other ways of recognition should be added here. | ||
4096 | */ | ||
4097 | ci->cccorebase = regs; | ||
4098 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
4099 | CORE_CC_REG(ci->cccorebase, chipid), 4); | ||
4100 | ci->chip = regdata & CID_ID_MASK; | ||
4101 | ci->chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT; | ||
4102 | |||
4103 | brcmf_dbg(INFO, "chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev); | ||
4104 | |||
4105 | /* Address of cores for new chips should be added here */ | ||
4106 | switch (ci->chip) { | ||
4107 | case BCM4329_CHIP_ID: | ||
4108 | ci->buscorebase = BCM4329_CORE_BUS_BASE; | ||
4109 | ci->ramcorebase = BCM4329_CORE_SOCRAM_BASE; | ||
4110 | ci->armcorebase = BCM4329_CORE_ARM_BASE; | ||
4111 | ci->ramsize = BCM4329_RAMSIZE; | ||
4112 | break; | ||
4113 | default: | ||
4114 | brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); | ||
4115 | return -ENODEV; | ||
4116 | } | ||
4117 | |||
4118 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
4119 | CORE_SB(ci->cccorebase, sbidhigh), 4); | ||
4120 | ci->ccrev = SBCOREREV(regdata); | ||
4121 | |||
4122 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
4123 | CORE_CC_REG(ci->cccorebase, pmucapabilities), 4); | ||
4124 | ci->pmurev = regdata & PCAP_REV_MASK; | ||
4125 | |||
4126 | regdata = brcmf_sdcard_reg_read(sdiodev, | ||
4127 | CORE_SB(ci->buscorebase, sbidhigh), 4); | ||
4128 | ci->buscorerev = SBCOREREV(regdata); | ||
4129 | ci->buscoretype = (regdata & SBIDH_CC_MASK) >> SBIDH_CC_SHIFT; | ||
4130 | |||
4131 | brcmf_dbg(INFO, "ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n", | ||
4132 | ci->ccrev, ci->pmurev, ci->buscorerev, ci->buscoretype); | ||
4133 | |||
4134 | /* get chipcommon capabilites */ | ||
4135 | ci->cccaps = brcmf_sdcard_reg_read(sdiodev, | ||
4136 | CORE_CC_REG(ci->cccorebase, capabilities), 4); | ||
4137 | |||
4138 | return 0; | ||
4139 | } | ||
4140 | |||
4141 | static int | ||
4142 | brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) | 4009 | brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) |
4143 | { | 4010 | { |
4144 | struct chip_info *ci; | 4011 | struct chip_info *ci; |
@@ -4196,7 +4063,7 @@ brcmf_sdbrcm_chip_attach(struct brcmf_bus *bus, u32 regs) | |||
4196 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, | 4063 | brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, |
4197 | SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); | 4064 | SBSDIO_FUNC1_SDIOPULLUP, 0, NULL); |
4198 | 4065 | ||
4199 | err = brcmf_sdbrcm_chip_recognition(bus->sdiodev, ci, regs); | 4066 | err = brcmf_sdio_chip_attach(bus->sdiodev, ci, regs); |
4200 | if (err) | 4067 | if (err) |
4201 | goto fail; | 4068 | goto fail; |
4202 | 4069 | ||