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