Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Srinivas Kandagatla and committed by
Greg Kroah-Hartman
ba360fd0 194c8581

+32 -16
-1
drivers/nvmem/Kconfig
··· 50 50 tristate "Mediatek SoCs EFUSE support" 51 51 depends on ARCH_MEDIATEK || COMPILE_TEST 52 52 depends on HAS_IOMEM 53 - select REGMAP_MMIO 54 53 help 55 54 This is a driver to access hardware related data like sensor 56 55 calibration, HDMI impedance etc.
+32 -15
drivers/nvmem/mtk-efuse.c
··· 14 14 15 15 #include <linux/device.h> 16 16 #include <linux/module.h> 17 + #include <linux/io.h> 17 18 #include <linux/nvmem-provider.h> 18 19 #include <linux/platform_device.h> 19 - #include <linux/regmap.h> 20 20 21 - static struct regmap_config mtk_regmap_config = { 22 - .reg_bits = 32, 23 - .val_bits = 32, 24 - .reg_stride = 4, 25 - }; 21 + static int mtk_reg_read(void *context, 22 + unsigned int reg, void *_val, size_t bytes) 23 + { 24 + void __iomem *base = context; 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 + 34 + static 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 27 47 static int mtk_efuse_probe(struct platform_device *pdev) 28 48 { ··· 50 30 struct resource *res; 51 31 struct nvmem_device *nvmem; 52 32 struct nvmem_config *econfig; 53 - struct regmap *regmap; 54 33 void __iomem *base; 55 34 56 35 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ··· 61 42 if (!econfig) 62 43 return -ENOMEM; 63 44 64 - mtk_regmap_config.max_register = resource_size(res) - 1; 65 - 66 - regmap = devm_regmap_init_mmio(dev, base, &mtk_regmap_config); 67 - if (IS_ERR(regmap)) { 68 - dev_err(dev, "regmap init failed\n"); 69 - return PTR_ERR(regmap); 70 - } 71 - 45 + econfig->stride = 4; 46 + econfig->word_size = 4; 47 + econfig->reg_read = mtk_reg_read; 48 + econfig->reg_write = mtk_reg_write; 49 + econfig->size = resource_size(res); 50 + econfig->priv = base; 72 51 econfig->dev = dev; 73 52 econfig->owner = THIS_MODULE; 74 53 nvmem = nvmem_register(econfig);