1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Driver for Qualcomm Secure Execution Environment (SEE) interface (QSEECOM).
4  * Responsible for setting up and managing QSEECOM client devices.
5  *
6  * Copyright (C) 2023 Maximilian Luz <luzmaximilian@gmail.com>
7  */
8 
9 #ifndef __QCOM_QSEECOM_H
10 #define __QCOM_QSEECOM_H
11 
12 #include <linux/auxiliary_bus.h>
13 #include <linux/dma-mapping.h>
14 #include <linux/types.h>
15 
16 #include <linux/firmware/qcom/qcom_scm.h>
17 
18 /**
19  * struct qseecom_client - QSEECOM client device.
20  * @aux_dev: Underlying auxiliary device.
21  * @app_id: ID of the loaded application.
22  */
23 struct qseecom_client {
24 	struct auxiliary_device aux_dev;
25 	u32 app_id;
26 };
27 
28 /**
29  * qcom_qseecom_app_send() - Send to and receive data from a given QSEE app.
30  * @client:   The QSEECOM client associated with the target app.
31  * @req:      Request buffer sent to the app (must be TZ memory).
32  * @req_size: Size of the request buffer.
33  * @rsp:      Response buffer, written to by the app (must be TZ memory).
34  * @rsp_size: Size of the response buffer.
35  *
36  * Sends a request to the QSEE app associated with the given client and read
37  * back its response. The caller must provide two DMA memory regions, one for
38  * the request and one for the response, and fill out the @req region with the
39  * respective (app-specific) request data. The QSEE app reads this and returns
40  * its response in the @rsp region.
41  *
42  * Note: This is a convenience wrapper around qcom_scm_qseecom_app_send().
43  * Clients should prefer to use this wrapper.
44  *
45  * Return: Zero on success, nonzero on failure.
46  */
qcom_qseecom_app_send(struct qseecom_client * client,void * req,size_t req_size,void * rsp,size_t rsp_size)47 static inline int qcom_qseecom_app_send(struct qseecom_client *client,
48 					void *req, size_t req_size,
49 					void *rsp, size_t rsp_size)
50 {
51 	return qcom_scm_qseecom_app_send(client->app_id, req, req_size, rsp, rsp_size);
52 }
53 
54 #endif /* __QCOM_QSEECOM_H */
55