From mboxrd@z Thu Jan 1 00:00:00 1970 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 5479DC77B73 for ; Wed, 24 May 2023 03:31:47 +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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:References:Cc:To:Subject:From: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i+pFywoJyftpg1VIo/F5Fu6Ku9d9DF21CRnC/OjpWv8=; b=OOwNX3SzeK4sum GCtCp6JrKGC9KxmUMcqA35xxiahHqQHKCRx0hyUs+ljKJy2M3EKfEogU3a+56VljVavcPfDh5KuPA AxGJ0uWndnSFQhJrPzBUr0mz1yyDy9lulICvrU25ozq6IIUzKQZb43neUzo9kl4kg0EAvxfhtlfcR L4biUdhu8HjAj/prvZQCGLOlVo1is7gMPrLpPvgrd+RrDlikx8ECtut6t4ANI3xcbyexQUYX7E0x5 P8FuQrU7uXewfDadDFYKiC9pYInoJkkApdICVMCD9JsKIPLEzQW/GWkNl1DuZ7xRZ79aajtiPbos4 nrfhUlr5qN2ETbL3ZWdw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1fDe-00CEFf-1g; Wed, 24 May 2023 03:31:22 +0000 Received: from phobos.denx.de ([85.214.62.61]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1fDO-00CECN-2K for linux-arm-kernel@lists.infradead.org; Wed, 24 May 2023 03:31:12 +0000 Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 77F3E846F3; Wed, 24 May 2023 05:31:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1684899064; bh=9sZDzeq4edg2YZc0Sc/2LYLWX+7rCP6fiNsmkjGOrQI=; h=Date:From:Subject:To:Cc:References:In-Reply-To:From; b=BZH54kYiwSkOeSzpj/B7xzYErex9rvPnGW0o1Swn0c9qFgzUn36B14puNgceRXSXt zPg9UnpWxBerlFbK2AXXHUqqJCKN3rUqRm7i06Oy8vg4So6u2ZfSFrIxT79aygxU0G gTNR07D/iHfH0quWGj2ttCrsN0OHmJFqrQMBphUDY4F9qLBCaCPA1tro2u4dAYc3Gq 8xRpeTmiI0r2y/snhVkwf2moiM9MpNedlGl/x6oHNNALYFLc0ELF4mBDXjHuH2OItV N5ixWcetat2ycnNUmAGw90B+C/WjNzvfN2fWqTypLkGbIzMPSig9mZ9oD3RGRRScBY O60J7KGbE4Mnw== Message-ID: <2bfd38fc-b804-e9cd-3f98-4e810386bf5d@denx.de> Date: Wed, 24 May 2023 05:30:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 From: Marek Vasut Subject: Re: [PATCH v2 2/3] nvmem: syscon: Add syscon backed nvmem driver To: Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org Cc: Alexandre Torgue , Conor Dooley , Krzysztof Kozlowski , Maxime Coquelin , Rob Herring , Srinivas Kandagatla , devicetree@vger.kernel.org, kernel@dh-electronics.com, linux-stm32@st-md-mailman.stormreply.com References: <20230517152513.27922-1-marex@denx.de> <20230517152513.27922-2-marex@denx.de> Content-Language: en-US In-Reply-To: X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230523_203107_094311_459FF969 X-CRM114-Status: GOOD ( 14.50 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 5/18/23 16:22, Krzysztof Kozlowski wrote: [...] >> +++ b/drivers/nvmem/nvmem-syscon.c >> @@ -0,0 +1,105 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/* >> + * Copyright (C) 2022 Marek Vasut >> + * >> + * Based on snvs_lpgpr.c . >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +struct nvmem_syscon_priv { >> + struct device_d *dev; >> + struct regmap *regmap; >> + struct nvmem_config cfg; >> + unsigned int off; >> +}; >> + >> +static int nvmem_syscon_write(void *context, unsigned int offset, void *val, >> + size_t bytes) >> +{ >> + struct nvmem_syscon_priv *priv = context; >> + >> + return regmap_bulk_write(priv->regmap, priv->off + offset, >> + val, bytes / 4); >> +} >> + >> +static int nvmem_syscon_read(void *context, unsigned int offset, void *val, >> + size_t bytes) >> +{ >> + struct nvmem_syscon_priv *priv = context; >> + >> + return regmap_bulk_read(priv->regmap, priv->off + offset, >> + val, bytes / 4); >> +} >> + >> +static int nvmem_syscon_probe(struct platform_device *pdev) >> +{ >> + struct device *dev = &pdev->dev; >> + struct device_node *node = dev->of_node; >> + struct device_node *syscon_node; >> + struct nvmem_syscon_priv *priv; >> + struct nvmem_device *nvmem; >> + struct nvmem_config *cfg; >> + int ret; >> + >> + if (!node) >> + return -ENOENT; >> + >> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); >> + if (!priv) >> + return -ENOMEM; >> + >> + ret = of_property_read_u32_index(node, "reg", 0, &priv->off); >> + if (ret) >> + return ret; >> + >> + ret = of_property_read_u32_index(node, "reg", 1, &priv->cfg.size); >> + if (ret) >> + return ret; >> + >> + syscon_node = of_get_parent(node); > > This does not look correct. You hard-code dependency that it must be a > child of syscon node. This is weird requirement and not explained in the > bindings. > > Why this cannot be then generic MMIO node? Why it has to be a child of > syscon? Because I already have a syscon node and I want to expose only a subset of it to userspace (bootcounter in my case) . See 1/3, I replied there, let's continue the discussion there. I fixed the rest in prep for V3, sorry for the horrid delays in replies. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel