| 1 | /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */ |
| 2 | /* |
| 3 | * Userspace interface for AMD Seamless Firmware Servicing (SFS) |
| 4 | * |
| 5 | * Copyright (C) 2025 Advanced Micro Devices, Inc. |
| 6 | * |
| 7 | * Author: Ashish Kalra <ashish.kalra@amd.com> |
| 8 | */ |
| 9 | |
| 10 | #ifndef __PSP_SFS_USER_H__ |
| 11 | #define __PSP_SFS_USER_H__ |
| 12 | |
| 13 | #include <linux/types.h> |
| 14 | |
| 15 | /** |
| 16 | * SFS: AMD Seamless Firmware Support (SFS) interface |
| 17 | */ |
| 18 | |
| 19 | #define PAYLOAD_NAME_SIZE 64 |
| 20 | #define TEE_EXT_CMD_BUFFER_SIZE 4096 |
| 21 | |
| 22 | /** |
| 23 | * struct sfs_user_get_fw_versions - get current level of base firmware (output). |
| 24 | * @blob: current level of base firmware for ASP and patch levels (input/output). |
| 25 | * @sfs_status: 32-bit SFS status value (output). |
| 26 | * @sfs_extended_status: 32-bit SFS extended status value (output). |
| 27 | */ |
| 28 | struct sfs_user_get_fw_versions { |
| 29 | __u8 blob[TEE_EXT_CMD_BUFFER_SIZE]; |
| 30 | __u32 sfs_status; |
| 31 | __u32 sfs_extended_status; |
| 32 | } __packed; |
| 33 | |
| 34 | /** |
| 35 | * struct sfs_user_update_package - update SFS package (input). |
| 36 | * @payload_name: name of SFS package to load, verify and execute (input). |
| 37 | * @sfs_status: 32-bit SFS status value (output). |
| 38 | * @sfs_extended_status: 32-bit SFS extended status value (output). |
| 39 | */ |
| 40 | struct sfs_user_update_package { |
| 41 | char payload_name[PAYLOAD_NAME_SIZE]; |
| 42 | __u32 sfs_status; |
| 43 | __u32 sfs_extended_status; |
| 44 | } __packed; |
| 45 | |
| 46 | /** |
| 47 | * Seamless Firmware Support (SFS) IOC |
| 48 | * |
| 49 | * possible return codes for all SFS IOCTLs: |
| 50 | * 0: success |
| 51 | * -EINVAL: invalid input |
| 52 | * -E2BIG: excess data passed |
| 53 | * -EFAULT: failed to copy to/from userspace |
| 54 | * -EBUSY: mailbox in recovery or in use |
| 55 | * -ENODEV: driver not bound with PSP device |
| 56 | * -EACCES: request isn't authorized |
| 57 | * -EINVAL: invalid parameter |
| 58 | * -ETIMEDOUT: request timed out |
| 59 | * -EAGAIN: invalid request for state machine |
| 60 | * -ENOENT: not implemented |
| 61 | * -ENFILE: overflow |
| 62 | * -EPERM: invalid signature |
| 63 | * -EIO: PSP I/O error |
| 64 | */ |
| 65 | #define SFS_IOC_TYPE 'S' |
| 66 | |
| 67 | /** |
| 68 | * SFSIOCFWVERS - returns blob containing FW versions |
| 69 | * ASP provides the current level of Base Firmware for the ASP |
| 70 | * and the other microprocessors as well as current patch |
| 71 | * level(s). |
| 72 | */ |
| 73 | #define SFSIOCFWVERS _IOWR(SFS_IOC_TYPE, 0x1, struct sfs_user_get_fw_versions) |
| 74 | |
| 75 | /** |
| 76 | * SFSIOCUPDATEPKG - updates package/payload |
| 77 | * ASP loads, verifies and executes the SFS package. |
| 78 | * By default, the SFS package/payload is loaded from |
| 79 | * /lib/firmware/amd, but alternative firmware loading |
| 80 | * path can be specified using kernel parameter |
| 81 | * firmware_class.path or the firmware loading path |
| 82 | * can be customized using sysfs file: |
| 83 | * /sys/module/firmware_class/parameters/path. |
| 84 | */ |
| 85 | #define SFSIOCUPDATEPKG _IOWR(SFS_IOC_TYPE, 0x2, struct sfs_user_update_package) |
| 86 | |
| 87 | #endif /* __PSP_SFS_USER_H__ */ |
| 88 | |