source: trunk/target/linux/brcm47xx/patches-2.6.37/032-bcm47xx-extend-bcm47xx_fill_sprom-with-prefix.patch @ 26801

Last change on this file since 26801 was 26801, checked in by hauke, 5 years ago

brcm47xx: add fallback sprom for pci devices without an own sprom.

If there is no sprom on an ssb based pci device on the brcm47xx
architecture ssb now asks the architecture code to look into the nvram
to get some sprom data for this device. Now we are able to read out
pci/1/1/ foo or pci/1/3/ foo config options.

This will fix some problems where the wireless devices does not got an
mac address and the following message was show:
ssb: WARNING: Invalid SPROM CRC (corrupt SPROM)

File size: 2.6 KB
  • arch/mips/bcm47xx/setup.c

    a b static void bcm47xx_machine_halt(void) 
    5959} 
    6060 
    6161#define READ_FROM_NVRAM(_outvar, name, buf) \ 
    62         if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\ 
     62        if (nvram_getprefix(prefix, name, buf, sizeof(buf)) >= 0)\ 
    6363                sprom->_outvar = simple_strtoul(buf, NULL, 0); 
    6464 
    65 static void bcm47xx_fill_sprom(struct ssb_sprom *sprom) 
     65static inline int nvram_getprefix(const char *prefix, char *name, 
     66                                  char *buf, int len) 
     67{ 
     68        if (prefix) { 
     69                char key[100]; 
     70 
     71                snprintf(key, sizeof(key), "%s%s", prefix, name); 
     72                return nvram_getenv(key, buf, len); 
     73        } 
     74 
     75        return nvram_getenv(name, buf, len); 
     76} 
     77 
     78static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix) 
    6679{ 
    6780        char buf[100]; 
    6881        u32 boardflags; 
    static void bcm47xx_fill_sprom(struct ss 
    7184 
    7285        sprom->revision = 1; /* Fallback: Old hardware does not define this. */ 
    7386        READ_FROM_NVRAM(revision, "sromrev", buf); 
    74         if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0) 
     87        if (nvram_getprefix(prefix, "il0macaddr", buf, sizeof(buf)) >= 0) 
    7588                nvram_parse_macaddr(buf, sprom->il0mac); 
    76         if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0) 
     89        if (nvram_getprefix(prefix, "et0macaddr", buf, sizeof(buf)) >= 0) 
    7790                nvram_parse_macaddr(buf, sprom->et0mac); 
    78         if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0) 
     91        if (nvram_getprefix(prefix, "et1macaddr", buf, sizeof(buf)) >= 0) 
    7992                nvram_parse_macaddr(buf, sprom->et1mac); 
    8093        READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf); 
    8194        READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf); 
    static void bcm47xx_fill_sprom(struct ss 
    127140        READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf); 
    128141        READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf); 
    129142 
    130         if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0) { 
     143        if (nvram_getprefix(prefix, "boardflags", buf, sizeof(buf)) >= 0) { 
    131144                boardflags = simple_strtoul(buf, NULL, 0); 
    132145                if (boardflags) { 
    133146                        sprom->boardflags_lo = (boardflags & 0x0000FFFFU); 
    134147                        sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16; 
    135148                } 
    136149        } 
    137         if (nvram_getenv("boardflags2", buf, sizeof(buf)) >= 0) { 
     150        if (nvram_getprefix(prefix, "boardflags2", buf, sizeof(buf)) >= 0) { 
    138151                boardflags = simple_strtoul(buf, NULL, 0); 
    139152                if (boardflags) { 
    140153                        sprom->boardflags2_lo = (boardflags & 0x0000FFFFU); 
    static int bcm47xx_get_invariants(struct 
    160173        if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0) 
    161174                iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0); 
    162175 
    163         bcm47xx_fill_sprom(&iv->sprom); 
     176        bcm47xx_fill_sprom(&iv->sprom, NULL); 
    164177 
    165178        if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0) 
    166179                iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10); 
Note: See TracBrowser for help on using the repository browser.