summaryrefslogtreecommitdiff
path: root/sys/src/9/mt7688/io.h
blob: 95725c1efe2eabaf9fe662bb7fc48ce7b6109f23 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
/*
 *  various things to IO with
 */

#define	IO(t,x)		((t*)(KSEG1|((ulong)x)))

/* for mt7688 testing on onion Ω 2 + */
#define	SYSCTLBASE	0x10000000
#define TIMERBASE	0x10000100
#define IRQBASE		0x10000200
#define MEMCBASE	0x10000300
#define RBUSBASE	0x10000400
#define	MCNTBASE	0x10000500
#define GPIOBASE	0x10000600
#define	I2CBASE		0x10000900
#define I2SBASE		0x10000A00
#define SPIBASE		0x10000B00
#define UARTLBASE	0x10000C00
#define UART1BASE	0x10000D00
#define UART2BASE	0x10000E00

#define	DMABASE		0x10002800
#define AESBASE		0x10004000	/* crypto engine */

#define ETHBASE		0x10100000
#define SWCHBASE	0x10110000
#define	PCIBASE		0x10140000
#define PCIWIN		0x10150000
#define	WIFIBASE	0x10300000
#define USBBASE		0x101C0000



/*
 *  duarts, frequency and registers
 */
#define DUARTFREQ	40000000  /* mt7688 has a 40MHz clock */	

#define UART_RBR	0x00
#define UART_THR	0x00
#define	UART_IER	0x04
#define UART_IIR	0x08
#define	UART_FCR	0x08
#define	UART_LCR	0x0C
#define UART_MCR	0x10
#define UART_LSR	0x14
#define	UART_MSR	0x18
#define	UART_SCR	0x1C
#define UART_DLL	0x00
#define UART_DLM	0x04


/*
 *	system control
 */

#define SYSCTL_RST			0x34


/*
 *  interrupt levels
 */

#define IRQshift	8;

/* for cpu */
enum {
	IRQsw1		=	0,	//INTR0
	IRQsw2,
	IRQlow,				//INTR2
	IRQhigh,
	IRQpci,
	IRQethr,
	IRQwifi,
	IRQtimer,			//INTR7
	IRQinc0,				// psuedo numbers for INC
	IRQsys,
	IRQtimer0,
	IRQillacc,
	IRQpcm,
	IRQinc5,
	IRQgpio,
	IRQdma,
	IRQinc8,
	IRQinc9,
	IRQi2s,
	IRQuartf,
	IRQspi,
	IRQcrypto,
	IRQnand,
	IRQperf,
	IRQinc16,
	IRQethsw,
	IRQusbh,
	IRQusbd,
	IRQuartl,
	IRQuart1,
	IRQuart2,
	IRQwdog,
	IRQmax,
};


/*
 * Interrupts on side controller
 */

#define INC_SYSCTL		1
#define INC_TIMER0		2
#define INC_ILLACC		3
#define INC_PCM			4

#define INC_GPIO		6
#define INC_DMA			7
#define INC_I2S			10
#define	INC_UARTF		11
#define INC_SPI			12 //?
#define INC_CRYPTO		13 //?
#define INC_NAND		14
#define INC_PERF		15
#define INC_ETHSW		17
#define	INC_USBH		18
#define	INC_USBD		19
#define	INC_UARTL		20
#define	INC_UART1		21
#define	INC_UART2		22
#define INC_WDOG		24

#define INC_GLOBAL		31



//#define INC_SDHC		14 //?
//#define INC_R2P			15 //?



/*
 * Interrupt Controller Registers
 */

#define IRQ_STAT		0x9C
#define FIQ_STAT		0xA0
#define IRQ_SEL0		0x00	/* set as IRQ */
#define	FIQ_SEL			0x6C	/* set as FIQ */
#define INT_PURE		0xA4	/* raw */
#define	IRQ_MASK		0x70	/* mask */
#define IRQ_MASK_SET	0x80	/* enable */
#define IRQ_MASK_CLR	0x78	/* disable */
#define	IRQ_EOI			0x88	/* call end to irq */


/*
 * timer controls
 */

#define TIME_GLB	0x00

#define CLK0_CTL	0x10
#define CLK0_LOAD	0x14
#define CLK0_TIME	0x18

#define WDOG_CTL	0x20
#define WDOG_LOAD	0x24
#define WDOG_TIME	0x28

#define GLB_T0_IRQ  (1<<0)
#define GLB_WD_IRQ	(1<<1)
#define GLB_T1_IRQ	(1<<2)
#define GLB_T0_RST	(1<<8)
#define	GLB_WD_RST	(1<<9)
#define	GLB_T1_RST	(1<<10)

#define TIMER_EN	(1<<7)  /* used on X_CTL regs */
#define AUTOLOAD	(1<<4)
#define CLK_PRSC(x)	((x)<<16)


/* for MIPS CNT */
#define MCNT_CFG	0x00
#define MCNT_CMP	0x04
#define	MCNT_CNT	0x08

#define MCNT_EN		1	/* for MCNT_CFG */


/* Frame Engine, ethernet controller */

#define TX_BASE_PTR_0	0x800	/*  TX Ring #0 Base Pointer */
#define	TX_MAX_CNT_0	0x804	/*  TX Ring #0 Maximum Count */
#define TX_CTX_IDX_0	0x808	/*  TX Ring #0 CPU pointer */
#define TX_DTX_IDX_0	0x80c	/*  TX Ring #0 DMA pointer */
#define PDMA_TX0_PTR	TX_BASE_PTR_0
#define PDMA_TX0_COUNT	TX_MAX_CNT_0
#define PDMA_TX0_CPU_IDX	TX_CTX_IDX_0
#define PDMA_TX0_DMA_IDX	TX_DTX_IDX_0
#define TX_BASE_PTR_1	0x810	/*  TX Ring #1 Base Pointer */
#define TX_MAX_CNT_1	0x814	/*  TX Ring #1 Maximum Count */
#define TX_CTX_IDX_1	0x818	/*  TX Ring #1 CPU pointer */
#define TX_DTX_IDX_1	0x81c	/*  TX Ring #1 DMA pointer */
#define TX_BASE_PTR_2	0x820	/*  TX Ring #2 Base Pointer */
#define TX_MAX_CNT_2	0x824	/*  TX Ring #2 Maximum Count */
#define TX_CTX_IDX_2	0x828	/*  TX Ring #2 CPU pointer */
#define TX_DTX_IDX_2	0x82c	/*  TX Ring #2 DMA pointer */
#define TX_BASE_PTR_3	0x830	/*  TX Ring #3 Base Pointer */
#define TX_MAX_CNT_3	0x834	/*  TX Ring #3 Maximum Count */
#define TX_CTX_IDX_3	0x838	/*  TX Ring #3 CPU pointer */
#define TX_DTX_IDX_3	0x83c	/*  TX Ring #3 DMA pointer */
#define RX_BASE_PTR_0	0x900	/*  RX Ring #0 Base Pointer */
#define RX_MAX_CNT_0	0x904	/*  RX Ring #0 Maximum Count */
#define RX_CRX_IDX_0	0x908	/*  RX Ring #0 CPU pointer */
#define RX_DRX_IDX_0	0x90c	/*  RX Ring #0 DMA pointer */
#define PDMA_RX0_PTR	RX_BASE_PTR_0
#define PDMA_RX0_COUNT	RX_MAX_CNT_0
#define PDMA_RX0_CPU_IDX	RX_CRX_IDX_0
#define PDMA_RX0_DMA_IDX	RX_DRX_IDX_0
#define RX_BASE_PTR_1	0x910	/*  RX Ring #1 Base Pointer */
#define RX_MAX_CNT_1	0x914	/*  RX Ring #1 Maximum Count */
#define RX_CRX_IDX_1	0x918	/*  RX Ring #1 CPU pointer */
#define RX_DRX_IDX_1	0x91c	/*  RX Ring #1 DMA pointer */
#define PDMA_INFO		0xa00	/*  PDMA Information */
#define PDMA_GLOBAL_CFG	0xa04	/*  PDMA Global Configuration */
#define	PDMA_IDX_RST	0xa08	/*	ring index reset ? */
#define DELAY_INT_CFG	0xa0c	/*  Delay Interrupt Configuration */
#define FREEQ_THRES		0xa10	/*  Free Queue Threshold */
#define INT_STATUS		0xa20	/*  Interrupt Status */
#define INT_MASK		0xa28	/*  Interrupt Mask */
#define PDMA_SCH		0xa80	/*  Scheduler Configuration for Q0&Q1 */
#define PDMA_WRR		0xa84	/*  Scheduler Configuration for Q2&Q3 */
#define SDM_CON			0xc00	/*  Switch DMA Control */
#define SDM_RING		0xc04	/*  Switch DMA Rx Ring */
#define SDM_TRING		0xc08	/*  Switch DMA TX Ring */
#define SDM_MAC_ADRL	0xc0c	/*  Switch MAC Address LSB */
#define SDM_MAC_ADRH	0xc10	/*  Switch MAC Address MSB */
#define GDMA1_MAC_LSB	SDM_MAC_ADRL
#define GDMA1_MAC_MSB	SDM_MAC_ADRH
#define SDM_TPCNT		0xd00	/*  Switch DMA Tx Packet Count */
#define SDM_TBCNT		0xd04	/*  Switch DMA TX Byte Count */
#define SDM_RPCNT		0xd08	/*  Switch DMA RX Packet Count */
#define SDM_RBCNT		0xd0c	/*  Switch DMA RX Byte Count */
#define SDM_CS_ERR		0xd10	/*  Switch DMA RX Checksum Error */


/*
 * 10/100 Switch registers
 */
#define SW_ISR		0x00
#define SW_IMR		0x04
#define SW_FCT0		0x08
#define  SW_FCT0_FC_RLS_TH(x)	(((x) & 0xff) << 24)
#define  SW_FCT0_FC_SET_TH(x)	(((x) & 0xff) << 16)
#define  SW_FCT0_DROP_RLS_TH(x)	(((x) & 0xff) << 8)
#define  SW_FCT0_DROP_SET_TH(x)	(((x) & 0xff) << 0)
#define SW_FCT1		0x0C
#define  SW_FCT1_PORT_TH(x)	(((x) & 0xff) << 0)
#define SW_PFC0		0x10
#define SW_PFC1		0x14
#define SW_PFC2		0x18
#define SW_QCS0		0x1C
#define SW_QCS1		0x20
#define SW_ATS		0x24
#define	SW_ATS0		0x28
#define SW_ATS1		0x2C
#define	SW_ATS2		0x30
#define SW_WMAD0	0x34
#define SW_WMAD1	0x38
#define SW_WMAD2	0x3C
#define SW_PVIDC0	0x40
#define SW_PVIDC1	0x44
#define SW_PVIDC2	0x48
#define SW_PVIDC3	0x4C
#define SW_VLANI0	0x50
#define SW_VLANI1	0x54
#define SW_VLANI2	0x58
#define SW_VLANI3	0x5C
#define SW_VLANI4	0x60
#define SW_VLANI5	0x64
#define SW_VLANI6	0x68
#define SW_VLANI7	0x6C
#define SW_VMSC0	0x70
#define SW_VMSC1	0x74
#define SW_VMSC2	0x78
#define SW_VMSC3	0x7C
#define SW_POA		0x80
#define SW_FPA		0x84
#define SW_PTS		0x88
#define SW_SOCPC	0x8C
#define SW_POC0		0x90
#define SW_POC1		0x94
#define SW_POC2		0x98
#define SW_SWGC		0x9C
#define SW_RST		0xA0
#define SW_LEDP0	0xA4
#define SW_LEDP1	0xA8
#define SW_LEDP2	0xAC
#define SW_LEDP3	0xB0
#define SW_LEDP4	0xB4
#define SW_WDOG		0xB8
#define SW_DBG		0xBC
#define SW_PCTL0	0xC0	/* PCR0 */
#define SW_PCTL1	0xC4	/* PCR1 */
#define SW_FPORT	0xC8
#define SW_FCT2		0xCC
#define SW_QSS0		0xD0
#define SW_QSS1		0xD4
#define SW_DBGC		0xD8
#define SW_MTI1		0xDC
#define SW_PPC		0xE0
#define SW_SGC2		0xE4
#define SW_PCNT0	0xE8
#define SW_PCNT1	0xEC
#define SW_PCNT2	0xF0
#define SW_PCNT3	0xF4
#define SW_PCNT4	0xF8
#define SW_PCNT5	0xFC