linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 1/2] documentation: Add nvmem bindings documentation
@ 2018-03-24 17:46 chinnikishore369
  2018-03-24 17:46 ` [RFC 2/2] nvmem: zynqmp: Added zynqmp nvmem firmware driver chinnikishore369
  2018-05-11  8:44 ` [RFC 1/2] documentation: Add nvmem bindings documentation Srinivas Kandagatla
  0 siblings, 2 replies; 3+ messages in thread
From: chinnikishore369 @ 2018-03-24 17:46 UTC (permalink / raw)
  To: srinivas.kandagatla, michal.simek, linux-arm-kernel, linux-kernel
  Cc: Nava kishore Manne

From: Nava kishore Manne <navam@xilinx.com>

This patch add the bindings document of zynqmp silicon id driver.

Signed-off-by: Nava kishore Manne <navam@xilinx.com>
---
 .../devicetree/bindings/nvmem/zynqmp_nvmem.txt     | 32 ++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/zynqmp_nvmem.txt

diff --git a/Documentation/devicetree/bindings/nvmem/zynqmp_nvmem.txt b/Documentation/devicetree/bindings/nvmem/zynqmp_nvmem.txt
new file mode 100644
index 000000000000..94332f160a92
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/zynqmp_nvmem.txt
@@ -0,0 +1,32 @@
+=  Zynq UltraScale+ MPSoC nvmem firmware driver binding =
+
+Required properties:
+- compatible: should be "xlnx,zynqmp-nvmem-fw"
+
+= Data cells =
+Are child nodes of silicon id, bindings of which as described in
+bindings/nvmem/nvmem.txt
+
+Example:
+
+	nvmem_firmware {
+		compatible = "xlnx,zynqmp-nvmem-fw";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		 /* Data cells */
+		soc_revision: soc_revision@0 {
+			reg = <0x0 0x4>;
+		};
+	};
+
+= Data consumers =
+Are device nodes which consume nvmem data cells.
+
+For example:
+
+	pcap {
+		...
+		nvmem-cells = <&soc_revision>;
+		nvmem-cell-names = "soc_revision";
+	};
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [RFC 2/2] nvmem: zynqmp: Added zynqmp nvmem firmware driver
  2018-03-24 17:46 [RFC 1/2] documentation: Add nvmem bindings documentation chinnikishore369
@ 2018-03-24 17:46 ` chinnikishore369
  2018-05-11  8:44 ` [RFC 1/2] documentation: Add nvmem bindings documentation Srinivas Kandagatla
  1 sibling, 0 replies; 3+ messages in thread
From: chinnikishore369 @ 2018-03-24 17:46 UTC (permalink / raw)
  To: srinivas.kandagatla, michal.simek, linux-arm-kernel, linux-kernel
  Cc: Nava kishore Manne

From: Nava kishore Manne <navam@xilinx.com>

This patch adds zynqmp nvmem firmware driver to access the
SoC revision information from the hardware register.

Signed-off-by: Nava kishore Manne <navam@xilinx.com>
---
 drivers/nvmem/Kconfig        |  9 +++++
 drivers/nvmem/Makefile       |  2 ++
 drivers/nvmem/zynqmp_nvmem.c | 85 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 96 insertions(+)
 create mode 100644 drivers/nvmem/zynqmp_nvmem.c

diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index ff505af064ba..a9349281d05a 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -175,4 +175,13 @@ config NVMEM_SNVS_LPGPR
 	  This driver can also be built as a module. If so, the module
 	  will be called nvmem-snvs-lpgpr.
 
+config NVMEM_ZYNQMP
+        bool "Xilinx ZYNQMP SoC nvmem firmware support"
+        depends on ARCH_ZYNQMP
+        help
+          This is a driver to access hardware related data like soc revision,
+          IDCODE... etc.
+
+          If sure, say yes. If unsure, say no.
+
 endif
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index e54dcfa6565a..932b4cebcb6c 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -37,3 +37,5 @@ obj-$(CONFIG_MESON_MX_EFUSE)	+= nvmem_meson_mx_efuse.o
 nvmem_meson_mx_efuse-y		:= meson-mx-efuse.o
 obj-$(CONFIG_NVMEM_SNVS_LPGPR)	+= nvmem_snvs_lpgpr.o
 nvmem_snvs_lpgpr-y		:= snvs_lpgpr.o
+obj-$(CONFIG_NVMEM_ZYNQMP)	+= nvmem_zynqmp_nvmem.o
+nvmem_zynqmp_nvmem-y		:= zynqmp_nvmem.o
diff --git a/drivers/nvmem/zynqmp_nvmem.c b/drivers/nvmem/zynqmp_nvmem.c
new file mode 100644
index 000000000000..206ec9bd775d
--- /dev/null
+++ b/drivers/nvmem/zynqmp_nvmem.c
@@ -0,0 +1,85 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Xilinx, Inc.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/nvmem-provider.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/firmware/xilinx/zynqmp/firmware.h>
+
+#define SILICON_REVISION_MASK 0xF
+
+static int zynqmp_nvmem_read(void *context, unsigned int offset,
+					void *val, size_t bytes)
+{
+	int ret;
+	int idcode, version;
+	const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops();
+
+	if (!eemi_ops || !eemi_ops->get_chipid)
+		return -ENXIO;
+
+	ret = eemi_ops->get_chipid(&idcode, &version);
+	if (ret < 0)
+		return ret;
+
+	pr_debug("Read chipid val %x %x\n", idcode, version);
+	*(int *)val = version & SILICON_REVISION_MASK;
+
+	return 0;
+}
+
+static struct nvmem_config econfig = {
+	.name = "zynqmp-nvmem",
+	.owner = THIS_MODULE,
+	.word_size = 1,
+	.size = 1,
+	.read_only = true,
+};
+
+static const struct of_device_id zynqmp_nvmem_match[] = {
+	{ .compatible = "xlnx,zynqmp-nvmem-fw", },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, zynqmp_nvmem_match);
+
+static int zynqmp_nvmem_probe(struct platform_device *pdev)
+{
+	struct nvmem_device *nvmem;
+
+	econfig.dev = &pdev->dev;
+	econfig.reg_read = zynqmp_nvmem_read;
+
+	nvmem = nvmem_register(&econfig);
+	if (IS_ERR(nvmem))
+		return PTR_ERR(nvmem);
+
+	platform_set_drvdata(pdev, nvmem);
+
+	return 0;
+}
+
+static int zynqmp_nvmem_remove(struct platform_device *pdev)
+{
+	struct nvmem_device *nvmem = platform_get_drvdata(pdev);
+
+	return nvmem_unregister(nvmem);
+}
+
+static struct platform_driver zynqmp_nvmem_driver = {
+	.probe = zynqmp_nvmem_probe,
+	.remove = zynqmp_nvmem_remove,
+	.driver = {
+		.name = "zynqmp-nvmem",
+		.of_match_table = zynqmp_nvmem_match,
+	},
+};
+
+module_platform_driver(zynqmp_nvmem_driver);
+
+MODULE_AUTHOR("Michal Simek <michal.simek@xilinx.com>, Nava kishore Manne <navam@xilinx.com>");
+MODULE_DESCRIPTION("ZynqMP NVMEM driver");
+MODULE_LICENSE("GPL");
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC 1/2] documentation: Add nvmem bindings documentation
  2018-03-24 17:46 [RFC 1/2] documentation: Add nvmem bindings documentation chinnikishore369
  2018-03-24 17:46 ` [RFC 2/2] nvmem: zynqmp: Added zynqmp nvmem firmware driver chinnikishore369
@ 2018-05-11  8:44 ` Srinivas Kandagatla
  1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2018-05-11  8:44 UTC (permalink / raw)
  To: chinnikishore369, michal.simek, linux-arm-kernel, linux-kernel
  Cc: Nava kishore Manne




On 24/03/18 17:46, chinnikishore369@gmail.com wrote:
> From: Nava kishore Manne <navam@xilinx.com>
> 
> This patch add the bindings document of zynqmp silicon id driver.
> 
> Signed-off-by: Nava kishore Manne <navam@xilinx.com>

I see that you have not included DT maintainers in to/cc list, I can not 
accept new drivers whose bindings are not Acked/Reviewed by DT maintainers.

Overall the driver looks fine for me.


thanks,
srini


> ---
>   .../devicetree/bindings/nvmem/zynqmp_nvmem.txt     | 32 ++++++++++++++++++++++
>   1 file changed, 32 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/nvmem/zynqmp_nvmem.txt
> 
> diff --git a/Documentation/devicetree/bindings/nvmem/zynqmp_nvmem.txt b/Documentation/devicetree/bindings/nvmem/zynqmp_nvmem.txt
> new file mode 100644
> index 000000000000..94332f160a92
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/nvmem/zynqmp_nvmem.txt
> @@ -0,0 +1,32 @@
> +=  Zynq UltraScale+ MPSoC nvmem firmware driver binding =
> +
> +Required properties:
> +- compatible: should be "xlnx,zynqmp-nvmem-fw"
> +
> += Data cells =
> +Are child nodes of silicon id, bindings of which as described in
> +bindings/nvmem/nvmem.txt
> +
> +Example:
> +
> +	nvmem_firmware {
> +		compatible = "xlnx,zynqmp-nvmem-fw";
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +
> +		 /* Data cells */
> +		soc_revision: soc_revision@0 {
> +			reg = <0x0 0x4>;
> +		};
> +	};
> +
> += Data consumers =
> +Are device nodes which consume nvmem data cells.
> +
> +For example:
> +
> +	pcap {
> +		...
> +		nvmem-cells = <&soc_revision>;
> +		nvmem-cell-names = "soc_revision";
> +	};
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-11  8:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-24 17:46 [RFC 1/2] documentation: Add nvmem bindings documentation chinnikishore369
2018-03-24 17:46 ` [RFC 2/2] nvmem: zynqmp: Added zynqmp nvmem firmware driver chinnikishore369
2018-05-11  8:44 ` [RFC 1/2] documentation: Add nvmem bindings documentation Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).