a8b0171cb342117323bec09c06a19f81ce646ce1
[openwrt/staging/neocturne.git] /
1 From 262f2b53f67936b59cc8dfc6f3899ab8905bf1ed Mon Sep 17 00:00:00 2001
2 From: Arend Van Spriel <arend.vanspriel@broadcom.com>
3 Date: Tue, 20 Feb 2018 00:14:20 +0100
4 Subject: [PATCH] brcmfmac: call brcmf_attach() just before calling
5 brcmf_bus_started()
6
7 Now we can move brcmf_attach() until after the firmware has been downloaded
8 to the device. Make the call just before brcmf_bus_started().
9
10 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
11 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
12 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
13 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
14 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
15 ---
16 .../wireless/broadcom/brcm80211/brcmfmac/core.c | 6 ++++
17 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 34 +++++++++++-----------
18 2 files changed, 23 insertions(+), 17 deletions(-)
19
20 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
21 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
22 @@ -1268,6 +1268,12 @@ void brcmf_bus_change_state(struct brcmf
23 int ifidx;
24
25 brcmf_dbg(TRACE, "%d -> %d\n", bus->state, state);
26 +
27 + if (!drvr) {
28 + brcmf_dbg(INFO, "ignoring transition, bus not attached yet\n");
29 + return;
30 + }
31 +
32 bus->state = state;
33
34 if (state == BRCMF_BUS_UP) {
35 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
36 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
37 @@ -4048,9 +4048,6 @@ static void brcmf_sdio_firmware_callback
38 if (err)
39 goto fail;
40
41 - if (!bus_if->drvr)
42 - return;
43 -
44 /* try to download image and nvram to the dongle */
45 bus->alp_only = true;
46 err = brcmf_sdio_download_firmware(bus, code, nvram, nvram_len);
47 @@ -4126,11 +4123,28 @@ static void brcmf_sdio_firmware_callback
48
49 sdio_release_host(sdiodev->func1);
50
51 + /* Assign bus interface call back */
52 + sdiodev->bus_if->dev = sdiodev->dev;
53 + sdiodev->bus_if->ops = &brcmf_sdio_bus_ops;
54 + sdiodev->bus_if->chip = bus->ci->chip;
55 + sdiodev->bus_if->chiprev = bus->ci->chiprev;
56 +
57 + /* Attach to the common layer, reserve hdr space */
58 + err = brcmf_attach(sdiodev->dev, sdiodev->settings);
59 + if (err != 0) {
60 + brcmf_err("brcmf_attach failed\n");
61 + goto fail;
62 + }
63 +
64 + brcmf_sdio_debugfs_create(bus);
65 +
66 err = brcmf_bus_started(dev);
67 if (err != 0) {
68 brcmf_err("dongle is not responding\n");
69 goto fail;
70 }
71 +
72 + /* ready */
73 return;
74
75 release:
76 @@ -4200,22 +4214,9 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
77 bus->dpc_triggered = false;
78 bus->dpc_running = false;
79
80 - /* Assign bus interface call back */
81 - bus->sdiodev->bus_if->dev = bus->sdiodev->dev;
82 - bus->sdiodev->bus_if->ops = &brcmf_sdio_bus_ops;
83 - bus->sdiodev->bus_if->chip = bus->ci->chip;
84 - bus->sdiodev->bus_if->chiprev = bus->ci->chiprev;
85 -
86 /* default sdio bus header length for tx packet */
87 bus->tx_hdrlen = SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN;
88
89 - /* Attach to the common layer, reserve hdr space */
90 - ret = brcmf_attach(bus->sdiodev->dev, bus->sdiodev->settings);
91 - if (ret != 0) {
92 - brcmf_err("brcmf_attach failed\n");
93 - goto fail;
94 - }
95 -
96 /* Query the F2 block size, set roundup accordingly */
97 bus->blocksize = bus->sdiodev->func2->cur_blksize;
98 bus->roundup = min(max_roundup, bus->blocksize);
99 @@ -4240,7 +4241,6 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
100 /* SR state */
101 bus->sr_enabled = false;
102
103 - brcmf_sdio_debugfs_create(bus);
104 brcmf_dbg(INFO, "completed!!\n");
105
106 ret = brcmf_fw_map_chip_to_name(bus->ci->chip, bus->ci->chiprev,