linux-mips
[Top] [All Lists]

[PATCH v2 3/5] MIPS: BCM47xx: read out full board data

To: ralf@linux-mips.org, john@phrozen.org
Subject: [PATCH v2 3/5] MIPS: BCM47xx: read out full board data
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Wed, 3 Oct 2012 14:34:18 +0200
Cc: linux-mips@linux-mips.org, Hauke Mehrtens <hauke@hauke-m.de>
In-reply-to: <1349267660-31845-1-git-send-email-hauke@hauke-m.de>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
References: <1349267660-31845-1-git-send-email-hauke@hauke-m.de>
Sender: linux-mips-bounce@linux-mips.org
Read out the full board data independently of the sprom version. Now we
also get the full boardflags and so on if sromrev is not set and our
code would assume a rev 1 device. When a nvram option is not set
because it is not there this is no problem.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 arch/mips/bcm47xx/sprom.c |   34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
index d3a8897..7fa3da3 100644
--- a/arch/mips/bcm47xx/sprom.c
+++ b/arch/mips/bcm47xx/sprom.c
@@ -164,10 +164,6 @@ static void nvram_read_alpha2(const char *prefix, const 
char *name,
 static void bcm47xx_fill_sprom_r1234589(struct ssb_sprom *sprom,
                                        const char *prefix)
 {
-       nvram_read_u16(prefix, NULL, "boardrev", &sprom->board_rev, 0);
-       if (!sprom->board_rev)
-               nvram_read_u16(NULL, NULL, "boardrev", &sprom->board_rev, 0);
-       nvram_read_u16(prefix, NULL, "boardnum", &sprom->board_num, 0);
        nvram_read_u8(prefix, NULL, "ledbh0", &sprom->gpio0, 0xff);
        nvram_read_u8(prefix, NULL, "ledbh1", &sprom->gpio1, 0xff);
        nvram_read_u8(prefix, NULL, "ledbh2", &sprom->gpio2, 0xff);
@@ -214,13 +210,6 @@ static void bcm47xx_fill_sprom_r2389(struct ssb_sprom 
*sprom,
        nvram_read_u8(prefix, NULL, "pa1himaxpwr", &sprom->maxpwr_ah, 0);
 }
 
-static void bcm47xx_fill_sprom_r2(struct ssb_sprom *sprom, const char *prefix)
-{
-       nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo,
-                        &sprom->boardflags_hi);
-       nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0);
-}
-
 static void bcm47xx_fill_sprom_r389(struct ssb_sprom *sprom, const char 
*prefix)
 {
        nvram_read_u8(prefix, NULL, "bxa2g", &sprom->bxa2g, 0);
@@ -241,9 +230,6 @@ static void bcm47xx_fill_sprom_r389(struct ssb_sprom 
*sprom, const char *prefix)
 
 static void bcm47xx_fill_sprom_r3(struct ssb_sprom *sprom, const char *prefix)
 {
-       nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo,
-                        &sprom->boardflags_hi);
-       nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0);
        nvram_read_u8(prefix, NULL, "regrev", &sprom->regrev, 0);
        nvram_read_leddc(prefix, "leddc", &sprom->leddc_on_time,
                         &sprom->leddc_off_time);
@@ -252,11 +238,6 @@ static void bcm47xx_fill_sprom_r3(struct ssb_sprom *sprom, 
const char *prefix)
 static void bcm47xx_fill_sprom_r4589(struct ssb_sprom *sprom,
                                     const char *prefix)
 {
-       nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo,
-                        &sprom->boardflags_hi);
-       nvram_read_u32_2(prefix, "boardflags2", &sprom->boardflags2_lo,
-                        &sprom->boardflags2_hi);
-       nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0);
        nvram_read_u8(prefix, NULL, "regrev", &sprom->regrev, 0);
        nvram_read_s8(prefix, NULL, "ag2", &sprom->antenna_gain.a2, 0);
        nvram_read_s8(prefix, NULL, "ag3", &sprom->antenna_gain.a3, 0);
@@ -555,9 +536,23 @@ void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, 
const char *prefix)
        nvram_read_macaddr(prefix, "il0macaddr", &sprom->il0mac);
 }
 
+static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char 
*prefix)
+{
+       nvram_read_u16(prefix, NULL, "boardrev", &sprom->board_rev, 0);
+       if (!sprom->board_rev)
+               nvram_read_u16(NULL, NULL, "boardrev", &sprom->board_rev, 0);
+       nvram_read_u16(prefix, NULL, "boardnum", &sprom->board_num, 0);
+       nvram_read_u16(prefix, NULL, "boardtype", &sprom->board_type, 0);
+       nvram_read_u32_2(prefix, "boardflags", &sprom->boardflags_lo,
+                        &sprom->boardflags_hi);
+       nvram_read_u32_2(prefix, "boardflags2", &sprom->boardflags2_lo,
+                        &sprom->boardflags2_hi);
+}
+
 void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix)
 {
        bcm47xx_fill_sprom_ethernet(sprom, prefix);
+       bcm47xx_fill_board_data(sprom, prefix);
 
        nvram_read_u8(prefix, NULL, "sromrev", &sprom->revision, 0);
 
@@ -571,7 +566,6 @@ void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char 
*prefix)
                bcm47xx_fill_sprom_r1234589(sprom, prefix);
                bcm47xx_fill_sprom_r12389(sprom, prefix);
                bcm47xx_fill_sprom_r2389(sprom, prefix);
-               bcm47xx_fill_sprom_r2(sprom, prefix);
                break;
        case 3:
                bcm47xx_fill_sprom_r1234589(sprom, prefix);
-- 
1.7.9.5


<Prev in Thread] Current Thread [Next in Thread>