diff options
author | Paul Walmsley <paul@pwsan.com> | 2012-09-23 19:28:26 -0400 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2012-09-23 19:28:26 -0400 |
commit | 665d92fa85b5cb4c0a3f36524ac6cc8f9e3d9c2d (patch) | |
tree | 42268a76ff4d1dff2d639f62b2207fc505988ec7 /drivers/char | |
parent | 02666360c92af7885c47163f936b58dc86213a53 (diff) |
hwrng: OMAP: convert to use runtime PM
Convert the OMAP onboard hardware RNG driver to use runtime PM.
This allows us to remove some OMAP-specific cpu_is_omap*() calls from
the RNG driver.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hw_random/omap-rng.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c index e0f0b9839862..748fcc8892f3 100644 --- a/drivers/char/hw_random/omap-rng.c +++ b/drivers/char/hw_random/omap-rng.c | |||
@@ -18,12 +18,12 @@ | |||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
20 | #include <linux/random.h> | 20 | #include <linux/random.h> |
21 | #include <linux/clk.h> | ||
22 | #include <linux/err.h> | 21 | #include <linux/err.h> |
23 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
24 | #include <linux/hw_random.h> | 23 | #include <linux/hw_random.h> |
25 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
26 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/pm_runtime.h> | ||
27 | 27 | ||
28 | #include <asm/io.h> | 28 | #include <asm/io.h> |
29 | 29 | ||
@@ -50,12 +50,10 @@ | |||
50 | /** | 50 | /** |
51 | * struct omap_rng_private_data - RNG IP block-specific data | 51 | * struct omap_rng_private_data - RNG IP block-specific data |
52 | * @base: virtual address of the beginning of the RNG IP block registers | 52 | * @base: virtual address of the beginning of the RNG IP block registers |
53 | * @clk: RNG clock | ||
54 | * @mem_res: struct resource * for the IP block registers physical memory | 53 | * @mem_res: struct resource * for the IP block registers physical memory |
55 | */ | 54 | */ |
56 | struct omap_rng_private_data { | 55 | struct omap_rng_private_data { |
57 | void __iomem *base; | 56 | void __iomem *base; |
58 | struct clk *clk; | ||
59 | struct resource *mem_res; | 57 | struct resource *mem_res; |
60 | }; | 58 | }; |
61 | 59 | ||
@@ -122,17 +120,6 @@ static int __devinit omap_rng_probe(struct platform_device *pdev) | |||
122 | omap_rng_ops.priv = (unsigned long)priv; | 120 | omap_rng_ops.priv = (unsigned long)priv; |
123 | dev_set_drvdata(&pdev->dev, priv); | 121 | dev_set_drvdata(&pdev->dev, priv); |
124 | 122 | ||
125 | if (cpu_is_omap24xx()) { | ||
126 | priv->clk = clk_get(&pdev->dev, "ick"); | ||
127 | if (IS_ERR(priv->clk)) { | ||
128 | dev_err(&pdev->dev, "Could not get rng_ick\n"); | ||
129 | ret = PTR_ERR(priv->clk); | ||
130 | return ret; | ||
131 | } else { | ||
132 | clk_enable(priv->clk); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | priv->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 123 | priv->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
137 | if (!priv->mem_res) { | 124 | if (!priv->mem_res) { |
138 | ret = -ENOENT; | 125 | ret = -ENOENT; |
@@ -146,6 +133,9 @@ static int __devinit omap_rng_probe(struct platform_device *pdev) | |||
146 | } | 133 | } |
147 | dev_set_drvdata(&pdev->dev, priv); | 134 | dev_set_drvdata(&pdev->dev, priv); |
148 | 135 | ||
136 | pm_runtime_enable(&pdev->dev); | ||
137 | pm_runtime_get_sync(&pdev->dev); | ||
138 | |||
149 | ret = hwrng_register(&omap_rng_ops); | 139 | ret = hwrng_register(&omap_rng_ops); |
150 | if (ret) | 140 | if (ret) |
151 | goto err_register; | 141 | goto err_register; |
@@ -153,19 +143,14 @@ static int __devinit omap_rng_probe(struct platform_device *pdev) | |||
153 | dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n", | 143 | dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n", |
154 | omap_rng_read_reg(priv, RNG_REV_REG)); | 144 | omap_rng_read_reg(priv, RNG_REV_REG)); |
155 | 145 | ||
156 | |||
157 | omap_rng_write_reg(priv, RNG_MASK_REG, 0x1); | 146 | omap_rng_write_reg(priv, RNG_MASK_REG, 0x1); |
158 | 147 | ||
159 | return 0; | 148 | return 0; |
160 | 149 | ||
161 | err_register: | 150 | err_register: |
162 | priv->base = NULL; | 151 | priv->base = NULL; |
152 | pm_runtime_disable(&pdev->dev); | ||
163 | err_ioremap: | 153 | err_ioremap: |
164 | if (cpu_is_omap24xx()) { | ||
165 | clk_disable(priv->clk); | ||
166 | clk_put(priv->clk); | ||
167 | } | ||
168 | |||
169 | kfree(priv); | 154 | kfree(priv); |
170 | 155 | ||
171 | return ret; | 156 | return ret; |
@@ -179,12 +164,8 @@ static int __exit omap_rng_remove(struct platform_device *pdev) | |||
179 | 164 | ||
180 | omap_rng_write_reg(priv, RNG_MASK_REG, 0x0); | 165 | omap_rng_write_reg(priv, RNG_MASK_REG, 0x0); |
181 | 166 | ||
182 | iounmap(priv->base); | 167 | pm_runtime_put_sync(&pdev->dev); |
183 | 168 | pm_runtime_disable(&pdev->dev); | |
184 | if (cpu_is_omap24xx()) { | ||
185 | clk_disable(priv->clk); | ||
186 | clk_put(priv->clk); | ||
187 | } | ||
188 | 169 | ||
189 | release_mem_region(priv->mem_res->start, resource_size(priv->mem_res)); | 170 | release_mem_region(priv->mem_res->start, resource_size(priv->mem_res)); |
190 | 171 | ||
@@ -200,6 +181,7 @@ static int omap_rng_suspend(struct device *dev) | |||
200 | struct omap_rng_private_data *priv = dev_get_drvdata(dev); | 181 | struct omap_rng_private_data *priv = dev_get_drvdata(dev); |
201 | 182 | ||
202 | omap_rng_write_reg(priv, RNG_MASK_REG, 0x0); | 183 | omap_rng_write_reg(priv, RNG_MASK_REG, 0x0); |
184 | pm_runtime_put_sync(dev); | ||
203 | 185 | ||
204 | return 0; | 186 | return 0; |
205 | } | 187 | } |
@@ -208,6 +190,7 @@ static int omap_rng_resume(struct device *dev) | |||
208 | { | 190 | { |
209 | struct omap_rng_private_data *priv = dev_get_drvdata(dev); | 191 | struct omap_rng_private_data *priv = dev_get_drvdata(dev); |
210 | 192 | ||
193 | pm_runtime_get_sync(dev); | ||
211 | omap_rng_write_reg(priv, RNG_MASK_REG, 0x1); | 194 | omap_rng_write_reg(priv, RNG_MASK_REG, 0x1); |
212 | 195 | ||
213 | return 0; | 196 | return 0; |