From patchwork Fri Feb 18 07:07:27 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: 12751003 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 417B6C433EF for ; Fri, 18 Feb 2022 07:09:28 +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=N14Ef8RFUg1M2x crIRPNkEcP8iCEcD+3JQz6HapmkbyDm0lE8QCMIh4aXFkIpAefb8a/F4VWpS99eY3nSNAwWY2eSbB JhadIn8T2vkr/2pBnntuQcFiwxHCxP5eUEP1tKq6hAuH/ERejYoY6J50em9JzrCWzMI2pruI09n7M 5+v35vQHO6YnTn3KEJp4lyoZYSv3trsKhu7s396HUaJPxSLjdOfMrPnyWPQINCa2fSkB0US+WOdsP Ls075a+1VkHQa1rxzidgEqsYKUJSOMrzuK9krbEK5BGzT4KiBBeLucLq2xKHWs2iAPa/nhWzS/OtG SYN5BgT44nBetF+nyzNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKxN8-00D8N0-3G; Fri, 18 Feb 2022 07:08:06 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKxMv-00D8IB-Vh for linux-arm-kernel@lists.infradead.org; Fri, 18 Feb 2022 07:07:55 +0000 Received: by mail-lf1-x12a.google.com with SMTP id p22so3655581lfu.5 for ; Thu, 17 Feb 2022 23:07:49 -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=cAviAy5J3oRRudjP5AIgmmBkwBZSkZpaCf7XKJkXx2jN9biGtrzmrz1tMLxXvk7Wqx +h5moiMM/uORfgGLhJOEyTGdAJkC7C1wCdlzfxxndxKWM9ImTphOcHmpfmmX298P5BRi GsFGEsDyhD76/KpyY71L9oz8AjUIb9DlzLyH0Bbslvn2A0OaVI1lbUxzHSsuj29RC7q/ N9WI03NxUi3RQT4duuhWdbcYDjZgYBQlBvfs6zwd6PLX4Kn2y2RmnViVwzSW4Y/TS6ki AHywcxA2maR2tyUnWnT5KrLXvXp+eFzxQjxm/gVxroIE8X4lAY8+EsFM00QV9VhTWAmP tjUw== 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=lRksERIs77cjra311/2p3ngYcQu4637nvScI4XMm1Z5R83YERXHgCSzd9JvIDShY8/ yW5dPh8HZO8A4P+6IaGOeMlYiNVK67tHTqPcxVLJ0JVNlm0WmWy8GVDgzQc+JTNcDo9W yK1FlRnAwSVZ2VUqKqd6uucPdATNfySveXIuJO/mPZyIJQDttVuHUts11EC+piErRO9O /8zMHUoIzEo/wrGsCy4nZxu75q3tOJC3ypoeZViaPaf4jEl/OS5trKxL4e5kNnNbVHdA /vq7+wIfrOqo+PnXuKf9SQlW7H0MAIM00bWsOHd+M9yLJwawnRV7OauCG5JkfiomsABt TFgw== X-Gm-Message-State: AOAM5324VdLq5mpFTnBOO0zug8lje2bQemMxfbyUsqb9y1q+wiyOsQcL bGPa6ofg0Oj40UJ84JVPEQo= X-Google-Smtp-Source: ABdhPJxOVs8gipD3+lXvLpzGAJAUN72tLwtRCdCU2mNHxQTEFevcefrvr5xFCYLginqNQACcLpA4Nw== X-Received: by 2002:a05:6512:1529:b0:432:2c53:f9e7 with SMTP id bq41-20020a056512152900b004322c53f9e7mr4464499lfb.139.1645168067679; Thu, 17 Feb 2022 23:07:47 -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 f2sm216321ljn.11.2022.02.17.23.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 23:07:47 -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 V3 1/3] dt-bindings: nvmem: make "reg" property optional Date: Fri, 18 Feb 2022 08:07:27 +0100 Message-Id: <20220218070729.3256-2-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218070729.3256-1-zajec5@gmail.com> References: <20220124160300.25131-1-zajec5@gmail.com> <20220218070729.3256-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220217_230754_027522_53E21AD6 X-CRM114-Status: GOOD ( 10.34 ) 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 18 07:07:28 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: 12751004 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 549EBC433F5 for ; Fri, 18 Feb 2022 07:09:31 +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=HZ2jRUtQDKwlTffox474eUu8rXiV3dniOeNTugkhs8w=; b=MMBajh4pUsazDY xG0W3aO/RxZaaJqngl2a9uV7VtvAM520Lf7Ht/MvTH5ItVRiYzcbHuivxRjFSKU/OGjNo9rhkm+i7 ao06LrqzMr+AiVJ1Z4+d9qgrnzrhS0qHUOlJXfPM01M02D9TmPdC9prQ7W1Lu8TINU6MiI7mFsU1V kdOBj+o7vfxA0+wl1qcSe3iWB5t94b2peycbQkfLyA1+49TwUjz2vvdi8AjOYohsocvYZYDIVF3VP 5KlqcMDEjlVYa1V9R7isN6hQhqDnvIcquSPy+/bk5mrX7DqcWDbfAH7sgiMPqwHm0IuH3X5nndfpD g5JEGjbYXQZvpQK0pwfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKxNH-00D8QJ-Ql; Fri, 18 Feb 2022 07:08:15 +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 1nKxMw-00D8II-BT for linux-arm-kernel@lists.infradead.org; Fri, 18 Feb 2022 07:07:55 +0000 Received: by mail-lj1-x233.google.com with SMTP id bn33so2948981ljb.6 for ; Thu, 17 Feb 2022 23:07:50 -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=IWDJ487yLqJMH2R9nX25geZJE4tvSDIiR8xa0l3wTz0=; b=IlUrs1RVK2LtAIx0K8FKunjdCr8qaBX4BhLfEYD1cCBATkF5gNTEO5aV7XLepcZngT 5xvmeytA/gzHC7V3X2nPXsV4pFX77uEGlVZbJSOnIN9ERh24nUyI6U1w20I77lwNLk3T YlewxLcYhoMWB0zHtnKLq1JaTd893WrE9ZFOjCRjeJBpPeRNDtgkZ3o+nKqQbX8NYVGG UQ040lm1calR6iOJOW+PHnP+cISn94xgQVBK27t6rACckUPZFd9mAokgv79qLo8YqwSL jcHfZcNH6DafyXoUSt3kpr5PBDWbz0aMI3lFx3XP2x11SkHkyg0IPgd7GUGj+y7hriwX PhaQ== 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=IWDJ487yLqJMH2R9nX25geZJE4tvSDIiR8xa0l3wTz0=; b=RbPoG9yQDUewWtze3e/IKoXG7GBXwUuV3UWwt55uNIr6q3+DMlrxPxMHptNYdqfiQf iXHBj+r0KS4v7TJLfP/HFfAQjmzTbZ2PRDtEW8Gm/CS/64NzGdsPdw0f4WA8+d8GqFZs iFD0L0Dvsn2XOBuqqFyJ3x4q3Yp970Yj/RUbJWzWGSf2x39sIp2/Cz/Va+ZmLGy5j2bT Zdei54FUr3zNXZ1cvI2+dfQA1KLiejmWUoGC5T3yutz4IDf+drsqejRQkkL4cZH2Bd4/ jAu1xfEf3F5MyTpTUMktvgwalpb+5sr+NUq7bD+g4kgaFzGHl4zr0kqSKYUyx6PrAMqi 8o5A== X-Gm-Message-State: AOAM530Pb35vkh2XL4zjRAos7U3AvX/nhmNP22pZ55Ia+7H8F1wTBndu T0AMJ8LczBEh/fmAwx66jh0= X-Google-Smtp-Source: ABdhPJyG4PhqQCB3tkP0I48RQhI08avuz/CEw5sI25p72beCNJ/SSg79592K5goUTi3gS47psMDsHA== X-Received: by 2002:a2e:9043:0:b0:246:1afb:1436 with SMTP id n3-20020a2e9043000000b002461afb1436mr3638607ljg.215.1645168069084; Thu, 17 Feb 2022 23:07:49 -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 f2sm216321ljn.11.2022.02.17.23.07.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 23:07:48 -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 V3 2/3] dt-bindings: nvmem: brcm,nvram: add basic NVMEM cells Date: Fri, 18 Feb 2022 08:07:28 +0100 Message-Id: <20220218070729.3256-3-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218070729.3256-1-zajec5@gmail.com> References: <20220124160300.25131-1-zajec5@gmail.com> <20220218070729.3256-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220217_230754_425761_D9BCA747 X-CRM114-Status: GOOD ( 13.05 ) 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. Update binding to allow including basic cells as NVMEM device subnodes. Signed-off-by: Rafał Miłecki Reviewed-by: Rob Herring --- V2: Add children nodes description per Rob's request V3: Document NVMEM cells as properties --- .../devicetree/bindings/nvmem/brcm,nvram.yaml | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml b/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml index 8c3f0cd22821..25033de3ef6b 100644 --- a/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml +++ b/Documentation/devicetree/bindings/nvmem/brcm,nvram.yaml @@ -14,6 +14,8 @@ description: | NVRAM can be accessed on Broadcom BCM47xx MIPS and Northstar ARM Cortex-A9 devices usiong I/O mapped memory. + NVRAM variables can be defined as NVMEM device subnodes. + maintainers: - Rafał Miłecki @@ -27,11 +29,30 @@ properties: reg: maxItems: 1 + board_id: + type: object + description: Board identification name + + et0macaddr: + type: object + description: First Ethernet interface's MAC address + + et1macaddr: + type: object + description: Second Ethernet interface's MAC address + + et2macaddr: + type: object + description: Third Ethernet interface's MAC address + unevaluatedProperties: false examples: - | nvram@1eff0000 { - compatible = "brcm,nvram"; - reg = <0x1eff0000 0x10000>; + compatible = "brcm,nvram"; + reg = <0x1eff0000 0x10000>; + + mac: et0macaddr { + }; }; From patchwork Fri Feb 18 07:07:29 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: 12751005 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 41637C433F5 for ; Fri, 18 Feb 2022 07:09:36 +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=NsHiZEo9OJnnAa aZsqMEdShN9nRTmwFm2lolZeb3Ngw6zvChOjXci9zTjb8SWffyLm+kESmi70VGhayoO5TOTCP0WUW DjJT1GpOqsQJrBPeFTNsPJ9NQmnaBJgUwc+txy8OgaXur5rf/2z/lYK7jSTRzO0Cr3P0o0g0n/gRA g856aPIkOCuSetOPCXQxdQE4CNCU3ZYw6cbFJLf46kydekfZBJhbQ2AKsWRNRTZun23yxIvs12aml S+Ourcm1acMgifhAop+wtU043NwraOUoI7Ydi+KeYootvx7sUmFZ3M4U988gJqwuxgrXjz+b5Lrit dhc4sctWe75s5UCqxPuQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKxNR-00D8RG-0x; Fri, 18 Feb 2022 07:08:25 +0000 Received: from mail-lf1-x131.google.com ([2a00:1450:4864:20::131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nKxMw-00D8Ic-RM for linux-arm-kernel@lists.infradead.org; Fri, 18 Feb 2022 07:07:56 +0000 Received: by mail-lf1-x131.google.com with SMTP id i11so3658658lfu.3 for ; Thu, 17 Feb 2022 23:07:51 -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=pxTGNtwoQqXXXR2NQW0yIPEwzA0QmPkCsh3TL6HrB99Tf4HSx4B99Dqicg+E+RHzC4 MHVO+WtCge/ccF+M4pDhmB+OD4gvoQIUaWPxzX5LNEvLfpsBaQVMP8fhanBREMlxHQ5E ZdNRPw0yRGsymvyZkIp1f+lCFpsngd3NFTe7zgypaZr8kw1W8gcuioLuvcbUG/YW02Vg Gisz5pm04fQLQuetkLKo5JcrTCmFE08MjcSuSeRa3UDe8sOu+okvGvlfJJc9FkH8OQRW qUBLmGNGZGFsQc3a7ViJMZUUZyVUeahBQTItXu0/PqWVLKKFJp/uB5ta0zEpLyVc60qg wjBw== 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=ggrzH3+AMVwceJasnjgFIpn8RjE0J6eRZ5SS2oGt6jBTY6SSrCdR+i8tZwnvnnMTnM QHSZMGg8eV+qmxfQ8GDcABdzjzxfZSKd3jHQc4dFboxsx1Ebz4GfqVXeuQGc0B27Tvj1 Yx3sXFRkOrp3LaEuXybZE41csZXm5AO/JyMnfDfWmQEc0lencVrUNO6YPAj2oaPZYxQZ WNPr9dVbW/5MKLbHfh7jab0+ApzsVf3Qbt5Q+991qzL36aPiwVtxE955DD4AqjULfF5u 3C7BjmGnfsIPn5GccNbmlSg+GWinOt9b2l0wNquHTtMcKbKXDt4nwzY/2LHPKDsUZ9JP mhIQ== X-Gm-Message-State: AOAM530g9yocfzvCYOyjEQSGQafxymAskbZBpFaJarOYUwKYe1Vjb6mZ k58uVRqBBngkplkOfioujuXN9v05RYE= X-Google-Smtp-Source: ABdhPJxGeC6tp3SeoxUP99YYLkCjtoNxEe4/ANtehLPoJQ2I5YnOQLjx0VpstabDvYhzosZJadeOmw== X-Received: by 2002:ac2:554d:0:b0:443:6539:a299 with SMTP id l13-20020ac2554d000000b004436539a299mr4590089lfk.552.1645168070508; Thu, 17 Feb 2022 23:07:50 -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 f2sm216321ljn.11.2022.02.17.23.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 23:07:50 -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 V3 3/3] nvmem: core: add cell name based matching of DT cell nodes Date: Fri, 18 Feb 2022 08:07:29 +0100 Message-Id: <20220218070729.3256-4-zajec5@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220218070729.3256-1-zajec5@gmail.com> References: <20220124160300.25131-1-zajec5@gmail.com> <20220218070729.3256-1-zajec5@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220217_230754_914103_0E474460 X-CRM114-Status: GOOD ( 14.65 ) 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]); }