d8e8a2a8db
It still requires fixing PCIe support: [ 6.644699] pcie_iproc_bcma bcma0:7: host bridge /axi@18000000/pcie@12000 ranges: [ 6.652217] pcie_iproc_bcma bcma0:7: No bus range found for /axi@18000000/pcie@12000, using [bus 00-ff] [ 6.661833] OF: /axi@18000000/pcie@12000: Missing device_type [ 6.667622] pcie_iproc_bcma: probe of bcma0:7 failed with error -12 [ 6.673985] pcie_iproc_bcma bcma0:8: host bridge /axi@18000000/pcie@13000 ranges: [ 6.681514] pcie_iproc_bcma bcma0:8: No bus range found for /axi@18000000/pcie@13000, using [bus 00-ff] [ 6.691137] pcie_iproc_bcma: probe of bcma0:8 failed with error -12 [ 6.697522] pcie_iproc_bcma bcma0:9: host bridge /axi@18000000/pcie@14000 ranges: [ 6.705048] pcie_iproc_bcma bcma0:9: No bus range found for /axi@18000000/pcie@14000, using [bus 00-ff] [ 6.714669] pcie_iproc_bcma: probe of bcma0:9 failed with error -12 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
125 lines
3.3 KiB
Diff
125 lines
3.3 KiB
Diff
From b152bbeb0282bfcf6f91d0d5befd7582c1c3fc23 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
|
|
Date: Fri, 5 Mar 2021 19:32:36 +0100
|
|
Subject: [PATCH] nvmem: brcm_nvram: new driver exposing Broadcom's NVRAM
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
This driver provides access to Broadcom's NVRAM.
|
|
|
|
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
|
|
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
|
|
---
|
|
drivers/nvmem/Kconfig | 9 +++++
|
|
drivers/nvmem/Makefile | 2 +
|
|
drivers/nvmem/brcm_nvram.c | 78 ++++++++++++++++++++++++++++++++++++++
|
|
3 files changed, 89 insertions(+)
|
|
create mode 100644 drivers/nvmem/brcm_nvram.c
|
|
|
|
--- a/drivers/nvmem/Kconfig
|
|
+++ b/drivers/nvmem/Kconfig
|
|
@@ -270,4 +270,13 @@ config SPRD_EFUSE
|
|
This driver can also be built as a module. If so, the module
|
|
will be called nvmem-sprd-efuse.
|
|
|
|
+
|
|
+config NVMEM_BRCM_NVRAM
|
|
+ tristate "Broadcom's NVRAM support"
|
|
+ depends on ARCH_BCM_5301X || COMPILE_TEST
|
|
+ depends on HAS_IOMEM
|
|
+ help
|
|
+ This driver provides support for Broadcom's NVRAM that can be accessed
|
|
+ using I/O mapping.
|
|
+
|
|
endif
|
|
--- a/drivers/nvmem/Makefile
|
|
+++ b/drivers/nvmem/Makefile
|
|
@@ -55,3 +55,5 @@ obj-$(CONFIG_NVMEM_ZYNQMP) += nvmem_zynq
|
|
nvmem_zynqmp_nvmem-y := zynqmp_nvmem.o
|
|
obj-$(CONFIG_SPRD_EFUSE) += nvmem_sprd_efuse.o
|
|
nvmem_sprd_efuse-y := sprd-efuse.o
|
|
+obj-$(CONFIG_NVMEM_BRCM_NVRAM) += nvmem_brcm_nvram.o
|
|
+nvmem_brcm_nvram-y := brcm_nvram.o
|
|
--- /dev/null
|
|
+++ b/drivers/nvmem/brcm_nvram.c
|
|
@@ -0,0 +1,78 @@
|
|
+// SPDX-License-Identifier: GPL-2.0-only
|
|
+/*
|
|
+ * Copyright (C) 2021 Rafał Miłecki <rafal@milecki.pl>
|
|
+ */
|
|
+
|
|
+#include <linux/io.h>
|
|
+#include <linux/mod_devicetable.h>
|
|
+#include <linux/module.h>
|
|
+#include <linux/nvmem-provider.h>
|
|
+#include <linux/platform_device.h>
|
|
+
|
|
+struct brcm_nvram {
|
|
+ struct device *dev;
|
|
+ void __iomem *base;
|
|
+};
|
|
+
|
|
+static int brcm_nvram_read(void *context, unsigned int offset, void *val,
|
|
+ size_t bytes)
|
|
+{
|
|
+ struct brcm_nvram *priv = context;
|
|
+ u8 *dst = val;
|
|
+
|
|
+ while (bytes--)
|
|
+ *dst++ = readb(priv->base + offset++);
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static int brcm_nvram_probe(struct platform_device *pdev)
|
|
+{
|
|
+ struct nvmem_config config = {
|
|
+ .name = "brcm-nvram",
|
|
+ .reg_read = brcm_nvram_read,
|
|
+ };
|
|
+ struct device *dev = &pdev->dev;
|
|
+ struct resource *res;
|
|
+ struct brcm_nvram *priv;
|
|
+
|
|
+ priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
|
|
+ if (!priv)
|
|
+ return -ENOMEM;
|
|
+ priv->dev = dev;
|
|
+
|
|
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
+ priv->base = devm_ioremap_resource(dev, res);
|
|
+ if (IS_ERR(priv->base))
|
|
+ return PTR_ERR(priv->base);
|
|
+
|
|
+ config.dev = dev;
|
|
+ config.priv = priv;
|
|
+ config.size = resource_size(res);
|
|
+
|
|
+ return PTR_ERR_OR_ZERO(devm_nvmem_register(dev, &config));
|
|
+}
|
|
+
|
|
+static const struct of_device_id brcm_nvram_of_match_table[] = {
|
|
+ { .compatible = "brcm,nvram", },
|
|
+ {},
|
|
+};
|
|
+
|
|
+static struct platform_driver brcm_nvram_driver = {
|
|
+ .probe = brcm_nvram_probe,
|
|
+ .driver = {
|
|
+ .name = "brcm_nvram",
|
|
+ .of_match_table = brcm_nvram_of_match_table,
|
|
+ },
|
|
+};
|
|
+
|
|
+static int __init brcm_nvram_init(void)
|
|
+{
|
|
+ return platform_driver_register(&brcm_nvram_driver);
|
|
+}
|
|
+
|
|
+subsys_initcall_sync(brcm_nvram_init);
|
|
+
|
|
+MODULE_AUTHOR("Rafał Miłecki");
|
|
+MODULE_LICENSE("GPL");
|
|
+MODULE_DEVICE_TABLE(of, brcm_nvram_of_match_table);
|