344-0015-brcmfmac-move-platform-data-retrieval-code-to-common.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. From: Hante Meuleman <meuleman@broadcom.com>
  2. Date: Wed, 17 Feb 2016 11:27:04 +0100
  3. Subject: [PATCH] brcmfmac: move platform data retrieval code to common
  4. In preparation of module parameters for all devices the module
  5. platform data retrieval is moved from sdio to common. It is still
  6. only used for sdio devices.
  7. Reviewed-by: Arend Van Spriel <arend@broadcom.com>
  8. Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
  9. Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
  10. Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
  11. Signed-off-by: Arend van Spriel <arend@broadcom.com>
  12. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  13. ---
  14. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
  15. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
  16. @@ -27,8 +27,6 @@
  17. #include <linux/mmc/sdio_func.h>
  18. #include <linux/mmc/card.h>
  19. #include <linux/mmc/host.h>
  20. -#include <linux/platform_device.h>
  21. -#include <linux/platform_data/brcmfmac-sdio.h>
  22. #include <linux/pm_runtime.h>
  23. #include <linux/suspend.h>
  24. #include <linux/errno.h>
  25. @@ -46,7 +44,6 @@
  26. #include "bus.h"
  27. #include "debug.h"
  28. #include "sdio.h"
  29. -#include "of.h"
  30. #include "core.h"
  31. #include "common.h"
  32. @@ -106,18 +103,18 @@ static void brcmf_sdiod_dummy_irqhandler
  33. int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
  34. {
  35. + struct brcmfmac_sdio_platform_data *pdata;
  36. int ret = 0;
  37. u8 data;
  38. u32 addr, gpiocontrol;
  39. unsigned long flags;
  40. - if ((sdiodev->pdata) && (sdiodev->pdata->oob_irq_supported)) {
  41. + pdata = sdiodev->pdata;
  42. + if ((pdata) && (pdata->oob_irq_supported)) {
  43. brcmf_dbg(SDIO, "Enter, register OOB IRQ %d\n",
  44. - sdiodev->pdata->oob_irq_nr);
  45. - ret = request_irq(sdiodev->pdata->oob_irq_nr,
  46. - brcmf_sdiod_oob_irqhandler,
  47. - sdiodev->pdata->oob_irq_flags,
  48. - "brcmf_oob_intr",
  49. + pdata->oob_irq_nr);
  50. + ret = request_irq(pdata->oob_irq_nr, brcmf_sdiod_oob_irqhandler,
  51. + pdata->oob_irq_flags, "brcmf_oob_intr",
  52. &sdiodev->func[1]->dev);
  53. if (ret != 0) {
  54. brcmf_err("request_irq failed %d\n", ret);
  55. @@ -129,7 +126,7 @@ int brcmf_sdiod_intr_register(struct brc
  56. sdiodev->irq_en = true;
  57. spin_unlock_irqrestore(&sdiodev->irq_en_lock, flags);
  58. - ret = enable_irq_wake(sdiodev->pdata->oob_irq_nr);
  59. + ret = enable_irq_wake(pdata->oob_irq_nr);
  60. if (ret != 0) {
  61. brcmf_err("enable_irq_wake failed %d\n", ret);
  62. return ret;
  63. @@ -158,7 +155,7 @@ int brcmf_sdiod_intr_register(struct brc
  64. /* redirect, configure and enable io for interrupt signal */
  65. data = SDIO_SEPINT_MASK | SDIO_SEPINT_OE;
  66. - if (sdiodev->pdata->oob_irq_flags & IRQF_TRIGGER_HIGH)
  67. + if (pdata->oob_irq_flags & IRQF_TRIGGER_HIGH)
  68. data |= SDIO_SEPINT_ACT_HI;
  69. brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, &ret);
  70. @@ -176,9 +173,12 @@ int brcmf_sdiod_intr_register(struct brc
  71. int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev)
  72. {
  73. + struct brcmfmac_sdio_platform_data *pdata;
  74. +
  75. brcmf_dbg(SDIO, "Entering\n");
  76. - if ((sdiodev->pdata) && (sdiodev->pdata->oob_irq_supported)) {
  77. + pdata = sdiodev->pdata;
  78. + if ((pdata) && (pdata->oob_irq_supported)) {
  79. sdio_claim_host(sdiodev->func[1]);
  80. brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, 0, NULL);
  81. brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_IENx, 0, NULL);
  82. @@ -187,11 +187,10 @@ int brcmf_sdiod_intr_unregister(struct b
  83. if (sdiodev->oob_irq_requested) {
  84. sdiodev->oob_irq_requested = false;
  85. if (sdiodev->irq_wake) {
  86. - disable_irq_wake(sdiodev->pdata->oob_irq_nr);
  87. + disable_irq_wake(pdata->oob_irq_nr);
  88. sdiodev->irq_wake = false;
  89. }
  90. - free_irq(sdiodev->pdata->oob_irq_nr,
  91. - &sdiodev->func[1]->dev);
  92. + free_irq(pdata->oob_irq_nr, &sdiodev->func[1]->dev);
  93. sdiodev->irq_en = false;
  94. }
  95. } else {
  96. @@ -1103,8 +1102,6 @@ static const struct sdio_device_id brcmf
  97. };
  98. MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
  99. -static struct brcmfmac_sdio_platform_data *brcmfmac_sdio_pdata;
  100. -
  101. static void brcmf_sdiod_acpi_set_power_manageable(struct device *dev,
  102. int val)
  103. @@ -1167,10 +1164,7 @@ static int brcmf_ops_sdio_probe(struct s
  104. dev_set_drvdata(&func->dev, bus_if);
  105. dev_set_drvdata(&sdiodev->func[1]->dev, bus_if);
  106. sdiodev->dev = &sdiodev->func[1]->dev;
  107. - sdiodev->pdata = brcmfmac_sdio_pdata;
  108. -
  109. - if (!sdiodev->pdata)
  110. - brcmf_of_probe(sdiodev);
  111. + sdiodev->pdata = brcmf_get_module_param(sdiodev->dev);
  112. #ifdef CONFIG_PM_SLEEP
  113. /* wowl can be supported when KEEP_POWER is true and (WAKE_SDIO_IRQ
  114. @@ -1296,7 +1290,7 @@ static const struct dev_pm_ops brcmf_sdi
  115. static struct sdio_driver brcmf_sdmmc_driver = {
  116. .probe = brcmf_ops_sdio_probe,
  117. .remove = brcmf_ops_sdio_remove,
  118. - .name = BRCMFMAC_SDIO_PDATA_NAME,
  119. + .name = KBUILD_MODNAME,
  120. .id_table = brcmf_sdmmc_ids,
  121. .drv = {
  122. .owner = THIS_MODULE,
  123. @@ -1306,37 +1300,6 @@ static struct sdio_driver brcmf_sdmmc_dr
  124. },
  125. };
  126. -static int __init brcmf_sdio_pd_probe(struct platform_device *pdev)
  127. -{
  128. - brcmf_dbg(SDIO, "Enter\n");
  129. -
  130. - brcmfmac_sdio_pdata = dev_get_platdata(&pdev->dev);
  131. -
  132. - if (brcmfmac_sdio_pdata->power_on)
  133. - brcmfmac_sdio_pdata->power_on();
  134. -
  135. - return 0;
  136. -}
  137. -
  138. -static int brcmf_sdio_pd_remove(struct platform_device *pdev)
  139. -{
  140. - brcmf_dbg(SDIO, "Enter\n");
  141. -
  142. - if (brcmfmac_sdio_pdata->power_off)
  143. - brcmfmac_sdio_pdata->power_off();
  144. -
  145. - sdio_unregister_driver(&brcmf_sdmmc_driver);
  146. -
  147. - return 0;
  148. -}
  149. -
  150. -static struct platform_driver brcmf_sdio_pd = {
  151. - .remove = brcmf_sdio_pd_remove,
  152. - .driver = {
  153. - .name = BRCMFMAC_SDIO_PDATA_NAME,
  154. - }
  155. -};
  156. -
  157. void brcmf_sdio_register(void)
  158. {
  159. int ret;
  160. @@ -1350,19 +1313,6 @@ void brcmf_sdio_exit(void)
  161. {
  162. brcmf_dbg(SDIO, "Enter\n");
  163. - if (brcmfmac_sdio_pdata)
  164. - platform_driver_unregister(&brcmf_sdio_pd);
  165. - else
  166. - sdio_unregister_driver(&brcmf_sdmmc_driver);
  167. + sdio_unregister_driver(&brcmf_sdmmc_driver);
  168. }
  169. -void __init brcmf_sdio_init(void)
  170. -{
  171. - int ret;
  172. -
  173. - brcmf_dbg(SDIO, "Enter\n");
  174. -
  175. - ret = platform_driver_probe(&brcmf_sdio_pd, brcmf_sdio_pd_probe);
  176. - if (ret == -ENODEV)
  177. - brcmf_dbg(SDIO, "No platform data available.\n");
  178. -}
  179. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
  180. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
  181. @@ -27,6 +27,7 @@
  182. #include "fwil_types.h"
  183. #include "tracepoint.h"
  184. #include "common.h"
  185. +#include "of.h"
  186. MODULE_AUTHOR("Broadcom Corporation");
  187. MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver.");
  188. @@ -79,6 +80,7 @@ module_param_named(ignore_probe_fail, br
  189. MODULE_PARM_DESC(ignore_probe_fail, "always succeed probe for debugging");
  190. #endif
  191. +static struct brcmfmac_sdio_platform_data *brcmfmac_pdata;
  192. struct brcmf_mp_global_t brcmf_mp_global;
  193. int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
  194. @@ -231,6 +233,13 @@ static void brcmf_mp_attach(void)
  195. BRCMF_FW_ALTPATH_LEN);
  196. }
  197. +struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev)
  198. +{
  199. + if (!brcmfmac_pdata)
  200. + brcmf_of_probe(dev, &brcmfmac_pdata);
  201. + return brcmfmac_pdata;
  202. +}
  203. +
  204. int brcmf_mp_device_attach(struct brcmf_pub *drvr)
  205. {
  206. drvr->settings = kzalloc(sizeof(*drvr->settings), GFP_ATOMIC);
  207. @@ -253,6 +262,35 @@ void brcmf_mp_device_detach(struct brcmf
  208. kfree(drvr->settings);
  209. }
  210. +static int __init brcmf_common_pd_probe(struct platform_device *pdev)
  211. +{
  212. + brcmf_dbg(INFO, "Enter\n");
  213. +
  214. + brcmfmac_pdata = dev_get_platdata(&pdev->dev);
  215. +
  216. + if (brcmfmac_pdata->power_on)
  217. + brcmfmac_pdata->power_on();
  218. +
  219. + return 0;
  220. +}
  221. +
  222. +static int brcmf_common_pd_remove(struct platform_device *pdev)
  223. +{
  224. + brcmf_dbg(INFO, "Enter\n");
  225. +
  226. + if (brcmfmac_pdata->power_off)
  227. + brcmfmac_pdata->power_off();
  228. +
  229. + return 0;
  230. +}
  231. +
  232. +static struct platform_driver brcmf_pd = {
  233. + .remove = brcmf_common_pd_remove,
  234. + .driver = {
  235. + .name = BRCMFMAC_SDIO_PDATA_NAME,
  236. + }
  237. +};
  238. +
  239. static int __init brcmfmac_module_init(void)
  240. {
  241. int err;
  242. @@ -260,16 +298,21 @@ static int __init brcmfmac_module_init(v
  243. /* Initialize debug system first */
  244. brcmf_debugfs_init();
  245. -#ifdef CPTCFG_BRCMFMAC_SDIO
  246. - brcmf_sdio_init();
  247. -#endif
  248. + /* Get the platform data (if available) for our devices */
  249. + err = platform_driver_probe(&brcmf_pd, brcmf_common_pd_probe);
  250. + if (err == -ENODEV)
  251. + brcmf_dbg(INFO, "No platform data available.\n");
  252. +
  253. /* Initialize global module paramaters */
  254. brcmf_mp_attach();
  255. /* Continue the initialization by registering the different busses */
  256. err = brcmf_core_init();
  257. - if (err)
  258. + if (err) {
  259. brcmf_debugfs_exit();
  260. + if (brcmfmac_pdata)
  261. + platform_driver_unregister(&brcmf_pd);
  262. + }
  263. return err;
  264. }
  265. @@ -277,6 +320,8 @@ static int __init brcmfmac_module_init(v
  266. static void __exit brcmfmac_module_exit(void)
  267. {
  268. brcmf_core_exit();
  269. + if (brcmfmac_pdata)
  270. + platform_driver_unregister(&brcmf_pd);
  271. brcmf_debugfs_exit();
  272. }
  273. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
  274. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
  275. @@ -15,6 +15,8 @@
  276. #ifndef BRCMFMAC_COMMON_H
  277. #define BRCMFMAC_COMMON_H
  278. +#include <linux/platform_device.h>
  279. +#include <linux/platform_data/brcmfmac-sdio.h>
  280. #include "fwil_types.h"
  281. extern const u8 ALLFFMAC[ETH_ALEN];
  282. @@ -89,6 +91,7 @@ struct brcmf_mp_device {
  283. struct cc_translate *country_codes;
  284. };
  285. +struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev);
  286. int brcmf_mp_device_attach(struct brcmf_pub *drvr);
  287. void brcmf_mp_device_detach(struct brcmf_pub *drvr);
  288. #ifdef DEBUG
  289. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
  290. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
  291. @@ -16,17 +16,16 @@
  292. #include <linux/init.h>
  293. #include <linux/of.h>
  294. #include <linux/of_irq.h>
  295. -#include <linux/mmc/card.h>
  296. -#include <linux/platform_data/brcmfmac-sdio.h>
  297. -#include <linux/mmc/sdio_func.h>
  298. #include <defs.h>
  299. #include "debug.h"
  300. -#include "sdio.h"
  301. +#include "core.h"
  302. +#include "common.h"
  303. +#include "of.h"
  304. -void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
  305. +void
  306. +brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio)
  307. {
  308. - struct device *dev = sdiodev->dev;
  309. struct device_node *np = dev->of_node;
  310. int irq;
  311. u32 irqf;
  312. @@ -35,12 +34,12 @@ void brcmf_of_probe(struct brcmf_sdio_de
  313. if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
  314. return;
  315. - sdiodev->pdata = devm_kzalloc(dev, sizeof(*sdiodev->pdata), GFP_KERNEL);
  316. - if (!sdiodev->pdata)
  317. + *sdio = devm_kzalloc(dev, sizeof(*sdio), GFP_KERNEL);
  318. + if (!(*sdio))
  319. return;
  320. if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0)
  321. - sdiodev->pdata->drive_strength = val;
  322. + (*sdio)->drive_strength = val;
  323. /* make sure there are interrupts defined in the node */
  324. if (!of_find_property(np, "interrupts", NULL))
  325. @@ -53,7 +52,7 @@ void brcmf_of_probe(struct brcmf_sdio_de
  326. }
  327. irqf = irqd_get_trigger_type(irq_get_irq_data(irq));
  328. - sdiodev->pdata->oob_irq_supported = true;
  329. - sdiodev->pdata->oob_irq_nr = irq;
  330. - sdiodev->pdata->oob_irq_flags = irqf;
  331. + (*sdio)->oob_irq_supported = true;
  332. + (*sdio)->oob_irq_nr = irq;
  333. + (*sdio)->oob_irq_flags = irqf;
  334. }
  335. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
  336. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
  337. @@ -14,9 +14,11 @@
  338. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  339. */
  340. #ifdef CONFIG_OF
  341. -void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev);
  342. +void
  343. +brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio);
  344. #else
  345. -static void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
  346. +static void brcmf_of_probe(struct device *dev,
  347. + struct brcmfmac_sdio_platform_data **sdio)
  348. {
  349. }
  350. #endif /* CONFIG_OF */