Lines Matching refs:qce
40 static void qce_unregister_algs(struct qce_device *qce) in qce_unregister_algs() argument
47 ops->unregister_algs(qce); in qce_unregister_algs()
51 static int qce_register_algs(struct qce_device *qce) in qce_register_algs() argument
58 ret = ops->register_algs(qce); in qce_register_algs()
61 ops->unregister_algs(qce); in qce_register_algs()
86 static int qce_handle_queue(struct qce_device *qce, in qce_handle_queue() argument
93 spin_lock_irqsave(&qce->lock, flags); in qce_handle_queue()
96 ret = crypto_enqueue_request(&qce->queue, req); in qce_handle_queue()
99 if (qce->req) { in qce_handle_queue()
100 spin_unlock_irqrestore(&qce->lock, flags); in qce_handle_queue()
104 backlog = crypto_get_backlog(&qce->queue); in qce_handle_queue()
105 async_req = crypto_dequeue_request(&qce->queue); in qce_handle_queue()
107 qce->req = async_req; in qce_handle_queue()
109 spin_unlock_irqrestore(&qce->lock, flags); in qce_handle_queue()
115 spin_lock_bh(&qce->lock); in qce_handle_queue()
117 spin_unlock_bh(&qce->lock); in qce_handle_queue()
122 qce->result = err; in qce_handle_queue()
123 tasklet_schedule(&qce->done_tasklet); in qce_handle_queue()
131 struct qce_device *qce = (struct qce_device *)data; in qce_tasklet_req_done() local
135 spin_lock_irqsave(&qce->lock, flags); in qce_tasklet_req_done()
136 req = qce->req; in qce_tasklet_req_done()
137 qce->req = NULL; in qce_tasklet_req_done()
138 spin_unlock_irqrestore(&qce->lock, flags); in qce_tasklet_req_done()
141 crypto_request_complete(req, qce->result); in qce_tasklet_req_done()
143 qce_handle_queue(qce, NULL); in qce_tasklet_req_done()
146 static int qce_async_request_enqueue(struct qce_device *qce, in qce_async_request_enqueue() argument
149 return qce_handle_queue(qce, req); in qce_async_request_enqueue()
152 static void qce_async_request_done(struct qce_device *qce, int ret) in qce_async_request_done() argument
154 qce->result = ret; in qce_async_request_done()
155 tasklet_schedule(&qce->done_tasklet); in qce_async_request_done()
158 static int qce_check_version(struct qce_device *qce) in qce_check_version() argument
162 qce_get_version(qce, &major, &minor, &step); in qce_check_version()
171 qce->burst_size = QCE_BAM_BURST_SIZE; in qce_check_version()
186 qce->pipe_pair_id = qce->dma.rxchan->chan_id >> 1; in qce_check_version()
188 dev_dbg(qce->dev, "Crypto device found, version %d.%d.%d\n", in qce_check_version()
197 struct qce_device *qce; in qce_crypto_probe() local
200 qce = devm_kzalloc(dev, sizeof(*qce), GFP_KERNEL); in qce_crypto_probe()
201 if (!qce) in qce_crypto_probe()
204 qce->dev = dev; in qce_crypto_probe()
205 platform_set_drvdata(pdev, qce); in qce_crypto_probe()
207 qce->base = devm_platform_ioremap_resource(pdev, 0); in qce_crypto_probe()
208 if (IS_ERR(qce->base)) in qce_crypto_probe()
209 return PTR_ERR(qce->base); in qce_crypto_probe()
215 qce->core = devm_clk_get_optional(qce->dev, "core"); in qce_crypto_probe()
216 if (IS_ERR(qce->core)) in qce_crypto_probe()
217 return PTR_ERR(qce->core); in qce_crypto_probe()
219 qce->iface = devm_clk_get_optional(qce->dev, "iface"); in qce_crypto_probe()
220 if (IS_ERR(qce->iface)) in qce_crypto_probe()
221 return PTR_ERR(qce->iface); in qce_crypto_probe()
223 qce->bus = devm_clk_get_optional(qce->dev, "bus"); in qce_crypto_probe()
224 if (IS_ERR(qce->bus)) in qce_crypto_probe()
225 return PTR_ERR(qce->bus); in qce_crypto_probe()
227 qce->mem_path = devm_of_icc_get(qce->dev, "memory"); in qce_crypto_probe()
228 if (IS_ERR(qce->mem_path)) in qce_crypto_probe()
229 return PTR_ERR(qce->mem_path); in qce_crypto_probe()
231 ret = icc_set_bw(qce->mem_path, QCE_DEFAULT_MEM_BANDWIDTH, QCE_DEFAULT_MEM_BANDWIDTH); in qce_crypto_probe()
235 ret = clk_prepare_enable(qce->core); in qce_crypto_probe()
239 ret = clk_prepare_enable(qce->iface); in qce_crypto_probe()
243 ret = clk_prepare_enable(qce->bus); in qce_crypto_probe()
247 ret = qce_dma_request(qce->dev, &qce->dma); in qce_crypto_probe()
251 ret = qce_check_version(qce); in qce_crypto_probe()
255 spin_lock_init(&qce->lock); in qce_crypto_probe()
256 tasklet_init(&qce->done_tasklet, qce_tasklet_req_done, in qce_crypto_probe()
257 (unsigned long)qce); in qce_crypto_probe()
258 crypto_init_queue(&qce->queue, QCE_QUEUE_LENGTH); in qce_crypto_probe()
260 qce->async_req_enqueue = qce_async_request_enqueue; in qce_crypto_probe()
261 qce->async_req_done = qce_async_request_done; in qce_crypto_probe()
263 ret = qce_register_algs(qce); in qce_crypto_probe()
270 qce_dma_release(&qce->dma); in qce_crypto_probe()
272 clk_disable_unprepare(qce->bus); in qce_crypto_probe()
274 clk_disable_unprepare(qce->iface); in qce_crypto_probe()
276 clk_disable_unprepare(qce->core); in qce_crypto_probe()
278 icc_set_bw(qce->mem_path, 0, 0); in qce_crypto_probe()
285 struct qce_device *qce = platform_get_drvdata(pdev); in qce_crypto_remove() local
287 tasklet_kill(&qce->done_tasklet); in qce_crypto_remove()
288 qce_unregister_algs(qce); in qce_crypto_remove()
289 qce_dma_release(&qce->dma); in qce_crypto_remove()
290 clk_disable_unprepare(qce->bus); in qce_crypto_remove()
291 clk_disable_unprepare(qce->iface); in qce_crypto_remove()
292 clk_disable_unprepare(qce->core); in qce_crypto_remove()