344-0017-brcmfmac-switch-to-new-platform-data.patch 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. From: Hante Meuleman <meuleman@broadcom.com>
  2. Date: Wed, 17 Feb 2016 11:27:07 +0100
  3. Subject: [PATCH] brcmfmac: switch to new platform data
  4. Platform data is only available for sdio. With this patch a new
  5. platform data structure is being used which allows for platform
  6. data for any device and configurable per device. This patch only
  7. switches to the new structure and adds support for SDIO devices.
  8. Reviewed-by: Arend Van Spriel <arend@broadcom.com>
  9. Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
  10. Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
  11. Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
  12. Signed-off-by: Arend van Spriel <arend@broadcom.com>
  13. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  14. ---
  15. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
  16. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
  17. @@ -103,7 +103,7 @@ static void brcmf_sdiod_dummy_irqhandler
  18. int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
  19. {
  20. - struct brcmfmac_sdio_platform_data *pdata;
  21. + struct brcmfmac_sdio_pd *pdata;
  22. int ret = 0;
  23. u8 data;
  24. u32 addr, gpiocontrol;
  25. @@ -173,7 +173,7 @@ int brcmf_sdiod_intr_register(struct brc
  26. int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev)
  27. {
  28. - struct brcmfmac_sdio_platform_data *pdata;
  29. + struct brcmfmac_sdio_pd *pdata;
  30. brcmf_dbg(SDIO, "Entering\n");
  31. @@ -1164,17 +1164,6 @@ static int brcmf_ops_sdio_probe(struct s
  32. dev_set_drvdata(&func->dev, bus_if);
  33. dev_set_drvdata(&sdiodev->func[1]->dev, bus_if);
  34. sdiodev->dev = &sdiodev->func[1]->dev;
  35. - sdiodev->pdata = brcmf_get_module_param(sdiodev->dev);
  36. -
  37. -#ifdef CONFIG_PM_SLEEP
  38. - /* wowl can be supported when KEEP_POWER is true and (WAKE_SDIO_IRQ
  39. - * is true or when platform data OOB irq is true).
  40. - */
  41. - if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) &&
  42. - ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) ||
  43. - (sdiodev->pdata && sdiodev->pdata->oob_irq_supported)))
  44. - bus_if->wowl_supported = true;
  45. -#endif
  46. brcmf_sdiod_change_state(sdiodev, BRCMF_SDIOD_DOWN);
  47. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  48. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  49. @@ -6459,8 +6459,8 @@ int brcmf_cfg80211_wait_vif_event(struct
  50. static s32 brcmf_translate_country_code(struct brcmf_pub *drvr, char alpha2[2],
  51. struct brcmf_fil_country_le *ccreq)
  52. {
  53. - struct cc_translate *country_codes;
  54. - struct cc_entry *cc;
  55. + struct brcmfmac_pd_cc *country_codes;
  56. + struct brcmfmac_pd_cc_entry *cc;
  57. s32 found_index;
  58. int i;
  59. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
  60. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
  61. @@ -80,7 +80,7 @@ module_param_named(ignore_probe_fail, br
  62. MODULE_PARM_DESC(ignore_probe_fail, "always succeed probe for debugging");
  63. #endif
  64. -static struct brcmfmac_sdio_platform_data *brcmfmac_pdata;
  65. +static struct brcmfmac_platform_data *brcmfmac_pdata;
  66. struct brcmf_mp_global_t brcmf_mp_global;
  67. int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
  68. @@ -229,15 +229,46 @@ void __brcmf_dbg(u32 level, const char *
  69. static void brcmf_mp_attach(void)
  70. {
  71. + /* If module param firmware path is set then this will always be used,
  72. + * if not set then if available use the platform data version. To make
  73. + * sure it gets initialized at all, always copy the module param version
  74. + */
  75. strlcpy(brcmf_mp_global.firmware_path, brcmf_firmware_path,
  76. BRCMF_FW_ALTPATH_LEN);
  77. + if ((brcmfmac_pdata) && (brcmfmac_pdata->fw_alternative_path) &&
  78. + (brcmf_mp_global.firmware_path[0] == '\0')) {
  79. + strlcpy(brcmf_mp_global.firmware_path,
  80. + brcmfmac_pdata->fw_alternative_path,
  81. + BRCMF_FW_ALTPATH_LEN);
  82. + }
  83. }
  84. -struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev)
  85. -{
  86. - if (!brcmfmac_pdata)
  87. - brcmf_of_probe(dev, &brcmfmac_pdata);
  88. - return brcmfmac_pdata;
  89. +struct brcmfmac_sdio_pd *brcmf_get_module_param(struct device *dev,
  90. + enum brcmf_bus_type bus_type,
  91. + u32 chip, u32 chiprev)
  92. +{
  93. + struct brcmfmac_sdio_pd *pdata;
  94. + struct brcmfmac_pd_device *device_pd;
  95. + int i;
  96. +
  97. + if (brcmfmac_pdata) {
  98. + for (i = 0; i < brcmfmac_pdata->device_count; i++) {
  99. + device_pd = &brcmfmac_pdata->devices[i];
  100. + if ((device_pd->bus_type == bus_type) &&
  101. + (device_pd->id == chip) &&
  102. + ((device_pd->rev == chiprev) ||
  103. + (device_pd->rev == -1))) {
  104. + brcmf_dbg(INFO, "Platform data for device found\n");
  105. + if (device_pd->bus_type == BRCMF_BUSTYPE_SDIO)
  106. + return &device_pd->bus.sdio;
  107. + break;
  108. + }
  109. + }
  110. + }
  111. + pdata = NULL;
  112. + brcmf_of_probe(dev, &pdata);
  113. +
  114. + return pdata;
  115. }
  116. int brcmf_mp_device_attach(struct brcmf_pub *drvr)
  117. @@ -287,7 +318,7 @@ static int brcmf_common_pd_remove(struct
  118. static struct platform_driver brcmf_pd = {
  119. .remove = brcmf_common_pd_remove,
  120. .driver = {
  121. - .name = BRCMFMAC_SDIO_PDATA_NAME,
  122. + .name = BRCMFMAC_PDATA_NAME,
  123. }
  124. };
  125. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
  126. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
  127. @@ -16,7 +16,7 @@
  128. #define BRCMFMAC_COMMON_H
  129. #include <linux/platform_device.h>
  130. -#include <linux/platform_data/brcmfmac-sdio.h>
  131. +#include <linux/platform_data/brcmfmac.h>
  132. #include "fwil_types.h"
  133. extern const u8 ALLFFMAC[ETH_ALEN];
  134. @@ -43,33 +43,6 @@ struct brcmf_mp_global_t {
  135. extern struct brcmf_mp_global_t brcmf_mp_global;
  136. /**
  137. - * struct cc_entry - Struct for translating user space country code (iso3166) to
  138. - * firmware country code and revision.
  139. - *
  140. - * @iso3166: iso3166 alpha 2 country code string.
  141. - * @cc: firmware country code string.
  142. - * @rev: firmware country code revision.
  143. - */
  144. -struct cc_entry {
  145. - char iso3166[BRCMF_COUNTRY_BUF_SZ];
  146. - char cc[BRCMF_COUNTRY_BUF_SZ];
  147. - s32 rev;
  148. -};
  149. -
  150. -/**
  151. - * struct cc_translate - Struct for translating country codes as set by user
  152. - * space to a country code and rev which can be used by
  153. - * firmware.
  154. - *
  155. - * @table_size: number of entries in table (> 0)
  156. - * @table: dynamic array of 1 or more elements with translation information.
  157. - */
  158. -struct cc_translate {
  159. - int table_size;
  160. - struct cc_entry table[0];
  161. -};
  162. -
  163. -/**
  164. * struct brcmf_mp_device - Device module paramaters.
  165. *
  166. * @sdiod_txglomsz: SDIO txglom size.
  167. @@ -88,10 +61,12 @@ struct brcmf_mp_device {
  168. int fcmode;
  169. bool roamoff;
  170. bool ignore_probe_fail;
  171. - struct cc_translate *country_codes;
  172. + struct brcmfmac_pd_cc *country_codes;
  173. };
  174. -struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev);
  175. +struct brcmfmac_sdio_pd *brcmf_get_module_param(struct device *dev,
  176. + enum brcmf_bus_type bus_type,
  177. + u32 chip, u32 chiprev);
  178. int brcmf_mp_device_attach(struct brcmf_pub *drvr);
  179. void brcmf_mp_device_detach(struct brcmf_pub *drvr);
  180. #ifdef DEBUG
  181. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
  182. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
  183. @@ -23,8 +23,7 @@
  184. #include "common.h"
  185. #include "of.h"
  186. -void
  187. -brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio)
  188. +void brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd **sdio)
  189. {
  190. struct device_node *np = dev->of_node;
  191. int irq;
  192. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
  193. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
  194. @@ -15,10 +15,9 @@
  195. */
  196. #ifdef CONFIG_OF
  197. void
  198. -brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio);
  199. +brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd **sdio);
  200. #else
  201. -static void brcmf_of_probe(struct device *dev,
  202. - struct brcmfmac_sdio_platform_data **sdio)
  203. +static void brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd **sdio)
  204. {
  205. }
  206. #endif /* CONFIG_OF */
  207. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  208. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  209. @@ -33,8 +33,6 @@
  210. #include <linux/bcma/bcma.h>
  211. #include <linux/debugfs.h>
  212. #include <linux/vmalloc.h>
  213. -#include <linux/platform_data/brcmfmac-sdio.h>
  214. -#include <linux/moduleparam.h>
  215. #include <asm/unaligned.h>
  216. #include <defs.h>
  217. #include <brcmu_wifi.h>
  218. @@ -44,6 +42,8 @@
  219. #include "sdio.h"
  220. #include "chip.h"
  221. #include "firmware.h"
  222. +#include "core.h"
  223. +#include "common.h"
  224. #define DCMD_RESP_TIMEOUT msecs_to_jiffies(2500)
  225. #define CTL_DONE_TIMEOUT msecs_to_jiffies(2500)
  226. @@ -3775,26 +3775,28 @@ static const struct brcmf_buscore_ops br
  227. static bool
  228. brcmf_sdio_probe_attach(struct brcmf_sdio *bus)
  229. {
  230. + struct brcmf_sdio_dev *sdiodev;
  231. u8 clkctl = 0;
  232. int err = 0;
  233. int reg_addr;
  234. u32 reg_val;
  235. u32 drivestrength;
  236. - sdio_claim_host(bus->sdiodev->func[1]);
  237. + sdiodev = bus->sdiodev;
  238. + sdio_claim_host(sdiodev->func[1]);
  239. pr_debug("F1 signature read @0x18000000=0x%4x\n",
  240. - brcmf_sdiod_regrl(bus->sdiodev, SI_ENUM_BASE, NULL));
  241. + brcmf_sdiod_regrl(sdiodev, SI_ENUM_BASE, NULL));
  242. /*
  243. * Force PLL off until brcmf_chip_attach()
  244. * programs PLL control regs
  245. */
  246. - brcmf_sdiod_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
  247. + brcmf_sdiod_regwb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
  248. BRCMF_INIT_CLKCTL1, &err);
  249. if (!err)
  250. - clkctl = brcmf_sdiod_regrb(bus->sdiodev,
  251. + clkctl = brcmf_sdiod_regrb(sdiodev,
  252. SBSDIO_FUNC1_CHIPCLKCSR, &err);
  253. if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) {
  254. @@ -3803,50 +3805,77 @@ brcmf_sdio_probe_attach(struct brcmf_sdi
  255. goto fail;
  256. }
  257. - bus->ci = brcmf_chip_attach(bus->sdiodev, &brcmf_sdio_buscore_ops);
  258. + bus->ci = brcmf_chip_attach(sdiodev, &brcmf_sdio_buscore_ops);
  259. if (IS_ERR(bus->ci)) {
  260. brcmf_err("brcmf_chip_attach failed!\n");
  261. bus->ci = NULL;
  262. goto fail;
  263. }
  264. + sdiodev->pdata = brcmf_get_module_param(sdiodev->dev,
  265. + BRCMF_BUSTYPE_SDIO,
  266. + bus->ci->chip,
  267. + bus->ci->chiprev);
  268. + /* platform specific configuration:
  269. + * alignments must be at least 4 bytes for ADMA
  270. + */
  271. + bus->head_align = ALIGNMENT;
  272. + bus->sgentry_align = ALIGNMENT;
  273. + if (sdiodev->pdata) {
  274. + if (sdiodev->pdata->sd_head_align > ALIGNMENT)
  275. + bus->head_align = sdiodev->pdata->sd_head_align;
  276. + if (sdiodev->pdata->sd_sgentry_align > ALIGNMENT)
  277. + bus->sgentry_align = sdiodev->pdata->sd_sgentry_align;
  278. + }
  279. + /* allocate scatter-gather table. sg support
  280. + * will be disabled upon allocation failure.
  281. + */
  282. + brcmf_sdiod_sgtable_alloc(sdiodev);
  283. +
  284. +#ifdef CONFIG_PM_SLEEP
  285. + /* wowl can be supported when KEEP_POWER is true and (WAKE_SDIO_IRQ
  286. + * is true or when platform data OOB irq is true).
  287. + */
  288. + if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) &&
  289. + ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) ||
  290. + (sdiodev->pdata && sdiodev->pdata->oob_irq_supported)))
  291. + sdiodev->bus_if->wowl_supported = true;
  292. +#endif
  293. if (brcmf_sdio_kso_init(bus)) {
  294. brcmf_err("error enabling KSO\n");
  295. goto fail;
  296. }
  297. - if ((bus->sdiodev->pdata) && (bus->sdiodev->pdata->drive_strength))
  298. - drivestrength = bus->sdiodev->pdata->drive_strength;
  299. + if ((sdiodev->pdata) && (sdiodev->pdata->drive_strength))
  300. + drivestrength = sdiodev->pdata->drive_strength;
  301. else
  302. drivestrength = DEFAULT_SDIO_DRIVE_STRENGTH;
  303. - brcmf_sdio_drivestrengthinit(bus->sdiodev, bus->ci, drivestrength);
  304. + brcmf_sdio_drivestrengthinit(sdiodev, bus->ci, drivestrength);
  305. /* Set card control so an SDIO card reset does a WLAN backplane reset */
  306. - reg_val = brcmf_sdiod_regrb(bus->sdiodev,
  307. - SDIO_CCCR_BRCM_CARDCTRL, &err);
  308. + reg_val = brcmf_sdiod_regrb(sdiodev, SDIO_CCCR_BRCM_CARDCTRL, &err);
  309. if (err)
  310. goto fail;
  311. reg_val |= SDIO_CCCR_BRCM_CARDCTRL_WLANRESET;
  312. - brcmf_sdiod_regwb(bus->sdiodev,
  313. - SDIO_CCCR_BRCM_CARDCTRL, reg_val, &err);
  314. + brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_CARDCTRL, reg_val, &err);
  315. if (err)
  316. goto fail;
  317. /* set PMUControl so a backplane reset does PMU state reload */
  318. reg_addr = CORE_CC_REG(brcmf_chip_get_pmu(bus->ci)->base, pmucontrol);
  319. - reg_val = brcmf_sdiod_regrl(bus->sdiodev, reg_addr, &err);
  320. + reg_val = brcmf_sdiod_regrl(sdiodev, reg_addr, &err);
  321. if (err)
  322. goto fail;
  323. reg_val |= (BCMA_CC_PMU_CTL_RES_RELOAD << BCMA_CC_PMU_CTL_RES_SHIFT);
  324. - brcmf_sdiod_regwl(bus->sdiodev, reg_addr, reg_val, &err);
  325. + brcmf_sdiod_regwl(sdiodev, reg_addr, reg_val, &err);
  326. if (err)
  327. goto fail;
  328. - sdio_release_host(bus->sdiodev->func[1]);
  329. + sdio_release_host(sdiodev->func[1]);
  330. brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN);
  331. @@ -3867,7 +3896,7 @@ brcmf_sdio_probe_attach(struct brcmf_sdi
  332. return true;
  333. fail:
  334. - sdio_release_host(bus->sdiodev->func[1]);
  335. + sdio_release_host(sdiodev->func[1]);
  336. return false;
  337. }
  338. @@ -4045,18 +4074,6 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
  339. bus->txminmax = BRCMF_TXMINMAX;
  340. bus->tx_seq = SDPCM_SEQ_WRAP - 1;
  341. - /* platform specific configuration:
  342. - * alignments must be at least 4 bytes for ADMA
  343. - */
  344. - bus->head_align = ALIGNMENT;
  345. - bus->sgentry_align = ALIGNMENT;
  346. - if (sdiodev->pdata) {
  347. - if (sdiodev->pdata->sd_head_align > ALIGNMENT)
  348. - bus->head_align = sdiodev->pdata->sd_head_align;
  349. - if (sdiodev->pdata->sd_sgentry_align > ALIGNMENT)
  350. - bus->sgentry_align = sdiodev->pdata->sd_sgentry_align;
  351. - }
  352. -
  353. /* single-threaded workqueue */
  354. wq = alloc_ordered_workqueue("brcmf_wq/%s", WQ_MEM_RECLAIM,
  355. dev_name(&sdiodev->func[1]->dev));
  356. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
  357. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
  358. @@ -184,7 +184,7 @@ struct brcmf_sdio_dev {
  359. struct brcmf_sdio *bus;
  360. struct device *dev;
  361. struct brcmf_bus *bus_if;
  362. - struct brcmfmac_sdio_platform_data *pdata;
  363. + struct brcmfmac_sdio_pd *pdata;
  364. bool oob_irq_requested;
  365. bool irq_en; /* irq enable flags */
  366. spinlock_t irq_en_lock;
  367. --- a/include/linux/platform_data/brcmfmac-sdio.h
  368. +++ /dev/null
  369. @@ -1,135 +0,0 @@
  370. -/*
  371. - * Copyright (c) 2013 Broadcom Corporation
  372. - *
  373. - * Permission to use, copy, modify, and/or distribute this software for any
  374. - * purpose with or without fee is hereby granted, provided that the above
  375. - * copyright notice and this permission notice appear in all copies.
  376. - *
  377. - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  378. - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  379. - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  380. - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  381. - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  382. - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  383. - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  384. - */
  385. -
  386. -#ifndef _LINUX_BRCMFMAC_PLATFORM_H
  387. -#define _LINUX_BRCMFMAC_PLATFORM_H
  388. -
  389. -/*
  390. - * Platform specific driver functions and data. Through the platform specific
  391. - * device data functions can be provided to help the brcmfmac driver to
  392. - * operate with the device in combination with the used platform.
  393. - *
  394. - * Use the platform data in the following (similar) way:
  395. - *
  396. - *
  397. -#include <brcmfmac_platform.h>
  398. -
  399. -
  400. -static void brcmfmac_power_on(void)
  401. -{
  402. -}
  403. -
  404. -static void brcmfmac_power_off(void)
  405. -{
  406. -}
  407. -
  408. -static void brcmfmac_reset(void)
  409. -{
  410. -}
  411. -
  412. -static struct brcmfmac_sdio_platform_data brcmfmac_sdio_pdata = {
  413. - .power_on = brcmfmac_power_on,
  414. - .power_off = brcmfmac_power_off,
  415. - .reset = brcmfmac_reset
  416. -};
  417. -
  418. -static struct platform_device brcmfmac_device = {
  419. - .name = BRCMFMAC_SDIO_PDATA_NAME,
  420. - .id = PLATFORM_DEVID_NONE,
  421. - .dev.platform_data = &brcmfmac_sdio_pdata
  422. -};
  423. -
  424. -void __init brcmfmac_init_pdata(void)
  425. -{
  426. - brcmfmac_sdio_pdata.oob_irq_supported = true;
  427. - brcmfmac_sdio_pdata.oob_irq_nr = gpio_to_irq(GPIO_BRCMF_SDIO_OOB);
  428. - brcmfmac_sdio_pdata.oob_irq_flags = IORESOURCE_IRQ |
  429. - IORESOURCE_IRQ_HIGHLEVEL;
  430. - platform_device_register(&brcmfmac_device);
  431. -}
  432. - *
  433. - *
  434. - * Note: the brcmfmac can be loaded as module or be statically built-in into
  435. - * the kernel. If built-in then do note that it uses module_init (and
  436. - * module_exit) routines which equal device_initcall. So if you intend to
  437. - * create a module with the platform specific data for the brcmfmac and have
  438. - * it built-in to the kernel then use a higher initcall then device_initcall
  439. - * (see init.h). If this is not done then brcmfmac will load without problems
  440. - * but will not pickup the platform data.
  441. - *
  442. - * When the driver does not "detect" platform driver data then it will continue
  443. - * without reporting anything and just assume there is no data needed. Which is
  444. - * probably true for most platforms.
  445. - *
  446. - * Explanation of the platform_data fields:
  447. - *
  448. - * drive_strength: is the preferred drive_strength to be used for the SDIO
  449. - * pins. If 0 then a default value will be used. This is the target drive
  450. - * strength, the exact drive strength which will be used depends on the
  451. - * capabilities of the device.
  452. - *
  453. - * oob_irq_supported: does the board have support for OOB interrupts. SDIO
  454. - * in-band interrupts are relatively slow and for having less overhead on
  455. - * interrupt processing an out of band interrupt can be used. If the HW
  456. - * supports this then enable this by setting this field to true and configure
  457. - * the oob related fields.
  458. - *
  459. - * oob_irq_nr, oob_irq_flags: the OOB interrupt information. The values are
  460. - * used for registering the irq using request_irq function.
  461. - *
  462. - * broken_sg_support: flag for broken sg list support of SDIO host controller.
  463. - * Set this to true if the SDIO host controller has higher align requirement
  464. - * than 32 bytes for each scatterlist item.
  465. - *
  466. - * sd_head_align: alignment requirement for start of data buffer
  467. - *
  468. - * sd_sgentry_align: length alignment requirement for each sg entry
  469. - *
  470. - * power_on: This function is called by the brcmfmac when the module gets
  471. - * loaded. This can be particularly useful for low power devices. The platform
  472. - * spcific routine may for example decide to power up the complete device.
  473. - * If there is no use-case for this function then provide NULL.
  474. - *
  475. - * power_off: This function is called by the brcmfmac when the module gets
  476. - * unloaded. At this point the device can be powered down or otherwise be reset.
  477. - * So if an actual power_off is not supported but reset is then reset the device
  478. - * when this function gets called. This can be particularly useful for low power
  479. - * devices. If there is no use-case for this function (either power-down or
  480. - * reset) then provide NULL.
  481. - *
  482. - * reset: This function can get called if the device communication broke down.
  483. - * This functionality is particularly useful in case of SDIO type devices. It is
  484. - * possible to reset a dongle via sdio data interface, but it requires that
  485. - * this is fully functional. This function is chip/module specific and this
  486. - * function should return only after the complete reset has completed.
  487. - */
  488. -
  489. -#define BRCMFMAC_SDIO_PDATA_NAME "brcmfmac_sdio"
  490. -
  491. -struct brcmfmac_sdio_platform_data {
  492. - unsigned int drive_strength;
  493. - bool oob_irq_supported;
  494. - unsigned int oob_irq_nr;
  495. - unsigned long oob_irq_flags;
  496. - bool broken_sg_support;
  497. - unsigned short sd_head_align;
  498. - unsigned short sd_sgentry_align;
  499. - void (*power_on)(void);
  500. - void (*power_off)(void);
  501. - void (*reset)(void);
  502. -};
  503. -
  504. -#endif /* _LINUX_BRCMFMAC_PLATFORM_H */
  505. --- /dev/null
  506. +++ b/include/linux/platform_data/brcmfmac.h
  507. @@ -0,0 +1,185 @@
  508. +/*
  509. + * Copyright (c) 201 Broadcom Corporation
  510. + *
  511. + * Permission to use, copy, modify, and/or distribute this software for any
  512. + * purpose with or without fee is hereby granted, provided that the above
  513. + * copyright notice and this permission notice appear in all copies.
  514. + *
  515. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  516. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  517. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  518. + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  519. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  520. + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  521. + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  522. + */
  523. +
  524. +#ifndef _LINUX_BRCMFMAC_PLATFORM_H
  525. +#define _LINUX_BRCMFMAC_PLATFORM_H
  526. +
  527. +
  528. +#define BRCMFMAC_PDATA_NAME "brcmfmac"
  529. +
  530. +#define BRCMFMAC_COUNTRY_BUF_SZ 4
  531. +
  532. +
  533. +/*
  534. + * Platform specific driver functions and data. Through the platform specific
  535. + * device data functions and data can be provided to help the brcmfmac driver to
  536. + * operate with the device in combination with the used platform.
  537. + */
  538. +
  539. +
  540. +/**
  541. + * Note: the brcmfmac can be loaded as module or be statically built-in into
  542. + * the kernel. If built-in then do note that it uses module_init (and
  543. + * module_exit) routines which equal device_initcall. So if you intend to
  544. + * create a module with the platform specific data for the brcmfmac and have
  545. + * it built-in to the kernel then use a higher initcall then device_initcall
  546. + * (see init.h). If this is not done then brcmfmac will load without problems
  547. + * but will not pickup the platform data.
  548. + *
  549. + * When the driver does not "detect" platform driver data then it will continue
  550. + * without reporting anything and just assume there is no data needed. Which is
  551. + * probably true for most platforms.
  552. + */
  553. +
  554. +/**
  555. + * enum brcmf_bus_type - Bus type identifier. Currently SDIO, USB and PCIE are
  556. + * supported.
  557. + */
  558. +enum brcmf_bus_type {
  559. + BRCMF_BUSTYPE_SDIO,
  560. + BRCMF_BUSTYPE_USB,
  561. + BRCMF_BUSTYPE_PCIE
  562. +};
  563. +
  564. +
  565. +/**
  566. + * struct brcmfmac_sdio_pd - SDIO Device specific platform data.
  567. + *
  568. + * @txglomsz: SDIO txglom size. Use 0 if default of driver is to be
  569. + * used.
  570. + * @drive_strength: is the preferred drive_strength to be used for the SDIO
  571. + * pins. If 0 then a default value will be used. This is
  572. + * the target drive strength, the exact drive strength
  573. + * which will be used depends on the capabilities of the
  574. + * device.
  575. + * @oob_irq_supported: does the board have support for OOB interrupts. SDIO
  576. + * in-band interrupts are relatively slow and for having
  577. + * less overhead on interrupt processing an out of band
  578. + * interrupt can be used. If the HW supports this then
  579. + * enable this by setting this field to true and configure
  580. + * the oob related fields.
  581. + * @oob_irq_nr,
  582. + * @oob_irq_flags: the OOB interrupt information. The values are used for
  583. + * registering the irq using request_irq function.
  584. + * @broken_sg_support: flag for broken sg list support of SDIO host controller.
  585. + * Set this to true if the SDIO host controller has higher
  586. + * align requirement than 32 bytes for each scatterlist
  587. + * item.
  588. + * @sd_head_align: alignment requirement for start of data buffer.
  589. + * @sd_sgentry_align: length alignment requirement for each sg entry.
  590. + * @reset: This function can get called if the device communication
  591. + * broke down. This functionality is particularly useful in
  592. + * case of SDIO type devices. It is possible to reset a
  593. + * dongle via sdio data interface, but it requires that
  594. + * this is fully functional. This function is chip/module
  595. + * specific and this function should return only after the
  596. + * complete reset has completed.
  597. + */
  598. +struct brcmfmac_sdio_pd {
  599. + int txglomsz;
  600. + unsigned int drive_strength;
  601. + bool oob_irq_supported;
  602. + unsigned int oob_irq_nr;
  603. + unsigned long oob_irq_flags;
  604. + bool broken_sg_support;
  605. + unsigned short sd_head_align;
  606. + unsigned short sd_sgentry_align;
  607. + void (*reset)(void);
  608. +};
  609. +
  610. +/**
  611. + * struct brcmfmac_pd_cc_entry - Struct for translating user space country code
  612. + * (iso3166) to firmware country code and
  613. + * revision.
  614. + *
  615. + * @iso3166: iso3166 alpha 2 country code string.
  616. + * @cc: firmware country code string.
  617. + * @rev: firmware country code revision.
  618. + */
  619. +struct brcmfmac_pd_cc_entry {
  620. + char iso3166[BRCMFMAC_COUNTRY_BUF_SZ];
  621. + char cc[BRCMFMAC_COUNTRY_BUF_SZ];
  622. + s32 rev;
  623. +};
  624. +
  625. +/**
  626. + * struct brcmfmac_pd_cc - Struct for translating country codes as set by user
  627. + * space to a country code and rev which can be used by
  628. + * firmware.
  629. + *
  630. + * @table_size: number of entries in table (> 0)
  631. + * @table: array of 1 or more elements with translation information.
  632. + */
  633. +struct brcmfmac_pd_cc {
  634. + int table_size;
  635. + struct brcmfmac_pd_cc_entry table[0];
  636. +};
  637. +
  638. +/**
  639. + * struct brcmfmac_pd_device - Device specific platform data. (id/rev/bus_type)
  640. + * is the unique identifier of the device.
  641. + *
  642. + * @id: ID of the device for which this data is. In case of SDIO
  643. + * or PCIE this is the chipid as identified by chip.c In
  644. + * case of USB this is the chipid as identified by the
  645. + * device query.
  646. + * @rev: chip revision, see id.
  647. + * @bus_type: The type of bus. Some chipid/rev exist for different bus
  648. + * types. Each bus type has its own set of settings.
  649. + * @feature_disable: Bitmask of features to disable (override), See feature.c
  650. + * in brcmfmac for details.
  651. + * @country_codes: If available, pointer to struct for translating country
  652. + * codes.
  653. + * @bus: Bus specific (union) device settings. Currently only
  654. + * SDIO.
  655. + */
  656. +struct brcmfmac_pd_device {
  657. + unsigned int id;
  658. + unsigned int rev;
  659. + enum brcmf_bus_type bus_type;
  660. + unsigned int feature_disable;
  661. + struct brcmfmac_pd_cc *country_codes;
  662. + union {
  663. + struct brcmfmac_sdio_pd sdio;
  664. + } bus;
  665. +};
  666. +
  667. +/**
  668. + * struct brcmfmac_platform_data - BRCMFMAC specific platform data.
  669. + *
  670. + * @power_on: This function is called by the brcmfmac driver when the module
  671. + * gets loaded. This can be particularly useful for low power
  672. + * devices. The platform spcific routine may for example decide to
  673. + * power up the complete device. If there is no use-case for this
  674. + * function then provide NULL.
  675. + * @power_off: This function is called by the brcmfmac when the module gets
  676. + * unloaded. At this point the devices can be powered down or
  677. + * otherwise be reset. So if an actual power_off is not supported
  678. + * but reset is supported by the devices then reset the devices
  679. + * when this function gets called. This can be particularly useful
  680. + * for low power devices. If there is no use-case for this
  681. + * function then provide NULL.
  682. + */
  683. +struct brcmfmac_platform_data {
  684. + void (*power_on)(void);
  685. + void (*power_off)(void);
  686. + char *fw_alternative_path;
  687. + int device_count;
  688. + struct brcmfmac_pd_device devices[0];
  689. +};
  690. +
  691. +
  692. +#endif /* _LINUX_BRCMFMAC_PLATFORM_H */