aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvmem
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2016-05-02 14:36:13 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-06-25 10:42:55 -0400
commitba360fd040e3417ed1d90e89d681698f82002207 (patch)
tree88539e04e60fff8400d8bc825872f967fa4285d9 /drivers/nvmem
parent194c8581eb9b6d42e9232c7693d86d2ee3799986 (diff)
nvmem: mtk-efuse: remove nvmem regmap dependency
Regmap raw accessors are bus specific implementations, using regmap raw apis in nvmem breaks nvmem providers based on regmap mmio. This patch moves to nvmem support in the driver to use callback instead of regmap, which is what the nvmem core supports now. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r--drivers/nvmem/Kconfig1
-rw-r--r--drivers/nvmem/mtk-efuse.c47
2 files changed, 32 insertions, 16 deletions
diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index 3041d48e7155..5ff21892bcd6 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -50,7 +50,6 @@ config MTK_EFUSE
50 tristate "Mediatek SoCs EFUSE support" 50 tristate "Mediatek SoCs EFUSE support"
51 depends on ARCH_MEDIATEK || COMPILE_TEST 51 depends on ARCH_MEDIATEK || COMPILE_TEST
52 depends on HAS_IOMEM 52 depends on HAS_IOMEM
53 select REGMAP_MMIO
54 help 53 help
55 This is a driver to access hardware related data like sensor 54 This is a driver to access hardware related data like sensor
56 calibration, HDMI impedance etc. 55 calibration, HDMI impedance etc.
diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
index 9c49369beea5..32fd572e18c5 100644
--- a/drivers/nvmem/mtk-efuse.c
+++ b/drivers/nvmem/mtk-efuse.c
@@ -14,15 +14,35 @@
14 14
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/io.h>
17#include <linux/nvmem-provider.h> 18#include <linux/nvmem-provider.h>
18#include <linux/platform_device.h> 19#include <linux/platform_device.h>
19#include <linux/regmap.h>
20 20
21static struct regmap_config mtk_regmap_config = { 21static int mtk_reg_read(void *context,
22 .reg_bits = 32, 22 unsigned int reg, void *_val, size_t bytes)
23 .val_bits = 32, 23{
24 .reg_stride = 4, 24 void __iomem *base = context;
25}; 25 u32 *val = _val;
26 int i = 0, words = bytes / 4;
27
28 while (words--)
29 *val++ = readl(base + reg + (i++ * 4));
30
31 return 0;
32}
33
34static int mtk_reg_write(void *context,
35 unsigned int reg, void *_val, size_t bytes)
36{
37 void __iomem *base = context;
38 u32 *val = _val;
39 int i = 0, words = bytes / 4;
40
41 while (words--)
42 writel(*val++, base + reg + (i++ * 4));
43
44 return 0;
45}
26 46
27static int mtk_efuse_probe(struct platform_device *pdev) 47static int mtk_efuse_probe(struct platform_device *pdev)
28{ 48{
@@ -30,7 +50,6 @@ static int mtk_efuse_probe(struct platform_device *pdev)
30 struct resource *res; 50 struct resource *res;
31 struct nvmem_device *nvmem; 51 struct nvmem_device *nvmem;
32 struct nvmem_config *econfig; 52 struct nvmem_config *econfig;
33 struct regmap *regmap;
34 void __iomem *base; 53 void __iomem *base;
35 54
36 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 55 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -42,14 +61,12 @@ static int mtk_efuse_probe(struct platform_device *pdev)
42 if (!econfig) 61 if (!econfig)
43 return -ENOMEM; 62 return -ENOMEM;
44 63
45 mtk_regmap_config.max_register = resource_size(res) - 1; 64 econfig->stride = 4;
46 65 econfig->word_size = 4;
47 regmap = devm_regmap_init_mmio(dev, base, &mtk_regmap_config); 66 econfig->reg_read = mtk_reg_read;
48 if (IS_ERR(regmap)) { 67 econfig->reg_write = mtk_reg_write;
49 dev_err(dev, "regmap init failed\n"); 68 econfig->size = resource_size(res);
50 return PTR_ERR(regmap); 69 econfig->priv = base;
51 }
52
53 econfig->dev = dev; 70 econfig->dev = dev;
54 econfig->owner = THIS_MODULE; 71 econfig->owner = THIS_MODULE;
55 nvmem = nvmem_register(econfig); 72 nvmem = nvmem_register(econfig);