From patchwork Sat Mar 24 23:24:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alban X-Patchwork-Id: 890741 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=free.fr Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WSoIuD2l"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="AmPeftFr"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 408YNH6kMkz9ryk for ; Mon, 26 Mar 2018 10:27:43 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0SrA/T4JMi9iFbbNme9ONfnn9Q3Tia1IcE1XSx37D6s=; b=WSoIuD2lFQQZp4ExPeH6JCePR4 1Emw4uZihEH7hcVhG2V+WZa3/DLwkdqFJvcoz8fpS/TVV767cdscs3jFDRVuDf4Q20z1C5I53h0bE BnKWI5UfHEjJ3yVr5E/O43hyE1oRpz8K/jGgXN9JWnsNBUWEWgFYct2b4uRKkk551MVDO0v9Kj4g8 OpzcZtc3XpHErAd/r/m4swMMfptr1UElj4Gu5ia7YYN8LnK6bSGGPF7KVhXr4tcgaQMuRBKyrJlT0 8HrLwzX4n6lYN33Jh6F1+10/3RBQG8CTnXATuUVtiC5769/LAm4v9NVNmFLtO16glDaB6SXK5pP5H yhkv4zcw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0F31-000792-GT; Sun, 25 Mar 2018 23:27:35 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f0En2-0006ba-WB for linux-mtd@bombadil.infradead.org; Sun, 25 Mar 2018 23:11:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AoRCd2gxqU2q3u+Yx0s/qg6uAhoGijuIfrunjXy7/pY=; b=AmPeftFrkTnzpitA5aBfsUcKN byQJcnfSDRnacQtebK41Kk5ATh3fJ3CAq22HTyky+0cjn1LoYeM2qPta0JzQzoFYifs3Qsc6yTht3 ikhSLXhOBntdchcBaH2pFtwtLxHpD8b0vdSOkFioa+TxTmy1eBJZ6VT7f2heP9Nt6UNDt/ZKVdZzR 9jB9KHpQmqA3PDu+BiD2NL2A+CeJVyJXaZwlTDz06Dr+aCn/i335fp2/G6s1zC+YgZbFdj7Qtbs+P ZtF+5qCO3nN5Lr5x/sAvaZJRXjtdRsx8uvYlPDwNSoQ1XckQwQlnivyRERcjNfV+YriOGLrfKMuHN zUx/kMNrw==; Received: from smtp4-g21.free.fr ([212.27.42.4]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ezsYz-0004ik-Fq for linux-mtd@lists.infradead.org; Sat, 24 Mar 2018 23:27:06 +0000 Received: from tock.home (unknown [IPv6:2a02:8108:4740:3978:85fa:b641:9ec1:a586]) (Authenticated sender: albeu) by smtp4-g21.free.fr (Postfix) with ESMTPA id 1197719F4EA; Sun, 25 Mar 2018 00:25:46 +0100 (CET) From: Alban Bedel To: linux-kernel@vger.kernel.org Subject: [PATCH v3 1/3] nvmem: Update the OF binding to use a subnode for the cells list Date: Sun, 25 Mar 2018 00:24:57 +0100 Message-Id: <1521933899-362-2-git-send-email-albeu@free.fr> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521933899-362-1-git-send-email-albeu@free.fr> References: <1521933899-362-1-git-send-email-albeu@free.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180324_192705_902054_4C940AB1 X-CRM114-Status: GOOD ( 16.19 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [212.27.42.4 listed in wl.mailspike.net] -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [212.27.42.4 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (albeu[at]free.fr) -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Boris Brezillon , devicetree@vger.kernel.org, Richard Weinberger , Marek Vasut , Rob Herring , Srinivas Kandagatla , linux-mtd@lists.infradead.org, Cyrille Pitchen , Alban Bedel , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Having the cells as subnodes of the provider device without any compatible property might clash with other bindings. To avoid this problem update the binding to have all the cells in a 'nvmem-cells' subnode with a 'nvmem-cells' compatible string. This new binding guarantee that we can turn any kind of device in a nvmem provider. While discouraged for new uses the old scheme is still supported for backward compatibility. Signed-off-by: Alban Bedel --- Documentation/devicetree/bindings/nvmem/nvmem.txt | 55 ++++++++++++++++------- drivers/nvmem/core.c | 10 +++++ 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/Documentation/devicetree/bindings/nvmem/nvmem.txt b/Documentation/devicetree/bindings/nvmem/nvmem.txt index fd06c09..6b723e7 100644 --- a/Documentation/devicetree/bindings/nvmem/nvmem.txt +++ b/Documentation/devicetree/bindings/nvmem/nvmem.txt @@ -11,14 +11,29 @@ these data from, and where they are stored on the storage device. This document is here to document this. = Data providers = -Contains bindings specific to provider drivers and data cells as children -of this node. +A data provider should have a subnode named 'nvmem-cells' that contains +a subnodes for each data cells. + +For backward compatibility the nvmem data cells can be direct children +of the data provider. This use is discouraged as it can conflict with +other bindings. Optional properties: read-only: Mark the provider as read only. += Data cells list = +The data cells list node should be named 'nvmem-cells' and have a +child node for each data cell. + +Required properties: + compatible: Must be "nvmem-cells" + #address-cells: <1> if the provider use 32 bit addressing, + <2> for 64 bits addressing + #size-cells: <1> if the provider use 32 bit sizes, + <2> for 64 bits sizes + = Data cells = -These are the child nodes of the provider which contain data cell +These are the child nodes of the nvmem-cells node which contain data cell information like offset and size in nvmem provider. Required properties: @@ -37,24 +52,30 @@ For example: ... /* Data cells */ - tsens_calibration: calib@404 { - reg = <0x404 0x10>; - }; + nvmem-cells { + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; - tsens_calibration_bckp: calib_bckp@504 { - reg = <0x504 0x11>; - bits = <6 128> - }; + tsens_calibration: calib@404 { + reg = <0x404 0x10>; + }; - pvs_version: pvs-version@6 { - reg = <0x6 0x2> - bits = <7 2> - }; + tsens_calibration_bckp: calib_bckp@504 { + reg = <0x504 0x11>; + bits = <6 128> + }; - speed_bin: speed-bin@c{ - reg = <0xc 0x1>; - bits = <2 3>; + pvs_version: pvs-version@6 { + reg = <0x6 0x2> + bits = <7 2> + }; + speed_bin: speed-bin@c{ + reg = <0xc 0x1>; + bits = <2 3>; + + }; }; ... }; diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 78051f0..a59195c 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -783,6 +783,16 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, if (!nvmem_np) return ERR_PTR(-EINVAL); + /* Devices using the new binding have all the cells in + * a subnode with compatible = "nvmem-cells". In this + * case the device will be the parent of this node. + */ + if (of_device_is_compatible(nvmem_np, "nvmem-cells")) { + nvmem_np = of_get_next_parent(nvmem_np); + if (!nvmem_np) + return ERR_PTR(-EINVAL); + } + nvmem = __nvmem_device_get(nvmem_np, NULL, NULL); of_node_put(nvmem_np); if (IS_ERR(nvmem))