Lines Matching full:trng
24 /* trng statuses */
37 struct xiphera_trng *trng = container_of(rng, struct xiphera_trng, rng); in xiphera_trng_read() local
42 if (readl(trng->mem + STATUS_REG) == TRNG_NEW_RAND_AVAILABLE) { in xiphera_trng_read()
43 *(u32 *)buf = readl(trng->mem + RAND_REG); in xiphera_trng_read()
45 * Inform the trng of the read in xiphera_trng_read()
48 writel(HOST_TO_TRNG_READ, trng->mem + CONTROL_REG); in xiphera_trng_read()
49 writel(HOST_TO_TRNG_ENABLE, trng->mem + CONTROL_REG); in xiphera_trng_read()
63 struct xiphera_trng *trng; in xiphera_trng_probe() local
66 trng = devm_kzalloc(dev, sizeof(*trng), GFP_KERNEL); in xiphera_trng_probe()
67 if (!trng) in xiphera_trng_probe()
70 trng->mem = devm_platform_ioremap_resource(pdev, 0); in xiphera_trng_probe()
71 if (IS_ERR(trng->mem)) in xiphera_trng_probe()
72 return PTR_ERR(trng->mem); in xiphera_trng_probe()
75 * the trng needs to be reset first which might not happen in time, in xiphera_trng_probe()
78 writel(HOST_TO_TRNG_RESET, trng->mem + CONTROL_REG); in xiphera_trng_probe()
81 if (readl(trng->mem + STATUS_REG) != TRNG_ACK_RESET) { in xiphera_trng_probe()
83 * there is a small chance the trng is just not ready yet, in xiphera_trng_probe()
87 if (readl(trng->mem + STATUS_REG) != TRNG_ACK_RESET) { in xiphera_trng_probe()
88 dev_err(dev, "failed to reset the trng ip\n"); in xiphera_trng_probe()
95 * for a while after zeroizing the trng in xiphera_trng_probe()
97 writel(HOST_TO_TRNG_RELEASE_RESET, trng->mem + CONTROL_REG); in xiphera_trng_probe()
98 writel(HOST_TO_TRNG_ENABLE, trng->mem + CONTROL_REG); in xiphera_trng_probe()
99 writel(HOST_TO_TRNG_ZEROIZE, trng->mem + CONTROL_REG); in xiphera_trng_probe()
102 if (readl(trng->mem + STATUS_REG) != TRNG_SUCCESSFUL_STARTUP) { in xiphera_trng_probe()
104 if (readl(trng->mem + STATUS_REG) == TRNG_FAILED_STARTUP) { in xiphera_trng_probe()
105 dev_err(dev, "trng ip startup-tests failed\n"); in xiphera_trng_probe()
112 writel(HOST_TO_TRNG_ACK_ZEROIZE, trng->mem + CONTROL_REG); in xiphera_trng_probe()
114 trng->rng.name = pdev->name; in xiphera_trng_probe()
115 trng->rng.read = xiphera_trng_read; in xiphera_trng_probe()
116 trng->rng.quality = 900; in xiphera_trng_probe()
118 ret = devm_hwrng_register(dev, &trng->rng); in xiphera_trng_probe()
128 { .compatible = "xiphera,xip8001b-trng", },
135 .name = "xiphera-trng",