Lines Matching full:rng

82 static int check_rng_health(struct cavium_rng *rng)  in check_rng_health()  argument
90 if (!rng->pf_regbase) in check_rng_health()
93 status = readq(rng->pf_regbase + HEALTH_STATUS_REG); in check_rng_health()
95 dev_err(&rng->pdev->dev, "HWRNG: Startup health test failed\n"); in check_rng_health()
110 cur_err = (cycles * 1000000000) / rng->clock_rate; /* In nanosec */ in check_rng_health()
116 rng->prev_error = 0; in check_rng_health()
117 rng->prev_time = 0; in check_rng_health()
121 if (rng->prev_error) { in check_rng_health()
125 time_elapsed = (cur_time - rng->prev_time) * 10; in check_rng_health()
126 time_elapsed += rng->prev_error; in check_rng_health()
133 dev_err(&rng->pdev->dev, "HWRNG failure detected\n"); in check_rng_health()
134 rng->prev_error = cur_err; in check_rng_health()
135 rng->prev_time = cur_time; in check_rng_health()
140 rng->prev_error = cur_err; in check_rng_health()
141 rng->prev_time = cur_time; in check_rng_health()
145 /* Read data from the RNG unit */
146 static int cavium_rng_read(struct hwrng *rng, void *dat, size_t max, bool wait) in cavium_rng_read() argument
148 struct cavium_rng *p = container_of(rng, struct cavium_rng, ops); in cavium_rng_read()
169 static int cavium_map_pf_regs(struct cavium_rng *rng) in cavium_map_pf_regs() argument
174 if (is_octeontx(rng->pdev)) { in cavium_map_pf_regs()
175 rng->pf_regbase = NULL; in cavium_map_pf_regs()
182 pr_err("Cannot find RNG PF device\n"); in cavium_map_pf_regs()
186 rng->pf_regbase = ioremap(pci_resource_start(pdev, 0), in cavium_map_pf_regs()
188 if (!rng->pf_regbase) { in cavium_map_pf_regs()
197 rng->clock_rate = rng_get_coprocessor_clkrate(); in cavium_map_pf_regs()
202 /* Map Cavium RNG to an HWRNG object */
206 struct cavium_rng *rng; in cavium_rng_probe_vf() local
209 rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); in cavium_rng_probe_vf()
210 if (!rng) in cavium_rng_probe_vf()
213 rng->pdev = pdev; in cavium_rng_probe_vf()
215 /* Map the RNG result */ in cavium_rng_probe_vf()
216 rng->result = pcim_iomap(pdev, 0, 0); in cavium_rng_probe_vf()
217 if (!rng->result) { in cavium_rng_probe_vf()
222 rng->ops.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, in cavium_rng_probe_vf()
223 "cavium-rng-%s", dev_name(&pdev->dev)); in cavium_rng_probe_vf()
224 if (!rng->ops.name) in cavium_rng_probe_vf()
227 rng->ops.read = cavium_rng_read; in cavium_rng_probe_vf()
229 pci_set_drvdata(pdev, rng); in cavium_rng_probe_vf()
232 ret = cavium_map_pf_regs(rng); in cavium_rng_probe_vf()
236 ret = devm_hwrng_register(&pdev->dev, &rng->ops); in cavium_rng_probe_vf()
248 struct cavium_rng *rng; in cavium_rng_remove_vf() local
250 rng = pci_get_drvdata(pdev); in cavium_rng_remove_vf()
251 iounmap(rng->pf_regbase); in cavium_rng_remove_vf()