Lines Matching refs:crc

78 	struct bfin_crypto_crc	*crc;  member
95 struct bfin_crypto_crc *crc; member
135 static int bfin_crypto_crc_init_hw(struct bfin_crypto_crc *crc, u32 key) in bfin_crypto_crc_init_hw() argument
137 writel(0, &crc->regs->datacntrld); in bfin_crypto_crc_init_hw()
138 writel(MODE_CALC_CRC << OPMODE_OFFSET, &crc->regs->control); in bfin_crypto_crc_init_hw()
139 writel(key, &crc->regs->curresult); in bfin_crypto_crc_init_hw()
142 writel(CMPERRI | DCNTEXPI, &crc->regs->status); in bfin_crypto_crc_init_hw()
143 writel(CMPERRI | DCNTEXPI, &crc->regs->intrenset); in bfin_crypto_crc_init_hw()
153 struct bfin_crypto_crc *crc; in bfin_crypto_crc_init() local
155 dev_dbg(ctx->crc->dev, "crc_init\n"); in bfin_crypto_crc_init()
157 list_for_each_entry(crc, &crc_list.dev_list, list) { in bfin_crypto_crc_init()
158 crc_ctx->crc = crc; in bfin_crypto_crc_init()
164 dev_dbg(ctx->crc->dev, "init: requested sg list is too big > %d\n", in bfin_crypto_crc_init()
169 ctx->crc = crc; in bfin_crypto_crc_init()
179 dev_dbg(ctx->crc->dev, "init: digest size: %d\n", in bfin_crypto_crc_init()
182 return bfin_crypto_crc_init_hw(crc, crc_ctx->key); in bfin_crypto_crc_init()
185 static void bfin_crypto_crc_config_dma(struct bfin_crypto_crc *crc) in bfin_crypto_crc_config_dma() argument
188 struct bfin_crypto_crc_reqctx *ctx = ahash_request_ctx(crc->req); in bfin_crypto_crc_config_dma()
196 dma_map_sg(crc->dev, ctx->sg, ctx->sg_nents, DMA_TO_DEVICE); in bfin_crypto_crc_config_dma()
211 memcpy(crc->sg_mid_buf +(i << 2) + mid_dma_count, in bfin_crypto_crc_config_dma()
221 crc->sg_cpu[i].start_addr = crc->sg_mid_dma + (i << 2); in bfin_crypto_crc_config_dma()
222 crc->sg_cpu[i].cfg = dma_config; in bfin_crypto_crc_config_dma()
223 crc->sg_cpu[i].x_count = 1; in bfin_crypto_crc_config_dma()
224 crc->sg_cpu[i].x_modify = CHKSUM_DIGEST_SIZE; in bfin_crypto_crc_config_dma()
225 dev_dbg(crc->dev, "%d: crc_dma: start_addr:0x%lx, " in bfin_crypto_crc_config_dma()
227 i, crc->sg_cpu[i].start_addr, in bfin_crypto_crc_config_dma()
228 crc->sg_cpu[i].cfg, crc->sg_cpu[i].x_count, in bfin_crypto_crc_config_dma()
229 crc->sg_cpu[i].x_modify); in bfin_crypto_crc_config_dma()
251 crc->sg_cpu[i].start_addr = dma_addr; in bfin_crypto_crc_config_dma()
252 crc->sg_cpu[i].cfg = dma_config; in bfin_crypto_crc_config_dma()
253 crc->sg_cpu[i].x_count = dma_count; in bfin_crypto_crc_config_dma()
254 crc->sg_cpu[i].x_modify = dma_mod; in bfin_crypto_crc_config_dma()
255 dev_dbg(crc->dev, "%d: crc_dma: start_addr:0x%lx, " in bfin_crypto_crc_config_dma()
257 i, crc->sg_cpu[i].start_addr, in bfin_crypto_crc_config_dma()
258 crc->sg_cpu[i].cfg, crc->sg_cpu[i].x_count, in bfin_crypto_crc_config_dma()
259 crc->sg_cpu[i].x_modify); in bfin_crypto_crc_config_dma()
264 memcpy(crc->sg_mid_buf + (i << 2), in bfin_crypto_crc_config_dma()
274 crc->sg_cpu[i].start_addr = dma_map_single(crc->dev, ctx->bufnext, in bfin_crypto_crc_config_dma()
276 crc->sg_cpu[i].cfg = dma_config; in bfin_crypto_crc_config_dma()
277 crc->sg_cpu[i].x_count = 1; in bfin_crypto_crc_config_dma()
278 crc->sg_cpu[i].x_modify = CHKSUM_DIGEST_SIZE; in bfin_crypto_crc_config_dma()
279 dev_dbg(crc->dev, "%d: crc_dma: start_addr:0x%lx, " in bfin_crypto_crc_config_dma()
281 i, crc->sg_cpu[i].start_addr, in bfin_crypto_crc_config_dma()
282 crc->sg_cpu[i].cfg, crc->sg_cpu[i].x_count, in bfin_crypto_crc_config_dma()
283 crc->sg_cpu[i].x_modify); in bfin_crypto_crc_config_dma()
291 crc->sg_cpu[i - 1].cfg &= ~(DMAFLOW | NDSIZE); in bfin_crypto_crc_config_dma()
292 crc->sg_cpu[i - 1].cfg |= DI_EN; in bfin_crypto_crc_config_dma()
293 set_dma_curr_desc_addr(crc->dma_ch, (unsigned long *)crc->sg_dma); in bfin_crypto_crc_config_dma()
294 set_dma_x_count(crc->dma_ch, 0); in bfin_crypto_crc_config_dma()
295 set_dma_x_modify(crc->dma_ch, 0); in bfin_crypto_crc_config_dma()
296 set_dma_config(crc->dma_ch, dma_config); in bfin_crypto_crc_config_dma()
299 static int bfin_crypto_crc_handle_queue(struct bfin_crypto_crc *crc, in bfin_crypto_crc_handle_queue() argument
311 spin_lock_irqsave(&crc->lock, flags); in bfin_crypto_crc_handle_queue()
313 ret = ahash_enqueue_request(&crc->queue, req); in bfin_crypto_crc_handle_queue()
314 if (crc->busy) { in bfin_crypto_crc_handle_queue()
315 spin_unlock_irqrestore(&crc->lock, flags); in bfin_crypto_crc_handle_queue()
318 backlog = crypto_get_backlog(&crc->queue); in bfin_crypto_crc_handle_queue()
319 async_req = crypto_dequeue_request(&crc->queue); in bfin_crypto_crc_handle_queue()
321 crc->busy = 1; in bfin_crypto_crc_handle_queue()
322 spin_unlock_irqrestore(&crc->lock, flags); in bfin_crypto_crc_handle_queue()
331 crc->req = req; in bfin_crypto_crc_handle_queue()
337 dev_dbg(crc->dev, "handling new req, flag=%u, nbytes: %d\n", in bfin_crypto_crc_handle_queue()
342 crc->busy = 0; in bfin_crypto_crc_handle_queue()
359 crc->busy = 0; in bfin_crypto_crc_handle_queue()
409 writel(ctx->sg_buflen >> 2, &crc->regs->datacnt); in bfin_crypto_crc_handle_queue()
412 bfin_crypto_crc_config_dma(crc); in bfin_crypto_crc_handle_queue()
415 reg = readl(&crc->regs->control); in bfin_crypto_crc_handle_queue()
416 writel(reg | BLKEN, &crc->regs->control); in bfin_crypto_crc_handle_queue()
428 dev_dbg(ctx->crc->dev, "crc_update\n"); in bfin_crypto_crc_update()
432 return bfin_crypto_crc_handle_queue(ctx->crc, req); in bfin_crypto_crc_update()
441 dev_dbg(ctx->crc->dev, "crc_final\n"); in bfin_crypto_crc_final()
445 return bfin_crypto_crc_handle_queue(ctx->crc, req); in bfin_crypto_crc_final()
454 dev_dbg(ctx->crc->dev, "crc_finishupdate\n"); in bfin_crypto_crc_finup()
459 return bfin_crypto_crc_handle_queue(ctx->crc, req); in bfin_crypto_crc_finup()
478 dev_dbg(crc_ctx->crc->dev, "crc_setkey\n"); in bfin_crypto_crc_setkey()
529 struct bfin_crypto_crc *crc = (struct bfin_crypto_crc *)data; in bfin_crypto_crc_done_task() local
531 bfin_crypto_crc_handle_queue(crc, NULL); in bfin_crypto_crc_done_task()
536 struct bfin_crypto_crc *crc = dev_id; in bfin_crypto_crc_handler() local
539 if (readl(&crc->regs->status) & DCNTEXP) { in bfin_crypto_crc_handler()
540 writel(DCNTEXP, &crc->regs->status); in bfin_crypto_crc_handler()
543 put_unaligned_le32(readl(&crc->regs->result), in bfin_crypto_crc_handler()
544 crc->req->result); in bfin_crypto_crc_handler()
546 reg = readl(&crc->regs->control); in bfin_crypto_crc_handler()
547 writel(reg & ~BLKEN, &crc->regs->control); in bfin_crypto_crc_handler()
548 crc->busy = 0; in bfin_crypto_crc_handler()
550 if (crc->req->base.complete) in bfin_crypto_crc_handler()
551 crc->req->base.complete(&crc->req->base, 0); in bfin_crypto_crc_handler()
553 tasklet_schedule(&crc->done_task); in bfin_crypto_crc_handler()
568 struct bfin_crypto_crc *crc = platform_get_drvdata(pdev); in bfin_crypto_crc_suspend() local
571 while ((readl(&crc->regs->control) & BLKEN) && --i) in bfin_crypto_crc_suspend()
593 struct bfin_crypto_crc *crc; in bfin_crypto_crc_probe() local
597 crc = devm_kzalloc(dev, sizeof(*crc), GFP_KERNEL); in bfin_crypto_crc_probe()
598 if (!crc) { in bfin_crypto_crc_probe()
603 crc->dev = dev; in bfin_crypto_crc_probe()
605 INIT_LIST_HEAD(&crc->list); in bfin_crypto_crc_probe()
606 spin_lock_init(&crc->lock); in bfin_crypto_crc_probe()
607 tasklet_init(&crc->done_task, bfin_crypto_crc_done_task, (unsigned long)crc); in bfin_crypto_crc_probe()
608 crypto_init_queue(&crc->queue, CRC_CCRYPTO_QUEUE_LENGTH); in bfin_crypto_crc_probe()
616 crc->regs = devm_ioremap_resource(dev, res); in bfin_crypto_crc_probe()
617 if (IS_ERR((void *)crc->regs)) { in bfin_crypto_crc_probe()
619 return PTR_ERR((void *)crc->regs); in bfin_crypto_crc_probe()
622 crc->irq = platform_get_irq(pdev, 0); in bfin_crypto_crc_probe()
623 if (crc->irq < 0) { in bfin_crypto_crc_probe()
628 ret = devm_request_irq(dev, crc->irq, bfin_crypto_crc_handler, in bfin_crypto_crc_probe()
629 IRQF_SHARED, dev_name(dev), crc); in bfin_crypto_crc_probe()
640 crc->dma_ch = res->start; in bfin_crypto_crc_probe()
642 ret = request_dma(crc->dma_ch, dev_name(dev)); in bfin_crypto_crc_probe()
648 crc->sg_cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, &crc->sg_dma, GFP_KERNEL); in bfin_crypto_crc_probe()
649 if (crc->sg_cpu == NULL) { in bfin_crypto_crc_probe()
657 crc->sg_mid_buf = (u8 *)(crc->sg_cpu + ((CRC_MAX_DMA_DESC + 1) << 1)); in bfin_crypto_crc_probe()
658 crc->sg_mid_dma = crc->sg_dma + sizeof(struct dma_desc_array) in bfin_crypto_crc_probe()
661 writel(0, &crc->regs->control); in bfin_crypto_crc_probe()
662 crc->poly = (u32)pdev->dev.platform_data; in bfin_crypto_crc_probe()
663 writel(crc->poly, &crc->regs->poly); in bfin_crypto_crc_probe()
665 while (!(readl(&crc->regs->status) & LUTDONE) && (--timeout) > 0) in bfin_crypto_crc_probe()
671 platform_set_drvdata(pdev, crc); in bfin_crypto_crc_probe()
674 list_add(&crc->list, &crc_list.dev_list); in bfin_crypto_crc_probe()
691 if (crc->sg_cpu) in bfin_crypto_crc_probe()
692 dma_free_coherent(&pdev->dev, PAGE_SIZE, crc->sg_cpu, crc->sg_dma); in bfin_crypto_crc_probe()
693 free_dma(crc->dma_ch); in bfin_crypto_crc_probe()
704 struct bfin_crypto_crc *crc = platform_get_drvdata(pdev); in bfin_crypto_crc_remove() local
706 if (!crc) in bfin_crypto_crc_remove()
710 list_del(&crc->list); in bfin_crypto_crc_remove()
714 tasklet_kill(&crc->done_task); in bfin_crypto_crc_remove()
715 free_dma(crc->dma_ch); in bfin_crypto_crc_remove()