blob: 4005102f0687998bc9c2a441e56ea8a9e389137d [file] [log] [blame]
Andrew F. Davis537d3ff2018-05-04 19:06:08 +00001/*
2 * Texas Instruments K3 Secure Proxy Driver
3 * Based on Linux and U-Boot implementation
4 *
5 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000010#ifndef SEC_PROXY_H
11#define SEC_PROXY_H
Andrew F. Davis537d3ff2018-05-04 19:06:08 +000012
13#include <stdint.h>
14
15/**
16 * enum k3_sec_proxy_chan_id - Secure Proxy thread IDs
17 *
18 * These the available IDs used in k3_sec_proxy_{send,recv}()
Nishanth Menond32de842020-12-10 18:39:41 -060019 * There are two schemes we use:
20 * * if K3_SEC_PROXY_LITE = 1, we just have two threads to talk
21 * * if K3_SEC_PROXY_LITE = 0, we have the full fledged
22 * communication scheme available.
Andrew F. Davis537d3ff2018-05-04 19:06:08 +000023 */
24enum k3_sec_proxy_chan_id {
Nishanth Menond32de842020-12-10 18:39:41 -060025#if !K3_SEC_PROXY_LITE
Andrew F. Davis537d3ff2018-05-04 19:06:08 +000026 SP_NOTIFY = 0,
27 SP_RESPONSE,
28 SP_HIGH_PRIORITY,
29 SP_LOW_PRIORITY,
30 SP_NOTIFY_RESP,
Nishanth Menond32de842020-12-10 18:39:41 -060031#else
32 SP_RESPONSE = 8,
33 /*
34 * Note: TISCI documentation indicates "low priority", but in reality
35 * with a single thread, there is no low or high priority.. This usage
36 * is more appropriate for TF-A since we can reduce the churn as a
37 * result.
38 */
39 SP_HIGH_PRIORITY,
40#endif /* K3_SEC_PROXY_LITE */
Andrew F. Davis537d3ff2018-05-04 19:06:08 +000041};
42
43/**
44 * struct k3_sec_proxy_msg - Secure proxy message structure
45 * @len: Length of data in the Buffer
46 * @buf: Buffer pointer
47 *
48 * This is the structure for data used in k3_sec_proxy_{send,recv}()
49 */
50struct k3_sec_proxy_msg {
51 size_t len;
52 uint8_t *buf;
53};
54
55/**
Andrew Davis5b9c6872022-04-28 09:39:02 -050056 * k3_sec_proxy_clear_rx_thread() - Clear a receive Secure Proxy thread
Andrew F. Davis537d3ff2018-05-04 19:06:08 +000057 * @id: Channel Identifier
58 * @msg: Pointer to k3_sec_proxy_msg
59 *
60 * Return: 0 if all goes well, else appropriate error message
61 */
Andrew F. Davis82a3c1d2019-01-04 12:44:00 -060062int k3_sec_proxy_clear_rx_thread(enum k3_sec_proxy_chan_id id);
63
64/**
65 * k3_sec_proxy_send() - Send data over a Secure Proxy thread
66 * @id: Channel Identifier
67 * @msg: Pointer to k3_sec_proxy_msg
68 *
69 * Return: 0 if all goes well, else appropriate error message
70 */
Andrew F. Davis537d3ff2018-05-04 19:06:08 +000071int k3_sec_proxy_send(enum k3_sec_proxy_chan_id id, const struct k3_sec_proxy_msg *msg);
72
73/**
74 * k3_sec_proxy_recv() - Receive data from a Secure Proxy thread
75 * @id: Channel Identifier
76 * @msg: Pointer to k3_sec_proxy_msg
77 *
78 * Return: 0 if all goes well, else appropriate error message
79 */
80int k3_sec_proxy_recv(enum k3_sec_proxy_chan_id id, struct k3_sec_proxy_msg *msg);
81
Antonio Nino Diaz5eb88372018-11-08 10:20:19 +000082#endif /* SEC_PROXY_H */