+
--- a/arch/mips/bcm47xx/nvram.c
+++ b/arch/mips/bcm47xx/nvram.c
-@@ -36,6 +36,8 @@ struct nvram_header {
-
+@@ -37,6 +37,8 @@ struct nvram_header {
static char nvram_buf[NVRAM_SPACE];
+ static size_t nvram_len;
static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
+static int cfe_env;
+extern char *cfe_env_get(char *nv_buf, const char *name);
static u32 find_nvram_size(void __iomem *end)
{
-@@ -65,6 +67,26 @@ static int nvram_find_and_copy(void __io
+@@ -66,6 +68,26 @@ static int nvram_find_and_copy(void __io
return -EEXIST;
}
/* TODO: when nvram is on nand flash check for bad blocks first. */
off = FLASH_MIN;
while (off <= lim) {
-@@ -189,6 +211,13 @@ int bcm47xx_nvram_getenv(const char *nam
- return err;
- }
+@@ -180,6 +202,13 @@ int bcm47xx_nvram_getenv(const char *nam
+ if (!name)
+ return -EINVAL;
+ if (cfe_env) {
+ value = cfe_env_get(nvram_buf, name);
+ return snprintf(val, val_len, "%s", value);
+ }
+
- /* Look for name=value and return value */
- var = &nvram_buf[sizeof(struct nvram_header)];
- end = nvram_buf + sizeof(nvram_buf);
+ if (!nvram_len) {
+ err = nvram_init();
+ if (err)