-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
brcmfmac: introduce feature and quirk handling
Introducing a new source module that will be responsible for identifying features and quirks related to the device being handled. Reviewed-by: Hante Meuleman <meuleman@broadcom.com> Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com> Reviewed-by: Daniel (Deognyoun) Kim <dekim@broadcom.com> Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
- Loading branch information
Arend van Spriel
authored and
John W. Linville
committed
Jul 15, 2014
1 parent
ccfd1e8
commit c08437b
Showing
6 changed files
with
244 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/* | ||
* Copyright (c) 2014 Broadcom Corporation | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | ||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#include <linux/netdevice.h> | ||
|
||
#include <brcm_hw_ids.h> | ||
#include "dhd.h" | ||
#include "dhd_bus.h" | ||
#include "dhd_dbg.h" | ||
#include "fwil.h" | ||
#include "feature.h" | ||
|
||
/* | ||
* firmware error code received if iovar is unsupported. | ||
*/ | ||
#define EBRCMF_FEAT_UNSUPPORTED 23 | ||
|
||
/* | ||
* expand feature list to array of feature strings. | ||
*/ | ||
#define BRCMF_FEAT_DEF(_f) \ | ||
#_f, | ||
static const char *brcmf_feat_names[] = { | ||
BRCMF_FEAT_LIST | ||
}; | ||
#undef BRCMF_FEAT_DEF | ||
|
||
#ifdef DEBUG | ||
/* | ||
* expand quirk list to array of quirk strings. | ||
*/ | ||
#define BRCMF_QUIRK_DEF(_q) \ | ||
#_q, | ||
static const char * const brcmf_quirk_names[] = { | ||
BRCMF_QUIRK_LIST | ||
}; | ||
#undef BRCMF_QUIRK_DEF | ||
|
||
/** | ||
* brcmf_feat_debugfs_read() - expose feature info to debugfs. | ||
* | ||
* @seq: sequence for debugfs entry. | ||
* @data: raw data pointer. | ||
*/ | ||
static int brcmf_feat_debugfs_read(struct seq_file *seq, void *data) | ||
{ | ||
struct brcmf_bus *bus_if = dev_get_drvdata(seq->private); | ||
u32 feats = bus_if->drvr->feat_flags; | ||
u32 quirks = bus_if->drvr->chip_quirks; | ||
int id; | ||
|
||
seq_printf(seq, "Features: %08x\n", feats); | ||
for (id = 0; id < BRCMF_FEAT_LAST; id++) | ||
if (feats & BIT(id)) | ||
seq_printf(seq, "\t%s\n", brcmf_feat_names[id]); | ||
seq_printf(seq, "\nQuirks: %08x\n", quirks); | ||
for (id = 0; id < BRCMF_FEAT_QUIRK_LAST; id++) | ||
if (quirks & BIT(id)) | ||
seq_printf(seq, "\t%s\n", brcmf_quirk_names[id]); | ||
return 0; | ||
} | ||
#else | ||
static int brcmf_feat_debugfs_read(struct seq_file *seq, void *data) | ||
{ | ||
return 0; | ||
} | ||
#endif /* DEBUG */ | ||
|
||
/** | ||
* brcmf_feat_iovar_int_get() - determine feature through iovar query. | ||
* | ||
* @ifp: interface to query. | ||
* @id: feature id. | ||
* @name: iovar name. | ||
*/ | ||
static void brcmf_feat_iovar_int_get(struct brcmf_if *ifp, | ||
enum brcmf_feat_id id, char *name) | ||
{ | ||
u32 data; | ||
int err; | ||
|
||
err = brcmf_fil_iovar_int_get(ifp, name, &data); | ||
if (err == 0) { | ||
brcmf_dbg(INFO, "enabling feature: %s\n", brcmf_feat_names[id]); | ||
ifp->drvr->feat_flags |= BIT(id); | ||
} else { | ||
brcmf_dbg(TRACE, "%s feature check failed: %d\n", | ||
brcmf_feat_names[id], err); | ||
} | ||
} | ||
|
||
void brcmf_feat_attach(struct brcmf_pub *drvr) | ||
{ | ||
struct brcmf_if *ifp = drvr->iflist[0]; | ||
|
||
brcmf_feat_iovar_int_get(ifp, BRCMF_FEAT_MCHAN, "mchan"); | ||
|
||
/* set chip related quirks */ | ||
switch (drvr->bus_if->chip) { | ||
case BRCM_CC_43236_CHIP_ID: | ||
drvr->chip_quirks |= BIT(BRCMF_FEAT_QUIRK_AUTO_AUTH); | ||
break; | ||
case BRCM_CC_4329_CHIP_ID: | ||
drvr->chip_quirks |= BIT(BRCMF_FEAT_QUIRK_NEED_MPC); | ||
break; | ||
default: | ||
/* no quirks */ | ||
break; | ||
} | ||
|
||
brcmf_debugfs_add_entry(drvr, "features", brcmf_feat_debugfs_read); | ||
} | ||
|
||
bool brcmf_feat_is_enabled(struct brcmf_if *ifp, enum brcmf_feat_id id) | ||
{ | ||
return (ifp->drvr->feat_flags & BIT(id)); | ||
} | ||
|
||
bool brcmf_feat_is_quirk_enabled(struct brcmf_if *ifp, | ||
enum brcmf_feat_quirk quirk) | ||
{ | ||
return (ifp->drvr->chip_quirks & BIT(quirk)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Copyright (c) 2014 Broadcom Corporation | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | ||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION | ||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | ||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
#ifndef _BRCMF_FEATURE_H | ||
#define _BRCMF_FEATURE_H | ||
|
||
/* | ||
* Features: | ||
* | ||
* MCHAN: multi-channel for concurrent P2P. | ||
*/ | ||
#define BRCMF_FEAT_LIST \ | ||
BRCMF_FEAT_DEF(MCHAN) | ||
/* | ||
* Quirks: | ||
* | ||
* AUTO_AUTH: workaround needed for automatic authentication type. | ||
* NEED_MPC: driver needs to disable MPC during scanning operation. | ||
*/ | ||
#define BRCMF_QUIRK_LIST \ | ||
BRCMF_QUIRK_DEF(AUTO_AUTH) \ | ||
BRCMF_QUIRK_DEF(NEED_MPC) | ||
|
||
#define BRCMF_FEAT_DEF(_f) \ | ||
BRCMF_FEAT_ ## _f, | ||
/* | ||
* expand feature list to enumeration. | ||
*/ | ||
enum brcmf_feat_id { | ||
BRCMF_FEAT_LIST | ||
BRCMF_FEAT_LAST | ||
}; | ||
#undef BRCMF_FEAT_DEF | ||
|
||
#define BRCMF_QUIRK_DEF(_q) \ | ||
BRCMF_FEAT_QUIRK_ ## _q, | ||
/* | ||
* expand quirk list to enumeration. | ||
*/ | ||
enum brcmf_feat_quirk { | ||
BRCMF_QUIRK_LIST | ||
BRCMF_FEAT_QUIRK_LAST | ||
}; | ||
#undef BRCMF_QUIRK_DEF | ||
|
||
/** | ||
* brcmf_feat_attach() - determine features and quirks. | ||
* | ||
* @drvr: driver instance. | ||
*/ | ||
void brcmf_feat_attach(struct brcmf_pub *drvr); | ||
|
||
/** | ||
* brcmf_feat_is_enabled() - query feature. | ||
* | ||
* @ifp: interface instance. | ||
* @id: feature id to check. | ||
* | ||
* Return: true is feature is enabled; otherwise false. | ||
*/ | ||
bool brcmf_feat_is_enabled(struct brcmf_if *ifp, enum brcmf_feat_id id); | ||
|
||
/** | ||
* brcmf_feat_is_quirk_enabled() - query chip quirk. | ||
* | ||
* @ifp: interface instance. | ||
* @quirk: quirk id to check. | ||
* | ||
* Return: true is quirk is enabled; otherwise false. | ||
*/ | ||
bool brcmf_feat_is_quirk_enabled(struct brcmf_if *ifp, | ||
enum brcmf_feat_quirk quirk); | ||
|
||
#endif /* _BRCMF_FEATURE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters