Lines Matching full:bus

2  * DHD Bus Module for SDIO
202 * bufpool was present for gspi bus.
204 #define PKTFREE2() if ((bus->bus != SPI_BUS) || bus->usebufpool) \
205 PKTFREE(bus->dhd->osh, pkt, FALSE);
228 #define REMAP_ENAB(bus) ((bus)->remap) argument
229 #define REMAP_ISADDR(bus, a) (((a) >= ((bus)->orig_ramsize)) && ((a) < ((bus)->ramsize))) argument
230 #define KSO_ENAB(bus) ((bus)->kso) argument
231 #define SR_ENAB(bus) ((bus)->_srenab) argument
232 #define SLPAUTO_ENAB(bus) ((SR_ENAB(bus)) && ((bus)->_slpauto)) argument
240 #define OOB_WAKEUP_ENAB(bus) ((bus)->_oobwakeup) argument
279 /* Private data for SDIO bus interaction */
297 uint32 bus; /* gSPI or SDIO bus */ member
298 uint32 bus_num; /* bus number */
338 uint8 sdpcm_ver; /* Bus protocol reported by dongle */
360 int32 idleclock; /* How to set bus driver when idle */
361 int32 sd_divisor; /* Speed control to bus driver */
362 int32 sd_mode; /* Mode control to bus driver */
365 bool sleeping; /* Is SDIO bus sleeping? */
469 uint32 bt_use_count; /* Counter that tracks whether BT is using the bus */
490 #define NO_OTHER_ACTIVE_BUS_USER(bus) (bus->bt_use_count == 0) argument
492 #define NO_OTHER_ACTIVE_BUS_USER(bus) (1) argument
522 extern void dhd_os_wd_timer(void *bus, uint wdtick);
573 static uint32 dhd_sdio_reg_read(struct dhd_bus *bus, ulong addr);
574 static void dhd_sdio_reg_write(struct dhd_bus *bus, ulong addr, uint32 val);
576 /** the debugger layer will call back into this (bus) layer to read/write dongle memory */
614 #define DATAOK(bus) \ argument
615 (((uint8)(bus->tx_max - bus->tx_seq) > TXCTL_CREDITS) && \
616 (((uint8)(bus->tx_max - bus->tx_seq) & 0x80) == 0))
619 #define TXCTLOK(bus) \ argument
620 (((uint8)(bus->tx_max - bus->tx_seq) != 0) && \
621 (((uint8)(bus->tx_max - bus->tx_seq) & 0x80) == 0))
624 #define DATABUFCNT(bus) \ argument
625 ((uint8)(bus->tx_max - bus->tx_seq) - 1)
628 /* NOTE: these assume a local dhdsdio_bus_t *bus! */
633 regvar = R_REG(bus->dhd->osh, regaddr); \
634 } while (bcmsdh_regfail(bus->sdh) && (++retryvar <= retry_limit)); \
636 bus->regfails += (retryvar-1); \
649 W_REG(bus->dhd->osh, regaddr, regval); \
650 } while (bcmsdh_regfail(bus->sdh) && (++retryvar <= retry_limit)); \
652 bus->regfails += (retryvar-1); \
659 #define BUS_WAKE(bus) \ argument
661 bus->idlecount = 0; \
662 if ((bus)->sleeping) \
663 dhdsdio_bussleep((bus), FALSE); \
693 #define FRAME_AVAIL_MASK(bus) I_HMB_FRAME_IND argument
698 #define PKT_AVAILABLE(bus, intstatus) (bcmsdh_get_dstatus(bus->sdh) & STATUS_F2_PKT_AVAILABLE) argument
704 uint32 dstatussw = bcmsdh_get_dstatus((void *)bus->sdh); \
705 uint32 dstatushw = bcmsdh_cfg_read_word(bus->sdh, SDIO_FUNC_0, SPID_STATUS_REG, NULL); \
709 R_SDREG(intstatuserr, &bus->regs->intstatus, retries); \
713 bus->nextlen = 0; \
719 #define FRAME_AVAIL_MASK(bus) \ argument
720 ((bus->rxint_mode == SDIO_DEVICE_HMB_RXINT) ? I_HMB_FRAME_IND : I_XMTDATA_AVAIL)
724 #define PKT_AVAILABLE(bus, intstatus) ((intstatus) & (FRAME_AVAIL_MASK(bus))) argument
739 static void dhdsdio_testrcv(dhd_bus_t *bus, void *pkt, uint seq);
740 static void dhdsdio_sdtest_set(dhd_bus_t *bus, uint count);
743 static int dhdsdio_checkdied(dhd_bus_t *bus, char *data, uint size);
745 static int dhd_serialconsole(dhd_bus_t *bus, bool get, bool enable, int *bcmerror);
749 static int dhdsdio_mem_dump(dhd_bus_t *bus);
750 static int dhdsdio_get_mem_dump(dhd_bus_t *bus);
752 static int dhdsdio_devcap_set(dhd_bus_t *bus, uint8 cap);
753 static int dhdsdio_readshared_console(dhd_bus_t *bus);
754 static int dhdsdio_download_state(dhd_bus_t *bus, bool enter);
755 static int dhdsdio_wait_bootloader_ready(dhd_bus_t *bus, hs_addrs_t *addr);
756 static int dhdsdio_dongle_host_get_handshake_address(dhd_bus_t *bus, hs_addrs_t *addr);
757 static int dhdsdio_dongle_host_pre_handshake(dhd_bus_t *bus, hs_addrs_t *addr);
758 static int dhdsdio_dongle_host_post_handshake(dhd_bus_t *bus, hs_addrs_t *addr);
759 static int dhdsdio_dongle_host_chk_validation(dhd_bus_t *bus, hs_addrs_t *addr);
760 static int dhdsdio_dongle_host_post_varswrite(dhd_bus_t *bus, hs_addrs_t *addr);
761 int dhdsdio_dongle_host_pre_wd_reset_sequence(dhd_bus_t *bus);
763 static int dhdsdio_handshake_msg_reg_write(dhd_bus_t *bus, volatile void *addr,
765 static int dhdsdio_handshake_msg_reg_read(dhd_bus_t *bus, volatile void *addr,
767 static int dhdsdio_cfg_write_buffer(dhd_bus_t *bus, uint32 *buffer, uint offset);
768 static int dhdsdio_cfg_read_buffer(dhd_bus_t *bus, uint32 *buffer, uint offset);
769 static int dhdsdio_dongle_host_handshake_spinwait(dhd_bus_t *bus, volatile void *addr,
772 static void dhdsdio_release(dhd_bus_t *bus, osl_t *osh);
773 static void dhdsdio_release_malloc(dhd_bus_t *bus, osl_t *osh);
776 static bool dhdsdio_probe_attach(dhd_bus_t *bus, osl_t *osh, void *sdh,
778 static bool dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh);
779 static bool dhdsdio_probe_init(dhd_bus_t *bus, osl_t *osh, void *sdh);
780 static void dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh, bool dongle_isolation,
783 static void dhd_dongle_setramsize(struct dhd_bus *bus, int mem_size);
784 static int dhd_bcmsdh_recv_buf(dhd_bus_t *bus, uint32 addr, uint fn, uint flags,
787 static int dhd_bcmsdh_send_buf(dhd_bus_t *bus, uint32 addr, uint fn, uint flags,
790 static int dhdsdio_txpkt(dhd_bus_t *bus, uint chan, void** pkts, int num_pkt, bool free_pkt);
791 static int dhdsdio_txpkt_preprocess(dhd_bus_t *bus, void *pkt, int chan, int txseq,
794 static int dhdsdio_txpkt_postprocess(dhd_bus_t *bus, void *pkt);
796 static int dhdsdio_download_firmware(dhd_bus_t *bus, osl_t *osh, void *sdh);
797 static int _dhdsdio_download_firmware(dhd_bus_t *bus);
800 static int dhdsdio_download_ucode_file(struct dhd_bus *bus, char *ucode_path);
802 static int dhdsdio_download_code_file(dhd_bus_t *bus, char *image_path);
803 static int dhdsdio_download_nvram(dhd_bus_t *bus);
804 static int dhdsdio_bussleep(dhd_bus_t *bus, bool sleep);
805 static int dhdsdio_clkctl(dhd_bus_t *bus, uint target, bool pendok);
806 static uint8 dhdsdio_sleepcsr_get(dhd_bus_t *bus);
807 static bool dhdsdio_dpc(dhd_bus_t *bus);
808 static int dhd_bcmsdh_send_buffer(void *bus, uint8 *frame, uint16 len);
809 static int dhdsdio_set_sdmode(dhd_bus_t *bus, int32 sd_mode);
810 static int dhdsdio_sdclk(dhd_bus_t *bus, bool on);
815 static int read_more_btbytes(struct dhd_bus *bus, void * file, char *line, int * addr_mode,
817 static int dhdsdio_download_btfw(struct dhd_bus *bus, osl_t *osh, void *sdh);
818 static int _dhdsdio_download_btfw(struct dhd_bus *bus);
823 static int dhd_bus_ulp_reinit_fw(dhd_bus_t *bus);
827 dhdsdio_tune_fifoparam(struct dhd_bus *bus) in dhdsdio_tune_fifoparam() argument
832 if (bus->sih->buscorerev >= 15) { in dhdsdio_tune_fifoparam()
834 if (bus->blocksize == 512) { in dhdsdio_tune_fifoparam()
838 mes = bus->blocksize/4; in dhdsdio_tune_fifoparam()
839 wm = bus->blocksize/4; in dhdsdio_tune_fifoparam()
846 bus->sih->buscorerev)); in dhdsdio_tune_fifoparam()
852 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_WATERMARK, wm, &err); in dhdsdio_tune_fifoparam()
854 devctl = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); in dhdsdio_tune_fifoparam()
856 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err); in dhdsdio_tune_fifoparam()
861 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_MESBUSYCTRL, in dhdsdio_tune_fifoparam()
866 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err), in dhdsdio_tune_fifoparam()
867 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_WATERMARK, &err), in dhdsdio_tune_fifoparam()
868 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_MESBUSYCTRL, &err))); in dhdsdio_tune_fifoparam()
872 dhd_dongle_setramsize(struct dhd_bus *bus, int mem_size) in dhd_dongle_setramsize() argument
879 (dhd_dongle_ramsize < (int32)bus->orig_ramsize)) in dhd_dongle_setramsize()
880 bus->ramsize = dhd_dongle_ramsize; in dhd_dongle_setramsize()
884 dhdsdio_set_siaddr_window(dhd_bus_t *bus, uint32 address) in dhdsdio_set_siaddr_window() argument
887 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, in dhdsdio_set_siaddr_window()
890 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRMID, in dhdsdio_set_siaddr_window()
893 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRHIGH, in dhdsdio_set_siaddr_window()
900 dhdsdio_wkwlan(dhd_bus_t *bus, bool on) in dhdsdio_wkwlan() argument
904 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_wkwlan()
906 if (bus->sih->buscoretype == SDIOD_CORE_ID) { in dhdsdio_wkwlan()
923 dhdsdio_oobwakeup_init(dhd_bus_t *bus) in dhdsdio_oobwakeup_init() argument
927 bcmsdh_gpioouten(bus->sdh, GPIO_DEV_WAKEUP); in dhdsdio_oobwakeup_init()
929 addr = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_addr); in dhdsdio_oobwakeup_init()
930 data = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_data); in dhdsdio_oobwakeup_init()
933 bcmsdh_reg_write(bus->sdh, addr, 4, 2); in dhdsdio_oobwakeup_init()
934 val = bcmsdh_reg_read(bus->sdh, data, 4); in dhdsdio_oobwakeup_init()
936 bcmsdh_reg_write(bus->sdh, data, 4, val); in dhdsdio_oobwakeup_init()
938 bus->_oobwakeup = TRUE; in dhdsdio_oobwakeup_init()
948 dhdsdio_sr_cap(dhd_bus_t *bus) in dhdsdio_sr_cap() argument
954 if (si_findcoreidx(bus->sih, SR_CORE_ID, 0) != BADIDX) { in dhdsdio_sr_cap()
955 if (bus->sih->chip == CYW55500_CHIP_ID || in dhdsdio_sr_cap()
956 bus->sih->chip == CYW55560_CHIP_ID) { in dhdsdio_sr_cap()
961 if (bus->sih->chip == BCM43430_CHIP_ID || in dhdsdio_sr_cap()
962 bus->sih->chip == BCM43018_CHIP_ID) { in dhdsdio_sr_cap()
964 addr = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, sr_control1); in dhdsdio_sr_cap()
965 if (bcmsdh_reg_read(bus->sdh, addr, 4) != 0) in dhdsdio_sr_cap()
973 } else if ((bus->sih->chip == BCM4335_CHIP_ID) || in dhdsdio_sr_cap()
974 (bus->sih->chip == BCM4339_CHIP_ID) || in dhdsdio_sr_cap()
975 BCM4345_CHIP(bus->sih->chip) || in dhdsdio_sr_cap()
976 (bus->sih->chip == BCM4354_CHIP_ID) || in dhdsdio_sr_cap()
977 (bus->sih->chip == BCM4358_CHIP_ID) || in dhdsdio_sr_cap()
978 (BCM4349_CHIP(bus->sih->chip)) || in dhdsdio_sr_cap()
979 (bus->sih->chip == BCM4350_CHIP_ID) || in dhdsdio_sr_cap()
981 (bus->sih->chip == BCM4362_CHIP_ID) || in dhdsdio_sr_cap()
983 (bus->sih->chip == BCM43012_CHIP_ID) || in dhdsdio_sr_cap()
984 (bus->sih->chip == BCM43014_CHIP_ID) || in dhdsdio_sr_cap()
985 (bus->sih->chip == BCM43751_CHIP_ID) || in dhdsdio_sr_cap()
986 (bus->sih->chip == BCM4373_CHIP_ID)) { in dhdsdio_sr_cap()
989 core_capext = bcmsdh_reg_read(bus->sdh, in dhdsdio_sr_cap()
990 si_get_pmu_reg_addr(bus->sih, OFFSETOF(chipcregs_t, core_cap_ext)), in dhdsdio_sr_cap()
998 if ((bus->sih->chip == BCM4335_CHIP_ID) || in dhdsdio_sr_cap()
999 (bus->sih->chip == BCM4339_CHIP_ID) || in dhdsdio_sr_cap()
1000 BCM4345_CHIP(bus->sih->chip) || in dhdsdio_sr_cap()
1001 (bus->sih->chip == BCM4354_CHIP_ID) || in dhdsdio_sr_cap()
1002 (bus->sih->chip == BCM4358_CHIP_ID) || in dhdsdio_sr_cap()
1003 (bus->sih->chip == BCM4350_CHIP_ID)) { in dhdsdio_sr_cap()
1005 addr = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_addr); in dhdsdio_sr_cap()
1006 data = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_data); in dhdsdio_sr_cap()
1007 bcmsdh_reg_write(bus->sdh, addr, 4, CC_PMUCC3); in dhdsdio_sr_cap()
1008 enabval = bcmsdh_reg_read(bus->sdh, data, 4); in dhdsdio_sr_cap()
1010 if ((bus->sih->chip == BCM4350_CHIP_ID) || in dhdsdio_sr_cap()
1011 BCM4345_CHIP(bus->sih->chip) || in dhdsdio_sr_cap()
1012 (bus->sih->chip == BCM4354_CHIP_ID) || in dhdsdio_sr_cap()
1013 (bus->sih->chip == BCM4358_CHIP_ID)) in dhdsdio_sr_cap()
1019 data = bcmsdh_reg_read(bus->sdh, in dhdsdio_sr_cap()
1020 si_get_pmu_reg_addr(bus->sih, OFFSETOF(chipcregs_t, retention_ctl)), in dhdsdio_sr_cap()
1030 dhdsdio_sr_init(dhd_bus_t *bus) in dhdsdio_sr_init() argument
1035 if (bus->sih->chip == BCM43012_CHIP_ID || in dhdsdio_sr_init()
1036 bus->sih->chip == CYW55500_CHIP_ID || in dhdsdio_sr_init()
1037 bus->sih->chip == CYW55560_CHIP_ID) { in dhdsdio_sr_init()
1038 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, NULL); in dhdsdio_sr_init()
1040 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, in dhdsdio_sr_init()
1042 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, NULL); in dhdsdio_sr_init()
1044 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, NULL); in dhdsdio_sr_init()
1046 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, in dhdsdio_sr_init()
1048 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, NULL); in dhdsdio_sr_init()
1053 dhdsdio_devcap_set(bus, in dhdsdio_sr_init()
1057 if (CHIPID(bus->sih->chip) == BCM43430_CHIP_ID || in dhdsdio_sr_init()
1058 CHIPID(bus->sih->chip) == BCM43018_CHIP_ID || in dhdsdio_sr_init()
1059 CHIPID(bus->sih->chip) == BCM4339_CHIP_ID || in dhdsdio_sr_init()
1060 CHIPID(bus->sih->chip) == BCM43012_CHIP_ID || in dhdsdio_sr_init()
1061 CHIPID(bus->sih->chip) == CYW55500_CHIP_ID || in dhdsdio_sr_init()
1062 CHIPID(bus->sih->chip) == CYW55560_CHIP_ID || in dhdsdio_sr_init()
1064 CHIPID(bus->sih->chip) == BCM4362_CHIP_ID || in dhdsdio_sr_init()
1066 CHIPID(bus->sih->chip) == BCM43014_CHIP_ID || in dhdsdio_sr_init()
1067 CHIPID(bus->sih->chip) == BCM43751_CHIP_ID || in dhdsdio_sr_init()
1070 dhdsdio_wkwlan(bus, FALSE); in dhdsdio_sr_init()
1072 dhdsdio_devcap_set(bus, SDIOD_CCCR_BRCM_CARDCAP_CMD_NODEC); in dhdsdio_sr_init()
1075 if (bus->sih->chip == BCM43012_CHIP_ID || in dhdsdio_sr_init()
1076 bus->sih->chip == CYW55500_CHIP_ID || in dhdsdio_sr_init()
1077 bus->sih->chip == CYW55560_CHIP_ID) { in dhdsdio_sr_init()
1078 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, in dhdsdio_sr_init()
1081 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, in dhdsdio_sr_init()
1084 bus->_slpauto = dhd_slpauto ? TRUE : FALSE; in dhdsdio_sr_init()
1086 bus->_srenab = TRUE; in dhdsdio_sr_init()
1096 dhdsdio_clk_kso_init(dhd_bus_t *bus) in dhdsdio_clk_kso_init() argument
1102 bus->kso = TRUE; in dhdsdio_clk_kso_init()
1108 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, NULL); in dhdsdio_clk_kso_init()
1111 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, val, &err); in dhdsdio_clk_kso_init()
1132 dhdsdio_clk_kso_enab(dhd_bus_t *bus, bool on) in dhdsdio_clk_kso_enab() argument
1140 struct sdioh_info *sd = (struct sdioh_info *)(bus->sdh->sdioh); in dhdsdio_clk_kso_enab()
1165 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, wr_val, &err); in dhdsdio_clk_kso_enab()
1171 if ((!on) && (bus->sih->chip == BCM43012_CHIP_ID || in dhdsdio_clk_kso_enab()
1172 bus->sih->chip == CYW55500_CHIP_ID || in dhdsdio_clk_kso_enab()
1173 bus->sih->chip == CYW55560_CHIP_ID)) { in dhdsdio_clk_kso_enab()
1190 rd_val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, &err); in dhdsdio_clk_kso_enab()
1201 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, wr_val, &err); in dhdsdio_clk_kso_enab()
1233 dhdsdio_clk_kso_iovar(dhd_bus_t *bus, bool on) in dhdsdio_clk_kso_iovar() argument
1239 BUS_WAKE(bus); in dhdsdio_clk_kso_iovar()
1240 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_clk_kso_iovar()
1243 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_clk_kso_iovar()
1245 dhdsdio_clk_kso_enab(bus, FALSE); in dhdsdio_clk_kso_iovar()
1249 /* Make sure we have SD bus access */ in dhdsdio_clk_kso_iovar()
1250 if (bus->clkstate == CLK_NONE) { in dhdsdio_clk_kso_iovar()
1252 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhdsdio_clk_kso_iovar()
1255 dhdsdio_clk_kso_enab(bus, TRUE); in dhdsdio_clk_kso_iovar()
1258 dhdsdio_sleepcsr_get(bus))); in dhdsdio_clk_kso_iovar()
1261 bus->kso = on; in dhdsdio_clk_kso_iovar()
1268 dhdsdio_sleepcsr_get(dhd_bus_t *bus) in dhdsdio_sleepcsr_get() argument
1273 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, &err); in dhdsdio_sleepcsr_get()
1281 dhdsdio_devcap_get(dhd_bus_t *bus) in dhdsdio_devcap_get() argument
1283 return bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_BRCM_CARDCAP, NULL); in dhdsdio_devcap_get()
1287 dhdsdio_devcap_set(dhd_bus_t *bus, uint8 cap) in dhdsdio_devcap_set() argument
1291 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_BRCM_CARDCAP, cap, &err); in dhdsdio_devcap_set()
1299 dhdsdio_clk_devsleep_iovar(dhd_bus_t *bus, bool on) in dhdsdio_clk_devsleep_iovar() argument
1312 if (!SLPAUTO_ENAB(bus)) in dhdsdio_clk_devsleep_iovar()
1313 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_clk_devsleep_iovar()
1315 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); in dhdsdio_clk_devsleep_iovar()
1321 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, in dhdsdio_clk_devsleep_iovar()
1324 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_clk_devsleep_iovar()
1330 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_clk_devsleep_iovar()
1333 err = bcmsdh_sleep(bus->sdh, TRUE); in dhdsdio_clk_devsleep_iovar()
1335 if ((SLPAUTO_ENAB(bus)) && (bus->idleclock == DHD_IDLE_STOP)) { in dhdsdio_clk_devsleep_iovar()
1338 dhdsdio_set_sdmode(bus, 1); in dhdsdio_clk_devsleep_iovar()
1342 err = dhdsdio_clk_kso_enab(bus, FALSE); in dhdsdio_clk_devsleep_iovar()
1343 if (OOB_WAKEUP_ENAB(bus)) in dhdsdio_clk_devsleep_iovar()
1345 err = bcmsdh_gpioout(bus->sdh, GPIO_DEV_WAKEUP, FALSE); /* GPIO_1 is off */ in dhdsdio_clk_devsleep_iovar()
1349 if ((SLPAUTO_ENAB(bus)) && (bus->idleclock != DHD_IDLE_ACTIVE)) { in dhdsdio_clk_devsleep_iovar()
1352 err = dhdsdio_sdclk(bus, FALSE); in dhdsdio_clk_devsleep_iovar()
1356 /* Make sure we have SD bus access */ in dhdsdio_clk_devsleep_iovar()
1357 if (bus->clkstate == CLK_NONE) { in dhdsdio_clk_devsleep_iovar()
1359 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhdsdio_clk_devsleep_iovar()
1362 err = bcmsdh_sleep(bus->sdh, FALSE); in dhdsdio_clk_devsleep_iovar()
1363 if (SLPAUTO_ENAB(bus) && (err != 0)) { in dhdsdio_clk_devsleep_iovar()
1368 err = bcmsdh_sleep(bus->sdh, TRUE); in dhdsdio_clk_devsleep_iovar()
1370 err = bcmsdh_sleep(bus->sdh, FALSE); in dhdsdio_clk_devsleep_iovar()
1377 err = bcmsdh_sleep(bus->sdh, TRUE); in dhdsdio_clk_devsleep_iovar()
1379 err = bcmsdh_sleep(bus->sdh, FALSE); in dhdsdio_clk_devsleep_iovar()
1389 if (OOB_WAKEUP_ENAB(bus)) in dhdsdio_clk_devsleep_iovar()
1391 err = bcmsdh_gpioout(bus->sdh, GPIO_DEV_WAKEUP, TRUE); /* GPIO_1 is on */ in dhdsdio_clk_devsleep_iovar()
1394 err = dhdsdio_clk_kso_enab(bus, TRUE); in dhdsdio_clk_devsleep_iovar()
1406 if ((SLPAUTO_ENAB(bus)) && (bus->idleclock == DHD_IDLE_STOP)) { in dhdsdio_clk_devsleep_iovar()
1407 dhdsdio_set_sdmode(bus, bus->sd_mode); in dhdsdio_clk_devsleep_iovar()
1416 (((csr = dhdsdio_sleepcsr_get(bus)) & in dhdsdio_clk_devsleep_iovar()
1429 (((csr = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_clk_devsleep_iovar()
1444 bus->kso = on ? FALSE : TRUE; in dhdsdio_clk_devsleep_iovar()
1447 __FUNCTION__, bus->kso, on, err)); in dhdsdio_clk_devsleep_iovar()
1449 bus->kso = FALSE; in dhdsdio_clk_devsleep_iovar()
1457 dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok) in dhdsdio_htclk() argument
1468 sdh = bus->sdh; in dhdsdio_htclk()
1470 if (!KSO_ENAB(bus)) in dhdsdio_htclk()
1473 if (SLPAUTO_ENAB(bus)) { in dhdsdio_htclk()
1474 bus->clkstate = (on ? CLK_AVAIL : CLK_SDONLY); in dhdsdio_htclk()
1480 clkreq = bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ; in dhdsdio_htclk()
1483 dhdsdio_wkwlan(bus, TRUE); in dhdsdio_htclk()
1495 bus->dhd->hang_reason = HANG_REASON_HT_AVAIL_ERROR; in dhdsdio_htclk()
1496 dhd_os_send_hang_message(bus->dhd); in dhdsdio_htclk()
1513 if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) { in dhdsdio_htclk()
1525 bus->clkstate = CLK_PENDING; in dhdsdio_htclk()
1530 if (bus->clkstate == CLK_PENDING) { in dhdsdio_htclk()
1539 if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { in dhdsdio_htclk()
1543 !SBSDIO_CLKAV(clkctl, bus->alp_only)), PMU_MAX_TRANSITION_DLY); in dhdsdio_htclk()
1549 if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { in dhdsdio_htclk()
1556 bus->clkstate = CLK_AVAIL; in dhdsdio_htclk()
1560 if (bus->alp_only == TRUE) { in dhdsdio_htclk()
1573 bus->activity = TRUE; in dhdsdio_htclk()
1575 bus->idlecount = 0; in dhdsdio_htclk()
1580 if (bus->clkstate == CLK_PENDING) { in dhdsdio_htclk()
1587 bus->clkstate = CLK_SDONLY; in dhdsdio_htclk()
1588 if (!SR_ENAB(bus)) { in dhdsdio_htclk()
1598 dhdsdio_wkwlan(bus, FALSE); in dhdsdio_htclk()
1604 /* Change SD1/SD4 bus mode */
1606 dhdsdio_set_sdmode(dhd_bus_t *bus, int32 sd_mode) in dhdsdio_set_sdmode() argument
1610 err = bcmsdh_iovar_op(bus->sdh, "sd_mode", NULL, 0, in dhdsdio_set_sdmode()
1622 dhdsdio_sdclk(dhd_bus_t *bus, bool on) in dhdsdio_sdclk() argument
1631 if (bus->idleclock == DHD_IDLE_STOP) { in dhdsdio_sdclk()
1634 err = bcmsdh_iovar_op(bus->sdh, "sd_clock", NULL, 0, in dhdsdio_sdclk()
1642 } else if (bus->idleclock != DHD_IDLE_ACTIVE) { in dhdsdio_sdclk()
1644 iovalue = bus->sd_divisor; in dhdsdio_sdclk()
1645 err = bcmsdh_iovar_op(bus->sdh, "sd_divisor", NULL, 0, in dhdsdio_sdclk()
1653 bus->clkstate = CLK_SDONLY; in dhdsdio_sdclk()
1656 if ((bus->sd_divisor == -1) || (bus->sd_mode == -1)) { in dhdsdio_sdclk()
1658 __FUNCTION__, bus->sd_divisor, bus->sd_mode)); in dhdsdio_sdclk()
1661 if (bus->idleclock == DHD_IDLE_STOP) { in dhdsdio_sdclk()
1663 err = bcmsdh_iovar_op(bus->sdh, "sd_clock", NULL, 0, in dhdsdio_sdclk()
1670 } else if (bus->idleclock != DHD_IDLE_ACTIVE) { in dhdsdio_sdclk()
1672 iovalue = bus->idleclock; in dhdsdio_sdclk()
1673 err = bcmsdh_iovar_op(bus->sdh, "sd_divisor", NULL, 0, in dhdsdio_sdclk()
1681 bus->clkstate = CLK_NONE; in dhdsdio_sdclk()
1691 dhdsdio_clkctl(dhd_bus_t *bus, uint target, bool pendok) in dhdsdio_clkctl() argument
1695 uint oldstate = bus->clkstate; in dhdsdio_clkctl()
1701 if (bus->clkstate == target) { in dhdsdio_clkctl()
1703 dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms); in dhdsdio_clkctl()
1704 bus->activity = TRUE; in dhdsdio_clkctl()
1706 bus->idlecount = 0; in dhdsdio_clkctl()
1715 if (bus->clkstate == CLK_NONE) in dhdsdio_clkctl()
1716 dhdsdio_sdclk(bus, TRUE); in dhdsdio_clkctl()
1718 ret = dhdsdio_htclk(bus, TRUE, pendok); in dhdsdio_clkctl()
1720 dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms); in dhdsdio_clkctl()
1721 bus->activity = TRUE; in dhdsdio_clkctl()
1723 bus->idlecount = 0; in dhdsdio_clkctl()
1736 * nothing is to be done & Bt has finished using the bus. in dhdsdio_clkctl()
1738 if (bus->bt_use_count != 0) { in dhdsdio_clkctl()
1740 __FUNCTION__, bus->bt_use_count)); in dhdsdio_clkctl()
1742 dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms); in dhdsdio_clkctl()
1751 if (bus->clkstate == CLK_NONE) in dhdsdio_clkctl()
1752 ret = dhdsdio_sdclk(bus, TRUE); in dhdsdio_clkctl()
1753 else if (bus->clkstate == CLK_AVAIL) in dhdsdio_clkctl()
1754 ret = dhdsdio_htclk(bus, FALSE, FALSE); in dhdsdio_clkctl()
1757 bus->clkstate, target)); in dhdsdio_clkctl()
1759 dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms); in dhdsdio_clkctl()
1771 * nothing is to be done & Bt has finished using the bus. in dhdsdio_clkctl()
1773 if (bus->bt_use_count != 0) { in dhdsdio_clkctl()
1775 __FUNCTION__, bus->bt_use_count)); in dhdsdio_clkctl()
1785 if (bus->clkstate == CLK_AVAIL) in dhdsdio_clkctl()
1786 ret = dhdsdio_htclk(bus, FALSE, FALSE); in dhdsdio_clkctl()
1788 ret = dhdsdio_sdclk(bus, FALSE); in dhdsdio_clkctl()
1790 if (bus->dhd->dhd_console_ms == 0) in dhdsdio_clkctl()
1792 if (bus->poll == 0) in dhdsdio_clkctl()
1793 dhd_os_wd_timer(bus->dhd, 0); in dhdsdio_clkctl()
1797 DHD_INFO(("dhdsdio_clkctl: %d -> %d\n", oldstate, bus->clkstate)); in dhdsdio_clkctl()
1804 dhdsdio_bussleep(dhd_bus_t *bus, bool sleep) in dhdsdio_bussleep() argument
1807 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_bussleep()
1808 sdpcmd_regs_t *regs = bus->regs; in dhdsdio_bussleep()
1816 (bus->sleeping ? "SLEEP" : "WAKE"))); in dhdsdio_bussleep()
1818 if (bus->dhd->hang_was_sent) in dhdsdio_bussleep()
1822 if (sleep == bus->sleeping) in dhdsdio_bussleep()
1829 if (bus->dpc_sched || bus->rxskip || pktq_n_pkts_tot(&bus->txq) || in dhdsdio_bussleep()
1830 bus->readframes || bus->ctrl_frame_stat) in dhdsdio_bussleep()
1832 if (bus->dpc_sched || bus->rxskip || pktq_n_pkts_tot(&bus->txq)) in dhdsdio_bussleep()
1841 * actively using the bus, we will return BCME_BUSY from here, but the bus->sleeping in dhdsdio_bussleep()
1850 if (bus->bt_use_count != 0) { in dhdsdio_bussleep()
1856 if (!SLPAUTO_ENAB(bus)) { in dhdsdio_bussleep()
1858 bcmsdh_intr_disable(bus->sdh); in dhdsdio_bussleep()
1860 /* Make sure the controller has the bus up */ in dhdsdio_bussleep()
1861 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_bussleep()
1869 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhdsdio_bussleep()
1874 /* Isolate the bus */ in dhdsdio_bussleep()
1881 err = dhdsdio_clk_devsleep_iovar(bus, TRUE /* sleep */); in dhdsdio_bussleep()
1885 bus->sleeping = TRUE; in dhdsdio_bussleep()
1888 err = bcmsdh_iovar_op(bus->sdh, "sd3_tuning_disable", NULL, 0, in dhdsdio_bussleep()
1892 wake_up(&bus->bus_sleep); in dhdsdio_bussleep()
1895 /* Waking up: bus power up is ok, set local state */ in dhdsdio_bussleep()
1897 if (!SLPAUTO_ENAB(bus)) { in dhdsdio_bussleep()
1903 /* Make sure the controller has the bus up */ in dhdsdio_bussleep()
1904 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_bussleep()
1914 /* Make sure we have SD bus access */ in dhdsdio_bussleep()
1915 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhdsdio_bussleep()
1918 if (bus->intr && (bus->dhd->busstate == DHD_BUS_DATA)) { in dhdsdio_bussleep()
1919 bus->intdis = FALSE; in dhdsdio_bussleep()
1920 bcmsdh_intr_enable(bus->sdh); in dhdsdio_bussleep()
1923 err = dhdsdio_clk_devsleep_iovar(bus, FALSE /* wake */); in dhdsdio_bussleep()
1927 dhd_pub_t *dhd = bus->dhd; in dhdsdio_bussleep()
1943 bus->sleeping = FALSE; in dhdsdio_bussleep()
1946 err = bcmsdh_iovar_op(bus->sdh, "sd3_tuning_disable", NULL, 0, in dhdsdio_bussleep()
1959 * bus - Pointer to the dhd_bus handle
1963 int __dhdsdio_clk_enable(struct dhd_bus *bus, bus_owner_t owner, int can_wait) in __dhdsdio_clk_enable() argument
1969 bus->bt_use_count++; in __dhdsdio_clk_enable()
1977 BUS_WAKE(bus); in __dhdsdio_clk_enable()
1983 ret = dhdsdio_clkctl(bus, CLK_AVAIL, can_wait); in __dhdsdio_clk_enable()
1986 bus->bt_use_count)); in __dhdsdio_clk_enable()
1993 * bus - Pointer to the dhd_bus handle
1997 int __dhdsdio_clk_disable(struct dhd_bus *bus, bus_owner_t owner, int can_wait) in __dhdsdio_clk_disable() argument
2004 if (bus->bt_use_count == 0) { in __dhdsdio_clk_disable()
2010 bus->bt_use_count--; in __dhdsdio_clk_disable()
2013 * When the SDIO Bus is shared between BT & WLAN, we turn Off the clock in __dhdsdio_clk_disable()
2015 * in that too. We consider WLAN as the bus master (even if its not in __dhdsdio_clk_disable()
2017 * So this Bus Watchdog is the context whill put the Bus to sleep. in __dhdsdio_clk_disable()
2023 bus->bt_use_count)); in __dhdsdio_clk_disable()
2027 void dhdsdio_reset_bt_use_count(struct dhd_bus *bus) in dhdsdio_reset_bt_use_count() argument
2030 bus->bt_use_count = 0; in dhdsdio_reset_bt_use_count()
2067 dhd_enable_oob_intr(struct dhd_bus *bus, bool enable) in dhd_enable_oob_intr() argument
2070 bcmsdh_intr_enable(bus->sdh); in dhd_enable_oob_intr()
2072 bcmsdh_enable_hw_oob_intr(bus->sdh, enable); in dhd_enable_oob_intr()
2074 sdpcmd_regs_t *regs = bus->regs; in dhd_enable_oob_intr()
2077 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_enable_oob_intr()
2093 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhd_enable_oob_intr()
2099 dhd_bus_txdata(struct dhd_bus *bus, void *pkt) in dhd_bus_txdata() argument
2113 osh = bus->dhd->osh; in dhd_bus_txdata()
2118 if (bus->ext_loop) { in dhd_bus_txdata()
2123 *data++ = (uint8)bus->loopid++; in dhd_bus_txdata()
2133 dhd_ulp_set_path(bus->dhd, DHD_ULP_TX_DATA); in dhd_bus_txdata()
2155 if (bus->dhd->aifsn_reverse) { in dhd_bus_txdata()
2166 if (dhd_deferred_tx || bus->fcstate || pktq_n_pkts_tot(&bus->txq) || bus->dpc_sched || in dhd_bus_txdata()
2167 (!DATAOK(bus)) || (bus->flowcontrol & NBITVAL(prec)) || in dhd_bus_txdata()
2168 (bus->clkstate != CLK_AVAIL)) { in dhd_bus_txdata()
2173 pktq_n_pkts_tot(&bus->txq))); in dhd_bus_txdata()
2174 bus->fcqueued++; in dhd_bus_txdata()
2177 dhd_os_sdlock_txq(bus->dhd); in dhd_bus_txdata()
2178 deq_ret = dhd_prec_enq(bus->dhd, &bus->txq, pkt, prec); in dhd_bus_txdata()
2179 dhd_os_sdunlock_txq(bus->dhd); in dhd_bus_txdata()
2187 if (dhd_tcpack_check_xmit(bus->dhd, pkt) == BCME_ERROR) { in dhd_bus_txdata()
2190 dhd_tcpack_suppress_set(bus->dhd, TCPACK_SUP_OFF); in dhd_bus_txdata()
2193 dhd_txcomplete(bus->dhd, pkt, FALSE); in dhd_bus_txdata()
2200 dhd_os_sdlock_txq(bus->dhd); in dhd_bus_txdata()
2201 pkq_len = pktq_n_pkts_tot(&bus->txq); in dhd_bus_txdata()
2202 dhd_os_sdunlock_txq(bus->dhd); in dhd_bus_txdata()
2206 wlfc_enabled = (dhd_wlfc_flowcontrol(bus->dhd, ON, FALSE) != in dhd_bus_txdata()
2210 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, ON); in dhd_bus_txdata()
2215 dhd_os_sdlock_txq(bus->dhd); in dhd_bus_txdata()
2216 if (pktqprec_n_pkts(&bus->txq, prec) > qcount[prec]) in dhd_bus_txdata()
2217 qcount[prec] = pktqprec_n_pkts(&bus->txq, prec); in dhd_bus_txdata()
2218 dhd_os_sdunlock_txq(bus->dhd); in dhd_bus_txdata()
2222 if (dhd_deferred_tx && !bus->dpc_sched) { in dhd_bus_txdata()
2223 bus->dpc_sched = TRUE; in dhd_bus_txdata()
2224 dhd_sched_dpc(bus->dhd); in dhd_bus_txdata()
2230 chan = (bus->ext_loop ? SDPCM_TEST_CHANNEL : SDPCM_DATA_CHANNEL); in dhd_bus_txdata()
2233 dhd_os_sdlock(bus->dhd); in dhd_bus_txdata()
2236 BUS_WAKE(bus); in dhd_bus_txdata()
2238 dhdsdio_clkctl(bus, CLK_AVAIL, TRUE); in dhd_bus_txdata()
2240 ret = dhdsdio_txpkt(bus, chan, &pkt, 1, TRUE); in dhd_bus_txdata()
2243 bus->dhd->tx_errors++; in dhd_bus_txdata()
2245 bus->dhd->dstats.tx_bytes += datalen; in dhd_bus_txdata()
2247 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhd_bus_txdata()
2248 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhd_bus_txdata()
2249 bus->activity = FALSE; in dhd_bus_txdata()
2250 dhdsdio_bussleep(bus, TRUE); in dhd_bus_txdata()
2251 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_txdata()
2254 dhd_os_sdunlock(bus->dhd); in dhd_bus_txdata()
2274 static int dhdsdio_txpkt_preprocess(dhd_bus_t *bus, void *pkt, int chan, int txseq, in dhdsdio_txpkt_preprocess() argument
2287 uint8 sdpcm_hdrlen = bus->txglom_enable ? SDPCM_HDRLEN_TXGLOM : SDPCM_HDRLEN; in dhdsdio_txpkt_preprocess()
2290 osh = bus->dhd->osh; in dhdsdio_txpkt_preprocess()
2293 if (dhd_tcpack_check_xmit(bus->dhd, pkt) == BCME_ERROR) { in dhdsdio_txpkt_preprocess()
2296 dhd_tcpack_suppress_set(bus->dhd, TCPACK_SUP_OFF); in dhdsdio_txpkt_preprocess()
2340 if (last_chained_pkt && bus->blocksize != 0 && in dhdsdio_txpkt_preprocess()
2341 (cur_chain_total_len > (int)bus->blocksize || prev_chain_total_len > 0)) { in dhdsdio_txpkt_preprocess()
2342 modulo = cur_chain_total_len % bus->blocksize; in dhdsdio_txpkt_preprocess()
2343 chain_tail_padding = modulo > 0 ? (bus->blocksize - modulo) : 0; in dhdsdio_txpkt_preprocess()
2350 bus->tx_tailpad_pktget++; in dhdsdio_txpkt_preprocess()
2357 if (bus->pad_pkt) { in dhdsdio_txpkt_preprocess()
2359 bus->tx_tailpad_chain++; in dhdsdio_txpkt_preprocess()
2362 bus->tx_tailpad_pktget++; in dhdsdio_txpkt_preprocess()
2393 if (last_chained_pkt && bus->blocksize != 0 && in dhdsdio_txpkt_preprocess()
2394 (cur_total_len > (int)bus->blocksize || prev_chain_total_len > 0)) { in dhdsdio_txpkt_preprocess()
2395 modulo = cur_total_len % bus->blocksize; in dhdsdio_txpkt_preprocess()
2396 tail_padding = modulo > 0 ? (bus->blocksize - modulo) : 0; in dhdsdio_txpkt_preprocess()
2402 newpkt_size = PKTLEN(osh, pkt) + bus->blocksize + DHD_SDALIGN; in dhdsdio_txpkt_preprocess()
2403 bus->dhd->tx_realloc++; in dhdsdio_txpkt_preprocess()
2454 if (bus->txglom_enable) { in dhdsdio_txpkt_preprocess()
2477 static int dhdsdio_txpkt_postprocess(dhd_bus_t *bus, void *pkt) in dhdsdio_txpkt_postprocess() argument
2483 int swhdr_offset = SDPCM_FRAMETAG_LEN + (bus->txglom_enable ? SDPCM_HWEXT_LEN : 0); in dhdsdio_txpkt_postprocess()
2486 osh = bus->dhd->osh; in dhdsdio_txpkt_postprocess()
2497 if (bus->txglom_enable) { in dhdsdio_txpkt_postprocess()
2524 static int dhdsdio_txpkt(dhd_bus_t *bus, uint chan, void** pkts, int num_pkt, bool free_pkt) in dhdsdio_txpkt() argument
2540 if (bus->dhd->dongle_reset) in dhdsdio_txpkt()
2546 sdh = bus->sdh; in dhdsdio_txpkt()
2547 osh = bus->dhd->osh; in dhdsdio_txpkt()
2559 pkt_len = dhdsdio_txpkt_preprocess(bus, pkt, chan, bus->tx_seq + i, in dhdsdio_txpkt()
2577 if (bus->txglom_enable) { in dhdsdio_txpkt()
2590 PKTSETLEN(osh, bus->pad_pkt, pad_pkt_len); in dhdsdio_txpkt()
2591 PKTSETNEXT(osh, pkt, bus->pad_pkt); in dhdsdio_txpkt()
2600 ret = dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC, in dhdsdio_txpkt()
2603 bus->tx_seq = (bus->tx_seq + num_pkt) % SDPCM_SEQUENCE_WRAP; in dhdsdio_txpkt()
2614 dhdsdio_txpkt_postprocess(bus, pkt); in dhdsdio_txpkt()
2626 wlfc_enabled = (dhd_wlfc_txcomplete(bus->dhd, pkt, ret == 0) != in dhdsdio_txpkt()
2632 dhd_txcomplete(bus->dhd, pkt, ret != 0); in dhdsdio_txpkt()
2645 dhdsdio_sendfromq(dhd_bus_t *bus, uint maxframes) in dhdsdio_sendfromq() argument
2654 dhd_pub_t *dhd = bus->dhd; in dhdsdio_sendfromq()
2655 sdpcmd_regs_t *regs = bus->regs; in dhdsdio_sendfromq()
2667 if (!KSO_ENAB(bus)) { in dhdsdio_sendfromq()
2673 tx_prec_map = ~bus->flowcontrol; in dhdsdio_sendfromq()
2677 for (cnt = 0; (cnt < maxframes) && DATAOK(bus);) { in dhdsdio_sendfromq()
2683 dhd_os_sdlock_txq(bus->dhd); in dhdsdio_sendfromq()
2684 if (bus->txglom_enable) { in dhdsdio_sendfromq()
2685 uint32 glomlimit = (uint32)bus->txglomsize; in dhdsdio_sendfromq()
2687 if (bus->blocksize == 64) { in dhdsdio_sendfromq()
2688 glomlimit = MIN((uint32)bus->txglomsize, BLK_64_MAXTXGLOM); in dhdsdio_sendfromq()
2691 num_pkt = MIN((uint32)DATABUFCNT(bus), glomlimit); in dhdsdio_sendfromq()
2694 num_pkt = MIN(num_pkt, pktq_mlen(&bus->txq, tx_prec_map)); in dhdsdio_sendfromq()
2696 pkts[i] = pktq_mdeq(&bus->txq, tx_prec_map, &prec_out); in dhdsdio_sendfromq()
2729 dhd_os_sdunlock_txq(bus->dhd); in dhdsdio_sendfromq()
2733 if (dhdsdio_txpkt(bus, SDPCM_DATA_CHANNEL, pkts, i, TRUE) != BCME_OK) in dhdsdio_sendfromq()
2740 if (!bus->intr && cnt) in dhdsdio_sendfromq()
2744 bus->f2txdata++; in dhdsdio_sendfromq()
2745 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_sendfromq()
2747 if (intstatus & bus->hostintmask) in dhdsdio_sendfromq()
2748 bus->ipend = TRUE; in dhdsdio_sendfromq()
2753 dhd_os_sdlock_txq(bus->dhd); in dhdsdio_sendfromq()
2754 txpktqlen = pktq_n_pkts_tot(&bus->txq); in dhdsdio_sendfromq()
2755 dhd_os_sdunlock_txq(bus->dhd); in dhdsdio_sendfromq()
2772 dhdsdio_sendpendctl(dhd_bus_t *bus) in dhdsdio_sendpendctl() argument
2774 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_sendpendctl()
2776 uint8* frame_seq = bus->ctrl_frame_buf + SDPCM_FRAMETAG_LEN; in dhdsdio_sendpendctl()
2778 if (bus->txglom_enable) in dhdsdio_sendpendctl()
2781 if (*frame_seq != bus->tx_seq) { in dhdsdio_sendpendctl()
2783 " frm_seq:%d != bus->tx_seq:%d, corrected\n", in dhdsdio_sendpendctl()
2784 __FUNCTION__, *frame_seq, bus->tx_seq)); in dhdsdio_sendpendctl()
2785 *frame_seq = bus->tx_seq; in dhdsdio_sendpendctl()
2788 ret = dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC, in dhdsdio_sendpendctl()
2789 (uint8 *)bus->ctrl_frame_buf, (uint32)bus->ctrl_frame_len, in dhdsdio_sendpendctl()
2792 bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; in dhdsdio_sendpendctl()
2794 bus->ctrl_frame_stat = FALSE; in dhdsdio_sendpendctl()
2795 dhd_wait_event_wakeup(bus->dhd); in dhdsdio_sendpendctl()
2799 dhd_bus_txctl(struct dhd_bus *bus, uchar *msg, uint msglen) in dhd_bus_txctl() argument
2807 uint8 sdpcm_hdrlen = bus->txglom_enable ? SDPCM_HDRLEN_TXGLOM : SDPCM_HDRLEN; in dhd_bus_txctl()
2811 if (bus->dhd->dongle_reset) in dhd_bus_txctl()
2814 /* Back the pointer to make a room for bus header */ in dhd_bus_txctl()
2832 if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { in dhd_bus_txctl()
2833 uint16 pad = bus->blocksize - (len % bus->blocksize); in dhd_bus_txctl()
2834 if ((pad <= bus->roundup) && (pad < bus->blocksize)) in dhd_bus_txctl()
2848 dhd_os_sdlock(bus->dhd); in dhd_bus_txctl()
2850 BUS_WAKE(bus); in dhd_bus_txctl()
2853 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_txctl()
2859 if (bus->txglom_enable) { in dhd_bus_txctl()
2863 | bus->tx_seq in dhd_bus_txctl()
2879 | bus->tx_seq | ((doff << SDPCM_DOFFSET_SHIFT) & SDPCM_DOFFSET_MASK); in dhd_bus_txctl()
2885 dhd_ulp_set_path(bus->dhd, DHD_ULP_TX_CTRL); in dhd_bus_txctl()
2887 if (!TXCTLOK(bus) || !dhd_ulp_f2_ready(bus->dhd, bus->sdh)) in dhd_bus_txctl()
2889 if (!TXCTLOK(bus)) in dhd_bus_txctl()
2892 DHD_INFO(("%s: No bus credit bus->tx_max %d, bus->tx_seq %d\n", in dhd_bus_txctl()
2893 __FUNCTION__, bus->tx_max, bus->tx_seq)); in dhd_bus_txctl()
2894 bus->ctrl_frame_stat = TRUE; in dhd_bus_txctl()
2896 bus->ctrl_frame_buf = frame; in dhd_bus_txctl()
2897 bus->ctrl_frame_len = len; in dhd_bus_txctl()
2899 if (!bus->dpc_sched) { in dhd_bus_txctl()
2900 bus->dpc_sched = TRUE; in dhd_bus_txctl()
2901 dhd_sched_dpc(bus->dhd); in dhd_bus_txctl()
2903 if (bus->ctrl_frame_stat) { in dhd_bus_txctl()
2904 dhd_wait_for_event(bus->dhd, &bus->ctrl_frame_stat); in dhd_bus_txctl()
2907 if (bus->ctrl_frame_stat == FALSE) { in dhd_bus_txctl()
2911 bus->dhd->txcnt_timeout++; in dhd_bus_txctl()
2912 if (!bus->dhd->hang_was_sent) { in dhd_bus_txctl()
2915 R_SDREG(status, &bus->regs->intstatus, retry); in dhd_bus_txctl()
2919 __FUNCTION__, bus->tx_max, bus->tx_seq, bus->clkstate)); in dhd_bus_txctl()
2922 __FUNCTION__, bus->dhd->txcnt_timeout)); in dhd_bus_txctl()
2926 if ((bus->dhd->memdump_enabled) && in dhd_bus_txctl()
2927 (bus->dhd->txcnt_timeout >= MAX_CNTL_TX_TIMEOUT)) { in dhd_bus_txctl()
2929 bus->dhd->memdump_type = DUMP_TYPE_RESUMED_ON_TIMEOUT_TX; in dhd_bus_txctl()
2930 dhd_os_sdunlock(bus->dhd); in dhd_bus_txctl()
2931 dhd_bus_mem_dump(bus->dhd); in dhd_bus_txctl()
2932 dhd_os_sdlock(bus->dhd); in dhd_bus_txctl()
2936 bus->ctrl_frame_stat = FALSE; in dhd_bus_txctl()
2941 bus->dhd->txcnt_timeout = 0; in dhd_bus_txctl()
2942 bus->ctrl_frame_stat = TRUE; in dhd_bus_txctl()
2952 ret = dhd_bcmsdh_send_buffer(bus, frame, len); in dhd_bus_txctl()
2954 bus->ctrl_frame_stat = FALSE; in dhd_bus_txctl()
2956 dhd_ulp_enable_cached_sbwad(bus->dhd, bus->sdh); in dhd_bus_txctl()
2960 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhd_bus_txctl()
2961 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhd_bus_txctl()
2962 bus->activity = FALSE; in dhd_bus_txctl()
2963 dhdsdio_bussleep(bus, TRUE); in dhd_bus_txctl()
2964 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_txctl()
2967 dhd_os_sdunlock(bus->dhd); in dhd_bus_txctl()
2970 bus->dhd->tx_ctlerrs++; in dhd_bus_txctl()
2972 bus->dhd->tx_ctlpkts++; in dhd_bus_txctl()
2974 if (bus->dhd->txcnt_timeout >= MAX_CNTL_TX_TIMEOUT) { in dhd_bus_txctl()
2994 dhd_bus_rxctl(struct dhd_bus *bus, uchar *msg, uint msglen) in dhd_bus_rxctl() argument
3001 if (bus->dhd->dongle_reset) in dhd_bus_rxctl()
3005 timeleft = dhd_os_ioctl_resp_wait(bus->dhd, &bus->rxlen); in dhd_bus_rxctl()
3007 dhd_os_sdlock(bus->dhd); in dhd_bus_rxctl()
3008 rxlen = bus->rxlen; in dhd_bus_rxctl()
3009 bcopy(bus->rxctl, msg, MIN(msglen, rxlen)); in dhd_bus_rxctl()
3010 bus->rxlen = 0; in dhd_bus_rxctl()
3011 dhd_os_sdunlock(bus->dhd); in dhd_bus_rxctl()
3020 R_SDREG(status, &bus->regs->intstatus, retry); in dhd_bus_rxctl()
3026 if (!bus->dhd->dongle_trap_occured) { in dhd_bus_rxctl()
3028 bus->dhd->memdump_type = DUMP_TYPE_RESUMED_ON_TIMEOUT; in dhd_bus_rxctl()
3030 dhd_os_sdlock(bus->dhd); in dhd_bus_rxctl()
3031 dhdsdio_checkdied(bus, NULL, 0); in dhd_bus_rxctl()
3032 dhd_os_sdunlock(bus->dhd); in dhd_bus_rxctl()
3036 if (!bus->dhd->dongle_trap_occured) { in dhd_bus_rxctl()
3038 bus->dhd->memdump_type = DUMP_TYPE_RESUMED_UNKNOWN; in dhd_bus_rxctl()
3040 dhd_os_sdlock(bus->dhd); in dhd_bus_rxctl()
3041 dhdsdio_checkdied(bus, NULL, 0); in dhd_bus_rxctl()
3042 dhd_os_sdunlock(bus->dhd); in dhd_bus_rxctl()
3047 if (bus->dhd->memdump_enabled && !bus->dhd->dongle_trap_occured) in dhd_bus_rxctl()
3048 dhdsdio_mem_dump(bus); in dhd_bus_rxctl()
3053 bus->dhd->rxcnt_timeout++; in dhd_bus_rxctl()
3055 bus->dhd->rxcnt_timeout, rxlen)); in dhd_bus_rxctl()
3058 if (bus->dhd->memdump_enabled) { in dhd_bus_rxctl()
3059 bus->dhd->memdump_type = DUMP_TYPE_RESUMED_ON_TIMEOUT_RX; in dhd_bus_rxctl()
3060 dhd_bus_mem_dump(bus->dhd); in dhd_bus_rxctl()
3064 bus->dhd->rxcnt_timeout = 0; in dhd_bus_rxctl()
3068 bus->dhd->rx_ctlpkts++; in dhd_bus_rxctl()
3070 bus->dhd->rx_ctlerrs++; in dhd_bus_rxctl()
3072 if (bus->dhd->rxcnt_timeout >= MAX_CNTL_RX_TIMEOUT) { in dhd_bus_rxctl()
3083 if (bus->dhd->dongle_trap_occured) in dhd_bus_rxctl()
3226 dhd_bus_t *bus = dhdp->bus; in dhd_bus_dump() local
3231 bcm_bprintf(strbuf, "Bus SDIO structure:\n"); in dhd_bus_dump()
3233 bus->hostintmask, bus->intstatus, bus->sdpcm_ver); in dhd_bus_dump()
3235 bus->fcstate, pktq_n_pkts_tot(&bus->txq), bus->tx_seq, bus->tx_max, bus->rxskip, in dhd_bus_dump()
3236 bus->rxlen, bus->rx_seq); in dhd_bus_dump()
3238 bus->intr, bus->intrcount, bus->lastintrs, bus->spurious); in dhd_bus_dump()
3242 bcmsdh_get_total_wake(bus->sdh), bus->wake_counts.rxwake, in dhd_bus_dump()
3243 bus->wake_counts.rcwake); in dhd_bus_dump()
3246 bus->wake_counts.rx_ucast, bus->wake_counts.rx_mcast, in dhd_bus_dump()
3247 bus->wake_counts.rx_bcast, bus->wake_counts.rx_arp); in dhd_bus_dump()
3249 bus->wake_counts.rx_multi_ipv4, bus->wake_counts.rx_multi_ipv6, in dhd_bus_dump()
3250 bus->wake_counts.rx_icmpv6, bus->wake_counts.rx_multi_other); in dhd_bus_dump()
3252 bus->wake_counts.rx_icmpv6_ra, bus->wake_counts.rx_icmpv6_na, in dhd_bus_dump()
3253 bus->wake_counts.rx_icmpv6_ns); in dhd_bus_dump()
3257 if (bus->wake_counts.rc_event[i] != 0) in dhd_bus_dump()
3259 bus->wake_counts.rc_event[i]); in dhd_bus_dump()
3265 bus->pollrate, bus->pollcnt, bus->regfails); in dhd_bus_dump()
3270 bus->tx_tailpad_chain, bus->tx_tailpad_pktget); in dhd_bus_dump()
3273 bus->tx_sderrs, bus->fcqueued, bus->rxrtx, bus->rx_toolong, in dhd_bus_dump()
3274 bus->rxc_errors); in dhd_bus_dump()
3276 bus->rx_hdrfail, bus->rx_badhdr, bus->rx_badseq); in dhd_bus_dump()
3278 bus->fc_rcvd, bus->fc_xoff, bus->fc_xon); in dhd_bus_dump()
3280 bus->rxglomfail, bus->rxglomframes, bus->rxglompkts); in dhd_bus_dump()
3282 (bus->f2rxhdrs + bus->f2rxdata), bus->f2rxhdrs, bus->f2rxdata, in dhd_bus_dump()
3283 bus->f2txdata, bus->f1regdata); in dhd_bus_dump()
3285 dhd_dump_pct(strbuf, "\nRx: pkts/f2rd", bus->dhd->rx_packets, in dhd_bus_dump()
3286 (bus->f2rxhdrs + bus->f2rxdata)); in dhd_bus_dump()
3287 dhd_dump_pct(strbuf, ", pkts/f1sd", bus->dhd->rx_packets, bus->f1regdata); in dhd_bus_dump()
3288 dhd_dump_pct(strbuf, ", pkts/sd", bus->dhd->rx_packets, in dhd_bus_dump()
3289 (bus->f2rxhdrs + bus->f2rxdata + bus->f1regdata)); in dhd_bus_dump()
3290 dhd_dump_pct(strbuf, ", pkts/int", bus->dhd->rx_packets, bus->intrcount); in dhd_bus_dump()
3293 dhd_dump_pct(strbuf, "Rx: glom pct", (100 * bus->rxglompkts), in dhd_bus_dump()
3294 bus->dhd->rx_packets); in dhd_bus_dump()
3295 dhd_dump_pct(strbuf, ", pkts/glom", bus->rxglompkts, bus->rxglomframes); in dhd_bus_dump()
3298 dhd_dump_pct(strbuf, "Tx: pkts/f2wr", bus->dhd->tx_packets, bus->f2txdata); in dhd_bus_dump()
3299 dhd_dump_pct(strbuf, ", pkts/f1sd", bus->dhd->tx_packets, bus->f1regdata); in dhd_bus_dump()
3300 dhd_dump_pct(strbuf, ", pkts/sd", bus->dhd->tx_packets, in dhd_bus_dump()
3301 (bus->f2txdata + bus->f1regdata)); in dhd_bus_dump()
3302 dhd_dump_pct(strbuf, ", pkts/int", bus->dhd->tx_packets, bus->intrcount); in dhd_bus_dump()
3306 (bus->dhd->tx_packets + bus->dhd->rx_packets), in dhd_bus_dump()
3307 (bus->f2txdata + bus->f2rxhdrs + bus->f2rxdata)); in dhd_bus_dump()
3309 (bus->dhd->tx_packets + bus->dhd->rx_packets), bus->f1regdata); in dhd_bus_dump()
3311 (bus->dhd->tx_packets + bus->dhd->rx_packets), in dhd_bus_dump()
3312 (bus->f2txdata + bus->f2rxhdrs + bus->f2rxdata + bus->f1regdata)); in dhd_bus_dump()
3314 (bus->dhd->tx_packets + bus->dhd->rx_packets), bus->intrcount); in dhd_bus_dump()
3319 if (bus->pktgen_count) { in dhd_bus_dump()
3322 bus->pktgen_freq, bus->pktgen_count, bus->pktgen_print, in dhd_bus_dump()
3323 bus->pktgen_total, bus->pktgen_minlen, bus->pktgen_maxlen); in dhd_bus_dump()
3325 bus->pktgen_sent, bus->pktgen_rcvd, bus->pktgen_fail); in dhd_bus_dump()
3330 bus->dpc_sched, (bcmsdh_intr_pending(bus->sdh) ? " " : " not ")); in dhd_bus_dump()
3331 bcm_bprintf(strbuf, "blocksize %u roundup %u\n", bus->blocksize, bus->roundup); in dhd_bus_dump()
3334 bus->clkstate, bus->activity, bus->idletime, bus->idlecount, bus->sleeping); in dhd_bus_dump()
3340 dhd_bus_t *bus = (dhd_bus_t *)dhdp->bus; in dhd_bus_clearcounts() local
3342 bus->intrcount = bus->lastintrs = bus->spurious = bus->regfails = 0; in dhd_bus_clearcounts()
3343 bus->rxrtx = bus->rx_toolong = bus->rxc_errors = 0; in dhd_bus_clearcounts()
3344 bus->rx_hdrfail = bus->rx_badhdr = bus->rx_badseq = 0; in dhd_bus_clearcounts()
3346 bus->tx_tailpad_chain = bus->tx_tailpad_pktget = 0; in dhd_bus_clearcounts()
3348 bus->tx_sderrs = bus->fc_rcvd = bus->fc_xoff = bus->fc_xon = 0; in dhd_bus_clearcounts()
3349 bus->rxglomfail = bus->rxglomframes = bus->rxglompkts = 0; in dhd_bus_clearcounts()
3350 bus->f2rxhdrs = bus->f2rxdata = bus->f2txdata = bus->f1regdata = 0; in dhd_bus_clearcounts()
3355 dhdsdio_pktgen_get(dhd_bus_t *bus, uint8 *arg) in dhdsdio_pktgen_get() argument
3360 pktgen.freq = bus->pktgen_freq; in dhdsdio_pktgen_get()
3361 pktgen.count = bus->pktgen_count; in dhdsdio_pktgen_get()
3362 pktgen.print = bus->pktgen_print; in dhdsdio_pktgen_get()
3363 pktgen.total = bus->pktgen_total; in dhdsdio_pktgen_get()
3364 pktgen.minlen = bus->pktgen_minlen; in dhdsdio_pktgen_get()
3365 pktgen.maxlen = bus->pktgen_maxlen; in dhdsdio_pktgen_get()
3366 pktgen.numsent = bus->pktgen_sent; in dhdsdio_pktgen_get()
3367 pktgen.numrcvd = bus->pktgen_rcvd; in dhdsdio_pktgen_get()
3368 pktgen.numfail = bus->pktgen_fail; in dhdsdio_pktgen_get()
3369 pktgen.mode = bus->pktgen_mode; in dhdsdio_pktgen_get()
3370 pktgen.stop = bus->pktgen_stop; in dhdsdio_pktgen_get()
3378 dhdsdio_pktgen_set(dhd_bus_t *bus, uint8 *arg) in dhdsdio_pktgen_set() argument
3387 oldcnt = bus->pktgen_count; in dhdsdio_pktgen_set()
3388 oldmode = bus->pktgen_mode; in dhdsdio_pktgen_set()
3390 bus->pktgen_freq = pktgen.freq; in dhdsdio_pktgen_set()
3391 bus->pktgen_count = pktgen.count; in dhdsdio_pktgen_set()
3392 bus->pktgen_print = pktgen.print; in dhdsdio_pktgen_set()
3393 bus->pktgen_total = pktgen.total; in dhdsdio_pktgen_set()
3394 bus->pktgen_minlen = pktgen.minlen; in dhdsdio_pktgen_set()
3395 bus->pktgen_maxlen = pktgen.maxlen; in dhdsdio_pktgen_set()
3396 bus->pktgen_mode = pktgen.mode; in dhdsdio_pktgen_set()
3397 bus->pktgen_stop = pktgen.stop; in dhdsdio_pktgen_set()
3399 bus->pktgen_tick = bus->pktgen_ptick = 0; in dhdsdio_pktgen_set()
3400 bus->pktgen_prev_time = jiffies; in dhdsdio_pktgen_set()
3401 bus->pktgen_len = MAX(bus->pktgen_len, bus->pktgen_minlen); in dhdsdio_pktgen_set()
3402 bus->pktgen_len = MIN(bus->pktgen_len, bus->pktgen_maxlen); in dhdsdio_pktgen_set()
3405 if (bus->pktgen_count && (!oldcnt || oldmode != bus->pktgen_mode)) { in dhdsdio_pktgen_set()
3406 bus->pktgen_sent = bus->pktgen_prev_sent = bus->pktgen_rcvd = 0; in dhdsdio_pktgen_set()
3407 bus->pktgen_prev_rcvd = bus->pktgen_fail = 0; in dhdsdio_pktgen_set()
3415 dhdsdio_devram_remap(dhd_bus_t *bus, bool val) in dhdsdio_devram_remap() argument
3419 si_socdevram(bus->sih, FALSE, &enable, &protect, &remap); in dhdsdio_devram_remap()
3421 si_socdevram(bus->sih, TRUE, &enable, &protect, &remap); in dhdsdio_devram_remap()
3425 dhdsdio_membytes(dhd_bus_t *bus, bool write, uint32 address, uint8 *data, uint size) in dhdsdio_membytes() argument
3435 if (REMAP_ENAB(bus) && REMAP_ISADDR(bus, address)) { in dhdsdio_membytes()
3436 address -= bus->orig_ramsize; in dhdsdio_membytes()
3448 if ((bcmerror = dhdsdio_set_siaddr_window(bus, address))) { in dhdsdio_membytes()
3474 memcpy(bus->membuf, pdata, nbytes); in dhdsdio_membytes()
3477 if ((bcmerror = bcmsdh_rwdata(bus->sdh, write, offset, bus->membuf, nbytes))) { in dhdsdio_membytes()
3483 memcpy(pdata, bus->membuf, nbytes); in dhdsdio_membytes()
3495 if ((bcmerror = bcmsdh_rwdata(bus->sdh, write, sdaddr, data, dsize))) { in dhdsdio_membytes()
3505 if ((bcmerror = dhdsdio_set_siaddr_window(bus, address))) { in dhdsdio_membytes()
3516 if (dhdsdio_set_siaddr_window(bus, bcmsdh_cur_sbwad(bus->sdh))) { in dhdsdio_membytes()
3518 bcmsdh_cur_sbwad(bus->sdh))); in dhdsdio_membytes()
3525 dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh) in dhdsdio_readshared() argument
3536 if (bus->sih == NULL) { in dhdsdio_readshared()
3537 if (bus->dhd && bus->dhd->dongle_reset) { in dhdsdio_readshared()
3541 ASSERT(bus->dhd); in dhdsdio_readshared()
3542 ASSERT(bus->sih); in dhdsdio_readshared()
3547 if ((CHIPID(bus->sih->chip) == BCM43430_CHIP_ID || in dhdsdio_readshared()
3548 CHIPID(bus->sih->chip) == BCM43018_CHIP_ID) && !dhdsdio_sr_cap(bus)) in dhdsdio_readshared()
3549 bus->srmemsize = 0; in dhdsdio_readshared()
3551 shaddr = bus->dongle_ram_base + bus->ramsize - 4; in dhdsdio_readshared()
3555 if ((rv = dhdsdio_membytes(bus, FALSE, shaddr, (uint8 *)&addr, 4)) < 0) in dhdsdio_readshared()
3567 if ((bus->srmemsize > 0) && (i++ == 0)) { in dhdsdio_readshared()
3568 shaddr -= bus->srmemsize; in dhdsdio_readshared()
3579 if ((rv = dhdsdio_membytes(bus, FALSE, addr, (uint8 *)sh, sizeof(sdpcm_shared_t))) < 0) in dhdsdio_readshared()
3606 dhdsdio_readshared_console(dhd_bus_t *bus) in dhdsdio_readshared_console() argument
3615 if ((CHIPID(bus->sih->chip) == BCM43430_CHIP_ID || in dhdsdio_readshared_console()
3616 CHIPID(bus->sih->chip) == BCM43018_CHIP_ID) && !dhdsdio_sr_cap(bus)) { in dhdsdio_readshared_console()
3617 bus->srmemsize = 0; in dhdsdio_readshared_console()
3620 shaddr = bus->dongle_ram_base + bus->ramsize - 4; in dhdsdio_readshared_console()
3625 if ((rv = dhdsdio_membytes(bus, FALSE, shaddr, (uint8 *)&addr, 4)) < 0) in dhdsdio_readshared_console()
3637 if ((bus->srmemsize > 0) && (i++ == 0)) { in dhdsdio_readshared_console()
3638 shaddr -= bus->srmemsize; in dhdsdio_readshared_console()
3652 if ((rv = dhdsdio_membytes(bus, FALSE, addr, (uint8 *)sh, sizeof(sdpcm_shared_t))) < 0) in dhdsdio_readshared_console()
3657 /* load bus console address */ in dhdsdio_readshared_console()
3658 bus->console_addr = sh->console_addr; in dhdsdio_readshared_console()
3667 dhdsdio_readconsole(dhd_bus_t *bus) in dhdsdio_readconsole() argument
3669 dhd_console_t *c = &bus->console; in dhdsdio_readconsole()
3678 if (bus->console_addr == 0) in dhdsdio_readconsole()
3681 if (!KSO_ENAB(bus)) in dhdsdio_readconsole()
3685 addr = bus->console_addr + OFFSETOF(hnd_cons_t, log); in dhdsdio_readconsole()
3694 MFREE(bus->dhd->osh, c->buf, c->bufsize); in dhdsdio_readconsole()
3701 if ((rv = dhdsdio_membytes(bus, FALSE, addr, (uint8 *)&c->log, sizeof(c->log))) < 0) in dhdsdio_readconsole()
3707 if ((c->buf = MALLOC(bus->dhd->osh, c->bufsize)) == NULL) in dhdsdio_readconsole()
3726 if ((rv = dhdsdio_membytes(bus, FALSE, addr, c->buf, c->bufsize)) < 0) in dhdsdio_readconsole()
3754 dhd_sendup_log(bus->dhd, line, n); in dhdsdio_readconsole()
3765 dhdsdio_checkdied(dhd_bus_t *bus, char *data, uint size) in dhdsdio_checkdied() argument
3791 mbuffer = data = MALLOC(bus->dhd->osh, msize); in dhdsdio_checkdied()
3799 if ((str = MALLOC(bus->dhd->osh, maxstrlen)) == NULL) { in dhdsdio_checkdied()
3805 if ((bcmerror = dhdsdio_readshared(bus, &l_sdpcm_shared)) < 0) in dhdsdio_checkdied()
3833 if ((bcmerror = dhdsdio_membytes(bus, FALSE, in dhdsdio_checkdied()
3844 if ((bcmerror = dhdsdio_membytes(bus, FALSE, in dhdsdio_checkdied()
3857 trap_t *tr = &bus->dhd->last_trap_info; in dhdsdio_checkdied()
3858 bus->dhd->dongle_trap_occured = TRUE; in dhdsdio_checkdied()
3859 if ((bcmerror = dhdsdio_membytes(bus, FALSE, in dhdsdio_checkdied()
3864 bus->dongle_trap_addr = ltoh32(l_sdpcm_shared.trap_addr); in dhdsdio_checkdied()
3866 dhd_bus_dump_trap_info(bus, &strbuf); in dhdsdio_checkdied()
3869 if ((rv = dhdsdio_membytes(bus, FALSE, addr, in dhdsdio_checkdied()
3874 if ((rv = dhdsdio_membytes(bus, FALSE, addr, in dhdsdio_checkdied()
3879 if ((rv = dhdsdio_membytes(bus, FALSE, addr, in dhdsdio_checkdied()
3888 !(console_buffer = MALLOC(bus->dhd->osh, console_size))) in dhdsdio_checkdied()
3891 if ((rv = dhdsdio_membytes(bus, FALSE, console_ptr, in dhdsdio_checkdied()
3925 if (bus->dhd->memdump_enabled && (l_sdpcm_shared.flags & SDPCM_SHARED_TRAP)) { in dhdsdio_checkdied()
3927 bus->dhd->memdump_type = DUMP_TYPE_DONGLE_TRAP; in dhdsdio_checkdied()
3928 dhd_os_sdunlock(bus->dhd); in dhdsdio_checkdied()
3929 dhdsdio_mem_dump(bus); in dhdsdio_checkdied()
3930 dhd_os_sdlock(bus->dhd); in dhdsdio_checkdied()
3936 MFREE(bus->dhd->osh, mbuffer, msize); in dhdsdio_checkdied()
3938 MFREE(bus->dhd->osh, str, maxstrlen); in dhdsdio_checkdied()
3940 MFREE(bus->dhd->osh, console_buffer, console_size); in dhdsdio_checkdied()
3949 dhd_bus_t *bus = dhdp->bus; in dhd_bus_mem_dump() local
3951 DHD_ERROR(("%s: Bus is suspend so skip\n", __FUNCTION__)); in dhd_bus_mem_dump()
3954 return dhdsdio_mem_dump(bus); in dhd_bus_mem_dump()
3965 return dhdsdio_get_mem_dump(dhdp->bus); in dhd_bus_get_mem_dump()
3969 dhdsdio_get_mem_dump(dhd_bus_t *bus) in dhdsdio_get_mem_dump() argument
3972 int size = bus->ramsize; /* Full mem size */ in dhdsdio_get_mem_dump()
3973 uint32 start = bus->dongle_ram_base; /* Start address */ in dhdsdio_get_mem_dump()
3978 p_buf = dhd_get_fwdump_buf(bus->dhd, size); in dhdsdio_get_mem_dump()
3985 dhd_os_sdlock(bus->dhd); in dhdsdio_get_mem_dump()
3987 BUS_WAKE(bus); in dhdsdio_get_mem_dump()
3988 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_get_mem_dump()
3995 ret = dhdsdio_membytes(bus, FALSE, start, databuf, read_size); in dhdsdio_get_mem_dump()
4007 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhdsdio_get_mem_dump()
4008 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhdsdio_get_mem_dump()
4009 bus->activity = FALSE; in dhdsdio_get_mem_dump()
4010 dhdsdio_clkctl(bus, CLK_NONE, TRUE); in dhdsdio_get_mem_dump()
4013 dhd_os_sdunlock(bus->dhd); in dhdsdio_get_mem_dump()
4019 dhdsdio_mem_dump(dhd_bus_t *bus) in dhdsdio_mem_dump() argument
4024 dhdp = bus->dhd; in dhdsdio_mem_dump()
4030 ret = dhdsdio_get_mem_dump(bus); in dhdsdio_mem_dump()
4047 dhd_socram_dump(dhd_bus_t * bus) in dhd_socram_dump() argument
4050 return (dhdsdio_mem_dump(bus)); in dhd_socram_dump()
4057 dhdsdio_downloadvars(dhd_bus_t *bus, void *arg, int len) in dhdsdio_downloadvars() argument
4063 if (bus->dhd->up && in dhdsdio_downloadvars()
4065 (DHD_ULP_DISABLED == dhd_ulp_get_ulp_state(bus->dhd)) && in dhdsdio_downloadvars()
4077 if (bus->vars) in dhdsdio_downloadvars()
4078 MFREE(bus->dhd->osh, bus->vars, bus->varsz); in dhdsdio_downloadvars()
4080 bus->vars = MALLOC(bus->dhd->osh, len); in dhdsdio_downloadvars()
4081 bus->varsz = bus->vars ? len : 0; in dhdsdio_downloadvars()
4082 if (bus->vars == NULL) { in dhdsdio_downloadvars()
4088 bcopy(arg, bus->vars, bus->varsz); in dhdsdio_downloadvars()
4095 dhd_serialconsole(dhd_bus_t *bus, bool set, bool enable, int *bcmerror) in dhd_serialconsole() argument
4100 addr = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_addr); in dhd_serialconsole()
4101 data = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_data); in dhd_serialconsole()
4104 bcmsdh_reg_write(bus->sdh, addr, 4, 1); in dhd_serialconsole()
4105 if (bcmsdh_regfail(bus->sdh)) { in dhd_serialconsole()
4109 int_val = bcmsdh_reg_read(bus->sdh, data, 4); in dhd_serialconsole()
4110 if (bcmsdh_regfail(bus->sdh)) { in dhd_serialconsole()
4121 bcmsdh_reg_write(bus->sdh, data, 4, int_val); in dhd_serialconsole()
4122 if (bcmsdh_regfail(bus->sdh)) { in dhd_serialconsole()
4132 dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, uint32 actionid, const char *name, in dhdsdio_doiovar() argument
4150 /* Some ioctls use the bus */ in dhdsdio_doiovar()
4151 dhd_os_sdlock(bus->dhd); in dhdsdio_doiovar()
4154 if (bus->dhd->dongle_reset && !(actionid == IOV_SVAL(IOV_DEVRESET) || in dhdsdio_doiovar()
4164 dhdsdio_clk_kso_iovar(bus, bool_val); in dhdsdio_doiovar()
4168 dhdsdio_clk_devsleep_iovar(bus, bool_val); in dhdsdio_doiovar()
4169 if (!SLPAUTO_ENAB(bus) && (bool_val == FALSE) && (bus->ipend)) { in dhdsdio_doiovar()
4171 bus->dpc_sched)); in dhdsdio_doiovar()
4172 if (!bus->dpc_sched) { in dhdsdio_doiovar()
4173 bus->dpc_sched = TRUE; in dhdsdio_doiovar()
4174 dhd_sched_dpc(bus->dhd); in dhdsdio_doiovar()
4184 bcmerror = dhdsdio_bussleep(bus, bool_val); in dhdsdio_doiovar()
4186 int_val = (int32)bus->sleeping; in dhdsdio_doiovar()
4193 if (!bus->dhd->dongle_reset) { in dhdsdio_doiovar()
4194 BUS_WAKE(bus); in dhdsdio_doiovar()
4195 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_doiovar()
4200 int_val = (int32)bus->intr; in dhdsdio_doiovar()
4205 bus->intr = bool_val; in dhdsdio_doiovar()
4206 bus->intdis = FALSE; in dhdsdio_doiovar()
4207 if (bus->dhd->up) { in dhdsdio_doiovar()
4208 if (bus->intr) { in dhdsdio_doiovar()
4210 bcmsdh_intr_enable(bus->sdh); in dhdsdio_doiovar()
4213 bcmsdh_intr_disable(bus->sdh); in dhdsdio_doiovar()
4219 int_val = (int32)bus->pollrate; in dhdsdio_doiovar()
4224 bus->pollrate = (uint)int_val; in dhdsdio_doiovar()
4225 bus->poll = (bus->pollrate != 0); in dhdsdio_doiovar()
4229 int_val = bus->idletime; in dhdsdio_doiovar()
4237 bus->idletime = int_val; in dhdsdio_doiovar()
4242 int_val = (int32)bus->idleclock; in dhdsdio_doiovar()
4247 bus->idleclock = int_val; in dhdsdio_doiovar()
4261 bcmerror = dhdsdio_checkdied(bus, arg, len); in dhdsdio_doiovar()
4294 if (si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) { in dhdsdio_doiovar()
4299 if (set && address == bus->dongle_ram_base) { in dhdsdio_doiovar()
4300 bus->resetinstr = *(((uint32*)params) + 2); in dhdsdio_doiovar()
4304 if ((bus->orig_ramsize) && in dhdsdio_doiovar()
4305 ((address > bus->orig_ramsize) || (address + size > bus->orig_ramsize))) in dhdsdio_doiovar()
4308 si_socdevram(bus->sih, FALSE, &enable, &protect, &remap); in dhdsdio_doiovar()
4311 __FUNCTION__, bus->orig_ramsize, size, address)); in dhdsdio_doiovar()
4318 if (!REMAP_ENAB(bus) && (address >= SOCDEVRAM_ARM_ADDR)) { in dhdsdio_doiovar()
4319 uint32 devramsize = si_socdevram_size(bus->sih); in dhdsdio_doiovar()
4334 } else if (REMAP_ENAB(bus) && REMAP_ISADDR(bus, address) && remap) { in dhdsdio_doiovar()
4350 bcmerror = dhdsdio_membytes(bus, set, address, data, size); in dhdsdio_doiovar()
4357 int_val = (int32)bus->ramsize; in dhdsdio_doiovar()
4362 int_val = (int32)bus->dongle_ram_base; in dhdsdio_doiovar()
4373 si_sdiod_drive_strength_init(bus->sih, bus->dhd->osh, dhd_sdiod_drive_strength); in dhdsdio_doiovar()
4377 bcmerror = dhdsdio_download_state(bus, bool_val); in dhdsdio_doiovar()
4381 bcmerror = dhdsdio_download_state(bus, bool_val); in dhdsdio_doiovar()
4385 bcmerror = dhdsdio_downloadvars(bus, arg, len); in dhdsdio_doiovar()
4395 bus->nextlen = 0; in dhdsdio_doiovar()
4400 int_val = (int32)bus->use_rxchain; in dhdsdio_doiovar()
4405 if (bool_val && !bus->sd_rxchain) in dhdsdio_doiovar()
4408 bus->use_rxchain = bool_val; in dhdsdio_doiovar()
4428 if (bus->varsz < (uint)len) in dhdsdio_doiovar()
4429 bcopy(bus->vars, arg, bus->varsz); in dhdsdio_doiovar()
4444 addr = ((uintptr)bus->regs + sd_ptr->offset); in dhdsdio_doiovar()
4446 int_val = (int32)bcmsdh_reg_read(bus->sdh, addr, size); in dhdsdio_doiovar()
4447 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_doiovar()
4461 addr = ((uintptr)bus->regs + sd_ptr->offset); in dhdsdio_doiovar()
4463 bcmsdh_reg_write(bus->sdh, addr, size, sd_ptr->value); in dhdsdio_doiovar()
4464 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_doiovar()
4477 addr = SI_ENUM_BASE(bus->sih) + sdreg.offset; in dhdsdio_doiovar()
4479 int_val = (int32)bcmsdh_reg_read(bus->sdh, addr, size); in dhdsdio_doiovar()
4480 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_doiovar()
4493 addr = SI_ENUM_BASE(bus->sih) + sdreg.offset; in dhdsdio_doiovar()
4495 bcmsdh_reg_write(bus->sdh, addr, size, sdreg.value); in dhdsdio_doiovar()
4496 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_doiovar()
4506 bcmsdh_cis_read(bus->sdh, 0x10, (uint8 *)arg + strlen(arg), SBSDIO_CIS_SIZE_LIMIT); in dhdsdio_doiovar()
4508 bcmsdh_cis_read(bus->sdh, 0x11, (uint8 *)arg + strlen(arg), SBSDIO_CIS_SIZE_LIMIT); in dhdsdio_doiovar()
4510 bcmsdh_cis_read(bus->sdh, 0x12, (uint8 *)arg + strlen(arg), SBSDIO_CIS_SIZE_LIMIT); in dhdsdio_doiovar()
4552 int_val = dhd_serialconsole(bus, FALSE, 0, &bcmerror); in dhdsdio_doiovar()
4560 dhd_serialconsole(bus, TRUE, bool_val, &bcmerror); in dhdsdio_doiovar()
4568 int_val = (int32)bus->ext_loop; in dhdsdio_doiovar()
4573 bus->ext_loop = bool_val; in dhdsdio_doiovar()
4577 bcmerror = dhdsdio_pktgen_get(bus, arg); in dhdsdio_doiovar()
4581 bcmerror = dhdsdio_pktgen_set(bus, arg); in dhdsdio_doiovar()
4595 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_WATERMARK, (uint8)watermark, NULL); in dhdsdio_doiovar()
4608 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_MESBUSYCTRL, in dhdsdio_doiovar()
4614 int_val = bus->dhd->dongle_isolation; in dhdsdio_doiovar()
4619 bus->dhd->dongle_isolation = bool_val; in dhdsdio_doiovar()
4624 __FUNCTION__, bool_val, bus->dhd->dongle_reset, in dhdsdio_doiovar()
4625 bus->dhd->busstate)); in dhdsdio_doiovar()
4627 ASSERT(bus->dhd->osh); in dhdsdio_doiovar()
4628 /* ASSERT(bus->cl_devid); */ in dhdsdio_doiovar()
4631 dhd_os_sdunlock(bus->dhd); in dhdsdio_doiovar()
4632 dhd_bus_devreset(bus->dhd, (uint8)bool_val); in dhdsdio_doiovar()
4633 dhd_os_sdlock(bus->dhd); in dhdsdio_doiovar()
4643 int_val = (bool) bus->dhd->dongle_reset; in dhdsdio_doiovar()
4649 int_val = dhdsdio_sleepcsr_get(bus); in dhdsdio_doiovar()
4654 int_val = dhdsdio_devcap_get(bus); in dhdsdio_doiovar()
4659 dhdsdio_devcap_set(bus, (uint8) int_val); in dhdsdio_doiovar()
4662 int_val = (int32)bus->txglomsize; in dhdsdio_doiovar()
4670 bus->txglomsize = (uint)int_val; in dhdsdio_doiovar()
4674 bus->dhd->hang_report = bool_val; in dhdsdio_doiovar()
4675 DHD_ERROR(("%s: Set hang_report as %d\n", __FUNCTION__, bus->dhd->hang_report)); in dhdsdio_doiovar()
4679 int_val = (int32)bus->dhd->hang_report; in dhdsdio_doiovar()
4684 int_val = bus->txinrx_thres; in dhdsdio_doiovar()
4691 bus->txinrx_thres = int_val; in dhdsdio_doiovar()
4696 int_val = (bus->dhd->busstate == DHD_BUS_SUSPEND) ? 1 : 0; in dhdsdio_doiovar()
4702 dhdsdio_suspend(bus); in dhdsdio_doiovar()
4705 dhdsdio_resume(bus); in dhdsdio_doiovar()
4712 debugger_init((void *) bus, &bus_ops, int_val, SI_ENUM_BASE(bus->sih)); in dhdsdio_doiovar()
4725 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhdsdio_doiovar()
4726 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhdsdio_doiovar()
4727 bus->activity = FALSE; in dhdsdio_doiovar()
4728 dhdsdio_bussleep(bus, TRUE); in dhdsdio_doiovar()
4729 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhdsdio_doiovar()
4732 dhd_os_sdunlock(bus->dhd); in dhdsdio_doiovar()
4738 dhdsdio_write_vars(dhd_bus_t *bus) in dhdsdio_write_vars() argument
4751 varsize = bus->varsz ? ROUNDUP(bus->varsz, 4) : 0; in dhdsdio_write_vars()
4752 varaddr = bus->ramsize - varsize - TOKENSIZE; in dhdsdio_write_vars()
4753 varaddr += bus->dongle_ram_base; in dhdsdio_write_vars()
4755 if (bus->vars) { in dhdsdio_write_vars()
4756 if ((bus->sih->buscoretype == SDIOD_CORE_ID) && (bus->sdpcmrev == 7)) { in dhdsdio_write_vars()
4764 vbuffer = (uint8 *)MALLOC(bus->dhd->osh, varsize + TOKENSIZE); in dhdsdio_write_vars()
4769 bcopy(bus->vars, vbuffer, bus->varsz); in dhdsdio_write_vars()
4784 bcmerror = dhdsdio_membytes(bus, TRUE, varaddr, vbuffer, varsize + TOKENSIZE); in dhdsdio_write_vars()
4794 nvram_ularray = (uint8*)MALLOC(bus->dhd->osh, varsize); in dhdsdio_write_vars()
4796 MFREE(bus->dhd->osh, vbuffer, varsize + TOKENSIZE); in dhdsdio_write_vars()
4804 bcmerror = dhdsdio_membytes(bus, FALSE, varaddr, nvram_ularray, varsize); in dhdsdio_write_vars()
4816 MFREE(bus->dhd->osh, nvram_ularray, varsize); in dhdsdio_write_vars()
4818 MFREE(bus->dhd->osh, vbuffer, varsize + TOKENSIZE); in dhdsdio_write_vars()
4822 phys_size = REMAP_ENAB(bus) ? bus->ramsize : bus->orig_ramsize; in dhdsdio_write_vars()
4824 phys_size += bus->dongle_ram_base; in dhdsdio_write_vars()
4828 phys_size, bus->ramsize)); in dhdsdio_write_vars()
4836 dhd_bus_is_multibp_capable(struct dhd_bus *bus) in dhd_bus_is_multibp_capable() argument
4838 return MULTIBP_CAP(bus->sih); in dhd_bus_is_multibp_capable()
4842 dhdsdio_download_state(dhd_bus_t *bus, bool enter) in dhdsdio_download_state() argument
4849 if (!bus->sih) in dhdsdio_download_state()
4852 if (bus->secureboot) { in dhdsdio_download_state()
4854 bcmerror = dhdsdio_dongle_host_get_handshake_address(bus, &bl_hs_addrs); in dhdsdio_download_state()
4865 bus->alp_only = TRUE; in dhdsdio_download_state()
4867 if (!(si_setcore(bus->sih, ARM7S_CORE_ID, 0)) && in dhdsdio_download_state()
4868 !(si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) { in dhdsdio_download_state()
4869 if (si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) { in dhdsdio_download_state()
4879 si_core_disable(bus->sih, 0); in dhdsdio_download_state()
4880 if (bcmsdh_regfail(bus->sdh)) { in dhdsdio_download_state()
4885 if (!(si_setcore(bus->sih, SOCRAM_CORE_ID, 0))) { in dhdsdio_download_state()
4891 si_core_reset(bus->sih, 0, 0); in dhdsdio_download_state()
4892 if (bcmsdh_regfail(bus->sdh)) { in dhdsdio_download_state()
4900 if (REMAP_ENAB(bus) && si_socdevram_remap_isenb(bus->sih)) in dhdsdio_download_state()
4901 dhdsdio_devram_remap(bus, FALSE); in dhdsdio_download_state()
4903 if (CHIPID(bus->sih->chip) == BCM43430_CHIP_ID || in dhdsdio_download_state()
4904 CHIPID(bus->sih->chip) == BCM43018_CHIP_ID) { in dhdsdio_download_state()
4906 si_socram_set_bankpda(bus->sih, 0x3, 0x0); in dhdsdio_download_state()
4910 if (bus->ramsize) { in dhdsdio_download_state()
4912 if (dhdsdio_membytes(bus, TRUE, bus->ramsize - 4, in dhdsdio_download_state()
4927 if (bus->secureboot) { in dhdsdio_download_state()
4932 (bus, &bl_hs_addrs))) { in dhdsdio_download_state()
4942 if ((bcmerror = dhdsdio_readshared_console(bus)) < 0) { in dhdsdio_download_state()
4948 if ((bcmerror = dhdsdio_readconsole(bus)) < 0) { in dhdsdio_download_state()
4955 si_core_reset(bus->sih, SICF_CPUHALT, SICF_CPUHALT); in dhdsdio_download_state()
4959 if (!si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) { in dhdsdio_download_state()
4960 if (!(si_setcore(bus->sih, SOCRAM_CORE_ID, 0))) { in dhdsdio_download_state()
4966 if (!si_iscoreup(bus->sih)) { in dhdsdio_download_state()
4972 if ((bcmerror = dhdsdio_write_vars(bus))) { in dhdsdio_download_state()
4980 if (REMAP_ENAB(bus) && !si_socdevram_remap_isenb(bus->sih)) in dhdsdio_download_state()
4981 dhdsdio_devram_remap(bus, TRUE); in dhdsdio_download_state()
4983 if (!si_setcore(bus->sih, CC_CORE_ID, 0)) { in dhdsdio_download_state()
4989 if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0) && in dhdsdio_download_state()
4990 !si_setcore(bus->sih, SDIOD_CORE_ID, 0)) { in dhdsdio_download_state()
4996 W_SDREG(0xFFFFFFFF, &bus->regs->intstatus, retries); in dhdsdio_download_state()
4998 if (!(si_setcore(bus->sih, ARM7S_CORE_ID, 0)) && in dhdsdio_download_state()
4999 !(si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) { in dhdsdio_download_state()
5005 if (bus->secureboot) { in dhdsdio_download_state()
5008 if ((bcmerror = dhdsdio_readconsole(bus)) < 0) { in dhdsdio_download_state()
5014 if ((bcmerror = dhdsdio_dongle_host_post_handshake(bus, in dhdsdio_download_state()
5030 if ((bcmerror = dhdsdio_dongle_host_chk_validation(bus, in dhdsdio_download_state()
5040 if ((bcmerror = dhdsdio_write_vars(bus))) { in dhdsdio_download_state()
5045 if (!si_setcore(bus->sih, CC_CORE_ID, 0)) { in dhdsdio_download_state()
5051 if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0) && in dhdsdio_download_state()
5052 !si_setcore(bus->sih, SDIOD_CORE_ID, 0)) { in dhdsdio_download_state()
5058 W_SDREG(0xFFFFFFFF, &bus->regs->intstatus, retries); in dhdsdio_download_state()
5061 if (!(si_setcore(bus->sih, ARMCR4_CORE_ID, 0))) { in dhdsdio_download_state()
5068 if (!bus->secureboot) { in dhdsdio_download_state()
5069 bcmerror = dhdsdio_membytes(bus, TRUE, 0, in dhdsdio_download_state()
5070 (uint8 *)&bus->resetinstr, sizeof(bus->resetinstr)); in dhdsdio_download_state()
5076 bcmerror = dhdsdio_membytes(bus, FALSE, 0, (uint8 *)&tmp, in dhdsdio_download_state()
5079 if (bcmerror == BCME_OK && tmp != bus->resetinstr) { in dhdsdio_download_state()
5081 __FUNCTION__, bus->resetinstr)); in dhdsdio_download_state()
5092 if (bus->secureboot) { in dhdsdio_download_state()
5095 if ((bcmerror = dhdsdio_readconsole(bus)) < 0) { in dhdsdio_download_state()
5101 if ((bcmerror = dhdsdio_dongle_host_post_varswrite(bus, &bl_hs_addrs))) { in dhdsdio_download_state()
5109 si_core_reset(bus->sih, 0, 0); in dhdsdio_download_state()
5111 if (bcmsdh_regfail(bus->sdh)) { in dhdsdio_download_state()
5118 bus->alp_only = FALSE; in dhdsdio_download_state()
5120 bus->dhd->busstate = DHD_BUS_LOAD; in dhdsdio_download_state()
5125 if (bus->secureboot) { in dhdsdio_download_state()
5127 if (dhdsdio_readshared_console(bus) < 0) { in dhdsdio_download_state()
5133 if (dhdsdio_readconsole(bus) < 0) { in dhdsdio_download_state()
5143 if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0)) in dhdsdio_download_state()
5144 si_setcore(bus->sih, SDIOD_CORE_ID, 0); in dhdsdio_download_state()
5150 dhdsdio_dongle_host_get_handshake_address(dhd_bus_t *bus, hs_addrs_t *addr) in dhdsdio_dongle_host_get_handshake_address() argument
5163 dhdsdio_wait_bootloader_ready(dhd_bus_t *bus, hs_addrs_t *addr) in dhdsdio_wait_bootloader_ready() argument
5169 bcmerror = dhdsdio_handshake_msg_reg_write(bus, addr->h2d, &h2d_reg); in dhdsdio_wait_bootloader_ready()
5174 bcmerror = dhdsdio_dongle_host_handshake_spinwait(bus, addr->d2h, in dhdsdio_wait_bootloader_ready()
5182 dhdsdio_dongle_host_pre_handshake(dhd_bus_t *bus, hs_addrs_t *addr) in dhdsdio_dongle_host_pre_handshake() argument
5189 bcmerror = dhdsdio_handshake_msg_reg_write(bus, addr->h2d, &h2d_reg); in dhdsdio_dongle_host_pre_handshake()
5195 dhdsdio_dongle_host_post_handshake(dhd_bus_t *bus, hs_addrs_t *addr) in dhdsdio_dongle_host_post_handshake() argument
5205 bcmerror = dhdsdio_handshake_msg_reg_write(bus, addr->h2d, &h2d_reg); in dhdsdio_dongle_host_post_handshake()
5210 bcmerror = dhdsdio_dongle_host_handshake_spinwait(bus, addr->d2h, in dhdsdio_dongle_host_post_handshake()
5215 dhdsdio_handshake_msg_reg_read(bus, addr->h2d, &h2d_reg); in dhdsdio_dongle_host_post_handshake()
5217 dhdsdio_handshake_msg_reg_write(bus, addr->h2d, &h2d_reg); in dhdsdio_dongle_host_post_handshake()
5225 dhdsdio_dongle_host_chk_validation(dhd_bus_t *bus, hs_addrs_t *addr) in dhdsdio_dongle_host_chk_validation() argument
5232 bcmerror = dhdsdio_dongle_host_handshake_spinwait(bus, addr->d2h, in dhdsdio_dongle_host_chk_validation()
5236 bcmerror = dhdsdio_handshake_msg_reg_read(bus, addr->d2h, &d2h_reg); in dhdsdio_dongle_host_chk_validation()
5253 dhdsdio_handshake_msg_reg_read(bus, addr->h2d, &h2d_reg); in dhdsdio_dongle_host_chk_validation()
5255 dhdsdio_handshake_msg_reg_write(bus, addr->h2d, &h2d_reg); in dhdsdio_dongle_host_chk_validation()
5262 dhdsdio_dongle_host_post_varswrite(dhd_bus_t *bus, hs_addrs_t *addr) in dhdsdio_dongle_host_post_varswrite() argument
5270 bcmerror = dhdsdio_handshake_msg_reg_write(bus, addr->h2d, &h2d_reg); in dhdsdio_dongle_host_post_varswrite()
5276 dhdsdio_dongle_host_pre_wd_reset_sequence(dhd_bus_t *bus) in dhdsdio_dongle_host_pre_wd_reset_sequence() argument
5283 bcmerror = dhdsdio_handshake_msg_reg_write(bus, regs, &h2d_reg); in dhdsdio_dongle_host_pre_wd_reset_sequence()
5289 dhdsdio_handshake_msg_reg_write(dhd_bus_t *bus, volatile void *addr, uint32 *buffer) in dhdsdio_handshake_msg_reg_write() argument
5295 bcmerror = dhdsdio_cfg_write_buffer(bus, buffer, (uint)(uintptr)addr); in dhdsdio_handshake_msg_reg_write()
5302 dhdsdio_handshake_msg_reg_read(dhd_bus_t *bus, volatile void *addr, uint32 *buffer) in dhdsdio_handshake_msg_reg_read() argument
5308 dhdsdio_cfg_read_buffer(bus, buffer, (uint)(uintptr)addr); in dhdsdio_handshake_msg_reg_read()
5315 dhdsdio_cfg_write_buffer(dhd_bus_t *bus, uint32 *buffer, uint offset) in dhdsdio_cfg_write_buffer() argument
5319 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, offset, ((*buffer) >> 0) in dhdsdio_cfg_write_buffer()
5322 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, offset+1, ((*buffer) >> 8) in dhdsdio_cfg_write_buffer()
5326 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, offset+2, ((*buffer) >> 16) in dhdsdio_cfg_write_buffer()
5330 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, offset+3, ((*buffer) >> 24) in dhdsdio_cfg_write_buffer()
5338 dhdsdio_cfg_read_buffer(dhd_bus_t *bus, uint32 *buffer, uint offset) in dhdsdio_cfg_read_buffer() argument
5340 *buffer = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, offset+0, NULL) << 0; in dhdsdio_cfg_read_buffer()
5341 *buffer = *buffer | bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, offset+1, NULL) << 8; in dhdsdio_cfg_read_buffer()
5342 *buffer = *buffer | bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, offset+2, NULL) << 16; in dhdsdio_cfg_read_buffer()
5343 *buffer = *buffer | bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, offset+3, NULL) << 24; in dhdsdio_cfg_read_buffer()
5349 dhdsdio_dongle_host_handshake_spinwait(dhd_bus_t *bus, volatile void *addr, in dhdsdio_dongle_host_handshake_spinwait() argument
5359 bcmerror = dhdsdio_handshake_msg_reg_read(bus, addr, &read_addr); in dhdsdio_dongle_host_handshake_spinwait()
5384 dhd_bus_t *bus = dhdp->bus; in dhd_bus_iovar_op() local
5403 dhd_os_sdlock(bus->dhd); in dhd_bus_iovar_op()
5405 BUS_WAKE(bus); in dhd_bus_iovar_op()
5408 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_iovar_op()
5410 bcmerror = bcmsdh_iovar_op(bus->sdh, name, params, plen, arg, len, set); in dhd_bus_iovar_op()
5412 /* Check for bus configuration changes of interest */ in dhd_bus_iovar_op()
5416 if (bcmsdh_iovar_op(bus->sdh, "sd_divisor", NULL, 0, in dhd_bus_iovar_op()
5417 &bus->sd_divisor, sizeof(int32), FALSE) != BCME_OK) { in dhd_bus_iovar_op()
5418 bus->sd_divisor = -1; in dhd_bus_iovar_op()
5422 __FUNCTION__, name, bus->sd_divisor)); in dhd_bus_iovar_op()
5427 if (bcmsdh_iovar_op(bus->sdh, "sd_mode", NULL, 0, in dhd_bus_iovar_op()
5428 &bus->sd_mode, sizeof(int32), FALSE) != BCME_OK) { in dhd_bus_iovar_op()
5429 bus->sd_mode = -1; in dhd_bus_iovar_op()
5433 __FUNCTION__, name, bus->sd_mode)); in dhd_bus_iovar_op()
5439 if (bcmsdh_iovar_op(bus->sdh, "sd_blocksize", &fnum, sizeof(int32), in dhd_bus_iovar_op()
5440 &bus->blocksize, sizeof(int32), FALSE) != BCME_OK) { in dhd_bus_iovar_op()
5441 bus->blocksize = 0; in dhd_bus_iovar_op()
5446 __FUNCTION__, fnum, "sd_blocksize", bus->blocksize)); in dhd_bus_iovar_op()
5448 dhdsdio_tune_fifoparam(bus); in dhd_bus_iovar_op()
5451 bus->roundup = MIN(max_roundup, bus->blocksize); in dhd_bus_iovar_op()
5453 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhd_bus_iovar_op()
5454 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhd_bus_iovar_op()
5455 bus->activity = FALSE; in dhd_bus_iovar_op()
5456 dhdsdio_bussleep(bus, TRUE); in dhd_bus_iovar_op()
5457 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_iovar_op()
5460 dhd_os_sdunlock(bus->dhd); in dhd_bus_iovar_op()
5484 bcmerror = dhdsdio_doiovar(bus, vi, actionid, name, params, plen, arg, len, val_size); in dhd_bus_iovar_op()
5491 dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex) in dhd_bus_stop() argument
5501 if (!bus->dhd) in dhd_bus_stop()
5504 osh = bus->dhd->osh; in dhd_bus_stop()
5507 bcmsdh_waitlockfree(bus->sdh); in dhd_bus_stop()
5510 dhd_os_sdlock(bus->dhd); in dhd_bus_stop()
5512 if ((bus->dhd->busstate == DHD_BUS_DOWN) || bus->dhd->hang_was_sent) { in dhd_bus_stop()
5515 bus->dhd->busstate = DHD_BUS_DOWN; in dhd_bus_stop()
5516 bus->hostintmask = 0; in dhd_bus_stop()
5517 bcmsdh_intr_disable(bus->sdh); in dhd_bus_stop()
5520 BUS_WAKE(bus); in dhd_bus_stop()
5522 if (KSO_ENAB(bus)) { in dhd_bus_stop()
5525 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_stop()
5528 W_SDREG(0, &bus->regs->hostintmask, retries); in dhd_bus_stop()
5529 local_hostintmask = bus->hostintmask; in dhd_bus_stop()
5530 bus->hostintmask = 0; in dhd_bus_stop()
5532 /* Change our idea of bus state */ in dhd_bus_stop()
5533 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhd_bus_stop()
5535 bus->dhd->busstate = DHD_BUS_DOWN; in dhd_bus_stop()
5536 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhd_bus_stop()
5539 saveclk = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); in dhd_bus_stop()
5541 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, in dhd_bus_stop()
5549 /* Turn off the bus (F2), free any pending packets */ in dhd_bus_stop()
5551 bcmsdh_intr_disable(bus->sdh); in dhd_bus_stop()
5553 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IOEN, SDIO_FUNC_ENABLE_1, NULL); in dhd_bus_stop()
5557 W_SDREG(local_hostintmask, &bus->regs->intstatus, retries); in dhd_bus_stop()
5561 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhd_bus_stop()
5565 wlfc_enabled = (dhd_wlfc_cleanup_txq(bus->dhd, NULL, 0) != WLFC_UNSUPPORTED); in dhd_bus_stop()
5572 dhd_tcpack_info_tbl_clean(bus->dhd); in dhd_bus_stop()
5574 dhd_os_sdlock_txq(bus->dhd); in dhd_bus_stop()
5576 pktq_flush(osh, &bus->txq, TRUE); in dhd_bus_stop()
5577 dhd_os_sdunlock_txq(bus->dhd); in dhd_bus_stop()
5581 if (bus->glomd) in dhd_bus_stop()
5582 PKTFREE(osh, bus->glomd, FALSE); in dhd_bus_stop()
5584 if (bus->glom) in dhd_bus_stop()
5585 PKTFREE(osh, bus->glom, FALSE); in dhd_bus_stop()
5587 bus->glom = bus->glomd = NULL; in dhd_bus_stop()
5590 bus->rxlen = 0; in dhd_bus_stop()
5591 dhd_os_ioctl_resp_wake(bus->dhd); in dhd_bus_stop()
5594 bus->rxskip = FALSE; in dhd_bus_stop()
5595 bus->tx_seq = bus->rx_seq = 0; in dhd_bus_stop()
5597 bus->tx_max = 4; in dhd_bus_stop()
5600 dhd_os_sdunlock(bus->dhd); in dhd_bus_stop()
5613 dhd_bus_t *bus = dhdp->bus; in dhd_txglom_enable() local
5627 ret = dhd_iovar(dhdp, 0, "bus:rxglom", (char *)&rxglom, sizeof(rxglom), NULL, 0, in dhd_txglom_enable()
5630 bus->txglom_enable = TRUE; in dhd_txglom_enable()
5635 bus->txglom_enable = FALSE; in dhd_txglom_enable()
5639 bus->txglom_enable = FALSE; in dhd_txglom_enable()
5645 dhd_bus_t *bus = dhdp->bus; in dhd_bus_init() local
5658 ASSERT(bus->dhd); in dhd_bus_init()
5659 if (!bus->dhd) in dhd_bus_init()
5663 if ((ret = dhdsdio_readshared_console(bus)) >= 0) { in dhd_bus_init()
5666 if ((ret = dhdsdio_readconsole(bus)) < 0) { in dhd_bus_init()
5675 dhd_os_sdlock(bus->dhd); in dhd_bus_init()
5678 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_init()
5679 if (bus->clkstate != CLK_AVAIL) { in dhd_bus_init()
5680 DHD_ERROR(("%s: clock state is wrong. state = %d\n", __FUNCTION__, bus->clkstate)); in dhd_bus_init()
5693 dstatus = bcmsdh_cfg_read_word(bus->sdh, SDIO_FUNC_0, SPID_STATUS_REG, NULL); in dhd_bus_init()
5710 saveclk = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); in dhd_bus_init()
5713 if (bus->sih->chip == BCM43012_CHIP_ID || in dhd_bus_init()
5714 bus->sih->chip == CYW55500_CHIP_ID || in dhd_bus_init()
5715 bus->sih->chip == CYW55560_CHIP_ID) { in dhd_bus_init()
5716 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, in dhd_bus_init()
5719 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, in dhd_bus_init()
5732 &bus->regs->tosbmailboxdata, retries); in dhd_bus_init()
5735 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IOEN, enable, NULL); in dhd_bus_init()
5742 ready = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IORDY, NULL); in dhd_bus_init()
5753 bus->regs = si_setcore(bus->sih, CC_CORE_ID, 0); in dhd_bus_init()
5754 ASSERT(bus->regs != NULL); in dhd_bus_init()
5756 if (!(bus->regs = si_setcore(bus->sih, PCMCIA_CORE_ID, 0))) in dhd_bus_init()
5757 bus->regs = si_setcore(bus->sih, SDIOD_CORE_ID, 0); in dhd_bus_init()
5758 ASSERT(bus->regs != NULL); in dhd_bus_init()
5761 bus->hostintmask = HOSTINTMASK; in dhd_bus_init()
5764 if ((bus->sih->buscoretype == SDIOD_CORE_ID) && (bus->sdpcmrev == 4) && in dhd_bus_init()
5765 (bus->rxint_mode != SDIO_DEVICE_HMB_RXINT)) { in dhd_bus_init()
5766 bus->hostintmask &= ~I_HMB_FRAME_IND; in dhd_bus_init()
5767 bus->hostintmask |= I_XMTDATA_AVAIL; in dhd_bus_init()
5771 W_SDREG(bus->hostintmask, &bus->regs->hostintmask, retries); in dhd_bus_init()
5773 if (bus->sih->buscorerev < 15) { in dhd_bus_init()
5774 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_WATERMARK, in dhd_bus_init()
5778 /* Set bus state according to enable result */ in dhd_bus_init()
5788 /* bcmsdh_intr_unmask(bus->sdh); */ in dhd_bus_init()
5790 bus->intdis = FALSE; in dhd_bus_init()
5791 if (bus->intr) { in dhd_bus_init()
5794 bcmsdh_intr_enable(bus->sdh); in dhd_bus_init()
5798 bcmsdh_intr_disable(bus->sdh); in dhd_bus_init()
5808 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IOEN, enable, NULL); in dhd_bus_init()
5812 if (bus->dhd->memdump_enabled && tcm_dump_enable) { in dhd_bus_init()
5814 dhd_bus_mem_dump(bus->dhd); in dhd_bus_init()
5818 if (dhdsdio_sr_cap(bus)) { in dhd_bus_init()
5819 dhdsdio_sr_init(bus); in dhd_bus_init()
5821 bus->hostintmask &= ~I_CHIPACTIVE; in dhd_bus_init()
5822 W_SDREG(bus->hostintmask, &bus->regs->hostintmask, retries); in dhd_bus_init()
5824 __FUNCTION__, bus->hostintmask)); in dhd_bus_init()
5826 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, in dhd_bus_init()
5831 if (dhdsdio_sr_cap(bus)) { in dhd_bus_init()
5832 dhdsdio_sr_init(bus); in dhd_bus_init()
5834 bus->hostintmask &= ~I_CHIPACTIVE; in dhd_bus_init()
5835 W_SDREG(bus->hostintmask, &bus->regs->hostintmask, retries); in dhd_bus_init()
5837 __FUNCTION__, bus->hostintmask)); in dhd_bus_init()
5844 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_init()
5848 dhd_os_sdunlock(bus->dhd); in dhd_bus_init()
5854 dhdsdio_rxfail(dhd_bus_t *bus, bool abort, bool rtx) in dhdsdio_rxfail() argument
5856 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_rxfail()
5857 sdpcmd_regs_t *regs = bus->regs; in dhdsdio_rxfail()
5866 if (!KSO_ENAB(bus)) { in dhdsdio_rxfail()
5880 bus->f1regdata++; in dhdsdio_rxfail()
5891 bus->f1regdata += 2; in dhdsdio_rxfail()
5910 bus->rxrtx++; in dhdsdio_rxfail()
5912 bus->f1regdata++; in dhdsdio_rxfail()
5914 bus->rxskip = TRUE; in dhdsdio_rxfail()
5919 bus->nextlen = 0; in dhdsdio_rxfail()
5925 bus->dhd->busstate = DHD_BUS_DOWN; in dhdsdio_rxfail()
5930 dhdsdio_read_control(dhd_bus_t *bus, uint8 *hdr, uint len, uint doff) in dhdsdio_read_control() argument
5932 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_read_control()
5940 if ((bus->bus == SPI_BUS) && (!bus->usebufpool)) in dhdsdio_read_control()
5943 ASSERT(bus->rxbuf); in dhdsdio_read_control()
5945 bus->rxctl = bus->rxbuf; in dhdsdio_read_control()
5947 bus->rxctl += firstread; in dhdsdio_read_control()
5948 if ((pad = ((uintptr)bus->rxctl % DHD_SDALIGN))) in dhdsdio_read_control()
5949 bus->rxctl += (DHD_SDALIGN - pad); in dhdsdio_read_control()
5950 bus->rxctl -= firstread; in dhdsdio_read_control()
5952 ASSERT(bus->rxctl >= bus->rxbuf); in dhdsdio_read_control()
5955 bcopy(hdr, bus->rxctl, firstread); in dhdsdio_read_control()
5960 if (bus->bus == SPI_BUS) { in dhdsdio_read_control()
5961 bcopy(hdr, bus->rxctl, len); in dhdsdio_read_control()
5967 if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { in dhdsdio_read_control()
5968 pad = bus->blocksize - (rdlen % bus->blocksize); in dhdsdio_read_control()
5969 if ((pad <= bus->roundup) && (pad < bus->blocksize) && in dhdsdio_read_control()
5970 ((len + pad) < bus->dhd->maxctl)) in dhdsdio_read_control()
5981 if ((rdlen + firstread) > bus->dhd->maxctl) { in dhdsdio_read_control()
5983 __FUNCTION__, rdlen, bus->dhd->maxctl)); in dhdsdio_read_control()
5984 bus->dhd->rx_errors++; in dhdsdio_read_control()
5985 dhdsdio_rxfail(bus, FALSE, FALSE); in dhdsdio_read_control()
5989 if ((len - doff) > bus->dhd->maxctl) { in dhdsdio_read_control()
5991 __FUNCTION__, len, (len - doff), bus->dhd->maxctl)); in dhdsdio_read_control()
5992 bus->dhd->rx_errors++; bus->rx_toolong++; in dhdsdio_read_control()
5993 dhdsdio_rxfail(bus, FALSE, FALSE); in dhdsdio_read_control()
5998 sdret = dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC, in dhdsdio_read_control()
5999 (bus->rxctl + firstread), rdlen, NULL, NULL, NULL); in dhdsdio_read_control()
6000 bus->f2rxdata++; in dhdsdio_read_control()
6006 bus->rxc_errors++; /* dhd.rx_ctlerrs is higher level */ in dhdsdio_read_control()
6007 dhdsdio_rxfail(bus, TRUE, TRUE); in dhdsdio_read_control()
6015 prhex("RxCtrl", bus->rxctl, len); in dhdsdio_read_control()
6020 bus->rxctl += doff; in dhdsdio_read_control()
6021 bus->rxlen = len - doff; in dhdsdio_read_control()
6025 dhd_os_ioctl_resp_wake(bus->dhd); in dhdsdio_read_control()
6032 dhdsdio_rxglom(dhd_bus_t *bus, uint8 rxseq) in dhdsdio_rxglom() argument
6042 osl_t *osh = bus->dhd->osh; in dhdsdio_rxglom()
6051 bool usechain = bus->use_rxchain; in dhdsdio_rxglom()
6056 DHD_TRACE(("dhdsdio_rxglom: start: glomd %p glom %p\n", bus->glomd, bus->glom)); in dhdsdio_rxglom()
6059 if (bus->glomd) { in dhdsdio_rxglom()
6060 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_rxglom()
6063 dlen = (uint16)PKTLEN(osh, bus->glomd); in dhdsdio_rxglom()
6064 dptr = PKTDATA(osh, bus->glomd); in dhdsdio_rxglom()
6092 sublen += (ROUNDUP(totlen, bus->blocksize) - totlen); in dhdsdio_rxglom()
6093 totlen = ROUNDUP(totlen, bus->blocksize); in dhdsdio_rxglom()
6116 /* If all allocations succeeded, save packet chain in bus structure */ in dhdsdio_rxglom()
6120 if (DHD_GLOM_ON() && bus->nextlen) { in dhdsdio_rxglom()
6121 if (totlen != bus->nextlen) { in dhdsdio_rxglom()
6123 "rxseq %d\n", __FUNCTION__, bus->nextlen, in dhdsdio_rxglom()
6127 bus->glom = pfirst; in dhdsdio_rxglom()
6132 bus->glom = NULL; in dhdsdio_rxglom()
6137 PKTFREE(osh, bus->glomd, FALSE); in dhdsdio_rxglom()
6138 bus->glomd = NULL; in dhdsdio_rxglom()
6139 bus->nextlen = 0; in dhdsdio_rxglom()
6141 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_rxglom()
6145 if (bus->glom) { in dhdsdio_rxglom()
6148 for (pnext = bus->glom; pnext; pnext = PKTNEXT(osh, pnext)) { in dhdsdio_rxglom()
6155 pfirst = bus->glom; in dhdsdio_rxglom()
6163 errcode = dhd_bcmsdh_recv_buf(bus, in dhdsdio_rxglom()
6164 bcmsdh_cur_sbwad(bus->sdh), SDIO_FUNC_2, in dhdsdio_rxglom()
6167 } else if (bus->dataptr) { in dhdsdio_rxglom()
6168 errcode = dhd_bcmsdh_recv_buf(bus, in dhdsdio_rxglom()
6169 bcmsdh_cur_sbwad(bus->sdh), SDIO_FUNC_2, in dhdsdio_rxglom()
6170 F2SYNC, bus->dataptr, in dhdsdio_rxglom()
6172 sublen = (uint16)pktfrombuf(osh, pfirst, 0, dlen, bus->dataptr); in dhdsdio_rxglom()
6184 bus->f2rxdata++; in dhdsdio_rxglom()
6191 bus->dhd->rx_errors++; in dhdsdio_rxglom()
6193 if (bus->glomerr++ < 3) { in dhdsdio_rxglom()
6194 dhdsdio_rxfail(bus, TRUE, TRUE); in dhdsdio_rxglom()
6196 bus->glomerr = 0; in dhdsdio_rxglom()
6197 dhdsdio_rxfail(bus, TRUE, FALSE); in dhdsdio_rxglom()
6198 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_rxglom()
6199 PKTFREE(osh, bus->glom, FALSE); in dhdsdio_rxglom()
6200 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_rxglom()
6201 bus->rxglomfail++; in dhdsdio_rxglom()
6202 bus->glom = NULL; in dhdsdio_rxglom()
6221 bus->nextlen = dptr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET]; in dhdsdio_rxglom()
6222 if ((bus->nextlen << 4) > MAX_RX_DATASZ) { in dhdsdio_rxglom()
6224 __FUNCTION__, bus->nextlen, seq)); in dhdsdio_rxglom()
6225 bus->nextlen = 0; in dhdsdio_rxglom()
6235 } else if (ROUNDUP(sublen, bus->blocksize) != dlen) { in dhdsdio_rxglom()
6237 __FUNCTION__, sublen, ROUNDUP(sublen, bus->blocksize), dlen)); in dhdsdio_rxglom()
6258 bus->rx_badseq++; in dhdsdio_rxglom()
6263 if ((uint8)(txmax - bus->tx_seq) > 0x70) { in dhdsdio_rxglom()
6265 __FUNCTION__, txmax, bus->tx_seq)); in dhdsdio_rxglom()
6266 txmax = bus->tx_max; in dhdsdio_rxglom()
6268 bus->tx_max = txmax; in dhdsdio_rxglom()
6313 if (bus->glomerr++ < 3) { in dhdsdio_rxglom()
6316 dhdsdio_rxfail(bus, TRUE, TRUE); in dhdsdio_rxglom()
6318 bus->glomerr = 0; in dhdsdio_rxglom()
6319 dhdsdio_rxfail(bus, TRUE, FALSE); in dhdsdio_rxglom()
6320 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_rxglom()
6321 PKTFREE(osh, bus->glom, FALSE); in dhdsdio_rxglom()
6322 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_rxglom()
6323 bus->rxglomfail++; in dhdsdio_rxglom()
6324 bus->glom = NULL; in dhdsdio_rxglom()
6326 bus->nextlen = 0; in dhdsdio_rxglom()
6331 bus->glom = NULL; in dhdsdio_rxglom()
6334 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_rxglom()
6354 bus->rx_badseq++; in dhdsdio_rxglom()
6370 PKTFREE(bus->dhd->osh, pfirst, FALSE); in dhdsdio_rxglom()
6372 } else if (dhd_prot_hdrpull(bus->dhd, &ifidx, pfirst, reorder_info_buf, in dhdsdio_rxglom()
6375 bus->dhd->rx_errors++; in dhdsdio_rxglom()
6385 dhd_process_pkt_reorder_info(bus->dhd, reorder_info_buf, in dhdsdio_rxglom()
6429 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_rxglom()
6441 dhd_os_sdunlock(bus->dhd); in dhdsdio_rxglom()
6442 dhd_rx_frame(bus->dhd, idx, list_head[idx], cnt, 0); in dhdsdio_rxglom()
6443 dhd_os_sdlock(bus->dhd); in dhdsdio_rxglom()
6447 bus->rxglomframes++; in dhdsdio_rxglom()
6448 bus->rxglompkts += num; in dhdsdio_rxglom()
6455 dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) argument
6457 osl_t *osh = bus->dhd->osh;
6458 bcmsdh_info_t *sdh = bus->sdh;
6488 bus->readframes = TRUE;
6490 if (!KSO_ENAB(bus)) {
6492 bus->readframes = FALSE;
6500 if (bus->pktgen_count && (bus->pktgen_mode == DHD_PKTGEN_RECV)) {
6501 maxframes = bus->pktgen_count;
6511 if (bus->bus == SPI_BUS) {
6513 dstatus = bcmsdh_get_dstatus(bus->sdh);
6520 bcmsdh_get_dstatus((void *)bus->sdh)));
6523 bus->nextlen = ((dstatus & STATUS_F2_PKT_LEN_MASK) >>
6526 bus->nextlen = (bus->nextlen == 0) ? SPI_MAX_PKT_LEN : bus->nextlen;
6527 if (bus->dwordmode)
6528 bus->nextlen = bus->nextlen << 2;
6530 __FUNCTION__, bus->nextlen));
6542 for (rxseq = bus->rx_seq, rxleft = maxframes;
6543 !bus->rxskip && rxleft && bus->dhd->busstate != DHD_BUS_DOWN;
6546 if (bus->dhd->tcpack_sup_mode != TCPACK_SUP_DELAYTX) {
6547 if (bus->dotxinrx == FALSE)
6549 __FUNCTION__, __LINE__, bus->dhd->tcpack_sup_mode));
6552 else if (pktq_mlen(&bus->txq, ~bus->flowcontrol) > 0) {
6553 tack_tbl.cnt[bus->dotxinrx ? 6 : 7]++;
6558 if (TXCTLOK(bus) && bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL)) {
6559 dhdsdio_sendpendctl(bus);
6560 } else if (bus->dotxinrx && (bus->clkstate == CLK_AVAIL) &&
6561 !bus->fcstate && DATAOK(bus) &&
6562 (pktq_mlen(&bus->txq, ~bus->flowcontrol) > bus->txinrx_thres)) {
6563 dhdsdio_sendfromq(bus, dhd_txbound);
6568 * in bus txq.
6570 bus->dotxinrx = (bus->dhd->tcpack_sup_mode == TCPACK_SUP_DELAYTX) ?
6576 if (bus->glom || bus->glomd) {
6579 __FUNCTION__, bus->glomd, bus->glom));
6580 cnt = dhdsdio_rxglom(bus, rxseq);
6588 if (dhd_readahead && bus->nextlen) {
6589 uint16 nextlen = bus->nextlen;
6590 bus->nextlen = 0;
6592 if (bus->bus == SPI_BUS) {
6598 if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) {
6599 pad = bus->blocksize - (rdlen % bus->blocksize);
6600 if ((pad <= bus->roundup) && (pad < bus->blocksize) &&
6608 /* We use bus->rxctl buffer in WinXP for initial control pkt receives.
6615 dhd_os_sdlock_rxq(bus->dhd);
6617 if (bus->bus == SPI_BUS) {
6618 bus->usebufpool = FALSE;
6619 bus->rxctl = bus->rxbuf;
6621 bus->rxctl += firstread;
6622 if ((pad = ((uintptr)bus->rxctl % DHD_SDALIGN)))
6623 bus->rxctl += (DHD_SDALIGN - pad);
6624 bus->rxctl -= firstread;
6626 ASSERT(bus->rxctl >= bus->rxbuf);
6627 rxbuf = bus->rxctl;
6629 sdret = dhd_bcmsdh_recv_buf(bus,
6634 bus->f2rxdata++;
6638 if (bcmsdh_get_dstatus((void *)bus->sdh) &
6640 bus->nextlen = 0;
6646 bus->rxc_errors++;
6647 dhd_os_sdunlock_rxq(bus->dhd);
6657 bus->rxc_errors++;
6658 dhd_os_sdunlock_rxq(bus->dhd);
6659 dhdsdio_rxfail(bus, TRUE,
6660 (bus->bus == SPI_BUS) ? FALSE : TRUE);
6669 dhd_os_sdunlock_rxq(bus->dhd);
6673 if (bus->bus == SPI_BUS)
6674 bus->usebufpool = TRUE;
6680 sdret = dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh),
6684 bus->f2rxdata++;
6687 if (bcmsdh_get_dstatus((void *)bus->sdh) & STATUS_UNDERFLOW) {
6688 bus->nextlen = 0;
6693 PKTFREE(bus->dhd->osh, pkt, FALSE);
6694 bus->dhd->rx_errors++;
6695 dhd_os_sdunlock_rxq(bus->dhd);
6703 PKTFREE(bus->dhd->osh, pkt, FALSE);
6704 bus->dhd->rx_errors++;
6705 dhd_os_sdunlock_rxq(bus->dhd);
6709 dhdsdio_rxfail(bus, TRUE,
6710 (bus->bus == SPI_BUS) ? FALSE : TRUE);
6714 dhd_os_sdunlock_rxq(bus->dhd);
6717 bcopy(rxbuf, bus->rxhdr, SDPCM_HDRLEN);
6720 len = ltoh16_ua(bus->rxhdr);
6721 check = ltoh16_ua(bus->rxhdr + sizeof(uint16));
6727 dhd_os_sdlock_rxq(bus->dhd);
6729 dhd_os_sdunlock_rxq(bus->dhd);
6739 dhd_os_sdlock_rxq(bus->dhd);
6741 dhd_os_sdunlock_rxq(bus->dhd);
6742 bus->rx_badhdr++;
6743 dhdsdio_rxfail(bus, FALSE, FALSE);
6752 dhd_os_sdlock_rxq(bus->dhd);
6754 dhd_os_sdunlock_rxq(bus->dhd);
6761 if (bus->bus == SPI_BUS) {
6762 if (bus->dwordmode) {
6776 dhd_os_sdlock_rxq(bus->dhd);
6778 dhd_os_sdunlock_rxq(bus->dhd);
6779 dhdsdio_rxfail(bus, TRUE, (bus->bus == SPI_BUS) ? FALSE : TRUE);
6785 chan = SDPCM_PACKET_CHANNEL(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
6786 seq = SDPCM_PACKET_SEQUENCE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
6787 doff = SDPCM_DOFFSET_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
6788 txmax = SDPCM_WINDOW_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
6792 if (bus->bus == SPI_BUS) {
6794 dstatus = bcmsdh_get_dstatus((void *)bus->sdh);
6796 bcmsdh_get_dstatus((void *)bus->sdh)));
6798 bus->nextlen = ((dstatus & STATUS_F2_PKT_LEN_MASK) >>
6800 bus->nextlen = (bus->nextlen == 0) ?
6801 SPI_MAX_PKT_LEN : bus->nextlen;
6802 if (bus->dwordmode)
6803 bus->nextlen = bus->nextlen << 2;
6805 bus->nextlen));
6806 bus->dhd->rx_readahead_cnt ++;
6808 bus->nextlen = 0;
6813 bus->nextlen =
6814 bus->rxhdr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET];
6815 if ((bus->nextlen << 4) > MAX_RX_DATASZ) {
6817 " (%d), seq %d\n", __FUNCTION__, bus->nextlen,
6819 bus->nextlen = 0;
6822 bus->dhd->rx_readahead_cnt ++;
6827 fcbits = SDPCM_FCMASK_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
6830 if (~bus->flowcontrol & fcbits) {
6831 bus->fc_xoff++;
6834 if (bus->flowcontrol & ~fcbits) {
6835 bus->fc_xon++;
6840 bus->fc_rcvd++;
6841 bus->flowcontrol = fcbits;
6848 bus->rx_badseq++;
6853 if ((uint8)(txmax - bus->tx_seq) > 0x70) {
6855 if ((bus->bus == SPI_BUS) && !(dstatus & STATUS_F2_RX_READY)) {
6857 __FUNCTION__, txmax, bus->tx_seq));
6858 txmax = bus->tx_seq + 2;
6862 __FUNCTION__, txmax, bus->tx_seq));
6863 txmax = bus->tx_max;
6868 bus->tx_max = txmax;
6874 prhex("RxHdr", bus->rxhdr, SDPCM_HDRLEN);
6879 if (bus->bus == SPI_BUS) {
6880 dhdsdio_read_control(bus, rxbuf, len, doff);
6881 if (bus->usebufpool) {
6882 dhd_os_sdlock_rxq(bus->dhd);
6883 PKTFREE(bus->dhd->osh, pkt, FALSE);
6884 dhd_os_sdunlock_rxq(bus->dhd);
6891 bus->nextlen = 0;
6892 dhdsdio_rxfail(bus, FALSE, TRUE);
6893 dhd_os_sdlock_rxq(bus->dhd);
6895 dhd_os_sdunlock_rxq(bus->dhd);
6900 if ((bus->bus == SPI_BUS) && !bus->usebufpool) {
6910 dhd_os_sdlock_rxq(bus->dhd);
6912 dhd_os_sdunlock_rxq(bus->dhd);
6914 dhdsdio_rxfail(bus, FALSE, FALSE);
6922 if (bus->bus == SPI_BUS) {
6927 sdret = dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC,
6928 bus->rxhdr, firstread, NULL, NULL, NULL);
6929 bus->f2rxhdrs++;
6934 bus->rx_hdrfail++;
6935 dhdsdio_rxfail(bus, TRUE, TRUE);
6941 prhex("RxHdr", bus->rxhdr, SDPCM_HDRLEN);
6946 len = ltoh16_ua(bus->rxhdr);
6947 check = ltoh16_ua(bus->rxhdr + sizeof(uint16));
6959 bus->rx_badhdr++;
6960 dhdsdio_rxfail(bus, FALSE, FALSE);
6971 chan = SDPCM_PACKET_CHANNEL(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
6972 seq = SDPCM_PACKET_SEQUENCE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
6973 doff = SDPCM_DOFFSET_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
6974 txmax = SDPCM_WINDOW_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
6980 bus->rx_badhdr++;
6982 dhdsdio_rxfail(bus, FALSE, FALSE);
6987 bus->nextlen = bus->rxhdr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET];
6988 if ((bus->nextlen << 4) > MAX_RX_DATASZ) {
6990 __FUNCTION__, bus->nextlen, seq));
6991 bus->nextlen = 0;
6995 fcbits = SDPCM_FCMASK_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]);
6998 if (~bus->flowcontrol & fcbits) {
6999 bus->fc_xoff++;
7002 if (bus->flowcontrol & ~fcbits) {
7003 bus->fc_xon++;
7008 bus->fc_rcvd++;
7009 bus->flowcontrol = fcbits;
7015 bus->rx_badseq++;
7020 if ((uint8)(txmax - bus->tx_seq) > 0x70) {
7022 __FUNCTION__, txmax, bus->tx_seq));
7023 txmax = bus->tx_max;
7025 bus->tx_max = txmax;
7029 dhdsdio_read_control(bus, bus->rxhdr, len, doff);
7040 if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) {
7041 pad = bus->blocksize - (rdlen % bus->blocksize);
7042 if ((pad <= bus->roundup) && (pad < bus->blocksize) &&
7056 bus->dhd->rx_errors++; bus->rx_toolong++;
7057 dhdsdio_rxfail(bus, FALSE, FALSE);
7061 dhd_os_sdlock_rxq(bus->dhd);
7066 bus->dhd->rx_dropped++;
7067 dhd_os_sdunlock_rxq(bus->dhd);
7068 dhdsdio_rxfail(bus, FALSE, RETRYCHAN(chan));
7071 dhd_os_sdunlock_rxq(bus->dhd);
7081 sdret = dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC,
7083 bus->f2rxdata++;
7090 dhd_os_sdlock_rxq(bus->dhd);
7091 PKTFREE(bus->dhd->osh, pkt, FALSE);
7092 dhd_os_sdunlock_rxq(bus->dhd);
7093 bus->dhd->rx_errors++;
7094 dhdsdio_rxfail(bus, TRUE, RETRYCHAN(chan));
7100 bcopy(bus->rxhdr, PKTDATA(osh, pkt), firstread);
7111 if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) {
7122 bus->glomd = pkt;
7125 dhdsdio_rxfail(bus, FALSE, FALSE);
7137 dhdsdio_testrcv(bus, pkt, seq);
7143 if ((chan == SDPCM_EVENT_CHANNEL) && (bus->sdpcmrev >= 17 && bus->sdpcmrev <= 22)) {
7147 dhd_os_sdlock_rxq(bus->dhd);
7148 PKTFREE(bus->dhd->osh, pkt, FALSE);
7149 dhd_os_sdunlock_rxq(bus->dhd);
7151 } else if (dhd_prot_hdrpull(bus->dhd, &ifidx, pkt, reorder_info_buf,
7154 dhd_os_sdlock_rxq(bus->dhd);
7155 PKTFREE(bus->dhd->osh, pkt, FALSE);
7156 dhd_os_sdunlock_rxq(bus->dhd);
7157 bus->dhd->rx_errors++;
7163 dhd_process_pkt_reorder_info(bus->dhd, reorder_info_buf, reorder_info_len,
7172 dhd_os_sdunlock(bus->dhd);
7173 dhd_rx_frame(bus->dhd, ifidx, pkt, pkt_count, chan);
7174 dhd_os_sdlock(bus->dhd);
7185 if (bus->rxskip)
7187 bus->rx_seq = rxseq;
7189 if (bus->reqbussleep)
7191 dhdsdio_bussleep(bus, TRUE);
7192 bus->reqbussleep = FALSE;
7194 bus->readframes = FALSE;
7200 dhdsdio_hostmail(dhd_bus_t *bus, uint32 *hmbd) argument
7202 sdpcmd_regs_t *regs = bus->regs;
7214 bus->f1regdata += 2;
7218 DHD_INFO(("Dongle reports NAK handled, expect rtx of %d\n", bus->rx_seq));
7219 if (!bus->rxskip) {
7222 bus->rxskip = FALSE;
7223 intstatus |= FRAME_AVAIL_MASK(bus);
7230 bus->sdpcm_ver = (hmb_data & HMB_DATA_VERSION_MASK) >> HMB_DATA_VERSION_SHIFT;
7231 if (bus->sdpcm_ver != SDPCM_PROT_VERSION)
7233 bus->sdpcm_ver, SDPCM_PROT_VERSION));
7235 DHD_INFO(("Dongle ready, protocol version %d\n", bus->sdpcm_ver));
7238 if ((bus->sih->buscoretype == SDIOD_CORE_ID) && (bus->sdpcmrev >= 4) &&
7239 (bus->rxint_mode == SDIO_DEVICE_RXDATAINT_MODE_1)) {
7242 val = R_REG(bus->dhd->osh, &bus->regs->corecontrol);
7245 W_REG(bus->dhd->osh, &bus->regs->corecontrol, val);
7247 val = R_REG(bus->dhd->osh, &bus->regs->corecontrol);
7255 if (dhdsdio_readshared(bus, &shared) == 0)
7256 bus->console_addr = shared.console_addr;
7269 if (fcbits & ~bus->flowcontrol)
7270 bus->fc_xoff++;
7271 if (bus->flowcontrol & ~fcbits)
7272 bus->fc_xon++;
7274 bus->fc_rcvd++;
7275 bus->flowcontrol = fcbits;
7280 DHD_ERROR(("INTERNAL ERROR: FIRMWARE HALTED : set BUS DOWN\n"));
7281 dhdsdio_checkdied(bus, NULL, 0);
7282 DHD_ERROR(("Not doing bus down untill memdump done \n"));
7304 dhdsdio_dpc(dhd_bus_t *bus) argument
7306 bcmsdh_info_t *sdh = bus->sdh;
7307 sdpcmd_regs_t *regs = bus->regs;
7321 dhd_os_sdlock(bus->dhd);
7322 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
7323 if (bus->dhd->busstate == DHD_BUS_DOWN) {
7324 DHD_ERROR(("%s: Bus down, ret\n", __FUNCTION__));
7325 bus->intstatus = 0;
7326 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
7327 dhd_os_sdunlock(bus->dhd);
7331 DHD_BUS_BUSY_SET_IN_DPC(bus->dhd);
7332 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
7335 intstatus = bus->intstatus;
7337 if (!SLPAUTO_ENAB(bus) && !KSO_ENAB(bus)) {
7343 if (!SLPAUTO_ENAB(bus) && (bus->clkstate == CLK_PENDING)) {
7353 bus->dhd->busstate = DHD_BUS_DOWN;
7364 bus->dhd->busstate = DHD_BUS_DOWN;
7375 bus->dhd->busstate = DHD_BUS_DOWN;
7383 bus->dhd->busstate = DHD_BUS_DOWN;
7385 bus->clkstate = CLK_AVAIL;
7391 BUS_WAKE(bus);
7394 dhdsdio_clkctl(bus, CLK_AVAIL, TRUE);
7395 if (bus->clkstate != CLK_AVAIL)
7399 if (bus->ipend) {
7400 bus->ipend = FALSE;
7406 bus->f1regdata++;
7407 if (bcmsdh_regfail(bus->sdh))
7409 newstatus &= bus->hostintmask;
7410 bus->fcstate = !!(newstatus & I_HMB_FC_STATE);
7412 bus->f1regdata++;
7414 if ((bus->rxint_mode == SDIO_DEVICE_RXDATAINT_MODE_0) &&
7424 bus->intstatus = 0;
7434 bus->f1regdata += 2;
7435 bus->fcstate = !!(newstatus & (I_HMB_FC_STATE | I_HMB_FC_CHANGE));
7436 intstatus |= (newstatus & bus->hostintmask);
7444 intstatus |= dhdsdio_hostmail(bus, &hmbdata);
7450 bcmsdh_force_sbwad_calc(bus->sdh, FALSE);
7452 if (dhd_ulp_pre_redownload_check(bus->dhd, bus->sdh, hmbdata)) {
7453 if (dhd_bus_ulp_reinit_fw(bus) < 0) {
7469 /* ASSERT(bus->clkstate == CLK_AVAIL); */
7476 intstatus |= dhdsdio_hostmail(bus, NULL);
7507 if (bus->rxskip) {
7508 intstatus &= ~FRAME_AVAIL_MASK(bus);
7512 if (PKT_AVAILABLE(bus, intstatus)) {
7514 framecnt = dhdsdio_readframes(bus, rxlimit, &rxdone);
7515 if (rxdone || bus->rxskip)
7516 intstatus &= ~FRAME_AVAIL_MASK(bus);
7521 bus->intstatus = intstatus;
7528 if (bus->intr && bus->intdis && !bcmsdh_regfail(sdh)) {
7531 bus->intdis = FALSE;
7533 bcmsdh_oob_intr_set(bus->sdh, TRUE);
7538 bcmsdh_oob_intr_set(bus->sdh, TRUE);
7550 if (bcmsdh_regfail(bus->sdh))
7552 if (newstatus & bus->hostintmask) {
7553 bus->ipend = TRUE;
7559 dhd_wlfc_commit_packets(bus->dhd, (f_commitpkt_t)dhd_bus_txdata, (void *)bus, NULL, FALSE);
7562 if (TXCTLOK(bus) && bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL))
7563 dhdsdio_sendpendctl(bus);
7566 else if ((bus->clkstate == CLK_AVAIL) && !bus->fcstate &&
7567 pktq_mlen(&bus->txq, ~bus->flowcontrol) && txlimit && DATAOK(bus)) {
7570 if (dhd_ulp_f2_ready(bus->dhd, bus->sdh)) {
7573 framecnt = dhdsdio_sendfromq(bus, framecnt);
7585 /* Resched the DPC if ctrl cmd is pending on bus credit */
7586 if (bus->ctrl_frame_stat)
7591 if ((bus->dhd->busstate == DHD_BUS_DOWN) || bcmsdh_regfail(sdh)) {
7592 if ((bus->sih && bus->sih->buscorerev >= 12) && !(dhdsdio_sleepcsr_get(bus) &
7594 /* Bus failed because of KSO */
7595 DHD_ERROR(("%s: Bus failed due to KSO\n", __FUNCTION__));
7596 bus->kso = FALSE;
7601 bus->dhd->busstate = DHD_BUS_DOWN;
7602 bus->intstatus = 0;
7604 } else if (bus->clkstate == CLK_PENDING) {
7606 } else if (bus->intstatus || bus->ipend ||
7607 (!bus->fcstate && pktq_mlen(&bus->txq, ~bus->flowcontrol) && DATAOK(bus)) ||
7608 PKT_AVAILABLE(bus, bus->intstatus)) { /* Read multiple frames */
7612 bus->dpc_sched = resched;
7615 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && (bus->clkstate != CLK_PENDING) &&
7616 NO_OTHER_ACTIVE_BUS_USER(bus)) {
7617 bus->activity = FALSE;
7618 dhdsdio_bussleep(bus, TRUE);
7619 dhdsdio_clkctl(bus, CLK_NONE, FALSE);
7625 if (dhdsdio_readframes(bus, dhd_rxbound, &rxdone) != 0) {
7633 dhd_os_sdunlock(bus->dhd);
7635 if (bus->dhd->dhd_bug_on) {
7638 __FUNCTION__, resched, bus->ctrl_frame_stat,
7639 bus->intstatus, bus->ipend,
7640 pktq_mlen(&bus->txq, ~bus->flowcontrol), is_resched_by_readframe));
7642 bus->dhd->dhd_bug_on = FALSE;
7646 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
7647 DHD_BUS_BUSY_CLEAR_IN_DPC(bus->dhd);
7648 dhd_os_busbusy_wake(bus->dhd);
7649 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
7655 dhd_bus_dpc(struct dhd_bus *bus) argument
7661 resched = dhdsdio_dpc(bus);
7669 dhd_bus_t *bus = (dhd_bus_t*)arg; local
7674 if (!bus) {
7675 DHD_ERROR(("%s : bus is null pointer , exit \n", __FUNCTION__));
7678 sdh = bus->sdh;
7680 if (bus->dhd->busstate == DHD_BUS_DOWN) {
7681 DHD_ERROR(("%s : bus is down. we have nothing to do\n", __FUNCTION__));
7688 bus->intrcount++;
7689 bus->ipend = TRUE;
7692 if (!SLPAUTO_ENAB(bus)) {
7693 if (bus->sleeping) {
7696 } else if (!KSO_ENAB(bus)) {
7702 if (bus->intr) {
7709 bcmsdh_oob_intr_set(bus->sdh, FALSE);
7712 bus->intdis = TRUE;
7716 DHD_OS_WAKE_LOCK(bus->dhd);
7717 dhdsdio_dpc(bus);
7718 DHD_OS_WAKE_UNLOCK(bus->dhd);
7720 bus->dpc_sched = TRUE;
7721 dhd_sched_dpc(bus->dhd);
7728 dhdsdio_pktgen_init(dhd_bus_t *bus) argument
7732 bus->pktgen_maxlen = MIN(dhd_pktgen_len, MAX_PKTGEN_LEN);
7733 bus->pktgen_minlen = bus->pktgen_maxlen;
7735 bus->pktgen_maxlen = MAX_PKTGEN_LEN;
7736 bus->pktgen_minlen = 0;
7738 bus->pktgen_len = (uint16)bus->pktgen_minlen;
7741 bus->pktgen_freq = 1;
7742 bus->pktgen_print = dhd_watchdog_ms ? (10000 / dhd_watchdog_ms) : 0;
7743 bus->pktgen_count = (dhd_pktgen * dhd_watchdog_ms + 999) / 1000;
7746 bus->pktgen_mode = DHD_PKTGEN_ECHO;
7747 bus->pktgen_stop = 1;
7751 dhdsdio_pktgen(dhd_bus_t *bus) argument
7757 osl_t *osh = bus->dhd->osh;
7764 if (bus->pktgen_print && (++bus->pktgen_ptick >= bus->pktgen_print)) {
7765 bus->pktgen_ptick = 0;
7767 __FUNCTION__, bus->pktgen_sent, bus->pktgen_rcvd, bus->pktgen_fail);
7770 if (bus->pktgen_minlen == bus->pktgen_maxlen) {
7771 time_lapse = jiffies - bus->pktgen_prev_time;
7772 bus->pktgen_prev_time = jiffies;
7773 sent_pkts = bus->pktgen_sent - bus->pktgen_prev_sent;
7774 bus->pktgen_prev_sent = bus->pktgen_sent;
7775 rcvd_pkts = bus->pktgen_rcvd - bus->pktgen_prev_rcvd;
7776 bus->pktgen_prev_rcvd = bus->pktgen_rcvd;
7780 (sent_pkts * bus->pktgen_len / jiffies_to_msecs(time_lapse)) * 8,
7781 (rcvd_pkts * bus->pktgen_len / jiffies_to_msecs(time_lapse)) * 8);
7786 if (bus->pktgen_mode == DHD_PKTGEN_RECV) {
7787 if (bus->pktgen_rcv_state == PKTGEN_RCV_IDLE) {
7788 bus->pktgen_rcv_state = PKTGEN_RCV_ONGOING;
7789 dhdsdio_sdtest_set(bus, bus->pktgen_total);
7795 for (pktcount = 0; pktcount < bus->pktgen_count; pktcount++) {
7797 if (bus->pktgen_total && (bus->pktgen_sent >= bus->pktgen_total)) {
7798 bus->pktgen_count = 0;
7803 if (bus->pktgen_mode == DHD_PKTGEN_RXBURST) {
7806 len = bus->pktgen_len;
7817 switch (bus->pktgen_mode) {
7820 *data++ = (uint8)bus->pktgen_sent;
7825 *data++ = (uint8)bus->pktgen_sent;
7830 *data++ = (uint8)bus->pktgen_count; /* Just for backward compatability */
7834 DHD_ERROR(("Unrecognized pktgen mode %d\n", bus->pktgen_mode));
7836 bus->pktgen_count = 0;
7841 *data++ = (bus->pktgen_len >> 0);
7842 *data++ = (bus->pktgen_len >> 8);
7847 if (bus->pktgen_mode == DHD_PKTGEN_RXBURST) {
7848 *data++ = (uint8)(bus->pktgen_count >> 0);
7849 *data++ = (uint8)(bus->pktgen_count >> 8);
7850 *data++ = (uint8)(bus->pktgen_count >> 16);
7851 *data++ = (uint8)(bus->pktgen_count >> 24);
7856 *data++ = SDPCM_TEST_FILL(fillbyte, (uint8)bus->pktgen_sent);
7867 if (dhdsdio_txpkt(bus, SDPCM_TEST_CHANNEL, &pkt, 1, TRUE) != BCME_OK) {
7868 bus->pktgen_fail++;
7869 if (bus->pktgen_stop && bus->pktgen_stop == bus->pktgen_fail)
7870 bus->pktgen_count = 0;
7872 bus->pktgen_sent++;
7875 if (++bus->pktgen_len > bus->pktgen_maxlen)
7876 bus->pktgen_len = (uint16)bus->pktgen_minlen;
7879 if (bus->pktgen_mode == DHD_PKTGEN_RXBURST)
7885 dhdsdio_sdtest_set(dhd_bus_t *bus, uint count) argument
7889 osl_t *osh = bus->dhd->osh;
7904 *data++ = (bus->pktgen_maxlen >> 0);
7905 *data++ = (bus->pktgen_maxlen >> 8);
7912 if (dhdsdio_txpkt(bus, SDPCM_TEST_CHANNEL, &pkt, 1, TRUE) != BCME_OK)
7913 bus->pktgen_fail++;
7917 dhdsdio_testrcv(dhd_bus_t *bus, void *pkt, uint seq) argument
7919 osl_t *osh = bus->dhd->osh;
7956 if (dhdsdio_txpkt(bus, SDPCM_TEST_CHANNEL, &pkt, 1, TRUE) == BCME_OK) {
7957 bus->pktgen_sent++;
7959 bus->pktgen_fail++;
7962 bus->pktgen_rcvd++;
7966 if (bus->ext_loop) {
7968 bus->pktgen_rcvd++;
7981 bus->pktgen_rcvd++;
7992 i, bus->pktgen_rcvd_rcvsession, testval, *prn));
7998 bus->pktgen_rcvd++;
8011 if (bus->pktgen_mode == DHD_PKTGEN_RECV) {
8012 if (bus->pktgen_rcv_state != PKTGEN_RCV_IDLE) {
8013 bus->pktgen_rcvd_rcvsession++;
8015 if (bus->pktgen_total &&
8016 (bus->pktgen_rcvd_rcvsession >= bus->pktgen_total)) {
8017 bus->pktgen_count = 0;
8019 bus->pktgen_rcv_state = PKTGEN_RCV_IDLE;
8020 dhdsdio_sdtest_set(bus, FALSE);
8021 bus->pktgen_rcvd_rcvsession = 0;
8033 err = bcmsdh_oob_intr_register(dhdp->bus->sdh, dhdsdio_isr, dhdp->bus);
8041 bcmsdh_oob_intr_unregister(dhdp->bus->sdh);
8048 bcmsdh_oob_intr_set(dhdp->bus->sdh, enable);
8054 bcmsdh_dev_pm_stay_awake(dhdpub->bus->sdh);
8059 bcmsdh_dev_relax(dhdpub->bus->sdh);
8066 enabled = bcmsdh_dev_pm_enabled(dhdpub->bus->sdh);
8073 dhd_bus_t *bus; local
8078 bus = dhdp->bus;
8080 if (bus->dhd->dongle_reset)
8083 if (bus->dhd->hang_was_sent) {
8084 dhd_os_wd_timer(bus->dhd, 0);
8088 /* Ignore the timer if simulating bus down */
8089 if (!SLPAUTO_ENAB(bus) && bus->sleeping)
8101 dhd_os_sdlock(bus->dhd);
8104 if (!SLPAUTO_ENAB(bus) && (bus->poll && (++bus->polltick >= bus->pollrate))) {
8108 bus->polltick = 0;
8111 if (!bus->intr || (bus->intrcount == bus->lastintrs)) {
8114 if (!bus->dpc_sched) {
8116 devpend = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0,
8121 if (!bus->dpc_sched) {
8123 devpend = bcmsdh_cfg_read_word(bus->sdh, SDIO_FUNC_0,
8131 bus->pollcnt++;
8132 bus->ipend = TRUE;
8133 if (bus->intr) {
8134 bcmsdh_intr_disable(bus->sdh);
8136 bus->dpc_sched = TRUE;
8137 dhd_sched_dpc(bus->dhd);
8142 bus->lastintrs = bus->intrcount;
8148 bus->console.count += dhd_watchdog_ms;
8149 if (bus->console.count >= dhdp->dhd_console_ms) {
8150 bus->console.count -= dhdp->dhd_console_ms;
8152 if (SLPAUTO_ENAB(bus))
8153 dhdsdio_bussleep(bus, FALSE);
8155 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
8156 if (dhdsdio_readconsole(bus) < 0)
8164 if (bus->pktgen_count && (++bus->pktgen_tick >= bus->pktgen_freq)) {
8166 if (SLPAUTO_ENAB(bus))
8167 dhdsdio_bussleep(bus, FALSE);
8169 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
8170 bus->pktgen_tick = 0;
8171 dhdsdio_pktgen(bus);
8177 if (bus->activity)
8178 bus->activity = FALSE;
8180 bus->idlecount++;
8195 * bus->idletime != 0 instead of idletime == 0
8197 if ((bus->idletime != 0) && (bus->idlecount >= bus->idletime) &&
8198 NO_OTHER_ACTIVE_BUS_USER(bus)) {
8200 if (SLPAUTO_ENAB(bus)) {
8201 if (dhdsdio_bussleep(bus, TRUE) != BCME_BUSY)
8202 dhd_os_wd_timer(bus->dhd, 0);
8204 dhdsdio_clkctl(bus, CLK_NONE, FALSE);
8206 bus->idlecount = 0;
8210 if ((bus->idletime != 0) && (bus->clkstate == CLK_AVAIL) &&
8211 NO_OTHER_ACTIVE_BUS_USER(bus)) {
8212 if (++bus->idlecount >= bus->idletime) {
8213 bus->idlecount = 0;
8214 if (bus->activity) {
8215 bus->activity = FALSE;
8219 if (SLPAUTO_ENAB(bus)) {
8220 if (!bus->readframes)
8221 dhdsdio_bussleep(bus, TRUE);
8223 bus->reqbussleep = TRUE;
8225 dhdsdio_clkctl(bus, CLK_NONE, FALSE);
8232 dhd_os_sdunlock(bus->dhd);
8239 return bus->ipend;
8245 dhd_bus_t *bus = dhdp->bus; local
8251 if (bus->console_addr == 0)
8254 /* Exclusive bus access */
8255 dhd_os_sdlock(bus->dhd);
8258 if (bus->dhd->dongle_reset) {
8259 dhd_os_sdunlock(bus->dhd);
8264 BUS_WAKE(bus);
8266 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
8269 addr = bus->console_addr + OFFSETOF(hnd_cons_t, cbuf_idx);
8271 if ((rv = dhdsdio_membytes(bus, TRUE, addr, (uint8 *)&val, sizeof(val))) < 0)
8275 addr = bus->console_addr + OFFSETOF(hnd_cons_t, cbuf);
8276 if ((rv = dhdsdio_membytes(bus, TRUE, addr, (uint8 *)msg, msglen)) < 0)
8280 addr = bus->console_addr + OFFSETOF(hnd_cons_t, vcons_in);
8282 if ((rv = dhdsdio_membytes(bus, TRUE, addr, (uint8 *)&val, sizeof(val))) < 0)
8288 if ((pkt = PKTGET(bus->dhd->osh, 4 + SDPCM_RESERVE, TRUE)) != NULL)
8289 rv = dhdsdio_txpkt(bus, SDPCM_EVENT_CHANNEL, &pkt, 1, TRUE);
8292 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched &&
8293 NO_OTHER_ACTIVE_BUS_USER(bus)) {
8294 bus->activity = FALSE;
8295 dhdsdio_bussleep(bus, TRUE);
8296 dhdsdio_clkctl(bus, CLK_NONE, FALSE);
8299 dhd_os_sdunlock(bus->dhd);
8389 dhd_bus_t *bus; local
8476 /* Allocate private bus interface state */
8477 if (!(bus = MALLOC(osh, sizeof(dhd_bus_t)))) {
8481 bzero(bus, sizeof(dhd_bus_t));
8482 bus->sdh = sdh;
8483 bus->cl_devid = (uint16)devid;
8484 bus->bus = DHD_BUS;
8485 bus->bus_num = bus_no;
8486 bus->slot_num = slot;
8487 bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1;
8488 bus->usebufpool = FALSE; /* Use bufpool if allocated, else use locally malloced rxbuf */
8490 bus->bt_use_count = 0;
8494 init_waitqueue_head(&bus->bus_sleep);
8498 if (!(dhdsdio_probe_attach(bus, osh, sdh, regsva, devid))) {
8504 if (!(bus->dhd = dhd_attach(osh, bus, SDPCM_RESERVE))) {
8510 if (!(dhdsdio_probe_malloc(bus, osh, sdh))) {
8515 if (!(dhdsdio_probe_init(bus, osh, sdh))) {
8520 if (bus->intr) {
8524 if ((ret = bcmsdh_intr_reg(sdh, dhdsdio_isr, bus)) != 0) {
8537 /* if firmware path present try to download and bring up bus */
8538 bus->dhd->hang_report = TRUE;
8540 if ((ret = dhd_bus_start(bus->dhd)) != 0) {
8550 get_random_bytes(&bus->dhd->mac.octet[3], 3);
8552 bus->dhd->mac.octet[0] = 0;
8553 bus->dhd->mac.octet[1] = 0x90;
8554 bus->dhd->mac.octet[2] = 0x4C;
8557 /* At this point Regulators are turned on and iconditionaly sdio bus is started
8559 * increase the bus user count, this count will only be disabled inside
8562 * so that WALN will always hold the bus untill rmmod is done.
8564 dhdsdio_bus_usr_cnt_inc(bus->dhd);
8568 if (dhd_attach_net(bus->dhd, TRUE) != 0)
8575 bcmsdh_reg_write(bus->sdh, 0x18000620, 2, 11);
8576 bcmsdh_reg_write(bus->sdh, 0x18000628, 4, 0x00F80001);
8584 return bus;
8587 dhdsdio_release(bus, osh);
8599 dhdsdio_probe_attach(struct dhd_bus *bus, osl_t *osh, void *sdh, void *regsva, argument
8616 bus->alp_only = TRUE;
8617 bus->sih = NULL;
8623 bus->secureboot = TRUE;
8627 bus->chipidpresent = true;
8630 cardcap = dhdsdio_devcap_get(bus);
8633 bus->secureboot = TRUE;
8637 bus->chipidpresent = true;
8641 if (bus->secureboot) {
8643 dhdsdio_dongle_host_get_handshake_address(bus, &bl_hs_addrs);
8644 err = dhdsdio_wait_bootloader_ready(bus, &bl_hs_addrs);
8651 if (bus->chipidpresent) {
8653 bus->regs = si_get_sdio_addrbase(sdh);
8657 if (dhdsdio_set_siaddr_window(bus, si_enum_base(devid))) {
8662 if (bus->chipidpresent) {
8664 (unsigned long)&bus->regs->chipid, R_REG(osh, &bus->regs->chipid)));
8667 bcmsdh_reg_read(bus->sdh, si_enum_base(devid), 4)));
8706 bus->blocksize = 0;
8721 /* Now request ALP be put on the bus */
8767 bus->blocksize = 0;
8818 if (!(bus->sih = si_attach((uint)devid, osh, regsva, DHD_BUS, sdh,
8819 &bus->vars, &bus->varsz))) {
8826 bus->sih->socitype, bus->sih->chip, bus->sih->chiprev, bus->sih->chippkg));
8830 bus->chipmodule = sd_chip_module;
8833 bcmsdh_chipinfo(sdh, bus->sih->chip, bus->sih->chiprev);
8835 if (!dhdsdio_chipmatch((uint16)bus->sih->chip)) {
8837 __FUNCTION__, bus->sih->chip));
8841 if (bus->sih->buscorerev >= 12)
8842 dhdsdio_clk_kso_init(bus);
8844 bus->kso = TRUE;
8846 si_sdiod_drive_strength_init(bus->sih, osh, dhd_sdiod_drive_strength);
8849 if (!DHD_NOPMU(bus)) {
8850 if ((si_setcore(bus->sih, ARM7S_CORE_ID, 0)) ||
8851 (si_setcore(bus->sih, ARMCM3_CORE_ID, 0)) ||
8852 (si_setcore(bus->sih, ARMCR4_CORE_ID, 0))) {
8853 bus->armrev = si_corerev(bus->sih);
8859 if (!si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) {
8860 if (!(bus->orig_ramsize = si_socram_size(bus->sih))) {
8866 if (!(bus->orig_ramsize = si_tcm_size(bus->sih))) {
8871 switch ((uint16)bus->sih->chip) {
8874 bus->dongle_ram_base = CR4_4335_RAM_BASE;
8879 bus->dongle_ram_base = CR4_4350_RAM_BASE;
8882 bus->dongle_ram_base = CR4_4360_RAM_BASE;
8885 bus->dongle_ram_base = (bus->sih->chiprev < 6) /* from 4345C0 */
8890 bus->dongle_ram_base = ((bus->sih->chiprev < 9) ?
8894 bus->dongle_ram_base = CR4_4373_RAM_BASE;
8910 bus->dongle_ram_base = CR4_4364_RAM_BASE;
8913 bus->dongle_ram_base = CR4_4362_RAM_BASE;
8916 bus->dongle_ram_base = CR4_43751_RAM_BASE;
8919 bus->dongle_ram_base = CR4_4369_RAM_BASE;
8922 bus->dongle_ram_base = CR4_55500_RAM_BASE;
8925 bus->dongle_ram_base = CR4_55560_RAM_BASE;
8929 bus->dongle_ram_base = CR4_4378_RAM_BASE;
8933 bus->dongle_ram_base = 0;
8935 __FUNCTION__, bus->dongle_ram_base));
8941 if (bus->sih->chip == CYW55500_CHIP_ID) {
8942 bus->orig_ramsize -= (CR4_55500_TCAM_SZ + CR4_55500_TRX_HDR_SZ);
8943 } else if (bus->sih->chip == CYW55560_CHIP_ID) {
8944 bus->orig_ramsize -= (CR4_55560_TCAM_SZ + CR4_55560_TRX_HDR_SZ);
8947 bus->ramsize = bus->orig_ramsize;
8949 dhd_dongle_setramsize(bus, dhd_dongle_ramsize);
8952 bus->ramsize, bus->orig_ramsize, bus->dongle_ram_base));
8954 bus->srmemsize = si_socram_srmem_size(bus->sih);
8959 if (!(bus->regs = si_setcore(bus->sih, CC_CORE_ID, 0))) {
8964 if (!(bus->regs = si_setcore(bus->sih, PCMCIA_CORE_ID, 0)) &&
8965 !(bus->regs = si_setcore(bus->sih, SDIOD_CORE_ID, 0))) {
8970 bus->sdpcmrev = si_corerev(bus->sih);
8973 OR_REG(osh, &bus->regs->corecontrol, CC_BPRESEN);
8975 bus->rxint_mode = SDIO_DEVICE_HMB_RXINT;
8977 if ((bus->sih->buscoretype == SDIOD_CORE_ID) && (bus->sdpcmrev >= 4) &&
8978 (bus->rxint_mode == SDIO_DEVICE_RXDATAINT_MODE_1))
8982 val = R_REG(osh, &bus->regs->corecontrol);
8985 W_REG(osh, &bus->regs->corecontrol, val);
8989 pktq_init(&bus->txq, (PRIOMASK + 1), QLEN);
8992 bus->rxhdr = (uint8 *)ROUNDUP((uintptr)&bus->hdrbuf[0], DHD_SDALIGN);
8995 bus->intr = (bool)dhd_intr;
8996 if ((bus->poll = (bool)dhd_poll))
8997 bus->pollrate = 1;
9000 bus->txglomsize = SDPCM_DEFGLOM_SIZE;
9005 if (bus->sih != NULL) {
9006 si_detach(bus->sih);
9007 bus->sih = NULL;
9013 dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh) argument
9017 if (bus->dhd->maxctl) {
9018 bus->rxblen = ROUNDUP((bus->dhd->maxctl+SDPCM_HDRLEN), ALIGNMENT) + DHD_SDALIGN;
9019 if (!(bus->rxbuf = DHD_OS_PREALLOC(bus->dhd, DHD_PREALLOC_RXBUF, bus->rxblen))) {
9021 __FUNCTION__, bus->rxblen));
9026 if (!(bus->databuf = DHD_OS_PREALLOC(bus->dhd, DHD_PREALLOC_DATABUF, MAX_DATA_BUF))) {
9030 if (!bus->rxblen)
9031 DHD_OS_PREFREE(bus->dhd, bus->rxbuf, bus->rxblen);
9036 bus->membuf = MALLOC(osh, MAX_MEM_BUF);
9037 if (bus->membuf == NULL) {
9039 if (bus->databuf) {
9041 MFREE(osh, bus->databuf, MAX_DATA_BUF);
9043 bus->databuf = NULL;
9045 if (!bus->rxblen)
9046 DHD_OS_PREFREE(bus->dhd, bus->rxbuf, bus->rxblen);
9049 memset(bus->membuf, 0, MAX_MEM_BUF);
9053 if ((uintptr)bus->databuf % DHD_SDALIGN)
9054 bus->dataptr = bus->databuf + (DHD_SDALIGN - ((uintptr)bus->databuf % DHD_SDALIGN));
9056 bus->dataptr = bus->databuf;
9065 dhdsdio_probe_init(dhd_bus_t *bus, osl_t *osh, void *sdh) argument
9071 bus->_srenab = FALSE;
9074 dhdsdio_pktgen_init(bus);
9083 bus->dhd->busstate = DHD_BUS_DOWN;
9084 bus->sleeping = FALSE;
9085 bus->rxflow = FALSE;
9086 bus->prev_rxlim_hit = 0;
9094 bus->clkstate = CLK_SDONLY;
9095 bus->idletime = (int32)dhd_idletime;
9096 bus->idleclock = DHD_IDLE_ACTIVE;
9100 &bus->sd_divisor, sizeof(int32), FALSE) != BCME_OK) {
9102 bus->sd_divisor = -1;
9105 __FUNCTION__, "sd_divisor", bus->sd_divisor));
9108 /* Query the SD bus mode */
9110 &bus->sd_mode, sizeof(int32), FALSE) != BCME_OK) {
9112 bus->sd_mode = -1;
9115 __FUNCTION__, "sd_mode", bus->sd_mode));
9121 &bus->blocksize, sizeof(int32), FALSE) != BCME_OK) {
9122 bus->blocksize = 0;
9126 __FUNCTION__, fnum, "sd_blocksize", bus->blocksize));
9128 dhdsdio_tune_fifoparam(bus);
9130 bus->roundup = MIN(max_roundup, bus->blocksize);
9133 if (bus->pad_pkt)
9134 PKTFREE(osh, bus->pad_pkt, FALSE);
9135 bus->pad_pkt = PKTGET(osh, SDIO_MAX_BLOCK_SIZE, FALSE);
9136 if (bus->pad_pkt == NULL)
9140 uintptr pktprt = (uintptr)PKTDATA(osh, bus->pad_pkt);
9142 PKTPUSH(osh, bus->pad_pkt, alignment_offset);
9143 PKTSETNEXT(osh, bus->pad_pkt, NULL);
9147 /* Query if bus module supports packet chaining, default to use if supported */
9149 &bus->sd_rxchain, sizeof(int32), FALSE) != BCME_OK) {
9150 bus->sd_rxchain = FALSE;
9152 DHD_INFO(("%s: bus module (through bcmsdh API) %s chaining\n",
9153 __FUNCTION__, (bus->sd_rxchain ? "supports" : "does not support")));
9155 bus->use_rxchain = (bool)bus->sd_rxchain;
9156 bus->txinrx_thres = CUSTOM_TXINRX_THRES;
9158 bus->dotxinrx = TRUE;
9164 dhd_bus_download_firmware(struct dhd_bus *bus, osl_t *osh, argument
9169 bus->fw_path = pfw_path;
9170 bus->nv_path = pnv_path;
9172 ret = dhdsdio_download_firmware(bus, osh, bus->sdh);
9176 if (((bus->sih->chip == BCM4329_CHIP_ID) && (bus->sih->chiprev > 1)) ||
9177 (bus->sih->chip == BCM43430_CHIP_ID)) {
9178 bcmsdh_dwordmode(bus->sdh, TRUE);
9179 bus->dwordmode = TRUE;
9188 dhdsdio_download_firmware(struct dhd_bus *bus, osl_t *osh, void *sdh) argument
9193 if (concate_revision(bus, bus->fw_path, bus->nv_path) != 0) {
9201 dhd_set_blob_support(bus->dhd, bus->fw_path);
9205 __FUNCTION__, bus->fw_path, bus->nv_path));
9206 DHD_OS_WAKE_LOCK(bus->dhd);
9209 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
9211 ret = _dhdsdio_download_firmware(bus);
9213 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE);
9215 DHD_OS_WAKE_UNLOCK(bus->dhd);
9221 dhdsdio_release(dhd_bus_t *bus, osl_t *osh) argument
9226 if (bus) {
9229 if (bus->dhd) {
9233 dongle_isolation = bus->dhd->dongle_isolation;
9234 dhd_detach(bus->dhd);
9238 bcmsdh_intr_disable(bus->sdh);
9239 bcmsdh_intr_dereg(bus->sdh);
9241 if (bus->dhd) {
9242 dhdsdio_release_dongle(bus, osh, dongle_isolation, TRUE);
9243 dhd_free(bus->dhd);
9244 bus->dhd = NULL;
9247 dhdsdio_release_malloc(bus, osh);
9250 if (bus->console.buf != NULL)
9251 MFREE(osh, bus->console.buf, bus->console.bufsize);
9255 if (bus->pad_pkt)
9256 PKTFREE(osh, bus->pad_pkt, FALSE);
9259 MFREE(osh, bus, sizeof(dhd_bus_t));
9266 dhdsdio_release_malloc(dhd_bus_t *bus, osl_t *osh) argument
9270 if (bus->dhd && bus->dhd->dongle_reset)
9273 if (bus->rxbuf) {
9275 MFREE(osh, bus->rxbuf, bus->rxblen);
9277 bus->rxctl = bus->rxbuf = NULL;
9278 bus->rxlen = 0;
9281 if (bus->databuf) {
9283 MFREE(osh, bus->databuf, MAX_DATA_BUF);
9285 bus->databuf = NULL;
9289 if (bus->membuf) {
9290 MFREE(osh, bus->membuf, MAX_MEM_BUF);
9291 bus->membuf = NULL;
9295 if (bus->vars && bus->varsz) {
9296 MFREE(osh, bus->vars, bus->varsz);
9297 bus->vars = NULL;
9303 dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh, bool dongle_isolation, bool reset_flag) argument
9309 DHD_TRACE(("%s: Enter bus->dhd %p bus->dhd->dongle_reset %d \n", __FUNCTION__,
9310 bus->dhd, bus->dhd->dongle_reset));
9312 if ((bus->dhd && bus->dhd->dongle_reset) && reset_flag)
9315 if (bus->sih) {
9319 if (bus->dhd) {
9320 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
9322 if (KSO_ENAB(bus) && (dongle_isolation == FALSE)) {
9323 if (bus->secureboot) {
9331 dhdsdio_dongle_host_pre_wd_reset_sequence(bus)))
9338 if (bus->chipidpresent) {
9345 cardctl = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0,
9349 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0,
9354 bcmerror = bcmsdh_abort(bus->sdh, SDIO_FUNC_0 | 0x8);
9359 si_watchdog(bus->sih, 4);
9364 if (bus->dhd) {
9365 dhdsdio_clkctl(bus, CLK_NONE, FALSE);
9367 si_detach(bus->sih);
9368 bus->sih = NULL;
9369 if (bus->vars && bus->varsz)
9370 MFREE(osh, bus->vars, bus->varsz);
9371 bus->vars = NULL;
9380 dhd_bus_t *bus = (dhd_bus_t *)ptr; local
9393 if (bus) {
9394 ASSERT(bus->dhd);
9395 /* Advertise bus cleanup during rmmod */
9396 dhdsdio_advertise_bus_cleanup(bus->dhd);
9397 dhdsdio_release(bus, bus->dhd->osh);
9416 dhd_bus_t *bus = (dhd_bus_t*)context; local
9420 if (bus->dhd == NULL) {
9421 DHD_ERROR(("bus not inited\n"));
9424 if (bus->dhd->prot == NULL) {
9429 if (bus->dhd->up == FALSE) {
9433 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
9434 if (bus->dhd->busstate != DHD_BUS_DATA && bus->dhd->busstate != DHD_BUS_SUSPEND) {
9436 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
9439 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
9440 if (bus->dhd->dongle_reset) {
9445 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
9447 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, ON);
9448 bus->dhd->busstate = DHD_BUS_SUSPEND;
9449 if (DHD_BUS_BUSY_CHECK_IN_TX(bus->dhd)) {
9451 bus->dhd->busstate = DHD_BUS_DATA;
9453 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF);
9454 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
9457 DHD_BUS_BUSY_SET_SUSPEND_IN_PROGRESS(bus->dhd);
9458 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
9461 if (bus->idletime > 0) {
9462 wait_time = msecs_to_jiffies(bus->idletime * dhd_watchdog_ms);
9465 ret = dhd_os_check_wakelock(bus->dhd);
9467 if ((!ret) && (bus->dhd->up) && (bus->dhd->op_mode != DHD_FLAG_HOSTAP_MODE)) {
9468 if (wait_event_timeout(bus->bus_sleep, bus->sleeping, wait_time) == 0) {
9469 if (!bus->sleeping) {
9476 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
9478 bus->dhd->busstate = DHD_BUS_DATA;
9480 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF);
9482 DHD_BUS_BUSY_CLEAR_SUSPEND_IN_PROGRESS(bus->dhd);
9483 dhd_os_busbusy_wake(bus->dhd);
9484 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
9491 dhd_bus_t *bus = (dhd_bus_t*)context; local
9496 if (bus->dhd->up == FALSE) {
9500 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
9501 DHD_BUS_BUSY_SET_RESUME_IN_PROGRESS(bus->dhd);
9502 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
9505 if (dhd_os_check_if_up(bus->dhd))
9506 bcmsdh_oob_intr_set(bus->sdh, TRUE);
9509 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
9510 DHD_BUS_BUSY_CLEAR_RESUME_IN_PROGRESS(bus->dhd);
9511 bus->dhd->busstate = DHD_BUS_DATA;
9512 dhd_os_busbusy_wake(bus->dhd);
9514 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF);
9515 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
9521 * point (e.g. module insertion) to link with the bus driver, in
9562 dhdsdio_download_code_file(struct dhd_bus *bus, char *pfw_path) argument
9579 image = dhd_os_open_image1(bus->dhd, pfw_path);
9588 memptr = memblock = MALLOC(bus->dhd->osh, memblock_size + DHD_SDALIGN);
9609 if (si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) {
9613 bus->resetinstr = *(((uint32*)memptr));
9615 offset += bus->dongle_ram_base;
9629 bcmerror = dhdsdio_membytes(bus, TRUE, offset, memptr, len);
9649 MFREE(bus->dhd->osh, memblock, memblock_size + DHD_SDALIGN);
9652 dhd_os_close_image1(bus->dhd, image);
9660 dhdsdio_ucode_base(struct dhd_bus *bus) argument
9664 switch ((uint16)bus->sih->chip) {
9677 dhdsdio_download_ucode_file(struct dhd_bus *bus, char *ucode_path) argument
9693 ucode_base = dhdsdio_ucode_base(bus);
9695 image = dhd_os_open_image1(bus->dhd, ucode_path);
9703 memptr = memblock = MALLOC(bus->dhd->osh, memblock_size + DHD_SDALIGN);
9724 bcmerror = dhdsdio_membytes(bus, TRUE, (ucode_base + offset), memptr, len);
9744 MFREE(bus->dhd->osh, memblock, memblock_size + DHD_SDALIGN);
9747 dhd_os_close_image1(bus->dhd, image);
9753 dhd_bus_ucode_download(struct dhd_bus *bus) argument
9757 shaddr = bus->dongle_ram_base + bus->ramsize - 4;
9758 dhdsdio_membytes(bus, FALSE, shaddr, (uint8 *)&shdata, 4);
9767 if (!dhd_get_ucode_path(bus->dhd)) {
9768 DHD_ERROR(("%s: bus->uc_path not set!\n", __func__));
9771 dhdsdio_download_ucode_file(bus, dhd_get_ucode_path(bus->dhd));
9776 dhdsdio_membytes(bus, TRUE, shaddr, (uint8 *)&shdata, 4);
9783 dhdsdio_download_nvram(struct dhd_bus *bus) argument
9793 pnv_path = bus->nv_path;
9799 image = dhd_os_open_image1(bus->dhd, pnv_path);
9801 memblock = MALLOC(bus->dhd->osh, MAX_NVRAMBUF_SIZE);
9821 bcmerror = dhdsdio_downloadvars(bus, memblock, len + 1);
9834 MFREE(bus->dhd->osh, memblock, MAX_NVRAMBUF_SIZE);
9837 dhd_os_close_image1(bus->dhd, image);
9843 _dhdsdio_download_firmware(struct dhd_bus *bus) argument
9851 if ((bus->fw_path == NULL) || (bus->fw_path[0] == '\0')) {
9856 if (dhdsdio_download_state(bus, TRUE)) {
9862 if ((bus->fw_path != NULL) && (bus->fw_path[0] != '\0')) {
9863 if (dhdsdio_download_code_file(bus, bus->fw_path)) {
9879 if (dhdsdio_download_nvram(bus)) {
9885 if (dhdsdio_download_state(bus, FALSE)) {
9897 dhd_bcmsdh_recv_buf(dhd_bus_t *bus, uint32 addr, uint fn, uint flags, uint8 *buf, uint nbytes, argument
9902 if (!KSO_ENAB(bus)) {
9907 status = bcmsdh_recv_buf(bus->sdh, addr, fn, flags, buf, nbytes, pkt, complete_fn, handle);
9913 dhd_bcmsdh_send_buf(dhd_bus_t *bus, uint32 addr, uint fn, uint flags, uint8 *buf, uint nbytes, argument
9921 if (!KSO_ENAB(bus)) {
9926 sdh = bus->sdh;
9931 ret = bcmsdh_send_buf(bus->sdh, addr, fn, flags, buf, nbytes,
9934 bus->f2txdata++;
9943 bus->tx_sderrs++;
9944 bus->f1regdata++;
9945 bus->dhd->tx_errors++;
9955 bus->f1regdata += 2;
9966 dhd_bus_is_ioready(struct dhd_bus *bus) argument
9970 ASSERT(bus);
9971 ASSERT(bus->sih != NULL);
9973 sdh = bus->sdh;
9978 dhd_bus_chip(struct dhd_bus *bus) argument
9980 ASSERT(bus->sih != NULL);
9981 return bus->sih->chip;
9985 dhd_bus_chiprev(struct dhd_bus *bus) argument
9987 ASSERT(bus);
9988 ASSERT(bus->sih != NULL);
9989 return bus->sih->chiprev;
9993 dhd_bus_pub(struct dhd_bus *bus) argument
9995 return bus->dhd;
9999 dhd_bus_sih(struct dhd_bus *bus) argument
10001 return (void *)bus->sih;
10005 dhd_bus_txq(struct dhd_bus *bus) argument
10007 return &bus->txq;
10011 dhd_bus_hdrlen(struct dhd_bus *bus) argument
10013 return (bus->txglom_enable) ? SDPCM_HDRLEN_TXGLOM : SDPCM_HDRLEN;
10017 dhd_bus_set_dotxinrx(struct dhd_bus *bus, bool val) argument
10019 bus->dotxinrx = val;
10024 * to other bus user contexts like Tx, Rx, IOVAR, WD etc and it waits for other contexts
10025 * to gracefully exit. All the bus usage contexts before marking busstate as busy, will check for
10053 dhd_bus_t *bus; local
10056 bus = dhdp->bus;
10059 if (!bus->dhd->dongle_reset) {
10061 dhdsdio_advertise_bus_cleanup(bus->dhd);
10067 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, ON);
10071 /* Stop the bus, disable F2 */
10072 dhd_bus_stop(bus, FALSE);
10075 dhd_enable_oob_intr(bus, FALSE);
10076 bcmsdh_oob_intr_set(bus->sdh, FALSE);
10077 bcmsdh_oob_intr_unregister(bus->sdh);
10081 dhdsdio_release_dongle(bus, bus->dhd->osh, TRUE, TRUE);
10083 bus->dhd->dongle_reset = TRUE;
10085 bus->dhd->up = FALSE;
10089 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
10091 bus->dhd->busstate = DHD_BUS_DOWN;
10092 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
10103 if (bus->dhd->dongle_reset) {
10109 bcmsdh_reset(bus->sdh);
10111 if (dhdsdio_probe_attach(bus, bus->dhd->osh, bus->sdh,
10112 (uint32 *)(uintptr)si_enum_base(bus->cl_devid),
10113 bus->cl_devid)) {
10115 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
10117 bus->dhd->busstate = DHD_BUS_DOWN;
10118 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
10121 if (dhdsdio_probe_init(bus, bus->dhd->osh, bus->sdh) &&
10122 dhdsdio_download_firmware(bus, bus->dhd->osh, bus->sdh) >= 0) {
10124 /* Re-init bus, enable F2 transfer */
10125 bcmerror = dhd_bus_init((dhd_pub_t *) bus->dhd, FALSE);
10128 dhd_enable_oob_intr(bus, TRUE);
10129 bcmsdh_oob_intr_register(bus->sdh,
10130 dhdsdio_isr, bus);
10131 bcmsdh_oob_intr_set(bus->sdh, TRUE);
10134 bus->dhd->dongle_reset = FALSE;
10135 bus->dhd->up = TRUE;
10139 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF);
10145 dhd_bus_stop(bus, FALSE);
10146 dhdsdio_release_dongle(bus, bus->dhd->osh,
10152 if (bus->sih != NULL) {
10153 si_detach(bus->sih);
10154 bus->sih = NULL;
10180 return bcmsdh_stop(dhdpub->bus->sdh);
10185 return bcmsdh_start(dhdpub->bus->sdh, stage);
10191 dhd_bus_t *bus = dhdp->bus; local
10193 return bus->sih->chip;
10199 dhd_bus_t *bus = dhdp->bus; local
10201 return bus->sih->chiprev;
10208 dhd_bus_t *bus = dhdp->bus; local
10210 return bus->chipmodule;
10217 dhd_bus_t *bus = dhdp->bus; local
10219 return bus->sih->chippkg;
10222 int dhd_bus_get_ids(struct dhd_bus *bus, uint32 *bus_type, uint32 *bus_num, uint32 *slot_num) argument
10224 *bus_type = bus->bus;
10225 *bus_num = bus->bus_num;
10226 *slot_num = bus->slot_num;
10233 dhd_bus_t *bus; local
10235 bus = dhdp->bus;
10236 return dhdsdio_membytes(bus, set, address, data, size);
10241 concate_revision_bcm4335(dhd_bus_t *bus, char *fw_path, char *nv_path) argument
10252 if (bus->sih->chip != BCM4335_CHIP_ID) {
10256 chipver = bus->sih->chiprev;
10274 concate_revision_bcm4339(dhd_bus_t *bus, char *fw_path, char *nv_path) argument
10285 if (bus->sih->chip != BCM4339_CHIP_ID) {
10289 chipver = bus->sih->chiprev;
10304 static int concate_revision_bcm4350(dhd_bus_t *bus, char *fw_path, char *nv_path) argument
10312 chip_ver = bus->sih->chiprev;
10333 static int concate_revision_bcm4354(dhd_bus_t *bus, char *fw_path, char *nv_path) argument
10342 chip_ver = bus->sih->chiprev;
10357 concate_revision_bcm43454(dhd_bus_t *bus, char *fw_path, char *nv_path) argument
10365 if (bus->sih->chip != BCM43454_CHIP_ID) {
10389 concate_revision(dhd_bus_t *bus, char *fw_path, char *nv_path) argument
10393 if (!bus || !bus->sih) {
10394 DHD_ERROR(("%s:Bus is Invalid\n", __FUNCTION__));
10398 switch (bus->sih->chip) {
10400 res = concate_revision_bcm4335(bus, fw_path, nv_path);
10404 res = concate_revision_bcm4339(bus, fw_path, nv_path);
10407 res = concate_revision_bcm4350(bus, fw_path, nv_path);
10410 res = concate_revision_bcm4354(bus, fw_path, nv_path);
10413 res = concate_revision_bcm43454(bus, fw_path, nv_path);
10428 dhd_bus_update_fw_nv_path(struct dhd_bus *bus, char *pfw_path, char *pnv_path) argument
10430 bus->fw_path = pfw_path;
10431 bus->nv_path = pnv_path;
10437 dhd_bus_t *bus = dhd->bus; local
10438 sdpcmd_regs_t *regs = bus->regs;
10442 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
10450 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE);
10452 /* Make sure the controller has the bus up */
10453 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
10463 /* Make sure we have SD bus access */
10464 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE);
10472 dhd_bus_t *bus = dhdp->bus; local
10483 dhd_tcpack_info_tbl_clean(bus->dhd);
10486 pktq_flush(dhdp->osh, &bus->txq, TRUE);
10494 dhd_bus_t *bus = dhd->bus; local
10496 if (!bus->_srenab)
10499 return dhdsdio_clk_devsleep_iovar(bus, on);
10505 dhd_bus_t *bus = dhd->bus; local
10507 if (bus && bus->sih)
10508 return (uint16)bus->sih->chip;
10516 dhd_sdio_reg_read(struct dhd_bus *bus, ulong addr) argument
10520 dhd_os_sdlock(bus->dhd);
10522 BUS_WAKE(bus);
10524 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
10526 rval = bcmsdh_reg_read(bus->sdh, addr, 4);
10528 dhd_os_sdunlock(bus->dhd);
10534 dhd_sdio_reg_write(struct dhd_bus *bus, ulong addr, uint32 val) argument
10536 dhd_os_sdlock(bus->dhd);
10538 BUS_WAKE(bus);
10540 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE);
10542 bcmsdh_reg_write(bus->sdh, addr, 4, val);
10544 dhd_os_sdunlock(bus->dhd);
10554 dhd_bus_t *bus = (dhd_bus_t *)dhdp->bus; local
10556 dhd_os_sdlock(bus->dhd);
10558 intrd = bcmsdh_cfg_read(bus->sdh, fun_num, addr, err);
10560 dhd_os_sdunlock(bus->dhd);
10568 dhd_bus_t *bus = (dhd_bus_t *)dhdp->bus; local
10570 dhd_os_sdlock(bus->dhd);
10572 bcmsdh_cfg_write(bus->sdh, fun_num, addr, val, err);
10574 dhd_os_sdunlock(bus->dhd);
10590 read_more_btbytes(struct dhd_bus *bus, void * file, char *line, int * addr_mode, uint16 * hi_addr, argument
10600 str_len = dhd_os_gets_image(bus->dhd, line, BTFW_MAX_STR_LEN, file);
10644 _dhdsdio_download_btfw(struct dhd_bus *bus) argument
10661 if ((bus->btfw_path == NULL) || (bus->btfw_path[0] == '\0')) {
10665 image = dhd_os_open_image1(bus->dhd, bus->btfw_path);
10669 mem_ptr = mem_blk = MALLOC(bus->dhd->osh, BTFW_DOWNLOAD_BLK_SIZE + DHD_SDALIGN);
10678 data_ptr = MALLOC(bus->dhd->osh, BTFW_DOWNLOAD_BLK_SIZE - 8);
10686 bcmsdh_reg_write(bus->sdh, bt2wlan_pwrup_adr, 4, BT2WLAN_PWRUP_WAKE);
10692 line = MALLOC(bus->dhd->osh, BTFW_MAX_STR_LEN);
10700 while (read_more_btbytes (bus, image, line, &addr_mode, &hiAddress, &dest_addr,
10714 start_data = bcmsdh_reg_read(bus->sdh, start_addr, 4);
10728 end_data = bcmsdh_reg_read(bus->sdh, end_addr, 4);
10737 bcm_error = dhdsdio_membytes(bus, TRUE, start_addr, mem_ptr, index);
10746 bcm_error = dhdsdio_membytes(bus, TRUE, start_addr, mem_ptr,
10756 bcm_error = dhdsdio_membytes(bus, TRUE, (start_addr + bytes_to_write),
10770 MFREE(bus->dhd->osh, mem_blk, BTFW_DOWNLOAD_BLK_SIZE + DHD_SDALIGN);
10773 MFREE(bus->dhd->osh, data_ptr, BTFW_DOWNLOAD_BLK_SIZE - 8);
10776 MFREE(bus->dhd->osh, line, BTFW_MAX_STR_LEN);
10779 dhd_os_close_image1(bus->dhd, image);
10785 dhdsdio_download_btfw(struct dhd_bus *bus, osl_t *osh, void *sdh) argument
10790 __FUNCTION__, bus->btfw_path));
10791 DHD_OS_WAKE_LOCK(bus->dhd);
10792 dhd_os_sdlock(bus->dhd);
10795 ret = _dhdsdio_download_btfw(bus);
10797 dhd_os_sdunlock(bus->dhd);
10798 DHD_OS_WAKE_UNLOCK(bus->dhd);
10804 dhd_bus_download_btfw(struct dhd_bus *bus, osl_t *osh, argument
10809 bus->btfw_path = pbtfw_path;
10811 ret = dhdsdio_download_btfw(bus, osh, bus->sdh);
10818 dhd_bus_dump_trap_info(dhd_bus_t *bus, struct bcmstrbuf *strbuf) argument
10820 trap_t *tr = &bus->dhd->last_trap_info;
10829 ltoh32(bus->dongle_trap_addr),
10836 dhd_bcmsdh_send_buffer(void *bus, uint8 *frame, uint16 len) argument
10840 ret = dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(((dhd_bus_t*)bus)->sdh),
10844 ((dhd_bus_t*)bus)->tx_seq = (((dhd_bus_t*)bus)->tx_seq + 1) % SDPCM_SEQUENCE_WRAP;
10851 dhd_bus_set_default_min_res_mask(struct dhd_bus *bus) argument
10853 if ((bus == NULL) || (bus->sih == NULL)) {
10858 switch (bus->sih->chip) {
10860 bcmsdh_reg_write(bus->sdh, SI_ENUM_BASE(bus->sih) + 0x618, 4, 0x3fcaf377);
10861 if (bcmsdh_regfail(bus->sdh)) {
10868 bcmsdh_reg_write(bus->sdh,
10869 si_get_pmu_reg_addr(bus->sih, OFFSETOF(pmuregs_t, min_res_mask)),
10871 if (bcmsdh_regfail(bus->sdh)) {
10889 struct dhd_bus *bus = dhdp->bus; local
10890 bcmsdh_reg_write(bus->sdh, si_get_pmu_reg_addr(bus->sih,
10892 if (bcmsdh_regfail(bus->sdh)) {
10910 dhdsdio_readconsole(dhdp->bus);
10917 dhd_bus_ulp_reinit_fw(dhd_bus_t *bus) argument
10924 bus->tx_seq = bus->rx_seq = 0;
10925 bus->tx_max = 4;
10927 if (dhd_bus_download_firmware(bus, bus->dhd->osh,
10928 bus->fw_path, bus->nv_path) >= 0) {
10930 /* Re-init bus, enable F2 transfer */
10931 bcmerror = dhd_bus_init((dhd_pub_t *) bus->dhd, FALSE);
10933 bus->dhd->up = TRUE;
10934 dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms);
10936 dhd_ulp_set_ulp_state(bus->dhd, DHD_ULP_READY);
10938 dhd_enable_oob_intr(bus, TRUE);
10939 bcmsdh_oob_intr_set(bus->sdh, TRUE);
10943 dhd_ulp_restore_console_interval(bus->dhd);
10946 DHD_ERROR(("bus init failed\n"));
10947 dhd_bus_stop(bus, FALSE);
10948 dhdsdio_release_dongle(bus, bus->dhd->osh,
10962 struct dhd_bus *bus = dhdp->bus; local
10965 *data = (int32)bcmsdh_reg_read(bus->sdh, addr, size);
10967 bcmsdh_reg_write(bus->sdh, addr, size, *data);
10970 if (bcmsdh_regfail(bus->sdh))
10978 return dhd->bus->idletime;
10985 return &dhd->bus->wake_counts;
10990 return bcmsdh_set_get_wake(dhd->bus->sdh, 0);