1
0
Fork 0

greybus: firmware: Update Documentation and sample application

Update documentation and sample application to capture the 'status' byte
in backend version operation and new error types in backend firmware
update operation.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
hifive-unleashed-5.1
Viresh Kumar 2016-07-25 14:38:09 -07:00 committed by Greg Kroah-Hartman
parent 5e10f0047a
commit 6136cce89c
2 changed files with 52 additions and 17 deletions

View File

@ -93,12 +93,28 @@ Following are the IOCTLs and their data structures available to the user:
#define GB_FW_BACKEND_FW_STATUS_FAIL_FETCH 0x03
#define GB_FW_BACKEND_FW_STATUS_FAIL_WRITE 0x04
#define GB_FW_BACKEND_FW_STATUS_INT 0x05
#define GB_FW_BACKEND_FW_STATUS_RETRY 0x06
#define GB_FW_BACKEND_FW_STATUS_NOT_SUPPORTED 0x07
struct fw_mgmt_ioc_get_fw {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
__u16 major;
__u16 minor;
} __packed;
#define GB_FW_BACKEND_VERSION_STATUS_SUCCESS 0x01
#define GB_FW_BACKEND_VERSION_STATUS_NOT_AVAILABLE 0x02
#define GB_FW_BACKEND_VERSION_STATUS_NOT_SUPPORTED 0x03
#define GB_FW_BACKEND_VERSION_STATUS_RETRY 0x04
#define GB_FW_BACKEND_VERSION_STATUS_FAIL_INT 0x05
struct fw_mgmt_ioc_get_intf_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
__u16 major;
__u16 minor;
} __attribute__ ((__packed__));
struct fw_mgmt_ioc_get_backend_version {
__u8 firmware_tag[GB_FIRMWARE_U_TAG_MAX_LEN];
__u16 major;
__u16 minor;
__u8 status;
} __attribute__ ((__packed__));
struct fw_mgmt_ioc_intf_load_and_validate {
__u8 firmware_tag[GB_FIRMWARE_TAG_MAX_LEN];
@ -114,8 +130,8 @@ struct fw_mgmt_ioc_backend_fw_update {
} __packed;
#define FW_MGMT_IOCTL_BASE 'S'
#define FW_MGMT_IOC_GET_INTF_FW _IOR(FW_MGMT_IOCTL_BASE, 0, struct fw_mgmt_ioc_get_fw)
#define FW_MGMT_IOC_GET_BACKEND_FW _IOWR(FW_MGMT_IOCTL_BASE, 1, struct fw_mgmt_ioc_get_fw)
#define FW_MGMT_IOC_GET_INTF_FW _IOR(FW_MGMT_IOCTL_BASE, 0, struct fw_mgmt_ioc_get_intf_version)
#define FW_MGMT_IOC_GET_BACKEND_FW _IOWR(FW_MGMT_IOCTL_BASE, 1, struct fw_mgmt_ioc_get_backend_version)
#define FW_MGMT_IOC_INTF_LOAD_AND_VALIDATE _IOWR(FW_MGMT_IOCTL_BASE, 2, struct fw_mgmt_ioc_intf_load_and_validate)
#define FW_MGMT_IOC_INTF_BACKEND_FW_UPDATE _IOWR(FW_MGMT_IOCTL_BASE, 3, struct fw_mgmt_ioc_backend_fw_update)
#define FW_MGMT_IOC_SET_TIMEOUT_MS _IOW(FW_MGMT_IOCTL_BASE, 4, unsigned int)

View File

@ -71,7 +71,8 @@ static const char *fwdev = FW_DEV_DEFAULT;
static int fw_update_type = FW_UPDATE_TYPE_DEFAULT;
static int fw_timeout = FW_TIMEOUT_DEFAULT;
static struct fw_mgmt_ioc_get_fw fw_info;
static struct fw_mgmt_ioc_get_intf_version intf_fw_info;
static struct fw_mgmt_ioc_get_backend_version backend_fw_info;
static struct fw_mgmt_ioc_intf_load_and_validate intf_load;
static struct fw_mgmt_ioc_backend_fw_update backend_update;
@ -87,7 +88,7 @@ static int update_intf_firmware(int fd)
/* Get Interface Firmware Version */
printf("Get Interface Firmware Version\n");
ret = ioctl(fd, FW_MGMT_IOC_GET_INTF_FW, &fw_info);
ret = ioctl(fd, FW_MGMT_IOC_GET_INTF_FW, &intf_fw_info);
if (ret < 0) {
printf("Failed to get interface firmware version: %s (%d)\n",
fwdev, ret);
@ -95,7 +96,8 @@ static int update_intf_firmware(int fd)
}
printf("Interface Firmware tag (%s), major (%d), minor (%d)\n",
fw_info.firmware_tag, fw_info.major, fw_info.minor);
intf_fw_info.firmware_tag, intf_fw_info.major,
intf_fw_info.minor);
/* Try Interface Firmware load over Unipro */
printf("Loading Interface Firmware\n");
@ -143,34 +145,51 @@ static int update_backend_firmware(int fd)
/* Get Backend Firmware Version */
printf("Getting Backend Firmware Version\n");
fw_info.major = 0;
fw_info.minor = 0;
strncpy((char *)&fw_info.firmware_tag, firmware_tag,
strncpy((char *)&backend_fw_info.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_LEN);
ret = ioctl(fd, FW_MGMT_IOC_GET_BACKEND_FW, &fw_info);
retry_fw_version:
ret = ioctl(fd, FW_MGMT_IOC_GET_BACKEND_FW, &backend_fw_info);
if (ret < 0) {
printf("Failed to get backend firmware version: %s (%d)\n",
fwdev, ret);
return -1;
}
printf("Backend Firmware tag (%s), major (%d), minor (%d)\n",
fw_info.firmware_tag, fw_info.major, fw_info.minor);
printf("Backend Firmware tag (%s), major (%d), minor (%d), status (%d)\n",
backend_fw_info.firmware_tag, backend_fw_info.major,
backend_fw_info.minor, backend_fw_info.status);
if (backend_fw_info.status == GB_FW_U_BACKEND_VERSION_STATUS_RETRY)
goto retry_fw_version;
if ((backend_fw_info.status != GB_FW_U_BACKEND_VERSION_STATUS_SUCCESS)
&& (backend_fw_info.status != GB_FW_U_BACKEND_VERSION_STATUS_NOT_AVAILABLE)) {
printf("Failed to get backend firmware version: %s (%d)\n",
fwdev, backend_fw_info.status);
return -1;
}
/* Try Backend Firmware Update over Unipro */
printf("Updating Backend Firmware\n");
backend_update.status = 0;
strncpy((char *)&backend_update.firmware_tag, firmware_tag,
GB_FIRMWARE_U_TAG_MAX_LEN);
retry_fw_update:
backend_update.status = 0;
ret = ioctl(fd, FW_MGMT_IOC_INTF_BACKEND_FW_UPDATE, &backend_update);
if (ret < 0) {
printf("Failed to load backend firmware: %s (%d)\n", fwdev, ret);
return -1;
}
if (backend_update.status == GB_FW_U_BACKEND_FW_STATUS_RETRY) {
printf("Retrying firmware update: %d\n", backend_update.status);
goto retry_fw_update;
}
if (backend_update.status != GB_FW_U_BACKEND_FW_STATUS_SUCCESS) {
printf("Load status says loading failed: %d\n",
backend_update.status);