18 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20 #include <linux/types.h>
21 #include <linux/netdevice.h>
38 #define BCM4329_CORE_BUS_BASE 0x18011000
40 #define BCM4329_CORE_SOCRAM_BASE 0x18003000
42 #define BCM4329_CORE_ARM_BASE 0x18002000
43 #define BCM4329_RAMSIZE 0x48000
45 #define SBCOREREV(sbidh) \
46 ((((sbidh) & SSB_IDHIGH_RCHI) >> SSB_IDHIGH_RCHI_SHIFT) | \
47 ((sbidh) & SSB_IDHIGH_RCLO))
54 #define CIB_REV_MASK 0xff000000
55 #define CIB_REV_SHIFT 24
57 #define SDIOD_DRVSTR_KEY(chip, pmu) (((chip) << 16) | (pmu))
81 if (coreid == ci->c_inf[idx].id)
89 struct chip_info *ci,
u16 coreid)
97 CORE_SB(ci->c_inf[idx].base, sbidhigh),
104 struct chip_info *ci,
u16 coreid)
115 struct chip_info *ci,
u16 coreid)
123 CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
132 struct chip_info *ci,
u16 coreid)
154 struct chip_info *ci,
u16 coreid)
160 base = ci->c_inf[
idx].base;
222 if (regdata & SSB_IDLOW_INITIATOR) {
240 struct chip_info *ci,
u16 coreid)
260 BCMA_RESET_CTL_RESET,
NULL);
266 struct chip_info *ci,
u16 coreid)
277 brcmf_sdio_sb_coredisable(sdiodev, ci, coreid);
285 CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
289 CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
295 CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
299 CORE_SB(ci->c_inf[idx].base, sbtmstatehigh),
303 CORE_SB(ci->c_inf[idx].base, sbimstate),
307 CORE_SB(ci->c_inf[idx].base, sbimstate),
315 CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
321 SSB_TMSLOW_CLOCK,
NULL);
323 CORE_SB(ci->c_inf[idx].base, sbtmstatelow),
330 struct chip_info *ci,
u16 coreid)
338 brcmf_sdio_ai_coredisable(sdiodev, ci, coreid);
356 static int brcmf_sdio_chip_recognition(
struct brcmf_sdio_dev *sdiodev,
357 struct chip_info *ci,
u32 regs)
368 ci->c_inf[0].base =
regs;
376 brcmf_dbg(
INFO,
"chipid=0x%x chiprev=%d\n", ci->chip, ci->chiprev);
381 ci->c_inf[0].wrapbase = 0x18100000;
382 ci->c_inf[0].cib = 0x2a084411;
384 ci->c_inf[1].base = 0x18002000;
385 ci->c_inf[1].wrapbase = 0x18102000;
386 ci->c_inf[1].cib = 0x0e004211;
388 ci->c_inf[2].base = 0x18004000;
389 ci->c_inf[2].wrapbase = 0x18104000;
390 ci->c_inf[2].cib = 0x14080401;
392 ci->c_inf[3].base = 0x18003000;
393 ci->c_inf[3].wrapbase = 0x18103000;
394 ci->c_inf[3].cib = 0x07004211;
395 ci->ramsize = 0x90000;
407 ci->c_inf[0].wrapbase = 0x18100000;
408 ci->c_inf[0].cib = 0x27004211;
410 ci->c_inf[1].base = 0x18002000;
411 ci->c_inf[1].wrapbase = 0x18102000;
412 ci->c_inf[1].cib = 0x07004211;
414 ci->c_inf[2].base = 0x18004000;
415 ci->c_inf[2].wrapbase = 0x18104000;
416 ci->c_inf[2].cib = 0x0d080401;
418 ci->c_inf[3].base = 0x18003000;
419 ci->c_inf[3].wrapbase = 0x18103000;
420 ci->c_inf[3].cib = 0x03004211;
421 ci->ramsize = 0x48000;
424 ci->c_inf[0].wrapbase = 0x18100000;
425 ci->c_inf[0].cib = 0x29004211;
427 ci->c_inf[1].base = 0x18002000;
428 ci->c_inf[1].wrapbase = 0x18102000;
429 ci->c_inf[1].cib = 0x0d004211;
431 ci->c_inf[2].base = 0x18004000;
432 ci->c_inf[2].wrapbase = 0x18104000;
433 ci->c_inf[2].cib = 0x13080401;
435 ci->c_inf[3].base = 0x18003000;
436 ci->c_inf[3].wrapbase = 0x18103000;
437 ci->c_inf[3].cib = 0x07004211;
438 ci->ramsize = 0x80000;
445 switch (ci->socitype) {
447 ci->iscoreup = brcmf_sdio_sb_iscoreup;
448 ci->corerev = brcmf_sdio_sb_corerev;
449 ci->coredisable = brcmf_sdio_sb_coredisable;
450 ci->resetcore = brcmf_sdio_sb_resetcore;
453 ci->iscoreup = brcmf_sdio_ai_iscoreup;
454 ci->corerev = brcmf_sdio_ai_corerev;
455 ci->coredisable = brcmf_sdio_ai_coredisable;
456 ci->resetcore = brcmf_sdio_ai_resetcore;
513 struct chip_info *ci)
515 u32 base = ci->c_inf[0].base;
518 ci->c_inf[0].rev = ci->corerev(sdiodev, ci, ci->c_inf[0].id);
534 ci->c_inf[1].rev = ci->corerev(sdiodev, ci, ci->c_inf[1].id);
536 brcmf_dbg(
INFO,
"ccrev=%d, pmurev=%d, buscore rev/type=%d/0x%x\n",
537 ci->c_inf[0].rev, ci->pmurev,
538 ci->c_inf[1].rev, ci->c_inf[1].id);
548 struct chip_info **ci_ptr,
u32 regs)
551 struct chip_info *ci;
556 ci = kzalloc(
sizeof(
struct chip_info),
GFP_ATOMIC);
560 ret = brcmf_sdio_chip_buscoreprep(sdiodev);
564 ret = brcmf_sdio_chip_recognition(sdiodev, ci, regs);
568 brcmf_sdio_chip_buscoresetup(sdiodev, ci);
596 fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ?
"%d" :
"%x";
603 struct chip_info *ci,
u32 drivestrength)
609 u32 base = ci->c_inf[0].base;
617 str_mask = 0x00003800;
621 brcmf_dbg(
ERROR,
"No SDIO Drive strength init done for chip %s rev %d pmurev %d\n",
622 brcmf_sdio_chip_name(ci->chip, chn, 8),
623 ci->chiprev, ci->pmurev);
627 if (str_tab !=
NULL) {
628 u32 drivestrength_sel = 0;
632 for (i = 0; str_tab[
i].
strength != 0; i++) {
633 if (drivestrength >= str_tab[i].
strength) {
634 drivestrength_sel = str_tab[
i].
sel;
645 cc_data_temp &= ~str_mask;
646 drivestrength_sel <<= str_shift;
647 cc_data_temp |= drivestrength_sel;
651 brcmf_dbg(
INFO,
"SDIO: %dmA drive strength selected, set to 0x%08x\n",
652 drivestrength, cc_data_temp);