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