[OpenWrt-Devel] [PATCH][HACK] bcma: add hack to init NVRAM content from NAND flash
Rafał Miłecki
zajec5 at gmail.com
Fri Sep 5 10:23:17 EDT 2014
---
Hauke: if you happen to update our code/drivers to what we sent
upstream, you may want to use this hack for now.
---
drivers/bcma/main.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 297a2d4..8216c4a 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -244,6 +244,28 @@ static void bcma_unregister_cores(struct bcma_bus *bus)
platform_device_unregister(bus->drv_cc.watchdog);
}
+/* We don't have driver for NAND flash yet, so getting NVRAM using mtd won't
+ * work. As a temporary workaround let's read NVRAM using flash mapping to the
+ * memory. This is not safe as we ignore OOB, some blocks could be marked as
+ * bad!
+ */
+extern int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
+static void bcma_init_nvram_from_nand(struct bcma_bus *bus)
+{
+ struct bcma_drv_cc *cc = &bus->drv_cc;
+
+ if (cc->core->id.rev == 42) {
+ struct bcma_device *core;
+
+ core = bcma_find_core(bus, BCMA_CORE_NS_ROM);
+ if (core) {
+ if ((bcma_aread32(core, BCMA_IOST) & BCMA_NS_ROM_IOST_BOOT_DEV_MASK) == BCMA_NS_ROM_IOST_BOOT_DEV_NAND) {
+ bcm47xx_nvram_init_from_mem(0x1c000000, 0x200000);
+ }
+ }
+ }
+}
+
int bcma_bus_register(struct bcma_bus *bus)
{
int err;
@@ -273,6 +295,8 @@ int bcma_bus_register(struct bcma_bus *bus)
bcma_register_core(bus, core);
}
+ bcma_init_nvram_from_nand(bus);
+
/* Try to get SPROM */
err = bcma_sprom_get(bus);
if (err == -ENOENT) {
--
1.8.4.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list