Lines Matching full:rng
69 static unsigned long reset_rng_health_state(struct cn10k_rng *rng) in reset_rng_health_state() argument
78 static int check_rng_health(struct cn10k_rng *rng) in check_rng_health() argument
84 if (!rng->reg_base) in check_rng_health()
87 status = readq(rng->reg_base + RNM_PF_EBG_HEALTH); in check_rng_health()
89 err = reset_rng_health_state(rng); in check_rng_health()
91 dev_err(&rng->pdev->dev, "HWRNG: Health test failed (status=%llx)\n", in check_rng_health()
93 dev_err(&rng->pdev->dev, "HWRNG: error during reset (error=%lx)\n", in check_rng_health()
102 static bool cn10k_read_trng(struct cn10k_rng *rng, u64 *value) in cn10k_read_trng() argument
108 if (rng->extended_trng_regs) { in cn10k_read_trng()
110 *value = readq(rng->reg_base + RNM_PF_TRNG_DAT); in cn10k_read_trng()
113 status = readq(rng->reg_base + RNM_PF_TRNG_RES); in cn10k_read_trng()
119 *value = readq(rng->reg_base + RNM_PF_RANDOM); in cn10k_read_trng()
125 upper = readq(rng->reg_base + RNM_PF_RANDOM); in cn10k_read_trng()
126 lower = readq(rng->reg_base + RNM_PF_RANDOM); in cn10k_read_trng()
128 upper = readq(rng->reg_base + RNM_PF_RANDOM); in cn10k_read_trng()
130 lower = readq(rng->reg_base + RNM_PF_RANDOM); in cn10k_read_trng()
140 struct cn10k_rng *rng = (struct cn10k_rng *)hwrng->priv; in cn10k_rng_read() local
146 err = check_rng_health(rng); in cn10k_rng_read()
153 if (!cn10k_read_trng(rng, &value)) in cn10k_rng_read()
162 if (!cn10k_read_trng(rng, &value)) in cn10k_rng_read()
179 struct cn10k_rng *rng; in cn10k_rng_probe() local
182 rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); in cn10k_rng_probe()
183 if (!rng) in cn10k_rng_probe()
186 rng->pdev = pdev; in cn10k_rng_probe()
187 pci_set_drvdata(pdev, rng); in cn10k_rng_probe()
189 rng->reg_base = pcim_iomap(pdev, 0, 0); in cn10k_rng_probe()
190 if (!rng->reg_base) in cn10k_rng_probe()
193 rng->ops.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, in cn10k_rng_probe()
194 "cn10k-rng-%s", dev_name(&pdev->dev)); in cn10k_rng_probe()
195 if (!rng->ops.name) in cn10k_rng_probe()
198 rng->ops.read = cn10k_rng_read; in cn10k_rng_probe()
199 rng->ops.priv = (unsigned long)rng; in cn10k_rng_probe()
201 rng->extended_trng_regs = cn10k_is_extended_trng_regs_supported(pdev); in cn10k_rng_probe()
203 reset_rng_health_state(rng); in cn10k_rng_probe()
205 err = devm_hwrng_register(&pdev->dev, &rng->ops); in cn10k_rng_probe()
213 { PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, 0xA098) }, /* RNG PF */
227 MODULE_DESCRIPTION("Marvell CN10K HW RNG Driver");