示例#1
0
static int omap_rng_resume(struct device *dev)
{
    struct omap_rng_private_data *priv = dev_get_drvdata(dev);

    pm_runtime_get_sync(dev);
    omap_rng_write_reg(priv, RNG_MASK_REG, 0x1);

    return 0;
}
示例#2
0
static int __devinit omap_rng_probe(struct platform_device *pdev)
{
	struct resource *res;
	int ret;

	/*
	 * A bit ugly, and it will never actually happen but there can
	 * be only one RNG and this catches any bork
	 */
	if (rng_dev)
		return -EBUSY;

	if (cpu_is_omap24xx()) {
		rng_ick = clk_get(&pdev->dev, "ick");
		if (IS_ERR(rng_ick)) {
			dev_err(&pdev->dev, "Could not get rng_ick\n");
			ret = PTR_ERR(rng_ick);
			return ret;
		} else
			clk_enable(rng_ick);
	}

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

	rng_base = devm_request_and_ioremap(&pdev->dev, res);
	if (!rng_base) {
		ret = -ENOMEM;
		goto err_ioremap;
	}
	dev_set_drvdata(&pdev->dev, res);

	ret = hwrng_register(&omap_rng_ops);
	if (ret)
		goto err_register;

	dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n",
		omap_rng_read_reg(RNG_REV_REG));
	omap_rng_write_reg(RNG_MASK_REG, 0x1);

	rng_dev = pdev;

	return 0;

err_register:
	rng_base = NULL;
err_ioremap:
	if (cpu_is_omap24xx()) {
		clk_disable(rng_ick);
		clk_put(rng_ick);
	}
	return ret;
}
示例#3
0
static int __init omap_rng_probe(struct platform_device *pdev)
{
	struct resource *res, *mem;
	int ret;

	/*
	 * A bit ugly, and it will never actually happen but there can
	 * be only one RNG and this catches any bork
	 */
	BUG_ON(rng_dev);

	if (cpu_is_omap24xx()) {
		rng_ick = clk_get(NULL, "rng_ick");
		if (IS_ERR(rng_ick)) {
			dev_err(&pdev->dev, "Could not get rng_ick\n");
			ret = PTR_ERR(rng_ick);
			return ret;
		} else
			clk_enable(rng_ick);
	}

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

	if (!res)
		return -ENOENT;

	mem = request_mem_region(res->start, res->end - res->start + 1,
				 pdev->name);
	if (mem == NULL)
		return -EBUSY;

	dev_set_drvdata(&pdev->dev, mem);
	rng_base = (u32 __iomem *)io_p2v(res->start);

	ret = hwrng_register(&omap_rng_ops);
	if (ret) {
		release_resource(mem);
		rng_base = NULL;
		return ret;
	}

	dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n",
		omap_rng_read_reg(RNG_REV_REG));
	omap_rng_write_reg(RNG_MASK_REG, 0x1);

	rng_dev = pdev;

	return 0;
}
示例#4
0
static int __devinit omap_rng_probe(struct platform_device *pdev)
{
    struct omap_rng_private_data *priv;
    int ret;

    priv = kzalloc(sizeof(struct omap_rng_private_data), GFP_KERNEL);
    if (!priv) {
        dev_err(&pdev->dev, "could not allocate memory\n");
        return -ENOMEM;
    };

    omap_rng_ops.priv = (unsigned long)priv;
    dev_set_drvdata(&pdev->dev, priv);

    priv->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    if (!priv->mem_res) {
        ret = -ENOENT;
        goto err_ioremap;
    }

    priv->base = devm_request_and_ioremap(&pdev->dev, priv->mem_res);
    if (!priv->base) {
        ret = -ENOMEM;
        goto err_ioremap;
    }
    dev_set_drvdata(&pdev->dev, priv);

    pm_runtime_enable(&pdev->dev);
    pm_runtime_get_sync(&pdev->dev);

    ret = hwrng_register(&omap_rng_ops);
    if (ret)
        goto err_register;

    dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n",
             omap_rng_read_reg(priv, RNG_REV_REG));

    omap_rng_write_reg(priv, RNG_MASK_REG, 0x1);

    return 0;

err_register:
    priv->base = NULL;
    pm_runtime_disable(&pdev->dev);
err_ioremap:
    kfree(priv);

    return ret;
}
示例#5
0
static int __exit omap_rng_remove(struct platform_device *pdev)
{
	hwrng_unregister(&omap_rng_ops);

	omap_rng_write_reg(RNG_MASK_REG, 0x0);

	if (cpu_is_omap24xx()) {
		clk_disable(rng_ick);
		clk_put(rng_ick);
	}

	rng_base = NULL;

	return 0;
}
示例#6
0
static int __exit omap_rng_remove(struct platform_device *pdev)
{
    struct omap_rng_private_data *priv = dev_get_drvdata(&pdev->dev);

    hwrng_unregister(&omap_rng_ops);

    omap_rng_write_reg(priv, RNG_MASK_REG, 0x0);

    pm_runtime_put_sync(&pdev->dev);
    pm_runtime_disable(&pdev->dev);

    release_mem_region(priv->mem_res->start, resource_size(priv->mem_res));

    kfree(priv);

    return 0;
}
示例#7
0
static int __exit omap_rng_remove(struct platform_device *pdev)
{
	struct resource *mem = dev_get_drvdata(&pdev->dev);

	hwrng_unregister(&omap_rng_ops);

	omap_rng_write_reg(RNG_MASK_REG, 0x0);

	if (cpu_is_omap24xx()) {
		clk_disable(rng_ick);
		clk_put(rng_ick);
	}

	release_resource(mem);
	rng_base = NULL;

	return 0;
}
示例#8
0
static int omap_rng_resume(struct platform_device *pdev)
{
	omap_rng_write_reg(RNG_MASK_REG, 0x1);
	return 0;
}
示例#9
0
static int omap_rng_suspend(struct platform_device *pdev, pm_message_t message)
{
	omap_rng_write_reg(RNG_MASK_REG, 0x0);
	return 0;
}
static int __devinit omap_rng_probe(struct platform_device *pdev)
{
	struct resource *res;
	int ret;

	if (rng_dev)
		return -EBUSY;

	if (cpu_is_omap24xx()) {
		rng_ick = clk_get(&pdev->dev, "ick");
		if (IS_ERR(rng_ick)) {
			dev_err(&pdev->dev, "Could not get rng_ick\n");
			ret = PTR_ERR(rng_ick);
			return ret;
		} else
			clk_enable(rng_ick);
	}

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);

	if (!res) {
		ret = -ENOENT;
		goto err_region;
	}

	if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
		ret = -EBUSY;
		goto err_region;
	}

	dev_set_drvdata(&pdev->dev, res);
	rng_base = ioremap(res->start, resource_size(res));
	if (!rng_base) {
		ret = -ENOMEM;
		goto err_ioremap;
	}

	ret = hwrng_register(&omap_rng_ops);
	if (ret)
		goto err_register;

	dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n",
		omap_rng_read_reg(RNG_REV_REG));
	omap_rng_write_reg(RNG_MASK_REG, 0x1);

	rng_dev = pdev;

	return 0;

err_register:
	iounmap(rng_base);
	rng_base = NULL;
err_ioremap:
	release_mem_region(res->start, resource_size(res));
err_region:
	if (cpu_is_omap24xx()) {
		clk_disable(rng_ick);
		clk_put(rng_ick);
	}
	return ret;
}
示例#11
0
static int omap_rng_suspend(struct device *dev)
{
	omap_rng_write_reg(RNG_MASK_REG, 0x0);
	return 0;
}