mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srini@kernel.org>
To: rva333@protonmail.com, Sen Chu <sen.chu@mediatek.com>,
	Sean Wang <sean.wang@mediatek.com>,
	Macpaul Lin <macpaul.lin@mediatek.com>,
	Lee Jones <lee@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Srinivas Kandagatla <srini@kernel.org>
Cc: Andy Shevchenko <andy@kernel.org>,
	linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	Ben Grisdale <bengris32@protonmail.ch>
Subject: Re: [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver
Date: Mon, 14 Sep 2026 23:08:36 +0100	[thread overview]
Message-ID: <170bcc15-38fc-47cb-89f5-8fe7411111aa@kernel.org> (raw)
In-Reply-To: <20260911-mt6323-nvmem-v4-2-626dd17531dc@protonmail.com>



On 9/11/26 7:33 AM, Roman Vivchar via B4 Relay wrote:
> From: Roman Vivchar <rva333@protonmail.com>
> 
> Add support for the EFUSE controller found in the Mediatek MT6323 PMIC.
> The MT6323 EFUSE stores 24 bytes of hardware-related data, such as
> thermal sensor calibration values.
> 
> Tested-by: Ben Grisdale <bengris32@protonmail.ch> # Amazon Echo Dot (2nd Generation)
> Reviewed-by: Andy Shevchenko <andy@kernel.org>
> Signed-off-by: Roman Vivchar <rva333@protonmail.com>
> ---
>  MAINTAINERS                  |  5 +++
>  drivers/nvmem/Kconfig        | 11 ++++++
>  drivers/nvmem/Makefile       |  2 ++
>  drivers/nvmem/mt6323-efuse.c | 84 ++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 102 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 3a19da74d00c..6ec0ed61260c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -16718,6 +16718,11 @@ S:	Maintained
>  F:	drivers/iio/adc/mt6323-auxadc.c
>  F:	include/dt-bindings/iio/adc/mediatek,mt6323-auxadc.h
>  
> +MEDIATEK MT6323 PMIC NVMEM DRIVER
> +M:	Roman Vivchar <rva333@protonmail.com>
> +S:	Maintained
> +F:	drivers/nvmem/mt6323-efuse.c

placement is in wrong order, same in make file too.
> +
>  MEDIATEK MT6735 CLOCK & RESET DRIVERS
>  M:	Yassine Oudjana <y.oudjana@protonmail.com>
>  L:	linux-clk@vger.kernel.org
> diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
> index c36c2a4c2a0b..5115c46beb97 100644
> --- a/drivers/nvmem/Kconfig
> +++ b/drivers/nvmem/Kconfig
> @@ -328,6 +328,17 @@ config NVMEM_MTK_EFUSE
>  	  This driver can also be built as a module. If so, the module
>  	  will be called efuse-mtk.
>  
> +config NVMEM_MT6323_EFUSE
> +	tristate "MediaTek MT6323 PMIC EFUSE support"
> +	depends on ARCH_MEDIATEK || COMPILE_TEST
> +	depends on MFD_MT6397
> +	help
> +	  This is a driver to access hardware related data like sensor
> +	  calibration, etc.
> +
> +	  This driver can also be built as a module. If so, the module
> +	  will be called efuse-mt6323.
> +
>  config NVMEM_MXS_OCOTP
>  	tristate "Freescale MXS On-Chip OTP Memory Support"
>  	depends on ARCH_MXS || COMPILE_TEST
> diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
> index 2bbfb9ff1885..626936e4dfdd 100644
> --- a/drivers/nvmem/Makefile
> +++ b/drivers/nvmem/Makefile
> @@ -55,6 +55,8 @@ obj-$(CONFIG_NVMEM_MICROCHIP_OTPC)	+= nvmem-microchip-otpc.o
>  nvmem-microchip-otpc-y			:= microchip-otpc.o
>  obj-$(CONFIG_NVMEM_MTK_EFUSE)		+= nvmem_mtk-efuse.o
>  nvmem_mtk-efuse-y			:= mtk-efuse.o
> +obj-$(CONFIG_NVMEM_MT6323_EFUSE)		+= nvmem_mt6323-efuse.o
> +nvmem_mt6323-efuse-y			:= mt6323-efuse.o
>  obj-$(CONFIG_NVMEM_MXS_OCOTP)		+= nvmem-mxs-ocotp.o
>  nvmem-mxs-ocotp-y			:= mxs-ocotp.o
>  obj-$(CONFIG_NVMEM_NINTENDO_OTP)	+= nvmem-nintendo-otp.o
> diff --git a/drivers/nvmem/mt6323-efuse.c b/drivers/nvmem/mt6323-efuse.c
> new file mode 100644
> index 000000000000..6f6f1cdc2f38
> --- /dev/null
> +++ b/drivers/nvmem/mt6323-efuse.c
> @@ -0,0 +1,84 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2026 Roman Vivchar <rva333@protonmail.com>
> + */
> +
> +#include <linux/err.h>
> +#include <linux/module.h>
> +#include <linux/nvmem-provider.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +#include <linux/types.h>
> +
> +#include <linux/mfd/mt6323/registers.h>
> +
> +#define MT6323_EFUSE_DOUT_BASE	MT6323_EFUSE_DOUT_0_15
> +#define MT6323_EFUSE_SIZE	24
> +
> +static int mt6323_efuse_read(void *context, unsigned int offset, void *val,
> +			     size_t bytes)
> +{
> +	struct regmap *map = context;
> +	u16 *buf = val;
> +	u32 tmp;
> +	int ret;
> +
> +	/*
> +	 * A manual loop using regmap_read is required because PWRAP is not
> +	 * a continuous MMIO space, but rather a FSM that doesn't implement the
> +	 * necessary read callback for the regmap_read_raw and regmap_read_bulk
> +	 * functions.
> +	 */
> +	for (size_t i = 0; i < bytes; i += sizeof(*buf)) {
> +		ret = regmap_read(map, MT6323_EFUSE_DOUT_BASE + offset + i, &tmp);
> +		if (ret)
> +			return ret;
> +
> +		*buf++ = tmp;
> +	}
> +
> +	return 0;
> +}
> +
> +static int mt6323_efuse_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct nvmem_config config = {
> +		.name = "mt6323-efuse",
> +		.stride = 2,
> +		.word_size = 2,
> +		.size = MT6323_EFUSE_SIZE,
> +		.reg_read = mt6323_efuse_read,
> +	};
> +	struct nvmem_device *nvmem;
> +	struct regmap *regmap;
> +
> +	/* efuse -> mfd -> pwrap */
> +	regmap = dev_get_regmap(dev->parent->parent, NULL);
> +	if (!regmap)
> +		return dev_err_probe(dev, -ENODEV, "failed to get regmap\n");

can we be more consistent here,

how about
	struct mt6397_chip *mt6323 = dev_get_drvdata(pdev->dev.parent);

and use mt6323->regmap

like how mt6323_regulators driver does it.


> +
> +	config.dev = dev;
> +	config.priv = regmap;
> +
> +	nvmem = devm_nvmem_register(dev, &config);
> +	return PTR_ERR_OR_ZERO(nvmem);
> +}
> +
> +static const struct of_device_id mt6323_efuse_of_match[] = {
> +	{ .compatible = "mediatek,mt6323-efuse" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, mt6323_efuse_of_match);
> +
> +static struct platform_driver mt6323_efuse_driver = {
> +	.probe = mt6323_efuse_probe,
> +	.driver = {
> +		.name = "mt6323-efuse",
> +		.of_match_table = mt6323_efuse_of_match,
> +	},
> +};
> +module_platform_driver(mt6323_efuse_driver);
> +
> +MODULE_DESCRIPTION("MediaTek MT6323 PMIC EFUSE driver");
> +MODULE_LICENSE("GPL");
> 


  reply	other threads:[~2026-09-14 22:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  6:32 [PATCH v4 0/3] nvmem: add support for the MediaTek mt6323 PMIC Roman Vivchar via B4 Relay
2026-09-11  6:32 ` [PATCH v4 1/3] dt-bindings: mfd: mediatek: mt6397: add mt6323 PMIC EFUSE Roman Vivchar via B4 Relay
2026-09-11  6:33 ` [PATCH v4 2/3] nvmem: add mt6323 PMIC EFUSE driver Roman Vivchar via B4 Relay
2026-09-14 22:08   ` Srinivas Kandagatla [this message]
2026-09-15  8:11     ` Andy Shevchenko
2026-09-11  6:33 ` [PATCH v4 3/3] ARM: dts: mediatek: mt6323: add EFUSE support Roman Vivchar via B4 Relay

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=170bcc15-38fc-47cb-89f5-8fe7411111aa@kernel.org \
    --to=srini@kernel.org \
    --cc=andy@kernel.org \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=bengris32@protonmail.ch \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=macpaul.lin@mediatek.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robh@kernel.org \
    --cc=rva333@protonmail.com \
    --cc=sean.wang@mediatek.com \
    --cc=sen.chu@mediatek.com \
    /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®