Skip to contentSkip to conversation

MIPS: BCM47XX: Move NVRAM driver to the drivers/firmware/

RFC PATCH In review Rafał Miłecki 2 participants 3 messages Dec 10, 2014 – Dec 22, 2014

Subsystems (3)
lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

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

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/

---
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:
<[email protected]>
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%)
arch/mips/Kconfig +1 -0
index d093889..ed9da3b 100644
@@ -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
 
arch/mips/bcm47xx/Makefile +1 -1
index d58c51b..66bea4e 100644
@@ -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
drivers/firmware/Kconfig +1 -0
index 4198388..ffbc9e4 100644
@@ -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"
 
drivers/firmware/Makefile +1 -0
index 5373dc5..e251f2b 100644
@@ -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/
drivers/firmware/broadcom/Kconfig new file +11 -0
new file mode 100644
index 0000000..6bed119
@@ -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.
drivers/firmware/broadcom/Makefile new file +1 -0
new file mode 100644
index 0000000..d0e6835
@@ -0,0 +1 @@
+obj-$(CONFIG_BCM47XX_NVRAM)		+= bcm47xx_nvram.o
drivers/firmware/broadcom/bcm47xx_nvram.c renamed from arch/mips/bcm47xx/nvram.c +2 -0
similarity index 99%
rename from arch/mips/bcm47xx/nvram.c
rename to drivers/firmware/broadcom/bcm47xx_nvram.c
index 2975187..fe8c8c9 100644
@@ -228,3 +228,5 @@ int bcm47xx_nvram_gpio_pin(const char *name)
 	return -ENOENT;
 }
 EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
+
+MODULE_LICENSE("GPLv2");
include/linux/bcm47xx_nvram.h +1 -1
index b12b07e..0e52a92 100644
@@ -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);
Signature · 1 line
1.8.4.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Rafał Miłecki

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/

---
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

Quoted 6 lines

Finally: why drivers/firmware/? Please see Paul's e-mail:
<[email protected]>
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.

Just to restate, if it's unclear for any other reviewers (as it initially was for me): this isn't an NVRAM driver as most folks understand the term. This "NVRAM" code parses SoC configuration data that is passed to the kernel in flash from the bootloader firmware, "CFE".

- Paul

author maintainer
#2 lore raw
Quoted 36 lines · Paul Walmsley
Quoted 27 lines · Rafał Miłecki

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/

---
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

Quoted 6 lines

Finally: why drivers/firmware/? Please see Paul's e-mail:
<[email protected]>
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.

Quoted 6 lines

Just to restate, if it's unclear for any other reviewers (as it initially was for me): this isn't an NVRAM driver as most folks understand the term. This "NVRAM" code parses SoC configuration data that is passed to the kernel in flash from the bootloader firmware, "CFE".

Thanks Paul.

Could anyone else review this, please?

Signature · 1 line
Rafał