1/*
2 * Copyright (c) 2011 Broadcom Corporation
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef _USB_RDL_H
18#define _USB_RDL_H
19
20/* Control messages: bRequest values */
21#define DL_GETSTATE	0	/* returns the rdl_state_t struct */
22#define DL_CHECK_CRC	1	/* currently unused */
23#define DL_GO		2	/* execute downloaded image */
24#define DL_START	3	/* initialize dl state */
25#define DL_REBOOT	4	/* reboot the device in 2 seconds */
26#define DL_GETVER	5	/* returns the bootrom_id_t struct */
27#define DL_GO_PROTECTED	6	/* execute the downloaded code and set reset
28				 * event to occur in 2 seconds.  It is the
29				 * responsibility of the downloaded code to
30				 * clear this event
31				 */
32#define DL_EXEC		7	/* jump to a supplied address */
33#define DL_RESETCFG	8	/* To support single enum on dongle
34				 * - Not used by bootloader
35				 */
36#define DL_DEFER_RESP_OK 9	/* Potentially defer the response to setup
37				 * if resp unavailable
38				 */
39
40/* states */
41#define DL_WAITING	0	/* waiting to rx first pkt */
42#define DL_READY	1	/* hdr was good, waiting for more of the
43				 * compressed image */
44#define DL_BAD_HDR	2	/* hdr was corrupted */
45#define DL_BAD_CRC	3	/* compressed image was corrupted */
46#define DL_RUNNABLE	4	/* download was successful,waiting for go cmd */
47#define DL_START_FAIL	5	/* failed to initialize correctly */
48#define DL_NVRAM_TOOBIG	6	/* host specified nvram data exceeds DL_NVRAM
49				 * value */
50#define DL_IMAGE_TOOBIG	7	/* download image too big (exceeds DATA_START
51				 *  for rdl) */
52
53struct rdl_state_le {
54	__le32 state;
55	__le32 bytes;
56};
57
58struct bootrom_id_le {
59	__le32 chip;	/* Chip id */
60	__le32 chiprev;	/* Chip rev */
61	__le32 ramsize;	/* Size of  RAM */
62	__le32 remapbase;	/* Current remap base address */
63	__le32 boardtype;	/* Type of board */
64	__le32 boardrev;	/* Board revision */
65};
66
67#define RDL_CHUNK	1500  /* size of each dl transfer */
68
69#define TRX_OFFSETS_DLFWLEN_IDX	0
70#define TRX_OFFSETS_JUMPTO_IDX	1
71#define TRX_OFFSETS_NVM_LEN_IDX	2
72
73#define TRX_OFFSETS_DLBASE_IDX  0
74
75#endif  /* _USB_RDL_H */
76