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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
|
typedef struct I2Cdev I2Cdev;
typedef struct PCMconftab PCMconftab;
typedef struct PCMmap PCMmap;
typedef struct PCMslot PCMslot;
#define INTRREG ((IntrReg*)PHYSINTR)
typedef struct IntrReg IntrReg;
struct IntrReg {
ulong icip; /* IRQ pending */
ulong icmr; /* mask */
ulong iclr; /* level */
ulong icfp; /* FIQ pending */
ulong icpr; /* pending */
ulong iccr; /* control */
};
/*
* types of interrupts
*/
enum
{
GPIOrising,
GPIOfalling,
GPIOboth,
IRQ,
};
enum {
/* first-level interrupts (table 4-36) */
IRQrtc= 31,
IRQhz= 30,
IRQtimer3= 29,
IRQtimer2= 28,
IRQtimer1= 27,
IRQtimer0= 26,
IRQdma= 25,
IRQssp= 24,
IRQmmc= 23,
IRQffuart= 22,
IRQbtuart= 21,
IRQstuart= 20,
IRQicp= 19,
IRQi2c= 18,
IRQlcd= 17,
IRQnssp= 16,
IRQac97= 14,
IRQi2s= 13,
IRQpmu= 12,
IRQusb= 11,
IRQgpio= 10,
IRQgpio1= 9,
IRQgpio0= 8,
IRQhwuart= 7,
};
#define GPIOREG ((GpioReg*)PHYSGPIO)
typedef struct GpioReg GpioReg;
struct GpioReg {
ulong gplr[3];
ulong gpdr[3];
ulong gpsr[3];
ulong gpcr[3];
ulong grer[3];
ulong gfer[3];
ulong gedr[3];
ulong gafr[6];
};
enum {
/* GPIO alternative functions if gafr bits set (see table 4-1, pp. 4-3 to 4-6) */
GPIO_GP_RST_1_i= 1, /* active low GP_reset */
GPIO_FFRXD_1_i= 34, /* FFUART receive */
GPIO_FFTXD_2_o= 39, /* FFUART transmit */
MaxGPIObit= 84,
MaxGPIOIRQ= 1,
};
#define GPB(n) (1<<((n)&31))
#define GPR(n) ((n)>>5)
#define GPAF(n,v) ((v)<<(((n)&15)*2))
void gpioreserve(int);
void gpioconfig(int, ulong);
ulong gpioget(int);
void gpioset(int, int);
void gpiorelease(int);
enum {
/* software configuration bits for gpioconfig */
Gpio_gpio= 0<<0,
Gpio_Alt1= 1<<0,
Gpio_Alt2= 2<<0,
Gpio_Alt3= 3<<0,
Gpio_in= 1<<2,
Gpio_out= 1<<3,
};
/*
* software structures used by ../port/devi2c.c and iic.c
*/
struct I2Cdev {
int addr;
int salen; /* length in bytes of subaddress, if used; 0 otherwise */
int tenbit; /* 10-bit addresses */
};
long i2crecv(I2Cdev*, void*, long, ulong);
long i2csend(I2Cdev*, void*, long, ulong);
void i2csetup(int);
#define COREREG ((Coreregs*)PHYSCORE)
typedef struct Coreregs Coreregs;
struct Coreregs {
ulong cccr; /* core clock config */
ulong cken; /* clock enable */
ulong oscc; /* oscillator configuration */
};
#define RTCREG ((RTCreg*)PHYSRTC)
typedef struct RTCreg RTCreg;
struct RTCreg {
ulong rcnr; /* count */
ulong rtar; /* alarm */
ulong rtsr; /* status */
ulong rttr; /* trim */
};
#define OSTMRREG ((OstmrReg*)PHYSOSTMR)
typedef struct OstmrReg OstmrReg;
struct OstmrReg {
ulong osmr[4]; /* match */
ulong oscr; /* counter */
ulong ossr; /* status */
ulong ower; /* watchdog */
ulong oier; /* interrupt enable */
};
#define PMGRREG ((PmgrReg*)PHYSPOWER)
typedef struct PmgrReg PmgrReg;
struct PmgrReg {
ulong pmcr; /* ctl register */
ulong pssr; /* sleep status */
ulong pspr; /* scratch pad */
ulong pwer; /* wakeup enable */
ulong prer; /* rising-edge detect enable */
ulong pfer; /* falling-edge detect enable */
ulong pedr; /* GPIO edge detect status */
ulong pcfr; /* general configuration */
ulong pgsr[3]; /* GPIO sleep state */
ulong rsvd;
ulong rcsr; /* reset controller status register */
};
enum {
/* pp. 3-25 to 3-31 */
PWER_rtc = 1<<31, /* wakeup by RTC alarm */
PWER_we0 = 1<<0, /* wake-up on GP0 edge detect */
PSSR_sss = 1<<0, /* software sleep status */
PSSR_bfs = 1<<1, /* battery fault status */
PSSR_vfs = 1<<2, /* VDD fault status */
PSSR_ph = 1<<4, /* peripheral control hold */
PSSR_rdh = 1<<5, /* read disable hold */
PMFW_fwake= 1<<1, /* fast wakeup enable (no power stabilisation delay) */
RSCR_gpr= 1<<3, /* gpio reset has occurred */
RSCR_smr= 1<<2, /* sleep mode has occurred */
RSCR_wdr= 1<<1, /* watchdog reset has occurred */
RSCR_hwr= 1<<0, /* hardware reset has occurred */
};
#define MEMCFGREG ((MemcfgReg*)PHYSMEMCFG)
typedef struct MemcfgReg MemcfgReg;
struct MemcfgReg {
ulong mdcnfg; /* SDRAM config */
ulong mdrefr; /* dram refresh */
ulong msc0; /* static memory or devices */
ulong msc1;
ulong msc2; /* static memory or devices */
ulong mecr; /* expansion bus (pcmcia, CF) */
ulong sxcnfg; /* synchronous static memory control */
ulong sxmrs; /* MRS value to write to SMROM */
ulong mcmem0; /* card interface socket 0 memory timing */
ulong mcmem1; /* card interface socket 1 memory timing */
ulong mcatt0; /* socket 0 attribute memory timing */
ulong mcatt1; /* socket 1 attribute memory timing */
ulong mcio0; /* socket 0 i/o timing */
ulong mcio1; /* socket 1 i/o timing */
ulong mdmrs; /* MRS value to write to SDRAM */
ulong boot_def; /* read-only boot-time register */
ulong mdmrslp; /* low-power SDRAM mode register set config */
ulong sa1111cr; /* SA1111 compatibility */
};
#define LCDREG ((LcdReg*)PHYSLCD)
typedef struct LcdReg LcdReg;
struct LcdReg {
ulong lccr0; /* control 0 */
ulong lccr1; /* control 1 */
ulong lccr2; /* control 2 */
ulong lccr3; /* control 3 */
struct {
ulong fdadr; /* dma frame descriptor address register */
ulong fsadr; /* dma frame source address register */
ulong fidr; /* dma frame ID register */
ulong ldcmd; /* dma command */
} frame[2];
ulong fbr[2]; /* frame branch register */
ulong lcsr; /* status */
ulong liidr; /* interrupt ID register */
ulong trgbr; /* TMED RGB seed register */
ulong tcr; /* TMED control register */
};
#define USBREG ((UsbReg*)PHYSUSB)
typedef struct UsbReg UsbReg;
struct UsbReg {
ulong udccr; /* control */
ulong udccs[16]; /* endpoint control/status */
ulong ufnrh; /* frame number high */
ulong ufnrl; /* frame number low */
ulong udbcr2;
ulong udbcr4;
ulong udbcr7;
ulong udbcr9;
ulong udbcr12;
ulong udbcr14;
ulong uddr[16]; /* endpoint data */
ulong uicr0;
ulong uicr1;
ulong usir0;
ulong usir1;
};
enum {
/* DMA configuration parameters */
/* DMA Direction */
DmaOut= 0,
DmaIn= 1,
/* dma devices */
DmaDREQ0= 0,
DmaDREQ1,
DmaI2S_i,
DmaI2S_o,
DmaBTUART_i,
DmaBTUART_o,
DmaFFUART_i,
DmaFFUART_o,
DmaAC97mic,
DmaAC97modem_i,
DmaAC97modem_o,
DmaAC97audio_i,
DmaAC97audio_o,
DmaSSP_i,
DmaSSP_o,
DmaNSSP_i,
DmaNSSP_o,
DmaICP_i,
DmaICP_o,
DmaSTUART_i,
DmaSTUART_o,
DmaMMC_i,
DmaMMC_o,
DmaRsvd0,
DmaRsvd1,
DmaUSB1,
DmaUSB2,
DmaUSB3,
DmaUSB4,
DmaHWUART_i,
DmaUSB6,
DmaUSB7,
DmaUSB8,
DmaUSB9,
DmaHWUART_o,
DmaUSB11,
DmaUSB12,
DmaUSB13,
DmaUSB14,
DmaRsvd2,
};
/*
* Interface to platform-specific PCMCIA signals, in arch*.c
*/
enum {
/* argument to pcmpin() */
PCMready,
PCMeject,
PCMstschng,
};
/*
* physical device addresses are mapped to the same virtual ones,
* allowing the same addresses to be used with or without mmu.
*/
#define PCMCIAcard(n) (PHYSPCMCIA0+((n)*PCMCIASIZE))
#define PCMCIAIO(n) (PCMCIAcard(n)+0x0) /* I/O space */
#define PCMCIAAttr(n) (PCMCIAcard(n)+0x8000000) /* Attribute space*/
#define PCMCIAMem(n) (PCMCIAcard(n)+0xC000000) /* Memory space */
/*
* PCMCIA structures known by both port/cis.c and the pcmcia driver
*/
/*
* Map between ISA memory space and PCMCIA card memory space.
*/
struct PCMmap {
ulong ca; /* card address */
ulong cea; /* card end address */
ulong isa; /* local virtual address */
int len; /* length of the ISA area */
int attr; /* attribute memory */
};
/*
* a PCMCIA configuration entry
*/
struct PCMconftab
{
int index;
ushort irqs; /* legal irqs */
uchar irqtype;
uchar bit16; /* true for 16 bit access */
uchar nlines;
struct {
ulong start;
ulong len;
} io[16];
int nio;
uchar vcc;
uchar vpp1;
uchar vpp2;
uchar memwait;
ulong maxwait;
ulong readywait;
ulong otherwait;
};
/*
* PCMCIA card slot
*/
struct PCMslot
{
RWlock;
Ref ref;
long memlen; /* memory length */
uchar slotno; /* slot number */
void *regs; /* i/o registers */
void *mem; /* memory */
void *attr; /* attribute memory */
/* status */
uchar occupied; /* card in the slot */
uchar configed; /* card configured */
uchar busy;
uchar powered;
uchar battery;
uchar wrprot;
uchar enabled;
uchar special;
uchar dsize;
/* cis info */
int cisread; /* set when the cis has been read */
char verstr[512]; /* version string */
uchar cpresent; /* config registers present */
ulong caddr; /* relative address of config registers */
int nctab; /* number of config table entries */
PCMconftab ctab[8];
PCMconftab *def; /* default conftab */
/* maps are fixed */
PCMmap memmap;
PCMmap attrmap;
};
|