1 --- a/arch/mips/bcm47xx/nvram.c
2 +++ b/arch/mips/bcm47xx/nvram.c
4 #include <asm/addrspace.h>
5 #include <asm/mach-bcm47xx/nvram.h>
6 #include <asm/mach-bcm47xx/bcm47xx.h>
7 +#include <asm/mach-bcm47xx/bus.h>
9 static char nvram_buf[NVRAM_SPACE];
11 /* Probe for NVRAM header */
12 -static void early_nvram_init(void)
13 +static void early_nvram_init_pflash(void)
15 #ifdef CONFIG_BCM47XX_SSB
16 struct ssb_chipcommon *ssb_cc;
17 @@ -50,9 +51,6 @@ static void early_nvram_init(void)
18 #ifdef CONFIG_BCM47XX_BCMA
19 case BCM47XX_BUS_TYPE_BCMA:
20 bcma_cc = &bcm47xx_bus.bcma.bus.drv_cc;
21 - if (bcma_cc->flash_type != BCMA_PFLASH)
24 base = bcma_cc->pflash.window;
25 lim = bcma_cc->pflash.window_size;
27 @@ -86,7 +84,106 @@ found:
28 for (i = 0; i < sizeof(struct nvram_header); i += 4)
30 for (; i < header->len && i < NVRAM_SPACE; i += 4)
31 - *dst++ = le32_to_cpu(*src++);
35 +static int early_nvram_init_sflash(void)
37 + struct nvram_header header;
43 + /* check if the struct is already initilized */
44 + if (!bcm47xx_sflash.size)
48 + while (off <= bcm47xx_sflash.size) {
49 + ret = bcm47xx_sflash.read(&bcm47xx_sflash, off - NVRAM_SPACE, sizeof(header), (u8 *)&header);
50 + if (ret != sizeof(header))
52 + if (header.magic == NVRAM_HEADER)
58 + while (off <= bcm47xx_sflash.size) {
59 + ret = bcm47xx_sflash.read(&bcm47xx_sflash, off - (2 * NVRAM_SPACE), sizeof(header), (u8 *)&header);
60 + if (ret != sizeof(header))
62 + if (header.magic == NVRAM_HEADER)
72 + ret = bcm47xx_sflash.read(&bcm47xx_sflash, off - (2 * NVRAM_SPACE), len, dst);
82 +#ifdef CONFIG_BCM47XX_SSB
83 +static void early_nvram_init_ssb(void)
87 + switch (bcm47xx_bus.ssb.chipco.flash_type) {
89 + early_nvram_init_pflash();
91 + err = early_nvram_init_sflash();
93 + printk(KERN_WARNING "can not read from flash: %i\n", err);
95 + printk(KERN_WARNING "unknow flash type\n");
100 +#ifdef CONFIG_BCM47XX_BCMA
101 +static void early_nvram_init_bcma(void)
105 + switch (bcm47xx_bus.bcma.bus.drv_cc.flash_type) {
107 + early_nvram_init_pflash();
109 + err = early_nvram_init_sflash();
111 + printk(KERN_WARNING "can not read from flash: %i\n", err);
113 + printk(KERN_WARNING "unknow flash type\n");
118 +static void early_nvram_init(void)
120 + switch (bcm47xx_bus_type) {
121 +#ifdef CONFIG_BCM47XX_SSB
122 + case BCM47XX_BUS_TYPE_SSB:
123 + early_nvram_init_ssb();
126 +#ifdef CONFIG_BCM47XX_BCMA
127 + case BCM47XX_BUS_TYPE_BCMA:
128 + early_nvram_init_bcma();
134 int nvram_getenv(char *name, char *val, size_t val_len)