1 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
3 * Greybus Firmware Management User Header
5 * Copyright(c) 2016 Google Inc. All rights reserved.
6 * Copyright(c) 2016 Linaro Ltd. All rights reserved.
9 #ifndef __GREYBUS_FIRMWARE_USER_H
10 #define __GREYBUS_FIRMWARE_USER_H
12 #include <linux/ioctl.h>
13 #include <linux/types.h>
15 #define GB_FIRMWARE_U_TAG_MAX_SIZE 10
17 #define GB_FW_U_LOAD_METHOD_UNIPRO 0x01
18 #define GB_FW_U_LOAD_METHOD_INTERNAL 0x02
20 #define GB_FW_U_LOAD_STATUS_FAILED 0x00
21 #define GB_FW_U_LOAD_STATUS_UNVALIDATED 0x01
22 #define GB_FW_U_LOAD_STATUS_VALIDATED 0x02
23 #define GB_FW_U_LOAD_STATUS_VALIDATION_FAILED 0x03
25 #define GB_FW_U_BACKEND_FW_STATUS_SUCCESS 0x01
26 #define GB_FW_U_BACKEND_FW_STATUS_FAIL_FIND 0x02
27 #define GB_FW_U_BACKEND_FW_STATUS_FAIL_FETCH 0x03
28 #define GB_FW_U_BACKEND_FW_STATUS_FAIL_WRITE 0x04
29 #define GB_FW_U_BACKEND_FW_STATUS_INT 0x05
30 #define GB_FW_U_BACKEND_FW_STATUS_RETRY 0x06
31 #define GB_FW_U_BACKEND_FW_STATUS_NOT_SUPPORTED 0x07
33 #define GB_FW_U_BACKEND_VERSION_STATUS_SUCCESS 0x01
34 #define GB_FW_U_BACKEND_VERSION_STATUS_NOT_AVAILABLE 0x02
35 #define GB_FW_U_BACKEND_VERSION_STATUS_NOT_SUPPORTED 0x03
36 #define GB_FW_U_BACKEND_VERSION_STATUS_RETRY 0x04
37 #define GB_FW_U_BACKEND_VERSION_STATUS_FAIL_INT 0x05
40 struct fw_mgmt_ioc_get_intf_version {
41 __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
44 } __attribute__ ((__packed__));
46 struct fw_mgmt_ioc_get_backend_version {
47 __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
51 } __attribute__ ((__packed__));
53 struct fw_mgmt_ioc_intf_load_and_validate {
54 __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
59 } __attribute__ ((__packed__));
61 struct fw_mgmt_ioc_backend_fw_update {
62 __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
64 } __attribute__ ((__packed__));
66 #define FW_MGMT_IOCTL_BASE 'F'
67 #define FW_MGMT_IOC_GET_INTF_FW _IOR(FW_MGMT_IOCTL_BASE, 0, struct fw_mgmt_ioc_get_intf_version)
68 #define FW_MGMT_IOC_GET_BACKEND_FW _IOWR(FW_MGMT_IOCTL_BASE, 1, struct fw_mgmt_ioc_get_backend_version)
69 #define FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE _IOWR(FW_MGMT_IOCTL_BASE, 2, struct fw_mgmt_ioc_intf_load_and_validate)
70 #define FW_MGMT_IOC_INTF_BACKEND_FW_UPDATE _IOWR(FW_MGMT_IOCTL_BASE, 3, struct fw_mgmt_ioc_backend_fw_update)
71 #define FW_MGMT_IOC_SET_TIMEOUT_MS _IOW(FW_MGMT_IOCTL_BASE, 4, unsigned int)
72 #define FW_MGMT_IOC_MODE_SWITCH _IO(FW_MGMT_IOCTL_BASE, 5)
74 #endif /* __GREYBUS_FIRMWARE_USER_H */