brcm47xx: backport MIPS BCM47XX changes queued for 4.2
[openwrt.git] / target / linux / brcm47xx / patches-3.18 / 820-wgt634u-nvram-fix.patch
index e2bbdcc..c543e8e 100644 (file)
@@ -12,7 +12,7 @@ out the configuration than the in kernel cfe config reader.
 +obj-y                         += cfe_env.o
 --- /dev/null
 +++ b/arch/mips/bcm47xx/cfe_env.c
-@@ -0,0 +1,229 @@
+@@ -0,0 +1,228 @@
 +/*
 + * CFE environment variable access
 + *
@@ -138,8 +138,7 @@ out the configuration than the in kernel cfe config reader.
 + * @return    value of variable or NULL if undefined
 + */
 +
-+char* 
-+cfe_env_get(unsigned char *nv_buf, char* name)
++char *cfe_env_get(unsigned char *nv_buf, const char *name)
 +{
 +    int size;
 +    unsigned char *buffer;
@@ -244,25 +243,25 @@ out the configuration than the in kernel cfe config reader.
 +
 --- a/arch/mips/bcm47xx/nvram.c
 +++ b/arch/mips/bcm47xx/nvram.c
-@@ -22,6 +22,8 @@
+@@ -36,6 +36,8 @@ struct nvram_header {
  
  static char nvram_buf[NVRAM_SPACE];
  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(u32 end)
+ static u32 find_nvram_size(void __iomem *end)
  {
-@@ -46,6 +48,26 @@ static int nvram_find_and_copy(u32 base,
-       u32 *src, *dst;
-       u32 size;
+@@ -65,6 +67,26 @@ static int nvram_find_and_copy(void __io
+               return -EEXIST;
+       }
  
 +      cfe_env = 0;
 +
 +      /* XXX: hack for supporting the CFE environment stuff on WGT634U */
 +      if (lim >= 8 * 1024 * 1024) {
-+              src = (u32 *) KSEG1ADDR(base + 8 * 1024 * 1024 - 0x2000);
-+              dst = (u32 *) nvram_buf;
++              src = (u32 *)(iobase + 8 * 1024 * 1024 - 0x2000);
++              dst = (u32 *)nvram_buf;
 +
 +              if ((*src & 0xff00ff) == 0x000001) {
 +                      printk("early_nvram_init: WGT634U NVRAM found.\n");
@@ -280,7 +279,7 @@ out the configuration than the in kernel cfe config reader.
        /* TODO: when nvram is on nand flash check for bad blocks first. */
        off = FLASH_MIN;
        while (off <= lim) {
-@@ -172,6 +194,13 @@ int bcm47xx_nvram_getenv(char *name, cha
+@@ -189,6 +211,13 @@ int bcm47xx_nvram_getenv(const char *nam
                        return err;
        }
  
@@ -293,4 +292,4 @@ out the configuration than the in kernel cfe config reader.
 +
        /* Look for name=value and return value */
        var = &nvram_buf[sizeof(struct nvram_header)];
-       end = nvram_buf + sizeof(nvram_buf) - 2;
+       end = nvram_buf + sizeof(nvram_buf);