18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#ifndef _CORE_H_
78c2ecf20Sopenharmony_ci#define _CORE_H_
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include "dma.h"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/**
128c2ecf20Sopenharmony_ci * struct qce_device - crypto engine device structure
138c2ecf20Sopenharmony_ci * @queue: crypto request queue
148c2ecf20Sopenharmony_ci * @lock: the lock protects queue and req
158c2ecf20Sopenharmony_ci * @done_tasklet: done tasklet object
168c2ecf20Sopenharmony_ci * @req: current active request
178c2ecf20Sopenharmony_ci * @result: result of current transform
188c2ecf20Sopenharmony_ci * @base: virtual IO base
198c2ecf20Sopenharmony_ci * @dev: pointer to device structure
208c2ecf20Sopenharmony_ci * @core: core device clock
218c2ecf20Sopenharmony_ci * @iface: interface clock
228c2ecf20Sopenharmony_ci * @bus: bus clock
238c2ecf20Sopenharmony_ci * @dma: pointer to dma data
248c2ecf20Sopenharmony_ci * @burst_size: the crypto burst size
258c2ecf20Sopenharmony_ci * @pipe_pair_id: which pipe pair id the device using
268c2ecf20Sopenharmony_ci * @async_req_enqueue: invoked by every algorithm to enqueue a request
278c2ecf20Sopenharmony_ci * @async_req_done: invoked by every algorithm to finish its request
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_cistruct qce_device {
308c2ecf20Sopenharmony_ci	struct crypto_queue queue;
318c2ecf20Sopenharmony_ci	spinlock_t lock;
328c2ecf20Sopenharmony_ci	struct tasklet_struct done_tasklet;
338c2ecf20Sopenharmony_ci	struct crypto_async_request *req;
348c2ecf20Sopenharmony_ci	int result;
358c2ecf20Sopenharmony_ci	void __iomem *base;
368c2ecf20Sopenharmony_ci	struct device *dev;
378c2ecf20Sopenharmony_ci	struct clk *core, *iface, *bus;
388c2ecf20Sopenharmony_ci	struct qce_dma_data dma;
398c2ecf20Sopenharmony_ci	int burst_size;
408c2ecf20Sopenharmony_ci	unsigned int pipe_pair_id;
418c2ecf20Sopenharmony_ci	int (*async_req_enqueue)(struct qce_device *qce,
428c2ecf20Sopenharmony_ci				 struct crypto_async_request *req);
438c2ecf20Sopenharmony_ci	void (*async_req_done)(struct qce_device *qce, int ret);
448c2ecf20Sopenharmony_ci};
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/**
478c2ecf20Sopenharmony_ci * struct qce_algo_ops - algorithm operations per crypto type
488c2ecf20Sopenharmony_ci * @type: should be CRYPTO_ALG_TYPE_XXX
498c2ecf20Sopenharmony_ci * @register_algs: invoked by core to register the algorithms
508c2ecf20Sopenharmony_ci * @unregister_algs: invoked by core to unregister the algorithms
518c2ecf20Sopenharmony_ci * @async_req_handle: invoked by core to handle enqueued request
528c2ecf20Sopenharmony_ci */
538c2ecf20Sopenharmony_cistruct qce_algo_ops {
548c2ecf20Sopenharmony_ci	u32 type;
558c2ecf20Sopenharmony_ci	int (*register_algs)(struct qce_device *qce);
568c2ecf20Sopenharmony_ci	void (*unregister_algs)(struct qce_device *qce);
578c2ecf20Sopenharmony_ci	int (*async_req_handle)(struct crypto_async_request *async_req);
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci#endif /* _CORE_H_ */
61