1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
3 * Greybus Firmware Management User Header
5 * This file is provided under a dual BSD/GPLv2 license. When using or
6 * redistributing this file, you may do so under either license.
10 * Copyright(c) 2016 Google Inc. All rights reserved.
11 * Copyright(c) 2016 Linaro Ltd. All rights reserved.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of version 2 of the GNU General Public License as
15 * published by the Free Software Foundation.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License version 2 for more details.
24 * Copyright(c) 2016 Google Inc. All rights reserved.
25 * Copyright(c) 2016 Linaro Ltd. All rights reserved.
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
31 * * Redistributions of source code must retain the above copyright
32 * notice, this list of conditions and the following disclaimer.
33 * * Redistributions in binary form must reproduce the above copyright
34 * notice, this list of conditions and the following disclaimer in
35 * the documentation and/or other materials provided with the
37 * * Neither the name of Google Inc. or Linaro Ltd. nor the names of
38 * its contributors may be used to endorse or promote products
39 * derived from this software without specific prior written
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC. OR
46 * LINARO LTD. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
47 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
48 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
49 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
50 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 #ifndef __GREYBUS_FIRMWARE_USER_H
56 #define __GREYBUS_FIRMWARE_USER_H
58 #include <linux/ioctl.h>
59 #include <linux/types.h>
61 #define GB_FIRMWARE_U_TAG_MAX_SIZE 10
63 #define GB_FW_U_LOAD_METHOD_UNIPRO 0x01
64 #define GB_FW_U_LOAD_METHOD_INTERNAL 0x02
66 #define GB_FW_U_LOAD_STATUS_FAILED 0x00
67 #define GB_FW_U_LOAD_STATUS_UNVALIDATED 0x01
68 #define GB_FW_U_LOAD_STATUS_VALIDATED 0x02
69 #define GB_FW_U_LOAD_STATUS_VALIDATION_FAILED 0x03
71 #define GB_FW_U_BACKEND_FW_STATUS_SUCCESS 0x01
72 #define GB_FW_U_BACKEND_FW_STATUS_FAIL_FIND 0x02
73 #define GB_FW_U_BACKEND_FW_STATUS_FAIL_FETCH 0x03
74 #define GB_FW_U_BACKEND_FW_STATUS_FAIL_WRITE 0x04
75 #define GB_FW_U_BACKEND_FW_STATUS_INT 0x05
76 #define GB_FW_U_BACKEND_FW_STATUS_RETRY 0x06
77 #define GB_FW_U_BACKEND_FW_STATUS_NOT_SUPPORTED 0x07
79 #define GB_FW_U_BACKEND_VERSION_STATUS_SUCCESS 0x01
80 #define GB_FW_U_BACKEND_VERSION_STATUS_NOT_AVAILABLE 0x02
81 #define GB_FW_U_BACKEND_VERSION_STATUS_NOT_SUPPORTED 0x03
82 #define GB_FW_U_BACKEND_VERSION_STATUS_RETRY 0x04
83 #define GB_FW_U_BACKEND_VERSION_STATUS_FAIL_INT 0x05
86 struct fw_mgmt_ioc_get_intf_version {
87 __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
90 } __attribute__ ((__packed__));
92 struct fw_mgmt_ioc_get_backend_version {
93 __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
97 } __attribute__ ((__packed__));
99 struct fw_mgmt_ioc_intf_load_and_validate {
100 __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
105 } __attribute__ ((__packed__));
107 struct fw_mgmt_ioc_backend_fw_update {
108 __u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_SIZE];
110 } __attribute__ ((__packed__));
112 #define FW_MGMT_IOCTL_BASE 'F'
113 #define FW_MGMT_IOC_GET_INTF_FW _IOR(FW_MGMT_IOCTL_BASE, 0, struct fw_mgmt_ioc_get_intf_version)
114 #define FW_MGMT_IOC_GET_BACKEND_FW _IOWR(FW_MGMT_IOCTL_BASE, 1, struct fw_mgmt_ioc_get_backend_version)
115 #define FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE _IOWR(FW_MGMT_IOCTL_BASE, 2, struct fw_mgmt_ioc_intf_load_and_validate)
116 #define FW_MGMT_IOC_INTF_BACKEND_FW_UPDATE _IOWR(FW_MGMT_IOCTL_BASE, 3, struct fw_mgmt_ioc_backend_fw_update)
117 #define FW_MGMT_IOC_SET_TIMEOUT_MS _IOW(FW_MGMT_IOCTL_BASE, 4, unsigned int)
118 #define FW_MGMT_IOC_MODE_SWITCH _IO(FW_MGMT_IOCTL_BASE, 5)
120 #endif /* __GREYBUS_FIRMWARE_USER_H */