diff options
author | Paul Bolle <pebolle@tiscali.nl> | 2014-04-15 04:55:18 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2014-04-16 08:40:18 -0400 |
commit | 8ece117104068de3e0e50d1601bca15f58e912fd (patch) | |
tree | 69505b88a371494175109f4cd50fa5fa91323513 /drivers/char | |
parent | 5347ee8eff1965f5a63a3da4a13aa92aed3e682d (diff) |
hwrng: picoxcell - remove unbuildable picoxcell TRNG
The driver for the "Picochip picoXcell true random number generator" was
added in v2.6.39. Its Kconfig symbol has always depended on
PICOXCELL_PC3X3. But that Kconfig symbol has never been part of the
tree. This means this driver has never been buildable. Let's remove it.
It can be re-added if its dependencies are actually part of the tree.
Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Acked-by: Jamie Iles <jamie@jamieiles.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hw_random/Kconfig | 13 | ||||
-rw-r--r-- | drivers/char/hw_random/Makefile | 1 | ||||
-rw-r--r-- | drivers/char/hw_random/picoxcell-rng.c | 181 |
3 files changed, 0 insertions, 195 deletions
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig index 58a15f28789f..38cfae686cc4 100644 --- a/drivers/char/hw_random/Kconfig +++ b/drivers/char/hw_random/Kconfig | |||
@@ -255,19 +255,6 @@ config HW_RANDOM_NOMADIK | |||
255 | 255 | ||
256 | If unsure, say Y. | 256 | If unsure, say Y. |
257 | 257 | ||
258 | config HW_RANDOM_PICOXCELL | ||
259 | tristate "Picochip picoXcell true random number generator support" | ||
260 | depends on ARCH_PICOXCELL && PICOXCELL_PC3X3 | ||
261 | default HW_RANDOM | ||
262 | ---help--- | ||
263 | This driver provides kernel-side support for the Random Number | ||
264 | Generator hardware found on Picochip PC3x3 and later devices. | ||
265 | |||
266 | To compile this driver as a module, choose M here: the | ||
267 | module will be called picoxcell-rng. | ||
268 | |||
269 | If unsure, say Y. | ||
270 | |||
271 | config HW_RANDOM_PPC4XX | 258 | config HW_RANDOM_PPC4XX |
272 | tristate "PowerPC 4xx generic true random number generator support" | 259 | tristate "PowerPC 4xx generic true random number generator support" |
273 | depends on PPC && 4xx | 260 | depends on PPC && 4xx |
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile index 3ae7755a52e7..199ed283e149 100644 --- a/drivers/char/hw_random/Makefile +++ b/drivers/char/hw_random/Makefile | |||
@@ -22,7 +22,6 @@ obj-$(CONFIG_HW_RANDOM_TX4939) += tx4939-rng.o | |||
22 | obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o | 22 | obj-$(CONFIG_HW_RANDOM_MXC_RNGA) += mxc-rnga.o |
23 | obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o | 23 | obj-$(CONFIG_HW_RANDOM_OCTEON) += octeon-rng.o |
24 | obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o | 24 | obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o |
25 | obj-$(CONFIG_HW_RANDOM_PICOXCELL) += picoxcell-rng.o | ||
26 | obj-$(CONFIG_HW_RANDOM_PPC4XX) += ppc4xx-rng.o | 25 | obj-$(CONFIG_HW_RANDOM_PPC4XX) += ppc4xx-rng.o |
27 | obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o | 26 | obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o |
28 | obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o | 27 | obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o |
diff --git a/drivers/char/hw_random/picoxcell-rng.c b/drivers/char/hw_random/picoxcell-rng.c deleted file mode 100644 index eab5448ad56f..000000000000 --- a/drivers/char/hw_random/picoxcell-rng.c +++ /dev/null | |||
@@ -1,181 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2010-2011 Picochip Ltd., Jamie Iles | ||
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 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * All enquiries to support@picochip.com | ||
9 | */ | ||
10 | #include <linux/clk.h> | ||
11 | #include <linux/delay.h> | ||
12 | #include <linux/err.h> | ||
13 | #include <linux/hw_random.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | |||
19 | #define DATA_REG_OFFSET 0x0200 | ||
20 | #define CSR_REG_OFFSET 0x0278 | ||
21 | #define CSR_OUT_EMPTY_MASK (1 << 24) | ||
22 | #define CSR_FAULT_MASK (1 << 1) | ||
23 | #define TRNG_BLOCK_RESET_MASK (1 << 0) | ||
24 | #define TAI_REG_OFFSET 0x0380 | ||
25 | |||
26 | /* | ||
27 | * The maximum amount of time in microseconds to spend waiting for data if the | ||
28 | * core wants us to wait. The TRNG should generate 32 bits every 320ns so a | ||
29 | * timeout of 20us seems reasonable. The TRNG does builtin tests of the data | ||
30 | * for randomness so we can't always assume there is data present. | ||
31 | */ | ||
32 | #define PICO_TRNG_TIMEOUT 20 | ||
33 | |||
34 | static void __iomem *rng_base; | ||
35 | static struct clk *rng_clk; | ||
36 | static struct device *rng_dev; | ||
37 | |||
38 | static inline u32 picoxcell_trng_read_csr(void) | ||
39 | { | ||
40 | return __raw_readl(rng_base + CSR_REG_OFFSET); | ||
41 | } | ||
42 | |||
43 | static inline bool picoxcell_trng_is_empty(void) | ||
44 | { | ||
45 | return picoxcell_trng_read_csr() & CSR_OUT_EMPTY_MASK; | ||
46 | } | ||
47 | |||
48 | /* | ||
49 | * Take the random number generator out of reset and make sure the interrupts | ||
50 | * are masked. We shouldn't need to get large amounts of random bytes so just | ||
51 | * poll the status register. The hardware generates 32 bits every 320ns so we | ||
52 | * shouldn't have to wait long enough to warrant waiting for an IRQ. | ||
53 | */ | ||
54 | static void picoxcell_trng_start(void) | ||
55 | { | ||
56 | __raw_writel(0, rng_base + TAI_REG_OFFSET); | ||
57 | __raw_writel(0, rng_base + CSR_REG_OFFSET); | ||
58 | } | ||
59 | |||
60 | static void picoxcell_trng_reset(void) | ||
61 | { | ||
62 | __raw_writel(TRNG_BLOCK_RESET_MASK, rng_base + CSR_REG_OFFSET); | ||
63 | __raw_writel(TRNG_BLOCK_RESET_MASK, rng_base + TAI_REG_OFFSET); | ||
64 | picoxcell_trng_start(); | ||
65 | } | ||
66 | |||
67 | /* | ||
68 | * Get some random data from the random number generator. The hw_random core | ||
69 | * layer provides us with locking. | ||
70 | */ | ||
71 | static int picoxcell_trng_read(struct hwrng *rng, void *buf, size_t max, | ||
72 | bool wait) | ||
73 | { | ||
74 | int i; | ||
75 | |||
76 | /* Wait for some data to become available. */ | ||
77 | for (i = 0; i < PICO_TRNG_TIMEOUT && picoxcell_trng_is_empty(); ++i) { | ||
78 | if (!wait) | ||
79 | return 0; | ||
80 | |||
81 | udelay(1); | ||
82 | } | ||
83 | |||
84 | if (picoxcell_trng_read_csr() & CSR_FAULT_MASK) { | ||
85 | dev_err(rng_dev, "fault detected, resetting TRNG\n"); | ||
86 | picoxcell_trng_reset(); | ||
87 | return -EIO; | ||
88 | } | ||
89 | |||
90 | if (i == PICO_TRNG_TIMEOUT) | ||
91 | return 0; | ||
92 | |||
93 | *(u32 *)buf = __raw_readl(rng_base + DATA_REG_OFFSET); | ||
94 | return sizeof(u32); | ||
95 | } | ||
96 | |||
97 | static struct hwrng picoxcell_trng = { | ||
98 | .name = "picoxcell", | ||
99 | .read = picoxcell_trng_read, | ||
100 | }; | ||
101 | |||
102 | static int picoxcell_trng_probe(struct platform_device *pdev) | ||
103 | { | ||
104 | int ret; | ||
105 | struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
106 | |||
107 | rng_base = devm_ioremap_resource(&pdev->dev, mem); | ||
108 | if (IS_ERR(rng_base)) | ||
109 | return PTR_ERR(rng_base); | ||
110 | |||
111 | rng_clk = devm_clk_get(&pdev->dev, NULL); | ||
112 | if (IS_ERR(rng_clk)) { | ||
113 | dev_warn(&pdev->dev, "no clk\n"); | ||
114 | return PTR_ERR(rng_clk); | ||
115 | } | ||
116 | |||
117 | ret = clk_enable(rng_clk); | ||
118 | if (ret) { | ||
119 | dev_warn(&pdev->dev, "unable to enable clk\n"); | ||
120 | return ret; | ||
121 | } | ||
122 | |||
123 | picoxcell_trng_start(); | ||
124 | ret = hwrng_register(&picoxcell_trng); | ||
125 | if (ret) | ||
126 | goto err_register; | ||
127 | |||
128 | rng_dev = &pdev->dev; | ||
129 | dev_info(&pdev->dev, "pixoxcell random number generator active\n"); | ||
130 | |||
131 | return 0; | ||
132 | |||
133 | err_register: | ||
134 | clk_disable(rng_clk); | ||
135 | return ret; | ||
136 | } | ||
137 | |||
138 | static int picoxcell_trng_remove(struct platform_device *pdev) | ||
139 | { | ||
140 | hwrng_unregister(&picoxcell_trng); | ||
141 | clk_disable(rng_clk); | ||
142 | |||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | #ifdef CONFIG_PM | ||
147 | static int picoxcell_trng_suspend(struct device *dev) | ||
148 | { | ||
149 | clk_disable(rng_clk); | ||
150 | |||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | static int picoxcell_trng_resume(struct device *dev) | ||
155 | { | ||
156 | return clk_enable(rng_clk); | ||
157 | } | ||
158 | |||
159 | static const struct dev_pm_ops picoxcell_trng_pm_ops = { | ||
160 | .suspend = picoxcell_trng_suspend, | ||
161 | .resume = picoxcell_trng_resume, | ||
162 | }; | ||
163 | #endif /* CONFIG_PM */ | ||
164 | |||
165 | static struct platform_driver picoxcell_trng_driver = { | ||
166 | .probe = picoxcell_trng_probe, | ||
167 | .remove = picoxcell_trng_remove, | ||
168 | .driver = { | ||
169 | .name = "picoxcell-trng", | ||
170 | .owner = THIS_MODULE, | ||
171 | #ifdef CONFIG_PM | ||
172 | .pm = &picoxcell_trng_pm_ops, | ||
173 | #endif /* CONFIG_PM */ | ||
174 | }, | ||
175 | }; | ||
176 | |||
177 | module_platform_driver(picoxcell_trng_driver); | ||
178 | |||
179 | MODULE_LICENSE("GPL"); | ||
180 | MODULE_AUTHOR("Jamie Iles"); | ||
181 | MODULE_DESCRIPTION("Picochip picoXcell TRNG driver"); | ||