From: Sascha Hauer <sha@pengutronix.de>
To: Jules Maselbas <jmaselbas@kalray.eu>
Cc: barebox@lists.infradead.org,
Clement Leger <clement.leger@bootlin.com>,
Louis Morhet <lmorhet@kalray.eu>, Luc Michel <lmichel@kalray.eu>,
Yann Sionneau <ysionneau@kalray.eu>,
Clement Leger <cleger@kalray.eu>
Subject: Re: [PATCH 08/13] nvmem: add kvx otp non volatile regbank support
Date: Mon, 17 Jan 2022 09:24:19 +0100 [thread overview]
Message-ID: <20220117082419.GA1121@pengutronix.de> (raw)
In-Reply-To: <20220114165208.9980-9-jmaselbas@kalray.eu>
On Fri, Jan 14, 2022 at 05:52:07PM +0100, Jules Maselbas wrote:
> From: Clement Leger <cleger@kalray.eu>
>
> Backport Linux driver to barebox to access nvmem.
>
> Signed-off-by: Clement Leger <cleger@kalray.eu>
> Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
> ---
> drivers/nvmem/Kconfig | 7 +++
> drivers/nvmem/Makefile | 3 ++
> drivers/nvmem/kvx-otp-nv.c | 99 ++++++++++++++++++++++++++++++++++++++
> 3 files changed, 109 insertions(+)
> create mode 100644 drivers/nvmem/kvx-otp-nv.c
>
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index 07320101b8..3624cc64b6 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -66,6 +66,13 @@ config STM32_BSEC
> This adds support for the STM32 OTP controller. Reads and writes
> to will go to the shadow RAM, not the OTP fuses themselvers.
>
> +config KVX_OTP_NV
> + tristate "kalray KVX OTP Non volatile regs Support"
> + depends on KVX
> + help
> + This is a simple driver to dump specified values of KVX OTP non
> + volatile regs.
> +
> config STARFIVE_OTP
> tristate "Starfive OTP Supprot"
> depends on SOC_STARFIVE
> diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
> index cd970aaea1..81629ddb27 100644
> --- a/drivers/nvmem/Makefile
> +++ b/drivers/nvmem/Makefile
> @@ -24,4 +24,7 @@ nvmem_eeprom_93xx46-y := eeprom_93xx46.o
> obj-$(CONFIG_STM32_BSEC) += nvmem_bsec.o
> nvmem_bsec-y := bsec.o
>
> +obj-$(CONFIG_KVX_OTP_NV) += nvmem-kvx-otp-nv.o
> +nvmem-kvx-otp-nv-y := kvx-otp-nv.o
> +
> obj-$(CONFIG_STARFIVE_OTP) += starfive-otp.o
> diff --git a/drivers/nvmem/kvx-otp-nv.c b/drivers/nvmem/kvx-otp-nv.c
> new file mode 100644
> index 0000000000..f997f8a63b
> --- /dev/null
> +++ b/drivers/nvmem/kvx-otp-nv.c
> @@ -0,0 +1,99 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2020 Kalray Inc., Clément Léger
> + */
> +
> +#include <common.h>
> +#include <driver.h>
> +#include <malloc.h>
> +#include <xfuncs.h>
> +#include <errno.h>
> +#include <init.h>
> +#include <net.h>
> +#include <io.h>
> +
> +#include <linux/nvmem-provider.h>
> +
> +#define OTP_NV_ALIGN 4
> +#define OTP_NV_ALIGN_MASK (OTP_NV_ALIGN - 1)
> +
> +struct kvx_otp_nv_priv {
> + void __iomem *base;
> +};
> +
> +static int kvx_otp_nv_read(void *context, unsigned int offset,
> + void *_val, size_t bytes)
> +{
> + struct kvx_otp_nv_priv *priv = context;
> + u8 *val = _val;
> + u32 tmp, copy_size;
> + u8 skip = offset & OTP_NV_ALIGN_MASK;
> +
> + offset &= ~OTP_NV_ALIGN_MASK;
> +
> + while (bytes) {
> + tmp = readl(priv->base + offset);
> + if (skip != 0)
> + copy_size = min(OTP_NV_ALIGN - skip, (int) bytes);
> + else
> + copy_size = min(bytes, sizeof(tmp));
> +
> + memcpy(val, ((u8 *) &tmp) + skip, copy_size);
> + if (skip != 0)
> + skip = 0;
The if() here is unnecessary.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2022-01-17 8:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-14 16:51 [PATCH 00/13] kvx arch update Jules Maselbas
2022-01-14 16:52 ` [PATCH 01/13] kvx: dma: Remove arch dma_map/unmap_single Jules Maselbas
2022-01-14 16:52 ` [PATCH 02/13] kvx: Move LINUX_BOOT_PARAM_MAGIC in asm/common.h Jules Maselbas
2022-01-14 16:52 ` [PATCH 03/13] kvx: Accept LINUX_BOOT_PARAM_MAGIC as a valid magic value Jules Maselbas
2022-01-14 16:52 ` [PATCH 04/13] common: elf: add elf_load_binary Jules Maselbas
2022-01-14 17:21 ` Clément Léger
2022-01-14 17:24 ` Jules Maselbas
2022-01-14 16:52 ` [PATCH 05/13] kvx: enable FITIMAGE support Jules Maselbas
2022-01-14 16:52 ` [PATCH 06/13] clocksource: kvx: Register as postcore_platform_driver Jules Maselbas
2022-01-14 16:52 ` [PATCH 07/13] watchdog: kvx: do not disable watchdog on probe Jules Maselbas
2022-01-14 16:52 ` [PATCH 08/13] nvmem: add kvx otp non volatile regbank support Jules Maselbas
2022-01-17 8:24 ` Sascha Hauer [this message]
2022-01-17 11:17 ` Jules Maselbas
2022-01-14 16:52 ` [PATCH 09/13] kvx: add kvx_sfr_field_val Jules Maselbas
2022-01-14 16:54 ` [PATCH 10/13] drivers: add soc hierarchy properly Jules Maselbas
2022-01-14 16:54 ` [PATCH 11/13] soc: add kvx_socinfo driver Jules Maselbas
2022-01-14 16:54 ` [PATCH 12/13] kvx: Update defconfig Jules Maselbas
2022-01-14 16:54 ` [PATCH 13/13] kvx: dts: Update k200.dts Jules Maselbas
2022-01-14 17:31 ` Clément Léger
2022-01-14 17:06 ` [PATCH 10/13] drivers: add soc hierarchy properly Ahmad Fatoum
2022-01-14 17:11 ` Jules Maselbas
2022-01-14 17:20 ` Ahmad Fatoum
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=20220117082419.GA1121@pengutronix.de \
--to=sha@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=cleger@kalray.eu \
--cc=clement.leger@bootlin.com \
--cc=jmaselbas@kalray.eu \
--cc=lmichel@kalray.eu \
--cc=lmorhet@kalray.eu \
--cc=ysionneau@kalray.eu \
/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