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