Lines Matching full:sha
9 * Some ideas are from atmel-sha.c and omap-sham.c drivers.
13 #include <crypto/sha.h>
26 /* SHA command token */
33 /* SHA transform information */
46 /* SHA flags */
275 /* Initialize basic transform information of SHA */
321 struct mtk_sha_rec *sha, in mtk_sha_info_update() argument
324 struct mtk_sha_reqctx *ctx = ahash_request_ctx(sha->req); in mtk_sha_info_update()
421 static int mtk_sha_xmit(struct mtk_cryp *cryp, struct mtk_sha_rec *sha, in mtk_sha_xmit() argument
425 struct mtk_sha_reqctx *ctx = ahash_request_ctx(sha->req); in mtk_sha_xmit()
426 struct mtk_ring *ring = cryp->ring[sha->id]; in mtk_sha_xmit()
430 err = mtk_sha_info_update(cryp, sha, len1, len2); in mtk_sha_xmit()
462 mtk_sha_write(cryp, RDR_PREP_COUNT(sha->id), MTK_DESC_CNT(count)); in mtk_sha_xmit()
463 mtk_sha_write(cryp, CDR_PREP_COUNT(sha->id), MTK_DESC_CNT(count)); in mtk_sha_xmit()
469 struct mtk_sha_rec *sha, in mtk_sha_dma_map() argument
482 return mtk_sha_xmit(cryp, sha, ctx->dma_addr, count, 0, 0); in mtk_sha_dma_map()
486 struct mtk_sha_rec *sha) in mtk_sha_update_slow() argument
488 struct mtk_sha_reqctx *ctx = ahash_request_ctx(sha->req); in mtk_sha_update_slow()
499 sha->flags |= SHA_FLAGS_FINAL; in mtk_sha_update_slow()
507 return mtk_sha_dma_map(cryp, sha, ctx, count); in mtk_sha_update_slow()
513 struct mtk_sha_rec *sha) in mtk_sha_update_start() argument
515 struct mtk_sha_reqctx *ctx = ahash_request_ctx(sha->req); in mtk_sha_update_start()
523 return mtk_sha_update_slow(cryp, sha); in mtk_sha_update_start()
528 return mtk_sha_update_slow(cryp, sha); in mtk_sha_update_start()
532 return mtk_sha_update_slow(cryp, sha); in mtk_sha_update_start()
569 sha->flags |= SHA_FLAGS_FINAL; in mtk_sha_update_start()
575 return mtk_sha_xmit(cryp, sha, ctx->dma_addr, in mtk_sha_update_start()
586 return mtk_sha_xmit(cryp, sha, sg_dma_address(ctx->sg), in mtk_sha_update_start()
598 return mtk_sha_xmit(cryp, sha, sg_dma_address(ctx->sg), in mtk_sha_update_start()
603 struct mtk_sha_rec *sha) in mtk_sha_final_req() argument
605 struct mtk_sha_reqctx *ctx = ahash_request_ctx(sha->req); in mtk_sha_final_req()
610 sha->flags |= SHA_FLAGS_FINAL; in mtk_sha_final_req()
614 return mtk_sha_dma_map(cryp, sha, ctx, count); in mtk_sha_final_req()
636 struct mtk_sha_rec *sha, in mtk_sha_finish_req() argument
639 if (likely(!err && (SHA_FLAGS_FINAL & sha->flags))) in mtk_sha_finish_req()
640 err = mtk_sha_finish(sha->req); in mtk_sha_finish_req()
642 sha->flags &= ~(SHA_FLAGS_BUSY | SHA_FLAGS_FINAL); in mtk_sha_finish_req()
644 sha->req->base.complete(&sha->req->base, err); in mtk_sha_finish_req()
647 tasklet_schedule(&sha->queue_task); in mtk_sha_finish_req()
653 struct mtk_sha_rec *sha = cryp->sha[id]; in mtk_sha_handle_queue() local
659 spin_lock_irqsave(&sha->lock, flags); in mtk_sha_handle_queue()
661 ret = ahash_enqueue_request(&sha->queue, req); in mtk_sha_handle_queue()
663 if (SHA_FLAGS_BUSY & sha->flags) { in mtk_sha_handle_queue()
664 spin_unlock_irqrestore(&sha->lock, flags); in mtk_sha_handle_queue()
668 backlog = crypto_get_backlog(&sha->queue); in mtk_sha_handle_queue()
669 async_req = crypto_dequeue_request(&sha->queue); in mtk_sha_handle_queue()
671 sha->flags |= SHA_FLAGS_BUSY; in mtk_sha_handle_queue()
672 spin_unlock_irqrestore(&sha->lock, flags); in mtk_sha_handle_queue()
683 sha->req = req; in mtk_sha_handle_queue()
688 err = mtk_sha_update_start(cryp, sha); in mtk_sha_handle_queue()
691 err = mtk_sha_final_req(cryp, sha); in mtk_sha_handle_queue()
693 err = mtk_sha_final_req(cryp, sha); in mtk_sha_handle_queue()
698 mtk_sha_finish_req(cryp, sha, err); in mtk_sha_handle_queue()
713 static void mtk_sha_unmap(struct mtk_cryp *cryp, struct mtk_sha_rec *sha) in mtk_sha_unmap() argument
715 struct mtk_sha_reqctx *ctx = ahash_request_ctx(sha->req); in mtk_sha_unmap()
737 struct mtk_sha_rec *sha) in mtk_sha_complete() argument
741 err = mtk_sha_update_start(cryp, sha); in mtk_sha_complete()
743 mtk_sha_finish_req(cryp, sha, err); in mtk_sha_complete()
1168 struct mtk_sha_rec *sha = (struct mtk_sha_rec *)data; in mtk_sha_queue_task() local
1170 mtk_sha_handle_queue(sha->cryp, sha->id - MTK_RING2, NULL); in mtk_sha_queue_task()
1175 struct mtk_sha_rec *sha = (struct mtk_sha_rec *)data; in mtk_sha_done_task() local
1176 struct mtk_cryp *cryp = sha->cryp; in mtk_sha_done_task()
1178 mtk_sha_unmap(cryp, sha); in mtk_sha_done_task()
1179 mtk_sha_complete(cryp, sha); in mtk_sha_done_task()
1184 struct mtk_sha_rec *sha = (struct mtk_sha_rec *)dev_id; in mtk_sha_irq() local
1185 struct mtk_cryp *cryp = sha->cryp; in mtk_sha_irq()
1186 u32 val = mtk_sha_read(cryp, RDR_STAT(sha->id)); in mtk_sha_irq()
1188 mtk_sha_write(cryp, RDR_STAT(sha->id), val); in mtk_sha_irq()
1190 if (likely((SHA_FLAGS_BUSY & sha->flags))) { in mtk_sha_irq()
1191 mtk_sha_write(cryp, RDR_PROC_COUNT(sha->id), MTK_CNT_RST); in mtk_sha_irq()
1192 mtk_sha_write(cryp, RDR_THRESH(sha->id), in mtk_sha_irq()
1195 tasklet_schedule(&sha->done_task); in mtk_sha_irq()
1197 dev_warn(cryp->dev, "SHA interrupt when no active requests.\n"); in mtk_sha_irq()
1203 * The purpose of two SHA records is used to get extra performance.
1208 struct mtk_sha_rec **sha = cryp->sha; in mtk_sha_record_init() local
1212 sha[i] = kzalloc(sizeof(**sha), GFP_KERNEL); in mtk_sha_record_init()
1213 if (!sha[i]) in mtk_sha_record_init()
1216 sha[i]->cryp = cryp; in mtk_sha_record_init()
1218 spin_lock_init(&sha[i]->lock); in mtk_sha_record_init()
1219 crypto_init_queue(&sha[i]->queue, SHA_QUEUE_SIZE); in mtk_sha_record_init()
1221 tasklet_init(&sha[i]->queue_task, mtk_sha_queue_task, in mtk_sha_record_init()
1222 (unsigned long)sha[i]); in mtk_sha_record_init()
1223 tasklet_init(&sha[i]->done_task, mtk_sha_done_task, in mtk_sha_record_init()
1224 (unsigned long)sha[i]); in mtk_sha_record_init()
1228 sha[0]->id = MTK_RING2; in mtk_sha_record_init()
1229 sha[1]->id = MTK_RING3; in mtk_sha_record_init()
1237 kfree(sha[i]); in mtk_sha_record_init()
1246 tasklet_kill(&cryp->sha[i]->done_task); in mtk_sha_record_free()
1247 tasklet_kill(&cryp->sha[i]->queue_task); in mtk_sha_record_free()
1249 kfree(cryp->sha[i]); in mtk_sha_record_free()
1305 0, "mtk-sha", cryp->sha[0]); in mtk_hash_alg_register()
1307 dev_err(cryp->dev, "unable to request sha irq0.\n"); in mtk_hash_alg_register()
1312 0, "mtk-sha", cryp->sha[1]); in mtk_hash_alg_register()
1314 dev_err(cryp->dev, "unable to request sha irq1.\n"); in mtk_hash_alg_register()
1340 dev_err(cryp->dev, "mtk-sha initialization failed.\n"); in mtk_hash_alg_register()