From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=68.232.153.233 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796024347; b=DS8BzCUA5laCmho+/Qik1QdSR/TI2+o+ac/oJEvhCc9aP44l9mf7b+3UFhIsf34wSIEr ypvbBCy5W5d5hGfPG/o5zvFS7/Etj/tfCOk3kO/rXByCoqU2MPeqzNjOQUrvg0GeBOhU/ aZ5tNNjtT3DiX8W0xp2JobgTsojnawiQ1iH6trmZcUDUsoV1VKep1cKP16FiM3KsnjRzz lfAQdPeuSU3ZePD8ynO1lgDzhlqajw/7wbwNvpoJBg+HuncXD0W99plh8QE0oG0ddE4tl /EfhEyyRlu0Yq3Fidr3ZUGO1uKNDa8nIUKx9kS4IKotcLT76jO7YSxdgLwevs8cteRQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796024347; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-Amp-Result:Received:Received:Received:From:To:CC: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type; bh=gdNzC6l6sFYglnKDtQnIkvHHN/8GXJt0fkELFROILFo=; b=5VEBYTvPt3a6aYym0GPFQhY7DURm1i0hdROvvQFNteWKyJwpZ/j7TPhL2yIzgcnoNsGo FxWqjvpvcu6puOXddif2PQCuP2m4imF0IzIMzhybDjxVWe1MAlHiaQTgrkIomRsgdjG0I 73vxnaslf39CpN9ri8An33VEPJcnh4j6ABX+0WsvUIkDmvJjn/+sYJuQpjPflw4U52gRb Bhmn7LoHq9Ov8iN26hYIDpSyY/4yj9JMHkZ5W6ydGJ4u+YUn+2ydTQEE7qy35rx9kRqcM 6IHCSGlncIuRSzz19zTDiV2y6y8HC05Jz5KJ7cVYs+bmqp/cE0kzkjeciPyxJi7c7Nw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b="udV0/mSm"; arc=none smtp.remote-ip=68.232.153.233 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D039606A31C; Mon, 30 Nov 2026 07:39:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8D039606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=udV0/mSm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796024347; x=1827560347; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UZyfvGSgk7ibuO5JZ6NtvACbf3AxOKlmplmDtqbZSvs=; b=udV0/mSmwMNjz6FUa4Cx/Ik/l4ksVYpqBzxoEasZfuK0koRbTbrOAtMn G9r0pl20tsd+a6oyYUFFQnQa47g5ibkeyYMktkAouLPm9TgPV20Au4oDU P009ekyxAOsWBEUMqEVL/AAP5nZ+4an0KGa7MbIUzaSHz7DYQRMIH54CH f0GEI0nvFMTXwTegdN/pzDP4qhnLpBSkUOtAj+1pKU7Mf5e3Pfhya9pNE jeKcd/sajtrCnVCRKf1tWOzs9cYRm69cAJeam6S3wYPkQjPR8W04ugICj ajDQG+GqS1Rz1+0NEn9e+YX8Cf8Bycis7iqHRQmOVgOXrhJ0nHReEBvC3 g==; X-CSE-ConnectionGUID: CWcXplEoSSKnizoQms6Q+Q== X-CSE-MsgGUID: nFZyhYFgSsqq/QmIMNZvjg== X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="67215029" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 30 Nov 2026 00:39:06 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58; Mon, 30 Nov 2026 00:39:04 -0700 Received: from che-ll-i67131.microchip.com (10.10.85.11) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Mon, 30 Nov 2026 00:38:45 -0700 From: Manikandan Muralidharan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v11 5/8] nvmem: layouts: add Microchip/SST SFDP EUI layout driver Date: Mon, 30 Nov 2026 13:07:28 +0530 Message-ID: <784cd836a85d777f6e43653cda6524411cf78963.1796023049.git.manikandan.m@microchip.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Add an NVMEM layout that exposes the factory-programmed EUI-48 identifier from the Microchip/SST vendor SFDP parameter table (e.g. SST26VF064BEUI) as a "mac-address" cell, for use as a network MAC address. The vendor table is located at runtime via the SFDP NVMEM device (no offset in DT). The EUI-48 is stored in canonical MAC order, the 24-bit OUI followed by the 24-bit extension identifier, so the cell is exposed as-is. Binds to an "nvmem-layout" node with compatible "microchip,sst26vf-sfdp-eui". Signed-off-by: Manikandan Muralidharan --- MAINTAINERS | 6 + drivers/nvmem/layouts/Kconfig | 10 ++ drivers/nvmem/layouts/Makefile | 1 + drivers/nvmem/layouts/sst26vf-sfdp-eui.c | 158 +++++++++++++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 drivers/nvmem/layouts/sst26vf-sfdp-eui.c diff --git a/MAINTAINERS b/MAINTAINERS index 84cb98ef4c49..24b2b975ff94 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -18466,6 +18466,12 @@ F: Documentation/devicetree/bindings/sound/atmel,at91-ssc.yaml F: drivers/misc/atmel-ssc.c F: include/linux/atmel-ssc.h +MICROCHIP SST SFDP EUI NVMEM LAYOUT DRIVER +M: Manikandan Muralidharan +S: Maintained +F: Documentation/devicetree/bindings/nvmem/layouts/microchip,sst26vf-sfdp-eui.yaml +F: drivers/nvmem/layouts/sst26vf-sfdp-eui.c + Microchip Timer Counter Block (TCB) Capture Driver M: Kamel Bouhara L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) diff --git a/drivers/nvmem/layouts/Kconfig b/drivers/nvmem/layouts/Kconfig index 5e586dfebe47..855c7db530da 100644 --- a/drivers/nvmem/layouts/Kconfig +++ b/drivers/nvmem/layouts/Kconfig @@ -26,6 +26,16 @@ config NVMEM_LAYOUT_ONIE_TLV If unsure, say N. +config NVMEM_LAYOUT_SST26VF_SFDP_EUI + tristate "Microchip/SST SFDP EUI-48 layout support" + help + Say Y here if you want to expose the factory-programmed EUI-48 + identifier stored in the Microchip/SST vendor-specific SFDP parameter + table (e.g. SST26VF064BEUI) as NVMEM cells, so that network drivers + can use them as a MAC address. + + If unsure, say N. + config NVMEM_LAYOUT_U_BOOT_ENV tristate "U-Boot environment variables layout" select CRC32 diff --git a/drivers/nvmem/layouts/Makefile b/drivers/nvmem/layouts/Makefile index dd6c6c70b1a9..3f5e01e40448 100644 --- a/drivers/nvmem/layouts/Makefile +++ b/drivers/nvmem/layouts/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_NVMEM_LAYOUTS) += 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 +obj-$(CONFIG_NVMEM_LAYOUT_SST26VF_SFDP_EUI) += sst26vf-sfdp-eui.o diff --git a/drivers/nvmem/layouts/sst26vf-sfdp-eui.c b/drivers/nvmem/layouts/sst26vf-sfdp-eui.c new file mode 100644 index 000000000000..c4fdda35b64c --- /dev/null +++ b/drivers/nvmem/layouts/sst26vf-sfdp-eui.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * NVMEM layout for the factory-programmed EUI-48 identifier stored in the + * Microchip/SST vendor-specific SFDP parameter table (e.g. SST26VF064BEUI). + * + * The whole SFDP is exposed as a read-only NVMEM device by the SPI NOR core. + * This layout locates the Microchip vendor parameter table at runtime and + * registers the EUI-48 address as an NVMEM cell, so that a network driver can + * consume it as a MAC address. No offset is hardcoded in the device tree. + * + * Copyright (C) 2026 Microchip Technology Inc. and its subsidiaries + * + * Author: Manikandan Muralidharan + */ + +#include +#include +#include +#include +#include + +/* SFDP header and parameter header, as laid out on the flash. */ +struct sfdp_header { + u8 signature[4]; + u8 minor; + u8 major; + u8 nph; + u8 unused; +}; + +struct sfdp_parameter_header { + u8 id_lsb; + u8 minor; + u8 major; + u8 length; + u8 parameter_table_pointer[3]; + u8 id_msb; +}; + +#define SFDP_SIGNATURE 0x50444653U + +#define SFDP_PARAM_HEADER_ID(h) (((h)->id_msb << 8) | (h)->id_lsb) +#define SFDP_PARAM_HEADER_PTP(h) get_unaligned_le24((h)->parameter_table_pointer) + +#define SFDP_MCHP_VENDOR_ID 0x01bf + +#define SFDP_MCHP_EUI48_MARKER_OFFSET 0x60 +#define SFDP_MCHP_EUI48_MARKER 0x30 +#define SFDP_MCHP_EUI48_OFFSET 0x61 + +static int sfdp_eui_find_vendor_table(struct nvmem_device *nvmem, u32 *ptp) +{ + struct sfdp_parameter_header ph; + struct sfdp_header hdr; + int nph, i, ret; + + ret = nvmem_device_read(nvmem, 0, sizeof(hdr), &hdr); + if (ret < 0) + return ret; + + if (get_unaligned_le32(hdr.signature) != SFDP_SIGNATURE) + return -EINVAL; + + nph = hdr.nph + 1; + + for (i = 0; i < nph; i++) { + ret = nvmem_device_read(nvmem, sizeof(hdr) + i * sizeof(ph), + sizeof(ph), &ph); + if (ret < 0) + return ret; + + if (SFDP_PARAM_HEADER_ID(&ph) != SFDP_MCHP_VENDOR_ID) + continue; + + *ptp = SFDP_PARAM_HEADER_PTP(&ph); + return 0; + } + + return -ENOENT; +} + +static int sfdp_eui_add_cells(struct nvmem_layout *layout) +{ + struct nvmem_device *nvmem = layout->nvmem; + struct device *dev = &layout->dev; + struct nvmem_cell_info info = { }; + struct device_node *layout_np; + u32 base = 0; + u8 marker; + int ret; + + ret = sfdp_eui_find_vendor_table(nvmem, &base); + if (ret == -ENOENT) { + dev_dbg(dev, "no Microchip SFDP vendor table found\n"); + return 0; + } + if (ret) + return ret; + + /* The EUI-48 is present only if its marker byte is programmed. */ + ret = nvmem_device_read(nvmem, base + SFDP_MCHP_EUI48_MARKER_OFFSET, + 1, &marker); + if (ret < 0) + return ret; + if (marker != SFDP_MCHP_EUI48_MARKER) { + dev_dbg(dev, "EUI-48 not programmed (marker 0x%02x)\n", marker); + return 0; + } + + layout_np = of_nvmem_layout_get_container(nvmem); + if (!layout_np) + return -ENOENT; + + info.name = "mac-address"; + info.offset = base + SFDP_MCHP_EUI48_OFFSET; + info.bytes = ETH_ALEN; + info.np = of_get_child_by_name(layout_np, "mac-address"); + + ret = nvmem_add_one_cell(nvmem, &info); + if (ret) + of_node_put(info.np); + + of_node_put(layout_np); + + return ret; +} + +static int sfdp_eui_probe(struct nvmem_layout *layout) +{ + layout->add_cells = sfdp_eui_add_cells; + + return nvmem_layout_register(layout); +} + +static void sfdp_eui_remove(struct nvmem_layout *layout) +{ + nvmem_layout_unregister(layout); +} + +static const struct of_device_id sfdp_eui_of_match_table[] = { + { .compatible = "microchip,sst26vf-sfdp-eui" }, + {} +}; +MODULE_DEVICE_TABLE(of, sfdp_eui_of_match_table); + +static struct nvmem_layout_driver sfdp_eui_layout = { + .driver = { + .name = "microchip-sst26vf-sfdp-eui-layout", + .of_match_table = sfdp_eui_of_match_table, + }, + .probe = sfdp_eui_probe, + .remove = sfdp_eui_remove, +}; +module_nvmem_layout_driver(sfdp_eui_layout); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Manikandan Muralidharan "); +MODULE_DESCRIPTION("NVMEM layout for the EUI-48 in the Microchip/SST SFDP vendor table"); -- 2.43.0