From patchwork Fri Jun 16 21:30:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 13283305 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 1A3E6EB64D7 for ; Fri, 16 Jun 2023 21:31:22 +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=ZqQbAZtbHUkON3zIK2quMaMVvZzYT4dc2WYx58W7HKE=; b=2kIuZvCrTrGIFC i4oUrgJFm2czmNwU8Ft74+fYu1EehuIVCsDOYSZxegzTmywHRbD2x2aLvUvkDrXG56vEuMY3cEKVk tCv6csRC5DmvynlMILD1jqtJrhgWaaMt7a/+faZczirXQwBzx1rTiY2JHdJ/kpKiezvh9FDje2SxP JR5wP73cZDvdU3uz+SQM1pqKOap5IexA8Kj52Vvs4WSdw5EHIanWYFN65LGFQ3Ujf59tQn+gjqkYz 91g6wpi39WfPNYCP6w8d+jvnqUcskwWAC2fnezDrjy7/9VBVl4lUDT/+BVnzt0G7MwqpsxGCU0XcL QTQMPZsiDpyjhWMOEmGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qAH1y-001uUa-2P; Fri, 16 Jun 2023 21:30:54 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qAH1v-001uTk-0x; Fri, 16 Jun 2023 21:30:52 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2b4636bb22eso4139501fa.2; Fri, 16 Jun 2023 14:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686951048; x=1689543048; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=SlSbhPNbssIprDpHNOXePwMeZq9BONqa1optZho/VFA=; b=X2Oqo9eS3GakYna+Mz41cEIe+tLHSdc9nn9qX81F6dp1fe84pLTVlOKyUUKnleimWG d6G5FZPKEA9F1BJ2xInh7TSoGWeNJXcCRtD0D8y28iUNRojahSZZIvjg2ZmTegnQHZFE EtQJd7Cgbd8wALKiFqcDgijigm6JDhUtXaR9np0bIoBM0QMDappFhgj4l9yeFvXhMe2V JUYNJ6jplFilgm9wjP3yPV00CMaVIQXCjB8kYST6dwL/njBHL25N6BG2Tn95VfF0NTsF KuAadI8k7MFvjaruxjbeQq+LnTmuJaKW19E3b8vgFt6sMeANA/bYlp60TAh+gVQIyYv/ AC1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686951048; x=1689543048; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SlSbhPNbssIprDpHNOXePwMeZq9BONqa1optZho/VFA=; b=NpCgInfHC4AINrhsXkWGQU7WgXO9dTPYZiFNJbKHPbzJvYi+8emdn0+Yb+hIwJWPe7 BfKplzf4n7p0Hij27MhyJrOf1KexfYs6LW2pasMvPLJhds7aOsLpYcYcLX2YcUGefxi+ F8zqJSHoFZKsOOoykWalbaYKRr8C1XyRJ2Q89a+ma/EnnkpsDCnSwdKB6MpqsRKyAD6i ajXO/8wnQZJWmxV+9migWK9NyDvOSQmk+hG9PmACIgxLKBzO4M4qmxirCaHEy8eqFu4g VAGUqNmSeTYcWTP5SYt2FxgphI1DVqMDXGkrOHFo2VZnSvTRDN1cVXlBCVGuONNtwzlI 4LtA== X-Gm-Message-State: AC+VfDzhH/8ufdUe3JRWvlmGaiKNHIZCPpbxSilST8JYaVgWHyzryh0q W9R2oumoD7jfuZ28KwSc1xY= X-Google-Smtp-Source: ACHHUZ4AzhyGOtF7rvB9gv6YHMUR1Zu3KGBIF9HNAkK08t5zoh8CJKAb9ppOvrCPtQ5asfg4HI9Ilg== X-Received: by 2002:a2e:3306:0:b0:2b4:5b21:a94e with SMTP id d6-20020a2e3306000000b002b45b21a94emr1951020ljc.7.1686951047501; Fri, 16 Jun 2023 14:30:47 -0700 (PDT) Received: from localhost.lan (031011218106.poznan.vectranet.pl. [31.11.218.106]) by smtp.gmail.com with ESMTPSA id o18-20020a2e90d2000000b002b445237affsm1060608ljg.58.2023.06.16.14.30.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jun 2023 14:30:46 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Miquel Raynal , Christian Marangi , devicetree@vger.kernel.org, linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWC?= =?utf-8?b?IE1pxYJlY2tp?= Subject: [PATCH] dt-bindings: nvmem: fixed-cell: add compatibles for MAC cells Date: Fri, 16 Jun 2023 23:30:33 +0200 Message-Id: <20230616213033.8451-1-zajec5@gmail.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230616_143051_336168_B98F65F1 X-CRM114-Status: GOOD ( 18.00 ) 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 From: Rafał Miłecki A lot of home routers have NVMEM fixed cells containing MAC address that need some further processing. In ~99% cases MAC needs to be: 1. Optionally parsed from ASCII format 2. Increased by a vendor-picked value There was already an attempt to design a binding for that at NVMEM device level in the past. It wasn't accepted though as it didn't really fit NVMEM device layer. The introduction of NVMEM fixed-cells layout seems to be an opportunity to provide a relevant binding in a clean way. This commit adds two *generic* compatible strings: "mac-base" and "mac-ascii". As always those need to be carefully reviewed. OpenWrt project currently supports ~300 home routers that would benefit from the "mac-base" binding. Those devices are manufactured by multiple vendors. There are TP-Link devices (76 of them), Netgear (19), D-Link (11), OpenMesh (9), EnGenius (8), GL.iNet (8), ZTE (7), Xiaomi (5), Ubiquiti (6) and more. Those devices don't share an architecture or SoC. Amount of devices to benefit from the "mac-ascii" is hard to determine as not all of them were converted to DT yet. There are at least 200 of such devices. It would be impractical to provide unique "compatible" strings for NVMEM layouts of all those devices. It seems like a valid case for allowing a generic binding instead. Even if this binding will not be sufficient for some further devices it seems to be useful enough as it is. Signed-off-by: Rafał Miłecki --- If this binding gets approved I will still need a minor help with YAML. For some reason my conditions in fixed-cell.yaml don't seem to work as expected. I tried to make "#nvmem-cell-cells" required only for the "mac-base" but it seems it got required for all cells: DTC_CHK Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.example.dtb Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.example.dtb: nvmem-layout: calibration@4000: '#nvmem-cell-cells' is a required property From schema: Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml Cell "calibration" doesn't have any "compatible" so it shouldn't require "#nvmem-cell-cells". Can someone hint me what I did wrong, please? --- .../bindings/nvmem/layouts/fixed-cell.yaml | 35 +++++++++++++++++++ .../bindings/nvmem/layouts/fixed-layout.yaml | 12 +++++++ .../devicetree/bindings/nvmem/nvmem.yaml | 5 ++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml b/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml index e698098450e1..047e42438a4f 100644 --- a/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml +++ b/Documentation/devicetree/bindings/nvmem/layouts/fixed-cell.yaml @@ -11,6 +11,17 @@ maintainers: - Srinivas Kandagatla properties: + compatible: + oneOf: + - const: mac-base + description: > + Cell with base MAC address to be used for calculating extra relative + addresses. + - const: mac-ascii + description: > + Cell with base MAC address stored in an ASCII format (like + "00:11:22:33:44:55"). + reg: maxItems: 1 @@ -25,6 +36,30 @@ properties: description: Size in bit within the address range specified by reg. +allOf: + - if: + properties: + compatible: + contains: + const: mac-base + then: + properties: + "#nvmem-cell-cells": + description: The first argument is a MAC address offset. + const: 1 + required: + - "#nvmem-cell-cells" + - if: + properties: + compatible: + contains: + const: mac-ascii + then: + properties: + "#nvmem-cell-cells": + description: The first argument is a MAC address offset. + const: 1 + required: - reg diff --git a/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml b/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml index c271537d0714..05b8230cd18c 100644 --- a/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml +++ b/Documentation/devicetree/bindings/nvmem/layouts/fixed-layout.yaml @@ -44,6 +44,18 @@ examples: #address-cells = <1>; #size-cells = <1>; + mac@100 { + compatible = "mac-base"; + reg = <0x100 0xc>; + #nvmem-cell-cells = <1>; + }; + + mac@110 { + compatible = "mac-ascii"; + reg = <0x110 0x11>; + #nvmem-cell-cells = <1>; + }; + calibration@4000 { reg = <0x4000 0x100>; }; diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml index 980244100690..9f921d940142 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml @@ -49,7 +49,10 @@ properties: patternProperties: "@[0-9a-f]+(,[0-7])?$": type: object - $ref: layouts/fixed-cell.yaml + allOf: + - $ref: layouts/fixed-cell.yaml + - properties: + compatible: false deprecated: true additionalProperties: true