lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aK8zg3sA4csHwAHU@lizhi-Precision-Tower-5810>
Date: Wed, 27 Aug 2025 12:34:11 -0400
From: Frank Li <Frank.li@....com>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Srinivas Kandagatla <srini@...nel.org>,
	NXP S32 Linux Team <s32@....com>, linaro-s32@...aro.org,
	linux-kernel@...r.kernel.org,
	Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Subject: Re: [PATCH V2 2/3] nvmem: s32g-ocotp: Add driver for S32G OCOTP

On Tue, Aug 26, 2025 at 07:38:10PM +0300, Dan Carpenter wrote:
> From: Ciprian Costea <ciprianmarian.costea@....com>
>
> Provide access to the On Chip One-Time Programmable Controller (OCOTP)
> pages on the NXP S32G platform.
>
> Signed-off-by: Ciprian Costea <ciprianmarian.costea@....com>
> Co-developed-by: Ghennadi Procopciuc <ghennadi.procopciuc@....com>
> Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@....com>
> Co-developed-by: Larisa Grigore <larisa.grigore@....com>
> Signed-off-by: Larisa Grigore <larisa.grigore@....com>
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> ---
> v2: Add S-o-b tags for Ghennadi and Larisa.
>
>     Use keepouts instead of the s32g_map[] table.  This allows a bunch
>     of code to be deleted.
>
>     Version 1 only let one word (S32G_OCOTP_WORD_SIZE or 4) to be read
>     at a time, but now the driver allows larger reads.  Set the
>     .word_size in s32g_ocotp_nvmem_config to be 4 instead.
>
>     Krzysztof asked for some changes in the probe() function but that
>     code was deleted instead.
>
>  drivers/nvmem/Kconfig            |  10 +++
>  drivers/nvmem/Makefile           |   2 +
>  drivers/nvmem/s32g-ocotp-nvmem.c | 101 +++++++++++++++++++++++++++++++
>  3 files changed, 113 insertions(+)
>  create mode 100644 drivers/nvmem/s32g-ocotp-nvmem.c
>
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index 0bdd86d74f62..55016f803492 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -240,6 +240,16 @@ config NVMEM_NINTENDO_OTP
>  	  This driver can also be built as a module. If so, the module
>  	  will be called nvmem-nintendo-otp.
>
...

> +
> +static int s32g_ocotp_read(void *context, unsigned int offset,
> +			    void *val, size_t bytes)
> +{
> +	struct s32g_ocotp_priv *s32g_data = context;
> +	u32 *dst = val;
> +
> +	while (bytes >= sizeof(u32)) {
> +		*dst++ = ioread32(s32g_data->base + offset);
> +
> +		bytes -= sizeof(u32);
> +		offset += sizeof(u32);
> +	}

readsw() ?

> +
> +	return 0;
> +}
> +
> +static struct nvmem_keepout s32g_keepouts[] = {
> +	{ .start = 0,   .end = 520 },
> +	{ .start = 540, .end = 564 },
> +	{ .start = 596, .end = 664 },
> +	{ .start = 668, .end = 676 },
> +	{ .start = 684, .end = 732 },
> +	{ .start = 744, .end = 864 },
> +	{ .start = 908, .end = 924 },
> +	{ .start = 928, .end = 936 },
> +	{ .start = 948, .end = 964 },
> +	{ .start = 968, .end = 976 },
> +	{ .start = 984, .end = 1012 },
> +};
> +
> +static struct nvmem_config s32g_ocotp_nvmem_config = {
> +	.name = "s32g-ocotp",
> +	.add_legacy_fixed_of_cells = true,
> +	.read_only = true,
> +	.word_size = 4,
> +	.reg_read = s32g_ocotp_read,
> +	.keepout = s32g_keepouts,
> +	.nkeepout = ARRAY_SIZE(s32g_keepouts),
> +};
> +
> +static const struct of_device_id ocotp_of_match[] = {
> +	{ .compatible = "nxp,s32g2-ocotp" },
> +	{ /* sentinel */ }
> +};
> +
> +static int s32g_ocotp_probe(struct platform_device *pdev)
> +{
> +	struct s32g_ocotp_priv *s32g_data;
> +	struct device *dev = &pdev->dev;
> +	struct nvmem_device *nvmem;
> +	struct resource *res;
> +
> +	s32g_data = devm_kzalloc(dev, sizeof(*s32g_data), GFP_KERNEL);
> +	if (!s32g_data)
> +		return -ENOMEM;
> +
> +	s32g_data->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
> +	if (IS_ERR(s32g_data->base)) {
> +		dev_err(dev, "Cannot map OCOTP device.\n");
> +		return PTR_ERR(s32g_data->base);

return dev_err_probe(dev, PTR_ERR(s32g_data->base), ...)

Frank

> +	}
> +
> +	s32g_data->dev = dev;
> +	s32g_ocotp_nvmem_config.dev = dev;
> +	s32g_ocotp_nvmem_config.priv = s32g_data;
> +	s32g_ocotp_nvmem_config.size = resource_size(res);
> +
> +	nvmem = devm_nvmem_register(dev, &s32g_ocotp_nvmem_config);
> +
> +	return PTR_ERR_OR_ZERO(nvmem);
> +}
> +
> +static struct platform_driver s32g_ocotp_driver = {
> +	.probe = s32g_ocotp_probe,
> +	.driver = {
> +		.name = "s32g-ocotp",
> +		.of_match_table = ocotp_of_match,
> +	},
> +};
> +module_platform_driver(s32g_ocotp_driver);
> +MODULE_AUTHOR("NXP");
> +MODULE_DESCRIPTION("S32G OCOTP driver");
> +MODULE_LICENSE("GPL");
> --
> 2.47.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ