Lines Matching +full:precondition +full:- +full:timeout
1 // SPDX-License-Identifier: ISC
72 __le32 buf; /* Can't be pointer on (64-bit) hosts */
117 #define TXHI (TXQLEN - 256) /* turn on flow control above TXHI */
118 #define TXLOW (TXHI - 256) /* turn off flow control below TXLOW */
148 /* 1: isolate internal sdio signals, put external pads in tri-state; requires
153 /* Force SD->SB reset mapping (rev 11) */
249 #define SFC_ABORTALL (1 << 3) /* Abort all in-progress frames */
288 * Software-defined protocol header
419 uint fc_rcvd; /* Number of flow-control events received */
420 uint fc_xoff; /* Number which turned on flow-control */
421 uint fc_xon; /* Number which turned off flow-control */
434 ulong rx_readahead_cnt; /* packets where header read-ahead was used */
446 atomic_t fcstate; /* State of dongle flow-control */
451 struct pktq txq; /* Queue length used for flow-control */
494 s32 idletime; /* Control for activity timeout */
495 s32 idlecount; /* Activity timeout counter */
506 spinlock_t txq_lock; /* protect bus->txq */
520 bool txoff; /* Transmit flow-controlled */
528 u16 sgentry_align; /* scatter-gather buffer alignment */
565 u8 sel; /* Chip-specific select value */
606 BRCMF_FW_DEF(43143, "brcmfmac43143-sdio");
607 BRCMF_FW_DEF(43241B0, "brcmfmac43241b0-sdio");
608 BRCMF_FW_DEF(43241B4, "brcmfmac43241b4-sdio");
609 BRCMF_FW_DEF(43241B5, "brcmfmac43241b5-sdio");
610 BRCMF_FW_DEF(4329, "brcmfmac4329-sdio");
611 BRCMF_FW_DEF(4330, "brcmfmac4330-sdio");
612 BRCMF_FW_DEF(4334, "brcmfmac4334-sdio");
613 BRCMF_FW_DEF(43340, "brcmfmac43340-sdio");
614 BRCMF_FW_DEF(4335, "brcmfmac4335-sdio");
615 BRCMF_FW_DEF(43362, "brcmfmac43362-sdio");
616 BRCMF_FW_DEF(4339, "brcmfmac4339-sdio");
617 BRCMF_FW_DEF(43430A0, "brcmfmac43430a0-sdio");
619 BRCMF_FW_CLM_DEF(43430A1, "brcmfmac43430-sdio");
620 BRCMF_FW_DEF(43430B0, "brcmfmac43430b0-sdio");
621 BRCMF_FW_CLM_DEF(43439, "brcmfmac43439-sdio");
622 BRCMF_FW_CLM_DEF(43455, "brcmfmac43455-sdio");
623 BRCMF_FW_DEF(43456, "brcmfmac43456-sdio");
624 BRCMF_FW_CLM_DEF(4354, "brcmfmac4354-sdio");
625 BRCMF_FW_CLM_DEF(4356, "brcmfmac4356-sdio");
626 BRCMF_FW_DEF(4359, "brcmfmac4359-sdio");
627 BRCMF_FW_CLM_DEF(4373, "brcmfmac4373-sdio");
628 BRCMF_FW_CLM_DEF(43012, "brcmfmac43012-sdio");
629 BRCMF_FW_CLM_DEF(43752, "brcmfmac43752-sdio");
632 MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcmfmac*-sdio.*.txt");
634 /* per-board firmware binaries */
635 MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH "brcmfmac*-sdio.*.bin");
670 datalign = (unsigned long)(p->data); in pkt_align()
671 datalign = roundup(datalign, (align)) - datalign; in pkt_align()
683 if (bus->ctrl_frame_stat) in data_ok()
686 return (bus->tx_max - bus->tx_seq - tx_rsv) != 0 && in data_ok()
687 ((bus->tx_max - bus->tx_seq - tx_rsv) & 0x80) == 0; in data_ok()
694 return (bus->tx_max - bus->tx_seq) != 0 && in txctl_ok()
695 ((bus->tx_max - bus->tx_seq) & 0x80) == 0; in txctl_ok()
708 sdio_retune_crc_disable(bus->sdiodev->func1); in brcmf_sdio_kso_control()
710 /* Cannot re-tune if device is asleep; defer till we're awake */ in brcmf_sdio_kso_control()
712 sdio_retune_hold_now(bus->sdiodev->func1); in brcmf_sdio_kso_control()
716 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, wr_val, &err); in brcmf_sdio_kso_control()
723 if (!on && bus->ci->chip == CY_CC_43012_CHIP_ID) in brcmf_sdio_kso_control()
750 rd_val = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, in brcmf_sdio_kso_control()
762 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, wr_val, in brcmf_sdio_kso_control()
775 sdio_retune_release(bus->sdiodev->func1); in brcmf_sdio_kso_control()
777 sdio_retune_crc_enable(bus->sdiodev->func1); in brcmf_sdio_kso_control()
789 unsigned long timeout; in brcmf_sdio_htclk() local
795 if (bus->sr_enabled) { in brcmf_sdio_htclk()
796 bus->clkstate = (on ? CLK_AVAIL : CLK_SDONLY); in brcmf_sdio_htclk()
803 bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ; in brcmf_sdio_htclk()
805 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, in brcmf_sdio_htclk()
809 return -EBADE; in brcmf_sdio_htclk()
813 clkctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_htclk()
817 return -EBADE; in brcmf_sdio_htclk()
821 if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) { in brcmf_sdio_htclk()
822 /* Allow only clock-available interrupt */ in brcmf_sdio_htclk()
823 devctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_htclk()
827 return -EBADE; in brcmf_sdio_htclk()
831 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_DEVICE_CTL, in brcmf_sdio_htclk()
834 bus->clkstate = CLK_PENDING; in brcmf_sdio_htclk()
837 } else if (bus->clkstate == CLK_PENDING) { in brcmf_sdio_htclk()
838 /* Cancel CA-only interrupt filter */ in brcmf_sdio_htclk()
839 devctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_htclk()
842 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_DEVICE_CTL, in brcmf_sdio_htclk()
847 timeout = jiffies + in brcmf_sdio_htclk()
849 while (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { in brcmf_sdio_htclk()
850 clkctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_htclk()
853 if (time_after(jiffies, timeout)) in brcmf_sdio_htclk()
860 return -EBADE; in brcmf_sdio_htclk()
862 if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { in brcmf_sdio_htclk()
863 brcmf_err("HT Avail timeout (%d): clkctl 0x%02x\n", in brcmf_sdio_htclk()
865 return -EBADE; in brcmf_sdio_htclk()
869 bus->clkstate = CLK_AVAIL; in brcmf_sdio_htclk()
873 if (!bus->alp_only) { in brcmf_sdio_htclk()
882 if (bus->clkstate == CLK_PENDING) { in brcmf_sdio_htclk()
883 /* Cancel CA-only interrupt filter */ in brcmf_sdio_htclk()
884 devctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_htclk()
887 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_DEVICE_CTL, in brcmf_sdio_htclk()
891 bus->clkstate = CLK_SDONLY; in brcmf_sdio_htclk()
892 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, in brcmf_sdio_htclk()
898 return -EBADE; in brcmf_sdio_htclk()
910 bus->clkstate = CLK_SDONLY; in brcmf_sdio_sdclk()
912 bus->clkstate = CLK_NONE; in brcmf_sdio_sdclk()
921 uint oldstate = bus->clkstate; in brcmf_sdio_clkctl()
927 if (bus->clkstate == target) in brcmf_sdio_clkctl()
933 if (bus->clkstate == CLK_NONE) in brcmf_sdio_clkctl()
941 if (bus->clkstate == CLK_NONE) in brcmf_sdio_clkctl()
943 else if (bus->clkstate == CLK_AVAIL) in brcmf_sdio_clkctl()
946 brcmf_err("request for %d -> %d\n", in brcmf_sdio_clkctl()
947 bus->clkstate, target); in brcmf_sdio_clkctl()
952 if (bus->clkstate == CLK_AVAIL) in brcmf_sdio_clkctl()
959 brcmf_dbg(SDIO, "%d -> %d\n", oldstate, bus->clkstate); in brcmf_sdio_clkctl()
973 (bus->sleeping ? "SLEEP" : "WAKE")); in brcmf_sdio_bus_sleep()
976 if (bus->sr_enabled) { in brcmf_sdio_bus_sleep()
978 if (sleep == bus->sleeping) in brcmf_sdio_bus_sleep()
983 clkcsr = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_bus_sleep()
988 brcmf_sdiod_writeb(bus->sdiodev, in brcmf_sdio_bus_sleep()
1006 if (!bus->sr_enabled) in brcmf_sdio_bus_sleep()
1012 bus->sleeping = sleep; in brcmf_sdio_bus_sleep()
1036 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readshared()
1043 shaddr = bus->ci->rambase + bus->ci->ramsize - 4; in brcmf_sdio_readshared()
1044 if (!bus->ci->rambase && brcmf_chip_sr_capable(bus->ci)) in brcmf_sdio_readshared()
1045 shaddr -= bus->ci->srsize; in brcmf_sdio_readshared()
1046 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, shaddr, in brcmf_sdio_readshared()
1058 rv = -EINVAL; in brcmf_sdio_readshared()
1065 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, (u8 *)&sh_le, in brcmf_sdio_readshared()
1070 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readshared()
1073 sh->flags = le32_to_cpu(sh_le.flags); in brcmf_sdio_readshared()
1074 sh->trap_addr = le32_to_cpu(sh_le.trap_addr); in brcmf_sdio_readshared()
1075 sh->assert_exp_addr = le32_to_cpu(sh_le.assert_exp_addr); in brcmf_sdio_readshared()
1076 sh->assert_file_addr = le32_to_cpu(sh_le.assert_file_addr); in brcmf_sdio_readshared()
1077 sh->assert_line = le32_to_cpu(sh_le.assert_line); in brcmf_sdio_readshared()
1078 sh->console_addr = le32_to_cpu(sh_le.console_addr); in brcmf_sdio_readshared()
1079 sh->msgtrace_addr = le32_to_cpu(sh_le.msgtrace_addr); in brcmf_sdio_readshared()
1081 if ((sh->flags & SDPCM_SHARED_VERSION_MASK) > SDPCM_SHARED_VERSION) { in brcmf_sdio_readshared()
1084 sh->flags & SDPCM_SHARED_VERSION_MASK); in brcmf_sdio_readshared()
1085 return -EPROTO; in brcmf_sdio_readshared()
1092 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readshared()
1101 bus->console_addr = sh.console_addr; in brcmf_sdio_get_console_addr()
1111 struct brcmf_sdio_dev *sdiod = bus->sdiodev; in brcmf_sdio_hostmail()
1112 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_hostmail()
1122 core->base + SD_REG(tohostmailboxdata), in brcmf_sdio_hostmail()
1126 brcmf_sdiod_writel(sdiod, core->base + SD_REG(tosbmailbox), in brcmf_sdio_hostmail()
1129 bus->sdcnt.f1regdata += 2; in brcmf_sdio_hostmail()
1134 brcmf_fw_crashed(&sdiod->func1->dev); in brcmf_sdio_hostmail()
1140 bus->rx_seq); in brcmf_sdio_hostmail()
1141 if (!bus->rxskip) in brcmf_sdio_hostmail()
1144 bus->rxskip = false; in brcmf_sdio_hostmail()
1152 bus->sdpcm_ver = in brcmf_sdio_hostmail()
1155 if (bus->sdpcm_ver != SDPCM_PROT_VERSION) in brcmf_sdio_hostmail()
1158 bus->sdpcm_ver, SDPCM_PROT_VERSION); in brcmf_sdio_hostmail()
1161 bus->sdpcm_ver); in brcmf_sdio_hostmail()
1179 if (fcbits & ~bus->flowcontrol) in brcmf_sdio_hostmail()
1180 bus->sdcnt.fc_xoff++; in brcmf_sdio_hostmail()
1182 if (bus->flowcontrol & ~fcbits) in brcmf_sdio_hostmail()
1183 bus->sdcnt.fc_xon++; in brcmf_sdio_hostmail()
1185 bus->sdcnt.fc_rcvd++; in brcmf_sdio_hostmail()
1186 bus->flowcontrol = fcbits; in brcmf_sdio_hostmail()
1204 struct brcmf_sdio_dev *sdiod = bus->sdiodev; in brcmf_sdio_rxfail()
1205 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_rxfail()
1216 brcmf_sdiod_abort(bus->sdiodev, bus->sdiodev->func2); in brcmf_sdio_rxfail()
1218 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_FRAMECTRL, SFC_RF_TERM, in brcmf_sdio_rxfail()
1220 bus->sdcnt.f1regdata++; in brcmf_sdio_rxfail()
1223 for (lastrbc = retries = 0xffff; retries > 0; retries--) { in brcmf_sdio_rxfail()
1224 hi = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_RFRAMEBCHI, in brcmf_sdio_rxfail()
1226 lo = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_RFRAMEBCLO, in brcmf_sdio_rxfail()
1228 bus->sdcnt.f1regdata += 2; in brcmf_sdio_rxfail()
1243 brcmf_dbg(SDIO, "flush took %d iterations\n", 0xffff - retries); in brcmf_sdio_rxfail()
1246 bus->sdcnt.rxrtx++; in brcmf_sdio_rxfail()
1247 brcmf_sdiod_writel(sdiod, core->base + SD_REG(tosbmailbox), in brcmf_sdio_rxfail()
1250 bus->sdcnt.f1regdata++; in brcmf_sdio_rxfail()
1252 bus->rxskip = true; in brcmf_sdio_rxfail()
1256 bus->cur_read.len = 0; in brcmf_sdio_rxfail()
1261 struct brcmf_sdio_dev *sdiodev = bus->sdiodev; in brcmf_sdio_txfail()
1266 bus->sdcnt.tx_sderrs++; in brcmf_sdio_txfail()
1268 brcmf_sdiod_abort(sdiodev, sdiodev->func2); in brcmf_sdio_txfail()
1270 bus->sdcnt.f1regdata++; in brcmf_sdio_txfail()
1275 bus->sdcnt.f1regdata += 2; in brcmf_sdio_txfail()
1288 skb_queue_walk(&bus->glom, p) in brcmf_sdio_glom_len()
1289 total += p->len; in brcmf_sdio_glom_len()
1297 skb_queue_walk_safe(&bus->glom, cur, next) { in brcmf_sdio_free_glom()
1298 skb_unlink(cur, &bus->glom); in brcmf_sdio_free_glom()
1311 * hardware header (frame tag) - 4 bytes
1313 * Byte 2~3: Checksum, bit-wise inverse of frame length
1314 * hardware extension header - 8 bytes
1321 * software header - 8 bytes
1386 bus->rxpending = false; in brcmf_sdio_hdparse()
1387 return -ENODATA; in brcmf_sdio_hdparse()
1391 bus->sdcnt.rx_badhdr++; in brcmf_sdio_hdparse()
1393 return -EIO; in brcmf_sdio_hdparse()
1397 return -EPROTO; in brcmf_sdio_hdparse()
1400 (roundup(len, bus->blocksize) != rd->len)) { in brcmf_sdio_hdparse()
1402 return -EPROTO; in brcmf_sdio_hdparse()
1404 if (type == BRCMF_SDIO_FT_SUB && len > rd->len) { in brcmf_sdio_hdparse()
1406 return -EPROTO; in brcmf_sdio_hdparse()
1408 rd->len = len; in brcmf_sdio_hdparse()
1415 rd->len = 0; in brcmf_sdio_hdparse()
1416 return -EINVAL; in brcmf_sdio_hdparse()
1419 rd->channel = (swheader & SDPCM_CHANNEL_MASK) >> SDPCM_CHANNEL_SHIFT; in brcmf_sdio_hdparse()
1420 if (len > MAX_RX_DATASZ && rd->channel != SDPCM_CONTROL_CHANNEL && in brcmf_sdio_hdparse()
1423 bus->sdcnt.rx_toolong++; in brcmf_sdio_hdparse()
1425 rd->len = 0; in brcmf_sdio_hdparse()
1426 return -EPROTO; in brcmf_sdio_hdparse()
1428 if (type == BRCMF_SDIO_FT_SUPER && rd->channel != SDPCM_GLOM_CHANNEL) { in brcmf_sdio_hdparse()
1430 rd->len = 0; in brcmf_sdio_hdparse()
1431 return -EINVAL; in brcmf_sdio_hdparse()
1433 if (type == BRCMF_SDIO_FT_SUB && rd->channel != SDPCM_DATA_CHANNEL && in brcmf_sdio_hdparse()
1434 rd->channel != SDPCM_EVENT_CHANNEL) { in brcmf_sdio_hdparse()
1436 rd->len = 0; in brcmf_sdio_hdparse()
1437 return -EINVAL; in brcmf_sdio_hdparse()
1439 rd->dat_offset = brcmf_sdio_getdatoffset(header); in brcmf_sdio_hdparse()
1440 if (rd->dat_offset < SDPCM_HDRLEN || rd->dat_offset > rd->len) { in brcmf_sdio_hdparse()
1442 bus->sdcnt.rx_badhdr++; in brcmf_sdio_hdparse()
1444 rd->len = 0; in brcmf_sdio_hdparse()
1445 return -ENXIO; in brcmf_sdio_hdparse()
1447 if (rd->seq_num != rx_seq) { in brcmf_sdio_hdparse()
1448 brcmf_dbg(SDIO, "seq %d, expected %d\n", rx_seq, rd->seq_num); in brcmf_sdio_hdparse()
1449 bus->sdcnt.rx_badseq++; in brcmf_sdio_hdparse()
1450 rd->seq_num = rx_seq; in brcmf_sdio_hdparse()
1455 rd->len_nxtfrm = (swheader & SDPCM_NEXTLEN_MASK) >> SDPCM_NEXTLEN_SHIFT; in brcmf_sdio_hdparse()
1456 if (rd->len_nxtfrm << 4 > MAX_RX_DATASZ) { in brcmf_sdio_hdparse()
1458 if (rd->channel != SDPCM_GLOM_CHANNEL) in brcmf_sdio_hdparse()
1460 rd->len_nxtfrm = 0; in brcmf_sdio_hdparse()
1464 if (bus->flowcontrol != fc) { in brcmf_sdio_hdparse()
1465 if (~bus->flowcontrol & fc) in brcmf_sdio_hdparse()
1466 bus->sdcnt.fc_xoff++; in brcmf_sdio_hdparse()
1467 if (bus->flowcontrol & ~fc) in brcmf_sdio_hdparse()
1468 bus->sdcnt.fc_xon++; in brcmf_sdio_hdparse()
1469 bus->sdcnt.fc_rcvd++; in brcmf_sdio_hdparse()
1470 bus->flowcontrol = fc; in brcmf_sdio_hdparse()
1473 if ((u8)(tx_seq_max - bus->tx_seq) > 0x40) { in brcmf_sdio_hdparse()
1475 tx_seq_max = bus->tx_seq + 2; in brcmf_sdio_hdparse()
1477 bus->tx_max = tx_seq_max; in brcmf_sdio_hdparse()
1494 brcmf_sdio_update_hwhdr(header, hd_info->len); in brcmf_sdio_hdpack()
1497 if (bus->txglom) { in brcmf_sdio_hdpack()
1498 hdrval = (hd_info->len - hdr_offset) | (hd_info->lastfrm << 24); in brcmf_sdio_hdpack()
1500 hdrval = (u16)hd_info->tail_pad << 16; in brcmf_sdio_hdpack()
1505 hdrval = hd_info->seq_num; in brcmf_sdio_hdpack()
1506 hdrval |= (hd_info->channel << SDPCM_CHANNEL_SHIFT) & in brcmf_sdio_hdpack()
1508 hdrval |= (hd_info->dat_offset << SDPCM_DOFFSET_SHIFT) & in brcmf_sdio_hdpack()
1512 trace_brcmf_sdpcm_hdr(SDPCM_TX + !!(bus->txglom), header); in brcmf_sdio_hdpack()
1531 bus->glomd, skb_peek(&bus->glom)); in brcmf_sdio_rxglom()
1534 if (bus->glomd) { in brcmf_sdio_rxglom()
1536 dlen = (u16) (bus->glomd->len); in brcmf_sdio_rxglom()
1537 dptr = bus->glomd->data; in brcmf_sdio_rxglom()
1547 dlen -= sizeof(u16); in brcmf_sdio_rxglom()
1556 if (sublen % bus->sgentry_align) { in brcmf_sdio_rxglom()
1558 sublen, bus->sgentry_align); in brcmf_sdio_rxglom()
1566 (roundup(totlen, bus->blocksize) - totlen); in brcmf_sdio_rxglom()
1567 totlen = roundup(totlen, bus->blocksize); in brcmf_sdio_rxglom()
1571 pnext = brcmu_pkt_buf_get_skb(sublen + bus->sgentry_align); in brcmf_sdio_rxglom()
1577 skb_queue_tail(&bus->glom, pnext); in brcmf_sdio_rxglom()
1580 pkt_align(pnext, sublen, bus->sgentry_align); in brcmf_sdio_rxglom()
1586 brcmf_dbg(GLOM, "allocated %d-byte packet chain for %d subframes\n", in brcmf_sdio_rxglom()
1588 if (BRCMF_GLOM_ON() && bus->cur_read.len && in brcmf_sdio_rxglom()
1589 totlen != bus->cur_read.len) { in brcmf_sdio_rxglom()
1591 bus->cur_read.len, totlen, rxseq); in brcmf_sdio_rxglom()
1600 brcmu_pkt_buf_free_skb(bus->glomd); in brcmf_sdio_rxglom()
1601 bus->glomd = NULL; in brcmf_sdio_rxglom()
1602 bus->cur_read.len = 0; in brcmf_sdio_rxglom()
1605 /* Ok -- either we just generated a packet chain, in brcmf_sdio_rxglom()
1607 if (!skb_queue_empty(&bus->glom)) { in brcmf_sdio_rxglom()
1610 skb_queue_walk(&bus->glom, pnext) { in brcmf_sdio_rxglom()
1612 pnext, (u8 *) (pnext->data), in brcmf_sdio_rxglom()
1613 pnext->len, pnext->len); in brcmf_sdio_rxglom()
1617 pfirst = skb_peek(&bus->glom); in brcmf_sdio_rxglom()
1624 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1625 errcode = brcmf_sdiod_recv_chain(bus->sdiodev, in brcmf_sdio_rxglom()
1626 &bus->glom, dlen); in brcmf_sdio_rxglom()
1627 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1628 bus->sdcnt.f2rxdata++; in brcmf_sdio_rxglom()
1635 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1637 bus->sdcnt.rxglomfail++; in brcmf_sdio_rxglom()
1639 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1644 pfirst->data, min_t(int, pfirst->len, 48), in brcmf_sdio_rxglom()
1649 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1650 errcode = brcmf_sdio_hdparse(bus, pfirst->data, &rd_new, in brcmf_sdio_rxglom()
1652 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1653 bus->cur_read.len = rd_new.len_nxtfrm << 4; in brcmf_sdio_rxglom()
1660 skb_queue_walk(&bus->glom, pnext) { in brcmf_sdio_rxglom()
1665 rd_new.len = pnext->len; in brcmf_sdio_rxglom()
1667 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1668 errcode = brcmf_sdio_hdparse(bus, pnext->data, &rd_new, in brcmf_sdio_rxglom()
1670 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1672 pnext->data, 32, "subframe:\n"); in brcmf_sdio_rxglom()
1679 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1681 bus->sdcnt.rxglomfail++; in brcmf_sdio_rxglom()
1683 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1684 bus->cur_read.len = 0; in brcmf_sdio_rxglom()
1688 /* Basic SD framing looks ok - process each packet (header) */ in brcmf_sdio_rxglom()
1690 skb_queue_walk_safe(&bus->glom, pfirst, pnext) { in brcmf_sdio_rxglom()
1691 dptr = (u8 *) (pfirst->data); in brcmf_sdio_rxglom()
1696 dptr, pfirst->len, in brcmf_sdio_rxglom()
1702 if (pfirst->len == 0) { in brcmf_sdio_rxglom()
1703 skb_unlink(pfirst, &bus->glom); in brcmf_sdio_rxglom()
1709 pfirst->data, in brcmf_sdio_rxglom()
1710 min_t(int, pfirst->len, 32), in brcmf_sdio_rxglom()
1712 bus->glom.qlen, pfirst, pfirst->data, in brcmf_sdio_rxglom()
1713 pfirst->len, pfirst->next, in brcmf_sdio_rxglom()
1714 pfirst->prev); in brcmf_sdio_rxglom()
1715 skb_unlink(pfirst, &bus->glom); in brcmf_sdio_rxglom()
1717 brcmf_rx_event(bus->sdiodev->dev, pfirst); in brcmf_sdio_rxglom()
1719 brcmf_rx_frame(bus->sdiodev->dev, pfirst, in brcmf_sdio_rxglom()
1721 bus->sdcnt.rxglompkts++; in brcmf_sdio_rxglom()
1724 bus->sdcnt.rxglomframes++; in brcmf_sdio_rxglom()
1733 int timeout = DCMD_RESP_TIMEOUT; in brcmf_sdio_dcmd_resp_wait() local
1736 add_wait_queue(&bus->dcmd_resp_wait, &wait); in brcmf_sdio_dcmd_resp_wait()
1739 while (!(*condition) && (!signal_pending(current) && timeout)) in brcmf_sdio_dcmd_resp_wait()
1740 timeout = schedule_timeout(timeout); in brcmf_sdio_dcmd_resp_wait()
1746 remove_wait_queue(&bus->dcmd_resp_wait, &wait); in brcmf_sdio_dcmd_resp_wait()
1748 return timeout; in brcmf_sdio_dcmd_resp_wait()
1753 wake_up_interruptible(&bus->dcmd_resp_wait); in brcmf_sdio_dcmd_resp_wake()
1765 if (bus->rxblen) in brcmf_sdio_read_control()
1766 buf = vzalloc(bus->rxblen); in brcmf_sdio_read_control()
1770 rbuf = bus->rxbuf; in brcmf_sdio_read_control()
1771 pad = ((unsigned long)rbuf % bus->head_align); in brcmf_sdio_read_control()
1773 rbuf += (bus->head_align - pad); in brcmf_sdio_read_control()
1775 /* Copy the already-read portion over */ in brcmf_sdio_read_control()
1781 rdlen = len - BRCMF_FIRSTREAD; in brcmf_sdio_read_control()
1782 if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { in brcmf_sdio_read_control()
1783 pad = bus->blocksize - (rdlen % bus->blocksize); in brcmf_sdio_read_control()
1784 if ((pad <= bus->roundup) && (pad < bus->blocksize) && in brcmf_sdio_read_control()
1785 ((len + pad) < bus->sdiodev->bus_if->maxctl)) in brcmf_sdio_read_control()
1787 } else if (rdlen % bus->head_align) { in brcmf_sdio_read_control()
1788 rdlen += bus->head_align - (rdlen % bus->head_align); in brcmf_sdio_read_control()
1792 if ((rdlen + BRCMF_FIRSTREAD) > bus->sdiodev->bus_if->maxctl) { in brcmf_sdio_read_control()
1793 brcmf_err("%d-byte control read exceeds %d-byte buffer\n", in brcmf_sdio_read_control()
1794 rdlen, bus->sdiodev->bus_if->maxctl); in brcmf_sdio_read_control()
1799 if ((len - doff) > bus->sdiodev->bus_if->maxctl) { in brcmf_sdio_read_control()
1800 brcmf_err("%d-byte ctl frame (%d-byte ctl data) exceeds %d-byte limit\n", in brcmf_sdio_read_control()
1801 len, len - doff, bus->sdiodev->bus_if->maxctl); in brcmf_sdio_read_control()
1802 bus->sdcnt.rx_toolong++; in brcmf_sdio_read_control()
1808 sdret = brcmf_sdiod_recv_buf(bus->sdiodev, rbuf, rdlen); in brcmf_sdio_read_control()
1809 bus->sdcnt.f2rxdata++; in brcmf_sdio_read_control()
1815 bus->sdcnt.rxc_errors++; in brcmf_sdio_read_control()
1827 spin_lock_bh(&bus->rxctl_lock); in brcmf_sdio_read_control()
1828 if (bus->rxctl) { in brcmf_sdio_read_control()
1830 spin_unlock_bh(&bus->rxctl_lock); in brcmf_sdio_read_control()
1834 bus->rxctl = buf + doff; in brcmf_sdio_read_control()
1835 bus->rxctl_orig = buf; in brcmf_sdio_read_control()
1836 bus->rxlen = len - doff; in brcmf_sdio_read_control()
1837 spin_unlock_bh(&bus->rxctl_lock); in brcmf_sdio_read_control()
1847 if (bus->roundup && bus->blocksize && *rdlen > bus->blocksize) { in brcmf_sdio_pad()
1848 *pad = bus->blocksize - (*rdlen % bus->blocksize); in brcmf_sdio_pad()
1849 if (*pad <= bus->roundup && *pad < bus->blocksize && in brcmf_sdio_pad()
1852 } else if (*rdlen % bus->head_align) { in brcmf_sdio_pad()
1853 *rdlen += bus->head_align - (*rdlen % bus->head_align); in brcmf_sdio_pad()
1864 struct brcmf_sdio_hdrinfo *rd = &bus->cur_read, rd_new; in brcmf_sdio_readframes()
1870 bus->rxpending = true; in brcmf_sdio_readframes()
1872 for (rd->seq_num = bus->rx_seq, rxleft = maxframes; in brcmf_sdio_readframes()
1873 !bus->rxskip && rxleft && bus->sdiodev->state == BRCMF_SDIOD_DATA; in brcmf_sdio_readframes()
1874 rd->seq_num++, rxleft--) { in brcmf_sdio_readframes()
1877 if (bus->glomd || !skb_queue_empty(&bus->glom)) { in brcmf_sdio_readframes()
1880 bus->glomd, skb_peek(&bus->glom)); in brcmf_sdio_readframes()
1881 cnt = brcmf_sdio_rxglom(bus, rd->seq_num); in brcmf_sdio_readframes()
1883 rd->seq_num += cnt - 1; in brcmf_sdio_readframes()
1884 rxleft = (rxleft > cnt) ? (rxleft - cnt) : 1; in brcmf_sdio_readframes()
1888 rd->len_left = rd->len; in brcmf_sdio_readframes()
1890 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1891 if (!rd->len) { in brcmf_sdio_readframes()
1892 ret = brcmf_sdiod_recv_buf(bus->sdiodev, in brcmf_sdio_readframes()
1893 bus->rxhdr, BRCMF_FIRSTREAD); in brcmf_sdio_readframes()
1894 bus->sdcnt.f2rxhdrs++; in brcmf_sdio_readframes()
1898 bus->sdcnt.rx_hdrfail++; in brcmf_sdio_readframes()
1900 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1905 bus->rxhdr, SDPCM_HDRLEN, in brcmf_sdio_readframes()
1908 if (brcmf_sdio_hdparse(bus, bus->rxhdr, rd, in brcmf_sdio_readframes()
1910 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1911 if (!bus->rxpending) in brcmf_sdio_readframes()
1917 if (rd->channel == SDPCM_CONTROL_CHANNEL) { in brcmf_sdio_readframes()
1918 brcmf_sdio_read_control(bus, bus->rxhdr, in brcmf_sdio_readframes()
1919 rd->len, in brcmf_sdio_readframes()
1920 rd->dat_offset); in brcmf_sdio_readframes()
1922 rd->len = rd->len_nxtfrm << 4; in brcmf_sdio_readframes()
1923 rd->len_nxtfrm = 0; in brcmf_sdio_readframes()
1925 rd->channel = SDPCM_EVENT_CHANNEL; in brcmf_sdio_readframes()
1926 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1929 rd->len_left = rd->len > BRCMF_FIRSTREAD ? in brcmf_sdio_readframes()
1930 rd->len - BRCMF_FIRSTREAD : 0; in brcmf_sdio_readframes()
1934 brcmf_sdio_pad(bus, &pad, &rd->len_left); in brcmf_sdio_readframes()
1936 pkt = brcmu_pkt_buf_get_skb(rd->len_left + head_read + in brcmf_sdio_readframes()
1937 bus->head_align); in brcmf_sdio_readframes()
1942 RETRYCHAN(rd->channel)); in brcmf_sdio_readframes()
1943 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1947 pkt_align(pkt, rd->len_left, bus->head_align); in brcmf_sdio_readframes()
1949 ret = brcmf_sdiod_recv_pkt(bus->sdiodev, pkt); in brcmf_sdio_readframes()
1950 bus->sdcnt.f2rxdata++; in brcmf_sdio_readframes()
1951 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1955 rd->len, rd->channel, ret); in brcmf_sdio_readframes()
1957 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1959 RETRYCHAN(rd->channel)); in brcmf_sdio_readframes()
1960 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1966 memcpy(pkt->data, bus->rxhdr, head_read); in brcmf_sdio_readframes()
1969 memcpy(bus->rxhdr, pkt->data, SDPCM_HDRLEN); in brcmf_sdio_readframes()
1970 rd_new.seq_num = rd->seq_num; in brcmf_sdio_readframes()
1971 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1972 if (brcmf_sdio_hdparse(bus, bus->rxhdr, &rd_new, in brcmf_sdio_readframes()
1974 rd->len = 0; in brcmf_sdio_readframes()
1976 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1980 bus->sdcnt.rx_readahead_cnt++; in brcmf_sdio_readframes()
1981 if (rd->len != roundup(rd_new.len, 16)) { in brcmf_sdio_readframes()
1983 rd->len, in brcmf_sdio_readframes()
1985 rd->len = 0; in brcmf_sdio_readframes()
1987 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1991 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1992 rd->len_nxtfrm = rd_new.len_nxtfrm; in brcmf_sdio_readframes()
1993 rd->channel = rd_new.channel; in brcmf_sdio_readframes()
1994 rd->dat_offset = rd_new.dat_offset; in brcmf_sdio_readframes()
1999 bus->rxhdr, SDPCM_HDRLEN, in brcmf_sdio_readframes()
2006 rd->len = 0; in brcmf_sdio_readframes()
2007 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
2009 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
2016 pkt->data, rd->len, "Rx Data:\n"); in brcmf_sdio_readframes()
2019 if (rd->channel == SDPCM_GLOM_CHANNEL) { in brcmf_sdio_readframes()
2020 if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_HWHDR_LEN])) { in brcmf_sdio_readframes()
2022 rd->len); in brcmf_sdio_readframes()
2024 pkt->data, rd->len, in brcmf_sdio_readframes()
2026 __skb_trim(pkt, rd->len); in brcmf_sdio_readframes()
2028 bus->glomd = pkt; in brcmf_sdio_readframes()
2032 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
2034 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
2037 rd->len = rd->len_nxtfrm << 4; in brcmf_sdio_readframes()
2038 rd->len_nxtfrm = 0; in brcmf_sdio_readframes()
2040 rd->channel = SDPCM_EVENT_CHANNEL; in brcmf_sdio_readframes()
2045 __skb_trim(pkt, rd->len); in brcmf_sdio_readframes()
2046 skb_pull(pkt, rd->dat_offset); in brcmf_sdio_readframes()
2048 if (pkt->len == 0) in brcmf_sdio_readframes()
2050 else if (rd->channel == SDPCM_EVENT_CHANNEL) in brcmf_sdio_readframes()
2051 brcmf_rx_event(bus->sdiodev->dev, pkt); in brcmf_sdio_readframes()
2053 brcmf_rx_frame(bus->sdiodev->dev, pkt, in brcmf_sdio_readframes()
2057 rd->len = rd->len_nxtfrm << 4; in brcmf_sdio_readframes()
2058 rd->len_nxtfrm = 0; in brcmf_sdio_readframes()
2060 rd->channel = SDPCM_EVENT_CHANNEL; in brcmf_sdio_readframes()
2063 rxcount = maxframes - rxleft; in brcmf_sdio_readframes()
2070 if (bus->rxskip) in brcmf_sdio_readframes()
2071 rd->seq_num--; in brcmf_sdio_readframes()
2072 bus->rx_seq = rd->seq_num; in brcmf_sdio_readframes()
2080 wake_up_interruptible(&bus->ctrl_wait); in brcmf_sdio_wait_event_wakeup()
2090 dat_buf = (u8 *)(pkt->data); in brcmf_sdio_txpkt_hdalign()
2093 head_pad = ((unsigned long)dat_buf % bus->head_align); in brcmf_sdio_txpkt_hdalign()
2096 stats = &bus->sdiodev->bus_if->stats; in brcmf_sdio_txpkt_hdalign()
2097 atomic_inc(&stats->pktcowed); in brcmf_sdio_txpkt_hdalign()
2099 atomic_inc(&stats->pktcow_failed); in brcmf_sdio_txpkt_hdalign()
2100 return -ENOMEM; in brcmf_sdio_txpkt_hdalign()
2105 dat_buf = (u8 *)(pkt->data); in brcmf_sdio_txpkt_hdalign()
2107 memset(dat_buf, 0, head_pad + bus->tx_hdrlen); in brcmf_sdio_txpkt_hdalign()
2131 sdiodev = bus->sdiodev; in brcmf_sdio_txpkt_prep_sg()
2132 blksize = sdiodev->func2->cur_blksize; in brcmf_sdio_txpkt_prep_sg()
2134 WARN_ON(blksize % bus->sgentry_align); in brcmf_sdio_txpkt_prep_sg()
2139 tail_chop = pkt->len % bus->sgentry_align; in brcmf_sdio_txpkt_prep_sg()
2141 tail_pad = bus->sgentry_align - tail_chop; in brcmf_sdio_txpkt_prep_sg()
2144 tail_pad += blksize - chain_pad; in brcmf_sdio_txpkt_prep_sg()
2145 if (skb_tailroom(pkt) < tail_pad && pkt->len > blksize) { in brcmf_sdio_txpkt_prep_sg()
2147 bus->head_align); in brcmf_sdio_txpkt_prep_sg()
2149 return -ENOMEM; in brcmf_sdio_txpkt_prep_sg()
2155 memcpy(pkt_pad->data, in brcmf_sdio_txpkt_prep_sg()
2156 pkt->data + pkt->len - tail_chop, in brcmf_sdio_txpkt_prep_sg()
2158 *(u16 *)(pkt_pad->cb) = ALIGN_SKB_FLAG + tail_chop; in brcmf_sdio_txpkt_prep_sg()
2159 skb_trim(pkt, pkt->len - tail_chop); in brcmf_sdio_txpkt_prep_sg()
2163 ntail = pkt->data_len + tail_pad - in brcmf_sdio_txpkt_prep_sg()
2164 (pkt->end - pkt->tail); in brcmf_sdio_txpkt_prep_sg()
2167 return -ENOMEM; in brcmf_sdio_txpkt_prep_sg()
2169 return -ENOMEM; in brcmf_sdio_txpkt_prep_sg()
2177 * brcmf_sdio_txpkt_prep - packet preparation for transmit
2183 * - Align data buffer pointer
2184 * - Align data buffer length
2185 * - Prepare header
2198 txseq = bus->tx_seq; in brcmf_sdio_txpkt_prep()
2206 if (*(u16 *)(pkt_next->cb) & ALIGN_SKB_FLAG) in brcmf_sdio_txpkt_prep()
2215 memset(pkt_next->data + bus->tx_hdrlen, 0, head_pad); in brcmf_sdio_txpkt_prep()
2217 total_len += pkt_next->len; in brcmf_sdio_txpkt_prep()
2219 hd_info.len = pkt_next->len; in brcmf_sdio_txpkt_prep()
2221 if (bus->txglom && pktq->qlen > 1) { in brcmf_sdio_txpkt_prep()
2231 hd_info.dat_offset = head_pad + bus->tx_hdrlen; in brcmf_sdio_txpkt_prep()
2235 brcmf_sdio_hdpack(bus, pkt_next->data, &hd_info); in brcmf_sdio_txpkt_prep()
2240 brcmf_dbg_hex_dump(true, pkt_next->data, hd_info.len, in brcmf_sdio_txpkt_prep()
2243 brcmf_dbg_hex_dump(true, pkt_next->data, in brcmf_sdio_txpkt_prep()
2244 head_pad + bus->tx_hdrlen, in brcmf_sdio_txpkt_prep()
2250 if (bus->txglom) in brcmf_sdio_txpkt_prep()
2251 brcmf_sdio_update_hwhdr(__skb_peek(pktq)->data, total_len); in brcmf_sdio_txpkt_prep()
2256 * brcmf_sdio_txpkt_postp - packet post processing for transmit
2261 * - Remove head padding
2262 * - Remove tail padding
2274 dummy_flags = *(u16 *)(pkt_next->cb); in brcmf_sdio_txpkt_postp()
2278 pkt_prev = pkt_next->prev; in brcmf_sdio_txpkt_postp()
2284 hdr = pkt_next->data + bus->tx_hdrlen - SDPCM_SWHDR_LEN; in brcmf_sdio_txpkt_postp()
2289 if (bus->txglom) { in brcmf_sdio_txpkt_postp()
2290 tail_pad = le16_to_cpu(*(__le16 *)(hdr - 2)); in brcmf_sdio_txpkt_postp()
2291 skb_trim(pkt_next, pkt_next->len - tail_pad); in brcmf_sdio_txpkt_postp()
2311 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_txpkt()
2312 ret = brcmf_sdiod_send_pkt(bus->sdiodev, pktq); in brcmf_sdio_txpkt()
2313 bus->sdcnt.f2txdata++; in brcmf_sdio_txpkt()
2318 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_txpkt()
2323 bus->tx_seq = (bus->tx_seq + pktq->qlen) % SDPCM_SEQ_WRAP; in brcmf_sdio_txpkt()
2326 brcmf_proto_bcdc_txcomplete(bus->sdiodev->dev, pkt_next, in brcmf_sdio_txpkt()
2336 u32 intstat_addr = bus->sdio_core->base + SD_REG(intstatus); in brcmf_sdio_sendfromq()
2344 tx_prec_map = ~bus->flowcontrol; in brcmf_sdio_sendfromq()
2349 if (bus->txglom) in brcmf_sdio_sendfromq()
2350 pkt_num = min_t(u8, bus->tx_max - bus->tx_seq, in brcmf_sdio_sendfromq()
2351 bus->sdiodev->txglomsz); in brcmf_sdio_sendfromq()
2353 brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol)); in brcmf_sdio_sendfromq()
2355 spin_lock_bh(&bus->txq_lock); in brcmf_sdio_sendfromq()
2357 pkt = brcmu_pktq_mdeq(&bus->txq, tx_prec_map, in brcmf_sdio_sendfromq()
2363 spin_unlock_bh(&bus->txq_lock); in brcmf_sdio_sendfromq()
2372 if (!bus->intr) { in brcmf_sdio_sendfromq()
2374 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_sendfromq()
2375 intstatus = brcmf_sdiod_readl(bus->sdiodev, in brcmf_sdio_sendfromq()
2377 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_sendfromq()
2379 bus->sdcnt.f2txdata++; in brcmf_sdio_sendfromq()
2382 if (intstatus & bus->hostintmask) in brcmf_sdio_sendfromq()
2383 atomic_set(&bus->ipend, 1); in brcmf_sdio_sendfromq()
2387 /* Deflow-control stack if needed */ in brcmf_sdio_sendfromq()
2388 if ((bus->sdiodev->state == BRCMF_SDIOD_DATA) && in brcmf_sdio_sendfromq()
2389 bus->txoff && (pktq_len(&bus->txq) < TXLOW)) { in brcmf_sdio_sendfromq()
2390 bus->txoff = false; in brcmf_sdio_sendfromq()
2391 brcmf_proto_bcdc_txflowblock(bus->sdiodev->dev, false); in brcmf_sdio_sendfromq()
2408 frame -= bus->tx_hdrlen; in brcmf_sdio_tx_ctrlframe()
2409 len += bus->tx_hdrlen; in brcmf_sdio_tx_ctrlframe()
2412 doff = ((unsigned long)frame % bus->head_align); in brcmf_sdio_tx_ctrlframe()
2414 frame -= doff; in brcmf_sdio_tx_ctrlframe()
2416 memset(frame + bus->tx_hdrlen, 0, doff); in brcmf_sdio_tx_ctrlframe()
2421 if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { in brcmf_sdio_tx_ctrlframe()
2422 pad = bus->blocksize - (len % bus->blocksize); in brcmf_sdio_tx_ctrlframe()
2423 if ((pad > bus->roundup) || (pad >= bus->blocksize)) in brcmf_sdio_tx_ctrlframe()
2425 } else if (len % bus->head_align) { in brcmf_sdio_tx_ctrlframe()
2426 pad = bus->head_align - (len % bus->head_align); in brcmf_sdio_tx_ctrlframe()
2430 hd_info.len = len - pad; in brcmf_sdio_tx_ctrlframe()
2432 hd_info.dat_offset = doff + bus->tx_hdrlen; in brcmf_sdio_tx_ctrlframe()
2433 hd_info.seq_num = bus->tx_seq; in brcmf_sdio_tx_ctrlframe()
2438 if (bus->txglom) in brcmf_sdio_tx_ctrlframe()
2448 ret = brcmf_sdiod_send_buf(bus->sdiodev, frame, len); in brcmf_sdio_tx_ctrlframe()
2453 bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQ_WRAP; in brcmf_sdio_tx_ctrlframe()
2461 if (ci->chip == CY_CC_43012_CHIP_ID) in brcmf_chip_is_ulp()
2470 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_bus_stop()
2471 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_stop()
2472 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_bus_stop()
2479 if (bus->watchdog_tsk) { in brcmf_sdio_bus_stop()
2480 send_sig(SIGTERM, bus->watchdog_tsk, 1); in brcmf_sdio_bus_stop()
2481 kthread_stop(bus->watchdog_tsk); in brcmf_sdio_bus_stop()
2482 bus->watchdog_tsk = NULL; in brcmf_sdio_bus_stop()
2485 if (sdiodev->state != BRCMF_SDIOD_NOMEDIUM) { in brcmf_sdio_bus_stop()
2486 sdio_claim_host(sdiodev->func1); in brcmf_sdio_bus_stop()
2492 brcmf_sdiod_writel(sdiodev, core->base + SD_REG(hostintmask), in brcmf_sdio_bus_stop()
2495 local_hostintmask = bus->hostintmask; in brcmf_sdio_bus_stop()
2496 bus->hostintmask = 0; in brcmf_sdio_bus_stop()
2503 bpreq |= brcmf_chip_is_ulp(bus->ci) ? in brcmf_sdio_bus_stop()
2515 sdio_disable_func(sdiodev->func2); in brcmf_sdio_bus_stop()
2518 brcmf_sdiod_writel(sdiodev, core->base + SD_REG(intstatus), in brcmf_sdio_bus_stop()
2521 sdio_release_host(sdiodev->func1); in brcmf_sdio_bus_stop()
2524 brcmu_pktq_flush(&bus->txq, true, NULL, NULL); in brcmf_sdio_bus_stop()
2527 brcmu_pkt_buf_free_skb(bus->glomd); in brcmf_sdio_bus_stop()
2531 spin_lock_bh(&bus->rxctl_lock); in brcmf_sdio_bus_stop()
2532 bus->rxlen = 0; in brcmf_sdio_bus_stop()
2533 spin_unlock_bh(&bus->rxctl_lock); in brcmf_sdio_bus_stop()
2537 bus->rxskip = false; in brcmf_sdio_bus_stop()
2538 bus->tx_seq = bus->rx_seq = 0; in brcmf_sdio_bus_stop()
2546 sdiodev = bus->sdiodev; in brcmf_sdio_clrintr()
2547 if (sdiodev->oob_irq_requested) { in brcmf_sdio_clrintr()
2548 spin_lock_irqsave(&sdiodev->irq_en_lock, flags); in brcmf_sdio_clrintr()
2549 if (!sdiodev->irq_en && !atomic_read(&bus->ipend)) { in brcmf_sdio_clrintr()
2550 enable_irq(sdiodev->settings->bus.sdio.oob_irq_nr); in brcmf_sdio_clrintr()
2551 sdiodev->irq_en = true; in brcmf_sdio_clrintr()
2553 spin_unlock_irqrestore(&sdiodev->irq_en_lock, flags); in brcmf_sdio_clrintr()
2559 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_intr_rstatus()
2564 addr = core->base + SD_REG(intstatus); in brcmf_sdio_intr_rstatus()
2566 val = brcmf_sdiod_readl(bus->sdiodev, addr, &ret); in brcmf_sdio_intr_rstatus()
2567 bus->sdcnt.f1regdata++; in brcmf_sdio_intr_rstatus()
2571 val &= bus->hostintmask; in brcmf_sdio_intr_rstatus()
2572 atomic_set(&bus->fcstate, !!(val & I_HMB_FC_STATE)); in brcmf_sdio_intr_rstatus()
2576 brcmf_sdiod_writel(bus->sdiodev, addr, val, &ret); in brcmf_sdio_intr_rstatus()
2577 bus->sdcnt.f1regdata++; in brcmf_sdio_intr_rstatus()
2578 atomic_or(val, &bus->intstatus); in brcmf_sdio_intr_rstatus()
2586 struct brcmf_sdio_dev *sdiod = bus->sdiodev; in brcmf_sdio_dpc()
2588 u32 intstat_addr = bus->sdio_core->base + SD_REG(intstatus); in brcmf_sdio_dpc()
2590 uint txlimit = bus->txbound; /* Tx frames to send before resched */ in brcmf_sdio_dpc()
2596 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2599 if (!bus->sr_enabled && bus->clkstate == CLK_PENDING) { in brcmf_sdio_dpc()
2604 devctl = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_DEVICE_CTL, in brcmf_sdio_dpc()
2609 clkctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_dpc()
2616 devctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_dpc()
2619 brcmf_sdiod_writeb(bus->sdiodev, in brcmf_sdio_dpc()
2621 bus->clkstate = CLK_AVAIL; in brcmf_sdio_dpc()
2629 if (atomic_read(&bus->ipend) > 0) { in brcmf_sdio_dpc()
2630 atomic_set(&bus->ipend, 0); in brcmf_sdio_dpc()
2635 intstatus = atomic_xchg(&bus->intstatus, 0); in brcmf_sdio_dpc()
2637 /* Handle flow-control change: read new state in case our ack in brcmf_sdio_dpc()
2647 bus->sdcnt.f1regdata += 2; in brcmf_sdio_dpc()
2648 atomic_set(&bus->fcstate, in brcmf_sdio_dpc()
2650 intstatus |= (newstatus & bus->hostintmask); in brcmf_sdio_dpc()
2659 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2677 /* Would be active due to wake-wlan in gSPI */ in brcmf_sdio_dpc()
2684 if (bus->rxskip) in brcmf_sdio_dpc()
2688 if ((intstatus & I_HMB_FRAME_IND) && (bus->clkstate == CLK_AVAIL)) { in brcmf_sdio_dpc()
2689 brcmf_sdio_readframes(bus, bus->rxbound); in brcmf_sdio_dpc()
2690 if (!bus->rxpending) in brcmf_sdio_dpc()
2694 /* Keep still-pending events for next scheduling */ in brcmf_sdio_dpc()
2696 atomic_or(intstatus, &bus->intstatus); in brcmf_sdio_dpc()
2700 if (bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL) && in brcmf_sdio_dpc()
2702 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2703 if (bus->ctrl_frame_stat) { in brcmf_sdio_dpc()
2704 err = brcmf_sdio_tx_ctrlframe(bus, bus->ctrl_frame_buf, in brcmf_sdio_dpc()
2705 bus->ctrl_frame_len); in brcmf_sdio_dpc()
2706 bus->ctrl_frame_err = err; in brcmf_sdio_dpc()
2708 bus->ctrl_frame_stat = false; in brcmf_sdio_dpc()
2713 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2717 if ((bus->clkstate == CLK_AVAIL) && !atomic_read(&bus->fcstate) && in brcmf_sdio_dpc()
2718 brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol) && txlimit && in brcmf_sdio_dpc()
2720 framecnt = bus->rxpending ? min(txlimit, bus->txminmax) : in brcmf_sdio_dpc()
2725 if ((bus->sdiodev->state != BRCMF_SDIOD_DATA) || (err != 0)) { in brcmf_sdio_dpc()
2727 atomic_set(&bus->intstatus, 0); in brcmf_sdio_dpc()
2728 if (bus->ctrl_frame_stat) { in brcmf_sdio_dpc()
2729 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2730 if (bus->ctrl_frame_stat) { in brcmf_sdio_dpc()
2731 bus->ctrl_frame_err = -ENODEV; in brcmf_sdio_dpc()
2733 bus->ctrl_frame_stat = false; in brcmf_sdio_dpc()
2736 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2738 } else if (atomic_read(&bus->intstatus) || in brcmf_sdio_dpc()
2739 atomic_read(&bus->ipend) > 0 || in brcmf_sdio_dpc()
2740 (!atomic_read(&bus->fcstate) && in brcmf_sdio_dpc()
2741 brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol) && in brcmf_sdio_dpc()
2743 bus->dpc_triggered = true; in brcmf_sdio_dpc()
2750 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_bus_gettxq()
2751 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_gettxq()
2753 return &bus->txq; in brcmf_sdio_bus_gettxq()
2759 int eprec = -1; /* precedence to evict from */ in brcmf_sdio_prec_enq()
2800 int ret = -EBADE; in brcmf_sdio_bus_txdata()
2803 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_bus_txdata()
2804 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_txdata()
2806 brcmf_dbg(TRACE, "Enter: pkt: data %p len %d\n", pkt->data, pkt->len); in brcmf_sdio_bus_txdata()
2807 if (sdiodev->state != BRCMF_SDIOD_DATA) in brcmf_sdio_bus_txdata()
2808 return -EIO; in brcmf_sdio_bus_txdata()
2811 skb_push(pkt, bus->tx_hdrlen); in brcmf_sdio_bus_txdata()
2812 /* precondition: IS_ALIGNED((unsigned long)(pkt->data), 2) */ in brcmf_sdio_bus_txdata()
2819 prec = brcmf_map_prio_to_prec(bus_if->drvr->config, in brcmf_sdio_bus_txdata()
2820 (pkt->priority & PRIOMASK)); in brcmf_sdio_bus_txdata()
2822 /* Check for existing queue, current flow-control, in brcmf_sdio_bus_txdata()
2824 brcmf_dbg(TRACE, "deferring pktq len %d\n", pktq_len(&bus->txq)); in brcmf_sdio_bus_txdata()
2825 bus->sdcnt.fcqueued++; in brcmf_sdio_bus_txdata()
2828 spin_lock_bh(&bus->txq_lock); in brcmf_sdio_bus_txdata()
2830 *(u16 *)(pkt->cb) = 0; in brcmf_sdio_bus_txdata()
2831 if (!brcmf_sdio_prec_enq(&bus->txq, pkt, prec)) { in brcmf_sdio_bus_txdata()
2832 skb_pull(pkt, bus->tx_hdrlen); in brcmf_sdio_bus_txdata()
2833 brcmf_err("out of bus->txq !!!\n"); in brcmf_sdio_bus_txdata()
2834 ret = -ENOSR; in brcmf_sdio_bus_txdata()
2839 if (pktq_len(&bus->txq) >= TXHI) { in brcmf_sdio_bus_txdata()
2840 bus->txoff = true; in brcmf_sdio_bus_txdata()
2843 spin_unlock_bh(&bus->txq_lock); in brcmf_sdio_bus_txdata()
2846 if (pktq_plen(&bus->txq, prec) > qcount[prec]) in brcmf_sdio_bus_txdata()
2847 qcount[prec] = pktq_plen(&bus->txq, prec); in brcmf_sdio_bus_txdata()
2859 struct brcmf_console *c = &bus->console; in brcmf_sdio_readconsole()
2865 if (bus->console_addr == 0) in brcmf_sdio_readconsole()
2869 addr = bus->console_addr + offsetof(struct rte_console, log_le); in brcmf_sdio_readconsole()
2870 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, (u8 *)&c->log_le, in brcmf_sdio_readconsole()
2871 sizeof(c->log_le)); in brcmf_sdio_readconsole()
2876 if (c->buf == NULL) { in brcmf_sdio_readconsole()
2877 c->bufsize = le32_to_cpu(c->log_le.buf_size); in brcmf_sdio_readconsole()
2878 c->buf = kmalloc(c->bufsize, GFP_ATOMIC); in brcmf_sdio_readconsole()
2879 if (c->buf == NULL) in brcmf_sdio_readconsole()
2880 return -ENOMEM; in brcmf_sdio_readconsole()
2883 idx = le32_to_cpu(c->log_le.idx); in brcmf_sdio_readconsole()
2886 if (idx > c->bufsize) in brcmf_sdio_readconsole()
2887 return -EBADE; in brcmf_sdio_readconsole()
2891 if (idx == c->last) in brcmf_sdio_readconsole()
2895 addr = le32_to_cpu(c->log_le.buf); in brcmf_sdio_readconsole()
2896 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, c->buf, c->bufsize); in brcmf_sdio_readconsole()
2900 while (c->last != idx) { in brcmf_sdio_readconsole()
2901 for (n = 0; n < CONSOLE_LINE_MAX - 2; n++) { in brcmf_sdio_readconsole()
2902 if (c->last == idx) { in brcmf_sdio_readconsole()
2908 if (c->last >= n) in brcmf_sdio_readconsole()
2909 c->last -= n; in brcmf_sdio_readconsole()
2911 c->last = c->bufsize - n; in brcmf_sdio_readconsole()
2914 ch = c->buf[c->last]; in brcmf_sdio_readconsole()
2915 c->last = (c->last + 1) % c->bufsize; in brcmf_sdio_readconsole()
2922 if (line[n - 1] == '\r') in brcmf_sdio_readconsole()
2923 n--; in brcmf_sdio_readconsole()
2938 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_bus_txctl()
2939 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_txctl()
2943 if (sdiodev->state != BRCMF_SDIOD_DATA) in brcmf_sdio_bus_txctl()
2944 return -EIO; in brcmf_sdio_bus_txctl()
2947 bus->ctrl_frame_buf = msg; in brcmf_sdio_bus_txctl()
2948 bus->ctrl_frame_len = msglen; in brcmf_sdio_bus_txctl()
2950 bus->ctrl_frame_stat = true; in brcmf_sdio_bus_txctl()
2953 wait_event_interruptible_timeout(bus->ctrl_wait, !bus->ctrl_frame_stat, in brcmf_sdio_bus_txctl()
2956 if (bus->ctrl_frame_stat) { in brcmf_sdio_bus_txctl()
2957 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_bus_txctl()
2958 if (bus->ctrl_frame_stat) { in brcmf_sdio_bus_txctl()
2959 brcmf_dbg(SDIO, "ctrl_frame timeout\n"); in brcmf_sdio_bus_txctl()
2960 bus->ctrl_frame_stat = false; in brcmf_sdio_bus_txctl()
2961 ret = -ETIMEDOUT; in brcmf_sdio_bus_txctl()
2963 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_bus_txctl()
2967 bus->ctrl_frame_err); in brcmf_sdio_bus_txctl()
2969 ret = bus->ctrl_frame_err; in brcmf_sdio_bus_txctl()
2973 bus->sdcnt.tx_ctlerrs++; in brcmf_sdio_bus_txctl()
2975 bus->sdcnt.tx_ctlpkts++; in brcmf_sdio_bus_txctl()
2990 addr = sh->console_addr + offsetof(struct rte_console, log_le); in brcmf_sdio_dump_console()
2991 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, in brcmf_sdio_dump_console()
2997 addr = sh->console_addr + offsetof(struct rte_console, log_le.buf_size); in brcmf_sdio_dump_console()
2998 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, in brcmf_sdio_dump_console()
3004 addr = sh->console_addr + offsetof(struct rte_console, log_le.idx); in brcmf_sdio_dump_console()
3005 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, in brcmf_sdio_dump_console()
3016 return -ENOMEM; in brcmf_sdio_dump_console()
3020 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, console_ptr, (u8 *)conbuf, in brcmf_sdio_dump_console()
3026 console_size - console_index); in brcmf_sdio_dump_console()
3031 rv = seq_write(seq, conbuf, console_index - 1); in brcmf_sdio_dump_console()
3044 if ((sh->flags & SDPCM_SHARED_TRAP) == 0) { in brcmf_sdio_trap_info()
3049 error = brcmf_sdiod_ramrw(bus->sdiodev, false, sh->trap_addr, (u8 *)&tr, in brcmf_sdio_trap_info()
3064 le32_to_cpu(tr.pc), sh->trap_addr, in brcmf_sdio_trap_info()
3078 le32_to_cpu(tr.pc), sh->trap_addr, in brcmf_sdio_trap_info()
3093 if ((sh->flags & SDPCM_SHARED_ASSERT_BUILT) == 0) { in brcmf_sdio_assert_info()
3094 brcmf_dbg(INFO, "firmware not built with -assert\n"); in brcmf_sdio_assert_info()
3096 } else if ((sh->flags & SDPCM_SHARED_ASSERT) == 0) { in brcmf_sdio_assert_info()
3101 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_assert_info()
3102 if (sh->assert_file_addr != 0) { in brcmf_sdio_assert_info()
3103 error = brcmf_sdiod_ramrw(bus->sdiodev, false, in brcmf_sdio_assert_info()
3104 sh->assert_file_addr, (u8 *)file, 80); in brcmf_sdio_assert_info()
3108 if (sh->assert_exp_addr != 0) { in brcmf_sdio_assert_info()
3109 error = brcmf_sdiod_ramrw(bus->sdiodev, false, in brcmf_sdio_assert_info()
3110 sh->assert_exp_addr, (u8 *)expr, 80); in brcmf_sdio_assert_info()
3114 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_assert_info()
3117 file, sh->assert_line, expr); in brcmf_sdio_assert_info()
3132 brcmf_dbg(INFO, "firmware not built with -assert\n"); in brcmf_sdio_checkdied()
3169 struct brcmf_bus *bus_if = dev_get_drvdata(seq->private); in brcmf_sdio_forensic_read()
3170 struct brcmf_sdio *bus = bus_if->bus_priv.sdio->bus; in brcmf_sdio_forensic_read()
3177 struct brcmf_bus *bus_if = dev_get_drvdata(seq->private); in brcmf_debugfs_sdio_count_read()
3178 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_debugfs_sdio_count_read()
3179 struct brcmf_sdio_count *sdcnt = &sdiodev->bus->sdcnt; in brcmf_debugfs_sdio_count_read()
3196 sdcnt->intrcount, sdcnt->lastintrs, in brcmf_debugfs_sdio_count_read()
3197 sdcnt->pollcnt, sdcnt->regfails, in brcmf_debugfs_sdio_count_read()
3198 sdcnt->tx_sderrs, sdcnt->fcqueued, in brcmf_debugfs_sdio_count_read()
3199 sdcnt->rxrtx, sdcnt->rx_toolong, in brcmf_debugfs_sdio_count_read()
3200 sdcnt->rxc_errors, sdcnt->rx_hdrfail, in brcmf_debugfs_sdio_count_read()
3201 sdcnt->rx_badhdr, sdcnt->rx_badseq, in brcmf_debugfs_sdio_count_read()
3202 sdcnt->fc_rcvd, sdcnt->fc_xoff, in brcmf_debugfs_sdio_count_read()
3203 sdcnt->fc_xon, sdcnt->rxglomfail, in brcmf_debugfs_sdio_count_read()
3204 sdcnt->rxglomframes, sdcnt->rxglompkts, in brcmf_debugfs_sdio_count_read()
3205 sdcnt->f2rxhdrs, sdcnt->f2rxdata, in brcmf_debugfs_sdio_count_read()
3206 sdcnt->f2txdata, sdcnt->f1regdata, in brcmf_debugfs_sdio_count_read()
3207 sdcnt->tickcnt, sdcnt->tx_ctlerrs, in brcmf_debugfs_sdio_count_read()
3208 sdcnt->tx_ctlpkts, sdcnt->rx_ctlerrs, in brcmf_debugfs_sdio_count_read()
3209 sdcnt->rx_ctlpkts, sdcnt->rx_readahead_cnt); in brcmf_debugfs_sdio_count_read()
3217 struct brcmf_pub *drvr = bus_if->drvr; in brcmf_sdio_debugfs_create()
3218 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_debugfs_create()
3219 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_debugfs_create()
3225 bus->console_interval = BRCMF_CONSOLE; in brcmf_sdio_debugfs_create()
3231 &bus->console_interval); in brcmf_sdio_debugfs_create()
3252 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_bus_rxctl()
3253 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_rxctl()
3256 if (sdiodev->state != BRCMF_SDIOD_DATA) in brcmf_sdio_bus_rxctl()
3257 return -EIO; in brcmf_sdio_bus_rxctl()
3260 timeleft = brcmf_sdio_dcmd_resp_wait(bus, &bus->rxlen, &pending); in brcmf_sdio_bus_rxctl()
3262 spin_lock_bh(&bus->rxctl_lock); in brcmf_sdio_bus_rxctl()
3263 rxlen = bus->rxlen; in brcmf_sdio_bus_rxctl()
3264 memcpy(msg, bus->rxctl, min(msglen, rxlen)); in brcmf_sdio_bus_rxctl()
3265 bus->rxctl = NULL; in brcmf_sdio_bus_rxctl()
3266 buf = bus->rxctl_orig; in brcmf_sdio_bus_rxctl()
3267 bus->rxctl_orig = NULL; in brcmf_sdio_bus_rxctl()
3268 bus->rxlen = 0; in brcmf_sdio_bus_rxctl()
3269 spin_unlock_bh(&bus->rxctl_lock); in brcmf_sdio_bus_rxctl()
3276 brcmf_err("resumed on timeout\n"); in brcmf_sdio_bus_rxctl()
3280 return -ERESTARTSYS; in brcmf_sdio_bus_rxctl()
3287 bus->sdcnt.rx_ctlpkts++; in brcmf_sdio_bus_rxctl()
3289 bus->sdcnt.rx_ctlerrs++; in brcmf_sdio_bus_rxctl()
3291 return rxlen ? (int)rxlen : -ETIMEDOUT; in brcmf_sdio_bus_rxctl()
3318 ram_sz - offset; in brcmf_sdio_verifymemory()
3355 err = brcmf_sdiod_ramrw(bus->sdiodev, true, bus->ci->rambase, in brcmf_sdio_download_code_file()
3356 (u8 *)fw->data, fw->size); in brcmf_sdio_download_code_file()
3359 err, (int)fw->size, bus->ci->rambase); in brcmf_sdio_download_code_file()
3360 else if (!brcmf_sdio_verifymemory(bus->sdiodev, bus->ci->rambase, in brcmf_sdio_download_code_file()
3361 (u8 *)fw->data, fw->size)) in brcmf_sdio_download_code_file()
3362 err = -EIO; in brcmf_sdio_download_code_file()
3375 address = bus->ci->ramsize - varsz + bus->ci->rambase; in brcmf_sdio_download_nvram()
3376 err = brcmf_sdiod_ramrw(bus->sdiodev, true, address, vars, varsz); in brcmf_sdio_download_nvram()
3380 else if (!brcmf_sdio_verifymemory(bus->sdiodev, address, vars, varsz)) in brcmf_sdio_download_nvram()
3381 err = -EIO; in brcmf_sdio_download_nvram()
3393 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_download_firmware()
3396 rstvec = get_unaligned_le32(fw->data); in brcmf_sdio_download_firmware()
3415 if (!brcmf_chip_set_active(bus->ci, rstvec)) { in brcmf_sdio_download_firmware()
3422 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_download_firmware()
3428 if (bus->ci->chip == CY_CC_43012_CHIP_ID || in brcmf_sdio_aos_no_decode()
3429 bus->ci->chip == CY_CC_43752_CHIP_ID) in brcmf_sdio_aos_no_decode()
3445 if (brcmf_chip_is_ulp(bus->ci)) { in brcmf_sdio_sr_init()
3460 val = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_WAKEUPCTRL, &err); in brcmf_sdio_sr_init()
3466 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_WAKEUPCTRL, val, &err); in brcmf_sdio_sr_init()
3473 brcmf_sdiod_func0_wb(bus->sdiodev, SDIO_CCCR_BRCM_CARDCAP, in brcmf_sdio_sr_init()
3481 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, in brcmf_sdio_sr_init()
3489 bus->sr_enabled = true; in brcmf_sdio_sr_init()
3496 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_kso_init()
3503 if (core->rev < 12) in brcmf_sdio_kso_init()
3506 val = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, &err); in brcmf_sdio_kso_init()
3515 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, in brcmf_sdio_kso_init()
3530 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_bus_preinit()
3531 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_preinit()
3532 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_bus_preinit()
3538 if (WARN_ON(!bus_if->maxctl)) in brcmf_sdio_bus_preinit()
3539 return -EINVAL; in brcmf_sdio_bus_preinit()
3542 bus_if->maxctl += bus->roundup; in brcmf_sdio_bus_preinit()
3543 value = roundup((bus_if->maxctl + SDPCM_HDRLEN), ALIGNMENT); in brcmf_sdio_bus_preinit()
3544 value += bus->head_align; in brcmf_sdio_bus_preinit()
3545 bus->rxbuf = kmalloc(value, GFP_ATOMIC); in brcmf_sdio_bus_preinit()
3546 if (bus->rxbuf) in brcmf_sdio_bus_preinit()
3547 bus->rxblen = value; in brcmf_sdio_bus_preinit()
3553 if (core->rev < 12) { in brcmf_sdio_bus_preinit()
3560 value = sdiodev->settings->bus.sdio.sd_sgentry_align; in brcmf_sdio_bus_preinit()
3570 bus->tx_hdrlen = SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN; in brcmf_sdio_bus_preinit()
3571 if (sdiodev->sg_support) { in brcmf_sdio_bus_preinit()
3572 bus->txglom = false; in brcmf_sdio_bus_preinit()
3574 err = brcmf_iovar_data_set(bus->sdiodev->dev, "bus:rxglom", in brcmf_sdio_bus_preinit()
3580 bus->txglom = true; in brcmf_sdio_bus_preinit()
3581 bus->tx_hdrlen += SDPCM_HWEXT_LEN; in brcmf_sdio_bus_preinit()
3584 brcmf_bus_add_txhdrlen(bus->sdiodev->dev, bus->tx_hdrlen); in brcmf_sdio_bus_preinit()
3593 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_bus_get_ramsize()
3594 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_get_ramsize()
3596 return bus->ci->ramsize - bus->ci->srsize; in brcmf_sdio_bus_get_ramsize()
3603 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_bus_get_memdump()
3604 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_get_memdump()
3610 brcmf_dbg(INFO, "dump at 0x%08x: size=%zu\n", bus->ci->rambase, in brcmf_sdio_bus_get_memdump()
3613 address = bus->ci->rambase; in brcmf_sdio_bus_get_memdump()
3615 sdio_claim_host(sdiodev->func1); in brcmf_sdio_bus_get_memdump()
3618 mem_size - offset; in brcmf_sdio_bus_get_memdump()
3631 sdio_release_host(sdiodev->func1); in brcmf_sdio_bus_get_memdump()
3637 if (!bus->dpc_triggered) { in brcmf_sdio_trigger_dpc()
3638 bus->dpc_triggered = true; in brcmf_sdio_trigger_dpc()
3639 queue_work(bus->brcmf_wq, &bus->datawork); in brcmf_sdio_trigger_dpc()
3653 bus->sdcnt.intrcount++; in brcmf_sdio_isr()
3655 atomic_set(&bus->ipend, 1); in brcmf_sdio_isr()
3662 if (!bus->intr) in brcmf_sdio_isr()
3665 bus->dpc_triggered = true; in brcmf_sdio_isr()
3666 queue_work(bus->brcmf_wq, &bus->datawork); in brcmf_sdio_isr()
3674 if (!bus->sr_enabled && in brcmf_sdio_bus_watchdog()
3675 bus->poll && (++bus->polltick >= bus->pollrate)) { in brcmf_sdio_bus_watchdog()
3679 bus->polltick = 0; in brcmf_sdio_bus_watchdog()
3682 if (!bus->intr || in brcmf_sdio_bus_watchdog()
3683 (bus->sdcnt.intrcount == bus->sdcnt.lastintrs)) { in brcmf_sdio_bus_watchdog()
3685 if (!bus->dpc_triggered) { in brcmf_sdio_bus_watchdog()
3688 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3689 devpend = brcmf_sdiod_func0_rb(bus->sdiodev, in brcmf_sdio_bus_watchdog()
3691 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3699 bus->sdcnt.pollcnt++; in brcmf_sdio_bus_watchdog()
3700 atomic_set(&bus->ipend, 1); in brcmf_sdio_bus_watchdog()
3702 bus->dpc_triggered = true; in brcmf_sdio_bus_watchdog()
3703 queue_work(bus->brcmf_wq, &bus->datawork); in brcmf_sdio_bus_watchdog()
3708 bus->sdcnt.lastintrs = bus->sdcnt.intrcount; in brcmf_sdio_bus_watchdog()
3712 if (bus->sdiodev->state == BRCMF_SDIOD_DATA && BRCMF_FWCON_ON() && in brcmf_sdio_bus_watchdog()
3713 bus->console_interval != 0) { in brcmf_sdio_bus_watchdog()
3714 bus->console.count += jiffies_to_msecs(BRCMF_WD_POLL); in brcmf_sdio_bus_watchdog()
3715 if (bus->console.count >= bus->console_interval) { in brcmf_sdio_bus_watchdog()
3716 bus->console.count -= bus->console_interval; in brcmf_sdio_bus_watchdog()
3717 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3722 bus->console_interval = 0; in brcmf_sdio_bus_watchdog()
3723 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3728 /* On idle timeout clear activity flag and/or turn off clock */ in brcmf_sdio_bus_watchdog()
3729 if (!bus->dpc_triggered) { in brcmf_sdio_bus_watchdog()
3731 if ((!bus->dpc_running) && (bus->idletime > 0) && in brcmf_sdio_bus_watchdog()
3732 (bus->clkstate == CLK_AVAIL)) { in brcmf_sdio_bus_watchdog()
3733 bus->idlecount++; in brcmf_sdio_bus_watchdog()
3734 if (bus->idlecount > bus->idletime) { in brcmf_sdio_bus_watchdog()
3736 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3739 bus->console_interval == 0) in brcmf_sdio_bus_watchdog()
3742 bus->idlecount = 0; in brcmf_sdio_bus_watchdog()
3744 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3747 bus->idlecount = 0; in brcmf_sdio_bus_watchdog()
3750 bus->idlecount = 0; in brcmf_sdio_bus_watchdog()
3759 bus->dpc_running = true; in brcmf_sdio_dataworker()
3761 while (READ_ONCE(bus->dpc_triggered)) { in brcmf_sdio_dataworker()
3762 bus->dpc_triggered = false; in brcmf_sdio_dataworker()
3764 bus->idlecount = 0; in brcmf_sdio_dataworker()
3766 bus->dpc_running = false; in brcmf_sdio_dataworker()
3767 if (brcmf_sdiod_freezing(bus->sdiodev)) { in brcmf_sdio_dataworker()
3768 brcmf_sdiod_change_state(bus->sdiodev, BRCMF_SDIOD_DOWN); in brcmf_sdio_dataworker()
3769 brcmf_sdiod_try_freeze(bus->sdiodev); in brcmf_sdio_dataworker()
3770 brcmf_sdiod_change_state(bus->sdiodev, BRCMF_SDIOD_DATA); in brcmf_sdio_dataworker()
3786 if (!(ci->cc_caps & CC_CAP_PMU)) in brcmf_sdio_drivestrengthinit()
3789 switch (SDIOD_DRVSTR_KEY(ci->chip, ci->pmurev)) { in brcmf_sdio_drivestrengthinit()
3802 i = ARRAY_SIZE(sdiod_drvstr_tab2_3v3) - 1; in brcmf_sdio_drivestrengthinit()
3809 ci->name, drivestrength); in brcmf_sdio_drivestrengthinit()
3818 ci->name, ci->chiprev, ci->pmurev); in brcmf_sdio_drivestrengthinit()
3831 addr = CORE_CC_REG(pmu->base, chipcontrol_addr); in brcmf_sdio_drivestrengthinit()
3865 return -EACCES; in brcmf_sdio_buscoreprep()
3874 brcmf_err("timeout on ALPAV wait, clkval 0x%02x\n", in brcmf_sdio_buscoreprep()
3876 return -EBUSY; in brcmf_sdio_buscoreprep()
3883 /* Also, disable the extra SDIO pull-ups */ in brcmf_sdio_buscoreprep()
3893 struct brcmf_core *core = sdiodev->bus->sdio_core; in brcmf_sdio_buscore_activate()
3897 reg_addr = core->base + SD_REG(intstatus); in brcmf_sdio_buscore_activate()
3915 * register. The 4339 is a next-gen of the 4335. It uses the same in brcmf_sdio_buscore_read32()
3921 (sdiodev->func1->device == SDIO_DEVICE_ID_BROADCOM_4339 || in brcmf_sdio_buscore_read32()
3922 sdiodev->func1->device == SDIO_DEVICE_ID_BROADCOM_4335_4339)) { in brcmf_sdio_buscore_read32()
3958 sdiodev = bus->sdiodev; in brcmf_sdio_probe_attach()
3959 sdio_claim_host(sdiodev->func1); in brcmf_sdio_probe_attach()
3961 enum_base = brcmf_chip_enum_base(sdiodev->func1->device); in brcmf_sdio_probe_attach()
3983 bus->ci = brcmf_chip_attach(sdiodev, sdiodev->func1->device, in brcmf_sdio_probe_attach()
3985 if (IS_ERR(bus->ci)) { in brcmf_sdio_probe_attach()
3987 bus->ci = NULL; in brcmf_sdio_probe_attach()
3992 bus->sdio_core = brcmf_chip_get_core(bus->ci, BCMA_CORE_SDIO_DEV); in brcmf_sdio_probe_attach()
3993 if (!bus->sdio_core) in brcmf_sdio_probe_attach()
3997 sdiodev->cc_core = brcmf_chip_get_core(bus->ci, BCMA_CORE_CHIPCOMMON); in brcmf_sdio_probe_attach()
3998 if (!sdiodev->cc_core) in brcmf_sdio_probe_attach()
4001 sdiodev->settings = brcmf_get_module_param(sdiodev->dev, in brcmf_sdio_probe_attach()
4003 bus->ci->chip, in brcmf_sdio_probe_attach()
4004 bus->ci->chiprev); in brcmf_sdio_probe_attach()
4005 if (!sdiodev->settings) { in brcmf_sdio_probe_attach()
4012 bus->head_align = ALIGNMENT; in brcmf_sdio_probe_attach()
4013 bus->sgentry_align = ALIGNMENT; in brcmf_sdio_probe_attach()
4014 if (sdiodev->settings->bus.sdio.sd_head_align > ALIGNMENT) in brcmf_sdio_probe_attach()
4015 bus->head_align = sdiodev->settings->bus.sdio.sd_head_align; in brcmf_sdio_probe_attach()
4016 if (sdiodev->settings->bus.sdio.sd_sgentry_align > ALIGNMENT) in brcmf_sdio_probe_attach()
4017 bus->sgentry_align = in brcmf_sdio_probe_attach()
4018 sdiodev->settings->bus.sdio.sd_sgentry_align; in brcmf_sdio_probe_attach()
4020 /* allocate scatter-gather table. sg support in brcmf_sdio_probe_attach()
4029 (sdio_get_host_pm_caps(sdiodev->func1) & MMC_PM_KEEP_POWER) && in brcmf_sdio_probe_attach()
4030 ((sdio_get_host_pm_caps(sdiodev->func1) & MMC_PM_WAKE_SDIO_IRQ) || in brcmf_sdio_probe_attach()
4031 (sdiodev->settings->bus.sdio.oob_irq_supported))) in brcmf_sdio_probe_attach()
4032 sdiodev->bus_if->wowl_supported = true; in brcmf_sdio_probe_attach()
4039 if (sdiodev->settings->bus.sdio.drive_strength) in brcmf_sdio_probe_attach()
4040 drivestrength = sdiodev->settings->bus.sdio.drive_strength; in brcmf_sdio_probe_attach()
4043 brcmf_sdio_drivestrengthinit(sdiodev, bus->ci, drivestrength); in brcmf_sdio_probe_attach()
4057 reg_addr = CORE_CC_REG(brcmf_chip_get_pmu(bus->ci)->base, pmucontrol); in brcmf_sdio_probe_attach()
4068 sdio_release_host(sdiodev->func1); in brcmf_sdio_probe_attach()
4070 brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); in brcmf_sdio_probe_attach()
4073 bus->hdrbuf = kzalloc(MAX_HDR_READ + bus->head_align, GFP_KERNEL); in brcmf_sdio_probe_attach()
4074 if (!bus->hdrbuf) in brcmf_sdio_probe_attach()
4076 /* Locate an appropriately-aligned portion of hdrbuf */ in brcmf_sdio_probe_attach()
4077 bus->rxhdr = (u8 *) roundup((unsigned long)&bus->hdrbuf[0], in brcmf_sdio_probe_attach()
4078 bus->head_align); in brcmf_sdio_probe_attach()
4081 bus->intr = true; in brcmf_sdio_probe_attach()
4082 bus->poll = false; in brcmf_sdio_probe_attach()
4083 if (bus->poll) in brcmf_sdio_probe_attach()
4084 bus->pollrate = 1; in brcmf_sdio_probe_attach()
4089 sdio_release_host(sdiodev->func1); in brcmf_sdio_probe_attach()
4101 brcmf_sdiod_freezer_count(bus->sdiodev); in brcmf_sdio_watchdog_thread()
4105 brcmf_sdiod_freezer_uncount(bus->sdiodev); in brcmf_sdio_watchdog_thread()
4106 wait = wait_for_completion_interruptible(&bus->watchdog_wait); in brcmf_sdio_watchdog_thread()
4107 brcmf_sdiod_freezer_count(bus->sdiodev); in brcmf_sdio_watchdog_thread()
4108 brcmf_sdiod_try_freeze(bus->sdiodev); in brcmf_sdio_watchdog_thread()
4112 bus->sdcnt.tickcnt++; in brcmf_sdio_watchdog_thread()
4113 reinit_completion(&bus->watchdog_wait); in brcmf_sdio_watchdog_thread()
4125 if (bus->watchdog_tsk) { in brcmf_sdio_watchdog()
4126 complete(&bus->watchdog_wait); in brcmf_sdio_watchdog()
4128 if (bus->wd_active) in brcmf_sdio_watchdog()
4129 mod_timer(&bus->timer, in brcmf_sdio_watchdog()
4138 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_get_blob()
4142 *fw = sdiodev->clm_fw; in brcmf_sdio_get_blob()
4143 sdiodev->clm_fw = NULL; in brcmf_sdio_get_blob()
4146 return -ENOENT; in brcmf_sdio_get_blob()
4150 return -ENOENT; in brcmf_sdio_get_blob()
4158 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; in brcmf_sdio_bus_reset()
4168 sdio_claim_host(sdiodev->func1); in brcmf_sdio_bus_reset()
4169 mmc_hw_reset(sdiodev->func1->card); in brcmf_sdio_bus_reset()
4170 sdio_release_host(sdiodev->func1); in brcmf_sdio_bus_reset()
4172 brcmf_bus_change_state(sdiodev->bus_if, BRCMF_BUS_DOWN); in brcmf_sdio_bus_reset()
4199 struct brcmf_sdio_dev *sdiod = bus_if->bus_priv.sdio; in brcmf_sdio_firmware_callback()
4200 struct brcmf_sdio *bus = sdiod->bus; in brcmf_sdio_firmware_callback()
4201 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_firmware_callback()
4213 code = fwreq->items[BRCMF_SDIO_FW_CODE].binary; in brcmf_sdio_firmware_callback()
4214 nvram = fwreq->items[BRCMF_SDIO_FW_NVRAM].nv_data.data; in brcmf_sdio_firmware_callback()
4215 nvram_len = fwreq->items[BRCMF_SDIO_FW_NVRAM].nv_data.len; in brcmf_sdio_firmware_callback()
4216 sdiod->clm_fw = fwreq->items[BRCMF_SDIO_FW_CLM].binary; in brcmf_sdio_firmware_callback()
4220 bus->alp_only = true; in brcmf_sdio_firmware_callback()
4224 bus->alp_only = false; in brcmf_sdio_firmware_callback()
4227 bus->sdcnt.tickcnt = 0; in brcmf_sdio_firmware_callback()
4230 sdio_claim_host(sdiod->func1); in brcmf_sdio_firmware_callback()
4234 if (bus->clkstate != CLK_AVAIL) in brcmf_sdio_firmware_callback()
4241 bpreq |= brcmf_chip_is_ulp(bus->ci) ? in brcmf_sdio_firmware_callback()
4252 brcmf_sdiod_writel(sdiod, core->base + SD_REG(tosbmailboxdata), in brcmf_sdio_firmware_callback()
4255 err = sdio_enable_func(sdiod->func2); in brcmf_sdio_firmware_callback()
4262 bus->hostintmask = HOSTINTMASK; in brcmf_sdio_firmware_callback()
4263 brcmf_sdiod_writel(sdiod, core->base + SD_REG(hostintmask), in brcmf_sdio_firmware_callback()
4264 bus->hostintmask, NULL); in brcmf_sdio_firmware_callback()
4266 switch (sdiod->func1->device) { in brcmf_sdio_firmware_callback()
4343 sdio_disable_func(sdiod->func2); in brcmf_sdio_firmware_callback()
4347 if (brcmf_chip_sr_capable(bus->ci)) { in brcmf_sdio_firmware_callback()
4357 sdiod->bus_if->dev = sdiod->dev; in brcmf_sdio_firmware_callback()
4358 sdiod->bus_if->ops = &brcmf_sdio_bus_ops; in brcmf_sdio_firmware_callback()
4359 sdiod->bus_if->chip = bus->ci->chip; in brcmf_sdio_firmware_callback()
4360 sdiod->bus_if->chiprev = bus->ci->chiprev; in brcmf_sdio_firmware_callback()
4363 brcmf_sdiod_change_state(bus->sdiodev, BRCMF_SDIOD_DATA); in brcmf_sdio_firmware_callback()
4376 sdio_release_host(sdiod->func1); in brcmf_sdio_firmware_callback()
4378 err = brcmf_alloc(sdiod->dev, sdiod->settings); in brcmf_sdio_firmware_callback()
4385 err = brcmf_attach(sdiod->dev); in brcmf_sdio_firmware_callback()
4395 brcmf_free(sdiod->dev); in brcmf_sdio_firmware_callback()
4397 sdio_claim_host(sdiod->func1); in brcmf_sdio_firmware_callback()
4401 sdio_release_host(sdiod->func1); in brcmf_sdio_firmware_callback()
4404 device_release_driver(&sdiod->func2->dev); in brcmf_sdio_firmware_callback()
4413 { ".bin", bus->sdiodev->fw_name }, in brcmf_sdio_prepare_fw_request()
4414 { ".txt", bus->sdiodev->nvram_name }, in brcmf_sdio_prepare_fw_request()
4415 { ".clm_blob", bus->sdiodev->clm_name }, in brcmf_sdio_prepare_fw_request()
4418 fwreq = brcmf_fw_alloc_request(bus->ci->chip, bus->ci->chiprev, in brcmf_sdio_prepare_fw_request()
4425 fwreq->items[BRCMF_SDIO_FW_CODE].type = BRCMF_FW_TYPE_BINARY; in brcmf_sdio_prepare_fw_request()
4426 fwreq->items[BRCMF_SDIO_FW_NVRAM].type = BRCMF_FW_TYPE_NVRAM; in brcmf_sdio_prepare_fw_request()
4427 fwreq->items[BRCMF_SDIO_FW_CLM].type = BRCMF_FW_TYPE_BINARY; in brcmf_sdio_prepare_fw_request()
4428 fwreq->items[BRCMF_SDIO_FW_CLM].flags = BRCMF_FW_REQF_OPTIONAL; in brcmf_sdio_prepare_fw_request()
4429 fwreq->board_types[0] = bus->sdiodev->settings->board_type; in brcmf_sdio_prepare_fw_request()
4448 bus->sdiodev = sdiodev; in brcmf_sdio_probe()
4449 sdiodev->bus = bus; in brcmf_sdio_probe()
4450 skb_queue_head_init(&bus->glom); in brcmf_sdio_probe()
4451 bus->txbound = BRCMF_TXBOUND; in brcmf_sdio_probe()
4452 bus->rxbound = BRCMF_RXBOUND; in brcmf_sdio_probe()
4453 bus->txminmax = BRCMF_TXMINMAX; in brcmf_sdio_probe()
4454 bus->tx_seq = SDPCM_SEQ_WRAP - 1; in brcmf_sdio_probe()
4456 /* single-threaded workqueue */ in brcmf_sdio_probe()
4458 dev_name(&sdiodev->func1->dev)); in brcmf_sdio_probe()
4464 INIT_WORK(&bus->datawork, brcmf_sdio_dataworker); in brcmf_sdio_probe()
4465 bus->brcmf_wq = wq; in brcmf_sdio_probe()
4473 spin_lock_init(&bus->rxctl_lock); in brcmf_sdio_probe()
4474 spin_lock_init(&bus->txq_lock); in brcmf_sdio_probe()
4475 init_waitqueue_head(&bus->ctrl_wait); in brcmf_sdio_probe()
4476 init_waitqueue_head(&bus->dcmd_resp_wait); in brcmf_sdio_probe()
4479 timer_setup(&bus->timer, brcmf_sdio_watchdog, 0); in brcmf_sdio_probe()
4481 init_completion(&bus->watchdog_wait); in brcmf_sdio_probe()
4482 bus->watchdog_tsk = kthread_run(brcmf_sdio_watchdog_thread, in brcmf_sdio_probe()
4484 dev_name(&sdiodev->func1->dev)); in brcmf_sdio_probe()
4485 if (IS_ERR(bus->watchdog_tsk)) { in brcmf_sdio_probe()
4487 bus->watchdog_tsk = NULL; in brcmf_sdio_probe()
4490 bus->dpc_triggered = false; in brcmf_sdio_probe()
4491 bus->dpc_running = false; in brcmf_sdio_probe()
4494 bus->tx_hdrlen = SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN; in brcmf_sdio_probe()
4497 bus->blocksize = bus->sdiodev->func2->cur_blksize; in brcmf_sdio_probe()
4498 bus->roundup = min(max_roundup, bus->blocksize); in brcmf_sdio_probe()
4500 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_probe()
4503 sdio_disable_func(bus->sdiodev->func2); in brcmf_sdio_probe()
4505 bus->rxflow = false; in brcmf_sdio_probe()
4507 /* Done with backplane-dependent accesses, can drop clock... */ in brcmf_sdio_probe()
4508 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); in brcmf_sdio_probe()
4510 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_probe()
4513 bus->clkstate = CLK_SDONLY; in brcmf_sdio_probe()
4514 bus->idletime = BRCMF_IDLE_INTERVAL; in brcmf_sdio_probe()
4515 bus->idleclock = BRCMF_IDLE_ACTIVE; in brcmf_sdio_probe()
4518 bus->sr_enabled = false; in brcmf_sdio_probe()
4524 ret = -ENOMEM; in brcmf_sdio_probe()
4528 ret = brcmf_fw_get_firmwares(sdiodev->dev, fwreq, in brcmf_sdio_probe()
4550 if (bus->watchdog_tsk) { in brcmf_sdio_remove()
4551 send_sig(SIGTERM, bus->watchdog_tsk, 1); in brcmf_sdio_remove()
4552 kthread_stop(bus->watchdog_tsk); in brcmf_sdio_remove()
4553 bus->watchdog_tsk = NULL; in brcmf_sdio_remove()
4556 /* De-register interrupt handler */ in brcmf_sdio_remove()
4557 brcmf_sdiod_intr_unregister(bus->sdiodev); in brcmf_sdio_remove()
4559 brcmf_detach(bus->sdiodev->dev); in brcmf_sdio_remove()
4560 brcmf_free(bus->sdiodev->dev); in brcmf_sdio_remove()
4562 cancel_work_sync(&bus->datawork); in brcmf_sdio_remove()
4563 if (bus->brcmf_wq) in brcmf_sdio_remove()
4564 destroy_workqueue(bus->brcmf_wq); in brcmf_sdio_remove()
4566 if (bus->ci) { in brcmf_sdio_remove()
4567 if (bus->sdiodev->state != BRCMF_SDIOD_NOMEDIUM) { in brcmf_sdio_remove()
4568 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_remove()
4576 brcmf_chip_set_passive(bus->ci); in brcmf_sdio_remove()
4578 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_remove()
4580 brcmf_chip_detach(bus->ci); in brcmf_sdio_remove()
4582 if (bus->sdiodev->settings) in brcmf_sdio_remove()
4583 brcmf_release_module_param(bus->sdiodev->settings); in brcmf_sdio_remove()
4585 release_firmware(bus->sdiodev->clm_fw); in brcmf_sdio_remove()
4586 bus->sdiodev->clm_fw = NULL; in brcmf_sdio_remove()
4587 kfree(bus->rxbuf); in brcmf_sdio_remove()
4588 kfree(bus->hdrbuf); in brcmf_sdio_remove()
4598 if (!active && bus->wd_active) { in brcmf_sdio_wd_timer()
4599 del_timer_sync(&bus->timer); in brcmf_sdio_wd_timer()
4600 bus->wd_active = false; in brcmf_sdio_wd_timer()
4605 if (bus->sdiodev->state != BRCMF_SDIOD_DATA) in brcmf_sdio_wd_timer()
4609 if (!bus->wd_active) { in brcmf_sdio_wd_timer()
4613 bus->timer.expires = jiffies + BRCMF_WD_POLL; in brcmf_sdio_wd_timer()
4614 add_timer(&bus->timer); in brcmf_sdio_wd_timer()
4615 bus->wd_active = true; in brcmf_sdio_wd_timer()
4618 mod_timer(&bus->timer, jiffies + BRCMF_WD_POLL); in brcmf_sdio_wd_timer()
4627 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_sleep()
4629 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_sleep()