From: Marek Vasut <marex@denx.de>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
linux-arm-kernel@lists.infradead.org
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
Conor Dooley <conor+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
devicetree@vger.kernel.org, kernel@dh-electronics.com,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v2 2/3] nvmem: syscon: Add syscon backed nvmem driver
Date: Wed, 24 May 2023 05:30:46 +0200 [thread overview]
Message-ID: <2bfd38fc-b804-e9cd-3f98-4e810386bf5d@denx.de> (raw)
In-Reply-To: <e7859392-fd52-e4ba-d7b2-f77ede98e0e1@linaro.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 <marex@denx.de>
>> + *
>> + * Based on snvs_lpgpr.c .
>> + */
>> +
>> +#include <linux/mfd/syscon.h>
>> +#include <linux/module.h>
>> +#include <linux/nvmem-provider.h>
>> +#include <linux/of_device.h>
>> +#include <linux/regmap.h>
>> +
>> +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
WARNING: multiple messages have this Message-ID (diff)
From: Marek Vasut <marex@denx.de>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
linux-arm-kernel@lists.infradead.org
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>,
Conor Dooley <conor+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
devicetree@vger.kernel.org, kernel@dh-electronics.com,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v2 2/3] nvmem: syscon: Add syscon backed nvmem driver
Date: Wed, 24 May 2023 05:30:46 +0200 [thread overview]
Message-ID: <2bfd38fc-b804-e9cd-3f98-4e810386bf5d@denx.de> (raw)
In-Reply-To: <e7859392-fd52-e4ba-d7b2-f77ede98e0e1@linaro.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 <marex@denx.de>
>> + *
>> + * Based on snvs_lpgpr.c .
>> + */
>> +
>> +#include <linux/mfd/syscon.h>
>> +#include <linux/module.h>
>> +#include <linux/nvmem-provider.h>
>> +#include <linux/of_device.h>
>> +#include <linux/regmap.h>
>> +
>> +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.
next prev parent reply other threads:[~2023-05-24 3:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 15:25 [PATCH v2 1/3] dt-bindings: nvmem: syscon: Add syscon backed nvmem bindings Marek Vasut
2023-05-17 15:25 ` Marek Vasut
2023-05-17 15:25 ` [PATCH v2 2/3] nvmem: syscon: Add syscon backed nvmem driver Marek Vasut
2023-05-17 15:25 ` Marek Vasut
2023-05-18 14:22 ` Krzysztof Kozlowski
2023-05-18 14:22 ` Krzysztof Kozlowski
2023-05-24 3:30 ` Marek Vasut [this message]
2023-05-24 3:30 ` Marek Vasut
2023-05-17 15:25 ` [PATCH v2 3/3] ARM: dts: stm32: Add nvmem-syscon node to TAMP to expose boot count on DHSOM Marek Vasut
2023-05-17 15:25 ` Marek Vasut
2023-05-26 14:32 ` Alexandre TORGUE
2023-05-26 14:32 ` Alexandre TORGUE
2023-05-26 15:28 ` patrick.delaunay
2023-05-26 15:28 ` patrick.delaunay
2023-05-31 23:09 ` Marek Vasut
2023-05-31 23:09 ` Marek Vasut
2023-06-01 15:15 ` Patrick DELAUNAY
2023-06-01 15:15 ` Patrick DELAUNAY
2023-05-18 14:26 ` [PATCH v2 1/3] dt-bindings: nvmem: syscon: Add syscon backed nvmem bindings Krzysztof Kozlowski
2023-05-18 14:26 ` Krzysztof Kozlowski
2023-05-24 3:30 ` Marek Vasut
2023-05-24 3:30 ` Marek Vasut
[not found] ` <a954db86-c5b7-0c07-8881-0ceb39ac7337@linaro.org>
[not found] ` <e9d7b2de-ef57-80fa-f92b-6f66d413114a@denx.de>
2023-06-01 6:47 ` Krzysztof Kozlowski
2023-06-01 6:47 ` Krzysztof Kozlowski
2023-05-18 14:30 ` Krzysztof Kozlowski
2023-05-18 14:30 ` Krzysztof Kozlowski
2023-05-24 3:29 ` Marek Vasut
2023-05-24 3:29 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2bfd38fc-b804-e9cd-3f98-4e810386bf5d@denx.de \
--to=marex@denx.de \
--cc=alexandre.torgue@foss.st.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=kernel@dh-electronics.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=robh+dt@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.