aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/configs/orion5x_defconfig3
-rw-r--r--arch/arm/mach-orion5x/ts78xx-fpga.h1
-rw-r--r--arch/arm/mach-orion5x/ts78xx-setup.c58
3 files changed, 61 insertions, 1 deletions
diff --git a/arch/arm/configs/orion5x_defconfig b/arch/arm/configs/orion5x_defconfig
index 5b98f764511..9e2385293ec 100644
--- a/arch/arm/configs/orion5x_defconfig
+++ b/arch/arm/configs/orion5x_defconfig
@@ -903,7 +903,8 @@ CONFIG_UNIX98_PTYS=y
903CONFIG_LEGACY_PTYS=y 903CONFIG_LEGACY_PTYS=y
904CONFIG_LEGACY_PTY_COUNT=16 904CONFIG_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 906CONFIG_HW_RANDOM=m
907CONFIG_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 0f9cdf45895..37b3d487529 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
30struct ts78xx_fpga_data { 31struct ts78xx_fpga_data {
diff --git a/arch/arm/mach-orion5x/ts78xx-setup.c b/arch/arm/mach-orion5x/ts78xx-setup.c
index 9a6b397f972..5041d1bc26b 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
278static struct resource ts78xx_ts_rng_resource = {
279 .flags = IORESOURCE_MEM,
280 .start = TS_RNG_DATA,
281 .end = TS_RNG_DATA + 4 - 1,
282};
283
284static struct timeriomem_rng_data ts78xx_ts_rng_data = {
285 .period = 1000000, /* one second */
286};
287
288static 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
298static 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
312static 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 ****************************************************************************/
275static void ts78xx_fpga_devices_zero_init(void) 320static 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
281static void ts78xx_fpga_supports(void) 327static 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}