785bfe53f547ab2020367a0005196f4de42a075e
[openwrt/staging/mans0n.git] /
1 From 98e2c4efae214fb7086cac9117616eb6ea11475d Mon Sep 17 00:00:00 2001
2 From: Chunfeng Yun <chunfeng.yun@mediatek.com>
3 Date: Thu, 9 Dec 2021 17:42:34 +0000
4 Subject: [PATCH] nvmem: mtk-efuse: support minimum one byte access stride and
5 granularity
6
7 In order to support nvmem bits property, should support minimum 1 byte
8 read stride and minimum 1 byte read granularity at the same time.
9
10 Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
11 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
12 Link: https://lore.kernel.org/r/20211209174235.14049-4-srinivas.kandagatla@linaro.org
13 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
14 ---
15 drivers/nvmem/mtk-efuse.c | 13 +++++++------
16 1 file changed, 7 insertions(+), 6 deletions(-)
17
18 --- a/drivers/nvmem/mtk-efuse.c
19 +++ b/drivers/nvmem/mtk-efuse.c
20 @@ -19,11 +19,12 @@ static int mtk_reg_read(void *context,
21 unsigned int reg, void *_val, size_t bytes)
22 {
23 struct mtk_efuse_priv *priv = context;
24 - u32 *val = _val;
25 - int i = 0, words = bytes / 4;
26 + void __iomem *addr = priv->base + reg;
27 + u8 *val = _val;
28 + int i;
29
30 - while (words--)
31 - *val++ = readl(priv->base + reg + (i++ * 4));
32 + for (i = 0; i < bytes; i++, val++)
33 + *val = readb(addr + i);
34
35 return 0;
36 }
37 @@ -45,8 +46,8 @@ static int mtk_efuse_probe(struct platfo
38 if (IS_ERR(priv->base))
39 return PTR_ERR(priv->base);
40
41 - econfig.stride = 4;
42 - econfig.word_size = 4;
43 + econfig.stride = 1;
44 + econfig.word_size = 1;
45 econfig.reg_read = mtk_reg_read;
46 econfig.size = resource_size(res);
47 econfig.priv = priv;