xref: /linux/include/linux/psp-platform-access.h (revision db10cb9b)
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 	PSP_I2C_REQ_BUS_CMD = 0x64,
11 	PSP_DYNAMIC_BOOST_GET_NONCE,
12 	PSP_DYNAMIC_BOOST_SET_UID,
13 	PSP_DYNAMIC_BOOST_GET_PARAMETER,
14 	PSP_DYNAMIC_BOOST_SET_PARAMETER,
15 };
16 
17 struct psp_req_buffer_hdr {
18 	u32 payload_size;
19 	u32 status;
20 } __packed;
21 
22 struct psp_request {
23 	struct psp_req_buffer_hdr header;
24 	void *buf;
25 } __packed;
26 
27 /**
28  * psp_send_platform_access_msg() - Send a message to control platform features
29  *
30  * This function is intended to be used by drivers outside of ccp to communicate
31  * with the platform.
32  *
33  * Returns:
34  *  0:           success
35  *  -%EBUSY:     mailbox in recovery or in use
36  *  -%ENODEV:    driver not bound with PSP device
37  *  -%ETIMEDOUT: request timed out
38  *  -%EIO:       unknown error (see kernel log)
39  */
40 int psp_send_platform_access_msg(enum psp_platform_access_msg, struct psp_request *req);
41 
42 /**
43  * psp_ring_platform_doorbell() - Ring platform doorbell
44  *
45  * This function is intended to be used by drivers outside of ccp to ring the
46  * platform doorbell with a message.
47  *
48  * Returns:
49  *  0:           success
50  *  -%EBUSY:     mailbox in recovery or in use
51  *  -%ENODEV:    driver not bound with PSP device
52  *  -%ETIMEDOUT: request timed out
53  *  -%EIO:       error will be stored in result argument
54  */
55 int psp_ring_platform_doorbell(int msg, u32 *result);
56 
57 /**
58  * psp_check_platform_access_status() - Checks whether platform features is ready
59  *
60  * This function is intended to be used by drivers outside of ccp to determine
61  * if platform features has initialized.
62  *
63  * Returns:
64  * 0          platform features is ready
65  * -%ENODEV   platform features is not ready or present
66  */
67 int psp_check_platform_access_status(void);
68 
69 #endif /* __PSP_PLATFORM_ACCESS_H */
70