Lines Matching full:bus

2  * DHD Bus Module for SDIO
204 * bufpool was present for gspi bus.
206 #define PKTFREE2() if ((bus->bus != SPI_BUS) || bus->usebufpool) \
207 PKTFREE(bus->dhd->osh, pkt, FALSE);
226 #define REMAP_ENAB(bus) ((bus)->remap) argument
227 #define REMAP_ISADDR(bus, a) (((a) >= ((bus)->orig_ramsize)) && ((a) < ((bus)->ramsize))) argument
228 #define KSO_ENAB(bus) ((bus)->kso) argument
229 #define SR_ENAB(bus) ((bus)->_srenab) argument
230 #define SLPAUTO_ENAB(bus) ((SR_ENAB(bus)) && ((bus)->_slpauto)) argument
238 #define OOB_WAKEUP_ENAB(bus) ((bus)->_oobwakeup) argument
277 /* Private data for SDIO bus interaction */
295 uint32 bus; /* gSPI or SDIO bus */ member
296 uint32 bus_num; /* bus number */
336 uint8 sdpcm_ver; /* Bus protocol reported by dongle */
358 int32 idleclock; /* How to set bus driver when idle */
359 int32 sd_divisor; /* Speed control to bus driver */
360 int32 sd_mode; /* Mode control to bus driver */
363 bool sleeping; /* Is SDIO bus sleeping? */
480 uint32 bt_use_count; /* Counter that tracks whether BT is using the bus */
505 #define NO_OTHER_ACTIVE_BUS_USER(bus) (bus->bt_use_count == 0) argument
507 #define NO_OTHER_ACTIVE_BUS_USER(bus) (1) argument
543 extern void dhd_os_wd_timer(void *bus, uint wdtick);
590 /* PR48178: read to (not through) bus burst to avoid F2 underflow */
612 static uint32 dhd_sdio_reg_read(struct dhd_bus *bus, ulong addr);
613 static void dhd_sdio_reg_write(struct dhd_bus *bus, ulong addr, uint32 val);
615 /** the debugger layer will call back into this (bus) layer to read/write dongle memory */
652 dhdsdio_is_dataok(dhd_bus_t *bus) { in dhdsdio_is_dataok() argument
653 return (((uint8)(bus->tx_max - bus->tx_seq) - bus->dhd->conf->tx_max_offset > 1) && \ in dhdsdio_is_dataok()
654 (((uint8)(bus->tx_max - bus->tx_seq) & 0x80) == 0)); in dhdsdio_is_dataok()
658 dhdsdio_get_databufcnt(dhd_bus_t *bus) { in dhdsdio_get_databufcnt() argument
659 return ((uint8)(bus->tx_max - bus->tx_seq) - 1 - bus->dhd->conf->tx_max_offset); in dhdsdio_get_databufcnt()
665 #define DATAOK(bus) dhdsdio_is_dataok(bus) argument
667 #define DATAOK(bus) \ argument
668 (((uint8)(bus->tx_max - bus->tx_seq) > 1) && \
669 (((uint8)(bus->tx_max - bus->tx_seq) & 0x80) == 0))
673 #define TXCTLOK(bus) \ argument
674 (((uint8)(bus->tx_max - bus->tx_seq) != 0) && \
675 (((uint8)(bus->tx_max - bus->tx_seq) & 0x80) == 0))
679 #define DATABUFCNT(bus) dhdsdio_get_databufcnt(bus) argument
681 #define DATABUFCNT(bus) \ argument
682 ((uint8)(bus->tx_max - bus->tx_seq) - 1)
686 /* NOTE: these assume a local dhdsdio_bus_t *bus! */
692 regvar = R_REG(bus->dhd->osh, regaddr); \
693 } while (bcmsdh_regfail(bus->sdh) && (++retryvar <= retry_limit)); \
695 bus->regfails += (retryvar-1); \
708 W_REG(bus->dhd->osh, regaddr, regval); \
709 } while (bcmsdh_regfail(bus->sdh) && (++retryvar <= retry_limit)); \
711 bus->regfails += (retryvar-1); \
718 #define BUS_WAKE(bus) \ argument
720 bus->idlecount = 0; \
721 if ((bus)->sleeping) \
722 dhdsdio_bussleep((bus), FALSE); \
748 #define FRAME_AVAIL_MASK(bus) I_HMB_FRAME_IND argument
753 #define PKT_AVAILABLE(bus, intstatus) (bcmsdh_get_dstatus(bus->sdh) & STATUS_F2_PKT_AVAILABLE) argument
759 uint32 dstatussw = bcmsdh_get_dstatus((void *)bus->sdh); \
760 uint32 dstatushw = bcmsdh_cfg_read_word(bus->sdh, SDIO_FUNC_0, SPID_STATUS_REG, NULL); \
764 R_SDREG(intstatuserr, &bus->regs->intstatus, retries); \
768 bus->nextlen = 0; \
774 #define FRAME_AVAIL_MASK(bus) \ argument
775 ((bus->rxint_mode == SDIO_DEVICE_HMB_RXINT) ? I_HMB_FRAME_IND : I_XMTDATA_AVAIL)
779 #define PKT_AVAILABLE(bus, intstatus) ((intstatus) & (FRAME_AVAIL_MASK(bus))) argument
788 static void dhdsdio_testrcv(dhd_bus_t *bus, void *pkt, uint seq);
789 static void dhdsdio_sdtest_set(dhd_bus_t *bus, uint count);
792 static int dhdsdio_checkdied(dhd_bus_t *bus, char *data, uint size);
794 static int dhd_serialconsole(dhd_bus_t *bus, bool get, bool enable, int *bcmerror);
798 static int dhdsdio_mem_dump(dhd_bus_t *bus);
799 static int dhdsdio_get_mem_dump(dhd_bus_t *bus);
801 static int dhdsdio_devcap_set(dhd_bus_t *bus, uint8 cap);
802 static int dhdsdio_download_state(dhd_bus_t *bus, bool enter);
804 static void dhdsdio_release(dhd_bus_t *bus, osl_t *osh);
805 static void dhdsdio_release_malloc(dhd_bus_t *bus, osl_t *osh);
808 static bool dhdsdio_probe_attach(dhd_bus_t *bus, osl_t *osh, void *sdh,
810 static bool dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh);
811 static bool dhdsdio_probe_init(dhd_bus_t *bus, osl_t *osh, void *sdh);
812 static void dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh, bool dongle_isolation,
815 static void dhd_dongle_setramsize(struct dhd_bus *bus, int mem_size);
816 static int dhd_bcmsdh_recv_buf(dhd_bus_t *bus, uint32 addr, uint fn, uint flags,
819 static int dhd_bcmsdh_send_buf(dhd_bus_t *bus, uint32 addr, uint fn, uint flags,
822 static int dhdsdio_txpkt(dhd_bus_t *bus, uint chan, void** pkts, int num_pkt, bool free_pkt);
823 static int dhdsdio_txpkt_preprocess(dhd_bus_t *bus, void *pkt, int chan, int txseq,
830 static int dhdsdio_txpkt_postprocess(dhd_bus_t *bus, void *pkt);
832 static int dhdsdio_download_firmware(dhd_bus_t *bus, osl_t *osh, void *sdh);
833 static int _dhdsdio_download_firmware(dhd_bus_t *bus);
836 static int dhdsdio_download_ucode_file(struct dhd_bus *bus, char *ucode_path);
838 static int dhdsdio_download_code_file(dhd_bus_t *bus, char *image_path);
839 static int dhdsdio_download_nvram(dhd_bus_t *bus);
841 static int dhdsdio_download_code_array(dhd_bus_t *bus);
843 static int dhdsdio_bussleep(dhd_bus_t *bus, bool sleep);
844 static int dhdsdio_clkctl(dhd_bus_t *bus, uint target, bool pendok);
845 static uint8 dhdsdio_sleepcsr_get(dhd_bus_t *bus);
846 static bool dhdsdio_dpc(dhd_bus_t *bus);
847 static int dhd_bcmsdh_send_buffer(void *bus, uint8 *frame, uint16 len);
848 static int dhdsdio_set_sdmode(dhd_bus_t *bus, int32 sd_mode);
849 static int dhdsdio_sdclk(dhd_bus_t *bus, bool on);
855 static int read_more_btbytes(struct dhd_bus *bus, void * file, char *line, int * addr_mode,
857 static int dhdsdio_download_btfw(struct dhd_bus *bus, osl_t *osh, void *sdh);
858 static int _dhdsdio_download_btfw(struct dhd_bus *bus);
870 dhdsdio_tune_fifoparam(struct dhd_bus *bus) in dhdsdio_tune_fifoparam() argument
875 if (bus->sih->buscorerev >= 15) { in dhdsdio_tune_fifoparam()
877 if (bus->blocksize == 512) { in dhdsdio_tune_fifoparam()
881 mes = bus->blocksize/4; in dhdsdio_tune_fifoparam()
882 wm = bus->blocksize/4; in dhdsdio_tune_fifoparam()
892 bus->sih->buscorerev)); in dhdsdio_tune_fifoparam()
898 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_WATERMARK, wm, &err); in dhdsdio_tune_fifoparam()
900 devctl = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err); in dhdsdio_tune_fifoparam()
902 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, devctl, &err); in dhdsdio_tune_fifoparam()
907 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_MESBUSYCTRL, in dhdsdio_tune_fifoparam()
912 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_DEVICE_CTL, &err), in dhdsdio_tune_fifoparam()
913 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_WATERMARK, &err), in dhdsdio_tune_fifoparam()
914 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_MESBUSYCTRL, &err))); in dhdsdio_tune_fifoparam()
918 dhd_dongle_setramsize(struct dhd_bus *bus, int mem_size) in dhd_dongle_setramsize() argument
925 (dhd_dongle_ramsize < (int32)bus->orig_ramsize)) in dhd_dongle_setramsize()
926 bus->ramsize = dhd_dongle_ramsize; in dhd_dongle_setramsize()
930 dhdsdio_set_siaddr_window(dhd_bus_t *bus, uint32 address) in dhdsdio_set_siaddr_window() argument
933 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRLOW, in dhdsdio_set_siaddr_window()
936 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRMID, in dhdsdio_set_siaddr_window()
939 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SBADDRHIGH, in dhdsdio_set_siaddr_window()
946 dhdsdio_wkwlan(dhd_bus_t *bus, bool on) in dhdsdio_wkwlan() argument
950 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_wkwlan()
954 if (bus->sih->buscoretype == SDIOD_CORE_ID) { in dhdsdio_wkwlan()
971 dhdsdio_oobwakeup_init(dhd_bus_t *bus) in dhdsdio_oobwakeup_init() argument
975 bcmsdh_gpioouten(bus->sdh, GPIO_DEV_WAKEUP); in dhdsdio_oobwakeup_init()
977 addr = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_addr); in dhdsdio_oobwakeup_init()
978 data = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_data); in dhdsdio_oobwakeup_init()
981 bcmsdh_reg_write(bus->sdh, addr, 4, 2); in dhdsdio_oobwakeup_init()
982 val = bcmsdh_reg_read(bus->sdh, data, 4); in dhdsdio_oobwakeup_init()
984 bcmsdh_reg_write(bus->sdh, data, 4, val); in dhdsdio_oobwakeup_init()
986 bus->_oobwakeup = TRUE; in dhdsdio_oobwakeup_init()
997 dhdsdio_sr_cap(dhd_bus_t *bus) in dhdsdio_sr_cap() argument
1002 if (bus->sih->chip == BCM43430_CHIP_ID || in dhdsdio_sr_cap()
1003 bus->sih->chip == BCM43018_CHIP_ID) { in dhdsdio_sr_cap()
1005 addr = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, sr_control1); in dhdsdio_sr_cap()
1006 if (bcmsdh_reg_read(bus->sdh, addr, 4) != 0) in dhdsdio_sr_cap()
1013 (bus->sih->chip == BCM4347_CHIP_ID) || in dhdsdio_sr_cap()
1014 (bus->sih->chip == BCM4357_CHIP_ID) || in dhdsdio_sr_cap()
1015 (bus->sih->chip == BCM4361_CHIP_ID) || in dhdsdio_sr_cap()
1019 } else if ((bus->sih->chip == BCM4330_CHIP_ID) || in dhdsdio_sr_cap()
1020 (bus->sih->chip == BCM43362_CHIP_ID) || in dhdsdio_sr_cap()
1021 (BCM4347_CHIP(bus->sih->chip))) { in dhdsdio_sr_cap()
1023 } else if ((bus->sih->chip == BCM4335_CHIP_ID) || in dhdsdio_sr_cap()
1024 (bus->sih->chip == BCM4339_CHIP_ID) || in dhdsdio_sr_cap()
1025 BCM4345_CHIP(bus->sih->chip) || in dhdsdio_sr_cap()
1026 (bus->sih->chip == BCM4354_CHIP_ID) || in dhdsdio_sr_cap()
1027 (bus->sih->chip == BCM4358_CHIP_ID) || in dhdsdio_sr_cap()
1028 (bus->sih->chip == BCM43569_CHIP_ID) || in dhdsdio_sr_cap()
1029 (bus->sih->chip == BCM4371_CHIP_ID) || in dhdsdio_sr_cap()
1030 (BCM4349_CHIP(bus->sih->chip)) || in dhdsdio_sr_cap()
1031 (bus->sih->chip == BCM4350_CHIP_ID) || in dhdsdio_sr_cap()
1032 (bus->sih->chip == BCM4362_CHIP_ID) || in dhdsdio_sr_cap()
1033 (bus->sih->chip == BCM43012_CHIP_ID) || in dhdsdio_sr_cap()
1034 (bus->sih->chip == BCM43013_CHIP_ID) || in dhdsdio_sr_cap()
1035 (bus->sih->chip == BCM43014_CHIP_ID) || in dhdsdio_sr_cap()
1036 (bus->sih->chip == BCM43751_CHIP_ID) || in dhdsdio_sr_cap()
1037 (bus->sih->chip == BCM43752_CHIP_ID)) { in dhdsdio_sr_cap()
1041 core_capext = bcmsdh_reg_read(bus->sdh, in dhdsdio_sr_cap()
1042 si_get_pmu_reg_addr(bus->sih, OFFSETOF(chipcregs_t, core_cap_ext)), in dhdsdio_sr_cap()
1050 if ((bus->sih->chip == BCM4335_CHIP_ID) || in dhdsdio_sr_cap()
1051 (bus->sih->chip == BCM4339_CHIP_ID) || in dhdsdio_sr_cap()
1052 BCM4345_CHIP(bus->sih->chip) || in dhdsdio_sr_cap()
1053 (bus->sih->chip == BCM4354_CHIP_ID) || in dhdsdio_sr_cap()
1054 (bus->sih->chip == BCM4358_CHIP_ID) || in dhdsdio_sr_cap()
1055 (bus->sih->chip == BCM43569_CHIP_ID) || in dhdsdio_sr_cap()
1056 (bus->sih->chip == BCM4371_CHIP_ID) || in dhdsdio_sr_cap()
1057 (bus->sih->chip == BCM4350_CHIP_ID)) { in dhdsdio_sr_cap()
1059 addr = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_addr); in dhdsdio_sr_cap()
1060 data = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_data); in dhdsdio_sr_cap()
1066 bcmsdh_reg_write(bus->sdh, addr, 4, CC_PMUCC3); in dhdsdio_sr_cap()
1067 enabval = bcmsdh_reg_read(bus->sdh, data, 4); in dhdsdio_sr_cap()
1069 if ((bus->sih->chip == BCM4350_CHIP_ID) || in dhdsdio_sr_cap()
1070 BCM4345_CHIP(bus->sih->chip) || in dhdsdio_sr_cap()
1071 (bus->sih->chip == BCM4354_CHIP_ID) || in dhdsdio_sr_cap()
1072 (bus->sih->chip == BCM4358_CHIP_ID) || in dhdsdio_sr_cap()
1073 (bus->sih->chip == BCM43569_CHIP_ID) || in dhdsdio_sr_cap()
1074 (bus->sih->chip == BCM4371_CHIP_ID)) in dhdsdio_sr_cap()
1084 data = bcmsdh_reg_read(bus->sdh, in dhdsdio_sr_cap()
1085 si_get_pmu_reg_addr(bus->sih, OFFSETOF(chipcregs_t, retention_ctl)), in dhdsdio_sr_cap()
1095 dhdsdio_sr_init(dhd_bus_t *bus) in dhdsdio_sr_init() argument
1100 if (bus->sih->chip == BCM43012_CHIP_ID || in dhdsdio_sr_init()
1101 bus->sih->chip == BCM43013_CHIP_ID || in dhdsdio_sr_init()
1102 bus->sih->chip == BCM43014_CHIP_ID) { in dhdsdio_sr_init()
1103 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, NULL); in dhdsdio_sr_init()
1105 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, in dhdsdio_sr_init()
1107 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, NULL); in dhdsdio_sr_init()
1109 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, NULL); in dhdsdio_sr_init()
1111 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, in dhdsdio_sr_init()
1113 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_WAKEUPCTRL, NULL); in dhdsdio_sr_init()
1118 dhdsdio_devcap_set(bus, in dhdsdio_sr_init()
1122 if (CHIPID(bus->sih->chip) == BCM43430_CHIP_ID || in dhdsdio_sr_init()
1123 CHIPID(bus->sih->chip) == BCM43018_CHIP_ID || in dhdsdio_sr_init()
1124 CHIPID(bus->sih->chip) == BCM4339_CHIP_ID || in dhdsdio_sr_init()
1125 CHIPID(bus->sih->chip) == BCM4362_CHIP_ID || in dhdsdio_sr_init()
1126 CHIPID(bus->sih->chip) == BCM43012_CHIP_ID || in dhdsdio_sr_init()
1127 CHIPID(bus->sih->chip) == BCM43013_CHIP_ID || in dhdsdio_sr_init()
1128 CHIPID(bus->sih->chip) == BCM43014_CHIP_ID || in dhdsdio_sr_init()
1129 CHIPID(bus->sih->chip) == BCM43751_CHIP_ID || in dhdsdio_sr_init()
1130 CHIPID(bus->sih->chip) == BCM43752_CHIP_ID) in dhdsdio_sr_init()
1131 dhdsdio_devcap_set(bus, SDIOD_CCCR_BRCM_CARDCAP_CMD_NODEC); in dhdsdio_sr_init()
1133 if (bus->sih->chip == BCM43012_CHIP_ID || in dhdsdio_sr_init()
1134 bus->sih->chip == BCM43013_CHIP_ID || in dhdsdio_sr_init()
1135 bus->sih->chip == BCM43014_CHIP_ID) { in dhdsdio_sr_init()
1136 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, in dhdsdio_sr_init()
1139 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, in dhdsdio_sr_init()
1142 bus->_slpauto = dhd_slpauto ? TRUE : FALSE; in dhdsdio_sr_init()
1144 bus->_srenab = TRUE; in dhdsdio_sr_init()
1155 dhdsdio_clk_kso_init(dhd_bus_t *bus) in dhdsdio_clk_kso_init() argument
1161 bus->kso = TRUE; in dhdsdio_clk_kso_init()
1167 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, NULL); in dhdsdio_clk_kso_init()
1170 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, val, &err); in dhdsdio_clk_kso_init()
1198 dhdsdio_clk_kso_enab(dhd_bus_t *bus, bool on) in dhdsdio_clk_kso_enab() argument
1203 struct dhd_conf *conf = bus->dhd->conf; in dhdsdio_clk_kso_enab()
1209 struct sdioh_info *sd = (struct sdioh_info *)(bus->sdh->sdioh); in dhdsdio_clk_kso_enab()
1216 dhd_bus_get_ids(bus, &bus_type, &bus_num, &slot_num); in dhdsdio_clk_kso_enab()
1229 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, wr_val, &err); in dhdsdio_clk_kso_enab()
1235 if ((!on) && (bus->sih->chip == BCM43012_CHIP_ID || in dhdsdio_clk_kso_enab()
1236 bus->sih->chip == BCM43013_CHIP_ID || in dhdsdio_clk_kso_enab()
1237 bus->sih->chip == BCM43014_CHIP_ID)) { in dhdsdio_clk_kso_enab()
1255 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, in dhdsdio_clk_kso_enab()
1260 rd_val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, &err); in dhdsdio_clk_kso_enab()
1262 /* Sdio Bus Failure - Bus hang */ in dhdsdio_clk_kso_enab()
1263 DHD_ERROR(("%s> op:%s, ERROR: SDIO Bus Hang, rd_val:%x, ERR:%x \n", in dhdsdio_clk_kso_enab()
1290 rd_val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, &err); in dhdsdio_clk_kso_enab()
1301 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, wr_val, &err); in dhdsdio_clk_kso_enab()
1359 dhdsdio_clk_kso_iovar(dhd_bus_t *bus, bool on) in dhdsdio_clk_kso_iovar() argument
1365 BUS_WAKE(bus); in dhdsdio_clk_kso_iovar()
1366 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_clk_kso_iovar()
1369 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_clk_kso_iovar()
1371 dhdsdio_clk_kso_enab(bus, FALSE); in dhdsdio_clk_kso_iovar()
1375 /* Make sure we have SD bus access */ in dhdsdio_clk_kso_iovar()
1376 if (bus->clkstate == CLK_NONE) { in dhdsdio_clk_kso_iovar()
1378 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhdsdio_clk_kso_iovar()
1381 dhdsdio_clk_kso_enab(bus, TRUE); in dhdsdio_clk_kso_iovar()
1384 dhdsdio_sleepcsr_get(bus))); in dhdsdio_clk_kso_iovar()
1387 bus->kso = on; in dhdsdio_clk_kso_iovar()
1394 dhdsdio_sleepcsr_get(dhd_bus_t *bus) in dhdsdio_sleepcsr_get() argument
1399 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_SLEEPCSR, &err); in dhdsdio_sleepcsr_get()
1408 dhdsdio_devcap_get(dhd_bus_t *bus) in dhdsdio_devcap_get() argument
1410 return bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_BRCM_CARDCAP, NULL); in dhdsdio_devcap_get()
1414 dhdsdio_devcap_set(dhd_bus_t *bus, uint8 cap) in dhdsdio_devcap_set() argument
1418 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_BRCM_CARDCAP, cap, &err); in dhdsdio_devcap_set()
1426 dhdsdio_clk_devsleep_iovar(dhd_bus_t *bus, bool on) in dhdsdio_clk_devsleep_iovar() argument
1439 if (!SLPAUTO_ENAB(bus)) in dhdsdio_clk_devsleep_iovar()
1440 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_clk_devsleep_iovar()
1446 val = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); in dhdsdio_clk_devsleep_iovar()
1452 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, in dhdsdio_clk_devsleep_iovar()
1455 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_clk_devsleep_iovar()
1461 bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_clk_devsleep_iovar()
1464 err = bcmsdh_sleep(bus->sdh, TRUE); in dhdsdio_clk_devsleep_iovar()
1466 if ((SLPAUTO_ENAB(bus)) && (bus->idleclock == DHD_IDLE_STOP)) { in dhdsdio_clk_devsleep_iovar()
1469 dhdsdio_set_sdmode(bus, 1); in dhdsdio_clk_devsleep_iovar()
1473 err = dhdsdio_clk_kso_enab(bus, FALSE); in dhdsdio_clk_devsleep_iovar()
1474 if (OOB_WAKEUP_ENAB(bus)) in dhdsdio_clk_devsleep_iovar()
1477 err = bcmsdh_gpioout(bus->sdh, GPIO_DEV_WAKEUP, FALSE); /* GPIO_1 is off */ in dhdsdio_clk_devsleep_iovar()
1482 if ((SLPAUTO_ENAB(bus)) && (bus->idleclock != DHD_IDLE_ACTIVE)) { in dhdsdio_clk_devsleep_iovar()
1485 err = dhdsdio_sdclk(bus, FALSE); in dhdsdio_clk_devsleep_iovar()
1489 /* Make sure we have SD bus access */ in dhdsdio_clk_devsleep_iovar()
1490 if (bus->clkstate == CLK_NONE) { in dhdsdio_clk_devsleep_iovar()
1492 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhdsdio_clk_devsleep_iovar()
1495 err = bcmsdh_sleep(bus->sdh, FALSE); in dhdsdio_clk_devsleep_iovar()
1496 if (SLPAUTO_ENAB(bus) && (err != 0)) { in dhdsdio_clk_devsleep_iovar()
1505 err = bcmsdh_sleep(bus->sdh, TRUE); in dhdsdio_clk_devsleep_iovar()
1507 err = bcmsdh_sleep(bus->sdh, FALSE); in dhdsdio_clk_devsleep_iovar()
1518 err = bcmsdh_sleep(bus->sdh, TRUE); in dhdsdio_clk_devsleep_iovar()
1520 err = bcmsdh_sleep(bus->sdh, FALSE); in dhdsdio_clk_devsleep_iovar()
1534 if (OOB_WAKEUP_ENAB(bus)) in dhdsdio_clk_devsleep_iovar()
1537 err = bcmsdh_gpioout(bus->sdh, GPIO_DEV_WAKEUP, TRUE); /* GPIO_1 is on */ in dhdsdio_clk_devsleep_iovar()
1545 err = dhdsdio_clk_kso_enab(bus, TRUE); in dhdsdio_clk_devsleep_iovar()
1557 if ((SLPAUTO_ENAB(bus)) && (bus->idleclock == DHD_IDLE_STOP)) { in dhdsdio_clk_devsleep_iovar()
1558 dhdsdio_set_sdmode(bus, bus->sd_mode); in dhdsdio_clk_devsleep_iovar()
1567 (((csr = dhdsdio_sleepcsr_get(bus)) & in dhdsdio_clk_devsleep_iovar()
1583 (((csr = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_clk_devsleep_iovar()
1598 bus->kso = on ? FALSE : TRUE; in dhdsdio_clk_devsleep_iovar()
1601 __FUNCTION__, bus->kso, on, err)); in dhdsdio_clk_devsleep_iovar()
1603 bus->kso = FALSE; in dhdsdio_clk_devsleep_iovar()
1611 dhdsdio_htclk(dhd_bus_t *bus, bool on, bool pendok) in dhdsdio_htclk() argument
1622 sdh = bus->sdh; in dhdsdio_htclk()
1625 if (DHD_NOPMU(bus)) { in dhdsdio_htclk()
1627 bus->clkstate = (on ? CLK_AVAIL : CLK_SDONLY); in dhdsdio_htclk()
1631 if (bus->clockpoll) in dhdsdio_htclk()
1635 if (!KSO_ENAB(bus)) in dhdsdio_htclk()
1638 if (SLPAUTO_ENAB(bus)) { in dhdsdio_htclk()
1639 bus->clkstate = (on ? CLK_AVAIL : CLK_SDONLY); in dhdsdio_htclk()
1645 clkreq = bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ; in dhdsdio_htclk()
1648 dhdsdio_wkwlan(bus, TRUE); in dhdsdio_htclk()
1662 bus->dhd->hang_reason = HANG_REASON_HT_AVAIL_ERROR; in dhdsdio_htclk()
1663 dhd_os_send_hang_message(bus->dhd); in dhdsdio_htclk()
1680 if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) { in dhdsdio_htclk()
1692 bus->clkstate = CLK_PENDING; in dhdsdio_htclk()
1697 if (bus->clkstate == CLK_PENDING) { in dhdsdio_htclk()
1706 if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { in dhdsdio_htclk()
1710 !SBSDIO_CLKAV(clkctl, bus->alp_only)), PMU_MAX_TRANSITION_DLY); in dhdsdio_htclk()
1716 if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { in dhdsdio_htclk()
1723 bus->clkstate = CLK_AVAIL; in dhdsdio_htclk()
1727 if (bus->alp_only == TRUE) { in dhdsdio_htclk()
1744 bus->activity = TRUE; in dhdsdio_htclk()
1746 bus->idlecount = 0; in dhdsdio_htclk()
1751 if (bus->clkstate == CLK_PENDING) { in dhdsdio_htclk()
1758 bus->clkstate = CLK_SDONLY; in dhdsdio_htclk()
1759 if (!SR_ENAB(bus)) { in dhdsdio_htclk()
1769 dhdsdio_wkwlan(bus, FALSE); in dhdsdio_htclk()
1775 /* Change SD1/SD4 bus mode */
1777 dhdsdio_set_sdmode(dhd_bus_t *bus, int32 sd_mode) in dhdsdio_set_sdmode() argument
1781 err = bcmsdh_iovar_op(bus->sdh, "sd_mode", NULL, 0, in dhdsdio_set_sdmode()
1793 dhdsdio_sdclk(dhd_bus_t *bus, bool on) in dhdsdio_sdclk() argument
1802 if (bus->idleclock == DHD_IDLE_STOP) { in dhdsdio_sdclk()
1805 err = bcmsdh_iovar_op(bus->sdh, "sd_clock", NULL, 0, in dhdsdio_sdclk()
1813 } else if (bus->idleclock != DHD_IDLE_ACTIVE) { in dhdsdio_sdclk()
1815 iovalue = bus->sd_divisor; in dhdsdio_sdclk()
1816 err = bcmsdh_iovar_op(bus->sdh, "sd_divisor", NULL, 0, in dhdsdio_sdclk()
1824 bus->clkstate = CLK_SDONLY; in dhdsdio_sdclk()
1827 if ((bus->sd_divisor == -1) || (bus->sd_mode == -1)) { in dhdsdio_sdclk()
1829 __FUNCTION__, bus->sd_divisor, bus->sd_mode)); in dhdsdio_sdclk()
1832 if (bus->idleclock == DHD_IDLE_STOP) { in dhdsdio_sdclk()
1834 err = bcmsdh_iovar_op(bus->sdh, "sd_clock", NULL, 0, in dhdsdio_sdclk()
1841 } else if (bus->idleclock != DHD_IDLE_ACTIVE) { in dhdsdio_sdclk()
1843 iovalue = bus->idleclock; in dhdsdio_sdclk()
1844 err = bcmsdh_iovar_op(bus->sdh, "sd_divisor", NULL, 0, in dhdsdio_sdclk()
1852 bus->clkstate = CLK_NONE; in dhdsdio_sdclk()
1861 dhdsdio_clkctl(dhd_bus_t *bus, uint target, bool pendok) in dhdsdio_clkctl() argument
1865 uint oldstate = bus->clkstate; in dhdsdio_clkctl()
1871 if (bus->clkstate == target) { in dhdsdio_clkctl()
1873 dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms); in dhdsdio_clkctl()
1874 bus->activity = TRUE; in dhdsdio_clkctl()
1876 bus->idlecount = 0; in dhdsdio_clkctl()
1885 if (bus->clkstate == CLK_NONE) in dhdsdio_clkctl()
1886 dhdsdio_sdclk(bus, TRUE); in dhdsdio_clkctl()
1888 ret = dhdsdio_htclk(bus, TRUE, pendok); in dhdsdio_clkctl()
1890 dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms); in dhdsdio_clkctl()
1891 bus->activity = TRUE; in dhdsdio_clkctl()
1893 bus->idlecount = 0; in dhdsdio_clkctl()
1906 * nothing is to be done & Bt has finished using the bus. in dhdsdio_clkctl()
1908 if (bus->bt_use_count != 0) { in dhdsdio_clkctl()
1910 __FUNCTION__, bus->bt_use_count)); in dhdsdio_clkctl()
1912 dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms); in dhdsdio_clkctl()
1921 if (bus->clkstate == CLK_NONE) in dhdsdio_clkctl()
1922 ret = dhdsdio_sdclk(bus, TRUE); in dhdsdio_clkctl()
1923 else if (bus->clkstate == CLK_AVAIL) in dhdsdio_clkctl()
1924 ret = dhdsdio_htclk(bus, FALSE, FALSE); in dhdsdio_clkctl()
1927 bus->clkstate, target)); in dhdsdio_clkctl()
1929 dhd_os_wd_timer(bus->dhd, dhd_watchdog_ms); in dhdsdio_clkctl()
1941 * nothing is to be done & Bt has finished using the bus. in dhdsdio_clkctl()
1943 if (bus->bt_use_count != 0) { in dhdsdio_clkctl()
1945 __FUNCTION__, bus->bt_use_count)); in dhdsdio_clkctl()
1955 if (bus->clkstate == CLK_AVAIL) in dhdsdio_clkctl()
1956 ret = dhdsdio_htclk(bus, FALSE, FALSE); in dhdsdio_clkctl()
1958 ret = dhdsdio_sdclk(bus, FALSE); in dhdsdio_clkctl()
1960 if (bus->dhd->dhd_console_ms == 0) in dhdsdio_clkctl()
1962 if (bus->poll == 0) in dhdsdio_clkctl()
1963 dhd_os_wd_timer(bus->dhd, 0); in dhdsdio_clkctl()
1967 DHD_INFO(("dhdsdio_clkctl: %d -> %d\n", oldstate, bus->clkstate)); in dhdsdio_clkctl()
1974 dhdsdio_bussleep(dhd_bus_t *bus, bool sleep) in dhdsdio_bussleep() argument
1977 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_bussleep()
1978 sdpcmd_regs_t *regs = bus->regs; in dhdsdio_bussleep()
1989 (bus->sleeping ? "SLEEP" : "WAKE"))); in dhdsdio_bussleep()
1991 if (bus->dhd->hang_was_sent) in dhdsdio_bussleep()
1995 if (sleep == bus->sleeping) in dhdsdio_bussleep()
2002 if (bus->dpc_sched || bus->rxskip || pktq_n_pkts_tot(&bus->txq) || in dhdsdio_bussleep()
2003 bus->readframes || bus->ctrl_frame_stat) in dhdsdio_bussleep()
2005 if (bus->dpc_sched || bus->rxskip || pktq_n_pkts_tot(&bus->txq)) in dhdsdio_bussleep()
2009 state = wl_ext_any_sta_handshaking(bus->dhd); in dhdsdio_bussleep()
2021 * actively using the bus, we will return BCME_BUSY from here, but the bus->sleeping in dhdsdio_bussleep()
2030 if (bus->bt_use_count != 0) { in dhdsdio_bussleep()
2038 if (!SLPAUTO_ENAB(bus)) { in dhdsdio_bussleep()
2040 bcmsdh_intr_disable(bus->sdh); in dhdsdio_bussleep()
2042 /* Make sure the controller has the bus up */ in dhdsdio_bussleep()
2043 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_bussleep()
2051 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhdsdio_bussleep()
2056 /* Isolate the bus */ in dhdsdio_bussleep()
2069 err = dhdsdio_clk_devsleep_iovar(bus, TRUE /* sleep */); in dhdsdio_bussleep()
2073 bus->sleeping = TRUE; in dhdsdio_bussleep()
2076 err = bcmsdh_iovar_op(bus->sdh, "sd3_tuning_disable", NULL, 0, in dhdsdio_bussleep()
2080 wake_up(&bus->bus_sleep); in dhdsdio_bussleep()
2085 /* Waking up: bus power up is ok, set local state */ in dhdsdio_bussleep()
2087 if (!SLPAUTO_ENAB(bus)) { in dhdsdio_bussleep()
2096 /* Make sure the controller has the bus up */ in dhdsdio_bussleep()
2097 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_bussleep()
2107 /* Make sure we have SD bus access */ in dhdsdio_bussleep()
2108 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhdsdio_bussleep()
2111 if (bus->intr && (bus->dhd->busstate == DHD_BUS_DATA)) { in dhdsdio_bussleep()
2112 bus->intdis = FALSE; in dhdsdio_bussleep()
2113 bcmsdh_intr_enable(bus->sdh); in dhdsdio_bussleep()
2116 err = dhdsdio_clk_devsleep_iovar(bus, FALSE /* wake */); in dhdsdio_bussleep()
2126 dhd_pub_t *dhd = bus->dhd; in dhdsdio_bussleep()
2142 bus->sleeping = FALSE; in dhdsdio_bussleep()
2145 err = bcmsdh_iovar_op(bus->sdh, "sd3_tuning_disable", NULL, 0, in dhdsdio_bussleep()
2158 * bus - Pointer to the dhd_bus handle
2162 int __dhdsdio_clk_enable(struct dhd_bus *bus, bus_owner_t owner, int can_wait) in __dhdsdio_clk_enable() argument
2168 bus->bt_use_count++; in __dhdsdio_clk_enable()
2176 BUS_WAKE(bus); in __dhdsdio_clk_enable()
2182 ret = dhdsdio_clkctl(bus, CLK_AVAIL, can_wait); in __dhdsdio_clk_enable()
2185 bus->bt_use_count)); in __dhdsdio_clk_enable()
2192 * bus - Pointer to the dhd_bus handle
2196 int __dhdsdio_clk_disable(struct dhd_bus *bus, bus_owner_t owner, int can_wait) in __dhdsdio_clk_disable() argument
2203 if (bus->bt_use_count == 0) { in __dhdsdio_clk_disable()
2209 bus->bt_use_count--; in __dhdsdio_clk_disable()
2212 * When the SDIO Bus is shared between BT & WLAN, we turn Off the clock in __dhdsdio_clk_disable()
2214 * in that too. We consider WLAN as the bus master (even if its not in __dhdsdio_clk_disable()
2216 * So this Bus Watchdog is the context whill put the Bus to sleep. in __dhdsdio_clk_disable()
2222 bus->bt_use_count)); in __dhdsdio_clk_disable()
2226 void dhdsdio_reset_bt_use_count(struct dhd_bus *bus) in dhdsdio_reset_bt_use_count() argument
2229 bus->bt_use_count = 0; in dhdsdio_reset_bt_use_count()
2266 dhd_enable_oob_intr(struct dhd_bus *bus, bool enable) in dhd_enable_oob_intr() argument
2269 bcmsdh_intr_enable(bus->sdh); in dhd_enable_oob_intr()
2271 bcmsdh_enable_hw_oob_intr(bus->sdh, enable); in dhd_enable_oob_intr()
2273 sdpcmd_regs_t *regs = bus->regs; in dhd_enable_oob_intr()
2276 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_enable_oob_intr()
2292 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhd_enable_oob_intr()
2298 dhd_bus_txdata(struct dhd_bus *bus, void *pkt) in dhd_bus_txdata() argument
2306 osh = bus->dhd->osh; in dhd_bus_txdata()
2311 if (bus->ext_loop) { in dhd_bus_txdata()
2316 *data++ = (uint8)bus->loopid++; in dhd_bus_txdata()
2328 if (bus->dhd->conf->orphan_move == 1) in dhd_bus_txdata()
2329 PKTORPHAN(pkt, bus->dhd->conf->tsq); in dhd_bus_txdata()
2332 if (dhd_deferred_tx || bus->fcstate || pktq_n_pkts_tot(&bus->txq) || bus->dpc_sched || in dhd_bus_txdata()
2333 (!DATAOK(bus)) || (bus->flowcontrol & NBITVAL(prec)) || in dhd_bus_txdata()
2334 (bus->clkstate != CLK_AVAIL)) { in dhd_bus_txdata()
2339 pktq_n_pkts_tot(&bus->txq))); in dhd_bus_txdata()
2341 if (!bus->fcstate) in dhd_bus_txdata()
2342 bus->tx_deferred++; in dhd_bus_txdata()
2344 bus->fcqueued++; in dhd_bus_txdata()
2347 dhd_os_sdlock_txq(bus->dhd); in dhd_bus_txdata()
2348 deq_ret = dhd_prec_enq(bus->dhd, &bus->txq, pkt, prec); in dhd_bus_txdata()
2349 dhd_os_sdunlock_txq(bus->dhd); in dhd_bus_txdata()
2357 if (dhd_tcpack_check_xmit(bus->dhd, pkt) == BCME_ERROR) { in dhd_bus_txdata()
2360 dhd_tcpack_suppress_set(bus->dhd, TCPACK_SUP_OFF); in dhd_bus_txdata()
2363 dhd_txcomplete(bus->dhd, pkt, FALSE); in dhd_bus_txdata()
2372 dhd_os_sdlock_txq(bus->dhd); in dhd_bus_txdata()
2373 pkq_len = pktq_n_pkts_tot(&bus->txq); in dhd_bus_txdata()
2374 dhd_os_sdunlock_txq(bus->dhd); in dhd_bus_txdata()
2379 wlfc_enabled = (dhd_wlfc_flowcontrol(bus->dhd, ON, FALSE) != in dhd_bus_txdata()
2383 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, ON); in dhd_bus_txdata()
2388 dhd_os_sdlock_txq(bus->dhd); in dhd_bus_txdata()
2389 if (pktqprec_n_pkts(&bus->txq, prec) > qcount[prec]) in dhd_bus_txdata()
2390 qcount[prec] = pktqprec_n_pkts(&bus->txq, prec); in dhd_bus_txdata()
2391 dhd_os_sdunlock_txq(bus->dhd); in dhd_bus_txdata()
2396 if (dhd_deferred_tx && !bus->dpc_sched) { in dhd_bus_txdata()
2397 if (bus->dhd->conf->deferred_tx_len) { in dhd_bus_txdata()
2398 if(dhd_os_wd_timer_enabled(bus->dhd) == FALSE) { in dhd_bus_txdata()
2399 bus->dpc_sched = TRUE; in dhd_bus_txdata()
2400 dhd_sched_dpc(bus->dhd); in dhd_bus_txdata()
2402 if(pktq_n_pkts_tot(&bus->txq) >= bus->dhd->conf->deferred_tx_len && in dhd_bus_txdata()
2403 dhd_os_wd_timer_enabled(bus->dhd) == FALSE) { in dhd_bus_txdata()
2404 bus->dpc_sched = TRUE; in dhd_bus_txdata()
2405 dhd_sched_dpc(bus->dhd); in dhd_bus_txdata()
2408 bus->dpc_sched = TRUE; in dhd_bus_txdata()
2409 dhd_sched_dpc(bus->dhd); in dhd_bus_txdata()
2416 chan = (bus->ext_loop ? SDPCM_TEST_CHANNEL : SDPCM_DATA_CHANNEL); in dhd_bus_txdata()
2419 dhd_os_sdlock(bus->dhd); in dhd_bus_txdata()
2422 BUS_WAKE(bus); in dhd_bus_txdata()
2424 dhdsdio_clkctl(bus, CLK_AVAIL, TRUE); in dhd_bus_txdata()
2426 ret = dhdsdio_txpkt(bus, chan, &pkt, 1, TRUE); in dhd_bus_txdata()
2429 bus->dhd->tx_errors++; in dhd_bus_txdata()
2431 bus->dhd->dstats.tx_bytes += datalen; in dhd_bus_txdata()
2433 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhd_bus_txdata()
2434 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhd_bus_txdata()
2435 bus->activity = FALSE; in dhd_bus_txdata()
2436 dhdsdio_bussleep(bus, TRUE); in dhd_bus_txdata()
2437 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_txdata()
2440 dhd_os_sdunlock(bus->dhd); in dhd_bus_txdata()
2460 static int dhdsdio_txpkt_preprocess(dhd_bus_t *bus, void *pkt, int chan, int txseq, in dhdsdio_txpkt_preprocess() argument
2477 uint8 sdpcm_hdrlen = bus->txglom_enable ? SDPCM_HDRLEN_TXGLOM : SDPCM_HDRLEN; in dhdsdio_txpkt_preprocess()
2483 osh = bus->dhd->osh; in dhdsdio_txpkt_preprocess()
2486 if (dhd_tcpack_check_xmit(bus->dhd, pkt) == BCME_ERROR) { in dhdsdio_txpkt_preprocess()
2489 dhd_tcpack_suppress_set(bus->dhd, TCPACK_SUP_OFF); in dhdsdio_txpkt_preprocess()
2504 bus->tx_statics.ctrl_count++; in dhdsdio_txpkt_preprocess()
2505 bus->tx_statics.ctrl_size += len; in dhdsdio_txpkt_preprocess()
2508 bus->tx_statics.data_count++; in dhdsdio_txpkt_preprocess()
2509 bus->tx_statics.data_size += len; in dhdsdio_txpkt_preprocess()
2512 bus->tx_statics.glom_count++; in dhdsdio_txpkt_preprocess()
2513 bus->tx_statics.glom_size += len; in dhdsdio_txpkt_preprocess()
2516 bus->tx_statics.event_count++; in dhdsdio_txpkt_preprocess()
2517 bus->tx_statics.event_size += len; in dhdsdio_txpkt_preprocess()
2520 bus->tx_statics.test_count++; in dhdsdio_txpkt_preprocess()
2521 bus->tx_statics.test_size += len; in dhdsdio_txpkt_preprocess()
2559 if (last_chained_pkt && bus->blocksize != 0 && in dhdsdio_txpkt_preprocess()
2560 (cur_chain_total_len > (int)bus->blocksize || prev_chain_total_len > 0)) { in dhdsdio_txpkt_preprocess()
2561 modulo = cur_chain_total_len % bus->blocksize; in dhdsdio_txpkt_preprocess()
2562 chain_tail_padding = modulo > 0 ? (bus->blocksize - modulo) : 0; in dhdsdio_txpkt_preprocess()
2569 bus->tx_tailpad_pktget++; in dhdsdio_txpkt_preprocess()
2576 if (bus->pad_pkt) { in dhdsdio_txpkt_preprocess()
2578 bus->tx_tailpad_chain++; in dhdsdio_txpkt_preprocess()
2581 bus->tx_tailpad_pktget++; in dhdsdio_txpkt_preprocess()
2611 if (last_chained_pkt && bus->blocksize != 0 && in dhdsdio_txpkt_preprocess()
2612 (cur_total_len > (int)bus->blocksize || prev_chain_total_len > 0)) { in dhdsdio_txpkt_preprocess()
2613 modulo = cur_total_len % bus->blocksize; in dhdsdio_txpkt_preprocess()
2614 tail_padding = modulo > 0 ? (bus->blocksize - modulo) : 0; in dhdsdio_txpkt_preprocess()
2620 newpkt_size = PKTLEN(osh, pkt) + bus->blocksize + DHD_SDALIGN; in dhdsdio_txpkt_preprocess()
2621 bus->dhd->tx_realloc++; in dhdsdio_txpkt_preprocess()
2668 if (bus->dhd->conf->txglom_bucket_size) in dhdsdio_txpkt_preprocess()
2676 if (bus->txglom_enable) { in dhdsdio_txpkt_preprocess()
2682 if(bus->dhd->conf->txglom_ext && !last_chained_pkt) { in dhdsdio_txpkt_preprocess()
2686 pkt_len = bus->dhd->conf->txglom_bucket_size - TXGLOM_RECV_OFFSET; in dhdsdio_txpkt_preprocess()
2689 pkt_len = bus->dhd->conf->txglom_bucket_size; in dhdsdio_txpkt_preprocess()
2729 static int dhdsdio_txpkt_postprocess(dhd_bus_t *bus, void *pkt) in dhdsdio_txpkt_postprocess() argument
2735 int swhdr_offset = SDPCM_FRAMETAG_LEN + (bus->txglom_enable ? SDPCM_HWEXT_LEN : 0); in dhdsdio_txpkt_postprocess()
2738 osh = bus->dhd->osh; in dhdsdio_txpkt_postprocess()
2749 if (bus->txglom_enable) { in dhdsdio_txpkt_postprocess()
2776 static int dhdsdio_txpkt(dhd_bus_t *bus, uint chan, void** pkts, int num_pkt, bool free_pkt) in dhdsdio_txpkt() argument
2792 if (bus->dhd->dongle_reset) in dhdsdio_txpkt()
2798 sdh = bus->sdh; in dhdsdio_txpkt()
2799 osh = bus->dhd->osh; in dhdsdio_txpkt()
2811 pkt_len = dhdsdio_txpkt_preprocess(bus, pkt, chan, bus->tx_seq + i, in dhdsdio_txpkt()
2833 if (bus->txglom_enable) { in dhdsdio_txpkt()
2846 PKTSETLEN(osh, bus->pad_pkt, pad_pkt_len); in dhdsdio_txpkt()
2847 PKTSETNEXT(osh, pkt, bus->pad_pkt); in dhdsdio_txpkt()
2857 if ((bus->dhd->conf->data_drop_mode == TXPKT_DROP) && (total_len > 500)) in dhdsdio_txpkt()
2861 ret = dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC, in dhdsdio_txpkt()
2864 bus->tx_seq = (bus->tx_seq + num_pkt) % SDPCM_SEQUENCE_WRAP; in dhdsdio_txpkt()
2875 dhdsdio_txpkt_postprocess(bus, pkt); in dhdsdio_txpkt()
2887 wlfc_enabled = (dhd_wlfc_txcomplete(bus->dhd, pkt, ret == 0) != in dhdsdio_txpkt()
2893 dhd_txcomplete(bus->dhd, pkt, ret != 0); in dhdsdio_txpkt()
2906 dhdsdio_sendfromq(dhd_bus_t *bus, uint maxframes) in dhdsdio_sendfromq() argument
2914 dhd_pub_t *dhd = bus->dhd; in dhdsdio_sendfromq()
2915 sdpcmd_regs_t *regs = bus->regs; in dhdsdio_sendfromq()
2927 if (!KSO_ENAB(bus)) { in dhdsdio_sendfromq()
2933 tx_prec_map = ~bus->flowcontrol; in dhdsdio_sendfromq()
2937 for (cnt = 0; (cnt < maxframes) && DATAOK(bus);) { in dhdsdio_sendfromq()
2944 dhd_os_sdlock_txq(bus->dhd); in dhdsdio_sendfromq()
2945 if (bus->txglom_enable) { in dhdsdio_sendfromq()
2946 uint32 glomlimit = (uint32)bus->txglomsize; in dhdsdio_sendfromq()
2948 if (bus->blocksize == 64) { in dhdsdio_sendfromq()
2949 glomlimit = MIN((uint32)bus->txglomsize, BLK_64_MAXTXGLOM); in dhdsdio_sendfromq()
2952 num_pkt = MIN((uint32)DATABUFCNT(bus), glomlimit); in dhdsdio_sendfromq()
2955 num_pkt = MIN(num_pkt, pktq_mlen(&bus->txq, tx_prec_map)); in dhdsdio_sendfromq()
2957 pkts[i] = pktq_mdeq(&bus->txq, tx_prec_map, &prec_out); in dhdsdio_sendfromq()
2989 dhd_dump_pkt(bus->dhd, BDC_GET_IF_IDX(bdc_header), pktdata, in dhdsdio_sendfromq()
2990 (uint32)PKTLEN(bus->dhd->osh, pkts[i]), TRUE, NULL, NULL); in dhdsdio_sendfromq()
2993 if (!bus->dhd->conf->orphan_move) in dhdsdio_sendfromq()
2994 PKTORPHAN(pkts[i], bus->dhd->conf->tsq); in dhdsdio_sendfromq()
2997 dhd_os_sdunlock_txq(bus->dhd); in dhdsdio_sendfromq()
3001 if (dhdsdio_txpkt(bus, SDPCM_DATA_CHANNEL, pkts, i, TRUE) != BCME_OK) in dhdsdio_sendfromq()
3005 bus->txglomframes++; in dhdsdio_sendfromq()
3006 bus->txglompkts += num_pkt; in dhdsdio_sendfromq()
3008 bus->tx_statics.glom_cnt_us[num_pkt-1] = in dhdsdio_sendfromq()
3009 (bus->tx_statics.glom_cnt[num_pkt-1]*bus->tx_statics.glom_cnt_us[num_pkt-1] in dhdsdio_sendfromq()
3010 + bcmsdh_get_spend_time(bus->sdh))/(bus->tx_statics.glom_cnt[num_pkt-1] + 1); in dhdsdio_sendfromq()
3016 bus->tx_statics.glom_cnt[num_pkt-1]++; in dhdsdio_sendfromq()
3017 if (num_pkt > bus->tx_statics.glom_max) in dhdsdio_sendfromq()
3018 bus->tx_statics.glom_max = num_pkt; in dhdsdio_sendfromq()
3023 if (!bus->intr && cnt) in dhdsdio_sendfromq()
3027 bus->f2txdata++; in dhdsdio_sendfromq()
3028 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_sendfromq()
3030 if (intstatus & bus->hostintmask) in dhdsdio_sendfromq()
3031 bus->ipend = TRUE; in dhdsdio_sendfromq()
3037 dhd_os_sdlock_txq(bus->dhd); in dhdsdio_sendfromq()
3038 txpktqlen = pktq_n_pkts_tot(&bus->txq); in dhdsdio_sendfromq()
3039 dhd_os_sdunlock_txq(bus->dhd); in dhdsdio_sendfromq()
3057 dhdsdio_sendpendctl(dhd_bus_t *bus) in dhdsdio_sendpendctl() argument
3059 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_sendpendctl()
3061 uint8* frame_seq = bus->ctrl_frame_buf + SDPCM_FRAMETAG_LEN; in dhdsdio_sendpendctl()
3063 if (bus->txglom_enable) in dhdsdio_sendpendctl()
3066 if (*frame_seq != bus->tx_seq) { in dhdsdio_sendpendctl()
3068 " frm_seq:%d != bus->tx_seq:%d, corrected\n", in dhdsdio_sendpendctl()
3069 __FUNCTION__, *frame_seq, bus->tx_seq)); in dhdsdio_sendpendctl()
3070 *frame_seq = bus->tx_seq; in dhdsdio_sendpendctl()
3073 ret = dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC, in dhdsdio_sendpendctl()
3074 (uint8 *)bus->ctrl_frame_buf, (uint32)bus->ctrl_frame_len, in dhdsdio_sendpendctl()
3077 bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; in dhdsdio_sendpendctl()
3079 bus->ctrl_frame_stat = FALSE; in dhdsdio_sendpendctl()
3080 dhd_wait_event_wakeup(bus->dhd); in dhdsdio_sendpendctl()
3084 dhd_bus_txctl(struct dhd_bus *bus, uchar *msg, uint msglen) in dhd_bus_txctl() argument
3092 uint8 sdpcm_hdrlen = bus->txglom_enable ? SDPCM_HDRLEN_TXGLOM : SDPCM_HDRLEN; in dhd_bus_txctl()
3096 if (bus->dhd->dongle_reset) in dhd_bus_txctl()
3099 /* Back the pointer to make a room for bus header */ in dhd_bus_txctl()
3117 if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { in dhd_bus_txctl()
3118 uint16 pad = bus->blocksize - (len % bus->blocksize); in dhd_bus_txctl()
3119 if ((pad <= bus->roundup) && (pad < bus->blocksize)) in dhd_bus_txctl()
3133 dhd_os_sdlock(bus->dhd); in dhd_bus_txctl()
3134 if (bus->dhd->conf->txctl_tmo_fix > 0 && !TXCTLOK(bus)) { in dhd_bus_txctl()
3135 bus->ctrl_wait = TRUE; in dhd_bus_txctl()
3136 dhd_os_sdunlock(bus->dhd); in dhd_bus_txctl()
3137 wait_event_interruptible_timeout(bus->ctrl_tx_wait, TXCTLOK(bus), in dhd_bus_txctl()
3138 msecs_to_jiffies(bus->dhd->conf->txctl_tmo_fix)); in dhd_bus_txctl()
3139 dhd_os_sdlock(bus->dhd); in dhd_bus_txctl()
3140 bus->ctrl_wait = FALSE; in dhd_bus_txctl()
3143 BUS_WAKE(bus); in dhd_bus_txctl()
3146 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_txctl()
3152 if (bus->txglom_enable) { in dhd_bus_txctl()
3156 | bus->tx_seq in dhd_bus_txctl()
3172 | bus->tx_seq | ((doff << SDPCM_DOFFSET_SHIFT) & SDPCM_DOFFSET_MASK); in dhd_bus_txctl()
3177 if (!TXCTLOK(bus)) in dhd_bus_txctl()
3179 DHD_INFO(("%s: No bus credit bus->tx_max %d, bus->tx_seq %d\n", in dhd_bus_txctl()
3180 __FUNCTION__, bus->tx_max, bus->tx_seq)); in dhd_bus_txctl()
3181 bus->ctrl_frame_stat = TRUE; in dhd_bus_txctl()
3183 bus->ctrl_frame_buf = frame; in dhd_bus_txctl()
3184 bus->ctrl_frame_len = len; in dhd_bus_txctl()
3187 dhd_os_sdunlock(bus->dhd); in dhd_bus_txctl()
3188 dhd_wait_for_event(bus->dhd, &bus->ctrl_frame_stat); in dhd_bus_txctl()
3189 dhd_os_sdlock(bus->dhd); in dhd_bus_txctl()
3191 if (!bus->dpc_sched) { in dhd_bus_txctl()
3192 bus->dpc_sched = TRUE; in dhd_bus_txctl()
3193 dhd_sched_dpc(bus->dhd); in dhd_bus_txctl()
3195 if (bus->ctrl_frame_stat) { in dhd_bus_txctl()
3196 dhd_wait_for_event(bus->dhd, &bus->ctrl_frame_stat); in dhd_bus_txctl()
3200 if (bus->ctrl_frame_stat == FALSE) { in dhd_bus_txctl()
3204 bus->dhd->txcnt_timeout++; in dhd_bus_txctl()
3205 if (!bus->dhd->hang_was_sent) { in dhd_bus_txctl()
3209 R_SDREG(status, &bus->regs->intstatus, retry); in dhd_bus_txctl()
3213 __FUNCTION__, bus->tx_max, bus->tx_seq, bus->clkstate)); in dhd_bus_txctl()
3216 __FUNCTION__, bus->dhd->txcnt_timeout)); in dhd_bus_txctl()
3220 bus->dhd->conf->rxlim_en, bus->rxlim_en, bus->rxlim_addr)); in dhd_bus_txctl()
3225 if ((bus->dhd->memdump_enabled) && in dhd_bus_txctl()
3226 (bus->dhd->txcnt_timeout >= MAX_CNTL_TX_TIMEOUT)) { in dhd_bus_txctl()
3228 bus->dhd->memdump_type = DUMP_TYPE_RESUMED_ON_TIMEOUT_TX; in dhd_bus_txctl()
3229 dhd_os_sdunlock(bus->dhd); in dhd_bus_txctl()
3230 dhd_bus_mem_dump(bus->dhd); in dhd_bus_txctl()
3231 dhd_os_sdlock(bus->dhd); in dhd_bus_txctl()
3235 bus->ctrl_frame_stat = FALSE; in dhd_bus_txctl()
3240 bus->dhd->txcnt_timeout = 0; in dhd_bus_txctl()
3241 bus->ctrl_frame_stat = TRUE; in dhd_bus_txctl()
3252 bus->tx_statics.ctrl_count++; in dhd_bus_txctl()
3253 bus->tx_statics.ctrl_size += len; in dhd_bus_txctl()
3255 ret = dhd_bcmsdh_send_buffer(bus, frame, len); in dhd_bus_txctl()
3257 bus->ctrl_frame_stat = FALSE; in dhd_bus_txctl()
3260 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhd_bus_txctl()
3261 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhd_bus_txctl()
3262 bus->activity = FALSE; in dhd_bus_txctl()
3263 dhdsdio_bussleep(bus, TRUE); in dhd_bus_txctl()
3264 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_txctl()
3267 dhd_os_sdunlock(bus->dhd); in dhd_bus_txctl()
3271 bus->dhd->tx_ctlerrs++; in dhd_bus_txctl()
3273 bus->dhd->tx_ctlpkts++; in dhd_bus_txctl()
3275 if (bus->dhd->txcnt_timeout >= MAX_CNTL_TX_TIMEOUT) { in dhd_bus_txctl()
3295 dhd_bus_rxctl(struct dhd_bus *bus, uchar *msg, uint msglen) in dhd_bus_rxctl() argument
3304 if (bus->dhd->dongle_reset) in dhd_bus_rxctl()
3308 timeleft = dhd_os_ioctl_resp_wait(bus->dhd, &bus->rxlen); in dhd_bus_rxctl()
3310 dhd_os_sdlock(bus->dhd); in dhd_bus_rxctl()
3311 rxlen = bus->rxlen; in dhd_bus_rxctl()
3312 bcopy(bus->rxctl, msg, MIN(msglen, rxlen)); in dhd_bus_rxctl()
3313 bus->rxlen = 0; in dhd_bus_rxctl()
3314 dhd_os_sdunlock(bus->dhd); in dhd_bus_rxctl()
3316 if (bus->dhd->conf->ctrl_resched > 0 && !rxlen && timeleft == 0) { in dhd_bus_rxctl()
3318 if (cnt <= bus->dhd->conf->ctrl_resched) { in dhd_bus_rxctl()
3320 R_SDREG(status, &bus->regs->intstatus, retry); in dhd_bus_rxctl()
3321 if ((status & I_HMB_HOST_INT) || PKT_AVAILABLE(bus, status)) { in dhd_bus_rxctl()
3324 bus->ipend = TRUE; in dhd_bus_rxctl()
3325 bus->dpc_sched = TRUE; in dhd_bus_rxctl()
3326 dhd_sched_dpc(bus->dhd); in dhd_bus_rxctl()
3329 timeleft = dhd_os_ioctl_resp_wait(bus->dhd, &bus->rxlen); in dhd_bus_rxctl()
3331 dhd_os_sdlock(bus->dhd); in dhd_bus_rxctl()
3332 rxlen = bus->rxlen; in dhd_bus_rxctl()
3333 bcopy(bus->rxctl, msg, MIN(msglen, rxlen)); in dhd_bus_rxctl()
3334 bus->rxlen = 0; in dhd_bus_rxctl()
3335 dhd_os_sdunlock(bus->dhd); in dhd_bus_rxctl()
3349 R_SDREG(status, &bus->regs->intstatus, retry); in dhd_bus_rxctl()
3355 if (!bus->dhd->dongle_trap_occured) { in dhd_bus_rxctl()
3357 bus->dhd->memdump_type = DUMP_TYPE_RESUMED_ON_TIMEOUT; in dhd_bus_rxctl()
3359 dhd_os_sdlock(bus->dhd); in dhd_bus_rxctl()
3360 dhdsdio_checkdied(bus, NULL, 0); in dhd_bus_rxctl()
3361 dhd_os_sdunlock(bus->dhd); in dhd_bus_rxctl()
3365 if (!bus->dhd->dongle_trap_occured) { in dhd_bus_rxctl()
3367 bus->dhd->memdump_type = DUMP_TYPE_RESUMED_UNKNOWN; in dhd_bus_rxctl()
3369 dhd_os_sdlock(bus->dhd); in dhd_bus_rxctl()
3370 dhdsdio_checkdied(bus, NULL, 0); in dhd_bus_rxctl()
3371 dhd_os_sdunlock(bus->dhd); in dhd_bus_rxctl()
3376 if (bus->dhd->memdump_enabled && !bus->dhd->dongle_trap_occured) in dhd_bus_rxctl()
3377 dhdsdio_mem_dump(bus); in dhd_bus_rxctl()
3382 bus->dhd->rxcnt_timeout++; in dhd_bus_rxctl()
3384 bus->dhd->rxcnt_timeout, rxlen)); in dhd_bus_rxctl()
3387 if (bus->dhd->memdump_enabled) { in dhd_bus_rxctl()
3388 bus->dhd->memdump_type = DUMP_TYPE_RESUMED_ON_TIMEOUT_RX; in dhd_bus_rxctl()
3389 dhd_bus_mem_dump(bus->dhd); in dhd_bus_rxctl()
3393 bus->dhd->rxcnt_timeout = 0; in dhd_bus_rxctl()
3397 bus->dhd->rx_ctlpkts++; in dhd_bus_rxctl()
3399 bus->dhd->rx_ctlerrs++; in dhd_bus_rxctl()
3401 if (bus->dhd->conf->rxcnt_timeout) in dhd_bus_rxctl()
3402 max_rxcnt = bus->dhd->conf->rxcnt_timeout; in dhd_bus_rxctl()
3405 if (bus->dhd->rxcnt_timeout >= max_rxcnt) { in dhd_bus_rxctl()
3416 if (bus->dhd->dongle_trap_occured) in dhd_bus_rxctl()
3593 dhd_bus_t *bus = dhdp->bus; in dhd_bus_dump() local
3598 bcm_bprintf(strbuf, "Bus SDIO structure:\n"); in dhd_bus_dump()
3600 bus->hostintmask, bus->intstatus, bus->sdpcm_ver); in dhd_bus_dump()
3602 bus->fcstate, pktq_n_pkts_tot(&bus->txq), bus->tx_seq, bus->tx_max, bus->rxskip, in dhd_bus_dump()
3603 bus->rxlen, bus->rx_seq); in dhd_bus_dump()
3605 bus->intr, bus->intrcount, bus->lastintrs, bus->spurious); in dhd_bus_dump()
3609 bcmsdh_get_total_wake(bus->sdh), bus->wake_counts.rxwake, in dhd_bus_dump()
3610 bus->wake_counts.rcwake); in dhd_bus_dump()
3613 bus->wake_counts.rx_ucast, bus->wake_counts.rx_mcast, in dhd_bus_dump()
3614 bus->wake_counts.rx_bcast, bus->wake_counts.rx_arp); in dhd_bus_dump()
3616 bus->wake_counts.rx_multi_ipv4, bus->wake_counts.rx_multi_ipv6, in dhd_bus_dump()
3617 bus->wake_counts.rx_icmpv6, bus->wake_counts.rx_multi_other); in dhd_bus_dump()
3619 bus->wake_counts.rx_icmpv6_ra, bus->wake_counts.rx_icmpv6_na, in dhd_bus_dump()
3620 bus->wake_counts.rx_icmpv6_ns); in dhd_bus_dump()
3624 if (bus->wake_counts.rc_event[i] != 0) in dhd_bus_dump()
3626 bus->wake_counts.rc_event[i]); in dhd_bus_dump()
3632 bus->pollrate, bus->pollcnt, bus->regfails); in dhd_bus_dump()
3637 bus->tx_tailpad_chain, bus->tx_tailpad_pktget); in dhd_bus_dump()
3640 bus->tx_sderrs, bus->fcqueued, bus->rxrtx, bus->rx_toolong, in dhd_bus_dump()
3641 bus->rxc_errors); in dhd_bus_dump()
3643 bus->rx_hdrfail, bus->rx_badhdr, bus->rx_badseq); in dhd_bus_dump()
3645 bus->fc_rcvd, bus->fc_xoff, bus->fc_xon); in dhd_bus_dump()
3647 bus->rxglomfail, bus->rxglomframes, bus->rxglompkts); in dhd_bus_dump()
3649 (bus->f2rxhdrs + bus->f2rxdata), bus->f2rxhdrs, bus->f2rxdata, in dhd_bus_dump()
3650 bus->f2txdata, bus->f1regdata); in dhd_bus_dump()
3652 dhd_dump_pct(strbuf, "\nRx: pkts/f2rd", bus->dhd->rx_packets, in dhd_bus_dump()
3653 (bus->f2rxhdrs + bus->f2rxdata)); in dhd_bus_dump()
3654 dhd_dump_pct(strbuf, ", pkts/f1sd", bus->dhd->rx_packets, bus->f1regdata); in dhd_bus_dump()
3655 dhd_dump_pct(strbuf, ", pkts/sd", bus->dhd->rx_packets, in dhd_bus_dump()
3656 (bus->f2rxhdrs + bus->f2rxdata + bus->f1regdata)); in dhd_bus_dump()
3657 dhd_dump_pct(strbuf, ", pkts/int", bus->dhd->rx_packets, bus->intrcount); in dhd_bus_dump()
3660 dhd_dump_pct(strbuf, "Rx: glom pct", (100 * bus->rxglompkts), in dhd_bus_dump()
3661 bus->dhd->rx_packets); in dhd_bus_dump()
3662 dhd_dump_pct(strbuf, ", pkts/glom", bus->rxglompkts, bus->rxglomframes); in dhd_bus_dump()
3665 dhd_dump_pct(strbuf, "Tx: pkts/f2wr", bus->dhd->tx_packets, bus->f2txdata); in dhd_bus_dump()
3666 dhd_dump_pct(strbuf, ", pkts/f1sd", bus->dhd->tx_packets, bus->f1regdata); in dhd_bus_dump()
3667 dhd_dump_pct(strbuf, ", pkts/sd", bus->dhd->tx_packets, in dhd_bus_dump()
3668 (bus->f2txdata + bus->f1regdata)); in dhd_bus_dump()
3669 dhd_dump_pct(strbuf, ", pkts/int", bus->dhd->tx_packets, bus->intrcount); in dhd_bus_dump()
3673 (bus->dhd->tx_packets + bus->dhd->rx_packets), in dhd_bus_dump()
3674 (bus->f2txdata + bus->f2rxhdrs + bus->f2rxdata)); in dhd_bus_dump()
3676 (bus->dhd->tx_packets + bus->dhd->rx_packets), bus->f1regdata); in dhd_bus_dump()
3678 (bus->dhd->tx_packets + bus->dhd->rx_packets), in dhd_bus_dump()
3679 (bus->f2txdata + bus->f2rxhdrs + bus->f2rxdata + bus->f1regdata)); in dhd_bus_dump()
3681 (bus->dhd->tx_packets + bus->dhd->rx_packets), bus->intrcount); in dhd_bus_dump()
3687 if (bus->pktgen_count) { in dhd_bus_dump()
3690 bus->pktgen_freq, bus->pktgen_count, bus->pktgen_print, in dhd_bus_dump()
3691 bus->pktgen_total, bus->pktgen_minlen, bus->pktgen_maxlen); in dhd_bus_dump()
3693 bus->pktgen_sent, bus->pktgen_rcvd, bus->pktgen_fail); in dhd_bus_dump()
3698 bus->dpc_sched, (bcmsdh_intr_pending(bus->sdh) ? " " : " not ")); in dhd_bus_dump()
3699 bcm_bprintf(strbuf, "blocksize %u roundup %u\n", bus->blocksize, bus->roundup); in dhd_bus_dump()
3702 bus->clkstate, bus->activity, bus->idletime, bus->idlecount, bus->sleeping); in dhd_bus_dump()
3704 bcm_bprintf(strbuf, "tx_deferred %d, fc 0x%x\n", bus->tx_deferred, bus->flowcontrol); in dhd_bus_dump()
3719 dhd_dump_pct(strbuf, "Tx: glom pct", (100 * bus->txglompkts), bus->dhd->tx_packets); in dhd_bus_dump()
3720 dhd_dump_pct(strbuf, ", pkts/glom", bus->txglompkts, bus->txglomframes); in dhd_bus_dump()
3722 bcm_bprintf(strbuf, "txglomframes %u, txglompkts %u\n", bus->txglomframes, bus->txglompkts); in dhd_bus_dump()
3729 dhd_bus_t *bus = (dhd_bus_t *)dhdp->bus; in dhd_bus_clearcounts() local
3731 bus->intrcount = bus->lastintrs = bus->spurious = bus->regfails = 0; in dhd_bus_clearcounts()
3732 bus->rxrtx = bus->rx_toolong = bus->rxc_errors = 0; in dhd_bus_clearcounts()
3733 bus->rx_hdrfail = bus->rx_badhdr = bus->rx_badseq = 0; in dhd_bus_clearcounts()
3735 bus->tx_tailpad_chain = bus->tx_tailpad_pktget = 0; in dhd_bus_clearcounts()
3737 bus->tx_sderrs = bus->fc_rcvd = bus->fc_xoff = bus->fc_xon = 0; in dhd_bus_clearcounts()
3738 bus->rxglomfail = bus->rxglomframes = bus->rxglompkts = 0; in dhd_bus_clearcounts()
3739 bus->f2rxhdrs = bus->f2rxdata = bus->f2txdata = bus->f1regdata = 0; in dhd_bus_clearcounts()
3741 bus->tx_deferred = bus->flowcontrol = 0; in dhd_bus_clearcounts()
3743 bus->txglomframes = bus->txglompkts = 0; in dhd_bus_clearcounts()
3748 dhdsdio_pktgen_get(dhd_bus_t *bus, uint8 *arg) in dhdsdio_pktgen_get() argument
3753 pktgen.freq = bus->pktgen_freq; in dhdsdio_pktgen_get()
3754 pktgen.count = bus->pktgen_count; in dhdsdio_pktgen_get()
3755 pktgen.print = bus->pktgen_print; in dhdsdio_pktgen_get()
3756 pktgen.total = bus->pktgen_total; in dhdsdio_pktgen_get()
3757 pktgen.minlen = bus->pktgen_minlen; in dhdsdio_pktgen_get()
3758 pktgen.maxlen = bus->pktgen_maxlen; in dhdsdio_pktgen_get()
3759 pktgen.numsent = bus->pktgen_sent; in dhdsdio_pktgen_get()
3760 pktgen.numrcvd = bus->pktgen_rcvd; in dhdsdio_pktgen_get()
3761 pktgen.numfail = bus->pktgen_fail; in dhdsdio_pktgen_get()
3762 pktgen.mode = bus->pktgen_mode; in dhdsdio_pktgen_get()
3763 pktgen.stop = bus->pktgen_stop; in dhdsdio_pktgen_get()
3771 dhdsdio_pktgen_set(dhd_bus_t *bus, uint8 *arg) in dhdsdio_pktgen_set() argument
3780 oldcnt = bus->pktgen_count; in dhdsdio_pktgen_set()
3781 oldmode = bus->pktgen_mode; in dhdsdio_pktgen_set()
3783 bus->pktgen_freq = pktgen.freq; in dhdsdio_pktgen_set()
3784 bus->pktgen_count = pktgen.count; in dhdsdio_pktgen_set()
3785 bus->pktgen_print = pktgen.print; in dhdsdio_pktgen_set()
3786 bus->pktgen_total = pktgen.total; in dhdsdio_pktgen_set()
3787 bus->pktgen_minlen = pktgen.minlen; in dhdsdio_pktgen_set()
3788 bus->pktgen_maxlen = pktgen.maxlen; in dhdsdio_pktgen_set()
3789 bus->pktgen_mode = pktgen.mode; in dhdsdio_pktgen_set()
3790 bus->pktgen_stop = pktgen.stop; in dhdsdio_pktgen_set()
3792 bus->pktgen_tick = bus->pktgen_ptick = 0; in dhdsdio_pktgen_set()
3794 bus->pktgen_prev_time = jiffies; in dhdsdio_pktgen_set()
3796 bus->pktgen_len = MAX(bus->pktgen_len, bus->pktgen_minlen); in dhdsdio_pktgen_set()
3797 bus->pktgen_len = MIN(bus->pktgen_len, bus->pktgen_maxlen); in dhdsdio_pktgen_set()
3800 if (bus->pktgen_count && (!oldcnt || oldmode != bus->pktgen_mode)) { in dhdsdio_pktgen_set()
3801 bus->pktgen_sent = bus->pktgen_prev_sent = bus->pktgen_rcvd = 0; in dhdsdio_pktgen_set()
3802 bus->pktgen_prev_rcvd = bus->pktgen_fail = 0; in dhdsdio_pktgen_set()
3810 dhdsdio_membytes(dhd_bus_t *bus, bool write, uint32 address, uint8 *data, uint size) in dhdsdio_membytes() argument
3821 if (REMAP_ENAB(bus) && REMAP_ISADDR(bus, address)) { in dhdsdio_membytes()
3822 address -= bus->orig_ramsize; in dhdsdio_membytes()
3834 if ((bcmerror = dhdsdio_set_siaddr_window(bus, address))) { in dhdsdio_membytes()
3845 pdata = bus->membuf; in dhdsdio_membytes()
3847 memcpy(bus->membuf, data, dsize); in dhdsdio_membytes()
3851 if ((bcmerror = bcmsdh_rwdata(bus->sdh, write, sdaddr, pdata, dsize))) { in dhdsdio_membytes()
3856 memcpy(data, bus->membuf, dsize); in dhdsdio_membytes()
3862 if ((bcmerror = dhdsdio_set_siaddr_window(bus, address))) { in dhdsdio_membytes()
3874 if (dhdsdio_set_siaddr_window(bus, bcmsdh_cur_sbwad(bus->sdh))) { in dhdsdio_membytes()
3876 bcmsdh_cur_sbwad(bus->sdh))); in dhdsdio_membytes()
3884 dhdsdio_txseq_sync(dhd_bus_t *bus, sdpcm_shared_t *sh) in dhdsdio_txseq_sync() argument
3886 struct dhd_conf *conf = bus->dhd->conf; in dhdsdio_txseq_sync()
3892 bus->rxlim_en = TRUE; in dhdsdio_txseq_sync()
3893 bus->rxlim_addr = sh->msgtrace_addr; in dhdsdio_txseq_sync()
3895 __FUNCTION__, bus->rxlim_addr)); in dhdsdio_txseq_sync()
3906 if (0 == dhdsdio_membytes(bus, FALSE, sh->txseq_sync_addr, (uint8 *)&val, 1)) { in dhdsdio_txseq_sync()
3907 if (bus->tx_seq != val) { in dhdsdio_txseq_sync()
3909 __FUNCTION__, bus->tx_seq, val)); in dhdsdio_txseq_sync()
3910 bus->tx_seq = val; in dhdsdio_txseq_sync()
3911 bus->tx_max = bus->tx_seq + 4; in dhdsdio_txseq_sync()
3923 bus->rxlim_en = 0; in dhdsdio_txseq_sync()
3934 dhdsdio_readshared(dhd_bus_t *bus, sdpcm_shared_t *sh) in dhdsdio_readshared() argument
3940 if (bus->sih == NULL) { in dhdsdio_readshared()
3941 if (bus->dhd && bus->dhd->dongle_reset) { in dhdsdio_readshared()
3945 ASSERT(bus->dhd); in dhdsdio_readshared()
3946 ASSERT(bus->sih); in dhdsdio_readshared()
3955 if ((CHIPID(bus->sih->chip) == BCM43430_CHIP_ID || in dhdsdio_readshared()
3956 CHIPID(bus->sih->chip) == BCM43018_CHIP_ID) && !dhdsdio_sr_cap(bus)) in dhdsdio_readshared()
3957 bus->srmemsize = 0; in dhdsdio_readshared()
3959 shaddr = bus->dongle_ram_base + bus->ramsize - 4; in dhdsdio_readshared()
3963 if ((rv = dhdsdio_membytes(bus, FALSE, shaddr, (uint8 *)&addr, 4)) < 0) in dhdsdio_readshared()
3975 if ((bus->srmemsize > 0) && (i++ == 0)) { in dhdsdio_readshared()
3976 shaddr -= bus->srmemsize; in dhdsdio_readshared()
3987 if ((rv = dhdsdio_membytes(bus, FALSE, addr, (uint8 *)sh, sizeof(sdpcm_shared_t))) < 0) in dhdsdio_readshared()
4000 dhdsdio_txseq_sync(bus, sh); in dhdsdio_readshared()
4030 dhdsdio_readconsole(dhd_bus_t *bus) in dhdsdio_readconsole() argument
4032 dhd_console_t *c = &bus->console; in dhdsdio_readconsole()
4038 if (bus->console_addr == 0) in dhdsdio_readconsole()
4041 if (!KSO_ENAB(bus)) in dhdsdio_readconsole()
4045 addr = bus->console_addr + OFFSETOF(hnd_cons_t, log); in dhdsdio_readconsole()
4046 if ((rv = dhdsdio_membytes(bus, FALSE, addr, (uint8 *)&c->log, sizeof(c->log))) < 0) in dhdsdio_readconsole()
4052 if ((c->buf = MALLOC(bus->dhd->osh, c->bufsize)) == NULL) in dhdsdio_readconsole()
4071 if ((rv = dhdsdio_membytes(bus, FALSE, addr, c->buf, c->bufsize)) < 0) in dhdsdio_readconsole()
4099 dhd_sendup_log(bus->dhd, line, n); in dhdsdio_readconsole()
4110 dhdsdio_checkdied(dhd_bus_t *bus, char *data, uint size) in dhdsdio_checkdied() argument
4136 mbuffer = data = MALLOC(bus->dhd->osh, msize); in dhdsdio_checkdied()
4144 if ((str = MALLOC(bus->dhd->osh, maxstrlen)) == NULL) { in dhdsdio_checkdied()
4150 if ((bcmerror = dhdsdio_readshared(bus, &l_sdpcm_shared)) < 0) in dhdsdio_checkdied()
4178 if ((bcmerror = dhdsdio_membytes(bus, FALSE, in dhdsdio_checkdied()
4189 if ((bcmerror = dhdsdio_membytes(bus, FALSE, in dhdsdio_checkdied()
4202 trap_t *tr = &bus->dhd->last_trap_info; in dhdsdio_checkdied()
4203 bus->dhd->dongle_trap_occured = TRUE; in dhdsdio_checkdied()
4204 if ((bcmerror = dhdsdio_membytes(bus, FALSE, in dhdsdio_checkdied()
4209 bus->dongle_trap_addr = ltoh32(l_sdpcm_shared.trap_addr); in dhdsdio_checkdied()
4211 dhd_bus_dump_trap_info(bus, &strbuf); in dhdsdio_checkdied()
4214 if ((rv = dhdsdio_membytes(bus, FALSE, addr, in dhdsdio_checkdied()
4219 if ((rv = dhdsdio_membytes(bus, FALSE, addr, in dhdsdio_checkdied()
4224 if ((rv = dhdsdio_membytes(bus, FALSE, addr, in dhdsdio_checkdied()
4233 !(console_buffer = MALLOC(bus->dhd->osh, console_size))) in dhdsdio_checkdied()
4236 if ((rv = dhdsdio_membytes(bus, FALSE, console_ptr, in dhdsdio_checkdied()
4270 if (bus->dhd->memdump_enabled && (l_sdpcm_shared.flags & SDPCM_SHARED_TRAP)) { in dhdsdio_checkdied()
4272 bus->dhd->memdump_type = DUMP_TYPE_DONGLE_TRAP; in dhdsdio_checkdied()
4275 * unlikely to have a better fix for now. The better Rearch of sdio bus in dhdsdio_checkdied()
4279 dhd_os_sdunlock(bus->dhd); in dhdsdio_checkdied()
4280 dhdsdio_mem_dump(bus); in dhdsdio_checkdied()
4281 dhd_os_sdlock(bus->dhd); in dhdsdio_checkdied()
4294 MFREE(bus->dhd->osh, mbuffer, msize); in dhdsdio_checkdied()
4296 MFREE(bus->dhd->osh, str, maxstrlen); in dhdsdio_checkdied()
4298 MFREE(bus->dhd->osh, console_buffer, console_size); in dhdsdio_checkdied()
4307 dhd_bus_t *bus = dhdp->bus; in dhd_bus_mem_dump() local
4309 DHD_ERROR(("%s: Bus is suspend so skip\n", __FUNCTION__)); in dhd_bus_mem_dump()
4312 return dhdsdio_mem_dump(bus); in dhd_bus_mem_dump()
4323 return dhdsdio_get_mem_dump(dhdp->bus); in dhd_bus_get_mem_dump()
4327 dhdsdio_get_mem_dump(dhd_bus_t *bus) in dhdsdio_get_mem_dump() argument
4330 int size = bus->ramsize; /* Full mem size */ in dhdsdio_get_mem_dump()
4331 uint32 start = bus->dongle_ram_base; /* Start address */ in dhdsdio_get_mem_dump()
4336 p_buf = dhd_get_fwdump_buf(bus->dhd, size); in dhdsdio_get_mem_dump()
4343 dhd_os_sdlock(bus->dhd); in dhdsdio_get_mem_dump()
4344 BUS_WAKE(bus); in dhdsdio_get_mem_dump()
4345 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_get_mem_dump()
4352 ret = dhdsdio_membytes(bus, FALSE, start, databuf, read_size); in dhdsdio_get_mem_dump()
4364 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhdsdio_get_mem_dump()
4365 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhdsdio_get_mem_dump()
4366 bus->activity = FALSE; in dhdsdio_get_mem_dump()
4367 dhdsdio_clkctl(bus, CLK_NONE, TRUE); in dhdsdio_get_mem_dump()
4370 dhd_os_sdunlock(bus->dhd); in dhdsdio_get_mem_dump()
4376 dhdsdio_mem_dump(dhd_bus_t *bus) in dhdsdio_mem_dump() argument
4381 dhdp = bus->dhd; in dhdsdio_mem_dump()
4387 ret = dhdsdio_get_mem_dump(bus); in dhdsdio_mem_dump()
4404 dhd_socram_dump(dhd_bus_t * bus) in dhd_socram_dump() argument
4407 return (dhdsdio_mem_dump(bus)); in dhd_socram_dump()
4414 dhdsdio_downloadvars(dhd_bus_t *bus, void *arg, int len) in dhdsdio_downloadvars() argument
4420 if (bus->dhd->up && in dhdsdio_downloadvars()
4431 if (bus->vars) in dhdsdio_downloadvars()
4432 MFREE(bus->dhd->osh, bus->vars, bus->varsz); in dhdsdio_downloadvars()
4434 bus->vars = MALLOC(bus->dhd->osh, len); in dhdsdio_downloadvars()
4435 bus->varsz = bus->vars ? len : 0; in dhdsdio_downloadvars()
4436 if (bus->vars == NULL) { in dhdsdio_downloadvars()
4442 bcopy(arg, bus->vars, bus->varsz); in dhdsdio_downloadvars()
4449 dhd_serialconsole(dhd_bus_t *bus, bool set, bool enable, int *bcmerror) in dhd_serialconsole() argument
4454 addr = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_addr); in dhd_serialconsole()
4455 data = SI_ENUM_BASE(bus->sih) + OFFSETOF(chipcregs_t, chipcontrol_data); in dhd_serialconsole()
4458 bcmsdh_reg_write(bus->sdh, addr, 4, 1); in dhd_serialconsole()
4459 if (bcmsdh_regfail(bus->sdh)) { in dhd_serialconsole()
4463 int_val = bcmsdh_reg_read(bus->sdh, data, 4); in dhd_serialconsole()
4464 if (bcmsdh_regfail(bus->sdh)) { in dhd_serialconsole()
4475 bcmsdh_reg_write(bus->sdh, data, 4, int_val); in dhd_serialconsole()
4476 if (bcmsdh_regfail(bus->sdh)) { in dhd_serialconsole()
4486 dhdsdio_doiovar(dhd_bus_t *bus, const bcm_iovar_t *vi, uint32 actionid, const char *name, in dhdsdio_doiovar() argument
4504 /* Some ioctls use the bus */ in dhdsdio_doiovar()
4505 dhd_os_sdlock(bus->dhd); in dhdsdio_doiovar()
4508 if (bus->dhd->dongle_reset && !(actionid == IOV_SVAL(IOV_DEVRESET) || in dhdsdio_doiovar()
4518 dhdsdio_clk_kso_iovar(bus, bool_val); in dhdsdio_doiovar()
4524 bus->dpc_sched = TRUE; in dhdsdio_doiovar()
4525 dhd_sched_dpc(bus->dhd); in dhdsdio_doiovar()
4527 bus->_slpauto = FALSE; in dhdsdio_doiovar()
4529 bus->_slpauto = TRUE; in dhdsdio_doiovar()
4531 bus->kso = TRUE; in dhdsdio_doiovar()
4533 bus->kso = FALSE; in dhdsdio_doiovar()
4537 dhdsdio_clk_devsleep_iovar(bus, bool_val); in dhdsdio_doiovar()
4538 if (!SLPAUTO_ENAB(bus) && (bool_val == FALSE) && (bus->ipend)) { in dhdsdio_doiovar()
4540 bus->dpc_sched)); in dhdsdio_doiovar()
4541 if (!bus->dpc_sched) { in dhdsdio_doiovar()
4542 bus->dpc_sched = TRUE; in dhdsdio_doiovar()
4543 dhd_sched_dpc(bus->dhd); in dhdsdio_doiovar()
4553 bcmerror = dhdsdio_bussleep(bus, bool_val); in dhdsdio_doiovar()
4555 int_val = (int32)bus->sleeping; in dhdsdio_doiovar()
4562 if (!bus->dhd->dongle_reset) { in dhdsdio_doiovar()
4563 BUS_WAKE(bus); in dhdsdio_doiovar()
4564 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_doiovar()
4569 int_val = (int32)bus->intr; in dhdsdio_doiovar()
4574 bus->intr = bool_val; in dhdsdio_doiovar()
4575 bus->intdis = FALSE; in dhdsdio_doiovar()
4576 if (bus->dhd->up) { in dhdsdio_doiovar()
4577 if (bus->intr) { in dhdsdio_doiovar()
4580 bus->intdis = TRUE; in dhdsdio_doiovar()
4581 bcmsdh_intr_enable(bus->sdh); in dhdsdio_doiovar()
4584 bcmsdh_intr_disable(bus->sdh); in dhdsdio_doiovar()
4590 int_val = (int32)bus->pollrate; in dhdsdio_doiovar()
4595 bus->pollrate = (uint)int_val; in dhdsdio_doiovar()
4596 bus->poll = (bus->pollrate != 0); in dhdsdio_doiovar()
4600 int_val = bus->idletime; in dhdsdio_doiovar()
4608 bus->idletime = int_val; in dhdsdio_doiovar()
4613 int_val = (int32)bus->idleclock; in dhdsdio_doiovar()
4618 bus->idleclock = int_val; in dhdsdio_doiovar()
4632 bcmerror = dhdsdio_checkdied(bus, arg, len); in dhdsdio_doiovar()
4665 if (si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) { in dhdsdio_doiovar()
4670 if (set && address == bus->dongle_ram_base) { in dhdsdio_doiovar()
4671 bus->resetinstr = *(((uint32*)params) + 2); in dhdsdio_doiovar()
4679 bcmerror = dhdsdio_membytes(bus, set, address, data, size); in dhdsdio_doiovar()
4686 int_val = (int32)bus->ramsize; in dhdsdio_doiovar()
4691 int_val = (int32)bus->dongle_ram_base; in dhdsdio_doiovar()
4702 si_sdiod_drive_strength_init(bus->sih, bus->dhd->osh, dhd_sdiod_drive_strength); in dhdsdio_doiovar()
4706 bcmerror = dhdsdio_download_state(bus, bool_val); in dhdsdio_doiovar()
4710 bcmerror = dhdsdio_download_state(bus, bool_val); in dhdsdio_doiovar()
4714 bcmerror = dhdsdio_downloadvars(bus, arg, len); in dhdsdio_doiovar()
4724 bus->nextlen = 0; in dhdsdio_doiovar()
4729 int_val = (int32)bus->use_rxchain; in dhdsdio_doiovar()
4734 if (bool_val && !bus->sd_rxchain) in dhdsdio_doiovar()
4737 bus->use_rxchain = bool_val; in dhdsdio_doiovar()
4757 if (bus->varsz < (uint)len) in dhdsdio_doiovar()
4758 bcopy(bus->vars, arg, bus->varsz); in dhdsdio_doiovar()
4774 addr = ((uintptr)bus->regs + sd_ptr->offset); in dhdsdio_doiovar()
4776 int_val = (int32)bcmsdh_reg_read(bus->sdh, addr, size); in dhdsdio_doiovar()
4777 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_doiovar()
4791 addr = ((uintptr)bus->regs + sd_ptr->offset); in dhdsdio_doiovar()
4793 bcmsdh_reg_write(bus->sdh, addr, size, sd_ptr->value); in dhdsdio_doiovar()
4794 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_doiovar()
4808 addr = SI_ENUM_BASE(bus->sih) + sdreg.offset; in dhdsdio_doiovar()
4810 int_val = (int32)bcmsdh_reg_read(bus->sdh, addr, size); in dhdsdio_doiovar()
4811 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_doiovar()
4824 addr = SI_ENUM_BASE(bus->sih) + sdreg.offset; in dhdsdio_doiovar()
4826 bcmsdh_reg_write(bus->sdh, addr, size, sdreg.value); in dhdsdio_doiovar()
4827 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_doiovar()
4838 bcmsdh_cis_read(bus->sdh, 0x10, (uint8 *)arg + strlen(arg), SBSDIO_CIS_SIZE_LIMIT); in dhdsdio_doiovar()
4840 bcmsdh_cis_read(bus->sdh, 0x11, (uint8 *)arg + strlen(arg), SBSDIO_CIS_SIZE_LIMIT); in dhdsdio_doiovar()
4842 bcmsdh_cis_read(bus->sdh, 0x12, (uint8 *)arg + strlen(arg), SBSDIO_CIS_SIZE_LIMIT); in dhdsdio_doiovar()
4884 int_val = dhd_serialconsole(bus, FALSE, 0, &bcmerror); in dhdsdio_doiovar()
4892 dhd_serialconsole(bus, TRUE, bool_val, &bcmerror); in dhdsdio_doiovar()
4899 si_viewall(bus->sih, TRUE); in dhdsdio_doiovar()
4923 if (bus->bus == SPI_BUS) in dhdsdio_doiovar()
4951 bcmerror = srom_read(bus->sih, DHD_BUS, (void*)bus->regs, bus->dhd->osh, in dhdsdio_doiovar()
4964 bcmerror = srom_write(bus->sih, DHD_BUS, (void*)bus->regs, bus->dhd->osh, in dhdsdio_doiovar()
4974 int_val = (int32)bus->ext_loop; in dhdsdio_doiovar()
4979 bus->ext_loop = bool_val; in dhdsdio_doiovar()
4983 bcmerror = dhdsdio_pktgen_get(bus, arg); in dhdsdio_doiovar()
4987 bcmerror = dhdsdio_pktgen_set(bus, arg); in dhdsdio_doiovar()
5001 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_WATERMARK, (uint8)watermark, NULL); in dhdsdio_doiovar()
5014 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_MESBUSYCTRL, in dhdsdio_doiovar()
5039 if (tstoph && bus->dhd->busstate == DHD_BUS_DOWN) { in dhdsdio_doiovar()
5041 bus->dhd->busstate = DHD_BUS_DATA; in dhdsdio_doiovar()
5042 if (bus->intr) { in dhdsdio_doiovar()
5043 bus->intdis = FALSE; in dhdsdio_doiovar()
5044 bcmsdh_intr_enable(bus->sdh); in dhdsdio_doiovar()
5075 if (!(buf = MALLOC(bus->dhd->osh, int_val))) { in dhdsdio_doiovar()
5081 ret = dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(bus->sdh), SDIO_FUNC_2, in dhdsdio_doiovar()
5084 ret = dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(bus->sdh), SDIO_FUNC_2, in dhdsdio_doiovar()
5091 MFREE(bus->dhd->osh, buf, int_val); in dhdsdio_doiovar()
5098 if (!(si_setcore(bus->sih, ARM7S_CORE_ID, 0)) && in dhdsdio_doiovar()
5099 !(si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) { in dhdsdio_doiovar()
5107 si_core_reset(bus->sih, 0, 0); in dhdsdio_doiovar()
5109 si_core_disable(bus->sih, 0); in dhdsdio_doiovar()
5111 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_doiovar()
5115 if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0)) in dhdsdio_doiovar()
5116 si_setcore(bus->sih, SDIOD_CORE_ID, 0); in dhdsdio_doiovar()
5121 if (!(si_setcore(bus->sih, ARM7S_CORE_ID, 0)) && in dhdsdio_doiovar()
5122 !(si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) { in dhdsdio_doiovar()
5129 int_val = (int32)si_iscoreup(bus->sih); in dhdsdio_doiovar()
5133 if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0)) in dhdsdio_doiovar()
5134 si_setcore(bus->sih, SDIOD_CORE_ID, 0); in dhdsdio_doiovar()
5138 bcmsdh_reset(bus->sdh); in dhdsdio_doiovar()
5143 bcmsdh_abort(bus->sdh, int_val); in dhdsdio_doiovar()
5157 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF); in dhdsdio_doiovar()
5161 int_val = (int32)bus->clockpoll; in dhdsdio_doiovar()
5166 int_val = (int32)bus->ramsize; in dhdsdio_doiovar()
5172 dhd_dongle_setramsize(bus, dhd_dongle_ramsize); in dhdsdio_doiovar()
5176 bus->clockpoll = bool_val; in dhdsdio_doiovar()
5181 int_val = bus->dhd->dongle_isolation; in dhdsdio_doiovar()
5186 bus->dhd->dongle_isolation = bool_val; in dhdsdio_doiovar()
5191 __FUNCTION__, bool_val, bus->dhd->dongle_reset, in dhdsdio_doiovar()
5192 bus->dhd->busstate)); in dhdsdio_doiovar()
5194 ASSERT(bus->dhd->osh); in dhdsdio_doiovar()
5195 /* ASSERT(bus->cl_devid); */ in dhdsdio_doiovar()
5198 dhd_os_sdunlock(bus->dhd); in dhdsdio_doiovar()
5199 dhd_bus_devreset(bus->dhd, (uint8)bool_val); in dhdsdio_doiovar()
5200 dhd_os_sdlock(bus->dhd); in dhdsdio_doiovar()
5210 int_val = (bool) bus->dhd->dongle_reset; in dhdsdio_doiovar()
5216 int_val = dhdsdio_sleepcsr_get(bus); in dhdsdio_doiovar()
5221 int_val = dhdsdio_devcap_get(bus); in dhdsdio_doiovar()
5226 dhdsdio_devcap_set(bus, (uint8) int_val); in dhdsdio_doiovar()
5229 int_val = (int32)bus->txglomsize; in dhdsdio_doiovar()
5237 bus->txglomsize = (uint)int_val; in dhdsdio_doiovar()
5241 bus->dhd->hang_report = bool_val; in dhdsdio_doiovar()
5242 DHD_ERROR(("%s: Set hang_report as %d\n", __FUNCTION__, bus->dhd->hang_report)); in dhdsdio_doiovar()
5246 int_val = (int32)bus->dhd->hang_report; in dhdsdio_doiovar()
5251 int_val = bus->txinrx_thres; in dhdsdio_doiovar()
5258 bus->txinrx_thres = int_val; in dhdsdio_doiovar()
5263 int_val = (bus->dhd->busstate == DHD_BUS_SUSPEND) ? 1 : 0; in dhdsdio_doiovar()
5269 dhdsdio_suspend(bus); in dhdsdio_doiovar()
5272 dhdsdio_resume(bus); in dhdsdio_doiovar()
5279 debugger_init((void *) bus, &bus_ops, int_val, SI_ENUM_BASE(bus->sih)); in dhdsdio_doiovar()
5292 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhdsdio_doiovar()
5293 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhdsdio_doiovar()
5294 bus->activity = FALSE; in dhdsdio_doiovar()
5295 dhdsdio_bussleep(bus, TRUE); in dhdsdio_doiovar()
5296 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhdsdio_doiovar()
5299 dhd_os_sdunlock(bus->dhd); in dhdsdio_doiovar()
5305 dhdsdio_write_vars(dhd_bus_t *bus) in dhdsdio_write_vars() argument
5317 varsize = bus->varsz ? ROUNDUP(bus->varsz, 4) : 0; in dhdsdio_write_vars()
5318 varaddr = (bus->ramsize - 4) - varsize; in dhdsdio_write_vars()
5321 if (bus->dhd->conf->chip == BCM43340_CHIP_ID || in dhdsdio_write_vars()
5322 bus->dhd->conf->chip == BCM43341_CHIP_ID) { in dhdsdio_write_vars()
5324 varaddr = (bus->ramsize - 64) - varsize; in dhdsdio_write_vars()
5327 varaddr += bus->dongle_ram_base; in dhdsdio_write_vars()
5329 if (bus->vars) { in dhdsdio_write_vars()
5331 if ((bus->sih->buscoretype == SDIOD_CORE_ID) && (bus->sdpcmrev == 7)) { in dhdsdio_write_vars()
5340 vbuffer = (uint8 *)MALLOC(bus->dhd->osh, varsize); in dhdsdio_write_vars()
5345 bcopy(bus->vars, vbuffer, bus->varsz); in dhdsdio_write_vars()
5348 bcmerror = dhdsdio_membytes(bus, TRUE, varaddr, vbuffer, varsize); in dhdsdio_write_vars()
5358 nvram_ularray = (uint8*)MALLOC(bus->dhd->osh, varsize); in dhdsdio_write_vars()
5360 MFREE(bus->dhd->osh, vbuffer, varsize); in dhdsdio_write_vars()
5368 bcmerror = dhdsdio_membytes(bus, FALSE, varaddr, nvram_ularray, varsize); in dhdsdio_write_vars()
5380 MFREE(bus->dhd->osh, nvram_ularray, varsize); in dhdsdio_write_vars()
5383 MFREE(bus->dhd->osh, vbuffer, varsize); in dhdsdio_write_vars()
5387 phys_size = bus->ramsize; in dhdsdio_write_vars()
5389 phys_size = REMAP_ENAB(bus) ? bus->ramsize : bus->orig_ramsize; in dhdsdio_write_vars()
5392 phys_size += bus->dongle_ram_base; in dhdsdio_write_vars()
5396 phys_size, bus->ramsize)); in dhdsdio_write_vars()
5419 bcmerror = dhdsdio_membytes(bus, TRUE, (phys_size - 4), in dhdsdio_write_vars()
5426 dhd_bus_is_multibp_capable(struct dhd_bus *bus) in dhd_bus_is_multibp_capable() argument
5428 return MULTIBP_CAP(bus->sih); in dhd_bus_is_multibp_capable()
5432 dhdsdio_download_state(dhd_bus_t *bus, bool enter) in dhdsdio_download_state() argument
5438 if (!bus->sih) in dhdsdio_download_state()
5444 bus->alp_only = TRUE; in dhdsdio_download_state()
5446 if (!(si_setcore(bus->sih, ARM7S_CORE_ID, 0)) && in dhdsdio_download_state()
5447 !(si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) { in dhdsdio_download_state()
5448 if (si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) { in dhdsdio_download_state()
5458 si_core_disable(bus->sih, 0); in dhdsdio_download_state()
5459 if (bcmsdh_regfail(bus->sdh)) { in dhdsdio_download_state()
5464 if (!(si_setcore(bus->sih, SOCRAM_CORE_ID, 0))) { in dhdsdio_download_state()
5470 si_core_reset(bus->sih, 0, 0); in dhdsdio_download_state()
5471 if (bcmsdh_regfail(bus->sdh)) { in dhdsdio_download_state()
5478 if (CHIPID(bus->sih->chip) == BCM43430_CHIP_ID || in dhdsdio_download_state()
5479 CHIPID(bus->sih->chip) == BCM43018_CHIP_ID) { in dhdsdio_download_state()
5481 si_socram_set_bankpda(bus->sih, 0x3, 0x0); in dhdsdio_download_state()
5485 if (bus->ramsize) { in dhdsdio_download_state()
5487 if (dhdsdio_membytes(bus, TRUE, bus->ramsize - 4, in dhdsdio_download_state()
5503 si_core_reset(bus->sih, SICF_CPUHALT, SICF_CPUHALT); in dhdsdio_download_state()
5506 if (!si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) { in dhdsdio_download_state()
5507 if (!(si_setcore(bus->sih, SOCRAM_CORE_ID, 0))) { in dhdsdio_download_state()
5513 if (!si_iscoreup(bus->sih)) { in dhdsdio_download_state()
5519 if ((bcmerror = dhdsdio_write_vars(bus))) { in dhdsdio_download_state()
5525 if (!si_setcore(bus->sih, CC_CORE_ID, 0)) { in dhdsdio_download_state()
5531 if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0) && in dhdsdio_download_state()
5532 !si_setcore(bus->sih, SDIOD_CORE_ID, 0)) { in dhdsdio_download_state()
5538 W_SDREG(0xFFFFFFFF, &bus->regs->intstatus, retries); in dhdsdio_download_state()
5542 if (!(si_setcore(bus->sih, ARM7S_CORE_ID, 0)) && in dhdsdio_download_state()
5543 !(si_setcore(bus->sih, ARMCM3_CORE_ID, 0))) { in dhdsdio_download_state()
5551 if ((bcmerror = dhdsdio_write_vars(bus))) { in dhdsdio_download_state()
5556 if (!si_setcore(bus->sih, CC_CORE_ID, 0)) { in dhdsdio_download_state()
5562 if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0) && in dhdsdio_download_state()
5563 !si_setcore(bus->sih, SDIOD_CORE_ID, 0)) { in dhdsdio_download_state()
5569 W_SDREG(0xFFFFFFFF, &bus->regs->intstatus, retries); in dhdsdio_download_state()
5572 if (!(si_setcore(bus->sih, ARMCR4_CORE_ID, 0))) { in dhdsdio_download_state()
5578 bcmerror = dhdsdio_membytes(bus, TRUE, 0, in dhdsdio_download_state()
5579 (uint8 *)&bus->resetinstr, sizeof(bus->resetinstr)); in dhdsdio_download_state()
5585 bcmerror = dhdsdio_membytes(bus, FALSE, 0, in dhdsdio_download_state()
5588 if (bcmerror == BCME_OK && tmp != bus->resetinstr) { in dhdsdio_download_state()
5590 __FUNCTION__, bus->resetinstr)); in dhdsdio_download_state()
5601 si_core_reset(bus->sih, 0, 0); in dhdsdio_download_state()
5602 if (bcmsdh_regfail(bus->sdh)) { in dhdsdio_download_state()
5609 bus->alp_only = FALSE; in dhdsdio_download_state()
5611 bus->dhd->busstate = DHD_BUS_LOAD; in dhdsdio_download_state()
5616 if (!si_setcore(bus->sih, PCMCIA_CORE_ID, 0)) in dhdsdio_download_state()
5617 si_setcore(bus->sih, SDIOD_CORE_ID, 0); in dhdsdio_download_state()
5626 dhd_bus_t *bus = dhdp->bus; in dhd_bus_iovar_op() local
5644 dhd_os_sdlock(bus->dhd); in dhd_bus_iovar_op()
5646 BUS_WAKE(bus); in dhd_bus_iovar_op()
5649 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_iovar_op()
5651 bcmerror = bcmsdh_iovar_op(bus->sdh, name, params, plen, arg, len, set); in dhd_bus_iovar_op()
5653 /* Check for bus configuration changes of interest */ in dhd_bus_iovar_op()
5657 if (bcmsdh_iovar_op(bus->sdh, "sd_divisor", NULL, 0, in dhd_bus_iovar_op()
5658 &bus->sd_divisor, sizeof(int32), FALSE) != BCME_OK) { in dhd_bus_iovar_op()
5659 bus->sd_divisor = -1; in dhd_bus_iovar_op()
5663 __FUNCTION__, name, bus->sd_divisor)); in dhd_bus_iovar_op()
5668 if (bcmsdh_iovar_op(bus->sdh, "sd_mode", NULL, 0, in dhd_bus_iovar_op()
5669 &bus->sd_mode, sizeof(int32), FALSE) != BCME_OK) { in dhd_bus_iovar_op()
5670 bus->sd_mode = -1; in dhd_bus_iovar_op()
5674 __FUNCTION__, name, bus->sd_mode)); in dhd_bus_iovar_op()
5680 if (bcmsdh_iovar_op(bus->sdh, "sd_blocksize", &fnum, sizeof(int32), in dhd_bus_iovar_op()
5681 &bus->blocksize, sizeof(int32), FALSE) != BCME_OK) { in dhd_bus_iovar_op()
5682 bus->blocksize = 0; in dhd_bus_iovar_op()
5686 __FUNCTION__, "sd_blocksize", bus->blocksize)); in dhd_bus_iovar_op()
5688 dhdsdio_tune_fifoparam(bus); in dhd_bus_iovar_op()
5691 bus->roundup = MIN(max_roundup, bus->blocksize); in dhd_bus_iovar_op()
5693 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhd_bus_iovar_op()
5694 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhd_bus_iovar_op()
5695 bus->activity = FALSE; in dhd_bus_iovar_op()
5696 dhdsdio_bussleep(bus, TRUE); in dhd_bus_iovar_op()
5697 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_iovar_op()
5700 dhd_os_sdunlock(bus->dhd); in dhd_bus_iovar_op()
5724 bcmerror = dhdsdio_doiovar(bus, vi, actionid, name, params, plen, arg, len, val_size); in dhd_bus_iovar_op()
5731 dhd_bus_stop(struct dhd_bus *bus, bool enforce_mutex) in dhd_bus_stop() argument
5741 if (!bus->dhd) in dhd_bus_stop()
5744 osh = bus->dhd->osh; in dhd_bus_stop()
5747 bcmsdh_waitlockfree(bus->sdh); in dhd_bus_stop()
5750 dhd_os_sdlock(bus->dhd); in dhd_bus_stop()
5752 if ((bus->dhd->busstate == DHD_BUS_DOWN) || bus->dhd->hang_was_sent) { in dhd_bus_stop()
5755 bus->dhd->busstate = DHD_BUS_DOWN; in dhd_bus_stop()
5756 bus->hostintmask = 0; in dhd_bus_stop()
5757 bcmsdh_intr_disable(bus->sdh); in dhd_bus_stop()
5760 BUS_WAKE(bus); in dhd_bus_stop()
5762 if (KSO_ENAB(bus)) { in dhd_bus_stop()
5765 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_stop()
5768 W_SDREG(0, &bus->regs->hostintmask, retries); in dhd_bus_stop()
5769 local_hostintmask = bus->hostintmask; in dhd_bus_stop()
5770 bus->hostintmask = 0; in dhd_bus_stop()
5773 saveclk = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); in dhd_bus_stop()
5775 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, in dhd_bus_stop()
5783 /* Turn off the bus (F2), free any pending packets */ in dhd_bus_stop()
5785 /* XXX New API: bcmsdh_fn_set(bus->sdh, SDIO_FUNC_2, FALSE); */ in dhd_bus_stop()
5788 bcmsdh_intr_disable(bus->sdh); /* XXX bcmsdh_intr_mask(bus->sdh); */ in dhd_bus_stop()
5791 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IOEN, SDIO_FUNC_ENABLE_1, NULL); in dhd_bus_stop()
5795 W_SDREG(local_hostintmask, &bus->regs->intstatus, retries); in dhd_bus_stop()
5799 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhd_bus_stop()
5801 /* Change our idea of bus state */ in dhd_bus_stop()
5802 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhd_bus_stop()
5804 bus->dhd->busstate = DHD_BUS_DOWN; in dhd_bus_stop()
5805 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhd_bus_stop()
5809 wlfc_enabled = (dhd_wlfc_cleanup_txq(bus->dhd, NULL, 0) != WLFC_UNSUPPORTED); in dhd_bus_stop()
5816 dhd_tcpack_info_tbl_clean(bus->dhd); in dhd_bus_stop()
5818 dhd_os_sdlock_txq(bus->dhd); in dhd_bus_stop()
5820 pktq_flush(osh, &bus->txq, TRUE); in dhd_bus_stop()
5821 dhd_os_sdunlock_txq(bus->dhd); in dhd_bus_stop()
5825 if (bus->glomd) in dhd_bus_stop()
5826 PKTFREE(osh, bus->glomd, FALSE); in dhd_bus_stop()
5828 if (bus->glom) in dhd_bus_stop()
5829 PKTFREE(osh, bus->glom, FALSE); in dhd_bus_stop()
5831 bus->glom = bus->glomd = NULL; in dhd_bus_stop()
5835 bus->rxlen = 0; in dhd_bus_stop()
5836 dhd_os_ioctl_resp_wake(bus->dhd); in dhd_bus_stop()
5839 bus->rxskip = FALSE; in dhd_bus_stop()
5840 bus->tx_seq = bus->rx_seq = 0; in dhd_bus_stop()
5848 bus->tx_max = 4; in dhd_bus_stop()
5851 dhd_os_sdunlock(bus->dhd); in dhd_bus_stop()
5864 dhd_bus_t *bus = dhdp->bus; in dhd_txglom_enable() local
5878 ret = dhd_iovar(dhdp, 0, "bus:rxglom", (char *)&rxglom, sizeof(rxglom), NULL, 0, in dhd_txglom_enable()
5881 bus->txglom_enable = TRUE; in dhd_txglom_enable()
5886 bus->txglom_enable = FALSE; in dhd_txglom_enable()
5890 bus->txglom_enable = FALSE; in dhd_txglom_enable()
5891 printf("%s: enable %d\n", __FUNCTION__, bus->txglom_enable); in dhd_txglom_enable()
5892 dhd_conf_set_txglom_params(bus->dhd, bus->txglom_enable); in dhd_txglom_enable()
5893 bcmsdh_set_mode(bus->sdh, bus->dhd->conf->txglom_mode); in dhd_txglom_enable()
5899 dhd_bus_t *bus = dhdp->bus; in dhd_bus_init() local
5915 ASSERT(bus->dhd); in dhd_bus_init()
5916 if (!bus->dhd) in dhd_bus_init()
5920 dhd_os_sdlock(bus->dhd); in dhd_bus_init()
5922 if (bus->sih->chip == BCM43362_CHIP_ID) { in dhd_bus_init()
5928 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_init()
5929 if (bus->clkstate != CLK_AVAIL) { in dhd_bus_init()
5930 DHD_ERROR(("%s: clock state is wrong. state = %d\n", __FUNCTION__, bus->clkstate)); in dhd_bus_init()
5943 dstatus = bcmsdh_cfg_read_word(bus->sdh, SDIO_FUNC_0, SPID_STATUS_REG, NULL); in dhd_bus_init()
5960 saveclk = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, &err); in dhd_bus_init()
5965 if (bus->sih->chip == BCM43012_CHIP_ID || in dhd_bus_init()
5966 bus->sih->chip == BCM43013_CHIP_ID || in dhd_bus_init()
5967 bus->sih->chip == BCM43014_CHIP_ID) { in dhd_bus_init()
5968 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, in dhd_bus_init()
5973 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_FUNC1_CHIPCLKCSR, in dhd_bus_init()
5987 &bus->regs->tosbmailboxdata, retries); in dhd_bus_init()
5990 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IOEN, enable, NULL); in dhd_bus_init()
6001 ready = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IORDY, NULL); in dhd_bus_init()
6010 intr_extn = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_INTR_EXTN, NULL); in dhd_bus_init()
6013 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_INTR_EXTN, intr_extn, NULL); in dhd_bus_init()
6027 bus->regs = si_setcore(bus->sih, CC_CORE_ID, 0); in dhd_bus_init()
6028 ASSERT(bus->regs != NULL); in dhd_bus_init()
6030 if (!(bus->regs = si_setcore(bus->sih, PCMCIA_CORE_ID, 0))) in dhd_bus_init()
6031 bus->regs = si_setcore(bus->sih, SDIOD_CORE_ID, 0); in dhd_bus_init()
6032 ASSERT(bus->regs != NULL); in dhd_bus_init()
6035 bus->hostintmask = HOSTINTMASK; in dhd_bus_init()
6038 if ((bus->sih->buscoretype == SDIOD_CORE_ID) && (bus->sdpcmrev == 4) && in dhd_bus_init()
6039 (bus->rxint_mode != SDIO_DEVICE_HMB_RXINT)) { in dhd_bus_init()
6040 bus->hostintmask &= ~I_HMB_FRAME_IND; in dhd_bus_init()
6041 bus->hostintmask |= I_XMTDATA_AVAIL; in dhd_bus_init()
6044 W_SDREG(bus->hostintmask, &bus->regs->hostintmask, retries); in dhd_bus_init()
6049 if (bus->sih->buscorerev < 15) { in dhd_bus_init()
6050 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, SBSDIO_WATERMARK, in dhd_bus_init()
6054 /* Set bus state according to enable result */ in dhd_bus_init()
6068 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, in dhd_bus_init()
6072 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, in dhd_bus_init()
6085 /* bcmsdh_intr_unmask(bus->sdh); */ in dhd_bus_init()
6087 bus->intdis = FALSE; in dhd_bus_init()
6088 if (bus->intr) { in dhd_bus_init()
6091 bcmsdh_intr_enable(bus->sdh); in dhd_bus_init()
6095 bcmsdh_intr_disable(bus->sdh); in dhd_bus_init()
6105 hostpending = bcmsdh_intr_pending(bus->sdh); in dhd_bus_init()
6106 devena = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_INTEN, NULL); in dhd_bus_init()
6107 devpend = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_INTPEND, NULL); in dhd_bus_init()
6109 R_SDREG(intstatus, &bus->regs->intstatus, sdr_retries); in dhd_bus_init()
6110 intstatus &= bus->hostintmask; in dhd_bus_init()
6115 devena, devpend, intstatus, bus->hostintmask)); in dhd_bus_init()
6129 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_IOEN, enable, NULL); in dhd_bus_init()
6132 if (dhdsdio_sr_cap(bus)) { in dhd_bus_init()
6133 dhdsdio_sr_init(bus); in dhd_bus_init()
6135 bus->hostintmask &= ~I_CHIPACTIVE; in dhd_bus_init()
6136 W_SDREG(bus->hostintmask, &bus->regs->hostintmask, retries); in dhd_bus_init()
6138 __FUNCTION__, bus->hostintmask)); in dhd_bus_init()
6140 bcmsdh_cfg_write(bus->sdh, SDIO_FUNC_1, in dhd_bus_init()
6147 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_init()
6151 dhd_os_sdunlock(bus->dhd); in dhd_bus_init()
6153 /* XXX Temp errnum workaround: return ok, caller checks bus state */ in dhd_bus_init()
6158 dhdsdio_rxfail(dhd_bus_t *bus, bool abort, bool rtx) in dhdsdio_rxfail() argument
6160 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_rxfail()
6161 sdpcmd_regs_t *regs = bus->regs; in dhdsdio_rxfail()
6170 if (!KSO_ENAB(bus)) { in dhdsdio_rxfail()
6184 bus->f1regdata++; in dhdsdio_rxfail()
6195 bus->f1regdata += 2; in dhdsdio_rxfail()
6214 bus->rxrtx++; in dhdsdio_rxfail()
6216 bus->f1regdata++; in dhdsdio_rxfail()
6218 bus->rxskip = TRUE; in dhdsdio_rxfail()
6223 bus->nextlen = 0; in dhdsdio_rxfail()
6229 bus->dhd->busstate = DHD_BUS_DOWN; in dhdsdio_rxfail()
6234 dhdsdio_read_control(dhd_bus_t *bus, uint8 *hdr, uint len, uint doff) in dhdsdio_read_control() argument
6236 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_read_control()
6244 if ((bus->bus == SPI_BUS) && (!bus->usebufpool)) in dhdsdio_read_control()
6247 ASSERT(bus->rxbuf); in dhdsdio_read_control()
6249 bus->rxctl = bus->rxbuf; in dhdsdio_read_control()
6251 bus->rxctl += firstread; in dhdsdio_read_control()
6252 if ((pad = ((uintptr)bus->rxctl % DHD_SDALIGN))) in dhdsdio_read_control()
6253 bus->rxctl += (DHD_SDALIGN - pad); in dhdsdio_read_control()
6254 bus->rxctl -= firstread; in dhdsdio_read_control()
6256 ASSERT(bus->rxctl >= bus->rxbuf); in dhdsdio_read_control()
6259 bcopy(hdr, bus->rxctl, firstread); in dhdsdio_read_control()
6264 if (bus->bus == SPI_BUS) { in dhdsdio_read_control()
6265 bcopy(hdr, bus->rxctl, len); in dhdsdio_read_control()
6271 if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { in dhdsdio_read_control()
6272 pad = bus->blocksize - (rdlen % bus->blocksize); in dhdsdio_read_control()
6273 if ((pad <= bus->roundup) && (pad < bus->blocksize) && in dhdsdio_read_control()
6274 ((len + pad) < bus->dhd->maxctl)) in dhdsdio_read_control()
6285 if ((rdlen + firstread) > bus->dhd->maxctl) { in dhdsdio_read_control()
6287 __FUNCTION__, rdlen, bus->dhd->maxctl)); in dhdsdio_read_control()
6288 bus->dhd->rx_errors++; in dhdsdio_read_control()
6289 dhdsdio_rxfail(bus, FALSE, FALSE); in dhdsdio_read_control()
6293 if ((len - doff) > bus->dhd->maxctl) { in dhdsdio_read_control()
6295 __FUNCTION__, len, (len - doff), bus->dhd->maxctl)); in dhdsdio_read_control()
6296 bus->dhd->rx_errors++; bus->rx_toolong++; in dhdsdio_read_control()
6297 dhdsdio_rxfail(bus, FALSE, FALSE); in dhdsdio_read_control()
6304 sdret = dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC, in dhdsdio_read_control()
6305 (bus->rxctl + firstread), rdlen, NULL, NULL, NULL); in dhdsdio_read_control()
6306 bus->f2rxdata++; in dhdsdio_read_control()
6312 bus->rxc_errors++; /* dhd.rx_ctlerrs is higher level */ in dhdsdio_read_control()
6313 dhdsdio_rxfail(bus, TRUE, TRUE); in dhdsdio_read_control()
6321 prhex("RxCtrl", bus->rxctl, len); in dhdsdio_read_control()
6326 bus->rxctl += doff; in dhdsdio_read_control()
6327 bus->rxlen = len - doff; in dhdsdio_read_control()
6331 dhd_os_ioctl_resp_wake(bus->dhd); in dhdsdio_read_control()
6338 dhdsdio_rxglom(dhd_bus_t *bus, uint8 rxseq) in dhdsdio_rxglom() argument
6348 osl_t *osh = bus->dhd->osh; in dhdsdio_rxglom()
6357 bool usechain = bus->use_rxchain; in dhdsdio_rxglom()
6362 DHD_TRACE(("dhdsdio_rxglom: start: glomd %p glom %p\n", bus->glomd, bus->glom)); in dhdsdio_rxglom()
6365 if (bus->glomd) { in dhdsdio_rxglom()
6366 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_rxglom()
6369 dlen = (uint16)PKTLEN(osh, bus->glomd); in dhdsdio_rxglom()
6370 dptr = PKTDATA(osh, bus->glomd); in dhdsdio_rxglom()
6398 sublen += (ROUNDUP(totlen, bus->blocksize) - totlen); in dhdsdio_rxglom()
6399 totlen = ROUNDUP(totlen, bus->blocksize); in dhdsdio_rxglom()
6422 /* If all allocations succeeded, save packet chain in bus structure */ in dhdsdio_rxglom()
6426 if (DHD_GLOM_ON() && bus->nextlen) { in dhdsdio_rxglom()
6427 if (totlen != bus->nextlen) { in dhdsdio_rxglom()
6429 "rxseq %d\n", __FUNCTION__, bus->nextlen, in dhdsdio_rxglom()
6433 bus->glom = pfirst; in dhdsdio_rxglom()
6438 bus->glom = NULL; in dhdsdio_rxglom()
6443 PKTFREE(osh, bus->glomd, FALSE); in dhdsdio_rxglom()
6444 bus->glomd = NULL; in dhdsdio_rxglom()
6445 bus->nextlen = 0; in dhdsdio_rxglom()
6447 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_rxglom()
6451 if (bus->glom) { in dhdsdio_rxglom()
6454 for (pnext = bus->glom; pnext; pnext = PKTNEXT(osh, pnext)) { in dhdsdio_rxglom()
6461 pfirst = bus->glom; in dhdsdio_rxglom()
6469 errcode = dhd_bcmsdh_recv_buf(bus, in dhdsdio_rxglom()
6470 bcmsdh_cur_sbwad(bus->sdh), SDIO_FUNC_2, in dhdsdio_rxglom()
6473 } else if (bus->dataptr) { in dhdsdio_rxglom()
6474 errcode = dhd_bcmsdh_recv_buf(bus, in dhdsdio_rxglom()
6475 bcmsdh_cur_sbwad(bus->sdh), SDIO_FUNC_2, in dhdsdio_rxglom()
6476 F2SYNC, bus->dataptr, in dhdsdio_rxglom()
6478 sublen = (uint16)pktfrombuf(osh, pfirst, 0, dlen, bus->dataptr); in dhdsdio_rxglom()
6490 bus->f2rxdata++; in dhdsdio_rxglom()
6497 bus->dhd->rx_errors++; /* XXX Account for rtx?? */ in dhdsdio_rxglom()
6499 if (bus->glomerr++ < 3) { in dhdsdio_rxglom()
6500 dhdsdio_rxfail(bus, TRUE, TRUE); in dhdsdio_rxglom()
6502 bus->glomerr = 0; in dhdsdio_rxglom()
6503 dhdsdio_rxfail(bus, TRUE, FALSE); in dhdsdio_rxglom()
6504 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_rxglom()
6505 PKTFREE(osh, bus->glom, FALSE); in dhdsdio_rxglom()
6506 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_rxglom()
6507 bus->rxglomfail++; in dhdsdio_rxglom()
6508 bus->glom = NULL; in dhdsdio_rxglom()
6527 bus->nextlen = dptr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET]; in dhdsdio_rxglom()
6528 if ((bus->nextlen << 4) > MAX_RX_DATASZ) { in dhdsdio_rxglom()
6530 __FUNCTION__, bus->nextlen, seq)); in dhdsdio_rxglom()
6531 bus->nextlen = 0; in dhdsdio_rxglom()
6541 } else if (ROUNDUP(sublen, bus->blocksize) != dlen) { in dhdsdio_rxglom()
6543 __FUNCTION__, sublen, ROUNDUP(sublen, bus->blocksize), dlen)); in dhdsdio_rxglom()
6564 bus->rx_badseq++; in dhdsdio_rxglom()
6569 if ((uint8)(txmax - bus->tx_seq) > 0x70) { in dhdsdio_rxglom()
6571 __FUNCTION__, txmax, bus->tx_seq)); in dhdsdio_rxglom()
6572 txmax = bus->tx_max; in dhdsdio_rxglom()
6574 bus->tx_max = txmax; in dhdsdio_rxglom()
6619 if (bus->glomerr++ < 3) { in dhdsdio_rxglom()
6622 dhdsdio_rxfail(bus, TRUE, TRUE); in dhdsdio_rxglom()
6624 bus->glomerr = 0; in dhdsdio_rxglom()
6625 dhdsdio_rxfail(bus, TRUE, FALSE); in dhdsdio_rxglom()
6626 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_rxglom()
6627 PKTFREE(osh, bus->glom, FALSE); in dhdsdio_rxglom()
6628 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_rxglom()
6629 bus->rxglomfail++; in dhdsdio_rxglom()
6630 bus->glom = NULL; in dhdsdio_rxglom()
6632 bus->nextlen = 0; in dhdsdio_rxglom()
6637 bus->glom = NULL; in dhdsdio_rxglom()
6640 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_rxglom()
6660 bus->rx_badseq++; in dhdsdio_rxglom()
6676 PKTFREE(bus->dhd->osh, pfirst, FALSE); in dhdsdio_rxglom()
6678 } else if (dhd_prot_hdrpull(bus->dhd, &ifidx, pfirst, reorder_info_buf, in dhdsdio_rxglom()
6681 bus->dhd->rx_errors++; in dhdsdio_rxglom()
6691 dhd_process_pkt_reorder_info(bus->dhd, reorder_info_buf, in dhdsdio_rxglom()
6735 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_rxglom()
6747 dhd_os_sdunlock(bus->dhd); in dhdsdio_rxglom()
6748 dhd_rx_frame(bus->dhd, idx, list_head[idx], cnt, 0); in dhdsdio_rxglom()
6749 dhd_os_sdlock(bus->dhd); in dhdsdio_rxglom()
6753 bus->rxglomframes++; in dhdsdio_rxglom()
6754 bus->rxglompkts += num; in dhdsdio_rxglom()
6761 dhdsdio_readframes(dhd_bus_t *bus, uint maxframes, bool *finished) in dhdsdio_readframes() argument
6763 osl_t *osh = bus->dhd->osh; in dhdsdio_readframes()
6764 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_readframes()
6794 bus->readframes = TRUE; in dhdsdio_readframes()
6796 if (!KSO_ENAB(bus)) { in dhdsdio_readframes()
6798 bus->readframes = FALSE; in dhdsdio_readframes()
6806 if (bus->pktgen_count && (bus->pktgen_mode == DHD_PKTGEN_RECV)) { in dhdsdio_readframes()
6807 maxframes = bus->pktgen_count; in dhdsdio_readframes()
6817 if (bus->bus == SPI_BUS) { in dhdsdio_readframes()
6819 dstatus = bcmsdh_get_dstatus(bus->sdh); in dhdsdio_readframes()
6826 bcmsdh_get_dstatus((void *)bus->sdh))); in dhdsdio_readframes()
6830 bus->nextlen = ((dstatus & STATUS_F2_PKT_LEN_MASK) >> in dhdsdio_readframes()
6833 bus->nextlen = (bus->nextlen == 0) ? SPI_MAX_PKT_LEN : bus->nextlen; in dhdsdio_readframes()
6834 if (bus->dwordmode) in dhdsdio_readframes()
6835 bus->nextlen = bus->nextlen << 2; in dhdsdio_readframes()
6837 __FUNCTION__, bus->nextlen)); in dhdsdio_readframes()
6849 for (rxseq = bus->rx_seq, rxleft = maxframes; in dhdsdio_readframes()
6850 !bus->rxskip && rxleft && bus->dhd->busstate != DHD_BUS_DOWN; in dhdsdio_readframes()
6853 if (bus->dhd->tcpack_sup_mode != TCPACK_SUP_DELAYTX) { in dhdsdio_readframes()
6854 if (bus->dotxinrx == FALSE) in dhdsdio_readframes()
6856 __FUNCTION__, __LINE__, bus->dhd->tcpack_sup_mode)); in dhdsdio_readframes()
6859 else if (pktq_mlen(&bus->txq, ~bus->flowcontrol) > 0) { in dhdsdio_readframes()
6860 tack_tbl.cnt[bus->dotxinrx ? 6 : 7]++; in dhdsdio_readframes()
6865 if (TXCTLOK(bus) && bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL)) { in dhdsdio_readframes()
6866 dhdsdio_sendpendctl(bus); in dhdsdio_readframes()
6867 } else if (bus->dotxinrx && (bus->clkstate == CLK_AVAIL) && in dhdsdio_readframes()
6868 !bus->fcstate && DATAOK(bus) && in dhdsdio_readframes()
6869 (pktq_mlen(&bus->txq, ~bus->flowcontrol) > bus->txinrx_thres)) { in dhdsdio_readframes()
6870 dhdsdio_sendfromq(bus, dhd_txbound); in dhdsdio_readframes()
6875 * in bus txq. in dhdsdio_readframes()
6877 bus->dotxinrx = (bus->dhd->tcpack_sup_mode == TCPACK_SUP_DELAYTX) ? in dhdsdio_readframes()
6883 if (bus->glom || bus->glomd) { in dhdsdio_readframes()
6886 __FUNCTION__, bus->glomd, bus->glom)); in dhdsdio_readframes()
6887 cnt = dhdsdio_rxglom(bus, rxseq); in dhdsdio_readframes()
6895 if (dhd_readahead && bus->nextlen) { in dhdsdio_readframes()
6896 uint16 nextlen = bus->nextlen; in dhdsdio_readframes()
6897 bus->nextlen = 0; in dhdsdio_readframes()
6899 if (bus->bus == SPI_BUS) { in dhdsdio_readframes()
6905 if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { in dhdsdio_readframes()
6906 pad = bus->blocksize - (rdlen % bus->blocksize); in dhdsdio_readframes()
6907 if ((pad <= bus->roundup) && (pad < bus->blocksize) && in dhdsdio_readframes()
6915 /* We use bus->rxctl buffer in WinXP for initial control pkt receives. in dhdsdio_readframes()
6922 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
6924 if (bus->bus == SPI_BUS) { in dhdsdio_readframes()
6925 bus->usebufpool = FALSE; in dhdsdio_readframes()
6926 bus->rxctl = bus->rxbuf; in dhdsdio_readframes()
6928 bus->rxctl += firstread; in dhdsdio_readframes()
6929 if ((pad = ((uintptr)bus->rxctl % DHD_SDALIGN))) in dhdsdio_readframes()
6930 bus->rxctl += (DHD_SDALIGN - pad); in dhdsdio_readframes()
6931 bus->rxctl -= firstread; in dhdsdio_readframes()
6933 ASSERT(bus->rxctl >= bus->rxbuf); in dhdsdio_readframes()
6934 rxbuf = bus->rxctl; in dhdsdio_readframes()
6936 sdret = dhd_bcmsdh_recv_buf(bus, in dhdsdio_readframes()
6941 bus->f2rxdata++; in dhdsdio_readframes()
6948 if (bcmsdh_get_dstatus((void *)bus->sdh) & in dhdsdio_readframes()
6950 bus->nextlen = 0; in dhdsdio_readframes()
6956 bus->rxc_errors++; in dhdsdio_readframes()
6957 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
6967 bus->rxc_errors++; in dhdsdio_readframes()
6968 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
6969 dhdsdio_rxfail(bus, TRUE, in dhdsdio_readframes()
6970 (bus->bus == SPI_BUS) ? FALSE : TRUE); in dhdsdio_readframes()
6980 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
6984 if (bus->bus == SPI_BUS) in dhdsdio_readframes()
6985 bus->usebufpool = TRUE; in dhdsdio_readframes()
6991 sdret = dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), in dhdsdio_readframes()
6995 bus->f2rxdata++; in dhdsdio_readframes()
7001 if (bcmsdh_get_dstatus((void *)bus->sdh) & STATUS_UNDERFLOW) { in dhdsdio_readframes()
7002 bus->nextlen = 0; in dhdsdio_readframes()
7007 PKTFREE(bus->dhd->osh, pkt, FALSE); in dhdsdio_readframes()
7008 bus->dhd->rx_errors++; in dhdsdio_readframes()
7009 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7017 PKTFREE(bus->dhd->osh, pkt, FALSE); in dhdsdio_readframes()
7018 bus->dhd->rx_errors++; /* XXX Account for rtx?? */ in dhdsdio_readframes()
7019 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7023 dhdsdio_rxfail(bus, TRUE, in dhdsdio_readframes()
7024 (bus->bus == SPI_BUS) ? FALSE : TRUE); in dhdsdio_readframes()
7028 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7031 bcopy(rxbuf, bus->rxhdr, SDPCM_HDRLEN); in dhdsdio_readframes()
7034 len = ltoh16_ua(bus->rxhdr); in dhdsdio_readframes()
7035 check = ltoh16_ua(bus->rxhdr + sizeof(uint16)); in dhdsdio_readframes()
7041 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7043 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7053 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7055 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7056 bus->rx_badhdr++; in dhdsdio_readframes()
7057 dhdsdio_rxfail(bus, FALSE, FALSE); in dhdsdio_readframes()
7067 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7069 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7076 if (bus->bus == SPI_BUS) { in dhdsdio_readframes()
7077 if (bus->dwordmode) { in dhdsdio_readframes()
7091 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7093 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7094 dhdsdio_rxfail(bus, TRUE, (bus->bus == SPI_BUS) ? FALSE : TRUE); in dhdsdio_readframes()
7100 chan = SDPCM_PACKET_CHANNEL(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); in dhdsdio_readframes()
7101 seq = SDPCM_PACKET_SEQUENCE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); in dhdsdio_readframes()
7102 doff = SDPCM_DOFFSET_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); in dhdsdio_readframes()
7103 txmax = SDPCM_WINDOW_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); in dhdsdio_readframes()
7107 if (bus->bus == SPI_BUS) { in dhdsdio_readframes()
7109 dstatus = bcmsdh_get_dstatus((void *)bus->sdh); in dhdsdio_readframes()
7111 bcmsdh_get_dstatus((void *)bus->sdh))); in dhdsdio_readframes()
7113 bus->nextlen = ((dstatus & STATUS_F2_PKT_LEN_MASK) >> in dhdsdio_readframes()
7115 bus->nextlen = (bus->nextlen == 0) ? in dhdsdio_readframes()
7116 SPI_MAX_PKT_LEN : bus->nextlen; in dhdsdio_readframes()
7117 if (bus->dwordmode) in dhdsdio_readframes()
7118 bus->nextlen = bus->nextlen << 2; in dhdsdio_readframes()
7120 bus->nextlen)); in dhdsdio_readframes()
7121 bus->dhd->rx_readahead_cnt ++; in dhdsdio_readframes()
7123 bus->nextlen = 0; in dhdsdio_readframes()
7128 bus->nextlen = in dhdsdio_readframes()
7129 bus->rxhdr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET]; in dhdsdio_readframes()
7130 if ((bus->nextlen << 4) > MAX_RX_DATASZ) { in dhdsdio_readframes()
7132 " (%d), seq %d\n", __FUNCTION__, bus->nextlen, in dhdsdio_readframes()
7134 bus->nextlen = 0; in dhdsdio_readframes()
7137 bus->dhd->rx_readahead_cnt ++; in dhdsdio_readframes()
7142 fcbits = SDPCM_FCMASK_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); in dhdsdio_readframes()
7145 if (~bus->flowcontrol & fcbits) { in dhdsdio_readframes()
7146 bus->fc_xoff++; in dhdsdio_readframes()
7149 if (bus->flowcontrol & ~fcbits) { in dhdsdio_readframes()
7150 bus->fc_xon++; in dhdsdio_readframes()
7155 bus->fc_rcvd++; in dhdsdio_readframes()
7156 bus->flowcontrol = fcbits; in dhdsdio_readframes()
7163 bus->rx_badseq++; in dhdsdio_readframes()
7168 if ((uint8)(txmax - bus->tx_seq) > 0x70) { in dhdsdio_readframes()
7170 if ((bus->bus == SPI_BUS) && !(dstatus & STATUS_F2_RX_READY)) { in dhdsdio_readframes()
7172 __FUNCTION__, txmax, bus->tx_seq)); in dhdsdio_readframes()
7173 txmax = bus->tx_seq + 2; in dhdsdio_readframes()
7177 __FUNCTION__, txmax, bus->tx_seq)); in dhdsdio_readframes()
7178 txmax = bus->tx_max; in dhdsdio_readframes()
7183 bus->tx_max = txmax; in dhdsdio_readframes()
7189 prhex("RxHdr", bus->rxhdr, SDPCM_HDRLEN); in dhdsdio_readframes()
7194 if (bus->bus == SPI_BUS) { in dhdsdio_readframes()
7195 dhdsdio_read_control(bus, rxbuf, len, doff); in dhdsdio_readframes()
7196 if (bus->usebufpool) { in dhdsdio_readframes()
7197 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7198 PKTFREE(bus->dhd->osh, pkt, FALSE); in dhdsdio_readframes()
7199 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7206 bus->nextlen = 0; in dhdsdio_readframes()
7207 dhdsdio_rxfail(bus, FALSE, TRUE); in dhdsdio_readframes()
7208 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7210 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7215 if ((bus->bus == SPI_BUS) && !bus->usebufpool) { in dhdsdio_readframes()
7225 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7227 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7229 dhdsdio_rxfail(bus, FALSE, FALSE); in dhdsdio_readframes()
7237 if (bus->bus == SPI_BUS) { in dhdsdio_readframes()
7242 sdret = dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC, in dhdsdio_readframes()
7243 bus->rxhdr, firstread, NULL, NULL, NULL); in dhdsdio_readframes()
7244 bus->f2rxhdrs++; in dhdsdio_readframes()
7249 bus->rx_hdrfail++; in dhdsdio_readframes()
7253 bus->dhd->busstate = DHD_BUS_DOWN; in dhdsdio_readframes()
7257 dhdsdio_rxfail(bus, TRUE, TRUE); in dhdsdio_readframes()
7263 prhex("RxHdr", bus->rxhdr, SDPCM_HDRLEN); in dhdsdio_readframes()
7268 len = ltoh16_ua(bus->rxhdr); in dhdsdio_readframes()
7269 check = ltoh16_ua(bus->rxhdr + sizeof(uint16)); in dhdsdio_readframes()
7281 bus->rx_badhdr++; in dhdsdio_readframes()
7282 dhdsdio_rxfail(bus, FALSE, FALSE); in dhdsdio_readframes()
7294 chan = SDPCM_PACKET_CHANNEL(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); in dhdsdio_readframes()
7295 seq = SDPCM_PACKET_SEQUENCE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); in dhdsdio_readframes()
7296 doff = SDPCM_DOFFSET_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); in dhdsdio_readframes()
7297 txmax = SDPCM_WINDOW_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); in dhdsdio_readframes()
7303 bus->rx_badhdr++; in dhdsdio_readframes()
7305 dhdsdio_rxfail(bus, FALSE, FALSE); in dhdsdio_readframes()
7310 bus->nextlen = bus->rxhdr[SDPCM_FRAMETAG_LEN + SDPCM_NEXTLEN_OFFSET]; in dhdsdio_readframes()
7311 if ((bus->nextlen << 4) > MAX_RX_DATASZ) { in dhdsdio_readframes()
7313 __FUNCTION__, bus->nextlen, seq)); in dhdsdio_readframes()
7314 bus->nextlen = 0; in dhdsdio_readframes()
7318 fcbits = SDPCM_FCMASK_VALUE(&bus->rxhdr[SDPCM_FRAMETAG_LEN]); in dhdsdio_readframes()
7321 if (~bus->flowcontrol & fcbits) { in dhdsdio_readframes()
7322 bus->fc_xoff++; in dhdsdio_readframes()
7325 if (bus->flowcontrol & ~fcbits) { in dhdsdio_readframes()
7326 bus->fc_xon++; in dhdsdio_readframes()
7331 bus->fc_rcvd++; in dhdsdio_readframes()
7332 bus->flowcontrol = fcbits; in dhdsdio_readframes()
7338 bus->rx_badseq++; in dhdsdio_readframes()
7343 if ((uint8)(txmax - bus->tx_seq) > 0x70) { in dhdsdio_readframes()
7345 __FUNCTION__, txmax, bus->tx_seq)); in dhdsdio_readframes()
7346 txmax = bus->tx_max; in dhdsdio_readframes()
7348 bus->tx_max = txmax; in dhdsdio_readframes()
7352 dhdsdio_read_control(bus, bus->rxhdr, len, doff); in dhdsdio_readframes()
7363 if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { in dhdsdio_readframes()
7364 pad = bus->blocksize - (rdlen % bus->blocksize); in dhdsdio_readframes()
7365 if ((pad <= bus->roundup) && (pad < bus->blocksize) && in dhdsdio_readframes()
7379 bus->dhd->rx_errors++; bus->rx_toolong++; in dhdsdio_readframes()
7380 dhdsdio_rxfail(bus, FALSE, FALSE); in dhdsdio_readframes()
7384 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7389 bus->dhd->rx_dropped++; in dhdsdio_readframes()
7390 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7391 dhdsdio_rxfail(bus, FALSE, RETRYCHAN(chan)); in dhdsdio_readframes()
7394 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7405 sdret = dhd_bcmsdh_recv_buf(bus, bcmsdh_cur_sbwad(sdh), SDIO_FUNC_2, F2SYNC, in dhdsdio_readframes()
7407 bus->f2rxdata++; in dhdsdio_readframes()
7414 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7415 PKTFREE(bus->dhd->osh, pkt, FALSE); in dhdsdio_readframes()
7416 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7417 bus->dhd->rx_errors++; /* XXX Account for rtx?? */ in dhdsdio_readframes()
7418 dhdsdio_rxfail(bus, TRUE, RETRYCHAN(chan)); in dhdsdio_readframes()
7424 bcopy(bus->rxhdr, PKTDATA(osh, pkt), firstread); in dhdsdio_readframes()
7435 if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_FRAMETAG_LEN])) { in dhdsdio_readframes()
7446 bus->glomd = pkt; in dhdsdio_readframes()
7449 dhdsdio_rxfail(bus, FALSE, FALSE); in dhdsdio_readframes()
7461 dhdsdio_testrcv(bus, pkt, seq); in dhdsdio_readframes()
7467 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7468 PKTFREE(bus->dhd->osh, pkt, FALSE); in dhdsdio_readframes()
7469 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7471 } else if (dhd_prot_hdrpull(bus->dhd, &ifidx, pkt, reorder_info_buf, in dhdsdio_readframes()
7474 dhd_os_sdlock_rxq(bus->dhd); in dhdsdio_readframes()
7475 PKTFREE(bus->dhd->osh, pkt, FALSE); in dhdsdio_readframes()
7476 dhd_os_sdunlock_rxq(bus->dhd); in dhdsdio_readframes()
7477 bus->dhd->rx_errors++; in dhdsdio_readframes()
7483 dhd_process_pkt_reorder_info(bus->dhd, reorder_info_buf, reorder_info_len, in dhdsdio_readframes()
7495 dhd_os_sdunlock(bus->dhd); in dhdsdio_readframes()
7496 dhd_rx_frame(bus->dhd, ifidx, pkt, pkt_count, chan); in dhdsdio_readframes()
7497 dhd_os_sdlock(bus->dhd); in dhdsdio_readframes()
7500 * so call BUS_WAKE to wake up bus again in dhdsdio_readframes()
7505 BUS_WAKE(bus); in dhdsdio_readframes()
7517 if (bus->rxskip) in dhdsdio_readframes()
7519 bus->rx_seq = rxseq; in dhdsdio_readframes()
7521 if (bus->reqbussleep) in dhdsdio_readframes()
7523 dhdsdio_bussleep(bus, TRUE); in dhdsdio_readframes()
7524 bus->reqbussleep = FALSE; in dhdsdio_readframes()
7526 bus->readframes = FALSE; in dhdsdio_readframes()
7532 dhdsdio_hostmail(dhd_bus_t *bus, uint32 *hmbd) in dhdsdio_hostmail() argument
7534 sdpcmd_regs_t *regs = bus->regs; in dhdsdio_hostmail()
7546 bus->f1regdata += 2; in dhdsdio_hostmail()
7550 DHD_INFO(("Dongle reports NAK handled, expect rtx of %d\n", bus->rx_seq)); in dhdsdio_hostmail()
7551 /* XXX ASSERT(bus->rxskip); */ in dhdsdio_hostmail()
7552 if (!bus->rxskip) { in dhdsdio_hostmail()
7555 bus->rxskip = FALSE; in dhdsdio_hostmail()
7556 intstatus |= FRAME_AVAIL_MASK(bus); in dhdsdio_hostmail()
7563 bus->sdpcm_ver = (hmb_data & HMB_DATA_VERSION_MASK) >> HMB_DATA_VERSION_SHIFT; in dhdsdio_hostmail()
7564 if (bus->sdpcm_ver != SDPCM_PROT_VERSION) in dhdsdio_hostmail()
7566 bus->sdpcm_ver, SDPCM_PROT_VERSION)); in dhdsdio_hostmail()
7568 DHD_INFO(("Dongle ready, protocol version %d\n", bus->sdpcm_ver)); in dhdsdio_hostmail()
7571 if ((bus->sih->buscoretype == SDIOD_CORE_ID) && (bus->sdpcmrev >= 4) && in dhdsdio_hostmail()
7572 (bus->rxint_mode == SDIO_DEVICE_RXDATAINT_MODE_1)) { in dhdsdio_hostmail()
7575 val = R_REG(bus->dhd->osh, &bus->regs->corecontrol); in dhdsdio_hostmail()
7578 W_REG(bus->dhd->osh, &bus->regs->corecontrol, val); in dhdsdio_hostmail()
7580 val = R_REG(bus->dhd->osh, &bus->regs->corecontrol); in dhdsdio_hostmail()
7588 if (dhdsdio_readshared(bus, &shared) == 0) in dhdsdio_hostmail()
7589 bus->console_addr = shared.console_addr; in dhdsdio_hostmail()
7602 if (fcbits & ~bus->flowcontrol) in dhdsdio_hostmail()
7603 bus->fc_xoff++; in dhdsdio_hostmail()
7604 if (bus->flowcontrol & ~fcbits) in dhdsdio_hostmail()
7605 bus->fc_xon++; in dhdsdio_hostmail()
7607 bus->fc_rcvd++; in dhdsdio_hostmail()
7608 bus->flowcontrol = fcbits; in dhdsdio_hostmail()
7614 dhdsdio_checkdied(bus, NULL, 0); in dhdsdio_hostmail()
7637 dhdsdio_read_intstatus_byte(dhd_bus_t *bus) in dhdsdio_read_intstatus_byte() argument
7639 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_read_intstatus_byte()
7640 sdpcmd_regs_t *regs = bus->regs; in dhdsdio_read_intstatus_byte()
7652 if (bus->dhd->conf->read_intr_mode) { in dhdsdio_read_intstatus_byte()
7653 if (bus->dhd->conf->read_intr_mode == 1) { in dhdsdio_read_intstatus_byte()
7655 if (!bcmsdh_regfail(bus->sdh)) { in dhdsdio_read_intstatus_byte()
7659 intstatus_byte = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_read_intstatus_byte()
7663 intstatus_byte = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_read_intstatus_byte()
7667 intstatus_byte |= bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_read_intstatus_byte()
7671 intstatus_byte |= bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_1, in dhdsdio_read_intstatus_byte()
7689 dhdsdio_dpc(dhd_bus_t *bus) in dhdsdio_dpc() argument
7691 bcmsdh_info_t *sdh = bus->sdh; in dhdsdio_dpc()
7692 sdpcmd_regs_t *regs = bus->regs; in dhdsdio_dpc()
7706 dhd_os_sdlock(bus->dhd); in dhdsdio_dpc()
7707 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhdsdio_dpc()
7708 if (bus->dhd->busstate == DHD_BUS_DOWN) { in dhdsdio_dpc()
7709 DHD_ERROR(("%s: Bus down, ret\n", __FUNCTION__)); in dhdsdio_dpc()
7710 bus->intstatus = 0; in dhdsdio_dpc()
7711 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhdsdio_dpc()
7712 dhd_os_sdunlock(bus->dhd); in dhdsdio_dpc()
7716 DHD_BUS_BUSY_SET_IN_DPC(bus->dhd); in dhdsdio_dpc()
7717 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhdsdio_dpc()
7720 intstatus = bus->intstatus; in dhdsdio_dpc()
7722 if (!SLPAUTO_ENAB(bus) && !KSO_ENAB(bus)) { in dhdsdio_dpc()
7728 if (!SLPAUTO_ENAB(bus) && (bus->clkstate == CLK_PENDING)) { in dhdsdio_dpc()
7738 bus->dhd->busstate = DHD_BUS_DOWN; in dhdsdio_dpc()
7749 bus->dhd->busstate = DHD_BUS_DOWN; in dhdsdio_dpc()
7760 bus->dhd->busstate = DHD_BUS_DOWN; in dhdsdio_dpc()
7768 bus->dhd->busstate = DHD_BUS_DOWN; in dhdsdio_dpc()
7770 bus->clkstate = CLK_AVAIL; in dhdsdio_dpc()
7776 BUS_WAKE(bus); in dhdsdio_dpc()
7779 dhdsdio_clkctl(bus, CLK_AVAIL, TRUE); in dhdsdio_dpc()
7780 if (bus->clkstate != CLK_AVAIL) in dhdsdio_dpc()
7784 if (bus->ipend) { in dhdsdio_dpc()
7785 bus->ipend = FALSE; in dhdsdio_dpc()
7791 newstatus = dhdsdio_read_intstatus_byte(bus); in dhdsdio_dpc()
7795 bus->f1regdata++; in dhdsdio_dpc()
7796 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_dpc()
7798 newstatus &= bus->hostintmask; in dhdsdio_dpc()
7799 bus->fcstate = !!(newstatus & I_HMB_FC_STATE); in dhdsdio_dpc()
7801 bus->f1regdata++; in dhdsdio_dpc()
7803 if ((bus->rxint_mode == SDIO_DEVICE_RXDATAINT_MODE_0) && in dhdsdio_dpc()
7813 bus->intstatus = 0; in dhdsdio_dpc()
7823 bus->f1regdata += 2; in dhdsdio_dpc()
7824 bus->fcstate = !!(newstatus & (I_HMB_FC_STATE | I_HMB_FC_CHANGE)); in dhdsdio_dpc()
7825 intstatus |= (newstatus & bus->hostintmask); in dhdsdio_dpc()
7833 intstatus |= dhdsdio_hostmail(bus, &hmbdata); in dhdsdio_dpc()
7843 /* ASSERT(bus->clkstate == CLK_AVAIL); */ in dhdsdio_dpc()
7850 intstatus |= dhdsdio_hostmail(bus, NULL); in dhdsdio_dpc()
7883 if (bus->rxskip) { in dhdsdio_dpc()
7884 intstatus &= ~FRAME_AVAIL_MASK(bus); in dhdsdio_dpc()
7888 if (PKT_AVAILABLE(bus, intstatus)) { in dhdsdio_dpc()
7894 uint coretype = bus->sih->buscoretype; in dhdsdio_dpc()
7895 uint corerev = bus->sdpcmrev; in dhdsdio_dpc()
7899 W_SDREG(fifoaddr, &SDPCMFIFOREG(bus, coretype, corerev)->fifoaddr, retries); in dhdsdio_dpc()
7900 if (bcmsdh_regfail(bus->sdh)) regerrs++; in dhdsdio_dpc()
7901 R_SDREG(rdptr, &SDPCMFIFOREG(bus, coretype, corerev)->fifodatalow, retries); in dhdsdio_dpc()
7902 if (bcmsdh_regfail(bus->sdh)) regerrs++; in dhdsdio_dpc()
7908 &SDPCMFIFOREG(bus, coretype, corerev)->fifoaddr, in dhdsdio_dpc()
7910 if (bcmsdh_regfail(bus->sdh)) regerrs++; in dhdsdio_dpc()
7912 &SDPCMFIFOREG(bus, coretype, corerev)->fifodatalow, in dhdsdio_dpc()
7914 if (bcmsdh_regfail(bus->sdh)) regerrs++; in dhdsdio_dpc()
7916 &SDPCMFIFOREG(bus, coretype, corerev)->fifoaddr, in dhdsdio_dpc()
7918 if (bcmsdh_regfail(bus->sdh)) regerrs++; in dhdsdio_dpc()
7920 &SDPCMFIFOREG(bus, coretype, corerev)->fifodatahigh, in dhdsdio_dpc()
7922 if (bcmsdh_regfail(bus->sdh)) regerrs++; in dhdsdio_dpc()
7929 &SDPCMFIFOREG(bus, coretype, corerev)->fifoaddr, retries); in dhdsdio_dpc()
7930 if (bcmsdh_regfail(bus->sdh)) regerrs++; in dhdsdio_dpc()
7932 &SDPCMFIFOREG(bus, coretype, corerev)->fifodatalow, retries); in dhdsdio_dpc()
7933 if (bcmsdh_regfail(bus->sdh)) regerrs++; in dhdsdio_dpc()
7949 framecnt = dhdsdio_readframes(bus, rxlimit, &rxdone); in dhdsdio_dpc()
7950 if (rxdone || bus->rxskip) in dhdsdio_dpc()
7951 intstatus &= ~FRAME_AVAIL_MASK(bus); in dhdsdio_dpc()
7956 bus->intstatus = intstatus; in dhdsdio_dpc()
7963 if (bus->intr && bus->intdis && !bcmsdh_regfail(sdh) && in dhdsdio_dpc()
7964 !(bus->dhd->conf->oob_enabled_later && !bus->ctrl_frame_stat)) { in dhdsdio_dpc()
7967 bus->intdis = FALSE; in dhdsdio_dpc()
7969 bcmsdh_oob_intr_set(bus->sdh, TRUE); in dhdsdio_dpc()
7976 bcmsdh_oob_intr_set(bus->sdh, TRUE); in dhdsdio_dpc()
7988 if (bcmsdh_regfail(bus->sdh)) in dhdsdio_dpc()
7990 if (newstatus & bus->hostintmask) { in dhdsdio_dpc()
7991 bus->ipend = TRUE; in dhdsdio_dpc()
7997 if (!DATAOK(bus) && bus->rxlim_en) { in dhdsdio_dpc()
7999 if (0 == dhdsdio_membytes(bus, FALSE, bus->rxlim_addr, (uint8 *)&rxlim, 1)) { in dhdsdio_dpc()
8000 if (bus->tx_max != rxlim) { in dhdsdio_dpc()
8001 DHD_INFO(("%s: bus->tx_max/rxlim=%d/%d\n", __FUNCTION__, in dhdsdio_dpc()
8002 bus->tx_max, rxlim)); in dhdsdio_dpc()
8003 bus->tx_max = rxlim; in dhdsdio_dpc()
8010 dhd_wlfc_commit_packets(bus->dhd, (f_commitpkt_t)dhd_bus_txdata, (void *)bus, NULL, FALSE); in dhdsdio_dpc()
8013 if (TXCTLOK(bus) && bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL)) in dhdsdio_dpc()
8014 dhdsdio_sendpendctl(bus); in dhdsdio_dpc()
8016 else if (DATAOK(bus) && strlen(bus->cons_cmd) && (bus->clkstate == CLK_AVAIL) && in dhdsdio_dpc()
8017 !bus->fcstate) { in dhdsdio_dpc()
8018 dhd_bus_console_in(bus->dhd, bus->cons_cmd, strlen(bus->cons_cmd)); in dhdsdio_dpc()
8023 else if ((bus->clkstate == CLK_AVAIL) && !bus->fcstate && in dhdsdio_dpc()
8024 pktq_mlen(&bus->txq, ~bus->flowcontrol) && txlimit && DATAOK(bus)) { in dhdsdio_dpc()
8026 if (bus->dhd->conf->dhd_txminmax < 0) in dhdsdio_dpc()
8027 framecnt = rxdone ? txlimit : MIN(txlimit, DATABUFCNT(bus)); in dhdsdio_dpc()
8029 framecnt = rxdone ? txlimit : MIN(txlimit, bus->dhd->conf->dhd_txminmax); in dhdsdio_dpc()
8030 framecnt = dhdsdio_sendfromq(bus, framecnt); in dhdsdio_dpc()
8033 /* Resched the DPC if ctrl cmd is pending on bus credit */ in dhdsdio_dpc()
8034 if (bus->ctrl_frame_stat) { in dhdsdio_dpc()
8035 if (bus->dhd->conf->txctl_tmo_fix) { in dhdsdio_dpc()
8046 if ((bus->dhd->busstate == DHD_BUS_DOWN) || bcmsdh_regfail(sdh)) { in dhdsdio_dpc()
8047 if ((bus->sih && bus->sih->buscorerev >= 12) && !(dhdsdio_sleepcsr_get(bus) & in dhdsdio_dpc()
8049 /* Bus failed because of KSO */ in dhdsdio_dpc()
8050 DHD_ERROR(("%s: Bus failed due to KSO\n", __FUNCTION__)); in dhdsdio_dpc()
8051 bus->kso = FALSE; in dhdsdio_dpc()
8056 bus->dhd->busstate = DHD_BUS_DOWN; in dhdsdio_dpc()
8057 bus->intstatus = 0; in dhdsdio_dpc()
8061 * of failures, so in case of bus lock up we avoid continuous interrupt. in dhdsdio_dpc()
8064 } else if (bus->clkstate == CLK_PENDING) { in dhdsdio_dpc()
8066 } else if (bus->intstatus || bus->ipend || in dhdsdio_dpc()
8067 (!bus->fcstate && (pktq_mlen(&bus->txq, ((~bus->flowcontrol) in dhdsdio_dpc()
8069 & bus->dhd->dequeue_prec_map in dhdsdio_dpc()
8071 ))) && DATAOK(bus)) || in dhdsdio_dpc()
8072 PKT_AVAILABLE(bus, bus->intstatus)) { /* Read multiple frames */ in dhdsdio_dpc()
8076 bus->dpc_sched = resched; in dhdsdio_dpc()
8080 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && (bus->clkstate != CLK_PENDING) && in dhdsdio_dpc()
8081 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhdsdio_dpc()
8082 bus->activity = FALSE; in dhdsdio_dpc()
8083 dhdsdio_bussleep(bus, TRUE); in dhdsdio_dpc()
8084 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhdsdio_dpc()
8094 if (bus->intr && bus->intdis && !bcmsdh_regfail(sdh) && in dhdsdio_dpc()
8095 (bus->dhd->conf->oob_enabled_later && !bus->ctrl_frame_stat)) { in dhdsdio_dpc()
8098 bus->intdis = FALSE; in dhdsdio_dpc()
8100 bcmsdh_oob_intr_set(bus->sdh, TRUE); in dhdsdio_dpc()
8105 if (dhdsdio_readframes(bus, dhd_rxbound, &rxdone) != 0) { in dhdsdio_dpc()
8115 dhd_conf_tput_monitor(bus->dhd); in dhdsdio_dpc()
8118 if (bus->ctrl_wait && TXCTLOK(bus)) in dhdsdio_dpc()
8119 wake_up_interruptible(&bus->ctrl_tx_wait); in dhdsdio_dpc()
8120 dhd_os_sdunlock(bus->dhd); in dhdsdio_dpc()
8122 if (bus->dhd->dhd_bug_on) { in dhdsdio_dpc()
8125 __FUNCTION__, resched, bus->ctrl_frame_stat, in dhdsdio_dpc()
8126 bus->intstatus, bus->ipend, in dhdsdio_dpc()
8127 pktq_mlen(&bus->txq, ~bus->flowcontrol), is_resched_by_readframe)); in dhdsdio_dpc()
8129 bus->dhd->dhd_bug_on = FALSE; in dhdsdio_dpc()
8133 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhdsdio_dpc()
8134 DHD_BUS_BUSY_CLEAR_IN_DPC(bus->dhd); in dhdsdio_dpc()
8135 dhd_os_busbusy_wake(bus->dhd); in dhdsdio_dpc()
8136 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhdsdio_dpc()
8142 dhd_bus_dpc(struct dhd_bus *bus) in dhd_bus_dpc() argument
8148 resched = dhdsdio_dpc(bus); in dhd_bus_dpc()
8156 dhd_bus_t *bus = (dhd_bus_t*)arg; in dhdsdio_isr() local
8159 if (!bus) { in dhdsdio_isr()
8160 DHD_ERROR(("%s : bus is null pointer , exit \n", __FUNCTION__)); in dhdsdio_isr()
8163 sdh = bus->sdh; in dhdsdio_isr()
8165 if (bus->dhd->busstate == DHD_BUS_DOWN) { in dhdsdio_isr()
8166 DHD_ERROR(("%s : bus is down. we have nothing to do\n", __FUNCTION__)); in dhdsdio_isr()
8179 bus->intrcount++; in dhdsdio_isr()
8180 bus->ipend = TRUE; in dhdsdio_isr()
8183 if (!SLPAUTO_ENAB(bus)) { in dhdsdio_isr()
8184 if (bus->sleeping) { in dhdsdio_isr()
8187 } else if (!KSO_ENAB(bus)) { in dhdsdio_isr()
8193 if (bus->intr) { in dhdsdio_isr()
8200 bcmsdh_oob_intr_set(bus->sdh, FALSE); in dhdsdio_isr()
8205 bus->intdis = TRUE; in dhdsdio_isr()
8209 DHD_OS_WAKE_LOCK(bus->dhd); in dhdsdio_isr()
8213 if (dhdsdio_dpc(bus)) { in dhdsdio_isr()
8214 bus->dpc_sched = TRUE; in dhdsdio_isr()
8215 dhd_sched_dpc(bus->dhd); in dhdsdio_isr()
8217 DHD_OS_WAKE_UNLOCK(bus->dhd); in dhdsdio_isr()
8220 bus->dpc_sched = TRUE; in dhdsdio_isr()
8221 dhd_sched_dpc(bus->dhd); in dhdsdio_isr()
8231 dhd_bus_t *bus = dhdp->bus; in dhd_bus_dump_txpktstatics() local
8236 __FUNCTION__, bus->tx_statics.event_count, bus->tx_statics.event_size); in dhd_bus_dump_txpktstatics()
8238 __FUNCTION__, bus->tx_statics.ctrl_count, bus->tx_statics.ctrl_size); in dhd_bus_dump_txpktstatics()
8240 __FUNCTION__, bus->tx_statics.data_count, bus->tx_statics.data_size); in dhd_bus_dump_txpktstatics()
8242 for (i=0;i<bus->tx_statics.glom_max;i++) { in dhd_bus_dump_txpktstatics()
8243 total += bus->tx_statics.glom_cnt[i]; in dhd_bus_dump_txpktstatics()
8246 for (i=0;i<bus->tx_statics.glom_max;i++) { in dhd_bus_dump_txpktstatics()
8247 printk(KERN_CONT "%02d: %5d", i+1, bus->tx_statics.glom_cnt[i]); in dhd_bus_dump_txpktstatics()
8257 for (i=0;i<bus->tx_statics.glom_max;i++) { in dhd_bus_dump_txpktstatics()
8258 printk(KERN_CONT "%02d:%5d%%", i+1, (bus->tx_statics.glom_cnt[i]*100)/total); in dhd_bus_dump_txpktstatics()
8269 for (i=0;i<bus->tx_statics.glom_max;i++) { in dhd_bus_dump_txpktstatics()
8270 printk(KERN_CONT "%02d: %5u", i+1, bus->tx_statics.glom_cnt_us[i]); in dhd_bus_dump_txpktstatics()
8281 __FUNCTION__, bus->tx_statics.data_count, total, in dhd_bus_dump_txpktstatics()
8282 bus->tx_statics.data_count/total, bus->tx_statics.glom_max); in dhd_bus_dump_txpktstatics()
8285 __FUNCTION__, bus->tx_statics.glom_count, bus->tx_statics.glom_size); in dhd_bus_dump_txpktstatics()
8287 __FUNCTION__, bus->tx_statics.test_count, bus->tx_statics.test_size); in dhd_bus_dump_txpktstatics()
8302 dhd_bus_t *bus = dhdp->bus; in dhd_bus_clear_txpktstatics() local
8303 memset((uint8*) &bus->tx_statics, 0, sizeof(pkt_statics_t)); in dhd_bus_clear_txpktstatics()
8309 dhdsdio_pktgen_init(dhd_bus_t *bus) in dhdsdio_pktgen_init() argument
8313 bus->pktgen_maxlen = MIN(dhd_pktgen_len, MAX_PKTGEN_LEN); in dhdsdio_pktgen_init()
8314 bus->pktgen_minlen = bus->pktgen_maxlen; in dhdsdio_pktgen_init()
8316 bus->pktgen_maxlen = MAX_PKTGEN_LEN; in dhdsdio_pktgen_init()
8317 bus->pktgen_minlen = 0; in dhdsdio_pktgen_init()
8319 bus->pktgen_len = (uint16)bus->pktgen_minlen; in dhdsdio_pktgen_init()
8322 bus->pktgen_freq = 1; in dhdsdio_pktgen_init()
8323 bus->pktgen_print = dhd_watchdog_ms ? (10000 / dhd_watchdog_ms) : 0; in dhdsdio_pktgen_init()
8324 bus->pktgen_count = (dhd_pktgen * dhd_watchdog_ms + 999) / 1000; in dhdsdio_pktgen_init()
8327 bus->pktgen_mode = DHD_PKTGEN_ECHO; in dhdsdio_pktgen_init()
8328 bus->pktgen_stop = 1; in dhdsdio_pktgen_init()
8332 dhdsdio_pktgen(dhd_bus_t *bus) in dhdsdio_pktgen() argument
8338 osl_t *osh = bus->dhd->osh; in dhdsdio_pktgen()
8347 if (bus->pktgen_print && (++bus->pktgen_ptick >= bus->pktgen_print)) { in dhdsdio_pktgen()
8348 bus->pktgen_ptick = 0; in dhdsdio_pktgen()
8350 __FUNCTION__, bus->pktgen_sent, bus->pktgen_rcvd, bus->pktgen_fail); in dhdsdio_pktgen()
8354 if (bus->pktgen_minlen == bus->pktgen_maxlen) { in dhdsdio_pktgen()
8355 time_lapse = jiffies - bus->pktgen_prev_time; in dhdsdio_pktgen()
8356 bus->pktgen_prev_time = jiffies; in dhdsdio_pktgen()
8357 sent_pkts = bus->pktgen_sent - bus->pktgen_prev_sent; in dhdsdio_pktgen()
8358 bus->pktgen_prev_sent = bus->pktgen_sent; in dhdsdio_pktgen()
8359 rcvd_pkts = bus->pktgen_rcvd - bus->pktgen_prev_rcvd; in dhdsdio_pktgen()
8360 bus->pktgen_prev_rcvd = bus->pktgen_rcvd; in dhdsdio_pktgen()
8364 (sent_pkts * bus->pktgen_len / jiffies_to_msecs(time_lapse)) * 8, in dhdsdio_pktgen()
8365 (rcvd_pkts * bus->pktgen_len / jiffies_to_msecs(time_lapse)) * 8); in dhdsdio_pktgen()
8371 if (bus->pktgen_mode == DHD_PKTGEN_RECV) { in dhdsdio_pktgen()
8372 if (bus->pktgen_rcv_state == PKTGEN_RCV_IDLE) { in dhdsdio_pktgen()
8373 bus->pktgen_rcv_state = PKTGEN_RCV_ONGOING; in dhdsdio_pktgen()
8374 dhdsdio_sdtest_set(bus, bus->pktgen_total); in dhdsdio_pktgen()
8380 for (pktcount = 0; pktcount < bus->pktgen_count; pktcount++) { in dhdsdio_pktgen()
8382 if (bus->pktgen_total && (bus->pktgen_sent >= bus->pktgen_total)) { in dhdsdio_pktgen()
8383 bus->pktgen_count = 0; in dhdsdio_pktgen()
8388 if (bus->pktgen_mode == DHD_PKTGEN_RXBURST) { in dhdsdio_pktgen()
8391 len = bus->pktgen_len; in dhdsdio_pktgen()
8402 switch (bus->pktgen_mode) { in dhdsdio_pktgen()
8405 *data++ = (uint8)bus->pktgen_sent; in dhdsdio_pktgen()
8410 *data++ = (uint8)bus->pktgen_sent; in dhdsdio_pktgen()
8415 *data++ = (uint8)bus->pktgen_count; /* Just for backward compatability */ in dhdsdio_pktgen()
8419 DHD_ERROR(("Unrecognized pktgen mode %d\n", bus->pktgen_mode)); in dhdsdio_pktgen()
8421 bus->pktgen_count = 0; in dhdsdio_pktgen()
8426 *data++ = (bus->pktgen_len >> 0); in dhdsdio_pktgen()
8427 *data++ = (bus->pktgen_len >> 8); in dhdsdio_pktgen()
8432 if (bus->pktgen_mode == DHD_PKTGEN_RXBURST) { in dhdsdio_pktgen()
8433 *data++ = (uint8)(bus->pktgen_count >> 0); in dhdsdio_pktgen()
8434 *data++ = (uint8)(bus->pktgen_count >> 8); in dhdsdio_pktgen()
8435 *data++ = (uint8)(bus->pktgen_count >> 16); in dhdsdio_pktgen()
8436 *data++ = (uint8)(bus->pktgen_count >> 24); in dhdsdio_pktgen()
8441 *data++ = SDPCM_TEST_FILL(fillbyte, (uint8)bus->pktgen_sent); in dhdsdio_pktgen()
8452 if (dhdsdio_txpkt(bus, SDPCM_TEST_CHANNEL, &pkt, 1, TRUE) != BCME_OK) { in dhdsdio_pktgen()
8453 bus->pktgen_fail++; in dhdsdio_pktgen()
8454 if (bus->pktgen_stop && bus->pktgen_stop == bus->pktgen_fail) in dhdsdio_pktgen()
8455 bus->pktgen_count = 0; in dhdsdio_pktgen()
8457 bus->pktgen_sent++; in dhdsdio_pktgen()
8460 if (++bus->pktgen_len > bus->pktgen_maxlen) in dhdsdio_pktgen()
8461 bus->pktgen_len = (uint16)bus->pktgen_minlen; in dhdsdio_pktgen()
8464 if (bus->pktgen_mode == DHD_PKTGEN_RXBURST) in dhdsdio_pktgen()
8470 dhdsdio_sdtest_set(dhd_bus_t *bus, uint count) in dhdsdio_sdtest_set() argument
8474 osl_t *osh = bus->dhd->osh; in dhdsdio_sdtest_set()
8489 *data++ = (bus->pktgen_maxlen >> 0); in dhdsdio_sdtest_set()
8490 *data++ = (bus->pktgen_maxlen >> 8); in dhdsdio_sdtest_set()
8497 if (dhdsdio_txpkt(bus, SDPCM_TEST_CHANNEL, &pkt, 1, TRUE) != BCME_OK) in dhdsdio_sdtest_set()
8498 bus->pktgen_fail++; in dhdsdio_sdtest_set()
8502 dhdsdio_testrcv(dhd_bus_t *bus, void *pkt, uint seq) in dhdsdio_testrcv() argument
8504 osl_t *osh = bus->dhd->osh; in dhdsdio_testrcv()
8541 if (dhdsdio_txpkt(bus, SDPCM_TEST_CHANNEL, &pkt, 1, TRUE) == BCME_OK) { in dhdsdio_testrcv()
8542 bus->pktgen_sent++; in dhdsdio_testrcv()
8544 bus->pktgen_fail++; in dhdsdio_testrcv()
8547 bus->pktgen_rcvd++; in dhdsdio_testrcv()
8551 if (bus->ext_loop) { in dhdsdio_testrcv()
8553 bus->pktgen_rcvd++; in dhdsdio_testrcv()
8566 bus->pktgen_rcvd++; in dhdsdio_testrcv()
8577 i, bus->pktgen_rcvd_rcvsession, testval, *prn)); in dhdsdio_testrcv()
8583 bus->pktgen_rcvd++; in dhdsdio_testrcv()
8596 if (bus->pktgen_mode == DHD_PKTGEN_RECV) { in dhdsdio_testrcv()
8597 if (bus->pktgen_rcv_state != PKTGEN_RCV_IDLE) { in dhdsdio_testrcv()
8598 bus->pktgen_rcvd_rcvsession++; in dhdsdio_testrcv()
8600 if (bus->pktgen_total && in dhdsdio_testrcv()
8601 (bus->pktgen_rcvd_rcvsession >= bus->pktgen_total)) { in dhdsdio_testrcv()
8602 bus->pktgen_count = 0; in dhdsdio_testrcv()
8604 bus->pktgen_rcv_state = PKTGEN_RCV_IDLE; in dhdsdio_testrcv()
8605 dhdsdio_sdtest_set(bus, FALSE); in dhdsdio_testrcv()
8606 bus->pktgen_rcvd_rcvsession = 0; in dhdsdio_testrcv()
8618 err = bcmsdh_oob_intr_register(dhdp->bus->sdh, dhdsdio_isr, dhdp->bus); in dhd_bus_oob_intr_register()
8626 bcmsdh_oob_intr_unregister(dhdp->bus->sdh); in dhd_bus_oob_intr_unregister()
8633 bcmsdh_oob_intr_set(dhdp->bus->sdh, enable); in dhd_bus_oob_intr_set()
8641 irq_num = bcmsdh_get_oob_intr_num(dhdp->bus->sdh); in dhd_bus_get_oob_irq_num()
8647 struct device *dhd_bus_to_dev(struct dhd_bus *bus) in dhd_bus_to_dev() argument
8649 return (struct device *)bcmsdh_get_dev(bus->sdh); in dhd_bus_to_dev()
8656 bcmsdh_dev_pm_stay_awake(dhdpub->bus->sdh); in dhd_bus_dev_pm_stay_awake()
8663 bcmsdh_dev_relax(dhdpub->bus->sdh); in dhd_bus_dev_pm_relax()
8672 enabled = bcmsdh_dev_pm_enabled(dhdpub->bus->sdh); in dhd_bus_dev_pm_enabled()
8680 dhd_bus_t *bus; in dhd_bus_watchdog() local
8685 bus = dhdp->bus; in dhd_bus_watchdog()
8687 if (bus->dhd->dongle_reset) in dhd_bus_watchdog()
8690 if (bus->dhd->hang_was_sent) { in dhd_bus_watchdog()
8691 dhd_os_wd_timer(bus->dhd, 0); in dhd_bus_watchdog()
8695 /* Ignore the timer if simulating bus down */ in dhd_bus_watchdog()
8696 if (!SLPAUTO_ENAB(bus) && bus->sleeping) in dhd_bus_watchdog()
8708 dhd_os_sdlock(bus->dhd); in dhd_bus_watchdog()
8711 // terence 20160615: remove !SLPAUTO_ENAB(bus) to fix not able to polling if sr supported in dhd_bus_watchdog()
8712 if (1 && (bus->poll && (++bus->polltick >= bus->pollrate))) { in dhd_bus_watchdog()
8716 bus->polltick = 0; in dhd_bus_watchdog()
8719 if (!bus->intr || (bus->intrcount == bus->lastintrs)) { in dhd_bus_watchdog()
8726 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_watchdog()
8728 hostpending = bcmsdh_intr_pending(bus->sdh); in dhd_bus_watchdog()
8729 devena = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_INTEN, NULL); in dhd_bus_watchdog()
8730 devpend = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, SDIOD_CCCR_INTPEND, NULL); in dhd_bus_watchdog()
8732 R_SDREG(intstatus, &bus->regs->intstatus, retries); in dhd_bus_watchdog()
8733 intstatus &= bus->hostintmask; in dhd_bus_watchdog()
8743 if (!bus->dpc_sched) { in dhd_bus_watchdog()
8745 devpend = bcmsdh_cfg_read(bus->sdh, SDIO_FUNC_0, in dhd_bus_watchdog()
8750 if (!bus->dpc_sched) { in dhd_bus_watchdog()
8752 devpend = bcmsdh_cfg_read_word(bus->sdh, SDIO_FUNC_0, in dhd_bus_watchdog()
8760 bus->pollcnt++; in dhd_bus_watchdog()
8761 bus->ipend = TRUE; in dhd_bus_watchdog()
8762 if (bus->intr) { in dhd_bus_watchdog()
8763 bcmsdh_intr_disable(bus->sdh); in dhd_bus_watchdog()
8765 bus->dpc_sched = TRUE; in dhd_bus_watchdog()
8766 dhd_sched_dpc(bus->dhd); in dhd_bus_watchdog()
8771 bus->lastintrs = bus->intrcount; in dhd_bus_watchdog()
8774 if ((!bus->dpc_sched) && pktq_n_pkts_tot(&bus->txq)) { in dhd_bus_watchdog()
8775 bus->dpc_sched = TRUE; in dhd_bus_watchdog()
8776 dhd_sched_dpc(bus->dhd); in dhd_bus_watchdog()
8782 bus->console.count += dhd_watchdog_ms; in dhd_bus_watchdog()
8783 if (bus->console.count >= dhdp->dhd_console_ms) { in dhd_bus_watchdog()
8784 bus->console.count -= dhdp->dhd_console_ms; in dhd_bus_watchdog()
8786 if (SLPAUTO_ENAB(bus)) in dhd_bus_watchdog()
8787 dhdsdio_bussleep(bus, FALSE); in dhd_bus_watchdog()
8789 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_watchdog()
8790 if (dhdsdio_readconsole(bus) < 0) in dhd_bus_watchdog()
8798 if (bus->pktgen_count && (++bus->pktgen_tick >= bus->pktgen_freq)) { in dhd_bus_watchdog()
8800 if (SLPAUTO_ENAB(bus)) in dhd_bus_watchdog()
8801 dhdsdio_bussleep(bus, FALSE); in dhd_bus_watchdog()
8803 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_watchdog()
8804 bus->pktgen_tick = 0; in dhd_bus_watchdog()
8805 dhdsdio_pktgen(bus); in dhd_bus_watchdog()
8811 if (bus->activity) in dhd_bus_watchdog()
8812 bus->activity = FALSE; in dhd_bus_watchdog()
8814 bus->idlecount++; in dhd_bus_watchdog()
8829 * bus->idletime != 0 instead of idletime == 0 in dhd_bus_watchdog()
8831 if ((bus->idletime != 0) && (bus->idlecount >= bus->idletime) && in dhd_bus_watchdog()
8832 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhd_bus_watchdog()
8834 if (!bus->poll && SLPAUTO_ENAB(bus)) { in dhd_bus_watchdog()
8835 if (dhdsdio_bussleep(bus, TRUE) != BCME_BUSY) in dhd_bus_watchdog()
8836 dhd_os_wd_timer(bus->dhd, 0); in dhd_bus_watchdog()
8838 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_watchdog()
8840 bus->idlecount = 0; in dhd_bus_watchdog()
8844 if ((bus->idletime != 0) && (bus->clkstate == CLK_AVAIL) && in dhd_bus_watchdog()
8845 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhd_bus_watchdog()
8846 if (++bus->idlecount >= bus->idletime) { in dhd_bus_watchdog()
8847 bus->idlecount = 0; in dhd_bus_watchdog()
8848 if (bus->activity) { in dhd_bus_watchdog()
8849 bus->activity = FALSE; in dhd_bus_watchdog()
8858 if (!bus->poll && SLPAUTO_ENAB(bus)) { in dhd_bus_watchdog()
8859 if (!bus->readframes) in dhd_bus_watchdog()
8860 dhdsdio_bussleep(bus, TRUE); in dhd_bus_watchdog()
8862 bus->reqbussleep = TRUE; in dhd_bus_watchdog()
8864 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_watchdog()
8871 dhd_os_sdunlock(bus->dhd); in dhd_bus_watchdog()
8878 return bus->ipend; in dhd_bus_watchdog()
8884 dhd_bus_t *bus = dhdp->bus; in dhd_bus_console_in() local
8890 /* Exclusive bus access */ in dhd_bus_console_in()
8891 dhd_os_sdlock(bus->dhd); in dhd_bus_console_in()
8895 if (bus->console_addr == 0) { in dhd_bus_console_in()
8901 if (bus->dhd->dongle_reset) { in dhd_bus_console_in()
8907 if (!DATAOK(bus)) { in dhd_bus_console_in()
8908 DHD_CTL(("%s: No bus credit bus->tx_max %d, bus->tx_seq %d, pktq_len %d\n", in dhd_bus_console_in()
8909 __FUNCTION__, bus->tx_max, bus->tx_seq, pktq_n_pkts_tot(&bus->txq))); in dhd_bus_console_in()
8915 BUS_WAKE(bus); in dhd_bus_console_in()
8917 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_bus_console_in()
8921 addr = bus->console_addr + OFFSETOF(hnd_cons_t, cbuf_idx); in dhd_bus_console_in()
8927 if ((rv = dhdsdio_membytes(bus, TRUE, addr, (uint8 *)&val, sizeof(val))) < 0) in dhd_bus_console_in()
8931 addr = bus->console_addr + OFFSETOF(hnd_cons_t, cbuf); in dhd_bus_console_in()
8936 if ((rv = dhdsdio_membytes(bus, TRUE, addr, (uint8 *)msg, msglen)) < 0) in dhd_bus_console_in()
8940 addr = bus->console_addr + OFFSETOF(hnd_cons_t, vcons_in); in dhd_bus_console_in()
8942 if ((rv = dhdsdio_membytes(bus, TRUE, addr, (uint8 *)&val, sizeof(val))) < 0) in dhd_bus_console_in()
8948 if ((pkt = PKTGET(bus->dhd->osh, 4 + SDPCM_RESERVE, TRUE)) != NULL) in dhd_bus_console_in()
8949 rv = dhdsdio_txpkt(bus, SDPCM_EVENT_CHANNEL, &pkt, 1, TRUE); in dhd_bus_console_in()
8953 if ((bus->idletime == DHD_IDLE_IMMEDIATE) && !bus->dpc_sched && in dhd_bus_console_in()
8954 NO_OTHER_ACTIVE_BUS_USER(bus)) { in dhd_bus_console_in()
8955 bus->activity = FALSE; in dhd_bus_console_in()
8956 dhdsdio_bussleep(bus, TRUE); in dhd_bus_console_in()
8957 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_console_in()
8963 memset(bus->cons_cmd, 0, sizeof(bus->cons_cmd)); in dhd_bus_console_in()
8965 dhd_os_sdunlock(bus->dhd); in dhd_bus_console_in()
8974 dhd_bus_t *bus = dhdp->bus; in dhd_bus_txcons() local
8977 dhd_os_sdlock(bus->dhd); in dhd_bus_txcons()
8980 if (bus->console_addr == 0) { in dhd_bus_txcons()
8986 if (bus->dhd->dongle_reset) { in dhd_bus_txcons()
8991 if (msglen >= sizeof(bus->cons_cmd)) { in dhd_bus_txcons()
8997 if (!strlen(bus->cons_cmd)) { in dhd_bus_txcons()
8998 strncpy(bus->cons_cmd, msg, sizeof(bus->cons_cmd)); in dhd_bus_txcons()
9000 __FUNCTION__, bus->cons_cmd, bus->tx_max, bus->tx_seq, pktq_n_pkts_tot(&bus->txq))); in dhd_bus_txcons()
9001 if (!bus->dpc_sched) { in dhd_bus_txcons()
9002 bus->dpc_sched = TRUE; in dhd_bus_txcons()
9003 dhd_sched_dpc(bus->dhd); in dhd_bus_txcons()
9007 __FUNCTION__, bus->cons_cmd, bus->tx_max, bus->tx_seq, pktq_n_pkts_tot(&bus->txq))); in dhd_bus_txcons()
9012 dhd_os_sdunlock(bus->dhd); in dhd_bus_txcons()
9125 dhd_bus_t *bus; in dhdsdio_probe() local
9202 /* Allocate private bus interface state */ in dhdsdio_probe()
9203 if (!(bus = MALLOC(osh, sizeof(dhd_bus_t)))) { in dhdsdio_probe()
9207 bzero(bus, sizeof(dhd_bus_t)); in dhdsdio_probe()
9208 bus->sdh = sdh; in dhdsdio_probe()
9209 bus->cl_devid = (uint16)devid; in dhdsdio_probe()
9210 bus->bus = DHD_BUS; in dhdsdio_probe()
9211 bus->bus_num = bus_no; in dhdsdio_probe()
9212 bus->slot_num = slot; in dhdsdio_probe()
9213 bus->tx_seq = SDPCM_SEQUENCE_WRAP - 1; in dhdsdio_probe()
9214 bus->usebufpool = FALSE; /* Use bufpool if allocated, else use locally malloced rxbuf */ in dhdsdio_probe()
9216 bus->bt_use_count = 0; in dhdsdio_probe()
9220 init_waitqueue_head(&bus->bus_sleep); in dhdsdio_probe()
9222 init_waitqueue_head(&bus->ctrl_tx_wait); in dhdsdio_probe()
9225 if (!(dhdsdio_probe_attach(bus, osh, sdh, regsva, devid))) { in dhdsdio_probe()
9231 if (!(bus->dhd = dhd_attach(osh, bus, SDPCM_RESERVE))) { in dhdsdio_probe()
9237 dhd_conf_get_otp(bus->dhd, sdh, bus->sih); in dhdsdio_probe()
9241 if (!(dhdsdio_probe_malloc(bus, osh, sdh))) { in dhdsdio_probe()
9246 if (!(dhdsdio_probe_init(bus, osh, sdh))) { in dhdsdio_probe()
9251 if (bus->intr) { in dhdsdio_probe()
9255 if ((ret = bcmsdh_intr_reg(sdh, dhdsdio_isr, bus)) != 0) { in dhdsdio_probe()
9268 /* if firmware path present try to download and bring up bus */ in dhdsdio_probe()
9269 bus->dhd->hang_report = TRUE; in dhdsdio_probe()
9274 if ((ret = dhd_bus_start(bus->dhd)) != 0) { in dhdsdio_probe()
9285 get_random_bytes(&bus->dhd->mac.octet[3], 3); in dhdsdio_probe()
9287 bus->dhd->mac.octet[0] = 0; in dhdsdio_probe()
9288 bus->dhd->mac.octet[1] = 0x90; in dhdsdio_probe()
9289 bus->dhd->mac.octet[2] = 0x4C; in dhdsdio_probe()
9294 /* At this point Regulators are turned on and iconditionaly sdio bus is started in dhdsdio_probe()
9296 * increase the bus user count, this count will only be disabled inside in dhdsdio_probe()
9299 * so that WALN will always hold the bus untill rmmod is done. in dhdsdio_probe()
9301 dhdsdio_bus_usr_cnt_inc(bus->dhd); in dhdsdio_probe()
9305 if (dhd_attach_net(bus->dhd, TRUE) != 0) { in dhdsdio_probe()
9311 bcmsdh_reg_write(bus->sdh, 0x18000620, 2, 11); in dhdsdio_probe()
9312 bcmsdh_reg_write(bus->sdh, 0x18000628, 4, 0x00F80001); in dhdsdio_probe()
9320 return bus; in dhdsdio_probe()
9323 dhdsdio_release(bus, osh); in dhdsdio_probe()
9332 dhdsdio_probe_attach(struct dhd_bus *bus, osl_t *osh, void *sdh, void *regsva, in dhdsdio_probe_attach() argument
9340 bus->alp_only = TRUE; in dhdsdio_probe_attach()
9341 bus->sih = NULL; in dhdsdio_probe_attach()
9344 if (dhdsdio_set_siaddr_window(bus, si_enum_base(devid))) { in dhdsdio_probe_attach()
9350 bcmsdh_reg_read(bus->sdh, si_enum_base(devid), 4))); in dhdsdio_probe_attach()
9397 /* Now request ALP be put on the bus */ in dhdsdio_probe_attach()
9434 if (!(bus->sih = si_attach((uint)devid, osh, regsva, DHD_BUS, sdh, in dhdsdio_probe_attach()
9435 &bus->vars, &bus->varsz))) { in dhdsdio_probe_attach()
9442 bus->sih->socitype, bus->sih->chip, bus->sih->chiprev, bus->sih->chippkg)); in dhdsdio_probe_attach()
9448 bcmsdh_chipinfo(sdh, bus->sih->chip, bus->sih->chiprev); in dhdsdio_probe_attach()
9450 if (!dhdsdio_chipmatch((uint16)bus->sih->chip)) { in dhdsdio_probe_attach()
9452 __FUNCTION__, bus->sih->chip)); in dhdsdio_probe_attach()
9461 if (bus->sih->buscorerev >= 12) in dhdsdio_probe_attach()
9462 dhdsdio_clk_kso_init(bus); in dhdsdio_probe_attach()
9464 bus->kso = TRUE; in dhdsdio_probe_attach()
9466 si_sdiod_drive_strength_init(bus->sih, osh, dhd_sdiod_drive_strength); in dhdsdio_probe_attach()
9470 if (!(bus->sih->cccaps & CC_CAP_PMU)) { in dhdsdio_probe_attach()
9471 DHD_NOPMU(bus) = 1; in dhdsdio_probe_attach()
9477 if (!DHD_NOPMU(bus)) { in dhdsdio_probe_attach()
9478 if ((si_setcore(bus->sih, ARM7S_CORE_ID, 0)) || in dhdsdio_probe_attach()
9479 (si_setcore(bus->sih, ARMCM3_CORE_ID, 0)) || in dhdsdio_probe_attach()
9480 (si_setcore(bus->sih, ARMCR4_CORE_ID, 0))) { in dhdsdio_probe_attach()
9481 bus->armrev = si_corerev(bus->sih); in dhdsdio_probe_attach()
9487 if (!si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) { in dhdsdio_probe_attach()
9488 if (!(bus->orig_ramsize = si_socram_size(bus->sih))) { in dhdsdio_probe_attach()
9494 if (!(bus->orig_ramsize = si_tcm_size(bus->sih))) { in dhdsdio_probe_attach()
9499 switch ((uint16)bus->sih->chip) { in dhdsdio_probe_attach()
9502 bus->dongle_ram_base = CR4_4335_RAM_BASE; in dhdsdio_probe_attach()
9509 bus->dongle_ram_base = CR4_4350_RAM_BASE; in dhdsdio_probe_attach()
9512 bus->dongle_ram_base = CR4_4360_RAM_BASE; in dhdsdio_probe_attach()
9515 bus->dongle_ram_base = (bus->sih->chiprev < 6) /* from 4345C0 */ in dhdsdio_probe_attach()
9520 bus->dongle_ram_base = ((bus->sih->chiprev < 9) ? in dhdsdio_probe_attach()
9524 bus->dongle_ram_base = CR4_4364_RAM_BASE; in dhdsdio_probe_attach()
9530 bus->dongle_ram_base = CR4_4347_RAM_BASE; in dhdsdio_probe_attach()
9534 bus->dongle_ram_base = CR4_4362_RAM_BASE; in dhdsdio_probe_attach()
9537 bus->dongle_ram_base = CR4_43751_RAM_BASE; in dhdsdio_probe_attach()
9540 bus->dongle_ram_base = CR4_43752_RAM_BASE; in dhdsdio_probe_attach()
9543 bus->dongle_ram_base = CR4_4369_RAM_BASE; in dhdsdio_probe_attach()
9546 bus->dongle_ram_base = CR4_4378_RAM_BASE; in dhdsdio_probe_attach()
9549 bus->dongle_ram_base = 0; in dhdsdio_probe_attach()
9551 __FUNCTION__, bus->dongle_ram_base)); in dhdsdio_probe_attach()
9554 bus->ramsize = bus->orig_ramsize; in dhdsdio_probe_attach()
9556 dhd_dongle_setramsize(bus, dhd_dongle_ramsize); in dhdsdio_probe_attach()
9559 bus->ramsize, bus->orig_ramsize, bus->dongle_ram_base)); in dhdsdio_probe_attach()
9561 bus->srmemsize = si_socram_srmem_size(bus->sih); in dhdsdio_probe_attach()
9566 if (!(bus->regs = si_setcore(bus->sih, CC_CORE_ID, 0))) { in dhdsdio_probe_attach()
9571 if (!(bus->regs = si_setcore(bus->sih, PCMCIA_CORE_ID, 0)) && in dhdsdio_probe_attach()
9572 !(bus->regs = si_setcore(bus->sih, SDIOD_CORE_ID, 0))) { in dhdsdio_probe_attach()
9577 bus->sdpcmrev = si_corerev(bus->sih); in dhdsdio_probe_attach()
9580 OR_REG(osh, &bus->regs->corecontrol, CC_BPRESEN); in dhdsdio_probe_attach()
9582 bus->rxint_mode = SDIO_DEVICE_HMB_RXINT; in dhdsdio_probe_attach()
9584 if ((bus->sih->buscoretype == SDIOD_CORE_ID) && (bus->sdpcmrev >= 4) && in dhdsdio_probe_attach()
9585 (bus->rxint_mode == SDIO_DEVICE_RXDATAINT_MODE_1)) in dhdsdio_probe_attach()
9589 val = R_REG(osh, &bus->regs->corecontrol); in dhdsdio_probe_attach()
9592 W_REG(osh, &bus->regs->corecontrol, val); in dhdsdio_probe_attach()
9598 pktq_init(&bus->txq, (PRIOMASK + 1), QLEN); in dhdsdio_probe_attach()
9602 bus->rxhdr = (uint8 *)ROUNDUP((uintptr)&bus->hdrbuf[0], DHD_SDALIGN); in dhdsdio_probe_attach()
9606 bus->intr = (bool)dhd_intr; in dhdsdio_probe_attach()
9607 if ((bus->poll = (bool)dhd_poll)) in dhdsdio_probe_attach()
9608 bus->pollrate = 1; in dhdsdio_probe_attach()
9611 bus->txglomsize = SDPCM_DEFGLOM_SIZE; in dhdsdio_probe_attach()
9616 if (bus->sih != NULL) { in dhdsdio_probe_attach()
9617 si_detach(bus->sih); in dhdsdio_probe_attach()
9618 bus->sih = NULL; in dhdsdio_probe_attach()
9624 dhdsdio_probe_malloc(dhd_bus_t *bus, osl_t *osh, void *sdh) in dhdsdio_probe_malloc() argument
9628 if (bus->dhd->maxctl) { in dhdsdio_probe_malloc()
9629 bus->rxblen = ROUNDUP((bus->dhd->maxctl+SDPCM_HDRLEN), ALIGNMENT) + DHD_SDALIGN; in dhdsdio_probe_malloc()
9630 if (!(bus->rxbuf = DHD_OS_PREALLOC(bus->dhd, DHD_PREALLOC_RXBUF, bus->rxblen))) { in dhdsdio_probe_malloc()
9632 __FUNCTION__, bus->rxblen)); in dhdsdio_probe_malloc()
9637 if (!(bus->databuf = DHD_OS_PREALLOC(bus->dhd, DHD_PREALLOC_DATABUF, MAX_DATA_BUF))) { in dhdsdio_probe_malloc()
9641 if (!bus->rxblen) in dhdsdio_probe_malloc()
9642 DHD_OS_PREFREE(bus->dhd, bus->rxbuf, bus->rxblen); in dhdsdio_probe_malloc()
9646 bus->membuf = MALLOC(osh, MAX_MEM_BUF); in dhdsdio_probe_malloc()
9647 if (bus->membuf == NULL) { in dhdsdio_probe_malloc()
9650 if (bus->databuf) { in dhdsdio_probe_malloc()
9652 MFREE(osh, bus->databuf, MAX_DATA_BUF); in dhdsdio_probe_malloc()
9654 bus->databuf = NULL; in dhdsdio_probe_malloc()
9657 if (!bus->rxblen) in dhdsdio_probe_malloc()
9658 DHD_OS_PREFREE(bus->dhd, bus->rxbuf, bus->rxblen); in dhdsdio_probe_malloc()
9661 memset(bus->membuf, 0, MAX_MEM_BUF); in dhdsdio_probe_malloc()
9664 if ((uintptr)bus->databuf % DHD_SDALIGN) in dhdsdio_probe_malloc()
9665 bus->dataptr = bus->databuf + (DHD_SDALIGN - ((uintptr)bus->databuf % DHD_SDALIGN)); in dhdsdio_probe_malloc()
9667 bus->dataptr = bus->databuf; in dhdsdio_probe_malloc()
9676 dhdsdio_probe_init(dhd_bus_t *bus, osl_t *osh, void *sdh) in dhdsdio_probe_init() argument
9682 bus->_srenab = FALSE; in dhdsdio_probe_init()
9685 dhdsdio_pktgen_init(bus); in dhdsdio_probe_init()
9696 bus->dhd->busstate = DHD_BUS_DOWN; in dhdsdio_probe_init()
9697 bus->sleeping = FALSE; in dhdsdio_probe_init()
9698 bus->rxflow = FALSE; in dhdsdio_probe_init()
9699 bus->prev_rxlim_hit = 0; in dhdsdio_probe_init()
9707 bus->clkstate = CLK_SDONLY; in dhdsdio_probe_init()
9708 bus->idletime = (int32)dhd_idletime; in dhdsdio_probe_init()
9709 bus->idleclock = DHD_IDLE_ACTIVE; in dhdsdio_probe_init()
9713 &bus->sd_divisor, sizeof(int32), FALSE) != BCME_OK) { in dhdsdio_probe_init()
9715 bus->sd_divisor = -1; in dhdsdio_probe_init()
9718 __FUNCTION__, "sd_divisor", bus->sd_divisor)); in dhdsdio_probe_init()
9721 /* Query the SD bus mode */ in dhdsdio_probe_init()
9723 &bus->sd_mode, sizeof(int32), FALSE) != BCME_OK) { in dhdsdio_probe_init()
9725 bus->sd_mode = -1; in dhdsdio_probe_init()
9728 __FUNCTION__, "sd_mode", bus->sd_mode)); in dhdsdio_probe_init()
9734 &bus->blocksize, sizeof(int32), FALSE) != BCME_OK) { in dhdsdio_probe_init()
9735 bus->blocksize = 0; in dhdsdio_probe_init()
9739 __FUNCTION__, "sd_blocksize", bus->blocksize)); in dhdsdio_probe_init()
9741 dhdsdio_tune_fifoparam(bus); in dhdsdio_probe_init()
9743 bus->roundup = MIN(max_roundup, bus->blocksize); in dhdsdio_probe_init()
9746 if (bus->pad_pkt) in dhdsdio_probe_init()
9747 PKTFREE(osh, bus->pad_pkt, FALSE); in dhdsdio_probe_init()
9748 bus->pad_pkt = PKTGET(osh, SDIO_MAX_BLOCK_SIZE, FALSE); in dhdsdio_probe_init()
9749 if (bus->pad_pkt == NULL) in dhdsdio_probe_init()
9753 uintptr pktprt = (uintptr)PKTDATA(osh, bus->pad_pkt); in dhdsdio_probe_init()
9755 PKTPUSH(osh, bus->pad_pkt, alignment_offset); in dhdsdio_probe_init()
9756 PKTSETNEXT(osh, bus->pad_pkt, NULL); in dhdsdio_probe_init()
9760 /* Query if bus module supports packet chaining, default to use if supported */ in dhdsdio_probe_init()
9762 &bus->sd_rxchain, sizeof(int32), FALSE) != BCME_OK) { in dhdsdio_probe_init()
9763 bus->sd_rxchain = FALSE; in dhdsdio_probe_init()
9765 DHD_INFO(("%s: bus module (through bcmsdh API) %s chaining\n", in dhdsdio_probe_init()
9766 __FUNCTION__, (bus->sd_rxchain ? "supports" : "does not support"))); in dhdsdio_probe_init()
9768 bus->use_rxchain = (bool)bus->sd_rxchain; in dhdsdio_probe_init()
9769 bus->txinrx_thres = CUSTOM_TXINRX_THRES; in dhdsdio_probe_init()
9771 bus->dotxinrx = TRUE; in dhdsdio_probe_init()
9774 dhd_bus_clear_txpktstatics(bus->dhd); in dhdsdio_probe_init()
9781 dhd_bus_download_firmware(struct dhd_bus *bus, osl_t *osh, in dhd_bus_download_firmware() argument
9787 bus->fw_path = pfw_path; in dhd_bus_download_firmware()
9788 bus->nv_path = pnv_path; in dhd_bus_download_firmware()
9789 bus->dhd->clm_path = pclm_path; in dhd_bus_download_firmware()
9790 bus->dhd->conf_path = pconf_path; in dhd_bus_download_firmware()
9792 ret = dhdsdio_download_firmware(bus, osh, bus->sdh); in dhd_bus_download_firmware()
9798 dhd_set_bus_params(struct dhd_bus *bus) in dhd_set_bus_params() argument
9802 if (bus->dhd->conf->dhd_poll >= 0) { in dhd_set_bus_params()
9803 bus->poll = bus->dhd->conf->dhd_poll; in dhd_set_bus_params()
9804 if (!bus->pollrate) in dhd_set_bus_params()
9805 bus->pollrate = 1; in dhd_set_bus_params()
9806 printf("%s: set polling mode %d\n", __FUNCTION__, bus->dhd->conf->dhd_poll); in dhd_set_bus_params()
9808 if (bus->dhd->conf->use_rxchain >= 0) { in dhd_set_bus_params()
9809 bus->use_rxchain = (bool)bus->dhd->conf->use_rxchain; in dhd_set_bus_params()
9811 if (bus->dhd->conf->txinrx_thres >= 0) { in dhd_set_bus_params()
9812 bus->txinrx_thres = bus->dhd->conf->txinrx_thres; in dhd_set_bus_params()
9814 if (bus->dhd->conf->txglomsize >= 0) { in dhd_set_bus_params()
9815 bus->txglomsize = bus->dhd->conf->txglomsize; in dhd_set_bus_params()
9818 if (bus->dhd->conf->fw_type == FW_TYPE_MINIME) { in dhd_set_bus_params()
9819 bus->ramsize = bus->dhd->conf->ramsize; in dhd_set_bus_params()
9820 printf("%s: set ramsize 0x%x\n", __FUNCTION__, bus->ramsize); in dhd_set_bus_params()
9824 if (bus->dhd->conf->max_hdr_read <= 0) { in dhd_set_bus_params()
9825 bus->dhd->conf->max_hdr_read = MAX_HDR_READ; in dhd_set_bus_params()
9827 if (bus->hdrbufp) { in dhd_set_bus_params()
9828 MFREE(bus->dhd->osh, bus->hdrbufp, bus->dhd->conf->max_hdr_read + DHD_SDALIGN); in dhd_set_bus_params()
9830 bus->hdrbufp = MALLOC(bus->dhd->osh, bus->dhd->conf->max_hdr_read + DHD_SDALIGN); in dhd_set_bus_params()
9831 if (bus->hdrbufp == NULL) { in dhd_set_bus_params()
9833 __FUNCTION__, bus->dhd->conf->max_hdr_read + DHD_SDALIGN)); in dhd_set_bus_params()
9837 bus->rxhdr = (uint8 *)ROUNDUP((uintptr)bus->hdrbufp, DHD_SDALIGN); in dhd_set_bus_params()
9845 dhdsdio_download_firmware(struct dhd_bus *bus, osl_t *osh, void *sdh) in dhdsdio_download_firmware() argument
9850 if (concate_revision(bus, bus->fw_path, bus->nv_path) != 0) { in dhdsdio_download_firmware()
9858 dhd_set_blob_support(bus->dhd, bus->fw_path); in dhdsdio_download_firmware()
9862 __FUNCTION__, bus->fw_path, bus->nv_path)); in dhdsdio_download_firmware()
9863 DHD_OS_WAKE_LOCK(bus->dhd); in dhdsdio_download_firmware()
9865 dhd_conf_set_path_params(bus->dhd, bus->fw_path, bus->nv_path); in dhdsdio_download_firmware()
9866 ret = dhd_set_bus_params(bus); in dhdsdio_download_firmware()
9872 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_download_firmware()
9874 ret = _dhdsdio_download_firmware(bus); in dhdsdio_download_firmware()
9876 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhdsdio_download_firmware()
9879 DHD_OS_WAKE_UNLOCK(bus->dhd); in dhdsdio_download_firmware()
9885 dhdsdio_release(dhd_bus_t *bus, osl_t *osh) in dhdsdio_release() argument
9890 if (bus) { in dhdsdio_release()
9893 if (bus->dhd) { in dhdsdio_release()
9897 dongle_isolation = bus->dhd->dongle_isolation; in dhdsdio_release()
9898 dhd_detach(bus->dhd); in dhdsdio_release()
9902 bcmsdh_intr_disable(bus->sdh); in dhdsdio_release()
9903 bcmsdh_intr_dereg(bus->sdh); in dhdsdio_release()
9905 if (bus->dhd) { in dhdsdio_release()
9906 dhdsdio_release_dongle(bus, osh, dongle_isolation, TRUE); in dhdsdio_release()
9907 dhd_free(bus->dhd); in dhdsdio_release()
9908 bus->dhd = NULL; in dhdsdio_release()
9911 dhdsdio_release_malloc(bus, osh); in dhdsdio_release()
9914 if (bus->console.buf != NULL) in dhdsdio_release()
9915 MFREE(osh, bus->console.buf, bus->console.bufsize); in dhdsdio_release()
9919 if (bus->pad_pkt) in dhdsdio_release()
9920 PKTFREE(osh, bus->pad_pkt, FALSE); in dhdsdio_release()
9923 if (bus->hdrbufp) { in dhdsdio_release()
9924 MFREE(osh, bus->hdrbufp, MAX_HDR_READ + DHD_SDALIGN); in dhdsdio_release()
9928 MFREE(osh, bus, sizeof(dhd_bus_t)); in dhdsdio_release()
9935 dhdsdio_release_malloc(dhd_bus_t *bus, osl_t *osh) in dhdsdio_release_malloc() argument
9939 if (bus->dhd && bus->dhd->dongle_reset) in dhdsdio_release_malloc()
9942 if (bus->rxbuf) { in dhdsdio_release_malloc()
9944 MFREE(osh, bus->rxbuf, bus->rxblen); in dhdsdio_release_malloc()
9946 bus->rxctl = NULL; in dhdsdio_release_malloc()
9947 bus->rxlen = 0; in dhdsdio_release_malloc()
9950 if (bus->databuf) { in dhdsdio_release_malloc()
9952 MFREE(osh, bus->databuf, MAX_DATA_BUF); in dhdsdio_release_malloc()
9956 if (bus->membuf) { in dhdsdio_release_malloc()
9957 MFREE(osh, bus->membuf, MAX_MEM_BUF); in dhdsdio_release_malloc()
9958 bus->membuf = NULL; in dhdsdio_release_malloc()
9961 if (bus->vars && bus->varsz) { in dhdsdio_release_malloc()
9962 MFREE(osh, bus->vars, bus->varsz); in dhdsdio_release_malloc()
9968 dhdsdio_release_dongle(dhd_bus_t *bus, osl_t *osh, bool dongle_isolation, bool reset_flag) in dhdsdio_release_dongle() argument
9970 DHD_TRACE(("%s: Enter bus->dhd %p bus->dhd->dongle_reset %d \n", __FUNCTION__, in dhdsdio_release_dongle()
9971 bus->dhd, bus->dhd->dongle_reset)); in dhdsdio_release_dongle()
9973 if ((bus->dhd && bus->dhd->dongle_reset) && reset_flag) in dhdsdio_release_dongle()
9976 if (bus->sih) { in dhdsdio_release_dongle()
9985 if (bus->dhd) { in dhdsdio_release_dongle()
9986 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhdsdio_release_dongle()
9988 if (KSO_ENAB(bus) && (dongle_isolation == FALSE)) in dhdsdio_release_dongle()
9989 si_watchdog(bus->sih, 4); in dhdsdio_release_dongle()
9991 if (bus->dhd) { in dhdsdio_release_dongle()
9992 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhdsdio_release_dongle()
9994 si_detach(bus->sih); in dhdsdio_release_dongle()
9995 bus->sih = NULL; in dhdsdio_release_dongle()
9996 if (bus->vars && bus->varsz) in dhdsdio_release_dongle()
9997 MFREE(osh, bus->vars, bus->varsz); in dhdsdio_release_dongle()
9998 bus->vars = NULL; in dhdsdio_release_dongle()
10007 dhd_bus_t *bus = (dhd_bus_t *)ptr; in dhdsdio_disconnect() local
10012 if (bus) { in dhdsdio_disconnect()
10013 ASSERT(bus->dhd); in dhdsdio_disconnect()
10014 /* Advertise bus remove during rmmod */ in dhdsdio_disconnect()
10015 dhdsdio_advertise_bus_remove(bus->dhd); in dhdsdio_disconnect()
10016 dhdsdio_release(bus, bus->dhd->osh); in dhdsdio_disconnect()
10032 dhd_bus_t *bus = (dhd_bus_t*)context; in dhdsdio_suspend() local
10036 if (bus->dhd == NULL) { in dhdsdio_suspend()
10037 DHD_ERROR(("bus not inited\n")); in dhdsdio_suspend()
10040 if (bus->dhd->prot == NULL) { in dhdsdio_suspend()
10045 if (bus->dhd->up == FALSE) { in dhdsdio_suspend()
10049 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhdsdio_suspend()
10050 if (bus->dhd->busstate != DHD_BUS_DATA && bus->dhd->busstate != DHD_BUS_SUSPEND) { in dhdsdio_suspend()
10052 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhdsdio_suspend()
10055 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhdsdio_suspend()
10056 if (bus->dhd->dongle_reset) { in dhdsdio_suspend()
10061 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhdsdio_suspend()
10063 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, ON); in dhdsdio_suspend()
10064 bus->dhd->busstate = DHD_BUS_SUSPEND; in dhdsdio_suspend()
10066 if (DHD_BUS_BUSY_CHECK_IN_TX(bus->dhd)) { in dhdsdio_suspend()
10068 bus->dhd->busstate = DHD_BUS_DATA; in dhdsdio_suspend()
10070 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF); in dhdsdio_suspend()
10071 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhdsdio_suspend()
10075 DHD_BUS_BUSY_SET_SUSPEND_IN_PROGRESS(bus->dhd); in dhdsdio_suspend()
10076 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhdsdio_suspend()
10079 if (bus->idletime > 0) { in dhdsdio_suspend()
10080 wait_time = msecs_to_jiffies(bus->idletime * dhd_watchdog_ms); in dhdsdio_suspend()
10083 ret = dhd_os_check_wakelock(bus->dhd); in dhdsdio_suspend()
10086 if (SLPAUTO_ENAB(bus) && (!ret) && (bus->dhd->up) && (bus->dhd->op_mode != DHD_FLAG_HOSTAP_MODE)) { in dhdsdio_suspend()
10087 if (wait_event_timeout(bus->bus_sleep, bus->sleeping, wait_time) == 0) { in dhdsdio_suspend()
10088 if (!bus->sleeping) { in dhdsdio_suspend()
10095 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhdsdio_suspend()
10097 bus->dhd->busstate = DHD_BUS_DATA; in dhdsdio_suspend()
10099 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF); in dhdsdio_suspend()
10101 bus->dhd->hostsleep = 2; in dhdsdio_suspend()
10102 DHD_BUS_BUSY_CLEAR_SUSPEND_IN_PROGRESS(bus->dhd); in dhdsdio_suspend()
10103 dhd_os_busbusy_wake(bus->dhd); in dhdsdio_suspend()
10104 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhdsdio_suspend()
10113 dhd_bus_t *bus = (dhd_bus_t*)context; in dhdsdio_resume() local
10118 if (bus->dhd->up == FALSE) { in dhdsdio_resume()
10122 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhdsdio_resume()
10123 DHD_BUS_BUSY_SET_RESUME_IN_PROGRESS(bus->dhd); in dhdsdio_resume()
10124 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhdsdio_resume()
10127 if (dhd_os_check_if_up(bus->dhd)) in dhdsdio_resume()
10128 bcmsdh_oob_intr_set(bus->sdh, TRUE); in dhdsdio_resume()
10131 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhdsdio_resume()
10132 DHD_BUS_BUSY_CLEAR_RESUME_IN_PROGRESS(bus->dhd); in dhdsdio_resume()
10133 bus->dhd->hostsleep = 0; in dhdsdio_resume()
10134 bus->dhd->busstate = DHD_BUS_DATA; in dhdsdio_resume()
10135 dhd_os_busbusy_wake(bus->dhd); in dhdsdio_resume()
10137 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF); in dhdsdio_resume()
10138 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhdsdio_resume()
10144 * point (e.g. module insertion) to link with the bus driver, in
10186 dhdsdio_download_code_array(struct dhd_bus *bus) in dhdsdio_download_code_array() argument
10197 if (si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) { in dhdsdio_download_code_array()
10201 bus->resetinstr = *(((uint32*)dlarray)); in dhdsdio_download_code_array()
10203 offset += bus->dongle_ram_base; in dhdsdio_download_code_array()
10207 bcmerror = dhdsdio_membytes(bus, TRUE, offset, in dhdsdio_download_code_array()
10219 bcmerror = dhdsdio_membytes(bus, TRUE, offset, in dhdsdio_download_code_array()
10231 ularray = MALLOC(bus->dhd->osh, bus->ramsize); in dhdsdio_download_code_array()
10234 memset(ularray, 0xaa, bus->ramsize); in dhdsdio_download_code_array()
10236 bcmerror = dhdsdio_membytes(bus, FALSE, offset, ularray + offset, MEMBLOCK); in dhdsdio_download_code_array()
10247 bcmerror = dhdsdio_membytes(bus, FALSE, offset, in dhdsdio_download_code_array()
10269 MFREE(bus->dhd->osh, ularray, bus->ramsize); in dhdsdio_download_code_array()
10276 dhdsdio_download_code_file(struct dhd_bus *bus, char *pfw_path) in dhdsdio_download_code_file() argument
10290 int offset_end = bus->ramsize; in dhdsdio_download_code_file()
10299 bcmerror = dhd_os_get_img_fwreq(&fw, bus->fw_path); in dhdsdio_download_code_file()
10313 memptr = memblock = MALLOC(bus->dhd->osh, memblock_size + DHD_SDALIGN); in dhdsdio_download_code_file()
10323 if (bus->dhd->conf->fwchk) { in dhdsdio_download_code_file()
10324 memptr_tmp = MALLOC(bus->dhd->osh, MEMBLOCK + DHD_SDALIGN); in dhdsdio_download_code_file()
10341 if (si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) { in dhdsdio_download_code_file()
10345 bus->resetinstr = *(((uint32*)memptr)); in dhdsdio_download_code_file()
10347 offset += bus->dongle_ram_base; in dhdsdio_download_code_file()
10352 bcmerror = dhdsdio_membytes(bus, TRUE, offset, (uint8 *)memptr, len); in dhdsdio_download_code_file()
10360 if (bus->dhd->conf->fwchk) { in dhdsdio_download_code_file()
10361 bcmerror = dhdsdio_membytes(bus, FALSE, offset, memptr_tmp, len); in dhdsdio_download_code_file()
10397 MFREE(bus->dhd->osh, memblock, memblock_size + DHD_SDALIGN); in dhdsdio_download_code_file()
10399 if (bus->dhd->conf->fwchk) { in dhdsdio_download_code_file()
10401 MFREE(bus->dhd->osh, memptr_tmp, MEMBLOCK + DHD_SDALIGN); in dhdsdio_download_code_file()
10413 dhdsdio_download_code_file(struct dhd_bus *bus, char *pfw_path) in dhdsdio_download_code_file() argument
10434 image = dhd_os_open_image1(bus->dhd, pfw_path); in dhdsdio_download_code_file()
10446 memptr = memblock = MALLOC(bus->dhd->osh, memblock_size + DHD_SDALIGN); in dhdsdio_download_code_file()
10456 if (bus->dhd->conf->fwchk) { in dhdsdio_download_code_file()
10457 memptr_tmp = MALLOC(bus->dhd->osh, MEMBLOCK + DHD_SDALIGN); in dhdsdio_download_code_file()
10472 if (bus->dhd->conf->chip == BCM43340_CHIP_ID || in dhdsdio_download_code_file()
10473 bus->dhd->conf->chip == BCM43341_CHIP_ID) { in dhdsdio_download_code_file()
10485 if (si_setcore(bus->sih, ARMCR4_CORE_ID, 0)) { in dhdsdio_download_code_file()
10489 bus->resetinstr = *(((uint32*)memptr)); in dhdsdio_download_code_file()
10491 offset += bus->dongle_ram_base; in dhdsdio_download_code_file()
10495 bcmerror = dhdsdio_membytes(bus, TRUE, offset, memptr, len); in dhdsdio_download_code_file()
10503 if (bus->dhd->conf->fwchk) { in dhdsdio_download_code_file()
10504 bcmerror = dhdsdio_membytes(bus, FALSE, offset, memptr_tmp, len); in dhdsdio_download_code_file()
10532 MFREE(bus->dhd->osh, memblock, memblock_size + DHD_SDALIGN); in dhdsdio_download_code_file()
10534 if (bus->dhd->conf->fwchk) { in dhdsdio_download_code_file()
10536 MFREE(bus->dhd->osh, memptr_tmp, MEMBLOCK + DHD_SDALIGN); in dhdsdio_download_code_file()
10541 dhd_os_close_image1(bus->dhd, image); in dhdsdio_download_code_file()
10550 dhdsdio_ucode_base(struct dhd_bus *bus) in dhdsdio_ucode_base() argument
10554 switch ((uint16)bus->sih->chip) { in dhdsdio_ucode_base()
10569 dhdsdio_download_ucode_file(struct dhd_bus *bus, char *ucode_path) in dhdsdio_download_ucode_file() argument
10585 ucode_base = dhdsdio_ucode_base(bus); in dhdsdio_download_ucode_file()
10590 image = dhd_os_open_image1(bus->dhd, ucode_path); in dhdsdio_download_ucode_file()
10598 memptr = memblock = MALLOC(bus->dhd->osh, memblock_size + DHD_SDALIGN); in dhdsdio_download_ucode_file()
10619 bcmerror = dhdsdio_membytes(bus, TRUE, (ucode_base + offset), memptr, len); in dhdsdio_download_ucode_file()
10639 MFREE(bus->dhd->osh, memblock, memblock_size + DHD_SDALIGN); in dhdsdio_download_ucode_file()
10642 dhd_os_close_image1(bus->dhd, image); in dhdsdio_download_ucode_file()
10648 dhd_bus_ucode_download(struct dhd_bus *bus) in dhd_bus_ucode_download() argument
10652 shaddr = bus->dongle_ram_base + bus->ramsize - 4; in dhd_bus_ucode_download()
10653 dhdsdio_membytes(bus, FALSE, shaddr, (uint8 *)&shdata, 4); in dhd_bus_ucode_download()
10662 if (!dhd_get_ucode_path(bus->dhd)) { in dhd_bus_ucode_download()
10663 DHD_ERROR(("%s: bus->uc_path not set!\n", __func__)); in dhd_bus_ucode_download()
10666 dhdsdio_download_ucode_file(bus, dhd_get_ucode_path(bus->dhd)); in dhd_bus_ucode_download()
10671 dhdsdio_membytes(bus, TRUE, shaddr, (uint8 *)&shdata, 4); in dhd_bus_ucode_download()
10678 dhdsdio_download_nvram(struct dhd_bus *bus) in dhdsdio_download_nvram() argument
10687 pnv_path = bus->nv_path; in dhdsdio_download_nvram()
10693 bcmerror = dhd_get_download_buffer(bus->dhd, pnv_path, NVRAM, &memblock, in dhdsdio_download_nvram()
10696 bcmerror = dhd_get_download_buffer(bus->dhd, NULL, NVRAM, &memblock, (int *)&len); in dhdsdio_download_nvram()
10717 bcmerror = dhdsdio_downloadvars(bus, memblock, len + 1); in dhdsdio_download_nvram()
10730 dhd_free_download_buffer(bus->dhd, memblock, memblock_len); in dhdsdio_download_nvram()
10736 _dhdsdio_download_firmware(struct dhd_bus *bus) in _dhdsdio_download_firmware() argument
10744 if ((bus->fw_path == NULL) || (bus->fw_path[0] == '\0')) { in _dhdsdio_download_firmware()
10753 if (dhdsdio_download_state(bus, TRUE)) { in _dhdsdio_download_firmware()
10759 if ((bus->fw_path != NULL) && (bus->fw_path[0] != '\0')) { in _dhdsdio_download_firmware()
10760 if (dhdsdio_download_code_file(bus, bus->fw_path)) { in _dhdsdio_download_firmware()
10775 if (dhdsdio_download_code_array(bus)) { in _dhdsdio_download_firmware()
10791 if (dhdsdio_download_nvram(bus)) { in _dhdsdio_download_firmware()
10797 if (dhdsdio_download_state(bus, FALSE)) { in _dhdsdio_download_firmware()
10809 dhd_bcmsdh_recv_buf(dhd_bus_t *bus, uint32 addr, uint fn, uint flags, uint8 *buf, uint nbytes, in dhd_bcmsdh_recv_buf() argument
10814 if (!KSO_ENAB(bus)) { in dhd_bcmsdh_recv_buf()
10819 status = bcmsdh_recv_buf(bus->sdh, addr, fn, flags, buf, nbytes, pkt, complete_fn, handle); in dhd_bcmsdh_recv_buf()
10825 dhd_bcmsdh_send_buf(dhd_bus_t *bus, uint32 addr, uint fn, uint flags, uint8 *buf, uint nbytes, in dhd_bcmsdh_send_buf() argument
10833 if (!KSO_ENAB(bus)) { in dhd_bcmsdh_send_buf()
10838 sdh = bus->sdh; in dhd_bcmsdh_send_buf()
10840 ret = bcmsdh_send_buf(bus->sdh, addr, fn, flags, buf, nbytes, in dhd_bcmsdh_send_buf()
10843 bus->f2txdata++; in dhd_bcmsdh_send_buf()
10852 bus->tx_sderrs++; in dhd_bcmsdh_send_buf()
10853 bus->f1regdata++; in dhd_bcmsdh_send_buf()
10854 bus->dhd->tx_errors++; in dhd_bcmsdh_send_buf()
10864 bus->f1regdata += 2; in dhd_bcmsdh_send_buf()
10875 dhd_bus_is_ioready(struct dhd_bus *bus) in dhd_bus_is_ioready() argument
10879 ASSERT(bus); in dhd_bus_is_ioready()
10880 ASSERT(bus->sih != NULL); in dhd_bus_is_ioready()
10882 sdh = bus->sdh; in dhd_bus_is_ioready()
10887 dhd_bus_chip(struct dhd_bus *bus) in dhd_bus_chip() argument
10889 ASSERT(bus->sih != NULL); in dhd_bus_chip()
10890 return bus->sih->chip; in dhd_bus_chip()
10894 dhd_bus_chiprev(struct dhd_bus *bus) in dhd_bus_chiprev() argument
10896 ASSERT(bus); in dhd_bus_chiprev()
10897 ASSERT(bus->sih != NULL); in dhd_bus_chiprev()
10898 return bus->sih->chiprev; in dhd_bus_chiprev()
10902 dhd_bus_pub(struct dhd_bus *bus) in dhd_bus_pub() argument
10904 return bus->dhd; in dhd_bus_pub()
10908 dhd_bus_sih(struct dhd_bus *bus) in dhd_bus_sih() argument
10910 return (void *)bus->sih; in dhd_bus_sih()
10914 dhd_bus_txq(struct dhd_bus *bus) in dhd_bus_txq() argument
10916 return &bus->txq; in dhd_bus_txq()
10920 dhd_bus_hdrlen(struct dhd_bus *bus) in dhd_bus_hdrlen() argument
10922 return (bus->txglom_enable) ? SDPCM_HDRLEN_TXGLOM : SDPCM_HDRLEN; in dhd_bus_hdrlen()
10926 dhd_bus_set_dotxinrx(struct dhd_bus *bus, bool val) in dhd_bus_set_dotxinrx() argument
10928 bus->dotxinrx = val; in dhd_bus_set_dotxinrx()
10933 * to other bus user contexts like Tx, Rx, IOVAR, WD etc and it waits for other contexts
10934 * to gracefully exit. All the bus usage contexts before marking busstate as busy, will check for
10956 * bus usage context is not clearing the respective usage bit, print in dhdsdio_advertise_bus_cleanup()
10991 dhd_bus_t *bus; in dhd_bus_devreset() local
10994 bus = dhdp->bus; in dhd_bus_devreset()
10997 if (!bus->dhd->dongle_reset) { in dhd_bus_devreset()
10999 dhdsdio_advertise_bus_cleanup(bus->dhd); in dhd_bus_devreset()
11005 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, ON); in dhd_bus_devreset()
11009 /* Stop the bus, disable F2 */ in dhd_bus_devreset()
11010 dhd_bus_stop(bus, FALSE); in dhd_bus_devreset()
11014 dhd_enable_oob_intr(bus, FALSE); in dhd_bus_devreset()
11015 bcmsdh_oob_intr_set(bus->sdh, FALSE); in dhd_bus_devreset()
11016 bcmsdh_oob_intr_unregister(bus->sdh); in dhd_bus_devreset()
11020 dhdsdio_release_dongle(bus, bus->dhd->osh, TRUE, TRUE); in dhd_bus_devreset()
11022 bus->dhd->dongle_reset = TRUE; in dhd_bus_devreset()
11024 bus->dhd->up = FALSE; in dhd_bus_devreset()
11028 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhd_bus_devreset()
11030 bus->dhd->busstate = DHD_BUS_DOWN; in dhd_bus_devreset()
11031 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhd_bus_devreset()
11042 if (bus->dhd->dongle_reset) { in dhd_bus_devreset()
11046 bcmsdh_reset(bus->sdh); in dhd_bus_devreset()
11049 if (dhdsdio_probe_attach(bus, bus->dhd->osh, bus->sdh, in dhd_bus_devreset()
11050 (uint32 *)(uintptr)si_enum_base(bus->cl_devid), in dhd_bus_devreset()
11051 bus->cl_devid)) { in dhd_bus_devreset()
11053 DHD_LINUX_GENERAL_LOCK(bus->dhd, flags); in dhd_bus_devreset()
11055 bus->dhd->busstate = DHD_BUS_DOWN; in dhd_bus_devreset()
11056 DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags); in dhd_bus_devreset()
11058 if (dhdsdio_probe_init(bus, bus->dhd->osh, bus->sdh) && in dhd_bus_devreset()
11059 dhdsdio_download_firmware(bus, bus->dhd->osh, bus->sdh) >= 0) { in dhd_bus_devreset()
11061 /* Re-init bus, enable F2 transfer */ in dhd_bus_devreset()
11062 bcmerror = dhd_bus_init((dhd_pub_t *) bus->dhd, FALSE); in dhd_bus_devreset()
11065 dhd_enable_oob_intr(bus, TRUE); in dhd_bus_devreset()
11066 bcmsdh_oob_intr_register(bus->sdh, in dhd_bus_devreset()
11067 dhdsdio_isr, bus); in dhd_bus_devreset()
11068 bcmsdh_oob_intr_set(bus->sdh, TRUE); in dhd_bus_devreset()
11070 dhd_enable_oob_intr(bus, TRUE); in dhd_bus_devreset()
11073 bus->dhd->dongle_reset = FALSE; in dhd_bus_devreset()
11074 bus->dhd->up = TRUE; in dhd_bus_devreset()
11078 dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF); in dhd_bus_devreset()
11084 dhd_bus_stop(bus, FALSE); in dhd_bus_devreset()
11085 dhdsdio_release_dongle(bus, bus->dhd->osh, in dhd_bus_devreset()
11091 if (bus->sih != NULL) { in dhd_bus_devreset()
11092 si_detach(bus->sih); in dhd_bus_devreset()
11093 bus->sih = NULL; in dhd_bus_devreset()
11108 dhd_conf_set_hw_oob_intr(bus->sdh, bus->sih); // terence 20120615: fix for OOB initial issue in dhd_bus_devreset()
11126 return bcmsdh_stop(dhdpub->bus->sdh); in dhd_bus_suspend()
11131 return bcmsdh_start(dhdpub->bus->sdh, stage); in dhd_bus_resume()
11138 dhd_bus_t *bus = dhdp->bus; in dhd_bus_chip_id() local
11140 if (bus && bus->sih) in dhd_bus_chip_id()
11141 return bus->sih->chip; in dhd_bus_chip_id()
11149 dhd_bus_t *bus = dhdp->bus; in dhd_bus_chiprev_id() local
11151 if (bus && bus->sih) in dhd_bus_chiprev_id()
11152 return bus->sih->chiprev; in dhd_bus_chiprev_id()
11160 dhd_bus_t *bus = dhdp->bus; in dhd_bus_chippkg_id() local
11162 return bus->sih->chippkg; in dhd_bus_chippkg_id()
11165 int dhd_bus_get_ids(struct dhd_bus *bus, uint32 *bus_type, uint32 *bus_num, uint32 *slot_num) in dhd_bus_get_ids() argument
11167 *bus_type = bus->bus; in dhd_bus_get_ids()
11168 *bus_num = bus->bus_num; in dhd_bus_get_ids()
11169 *slot_num = bus->slot_num; in dhd_bus_get_ids()
11176 dhd_bus_t *bus; in dhd_bus_membytes() local
11178 bus = dhdp->bus; in dhd_bus_membytes()
11179 return dhdsdio_membytes(bus, set, address, data, size); in dhd_bus_membytes()
11184 concate_revision_bcm4335(dhd_bus_t *bus, char *fw_path, char *nv_path) in concate_revision_bcm4335() argument
11195 if (bus->sih->chip != BCM4335_CHIP_ID) { in concate_revision_bcm4335()
11199 chipver = bus->sih->chiprev; in concate_revision_bcm4335()
11217 concate_revision_bcm4339(dhd_bus_t *bus, char *fw_path, char *nv_path) in concate_revision_bcm4339() argument
11228 if (bus->sih->chip != BCM4339_CHIP_ID) { in concate_revision_bcm4339()
11232 chipver = bus->sih->chiprev; in concate_revision_bcm4339()
11247 static int concate_revision_bcm4350(dhd_bus_t *bus, char *fw_path, char *nv_path) in concate_revision_bcm4350() argument
11255 chip_ver = bus->sih->chiprev; in concate_revision_bcm4350()
11276 static int concate_revision_bcm4354(dhd_bus_t *bus, char *fw_path, char *nv_path) in concate_revision_bcm4354() argument
11287 chip_ver = bus->sih->chiprev; in concate_revision_bcm4354()
11306 concate_revision_bcm43454(dhd_bus_t *bus, char *fw_path, char *nv_path) in concate_revision_bcm43454() argument
11314 if (bus->sih->chip != BCM43454_CHIP_ID) { in concate_revision_bcm43454()
11338 concate_revision(dhd_bus_t *bus, char *fw_path, char *nv_path) in concate_revision() argument
11342 if (!bus || !bus->sih) { in concate_revision()
11343 DHD_ERROR(("%s:Bus is Invalid\n", __FUNCTION__)); in concate_revision()
11347 switch (bus->sih->chip) { in concate_revision()
11349 res = concate_revision_bcm4335(bus, fw_path, nv_path); in concate_revision()
11353 res = concate_revision_bcm4339(bus, fw_path, nv_path); in concate_revision()
11356 res = concate_revision_bcm4350(bus, fw_path, nv_path); in concate_revision()
11359 res = concate_revision_bcm4354(bus, fw_path, nv_path); in concate_revision()
11362 res = concate_revision_bcm43454(bus, fw_path, nv_path); in concate_revision()
11390 bcmsdh_reject_ioreqs(dhdp->bus->sdh, reject); in dhd_bus_reject_ioreqs()
11399 bcmsdh_waitfor_iodrain(dhdp->bus->sdh); in dhd_bus_waitfor_iodrain()
11404 dhd_bus_update_fw_nv_path(struct dhd_bus *bus, char *pfw_path, char *pnv_path, in dhd_bus_update_fw_nv_path() argument
11407 bus->fw_path = pfw_path; in dhd_bus_update_fw_nv_path()
11408 bus->nv_path = pnv_path; in dhd_bus_update_fw_nv_path()
11409 bus->dhd->clm_path = pclm_path; in dhd_bus_update_fw_nv_path()
11410 bus->dhd->conf_path = pconf_path; in dhd_bus_update_fw_nv_path()
11416 dhd_bus_t *bus = dhd->bus; in dhd_enableOOB() local
11417 sdpcmd_regs_t *regs = bus->regs; in dhd_enableOOB()
11421 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_enableOOB()
11429 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhd_enableOOB()
11431 /* Make sure the controller has the bus up */ in dhd_enableOOB()
11432 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_enableOOB()
11442 /* Make sure we have SD bus access */ in dhd_enableOOB()
11443 dhdsdio_clkctl(bus, CLK_SDONLY, FALSE); in dhd_enableOOB()
11451 dhd_bus_t *bus = dhdp->bus; in dhd_bus_pktq_flush() local
11462 dhd_tcpack_info_tbl_clean(bus->dhd); in dhd_bus_pktq_flush()
11465 pktq_flush(dhdp->osh, &bus->txq, TRUE); in dhd_bus_pktq_flush()
11473 dhd_bus_t *bus = dhd->bus; in dhd_sr_config() local
11475 if (!bus->_srenab) in dhd_sr_config()
11478 return dhdsdio_clk_devsleep_iovar(bus, on); in dhd_sr_config()
11482 dhd_get_chipid(struct dhd_bus *bus) in dhd_get_chipid() argument
11484 if (bus && bus->sih) in dhd_get_chipid()
11485 return (uint16)bus->sih->chip; in dhd_get_chipid()
11493 dhd_sdio_reg_read(struct dhd_bus *bus, ulong addr) in dhd_sdio_reg_read() argument
11497 dhd_os_sdlock(bus->dhd); in dhd_sdio_reg_read()
11499 BUS_WAKE(bus); in dhd_sdio_reg_read()
11501 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_sdio_reg_read()
11503 rval = bcmsdh_reg_read(bus->sdh, addr, 4); in dhd_sdio_reg_read()
11505 dhd_os_sdunlock(bus->dhd); in dhd_sdio_reg_read()
11511 dhd_sdio_reg_write(struct dhd_bus *bus, ulong addr, uint32 val) in dhd_sdio_reg_write() argument
11513 dhd_os_sdlock(bus->dhd); in dhd_sdio_reg_write()
11515 BUS_WAKE(bus); in dhd_sdio_reg_write()
11517 dhdsdio_clkctl(bus, CLK_AVAIL, FALSE); in dhd_sdio_reg_write()
11519 bcmsdh_reg_write(bus->sdh, addr, 4, val); in dhd_sdio_reg_write()
11521 dhd_os_sdunlock(bus->dhd); in dhd_sdio_reg_write()
11529 if (!dhdp || !dhdp->bus) { in dhd_bus_setidletime()
11530 DHD_ERROR(("%s:Bus is Invalid\n", __FUNCTION__)); in dhd_bus_setidletime()
11533 dhdp->bus->idletime = idle_time; in dhd_bus_setidletime()
11538 if (!dhdp || !dhdp->bus) { in dhd_bus_getidletime()
11539 DHD_ERROR(("%s:Bus is Invalid\n", __FUNCTION__)); in dhd_bus_getidletime()
11547 *idle_time = dhdp->bus->idletime; in dhd_bus_getidletime()
11556 dhd_bus_t *bus = (dhd_bus_t *)dhdp->bus; in dhd_bus_cfg_read() local
11558 dhd_os_sdlock(bus->dhd); in dhd_bus_cfg_read()
11560 intrd = bcmsdh_cfg_read(bus->sdh, fun_num, addr, err); in dhd_bus_cfg_read()
11562 dhd_os_sdunlock(bus->dhd); in dhd_bus_cfg_read()
11570 dhd_bus_t *bus = (dhd_bus_t *)dhdp->bus; in dhd_bus_cfg_write() local
11572 dhd_os_sdlock(bus->dhd); in dhd_bus_cfg_write()
11574 bcmsdh_cfg_write(bus->sdh, fun_num, addr, val, err); in dhd_bus_cfg_write()
11576 dhd_os_sdunlock(bus->dhd); in dhd_bus_cfg_write()
11591 read_more_btbytes(struct dhd_bus *bus, void * file, char *line, int * addr_mode, uint16 * hi_addr, in read_more_btbytes() argument
11601 str_len = dhd_os_gets_image(bus->dhd, line, BTFW_MAX_STR_LEN, file); in read_more_btbytes()
11645 _dhdsdio_download_btfw(struct dhd_bus *bus) in _dhdsdio_download_btfw() argument
11662 if ((bus->btfw_path == NULL) || (bus->btfw_path[0] == '\0')) { in _dhdsdio_download_btfw()
11669 image = dhd_os_open_image1(bus->dhd, bus->btfw_path); in _dhdsdio_download_btfw()
11673 mem_ptr = mem_blk = MALLOC(bus->dhd->osh, BTFW_DOWNLOAD_BLK_SIZE + DHD_SDALIGN); in _dhdsdio_download_btfw()
11682 data_ptr = MALLOC(bus->dhd->osh, BTFW_DOWNLOAD_BLK_SIZE - 8); in _dhdsdio_download_btfw()
11690 bcmsdh_reg_write(bus->sdh, bt2wlan_pwrup_adr, 4, BT2WLAN_PWRUP_WAKE); in _dhdsdio_download_btfw()
11696 line = MALLOC(bus->dhd->osh, BTFW_MAX_STR_LEN); in _dhdsdio_download_btfw()
11704 while (read_more_btbytes (bus, image, line, &addr_mode, &hiAddress, &dest_addr, in _dhdsdio_download_btfw()
11718 start_data = bcmsdh_reg_read(bus->sdh, start_addr, 4); in _dhdsdio_download_btfw()
11732 end_data = bcmsdh_reg_read(bus->sdh, end_addr, 4); in _dhdsdio_download_btfw()
11741 bcm_error = dhdsdio_membytes(bus, TRUE, start_addr, mem_ptr, index); in _dhdsdio_download_btfw()
11750 bcm_error = dhdsdio_membytes(bus, TRUE, start_addr, mem_ptr, in _dhdsdio_download_btfw()
11760 bcm_error = dhdsdio_membytes(bus, TRUE, (start_addr + bytes_to_write), in _dhdsdio_download_btfw()
11774 MFREE(bus->dhd->osh, mem_blk, BTFW_DOWNLOAD_BLK_SIZE + DHD_SDALIGN); in _dhdsdio_download_btfw()
11777 MFREE(bus->dhd->osh, data_ptr, BTFW_DOWNLOAD_BLK_SIZE - 8); in _dhdsdio_download_btfw()
11780 MFREE(bus->dhd->osh, line, BTFW_MAX_STR_LEN); in _dhdsdio_download_btfw()
11783 dhd_os_close_image1(bus->dhd, image); in _dhdsdio_download_btfw()
11789 dhdsdio_download_btfw(struct dhd_bus *bus, osl_t *osh, void *sdh) in dhdsdio_download_btfw() argument
11794 __FUNCTION__, bus->btfw_path)); in dhdsdio_download_btfw()
11795 DHD_OS_WAKE_LOCK(bus->dhd); in dhdsdio_download_btfw()
11796 dhd_os_sdlock(bus->dhd); in dhdsdio_download_btfw()
11799 ret = _dhdsdio_download_btfw(bus); in dhdsdio_download_btfw()
11801 dhd_os_sdunlock(bus->dhd); in dhdsdio_download_btfw()
11802 DHD_OS_WAKE_UNLOCK(bus->dhd); in dhdsdio_download_btfw()
11808 dhd_bus_download_btfw(struct dhd_bus *bus, osl_t *osh, in dhd_bus_download_btfw() argument
11813 bus->btfw_path = pbtfw_path; in dhd_bus_download_btfw()
11815 ret = dhdsdio_download_btfw(bus, osh, bus->sdh); in dhd_bus_download_btfw()
11822 dhd_bus_dump_trap_info(dhd_bus_t *bus, struct bcmstrbuf *strbuf) in dhd_bus_dump_trap_info() argument
11824 trap_t *tr = &bus->dhd->last_trap_info; in dhd_bus_dump_trap_info()
11833 ltoh32(bus->dongle_trap_addr), in dhd_bus_dump_trap_info()
11840 dhd_bcmsdh_send_buffer(void *bus, uint8 *frame, uint16 len) in dhd_bcmsdh_send_buffer() argument
11844 ret = dhd_bcmsdh_send_buf(bus, bcmsdh_cur_sbwad(((dhd_bus_t*)bus)->sdh), in dhd_bcmsdh_send_buffer()
11848 ((dhd_bus_t*)bus)->tx_seq = (((dhd_bus_t*)bus)->tx_seq + 1) % SDPCM_SEQUENCE_WRAP; in dhd_bcmsdh_send_buffer()
11855 dhd_bus_set_default_min_res_mask(struct dhd_bus *bus) in dhd_bus_set_default_min_res_mask() argument
11857 if ((bus == NULL) || (bus->sih == NULL)) { in dhd_bus_set_default_min_res_mask()
11862 switch (bus->sih->chip) { in dhd_bus_set_default_min_res_mask()
11864 bcmsdh_reg_write(bus->sdh, SI_ENUM_BASE(bus->sih) + 0x618, 4, 0x3fcaf377); in dhd_bus_set_default_min_res_mask()
11865 if (bcmsdh_regfail(bus->sdh)) { in dhd_bus_set_default_min_res_mask()
11874 bcmsdh_reg_write(bus->sdh, in dhd_bus_set_default_min_res_mask()
11875 si_get_pmu_reg_addr(bus->sih, OFFSETOF(pmuregs_t, min_res_mask)), in dhd_bus_set_default_min_res_mask()
11877 if (bcmsdh_regfail(bus->sdh)) { in dhd_bus_set_default_min_res_mask()
11895 struct dhd_bus *bus = dhdp->bus; in dhd_bus_pmu_reg_reset() local
11896 bcmsdh_reg_write(bus->sdh, si_get_pmu_reg_addr(bus->sih, in dhd_bus_pmu_reg_reset()
11898 if (bcmsdh_regfail(bus->sdh)) { in dhd_bus_pmu_reg_reset()
11907 struct dhd_bus *bus = dhdp->bus; in dhd_bus_readwrite_bp_addr() local
11910 *data = (int32)bcmsdh_reg_read(bus->sdh, addr, size); in dhd_bus_readwrite_bp_addr()
11912 bcmsdh_reg_write(bus->sdh, addr, size, *data); in dhd_bus_readwrite_bp_addr()
11915 if (bcmsdh_regfail(bus->sdh)) in dhd_bus_readwrite_bp_addr()
11923 return dhd->bus->idletime; in dhd_get_idletime()
11930 if (!dhd->bus) { in dhd_bus_get_wakecount()
11933 return &dhd->bus->wake_counts; in dhd_bus_get_wakecount()
11938 return bcmsdh_set_get_wake(dhd->bus->sdh, 0); in dhd_bus_get_bus_wake()
11945 dhd_bus_t *bus = dhdp->bus; in dhd_bus_sleep() local
11949 if (bus) { in dhd_bus_sleep()
11951 BUS_WAKE(bus); in dhd_bus_sleep()
11952 R_SDREG(*intstatus, &bus->regs->intstatus, retry); in dhd_bus_sleep()
11954 if (SLPAUTO_ENAB(bus)) { in dhd_bus_sleep()
11955 ret = dhdsdio_bussleep(bus, sleep); in dhd_bus_sleep()
11957 dhd_os_wd_timer(bus->dhd, 0); in dhd_bus_sleep()
11959 dhdsdio_clkctl(bus, CLK_NONE, FALSE); in dhd_bus_sleep()
11963 DHD_ERROR(("bus is NULL\n")); in dhd_bus_sleep()