linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] nvmem: core: support passing DT node in cell info
@ 2022-02-28  9:33 Rafał Miłecki
  2022-02-28  9:33 ` [PATCH 2/2] nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells Rafał Miłecki
  2022-04-08 10:20 ` [PATCH 1/2] nvmem: core: support passing DT node in cell info Srinivas Kandagatla
  0 siblings, 2 replies; 3+ messages in thread
From: Rafał Miłecki @ 2022-02-28  9:33 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: Rob Herring, Krzysztof Kozlowski, Florian Fainelli,
	Hauke Mehrtens, bcm-kernel-feedback-list, devicetree,
	linux-arm-kernel, linux-kernel, Rafał Miłecki

From: Rafał Miłecki <rafal@milecki.pl>

Some hardware may have NVMEM cells described in Device Tree using
individual nodes. Let drivers pass such nodes to the NVMEM subsystem so
they can be later used by NVMEM consumers.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/nvmem/core.c           | 1 +
 include/linux/nvmem-consumer.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 6d5702e715d6..5fcf2793b599 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -467,6 +467,7 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
 
 	cell->bit_offset = info->bit_offset;
 	cell->nbits = info->nbits;
+	cell->np = info->np;
 
 	if (cell->nbits)
 		cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
index c0c0cefc3b92..980f9c9ac0bc 100644
--- a/include/linux/nvmem-consumer.h
+++ b/include/linux/nvmem-consumer.h
@@ -25,6 +25,7 @@ struct nvmem_cell_info {
 	unsigned int		bytes;
 	unsigned int		bit_offset;
 	unsigned int		nbits;
+	struct device_node	*np;
 };
 
 /**
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells
  2022-02-28  9:33 [PATCH 1/2] nvmem: core: support passing DT node in cell info Rafał Miłecki
@ 2022-02-28  9:33 ` Rafał Miłecki
  2022-04-08 10:20 ` [PATCH 1/2] nvmem: core: support passing DT node in cell info Srinivas Kandagatla
  1 sibling, 0 replies; 3+ messages in thread
From: Rafał Miłecki @ 2022-02-28  9:33 UTC (permalink / raw)
  To: Srinivas Kandagatla
  Cc: Rob Herring, Krzysztof Kozlowski, Florian Fainelli,
	Hauke Mehrtens, bcm-kernel-feedback-list, devicetree,
	linux-arm-kernel, linux-kernel, Rafał Miłecki

From: Rafał Miłecki <rafal@milecki.pl>

DT binding for Broadcom's NVRAM supports specifying NVMEM cells as NVMEM
device (provider) subnodes. Look for such subnodes when collecing NVMEM
cells. This allows NVMEM consumers to use NVRAM variables.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/nvmem/brcm_nvram.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c
index 439f00b9eef6..450b927691c3 100644
--- a/drivers/nvmem/brcm_nvram.c
+++ b/drivers/nvmem/brcm_nvram.c
@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/nvmem-consumer.h>
 #include <linux/nvmem-provider.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
@@ -72,6 +73,7 @@ static int brcm_nvram_add_cells(struct brcm_nvram *priv, uint8_t *data,
 			return -ENOMEM;
 		priv->cells[idx].offset = value - (char *)data;
 		priv->cells[idx].bytes = strlen(value);
+		priv->cells[idx].np = of_get_child_by_name(dev->of_node, priv->cells[idx].name);
 	}
 
 	return 0;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] nvmem: core: support passing DT node in cell info
  2022-02-28  9:33 [PATCH 1/2] nvmem: core: support passing DT node in cell info Rafał Miłecki
  2022-02-28  9:33 ` [PATCH 2/2] nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells Rafał Miłecki
@ 2022-04-08 10:20 ` Srinivas Kandagatla
  1 sibling, 0 replies; 3+ messages in thread
From: Srinivas Kandagatla @ 2022-04-08 10:20 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Rob Herring, Krzysztof Kozlowski, Florian Fainelli,
	Hauke Mehrtens, bcm-kernel-feedback-list, devicetree,
	linux-arm-kernel, linux-kernel, Rafał Miłecki



On 28/02/2022 09:33, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> Some hardware may have NVMEM cells described in Device Tree using
> individual nodes. Let drivers pass such nodes to the NVMEM subsystem so
> they can be later used by NVMEM consumers.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---

Applied both, thanks,

--srini
>   drivers/nvmem/core.c           | 1 +
>   include/linux/nvmem-consumer.h | 1 +
>   2 files changed, 2 insertions(+)
> 
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index 6d5702e715d6..5fcf2793b599 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -467,6 +467,7 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
>   
>   	cell->bit_offset = info->bit_offset;
>   	cell->nbits = info->nbits;
> +	cell->np = info->np;
>   
>   	if (cell->nbits)
>   		cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
> diff --git a/include/linux/nvmem-consumer.h b/include/linux/nvmem-consumer.h
> index c0c0cefc3b92..980f9c9ac0bc 100644
> --- a/include/linux/nvmem-consumer.h
> +++ b/include/linux/nvmem-consumer.h
> @@ -25,6 +25,7 @@ struct nvmem_cell_info {
>   	unsigned int		bytes;
>   	unsigned int		bit_offset;
>   	unsigned int		nbits;
> +	struct device_node	*np;
>   };
>   
>   /**

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-08 10:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28  9:33 [PATCH 1/2] nvmem: core: support passing DT node in cell info Rafał Miłecki
2022-02-28  9:33 ` [PATCH 2/2] nvmem: brcm_nvram: find Device Tree nodes for NVMEM cells Rafał Miłecki
2022-04-08 10:20 ` [PATCH 1/2] nvmem: core: support passing DT node in cell info Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).