diff options
author | Keiji Hayashibara <hayashibara.keiji@socionext.com> | 2017-10-24 05:54:26 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-11-08 08:19:05 -0500 |
commit | 71c5dd5002b11d240c9b0e4adc972903183000aa (patch) | |
tree | ef72168e272442c2b119ba7ee4c3a60458b4b694 | |
parent | 2a96c818f484bcc16f42a09b030a470f2b44df04 (diff) |
nvmem: uniphier: add UniPhier eFuse driver
Add eFuse driver for Socionext UniPhier series SoC.
Note that eFuse device is under soc-glue and this register
implements as read only.
Signed-off-by: Keiji Hayashibara <hayashibara.keiji@socionext.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/nvmem/Kconfig | 11 | ||||
-rw-r--r-- | drivers/nvmem/Makefile | 2 | ||||
-rw-r--r-- | drivers/nvmem/uniphier-efuse.c | 97 |
3 files changed, 110 insertions, 0 deletions
diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index eb09916744bf..ff505af064ba 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig | |||
@@ -123,6 +123,17 @@ config NVMEM_SUNXI_SID | |||
123 | This driver can also be built as a module. If so, the module | 123 | This driver can also be built as a module. If so, the module |
124 | will be called nvmem_sunxi_sid. | 124 | will be called nvmem_sunxi_sid. |
125 | 125 | ||
126 | config UNIPHIER_EFUSE | ||
127 | tristate "UniPhier SoCs eFuse support" | ||
128 | depends on ARCH_UNIPHIER || COMPILE_TEST | ||
129 | depends on HAS_IOMEM | ||
130 | help | ||
131 | This is a simple driver to dump specified values of UniPhier SoC | ||
132 | from eFuse. | ||
133 | |||
134 | This driver can also be built as a module. If so, the module | ||
135 | will be called nvmem-uniphier-efuse. | ||
136 | |||
126 | config NVMEM_VF610_OCOTP | 137 | config NVMEM_VF610_OCOTP |
127 | tristate "VF610 SoC OCOTP support" | 138 | tristate "VF610 SoC OCOTP support" |
128 | depends on SOC_VF610 || COMPILE_TEST | 139 | depends on SOC_VF610 || COMPILE_TEST |
diff --git a/drivers/nvmem/Makefile b/drivers/nvmem/Makefile index 362f394da65d..64849e946d50 100644 --- a/drivers/nvmem/Makefile +++ b/drivers/nvmem/Makefile | |||
@@ -26,6 +26,8 @@ obj-$(CONFIG_ROCKCHIP_EFUSE) += nvmem_rockchip_efuse.o | |||
26 | nvmem_rockchip_efuse-y := rockchip-efuse.o | 26 | nvmem_rockchip_efuse-y := rockchip-efuse.o |
27 | obj-$(CONFIG_NVMEM_SUNXI_SID) += nvmem_sunxi_sid.o | 27 | obj-$(CONFIG_NVMEM_SUNXI_SID) += nvmem_sunxi_sid.o |
28 | nvmem_sunxi_sid-y := sunxi_sid.o | 28 | nvmem_sunxi_sid-y := sunxi_sid.o |
29 | obj-$(CONFIG_UNIPHIER_EFUSE) += nvmem-uniphier-efuse.o | ||
30 | nvmem-uniphier-efuse-y := uniphier-efuse.o | ||
29 | obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o | 31 | obj-$(CONFIG_NVMEM_VF610_OCOTP) += nvmem-vf610-ocotp.o |
30 | nvmem-vf610-ocotp-y := vf610-ocotp.o | 32 | nvmem-vf610-ocotp-y := vf610-ocotp.o |
31 | obj-$(CONFIG_MESON_EFUSE) += nvmem_meson_efuse.o | 33 | obj-$(CONFIG_MESON_EFUSE) += nvmem_meson_efuse.o |
diff --git a/drivers/nvmem/uniphier-efuse.c b/drivers/nvmem/uniphier-efuse.c new file mode 100644 index 000000000000..9d278b4e1dc7 --- /dev/null +++ b/drivers/nvmem/uniphier-efuse.c | |||
@@ -0,0 +1,97 @@ | |||
1 | /* | ||
2 | * UniPhier eFuse driver | ||
3 | * | ||
4 | * Copyright (C) 2017 Socionext Inc. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | */ | ||
15 | |||
16 | #include <linux/device.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/nvmem-provider.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | |||
22 | struct uniphier_efuse_priv { | ||
23 | void __iomem *base; | ||
24 | }; | ||
25 | |||
26 | static int uniphier_reg_read(void *context, | ||
27 | unsigned int reg, void *_val, size_t bytes) | ||
28 | { | ||
29 | struct uniphier_efuse_priv *priv = context; | ||
30 | u32 *val = _val; | ||
31 | int offs; | ||
32 | |||
33 | for (offs = 0; offs < bytes; offs += sizeof(u32)) | ||
34 | *val++ = readl(priv->base + reg + offs); | ||
35 | |||
36 | return 0; | ||
37 | } | ||
38 | |||
39 | static int uniphier_efuse_probe(struct platform_device *pdev) | ||
40 | { | ||
41 | struct device *dev = &pdev->dev; | ||
42 | struct resource *res; | ||
43 | struct nvmem_device *nvmem; | ||
44 | struct nvmem_config econfig = {}; | ||
45 | struct uniphier_efuse_priv *priv; | ||
46 | |||
47 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | ||
48 | if (!priv) | ||
49 | return -ENOMEM; | ||
50 | |||
51 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
52 | priv->base = devm_ioremap_resource(dev, res); | ||
53 | if (IS_ERR(priv->base)) | ||
54 | return PTR_ERR(priv->base); | ||
55 | |||
56 | econfig.stride = 4; | ||
57 | econfig.word_size = 4; | ||
58 | econfig.read_only = true; | ||
59 | econfig.reg_read = uniphier_reg_read; | ||
60 | econfig.size = resource_size(res); | ||
61 | econfig.priv = priv; | ||
62 | econfig.dev = dev; | ||
63 | nvmem = nvmem_register(&econfig); | ||
64 | if (IS_ERR(nvmem)) | ||
65 | return PTR_ERR(nvmem); | ||
66 | |||
67 | platform_set_drvdata(pdev, nvmem); | ||
68 | |||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | static int uniphier_efuse_remove(struct platform_device *pdev) | ||
73 | { | ||
74 | struct nvmem_device *nvmem = platform_get_drvdata(pdev); | ||
75 | |||
76 | return nvmem_unregister(nvmem); | ||
77 | } | ||
78 | |||
79 | static const struct of_device_id uniphier_efuse_of_match[] = { | ||
80 | { .compatible = "socionext,uniphier-efuse",}, | ||
81 | {/* sentinel */}, | ||
82 | }; | ||
83 | MODULE_DEVICE_TABLE(of, uniphier_efuse_of_match); | ||
84 | |||
85 | static struct platform_driver uniphier_efuse_driver = { | ||
86 | .probe = uniphier_efuse_probe, | ||
87 | .remove = uniphier_efuse_remove, | ||
88 | .driver = { | ||
89 | .name = "uniphier-efuse", | ||
90 | .of_match_table = uniphier_efuse_of_match, | ||
91 | }, | ||
92 | }; | ||
93 | module_platform_driver(uniphier_efuse_driver); | ||
94 | |||
95 | MODULE_AUTHOR("Keiji Hayashibara <hayashibara.keiji@socionext.com>"); | ||
96 | MODULE_DESCRIPTION("UniPhier eFuse driver"); | ||
97 | MODULE_LICENSE("GPL v2"); | ||