diff options
Diffstat (limited to 'drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c')
-rw-r--r-- | drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 79 |
1 files changed, 27 insertions, 52 deletions
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index c9c5ad269eaf..70cd0e9cd52b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | |||
@@ -162,7 +162,7 @@ int brcmf_sdio_intr_unregister(struct brcmf_sdio_dev *sdiodev) | |||
162 | return 0; | 162 | return 0; |
163 | } | 163 | } |
164 | 164 | ||
165 | int | 165 | static int |
166 | brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address) | 166 | brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address) |
167 | { | 167 | { |
168 | int err = 0, i; | 168 | int err = 0, i; |
@@ -193,12 +193,33 @@ brcmf_sdcard_set_sbaddr_window(struct brcmf_sdio_dev *sdiodev, u32 address) | |||
193 | return err; | 193 | return err; |
194 | } | 194 | } |
195 | 195 | ||
196 | static int | ||
197 | brcmf_sdio_addrprep(struct brcmf_sdio_dev *sdiodev, uint width, u32 *addr) | ||
198 | { | ||
199 | uint bar0 = *addr & ~SBSDIO_SB_OFT_ADDR_MASK; | ||
200 | int err = 0; | ||
201 | |||
202 | if (bar0 != sdiodev->sbwad) { | ||
203 | err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0); | ||
204 | if (err) | ||
205 | return err; | ||
206 | |||
207 | sdiodev->sbwad = bar0; | ||
208 | } | ||
209 | |||
210 | *addr &= SBSDIO_SB_OFT_ADDR_MASK; | ||
211 | |||
212 | if (width == 4) | ||
213 | *addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; | ||
214 | |||
215 | return 0; | ||
216 | } | ||
217 | |||
196 | int | 218 | int |
197 | brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr, | 219 | brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr, |
198 | void *data, bool write) | 220 | void *data, bool write) |
199 | { | 221 | { |
200 | u8 func_num, reg_size; | 222 | u8 func_num, reg_size; |
201 | u32 bar; | ||
202 | s32 retry = 0; | 223 | s32 retry = 0; |
203 | int ret; | 224 | int ret; |
204 | 225 | ||
@@ -218,18 +239,7 @@ brcmf_sdio_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr, | |||
218 | func_num = SDIO_FUNC_1; | 239 | func_num = SDIO_FUNC_1; |
219 | reg_size = 4; | 240 | reg_size = 4; |
220 | 241 | ||
221 | /* Set the window for SB core register */ | 242 | brcmf_sdio_addrprep(sdiodev, reg_size, &addr); |
222 | bar = addr & ~SBSDIO_SB_OFT_ADDR_MASK; | ||
223 | if (bar != sdiodev->sbwad) { | ||
224 | ret = brcmf_sdcard_set_sbaddr_window(sdiodev, bar); | ||
225 | if (ret != 0) { | ||
226 | memset(data, 0xFF, reg_size); | ||
227 | return ret; | ||
228 | } | ||
229 | sdiodev->sbwad = bar; | ||
230 | } | ||
231 | addr &= SBSDIO_SB_OFT_ADDR_MASK; | ||
232 | addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; | ||
233 | } | 243 | } |
234 | 244 | ||
235 | do { | 245 | do { |
@@ -452,28 +462,6 @@ static int brcmf_sdio_buffrw(struct brcmf_sdio_dev *sdiodev, uint fn, | |||
452 | return ret; | 462 | return ret; |
453 | } | 463 | } |
454 | 464 | ||
455 | static int brcmf_sdcard_recv_prepare(struct brcmf_sdio_dev *sdiodev, uint fn, | ||
456 | uint width, u32 *addr) | ||
457 | { | ||
458 | uint bar0 = *addr & ~SBSDIO_SB_OFT_ADDR_MASK; | ||
459 | int err = 0; | ||
460 | |||
461 | if (bar0 != sdiodev->sbwad) { | ||
462 | err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0); | ||
463 | if (err) | ||
464 | return err; | ||
465 | |||
466 | sdiodev->sbwad = bar0; | ||
467 | } | ||
468 | |||
469 | *addr &= SBSDIO_SB_OFT_ADDR_MASK; | ||
470 | |||
471 | if (width == 4) | ||
472 | *addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; | ||
473 | |||
474 | return 0; | ||
475 | } | ||
476 | |||
477 | int | 465 | int |
478 | brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, | 466 | brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, |
479 | uint flags, u8 *buf, uint nbytes) | 467 | uint flags, u8 *buf, uint nbytes) |
@@ -508,7 +496,7 @@ brcmf_sdcard_recv_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, | |||
508 | fn, addr, pkt->len); | 496 | fn, addr, pkt->len); |
509 | 497 | ||
510 | width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; | 498 | width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; |
511 | err = brcmf_sdcard_recv_prepare(sdiodev, fn, width, &addr); | 499 | err = brcmf_sdio_addrprep(sdiodev, width, &addr); |
512 | if (err) | 500 | if (err) |
513 | goto done; | 501 | goto done; |
514 | 502 | ||
@@ -532,7 +520,7 @@ int brcmf_sdcard_recv_chain(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, | |||
532 | fn, addr, pktq->qlen); | 520 | fn, addr, pktq->qlen); |
533 | 521 | ||
534 | width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; | 522 | width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; |
535 | err = brcmf_sdcard_recv_prepare(sdiodev, fn, width, &addr); | 523 | err = brcmf_sdio_addrprep(sdiodev, width, &addr); |
536 | if (err) | 524 | if (err) |
537 | goto done; | 525 | goto done; |
538 | 526 | ||
@@ -570,33 +558,20 @@ brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, | |||
570 | uint flags, struct sk_buff *pkt) | 558 | uint flags, struct sk_buff *pkt) |
571 | { | 559 | { |
572 | uint width; | 560 | uint width; |
573 | uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; | ||
574 | int err = 0; | 561 | int err = 0; |
575 | struct sk_buff_head pkt_list; | 562 | struct sk_buff_head pkt_list; |
576 | 563 | ||
577 | brcmf_dbg(SDIO, "fun = %d, addr = 0x%x, size = %d\n", | 564 | brcmf_dbg(SDIO, "fun = %d, addr = 0x%x, size = %d\n", |
578 | fn, addr, pkt->len); | 565 | fn, addr, pkt->len); |
579 | 566 | ||
580 | if (bar0 != sdiodev->sbwad) { | ||
581 | err = brcmf_sdcard_set_sbaddr_window(sdiodev, bar0); | ||
582 | if (err) | ||
583 | goto done; | ||
584 | |||
585 | sdiodev->sbwad = bar0; | ||
586 | } | ||
587 | |||
588 | addr &= SBSDIO_SB_OFT_ADDR_MASK; | ||
589 | |||
590 | width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; | 567 | width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; |
591 | if (width == 4) | 568 | brcmf_sdio_addrprep(sdiodev, width, &addr); |
592 | addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; | ||
593 | 569 | ||
594 | skb_queue_head_init(&pkt_list); | 570 | skb_queue_head_init(&pkt_list); |
595 | skb_queue_tail(&pkt_list, pkt); | 571 | skb_queue_tail(&pkt_list, pkt); |
596 | err = brcmf_sdio_buffrw(sdiodev, fn, true, addr, &pkt_list); | 572 | err = brcmf_sdio_buffrw(sdiodev, fn, true, addr, &pkt_list); |
597 | skb_dequeue_tail(&pkt_list); | 573 | skb_dequeue_tail(&pkt_list); |
598 | 574 | ||
599 | done: | ||
600 | return err; | 575 | return err; |
601 | } | 576 | } |
602 | 577 | ||