314-v4.16-0001-brcmfmac-Remove-r-w-_sdreg32.patch 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. From 3d110df8f74781354051e4bb1e3e97fa368b2f80 Mon Sep 17 00:00:00 2001
  2. From: Ian Molton <[email protected]>
  3. Date: Tue, 19 Dec 2017 13:47:07 +0100
  4. Subject: [PATCH] brcmfmac: Remove {r,w}_sdreg32
  5. Remove yet another IO function from the code and replace with one
  6. that already exists.
  7. Signed-off-by: Ian Molton <[email protected]>
  8. Reviewed-by: Arend van Spriel <[email protected]>
  9. [arend: keep address calculation, ie. (base + offset) in one line]
  10. Signed-off-by: Arend van Spriel <[email protected]>
  11. Signed-off-by: Kalle Valo <[email protected]>
  12. ---
  13. .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 88 +++++++++++-----------
  14. 1 file changed, 42 insertions(+), 46 deletions(-)
  15. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  16. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  17. @@ -660,30 +660,6 @@ static bool data_ok(struct brcmf_sdio *b
  18. ((u8)(bus->tx_max - bus->tx_seq) & 0x80) == 0;
  19. }
  20. -/*
  21. - * Reads a register in the SDIO hardware block. This block occupies a series of
  22. - * adresses on the 32 bit backplane bus.
  23. - */
  24. -static int r_sdreg32(struct brcmf_sdio *bus, u32 *regvar, u32 offset)
  25. -{
  26. - struct brcmf_core *core = bus->sdio_core;
  27. - int ret;
  28. -
  29. - *regvar = brcmf_sdiod_readl(bus->sdiodev, core->base + offset, &ret);
  30. -
  31. - return ret;
  32. -}
  33. -
  34. -static int w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset)
  35. -{
  36. - struct brcmf_core *core = bus->sdio_core;
  37. - int ret;
  38. -
  39. - brcmf_sdiod_writel(bus->sdiodev, core->base + reg_offset, regval, &ret);
  40. -
  41. - return ret;
  42. -}
  43. -
  44. static int
  45. brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on)
  46. {
  47. @@ -1078,6 +1054,8 @@ static void brcmf_sdio_get_console_addr(
  48. static u32 brcmf_sdio_hostmail(struct brcmf_sdio *bus)
  49. {
  50. + struct brcmf_sdio_dev *sdiod = bus->sdiodev;
  51. + struct brcmf_core *core = bus->sdio_core;
  52. u32 intstatus = 0;
  53. u32 hmb_data;
  54. u8 fcbits;
  55. @@ -1086,10 +1064,14 @@ static u32 brcmf_sdio_hostmail(struct br
  56. brcmf_dbg(SDIO, "Enter\n");
  57. /* Read mailbox data and ack that we did so */
  58. - ret = r_sdreg32(bus, &hmb_data, SD_REG(tohostmailboxdata));
  59. + hmb_data = brcmf_sdiod_readl(sdiod,
  60. + core->base + SD_REG(tohostmailboxdata),
  61. + &ret);
  62. +
  63. + if (!ret)
  64. + brcmf_sdiod_writel(sdiod, core->base + SD_REG(tosbmailbox),
  65. + SMB_INT_ACK, &ret);
  66. - if (ret == 0)
  67. - w_sdreg32(bus, SMB_INT_ACK, SD_REG(tosbmailbox));
  68. bus->sdcnt.f1regdata += 2;
  69. /* dongle indicates the firmware has halted/crashed */
  70. @@ -1163,6 +1145,8 @@ static u32 brcmf_sdio_hostmail(struct br
  71. static void brcmf_sdio_rxfail(struct brcmf_sdio *bus, bool abort, bool rtx)
  72. {
  73. + struct brcmf_sdio_dev *sdiod = bus->sdiodev;
  74. + struct brcmf_core *core = bus->sdio_core;
  75. uint retries = 0;
  76. u16 lastrbc;
  77. u8 hi, lo;
  78. @@ -1204,7 +1188,8 @@ static void brcmf_sdio_rxfail(struct brc
  79. if (rtx) {
  80. bus->sdcnt.rxrtx++;
  81. - err = w_sdreg32(bus, SMB_NAK, SD_REG(tosbmailbox));
  82. + brcmf_sdiod_writel(sdiod, core->base + SD_REG(tosbmailbox),
  83. + SMB_NAK, &err);
  84. bus->sdcnt.f1regdata++;
  85. if (err == 0)
  86. @@ -2291,6 +2276,7 @@ static uint brcmf_sdio_sendfromq(struct
  87. {
  88. struct sk_buff *pkt;
  89. struct sk_buff_head pktq;
  90. + u32 intstat_addr = bus->sdio_core->base + SD_REG(intstatus);
  91. u32 intstatus = 0;
  92. int ret = 0, prec_out, i;
  93. uint cnt = 0;
  94. @@ -2329,7 +2315,8 @@ static uint brcmf_sdio_sendfromq(struct
  95. if (!bus->intr) {
  96. /* Check device status, signal pending interrupt */
  97. sdio_claim_host(bus->sdiodev->func[1]);
  98. - ret = r_sdreg32(bus, &intstatus, SD_REG(intstatus));
  99. + intstatus = brcmf_sdiod_readl(bus->sdiodev,
  100. + intstat_addr, &ret);
  101. sdio_release_host(bus->sdiodev->func[1]);
  102. bus->sdcnt.f2txdata++;
  103. if (ret != 0)
  104. @@ -2413,12 +2400,13 @@ static int brcmf_sdio_tx_ctrlframe(struc
  105. static void brcmf_sdio_bus_stop(struct device *dev)
  106. {
  107. - u32 local_hostintmask;
  108. - u8 saveclk;
  109. - int err;
  110. struct brcmf_bus *bus_if = dev_get_drvdata(dev);
  111. struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
  112. struct brcmf_sdio *bus = sdiodev->bus;
  113. + struct brcmf_core *core = bus->sdio_core;
  114. + u32 local_hostintmask;
  115. + u8 saveclk;
  116. + int err;
  117. brcmf_dbg(TRACE, "Enter\n");
  118. @@ -2435,7 +2423,9 @@ static void brcmf_sdio_bus_stop(struct d
  119. brcmf_sdio_bus_sleep(bus, false, false);
  120. /* Disable and clear interrupts at the chip level also */
  121. - w_sdreg32(bus, 0, SD_REG(hostintmask));
  122. + brcmf_sdiod_writel(sdiodev, core->base + SD_REG(hostintmask),
  123. + 0, NULL);
  124. +
  125. local_hostintmask = bus->hostintmask;
  126. bus->hostintmask = 0;
  127. @@ -2454,7 +2444,8 @@ static void brcmf_sdio_bus_stop(struct d
  128. sdio_disable_func(sdiodev->func[SDIO_FUNC_2]);
  129. /* Clear any pending interrupts now that F2 is disabled */
  130. - w_sdreg32(bus, local_hostintmask, SD_REG(intstatus));
  131. + brcmf_sdiod_writel(sdiodev, core->base + SD_REG(intstatus),
  132. + local_hostintmask, NULL);
  133. sdio_release_host(sdiodev->func[1]);
  134. }
  135. @@ -2521,7 +2512,9 @@ static int brcmf_sdio_intr_rstatus(struc
  136. static void brcmf_sdio_dpc(struct brcmf_sdio *bus)
  137. {
  138. + struct brcmf_sdio_dev *sdiod = bus->sdiodev;
  139. u32 newstatus = 0;
  140. + u32 intstat_addr = bus->sdio_core->base + SD_REG(intstatus);
  141. unsigned long intstatus;
  142. uint txlimit = bus->txbound; /* Tx frames to send before resched */
  143. uint framecnt; /* Temporary counter of tx/rx frames */
  144. @@ -2576,9 +2569,10 @@ static void brcmf_sdio_dpc(struct brcmf_
  145. */
  146. if (intstatus & I_HMB_FC_CHANGE) {
  147. intstatus &= ~I_HMB_FC_CHANGE;
  148. - err = w_sdreg32(bus, I_HMB_FC_CHANGE, SD_REG(intstatus));
  149. + brcmf_sdiod_writel(sdiod, intstat_addr, I_HMB_FC_CHANGE, &err);
  150. +
  151. + newstatus = brcmf_sdiod_readl(sdiod, intstat_addr, &err);
  152. - err = r_sdreg32(bus, &newstatus, SD_REG(intstatus));
  153. bus->sdcnt.f1regdata += 2;
  154. atomic_set(&bus->fcstate,
  155. !!(newstatus & (I_HMB_FC_STATE | I_HMB_FC_CHANGE)));
  156. @@ -4017,22 +4011,21 @@ static void brcmf_sdio_firmware_callback
  157. const struct firmware *code,
  158. void *nvram, u32 nvram_len)
  159. {
  160. - struct brcmf_bus *bus_if;
  161. - struct brcmf_sdio_dev *sdiodev;
  162. - struct brcmf_sdio *bus;
  163. + struct brcmf_bus *bus_if = dev_get_drvdata(dev);
  164. + struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
  165. + struct brcmf_sdio *bus = sdiodev->bus;
  166. + struct brcmf_sdio_dev *sdiod = bus->sdiodev;
  167. + struct brcmf_core *core = bus->sdio_core;
  168. u8 saveclk;
  169. brcmf_dbg(TRACE, "Enter: dev=%s, err=%d\n", dev_name(dev), err);
  170. - bus_if = dev_get_drvdata(dev);
  171. - sdiodev = bus_if->bus_priv.sdio;
  172. +
  173. if (err)
  174. goto fail;
  175. if (!bus_if->drvr)
  176. return;
  177. - bus = sdiodev->bus;
  178. -
  179. /* try to download image and nvram to the dongle */
  180. bus->alp_only = true;
  181. err = brcmf_sdio_download_firmware(bus, code, nvram, nvram_len);
  182. @@ -4063,8 +4056,9 @@ static void brcmf_sdio_firmware_callback
  183. }
  184. /* Enable function 2 (frame transfers) */
  185. - w_sdreg32(bus, SDPCM_PROT_VERSION << SMB_DATA_VERSION_SHIFT,
  186. - SD_REG(tosbmailboxdata));
  187. + brcmf_sdiod_writel(sdiod, core->base + SD_REG(tosbmailboxdata),
  188. + SDPCM_PROT_VERSION << SMB_DATA_VERSION_SHIFT, NULL);
  189. +
  190. err = sdio_enable_func(sdiodev->func[SDIO_FUNC_2]);
  191. @@ -4074,7 +4068,9 @@ static void brcmf_sdio_firmware_callback
  192. if (!err) {
  193. /* Set up the interrupt mask and enable interrupts */
  194. bus->hostintmask = HOSTINTMASK;
  195. - w_sdreg32(bus, bus->hostintmask, SD_REG(hostintmask));
  196. + brcmf_sdiod_writel(sdiod, core->base + SD_REG(hostintmask),
  197. + bus->hostintmask, NULL);
  198. +
  199. brcmf_sdiod_writeb(sdiodev, SBSDIO_WATERMARK, 8, &err);
  200. } else {