aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/nvmem
diff options
context:
space:
mode:
authorSrinivas Kandagatla <srinivas.kandagatla@linaro.org>2015-07-27 07:15:00 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-08-05 16:44:23 -0400
commit4ab11996b489ad65092216315484824ed32018f8 (patch)
treed8b4c879cbf20c51358b0a8d32429d627726f143 /drivers/nvmem
parent354ebb541dfa37a83395e5a9b7d68c34f80fffc0 (diff)
nvmem: qfprom: Add Qualcomm QFPROM support.
This patch adds QFPROM support driver which is used by other drivers like thermal sensor and cpufreq. On MSM parts there are some efuses (called qfprom) these fuses store things like calibration data, speed bins.. etc. Drivers like cpufreq, thermal sensors would read out this data for configuring the driver. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Tested-by: Philipp Zabel <p.zabel@pengutronix.de> Tested-by: Rajendra Nayak <rnayak@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r--drivers/nvmem/Kconfig15
-rw-r--r--drivers/nvmem/Makefile4
-rw-r--r--drivers/nvmem/qfprom.c85
3 files changed, 104 insertions, 0 deletions
diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig
index de90c82d891b..fa85805bbdb7 100644
--- a/drivers/nvmem/Kconfig
+++ b/drivers/nvmem/Kconfig
@@ -11,3 +11,18 @@ menuconfig NVMEM
11 will be called nvmem_core. 11 will be called nvmem_core.
12 12
13 If unsure, say no. 13 If unsure, say no.
14
15if NVMEM
16
17config QCOM_QFPROM
18 tristate "QCOM QFPROM Support"
19 depends on ARCH_QCOM || COMPILE_TEST
20 select REGMAP_MMIO
21 help
22 Say y here to enable QFPROM support. The QFPROM provides access
23 functions for QFPROM data to rest of the drivers via nvmem interface.
24
25 This driver can also be built as a module. If so, the module
26 will be called nvmem_qfprom.
27
28endif
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile
index 6df2c6952ad5..ff44fe99c7d2 100644
--- a/drivers/nvmem/Makefile
+++ b/drivers/nvmem/Makefile
@@ -4,3 +4,7 @@
4 4
5obj-$(CONFIG_NVMEM) += nvmem_core.o 5obj-$(CONFIG_NVMEM) += nvmem_core.o
6nvmem_core-y := core.o 6nvmem_core-y := core.o
7
8# Devices
9obj-$(CONFIG_QCOM_QFPROM) += nvmem_qfprom.o
10nvmem_qfprom-y := qfprom.o
diff --git a/drivers/nvmem/qfprom.c b/drivers/nvmem/qfprom.c
new file mode 100644
index 000000000000..afb67e7eeee4
--- /dev/null
+++ b/drivers/nvmem/qfprom.c
@@ -0,0 +1,85 @@
1/*
2 * Copyright (C) 2015 Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/device.h>
15#include <linux/module.h>
16#include <linux/nvmem-provider.h>
17#include <linux/platform_device.h>
18#include <linux/regmap.h>
19
20static struct regmap_config qfprom_regmap_config = {
21 .reg_bits = 32,
22 .val_bits = 8,
23 .reg_stride = 1,
24};
25
26static struct nvmem_config econfig = {
27 .name = "qfprom",
28 .owner = THIS_MODULE,
29};
30
31static int qfprom_remove(struct platform_device *pdev)
32{
33 struct nvmem_device *nvmem = platform_get_drvdata(pdev);
34
35 return nvmem_unregister(nvmem);
36}
37
38static int qfprom_probe(struct platform_device *pdev)
39{
40 struct device *dev = &pdev->dev;
41 struct resource *res;
42 struct nvmem_device *nvmem;
43 struct regmap *regmap;
44 void __iomem *base;
45
46 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
47 base = devm_ioremap_resource(dev, res);
48 if (IS_ERR(base))
49 return PTR_ERR(base);
50
51 qfprom_regmap_config.max_register = resource_size(res) - 1;
52
53 regmap = devm_regmap_init_mmio(dev, base, &qfprom_regmap_config);
54 if (IS_ERR(regmap)) {
55 dev_err(dev, "regmap init failed\n");
56 return PTR_ERR(regmap);
57 }
58 econfig.dev = dev;
59 nvmem = nvmem_register(&econfig);
60 if (IS_ERR(nvmem))
61 return PTR_ERR(nvmem);
62
63 platform_set_drvdata(pdev, nvmem);
64
65 return 0;
66}
67
68static const struct of_device_id qfprom_of_match[] = {
69 { .compatible = "qcom,qfprom",},
70 {/* sentinel */},
71};
72MODULE_DEVICE_TABLE(of, qfprom_of_match);
73
74static struct platform_driver qfprom_driver = {
75 .probe = qfprom_probe,
76 .remove = qfprom_remove,
77 .driver = {
78 .name = "qcom,qfprom",
79 .of_match_table = qfprom_of_match,
80 },
81};
82module_platform_driver(qfprom_driver);
83MODULE_AUTHOR("Srinivas Kandagatla <srinivas.kandagatla@linaro.org>");
84MODULE_DESCRIPTION("Qualcomm QFPROM driver");
85MODULE_LICENSE("GPL v2");