source: trunk/target/linux/brcm47xx/patches-2.6.35/012-MIPS-BCM47xx-Fill-more-values-into-ssb-sprom.patch @ 22298

Last change on this file since 22298 was 22298, checked in by hauke, 6 years ago

brcm47xx: write boardflags correct into sprom

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

    From 493d4a90850509e5f09b4799d4fc234b734a9d30 Mon Sep 17 00:00:00 2001
    From: Hauke Mehrtens <hauke@hauke-m.de>
    Date: Sun, 18 Jul 2010 13:34:32 +0200
    Subject: [PATCH 2/5] MIPS: BCM47xx: Fill more values into ssb sprom
    
    Most of the values are stored in the nvram and not in the CFE. At first
    the nvram should be read and if there is no value it should look into
    the CFE. Now more values are read out because the b43 and b43legacy
    drivers needs them.
    
    Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
    ---
     arch/mips/bcm47xx/setup.c |  125 +++++++++++++++++++++++++++++++++------------
     1 files changed, 92 insertions(+), 33 deletions(-)
    
    a b static void str2eaddr(char *str, char *d 
    7474        } 
    7575} 
    7676 
     77static void bcm47xx_fill_sprom(struct ssb_sprom *sprom) 
     78{ 
     79        char buf[100]; 
     80        u64 boardflags; 
     81 
     82        memset(sprom, 0, sizeof(struct ssb_sprom)); 
     83 
     84        sprom->revision = 3; 
     85        if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0 || 
     86            cfe_getenv("il0macaddr", buf, sizeof(buf)) >= 0) 
     87                str2eaddr(buf, sprom->il0mac); 
     88        if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0 || 
     89            cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0) 
     90                str2eaddr(buf, sprom->et0mac); 
     91        if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0 || 
     92            cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0) 
     93                str2eaddr(buf, sprom->et1mac); 
     94        if (nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 || 
     95            cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0) 
     96                sprom->et0phyaddr = simple_strtoul(buf, NULL, 0); 
     97        if (nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 || 
     98            cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0) 
     99                sprom->et1phyaddr = simple_strtoul(buf, NULL, 0); 
     100        if (nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0 || 
     101            cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0) 
     102                sprom->et0mdcport = !!simple_strtoul(buf, NULL, 10); 
     103        if (nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0 || 
     104            cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0) 
     105                sprom->et1mdcport = !!simple_strtoul(buf, NULL, 10); 
     106        if (nvram_getenv("pa0b0", buf, sizeof(buf)) >= 0 || 
     107            cfe_getenv("pa0b0", buf, sizeof(buf)) >= 0) 
     108                sprom->pa0b0 = simple_strtoul(buf, NULL, 0); 
     109        if (nvram_getenv("pa0b1", buf, sizeof(buf)) >= 0 || 
     110            cfe_getenv("pa0b1", buf, sizeof(buf)) >= 0) 
     111                sprom->pa0b1 = simple_strtoul(buf, NULL, 0); 
     112        if (nvram_getenv("pa0b2", buf, sizeof(buf)) >= 0 || 
     113            cfe_getenv("pa0b2", buf, sizeof(buf)) >= 0) 
     114                sprom->pa0b2 = simple_strtoul(buf, NULL, 0); 
     115        if (nvram_getenv("pa1b0", buf, sizeof(buf)) >= 0 || 
     116            cfe_getenv("pa1b0", buf, sizeof(buf)) >= 0) 
     117                sprom->pa1b0 = simple_strtoul(buf, NULL, 0); 
     118        if (nvram_getenv("pa1b1", buf, sizeof(buf)) >= 0 || 
     119            cfe_getenv("pa1b1", buf, sizeof(buf)) >= 0) 
     120                sprom->pa1b1 = simple_strtoul(buf, NULL, 0); 
     121        if (nvram_getenv("pa1b2", buf, sizeof(buf)) >= 0 || 
     122            cfe_getenv("pa1b2", buf, sizeof(buf)) >= 0) 
     123                sprom->pa1b2 = simple_strtoul(buf, NULL, 0); 
     124        if (nvram_getenv("wl0gpio0", buf, sizeof(buf)) >= 0 || 
     125            cfe_getenv("wl0gpio0", buf, sizeof(buf)) >= 0) 
     126                sprom->gpio0 = simple_strtoul(buf, NULL, 0); 
     127        if (nvram_getenv("wl0gpio1", buf, sizeof(buf)) >= 0 || 
     128            cfe_getenv("wl0gpio1", buf, sizeof(buf)) >= 0) 
     129                sprom->gpio1 = simple_strtoul(buf, NULL, 0); 
     130        if (nvram_getenv("wl0gpio2", buf, sizeof(buf)) >= 0 || 
     131            cfe_getenv("wl0gpio2", buf, sizeof(buf)) >= 0) 
     132                sprom->gpio2 = simple_strtoul(buf, NULL, 0); 
     133        if (nvram_getenv("wl0gpio3", buf, sizeof(buf)) >= 0 || 
     134            cfe_getenv("wl0gpio3", buf, sizeof(buf)) >= 0) 
     135                sprom->gpio3 = simple_strtoul(buf, NULL, 0); 
     136        if (nvram_getenv("pa0maxpwr", buf, sizeof(buf)) >= 0 || 
     137            cfe_getenv("pa0maxpwr", buf, sizeof(buf)) >= 0) 
     138                sprom->maxpwr_bg = simple_strtoul(buf, NULL, 0); 
     139        if (nvram_getenv("pa1maxpwr", buf, sizeof(buf)) >= 0 || 
     140            cfe_getenv("pa1maxpwr", buf, sizeof(buf)) >= 0) 
     141                sprom->maxpwr_a = simple_strtoul(buf, NULL, 0); 
     142        if (nvram_getenv("pa0itssit", buf, sizeof(buf)) >= 0 || 
     143            cfe_getenv("pa0itssit", buf, sizeof(buf)) >= 0) 
     144                sprom->itssi_bg = simple_strtoul(buf, NULL, 0); 
     145        if (nvram_getenv("pa1itssit", buf, sizeof(buf)) >= 0 || 
     146            cfe_getenv("pa1itssit", buf, sizeof(buf)) >= 0) 
     147                sprom->itssi_a = simple_strtoul(buf, NULL, 0); 
     148 
     149        if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0 || 
     150            cfe_getenv("boardflags", buf, sizeof(buf)) >= 0) 
     151                boardflags = simple_strtoll(buf, NULL, 0); 
     152        if (boardflags) { 
     153                sprom->boardflags_lo = (boardflags & 0x000000000000FFFFLLU); 
     154                sprom->boardflags_hi = (boardflags & 0x00000000FFFF0000LLU) >> 16; 
     155                sprom->boardflags2_lo = (boardflags & 0x0000FFFF00000000LLU) >> 32; 
     156                sprom->boardflags2_hi = (boardflags & 0xFFFF000000000000LLU) >> 48; 
     157        } 
     158} 
     159 
    77160static int bcm47xx_get_invariants(struct ssb_bus *bus, 
    78161                                   struct ssb_init_invariants *iv) 
    79162{ 
    static int bcm47xx_get_invariants(struct 
    82165        /* Fill boardinfo structure */ 
    83166        memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo)); 
    84167 
    85         if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0 || 
    86             nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0) 
     168        iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM; 
     169        if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0 || 
     170            cfe_getenv("boardtype", buf, sizeof(buf)) >= 0) 
    87171                iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0); 
    88         if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0 || 
    89             nvram_getenv("boardtype", buf, sizeof(buf)) >= 0) 
    90                 iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0); 
    91         if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0 || 
    92             nvram_getenv("boardrev", buf, sizeof(buf)) >= 0) 
     172        if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0 || 
     173            cfe_getenv("boardrev", buf, sizeof(buf)) >= 0) 
    93174                iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0); 
    94175 
    95         /* Fill sprom structure */ 
    96         memset(&(iv->sprom), 0, sizeof(struct ssb_sprom)); 
    97         iv->sprom.revision = 3; 
    98  
    99         if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0 || 
    100             nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0) 
    101                 str2eaddr(buf, iv->sprom.et0mac); 
    102  
    103         if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0 || 
    104             nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0) 
    105                 str2eaddr(buf, iv->sprom.et1mac); 
    106  
    107         if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 || 
    108             nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0) 
    109                 iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0); 
    110  
    111         if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 || 
    112             nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0) 
    113                 iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0); 
    114  
    115         if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0 || 
    116             nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0) 
    117                 iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10); 
    118  
    119         if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0 || 
    120             nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0) 
    121                 iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10); 
     176        bcm47xx_fill_sprom(&iv->sprom); 
     177 
     178        if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0 || 
     179            cfe_getenv("cardbus", buf, sizeof(buf)) >= 0) 
     180                iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10); 
    122181 
    123182        return 0; 
    124183} 
Note: See TracBrowser for help on using the repository browser.