Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

brcmfmac: switch to new platform data

Platform data is only available for sdio. With this patch a new
platform data structure is being used which allows for platform
data for any device and configurable per device. This patch only
switches to the new structure and adds support for SDIO devices.

Reviewed-by: Arend Van Spriel <arend@broadcom.com>
Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

authored by

Hante Meuleman and committed by
Kalle Valo
4d792895 73ef9e64

+282 -222
+2 -13
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
··· 103 103 104 104 int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev) 105 105 { 106 - struct brcmfmac_sdio_platform_data *pdata; 106 + struct brcmfmac_sdio_pd *pdata; 107 107 int ret = 0; 108 108 u8 data; 109 109 u32 addr, gpiocontrol; ··· 173 173 174 174 int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev) 175 175 { 176 - struct brcmfmac_sdio_platform_data *pdata; 176 + struct brcmfmac_sdio_pd *pdata; 177 177 178 178 brcmf_dbg(SDIO, "Entering\n"); 179 179 ··· 1164 1164 dev_set_drvdata(&func->dev, bus_if); 1165 1165 dev_set_drvdata(&sdiodev->func[1]->dev, bus_if); 1166 1166 sdiodev->dev = &sdiodev->func[1]->dev; 1167 - sdiodev->pdata = brcmf_get_module_param(sdiodev->dev); 1168 - 1169 - #ifdef CONFIG_PM_SLEEP 1170 - /* wowl can be supported when KEEP_POWER is true and (WAKE_SDIO_IRQ 1171 - * is true or when platform data OOB irq is true). 1172 - */ 1173 - if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) && 1174 - ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) || 1175 - (sdiodev->pdata && sdiodev->pdata->oob_irq_supported))) 1176 - bus_if->wowl_supported = true; 1177 - #endif 1178 1167 1179 1168 brcmf_sdiod_change_state(sdiodev, BRCMF_SDIOD_DOWN); 1180 1169
+2 -2
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
··· 6459 6459 static s32 brcmf_translate_country_code(struct brcmf_pub *drvr, char alpha2[2], 6460 6460 struct brcmf_fil_country_le *ccreq) 6461 6461 { 6462 - struct cc_translate *country_codes; 6463 - struct cc_entry *cc; 6462 + struct brcmfmac_pd_cc *country_codes; 6463 + struct brcmfmac_pd_cc_entry *cc; 6464 6464 s32 found_index; 6465 6465 int i; 6466 6466
+37 -6
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
··· 80 80 MODULE_PARM_DESC(ignore_probe_fail, "always succeed probe for debugging"); 81 81 #endif 82 82 83 - static struct brcmfmac_sdio_platform_data *brcmfmac_pdata; 83 + static struct brcmfmac_platform_data *brcmfmac_pdata; 84 84 struct brcmf_mp_global_t brcmf_mp_global; 85 85 86 86 int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) ··· 229 229 230 230 static void brcmf_mp_attach(void) 231 231 { 232 + /* If module param firmware path is set then this will always be used, 233 + * if not set then if available use the platform data version. To make 234 + * sure it gets initialized at all, always copy the module param version 235 + */ 232 236 strlcpy(brcmf_mp_global.firmware_path, brcmf_firmware_path, 233 237 BRCMF_FW_ALTPATH_LEN); 238 + if ((brcmfmac_pdata) && (brcmfmac_pdata->fw_alternative_path) && 239 + (brcmf_mp_global.firmware_path[0] == '\0')) { 240 + strlcpy(brcmf_mp_global.firmware_path, 241 + brcmfmac_pdata->fw_alternative_path, 242 + BRCMF_FW_ALTPATH_LEN); 243 + } 234 244 } 235 245 236 - struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev) 246 + struct brcmfmac_sdio_pd *brcmf_get_module_param(struct device *dev, 247 + enum brcmf_bus_type bus_type, 248 + u32 chip, u32 chiprev) 237 249 { 238 - if (!brcmfmac_pdata) 239 - brcmf_of_probe(dev, &brcmfmac_pdata); 240 - return brcmfmac_pdata; 250 + struct brcmfmac_sdio_pd *pdata; 251 + struct brcmfmac_pd_device *device_pd; 252 + int i; 253 + 254 + if (brcmfmac_pdata) { 255 + for (i = 0; i < brcmfmac_pdata->device_count; i++) { 256 + device_pd = &brcmfmac_pdata->devices[i]; 257 + if ((device_pd->bus_type == bus_type) && 258 + (device_pd->id == chip) && 259 + ((device_pd->rev == chiprev) || 260 + (device_pd->rev == -1))) { 261 + brcmf_dbg(INFO, "Platform data for device found\n"); 262 + if (device_pd->bus_type == BRCMF_BUSTYPE_SDIO) 263 + return &device_pd->bus.sdio; 264 + break; 265 + } 266 + } 267 + } 268 + pdata = NULL; 269 + brcmf_of_probe(dev, &pdata); 270 + 271 + return pdata; 241 272 } 242 273 243 274 int brcmf_mp_device_attach(struct brcmf_pub *drvr) ··· 318 287 static struct platform_driver brcmf_pd = { 319 288 .remove = brcmf_common_pd_remove, 320 289 .driver = { 321 - .name = BRCMFMAC_SDIO_PDATA_NAME, 290 + .name = BRCMFMAC_PDATA_NAME, 322 291 } 323 292 }; 324 293
+5 -30
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
··· 16 16 #define BRCMFMAC_COMMON_H 17 17 18 18 #include <linux/platform_device.h> 19 - #include <linux/platform_data/brcmfmac-sdio.h> 19 + #include <linux/platform_data/brcmfmac.h> 20 20 #include "fwil_types.h" 21 21 22 22 extern const u8 ALLFFMAC[ETH_ALEN]; ··· 43 43 extern struct brcmf_mp_global_t brcmf_mp_global; 44 44 45 45 /** 46 - * struct cc_entry - Struct for translating user space country code (iso3166) to 47 - * firmware country code and revision. 48 - * 49 - * @iso3166: iso3166 alpha 2 country code string. 50 - * @cc: firmware country code string. 51 - * @rev: firmware country code revision. 52 - */ 53 - struct cc_entry { 54 - char iso3166[BRCMF_COUNTRY_BUF_SZ]; 55 - char cc[BRCMF_COUNTRY_BUF_SZ]; 56 - s32 rev; 57 - }; 58 - 59 - /** 60 - * struct cc_translate - Struct for translating country codes as set by user 61 - * space to a country code and rev which can be used by 62 - * firmware. 63 - * 64 - * @table_size: number of entries in table (> 0) 65 - * @table: dynamic array of 1 or more elements with translation information. 66 - */ 67 - struct cc_translate { 68 - int table_size; 69 - struct cc_entry table[0]; 70 - }; 71 - 72 - /** 73 46 * struct brcmf_mp_device - Device module paramaters. 74 47 * 75 48 * @sdiod_txglomsz: SDIO txglom size. ··· 61 88 int fcmode; 62 89 bool roamoff; 63 90 bool ignore_probe_fail; 64 - struct cc_translate *country_codes; 91 + struct brcmfmac_pd_cc *country_codes; 65 92 }; 66 93 67 - struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev); 94 + struct brcmfmac_sdio_pd *brcmf_get_module_param(struct device *dev, 95 + enum brcmf_bus_type bus_type, 96 + u32 chip, u32 chiprev); 68 97 int brcmf_mp_device_attach(struct brcmf_pub *drvr); 69 98 void brcmf_mp_device_detach(struct brcmf_pub *drvr); 70 99 #ifdef DEBUG
+1 -2
drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
··· 23 23 #include "common.h" 24 24 #include "of.h" 25 25 26 - void 27 - brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio) 26 + void brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd **sdio) 28 27 { 29 28 struct device_node *np = dev->of_node; 30 29 int irq;
+2 -3
drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
··· 15 15 */ 16 16 #ifdef CONFIG_OF 17 17 void 18 - brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio); 18 + brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd **sdio); 19 19 #else 20 - static void brcmf_of_probe(struct device *dev, 21 - struct brcmfmac_sdio_platform_data **sdio) 20 + static void brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd **sdio) 22 21 { 23 22 } 24 23 #endif /* CONFIG_OF */
+47 -30
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
··· 33 33 #include <linux/bcma/bcma.h> 34 34 #include <linux/debugfs.h> 35 35 #include <linux/vmalloc.h> 36 - #include <linux/platform_data/brcmfmac-sdio.h> 37 - #include <linux/moduleparam.h> 38 36 #include <asm/unaligned.h> 39 37 #include <defs.h> 40 38 #include <brcmu_wifi.h> ··· 42 44 #include "sdio.h" 43 45 #include "chip.h" 44 46 #include "firmware.h" 47 + #include "core.h" 48 + #include "common.h" 45 49 46 50 #define DCMD_RESP_TIMEOUT msecs_to_jiffies(2500) 47 51 #define CTL_DONE_TIMEOUT msecs_to_jiffies(2500) ··· 3775 3775 static bool 3776 3776 brcmf_sdio_probe_attach(struct brcmf_sdio *bus) 3777 3777 { 3778 + struct brcmf_sdio_dev *sdiodev; 3778 3779 u8 clkctl = 0; 3779 3780 int err = 0; 3780 3781 int reg_addr; 3781 3782 u32 reg_val; 3782 3783 u32 drivestrength; 3783 3784 3784 - sdio_claim_host(bus->sdiodev->func[1]); 3785 + sdiodev = bus->sdiodev; 3786 + sdio_claim_host(sdiodev->func[1]); 3785 3787 3786 3788 pr_debug("F1 signature read @0x18000000=0x%4x\n", 3787 - brcmf_sdiod_regrl(bus->sdiodev, SI_ENUM_BASE, NULL)); 3789 + brcmf_sdiod_regrl(sdiodev, SI_ENUM_BASE, NULL)); 3788 3790 3789 3791 /* 3790 3792 * Force PLL off until brcmf_chip_attach() 3791 3793 * programs PLL control regs 3792 3794 */ 3793 3795 3794 - brcmf_sdiod_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, 3796 + brcmf_sdiod_regwb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR, 3795 3797 BRCMF_INIT_CLKCTL1, &err); 3796 3798 if (!err) 3797 - clkctl = brcmf_sdiod_regrb(bus->sdiodev, 3799 + clkctl = brcmf_sdiod_regrb(sdiodev, 3798 3800 SBSDIO_FUNC1_CHIPCLKCSR, &err); 3799 3801 3800 3802 if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) { ··· 3805 3803 goto fail; 3806 3804 } 3807 3805 3808 - bus->ci = brcmf_chip_attach(bus->sdiodev, &brcmf_sdio_buscore_ops); 3806 + bus->ci = brcmf_chip_attach(sdiodev, &brcmf_sdio_buscore_ops); 3809 3807 if (IS_ERR(bus->ci)) { 3810 3808 brcmf_err("brcmf_chip_attach failed!\n"); 3811 3809 bus->ci = NULL; 3812 3810 goto fail; 3813 3811 } 3812 + sdiodev->pdata = brcmf_get_module_param(sdiodev->dev, 3813 + BRCMF_BUSTYPE_SDIO, 3814 + bus->ci->chip, 3815 + bus->ci->chiprev); 3816 + /* platform specific configuration: 3817 + * alignments must be at least 4 bytes for ADMA 3818 + */ 3819 + bus->head_align = ALIGNMENT; 3820 + bus->sgentry_align = ALIGNMENT; 3821 + if (sdiodev->pdata) { 3822 + if (sdiodev->pdata->sd_head_align > ALIGNMENT) 3823 + bus->head_align = sdiodev->pdata->sd_head_align; 3824 + if (sdiodev->pdata->sd_sgentry_align > ALIGNMENT) 3825 + bus->sgentry_align = sdiodev->pdata->sd_sgentry_align; 3826 + } 3827 + /* allocate scatter-gather table. sg support 3828 + * will be disabled upon allocation failure. 3829 + */ 3830 + brcmf_sdiod_sgtable_alloc(sdiodev); 3831 + 3832 + #ifdef CONFIG_PM_SLEEP 3833 + /* wowl can be supported when KEEP_POWER is true and (WAKE_SDIO_IRQ 3834 + * is true or when platform data OOB irq is true). 3835 + */ 3836 + if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) && 3837 + ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) || 3838 + (sdiodev->pdata && sdiodev->pdata->oob_irq_supported))) 3839 + sdiodev->bus_if->wowl_supported = true; 3840 + #endif 3814 3841 3815 3842 if (brcmf_sdio_kso_init(bus)) { 3816 3843 brcmf_err("error enabling KSO\n"); 3817 3844 goto fail; 3818 3845 } 3819 3846 3820 - if ((bus->sdiodev->pdata) && (bus->sdiodev->pdata->drive_strength)) 3821 - drivestrength = bus->sdiodev->pdata->drive_strength; 3847 + if ((sdiodev->pdata) && (sdiodev->pdata->drive_strength)) 3848 + drivestrength = sdiodev->pdata->drive_strength; 3822 3849 else 3823 3850 drivestrength = DEFAULT_SDIO_DRIVE_STRENGTH; 3824 - brcmf_sdio_drivestrengthinit(bus->sdiodev, bus->ci, drivestrength); 3851 + brcmf_sdio_drivestrengthinit(sdiodev, bus->ci, drivestrength); 3825 3852 3826 3853 /* Set card control so an SDIO card reset does a WLAN backplane reset */ 3827 - reg_val = brcmf_sdiod_regrb(bus->sdiodev, 3828 - SDIO_CCCR_BRCM_CARDCTRL, &err); 3854 + reg_val = brcmf_sdiod_regrb(sdiodev, SDIO_CCCR_BRCM_CARDCTRL, &err); 3829 3855 if (err) 3830 3856 goto fail; 3831 3857 3832 3858 reg_val |= SDIO_CCCR_BRCM_CARDCTRL_WLANRESET; 3833 3859 3834 - brcmf_sdiod_regwb(bus->sdiodev, 3835 - SDIO_CCCR_BRCM_CARDCTRL, reg_val, &err); 3860 + brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_CARDCTRL, reg_val, &err); 3836 3861 if (err) 3837 3862 goto fail; 3838 3863 3839 3864 /* set PMUControl so a backplane reset does PMU state reload */ 3840 3865 reg_addr = CORE_CC_REG(brcmf_chip_get_pmu(bus->ci)->base, pmucontrol); 3841 - reg_val = brcmf_sdiod_regrl(bus->sdiodev, reg_addr, &err); 3866 + reg_val = brcmf_sdiod_regrl(sdiodev, reg_addr, &err); 3842 3867 if (err) 3843 3868 goto fail; 3844 3869 3845 3870 reg_val |= (BCMA_CC_PMU_CTL_RES_RELOAD << BCMA_CC_PMU_CTL_RES_SHIFT); 3846 3871 3847 - brcmf_sdiod_regwl(bus->sdiodev, reg_addr, reg_val, &err); 3872 + brcmf_sdiod_regwl(sdiodev, reg_addr, reg_val, &err); 3848 3873 if (err) 3849 3874 goto fail; 3850 3875 3851 - sdio_release_host(bus->sdiodev->func[1]); 3876 + sdio_release_host(sdiodev->func[1]); 3852 3877 3853 3878 brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN); 3854 3879 ··· 3896 3867 return true; 3897 3868 3898 3869 fail: 3899 - sdio_release_host(bus->sdiodev->func[1]); 3870 + sdio_release_host(sdiodev->func[1]); 3900 3871 return false; 3901 3872 } 3902 3873 ··· 4073 4044 bus->rxbound = BRCMF_RXBOUND; 4074 4045 bus->txminmax = BRCMF_TXMINMAX; 4075 4046 bus->tx_seq = SDPCM_SEQ_WRAP - 1; 4076 - 4077 - /* platform specific configuration: 4078 - * alignments must be at least 4 bytes for ADMA 4079 - */ 4080 - bus->head_align = ALIGNMENT; 4081 - bus->sgentry_align = ALIGNMENT; 4082 - if (sdiodev->pdata) { 4083 - if (sdiodev->pdata->sd_head_align > ALIGNMENT) 4084 - bus->head_align = sdiodev->pdata->sd_head_align; 4085 - if (sdiodev->pdata->sd_sgentry_align > ALIGNMENT) 4086 - bus->sgentry_align = sdiodev->pdata->sd_sgentry_align; 4087 - } 4088 4047 4089 4048 /* single-threaded workqueue */ 4090 4049 wq = alloc_ordered_workqueue("brcmf_wq/%s", WQ_MEM_RECLAIM,
+1 -1
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
··· 184 184 struct brcmf_sdio *bus; 185 185 struct device *dev; 186 186 struct brcmf_bus *bus_if; 187 - struct brcmfmac_sdio_platform_data *pdata; 187 + struct brcmfmac_sdio_pd *pdata; 188 188 bool oob_irq_requested; 189 189 bool irq_en; /* irq enable flags */ 190 190 spinlock_t irq_en_lock;
-135
include/linux/platform_data/brcmfmac-sdio.h
··· 1 - /* 2 - * Copyright (c) 2013 Broadcom Corporation 3 - * 4 - * Permission to use, copy, modify, and/or distribute this software for any 5 - * purpose with or without fee is hereby granted, provided that the above 6 - * copyright notice and this permission notice appear in all copies. 7 - * 8 - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11 - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13 - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 - */ 16 - 17 - #ifndef _LINUX_BRCMFMAC_PLATFORM_H 18 - #define _LINUX_BRCMFMAC_PLATFORM_H 19 - 20 - /* 21 - * Platform specific driver functions and data. Through the platform specific 22 - * device data functions can be provided to help the brcmfmac driver to 23 - * operate with the device in combination with the used platform. 24 - * 25 - * Use the platform data in the following (similar) way: 26 - * 27 - * 28 - #include <brcmfmac_platform.h> 29 - 30 - 31 - static void brcmfmac_power_on(void) 32 - { 33 - } 34 - 35 - static void brcmfmac_power_off(void) 36 - { 37 - } 38 - 39 - static void brcmfmac_reset(void) 40 - { 41 - } 42 - 43 - static struct brcmfmac_sdio_platform_data brcmfmac_sdio_pdata = { 44 - .power_on = brcmfmac_power_on, 45 - .power_off = brcmfmac_power_off, 46 - .reset = brcmfmac_reset 47 - }; 48 - 49 - static struct platform_device brcmfmac_device = { 50 - .name = BRCMFMAC_SDIO_PDATA_NAME, 51 - .id = PLATFORM_DEVID_NONE, 52 - .dev.platform_data = &brcmfmac_sdio_pdata 53 - }; 54 - 55 - void __init brcmfmac_init_pdata(void) 56 - { 57 - brcmfmac_sdio_pdata.oob_irq_supported = true; 58 - brcmfmac_sdio_pdata.oob_irq_nr = gpio_to_irq(GPIO_BRCMF_SDIO_OOB); 59 - brcmfmac_sdio_pdata.oob_irq_flags = IORESOURCE_IRQ | 60 - IORESOURCE_IRQ_HIGHLEVEL; 61 - platform_device_register(&brcmfmac_device); 62 - } 63 - * 64 - * 65 - * Note: the brcmfmac can be loaded as module or be statically built-in into 66 - * the kernel. If built-in then do note that it uses module_init (and 67 - * module_exit) routines which equal device_initcall. So if you intend to 68 - * create a module with the platform specific data for the brcmfmac and have 69 - * it built-in to the kernel then use a higher initcall then device_initcall 70 - * (see init.h). If this is not done then brcmfmac will load without problems 71 - * but will not pickup the platform data. 72 - * 73 - * When the driver does not "detect" platform driver data then it will continue 74 - * without reporting anything and just assume there is no data needed. Which is 75 - * probably true for most platforms. 76 - * 77 - * Explanation of the platform_data fields: 78 - * 79 - * drive_strength: is the preferred drive_strength to be used for the SDIO 80 - * pins. If 0 then a default value will be used. This is the target drive 81 - * strength, the exact drive strength which will be used depends on the 82 - * capabilities of the device. 83 - * 84 - * oob_irq_supported: does the board have support for OOB interrupts. SDIO 85 - * in-band interrupts are relatively slow and for having less overhead on 86 - * interrupt processing an out of band interrupt can be used. If the HW 87 - * supports this then enable this by setting this field to true and configure 88 - * the oob related fields. 89 - * 90 - * oob_irq_nr, oob_irq_flags: the OOB interrupt information. The values are 91 - * used for registering the irq using request_irq function. 92 - * 93 - * broken_sg_support: flag for broken sg list support of SDIO host controller. 94 - * Set this to true if the SDIO host controller has higher align requirement 95 - * than 32 bytes for each scatterlist item. 96 - * 97 - * sd_head_align: alignment requirement for start of data buffer 98 - * 99 - * sd_sgentry_align: length alignment requirement for each sg entry 100 - * 101 - * power_on: This function is called by the brcmfmac when the module gets 102 - * loaded. This can be particularly useful for low power devices. The platform 103 - * spcific routine may for example decide to power up the complete device. 104 - * If there is no use-case for this function then provide NULL. 105 - * 106 - * power_off: This function is called by the brcmfmac when the module gets 107 - * unloaded. At this point the device can be powered down or otherwise be reset. 108 - * So if an actual power_off is not supported but reset is then reset the device 109 - * when this function gets called. This can be particularly useful for low power 110 - * devices. If there is no use-case for this function (either power-down or 111 - * reset) then provide NULL. 112 - * 113 - * reset: This function can get called if the device communication broke down. 114 - * This functionality is particularly useful in case of SDIO type devices. It is 115 - * possible to reset a dongle via sdio data interface, but it requires that 116 - * this is fully functional. This function is chip/module specific and this 117 - * function should return only after the complete reset has completed. 118 - */ 119 - 120 - #define BRCMFMAC_SDIO_PDATA_NAME "brcmfmac_sdio" 121 - 122 - struct brcmfmac_sdio_platform_data { 123 - unsigned int drive_strength; 124 - bool oob_irq_supported; 125 - unsigned int oob_irq_nr; 126 - unsigned long oob_irq_flags; 127 - bool broken_sg_support; 128 - unsigned short sd_head_align; 129 - unsigned short sd_sgentry_align; 130 - void (*power_on)(void); 131 - void (*power_off)(void); 132 - void (*reset)(void); 133 - }; 134 - 135 - #endif /* _LINUX_BRCMFMAC_PLATFORM_H */
+185
include/linux/platform_data/brcmfmac.h
··· 1 + /* 2 + * Copyright (c) 201 Broadcom Corporation 3 + * 4 + * Permission to use, copy, modify, and/or distribute this software for any 5 + * purpose with or without fee is hereby granted, provided that the above 6 + * copyright notice and this permission notice appear in all copies. 7 + * 8 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 11 + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 13 + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 14 + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 + */ 16 + 17 + #ifndef _LINUX_BRCMFMAC_PLATFORM_H 18 + #define _LINUX_BRCMFMAC_PLATFORM_H 19 + 20 + 21 + #define BRCMFMAC_PDATA_NAME "brcmfmac" 22 + 23 + #define BRCMFMAC_COUNTRY_BUF_SZ 4 24 + 25 + 26 + /* 27 + * Platform specific driver functions and data. Through the platform specific 28 + * device data functions and data can be provided to help the brcmfmac driver to 29 + * operate with the device in combination with the used platform. 30 + */ 31 + 32 + 33 + /** 34 + * Note: the brcmfmac can be loaded as module or be statically built-in into 35 + * the kernel. If built-in then do note that it uses module_init (and 36 + * module_exit) routines which equal device_initcall. So if you intend to 37 + * create a module with the platform specific data for the brcmfmac and have 38 + * it built-in to the kernel then use a higher initcall then device_initcall 39 + * (see init.h). If this is not done then brcmfmac will load without problems 40 + * but will not pickup the platform data. 41 + * 42 + * When the driver does not "detect" platform driver data then it will continue 43 + * without reporting anything and just assume there is no data needed. Which is 44 + * probably true for most platforms. 45 + */ 46 + 47 + /** 48 + * enum brcmf_bus_type - Bus type identifier. Currently SDIO, USB and PCIE are 49 + * supported. 50 + */ 51 + enum brcmf_bus_type { 52 + BRCMF_BUSTYPE_SDIO, 53 + BRCMF_BUSTYPE_USB, 54 + BRCMF_BUSTYPE_PCIE 55 + }; 56 + 57 + 58 + /** 59 + * struct brcmfmac_sdio_pd - SDIO Device specific platform data. 60 + * 61 + * @txglomsz: SDIO txglom size. Use 0 if default of driver is to be 62 + * used. 63 + * @drive_strength: is the preferred drive_strength to be used for the SDIO 64 + * pins. If 0 then a default value will be used. This is 65 + * the target drive strength, the exact drive strength 66 + * which will be used depends on the capabilities of the 67 + * device. 68 + * @oob_irq_supported: does the board have support for OOB interrupts. SDIO 69 + * in-band interrupts are relatively slow and for having 70 + * less overhead on interrupt processing an out of band 71 + * interrupt can be used. If the HW supports this then 72 + * enable this by setting this field to true and configure 73 + * the oob related fields. 74 + * @oob_irq_nr, 75 + * @oob_irq_flags: the OOB interrupt information. The values are used for 76 + * registering the irq using request_irq function. 77 + * @broken_sg_support: flag for broken sg list support of SDIO host controller. 78 + * Set this to true if the SDIO host controller has higher 79 + * align requirement than 32 bytes for each scatterlist 80 + * item. 81 + * @sd_head_align: alignment requirement for start of data buffer. 82 + * @sd_sgentry_align: length alignment requirement for each sg entry. 83 + * @reset: This function can get called if the device communication 84 + * broke down. This functionality is particularly useful in 85 + * case of SDIO type devices. It is possible to reset a 86 + * dongle via sdio data interface, but it requires that 87 + * this is fully functional. This function is chip/module 88 + * specific and this function should return only after the 89 + * complete reset has completed. 90 + */ 91 + struct brcmfmac_sdio_pd { 92 + int txglomsz; 93 + unsigned int drive_strength; 94 + bool oob_irq_supported; 95 + unsigned int oob_irq_nr; 96 + unsigned long oob_irq_flags; 97 + bool broken_sg_support; 98 + unsigned short sd_head_align; 99 + unsigned short sd_sgentry_align; 100 + void (*reset)(void); 101 + }; 102 + 103 + /** 104 + * struct brcmfmac_pd_cc_entry - Struct for translating user space country code 105 + * (iso3166) to firmware country code and 106 + * revision. 107 + * 108 + * @iso3166: iso3166 alpha 2 country code string. 109 + * @cc: firmware country code string. 110 + * @rev: firmware country code revision. 111 + */ 112 + struct brcmfmac_pd_cc_entry { 113 + char iso3166[BRCMFMAC_COUNTRY_BUF_SZ]; 114 + char cc[BRCMFMAC_COUNTRY_BUF_SZ]; 115 + s32 rev; 116 + }; 117 + 118 + /** 119 + * struct brcmfmac_pd_cc - Struct for translating country codes as set by user 120 + * space to a country code and rev which can be used by 121 + * firmware. 122 + * 123 + * @table_size: number of entries in table (> 0) 124 + * @table: array of 1 or more elements with translation information. 125 + */ 126 + struct brcmfmac_pd_cc { 127 + int table_size; 128 + struct brcmfmac_pd_cc_entry table[0]; 129 + }; 130 + 131 + /** 132 + * struct brcmfmac_pd_device - Device specific platform data. (id/rev/bus_type) 133 + * is the unique identifier of the device. 134 + * 135 + * @id: ID of the device for which this data is. In case of SDIO 136 + * or PCIE this is the chipid as identified by chip.c In 137 + * case of USB this is the chipid as identified by the 138 + * device query. 139 + * @rev: chip revision, see id. 140 + * @bus_type: The type of bus. Some chipid/rev exist for different bus 141 + * types. Each bus type has its own set of settings. 142 + * @feature_disable: Bitmask of features to disable (override), See feature.c 143 + * in brcmfmac for details. 144 + * @country_codes: If available, pointer to struct for translating country 145 + * codes. 146 + * @bus: Bus specific (union) device settings. Currently only 147 + * SDIO. 148 + */ 149 + struct brcmfmac_pd_device { 150 + unsigned int id; 151 + unsigned int rev; 152 + enum brcmf_bus_type bus_type; 153 + unsigned int feature_disable; 154 + struct brcmfmac_pd_cc *country_codes; 155 + union { 156 + struct brcmfmac_sdio_pd sdio; 157 + } bus; 158 + }; 159 + 160 + /** 161 + * struct brcmfmac_platform_data - BRCMFMAC specific platform data. 162 + * 163 + * @power_on: This function is called by the brcmfmac driver when the module 164 + * gets loaded. This can be particularly useful for low power 165 + * devices. The platform spcific routine may for example decide to 166 + * power up the complete device. If there is no use-case for this 167 + * function then provide NULL. 168 + * @power_off: This function is called by the brcmfmac when the module gets 169 + * unloaded. At this point the devices can be powered down or 170 + * otherwise be reset. So if an actual power_off is not supported 171 + * but reset is supported by the devices then reset the devices 172 + * when this function gets called. This can be particularly useful 173 + * for low power devices. If there is no use-case for this 174 + * function then provide NULL. 175 + */ 176 + struct brcmfmac_platform_data { 177 + void (*power_on)(void); 178 + void (*power_off)(void); 179 + char *fw_alternative_path; 180 + int device_count; 181 + struct brcmfmac_pd_device devices[0]; 182 + }; 183 + 184 + 185 + #endif /* _LINUX_BRCMFMAC_PLATFORM_H */