From d73904309ec0f24dce849bf64fb7669887ca1de1 Mon Sep 17 00:00:00 2001 From: Komal Shah Date: Tue, 11 Oct 2005 17:59:54 +0300 Subject: [PATCH] [PATCH] ARM: OMAP: 24xx RNG Added OMAP24xx RNG support --- drivers/char/Kconfig | 12 +++---- drivers/char/Makefile | 2 +- drivers/char/{omap16xx-rng.c => omap-rng.c} | 39 +++++++++++++-------- 3 files changed, 30 insertions(+), 23 deletions(-) rename drivers/char/{omap16xx-rng.c => omap-rng.c} (66%) diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 35a3fc1b5cb..0c4a062319f 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -659,15 +659,13 @@ config HW_RANDOM If unsure, say N. -config OMAP16XX_RNG - tristate "OMAP16xx Random Number Generator support" - depends on ARCH_OMAP16XX +config OMAP_RNG + tristate "OMAP Random Number Generator support" + depends on ARCH_OMAP16XX || ARCH_OMAP24XX ---help--- This driver provides kernel-side support for the Random Number - Generator hardware found on OMAP16xx multimedia processors. - - To compile this driver as a module, choose M here: the - module will be called hw_random. + Generator hardware found on OMAP16xx and OMAP24xx multimedia + processors. If unsure, say N. diff --git a/drivers/char/Makefile b/drivers/char/Makefile index d7d8df647db..7633a5ad382 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile @@ -75,7 +75,7 @@ obj-$(CONFIG_TOSHIBA) += toshiba.o obj-$(CONFIG_I8K) += i8k.o obj-$(CONFIG_DS1620) += ds1620.o obj-$(CONFIG_HW_RANDOM) += hw_random.o -obj-$(CONFIG_OMAP16XX_RNG) += omap16xx-rng.o +obj-$(CONFIG_OMAP_RNG) += omap-rng.o obj-$(CONFIG_FTAPE) += ftape/ obj-$(CONFIG_COBALT_LCD) += lcd.o obj-$(CONFIG_PPDEV) += ppdev.o diff --git a/drivers/char/omap16xx-rng.c b/drivers/char/omap-rng.c similarity index 66% rename from drivers/char/omap16xx-rng.c rename to drivers/char/omap-rng.c index 0638eaacf90..86ecd2939eb 100644 --- a/drivers/char/omap16xx-rng.c +++ b/drivers/char/omap-rng.c @@ -1,10 +1,10 @@ /* - * drivers/char/omap16xx-rng.c + * drivers/char/omap-rng.c * * Copyright (C) 2005 Nokia Corporation * Author: Juha Yrjölä * - * OMAP16xx Random Number Generator driver + * OMAP16xx and OMAP24xx Random Number Generator driver * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -15,9 +15,17 @@ #include #include #include +#include + #include +#include +#if defined (CONFIG_ARCH_OMAP16XX) #define RNG_BASE 0xfffe5000 +#endif +#if defined (CONFIG_ARCH_OMAP24XX) +#define RNG_BASE 0x480A0000 +#endif #define RNG_OUT_REG 0x00 #define RNG_STAT_REG 0x04 #define RNG_REV_REG 0x3c @@ -27,6 +35,8 @@ static u32 rng_base = io_p2v(RNG_BASE); +static struct clk *rng_ick = NULL; + static u32 rng_read_reg(int reg) { return __raw_readl(rng_base + reg); @@ -50,10 +60,19 @@ static void rng_feed_entropy(int count) static int __init rng_init(void) { - if (!cpu_is_omap16xx()) + if (!cpu_is_omap16xx() && !cpu_is_omap24xx()) return -ENODEV; - printk("OMAP16xx Random Number Generator ver. %02x\n", + if (cpu_is_omap24xx()) { + rng_ick = clk_get(NULL, "rng_ick"); + if (IS_ERR(rng_ick)) { + printk(KERN_ERR "omap-rng.c: Could not get rng_ick\n"); + return PTR_ERR(rng_ick); + } + clk_use(rng_ick); + } + + printk("OMAP Random Number Generator ver. %02x\n", rng_read_reg(RNG_REV_REG)); rng_write_reg(RNG_MASK_REG, 0x00000001); rng_feed_entropy(ENTROPY_WORD_COUNT); @@ -62,14 +81,4 @@ static int __init rng_init(void) return 0; } - -static void __exit rng_cleanup(void) -{ -} - -MODULE_AUTHOR("Juha Yrjölä"); -MODULE_DESCRIPTION("OMAP16xx H/W Random Number Generator (RNG) driver"); -MODULE_LICENSE("GPL"); - -module_init(rng_init); -module_exit(rng_cleanup); +late_initcall(rng_init); -- 2.41.1