[PATCH][RFC] MIPS: BCM47XX: Move NVRAM driver to the drivers/firmware/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After Broadcom switched from MIPS to ARM for their home routers we need
to have NVRAM driver in some common place (not arch/mips/).
We were thinking about putting it in bus directory, however there are
two possible buses for MIPS: drivers/ssb/ and drivers/bcma/. So this
won't fit there neither.
This is why I would like to move this driver to the drivers/firmware/

Signed-off-by: Rafał Miłecki <zajec5@xxxxxxxxx>
---
Hey, this is another try for the NVRAM driver. At first I tried moving it to the
drivers/misc/, but then decided drivers/soc/ will be better. Then after
discussion with Paul we decided to try drivers/firmware/ and so I do.

Meanwhile I've sent few patches cleaning nvram.c: following kernel coding style
and using helpers like readl.

I would like to get few Reviewed-by for this patch. If I get that, then I'll
re-send this patch to Ralf without the RFC.

If you want to review nvram.c code, please make sure to check version in
ralf/upstream-sfr.git repository as it contains many cleanups:
git://git.linux-mips.org/pub/scm/ralf/upstream-sfr.git
http://git.linux-mips.org/cgit/ralf/upstream-sfr.git/log/

Mentioned patches (more cleanups):
http://patchwork.linux-mips.org/project/linux-mips/list/?submitter=478

Finally: why drivers/firmware/? Please see Paul's e-mail:
<alpine.DEB.2.02.1411271926560.1406@xxxxxxxxxxxxxxxxxx>
http://www.linux-mips.org/archives/linux-mips/2014-11/msg00678.html

Unfortunately there is no mailing list for drivers/firmware/, so I've
picked ppl with 5+ commits to this directory. Hope this is OK.
---
 arch/mips/Kconfig                                             |  1 +
 arch/mips/bcm47xx/Makefile                                    |  2 +-
 drivers/firmware/Kconfig                                      |  1 +
 drivers/firmware/Makefile                                     |  1 +
 drivers/firmware/broadcom/Kconfig                             | 11 +++++++++++
 drivers/firmware/broadcom/Makefile                            |  1 +
 .../nvram.c => drivers/firmware/broadcom/bcm47xx_nvram.c      |  2 ++
 include/linux/bcm47xx_nvram.h                                 |  2 +-
 8 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 drivers/firmware/broadcom/Kconfig
 create mode 100644 drivers/firmware/broadcom/Makefile
 rename arch/mips/bcm47xx/nvram.c => drivers/firmware/broadcom/bcm47xx_nvram.c (99%)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index d093889..ed9da3b 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -174,6 +174,7 @@ config BCM47XX
 	select USE_GENERIC_EARLY_PRINTK_8250
 	select GPIOLIB
 	select LEDS_GPIO_REGISTER
+	select BCM47XX_NVRAM
 	help
 	 Support for BCM47XX based boards
 
diff --git a/arch/mips/bcm47xx/Makefile b/arch/mips/bcm47xx/Makefile
index d58c51b..66bea4e 100644
--- a/arch/mips/bcm47xx/Makefile
+++ b/arch/mips/bcm47xx/Makefile
@@ -3,5 +3,5 @@
 # under Linux.
 #
 
-obj-y				+= irq.o nvram.o prom.o serial.o setup.o time.o sprom.o
+obj-y				+= irq.o prom.o serial.o setup.o time.o sprom.o
 obj-y				+= board.o buttons.o leds.o workarounds.o
diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
index 4198388..ffbc9e4 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -132,6 +132,7 @@ config ISCSI_IBFT
 	  detect iSCSI boot parameters dynamically during system boot, say Y.
 	  Otherwise, say N.
 
+source "drivers/firmware/broadcom/Kconfig"
 source "drivers/firmware/google/Kconfig"
 source "drivers/firmware/efi/Kconfig"
 
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile
index 5373dc5..e251f2b 100644
--- a/drivers/firmware/Makefile
+++ b/drivers/firmware/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_ISCSI_IBFT_FIND)	+= iscsi_ibft_find.o
 obj-$(CONFIG_ISCSI_IBFT)	+= iscsi_ibft.o
 obj-$(CONFIG_FIRMWARE_MEMMAP)	+= memmap.o
 
+obj-y				+= broadcom/
 obj-$(CONFIG_GOOGLE_FIRMWARE)	+= google/
 obj-$(CONFIG_EFI)		+= efi/
 obj-$(CONFIG_UEFI_CPER)		+= efi/
diff --git a/drivers/firmware/broadcom/Kconfig b/drivers/firmware/broadcom/Kconfig
new file mode 100644
index 0000000..6bed119
--- /dev/null
+++ b/drivers/firmware/broadcom/Kconfig
@@ -0,0 +1,11 @@
+config BCM47XX_NVRAM
+	bool "Broadcom NVRAM driver"
+	depends on BCM47XX || ARCH_BCM_5301X
+	help
+	  Broadcom home routers contain flash partition called "nvram" with all
+	  important hardware configuration as well as some minor user setup.
+	  NVRAM partition contains a text-like data representing name=value
+	  pairs.
+	  This driver provides an easy way to get value of requested parameter.
+	  It simply reads content of NVRAM and parses it. It doesn't control any
+	  hardware part itself.
diff --git a/drivers/firmware/broadcom/Makefile b/drivers/firmware/broadcom/Makefile
new file mode 100644
index 0000000..d0e6835
--- /dev/null
+++ b/drivers/firmware/broadcom/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_BCM47XX_NVRAM)		+= bcm47xx_nvram.o
diff --git a/arch/mips/bcm47xx/nvram.c b/drivers/firmware/broadcom/bcm47xx_nvram.c
similarity index 99%
rename from arch/mips/bcm47xx/nvram.c
rename to drivers/firmware/broadcom/bcm47xx_nvram.c
index 2975187..fe8c8c9 100644
--- a/arch/mips/bcm47xx/nvram.c
+++ b/drivers/firmware/broadcom/bcm47xx_nvram.c
@@ -228,3 +228,5 @@ int bcm47xx_nvram_gpio_pin(const char *name)
 	return -ENOENT;
 }
 EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
+
+MODULE_LICENSE("GPLv2");
diff --git a/include/linux/bcm47xx_nvram.h b/include/linux/bcm47xx_nvram.h
index b12b07e..0e52a92 100644
--- a/include/linux/bcm47xx_nvram.h
+++ b/include/linux/bcm47xx_nvram.h
@@ -11,7 +11,7 @@
 #include <linux/types.h>
 #include <linux/kernel.h>
 
-#ifdef CONFIG_BCM47XX
+#ifdef CONFIG_BCM47XX_NVRAM
 int bcm47xx_nvram_init_from_mem(u32 base, u32 lim);
 int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
 int bcm47xx_nvram_gpio_pin(const char *name);
-- 
1.8.4.5






[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux