aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm53xx/patches-3.14/111-bcm47xx-nvram-add-new-nvram-driver-with-dt-support.patch
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2014-08-24 15:57:49 +0000
committerHauke Mehrtens <hauke@hauke-m.de>2014-08-24 15:57:49 +0000
commit823659f458637665ebb91bcf25fae22e4ab74d6b (patch)
treecb13ff278a99b276b38c857936cdf445eb0ce2d8 /target/linux/bcm53xx/patches-3.14/111-bcm47xx-nvram-add-new-nvram-driver-with-dt-support.patch
parentbefad7432bc17b6cb34ccc2bd1f0961cf161617c (diff)
downloadupstream-823659f458637665ebb91bcf25fae22e4ab74d6b.tar.gz
upstream-823659f458637665ebb91bcf25fae22e4ab74d6b.tar.bz2
upstream-823659f458637665ebb91bcf25fae22e4ab74d6b.zip
bcm53xx: update bcma device tree intergeneration and fix nvram parsing
This fixes lots of sparse and checkpatch errors and extends the documentation. This also fixes a problem in the nvram parser, it now detects the correct nvram on my Netgear R6250. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> SVN-Revision: 42272
Diffstat (limited to 'target/linux/bcm53xx/patches-3.14/111-bcm47xx-nvram-add-new-nvram-driver-with-dt-support.patch')
-rw-r--r--target/linux/bcm53xx/patches-3.14/111-bcm47xx-nvram-add-new-nvram-driver-with-dt-support.patch142
1 files changed, 93 insertions, 49 deletions
diff --git a/target/linux/bcm53xx/patches-3.14/111-bcm47xx-nvram-add-new-nvram-driver-with-dt-support.patch b/target/linux/bcm53xx/patches-3.14/111-bcm47xx-nvram-add-new-nvram-driver-with-dt-support.patch
index a53e86d4b5..78997ed268 100644
--- a/target/linux/bcm53xx/patches-3.14/111-bcm47xx-nvram-add-new-nvram-driver-with-dt-support.patch
+++ b/target/linux/bcm53xx/patches-3.14/111-bcm47xx-nvram-add-new-nvram-driver-with-dt-support.patch
@@ -1,30 +1,64 @@
-From 60a413ed5bc7917f1612df441240f458163b10c1 Mon Sep 17 00:00:00 2001
+From 71a6bff8656a1713615ffdd9139a83d65ba46c6d Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Sat, 3 May 2014 22:54:59 +0200
-Subject: [PATCH 03/15] bcm47xx-nvram: add new nvram driver with dt support
+Subject: [PATCH 02/17] bcm47xx-nvram: add new broadcom nvram driver with dt
+ support
-This adds a new nvrm driver which uses device tree to provide nvram
-access to other drivers. You have to specify the memory ranges where
-the flash chip is mapped and this driver will search there for some
-nvram and parse it. Other drivers can use this driver to access the
+This adds a new driver which searches at a given memory range for a
+nvram like it is used on the bcm47xx and bcm53xx SoCs with ARM and MIPS
+CPUs. This driver provides acces to this nvram to other device in the
+device tree. You have to specify the memory ranges where the content of
+the flash chip is memory mapped and this driver will search there for
+some nvram and parse it. Other drivers can use this driver to access the
device nvram. The nvram is used to store board configurations like the
-mac address and also for configuration values in the vendor firmware.
+mac addresses, the switch configuration and the calibration data for
+the wifi devices.
+
+This was copied from arch/mips/bcm47xx/nvram.c and modified to interact
+with device tree. My plan is to make the MIPS bcm47xx also use this new
+driver some time later.
+
+Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
- arch/mips/bcm47xx/board.c | 36 +++---
- arch/mips/bcm47xx/nvram.c | 7 +-
- arch/mips/bcm47xx/setup.c | 4 +-
- arch/mips/bcm47xx/sprom.c | 4 +-
- arch/mips/bcm47xx/time.c | 2 +-
- drivers/misc/Kconfig | 5 +
- drivers/misc/Makefile | 1 +
- drivers/misc/bcm47xx-nvram.c | 211 ++++++++++++++++++++++++++++++++++
- drivers/net/ethernet/broadcom/b44.c | 2 +-
- drivers/net/ethernet/broadcom/bgmac.c | 4 +-
- drivers/ssb/driver_chipcommon_pmu.c | 2 +-
- include/linux/bcm47xx_nvram.h | 16 ++-
- 12 files changed, 259 insertions(+), 35 deletions(-)
+ .../devicetree/bindings/misc/bcm47xx-nvram.txt | 19 ++
+ arch/mips/bcm47xx/board.c | 40 ++--
+ arch/mips/bcm47xx/nvram.c | 7 +-
+ arch/mips/bcm47xx/setup.c | 4 +-
+ arch/mips/bcm47xx/sprom.c | 4 +-
+ arch/mips/bcm47xx/time.c | 2 +-
+ drivers/misc/Kconfig | 5 +
+ drivers/misc/Makefile | 1 +
+ drivers/misc/bcm47xx-nvram.c | 215 +++++++++++++++++++++
+ drivers/net/ethernet/broadcom/b44.c | 2 +-
+ drivers/net/ethernet/broadcom/bgmac.c | 5 +-
+ drivers/ssb/driver_chipcommon_pmu.c | 3 +-
+ include/linux/bcm47xx_nvram.h | 17 +-
+ 13 files changed, 286 insertions(+), 38 deletions(-)
+ create mode 100644 Documentation/devicetree/bindings/misc/bcm47xx-nvram.txt
create mode 100644 drivers/misc/bcm47xx-nvram.c
+--- /dev/null
++++ b/Documentation/devicetree/bindings/misc/bcm47xx-nvram.txt
+@@ -0,0 +1,19 @@
++Broadcom bcm47xx/bcm53xx nvram access driver
++
++This driver provides access to the nvram for other drivers.
++
++Required properties:
++
++- compatible : brcm,bcm47xx-nvram
++
++- reg : iomem address range
++
++On NorthStar ARM SoCs the NAND flash is available at 0x1c000000 and the
++NOR flash is at 0x1e000000
++
++Example:
++
++nvram0: nvram@0 {
++ compatible = "brcm,bcm47xx-nvram";
++ reg = <0x1c000000 0x01000000>;
++};
--- a/arch/mips/bcm47xx/board.c
+++ b/arch/mips/bcm47xx/board.c
@@ -196,50 +196,50 @@ static __init const struct bcm47xx_board
@@ -226,7 +260,7 @@ mac address and also for configuration values in the vendor firmware.
+obj-$(CONFIG_BCM47XX_NVRAM) += bcm47xx-nvram.o
--- /dev/null
+++ b/drivers/misc/bcm47xx-nvram.c
-@@ -0,0 +1,211 @@
+@@ -0,0 +1,215 @@
+/*
+ * BCM947xx nvram variable access
+ *
@@ -259,12 +293,12 @@ mac address and also for configuration values in the vendor firmware.
+
+static u32 find_nvram_size(void __iomem *end)
+{
-+ struct nvram_header *header;
++ struct nvram_header __iomem *header;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
-+ header = (struct nvram_header *)(end - nvram_sizes[i]);
-+ if (header->magic == NVRAM_HEADER)
++ header = (struct nvram_header __iomem *)(end - nvram_sizes[i]);
++ if (__raw_readl(&header->magic) == NVRAM_HEADER)
+ return nvram_sizes[i];
+ }
+
@@ -276,10 +310,11 @@ mac address and also for configuration values in the vendor firmware.
+ size_t len, char **nvram_buf,
+ size_t *nvram_len)
+{
-+ struct nvram_header *header;
++ struct nvram_header __iomem *header;
+ int i;
+ u32 off;
-+ u32 *src, *dst;
++ u32 *dst;
++ __le32 __iomem *src;
+ u32 size;
+
+ /* TODO: when nvram is on nand flash check for bad blocks first. */
@@ -288,21 +323,22 @@ mac address and also for configuration values in the vendor firmware.
+ /* Windowed flash access */
+ size = find_nvram_size(base + off);
+ if (size) {
-+ header = (struct nvram_header *)(base + off - size);
++ header = (struct nvram_header __iomem *)
++ (base + off - size);
+ goto found;
+ }
-+ off <<= 1;
++ off += 0x10000;
+ }
+
+ /* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
-+ header = (struct nvram_header *)(base + 4096);
-+ if (header->magic == NVRAM_HEADER) {
++ header = (struct nvram_header __iomem *)(base + 4096);
++ if (__raw_readl(&header->magic) == NVRAM_HEADER) {
+ size = NVRAM_SPACE;
+ goto found;
+ }
+
-+ header = (struct nvram_header *)(base + 1024);
-+ if (header->magic == NVRAM_HEADER) {
++ header = (struct nvram_header __iomem *)(base + 1024);
++ if (__raw_readl(&header->magic) == NVRAM_HEADER) {
+ size = NVRAM_SPACE;
+ goto found;
+ }
@@ -313,25 +349,26 @@ mac address and also for configuration values in the vendor firmware.
+ return -ENXIO;
+
+found:
-+ if (header->len > size)
++ if (readl(&header->len) > size)
+ pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
-+ *nvram_len = min_t(u32, header->len, size);
++ *nvram_len = min_t(u32, readl(&header->len), size);
+
+ *nvram_buf = devm_kzalloc(dev, *nvram_len, GFP_KERNEL);
+ if (!*nvram_buf)
+ return -ENOMEM;
+
-+ src = (u32 *) header;
++ src = (__le32 __iomem *) header;
+ dst = (u32 *) *nvram_buf;
+ for (i = 0; i < sizeof(struct nvram_header); i += 4)
-+ *dst++ = *src++;
++ *dst++ = __raw_readl(src++);
+ for (; i < *nvram_len; i += 4)
-+ *dst++ = le32_to_cpu(*src++);
++ *dst++ = readl(src++);
+
+ return 0;
+}
+
-+int bcm47xx_nvram_getenv(const struct device *dev, const char *name, char *val, size_t val_len)
++int bcm47xx_nvram_getenv(const struct device *dev, const char *name, char *val,
++ size_t val_len)
+{
+ char *var, *value, *end, *eq;
+ struct bcm47xx_nvram *nvram;
@@ -407,7 +444,8 @@ mac address and also for configuration values in the vendor firmware.
+ if (!mmio)
+ return -ENOMEM;
+
-+ err = nvram_find_and_copy(dev, mmio, resource_size(&flash_mem), &nvram->nvram_buf, &nvram->nvram_len);
++ err = nvram_find_and_copy(dev, mmio, resource_size(&flash_mem),
++ &nvram->nvram_buf, &nvram->nvram_len);
+ if (err)
+ goto err_unmap_mmio;
+
@@ -451,16 +489,17 @@ mac address and also for configuration values in the vendor firmware.
err = __b44_readphy(bp, 0, MII_BMCR, &val);
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
-@@ -974,7 +974,7 @@ static void bgmac_chip_reset(struct bgma
+@@ -974,7 +974,8 @@ static void bgmac_chip_reset(struct bgma
BGMAC_CHIPCTL_1_IF_TYPE_MII;
char buf[4];
- if (bcm47xx_nvram_getenv("et_swtype", buf, sizeof(buf)) > 0) {
-+ if (bcm47xx_nvram_getenv(NULL, "et_swtype", buf, sizeof(buf)) > 0) {
++ if (bcm47xx_nvram_getenv(NULL, "et_swtype", buf,
++ sizeof(buf)) > 0) {
if (kstrtou8(buf, 0, &et_swtype))
bgmac_err(bgmac, "Failed to parse et_swtype (%s)\n",
buf);
-@@ -1534,7 +1534,7 @@ static int bgmac_probe(struct bcma_devic
+@@ -1534,7 +1535,7 @@ static int bgmac_probe(struct bcma_devic
}
bgmac->int_mask = BGMAC_IS_ERRMASK | BGMAC_IS_RX | BGMAC_IS_TX_MASK;
@@ -471,18 +510,19 @@ mac address and also for configuration values in the vendor firmware.
/* TODO: reset the external phy. Specs are needed */
--- a/drivers/ssb/driver_chipcommon_pmu.c
+++ b/drivers/ssb/driver_chipcommon_pmu.c
-@@ -319,7 +319,7 @@ static void ssb_pmu_pll_init(struct ssb_
+@@ -319,7 +319,8 @@ static void ssb_pmu_pll_init(struct ssb_
if (bus->bustype == SSB_BUSTYPE_SSB) {
char buf[20];
- if (bcm47xx_nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0)
-+ if (bcm47xx_nvram_getenv(NULL, "xtalfreq", buf, sizeof(buf)) >= 0)
++ if (bcm47xx_nvram_getenv(NULL, "xtalfreq", buf,
++ sizeof(buf)) >= 0)
crystalfreq = simple_strtoul(buf, NULL, 0);
}
--- a/include/linux/bcm47xx_nvram.h
+++ b/include/linux/bcm47xx_nvram.h
-@@ -15,6 +15,8 @@
+@@ -15,9 +15,11 @@
#include <linux/types.h>
#include <linux/kernel.h>
@@ -490,8 +530,12 @@ mac address and also for configuration values in the vendor firmware.
+
struct nvram_header {
u32 magic;
- u32 len;
-@@ -33,17 +35,21 @@ struct nvram_header {
+- u32 len;
++ __le32 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 */
+@@ -33,18 +35,21 @@ struct nvram_header {
#define NVRAM_MAX_VALUE_LEN 255
#define NVRAM_MAX_PARAM_LEN 64
@@ -504,10 +548,10 @@ mac address and also for configuration values in the vendor firmware.
-int bcm47xx_nvram_gpio_pin(const char *name);
+int bcm47xx_nvram_gpio_pin(const struct device *dev, const char *name);
#else
--static inline int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
+-static inline int bcm47xx_nvram_getenv(const char *name, char *val,
+static inline int bcm47xx_nvram_getenv(const struct device *dev,
+ const char *name, char *val,
-+ size_t val_len)
+ size_t val_len)
{
return -ENXIO;
}