]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - drivers/usb/gadget/f_dfu.h
socfpga: Move board/socfpga_cyclone5 to board/socfpga
[karo-tx-uboot.git] / drivers / usb / gadget / f_dfu.h
1 /*
2  * f_dfu.h -- Device Firmware Update gadget
3  *
4  * Copyright (C) 2011-2012 Samsung Electronics
5  * author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #ifndef __F_DFU_H_
23 #define __F_DFU_H_
24
25 #include <linux/compiler.h>
26 #include <linux/usb/composite.h>
27
28 #define DFU_CONFIG_VAL                  1
29 #define DFU_DT_FUNC                     0x21
30
31 #define DFU_BIT_WILL_DETACH             (0x1 << 3)
32 #define DFU_BIT_MANIFESTATION_TOLERANT  (0x1 << 2)
33 #define DFU_BIT_CAN_UPLOAD              (0x1 << 1)
34 #define DFU_BIT_CAN_DNLOAD              0x1
35
36 /* big enough to hold our biggest descriptor */
37 #define DFU_USB_BUFSIZ                  4096
38
39 #define USB_REQ_DFU_DETACH              0x00
40 #define USB_REQ_DFU_DNLOAD              0x01
41 #define USB_REQ_DFU_UPLOAD              0x02
42 #define USB_REQ_DFU_GETSTATUS           0x03
43 #define USB_REQ_DFU_CLRSTATUS           0x04
44 #define USB_REQ_DFU_GETSTATE            0x05
45 #define USB_REQ_DFU_ABORT               0x06
46
47 #define DFU_STATUS_OK                   0x00
48 #define DFU_STATUS_errTARGET            0x01
49 #define DFU_STATUS_errFILE              0x02
50 #define DFU_STATUS_errWRITE             0x03
51 #define DFU_STATUS_errERASE             0x04
52 #define DFU_STATUS_errCHECK_ERASED      0x05
53 #define DFU_STATUS_errPROG              0x06
54 #define DFU_STATUS_errVERIFY            0x07
55 #define DFU_STATUS_errADDRESS           0x08
56 #define DFU_STATUS_errNOTDONE           0x09
57 #define DFU_STATUS_errFIRMWARE          0x0a
58 #define DFU_STATUS_errVENDOR            0x0b
59 #define DFU_STATUS_errUSBR              0x0c
60 #define DFU_STATUS_errPOR               0x0d
61 #define DFU_STATUS_errUNKNOWN           0x0e
62 #define DFU_STATUS_errSTALLEDPKT        0x0f
63
64 #define RET_STALL                       -1
65 #define RET_ZLP                         0
66 #define RET_STAT_LEN                    6
67
68 enum dfu_state {
69         DFU_STATE_appIDLE               = 0,
70         DFU_STATE_appDETACH             = 1,
71         DFU_STATE_dfuIDLE               = 2,
72         DFU_STATE_dfuDNLOAD_SYNC        = 3,
73         DFU_STATE_dfuDNBUSY             = 4,
74         DFU_STATE_dfuDNLOAD_IDLE        = 5,
75         DFU_STATE_dfuMANIFEST_SYNC      = 6,
76         DFU_STATE_dfuMANIFEST           = 7,
77         DFU_STATE_dfuMANIFEST_WAIT_RST  = 8,
78         DFU_STATE_dfuUPLOAD_IDLE        = 9,
79         DFU_STATE_dfuERROR              = 10,
80 };
81
82 struct dfu_status {
83         __u8                            bStatus;
84         __u8                            bwPollTimeout[3];
85         __u8                            bState;
86         __u8                            iString;
87 } __packed;
88
89 struct dfu_function_descriptor {
90         __u8                            bLength;
91         __u8                            bDescriptorType;
92         __u8                            bmAttributes;
93         __le16                          wDetachTimeOut;
94         __le16                          wTransferSize;
95         __le16                          bcdDFUVersion;
96 } __packed;
97
98 /* configuration-specific linkup */
99 int dfu_add(struct usb_configuration *c);
100 #endif /* __F_DFU_H_ */