CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/cache/sources/wl/include/bcmsdpcm.h
Views: 3959
1
/*
2
* Broadcom SDIO/PCMCIA
3
* Software-specific definitions shared between device and host side
4
*
5
* $Copyright Open 2005 Broadcom Corporation$
6
*
7
* $Id: bcmsdpcm.h 314495 2012-02-12 07:56:39Z $
8
*/
9
10
#ifndef _bcmsdpcm_h_
11
#define _bcmsdpcm_h_
12
13
/*
14
* Software allocation of To SB Mailbox resources
15
*/
16
17
/* intstatus bits */
18
#define I_SMB_NAK I_SMB_SW0 /* To SB Mailbox Frame NAK */
19
#define I_SMB_INT_ACK I_SMB_SW1 /* To SB Mailbox Host Interrupt ACK */
20
#define I_SMB_USE_OOB I_SMB_SW2 /* To SB Mailbox Use OOB Wakeup */
21
#define I_SMB_DEV_INT I_SMB_SW3 /* To SB Mailbox Miscellaneous Interrupt */
22
23
#define I_TOSBMAIL (I_SMB_NAK | I_SMB_INT_ACK | I_SMB_USE_OOB | I_SMB_DEV_INT)
24
25
/* tosbmailbox bits corresponding to intstatus bits */
26
#define SMB_NAK (1 << 0) /* To SB Mailbox Frame NAK */
27
#define SMB_INT_ACK (1 << 1) /* To SB Mailbox Host Interrupt ACK */
28
#define SMB_USE_OOB (1 << 2) /* To SB Mailbox Use OOB Wakeup */
29
#define SMB_DEV_INT (1 << 3) /* To SB Mailbox Miscellaneous Interrupt */
30
#define SMB_MASK 0x0000000f /* To SB Mailbox Mask */
31
32
/* tosbmailboxdata */
33
#define SMB_DATA_VERSION_MASK 0x00ff0000 /* host protocol version (sent with F2 enable) */
34
#define SMB_DATA_VERSION_SHIFT 16 /* host protocol version (sent with F2 enable) */
35
36
/*
37
* Software allocation of To Host Mailbox resources
38
*/
39
40
/* intstatus bits */
41
#define I_HMB_FC_STATE I_HMB_SW0 /* To Host Mailbox Flow Control State */
42
#define I_HMB_FC_CHANGE I_HMB_SW1 /* To Host Mailbox Flow Control State Changed */
43
#define I_HMB_FRAME_IND I_HMB_SW2 /* To Host Mailbox Frame Indication */
44
#define I_HMB_HOST_INT I_HMB_SW3 /* To Host Mailbox Miscellaneous Interrupt */
45
46
#define I_TOHOSTMAIL (I_HMB_FC_CHANGE | I_HMB_FRAME_IND | I_HMB_HOST_INT)
47
48
/* tohostmailbox bits corresponding to intstatus bits */
49
#define HMB_FC_ON (1 << 0) /* To Host Mailbox Flow Control State */
50
#define HMB_FC_CHANGE (1 << 1) /* To Host Mailbox Flow Control State Changed */
51
#define HMB_FRAME_IND (1 << 2) /* To Host Mailbox Frame Indication */
52
#define HMB_HOST_INT (1 << 3) /* To Host Mailbox Miscellaneous Interrupt */
53
#define HMB_MASK 0x0000000f /* To Host Mailbox Mask */
54
55
/* tohostmailboxdata */
56
#define HMB_DATA_NAKHANDLED 0x01 /* we're ready to retransmit NAK'd frame to host */
57
#define HMB_DATA_DEVREADY 0x02 /* we're ready to to talk to host after enable */
58
#define HMB_DATA_FC 0x04 /* per prio flowcontrol update flag to host */
59
#define HMB_DATA_FWREADY 0x08 /* firmware is ready for protocol activity */
60
#define HMB_DATA_FWHALT 0x10 /* firmware has halted operation */
61
62
#define HMB_DATA_FCDATA_MASK 0xff000000 /* per prio flowcontrol data */
63
#define HMB_DATA_FCDATA_SHIFT 24 /* per prio flowcontrol data */
64
65
#define HMB_DATA_VERSION_MASK 0x00ff0000 /* device protocol version (with devready) */
66
#define HMB_DATA_VERSION_SHIFT 16 /* device protocol version (with devready) */
67
68
/*
69
* Software-defined protocol header
70
*/
71
72
/* Current protocol version */
73
#define SDPCM_PROT_VERSION 4
74
75
/* SW frame header */
76
#define SDPCM_SEQUENCE_MASK 0x000000ff /* Sequence Number Mask */
77
#define SDPCM_PACKET_SEQUENCE(p) (((uint8 *)p)[0] & 0xff) /* p starts w/SW Header */
78
79
#define SDPCM_CHANNEL_MASK 0x00000f00 /* Channel Number Mask */
80
#define SDPCM_CHANNEL_SHIFT 8 /* Channel Number Shift */
81
#define SDPCM_PACKET_CHANNEL(p) (((uint8 *)p)[1] & 0x0f) /* p starts w/SW Header */
82
83
#define SDPCM_FLAGS_MASK 0x0000f000 /* Mask of flag bits */
84
#define SDPCM_FLAGS_SHIFT 12 /* Flag bits shift */
85
#define SDPCM_PACKET_FLAGS(p) ((((uint8 *)p)[1] & 0xf0) >> 4) /* p starts w/SW Header */
86
87
/* Next Read Len: lookahead length of next frame, in 16-byte units (rounded up) */
88
#define SDPCM_NEXTLEN_MASK 0x00ff0000 /* Next Read Len Mask */
89
#define SDPCM_NEXTLEN_SHIFT 16 /* Next Read Len Shift */
90
#define SDPCM_NEXTLEN_VALUE(p) ((((uint8 *)p)[2] & 0xff) << 4) /* p starts w/SW Header */
91
#define SDPCM_NEXTLEN_OFFSET 2
92
93
/* Data Offset from SOF (HW Tag, SW Tag, Pad) */
94
#define SDPCM_DOFFSET_OFFSET 3 /* Data Offset */
95
#define SDPCM_DOFFSET_VALUE(p) (((uint8 *)p)[SDPCM_DOFFSET_OFFSET] & 0xff)
96
#define SDPCM_DOFFSET_MASK 0xff000000
97
#define SDPCM_DOFFSET_SHIFT 24
98
99
#define SDPCM_FCMASK_OFFSET 4 /* Flow control */
100
#define SDPCM_FCMASK_VALUE(p) (((uint8 *)p)[SDPCM_FCMASK_OFFSET ] & 0xff)
101
#define SDPCM_WINDOW_OFFSET 5 /* Credit based fc */
102
#define SDPCM_WINDOW_VALUE(p) (((uint8 *)p)[SDPCM_WINDOW_OFFSET] & 0xff)
103
#define SDPCM_VERSION_OFFSET 6 /* Version # */
104
#define SDPCM_VERSION_VALUE(p) (((uint8 *)p)[SDPCM_VERSION_OFFSET] & 0xff)
105
#define SDPCM_UNUSED_OFFSET 7 /* Spare */
106
#define SDPCM_UNUSED_VALUE(p) (((uint8 *)p)[SDPCM_UNUSED_OFFSET] & 0xff)
107
108
#define SDPCM_SWHEADER_LEN 8 /* SW header is 64 bits */
109
110
/* logical channel numbers */
111
#define SDPCM_CONTROL_CHANNEL 0 /* Control Request/Response Channel Id */
112
#define SDPCM_EVENT_CHANNEL 1 /* Asyc Event Indication Channel Id */
113
#define SDPCM_DATA_CHANNEL 2 /* Data Xmit/Recv Channel Id */
114
#define SDPCM_GLOM_CHANNEL 3 /* For coalesced packets (superframes) */
115
#define SDPCM_TEST_CHANNEL 15 /* Reserved for test/debug packets */
116
#define SDPCM_MAX_CHANNEL 15
117
118
#define SDPCM_SEQUENCE_WRAP 256 /* wrap-around val for eight-bit frame seq number */
119
120
#define SDPCM_FLAG_RESVD0 0x01
121
#define SDPCM_FLAG_RESVD1 0x02
122
#define SDPCM_FLAG_GSPI_TXENAB 0x04
123
#define SDPCM_FLAG_GLOMDESC 0x08 /* Superframe descriptor mask */
124
125
/* For GLOM_CHANNEL frames, use a flag to indicate descriptor frame */
126
#define SDPCM_GLOMDESC_FLAG (SDPCM_FLAG_GLOMDESC << SDPCM_FLAGS_SHIFT)
127
128
#define SDPCM_GLOMDESC(p) (((uint8 *)p)[1] & 0x80)
129
130
/* For TEST_CHANNEL packets, define another 4-byte header */
131
#define SDPCM_TEST_HDRLEN 4 /* Generally: Cmd(1), Ext(1), Len(2);
132
* Semantics of Ext byte depend on command.
133
* Len is current or requested frame length, not
134
* including test header; sent little-endian.
135
*/
136
#define SDPCM_TEST_DISCARD 0x01 /* Receiver discards. Ext is a pattern id. */
137
#define SDPCM_TEST_ECHOREQ 0x02 /* Echo request. Ext is a pattern id. */
138
#define SDPCM_TEST_ECHORSP 0x03 /* Echo response. Ext is a pattern id. */
139
#define SDPCM_TEST_BURST 0x04 /* Receiver to send a burst. Ext is a frame count */
140
#define SDPCM_TEST_SEND 0x05 /* Receiver sets send mode. Ext is boolean on/off */
141
142
/* Handy macro for filling in datagen packets with a pattern */
143
#define SDPCM_TEST_FILL(byteno, id) ((uint8)(id + byteno))
144
145
/*
146
* Software counters (first part matches hardware counters)
147
*/
148
149
typedef volatile struct {
150
uint32 cmd52rd; /* Cmd52RdCount, SDIO: cmd52 reads */
151
uint32 cmd52wr; /* Cmd52WrCount, SDIO: cmd52 writes */
152
uint32 cmd53rd; /* Cmd53RdCount, SDIO: cmd53 reads */
153
uint32 cmd53wr; /* Cmd53WrCount, SDIO: cmd53 writes */
154
uint32 abort; /* AbortCount, SDIO: aborts */
155
uint32 datacrcerror; /* DataCrcErrorCount, SDIO: frames w/CRC error */
156
uint32 rdoutofsync; /* RdOutOfSyncCount, SDIO/PCMCIA: Rd Frm out of sync */
157
uint32 wroutofsync; /* RdOutOfSyncCount, SDIO/PCMCIA: Wr Frm out of sync */
158
uint32 writebusy; /* WriteBusyCount, SDIO: device asserted "busy" */
159
uint32 readwait; /* ReadWaitCount, SDIO: no data ready for a read cmd */
160
uint32 readterm; /* ReadTermCount, SDIO: read frame termination cmds */
161
uint32 writeterm; /* WriteTermCount, SDIO: write frames termination cmds */
162
uint32 rxdescuflo; /* receive descriptor underflows */
163
uint32 rxfifooflo; /* receive fifo overflows */
164
uint32 txfifouflo; /* transmit fifo underflows */
165
uint32 runt; /* runt (too short) frames recv'd from bus */
166
uint32 badlen; /* frame's rxh len does not match its hw tag len */
167
uint32 badcksum; /* frame's hw tag chksum doesn't agree with len value */
168
uint32 seqbreak; /* break in sequence # space from one rx frame to the next */
169
uint32 rxfcrc; /* frame rx header indicates crc error */
170
uint32 rxfwoos; /* frame rx header indicates write out of sync */
171
uint32 rxfwft; /* frame rx header indicates write frame termination */
172
uint32 rxfabort; /* frame rx header indicates frame aborted */
173
uint32 woosint; /* write out of sync interrupt */
174
uint32 roosint; /* read out of sync interrupt */
175
uint32 rftermint; /* read frame terminate interrupt */
176
uint32 wftermint; /* write frame terminate interrupt */
177
} sdpcmd_cnt_t;
178
179
/*
180
* Register Access Macros
181
*/
182
183
#define SDIODREV_IS(var, val) ((var) == (val))
184
#define SDIODREV_GE(var, val) ((var) >= (val))
185
#define SDIODREV_GT(var, val) ((var) > (val))
186
#define SDIODREV_LT(var, val) ((var) < (val))
187
#define SDIODREV_LE(var, val) ((var) <= (val))
188
189
#define SDIODDMAREG32(h, dir, chnl) \
190
((dir) == DMA_TX ? \
191
(void *)(uintptr)&((h)->regs->dma.sdiod32.dma32regs[chnl].xmt) : \
192
(void *)(uintptr)&((h)->regs->dma.sdiod32.dma32regs[chnl].rcv))
193
194
#define SDIODDMAREG64(h, dir, chnl) \
195
((dir) == DMA_TX ? \
196
(void *)(uintptr)&((h)->regs->dma.sdiod64.dma64regs[chnl].xmt) : \
197
(void *)(uintptr)&((h)->regs->dma.sdiod64.dma64regs[chnl].rcv))
198
199
#define SDIODDMAREG(h, dir, chnl) \
200
(SDIODREV_LT((h)->corerev, 1) ? \
201
SDIODDMAREG32((h), (dir), (chnl)) : \
202
SDIODDMAREG64((h), (dir), (chnl)))
203
204
#define PCMDDMAREG(h, dir, chnl) \
205
((dir) == DMA_TX ? \
206
(void *)(uintptr)&((h)->regs->dma.pcm32.dmaregs.xmt) : \
207
(void *)(uintptr)&((h)->regs->dma.pcm32.dmaregs.rcv))
208
209
#define SDPCMDMAREG(h, dir, chnl, coreid) \
210
((coreid) == SDIOD_CORE_ID ? \
211
SDIODDMAREG(h, dir, chnl) : \
212
PCMDDMAREG(h, dir, chnl))
213
214
#define SDIODFIFOREG(h, corerev) \
215
(SDIODREV_LT((corerev), 1) ? \
216
((dma32diag_t *)(uintptr)&((h)->regs->dma.sdiod32.dmafifo)) : \
217
((dma32diag_t *)(uintptr)&((h)->regs->dma.sdiod64.dmafifo)))
218
219
#define PCMDFIFOREG(h) \
220
((dma32diag_t *)(uintptr)&((h)->regs->dma.pcm32.dmafifo))
221
222
#define SDPCMFIFOREG(h, coreid, corerev) \
223
((coreid) == SDIOD_CORE_ID ? \
224
SDIODFIFOREG(h, corerev) : \
225
PCMDFIFOREG(h))
226
227
/*
228
* Shared structure between dongle and the host.
229
* The structure contains pointers to trap or assert information.
230
*/
231
#define SDPCM_SHARED_VERSION 0x0001
232
#define SDPCM_SHARED_VERSION_MASK 0x00FF
233
#define SDPCM_SHARED_ASSERT_BUILT 0x0100
234
#define SDPCM_SHARED_ASSERT 0x0200
235
#define SDPCM_SHARED_TRAP 0x0400
236
#define SDPCM_SHARED_IN_BRPT 0x0800
237
#define SDPCM_SHARED_SET_BRPT 0x1000
238
#define SDPCM_SHARED_PENDING_BRPT 0x2000
239
240
typedef struct {
241
uint32 flags;
242
uint32 trap_addr;
243
uint32 assert_exp_addr;
244
uint32 assert_file_addr;
245
uint32 assert_line;
246
uint32 console_addr; /* Address of hndrte_cons_t */
247
uint32 msgtrace_addr;
248
uint32 fwid;
249
} sdpcm_shared_t;
250
251
extern sdpcm_shared_t sdpcm_shared;
252
253
/* Function can be used to notify host of FW halt */
254
extern void sdpcmd_fwhalt(void);
255
256
#endif /* _bcmsdpcm_h_ */
257
258