From patchwork Fri Feb 11 13:05:52 2022 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: 12743425 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 99B36C433EF for ; Fri, 11 Feb 2022 13:07:33 +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:References:In-Reply-To: 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: List-Owner; bh=LffeZX6GstCMgpGa6v96ixk/WrMiG5bcUT/MEDngCog=; b=RtRo5DLnNBf/SA 1za11nN84SWWWAAMh+M2wXvWsU5Mf+f9aoYQUR2RRHCcGL+MCjcRXZn6I5Ok9s6gYHbE030rg8rPR +Oxj9gterEveMx75I2k5SlevZGpFpm2j7rXMfWvHeLECUHxKKzgsUTdo4fq6r2kxeDMcInEDViT5Q lGDlO7I22iqNTHH1ZwfugVwoxlnF9YwUz8R/jKHo5Vk6+iIeEGhUGC1uv/PLhcKvXO1rm0vhbc1Pa bd0WweqCSN/OF0BIVWzRx5uq/V1XgIrv473D4BV/30ga2eoLdSMpL41BD23WVdLCM5J1gwxeyaorE vPOR75RtrIEkzmdw5rqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIVcy-007Jav-L1; Fri, 11 Feb 2022 13:06:20 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIVco-007JWz-4o for linux-arm-kernel@lists.infradead.org; Fri, 11 Feb 2022 13:06:11 +0000 Received: by mail-lf1-x12d.google.com with SMTP id i17so16381948lfg.11 for ; Fri, 11 Feb 2022 05:06: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=P+bxWvATPkNOJhL/LdCmA0xomBxVYCMbyohvhLg0UcI=; b=U31jAZBh+UkPdAsdfXxNqS06v5iv4Kmb619Q0qXa5b4daXQDdI6iKCr40v3fjPF1r1 L0+nZvCrzpR8LroM6/TPlloZH9EBRY58oHBMdHmNfPXJPBOMlTZr6M9Uw2jHlsucW0R+ CYwGyi06XQn+TXUWHqpiRlYgfAAe9y8CQ4rAgsm5NJLgq1C+JquOzdtk0WlFdahCwldN f9UcuCvgiA91r6BTgN8spISIu7KNVPCJfD84WMxdpQUKmWfriSjrvHlx/t6NSJgIns9b lqo/WnA709FXhudPc6C4aA0DZlueBaZSL3THgXasy/TRimaRAUXzM0kBvIuvyVYUYkFn 4q2Q== 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=P+bxWvATPkNOJhL/LdCmA0xomBxVYCMbyohvhLg0UcI=; b=caS1DrUhk28iCluVHRkpKYEeHCXxrp4R+RRK5kwcy/HCK+mNOd5LcS9EFqWF2DIqs0 EzfJPhh6a7plq04xrW1KSyMpZ3e6/GonnXSyHl1w91AN2wa9x1IIOXroPK01QDQH7GT8 l/hH1BWFBjmhB3W805VJ6WveG/le3FNyI1zZUsV1E1k3EE5ufB6wy0GkNITg5gA7Kvgh 5GpC7WVajH2lTM30OCJ67YHEaXhdVg+pVJg29OSQGk9uqfwK8XChT3KT3LbGTzOlgIzL KXVfftBFPmHtGrYkui6Ewu3DAilzJt4O9hg1wruknA6vF//ihH23vSDYIV373slCTMPC Ezzw== X-Gm-Message-State: AOAM530N1ycrcjv+nkY9bkx17NcVDSsTZOxU9l2/nF0gIErirGiXea/V 2TFJUFCxTjkIW/9a8uSQVr0= X-Google-Smtp-Source: ABdhPJyANwpxODf7FJd9LpX2QULdfogZP9CIp2POXVV9rIbBeWcAw6Pa79ERcCDcf6OALw6cAbfTmQ== X-Received: by 2002:a05:6512:3d0e:: with SMTP id d14mr1122587lfv.165.1644584768402; Fri, 11 Feb 2022 05:06: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 b13sm3111094lfv.175.2022.02.11.05.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 05:06:07 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring Cc: Krzysztof Kozlowski , Florian Fainelli , Hauke Mehrtens , bcm-kernel-feedback-list@broadcom.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Rob Herring Subject: [PATCH V2 1/3] dt-bindings: nvmem: make "reg" property optional Date: Fri, 11 Feb 2022 14:05:52 +0100 Message-Id: <20220211130554.13062-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211130554.13062-1-zajec5@gmail.com> References: <20220124160300.25131-1-zajec5@gmail.com> <20220211130554.13062-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220211_050610_225843_8FE1F856 X-CRM114-Status: GOOD ( 10.43 ) 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 Most NVMEM providers have cells at hardcoded addresses however there are some exceptions. Some devices store cells layout in internal structs using custom formats. It's important to allow NVMEM consumers to still reference such NVMEM cells. Making "reg" optional allows defining NVMEM cells by their names only and using them with phandles. Signed-off-by: Rafał Miłecki Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/nvmem/nvmem.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.yaml b/Documentation/devicetree/bindings/nvmem/nvmem.yaml index 43ed7e32e5ac..3bb349c634cb 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml @@ -60,9 +60,6 @@ patternProperties: description: Size in bit within the address range specified by reg. - required: - - reg - additionalProperties: true examples: From patchwork Fri Feb 11 13:05:53 2022 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: 12743426 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 AF7F7C433EF for ; Fri, 11 Feb 2022 13:07:39 +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:References:In-Reply-To: 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: List-Owner; bh=Gk4OvC6KIm+QnUdBNjKhb97BOYmX7boA6sxwyR8LCpQ=; b=27kD53rHt6lIgK xCvTsDn0qboEake0rwlpc8RvQP4aXsMpG7sk8HpGTScmAsirvUwsqGDCHNNMztLJGVM/dpLkM2mzL 5WKoFi7Y8FyGWxP+5BTy7vKyYQ0i+o5cQJh5X8Q/saGvDBPlSh1wEfrLspqM0voP3aqAT9MYwXElL JCD9csv6tBSFPZXwLc4g1TUqbHEGT+mrBZUrhASfoU7n3Pl5LthqfWXbpAvFdy2jiEWe8Owl8CGEE jHAJcopJ+SYMEOx6JzUVddwm6HyeidvveRdrhArJhbkjrQT3ceZQ99Y+9tHHc8oNmlmgHHNkSZZCC SuJRMVXRXaNIoSCrCpLw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIVd8-007JeU-Mt; Fri, 11 Feb 2022 13:06:30 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIVcq-007JXO-5B for linux-arm-kernel@lists.infradead.org; Fri, 11 Feb 2022 13:06:13 +0000 Received: by mail-lj1-x22e.google.com with SMTP id o9so7585451ljq.4 for ; Fri, 11 Feb 2022 05:06: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=QOZGevQGicR/4MkXAylsEnnmSbv+cCBrPCN/jkqNkh8=; b=eCZCn1FmAZxUuMEtpttv+KsWo7SwhcG/TpxpuSl+CJ1TkCD9kX+4YuN033rLRqjVbB COEB6eYs5kPbYM+lvMrP+/NoUg2zAu+N/r0aso39xSo/JEahMvA2ccHLvib9uvBu5Svp C5n+Ehizm3QJg7NpbYZPLm2BofR8A6eibHw16MJ803VjBtyBlBD5gSzgk7dmCV+TrKY0 snent26UPAX2zdPuUtvehBjiJVWmRx7J6Pq8yO5aXCR6VEr+5ZnnB4JNx7GRjxo5/1LD G5QJfceGRpDWr87fSo8JSsRZiJBkG4A9f+pUXsb9QMqOl2yr3DZ3DRULi4aa+IHOQBlV OBow== 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=QOZGevQGicR/4MkXAylsEnnmSbv+cCBrPCN/jkqNkh8=; b=kRGnlQ0egM55v8MLH0QRbC2NJKnKxpU1+mAjUsJbxkb0DimhoxK6xPzPJRfVx2TZo8 2and6zhvGweX8FkobaUV8hngxgD7VvCL4mEGDZBMWnx7U93xe1xSTrPm0JJr+eUg/S27 uXybzD19HT76+NIvsRoj6IJVCWTov7MN73yP9t92MnPcDlLwHgry03O1GECEcVDlj6pw C2UxLSio33wp0QrblQlg097NNtWs6M9ebw9GRQASzq7H/4gp8f/zMWHQvKOSiKBfuK5J U40NVbRyTt7Aj9ckFkaGt7LhLNSC0MhofHJmJpOInJ+iWSondTRv0SiCJJsYZOOjGHQI +QOQ== X-Gm-Message-State: AOAM531oxDj1YSFI/ivQEBnu4Wm30zSlrnSEODq1kBqu9BLjVMsT7+Z1 nsDZzU/F5IL3HpkDnVHXJzk= X-Google-Smtp-Source: ABdhPJzBevgFzgppACuqmRMqskbqEtIQ/liEcKObs5ceSG/hjKKZgV3iJ9hpb9+QiyO+mgjTxxCMwg== X-Received: by 2002:a2e:a786:: with SMTP id c6mr930312ljf.385.1644584770532; Fri, 11 Feb 2022 05:06: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 b13sm3111094lfv.175.2022.02.11.05.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 05:06:10 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring Cc: Krzysztof Kozlowski , Florian Fainelli , Hauke Mehrtens , bcm-kernel-feedback-list@broadcom.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 2/3] dt-bindings: nvmem: brcm, nvram: add NVMEM cell to example Date: Fri, 11 Feb 2022 14:05:53 +0100 Message-Id: <20220211130554.13062-3-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211130554.13062-1-zajec5@gmail.com> References: <20220124160300.25131-1-zajec5@gmail.com> <20220211130554.13062-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220211_050612_228888_642C3F16 X-CRM114-Status: GOOD ( 13.56 ) 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 NVRAM doesn't have cells at hardcoded addresses. They are stored in internal struct (custom & dynamic format) . It's still important to define relevant cells in DT so NVMEM consumers can reference them. One of cells set in almost every device is "et0macaddr" containing MAC address. Add it to example to show how it can be referenced. Signed-off-by: Rafał Miłecki --- V2: Add children nodes description per Rob's request --- .../devicetree/bindings/nvmem/brcm,nvram.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml b/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml index 8c3f0cd22821..fc1df9d1c4d4 100644 --- a/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml +++ b/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml @@ -27,11 +27,23 @@ properties: reg: maxItems: 1 +patternProperties: + ".*": + description: | + Each child node represents one NVRAM entry (variable). Node name has to + match variable name as internally defined in the NVRAM. + + Some of common NVRAM variables are: "board_id", "boardflags", "boot_wait", + "clkfreq", "et0macaddr", "sdram_config", "wait_time". + unevaluatedProperties: false examples: - | nvram@1eff0000 { - compatible = "brcm,nvram"; - reg = <0x1eff0000 0x10000>; + compatible = "brcm,nvram"; + reg = <0x1eff0000 0x10000>; + + mac: et0macaddr { + }; }; From patchwork Fri Feb 11 13:05:54 2022 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: 12743427 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 F384EC433F5 for ; Fri, 11 Feb 2022 13:07:52 +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:References:In-Reply-To: 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: List-Owner; bh=CO/KfhwGbwH9Z/eXLCsxCh8pX7RYFG0COGrwz02UbqA=; b=tGEi7GQgIYgBH3 Q8b5uf0+uPwOyHzGR3w4hrO/ZQNDwas/mM9zmiZWM7nEl/SNuXUj22EdM2Z0aO7qI/utK51r1SqfM o/OEp6FUhaL9ITUMPtqPE0b2X4vycEgDCeiVOX+2Z7rgxRYbqUs/uMcAxCGKHR7tnD+QYRqUTkv/Z 8BxW+t6mqDfwtch72sQah6xpFJKmAvskH6l55bJRA4D0tcIltQHVKK0tR8dytkyHn2bisBwoIb/MD 2xIJAqLsQ6TwOYI1QArpBBaRCF/wXi7TqmLtEHkGuYixcS2Vah5wqINp8vt+293CiJbL+5X3Kfhs3 9TTUTPXT4pr+ROl0EOjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIVdI-007JiG-Ub; Fri, 11 Feb 2022 13:06:41 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nIVcs-007JYA-AA for linux-arm-kernel@lists.infradead.org; Fri, 11 Feb 2022 13:06:16 +0000 Received: by mail-lj1-x233.google.com with SMTP id n24so9754317ljj.10 for ; Fri, 11 Feb 2022 05:06:13 -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=tX9YbbK4wZDYd/1rJF+Fsl9cu8MwUvaAy3wkrzRgdck=; b=EYhftBejqCnc8+Xc8fkkRb1kgXnwY9DZicwijRuZEMwqwLctCSRnWT3czltZ1Oe7Vi RRYXVlpSymNMkx85YtOHjmuCrs4Rw1nSL9N5I1CLdYMj78PYUCVl0FtUgXFjgJTHx9TZ HQdK1nrxeRo/nseosHSxIJdwwgSttMcTBwBK7BVq95O65zEO9lyQT5Ko+tFf1bS7VG3S OQuJYPPe3DOGMSto56n04z06eUyBmXcgu4jxGd9GtAbNNXNIKURGrny0I2FNPa2g2E7a O6NltEOPRVDIM2iBU+78Qa4FgjfDX3ggUzOcjIBgqXnASsQX3Yep9azAufzehByV5hAI a6KQ== 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=tX9YbbK4wZDYd/1rJF+Fsl9cu8MwUvaAy3wkrzRgdck=; b=M2pdRc1qW4IRoiVtfiby7OiQDXGAfudTkZnylrlPIITqKq8+rOynpMArgZKDPqjjoE YINOwB9509oTEG4sDeTHPit8dCXXp5oz/E+6nz0QrEwuDmSYMNsckAISPqUm3JZJKhiY Kc8pxQMoxjSAVhSCOXPHhR8xYTuSvwpRYBFnkRCAvYORGOC8odmo6agQmsdgDqK9Qmxq gPg8THS5oCx1rLYrQPcZFKHi8mSMLuN/f1d91jE/srKOtx9UOkj1hlV8gE0OCY+tS1zi Ti0EiTnH65SzwAPx1y6PTmTGQHnCSCd9sLHJakDDihFdyA9Tfb/Q3dK4af+v64Qn59je DMGg== X-Gm-Message-State: AOAM531JYzlmIDbeOW95K6QSsiNcfUgU0JcQUJrIkqx2FnYxtm52M7BX RBA4aBw8iInaRmVeeWBcabg= X-Google-Smtp-Source: ABdhPJwjh3Lda7G/sGCxxqTFqmt+fCLA8UjkG+crA1HMkLbUpGWDYr9nLfTZA8qjf3oHiyFBjGOzjA== X-Received: by 2002:a2e:9d96:: with SMTP id c22mr976389ljj.293.1644584772698; Fri, 11 Feb 2022 05:06:12 -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 b13sm3111094lfv.175.2022.02.11.05.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 05:06:12 -0800 (PST) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: Srinivas Kandagatla , Rob Herring Cc: Krzysztof Kozlowski , Florian Fainelli , Hauke Mehrtens , bcm-kernel-feedback-list@broadcom.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 3/3] nvmem: core: add cell name based matching of DT cell nodes Date: Fri, 11 Feb 2022 14:05:54 +0100 Message-Id: <20220211130554.13062-4-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220211130554.13062-1-zajec5@gmail.com> References: <20220124160300.25131-1-zajec5@gmail.com> <20220211130554.13062-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220211_050614_405504_87388827 X-CRM114-Status: GOOD ( 14.74 ) 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 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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 53a43d843743..a891449c52f1 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -499,6 +499,31 @@ 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 provider + * @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 then 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; + + for_each_child_of_node(nvmem->dev.of_node, child) { + if (!strcmp(child->name, name)) + return child; + } + + return NULL; +} + /** * nvmem_add_cells() - Add cell information to an nvmem device * @@ -532,6 +557,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]); }