From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 DBD9130E828 for ; Tue, 5 May 2026 08:42:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777970562; cv=none; b=lAzka+whfPIennWObUfqbDWfpIAcew/FXJmNnEaSZJbkqXeZReKyJ660tkk220cFFC7rdG1grNQAyZwlkk26HQHSUDLqVhylZjuZgqze6RZqhxegljbc0v5jcMK7So3qovZrZ4vULIlmJzow08uC/Yja4OSa0YDSHjyblvG9Elw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777970562; c=relaxed/simple; bh=mQLaLtGcPN3Jk+ZXO7UFbF5Rcf1yuEQ0alqkh3Xhiuo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=S73qgj86J0NiQZQ/Xjq+EKWVjmmEpC+L/p7GnO8kl+sNRmf53J6BdO8ysK9fUA8QCta3EdVg0ul5Go5ZTgQIDEbHrL2xlvmP2M0AAwGVQi12aLtvnZAdPwv0+AWZuCkQwgBq7SyYvMvzrwYaCkfTON5NyWqkHwDgj8SBMcYaabU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=aZnkfxLO; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="aZnkfxLO" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 5A23B1A3526 for ; Tue, 5 May 2026 08:42:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 27B656053C; Tue, 5 May 2026 08:42:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id EDD8811AD0198; Tue, 5 May 2026 10:42:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777970557; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding; bh=ZzfYjRolzEkZQv70gjfMDXaf18qHVjq2r5Q1/80/6qs=; b=aZnkfxLOrgc/svyGpo7n3DGFj6A7JhZsQY9G3DbFapiCydNOTlH9WqAkOlMY8Ew2huWBj7 yFrBIzGjK61zAAdizKn27LLf70haFsRUEVbtiS5qsXs2qrwfCRVbZ0CdM+C1wLorDr9tTS u5LH3UlGF2v77SD6pcSHqJSv5VLZcF7QDHtuo6Tu/Kc9sHbnoAOpneEe+0Zt0BJRE6F1Ts Cy9UWueX9Km7tKavKq5Hs82iMfDQWrNIpakv3qaGHgVRhSlV2YKNCvmkv7NnoXTLNMZXyn 4p/oz48+yLA5I99yphuY8jMriXsZI6KCSInLSyIPWs2QmNjmnF1cyGn4YAD8Cg== From: Mathieu Dubois-Briand Date: Tue, 05 May 2026 10:42:10 +0200 Subject: [PATCH] nvmem: layouts: Add fixed-layout driver Precedence: bulk X-Mailing-List: linux-kernel@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: <20260505-mathieu-nvmem-fixed-layout-v1-1-7f6ecbce108d@bootlin.com> X-B4-Tracking: v=1; b=H4sIAGGt+WkC/xXM0QpAMBSA4VfRuXbqWCx5FbkYzjhlow2RvLu5/ PrrfyByEI7QZA8EPiXK6hOKPINhNn5ilDEZFClNFZXozD4LH+hPxw6tXDziYu712FGVg7Z1RdR bDWmwBf77P2+79/0A3t4Lx2wAAAA= X-Change-ID: 20260504-mathieu-nvmem-fixed-layout-24c6f8500bf6 To: Srinivas Kandagatla Cc: Miquel Raynal , =?utf-8?q?Gr=C3=A9gory_Clement?= , Thomas Petazzoni , linux-kernel@vger.kernel.org, Mathieu Dubois-Briand X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777970556; l=7013; i=mathieu.dubois-briand@bootlin.com; s=20241219; h=from:subject:message-id; bh=mQLaLtGcPN3Jk+ZXO7UFbF5Rcf1yuEQ0alqkh3Xhiuo=; b=4vFB+sW95tOLT+dQVFrNm0+ELq7/6vEDZwz0+32PMVJhaJAMXbG9Gl6tjaBooE2IR3eM2PVU2 x06AdjLotRbAECRPyCjGU4EsAd4JVvjPGYQbc8rgkkgXe7eLea6oKQy X-Developer-Key: i=mathieu.dubois-briand@bootlin.com; a=ed25519; pk=1PVTmzPXfKvDwcPUzG0aqdGoKZJA3b9s+3DqRlm0Lww= X-Last-TLS-Session-Version: TLSv1.3 Current implementation isn't working well when device tree nodes have a phandle on a fixed-layout nvmem node. As the fixed layout is handled in nvmem core, no driver is ever associated with the layout, and the device consumer driver probe is deferred indefinitely. Remove the specific handling of fixed-layout and add a layout driver. This makes the fixed-layout similar to all other layouts, fixing the whole issue. Signed-off-by: Mathieu Dubois-Briand --- MAINTAINERS | 5 ++++ drivers/nvmem/core.c | 23 +--------------- drivers/nvmem/layouts.c | 11 -------- drivers/nvmem/layouts/Makefile | 1 + drivers/nvmem/layouts/fixed-layout.c | 52 ++++++++++++++++++++++++++++++++++++ include/linux/nvmem-provider.h | 7 +++++ 6 files changed, 66 insertions(+), 33 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 882214b0e7db..c48c4e129736 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10018,6 +10018,11 @@ F: drivers/base/firmware_loader/ F: rust/kernel/firmware.rs F: include/linux/firmware.h +FIXED-LAYOUT NVMEM LAYOUT DRIVER +M: Mathieu Dubois-Briand +S: Maintained +F: drivers/nvmem/layouts/fixed-layout.c + FLEXTIMER FTM-QUADDEC DRIVER M: Patrick Havelange L: linux-iio@vger.kernel.org diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 311cb2e5a5c0..0ec4924c4bda 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -786,7 +786,7 @@ static int nvmem_validate_keepouts(struct nvmem_device *nvmem) return 0; } -static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np) +int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np) { struct device *dev = &nvmem->dev; const __be32 *addr; @@ -840,23 +840,6 @@ static int nvmem_add_cells_from_legacy_of(struct nvmem_device *nvmem) return nvmem_add_cells_from_dt(nvmem, nvmem->dev.of_node); } -static int nvmem_add_cells_from_fixed_layout(struct nvmem_device *nvmem) -{ - struct device_node *layout_np; - int err = 0; - - layout_np = of_nvmem_layout_get_container(nvmem); - if (!layout_np) - return 0; - - if (of_device_is_compatible(layout_np, "fixed-layout")) - err = nvmem_add_cells_from_dt(nvmem, layout_np); - - of_node_put(layout_np); - - return err; -} - int nvmem_layout_register(struct nvmem_layout *layout) { int ret; @@ -1005,10 +988,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) goto err_remove_cells; } - rval = nvmem_add_cells_from_fixed_layout(nvmem); - if (rval) - goto err_remove_cells; - dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name); rval = device_add(&nvmem->dev); diff --git a/drivers/nvmem/layouts.c b/drivers/nvmem/layouts.c index b90584e1b99e..07a34be9669c 100644 --- a/drivers/nvmem/layouts.c +++ b/drivers/nvmem/layouts.c @@ -125,11 +125,6 @@ static int nvmem_layout_create_device(struct nvmem_device *nvmem, return 0; } -static const struct of_device_id of_nvmem_layout_skip_table[] = { - { .compatible = "fixed-layout", }, - {} -}; - static int nvmem_layout_bus_populate(struct nvmem_device *nvmem, struct device_node *layout_dn) { @@ -142,12 +137,6 @@ static int nvmem_layout_bus_populate(struct nvmem_device *nvmem, return 0; } - /* Fixed layouts are parsed manually somewhere else for now */ - if (of_match_node(of_nvmem_layout_skip_table, layout_dn)) { - pr_debug("%s() - skipping %pOF node\n", __func__, layout_dn); - return 0; - } - if (of_node_check_flag(layout_dn, OF_POPULATED_BUS)) { pr_debug("%s() - skipping %pOF, already populated\n", __func__, layout_dn); diff --git a/drivers/nvmem/layouts/Makefile b/drivers/nvmem/layouts/Makefile index 4940c9db0665..fbc195aa382c 100644 --- a/drivers/nvmem/layouts/Makefile +++ b/drivers/nvmem/layouts/Makefile @@ -3,6 +3,7 @@ # Makefile for nvmem layouts. # +obj-y += fixed-layout.o obj-$(CONFIG_NVMEM_LAYOUT_SL28_VPD) += sl28vpd.o obj-$(CONFIG_NVMEM_LAYOUT_ONIE_TLV) += onie-tlv.o obj-$(CONFIG_NVMEM_LAYOUT_U_BOOT_ENV) += u-boot-env.o diff --git a/drivers/nvmem/layouts/fixed-layout.c b/drivers/nvmem/layouts/fixed-layout.c new file mode 100644 index 000000000000..e5078d72a6fc --- /dev/null +++ b/drivers/nvmem/layouts/fixed-layout.c @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright 2025 Bootlin + * + * Authors: Mathieu Dubois-Briand + */ + +#include +#include + +static int fixed_layout_add_cells(struct nvmem_layout *layout) +{ + struct device_node *np; + + np = of_nvmem_layout_get_container(layout->nvmem); + if (!np) + return -ENOENT; + + return nvmem_add_cells_from_dt(layout->nvmem, np); +} + +static int fixed_layout_probe(struct nvmem_layout *layout) +{ + layout->add_cells = fixed_layout_add_cells; + + return nvmem_layout_register(layout); +} + +static void fixed_layout_remove(struct nvmem_layout *layout) +{ + nvmem_layout_unregister(layout); +} + +static const struct of_device_id fixed_layout_of_match_table[] = { + { .compatible = "fixed-layout", }, + {}, +}; + +static struct nvmem_layout_driver fixed_layout_layout = { + .driver = { + .name = "fixed-layout", + .of_match_table = fixed_layout_of_match_table, + }, + .probe = fixed_layout_probe, + .remove = fixed_layout_remove, +}; +module_nvmem_layout_driver(fixed_layout_layout); + +MODULE_AUTHOR("Mathieu Dubois-Briand"); +MODULE_LICENSE("GPL"); +MODULE_DEVICE_TABLE(of, fixed_layout_of_match_table); +MODULE_DESCRIPTION("NVMEM fixed-layout driver"); diff --git a/include/linux/nvmem-provider.h b/include/linux/nvmem-provider.h index f3b13da78aac..e7eaa9a89b8b 100644 --- a/include/linux/nvmem-provider.h +++ b/include/linux/nvmem-provider.h @@ -176,6 +176,7 @@ int nvmem_add_one_cell(struct nvmem_device *nvmem, int nvmem_layout_register(struct nvmem_layout *layout); void nvmem_layout_unregister(struct nvmem_layout *layout); +int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_node *np); #define nvmem_layout_driver_register(drv) \ __nvmem_layout_driver_register(drv, THIS_MODULE) @@ -214,6 +215,12 @@ static inline int nvmem_layout_register(struct nvmem_layout *layout) static inline void nvmem_layout_unregister(struct nvmem_layout *layout) {} +static inline int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, + struct device_node *np) +{ + return -EOPNOTSUPP; +} + #endif /* CONFIG_NVMEM */ #if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF) --- base-commit: 7fd2df204f342fc17d1a0bfcd474b24232fb0f32 change-id: 20260504-mathieu-nvmem-fixed-layout-24c6f8500bf6 Best regards, -- Mathieu Dubois-Briand