mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Michael Walle <michael@walle.cc>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Cc: Rob Herring <robh+dt@kernel.org>, Shawn Guo <shawnguo@kernel.org>,
	Li Yang <leoyang.li@nxp.com>
Subject: Re: [PATCH v1 2/3] nvmem: add driver for Layerscape SFP (Security Fuse Processor)
Date: Mon, 14 Feb 2022 10:58:56 +0000	[thread overview]
Message-ID: <8e718e04-5abe-0cb9-c8db-384f3604ad2a@linaro.org> (raw)
In-Reply-To: <20220127163728.3650648-3-michael@walle.cc>



On 27/01/2022 16:37, Michael Walle wrote:
> 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>
minor comments below.


> ---
>   drivers/nvmem/Kconfig          | 12 +++++
>   drivers/nvmem/Makefile         |  2 +
>   drivers/nvmem/layerscape-sfp.c | 91 ++++++++++++++++++++++++++++++++++
>   3 files changed, 105 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..4aa94e03d8d1
> --- /dev/null
> +++ b/drivers/nvmem/layerscape-sfp.c
> @@ -0,0 +1,91 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Layerscape SFP driver
> + *
> + * Copyright (c) 2022 Michael Walle <michael@walle.cc>
> + *
> + */
> +
> +#include <linux/clk.h>

is this required?

> +#include <linux/device.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/nvmem-provider.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/slab.h>
> +#include <linux/delay.h>

Same here.

> +
> +#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)

incorrect indention here.
> +{
> +	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 v2");
Just MODULE_LICENSE("GPL") should be good here.

--srini


  reply	other threads:[~2022-02-14 11:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 16:37 [PATCH v1 0/3] nvmem: add Layerscape SFP support Michael Walle
2022-01-27 16:37 ` [PATCH v1 1/3] dt-bindings: nvmem: add fsl,layerscape-sfp binding Michael Walle
2022-02-11 12:52   ` Rob Herring
2022-01-27 16:37 ` [PATCH v1 2/3] nvmem: add driver for Layerscape SFP (Security Fuse Processor) Michael Walle
2022-02-14 10:58   ` Srinivas Kandagatla [this message]
2022-01-27 16:37 ` [PATCH v1 3/3] arm64: dts: ls1028a: add efuse node Michael Walle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e718e04-5abe-0cb9-c8db-384f3604ad2a@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=leoyang.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@walle.cc \
    --cc=robh+dt@kernel.org \
    --cc=shawnguo@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®