diff options
author | Alexander Clouter <alex@digriz.org.uk> | 2009-05-03 15:57:48 -0400 |
---|---|---|
committer | Nicolas Pitre <nico@cam.org> | 2009-06-03 15:29:40 -0400 |
commit | a914d4309c4cf6e7c4d0dbce4822dcad38a7cf27 (patch) | |
tree | 85eebd36c7fa8180b3e20a6414693e10d18a2afd /arch | |
parent | 9fa7eb283c5cdc2b0f4a8cfe6387ed82e5e9a3d3 (diff) |
[ARM] orion: add hwrng timeriomem hook to TS-78xx
Add hook so that the HW RNG source on the TS-78xx is available.
Signed-off-by: Alexander Clouter <alex@digriz.org.uk>
Signed-off-by: Nicolas Pitre <nico@marvell.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/configs/orion5x_defconfig | 3 | ||||
-rw-r--r-- | arch/arm/mach-orion5x/ts78xx-fpga.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-orion5x/ts78xx-setup.c | 58 |
3 files changed, 61 insertions, 1 deletions
diff --git a/arch/arm/configs/orion5x_defconfig b/arch/arm/configs/orion5x_defconfig index 5b98f7645119..9e2385293ecb 100644 --- a/arch/arm/configs/orion5x_defconfig +++ b/arch/arm/configs/orion5x_defconfig | |||
@@ -903,7 +903,8 @@ CONFIG_UNIX98_PTYS=y | |||
903 | CONFIG_LEGACY_PTYS=y | 903 | CONFIG_LEGACY_PTYS=y |
904 | CONFIG_LEGACY_PTY_COUNT=16 | 904 | CONFIG_LEGACY_PTY_COUNT=16 |
905 | # CONFIG_IPMI_HANDLER is not set | 905 | # CONFIG_IPMI_HANDLER is not set |
906 | # CONFIG_HW_RANDOM is not set | 906 | CONFIG_HW_RANDOM=m |
907 | CONFIG_HW_RANDOM_TIMERIOMEM=m | ||
907 | # CONFIG_R3964 is not set | 908 | # CONFIG_R3964 is not set |
908 | # CONFIG_APPLICOM is not set | 909 | # CONFIG_APPLICOM is not set |
909 | # CONFIG_RAW_DRIVER is not set | 910 | # CONFIG_RAW_DRIVER is not set |
diff --git a/arch/arm/mach-orion5x/ts78xx-fpga.h b/arch/arm/mach-orion5x/ts78xx-fpga.h index 0f9cdf458952..37b3d4875291 100644 --- a/arch/arm/mach-orion5x/ts78xx-fpga.h +++ b/arch/arm/mach-orion5x/ts78xx-fpga.h | |||
@@ -25,6 +25,7 @@ struct fpga_devices { | |||
25 | /* Technologic Systems */ | 25 | /* Technologic Systems */ |
26 | struct fpga_device ts_rtc; | 26 | struct fpga_device ts_rtc; |
27 | struct fpga_device ts_nand; | 27 | struct fpga_device ts_nand; |
28 | struct fpga_device ts_rng; | ||
28 | }; | 29 | }; |
29 | 30 | ||
30 | struct ts78xx_fpga_data { | 31 | struct ts78xx_fpga_data { |
diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c b/arch/arm/mach-orion5x/ts78xx-setup.c index 9a6b397f972d..5041d1bc26b1 100644 --- a/arch/arm/mach-orion5x/ts78xx-setup.c +++ b/arch/arm/mach-orion5x/ts78xx-setup.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/m48t86.h> | 17 | #include <linux/m48t86.h> |
18 | #include <linux/mtd/nand.h> | 18 | #include <linux/mtd/nand.h> |
19 | #include <linux/mtd/partitions.h> | 19 | #include <linux/mtd/partitions.h> |
20 | #include <linux/timeriomem-rng.h> | ||
20 | #include <asm/mach-types.h> | 21 | #include <asm/mach-types.h> |
21 | #include <asm/mach/arch.h> | 22 | #include <asm/mach/arch.h> |
22 | #include <asm/mach/map.h> | 23 | #include <asm/mach/map.h> |
@@ -270,12 +271,57 @@ static void ts78xx_ts_nand_unload(void) | |||
270 | } | 271 | } |
271 | 272 | ||
272 | /***************************************************************************** | 273 | /***************************************************************************** |
274 | * HW RNG | ||
275 | ****************************************************************************/ | ||
276 | #define TS_RNG_DATA (TS78XX_FPGA_REGS_PHYS_BASE | 0x044) | ||
277 | |||
278 | static struct resource ts78xx_ts_rng_resource = { | ||
279 | .flags = IORESOURCE_MEM, | ||
280 | .start = TS_RNG_DATA, | ||
281 | .end = TS_RNG_DATA + 4 - 1, | ||
282 | }; | ||
283 | |||
284 | static struct timeriomem_rng_data ts78xx_ts_rng_data = { | ||
285 | .period = 1000000, /* one second */ | ||
286 | }; | ||
287 | |||
288 | static struct platform_device ts78xx_ts_rng_device = { | ||
289 | .name = "timeriomem_rng", | ||
290 | .id = -1, | ||
291 | .dev = { | ||
292 | .platform_data = &ts78xx_ts_rng_data, | ||
293 | }, | ||
294 | .resource = &ts78xx_ts_rng_resource, | ||
295 | .num_resources = 1, | ||
296 | }; | ||
297 | |||
298 | static int ts78xx_ts_rng_load(void) | ||
299 | { | ||
300 | int rc; | ||
301 | |||
302 | if (ts78xx_fpga.supports.ts_rng.init == 0) { | ||
303 | rc = platform_device_register(&ts78xx_ts_rng_device); | ||
304 | if (!rc) | ||
305 | ts78xx_fpga.supports.ts_rng.init = 1; | ||
306 | } else | ||
307 | rc = platform_device_add(&ts78xx_ts_rng_device); | ||
308 | |||
309 | return rc; | ||
310 | }; | ||
311 | |||
312 | static void ts78xx_ts_rng_unload(void) | ||
313 | { | ||
314 | platform_device_del(&ts78xx_ts_rng_device); | ||
315 | } | ||
316 | |||
317 | /***************************************************************************** | ||
273 | * FPGA 'hotplug' support code | 318 | * FPGA 'hotplug' support code |
274 | ****************************************************************************/ | 319 | ****************************************************************************/ |
275 | static void ts78xx_fpga_devices_zero_init(void) | 320 | static void ts78xx_fpga_devices_zero_init(void) |
276 | { | 321 | { |
277 | ts78xx_fpga.supports.ts_rtc.init = 0; | 322 | ts78xx_fpga.supports.ts_rtc.init = 0; |
278 | ts78xx_fpga.supports.ts_nand.init = 0; | 323 | ts78xx_fpga.supports.ts_nand.init = 0; |
324 | ts78xx_fpga.supports.ts_rng.init = 0; | ||
279 | } | 325 | } |
280 | 326 | ||
281 | static void ts78xx_fpga_supports(void) | 327 | static void ts78xx_fpga_supports(void) |
@@ -289,10 +335,12 @@ static void ts78xx_fpga_supports(void) | |||
289 | case TS7800_REV_5: | 335 | case TS7800_REV_5: |
290 | ts78xx_fpga.supports.ts_rtc.present = 1; | 336 | ts78xx_fpga.supports.ts_rtc.present = 1; |
291 | ts78xx_fpga.supports.ts_nand.present = 1; | 337 | ts78xx_fpga.supports.ts_nand.present = 1; |
338 | ts78xx_fpga.supports.ts_rng.present = 1; | ||
292 | break; | 339 | break; |
293 | default: | 340 | default: |
294 | ts78xx_fpga.supports.ts_rtc.present = 0; | 341 | ts78xx_fpga.supports.ts_rtc.present = 0; |
295 | ts78xx_fpga.supports.ts_nand.present = 0; | 342 | ts78xx_fpga.supports.ts_nand.present = 0; |
343 | ts78xx_fpga.supports.ts_rng.present = 0; | ||
296 | } | 344 | } |
297 | } | 345 | } |
298 | 346 | ||
@@ -316,6 +364,14 @@ static int ts78xx_fpga_load_devices(void) | |||
316 | } | 364 | } |
317 | ret |= tmp; | 365 | ret |= tmp; |
318 | } | 366 | } |
367 | if (ts78xx_fpga.supports.ts_rng.present == 1) { | ||
368 | tmp = ts78xx_ts_rng_load(); | ||
369 | if (tmp) { | ||
370 | printk(KERN_INFO "TS-78xx: RNG not registered\n"); | ||
371 | ts78xx_fpga.supports.ts_rng.present = 0; | ||
372 | } | ||
373 | ret |= tmp; | ||
374 | } | ||
319 | 375 | ||
320 | return ret; | 376 | return ret; |
321 | } | 377 | } |
@@ -328,6 +384,8 @@ static int ts78xx_fpga_unload_devices(void) | |||
328 | ts78xx_ts_rtc_unload(); | 384 | ts78xx_ts_rtc_unload(); |
329 | if (ts78xx_fpga.supports.ts_nand.present == 1) | 385 | if (ts78xx_fpga.supports.ts_nand.present == 1) |
330 | ts78xx_ts_nand_unload(); | 386 | ts78xx_ts_nand_unload(); |
387 | if (ts78xx_fpga.supports.ts_rng.present == 1) | ||
388 | ts78xx_ts_rng_unload(); | ||
331 | 389 | ||
332 | return ret; | 390 | return ret; |
333 | } | 391 | } |