From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6A9D44A40B; Mon, 21 Sep 2026 07:50:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789977029; cv=none; b=AgUfop4VrGLxJOS+7I/QNBbbyqCJ42W6KME1+Ng5lzeI4YgfSAkJacYXFIbkS/7RWBn6t0yJdgabEpNjmO3YVgTMUOAboNEtxmL/ZB8ivtSQI0Gr5wE75/dCOj69YcV5Ew2BDA3n/3JNl2ehmS6EzsOW4lDEfU76r4odqF06/XQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789977029; c=relaxed/simple; bh=7eRTuK1J7JLSJe8eP4zoF7OjTxmSHdj6GVl84M2RdZc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oxSq1FxVAYrP/EB4TqxmjsF0ZfHGlFg/ItFEvqfiBgIi1bmXPfd0RjU1TdTUGnpElbf6oFGCeYtAt0+JJuncPrHUOvCcBW3ITN4lbpxxjAmLU/DRy0EU2tv4Fiwh7IOnUXbl2IomJKNPkjDG5lM3ZWUIVg3vOPf2BT6SKbHZLEU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gN5PTR9T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gN5PTR9T" Received: by smtp.kernel.org (Postfix) with ESMTPS id 98091C2BCFD; Mon, 21 Sep 2026 07:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1789977028; bh=7eRTuK1J7JLSJe8eP4zoF7OjTxmSHdj6GVl84M2RdZc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=gN5PTR9TY2UluQhZq6Er4ZQ2vYoqcikXshUATew7F7KEnK03vir5PuIw7iw/LH9bM M4Sg8SPSilPA0YcdkDvicaLWxRGJFz9bENe6+n3vKfGENzVwmnxXerVeiUWa3/8Gvh DgaNHhFN/MXlvdZLbZo1DwxlLeHOX1tg8A6ED5O/BLvy3+pgdZXTcS9hrree3orfoB UDtezWbhMFraEHiJaNmuLhcDzGWbDqnvSMYgcmqC/9jfKQIi0ReVrLEvQn4YzSknt0 Nvt4dBP+PExiP4MUFUjwyraMIaP6GeTw7u955NTsiG5LYhpvhkz/5EjEDayvWXuRST 93hQ8wvEV+V4Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7815CC982EE; Mon, 21 Sep 2026 07:50:28 +0000 (UTC) From: Roman Vivchar via B4 Relay Date: Mon, 21 Sep 2026 10:50:03 +0300 Subject: [PATCH v5 2/3] nvmem: add mt6323 PMIC EFUSE driver Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260921-mt6323-nvmem-v5-2-2f5d308369f0@protonmail.com> References: <20260921-mt6323-nvmem-v5-0-2f5d308369f0@protonmail.com> In-Reply-To: <20260921-mt6323-nvmem-v5-0-2f5d308369f0@protonmail.com> To: Sen Chu , Sean Wang , Macpaul Lin , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Srinivas Kandagatla , Roman Vivchar Cc: Andy Shevchenko , 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 X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1789977026; l=4983; i=rva333@protonmail.com; s=20260510; h=from:subject:message-id; bh=ah8lcn6KNr0dkMxSWN/QXud3pFB++YUj9D6tI73pyGs=; b=q+/1KuGDhhtVBOgEHlwUYKHJMl+XGPr+Xbr/3A1cBlOnOUGNffjnuGkRZ1jXRLtfDbki5VIca kDWCRxKn3sbAIZKNDiyhenzIxRkiLmc7g/3YK4GvKNWHgf5sudCwbjW X-Developer-Key: i=rva333@protonmail.com; a=ed25519; pk=zww/nWjBGoQ4POXCG0BV6fx2iuXK6jx77rsKPA5YK5Y= X-Endpoint-Received: by B4 Relay for rva333@protonmail.com/20260510 with auth_id=777 X-Original-From: Roman Vivchar Reply-To: rva333@protonmail.com From: Roman Vivchar 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 # Amazon Echo Dot (2nd Generation) Reviewed-by: Andy Shevchenko Signed-off-by: Roman Vivchar --- MAINTAINERS | 5 +++ drivers/nvmem/Kconfig | 11 ++++++ drivers/nvmem/Makefile | 2 ++ drivers/nvmem/mt6323-efuse.c | 83 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 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 +S: Maintained +F: drivers/nvmem/mt6323-efuse.c + MEDIATEK MT6735 CLOCK & RESET DRIVERS M: Yassine Oudjana 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..5e70bad9f0f9 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile @@ -53,6 +53,8 @@ obj-$(CONFIG_NVMEM_MESON_MX_EFUSE) += nvmem_meson_mx_efuse.o nvmem_meson_mx_efuse-y := meson-mx-efuse.o obj-$(CONFIG_NVMEM_MICROCHIP_OTPC) += nvmem-microchip-otpc.o nvmem-microchip-otpc-y := microchip-otpc.o +obj-$(CONFIG_NVMEM_MT6323_EFUSE) += nvmem_mt6323-efuse.o +nvmem_mt6323-efuse-y := mt6323-efuse.o obj-$(CONFIG_NVMEM_MTK_EFUSE) += nvmem_mtk-efuse.o nvmem_mtk-efuse-y := mtk-efuse.o obj-$(CONFIG_NVMEM_MXS_OCOTP) += nvmem-mxs-ocotp.o diff --git a/drivers/nvmem/mt6323-efuse.c b/drivers/nvmem/mt6323-efuse.c new file mode 100644 index 000000000000..de5e30215c22 --- /dev/null +++ b/drivers/nvmem/mt6323-efuse.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2026 Roman Vivchar + */ + +#include +#include +#include +#include +#include +#include +#include + +#include + +#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 mt6397_chip *mt6323 = dev_get_drvdata(pdev->dev.parent); + 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; + + if (!mt6323 || !mt6323->regmap) + return dev_err_probe(dev, -ENODEV, "failed to get parent\n"); + + config.dev = dev; + config.priv = mt6323->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"); -- 2.55.0