diff options
author | Srinivas Kandagatla <srinivas.kandagatla@linaro.org> | 2016-04-24 15:28:10 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-05-01 17:01:00 -0400 |
commit | 9c7b16eb35d283f00ba278b62b5115dacdf12dd7 (patch) | |
tree | 1a8bd73aa8dfc3123ae54681e83a6c38cec34d97 | |
parent | 2c0235c6041857b45f4d2f368efb9866420b6ff2 (diff) |
nvmem: sunxi-sid: remove nvmem regmap dependency
This patch moves to nvmem support in the driver to use callback
instead of regmap.
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/nvmem/Kconfig | 1 | ||||
-rw-r--r-- | drivers/nvmem/sunxi_sid.c | 54 |
2 files changed, 9 insertions, 46 deletions
diff --git a/drivers/nvmem/Kconfig b/drivers/nvmem/Kconfig index df05b1a24514..3041d48e7155 100644 --- a/drivers/nvmem/Kconfig +++ b/drivers/nvmem/Kconfig | |||
@@ -83,7 +83,6 @@ config ROCKCHIP_EFUSE | |||
83 | config NVMEM_SUNXI_SID | 83 | config NVMEM_SUNXI_SID |
84 | tristate "Allwinner SoCs SID support" | 84 | tristate "Allwinner SoCs SID support" |
85 | depends on ARCH_SUNXI | 85 | depends on ARCH_SUNXI |
86 | select REGMAP_MMIO | ||
87 | help | 86 | help |
88 | This is a driver for the 'security ID' available on various Allwinner | 87 | This is a driver for the 'security ID' available on various Allwinner |
89 | devices. | 88 | devices. |
diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c index bc88b4084055..1567ccca8de3 100644 --- a/drivers/nvmem/sunxi_sid.c +++ b/drivers/nvmem/sunxi_sid.c | |||
@@ -21,13 +21,14 @@ | |||
21 | #include <linux/nvmem-provider.h> | 21 | #include <linux/nvmem-provider.h> |
22 | #include <linux/of.h> | 22 | #include <linux/of.h> |
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/regmap.h> | ||
25 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
26 | #include <linux/random.h> | 25 | #include <linux/random.h> |
27 | 26 | ||
28 | static struct nvmem_config econfig = { | 27 | static struct nvmem_config econfig = { |
29 | .name = "sunxi-sid", | 28 | .name = "sunxi-sid", |
30 | .read_only = true, | 29 | .read_only = true, |
30 | .stride = 4, | ||
31 | .word_size = 1, | ||
31 | .owner = THIS_MODULE, | 32 | .owner = THIS_MODULE, |
32 | }; | 33 | }; |
33 | 34 | ||
@@ -51,54 +52,23 @@ static u8 sunxi_sid_read_byte(const struct sunxi_sid *sid, | |||
51 | return sid_key; /* Only return the last byte */ | 52 | return sid_key; /* Only return the last byte */ |
52 | } | 53 | } |
53 | 54 | ||
54 | static int sunxi_sid_read(void *context, | 55 | static int sunxi_sid_read(void *context, unsigned int offset, |
55 | const void *reg, size_t reg_size, | 56 | void *val, size_t bytes) |
56 | void *val, size_t val_size) | ||
57 | { | 57 | { |
58 | struct sunxi_sid *sid = context; | 58 | struct sunxi_sid *sid = context; |
59 | unsigned int offset = *(u32 *)reg; | ||
60 | u8 *buf = val; | 59 | u8 *buf = val; |
61 | 60 | ||
62 | while (val_size) { | 61 | while (bytes--) |
63 | *buf++ = sunxi_sid_read_byte(sid, offset); | 62 | *buf++ = sunxi_sid_read_byte(sid, offset++); |
64 | val_size--; | ||
65 | offset++; | ||
66 | } | ||
67 | |||
68 | return 0; | ||
69 | } | ||
70 | 63 | ||
71 | static int sunxi_sid_write(void *context, const void *data, size_t count) | ||
72 | { | ||
73 | /* Unimplemented, dummy to keep regmap core happy */ | ||
74 | return 0; | 64 | return 0; |
75 | } | 65 | } |
76 | 66 | ||
77 | static struct regmap_bus sunxi_sid_bus = { | ||
78 | .read = sunxi_sid_read, | ||
79 | .write = sunxi_sid_write, | ||
80 | .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, | ||
81 | .val_format_endian_default = REGMAP_ENDIAN_NATIVE, | ||
82 | }; | ||
83 | |||
84 | static bool sunxi_sid_writeable_reg(struct device *dev, unsigned int reg) | ||
85 | { | ||
86 | return false; | ||
87 | } | ||
88 | |||
89 | static struct regmap_config sunxi_sid_regmap_config = { | ||
90 | .reg_bits = 32, | ||
91 | .val_bits = 8, | ||
92 | .reg_stride = 1, | ||
93 | .writeable_reg = sunxi_sid_writeable_reg, | ||
94 | }; | ||
95 | |||
96 | static int sunxi_sid_probe(struct platform_device *pdev) | 67 | static int sunxi_sid_probe(struct platform_device *pdev) |
97 | { | 68 | { |
98 | struct device *dev = &pdev->dev; | 69 | struct device *dev = &pdev->dev; |
99 | struct resource *res; | 70 | struct resource *res; |
100 | struct nvmem_device *nvmem; | 71 | struct nvmem_device *nvmem; |
101 | struct regmap *regmap; | ||
102 | struct sunxi_sid *sid; | 72 | struct sunxi_sid *sid; |
103 | int ret, i, size; | 73 | int ret, i, size; |
104 | char *randomness; | 74 | char *randomness; |
@@ -113,16 +83,10 @@ static int sunxi_sid_probe(struct platform_device *pdev) | |||
113 | return PTR_ERR(sid->base); | 83 | return PTR_ERR(sid->base); |
114 | 84 | ||
115 | size = resource_size(res) - 1; | 85 | size = resource_size(res) - 1; |
116 | sunxi_sid_regmap_config.max_register = size; | 86 | econfig.size = resource_size(res); |
117 | |||
118 | regmap = devm_regmap_init(dev, &sunxi_sid_bus, sid, | ||
119 | &sunxi_sid_regmap_config); | ||
120 | if (IS_ERR(regmap)) { | ||
121 | dev_err(dev, "regmap init failed\n"); | ||
122 | return PTR_ERR(regmap); | ||
123 | } | ||
124 | |||
125 | econfig.dev = dev; | 87 | econfig.dev = dev; |
88 | econfig.reg_read = sunxi_sid_read; | ||
89 | econfig.priv = sid; | ||
126 | nvmem = nvmem_register(&econfig); | 90 | nvmem = nvmem_register(&econfig); |
127 | if (IS_ERR(nvmem)) | 91 | if (IS_ERR(nvmem)) |
128 | return PTR_ERR(nvmem); | 92 | return PTR_ERR(nvmem); |