add SDHC support in mmc driver
[u-boot-openmoko/mini2440.git] / include / usb_dfu.h
blobc63d2060d082af3000d08c2285eb0bacd2d3c78f
1 #ifndef _DFU_H
2 #define _DFU_H
4 /* USB Device Firmware Update Implementation for u-boot
5 * (C) 2007 by OpenMoko, Inc.
6 * Author: Harald Welte <laforge@openmoko.org>
8 * based on: USB Device Firmware Update Implementation for OpenPCD
9 * (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
11 * This ought to be compliant to the USB DFU Spec 1.0 as available from
12 * http://www.usb.org/developers/devclass_docs/usbdfu10.pdf
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <asm/types.h>
30 #include <usbdescriptors.h>
31 #include <usb_dfu_descriptors.h>
32 #include <config.h>
34 /* USB DFU functional descriptor */
35 #define DFU_FUNC_DESC { \
36 .bLength = USB_DT_DFU_SIZE, \
37 .bDescriptorType = USB_DT_DFU, \
38 .bmAttributes = USB_DFU_CAN_UPLOAD | USB_DFU_CAN_DOWNLOAD | USB_DFU_MANIFEST_TOL, \
39 .wDetachTimeOut = 0xff00, \
40 .wTransferSize = CONFIG_USBD_DFU_XFER_SIZE, \
41 .bcdDFUVersion = 0x0100, \
44 /* USB Interface descriptor in Runtime mode */
45 #define DFU_RT_IF_DESC { \
46 .bLength = USB_DT_INTERFACE_SIZE, \
47 .bDescriptorType = USB_DT_INTERFACE, \
48 .bInterfaceNumber = CONFIG_USBD_DFU_INTERFACE, \
49 .bAlternateSetting = 0x00, \
50 .bNumEndpoints = 0x00, \
51 .bInterfaceClass = 0xfe, \
52 .bInterfaceSubClass = 0x01, \
53 .bInterfaceProtocol = 0x01, \
54 .iInterface = DFU_STR_CONFIG, \
57 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
59 #ifndef DFU_NUM_ALTERNATES
60 #define DFU_NUM_ALTERNATES 6
61 #endif
63 #define DFU_STR_MANUFACTURER STR_MANUFACTURER
64 #define DFU_STR_PRODUCT STR_PRODUCT
65 #define DFU_STR_SERIAL STR_SERIAL
66 #define DFU_STR_CONFIG (STR_COUNT)
67 #define DFU_STR_ALT(n) (STR_COUNT+(n)+1)
68 #define DFU_STR_COUNT DFU_STR_ALT(DFU_NUM_ALTERNATES)
70 #define CONFIG_DFU_CFG_STR "USB Device Firmware Upgrade"
71 #define CONFIG_DFU_ALT0_STR "RAM 0x32000000"
73 struct _dfu_desc {
74 struct usb_configuration_descriptor ucfg;
75 struct usb_interface_descriptor uif[DFU_NUM_ALTERNATES];
76 struct usb_dfu_func_descriptor func_dfu;
79 int dfu_init_instance(struct usb_device_instance *dev);
81 #define DFU_EP0_NONE 0
82 #define DFU_EP0_UNHANDLED 1
83 #define DFU_EP0_STALL 2
84 #define DFU_EP0_ZLP 3
85 #define DFU_EP0_DATA 4
87 extern volatile enum dfu_state *system_dfu_state; /* for 3rd parties */
89 int dfu_ep0_handler(struct urb *urb);
91 void dfu_event(struct usb_device_instance *device,
92 usb_device_event_t event, int data);
94 #endif /* _DFU_H */