25 irqstate = rd_reg32(&jrp->
rregs->jrintstatus);
35 dev_err(dev,
"job ring error: irqstate: %08x\n", irqstate);
43 wr_reg32(&jrp->
rregs->jrintstatus, irqstate);
46 tasklet_schedule(&jrp->
irqtask);
53 static void caam_jr_dequeue(
unsigned long devarg)
59 u32 *userdesc, userstatus;
62 while (rd_reg32(&jrp->
rregs->outring_used)) {
66 spin_lock(&jrp->outlock);
68 sw_idx = tail = jrp->
tail;
76 if (jrp->
outring[hw_idx].desc ==
77 jrp->
entinfo[sw_idx].desc_addr_dma)
89 jrp->
entinfo[sw_idx].desc_addr_dma = 0;
92 usercall = jrp->
entinfo[sw_idx].callbk;
93 userarg = jrp->
entinfo[sw_idx].cbkarg;
94 userdesc = jrp->
entinfo[sw_idx].desc_addr_virt;
95 userstatus = jrp->
outring[hw_idx].jrstatus;
98 wr_reg32(&jrp->
rregs->outring_rmvd, 1);
108 if (sw_idx == tail) {
113 jrp->
entinfo[tail].desc_addr_dma == 0);
118 spin_unlock(&jrp->outlock);
121 usercall(dev, userdesc, userstatus, userarg);
145 for (ring = 0; ring < ctrlpriv->
total_jobrs; ring++) {
149 *rdev = ctrlpriv->
jrdev[ring];
181 if (rd_reg32(&jrpriv->
rregs->outring_used) ||
223 void (*cbk)(
struct device *dev,
u32 *desc,
224 u32 status,
void *areq),
235 dev_err(dev,
"caam_jr_enqueue(): can't map jobdesc\n");
239 spin_lock_bh(&jrp->inplock);
244 if (!rd_reg32(&jrp->
rregs->inpring_avail) ||
246 spin_unlock_bh(&jrp->inplock);
254 head_entry->
callbk = (
void *)cbk;
255 head_entry->
cbkarg = areq;
266 wr_reg32(&jrp->
rregs->inpring_jobadd, 1);
268 spin_unlock_bh(&jrp->inplock);
274 static int caam_reset_hw_jr(
struct device *dev)
293 dev_err(dev,
"failed to flush job ring %d\n", jrp->
ridx);
304 dev_err(dev,
"failed to reset job ring %d\n", jrp->
ridx);
317 static int caam_jr_init(
struct device *dev)
331 dev_err(dev,
"can't connect JobR %d interrupt (%d)\n",
338 error = caam_reset_hw_jr(dev);
353 dev_err(dev,
"can't allocate job rings for %d\n",
359 jrp->
entinfo[i].desc_addr_dma = !0;
367 wr_reg64(&jrp->
rregs->inpring_base, inpbusaddr);
368 wr_reg64(&jrp->
rregs->outring_base, outbusaddr);
369 wr_reg32(&jrp->
rregs->inpring_size, JOBR_DEPTH);
370 wr_reg32(&jrp->
rregs->outring_size, JOBR_DEPTH);
395 ret = caam_reset_hw_jr(dev);
403 inpbusaddr = rd_reg64(&jrp->
rregs->inpring_base);
404 outbusaddr = rd_reg64(&jrp->
rregs->outring_base);
421 struct device *ctrldev, *jrdev;
428 ctrldev = &pdev->
dev;
433 if (jrpriv ==
NULL) {
434 dev_err(ctrldev,
"can't alloc private mem for job ring %d\n",
452 jr_pdev = of_platform_device_create(np,
NULL, ctrldev);
453 if (jr_pdev ==
NULL) {
457 jrdev = &jr_pdev->
dev;
459 ctrlpriv->
jrdev[ring] = jrdev;
473 error = caam_jr_init(jrdev);