summaryrefslogtreecommitdiffstats
path: root/sys/arm/lpc/lpcreg.h
blob: b63dfbc5accd0edcaebba1ff0a23eb26c3cfb0d2 (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
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
/*-
 * Copyright (c) 2011 Jakub Wojciech Klama <jceel@FreeBSD.org>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD$
 */

#ifndef	_ARM_LPC_LPCREG_H
#define	_ARM_LPC_LPCREG_H

#define	LPC_DEV_PHYS_BASE		0x40000000
#define	LPC_DEV_P5_PHYS_BASE		0x20000000
#define	LPC_DEV_P6_PHYS_BASE		0x30000000
#define	LPC_DEV_SIZE			0x10000000

/*
 * Interrupt controller (from UM10326: LPC32x0 User manual, page 87)

 */
#define	LPC_INTC_MIC_ER			0x0000
#define	LPC_INTC_MIC_RSR		0x0004
#define	LPC_INTC_MIC_SR			0x0008
#define	LPC_INTC_MIC_APR		0x000c
#define	LPC_INTC_MIC_ATR		0x0010
#define	LPC_INTC_MIC_ITR		0x0014
#define	LPC_INTC_SIC1_ER		0x4000
#define	LPC_INTC_SIC1_RSR		0x4004
#define	LPC_INTC_SIC1_SR		0x4008
#define	LPC_INTC_SIC1_APR		0x400c
#define	LPC_INTC_SIC1_ATR		0x4010
#define	LPC_INTC_SIC1_ITR		0x4014
#define	LPC_INTC_SIC2_ER		0x8000
#define	LPC_INTC_SIC2_RSR		0x8004
#define	LPC_INTC_SIC2_SR		0x8008
#define	LPC_INTC_SIC2_APR		0x800c
#define	LPC_INTC_SIC2_ATR		0x8010
#define	LPC_INTC_SIC2_ITR		0x8014


/*
 * Timer 0|1|2|3|4|5. (from UM10326: LPC32x0 User manual, page 540)
 */
#define	LPC_TIMER_IR			0x00
#define	LPC_TIMER_TCR			0x04
#define	LPC_TIMER_TCR_ENABLE		(1 << 0)
#define	LPC_TIMER_TCR_RESET		(1 << 1)
#define	LPC_TIMER_TC			0x08
#define	LPC_TIMER_PR			0x0c
#define	LPC_TIMER_PC			0x10
#define	LPC_TIMER_MCR			0x14
#define	LPC_TIMER_MCR_MR0I		(1 << 0)
#define	LPC_TIMER_MCR_MR0R		(1 << 1)
#define	LPC_TIMER_MCR_MR0S		(1 << 2)
#define	LPC_TIMER_MCR_MR1I		(1 << 3)
#define	LPC_TIMER_MCR_MR1R		(1 << 4)
#define	LPC_TIMER_MCR_MR1S		(1 << 5)
#define	LPC_TIMER_MCR_MR2I		(1 << 6)
#define	LPC_TIMER_MCR_MR2R		(1 << 7)
#define	LPC_TIMER_MCR_MR2S		(1 << 8)
#define	LPC_TIMER_MCR_MR3I		(1 << 9)
#define	LPC_TIMER_MCR_MR3R		(1 << 10)
#define	LPC_TIMER_MCR_MR3S		(1 << 11)
#define	LPC_TIMER_MR0			0x18
#define	LPC_TIMER_CTCR			0x70

/*
 * Watchdog timer. (from UM10326: LPC32x0 User manual, page 572)
 */
#define	LPC_WDTIM_PHYS_BASE		(LPC_DEV_PHYS_BASE + 0x3c000)
#define	LPC_WDTIM_INT			0x00
#define	LPC_WDTIM_CTRL			0x04
#define	LPC_WDTIM_COUNTER		0x08
#define	LPC_WDTIM_MCTRL			0x0c
#define	LPC_WDTIM_MATCH0		0x10
#define	LPC_WDTIM_EMR			0x14
#define	LPC_WDTIM_PULSE			0x18
#define	LPC_WDTIM_RES			0x1c
#define	LPC_WDTIM_SIZE			0x20

/*
 * Clocking and power control. (from UM10326: LPC32x0 User manual, page 58)
 */
#define	LPC_CLKPWR_PHYS_BASE		(LPC_DEV_PHYS_BASE + 0x4000)
#define	LPC_CLKPWR_PWR_CTRL		0x44
#define	LPC_CLKPWR_OSC_CTRL		0x4c
#define	LPC_CLKPWR_SYSCLK_CTRL		0x50
#define	LPC_CLKPWR_PLL397_CTRL		0x48
#define	LPC_CLKPWR_HCLKPLL_CTRL		0x58
#define	LPC_CLKPWR_HCLKDIV_CTRL		0x40
#define	LPC_CLKPWR_TEST_CTRL		0xa4
#define	LPC_CLKPWR_AUTOCLK_CTRL		0xec
#define	LPC_CLKPWR_START_ER_PIN		0x30
#define	LPC_CLKPWR_START_ER_INT		0x20
#define	LPC_CLKPWR_P0_INTR_ER		0x18
#define	LPC_CLKPWR_START_SR_PIN		0x38
#define	LPC_CLKPWR_START_SR_INT		0x28
#define	LPC_CLKPWR_START_RSR_PIN	0x34
#define	LPC_CLKPWR_START_RSR_INT	0x24
#define	LPC_CLKPWR_START_APR_PIN	0x3c
#define	LPC_CLKPWR_START_APR_INT	0x2c
#define	LPC_CLKPWR_USB_CTRL		0x64
#define	LPC_CLKPWR_USB_CTRL_SLAVE_HCLK	(1 << 24)
#define	LPC_CLKPWR_USB_CTRL_I2C_EN	(1 << 23)
#define	LPC_CLKPWR_USB_CTRL_DEV_NEED_CLK_EN	(1 << 22)
#define	LPC_CLKPWR_USB_CTRL_HOST_NEED_CLK_EN	(1 << 21)
#define	LPC_CLKPWR_USB_CTRL_BUSKEEPER	(1 << 19)
#define	LPC_CLKPWR_USB_CTRL_CLK_EN2	(1 << 18)
#define	LPC_CLKPWR_USB_CTRL_CLK_EN1	(1 << 17)
#define	LPC_CLKPWR_USB_CTRL_PLL_PDOWN	(1 << 16)
#define	LPC_CLKPWR_USB_CTRL_BYPASS	(1 << 15)
#define	LPC_CLKPWR_USB_CTRL_DIRECT_OUT	(1 << 14)
#define	LPC_CLKPWR_USB_CTRL_FEEDBACK	(1 << 13)
#define	LPC_CLKPWR_USB_CTRL_POSTDIV(_x)	((_x & 0x3) << 11)
#define	LPC_CLKPWR_USB_CTRL_PREDIV(_x)	((_x & 0x3) << 9)
#define	LPC_CLKPWR_USB_CTRL_FDBKDIV(_x)	(((_x-1) & 0xff) << 1)
#define	LPC_CLKPWR_USB_CTRL_PLL_LOCK	(1 << 0)
#define	LPC_CLKPWR_USBDIV_CTRL		0x1c
#define	LPC_CLKPWR_MS_CTRL		0x80
#define	LPC_CLKPWR_MS_CTRL_DISABLE_SD	(1 << 10)
#define	LPC_CLKPWR_MS_CTRL_CLOCK_EN	(1 << 9)
#define	LPC_CLKPWR_MS_CTRL_MSSDIO23_PAD	(1 << 8)
#define	LPC_CLKPWR_MS_CTRL_MSSDIO1_PAD	(1 << 7)
#define	LPC_CLKPWR_MS_CTRL_MSSDIO0_PAD	(1 << 6)
#define	LPC_CLKPWR_MS_CTRL_SD_CLOCK	(1 << 5)
#define	LPC_CLKPWR_MS_CTRL_CLKDIV_MASK	0xf
#define	LPC_CLKPWR_DMACLK_CTRL		0xe8
#define	LPC_CLKPWR_DMACLK_CTRL_EN	(1 << 0)
#define	LPC_CLKPWR_FLASHCLK_CTRL	0xc8
#define	LPC_CLKPWR_MACCLK_CTRL		0x90
#define	LPC_CLKPWR_MACCLK_CTRL_REG	(1 << 0)
#define	LPC_CLKPWR_MACCLK_CTRL_SLAVE	(1 << 1)
#define	LPC_CLKPWR_MACCLK_CTRL_MASTER	(1 << 2)
#define	LPC_CLKPWR_MACCLK_CTRL_HDWINF(_n) ((_n & 0x3) << 3)
#define	LPC_CLKPWR_LCDCLK_CTRL		0x54
#define	LPC_CLKPWR_LCDCLK_CTRL_DISPTYPE	(1 << 8)
#define	LPC_CLKPWR_LCDCLK_CTRL_MODE(_n)	((_n & 0x3) << 6)
#define	LPC_CLKPWR_LCDCLK_CTRL_MODE_12	0x0
#define	LPC_CLKPWR_LCDCLK_CTRL_MODE_15	0x1
#define	LPC_CLKPWR_LCDCLK_CTRL_MODE_16	0x2
#define	LPC_CLKPWR_LCDCLK_CTRL_MODE_24	0x3
#define	LPC_CLKPWR_LCDCLK_CTRL_HCLKEN	(1 << 5)
#define	LPC_CLKPWR_LCDCLK_CTRL_CLKDIV(_n) ((_n) & 0x1f)
#define	LPC_CLKPWR_I2S_CTRL		0x7c
#define	LPC_CLKPWR_SSP_CTRL		0x78
#define	LPC_CLKPWR_SSP_CTRL_SSP1RXDMA	(1 << 5)
#define	LPC_CLKPWR_SSP_CTRL_SSP1TXDMA	(1 << 4)
#define	LPC_CLKPWR_SSP_CTRL_SSP0RXDMA	(1 << 3)
#define	LPC_CLKPWR_SSP_CTRL_SSP0TXDMA	(1 << 2)
#define	LPC_CLKPWR_SSP_CTRL_SSP1EN	(1 << 1)
#define	LPC_CLKPWR_SSP_CTRL_SSP0EN	(1 << 0)
#define	LPC_CLKPWR_SPI_CTRL		0xc4
#define	LPC_CLKPWR_I2CCLK_CTRL		0xac
#define	LPC_CLKPWR_TIMCLK_CTRL1		0xc0
#define	LPC_CLKPWR_TIMCLK_CTRL1_TIMER4	(1 << 0)
#define	LPC_CLKPWR_TIMCLK_CTRL1_TIMER5	(1 << 1)
#define	LPC_CLKPWR_TIMCLK_CTRL1_TIMER0	(1 << 2)
#define	LPC_CLKPWR_TIMCLK_CTRL1_TIMER1	(1 << 3)
#define	LPC_CLKPWR_TIMCLK_CTRL1_TIMER2	(1 << 4)
#define	LPC_CLKPWR_TIMCLK_CTRL1_TIMER3	(1 << 5)
#define	LPC_CLKPWR_TIMCLK_CTRL1_MOTORCTL	(1 << 6)
#define	LPC_CLKPWR_TIMCLK_CTRL		0xbc
#define	LPC_CLKPWR_TIMCLK_CTRL_WATCHDOG	(1 << 0)
#define	LPC_CLKPWR_TIMCLK_CTRL_HSTIMER	(1 << 1)
#define	LPC_CLKPWR_ADCLK_CTRL		0xb4
#define	LPC_CLKPWR_ADCLK_CTRL1		0x60
#define	LPC_CLKPWR_KEYCLK_CTRL		0xb0
#define	LPC_CLKPWR_PWMCLK_CTRL		0xb8
#define	LPC_CLKPWR_UARTCLK_CTRL		0xe4
#define	LPC_CLKPWR_POS0_IRAM_CTRL	0x110
#define	LPC_CLKPWR_POS1_IRAM_CTRL	0x114
#define	LPC_CLKPWR_SIZE			0x118

/* Additional UART registers in CLKPWR address space. */
#define	LPC_CLKPWR_UART_U3CLK		0xd0
#define	LPC_CLKPWR_UART_U4CLK		0xd4
#define	LPC_CLKPWR_UART_U5CLK		0xd8
#define	LPC_CLKPWR_UART_U6CLK		0xdc
#define	LPC_CLKPWR_UART_UCLK_HCLK	(1 << 16)
#define	LPC_CLKPWR_UART_UCLK_X(_n)	(((_n) & 0xff) << 8)
#define	LPC_CLKPWR_UART_UCLK_Y(_n)	((_n) & 0xff)
#define	LPC_CLKPWR_UART_IRDACLK		0xe0

/* Additional UART registers */
#define	LPC_UART_BASE			0x80000
#define	LPC_UART_CONTROL_BASE		0x54000
#define	LPC_UART5_BASE			0x90000
#define	LPC_UART_CTRL			0x00
#define	LPC_UART_CLKMODE		0x04
#define	LPC_UART_CLKMODE_UART3(_n)	(((_n) & 0x3) << 4)
#define	LPC_UART_CLKMODE_UART4(_n)	(((_n) & 0x3) << 6)
#define	LPC_UART_CLKMODE_UART5(_n)	(((_n) & 0x3) << 8)
#define	LPC_UART_CLKMODE_UART6(_n)	(((_n) & 0x3) << 10)
#define	LPC_UART_LOOP			0x08
#define	LPC_UART_CONTROL_SIZE		0x0c
#define	LPC_UART_FIFOSIZE		64

/*
 * Real time clock. (from UM10326: LPC32x0 User manual, page 566)
 */
#define	LPC_RTC_UCOUNT			0x00
#define	LPC_RTC_DCOUNT			0x04
#define	LPC_RTC_MATCH0			0x08
#define	LPC_RTC_MATCH1			0x0c
#define	LPC_RTC_CTRL			0x10
#define	LPC_RTC_CTRL_ONSW		(1 << 7)
#define	LPC_RTC_CTRL_DISABLE		(1 << 6)
#define	LPC_RTC_CTRL_RTCRESET		(1 << 4)
#define	LPC_RTC_CTRL_MATCH0ONSW		(1 << 3)
#define	LPC_RTC_CTRL_MATCH1ONSW		(1 << 2)
#define	LPC_RTC_CTRL_MATCH1INTR		(1 << 1)
#define	LPC_RTC_CTRL_MATCH0INTR		(1 << 0)
#define	LPC_RTC_INTSTAT			0x14
#define	LPC_RTC_KEY			0x18
#define	LPC_RTC_SRAM_BEGIN		0x80
#define LPC_RTC_SRAM_END		0xff

/*
 * MMC/SD controller. (from UM10326: LPC32x0 User manual, page 436)
 */
#define	LPC_SD_PHYS_BASE		(LPC_DEV_P5_PHYS_BASE + 0x98000)
#define	LPC_SD_CLK			(13 * 1000 * 1000)	// 13Mhz
#define	LPC_SD_POWER			0x00
#define	LPC_SD_POWER_OPENDRAIN		(1 << 6)
#define	LPC_SD_POWER_CTRL_OFF		0x00
#define	LPC_SD_POWER_CTRL_UP		0x02
#define	LPC_SD_POWER_CTRL_ON		0x03
#define	LPC_SD_CLOCK			0x04
#define	LPC_SD_CLOCK_WIDEBUS		(1 << 11)
#define	LPC_SD_CLOCK_BYPASS		(1 << 10)
#define	LPC_SD_CLOCK_PWRSAVE		(1 << 9)
#define	LPC_SD_CLOCK_ENABLE		(1 << 8)
#define	LPC_SD_CLOCK_CLKDIVMASK		0xff
#define	LPC_SD_ARGUMENT			0x08
#define	LPC_SD_COMMAND			0x0c
#define	LPC_SD_COMMAND_ENABLE		(1 << 10)
#define	LPC_SD_COMMAND_PENDING		(1 << 9)
#define	LPC_SD_COMMAND_INTERRUPT	(1 << 8)
#define	LPC_SD_COMMAND_LONGRSP		(1 << 7)
#define	LPC_SD_COMMAND_RESPONSE		(1 << 6)
#define	LPC_SD_COMMAND_CMDINDEXMASK	0x3f
#define	LPC_SD_RESPCMD			0x10
#define	LPC_SD_RESP0			0x14
#define	LPC_SD_RESP1			0x18
#define	LPC_SD_RESP2			0x1c
#define	LPC_SD_RESP3			0x20
#define	LPC_SD_DATATIMER		0x24
#define	LPC_SD_DATALENGTH		0x28
#define	LPC_SD_DATACTRL			0x2c
#define	LPC_SD_DATACTRL_BLOCKSIZESHIFT	4
#define	LPC_SD_DATACTRL_BLOCKSIZEMASK	0xf
#define	LPC_SD_DATACTRL_DMAENABLE	(1 << 3)
#define	LPC_SD_DATACTRL_MODE		(1 << 2)
#define	LPC_SD_DATACTRL_WRITE		(0 << 1)
#define	LPC_SD_DATACTRL_READ		(1 << 1)
#define	LPC_SD_DATACTRL_ENABLE		(1 << 0)
#define	LPC_SD_DATACNT			0x30
#define	LPC_SD_STATUS			0x34
#define	LPC_SD_STATUS_RXDATAAVLBL	(1 << 21)
#define	LPC_SD_STATUS_TXDATAAVLBL	(1 << 20)
#define	LPC_SD_STATUS_RXFIFOEMPTY	(1 << 19)
#define	LPC_SD_STATUS_TXFIFOEMPTY	(1 << 18)
#define	LPC_SD_STATUS_RXFIFOFULL	(1 << 17)
#define	LPC_SD_STATUS_TXFIFOFULL	(1 << 16)
#define	LPC_SD_STATUS_RXFIFOHALFFULL	(1 << 15)
#define	LPC_SD_STATUS_TXFIFOHALFEMPTY	(1 << 14)
#define	LPC_SD_STATUS_RXACTIVE		(1 << 13)
#define	LPC_SD_STATUS_TXACTIVE		(1 << 12)
#define	LPC_SD_STATUS_CMDACTIVE		(1 << 11)
#define	LPC_SD_STATUS_DATABLOCKEND	(1 << 10)
#define	LPC_SD_STATUS_STARTBITERR	(1 << 9)
#define	LPC_SD_STATUS_DATAEND		(1 << 8)
#define	LPC_SD_STATUS_CMDSENT		(1 << 7)
#define	LPC_SD_STATUS_CMDRESPEND	(1 << 6)
#define	LPC_SD_STATUS_RXOVERRUN		(1 << 5)
#define	LPC_SD_STATUS_TXUNDERRUN	(1 << 4)
#define	LPC_SD_STATUS_DATATIMEOUT	(1 << 3)
#define	LPC_SD_STATUS_CMDTIMEOUT	(1 << 2)
#define	LPC_SD_STATUS_DATACRCFAIL	(1 << 1)
#define	LPC_SD_STATUS_CMDCRCFAIL	(1 << 0)
#define	LPC_SD_CLEAR			0x38
#define	LPC_SD_MASK0			0x03c
#define	LPC_SD_MASK1			0x40
#define	LPC_SD_FIFOCNT			0x48
#define	LPC_SD_FIFO			0x80

/*
 * USB OTG controller (from UM10326: LPC32x0 User manual, page 410)
 */
#define	LPC_OTG_INT_STATUS		0x100
#define	LPC_OTG_INT_ENABLE		0x104
#define	LPC_OTG_INT_SET			0x108
#define	LPC_OTG_INT_CLEAR		0x10c
#define	LPC_OTG_STATUS			0x110
#define	LPC_OTG_STATUS_ATOB_HNP_TRACK	(1 << 9)
#define	LPC_OTG_STATUS_BTOA_HNP_TACK	(1 << 8)
#define	LPC_OTG_STATUS_TRANSP_I2C_EN	(1 << 7)
#define	LPC_OTG_STATUS_TIMER_RESET	(1 << 6)
#define	LPC_OTG_STATUS_TIMER_EN		(1 << 5)
#define	LPC_OTG_STATUS_TIMER_MODE	(1 << 4)
#define	LPC_OTG_STATUS_TIMER_SCALE	(1 << 2)
#define	LPC_OTG_STATUS_HOST_EN		(1 << 0)
#define	LPC_OTG_TIMER			0x114
#define	LPC_OTG_I2C_TXRX		0x300
#define	LPC_OTG_I2C_STATUS		0x304
#define	LPC_OTG_I2C_STATUS_TFE		(1 << 11)
#define	LPC_OTG_I2C_STATUS_TFF		(1 << 10)
#define	LPC_OTG_I2C_STATUS_RFE		(1 << 9)
#define	LPC_OTG_I2C_STATUS_RFF		(1 << 8)
#define	LPC_OTG_I2C_STATUS_SDA		(1 << 7)
#define	LPC_OTG_I2C_STATUS_SCL		(1 << 6)
#define	LPC_OTG_I2C_STATUS_ACTIVE	(1 << 5)
#define	LPC_OTG_I2C_STATUS_DRSI		(1 << 4)
#define	LPC_OTG_I2C_STATUS_DRMI		(1 << 3)
#define	LPC_OTG_I2C_STATUS_NAI		(1 << 2)
#define	LPC_OTG_I2C_STATUS_AFI		(1 << 1)
#define	LPC_OTG_I2C_STATUS_TDI		(1 << 0)
#define	LPC_OTG_I2C_CTRL		0x308
#define	LPC_OTG_I2C_CTRL_SRST		(1 << 8)
#define	LPC_OTG_I2C_CTRL_TFFIE		(1 << 7)
#define	LPC_OTG_I2C_CTRL_RFDAIE		(1 << 6)
#define	LPC_OTG_I2C_CTRL_RFFIE		(1 << 5)
#define	LPC_OTG_I2C_CTRL_DRSIE		(1 << 4)
#define	LPC_OTG_I2C_CTRL_DRMIE		(1 << 3)
#define	LPC_OTG_I2C_CTRL_NAIE		(1 << 2)
#define	LPC_OTG_I2C_CTRL_AFIE		(1 << 1)
#define	LPC_OTG_I2C_CTRL_TDIE		(1 << 0)
#define	LPC_OTG_I2C_CLKHI		0x30c
#define	LPC_OTG_I2C_CLKLO		0x310
#define	LPC_OTG_CLOCK_CTRL		0xff4
#define	LPC_OTG_CLOCK_CTRL_AHB_EN	(1 << 4)
#define	LPC_OTG_CLOCK_CTRL_OTG_EN	(1 << 3)
#define	LPC_OTG_CLOCK_CTRL_I2C_EN	(1 << 2)
#define	LPC_OTG_CLOCK_CTRL_DEV_EN	(1 << 1)
#define	LPC_OTG_CLOCK_CTRL_HOST_EN	(1 << 0)
#define	LPC_OTG_CLOCK_STATUS		0xff8

/*
 * ISP3101 USB transceiver registers
 */
#define	LPC_ISP3101_I2C_ADDR		0x2d
#define	LPC_ISP3101_MODE_CONTROL_1	0x04
#define	LPC_ISP3101_MC1_SPEED_REG	(1 << 0)
#define	LPC_ISP3101_MC1_SUSPEND_REG	(1 << 1)
#define	LPC_ISP3101_MC1_DAT_SE0		(1 << 2)
#define	LPC_ISP3101_MC1_TRANSPARENT	(1 << 3)
#define	LPC_ISP3101_MC1_BDIS_ACON_EN	(1 << 4)
#define	LPC_ISP3101_MC1_OE_INT_EN	(1 << 5)
#define	LPC_ISP3101_MC1_UART_EN		(1 << 6)
#define	LPC_ISP3101_MODE_CONTROL_2	0x12
#define	LPC_ISP3101_MC2_GLOBAL_PWR_DN	(1 << 0)
#define	LPC_ISP3101_MC2_SPD_SUSP_CTRL	(1 << 1)
#define	LPC_ISP3101_MC2_BI_DI		(1 << 2)
#define	LPC_ISP3101_MC2_TRANSP_BDIR0	(1 << 3)
#define	LPC_ISP3101_MC2_TRANSP_BDIR1	(1 << 4)
#define	LPC_ISP3101_MC2_AUDIO_EN	(1 << 5)
#define	LPC_ISP3101_MC2_PSW_EN		(1 << 6)
#define	LPC_ISP3101_MC2_EN2V7		(1 << 7)
#define	LPC_ISP3101_OTG_CONTROL_1	0x06
#define	LPC_ISP3101_OTG1_DP_PULLUP	(1 << 0)
#define	LPC_ISP3101_OTG1_DM_PULLUP	(1 << 1)
#define	LPC_ISP3101_OTG1_DP_PULLDOWN	(1 << 2)
#define	LPC_ISP3101_OTG1_DM_PULLDOWN	(1 << 3)
#define	LPC_ISP3101_OTG1_ID_PULLDOWN	(1 << 4)
#define	LPC_ISP3101_OTG1_VBUS_DRV	(1 << 5)
#define	LPC_ISP3101_OTG1_VBUS_DISCHRG	(1 << 6)
#define	LPC_ISP3101_OTG1_VBUS_CHRG	(1 << 7)
#define	LPC_ISP3101_OTG_CONTROL_2	0x10
#define	LPC_ISP3101_OTG_INTR_LATCH	0x0a
#define	LPC_ISP3101_OTG_INTR_FALLING	0x0c
#define	LPC_ISP3101_OTG_INTR_RISING	0x0e
#define	LPC_ISP3101_REG_CLEAR_ADDR	0x01

/*
 * LCD Controller (from UM10326: LPC32x0 User manual, page 229)
 */
#define	LPC_LCD_TIMH			0x00
#define	LPC_LCD_TIMH_HBP(_n)		(((_n) & 0xff) << 24)
#define	LPC_LCD_TIMH_HFP(_n)		(((_n) & 0xff) << 16)
#define	LPC_LCD_TIMH_HSW(_n)		(((_n) & 0xff) << 8)
#define	LPC_LCD_TIMH_PPL(_n)		(((_n) / 16 - 1) << 2)
#define	LPC_LCD_TIMV			0x04
#define	LPC_LCD_TIMV_VBP(_n)		(((_n) & 0xff) << 24)
#define	LPC_LCD_TIMV_VFP(_n)		(((_n) & 0xff) << 16)
#define	LPC_LCD_TIMV_VSW(_n)		(((_n) & 0x3f) << 10)
#define	LPC_LCD_TIMV_LPP(_n)		((_n) & 0x1ff)
#define	LPC_LCD_POL			0x08
#define	LPC_LCD_POL_PCD_HI		(((_n) & 0x1f) << 27)
#define	LPC_LCD_POL_BCD			(1 << 26)
#define	LPC_LCD_POL_CPL(_n)		(((_n) & 0x3ff) << 16)
#define	LPC_LCD_POL_IOE			(1 << 14)
#define	LPC_LCD_POL_IPC			(1 << 13)
#define	LPC_LCD_POL_IHS			(1 << 12)
#define	LPC_LCD_POL_IVS			(1 << 11)
#define	LPC_LCD_POL_ACB(_n)		((_n & 0x1f) << 6)
#define	LPC_LCD_POL_CLKSEL		(1 << 5)
#define	LPC_LCD_POL_PCD_LO(_n)		((_n) & 0x1f)
#define	LPC_LCD_LE			0x0c
#define	LPC_LCD_LE_LEE			(1 << 16)
#define	LPC_LCD_LE_LED			((_n) & 0x7f)
#define	LPC_LCD_UPBASE			0x10
#define	LPC_LCD_LPBASE			0x14
#define	LPC_LCD_CTRL			0x18
#define	LPC_LCD_CTRL_WATERMARK		(1 << 16)
#define	LPC_LCD_CTRL_LCDVCOMP(_n)	(((_n) & 0x3) << 12)
#define	LPC_LCD_CTRL_LCDPWR		(1 << 11)
#define	LPC_LCD_CTRL_BEPO		(1 << 10)
#define	LPC_LCD_CTRL_BEBO		(1 << 9)
#define	LPC_LCD_CTRL_BGR		(1 << 8)
#define	LPC_LCD_CTRL_LCDDUAL		(1 << 7)
#define	LPC_LCD_CTRL_LCDMONO8		(1 << 6)
#define	LPC_LCD_CTRL_LCDTFT		(1 << 5)
#define	LPC_LCD_CTRL_LCDBW		(1 << 4)
#define	LPC_LCD_CTRL_LCDBPP(_n)		(((_n) & 0x7) << 1)
#define	LPC_LCD_CTRL_BPP1		0
#define	LPC_LCD_CTRL_BPP2		1
#define	LPC_LCD_CTRL_BPP4		2
#define	LPC_LCD_CTRL_BPP8		3
#define	LPC_LCD_CTRL_BPP16		4
#define	LPC_LCD_CTRL_BPP24		5
#define	LPC_LCD_CTRL_BPP16_565		6
#define	LPC_LCD_CTRL_BPP12_444		7
#define	LPC_LCD_CTRL_LCDEN		(1 << 0)
#define	LPC_LCD_INTMSK			0x1c
#define	LPC_LCD_INTRAW			0x20
#define	LPC_LCD_INTSTAT			0x24
#define	LPC_LCD_INTCLR			0x28
#define	LPC_LCD_UPCURR			0x2c
#define	LPC_LCD_LPCURR			0x30
#define	LPC_LCD_PAL			0x200
#define	LPC_LCD_CRSR_IMG		0x800
#define	LPC_LCD_CRSR_CTRL		0xc00
#define	LPC_LCD_CRSR_CFG		0xc04
#define	LPC_LCD_CRSR_PAL0		0xc08
#define	LPC_LCD_CRSR_PAL1		0xc0c
#define	LPC_LCD_CRSR_XY			0xc10
#define	LPC_LCD_CRSR_CLIP		0xc14
#define	LPC_LCD_CRSR_INTMSK		0xc20
#define	LPC_LCD_CRSR_INTCLR		0xc24
#define	LPC_LCD_CRSR_INTRAW		0xc28
#define	LPC_LCD_CRSR_INTSTAT		0xc2c

/*
 * SPI interface (from UM10326: LPC32x0 User manual, page 483)
 */
#define	LPC_SPI_GLOBAL			0x00
#define	LPC_SPI_GLOBAL_RST		(1 << 1)
#define	LPC_SPI_GLOBAL_ENABLE		(1 << 0)
#define	LPC_SPI_CON			0x04
#define	LPC_SPI_CON_UNIDIR		(1 << 23)
#define	LPC_SPI_CON_BHALT		(1 << 22)
#define	LPC_SPI_CON_BPOL		(1 << 21)
#define	LPC_SPI_CON_MSB			(1 << 19)
#define	LPC_SPI_CON_MODE(_n)		((_n & 0x3) << 16)
#define	LPC_SPI_CON_RXTX		(1 << 15)
#define	LPC_SPI_CON_THR			(1 << 14)
#define	LPC_SPI_CON_SHIFT_OFF		(1 << 13)
#define	LPC_SPI_CON_BITNUM(_n)		((_n & 0xf) << 9)
#define	LPC_SPI_CON_MS			(1 << 7)
#define	LPC_SPI_CON_RATE(_n)		(_n & 0x7f)
#define	LPC_SPI_FRM			0x08
#define	LPC_SPI_IER			0x0c
#define	LPC_SPI_IER_INTEOT		(1 << 1)
#define	LPC_SPI_IER_INTTHR		(1 << 0)
#define	LPC_SPI_STAT			0x10
#define	LPC_SPI_STAT_INTCLR		(1 << 8)
#define	LPC_SPI_STAT_EOT		(1 << 7)
#define	LPC_SPI_STAT_BUSYLEV		(1 << 6)
#define	LPC_SPI_STAT_SHIFTACT		(1 << 3)
#define	LPC_SPI_STAT_BF			(1 << 2)
#define	LPC_SPI_STAT_THR		(1 << 1)
#define	LPC_SPI_STAT_BE			(1 << 0)
#define	LPC_SPI_DAT			0x14
#define	LPC_SPI_TIM_CTRL		0x400
#define	LPC_SPI_TIM_COUNT		0x404
#define	LPC_SPI_TIM_STAT		0x408

/*
 * SSP interface (from UM10326: LPC32x0 User manual, page 500)
 */
#define	LPC_SSP0_BASE			0x4c00
#define	LPC_SSP1_BASE			0xc000
#define	LPC_SSP_CR0			0x00
#define	LPC_SSP_CR0_DSS(_n)		((_n-1) & 0xf)
#define	LPC_SSP_CR0_TI			(1 << 4)
#define	LPC_SSP_CR0_MICROWIRE		(1 << 5)
#define	LPC_SSP_CR0_CPOL		(1 << 6)
#define	LPC_SSP_CR0_CPHA		(1 << 7)
#define	LPC_SSP_CR0_SCR(_n)		((_x & & 0xff) << 8)
#define	LPC_SSP_CR1			0x04
#define	LPC_SSP_CR1_LBM			(1 << 0)
#define	LPC_SSP_CR1_SSE			(1 << 1)
#define	LPC_SSP_CR1_MS			(1 << 2)
#define	LPC_SSP_CR1_SOD			(1 << 3)
#define	LPC_SSP_DR			0x08
#define	LPC_SSP_SR			0x0c
#define	LPC_SSP_SR_TFE			(1 << 0)
#define	LPC_SSP_SR_TNF			(1 << 1)
#define	LPC_SSP_SR_RNE			(1 << 2)
#define	LPC_SSP_SR_RFF			(1 << 3)
#define	LPC_SSP_SR_BSY			(1 << 4)
#define	LPC_SSP_CPSR			0x10
#define	LPC_SSP_IMSC			0x14
#define	LPC_SSP_IMSC_RORIM		(1 << 0)
#define	LPC_SSP_IMSC_RTIM		(1 << 1)
#define	LPC_SSP_IMSC_RXIM		(1 << 2)
#define	LPC_SSP_IMSC_TXIM		(1 << 3)
#define	LPC_SSP_RIS			0x18
#define	LPC_SSP_RIS_RORRIS		(1 << 0)
#define	LPC_SSP_RIS_RTRIS		(1 << 1)
#define	LPC_SSP_RIS_RXRIS		(1 << 2)
#define	LPC_SSP_RIS_TXRIS		(1 << 3)
#define	LPC_SSP_MIS			0x1c
#define	LPC_SSP_ICR			0x20
#define	LPC_SSP_DMACR			0x24

/*
 * GPIO (from UM10326: LPC32x0 User manual, page 606)
 */
#define	LPC_GPIO_PHYS_BASE		(LPC_DEV_PHYS_BASE + 0x28000)
#define	LPC_GPIO_P0_COUNT		8
#define	LPC_GPIO_P1_COUNT		24
#define	LPC_GPIO_P2_COUNT		13
#define	LPC_GPIO_P3_COUNT		52
#define	LPC_GPIO_P0_INP_STATE		0x40
#define	LPC_GPIO_P0_OUTP_SET		0x44
#define	LPC_GPIO_P0_OUTP_CLR		0x48
#define	LPC_GPIO_P0_OUTP_STATE		0x4c
#define	LPC_GPIO_P0_DIR_SET		0x50
#define	LPC_GPIO_P0_DIR_CLR		0x54
#define	LPC_GPIO_P0_DIR_STATE		0x58
#define	LPC_GPIO_P1_INP_STATE		0x60
#define	LPC_GPIO_P1_OUTP_SET		0x64
#define	LPC_GPIO_P1_OUTP_CLR		0x68
#define	LPC_GPIO_P1_OUTP_STATE		0x6c
#define	LPC_GPIO_P1_DIR_SET		0x70
#define	LPC_GPIO_P1_DIR_CLR		0x74
#define	LPC_GPIO_P1_DIR_STATE		0x78
#define	LPC_GPIO_P2_INP_STATE		0x1c
#define	LPC_GPIO_P2_OUTP_SET		0x20
#define	LPC_GPIO_P2_OUTP_CLR		0x24
#define	LPC_GPIO_P2_DIR_SET		0x10
#define	LPC_GPIO_P2_DIR_CLR		0x14
#define	LPC_GPIO_P2_DIR_STATE		0x14
#define	LPC_GPIO_P3_INP_STATE		0x00
#define	LPC_GPIO_P3_OUTP_SET		0x04
#define	LPC_GPIO_P3_OUTP_CLR		0x08
#define	LPC_GPIO_P3_OUTP_STATE		0x0c
#define	LPC_GPIO_SIZE			0x80

/* Aliases for logical pin numbers: */
#define	LPC_GPIO_GPI_00(_n)		(0 + _n)
#define	LPC_GPIO_GPI_15(_n)		(10 + _n)
#define	LPC_GPIO_GPI_25			(19)
#define	LPC_GPIO_GPI_27(_n)		(20 + _n)
#define	LPC_GPIO_GPO_00(_n)		(22 + _n)
#define	LPC_GPIO_GPIO_00(_n)		(46 + _n)
/* SPI devices chip selects: */
#define	SSD1289_CS_PIN			LPC_GPIO_GPO_00(4)
#define	SSD1289_DC_PIN			LPC_GPIO_GPO_00(5)
#define	ADS7846_CS_PIN			LPC_GPIO_GPO_00(11)
#define	ADS7846_INTR_PIN		LPC_GPIO_GPIO_00(0)

/*
 * GPDMA controller (from UM10326: LPC32x0 User manual, page 106)
 */
#define	LPC_DMAC_INTSTAT		0x00
#define	LPC_DMAC_INTTCSTAT		0x04
#define	LPC_DMAC_INTTCCLEAR		0x08
#define	LPC_DMAC_INTERRSTAT		0x0c
#define	LPC_DMAC_INTERRCLEAR		0x10
#define	LPC_DMAC_RAWINTTCSTAT		0x14
#define	LPC_DMAC_RAWINTERRSTAT		0x18
#define	LPC_DMAC_ENABLED_CHANNELS	0x1c
#define	LPC_DMAC_SOFTBREQ		0x20
#define	LPC_DMAC_SOFTSREQ		0x24
#define	LPC_DMAC_SOFTLBREQ		0x28
#define	LPC_DMAC_SOFTLSREQ		0x2c
#define	LPC_DMAC_CONFIG			0x30
#define	LPC_DMAC_CONFIG_M1		(1 << 2)
#define	LPC_DMAC_CONFIG_M0		(1 << 1)
#define	LPC_DMAC_CONFIG_ENABLE		(1 << 0)
#define	LPC_DMAC_CHADDR(_n)		(0x100 + (_n * 0x20))
#define	LPC_DMAC_CHNUM			8
#define	LPC_DMAC_CHSIZE			0x20
#define	LPC_DMAC_CH_SRCADDR		0x00
#define	LPC_DMAC_CH_DSTADDR		0x04
#define	LPC_DMAC_CH_LLI			0x08
#define	LPC_DMAC_CH_LLI_AHB1		(1 << 0)
#define	LPC_DMAC_CH_CONTROL		0x0c
#define	LPC_DMAC_CH_CONTROL_I		(1U << 31)
#define	LPC_DMAC_CH_CONTROL_DI		(1 << 27)
#define	LPC_DMAC_CH_CONTROL_SI		(1 << 26)
#define	LPC_DMAC_CH_CONTROL_D		(1 << 25)
#define	LPC_DMAC_CH_CONTROL_S		(1 << 24)
#define	LPC_DMAC_CH_CONTROL_WIDTH_4	2
#define	LPC_DMAC_CH_CONTROL_DWIDTH(_n)	((_n & 0x7) << 21)
#define	LPC_DMAC_CH_CONTROL_SWIDTH(_n)	((_n & 0x7) << 18)
#define	LPC_DMAC_CH_CONTROL_BURST_8	2
#define	LPC_DMAC_CH_CONTROL_DBSIZE(_n)	((_n & 0x7) << 15)
#define	LPC_DMAC_CH_CONTROL_SBSIZE(_n)	((_n & 0x7) << 12)
#define	LPC_DMAC_CH_CONTROL_XFERLEN(_n)	(_n & 0xfff) 
#define	LPC_DMAC_CH_CONFIG		0x10
#define	LPC_DMAC_CH_CONFIG_H		(1 << 18)
#define	LPC_DMAC_CH_CONFIG_A		(1 << 17)
#define	LPC_DMAC_CH_CONFIG_L		(1 << 16)
#define	LPC_DMAC_CH_CONFIG_ITC		(1 << 15)
#define	LPC_DMAC_CH_CONFIG_IE		(1 << 14)
#define	LPC_DMAC_CH_CONFIG_FLOWCNTL(_n)	((_n & 0x7) << 11)
#define	LPC_DMAC_CH_CONFIG_DESTP(_n)	((_n & 0x1f) << 6)
#define	LPC_DMAC_CH_CONFIG_SRCP(_n)	((_n & 0x1f) << 1)
#define	LPC_DMAC_CH_CONFIG_E		(1 << 0)

/* DMA flow control values */
#define	LPC_DMAC_FLOW_D_M2M		0
#define	LPC_DMAC_FLOW_D_M2P		1
#define	LPC_DMAC_FLOW_D_P2M		2
#define	LPC_DMAC_FLOW_D_P2P		3
#define	LPC_DMAC_FLOW_DP_P2P		4
#define	LPC_DMAC_FLOW_P_M2P		5
#define	LPC_DMAC_FLOW_P_P2M		6
#define	LPC_DMAC_FLOW_SP_P2P		7

/* DMA peripheral ID's */
#define	LPC_DMAC_I2S0_DMA0_ID		0
#define	LPC_DMAC_NAND_ID		1
#define	LPC_DMAC_IS21_DMA0_ID		2
#define	LPC_DMAC_SSP1_ID		3
#define	LPC_DMAC_SPI2_ID		3
#define	LPC_DMAC_SD_ID			4
#define	LPC_DMAC_UART1_TX_ID		5
#define	LPC_DMAC_UART1_RX_ID		6
#define	LPC_DMAC_UART2_TX_ID		7
#define	LPC_DMAC_UART2_RX_ID		8
#define	LPC_DMAC_UART7_TX_ID		9
#define	LPC_DMAC_UART7_RX_ID		10
#define	LPC_DMAC_I2S1_DMA1_ID		10
#define	LPC_DMAC_SPI1_ID		11
#define	LPC_DMAC_SSP1_TX_ID		11
#define	LPC_DMAC_NAND2_ID		12
#define	LPC_DMAC_I2S0_DMA1_ID		13
#define	LPC_DMAC_SSP0_RX		14
#define	LPC_DMAC_SSP0_TX		15

#endif	/* _ARM_LPC_LPCREG_H */
OpenPOWER on IntegriCloud