Lines Matching full:rng

4 // Based on msm-rng.c and downstream driver
6 #include <crypto/internal/rng.h>
37 struct qcom_rng *rng; member
42 static int qcom_rng_read(struct qcom_rng *rng, u8 *data, unsigned int max) in qcom_rng_read() argument
49 val = readl_relaxed(rng->base + PRNG_STATUS); in qcom_rng_read()
53 val = readl_relaxed(rng->base + PRNG_DATA_OUT); in qcom_rng_read()
76 struct qcom_rng *rng = ctx->rng; in qcom_rng_generate() local
79 ret = clk_prepare_enable(rng->clk); in qcom_rng_generate()
83 mutex_lock(&rng->lock); in qcom_rng_generate()
85 ret = qcom_rng_read(rng, dstn, dlen); in qcom_rng_generate()
87 mutex_unlock(&rng->lock); in qcom_rng_generate()
88 clk_disable_unprepare(rng->clk); in qcom_rng_generate()
99 static int qcom_rng_enable(struct qcom_rng *rng) in qcom_rng_enable() argument
104 ret = clk_prepare_enable(rng->clk); in qcom_rng_enable()
109 val = readl_relaxed(rng->base + PRNG_CONFIG); in qcom_rng_enable()
113 val = readl_relaxed(rng->base + PRNG_LFSR_CFG); in qcom_rng_enable()
116 writel(val, rng->base + PRNG_LFSR_CFG); in qcom_rng_enable()
118 val = readl_relaxed(rng->base + PRNG_CONFIG); in qcom_rng_enable()
120 writel(val, rng->base + PRNG_CONFIG); in qcom_rng_enable()
123 clk_disable_unprepare(rng->clk); in qcom_rng_enable()
132 ctx->rng = qcom_rng_dev; in qcom_rng_init()
134 if (!ctx->rng->skip_init) in qcom_rng_init()
135 return qcom_rng_enable(ctx->rng); in qcom_rng_init()
146 .cra_driver_name = "qcom-rng",
157 struct qcom_rng *rng; in qcom_rng_probe() local
160 rng = devm_kzalloc(&pdev->dev, sizeof(*rng), GFP_KERNEL); in qcom_rng_probe()
161 if (!rng) in qcom_rng_probe()
164 platform_set_drvdata(pdev, rng); in qcom_rng_probe()
165 mutex_init(&rng->lock); in qcom_rng_probe()
167 rng->base = devm_platform_ioremap_resource(pdev, 0); in qcom_rng_probe()
168 if (IS_ERR(rng->base)) in qcom_rng_probe()
169 return PTR_ERR(rng->base); in qcom_rng_probe()
173 rng->clk = devm_clk_get(&pdev->dev, "core"); in qcom_rng_probe()
174 if (IS_ERR(rng->clk)) in qcom_rng_probe()
175 return PTR_ERR(rng->clk); in qcom_rng_probe()
179 rng->skip_init = (unsigned long)device_get_match_data(&pdev->dev); in qcom_rng_probe()
181 qcom_rng_dev = rng; in qcom_rng_probe()
184 dev_err(&pdev->dev, "Register crypto rng failed: %d\n", ret); in qcom_rng_probe()