1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __PSP_PLATFORM_ACCESS_H
4 #define __PSP_PLATFORM_ACCESS_H
5 
6 #include <linux/psp.h>
7 
8 enum psp_platform_access_msg {
9 	PSP_CMD_NONE = 0x0,
10 };
11 
12 struct psp_req_buffer_hdr {
13 	u32 payload_size;
14 	u32 status;
15 } __packed;
16 
17 struct psp_request {
18 	struct psp_req_buffer_hdr header;
19 	void *buf;
20 } __packed;
21 
22 /**
23  * psp_send_platform_access_msg() - Send a message to control platform features
24  *
25  * This function is intended to be used by drivers outside of ccp to communicate
26  * with the platform.
27  *
28  * Returns:
29  *  0:           success
30  *  -%EBUSY:     mailbox in recovery or in use
31  *  -%ENODEV:    driver not bound with PSP device
32  *  -%ETIMEDOUT: request timed out
33  *  -%EIO:       unknown error (see kernel log)
34  */
35 int psp_send_platform_access_msg(enum psp_platform_access_msg, struct psp_request *req);
36 
37 /**
38  * psp_ring_platform_doorbell() - Ring platform doorbell
39  *
40  * This function is intended to be used by drivers outside of ccp to ring the
41  * platform doorbell with a message.
42  *
43  * Returns:
44  *  0:           success
45  *  -%EBUSY:     mailbox in recovery or in use
46  *  -%ENODEV:    driver not bound with PSP device
47  *  -%ETIMEDOUT: request timed out
48  *  -%EIO:       unknown error (see kernel log)
49  */
50 int psp_ring_platform_doorbell(int msg);
51 
52 /**
53  * psp_check_platform_access_status() - Checks whether platform features is ready
54  *
55  * This function is intended to be used by drivers outside of ccp to determine
56  * if platform features has initialized.
57  *
58  * Returns:
59  * 0          platform features is ready
60  * -%ENODEV   platform features is not ready or present
61  */
62 int psp_check_platform_access_status(void);
63 
64 #endif /* __PSP_PLATFORM_ACCESS_H */
65