Lines Matching +full:cmd +full:- +full:max +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (C) 2008-2012 Freescale Semiconductor, Inc.
76 u32 ctrl, cmd; in imx_rngc_irq_mask_clear() local
79 ctrl = readl(rngc->base + RNGC_CONTROL); in imx_rngc_irq_mask_clear()
81 writel(ctrl, rngc->base + RNGC_CONTROL); in imx_rngc_irq_mask_clear()
88 cmd = readl(rngc->base + RNGC_COMMAND); in imx_rngc_irq_mask_clear()
89 cmd |= RNGC_CMD_CLR_INT | RNGC_CMD_CLR_ERR; in imx_rngc_irq_mask_clear()
90 writel(cmd, rngc->base + RNGC_COMMAND); in imx_rngc_irq_mask_clear()
97 ctrl = readl(rngc->base + RNGC_CONTROL); in imx_rngc_irq_unmask()
99 writel(ctrl, rngc->base + RNGC_CONTROL); in imx_rngc_irq_unmask()
104 u32 cmd; in imx_rngc_self_test() local
110 cmd = readl(rngc->base + RNGC_COMMAND); in imx_rngc_self_test()
111 writel(cmd | RNGC_CMD_SELF_TEST, rngc->base + RNGC_COMMAND); in imx_rngc_self_test()
113 ret = wait_for_completion_timeout(&rngc->rng_op_done, in imx_rngc_self_test()
117 return -ETIMEDOUT; in imx_rngc_self_test()
119 return rngc->err_reg ? -EIO : 0; in imx_rngc_self_test()
122 static int imx_rngc_read(struct hwrng *rng, void *data, size_t max, bool wait) in imx_rngc_read() argument
128 while (max >= sizeof(u32)) { in imx_rngc_read()
129 status = readl(rngc->base + RNGC_STATUS); in imx_rngc_read()
137 *(u32 *)data = readl(rngc->base + RNGC_FIFO); in imx_rngc_read()
141 max -= sizeof(u32); in imx_rngc_read()
145 return retval ? retval : -EIO; in imx_rngc_read()
157 status = readl(rngc->base + RNGC_STATUS); in imx_rngc_irq()
158 rngc->err_reg = readl(rngc->base + RNGC_ERROR); in imx_rngc_irq()
163 complete(&rngc->rng_op_done); in imx_rngc_irq()
171 u32 cmd, ctrl; in imx_rngc_init() local
175 cmd = readl(rngc->base + RNGC_COMMAND); in imx_rngc_init()
176 writel(cmd | RNGC_CMD_CLR_ERR, rngc->base + RNGC_COMMAND); in imx_rngc_init()
183 cmd = readl(rngc->base + RNGC_COMMAND); in imx_rngc_init()
184 writel(cmd | RNGC_CMD_SEED, rngc->base + RNGC_COMMAND); in imx_rngc_init()
186 ret = wait_for_completion_timeout(&rngc->rng_op_done, in imx_rngc_init()
189 ret = -ETIMEDOUT; in imx_rngc_init()
193 } while (rngc->err_reg == RNGC_ERROR_STATUS_STAT_ERR); in imx_rngc_init()
195 if (rngc->err_reg) { in imx_rngc_init()
196 ret = -EIO; in imx_rngc_init()
202 * after serving 2^20 random 160-bit words in imx_rngc_init()
204 ctrl = readl(rngc->base + RNGC_CONTROL); in imx_rngc_init()
206 writel(ctrl, rngc->base + RNGC_CONTROL); in imx_rngc_init()
235 rngc = devm_kzalloc(&pdev->dev, sizeof(*rngc), GFP_KERNEL); in imx_rngc_probe()
237 return -ENOMEM; in imx_rngc_probe()
239 rngc->base = devm_platform_ioremap_resource(pdev, 0); in imx_rngc_probe()
240 if (IS_ERR(rngc->base)) in imx_rngc_probe()
241 return PTR_ERR(rngc->base); in imx_rngc_probe()
243 rngc->clk = devm_clk_get_enabled(&pdev->dev, NULL); in imx_rngc_probe()
244 if (IS_ERR(rngc->clk)) in imx_rngc_probe()
245 return dev_err_probe(&pdev->dev, PTR_ERR(rngc->clk), "Cannot get rng_clk\n"); in imx_rngc_probe()
251 ver_id = readl(rngc->base + RNGC_VER_ID); in imx_rngc_probe()
258 return -ENODEV; in imx_rngc_probe()
260 init_completion(&rngc->rng_op_done); in imx_rngc_probe()
262 rngc->rng.name = pdev->name; in imx_rngc_probe()
263 rngc->rng.init = imx_rngc_init; in imx_rngc_probe()
264 rngc->rng.read = imx_rngc_read; in imx_rngc_probe()
265 rngc->rng.cleanup = imx_rngc_cleanup; in imx_rngc_probe()
266 rngc->rng.quality = 19; in imx_rngc_probe()
268 rngc->dev = &pdev->dev; in imx_rngc_probe()
273 ret = devm_request_irq(&pdev->dev, in imx_rngc_probe()
274 irq, imx_rngc_irq, 0, pdev->name, (void *)rngc); in imx_rngc_probe()
276 return dev_err_probe(&pdev->dev, ret, "Can't get interrupt working.\n"); in imx_rngc_probe()
281 return dev_err_probe(&pdev->dev, ret, "self test failed\n"); in imx_rngc_probe()
284 ret = devm_hwrng_register(&pdev->dev, &rngc->rng); in imx_rngc_probe()
286 return dev_err_probe(&pdev->dev, ret, "hwrng registration failed\n"); in imx_rngc_probe()
288 dev_info(&pdev->dev, in imx_rngc_probe()
299 clk_disable_unprepare(rngc->clk); in imx_rngc_suspend()
308 clk_prepare_enable(rngc->clk); in imx_rngc_resume()
316 { .compatible = "fsl,imx25-rngb" },
323 .name = KBUILD_MODNAME,