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