summaryrefslogtreecommitdiff
path: root/openpcd/firmware/src/dfu.h
blob: 437204329736edb095867e096b20850475b45f56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _DFU_H
#define _DFU_H

/* USB Device Firmware Update Implementation for OpenPCD
 * (C) 2006 by Harald Welte <hwelte@hmw-consulting.de>
 *
 * This ought to be compliant to the USB DFU Spec 1.0 as available from
 * http://www.usb.org/developers/devclass_docs/usbdfu10.pdf
 *
 */

#include <sys/types.h>
#include <usb_ch9.h>
#include <usb_dfu.h>

#include "dbgu.h"

/* USB DFU functional descriptor */
#define DFU_FUNC_DESC  {						\
	.bLength		= USB_DT_DFU_SIZE,			\
	.bDescriptorType	= USB_DT_DFU,				\
	.bmAttributes		= USB_DFU_CAN_UPLOAD | USB_DFU_CAN_DOWNLOAD, \
	.wDetachTimeOut		= 0xff00,				\
	.wTransferSize		= AT91C_IFLASH_PAGE_SIZE,		\
	.bcdDFUVersion		= 0x0100,				\
}

/* USB Interface descriptor in Runtime mode */
#define DFU_RT_IF_DESC	{						\
	.bLength		= USB_DT_INTERFACE_SIZE,		\
	.bDescriptorType	= USB_DT_INTERFACE,			\
	.bInterfaceNumber	= 0x01,					\
	.bAlternateSetting	= 0x00,					\
	.bNumEndpoints		= 0x00,					\
	.bInterfaceClass	= 0xfe,					\
	.bInterfaceSubClass	= 0x01,					\
	.bInterfaceProtocol	= 0x01,					\
	.iInterface		= 1,					\
}

struct udp_pcd;

extern struct usb_device_descriptor dfu_dev_descriptor;

struct _dfu_desc {
	struct usb_config_descriptor ucfg;
	struct usb_interface_descriptor uif[2];
	struct usb_dfu_func_descriptor func_dfu;
};

extern struct _dfu_desc dfu_cfg_descriptor;

extern void dfu_switch(void);
extern int __ramfunc dfu_ep0_handler(u_int8_t req_type, u_int8_t req,
				     u_int16_t val, u_int16_t len);

extern enum dfu_state dfu_state;
	
#endif /* _DFU_H */
personal git repositories of Harald Welte. Your mileage may vary