2021-11-07 16:47:20

by Chunfeng Yun

[permalink] [raw]
Subject: [PATCH 1/6] dt-bindings: nvmem: mediatek: add support bits property

Add support bits property, will satisfy more consumers.

Signed-off-by: Chunfeng Yun <[email protected]>
---
Need convert mtk-efuse.txt into yaml first?
---
Documentation/devicetree/bindings/nvmem/mtk-efuse.txt | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/nvmem/mtk-efuse.txt b/Documentation/devicetree/bindings/nvmem/mtk-efuse.txt
index b6791702bcfc..ec70c5b7a340 100644
--- a/Documentation/devicetree/bindings/nvmem/mtk-efuse.txt
+++ b/Documentation/devicetree/bindings/nvmem/mtk-efuse.txt
@@ -10,6 +10,7 @@ Required properties:
"mediatek,mt8192-efuse", "mediatek,efuse": for MT8192
"mediatek,mt8516-efuse", "mediatek,efuse": for MT8516
- reg: Should contain registers location and length
+- bits: contain the bits range by offset and size

= Data cells =
Are child nodes of MTK-EFUSE, bindings of which as described in
--
2.18.0


2021-11-07 16:47:21

by Chunfeng Yun

[permalink] [raw]
Subject: [PATCH 3/6] nvmem: mtk-efuse: support minimum one byte access stride and granularity

In order to support nvmem bits property, should support minimum 1 byte
read stride and minimum 1 byte read granularity at the same time.

Signed-off-by: Chunfeng Yun <[email protected]>
---
drivers/nvmem/mtk-efuse.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
index 6a537d959f14..e9a375dd84af 100644
--- a/drivers/nvmem/mtk-efuse.c
+++ b/drivers/nvmem/mtk-efuse.c
@@ -19,11 +19,12 @@ static int mtk_reg_read(void *context,
unsigned int reg, void *_val, size_t bytes)
{
struct mtk_efuse_priv *priv = context;
- u32 *val = _val;
- int i = 0, words = bytes / 4;
+ void __iomem *addr = priv->base + reg;
+ u8 *val = _val;
+ int i;

- while (words--)
- *val++ = readl(priv->base + reg + (i++ * 4));
+ for (i = 0; i < bytes; i++, val++)
+ *val = readb(addr + i);

return 0;
}
@@ -45,8 +46,8 @@ static int mtk_efuse_probe(struct platform_device *pdev)
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);

- econfig.stride = 4;
- econfig.word_size = 4;
+ econfig.stride = 1;
+ econfig.word_size = 1;
econfig.reg_read = mtk_reg_read;
econfig.size = resource_size(res);
econfig.priv = priv;
--
2.18.0

2021-11-12 22:41:56

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH 1/6] dt-bindings: nvmem: mediatek: add support bits property

On Sun, 07 Nov 2021 15:56:41 +0800, Chunfeng Yun wrote:
> Add support bits property, will satisfy more consumers.
>
> Signed-off-by: Chunfeng Yun <[email protected]>
> ---
> Need convert mtk-efuse.txt into yaml first?
> ---
> Documentation/devicetree/bindings/nvmem/mtk-efuse.txt | 1 +
> 1 file changed, 1 insertion(+)
>

Acked-by: Rob Herring <[email protected]>

2021-11-19 17:18:27

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH 3/6] nvmem: mtk-efuse: support minimum one byte access stride and granularity



On 07/11/2021 07:56, Chunfeng Yun wrote:
> In order to support nvmem bits property, should support minimum 1 byte
> read stride and minimum 1 byte read granularity at the same time.
>
> Signed-off-by: Chunfeng Yun <[email protected]>
Applied thanks,

--srini

> ---
> drivers/nvmem/mtk-efuse.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
> index 6a537d959f14..e9a375dd84af 100644
> --- a/drivers/nvmem/mtk-efuse.c
> +++ b/drivers/nvmem/mtk-efuse.c
> @@ -19,11 +19,12 @@ static int mtk_reg_read(void *context,
> unsigned int reg, void *_val, size_t bytes)
> {
> struct mtk_efuse_priv *priv = context;
> - u32 *val = _val;
> - int i = 0, words = bytes / 4;
> + void __iomem *addr = priv->base + reg;
> + u8 *val = _val;
> + int i;
>
> - while (words--)
> - *val++ = readl(priv->base + reg + (i++ * 4));
> + for (i = 0; i < bytes; i++, val++)
> + *val = readb(addr + i);
>
> return 0;
> }
> @@ -45,8 +46,8 @@ static int mtk_efuse_probe(struct platform_device *pdev)
> if (IS_ERR(priv->base))
> return PTR_ERR(priv->base);
>
> - econfig.stride = 4;
> - econfig.word_size = 4;
> + econfig.stride = 1;
> + econfig.word_size = 1;
> econfig.reg_read = mtk_reg_read;
> econfig.size = resource_size(res);
> econfig.priv = priv;
>

2021-11-19 17:18:34

by Srinivas Kandagatla

[permalink] [raw]
Subject: Re: [PATCH 1/6] dt-bindings: nvmem: mediatek: add support bits property



On 07/11/2021 07:56, Chunfeng Yun wrote:
> Add support bits property, will satisfy more consumers.
>
> Signed-off-by: Chunfeng Yun <[email protected]>


Applied thanks,

--srini
> ---
> Need convert mtk-efuse.txt into yaml first?
> ---
> Documentation/devicetree/bindings/nvmem/mtk-efuse.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/nvmem/mtk-efuse.txt b/Documentation/devicetree/bindings/nvmem/mtk-efuse.txt
> index b6791702bcfc..ec70c5b7a340 100644
> --- a/Documentation/devicetree/bindings/nvmem/mtk-efuse.txt
> +++ b/Documentation/devicetree/bindings/nvmem/mtk-efuse.txt
> @@ -10,6 +10,7 @@ Required properties:
> "mediatek,mt8192-efuse", "mediatek,efuse": for MT8192
> "mediatek,mt8516-efuse", "mediatek,efuse": for MT8516
> - reg: Should contain registers location and length
> +- bits: contain the bits range by offset and size
>
> = Data cells =
> Are child nodes of MTK-EFUSE, bindings of which as described in
>