Lines Matching full:trng
25 /* trng statuses */
38 struct xiphera_trng *trng = container_of(rng, struct xiphera_trng, rng); in xiphera_trng_read() local
43 if (readl(trng->mem + STATUS_REG) == TRNG_NEW_RAND_AVAILABLE) { in xiphera_trng_read()
44 *(u32 *)buf = readl(trng->mem + RAND_REG); in xiphera_trng_read()
46 * Inform the trng of the read in xiphera_trng_read()
49 writel(HOST_TO_TRNG_READ, trng->mem + CONTROL_REG); in xiphera_trng_read()
50 writel(HOST_TO_TRNG_ENABLE, trng->mem + CONTROL_REG); in xiphera_trng_read()
64 struct xiphera_trng *trng; in xiphera_trng_probe() local
67 trng = devm_kzalloc(dev, sizeof(*trng), GFP_KERNEL); in xiphera_trng_probe()
68 if (!trng) in xiphera_trng_probe()
71 trng->mem = devm_platform_ioremap_resource(pdev, 0); in xiphera_trng_probe()
72 if (IS_ERR(trng->mem)) in xiphera_trng_probe()
73 return PTR_ERR(trng->mem); in xiphera_trng_probe()
76 * the trng needs to be reset first which might not happen in time, in xiphera_trng_probe()
79 writel(HOST_TO_TRNG_RESET, trng->mem + CONTROL_REG); in xiphera_trng_probe()
82 if (readl(trng->mem + STATUS_REG) != TRNG_ACK_RESET) { in xiphera_trng_probe()
84 * there is a small chance the trng is just not ready yet, in xiphera_trng_probe()
88 if (readl(trng->mem + STATUS_REG) != TRNG_ACK_RESET) { in xiphera_trng_probe()
89 dev_err(dev, "failed to reset the trng ip\n"); in xiphera_trng_probe()
96 * for a while after zeroizing the trng in xiphera_trng_probe()
98 writel(HOST_TO_TRNG_RELEASE_RESET, trng->mem + CONTROL_REG); in xiphera_trng_probe()
99 writel(HOST_TO_TRNG_ENABLE, trng->mem + CONTROL_REG); in xiphera_trng_probe()
100 writel(HOST_TO_TRNG_ZEROIZE, trng->mem + CONTROL_REG); in xiphera_trng_probe()
103 if (readl(trng->mem + STATUS_REG) != TRNG_SUCCESSFUL_STARTUP) { in xiphera_trng_probe()
105 if (readl(trng->mem + STATUS_REG) == TRNG_FAILED_STARTUP) { in xiphera_trng_probe()
106 dev_err(dev, "trng ip startup-tests failed\n"); in xiphera_trng_probe()
113 writel(HOST_TO_TRNG_ACK_ZEROIZE, trng->mem + CONTROL_REG); in xiphera_trng_probe()
115 trng->rng.name = pdev->name; in xiphera_trng_probe()
116 trng->rng.read = xiphera_trng_read; in xiphera_trng_probe()
117 trng->rng.quality = 900; in xiphera_trng_probe()
119 ret = devm_hwrng_register(dev, &trng->rng); in xiphera_trng_probe()
125 platform_set_drvdata(pdev, trng); in xiphera_trng_probe()
131 { .compatible = "xiphera,xip8001b-trng", },
138 .name = "xiphera-trng",