Commit b8d665ae authored by Tony Lindgren's avatar Tony Lindgren Committed by Herbert Xu

hwrng: omap3-rom - Update to use standard driver data

Let's update omap3-rom-rng to use standard driver data to make it easier
to add runtime PM support in the following patch. Just use it for the
rng ops and clock for now. Let's still keep also old rng_clk still around,
we will remove delayed work and rng_clk with runtime PM in the next patch.

Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Adam Ford <aford173@gmail.com>
Cc: Pali Rohár <pali.rohar@gmail.com>
Cc: Sebastian Reichel <sre@kernel.org>
Cc: Tero Kristo <t-kristo@ti.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent a0f19a89
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
/* param1: ptr, param2: count, param3: flag */ /* param1: ptr, param2: count, param3: flag */
static u32 (*omap3_rom_rng_call)(u32, u32, u32); static u32 (*omap3_rom_rng_call)(u32, u32, u32);
struct omap_rom_rng {
struct clk *clk;
struct device *dev;
struct hwrng ops;
};
static struct delayed_work idle_work; static struct delayed_work idle_work;
static int rng_idle; static int rng_idle;
static struct clk *rng_clk; static struct clk *rng_clk;
...@@ -86,48 +92,57 @@ static int omap3_rom_rng_read(struct hwrng *rng, void *data, size_t max, bool w) ...@@ -86,48 +92,57 @@ static int omap3_rom_rng_read(struct hwrng *rng, void *data, size_t max, bool w)
return 4; return 4;
} }
static struct hwrng omap3_rom_rng_ops = {
.name = "omap3-rom",
.quality = 900,
};
static int omap3_rom_rng_probe(struct platform_device *pdev) static int omap3_rom_rng_probe(struct platform_device *pdev)
{ {
struct omap_rom_rng *ddata;
int ret = 0; int ret = 0;
omap3_rom_rng_ops.read = of_device_get_match_data(&pdev->dev); ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
if (!omap3_rom_rng_ops.read) { if (!ddata)
return -ENOMEM;
ddata->dev = &pdev->dev;
ddata->ops.priv = (unsigned long)ddata;
ddata->ops.name = "omap3-rom";
ddata->ops.read = of_device_get_match_data(&pdev->dev);
ddata->ops.quality = 900;
if (!ddata->ops.read) {
dev_err(&pdev->dev, "missing rom code handler\n"); dev_err(&pdev->dev, "missing rom code handler\n");
return -ENODEV; return -ENODEV;
} }
dev_set_drvdata(ddata->dev, ddata);
omap3_rom_rng_call = pdev->dev.platform_data; omap3_rom_rng_call = pdev->dev.platform_data;
if (!omap3_rom_rng_call) { if (!omap3_rom_rng_call) {
pr_err("omap3_rom_rng_call is NULL\n"); dev_err(ddata->dev, "rom_rng_call is NULL\n");
return -EINVAL; return -EINVAL;
} }
INIT_DELAYED_WORK(&idle_work, omap3_rom_rng_idle); INIT_DELAYED_WORK(&idle_work, omap3_rom_rng_idle);
rng_clk = devm_clk_get(&pdev->dev, "ick"); ddata->clk = devm_clk_get(ddata->dev, "ick");
if (IS_ERR(rng_clk)) { if (IS_ERR(ddata->clk)) {
pr_err("unable to get RNG clock\n"); dev_err(ddata->dev, "unable to get RNG clock\n");
return PTR_ERR(rng_clk); return PTR_ERR(ddata->clk);
} }
rng_clk = ddata->clk;
/* Leave the RNG in reset state. */ /* Leave the RNG in reset state. */
ret = clk_prepare_enable(rng_clk); ret = clk_prepare_enable(ddata->clk);
if (ret) if (ret)
return ret; return ret;
omap3_rom_rng_idle(0); omap3_rom_rng_idle(0);
return hwrng_register(&omap3_rom_rng_ops); return hwrng_register(&ddata->ops);
} }
static int omap3_rom_rng_remove(struct platform_device *pdev) static int omap3_rom_rng_remove(struct platform_device *pdev)
{ {
struct omap_rom_rng *ddata;
ddata = dev_get_drvdata(&pdev->dev);
cancel_delayed_work_sync(&idle_work); cancel_delayed_work_sync(&idle_work);
hwrng_unregister(&omap3_rom_rng_ops); hwrng_unregister(&ddata->ops);
if (!rng_idle) if (!rng_idle)
clk_disable_unprepare(rng_clk); clk_disable_unprepare(rng_clk);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment