1 From 3d110df8f74781354051e4bb1e3e97fa368b2f80 Mon Sep 17 00:00:00 2001
2 From: Ian Molton <ian@mnementh.co.uk>
3 Date: Tue, 19 Dec 2017 13:47:07 +0100
4 Subject: [PATCH] brcmfmac: Remove {r,w}_sdreg32
6 Remove yet another IO function from the code and replace with one
9 Signed-off-by: Ian Molton <ian@mnementh.co.uk>
10 Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
11 [arend: keep address calculation, ie. (base + offset) in one line]
12 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
13 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
15 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 88 +++++++++++-----------
16 1 file changed, 42 insertions(+), 46 deletions(-)
18 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
19 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
20 @@ -660,30 +660,6 @@ static bool data_ok(struct brcmf_sdio *b
21 ((u8)(bus->tx_max - bus->tx_seq) & 0x80) == 0;
25 - * Reads a register in the SDIO hardware block. This block occupies a series of
26 - * adresses on the 32 bit backplane bus.
28 -static int r_sdreg32(struct brcmf_sdio *bus, u32 *regvar, u32 offset)
30 - struct brcmf_core *core = bus->sdio_core;
33 - *regvar = brcmf_sdiod_readl(bus->sdiodev, core->base + offset, &ret);
38 -static int w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset)
40 - struct brcmf_core *core = bus->sdio_core;
43 - brcmf_sdiod_writel(bus->sdiodev, core->base + reg_offset, regval, &ret);
49 brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on)
51 @@ -1078,6 +1054,8 @@ static void brcmf_sdio_get_console_addr(
53 static u32 brcmf_sdio_hostmail(struct brcmf_sdio *bus)
55 + struct brcmf_sdio_dev *sdiod = bus->sdiodev;
56 + struct brcmf_core *core = bus->sdio_core;
60 @@ -1086,10 +1064,14 @@ static u32 brcmf_sdio_hostmail(struct br
61 brcmf_dbg(SDIO, "Enter\n");
63 /* Read mailbox data and ack that we did so */
64 - ret = r_sdreg32(bus, &hmb_data, SD_REG(tohostmailboxdata));
65 + hmb_data = brcmf_sdiod_readl(sdiod,
66 + core->base + SD_REG(tohostmailboxdata),
70 + brcmf_sdiod_writel(sdiod, core->base + SD_REG(tosbmailbox),
74 - w_sdreg32(bus, SMB_INT_ACK, SD_REG(tosbmailbox));
75 bus->sdcnt.f1regdata += 2;
77 /* dongle indicates the firmware has halted/crashed */
78 @@ -1163,6 +1145,8 @@ static u32 brcmf_sdio_hostmail(struct br
80 static void brcmf_sdio_rxfail(struct brcmf_sdio *bus, bool abort, bool rtx)
82 + struct brcmf_sdio_dev *sdiod = bus->sdiodev;
83 + struct brcmf_core *core = bus->sdio_core;
87 @@ -1204,7 +1188,8 @@ static void brcmf_sdio_rxfail(struct brc
91 - err = w_sdreg32(bus, SMB_NAK, SD_REG(tosbmailbox));
92 + brcmf_sdiod_writel(sdiod, core->base + SD_REG(tosbmailbox),
95 bus->sdcnt.f1regdata++;
97 @@ -2291,6 +2276,7 @@ static uint brcmf_sdio_sendfromq(struct
100 struct sk_buff_head pktq;
101 + u32 intstat_addr = bus->sdio_core->base + SD_REG(intstatus);
103 int ret = 0, prec_out, i;
105 @@ -2329,7 +2315,8 @@ static uint brcmf_sdio_sendfromq(struct
107 /* Check device status, signal pending interrupt */
108 sdio_claim_host(bus->sdiodev->func[1]);
109 - ret = r_sdreg32(bus, &intstatus, SD_REG(intstatus));
110 + intstatus = brcmf_sdiod_readl(bus->sdiodev,
111 + intstat_addr, &ret);
112 sdio_release_host(bus->sdiodev->func[1]);
113 bus->sdcnt.f2txdata++;
115 @@ -2413,12 +2400,13 @@ static int brcmf_sdio_tx_ctrlframe(struc
117 static void brcmf_sdio_bus_stop(struct device *dev)
119 - u32 local_hostintmask;
122 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
123 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
124 struct brcmf_sdio *bus = sdiodev->bus;
125 + struct brcmf_core *core = bus->sdio_core;
126 + u32 local_hostintmask;
130 brcmf_dbg(TRACE, "Enter\n");
132 @@ -2435,7 +2423,9 @@ static void brcmf_sdio_bus_stop(struct d
133 brcmf_sdio_bus_sleep(bus, false, false);
135 /* Disable and clear interrupts at the chip level also */
136 - w_sdreg32(bus, 0, SD_REG(hostintmask));
137 + brcmf_sdiod_writel(sdiodev, core->base + SD_REG(hostintmask),
140 local_hostintmask = bus->hostintmask;
141 bus->hostintmask = 0;
143 @@ -2454,7 +2444,8 @@ static void brcmf_sdio_bus_stop(struct d
144 sdio_disable_func(sdiodev->func[SDIO_FUNC_2]);
146 /* Clear any pending interrupts now that F2 is disabled */
147 - w_sdreg32(bus, local_hostintmask, SD_REG(intstatus));
148 + brcmf_sdiod_writel(sdiodev, core->base + SD_REG(intstatus),
149 + local_hostintmask, NULL);
151 sdio_release_host(sdiodev->func[1]);
153 @@ -2521,7 +2512,9 @@ static int brcmf_sdio_intr_rstatus(struc
155 static void brcmf_sdio_dpc(struct brcmf_sdio *bus)
157 + struct brcmf_sdio_dev *sdiod = bus->sdiodev;
159 + u32 intstat_addr = bus->sdio_core->base + SD_REG(intstatus);
160 unsigned long intstatus;
161 uint txlimit = bus->txbound; /* Tx frames to send before resched */
162 uint framecnt; /* Temporary counter of tx/rx frames */
163 @@ -2576,9 +2569,10 @@ static void brcmf_sdio_dpc(struct brcmf_
165 if (intstatus & I_HMB_FC_CHANGE) {
166 intstatus &= ~I_HMB_FC_CHANGE;
167 - err = w_sdreg32(bus, I_HMB_FC_CHANGE, SD_REG(intstatus));
168 + brcmf_sdiod_writel(sdiod, intstat_addr, I_HMB_FC_CHANGE, &err);
170 + newstatus = brcmf_sdiod_readl(sdiod, intstat_addr, &err);
172 - err = r_sdreg32(bus, &newstatus, SD_REG(intstatus));
173 bus->sdcnt.f1regdata += 2;
174 atomic_set(&bus->fcstate,
175 !!(newstatus & (I_HMB_FC_STATE | I_HMB_FC_CHANGE)));
176 @@ -4017,22 +4011,21 @@ static void brcmf_sdio_firmware_callback
177 const struct firmware *code,
178 void *nvram, u32 nvram_len)
180 - struct brcmf_bus *bus_if;
181 - struct brcmf_sdio_dev *sdiodev;
182 - struct brcmf_sdio *bus;
183 + struct brcmf_bus *bus_if = dev_get_drvdata(dev);
184 + struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
185 + struct brcmf_sdio *bus = sdiodev->bus;
186 + struct brcmf_sdio_dev *sdiod = bus->sdiodev;
187 + struct brcmf_core *core = bus->sdio_core;
190 brcmf_dbg(TRACE, "Enter: dev=%s, err=%d\n", dev_name(dev), err);
191 - bus_if = dev_get_drvdata(dev);
192 - sdiodev = bus_if->bus_priv.sdio;
200 - bus = sdiodev->bus;
202 /* try to download image and nvram to the dongle */
203 bus->alp_only = true;
204 err = brcmf_sdio_download_firmware(bus, code, nvram, nvram_len);
205 @@ -4063,8 +4056,9 @@ static void brcmf_sdio_firmware_callback
208 /* Enable function 2 (frame transfers) */
209 - w_sdreg32(bus, SDPCM_PROT_VERSION << SMB_DATA_VERSION_SHIFT,
210 - SD_REG(tosbmailboxdata));
211 + brcmf_sdiod_writel(sdiod, core->base + SD_REG(tosbmailboxdata),
212 + SDPCM_PROT_VERSION << SMB_DATA_VERSION_SHIFT, NULL);
214 err = sdio_enable_func(sdiodev->func[SDIO_FUNC_2]);
217 @@ -4074,7 +4068,9 @@ static void brcmf_sdio_firmware_callback
219 /* Set up the interrupt mask and enable interrupts */
220 bus->hostintmask = HOSTINTMASK;
221 - w_sdreg32(bus, bus->hostintmask, SD_REG(hostintmask));
222 + brcmf_sdiod_writel(sdiod, core->base + SD_REG(hostintmask),
223 + bus->hostintmask, NULL);
226 brcmf_sdiod_writeb(sdiodev, SBSDIO_WATERMARK, 8, &err);