linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] nvmem: add Layerscape SFP support
@ 2022-02-14 11:55 Michael Walle
  2022-02-14 11:55 ` [PATCH v2 1/3] dt-bindings: nvmem: add fsl,layerscape-sfp binding Michael Walle
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Michael Walle @ 2022-02-14 11:55 UTC (permalink / raw)
  To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski, Shawn Guo,
	Li Yang
  Cc: devicetree, linux-kernel, linux-arm-kernel, Michael Walle

Add support for the Security Fuse Processor found on Layerscape
SoCs.

changes since v1:
 - added Rob's Rb
 - cleaned up the include files
 - changed the module license to only "GPL"
 - fix indendation, split lines longer than 80c

Michael Walle (3):
  dt-bindings: nvmem: add fsl,layerscape-sfp binding
  nvmem: add driver for Layerscape SFP (Security Fuse Processor)
  arm64: dts: ls1028a: add efuse node

 .../bindings/nvmem/fsl,layerscape-sfp.yaml    | 38 ++++++++
 .../arm64/boot/dts/freescale/fsl-ls1028a.dtsi | 11 +++
 drivers/nvmem/Kconfig                         | 12 +++
 drivers/nvmem/Makefile                        |  2 +
 drivers/nvmem/layerscape-sfp.c                | 89 +++++++++++++++++++
 5 files changed, 152 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
 create mode 100644 drivers/nvmem/layerscape-sfp.c

-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 1/3] dt-bindings: nvmem: add fsl,layerscape-sfp binding
  2022-02-14 11:55 [PATCH v2 0/3] nvmem: add Layerscape SFP support Michael Walle
@ 2022-02-14 11:55 ` Michael Walle
  2022-02-14 11:55 ` [PATCH v2 2/3] nvmem: add driver for Layerscape SFP (Security Fuse Processor) Michael Walle
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Michael Walle @ 2022-02-14 11:55 UTC (permalink / raw)
  To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski, Shawn Guo,
	Li Yang
  Cc: devicetree, linux-kernel, linux-arm-kernel, Michael Walle, Rob Herring

The Security Fuse Processor provides efuses and is responsible for
reading it at SoC startup and configuring it accordingly.

Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 .../bindings/nvmem/fsl,layerscape-sfp.yaml    | 38 +++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml

diff --git a/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
new file mode 100644
index 000000000000..80914b93638e
--- /dev/null
+++ b/Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/nvmem/fsl,layerscape-sfp.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Freescale Layerscape Security Fuse Processor
+
+maintainers:
+  - Michael Walle <michael@walle.cc>
+
+description: |
+  SFP is the security fuse processor which among other things provide a
+  unique identifier per part.
+
+allOf:
+  - $ref: "nvmem.yaml#"
+
+properties:
+  compatible:
+    enum:
+      - fsl,ls1028a-sfp
+
+  reg:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    efuse@1e80000 {
+        compatible = "fsl,ls1028a-sfp";
+        reg = <0x1e80000 0x8000>;
+    };
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 2/3] nvmem: add driver for Layerscape SFP (Security Fuse Processor)
  2022-02-14 11:55 [PATCH v2 0/3] nvmem: add Layerscape SFP support Michael Walle
  2022-02-14 11:55 ` [PATCH v2 1/3] dt-bindings: nvmem: add fsl,layerscape-sfp binding Michael Walle
@ 2022-02-14 11:55 ` Michael Walle
  2022-02-14 11:55 ` [PATCH v2 3/3] arm64: dts: ls1028a: add efuse node Michael Walle
  2022-02-14 11:58 ` [PATCH v2 0/3] nvmem: add Layerscape SFP support Srinivas Kandagatla
  3 siblings, 0 replies; 6+ messages in thread
From: Michael Walle @ 2022-02-14 11:55 UTC (permalink / raw)
  To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski, Shawn Guo,
	Li Yang
  Cc: devicetree, linux-kernel, linux-arm-kernel, Michael Walle

Add support for the Security Fuse Processor found on Layerscape SoCs.
This driver implements basic read access.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 drivers/nvmem/Kconfig          | 12 +++++
 drivers/nvmem/Makefile         |  2 +
 drivers/nvmem/layerscape-sfp.c | 89 ++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+)
 create mode 100644 drivers/nvmem/layerscape-sfp.c

diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index 94dd60b2654e..63792082e476 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -307,4 +307,16 @@ config NVMEM_BRCM_NVRAM
 	  This driver provides support for Broadcom's NVRAM that can be accessed
 	  using I/O mapping.
 
+config NVMEM_LAYERSCAPE_SFP
+	tristate "Layerscape SFP (Security Fuse Processor) support"
+	depends on ARCH_LAYERSCAPE || COMPILE_TEST
+	depends on HAS_IOMEM
+	help
+	  This driver provides support to read the eFuses on Freescale
+	  Layerscape SoC's. For example, the vendor provides a per part
+	  unique ID there.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called layerscape-sfp.
+
 endif
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index 4e6d877fdfaf..914358fcdb37 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -62,3 +62,5 @@ obj-$(CONFIG_NVMEM_RMEM) 	+= nvmem-rmem.o
 nvmem-rmem-y			:= rmem.o
 obj-$(CONFIG_NVMEM_BRCM_NVRAM)	+= nvmem_brcm_nvram.o
 nvmem_brcm_nvram-y		:= brcm_nvram.o
+obj-$(CONFIG_NVMEM_LAYERSCAPE_SFP)	+= nvmem-layerscape-sfp.o
+nvmem-layerscape-sfp-y		:= layerscape-sfp.o
diff --git a/drivers/nvmem/layerscape-sfp.c b/drivers/nvmem/layerscape-sfp.c
new file mode 100644
index 000000000000..e591c1511e33
--- /dev/null
+++ b/drivers/nvmem/layerscape-sfp.c
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Layerscape SFP driver
+ *
+ * Copyright (c) 2022 Michael Walle <michael@walle.cc>
+ *
+ */
+
+#include <linux/device.h>
+#include <linux/io.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/nvmem-provider.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+
+#define LAYERSCAPE_SFP_OTP_OFFSET	0x0200
+
+struct layerscape_sfp_priv {
+	void __iomem *base;
+};
+
+struct layerscape_sfp_data {
+	int size;
+};
+
+static int layerscape_sfp_read(void *context, unsigned int offset, void *val,
+			       size_t bytes)
+{
+	struct layerscape_sfp_priv *priv = context;
+
+	memcpy_fromio(val, priv->base + LAYERSCAPE_SFP_OTP_OFFSET + offset,
+		      bytes);
+
+	return 0;
+}
+
+static struct nvmem_config layerscape_sfp_nvmem_config = {
+	.name = "fsl-sfp",
+	.reg_read = layerscape_sfp_read,
+};
+
+static int layerscape_sfp_probe(struct platform_device *pdev)
+{
+	const struct layerscape_sfp_data *data;
+	struct layerscape_sfp_priv *priv;
+	struct nvmem_device *nvmem;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
+	priv->base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(priv->base))
+		return PTR_ERR(priv->base);
+
+	data = device_get_match_data(&pdev->dev);
+
+	layerscape_sfp_nvmem_config.size = data->size;
+	layerscape_sfp_nvmem_config.dev = &pdev->dev;
+	layerscape_sfp_nvmem_config.priv = priv;
+
+	nvmem = devm_nvmem_register(&pdev->dev, &layerscape_sfp_nvmem_config);
+
+	return PTR_ERR_OR_ZERO(nvmem);
+}
+
+static const struct layerscape_sfp_data ls1028a_data = {
+	.size = 0x88,
+};
+
+static const struct of_device_id layerscape_sfp_dt_ids[] = {
+	{ .compatible = "fsl,ls1028a-sfp", .data = &ls1028a_data },
+	{},
+};
+MODULE_DEVICE_TABLE(of, layerscape_sfp_dt_ids);
+
+static struct platform_driver layerscape_sfp_driver = {
+	.probe	= layerscape_sfp_probe,
+	.driver = {
+		.name	= "layerscape_sfp",
+		.of_match_table = layerscape_sfp_dt_ids,
+	},
+};
+module_platform_driver(layerscape_sfp_driver);
+
+MODULE_AUTHOR("Michael Walle <michael@walle.cc>");
+MODULE_DESCRIPTION("Layerscape Security Fuse Processor driver");
+MODULE_LICENSE("GPL");
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH v2 3/3] arm64: dts: ls1028a: add efuse node
  2022-02-14 11:55 [PATCH v2 0/3] nvmem: add Layerscape SFP support Michael Walle
  2022-02-14 11:55 ` [PATCH v2 1/3] dt-bindings: nvmem: add fsl,layerscape-sfp binding Michael Walle
  2022-02-14 11:55 ` [PATCH v2 2/3] nvmem: add driver for Layerscape SFP (Security Fuse Processor) Michael Walle
@ 2022-02-14 11:55 ` Michael Walle
  2022-02-21  3:51   ` Shawn Guo
  2022-02-14 11:58 ` [PATCH v2 0/3] nvmem: add Layerscape SFP support Srinivas Kandagatla
  3 siblings, 1 reply; 6+ messages in thread
From: Michael Walle @ 2022-02-14 11:55 UTC (permalink / raw)
  To: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski, Shawn Guo,
	Li Yang
  Cc: devicetree, linux-kernel, linux-arm-kernel, Michael Walle

Layerscape SoCs contain a Security Fuse Processor which is basically a
efuse controller. Add the node, so userspace can read the efuses.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
index 7d44102d9c6c..4b248cee830a 100644
--- a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
+++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
@@ -224,6 +224,17 @@ rst: syscon@1e60000 {
 			little-endian;
 		};
 
+		efuse@1e80000 {
+			compatible = "fsl,ls1028a-sfp";
+			reg = <0x0 0x1e80000 0x0 0x10000>;
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			ls1028a_uid: unique-id@1c {
+				reg = <0x1c 0x8>;
+			};
+		};
+
 		scfg: syscon@1fc0000 {
 			compatible = "fsl,ls1028a-scfg", "syscon";
 			reg = <0x0 0x1fc0000 0x0 0x10000>;
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 0/3] nvmem: add Layerscape SFP support
  2022-02-14 11:55 [PATCH v2 0/3] nvmem: add Layerscape SFP support Michael Walle
                   ` (2 preceding siblings ...)
  2022-02-14 11:55 ` [PATCH v2 3/3] arm64: dts: ls1028a: add efuse node Michael Walle
@ 2022-02-14 11:58 ` Srinivas Kandagatla
  3 siblings, 0 replies; 6+ messages in thread
From: Srinivas Kandagatla @ 2022-02-14 11:58 UTC (permalink / raw)
  To: Michael Walle, Rob Herring, Krzysztof Kozlowski, Shawn Guo, Li Yang
  Cc: devicetree, linux-kernel, linux-arm-kernel



On 14/02/2022 11:55, Michael Walle wrote:
> Add support for the Security Fuse Processor found on Layerscape
> SoCs.
> 
> changes since v1:
>   - added Rob's Rb
>   - cleaned up the include files
>   - changed the module license to only "GPL"
>   - fix indendation, split lines longer than 80c
> 
> Michael Walle (3):
>    dt-bindings: nvmem: add fsl,layerscape-sfp binding
>    nvmem: add driver for Layerscape SFP (Security Fuse Processor)

Applied 1/3 and 2/3.

dts patch has to go via respective arm soc maintainer tree.


--srini
>    arm64: dts: ls1028a: add efuse node
> 
>   .../bindings/nvmem/fsl,layerscape-sfp.yaml    | 38 ++++++++
>   .../arm64/boot/dts/freescale/fsl-ls1028a.dtsi | 11 +++
>   drivers/nvmem/Kconfig                         | 12 +++
>   drivers/nvmem/Makefile                        |  2 +
>   drivers/nvmem/layerscape-sfp.c                | 89 +++++++++++++++++++
>   5 files changed, 152 insertions(+)
>   create mode 100644 Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml
>   create mode 100644 drivers/nvmem/layerscape-sfp.c
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v2 3/3] arm64: dts: ls1028a: add efuse node
  2022-02-14 11:55 ` [PATCH v2 3/3] arm64: dts: ls1028a: add efuse node Michael Walle
@ 2022-02-21  3:51   ` Shawn Guo
  0 siblings, 0 replies; 6+ messages in thread
From: Shawn Guo @ 2022-02-21  3:51 UTC (permalink / raw)
  To: Michael Walle
  Cc: Srinivas Kandagatla, Rob Herring, Krzysztof Kozlowski, Li Yang,
	devicetree, linux-kernel, linux-arm-kernel

On Mon, Feb 14, 2022 at 12:55:29PM +0100, Michael Walle wrote:
> Layerscape SoCs contain a Security Fuse Processor which is basically a
> efuse controller. Add the node, so userspace can read the efuses.
> 
> Signed-off-by: Michael Walle <michael@walle.cc>

Applied, thanks!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-02-21  3:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14 11:55 [PATCH v2 0/3] nvmem: add Layerscape SFP support Michael Walle
2022-02-14 11:55 ` [PATCH v2 1/3] dt-bindings: nvmem: add fsl,layerscape-sfp binding Michael Walle
2022-02-14 11:55 ` [PATCH v2 2/3] nvmem: add driver for Layerscape SFP (Security Fuse Processor) Michael Walle
2022-02-14 11:55 ` [PATCH v2 3/3] arm64: dts: ls1028a: add efuse node Michael Walle
2022-02-21  3:51   ` Shawn Guo
2022-02-14 11:58 ` [PATCH v2 0/3] nvmem: add Layerscape SFP support 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).