brcm47xx: add a new version of the nvram rewrite patch
This is the version like it was send for mainline inclusion. SVN-Revision: 34988
This commit is contained in:
parent
edc7ab525f
commit
25afeba608
13 changed files with 360 additions and 84 deletions
|
@ -38,7 +38,7 @@
|
||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
#ifdef CONFIG_BCM47XX
|
#ifdef CONFIG_BCM47XX
|
||||||
#include <nvram.h>
|
#include <bcm47xx_nvram.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DRIVER_NAME "adm6996"
|
#define DRIVER_NAME "adm6996"
|
||||||
|
@ -89,7 +89,7 @@ static unsigned int get_gpiopin(char *pin_name, unsigned int def_pin)
|
||||||
/* Go thru all possibilities till a match in pin name */
|
/* Go thru all possibilities till a match in pin name */
|
||||||
for (pin = 0; pin < 16; pin ++) {
|
for (pin = 0; pin < 16; pin ++) {
|
||||||
sprintf(name, "gpio%d", pin);
|
sprintf(name, "gpio%d", pin);
|
||||||
if (nvram_getenv(name, val, sizeof(val)) >= 0) {
|
if (bcm47xx_nvram_getenv(name, val, sizeof(val)) >= 0) {
|
||||||
if (!strcmp(val, pin_name))
|
if (!strcmp(val, pin_name))
|
||||||
return pin;
|
return pin;
|
||||||
}
|
}
|
||||||
|
@ -497,10 +497,10 @@ static int detect_adm(void)
|
||||||
int boardflags = 0;
|
int boardflags = 0;
|
||||||
int boardnum = 0;
|
int boardnum = 0;
|
||||||
|
|
||||||
if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0)
|
if (bcm47xx_nvram_getenv("boardflags", buf, sizeof(buf)) >= 0)
|
||||||
boardflags = simple_strtoul(buf, NULL, 0);
|
boardflags = simple_strtoul(buf, NULL, 0);
|
||||||
|
|
||||||
if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
|
if (bcm47xx_nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
|
||||||
boardnum = simple_strtoul(buf, NULL, 0);
|
boardnum = simple_strtoul(buf, NULL, 0);
|
||||||
|
|
||||||
if ((boardnum == 44) && (boardflags == 0x0388)) { /* Trendware TEW-411BRP+ */
|
if ((boardnum == 44) && (boardflags == 0x0388)) { /* Trendware TEW-411BRP+ */
|
||||||
|
@ -519,9 +519,9 @@ static int detect_adm(void)
|
||||||
eedi = get_gpiopin("adm_eedi", 4);
|
eedi = get_gpiopin("adm_eedi", 4);
|
||||||
eerc = get_gpiopin("adm_rc", 0);
|
eerc = get_gpiopin("adm_rc", 0);
|
||||||
|
|
||||||
} else if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0) {
|
} else if (bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf)) >= 0) {
|
||||||
if (strcmp(buf, "bcm94710dev") == 0) {
|
if (strcmp(buf, "bcm94710dev") == 0) {
|
||||||
if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0) {
|
if (bcm47xx_nvram_getenv("boardnum", buf, sizeof(buf)) >= 0) {
|
||||||
if (strncmp(buf, "42", 2) == 0) {
|
if (strncmp(buf, "42", 2) == 0) {
|
||||||
/* WRT54G v1.1 hack */
|
/* WRT54G v1.1 hack */
|
||||||
eecs = 2;
|
eecs = 2;
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include "etc53xx.h"
|
#include "etc53xx.h"
|
||||||
|
|
||||||
#ifdef CONFIG_BCM47XX
|
#ifdef CONFIG_BCM47XX
|
||||||
#include <nvram.h>
|
#include <bcm47xx_nvram.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DRIVER_NAME "bcm53xx"
|
#define DRIVER_NAME "bcm53xx"
|
||||||
|
@ -236,7 +236,7 @@ static int robo_switch_enable(void)
|
||||||
|
|
||||||
#ifdef CONFIG_BCM47XX
|
#ifdef CONFIG_BCM47XX
|
||||||
/* WAN port LED, except for Netgear WGT634U */
|
/* WAN port LED, except for Netgear WGT634U */
|
||||||
if (nvram_getenv("nvram_type", buf, sizeof(buf)) >= 0) {
|
if (bcm47xx_nvram_getenv("nvram_type", buf, sizeof(buf)) >= 0) {
|
||||||
if (strcmp(buf, "cfe") != 0)
|
if (strcmp(buf, "cfe") != 0)
|
||||||
robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
|
robo_write16(ROBO_CTRL_PAGE, 0x16, 0x1F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <bcm47xx.h>
|
#include <bcm47xx.h>
|
||||||
#include <nvram.h>
|
#include <bcm47xx_nvram.h>
|
||||||
|
|
||||||
#define RTC_IS_OPEN 0x01 /* Means /dev/rtc is in use. */
|
#define RTC_IS_OPEN 0x01 /* Means /dev/rtc is in use. */
|
||||||
|
|
||||||
|
@ -530,7 +530,7 @@ static void platform_detect(void)
|
||||||
int et0phyaddr, et1phyaddr;
|
int et0phyaddr, et1phyaddr;
|
||||||
|
|
||||||
/* Based on "model_no". */
|
/* Based on "model_no". */
|
||||||
if (nvram_getenv("model_no", buf, sizeof(buf)) >= 0) {
|
if (bcm47xx_nvram_getenv("model_no", buf, sizeof(buf)) >= 0) {
|
||||||
if (startswith(buf, "WL700")) { /* WL700* */
|
if (startswith(buf, "WL700")) { /* WL700* */
|
||||||
sda_index = 2;
|
sda_index = 2;
|
||||||
scl_index = 5;
|
scl_index = 5;
|
||||||
|
@ -538,12 +538,12 @@ static void platform_detect(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 )
|
if (bcm47xx_nvram_getenv("et0phyaddr", buf, sizeof(buf)) >= 0 )
|
||||||
et0phyaddr = simple_strtoul(buf, NULL, 0);
|
et0phyaddr = simple_strtoul(buf, NULL, 0);
|
||||||
if (nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 )
|
if (bcm47xx_nvram_getenv("et1phyaddr", buf, sizeof(buf)) >= 0 )
|
||||||
et1phyaddr = simple_strtoul(buf, NULL, 0);
|
et1phyaddr = simple_strtoul(buf, NULL, 0);
|
||||||
|
|
||||||
if (nvram_getenv("hardware_version", buf, sizeof(buf)) >= 0) {
|
if (bcm47xx_nvram_getenv("hardware_version", buf, sizeof(buf)) >= 0) {
|
||||||
/* Either WL-300g or WL-HDD, do more extensive checks */
|
/* Either WL-300g or WL-HDD, do more extensive checks */
|
||||||
if (startswith(buf, "WL300-") && et0phyaddr == 0 && et1phyaddr == 1) {
|
if (startswith(buf, "WL300-") && et0phyaddr == 0 && et1phyaddr == 1) {
|
||||||
sda_index = 4;
|
sda_index = 4;
|
||||||
|
|
|
@ -76,8 +76,8 @@
|
||||||
+#include <linux/mtd/partitions.h>
|
+#include <linux/mtd/partitions.h>
|
||||||
+#include <linux/crc32.h>
|
+#include <linux/crc32.h>
|
||||||
+#include <linux/io.h>
|
+#include <linux/io.h>
|
||||||
+#include <asm/mach-bcm47xx/nvram.h>
|
+#include <bcm47xx_nvram.h>
|
||||||
+#include <asm/mach-bcm47xx/bcm47xx.h>
|
+#include <bcm47xx.h>
|
||||||
+#include <asm/fw/cfe/cfe_api.h>
|
+#include <asm/fw/cfe/cfe_api.h>
|
||||||
+
|
+
|
||||||
+
|
+
|
||||||
|
@ -378,19 +378,19 @@
|
||||||
+ u16 cardbus = 0;
|
+ u16 cardbus = 0;
|
||||||
+ u16 strev = 0;
|
+ u16 strev = 0;
|
||||||
+
|
+
|
||||||
+ if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
|
+ if (bcm47xx_nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
|
||||||
+ boardnum = simple_strtoul(buf, NULL, 0);
|
+ boardnum = simple_strtoul(buf, NULL, 0);
|
||||||
+ if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
|
+ if (bcm47xx_nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
|
||||||
+ boardtype = simple_strtoul(buf, NULL, 0);
|
+ boardtype = simple_strtoul(buf, NULL, 0);
|
||||||
+ if (nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
|
+ if (bcm47xx_nvram_getenv("boardrev", buf, sizeof(buf)) >= 0)
|
||||||
+ boardrev = simple_strtoul(buf, NULL, 0);
|
+ boardrev = simple_strtoul(buf, NULL, 0);
|
||||||
+ if (nvram_getenv("boardflags", buf, sizeof(buf)) >= 0)
|
+ if (bcm47xx_nvram_getenv("boardflags", buf, sizeof(buf)) >= 0)
|
||||||
+ boardflags = simple_strtoul(buf, NULL, 0);
|
+ boardflags = simple_strtoul(buf, NULL, 0);
|
||||||
+ if (nvram_getenv("sdram_init", buf, sizeof(buf)) >= 0)
|
+ if (bcm47xx_nvram_getenv("sdram_init", buf, sizeof(buf)) >= 0)
|
||||||
+ sdram_init = simple_strtoul(buf, NULL, 0);
|
+ sdram_init = simple_strtoul(buf, NULL, 0);
|
||||||
+ if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
|
+ if (bcm47xx_nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
|
||||||
+ cardbus = simple_strtoul(buf, NULL, 0);
|
+ cardbus = simple_strtoul(buf, NULL, 0);
|
||||||
+ if (nvram_getenv("st_rev", buf, sizeof(buf)) >= 0)
|
+ if (bcm47xx_nvram_getenv("st_rev", buf, sizeof(buf)) >= 0)
|
||||||
+ strev = simple_strtoul(buf, NULL, 0);
|
+ strev = simple_strtoul(buf, NULL, 0);
|
||||||
+
|
+
|
||||||
+ if ((boardnum == 8 || boardnum == 01)
|
+ if ((boardnum == 8 || boardnum == 01)
|
||||||
|
|
|
@ -9,7 +9,13 @@
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms of the GNU General Public License as published by the
|
* under the terms of the GNU General Public License as published by the
|
||||||
@@ -23,69 +23,139 @@
|
@@ -18,83 +18,166 @@
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/string.h>
|
||||||
|
#include <asm/addrspace.h>
|
||||||
|
-#include <asm/mach-bcm47xx/nvram.h>
|
||||||
|
+#include <bcm47xx_nvram.h>
|
||||||
|
#include <asm/mach-bcm47xx/bcm47xx.h>
|
||||||
|
|
||||||
static char nvram_buf[NVRAM_SPACE];
|
static char nvram_buf[NVRAM_SPACE];
|
||||||
|
|
||||||
|
@ -30,7 +36,7 @@
|
||||||
+
|
+
|
||||||
/* Probe for NVRAM header */
|
/* Probe for NVRAM header */
|
||||||
-static void early_nvram_init(void)
|
-static void early_nvram_init(void)
|
||||||
+static void early_nvram_init_fill(u32 base, u32 lim)
|
+static int nvram_find_and_copy(u32 base, u32 lim)
|
||||||
{
|
{
|
||||||
-#ifdef CONFIG_BCM47XX_SSB
|
-#ifdef CONFIG_BCM47XX_SSB
|
||||||
- struct ssb_mipscore *mcore_ssb;
|
- struct ssb_mipscore *mcore_ssb;
|
||||||
|
@ -94,8 +100,9 @@
|
||||||
goto found;
|
goto found;
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
|
- return;
|
||||||
+ pr_err("no nvram found\n");
|
+ pr_err("no nvram found\n");
|
||||||
return;
|
+ return -ENXIO;
|
||||||
|
|
||||||
found:
|
found:
|
||||||
+
|
+
|
||||||
|
@ -112,72 +119,341 @@
|
||||||
- for (; i < header->len && i < NVRAM_SPACE; i += 4)
|
- for (; i < header->len && i < NVRAM_SPACE; i += 4)
|
||||||
+ for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4)
|
+ for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4)
|
||||||
*dst++ = le32_to_cpu(*src++);
|
*dst++ = le32_to_cpu(*src++);
|
||||||
|
+ memset(dst, 0x0, NVRAM_SPACE - i);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
+#ifdef CONFIG_BCM47XX_BCMA
|
-int nvram_getenv(char *name, char *val, size_t val_len)
|
||||||
+static void early_nvram_init_bcma(void)
|
|
||||||
+{
|
|
||||||
+ struct bcma_drv_cc *cc = &bcm47xx_bus.bcma.bus.drv_cc;
|
|
||||||
+ u32 base = 0;
|
|
||||||
+ u32 lim = 0;
|
|
||||||
+
|
|
||||||
+ if (cc->nflash.boot) {
|
|
||||||
+ base = BCMA_SOC_FLASH1;
|
|
||||||
+ lim = BCMA_SOC_FLASH1_SZ;
|
|
||||||
+ } else if (cc->pflash.present) {
|
|
||||||
+ base = cc->pflash.window;
|
|
||||||
+ lim = cc->pflash.window_size;
|
|
||||||
+ } else if (cc->sflash.present) {
|
|
||||||
+ base = cc->sflash.window;
|
|
||||||
+ lim = cc->sflash.size;
|
|
||||||
+ } else {
|
|
||||||
+ pr_err("No supported flash found\n");
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ early_nvram_init_fill(base, lim);
|
|
||||||
+}
|
|
||||||
+#endif
|
|
||||||
+
|
|
||||||
+#ifdef CONFIG_BCM47XX_SSB
|
+#ifdef CONFIG_BCM47XX_SSB
|
||||||
+static void early_nvram_init_ssb(void)
|
+static int nvram_init_ssb(void)
|
||||||
+{
|
+{
|
||||||
+ struct ssb_mipscore *mcore = &bcm47xx_bus.ssb.mipscore;
|
+ struct ssb_mipscore *mcore = &bcm47xx_bus.ssb.mipscore;
|
||||||
+ struct ssb_chipcommon *chipco = &bcm47xx_bus.ssb.chipco;
|
+ struct ssb_chipcommon *chipco = &bcm47xx_bus.ssb.chipco;
|
||||||
+ u32 base = 0;
|
+ u32 base;
|
||||||
+ u32 lim = 0;
|
+ u32 lim;
|
||||||
+
|
+
|
||||||
+ if (mcore->pflash.present) {
|
+ if (mcore->pflash.present) {
|
||||||
+ base = mcore->pflash.window;
|
+ base = mcore->pflash.window;
|
||||||
+ lim = mcore->pflash.window_size;
|
+ lim = mcore->pflash.window_size;
|
||||||
|
+#ifdef CONFIG_SSB_SFLASH
|
||||||
+ } else if (chipco->sflash.present) {
|
+ } else if (chipco->sflash.present) {
|
||||||
+ base = chipco->sflash.window;
|
+ base = chipco->sflash.window;
|
||||||
+ lim = chipco->sflash.size;
|
+ lim = chipco->sflash.size;
|
||||||
|
+#endif
|
||||||
+ } else {
|
+ } else {
|
||||||
+ pr_err("No supported flash found\n");
|
+ pr_err("Couldn't find supported flash memory\n");
|
||||||
+ return;
|
+ return -ENXIO;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ early_nvram_init_fill(base, lim);
|
+ return nvram_find_and_copy(base, lim);
|
||||||
+}
|
+}
|
||||||
+#endif
|
+#endif
|
||||||
+
|
+
|
||||||
+static void early_nvram_init(void)
|
+#ifdef CONFIG_BCM47XX_BCMA
|
||||||
|
+static int nvram_init_bcma(void)
|
||||||
|
+{
|
||||||
|
+ struct bcma_drv_cc *cc = &bcm47xx_bus.bcma.bus.drv_cc;
|
||||||
|
+ u32 base;
|
||||||
|
+ u32 lim;
|
||||||
|
+
|
||||||
|
+#ifdef CONFIG_BCMA_NFLASH
|
||||||
|
+ if (cc->nflash.boot) {
|
||||||
|
+ base = BCMA_SOC_FLASH1;
|
||||||
|
+ lim = BCMA_SOC_FLASH1_SZ;
|
||||||
|
+ } else
|
||||||
|
+#endif
|
||||||
|
+ if (cc->pflash.present) {
|
||||||
|
+ base = cc->pflash.window;
|
||||||
|
+ lim = cc->pflash.window_size;
|
||||||
|
+#ifdef CONFIG_BCMA_SFLASH
|
||||||
|
+ } else if (cc->sflash.present) {
|
||||||
|
+ base = cc->sflash.window;
|
||||||
|
+ lim = cc->sflash.size;
|
||||||
|
+#endif
|
||||||
|
+ } else {
|
||||||
|
+ pr_err("Couldn't find supported flash memory\n");
|
||||||
|
+ return -ENXIO;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return nvram_find_and_copy(base, lim);
|
||||||
|
+}
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+static int nvram_init(void)
|
||||||
+{
|
+{
|
||||||
+ switch (bcm47xx_bus_type) {
|
+ switch (bcm47xx_bus_type) {
|
||||||
+#ifdef CONFIG_BCM47XX_SSB
|
+#ifdef CONFIG_BCM47XX_SSB
|
||||||
+ case BCM47XX_BUS_TYPE_SSB:
|
+ case BCM47XX_BUS_TYPE_SSB:
|
||||||
+ early_nvram_init_ssb();
|
+ return nvram_init_ssb();
|
||||||
+ break;
|
|
||||||
+#endif
|
+#endif
|
||||||
+#ifdef CONFIG_BCM47XX_BCMA
|
+#ifdef CONFIG_BCM47XX_BCMA
|
||||||
+ case BCM47XX_BUS_TYPE_BCMA:
|
+ case BCM47XX_BUS_TYPE_BCMA:
|
||||||
+ early_nvram_init_bcma();
|
+ return nvram_init_bcma();
|
||||||
+ break;
|
|
||||||
+#endif
|
+#endif
|
||||||
+ }
|
+ }
|
||||||
|
+ return -ENXIO;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
int nvram_getenv(char *name, char *val, size_t val_len)
|
+int bcm47xx_nvram_getenv(char *name, char *val, size_t val_len)
|
||||||
{
|
{
|
||||||
char *var, *value, *end, *eq;
|
char *var, *value, *end, *eq;
|
||||||
|
+ int err;
|
||||||
|
|
||||||
|
if (!name)
|
||||||
|
- return NVRAM_ERR_INV_PARAM;
|
||||||
|
+ return -EINVAL;
|
||||||
|
|
||||||
|
- if (!nvram_buf[0])
|
||||||
|
- early_nvram_init();
|
||||||
|
+ if (!nvram_buf[0]) {
|
||||||
|
+ err = nvram_init();
|
||||||
|
+ if (err)
|
||||||
|
+ return err;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
/* Look for name=value and return value */
|
||||||
|
var = &nvram_buf[sizeof(struct nvram_header)];
|
||||||
|
@@ -110,6 +193,6 @@ int nvram_getenv(char *name, char *val,
|
||||||
|
return snprintf(val, val_len, "%s", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- return NVRAM_ERR_ENVNOTFOUND;
|
||||||
|
+ return -ENOENT;
|
||||||
|
}
|
||||||
|
-EXPORT_SYMBOL(nvram_getenv);
|
||||||
|
+EXPORT_SYMBOL(bcm47xx_nvram_getenv);
|
||||||
|
--- a/arch/mips/bcm47xx/setup.c
|
||||||
|
+++ b/arch/mips/bcm47xx/setup.c
|
||||||
|
@@ -35,7 +35,7 @@
|
||||||
|
#include <asm/reboot.h>
|
||||||
|
#include <asm/time.h>
|
||||||
|
#include <bcm47xx.h>
|
||||||
|
-#include <asm/mach-bcm47xx/nvram.h>
|
||||||
|
+#include <bcm47xx_nvram.h>
|
||||||
|
|
||||||
|
union bcm47xx_bus bcm47xx_bus;
|
||||||
|
EXPORT_SYMBOL(bcm47xx_bus);
|
||||||
|
@@ -115,7 +115,7 @@ static int bcm47xx_get_invariants(struct
|
||||||
|
memset(&iv->sprom, 0, sizeof(struct ssb_sprom));
|
||||||
|
bcm47xx_fill_sprom(&iv->sprom, NULL, false);
|
||||||
|
|
||||||
|
- if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
|
||||||
|
+ if (bcm47xx_nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
|
||||||
|
iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
@@ -138,7 +138,7 @@ static void __init bcm47xx_register_ssb(
|
||||||
|
panic("Failed to initialize SSB bus (err %d)", err);
|
||||||
|
|
||||||
|
mcore = &bcm47xx_bus.ssb.mipscore;
|
||||||
|
- if (nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0) {
|
||||||
|
+ if (bcm47xx_nvram_getenv("kernel_args", buf, sizeof(buf)) >= 0) {
|
||||||
|
if (strstr(buf, "console=ttyS1")) {
|
||||||
|
struct ssb_serial_port port;
|
||||||
|
|
||||||
|
--- a/arch/mips/bcm47xx/sprom.c
|
||||||
|
+++ b/arch/mips/bcm47xx/sprom.c
|
||||||
|
@@ -27,7 +27,7 @@
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <bcm47xx.h>
|
||||||
|
-#include <nvram.h>
|
||||||
|
+#include <bcm47xx_nvram.h>
|
||||||
|
|
||||||
|
static void create_key(const char *prefix, const char *postfix,
|
||||||
|
const char *name, char *buf, int len)
|
||||||
|
@@ -50,10 +50,10 @@ static int get_nvram_var(const char *pre
|
||||||
|
|
||||||
|
create_key(prefix, postfix, name, key, sizeof(key));
|
||||||
|
|
||||||
|
- err = nvram_getenv(key, buf, len);
|
||||||
|
- if (fallback && err == NVRAM_ERR_ENVNOTFOUND && prefix) {
|
||||||
|
+ err = bcm47xx_nvram_getenv(key, buf, len);
|
||||||
|
+ if (fallback && err == -ENOENT && prefix) {
|
||||||
|
create_key(NULL, postfix, name, key, sizeof(key));
|
||||||
|
- err = nvram_getenv(key, buf, len);
|
||||||
|
+ err = bcm47xx_nvram_getenv(key, buf, len);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
@@ -144,7 +144,7 @@ static void nvram_read_macaddr(const cha
|
||||||
|
if (err < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- nvram_parse_macaddr(buf, *val);
|
||||||
|
+ bcm47xx_nvram_parse_macaddr(buf, *val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void nvram_read_alpha2(const char *prefix, const char *name,
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
|
||||||
|
@@ -0,0 +1,51 @@
|
||||||
|
+/*
|
||||||
|
+ * Copyright (C) 2005, Broadcom Corporation
|
||||||
|
+ * Copyright (C) 2006, Felix Fietkau <nbd@openwrt.org>
|
||||||
|
+ *
|
||||||
|
+ * This program is free software; you can redistribute it and/or modify it
|
||||||
|
+ * under the terms of the GNU General Public License as published by the
|
||||||
|
+ * Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
+ * option) any later version.
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+#ifndef __BCM47XX_NVRAM_H
|
||||||
|
+#define __BCM47XX_NVRAM_H
|
||||||
|
+
|
||||||
|
+#include <linux/types.h>
|
||||||
|
+#include <linux/kernel.h>
|
||||||
|
+
|
||||||
|
+struct nvram_header {
|
||||||
|
+ u32 magic;
|
||||||
|
+ u32 len;
|
||||||
|
+ u32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
|
||||||
|
+ u32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
|
||||||
|
+ u32 config_ncdl; /* ncdl values for memc */
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+#define NVRAM_HEADER 0x48534C46 /* 'FLSH' */
|
||||||
|
+#define NVRAM_VERSION 1
|
||||||
|
+#define NVRAM_HEADER_SIZE 20
|
||||||
|
+#define NVRAM_SPACE 0x8000
|
||||||
|
+
|
||||||
|
+#define FLASH_MIN 0x00020000 /* Minimum flash size */
|
||||||
|
+
|
||||||
|
+#define NVRAM_MAX_VALUE_LEN 255
|
||||||
|
+#define NVRAM_MAX_PARAM_LEN 64
|
||||||
|
+
|
||||||
|
+extern int bcm47xx_nvram_getenv(char *name, char *val, size_t val_len);
|
||||||
|
+
|
||||||
|
+static inline void bcm47xx_nvram_parse_macaddr(char *buf, u8 macaddr[6])
|
||||||
|
+{
|
||||||
|
+ if (strchr(buf, ':'))
|
||||||
|
+ sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0],
|
||||||
|
+ &macaddr[1], &macaddr[2], &macaddr[3], &macaddr[4],
|
||||||
|
+ &macaddr[5]);
|
||||||
|
+ else if (strchr(buf, '-'))
|
||||||
|
+ sscanf(buf, "%hhx-%hhx-%hhx-%hhx-%hhx-%hhx", &macaddr[0],
|
||||||
|
+ &macaddr[1], &macaddr[2], &macaddr[3], &macaddr[4],
|
||||||
|
+ &macaddr[5]);
|
||||||
|
+ else
|
||||||
|
+ printk(KERN_WARNING "Can not parse mac address: %s\n", buf);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+#endif /* __BCM47XX_NVRAM_H */
|
||||||
|
--- a/arch/mips/include/asm/mach-bcm47xx/nvram.h
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,54 +0,0 @@
|
||||||
|
-/*
|
||||||
|
- * Copyright (C) 2005, Broadcom Corporation
|
||||||
|
- * Copyright (C) 2006, Felix Fietkau <nbd@openwrt.org>
|
||||||
|
- *
|
||||||
|
- * This program is free software; you can redistribute it and/or modify it
|
||||||
|
- * under the terms of the GNU General Public License as published by the
|
||||||
|
- * Free Software Foundation; either version 2 of the License, or (at your
|
||||||
|
- * option) any later version.
|
||||||
|
- */
|
||||||
|
-
|
||||||
|
-#ifndef __NVRAM_H
|
||||||
|
-#define __NVRAM_H
|
||||||
|
-
|
||||||
|
-#include <linux/types.h>
|
||||||
|
-#include <linux/kernel.h>
|
||||||
|
-
|
||||||
|
-struct nvram_header {
|
||||||
|
- u32 magic;
|
||||||
|
- u32 len;
|
||||||
|
- u32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
|
||||||
|
- u32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
|
||||||
|
- u32 config_ncdl; /* ncdl values for memc */
|
||||||
|
-};
|
||||||
|
-
|
||||||
|
-#define NVRAM_HEADER 0x48534C46 /* 'FLSH' */
|
||||||
|
-#define NVRAM_VERSION 1
|
||||||
|
-#define NVRAM_HEADER_SIZE 20
|
||||||
|
-#define NVRAM_SPACE 0x8000
|
||||||
|
-
|
||||||
|
-#define FLASH_MIN 0x00020000 /* Minimum flash size */
|
||||||
|
-
|
||||||
|
-#define NVRAM_MAX_VALUE_LEN 255
|
||||||
|
-#define NVRAM_MAX_PARAM_LEN 64
|
||||||
|
-
|
||||||
|
-#define NVRAM_ERR_INV_PARAM -8
|
||||||
|
-#define NVRAM_ERR_ENVNOTFOUND -9
|
||||||
|
-
|
||||||
|
-extern int nvram_getenv(char *name, char *val, size_t val_len);
|
||||||
|
-
|
||||||
|
-static inline void nvram_parse_macaddr(char *buf, u8 macaddr[6])
|
||||||
|
-{
|
||||||
|
- if (strchr(buf, ':'))
|
||||||
|
- sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &macaddr[0],
|
||||||
|
- &macaddr[1], &macaddr[2], &macaddr[3], &macaddr[4],
|
||||||
|
- &macaddr[5]);
|
||||||
|
- else if (strchr(buf, '-'))
|
||||||
|
- sscanf(buf, "%hhx-%hhx-%hhx-%hhx-%hhx-%hhx", &macaddr[0],
|
||||||
|
- &macaddr[1], &macaddr[2], &macaddr[3], &macaddr[4],
|
||||||
|
- &macaddr[5]);
|
||||||
|
- else
|
||||||
|
- printk(KERN_WARNING "Can not parse mac address: %s\n", buf);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-#endif
|
||||||
|
--- a/drivers/net/ethernet/broadcom/b44.c
|
||||||
|
+++ b/drivers/net/ethernet/broadcom/b44.c
|
||||||
|
@@ -381,7 +381,7 @@ static void b44_set_flow_ctrl(struct b44
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_BCM47XX
|
||||||
|
-#include <asm/mach-bcm47xx/nvram.h>
|
||||||
|
+#include <bcm47xx_nvram.h>
|
||||||
|
static void b44_wap54g10_workaround(struct b44 *bp)
|
||||||
|
{
|
||||||
|
char buf[20];
|
||||||
|
@@ -393,7 +393,7 @@ static void b44_wap54g10_workaround(stru
|
||||||
|
* see https://dev.openwrt.org/ticket/146
|
||||||
|
* check and reset bit "isolate"
|
||||||
|
*/
|
||||||
|
- if (nvram_getenv("boardnum", buf, sizeof(buf)) < 0)
|
||||||
|
+ if (bcm47xx_nvram_getenv("boardnum", buf, sizeof(buf)) < 0)
|
||||||
|
return;
|
||||||
|
if (simple_strtoul(buf, NULL, 0) == 2) {
|
||||||
|
err = __b44_readphy(bp, 0, MII_BMCR, &val);
|
||||||
|
--- a/drivers/ssb/driver_chipcommon_pmu.c
|
||||||
|
+++ b/drivers/ssb/driver_chipcommon_pmu.c
|
||||||
|
@@ -14,7 +14,7 @@
|
||||||
|
#include <linux/delay.h>
|
||||||
|
#include <linux/export.h>
|
||||||
|
#ifdef CONFIG_BCM47XX
|
||||||
|
-#include <asm/mach-bcm47xx/nvram.h>
|
||||||
|
+#include <bcm47xx_nvram.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ssb_private.h"
|
||||||
|
@@ -322,7 +322,7 @@ static void ssb_pmu_pll_init(struct ssb_
|
||||||
|
if (bus->bustype == SSB_BUSTYPE_SSB) {
|
||||||
|
#ifdef CONFIG_BCM47XX
|
||||||
|
char buf[20];
|
||||||
|
- if (nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0)
|
||||||
|
+ if (bcm47xx_nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0)
|
||||||
|
crystalfreq = simple_strtoul(buf, NULL, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
--- a/include/linux/ssb/ssb_driver_gige.h
|
||||||
|
+++ b/include/linux/ssb/ssb_driver_gige.h
|
||||||
|
@@ -98,14 +98,14 @@ static inline bool ssb_gige_must_flush_p
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_BCM47XX
|
||||||
|
-#include <asm/mach-bcm47xx/nvram.h>
|
||||||
|
+#include <bcm47xx_nvram.h>
|
||||||
|
/* Get the device MAC address */
|
||||||
|
static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
|
||||||
|
{
|
||||||
|
char buf[20];
|
||||||
|
- if (nvram_getenv("et0macaddr", buf, sizeof(buf)) < 0)
|
||||||
|
+ if (bcm47xx_nvram_getenv("et0macaddr", buf, sizeof(buf)) < 0)
|
||||||
|
return;
|
||||||
|
- nvram_parse_macaddr(buf, macaddr);
|
||||||
|
+ bcm47xx_nvram_parse_macaddr(buf, macaddr);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
|
||||||
|
|
|
@ -26,7 +26,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
||||||
Support for BCM47XX based boards
|
Support for BCM47XX based boards
|
||||||
--- a/arch/mips/bcm47xx/prom.c
|
--- a/arch/mips/bcm47xx/prom.c
|
||||||
+++ b/arch/mips/bcm47xx/prom.c
|
+++ b/arch/mips/bcm47xx/prom.c
|
||||||
@@ -31,96 +31,28 @@
|
@@ -33,96 +33,28 @@
|
||||||
#include <asm/fw/cfe/cfe_api.h>
|
#include <asm/fw/cfe/cfe_api.h>
|
||||||
#include <asm/fw/cfe/cfe_error.h>
|
#include <asm/fw/cfe/cfe_error.h>
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
||||||
}
|
}
|
||||||
|
|
||||||
static __init void prom_init_mem(void)
|
static __init void prom_init_mem(void)
|
||||||
@@ -161,8 +93,6 @@ static __init void prom_init_mem(void)
|
@@ -173,8 +105,6 @@ static __init void prom_init_mem(void)
|
||||||
void __init prom_init(void)
|
void __init prom_init(void)
|
||||||
{
|
{
|
||||||
prom_init_cfe();
|
prom_init_cfe();
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
+ bp->phy_addr = B44_PHY_ADDR_NO_PHY;
|
+ bp->phy_addr = B44_PHY_ADDR_NO_PHY;
|
||||||
+ } else {
|
+ } else {
|
||||||
+ /* WL-HDD */
|
+ /* WL-HDD */
|
||||||
+ if (nvram_getenv("hardware_version", buf, sizeof(buf)) >= 0 &&
|
+ if (bcm47xx_nvram_getenv("hardware_version", buf, sizeof(buf)) >= 0 &&
|
||||||
+ !strncmp(buf, "WL300-", strlen("WL300-"))) {
|
+ !strncmp(buf, "WL300-", strlen("WL300-"))) {
|
||||||
+ if (sdev->bus->sprom.et0phyaddr == 0 &&
|
+ if (sdev->bus->sprom.et0phyaddr == 0 &&
|
||||||
+ sdev->bus->sprom.et1phyaddr == 1)
|
+ sdev->bus->sprom.et1phyaddr == 1)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
--- a/arch/mips/bcm47xx/nvram.c
|
--- a/arch/mips/bcm47xx/nvram.c
|
||||||
+++ b/arch/mips/bcm47xx/nvram.c
|
+++ b/arch/mips/bcm47xx/nvram.c
|
||||||
@@ -183,3 +183,30 @@ int nvram_getenv(char *name, char *val,
|
@@ -196,3 +196,30 @@ int bcm47xx_nvram_getenv(char *name, cha
|
||||||
return NVRAM_ERR_ENVNOTFOUND;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(nvram_getenv);
|
EXPORT_SYMBOL(bcm47xx_nvram_getenv);
|
||||||
+
|
+
|
||||||
+char *nvram_get(const char *name)
|
+char *nvram_get(const char *name)
|
||||||
+{
|
+{
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
+ return NULL;
|
+ return NULL;
|
||||||
+
|
+
|
||||||
+ if (!nvram_buf[0])
|
+ if (!nvram_buf[0])
|
||||||
+ early_nvram_init();
|
+ nvram_init();
|
||||||
+
|
+
|
||||||
+ /* Look for name=value and return value */
|
+ /* Look for name=value and return value */
|
||||||
+ var = &nvram_buf[sizeof(struct nvram_header)];
|
+ var = &nvram_buf[sizeof(struct nvram_header)];
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <linux/ssb/ssb.h>
|
#include <linux/ssb/ssb.h>
|
||||||
#include <asm/time.h>
|
#include <asm/time.h>
|
||||||
#include <bcm47xx.h>
|
#include <bcm47xx.h>
|
||||||
+#include <nvram.h>
|
+#include <bcm47xx_nvram.h>
|
||||||
|
|
||||||
void __init plat_time_init(void)
|
void __init plat_time_init(void)
|
||||||
{
|
{
|
||||||
|
@ -31,10 +31,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
+ if (chip_id == 0x5354) {
|
+ if (chip_id == 0x5354) {
|
||||||
+ len = nvram_getenv("clkfreq", buf, sizeof(buf));
|
+ len = bcm47xx_nvram_getenv("clkfreq", buf, sizeof(buf));
|
||||||
+ if (len >= 0 && !strncmp(buf, "200", 4))
|
+ if (len >= 0 && !strncmp(buf, "200", 4))
|
||||||
+ hz = 100000000;
|
+ hz = 100000000;
|
||||||
+ len = nvram_getenv("hardware_version", buf, sizeof(buf));
|
+ len = bcm47xx_nvram_getenv("hardware_version", buf, sizeof(buf));
|
||||||
+ if (len >= 0 && !strncmp(buf, "WL520G", 6))
|
+ if (len >= 0 && !strncmp(buf, "WL520G", 6))
|
||||||
+ hz = 100000000;
|
+ hz = 100000000;
|
||||||
+
|
+
|
||||||
|
|
|
@ -406,14 +406,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
-#ifdef CONFIG_BCM47XX
|
-#ifdef CONFIG_BCM47XX
|
||||||
-#include <asm/mach-bcm47xx/nvram.h>
|
-#include <bcm47xx_nvram.h>
|
||||||
-/* Get the device MAC address */
|
-/* Get the device MAC address */
|
||||||
-static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
|
-static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
|
||||||
-{
|
-{
|
||||||
- char buf[20];
|
- char buf[20];
|
||||||
- if (nvram_getenv("et0macaddr", buf, sizeof(buf)) < 0)
|
- if (bcm47xx_nvram_getenv("et0macaddr", buf, sizeof(buf)) < 0)
|
||||||
- return;
|
- return;
|
||||||
- nvram_parse_macaddr(buf, macaddr);
|
- bcm47xx_nvram_parse_macaddr(buf, macaddr);
|
||||||
-}
|
-}
|
||||||
-#else
|
-#else
|
||||||
static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
|
static inline void ssb_gige_get_macaddr(struct pci_dev *pdev, u8 *macaddr)
|
||||||
|
|
|
@ -254,7 +254,7 @@ out the configuration than the in kernel cfe config reader.
|
||||||
|
|
||||||
static u32 find_nvram_size(u32 end)
|
static u32 find_nvram_size(u32 end)
|
||||||
{
|
{
|
||||||
@@ -47,6 +49,26 @@ static void early_nvram_init_fill(u32 ba
|
@@ -47,6 +49,26 @@ static int nvram_find_and_copy(u32 base,
|
||||||
u32 *src, *dst;
|
u32 *src, *dst;
|
||||||
u32 size;
|
u32 size;
|
||||||
|
|
||||||
|
@ -274,16 +274,16 @@ out the configuration than the in kernel cfe config reader.
|
||||||
+ *dst++ = *src++;
|
+ *dst++ = *src++;
|
||||||
+ }
|
+ }
|
||||||
+ cfe_env = 1;
|
+ cfe_env = 1;
|
||||||
+ return;
|
+ return 0;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
/* TODO: when nvram is on nand flash check for bad blocks first. */
|
/* TODO: when nvram is on nand flash check for bad blocks first. */
|
||||||
off = FLASH_MIN;
|
off = FLASH_MIN;
|
||||||
while (off <= lim) {
|
while (off <= lim) {
|
||||||
@@ -166,6 +188,12 @@ int nvram_getenv(char *name, char *val,
|
@@ -179,6 +201,12 @@ int bcm47xx_nvram_getenv(char *name, cha
|
||||||
if (!nvram_buf[0])
|
return err;
|
||||||
early_nvram_init();
|
}
|
||||||
|
|
||||||
+ if (cfe_env) {
|
+ if (cfe_env) {
|
||||||
+ value = cfe_env_get(nvram_buf, name);
|
+ value = cfe_env_get(nvram_buf, name);
|
||||||
|
@ -294,9 +294,9 @@ out the configuration than the in kernel cfe config reader.
|
||||||
/* Look for name=value and return value */
|
/* Look for name=value and return value */
|
||||||
var = &nvram_buf[sizeof(struct nvram_header)];
|
var = &nvram_buf[sizeof(struct nvram_header)];
|
||||||
end = nvram_buf + sizeof(nvram_buf) - 2;
|
end = nvram_buf + sizeof(nvram_buf) - 2;
|
||||||
@@ -194,6 +222,9 @@ char *nvram_get(const char *name)
|
@@ -207,6 +235,9 @@ char *nvram_get(const char *name)
|
||||||
if (!nvram_buf[0])
|
if (!nvram_buf[0])
|
||||||
early_nvram_init();
|
nvram_init();
|
||||||
|
|
||||||
+ if (cfe_env)
|
+ if (cfe_env)
|
||||||
+ return cfe_env_get(nvram_buf, name);
|
+ return cfe_env_get(nvram_buf, name);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
--- a/arch/mips/bcm47xx/setup.c
|
--- a/arch/mips/bcm47xx/setup.c
|
||||||
+++ b/arch/mips/bcm47xx/setup.c
|
+++ b/arch/mips/bcm47xx/setup.c
|
||||||
@@ -120,6 +120,10 @@ static int bcm47xx_get_invariants(struct
|
@@ -120,6 +120,10 @@ static int bcm47xx_get_invariants(struct
|
||||||
if (nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
|
if (bcm47xx_nvram_getenv("cardbus", buf, sizeof(buf)) >= 0)
|
||||||
iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
|
iv->has_cardbus_slot = !!simple_strtoul(buf, NULL, 10);
|
||||||
|
|
||||||
+ /* Do not indicate cardbus for Netgear WNR834B V1 and V2 */
|
+ /* Do not indicate cardbus for Netgear WNR834B V1 and V2 */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
--- a/arch/mips/bcm47xx/nvram.c
|
--- a/arch/mips/bcm47xx/nvram.c
|
||||||
+++ b/arch/mips/bcm47xx/nvram.c
|
+++ b/arch/mips/bcm47xx/nvram.c
|
||||||
@@ -21,7 +21,8 @@
|
@@ -21,7 +21,8 @@
|
||||||
#include <asm/mach-bcm47xx/nvram.h>
|
#include <bcm47xx_nvram.h>
|
||||||
#include <asm/mach-bcm47xx/bcm47xx.h>
|
#include <asm/mach-bcm47xx/bcm47xx.h>
|
||||||
|
|
||||||
-static char nvram_buf[NVRAM_SPACE];
|
-static char nvram_buf[NVRAM_SPACE];
|
||||||
|
|
Loading…
Reference in a new issue