bcm53xx: use bcma callback in SPROM driver to fill the SPROM
[15.05/openwrt.git] / target / linux / bcm53xx / patches-3.14 / 111-bcm47xx-nvram-add-new-nvram-driver-with-dt-support.patch
1 From 71a6bff8656a1713615ffdd9139a83d65ba46c6d Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sat, 3 May 2014 22:54:59 +0200
4 Subject: [PATCH 02/17] bcm47xx-nvram: add new broadcom nvram driver with dt
5  support
6
7 This adds a new driver which searches at a given memory range for a
8 nvram like it is used on the bcm47xx and bcm53xx SoCs with ARM and MIPS
9 CPUs. This driver provides acces to this nvram to other device in the
10 device tree. You have to specify the memory ranges where the content of
11 the flash chip is memory mapped and this driver will search there for
12 some nvram and parse it. Other drivers can use this driver to access the
13 device nvram. The nvram is used to store board configurations like the
14 mac addresses, the switch configuration and the calibration data for
15 the wifi devices.
16
17 This was copied from arch/mips/bcm47xx/nvram.c and modified to interact
18 with device tree. My plan is to make the MIPS bcm47xx also use this new
19 driver some time later.
20
21 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
22 ---
23  .../devicetree/bindings/misc/bcm47xx-nvram.txt     |  19 ++
24  arch/mips/bcm47xx/board.c                          |  40 ++--
25  arch/mips/bcm47xx/nvram.c                          |   7 +-
26  arch/mips/bcm47xx/setup.c                          |   4 +-
27  arch/mips/bcm47xx/sprom.c                          |   4 +-
28  arch/mips/bcm47xx/time.c                           |   2 +-
29  drivers/misc/Kconfig                               |   5 +
30  drivers/misc/Makefile                              |   1 +
31  drivers/misc/bcm47xx-nvram.c                       | 215 +++++++++++++++++++++
32  drivers/net/ethernet/broadcom/b44.c                |   2 +-
33  drivers/net/ethernet/broadcom/bgmac.c              |   5 +-
34  drivers/ssb/driver_chipcommon_pmu.c                |   3 +-
35  include/linux/bcm47xx_nvram.h                      |  17 +-
36  13 files changed, 286 insertions(+), 38 deletions(-)
37  create mode 100644 Documentation/devicetree/bindings/misc/bcm47xx-nvram.txt
38  create mode 100644 drivers/misc/bcm47xx-nvram.c
39
40 --- /dev/null
41 +++ b/Documentation/devicetree/bindings/misc/bcm47xx-nvram.txt
42 @@ -0,0 +1,19 @@
43 +Broadcom bcm47xx/bcm53xx nvram access driver
44 +
45 +This driver provides access to the nvram for other drivers.
46 +
47 +Required properties:
48 +
49 +- compatible : brcm,bcm47xx-nvram
50 +
51 +- reg : iomem address range
52 +
53 +On NorthStar ARM SoCs the NAND flash is available at 0x1c000000 and the
54 +NOR flash is at 0x1e000000
55 +
56 +Example:
57 +
58 +nvram0: nvram@0 {
59 +       compatible = "brcm,bcm47xx-nvram";
60 +       reg = <0x1c000000 0x01000000>;
61 +};
62 --- a/drivers/misc/Kconfig
63 +++ b/drivers/misc/Kconfig
64 @@ -515,6 +515,11 @@ config SRAM
65           the genalloc API. It is supposed to be used for small on-chip SRAM
66           areas found on many SoCs.
67  
68 +config BCM47XX_NVRAM
69 +       tristate "BCM47XX nvram driver"
70 +       help
71 +               This adds support for the brcm47xx nvram driver.
72 +
73  source "drivers/misc/c2port/Kconfig"
74  source "drivers/misc/eeprom/Kconfig"
75  source "drivers/misc/cb710/Kconfig"
76 --- a/drivers/misc/Makefile
77 +++ b/drivers/misc/Makefile
78 @@ -54,3 +54,4 @@ obj-$(CONFIG_LATTICE_ECP3_CONFIG)     += lat
79  obj-$(CONFIG_SRAM)             += sram.o
80  obj-y                          += mic/
81  obj-$(CONFIG_GENWQE)           += genwqe/
82 +obj-$(CONFIG_BCM47XX_NVRAM)    += bcm47xx-nvram.o
83 --- a/include/linux/bcm47xx_nvram.h
84 +++ b/include/linux/bcm47xx_nvram.h
85 @@ -15,7 +15,7 @@
86  #include <linux/types.h>
87  #include <linux/kernel.h>
88  
89 -#ifdef CONFIG_BCM47XX
90 +#if defined(CONFIG_BCM47XX) || defined(CONFIG_BCM47XX_NVRAM)
91  int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
92  
93  int bcm47xx_nvram_gpio_pin(const char *name);
94 --- a/drivers/misc/bcm47xx-nvram.c
95 +++ b/drivers/misc/bcm47xx-nvram.c
96 @@ -28,7 +28,7 @@
97  
98  struct nvram_header {
99         u32 magic;
100 -       u32 len;
101 +       __le32 len;
102         u32 crc_ver_init;       /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
103         u32 config_refresh;     /* 0:15 sdram_config, 16:31 sdram_refresh */
104         u32 config_ncdl;        /* ncdl values for memc */