summaryrefslogtreecommitdiff
path: root/drivers/char
diff options
context:
space:
mode:
authorAnish Trivedi <anish@freescale.com>2010-08-09 10:07:58 -0500
committerAlan Tull <r80115@freescale.com>2010-09-25 09:50:27 -0500
commite05148ea7ff491aa620e0ccc8ca762421d62ad16 (patch)
tree1aa34a09f1d40769867d4586c051a4208c1f3c12 /drivers/char
parent072ec1840763f9e4d7ea37a08531dc4c1faec85a (diff)
ENGR00126057-1 Add RNGB support
Adopt the mainline RNGC driver for RNGB hw Add clock gating on suspend resume Signed-off-by: Anish Trivedi <anish@freescale.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hw_random/fsl-rngc.c54
1 files changed, 46 insertions, 8 deletions
diff --git a/drivers/char/hw_random/fsl-rngc.c b/drivers/char/hw_random/fsl-rngc.c
index 678c5bd3e9a9..c43013027daf 100644
--- a/drivers/char/hw_random/fsl-rngc.c
+++ b/drivers/char/hw_random/fsl-rngc.c
@@ -1,10 +1,4 @@
/*
- * RNG driver for Freescale RNGC
- *
- * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
- */
-
-/*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* Version 2 or later at the following locations:
@@ -33,6 +27,12 @@
* warranty of any kind, whether express or implied.
*/
+/*
+ * RNG driver for Freescale RNGC
+ *
+ * Copyright (C) 2008-2010 Freescale Semiconductor, Inc.
+ */
+
#include <linux/module.h>
#include <linux/init.h>
#include <linux/kernel.h>
@@ -42,7 +42,6 @@
#include <linux/interrupt.h>
#include <linux/hw_random.h>
#include <linux/io.h>
-#include <asm/hardware.h>
#define RNGC_VERSION_MAJOR3 3
@@ -292,7 +291,7 @@ static int __init fsl_rngc_probe(struct platform_device *pdev)
if (rng_dev)
return -EBUSY;
- clk = clk_get(NULL, "rng_clk");
+ clk = clk_get(&pdev->dev, "rng_clk");
if (IS_ERR(clk)) {
dev_err(&pdev->dev, "Can not get rng_clk\n");
@@ -334,9 +333,17 @@ static int __init fsl_rngc_probe(struct platform_device *pdev)
static int __exit fsl_rngc_remove(struct platform_device *pdev)
{
+ struct clk *clk;
struct resource *mem = dev_get_drvdata(&pdev->dev);
void __iomem *rngc_base = (void __iomem *)fsl_rngc.priv;
+ clk = clk_get(&pdev->dev, "rng_clk");
+
+ if (IS_ERR(clk))
+ dev_err(&pdev->dev, "Can not get rng_clk\n");
+ else
+ clk_disable(clk);
+
hwrng_unregister(&fsl_rngc);
release_resource(mem);
@@ -346,12 +353,43 @@ static int __exit fsl_rngc_remove(struct platform_device *pdev)
return 0;
}
+static int fsl_rngc_suspend(struct platform_device *pdev,
+ pm_message_t state)
+{
+ struct clk *clk = clk_get(&pdev->dev, "rng_clk");
+
+ if (IS_ERR(clk)) {
+ dev_err(&pdev->dev, "Can not get rng_clk\n");
+ return PTR_ERR(clk);
+ }
+
+ clk_disable(clk);
+
+ return 0;
+}
+
+static int fsl_rngc_resume(struct platform_device *pdev)
+{
+ struct clk *clk = clk_get(&pdev->dev, "rng_clk");
+
+ if (IS_ERR(clk)) {
+ dev_err(&pdev->dev, "Can not get rng_clk\n");
+ return PTR_ERR(clk);
+ }
+
+ clk_enable(clk);
+
+ return 0;
+}
+
static struct platform_driver fsl_rngc_driver = {
.driver = {
.name = "fsl_rngc",
.owner = THIS_MODULE,
},
.remove = __exit_p(fsl_rngc_remove),
+ .suspend = fsl_rngc_suspend,
+ .resume = fsl_rngc_resume,
};
static int __init mod_init(void)