--- /dev/null
+From 12b15e5d5914d174e3411d0f0b3fd55dc1b5e55a Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 27 Nov 2010 00:34:02 +0100
+Subject: [PATCH 1/6] MIPS: BCM47xx: Do not read config from CFE
+
+The config options read out here are not stored in CFE, but only in
+NVRAM on the devices. Remove reading from CFE and only access the NVRAM.
+Reading out CFE does not harm, but is useless here.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ arch/mips/bcm47xx/setup.c | 28 +++++++++-------------------
+ 1 files changed, 9 insertions(+), 19 deletions(-)
+
+--- a/arch/mips/bcm47xx/setup.c
++++ b/arch/mips/bcm47xx/setup.c
+@@ -32,7 +32,6 @@
+ #include <asm/reboot.h>
+ #include <asm/time.h>
+ #include <bcm47xx.h>
+-#include <asm/fw/cfe/cfe_api.h>
+ #include <asm/mach-bcm47xx/nvram.h>
+
+ struct ssb_bus ssb_bcm47xx;
+@@ -82,42 +81,33 @@ static int bcm47xx_get_invariants(struct
+ /* Fill boardinfo structure */
+ memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
+
+- if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0 ||
+- nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
++ if (nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
+ iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
+- if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
+- nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
++ if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
+ iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
+- if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
+- nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
++ if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
+ iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
+
+ /* Fill sprom structure */
+ memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
+ iv->sprom.revision = 3;
+
+- if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
+- nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
++ if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
+ str2eaddr(buf, iv->sprom.et0mac);
+
+- if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0 ||
+- nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
++ if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
+ str2eaddr(buf, iv->sprom.et1mac);
+
+- if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 ||
+- nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
++ if (nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
+ iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);
+
+- if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 ||
+- nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
++ if (nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
+ iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);
+
+- if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0 ||
+- nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
++ if (nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
+ iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
+
+- if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0 ||
+- nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
++ if (nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
+ iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
+
+ return 0;
--- /dev/null
+From 4f95d9875b74bbf804a3a83f2c3c5e2068c3f857 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 27 Nov 2010 00:44:58 +0100
+Subject: [PATCH 2/6] MIPS: BCM47xx: Fill values for b43 into ssb sprom
+
+Fill the sprom with all available values from the nvram. Most of these
+new values are needed for the b43 or b43legacy driver.
+
+Some parts of this patch have been in OpenWRT for a long time and were
+made by Michael Buesch.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ arch/mips/bcm47xx/setup.c | 114 ++++++++++++++++++++++++++++++++++++---------
+ 1 files changed, 92 insertions(+), 22 deletions(-)
+
+--- a/arch/mips/bcm47xx/setup.c
++++ b/arch/mips/bcm47xx/setup.c
+@@ -73,42 +73,112 @@ static void str2eaddr(char *str, char *d
+ }
+ }
+
++#define READ_FROM_NVRAM(_outvar, name, buf) \
++ if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\
++ sprom->_outvar = simple_strtoul(buf, NULL, 0);
++
++static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
++{
++ char buf[100];
++ u32 boardflags;
++
++ memset(sprom, 0, sizeof(struct ssb_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)
++ str2eaddr(buf, sprom->il0mac);
++ if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
++ str2eaddr(buf, sprom->et0mac);
++ if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
++ str2eaddr(buf, sprom->et1mac);
++ READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
++ READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
++ READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf);
++ READ_FROM_NVRAM(et1mdcport, "et1mdcport", buf);
++ READ_FROM_NVRAM(board_rev, "boardrev", buf);
++ READ_FROM_NVRAM(country_code, "ccode", buf);
++ READ_FROM_NVRAM(ant_available_a, "aa5g", buf);
++ READ_FROM_NVRAM(ant_available_bg, "aa2g", buf);
++ READ_FROM_NVRAM(pa0b0, "pa0b0", buf);
++ READ_FROM_NVRAM(pa0b1, "pa0b1", buf);
++ READ_FROM_NVRAM(pa0b2, "pa0b2", buf);
++ READ_FROM_NVRAM(pa1b0, "pa1b0", buf);
++ READ_FROM_NVRAM(pa1b1, "pa1b1", buf);
++ READ_FROM_NVRAM(pa1b2, "pa1b2", buf);
++ READ_FROM_NVRAM(pa1lob0, "pa1lob0", buf);
++ READ_FROM_NVRAM(pa1lob2, "pa1lob1", buf);
++ READ_FROM_NVRAM(pa1lob1, "pa1lob2", buf);
++ READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf);
++ READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf);
++ READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf);
++ READ_FROM_NVRAM(gpio0, "wl0gpio0", buf);
++ READ_FROM_NVRAM(gpio1, "wl0gpio1", buf);
++ READ_FROM_NVRAM(gpio2, "wl0gpio2", buf);
++ READ_FROM_NVRAM(gpio3, "wl0gpio3", buf);
++ READ_FROM_NVRAM(maxpwr_bg, "pa0maxpwr", buf);
++ READ_FROM_NVRAM(maxpwr_al, "pa1lomaxpwr", buf);
++ READ_FROM_NVRAM(maxpwr_a, "pa1maxpwr", buf);
++ READ_FROM_NVRAM(maxpwr_ah, "pa1himaxpwr", buf);
++ READ_FROM_NVRAM(itssi_a, "pa1itssit", buf);
++ READ_FROM_NVRAM(itssi_bg, "pa0itssit", buf);
++ READ_FROM_NVRAM(tri2g, "tri2g", buf);
++ READ_FROM_NVRAM(tri5gl, "tri5gl", buf);
++ READ_FROM_NVRAM(tri5g, "tri5g", buf);
++ READ_FROM_NVRAM(tri5gh, "tri5gh", buf);
++ READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf);
++ READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf);
++ READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf);
++ READ_FROM_NVRAM(rssismc2g, "rssismc2g", buf);
++ READ_FROM_NVRAM(rssismf2g, "rssismf2g", buf);
++ READ_FROM_NVRAM(bxa2g, "bxa2g", buf);
++ READ_FROM_NVRAM(rssisav5g, "rssisav5g", buf);
++ READ_FROM_NVRAM(rssismc5g, "rssismc5g", buf);
++ READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf);
++ READ_FROM_NVRAM(bxa5g, "bxa5g", buf);
++ READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf);
++ READ_FROM_NVRAM(ofdm2gpo, "ofdm2gpo", buf);
++ READ_FROM_NVRAM(ofdm5glpo, "ofdm5glpo", buf);
++ READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf);
++ READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf);
++
++ if (nvram_getenv("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) {
++ boardflags = simple_strtoul(buf, NULL, 0);
++ if (boardflags) {
++ sprom->boardflags2_lo = (boardflags & 0x0000FFFFU);
++ sprom->boardflags2_hi = (boardflags & 0xFFFF0000U) >> 16;
++ }
++ }
++}
++
+ static int bcm47xx_get_invariants(struct ssb_bus *bus,
+ struct ssb_init_invariants *iv)
+ {
+- char buf[100];
++ char buf[20];
+
+ /* Fill boardinfo structure */
+ memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
+
+ if (nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
+- iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
++ iv->boardinfo.vendor = (u16)simple_strtoul(buf, NULL, 0);
++ else
++ iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
+ if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
+ iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
+ if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
+ iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
+
+- /* Fill sprom structure */
+- memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
+- iv->sprom.revision = 3;
+-
+- if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
+- str2eaddr(buf, iv->sprom.et0mac);
+-
+- if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
+- str2eaddr(buf, iv->sprom.et1mac);
+-
+- if (nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
+- iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);
+-
+- if (nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
+- iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);
+-
+- if (nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
+- iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
++ bcm47xx_fill_sprom(&iv->sprom);
+
+- if (nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
+- iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
++ if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
++ iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
+
+ return 0;
+ }
+++ /dev/null
-From e5c5828063a55a752e2392d820383dd7a5da3737 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/6] MIPS: BCM47xx: Fill values for b43 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.
-
-Some parts of this patch have been in OpenWRT for a long time and were
-made by Michael Buesch.
-
-Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
----
- arch/mips/bcm47xx/setup.c | 131 +++++++++++++++++++++++++++++++++-----------
- 1 files changed, 98 insertions(+), 33 deletions(-)
-
---- a/arch/mips/bcm47xx/setup.c
-+++ b/arch/mips/bcm47xx/setup.c
-@@ -74,6 +74,95 @@ static void str2eaddr(char *str, char *d
- }
- }
-
-+#define READ_FROM_NVRAM(_outvar, name, buf) \
-+ if (nvram_getenv(name, buf, sizeof(buf)) >= 0 || \
-+ cfe_getenv(name, buf, sizeof(buf)) >= 0) \
-+ sprom->_outvar = simple_strtoul(buf, NULL, 0);
-+
-+static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
-+{
-+ char buf[100];
-+ u32 boardflags;
-+
-+ memset(sprom, 0, sizeof(struct ssb_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 ||
-+ cfe_getenv("il0macaddr", buf, sizeof(buf)) >= 0)
-+ str2eaddr(buf, sprom->il0mac);
-+ if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
-+ cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
-+ str2eaddr(buf, sprom->et0mac);
-+ if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0 ||
-+ cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
-+ str2eaddr(buf, sprom->et1mac);
-+ READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
-+ READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
-+ READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf);
-+ READ_FROM_NVRAM(et1mdcport, "et1mdcport", buf);
-+ READ_FROM_NVRAM(board_rev, "boardrev", buf);
-+ READ_FROM_NVRAM(country_code, "ccode", buf);
-+ READ_FROM_NVRAM(ant_available_a, "aa5g", buf);
-+ READ_FROM_NVRAM(ant_available_bg, "aa2g", buf);
-+ READ_FROM_NVRAM(pa0b0, "pa0b0", buf);
-+ READ_FROM_NVRAM(pa0b1, "pa0b1", buf);
-+ READ_FROM_NVRAM(pa0b2, "pa0b2", buf);
-+ READ_FROM_NVRAM(pa1b0, "pa1b0", buf);
-+ READ_FROM_NVRAM(pa1b1, "pa1b1", buf);
-+ READ_FROM_NVRAM(pa1b2, "pa1b2", buf);
-+ READ_FROM_NVRAM(pa1lob0, "pa1lob0", buf);
-+ READ_FROM_NVRAM(pa1lob2, "pa1lob1", buf);
-+ READ_FROM_NVRAM(pa1lob1, "pa1lob2", buf);
-+ READ_FROM_NVRAM(pa1hib0, "pa1hib0", buf);
-+ READ_FROM_NVRAM(pa1hib2, "pa1hib1", buf);
-+ READ_FROM_NVRAM(pa1hib1, "pa1hib2", buf);
-+ READ_FROM_NVRAM(gpio0, "wl0gpio0", buf);
-+ READ_FROM_NVRAM(gpio1, "wl0gpio1", buf);
-+ READ_FROM_NVRAM(gpio2, "wl0gpio2", buf);
-+ READ_FROM_NVRAM(gpio3, "wl0gpio3", buf);
-+ READ_FROM_NVRAM(maxpwr_bg, "pa0maxpwr", buf);
-+ READ_FROM_NVRAM(maxpwr_al, "pa1lomaxpwr", buf);
-+ READ_FROM_NVRAM(maxpwr_a, "pa1maxpwr", buf);
-+ READ_FROM_NVRAM(maxpwr_ah, "pa1himaxpwr", buf);
-+ READ_FROM_NVRAM(itssi_a, "pa1itssit", buf);
-+ READ_FROM_NVRAM(itssi_bg, "pa0itssit", buf);
-+ READ_FROM_NVRAM(tri2g, "tri2g", buf);
-+ READ_FROM_NVRAM(tri5gl, "tri5gl", buf);
-+ READ_FROM_NVRAM(tri5g, "tri5g", buf);
-+ READ_FROM_NVRAM(tri5gh, "tri5gh", buf);
-+ READ_FROM_NVRAM(rxpo2g, "rxpo2g", buf);
-+ READ_FROM_NVRAM(rxpo5g, "rxpo5g", buf);
-+ READ_FROM_NVRAM(rssisav2g, "rssisav2g", buf);
-+ READ_FROM_NVRAM(rssismc2g, "rssismc2g", buf);
-+ READ_FROM_NVRAM(rssismf2g, "rssismf2g", buf);
-+ READ_FROM_NVRAM(bxa2g, "bxa2g", buf);
-+ READ_FROM_NVRAM(rssisav5g, "rssisav5g", buf);
-+ READ_FROM_NVRAM(rssismc5g, "rssismc5g", buf);
-+ READ_FROM_NVRAM(rssismf5g, "rssismf5g", buf);
-+ READ_FROM_NVRAM(bxa5g, "bxa5g", buf);
-+ READ_FROM_NVRAM(cck2gpo, "cck2gpo", buf);
-+ READ_FROM_NVRAM(ofdm2gpo, "ofdm2gpo", buf);
-+ READ_FROM_NVRAM(ofdm5glpo, "ofdm5glpo", buf);
-+ READ_FROM_NVRAM(ofdm5gpo, "ofdm5gpo", buf);
-+ READ_FROM_NVRAM(ofdm5ghpo, "ofdm5ghpo", buf);
-+
-+ if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0 ||
-+ cfe_getenv("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 ||
-+ cfe_getenv("boardflags2", buf, sizeof(buf)) >= 0)
-+ boardflags = simple_strtoul(buf, NULL, 0);
-+ if (boardflags) {
-+ sprom->boardflags2_lo = (boardflags & 0x0000FFFFU);
-+ sprom->boardflags2_hi = (boardflags & 0xFFFF0000U) >> 16;
-+ }
-+}
-+
- static int bcm47xx_get_invariants(struct ssb_bus *bus,
- struct ssb_init_invariants *iv)
- {
-@@ -82,43 +171,19 @@ static int bcm47xx_get_invariants(struct
- /* Fill boardinfo structure */
- memset(&(iv->boardinfo), 0 , sizeof(struct ssb_boardinfo));
-
-- if (cfe_getenv("boardvendor", buf, sizeof(buf)) >= 0 ||
-- nvram_getenv("boardvendor", buf, sizeof(buf)) >= 0)
-+ iv->boardinfo.vendor = SSB_BOARDVENDOR_BCM;
-+ if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
-+ cfe_getenv("boardtype", buf, sizeof(buf)) >= 0)
- iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
-- if (cfe_getenv("boardtype", buf, sizeof(buf)) >= 0 ||
-- nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
-- iv->boardinfo.type = (u16)simple_strtoul(buf, NULL, 0);
-- if (cfe_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
-- nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
-+ if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0 ||
-+ cfe_getenv("boardrev", buf, sizeof(buf)) >= 0)
- iv->boardinfo.rev = (u16)simple_strtoul(buf, NULL, 0);
-
-- /* Fill sprom structure */
-- memset(&(iv->sprom), 0, sizeof(struct ssb_sprom));
-- iv->sprom.revision = 3;
--
-- if (cfe_getenv("et0macaddr", buf, sizeof(buf)) >= 0 ||
-- nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
-- str2eaddr(buf, iv->sprom.et0mac);
--
-- if (cfe_getenv("et1macaddr", buf, sizeof(buf)) >= 0 ||
-- nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
-- str2eaddr(buf, iv->sprom.et1mac);
--
-- if (cfe_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 ||
-- nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0)
-- iv->sprom.et0phyaddr = simple_strtoul(buf, NULL, 0);
--
-- if (cfe_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 ||
-- nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0)
-- iv->sprom.et1phyaddr = simple_strtoul(buf, NULL, 0);
--
-- if (cfe_getenv("et0mdcport", buf, sizeof(buf)) >= 0 ||
-- nvram_getenv("et0mdcport", buf, sizeof(buf)) >= 0)
-- iv->sprom.et0mdcport = simple_strtoul(buf, NULL, 10);
--
-- if (cfe_getenv("et1mdcport", buf, sizeof(buf)) >= 0 ||
-- nvram_getenv("et1mdcport", buf, sizeof(buf)) >= 0)
-- iv->sprom.et1mdcport = simple_strtoul(buf, NULL, 10);
-+ bcm47xx_fill_sprom(&iv->sprom);
-+
-+ if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0 ||
-+ cfe_getenv("cardbus", buf, sizeof(buf)) >= 0)
-+ iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
-
- return 0;
- }
--- /dev/null
+From f52926174040418e26112cd0ba36afd8bb066928 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 27 Nov 2010 14:02:49 +0100
+Subject: [PATCH 3/6] MIPS: BCM47xx: Use sscanf for parsing mac address
+
+Instead of writing out own function for parsing the mac address we now
+use sscanf.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ arch/mips/bcm47xx/setup.c | 23 +++--------------------
+ arch/mips/include/asm/mach-bcm47xx/nvram.h | 7 +++++++
+ 2 files changed, 10 insertions(+), 20 deletions(-)
+
+--- a/arch/mips/bcm47xx/setup.c
++++ b/arch/mips/bcm47xx/setup.c
+@@ -56,23 +56,6 @@ static void bcm47xx_machine_halt(void)
+ cpu_relax();
+ }
+
+-static void str2eaddr(char *str, char *dest)
+-{
+- int i = 0;
+-
+- if (str == NULL) {
+- memset(dest, 0, 6);
+- return;
+- }
+-
+- for (;;) {
+- dest[i++] = (char) simple_strtoul(str, NULL, 16);
+- str += 2;
+- if (!*str++ || i == 6)
+- break;
+- }
+-}
+-
+ #define READ_FROM_NVRAM(_outvar, name, buf) \
+ if (nvram_getenv(name, buf, sizeof(buf)) >= 0)\
+ sprom->_outvar = simple_strtoul(buf, NULL, 0);
+@@ -87,11 +70,11 @@ static void bcm47xx_fill_sprom(struct ss
+ sprom->revision = 1; /* Fallback: Old hardware does not define this. */
+ READ_FROM_NVRAM(revision, "sromrev", buf);
+ if (nvram_getenv("il0macaddr", buf, sizeof(buf)) >= 0)
+- str2eaddr(buf, sprom->il0mac);
++ nvram_parse_macaddr(buf, sprom->il0mac);
+ if (nvram_getenv("et0macaddr", buf, sizeof(buf)) >= 0)
+- str2eaddr(buf, sprom->et0mac);
++ nvram_parse_macaddr(buf, sprom->et0mac);
+ if (nvram_getenv("et1macaddr", buf, sizeof(buf)) >= 0)
+- str2eaddr(buf, sprom->et1mac);
++ nvram_parse_macaddr(buf, sprom->et1mac);
+ READ_FROM_NVRAM(et0phyaddr, "et0phyaddr", buf);
+ READ_FROM_NVRAM(et1phyaddr, "et1phyaddr", buf);
+ READ_FROM_NVRAM(et0mdcport, "et0mdcport", buf);
+--- a/arch/mips/include/asm/mach-bcm47xx/nvram.h
++++ b/arch/mips/include/asm/mach-bcm47xx/nvram.h
+@@ -12,6 +12,7 @@
+ #define __NVRAM_H
+
+ #include <linux/types.h>
++#include <linux/kernel.h>
+
+ struct nvram_header {
+ u32 magic;
+@@ -36,4 +37,10 @@ struct nvram_header {
+
+ extern int nvram_getenv(char *name, char *val, size_t val_len);
+
++static inline void nvram_parse_macaddr(char *buf, u8 *macaddr)
++{
++ sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0], &macaddr[1],
++ &macaddr[2], &macaddr[3], &macaddr[4], &macaddr[5]);
++}
++
+ #endif
--- /dev/null
+From 25abc0cde3f4865910b380d68ffda0916b5870e7 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 27 Nov 2010 12:25:21 +0100
+Subject: [PATCH 4/6] MIPS: BCM47xx: Swap serial console if ttyS1 was specified.
+
+Some devices like the Netgear WGT634U are using ttyS1 for default
+console output. We should switch to that console if it was given in
+the kernel_args parameters.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ arch/mips/bcm47xx/setup.c | 16 ++++++++++++++++
+ 1 files changed, 16 insertions(+), 0 deletions(-)
+
+--- a/arch/mips/bcm47xx/setup.c
++++ b/arch/mips/bcm47xx/setup.c
+@@ -169,12 +169,28 @@ static int bcm47xx_get_invariants(struct
+ void __init plat_mem_setup(void)
+ {
+ int err;
++ char buf[100];
++ struct ssb_mipscore *mcore;
+
+ err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
+ bcm47xx_get_invariants);
+ if (err)
+ panic("Failed to initialize SSB bus (err %d)\n", err);
+
++ mcore = &ssb_bcm47xx.mipscore;
++ if (nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0) {
++ if (strstr(buf, "console=ttyS1")) {
++ struct ssb_serial_port port;
++
++ printk(KERN_DEBUG "Swapping serial ports!\n");
++ /* swap serial ports */
++ memcpy(&port, &mcore->serial_ports[0], sizeof(port));
++ memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1],
++ sizeof(port));
++ memcpy(&mcore->serial_ports[1], &port, sizeof(port));
++ }
++ }
++
+ _machine_restart = bcm47xx_machine_restart;
+ _machine_halt = bcm47xx_machine_halt;
+ pm_power_off = bcm47xx_machine_halt;
#include <asm/bootinfo.h>
#include <asm/reboot.h>
#include <asm/time.h>
-@@ -190,12 +192,47 @@ static int bcm47xx_get_invariants(struct
+@@ -168,7 +170,7 @@ static int bcm47xx_get_invariants(struct
void __init plat_mem_setup(void)
{
- int err;
+ int i, err;
-+ char buf[100];
-+ struct ssb_mipscore *mcore;
+ char buf[100];
+ struct ssb_mipscore *mcore;
+
+@@ -191,6 +193,24 @@ void __init plat_mem_setup(void)
+ }
+ }
- err = ssb_bus_ssbbus_register(&ssb_bcm47xx, SSB_ENUM_BASE,
- bcm47xx_get_invariants);
- if (err)
- panic("Failed to initialize SSB bus (err %d)\n", err);
-+ mcore = &ssb_bcm47xx.mipscore;
-+
-+ if (nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0 ||
-+ cfe_getenv("kernel_args", buf, sizeof(buf)) >= 0) {
-+ if (strstr(buf, "console=ttyS1")) {
-+ struct ssb_serial_port port;
-+
-+ printk(KERN_DEBUG "Swapping serial ports!\n");
-+ /* swap serial ports */
-+ memcpy(&port, &mcore->serial_ports[0], sizeof(port));
-+ memcpy(&mcore->serial_ports[0], &mcore->serial_ports[1],
-+ sizeof(port));
-+ memcpy(&mcore->serial_ports[1], &port, sizeof(port));
-+ }
-+ }
-+
+ for (i = 0; i < mcore->nr_serial_ports; i++) {
+ struct ssb_serial_port *port = &(mcore->serial_ports[i]);
+ struct uart_port s;
+ early_serial_setup(&s);
+ }
+ printk(KERN_DEBUG "Serial init done.\n");
-
++
_machine_restart = bcm47xx_machine_restart;
_machine_halt = bcm47xx_machine_halt;
+ pm_power_off = bcm47xx_machine_halt;
--- /dev/null
+From 93f94103b9d239b15bba69f592bb6fb2ec5e363f Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 27 Nov 2010 13:14:14 +0100
+Subject: [PATCH 5/6] b44: fix workarround for wap54g10
+
+The code for the b44_wap54g10_workaround was never included, because
+the config option was wrong. The nvram_get function was never in
+mainline kernel, only in external OpenWrt patches.
+
+The code should be compiled in when CONFIG_BCM47XX is selected and not
+when CONFIG_SSB_DRIVER_MIPS is selected, because nvram_getenv is only
+available on bcm47xx platforms and now in the mainline kernel code.
+Using an include is better than a second function declaration, to fix
+this when the function signature changes.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ drivers/net/b44.c | 11 +++++------
+ 1 files changed, 5 insertions(+), 6 deletions(-)
+
+--- a/drivers/net/b44.c
++++ b/drivers/net/b44.c
+@@ -381,11 +381,11 @@ static void b44_set_flow_ctrl(struct b44
+ __b44_set_flow_ctrl(bp, pause_enab);
+ }
+
+-#ifdef SSB_DRIVER_MIPS
+-extern char *nvram_get(char *name);
++#ifdef CONFIG_BCM47XX
++#include <asm/mach-bcm47xx/nvram.h>
+ static void b44_wap54g10_workaround(struct b44 *bp)
+ {
+- const char *str;
++ char buf[20];
+ u32 val;
+ int err;
+
+@@ -394,10 +394,9 @@ static void b44_wap54g10_workaround(stru
+ * see https://dev.openwrt.org/ticket/146
+ * check and reset bit "isolate"
+ */
+- str = nvram_get("boardnum");
+- if (!str)
++ if (nvram_getenv("boardnum", buf, sizeof(buf)) < 0)
+ return;
+- if (simple_strtoul(str, NULL, 0) == 2) {
++ if (simple_strtoul(buf, NULL, 0) == 2) {
+ err = __b44_readphy(bp, 0, MII_BMCR, &val);
+ if (err)
+ goto error;
--- /dev/null
+From 99dfec6e793651963ede3c2721b9ff3c81e3aeac Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 27 Nov 2010 14:04:36 +0100
+Subject: [PATCH 6/6] sb: fix nvram_get on bcm47xx platform
+
+The nvram_get function was never in the mainline kernel, it only
+existed in an external OpenWrt patch. Use nvram_getenv function, which
+is in mainline and use an include instead of an extra function
+declaration.
+et0macaddr contains the mac address in text from like
+00:11:22:33:44:55. We have to parse it before adding it into macaddr.
+
+nvram_parse_macaddr will be merged into asm/mach-bcm47xx/nvram.h though
+the MIPS git tree and will be available soon. It will not build now
+without nvram_parse_macaddr, but it haven't done before.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ include/linux/ssb/ssb_driver_gige.h | 17 +++++++++++------
+ 1 files changed, 11 insertions(+), 6 deletions(-)
+
+--- a/include/linux/ssb/ssb_driver_gige.h
++++ b/include/linux/ssb/ssb_driver_gige.h
+@@ -96,16 +96,21 @@ static inline bool ssb_gige_must_flush_p
+ return 0;
+ }
+
+-extern char * nvram_get(const char *name);
++#ifdef CONFIG_BCM47XX
++#include <asm/mach-bcm47xx/nvram.h>
+ /* Get the device MAC address */
+ static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
+ {
+-#ifdef CONFIG_BCM47XX
+- char *res = nvram_get("et0macaddr");
+- if (res)
+- memcpy(macaddr, res, 6);
+-#endif
++ char buf[20];
++ if (nvram_getenv("et0macaddr", buf, sizeof(buf)) < 0)
++ return;
++ nvram_parse_macaddr(buf, macaddr);
+ }
++#else
++static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
++{
++}
++#endif
+
+ extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
+ struct pci_dev *pdev);
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
-@@ -381,11 +381,12 @@ static void b44_set_flow_ctrl(struct b44
- __b44_set_flow_ctrl(bp, pause_enab);
- }
-
--#ifdef SSB_DRIVER_MIPS
--extern char *nvram_get(char *name);
-+#ifdef CONFIG_BCM47XX
-+
-+#include <asm/mach-bcm47xx/nvram.h>
- static void b44_wap54g10_workaround(struct b44 *bp)
- {
-- const char *str;
-+ char buf[20];
- u32 val;
- int err;
-
-@@ -394,10 +395,9 @@ static void b44_wap54g10_workaround(stru
- * see https://dev.openwrt.org/ticket/146
- * check and reset bit "isolate"
- */
-- str = nvram_get("boardnum");
-- if (!str)
-+ if (nvram_getenv("boardnum", buf, sizeof(buf)) > 0)
- return;
-- if (simple_strtoul(str, NULL, 0) == 2) {
-+ if (simple_strtoul(buf, NULL, 0) == 2) {
- err = __b44_readphy(bp, 0, MII_BMCR, &val);
- if (err)
- goto error;
-@@ -412,10 +412,43 @@ static void b44_wap54g10_workaround(stru
+@@ -411,10 +411,41 @@ static void b44_wap54g10_workaround(stru
error:
pr_warning("PHY: cannot reset MII transceiver isolate bit\n");
}
+ }
+ return;
+}
-+
#else
-+
static inline void b44_wap54g10_workaround(struct b44 *bp)
{
}
#endif
static int b44_setup_phy(struct b44 *bp)
-@@ -424,6 +457,7 @@ static int b44_setup_phy(struct b44 *bp)
+@@ -423,6 +454,7 @@ static int b44_setup_phy(struct b44 *bp)
int err;
b44_wap54g10_workaround(bp);
if (bp->phy_addr == B44_PHY_ADDR_NO_PHY)
return 0;
-@@ -2089,6 +2123,8 @@ static int __devinit b44_get_invariants(
+@@ -2088,6 +2120,8 @@ static int __devinit b44_get_invariants(
* valid PHY address. */
bp->phy_addr &= 0x1F;
+EXPORT_SYMBOL(nvram_get);
--- a/arch/mips/bcm47xx/setup.c
+++ b/arch/mips/bcm47xx/setup.c
-@@ -238,3 +238,20 @@ void __init plat_mem_setup(void)
+@@ -215,3 +215,20 @@ void __init plat_mem_setup(void)
_machine_halt = bcm47xx_machine_halt;
pm_power_off = bcm47xx_machine_halt;
}
+++ /dev/null
---- a/arch/mips/bcm47xx/setup.c
-+++ b/arch/mips/bcm47xx/setup.c
-@@ -84,7 +84,7 @@ static void str2eaddr(char *str, char *d
- static void bcm47xx_fill_sprom(struct ssb_sprom *sprom)
- {
- char buf[100];
-- u32 boardflags;
-+ u32 uninitialized_var(boardflags);
-
- memset(sprom, 0, sizeof(struct ssb_sprom));
-
+From 3cfa0a9d4b4cc30ec735c5c9535ff493bae24d08 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 27 Nov 2010 18:14:23 +0100
+Subject: [PATCH] ssb: Add sysfs attributes to ssb devices
+
+Make it possible to read out the attributes, till now only show on
+dmesg, through sysfs.
+
+This patch was some time in OpenWrt.
+
+Signed-off-by: Bernhard Loos <bernhardloos@googlemail.com>
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
+---
+ drivers/ssb/main.c | 30 ++++++++++++++++++++++++++++++
+ 1 files changed, 30 insertions(+), 0 deletions(-)
+
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
-@@ -384,6 +384,34 @@ static int ssb_device_uevent(struct devi
+@@ -384,6 +384,35 @@ static int ssb_device_uevent(struct devi
ssb_dev->id.revision);
}
-+#define ssb_config_attr(attrib, field, format_string) \
-+static ssize_t \
++#define ssb_config_attr(attrib, field, format_string) \
++static ssize_t \
+attrib##_show(struct device *dev, struct device_attribute *attr, char *buf) \
-+{ \
-+ return sprintf(buf, format_string, dev_to_ssb_dev(dev)->field); \
++{ \
++ return sprintf(buf, format_string, dev_to_ssb_dev(dev)->field); \
+}
+
+ssb_config_attr(core_num, core_index, "%u\n")
+static ssize_t
+name_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
-+ return sprintf(buf, "%s\n", ssb_core_name(dev_to_ssb_dev(dev)->id.coreid));
++ return sprintf(buf, "%s\n",
++ ssb_core_name(dev_to_ssb_dev(dev)->id.coreid));
+}
+
+static struct device_attribute ssb_device_attrs[] = {
static struct bus_type ssb_bustype = {
.name = "ssb",
.match = ssb_bus_match,
-@@ -393,6 +421,7 @@ static struct bus_type ssb_bustype = {
+@@ -393,6 +422,7 @@ static struct bus_type ssb_bustype = {
.suspend = ssb_device_suspend,
.resume = ssb_device_resume,
.uevent = ssb_device_uevent,