bcma: expose cc sprom for read/write in sysfs
cover bcma: expose cc sprom for read/write in sysfs
The ssb driver exposes the device SPROM to sysfs, which allows users to modify various device settings using ssb-sprom from the b43-tools package.
These patches implement similar functionality in bcma, so that ssb-sprom can be used with newer Broadcom devices.
Saul St. John (2):
bcma: register cc core driver, device
bcma: expose cc sprom to sysfs
drivers/bcma/bcma_private.h | 5 + drivers/bcma/driver_chipcommon.c | 212 ++++++++++++++++++++++++--- drivers/bcma/main.c | 79 +++++----- drivers/bcma/sprom.c | 47 +++++- include/linux/bcma/bcma_driver_chipcommon.h | 4 +- 5 files changed, 287 insertions(+), 60 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/2 bcma: register cc core driver, device
This patch adds a device driver for the ChipCommon core ("bcma-cc-core"), registers that driver during module initialization, and registers the CC device if present with device_register().
Tested on a MacBookPro8,2 with BCM4331.
--- drivers/bcma/bcma_private.h | 1 + drivers/bcma/driver_chipcommon.c | 51 +++++++++++------ drivers/bcma/main.c | 79 ++++++++++++++------------- include/linux/bcma/bcma_driver_chipcommon.h | 2 - 4 files changed, 75 insertions(+), 58 deletions(-)
drivers/bcma/bcma_private.h +1 -0
@@ -46,6 +46,7 @@ int bcma_sprom_get(struct bcma_bus *bus);#ifdef CONFIG_BCMA_DRIVER_MIPS void bcma_chipco_serial_init (struct bcma_drv_cc *cc);#endif /* CONFIG_BCMA_DRIVER_MIPS */ +extern struct bcma_driver bcma_core_cc_driver;/* driver_chipcommon_pmu.c */ u32 bcma_pmu_alp_clock (struct bcma_drv_cc *cc);
drivers/bcma/driver_chipcommon.c +34 -17
77 lines not on this page · raw message
drivers/bcma/main.c +40 -39
132 lines not on this page · raw message
include/linux/bcma/bcma_driver_chipcommon.h +0 -2
@@ -469,8 +469,6 @@ struct bcma_drv_cc {#define bcma_cc_maskset32 (cc, offset, mask, set) \ bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set)) -extern void bcma_core_chipcommon_init (struct bcma_drv_cc *cc); -extern void bcma_chipco_suspend (struct bcma_drv_cc *cc);extern void bcma_chipco_resume (struct bcma_drv_cc *cc);
Signature · 1 line
1.7.10.4
PATCH 2/2 bcma: expose cc sprom to sysfs
In reply to Saul St. JohnOn BCMA devices with a ChipCommon core of revision 31 or higher, the device SPROM can be accessed through CC core registers. This patch exposes the SPROM on such devices for read/write access as a sysfs attribute.
Tested on a MacBookPro8,2 with BCM4331.
--- drivers/bcma/bcma_private.h | 4 + drivers/bcma/driver_chipcommon.c | 163 ++++++++++++++++++++++++++- drivers/bcma/sprom.c | 47 +++++++- include/linux/bcma/bcma_driver_chipcommon.h | 2 + 4 files changed, 213 insertions(+), 3 deletions(-)
drivers/bcma/bcma_private.h +4 -0
@@ -41,6 +41,10 @@ void bcma_init_bus(struct bcma_bus *bus);/* sprom.c */ int bcma_sprom_get (struct bcma_bus *bus); +int bcma_sprom_valid (const u16 *sprom); +void bcma_sprom_extract_r8 (struct bcma_bus *bus,const u16 *sprom); +int bcma_sprom_fromhex (u16 *sprom,const char *dump,size_t len); +int bcma_sprom_tohex (const u16 *sprom,char *buf,size_t buf_len);/* driver_chipcommon.c */ #ifdef CONFIG_BCMA_DRIVER_MIPS
drivers/bcma/driver_chipcommon.c +162 -1
182 lines not on this page · raw message
drivers/bcma/sprom.c +45 -2
68 lines not on this page · raw message
include/linux/bcma/bcma_driver_chipcommon.h +2 -0
@@ -251,6 +251,8 @@#define BCMA_CC_FLASH_CFG_DS 0x0010/* Data size, 0=8bit, 1=16bit */ #define BCMA_CC_FLASH_WAITCNT 0x012C#define BCMA_CC_SROM_CONTROL 0x0190 +#define BCMA_CC_SROM_ADDRESS 0x0194 +#define BCMA_CC_SROM_DATA 0x0198#define BCMA_CC_SROM_CONTROL_START 0x80000000#define BCMA_CC_SROM_CONTROL_BUSY 0x80000000#define BCMA_CC_SROM_CONTROL_OPCODE 0x60000000
Signature · 1 line
1.7.10.4
Re: [PATCH 2/2] bcma: expose cc sprom to sysfs
Quoted 9 lines · Saul St. John
On BCMA devices with a ChipCommon core of revision 31 or higher, the device SPROM can be accessed through CC core registers. This patch exposes the SPROM on such devices for read/write access as a sysfs attribute.
Tested on a MacBookPro8,2 with BCM4331.
Cc Rafał Miłecki <[email protected]>Cc John W. Linville <[email protected]>Signed-off-by Saul St. John <[email protected]>
Hi Saul,
I was still planning to come back to your reply on August 14. Just wanted to reply to this patch as I still feel it is a bad thing to open up the sprom as a whole. I can see the use-cases you mentioned as useful, but maybe we can get a specific solution for that.
Gr. AvS
Re: [PATCH 2/2] bcma: expose cc sprom to sysfs
On Fri, Aug 17, 2012 at 03:47:28PM +0200, Arend van Spriel wrote:
[snip]
Quoted 10 lines
Hi Saul,
I was still planning to come back to your reply on August 14. Just wanted to reply to this patch as I still feel it is a bad thing to open up the sprom as a whole. I can see the use-cases you mentioned as useful, but maybe we can get a specific solution for that.
Gr. AvS
Hi Arend!
Apologies for forking the discussion. I just wasn't sure that any more replies would be forthcoming.
I'm curious why you feel it's a "bad" thing to open up the sprom as a whole. I see a number of distinct advantages to it; most prominently, that it allows for the use of existing tools and processes. I can find several examples of end-users attempting to modify the sprom on bcma devices using the instructions from b43-tools ([1][2][3]), and suggest that it would be confusing to those users were the procedures for sprom-modification through bcma substantially different than the procedures through ssb.
That said, I do recognize that this functionality is potentially dangerous in some circumstances. I'd considered hiding it behind a non-default module parameter-- would that assuage your concerns? Alternatively, if you have specific solutions in mind for the use-cases previously discussed, I'm very interested in knowing them.
-saul
[1] http://ubuntuforums.org/showthread.php?t=1830739
[2] http://www.tonymacx86.com/network/25669-rebranding-bcm94322mc-based-prasys-guide-what-device-id-8.html#post291328
[3] http://www.tonymacx86.com/network/26904-help-rebrand-broadcom-bcm94322-5.html
Re: [PATCH 2/2] bcma: expose cc sprom to sysfs
Quoted 2 lines · Saul St. John
[2] http://www.tonymacx86.com/network/25669-rebranding-bcm94322mc-based-prasys-guide-what-device-id-8.html#post291328
[3] http://www.tonymacx86.com/network/26904-help-rebrand-broadcom-bcm94322-5.html
Sorry, these two references are not actually on point. Please ignore them, my grep-fu is off today.
Rafał Miłecki
maintainerRe: [PATCH 2/2] bcma: expose cc sprom to sysfs
In reply to Arend van Spriel2012/8/17 Arend van Spriel <[email protected]>:
Quoted 14 lines · Saul St. John
Quoted 11 lines
On BCMA devices with a ChipCommon core of revision 31 or higher, the device
SPROM can be accessed through CC core registers. This patch exposes the SPROM on such devices for read/write access as a sysfs attribute.Tested on a MacBookPro8,2 with BCM4331.
Cc Rafał Miłecki <[email protected]>Cc John W. Linville <[email protected]>Signed-off-by Saul St. John <[email protected]>
Quoted 6 lines
Hi Saul,
I was still planning to come back to your reply on August 14. Just wanted to reply to this patch as I still feel it is a bad thing to open up the sprom as a whole. I can see the use-cases you mentioned as useful, but maybe we can get a specific solution for that.
I agree with Arend's doubts, on the other hand it would be nice to provide some workaround for that stupid HP wifi blacklisting.
Providing a way to overwrite just a vendor is really close to allowing overwriting anything. In that case we probably should just allow writing whole SPROM... Which again, is sth some want to avoid.
I wonder if we could write some user-space tool for writing SPROM. Accessing ChipCommon registers is quite trivial, the thing I'm not familiar with is accessing PCIE Wifi card registers. I know there are tools for accessing GPU card regs. They work really well, I wonder if we can use the same method for Wifi cards?
If so, we could write user-space app and keep this out of kernel. Maybe we could even extend that tool to cover ssb cards and drop SPROM on SSB writing support from kernel?
Signature · 1 line
Rafał
Re: [PATCH 2/2] bcma: expose cc sprom to sysfs
Quoted 30 lines · Rafał Miłecki
2012/8/17 Arend van Spriel <[email protected]>:
Quoted 14 lines · Saul St. John
Quoted 11 lines
On BCMA devices with a ChipCommon core of revision 31 or higher, the device
SPROM can be accessed through CC core registers. This patch exposes the SPROM on such devices for read/write access as a sysfs attribute.Tested on a MacBookPro8,2 with BCM4331.
Cc Rafał Miłecki <[email protected]>Cc John W. Linville <[email protected]>Signed-off-by Saul St. John <[email protected]>Quoted 6 lines
Hi Saul,
I was still planning to come back to your reply on August 14. Just wanted to reply to this patch as I still feel it is a bad thing to open up the sprom as a whole. I can see the use-cases you mentioned as useful, but maybe we can get a specific solution for that.
I agree with Arend's doubts, on the other hand it would be nice to provide some workaround for that stupid HP wifi blacklisting.
Providing a way to overwrite just a vendor is really close to allowing overwriting anything. In that case we probably should just allow writing whole SPROM... Which again, is sth some want to avoid.
Quoted 8 lines
I wonder if we could write some user-space tool for writing SPROM. Accessing ChipCommon registers is quite trivial, the thing I'm not familiar with is accessing PCIE Wifi card registers. I know there are tools for accessing GPU card regs. They work really well, I wonder if we can use the same method for Wifi cards?
If so, we could write user-space app and keep this out of kernel. Maybe we could even extend that tool to cover ssb cards and drop SPROM on SSB writing support from kernel?
This idea sounds good to me. The only valid use of the ssb SPROM writing was when we found some G-PHY cards that had the BT compatibility setting wrong. Now there is a set of quirks that eliminate that need for rewriting the SPROM.
With a separate utility, we can control what parameters can be changed. The vendor codes are one possibility. What else would be useful? I have seen changing the MAC address be mentioned, but I would argue against that. There are too many possibilities for misuse.
Larry
Re: [PATCH 2/2] bcma: expose cc sprom to sysfs
Quoted 48 lines · Larry Finger
Quoted 33 lines · Rafał Miłecki
2012/8/17 Arend van Spriel <[email protected]>:
Quoted 16 lines · Saul St. John
Quoted 11 lines
On BCMA devices with a ChipCommon core of revision 31 or higher, the device
SPROM can be accessed through CC core registers. This patch exposes the SPROM on such devices for read/write access as a sysfs attribute.Tested on a MacBookPro8,2 with BCM4331.
Cc Rafał Miłecki <[email protected]>Cc John W. Linville <[email protected]>Signed-off-by Saul St. John <[email protected]>Hi Saul,
Quoted 7 lines
I was still planning to come back to your reply on August 14. Just wanted to
reply to this patch as I still feel it is a bad thing to open up the sprom
as a whole. I can see the use-cases you mentioned as useful, but maybe we
can get a specific solution for that.I agree with Arend's doubts, on the other hand it would be nice to provide some workaround for that stupid HP wifi blacklisting.
Providing a way to overwrite just a vendor is really close to allowing overwriting anything. In that case we probably should just allow writing whole SPROM... Which again, is sth some want to avoid.
Quoted 8 lines
I wonder if we could write some user-space tool for writing SPROM. Accessing ChipCommon registers is quite trivial, the thing I'm not familiar with is accessing PCIE Wifi card registers. I know there are tools for accessing GPU card regs. They work really well, I wonder if we can use the same method for Wifi cards?
If so, we could write user-space app and keep this out of kernel. Maybe we could even extend that tool to cover ssb cards and drop SPROM on SSB writing support from kernel?This idea sounds good to me. The only valid use of the ssb SPROM writing was when we found some G-PHY cards that had the BT compatibility setting wrong. Now there is a set of quirks that eliminate that need for rewriting the SPROM.
Quoted 4 lines
With a separate utility, we can control what parameters can be changed. The vendor codes are one possibility. What else would be useful? I have seen changing the MAC address be mentioned, but I would argue against that. There are too many possibilities for misuse.
That was indeed my concern. I know people have their legitimate reasons for it, but it is more for convenience as it is a necessity. Given that MAC spoofing also allows misuse.
The same is true for the country code. When left to the user they can select a country code with a less restrictive regulatory parameters for which the device might not be certified. With the utility we could also control how the parameters are changed. However, the country code change on system level is already covered and properly restricted by the regulatory framework.
Gr. AvS