MIPS: BCM47XX: Move NVRAM driver to the drivers/soc/
Subsystems (7)
Rafał Miłecki
maintainerPATCH v2 1/1 MIPS: BCM47XX: Move NVRAM driver to the drivers/soc/
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/soc/
---
V2: Use drivers/soc/broadcom/ (instead of misc) and use -M for patch
I wasn't sure who to to/cc sending this patch. There isn't entry for drivers/soc/ in MAINTAINERS. I picked e-mails from the commit 3a6e08218f36baa9c49282ad2fe0dfbf001d8f23
soc: Introduce drivers/soc place-holder for SOC specific drivers
---
arch/mips/Kconfig | 1 +
arch/mips/bcm47xx/Makefile | 2 +-
arch/mips/bcm47xx/board.c | 2 +-
arch/mips/bcm47xx/setup.c | 1 -
arch/mips/bcm47xx/sprom.c | 1 -
arch/mips/bcm47xx/time.c | 1 -
arch/mips/include/asm/mach-bcm47xx/bcm47xx.h | 1 +
drivers/bcma/driver_mips.c | 2 +-
drivers/net/ethernet/broadcom/b44.c | 2 +-
drivers/net/ethernet/broadcom/bgmac.c | 2 +-
drivers/soc/Kconfig | 1 +
drivers/soc/Makefile | 1 +
drivers/soc/broadcom/Kconfig | 12 ++++++++++++
drivers/soc/broadcom/Makefile | 1 +
.../bcm47xx/nvram.c => drivers/soc/broadcom/bcm47xx_nvram.c | 4 +++-
drivers/ssb/driver_chipcommon_pmu.c | 2 +-
drivers/ssb/driver_mipscore.c | 2 +-
.../asm/mach-bcm47xx => include/linux}/bcm47xx_nvram.h | 3 ---
18 files changed, 27 insertions(+), 14 deletions(-)
create mode 100644 drivers/soc/broadcom/Kconfig
create mode 100644 drivers/soc/broadcom/Makefile
rename arch/mips/bcm47xx/nvram.c => drivers/soc/broadcom/bcm47xx_nvram.c (98%)
rename {arch/mips/include/asm/mach-bcm47xx => include/linux}/bcm47xx_nvram.h (84%)arch/mips/Kconfig +1 -0
@@ -134,6 +134,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
@@ -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
arch/mips/bcm47xx/board.c +1 -1
@@ -1,8 +1,8 @@#include <linux/errno.h> #include <linux/export.h> #include <linux/string.h> +#include <bcm47xx.h> #include <bcm47xx_board.h> -#include <bcm47xx_nvram.h> struct bcm47xx_board_type {const enum bcm47xx_board board;
arch/mips/bcm47xx/setup.c +0 -1
@@ -42,7 +42,6 @@#include <asm/reboot.h> #include <asm/time.h> #include <bcm47xx.h> -#include <bcm47xx_nvram.h> #include <bcm47xx_board.h> union bcm47xx_bus bcm47xx_bus;
arch/mips/bcm47xx/sprom.c +0 -1
@@ -27,7 +27,6 @@*/ #include <bcm47xx.h> -#include <bcm47xx_nvram.h> #include <linux/if_ether.h> #include <linux/etherdevice.h>
arch/mips/bcm47xx/time.c +0 -1
@@ -27,7 +27,6 @@#include <linux/ssb/ssb.h> #include <asm/time.h> #include <bcm47xx.h> -#include <bcm47xx_nvram.h> #include <bcm47xx_board.h> void __init plat_time_init (void )
arch/mips/include/asm/mach-bcm47xx/bcm47xx.h +1 -0
@@ -22,6 +22,7 @@#include <linux/ssb/ssb.h> #include <linux/bcma/bcma.h> #include <linux/bcma/bcma_soc.h> +#include <linux/bcm47xx_nvram.h> enum bcm47xx_bus_type {#ifdef CONFIG_BCM47XX_SSB
drivers/bcma/driver_mips.c +1 -1
@@ -21,7 +21,7 @@#include <linux/serial_reg.h> #include <linux/time.h> #ifdef CONFIG_BCM47XX -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> #endif enum bcma_boot_dev {
drivers/net/ethernet/broadcom/b44.c +1 -1
@@ -400,7 +400,7 @@ static void b44_set_flow_ctrl(struct b44 *bp, u32 local, u32 remote) }#ifdef CONFIG_BCM47XX -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> static void b44_wap54g10_workaround (struct b44 *bp) {char buf[20 ];
drivers/net/ethernet/broadcom/bgmac.c +1 -1
@@ -16,7 +16,7 @@#include <linux/phy.h> #include <linux/interrupt.h> #include <linux/dma-mapping.h> -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> static const struct bcma_device_id bgmac_bcma_tbl[] = {BCMA_CORE (BCMA_MANUF_BCM ,BCMA_CORE_4706_MAC_GBIT ,BCMA_ANY_REV ,BCMA_ANY_CLASS ),
drivers/soc/Kconfig +1 -0
@@ -1,5 +1,6 @@ menu "SOC (System On Chip) specific Drivers" +source "drivers/soc/broadcom/Kconfig" source "drivers/soc/qcom/Kconfig" source "drivers/soc/ti/Kconfig" source "drivers/soc/versatile/Kconfig"
drivers/soc/Makefile +1 -0
@@ -2,6 +2,7 @@ # Makefile for the Linux Kernel SOC specific device drivers. # +obj-y += broadcom/ obj-$(CONFIG_ARCH_QCOM) += qcom/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_SOC_TI) += ti/
drivers/soc/broadcom/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# +# Broadcom SoC drivers +# + +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. + It contains a text-like data representing name=value pairs. + This driver provides an easy way to get value of requested parameter.
drivers/soc/broadcom/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_BCM47XX_NVRAM) += bcm47xx_nvram.o
drivers/soc/broadcom/bcm47xx_nvram.c renamed from arch/mips/bcm47xx/nvram.c +3 -1
@@ -16,7 +16,7 @@#include <linux/kernel.h> #include <linux/string.h> #include <linux/mtd/mtd.h> -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> #define NVRAM_MAGIC 0x48534C46/* 'FLSH' */ #define NVRAM_SPACE 0x8000
@@ -226,3 +226,5 @@ int bcm47xx_nvram_gpio_pin(const char *name)return -ENOENT ; }EXPORT_SYMBOL (bcm47xx_nvram_gpio_pin); + +MODULE_LICENSE ("GPLv2" );
drivers/ssb/driver_chipcommon_pmu.c +1 -1
@@ -14,7 +14,7 @@#include <linux/delay.h> #include <linux/export.h> #ifdef CONFIG_BCM47XX -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> #endif #include "ssb_private.h"
drivers/ssb/driver_mipscore.c +1 -1
@@ -16,7 +16,7 @@#include <linux/serial_reg.h> #include <linux/time.h> #ifdef CONFIG_BCM47XX -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> #endif #include "ssb_private.h"
include/linux/bcm47xx_nvram.h renamed from arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h +0 -3
@@ -1,7 +1,4 @@/* -* Copyright (C) 2005, Broadcom Corporation -* Copyright (C) 2006, Felix Fietkau <[email protected]> -* * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your
Signature · 1 line
1.8.4.5
Hauke Mehrtens
maintainerQuoted 40 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/anddrivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to thedrivers/soc/Signed-off-by Rafał Miłecki <[email protected]>---
V2: Usedrivers/soc/broadcom/(instead of misc) and use -M for patchI wasn't sure who to to/cc sending this patch. There isn't entry for
drivers/soc/inMAINTAINERS. I picked e-mails from the commit3a6e08218f36baa9c49282ad2fe0dfbf001d8f23
soc: Introducedrivers/socplace-holder for SOC specific drivers--- arch/mips/Kconfig | 1 + arch/mips/bcm47xx/Makefile | 2 +- arch/mips/bcm47xx/board.c | 2 +- arch/mips/bcm47xx/setup.c | 1 - arch/mips/bcm47xx/sprom.c | 1 - arch/mips/bcm47xx/time.c | 1 - arch/mips/include/asm/mach-bcm47xx/bcm47xx.h | 1 + drivers/bcma/driver_mips.c | 2 +- drivers/net/ethernet/broadcom/b44.c | 2 +- drivers/net/ethernet/broadcom/bgmac.c | 2 +- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/broadcom/Kconfig | 12 ++++++++++++ drivers/soc/broadcom/Makefile | 1 + .../bcm47xx/nvram.c => drivers/soc/broadcom/bcm47xx_nvram.c | 4 +++- drivers/ssb/driver_chipcommon_pmu.c | 2 +- drivers/ssb/driver_mipscore.c | 2 +- .../asm/mach-bcm47xx => include/linux}/bcm47xx_nvram.h | 3 --- 18 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 drivers/soc/broadcom/Kconfig create mode 100644 drivers/soc/broadcom/Makefile rename arch/mips/bcm47xx/nvram.c => drivers/soc/broadcom/bcm47xx_nvram.c (98%) rename {arch/mips/include/asm/mach-bcm47xx => include/linux}/bcm47xx_nvram.h (84%)
....
Quoted 8 lines
drivers/soc/broadcom/Kconfig new file +2
-0@@ -0,0 +1,12 @@ +# +# Broadcom SoC drivers
drivers/soc/broadcom/Kconfig line 12
Quoted 10 lines
drivers/soc/broadcom/Kconfig new file +10
-0+# + +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. + It contains a text-like data representing name=value pairs. + This driver provides an easy way to get value of requested parameter.
You could also explicitly add that this "driver" does not drive any hardware. I think your text already says so, but it could be that someone does not understand this.
include/linux/bcm47xx_nvram.h line 4
Quoted 12 lines
include/linux/bcm47xx_nvram.h renamed from arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h +0
-3@@ -1,7 +1,4 @@/* -* Copyright (C) 2005, Broadcom Corporation -* Copyright (C) 2006, Felix Fietkau <[email protected]> -*
Any reason for removing these copyright statements? I think that nothing in this file is copyrightable, but I am not a lawyer and would not remove these lines.
Quoted 4 lines
include/linux/bcm47xx_nvram.h renamed from arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h +0
-0* This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your
Rafał Miłecki
maintainerPATCH v3 1/1 MIPS: BCM47XX: Move NVRAM driver to the drivers/soc/
In reply to Rafał MiłeckiAfter 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/soc/
---
V2: Use drivers/soc/broadcom/ (instead of misc) and use -M for patch
V3: Extend description in Kconfig by saying what this drivers does
Make calls to bcm47xx_nvram_* safe even with the driver disabled
Hauke: to address your question about .h copyrights.
1) I don't claim/have any copyrights to the bcm47xx_nvram_init_from_mem function name
2) I don't think you claim/have any copyrights to the bcm47xx_nvram_gpio_pin or bcm47xx_nvram_getenv function names
3) String "nvram_getenv" is not copyrightable
---
arch/mips/Kconfig | 1 +
arch/mips/bcm47xx/Makefile | 2 +-
arch/mips/bcm47xx/board.c | 2 +-
arch/mips/bcm47xx/setup.c | 1 -
arch/mips/bcm47xx/sprom.c | 1 -
arch/mips/bcm47xx/time.c | 1 -
arch/mips/include/asm/mach-bcm47xx/bcm47xx.h | 1 +
drivers/bcma/driver_mips.c | 2 +-
drivers/net/ethernet/broadcom/b44.c | 2 +-
drivers/net/ethernet/broadcom/bgmac.c | 2 +-
drivers/soc/Kconfig | 1 +
drivers/soc/Makefile | 1 +
drivers/soc/broadcom/Kconfig | 15 +++++++++++++++
drivers/soc/broadcom/Makefile | 1 +
.../nvram.c => drivers/soc/broadcom/bcm47xx_nvram.c | 4 +++-
drivers/ssb/driver_chipcommon_pmu.c | 2 +-
drivers/ssb/driver_mipscore.c | 2 +-
.../asm/mach-bcm47xx => include/linux}/bcm47xx_nvram.h | 16 +++++++++++++---
18 files changed, 43 insertions(+), 14 deletions(-)
create mode 100644 drivers/soc/broadcom/Kconfig
create mode 100644 drivers/soc/broadcom/Makefile
rename arch/mips/bcm47xx/nvram.c => drivers/soc/broadcom/bcm47xx_nvram.c (98%)
rename {arch/mips/include/asm/mach-bcm47xx => include/linux}/bcm47xx_nvram.h (63%)arch/mips/Kconfig +1 -0
@@ -134,6 +134,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
@@ -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
arch/mips/bcm47xx/board.c +1 -1
@@ -1,8 +1,8 @@#include <linux/errno.h> #include <linux/export.h> #include <linux/string.h> +#include <bcm47xx.h> #include <bcm47xx_board.h> -#include <bcm47xx_nvram.h> struct bcm47xx_board_type {const enum bcm47xx_board board;
arch/mips/bcm47xx/setup.c +0 -1
@@ -42,7 +42,6 @@#include <asm/reboot.h> #include <asm/time.h> #include <bcm47xx.h> -#include <bcm47xx_nvram.h> #include <bcm47xx_board.h> union bcm47xx_bus bcm47xx_bus;
arch/mips/bcm47xx/sprom.c +0 -1
@@ -27,7 +27,6 @@*/ #include <bcm47xx.h> -#include <bcm47xx_nvram.h> #include <linux/if_ether.h> #include <linux/etherdevice.h>
arch/mips/bcm47xx/time.c +0 -1
@@ -27,7 +27,6 @@#include <linux/ssb/ssb.h> #include <asm/time.h> #include <bcm47xx.h> -#include <bcm47xx_nvram.h> #include <bcm47xx_board.h> void __init plat_time_init (void )
arch/mips/include/asm/mach-bcm47xx/bcm47xx.h +1 -0
@@ -22,6 +22,7 @@#include <linux/ssb/ssb.h> #include <linux/bcma/bcma.h> #include <linux/bcma/bcma_soc.h> +#include <linux/bcm47xx_nvram.h> enum bcm47xx_bus_type {#ifdef CONFIG_BCM47XX_SSB
drivers/bcma/driver_mips.c +1 -1
@@ -21,7 +21,7 @@#include <linux/serial_reg.h> #include <linux/time.h> #ifdef CONFIG_BCM47XX -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> #endif enum bcma_boot_dev {
drivers/net/ethernet/broadcom/b44.c +1 -1
@@ -400,7 +400,7 @@ static void b44_set_flow_ctrl(struct b44 *bp, u32 local, u32 remote) }#ifdef CONFIG_BCM47XX -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> static void b44_wap54g10_workaround (struct b44 *bp) {char buf[20 ];
drivers/net/ethernet/broadcom/bgmac.c +1 -1
@@ -16,7 +16,7 @@#include <linux/phy.h> #include <linux/interrupt.h> #include <linux/dma-mapping.h> -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> static const struct bcma_device_id bgmac_bcma_tbl[] = {BCMA_CORE (BCMA_MANUF_BCM ,BCMA_CORE_4706_MAC_GBIT ,BCMA_ANY_REV ,BCMA_ANY_CLASS ),
drivers/soc/Kconfig +1 -0
@@ -1,5 +1,6 @@ menu "SOC (System On Chip) specific Drivers" +source "drivers/soc/broadcom/Kconfig" source "drivers/soc/qcom/Kconfig" source "drivers/soc/ti/Kconfig" source "drivers/soc/versatile/Kconfig"
drivers/soc/Makefile +1 -0
@@ -2,6 +2,7 @@ # Makefile for the Linux Kernel SOC specific device drivers. # +obj-y += broadcom/ obj-$(CONFIG_ARCH_QCOM) += qcom/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_SOC_TI) += ti/
drivers/soc/broadcom/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# +# Broadcom SoC drivers +# + +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/soc/broadcom/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_BCM47XX_NVRAM) += bcm47xx_nvram.o
drivers/soc/broadcom/bcm47xx_nvram.c renamed from arch/mips/bcm47xx/nvram.c +3 -1
@@ -16,7 +16,7 @@#include <linux/kernel.h> #include <linux/string.h> #include <linux/mtd/mtd.h> -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> #define NVRAM_MAGIC 0x48534C46/* 'FLSH' */ #define NVRAM_SPACE 0x8000
@@ -226,3 +226,5 @@ int bcm47xx_nvram_gpio_pin(const char *name)return -ENOENT ; }EXPORT_SYMBOL (bcm47xx_nvram_gpio_pin); + +MODULE_LICENSE ("GPLv2" );
drivers/ssb/driver_chipcommon_pmu.c +1 -1
@@ -14,7 +14,7 @@#include <linux/delay.h> #include <linux/export.h> #ifdef CONFIG_BCM47XX -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> #endif #include "ssb_private.h"
drivers/ssb/driver_mipscore.c +1 -1
@@ -16,7 +16,7 @@#include <linux/serial_reg.h> #include <linux/time.h> #ifdef CONFIG_BCM47XX -#include <bcm47xx_nvram.h> +#include <linux/bcm47xx_nvram.h> #endif #include "ssb_private.h"
include/linux/bcm47xx_nvram.h renamed from arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h +13 -3
@@ -1,7 +1,4 @@/* -* Copyright (C) 2005, Broadcom Corporation -* Copyright (C) 2006, Felix Fietkau <[email protected]> -* * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your
@@ -14,8 +11,21 @@#include <linux/types.h> #include <linux/kernel.h> +#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); +#else +static inline int bcm47xx_nvram_init_from_mem (u32 base,u32 lim) { +return -ENOTSUPP ; +}; +static inline int bcm47xx_nvram_getenv (const char *name,char *val, +size_t val_len) { +return -ENOTSUPP ; +}; +static inline int bcm47xx_nvram_gpio_pin (const char *name) { +return -ENOTSUPP ; +}; +#endif #endif /* __BCM47XX_NVRAM_H */
Signature · 1 line
1.8.4.5
Hi Rafał.
Quoted 2 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/).
So this is a driver for a chunk of NVRAM that's embedded in the SoC, hanging off an I/O bus?
Is this actually some kind of RAM, or is it flash, or something else?
Quoted 4 lines
We were thinking about putting it in bus directory, however there are two possible buses for MIPS:
drivers/ssb/anddrivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to thedrivers/soc/
Can't speak for anyone else, but I personally consider drivers/soc to be primarily intended for so-called "integration" IP blocks. Those are used for SoC control functions.
So low-level NVRAM drivers would probably go somewhere else. Here are some likely possibilities, where it can live with others of its kind (assuming it is something similar to RAM):
1. the PC "CMOS memory" NVRAM driver appears to be under drivers/char, as drivers/char/nvram.c.
2. there's a generic SRAM driver, drivers/misc/sram.c
3. while people have put some of the eFuse code under drivers/soc, in my opinion, the low-level fuse access code should really go under drivers/misc/fuse.
...
Looking at arch/mips/bcm47xx/nvram.c: if the low-level NVRAM probe code were moved elsewhere, the higher-level NVRAM "interpretation" functions still remain: bcm47xx_nvram_getenv() and bcm47xx_nvram_gpio_pin(). Those seem to be intended to parse device configuration data, yes? And this device configuration data is organized this way by platform software convention -- there's no hardware requirement to store data this way in the NVRAM, right?
Unfortunately the way that we organize device data parsing code in the kernel is quite frankly ... anarchic. In some kind of ideal world, we'd have a standard place for device data storage and parsing functions, and any combination of DT/ACPI/pdata/PCI/ISAPNP/whatever could be placed in use, depending on the software environment. But instead we have directories like drivers/acpi and drivers/of and drivers/base/platform and drivers/pnp and drivers/platform/chrome.
So if the answer to the above two questions is "yes," meaning that this NVRAM is used to store device probing data by software convention, then it would seem to me that proposing some place like drivers/devicedata/bcm47xx-nvram is a better bet (where "bcm47xx-nvram" is just some kind of opaque token). Looking at those two functions, it doesn't seem like there's really anything MIPS or Broadcom or NVRAM or even SoC-specific about key-value pair parsing and GPIO device data? Or am I missing something?
Actually, considering that bcm47xx_nvram_gpio_pin() isn't even used, can we just drop it and save the hassle? :-)
- Paul
Rafał Miłecki
maintainerQuoted 11 lines · Paul Walmsley
Hi Rafał.
Quoted 2 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/).So this is a driver for a chunk of NVRAM that's embedded in the SoC, hanging off an I/O bus?
Is this actually some kind of RAM, or is it flash, or something else?
I think you missed my description (help section) in Kconfig file :) As it says, NVRAM is a special partition on flash.
Quoted 13 lines
Quoted 4 lines
We were thinking about putting it in bus directory, however there are two possible buses for MIPS:
drivers/ssb/anddrivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to thedrivers/soc/Can't speak for anyone else, but I personally consider
drivers/socto be primarily intended for so-called "integration" IP blocks. Those are used for SoC control functions.So low-level NVRAM drivers would probably go somewhere else. Here are some likely possibilities, where it can live with others of its kind (assuming it is something similar to RAM):
Quoted 8 lines
1. the PC "CMOS memory" NVRAM driver appears to be under
drivers/char, asdrivers/char/nvram.c.2. there's a generic SRAM driver,
drivers/misc/sram.c3. while people have put some of the eFuse code under
drivers/soc, in my opinion, the low-level fuse access code should really go underdrivers/misc/fuse.
I don't think NVRAM can be treated as a standard char device. Also, in my V1 I tried moving it to the drivers/misc/, but then drivers/soc/ was suggested as a better place, see Arnd's reply:
http://www.linux-mips.org/archives/linux-mips/2014-11/msg00238.html
Quoted 7 lines
Looking at
arch/mips/bcm47xx/nvram.c: if the low-level NVRAM probe code were moved elsewhere, the higher-level NVRAM "interpretation" functions still remain:bcm47xx_nvram_getenv()andbcm47xx_nvram_gpio_pin(). Those seem to be intended to parse device configuration data, yes? And this device configuration data is organized this way by platform software convention -- there's no hardware requirement to store data this way in the NVRAM, right?
This bcm47xx_nvram driver has two ways of reading NVRAM content:
1) Using a standard MTD API to access "nvram" partition. In such case flash driver is a low-level thing if you call it so.
2) Using memory-mapped flash access window. In such case there isn't any extra low-level driver.
The "nvram" partition is required by the bootloader (CFE). It contains some important info like CPU clock, RAM configuration, switch ports layout. Then it's used by system drivers (like Ethernet driver bgmac) to get info about some particular hardware parts (like PHY address, MAC, etc.).
Quoted 11 lines
So if the answer to the above two questions is "yes," meaning that this NVRAM is used to store device probing data by software convention, then it would seem to me that proposing some place like
drivers/devicedata/bcm47xx-nvramis a better bet (where "bcm47xx-nvram" is just some kind of opaque token). Looking at those two functions, it doesn't seem like there's really anything MIPS or Broadcom or NVRAM or even SoC-specific about key-value pair parsing and GPIO device data? Or am I missing something?Actually, considering that
bcm47xx_nvram_gpio_pin()isn't even used, can we just drop it and save the hassle? :-)
We need this function to easily find GPIO responsible for "something". For example during switch initialization we need to reset it toggling GPIO. NVRAM contains info which GPIO should be toggled, e.g.:
gpio4=robo_reset
(robo means roboswitch)
bcm47xx_nvram_gpio_pin is needed by out-of-tree "b53" driver that some tried to push upstream, but was rejected because of API.
I'll also send a patch to USB host driver soon that will require bcm47xx_nvram_gpio_pin.
Signature · 1 line
Rafał
Hi Rafał,
Quoted 8 lines · Rafał Miłecki
Quoted 7 lines · Paul Walmsley
Hi Rafał.
Quoted 2 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/).
Quoted 6 lines
Quoted 4 lines
So this is a driver for a chunk of NVRAM that's embedded in the SoC, hanging off an I/O bus?
Is this actually some kind of RAM, or is it flash, or something else?
I think you missed my description (help section) in
Kconfigfile :)
That's correct. I only looked at the patch description in the E-mail, and the code in arch/mips/bcm47xx/nvram.c.
Quoted 1 line
As it says, NVRAM is a special partition on flash.
OK, thanks for the clarification.
Quoted 18 lines
Quoted 18 lines
Quoted 4 lines
We were thinking about putting it in bus directory, however there are two possible buses for MIPS:
drivers/ssb/anddrivers/bcma/. So this won't fit there neither.
This is why I would like to move this driver to thedrivers/soc/Can't speak for anyone else, but I personally consider
drivers/socto be primarily intended for so-called "integration" IP blocks. Those are used for SoC control functions.So low-level NVRAM drivers would probably go somewhere else. Here are some likely possibilities, where it can live with others of its kind (assuming it is something similar to RAM):
1. the PC "CMOS memory" NVRAM driver appears to be under
drivers/char, asdrivers/char/nvram.c.2. there's a generic SRAM driver,
drivers/misc/sram.c
Quoted 8 lines
Quoted 3 lines
3. while people have put some of the eFuse code under
drivers/soc, in my opinion, the low-level fuse access code should really go underdrivers/misc/fuse.I don't think NVRAM can be treated as a standard char device. Also, in my V1 I tried moving it to the
drivers/misc/, but thendrivers/soc/was suggested as a better place, see Arnd's reply:
http://www.linux-mips.org/archives/linux-mips/2014-11/msg00238.html
Yeah. It depends on who is going to merge the patch. If you can persuade someone else to merge it in drivers/soc, then it doesn't really matter what I think.
To my mind, drivers/soc was intended to fill a very narrow and specific
need: for low-level, hardware IP block drivers for so-called 'integration' IP blocks. These IP blocks generally control some combination of clocks, external muxing (pin mux), internal muxing, reset, IO cells/bricks, debug observability, etc., and tend to be very specific to particular SoC families. While it's certainly understandable that folks would like a place to move arbitrary code out of arch/*, drivers/soc was not intended to be that.
Quoted 11 lines
Quoted 7 lines
Looking at
arch/mips/bcm47xx/nvram.c: if the low-level NVRAM probe code were moved elsewhere, the higher-level NVRAM "interpretation" functions still remain:bcm47xx_nvram_getenv()andbcm47xx_nvram_gpio_pin(). Those seem to be intended to parse device configuration data, yes? And this device configuration data is organized this way by platform software convention -- there's no hardware requirement to store data this way in the NVRAM, right?This
bcm47xx_nvramdriver has two ways of reading NVRAM content:
1) Using a standard MTD API to access "nvram" partition. In such case flash driver is a low-level thing if you call it so.
OK, so just to confirm, you are referring to these drivers:
drivers/mtd/nand/bcm47xxnflash/*drivers/mtd/devices/bcm47xxsflash.cdrivers/ssb/driver_mipscore.c (for pflash)drivers/bcma/driver_mips.c (for pflash)
?
Just out of curiosity, the nvram.c code seems to contain some code to work around cases where the flash size is larger than the MMIO aperture, and to truncate the copy. Is there some way to program the flash controller to point the aperture at a different section of the flash?
Quoted 2 lines
2) Using memory-mapped flash access window. In such case there isn't any extra low-level driver.
Could you point me at the software entity that configures the memory-mapped flash access window and programs the flash controller to use one of {p,n,s}flash? Or is that done by some code external to the kernel, like the bootloader?
Quoted 5 lines
The "nvram" partition is required by the bootloader (CFE). It contains some important info like CPU clock, RAM configuration, switch ports layout. Then it's used by system drivers (like Ethernet driver bgmac) to get info about some particular hardware parts (like PHY address, MAC, etc.).
So it's not used by the on-chip boot-ROM? Sounds like it's just software convention, then? In other words, if one used a different bootloader, like u-boot, and passed a DT or something like that to the kernel, this wouldn't be needed. The presence and format of this flash is part of a specific hardware/software platform, external to the SoC hardware itself, that Broadcom suggests. It's analogous to ARM ATAGS - arch/arm/kernel/atags_parse.c. Does all this match your understanding? (I'm not advocating using a different bootloader or device data format - I think it's important to preserve compatibility with CPE - I am just trying to understand how this area of flash is used.)
Quoted 18 lines
Quoted 11 lines
So if the answer to the above two questions is "yes," meaning that this NVRAM is used to store device probing data by software convention, then it would seem to me that proposing some place like
drivers/devicedata/bcm47xx-nvramis a better bet (where "bcm47xx-nvram" is just some kind of opaque token). Looking at those two functions, it doesn't seem like there's really anything MIPS or Broadcom or NVRAM or even SoC-specific about key-value pair parsing and GPIO device data? Or am I missing something?Actually, considering that
bcm47xx_nvram_gpio_pin()isn't even used, can we just drop it and save the hassle? :-)We need this function to easily find GPIO responsible for "something". For example during switch initialization we need to reset it toggling GPIO. NVRAM contains info which GPIO should be toggled, e.g.:
gpio4=robo_reset
(robo means roboswitch)
Quoted 5 lines
bcm47xx_nvram_gpio_pinis needed by out-of-tree "b53" driver that some tried to push upstream, but was rejected because of API.I'll also send a patch to USB host driver soon that will require
bcm47xx_nvram_gpio_pin.
OK thanks for the context.
It sounds to me like this code is a combination of three pieces:
1. code that autoprobes the size of the "nvram" partition in the Broadcom platform flash, by reading various locations in the MMIO flash aperture, configured by some other system entity
2. code that shadow copies the device data from the MMIO flash aperture into system RAM
3. code that parses the CPE-generated device data and returns it to other drivers
Does that sound accurate?
- Paul
Rafał Miłecki
maintainerQuoted 8 lines · Paul Walmsley
Quoted 4 lines
I don't think NVRAM can be treated as a standard char device. Also, in my V1 I tried moving it to the
drivers/misc/, but thendrivers/soc/was suggested as a better place, see Arnd's reply:
http://www.linux-mips.org/archives/linux-mips/2014-11/msg00238.htmlYeah. It depends on who is going to merge the patch. If you can persuade someone else to merge it in
drivers/soc, then it doesn't really matter what I think.
I'm looking for the solution that will satisfy most ppl. I understand your arguments against drivers/soc/, but on the other hand I have no idea where else this driver could go.
Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Looking at
arch/mips/bcm47xx/nvram.c: if the low-level NVRAM probe code were moved elsewhere, the higher-level NVRAM "interpretation" functions still remain:bcm47xx_nvram_getenv()andbcm47xx_nvram_gpio_pin(). Those seem to be intended to parse device configuration data, yes? And this device configuration data is organized this way by platform software convention -- there's no hardware requirement to store data this way in the NVRAM, right?This
bcm47xx_nvramdriver has two ways of reading NVRAM content:
1) Using a standard MTD API to access "nvram" partition. In such case flash driver is a low-level thing if you call it so.
Quoted 8 lines
OK, so just to confirm, you are referring to these drivers:
drivers/mtd/nand/bcm47xxnflash/*drivers/mtd/devices/bcm47xxsflash.cdrivers/ssb/driver_mipscore.c(for pflash)drivers/bcma/driver_mips.c(for pflash)?
Yes, these are drivers for Broadcom flash memories that implement (more or less directly) MTD API. There is also a new SPI-NOR based driver I'm trying to upstream (it was already sent, needs accepting some more spi-nor changes first).
Quoted 4 lines
Just out of curiosity, the
nvram.ccode seems to contain some code to work around cases where the flash size is larger than the MMIO aperture, and to truncate the copy. Is there some way to program the flash controller to point the aperture at a different section of the flash?
Er, not really. We assume NVRAM content is not bigger than NVRAM_SPACE (0x8000), but that's all. If NVRAM can be read using MMIO, then it's always fully available.
There isn't any documented way of reprogramming flash content mapping into memory.
Quoted 7 lines
Quoted 2 lines
2) Using memory-mapped flash access window. In such case there isn't any extra low-level driver.
Could you point me at the software entity that configures the memory-mapped flash access window and programs the flash controller to use one of {p,n,s}flash? Or is that done by some code external to the kernel, like the bootloader?
It's done by the CFE (bootloader). You can find CFE source in some tarballs published by Asus in their GPL firmware packages. I never really focused on CFE source, never tried to compiling it or re-installing.
Quoted 6 lines
Quoted 5 lines
The "nvram" partition is required by the bootloader (CFE). It contains some important info like CPU clock, RAM configuration, switch ports layout. Then it's used by system drivers (like Ethernet driver bgmac) to get info about some particular hardware parts (like PHY address, MAC, etc.).
Quoted 10 lines
So it's not used by the on-chip boot-ROM? Sounds like it's just software convention, then? In other words, if one used a different bootloader, like u-boot, and passed a DT or something like that to the kernel, this wouldn't be needed. The presence and format of this flash is part of a specific hardware/software platform, external to the SoC hardware itself, that Broadcom suggests. It's analogous to ARM ATAGS -
arch/arm/kernel/atags_parse.c. Does all this match your understanding? (I'm not advocating using a different bootloader or device data format - I think it's important to preserve compatibility with CPE - I am just trying to understand how this area of flash is used.)
I guess yes, you could probably use different bootloader and hardcode all important settings into it (e.g. using DTB).
I guess DT is older than CFE, but Broadcom decided to invent own solution called NVRAM anyway. This is a bit messy, because it actually stores hardware details (CPU, RAM, switch) as well as user settings (e.g. LEDs behavior). I can't say why Broadcom decided to implement it this way.
We all would love to see Broadcom shipping devices with U-Boot and DT! ;)
Quoted 24 lines
Quoted 18 lines
Quoted 11 lines
So if the answer to the above two questions is "yes," meaning that this NVRAM is used to store device probing data by software convention, then it would seem to me that proposing some place like
drivers/devicedata/bcm47xx-nvramis a better bet (where "bcm47xx-nvram" is just some kind of opaque token). Looking at those two functions, it doesn't seem like there's really anything MIPS or Broadcom or NVRAM or even SoC-specific about key-value pair parsing and GPIO device data? Or am I missing something?Actually, considering that
bcm47xx_nvram_gpio_pin()isn't even used, can we just drop it and save the hassle? :-)We need this function to easily find GPIO responsible for "something". For example during switch initialization we need to reset it toggling GPIO. NVRAM contains info which GPIO should be toggled, e.g.:
gpio4=robo_reset
(robo means roboswitch)Quoted 5 lines
bcm47xx_nvram_gpio_pinis needed by out-of-tree "b53" driver that some tried to push upstream, but was rejected because of API.I'll also send a patch to USB host driver soon that will require
bcm47xx_nvram_gpio_pin.
Quoted 8 lines
OK thanks for the context.
It sounds to me like this code is a combination of three pieces:
1. code that autoprobes the size of the "nvram" partition in the Broadcom platform flash, by reading various locations in the MMIO flash aperture, configured by some other system entity
That's right, on MIPS we simply detect flash type (drivers/ssb & driver/bcma) and using that we init NVRAM passing memory offset where the flash is mapped.
Quoted 7 lines
2. code that shadow copies the device data from the MMIO flash aperture into system RAM
3. code that parses the CPE-generated device data and returns it to other drivers
Does that sound accurate?
Correct (s/CPE/CFE).
Signature · 1 line
Rafał
+ lkml
Hi Rafał,
Quoted 11 lines · Rafał Miłecki
Quoted 8 lines · Paul Walmsley
Quoted 4 lines
I don't think NVRAM can be treated as a standard char device. Also, in my V1 I tried moving it to the
drivers/misc/, but thendrivers/soc/was suggested as a better place, see Arnd's reply:
http://www.linux-mips.org/archives/linux-mips/2014-11/msg00238.htmlYeah. It depends on who is going to merge the patch. If you can persuade someone else to merge it in
drivers/soc, then it doesn't really matter what I think.I'm looking for the solution that will satisfy most ppl.
Wow, that's a pretty high bar ;-) Better IMHO to try for something that seems to make rational sense, then let others convert it into something that makes less sense afterwards, if necessary ;-)
Quoted 2 lines
I understand your arguments against
drivers/soc/, but on the other hand I have no idea where else this driver could go.
After looking around the tree to find out where similar code is located, it looks like drivers/firmware is the right place. These days, drivers/firmware is mainly used for drivers that parse EFI bootloader data, DMI data, that sort of thing. Quite similar to the CFE-provided data that the bcm47xx-nvram code deals with. So, by functional analogy, drivers/firmware appears to be the right place to stash this device data-probing code.
Quoted 5 lines
I guess DT is older than CFE, but Broadcom decided to invent own solution called NVRAM anyway. This is a bit messy, because it actually stores hardware details (CPU, RAM, switch) as well as user settings (e.g. LEDs behavior). I can't say why Broadcom decided to implement it this way.
Yep, based on what the other drivers in drivers/firmware are used for, I think drivers/firmware is the right place for the CFE parsing code.
Quoted 10 lines
Quoted 6 lines
It sounds to me like this code is a combination of three pieces:
1. code that autoprobes the size of the "nvram" partition in the Broadcom platform flash, by reading various locations in the MMIO flash aperture, configured by some other system entity
That's right, on MIPS we simply detect flash type (
drivers/ssb& driver/bcma) and using that we init NVRAM passing memory offset where the flash is mapped.
OK.
So (as a side issue), I would suggest that when you move this code out of arch/mips, the MIPS-isms in it should be removed, like KSEG1ADDR(), etc., and replaced by the standard ioremap()-type approach. After all, Broadcom could build CFE for ARM, and then we'd want to use this same code to parse the CFE-provided data.
Also I would suggest getting rid of the #ifdefs for the flash type, and probing it dynamically instead. The flash setup code under drivers/ssb/ and drivers/bcma/ sets up platform_devices for the flash, right? If so then it would be best if this code could run after the bus setup code, query the Linux device model for the type of platform flash in use, and then extract the appropriate address space to probe from that data.
Quoted 9 lines
Quoted 7 lines
2. code that shadow copies the device data from the MMIO flash aperture into system RAM
3. code that parses the CPE-generated device data and returns it to other drivers
Does that sound accurate?
Correct (s/CPE/CFE).
Thanks for the correction, I must have been dreaming of telecom equipment..
What do you think? Does this sound reasonable?
- Paul
Rafał Miłecki
maintainerQuoted 12 lines · Paul Walmsley
Quoted 2 lines · Rafał Miłecki
I understand your arguments against
drivers/soc/, but on the other hand I have no idea where else this driver could go.After looking around the tree to find out where similar code is located, it looks like
drivers/firmwareis the right place. These days,drivers/firmwareis mainly used for drivers that parse EFI bootloader data, DMI data, that sort of thing. Quite similar to the CFE-provided data that the bcm47xx-nvram code deals with. So, by functional analogy,drivers/firmwareappears to be the right place to stash this device data-probing code.
Quoted 8 lines
Quoted 5 lines
I guess DT is older than CFE, but Broadcom decided to invent own solution called NVRAM anyway. This is a bit messy, because it actually stores hardware details (CPU, RAM, switch) as well as user settings (e.g. LEDs behavior). I can't say why Broadcom decided to implement it this way.
Yep, based on what the other drivers in
drivers/firmwareare used for, I thinkdrivers/firmwareis the right place for the CFE parsing code.
The problem is I can't find MAINTAINER of the drivers/firmware/. Is there someone responsible for that? Some mailing list maybe? Who could give us an ACK to move bcm47xx_nvram there?
Quoted 19 lines
Quoted 10 lines
Quoted 6 lines
It sounds to me like this code is a combination of three pieces:
1. code that autoprobes the size of the "nvram" partition in the Broadcom platform flash, by reading various locations in the MMIO flash aperture, configured by some other system entity
That's right, on MIPS we simply detect flash type (
drivers/ssb& driver/bcma) and using that we init NVRAM passing memory offset where the flash is mapped.OK.
So (as a side issue), I would suggest that when you move this code out of
arch/mips, the MIPS-isms in it should be removed, likeKSEG1ADDR(), etc., and replaced by the standard ioremap()-type approach. After all, Broadcom could build CFE for ARM, and then we'd want to use this same code to parse the CFE-provided data.
Quoted 6 lines
Also I would suggest getting rid of the #ifdefs for the flash type, and probing it dynamically instead. The flash setup code under
drivers/ssb/anddrivers/bcma/sets upplatform_devicesfor the flash, right? If so then it would be best if this code could run after the bus setup code, query the Linux device model for the type of platform flash in use, and then extract the appropriate address space to probe from that data.
I'm pretty sure you look at some old version of arch/bcm47xx/nvram.c. I wouldn't dare to move such a MIPS-focused driver to some common place ;)
Please check for the version of nvram.c in Ralf's upstream-sfr tree. I think you'll like it much more. Hopefully you will even consider it ready for moving to the drivers/firmware/ or whatever :)
Signature · 1 line
Rafał
Hi Rafał,
Quoted 19 lines · Rafał Miłecki
Quoted 18 lines · Paul Walmsley
Quoted 2 lines · Rafał Miłecki
I understand your arguments against
drivers/soc/, but on the other hand I have no idea where else this driver could go.After looking around the tree to find out where similar code is located, it looks like
drivers/firmwareis the right place. These days,drivers/firmwareis mainly used for drivers that parse EFI bootloader data, DMI data, that sort of thing. Quite similar to the CFE-provided data that the bcm47xx-nvram code deals with. So, by functional analogy,drivers/firmwareappears to be the right place to stash this device data-probing code.Quoted 5 lines
I guess DT is older than CFE, but Broadcom decided to invent own solution called NVRAM anyway. This is a bit messy, because it actually stores hardware details (CPU, RAM, switch) as well as user settings (e.g. LEDs behavior). I can't say why Broadcom decided to implement it this way.
Quoted 6 lines
Quoted 2 lines
Yep, based on what the other drivers in
drivers/firmwareare used for, I thinkdrivers/firmwareis the right place for the CFE parsing code.The problem is I can't find MAINTAINER of the
drivers/firmware/. Is there someone responsible for that? Some mailing list maybe? Who could give us an ACK to movebcm47xx_nvramthere?
The list of folks who have committed patches that touch drivers/firmware is large. I did this as a first-order approximation:
$ git log --format=fuller drivers/firmware/* | grep Commit: | sort -u Commit: Adrian Bunk <[email protected]> Commit: Adrian Bunk <[email protected]> Commit: Al Viro <[email protected]> Commit: Andi Kleen <[email protected]> Commit: Benjamin Herrenschmidt <[email protected]> Commit: David S. Miller <[email protected]> Commit: David Woodhouse <[email protected]> Commit: Dmitry Torokhov <[email protected]> Commit: Greg Kroah-Hartman <[email protected]> Commit: Greg Kroah-Hartman <[email protected]> Commit: H. Peter Anvin <[email protected]> Commit: H. Peter Anvin <[email protected]> Commit: Ingo Molnar <[email protected]> Commit: Ingo Molnar <[email protected]> Commit: James Bottomley <[email protected]> Commit: James Bottomley <[email protected]> Commit: Jean Delvare <[email protected]> Commit: Jeff Garzik <[email protected]> Commit: Jeff Garzik <[email protected]> Commit: Jesse Barnes <[email protected]> Commit: Jiri Kosina <[email protected]> Commit: Konrad Rzeszutek Wilk <[email protected]> Commit: Konrad Rzeszutek Wilk <[email protected]> Commit: Len Brown <[email protected]> Commit: Linus Torvalds <[email protected]> Commit: Linus Torvalds <[email protected]> Commit: Linus Torvalds <[email protected]> Commit: Linus Torvalds <[email protected]> Commit: Linus Torvalds <[email protected]> Commit: Mark Brown <[email protected]> Commit: Mark M. Hoffman <[email protected]> Commit: Matt Fleming <[email protected]> Commit: Matthew Wilcox <[email protected]> Commit: Paul Gortmaker <[email protected]> Commit: Rafael J. Wysocki <[email protected]> Commit: Russell King <[email protected]> Commit: Tejun Heo <[email protected]> Commit: Theodore Ts'o <[email protected]> Commit: Thomas Gleixner <[email protected]> Commit: Tony Luck <[email protected]>
If I were in your shoes, I would suggest either
1. asking Ralf to merge your patches that touch drivers/firmware, since he'll also presumably be merging the parts that touch arch/mips
or
2. asking Greg KH to merge those patches
And of course it would not hurt to collect some Reviewed-By:s from other folks. (See below...)
Quoted 26 lines
Quoted 19 lines
Quoted 10 lines
Quoted 6 lines
It sounds to me like this code is a combination of three pieces:
1. code that autoprobes the size of the "nvram" partition in the Broadcom platform flash, by reading various locations in the MMIO flash aperture, configured by some other system entity
That's right, on MIPS we simply detect flash type (
drivers/ssb& driver/bcma) and using that we init NVRAM passing memory offset where the flash is mapped.OK.
So (as a side issue), I would suggest that when you move this code out of
arch/mips, the MIPS-isms in it should be removed, likeKSEG1ADDR(), etc., and replaced by the standard ioremap()-type approach. After all, Broadcom could build CFE for ARM, and then we'd want to use this same code to parse the CFE-provided data.Quoted 6 lines
Also I would suggest getting rid of the #ifdefs for the flash type, and probing it dynamically instead. The flash setup code under
drivers/ssb/anddrivers/bcma/sets upplatform_devicesfor the flash, right? If so then it would be best if this code could run after the bus setup code, query the Linux device model for the type of platform flash in use, and then extract the appropriate address space to probe from that data.
Quoted 7 lines
I'm pretty sure you look at some old version of
arch/bcm47xx/nvram.c. I wouldn't dare to move such a MIPS-focused driver to some common place ;)Please check for the version of
nvram.cin Ralf's upstream-sfr tree. I think you'll like it much more. Hopefully you will even consider it ready for moving to thedrivers/firmware/or whatever :)
OK I will take a look at this, and will either send comments, or will send a Reviewed-By:.
Thanks for all of the good discussion on this :-)
- Paul
Quoted 11 lines · Paul Walmsley
If I were in your shoes, I would suggest either
1. asking Ralf to merge your patches that touch
drivers/firmware, since he'll also presumably be merging the parts that toucharch/mipsor
2. asking Greg KH to merge those patches
And of course it would not hurt to collect some Reviewed-By:s from other folks. (See below...)
I surely can carry this patch.
Ralf
Hello Rafał,
Quoted 6 lines · Paul Walmsley
Quoted 4 lines · Rafał Miłecki
I'm pretty sure you look at some old version of
arch/bcm47xx/nvram.c. I wouldn't dare to move such a MIPS-focused driver to some common place ;)
Quoted 6 lines
Quoted 3 lines
Please check for the version of
nvram.cin Ralf's upstream-sfr tree. I think you'll like it much more. Hopefully you will even consider it ready for moving to thedrivers/firmware/or whatever :)OK I will take a look at this, and will either send comments, or will send a Reviewed-By:.
I had the chance to take a brief look at this file, and you are right: I like your newer version better than the older one :-)
It is too bad that it seems this flash area has to be accessed very early in boot. That certainly makes it more difficult to write something particularly elegant. It is also a pity that it is unknown how to verify that the flash MMIO window has been configured before reading from these areas of the address space. But under the circumstances, calling bcm47xx_nvram_init_from_mem() with the appropriate addresses from the bus code during early init, as you did, seems rather reasonable. I also like the code that you added to read the flash data from MTD later in boot.
Here are a few very minor comments that you are welcome to take or leave as you wish.
1. In nvram_find_and_copy(), the flash header copy loop uses:
for (i = 0; i < sizeof(struct nvram_header); i += 4) *dst++ = *src++;
Consider using either __raw_readl() to read from the MMIO window, or possibly memcpy_fromio(). In theory, all MMIO accesses should use functions like these.
2. In nvram_find_and_copy(), the flash payload copy loop uses:
for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4) *dst++ = le32_to_cpu(*src++);
Consider using readl() instead of the direct MMIO read & endianness conversion.
3. In nvram_find_and_copy(), I don't believe that this is necessary:
memset(dst, 0x0, NVRAM_SPACE - i);
since nvram_buf[] is a file-static variable, and thus should have been initialized to all zeroes.
4. As with #3 above, in nvram_init(), I don't believe that this is necessary:
memset(dst + bytes_read, 0x0, NVRAM_SPACE - bytes_read);
5. In bcm47xx_nvram_getenv(), this multiple assignment exists:
end[0] = end[1] = '\0';
Best to avoid multiple assignments, per Chapter 1 of Documentation/CodingStyle. You might consider running checkpatch.pl on the file:
$ scripts/checkpatch.pl -f --strict arch/mips/bcm47xx/nvram.c CHECK: No space is necessary after a cast #101: FILE: arch/mips/bcm47xx/nvram.c:101: + src = (u32 *) header;
CHECK: No space is necessary after a cast
#102: FILE: arch/mips/bcm47xx/nvram.c:102:
+ dst = (u32 *) nvram_buf;
CHECK: multiple assignments should be avoided
#195: FILE: arch/mips/bcm47xx/nvram.c:195:
+ end[0] = end[1] = '\0';
CHECK: Alignment should match open parenthesis
#202: FILE: arch/mips/bcm47xx/nvram.c:202:
+ if ((eq - var) == strlen(name) &&
+ strncmp(var, name, (eq - var)) == 0) {
6. bcm47xx_nvram_getenv() calls strchr(). Perhaps it would be better to use strnchr(), in case the flash data is corrupted or in an invalid format?
7. There are a few magic numbers in this code, mostly in bcm47xx_nvram_gpio_pin(). It might be worth converting those to macros and documenting the expectations there in a comment above the macro.
8. The way that bcm47xx_nvram_gpio_pin() calls bcm47xx_nvram_getenv() seems a bit inefficient. It might be better to loop over all of the keys in the shadowed flash, looking for values that match "name". Then if the key name matches "gpio" plus one or two digits, the code could just return the digits. That way, only one pass is needed, rather than 32 (in the worst case). Well, at least the reads should be coming from cached DRAM, rather than flash...
If you fix/address those (or correct my review ;-) ), then you're welcome to add my Reviewed-by: to a patch that moves this file out to drivers/firmware.
regards,
- Paul
Rafał Miłecki
maintainerQuoted 29 lines · Paul Walmsley
Hello Rafał,
Quoted 6 lines · Paul Walmsley
Quoted 4 lines · Rafał Miłecki
I'm pretty sure you look at some old version of
arch/bcm47xx/nvram.c. I wouldn't dare to move such a MIPS-focused driver to some common place ;)Quoted 6 lines
Quoted 3 lines
Please check for the version of
nvram.cin Ralf's upstream-sfr tree. I think you'll like it much more. Hopefully you will even consider it ready for moving to thedrivers/firmware/or whatever :)OK I will take a look at this, and will either send comments, or will send a Reviewed-By:.
I had the chance to take a brief look at this file, and you are right: I like your newer version better than the older one :-)
It is too bad that it seems this flash area has to be accessed very early in boot. That certainly makes it more difficult to write something particularly elegant. It is also a pity that it is unknown how to verify that the flash MMIO window has been configured before reading from these areas of the address space. But under the circumstances, calling
bcm47xx_nvram_init_from_mem()with the appropriate addresses from the bus code during early init, as you did, seems rather reasonable. I also like the code that you added to read the flash data from MTD later in boot.
Quoted 2 lines
Here are a few very minor comments that you are welcome to take or leave as you wish.
Thanks for your comments! I'll address them before (trying) moving driver to the drivers/firmware/. Appreciate your review.