From patchwork Fri Nov 18 18:51:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 13048619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A35A2C4332F for ; Fri, 18 Nov 2022 18:55:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=lPpuipDC9OEYnwfymgL1by2p9y6fQ9Uh6LT/SELIJYU=; b=2Ac6UrAAIgZBry Z5uon1CynuZND9kSra+GFel40M8f5fYMgRAt13qF//Xxrq5tDY52Mgea6kt7HxwLlb+zy1TfiRUP8 N09n4ZN6HpGNzab5RhvNRtWNcAGOqtHT31XaLuDDhSwPxYMZeL9lHy4dTUK53TGW2KgDxkkzDtED9 9s2bGPt1ZdCJdEKBCU7azo1xqEPeUU7adPZV2jeZPe0baawUt88eUt2GyXv1nnsUtt7OaFWC5kmZC 9Gzy1mVSZ9Ht4OG+41qk/CAhsirJvQJh66y+hX9DKh1w//wGqoW9vqgc1eS6S30r1Sp66xyA8n58P 9iHHpUBKPAkUQHkSicJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ow6Ve-007L8E-E0; Fri, 18 Nov 2022 18:54:42 +0000 Received: from 0001.3ffe.de ([2a01:4f8:c0c:9d57::1] helo=mail.3ffe.de) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ow6Sc-007JP3-EQ for linux-arm-kernel@lists.infradead.org; Fri, 18 Nov 2022 18:51:36 +0000 Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id 0EE8D1382; Fri, 18 Nov 2022 19:51:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1668797485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=betImScO1GhQ0JuM7C17Rd8Gr/O3/6aRG6Ij9CO1FLg=; b=IjlwvoqX3/zayXTq8N7wnScOL/BFbSspXv/y8cNFeCEihYkE4R9O0Z1AtTTCqK7jXCJMqG xDZVRhfPD+IXD6wFmmxIzGFKx8blGh5Fq7VfWY2xFXa/en7sI7GKhwHex7RqelC5zfC+Em sU7mW72DRWomXpCZVYlTiORC2nh2n56hgpMKFbcCjJqlFQIldZP9SOz2BBLL5tTrjEfWrF Bu7OiNKGY4PSipIVExu3UM7xyKHkfE7xHq9IO2mq9oMToH1SxI1MSKIT/YrHhOLamYWdv6 +I1doAvDQcwRAe/5zZwVz8zlp4/Zzts2ExdQhX06XLQKxbPIt8jmL8Q1Uus2FA== From: Michael Walle To: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, Michael Walle Subject: [PATCH v3 00/18] nvmem: core: introduce NVMEM layouts Date: Fri, 18 Nov 2022 19:51:00 +0100 Message-Id: <20221118185118.1190044-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam: Yes X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221118_105134_763539_6D4E0952 X-CRM114-Status: GOOD ( 19.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is now the third attempt to fetch the MAC addresses from the VPD for the Kontron sl28 boards. Previous discussions can be found here: https://lore.kernel.org/lkml/20211228142549.1275412-1-michael@walle.cc/ NVMEM cells are typically added by board code or by the devicetree. But as the cells get more complex, there is (valid) push back from the devicetree maintainers to not put that handling in the devicetree. Therefore, introduce NVMEM layouts. They operate on the NVMEM device and can add cells during runtime. That way it is possible to add more complex cells than it is possible right now with the offset/length/bits description in the device tree. For example, you can have post processing for individual cells (think of endian swapping, or ethernet offset handling). The imx-ocotp driver is the only user of the global post processing hook, convert it to nvmem layouts and drop the global post pocessing hook. For now, the layouts are selected by the device tree. But the idea is that also board files or other drivers could set a layout. Although no code for that exists yet. Thanks to Miquel, the device tree bindings are already approved and merged. NVMEM layouts as modules? While possible in principle, it doesn't make any sense because the NVMEM core can't be compiled as a module. The layouts needs to be available at probe time. (That is also the reason why they get registered with subsys_initcall().) So if the NVMEM core would be a module, the layouts could be modules, too. Michael Walle (16): net: add helper eth_addr_add() of: base: add of_parse_phandle_with_optional_args() nvmem: core: fix device node refcounting nvmem: core: add an index parameter to the cell nvmem: core: move struct nvmem_cell_info to nvmem-provider.h nvmem: core: drop the removal of the cells in nvmem_add_cells() nvmem: core: add nvmem_add_one_cell() nvmem: core: use nvmem_add_one_cell() in nvmem_add_cells_from_of() nvmem: core: introduce NVMEM layouts nvmem: core: add per-cell post processing nvmem: core: allow to modify a cell before adding it nvmem: imx-ocotp: replace global post processing with layouts nvmem: cell: drop global cell_post_process nvmem: core: provide own priv pointer in post process callback nvmem: layouts: add sl28vpd layout MAINTAINERS: add myself as sl28vpd nvmem layout driver Miquel Raynal (2): nvmem: layouts: Add ONIE tlv layout driver MAINTAINERS: Add myself as ONIE tlv NVMEM layout maintainer Documentation/driver-api/nvmem.rst | 15 ++ MAINTAINERS | 12 ++ drivers/nvmem/Kconfig | 4 + drivers/nvmem/Makefile | 1 + drivers/nvmem/core.c | 281 ++++++++++++++++++++++------- drivers/nvmem/imx-ocotp.c | 34 ++-- drivers/nvmem/layouts/Kconfig | 23 +++ drivers/nvmem/layouts/Makefile | 7 + drivers/nvmem/layouts/onie-tlv.c | 249 +++++++++++++++++++++++++ drivers/nvmem/layouts/sl28vpd.c | 153 ++++++++++++++++ include/linux/etherdevice.h | 14 ++ include/linux/nvmem-consumer.h | 17 +- include/linux/nvmem-provider.h | 95 +++++++++- include/linux/of.h | 25 +++ 14 files changed, 834 insertions(+), 96 deletions(-) create mode 100644 drivers/nvmem/layouts/Kconfig create mode 100644 drivers/nvmem/layouts/Makefile create mode 100644 drivers/nvmem/layouts/onie-tlv.c create mode 100644 drivers/nvmem/layouts/sl28vpd.c