• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Broadcom USB remote download definitions
3  *
4  * Copyright (C) 1999-2016, Broadcom Corporation
5  *
6  *      Unless you and Broadcom execute a separate written software license
7  * agreement governing use of this software, this software is licensed to you
8  * under the terms of the GNU General Public License version 2 (the "GPL"),
9  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10  * following added to such license:
11  *
12  *      As a special exception, the copyright holders of this software give you
13  * permission to link this software with independent modules, and to copy and
14  * distribute the resulting executable under terms of your choice, provided that
15  * you also meet, for each linked independent module, the terms and conditions
16  * of the license of that module.  An independent module is a module which is
17  * not derived from this software.  The special exception does not apply to any
18  * modifications of the software.
19  *
20  *      Notwithstanding the above, under no circumstances may you combine this
21  * software in any way with any other Broadcom software provided under a license
22  * other than the GPL, without Broadcom's express prior written consent.
23  *
24  *
25  * <<Broadcom-WL-IPTag/Open:>>
26  *
27  * $Id: usbrdl.h 597933 2015-11-06 18:52:06Z $
28  */
29 
30 #ifndef _USB_RDL_H
31 #define _USB_RDL_H
32 
33 /* Control messages: bRequest values */
34 #define DL_GETSTATE 0  /* returns the rdl_state_t struct */
35 #define DL_CHECK_CRC 1 /* currently unused */
36 #define DL_GO 2        /* execute downloaded image */
37 #define DL_START 3     /* initialize dl state */
38 #define DL_REBOOT 4    /* reboot the device in 2 seconds */
39 #define DL_GETVER 5    /* returns the bootrom_id_t struct */
40 #define DL_GO_PROTECTED                                                        \
41     6             /* execute the downloaded code and set reset event           \
42                    * to occur in 2 seconds.  It is the responsibility          \
43                    * of the downloaded code to clear this event                \
44                    */
45 #define DL_EXEC 7 /* jump to a supplied address */
46 #define DL_RESETCFG                                                            \
47     8 /* To support single enum on dongle                                      \
48        * - Not used by bootloader                                              \
49        */
50 #define DL_DEFER_RESP_OK                                                       \
51     9 /* Potentially defer the response to setup                               \
52        * if resp unavailable                                                   \
53        */
54 #define DL_CHGSPD 0x0A
55 
56 #define DL_HWCMD_MASK 0xfc /* Mask for hardware read commands: */
57 #define DL_RDHW 0x10       /* Read a hardware address (Ctl-in) */
58 #define DL_RDHW32 0x10     /* Read a 32 bit word */
59 #define DL_RDHW16 0x11     /* Read 16 bits */
60 #define DL_RDHW8 0x12      /* Read an 8 bit byte */
61 #define DL_WRHW 0x14       /* Write a hardware address (Ctl-out) */
62 #define DL_WRHW_BLK 0x13   /* Block write to hardware access */
63 
64 #define DL_CMD_WRHW 2
65 
66 /* states */
67 #define DL_WAITING 0 /* waiting to rx first pkt that includes the hdr info */
68 #define DL_READY 1   /* hdr was good, waiting for more of the compressed image \
69                       */
70 #define DL_BAD_HDR 2 /* hdr was corrupted */
71 #define DL_BAD_CRC 3 /* compressed image was corrupted */
72 #define DL_RUNNABLE 4     /* download was successful, waiting for go cmd */
73 #define DL_START_FAIL 5   /* failed to initialize correctly */
74 #define DL_NVRAM_TOOBIG 6 /* host specified nvram data exceeds DL_NVRAM value  \
75                            */
76 #define DL_IMAGE_TOOBIG                                                        \
77     7 /* download image too big (exceeds DATA_START for rdl) */
78 
79 #define TIMEOUT 5000 /* Timeout for usb commands */
80 
81 struct bcm_device_id {
82     char *name;
83     uint32 vend;
84     uint32 prod;
85 };
86 
87 typedef struct {
88     uint32 state;
89     uint32 bytes;
90 } rdl_state_t;
91 
92 typedef struct {
93     uint32 chip;      /* Chip id */
94     uint32 chiprev;   /* Chip rev */
95     uint32 ramsize;   /* Size of RAM */
96     uint32 remapbase; /* Current remap base address */
97     uint32 boardtype; /* Type of board */
98     uint32 boardrev;  /* Board revision */
99 } bootrom_id_t;
100 
101 /* struct for backplane & jtag accesses */
102 typedef struct {
103     uint32 cmd;  /* tag to identify the cmd */
104     uint32 addr; /* backplane address for write */
105     uint32 len;  /* length of data: 1, 2, 4 bytes */
106     uint32 data; /* data to write */
107 } hwacc_t;
108 
109 /* struct for querying nvram params from bootloader */
110 #define QUERY_STRING_MAX 32
111 typedef struct {
112     uint32 cmd;                 /* tag to identify the cmd */
113     char var[QUERY_STRING_MAX]; /* param name */
114 } nvparam_t;
115 
116 typedef void (*exec_fn_t)(void *sih);
117 
118 #define USB_CTRL_IN (USB_TYPE_VENDOR | 0x80 | USB_RECIP_INTERFACE)
119 #define USB_CTRL_OUT (USB_TYPE_VENDOR | 0 | USB_RECIP_INTERFACE)
120 
121 #define USB_CTRL_EP_TIMEOUT                                                    \
122     500 /* Timeout used in USB control_msg transactions. */
123 #define USB_BULK_EP_TIMEOUT 500 /* Timeout used in USB bulk transactions. */
124 
125 #define RDL_CHUNK_MAX (64 * 1024) /* max size of each dl transfer */
126 #define RDL_CHUNK 1500            /* size of each dl transfer */
127 
128 /* bootloader makes special use of trx header "offsets" array */
129 #define TRX_OFFSETS_DLFWLEN_IDX                                                \
130     0                            /* Size of the fw; used in uncompressed case */
131 #define TRX_OFFSETS_JUMPTO_IDX 1 /* RAM address for jumpto after download */
132 #define TRX_OFFSETS_NVM_LEN_IDX 2 /* Length of appended NVRAM data */
133 #ifdef BCMTRXV2
134 #define TRX_OFFSETS_DSG_LEN_IDX                                                \
135     3 /* Length of digital signature for the first image */
136 #define TRX_OFFSETS_CFG_LEN_IDX                                                \
137     4  /* Length of config region, which is not digitally signed */
138 #endif /* BCMTRXV2 */
139 
140 #define TRX_OFFSETS_DLBASE_IDX 0 /* RAM start address for download */
141 
142 #endif /* _USB_RDL_H */
143