aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/brcm47xx/patches-3.18/030-06-MIPS-BCM47XX-Use-mtd-as-an-alternative-way-API-to-ge.patch
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-04-07 11:54:18 +0000
committerRafał Miłecki <zajec5@gmail.com>2015-04-07 11:54:18 +0000
commit3fa00eeda227f7e2f182718509a8a3b8cc163668 (patch)
tree1884133421c05d053073c5a8cf801e0f909db8db /target/linux/brcm47xx/patches-3.18/030-06-MIPS-BCM47XX-Use-mtd-as-an-alternative-way-API-to-ge.patch
parentbeca028bd6bb71898052faadff680d8e76f61eb3 (diff)
downloadupstream-3fa00eeda227f7e2f182718509a8a3b8cc163668.tar.gz
upstream-3fa00eeda227f7e2f182718509a8a3b8cc163668.tar.bz2
upstream-3fa00eeda227f7e2f182718509a8a3b8cc163668.zip
brcm47xx: group MIPS BCM47XX backported patches by source kernel
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 45287
Diffstat (limited to 'target/linux/brcm47xx/patches-3.18/030-06-MIPS-BCM47XX-Use-mtd-as-an-alternative-way-API-to-ge.patch')
-rw-r--r--target/linux/brcm47xx/patches-3.18/030-06-MIPS-BCM47XX-Use-mtd-as-an-alternative-way-API-to-ge.patch88
1 files changed, 88 insertions, 0 deletions
diff --git a/target/linux/brcm47xx/patches-3.18/030-06-MIPS-BCM47XX-Use-mtd-as-an-alternative-way-API-to-ge.patch b/target/linux/brcm47xx/patches-3.18/030-06-MIPS-BCM47XX-Use-mtd-as-an-alternative-way-API-to-ge.patch
new file mode 100644
index 0000000000..7f19d3ac65
--- /dev/null
+++ b/target/linux/brcm47xx/patches-3.18/030-06-MIPS-BCM47XX-Use-mtd-as-an-alternative-way-API-to-ge.patch
@@ -0,0 +1,88 @@
+From 9d1d08646af4491aec41d40341930b9bfd62ffa9 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
+Date: Wed, 29 Oct 2014 10:05:06 +0100
+Subject: [PATCH] MIPS: BCM47XX: Use mtd as an alternative way/API to get NVRAM
+ content
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+NVRAM can be read using magic memory offset, but after all it's just a
+flash partition. On platforms where NVRAM isn't needed early we can get
+it using mtd subsystem.
+
+Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
+Acked-by: Hauke Mehrtens <hauke@hauke-m.de>
+Cc: linux-mips@linux-mips.org
+Patchwork: https://patchwork.linux-mips.org/patch/8266/
+Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
+---
+ arch/mips/bcm47xx/nvram.c | 42 ++++++++++++++++++++++++++++++++++++++----
+ 1 file changed, 38 insertions(+), 4 deletions(-)
+
+diff --git a/arch/mips/bcm47xx/nvram.c b/arch/mips/bcm47xx/nvram.c
+index 21712fb..8b64991 100644
+--- a/arch/mips/bcm47xx/nvram.c
++++ b/arch/mips/bcm47xx/nvram.c
+@@ -13,12 +13,10 @@
+
+ #include <linux/types.h>
+ #include <linux/module.h>
+-#include <linux/ssb/ssb.h>
+ #include <linux/kernel.h>
+ #include <linux/string.h>
+-#include <asm/addrspace.h>
++#include <linux/mtd/mtd.h>
+ #include <bcm47xx_nvram.h>
+-#include <asm/mach-bcm47xx/bcm47xx.h>
+
+ static char nvram_buf[NVRAM_SPACE];
+ static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
+@@ -123,7 +121,43 @@ int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
+
+ static int nvram_init(void)
+ {
+- /* TODO: Look for MTD "nvram" partition */
++#ifdef CONFIG_MTD
++ struct mtd_info *mtd;
++ struct nvram_header header;
++ size_t bytes_read;
++ int err, i;
++
++ mtd = get_mtd_device_nm("nvram");
++ if (IS_ERR(mtd))
++ return -ENODEV;
++
++ for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
++ loff_t from = mtd->size - nvram_sizes[i];
++
++ if (from < 0)
++ continue;
++
++ err = mtd_read(mtd, from, sizeof(header), &bytes_read,
++ (uint8_t *)&header);
++ if (!err && header.magic == NVRAM_HEADER) {
++ u8 *dst = (uint8_t *)nvram_buf;
++ size_t len = header.len;
++
++ 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);
++ len = NVRAM_SPACE;
++ }
++
++ err = mtd_read(mtd, from, len, &bytes_read, dst);
++ if (err)
++ return err;
++ memset(dst + bytes_read, 0x0, NVRAM_SPACE - bytes_read);
++
++ return 0;
++ }
++ }
++#endif
+
+ return -ENXIO;
+ }
+--
+1.8.4.5
+