Skip to content

Commit 4d79289

Browse files
Hante MeulemanKalle Valo
authored andcommitted
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 <[email protected]> Reviewed-by: Franky (Zhenhui) Lin <[email protected]> Reviewed-by: Pieter-Paul Giesberts <[email protected]> Signed-off-by: Hante Meuleman <[email protected]> Signed-off-by: Arend van Spriel <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 73ef9e6 commit 4d79289

File tree

10 files changed

+282
-222
lines changed

10 files changed

+282
-222
lines changed

drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static void brcmf_sdiod_dummy_irqhandler(struct sdio_func *func)
103103

104104
int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
105105
{
106-
struct brcmfmac_sdio_platform_data *pdata;
106+
struct brcmfmac_sdio_pd *pdata;
107107
int ret = 0;
108108
u8 data;
109109
u32 addr, gpiocontrol;
@@ -173,7 +173,7 @@ int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
173173

174174
int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev)
175175
{
176-
struct brcmfmac_sdio_platform_data *pdata;
176+
struct brcmfmac_sdio_pd *pdata;
177177

178178
brcmf_dbg(SDIO, "Entering\n");
179179

@@ -1164,17 +1164,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
11641164
dev_set_drvdata(&func->dev, bus_if);
11651165
dev_set_drvdata(&sdiodev->func[1]->dev, bus_if);
11661166
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
11781167

11791168
brcmf_sdiod_change_state(sdiodev, BRCMF_SDIOD_DOWN);
11801169

drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6459,8 +6459,8 @@ int brcmf_cfg80211_wait_vif_event(struct brcmf_cfg80211_info *cfg,
64596459
static s32 brcmf_translate_country_code(struct brcmf_pub *drvr, char alpha2[2],
64606460
struct brcmf_fil_country_le *ccreq)
64616461
{
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;
64646464
s32 found_index;
64656465
int i;
64666466

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module_param_named(ignore_probe_fail, brcmf_ignore_probe_fail, int, 0);
8080
MODULE_PARM_DESC(ignore_probe_fail, "always succeed probe for debugging");
8181
#endif
8282

83-
static struct brcmfmac_sdio_platform_data *brcmfmac_pdata;
83+
static struct brcmfmac_platform_data *brcmfmac_pdata;
8484
struct brcmf_mp_global_t brcmf_mp_global;
8585

8686
int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
@@ -229,15 +229,46 @@ void __brcmf_dbg(u32 level, const char *func, const char *fmt, ...)
229229

230230
static void brcmf_mp_attach(void)
231231
{
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+
*/
232236
strlcpy(brcmf_mp_global.firmware_path, brcmf_firmware_path,
233237
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+
}
234244
}
235245

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)
237249
{
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;
241272
}
242273

243274
int brcmf_mp_device_attach(struct brcmf_pub *drvr)
@@ -287,7 +318,7 @@ static int brcmf_common_pd_remove(struct platform_device *pdev)
287318
static struct platform_driver brcmf_pd = {
288319
.remove = brcmf_common_pd_remove,
289320
.driver = {
290-
.name = BRCMFMAC_SDIO_PDATA_NAME,
321+
.name = BRCMFMAC_PDATA_NAME,
291322
}
292323
};
293324

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define BRCMFMAC_COMMON_H
1717

1818
#include <linux/platform_device.h>
19-
#include <linux/platform_data/brcmfmac-sdio.h>
19+
#include <linux/platform_data/brcmfmac.h>
2020
#include "fwil_types.h"
2121

2222
extern const u8 ALLFFMAC[ETH_ALEN];
@@ -42,33 +42,6 @@ struct brcmf_mp_global_t {
4242

4343
extern struct brcmf_mp_global_t brcmf_mp_global;
4444

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-
7245
/**
7346
* struct brcmf_mp_device - Device module paramaters.
7447
*
@@ -88,10 +61,12 @@ struct brcmf_mp_device {
8861
int fcmode;
8962
bool roamoff;
9063
bool ignore_probe_fail;
91-
struct cc_translate *country_codes;
64+
struct brcmfmac_pd_cc *country_codes;
9265
};
9366

94-
struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev);
67+
struct brcmfmac_sdio_pd *brcmf_get_module_param(struct device *dev,
68+
enum brcmf_bus_type bus_type,
69+
u32 chip, u32 chiprev);
9570
int brcmf_mp_device_attach(struct brcmf_pub *drvr);
9671
void brcmf_mp_device_detach(struct brcmf_pub *drvr);
9772
#ifdef DEBUG

drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
#include "common.h"
2424
#include "of.h"
2525

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)
2827
{
2928
struct device_node *np = dev->of_node;
3029
int irq;

drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
*/
1616
#ifdef CONFIG_OF
1717
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);
1919
#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)
2221
{
2322
}
2423
#endif /* CONFIG_OF */

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
#include <linux/bcma/bcma.h>
3434
#include <linux/debugfs.h>
3535
#include <linux/vmalloc.h>
36-
#include <linux/platform_data/brcmfmac-sdio.h>
37-
#include <linux/moduleparam.h>
3836
#include <asm/unaligned.h>
3937
#include <defs.h>
4038
#include <brcmu_wifi.h>
@@ -44,6 +42,8 @@
4442
#include "sdio.h"
4543
#include "chip.h"
4644
#include "firmware.h"
45+
#include "core.h"
46+
#include "common.h"
4747

4848
#define DCMD_RESP_TIMEOUT msecs_to_jiffies(2500)
4949
#define CTL_DONE_TIMEOUT msecs_to_jiffies(2500)
@@ -3775,26 +3775,28 @@ static const struct brcmf_buscore_ops brcmf_sdio_buscore_ops = {
37753775
static bool
37763776
brcmf_sdio_probe_attach(struct brcmf_sdio *bus)
37773777
{
3778+
struct brcmf_sdio_dev *sdiodev;
37783779
u8 clkctl = 0;
37793780
int err = 0;
37803781
int reg_addr;
37813782
u32 reg_val;
37823783
u32 drivestrength;
37833784

3784-
sdio_claim_host(bus->sdiodev->func[1]);
3785+
sdiodev = bus->sdiodev;
3786+
sdio_claim_host(sdiodev->func[1]);
37853787

37863788
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));
37883790

37893791
/*
37903792
* Force PLL off until brcmf_chip_attach()
37913793
* programs PLL control regs
37923794
*/
37933795

3794-
brcmf_sdiod_regwb(bus->sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
3796+
brcmf_sdiod_regwb(sdiodev, SBSDIO_FUNC1_CHIPCLKCSR,
37953797
BRCMF_INIT_CLKCTL1, &err);
37963798
if (!err)
3797-
clkctl = brcmf_sdiod_regrb(bus->sdiodev,
3799+
clkctl = brcmf_sdiod_regrb(sdiodev,
37983800
SBSDIO_FUNC1_CHIPCLKCSR, &err);
37993801

38003802
if (err || ((clkctl & ~SBSDIO_AVBITS) != BRCMF_INIT_CLKCTL1)) {
@@ -3803,50 +3805,77 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus)
38033805
goto fail;
38043806
}
38053807

3806-
bus->ci = brcmf_chip_attach(bus->sdiodev, &brcmf_sdio_buscore_ops);
3808+
bus->ci = brcmf_chip_attach(sdiodev, &brcmf_sdio_buscore_ops);
38073809
if (IS_ERR(bus->ci)) {
38083810
brcmf_err("brcmf_chip_attach failed!\n");
38093811
bus->ci = NULL;
38103812
goto fail;
38113813
}
3814+
sdiodev->pdata = brcmf_get_module_param(sdiodev->dev,
3815+
BRCMF_BUSTYPE_SDIO,
3816+
bus->ci->chip,
3817+
bus->ci->chiprev);
3818+
/* platform specific configuration:
3819+
* alignments must be at least 4 bytes for ADMA
3820+
*/
3821+
bus->head_align = ALIGNMENT;
3822+
bus->sgentry_align = ALIGNMENT;
3823+
if (sdiodev->pdata) {
3824+
if (sdiodev->pdata->sd_head_align > ALIGNMENT)
3825+
bus->head_align = sdiodev->pdata->sd_head_align;
3826+
if (sdiodev->pdata->sd_sgentry_align > ALIGNMENT)
3827+
bus->sgentry_align = sdiodev->pdata->sd_sgentry_align;
3828+
}
3829+
/* allocate scatter-gather table. sg support
3830+
* will be disabled upon allocation failure.
3831+
*/
3832+
brcmf_sdiod_sgtable_alloc(sdiodev);
3833+
3834+
#ifdef CONFIG_PM_SLEEP
3835+
/* wowl can be supported when KEEP_POWER is true and (WAKE_SDIO_IRQ
3836+
* is true or when platform data OOB irq is true).
3837+
*/
3838+
if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) &&
3839+
((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) ||
3840+
(sdiodev->pdata && sdiodev->pdata->oob_irq_supported)))
3841+
sdiodev->bus_if->wowl_supported = true;
3842+
#endif
38123843

38133844
if (brcmf_sdio_kso_init(bus)) {
38143845
brcmf_err("error enabling KSO\n");
38153846
goto fail;
38163847
}
38173848

3818-
if ((bus->sdiodev->pdata) && (bus->sdiodev->pdata->drive_strength))
3819-
drivestrength = bus->sdiodev->pdata->drive_strength;
3849+
if ((sdiodev->pdata) && (sdiodev->pdata->drive_strength))
3850+
drivestrength = sdiodev->pdata->drive_strength;
38203851
else
38213852
drivestrength = DEFAULT_SDIO_DRIVE_STRENGTH;
3822-
brcmf_sdio_drivestrengthinit(bus->sdiodev, bus->ci, drivestrength);
3853+
brcmf_sdio_drivestrengthinit(sdiodev, bus->ci, drivestrength);
38233854

38243855
/* Set card control so an SDIO card reset does a WLAN backplane reset */
3825-
reg_val = brcmf_sdiod_regrb(bus->sdiodev,
3826-
SDIO_CCCR_BRCM_CARDCTRL, &err);
3856+
reg_val = brcmf_sdiod_regrb(sdiodev, SDIO_CCCR_BRCM_CARDCTRL, &err);
38273857
if (err)
38283858
goto fail;
38293859

38303860
reg_val |= SDIO_CCCR_BRCM_CARDCTRL_WLANRESET;
38313861

3832-
brcmf_sdiod_regwb(bus->sdiodev,
3833-
SDIO_CCCR_BRCM_CARDCTRL, reg_val, &err);
3862+
brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_CARDCTRL, reg_val, &err);
38343863
if (err)
38353864
goto fail;
38363865

38373866
/* set PMUControl so a backplane reset does PMU state reload */
38383867
reg_addr = CORE_CC_REG(brcmf_chip_get_pmu(bus->ci)->base, pmucontrol);
3839-
reg_val = brcmf_sdiod_regrl(bus->sdiodev, reg_addr, &err);
3868+
reg_val = brcmf_sdiod_regrl(sdiodev, reg_addr, &err);
38403869
if (err)
38413870
goto fail;
38423871

38433872
reg_val |= (BCMA_CC_PMU_CTL_RES_RELOAD << BCMA_CC_PMU_CTL_RES_SHIFT);
38443873

3845-
brcmf_sdiod_regwl(bus->sdiodev, reg_addr, reg_val, &err);
3874+
brcmf_sdiod_regwl(sdiodev, reg_addr, reg_val, &err);
38463875
if (err)
38473876
goto fail;
38483877

3849-
sdio_release_host(bus->sdiodev->func[1]);
3878+
sdio_release_host(sdiodev->func[1]);
38503879

38513880
brcmu_pktq_init(&bus->txq, (PRIOMASK + 1), TXQLEN);
38523881

@@ -3867,7 +3896,7 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus)
38673896
return true;
38683897

38693898
fail:
3870-
sdio_release_host(bus->sdiodev->func[1]);
3899+
sdio_release_host(sdiodev->func[1]);
38713900
return false;
38723901
}
38733902

@@ -4045,18 +4074,6 @@ struct brcmf_sdio *brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev)
40454074
bus->txminmax = BRCMF_TXMINMAX;
40464075
bus->tx_seq = SDPCM_SEQ_WRAP - 1;
40474076

4048-
/* platform specific configuration:
4049-
* alignments must be at least 4 bytes for ADMA
4050-
*/
4051-
bus->head_align = ALIGNMENT;
4052-
bus->sgentry_align = ALIGNMENT;
4053-
if (sdiodev->pdata) {
4054-
if (sdiodev->pdata->sd_head_align > ALIGNMENT)
4055-
bus->head_align = sdiodev->pdata->sd_head_align;
4056-
if (sdiodev->pdata->sd_sgentry_align > ALIGNMENT)
4057-
bus->sgentry_align = sdiodev->pdata->sd_sgentry_align;
4058-
}
4059-
40604077
/* single-threaded workqueue */
40614078
wq = alloc_ordered_workqueue("brcmf_wq/%s", WQ_MEM_RECLAIM,
40624079
dev_name(&sdiodev->func[1]->dev));

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ struct brcmf_sdio_dev {
184184
struct brcmf_sdio *bus;
185185
struct device *dev;
186186
struct brcmf_bus *bus_if;
187-
struct brcmfmac_sdio_platform_data *pdata;
187+
struct brcmfmac_sdio_pd *pdata;
188188
bool oob_irq_requested;
189189
bool irq_en; /* irq enable flags */
190190
spinlock_t irq_en_lock;

0 commit comments

Comments
 (0)