drivers/firmware/broadcom/bcm47xx_sprom.c
Source file repositories/reference/linux-study-clean/drivers/firmware/broadcom/bcm47xx_sprom.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/broadcom/bcm47xx_sprom.c- Extension
.c- Size
- 28072 bytes
- Lines
- 728
- Domain
- Driver Families
- Bucket
- drivers/firmware
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bcm47xx_nvram.hlinux/bcm47xx_sprom.hlinux/bcma/bcma.hlinux/etherdevice.hlinux/hex.hlinux/if_ether.hlinux/ssb/ssb.h
Detected Declarations
function create_keyfunction get_nvram_varfunction nvram_read_u32_2function nvram_read_leddcfunction nvram_read_macaddrfunction nvram_read_alpha2function codefunction bcm47xx_fill_sprom_path_r4589function bcm47xx_fill_sprom_path_r45function bcm47xx_is_valid_macfunction bcm47xx_increase_mac_addrfunction bcm47xx_fill_sprom_ethernetfunction bcm47xx_fill_board_datafunction bcm47xx_fill_spromfunction bcm47xx_get_sprom_ssbfunction bcm47xx_sprom_apply_prefix_aliasfunction bcm47xx_get_sprom_bcmafunction bcm47xx_sprom_register_fallbacksmodule init bcm47xx_sprom_register_fallbacks
Annotated Snippet
if (bcm47xx_is_valid_mac(mac)) {
int err = bcm47xx_increase_mac_addr(mac, mac_addr_used);
if (!err) {
ether_addr_copy(sprom->il0mac, mac);
mac_addr_used++;
}
}
}
}
static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix,
bool fallback)
{
nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo,
&sprom->boardflags_hi, fallback);
nvram_read_u32_2(prefix, "boardflags2", &sprom->boardflags2_lo,
&sprom->boardflags2_hi, fallback);
}
void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix,
bool fallback)
{
bcm47xx_fill_sprom_ethernet(sprom, prefix, fallback);
bcm47xx_fill_board_data(sprom, prefix, fallback);
nvram_read_u8(prefix, NULL, "sromrev", &sprom->revision, 0, fallback);
/* Entries requiring custom functions */
nvram_read_alpha2(prefix, "ccode", sprom->alpha2, fallback);
if (sprom->revision >= 3)
nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time,
&sprom->leddc_off_time, fallback);
switch (sprom->revision) {
case 4:
case 5:
bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback);
bcm47xx_fill_sprom_path_r45(sprom, prefix, fallback);
break;
case 8:
case 9:
bcm47xx_fill_sprom_path_r4589(sprom, prefix, fallback);
break;
}
bcm47xx_sprom_fill_auto(sprom, prefix, fallback);
}
#if IS_BUILTIN(CONFIG_SSB) && IS_ENABLED(CONFIG_SSB_SPROM)
static int bcm47xx_get_sprom_ssb(struct ssb_bus *bus, struct ssb_sprom *out)
{
char prefix[10];
switch (bus->bustype) {
case SSB_BUSTYPE_SSB:
bcm47xx_fill_sprom(out, NULL, false);
return 0;
case SSB_BUSTYPE_PCI:
memset(out, 0, sizeof(struct ssb_sprom));
snprintf(prefix, sizeof(prefix), "pci/%u/%u/",
bus->host_pci->bus->number + 1,
PCI_SLOT(bus->host_pci->devfn));
bcm47xx_fill_sprom(out, prefix, false);
return 0;
default:
pr_warn("Unable to fill SPROM for given bustype.\n");
return -EINVAL;
}
}
#endif
#if IS_BUILTIN(CONFIG_BCMA)
/*
* Having many NVRAM entries for PCI devices led to repeating prefixes like
* pci/1/1/ all the time and wasting flash space. So at some point Broadcom
* decided to introduce prefixes like 0: 1: 2: etc.
* If we find e.g. devpath0=pci/2/1 or devpath0=pci/2/1/ we should use 0:
* instead of pci/2/1/.
*/
static void bcm47xx_sprom_apply_prefix_alias(char *prefix, size_t prefix_size)
{
size_t prefix_len = strlen(prefix);
size_t short_len = prefix_len - 1;
char nvram_var[10];
char buf[20];
int i;
/* Passed prefix has to end with a slash */
if (prefix_len <= 0 || prefix[prefix_len - 1] != '/')
Annotation
- Immediate include surface: `linux/bcm47xx_nvram.h`, `linux/bcm47xx_sprom.h`, `linux/bcma/bcma.h`, `linux/etherdevice.h`, `linux/hex.h`, `linux/if_ether.h`, `linux/ssb/ssb.h`.
- Detected declarations: `function create_key`, `function get_nvram_var`, `function nvram_read_u32_2`, `function nvram_read_leddc`, `function nvram_read_macaddr`, `function nvram_read_alpha2`, `function code`, `function bcm47xx_fill_sprom_path_r4589`, `function bcm47xx_fill_sprom_path_r45`, `function bcm47xx_is_valid_mac`.
- Atlas domain: Driver Families / drivers/firmware.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.