Lines Matching +full:x1830 +full:- +full:dtrng
1 // SPDX-License-Identifier: GPL-2.0
19 /* DTRNG register offsets */
40 ctrl = readl(trng->base + TRNG_REG_CFG_OFFSET); in ingenic_trng_init()
42 writel(ctrl, trng->base + TRNG_REG_CFG_OFFSET); in ingenic_trng_init()
52 ctrl = readl(trng->base + TRNG_REG_CFG_OFFSET); in ingenic_trng_cleanup()
54 writel(ctrl, trng->base + TRNG_REG_CFG_OFFSET); in ingenic_trng_cleanup()
64 ret = readl_poll_timeout(trng->base + TRNG_REG_STATUS_OFFSET, status, in ingenic_trng_read()
66 if (ret == -ETIMEDOUT) { in ingenic_trng_read()
67 pr_err("%s: Wait for DTRNG data ready timeout\n", __func__); in ingenic_trng_read()
71 *data = readl(trng->base + TRNG_REG_RANDOMNUM_OFFSET); in ingenic_trng_read()
82 trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL); in ingenic_trng_probe()
84 return -ENOMEM; in ingenic_trng_probe()
86 trng->base = devm_platform_ioremap_resource(pdev, 0); in ingenic_trng_probe()
87 if (IS_ERR(trng->base)) in ingenic_trng_probe()
88 return dev_err_probe(&pdev->dev, PTR_ERR(trng->base), in ingenic_trng_probe()
89 "%s: Failed to map DTRNG registers\n", __func__); in ingenic_trng_probe()
91 clk = devm_clk_get_enabled(&pdev->dev, NULL); in ingenic_trng_probe()
93 return dev_err_probe(&pdev->dev, PTR_ERR(clk), in ingenic_trng_probe()
94 "%s: Cannot get and enable DTRNG clock\n", __func__); in ingenic_trng_probe()
96 trng->rng.name = pdev->name; in ingenic_trng_probe()
97 trng->rng.init = ingenic_trng_init; in ingenic_trng_probe()
98 trng->rng.cleanup = ingenic_trng_cleanup; in ingenic_trng_probe()
99 trng->rng.read = ingenic_trng_read; in ingenic_trng_probe()
101 ret = devm_hwrng_register(&pdev->dev, &trng->rng); in ingenic_trng_probe()
103 return dev_err_probe(&pdev->dev, ret, "Failed to register hwrng\n"); in ingenic_trng_probe()
107 dev_info(&pdev->dev, "Ingenic DTRNG driver registered\n"); in ingenic_trng_probe()
112 { .compatible = "ingenic,x1830-dtrng" },
120 .name = "ingenic-trng",