Lines Matching full:trng

43 static bool atmel_trng_wait_ready(struct atmel_trng *trng, bool wait)  in atmel_trng_wait_ready()  argument
47 ready = readl(trng->base + TRNG_ISR) & TRNG_ISR_DATRDY; in atmel_trng_wait_ready()
49 readl_poll_timeout(trng->base + TRNG_ISR, ready, in atmel_trng_wait_ready()
58 struct atmel_trng *trng = container_of(rng, struct atmel_trng, rng); in atmel_trng_read() local
62 ret = pm_runtime_get_sync((struct device *)trng->rng.priv); in atmel_trng_read()
64 pm_runtime_put_sync((struct device *)trng->rng.priv); in atmel_trng_read()
68 ret = atmel_trng_wait_ready(trng, wait); in atmel_trng_read()
72 *data = readl(trng->base + TRNG_ODATA); in atmel_trng_read()
78 readl(trng->base + TRNG_ISR); in atmel_trng_read()
82 pm_runtime_mark_last_busy((struct device *)trng->rng.priv); in atmel_trng_read()
83 pm_runtime_put_sync_autosuspend((struct device *)trng->rng.priv); in atmel_trng_read()
87 static int atmel_trng_init(struct atmel_trng *trng) in atmel_trng_init() argument
92 ret = clk_prepare_enable(trng->clk); in atmel_trng_init()
96 if (trng->has_half_rate) { in atmel_trng_init()
97 rate = clk_get_rate(trng->clk); in atmel_trng_init()
101 writel(TRNG_HALFR, trng->base + TRNG_MR); in atmel_trng_init()
104 writel(TRNG_KEY | 1, trng->base + TRNG_CR); in atmel_trng_init()
109 static void atmel_trng_cleanup(struct atmel_trng *trng) in atmel_trng_cleanup() argument
111 writel(TRNG_KEY, trng->base + TRNG_CR); in atmel_trng_cleanup()
112 clk_disable_unprepare(trng->clk); in atmel_trng_cleanup()
117 struct atmel_trng *trng; in atmel_trng_probe() local
121 trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL); in atmel_trng_probe()
122 if (!trng) in atmel_trng_probe()
125 trng->base = devm_platform_ioremap_resource(pdev, 0); in atmel_trng_probe()
126 if (IS_ERR(trng->base)) in atmel_trng_probe()
127 return PTR_ERR(trng->base); in atmel_trng_probe()
129 trng->clk = devm_clk_get(&pdev->dev, NULL); in atmel_trng_probe()
130 if (IS_ERR(trng->clk)) in atmel_trng_probe()
131 return PTR_ERR(trng->clk); in atmel_trng_probe()
136 trng->has_half_rate = data->has_half_rate; in atmel_trng_probe()
137 trng->rng.name = pdev->name; in atmel_trng_probe()
138 trng->rng.read = atmel_trng_read; in atmel_trng_probe()
139 trng->rng.priv = (unsigned long)&pdev->dev; in atmel_trng_probe()
140 platform_set_drvdata(pdev, trng); in atmel_trng_probe()
143 ret = atmel_trng_init(trng); in atmel_trng_probe()
152 ret = devm_hwrng_register(&pdev->dev, &trng->rng); in atmel_trng_probe()
157 atmel_trng_cleanup(trng); in atmel_trng_probe()
166 struct atmel_trng *trng = platform_get_drvdata(pdev); in atmel_trng_remove() local
168 atmel_trng_cleanup(trng); in atmel_trng_remove()
175 struct atmel_trng *trng = dev_get_drvdata(dev); in atmel_trng_runtime_suspend() local
177 atmel_trng_cleanup(trng); in atmel_trng_runtime_suspend()
184 struct atmel_trng *trng = dev_get_drvdata(dev); in atmel_trng_runtime_resume() local
186 return atmel_trng_init(trng); in atmel_trng_runtime_resume()
206 .compatible = "atmel,at91sam9g45-trng",
209 .compatible = "microchip,sam9x60-trng",
221 .name = "atmel-trng",