Lines Matching refs:bus
654 static bool data_ok(struct brcmf_sdio *bus) in data_ok() argument
656 return (u8)(bus->tx_max - bus->tx_seq) != 0 && in data_ok()
657 ((u8)(bus->tx_max - bus->tx_seq) & 0x80) == 0; in data_ok()
661 brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on) in brcmf_sdio_kso_control() argument
672 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, wr_val, &err); in brcmf_sdio_kso_control()
698 rd_val = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, in brcmf_sdio_kso_control()
710 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, wr_val, in brcmf_sdio_kso_control()
728 static int brcmf_sdio_htclk(struct brcmf_sdio *bus, bool on, bool pendok) in brcmf_sdio_htclk() argument
738 if (bus->sr_enabled) { in brcmf_sdio_htclk()
739 bus->clkstate = (on ? CLK_AVAIL : CLK_SDONLY); in brcmf_sdio_htclk()
746 bus->alp_only ? SBSDIO_ALP_AVAIL_REQ : SBSDIO_HT_AVAIL_REQ; in brcmf_sdio_htclk()
748 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, in brcmf_sdio_htclk()
756 clkctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_htclk()
764 if (!SBSDIO_CLKAV(clkctl, bus->alp_only) && pendok) { in brcmf_sdio_htclk()
766 devctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_htclk()
774 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_DEVICE_CTL, in brcmf_sdio_htclk()
777 bus->clkstate = CLK_PENDING; in brcmf_sdio_htclk()
780 } else if (bus->clkstate == CLK_PENDING) { in brcmf_sdio_htclk()
782 devctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_htclk()
785 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_DEVICE_CTL, in brcmf_sdio_htclk()
792 while (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { in brcmf_sdio_htclk()
793 clkctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_htclk()
805 if (!SBSDIO_CLKAV(clkctl, bus->alp_only)) { in brcmf_sdio_htclk()
812 bus->clkstate = CLK_AVAIL; in brcmf_sdio_htclk()
816 if (!bus->alp_only) { in brcmf_sdio_htclk()
825 if (bus->clkstate == CLK_PENDING) { in brcmf_sdio_htclk()
827 devctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_htclk()
830 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_DEVICE_CTL, in brcmf_sdio_htclk()
834 bus->clkstate = CLK_SDONLY; in brcmf_sdio_htclk()
835 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, in brcmf_sdio_htclk()
848 static int brcmf_sdio_sdclk(struct brcmf_sdio *bus, bool on) in brcmf_sdio_sdclk() argument
853 bus->clkstate = CLK_SDONLY; in brcmf_sdio_sdclk()
855 bus->clkstate = CLK_NONE; in brcmf_sdio_sdclk()
861 static int brcmf_sdio_clkctl(struct brcmf_sdio *bus, uint target, bool pendok) in brcmf_sdio_clkctl() argument
864 uint oldstate = bus->clkstate; in brcmf_sdio_clkctl()
870 if (bus->clkstate == target) in brcmf_sdio_clkctl()
876 if (bus->clkstate == CLK_NONE) in brcmf_sdio_clkctl()
877 brcmf_sdio_sdclk(bus, true); in brcmf_sdio_clkctl()
879 brcmf_sdio_htclk(bus, true, pendok); in brcmf_sdio_clkctl()
884 if (bus->clkstate == CLK_NONE) in brcmf_sdio_clkctl()
885 brcmf_sdio_sdclk(bus, true); in brcmf_sdio_clkctl()
886 else if (bus->clkstate == CLK_AVAIL) in brcmf_sdio_clkctl()
887 brcmf_sdio_htclk(bus, false, false); in brcmf_sdio_clkctl()
890 bus->clkstate, target); in brcmf_sdio_clkctl()
895 if (bus->clkstate == CLK_AVAIL) in brcmf_sdio_clkctl()
896 brcmf_sdio_htclk(bus, false, false); in brcmf_sdio_clkctl()
898 brcmf_sdio_sdclk(bus, false); in brcmf_sdio_clkctl()
902 brcmf_dbg(SDIO, "%d -> %d\n", oldstate, bus->clkstate); in brcmf_sdio_clkctl()
909 brcmf_sdio_bus_sleep(struct brcmf_sdio *bus, bool sleep, bool pendok) in brcmf_sdio_bus_sleep() argument
916 (bus->sleeping ? "SLEEP" : "WAKE")); in brcmf_sdio_bus_sleep()
919 if (bus->sr_enabled) { in brcmf_sdio_bus_sleep()
921 if (sleep == bus->sleeping) in brcmf_sdio_bus_sleep()
926 clkcsr = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_bus_sleep()
931 brcmf_sdiod_writeb(bus->sdiodev, in brcmf_sdio_bus_sleep()
935 err = brcmf_sdio_kso_control(bus, false); in brcmf_sdio_bus_sleep()
937 err = brcmf_sdio_kso_control(bus, true); in brcmf_sdio_bus_sleep()
949 if (!bus->sr_enabled) in brcmf_sdio_bus_sleep()
950 brcmf_sdio_clkctl(bus, CLK_NONE, pendok); in brcmf_sdio_bus_sleep()
952 brcmf_sdio_clkctl(bus, CLK_AVAIL, pendok); in brcmf_sdio_bus_sleep()
953 brcmf_sdio_wd_timer(bus, true); in brcmf_sdio_bus_sleep()
955 bus->sleeping = sleep; in brcmf_sdio_bus_sleep()
970 static int brcmf_sdio_readshared(struct brcmf_sdio *bus, in brcmf_sdio_readshared() argument
979 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readshared()
980 brcmf_sdio_bus_sleep(bus, false, false); in brcmf_sdio_readshared()
986 shaddr = bus->ci->rambase + bus->ci->ramsize - 4; in brcmf_sdio_readshared()
987 if (!bus->ci->rambase && brcmf_chip_sr_capable(bus->ci)) in brcmf_sdio_readshared()
988 shaddr -= bus->ci->srsize; in brcmf_sdio_readshared()
989 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, shaddr, in brcmf_sdio_readshared()
1008 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, (u8 *)&sh_le, in brcmf_sdio_readshared()
1013 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readshared()
1035 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readshared()
1039 static void brcmf_sdio_get_console_addr(struct brcmf_sdio *bus) in brcmf_sdio_get_console_addr() argument
1043 if (brcmf_sdio_readshared(bus, &sh) == 0) in brcmf_sdio_get_console_addr()
1044 bus->console_addr = sh.console_addr; in brcmf_sdio_get_console_addr()
1047 static void brcmf_sdio_get_console_addr(struct brcmf_sdio *bus) in brcmf_sdio_get_console_addr() argument
1052 static u32 brcmf_sdio_hostmail(struct brcmf_sdio *bus) in brcmf_sdio_hostmail() argument
1054 struct brcmf_sdio_dev *sdiod = bus->sdiodev; in brcmf_sdio_hostmail()
1055 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_hostmail()
1072 bus->sdcnt.f1regdata += 2; in brcmf_sdio_hostmail()
1083 bus->rx_seq); in brcmf_sdio_hostmail()
1084 if (!bus->rxskip) in brcmf_sdio_hostmail()
1087 bus->rxskip = false; in brcmf_sdio_hostmail()
1095 bus->sdpcm_ver = in brcmf_sdio_hostmail()
1098 if (bus->sdpcm_ver != SDPCM_PROT_VERSION) in brcmf_sdio_hostmail()
1101 bus->sdpcm_ver, SDPCM_PROT_VERSION); in brcmf_sdio_hostmail()
1104 bus->sdpcm_ver); in brcmf_sdio_hostmail()
1110 brcmf_sdio_get_console_addr(bus); in brcmf_sdio_hostmail()
1122 if (fcbits & ~bus->flowcontrol) in brcmf_sdio_hostmail()
1123 bus->sdcnt.fc_xoff++; in brcmf_sdio_hostmail()
1125 if (bus->flowcontrol & ~fcbits) in brcmf_sdio_hostmail()
1126 bus->sdcnt.fc_xon++; in brcmf_sdio_hostmail()
1128 bus->sdcnt.fc_rcvd++; in brcmf_sdio_hostmail()
1129 bus->flowcontrol = fcbits; in brcmf_sdio_hostmail()
1145 static void brcmf_sdio_rxfail(struct brcmf_sdio *bus, bool abort, bool rtx) in brcmf_sdio_rxfail() argument
1147 struct brcmf_sdio_dev *sdiod = bus->sdiodev; in brcmf_sdio_rxfail()
1148 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_rxfail()
1159 brcmf_sdiod_abort(bus->sdiodev, bus->sdiodev->func2); in brcmf_sdio_rxfail()
1161 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_FRAMECTRL, SFC_RF_TERM, in brcmf_sdio_rxfail()
1163 bus->sdcnt.f1regdata++; in brcmf_sdio_rxfail()
1167 hi = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_RFRAMEBCHI, in brcmf_sdio_rxfail()
1169 lo = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_RFRAMEBCLO, in brcmf_sdio_rxfail()
1171 bus->sdcnt.f1regdata += 2; in brcmf_sdio_rxfail()
1189 bus->sdcnt.rxrtx++; in brcmf_sdio_rxfail()
1193 bus->sdcnt.f1regdata++; in brcmf_sdio_rxfail()
1195 bus->rxskip = true; in brcmf_sdio_rxfail()
1199 bus->cur_read.len = 0; in brcmf_sdio_rxfail()
1202 static void brcmf_sdio_txfail(struct brcmf_sdio *bus) in brcmf_sdio_txfail() argument
1204 struct brcmf_sdio_dev *sdiodev = bus->sdiodev; in brcmf_sdio_txfail()
1209 bus->sdcnt.tx_sderrs++; in brcmf_sdio_txfail()
1213 bus->sdcnt.f1regdata++; in brcmf_sdio_txfail()
1218 bus->sdcnt.f1regdata += 2; in brcmf_sdio_txfail()
1225 static uint brcmf_sdio_glom_len(struct brcmf_sdio *bus) in brcmf_sdio_glom_len() argument
1231 skb_queue_walk(&bus->glom, p) in brcmf_sdio_glom_len()
1236 static void brcmf_sdio_free_glom(struct brcmf_sdio *bus) in brcmf_sdio_free_glom() argument
1240 skb_queue_walk_safe(&bus->glom, cur, next) { in brcmf_sdio_free_glom()
1241 skb_unlink(cur, &bus->glom); in brcmf_sdio_free_glom()
1314 static int brcmf_sdio_hdparse(struct brcmf_sdio *bus, u8 *header, in brcmf_sdio_hdparse() argument
1329 bus->rxpending = false; in brcmf_sdio_hdparse()
1334 bus->sdcnt.rx_badhdr++; in brcmf_sdio_hdparse()
1335 brcmf_sdio_rxfail(bus, false, false); in brcmf_sdio_hdparse()
1343 (roundup(len, bus->blocksize) != rd->len)) { in brcmf_sdio_hdparse()
1366 bus->sdcnt.rx_toolong++; in brcmf_sdio_hdparse()
1367 brcmf_sdio_rxfail(bus, false, false); in brcmf_sdio_hdparse()
1385 bus->sdcnt.rx_badhdr++; in brcmf_sdio_hdparse()
1386 brcmf_sdio_rxfail(bus, false, false); in brcmf_sdio_hdparse()
1392 bus->sdcnt.rx_badseq++; in brcmf_sdio_hdparse()
1407 if (bus->flowcontrol != fc) { in brcmf_sdio_hdparse()
1408 if (~bus->flowcontrol & fc) in brcmf_sdio_hdparse()
1409 bus->sdcnt.fc_xoff++; in brcmf_sdio_hdparse()
1410 if (bus->flowcontrol & ~fc) in brcmf_sdio_hdparse()
1411 bus->sdcnt.fc_xon++; in brcmf_sdio_hdparse()
1412 bus->sdcnt.fc_rcvd++; in brcmf_sdio_hdparse()
1413 bus->flowcontrol = fc; in brcmf_sdio_hdparse()
1416 if ((u8)(tx_seq_max - bus->tx_seq) > 0x40) { in brcmf_sdio_hdparse()
1418 tx_seq_max = bus->tx_seq + 2; in brcmf_sdio_hdparse()
1420 bus->tx_max = tx_seq_max; in brcmf_sdio_hdparse()
1431 static void brcmf_sdio_hdpack(struct brcmf_sdio *bus, u8 *header, in brcmf_sdio_hdpack() argument
1440 if (bus->txglom) { in brcmf_sdio_hdpack()
1455 trace_brcmf_sdpcm_hdr(SDPCM_TX + !!(bus->txglom), header); in brcmf_sdio_hdpack()
1458 static u8 brcmf_sdio_rxglom(struct brcmf_sdio *bus, u8 rxseq) in brcmf_sdio_rxglom() argument
1474 bus->glomd, skb_peek(&bus->glom)); in brcmf_sdio_rxglom()
1477 if (bus->glomd) { in brcmf_sdio_rxglom()
1479 dlen = (u16) (bus->glomd->len); in brcmf_sdio_rxglom()
1480 dptr = bus->glomd->data; in brcmf_sdio_rxglom()
1499 if (sublen % bus->sgentry_align) { in brcmf_sdio_rxglom()
1501 sublen, bus->sgentry_align); in brcmf_sdio_rxglom()
1509 (roundup(totlen, bus->blocksize) - totlen); in brcmf_sdio_rxglom()
1510 totlen = roundup(totlen, bus->blocksize); in brcmf_sdio_rxglom()
1514 pnext = brcmu_pkt_buf_get_skb(sublen + bus->sgentry_align); in brcmf_sdio_rxglom()
1520 skb_queue_tail(&bus->glom, pnext); in brcmf_sdio_rxglom()
1523 pkt_align(pnext, sublen, bus->sgentry_align); in brcmf_sdio_rxglom()
1531 if (BRCMF_GLOM_ON() && bus->cur_read.len && in brcmf_sdio_rxglom()
1532 totlen != bus->cur_read.len) { in brcmf_sdio_rxglom()
1534 bus->cur_read.len, totlen, rxseq); in brcmf_sdio_rxglom()
1538 brcmf_sdio_free_glom(bus); in brcmf_sdio_rxglom()
1543 brcmu_pkt_buf_free_skb(bus->glomd); in brcmf_sdio_rxglom()
1544 bus->glomd = NULL; in brcmf_sdio_rxglom()
1545 bus->cur_read.len = 0; in brcmf_sdio_rxglom()
1550 if (!skb_queue_empty(&bus->glom)) { in brcmf_sdio_rxglom()
1553 skb_queue_walk(&bus->glom, pnext) { in brcmf_sdio_rxglom()
1560 pfirst = skb_peek(&bus->glom); in brcmf_sdio_rxglom()
1561 dlen = (u16) brcmf_sdio_glom_len(bus); in brcmf_sdio_rxglom()
1567 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1568 errcode = brcmf_sdiod_recv_chain(bus->sdiodev, in brcmf_sdio_rxglom()
1569 &bus->glom, dlen); in brcmf_sdio_rxglom()
1570 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1571 bus->sdcnt.f2rxdata++; in brcmf_sdio_rxglom()
1578 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1579 brcmf_sdio_rxfail(bus, true, false); in brcmf_sdio_rxglom()
1580 bus->sdcnt.rxglomfail++; in brcmf_sdio_rxglom()
1581 brcmf_sdio_free_glom(bus); in brcmf_sdio_rxglom()
1582 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1592 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1593 errcode = brcmf_sdio_hdparse(bus, pfirst->data, &rd_new, in brcmf_sdio_rxglom()
1595 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1596 bus->cur_read.len = rd_new.len_nxtfrm << 4; in brcmf_sdio_rxglom()
1604 skb_queue_walk(&bus->glom, pnext) { in brcmf_sdio_rxglom()
1611 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1612 errcode = brcmf_sdio_hdparse(bus, pnext->data, &rd_new, in brcmf_sdio_rxglom()
1614 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1623 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1624 brcmf_sdio_rxfail(bus, true, false); in brcmf_sdio_rxglom()
1625 bus->sdcnt.rxglomfail++; in brcmf_sdio_rxglom()
1626 brcmf_sdio_free_glom(bus); in brcmf_sdio_rxglom()
1627 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_rxglom()
1628 bus->cur_read.len = 0; in brcmf_sdio_rxglom()
1634 skb_queue_walk_safe(&bus->glom, pfirst, pnext) { in brcmf_sdio_rxglom()
1647 skb_unlink(pfirst, &bus->glom); in brcmf_sdio_rxglom()
1656 bus->glom.qlen, pfirst, pfirst->data, in brcmf_sdio_rxglom()
1659 skb_unlink(pfirst, &bus->glom); in brcmf_sdio_rxglom()
1661 brcmf_rx_event(bus->sdiodev->dev, pfirst); in brcmf_sdio_rxglom()
1663 brcmf_rx_frame(bus->sdiodev->dev, pfirst, in brcmf_sdio_rxglom()
1665 bus->sdcnt.rxglompkts++; in brcmf_sdio_rxglom()
1668 bus->sdcnt.rxglomframes++; in brcmf_sdio_rxglom()
1673 static int brcmf_sdio_dcmd_resp_wait(struct brcmf_sdio *bus, uint *condition, in brcmf_sdio_dcmd_resp_wait() argument
1680 add_wait_queue(&bus->dcmd_resp_wait, &wait); in brcmf_sdio_dcmd_resp_wait()
1690 remove_wait_queue(&bus->dcmd_resp_wait, &wait); in brcmf_sdio_dcmd_resp_wait()
1695 static int brcmf_sdio_dcmd_resp_wake(struct brcmf_sdio *bus) in brcmf_sdio_dcmd_resp_wake() argument
1697 wake_up_interruptible(&bus->dcmd_resp_wait); in brcmf_sdio_dcmd_resp_wake()
1702 brcmf_sdio_read_control(struct brcmf_sdio *bus, u8 *hdr, uint len, uint doff) in brcmf_sdio_read_control() argument
1709 if (bus->rxblen) in brcmf_sdio_read_control()
1710 buf = vzalloc(bus->rxblen); in brcmf_sdio_read_control()
1714 rbuf = bus->rxbuf; in brcmf_sdio_read_control()
1715 pad = ((unsigned long)rbuf % bus->head_align); in brcmf_sdio_read_control()
1717 rbuf += (bus->head_align - pad); in brcmf_sdio_read_control()
1726 if (bus->roundup && bus->blocksize && (rdlen > bus->blocksize)) { in brcmf_sdio_read_control()
1727 pad = bus->blocksize - (rdlen % bus->blocksize); in brcmf_sdio_read_control()
1728 if ((pad <= bus->roundup) && (pad < bus->blocksize) && in brcmf_sdio_read_control()
1729 ((len + pad) < bus->sdiodev->bus_if->maxctl)) in brcmf_sdio_read_control()
1731 } else if (rdlen % bus->head_align) { in brcmf_sdio_read_control()
1732 rdlen += bus->head_align - (rdlen % bus->head_align); in brcmf_sdio_read_control()
1736 if ((rdlen + BRCMF_FIRSTREAD) > bus->sdiodev->bus_if->maxctl) { in brcmf_sdio_read_control()
1738 rdlen, bus->sdiodev->bus_if->maxctl); in brcmf_sdio_read_control()
1739 brcmf_sdio_rxfail(bus, false, false); in brcmf_sdio_read_control()
1743 if ((len - doff) > bus->sdiodev->bus_if->maxctl) { in brcmf_sdio_read_control()
1745 len, len - doff, bus->sdiodev->bus_if->maxctl); in brcmf_sdio_read_control()
1746 bus->sdcnt.rx_toolong++; in brcmf_sdio_read_control()
1747 brcmf_sdio_rxfail(bus, false, false); in brcmf_sdio_read_control()
1752 sdret = brcmf_sdiod_recv_buf(bus->sdiodev, rbuf, rdlen); in brcmf_sdio_read_control()
1753 bus->sdcnt.f2rxdata++; in brcmf_sdio_read_control()
1759 bus->sdcnt.rxc_errors++; in brcmf_sdio_read_control()
1760 brcmf_sdio_rxfail(bus, true, true); in brcmf_sdio_read_control()
1771 spin_lock_bh(&bus->rxctl_lock); in brcmf_sdio_read_control()
1772 if (bus->rxctl) { in brcmf_sdio_read_control()
1774 spin_unlock_bh(&bus->rxctl_lock); in brcmf_sdio_read_control()
1778 bus->rxctl = buf + doff; in brcmf_sdio_read_control()
1779 bus->rxctl_orig = buf; in brcmf_sdio_read_control()
1780 bus->rxlen = len - doff; in brcmf_sdio_read_control()
1781 spin_unlock_bh(&bus->rxctl_lock); in brcmf_sdio_read_control()
1785 brcmf_sdio_dcmd_resp_wake(bus); in brcmf_sdio_read_control()
1789 static void brcmf_sdio_pad(struct brcmf_sdio *bus, u16 *pad, u16 *rdlen) in brcmf_sdio_pad() argument
1791 if (bus->roundup && bus->blocksize && *rdlen > bus->blocksize) { in brcmf_sdio_pad()
1792 *pad = bus->blocksize - (*rdlen % bus->blocksize); in brcmf_sdio_pad()
1793 if (*pad <= bus->roundup && *pad < bus->blocksize && in brcmf_sdio_pad()
1796 } else if (*rdlen % bus->head_align) { in brcmf_sdio_pad()
1797 *rdlen += bus->head_align - (*rdlen % bus->head_align); in brcmf_sdio_pad()
1801 static uint brcmf_sdio_readframes(struct brcmf_sdio *bus, uint maxframes) in brcmf_sdio_readframes() argument
1808 struct brcmf_sdio_hdrinfo *rd = &bus->cur_read, rd_new; in brcmf_sdio_readframes()
1814 bus->rxpending = true; in brcmf_sdio_readframes()
1816 for (rd->seq_num = bus->rx_seq, rxleft = maxframes; in brcmf_sdio_readframes()
1817 !bus->rxskip && rxleft && bus->sdiodev->state == BRCMF_SDIOD_DATA; in brcmf_sdio_readframes()
1821 if (bus->glomd || !skb_queue_empty(&bus->glom)) { in brcmf_sdio_readframes()
1824 bus->glomd, skb_peek(&bus->glom)); in brcmf_sdio_readframes()
1825 cnt = brcmf_sdio_rxglom(bus, rd->seq_num); in brcmf_sdio_readframes()
1834 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1836 ret = brcmf_sdiod_recv_buf(bus->sdiodev, in brcmf_sdio_readframes()
1837 bus->rxhdr, BRCMF_FIRSTREAD); in brcmf_sdio_readframes()
1838 bus->sdcnt.f2rxhdrs++; in brcmf_sdio_readframes()
1842 bus->sdcnt.rx_hdrfail++; in brcmf_sdio_readframes()
1843 brcmf_sdio_rxfail(bus, true, true); in brcmf_sdio_readframes()
1844 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1849 bus->rxhdr, SDPCM_HDRLEN, in brcmf_sdio_readframes()
1852 if (brcmf_sdio_hdparse(bus, bus->rxhdr, rd, in brcmf_sdio_readframes()
1854 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1855 if (!bus->rxpending) in brcmf_sdio_readframes()
1862 brcmf_sdio_read_control(bus, bus->rxhdr, in brcmf_sdio_readframes()
1870 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1878 brcmf_sdio_pad(bus, &pad, &rd->len_left); in brcmf_sdio_readframes()
1881 bus->head_align); in brcmf_sdio_readframes()
1885 brcmf_sdio_rxfail(bus, false, in brcmf_sdio_readframes()
1887 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1891 pkt_align(pkt, rd->len_left, bus->head_align); in brcmf_sdio_readframes()
1893 ret = brcmf_sdiod_recv_pkt(bus->sdiodev, pkt); in brcmf_sdio_readframes()
1894 bus->sdcnt.f2rxdata++; in brcmf_sdio_readframes()
1895 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1901 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1902 brcmf_sdio_rxfail(bus, true, in brcmf_sdio_readframes()
1904 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1910 memcpy(pkt->data, bus->rxhdr, head_read); in brcmf_sdio_readframes()
1913 memcpy(bus->rxhdr, pkt->data, SDPCM_HDRLEN); in brcmf_sdio_readframes()
1915 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1916 if (brcmf_sdio_hdparse(bus, bus->rxhdr, &rd_new, in brcmf_sdio_readframes()
1921 bus->sdcnt.rx_readahead_cnt++; in brcmf_sdio_readframes()
1927 brcmf_sdio_rxfail(bus, true, true); in brcmf_sdio_readframes()
1928 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1932 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1940 bus->rxhdr, SDPCM_HDRLEN, in brcmf_sdio_readframes()
1948 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1949 brcmf_sdio_rxfail(bus, false, true); in brcmf_sdio_readframes()
1950 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1961 if (SDPCM_GLOMDESC(&bus->rxhdr[SDPCM_HWHDR_LEN])) { in brcmf_sdio_readframes()
1969 bus->glomd = pkt; in brcmf_sdio_readframes()
1973 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1974 brcmf_sdio_rxfail(bus, false, false); in brcmf_sdio_readframes()
1975 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_readframes()
1992 brcmf_rx_event(bus->sdiodev->dev, pkt); in brcmf_sdio_readframes()
1994 brcmf_rx_frame(bus->sdiodev->dev, pkt, in brcmf_sdio_readframes()
2011 if (bus->rxskip) in brcmf_sdio_readframes()
2013 bus->rx_seq = rd->seq_num; in brcmf_sdio_readframes()
2019 brcmf_sdio_wait_event_wakeup(struct brcmf_sdio *bus) in brcmf_sdio_wait_event_wakeup() argument
2021 wake_up_interruptible(&bus->ctrl_wait); in brcmf_sdio_wait_event_wakeup()
2025 static int brcmf_sdio_txpkt_hdalign(struct brcmf_sdio *bus, struct sk_buff *pkt) in brcmf_sdio_txpkt_hdalign() argument
2034 head_pad = ((unsigned long)dat_buf % bus->head_align); in brcmf_sdio_txpkt_hdalign()
2037 stats = &bus->sdiodev->bus_if->stats; in brcmf_sdio_txpkt_hdalign()
2048 memset(dat_buf, 0, head_pad + bus->tx_hdrlen); in brcmf_sdio_txpkt_hdalign()
2061 static int brcmf_sdio_txpkt_prep_sg(struct brcmf_sdio *bus, in brcmf_sdio_txpkt_prep_sg() argument
2072 sdiodev = bus->sdiodev; in brcmf_sdio_txpkt_prep_sg()
2075 WARN_ON(blksize % bus->sgentry_align); in brcmf_sdio_txpkt_prep_sg()
2080 tail_chop = pkt->len % bus->sgentry_align; in brcmf_sdio_txpkt_prep_sg()
2082 tail_pad = bus->sgentry_align - tail_chop; in brcmf_sdio_txpkt_prep_sg()
2088 bus->head_align); in brcmf_sdio_txpkt_prep_sg()
2091 ret = brcmf_sdio_txpkt_hdalign(bus, pkt_pad); in brcmf_sdio_txpkt_prep_sg()
2130 brcmf_sdio_txpkt_prep(struct brcmf_sdio *bus, struct sk_buff_head *pktq, in brcmf_sdio_txpkt_prep() argument
2139 txseq = bus->tx_seq; in brcmf_sdio_txpkt_prep()
2151 ret = brcmf_sdio_txpkt_hdalign(bus, pkt_next); in brcmf_sdio_txpkt_prep()
2156 memset(pkt_next->data + bus->tx_hdrlen, 0, head_pad); in brcmf_sdio_txpkt_prep()
2162 if (bus->txglom && pktq->qlen > 1) { in brcmf_sdio_txpkt_prep()
2163 ret = brcmf_sdio_txpkt_prep_sg(bus, pktq, in brcmf_sdio_txpkt_prep()
2172 hd_info.dat_offset = head_pad + bus->tx_hdrlen; in brcmf_sdio_txpkt_prep()
2176 brcmf_sdio_hdpack(bus, pkt_next->data, &hd_info); in brcmf_sdio_txpkt_prep()
2185 head_pad + bus->tx_hdrlen, in brcmf_sdio_txpkt_prep()
2191 if (bus->txglom) in brcmf_sdio_txpkt_prep()
2206 brcmf_sdio_txpkt_postp(struct brcmf_sdio *bus, struct sk_buff_head *pktq) in brcmf_sdio_txpkt_postp() argument
2225 hdr = pkt_next->data + bus->tx_hdrlen - SDPCM_SWHDR_LEN; in brcmf_sdio_txpkt_postp()
2230 if (bus->txglom) { in brcmf_sdio_txpkt_postp()
2240 static int brcmf_sdio_txpkt(struct brcmf_sdio *bus, struct sk_buff_head *pktq, in brcmf_sdio_txpkt() argument
2248 ret = brcmf_sdio_txpkt_prep(bus, pktq, chan); in brcmf_sdio_txpkt()
2252 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_txpkt()
2253 ret = brcmf_sdiod_send_pkt(bus->sdiodev, pktq); in brcmf_sdio_txpkt()
2254 bus->sdcnt.f2txdata++; in brcmf_sdio_txpkt()
2257 brcmf_sdio_txfail(bus); in brcmf_sdio_txpkt()
2259 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_txpkt()
2262 brcmf_sdio_txpkt_postp(bus, pktq); in brcmf_sdio_txpkt()
2264 bus->tx_seq = (bus->tx_seq + pktq->qlen) % SDPCM_SEQ_WRAP; in brcmf_sdio_txpkt()
2267 brcmf_proto_bcdc_txcomplete(bus->sdiodev->dev, pkt_next, in brcmf_sdio_txpkt()
2273 static uint brcmf_sdio_sendfromq(struct brcmf_sdio *bus, uint maxframes) in brcmf_sdio_sendfromq() argument
2277 u32 intstat_addr = bus->sdio_core->base + SD_REG(intstatus); in brcmf_sdio_sendfromq()
2285 tx_prec_map = ~bus->flowcontrol; in brcmf_sdio_sendfromq()
2288 for (cnt = 0; (cnt < maxframes) && data_ok(bus);) { in brcmf_sdio_sendfromq()
2290 if (bus->txglom) in brcmf_sdio_sendfromq()
2291 pkt_num = min_t(u8, bus->tx_max - bus->tx_seq, in brcmf_sdio_sendfromq()
2292 bus->sdiodev->txglomsz); in brcmf_sdio_sendfromq()
2294 brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol)); in brcmf_sdio_sendfromq()
2296 spin_lock_bh(&bus->txq_lock); in brcmf_sdio_sendfromq()
2298 pkt = brcmu_pktq_mdeq(&bus->txq, tx_prec_map, in brcmf_sdio_sendfromq()
2304 spin_unlock_bh(&bus->txq_lock); in brcmf_sdio_sendfromq()
2308 ret = brcmf_sdio_txpkt(bus, &pktq, SDPCM_DATA_CHANNEL); in brcmf_sdio_sendfromq()
2313 if (!bus->intr) { in brcmf_sdio_sendfromq()
2315 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_sendfromq()
2316 intstatus = brcmf_sdiod_readl(bus->sdiodev, in brcmf_sdio_sendfromq()
2318 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_sendfromq()
2320 bus->sdcnt.f2txdata++; in brcmf_sdio_sendfromq()
2323 if (intstatus & bus->hostintmask) in brcmf_sdio_sendfromq()
2324 atomic_set(&bus->ipend, 1); in brcmf_sdio_sendfromq()
2329 if ((bus->sdiodev->state == BRCMF_SDIOD_DATA) && in brcmf_sdio_sendfromq()
2330 bus->txoff && (pktq_len(&bus->txq) < TXLOW)) { in brcmf_sdio_sendfromq()
2331 bus->txoff = false; in brcmf_sdio_sendfromq()
2332 brcmf_proto_bcdc_txflowblock(bus->sdiodev->dev, false); in brcmf_sdio_sendfromq()
2338 static int brcmf_sdio_tx_ctrlframe(struct brcmf_sdio *bus, u8 *frame, u16 len) in brcmf_sdio_tx_ctrlframe() argument
2349 frame -= bus->tx_hdrlen; in brcmf_sdio_tx_ctrlframe()
2350 len += bus->tx_hdrlen; in brcmf_sdio_tx_ctrlframe()
2353 doff = ((unsigned long)frame % bus->head_align); in brcmf_sdio_tx_ctrlframe()
2357 memset(frame + bus->tx_hdrlen, 0, doff); in brcmf_sdio_tx_ctrlframe()
2362 if (bus->roundup && bus->blocksize && (len > bus->blocksize)) { in brcmf_sdio_tx_ctrlframe()
2363 pad = bus->blocksize - (len % bus->blocksize); in brcmf_sdio_tx_ctrlframe()
2364 if ((pad > bus->roundup) || (pad >= bus->blocksize)) in brcmf_sdio_tx_ctrlframe()
2366 } else if (len % bus->head_align) { in brcmf_sdio_tx_ctrlframe()
2367 pad = bus->head_align - (len % bus->head_align); in brcmf_sdio_tx_ctrlframe()
2373 hd_info.dat_offset = doff + bus->tx_hdrlen; in brcmf_sdio_tx_ctrlframe()
2374 hd_info.seq_num = bus->tx_seq; in brcmf_sdio_tx_ctrlframe()
2377 brcmf_sdio_hdpack(bus, frame, &hd_info); in brcmf_sdio_tx_ctrlframe()
2379 if (bus->txglom) in brcmf_sdio_tx_ctrlframe()
2389 ret = brcmf_sdiod_send_buf(bus->sdiodev, frame, len); in brcmf_sdio_tx_ctrlframe()
2392 brcmf_sdio_txfail(bus); in brcmf_sdio_tx_ctrlframe()
2394 bus->tx_seq = (bus->tx_seq + 1) % SDPCM_SEQ_WRAP; in brcmf_sdio_tx_ctrlframe()
2404 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_stop() local
2405 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_bus_stop()
2412 if (bus->watchdog_tsk) { in brcmf_sdio_bus_stop()
2413 send_sig(SIGTERM, bus->watchdog_tsk, 1); in brcmf_sdio_bus_stop()
2414 kthread_stop(bus->watchdog_tsk); in brcmf_sdio_bus_stop()
2415 bus->watchdog_tsk = NULL; in brcmf_sdio_bus_stop()
2422 brcmf_sdio_bus_sleep(bus, false, false); in brcmf_sdio_bus_stop()
2428 local_hostintmask = bus->hostintmask; in brcmf_sdio_bus_stop()
2429 bus->hostintmask = 0; in brcmf_sdio_bus_stop()
2452 brcmu_pktq_flush(&bus->txq, true, NULL, NULL); in brcmf_sdio_bus_stop()
2455 brcmu_pkt_buf_free_skb(bus->glomd); in brcmf_sdio_bus_stop()
2456 brcmf_sdio_free_glom(bus); in brcmf_sdio_bus_stop()
2459 spin_lock_bh(&bus->rxctl_lock); in brcmf_sdio_bus_stop()
2460 bus->rxlen = 0; in brcmf_sdio_bus_stop()
2461 spin_unlock_bh(&bus->rxctl_lock); in brcmf_sdio_bus_stop()
2462 brcmf_sdio_dcmd_resp_wake(bus); in brcmf_sdio_bus_stop()
2465 bus->rxskip = false; in brcmf_sdio_bus_stop()
2466 bus->tx_seq = bus->rx_seq = 0; in brcmf_sdio_bus_stop()
2469 static inline void brcmf_sdio_clrintr(struct brcmf_sdio *bus) in brcmf_sdio_clrintr() argument
2474 sdiodev = bus->sdiodev; in brcmf_sdio_clrintr()
2477 if (!sdiodev->irq_en && !atomic_read(&bus->ipend)) { in brcmf_sdio_clrintr()
2478 enable_irq(sdiodev->settings->bus.sdio.oob_irq_nr); in brcmf_sdio_clrintr()
2485 static int brcmf_sdio_intr_rstatus(struct brcmf_sdio *bus) in brcmf_sdio_intr_rstatus() argument
2487 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_intr_rstatus()
2494 val = brcmf_sdiod_readl(bus->sdiodev, addr, &ret); in brcmf_sdio_intr_rstatus()
2495 bus->sdcnt.f1regdata++; in brcmf_sdio_intr_rstatus()
2499 val &= bus->hostintmask; in brcmf_sdio_intr_rstatus()
2500 atomic_set(&bus->fcstate, !!(val & I_HMB_FC_STATE)); in brcmf_sdio_intr_rstatus()
2504 brcmf_sdiod_writel(bus->sdiodev, addr, val, &ret); in brcmf_sdio_intr_rstatus()
2505 bus->sdcnt.f1regdata++; in brcmf_sdio_intr_rstatus()
2506 atomic_or(val, &bus->intstatus); in brcmf_sdio_intr_rstatus()
2512 static void brcmf_sdio_dpc(struct brcmf_sdio *bus) in brcmf_sdio_dpc() argument
2514 struct brcmf_sdio_dev *sdiod = bus->sdiodev; in brcmf_sdio_dpc()
2516 u32 intstat_addr = bus->sdio_core->base + SD_REG(intstatus); in brcmf_sdio_dpc()
2518 uint txlimit = bus->txbound; /* Tx frames to send before resched */ in brcmf_sdio_dpc()
2524 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2527 if (!bus->sr_enabled && bus->clkstate == CLK_PENDING) { in brcmf_sdio_dpc()
2532 devctl = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_DEVICE_CTL, in brcmf_sdio_dpc()
2537 clkctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_dpc()
2544 devctl = brcmf_sdiod_readb(bus->sdiodev, in brcmf_sdio_dpc()
2547 brcmf_sdiod_writeb(bus->sdiodev, in brcmf_sdio_dpc()
2549 bus->clkstate = CLK_AVAIL; in brcmf_sdio_dpc()
2554 brcmf_sdio_bus_sleep(bus, false, true); in brcmf_sdio_dpc()
2557 if (atomic_read(&bus->ipend) > 0) { in brcmf_sdio_dpc()
2558 atomic_set(&bus->ipend, 0); in brcmf_sdio_dpc()
2559 err = brcmf_sdio_intr_rstatus(bus); in brcmf_sdio_dpc()
2563 intstatus = atomic_xchg(&bus->intstatus, 0); in brcmf_sdio_dpc()
2575 bus->sdcnt.f1regdata += 2; in brcmf_sdio_dpc()
2576 atomic_set(&bus->fcstate, in brcmf_sdio_dpc()
2578 intstatus |= (newstatus & bus->hostintmask); in brcmf_sdio_dpc()
2584 intstatus |= brcmf_sdio_hostmail(bus); in brcmf_sdio_dpc()
2587 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2612 if (bus->rxskip) in brcmf_sdio_dpc()
2616 if ((intstatus & I_HMB_FRAME_IND) && (bus->clkstate == CLK_AVAIL)) { in brcmf_sdio_dpc()
2617 brcmf_sdio_readframes(bus, bus->rxbound); in brcmf_sdio_dpc()
2618 if (!bus->rxpending) in brcmf_sdio_dpc()
2624 atomic_or(intstatus, &bus->intstatus); in brcmf_sdio_dpc()
2626 brcmf_sdio_clrintr(bus); in brcmf_sdio_dpc()
2628 if (bus->ctrl_frame_stat && (bus->clkstate == CLK_AVAIL) && in brcmf_sdio_dpc()
2629 data_ok(bus)) { in brcmf_sdio_dpc()
2630 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2631 if (bus->ctrl_frame_stat) { in brcmf_sdio_dpc()
2632 err = brcmf_sdio_tx_ctrlframe(bus, bus->ctrl_frame_buf, in brcmf_sdio_dpc()
2633 bus->ctrl_frame_len); in brcmf_sdio_dpc()
2634 bus->ctrl_frame_err = err; in brcmf_sdio_dpc()
2636 bus->ctrl_frame_stat = false; in brcmf_sdio_dpc()
2638 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2639 brcmf_sdio_wait_event_wakeup(bus); in brcmf_sdio_dpc()
2642 if ((bus->clkstate == CLK_AVAIL) && !atomic_read(&bus->fcstate) && in brcmf_sdio_dpc()
2643 brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol) && txlimit && in brcmf_sdio_dpc()
2644 data_ok(bus)) { in brcmf_sdio_dpc()
2645 framecnt = bus->rxpending ? min(txlimit, bus->txminmax) : in brcmf_sdio_dpc()
2647 brcmf_sdio_sendfromq(bus, framecnt); in brcmf_sdio_dpc()
2650 if ((bus->sdiodev->state != BRCMF_SDIOD_DATA) || (err != 0)) { in brcmf_sdio_dpc()
2652 atomic_set(&bus->intstatus, 0); in brcmf_sdio_dpc()
2653 if (bus->ctrl_frame_stat) { in brcmf_sdio_dpc()
2654 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2655 if (bus->ctrl_frame_stat) { in brcmf_sdio_dpc()
2656 bus->ctrl_frame_err = -ENODEV; in brcmf_sdio_dpc()
2658 bus->ctrl_frame_stat = false; in brcmf_sdio_dpc()
2659 brcmf_sdio_wait_event_wakeup(bus); in brcmf_sdio_dpc()
2661 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_dpc()
2663 } else if (atomic_read(&bus->intstatus) || in brcmf_sdio_dpc()
2664 atomic_read(&bus->ipend) > 0 || in brcmf_sdio_dpc()
2665 (!atomic_read(&bus->fcstate) && in brcmf_sdio_dpc()
2666 brcmu_pktq_mlen(&bus->txq, ~bus->flowcontrol) && in brcmf_sdio_dpc()
2667 data_ok(bus))) { in brcmf_sdio_dpc()
2668 bus->dpc_triggered = true; in brcmf_sdio_dpc()
2676 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_gettxq() local
2678 return &bus->txq; in brcmf_sdio_bus_gettxq()
2729 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_txdata() local
2736 skb_push(pkt, bus->tx_hdrlen); in brcmf_sdio_bus_txdata()
2743 brcmf_dbg(TRACE, "deferring pktq len %d\n", pktq_len(&bus->txq)); in brcmf_sdio_bus_txdata()
2744 bus->sdcnt.fcqueued++; in brcmf_sdio_bus_txdata()
2747 spin_lock_bh(&bus->txq_lock); in brcmf_sdio_bus_txdata()
2750 if (!brcmf_sdio_prec_enq(&bus->txq, pkt, prec)) { in brcmf_sdio_bus_txdata()
2751 skb_pull(pkt, bus->tx_hdrlen); in brcmf_sdio_bus_txdata()
2758 if (pktq_len(&bus->txq) >= TXHI) { in brcmf_sdio_bus_txdata()
2759 bus->txoff = true; in brcmf_sdio_bus_txdata()
2762 spin_unlock_bh(&bus->txq_lock); in brcmf_sdio_bus_txdata()
2765 if (pktq_plen(&bus->txq, prec) > qcount[prec]) in brcmf_sdio_bus_txdata()
2766 qcount[prec] = pktq_plen(&bus->txq, prec); in brcmf_sdio_bus_txdata()
2769 brcmf_sdio_trigger_dpc(bus); in brcmf_sdio_bus_txdata()
2776 static int brcmf_sdio_readconsole(struct brcmf_sdio *bus) in brcmf_sdio_readconsole() argument
2778 struct brcmf_console *c = &bus->console; in brcmf_sdio_readconsole()
2784 if (bus->console_addr == 0) in brcmf_sdio_readconsole()
2788 addr = bus->console_addr + offsetof(struct rte_console, log_le); in brcmf_sdio_readconsole()
2789 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, (u8 *)&c->log_le, in brcmf_sdio_readconsole()
2815 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, c->buf, c->bufsize); in brcmf_sdio_readconsole()
2858 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_txctl() local
2866 bus->ctrl_frame_buf = msg; in brcmf_sdio_bus_txctl()
2867 bus->ctrl_frame_len = msglen; in brcmf_sdio_bus_txctl()
2869 bus->ctrl_frame_stat = true; in brcmf_sdio_bus_txctl()
2871 brcmf_sdio_trigger_dpc(bus); in brcmf_sdio_bus_txctl()
2872 wait_event_interruptible_timeout(bus->ctrl_wait, !bus->ctrl_frame_stat, in brcmf_sdio_bus_txctl()
2875 if (bus->ctrl_frame_stat) { in brcmf_sdio_bus_txctl()
2876 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_bus_txctl()
2877 if (bus->ctrl_frame_stat) { in brcmf_sdio_bus_txctl()
2879 bus->ctrl_frame_stat = false; in brcmf_sdio_bus_txctl()
2882 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_bus_txctl()
2886 bus->ctrl_frame_err); in brcmf_sdio_bus_txctl()
2888 ret = bus->ctrl_frame_err; in brcmf_sdio_bus_txctl()
2892 bus->sdcnt.tx_ctlerrs++; in brcmf_sdio_bus_txctl()
2894 bus->sdcnt.tx_ctlpkts++; in brcmf_sdio_bus_txctl()
2900 static int brcmf_sdio_dump_console(struct seq_file *seq, struct brcmf_sdio *bus, in brcmf_sdio_dump_console() argument
2910 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, in brcmf_sdio_dump_console()
2917 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, in brcmf_sdio_dump_console()
2924 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, in brcmf_sdio_dump_console()
2939 rv = brcmf_sdiod_ramrw(bus->sdiodev, false, console_ptr, (u8 *)conbuf, in brcmf_sdio_dump_console()
2957 static int brcmf_sdio_trap_info(struct seq_file *seq, struct brcmf_sdio *bus, in brcmf_sdio_trap_info() argument
2968 error = brcmf_sdiod_ramrw(bus->sdiodev, false, sh->trap_addr, (u8 *)&tr, in brcmf_sdio_trap_info()
2991 static int brcmf_sdio_assert_info(struct seq_file *seq, struct brcmf_sdio *bus, in brcmf_sdio_assert_info() argument
3006 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_assert_info()
3008 error = brcmf_sdiod_ramrw(bus->sdiodev, false, in brcmf_sdio_assert_info()
3014 error = brcmf_sdiod_ramrw(bus->sdiodev, false, in brcmf_sdio_assert_info()
3019 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_assert_info()
3026 static int brcmf_sdio_checkdied(struct brcmf_sdio *bus) in brcmf_sdio_checkdied() argument
3031 error = brcmf_sdio_readshared(bus, &sh); in brcmf_sdio_checkdied()
3047 static int brcmf_sdio_died_dump(struct seq_file *seq, struct brcmf_sdio *bus) in brcmf_sdio_died_dump() argument
3052 error = brcmf_sdio_readshared(bus, &sh); in brcmf_sdio_died_dump()
3056 error = brcmf_sdio_assert_info(seq, bus, &sh); in brcmf_sdio_died_dump()
3060 error = brcmf_sdio_trap_info(seq, bus, &sh); in brcmf_sdio_died_dump()
3064 error = brcmf_sdio_dump_console(seq, bus, &sh); in brcmf_sdio_died_dump()
3073 struct brcmf_sdio *bus = bus_if->bus_priv.sdio->bus; in brcmf_sdio_forensic_read() local
3075 return brcmf_sdio_died_dump(seq, bus); in brcmf_sdio_forensic_read()
3082 struct brcmf_sdio_count *sdcnt = &sdiodev->bus->sdcnt; in brcmf_debugfs_sdio_count_read()
3117 static void brcmf_sdio_debugfs_create(struct brcmf_sdio *bus) in brcmf_sdio_debugfs_create() argument
3119 struct brcmf_pub *drvr = bus->sdiodev->bus_if->drvr; in brcmf_sdio_debugfs_create()
3125 bus->console_interval = BRCMF_CONSOLE; in brcmf_sdio_debugfs_create()
3131 &bus->console_interval); in brcmf_sdio_debugfs_create()
3134 static int brcmf_sdio_checkdied(struct brcmf_sdio *bus) in brcmf_sdio_checkdied() argument
3139 static void brcmf_sdio_debugfs_create(struct brcmf_sdio *bus) in brcmf_sdio_debugfs_create() argument
3153 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_rxctl() local
3160 timeleft = brcmf_sdio_dcmd_resp_wait(bus, &bus->rxlen, &pending); in brcmf_sdio_bus_rxctl()
3162 spin_lock_bh(&bus->rxctl_lock); in brcmf_sdio_bus_rxctl()
3163 rxlen = bus->rxlen; in brcmf_sdio_bus_rxctl()
3164 memcpy(msg, bus->rxctl, min(msglen, rxlen)); in brcmf_sdio_bus_rxctl()
3165 bus->rxctl = NULL; in brcmf_sdio_bus_rxctl()
3166 buf = bus->rxctl_orig; in brcmf_sdio_bus_rxctl()
3167 bus->rxctl_orig = NULL; in brcmf_sdio_bus_rxctl()
3168 bus->rxlen = 0; in brcmf_sdio_bus_rxctl()
3169 spin_unlock_bh(&bus->rxctl_lock); in brcmf_sdio_bus_rxctl()
3177 brcmf_sdio_checkdied(bus); in brcmf_sdio_bus_rxctl()
3183 brcmf_sdio_checkdied(bus); in brcmf_sdio_bus_rxctl()
3187 bus->sdcnt.rx_ctlpkts++; in brcmf_sdio_bus_rxctl()
3189 bus->sdcnt.rx_ctlerrs++; in brcmf_sdio_bus_rxctl()
3248 static int brcmf_sdio_download_code_file(struct brcmf_sdio *bus, in brcmf_sdio_download_code_file() argument
3255 err = brcmf_sdiod_ramrw(bus->sdiodev, true, bus->ci->rambase, in brcmf_sdio_download_code_file()
3259 err, (int)fw->size, bus->ci->rambase); in brcmf_sdio_download_code_file()
3260 else if (!brcmf_sdio_verifymemory(bus->sdiodev, bus->ci->rambase, in brcmf_sdio_download_code_file()
3267 static int brcmf_sdio_download_nvram(struct brcmf_sdio *bus, in brcmf_sdio_download_nvram() argument
3275 address = bus->ci->ramsize - varsz + bus->ci->rambase; in brcmf_sdio_download_nvram()
3276 err = brcmf_sdiod_ramrw(bus->sdiodev, true, address, vars, varsz); in brcmf_sdio_download_nvram()
3280 else if (!brcmf_sdio_verifymemory(bus->sdiodev, address, vars, varsz)) in brcmf_sdio_download_nvram()
3286 static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus, in brcmf_sdio_download_firmware() argument
3293 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_download_firmware()
3294 brcmf_sdio_clkctl(bus, CLK_AVAIL, false); in brcmf_sdio_download_firmware()
3299 bcmerror = brcmf_sdio_download_code_file(bus, fw); in brcmf_sdio_download_firmware()
3307 bcmerror = brcmf_sdio_download_nvram(bus, nvram, nvlen); in brcmf_sdio_download_firmware()
3315 if (!brcmf_chip_set_active(bus->ci, rstvec)) { in brcmf_sdio_download_firmware()
3321 brcmf_sdio_clkctl(bus, CLK_SDONLY, false); in brcmf_sdio_download_firmware()
3322 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_download_firmware()
3326 static void brcmf_sdio_sr_init(struct brcmf_sdio *bus) in brcmf_sdio_sr_init() argument
3333 val = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_WAKEUPCTRL, &err); in brcmf_sdio_sr_init()
3340 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_WAKEUPCTRL, val, &err); in brcmf_sdio_sr_init()
3347 brcmf_sdiod_func0_wb(bus->sdiodev, SDIO_CCCR_BRCM_CARDCAP, in brcmf_sdio_sr_init()
3356 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, in brcmf_sdio_sr_init()
3364 bus->sr_enabled = true; in brcmf_sdio_sr_init()
3369 static int brcmf_sdio_kso_init(struct brcmf_sdio *bus) in brcmf_sdio_kso_init() argument
3371 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_kso_init()
3381 val = brcmf_sdiod_readb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, &err); in brcmf_sdio_kso_init()
3390 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, in brcmf_sdio_kso_init()
3406 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_preinit() local
3407 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_bus_preinit()
3417 bus_if->maxctl += bus->roundup; in brcmf_sdio_bus_preinit()
3419 value += bus->head_align; in brcmf_sdio_bus_preinit()
3420 bus->rxbuf = kmalloc(value, GFP_ATOMIC); in brcmf_sdio_bus_preinit()
3421 if (bus->rxbuf) in brcmf_sdio_bus_preinit()
3422 bus->rxblen = value; in brcmf_sdio_bus_preinit()
3424 brcmf_sdio_debugfs_create(bus); in brcmf_sdio_bus_preinit()
3437 value = sdiodev->settings->bus.sdio.sd_sgentry_align; in brcmf_sdio_bus_preinit()
3447 bus->tx_hdrlen = SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN; in brcmf_sdio_bus_preinit()
3449 bus->txglom = false; in brcmf_sdio_bus_preinit()
3451 pad_size = bus->sdiodev->func2->cur_blksize << 1; in brcmf_sdio_bus_preinit()
3452 err = brcmf_iovar_data_set(bus->sdiodev->dev, "bus:rxglom", in brcmf_sdio_bus_preinit()
3458 bus->txglom = true; in brcmf_sdio_bus_preinit()
3459 bus->tx_hdrlen += SDPCM_HWEXT_LEN; in brcmf_sdio_bus_preinit()
3462 brcmf_bus_add_txhdrlen(bus->sdiodev->dev, bus->tx_hdrlen); in brcmf_sdio_bus_preinit()
3472 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_get_ramsize() local
3474 return bus->ci->ramsize - bus->ci->srsize; in brcmf_sdio_bus_get_ramsize()
3482 struct brcmf_sdio *bus = sdiodev->bus; in brcmf_sdio_bus_get_memdump() local
3488 brcmf_dbg(INFO, "dump at 0x%08x: size=%zu\n", bus->ci->rambase, in brcmf_sdio_bus_get_memdump()
3491 address = bus->ci->rambase; in brcmf_sdio_bus_get_memdump()
3513 void brcmf_sdio_trigger_dpc(struct brcmf_sdio *bus) in brcmf_sdio_trigger_dpc() argument
3515 if (!bus->dpc_triggered) { in brcmf_sdio_trigger_dpc()
3516 bus->dpc_triggered = true; in brcmf_sdio_trigger_dpc()
3517 queue_work(bus->brcmf_wq, &bus->datawork); in brcmf_sdio_trigger_dpc()
3521 void brcmf_sdio_isr(struct brcmf_sdio *bus) in brcmf_sdio_isr() argument
3525 if (!bus) { in brcmf_sdio_isr()
3531 bus->sdcnt.intrcount++; in brcmf_sdio_isr()
3533 atomic_set(&bus->ipend, 1); in brcmf_sdio_isr()
3535 if (brcmf_sdio_intr_rstatus(bus)) { in brcmf_sdio_isr()
3540 if (!bus->intr) in brcmf_sdio_isr()
3543 bus->dpc_triggered = true; in brcmf_sdio_isr()
3544 queue_work(bus->brcmf_wq, &bus->datawork); in brcmf_sdio_isr()
3547 static void brcmf_sdio_bus_watchdog(struct brcmf_sdio *bus) in brcmf_sdio_bus_watchdog() argument
3552 if (!bus->sr_enabled && in brcmf_sdio_bus_watchdog()
3553 bus->poll && (++bus->polltick >= bus->pollrate)) { in brcmf_sdio_bus_watchdog()
3557 bus->polltick = 0; in brcmf_sdio_bus_watchdog()
3560 if (!bus->intr || in brcmf_sdio_bus_watchdog()
3561 (bus->sdcnt.intrcount == bus->sdcnt.lastintrs)) { in brcmf_sdio_bus_watchdog()
3563 if (!bus->dpc_triggered) { in brcmf_sdio_bus_watchdog()
3566 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3567 devpend = brcmf_sdiod_func0_rb(bus->sdiodev, in brcmf_sdio_bus_watchdog()
3569 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3577 bus->sdcnt.pollcnt++; in brcmf_sdio_bus_watchdog()
3578 atomic_set(&bus->ipend, 1); in brcmf_sdio_bus_watchdog()
3580 bus->dpc_triggered = true; in brcmf_sdio_bus_watchdog()
3581 queue_work(bus->brcmf_wq, &bus->datawork); in brcmf_sdio_bus_watchdog()
3586 bus->sdcnt.lastintrs = bus->sdcnt.intrcount; in brcmf_sdio_bus_watchdog()
3590 if (bus->sdiodev->state == BRCMF_SDIOD_DATA && BRCMF_FWCON_ON() && in brcmf_sdio_bus_watchdog()
3591 bus->console_interval != 0) { in brcmf_sdio_bus_watchdog()
3592 bus->console.count += jiffies_to_msecs(BRCMF_WD_POLL); in brcmf_sdio_bus_watchdog()
3593 if (bus->console.count >= bus->console_interval) { in brcmf_sdio_bus_watchdog()
3594 bus->console.count -= bus->console_interval; in brcmf_sdio_bus_watchdog()
3595 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3597 brcmf_sdio_bus_sleep(bus, false, false); in brcmf_sdio_bus_watchdog()
3598 if (brcmf_sdio_readconsole(bus) < 0) in brcmf_sdio_bus_watchdog()
3600 bus->console_interval = 0; in brcmf_sdio_bus_watchdog()
3601 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3607 if (!bus->dpc_triggered) { in brcmf_sdio_bus_watchdog()
3609 if ((!bus->dpc_running) && (bus->idletime > 0) && in brcmf_sdio_bus_watchdog()
3610 (bus->clkstate == CLK_AVAIL)) { in brcmf_sdio_bus_watchdog()
3611 bus->idlecount++; in brcmf_sdio_bus_watchdog()
3612 if (bus->idlecount > bus->idletime) { in brcmf_sdio_bus_watchdog()
3614 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3615 brcmf_sdio_wd_timer(bus, false); in brcmf_sdio_bus_watchdog()
3616 bus->idlecount = 0; in brcmf_sdio_bus_watchdog()
3617 brcmf_sdio_bus_sleep(bus, true, false); in brcmf_sdio_bus_watchdog()
3618 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_bus_watchdog()
3621 bus->idlecount = 0; in brcmf_sdio_bus_watchdog()
3624 bus->idlecount = 0; in brcmf_sdio_bus_watchdog()
3630 struct brcmf_sdio *bus = container_of(work, struct brcmf_sdio, in brcmf_sdio_dataworker() local
3633 bus->dpc_running = true; in brcmf_sdio_dataworker()
3635 while (READ_ONCE(bus->dpc_triggered)) { in brcmf_sdio_dataworker()
3636 bus->dpc_triggered = false; in brcmf_sdio_dataworker()
3637 brcmf_sdio_dpc(bus); in brcmf_sdio_dataworker()
3638 bus->idlecount = 0; in brcmf_sdio_dataworker()
3640 bus->dpc_running = false; in brcmf_sdio_dataworker()
3641 if (brcmf_sdiod_freezing(bus->sdiodev)) { in brcmf_sdio_dataworker()
3642 brcmf_sdiod_change_state(bus->sdiodev, BRCMF_SDIOD_DOWN); in brcmf_sdio_dataworker()
3643 brcmf_sdiod_try_freeze(bus->sdiodev); in brcmf_sdio_dataworker()
3644 brcmf_sdiod_change_state(bus->sdiodev, BRCMF_SDIOD_DATA); in brcmf_sdio_dataworker()
3767 struct brcmf_core *core = sdiodev->bus->sdio_core; in brcmf_sdio_buscore_activate()
3822 brcmf_sdio_probe_attach(struct brcmf_sdio *bus) in brcmf_sdio_probe_attach() argument
3831 sdiodev = bus->sdiodev; in brcmf_sdio_probe_attach()
3854 bus->ci = brcmf_chip_attach(sdiodev, &brcmf_sdio_buscore_ops); in brcmf_sdio_probe_attach()
3855 if (IS_ERR(bus->ci)) { in brcmf_sdio_probe_attach()
3857 bus->ci = NULL; in brcmf_sdio_probe_attach()
3862 bus->sdio_core = brcmf_chip_get_core(bus->ci, BCMA_CORE_SDIO_DEV); in brcmf_sdio_probe_attach()
3863 if (!bus->sdio_core) in brcmf_sdio_probe_attach()
3867 sdiodev->cc_core = brcmf_chip_get_core(bus->ci, BCMA_CORE_CHIPCOMMON); in brcmf_sdio_probe_attach()
3873 bus->ci->chip, in brcmf_sdio_probe_attach()
3874 bus->ci->chiprev); in brcmf_sdio_probe_attach()
3882 bus->head_align = ALIGNMENT; in brcmf_sdio_probe_attach()
3883 bus->sgentry_align = ALIGNMENT; in brcmf_sdio_probe_attach()
3884 if (sdiodev->settings->bus.sdio.sd_head_align > ALIGNMENT) in brcmf_sdio_probe_attach()
3885 bus->head_align = sdiodev->settings->bus.sdio.sd_head_align; in brcmf_sdio_probe_attach()
3886 if (sdiodev->settings->bus.sdio.sd_sgentry_align > ALIGNMENT) in brcmf_sdio_probe_attach()
3887 bus->sgentry_align = in brcmf_sdio_probe_attach()
3888 sdiodev->settings->bus.sdio.sd_sgentry_align; in brcmf_sdio_probe_attach()
3901 (sdiodev->settings->bus.sdio.oob_irq_supported))) in brcmf_sdio_probe_attach()
3905 if (brcmf_sdio_kso_init(bus)) { in brcmf_sdio_probe_attach()
3910 if (sdiodev->settings->bus.sdio.drive_strength) in brcmf_sdio_probe_attach()
3911 drivestrength = sdiodev->settings->bus.sdio.drive_strength; in brcmf_sdio_probe_attach()
3914 brcmf_sdio_drivestrengthinit(sdiodev, bus->ci, drivestrength); in brcmf_sdio_probe_attach()
3928 reg_addr = CORE_CC_REG(brcmf_chip_get_pmu(bus->ci)->base, pmucontrol); in brcmf_sdio_probe_attach()
3941 brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); in brcmf_sdio_probe_attach()
3944 bus->hdrbuf = kzalloc(MAX_HDR_READ + bus->head_align, GFP_KERNEL); in brcmf_sdio_probe_attach()
3945 if (!bus->hdrbuf) in brcmf_sdio_probe_attach()
3948 bus->rxhdr = (u8 *) roundup((unsigned long)&bus->hdrbuf[0], in brcmf_sdio_probe_attach()
3949 bus->head_align); in brcmf_sdio_probe_attach()
3952 bus->intr = true; in brcmf_sdio_probe_attach()
3953 bus->poll = false; in brcmf_sdio_probe_attach()
3954 if (bus->poll) in brcmf_sdio_probe_attach()
3955 bus->pollrate = 1; in brcmf_sdio_probe_attach()
3967 struct brcmf_sdio *bus = (struct brcmf_sdio *)data; in brcmf_sdio_watchdog_thread() local
3972 brcmf_sdiod_freezer_count(bus->sdiodev); in brcmf_sdio_watchdog_thread()
3976 brcmf_sdiod_freezer_uncount(bus->sdiodev); in brcmf_sdio_watchdog_thread()
3977 wait = wait_for_completion_interruptible(&bus->watchdog_wait); in brcmf_sdio_watchdog_thread()
3978 brcmf_sdiod_freezer_count(bus->sdiodev); in brcmf_sdio_watchdog_thread()
3979 brcmf_sdiod_try_freeze(bus->sdiodev); in brcmf_sdio_watchdog_thread()
3981 brcmf_sdio_bus_watchdog(bus); in brcmf_sdio_watchdog_thread()
3983 bus->sdcnt.tickcnt++; in brcmf_sdio_watchdog_thread()
3984 reinit_completion(&bus->watchdog_wait); in brcmf_sdio_watchdog_thread()
3994 struct brcmf_sdio *bus = from_timer(bus, t, timer); in brcmf_sdio_watchdog() local
3996 if (bus->watchdog_tsk) { in brcmf_sdio_watchdog()
3997 complete(&bus->watchdog_wait); in brcmf_sdio_watchdog()
3999 if (bus->wd_active) in brcmf_sdio_watchdog()
4000 mod_timer(&bus->timer, in brcmf_sdio_watchdog()
4046 struct brcmf_sdio *bus = sdiod->bus; in brcmf_sdio_firmware_callback() local
4047 struct brcmf_core *core = bus->sdio_core; in brcmf_sdio_firmware_callback()
4064 bus->alp_only = true; in brcmf_sdio_firmware_callback()
4065 err = brcmf_sdio_download_firmware(bus, code, nvram, nvram_len); in brcmf_sdio_firmware_callback()
4068 bus->alp_only = false; in brcmf_sdio_firmware_callback()
4071 bus->sdcnt.tickcnt = 0; in brcmf_sdio_firmware_callback()
4072 brcmf_sdio_wd_timer(bus, true); in brcmf_sdio_firmware_callback()
4077 brcmf_sdio_clkctl(bus, CLK_AVAIL, false); in brcmf_sdio_firmware_callback()
4078 if (bus->clkstate != CLK_AVAIL) in brcmf_sdio_firmware_callback()
4103 bus->hostintmask = HOSTINTMASK; in brcmf_sdio_firmware_callback()
4105 bus->hostintmask, NULL); in brcmf_sdio_firmware_callback()
4115 if (brcmf_chip_sr_capable(bus->ci)) { in brcmf_sdio_firmware_callback()
4116 brcmf_sdio_sr_init(bus); in brcmf_sdio_firmware_callback()
4125 brcmf_sdiod_change_state(bus->sdiodev, BRCMF_SDIOD_DATA); in brcmf_sdio_firmware_callback()
4134 brcmf_sdio_clkctl(bus, CLK_NONE, false); in brcmf_sdio_firmware_callback()
4141 sdiod->bus_if->chip = bus->ci->chip; in brcmf_sdio_firmware_callback()
4142 sdiod->bus_if->chiprev = bus->ci->chiprev; in brcmf_sdio_firmware_callback()
4163 brcmf_sdio_prepare_fw_request(struct brcmf_sdio *bus) in brcmf_sdio_prepare_fw_request() argument
4167 { ".bin", bus->sdiodev->fw_name }, in brcmf_sdio_prepare_fw_request()
4168 { ".txt", bus->sdiodev->nvram_name }, in brcmf_sdio_prepare_fw_request()
4171 fwreq = brcmf_fw_alloc_request(bus->ci->chip, bus->ci->chiprev, in brcmf_sdio_prepare_fw_request()
4187 struct brcmf_sdio *bus; in brcmf_sdio_probe() local
4194 bus = kzalloc(sizeof(struct brcmf_sdio), GFP_ATOMIC); in brcmf_sdio_probe()
4195 if (!bus) in brcmf_sdio_probe()
4198 bus->sdiodev = sdiodev; in brcmf_sdio_probe()
4199 sdiodev->bus = bus; in brcmf_sdio_probe()
4200 skb_queue_head_init(&bus->glom); in brcmf_sdio_probe()
4201 bus->txbound = BRCMF_TXBOUND; in brcmf_sdio_probe()
4202 bus->rxbound = BRCMF_RXBOUND; in brcmf_sdio_probe()
4203 bus->txminmax = BRCMF_TXMINMAX; in brcmf_sdio_probe()
4204 bus->tx_seq = SDPCM_SEQ_WRAP - 1; in brcmf_sdio_probe()
4214 INIT_WORK(&bus->datawork, brcmf_sdio_dataworker); in brcmf_sdio_probe()
4215 bus->brcmf_wq = wq; in brcmf_sdio_probe()
4218 if (!(brcmf_sdio_probe_attach(bus))) { in brcmf_sdio_probe()
4223 spin_lock_init(&bus->rxctl_lock); in brcmf_sdio_probe()
4224 spin_lock_init(&bus->txq_lock); in brcmf_sdio_probe()
4225 init_waitqueue_head(&bus->ctrl_wait); in brcmf_sdio_probe()
4226 init_waitqueue_head(&bus->dcmd_resp_wait); in brcmf_sdio_probe()
4229 timer_setup(&bus->timer, brcmf_sdio_watchdog, 0); in brcmf_sdio_probe()
4231 init_completion(&bus->watchdog_wait); in brcmf_sdio_probe()
4232 bus->watchdog_tsk = kthread_run(brcmf_sdio_watchdog_thread, in brcmf_sdio_probe()
4233 bus, "brcmf_wdog/%s", in brcmf_sdio_probe()
4235 if (IS_ERR(bus->watchdog_tsk)) { in brcmf_sdio_probe()
4237 bus->watchdog_tsk = NULL; in brcmf_sdio_probe()
4240 bus->dpc_triggered = false; in brcmf_sdio_probe()
4241 bus->dpc_running = false; in brcmf_sdio_probe()
4244 bus->tx_hdrlen = SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN; in brcmf_sdio_probe()
4247 bus->blocksize = bus->sdiodev->func2->cur_blksize; in brcmf_sdio_probe()
4248 bus->roundup = min(max_roundup, bus->blocksize); in brcmf_sdio_probe()
4250 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_probe()
4253 sdio_disable_func(bus->sdiodev->func2); in brcmf_sdio_probe()
4255 bus->rxflow = false; in brcmf_sdio_probe()
4258 brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, 0, NULL); in brcmf_sdio_probe()
4260 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_probe()
4263 bus->clkstate = CLK_SDONLY; in brcmf_sdio_probe()
4264 bus->idletime = BRCMF_IDLE_INTERVAL; in brcmf_sdio_probe()
4265 bus->idleclock = BRCMF_IDLE_ACTIVE; in brcmf_sdio_probe()
4268 bus->sr_enabled = false; in brcmf_sdio_probe()
4272 fwreq = brcmf_sdio_prepare_fw_request(bus); in brcmf_sdio_probe()
4286 return bus; in brcmf_sdio_probe()
4289 brcmf_sdio_remove(bus); in brcmf_sdio_probe()
4294 void brcmf_sdio_remove(struct brcmf_sdio *bus) in brcmf_sdio_remove() argument
4298 if (bus) { in brcmf_sdio_remove()
4300 if (bus->watchdog_tsk) { in brcmf_sdio_remove()
4301 send_sig(SIGTERM, bus->watchdog_tsk, 1); in brcmf_sdio_remove()
4302 kthread_stop(bus->watchdog_tsk); in brcmf_sdio_remove()
4303 bus->watchdog_tsk = NULL; in brcmf_sdio_remove()
4307 brcmf_sdiod_intr_unregister(bus->sdiodev); in brcmf_sdio_remove()
4309 brcmf_detach(bus->sdiodev->dev); in brcmf_sdio_remove()
4311 cancel_work_sync(&bus->datawork); in brcmf_sdio_remove()
4312 if (bus->brcmf_wq) in brcmf_sdio_remove()
4313 destroy_workqueue(bus->brcmf_wq); in brcmf_sdio_remove()
4315 if (bus->ci) { in brcmf_sdio_remove()
4316 if (bus->sdiodev->state != BRCMF_SDIOD_NOMEDIUM) { in brcmf_sdio_remove()
4317 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_remove()
4318 brcmf_sdio_wd_timer(bus, false); in brcmf_sdio_remove()
4319 brcmf_sdio_clkctl(bus, CLK_AVAIL, false); in brcmf_sdio_remove()
4325 brcmf_chip_set_passive(bus->ci); in brcmf_sdio_remove()
4326 brcmf_sdio_clkctl(bus, CLK_NONE, false); in brcmf_sdio_remove()
4327 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_remove()
4329 brcmf_chip_detach(bus->ci); in brcmf_sdio_remove()
4331 if (bus->sdiodev->settings) in brcmf_sdio_remove()
4332 brcmf_release_module_param(bus->sdiodev->settings); in brcmf_sdio_remove()
4334 kfree(bus->rxbuf); in brcmf_sdio_remove()
4335 kfree(bus->hdrbuf); in brcmf_sdio_remove()
4336 kfree(bus); in brcmf_sdio_remove()
4342 void brcmf_sdio_wd_timer(struct brcmf_sdio *bus, bool active) in brcmf_sdio_wd_timer() argument
4345 if (!active && bus->wd_active) { in brcmf_sdio_wd_timer()
4346 del_timer_sync(&bus->timer); in brcmf_sdio_wd_timer()
4347 bus->wd_active = false; in brcmf_sdio_wd_timer()
4352 if (bus->sdiodev->state != BRCMF_SDIOD_DATA) in brcmf_sdio_wd_timer()
4356 if (!bus->wd_active) { in brcmf_sdio_wd_timer()
4360 bus->timer.expires = jiffies + BRCMF_WD_POLL; in brcmf_sdio_wd_timer()
4361 add_timer(&bus->timer); in brcmf_sdio_wd_timer()
4362 bus->wd_active = true; in brcmf_sdio_wd_timer()
4365 mod_timer(&bus->timer, jiffies + BRCMF_WD_POLL); in brcmf_sdio_wd_timer()
4370 int brcmf_sdio_sleep(struct brcmf_sdio *bus, bool sleep) in brcmf_sdio_sleep() argument
4374 sdio_claim_host(bus->sdiodev->func1); in brcmf_sdio_sleep()
4375 ret = brcmf_sdio_bus_sleep(bus, sleep, false); in brcmf_sdio_sleep()
4376 sdio_release_host(bus->sdiodev->func1); in brcmf_sdio_sleep()