From patchwork Thu Dec 23 11:07:51 2021 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: 527833 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 957E7C43217 for ; Thu, 23 Dec 2021 11:08:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347865AbhLWLIH (ORCPT ); Thu, 23 Dec 2021 06:08:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347859AbhLWLIG (ORCPT ); Thu, 23 Dec 2021 06:08:06 -0500 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B213C061401; Thu, 23 Dec 2021 03:08:06 -0800 (PST) Received: by mail-lj1-x231.google.com with SMTP id p7so7714354ljj.1; Thu, 23 Dec 2021 03:08:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NwiKmETSPCmVX7lPyPmwbKvzH3QbmKWwfTWUmPe7S4Y=; b=nQ2KcNvEoz4rICj8RmIV40zF7KqyLlhxvx7ZSsHn24ttAW6l48FaLxsT/tI4+BS8ly UTX7lcKxGQx4v59MtfWHVSzeXxJayOr4eeEHja2Rq/bS/Ooefj47oQ4xPAftbgQC6a11 lSJxPfKz2TZOVoWnpf5dOg8kBz5/UAOxWOHf55gXPdnzz9Q2O2b3A8SynHsvHaAAvVva jR4YClO7ZtkasYKBpJYtYEEanqTx8pTn8V3NXMyIfypo5RdIAfqz9Ei/K4pfeFwZ3BPv 87HppKGYbjk0Ypy5saHuV51KoQs3nCakKjg/9DWEY5dE+DoPZmMS1s4zZZUlHYaxPBev D91w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NwiKmETSPCmVX7lPyPmwbKvzH3QbmKWwfTWUmPe7S4Y=; b=awn01f4W5qMAD4Ejx8HZv/pwhWBhO6WRoeFom/tiKUiX0yvBetDMHjjxhWjvDiHpIn WSs1Wl5Zyx0iAsGR2Sca0Znhy+uYh3lonkvEkjwFgFlEOJy/3yY65bP50nVwK86BXwRe 3Mm7GPXAK8k20zMdrJjYD+fEp530UmTzPmyk16ccrYZSb530LQ6T3+mz28Kmtt1XbdGv 0+WZeQ1lUTLp25KeE9DPIKw6FvWAa5jfLnR3hFsYFGlDyq7mQdjMZNkb8M0rF+gsPjgJ BKyW6zlUpUKKr/BsmnsQnPmWYgOL55CA/r01SOzbtt1JXzwrc8dkNgqO3OJSRRg2B5Pt zY/Q== X-Gm-Message-State: AOAM533sWldDtxinEBdXl5Mz8lPncxqQp7EE48WurcdWiuaF2jeq0vMP bS5BJdbsFMIpNNinJCgK3ss= X-Google-Smtp-Source: ABdhPJxEh5gjL3BaNJkFvEhL/qh93ZA3qEmy0VIAiCWn3r6UT2AIgNOC4HR+h9KEAMmBgeQexfMf4g== X-Received: by 2002:a05:651c:2123:: with SMTP id a35mr1402949ljq.285.1640257684316; Thu, 23 Dec 2021 03:08:04 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id t7sm473047lfg.115.2021.12.23.03.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:08:04 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 1/5] dt-bindings: nvmem: add "label" property to allow more flexible cells names Date: Thu, 23 Dec 2021 12:07:51 +0100 Message-Id: <20211223110755.22722-2-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211223110755.22722-1-zajec5@gmail.com> References: <20211223110755.22722-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Rafał Miłecki So far NVMEM cells names were indicated by DT $nodename. That didn't allow fancy names with characters that are not allowed there. That wasn't a big problem for cells fully defined in DT. One could just adjust a name slightly if needed. This is a problem a however for NVMEM devices with cells defined at device level. Such vendor defined names can be more fancy and DT needs a way to match them strictly. Signed-off-by: Rafał Miłecki --- Documentation/devicetree/bindings/nvmem/nvmem.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml index 456fb808100a..3392405ee010 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml @@ -49,6 +49,9 @@ patternProperties: description: Offset and size in bytes within the storage device. + label: + description: name of NVMEM cell + bits: maxItems: 1 items: From patchwork Thu Dec 23 11:07:52 2021 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: 527525 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E5C8C433FE for ; Thu, 23 Dec 2021 11:08:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347879AbhLWLIJ (ORCPT ); Thu, 23 Dec 2021 06:08:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347870AbhLWLII (ORCPT ); Thu, 23 Dec 2021 06:08:08 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F6B6C061401; Thu, 23 Dec 2021 03:08:07 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id i31so11561045lfv.10; Thu, 23 Dec 2021 03:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1Q2sDj8vBUbZIesYQrujYlWmiKDT0P354Oapa4ONG34=; b=g3aYWmCexve9yEciuzZeNB9QdT9WkllhzHhrFMmmkLaHuq/k/YZdxtMhy1c8TnN0Q2 vxh7vVZXJth6rkJWQ8nwD7112UkXMrZ067dGk1Tm3/6+JEBb5t7zHQuWCffxLeav8o+t dCFyYc1CRE/2T/imtoxz1YzMS9eev4Qj7BmwlUaUi78abwQGIE6ys2Iu3SLtfBLVM4z9 Lfi4e99FutwWBVD7c9durybCIMHtAHNsimVy2ELOJtjOUShqelg+7FFAz/62H/iqhE12 0Y2wWrT790fmU9r4R9LFOliRiGlIWhrAKsxAyT3vwx8szgON2LgHF7kqiIuMvRRQdTGu myZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1Q2sDj8vBUbZIesYQrujYlWmiKDT0P354Oapa4ONG34=; b=F26K/eqpvvr77m3k7Vo+Pccb7TIziPsdLWOGwp/H8RvS2X0+URthDtjNRkYrN6Ip6a MZMXThkH+c30PrVdIEa05WehIl27qVg9GxocTdHIRZqRkstC8SD5RHE4K0jLcJrpi0sc HfMH66QLYGZi7YWi4mYfAajKuyubQrCCaLGUI776eefrA6BFa+VIOiqWK6YVrWdD2QIk I2qBgBtZA4RdhxW58iHVaYsaaD5ksgHY1VdkM6vwJTjQDzMEk7joOSCJWwZEibuvCiB3 q6F6XJGpgiSL+OXljJvJh7VimEfwxKxjIBiLZr7eYsx2Lc3At41JIhOWJ8u7d6VTKEla A54Q== X-Gm-Message-State: AOAM533Yfr3Yxf9yi6ACr2/yBaNxLpCYr9JhKdQ+3WB0o1daA0ndK2b3 gDFLx7JOEr+ar2BSDAMKb6HDGgaITgc= X-Google-Smtp-Source: ABdhPJzGNI930rsD+erY1tcIyxPvd4M5jaZyrpQINFCweZG3cd5Pkri6K8w5ykWmSOlxi2h3/EOxAw== X-Received: by 2002:a05:6512:3b14:: with SMTP id f20mr1452307lfv.410.1640257685904; Thu, 23 Dec 2021 03:08:05 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id t7sm473047lfg.115.2021.12.23.03.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:08:05 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 2/5] nvmem: core: read OF defined NVMEM cell name from "label" property Date: Thu, 23 Dec 2021 12:07:52 +0100 Message-Id: <20211223110755.22722-3-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211223110755.22722-1-zajec5@gmail.com> References: <20211223110755.22722-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Rafał Miłecki Prefer it over $nodename. Property "label" allows more fancy / customized names with special characters. Signed-off-by: Rafał Miłecki --- drivers/nvmem/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 23a38dcf0fc4..45c39ac401bd 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -685,6 +685,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) struct device *dev = &nvmem->dev; struct nvmem_cell_entry *cell; const __be32 *addr; + const char *label; int len; parent = dev->of_node; @@ -708,7 +709,11 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) cell->nvmem = nvmem; cell->offset = be32_to_cpup(addr++); cell->bytes = be32_to_cpup(addr); - cell->name = kasprintf(GFP_KERNEL, "%pOFn", child); + + if (!of_property_read_string(child, "label", &label)) + cell->name = kasprintf(GFP_KERNEL, "%s", label); + else + cell->name = kasprintf(GFP_KERNEL, "%pOFn", child); addr = of_get_property(child, "bits", &len); if (addr && len == (2 * sizeof(u32))) { From patchwork Thu Dec 23 11:07:53 2021 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: 527832 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B944EC433F5 for ; Thu, 23 Dec 2021 11:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347877AbhLWLIO (ORCPT ); Thu, 23 Dec 2021 06:08:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347881AbhLWLIJ (ORCPT ); Thu, 23 Dec 2021 06:08:09 -0500 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CAF5C061756; Thu, 23 Dec 2021 03:08:09 -0800 (PST) Received: by mail-lj1-x234.google.com with SMTP id p7so7714600ljj.1; Thu, 23 Dec 2021 03:08:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AIxig2RTBFVfYYo4FfiMlQHzX8KyhSHk6+94kt28iGg=; b=gMCx5RVpM32NN7w2NYmYUxYXwhoEhd4MjYxU+eKuI2A5dBkdYinO+Cur5UAk8X+f5n W2QwQu/4SgHiAmC58cPDmpRg3HgS+w91jz0/TYal2hzYJ67AKihM7nihEeik0MmWGCPn qCJMZPOxY34rvYSGcwK6TehYh2KDEID84D0IPJkKBkgPLt35ihmGTZ53Nwy3nMQBxkEV 5iEGajcP6Myhsgprkg4UB56U8+LRHo/83JP96bQyD+ecHXkQ6LLval5oH80JAlEGxWmD j9FhP9LV/miVnExuUdInTwNF6iQGQ0CbzPq2ruhesSYub53tfXANe3TIxezUhKKMTDP+ Gg9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AIxig2RTBFVfYYo4FfiMlQHzX8KyhSHk6+94kt28iGg=; b=juuKsTnifPyXLJ9/+aGKWjx53js0GbzG2svJTtO6JucvLRCts/hEOWXoqB/JgxbdOG XNQnsXolhAQV9+UsJiNfh81x7r30W92NYKAeQg63DpKGhsL1OQuLWm3ZkUFJiW7wgh+z uK2Iy+umAUGK7bxd4J6hx9EYfXUK/eWl5+kCTE0jgx8CQGGnObjAnEe7VsO4RoHooUPo Oew8lWdjLIaVHNWolbo6diDSKgx/8EIQxFKmfnS0tMCGVWJ0HNhxTkiJnNn/mN/ppAl/ d4uxLRjEDfkfY7K6PYSOEsWu6zcntQHYnUmN/GTZejiDzyIXNsbyXO7BuLt19IGRcuhp ZJHA== X-Gm-Message-State: AOAM532FcSKfcvSI9XQNRfXD+t6gaiKuSWPspWueivAG37ibztHwcdnX fgjT43T4MeBfO/BQe97ckyk= X-Google-Smtp-Source: ABdhPJwuuf+vvycPVuTIuDiqX5ygVekHwb6hCOfnl/98iXEYjWJmMl2UW8tR5YZBfv0BKZi20LVndw== X-Received: by 2002:a2e:6e0d:: with SMTP id j13mr1294170ljc.124.1640257687427; Thu, 23 Dec 2021 03:08:07 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id t7sm473047lfg.115.2021.12.23.03.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:08:07 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 3/5] dt-bindings: nvmem: allow referencing device defined cells by names Date: Thu, 23 Dec 2021 12:07:53 +0100 Message-Id: <20211223110755.22722-4-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211223110755.22722-1-zajec5@gmail.com> References: <20211223110755.22722-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Rafał Miłecki Not every NVMEM has predefined cells at hardcoded addresses. Some devices store cells in internal structs and custom formats. Referencing such cells is still required to let other bindings use them. Modify binding to require "reg" xor "label". The later one can be used to match "dynamic" NVMEM cells by their names. Signed-off-by: Rafał Miłecki --- Documentation/devicetree/bindings/nvmem/nvmem.yaml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml index 3392405ee010..83154df25c27 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml @@ -43,6 +43,12 @@ patternProperties: "@[0-9a-f]+(,[0-7])?$": type: object + description: | + NVMEM cell - a part of NVMEM containing one specific information. + + Cells can be fully defined by a binding or stored in NVMEM device specific + data and just referenced in DT by a name (label). + properties: reg: maxItems: 1 @@ -64,8 +70,11 @@ patternProperties: description: Size in bit within the address range specified by reg. - required: - - reg + oneOf: + - required: + - reg + - required: + - label additionalProperties: true From patchwork Thu Dec 23 11:07:54 2021 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: 527831 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 895BEC43219 for ; Thu, 23 Dec 2021 11:08:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347887AbhLWLIP (ORCPT ); Thu, 23 Dec 2021 06:08:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347895AbhLWLIL (ORCPT ); Thu, 23 Dec 2021 06:08:11 -0500 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F88C061759; Thu, 23 Dec 2021 03:08:10 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id a37so8430834ljq.13; Thu, 23 Dec 2021 03:08:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KnVwXtElgkqludi56UdcLE42+Lel1OeKyHXLPGAi3Yk=; b=QT0FMS5l06BCQPHuZqFcYx9kbLvsIlr1SPQMCgULHyubHtN8OATPOzeaRgnVc0WTMh sjndt3Y/7jKrRdGIdsO0TQSzZMrvWH9O0IwrZxHAF0s3GuUR8itYdLUmNkRGQoLRi70S UOjW0KHX579tSsfv9EayVRtKQ6+IV5qT0wy9MAlItVw+/Y0r/ZS+lRqFgEyfQDjWX1I4 kbyI58lrm3YM606HlRrFdqRxbzq+NAJNVqJztH8EgJlG/PE/jcW6UAV1chWcy0B3EvG1 kkl1pdrWfxJU4gDsVMtKg7x58qLiDMqFO2cXPJFq0vqunlTbBDznQ17qjayrJAwod3f7 uwQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KnVwXtElgkqludi56UdcLE42+Lel1OeKyHXLPGAi3Yk=; b=s+A3ALsSX8t/HgJWQeyc4Fa8ZDbjRt74XRVUiphK3WZlD9kNXSr5wj190khKYAcEOa GNiBLh3J5o9ctJXZ2D2lmtx7pAG4AwnEcYErAER7fFgC9pcvKG3qRcXzRxe5BYZxVdaX Xy1Bqbug6KZ47X4LPtX5c158ck8mc7P6sTNhSu+U2CQ2DX5ncKVEXhqkp1pEupUtav96 luwFeaJebiEO9HmDyk1u8qM5Cwa4ctuyH8vfRyWu8hQXTLlRkUW7AGLEJIopse9C463E j3wcztV+xw501J/XUEf0hEqTzUr7pPx2TinGcKoXr9QTaheQd3/cAol1E0+FDA7nikwg yDmA== X-Gm-Message-State: AOAM531ShibgDZlc1fH6OOh5im8x1tXf8v/PrRAQJutMZxrcpwqqhubK SBRi74yCcrFZEptAIlAqYJo= X-Google-Smtp-Source: ABdhPJwbXuWbb49XNu/OZB3UxNVRNFvpamPv3uvoYM3UqOOry1TcXEdws19cYreV4umO4zkkw0cNBg== X-Received: by 2002:a2e:aa14:: with SMTP id bf20mr1349678ljb.169.1640257688524; Thu, 23 Dec 2021 03:08:08 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id t7sm473047lfg.115.2021.12.23.03.08.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:08:08 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 4/5] dt-bindings: nvmem: brcm, nvram: add NVMEM cell to example Date: Thu, 23 Dec 2021 12:07:54 +0100 Message-Id: <20211223110755.22722-5-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211223110755.22722-1-zajec5@gmail.com> References: <20211223110755.22722-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Rafał Miłecki NVRAM doesn't have cells at hardcoded addresses. They are stored in internal struct. One of cells set in almost every device is "et0macaddr" containing MAC address. Add example that show how it can be referenced. Signed-off-by: Rafał Miłecki --- Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml b/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml index 8c3f0cd22821..840a4559b2fd 100644 --- a/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml +++ b/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml @@ -32,6 +32,10 @@ unevaluatedProperties: false examples: - | nvram@1eff0000 { - compatible = "brcm,nvram"; - reg = <0x1eff0000 0x10000>; + compatible = "brcm,nvram"; + reg = <0x1eff0000 0x10000>; + + mac: cell-0 { + label = "et0macaddr"; + }; }; From patchwork Thu Dec 23 11:07:55 2021 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: 527524 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D78EFC433F5 for ; Thu, 23 Dec 2021 11:08:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347907AbhLWLIP (ORCPT ); Thu, 23 Dec 2021 06:08:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347900AbhLWLIM (ORCPT ); Thu, 23 Dec 2021 06:08:12 -0500 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB389C06175A; Thu, 23 Dec 2021 03:08:11 -0800 (PST) Received: by mail-lj1-x22a.google.com with SMTP id p8so8487530ljo.5; Thu, 23 Dec 2021 03:08:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=84LeHW/e19a5g89AaewWo8yiJv+44/hW3Ak/xWdyyA8=; b=LnZGA5tObecQRuwxdzey7KYJRuQO7Du0GYRah5VyFrCTa6a0Chg6WIzADqa51h7qpp +8TczdT/VPZHAagcOijkp1UlluvbIuWap+Bt/h02HLcq/v0dhmNQQ6/YtXanFiiWpjGk w7wu3wSBqLJ1fHWJju2xPOTWHC3xGrK/K22SkPMeC+AbwUvfha/G5wmThbNZgq7Gd9jm JlNG6TVGuRk1oKyoq2E8YfJfK4aQ/XfPR07sk7V1A7tnDwbAlfJoLZcheQJr8Zru7q2l x1C0XMQFZaM+amyqrESqPUctvg3ESz0+OY4v5MtZpz2GLH89bemWgs4wcc3OWKBEjJxo eLDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=84LeHW/e19a5g89AaewWo8yiJv+44/hW3Ak/xWdyyA8=; b=HixRQIUUeMBUSGV9ZckDiZh8or5GqmXpcttjktbCqIxbBu/QMsAXVxARm1D/x282T4 P4VPwCcmLZgkLbtxqRGAdP1bWU0IHUnQ9N99nUhuxVLIZzhWyHznTRGGSUb8yXlCsCCQ 15nMxoaamouyO84Qy9QXs9AsDOPdjaMX/JaDN9NT/saaKd5B3pzh0URMcxT+zA+3Y98M zDn6i8mLcKJsIlFyVgiqPsbc3O/PItFj+rxHiNdP6GgOrHkuYnel8LsP399jmiKvQOiO lJ3gb09YXNZENvyJRAhnMglleHnglWe+7t2JRS4OkOr3SQ6Zwk0dzMJkUwX6iFpjnmKs PQxg== X-Gm-Message-State: AOAM532i0BQNAkKGHOoRbBGogMkmS+Vr+FqH71kGyKsnS3vyCAUfnEyJ Z0+7mAs5yhSjl5LELiGDJ8w= X-Google-Smtp-Source: ABdhPJwHtj537VAWY1ZrCuOV3QEoO+Y8FoZA8+jyb0dgmaT1NpPfixRyUYbGFo0vvvpZ1afm2Rbwng== X-Received: by 2002:a2e:9192:: with SMTP id f18mr1316446ljg.211.1640257690200; Thu, 23 Dec 2021 03:08:10 -0800 (PST) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id t7sm473047lfg.115.2021.12.23.03.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 03:08:09 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH 5/5] nvmem: core: add cell name based matching of DT cell nodes Date: Thu, 23 Dec 2021 12:07:55 +0100 Message-Id: <20211223110755.22722-6-zajec5@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211223110755.22722-1-zajec5@gmail.com> References: <20211223110755.22722-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Rafał Miłecki When adding NVMEM cells defined by driver it's important to match them with DT nodes that specify matching names. That way other bindings & drivers can reference such "dynamic" NVMEM cells. Signed-off-by: Rafał Miłecki --- drivers/nvmem/core.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 45c39ac401bd..5fe92751645a 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -499,6 +499,33 @@ static int nvmem_cell_info_to_nvmem_cell_entry(struct nvmem_device *nvmem, return 0; } +/** + * nvmem_find_cell_of_node() - Find DT node matching nvmem cell + * + * @nvmem: nvmem device to add cells to. + * @name: nvmem cell name + * + * Runtime created nvmem cells (those not coming from DT) may still need to be + * referenced in DT. This function allows finding DT node referencing nvmem cell + * by its name. Such a DT node can be used by nvmem consumers. + * + * Return: NULL or pointer to DT node + */ +static struct device_node *nvmem_find_cell_of_node(struct nvmem_device *nvmem, + const char *name) +{ + struct device_node *child; + const char *label; + + for_each_child_of_node(nvmem->dev.of_node, child) { + if (!of_property_read_string(child, "label", &label) && + !strcmp(label, name)) + return child; + } + + return NULL; +} + /** * nvmem_add_cells() - Add cell information to an nvmem device * @@ -532,6 +559,8 @@ static int nvmem_add_cells(struct nvmem_device *nvmem, goto err; } + cells[i]->np = nvmem_find_cell_of_node(nvmem, cells[i]->name); + nvmem_cell_entry_add(cells[i]); }