Lines Matching refs:cryp
39 static inline int starfive_hash_wait_busy(struct starfive_cryp_dev *cryp) in starfive_hash_wait_busy() argument
43 return readl_relaxed_poll_timeout(cryp->base + STARFIVE_HASH_SHACSR, status, in starfive_hash_wait_busy()
47 static inline int starfive_hash_wait_hmac_done(struct starfive_cryp_dev *cryp) in starfive_hash_wait_hmac_done() argument
51 return readl_relaxed_poll_timeout(cryp->base + STARFIVE_HASH_SHACSR, status, in starfive_hash_wait_hmac_done()
57 struct starfive_cryp_dev *cryp = ctx->cryp; in starfive_hash_wait_key_done() local
60 return readl_relaxed_poll_timeout(cryp->base + STARFIVE_HASH_SHACSR, status, in starfive_hash_wait_key_done()
67 struct starfive_cryp_dev *cryp = ctx->cryp; in starfive_hash_hmac_key() local
72 writel(ctx->keylen, cryp->base + STARFIVE_HASH_SHAWKLEN); in starfive_hash_hmac_key()
77 writel(rctx->csr.hash.v, cryp->base + STARFIVE_HASH_SHACSR); in starfive_hash_hmac_key()
80 writel(*key, cryp->base + STARFIVE_HASH_SHAWKR); in starfive_hash_hmac_key()
85 writeb(*cl, cryp->base + STARFIVE_HASH_SHAWKR); in starfive_hash_hmac_key()
89 return dev_err_probe(cryp->dev, -ETIMEDOUT, "starfive_hash_wait_key_done error\n"); in starfive_hash_hmac_key()
94 static void starfive_hash_start(struct starfive_cryp_dev *cryp) in starfive_hash_start() argument
98 csr.v = readl(cryp->base + STARFIVE_HASH_SHACSR); in starfive_hash_start()
101 writel(csr.v, cryp->base + STARFIVE_HASH_SHACSR); in starfive_hash_start()
106 struct starfive_cryp_dev *cryp = param; in starfive_hash_dma_callback() local
108 complete(&cryp->dma_done); in starfive_hash_dma_callback()
111 static void starfive_hash_dma_init(struct starfive_cryp_dev *cryp) in starfive_hash_dma_init() argument
113 cryp->cfg_in.src_addr_width = DMA_SLAVE_BUSWIDTH_16_BYTES; in starfive_hash_dma_init()
114 cryp->cfg_in.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in starfive_hash_dma_init()
115 cryp->cfg_in.src_maxburst = cryp->dma_maxburst; in starfive_hash_dma_init()
116 cryp->cfg_in.dst_maxburst = cryp->dma_maxburst; in starfive_hash_dma_init()
117 cryp->cfg_in.dst_addr = cryp->phys_base + STARFIVE_ALG_FIFO_OFFSET; in starfive_hash_dma_init()
119 dmaengine_slave_config(cryp->tx, &cryp->cfg_in); in starfive_hash_dma_init()
121 init_completion(&cryp->dma_done); in starfive_hash_dma_init()
124 static int starfive_hash_dma_xfer(struct starfive_cryp_dev *cryp, in starfive_hash_dma_xfer() argument
134 writel(alg_cr.v, cryp->base + STARFIVE_ALG_CR_OFFSET); in starfive_hash_dma_xfer()
136 writel(sg_dma_len(sg), cryp->base + STARFIVE_DMA_IN_LEN_OFFSET); in starfive_hash_dma_xfer()
139 in_desc = dmaengine_prep_slave_sg(cryp->tx, sg, 1, DMA_MEM_TO_DEV, in starfive_hash_dma_xfer()
146 reinit_completion(&cryp->dma_done); in starfive_hash_dma_xfer()
148 in_desc->callback_param = cryp; in starfive_hash_dma_xfer()
151 dma_async_issue_pending(cryp->tx); in starfive_hash_dma_xfer()
153 if (!wait_for_completion_timeout(&cryp->dma_done, in starfive_hash_dma_xfer()
160 writel(alg_cr.v, cryp->base + STARFIVE_ALG_CR_OFFSET); in starfive_hash_dma_xfer()
179 put_unaligned(readl(ctx->cryp->base + STARFIVE_HASH_SHARDR), in starfive_hash_copy_hash()
185 static void starfive_hash_done_task(struct starfive_cryp_dev *cryp) in starfive_hash_done_task() argument
187 int err = cryp->err; in starfive_hash_done_task()
190 err = starfive_hash_copy_hash(cryp->req.hreq); in starfive_hash_done_task()
192 crypto_finalize_hash_request(cryp->engine, cryp->req.hreq, err); in starfive_hash_done_task()
201 struct starfive_cryp_dev *cryp = ctx->cryp; in starfive_hash_one_request() local
205 writel(STARFIVE_HASH_RESET, cryp->base + STARFIVE_HASH_SHACSR); in starfive_hash_one_request()
207 if (starfive_hash_wait_busy(cryp)) in starfive_hash_one_request()
208 return dev_err_probe(cryp->dev, -ETIMEDOUT, "Error resetting hardware\n"); in starfive_hash_one_request()
220 writel(rctx->csr.hash.v, cryp->base + STARFIVE_HASH_SHACSR); in starfive_hash_one_request()
227 starfive_hash_dma_init(cryp); in starfive_hash_one_request()
230 src_nents = dma_map_sg(cryp->dev, tsg, 1, DMA_TO_DEVICE); in starfive_hash_one_request()
232 return dev_err_probe(cryp->dev, -ENOMEM, in starfive_hash_one_request()
235 ret = starfive_hash_dma_xfer(cryp, tsg); in starfive_hash_one_request()
236 dma_unmap_sg(cryp->dev, tsg, 1, DMA_TO_DEVICE); in starfive_hash_one_request()
242 starfive_hash_start(cryp); in starfive_hash_one_request()
244 if (starfive_hash_wait_busy(cryp)) in starfive_hash_one_request()
245 return dev_err_probe(cryp->dev, -ETIMEDOUT, "Error generating digest\n"); in starfive_hash_one_request()
248 cryp->err = starfive_hash_wait_hmac_done(cryp); in starfive_hash_one_request()
250 starfive_hash_done_task(cryp); in starfive_hash_one_request()
328 struct starfive_cryp_dev *cryp = ctx->cryp; in starfive_hash_digest() local
332 cryp->req.hreq = req; in starfive_hash_digest()
340 return crypto_transfer_hash_request_to_engine(cryp->engine, req); in starfive_hash_digest()
378 ctx->cryp = starfive_cryp_find_dev(ctx); in starfive_hash_init_tfm()
380 if (!ctx->cryp) in starfive_hash_init_tfm()
387 return dev_err_probe(ctx->cryp->dev, PTR_ERR(ctx->ahash_fbk), in starfive_hash_init_tfm()