All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hauke Mehrtens <hauke@hauke-m.de>
To: ralf@linux-mips.org
Cc: linux-mips@linux-mips.org, Hauke Mehrtens <hauke@hauke-m.de>
Subject: [PATCH 2/5] MIPS: BCM47xx: extend bcm47xx_fill_sprom with prefix.
Date: Tue, 10 May 2011 23:31:31 +0200	[thread overview]
Message-ID: <1305063094-26656-3-git-send-email-hauke@hauke-m.de> (raw)
In-Reply-To: <1305063094-26656-1-git-send-email-hauke@hauke-m.de>

When an other ssb based device without an own sprom is attached, using
the PCI bus to the main ssb based device, the data normally found in
the sprom will be stored in the nvram on modern devices. The keys, to
load the data from the nvram, are all using some sort of prefix like
pci/1/1/, pci/1/3/ or sb/1/ before the actual key. This patch extends
bcm47xx_fill_sprom() to make it possible to read out these values when
some prefix was used.
The keys for the sprom data used on the main chip does not have a
prefix.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 arch/mips/bcm47xx/setup.c |   29 +++++++++++++++++++++--------
 1 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index c95f90b..bbfcf9b 100644
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
@@ -57,10 +57,23 @@ static void bcm47xx_machine_halt(void)
 }
 
 #define READ_FROM_NVRAM(_outvar, name, buf) \
-	if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\
+	if (nvram_getprefix(prefix, name, buf, sizeof(buf)) >= 0)\
 		sprom->_outvar = simple_strtoul(buf, NULL, 0);
 
-static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
+static inline int nvram_getprefix(const char *prefix, char *name,
+				  char *buf, int len)
+{
+	if (prefix) {
+		char key[100];
+
+		snprintf(key, sizeof(key), "%s%s", prefix, name);
+		return nvram_getenv(key, buf, len);
+	}
+
+	return nvram_getenv(name, buf, len);
+}
+
+static void bcm47xx_fill_sprom(struct ssb_sprom *sprom, const char *prefix)
 {
 	char buf[100];
 	u32 boardflags;
@@ -69,11 +82,11 @@ static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
 
 	sprom->revision = 1; /* Fallback: Old hardware does not define this. */
 	READ_FROM_NVRAM(revision, "sromrev", buf);
-	if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0)
+	if (nvram_getprefix(prefix, "il0macaddr", buf, sizeof(buf)) >= 0)
 		nvram_parse_macaddr(buf, sprom->il0mac);
-	if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
+	if (nvram_getprefix(prefix, "et0macaddr", buf, sizeof(buf)) >= 0)
 		nvram_parse_macaddr(buf, sprom->et0mac);
-	if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
+	if (nvram_getprefix(prefix, "et1macaddr", buf, sizeof(buf)) >= 0)
 		nvram_parse_macaddr(buf, sprom->et1mac);
 	READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
 	READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
@@ -125,14 +138,14 @@ static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
 	READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf);
 	READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf);
 
-	if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0) {
+	if (nvram_getprefix(prefix, "boardflags", buf, sizeof(buf)) >= 0) {
 		boardflags = simple_strtoul(buf, NULL, 0);
 		if (boardflags) {
 			sprom->boardflags_lo = (boardflags & 0x0000FFFFU);
 			sprom->boardflags_hi = (boardflags & 0xFFFF0000U) >> 16;
 		}
 	}
-	if (nvram_getenv("boardflags2", buf, sizeof(buf)) >= 0) {
+	if (nvram_getprefix(prefix, "boardflags2", buf, sizeof(buf)) >= 0) {
 		boardflags = simple_strtoul(buf, NULL, 0);
 		if (boardflags) {
 			sprom->boardflags2_lo = (boardflags & 0x0000FFFFU);
@@ -158,7 +171,7 @@ static int bcm47xx_get_invariants(struct ssb_bus *bus,
 	if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
 		iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
 
-	bcm47xx_fill_sprom(&iv->sprom);
+	bcm47xx_fill_sprom(&iv->sprom, NULL);
 
 	if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
 		iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
-- 
1.7.4.1

  parent reply	other threads:[~2011-05-10 21:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-10 21:31 [PATCH v2 0/5] MIPS: BCM47xx: Enhancements in Parsing the NVRAM data Hauke Mehrtens
2011-05-10 21:31 ` [PATCH v2 1/5] ssb: Change fallback sprom to callback mechanism Hauke Mehrtens
2011-05-10 21:31   ` Hauke Mehrtens
2011-05-10 23:12   ` Rafał Miłecki
2011-05-11 11:53   ` Ralf Baechle
2011-05-10 21:31 ` Hauke Mehrtens [this message]
2011-05-11 11:54   ` [PATCH 2/5] MIPS: BCM47xx: extend bcm47xx_fill_sprom with prefix Ralf Baechle
2011-05-10 21:31 ` [PATCH 3/5] MIPS: BCM47xx: register ssb fallback sprom callback Hauke Mehrtens
2011-05-11 11:54   ` Ralf Baechle
2011-05-10 21:31 ` [PATCH 4/5] MIPS: BCM47xx: extend the filling of sprom from nvram Hauke Mehrtens
2011-05-11 11:55   ` Ralf Baechle
2011-05-10 21:31 ` [PATCH v2 5/5] MIPS: BCM47xx: Fix mac address parsing Hauke Mehrtens
2011-05-11 11:55   ` Ralf Baechle
  -- strict thread matches above, loose matches on Subject: below --
2011-05-07 12:27 [PATCH 0/5] MIPS: BCM47xx: Enhancements in Parsing the NVRAM data Hauke Mehrtens
2011-05-07 12:27 ` [PATCH 2/5] MIPS: BCM47xx: extend bcm47xx_fill_sprom with prefix Hauke Mehrtens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305063094-26656-3-git-send-email-hauke@hauke-m.de \
    --to=hauke@hauke-m.de \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.