bcma: read SPROM and extract MAC from it
Rafał Miłecki
maintainerPATCH 1/1 bcma: read SPROM and extract MAC from it
In case of BCMA cards SPROM is located in the ChipCommon core, it is not mapped as separated host window. So far we have met only SPROMs rev 8.
SPROM layout seems to be the same as for SSB buses, so we decided to share SPROM struct and some defines.
For now we extract MAC address only, this can be improved of course.
--- drivers/bcma/Makefile | 2 +- drivers/bcma/bcma_private.h | 3 + drivers/bcma/main.c | 7 + drivers/bcma/sprom.c | 162 +++++++++++++++++++++++++++ include/linux/bcma/bcma.h | 5 + include/linux/bcma/bcma_driver_chipcommon.h | 1 + 6 files changed, 179 insertions(+), 1 deletions(-) create mode 100644 drivers/bcma/sprom.c
drivers/bcma/Makefile +1 -1
@@ -1,4 +1,4 @@ -bcma-y += main.o scan.o core.o +bcma-y += main.o scan.o core.o sprom.o bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o bcma-y += driver_pci.o bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
drivers/bcma/bcma_private.h +3 -0
@@ -19,6 +19,9 @@ extern void bcma_bus_unregister(struct bcma_bus *bus);/* scan.c */ int bcma_bus_scan (struct bcma_bus *bus); +/* sprom.c */ +int bcma_sprom_get (struct bcma_bus *bus); +#ifdef CONFIG_BCMA_HOST_PCI /* host_pci.c */ extern int __init bcma_host_pci_init (void );
drivers/bcma/main.c +7 -0
@@ -146,6 +146,13 @@ int bcma_bus_register(struct bcma_bus *bus)bcma_core_pci_init (&bus->drv_pci); } +/* Try to get SPROM */ + err =bcma_sprom_get (bus); +if (err) { +pr_err ("Failed to get SPROM: %d\n" , err); +return -ENOENT ; + } +/* Register found cores */ bcma_register_cores (bus);
drivers/bcma/sprom.c new file +162 -0
162 lines not on this page · raw message
include/linux/bcma/bcma.h +5 -0
@@ -6,6 +6,7 @@#include <linux/bcma/bcma_driver_chipcommon.h> #include <linux/bcma/bcma_driver_pci.h> +#include <linux/ssb/ssb.h> /* SPROM sharing */ #include "bcma_regs.h"
@@ -187,6 +188,10 @@ struct bcma_bus {struct bcma_drv_cc drv_cc;struct bcma_drv_pci drv_pci; + +/* We decided to share SPROM struct with SSB as long as we do not need +* any hacks for BCMA. This simplifies drivers code. */ +struct ssb_sprom sprom; };extern inline u32 bcma_read8 (struct bcma_device *core,u16 offset)
include/linux/bcma/bcma_driver_chipcommon.h +1 -0
@@ -244,6 +244,7 @@#define BCMA_CC_REGCTL_DATA 0x065C#define BCMA_CC_PLLCTL_ADDR 0x0660#define BCMA_CC_PLLCTL_DATA 0x0664 +#define BCMA_CC_SPROM 0x0830/* SPROM beginning */ /* Data for the PMU, if available. * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
Signature · 1 line
1.7.3.4
Quoted 9 lines · Rafał Miłecki
In case of BCMA cards SPROM is located in the ChipCommon core, it is not mapped as separated host window. So far we have met only SPROMs rev 8.
SPROM layout seems to be the same as for SSB buses, so we decided to share SPROM struct and some defines.
For now we extract MAC address only, this can be improved of course.Signed-off-by Rafał Miłecki<[email protected]>
drivers/bcma/sprom.c line 36
Quoted 6 lines
drivers/bcma/sprom.c new file +6
-0+/************************************************** +* Validation. +**************************************************/ + +static inline u8 bcma_crc8 (u8 crc,u8 data) +{
Somehow this crc8 looks quite familiar to me ;-) I send out a patch to John providing a crc8 as library module so you could consider using that. It will probably end up in wireless-testing before this patch (if accepted that is).
Gr. AvS
Signature · 2 lines
Almost nobody dances sober, unless they happen to be insane. -- H.P. Lovecraft --