Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1526396pxb; Wed, 2 Feb 2022 07:00:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwL6qmEKDMha7ucvgNztLhywW2GJfc5SsD4zx2HO2yWkSENik5PU7x9aE5dHfPLbyzUg/2a X-Received: by 2002:a50:ef18:: with SMTP id m24mr30383196eds.297.1643814034804; Wed, 02 Feb 2022 07:00:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643814034; cv=none; d=google.com; s=arc-20160816; b=NV9IurAYPY5Htv3OS7bCBa/qRIq925v+mfifvEdjvq4jgT3foMxRnXfeAWaOPZ/9/q yg0lpNvQJCYXIdO2Tl0WLKA61C0FLGPLvsovS9ep14IoTurkhzBpMfoqRgfXGKD+7P4O KpCkliqk6ph78ObZ6LxwYLP/rYVZAynUuzBqzhz7YeMF2b5Z1lZx9JHF0CbmHbwOvNBR mvfErGeY3LJ94ng9+AdvUSVqyZ1hmAqTp1r02F3tVj0Fbx1OU3iZ5lPQg8gHNgs0pSXH DTjE5MOh1WCu7uXpmcaTyPYcpyhLAzbmCu4CAd7Vuii1rdC+8eP2ZZqsWga2op576XCl eFhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version; bh=bSvaRQWVmd4Ve9dyTUMjweneKpw7yI+Vju6tBD2S/LE=; b=DJIbYHYnjXGul6pT5kS7fFVW6lPedVJcOF98beL4aoG58ZMn8juWSdQ3dt2ME7byft TnuraC0ygIqORRLvenK8ki8IaNJCZ/O4z8q1KAEhLRT8oveKefz8PyUWugd07MdZEnY0 mFJerWryPaOwEbLuC7PiejgMZKOT6DKL70NjrQ6qhkoaxqg5Zvqq9patYICVQqzCYdNz OkD1d1qUwemtjB6zj4Kr3k/MLujFCI/1ls7Pku7e5nwlurs3/UpZRqHpSNqI3QzDskmS aFbg2nX5cFql6lWw2431Ntb887WFBAX20gcUYikFPPDxbBXrVgjPhTz+0PmQq2GQvbxJ AbPA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16si14581487edz.46.2022.02.02.07.00.09; Wed, 02 Feb 2022 07:00:34 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242368AbiBATTI (ORCPT + 99 others); Tue, 1 Feb 2022 14:19:08 -0500 Received: from 7.mo550.mail-out.ovh.net ([87.98.158.110]:34015 "EHLO 7.mo550.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242348AbiBATTG (ORCPT ); Tue, 1 Feb 2022 14:19:06 -0500 X-Greylist: delayed 8966 seconds by postgrey-1.27 at vger.kernel.org; Tue, 01 Feb 2022 14:19:06 EST Received: from player687.ha.ovh.net (unknown [10.110.115.188]) by mo550.mail-out.ovh.net (Postfix) with ESMTP id 6966621F5C for ; Tue, 1 Feb 2022 16:49:37 +0000 (UTC) Received: from RCM-web6.webmail.mail.ovh.net (ip-194-187-74-233.konfederacka.maverick.com.pl [194.187.74.233]) (Authenticated sender: rafal@milecki.pl) by player687.ha.ovh.net (Postfix) with ESMTPSA id 9168F26E9FF01; Tue, 1 Feb 2022 16:49:14 +0000 (UTC) MIME-Version: 1.0 Date: Tue, 01 Feb 2022 17:49:14 +0100 From: =?UTF-8?Q?Rafa=C5=82_Mi=C5=82ecki?= To: Rob Herring , Michael Walle Cc: =?UTF-8?Q?Rafa=C5=82_Mi=C5=82ecki?= , Srinivas Kandagatla , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Shawn Guo , Li Yang , Frank Rowand , "David S . Miller" , Jakub Kicinski , Ansuel Smith , Andrew Lunn , Florian Fainelli , Hauke Mehrtens Subject: Re: [PATCH REBASED 2/2] dt-bindings: nvmem: cells: add MAC address cell In-Reply-To: References: <20220125180114.12286-1-zajec5@gmail.com> <20220126070745.32305-1-zajec5@gmail.com> <20220126070745.32305-2-zajec5@gmail.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <1dd3522d9c7cfcb40f4f8198d4d35118@milecki.pl> X-Sender: rafal@milecki.pl X-Originating-IP: 194.187.74.233 X-Webmail-UserID: rafal@milecki.pl Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 7251076875513539502 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvvddrgeefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpeggfffhvffujghffgfkgihitgfgsehtkehjtddtreejnecuhfhrohhmpeftrghfrghlpgfoihhlvggtkhhiuceorhgrfhgrlhesmhhilhgvtghkihdrphhlqeenucggtffrrghtthgvrhhnpedugeeluefgffekfeehieehvdfgffehtdettefffeekieeijeelhfelvedvgfevtdenucffohhmrghinhepuggvvhhitggvthhrvggvrdhorhhgpdhkvghrnhgvlhdrohhrghenucfkpheptddrtddrtddrtddpudelgedrudekjedrjeegrddvfeefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpohhuthdphhgvlhhopehplhgrhigvrheikeejrdhhrgdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomheprhgrfhgrlhesmhhilhgvtghkihdrphhlpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhg Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-02-01 16:55, Rob Herring wrote: > On Wed, Jan 26, 2022 at 08:07:45AM +0100, Rafał Miłecki wrote: >> From: Rafał Miłecki >> >> This adds support for describing details of NVMEM cell containing MAC >> address. Those are often device specific and could be nicely stored in >> DT. >> >> Initial documentation includes support for describing: >> 1. Cell data format (e.g. Broadcom's NVRAM uses ASCII to store MAC) >> 2. Reversed bytes flash (required for i.MX6/i.MX7 OCOTP support) >> 3. Source for multiple addresses (very common in home routers) >> >> Signed-off-by: Rafał Miłecki >> --- >> .../bindings/nvmem/cells/mac-address.yaml | 94 >> +++++++++++++++++++ >> 1 file changed, 94 insertions(+) >> create mode 100644 >> Documentation/devicetree/bindings/nvmem/cells/mac-address.yaml >> >> diff --git >> a/Documentation/devicetree/bindings/nvmem/cells/mac-address.yaml >> b/Documentation/devicetree/bindings/nvmem/cells/mac-address.yaml >> new file mode 100644 >> index 000000000000..f8d19e87cdf0 >> --- /dev/null >> +++ b/Documentation/devicetree/bindings/nvmem/cells/mac-address.yaml >> @@ -0,0 +1,94 @@ >> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause >> +%YAML 1.2 >> +--- >> +$id: http://devicetree.org/schemas/nvmem/cells/mac-address.yaml# >> +$schema: http://devicetree.org/meta-schemas/core.yaml# >> + >> +title: NVMEM cell containing a MAC address >> + >> +maintainers: >> + - Rafał Miłecki >> + >> +properties: >> + compatible: >> + const: mac-address >> + >> + format: >> + description: | >> + Some NVMEM cells contain MAC in a non-binary format. >> + >> + ASCII should be specified if MAC is string formatted like: >> + - "01:23:45:67:89:AB" (30 31 3a 32 33 3a 34 35 3a 36 37 3a 38 >> 39 3a 41 42) >> + - "01-23-45-67-89-AB" >> + - "0123456789AB" >> + enum: >> + - ascii >> + >> + reversed-bytes: >> + type: boolean >> + description: | >> + MAC is stored in reversed bytes order. Example: >> + Stored value: AB 89 67 45 23 01 >> + Actual MAC: 01 23 45 67 89 AB >> + >> + base-address: >> + type: boolean >> + description: | >> + Marks NVMEM cell as provider of multiple addresses that are >> relative to >> + the one actually stored physically. Respective addresses can be >> requested >> + by specifying cell index of NVMEM cell. > > While a base address is common, aren't there different ways the base is > modified. > > The problem with these properties is every new variation results in a > new property and the end result is something not well designed. A > unique > compatible string, "#nvmem-cell-cells" and code to interpret the data > is > more flexible. > > For something like this to fly, I need some level of confidence this is > enough for everyone for some time (IOW, find all the previous attempts > and get those people's buy-in). You have found at least 3 cases, but I > seem to recall more. For base address I thought of dealing with base + offset only. I'm not sure what are other cases. I read few old threads: https://lore.kernel.org/lkml/20211228142549.1275412-1-michael@walle.cc/T/ https://lore.kernel.org/linux-devicetree/20211123134425.3875656-1-michael@walle.cc/ https://lore.kernel.org/all/20210414152657.12097-2-michael@walle.cc/ https://lore.kernel.org/linux-devicetree/362f1c6a8b0ec191b285ac6a604500da@walle.cc/ but didn't find other required /transformations/ except for offset and format. Even "reversed-bytes" wasn't widely discussed (or I missed that) and I just came with it on my own. If anyone knows other cases: please share so we have a complete view. I tried to Cc all previously invovled people but it seems only me and Michael remained active in this subject. If anyone knows other interested please Cc them and let us know. Rob: instead of me and Michael sending patch after patch let me try to gather solutions I can think of / I recall. Please kindly review them and let us know what do you find the cleanest. 1. NVMEM specific "compatible" string Example: partition@f00000 { compatible = "brcm,foo-cells", "nvmem-cells"; label = "calibration"; reg = <0xf00000 0x100000>; ranges = <0 0xf00000 0x100000>; #address-cells = <1>; #size-cells = <1>; mac@100 { reg = <0x100 0x6>; [optional: #nvmem-cell-cells = <1>;] }; }; A minimalistic binding proposed by Michael. DT doesn't carry any information on NVMEM cell format. Specific drivers (e.g. one handling "brcm,foo-cells") have to know how to handle specific cell. Cell handling conditional code can depend on cell node name ("mac" in above case) OR on value of "nvmem-cell-names" in cell consumer (e.g. nvmem-cell-names = "mac-address"). 2. NVMEM specific "compatible" string + cells "compatible"s Example: partition@f00000 { compatible = "brcm,foo-cells", "nvmem-cells"; label = "calibration"; reg = <0xf00000 0x100000>; ranges = <0 0xf00000 0x100000>; #address-cells = <1>; #size-cells = <1>; mac@100 { compatible = "mac-address"; reg = <0x100 0x6>; [optional: #nvmem-cell-cells = <1>;] }; }; Similar to the first case but cells that require special handling are marked with NVMEM device specific "compatible" values. Details of handling cells are still hardcoded in NVMEM driver. Different cells with compatible = "mac-address"; may be handled differencly - depending on parent NVMEM device. 3. Flexible properties in NVMEM cells Example: partition@f00000 { compatible = "brcm,foo-cells", "nvmem-cells"; label = "calibration"; reg = <0xf00000 0x100000>; ranges = <0 0xf00000 0x100000>; #address-cells = <1>; #size-cells = <1>; mac@100 { compatible = "mac-address"; reg = <0x100 0x6>; [optional: #nvmem-cell-cells = <1>;] }; mac@200 { compatible = "mac-address"; reg = <0x200 0x6>; reversed-bytes; [optional: #nvmem-cell-cells = <1>;] }; mac@300 { compatible = "mac-address"; reg = <0x300 0x11>; format = "ascii"; [optional: #nvmem-cell-cells = <1>;] }; }; This moves details into DT and requires more shared properties. It helps avoiding duplicated code for common cases (like base MAC address). It's what I proposed in the [PATCH 0/2] dt-bindings: nvmem: support describing cells