bcm53xx: backport NVRAM driver sent upstream
Signed-off-by: Rafał Miłecki <zajec5@gmail.com> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@43612 3c298f89-4303-0410-b956-a3cf2f4a3e73master
parent
884483dbd5
commit
935b8f6e25
|
@ -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.
|
|
@ -0,0 +1 @@
|
|||
obj-$(CONFIG_BCM47XX_NVRAM) += bcm47xx_nvram.o
|
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* BCM947xx nvram variable access
|
||||
*
|
||||
* Copyright (C) 2005 Broadcom Corporation
|
||||
* Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
|
||||
* Copyright (C) 2010-2012 Hauke Mehrtens <hauke@hauke-m.de>
|
||||
*
|
||||
* 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
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/bcm47xx_nvram.h>
|
||||
|
||||
#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
|
||||
#define NVRAM_SPACE 0x8000
|
||||
#define NVRAM_MAX_GPIO_ENTRIES 32
|
||||
#define NVRAM_MAX_GPIO_VALUE_LEN 30
|
||||
|
||||
#define FLASH_MIN 0x00020000 /* Minimum flash size */
|
||||
|
||||
struct nvram_header {
|
||||
u32 magic;
|
||||
u32 len;
|
||||
u32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
|
||||
u32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
|
||||
u32 config_ncdl; /* ncdl values for memc */
|
||||
};
|
||||
|
||||
static char nvram_buf[NVRAM_SPACE];
|
||||
static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
|
||||
|
||||
static u32 find_nvram_size(void __iomem *end)
|
||||
{
|
||||
struct nvram_header __iomem *header;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
|
||||
header = (struct nvram_header *)(end - nvram_sizes[i]);
|
||||
if (header->magic == NVRAM_MAGIC)
|
||||
return nvram_sizes[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Probe for NVRAM header */
|
||||
static int nvram_find_and_copy(void __iomem *iobase, u32 lim)
|
||||
{
|
||||
struct nvram_header __iomem *header;
|
||||
int i;
|
||||
u32 off;
|
||||
u32 *src, *dst;
|
||||
u32 size;
|
||||
|
||||
if (nvram_buf[0]) {
|
||||
pr_warn("nvram already initialized\n");
|
||||
return -EEXIST;
|
||||
}
|
||||
|
||||
/* TODO: when nvram is on nand flash check for bad blocks first. */
|
||||
off = FLASH_MIN;
|
||||
while (off <= lim) {
|
||||
/* Windowed flash access */
|
||||
size = find_nvram_size(iobase + off);
|
||||
if (size) {
|
||||
header = (struct nvram_header *)(iobase + off - size);
|
||||
goto found;
|
||||
}
|
||||
off <<= 1;
|
||||
}
|
||||
|
||||
/* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
|
||||
header = (struct nvram_header *)(iobase + 4096);
|
||||
if (header->magic == NVRAM_MAGIC) {
|
||||
size = NVRAM_SPACE;
|
||||
goto found;
|
||||
}
|
||||
|
||||
header = (struct nvram_header *)(iobase + 1024);
|
||||
if (header->magic == NVRAM_MAGIC) {
|
||||
size = NVRAM_SPACE;
|
||||
goto found;
|
||||
}
|
||||
|
||||
pr_err("no nvram found\n");
|
||||
return -ENXIO;
|
||||
|
||||
found:
|
||||
if (header->len > size)
|
||||
pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
|
||||
if (header->len > NVRAM_SPACE)
|
||||
pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
|
||||
header->len, NVRAM_SPACE);
|
||||
|
||||
src = (u32 *)header;
|
||||
dst = (u32 *)nvram_buf;
|
||||
for (i = 0; i < sizeof(struct nvram_header); i += 4)
|
||||
*dst++ = __raw_readl(src++);
|
||||
for (; i < header->len && i < NVRAM_SPACE && i < size; i += 4)
|
||||
*dst++ = readl(src++);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* On bcm47xx we need access to the NVRAM very early, so we can't use mtd
|
||||
* subsystem to access flash. We can't even use platform device / driver to
|
||||
* store memory offset.
|
||||
* To handle this we provide following symbol. It's supposed to be called as
|
||||
* soon as we get info about flash device, before any NVRAM entry is needed.
|
||||
*/
|
||||
int bcm47xx_nvram_init_from_mem(u32 base, u32 lim)
|
||||
{
|
||||
void __iomem *iobase;
|
||||
int err;
|
||||
|
||||
iobase = ioremap_nocache(base, lim);
|
||||
if (!iobase)
|
||||
return -ENOMEM;
|
||||
|
||||
err = nvram_find_and_copy(iobase, lim);
|
||||
|
||||
iounmap(iobase);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int nvram_init(void)
|
||||
{
|
||||
#ifdef CONFIG_MTD
|
||||
struct mtd_info *mtd;
|
||||
struct nvram_header header;
|
||||
size_t bytes_read;
|
||||
int err, i;
|
||||
|
||||
mtd = get_mtd_device_nm("nvram");
|
||||
if (IS_ERR(mtd))
|
||||
return -ENODEV;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
|
||||
loff_t from = mtd->size - nvram_sizes[i];
|
||||
|
||||
if (from < 0)
|
||||
continue;
|
||||
|
||||
err = mtd_read(mtd, from, sizeof(header), &bytes_read,
|
||||
(uint8_t *)&header);
|
||||
if (!err && header.magic == NVRAM_MAGIC) {
|
||||
u8 *dst = (uint8_t *)nvram_buf;
|
||||
size_t len = header.len;
|
||||
|
||||
if (header.len > NVRAM_SPACE) {
|
||||
pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n",
|
||||
header.len, NVRAM_SPACE);
|
||||
len = NVRAM_SPACE;
|
||||
}
|
||||
|
||||
err = mtd_read(mtd, from, len, &bytes_read, dst);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
|
||||
{
|
||||
char *var, *value, *end, *eq;
|
||||
int data_left, err;
|
||||
|
||||
if (!name)
|
||||
return -EINVAL;
|
||||
|
||||
if (!nvram_buf[0]) {
|
||||
err = nvram_init();
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Look for name=value and return value */
|
||||
var = &nvram_buf[sizeof(struct nvram_header)];
|
||||
end = nvram_buf + sizeof(nvram_buf) - 2;
|
||||
end[0] = '\0';
|
||||
end[1] = '\0';
|
||||
for (; *var; var = value + strlen(value) + 1) {
|
||||
data_left = end - var;
|
||||
|
||||
eq = strnchr(var, data_left, '=');
|
||||
if (!eq)
|
||||
break;
|
||||
value = eq + 1;
|
||||
if (eq - var == strlen(name) &&
|
||||
strncmp(var, name, eq - var) == 0)
|
||||
return snprintf(val, val_len, "%s", value);
|
||||
}
|
||||
return -ENOENT;
|
||||
}
|
||||
EXPORT_SYMBOL(bcm47xx_nvram_getenv);
|
||||
|
||||
int bcm47xx_nvram_gpio_pin(const char *name)
|
||||
{
|
||||
int i, err;
|
||||
char nvram_var[] = "gpioXX";
|
||||
char buf[NVRAM_MAX_GPIO_VALUE_LEN];
|
||||
|
||||
/* TODO: Optimize it to don't call getenv so many times */
|
||||
for (i = 0; i < NVRAM_MAX_GPIO_ENTRIES; i++) {
|
||||
err = snprintf(nvram_var, sizeof(nvram_var), "gpio%i", i);
|
||||
if (err <= 0)
|
||||
continue;
|
||||
err = bcm47xx_nvram_getenv(nvram_var, buf, sizeof(buf));
|
||||
if (err <= 0)
|
||||
continue;
|
||||
if (!strcmp(name, buf))
|
||||
return i;
|
||||
}
|
||||
return -ENOENT;
|
||||
}
|
||||
EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
|
||||
|
||||
MODULE_LICENSE("GPLv2");
|
|
@ -1,217 +0,0 @@
|
|||
/*
|
||||
* BCM947xx nvram variable access
|
||||
*
|
||||
* Copyright (C) 2005 Broadcom Corporation
|
||||
* Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
|
||||
* Copyright (C) 2010-2014 Hauke Mehrtens <hauke@hauke-m.de>
|
||||
*
|
||||
* 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
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/bcm47xx_nvram.h>
|
||||
|
||||
#define NVRAM_HEADER 0x48534C46 /* 'FLSH' */
|
||||
#define NVRAM_SPACE 0x8000
|
||||
|
||||
#define FLASH_MIN 0x00020000 /* Minimum flash size */
|
||||
|
||||
struct nvram_header {
|
||||
u32 magic;
|
||||
u32 len;
|
||||
u32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
|
||||
u32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
|
||||
u32 config_ncdl; /* ncdl values for memc */
|
||||
};
|
||||
|
||||
struct bcm47xx_nvram {
|
||||
size_t nvram_len;
|
||||
char *nvram_buf;
|
||||
};
|
||||
|
||||
static struct bcm47xx_nvram *nvram = NULL;
|
||||
|
||||
static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
|
||||
|
||||
static u32 find_nvram_size(void __iomem *end)
|
||||
{
|
||||
struct nvram_header __iomem *header;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(nvram_sizes); i++) {
|
||||
header = (struct nvram_header __iomem *)(end - nvram_sizes[i]);
|
||||
if (__raw_readl(&header->magic) == NVRAM_HEADER)
|
||||
return nvram_sizes[i];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Probe for NVRAM header */
|
||||
static int nvram_find_and_copy(struct device *dev, void __iomem *base,
|
||||
size_t len, char **nvram_buf,
|
||||
size_t *nvram_len)
|
||||
{
|
||||
struct nvram_header __iomem *header;
|
||||
int i;
|
||||
u32 off;
|
||||
u32 *dst;
|
||||
__le32 __iomem *src;
|
||||
u32 size;
|
||||
|
||||
/* TODO: when nvram is on nand flash check for bad blocks first. */
|
||||
off = FLASH_MIN;
|
||||
while (off <= len) {
|
||||
/* Windowed flash access */
|
||||
size = find_nvram_size(base + off);
|
||||
if (size) {
|
||||
header = (struct nvram_header __iomem *)
|
||||
(base + off - size);
|
||||
goto found;
|
||||
}
|
||||
off += 0x10000;
|
||||
}
|
||||
|
||||
/* Try embedded NVRAM at 4 KB and 1 KB as last resorts */
|
||||
header = (struct nvram_header __iomem *)(base + 4096);
|
||||
if (__raw_readl(&header->magic) == NVRAM_HEADER) {
|
||||
size = NVRAM_SPACE;
|
||||
goto found;
|
||||
}
|
||||
|
||||
header = (struct nvram_header __iomem *)(base + 1024);
|
||||
if (__raw_readl(&header->magic) == NVRAM_HEADER) {
|
||||
size = NVRAM_SPACE;
|
||||
goto found;
|
||||
}
|
||||
|
||||
*nvram_buf = NULL;
|
||||
*nvram_len = 0;
|
||||
pr_err("no nvram found\n");
|
||||
return -ENXIO;
|
||||
|
||||
found:
|
||||
if (readl(&header->len) > size)
|
||||
pr_err("The nvram size accoridng to the header seems to be bigger than the partition on flash\n");
|
||||
*nvram_len = min_t(u32, readl(&header->len), size);
|
||||
|
||||
*nvram_buf = devm_kzalloc(dev, *nvram_len, GFP_KERNEL);
|
||||
if (!*nvram_buf)
|
||||
return -ENOMEM;
|
||||
|
||||
src = (__le32 __iomem *) header;
|
||||
dst = (u32 *) *nvram_buf;
|
||||
for (i = 0; i < sizeof(struct nvram_header); i += 4)
|
||||
*dst++ = __raw_readl(src++);
|
||||
for (; i < *nvram_len; i += 4)
|
||||
*dst++ = readl(src++);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len)
|
||||
{
|
||||
char *var, *value, *end, *eq;
|
||||
|
||||
if (!name || !nvram || !nvram->nvram_len)
|
||||
return -EINVAL;
|
||||
|
||||
/* Look for name=value and return value */
|
||||
var = nvram->nvram_buf + sizeof(struct nvram_header);
|
||||
end = nvram->nvram_buf + nvram->nvram_len - 2;
|
||||
end[0] = end[1] = '\0';
|
||||
for (; *var; var = value + strlen(value) + 1) {
|
||||
eq = strchr(var, '=');
|
||||
if (!eq)
|
||||
break;
|
||||
value = eq + 1;
|
||||
if ((eq - var) == strlen(name) &&
|
||||
strncmp(var, name, (eq - var)) == 0) {
|
||||
return snprintf(val, val_len, "%s", value);
|
||||
}
|
||||
}
|
||||
return -ENOENT;
|
||||
}
|
||||
EXPORT_SYMBOL(bcm47xx_nvram_getenv);
|
||||
|
||||
int bcm47xx_nvram_gpio_pin(const char *name)
|
||||
{
|
||||
int i, err;
|
||||
char nvram_var[10];
|
||||
char buf[30];
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
err = snprintf(nvram_var, sizeof(nvram_var), "gpio%i", i);
|
||||
if (err <= 0)
|
||||
continue;
|
||||
err = bcm47xx_nvram_getenv(nvram_var, buf, sizeof(buf));
|
||||
if (err <= 0)
|
||||
continue;
|
||||
if (!strcmp(name, buf))
|
||||
return i;
|
||||
}
|
||||
return -ENOENT;
|
||||
}
|
||||
EXPORT_SYMBOL(bcm47xx_nvram_gpio_pin);
|
||||
|
||||
static int bcm47xx_nvram_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct device_node *np = dev->of_node;
|
||||
int err;
|
||||
struct resource flash_mem;
|
||||
void __iomem *mmio;
|
||||
|
||||
/* Alloc */
|
||||
nvram = devm_kzalloc(dev, sizeof(*nvram), GFP_KERNEL);
|
||||
if (!nvram)
|
||||
return -ENOMEM;
|
||||
|
||||
err = of_address_to_resource(np, 0, &flash_mem);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
mmio = ioremap_nocache(flash_mem.start, resource_size(&flash_mem));
|
||||
if (!mmio)
|
||||
return -ENOMEM;
|
||||
|
||||
err = nvram_find_and_copy(dev, mmio, resource_size(&flash_mem),
|
||||
&nvram->nvram_buf, &nvram->nvram_len);
|
||||
if (err)
|
||||
goto err_unmap_mmio;
|
||||
|
||||
err_unmap_mmio:
|
||||
iounmap(mmio);
|
||||
return err;
|
||||
}
|
||||
|
||||
static const struct of_device_id bcm47xx_nvram_of_match_table[] = {
|
||||
{ .compatible = "brcm,bcm47xx-nvram", },
|
||||
{},
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, mvebu_pcie_of_match_table);
|
||||
|
||||
static struct platform_driver bcm47xx_nvram_driver = {
|
||||
.driver = {
|
||||
.owner = THIS_MODULE,
|
||||
.name = "bcm47xx-nvram",
|
||||
.of_match_table = bcm47xx_nvram_of_match_table,
|
||||
/* driver unloading/unbinding currently not supported */
|
||||
.suppress_bind_attrs = true,
|
||||
},
|
||||
.probe = bcm47xx_nvram_probe,
|
||||
};
|
||||
module_platform_driver(bcm47xx_nvram_driver);
|
||||
|
||||
MODULE_AUTHOR("Hauke Mehrtens <hauke@hauke-m.de>");
|
||||
MODULE_LICENSE("GPLv2");
|
|
@ -1,8 +1,4 @@
|
|||
/*
|
||||
* Copyright (C) 2005, Broadcom Corporation
|
||||
* Copyright (C) 2006, Felix Fietkau <nbd@openwrt.org>
|
||||
* Copyright (C) 2014 Hauke Mehrtens <hauke@hauke-m.de>
|
||||
*
|
||||
* 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
|
||||
|
@ -15,20 +11,24 @@
|
|||
#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);
|
||||
#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 -ENXIO;
|
||||
}
|
||||
|
||||
return -ENOTSUPP;
|
||||
};
|
||||
static inline int bcm47xx_nvram_gpio_pin(const char *name)
|
||||
{
|
||||
return -ENXIO;
|
||||
}
|
||||
return -ENOTSUPP;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* __BCM47XX_NVRAM_H */
|
||||
|
|
|
@ -1,154 +0,0 @@
|
|||
From 7063a1583166abe1a9cefed38c2f53a0e14a0005 Mon Sep 17 00:00:00 2001
|
||||
From: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
Date: Sun, 4 May 2014 16:35:42 +0200
|
||||
Subject: [PATCH 01/17] MIPS: BCM47XX: move the nvram header file into common
|
||||
space
|
||||
|
||||
Moving mach-bcm47xx/bcm47xx_nvram.h to include/linux/bcm47xx_nvram.h
|
||||
makes it possible to reuse this header on the ARM based bcm47xx/bcm53xx
|
||||
SoCs (e.g. BCM5301X devices). Broadcom uses ARM CPUs in their new SoC
|
||||
form the bcm47xx and bcm53xx line, but many other things like nvram
|
||||
stayed the same.
|
||||
|
||||
This is a preparation for adding a new nvram driver, which can be used
|
||||
by the ARM SoC and the MIPS SoC code. The device drivers accessing
|
||||
nvram do not have to care about ARM or MIPS SoC version.
|
||||
|
||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
---
|
||||
arch/mips/bcm47xx/board.c | 2 +-
|
||||
arch/mips/bcm47xx/nvram.c | 2 +-
|
||||
arch/mips/bcm47xx/setup.c | 2 +-
|
||||
arch/mips/bcm47xx/sprom.c | 2 +-
|
||||
arch/mips/bcm47xx/time.c | 2 +-
|
||||
arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h | 53 -----------------
|
||||
drivers/net/ethernet/broadcom/b44.c | 8 +--
|
||||
drivers/net/ethernet/broadcom/bgmac.c | 2 +-
|
||||
drivers/ssb/driver_chipcommon_pmu.c | 6 +-
|
||||
include/linux/bcm47xx_nvram.h | 66 ++++++++++++++++++++++
|
||||
10 files changed, 74 insertions(+), 71 deletions(-)
|
||||
delete mode 100644 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
|
||||
create mode 100644 include/linux/bcm47xx_nvram.h
|
||||
|
||||
--- a/arch/mips/bcm47xx/board.c
|
||||
+++ b/arch/mips/bcm47xx/board.c
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <linux/export.h>
|
||||
#include <linux/string.h>
|
||||
#include <bcm47xx_board.h>
|
||||
-#include <bcm47xx_nvram.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
|
||||
struct bcm47xx_board_type {
|
||||
const enum bcm47xx_board board;
|
||||
--- a/arch/mips/bcm47xx/nvram.c
|
||||
+++ b/arch/mips/bcm47xx/nvram.c
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
#include <asm/addrspace.h>
|
||||
-#include <bcm47xx_nvram.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
#include <asm/mach-bcm47xx/bcm47xx.h>
|
||||
|
||||
static char nvram_buf[NVRAM_SPACE];
|
||||
--- a/arch/mips/bcm47xx/setup.c
|
||||
+++ b/arch/mips/bcm47xx/setup.c
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <asm/reboot.h>
|
||||
#include <asm/time.h>
|
||||
#include <bcm47xx.h>
|
||||
-#include <bcm47xx_nvram.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
#include <bcm47xx_board.h>
|
||||
|
||||
union bcm47xx_bus bcm47xx_bus;
|
||||
--- a/arch/mips/bcm47xx/sprom.c
|
||||
+++ b/arch/mips/bcm47xx/sprom.c
|
||||
@@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <bcm47xx.h>
|
||||
-#include <bcm47xx_nvram.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
|
||||
static void create_key(const char *prefix, const char *postfix,
|
||||
const char *name, char *buf, int len)
|
||||
--- a/arch/mips/bcm47xx/time.c
|
||||
+++ b/arch/mips/bcm47xx/time.c
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <linux/ssb/ssb.h>
|
||||
#include <asm/time.h>
|
||||
#include <bcm47xx.h>
|
||||
-#include <bcm47xx_nvram.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
#include <bcm47xx_board.h>
|
||||
|
||||
void __init plat_time_init(void)
|
||||
--- a/drivers/net/ethernet/broadcom/b44.c
|
||||
+++ b/drivers/net/ethernet/broadcom/b44.c
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <linux/ssb/ssb.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/phy.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/io.h>
|
||||
@@ -399,8 +400,6 @@ static void b44_set_flow_ctrl(struct b44
|
||||
__b44_set_flow_ctrl(bp, pause_enab);
|
||||
}
|
||||
|
||||
-#ifdef CONFIG_BCM47XX
|
||||
-#include <bcm47xx_nvram.h>
|
||||
static void b44_wap54g10_workaround(struct b44 *bp)
|
||||
{
|
||||
char buf[20];
|
||||
@@ -429,11 +428,6 @@ static void b44_wap54g10_workaround(stru
|
||||
error:
|
||||
pr_warning("PHY: cannot reset MII transceiver isolate bit\n");
|
||||
}
|
||||
-#else
|
||||
-static inline void b44_wap54g10_workaround(struct b44 *bp)
|
||||
-{
|
||||
-}
|
||||
-#endif
|
||||
|
||||
static int b44_setup_phy(struct b44 *bp)
|
||||
{
|
||||
--- a/drivers/net/ethernet/broadcom/bgmac.c
|
||||
+++ b/drivers/net/ethernet/broadcom/bgmac.c
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/platform_data/b53.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),
|
||||
--- a/drivers/ssb/driver_chipcommon_pmu.c
|
||||
+++ b/drivers/ssb/driver_chipcommon_pmu.c
|
||||
@@ -13,9 +13,7 @@
|
||||
#include <linux/ssb/ssb_driver_chipcommon.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/export.h>
|
||||
-#ifdef CONFIG_BCM47XX
|
||||
-#include <bcm47xx_nvram.h>
|
||||
-#endif
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
|
||||
#include "ssb_private.h"
|
||||
|
||||
@@ -320,11 +318,9 @@ static void ssb_pmu_pll_init(struct ssb_
|
||||
u32 crystalfreq = 0; /* in kHz. 0 = keep default freq. */
|
||||
|
||||
if (bus->bustype == SSB_BUSTYPE_SSB) {
|
||||
-#ifdef CONFIG_BCM47XX
|
||||
char buf[20];
|
||||
if (bcm47xx_nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0)
|
||||
crystalfreq = simple_strtoul(buf, NULL, 0);
|
||||
-#endif
|
||||
}
|
||||
|
||||
switch (bus->chip_id) {
|
|
@ -0,0 +1,119 @@
|
|||
From 0509f6dcc46d10ea4bb8c70494dc7ae11bcb3f01 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
|
||||
Date: Wed, 10 Dec 2014 21:14:10 +0100
|
||||
Subject: [PATCH] firmware: backport NVRAM driver
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
|
||||
---
|
||||
arch/arm/Kconfig | 2 ++
|
||||
drivers/firmware/Kconfig | 1 +
|
||||
drivers/firmware/Makefile | 1 +
|
||||
drivers/firmware/broadcom/bcm47xx_nvram.c | 3 ++-
|
||||
drivers/net/ethernet/broadcom/b44.c | 2 +-
|
||||
drivers/net/ethernet/broadcom/bgmac.c | 2 +-
|
||||
drivers/ssb/driver_chipcommon_pmu.c | 2 +-
|
||||
7 files changed, 9 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
|
||||
index 4733d32..ab18030 100644
|
||||
--- a/arch/arm/Kconfig
|
||||
+++ b/arch/arm/Kconfig
|
||||
@@ -2286,6 +2286,8 @@ source "net/Kconfig"
|
||||
|
||||
source "drivers/Kconfig"
|
||||
|
||||
+source "drivers/firmware/Kconfig"
|
||||
+
|
||||
source "fs/Kconfig"
|
||||
|
||||
source "arch/arm/Kconfig.debug"
|
||||
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/bcm47xx_nvram.c b/drivers/firmware/broadcom/bcm47xx_nvram.c
|
||||
index b6e1cc7..8ca7358 100644
|
||||
--- a/drivers/firmware/broadcom/bcm47xx_nvram.c
|
||||
+++ b/drivers/firmware/broadcom/bcm47xx_nvram.c
|
||||
@@ -11,6 +11,7 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
+#include <linux/io.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -34,7 +35,7 @@ struct nvram_header {
|
||||
};
|
||||
|
||||
static char nvram_buf[NVRAM_SPACE];
|
||||
-static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
|
||||
+static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000, 0x160000};
|
||||
|
||||
static u32 find_nvram_size(void __iomem *end)
|
||||
{
|
||||
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
|
||||
index 8a7bf7d..bf3bcd6 100644
|
||||
--- a/drivers/net/ethernet/broadcom/b44.c
|
||||
+++ b/drivers/net/ethernet/broadcom/b44.c
|
||||
@@ -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];
|
||||
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
|
||||
index 34c7bc8..943707f 100644
|
||||
--- a/drivers/net/ethernet/broadcom/bgmac.c
|
||||
+++ b/drivers/net/ethernet/broadcom/bgmac.c
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/platform_data/b53.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),
|
||||
diff --git a/drivers/ssb/driver_chipcommon_pmu.c b/drivers/ssb/driver_chipcommon_pmu.c
|
||||
index 1173a09..0942841 100644
|
||||
--- a/drivers/ssb/driver_chipcommon_pmu.c
|
||||
+++ b/drivers/ssb/driver_chipcommon_pmu.c
|
||||
@@ -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"
|
||||
--
|
||||
1.8.4.5
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
From 71a6bff8656a1713615ffdd9139a83d65ba46c6d Mon Sep 17 00:00:00 2001
|
||||
From: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
Date: Sat, 3 May 2014 22:54:59 +0200
|
||||
Subject: [PATCH 02/17] bcm47xx-nvram: add new broadcom nvram driver with dt
|
||||
support
|
||||
|
||||
This adds a new driver which searches at a given memory range for a
|
||||
nvram like it is used on the bcm47xx and bcm53xx SoCs with ARM and MIPS
|
||||
CPUs. This driver provides acces to this nvram to other device in the
|
||||
device tree. You have to specify the memory ranges where the content of
|
||||
the flash chip is memory mapped and this driver will search there for
|
||||
some nvram and parse it. Other drivers can use this driver to access the
|
||||
device nvram. The nvram is used to store board configurations like the
|
||||
mac addresses, the switch configuration and the calibration data for
|
||||
the wifi devices.
|
||||
|
||||
This was copied from arch/mips/bcm47xx/nvram.c and modified to interact
|
||||
with device tree. My plan is to make the MIPS bcm47xx also use this new
|
||||
driver some time later.
|
||||
|
||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
---
|
||||
.../devicetree/bindings/misc/bcm47xx-nvram.txt | 19 ++
|
||||
arch/mips/bcm47xx/board.c | 40 ++--
|
||||
arch/mips/bcm47xx/nvram.c | 7 +-
|
||||
arch/mips/bcm47xx/setup.c | 4 +-
|
||||
arch/mips/bcm47xx/sprom.c | 4 +-
|
||||
arch/mips/bcm47xx/time.c | 2 +-
|
||||
drivers/misc/Kconfig | 5 +
|
||||
drivers/misc/Makefile | 1 +
|
||||
drivers/misc/bcm47xx-nvram.c | 215 +++++++++++++++++++++
|
||||
drivers/net/ethernet/broadcom/b44.c | 2 +-
|
||||
drivers/net/ethernet/broadcom/bgmac.c | 5 +-
|
||||
drivers/ssb/driver_chipcommon_pmu.c | 3 +-
|
||||
include/linux/bcm47xx_nvram.h | 17 +-
|
||||
13 files changed, 286 insertions(+), 38 deletions(-)
|
||||
create mode 100644 Documentation/devicetree/bindings/misc/bcm47xx-nvram.txt
|
||||
create mode 100644 drivers/misc/bcm47xx-nvram.c
|
||||
|
||||
--- /dev/null
|
||||
+++ b/Documentation/devicetree/bindings/misc/bcm47xx-nvram.txt
|
||||
@@ -0,0 +1,19 @@
|
||||
+Broadcom bcm47xx/bcm53xx nvram access driver
|
||||
+
|
||||
+This driver provides access to the nvram for other drivers.
|
||||
+
|
||||
+Required properties:
|
||||
+
|
||||
+- compatible : brcm,bcm47xx-nvram
|
||||
+
|
||||
+- reg : iomem address range
|
||||
+
|
||||
+On NorthStar ARM SoCs the NAND flash is available at 0x1c000000 and the
|
||||
+NOR flash is at 0x1e000000
|
||||
+
|
||||
+Example:
|
||||
+
|
||||
+nvram0: nvram@0 {
|
||||
+ compatible = "brcm,bcm47xx-nvram";
|
||||
+ reg = <0x1c000000 0x01000000>;
|
||||
+};
|
||||
--- a/drivers/misc/Kconfig
|
||||
+++ b/drivers/misc/Kconfig
|
||||
@@ -515,6 +515,11 @@ config SRAM
|
||||
the genalloc API. It is supposed to be used for small on-chip SRAM
|
||||
areas found on many SoCs.
|
||||
|
||||
+config BCM47XX_NVRAM
|
||||
+ tristate "BCM47XX nvram driver"
|
||||
+ help
|
||||
+ This adds support for the brcm47xx nvram driver.
|
||||
+
|
||||
source "drivers/misc/c2port/Kconfig"
|
||||
source "drivers/misc/eeprom/Kconfig"
|
||||
source "drivers/misc/cb710/Kconfig"
|
||||
--- a/drivers/misc/Makefile
|
||||
+++ b/drivers/misc/Makefile
|
||||
@@ -54,3 +54,4 @@ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lat
|
||||
obj-$(CONFIG_SRAM) += sram.o
|
||||
obj-y += mic/
|
||||
obj-$(CONFIG_GENWQE) += genwqe/
|
||||
+obj-$(CONFIG_BCM47XX_NVRAM) += bcm47xx-nvram.o
|
||||
--- a/include/linux/bcm47xx_nvram.h
|
||||
+++ b/include/linux/bcm47xx_nvram.h
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
-#ifdef CONFIG_BCM47XX
|
||||
+#if defined(CONFIG_BCM47XX) || defined(CONFIG_BCM47XX_NVRAM)
|
||||
int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
|
||||
|
||||
int bcm47xx_nvram_gpio_pin(const char *name);
|
||||
--- a/drivers/misc/bcm47xx-nvram.c
|
||||
+++ b/drivers/misc/bcm47xx-nvram.c
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
struct nvram_header {
|
||||
u32 magic;
|
||||
- u32 len;
|
||||
+ __le32 len;
|
||||
u32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
|
||||
u32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
|
||||
u32 config_ncdl; /* ncdl values for memc */
|
|
@ -42,9 +42,9 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
|||
+};
|
||||
--- a/drivers/misc/Kconfig
|
||||
+++ b/drivers/misc/Kconfig
|
||||
@@ -520,6 +520,17 @@ config BCM47XX_NVRAM
|
||||
help
|
||||
This adds support for the brcm47xx nvram driver.
|
||||
@@ -515,6 +515,17 @@ config SRAM
|
||||
the genalloc API. It is supposed to be used for small on-chip SRAM
|
||||
areas found on many SoCs.
|
||||
|
||||
+config BCM47XX_SPROM
|
||||
+ tristate "BCM47XX sprom driver"
|
||||
|
@ -62,8 +62,8 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
|||
source "drivers/misc/cb710/Kconfig"
|
||||
--- a/drivers/misc/Makefile
|
||||
+++ b/drivers/misc/Makefile
|
||||
@@ -55,3 +55,4 @@ obj-$(CONFIG_SRAM) += sram.o
|
||||
@@ -54,3 +54,4 @@ obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lat
|
||||
obj-$(CONFIG_SRAM) += sram.o
|
||||
obj-y += mic/
|
||||
obj-$(CONFIG_GENWQE) += genwqe/
|
||||
obj-$(CONFIG_BCM47XX_NVRAM) += bcm47xx-nvram.o
|
||||
+obj-$(CONFIG_BCM47XX_SPROM) += bcm47xx-sprom.o
|
||||
|
|
|
@ -1,154 +0,0 @@
|
|||
From 7063a1583166abe1a9cefed38c2f53a0e14a0005 Mon Sep 17 00:00:00 2001
|
||||
From: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
Date: Sun, 4 May 2014 16:35:42 +0200
|
||||
Subject: [PATCH 01/17] MIPS: BCM47XX: move the nvram header file into common
|
||||
space
|
||||
|
||||
Moving mach-bcm47xx/bcm47xx_nvram.h to include/linux/bcm47xx_nvram.h
|
||||
makes it possible to reuse this header on the ARM based bcm47xx/bcm53xx
|
||||
SoCs (e.g. BCM5301X devices). Broadcom uses ARM CPUs in their new SoC
|
||||
form the bcm47xx and bcm53xx line, but many other things like nvram
|
||||
stayed the same.
|
||||
|
||||
This is a preparation for adding a new nvram driver, which can be used
|
||||
by the ARM SoC and the MIPS SoC code. The device drivers accessing
|
||||
nvram do not have to care about ARM or MIPS SoC version.
|
||||
|
||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
---
|
||||
arch/mips/bcm47xx/board.c | 2 +-
|
||||
arch/mips/bcm47xx/nvram.c | 2 +-
|
||||
arch/mips/bcm47xx/setup.c | 2 +-
|
||||
arch/mips/bcm47xx/sprom.c | 2 +-
|
||||
arch/mips/bcm47xx/time.c | 2 +-
|
||||
arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h | 53 -----------------
|
||||
drivers/net/ethernet/broadcom/b44.c | 8 +--
|
||||
drivers/net/ethernet/broadcom/bgmac.c | 2 +-
|
||||
drivers/ssb/driver_chipcommon_pmu.c | 6 +-
|
||||
include/linux/bcm47xx_nvram.h | 66 ++++++++++++++++++++++
|
||||
10 files changed, 74 insertions(+), 71 deletions(-)
|
||||
delete mode 100644 arch/mips/include/asm/mach-bcm47xx/bcm47xx_nvram.h
|
||||
create mode 100644 include/linux/bcm47xx_nvram.h
|
||||
|
||||
--- a/arch/mips/bcm47xx/board.c
|
||||
+++ b/arch/mips/bcm47xx/board.c
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <linux/export.h>
|
||||
#include <linux/string.h>
|
||||
#include <bcm47xx_board.h>
|
||||
-#include <bcm47xx_nvram.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
|
||||
struct bcm47xx_board_type {
|
||||
const enum bcm47xx_board board;
|
||||
--- a/arch/mips/bcm47xx/nvram.c
|
||||
+++ b/arch/mips/bcm47xx/nvram.c
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/string.h>
|
||||
#include <asm/addrspace.h>
|
||||
-#include <bcm47xx_nvram.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
#include <asm/mach-bcm47xx/bcm47xx.h>
|
||||
|
||||
static char nvram_buf[NVRAM_SPACE];
|
||||
--- a/arch/mips/bcm47xx/setup.c
|
||||
+++ b/arch/mips/bcm47xx/setup.c
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <asm/reboot.h>
|
||||
#include <asm/time.h>
|
||||
#include <bcm47xx.h>
|
||||
-#include <bcm47xx_nvram.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
#include <bcm47xx_board.h>
|
||||
|
||||
union bcm47xx_bus bcm47xx_bus;
|
||||
--- a/arch/mips/bcm47xx/sprom.c
|
||||
+++ b/arch/mips/bcm47xx/sprom.c
|
||||
@@ -27,7 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <bcm47xx.h>
|
||||
-#include <bcm47xx_nvram.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/etherdevice.h>
|
||||
|
||||
--- a/arch/mips/bcm47xx/time.c
|
||||
+++ b/arch/mips/bcm47xx/time.c
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <linux/ssb/ssb.h>
|
||||
#include <asm/time.h>
|
||||
#include <bcm47xx.h>
|
||||
-#include <bcm47xx_nvram.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
#include <bcm47xx_board.h>
|
||||
|
||||
void __init plat_time_init(void)
|
||||
--- a/drivers/net/ethernet/broadcom/b44.c
|
||||
+++ b/drivers/net/ethernet/broadcom/b44.c
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <linux/ssb/ssb.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/phy.h>
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/io.h>
|
||||
@@ -399,8 +400,6 @@ static void b44_set_flow_ctrl(struct b44
|
||||
__b44_set_flow_ctrl(bp, pause_enab);
|
||||
}
|
||||
|
||||
-#ifdef CONFIG_BCM47XX
|
||||
-#include <bcm47xx_nvram.h>
|
||||
static void b44_wap54g10_workaround(struct b44 *bp)
|
||||
{
|
||||
char buf[20];
|
||||
@@ -429,11 +428,6 @@ static void b44_wap54g10_workaround(stru
|
||||
error:
|
||||
pr_warn("PHY: cannot reset MII transceiver isolate bit\n");
|
||||
}
|
||||
-#else
|
||||
-static inline void b44_wap54g10_workaround(struct b44 *bp)
|
||||
-{
|
||||
-}
|
||||
-#endif
|
||||
|
||||
static int b44_setup_phy(struct b44 *bp)
|
||||
{
|
||||
--- a/drivers/net/ethernet/broadcom/bgmac.c
|
||||
+++ b/drivers/net/ethernet/broadcom/bgmac.c
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/platform_data/b53.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),
|
||||
--- a/drivers/ssb/driver_chipcommon_pmu.c
|
||||
+++ b/drivers/ssb/driver_chipcommon_pmu.c
|
||||
@@ -13,9 +13,7 @@
|
||||
#include <linux/ssb/ssb_driver_chipcommon.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/export.h>
|
||||
-#ifdef CONFIG_BCM47XX
|
||||
-#include <bcm47xx_nvram.h>
|
||||
-#endif
|
||||
+#include <linux/bcm47xx_nvram.h>
|
||||
|
||||
#include "ssb_private.h"
|
||||
|
||||
@@ -320,11 +318,9 @@ static void ssb_pmu_pll_init(struct ssb_
|
||||
u32 crystalfreq = 0; /* in kHz. 0 = keep default freq. */
|
||||
|
||||
if (bus->bustype == SSB_BUSTYPE_SSB) {
|
||||
-#ifdef CONFIG_BCM47XX
|
||||
char buf[20];
|
||||
if (bcm47xx_nvram_getenv("xtalfreq", buf, sizeof(buf)) >= 0)
|
||||
crystalfreq = simple_strtoul(buf, NULL, 0);
|
||||
-#endif
|
||||
}
|
||||
|
||||
switch (bus->chip_id) {
|
|
@ -0,0 +1,119 @@
|
|||
From 0509f6dcc46d10ea4bb8c70494dc7ae11bcb3f01 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
|
||||
Date: Wed, 10 Dec 2014 21:14:10 +0100
|
||||
Subject: [PATCH] firmware: backport NVRAM driver
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
|
||||
---
|
||||
arch/arm/Kconfig | 2 ++
|
||||
drivers/firmware/Kconfig | 1 +
|
||||
drivers/firmware/Makefile | 1 +
|
||||
drivers/firmware/broadcom/bcm47xx_nvram.c | 3 ++-
|
||||
drivers/net/ethernet/broadcom/b44.c | 2 +-
|
||||
drivers/net/ethernet/broadcom/bgmac.c | 2 +-
|
||||
drivers/ssb/driver_chipcommon_pmu.c | 2 +-
|
||||
7 files changed, 9 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
|
||||
index 4733d32..ab18030 100644
|
||||
--- a/arch/arm/Kconfig
|
||||
+++ b/arch/arm/Kconfig
|
||||
@@ -2286,6 +2286,8 @@ source "net/Kconfig"
|
||||
|
||||
source "drivers/Kconfig"
|
||||
|
||||
+source "drivers/firmware/Kconfig"
|
||||
+
|
||||
source "fs/Kconfig"
|
||||
|
||||
source "arch/arm/Kconfig.debug"
|
||||
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/bcm47xx_nvram.c b/drivers/firmware/broadcom/bcm47xx_nvram.c
|
||||
index b6e1cc7..8ca7358 100644
|
||||
--- a/drivers/firmware/broadcom/bcm47xx_nvram.c
|
||||
+++ b/drivers/firmware/broadcom/bcm47xx_nvram.c
|
||||
@@ -11,6 +11,7 @@
|
||||
* option) any later version.
|
||||
*/
|
||||
|
||||
+#include <linux/io.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
@@ -34,7 +35,7 @@ struct nvram_header {
|
||||
};
|
||||
|
||||
static char nvram_buf[NVRAM_SPACE];
|
||||
-static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
|
||||
+static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000, 0x160000};
|
||||
|
||||
static u32 find_nvram_size(void __iomem *end)
|
||||
{
|
||||
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
|
||||
index 8a7bf7d..bf3bcd6 100644
|
||||
--- a/drivers/net/ethernet/broadcom/b44.c
|
||||
+++ b/drivers/net/ethernet/broadcom/b44.c
|
||||
@@ -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];
|
||||
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
|
||||
index 34c7bc8..943707f 100644
|
||||
--- a/drivers/net/ethernet/broadcom/bgmac.c
|
||||
+++ b/drivers/net/ethernet/broadcom/bgmac.c
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/dma-mapping.h>
|
||||
#include <linux/platform_data/b53.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),
|
||||
diff --git a/drivers/ssb/driver_chipcommon_pmu.c b/drivers/ssb/driver_chipcommon_pmu.c
|
||||
index 1173a09..0942841 100644
|
||||
--- a/drivers/ssb/driver_chipcommon_pmu.c
|
||||
+++ b/drivers/ssb/driver_chipcommon_pmu.c
|
||||
@@ -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"
|
||||
--
|
||||
1.8.4.5
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
From 71a6bff8656a1713615ffdd9139a83d65ba46c6d Mon Sep 17 00:00:00 2001
|
||||
From: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
Date: Sat, 3 May 2014 22:54:59 +0200
|
||||
Subject: [PATCH 02/17] bcm47xx-nvram: add new broadcom nvram driver with dt
|
||||
support
|
||||
|
||||
This adds a new driver which searches at a given memory range for a
|
||||
nvram like it is used on the bcm47xx and bcm53xx SoCs with ARM and MIPS
|
||||
CPUs. This driver provides acces to this nvram to other device in the
|
||||
device tree. You have to specify the memory ranges where the content of
|
||||
the flash chip is memory mapped and this driver will search there for
|
||||
some nvram and parse it. Other drivers can use this driver to access the
|
||||
device nvram. The nvram is used to store board configurations like the
|
||||
mac addresses, the switch configuration and the calibration data for
|
||||
the wifi devices.
|
||||
|
||||
This was copied from arch/mips/bcm47xx/nvram.c and modified to interact
|
||||
with device tree. My plan is to make the MIPS bcm47xx also use this new
|
||||
driver some time later.
|
||||
|
||||
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
||||
---
|
||||
.../devicetree/bindings/misc/bcm47xx-nvram.txt | 19 ++
|
||||
arch/mips/bcm47xx/board.c | 40 ++--
|
||||
arch/mips/bcm47xx/nvram.c | 7 +-
|
||||
arch/mips/bcm47xx/setup.c | 4 +-
|
||||
arch/mips/bcm47xx/sprom.c | 4 +-
|
||||
arch/mips/bcm47xx/time.c | 2 +-
|
||||
drivers/misc/Kconfig | 5 +
|
||||
drivers/misc/Makefile | 1 +
|
||||
drivers/misc/bcm47xx-nvram.c | 215 +++++++++++++++++++++
|
||||
drivers/net/ethernet/broadcom/b44.c | 2 +-
|
||||
drivers/net/ethernet/broadcom/bgmac.c | 5 +-
|
||||
drivers/ssb/driver_chipcommon_pmu.c | 3 +-
|
||||
include/linux/bcm47xx_nvram.h | 17 +-
|
||||
13 files changed, 286 insertions(+), 38 deletions(-)
|
||||
create mode 100644 Documentation/devicetree/bindings/misc/bcm47xx-nvram.txt
|
||||
create mode 100644 drivers/misc/bcm47xx-nvram.c
|
||||
|
||||
--- /dev/null
|
||||
+++ b/Documentation/devicetree/bindings/misc/bcm47xx-nvram.txt
|
||||
@@ -0,0 +1,19 @@
|
||||
+Broadcom bcm47xx/bcm53xx nvram access driver
|
||||
+
|
||||
+This driver provides access to the nvram for other drivers.
|
||||
+
|
||||
+Required properties:
|
||||
+
|
||||
+- compatible : brcm,bcm47xx-nvram
|
||||
+
|
||||
+- reg : iomem address range
|
||||
+
|
||||
+On NorthStar ARM SoCs the NAND flash is available at 0x1c000000 and the
|
||||
+NOR flash is at 0x1e000000
|
||||
+
|
||||
+Example:
|
||||
+
|
||||
+nvram0: nvram@0 {
|
||||
+ compatible = "brcm,bcm47xx-nvram";
|
||||
+ reg = <0x1c000000 0x01000000>;
|
||||
+};
|
||||
--- a/drivers/misc/Kconfig
|
||||
+++ b/drivers/misc/Kconfig
|
||||
@@ -515,6 +515,11 @@ config VEXPRESS_SYSCFG
|
||||
bus. System Configuration interface is one of the possible means
|
||||
of generating transactions on this bus.
|
||||
|
||||
+config BCM47XX_NVRAM
|
||||
+ tristate "BCM47XX nvram driver"
|
||||
+ help
|
||||
+ This adds support for the brcm47xx nvram driver.
|
||||
+
|
||||
source "drivers/misc/c2port/Kconfig"
|
||||
source "drivers/misc/eeprom/Kconfig"
|
||||
source "drivers/misc/cb710/Kconfig"
|
||||
--- a/drivers/misc/Makefile
|
||||
+++ b/drivers/misc/Makefile
|
||||
@@ -56,3 +56,4 @@ obj-$(CONFIG_GENWQE) += genwqe/
|
||||
obj-$(CONFIG_ECHO) += echo/
|
||||
obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o
|
||||
obj-$(CONFIG_CXL_BASE) += cxl/
|
||||
+obj-$(CONFIG_BCM47XX_NVRAM) += bcm47xx-nvram.o
|
||||
--- a/include/linux/bcm47xx_nvram.h
|
||||
+++ b/include/linux/bcm47xx_nvram.h
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/kernel.h>
|
||||
-
|
||||
-#ifdef CONFIG_BCM47XX
|
||||
+
|
||||
+#if defined(CONFIG_BCM47XX) || defined(CONFIG_BCM47XX_NVRAM)
|
||||
int bcm47xx_nvram_getenv(const char *name, char *val, size_t val_len);
|
||||
|
||||
int bcm47xx_nvram_gpio_pin(const char *name);
|
||||
--- a/drivers/misc/bcm47xx-nvram.c
|
||||
+++ b/drivers/misc/bcm47xx-nvram.c
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
struct nvram_header {
|
||||
u32 magic;
|
||||
- u32 len;
|
||||
+ __le32 len;
|
||||
u32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:31 sdram_init */
|
||||
u32 config_refresh; /* 0:15 sdram_config, 16:31 sdram_refresh */
|
||||
u32 config_ncdl; /* ncdl values for memc */
|
|
@ -42,9 +42,9 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
|||
+};
|
||||
--- a/drivers/misc/Kconfig
|
||||
+++ b/drivers/misc/Kconfig
|
||||
@@ -520,6 +520,17 @@ config BCM47XX_NVRAM
|
||||
help
|
||||
This adds support for the brcm47xx nvram driver.
|
||||
@@ -515,6 +515,17 @@ config VEXPRESS_SYSCFG
|
||||
bus. System Configuration interface is one of the possible means
|
||||
of generating transactions on this bus.
|
||||
|
||||
+config BCM47XX_SPROM
|
||||
+ tristate "BCM47XX sprom driver"
|
||||
|
@ -62,8 +62,8 @@ Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
|||
source "drivers/misc/cb710/Kconfig"
|
||||
--- a/drivers/misc/Makefile
|
||||
+++ b/drivers/misc/Makefile
|
||||
@@ -57,3 +57,4 @@ obj-$(CONFIG_ECHO) += echo/
|
||||
@@ -56,3 +56,4 @@ obj-$(CONFIG_GENWQE) += genwqe/
|
||||
obj-$(CONFIG_ECHO) += echo/
|
||||
obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o
|
||||
obj-$(CONFIG_CXL_BASE) += cxl/
|
||||
obj-$(CONFIG_BCM47XX_NVRAM) += bcm47xx-nvram.o
|
||||
+obj-$(CONFIG_BCM47XX_SPROM) += bcm47xx-sprom.o
|
||||
|
|
Loading…
Reference in New Issue