Lines Matching refs:trng
61 struct hisi_trng *trng; member
67 static void hisi_trng_set_seed(struct hisi_trng *trng, const u8 *seed) in hisi_trng_set_seed() argument
79 writel(val, trng->base + SW_DRBG_SEED(seed_reg)); in hisi_trng_set_seed()
87 struct hisi_trng *trng = ctx->trng; in hisi_trng_seed() local
97 writel(0x0, trng->base + SW_DRBG_BLOCKS); in hisi_trng_seed()
98 hisi_trng_set_seed(trng, seed); in hisi_trng_seed()
101 trng->base + SW_DRBG_BLOCKS); in hisi_trng_seed()
102 writel(0x1, trng->base + SW_DRBG_INIT); in hisi_trng_seed()
104 ret = readl_relaxed_poll_timeout(trng->base + SW_DRBG_STATUS, in hisi_trng_seed()
116 struct hisi_trng *trng = ctx->trng; in hisi_trng_generate() local
130 ret = readl_relaxed_poll_timeout(trng->base + SW_DRBG_STATUS, in hisi_trng_generate()
138 data[i] = readl(trng->base + SW_DRBG_DATA(i)); in hisi_trng_generate()
148 writel(0x1, trng->base + SW_DRBG_GEN); in hisi_trng_generate()
157 struct hisi_trng *trng; in hisi_trng_init() local
161 list_for_each_entry(trng, &trng_devices.list, list) { in hisi_trng_init()
162 if (!trng->is_used) { in hisi_trng_init()
163 trng->is_used = true; in hisi_trng_init()
164 ctx->trng = trng; in hisi_trng_init()
179 ctx->trng->is_used = false; in hisi_trng_exit()
185 struct hisi_trng *trng; in hisi_trng_read() local
190 trng = container_of(rng, struct hisi_trng, rng); in hisi_trng_read()
193 ret = readl_poll_timeout(trng->base + HISI_TRNG_REG, val, in hisi_trng_read()
229 static void hisi_trng_add_to_list(struct hisi_trng *trng) in hisi_trng_add_to_list() argument
232 list_add_tail(&trng->list, &trng_devices.list); in hisi_trng_add_to_list()
236 static int hisi_trng_del_from_list(struct hisi_trng *trng) in hisi_trng_del_from_list() argument
241 if (!trng->is_used) { in hisi_trng_del_from_list()
242 list_del(&trng->list); in hisi_trng_del_from_list()
252 struct hisi_trng *trng; in hisi_trng_probe() local
255 trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL); in hisi_trng_probe()
256 if (!trng) in hisi_trng_probe()
259 platform_set_drvdata(pdev, trng); in hisi_trng_probe()
261 trng->base = devm_platform_ioremap_resource(pdev, 0); in hisi_trng_probe()
262 if (IS_ERR(trng->base)) in hisi_trng_probe()
263 return PTR_ERR(trng->base); in hisi_trng_probe()
265 trng->is_used = false; in hisi_trng_probe()
266 trng->ver = readl(trng->base + HISI_TRNG_VERSION); in hisi_trng_probe()
273 hisi_trng_add_to_list(trng); in hisi_trng_probe()
274 if (trng->ver != HISI_TRNG_VER_V1 && in hisi_trng_probe()
285 trng->rng.name = pdev->name; in hisi_trng_probe()
286 trng->rng.read = hisi_trng_read; in hisi_trng_probe()
287 trng->rng.quality = HISI_TRNG_QUALITY; in hisi_trng_probe()
288 ret = devm_hwrng_register(&pdev->dev, &trng->rng); in hisi_trng_probe()
297 if (trng->ver != HISI_TRNG_VER_V1 && in hisi_trng_probe()
302 hisi_trng_del_from_list(trng); in hisi_trng_probe()
308 struct hisi_trng *trng = platform_get_drvdata(pdev); in hisi_trng_remove() local
311 while (hisi_trng_del_from_list(trng)) in hisi_trng_remove()
314 if (trng->ver != HISI_TRNG_VER_V1 && in hisi_trng_remove()