* [PATCH 1/6] MIPS: BCM47XX: use common error codes in nvram reads
2012-12-26 20:51 [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Hauke Mehrtens
@ 2012-12-26 20:51 ` Hauke Mehrtens
2012-12-26 20:51 ` [PATCH 2/6] MIPS: BCM47XX: return error when init of nvram failed Hauke Mehrtens
` (6 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Hauke Mehrtens @ 2012-12-26 20:51 UTC (permalink / raw)
To: john, ralf; +Cc: linux-mips, zajec5, Hauke Mehrtens
Instead of using our own error codes use some common codes.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
arch/mips/bcm47xx/nvram.c | 4 ++--
arch/mips/bcm47xx/sprom.c | 2 +-
arch/mips/include/asm/mach-bcm47xx/nvram.h | 3 ---
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
index 6461367..e19fc26 100644
--- a/arch/mips/bcm47xx/nvram.c
+++ b/arch/mips/bcm47xx/nvram.c
@@ -124,7 +124,7 @@ int nvram_getenv(char *name, char *val, size_t val_len)
char *var, *value, *end, *eq;
if (!name)
- return NVRAM_ERR_INV_PARAM;
+ return -EINVAL;
if (!nvram_buf[0])
early_nvram_init();
@@ -143,6 +143,6 @@ int nvram_getenv(char *name, char *val, size_t val_len)
return snprintf(val, val_len, "%s", value);
}
}
- return NVRAM_ERR_ENVNOTFOUND;
+ return -ENOENT;
}
EXPORT_SYMBOL(nvram_getenv);
diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
index 289cc0a..66b71c3 100644
--- a/arch/mips/bcm47xx/sprom.c
+++ b/arch/mips/bcm47xx/sprom.c
@@ -51,7 +51,7 @@ static int get_nvram_var(const char *prefix, const char *postfix,
create_key(prefix, postfix, name, key, sizeof(key));
err = nvram_getenv(key, buf, len);
- if (fallback && err == NVRAM_ERR_ENVNOTFOUND && prefix) {
+ if (fallback && err == -ENOENT && prefix) {
create_key(NULL, postfix, name, key, sizeof(key));
err = nvram_getenv(key, buf, len);
}
diff --git a/arch/mips/include/asm/mach-bcm47xx/nvram.h b/arch/mips/include/asm/mach-bcm47xx/nvram.h
index 69ef3ef..550a7fc 100644
--- a/arch/mips/include/asm/mach-bcm47xx/nvram.h
+++ b/arch/mips/include/asm/mach-bcm47xx/nvram.h
@@ -32,9 +32,6 @@ struct nvram_header {
#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])
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 2/6] MIPS: BCM47XX: return error when init of nvram failed
2012-12-26 20:51 [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Hauke Mehrtens
2012-12-26 20:51 ` [PATCH 1/6] MIPS: BCM47XX: use common error codes in nvram reads Hauke Mehrtens
@ 2012-12-26 20:51 ` Hauke Mehrtens
2012-12-26 20:51 ` [PATCH 3/6] MIPS: BCM47XX: nvram add nand flash support Hauke Mehrtens
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Hauke Mehrtens @ 2012-12-26 20:51 UTC (permalink / raw)
To: john, ralf; +Cc: linux-mips, zajec5, Hauke Mehrtens
This makes it possible to handle the case of not being able to read the
nvram ram. This could happen when the code searching for the specific
flash chip have not run jet.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
arch/mips/bcm47xx/nvram.c | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
index e19fc26..80e352e 100644
--- a/arch/mips/bcm47xx/nvram.c
+++ b/arch/mips/bcm47xx/nvram.c
@@ -23,7 +23,7 @@
static char nvram_buf[NVRAM_SPACE];
-static void nvram_find_and_copy(u32 base, u32 lim)
+static int nvram_find_and_copy(u32 base, u32 lim)
{
struct nvram_header *header;
int i;
@@ -49,7 +49,7 @@ static void nvram_find_and_copy(u32 base, u32 lim)
if (header->magic == NVRAM_HEADER)
goto found;
- return;
+ return -ENXIO;
found:
src = (u32 *) header;
@@ -58,10 +58,12 @@ found:
*dst++ = *src++;
for (; i < header->len && i < NVRAM_SPACE; i += 4)
*dst++ = le32_to_cpu(*src++);
+
+ return 0;
}
#ifdef CONFIG_BCM47XX_SSB
-static void nvram_init_ssb(void)
+static int nvram_init_ssb(void)
{
struct ssb_mipscore *mcore = &bcm47xx_bus.ssb.mipscore;
u32 base;
@@ -72,15 +74,15 @@ static void nvram_init_ssb(void)
lim = mcore->pflash.window_size;
} else {
pr_err("Couldn't find supported flash memory\n");
- return;
+ return -ENXIO;
}
- nvram_find_and_copy(base, lim);
+ return nvram_find_and_copy(base, lim);
}
#endif
#ifdef CONFIG_BCM47XX_BCMA
-static void nvram_init_bcma(void)
+static int nvram_init_bcma(void)
{
struct bcma_drv_cc *cc = &bcm47xx_bus.bcma.bus.drv_cc;
u32 base;
@@ -96,38 +98,41 @@ static void nvram_init_bcma(void)
#endif
} else {
pr_err("Couldn't find supported flash memory\n");
- return;
+ return -ENXIO;
}
- nvram_find_and_copy(base, lim);
+ return nvram_find_and_copy(base, lim);
}
#endif
-static void early_nvram_init(void)
+static int early_nvram_init(void)
{
switch (bcm47xx_bus_type) {
#ifdef CONFIG_BCM47XX_SSB
case BCM47XX_BUS_TYPE_SSB:
- nvram_init_ssb();
- break;
+ return nvram_init_ssb();
#endif
#ifdef CONFIG_BCM47XX_BCMA
case BCM47XX_BUS_TYPE_BCMA:
- nvram_init_bcma();
- break;
+ return nvram_init_bcma();
#endif
}
+ return -ENXIO;
}
int nvram_getenv(char *name, char *val, size_t val_len)
{
char *var, *value, *end, *eq;
+ int err;
if (!name)
return -EINVAL;
- if (!nvram_buf[0])
- early_nvram_init();
+ if (!nvram_buf[0]) {
+ err = early_nvram_init();
+ if (err)
+ return err;
+ }
/* Look for name=value and return value */
var = &nvram_buf[sizeof(struct nvram_header)];
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 3/6] MIPS: BCM47XX: nvram add nand flash support
2012-12-26 20:51 [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Hauke Mehrtens
2012-12-26 20:51 ` [PATCH 1/6] MIPS: BCM47XX: use common error codes in nvram reads Hauke Mehrtens
2012-12-26 20:51 ` [PATCH 2/6] MIPS: BCM47XX: return error when init of nvram failed Hauke Mehrtens
@ 2012-12-26 20:51 ` Hauke Mehrtens
2012-12-26 20:51 ` [PATCH 4/6] MIPS: BCM47XX: rename early_nvram_init to nvram_init Hauke Mehrtens
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Hauke Mehrtens @ 2012-12-26 20:51 UTC (permalink / raw)
To: john, ralf; +Cc: linux-mips, zajec5, Hauke Mehrtens
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
arch/mips/bcm47xx/nvram.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
index 80e352e..42e5271 100644
--- a/arch/mips/bcm47xx/nvram.c
+++ b/arch/mips/bcm47xx/nvram.c
@@ -30,6 +30,7 @@ static int nvram_find_and_copy(u32 base, u32 lim)
u32 off;
u32 *src, *dst;
+ /* TODO: when nvram is on nand flash check for bad blocks first. */
off = FLASH_MIN;
while (off <= lim) {
/* Windowed flash access */
@@ -88,6 +89,12 @@ static int nvram_init_bcma(void)
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;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 4/6] MIPS: BCM47XX: rename early_nvram_init to nvram_init
2012-12-26 20:51 [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Hauke Mehrtens
` (2 preceding siblings ...)
2012-12-26 20:51 ` [PATCH 3/6] MIPS: BCM47XX: nvram add nand flash support Hauke Mehrtens
@ 2012-12-26 20:51 ` Hauke Mehrtens
2012-12-26 20:51 ` [PATCH 5/6] MIPS: BCM47XX: handle different nvram sizes Hauke Mehrtens
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Hauke Mehrtens @ 2012-12-26 20:51 UTC (permalink / raw)
To: john, ralf; +Cc: linux-mips, zajec5, Hauke Mehrtens
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
arch/mips/bcm47xx/nvram.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
index 42e5271..6cf3ef2 100644
--- a/arch/mips/bcm47xx/nvram.c
+++ b/arch/mips/bcm47xx/nvram.c
@@ -112,7 +112,7 @@ static int nvram_init_bcma(void)
}
#endif
-static int early_nvram_init(void)
+static int nvram_init(void)
{
switch (bcm47xx_bus_type) {
#ifdef CONFIG_BCM47XX_SSB
@@ -136,7 +136,7 @@ int nvram_getenv(char *name, char *val, size_t val_len)
return -EINVAL;
if (!nvram_buf[0]) {
- err = early_nvram_init();
+ err = nvram_init();
if (err)
return err;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 5/6] MIPS: BCM47XX: handle different nvram sizes
2012-12-26 20:51 [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Hauke Mehrtens
` (3 preceding siblings ...)
2012-12-26 20:51 ` [PATCH 4/6] MIPS: BCM47XX: rename early_nvram_init to nvram_init Hauke Mehrtens
@ 2012-12-26 20:51 ` Hauke Mehrtens
2012-12-26 20:51 ` [PATCH 6/6] MIPS: BCM47XX: add bcm47xx prefix in front of nvram function names Hauke Mehrtens
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Hauke Mehrtens @ 2012-12-26 20:51 UTC (permalink / raw)
To: john, ralf; +Cc: linux-mips, zajec5, Hauke Mehrtens
The old code just worked for nvram with a size of 0x8000 bytes. This
patch adds support for reading nvram from partitions of 0xF000 and
0x10000 bytes.
There is just 32KB space for the nvram, but most devices do not use the
full size and this code reads the first 32KB in that case and prints a
warning.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
arch/mips/bcm47xx/nvram.c | 46 ++++++++++++++++++++++++++++++++++++++-------
1 file changed, 39 insertions(+), 7 deletions(-)
diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
index 6cf3ef2..b4a47fc 100644
--- a/arch/mips/bcm47xx/nvram.c
+++ b/arch/mips/bcm47xx/nvram.c
@@ -3,7 +3,7 @@
*
* Copyright (C) 2005 Broadcom Corporation
* Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
- * Copyright (C) 2010-2011 Hauke Mehrtens <hauke@hauke-m.de>
+ * Copyright (C) 2010-2012 Hauke Mehrtens <hauke@hauke-m.de>
*
* 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
@@ -23,42 +23,74 @@
static char nvram_buf[NVRAM_SPACE];
+static u32 find_nvram_size(u32 end)
+{
+ struct nvram_header *header;
+ u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
+ header = (struct nvram_header *)KSEG1ADDR(end - nvram_sizes[i]);
+ if (header->magic == NVRAM_HEADER)
+ return nvram_sizes[i];
+ }
+
+ return 0;
+}
+
+/* Probe for NVRAM header */
static int nvram_find_and_copy(u32 base, u32 lim)
{
struct nvram_header *header;
int i;
u32 off;
u32 *src, *dst;
+ u32 size;
/* TODO: when nvram is on nand flash check for bad blocks first. */
off = FLASH_MIN;
while (off <= lim) {
/* Windowed flash access */
- header = (struct nvram_header *)
- KSEG1ADDR(base + off - NVRAM_SPACE);
- if (header->magic == NVRAM_HEADER)
+ size = find_nvram_size(base + off);
+ if (size) {
+ header = (struct nvram_header *)KSEG1ADDR(base + off -
+ size);
goto found;
+ }
off <<= 1;
}
/* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
header = (struct nvram_header *) KSEG1ADDR(base + 4096);
- if (header->magic == NVRAM_HEADER)
+ if (header->magic == NVRAM_HEADER) {
+ size = NVRAM_SPACE;
goto found;
+ }
header = (struct nvram_header *) KSEG1ADDR(base + 1024);
- if (header->magic == NVRAM_HEADER)
+ if (header->magic == NVRAM_HEADER) {
+ size = NVRAM_SPACE;
goto found;
+ }
+ pr_err("no nvram found\n");
return -ENXIO;
found:
+
+ if (header->len > size)
+ pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
+ if (header->len > NVRAM_SPACE)
+ pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
+ header->len, NVRAM_SPACE);
+
src = (u32 *) header;
dst = (u32 *) nvram_buf;
for (i = 0; i < sizeof(struct nvram_header); i += 4)
*dst++ = *src++;
- for (; i < header->len && i < NVRAM_SPACE; i += 4)
+ for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4)
*dst++ = le32_to_cpu(*src++);
+ memset(dst, 0x0, NVRAM_SPACE - i);
return 0;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 6/6] MIPS: BCM47XX: add bcm47xx prefix in front of nvram function names
2012-12-26 20:51 [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Hauke Mehrtens
` (4 preceding siblings ...)
2012-12-26 20:51 ` [PATCH 5/6] MIPS: BCM47XX: handle different nvram sizes Hauke Mehrtens
@ 2012-12-26 20:51 ` Hauke Mehrtens
2012-12-27 8:49 ` [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Rafał Miłecki
2012-12-28 0:01 ` Rafał Miłecki
7 siblings, 0 replies; 12+ messages in thread
From: Hauke Mehrtens @ 2012-12-26 20:51 UTC (permalink / raw)
To: john, ralf; +Cc: linux-mips, zajec5, Hauke Mehrtens
The nvram functions are exported and used by some normal drivers. To
prevent name clashes with ofter parts of the kernel code add a bcm47xx_
prefix in front of the function names and the header file name.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
arch/mips/bcm47xx/nvram.c | 6 +++---
arch/mips/bcm47xx/setup.c | 6 +++---
arch/mips/bcm47xx/sprom.c | 8 ++++----
.../include/asm/mach-bcm47xx/{nvram.h => bcm47xx_nvram.h} | 10 +++++-----
drivers/mtd/bcm47xxpart.c | 2 +-
drivers/net/ethernet/broadcom/b44.c | 4 ++--
drivers/ssb/driver_chipcommon_pmu.c | 4 ++--
include/linux/ssb/ssb_driver_gige.h | 6 +++---
8 files changed, 23 insertions(+), 23 deletions(-)
rename arch/mips/include/asm/mach-bcm47xx/{nvram.h => bcm47xx_nvram.h} (84%)
diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
index b4a47fc..e63bd5a 100644
--- a/arch/mips/bcm47xx/nvram.c
+++ b/arch/mips/bcm47xx/nvram.c
@@ -18,7 +18,7 @@
#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];
@@ -159,7 +159,7 @@ static int nvram_init(void)
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;
int err;
@@ -189,4 +189,4 @@ int nvram_getenv(char *name, char *val, size_t val_len)
}
return -ENOENT;
}
-EXPORT_SYMBOL(nvram_getenv);
+EXPORT_SYMBOL(bcm47xx_nvram_getenv);
diff --git a/arch/mips/bcm47xx/setup.c b/arch/mips/bcm47xx/setup.c
index 4d54b58..b2246cd 100644
--- 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 ssb_bus *bus,
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(void)
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;
diff --git a/arch/mips/bcm47xx/sprom.c b/arch/mips/bcm47xx/sprom.c
index 66b71c3..89b9bf4 100644
--- 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 *prefix, const char *postfix,
create_key(prefix, postfix, name, key, sizeof(key));
- err = nvram_getenv(key, buf, len);
+ 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 char *prefix, const char *name,
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,
diff --git a/arch/mips/include/asm/mach-bcm47xx/nvram.h b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
similarity index 84%
rename from arch/mips/include/asm/mach-bcm47xx/nvram.h
rename to arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
index 550a7fc..b8e7be8 100644
--- a/arch/mips/include/asm/mach-bcm47xx/nvram.h
+++ b/arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
@@ -8,8 +8,8 @@
* option) any later version.
*/
-#ifndef __NVRAM_H
-#define __NVRAM_H
+#ifndef __BCM47XX_NVRAM_H
+#define __BCM47XX_NVRAM_H
#include <linux/types.h>
#include <linux/kernel.h>
@@ -32,9 +32,9 @@ struct nvram_header {
#define NVRAM_MAX_VALUE_LEN 255
#define NVRAM_MAX_PARAM_LEN 64
-extern int nvram_getenv(char *name, char *val, size_t val_len);
+extern int bcm47xx_nvram_getenv(char *name, char *val, size_t val_len);
-static inline void nvram_parse_macaddr(char *buf, u8 macaddr[6])
+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],
@@ -48,4 +48,4 @@ static inline void nvram_parse_macaddr(char *buf, u8 macaddr[6])
printk(KERN_WARNING "Can not parse mac address: %s\n", buf);
}
-#endif
+#endif /* __BCM47XX_NVRAM_H */
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index e06d782..6a11805 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -14,7 +14,7 @@
#include <linux/slab.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
-#include <asm/mach-bcm47xx/nvram.h>
+#include <bcm47xx_nvram.h>
/* 10 parts were found on sflash on Netgear WNDR4500 */
#define BCM47XXPART_MAX_PARTS 12
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 219f622..330b090 100644
--- 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 *bp, u32 local, u32 remote)
}
#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(struct b44 *bp)
* 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);
diff --git a/drivers/ssb/driver_chipcommon_pmu.c b/drivers/ssb/driver_chipcommon_pmu.c
index a43415a..4c0f6d8 100644
--- 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_chipcommon *cc)
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
}
diff --git a/include/linux/ssb/ssb_driver_gige.h b/include/linux/ssb/ssb_driver_gige.h
index 6b05dcd..6d92a92 100644
--- 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_posted_writes(struct pci_dev *pdev)
}
#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)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements
2012-12-26 20:51 [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Hauke Mehrtens
` (5 preceding siblings ...)
2012-12-26 20:51 ` [PATCH 6/6] MIPS: BCM47XX: add bcm47xx prefix in front of nvram function names Hauke Mehrtens
@ 2012-12-27 8:49 ` Rafał Miłecki
2012-12-27 12:54 ` Hauke Mehrtens
2012-12-28 0:01 ` Rafał Miłecki
7 siblings, 1 reply; 12+ messages in thread
From: Rafał Miłecki @ 2012-12-27 8:49 UTC (permalink / raw)
To: Hauke Mehrtens; +Cc: john, ralf, linux-mips
2012/12/26 Hauke Mehrtens <hauke@hauke-m.de>:
> Clean up the nvram reading code and add support for different nvram
> sizes.
>
> This depends on patch "MIPS: bcm47xx: separate functions finding flash
> window addr" by Rafał Miłeck, Patchwork: https://patchwork.linux-mips.org/patch/4738/
>
> Hauke Mehrtens (6):
> MIPS: BCM47XX: use common error codes in nvram reads
> MIPS: BCM47XX: return error when init of nvram failed
> MIPS: BCM47XX: nvram add nand flash support
> MIPS: BCM47XX: rename early_nvram_init to nvram_init
> MIPS: BCM47XX: handle different nvram sizes
> MIPS: BCM47XX: add bcm47xx prefix in front of nvram function names
Hm, the only question? Why so late ;) I've spent 3 hours yesterday
debugging nvram on my WNDR4500, it didn't fill SPROM of PCIe cards
correctly. Will test your patches today.
--
Rafał
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements
2012-12-27 8:49 ` [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Rafał Miłecki
@ 2012-12-27 12:54 ` Hauke Mehrtens
2012-12-28 0:00 ` Rafał Miłecki
0 siblings, 1 reply; 12+ messages in thread
From: Hauke Mehrtens @ 2012-12-27 12:54 UTC (permalink / raw)
To: Rafał Miłecki; +Cc: john, ralf, linux-mips
On 12/27/2012 09:49 AM, Rafał Miłecki wrote:
> 2012/12/26 Hauke Mehrtens <hauke@hauke-m.de>:
>> Clean up the nvram reading code and add support for different nvram
>> sizes.
>>
>> This depends on patch "MIPS: bcm47xx: separate functions finding flash
>> window addr" by Rafał Miłeck, Patchwork: https://patchwork.linux-mips.org/patch/4738/
>>
>> Hauke Mehrtens (6):
>> MIPS: BCM47XX: use common error codes in nvram reads
>> MIPS: BCM47XX: return error when init of nvram failed
>> MIPS: BCM47XX: nvram add nand flash support
>> MIPS: BCM47XX: rename early_nvram_init to nvram_init
>> MIPS: BCM47XX: handle different nvram sizes
>> MIPS: BCM47XX: add bcm47xx prefix in front of nvram function names
>
> Hm, the only question? Why so late ;) I've spent 3 hours yesterday
> debugging nvram on my WNDR4500, it didn't fill SPROM of PCIe cards
> correctly. Will test your patches today.
I waited till the bit in the flash part in bcma got into the mips tree.
Most of the patches in this series were already in my tree and OpenWrt
for some time.
Does it work now? Your patch was the most important one. In this series
only the "handle different nvram sizes" could fix the problem with your
device.
Hauke
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements
2012-12-27 12:54 ` Hauke Mehrtens
@ 2012-12-28 0:00 ` Rafał Miłecki
2012-12-28 11:32 ` Hauke Mehrtens
0 siblings, 1 reply; 12+ messages in thread
From: Rafał Miłecki @ 2012-12-28 0:00 UTC (permalink / raw)
To: Hauke Mehrtens; +Cc: john, ralf, linux-mips
2012/12/27 Hauke Mehrtens <hauke@hauke-m.de>:
> On 12/27/2012 09:49 AM, Rafał Miłecki wrote:
>> 2012/12/26 Hauke Mehrtens <hauke@hauke-m.de>:
>>> Clean up the nvram reading code and add support for different nvram
>>> sizes.
>>>
>>> This depends on patch "MIPS: bcm47xx: separate functions finding flash
>>> window addr" by Rafał Miłeck, Patchwork: https://patchwork.linux-mips.org/patch/4738/
>>>
>>> Hauke Mehrtens (6):
>>> MIPS: BCM47XX: use common error codes in nvram reads
>>> MIPS: BCM47XX: return error when init of nvram failed
>>> MIPS: BCM47XX: nvram add nand flash support
>>> MIPS: BCM47XX: rename early_nvram_init to nvram_init
>>> MIPS: BCM47XX: handle different nvram sizes
>>> MIPS: BCM47XX: add bcm47xx prefix in front of nvram function names
>>
>> Hm, the only question? Why so late ;) I've spent 3 hours yesterday
>> debugging nvram on my WNDR4500, it didn't fill SPROM of PCIe cards
>> correctly. Will test your patches today.
>
> I waited till the bit in the flash part in bcma got into the mips tree.
> Most of the patches in this series were already in my tree and OpenWrt
> for some time.
>
> Does it work now? Your patch was the most important one. In this series
> only the "handle different nvram sizes" could fix the problem with your
> device.
I didn't have access to the hardware until now. It seems to be working
now! I don't get invalid SPROM with rev 0 anymore.
The only message log that bothers me is:
[ 0.716000] bcma: bus1: invalid sprom read from the PCIe card, try
to use fallback sprom
[ 0.812000] can not parse nvram name pci/1/1/mcsbw402gpo(null) with
value 0x0x88800000 got -22
I didn't have time to track it yet.
--
Rafał
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements
2012-12-28 0:00 ` Rafał Miłecki
@ 2012-12-28 11:32 ` Hauke Mehrtens
0 siblings, 0 replies; 12+ messages in thread
From: Hauke Mehrtens @ 2012-12-28 11:32 UTC (permalink / raw)
To: Rafał Miłecki; +Cc: john, ralf, linux-mips
On 12/28/2012 01:00 AM, Rafał Miłecki wrote:
> 2012/12/27 Hauke Mehrtens <hauke@hauke-m.de>:
>> On 12/27/2012 09:49 AM, Rafał Miłecki wrote:
>>> 2012/12/26 Hauke Mehrtens <hauke@hauke-m.de>:
>>>> Clean up the nvram reading code and add support for different nvram
>>>> sizes.
>>>>
>>>> This depends on patch "MIPS: bcm47xx: separate functions finding flash
>>>> window addr" by Rafał Miłeck, Patchwork: https://patchwork.linux-mips.org/patch/4738/
>>>>
>>>> Hauke Mehrtens (6):
>>>> MIPS: BCM47XX: use common error codes in nvram reads
>>>> MIPS: BCM47XX: return error when init of nvram failed
>>>> MIPS: BCM47XX: nvram add nand flash support
>>>> MIPS: BCM47XX: rename early_nvram_init to nvram_init
>>>> MIPS: BCM47XX: handle different nvram sizes
>>>> MIPS: BCM47XX: add bcm47xx prefix in front of nvram function names
>>>
>>> Hm, the only question? Why so late ;) I've spent 3 hours yesterday
>>> debugging nvram on my WNDR4500, it didn't fill SPROM of PCIe cards
>>> correctly. Will test your patches today.
>>
>> I waited till the bit in the flash part in bcma got into the mips tree.
>> Most of the patches in this series were already in my tree and OpenWrt
>> for some time.
>>
>> Does it work now? Your patch was the most important one. In this series
>> only the "handle different nvram sizes" could fix the problem with your
>> device.
>
> I didn't have access to the hardware until now. It seems to be working
> now! I don't get invalid SPROM with rev 0 anymore.
>
> The only message log that bothers me is:
> [ 0.716000] bcma: bus1: invalid sprom read from the PCIe card, try
> to use fallback sprom
> [ 0.812000] can not parse nvram name pci/1/1/mcsbw402gpo(null) with
> value 0x0x88800000 got -22
Nice, an other form of invalid syntax (0x0x88800000) in the nvram, lets
see what the vendors do next. ;-)
This particular issue should not be a problem neither b43 nor brcmsmac
is reading this value and all the other values should be read from nvram
correctly.
Hauke
> I didn't have time to track it yet.
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements
2012-12-26 20:51 [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Hauke Mehrtens
` (6 preceding siblings ...)
2012-12-27 8:49 ` [PATCH 0/6] MIPS: BCM47XX: nvram read enhancements Rafał Miłecki
@ 2012-12-28 0:01 ` Rafał Miłecki
7 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2012-12-28 0:01 UTC (permalink / raw)
To: Hauke Mehrtens; +Cc: john, ralf, linux-mips
2012/12/26 Hauke Mehrtens <hauke@hauke-m.de>:
> Clean up the nvram reading code and add support for different nvram
> sizes.
>
> This depends on patch "MIPS: bcm47xx: separate functions finding flash
> window addr" by Rafał Miłeck, Patchwork: https://patchwork.linux-mips.org/patch/4738/
>
> Hauke Mehrtens (6):
> MIPS: BCM47XX: use common error codes in nvram reads
> MIPS: BCM47XX: return error when init of nvram failed
> MIPS: BCM47XX: nvram add nand flash support
> MIPS: BCM47XX: rename early_nvram_init to nvram_init
> MIPS: BCM47XX: handle different nvram sizes
> MIPS: BCM47XX: add bcm47xx prefix in front of nvram function names
Tested-by: Rafał Miłecki <zajec5@gmail.com>
I wonder if it would be easier to write nvram.c from the scratch ;)
--
Rafał
^ permalink raw reply [flat|nested] 12+ messages in thread