Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5130127rwb; Wed, 21 Sep 2022 03:41:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Xzs6V+9B4o1+DC+DsaENYCqvMkkBxfNHOSxdCPBpn7dEg6wSNSBYl8+9hFsgo5toJSqXJ X-Received: by 2002:a17:907:9807:b0:781:feee:f87c with SMTP id ji7-20020a170907980700b00781feeef87cmr2961091ejc.101.1663756891960; Wed, 21 Sep 2022 03:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663756891; cv=none; d=google.com; s=arc-20160816; b=I28wQYUUCYlIBKQW8Q/WGa6pR7wYnSA9HGG9ISPfqi7eGVzYHTBm6K+T2wdETbf5BD UhgrMh8xbjCKEChy/NXT2ShIG2MmnA0CALv7zNp4mHR01JMTnIwev/8DyKdtr++1pCx5 0rAtUV494hkSBmVkUNMlYcwj7ztdaOG9fV3mKpXO2AV7Bwk1punu9AfNBb3trSgsmuk1 b0iNYztGFFz3Kyl6ZMS82g+/ayDPzrWISDTzXiQ+jROVezbjyx4xTQbf7Z99UTjr09fR Vob3PF375/iyQ3jBf/2UTotBaMNSDlqmJqoCO6HBwaQzX8CUDC06sR9u3240XgStQevT DnwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=DyHD1cpJLUHFIMs13MWIgjp+SJUxrqpST3FASTVSKyg=; b=DKFPlfrn22nnyVJbL1MvPqpWeP1fD3szxiJF2XOwvVD8SoeALahGlUIRLSya+riukg q6oru20WwGsQOqfX7Z7mOkseiZQjxOZ22rXYohaPjxpud2yPvhgz9TeyOOMf+4B1UR2S 786QC0ZSbW02uOz94ixwbd+PhnmYvt50Px77LvWx3bYiktqO6vguMDEWsFqMWlZpmg10 4CNEixVrSifRw6Q52S14psvtTzjS0UReqCe8YeKVF3MViGnPQqOKRU9xn//OMvzyFZBP DUJp3ttSbwRlLZYGr95jlRFVNCVETbRzkNhMVJHaCO+690nhbfzfS/BpzsBcvRuH2aid J2mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NKgx0wIh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k10-20020a1709067aca00b0073c0169863dsi1864191ejo.465.2022.09.21.03.41.06; Wed, 21 Sep 2022 03:41:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NKgx0wIh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230047AbiIUJ60 (ORCPT + 99 others); Wed, 21 Sep 2022 05:58:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229972AbiIUJ6Y (ORCPT ); Wed, 21 Sep 2022 05:58:24 -0400 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C8CD31233; Wed, 21 Sep 2022 02:58:21 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 196031BF20E; Wed, 21 Sep 2022 09:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1663754300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DyHD1cpJLUHFIMs13MWIgjp+SJUxrqpST3FASTVSKyg=; b=NKgx0wIhTPfQ5YxJxGGUmmnBRphvtN7QuHUpyH1cPD/8Ph1Qw3r+I4svJb9t8CV534EELl 3usa6Vb6KvFX6P1OoFx2BdG2IAaLed+v0IfcpsWTPkMe7cv/Q0rxMM2e+4hlpJqjG5a9TU y78/qxC74wNo3nbRqLfZAQlIeBmdm2cJWDUpXvLtNUrA6tXLuehjmubX2k/RAT2Ne5bMMQ onN/8FdpyDJ+1pEbMwqwv4B2MROBUm9XOlYifOg5FbE3cn9A7THPNKeMZJ7+Lxd4bqLtEh wf1+htFsCdXcF/B3Zh3Zzpvv3TP+5o9JqBmNWYApH9rrSzR5qW3Ch4eBYxGn8g== Date: Wed, 21 Sep 2022 11:58:13 +0200 From: Miquel Raynal To: Michael Walle Cc: Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Srinivas Kandagatla , Shawn Guo , Li Yang , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , Frank Rowand , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ahmad Fatoum , Philipp Zabel , Thomas Petazzoni , Robert Marko Subject: Re: [PATCH v2 00/20] nvmem: core: introduce NVMEM layouts Message-ID: <20220921115813.208ff789@xps-13> In-Reply-To: <20220901221857.2600340-1-michael@walle.cc> References: <20220901221857.2600340-1-michael@walle.cc> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michael, Srinivas, + Thomas and Robert michael@walle.cc wrote on Fri, 2 Sep 2022 00:18:37 +0200: > 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/ >=20 >=20 > 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. >=20 > 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). >=20 > 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. Plea= se > note, that this change is only compile-time tested. These layouts are an excellent idea. I actually have a new use case for them. In modern Ethernet switches which follow the ONIE standard [1] there is an nvmem device which contains a standardized type-length-value array with many information about manufacturing and mac addresses. There is no "static" pattern there and anyway so many possible entries that it would be very tedious to list all of them in the bindings, as each manufacturer chooses what it want to export on each of its devices (although reading the data sequentially and extracting the cells is rather straightforward). Moreover, the specification [1] does not define any storage device type, so it can be eg. an MTD device or an EEPROM. Having an nvmem device provider separated from the nvmem cells provider makes complete sense, the "layout" drivers idea proposed by Michael seem to be a perfect fit. Srinivas, can you give us an update on what you think about this series (not a commitment, just how you feel it overall)? Michael, is there a v3 in preparation? I'll try to write something on top of your v2 otherwise. > You can also have cells which have no static offset, like the > ones in an u-boot environment. The last patches will convert the current > u-boot environment driver to a NVMEM layout and lifting the restriction > that it only works with mtd devices. But as it will change the required > compatible strings, it is marked as RFC for now. It also needs to have > its device tree schema update which is left out here. These two patches > are not expected to be applied, but rather to show another example of > how to use the layouts. Actually I think these two matches make complete sense, right now one can only use the u-boot-env cells if the environment is stored in an mtd device, of course this covers many cases but not all of them and it would be really nice to have this first layout example merged, not only on the mailing list. > For now, the layouts are selected by a specific compatible string in a > device tree. E.g. the VPD on the kontron sl28 do (within a SPI flash node= ): > compatible =3D "kontron,sl28-vpd", "user-otp"; > or if you'd use the u-boot environment (within an MTD patition): > compatible =3D "u-boot,env", "nvmem"; >=20 > The "user-otp" (or "nvmem") will lead to a NVMEM device, the > "kontron,sl28-vpd" (or "u-boot,env") will then apply the specific layout > on top of the NVMEM device. Thanks, Miqu=C3=A8l