50 #define RN_BUF_SIZE (0xffff / L1_CACHE_BYTES * \
54 #define DESC_JOB_O_LEN (CAAM_CMD_SZ * 2 + CAAM_PTR_SZ * 2)
55 #define DESC_RNG_LEN (10 * CAAM_CMD_SZ)
63 #define BUF_NOT_EMPTY 0
95 rng_unmap_buf(jrdev, &ctx->
bufs[0]);
96 rng_unmap_buf(jrdev, &ctx->
bufs[1]);
103 bd = (
struct buf_data *)((
char *)desc -
115 print_hex_dump(
KERN_ERR,
"rng refreshed buf@: ",
120 static inline int submit_job(
struct caam_rng_ctx *ctx,
int to_current)
128 init_completion(&bd->
filled);
142 int next_buf_idx, copied_idx;
148 err = submit_job(ctx, 1);
163 dev_dbg(ctx->
jrdev,
"%s: start reading at buffer %d, idx %d\n",
187 return copied_idx + caam_read(rng, data + copied_idx,
188 max - copied_idx,
false);
191 static inline void rng_create_sh_desc(
struct caam_rng_ctx *ctx)
211 desc, desc_bytes(desc), 1);
215 static inline void rng_create_job_desc(
struct caam_rng_ctx *ctx,
int buf_id)
220 int sh_len = desc_len(ctx->
sh_desc);
230 desc, desc_bytes(desc), 1);
234 static void caam_cleanup(
struct hwrng *rng)
239 for (i = 0; i < 2; i++) {
240 bd = &rng_ctx.bufs[
i];
245 rng_unmap_ctx(&rng_ctx);
248 static void caam_init_buf(
struct caam_rng_ctx *ctx,
int buf_id)
252 rng_create_job_desc(ctx, buf_id);
261 rng_create_sh_desc(ctx);
264 caam_init_buf(ctx, 0);
265 caam_init_buf(ctx, 1);
268 static struct hwrng caam_rng = {
270 .cleanup = caam_cleanup,
274 static void __exit caam_rng_exit(
void)
279 static int __init caam_rng_init(
void)
297 ctrldev = &pdev->
dev;
299 of_node_put(dev_node);
301 caam_init_rng(&rng_ctx, priv->
jrdev[0]);