Fixed tools/env utilities
[u-boot-openmoko/mini2440.git] / include / usb_dfu_descriptors.h
blobd4d6a4d3206d9091b2a0956f9fa0199cd7aa96ad
1 #ifndef _USB_DFU_H
2 #define _USB_DFU_H
3 /* USB Device Firmware Update Implementation for OpenPCD
4 * (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
6 * Protocol definitions for USB DFU
8 * This ought to be compliant to the USB DFU Spec 1.0 as available from
9 * http://www.usb.org/developers/devclass_docs/usbdfu10.pdf
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/types.h>
28 #define USB_DT_DFU 0x21
30 struct usb_dfu_func_descriptor {
31 u_int8_t bLength;
32 u_int8_t bDescriptorType;
33 u_int8_t bmAttributes;
34 #define USB_DFU_CAN_DOWNLOAD (1 << 0)
35 #define USB_DFU_CAN_UPLOAD (1 << 1)
36 #define USB_DFU_MANIFEST_TOL (1 << 2)
37 #define USB_DFU_WILL_DETACH (1 << 3)
38 u_int16_t wDetachTimeOut;
39 u_int16_t wTransferSize;
40 u_int16_t bcdDFUVersion;
41 } __attribute__ ((packed));
43 #define USB_DT_DFU_SIZE 9
45 #define USB_TYPE_DFU (USB_TYPE_CLASS|USB_RECIP_INTERFACE)
47 /* DFU class-specific requests (Section 3, DFU Rev 1.1) */
48 #define USB_REQ_DFU_DETACH 0x00
49 #define USB_REQ_DFU_DNLOAD 0x01
50 #define USB_REQ_DFU_UPLOAD 0x02
51 #define USB_REQ_DFU_GETSTATUS 0x03
52 #define USB_REQ_DFU_CLRSTATUS 0x04
53 #define USB_REQ_DFU_GETSTATE 0x05
54 #define USB_REQ_DFU_ABORT 0x06
56 struct dfu_status {
57 u_int8_t bStatus;
58 u_int8_t bwPollTimeout[3];
59 u_int8_t bState;
60 u_int8_t iString;
61 } __attribute__((packed));
63 #define DFU_STATUS_OK 0x00
64 #define DFU_STATUS_errTARGET 0x01
65 #define DFU_STATUS_errFILE 0x02
66 #define DFU_STATUS_errWRITE 0x03
67 #define DFU_STATUS_errERASE 0x04
68 #define DFU_STATUS_errCHECK_ERASED 0x05
69 #define DFU_STATUS_errPROG 0x06
70 #define DFU_STATUS_errVERIFY 0x07
71 #define DFU_STATUS_errADDRESS 0x08
72 #define DFU_STATUS_errNOTDONE 0x09
73 #define DFU_STATUS_errFIRMWARE 0x0a
74 #define DFU_STATUS_errVENDOR 0x0b
75 #define DFU_STATUS_errUSBR 0x0c
76 #define DFU_STATUS_errPOR 0x0d
77 #define DFU_STATUS_errUNKNOWN 0x0e
78 #define DFU_STATUS_errSTALLEDPKT 0x0f
80 enum dfu_state {
81 DFU_STATE_appIDLE = 0,
82 DFU_STATE_appDETACH = 1,
83 DFU_STATE_dfuIDLE = 2,
84 DFU_STATE_dfuDNLOAD_SYNC = 3,
85 DFU_STATE_dfuDNBUSY = 4,
86 DFU_STATE_dfuDNLOAD_IDLE = 5,
87 DFU_STATE_dfuMANIFEST_SYNC = 6,
88 DFU_STATE_dfuMANIFEST = 7,
89 DFU_STATE_dfuMANIFEST_WAIT_RST = 8,
90 DFU_STATE_dfuUPLOAD_IDLE = 9,
91 DFU_STATE_dfuERROR = 10,
94 #endif /* _USB_DFU_H */