aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /arch/arm/mach-at91
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'arch/arm/mach-at91')
-rw-r--r--arch/arm/mach-at91/Kconfig234
-rw-r--r--arch/arm/mach-at91/Makefile40
-rw-r--r--arch/arm/mach-at91/Makefile.boot10
-rw-r--r--arch/arm/mach-at91/at91_aic.h99
-rw-r--r--arch/arm/mach-at91/at91_rstc.h53
-rw-r--r--arch/arm/mach-at91/at91_shdwc.h50
-rw-r--r--arch/arm/mach-at91/at91_tc.h146
-rw-r--r--arch/arm/mach-at91/at91rm9200.c102
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c272
-rw-r--r--arch/arm/mach-at91/at91rm9200_time.c108
-rw-r--r--arch/arm/mach-at91/at91sam9260.c112
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c409
-rw-r--r--arch/arm/mach-at91/at91sam9261.c99
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c244
-rw-r--r--arch/arm/mach-at91/at91sam9263.c104
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c439
-rw-r--r--arch/arm/mach-at91/at91sam926x_time.c118
-rw-r--r--arch/arm/mach-at91/at91sam9_alt_reset.S24
-rw-r--r--arch/arm/mach-at91/at91sam9g45.c136
-rw-r--r--arch/arm/mach-at91/at91sam9g45_devices.c618
-rw-r--r--arch/arm/mach-at91/at91sam9g45_reset.S37
-rw-r--r--arch/arm/mach-at91/at91sam9n12.c233
-rw-r--r--arch/arm/mach-at91/at91sam9rl.c71
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c248
-rw-r--r--arch/arm/mach-at91/at91sam9x5.c326
-rw-r--r--arch/arm/mach-at91/at91x40.c18
-rw-r--r--arch/arm/mach-at91/at91x40_time.c31
-rw-r--r--arch/arm/mach-at91/board-1arm.c34
-rw-r--r--arch/arm/mach-at91/board-afeb-9260v1.c67
-rw-r--r--arch/arm/mach-at91/board-cam60.c32
-rw-r--r--arch/arm/mach-at91/board-carmeva.c45
-rw-r--r--arch/arm/mach-at91/board-cpu9krea.c91
-rw-r--r--arch/arm/mach-at91/board-cpuat91.c63
-rw-r--r--arch/arm/mach-at91/board-csb337.c38
-rw-r--r--arch/arm/mach-at91/board-csb637.c18
-rw-r--r--arch/arm/mach-at91/board-dt.c59
-rw-r--r--arch/arm/mach-at91/board-eb01.c5
-rw-r--r--arch/arm/mach-at91/board-eb9200.c50
-rw-r--r--arch/arm/mach-at91/board-ecbat91.c53
-rw-r--r--arch/arm/mach-at91/board-eco920.c55
-rw-r--r--arch/arm/mach-at91/board-flexibity.c41
-rw-r--r--arch/arm/mach-at91/board-foxg20.c94
-rw-r--r--arch/arm/mach-at91/board-gsia18s.c78
-rw-r--r--arch/arm/mach-at91/board-kafa.c41
-rw-r--r--arch/arm/mach-at91/board-kb9202.c84
-rw-r--r--arch/arm/mach-at91/board-neocore926.c52
-rw-r--r--arch/arm/mach-at91/board-pcontrol-g20.c35
-rw-r--r--arch/arm/mach-at91/board-picotux200.c42
-rw-r--r--arch/arm/mach-at91/board-qil-a9260.c76
-rw-r--r--arch/arm/mach-at91/board-rm9200-dt.c57
-rw-r--r--arch/arm/mach-at91/board-rm9200dk.c60
-rw-r--r--arch/arm/mach-at91/board-rm9200ek.c47
-rw-r--r--arch/arm/mach-at91/board-rsi-ews.c231
-rw-r--r--arch/arm/mach-at91/board-sam9-l9260.c89
-rw-r--r--arch/arm/mach-at91/board-sam9260ek.c69
-rw-r--r--arch/arm/mach-at91/board-sam9261ek.c57
-rw-r--r--arch/arm/mach-at91/board-sam9263ek.c59
-rw-r--r--arch/arm/mach-at91/board-sam9g20ek.c92
-rw-r--r--arch/arm/mach-at91/board-sam9m10g45ek.c136
-rw-r--r--arch/arm/mach-at91/board-sam9rlek.c52
-rw-r--r--arch/arm/mach-at91/board-snapper9260.c53
-rw-r--r--arch/arm/mach-at91/board-stamp9g20.c94
-rw-r--r--arch/arm/mach-at91/board-usb-a926x.c384
-rw-r--r--arch/arm/mach-at91/board-yl-9200.c72
-rw-r--r--arch/arm/mach-at91/board.h131
-rw-r--r--arch/arm/mach-at91/clock.c244
-rw-r--r--arch/arm/mach-at91/cpuidle.c74
-rw-r--r--arch/arm/mach-at91/generic.h48
-rw-r--r--arch/arm/mach-at91/gpio.c507
-rw-r--r--arch/arm/mach-at91/gsia18s.h33
-rw-r--r--arch/arm/mach-at91/include/mach/at91_dbgu.h2
-rw-r--r--arch/arm/mach-at91/include/mach/at91_matrix.h23
-rw-r--r--arch/arm/mach-at91/include/mach/at91_pio.h25
-rw-r--r--arch/arm/mach-at91/include/mach/at91_pmc.h118
-rw-r--r--arch/arm/mach-at91/include/mach/at91_ramc.h32
-rw-r--r--arch/arm/mach-at91/include/mach/at91_st.h32
-rw-r--r--arch/arm/mach-at91/include/mach/at91rm9200.h27
-rw-r--r--arch/arm/mach-at91/include/mach/at91rm9200_mc.h58
-rw-r--r--arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h63
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9260.h44
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9260_matrix.h36
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9261.h34
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9261_matrix.h18
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9263.h49
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9263_matrix.h74
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h26
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9_sdramc.h6
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9_smc.h46
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9g45.h51
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h84
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9n12.h60
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h53
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9rl.h41
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h42
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9x5.h66
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h53
-rw-r--r--arch/arm/mach-at91/include/mach/at91x40.h19
-rw-r--r--arch/arm/mach-at91/include/mach/atmel-mci.h9
-rw-r--r--arch/arm/mach-at91/include/mach/cpu.h53
-rw-r--r--arch/arm/mach-at91/include/mach/debug-macro.S12
-rw-r--r--arch/arm/mach-at91/include/mach/gpio.h354
-rw-r--r--arch/arm/mach-at91/include/mach/hardware.h40
-rw-r--r--arch/arm/mach-at91/include/mach/io.h32
-rw-r--r--arch/arm/mach-at91/include/mach/system_rev.h4
-rw-r--r--arch/arm/mach-at91/include/mach/timex.h60
-rw-r--r--arch/arm/mach-at91/include/mach/uncompress.h177
-rw-r--r--arch/arm/mach-at91/irq.c511
-rw-r--r--arch/arm/mach-at91/leds.c109
-rw-r--r--arch/arm/mach-at91/pm.c77
-rw-r--r--arch/arm/mach-at91/pm.h101
-rw-r--r--arch/arm/mach-at91/pm_slowclock.S278
-rw-r--r--arch/arm/mach-at91/sam9_smc.c128
-rw-r--r--arch/arm/mach-at91/sam9_smc.h24
-rw-r--r--arch/arm/mach-at91/setup.c281
-rw-r--r--arch/arm/mach-at91/soc.h37
-rw-r--r--arch/arm/mach-at91/stamp9g20.h7
116 files changed, 3618 insertions, 7981 deletions
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 958358c91af..22484670e7b 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -3,140 +3,88 @@ if ARCH_AT91
3config HAVE_AT91_DATAFLASH_CARD 3config HAVE_AT91_DATAFLASH_CARD
4 bool 4 bool
5 5
6config HAVE_AT91_DBGU0 6config HAVE_AT91_USART3
7 bool 7 bool
8 8
9config HAVE_AT91_DBGU1 9config HAVE_AT91_USART4
10 bool 10 bool
11 11
12config AT91_SAM9_ALT_RESET 12config HAVE_AT91_USART5
13 bool 13 bool
14 default !ARCH_AT91X40
15
16config AT91_SAM9G45_RESET
17 bool
18 default !ARCH_AT91X40
19
20config SOC_AT91SAM9
21 bool
22 select CPU_ARM926T
23 select GENERIC_CLOCKEVENTS
24 select MULTI_IRQ_HANDLER
25 select SPARSE_IRQ
26 14
27menu "Atmel AT91 System-on-Chip" 15menu "Atmel AT91 System-on-Chip"
28 16
29comment "Atmel AT91 Processor"
30
31config SOC_AT91RM9200
32 bool "AT91RM9200"
33 select CPU_ARM920T
34 select GENERIC_CLOCKEVENTS
35 select HAVE_AT91_DBGU0
36 select MULTI_IRQ_HANDLER
37 select SPARSE_IRQ
38
39config SOC_AT91SAM9260
40 bool "AT91SAM9260, AT91SAM9XE or AT91SAM9G20"
41 select HAVE_AT91_DBGU0
42 select SOC_AT91SAM9
43 help
44 Select this if you are using one of Atmel's AT91SAM9260, AT91SAM9XE
45 or AT91SAM9G20 SoC.
46
47config SOC_AT91SAM9261
48 bool "AT91SAM9261 or AT91SAM9G10"
49 select HAVE_AT91_DBGU0
50 select HAVE_FB_ATMEL
51 select SOC_AT91SAM9
52 help
53 Select this if you are using one of Atmel's AT91SAM9261 or AT91SAM9G10 SoC.
54
55config SOC_AT91SAM9263
56 bool "AT91SAM9263"
57 select HAVE_AT91_DBGU1
58 select HAVE_FB_ATMEL
59 select SOC_AT91SAM9
60
61config SOC_AT91SAM9RL
62 bool "AT91SAM9RL"
63 select HAVE_AT91_DBGU0
64 select HAVE_FB_ATMEL
65 select SOC_AT91SAM9
66
67config SOC_AT91SAM9G45
68 bool "AT91SAM9G45 or AT91SAM9M10 families"
69 select HAVE_AT91_DBGU1
70 select HAVE_FB_ATMEL
71 select SOC_AT91SAM9
72 help
73 Select this if you are using one of Atmel's AT91SAM9G45 family SoC.
74 This support covers AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and AT91SAM9M11.
75
76config SOC_AT91SAM9X5
77 bool "AT91SAM9x5 family"
78 select HAVE_AT91_DBGU0
79 select HAVE_FB_ATMEL
80 select SOC_AT91SAM9
81 help
82 Select this if you are using one of Atmel's AT91SAM9x5 family SoC.
83 This means that your SAM9 name finishes with a '5' (except if it is
84 AT91SAM9G45!).
85 This support covers AT91SAM9G15, AT91SAM9G25, AT91SAM9X25, AT91SAM9G35
86 and AT91SAM9X35.
87
88config SOC_AT91SAM9N12
89 bool "AT91SAM9N12 family"
90 select HAVE_AT91_DBGU0
91 select HAVE_FB_ATMEL
92 select SOC_AT91SAM9
93 help
94 Select this if you are using Atmel's AT91SAM9N12 SoC.
95
96choice 17choice
97 prompt "Atmel AT91 Processor Devices for non DT boards" 18 prompt "Atmel AT91 Processor"
98
99config ARCH_AT91_NONE
100 bool "None"
101 19
102config ARCH_AT91RM9200 20config ARCH_AT91RM9200
103 bool "AT91RM9200" 21 bool "AT91RM9200"
104 select SOC_AT91RM9200 22 select CPU_ARM920T
23 select GENERIC_CLOCKEVENTS
24 select HAVE_AT91_USART3
105 25
106config ARCH_AT91SAM9260 26config ARCH_AT91SAM9260
107 bool "AT91SAM9260 or AT91SAM9XE" 27 bool "AT91SAM9260 or AT91SAM9XE"
108 select SOC_AT91SAM9260 28 select CPU_ARM926T
29 select GENERIC_CLOCKEVENTS
30 select HAVE_AT91_USART3
31 select HAVE_AT91_USART4
32 select HAVE_AT91_USART5
33 select HAVE_NET_MACB
109 34
110config ARCH_AT91SAM9261 35config ARCH_AT91SAM9261
111 bool "AT91SAM9261" 36 bool "AT91SAM9261"
112 select SOC_AT91SAM9261 37 select CPU_ARM926T
38 select GENERIC_CLOCKEVENTS
39 select HAVE_FB_ATMEL
113 40
114config ARCH_AT91SAM9G10 41config ARCH_AT91SAM9G10
115 bool "AT91SAM9G10" 42 bool "AT91SAM9G10"
116 select SOC_AT91SAM9261 43 select CPU_ARM926T
44 select GENERIC_CLOCKEVENTS
45 select HAVE_FB_ATMEL
117 46
118config ARCH_AT91SAM9263 47config ARCH_AT91SAM9263
119 bool "AT91SAM9263" 48 bool "AT91SAM9263"
120 select SOC_AT91SAM9263 49 select CPU_ARM926T
50 select GENERIC_CLOCKEVENTS
51 select HAVE_FB_ATMEL
52 select HAVE_NET_MACB
121 53
122config ARCH_AT91SAM9RL 54config ARCH_AT91SAM9RL
123 bool "AT91SAM9RL" 55 bool "AT91SAM9RL"
124 select SOC_AT91SAM9RL 56 select CPU_ARM926T
57 select GENERIC_CLOCKEVENTS
58 select HAVE_AT91_USART3
59 select HAVE_FB_ATMEL
125 60
126config ARCH_AT91SAM9G20 61config ARCH_AT91SAM9G20
127 bool "AT91SAM9G20" 62 bool "AT91SAM9G20"
128 select SOC_AT91SAM9260 63 select CPU_ARM926T
64 select GENERIC_CLOCKEVENTS
65 select HAVE_AT91_USART3
66 select HAVE_AT91_USART4
67 select HAVE_AT91_USART5
68 select HAVE_NET_MACB
129 69
130config ARCH_AT91SAM9G45 70config ARCH_AT91SAM9G45
131 bool "AT91SAM9G45" 71 bool "AT91SAM9G45"
132 select SOC_AT91SAM9G45 72 select CPU_ARM926T
73 select GENERIC_CLOCKEVENTS
74 select HAVE_AT91_USART3
75 select HAVE_FB_ATMEL
76 select HAVE_NET_MACB
77
78config ARCH_AT91CAP9
79 bool "AT91CAP9"
80 select CPU_ARM926T
81 select GENERIC_CLOCKEVENTS
82 select HAVE_FB_ATMEL
83 select HAVE_NET_MACB
133 84
134config ARCH_AT91X40 85config ARCH_AT91X40
135 bool "AT91x40" 86 bool "AT91x40"
136 depends on !MMU
137 select ARCH_USES_GETTIMEOFFSET 87 select ARCH_USES_GETTIMEOFFSET
138 select MULTI_IRQ_HANDLER
139 select SPARSE_IRQ
140 88
141endchoice 89endchoice
142 90
@@ -234,11 +182,6 @@ config MACH_ECO920
234 help 182 help
235 Select this if you are using the eco920 board 183 Select this if you are using the eco920 board
236 184
237config MACH_RSI_EWS
238 bool "RSI Embedded Webserver"
239 depends on ARCH_AT91RM9200
240 help
241 Select this if you are using RSIs EWS board.
242endif 185endif
243 186
244# ---------------------------------------------------------- 187# ----------------------------------------------------------
@@ -247,6 +190,12 @@ if ARCH_AT91SAM9260
247 190
248comment "AT91SAM9260 Variants" 191comment "AT91SAM9260 Variants"
249 192
193config ARCH_AT91SAM9260_SAM9XE
194 bool "AT91SAM9XE"
195 help
196 Select this if you are using Atmel's AT91SAM9XE System-on-Chip.
197 They are basically AT91SAM9260s with various sizes of embedded Flash.
198
250comment "AT91SAM9260 / AT91SAM9XE Board Type" 199comment "AT91SAM9260 / AT91SAM9XE Board Type"
251 200
252config MACH_AT91SAM9260EK 201config MACH_AT91SAM9260EK
@@ -393,7 +342,6 @@ config MACH_AT91SAM9G20EK_2MMC
393 Select this if you are using an Atmel AT91SAM9G20-EK Evaluation Kit 342 Select this if you are using an Atmel AT91SAM9G20-EK Evaluation Kit
394 with 2 SD/MMC Slots. This is the case for AT91SAM9G20-EK rev. C and 343 with 2 SD/MMC Slots. This is the case for AT91SAM9G20-EK rev. C and
395 onwards. 344 onwards.
396 <http://www.atmel.com/tools/SAM9G20-EK.aspx>
397 345
398config MACH_CPU9G20 346config MACH_CPU9G20
399 bool "Eukrea CPU9G20 board" 347 bool "Eukrea CPU9G20 board"
@@ -433,14 +381,6 @@ config MACH_GSIA18S
433 This enables support for the GS_IA18_S board 381 This enables support for the GS_IA18_S board
434 produced by GeoSIG Ltd company. This is an internet accelerograph. 382 produced by GeoSIG Ltd company. This is an internet accelerograph.
435 <http://www.geosig.com> 383 <http://www.geosig.com>
436
437config MACH_USB_A9G20
438 bool "CALAO USB-A9G20"
439 depends on ARCH_AT91SAM9G20
440 help
441 Select this if you are using a Calao Systems USB-A9G20.
442 <http://www.calao-systems.com>
443
444endif 384endif
445 385
446if (ARCH_AT91SAM9260 || ARCH_AT91SAM9G20) 386if (ARCH_AT91SAM9260 || ARCH_AT91SAM9G20)
@@ -463,10 +403,24 @@ comment "AT91SAM9G45 Board Type"
463config MACH_AT91SAM9M10G45EK 403config MACH_AT91SAM9M10G45EK
464 bool "Atmel AT91SAM9M10G45-EK Evaluation Kits" 404 bool "Atmel AT91SAM9M10G45-EK Evaluation Kits"
465 help 405 help
466 Select this if you are using Atmel's AT91SAM9M10G45-EK Evaluation Kit. 406 Select this if you are using Atmel's AT91SAM9G45-EKES Evaluation Kit.
467 Those boards can be populated with any SoC of AT91SAM9G45 or AT91SAM9M10 407 "ES" at the end of the name means that this board is an
468 families: AT91SAM9G45, AT91SAM9G46, AT91SAM9M10 and AT91SAM9M11. 408 Engineering Sample.
469 <http://www.atmel.com/tools/SAM9M10-G45-EK.aspx> 409
410endif
411
412# ----------------------------------------------------------
413
414if ARCH_AT91CAP9
415
416comment "AT91CAP9 Board Type"
417
418config MACH_AT91CAP9ADK
419 bool "Atmel AT91CAP9A-DK Evaluation Kit"
420 select HAVE_AT91_DATAFLASH_CARD
421 help
422 Select this if you are using Atmel's AT91CAP9A-DK Evaluation Kit.
423 <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4138>
470 424
471endif 425endif
472 426
@@ -488,26 +442,6 @@ endif
488 442
489# ---------------------------------------------------------- 443# ----------------------------------------------------------
490 444
491comment "Generic Board Type"
492
493config MACH_AT91RM9200_DT
494 bool "Atmel AT91RM9200 Evaluation Kits with device-tree support"
495 depends on SOC_AT91RM9200
496 select USE_OF
497 help
498 Select this if you want to experiment device-tree with
499 an Atmel RM9200 Evaluation Kit.
500
501config MACH_AT91SAM_DT
502 bool "Atmel AT91SAM Evaluation Kits with device-tree support"
503 depends on SOC_AT91SAM9
504 select USE_OF
505 help
506 Select this if you want to experiment device-tree with
507 an Atmel Evaluation Kit.
508
509# ----------------------------------------------------------
510
511comment "AT91 Board Options" 445comment "AT91 Board Options"
512 446
513config MTD_AT91_DATAFLASH_CARD 447config MTD_AT91_DATAFLASH_CARD
@@ -555,6 +489,36 @@ config AT91_TIMER_HZ
555 system clock (of at least several MHz), rounding is less of a 489 system clock (of at least several MHz), rounding is less of a
556 problem so it can be safer to use a decimal values like 100. 490 problem so it can be safer to use a decimal values like 100.
557 491
492choice
493 prompt "Select a UART for early kernel messages"
494
495config AT91_EARLY_DBGU
496 bool "DBGU"
497
498config AT91_EARLY_USART0
499 bool "USART0"
500
501config AT91_EARLY_USART1
502 bool "USART1"
503
504config AT91_EARLY_USART2
505 bool "USART2"
506 depends on ! ARCH_AT91X40
507
508config AT91_EARLY_USART3
509 bool "USART3"
510 depends on HAVE_AT91_USART3
511
512config AT91_EARLY_USART4
513 bool "USART4"
514 depends on HAVE_AT91_USART4
515
516config AT91_EARLY_USART5
517 bool "USART5"
518 depends on HAVE_AT91_USART5
519
520endchoice
521
558endmenu 522endmenu
559 523
560endif 524endif
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index b38a1dcb79b..bf57e8b1c9d 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -8,28 +8,17 @@ obj-n :=
8obj- := 8obj- :=
9 9
10obj-$(CONFIG_AT91_PMC_UNIT) += clock.o 10obj-$(CONFIG_AT91_PMC_UNIT) += clock.o
11obj-$(CONFIG_AT91_SAM9_ALT_RESET) += at91sam9_alt_reset.o
12obj-$(CONFIG_AT91_SAM9G45_RESET) += at91sam9g45_reset.o
13obj-$(CONFIG_SOC_AT91SAM9) += at91sam926x_time.o sam9_smc.o
14 11
15# CPU-specific support 12# CPU-specific support
16obj-$(CONFIG_SOC_AT91RM9200) += at91rm9200.o at91rm9200_time.o 13obj-$(CONFIG_ARCH_AT91RM9200) += at91rm9200.o at91rm9200_time.o at91rm9200_devices.o
17obj-$(CONFIG_SOC_AT91SAM9260) += at91sam9260.o 14obj-$(CONFIG_ARCH_AT91SAM9260) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o at91sam9_alt_reset.o
18obj-$(CONFIG_SOC_AT91SAM9261) += at91sam9261.o 15obj-$(CONFIG_ARCH_AT91SAM9261) += at91sam9261.o at91sam926x_time.o at91sam9261_devices.o sam9_smc.o at91sam9_alt_reset.o
19obj-$(CONFIG_SOC_AT91SAM9263) += at91sam9263.o 16obj-$(CONFIG_ARCH_AT91SAM9G10) += at91sam9261.o at91sam926x_time.o at91sam9261_devices.o sam9_smc.o at91sam9_alt_reset.o
20obj-$(CONFIG_SOC_AT91SAM9G45) += at91sam9g45.o 17obj-$(CONFIG_ARCH_AT91SAM9263) += at91sam9263.o at91sam926x_time.o at91sam9263_devices.o sam9_smc.o at91sam9_alt_reset.o
21obj-$(CONFIG_SOC_AT91SAM9N12) += at91sam9n12.o 18obj-$(CONFIG_ARCH_AT91SAM9RL) += at91sam9rl.o at91sam926x_time.o at91sam9rl_devices.o sam9_smc.o at91sam9_alt_reset.o
22obj-$(CONFIG_SOC_AT91SAM9X5) += at91sam9x5.o 19obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o at91sam9_alt_reset.o
23obj-$(CONFIG_SOC_AT91SAM9RL) += at91sam9rl.o 20obj-$(CONFIG_ARCH_AT91SAM9G45) += at91sam9g45.o at91sam926x_time.o at91sam9g45_devices.o sam9_smc.o
24 21obj-$(CONFIG_ARCH_AT91CAP9) += at91cap9.o at91sam926x_time.o at91cap9_devices.o sam9_smc.o
25obj-$(CONFIG_ARCH_AT91RM9200) += at91rm9200_devices.o
26obj-$(CONFIG_ARCH_AT91SAM9260) += at91sam9260_devices.o
27obj-$(CONFIG_ARCH_AT91SAM9261) += at91sam9261_devices.o
28obj-$(CONFIG_ARCH_AT91SAM9G10) += at91sam9261_devices.o
29obj-$(CONFIG_ARCH_AT91SAM9263) += at91sam9263_devices.o
30obj-$(CONFIG_ARCH_AT91SAM9RL) += at91sam9rl_devices.o
31obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260_devices.o
32obj-$(CONFIG_ARCH_AT91SAM9G45) += at91sam9g45_devices.o
33obj-$(CONFIG_ARCH_AT91X40) += at91x40.o at91x40_time.o 22obj-$(CONFIG_ARCH_AT91X40) += at91x40.o at91x40_time.o
34 23
35# AT91RM9200 board-specific support 24# AT91RM9200 board-specific support
@@ -47,13 +36,12 @@ obj-$(CONFIG_MACH_ECBAT91) += board-ecbat91.o
47obj-$(CONFIG_MACH_YL9200) += board-yl-9200.o 36obj-$(CONFIG_MACH_YL9200) += board-yl-9200.o
48obj-$(CONFIG_MACH_CPUAT91) += board-cpuat91.o 37obj-$(CONFIG_MACH_CPUAT91) += board-cpuat91.o
49obj-$(CONFIG_MACH_ECO920) += board-eco920.o 38obj-$(CONFIG_MACH_ECO920) += board-eco920.o
50obj-$(CONFIG_MACH_RSI_EWS) += board-rsi-ews.o
51 39
52# AT91SAM9260 board-specific support 40# AT91SAM9260 board-specific support
53obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o 41obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
54obj-$(CONFIG_MACH_CAM60) += board-cam60.o 42obj-$(CONFIG_MACH_CAM60) += board-cam60.o
55obj-$(CONFIG_MACH_SAM9_L9260) += board-sam9-l9260.o 43obj-$(CONFIG_MACH_SAM9_L9260) += board-sam9-l9260.o
56obj-$(CONFIG_MACH_USB_A9260) += board-usb-a926x.o 44obj-$(CONFIG_MACH_USB_A9260) += board-usb-a9260.o
57obj-$(CONFIG_MACH_QIL_A9260) += board-qil-a9260.o 45obj-$(CONFIG_MACH_QIL_A9260) += board-qil-a9260.o
58obj-$(CONFIG_MACH_AFEB9260) += board-afeb-9260v1.o 46obj-$(CONFIG_MACH_AFEB9260) += board-afeb-9260v1.o
59obj-$(CONFIG_MACH_CPU9260) += board-cpu9krea.o 47obj-$(CONFIG_MACH_CPU9260) += board-cpu9krea.o
@@ -65,7 +53,7 @@ obj-$(CONFIG_MACH_AT91SAM9G10EK) += board-sam9261ek.o
65 53
66# AT91SAM9263 board-specific support 54# AT91SAM9263 board-specific support
67obj-$(CONFIG_MACH_AT91SAM9263EK) += board-sam9263ek.o 55obj-$(CONFIG_MACH_AT91SAM9263EK) += board-sam9263ek.o
68obj-$(CONFIG_MACH_USB_A9263) += board-usb-a926x.o 56obj-$(CONFIG_MACH_USB_A9263) += board-usb-a9263.o
69obj-$(CONFIG_MACH_NEOCORE926) += board-neocore926.o 57obj-$(CONFIG_MACH_NEOCORE926) += board-neocore926.o
70 58
71# AT91SAM9RL board-specific support 59# AT91SAM9RL board-specific support
@@ -79,7 +67,6 @@ obj-$(CONFIG_MACH_STAMP9G20) += board-stamp9g20.o
79obj-$(CONFIG_MACH_PORTUXG20) += board-stamp9g20.o 67obj-$(CONFIG_MACH_PORTUXG20) += board-stamp9g20.o
80obj-$(CONFIG_MACH_PCONTROL_G20) += board-pcontrol-g20.o board-stamp9g20.o 68obj-$(CONFIG_MACH_PCONTROL_G20) += board-pcontrol-g20.o board-stamp9g20.o
81obj-$(CONFIG_MACH_GSIA18S) += board-gsia18s.o board-stamp9g20.o 69obj-$(CONFIG_MACH_GSIA18S) += board-gsia18s.o board-stamp9g20.o
82obj-$(CONFIG_MACH_USB_A9G20) += board-usb-a926x.o
83 70
84# AT91SAM9260/AT91SAM9G20 board-specific support 71# AT91SAM9260/AT91SAM9G20 board-specific support
85obj-$(CONFIG_MACH_SNAPPER_9260) += board-snapper9260.o 72obj-$(CONFIG_MACH_SNAPPER_9260) += board-snapper9260.o
@@ -87,9 +74,8 @@ obj-$(CONFIG_MACH_SNAPPER_9260) += board-snapper9260.o
87# AT91SAM9G45 board-specific support 74# AT91SAM9G45 board-specific support
88obj-$(CONFIG_MACH_AT91SAM9M10G45EK) += board-sam9m10g45ek.o 75obj-$(CONFIG_MACH_AT91SAM9M10G45EK) += board-sam9m10g45ek.o
89 76
90# AT91SAM board with device-tree 77# AT91CAP9 board-specific support
91obj-$(CONFIG_MACH_AT91RM9200_DT) += board-rm9200-dt.o 78obj-$(CONFIG_MACH_AT91CAP9ADK) += board-cap9adk.o
92obj-$(CONFIG_MACH_AT91SAM_DT) += board-dt.o
93 79
94# AT91X40 board-specific support 80# AT91X40 board-specific support
95obj-$(CONFIG_MACH_AT91EB01) += board-eb01.o 81obj-$(CONFIG_MACH_AT91EB01) += board-eb01.o
diff --git a/arch/arm/mach-at91/Makefile.boot b/arch/arm/mach-at91/Makefile.boot
index 5309f9b6aab..3462b815054 100644
--- a/arch/arm/mach-at91/Makefile.boot
+++ b/arch/arm/mach-at91/Makefile.boot
@@ -3,12 +3,16 @@
3# PARAMS_PHYS must be within 4MB of ZRELADDR 3# PARAMS_PHYS must be within 4MB of ZRELADDR
4# INITRD_PHYS must be in RAM 4# INITRD_PHYS must be in RAM
5 5
6ifeq ($(CONFIG_ARCH_AT91SAM9G45),y) 6ifeq ($(CONFIG_ARCH_AT91CAP9),y)
7 zreladdr-y += 0x70008000 7 zreladdr-y := 0x70008000
8params_phys-y := 0x70000100
9initrd_phys-y := 0x70410000
10else ifeq ($(CONFIG_ARCH_AT91SAM9G45),y)
11 zreladdr-y := 0x70008000
8params_phys-y := 0x70000100 12params_phys-y := 0x70000100
9initrd_phys-y := 0x70410000 13initrd_phys-y := 0x70410000
10else 14else
11 zreladdr-y += 0x20008000 15 zreladdr-y := 0x20008000
12params_phys-y := 0x20000100 16params_phys-y := 0x20000100
13initrd_phys-y := 0x20410000 17initrd_phys-y := 0x20410000
14endif 18endif
diff --git a/arch/arm/mach-at91/at91_aic.h b/arch/arm/mach-at91/at91_aic.h
deleted file mode 100644
index eaea66197fa..00000000000
--- a/arch/arm/mach-at91/at91_aic.h
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91_aic.h
3 *
4 * Copyright (C) 2005 Ivan Kokshaysky
5 * Copyright (C) SAN People
6 *
7 * Advanced Interrupt Controller (AIC) - System peripherals registers.
8 * Based on AT91RM9200 datasheet revision E.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#ifndef AT91_AIC_H
17#define AT91_AIC_H
18
19#ifndef __ASSEMBLY__
20extern void __iomem *at91_aic_base;
21
22#define at91_aic_read(field) \
23 __raw_readl(at91_aic_base + field)
24
25#define at91_aic_write(field, value) \
26 __raw_writel(value, at91_aic_base + field)
27#else
28.extern at91_aic_base
29#endif
30
31/* Number of irq lines managed by AIC */
32#define NR_AIC_IRQS 32
33#define NR_AIC5_IRQS 128
34
35#define AT91_AIC5_SSR 0x0 /* Source Select Register [AIC5] */
36#define AT91_AIC5_INTSEL_MSK (0x7f << 0) /* Interrupt Line Selection Mask */
37
38#define AT91_AIC_IRQ_MIN_PRIORITY 0
39#define AT91_AIC_IRQ_MAX_PRIORITY 7
40
41#define AT91_AIC_SMR(n) ((n) * 4) /* Source Mode Registers 0-31 */
42#define AT91_AIC5_SMR 0x4 /* Source Mode Register [AIC5] */
43#define AT91_AIC_PRIOR (7 << 0) /* Priority Level */
44#define AT91_AIC_SRCTYPE (3 << 5) /* Interrupt Source Type */
45#define AT91_AIC_SRCTYPE_LOW (0 << 5)
46#define AT91_AIC_SRCTYPE_FALLING (1 << 5)
47#define AT91_AIC_SRCTYPE_HIGH (2 << 5)
48#define AT91_AIC_SRCTYPE_RISING (3 << 5)
49
50#define AT91_AIC_SVR(n) (0x80 + ((n) * 4)) /* Source Vector Registers 0-31 */
51#define AT91_AIC5_SVR 0x8 /* Source Vector Register [AIC5] */
52#define AT91_AIC_IVR 0x100 /* Interrupt Vector Register */
53#define AT91_AIC5_IVR 0x10 /* Interrupt Vector Register [AIC5] */
54#define AT91_AIC_FVR 0x104 /* Fast Interrupt Vector Register */
55#define AT91_AIC5_FVR 0x14 /* Fast Interrupt Vector Register [AIC5] */
56#define AT91_AIC_ISR 0x108 /* Interrupt Status Register */
57#define AT91_AIC5_ISR 0x18 /* Interrupt Status Register [AIC5] */
58#define AT91_AIC_IRQID (0x1f << 0) /* Current Interrupt Identifier */
59
60#define AT91_AIC_IPR 0x10c /* Interrupt Pending Register */
61#define AT91_AIC5_IPR0 0x20 /* Interrupt Pending Register 0 [AIC5] */
62#define AT91_AIC5_IPR1 0x24 /* Interrupt Pending Register 1 [AIC5] */
63#define AT91_AIC5_IPR2 0x28 /* Interrupt Pending Register 2 [AIC5] */
64#define AT91_AIC5_IPR3 0x2c /* Interrupt Pending Register 3 [AIC5] */
65#define AT91_AIC_IMR 0x110 /* Interrupt Mask Register */
66#define AT91_AIC5_IMR 0x30 /* Interrupt Mask Register [AIC5] */
67#define AT91_AIC_CISR 0x114 /* Core Interrupt Status Register */
68#define AT91_AIC5_CISR 0x34 /* Core Interrupt Status Register [AIC5] */
69#define AT91_AIC_NFIQ (1 << 0) /* nFIQ Status */
70#define AT91_AIC_NIRQ (1 << 1) /* nIRQ Status */
71
72#define AT91_AIC_IECR 0x120 /* Interrupt Enable Command Register */
73#define AT91_AIC5_IECR 0x40 /* Interrupt Enable Command Register [AIC5] */
74#define AT91_AIC_IDCR 0x124 /* Interrupt Disable Command Register */
75#define AT91_AIC5_IDCR 0x44 /* Interrupt Disable Command Register [AIC5] */
76#define AT91_AIC_ICCR 0x128 /* Interrupt Clear Command Register */
77#define AT91_AIC5_ICCR 0x48 /* Interrupt Clear Command Register [AIC5] */
78#define AT91_AIC_ISCR 0x12c /* Interrupt Set Command Register */
79#define AT91_AIC5_ISCR 0x4c /* Interrupt Set Command Register [AIC5] */
80#define AT91_AIC_EOICR 0x130 /* End of Interrupt Command Register */
81#define AT91_AIC5_EOICR 0x38 /* End of Interrupt Command Register [AIC5] */
82#define AT91_AIC_SPU 0x134 /* Spurious Interrupt Vector Register */
83#define AT91_AIC5_SPU 0x3c /* Spurious Interrupt Vector Register [AIC5] */
84#define AT91_AIC_DCR 0x138 /* Debug Control Register */
85#define AT91_AIC5_DCR 0x6c /* Debug Control Register [AIC5] */
86#define AT91_AIC_DCR_PROT (1 << 0) /* Protection Mode */
87#define AT91_AIC_DCR_GMSK (1 << 1) /* General Mask */
88
89#define AT91_AIC_FFER 0x140 /* Fast Forcing Enable Register [SAM9 only] */
90#define AT91_AIC5_FFER 0x50 /* Fast Forcing Enable Register [AIC5] */
91#define AT91_AIC_FFDR 0x144 /* Fast Forcing Disable Register [SAM9 only] */
92#define AT91_AIC5_FFDR 0x54 /* Fast Forcing Disable Register [AIC5] */
93#define AT91_AIC_FFSR 0x148 /* Fast Forcing Status Register [SAM9 only] */
94#define AT91_AIC5_FFSR 0x58 /* Fast Forcing Status Register [AIC5] */
95
96void at91_aic_handle_irq(struct pt_regs *regs);
97void at91_aic5_handle_irq(struct pt_regs *regs);
98
99#endif
diff --git a/arch/arm/mach-at91/at91_rstc.h b/arch/arm/mach-at91/at91_rstc.h
deleted file mode 100644
index 875fa336800..00000000000
--- a/arch/arm/mach-at91/at91_rstc.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91_rstc.h
3 *
4 * Copyright (C) 2007 Andrew Victor
5 * Copyright (C) 2007 Atmel Corporation.
6 *
7 * Reset Controller (RSTC) - System peripherals regsters.
8 * Based on AT91SAM9261 datasheet revision D.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#ifndef AT91_RSTC_H
17#define AT91_RSTC_H
18
19#ifndef __ASSEMBLY__
20extern void __iomem *at91_rstc_base;
21
22#define at91_rstc_read(field) \
23 __raw_readl(at91_rstc_base + field)
24
25#define at91_rstc_write(field, value) \
26 __raw_writel(value, at91_rstc_base + field);
27#else
28.extern at91_rstc_base
29#endif
30
31#define AT91_RSTC_CR 0x00 /* Reset Controller Control Register */
32#define AT91_RSTC_PROCRST (1 << 0) /* Processor Reset */
33#define AT91_RSTC_PERRST (1 << 2) /* Peripheral Reset */
34#define AT91_RSTC_EXTRST (1 << 3) /* External Reset */
35#define AT91_RSTC_KEY (0xa5 << 24) /* KEY Password */
36
37#define AT91_RSTC_SR 0x04 /* Reset Controller Status Register */
38#define AT91_RSTC_URSTS (1 << 0) /* User Reset Status */
39#define AT91_RSTC_RSTTYP (7 << 8) /* Reset Type */
40#define AT91_RSTC_RSTTYP_GENERAL (0 << 8)
41#define AT91_RSTC_RSTTYP_WAKEUP (1 << 8)
42#define AT91_RSTC_RSTTYP_WATCHDOG (2 << 8)
43#define AT91_RSTC_RSTTYP_SOFTWARE (3 << 8)
44#define AT91_RSTC_RSTTYP_USER (4 << 8)
45#define AT91_RSTC_NRSTL (1 << 16) /* NRST Pin Level */
46#define AT91_RSTC_SRCMP (1 << 17) /* Software Reset Command in Progress */
47
48#define AT91_RSTC_MR 0x08 /* Reset Controller Mode Register */
49#define AT91_RSTC_URSTEN (1 << 0) /* User Reset Enable */
50#define AT91_RSTC_URSTIEN (1 << 4) /* User Reset Interrupt Enable */
51#define AT91_RSTC_ERSTL (0xf << 8) /* External Reset Length */
52
53#endif
diff --git a/arch/arm/mach-at91/at91_shdwc.h b/arch/arm/mach-at91/at91_shdwc.h
deleted file mode 100644
index 60478ea8bd4..00000000000
--- a/arch/arm/mach-at91/at91_shdwc.h
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91_shdwc.h
3 *
4 * Copyright (C) 2007 Andrew Victor
5 * Copyright (C) 2007 Atmel Corporation.
6 *
7 * Shutdown Controller (SHDWC) - System peripherals regsters.
8 * Based on AT91SAM9261 datasheet revision D.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#ifndef AT91_SHDWC_H
17#define AT91_SHDWC_H
18
19#ifndef __ASSEMBLY__
20extern void __iomem *at91_shdwc_base;
21
22#define at91_shdwc_read(field) \
23 __raw_readl(at91_shdwc_base + field)
24
25#define at91_shdwc_write(field, value) \
26 __raw_writel(value, at91_shdwc_base + field);
27#endif
28
29#define AT91_SHDW_CR 0x00 /* Shut Down Control Register */
30#define AT91_SHDW_SHDW (1 << 0) /* Shut Down command */
31#define AT91_SHDW_KEY (0xa5 << 24) /* KEY Password */
32
33#define AT91_SHDW_MR 0x04 /* Shut Down Mode Register */
34#define AT91_SHDW_WKMODE0 (3 << 0) /* Wake-up 0 Mode Selection */
35#define AT91_SHDW_WKMODE0_NONE 0
36#define AT91_SHDW_WKMODE0_HIGH 1
37#define AT91_SHDW_WKMODE0_LOW 2
38#define AT91_SHDW_WKMODE0_ANYLEVEL 3
39#define AT91_SHDW_CPTWK0_MAX 0xf /* Maximum Counter On Wake Up 0 */
40#define AT91_SHDW_CPTWK0 (AT91_SHDW_CPTWK0_MAX << 4) /* Counter On Wake Up 0 */
41#define AT91_SHDW_CPTWK0_(x) ((x) << 4)
42#define AT91_SHDW_RTTWKEN (1 << 16) /* Real Time Timer Wake-up Enable */
43#define AT91_SHDW_RTCWKEN (1 << 17) /* Real Time Clock Wake-up Enable */
44
45#define AT91_SHDW_SR 0x08 /* Shut Down Status Register */
46#define AT91_SHDW_WAKEUP0 (1 << 0) /* Wake-up 0 Status */
47#define AT91_SHDW_RTTWK (1 << 16) /* Real-time Timer Wake-up */
48#define AT91_SHDW_RTCWK (1 << 17) /* Real-time Clock Wake-up [SAM9RL] */
49
50#endif
diff --git a/arch/arm/mach-at91/at91_tc.h b/arch/arm/mach-at91/at91_tc.h
deleted file mode 100644
index 46a317fd716..00000000000
--- a/arch/arm/mach-at91/at91_tc.h
+++ /dev/null
@@ -1,146 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91_tc.h
3 *
4 * Copyright (C) SAN People
5 *
6 * Timer/Counter Unit (TC) registers.
7 * Based on AT91RM9200 datasheet revision E.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */
14
15#ifndef AT91_TC_H
16#define AT91_TC_H
17
18#define AT91_TC_BCR 0xc0 /* TC Block Control Register */
19#define AT91_TC_SYNC (1 << 0) /* Synchro Command */
20
21#define AT91_TC_BMR 0xc4 /* TC Block Mode Register */
22#define AT91_TC_TC0XC0S (3 << 0) /* External Clock Signal 0 Selection */
23#define AT91_TC_TC0XC0S_TCLK0 (0 << 0)
24#define AT91_TC_TC0XC0S_NONE (1 << 0)
25#define AT91_TC_TC0XC0S_TIOA1 (2 << 0)
26#define AT91_TC_TC0XC0S_TIOA2 (3 << 0)
27#define AT91_TC_TC1XC1S (3 << 2) /* External Clock Signal 1 Selection */
28#define AT91_TC_TC1XC1S_TCLK1 (0 << 2)
29#define AT91_TC_TC1XC1S_NONE (1 << 2)
30#define AT91_TC_TC1XC1S_TIOA0 (2 << 2)
31#define AT91_TC_TC1XC1S_TIOA2 (3 << 2)
32#define AT91_TC_TC2XC2S (3 << 4) /* External Clock Signal 2 Selection */
33#define AT91_TC_TC2XC2S_TCLK2 (0 << 4)
34#define AT91_TC_TC2XC2S_NONE (1 << 4)
35#define AT91_TC_TC2XC2S_TIOA0 (2 << 4)
36#define AT91_TC_TC2XC2S_TIOA1 (3 << 4)
37
38
39#define AT91_TC_CCR 0x00 /* Channel Control Register */
40#define AT91_TC_CLKEN (1 << 0) /* Counter Clock Enable Command */
41#define AT91_TC_CLKDIS (1 << 1) /* Counter CLock Disable Command */
42#define AT91_TC_SWTRG (1 << 2) /* Software Trigger Command */
43
44#define AT91_TC_CMR 0x04 /* Channel Mode Register */
45#define AT91_TC_TCCLKS (7 << 0) /* Capture/Waveform Mode: Clock Selection */
46#define AT91_TC_TIMER_CLOCK1 (0 << 0)
47#define AT91_TC_TIMER_CLOCK2 (1 << 0)
48#define AT91_TC_TIMER_CLOCK3 (2 << 0)
49#define AT91_TC_TIMER_CLOCK4 (3 << 0)
50#define AT91_TC_TIMER_CLOCK5 (4 << 0)
51#define AT91_TC_XC0 (5 << 0)
52#define AT91_TC_XC1 (6 << 0)
53#define AT91_TC_XC2 (7 << 0)
54#define AT91_TC_CLKI (1 << 3) /* Capture/Waveform Mode: Clock Invert */
55#define AT91_TC_BURST (3 << 4) /* Capture/Waveform Mode: Burst Signal Selection */
56#define AT91_TC_LDBSTOP (1 << 6) /* Capture Mode: Counter Clock Stopped with TB Loading */
57#define AT91_TC_LDBDIS (1 << 7) /* Capture Mode: Counter Clock Disable with RB Loading */
58#define AT91_TC_ETRGEDG (3 << 8) /* Capture Mode: External Trigger Edge Selection */
59#define AT91_TC_ABETRG (1 << 10) /* Capture Mode: TIOA or TIOB External Trigger Selection */
60#define AT91_TC_CPCTRG (1 << 14) /* Capture Mode: RC Compare Trigger Enable */
61#define AT91_TC_WAVE (1 << 15) /* Capture/Waveform mode */
62#define AT91_TC_LDRA (3 << 16) /* Capture Mode: RA Loading Selection */
63#define AT91_TC_LDRB (3 << 18) /* Capture Mode: RB Loading Selection */
64
65#define AT91_TC_CPCSTOP (1 << 6) /* Waveform Mode: Counter Clock Stopped with RC Compare */
66#define AT91_TC_CPCDIS (1 << 7) /* Waveform Mode: Counter Clock Disable with RC Compare */
67#define AT91_TC_EEVTEDG (3 << 8) /* Waveform Mode: External Event Edge Selection */
68#define AT91_TC_EEVTEDG_NONE (0 << 8)
69#define AT91_TC_EEVTEDG_RISING (1 << 8)
70#define AT91_TC_EEVTEDG_FALLING (2 << 8)
71#define AT91_TC_EEVTEDG_BOTH (3 << 8)
72#define AT91_TC_EEVT (3 << 10) /* Waveform Mode: External Event Selection */
73#define AT91_TC_EEVT_TIOB (0 << 10)
74#define AT91_TC_EEVT_XC0 (1 << 10)
75#define AT91_TC_EEVT_XC1 (2 << 10)
76#define AT91_TC_EEVT_XC2 (3 << 10)
77#define AT91_TC_ENETRG (1 << 12) /* Waveform Mode: External Event Trigger Enable */
78#define AT91_TC_WAVESEL (3 << 13) /* Waveform Mode: Waveform Selection */
79#define AT91_TC_WAVESEL_UP (0 << 13)
80#define AT91_TC_WAVESEL_UP_AUTO (2 << 13)
81#define AT91_TC_WAVESEL_UPDOWN (1 << 13)
82#define AT91_TC_WAVESEL_UPDOWN_AUTO (3 << 13)
83#define AT91_TC_ACPA (3 << 16) /* Waveform Mode: RA Compare Effect on TIOA */
84#define AT91_TC_ACPA_NONE (0 << 16)
85#define AT91_TC_ACPA_SET (1 << 16)
86#define AT91_TC_ACPA_CLEAR (2 << 16)
87#define AT91_TC_ACPA_TOGGLE (3 << 16)
88#define AT91_TC_ACPC (3 << 18) /* Waveform Mode: RC Compre Effect on TIOA */
89#define AT91_TC_ACPC_NONE (0 << 18)
90#define AT91_TC_ACPC_SET (1 << 18)
91#define AT91_TC_ACPC_CLEAR (2 << 18)
92#define AT91_TC_ACPC_TOGGLE (3 << 18)
93#define AT91_TC_AEEVT (3 << 20) /* Waveform Mode: External Event Effect on TIOA */
94#define AT91_TC_AEEVT_NONE (0 << 20)
95#define AT91_TC_AEEVT_SET (1 << 20)
96#define AT91_TC_AEEVT_CLEAR (2 << 20)
97#define AT91_TC_AEEVT_TOGGLE (3 << 20)
98#define AT91_TC_ASWTRG (3 << 22) /* Waveform Mode: Software Trigger Effect on TIOA */
99#define AT91_TC_ASWTRG_NONE (0 << 22)
100#define AT91_TC_ASWTRG_SET (1 << 22)
101#define AT91_TC_ASWTRG_CLEAR (2 << 22)
102#define AT91_TC_ASWTRG_TOGGLE (3 << 22)
103#define AT91_TC_BCPB (3 << 24) /* Waveform Mode: RB Compare Effect on TIOB */
104#define AT91_TC_BCPB_NONE (0 << 24)
105#define AT91_TC_BCPB_SET (1 << 24)
106#define AT91_TC_BCPB_CLEAR (2 << 24)
107#define AT91_TC_BCPB_TOGGLE (3 << 24)
108#define AT91_TC_BCPC (3 << 26) /* Waveform Mode: RC Compare Effect on TIOB */
109#define AT91_TC_BCPC_NONE (0 << 26)
110#define AT91_TC_BCPC_SET (1 << 26)
111#define AT91_TC_BCPC_CLEAR (2 << 26)
112#define AT91_TC_BCPC_TOGGLE (3 << 26)
113#define AT91_TC_BEEVT (3 << 28) /* Waveform Mode: External Event Effect on TIOB */
114#define AT91_TC_BEEVT_NONE (0 << 28)
115#define AT91_TC_BEEVT_SET (1 << 28)
116#define AT91_TC_BEEVT_CLEAR (2 << 28)
117#define AT91_TC_BEEVT_TOGGLE (3 << 28)
118#define AT91_TC_BSWTRG (3 << 30) /* Waveform Mode: Software Trigger Effect on TIOB */
119#define AT91_TC_BSWTRG_NONE (0 << 30)
120#define AT91_TC_BSWTRG_SET (1 << 30)
121#define AT91_TC_BSWTRG_CLEAR (2 << 30)
122#define AT91_TC_BSWTRG_TOGGLE (3 << 30)
123
124#define AT91_TC_CV 0x10 /* Counter Value */
125#define AT91_TC_RA 0x14 /* Register A */
126#define AT91_TC_RB 0x18 /* Register B */
127#define AT91_TC_RC 0x1c /* Register C */
128
129#define AT91_TC_SR 0x20 /* Status Register */
130#define AT91_TC_COVFS (1 << 0) /* Counter Overflow Status */
131#define AT91_TC_LOVRS (1 << 1) /* Load Overrun Status */
132#define AT91_TC_CPAS (1 << 2) /* RA Compare Status */
133#define AT91_TC_CPBS (1 << 3) /* RB Compare Status */
134#define AT91_TC_CPCS (1 << 4) /* RC Compare Status */
135#define AT91_TC_LDRAS (1 << 5) /* RA Loading Status */
136#define AT91_TC_LDRBS (1 << 6) /* RB Loading Status */
137#define AT91_TC_ETRGS (1 << 7) /* External Trigger Status */
138#define AT91_TC_CLKSTA (1 << 16) /* Clock Enabling Status */
139#define AT91_TC_MTIOA (1 << 17) /* TIOA Mirror */
140#define AT91_TC_MTIOB (1 << 18) /* TIOB Mirror */
141
142#define AT91_TC_IER 0x24 /* Interrupt Enable Register */
143#define AT91_TC_IDR 0x28 /* Interrupt Disable Register */
144#define AT91_TC_IMR 0x2c /* Interrupt Mask Register */
145
146#endif
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 7aeb473ee53..f73302dbc6a 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -15,17 +15,23 @@
15#include <asm/irq.h> 15#include <asm/irq.h>
16#include <asm/mach/arch.h> 16#include <asm/mach/arch.h>
17#include <asm/mach/map.h> 17#include <asm/mach/map.h>
18#include <asm/system_misc.h>
19#include <mach/at91rm9200.h> 18#include <mach/at91rm9200.h>
20#include <mach/at91_pmc.h> 19#include <mach/at91_pmc.h>
21#include <mach/at91_st.h> 20#include <mach/at91_st.h>
22#include <mach/cpu.h> 21#include <mach/cpu.h>
23 22
24#include "at91_aic.h"
25#include "soc.h" 23#include "soc.h"
26#include "generic.h" 24#include "generic.h"
27#include "clock.h" 25#include "clock.h"
28#include "sam9_smc.h" 26
27static struct map_desc at91rm9200_io_desc[] __initdata = {
28 {
29 .virtual = AT91_VA_BASE_EMAC,
30 .pfn = __phys_to_pfn(AT91RM9200_BASE_EMAC),
31 .length = SZ_16K,
32 .type = MT_DEVICE,
33 },
34};
29 35
30/* -------------------------------------------------------------------- 36/* --------------------------------------------------------------------
31 * Clocks 37 * Clocks
@@ -184,37 +190,9 @@ static struct clk_lookup periph_clocks_lookups[] = {
184 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk), 190 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk),
185 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk), 191 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk),
186 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk), 192 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk),
187 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk), 193 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
188 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk), 194 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
189 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.2", &ssc2_clk), 195 CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk),
190 CLKDEV_CON_DEV_ID("pclk", "fffd0000.ssc", &ssc0_clk),
191 CLKDEV_CON_DEV_ID("pclk", "fffd4000.ssc", &ssc1_clk),
192 CLKDEV_CON_DEV_ID("pclk", "fffd8000.ssc", &ssc2_clk),
193 CLKDEV_CON_DEV_ID(NULL, "i2c-at91rm9200.0", &twi_clk),
194 /* fake hclk clock */
195 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
196 CLKDEV_CON_ID("pioA", &pioA_clk),
197 CLKDEV_CON_ID("pioB", &pioB_clk),
198 CLKDEV_CON_ID("pioC", &pioC_clk),
199 CLKDEV_CON_ID("pioD", &pioD_clk),
200 /* usart lookup table for DT entries */
201 CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
202 CLKDEV_CON_DEV_ID("usart", "fffc0000.serial", &usart0_clk),
203 CLKDEV_CON_DEV_ID("usart", "fffc4000.serial", &usart1_clk),
204 CLKDEV_CON_DEV_ID("usart", "fffc8000.serial", &usart2_clk),
205 CLKDEV_CON_DEV_ID("usart", "fffcc000.serial", &usart3_clk),
206 /* tc lookup table for DT entries */
207 CLKDEV_CON_DEV_ID("t0_clk", "fffa0000.timer", &tc0_clk),
208 CLKDEV_CON_DEV_ID("t1_clk", "fffa0000.timer", &tc1_clk),
209 CLKDEV_CON_DEV_ID("t2_clk", "fffa0000.timer", &tc2_clk),
210 CLKDEV_CON_DEV_ID("t0_clk", "fffa4000.timer", &tc3_clk),
211 CLKDEV_CON_DEV_ID("t1_clk", "fffa4000.timer", &tc4_clk),
212 CLKDEV_CON_DEV_ID("t2_clk", "fffa4000.timer", &tc5_clk),
213 CLKDEV_CON_DEV_ID("hclk", "300000.ohci", &ohci_clk),
214 CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioA_clk),
215 CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioB_clk),
216 CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioC_clk),
217 CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioD_clk),
218}; 196};
219 197
220static struct clk_lookup usart_clocks_lookups[] = { 198static struct clk_lookup usart_clocks_lookups[] = {
@@ -272,42 +250,49 @@ static void __init at91rm9200_register_clocks(void)
272 clk_register(&pck3); 250 clk_register(&pck3);
273} 251}
274 252
253static struct clk_lookup console_clock_lookup;
254
255void __init at91rm9200_set_console_clock(int id)
256{
257 if (id >= ARRAY_SIZE(usart_clocks_lookups))
258 return;
259
260 console_clock_lookup.con_id = "usart";
261 console_clock_lookup.clk = usart_clocks_lookups[id].clk;
262 clkdev_add(&console_clock_lookup);
263}
264
275/* -------------------------------------------------------------------- 265/* --------------------------------------------------------------------
276 * GPIO 266 * GPIO
277 * -------------------------------------------------------------------- */ 267 * -------------------------------------------------------------------- */
278 268
279static struct at91_gpio_bank at91rm9200_gpio[] __initdata = { 269static struct at91_gpio_bank at91rm9200_gpio[] = {
280 { 270 {
281 .id = AT91RM9200_ID_PIOA, 271 .id = AT91RM9200_ID_PIOA,
282 .regbase = AT91RM9200_BASE_PIOA, 272 .offset = AT91_PIOA,
273 .clock = &pioA_clk,
283 }, { 274 }, {
284 .id = AT91RM9200_ID_PIOB, 275 .id = AT91RM9200_ID_PIOB,
285 .regbase = AT91RM9200_BASE_PIOB, 276 .offset = AT91_PIOB,
277 .clock = &pioB_clk,
286 }, { 278 }, {
287 .id = AT91RM9200_ID_PIOC, 279 .id = AT91RM9200_ID_PIOC,
288 .regbase = AT91RM9200_BASE_PIOC, 280 .offset = AT91_PIOC,
281 .clock = &pioC_clk,
289 }, { 282 }, {
290 .id = AT91RM9200_ID_PIOD, 283 .id = AT91RM9200_ID_PIOD,
291 .regbase = AT91RM9200_BASE_PIOD, 284 .offset = AT91_PIOD,
285 .clock = &pioD_clk,
292 } 286 }
293}; 287};
294 288
295static void at91rm9200_idle(void) 289static void at91rm9200_reset(void)
296{
297 /*
298 * Disable the processor clock. The processor will be automatically
299 * re-enabled by an interrupt or by a reset.
300 */
301 at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
302}
303
304static void at91rm9200_restart(char mode, const char *cmd)
305{ 290{
306 /* 291 /*
307 * Perform a hardware reset with the use of the Watchdog timer. 292 * Perform a hardware reset with the use of the Watchdog timer.
308 */ 293 */
309 at91_st_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1); 294 at91_sys_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1);
310 at91_st_write(AT91_ST_CR, AT91_ST_WDRST); 295 at91_sys_write(AT91_ST_CR, AT91_ST_WDRST);
311} 296}
312 297
313/* -------------------------------------------------------------------- 298/* --------------------------------------------------------------------
@@ -317,18 +302,12 @@ static void __init at91rm9200_map_io(void)
317{ 302{
318 /* Map peripherals */ 303 /* Map peripherals */
319 at91_init_sram(0, AT91RM9200_SRAM_BASE, AT91RM9200_SRAM_SIZE); 304 at91_init_sram(0, AT91RM9200_SRAM_BASE, AT91RM9200_SRAM_SIZE);
320} 305 iotable_init(at91rm9200_io_desc, ARRAY_SIZE(at91rm9200_io_desc));
321
322static void __init at91rm9200_ioremap_registers(void)
323{
324 at91rm9200_ioremap_st(AT91RM9200_BASE_ST);
325 at91_ioremap_ramc(0, AT91RM9200_BASE_MC, 256);
326} 306}
327 307
328static void __init at91rm9200_initialize(void) 308static void __init at91rm9200_initialize(void)
329{ 309{
330 arm_pm_idle = at91rm9200_idle; 310 at91_arch_reset = at91rm9200_reset;
331 arm_pm_restart = at91rm9200_restart;
332 at91_extern_irq = (1 << AT91RM9200_ID_IRQ0) | (1 << AT91RM9200_ID_IRQ1) 311 at91_extern_irq = (1 << AT91RM9200_ID_IRQ0) | (1 << AT91RM9200_ID_IRQ1)
333 | (1 << AT91RM9200_ID_IRQ2) | (1 << AT91RM9200_ID_IRQ3) 312 | (1 << AT91RM9200_ID_IRQ2) | (1 << AT91RM9200_ID_IRQ3)
334 | (1 << AT91RM9200_ID_IRQ4) | (1 << AT91RM9200_ID_IRQ5) 313 | (1 << AT91RM9200_ID_IRQ4) | (1 << AT91RM9200_ID_IRQ5)
@@ -382,10 +361,9 @@ static unsigned int at91rm9200_default_irq_priority[NR_AIC_IRQS] __initdata = {
382 0 /* Advanced Interrupt Controller (IRQ6) */ 361 0 /* Advanced Interrupt Controller (IRQ6) */
383}; 362};
384 363
385AT91_SOC_START(rm9200) 364struct at91_init_soc __initdata at91rm9200_soc = {
386 .map_io = at91rm9200_map_io, 365 .map_io = at91rm9200_map_io,
387 .default_irq_priority = at91rm9200_default_irq_priority, 366 .default_irq_priority = at91rm9200_default_irq_priority,
388 .ioremap_registers = at91rm9200_ioremap_registers,
389 .register_clocks = at91rm9200_register_clocks, 367 .register_clocks = at91rm9200_register_clocks,
390 .init = at91rm9200_initialize, 368 .init = at91rm9200_initialize,
391AT91_SOC_END 369};
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 3ebc9792560..e596f45e042 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -14,15 +14,14 @@
14#include <asm/mach/map.h> 14#include <asm/mach/map.h>
15 15
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <linux/gpio.h>
18#include <linux/platform_device.h> 17#include <linux/platform_device.h>
19#include <linux/i2c-gpio.h> 18#include <linux/i2c-gpio.h>
20 19
20#include <mach/board.h>
21#include <mach/gpio.h>
21#include <mach/at91rm9200.h> 22#include <mach/at91rm9200.h>
22#include <mach/at91rm9200_mc.h> 23#include <mach/at91rm9200_mc.h>
23#include <mach/at91_ramc.h>
24 24
25#include "board.h"
26#include "generic.h" 25#include "generic.h"
27 26
28 27
@@ -41,8 +40,8 @@ static struct resource usbh_resources[] = {
41 .flags = IORESOURCE_MEM, 40 .flags = IORESOURCE_MEM,
42 }, 41 },
43 [1] = { 42 [1] = {
44 .start = NR_IRQS_LEGACY + AT91RM9200_ID_UHP, 43 .start = AT91RM9200_ID_UHP,
45 .end = NR_IRQS_LEGACY + AT91RM9200_ID_UHP, 44 .end = AT91RM9200_ID_UHP,
46 .flags = IORESOURCE_IRQ, 45 .flags = IORESOURCE_IRQ,
47 }, 46 },
48}; 47};
@@ -61,17 +60,9 @@ static struct platform_device at91rm9200_usbh_device = {
61 60
62void __init at91_add_device_usbh(struct at91_usbh_data *data) 61void __init at91_add_device_usbh(struct at91_usbh_data *data)
63{ 62{
64 int i;
65
66 if (!data) 63 if (!data)
67 return; 64 return;
68 65
69 /* Enable overcurrent notification */
70 for (i = 0; i < data->ports; i++) {
71 if (gpio_is_valid(data->overcurrent_pin[i]))
72 at91_set_gpio_input(data->overcurrent_pin[i], 1);
73 }
74
75 usbh_data = *data; 66 usbh_data = *data;
76 platform_device_register(&at91rm9200_usbh_device); 67 platform_device_register(&at91rm9200_usbh_device);
77} 68}
@@ -84,7 +75,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
84 * USB Device (Gadget) 75 * USB Device (Gadget)
85 * -------------------------------------------------------------------- */ 76 * -------------------------------------------------------------------- */
86 77
87#if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE) 78#ifdef CONFIG_USB_AT91
88static struct at91_udc_data udc_data; 79static struct at91_udc_data udc_data;
89 80
90static struct resource udc_resources[] = { 81static struct resource udc_resources[] = {
@@ -94,8 +85,8 @@ static struct resource udc_resources[] = {
94 .flags = IORESOURCE_MEM, 85 .flags = IORESOURCE_MEM,
95 }, 86 },
96 [1] = { 87 [1] = {
97 .start = NR_IRQS_LEGACY + AT91RM9200_ID_UDP, 88 .start = AT91RM9200_ID_UDP,
98 .end = NR_IRQS_LEGACY + AT91RM9200_ID_UDP, 89 .end = AT91RM9200_ID_UDP,
99 .flags = IORESOURCE_IRQ, 90 .flags = IORESOURCE_IRQ,
100 }, 91 },
101}; 92};
@@ -115,11 +106,11 @@ void __init at91_add_device_udc(struct at91_udc_data *data)
115 if (!data) 106 if (!data)
116 return; 107 return;
117 108
118 if (gpio_is_valid(data->vbus_pin)) { 109 if (data->vbus_pin) {
119 at91_set_gpio_input(data->vbus_pin, 0); 110 at91_set_gpio_input(data->vbus_pin, 0);
120 at91_set_deglitch(data->vbus_pin, 1); 111 at91_set_deglitch(data->vbus_pin, 1);
121 } 112 }
122 if (gpio_is_valid(data->pullup_pin)) 113 if (data->pullup_pin)
123 at91_set_gpio_output(data->pullup_pin, 0); 114 at91_set_gpio_output(data->pullup_pin, 0);
124 115
125 udc_data = *data; 116 udc_data = *data;
@@ -136,17 +127,17 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
136 127
137#if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE) 128#if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE)
138static u64 eth_dmamask = DMA_BIT_MASK(32); 129static u64 eth_dmamask = DMA_BIT_MASK(32);
139static struct macb_platform_data eth_data; 130static struct at91_eth_data eth_data;
140 131
141static struct resource eth_resources[] = { 132static struct resource eth_resources[] = {
142 [0] = { 133 [0] = {
143 .start = AT91RM9200_BASE_EMAC, 134 .start = AT91_VA_BASE_EMAC,
144 .end = AT91RM9200_BASE_EMAC + SZ_16K - 1, 135 .end = AT91_VA_BASE_EMAC + SZ_16K - 1,
145 .flags = IORESOURCE_MEM, 136 .flags = IORESOURCE_MEM,
146 }, 137 },
147 [1] = { 138 [1] = {
148 .start = NR_IRQS_LEGACY + AT91RM9200_ID_EMAC, 139 .start = AT91RM9200_ID_EMAC,
149 .end = NR_IRQS_LEGACY + AT91RM9200_ID_EMAC, 140 .end = AT91RM9200_ID_EMAC,
150 .flags = IORESOURCE_IRQ, 141 .flags = IORESOURCE_IRQ,
151 }, 142 },
152}; 143};
@@ -163,12 +154,12 @@ static struct platform_device at91rm9200_eth_device = {
163 .num_resources = ARRAY_SIZE(eth_resources), 154 .num_resources = ARRAY_SIZE(eth_resources),
164}; 155};
165 156
166void __init at91_add_device_eth(struct macb_platform_data *data) 157void __init at91_add_device_eth(struct at91_eth_data *data)
167{ 158{
168 if (!data) 159 if (!data)
169 return; 160 return;
170 161
171 if (gpio_is_valid(data->phy_irq_pin)) { 162 if (data->phy_irq_pin) {
172 at91_set_gpio_input(data->phy_irq_pin, 0); 163 at91_set_gpio_input(data->phy_irq_pin, 0);
173 at91_set_deglitch(data->phy_irq_pin, 1); 164 at91_set_deglitch(data->phy_irq_pin, 1);
174 } 165 }
@@ -200,7 +191,7 @@ void __init at91_add_device_eth(struct macb_platform_data *data)
200 platform_device_register(&at91rm9200_eth_device); 191 platform_device_register(&at91rm9200_eth_device);
201} 192}
202#else 193#else
203void __init at91_add_device_eth(struct macb_platform_data *data) {} 194void __init at91_add_device_eth(struct at91_eth_data *data) {}
204#endif 195#endif
205 196
206 197
@@ -242,15 +233,15 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
242 data->chipselect = 4; /* can only use EBI ChipSelect 4 */ 233 data->chipselect = 4; /* can only use EBI ChipSelect 4 */
243 234
244 /* CF takes over CS4, CS5, CS6 */ 235 /* CF takes over CS4, CS5, CS6 */
245 csa = at91_ramc_read(0, AT91_EBI_CSA); 236 csa = at91_sys_read(AT91_EBI_CSA);
246 at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH); 237 at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
247 238
248 /* 239 /*
249 * Static memory controller timing adjustments. 240 * Static memory controller timing adjustments.
250 * REVISIT: these timings are in terms of MCK cycles, so 241 * REVISIT: these timings are in terms of MCK cycles, so
251 * when MCK changes (cpufreq etc) so must these values... 242 * when MCK changes (cpufreq etc) so must these values...
252 */ 243 */
253 at91_ramc_write(0, AT91_SMC_CSR(4), 244 at91_sys_write(AT91_SMC_CSR(4),
254 AT91_SMC_ACSS_STD 245 AT91_SMC_ACSS_STD
255 | AT91_SMC_DBW_16 246 | AT91_SMC_DBW_16
256 | AT91_SMC_BAT 247 | AT91_SMC_BAT
@@ -261,7 +252,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
261 ); 252 );
262 253
263 /* input/irq */ 254 /* input/irq */
264 if (gpio_is_valid(data->irq_pin)) { 255 if (data->irq_pin) {
265 at91_set_gpio_input(data->irq_pin, 1); 256 at91_set_gpio_input(data->irq_pin, 1);
266 at91_set_deglitch(data->irq_pin, 1); 257 at91_set_deglitch(data->irq_pin, 1);
267 } 258 }
@@ -269,7 +260,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
269 at91_set_deglitch(data->det_pin, 1); 260 at91_set_deglitch(data->det_pin, 1);
270 261
271 /* outputs, initially off */ 262 /* outputs, initially off */
272 if (gpio_is_valid(data->vcc_pin)) 263 if (data->vcc_pin)
273 at91_set_gpio_output(data->vcc_pin, 0); 264 at91_set_gpio_output(data->vcc_pin, 0);
274 at91_set_gpio_output(data->rst_pin, 0); 265 at91_set_gpio_output(data->rst_pin, 0);
275 266
@@ -294,9 +285,9 @@ void __init at91_add_device_cf(struct at91_cf_data *data) {}
294 * MMC / SD 285 * MMC / SD
295 * -------------------------------------------------------------------- */ 286 * -------------------------------------------------------------------- */
296 287
297#if IS_ENABLED(CONFIG_MMC_ATMELMCI) 288#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
298static u64 mmc_dmamask = DMA_BIT_MASK(32); 289static u64 mmc_dmamask = DMA_BIT_MASK(32);
299static struct mci_platform_data mmc_data; 290static struct at91_mmc_data mmc_data;
300 291
301static struct resource mmc_resources[] = { 292static struct resource mmc_resources[] = {
302 [0] = { 293 [0] = {
@@ -305,14 +296,14 @@ static struct resource mmc_resources[] = {
305 .flags = IORESOURCE_MEM, 296 .flags = IORESOURCE_MEM,
306 }, 297 },
307 [1] = { 298 [1] = {
308 .start = NR_IRQS_LEGACY + AT91RM9200_ID_MCI, 299 .start = AT91RM9200_ID_MCI,
309 .end = NR_IRQS_LEGACY + AT91RM9200_ID_MCI, 300 .end = AT91RM9200_ID_MCI,
310 .flags = IORESOURCE_IRQ, 301 .flags = IORESOURCE_IRQ,
311 }, 302 },
312}; 303};
313 304
314static struct platform_device at91rm9200_mmc_device = { 305static struct platform_device at91rm9200_mmc_device = {
315 .name = "atmel_mci", 306 .name = "at91_mci",
316 .id = -1, 307 .id = -1,
317 .dev = { 308 .dev = {
318 .dma_mask = &mmc_dmamask, 309 .dma_mask = &mmc_dmamask,
@@ -323,69 +314,53 @@ static struct platform_device at91rm9200_mmc_device = {
323 .num_resources = ARRAY_SIZE(mmc_resources), 314 .num_resources = ARRAY_SIZE(mmc_resources),
324}; 315};
325 316
326void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) 317void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
327{ 318{
328 unsigned int i;
329 unsigned int slot_count = 0;
330
331 if (!data) 319 if (!data)
332 return; 320 return;
333 321
334 for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) { 322 /* input/irq */
323 if (data->det_pin) {
324 at91_set_gpio_input(data->det_pin, 1);
325 at91_set_deglitch(data->det_pin, 1);
326 }
327 if (data->wp_pin)
328 at91_set_gpio_input(data->wp_pin, 1);
329 if (data->vcc_pin)
330 at91_set_gpio_output(data->vcc_pin, 0);
331
332 /* CLK */
333 at91_set_A_periph(AT91_PIN_PA27, 0);
335 334
336 if (!data->slot[i].bus_width) 335 if (data->slot_b) {
337 continue; 336 /* CMD */
337 at91_set_B_periph(AT91_PIN_PA8, 1);
338 338
339 /* input/irq */ 339 /* DAT0, maybe DAT1..DAT3 */
340 if (gpio_is_valid(data->slot[i].detect_pin)) { 340 at91_set_B_periph(AT91_PIN_PA9, 1);
341 at91_set_gpio_input(data->slot[i].detect_pin, 1); 341 if (data->wire4) {
342 at91_set_deglitch(data->slot[i].detect_pin, 1); 342 at91_set_B_periph(AT91_PIN_PA10, 1);
343 } 343 at91_set_B_periph(AT91_PIN_PA11, 1);
344 if (gpio_is_valid(data->slot[i].wp_pin)) 344 at91_set_B_periph(AT91_PIN_PA12, 1);
345 at91_set_gpio_input(data->slot[i].wp_pin, 1);
346
347 switch (i) {
348 case 0: /* slot A */
349 /* CMD */
350 at91_set_A_periph(AT91_PIN_PA28, 1);
351 /* DAT0, maybe DAT1..DAT3 */
352 at91_set_A_periph(AT91_PIN_PA29, 1);
353 if (data->slot[i].bus_width == 4) {
354 at91_set_B_periph(AT91_PIN_PB3, 1);
355 at91_set_B_periph(AT91_PIN_PB4, 1);
356 at91_set_B_periph(AT91_PIN_PB5, 1);
357 }
358 slot_count++;
359 break;
360 case 1: /* slot B */
361 /* CMD */
362 at91_set_B_periph(AT91_PIN_PA8, 1);
363 /* DAT0, maybe DAT1..DAT3 */
364 at91_set_B_periph(AT91_PIN_PA9, 1);
365 if (data->slot[i].bus_width == 4) {
366 at91_set_B_periph(AT91_PIN_PA10, 1);
367 at91_set_B_periph(AT91_PIN_PA11, 1);
368 at91_set_B_periph(AT91_PIN_PA12, 1);
369 }
370 slot_count++;
371 break;
372 default:
373 printk(KERN_ERR
374 "AT91: SD/MMC slot %d not available\n", i);
375 break;
376 } 345 }
377 if (slot_count) { 346 } else {
378 /* CLK */ 347 /* CMD */
379 at91_set_A_periph(AT91_PIN_PA27, 0); 348 at91_set_A_periph(AT91_PIN_PA28, 1);
380 349
381 mmc_data = *data; 350 /* DAT0, maybe DAT1..DAT3 */
382 platform_device_register(&at91rm9200_mmc_device); 351 at91_set_A_periph(AT91_PIN_PA29, 1);
352 if (data->wire4) {
353 at91_set_B_periph(AT91_PIN_PB3, 1);
354 at91_set_B_periph(AT91_PIN_PB4, 1);
355 at91_set_B_periph(AT91_PIN_PB5, 1);
383 } 356 }
384 } 357 }
385 358
359 mmc_data = *data;
360 platform_device_register(&at91rm9200_mmc_device);
386} 361}
387#else 362#else
388void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {} 363void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
389#endif 364#endif
390 365
391 366
@@ -424,11 +399,11 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
424 return; 399 return;
425 400
426 /* enable the address range of CS3 */ 401 /* enable the address range of CS3 */
427 csa = at91_ramc_read(0, AT91_EBI_CSA); 402 csa = at91_sys_read(AT91_EBI_CSA);
428 at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA); 403 at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
429 404
430 /* set the bus interface characteristics */ 405 /* set the bus interface characteristics */
431 at91_ramc_write(0, AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN 406 at91_sys_write(AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
432 | AT91_SMC_NWS_(5) 407 | AT91_SMC_NWS_(5)
433 | AT91_SMC_TDF_(1) 408 | AT91_SMC_TDF_(1)
434 | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */ 409 | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */
@@ -436,15 +411,15 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
436 ); 411 );
437 412
438 /* enable pin */ 413 /* enable pin */
439 if (gpio_is_valid(data->enable_pin)) 414 if (data->enable_pin)
440 at91_set_gpio_output(data->enable_pin, 1); 415 at91_set_gpio_output(data->enable_pin, 1);
441 416
442 /* ready/busy pin */ 417 /* ready/busy pin */
443 if (gpio_is_valid(data->rdy_pin)) 418 if (data->rdy_pin)
444 at91_set_gpio_input(data->rdy_pin, 1); 419 at91_set_gpio_input(data->rdy_pin, 1);
445 420
446 /* card detect pin */ 421 /* card detect pin */
447 if (gpio_is_valid(data->det_pin)) 422 if (data->det_pin)
448 at91_set_gpio_input(data->det_pin, 1); 423 at91_set_gpio_input(data->det_pin, 1);
449 424
450 at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */ 425 at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */
@@ -479,7 +454,7 @@ static struct i2c_gpio_platform_data pdata = {
479 454
480static struct platform_device at91rm9200_twi_device = { 455static struct platform_device at91rm9200_twi_device = {
481 .name = "i2c-gpio", 456 .name = "i2c-gpio",
482 .id = 0, 457 .id = -1,
483 .dev.platform_data = &pdata, 458 .dev.platform_data = &pdata,
484}; 459};
485 460
@@ -504,15 +479,15 @@ static struct resource twi_resources[] = {
504 .flags = IORESOURCE_MEM, 479 .flags = IORESOURCE_MEM,
505 }, 480 },
506 [1] = { 481 [1] = {
507 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TWI, 482 .start = AT91RM9200_ID_TWI,
508 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TWI, 483 .end = AT91RM9200_ID_TWI,
509 .flags = IORESOURCE_IRQ, 484 .flags = IORESOURCE_IRQ,
510 }, 485 },
511}; 486};
512 487
513static struct platform_device at91rm9200_twi_device = { 488static struct platform_device at91rm9200_twi_device = {
514 .name = "i2c-at91rm9200", 489 .name = "at91_i2c",
515 .id = 0, 490 .id = -1,
516 .resource = twi_resources, 491 .resource = twi_resources,
517 .num_resources = ARRAY_SIZE(twi_resources), 492 .num_resources = ARRAY_SIZE(twi_resources),
518}; 493};
@@ -548,8 +523,8 @@ static struct resource spi_resources[] = {
548 .flags = IORESOURCE_MEM, 523 .flags = IORESOURCE_MEM,
549 }, 524 },
550 [1] = { 525 [1] = {
551 .start = NR_IRQS_LEGACY + AT91RM9200_ID_SPI, 526 .start = AT91RM9200_ID_SPI,
552 .end = NR_IRQS_LEGACY + AT91RM9200_ID_SPI, 527 .end = AT91RM9200_ID_SPI,
553 .flags = IORESOURCE_IRQ, 528 .flags = IORESOURCE_IRQ,
554 }, 529 },
555}; 530};
@@ -614,18 +589,18 @@ static struct resource tcb0_resources[] = {
614 .flags = IORESOURCE_MEM, 589 .flags = IORESOURCE_MEM,
615 }, 590 },
616 [1] = { 591 [1] = {
617 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC0, 592 .start = AT91RM9200_ID_TC0,
618 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC0, 593 .end = AT91RM9200_ID_TC0,
619 .flags = IORESOURCE_IRQ, 594 .flags = IORESOURCE_IRQ,
620 }, 595 },
621 [2] = { 596 [2] = {
622 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC1, 597 .start = AT91RM9200_ID_TC1,
623 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC1, 598 .end = AT91RM9200_ID_TC1,
624 .flags = IORESOURCE_IRQ, 599 .flags = IORESOURCE_IRQ,
625 }, 600 },
626 [3] = { 601 [3] = {
627 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC2, 602 .start = AT91RM9200_ID_TC2,
628 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC2, 603 .end = AT91RM9200_ID_TC2,
629 .flags = IORESOURCE_IRQ, 604 .flags = IORESOURCE_IRQ,
630 }, 605 },
631}; 606};
@@ -644,18 +619,18 @@ static struct resource tcb1_resources[] = {
644 .flags = IORESOURCE_MEM, 619 .flags = IORESOURCE_MEM,
645 }, 620 },
646 [1] = { 621 [1] = {
647 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC3, 622 .start = AT91RM9200_ID_TC3,
648 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC3, 623 .end = AT91RM9200_ID_TC3,
649 .flags = IORESOURCE_IRQ, 624 .flags = IORESOURCE_IRQ,
650 }, 625 },
651 [2] = { 626 [2] = {
652 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC4, 627 .start = AT91RM9200_ID_TC4,
653 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC4, 628 .end = AT91RM9200_ID_TC4,
654 .flags = IORESOURCE_IRQ, 629 .flags = IORESOURCE_IRQ,
655 }, 630 },
656 [3] = { 631 [3] = {
657 .start = NR_IRQS_LEGACY + AT91RM9200_ID_TC5, 632 .start = AT91RM9200_ID_TC5,
658 .end = NR_IRQS_LEGACY + AT91RM9200_ID_TC5, 633 .end = AT91RM9200_ID_TC5,
659 .flags = IORESOURCE_IRQ, 634 .flags = IORESOURCE_IRQ,
660 }, 635 },
661}; 636};
@@ -682,24 +657,10 @@ static void __init at91_add_device_tc(void) { }
682 * -------------------------------------------------------------------- */ 657 * -------------------------------------------------------------------- */
683 658
684#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE) 659#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
685static struct resource rtc_resources[] = {
686 [0] = {
687 .start = AT91RM9200_BASE_RTC,
688 .end = AT91RM9200_BASE_RTC + SZ_256 - 1,
689 .flags = IORESOURCE_MEM,
690 },
691 [1] = {
692 .start = NR_IRQS_LEGACY + AT91_ID_SYS,
693 .end = NR_IRQS_LEGACY + AT91_ID_SYS,
694 .flags = IORESOURCE_IRQ,
695 },
696};
697
698static struct platform_device at91rm9200_rtc_device = { 660static struct platform_device at91rm9200_rtc_device = {
699 .name = "at91_rtc", 661 .name = "at91_rtc",
700 .id = -1, 662 .id = -1,
701 .resource = rtc_resources, 663 .num_resources = 0,
702 .num_resources = ARRAY_SIZE(rtc_resources),
703}; 664};
704 665
705static void __init at91_add_device_rtc(void) 666static void __init at91_add_device_rtc(void)
@@ -745,14 +706,14 @@ static struct resource ssc0_resources[] = {
745 .flags = IORESOURCE_MEM, 706 .flags = IORESOURCE_MEM,
746 }, 707 },
747 [1] = { 708 [1] = {
748 .start = NR_IRQS_LEGACY + AT91RM9200_ID_SSC0, 709 .start = AT91RM9200_ID_SSC0,
749 .end = NR_IRQS_LEGACY + AT91RM9200_ID_SSC0, 710 .end = AT91RM9200_ID_SSC0,
750 .flags = IORESOURCE_IRQ, 711 .flags = IORESOURCE_IRQ,
751 }, 712 },
752}; 713};
753 714
754static struct platform_device at91rm9200_ssc0_device = { 715static struct platform_device at91rm9200_ssc0_device = {
755 .name = "at91rm9200_ssc", 716 .name = "ssc",
756 .id = 0, 717 .id = 0,
757 .dev = { 718 .dev = {
758 .dma_mask = &ssc0_dmamask, 719 .dma_mask = &ssc0_dmamask,
@@ -787,14 +748,14 @@ static struct resource ssc1_resources[] = {
787 .flags = IORESOURCE_MEM, 748 .flags = IORESOURCE_MEM,
788 }, 749 },
789 [1] = { 750 [1] = {
790 .start = NR_IRQS_LEGACY + AT91RM9200_ID_SSC1, 751 .start = AT91RM9200_ID_SSC1,
791 .end = NR_IRQS_LEGACY + AT91RM9200_ID_SSC1, 752 .end = AT91RM9200_ID_SSC1,
792 .flags = IORESOURCE_IRQ, 753 .flags = IORESOURCE_IRQ,
793 }, 754 },
794}; 755};
795 756
796static struct platform_device at91rm9200_ssc1_device = { 757static struct platform_device at91rm9200_ssc1_device = {
797 .name = "at91rm9200_ssc", 758 .name = "ssc",
798 .id = 1, 759 .id = 1,
799 .dev = { 760 .dev = {
800 .dma_mask = &ssc1_dmamask, 761 .dma_mask = &ssc1_dmamask,
@@ -829,14 +790,14 @@ static struct resource ssc2_resources[] = {
829 .flags = IORESOURCE_MEM, 790 .flags = IORESOURCE_MEM,
830 }, 791 },
831 [1] = { 792 [1] = {
832 .start = NR_IRQS_LEGACY + AT91RM9200_ID_SSC2, 793 .start = AT91RM9200_ID_SSC2,
833 .end = NR_IRQS_LEGACY + AT91RM9200_ID_SSC2, 794 .end = AT91RM9200_ID_SSC2,
834 .flags = IORESOURCE_IRQ, 795 .flags = IORESOURCE_IRQ,
835 }, 796 },
836}; 797};
837 798
838static struct platform_device at91rm9200_ssc2_device = { 799static struct platform_device at91rm9200_ssc2_device = {
839 .name = "at91rm9200_ssc", 800 .name = "ssc",
840 .id = 2, 801 .id = 2,
841 .dev = { 802 .dev = {
842 .dma_mask = &ssc2_dmamask, 803 .dma_mask = &ssc2_dmamask,
@@ -908,13 +869,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
908#if defined(CONFIG_SERIAL_ATMEL) 869#if defined(CONFIG_SERIAL_ATMEL)
909static struct resource dbgu_resources[] = { 870static struct resource dbgu_resources[] = {
910 [0] = { 871 [0] = {
911 .start = AT91RM9200_BASE_DBGU, 872 .start = AT91_VA_BASE_SYS + AT91_DBGU,
912 .end = AT91RM9200_BASE_DBGU + SZ_512 - 1, 873 .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
913 .flags = IORESOURCE_MEM, 874 .flags = IORESOURCE_MEM,
914 }, 875 },
915 [1] = { 876 [1] = {
916 .start = NR_IRQS_LEGACY + AT91_ID_SYS, 877 .start = AT91_ID_SYS,
917 .end = NR_IRQS_LEGACY + AT91_ID_SYS, 878 .end = AT91_ID_SYS,
918 .flags = IORESOURCE_IRQ, 879 .flags = IORESOURCE_IRQ,
919 }, 880 },
920}; 881};
@@ -922,6 +883,7 @@ static struct resource dbgu_resources[] = {
922static struct atmel_uart_data dbgu_data = { 883static struct atmel_uart_data dbgu_data = {
923 .use_dma_tx = 0, 884 .use_dma_tx = 0,
924 .use_dma_rx = 0, /* DBGU not capable of receive DMA */ 885 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
886 .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
925}; 887};
926 888
927static u64 dbgu_dmamask = DMA_BIT_MASK(32); 889static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -951,8 +913,8 @@ static struct resource uart0_resources[] = {
951 .flags = IORESOURCE_MEM, 913 .flags = IORESOURCE_MEM,
952 }, 914 },
953 [1] = { 915 [1] = {
954 .start = NR_IRQS_LEGACY + AT91RM9200_ID_US0, 916 .start = AT91RM9200_ID_US0,
955 .end = NR_IRQS_LEGACY + AT91RM9200_ID_US0, 917 .end = AT91RM9200_ID_US0,
956 .flags = IORESOURCE_IRQ, 918 .flags = IORESOURCE_IRQ,
957 }, 919 },
958}; 920};
@@ -1000,8 +962,8 @@ static struct resource uart1_resources[] = {
1000 .flags = IORESOURCE_MEM, 962 .flags = IORESOURCE_MEM,
1001 }, 963 },
1002 [1] = { 964 [1] = {
1003 .start = NR_IRQS_LEGACY + AT91RM9200_ID_US1, 965 .start = AT91RM9200_ID_US1,
1004 .end = NR_IRQS_LEGACY + AT91RM9200_ID_US1, 966 .end = AT91RM9200_ID_US1,
1005 .flags = IORESOURCE_IRQ, 967 .flags = IORESOURCE_IRQ,
1006 }, 968 },
1007}; 969};
@@ -1051,8 +1013,8 @@ static struct resource uart2_resources[] = {
1051 .flags = IORESOURCE_MEM, 1013 .flags = IORESOURCE_MEM,
1052 }, 1014 },
1053 [1] = { 1015 [1] = {
1054 .start = NR_IRQS_LEGACY + AT91RM9200_ID_US2, 1016 .start = AT91RM9200_ID_US2,
1055 .end = NR_IRQS_LEGACY + AT91RM9200_ID_US2, 1017 .end = AT91RM9200_ID_US2,
1056 .flags = IORESOURCE_IRQ, 1018 .flags = IORESOURCE_IRQ,
1057 }, 1019 },
1058}; 1020};
@@ -1094,8 +1056,8 @@ static struct resource uart3_resources[] = {
1094 .flags = IORESOURCE_MEM, 1056 .flags = IORESOURCE_MEM,
1095 }, 1057 },
1096 [1] = { 1058 [1] = {
1097 .start = NR_IRQS_LEGACY + AT91RM9200_ID_US3, 1059 .start = AT91RM9200_ID_US3,
1098 .end = NR_IRQS_LEGACY + AT91RM9200_ID_US3, 1060 .end = AT91RM9200_ID_US3,
1099 .flags = IORESOURCE_IRQ, 1061 .flags = IORESOURCE_IRQ,
1100 }, 1062 },
1101}; 1063};
@@ -1131,6 +1093,7 @@ static inline void configure_usart3_pins(unsigned pins)
1131} 1093}
1132 1094
1133static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1095static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1096struct platform_device *atmel_default_console_device; /* the serial console device */
1134 1097
1135void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1098void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1136{ 1099{
@@ -1168,6 +1131,14 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1168 at91_uarts[portnr] = pdev; 1131 at91_uarts[portnr] = pdev;
1169} 1132}
1170 1133
1134void __init at91_set_serial_console(unsigned portnr)
1135{
1136 if (portnr < ATMEL_MAX_UART) {
1137 atmel_default_console_device = at91_uarts[portnr];
1138 at91rm9200_set_console_clock(at91_uarts[portnr]->id);
1139 }
1140}
1141
1171void __init at91_add_device_serial(void) 1142void __init at91_add_device_serial(void)
1172{ 1143{
1173 int i; 1144 int i;
@@ -1176,9 +1147,14 @@ void __init at91_add_device_serial(void)
1176 if (at91_uarts[i]) 1147 if (at91_uarts[i])
1177 platform_device_register(at91_uarts[i]); 1148 platform_device_register(at91_uarts[i]);
1178 } 1149 }
1150
1151 if (!atmel_default_console_device)
1152 printk(KERN_INFO "AT91: No default serial console defined.\n");
1179} 1153}
1180#else 1154#else
1155void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
1181void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1156void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1157void __init at91_set_serial_console(unsigned portnr) {}
1182void __init at91_add_device_serial(void) {} 1158void __init at91_add_device_serial(void) {}
1183#endif 1159#endif
1184 1160
diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/arch/arm/mach-at91/at91rm9200_time.c
index cafe98836c8..1dd69c85dfe 100644
--- a/arch/arm/mach-at91/at91rm9200_time.c
+++ b/arch/arm/mach-at91/at91rm9200_time.c
@@ -23,10 +23,6 @@
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/irq.h> 24#include <linux/irq.h>
25#include <linux/clockchips.h> 25#include <linux/clockchips.h>
26#include <linux/export.h>
27#include <linux/of.h>
28#include <linux/of_address.h>
29#include <linux/of_irq.h>
30 26
31#include <asm/mach/time.h> 27#include <asm/mach/time.h>
32 28
@@ -36,8 +32,6 @@ static unsigned long last_crtr;
36static u32 irqmask; 32static u32 irqmask;
37static struct clock_event_device clkevt; 33static struct clock_event_device clkevt;
38 34
39#define RM9200_TIMER_LATCH ((AT91_SLOW_CLOCK + HZ/2) / HZ)
40
41/* 35/*
42 * The ST_CRTR is updated asynchronously to the master clock ... but 36 * The ST_CRTR is updated asynchronously to the master clock ... but
43 * the updates as seen by the CPU don't seem to be strictly monotonic. 37 * the updates as seen by the CPU don't seem to be strictly monotonic.
@@ -47,9 +41,9 @@ static inline unsigned long read_CRTR(void)
47{ 41{
48 unsigned long x1, x2; 42 unsigned long x1, x2;
49 43
50 x1 = at91_st_read(AT91_ST_CRTR); 44 x1 = at91_sys_read(AT91_ST_CRTR);
51 do { 45 do {
52 x2 = at91_st_read(AT91_ST_CRTR); 46 x2 = at91_sys_read(AT91_ST_CRTR);
53 if (x1 == x2) 47 if (x1 == x2)
54 break; 48 break;
55 x1 = x2; 49 x1 = x2;
@@ -62,7 +56,7 @@ static inline unsigned long read_CRTR(void)
62 */ 56 */
63static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id) 57static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
64{ 58{
65 u32 sr = at91_st_read(AT91_ST_SR) & irqmask; 59 u32 sr = at91_sys_read(AT91_ST_SR) & irqmask;
66 60
67 /* 61 /*
68 * irqs should be disabled here, but as the irq is shared they are only 62 * irqs should be disabled here, but as the irq is shared they are only
@@ -80,8 +74,8 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
80 if (sr & AT91_ST_PITS) { 74 if (sr & AT91_ST_PITS) {
81 u32 crtr = read_CRTR(); 75 u32 crtr = read_CRTR();
82 76
83 while (((crtr - last_crtr) & AT91_ST_CRTV) >= RM9200_TIMER_LATCH) { 77 while (((crtr - last_crtr) & AT91_ST_CRTV) >= LATCH) {
84 last_crtr += RM9200_TIMER_LATCH; 78 last_crtr += LATCH;
85 clkevt.event_handler(&clkevt); 79 clkevt.event_handler(&clkevt);
86 } 80 }
87 return IRQ_HANDLED; 81 return IRQ_HANDLED;
@@ -94,8 +88,7 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
94static struct irqaction at91rm9200_timer_irq = { 88static struct irqaction at91rm9200_timer_irq = {
95 .name = "at91_tick", 89 .name = "at91_tick",
96 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, 90 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
97 .handler = at91rm9200_timer_interrupt, 91 .handler = at91rm9200_timer_interrupt
98 .irq = NR_IRQS_LEGACY + AT91_ID_SYS,
99}; 92};
100 93
101static cycle_t read_clk32k(struct clocksource *cs) 94static cycle_t read_clk32k(struct clocksource *cs)
@@ -115,22 +108,22 @@ static void
115clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev) 108clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
116{ 109{
117 /* Disable and flush pending timer interrupts */ 110 /* Disable and flush pending timer interrupts */
118 at91_st_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS); 111 at91_sys_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS);
119 at91_st_read(AT91_ST_SR); 112 (void) at91_sys_read(AT91_ST_SR);
120 113
121 last_crtr = read_CRTR(); 114 last_crtr = read_CRTR();
122 switch (mode) { 115 switch (mode) {
123 case CLOCK_EVT_MODE_PERIODIC: 116 case CLOCK_EVT_MODE_PERIODIC:
124 /* PIT for periodic irqs; fixed rate of 1/HZ */ 117 /* PIT for periodic irqs; fixed rate of 1/HZ */
125 irqmask = AT91_ST_PITS; 118 irqmask = AT91_ST_PITS;
126 at91_st_write(AT91_ST_PIMR, RM9200_TIMER_LATCH); 119 at91_sys_write(AT91_ST_PIMR, LATCH);
127 break; 120 break;
128 case CLOCK_EVT_MODE_ONESHOT: 121 case CLOCK_EVT_MODE_ONESHOT:
129 /* ALM for oneshot irqs, set by next_event() 122 /* ALM for oneshot irqs, set by next_event()
130 * before 32 seconds have passed 123 * before 32 seconds have passed
131 */ 124 */
132 irqmask = AT91_ST_ALMS; 125 irqmask = AT91_ST_ALMS;
133 at91_st_write(AT91_ST_RTAR, last_crtr); 126 at91_sys_write(AT91_ST_RTAR, last_crtr);
134 break; 127 break;
135 case CLOCK_EVT_MODE_SHUTDOWN: 128 case CLOCK_EVT_MODE_SHUTDOWN:
136 case CLOCK_EVT_MODE_UNUSED: 129 case CLOCK_EVT_MODE_UNUSED:
@@ -138,7 +131,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
138 irqmask = 0; 131 irqmask = 0;
139 break; 132 break;
140 } 133 }
141 at91_st_write(AT91_ST_IER, irqmask); 134 at91_sys_write(AT91_ST_IER, irqmask);
142} 135}
143 136
144static int 137static int
@@ -161,12 +154,12 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
161 alm = read_CRTR(); 154 alm = read_CRTR();
162 155
163 /* Cancel any pending alarm; flush any pending IRQ */ 156 /* Cancel any pending alarm; flush any pending IRQ */
164 at91_st_write(AT91_ST_RTAR, alm); 157 at91_sys_write(AT91_ST_RTAR, alm);
165 at91_st_read(AT91_ST_SR); 158 (void) at91_sys_read(AT91_ST_SR);
166 159
167 /* Schedule alarm by writing RTAR. */ 160 /* Schedule alarm by writing RTAR. */
168 alm += delta; 161 alm += delta;
169 at91_st_write(AT91_ST_RTAR, alm); 162 at91_sys_write(AT91_ST_RTAR, alm);
170 163
171 return status; 164 return status;
172} 165}
@@ -180,89 +173,24 @@ static struct clock_event_device clkevt = {
180 .set_mode = clkevt32k_mode, 173 .set_mode = clkevt32k_mode,
181}; 174};
182 175
183void __iomem *at91_st_base;
184EXPORT_SYMBOL_GPL(at91_st_base);
185
186#ifdef CONFIG_OF
187static struct of_device_id at91rm9200_st_timer_ids[] = {
188 { .compatible = "atmel,at91rm9200-st" },
189 { /* sentinel */ }
190};
191
192static int __init of_at91rm9200_st_init(void)
193{
194 struct device_node *np;
195 int ret;
196
197 np = of_find_matching_node(NULL, at91rm9200_st_timer_ids);
198 if (!np)
199 goto err;
200
201 at91_st_base = of_iomap(np, 0);
202 if (!at91_st_base)
203 goto node_err;
204
205 /* Get the interrupts property */
206 ret = irq_of_parse_and_map(np, 0);
207 if (!ret)
208 goto ioremap_err;
209 at91rm9200_timer_irq.irq = ret;
210
211 of_node_put(np);
212
213 return 0;
214
215ioremap_err:
216 iounmap(at91_st_base);
217node_err:
218 of_node_put(np);
219err:
220 return -EINVAL;
221}
222#else
223static int __init of_at91rm9200_st_init(void)
224{
225 return -EINVAL;
226}
227#endif
228
229void __init at91rm9200_ioremap_st(u32 addr)
230{
231#ifdef CONFIG_OF
232 struct device_node *np;
233
234 np = of_find_matching_node(NULL, at91rm9200_st_timer_ids);
235 if (np) {
236 of_node_put(np);
237 return;
238 }
239#endif
240 at91_st_base = ioremap(addr, 256);
241 if (!at91_st_base)
242 panic("Impossible to ioremap ST\n");
243}
244
245/* 176/*
246 * ST (system timer) module supports both clockevents and clocksource. 177 * ST (system timer) module supports both clockevents and clocksource.
247 */ 178 */
248void __init at91rm9200_timer_init(void) 179void __init at91rm9200_timer_init(void)
249{ 180{
250 /* For device tree enabled device: initialize here */
251 of_at91rm9200_st_init();
252
253 /* Disable all timer interrupts, and clear any pending ones */ 181 /* Disable all timer interrupts, and clear any pending ones */
254 at91_st_write(AT91_ST_IDR, 182 at91_sys_write(AT91_ST_IDR,
255 AT91_ST_PITS | AT91_ST_WDOVF | AT91_ST_RTTINC | AT91_ST_ALMS); 183 AT91_ST_PITS | AT91_ST_WDOVF | AT91_ST_RTTINC | AT91_ST_ALMS);
256 at91_st_read(AT91_ST_SR); 184 (void) at91_sys_read(AT91_ST_SR);
257 185
258 /* Make IRQs happen for the system timer */ 186 /* Make IRQs happen for the system timer */
259 setup_irq(at91rm9200_timer_irq.irq, &at91rm9200_timer_irq); 187 setup_irq(AT91_ID_SYS, &at91rm9200_timer_irq);
260 188
261 /* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used 189 /* The 32KiHz "Slow Clock" (tick every 30517.58 nanoseconds) is used
262 * directly for the clocksource and all clockevents, after adjusting 190 * directly for the clocksource and all clockevents, after adjusting
263 * its prescaler from the 1 Hz default. 191 * its prescaler from the 1 Hz default.
264 */ 192 */
265 at91_st_write(AT91_ST_RTMR, 1); 193 at91_sys_write(AT91_ST_RTMR, 1);
266 194
267 /* Setup timer clockevent, with minimum of two ticks (important!!) */ 195 /* Setup timer clockevent, with minimum of two ticks (important!!) */
268 clkevt.mult = div_sc(AT91_SLOW_CLOCK, NSEC_PER_SEC, clkevt.shift); 196 clkevt.mult = div_sc(AT91_SLOW_CLOCK, NSEC_PER_SEC, clkevt.shift);
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index b67cd537411..de4036f6ab3 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -11,23 +11,21 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pm.h>
14 15
15#include <asm/proc-fns.h>
16#include <asm/irq.h> 16#include <asm/irq.h>
17#include <asm/mach/arch.h> 17#include <asm/mach/arch.h>
18#include <asm/mach/map.h> 18#include <asm/mach/map.h>
19#include <asm/system_misc.h>
20#include <mach/cpu.h> 19#include <mach/cpu.h>
21#include <mach/at91_dbgu.h> 20#include <mach/at91_dbgu.h>
22#include <mach/at91sam9260.h> 21#include <mach/at91sam9260.h>
23#include <mach/at91_pmc.h> 22#include <mach/at91_pmc.h>
23#include <mach/at91_rstc.h>
24#include <mach/at91_shdwc.h>
24 25
25#include "at91_aic.h"
26#include "at91_rstc.h"
27#include "soc.h" 26#include "soc.h"
28#include "generic.h" 27#include "generic.h"
29#include "clock.h" 28#include "clock.h"
30#include "sam9_smc.h"
31 29
32/* -------------------------------------------------------------------- 30/* --------------------------------------------------------------------
33 * Clocks 31 * Clocks
@@ -56,13 +54,6 @@ static struct clk adc_clk = {
56 .pmc_mask = 1 << AT91SAM9260_ID_ADC, 54 .pmc_mask = 1 << AT91SAM9260_ID_ADC,
57 .type = CLK_TYPE_PERIPHERAL, 55 .type = CLK_TYPE_PERIPHERAL,
58}; 56};
59
60static struct clk adc_op_clk = {
61 .name = "adc_op_clk",
62 .type = CLK_TYPE_PERIPHERAL,
63 .rate_hz = 5000000,
64};
65
66static struct clk usart0_clk = { 57static struct clk usart0_clk = {
67 .name = "usart0_clk", 58 .name = "usart0_clk",
68 .pmc_mask = 1 << AT91SAM9260_ID_US0, 59 .pmc_mask = 1 << AT91SAM9260_ID_US0,
@@ -129,7 +120,7 @@ static struct clk ohci_clk = {
129 .type = CLK_TYPE_PERIPHERAL, 120 .type = CLK_TYPE_PERIPHERAL,
130}; 121};
131static struct clk macb_clk = { 122static struct clk macb_clk = {
132 .name = "pclk", 123 .name = "macb_clk",
133 .pmc_mask = 1 << AT91SAM9260_ID_EMAC, 124 .pmc_mask = 1 << AT91SAM9260_ID_EMAC,
134 .type = CLK_TYPE_PERIPHERAL, 125 .type = CLK_TYPE_PERIPHERAL,
135}; 126};
@@ -174,7 +165,6 @@ static struct clk *periph_clocks[] __initdata = {
174 &pioB_clk, 165 &pioB_clk,
175 &pioC_clk, 166 &pioC_clk,
176 &adc_clk, 167 &adc_clk,
177 &adc_op_clk,
178 &usart0_clk, 168 &usart0_clk,
179 &usart1_clk, 169 &usart1_clk,
180 &usart2_clk, 170 &usart2_clk,
@@ -200,8 +190,6 @@ static struct clk *periph_clocks[] __initdata = {
200}; 190};
201 191
202static struct clk_lookup periph_clocks_lookups[] = { 192static struct clk_lookup periph_clocks_lookups[] = {
203 /* One additional fake clock for macb_hclk */
204 CLKDEV_CON_ID("hclk", &macb_clk),
205 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), 193 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
206 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), 194 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
207 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), 195 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk),
@@ -210,36 +198,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
210 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk), 198 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk),
211 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk), 199 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk),
212 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk), 200 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk),
213 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc_clk), 201 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk),
214 CLKDEV_CON_DEV_ID("pclk", "fffbc000.ssc", &ssc_clk),
215 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260.0", &twi_clk),
216 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi_clk),
217 /* more usart lookup table for DT entries */
218 CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
219 CLKDEV_CON_DEV_ID("usart", "fffb0000.serial", &usart0_clk),
220 CLKDEV_CON_DEV_ID("usart", "fffb4000.serial", &usart1_clk),
221 CLKDEV_CON_DEV_ID("usart", "fffb8000.serial", &usart2_clk),
222 CLKDEV_CON_DEV_ID("usart", "fffd0000.serial", &usart3_clk),
223 CLKDEV_CON_DEV_ID("usart", "fffd4000.serial", &usart4_clk),
224 CLKDEV_CON_DEV_ID("usart", "fffd8000.serial", &usart5_clk),
225 CLKDEV_CON_DEV_ID(NULL, "fffac000.i2c", &twi_clk),
226 /* more tc lookup table for DT entries */
227 CLKDEV_CON_DEV_ID("t0_clk", "fffa0000.timer", &tc0_clk),
228 CLKDEV_CON_DEV_ID("t1_clk", "fffa0000.timer", &tc1_clk),
229 CLKDEV_CON_DEV_ID("t2_clk", "fffa0000.timer", &tc2_clk),
230 CLKDEV_CON_DEV_ID("t0_clk", "fffdc000.timer", &tc3_clk),
231 CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
232 CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
233 CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
234 CLKDEV_CON_DEV_ID("mci_clk", "fffa8000.mmc", &mmc_clk),
235 /* fake hclk clock */
236 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
237 CLKDEV_CON_ID("pioA", &pioA_clk),
238 CLKDEV_CON_ID("pioB", &pioB_clk),
239 CLKDEV_CON_ID("pioC", &pioC_clk),
240 CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioA_clk),
241 CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioB_clk),
242 CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioC_clk),
243}; 202};
244 203
245static struct clk_lookup usart_clocks_lookups[] = { 204static struct clk_lookup usart_clocks_lookups[] = {
@@ -285,23 +244,44 @@ static void __init at91sam9260_register_clocks(void)
285 clk_register(&pck1); 244 clk_register(&pck1);
286} 245}
287 246
247static struct clk_lookup console_clock_lookup;
248
249void __init at91sam9260_set_console_clock(int id)
250{
251 if (id >= ARRAY_SIZE(usart_clocks_lookups))
252 return;
253
254 console_clock_lookup.con_id = "usart";
255 console_clock_lookup.clk = usart_clocks_lookups[id].clk;
256 clkdev_add(&console_clock_lookup);
257}
258
288/* -------------------------------------------------------------------- 259/* --------------------------------------------------------------------
289 * GPIO 260 * GPIO
290 * -------------------------------------------------------------------- */ 261 * -------------------------------------------------------------------- */
291 262
292static struct at91_gpio_bank at91sam9260_gpio[] __initdata = { 263static struct at91_gpio_bank at91sam9260_gpio[] = {
293 { 264 {
294 .id = AT91SAM9260_ID_PIOA, 265 .id = AT91SAM9260_ID_PIOA,
295 .regbase = AT91SAM9260_BASE_PIOA, 266 .offset = AT91_PIOA,
267 .clock = &pioA_clk,
296 }, { 268 }, {
297 .id = AT91SAM9260_ID_PIOB, 269 .id = AT91SAM9260_ID_PIOB,
298 .regbase = AT91SAM9260_BASE_PIOB, 270 .offset = AT91_PIOB,
271 .clock = &pioB_clk,
299 }, { 272 }, {
300 .id = AT91SAM9260_ID_PIOC, 273 .id = AT91SAM9260_ID_PIOC,
301 .regbase = AT91SAM9260_BASE_PIOC, 274 .offset = AT91_PIOC,
275 .clock = &pioC_clk,
302 } 276 }
303}; 277};
304 278
279static void at91sam9260_poweroff(void)
280{
281 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
282}
283
284
305/* -------------------------------------------------------------------- 285/* --------------------------------------------------------------------
306 * AT91SAM9260 processor initialization 286 * AT91SAM9260 processor initialization
307 * -------------------------------------------------------------------- */ 287 * -------------------------------------------------------------------- */
@@ -324,28 +304,21 @@ static void __init at91sam9xe_map_io(void)
324 304
325static void __init at91sam9260_map_io(void) 305static void __init at91sam9260_map_io(void)
326{ 306{
327 if (cpu_is_at91sam9xe()) 307 if (cpu_is_at91sam9xe()) {
328 at91sam9xe_map_io(); 308 at91sam9xe_map_io();
329 else if (cpu_is_at91sam9g20()) 309 } else if (cpu_is_at91sam9g20()) {
330 at91_init_sram(0, AT91SAM9G20_SRAM_BASE, AT91SAM9G20_SRAM_SIZE); 310 at91_init_sram(0, AT91SAM9G20_SRAM0_BASE, AT91SAM9G20_SRAM0_SIZE);
331 else 311 at91_init_sram(1, AT91SAM9G20_SRAM1_BASE, AT91SAM9G20_SRAM1_SIZE);
332 at91_init_sram(0, AT91SAM9260_SRAM_BASE, AT91SAM9260_SRAM_SIZE); 312 } else {
333} 313 at91_init_sram(0, AT91SAM9260_SRAM0_BASE, AT91SAM9260_SRAM0_SIZE);
334 314 at91_init_sram(1, AT91SAM9260_SRAM1_BASE, AT91SAM9260_SRAM1_SIZE);
335static void __init at91sam9260_ioremap_registers(void) 315 }
336{
337 at91_ioremap_shdwc(AT91SAM9260_BASE_SHDWC);
338 at91_ioremap_rstc(AT91SAM9260_BASE_RSTC);
339 at91_ioremap_ramc(0, AT91SAM9260_BASE_SDRAMC, 512);
340 at91sam926x_ioremap_pit(AT91SAM9260_BASE_PIT);
341 at91sam9_ioremap_smc(0, AT91SAM9260_BASE_SMC);
342 at91_ioremap_matrix(AT91SAM9260_BASE_MATRIX);
343} 316}
344 317
345static void __init at91sam9260_initialize(void) 318static void __init at91sam9260_initialize(void)
346{ 319{
347 arm_pm_idle = at91sam9_idle; 320 at91_arch_reset = at91sam9_alt_reset;
348 arm_pm_restart = at91sam9_alt_restart; 321 pm_power_off = at91sam9260_poweroff;
349 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1) 322 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1)
350 | (1 << AT91SAM9260_ID_IRQ2); 323 | (1 << AT91SAM9260_ID_IRQ2);
351 324
@@ -395,10 +368,9 @@ static unsigned int at91sam9260_default_irq_priority[NR_AIC_IRQS] __initdata = {
395 0, /* Advanced Interrupt Controller */ 368 0, /* Advanced Interrupt Controller */
396}; 369};
397 370
398AT91_SOC_START(sam9260) 371struct at91_init_soc __initdata at91sam9260_soc = {
399 .map_io = at91sam9260_map_io, 372 .map_io = at91sam9260_map_io,
400 .default_irq_priority = at91sam9260_default_irq_priority, 373 .default_irq_priority = at91sam9260_default_irq_priority,
401 .ioremap_registers = at91sam9260_ioremap_registers,
402 .register_clocks = at91sam9260_register_clocks, 374 .register_clocks = at91sam9260_register_clocks,
403 .init = at91sam9260_initialize, 375 .init = at91sam9260_initialize,
404AT91_SOC_END 376};
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index eda8d1679d4..ec2572653d0 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -13,20 +13,16 @@
13#include <asm/mach/map.h> 13#include <asm/mach/map.h>
14 14
15#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
16#include <linux/gpio.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
18#include <linux/i2c-gpio.h> 17#include <linux/i2c-gpio.h>
19 18
20#include <linux/platform_data/at91_adc.h> 19#include <mach/board.h>
21 20#include <mach/gpio.h>
22#include <mach/cpu.h> 21#include <mach/cpu.h>
23#include <mach/at91sam9260.h> 22#include <mach/at91sam9260.h>
24#include <mach/at91sam9260_matrix.h> 23#include <mach/at91sam9260_matrix.h>
25#include <mach/at91_matrix.h>
26#include <mach/at91sam9_smc.h> 24#include <mach/at91sam9_smc.h>
27#include <mach/at91_adc.h>
28 25
29#include "board.h"
30#include "generic.h" 26#include "generic.h"
31 27
32 28
@@ -45,8 +41,8 @@ static struct resource usbh_resources[] = {
45 .flags = IORESOURCE_MEM, 41 .flags = IORESOURCE_MEM,
46 }, 42 },
47 [1] = { 43 [1] = {
48 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_UHP, 44 .start = AT91SAM9260_ID_UHP,
49 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_UHP, 45 .end = AT91SAM9260_ID_UHP,
50 .flags = IORESOURCE_IRQ, 46 .flags = IORESOURCE_IRQ,
51 }, 47 },
52}; 48};
@@ -65,17 +61,9 @@ static struct platform_device at91_usbh_device = {
65 61
66void __init at91_add_device_usbh(struct at91_usbh_data *data) 62void __init at91_add_device_usbh(struct at91_usbh_data *data)
67{ 63{
68 int i;
69
70 if (!data) 64 if (!data)
71 return; 65 return;
72 66
73 /* Enable overcurrent notification */
74 for (i = 0; i < data->ports; i++) {
75 if (gpio_is_valid(data->overcurrent_pin[i]))
76 at91_set_gpio_input(data->overcurrent_pin[i], 1);
77 }
78
79 usbh_data = *data; 67 usbh_data = *data;
80 platform_device_register(&at91_usbh_device); 68 platform_device_register(&at91_usbh_device);
81} 69}
@@ -88,7 +76,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
88 * USB Device (Gadget) 76 * USB Device (Gadget)
89 * -------------------------------------------------------------------- */ 77 * -------------------------------------------------------------------- */
90 78
91#if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE) 79#ifdef CONFIG_USB_AT91
92static struct at91_udc_data udc_data; 80static struct at91_udc_data udc_data;
93 81
94static struct resource udc_resources[] = { 82static struct resource udc_resources[] = {
@@ -98,8 +86,8 @@ static struct resource udc_resources[] = {
98 .flags = IORESOURCE_MEM, 86 .flags = IORESOURCE_MEM,
99 }, 87 },
100 [1] = { 88 [1] = {
101 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_UDP, 89 .start = AT91SAM9260_ID_UDP,
102 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_UDP, 90 .end = AT91SAM9260_ID_UDP,
103 .flags = IORESOURCE_IRQ, 91 .flags = IORESOURCE_IRQ,
104 }, 92 },
105}; 93};
@@ -119,7 +107,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data)
119 if (!data) 107 if (!data)
120 return; 108 return;
121 109
122 if (gpio_is_valid(data->vbus_pin)) { 110 if (data->vbus_pin) {
123 at91_set_gpio_input(data->vbus_pin, 0); 111 at91_set_gpio_input(data->vbus_pin, 0);
124 at91_set_deglitch(data->vbus_pin, 1); 112 at91_set_deglitch(data->vbus_pin, 1);
125 } 113 }
@@ -140,7 +128,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
140 128
141#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE) 129#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
142static u64 eth_dmamask = DMA_BIT_MASK(32); 130static u64 eth_dmamask = DMA_BIT_MASK(32);
143static struct macb_platform_data eth_data; 131static struct at91_eth_data eth_data;
144 132
145static struct resource eth_resources[] = { 133static struct resource eth_resources[] = {
146 [0] = { 134 [0] = {
@@ -149,8 +137,8 @@ static struct resource eth_resources[] = {
149 .flags = IORESOURCE_MEM, 137 .flags = IORESOURCE_MEM,
150 }, 138 },
151 [1] = { 139 [1] = {
152 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_EMAC, 140 .start = AT91SAM9260_ID_EMAC,
153 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_EMAC, 141 .end = AT91SAM9260_ID_EMAC,
154 .flags = IORESOURCE_IRQ, 142 .flags = IORESOURCE_IRQ,
155 }, 143 },
156}; 144};
@@ -167,12 +155,12 @@ static struct platform_device at91sam9260_eth_device = {
167 .num_resources = ARRAY_SIZE(eth_resources), 155 .num_resources = ARRAY_SIZE(eth_resources),
168}; 156};
169 157
170void __init at91_add_device_eth(struct macb_platform_data *data) 158void __init at91_add_device_eth(struct at91_eth_data *data)
171{ 159{
172 if (!data) 160 if (!data)
173 return; 161 return;
174 162
175 if (gpio_is_valid(data->phy_irq_pin)) { 163 if (data->phy_irq_pin) {
176 at91_set_gpio_input(data->phy_irq_pin, 0); 164 at91_set_gpio_input(data->phy_irq_pin, 0);
177 at91_set_deglitch(data->phy_irq_pin, 1); 165 at91_set_deglitch(data->phy_irq_pin, 1);
178 } 166 }
@@ -204,15 +192,97 @@ void __init at91_add_device_eth(struct macb_platform_data *data)
204 platform_device_register(&at91sam9260_eth_device); 192 platform_device_register(&at91sam9260_eth_device);
205} 193}
206#else 194#else
207void __init at91_add_device_eth(struct macb_platform_data *data) {} 195void __init at91_add_device_eth(struct at91_eth_data *data) {}
208#endif 196#endif
209 197
210 198
211/* -------------------------------------------------------------------- 199/* --------------------------------------------------------------------
200 * MMC / SD
201 * -------------------------------------------------------------------- */
202
203#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
204static u64 mmc_dmamask = DMA_BIT_MASK(32);
205static struct at91_mmc_data mmc_data;
206
207static struct resource mmc_resources[] = {
208 [0] = {
209 .start = AT91SAM9260_BASE_MCI,
210 .end = AT91SAM9260_BASE_MCI + SZ_16K - 1,
211 .flags = IORESOURCE_MEM,
212 },
213 [1] = {
214 .start = AT91SAM9260_ID_MCI,
215 .end = AT91SAM9260_ID_MCI,
216 .flags = IORESOURCE_IRQ,
217 },
218};
219
220static struct platform_device at91sam9260_mmc_device = {
221 .name = "at91_mci",
222 .id = -1,
223 .dev = {
224 .dma_mask = &mmc_dmamask,
225 .coherent_dma_mask = DMA_BIT_MASK(32),
226 .platform_data = &mmc_data,
227 },
228 .resource = mmc_resources,
229 .num_resources = ARRAY_SIZE(mmc_resources),
230};
231
232void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
233{
234 if (!data)
235 return;
236
237 /* input/irq */
238 if (data->det_pin) {
239 at91_set_gpio_input(data->det_pin, 1);
240 at91_set_deglitch(data->det_pin, 1);
241 }
242 if (data->wp_pin)
243 at91_set_gpio_input(data->wp_pin, 1);
244 if (data->vcc_pin)
245 at91_set_gpio_output(data->vcc_pin, 0);
246
247 /* CLK */
248 at91_set_A_periph(AT91_PIN_PA8, 0);
249
250 if (data->slot_b) {
251 /* CMD */
252 at91_set_B_periph(AT91_PIN_PA1, 1);
253
254 /* DAT0, maybe DAT1..DAT3 */
255 at91_set_B_periph(AT91_PIN_PA0, 1);
256 if (data->wire4) {
257 at91_set_B_periph(AT91_PIN_PA5, 1);
258 at91_set_B_periph(AT91_PIN_PA4, 1);
259 at91_set_B_periph(AT91_PIN_PA3, 1);
260 }
261 } else {
262 /* CMD */
263 at91_set_A_periph(AT91_PIN_PA7, 1);
264
265 /* DAT0, maybe DAT1..DAT3 */
266 at91_set_A_periph(AT91_PIN_PA6, 1);
267 if (data->wire4) {
268 at91_set_A_periph(AT91_PIN_PA9, 1);
269 at91_set_A_periph(AT91_PIN_PA10, 1);
270 at91_set_A_periph(AT91_PIN_PA11, 1);
271 }
272 }
273
274 mmc_data = *data;
275 platform_device_register(&at91sam9260_mmc_device);
276}
277#else
278void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
279#endif
280
281/* --------------------------------------------------------------------
212 * MMC / SD Slot for Atmel MCI Driver 282 * MMC / SD Slot for Atmel MCI Driver
213 * -------------------------------------------------------------------- */ 283 * -------------------------------------------------------------------- */
214 284
215#if IS_ENABLED(CONFIG_MMC_ATMELMCI) 285#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
216static u64 mmc_dmamask = DMA_BIT_MASK(32); 286static u64 mmc_dmamask = DMA_BIT_MASK(32);
217static struct mci_platform_data mmc_data; 287static struct mci_platform_data mmc_data;
218 288
@@ -223,8 +293,8 @@ static struct resource mmc_resources[] = {
223 .flags = IORESOURCE_MEM, 293 .flags = IORESOURCE_MEM,
224 }, 294 },
225 [1] = { 295 [1] = {
226 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_MCI, 296 .start = AT91SAM9260_ID_MCI,
227 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_MCI, 297 .end = AT91SAM9260_ID_MCI,
228 .flags = IORESOURCE_IRQ, 298 .flags = IORESOURCE_IRQ,
229 }, 299 },
230}; 300};
@@ -249,14 +319,14 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
249 if (!data) 319 if (!data)
250 return; 320 return;
251 321
252 for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) { 322 for (i = 0; i < ATMEL_MCI_MAX_NR_SLOTS; i++) {
253 if (data->slot[i].bus_width) { 323 if (data->slot[i].bus_width) {
254 /* input/irq */ 324 /* input/irq */
255 if (gpio_is_valid(data->slot[i].detect_pin)) { 325 if (data->slot[i].detect_pin) {
256 at91_set_gpio_input(data->slot[i].detect_pin, 1); 326 at91_set_gpio_input(data->slot[i].detect_pin, 1);
257 at91_set_deglitch(data->slot[i].detect_pin, 1); 327 at91_set_deglitch(data->slot[i].detect_pin, 1);
258 } 328 }
259 if (gpio_is_valid(data->slot[i].wp_pin)) 329 if (data->slot[i].wp_pin)
260 at91_set_gpio_input(data->slot[i].wp_pin, 1); 330 at91_set_gpio_input(data->slot[i].wp_pin, 1);
261 331
262 switch (i) { 332 switch (i) {
@@ -321,8 +391,8 @@ static struct resource nand_resources[] = {
321 .flags = IORESOURCE_MEM, 391 .flags = IORESOURCE_MEM,
322 }, 392 },
323 [1] = { 393 [1] = {
324 .start = AT91SAM9260_BASE_ECC, 394 .start = AT91_BASE_SYS + AT91_ECC,
325 .end = AT91SAM9260_BASE_ECC + SZ_512 - 1, 395 .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
326 .flags = IORESOURCE_MEM, 396 .flags = IORESOURCE_MEM,
327 } 397 }
328}; 398};
@@ -344,19 +414,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
344 if (!data) 414 if (!data)
345 return; 415 return;
346 416
347 csa = at91_matrix_read(AT91_MATRIX_EBICSA); 417 csa = at91_sys_read(AT91_MATRIX_EBICSA);
348 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); 418 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
349 419
350 /* enable pin */ 420 /* enable pin */
351 if (gpio_is_valid(data->enable_pin)) 421 if (data->enable_pin)
352 at91_set_gpio_output(data->enable_pin, 1); 422 at91_set_gpio_output(data->enable_pin, 1);
353 423
354 /* ready/busy pin */ 424 /* ready/busy pin */
355 if (gpio_is_valid(data->rdy_pin)) 425 if (data->rdy_pin)
356 at91_set_gpio_input(data->rdy_pin, 1); 426 at91_set_gpio_input(data->rdy_pin, 1);
357 427
358 /* card detect pin */ 428 /* card detect pin */
359 if (gpio_is_valid(data->det_pin)) 429 if (data->det_pin)
360 at91_set_gpio_input(data->det_pin, 1); 430 at91_set_gpio_input(data->det_pin, 1);
361 431
362 nand_data = *data; 432 nand_data = *data;
@@ -389,7 +459,7 @@ static struct i2c_gpio_platform_data pdata = {
389 459
390static struct platform_device at91sam9260_twi_device = { 460static struct platform_device at91sam9260_twi_device = {
391 .name = "i2c-gpio", 461 .name = "i2c-gpio",
392 .id = 0, 462 .id = -1,
393 .dev.platform_data = &pdata, 463 .dev.platform_data = &pdata,
394}; 464};
395 465
@@ -414,27 +484,21 @@ static struct resource twi_resources[] = {
414 .flags = IORESOURCE_MEM, 484 .flags = IORESOURCE_MEM,
415 }, 485 },
416 [1] = { 486 [1] = {
417 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TWI, 487 .start = AT91SAM9260_ID_TWI,
418 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TWI, 488 .end = AT91SAM9260_ID_TWI,
419 .flags = IORESOURCE_IRQ, 489 .flags = IORESOURCE_IRQ,
420 }, 490 },
421}; 491};
422 492
423static struct platform_device at91sam9260_twi_device = { 493static struct platform_device at91sam9260_twi_device = {
424 .id = 0, 494 .name = "at91_i2c",
495 .id = -1,
425 .resource = twi_resources, 496 .resource = twi_resources,
426 .num_resources = ARRAY_SIZE(twi_resources), 497 .num_resources = ARRAY_SIZE(twi_resources),
427}; 498};
428 499
429void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) 500void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
430{ 501{
431 /* IP version is not the same on 9260 and g20 */
432 if (cpu_is_at91sam9g20()) {
433 at91sam9260_twi_device.name = "i2c-at91sam9g20";
434 } else {
435 at91sam9260_twi_device.name = "i2c-at91sam9260";
436 }
437
438 /* pins used for TWI interface */ 502 /* pins used for TWI interface */
439 at91_set_A_periph(AT91_PIN_PA23, 0); /* TWD */ 503 at91_set_A_periph(AT91_PIN_PA23, 0); /* TWD */
440 at91_set_multi_drive(AT91_PIN_PA23, 1); 504 at91_set_multi_drive(AT91_PIN_PA23, 1);
@@ -464,8 +528,8 @@ static struct resource spi0_resources[] = {
464 .flags = IORESOURCE_MEM, 528 .flags = IORESOURCE_MEM,
465 }, 529 },
466 [1] = { 530 [1] = {
467 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_SPI0, 531 .start = AT91SAM9260_ID_SPI0,
468 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_SPI0, 532 .end = AT91SAM9260_ID_SPI0,
469 .flags = IORESOURCE_IRQ, 533 .flags = IORESOURCE_IRQ,
470 }, 534 },
471}; 535};
@@ -490,8 +554,8 @@ static struct resource spi1_resources[] = {
490 .flags = IORESOURCE_MEM, 554 .flags = IORESOURCE_MEM,
491 }, 555 },
492 [1] = { 556 [1] = {
493 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_SPI1, 557 .start = AT91SAM9260_ID_SPI1,
494 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_SPI1, 558 .end = AT91SAM9260_ID_SPI1,
495 .flags = IORESOURCE_IRQ, 559 .flags = IORESOURCE_IRQ,
496 }, 560 },
497}; 561};
@@ -525,9 +589,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
525 else 589 else
526 cs_pin = spi1_standard_cs[devices[i].chip_select]; 590 cs_pin = spi1_standard_cs[devices[i].chip_select];
527 591
528 if (!gpio_is_valid(cs_pin))
529 continue;
530
531 if (devices[i].bus_num == 0) 592 if (devices[i].bus_num == 0)
532 enable_spi0 = 1; 593 enable_spi0 = 1;
533 else 594 else
@@ -572,22 +633,22 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
572static struct resource tcb0_resources[] = { 633static struct resource tcb0_resources[] = {
573 [0] = { 634 [0] = {
574 .start = AT91SAM9260_BASE_TCB0, 635 .start = AT91SAM9260_BASE_TCB0,
575 .end = AT91SAM9260_BASE_TCB0 + SZ_256 - 1, 636 .end = AT91SAM9260_BASE_TCB0 + SZ_16K - 1,
576 .flags = IORESOURCE_MEM, 637 .flags = IORESOURCE_MEM,
577 }, 638 },
578 [1] = { 639 [1] = {
579 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC0, 640 .start = AT91SAM9260_ID_TC0,
580 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC0, 641 .end = AT91SAM9260_ID_TC0,
581 .flags = IORESOURCE_IRQ, 642 .flags = IORESOURCE_IRQ,
582 }, 643 },
583 [2] = { 644 [2] = {
584 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC1, 645 .start = AT91SAM9260_ID_TC1,
585 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC1, 646 .end = AT91SAM9260_ID_TC1,
586 .flags = IORESOURCE_IRQ, 647 .flags = IORESOURCE_IRQ,
587 }, 648 },
588 [3] = { 649 [3] = {
589 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC2, 650 .start = AT91SAM9260_ID_TC2,
590 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC2, 651 .end = AT91SAM9260_ID_TC2,
591 .flags = IORESOURCE_IRQ, 652 .flags = IORESOURCE_IRQ,
592 }, 653 },
593}; 654};
@@ -602,22 +663,22 @@ static struct platform_device at91sam9260_tcb0_device = {
602static struct resource tcb1_resources[] = { 663static struct resource tcb1_resources[] = {
603 [0] = { 664 [0] = {
604 .start = AT91SAM9260_BASE_TCB1, 665 .start = AT91SAM9260_BASE_TCB1,
605 .end = AT91SAM9260_BASE_TCB1 + SZ_256 - 1, 666 .end = AT91SAM9260_BASE_TCB1 + SZ_16K - 1,
606 .flags = IORESOURCE_MEM, 667 .flags = IORESOURCE_MEM,
607 }, 668 },
608 [1] = { 669 [1] = {
609 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC3, 670 .start = AT91SAM9260_ID_TC3,
610 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC3, 671 .end = AT91SAM9260_ID_TC3,
611 .flags = IORESOURCE_IRQ, 672 .flags = IORESOURCE_IRQ,
612 }, 673 },
613 [2] = { 674 [2] = {
614 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC4, 675 .start = AT91SAM9260_ID_TC4,
615 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC4, 676 .end = AT91SAM9260_ID_TC4,
616 .flags = IORESOURCE_IRQ, 677 .flags = IORESOURCE_IRQ,
617 }, 678 },
618 [3] = { 679 [3] = {
619 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_TC5, 680 .start = AT91SAM9260_ID_TC5,
620 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_TC5, 681 .end = AT91SAM9260_ID_TC5,
621 .flags = IORESOURCE_IRQ, 682 .flags = IORESOURCE_IRQ,
622 }, 683 },
623}; 684};
@@ -645,49 +706,21 @@ static void __init at91_add_device_tc(void) { }
645 706
646static struct resource rtt_resources[] = { 707static struct resource rtt_resources[] = {
647 { 708 {
648 .start = AT91SAM9260_BASE_RTT, 709 .start = AT91_BASE_SYS + AT91_RTT,
649 .end = AT91SAM9260_BASE_RTT + SZ_16 - 1, 710 .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
650 .flags = IORESOURCE_MEM,
651 }, {
652 .flags = IORESOURCE_MEM, 711 .flags = IORESOURCE_MEM,
653 }, { 712 }
654 .flags = IORESOURCE_IRQ,
655 },
656}; 713};
657 714
658static struct platform_device at91sam9260_rtt_device = { 715static struct platform_device at91sam9260_rtt_device = {
659 .name = "at91_rtt", 716 .name = "at91_rtt",
660 .id = 0, 717 .id = 0,
661 .resource = rtt_resources, 718 .resource = rtt_resources,
719 .num_resources = ARRAY_SIZE(rtt_resources),
662}; 720};
663 721
664
665#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
666static void __init at91_add_device_rtt_rtc(void)
667{
668 at91sam9260_rtt_device.name = "rtc-at91sam9";
669 /*
670 * The second resource is needed:
671 * GPBR will serve as the storage for RTC time offset
672 */
673 at91sam9260_rtt_device.num_resources = 3;
674 rtt_resources[1].start = AT91SAM9260_BASE_GPBR +
675 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
676 rtt_resources[1].end = rtt_resources[1].start + 3;
677 rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;
678 rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;
679}
680#else
681static void __init at91_add_device_rtt_rtc(void)
682{
683 /* Only one resource is needed: RTT not used as RTC */
684 at91sam9260_rtt_device.num_resources = 1;
685}
686#endif
687
688static void __init at91_add_device_rtt(void) 722static void __init at91_add_device_rtt(void)
689{ 723{
690 at91_add_device_rtt_rtc();
691 platform_device_register(&at91sam9260_rtt_device); 724 platform_device_register(&at91sam9260_rtt_device);
692} 725}
693 726
@@ -697,19 +730,10 @@ static void __init at91_add_device_rtt(void)
697 * -------------------------------------------------------------------- */ 730 * -------------------------------------------------------------------- */
698 731
699#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) 732#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
700static struct resource wdt_resources[] = {
701 {
702 .start = AT91SAM9260_BASE_WDT,
703 .end = AT91SAM9260_BASE_WDT + SZ_16 - 1,
704 .flags = IORESOURCE_MEM,
705 }
706};
707
708static struct platform_device at91sam9260_wdt_device = { 733static struct platform_device at91sam9260_wdt_device = {
709 .name = "at91_wdt", 734 .name = "at91_wdt",
710 .id = -1, 735 .id = -1,
711 .resource = wdt_resources, 736 .num_resources = 0,
712 .num_resources = ARRAY_SIZE(wdt_resources),
713}; 737};
714 738
715static void __init at91_add_device_watchdog(void) 739static void __init at91_add_device_watchdog(void)
@@ -735,14 +759,14 @@ static struct resource ssc_resources[] = {
735 .flags = IORESOURCE_MEM, 759 .flags = IORESOURCE_MEM,
736 }, 760 },
737 [1] = { 761 [1] = {
738 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_SSC, 762 .start = AT91SAM9260_ID_SSC,
739 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_SSC, 763 .end = AT91SAM9260_ID_SSC,
740 .flags = IORESOURCE_IRQ, 764 .flags = IORESOURCE_IRQ,
741 }, 765 },
742}; 766};
743 767
744static struct platform_device at91sam9260_ssc_device = { 768static struct platform_device at91sam9260_ssc_device = {
745 .name = "at91rm9200_ssc", 769 .name = "ssc",
746 .id = 0, 770 .id = 0,
747 .dev = { 771 .dev = {
748 .dma_mask = &ssc_dmamask, 772 .dma_mask = &ssc_dmamask,
@@ -805,13 +829,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
805#if defined(CONFIG_SERIAL_ATMEL) 829#if defined(CONFIG_SERIAL_ATMEL)
806static struct resource dbgu_resources[] = { 830static struct resource dbgu_resources[] = {
807 [0] = { 831 [0] = {
808 .start = AT91SAM9260_BASE_DBGU, 832 .start = AT91_VA_BASE_SYS + AT91_DBGU,
809 .end = AT91SAM9260_BASE_DBGU + SZ_512 - 1, 833 .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
810 .flags = IORESOURCE_MEM, 834 .flags = IORESOURCE_MEM,
811 }, 835 },
812 [1] = { 836 [1] = {
813 .start = NR_IRQS_LEGACY + AT91_ID_SYS, 837 .start = AT91_ID_SYS,
814 .end = NR_IRQS_LEGACY + AT91_ID_SYS, 838 .end = AT91_ID_SYS,
815 .flags = IORESOURCE_IRQ, 839 .flags = IORESOURCE_IRQ,
816 }, 840 },
817}; 841};
@@ -819,6 +843,7 @@ static struct resource dbgu_resources[] = {
819static struct atmel_uart_data dbgu_data = { 843static struct atmel_uart_data dbgu_data = {
820 .use_dma_tx = 0, 844 .use_dma_tx = 0,
821 .use_dma_rx = 0, /* DBGU not capable of receive DMA */ 845 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
846 .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
822}; 847};
823 848
824static u64 dbgu_dmamask = DMA_BIT_MASK(32); 849static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -848,8 +873,8 @@ static struct resource uart0_resources[] = {
848 .flags = IORESOURCE_MEM, 873 .flags = IORESOURCE_MEM,
849 }, 874 },
850 [1] = { 875 [1] = {
851 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US0, 876 .start = AT91SAM9260_ID_US0,
852 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US0, 877 .end = AT91SAM9260_ID_US0,
853 .flags = IORESOURCE_IRQ, 878 .flags = IORESOURCE_IRQ,
854 }, 879 },
855}; 880};
@@ -899,8 +924,8 @@ static struct resource uart1_resources[] = {
899 .flags = IORESOURCE_MEM, 924 .flags = IORESOURCE_MEM,
900 }, 925 },
901 [1] = { 926 [1] = {
902 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US1, 927 .start = AT91SAM9260_ID_US1,
903 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US1, 928 .end = AT91SAM9260_ID_US1,
904 .flags = IORESOURCE_IRQ, 929 .flags = IORESOURCE_IRQ,
905 }, 930 },
906}; 931};
@@ -942,8 +967,8 @@ static struct resource uart2_resources[] = {
942 .flags = IORESOURCE_MEM, 967 .flags = IORESOURCE_MEM,
943 }, 968 },
944 [1] = { 969 [1] = {
945 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US2, 970 .start = AT91SAM9260_ID_US2,
946 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US2, 971 .end = AT91SAM9260_ID_US2,
947 .flags = IORESOURCE_IRQ, 972 .flags = IORESOURCE_IRQ,
948 }, 973 },
949}; 974};
@@ -985,8 +1010,8 @@ static struct resource uart3_resources[] = {
985 .flags = IORESOURCE_MEM, 1010 .flags = IORESOURCE_MEM,
986 }, 1011 },
987 [1] = { 1012 [1] = {
988 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US3, 1013 .start = AT91SAM9260_ID_US3,
989 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US3, 1014 .end = AT91SAM9260_ID_US3,
990 .flags = IORESOURCE_IRQ, 1015 .flags = IORESOURCE_IRQ,
991 }, 1016 },
992}; 1017};
@@ -1028,8 +1053,8 @@ static struct resource uart4_resources[] = {
1028 .flags = IORESOURCE_MEM, 1053 .flags = IORESOURCE_MEM,
1029 }, 1054 },
1030 [1] = { 1055 [1] = {
1031 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US4, 1056 .start = AT91SAM9260_ID_US4,
1032 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US4, 1057 .end = AT91SAM9260_ID_US4,
1033 .flags = IORESOURCE_IRQ, 1058 .flags = IORESOURCE_IRQ,
1034 }, 1059 },
1035}; 1060};
@@ -1066,8 +1091,8 @@ static struct resource uart5_resources[] = {
1066 .flags = IORESOURCE_MEM, 1091 .flags = IORESOURCE_MEM,
1067 }, 1092 },
1068 [1] = { 1093 [1] = {
1069 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_US5, 1094 .start = AT91SAM9260_ID_US5,
1070 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_US5, 1095 .end = AT91SAM9260_ID_US5,
1071 .flags = IORESOURCE_IRQ, 1096 .flags = IORESOURCE_IRQ,
1072 }, 1097 },
1073}; 1098};
@@ -1098,6 +1123,7 @@ static inline void configure_usart5_pins(void)
1098} 1123}
1099 1124
1100static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1125static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1126struct platform_device *atmel_default_console_device; /* the serial console device */
1101 1127
1102void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1128void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1103{ 1129{
@@ -1143,6 +1169,14 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1143 at91_uarts[portnr] = pdev; 1169 at91_uarts[portnr] = pdev;
1144} 1170}
1145 1171
1172void __init at91_set_serial_console(unsigned portnr)
1173{
1174 if (portnr < ATMEL_MAX_UART) {
1175 atmel_default_console_device = at91_uarts[portnr];
1176 at91sam9260_set_console_clock(at91_uarts[portnr]->id);
1177 }
1178}
1179
1146void __init at91_add_device_serial(void) 1180void __init at91_add_device_serial(void)
1147{ 1181{
1148 int i; 1182 int i;
@@ -1151,9 +1185,13 @@ void __init at91_add_device_serial(void)
1151 if (at91_uarts[i]) 1185 if (at91_uarts[i])
1152 platform_device_register(at91_uarts[i]); 1186 platform_device_register(at91_uarts[i]);
1153 } 1187 }
1188
1189 if (!atmel_default_console_device)
1190 printk(KERN_INFO "AT91: No default serial console defined.\n");
1154} 1191}
1155#else 1192#else
1156void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1193void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1194void __init at91_set_serial_console(unsigned portnr) {}
1157void __init at91_add_device_serial(void) {} 1195void __init at91_add_device_serial(void) {}
1158#endif 1196#endif
1159 1197
@@ -1161,7 +1199,8 @@ void __init at91_add_device_serial(void) {}
1161 * CF/IDE 1199 * CF/IDE
1162 * -------------------------------------------------------------------- */ 1200 * -------------------------------------------------------------------- */
1163 1201
1164#if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \ 1202#if defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE) || \
1203 defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \
1165 defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) 1204 defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
1166 1205
1167static struct at91_cf_data cf0_data; 1206static struct at91_cf_data cf0_data;
@@ -1210,7 +1249,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
1210 if (!data) 1249 if (!data)
1211 return; 1250 return;
1212 1251
1213 csa = at91_matrix_read(AT91_MATRIX_EBICSA); 1252 csa = at91_sys_read(AT91_MATRIX_EBICSA);
1214 1253
1215 switch (data->chipselect) { 1254 switch (data->chipselect) {
1216 case 4: 1255 case 4:
@@ -1233,19 +1272,19 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
1233 return; 1272 return;
1234 } 1273 }
1235 1274
1236 at91_matrix_write(AT91_MATRIX_EBICSA, csa); 1275 at91_sys_write(AT91_MATRIX_EBICSA, csa);
1237 1276
1238 if (gpio_is_valid(data->rst_pin)) { 1277 if (data->rst_pin) {
1239 at91_set_multi_drive(data->rst_pin, 0); 1278 at91_set_multi_drive(data->rst_pin, 0);
1240 at91_set_gpio_output(data->rst_pin, 1); 1279 at91_set_gpio_output(data->rst_pin, 1);
1241 } 1280 }
1242 1281
1243 if (gpio_is_valid(data->irq_pin)) { 1282 if (data->irq_pin) {
1244 at91_set_gpio_input(data->irq_pin, 0); 1283 at91_set_gpio_input(data->irq_pin, 0);
1245 at91_set_deglitch(data->irq_pin, 1); 1284 at91_set_deglitch(data->irq_pin, 1);
1246 } 1285 }
1247 1286
1248 if (gpio_is_valid(data->det_pin)) { 1287 if (data->det_pin) {
1249 at91_set_gpio_input(data->det_pin, 0); 1288 at91_set_gpio_input(data->det_pin, 0);
1250 at91_set_deglitch(data->det_pin, 1); 1289 at91_set_deglitch(data->det_pin, 1);
1251 } 1290 }
@@ -1258,8 +1297,10 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
1258 if (data->flags & AT91_CF_TRUE_IDE) 1297 if (data->flags & AT91_CF_TRUE_IDE)
1259#if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) 1298#if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE)
1260 pdev->name = "pata_at91"; 1299 pdev->name = "pata_at91";
1300#elif defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE)
1301 pdev->name = "at91_ide";
1261#else 1302#else
1262#warning "board requires AT91_CF_TRUE_IDE: enable pata_at91" 1303#warning "board requires AT91_CF_TRUE_IDE: enable either at91_ide or pata_at91"
1263#endif 1304#endif
1264 else 1305 else
1265 pdev->name = "at91_cf"; 1306 pdev->name = "at91_cf";
@@ -1271,93 +1312,6 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
1271void __init at91_add_device_cf(struct at91_cf_data * data) {} 1312void __init at91_add_device_cf(struct at91_cf_data * data) {}
1272#endif 1313#endif
1273 1314
1274/* --------------------------------------------------------------------
1275 * ADCs
1276 * -------------------------------------------------------------------- */
1277
1278#if IS_ENABLED(CONFIG_AT91_ADC)
1279static struct at91_adc_data adc_data;
1280
1281static struct resource adc_resources[] = {
1282 [0] = {
1283 .start = AT91SAM9260_BASE_ADC,
1284 .end = AT91SAM9260_BASE_ADC + SZ_16K - 1,
1285 .flags = IORESOURCE_MEM,
1286 },
1287 [1] = {
1288 .start = NR_IRQS_LEGACY + AT91SAM9260_ID_ADC,
1289 .end = NR_IRQS_LEGACY + AT91SAM9260_ID_ADC,
1290 .flags = IORESOURCE_IRQ,
1291 },
1292};
1293
1294static struct platform_device at91_adc_device = {
1295 .name = "at91_adc",
1296 .id = -1,
1297 .dev = {
1298 .platform_data = &adc_data,
1299 },
1300 .resource = adc_resources,
1301 .num_resources = ARRAY_SIZE(adc_resources),
1302};
1303
1304static struct at91_adc_trigger at91_adc_triggers[] = {
1305 [0] = {
1306 .name = "timer-counter-0",
1307 .value = AT91_ADC_TRGSEL_TC0 | AT91_ADC_TRGEN,
1308 },
1309 [1] = {
1310 .name = "timer-counter-1",
1311 .value = AT91_ADC_TRGSEL_TC1 | AT91_ADC_TRGEN,
1312 },
1313 [2] = {
1314 .name = "timer-counter-2",
1315 .value = AT91_ADC_TRGSEL_TC2 | AT91_ADC_TRGEN,
1316 },
1317 [3] = {
1318 .name = "external",
1319 .value = AT91_ADC_TRGSEL_EXTERNAL | AT91_ADC_TRGEN,
1320 .is_external = true,
1321 },
1322};
1323
1324static struct at91_adc_reg_desc at91_adc_register_g20 = {
1325 .channel_base = AT91_ADC_CHR(0),
1326 .drdy_mask = AT91_ADC_DRDY,
1327 .status_register = AT91_ADC_SR,
1328 .trigger_register = AT91_ADC_MR,
1329};
1330
1331void __init at91_add_device_adc(struct at91_adc_data *data)
1332{
1333 if (!data)
1334 return;
1335
1336 if (test_bit(0, &data->channels_used))
1337 at91_set_A_periph(AT91_PIN_PC0, 0);
1338 if (test_bit(1, &data->channels_used))
1339 at91_set_A_periph(AT91_PIN_PC1, 0);
1340 if (test_bit(2, &data->channels_used))
1341 at91_set_A_periph(AT91_PIN_PC2, 0);
1342 if (test_bit(3, &data->channels_used))
1343 at91_set_A_periph(AT91_PIN_PC3, 0);
1344
1345 if (data->use_external_triggers)
1346 at91_set_A_periph(AT91_PIN_PA22, 0);
1347
1348 data->num_channels = 4;
1349 data->startup_time = 10;
1350 data->registers = &at91_adc_register_g20;
1351 data->trigger_number = 4;
1352 data->trigger_list = at91_adc_triggers;
1353
1354 adc_data = *data;
1355 platform_device_register(&at91_adc_device);
1356}
1357#else
1358void __init at91_add_device_adc(struct at91_adc_data *data) {}
1359#endif
1360
1361/* -------------------------------------------------------------------- */ 1315/* -------------------------------------------------------------------- */
1362/* 1316/*
1363 * These devices are always present and don't need any board-specific 1317 * These devices are always present and don't need any board-specific
@@ -1365,9 +1319,6 @@ void __init at91_add_device_adc(struct at91_adc_data *data) {}
1365 */ 1319 */
1366static int __init at91_add_standard_devices(void) 1320static int __init at91_add_standard_devices(void)
1367{ 1321{
1368 if (of_have_populated_dt())
1369 return 0;
1370
1371 at91_add_device_rtt(); 1322 at91_add_device_rtt();
1372 at91_add_device_watchdog(); 1323 at91_add_device_watchdog();
1373 at91_add_device_tc(); 1324 at91_add_device_tc();
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 2998a08afc2..6c8e3b5f669 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -11,22 +11,20 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pm.h>
14 15
15#include <asm/proc-fns.h>
16#include <asm/irq.h> 16#include <asm/irq.h>
17#include <asm/mach/arch.h> 17#include <asm/mach/arch.h>
18#include <asm/mach/map.h> 18#include <asm/mach/map.h>
19#include <asm/system_misc.h>
20#include <mach/cpu.h> 19#include <mach/cpu.h>
21#include <mach/at91sam9261.h> 20#include <mach/at91sam9261.h>
22#include <mach/at91_pmc.h> 21#include <mach/at91_pmc.h>
22#include <mach/at91_rstc.h>
23#include <mach/at91_shdwc.h>
23 24
24#include "at91_aic.h"
25#include "at91_rstc.h"
26#include "soc.h" 25#include "soc.h"
27#include "generic.h" 26#include "generic.h"
28#include "clock.h" 27#include "clock.h"
29#include "sam9_smc.h"
30 28
31/* -------------------------------------------------------------------- 29/* --------------------------------------------------------------------
32 * Clocks 30 * Clocks
@@ -131,20 +129,6 @@ static struct clk lcdc_clk = {
131 .type = CLK_TYPE_PERIPHERAL, 129 .type = CLK_TYPE_PERIPHERAL,
132}; 130};
133 131
134/* HClocks */
135static struct clk hck0 = {
136 .name = "hck0",
137 .pmc_mask = AT91_PMC_HCK0,
138 .type = CLK_TYPE_SYSTEM,
139 .id = 0,
140};
141static struct clk hck1 = {
142 .name = "hck1",
143 .pmc_mask = AT91_PMC_HCK1,
144 .type = CLK_TYPE_SYSTEM,
145 .id = 1,
146};
147
148static struct clk *periph_clocks[] __initdata = { 132static struct clk *periph_clocks[] __initdata = {
149 &pioA_clk, 133 &pioA_clk,
150 &pioB_clk, 134 &pioB_clk,
@@ -174,18 +158,9 @@ static struct clk_lookup periph_clocks_lookups[] = {
174 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), 158 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk),
175 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), 159 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk),
176 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), 160 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk),
177 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk), 161 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
178 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk), 162 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
179 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.2", &ssc2_clk), 163 CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk),
180 CLKDEV_CON_DEV_ID("pclk", "fffbc000.ssc", &ssc0_clk),
181 CLKDEV_CON_DEV_ID("pclk", "fffc0000.ssc", &ssc1_clk),
182 CLKDEV_CON_DEV_ID("pclk", "fffc4000.ssc", &ssc2_clk),
183 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &hck0),
184 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9261.0", &twi_clk),
185 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi_clk),
186 CLKDEV_CON_ID("pioA", &pioA_clk),
187 CLKDEV_CON_ID("pioB", &pioB_clk),
188 CLKDEV_CON_ID("pioC", &pioC_clk),
189}; 164};
190 165
191static struct clk_lookup usart_clocks_lookups[] = { 166static struct clk_lookup usart_clocks_lookups[] = {
@@ -224,6 +199,20 @@ static struct clk pck3 = {
224 .id = 3, 199 .id = 3,
225}; 200};
226 201
202/* HClocks */
203static struct clk hck0 = {
204 .name = "hck0",
205 .pmc_mask = AT91_PMC_HCK0,
206 .type = CLK_TYPE_SYSTEM,
207 .id = 0,
208};
209static struct clk hck1 = {
210 .name = "hck1",
211 .pmc_mask = AT91_PMC_HCK1,
212 .type = CLK_TYPE_SYSTEM,
213 .id = 1,
214};
215
227static void __init at91sam9261_register_clocks(void) 216static void __init at91sam9261_register_clocks(void)
228{ 217{
229 int i; 218 int i;
@@ -245,23 +234,44 @@ static void __init at91sam9261_register_clocks(void)
245 clk_register(&hck1); 234 clk_register(&hck1);
246} 235}
247 236
237static struct clk_lookup console_clock_lookup;
238
239void __init at91sam9261_set_console_clock(int id)
240{
241 if (id >= ARRAY_SIZE(usart_clocks_lookups))
242 return;
243
244 console_clock_lookup.con_id = "usart";
245 console_clock_lookup.clk = usart_clocks_lookups[id].clk;
246 clkdev_add(&console_clock_lookup);
247}
248
248/* -------------------------------------------------------------------- 249/* --------------------------------------------------------------------
249 * GPIO 250 * GPIO
250 * -------------------------------------------------------------------- */ 251 * -------------------------------------------------------------------- */
251 252
252static struct at91_gpio_bank at91sam9261_gpio[] __initdata = { 253static struct at91_gpio_bank at91sam9261_gpio[] = {
253 { 254 {
254 .id = AT91SAM9261_ID_PIOA, 255 .id = AT91SAM9261_ID_PIOA,
255 .regbase = AT91SAM9261_BASE_PIOA, 256 .offset = AT91_PIOA,
257 .clock = &pioA_clk,
256 }, { 258 }, {
257 .id = AT91SAM9261_ID_PIOB, 259 .id = AT91SAM9261_ID_PIOB,
258 .regbase = AT91SAM9261_BASE_PIOB, 260 .offset = AT91_PIOB,
261 .clock = &pioB_clk,
259 }, { 262 }, {
260 .id = AT91SAM9261_ID_PIOC, 263 .id = AT91SAM9261_ID_PIOC,
261 .regbase = AT91SAM9261_BASE_PIOC, 264 .offset = AT91_PIOC,
265 .clock = &pioC_clk,
262 } 266 }
263}; 267};
264 268
269static void at91sam9261_poweroff(void)
270{
271 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
272}
273
274
265/* -------------------------------------------------------------------- 275/* --------------------------------------------------------------------
266 * AT91SAM9261 processor initialization 276 * AT91SAM9261 processor initialization
267 * -------------------------------------------------------------------- */ 277 * -------------------------------------------------------------------- */
@@ -274,20 +284,10 @@ static void __init at91sam9261_map_io(void)
274 at91_init_sram(0, AT91SAM9261_SRAM_BASE, AT91SAM9261_SRAM_SIZE); 284 at91_init_sram(0, AT91SAM9261_SRAM_BASE, AT91SAM9261_SRAM_SIZE);
275} 285}
276 286
277static void __init at91sam9261_ioremap_registers(void)
278{
279 at91_ioremap_shdwc(AT91SAM9261_BASE_SHDWC);
280 at91_ioremap_rstc(AT91SAM9261_BASE_RSTC);
281 at91_ioremap_ramc(0, AT91SAM9261_BASE_SDRAMC, 512);
282 at91sam926x_ioremap_pit(AT91SAM9261_BASE_PIT);
283 at91sam9_ioremap_smc(0, AT91SAM9261_BASE_SMC);
284 at91_ioremap_matrix(AT91SAM9261_BASE_MATRIX);
285}
286
287static void __init at91sam9261_initialize(void) 287static void __init at91sam9261_initialize(void)
288{ 288{
289 arm_pm_idle = at91sam9_idle; 289 at91_arch_reset = at91sam9_alt_reset;
290 arm_pm_restart = at91sam9_alt_restart; 290 pm_power_off = at91sam9261_poweroff;
291 at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1) 291 at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1)
292 | (1 << AT91SAM9261_ID_IRQ2); 292 | (1 << AT91SAM9261_ID_IRQ2);
293 293
@@ -337,10 +337,9 @@ static unsigned int at91sam9261_default_irq_priority[NR_AIC_IRQS] __initdata = {
337 0, /* Advanced Interrupt Controller */ 337 0, /* Advanced Interrupt Controller */
338}; 338};
339 339
340AT91_SOC_START(sam9261) 340struct at91_init_soc __initdata at91sam9261_soc = {
341 .map_io = at91sam9261_map_io, 341 .map_io = at91sam9261_map_io,
342 .default_irq_priority = at91sam9261_default_irq_priority, 342 .default_irq_priority = at91sam9261_default_irq_priority,
343 .ioremap_registers = at91sam9261_ioremap_registers,
344 .register_clocks = at91sam9261_register_clocks, 343 .register_clocks = at91sam9261_register_clocks,
345 .init = at91sam9261_initialize, 344 .init = at91sam9261_initialize,
346AT91_SOC_END 345};
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 92e0f861084..9e113f60d25 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -14,19 +14,18 @@
14#include <asm/mach/map.h> 14#include <asm/mach/map.h>
15 15
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <linux/gpio.h>
18#include <linux/platform_device.h> 17#include <linux/platform_device.h>
19#include <linux/i2c-gpio.h> 18#include <linux/i2c-gpio.h>
20 19
21#include <linux/fb.h> 20#include <linux/fb.h>
22#include <video/atmel_lcdc.h> 21#include <video/atmel_lcdc.h>
23 22
23#include <mach/board.h>
24#include <mach/gpio.h>
24#include <mach/at91sam9261.h> 25#include <mach/at91sam9261.h>
25#include <mach/at91sam9261_matrix.h> 26#include <mach/at91sam9261_matrix.h>
26#include <mach/at91_matrix.h>
27#include <mach/at91sam9_smc.h> 27#include <mach/at91sam9_smc.h>
28 28
29#include "board.h"
30#include "generic.h" 29#include "generic.h"
31 30
32 31
@@ -45,8 +44,8 @@ static struct resource usbh_resources[] = {
45 .flags = IORESOURCE_MEM, 44 .flags = IORESOURCE_MEM,
46 }, 45 },
47 [1] = { 46 [1] = {
48 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_UHP, 47 .start = AT91SAM9261_ID_UHP,
49 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_UHP, 48 .end = AT91SAM9261_ID_UHP,
50 .flags = IORESOURCE_IRQ, 49 .flags = IORESOURCE_IRQ,
51 }, 50 },
52}; 51};
@@ -65,17 +64,9 @@ static struct platform_device at91sam9261_usbh_device = {
65 64
66void __init at91_add_device_usbh(struct at91_usbh_data *data) 65void __init at91_add_device_usbh(struct at91_usbh_data *data)
67{ 66{
68 int i;
69
70 if (!data) 67 if (!data)
71 return; 68 return;
72 69
73 /* Enable overcurrent notification */
74 for (i = 0; i < data->ports; i++) {
75 if (gpio_is_valid(data->overcurrent_pin[i]))
76 at91_set_gpio_input(data->overcurrent_pin[i], 1);
77 }
78
79 usbh_data = *data; 70 usbh_data = *data;
80 platform_device_register(&at91sam9261_usbh_device); 71 platform_device_register(&at91sam9261_usbh_device);
81} 72}
@@ -88,7 +79,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
88 * USB Device (Gadget) 79 * USB Device (Gadget)
89 * -------------------------------------------------------------------- */ 80 * -------------------------------------------------------------------- */
90 81
91#if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE) 82#ifdef CONFIG_USB_AT91
92static struct at91_udc_data udc_data; 83static struct at91_udc_data udc_data;
93 84
94static struct resource udc_resources[] = { 85static struct resource udc_resources[] = {
@@ -98,8 +89,8 @@ static struct resource udc_resources[] = {
98 .flags = IORESOURCE_MEM, 89 .flags = IORESOURCE_MEM,
99 }, 90 },
100 [1] = { 91 [1] = {
101 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_UDP, 92 .start = AT91SAM9261_ID_UDP,
102 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_UDP, 93 .end = AT91SAM9261_ID_UDP,
103 .flags = IORESOURCE_IRQ, 94 .flags = IORESOURCE_IRQ,
104 }, 95 },
105}; 96};
@@ -119,7 +110,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data)
119 if (!data) 110 if (!data)
120 return; 111 return;
121 112
122 if (gpio_is_valid(data->vbus_pin)) { 113 if (data->vbus_pin) {
123 at91_set_gpio_input(data->vbus_pin, 0); 114 at91_set_gpio_input(data->vbus_pin, 0);
124 at91_set_deglitch(data->vbus_pin, 1); 115 at91_set_deglitch(data->vbus_pin, 1);
125 } 116 }
@@ -137,9 +128,9 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
137 * MMC / SD 128 * MMC / SD
138 * -------------------------------------------------------------------- */ 129 * -------------------------------------------------------------------- */
139 130
140#if IS_ENABLED(CONFIG_MMC_ATMELMCI) 131#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
141static u64 mmc_dmamask = DMA_BIT_MASK(32); 132static u64 mmc_dmamask = DMA_BIT_MASK(32);
142static struct mci_platform_data mmc_data; 133static struct at91_mmc_data mmc_data;
143 134
144static struct resource mmc_resources[] = { 135static struct resource mmc_resources[] = {
145 [0] = { 136 [0] = {
@@ -148,14 +139,14 @@ static struct resource mmc_resources[] = {
148 .flags = IORESOURCE_MEM, 139 .flags = IORESOURCE_MEM,
149 }, 140 },
150 [1] = { 141 [1] = {
151 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_MCI, 142 .start = AT91SAM9261_ID_MCI,
152 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_MCI, 143 .end = AT91SAM9261_ID_MCI,
153 .flags = IORESOURCE_IRQ, 144 .flags = IORESOURCE_IRQ,
154 }, 145 },
155}; 146};
156 147
157static struct platform_device at91sam9261_mmc_device = { 148static struct platform_device at91sam9261_mmc_device = {
158 .name = "atmel_mci", 149 .name = "at91_mci",
159 .id = -1, 150 .id = -1,
160 .dev = { 151 .dev = {
161 .dma_mask = &mmc_dmamask, 152 .dma_mask = &mmc_dmamask,
@@ -166,40 +157,40 @@ static struct platform_device at91sam9261_mmc_device = {
166 .num_resources = ARRAY_SIZE(mmc_resources), 157 .num_resources = ARRAY_SIZE(mmc_resources),
167}; 158};
168 159
169void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) 160void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
170{ 161{
171 if (!data) 162 if (!data)
172 return; 163 return;
173 164
174 if (data->slot[0].bus_width) { 165 /* input/irq */
175 /* input/irq */ 166 if (data->det_pin) {
176 if (gpio_is_valid(data->slot[0].detect_pin)) { 167 at91_set_gpio_input(data->det_pin, 1);
177 at91_set_gpio_input(data->slot[0].detect_pin, 1); 168 at91_set_deglitch(data->det_pin, 1);
178 at91_set_deglitch(data->slot[0].detect_pin, 1);
179 }
180 if (gpio_is_valid(data->slot[0].wp_pin))
181 at91_set_gpio_input(data->slot[0].wp_pin, 1);
182
183 /* CLK */
184 at91_set_B_periph(AT91_PIN_PA2, 0);
185
186 /* CMD */
187 at91_set_B_periph(AT91_PIN_PA1, 1);
188
189 /* DAT0, maybe DAT1..DAT3 */
190 at91_set_B_periph(AT91_PIN_PA0, 1);
191 if (data->slot[0].bus_width == 4) {
192 at91_set_B_periph(AT91_PIN_PA4, 1);
193 at91_set_B_periph(AT91_PIN_PA5, 1);
194 at91_set_B_periph(AT91_PIN_PA6, 1);
195 }
196
197 mmc_data = *data;
198 platform_device_register(&at91sam9261_mmc_device);
199 } 169 }
170 if (data->wp_pin)
171 at91_set_gpio_input(data->wp_pin, 1);
172 if (data->vcc_pin)
173 at91_set_gpio_output(data->vcc_pin, 0);
174
175 /* CLK */
176 at91_set_B_periph(AT91_PIN_PA2, 0);
177
178 /* CMD */
179 at91_set_B_periph(AT91_PIN_PA1, 1);
180
181 /* DAT0, maybe DAT1..DAT3 */
182 at91_set_B_periph(AT91_PIN_PA0, 1);
183 if (data->wire4) {
184 at91_set_B_periph(AT91_PIN_PA4, 1);
185 at91_set_B_periph(AT91_PIN_PA5, 1);
186 at91_set_B_periph(AT91_PIN_PA6, 1);
187 }
188
189 mmc_data = *data;
190 platform_device_register(&at91sam9261_mmc_device);
200} 191}
201#else 192#else
202void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {} 193void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
203#endif 194#endif
204 195
205 196
@@ -237,19 +228,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
237 if (!data) 228 if (!data)
238 return; 229 return;
239 230
240 csa = at91_matrix_read(AT91_MATRIX_EBICSA); 231 csa = at91_sys_read(AT91_MATRIX_EBICSA);
241 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); 232 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
242 233
243 /* enable pin */ 234 /* enable pin */
244 if (gpio_is_valid(data->enable_pin)) 235 if (data->enable_pin)
245 at91_set_gpio_output(data->enable_pin, 1); 236 at91_set_gpio_output(data->enable_pin, 1);
246 237
247 /* ready/busy pin */ 238 /* ready/busy pin */
248 if (gpio_is_valid(data->rdy_pin)) 239 if (data->rdy_pin)
249 at91_set_gpio_input(data->rdy_pin, 1); 240 at91_set_gpio_input(data->rdy_pin, 1);
250 241
251 /* card detect pin */ 242 /* card detect pin */
252 if (gpio_is_valid(data->det_pin)) 243 if (data->det_pin)
253 at91_set_gpio_input(data->det_pin, 1); 244 at91_set_gpio_input(data->det_pin, 1);
254 245
255 at91_set_A_periph(AT91_PIN_PC0, 0); /* NANDOE */ 246 at91_set_A_periph(AT91_PIN_PC0, 0); /* NANDOE */
@@ -285,7 +276,7 @@ static struct i2c_gpio_platform_data pdata = {
285 276
286static struct platform_device at91sam9261_twi_device = { 277static struct platform_device at91sam9261_twi_device = {
287 .name = "i2c-gpio", 278 .name = "i2c-gpio",
288 .id = 0, 279 .id = -1,
289 .dev.platform_data = &pdata, 280 .dev.platform_data = &pdata,
290}; 281};
291 282
@@ -310,33 +301,27 @@ static struct resource twi_resources[] = {
310 .flags = IORESOURCE_MEM, 301 .flags = IORESOURCE_MEM,
311 }, 302 },
312 [1] = { 303 [1] = {
313 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TWI, 304 .start = AT91SAM9261_ID_TWI,
314 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TWI, 305 .end = AT91SAM9261_ID_TWI,
315 .flags = IORESOURCE_IRQ, 306 .flags = IORESOURCE_IRQ,
316 }, 307 },
317}; 308};
318 309
319static struct platform_device at91sam9261_twi_device = { 310static struct platform_device at91sam9261_twi_device = {
320 .id = 0, 311 .name = "at91_i2c",
312 .id = -1,
321 .resource = twi_resources, 313 .resource = twi_resources,
322 .num_resources = ARRAY_SIZE(twi_resources), 314 .num_resources = ARRAY_SIZE(twi_resources),
323}; 315};
324 316
325void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) 317void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
326{ 318{
327 /* IP version is not the same on 9261 and g10 */
328 if (cpu_is_at91sam9g10()) {
329 at91sam9261_twi_device.name = "i2c-at91sam9g10";
330 /* I2C PIO must not be configured as open-drain on this chip */
331 } else {
332 at91sam9261_twi_device.name = "i2c-at91sam9261";
333 at91_set_multi_drive(AT91_PIN_PA7, 1);
334 at91_set_multi_drive(AT91_PIN_PA8, 1);
335 }
336
337 /* pins used for TWI interface */ 319 /* pins used for TWI interface */
338 at91_set_A_periph(AT91_PIN_PA7, 0); /* TWD */ 320 at91_set_A_periph(AT91_PIN_PA7, 0); /* TWD */
321 at91_set_multi_drive(AT91_PIN_PA7, 1);
322
339 at91_set_A_periph(AT91_PIN_PA8, 0); /* TWCK */ 323 at91_set_A_periph(AT91_PIN_PA8, 0); /* TWCK */
324 at91_set_multi_drive(AT91_PIN_PA8, 1);
340 325
341 i2c_register_board_info(0, devices, nr_devices); 326 i2c_register_board_info(0, devices, nr_devices);
342 platform_device_register(&at91sam9261_twi_device); 327 platform_device_register(&at91sam9261_twi_device);
@@ -360,8 +345,8 @@ static struct resource spi0_resources[] = {
360 .flags = IORESOURCE_MEM, 345 .flags = IORESOURCE_MEM,
361 }, 346 },
362 [1] = { 347 [1] = {
363 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI0, 348 .start = AT91SAM9261_ID_SPI0,
364 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI0, 349 .end = AT91SAM9261_ID_SPI0,
365 .flags = IORESOURCE_IRQ, 350 .flags = IORESOURCE_IRQ,
366 }, 351 },
367}; 352};
@@ -386,8 +371,8 @@ static struct resource spi1_resources[] = {
386 .flags = IORESOURCE_MEM, 371 .flags = IORESOURCE_MEM,
387 }, 372 },
388 [1] = { 373 [1] = {
389 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI1, 374 .start = AT91SAM9261_ID_SPI1,
390 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SPI1, 375 .end = AT91SAM9261_ID_SPI1,
391 .flags = IORESOURCE_IRQ, 376 .flags = IORESOURCE_IRQ,
392 }, 377 },
393}; 378};
@@ -421,9 +406,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
421 else 406 else
422 cs_pin = spi1_standard_cs[devices[i].chip_select]; 407 cs_pin = spi1_standard_cs[devices[i].chip_select];
423 408
424 if (!gpio_is_valid(cs_pin))
425 continue;
426
427 if (devices[i].bus_num == 0) 409 if (devices[i].bus_num == 0)
428 enable_spi0 = 1; 410 enable_spi0 = 1;
429 else 411 else
@@ -474,8 +456,8 @@ static struct resource lcdc_resources[] = {
474 .flags = IORESOURCE_MEM, 456 .flags = IORESOURCE_MEM,
475 }, 457 },
476 [1] = { 458 [1] = {
477 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_LCDC, 459 .start = AT91SAM9261_ID_LCDC,
478 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_LCDC, 460 .end = AT91SAM9261_ID_LCDC,
479 .flags = IORESOURCE_IRQ, 461 .flags = IORESOURCE_IRQ,
480 }, 462 },
481#if defined(CONFIG_FB_INTSRAM) 463#if defined(CONFIG_FB_INTSRAM)
@@ -572,18 +554,18 @@ static struct resource tcb_resources[] = {
572 .flags = IORESOURCE_MEM, 554 .flags = IORESOURCE_MEM,
573 }, 555 },
574 [1] = { 556 [1] = {
575 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TC0, 557 .start = AT91SAM9261_ID_TC0,
576 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TC0, 558 .end = AT91SAM9261_ID_TC0,
577 .flags = IORESOURCE_IRQ, 559 .flags = IORESOURCE_IRQ,
578 }, 560 },
579 [2] = { 561 [2] = {
580 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TC1, 562 .start = AT91SAM9261_ID_TC1,
581 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TC1, 563 .end = AT91SAM9261_ID_TC1,
582 .flags = IORESOURCE_IRQ, 564 .flags = IORESOURCE_IRQ,
583 }, 565 },
584 [3] = { 566 [3] = {
585 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_TC2, 567 .start = AT91SAM9261_ID_TC2,
586 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_TC2, 568 .end = AT91SAM9261_ID_TC2,
587 .flags = IORESOURCE_IRQ, 569 .flags = IORESOURCE_IRQ,
588 }, 570 },
589}; 571};
@@ -610,13 +592,9 @@ static void __init at91_add_device_tc(void) { }
610 592
611static struct resource rtt_resources[] = { 593static struct resource rtt_resources[] = {
612 { 594 {
613 .start = AT91SAM9261_BASE_RTT, 595 .start = AT91_BASE_SYS + AT91_RTT,
614 .end = AT91SAM9261_BASE_RTT + SZ_16 - 1, 596 .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
615 .flags = IORESOURCE_MEM, 597 .flags = IORESOURCE_MEM,
616 }, {
617 .flags = IORESOURCE_MEM,
618 }, {
619 .flags = IORESOURCE_IRQ,
620 } 598 }
621}; 599};
622 600
@@ -624,34 +602,11 @@ static struct platform_device at91sam9261_rtt_device = {
624 .name = "at91_rtt", 602 .name = "at91_rtt",
625 .id = 0, 603 .id = 0,
626 .resource = rtt_resources, 604 .resource = rtt_resources,
605 .num_resources = ARRAY_SIZE(rtt_resources),
627}; 606};
628 607
629#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
630static void __init at91_add_device_rtt_rtc(void)
631{
632 at91sam9261_rtt_device.name = "rtc-at91sam9";
633 /*
634 * The second resource is needed:
635 * GPBR will serve as the storage for RTC time offset
636 */
637 at91sam9261_rtt_device.num_resources = 3;
638 rtt_resources[1].start = AT91SAM9261_BASE_GPBR +
639 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
640 rtt_resources[1].end = rtt_resources[1].start + 3;
641 rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;
642 rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;
643}
644#else
645static void __init at91_add_device_rtt_rtc(void)
646{
647 /* Only one resource is needed: RTT not used as RTC */
648 at91sam9261_rtt_device.num_resources = 1;
649}
650#endif
651
652static void __init at91_add_device_rtt(void) 608static void __init at91_add_device_rtt(void)
653{ 609{
654 at91_add_device_rtt_rtc();
655 platform_device_register(&at91sam9261_rtt_device); 610 platform_device_register(&at91sam9261_rtt_device);
656} 611}
657 612
@@ -661,19 +616,10 @@ static void __init at91_add_device_rtt(void)
661 * -------------------------------------------------------------------- */ 616 * -------------------------------------------------------------------- */
662 617
663#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) 618#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
664static struct resource wdt_resources[] = {
665 {
666 .start = AT91SAM9261_BASE_WDT,
667 .end = AT91SAM9261_BASE_WDT + SZ_16 - 1,
668 .flags = IORESOURCE_MEM,
669 }
670};
671
672static struct platform_device at91sam9261_wdt_device = { 619static struct platform_device at91sam9261_wdt_device = {
673 .name = "at91_wdt", 620 .name = "at91_wdt",
674 .id = -1, 621 .id = -1,
675 .resource = wdt_resources, 622 .num_resources = 0,
676 .num_resources = ARRAY_SIZE(wdt_resources),
677}; 623};
678 624
679static void __init at91_add_device_watchdog(void) 625static void __init at91_add_device_watchdog(void)
@@ -699,14 +645,14 @@ static struct resource ssc0_resources[] = {
699 .flags = IORESOURCE_MEM, 645 .flags = IORESOURCE_MEM,
700 }, 646 },
701 [1] = { 647 [1] = {
702 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC0, 648 .start = AT91SAM9261_ID_SSC0,
703 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC0, 649 .end = AT91SAM9261_ID_SSC0,
704 .flags = IORESOURCE_IRQ, 650 .flags = IORESOURCE_IRQ,
705 }, 651 },
706}; 652};
707 653
708static struct platform_device at91sam9261_ssc0_device = { 654static struct platform_device at91sam9261_ssc0_device = {
709 .name = "at91rm9200_ssc", 655 .name = "ssc",
710 .id = 0, 656 .id = 0,
711 .dev = { 657 .dev = {
712 .dma_mask = &ssc0_dmamask, 658 .dma_mask = &ssc0_dmamask,
@@ -741,14 +687,14 @@ static struct resource ssc1_resources[] = {
741 .flags = IORESOURCE_MEM, 687 .flags = IORESOURCE_MEM,
742 }, 688 },
743 [1] = { 689 [1] = {
744 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC1, 690 .start = AT91SAM9261_ID_SSC1,
745 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC1, 691 .end = AT91SAM9261_ID_SSC1,
746 .flags = IORESOURCE_IRQ, 692 .flags = IORESOURCE_IRQ,
747 }, 693 },
748}; 694};
749 695
750static struct platform_device at91sam9261_ssc1_device = { 696static struct platform_device at91sam9261_ssc1_device = {
751 .name = "at91rm9200_ssc", 697 .name = "ssc",
752 .id = 1, 698 .id = 1,
753 .dev = { 699 .dev = {
754 .dma_mask = &ssc1_dmamask, 700 .dma_mask = &ssc1_dmamask,
@@ -783,14 +729,14 @@ static struct resource ssc2_resources[] = {
783 .flags = IORESOURCE_MEM, 729 .flags = IORESOURCE_MEM,
784 }, 730 },
785 [1] = { 731 [1] = {
786 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC2, 732 .start = AT91SAM9261_ID_SSC2,
787 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_SSC2, 733 .end = AT91SAM9261_ID_SSC2,
788 .flags = IORESOURCE_IRQ, 734 .flags = IORESOURCE_IRQ,
789 }, 735 },
790}; 736};
791 737
792static struct platform_device at91sam9261_ssc2_device = { 738static struct platform_device at91sam9261_ssc2_device = {
793 .name = "at91rm9200_ssc", 739 .name = "ssc",
794 .id = 2, 740 .id = 2,
795 .dev = { 741 .dev = {
796 .dma_mask = &ssc2_dmamask, 742 .dma_mask = &ssc2_dmamask,
@@ -862,13 +808,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
862#if defined(CONFIG_SERIAL_ATMEL) 808#if defined(CONFIG_SERIAL_ATMEL)
863static struct resource dbgu_resources[] = { 809static struct resource dbgu_resources[] = {
864 [0] = { 810 [0] = {
865 .start = AT91SAM9261_BASE_DBGU, 811 .start = AT91_VA_BASE_SYS + AT91_DBGU,
866 .end = AT91SAM9261_BASE_DBGU + SZ_512 - 1, 812 .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
867 .flags = IORESOURCE_MEM, 813 .flags = IORESOURCE_MEM,
868 }, 814 },
869 [1] = { 815 [1] = {
870 .start = NR_IRQS_LEGACY + AT91_ID_SYS, 816 .start = AT91_ID_SYS,
871 .end = NR_IRQS_LEGACY + AT91_ID_SYS, 817 .end = AT91_ID_SYS,
872 .flags = IORESOURCE_IRQ, 818 .flags = IORESOURCE_IRQ,
873 }, 819 },
874}; 820};
@@ -876,6 +822,7 @@ static struct resource dbgu_resources[] = {
876static struct atmel_uart_data dbgu_data = { 822static struct atmel_uart_data dbgu_data = {
877 .use_dma_tx = 0, 823 .use_dma_tx = 0,
878 .use_dma_rx = 0, /* DBGU not capable of receive DMA */ 824 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
825 .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
879}; 826};
880 827
881static u64 dbgu_dmamask = DMA_BIT_MASK(32); 828static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -905,8 +852,8 @@ static struct resource uart0_resources[] = {
905 .flags = IORESOURCE_MEM, 852 .flags = IORESOURCE_MEM,
906 }, 853 },
907 [1] = { 854 [1] = {
908 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_US0, 855 .start = AT91SAM9261_ID_US0,
909 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_US0, 856 .end = AT91SAM9261_ID_US0,
910 .flags = IORESOURCE_IRQ, 857 .flags = IORESOURCE_IRQ,
911 }, 858 },
912}; 859};
@@ -948,8 +895,8 @@ static struct resource uart1_resources[] = {
948 .flags = IORESOURCE_MEM, 895 .flags = IORESOURCE_MEM,
949 }, 896 },
950 [1] = { 897 [1] = {
951 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_US1, 898 .start = AT91SAM9261_ID_US1,
952 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_US1, 899 .end = AT91SAM9261_ID_US1,
953 .flags = IORESOURCE_IRQ, 900 .flags = IORESOURCE_IRQ,
954 }, 901 },
955}; 902};
@@ -991,8 +938,8 @@ static struct resource uart2_resources[] = {
991 .flags = IORESOURCE_MEM, 938 .flags = IORESOURCE_MEM,
992 }, 939 },
993 [1] = { 940 [1] = {
994 .start = NR_IRQS_LEGACY + AT91SAM9261_ID_US2, 941 .start = AT91SAM9261_ID_US2,
995 .end = NR_IRQS_LEGACY + AT91SAM9261_ID_US2, 942 .end = AT91SAM9261_ID_US2,
996 .flags = IORESOURCE_IRQ, 943 .flags = IORESOURCE_IRQ,
997 }, 944 },
998}; 945};
@@ -1028,6 +975,7 @@ static inline void configure_usart2_pins(unsigned pins)
1028} 975}
1029 976
1030static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 977static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
978struct platform_device *atmel_default_console_device; /* the serial console device */
1031 979
1032void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 980void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1033{ 981{
@@ -1061,6 +1009,14 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1061 at91_uarts[portnr] = pdev; 1009 at91_uarts[portnr] = pdev;
1062} 1010}
1063 1011
1012void __init at91_set_serial_console(unsigned portnr)
1013{
1014 if (portnr < ATMEL_MAX_UART) {
1015 atmel_default_console_device = at91_uarts[portnr];
1016 at91sam9261_set_console_clock(at91_uarts[portnr]->id);
1017 }
1018}
1019
1064void __init at91_add_device_serial(void) 1020void __init at91_add_device_serial(void)
1065{ 1021{
1066 int i; 1022 int i;
@@ -1069,9 +1025,13 @@ void __init at91_add_device_serial(void)
1069 if (at91_uarts[i]) 1025 if (at91_uarts[i])
1070 platform_device_register(at91_uarts[i]); 1026 platform_device_register(at91_uarts[i]);
1071 } 1027 }
1028
1029 if (!atmel_default_console_device)
1030 printk(KERN_INFO "AT91: No default serial console defined.\n");
1072} 1031}
1073#else 1032#else
1074void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1033void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1034void __init at91_set_serial_console(unsigned portnr) {}
1075void __init at91_add_device_serial(void) {} 1035void __init at91_add_device_serial(void) {}
1076#endif 1036#endif
1077 1037
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index b9fc60d1b33..044f3c927e6 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -11,21 +11,19 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pm.h>
14 15
15#include <asm/proc-fns.h>
16#include <asm/irq.h> 16#include <asm/irq.h>
17#include <asm/mach/arch.h> 17#include <asm/mach/arch.h>
18#include <asm/mach/map.h> 18#include <asm/mach/map.h>
19#include <asm/system_misc.h>
20#include <mach/at91sam9263.h> 19#include <mach/at91sam9263.h>
21#include <mach/at91_pmc.h> 20#include <mach/at91_pmc.h>
21#include <mach/at91_rstc.h>
22#include <mach/at91_shdwc.h>
22 23
23#include "at91_aic.h"
24#include "at91_rstc.h"
25#include "soc.h" 24#include "soc.h"
26#include "generic.h" 25#include "generic.h"
27#include "clock.h" 26#include "clock.h"
28#include "sam9_smc.h"
29 27
30/* -------------------------------------------------------------------- 28/* --------------------------------------------------------------------
31 * Clocks 29 * Clocks
@@ -120,7 +118,7 @@ static struct clk pwm_clk = {
120 .type = CLK_TYPE_PERIPHERAL, 118 .type = CLK_TYPE_PERIPHERAL,
121}; 119};
122static struct clk macb_clk = { 120static struct clk macb_clk = {
123 .name = "pclk", 121 .name = "macb_clk",
124 .pmc_mask = 1 << AT91SAM9263_ID_EMAC, 122 .pmc_mask = 1 << AT91SAM9263_ID_EMAC,
125 .type = CLK_TYPE_PERIPHERAL, 123 .type = CLK_TYPE_PERIPHERAL,
126}; 124};
@@ -184,43 +182,13 @@ static struct clk *periph_clocks[] __initdata = {
184}; 182};
185 183
186static struct clk_lookup periph_clocks_lookups[] = { 184static struct clk_lookup periph_clocks_lookups[] = {
187 /* One additional fake clock for macb_hclk */ 185 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
188 CLKDEV_CON_ID("hclk", &macb_clk), 186 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
189 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk), 187 CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.0", &mmc0_clk),
190 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk), 188 CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.1", &mmc1_clk),
191 CLKDEV_CON_DEV_ID("pclk", "fff98000.ssc", &ssc0_clk),
192 CLKDEV_CON_DEV_ID("pclk", "fff9c000.ssc", &ssc1_clk),
193 CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.0", &mmc0_clk),
194 CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.1", &mmc1_clk),
195 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), 189 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
196 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), 190 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
197 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk), 191 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk),
198 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260.0", &twi_clk),
199 /* fake hclk clock */
200 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
201 CLKDEV_CON_ID("pioA", &pioA_clk),
202 CLKDEV_CON_ID("pioB", &pioB_clk),
203 CLKDEV_CON_ID("pioC", &pioCDE_clk),
204 CLKDEV_CON_ID("pioD", &pioCDE_clk),
205 CLKDEV_CON_ID("pioE", &pioCDE_clk),
206 /* more usart lookup table for DT entries */
207 CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck),
208 CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk),
209 CLKDEV_CON_DEV_ID("usart", "fff90000.serial", &usart1_clk),
210 CLKDEV_CON_DEV_ID("usart", "fff94000.serial", &usart2_clk),
211 /* more tc lookup table for DT entries */
212 CLKDEV_CON_DEV_ID("t0_clk", "fff7c000.timer", &tcb_clk),
213 CLKDEV_CON_DEV_ID("hclk", "a00000.ohci", &ohci_clk),
214 CLKDEV_CON_DEV_ID("spi_clk", "fffa4000.spi", &spi0_clk),
215 CLKDEV_CON_DEV_ID("spi_clk", "fffa8000.spi", &spi1_clk),
216 CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk),
217 CLKDEV_CON_DEV_ID("mci_clk", "fff84000.mmc", &mmc1_clk),
218 CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi_clk),
219 CLKDEV_CON_DEV_ID(NULL, "fffff200.gpio", &pioA_clk),
220 CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioB_clk),
221 CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioCDE_clk),
222 CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioCDE_clk),
223 CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioCDE_clk),
224}; 192};
225 193
226static struct clk_lookup usart_clocks_lookups[] = { 194static struct clk_lookup usart_clocks_lookups[] = {
@@ -277,29 +245,52 @@ static void __init at91sam9263_register_clocks(void)
277 clk_register(&pck3); 245 clk_register(&pck3);
278} 246}
279 247
248static struct clk_lookup console_clock_lookup;
249
250void __init at91sam9263_set_console_clock(int id)
251{
252 if (id >= ARRAY_SIZE(usart_clocks_lookups))
253 return;
254
255 console_clock_lookup.con_id = "usart";
256 console_clock_lookup.clk = usart_clocks_lookups[id].clk;
257 clkdev_add(&console_clock_lookup);
258}
259
280/* -------------------------------------------------------------------- 260/* --------------------------------------------------------------------
281 * GPIO 261 * GPIO
282 * -------------------------------------------------------------------- */ 262 * -------------------------------------------------------------------- */
283 263
284static struct at91_gpio_bank at91sam9263_gpio[] __initdata = { 264static struct at91_gpio_bank at91sam9263_gpio[] = {
285 { 265 {
286 .id = AT91SAM9263_ID_PIOA, 266 .id = AT91SAM9263_ID_PIOA,
287 .regbase = AT91SAM9263_BASE_PIOA, 267 .offset = AT91_PIOA,
268 .clock = &pioA_clk,
288 }, { 269 }, {
289 .id = AT91SAM9263_ID_PIOB, 270 .id = AT91SAM9263_ID_PIOB,
290 .regbase = AT91SAM9263_BASE_PIOB, 271 .offset = AT91_PIOB,
272 .clock = &pioB_clk,
291 }, { 273 }, {
292 .id = AT91SAM9263_ID_PIOCDE, 274 .id = AT91SAM9263_ID_PIOCDE,
293 .regbase = AT91SAM9263_BASE_PIOC, 275 .offset = AT91_PIOC,
276 .clock = &pioCDE_clk,
294 }, { 277 }, {
295 .id = AT91SAM9263_ID_PIOCDE, 278 .id = AT91SAM9263_ID_PIOCDE,
296 .regbase = AT91SAM9263_BASE_PIOD, 279 .offset = AT91_PIOD,
280 .clock = &pioCDE_clk,
297 }, { 281 }, {
298 .id = AT91SAM9263_ID_PIOCDE, 282 .id = AT91SAM9263_ID_PIOCDE,
299 .regbase = AT91SAM9263_BASE_PIOE, 283 .offset = AT91_PIOE,
284 .clock = &pioCDE_clk,
300 } 285 }
301}; 286};
302 287
288static void at91sam9263_poweroff(void)
289{
290 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
291}
292
293
303/* -------------------------------------------------------------------- 294/* --------------------------------------------------------------------
304 * AT91SAM9263 processor initialization 295 * AT91SAM9263 processor initialization
305 * -------------------------------------------------------------------- */ 296 * -------------------------------------------------------------------- */
@@ -310,22 +301,10 @@ static void __init at91sam9263_map_io(void)
310 at91_init_sram(1, AT91SAM9263_SRAM1_BASE, AT91SAM9263_SRAM1_SIZE); 301 at91_init_sram(1, AT91SAM9263_SRAM1_BASE, AT91SAM9263_SRAM1_SIZE);
311} 302}
312 303
313static void __init at91sam9263_ioremap_registers(void)
314{
315 at91_ioremap_shdwc(AT91SAM9263_BASE_SHDWC);
316 at91_ioremap_rstc(AT91SAM9263_BASE_RSTC);
317 at91_ioremap_ramc(0, AT91SAM9263_BASE_SDRAMC0, 512);
318 at91_ioremap_ramc(1, AT91SAM9263_BASE_SDRAMC1, 512);
319 at91sam926x_ioremap_pit(AT91SAM9263_BASE_PIT);
320 at91sam9_ioremap_smc(0, AT91SAM9263_BASE_SMC0);
321 at91sam9_ioremap_smc(1, AT91SAM9263_BASE_SMC1);
322 at91_ioremap_matrix(AT91SAM9263_BASE_MATRIX);
323}
324
325static void __init at91sam9263_initialize(void) 304static void __init at91sam9263_initialize(void)
326{ 305{
327 arm_pm_idle = at91sam9_idle; 306 at91_arch_reset = at91sam9_alt_reset;
328 arm_pm_restart = at91sam9_alt_restart; 307 pm_power_off = at91sam9263_poweroff;
329 at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1); 308 at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1);
330 309
331 /* Register GPIO subsystem */ 310 /* Register GPIO subsystem */
@@ -374,10 +353,9 @@ static unsigned int at91sam9263_default_irq_priority[NR_AIC_IRQS] __initdata = {
374 0, /* Advanced Interrupt Controller (IRQ1) */ 353 0, /* Advanced Interrupt Controller (IRQ1) */
375}; 354};
376 355
377AT91_SOC_START(sam9263) 356struct at91_init_soc __initdata at91sam9263_soc = {
378 .map_io = at91sam9263_map_io, 357 .map_io = at91sam9263_map_io,
379 .default_irq_priority = at91sam9263_default_irq_priority, 358 .default_irq_priority = at91sam9263_default_irq_priority,
380 .ioremap_registers = at91sam9263_ioremap_registers,
381 .register_clocks = at91sam9263_register_clocks, 359 .register_clocks = at91sam9263_register_clocks,
382 .init = at91sam9263_initialize, 360 .init = at91sam9263_initialize,
383AT91_SOC_END 361};
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index ed666f5cb01..863e4661409 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -13,19 +13,18 @@
13#include <asm/mach/map.h> 13#include <asm/mach/map.h>
14 14
15#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
16#include <linux/gpio.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
18#include <linux/i2c-gpio.h> 17#include <linux/i2c-gpio.h>
19 18
20#include <linux/fb.h> 19#include <linux/fb.h>
21#include <video/atmel_lcdc.h> 20#include <video/atmel_lcdc.h>
22 21
22#include <mach/board.h>
23#include <mach/gpio.h>
23#include <mach/at91sam9263.h> 24#include <mach/at91sam9263.h>
24#include <mach/at91sam9263_matrix.h> 25#include <mach/at91sam9263_matrix.h>
25#include <mach/at91_matrix.h>
26#include <mach/at91sam9_smc.h> 26#include <mach/at91sam9_smc.h>
27 27
28#include "board.h"
29#include "generic.h" 28#include "generic.h"
30 29
31 30
@@ -44,8 +43,8 @@ static struct resource usbh_resources[] = {
44 .flags = IORESOURCE_MEM, 43 .flags = IORESOURCE_MEM,
45 }, 44 },
46 [1] = { 45 [1] = {
47 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_UHP, 46 .start = AT91SAM9263_ID_UHP,
48 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_UHP, 47 .end = AT91SAM9263_ID_UHP,
49 .flags = IORESOURCE_IRQ, 48 .flags = IORESOURCE_IRQ,
50 }, 49 },
51}; 50};
@@ -71,15 +70,8 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)
71 70
72 /* Enable VBus control for UHP ports */ 71 /* Enable VBus control for UHP ports */
73 for (i = 0; i < data->ports; i++) { 72 for (i = 0; i < data->ports; i++) {
74 if (gpio_is_valid(data->vbus_pin[i])) 73 if (data->vbus_pin[i])
75 at91_set_gpio_output(data->vbus_pin[i], 74 at91_set_gpio_output(data->vbus_pin[i], 0);
76 data->vbus_pin_active_low[i]);
77 }
78
79 /* Enable overcurrent notification */
80 for (i = 0; i < data->ports; i++) {
81 if (gpio_is_valid(data->overcurrent_pin[i]))
82 at91_set_gpio_input(data->overcurrent_pin[i], 1);
83 } 75 }
84 76
85 usbh_data = *data; 77 usbh_data = *data;
@@ -94,7 +86,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
94 * USB Device (Gadget) 86 * USB Device (Gadget)
95 * -------------------------------------------------------------------- */ 87 * -------------------------------------------------------------------- */
96 88
97#if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE) 89#ifdef CONFIG_USB_AT91
98static struct at91_udc_data udc_data; 90static struct at91_udc_data udc_data;
99 91
100static struct resource udc_resources[] = { 92static struct resource udc_resources[] = {
@@ -104,8 +96,8 @@ static struct resource udc_resources[] = {
104 .flags = IORESOURCE_MEM, 96 .flags = IORESOURCE_MEM,
105 }, 97 },
106 [1] = { 98 [1] = {
107 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_UDP, 99 .start = AT91SAM9263_ID_UDP,
108 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_UDP, 100 .end = AT91SAM9263_ID_UDP,
109 .flags = IORESOURCE_IRQ, 101 .flags = IORESOURCE_IRQ,
110 }, 102 },
111}; 103};
@@ -125,7 +117,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data)
125 if (!data) 117 if (!data)
126 return; 118 return;
127 119
128 if (gpio_is_valid(data->vbus_pin)) { 120 if (data->vbus_pin) {
129 at91_set_gpio_input(data->vbus_pin, 0); 121 at91_set_gpio_input(data->vbus_pin, 0);
130 at91_set_deglitch(data->vbus_pin, 1); 122 at91_set_deglitch(data->vbus_pin, 1);
131 } 123 }
@@ -146,7 +138,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {}
146 138
147#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE) 139#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
148static u64 eth_dmamask = DMA_BIT_MASK(32); 140static u64 eth_dmamask = DMA_BIT_MASK(32);
149static struct macb_platform_data eth_data; 141static struct at91_eth_data eth_data;
150 142
151static struct resource eth_resources[] = { 143static struct resource eth_resources[] = {
152 [0] = { 144 [0] = {
@@ -155,8 +147,8 @@ static struct resource eth_resources[] = {
155 .flags = IORESOURCE_MEM, 147 .flags = IORESOURCE_MEM,
156 }, 148 },
157 [1] = { 149 [1] = {
158 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_EMAC, 150 .start = AT91SAM9263_ID_EMAC,
159 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_EMAC, 151 .end = AT91SAM9263_ID_EMAC,
160 .flags = IORESOURCE_IRQ, 152 .flags = IORESOURCE_IRQ,
161 }, 153 },
162}; 154};
@@ -173,12 +165,12 @@ static struct platform_device at91sam9263_eth_device = {
173 .num_resources = ARRAY_SIZE(eth_resources), 165 .num_resources = ARRAY_SIZE(eth_resources),
174}; 166};
175 167
176void __init at91_add_device_eth(struct macb_platform_data *data) 168void __init at91_add_device_eth(struct at91_eth_data *data)
177{ 169{
178 if (!data) 170 if (!data)
179 return; 171 return;
180 172
181 if (gpio_is_valid(data->phy_irq_pin)) { 173 if (data->phy_irq_pin) {
182 at91_set_gpio_input(data->phy_irq_pin, 0); 174 at91_set_gpio_input(data->phy_irq_pin, 0);
183 at91_set_deglitch(data->phy_irq_pin, 1); 175 at91_set_deglitch(data->phy_irq_pin, 1);
184 } 176 }
@@ -210,7 +202,7 @@ void __init at91_add_device_eth(struct macb_platform_data *data)
210 platform_device_register(&at91sam9263_eth_device); 202 platform_device_register(&at91sam9263_eth_device);
211} 203}
212#else 204#else
213void __init at91_add_device_eth(struct macb_platform_data *data) {} 205void __init at91_add_device_eth(struct at91_eth_data *data) {}
214#endif 206#endif
215 207
216 208
@@ -218,9 +210,9 @@ void __init at91_add_device_eth(struct macb_platform_data *data) {}
218 * MMC / SD 210 * MMC / SD
219 * -------------------------------------------------------------------- */ 211 * -------------------------------------------------------------------- */
220 212
221#if IS_ENABLED(CONFIG_MMC_ATMELMCI) 213#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
222static u64 mmc_dmamask = DMA_BIT_MASK(32); 214static u64 mmc_dmamask = DMA_BIT_MASK(32);
223static struct mci_platform_data mmc0_data, mmc1_data; 215static struct at91_mmc_data mmc0_data, mmc1_data;
224 216
225static struct resource mmc0_resources[] = { 217static struct resource mmc0_resources[] = {
226 [0] = { 218 [0] = {
@@ -229,14 +221,14 @@ static struct resource mmc0_resources[] = {
229 .flags = IORESOURCE_MEM, 221 .flags = IORESOURCE_MEM,
230 }, 222 },
231 [1] = { 223 [1] = {
232 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI0, 224 .start = AT91SAM9263_ID_MCI0,
233 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI0, 225 .end = AT91SAM9263_ID_MCI0,
234 .flags = IORESOURCE_IRQ, 226 .flags = IORESOURCE_IRQ,
235 }, 227 },
236}; 228};
237 229
238static struct platform_device at91sam9263_mmc0_device = { 230static struct platform_device at91sam9263_mmc0_device = {
239 .name = "atmel_mci", 231 .name = "at91_mci",
240 .id = 0, 232 .id = 0,
241 .dev = { 233 .dev = {
242 .dma_mask = &mmc_dmamask, 234 .dma_mask = &mmc_dmamask,
@@ -254,14 +246,14 @@ static struct resource mmc1_resources[] = {
254 .flags = IORESOURCE_MEM, 246 .flags = IORESOURCE_MEM,
255 }, 247 },
256 [1] = { 248 [1] = {
257 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI1, 249 .start = AT91SAM9263_ID_MCI1,
258 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_MCI1, 250 .end = AT91SAM9263_ID_MCI1,
259 .flags = IORESOURCE_IRQ, 251 .flags = IORESOURCE_IRQ,
260 }, 252 },
261}; 253};
262 254
263static struct platform_device at91sam9263_mmc1_device = { 255static struct platform_device at91sam9263_mmc1_device = {
264 .name = "atmel_mci", 256 .name = "at91_mci",
265 .id = 1, 257 .id = 1,
266 .dev = { 258 .dev = {
267 .dma_mask = &mmc_dmamask, 259 .dma_mask = &mmc_dmamask,
@@ -272,118 +264,93 @@ static struct platform_device at91sam9263_mmc1_device = {
272 .num_resources = ARRAY_SIZE(mmc1_resources), 264 .num_resources = ARRAY_SIZE(mmc1_resources),
273}; 265};
274 266
275void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) 267void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
276{ 268{
277 unsigned int i;
278 unsigned int slot_count = 0;
279
280 if (!data) 269 if (!data)
281 return; 270 return;
282 271
283 for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) { 272 /* input/irq */
273 if (data->det_pin) {
274 at91_set_gpio_input(data->det_pin, 1);
275 at91_set_deglitch(data->det_pin, 1);
276 }
277 if (data->wp_pin)
278 at91_set_gpio_input(data->wp_pin, 1);
279 if (data->vcc_pin)
280 at91_set_gpio_output(data->vcc_pin, 0);
284 281
285 if (!data->slot[i].bus_width) 282 if (mmc_id == 0) { /* MCI0 */
286 continue; 283 /* CLK */
284 at91_set_A_periph(AT91_PIN_PA12, 0);
287 285
288 /* input/irq */ 286 if (data->slot_b) {
289 if (gpio_is_valid(data->slot[i].detect_pin)) { 287 /* CMD */
290 at91_set_gpio_input(data->slot[i].detect_pin, 288 at91_set_A_periph(AT91_PIN_PA16, 1);
291 1);
292 at91_set_deglitch(data->slot[i].detect_pin,
293 1);
294 }
295 if (gpio_is_valid(data->slot[i].wp_pin))
296 at91_set_gpio_input(data->slot[i].wp_pin, 1);
297
298 if (mmc_id == 0) { /* MCI0 */
299 switch (i) {
300 case 0: /* slot A */
301 /* CMD */
302 at91_set_A_periph(AT91_PIN_PA1, 1);
303 /* DAT0, maybe DAT1..DAT3 */
304 at91_set_A_periph(AT91_PIN_PA0, 1);
305 if (data->slot[i].bus_width == 4) {
306 at91_set_A_periph(AT91_PIN_PA3, 1);
307 at91_set_A_periph(AT91_PIN_PA4, 1);
308 at91_set_A_periph(AT91_PIN_PA5, 1);
309 }
310 slot_count++;
311 break;
312 case 1: /* slot B */
313 /* CMD */
314 at91_set_A_periph(AT91_PIN_PA16, 1);
315 /* DAT0, maybe DAT1..DAT3 */
316 at91_set_A_periph(AT91_PIN_PA17, 1);
317 if (data->slot[i].bus_width == 4) {
318 at91_set_A_periph(AT91_PIN_PA18, 1);
319 at91_set_A_periph(AT91_PIN_PA19, 1);
320 at91_set_A_periph(AT91_PIN_PA20, 1);
321 }
322 slot_count++;
323 break;
324 default:
325 printk(KERN_ERR
326 "AT91: SD/MMC slot %d not available\n", i);
327 break;
328 }
329 if (slot_count) {
330 /* CLK */
331 at91_set_A_periph(AT91_PIN_PA12, 0);
332 289
333 mmc0_data = *data; 290 /* DAT0, maybe DAT1..DAT3 */
334 platform_device_register(&at91sam9263_mmc0_device); 291 at91_set_A_periph(AT91_PIN_PA17, 1);
292 if (data->wire4) {
293 at91_set_A_periph(AT91_PIN_PA18, 1);
294 at91_set_A_periph(AT91_PIN_PA19, 1);
295 at91_set_A_periph(AT91_PIN_PA20, 1);
335 } 296 }
336 } else if (mmc_id == 1) { /* MCI1 */ 297 } else {
337 switch (i) { 298 /* CMD */
338 case 0: /* slot A */ 299 at91_set_A_periph(AT91_PIN_PA1, 1);
339 /* CMD */ 300
340 at91_set_A_periph(AT91_PIN_PA7, 1); 301 /* DAT0, maybe DAT1..DAT3 */
341 /* DAT0, maybe DAT1..DAT3 */ 302 at91_set_A_periph(AT91_PIN_PA0, 1);
342 at91_set_A_periph(AT91_PIN_PA8, 1); 303 if (data->wire4) {
343 if (data->slot[i].bus_width == 4) { 304 at91_set_A_periph(AT91_PIN_PA3, 1);
344 at91_set_A_periph(AT91_PIN_PA9, 1); 305 at91_set_A_periph(AT91_PIN_PA4, 1);
345 at91_set_A_periph(AT91_PIN_PA10, 1); 306 at91_set_A_periph(AT91_PIN_PA5, 1);
346 at91_set_A_periph(AT91_PIN_PA11, 1);
347 }
348 slot_count++;
349 break;
350 case 1: /* slot B */
351 /* CMD */
352 at91_set_A_periph(AT91_PIN_PA21, 1);
353 /* DAT0, maybe DAT1..DAT3 */
354 at91_set_A_periph(AT91_PIN_PA22, 1);
355 if (data->slot[i].bus_width == 4) {
356 at91_set_A_periph(AT91_PIN_PA23, 1);
357 at91_set_A_periph(AT91_PIN_PA24, 1);
358 at91_set_A_periph(AT91_PIN_PA25, 1);
359 }
360 slot_count++;
361 break;
362 default:
363 printk(KERN_ERR
364 "AT91: SD/MMC slot %d not available\n", i);
365 break;
366 } 307 }
367 if (slot_count) { 308 }
368 /* CLK */
369 at91_set_A_periph(AT91_PIN_PA6, 0);
370 309
371 mmc1_data = *data; 310 mmc0_data = *data;
372 platform_device_register(&at91sam9263_mmc1_device); 311 platform_device_register(&at91sam9263_mmc0_device);
312 } else { /* MCI1 */
313 /* CLK */
314 at91_set_A_periph(AT91_PIN_PA6, 0);
315
316 if (data->slot_b) {
317 /* CMD */
318 at91_set_A_periph(AT91_PIN_PA21, 1);
319
320 /* DAT0, maybe DAT1..DAT3 */
321 at91_set_A_periph(AT91_PIN_PA22, 1);
322 if (data->wire4) {
323 at91_set_A_periph(AT91_PIN_PA23, 1);
324 at91_set_A_periph(AT91_PIN_PA24, 1);
325 at91_set_A_periph(AT91_PIN_PA25, 1);
326 }
327 } else {
328 /* CMD */
329 at91_set_A_periph(AT91_PIN_PA7, 1);
330
331 /* DAT0, maybe DAT1..DAT3 */
332 at91_set_A_periph(AT91_PIN_PA8, 1);
333 if (data->wire4) {
334 at91_set_A_periph(AT91_PIN_PA9, 1);
335 at91_set_A_periph(AT91_PIN_PA10, 1);
336 at91_set_A_periph(AT91_PIN_PA11, 1);
373 } 337 }
374 } 338 }
339
340 mmc1_data = *data;
341 platform_device_register(&at91sam9263_mmc1_device);
375 } 342 }
376} 343}
377#else 344#else
378void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {} 345void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
379#endif 346#endif
380 347
381/* -------------------------------------------------------------------- 348/* --------------------------------------------------------------------
382 * Compact Flash (PCMCIA or IDE) 349 * Compact Flash (PCMCIA or IDE)
383 * -------------------------------------------------------------------- */ 350 * -------------------------------------------------------------------- */
384 351
385#if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \ 352#if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) || \
386 defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) 353 defined(CONFIG_BLK_DEV_IDE_AT91) || defined(CONFIG_BLK_DEV_IDE_AT91_MODULE)
387 354
388static struct at91_cf_data cf0_data; 355static struct at91_cf_data cf0_data;
389 356
@@ -436,7 +403,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
436 * we assume SMC timings are configured by board code, 403 * we assume SMC timings are configured by board code,
437 * except True IDE where timings are controlled by driver 404 * except True IDE where timings are controlled by driver
438 */ 405 */
439 ebi0_csa = at91_matrix_read(AT91_MATRIX_EBI0CSA); 406 ebi0_csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
440 switch (data->chipselect) { 407 switch (data->chipselect) {
441 case 4: 408 case 4:
442 at91_set_A_periph(AT91_PIN_PD6, 0); /* EBI0_NCS4/CFCS0 */ 409 at91_set_A_periph(AT91_PIN_PD6, 0); /* EBI0_NCS4/CFCS0 */
@@ -455,19 +422,19 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
455 data->chipselect); 422 data->chipselect);
456 return; 423 return;
457 } 424 }
458 at91_matrix_write(AT91_MATRIX_EBI0CSA, ebi0_csa); 425 at91_sys_write(AT91_MATRIX_EBI0CSA, ebi0_csa);
459 426
460 if (gpio_is_valid(data->det_pin)) { 427 if (data->det_pin) {
461 at91_set_gpio_input(data->det_pin, 1); 428 at91_set_gpio_input(data->det_pin, 1);
462 at91_set_deglitch(data->det_pin, 1); 429 at91_set_deglitch(data->det_pin, 1);
463 } 430 }
464 431
465 if (gpio_is_valid(data->irq_pin)) { 432 if (data->irq_pin) {
466 at91_set_gpio_input(data->irq_pin, 1); 433 at91_set_gpio_input(data->irq_pin, 1);
467 at91_set_deglitch(data->irq_pin, 1); 434 at91_set_deglitch(data->irq_pin, 1);
468 } 435 }
469 436
470 if (gpio_is_valid(data->vcc_pin)) 437 if (data->vcc_pin)
471 /* initially off */ 438 /* initially off */
472 at91_set_gpio_output(data->vcc_pin, 0); 439 at91_set_gpio_output(data->vcc_pin, 0);
473 440
@@ -477,7 +444,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
477 at91_set_A_periph(AT91_PIN_PD9, 0); /* CFCE2 */ 444 at91_set_A_periph(AT91_PIN_PD9, 0); /* CFCE2 */
478 at91_set_A_periph(AT91_PIN_PD14, 0); /* CFNRW */ 445 at91_set_A_periph(AT91_PIN_PD14, 0); /* CFNRW */
479 446
480 pdev->name = (data->flags & AT91_CF_TRUE_IDE) ? "pata_at91" : "at91_cf"; 447 pdev->name = (data->flags & AT91_CF_TRUE_IDE) ? "at91_ide" : "at91_cf";
481 platform_device_register(pdev); 448 platform_device_register(pdev);
482} 449}
483#else 450#else
@@ -500,8 +467,8 @@ static struct resource nand_resources[] = {
500 .flags = IORESOURCE_MEM, 467 .flags = IORESOURCE_MEM,
501 }, 468 },
502 [1] = { 469 [1] = {
503 .start = AT91SAM9263_BASE_ECC0, 470 .start = AT91_BASE_SYS + AT91_ECC0,
504 .end = AT91SAM9263_BASE_ECC0 + SZ_512 - 1, 471 .end = AT91_BASE_SYS + AT91_ECC0 + SZ_512 - 1,
505 .flags = IORESOURCE_MEM, 472 .flags = IORESOURCE_MEM,
506 } 473 }
507}; 474};
@@ -523,19 +490,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
523 if (!data) 490 if (!data)
524 return; 491 return;
525 492
526 csa = at91_matrix_read(AT91_MATRIX_EBI0CSA); 493 csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
527 at91_matrix_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA); 494 at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA);
528 495
529 /* enable pin */ 496 /* enable pin */
530 if (gpio_is_valid(data->enable_pin)) 497 if (data->enable_pin)
531 at91_set_gpio_output(data->enable_pin, 1); 498 at91_set_gpio_output(data->enable_pin, 1);
532 499
533 /* ready/busy pin */ 500 /* ready/busy pin */
534 if (gpio_is_valid(data->rdy_pin)) 501 if (data->rdy_pin)
535 at91_set_gpio_input(data->rdy_pin, 1); 502 at91_set_gpio_input(data->rdy_pin, 1);
536 503
537 /* card detect pin */ 504 /* card detect pin */
538 if (gpio_is_valid(data->det_pin)) 505 if (data->det_pin)
539 at91_set_gpio_input(data->det_pin, 1); 506 at91_set_gpio_input(data->det_pin, 1);
540 507
541 nand_data = *data; 508 nand_data = *data;
@@ -567,7 +534,7 @@ static struct i2c_gpio_platform_data pdata = {
567 534
568static struct platform_device at91sam9263_twi_device = { 535static struct platform_device at91sam9263_twi_device = {
569 .name = "i2c-gpio", 536 .name = "i2c-gpio",
570 .id = 0, 537 .id = -1,
571 .dev.platform_data = &pdata, 538 .dev.platform_data = &pdata,
572}; 539};
573 540
@@ -592,15 +559,15 @@ static struct resource twi_resources[] = {
592 .flags = IORESOURCE_MEM, 559 .flags = IORESOURCE_MEM,
593 }, 560 },
594 [1] = { 561 [1] = {
595 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_TWI, 562 .start = AT91SAM9263_ID_TWI,
596 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_TWI, 563 .end = AT91SAM9263_ID_TWI,
597 .flags = IORESOURCE_IRQ, 564 .flags = IORESOURCE_IRQ,
598 }, 565 },
599}; 566};
600 567
601static struct platform_device at91sam9263_twi_device = { 568static struct platform_device at91sam9263_twi_device = {
602 .name = "i2c-at91sam9260", 569 .name = "at91_i2c",
603 .id = 0, 570 .id = -1,
604 .resource = twi_resources, 571 .resource = twi_resources,
605 .num_resources = ARRAY_SIZE(twi_resources), 572 .num_resources = ARRAY_SIZE(twi_resources),
606}; 573};
@@ -636,8 +603,8 @@ static struct resource spi0_resources[] = {
636 .flags = IORESOURCE_MEM, 603 .flags = IORESOURCE_MEM,
637 }, 604 },
638 [1] = { 605 [1] = {
639 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI0, 606 .start = AT91SAM9263_ID_SPI0,
640 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI0, 607 .end = AT91SAM9263_ID_SPI0,
641 .flags = IORESOURCE_IRQ, 608 .flags = IORESOURCE_IRQ,
642 }, 609 },
643}; 610};
@@ -662,8 +629,8 @@ static struct resource spi1_resources[] = {
662 .flags = IORESOURCE_MEM, 629 .flags = IORESOURCE_MEM,
663 }, 630 },
664 [1] = { 631 [1] = {
665 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI1, 632 .start = AT91SAM9263_ID_SPI1,
666 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_SPI1, 633 .end = AT91SAM9263_ID_SPI1,
667 .flags = IORESOURCE_IRQ, 634 .flags = IORESOURCE_IRQ,
668 }, 635 },
669}; 636};
@@ -697,9 +664,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
697 else 664 else
698 cs_pin = spi1_standard_cs[devices[i].chip_select]; 665 cs_pin = spi1_standard_cs[devices[i].chip_select];
699 666
700 if (!gpio_is_valid(cs_pin))
701 continue;
702
703 if (devices[i].bus_num == 0) 667 if (devices[i].bus_num == 0)
704 enable_spi0 = 1; 668 enable_spi0 = 1;
705 else 669 else
@@ -750,8 +714,8 @@ static struct resource ac97_resources[] = {
750 .flags = IORESOURCE_MEM, 714 .flags = IORESOURCE_MEM,
751 }, 715 },
752 [1] = { 716 [1] = {
753 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_AC97C, 717 .start = AT91SAM9263_ID_AC97C,
754 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_AC97C, 718 .end = AT91SAM9263_ID_AC97C,
755 .flags = IORESOURCE_IRQ, 719 .flags = IORESOURCE_IRQ,
756 }, 720 },
757}; 721};
@@ -779,7 +743,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data)
779 at91_set_A_periph(AT91_PIN_PB3, 0); /* AC97RX */ 743 at91_set_A_periph(AT91_PIN_PB3, 0); /* AC97RX */
780 744
781 /* reset */ 745 /* reset */
782 if (gpio_is_valid(data->reset_pin)) 746 if (data->reset_pin)
783 at91_set_gpio_output(data->reset_pin, 0); 747 at91_set_gpio_output(data->reset_pin, 0);
784 748
785 ac97_data = *data; 749 ac97_data = *data;
@@ -801,8 +765,8 @@ static struct resource can_resources[] = {
801 .flags = IORESOURCE_MEM, 765 .flags = IORESOURCE_MEM,
802 }, 766 },
803 [1] = { 767 [1] = {
804 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_CAN, 768 .start = AT91SAM9263_ID_CAN,
805 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_CAN, 769 .end = AT91SAM9263_ID_CAN,
806 .flags = IORESOURCE_IRQ, 770 .flags = IORESOURCE_IRQ,
807 }, 771 },
808}; 772};
@@ -841,8 +805,8 @@ static struct resource lcdc_resources[] = {
841 .flags = IORESOURCE_MEM, 805 .flags = IORESOURCE_MEM,
842 }, 806 },
843 [1] = { 807 [1] = {
844 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_LCDC, 808 .start = AT91SAM9263_ID_LCDC,
845 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_LCDC, 809 .end = AT91SAM9263_ID_LCDC,
846 .flags = IORESOURCE_IRQ, 810 .flags = IORESOURCE_IRQ,
847 }, 811 },
848}; 812};
@@ -908,8 +872,8 @@ struct resource isi_resources[] = {
908 .flags = IORESOURCE_MEM, 872 .flags = IORESOURCE_MEM,
909 }, 873 },
910 [1] = { 874 [1] = {
911 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_ISI, 875 .start = AT91SAM9263_ID_ISI,
912 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_ISI, 876 .end = AT91SAM9263_ID_ISI,
913 .flags = IORESOURCE_IRQ, 877 .flags = IORESOURCE_IRQ,
914 }, 878 },
915}; 879};
@@ -921,8 +885,7 @@ static struct platform_device at91sam9263_isi_device = {
921 .num_resources = ARRAY_SIZE(isi_resources), 885 .num_resources = ARRAY_SIZE(isi_resources),
922}; 886};
923 887
924void __init at91_add_device_isi(struct isi_platform_data *data, 888void __init at91_add_device_isi(void)
925 bool use_pck_as_mck)
926{ 889{
927 at91_set_A_periph(AT91_PIN_PE0, 0); /* ISI_D0 */ 890 at91_set_A_periph(AT91_PIN_PE0, 0); /* ISI_D0 */
928 at91_set_A_periph(AT91_PIN_PE1, 0); /* ISI_D1 */ 891 at91_set_A_periph(AT91_PIN_PE1, 0); /* ISI_D1 */
@@ -935,20 +898,14 @@ void __init at91_add_device_isi(struct isi_platform_data *data,
935 at91_set_A_periph(AT91_PIN_PE8, 0); /* ISI_PCK */ 898 at91_set_A_periph(AT91_PIN_PE8, 0); /* ISI_PCK */
936 at91_set_A_periph(AT91_PIN_PE9, 0); /* ISI_HSYNC */ 899 at91_set_A_periph(AT91_PIN_PE9, 0); /* ISI_HSYNC */
937 at91_set_A_periph(AT91_PIN_PE10, 0); /* ISI_VSYNC */ 900 at91_set_A_periph(AT91_PIN_PE10, 0); /* ISI_VSYNC */
901 at91_set_B_periph(AT91_PIN_PE11, 0); /* ISI_MCK (PCK3) */
938 at91_set_B_periph(AT91_PIN_PE12, 0); /* ISI_PD8 */ 902 at91_set_B_periph(AT91_PIN_PE12, 0); /* ISI_PD8 */
939 at91_set_B_periph(AT91_PIN_PE13, 0); /* ISI_PD9 */ 903 at91_set_B_periph(AT91_PIN_PE13, 0); /* ISI_PD9 */
940 at91_set_B_periph(AT91_PIN_PE14, 0); /* ISI_PD10 */ 904 at91_set_B_periph(AT91_PIN_PE14, 0); /* ISI_PD10 */
941 at91_set_B_periph(AT91_PIN_PE15, 0); /* ISI_PD11 */ 905 at91_set_B_periph(AT91_PIN_PE15, 0); /* ISI_PD11 */
942
943 if (use_pck_as_mck) {
944 at91_set_B_periph(AT91_PIN_PE11, 0); /* ISI_MCK (PCK3) */
945
946 /* TODO: register the PCK for ISI_MCK and set its parent */
947 }
948} 906}
949#else 907#else
950void __init at91_add_device_isi(struct isi_platform_data *data, 908void __init at91_add_device_isi(void) {}
951 bool use_pck_as_mck) {}
952#endif 909#endif
953 910
954 911
@@ -965,8 +922,8 @@ static struct resource tcb_resources[] = {
965 .flags = IORESOURCE_MEM, 922 .flags = IORESOURCE_MEM,
966 }, 923 },
967 [1] = { 924 [1] = {
968 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_TCB, 925 .start = AT91SAM9263_ID_TCB,
969 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_TCB, 926 .end = AT91SAM9263_ID_TCB,
970 .flags = IORESOURCE_IRQ, 927 .flags = IORESOURCE_IRQ,
971 }, 928 },
972}; 929};
@@ -978,25 +935,8 @@ static struct platform_device at91sam9263_tcb_device = {
978 .num_resources = ARRAY_SIZE(tcb_resources), 935 .num_resources = ARRAY_SIZE(tcb_resources),
979}; 936};
980 937
981#if defined(CONFIG_OF)
982static struct of_device_id tcb_ids[] = {
983 { .compatible = "atmel,at91rm9200-tcb" },
984 { /*sentinel*/ }
985};
986#endif
987
988static void __init at91_add_device_tc(void) 938static void __init at91_add_device_tc(void)
989{ 939{
990#if defined(CONFIG_OF)
991 struct device_node *np;
992
993 np = of_find_matching_node(NULL, tcb_ids);
994 if (np) {
995 of_node_put(np);
996 return;
997 }
998#endif
999
1000 platform_device_register(&at91sam9263_tcb_device); 940 platform_device_register(&at91sam9263_tcb_device);
1001} 941}
1002#else 942#else
@@ -1010,13 +950,9 @@ static void __init at91_add_device_tc(void) { }
1010 950
1011static struct resource rtt0_resources[] = { 951static struct resource rtt0_resources[] = {
1012 { 952 {
1013 .start = AT91SAM9263_BASE_RTT0, 953 .start = AT91_BASE_SYS + AT91_RTT0,
1014 .end = AT91SAM9263_BASE_RTT0 + SZ_16 - 1, 954 .end = AT91_BASE_SYS + AT91_RTT0 + SZ_16 - 1,
1015 .flags = IORESOURCE_MEM, 955 .flags = IORESOURCE_MEM,
1016 }, {
1017 .flags = IORESOURCE_MEM,
1018 }, {
1019 .flags = IORESOURCE_IRQ,
1020 } 956 }
1021}; 957};
1022 958
@@ -1024,17 +960,14 @@ static struct platform_device at91sam9263_rtt0_device = {
1024 .name = "at91_rtt", 960 .name = "at91_rtt",
1025 .id = 0, 961 .id = 0,
1026 .resource = rtt0_resources, 962 .resource = rtt0_resources,
963 .num_resources = ARRAY_SIZE(rtt0_resources),
1027}; 964};
1028 965
1029static struct resource rtt1_resources[] = { 966static struct resource rtt1_resources[] = {
1030 { 967 {
1031 .start = AT91SAM9263_BASE_RTT1, 968 .start = AT91_BASE_SYS + AT91_RTT1,
1032 .end = AT91SAM9263_BASE_RTT1 + SZ_16 - 1, 969 .end = AT91_BASE_SYS + AT91_RTT1 + SZ_16 - 1,
1033 .flags = IORESOURCE_MEM,
1034 }, {
1035 .flags = IORESOURCE_MEM, 970 .flags = IORESOURCE_MEM,
1036 }, {
1037 .flags = IORESOURCE_IRQ,
1038 } 971 }
1039}; 972};
1040 973
@@ -1042,55 +975,11 @@ static struct platform_device at91sam9263_rtt1_device = {
1042 .name = "at91_rtt", 975 .name = "at91_rtt",
1043 .id = 1, 976 .id = 1,
1044 .resource = rtt1_resources, 977 .resource = rtt1_resources,
978 .num_resources = ARRAY_SIZE(rtt1_resources),
1045}; 979};
1046 980
1047#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
1048static void __init at91_add_device_rtt_rtc(void)
1049{
1050 struct platform_device *pdev;
1051 struct resource *r;
1052
1053 switch (CONFIG_RTC_DRV_AT91SAM9_RTT) {
1054 case 0:
1055 /*
1056 * The second resource is needed only for the chosen RTT:
1057 * GPBR will serve as the storage for RTC time offset
1058 */
1059 at91sam9263_rtt0_device.num_resources = 3;
1060 at91sam9263_rtt1_device.num_resources = 1;
1061 pdev = &at91sam9263_rtt0_device;
1062 r = rtt0_resources;
1063 break;
1064 case 1:
1065 at91sam9263_rtt0_device.num_resources = 1;
1066 at91sam9263_rtt1_device.num_resources = 3;
1067 pdev = &at91sam9263_rtt1_device;
1068 r = rtt1_resources;
1069 break;
1070 default:
1071 pr_err("at91sam9263: only supports 2 RTT (%d)\n",
1072 CONFIG_RTC_DRV_AT91SAM9_RTT);
1073 return;
1074 }
1075
1076 pdev->name = "rtc-at91sam9";
1077 r[1].start = AT91SAM9263_BASE_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
1078 r[1].end = r[1].start + 3;
1079 r[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;
1080 r[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;
1081}
1082#else
1083static void __init at91_add_device_rtt_rtc(void)
1084{
1085 /* Only one resource is needed: RTT not used as RTC */
1086 at91sam9263_rtt0_device.num_resources = 1;
1087 at91sam9263_rtt1_device.num_resources = 1;
1088}
1089#endif
1090
1091static void __init at91_add_device_rtt(void) 981static void __init at91_add_device_rtt(void)
1092{ 982{
1093 at91_add_device_rtt_rtc();
1094 platform_device_register(&at91sam9263_rtt0_device); 983 platform_device_register(&at91sam9263_rtt0_device);
1095 platform_device_register(&at91sam9263_rtt1_device); 984 platform_device_register(&at91sam9263_rtt1_device);
1096} 985}
@@ -1101,19 +990,10 @@ static void __init at91_add_device_rtt(void)
1101 * -------------------------------------------------------------------- */ 990 * -------------------------------------------------------------------- */
1102 991
1103#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) 992#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
1104static struct resource wdt_resources[] = {
1105 {
1106 .start = AT91SAM9263_BASE_WDT,
1107 .end = AT91SAM9263_BASE_WDT + SZ_16 - 1,
1108 .flags = IORESOURCE_MEM,
1109 }
1110};
1111
1112static struct platform_device at91sam9263_wdt_device = { 993static struct platform_device at91sam9263_wdt_device = {
1113 .name = "at91_wdt", 994 .name = "at91_wdt",
1114 .id = -1, 995 .id = -1,
1115 .resource = wdt_resources, 996 .num_resources = 0,
1116 .num_resources = ARRAY_SIZE(wdt_resources),
1117}; 997};
1118 998
1119static void __init at91_add_device_watchdog(void) 999static void __init at91_add_device_watchdog(void)
@@ -1139,8 +1019,8 @@ static struct resource pwm_resources[] = {
1139 .flags = IORESOURCE_MEM, 1019 .flags = IORESOURCE_MEM,
1140 }, 1020 },
1141 [1] = { 1021 [1] = {
1142 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_PWMC, 1022 .start = AT91SAM9263_ID_PWMC,
1143 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_PWMC, 1023 .end = AT91SAM9263_ID_PWMC,
1144 .flags = IORESOURCE_IRQ, 1024 .flags = IORESOURCE_IRQ,
1145 }, 1025 },
1146}; 1026};
@@ -1192,14 +1072,14 @@ static struct resource ssc0_resources[] = {
1192 .flags = IORESOURCE_MEM, 1072 .flags = IORESOURCE_MEM,
1193 }, 1073 },
1194 [1] = { 1074 [1] = {
1195 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_SSC0, 1075 .start = AT91SAM9263_ID_SSC0,
1196 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_SSC0, 1076 .end = AT91SAM9263_ID_SSC0,
1197 .flags = IORESOURCE_IRQ, 1077 .flags = IORESOURCE_IRQ,
1198 }, 1078 },
1199}; 1079};
1200 1080
1201static struct platform_device at91sam9263_ssc0_device = { 1081static struct platform_device at91sam9263_ssc0_device = {
1202 .name = "at91rm9200_ssc", 1082 .name = "ssc",
1203 .id = 0, 1083 .id = 0,
1204 .dev = { 1084 .dev = {
1205 .dma_mask = &ssc0_dmamask, 1085 .dma_mask = &ssc0_dmamask,
@@ -1234,14 +1114,14 @@ static struct resource ssc1_resources[] = {
1234 .flags = IORESOURCE_MEM, 1114 .flags = IORESOURCE_MEM,
1235 }, 1115 },
1236 [1] = { 1116 [1] = {
1237 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_SSC1, 1117 .start = AT91SAM9263_ID_SSC1,
1238 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_SSC1, 1118 .end = AT91SAM9263_ID_SSC1,
1239 .flags = IORESOURCE_IRQ, 1119 .flags = IORESOURCE_IRQ,
1240 }, 1120 },
1241}; 1121};
1242 1122
1243static struct platform_device at91sam9263_ssc1_device = { 1123static struct platform_device at91sam9263_ssc1_device = {
1244 .name = "at91rm9200_ssc", 1124 .name = "ssc",
1245 .id = 1, 1125 .id = 1,
1246 .dev = { 1126 .dev = {
1247 .dma_mask = &ssc1_dmamask, 1127 .dma_mask = &ssc1_dmamask,
@@ -1310,13 +1190,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
1310 1190
1311static struct resource dbgu_resources[] = { 1191static struct resource dbgu_resources[] = {
1312 [0] = { 1192 [0] = {
1313 .start = AT91SAM9263_BASE_DBGU, 1193 .start = AT91_VA_BASE_SYS + AT91_DBGU,
1314 .end = AT91SAM9263_BASE_DBGU + SZ_512 - 1, 1194 .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
1315 .flags = IORESOURCE_MEM, 1195 .flags = IORESOURCE_MEM,
1316 }, 1196 },
1317 [1] = { 1197 [1] = {
1318 .start = NR_IRQS_LEGACY + AT91_ID_SYS, 1198 .start = AT91_ID_SYS,
1319 .end = NR_IRQS_LEGACY + AT91_ID_SYS, 1199 .end = AT91_ID_SYS,
1320 .flags = IORESOURCE_IRQ, 1200 .flags = IORESOURCE_IRQ,
1321 }, 1201 },
1322}; 1202};
@@ -1324,6 +1204,7 @@ static struct resource dbgu_resources[] = {
1324static struct atmel_uart_data dbgu_data = { 1204static struct atmel_uart_data dbgu_data = {
1325 .use_dma_tx = 0, 1205 .use_dma_tx = 0,
1326 .use_dma_rx = 0, /* DBGU not capable of receive DMA */ 1206 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
1207 .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
1327}; 1208};
1328 1209
1329static u64 dbgu_dmamask = DMA_BIT_MASK(32); 1210static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -1353,8 +1234,8 @@ static struct resource uart0_resources[] = {
1353 .flags = IORESOURCE_MEM, 1234 .flags = IORESOURCE_MEM,
1354 }, 1235 },
1355 [1] = { 1236 [1] = {
1356 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_US0, 1237 .start = AT91SAM9263_ID_US0,
1357 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_US0, 1238 .end = AT91SAM9263_ID_US0,
1358 .flags = IORESOURCE_IRQ, 1239 .flags = IORESOURCE_IRQ,
1359 }, 1240 },
1360}; 1241};
@@ -1396,8 +1277,8 @@ static struct resource uart1_resources[] = {
1396 .flags = IORESOURCE_MEM, 1277 .flags = IORESOURCE_MEM,
1397 }, 1278 },
1398 [1] = { 1279 [1] = {
1399 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_US1, 1280 .start = AT91SAM9263_ID_US1,
1400 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_US1, 1281 .end = AT91SAM9263_ID_US1,
1401 .flags = IORESOURCE_IRQ, 1282 .flags = IORESOURCE_IRQ,
1402 }, 1283 },
1403}; 1284};
@@ -1439,8 +1320,8 @@ static struct resource uart2_resources[] = {
1439 .flags = IORESOURCE_MEM, 1320 .flags = IORESOURCE_MEM,
1440 }, 1321 },
1441 [1] = { 1322 [1] = {
1442 .start = NR_IRQS_LEGACY + AT91SAM9263_ID_US2, 1323 .start = AT91SAM9263_ID_US2,
1443 .end = NR_IRQS_LEGACY + AT91SAM9263_ID_US2, 1324 .end = AT91SAM9263_ID_US2,
1444 .flags = IORESOURCE_IRQ, 1325 .flags = IORESOURCE_IRQ,
1445 }, 1326 },
1446}; 1327};
@@ -1476,6 +1357,7 @@ static inline void configure_usart2_pins(unsigned pins)
1476} 1357}
1477 1358
1478static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1359static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1360struct platform_device *atmel_default_console_device; /* the serial console device */
1479 1361
1480void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1362void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1481{ 1363{
@@ -1509,6 +1391,14 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1509 at91_uarts[portnr] = pdev; 1391 at91_uarts[portnr] = pdev;
1510} 1392}
1511 1393
1394void __init at91_set_serial_console(unsigned portnr)
1395{
1396 if (portnr < ATMEL_MAX_UART) {
1397 atmel_default_console_device = at91_uarts[portnr];
1398 at91sam9263_set_console_clock(at91_uarts[portnr]->id);
1399 }
1400}
1401
1512void __init at91_add_device_serial(void) 1402void __init at91_add_device_serial(void)
1513{ 1403{
1514 int i; 1404 int i;
@@ -1517,9 +1407,13 @@ void __init at91_add_device_serial(void)
1517 if (at91_uarts[i]) 1407 if (at91_uarts[i])
1518 platform_device_register(at91_uarts[i]); 1408 platform_device_register(at91_uarts[i]);
1519 } 1409 }
1410
1411 if (!atmel_default_console_device)
1412 printk(KERN_INFO "AT91: No default serial console defined.\n");
1520} 1413}
1521#else 1414#else
1522void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1415void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1416void __init at91_set_serial_console(unsigned portnr) {}
1523void __init at91_add_device_serial(void) {} 1417void __init at91_add_device_serial(void) {}
1524#endif 1418#endif
1525 1419
@@ -1531,9 +1425,6 @@ void __init at91_add_device_serial(void) {}
1531 */ 1425 */
1532static int __init at91_add_standard_devices(void) 1426static int __init at91_add_standard_devices(void)
1533{ 1427{
1534 if (of_have_populated_dt())
1535 return 0;
1536
1537 at91_add_device_rtt(); 1428 at91_add_device_rtt();
1538 at91_add_device_watchdog(); 1429 at91_add_device_watchdog();
1539 at91_add_device_tc(); 1430 at91_add_device_tc();
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index 358412f1f5f..4ba85499fa9 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -14,41 +14,18 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/clk.h> 15#include <linux/clk.h>
16#include <linux/clockchips.h> 16#include <linux/clockchips.h>
17#include <linux/of.h>
18#include <linux/of_address.h>
19#include <linux/of_irq.h>
20 17
21#include <asm/mach/time.h> 18#include <asm/mach/time.h>
22 19
23#define AT91_PIT_MR 0x00 /* Mode Register */ 20#include <mach/at91_pit.h>
24#define AT91_PIT_PITIEN (1 << 25) /* Timer Interrupt Enable */
25#define AT91_PIT_PITEN (1 << 24) /* Timer Enabled */
26#define AT91_PIT_PIV (0xfffff) /* Periodic Interval Value */
27 21
28#define AT91_PIT_SR 0x04 /* Status Register */
29#define AT91_PIT_PITS (1 << 0) /* Timer Status */
30
31#define AT91_PIT_PIVR 0x08 /* Periodic Interval Value Register */
32#define AT91_PIT_PIIR 0x0c /* Periodic Interval Image Register */
33#define AT91_PIT_PICNT (0xfff << 20) /* Interval Counter */
34#define AT91_PIT_CPIV (0xfffff) /* Inverval Value */
35 22
36#define PIT_CPIV(x) ((x) & AT91_PIT_CPIV) 23#define PIT_CPIV(x) ((x) & AT91_PIT_CPIV)
37#define PIT_PICNT(x) (((x) & AT91_PIT_PICNT) >> 20) 24#define PIT_PICNT(x) (((x) & AT91_PIT_PICNT) >> 20)
38 25
39static u32 pit_cycle; /* write-once */ 26static u32 pit_cycle; /* write-once */
40static u32 pit_cnt; /* access only w/system irq blocked */ 27static u32 pit_cnt; /* access only w/system irq blocked */
41static void __iomem *pit_base_addr __read_mostly;
42 28
43static inline unsigned int pit_read(unsigned int reg_offset)
44{
45 return __raw_readl(pit_base_addr + reg_offset);
46}
47
48static inline void pit_write(unsigned int reg_offset, unsigned long value)
49{
50 __raw_writel(value, pit_base_addr + reg_offset);
51}
52 29
53/* 30/*
54 * Clocksource: just a monotonic counter of MCK/16 cycles. 31 * Clocksource: just a monotonic counter of MCK/16 cycles.
@@ -62,7 +39,7 @@ static cycle_t read_pit_clk(struct clocksource *cs)
62 39
63 raw_local_irq_save(flags); 40 raw_local_irq_save(flags);
64 elapsed = pit_cnt; 41 elapsed = pit_cnt;
65 t = pit_read(AT91_PIT_PIIR); 42 t = at91_sys_read(AT91_PIT_PIIR);
66 raw_local_irq_restore(flags); 43 raw_local_irq_restore(flags);
67 44
68 elapsed += PIT_PICNT(t) * pit_cycle; 45 elapsed += PIT_PICNT(t) * pit_cycle;
@@ -87,8 +64,8 @@ pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)
87 switch (mode) { 64 switch (mode) {
88 case CLOCK_EVT_MODE_PERIODIC: 65 case CLOCK_EVT_MODE_PERIODIC:
89 /* update clocksource counter */ 66 /* update clocksource counter */
90 pit_cnt += pit_cycle * PIT_PICNT(pit_read(AT91_PIT_PIVR)); 67 pit_cnt += pit_cycle * PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
91 pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN 68 at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN
92 | AT91_PIT_PITIEN); 69 | AT91_PIT_PITIEN);
93 break; 70 break;
94 case CLOCK_EVT_MODE_ONESHOT: 71 case CLOCK_EVT_MODE_ONESHOT:
@@ -97,7 +74,7 @@ pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)
97 case CLOCK_EVT_MODE_SHUTDOWN: 74 case CLOCK_EVT_MODE_SHUTDOWN:
98 case CLOCK_EVT_MODE_UNUSED: 75 case CLOCK_EVT_MODE_UNUSED:
99 /* disable irq, leaving the clocksource active */ 76 /* disable irq, leaving the clocksource active */
100 pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN); 77 at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
101 break; 78 break;
102 case CLOCK_EVT_MODE_RESUME: 79 case CLOCK_EVT_MODE_RESUME:
103 break; 80 break;
@@ -126,11 +103,11 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
126 103
127 /* The PIT interrupt may be disabled, and is shared */ 104 /* The PIT interrupt may be disabled, and is shared */
128 if ((pit_clkevt.mode == CLOCK_EVT_MODE_PERIODIC) 105 if ((pit_clkevt.mode == CLOCK_EVT_MODE_PERIODIC)
129 && (pit_read(AT91_PIT_SR) & AT91_PIT_PITS)) { 106 && (at91_sys_read(AT91_PIT_SR) & AT91_PIT_PITS)) {
130 unsigned nr_ticks; 107 unsigned nr_ticks;
131 108
132 /* Get number of ticks performed before irq, and ack it */ 109 /* Get number of ticks performed before irq, and ack it */
133 nr_ticks = PIT_PICNT(pit_read(AT91_PIT_PIVR)); 110 nr_ticks = PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
134 do { 111 do {
135 pit_cnt += pit_cycle; 112 pit_cnt += pit_cycle;
136 pit_clkevt.event_handler(&pit_clkevt); 113 pit_clkevt.event_handler(&pit_clkevt);
@@ -146,68 +123,22 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
146static struct irqaction at91sam926x_pit_irq = { 123static struct irqaction at91sam926x_pit_irq = {
147 .name = "at91_tick", 124 .name = "at91_tick",
148 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, 125 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
149 .handler = at91sam926x_pit_interrupt, 126 .handler = at91sam926x_pit_interrupt
150 .irq = NR_IRQS_LEGACY + AT91_ID_SYS,
151}; 127};
152 128
153static void at91sam926x_pit_reset(void) 129static void at91sam926x_pit_reset(void)
154{ 130{
155 /* Disable timer and irqs */ 131 /* Disable timer and irqs */
156 pit_write(AT91_PIT_MR, 0); 132 at91_sys_write(AT91_PIT_MR, 0);
157 133
158 /* Clear any pending interrupts, wait for PIT to stop counting */ 134 /* Clear any pending interrupts, wait for PIT to stop counting */
159 while (PIT_CPIV(pit_read(AT91_PIT_PIVR)) != 0) 135 while (PIT_CPIV(at91_sys_read(AT91_PIT_PIVR)) != 0)
160 cpu_relax(); 136 cpu_relax();
161 137
162 /* Start PIT but don't enable IRQ */ 138 /* Start PIT but don't enable IRQ */
163 pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN); 139 at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
164} 140}
165 141
166#ifdef CONFIG_OF
167static struct of_device_id pit_timer_ids[] = {
168 { .compatible = "atmel,at91sam9260-pit" },
169 { /* sentinel */ }
170};
171
172static int __init of_at91sam926x_pit_init(void)
173{
174 struct device_node *np;
175 int ret;
176
177 np = of_find_matching_node(NULL, pit_timer_ids);
178 if (!np)
179 goto err;
180
181 pit_base_addr = of_iomap(np, 0);
182 if (!pit_base_addr)
183 goto node_err;
184
185 /* Get the interrupts property */
186 ret = irq_of_parse_and_map(np, 0);
187 if (!ret) {
188 pr_crit("AT91: PIT: Unable to get IRQ from DT\n");
189 goto ioremap_err;
190 }
191 at91sam926x_pit_irq.irq = ret;
192
193 of_node_put(np);
194
195 return 0;
196
197ioremap_err:
198 iounmap(pit_base_addr);
199node_err:
200 of_node_put(np);
201err:
202 return -EINVAL;
203}
204#else
205static int __init of_at91sam926x_pit_init(void)
206{
207 return -EINVAL;
208}
209#endif
210
211/* 142/*
212 * Set up both clocksource and clockevent support. 143 * Set up both clocksource and clockevent support.
213 */ 144 */
@@ -215,10 +146,6 @@ static void __init at91sam926x_pit_init(void)
215{ 146{
216 unsigned long pit_rate; 147 unsigned long pit_rate;
217 unsigned bits; 148 unsigned bits;
218 int ret;
219
220 /* For device tree enabled device: initialize here */
221 of_at91sam926x_pit_init();
222 149
223 /* 150 /*
224 * Use our actual MCK to figure out how many MCK/16 ticks per 151 * Use our actual MCK to figure out how many MCK/16 ticks per
@@ -240,9 +167,7 @@ static void __init at91sam926x_pit_init(void)
240 clocksource_register_hz(&pit_clk, pit_rate); 167 clocksource_register_hz(&pit_clk, pit_rate);
241 168
242 /* Set up irq handler */ 169 /* Set up irq handler */
243 ret = setup_irq(at91sam926x_pit_irq.irq, &at91sam926x_pit_irq); 170 setup_irq(AT91_ID_SYS, &at91sam926x_pit_irq);
244 if (ret)
245 pr_crit("AT91: PIT: Unable to setup IRQ\n");
246 171
247 /* Set up and register clockevents */ 172 /* Set up and register clockevents */
248 pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift); 173 pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift);
@@ -253,24 +178,7 @@ static void __init at91sam926x_pit_init(void)
253static void at91sam926x_pit_suspend(void) 178static void at91sam926x_pit_suspend(void)
254{ 179{
255 /* Disable timer */ 180 /* Disable timer */
256 pit_write(AT91_PIT_MR, 0); 181 at91_sys_write(AT91_PIT_MR, 0);
257}
258
259void __init at91sam926x_ioremap_pit(u32 addr)
260{
261#if defined(CONFIG_OF)
262 struct device_node *np =
263 of_find_matching_node(NULL, pit_timer_ids);
264
265 if (np) {
266 of_node_put(np);
267 return;
268 }
269#endif
270 pit_base_addr = ioremap(addr, 16);
271
272 if (!pit_base_addr)
273 panic("Impossible to ioremap PIT\n");
274} 182}
275 183
276struct sys_timer at91sam926x_timer = { 184struct sys_timer at91sam926x_timer = {
diff --git a/arch/arm/mach-at91/at91sam9_alt_reset.S b/arch/arm/mach-at91/at91sam9_alt_reset.S
index f039538d3bd..e0256deb91f 100644
--- a/arch/arm/mach-at91/at91sam9_alt_reset.S
+++ b/arch/arm/mach-at91/at91sam9_alt_reset.S
@@ -14,18 +14,21 @@
14 */ 14 */
15 15
16#include <linux/linkage.h> 16#include <linux/linkage.h>
17#include <asm/system.h>
17#include <mach/hardware.h> 18#include <mach/hardware.h>
18#include <mach/at91_ramc.h> 19#include <mach/at91sam9_sdramc.h>
19#include "at91_rstc.h" 20#include <mach/at91_rstc.h>
20 21
21 .arm 22 .arm
22 23
23 .globl at91sam9_alt_restart 24 .globl at91sam9_alt_reset
24 25
25at91sam9_alt_restart: ldr r0, =at91_ramc_base @ preload constants 26at91sam9_alt_reset: mrc p15, 0, r0, c1, c0, 0
26 ldr r0, [r0] 27 orr r0, r0, #CR_I
27 ldr r4, =at91_rstc_base 28 mcr p15, 0, r0, c1, c0, 0 @ enable I-cache
28 ldr r1, [r4] 29
30 ldr r0, .at91_va_base_sdramc @ preload constants
31 ldr r1, .at91_va_base_rstc_cr
29 32
30 mov r2, #1 33 mov r2, #1
31 mov r3, #AT91_SDRAMC_LPCB_POWER_DOWN 34 mov r3, #AT91_SDRAMC_LPCB_POWER_DOWN
@@ -35,6 +38,11 @@ at91sam9_alt_restart: ldr r0, =at91_ramc_base @ preload constants
35 38
36 str r2, [r0, #AT91_SDRAMC_TR] @ disable SDRAM access 39 str r2, [r0, #AT91_SDRAMC_TR] @ disable SDRAM access
37 str r3, [r0, #AT91_SDRAMC_LPR] @ power down SDRAM 40 str r3, [r0, #AT91_SDRAMC_LPR] @ power down SDRAM
38 str r4, [r1, #AT91_RSTC_CR] @ reset processor 41 str r4, [r1] @ reset processor
39 42
40 b . 43 b .
44
45.at91_va_base_sdramc:
46 .word AT91_VA_BASE_SYS + AT91_SDRAMC0
47.at91_va_base_rstc_cr:
48 .word AT91_VA_BASE_SYS + AT91_RSTC_CR
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index d3addee43d8..e04c5fb6f1e 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -11,21 +11,20 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/dma-mapping.h> 14#include <linux/pm.h>
15 15
16#include <asm/irq.h> 16#include <asm/irq.h>
17#include <asm/mach/arch.h> 17#include <asm/mach/arch.h>
18#include <asm/mach/map.h> 18#include <asm/mach/map.h>
19#include <asm/system_misc.h>
20#include <mach/at91sam9g45.h> 19#include <mach/at91sam9g45.h>
21#include <mach/at91_pmc.h> 20#include <mach/at91_pmc.h>
21#include <mach/at91_rstc.h>
22#include <mach/at91_shdwc.h>
22#include <mach/cpu.h> 23#include <mach/cpu.h>
23 24
24#include "at91_aic.h"
25#include "soc.h" 25#include "soc.h"
26#include "generic.h" 26#include "generic.h"
27#include "clock.h" 27#include "clock.h"
28#include "sam9_smc.h"
29 28
30/* -------------------------------------------------------------------- 29/* --------------------------------------------------------------------
31 * Clocks 30 * Clocks
@@ -54,11 +53,6 @@ static struct clk pioDE_clk = {
54 .pmc_mask = 1 << AT91SAM9G45_ID_PIODE, 53 .pmc_mask = 1 << AT91SAM9G45_ID_PIODE,
55 .type = CLK_TYPE_PERIPHERAL, 54 .type = CLK_TYPE_PERIPHERAL,
56}; 55};
57static struct clk trng_clk = {
58 .name = "trng_clk",
59 .pmc_mask = 1 << AT91SAM9G45_ID_TRNG,
60 .type = CLK_TYPE_PERIPHERAL,
61};
62static struct clk usart0_clk = { 56static struct clk usart0_clk = {
63 .name = "usart0_clk", 57 .name = "usart0_clk",
64 .pmc_mask = 1 << AT91SAM9G45_ID_US0, 58 .pmc_mask = 1 << AT91SAM9G45_ID_US0,
@@ -150,7 +144,7 @@ static struct clk ac97_clk = {
150 .type = CLK_TYPE_PERIPHERAL, 144 .type = CLK_TYPE_PERIPHERAL,
151}; 145};
152static struct clk macb_clk = { 146static struct clk macb_clk = {
153 .name = "pclk", 147 .name = "macb_clk",
154 .pmc_mask = 1 << AT91SAM9G45_ID_EMAC, 148 .pmc_mask = 1 << AT91SAM9G45_ID_EMAC,
155 .type = CLK_TYPE_PERIPHERAL, 149 .type = CLK_TYPE_PERIPHERAL,
156}; 150};
@@ -177,25 +171,11 @@ static struct clk vdec_clk = {
177 .type = CLK_TYPE_PERIPHERAL, 171 .type = CLK_TYPE_PERIPHERAL,
178}; 172};
179 173
180static struct clk adc_op_clk = {
181 .name = "adc_op_clk",
182 .type = CLK_TYPE_PERIPHERAL,
183 .rate_hz = 13200000,
184};
185
186/* AES/TDES/SHA clock - Only for sam9m11/sam9g56 */
187static struct clk aestdessha_clk = {
188 .name = "aestdessha_clk",
189 .pmc_mask = 1 << AT91SAM9G45_ID_AESTDESSHA,
190 .type = CLK_TYPE_PERIPHERAL,
191};
192
193static struct clk *periph_clocks[] __initdata = { 174static struct clk *periph_clocks[] __initdata = {
194 &pioA_clk, 175 &pioA_clk,
195 &pioB_clk, 176 &pioB_clk,
196 &pioC_clk, 177 &pioC_clk,
197 &pioDE_clk, 178 &pioDE_clk,
198 &trng_clk,
199 &usart0_clk, 179 &usart0_clk,
200 &usart1_clk, 180 &usart1_clk,
201 &usart2_clk, 181 &usart2_clk,
@@ -218,14 +198,10 @@ static struct clk *periph_clocks[] __initdata = {
218 &isi_clk, 198 &isi_clk,
219 &udphs_clk, 199 &udphs_clk,
220 &mmc1_clk, 200 &mmc1_clk,
221 &adc_op_clk,
222 &aestdessha_clk,
223 // irq0 201 // irq0
224}; 202};
225 203
226static struct clk_lookup periph_clocks_lookups[] = { 204static struct clk_lookup periph_clocks_lookups[] = {
227 /* One additional fake clock for macb_hclk */
228 CLKDEV_CON_ID("hclk", &macb_clk),
229 /* One additional fake clock for ohci */ 205 /* One additional fake clock for ohci */
230 CLKDEV_CON_ID("ohci_clk", &uhphs_clk), 206 CLKDEV_CON_ID("ohci_clk", &uhphs_clk),
231 CLKDEV_CON_DEV_ID("ehci_clk", "atmel-ehci", &uhphs_clk), 207 CLKDEV_CON_DEV_ID("ehci_clk", "atmel-ehci", &uhphs_clk),
@@ -237,46 +213,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
237 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), 213 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
238 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb0_clk), 214 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb0_clk),
239 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tcb0_clk), 215 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tcb0_clk),
240 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi0_clk), 216 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
241 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.1", &twi1_clk), 217 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
242 CLKDEV_CON_DEV_ID("pclk", "at91sam9g45_ssc.0", &ssc0_clk),
243 CLKDEV_CON_DEV_ID("pclk", "at91sam9g45_ssc.1", &ssc1_clk),
244 CLKDEV_CON_DEV_ID("pclk", "fff9c000.ssc", &ssc0_clk),
245 CLKDEV_CON_DEV_ID("pclk", "fffa0000.ssc", &ssc1_clk),
246 CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk),
247 CLKDEV_CON_DEV_ID(NULL, "atmel_sha", &aestdessha_clk),
248 CLKDEV_CON_DEV_ID(NULL, "atmel_tdes", &aestdessha_clk),
249 CLKDEV_CON_DEV_ID(NULL, "atmel_aes", &aestdessha_clk),
250 /* more usart lookup table for DT entries */
251 CLKDEV_CON_DEV_ID("usart", "ffffee00.serial", &mck),
252 CLKDEV_CON_DEV_ID("usart", "fff8c000.serial", &usart0_clk),
253 CLKDEV_CON_DEV_ID("usart", "fff90000.serial", &usart1_clk),
254 CLKDEV_CON_DEV_ID("usart", "fff94000.serial", &usart2_clk),
255 CLKDEV_CON_DEV_ID("usart", "fff98000.serial", &usart3_clk),
256 /* more tc lookup table for DT entries */
257 CLKDEV_CON_DEV_ID("t0_clk", "fff7c000.timer", &tcb0_clk),
258 CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
259 CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
260 CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
261 CLKDEV_CON_DEV_ID("mci_clk", "fff80000.mmc", &mmc0_clk),
262 CLKDEV_CON_DEV_ID("mci_clk", "fffd0000.mmc", &mmc1_clk),
263 CLKDEV_CON_DEV_ID(NULL, "fff84000.i2c", &twi0_clk),
264 CLKDEV_CON_DEV_ID(NULL, "fff88000.i2c", &twi1_clk),
265 /* fake hclk clock */
266 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
267 CLKDEV_CON_DEV_ID(NULL, "fffff200.gpio", &pioA_clk),
268 CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioB_clk),
269 CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioC_clk),
270 CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioDE_clk),
271 CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioDE_clk),
272
273 CLKDEV_CON_ID("pioA", &pioA_clk),
274 CLKDEV_CON_ID("pioB", &pioB_clk),
275 CLKDEV_CON_ID("pioC", &pioC_clk),
276 CLKDEV_CON_ID("pioD", &pioDE_clk),
277 CLKDEV_CON_ID("pioE", &pioDE_clk),
278 /* Fake adc clock */
279 CLKDEV_CON_ID("adc_clk", &tsc_clk),
280}; 218};
281 219
282static struct clk_lookup usart_clocks_lookups[] = { 220static struct clk_lookup usart_clocks_lookups[] = {
@@ -323,29 +261,57 @@ static void __init at91sam9g45_register_clocks(void)
323 clk_register(&pck1); 261 clk_register(&pck1);
324} 262}
325 263
264static struct clk_lookup console_clock_lookup;
265
266void __init at91sam9g45_set_console_clock(int id)
267{
268 if (id >= ARRAY_SIZE(usart_clocks_lookups))
269 return;
270
271 console_clock_lookup.con_id = "usart";
272 console_clock_lookup.clk = usart_clocks_lookups[id].clk;
273 clkdev_add(&console_clock_lookup);
274}
275
326/* -------------------------------------------------------------------- 276/* --------------------------------------------------------------------
327 * GPIO 277 * GPIO
328 * -------------------------------------------------------------------- */ 278 * -------------------------------------------------------------------- */
329 279
330static struct at91_gpio_bank at91sam9g45_gpio[] __initdata = { 280static struct at91_gpio_bank at91sam9g45_gpio[] = {
331 { 281 {
332 .id = AT91SAM9G45_ID_PIOA, 282 .id = AT91SAM9G45_ID_PIOA,
333 .regbase = AT91SAM9G45_BASE_PIOA, 283 .offset = AT91_PIOA,
284 .clock = &pioA_clk,
334 }, { 285 }, {
335 .id = AT91SAM9G45_ID_PIOB, 286 .id = AT91SAM9G45_ID_PIOB,
336 .regbase = AT91SAM9G45_BASE_PIOB, 287 .offset = AT91_PIOB,
288 .clock = &pioB_clk,
337 }, { 289 }, {
338 .id = AT91SAM9G45_ID_PIOC, 290 .id = AT91SAM9G45_ID_PIOC,
339 .regbase = AT91SAM9G45_BASE_PIOC, 291 .offset = AT91_PIOC,
292 .clock = &pioC_clk,
340 }, { 293 }, {
341 .id = AT91SAM9G45_ID_PIODE, 294 .id = AT91SAM9G45_ID_PIODE,
342 .regbase = AT91SAM9G45_BASE_PIOD, 295 .offset = AT91_PIOD,
296 .clock = &pioDE_clk,
343 }, { 297 }, {
344 .id = AT91SAM9G45_ID_PIODE, 298 .id = AT91SAM9G45_ID_PIODE,
345 .regbase = AT91SAM9G45_BASE_PIOE, 299 .offset = AT91_PIOE,
300 .clock = &pioDE_clk,
346 } 301 }
347}; 302};
348 303
304static void at91sam9g45_reset(void)
305{
306 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
307}
308
309static void at91sam9g45_poweroff(void)
310{
311 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
312}
313
314
349/* -------------------------------------------------------------------- 315/* --------------------------------------------------------------------
350 * AT91SAM9G45 processor initialization 316 * AT91SAM9G45 processor initialization
351 * -------------------------------------------------------------------- */ 317 * -------------------------------------------------------------------- */
@@ -355,21 +321,10 @@ static void __init at91sam9g45_map_io(void)
355 at91_init_sram(0, AT91SAM9G45_SRAM_BASE, AT91SAM9G45_SRAM_SIZE); 321 at91_init_sram(0, AT91SAM9G45_SRAM_BASE, AT91SAM9G45_SRAM_SIZE);
356} 322}
357 323
358static void __init at91sam9g45_ioremap_registers(void)
359{
360 at91_ioremap_shdwc(AT91SAM9G45_BASE_SHDWC);
361 at91_ioremap_rstc(AT91SAM9G45_BASE_RSTC);
362 at91_ioremap_ramc(0, AT91SAM9G45_BASE_DDRSDRC1, 512);
363 at91_ioremap_ramc(1, AT91SAM9G45_BASE_DDRSDRC0, 512);
364 at91sam926x_ioremap_pit(AT91SAM9G45_BASE_PIT);
365 at91sam9_ioremap_smc(0, AT91SAM9G45_BASE_SMC);
366 at91_ioremap_matrix(AT91SAM9G45_BASE_MATRIX);
367}
368
369static void __init at91sam9g45_initialize(void) 324static void __init at91sam9g45_initialize(void)
370{ 325{
371 arm_pm_idle = at91sam9_idle; 326 at91_arch_reset = at91sam9g45_reset;
372 arm_pm_restart = at91sam9g45_restart; 327 pm_power_off = at91sam9g45_poweroff;
373 at91_extern_irq = (1 << AT91SAM9G45_ID_IRQ0); 328 at91_extern_irq = (1 << AT91SAM9G45_ID_IRQ0);
374 329
375 /* Register GPIO subsystem */ 330 /* Register GPIO subsystem */
@@ -412,16 +367,15 @@ static unsigned int at91sam9g45_default_irq_priority[NR_AIC_IRQS] __initdata = {
412 3, /* Ethernet */ 367 3, /* Ethernet */
413 0, /* Image Sensor Interface */ 368 0, /* Image Sensor Interface */
414 2, /* USB Device High speed port */ 369 2, /* USB Device High speed port */
415 0, /* AESTDESSHA Crypto HW Accelerators */ 370 0,
416 0, /* Multimedia Card Interface 1 */ 371 0, /* Multimedia Card Interface 1 */
417 0, 372 0,
418 0, /* Advanced Interrupt Controller (IRQ0) */ 373 0, /* Advanced Interrupt Controller (IRQ0) */
419}; 374};
420 375
421AT91_SOC_START(sam9g45) 376struct at91_init_soc __initdata at91sam9g45_soc = {
422 .map_io = at91sam9g45_map_io, 377 .map_io = at91sam9g45_map_io,
423 .default_irq_priority = at91sam9g45_default_irq_priority, 378 .default_irq_priority = at91sam9g45_default_irq_priority,
424 .ioremap_registers = at91sam9g45_ioremap_registers,
425 .register_clocks = at91sam9g45_register_clocks, 379 .register_clocks = at91sam9g45_register_clocks,
426 .init = at91sam9g45_initialize, 380 .init = at91sam9g45_initialize,
427AT91_SOC_END 381};
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 827c9f2a70f..371bb0ecb0d 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -13,31 +13,22 @@
13#include <asm/mach/map.h> 13#include <asm/mach/map.h>
14 14
15#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
16#include <linux/gpio.h>
17#include <linux/clk.h>
18#include <linux/platform_device.h> 16#include <linux/platform_device.h>
19#include <linux/i2c-gpio.h> 17#include <linux/i2c-gpio.h>
20#include <linux/atmel-mci.h> 18#include <linux/atmel-mci.h>
21#include <linux/platform_data/atmel-aes.h>
22
23#include <linux/platform_data/at91_adc.h>
24 19
25#include <linux/fb.h> 20#include <linux/fb.h>
26#include <video/atmel_lcdc.h> 21#include <video/atmel_lcdc.h>
27 22
28#include <mach/at91_adc.h> 23#include <mach/board.h>
24#include <mach/gpio.h>
29#include <mach/at91sam9g45.h> 25#include <mach/at91sam9g45.h>
30#include <mach/at91sam9g45_matrix.h> 26#include <mach/at91sam9g45_matrix.h>
31#include <mach/at91_matrix.h>
32#include <mach/at91sam9_smc.h> 27#include <mach/at91sam9_smc.h>
33#include <linux/platform_data/dma-atmel.h> 28#include <mach/at_hdmac.h>
34#include <mach/atmel-mci.h> 29#include <mach/atmel-mci.h>
35 30
36#include <media/atmel-isi.h>
37
38#include "board.h"
39#include "generic.h" 31#include "generic.h"
40#include "clock.h"
41 32
42 33
43/* -------------------------------------------------------------------- 34/* --------------------------------------------------------------------
@@ -47,25 +38,30 @@
47#if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE) 38#if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
48static u64 hdmac_dmamask = DMA_BIT_MASK(32); 39static u64 hdmac_dmamask = DMA_BIT_MASK(32);
49 40
41static struct at_dma_platform_data atdma_pdata = {
42 .nr_channels = 8,
43};
44
50static struct resource hdmac_resources[] = { 45static struct resource hdmac_resources[] = {
51 [0] = { 46 [0] = {
52 .start = AT91SAM9G45_BASE_DMA, 47 .start = AT91_BASE_SYS + AT91_DMA,
53 .end = AT91SAM9G45_BASE_DMA + SZ_512 - 1, 48 .end = AT91_BASE_SYS + AT91_DMA + SZ_512 - 1,
54 .flags = IORESOURCE_MEM, 49 .flags = IORESOURCE_MEM,
55 }, 50 },
56 [1] = { 51 [1] = {
57 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_DMA, 52 .start = AT91SAM9G45_ID_DMA,
58 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_DMA, 53 .end = AT91SAM9G45_ID_DMA,
59 .flags = IORESOURCE_IRQ, 54 .flags = IORESOURCE_IRQ,
60 }, 55 },
61}; 56};
62 57
63static struct platform_device at_hdmac_device = { 58static struct platform_device at_hdmac_device = {
64 .name = "at91sam9g45_dma", 59 .name = "at_hdmac",
65 .id = -1, 60 .id = -1,
66 .dev = { 61 .dev = {
67 .dma_mask = &hdmac_dmamask, 62 .dma_mask = &hdmac_dmamask,
68 .coherent_dma_mask = DMA_BIT_MASK(32), 63 .coherent_dma_mask = DMA_BIT_MASK(32),
64 .platform_data = &atdma_pdata,
69 }, 65 },
70 .resource = hdmac_resources, 66 .resource = hdmac_resources,
71 .num_resources = ARRAY_SIZE(hdmac_resources), 67 .num_resources = ARRAY_SIZE(hdmac_resources),
@@ -73,6 +69,8 @@ static struct platform_device at_hdmac_device = {
73 69
74void __init at91_add_device_hdmac(void) 70void __init at91_add_device_hdmac(void)
75{ 71{
72 dma_cap_set(DMA_MEMCPY, atdma_pdata.cap_mask);
73 dma_cap_set(DMA_SLAVE, atdma_pdata.cap_mask);
76 platform_device_register(&at_hdmac_device); 74 platform_device_register(&at_hdmac_device);
77} 75}
78#else 76#else
@@ -95,8 +93,8 @@ static struct resource usbh_ohci_resources[] = {
95 .flags = IORESOURCE_MEM, 93 .flags = IORESOURCE_MEM,
96 }, 94 },
97 [1] = { 95 [1] = {
98 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS, 96 .start = AT91SAM9G45_ID_UHPHS,
99 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS, 97 .end = AT91SAM9G45_ID_UHPHS,
100 .flags = IORESOURCE_IRQ, 98 .flags = IORESOURCE_IRQ,
101 }, 99 },
102}; 100};
@@ -122,15 +120,8 @@ void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data)
122 120
123 /* Enable VBus control for UHP ports */ 121 /* Enable VBus control for UHP ports */
124 for (i = 0; i < data->ports; i++) { 122 for (i = 0; i < data->ports; i++) {
125 if (gpio_is_valid(data->vbus_pin[i])) 123 if (data->vbus_pin[i])
126 at91_set_gpio_output(data->vbus_pin[i], 124 at91_set_gpio_output(data->vbus_pin[i], 0);
127 data->vbus_pin_active_low[i]);
128 }
129
130 /* Enable overcurrent notification */
131 for (i = 0; i < data->ports; i++) {
132 if (gpio_is_valid(data->overcurrent_pin[i]))
133 at91_set_gpio_input(data->overcurrent_pin[i], 1);
134 } 125 }
135 126
136 usbh_ohci_data = *data; 127 usbh_ohci_data = *data;
@@ -157,8 +148,8 @@ static struct resource usbh_ehci_resources[] = {
157 .flags = IORESOURCE_MEM, 148 .flags = IORESOURCE_MEM,
158 }, 149 },
159 [1] = { 150 [1] = {
160 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS, 151 .start = AT91SAM9G45_ID_UHPHS,
161 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS, 152 .end = AT91SAM9G45_ID_UHPHS,
162 .flags = IORESOURCE_IRQ, 153 .flags = IORESOURCE_IRQ,
163 }, 154 },
164}; 155};
@@ -184,9 +175,8 @@ void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data)
184 175
185 /* Enable VBus control for UHP ports */ 176 /* Enable VBus control for UHP ports */
186 for (i = 0; i < data->ports; i++) { 177 for (i = 0; i < data->ports; i++) {
187 if (gpio_is_valid(data->vbus_pin[i])) 178 if (data->vbus_pin[i])
188 at91_set_gpio_output(data->vbus_pin[i], 179 at91_set_gpio_output(data->vbus_pin[i], 0);
189 data->vbus_pin_active_low[i]);
190 } 180 }
191 181
192 usbh_ehci_data = *data; 182 usbh_ehci_data = *data;
@@ -214,8 +204,8 @@ static struct resource usba_udc_resources[] = {
214 .flags = IORESOURCE_MEM, 204 .flags = IORESOURCE_MEM,
215 }, 205 },
216 [2] = { 206 [2] = {
217 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UDPHS, 207 .start = AT91SAM9G45_ID_UDPHS,
218 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UDPHS, 208 .end = AT91SAM9G45_ID_UDPHS,
219 .flags = IORESOURCE_IRQ, 209 .flags = IORESOURCE_IRQ,
220 }, 210 },
221}; 211};
@@ -267,7 +257,7 @@ void __init at91_add_device_usba(struct usba_platform_data *data)
267 usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep); 257 usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
268 memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep)); 258 memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));
269 259
270 if (data && gpio_is_valid(data->vbus_pin)) { 260 if (data && data->vbus_pin > 0) {
271 at91_set_gpio_input(data->vbus_pin, 0); 261 at91_set_gpio_input(data->vbus_pin, 0);
272 at91_set_deglitch(data->vbus_pin, 1); 262 at91_set_deglitch(data->vbus_pin, 1);
273 usba_udc_data.pdata.vbus_pin = data->vbus_pin; 263 usba_udc_data.pdata.vbus_pin = data->vbus_pin;
@@ -288,7 +278,7 @@ void __init at91_add_device_usba(struct usba_platform_data *data) {}
288 278
289#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE) 279#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
290static u64 eth_dmamask = DMA_BIT_MASK(32); 280static u64 eth_dmamask = DMA_BIT_MASK(32);
291static struct macb_platform_data eth_data; 281static struct at91_eth_data eth_data;
292 282
293static struct resource eth_resources[] = { 283static struct resource eth_resources[] = {
294 [0] = { 284 [0] = {
@@ -297,8 +287,8 @@ static struct resource eth_resources[] = {
297 .flags = IORESOURCE_MEM, 287 .flags = IORESOURCE_MEM,
298 }, 288 },
299 [1] = { 289 [1] = {
300 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_EMAC, 290 .start = AT91SAM9G45_ID_EMAC,
301 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_EMAC, 291 .end = AT91SAM9G45_ID_EMAC,
302 .flags = IORESOURCE_IRQ, 292 .flags = IORESOURCE_IRQ,
303 }, 293 },
304}; 294};
@@ -315,12 +305,12 @@ static struct platform_device at91sam9g45_eth_device = {
315 .num_resources = ARRAY_SIZE(eth_resources), 305 .num_resources = ARRAY_SIZE(eth_resources),
316}; 306};
317 307
318void __init at91_add_device_eth(struct macb_platform_data *data) 308void __init at91_add_device_eth(struct at91_eth_data *data)
319{ 309{
320 if (!data) 310 if (!data)
321 return; 311 return;
322 312
323 if (gpio_is_valid(data->phy_irq_pin)) { 313 if (data->phy_irq_pin) {
324 at91_set_gpio_input(data->phy_irq_pin, 0); 314 at91_set_gpio_input(data->phy_irq_pin, 0);
325 at91_set_deglitch(data->phy_irq_pin, 1); 315 at91_set_deglitch(data->phy_irq_pin, 1);
326 } 316 }
@@ -352,7 +342,7 @@ void __init at91_add_device_eth(struct macb_platform_data *data)
352 platform_device_register(&at91sam9g45_eth_device); 342 platform_device_register(&at91sam9g45_eth_device);
353} 343}
354#else 344#else
355void __init at91_add_device_eth(struct macb_platform_data *data) {} 345void __init at91_add_device_eth(struct at91_eth_data *data) {}
356#endif 346#endif
357 347
358 348
@@ -371,8 +361,8 @@ static struct resource mmc0_resources[] = {
371 .flags = IORESOURCE_MEM, 361 .flags = IORESOURCE_MEM,
372 }, 362 },
373 [1] = { 363 [1] = {
374 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI0, 364 .start = AT91SAM9G45_ID_MCI0,
375 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI0, 365 .end = AT91SAM9G45_ID_MCI0,
376 .flags = IORESOURCE_IRQ, 366 .flags = IORESOURCE_IRQ,
377 }, 367 },
378}; 368};
@@ -396,8 +386,8 @@ static struct resource mmc1_resources[] = {
396 .flags = IORESOURCE_MEM, 386 .flags = IORESOURCE_MEM,
397 }, 387 },
398 [1] = { 388 [1] = {
399 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI1, 389 .start = AT91SAM9G45_ID_MCI1,
400 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_MCI1, 390 .end = AT91SAM9G45_ID_MCI1,
401 .flags = IORESOURCE_IRQ, 391 .flags = IORESOURCE_IRQ,
402 }, 392 },
403}; 393};
@@ -435,8 +425,10 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
435 425
436 /* DMA slave channel configuration */ 426 /* DMA slave channel configuration */
437 atslave->dma_dev = &at_hdmac_device.dev; 427 atslave->dma_dev = &at_hdmac_device.dev;
428 atslave->reg_width = AT_DMA_SLAVE_WIDTH_32BIT;
438 atslave->cfg = ATC_FIFOCFG_HALFFIFO 429 atslave->cfg = ATC_FIFOCFG_HALFFIFO
439 | ATC_SRC_H2SEL_HW | ATC_DST_H2SEL_HW; 430 | ATC_SRC_H2SEL_HW | ATC_DST_H2SEL_HW;
431 atslave->ctrla = ATC_SCSIZE_16 | ATC_DCSIZE_16;
440 if (mmc_id == 0) /* MCI0 */ 432 if (mmc_id == 0) /* MCI0 */
441 atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI0) 433 atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI0)
442 | ATC_DST_PER(AT_DMA_ID_MCI0); 434 | ATC_DST_PER(AT_DMA_ID_MCI0);
@@ -451,11 +443,11 @@ void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
451 443
452 444
453 /* input/irq */ 445 /* input/irq */
454 if (gpio_is_valid(data->slot[0].detect_pin)) { 446 if (data->slot[0].detect_pin) {
455 at91_set_gpio_input(data->slot[0].detect_pin, 1); 447 at91_set_gpio_input(data->slot[0].detect_pin, 1);
456 at91_set_deglitch(data->slot[0].detect_pin, 1); 448 at91_set_deglitch(data->slot[0].detect_pin, 1);
457 } 449 }
458 if (gpio_is_valid(data->slot[0].wp_pin)) 450 if (data->slot[0].wp_pin)
459 at91_set_gpio_input(data->slot[0].wp_pin, 1); 451 at91_set_gpio_input(data->slot[0].wp_pin, 1);
460 452
461 if (mmc_id == 0) { /* MCI0 */ 453 if (mmc_id == 0) { /* MCI0 */
@@ -531,8 +523,8 @@ static struct resource nand_resources[] = {
531 .flags = IORESOURCE_MEM, 523 .flags = IORESOURCE_MEM,
532 }, 524 },
533 [1] = { 525 [1] = {
534 .start = AT91SAM9G45_BASE_ECC, 526 .start = AT91_BASE_SYS + AT91_ECC,
535 .end = AT91SAM9G45_BASE_ECC + SZ_512 - 1, 527 .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
536 .flags = IORESOURCE_MEM, 528 .flags = IORESOURCE_MEM,
537 } 529 }
538}; 530};
@@ -554,19 +546,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
554 if (!data) 546 if (!data)
555 return; 547 return;
556 548
557 csa = at91_matrix_read(AT91_MATRIX_EBICSA); 549 csa = at91_sys_read(AT91_MATRIX_EBICSA);
558 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA); 550 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA);
559 551
560 /* enable pin */ 552 /* enable pin */
561 if (gpio_is_valid(data->enable_pin)) 553 if (data->enable_pin)
562 at91_set_gpio_output(data->enable_pin, 1); 554 at91_set_gpio_output(data->enable_pin, 1);
563 555
564 /* ready/busy pin */ 556 /* ready/busy pin */
565 if (gpio_is_valid(data->rdy_pin)) 557 if (data->rdy_pin)
566 at91_set_gpio_input(data->rdy_pin, 1); 558 at91_set_gpio_input(data->rdy_pin, 1);
567 559
568 /* card detect pin */ 560 /* card detect pin */
569 if (gpio_is_valid(data->det_pin)) 561 if (data->det_pin)
570 at91_set_gpio_input(data->det_pin, 1); 562 at91_set_gpio_input(data->det_pin, 1);
571 563
572 nand_data = *data; 564 nand_data = *data;
@@ -646,14 +638,14 @@ static struct resource twi0_resources[] = {
646 .flags = IORESOURCE_MEM, 638 .flags = IORESOURCE_MEM,
647 }, 639 },
648 [1] = { 640 [1] = {
649 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI0, 641 .start = AT91SAM9G45_ID_TWI0,
650 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI0, 642 .end = AT91SAM9G45_ID_TWI0,
651 .flags = IORESOURCE_IRQ, 643 .flags = IORESOURCE_IRQ,
652 }, 644 },
653}; 645};
654 646
655static struct platform_device at91sam9g45_twi0_device = { 647static struct platform_device at91sam9g45_twi0_device = {
656 .name = "i2c-at91sam9g10", 648 .name = "at91_i2c",
657 .id = 0, 649 .id = 0,
658 .resource = twi0_resources, 650 .resource = twi0_resources,
659 .num_resources = ARRAY_SIZE(twi0_resources), 651 .num_resources = ARRAY_SIZE(twi0_resources),
@@ -666,14 +658,14 @@ static struct resource twi1_resources[] = {
666 .flags = IORESOURCE_MEM, 658 .flags = IORESOURCE_MEM,
667 }, 659 },
668 [1] = { 660 [1] = {
669 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI1, 661 .start = AT91SAM9G45_ID_TWI1,
670 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TWI1, 662 .end = AT91SAM9G45_ID_TWI1,
671 .flags = IORESOURCE_IRQ, 663 .flags = IORESOURCE_IRQ,
672 }, 664 },
673}; 665};
674 666
675static struct platform_device at91sam9g45_twi1_device = { 667static struct platform_device at91sam9g45_twi1_device = {
676 .name = "i2c-at91sam9g10", 668 .name = "at91_i2c",
677 .id = 1, 669 .id = 1,
678 .resource = twi1_resources, 670 .resource = twi1_resources,
679 .num_resources = ARRAY_SIZE(twi1_resources), 671 .num_resources = ARRAY_SIZE(twi1_resources),
@@ -686,12 +678,18 @@ void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, in
686 /* pins used for TWI interface */ 678 /* pins used for TWI interface */
687 if (i2c_id == 0) { 679 if (i2c_id == 0) {
688 at91_set_A_periph(AT91_PIN_PA20, 0); /* TWD */ 680 at91_set_A_periph(AT91_PIN_PA20, 0); /* TWD */
681 at91_set_multi_drive(AT91_PIN_PA20, 1);
682
689 at91_set_A_periph(AT91_PIN_PA21, 0); /* TWCK */ 683 at91_set_A_periph(AT91_PIN_PA21, 0); /* TWCK */
684 at91_set_multi_drive(AT91_PIN_PA21, 1);
690 685
691 platform_device_register(&at91sam9g45_twi0_device); 686 platform_device_register(&at91sam9g45_twi0_device);
692 } else { 687 } else {
693 at91_set_A_periph(AT91_PIN_PB10, 0); /* TWD */ 688 at91_set_A_periph(AT91_PIN_PB10, 0); /* TWD */
689 at91_set_multi_drive(AT91_PIN_PB10, 1);
690
694 at91_set_A_periph(AT91_PIN_PB11, 0); /* TWCK */ 691 at91_set_A_periph(AT91_PIN_PB11, 0); /* TWCK */
692 at91_set_multi_drive(AT91_PIN_PB11, 1);
695 693
696 platform_device_register(&at91sam9g45_twi1_device); 694 platform_device_register(&at91sam9g45_twi1_device);
697 } 695 }
@@ -715,8 +713,8 @@ static struct resource spi0_resources[] = {
715 .flags = IORESOURCE_MEM, 713 .flags = IORESOURCE_MEM,
716 }, 714 },
717 [1] = { 715 [1] = {
718 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI0, 716 .start = AT91SAM9G45_ID_SPI0,
719 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI0, 717 .end = AT91SAM9G45_ID_SPI0,
720 .flags = IORESOURCE_IRQ, 718 .flags = IORESOURCE_IRQ,
721 }, 719 },
722}; 720};
@@ -741,8 +739,8 @@ static struct resource spi1_resources[] = {
741 .flags = IORESOURCE_MEM, 739 .flags = IORESOURCE_MEM,
742 }, 740 },
743 [1] = { 741 [1] = {
744 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI1, 742 .start = AT91SAM9G45_ID_SPI1,
745 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SPI1, 743 .end = AT91SAM9G45_ID_SPI1,
746 .flags = IORESOURCE_IRQ, 744 .flags = IORESOURCE_IRQ,
747 }, 745 },
748}; 746};
@@ -776,9 +774,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
776 else 774 else
777 cs_pin = spi1_standard_cs[devices[i].chip_select]; 775 cs_pin = spi1_standard_cs[devices[i].chip_select];
778 776
779 if (!gpio_is_valid(cs_pin))
780 continue;
781
782 if (devices[i].bus_num == 0) 777 if (devices[i].bus_num == 0)
783 enable_spi0 = 1; 778 enable_spi0 = 1;
784 else 779 else
@@ -829,8 +824,8 @@ static struct resource ac97_resources[] = {
829 .flags = IORESOURCE_MEM, 824 .flags = IORESOURCE_MEM,
830 }, 825 },
831 [1] = { 826 [1] = {
832 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AC97C, 827 .start = AT91SAM9G45_ID_AC97C,
833 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AC97C, 828 .end = AT91SAM9G45_ID_AC97C,
834 .flags = IORESOURCE_IRQ, 829 .flags = IORESOURCE_IRQ,
835 }, 830 },
836}; 831};
@@ -858,7 +853,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data)
858 at91_set_A_periph(AT91_PIN_PD6, 0); /* AC97RX */ 853 at91_set_A_periph(AT91_PIN_PD6, 0); /* AC97RX */
859 854
860 /* reset */ 855 /* reset */
861 if (gpio_is_valid(data->reset_pin)) 856 if (data->reset_pin)
862 at91_set_gpio_output(data->reset_pin, 0); 857 at91_set_gpio_output(data->reset_pin, 0);
863 858
864 ac97_data = *data; 859 ac97_data = *data;
@@ -868,96 +863,6 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data)
868void __init at91_add_device_ac97(struct ac97c_platform_data *data) {} 863void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
869#endif 864#endif
870 865
871/* --------------------------------------------------------------------
872 * Image Sensor Interface
873 * -------------------------------------------------------------------- */
874#if defined(CONFIG_VIDEO_ATMEL_ISI) || defined(CONFIG_VIDEO_ATMEL_ISI_MODULE)
875static u64 isi_dmamask = DMA_BIT_MASK(32);
876static struct isi_platform_data isi_data;
877
878struct resource isi_resources[] = {
879 [0] = {
880 .start = AT91SAM9G45_BASE_ISI,
881 .end = AT91SAM9G45_BASE_ISI + SZ_16K - 1,
882 .flags = IORESOURCE_MEM,
883 },
884 [1] = {
885 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_ISI,
886 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_ISI,
887 .flags = IORESOURCE_IRQ,
888 },
889};
890
891static struct platform_device at91sam9g45_isi_device = {
892 .name = "atmel_isi",
893 .id = 0,
894 .dev = {
895 .dma_mask = &isi_dmamask,
896 .coherent_dma_mask = DMA_BIT_MASK(32),
897 .platform_data = &isi_data,
898 },
899 .resource = isi_resources,
900 .num_resources = ARRAY_SIZE(isi_resources),
901};
902
903static struct clk_lookup isi_mck_lookups[] = {
904 CLKDEV_CON_DEV_ID("isi_mck", "atmel_isi.0", NULL),
905};
906
907void __init at91_add_device_isi(struct isi_platform_data *data,
908 bool use_pck_as_mck)
909{
910 struct clk *pck;
911 struct clk *parent;
912
913 if (!data)
914 return;
915 isi_data = *data;
916
917 at91_set_A_periph(AT91_PIN_PB20, 0); /* ISI_D0 */
918 at91_set_A_periph(AT91_PIN_PB21, 0); /* ISI_D1 */
919 at91_set_A_periph(AT91_PIN_PB22, 0); /* ISI_D2 */
920 at91_set_A_periph(AT91_PIN_PB23, 0); /* ISI_D3 */
921 at91_set_A_periph(AT91_PIN_PB24, 0); /* ISI_D4 */
922 at91_set_A_periph(AT91_PIN_PB25, 0); /* ISI_D5 */
923 at91_set_A_periph(AT91_PIN_PB26, 0); /* ISI_D6 */
924 at91_set_A_periph(AT91_PIN_PB27, 0); /* ISI_D7 */
925 at91_set_A_periph(AT91_PIN_PB28, 0); /* ISI_PCK */
926 at91_set_A_periph(AT91_PIN_PB30, 0); /* ISI_HSYNC */
927 at91_set_A_periph(AT91_PIN_PB29, 0); /* ISI_VSYNC */
928 at91_set_B_periph(AT91_PIN_PB8, 0); /* ISI_PD8 */
929 at91_set_B_periph(AT91_PIN_PB9, 0); /* ISI_PD9 */
930 at91_set_B_periph(AT91_PIN_PB10, 0); /* ISI_PD10 */
931 at91_set_B_periph(AT91_PIN_PB11, 0); /* ISI_PD11 */
932
933 platform_device_register(&at91sam9g45_isi_device);
934
935 if (use_pck_as_mck) {
936 at91_set_B_periph(AT91_PIN_PB31, 0); /* ISI_MCK (PCK1) */
937
938 pck = clk_get(NULL, "pck1");
939 parent = clk_get(NULL, "plla");
940
941 BUG_ON(IS_ERR(pck) || IS_ERR(parent));
942
943 if (clk_set_parent(pck, parent)) {
944 pr_err("Failed to set PCK's parent\n");
945 } else {
946 /* Register PCK as ISI_MCK */
947 isi_mck_lookups[0].clk = pck;
948 clkdev_add_table(isi_mck_lookups,
949 ARRAY_SIZE(isi_mck_lookups));
950 }
951
952 clk_put(pck);
953 clk_put(parent);
954 }
955}
956#else
957void __init at91_add_device_isi(struct isi_platform_data *data,
958 bool use_pck_as_mck) {}
959#endif
960
961 866
962/* -------------------------------------------------------------------- 867/* --------------------------------------------------------------------
963 * LCD Controller 868 * LCD Controller
@@ -974,8 +879,8 @@ static struct resource lcdc_resources[] = {
974 .flags = IORESOURCE_MEM, 879 .flags = IORESOURCE_MEM,
975 }, 880 },
976 [1] = { 881 [1] = {
977 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_LCDC, 882 .start = AT91SAM9G45_ID_LCDC,
978 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_LCDC, 883 .end = AT91SAM9G45_ID_LCDC,
979 .flags = IORESOURCE_IRQ, 884 .flags = IORESOURCE_IRQ,
980 }, 885 },
981}; 886};
@@ -1045,12 +950,12 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
1045static struct resource tcb0_resources[] = { 950static struct resource tcb0_resources[] = {
1046 [0] = { 951 [0] = {
1047 .start = AT91SAM9G45_BASE_TCB0, 952 .start = AT91SAM9G45_BASE_TCB0,
1048 .end = AT91SAM9G45_BASE_TCB0 + SZ_256 - 1, 953 .end = AT91SAM9G45_BASE_TCB0 + SZ_16K - 1,
1049 .flags = IORESOURCE_MEM, 954 .flags = IORESOURCE_MEM,
1050 }, 955 },
1051 [1] = { 956 [1] = {
1052 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB, 957 .start = AT91SAM9G45_ID_TCB,
1053 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB, 958 .end = AT91SAM9G45_ID_TCB,
1054 .flags = IORESOURCE_IRQ, 959 .flags = IORESOURCE_IRQ,
1055 }, 960 },
1056}; 961};
@@ -1066,12 +971,12 @@ static struct platform_device at91sam9g45_tcb0_device = {
1066static struct resource tcb1_resources[] = { 971static struct resource tcb1_resources[] = {
1067 [0] = { 972 [0] = {
1068 .start = AT91SAM9G45_BASE_TCB1, 973 .start = AT91SAM9G45_BASE_TCB1,
1069 .end = AT91SAM9G45_BASE_TCB1 + SZ_256 - 1, 974 .end = AT91SAM9G45_BASE_TCB1 + SZ_16K - 1,
1070 .flags = IORESOURCE_MEM, 975 .flags = IORESOURCE_MEM,
1071 }, 976 },
1072 [1] = { 977 [1] = {
1073 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB, 978 .start = AT91SAM9G45_ID_TCB,
1074 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TCB, 979 .end = AT91SAM9G45_ID_TCB,
1075 .flags = IORESOURCE_IRQ, 980 .flags = IORESOURCE_IRQ,
1076 }, 981 },
1077}; 982};
@@ -1098,24 +1003,10 @@ static void __init at91_add_device_tc(void) { }
1098 * -------------------------------------------------------------------- */ 1003 * -------------------------------------------------------------------- */
1099 1004
1100#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE) 1005#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
1101static struct resource rtc_resources[] = {
1102 [0] = {
1103 .start = AT91SAM9G45_BASE_RTC,
1104 .end = AT91SAM9G45_BASE_RTC + SZ_256 - 1,
1105 .flags = IORESOURCE_MEM,
1106 },
1107 [1] = {
1108 .start = NR_IRQS_LEGACY + AT91_ID_SYS,
1109 .end = NR_IRQS_LEGACY + AT91_ID_SYS,
1110 .flags = IORESOURCE_IRQ,
1111 },
1112};
1113
1114static struct platform_device at91sam9g45_rtc_device = { 1006static struct platform_device at91sam9g45_rtc_device = {
1115 .name = "at91_rtc", 1007 .name = "at91_rtc",
1116 .id = -1, 1008 .id = -1,
1117 .resource = rtc_resources, 1009 .num_resources = 0,
1118 .num_resources = ARRAY_SIZE(rtc_resources),
1119}; 1010};
1120 1011
1121static void __init at91_add_device_rtc(void) 1012static void __init at91_add_device_rtc(void)
@@ -1142,8 +1033,8 @@ static struct resource tsadcc_resources[] = {
1142 .flags = IORESOURCE_MEM, 1033 .flags = IORESOURCE_MEM,
1143 }, 1034 },
1144 [1] = { 1035 [1] = {
1145 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC, 1036 .start = AT91SAM9G45_ID_TSC,
1146 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC, 1037 .end = AT91SAM9G45_ID_TSC,
1147 .flags = IORESOURCE_IRQ, 1038 .flags = IORESOURCE_IRQ,
1148 } 1039 }
1149}; 1040};
@@ -1179,116 +1070,14 @@ void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {}
1179 1070
1180 1071
1181/* -------------------------------------------------------------------- 1072/* --------------------------------------------------------------------
1182 * ADC
1183 * -------------------------------------------------------------------- */
1184
1185#if IS_ENABLED(CONFIG_AT91_ADC)
1186static struct at91_adc_data adc_data;
1187
1188static struct resource adc_resources[] = {
1189 [0] = {
1190 .start = AT91SAM9G45_BASE_TSC,
1191 .end = AT91SAM9G45_BASE_TSC + SZ_16K - 1,
1192 .flags = IORESOURCE_MEM,
1193 },
1194 [1] = {
1195 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC,
1196 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_TSC,
1197 .flags = IORESOURCE_IRQ,
1198 }
1199};
1200
1201static struct platform_device at91_adc_device = {
1202 .name = "at91_adc",
1203 .id = -1,
1204 .dev = {
1205 .platform_data = &adc_data,
1206 },
1207 .resource = adc_resources,
1208 .num_resources = ARRAY_SIZE(adc_resources),
1209};
1210
1211static struct at91_adc_trigger at91_adc_triggers[] = {
1212 [0] = {
1213 .name = "external-rising",
1214 .value = 1,
1215 .is_external = true,
1216 },
1217 [1] = {
1218 .name = "external-falling",
1219 .value = 2,
1220 .is_external = true,
1221 },
1222 [2] = {
1223 .name = "external-any",
1224 .value = 3,
1225 .is_external = true,
1226 },
1227 [3] = {
1228 .name = "continuous",
1229 .value = 6,
1230 .is_external = false,
1231 },
1232};
1233
1234static struct at91_adc_reg_desc at91_adc_register_g45 = {
1235 .channel_base = AT91_ADC_CHR(0),
1236 .drdy_mask = AT91_ADC_DRDY,
1237 .status_register = AT91_ADC_SR,
1238 .trigger_register = 0x08,
1239};
1240
1241void __init at91_add_device_adc(struct at91_adc_data *data)
1242{
1243 if (!data)
1244 return;
1245
1246 if (test_bit(0, &data->channels_used))
1247 at91_set_gpio_input(AT91_PIN_PD20, 0);
1248 if (test_bit(1, &data->channels_used))
1249 at91_set_gpio_input(AT91_PIN_PD21, 0);
1250 if (test_bit(2, &data->channels_used))
1251 at91_set_gpio_input(AT91_PIN_PD22, 0);
1252 if (test_bit(3, &data->channels_used))
1253 at91_set_gpio_input(AT91_PIN_PD23, 0);
1254 if (test_bit(4, &data->channels_used))
1255 at91_set_gpio_input(AT91_PIN_PD24, 0);
1256 if (test_bit(5, &data->channels_used))
1257 at91_set_gpio_input(AT91_PIN_PD25, 0);
1258 if (test_bit(6, &data->channels_used))
1259 at91_set_gpio_input(AT91_PIN_PD26, 0);
1260 if (test_bit(7, &data->channels_used))
1261 at91_set_gpio_input(AT91_PIN_PD27, 0);
1262
1263 if (data->use_external_triggers)
1264 at91_set_A_periph(AT91_PIN_PD28, 0);
1265
1266 data->num_channels = 8;
1267 data->startup_time = 40;
1268 data->registers = &at91_adc_register_g45;
1269 data->trigger_number = 4;
1270 data->trigger_list = at91_adc_triggers;
1271
1272 adc_data = *data;
1273 platform_device_register(&at91_adc_device);
1274}
1275#else
1276void __init at91_add_device_adc(struct at91_adc_data *data) {}
1277#endif
1278
1279/* --------------------------------------------------------------------
1280 * RTT 1073 * RTT
1281 * -------------------------------------------------------------------- */ 1074 * -------------------------------------------------------------------- */
1282 1075
1283static struct resource rtt_resources[] = { 1076static struct resource rtt_resources[] = {
1284 { 1077 {
1285 .start = AT91SAM9G45_BASE_RTT, 1078 .start = AT91_BASE_SYS + AT91_RTT,
1286 .end = AT91SAM9G45_BASE_RTT + SZ_16 - 1, 1079 .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
1287 .flags = IORESOURCE_MEM,
1288 }, {
1289 .flags = IORESOURCE_MEM, 1080 .flags = IORESOURCE_MEM,
1290 }, {
1291 .flags = IORESOURCE_IRQ,
1292 } 1081 }
1293}; 1082};
1294 1083
@@ -1296,84 +1085,24 @@ static struct platform_device at91sam9g45_rtt_device = {
1296 .name = "at91_rtt", 1085 .name = "at91_rtt",
1297 .id = 0, 1086 .id = 0,
1298 .resource = rtt_resources, 1087 .resource = rtt_resources,
1088 .num_resources = ARRAY_SIZE(rtt_resources),
1299}; 1089};
1300 1090
1301#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
1302static void __init at91_add_device_rtt_rtc(void)
1303{
1304 at91sam9g45_rtt_device.name = "rtc-at91sam9";
1305 /*
1306 * The second resource is needed:
1307 * GPBR will serve as the storage for RTC time offset
1308 */
1309 at91sam9g45_rtt_device.num_resources = 3;
1310 rtt_resources[1].start = AT91SAM9G45_BASE_GPBR +
1311 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
1312 rtt_resources[1].end = rtt_resources[1].start + 3;
1313 rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;
1314 rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;
1315}
1316#else
1317static void __init at91_add_device_rtt_rtc(void)
1318{
1319 /* Only one resource is needed: RTT not used as RTC */
1320 at91sam9g45_rtt_device.num_resources = 1;
1321}
1322#endif
1323
1324static void __init at91_add_device_rtt(void) 1091static void __init at91_add_device_rtt(void)
1325{ 1092{
1326 at91_add_device_rtt_rtc();
1327 platform_device_register(&at91sam9g45_rtt_device); 1093 platform_device_register(&at91sam9g45_rtt_device);
1328} 1094}
1329 1095
1330 1096
1331/* -------------------------------------------------------------------- 1097/* --------------------------------------------------------------------
1332 * TRNG
1333 * -------------------------------------------------------------------- */
1334
1335#if defined(CONFIG_HW_RANDOM_ATMEL) || defined(CONFIG_HW_RANDOM_ATMEL_MODULE)
1336static struct resource trng_resources[] = {
1337 {
1338 .start = AT91SAM9G45_BASE_TRNG,
1339 .end = AT91SAM9G45_BASE_TRNG + SZ_16K - 1,
1340 .flags = IORESOURCE_MEM,
1341 },
1342};
1343
1344static struct platform_device at91sam9g45_trng_device = {
1345 .name = "atmel-trng",
1346 .id = -1,
1347 .resource = trng_resources,
1348 .num_resources = ARRAY_SIZE(trng_resources),
1349};
1350
1351static void __init at91_add_device_trng(void)
1352{
1353 platform_device_register(&at91sam9g45_trng_device);
1354}
1355#else
1356static void __init at91_add_device_trng(void) {}
1357#endif
1358
1359/* --------------------------------------------------------------------
1360 * Watchdog 1098 * Watchdog
1361 * -------------------------------------------------------------------- */ 1099 * -------------------------------------------------------------------- */
1362 1100
1363#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) 1101#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
1364static struct resource wdt_resources[] = {
1365 {
1366 .start = AT91SAM9G45_BASE_WDT,
1367 .end = AT91SAM9G45_BASE_WDT + SZ_16 - 1,
1368 .flags = IORESOURCE_MEM,
1369 }
1370};
1371
1372static struct platform_device at91sam9g45_wdt_device = { 1102static struct platform_device at91sam9g45_wdt_device = {
1373 .name = "at91_wdt", 1103 .name = "at91_wdt",
1374 .id = -1, 1104 .id = -1,
1375 .resource = wdt_resources, 1105 .num_resources = 0,
1376 .num_resources = ARRAY_SIZE(wdt_resources),
1377}; 1106};
1378 1107
1379static void __init at91_add_device_watchdog(void) 1108static void __init at91_add_device_watchdog(void)
@@ -1399,8 +1128,8 @@ static struct resource pwm_resources[] = {
1399 .flags = IORESOURCE_MEM, 1128 .flags = IORESOURCE_MEM,
1400 }, 1129 },
1401 [1] = { 1130 [1] = {
1402 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_PWMC, 1131 .start = AT91SAM9G45_ID_PWMC,
1403 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_PWMC, 1132 .end = AT91SAM9G45_ID_PWMC,
1404 .flags = IORESOURCE_IRQ, 1133 .flags = IORESOURCE_IRQ,
1405 }, 1134 },
1406}; 1135};
@@ -1452,14 +1181,14 @@ static struct resource ssc0_resources[] = {
1452 .flags = IORESOURCE_MEM, 1181 .flags = IORESOURCE_MEM,
1453 }, 1182 },
1454 [1] = { 1183 [1] = {
1455 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC0, 1184 .start = AT91SAM9G45_ID_SSC0,
1456 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC0, 1185 .end = AT91SAM9G45_ID_SSC0,
1457 .flags = IORESOURCE_IRQ, 1186 .flags = IORESOURCE_IRQ,
1458 }, 1187 },
1459}; 1188};
1460 1189
1461static struct platform_device at91sam9g45_ssc0_device = { 1190static struct platform_device at91sam9g45_ssc0_device = {
1462 .name = "at91sam9g45_ssc", 1191 .name = "ssc",
1463 .id = 0, 1192 .id = 0,
1464 .dev = { 1193 .dev = {
1465 .dma_mask = &ssc0_dmamask, 1194 .dma_mask = &ssc0_dmamask,
@@ -1494,14 +1223,14 @@ static struct resource ssc1_resources[] = {
1494 .flags = IORESOURCE_MEM, 1223 .flags = IORESOURCE_MEM,
1495 }, 1224 },
1496 [1] = { 1225 [1] = {
1497 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC1, 1226 .start = AT91SAM9G45_ID_SSC1,
1498 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_SSC1, 1227 .end = AT91SAM9G45_ID_SSC1,
1499 .flags = IORESOURCE_IRQ, 1228 .flags = IORESOURCE_IRQ,
1500 }, 1229 },
1501}; 1230};
1502 1231
1503static struct platform_device at91sam9g45_ssc1_device = { 1232static struct platform_device at91sam9g45_ssc1_device = {
1504 .name = "at91sam9g45_ssc", 1233 .name = "ssc",
1505 .id = 1, 1234 .id = 1,
1506 .dev = { 1235 .dev = {
1507 .dma_mask = &ssc1_dmamask, 1236 .dma_mask = &ssc1_dmamask,
@@ -1569,13 +1298,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
1569#if defined(CONFIG_SERIAL_ATMEL) 1298#if defined(CONFIG_SERIAL_ATMEL)
1570static struct resource dbgu_resources[] = { 1299static struct resource dbgu_resources[] = {
1571 [0] = { 1300 [0] = {
1572 .start = AT91SAM9G45_BASE_DBGU, 1301 .start = AT91_VA_BASE_SYS + AT91_DBGU,
1573 .end = AT91SAM9G45_BASE_DBGU + SZ_512 - 1, 1302 .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
1574 .flags = IORESOURCE_MEM, 1303 .flags = IORESOURCE_MEM,
1575 }, 1304 },
1576 [1] = { 1305 [1] = {
1577 .start = NR_IRQS_LEGACY + AT91_ID_SYS, 1306 .start = AT91_ID_SYS,
1578 .end = NR_IRQS_LEGACY + AT91_ID_SYS, 1307 .end = AT91_ID_SYS,
1579 .flags = IORESOURCE_IRQ, 1308 .flags = IORESOURCE_IRQ,
1580 }, 1309 },
1581}; 1310};
@@ -1583,6 +1312,7 @@ static struct resource dbgu_resources[] = {
1583static struct atmel_uart_data dbgu_data = { 1312static struct atmel_uart_data dbgu_data = {
1584 .use_dma_tx = 0, 1313 .use_dma_tx = 0,
1585 .use_dma_rx = 0, 1314 .use_dma_rx = 0,
1315 .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
1586}; 1316};
1587 1317
1588static u64 dbgu_dmamask = DMA_BIT_MASK(32); 1318static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -1612,8 +1342,8 @@ static struct resource uart0_resources[] = {
1612 .flags = IORESOURCE_MEM, 1342 .flags = IORESOURCE_MEM,
1613 }, 1343 },
1614 [1] = { 1344 [1] = {
1615 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US0, 1345 .start = AT91SAM9G45_ID_US0,
1616 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US0, 1346 .end = AT91SAM9G45_ID_US0,
1617 .flags = IORESOURCE_IRQ, 1347 .flags = IORESOURCE_IRQ,
1618 }, 1348 },
1619}; 1349};
@@ -1655,8 +1385,8 @@ static struct resource uart1_resources[] = {
1655 .flags = IORESOURCE_MEM, 1385 .flags = IORESOURCE_MEM,
1656 }, 1386 },
1657 [1] = { 1387 [1] = {
1658 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US1, 1388 .start = AT91SAM9G45_ID_US1,
1659 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US1, 1389 .end = AT91SAM9G45_ID_US1,
1660 .flags = IORESOURCE_IRQ, 1390 .flags = IORESOURCE_IRQ,
1661 }, 1391 },
1662}; 1392};
@@ -1698,8 +1428,8 @@ static struct resource uart2_resources[] = {
1698 .flags = IORESOURCE_MEM, 1428 .flags = IORESOURCE_MEM,
1699 }, 1429 },
1700 [1] = { 1430 [1] = {
1701 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US2, 1431 .start = AT91SAM9G45_ID_US2,
1702 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US2, 1432 .end = AT91SAM9G45_ID_US2,
1703 .flags = IORESOURCE_IRQ, 1433 .flags = IORESOURCE_IRQ,
1704 }, 1434 },
1705}; 1435};
@@ -1741,8 +1471,8 @@ static struct resource uart3_resources[] = {
1741 .flags = IORESOURCE_MEM, 1471 .flags = IORESOURCE_MEM,
1742 }, 1472 },
1743 [1] = { 1473 [1] = {
1744 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_US3, 1474 .start = AT91SAM9G45_ID_US3,
1745 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_US3, 1475 .end = AT91SAM9G45_ID_US3,
1746 .flags = IORESOURCE_IRQ, 1476 .flags = IORESOURCE_IRQ,
1747 }, 1477 },
1748}; 1478};
@@ -1778,6 +1508,7 @@ static inline void configure_usart3_pins(unsigned pins)
1778} 1508}
1779 1509
1780static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1510static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1511struct platform_device *atmel_default_console_device; /* the serial console device */
1781 1512
1782void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1513void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1783{ 1514{
@@ -1815,6 +1546,14 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1815 at91_uarts[portnr] = pdev; 1546 at91_uarts[portnr] = pdev;
1816} 1547}
1817 1548
1549void __init at91_set_serial_console(unsigned portnr)
1550{
1551 if (portnr < ATMEL_MAX_UART) {
1552 atmel_default_console_device = at91_uarts[portnr];
1553 at91sam9g45_set_console_clock(at91_uarts[portnr]->id);
1554 }
1555}
1556
1818void __init at91_add_device_serial(void) 1557void __init at91_add_device_serial(void)
1819{ 1558{
1820 int i; 1559 int i;
@@ -1823,136 +1562,16 @@ void __init at91_add_device_serial(void)
1823 if (at91_uarts[i]) 1562 if (at91_uarts[i])
1824 platform_device_register(at91_uarts[i]); 1563 platform_device_register(at91_uarts[i]);
1825 } 1564 }
1565
1566 if (!atmel_default_console_device)
1567 printk(KERN_INFO "AT91: No default serial console defined.\n");
1826} 1568}
1827#else 1569#else
1828void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1570void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1571void __init at91_set_serial_console(unsigned portnr) {}
1829void __init at91_add_device_serial(void) {} 1572void __init at91_add_device_serial(void) {}
1830#endif 1573#endif
1831 1574
1832/* --------------------------------------------------------------------
1833 * SHA1/SHA256
1834 * -------------------------------------------------------------------- */
1835
1836#if defined(CONFIG_CRYPTO_DEV_ATMEL_SHA) || defined(CONFIG_CRYPTO_DEV_ATMEL_SHA_MODULE)
1837static struct resource sha_resources[] = {
1838 {
1839 .start = AT91SAM9G45_BASE_SHA,
1840 .end = AT91SAM9G45_BASE_SHA + SZ_16K - 1,
1841 .flags = IORESOURCE_MEM,
1842 },
1843 [1] = {
1844 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1845 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1846 .flags = IORESOURCE_IRQ,
1847 },
1848};
1849
1850static struct platform_device at91sam9g45_sha_device = {
1851 .name = "atmel_sha",
1852 .id = -1,
1853 .resource = sha_resources,
1854 .num_resources = ARRAY_SIZE(sha_resources),
1855};
1856
1857static void __init at91_add_device_sha(void)
1858{
1859 platform_device_register(&at91sam9g45_sha_device);
1860}
1861#else
1862static void __init at91_add_device_sha(void) {}
1863#endif
1864
1865/* --------------------------------------------------------------------
1866 * DES/TDES
1867 * -------------------------------------------------------------------- */
1868
1869#if defined(CONFIG_CRYPTO_DEV_ATMEL_TDES) || defined(CONFIG_CRYPTO_DEV_ATMEL_TDES_MODULE)
1870static struct resource tdes_resources[] = {
1871 [0] = {
1872 .start = AT91SAM9G45_BASE_TDES,
1873 .end = AT91SAM9G45_BASE_TDES + SZ_16K - 1,
1874 .flags = IORESOURCE_MEM,
1875 },
1876 [1] = {
1877 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1878 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1879 .flags = IORESOURCE_IRQ,
1880 },
1881};
1882
1883static struct platform_device at91sam9g45_tdes_device = {
1884 .name = "atmel_tdes",
1885 .id = -1,
1886 .resource = tdes_resources,
1887 .num_resources = ARRAY_SIZE(tdes_resources),
1888};
1889
1890static void __init at91_add_device_tdes(void)
1891{
1892 platform_device_register(&at91sam9g45_tdes_device);
1893}
1894#else
1895static void __init at91_add_device_tdes(void) {}
1896#endif
1897
1898/* --------------------------------------------------------------------
1899 * AES
1900 * -------------------------------------------------------------------- */
1901
1902#if defined(CONFIG_CRYPTO_DEV_ATMEL_AES) || defined(CONFIG_CRYPTO_DEV_ATMEL_AES_MODULE)
1903static struct aes_platform_data aes_data;
1904static u64 aes_dmamask = DMA_BIT_MASK(32);
1905
1906static struct resource aes_resources[] = {
1907 [0] = {
1908 .start = AT91SAM9G45_BASE_AES,
1909 .end = AT91SAM9G45_BASE_AES + SZ_16K - 1,
1910 .flags = IORESOURCE_MEM,
1911 },
1912 [1] = {
1913 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1914 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1915 .flags = IORESOURCE_IRQ,
1916 },
1917};
1918
1919static struct platform_device at91sam9g45_aes_device = {
1920 .name = "atmel_aes",
1921 .id = -1,
1922 .dev = {
1923 .dma_mask = &aes_dmamask,
1924 .coherent_dma_mask = DMA_BIT_MASK(32),
1925 .platform_data = &aes_data,
1926 },
1927 .resource = aes_resources,
1928 .num_resources = ARRAY_SIZE(aes_resources),
1929};
1930
1931static void __init at91_add_device_aes(void)
1932{
1933 struct at_dma_slave *atslave;
1934 struct aes_dma_data *alt_atslave;
1935
1936 alt_atslave = kzalloc(sizeof(struct aes_dma_data), GFP_KERNEL);
1937
1938 /* DMA TX slave channel configuration */
1939 atslave = &alt_atslave->txdata;
1940 atslave->dma_dev = &at_hdmac_device.dev;
1941 atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE | ATC_SRC_H2SEL_HW |
1942 ATC_SRC_PER(AT_DMA_ID_AES_RX);
1943
1944 /* DMA RX slave channel configuration */
1945 atslave = &alt_atslave->rxdata;
1946 atslave->dma_dev = &at_hdmac_device.dev;
1947 atslave->cfg = ATC_FIFOCFG_ENOUGHSPACE | ATC_DST_H2SEL_HW |
1948 ATC_DST_PER(AT_DMA_ID_AES_TX);
1949
1950 aes_data.dma_slave = alt_atslave;
1951 platform_device_register(&at91sam9g45_aes_device);
1952}
1953#else
1954static void __init at91_add_device_aes(void) {}
1955#endif
1956 1575
1957/* -------------------------------------------------------------------- */ 1576/* -------------------------------------------------------------------- */
1958/* 1577/*
@@ -1961,18 +1580,11 @@ static void __init at91_add_device_aes(void) {}
1961 */ 1580 */
1962static int __init at91_add_standard_devices(void) 1581static int __init at91_add_standard_devices(void)
1963{ 1582{
1964 if (of_have_populated_dt())
1965 return 0;
1966
1967 at91_add_device_hdmac(); 1583 at91_add_device_hdmac();
1968 at91_add_device_rtc(); 1584 at91_add_device_rtc();
1969 at91_add_device_rtt(); 1585 at91_add_device_rtt();
1970 at91_add_device_trng();
1971 at91_add_device_watchdog(); 1586 at91_add_device_watchdog();
1972 at91_add_device_tc(); 1587 at91_add_device_tc();
1973 at91_add_device_sha();
1974 at91_add_device_tdes();
1975 at91_add_device_aes();
1976 return 0; 1588 return 0;
1977} 1589}
1978 1590
diff --git a/arch/arm/mach-at91/at91sam9g45_reset.S b/arch/arm/mach-at91/at91sam9g45_reset.S
deleted file mode 100644
index 721a1a34dd1..00000000000
--- a/arch/arm/mach-at91/at91sam9g45_reset.S
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * reset AT91SAM9G45 as per errata
3 *
4 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcosoft.com>
5 *
6 * unless the SDRAM is cleanly shutdown before we hit the
7 * reset register it can be left driving the data bus and
8 * killing the chance of a subsequent boot from NAND
9 *
10 * GPLv2 Only
11 */
12
13#include <linux/linkage.h>
14#include <mach/hardware.h>
15#include <mach/at91_ramc.h>
16#include "at91_rstc.h"
17 .arm
18
19 .globl at91sam9g45_restart
20
21at91sam9g45_restart:
22 ldr r5, =at91_ramc_base @ preload constants
23 ldr r0, [r5]
24 ldr r4, =at91_rstc_base
25 ldr r1, [r4]
26
27 mov r2, #1
28 mov r3, #AT91_DDRSDRC_LPCB_POWER_DOWN
29 ldr r4, =AT91_RSTC_KEY | AT91_RSTC_PERRST | AT91_RSTC_PROCRST
30
31 .balign 32 @ align to cache line
32
33 str r2, [r0, #AT91_DDRSDRC_RTR] @ disable DDR0 access
34 str r3, [r0, #AT91_DDRSDRC_LPR] @ power down DDR0
35 str r4, [r1, #AT91_RSTC_CR] @ reset processor
36
37 b .
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
deleted file mode 100644
index 5dfc8fd8710..00000000000
--- a/arch/arm/mach-at91/at91sam9n12.c
+++ /dev/null
@@ -1,233 +0,0 @@
1/*
2 * SoC specific setup code for the AT91SAM9N12
3 *
4 * Copyright (C) 2012 Atmel Corporation.
5 *
6 * Licensed under GPLv2 or later.
7 */
8
9#include <linux/module.h>
10#include <linux/dma-mapping.h>
11
12#include <asm/irq.h>
13#include <asm/mach/arch.h>
14#include <asm/mach/map.h>
15#include <mach/at91sam9n12.h>
16#include <mach/at91_pmc.h>
17#include <mach/cpu.h>
18
19#include "board.h"
20#include "soc.h"
21#include "generic.h"
22#include "clock.h"
23#include "sam9_smc.h"
24
25/* --------------------------------------------------------------------
26 * Clocks
27 * -------------------------------------------------------------------- */
28
29/*
30 * The peripheral clocks.
31 */
32static struct clk pioAB_clk = {
33 .name = "pioAB_clk",
34 .pmc_mask = 1 << AT91SAM9N12_ID_PIOAB,
35 .type = CLK_TYPE_PERIPHERAL,
36};
37static struct clk pioCD_clk = {
38 .name = "pioCD_clk",
39 .pmc_mask = 1 << AT91SAM9N12_ID_PIOCD,
40 .type = CLK_TYPE_PERIPHERAL,
41};
42static struct clk usart0_clk = {
43 .name = "usart0_clk",
44 .pmc_mask = 1 << AT91SAM9N12_ID_USART0,
45 .type = CLK_TYPE_PERIPHERAL,
46};
47static struct clk usart1_clk = {
48 .name = "usart1_clk",
49 .pmc_mask = 1 << AT91SAM9N12_ID_USART1,
50 .type = CLK_TYPE_PERIPHERAL,
51};
52static struct clk usart2_clk = {
53 .name = "usart2_clk",
54 .pmc_mask = 1 << AT91SAM9N12_ID_USART2,
55 .type = CLK_TYPE_PERIPHERAL,
56};
57static struct clk usart3_clk = {
58 .name = "usart3_clk",
59 .pmc_mask = 1 << AT91SAM9N12_ID_USART3,
60 .type = CLK_TYPE_PERIPHERAL,
61};
62static struct clk twi0_clk = {
63 .name = "twi0_clk",
64 .pmc_mask = 1 << AT91SAM9N12_ID_TWI0,
65 .type = CLK_TYPE_PERIPHERAL,
66};
67static struct clk twi1_clk = {
68 .name = "twi1_clk",
69 .pmc_mask = 1 << AT91SAM9N12_ID_TWI1,
70 .type = CLK_TYPE_PERIPHERAL,
71};
72static struct clk mmc_clk = {
73 .name = "mci_clk",
74 .pmc_mask = 1 << AT91SAM9N12_ID_MCI,
75 .type = CLK_TYPE_PERIPHERAL,
76};
77static struct clk spi0_clk = {
78 .name = "spi0_clk",
79 .pmc_mask = 1 << AT91SAM9N12_ID_SPI0,
80 .type = CLK_TYPE_PERIPHERAL,
81};
82static struct clk spi1_clk = {
83 .name = "spi1_clk",
84 .pmc_mask = 1 << AT91SAM9N12_ID_SPI1,
85 .type = CLK_TYPE_PERIPHERAL,
86};
87static struct clk uart0_clk = {
88 .name = "uart0_clk",
89 .pmc_mask = 1 << AT91SAM9N12_ID_UART0,
90 .type = CLK_TYPE_PERIPHERAL,
91};
92static struct clk uart1_clk = {
93 .name = "uart1_clk",
94 .pmc_mask = 1 << AT91SAM9N12_ID_UART1,
95 .type = CLK_TYPE_PERIPHERAL,
96};
97static struct clk tcb_clk = {
98 .name = "tcb_clk",
99 .pmc_mask = 1 << AT91SAM9N12_ID_TCB,
100 .type = CLK_TYPE_PERIPHERAL,
101};
102static struct clk pwm_clk = {
103 .name = "pwm_clk",
104 .pmc_mask = 1 << AT91SAM9N12_ID_PWM,
105 .type = CLK_TYPE_PERIPHERAL,
106};
107static struct clk adc_clk = {
108 .name = "adc_clk",
109 .pmc_mask = 1 << AT91SAM9N12_ID_ADC,
110 .type = CLK_TYPE_PERIPHERAL,
111};
112static struct clk dma_clk = {
113 .name = "dma_clk",
114 .pmc_mask = 1 << AT91SAM9N12_ID_DMA,
115 .type = CLK_TYPE_PERIPHERAL,
116};
117static struct clk uhp_clk = {
118 .name = "uhp",
119 .pmc_mask = 1 << AT91SAM9N12_ID_UHP,
120 .type = CLK_TYPE_PERIPHERAL,
121};
122static struct clk udp_clk = {
123 .name = "udp_clk",
124 .pmc_mask = 1 << AT91SAM9N12_ID_UDP,
125 .type = CLK_TYPE_PERIPHERAL,
126};
127static struct clk lcdc_clk = {
128 .name = "lcdc_clk",
129 .pmc_mask = 1 << AT91SAM9N12_ID_LCDC,
130 .type = CLK_TYPE_PERIPHERAL,
131};
132static struct clk ssc_clk = {
133 .name = "ssc_clk",
134 .pmc_mask = 1 << AT91SAM9N12_ID_SSC,
135 .type = CLK_TYPE_PERIPHERAL,
136};
137
138static struct clk *periph_clocks[] __initdata = {
139 &pioAB_clk,
140 &pioCD_clk,
141 &usart0_clk,
142 &usart1_clk,
143 &usart2_clk,
144 &usart3_clk,
145 &twi0_clk,
146 &twi1_clk,
147 &mmc_clk,
148 &spi0_clk,
149 &spi1_clk,
150 &lcdc_clk,
151 &uart0_clk,
152 &uart1_clk,
153 &tcb_clk,
154 &pwm_clk,
155 &adc_clk,
156 &dma_clk,
157 &uhp_clk,
158 &udp_clk,
159 &ssc_clk,
160};
161
162static struct clk_lookup periph_clocks_lookups[] = {
163 /* lookup table for DT entries */
164 CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
165 CLKDEV_CON_DEV_ID("usart", "f801c000.serial", &usart0_clk),
166 CLKDEV_CON_DEV_ID("usart", "f8020000.serial", &usart1_clk),
167 CLKDEV_CON_DEV_ID("usart", "f8024000.serial", &usart2_clk),
168 CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk),
169 CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb_clk),
170 CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb_clk),
171 CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc_clk),
172 CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma_clk),
173 CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
174 CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
175 CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioAB_clk),
176 CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioAB_clk),
177 CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioCD_clk),
178 CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioCD_clk),
179 /* additional fake clock for macb_hclk */
180 CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &uhp_clk),
181 CLKDEV_CON_DEV_ID("ohci_clk", "500000.ohci", &uhp_clk),
182};
183
184/*
185 * The two programmable clocks.
186 * You must configure pin multiplexing to bring these signals out.
187 */
188static struct clk pck0 = {
189 .name = "pck0",
190 .pmc_mask = AT91_PMC_PCK0,
191 .type = CLK_TYPE_PROGRAMMABLE,
192 .id = 0,
193};
194static struct clk pck1 = {
195 .name = "pck1",
196 .pmc_mask = AT91_PMC_PCK1,
197 .type = CLK_TYPE_PROGRAMMABLE,
198 .id = 1,
199};
200
201static void __init at91sam9n12_register_clocks(void)
202{
203 int i;
204
205 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
206 clk_register(periph_clocks[i]);
207 clk_register(&pck0);
208 clk_register(&pck1);
209
210 clkdev_add_table(periph_clocks_lookups,
211 ARRAY_SIZE(periph_clocks_lookups));
212
213}
214
215/* --------------------------------------------------------------------
216 * AT91SAM9N12 processor initialization
217 * -------------------------------------------------------------------- */
218
219static void __init at91sam9n12_map_io(void)
220{
221 at91_init_sram(0, AT91SAM9N12_SRAM_BASE, AT91SAM9N12_SRAM_SIZE);
222}
223
224void __init at91sam9n12_initialize(void)
225{
226 at91_extern_irq = (1 << AT91SAM9N12_ID_IRQ0);
227}
228
229AT91_SOC_START(sam9n12)
230 .map_io = at91sam9n12_map_io,
231 .register_clocks = at91sam9n12_register_clocks,
232 .init = at91sam9n12_initialize,
233AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index eb98704db2d..a238105d2c1 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -10,23 +10,21 @@
10 */ 10 */
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/pm.h>
13 14
14#include <asm/proc-fns.h>
15#include <asm/irq.h> 15#include <asm/irq.h>
16#include <asm/mach/arch.h> 16#include <asm/mach/arch.h>
17#include <asm/mach/map.h> 17#include <asm/mach/map.h>
18#include <asm/system_misc.h>
19#include <mach/cpu.h> 18#include <mach/cpu.h>
20#include <mach/at91_dbgu.h> 19#include <mach/at91_dbgu.h>
21#include <mach/at91sam9rl.h> 20#include <mach/at91sam9rl.h>
22#include <mach/at91_pmc.h> 21#include <mach/at91_pmc.h>
22#include <mach/at91_rstc.h>
23#include <mach/at91_shdwc.h>
23 24
24#include "at91_aic.h"
25#include "at91_rstc.h"
26#include "soc.h" 25#include "soc.h"
27#include "generic.h" 26#include "generic.h"
28#include "clock.h" 27#include "clock.h"
29#include "sam9_smc.h"
30 28
31/* -------------------------------------------------------------------- 29/* --------------------------------------------------------------------
32 * Clocks 30 * Clocks
@@ -184,16 +182,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
184 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), 182 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk),
185 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), 183 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk),
186 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), 184 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk),
187 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk), 185 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
188 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk), 186 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
189 CLKDEV_CON_DEV_ID("pclk", "fffc0000.ssc", &ssc0_clk),
190 CLKDEV_CON_DEV_ID("pclk", "fffc4000.ssc", &ssc1_clk),
191 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi0_clk),
192 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.1", &twi1_clk),
193 CLKDEV_CON_ID("pioA", &pioA_clk),
194 CLKDEV_CON_ID("pioB", &pioB_clk),
195 CLKDEV_CON_ID("pioC", &pioC_clk),
196 CLKDEV_CON_ID("pioD", &pioD_clk),
197}; 187};
198 188
199static struct clk_lookup usart_clocks_lookups[] = { 189static struct clk_lookup usart_clocks_lookups[] = {
@@ -237,26 +227,48 @@ static void __init at91sam9rl_register_clocks(void)
237 clk_register(&pck1); 227 clk_register(&pck1);
238} 228}
239 229
230static struct clk_lookup console_clock_lookup;
231
232void __init at91sam9rl_set_console_clock(int id)
233{
234 if (id >= ARRAY_SIZE(usart_clocks_lookups))
235 return;
236
237 console_clock_lookup.con_id = "usart";
238 console_clock_lookup.clk = usart_clocks_lookups[id].clk;
239 clkdev_add(&console_clock_lookup);
240}
241
240/* -------------------------------------------------------------------- 242/* --------------------------------------------------------------------
241 * GPIO 243 * GPIO
242 * -------------------------------------------------------------------- */ 244 * -------------------------------------------------------------------- */
243 245
244static struct at91_gpio_bank at91sam9rl_gpio[] __initdata = { 246static struct at91_gpio_bank at91sam9rl_gpio[] = {
245 { 247 {
246 .id = AT91SAM9RL_ID_PIOA, 248 .id = AT91SAM9RL_ID_PIOA,
247 .regbase = AT91SAM9RL_BASE_PIOA, 249 .offset = AT91_PIOA,
250 .clock = &pioA_clk,
248 }, { 251 }, {
249 .id = AT91SAM9RL_ID_PIOB, 252 .id = AT91SAM9RL_ID_PIOB,
250 .regbase = AT91SAM9RL_BASE_PIOB, 253 .offset = AT91_PIOB,
254 .clock = &pioB_clk,
251 }, { 255 }, {
252 .id = AT91SAM9RL_ID_PIOC, 256 .id = AT91SAM9RL_ID_PIOC,
253 .regbase = AT91SAM9RL_BASE_PIOC, 257 .offset = AT91_PIOC,
258 .clock = &pioC_clk,
254 }, { 259 }, {
255 .id = AT91SAM9RL_ID_PIOD, 260 .id = AT91SAM9RL_ID_PIOD,
256 .regbase = AT91SAM9RL_BASE_PIOD, 261 .offset = AT91_PIOD,
262 .clock = &pioD_clk,
257 } 263 }
258}; 264};
259 265
266static void at91sam9rl_poweroff(void)
267{
268 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
269}
270
271
260/* -------------------------------------------------------------------- 272/* --------------------------------------------------------------------
261 * AT91SAM9RL processor initialization 273 * AT91SAM9RL processor initialization
262 * -------------------------------------------------------------------- */ 274 * -------------------------------------------------------------------- */
@@ -278,20 +290,10 @@ static void __init at91sam9rl_map_io(void)
278 at91_init_sram(0, AT91SAM9RL_SRAM_BASE, sram_size); 290 at91_init_sram(0, AT91SAM9RL_SRAM_BASE, sram_size);
279} 291}
280 292
281static void __init at91sam9rl_ioremap_registers(void)
282{
283 at91_ioremap_shdwc(AT91SAM9RL_BASE_SHDWC);
284 at91_ioremap_rstc(AT91SAM9RL_BASE_RSTC);
285 at91_ioremap_ramc(0, AT91SAM9RL_BASE_SDRAMC, 512);
286 at91sam926x_ioremap_pit(AT91SAM9RL_BASE_PIT);
287 at91sam9_ioremap_smc(0, AT91SAM9RL_BASE_SMC);
288 at91_ioremap_matrix(AT91SAM9RL_BASE_MATRIX);
289}
290
291static void __init at91sam9rl_initialize(void) 293static void __init at91sam9rl_initialize(void)
292{ 294{
293 arm_pm_idle = at91sam9_idle; 295 at91_arch_reset = at91sam9_alt_reset;
294 arm_pm_restart = at91sam9_alt_restart; 296 pm_power_off = at91sam9rl_poweroff;
295 at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0); 297 at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0);
296 298
297 /* Register GPIO subsystem */ 299 /* Register GPIO subsystem */
@@ -340,10 +342,9 @@ static unsigned int at91sam9rl_default_irq_priority[NR_AIC_IRQS] __initdata = {
340 0, /* Advanced Interrupt Controller */ 342 0, /* Advanced Interrupt Controller */
341}; 343};
342 344
343AT91_SOC_START(sam9rl) 345struct at91_init_soc __initdata at91sam9rl_soc = {
344 .map_io = at91sam9rl_map_io, 346 .map_io = at91sam9rl_map_io,
345 .default_irq_priority = at91sam9rl_default_irq_priority, 347 .default_irq_priority = at91sam9rl_default_irq_priority,
346 .ioremap_registers = at91sam9rl_ioremap_registers,
347 .register_clocks = at91sam9rl_register_clocks, 348 .register_clocks = at91sam9rl_register_clocks,
348 .init = at91sam9rl_initialize, 349 .init = at91sam9rl_initialize,
349AT91_SOC_END 350};
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index ddf223ff35c..c884d590b00 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -10,20 +10,19 @@
10#include <asm/mach/map.h> 10#include <asm/mach/map.h>
11 11
12#include <linux/dma-mapping.h> 12#include <linux/dma-mapping.h>
13#include <linux/gpio.h>
14#include <linux/platform_device.h> 13#include <linux/platform_device.h>
15#include <linux/i2c-gpio.h> 14#include <linux/i2c-gpio.h>
16 15
17#include <linux/fb.h> 16#include <linux/fb.h>
18#include <video/atmel_lcdc.h> 17#include <video/atmel_lcdc.h>
19 18
19#include <mach/board.h>
20#include <mach/gpio.h>
20#include <mach/at91sam9rl.h> 21#include <mach/at91sam9rl.h>
21#include <mach/at91sam9rl_matrix.h> 22#include <mach/at91sam9rl_matrix.h>
22#include <mach/at91_matrix.h>
23#include <mach/at91sam9_smc.h> 23#include <mach/at91sam9_smc.h>
24#include <linux/platform_data/dma-atmel.h> 24#include <mach/at_hdmac.h>
25 25
26#include "board.h"
27#include "generic.h" 26#include "generic.h"
28 27
29 28
@@ -34,25 +33,30 @@
34#if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE) 33#if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
35static u64 hdmac_dmamask = DMA_BIT_MASK(32); 34static u64 hdmac_dmamask = DMA_BIT_MASK(32);
36 35
36static struct at_dma_platform_data atdma_pdata = {
37 .nr_channels = 2,
38};
39
37static struct resource hdmac_resources[] = { 40static struct resource hdmac_resources[] = {
38 [0] = { 41 [0] = {
39 .start = AT91SAM9RL_BASE_DMA, 42 .start = AT91_BASE_SYS + AT91_DMA,
40 .end = AT91SAM9RL_BASE_DMA + SZ_512 - 1, 43 .end = AT91_BASE_SYS + AT91_DMA + SZ_512 - 1,
41 .flags = IORESOURCE_MEM, 44 .flags = IORESOURCE_MEM,
42 }, 45 },
43 [2] = { 46 [2] = {
44 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_DMA, 47 .start = AT91SAM9RL_ID_DMA,
45 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_DMA, 48 .end = AT91SAM9RL_ID_DMA,
46 .flags = IORESOURCE_IRQ, 49 .flags = IORESOURCE_IRQ,
47 }, 50 },
48}; 51};
49 52
50static struct platform_device at_hdmac_device = { 53static struct platform_device at_hdmac_device = {
51 .name = "at91sam9rl_dma", 54 .name = "at_hdmac",
52 .id = -1, 55 .id = -1,
53 .dev = { 56 .dev = {
54 .dma_mask = &hdmac_dmamask, 57 .dma_mask = &hdmac_dmamask,
55 .coherent_dma_mask = DMA_BIT_MASK(32), 58 .coherent_dma_mask = DMA_BIT_MASK(32),
59 .platform_data = &atdma_pdata,
56 }, 60 },
57 .resource = hdmac_resources, 61 .resource = hdmac_resources,
58 .num_resources = ARRAY_SIZE(hdmac_resources), 62 .num_resources = ARRAY_SIZE(hdmac_resources),
@@ -60,6 +64,7 @@ static struct platform_device at_hdmac_device = {
60 64
61void __init at91_add_device_hdmac(void) 65void __init at91_add_device_hdmac(void)
62{ 66{
67 dma_cap_set(DMA_MEMCPY, atdma_pdata.cap_mask);
63 platform_device_register(&at_hdmac_device); 68 platform_device_register(&at_hdmac_device);
64} 69}
65#else 70#else
@@ -84,8 +89,8 @@ static struct resource usba_udc_resources[] = {
84 .flags = IORESOURCE_MEM, 89 .flags = IORESOURCE_MEM,
85 }, 90 },
86 [2] = { 91 [2] = {
87 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_UDPHS, 92 .start = AT91SAM9RL_ID_UDPHS,
88 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_UDPHS, 93 .end = AT91SAM9RL_ID_UDPHS,
89 .flags = IORESOURCE_IRQ, 94 .flags = IORESOURCE_IRQ,
90 }, 95 },
91}; 96};
@@ -142,7 +147,7 @@ void __init at91_add_device_usba(struct usba_platform_data *data)
142 usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep); 147 usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
143 memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep)); 148 memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));
144 149
145 if (data && gpio_is_valid(data->vbus_pin)) { 150 if (data && data->vbus_pin > 0) {
146 at91_set_gpio_input(data->vbus_pin, 0); 151 at91_set_gpio_input(data->vbus_pin, 0);
147 at91_set_deglitch(data->vbus_pin, 1); 152 at91_set_deglitch(data->vbus_pin, 1);
148 usba_udc_data.pdata.vbus_pin = data->vbus_pin; 153 usba_udc_data.pdata.vbus_pin = data->vbus_pin;
@@ -161,9 +166,9 @@ void __init at91_add_device_usba(struct usba_platform_data *data) {}
161 * MMC / SD 166 * MMC / SD
162 * -------------------------------------------------------------------- */ 167 * -------------------------------------------------------------------- */
163 168
164#if IS_ENABLED(CONFIG_MMC_ATMELMCI) 169#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
165static u64 mmc_dmamask = DMA_BIT_MASK(32); 170static u64 mmc_dmamask = DMA_BIT_MASK(32);
166static struct mci_platform_data mmc_data; 171static struct at91_mmc_data mmc_data;
167 172
168static struct resource mmc_resources[] = { 173static struct resource mmc_resources[] = {
169 [0] = { 174 [0] = {
@@ -172,14 +177,14 @@ static struct resource mmc_resources[] = {
172 .flags = IORESOURCE_MEM, 177 .flags = IORESOURCE_MEM,
173 }, 178 },
174 [1] = { 179 [1] = {
175 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_MCI, 180 .start = AT91SAM9RL_ID_MCI,
176 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_MCI, 181 .end = AT91SAM9RL_ID_MCI,
177 .flags = IORESOURCE_IRQ, 182 .flags = IORESOURCE_IRQ,
178 }, 183 },
179}; 184};
180 185
181static struct platform_device at91sam9rl_mmc_device = { 186static struct platform_device at91sam9rl_mmc_device = {
182 .name = "atmel_mci", 187 .name = "at91_mci",
183 .id = -1, 188 .id = -1,
184 .dev = { 189 .dev = {
185 .dma_mask = &mmc_dmamask, 190 .dma_mask = &mmc_dmamask,
@@ -190,40 +195,40 @@ static struct platform_device at91sam9rl_mmc_device = {
190 .num_resources = ARRAY_SIZE(mmc_resources), 195 .num_resources = ARRAY_SIZE(mmc_resources),
191}; 196};
192 197
193void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) 198void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
194{ 199{
195 if (!data) 200 if (!data)
196 return; 201 return;
197 202
198 if (data->slot[0].bus_width) { 203 /* input/irq */
199 /* input/irq */ 204 if (data->det_pin) {
200 if (gpio_is_valid(data->slot[0].detect_pin)) { 205 at91_set_gpio_input(data->det_pin, 1);
201 at91_set_gpio_input(data->slot[0].detect_pin, 1); 206 at91_set_deglitch(data->det_pin, 1);
202 at91_set_deglitch(data->slot[0].detect_pin, 1); 207 }
203 } 208 if (data->wp_pin)
204 if (gpio_is_valid(data->slot[0].wp_pin)) 209 at91_set_gpio_input(data->wp_pin, 1);
205 at91_set_gpio_input(data->slot[0].wp_pin, 1); 210 if (data->vcc_pin)
206 211 at91_set_gpio_output(data->vcc_pin, 0);
207 /* CLK */ 212
208 at91_set_A_periph(AT91_PIN_PA2, 0); 213 /* CLK */
209 214 at91_set_A_periph(AT91_PIN_PA2, 0);
210 /* CMD */ 215
211 at91_set_A_periph(AT91_PIN_PA1, 1); 216 /* CMD */
212 217 at91_set_A_periph(AT91_PIN_PA1, 1);
213 /* DAT0, maybe DAT1..DAT3 */ 218
214 at91_set_A_periph(AT91_PIN_PA0, 1); 219 /* DAT0, maybe DAT1..DAT3 */
215 if (data->slot[0].bus_width == 4) { 220 at91_set_A_periph(AT91_PIN_PA0, 1);
216 at91_set_A_periph(AT91_PIN_PA3, 1); 221 if (data->wire4) {
217 at91_set_A_periph(AT91_PIN_PA4, 1); 222 at91_set_A_periph(AT91_PIN_PA3, 1);
218 at91_set_A_periph(AT91_PIN_PA5, 1); 223 at91_set_A_periph(AT91_PIN_PA4, 1);
219 } 224 at91_set_A_periph(AT91_PIN_PA5, 1);
220
221 mmc_data = *data;
222 platform_device_register(&at91sam9rl_mmc_device);
223 } 225 }
226
227 mmc_data = *data;
228 platform_device_register(&at91sam9rl_mmc_device);
224} 229}
225#else 230#else
226void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {} 231void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
227#endif 232#endif
228 233
229 234
@@ -243,8 +248,8 @@ static struct resource nand_resources[] = {
243 .flags = IORESOURCE_MEM, 248 .flags = IORESOURCE_MEM,
244 }, 249 },
245 [1] = { 250 [1] = {
246 .start = AT91SAM9RL_BASE_ECC, 251 .start = AT91_BASE_SYS + AT91_ECC,
247 .end = AT91SAM9RL_BASE_ECC + SZ_512 - 1, 252 .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
248 .flags = IORESOURCE_MEM, 253 .flags = IORESOURCE_MEM,
249 } 254 }
250}; 255};
@@ -266,19 +271,19 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
266 if (!data) 271 if (!data)
267 return; 272 return;
268 273
269 csa = at91_matrix_read(AT91_MATRIX_EBICSA); 274 csa = at91_sys_read(AT91_MATRIX_EBICSA);
270 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); 275 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
271 276
272 /* enable pin */ 277 /* enable pin */
273 if (gpio_is_valid(data->enable_pin)) 278 if (data->enable_pin)
274 at91_set_gpio_output(data->enable_pin, 1); 279 at91_set_gpio_output(data->enable_pin, 1);
275 280
276 /* ready/busy pin */ 281 /* ready/busy pin */
277 if (gpio_is_valid(data->rdy_pin)) 282 if (data->rdy_pin)
278 at91_set_gpio_input(data->rdy_pin, 1); 283 at91_set_gpio_input(data->rdy_pin, 1);
279 284
280 /* card detect pin */ 285 /* card detect pin */
281 if (gpio_is_valid(data->det_pin)) 286 if (data->det_pin)
282 at91_set_gpio_input(data->det_pin, 1); 287 at91_set_gpio_input(data->det_pin, 1);
283 288
284 at91_set_A_periph(AT91_PIN_PB4, 0); /* NANDOE */ 289 at91_set_A_periph(AT91_PIN_PB4, 0); /* NANDOE */
@@ -314,7 +319,7 @@ static struct i2c_gpio_platform_data pdata = {
314 319
315static struct platform_device at91sam9rl_twi_device = { 320static struct platform_device at91sam9rl_twi_device = {
316 .name = "i2c-gpio", 321 .name = "i2c-gpio",
317 .id = 0, 322 .id = -1,
318 .dev.platform_data = &pdata, 323 .dev.platform_data = &pdata,
319}; 324};
320 325
@@ -339,15 +344,15 @@ static struct resource twi_resources[] = {
339 .flags = IORESOURCE_MEM, 344 .flags = IORESOURCE_MEM,
340 }, 345 },
341 [1] = { 346 [1] = {
342 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TWI0, 347 .start = AT91SAM9RL_ID_TWI0,
343 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TWI0, 348 .end = AT91SAM9RL_ID_TWI0,
344 .flags = IORESOURCE_IRQ, 349 .flags = IORESOURCE_IRQ,
345 }, 350 },
346}; 351};
347 352
348static struct platform_device at91sam9rl_twi_device = { 353static struct platform_device at91sam9rl_twi_device = {
349 .name = "i2c-at91sam9g20", 354 .name = "at91_i2c",
350 .id = 0, 355 .id = -1,
351 .resource = twi_resources, 356 .resource = twi_resources,
352 .num_resources = ARRAY_SIZE(twi_resources), 357 .num_resources = ARRAY_SIZE(twi_resources),
353}; 358};
@@ -383,8 +388,8 @@ static struct resource spi_resources[] = {
383 .flags = IORESOURCE_MEM, 388 .flags = IORESOURCE_MEM,
384 }, 389 },
385 [1] = { 390 [1] = {
386 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_SPI, 391 .start = AT91SAM9RL_ID_SPI,
387 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_SPI, 392 .end = AT91SAM9RL_ID_SPI,
388 .flags = IORESOURCE_IRQ, 393 .flags = IORESOURCE_IRQ,
389 }, 394 },
390}; 395};
@@ -419,9 +424,6 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
419 else 424 else
420 cs_pin = spi_standard_cs[devices[i].chip_select]; 425 cs_pin = spi_standard_cs[devices[i].chip_select];
421 426
422 if (!gpio_is_valid(cs_pin))
423 continue;
424
425 /* enable chip-select pin */ 427 /* enable chip-select pin */
426 at91_set_gpio_output(cs_pin, 1); 428 at91_set_gpio_output(cs_pin, 1);
427 429
@@ -452,8 +454,8 @@ static struct resource ac97_resources[] = {
452 .flags = IORESOURCE_MEM, 454 .flags = IORESOURCE_MEM,
453 }, 455 },
454 [1] = { 456 [1] = {
455 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_AC97C, 457 .start = AT91SAM9RL_ID_AC97C,
456 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_AC97C, 458 .end = AT91SAM9RL_ID_AC97C,
457 .flags = IORESOURCE_IRQ, 459 .flags = IORESOURCE_IRQ,
458 }, 460 },
459}; 461};
@@ -481,7 +483,7 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data)
481 at91_set_A_periph(AT91_PIN_PD4, 0); /* AC97RX */ 483 at91_set_A_periph(AT91_PIN_PD4, 0); /* AC97RX */
482 484
483 /* reset */ 485 /* reset */
484 if (gpio_is_valid(data->reset_pin)) 486 if (data->reset_pin)
485 at91_set_gpio_output(data->reset_pin, 0); 487 at91_set_gpio_output(data->reset_pin, 0);
486 488
487 ac97_data = *data; 489 ac97_data = *data;
@@ -507,8 +509,8 @@ static struct resource lcdc_resources[] = {
507 .flags = IORESOURCE_MEM, 509 .flags = IORESOURCE_MEM,
508 }, 510 },
509 [1] = { 511 [1] = {
510 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_LCDC, 512 .start = AT91SAM9RL_ID_LCDC,
511 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_LCDC, 513 .end = AT91SAM9RL_ID_LCDC,
512 .flags = IORESOURCE_IRQ, 514 .flags = IORESOURCE_IRQ,
513 }, 515 },
514}; 516};
@@ -574,18 +576,18 @@ static struct resource tcb_resources[] = {
574 .flags = IORESOURCE_MEM, 576 .flags = IORESOURCE_MEM,
575 }, 577 },
576 [1] = { 578 [1] = {
577 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC0, 579 .start = AT91SAM9RL_ID_TC0,
578 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC0, 580 .end = AT91SAM9RL_ID_TC0,
579 .flags = IORESOURCE_IRQ, 581 .flags = IORESOURCE_IRQ,
580 }, 582 },
581 [2] = { 583 [2] = {
582 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC1, 584 .start = AT91SAM9RL_ID_TC1,
583 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC1, 585 .end = AT91SAM9RL_ID_TC1,
584 .flags = IORESOURCE_IRQ, 586 .flags = IORESOURCE_IRQ,
585 }, 587 },
586 [3] = { 588 [3] = {
587 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC2, 589 .start = AT91SAM9RL_ID_TC2,
588 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TC2, 590 .end = AT91SAM9RL_ID_TC2,
589 .flags = IORESOURCE_IRQ, 591 .flags = IORESOURCE_IRQ,
590 }, 592 },
591}; 593};
@@ -621,8 +623,8 @@ static struct resource tsadcc_resources[] = {
621 .flags = IORESOURCE_MEM, 623 .flags = IORESOURCE_MEM,
622 }, 624 },
623 [1] = { 625 [1] = {
624 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_TSC, 626 .start = AT91SAM9RL_ID_TSC,
625 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_TSC, 627 .end = AT91SAM9RL_ID_TSC,
626 .flags = IORESOURCE_IRQ, 628 .flags = IORESOURCE_IRQ,
627 } 629 }
628}; 630};
@@ -683,13 +685,9 @@ static void __init at91_add_device_rtc(void) {}
683 685
684static struct resource rtt_resources[] = { 686static struct resource rtt_resources[] = {
685 { 687 {
686 .start = AT91SAM9RL_BASE_RTT, 688 .start = AT91_BASE_SYS + AT91_RTT,
687 .end = AT91SAM9RL_BASE_RTT + SZ_16 - 1, 689 .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
688 .flags = IORESOURCE_MEM, 690 .flags = IORESOURCE_MEM,
689 }, {
690 .flags = IORESOURCE_MEM,
691 }, {
692 .flags = IORESOURCE_IRQ,
693 } 691 }
694}; 692};
695 693
@@ -697,34 +695,11 @@ static struct platform_device at91sam9rl_rtt_device = {
697 .name = "at91_rtt", 695 .name = "at91_rtt",
698 .id = 0, 696 .id = 0,
699 .resource = rtt_resources, 697 .resource = rtt_resources,
698 .num_resources = ARRAY_SIZE(rtt_resources),
700}; 699};
701 700
702#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
703static void __init at91_add_device_rtt_rtc(void)
704{
705 at91sam9rl_rtt_device.name = "rtc-at91sam9";
706 /*
707 * The second resource is needed:
708 * GPBR will serve as the storage for RTC time offset
709 */
710 at91sam9rl_rtt_device.num_resources = 3;
711 rtt_resources[1].start = AT91SAM9RL_BASE_GPBR +
712 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
713 rtt_resources[1].end = rtt_resources[1].start + 3;
714 rtt_resources[2].start = NR_IRQS_LEGACY + AT91_ID_SYS;
715 rtt_resources[2].end = NR_IRQS_LEGACY + AT91_ID_SYS;
716}
717#else
718static void __init at91_add_device_rtt_rtc(void)
719{
720 /* Only one resource is needed: RTT not used as RTC */
721 at91sam9rl_rtt_device.num_resources = 1;
722}
723#endif
724
725static void __init at91_add_device_rtt(void) 701static void __init at91_add_device_rtt(void)
726{ 702{
727 at91_add_device_rtt_rtc();
728 platform_device_register(&at91sam9rl_rtt_device); 703 platform_device_register(&at91sam9rl_rtt_device);
729} 704}
730 705
@@ -734,19 +709,10 @@ static void __init at91_add_device_rtt(void)
734 * -------------------------------------------------------------------- */ 709 * -------------------------------------------------------------------- */
735 710
736#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE) 711#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
737static struct resource wdt_resources[] = {
738 {
739 .start = AT91SAM9RL_BASE_WDT,
740 .end = AT91SAM9RL_BASE_WDT + SZ_16 - 1,
741 .flags = IORESOURCE_MEM,
742 }
743};
744
745static struct platform_device at91sam9rl_wdt_device = { 712static struct platform_device at91sam9rl_wdt_device = {
746 .name = "at91_wdt", 713 .name = "at91_wdt",
747 .id = -1, 714 .id = -1,
748 .resource = wdt_resources, 715 .num_resources = 0,
749 .num_resources = ARRAY_SIZE(wdt_resources),
750}; 716};
751 717
752static void __init at91_add_device_watchdog(void) 718static void __init at91_add_device_watchdog(void)
@@ -772,8 +738,8 @@ static struct resource pwm_resources[] = {
772 .flags = IORESOURCE_MEM, 738 .flags = IORESOURCE_MEM,
773 }, 739 },
774 [1] = { 740 [1] = {
775 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_PWMC, 741 .start = AT91SAM9RL_ID_PWMC,
776 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_PWMC, 742 .end = AT91SAM9RL_ID_PWMC,
777 .flags = IORESOURCE_IRQ, 743 .flags = IORESOURCE_IRQ,
778 }, 744 },
779}; 745};
@@ -825,14 +791,14 @@ static struct resource ssc0_resources[] = {
825 .flags = IORESOURCE_MEM, 791 .flags = IORESOURCE_MEM,
826 }, 792 },
827 [1] = { 793 [1] = {
828 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC0, 794 .start = AT91SAM9RL_ID_SSC0,
829 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC0, 795 .end = AT91SAM9RL_ID_SSC0,
830 .flags = IORESOURCE_IRQ, 796 .flags = IORESOURCE_IRQ,
831 }, 797 },
832}; 798};
833 799
834static struct platform_device at91sam9rl_ssc0_device = { 800static struct platform_device at91sam9rl_ssc0_device = {
835 .name = "at91rm9200_ssc", 801 .name = "ssc",
836 .id = 0, 802 .id = 0,
837 .dev = { 803 .dev = {
838 .dma_mask = &ssc0_dmamask, 804 .dma_mask = &ssc0_dmamask,
@@ -867,14 +833,14 @@ static struct resource ssc1_resources[] = {
867 .flags = IORESOURCE_MEM, 833 .flags = IORESOURCE_MEM,
868 }, 834 },
869 [1] = { 835 [1] = {
870 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC1, 836 .start = AT91SAM9RL_ID_SSC1,
871 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_SSC1, 837 .end = AT91SAM9RL_ID_SSC1,
872 .flags = IORESOURCE_IRQ, 838 .flags = IORESOURCE_IRQ,
873 }, 839 },
874}; 840};
875 841
876static struct platform_device at91sam9rl_ssc1_device = { 842static struct platform_device at91sam9rl_ssc1_device = {
877 .name = "at91rm9200_ssc", 843 .name = "ssc",
878 .id = 1, 844 .id = 1,
879 .dev = { 845 .dev = {
880 .dma_mask = &ssc1_dmamask, 846 .dma_mask = &ssc1_dmamask,
@@ -942,13 +908,13 @@ void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
942#if defined(CONFIG_SERIAL_ATMEL) 908#if defined(CONFIG_SERIAL_ATMEL)
943static struct resource dbgu_resources[] = { 909static struct resource dbgu_resources[] = {
944 [0] = { 910 [0] = {
945 .start = AT91SAM9RL_BASE_DBGU, 911 .start = AT91_VA_BASE_SYS + AT91_DBGU,
946 .end = AT91SAM9RL_BASE_DBGU + SZ_512 - 1, 912 .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
947 .flags = IORESOURCE_MEM, 913 .flags = IORESOURCE_MEM,
948 }, 914 },
949 [1] = { 915 [1] = {
950 .start = NR_IRQS_LEGACY + AT91_ID_SYS, 916 .start = AT91_ID_SYS,
951 .end = NR_IRQS_LEGACY + AT91_ID_SYS, 917 .end = AT91_ID_SYS,
952 .flags = IORESOURCE_IRQ, 918 .flags = IORESOURCE_IRQ,
953 }, 919 },
954}; 920};
@@ -956,6 +922,7 @@ static struct resource dbgu_resources[] = {
956static struct atmel_uart_data dbgu_data = { 922static struct atmel_uart_data dbgu_data = {
957 .use_dma_tx = 0, 923 .use_dma_tx = 0,
958 .use_dma_rx = 0, /* DBGU not capable of receive DMA */ 924 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
925 .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
959}; 926};
960 927
961static u64 dbgu_dmamask = DMA_BIT_MASK(32); 928static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -985,8 +952,8 @@ static struct resource uart0_resources[] = {
985 .flags = IORESOURCE_MEM, 952 .flags = IORESOURCE_MEM,
986 }, 953 },
987 [1] = { 954 [1] = {
988 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_US0, 955 .start = AT91SAM9RL_ID_US0,
989 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_US0, 956 .end = AT91SAM9RL_ID_US0,
990 .flags = IORESOURCE_IRQ, 957 .flags = IORESOURCE_IRQ,
991 }, 958 },
992}; 959};
@@ -1036,8 +1003,8 @@ static struct resource uart1_resources[] = {
1036 .flags = IORESOURCE_MEM, 1003 .flags = IORESOURCE_MEM,
1037 }, 1004 },
1038 [1] = { 1005 [1] = {
1039 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_US1, 1006 .start = AT91SAM9RL_ID_US1,
1040 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_US1, 1007 .end = AT91SAM9RL_ID_US1,
1041 .flags = IORESOURCE_IRQ, 1008 .flags = IORESOURCE_IRQ,
1042 }, 1009 },
1043}; 1010};
@@ -1079,8 +1046,8 @@ static struct resource uart2_resources[] = {
1079 .flags = IORESOURCE_MEM, 1046 .flags = IORESOURCE_MEM,
1080 }, 1047 },
1081 [1] = { 1048 [1] = {
1082 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_US2, 1049 .start = AT91SAM9RL_ID_US2,
1083 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_US2, 1050 .end = AT91SAM9RL_ID_US2,
1084 .flags = IORESOURCE_IRQ, 1051 .flags = IORESOURCE_IRQ,
1085 }, 1052 },
1086}; 1053};
@@ -1122,8 +1089,8 @@ static struct resource uart3_resources[] = {
1122 .flags = IORESOURCE_MEM, 1089 .flags = IORESOURCE_MEM,
1123 }, 1090 },
1124 [1] = { 1091 [1] = {
1125 .start = NR_IRQS_LEGACY + AT91SAM9RL_ID_US3, 1092 .start = AT91SAM9RL_ID_US3,
1126 .end = NR_IRQS_LEGACY + AT91SAM9RL_ID_US3, 1093 .end = AT91SAM9RL_ID_US3,
1127 .flags = IORESOURCE_IRQ, 1094 .flags = IORESOURCE_IRQ,
1128 }, 1095 },
1129}; 1096};
@@ -1159,6 +1126,7 @@ static inline void configure_usart3_pins(unsigned pins)
1159} 1126}
1160 1127
1161static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1128static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1129struct platform_device *atmel_default_console_device; /* the serial console device */
1162 1130
1163void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1131void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1164{ 1132{
@@ -1196,6 +1164,14 @@ void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1196 at91_uarts[portnr] = pdev; 1164 at91_uarts[portnr] = pdev;
1197} 1165}
1198 1166
1167void __init at91_set_serial_console(unsigned portnr)
1168{
1169 if (portnr < ATMEL_MAX_UART) {
1170 atmel_default_console_device = at91_uarts[portnr];
1171 at91sam9rl_set_console_clock(at91_uarts[portnr]->id);
1172 }
1173}
1174
1199void __init at91_add_device_serial(void) 1175void __init at91_add_device_serial(void)
1200{ 1176{
1201 int i; 1177 int i;
@@ -1204,9 +1180,13 @@ void __init at91_add_device_serial(void)
1204 if (at91_uarts[i]) 1180 if (at91_uarts[i])
1205 platform_device_register(at91_uarts[i]); 1181 platform_device_register(at91_uarts[i]);
1206 } 1182 }
1183
1184 if (!atmel_default_console_device)
1185 printk(KERN_INFO "AT91: No default serial console defined.\n");
1207} 1186}
1208#else 1187#else
1209void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1188void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1189void __init at91_set_serial_console(unsigned portnr) {}
1210void __init at91_add_device_serial(void) {} 1190void __init at91_add_device_serial(void) {}
1211#endif 1191#endif
1212 1192
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
deleted file mode 100644
index 44a9a62dcc1..00000000000
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ /dev/null
@@ -1,326 +0,0 @@
1/*
2 * Chip-specific setup code for the AT91SAM9x5 family
3 *
4 * Copyright (C) 2010-2012 Atmel Corporation.
5 *
6 * Licensed under GPLv2 or later.
7 */
8
9#include <linux/module.h>
10#include <linux/dma-mapping.h>
11
12#include <asm/irq.h>
13#include <asm/mach/arch.h>
14#include <asm/mach/map.h>
15#include <mach/at91sam9x5.h>
16#include <mach/at91_pmc.h>
17#include <mach/cpu.h>
18
19#include "board.h"
20#include "soc.h"
21#include "generic.h"
22#include "clock.h"
23#include "sam9_smc.h"
24
25/* --------------------------------------------------------------------
26 * Clocks
27 * -------------------------------------------------------------------- */
28
29/*
30 * The peripheral clocks.
31 */
32static struct clk pioAB_clk = {
33 .name = "pioAB_clk",
34 .pmc_mask = 1 << AT91SAM9X5_ID_PIOAB,
35 .type = CLK_TYPE_PERIPHERAL,
36};
37static struct clk pioCD_clk = {
38 .name = "pioCD_clk",
39 .pmc_mask = 1 << AT91SAM9X5_ID_PIOCD,
40 .type = CLK_TYPE_PERIPHERAL,
41};
42static struct clk smd_clk = {
43 .name = "smd_clk",
44 .pmc_mask = 1 << AT91SAM9X5_ID_SMD,
45 .type = CLK_TYPE_PERIPHERAL,
46};
47static struct clk usart0_clk = {
48 .name = "usart0_clk",
49 .pmc_mask = 1 << AT91SAM9X5_ID_USART0,
50 .type = CLK_TYPE_PERIPHERAL,
51};
52static struct clk usart1_clk = {
53 .name = "usart1_clk",
54 .pmc_mask = 1 << AT91SAM9X5_ID_USART1,
55 .type = CLK_TYPE_PERIPHERAL,
56};
57static struct clk usart2_clk = {
58 .name = "usart2_clk",
59 .pmc_mask = 1 << AT91SAM9X5_ID_USART2,
60 .type = CLK_TYPE_PERIPHERAL,
61};
62/* USART3 clock - Only for sam9g25/sam9x25 */
63static struct clk usart3_clk = {
64 .name = "usart3_clk",
65 .pmc_mask = 1 << AT91SAM9X5_ID_USART3,
66 .type = CLK_TYPE_PERIPHERAL,
67};
68static struct clk twi0_clk = {
69 .name = "twi0_clk",
70 .pmc_mask = 1 << AT91SAM9X5_ID_TWI0,
71 .type = CLK_TYPE_PERIPHERAL,
72};
73static struct clk twi1_clk = {
74 .name = "twi1_clk",
75 .pmc_mask = 1 << AT91SAM9X5_ID_TWI1,
76 .type = CLK_TYPE_PERIPHERAL,
77};
78static struct clk twi2_clk = {
79 .name = "twi2_clk",
80 .pmc_mask = 1 << AT91SAM9X5_ID_TWI2,
81 .type = CLK_TYPE_PERIPHERAL,
82};
83static struct clk mmc0_clk = {
84 .name = "mci0_clk",
85 .pmc_mask = 1 << AT91SAM9X5_ID_MCI0,
86 .type = CLK_TYPE_PERIPHERAL,
87};
88static struct clk spi0_clk = {
89 .name = "spi0_clk",
90 .pmc_mask = 1 << AT91SAM9X5_ID_SPI0,
91 .type = CLK_TYPE_PERIPHERAL,
92};
93static struct clk spi1_clk = {
94 .name = "spi1_clk",
95 .pmc_mask = 1 << AT91SAM9X5_ID_SPI1,
96 .type = CLK_TYPE_PERIPHERAL,
97};
98static struct clk uart0_clk = {
99 .name = "uart0_clk",
100 .pmc_mask = 1 << AT91SAM9X5_ID_UART0,
101 .type = CLK_TYPE_PERIPHERAL,
102};
103static struct clk uart1_clk = {
104 .name = "uart1_clk",
105 .pmc_mask = 1 << AT91SAM9X5_ID_UART1,
106 .type = CLK_TYPE_PERIPHERAL,
107};
108static struct clk tcb0_clk = {
109 .name = "tcb0_clk",
110 .pmc_mask = 1 << AT91SAM9X5_ID_TCB,
111 .type = CLK_TYPE_PERIPHERAL,
112};
113static struct clk pwm_clk = {
114 .name = "pwm_clk",
115 .pmc_mask = 1 << AT91SAM9X5_ID_PWM,
116 .type = CLK_TYPE_PERIPHERAL,
117};
118static struct clk adc_clk = {
119 .name = "adc_clk",
120 .pmc_mask = 1 << AT91SAM9X5_ID_ADC,
121 .type = CLK_TYPE_PERIPHERAL,
122};
123static struct clk adc_op_clk = {
124 .name = "adc_op_clk",
125 .type = CLK_TYPE_PERIPHERAL,
126 .rate_hz = 5000000,
127};
128static struct clk dma0_clk = {
129 .name = "dma0_clk",
130 .pmc_mask = 1 << AT91SAM9X5_ID_DMA0,
131 .type = CLK_TYPE_PERIPHERAL,
132};
133static struct clk dma1_clk = {
134 .name = "dma1_clk",
135 .pmc_mask = 1 << AT91SAM9X5_ID_DMA1,
136 .type = CLK_TYPE_PERIPHERAL,
137};
138static struct clk uhphs_clk = {
139 .name = "uhphs",
140 .pmc_mask = 1 << AT91SAM9X5_ID_UHPHS,
141 .type = CLK_TYPE_PERIPHERAL,
142};
143static struct clk udphs_clk = {
144 .name = "udphs_clk",
145 .pmc_mask = 1 << AT91SAM9X5_ID_UDPHS,
146 .type = CLK_TYPE_PERIPHERAL,
147};
148/* emac0 clock - Only for sam9g25/sam9x25/sam9g35/sam9x35 */
149static struct clk macb0_clk = {
150 .name = "pclk",
151 .pmc_mask = 1 << AT91SAM9X5_ID_EMAC0,
152 .type = CLK_TYPE_PERIPHERAL,
153};
154/* lcd clock - Only for sam9g15/sam9g35/sam9x35 */
155static struct clk lcdc_clk = {
156 .name = "lcdc_clk",
157 .pmc_mask = 1 << AT91SAM9X5_ID_LCDC,
158 .type = CLK_TYPE_PERIPHERAL,
159};
160/* isi clock - Only for sam9g25 */
161static struct clk isi_clk = {
162 .name = "isi_clk",
163 .pmc_mask = 1 << AT91SAM9X5_ID_ISI,
164 .type = CLK_TYPE_PERIPHERAL,
165};
166static struct clk mmc1_clk = {
167 .name = "mci1_clk",
168 .pmc_mask = 1 << AT91SAM9X5_ID_MCI1,
169 .type = CLK_TYPE_PERIPHERAL,
170};
171/* emac1 clock - Only for sam9x25 */
172static struct clk macb1_clk = {
173 .name = "pclk",
174 .pmc_mask = 1 << AT91SAM9X5_ID_EMAC1,
175 .type = CLK_TYPE_PERIPHERAL,
176};
177static struct clk ssc_clk = {
178 .name = "ssc_clk",
179 .pmc_mask = 1 << AT91SAM9X5_ID_SSC,
180 .type = CLK_TYPE_PERIPHERAL,
181};
182/* can0 clock - Only for sam9x35 */
183static struct clk can0_clk = {
184 .name = "can0_clk",
185 .pmc_mask = 1 << AT91SAM9X5_ID_CAN0,
186 .type = CLK_TYPE_PERIPHERAL,
187};
188/* can1 clock - Only for sam9x35 */
189static struct clk can1_clk = {
190 .name = "can1_clk",
191 .pmc_mask = 1 << AT91SAM9X5_ID_CAN1,
192 .type = CLK_TYPE_PERIPHERAL,
193};
194
195static struct clk *periph_clocks[] __initdata = {
196 &pioAB_clk,
197 &pioCD_clk,
198 &smd_clk,
199 &usart0_clk,
200 &usart1_clk,
201 &usart2_clk,
202 &twi0_clk,
203 &twi1_clk,
204 &twi2_clk,
205 &mmc0_clk,
206 &spi0_clk,
207 &spi1_clk,
208 &uart0_clk,
209 &uart1_clk,
210 &tcb0_clk,
211 &pwm_clk,
212 &adc_clk,
213 &adc_op_clk,
214 &dma0_clk,
215 &dma1_clk,
216 &uhphs_clk,
217 &udphs_clk,
218 &mmc1_clk,
219 &ssc_clk,
220 // irq0
221};
222
223static struct clk_lookup periph_clocks_lookups[] = {
224 /* lookup table for DT entries */
225 CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
226 CLKDEV_CON_DEV_ID("usart", "f801c000.serial", &usart0_clk),
227 CLKDEV_CON_DEV_ID("usart", "f8020000.serial", &usart1_clk),
228 CLKDEV_CON_DEV_ID("usart", "f8024000.serial", &usart2_clk),
229 CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk),
230 CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb0_clk),
231 CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
232 CLKDEV_CON_DEV_ID("mci_clk", "f0008000.mmc", &mmc0_clk),
233 CLKDEV_CON_DEV_ID("mci_clk", "f000c000.mmc", &mmc1_clk),
234 CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
235 CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
236 CLKDEV_CON_DEV_ID("pclk", "f0010000.ssc", &ssc_clk),
237 CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
238 CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
239 CLKDEV_CON_DEV_ID(NULL, "f8018000.i2c", &twi2_clk),
240 CLKDEV_CON_DEV_ID(NULL, "fffff400.gpio", &pioAB_clk),
241 CLKDEV_CON_DEV_ID(NULL, "fffff600.gpio", &pioAB_clk),
242 CLKDEV_CON_DEV_ID(NULL, "fffff800.gpio", &pioCD_clk),
243 CLKDEV_CON_DEV_ID(NULL, "fffffa00.gpio", &pioCD_clk),
244 /* additional fake clock for macb_hclk */
245 CLKDEV_CON_DEV_ID("hclk", "f802c000.ethernet", &macb0_clk),
246 CLKDEV_CON_DEV_ID("hclk", "f8030000.ethernet", &macb1_clk),
247 CLKDEV_CON_DEV_ID("hclk", "600000.ohci", &uhphs_clk),
248 CLKDEV_CON_DEV_ID("ohci_clk", "600000.ohci", &uhphs_clk),
249 CLKDEV_CON_DEV_ID("ehci_clk", "700000.ehci", &uhphs_clk),
250};
251
252/*
253 * The two programmable clocks.
254 * You must configure pin multiplexing to bring these signals out.
255 */
256static struct clk pck0 = {
257 .name = "pck0",
258 .pmc_mask = AT91_PMC_PCK0,
259 .type = CLK_TYPE_PROGRAMMABLE,
260 .id = 0,
261};
262static struct clk pck1 = {
263 .name = "pck1",
264 .pmc_mask = AT91_PMC_PCK1,
265 .type = CLK_TYPE_PROGRAMMABLE,
266 .id = 1,
267};
268
269static void __init at91sam9x5_register_clocks(void)
270{
271 int i;
272
273 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
274 clk_register(periph_clocks[i]);
275
276 clkdev_add_table(periph_clocks_lookups,
277 ARRAY_SIZE(periph_clocks_lookups));
278
279 if (cpu_is_at91sam9g25()
280 || cpu_is_at91sam9x25())
281 clk_register(&usart3_clk);
282
283 if (cpu_is_at91sam9g25()
284 || cpu_is_at91sam9x25()
285 || cpu_is_at91sam9g35()
286 || cpu_is_at91sam9x35())
287 clk_register(&macb0_clk);
288
289 if (cpu_is_at91sam9g15()
290 || cpu_is_at91sam9g35()
291 || cpu_is_at91sam9x35())
292 clk_register(&lcdc_clk);
293
294 if (cpu_is_at91sam9g25())
295 clk_register(&isi_clk);
296
297 if (cpu_is_at91sam9x25())
298 clk_register(&macb1_clk);
299
300 if (cpu_is_at91sam9x25()
301 || cpu_is_at91sam9x35()) {
302 clk_register(&can0_clk);
303 clk_register(&can1_clk);
304 }
305
306 clk_register(&pck0);
307 clk_register(&pck1);
308}
309
310/* --------------------------------------------------------------------
311 * AT91SAM9x5 processor initialization
312 * -------------------------------------------------------------------- */
313
314static void __init at91sam9x5_map_io(void)
315{
316 at91_init_sram(0, AT91SAM9X5_SRAM_BASE, AT91SAM9X5_SRAM_SIZE);
317}
318
319/* --------------------------------------------------------------------
320 * Interrupt initialization
321 * -------------------------------------------------------------------- */
322
323AT91_SOC_START(sam9x5)
324 .map_io = at91sam9x5_map_io,
325 .register_clocks = at91sam9x5_register_clocks,
326AT91_SOC_END
diff --git a/arch/arm/mach-at91/at91x40.c b/arch/arm/mach-at91/at91x40.c
index 19ca7939690..56ba3bd035a 100644
--- a/arch/arm/mach-at91/at91x40.c
+++ b/arch/arm/mach-at91/at91x40.c
@@ -13,15 +13,10 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/irq.h> 15#include <linux/irq.h>
16#include <linux/io.h>
17#include <asm/proc-fns.h>
18#include <asm/system_misc.h>
19#include <asm/mach/arch.h> 16#include <asm/mach/arch.h>
20#include <mach/at91x40.h> 17#include <mach/at91x40.h>
21#include <mach/at91_st.h> 18#include <mach/at91_st.h>
22#include <mach/timex.h> 19#include <mach/timex.h>
23
24#include "at91_aic.h"
25#include "generic.h" 20#include "generic.h"
26 21
27/* 22/*
@@ -42,19 +37,8 @@ unsigned long clk_get_rate(struct clk *clk)
42 return AT91X40_MASTER_CLOCK; 37 return AT91X40_MASTER_CLOCK;
43} 38}
44 39
45static void at91x40_idle(void)
46{
47 /*
48 * Disable the processor clock. The processor will be automatically
49 * re-enabled by an interrupt or by a reset.
50 */
51 __raw_writel(AT91_PS_CR_CPU, AT91_IO_P2V(AT91_PS_CR));
52 cpu_do_idle();
53}
54
55void __init at91x40_initialize(unsigned long main_clock) 40void __init at91x40_initialize(unsigned long main_clock)
56{ 41{
57 arm_pm_idle = at91x40_idle;
58 at91_extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1) 42 at91_extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1)
59 | (1 << AT91X40_ID_IRQ2); 43 | (1 << AT91X40_ID_IRQ2);
60} 44}
@@ -89,6 +73,6 @@ void __init at91x40_init_interrupts(unsigned int priority[NR_AIC_IRQS])
89 if (!priority) 73 if (!priority)
90 priority = at91x40_default_irq_priority; 74 priority = at91x40_default_irq_priority;
91 75
92 at91_aic_init(priority, at91_extern_irq); 76 at91_aic_init(priority);
93} 77}
94 78
diff --git a/arch/arm/mach-at91/at91x40_time.c b/arch/arm/mach-at91/at91x40_time.c
index 0e57e440c06..dfff2895f4b 100644
--- a/arch/arm/mach-at91/at91x40_time.c
+++ b/arch/arm/mach-at91/at91x40_time.c
@@ -26,14 +26,7 @@
26#include <linux/io.h> 26#include <linux/io.h>
27#include <mach/hardware.h> 27#include <mach/hardware.h>
28#include <asm/mach/time.h> 28#include <asm/mach/time.h>
29 29#include <mach/at91_tc.h>
30#include "at91_tc.h"
31
32#define at91_tc_read(field) \
33 __raw_readl(AT91_IO_P2V(AT91_TC) + field)
34
35#define at91_tc_write(field, value) \
36 __raw_writel(value, AT91_IO_P2V(AT91_TC) + field);
37 30
38/* 31/*
39 * 3 counter/timer units present. 32 * 3 counter/timer units present.
@@ -44,12 +37,12 @@
44 37
45static unsigned long at91x40_gettimeoffset(void) 38static unsigned long at91x40_gettimeoffset(void)
46{ 39{
47 return (at91_tc_read(AT91_TC_CLK1BASE + AT91_TC_CV) * 1000000 / (AT91X40_MASTER_CLOCK / 128)); 40 return (at91_sys_read(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CV) * 1000000 / (AT91X40_MASTER_CLOCK / 128));
48} 41}
49 42
50static irqreturn_t at91x40_timer_interrupt(int irq, void *dev_id) 43static irqreturn_t at91x40_timer_interrupt(int irq, void *dev_id)
51{ 44{
52 at91_tc_read(AT91_TC_CLK1BASE + AT91_TC_SR); 45 at91_sys_read(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_SR);
53 timer_tick(); 46 timer_tick();
54 return IRQ_HANDLED; 47 return IRQ_HANDLED;
55} 48}
@@ -64,20 +57,20 @@ void __init at91x40_timer_init(void)
64{ 57{
65 unsigned int v; 58 unsigned int v;
66 59
67 at91_tc_write(AT91_TC_BCR, 0); 60 at91_sys_write(AT91_TC + AT91_TC_BCR, 0);
68 v = at91_tc_read(AT91_TC_BMR); 61 v = at91_sys_read(AT91_TC + AT91_TC_BMR);
69 v = (v & ~AT91_TC_TC1XC1S) | AT91_TC_TC1XC1S_NONE; 62 v = (v & ~AT91_TC_TC1XC1S) | AT91_TC_TC1XC1S_NONE;
70 at91_tc_write(AT91_TC_BMR, v); 63 at91_sys_write(AT91_TC + AT91_TC_BMR, v);
71 64
72 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_CCR, AT91_TC_CLKDIS); 65 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CCR, AT91_TC_CLKDIS);
73 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_CMR, (AT91_TC_TIMER_CLOCK4 | AT91_TC_CPCTRG)); 66 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CMR, (AT91_TC_TIMER_CLOCK4 | AT91_TC_CPCTRG));
74 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_IDR, 0xffffffff); 67 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_IDR, 0xffffffff);
75 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_RC, (AT91X40_MASTER_CLOCK / 128) / HZ - 1); 68 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_RC, (AT91X40_MASTER_CLOCK / 128) / HZ - 1);
76 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_IER, (1<<4)); 69 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_IER, (1<<4));
77 70
78 setup_irq(AT91X40_ID_TC1, &at91x40_timer_irq); 71 setup_irq(AT91X40_ID_TC1, &at91x40_timer_irq);
79 72
80 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_CCR, (AT91_TC_SWTRG | AT91_TC_CLKEN)); 73 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CCR, (AT91_TC_SWTRG | AT91_TC_CLKEN));
81} 74}
82 75
83struct sys_timer at91x40_timer = { 76struct sys_timer at91x40_timer = {
diff --git a/arch/arm/mach-at91/board-1arm.c b/arch/arm/mach-at91/board-1arm.c
index b99b5752cc1..5aa58851eb3 100644
--- a/arch/arm/mach-at91/board-1arm.c
+++ b/arch/arm/mach-at91/board-1arm.c
@@ -19,7 +19,6 @@
19 */ 19 */
20 20
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/gpio.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/mm.h> 23#include <linux/mm.h>
25#include <linux/module.h> 24#include <linux/module.h>
@@ -34,10 +33,10 @@
34#include <asm/mach/map.h> 33#include <asm/mach/map.h>
35#include <asm/mach/irq.h> 34#include <asm/mach/irq.h>
36 35
36#include <mach/board.h>
37#include <mach/gpio.h>
37#include <mach/cpu.h> 38#include <mach/cpu.h>
38 39
39#include "at91_aic.h"
40#include "board.h"
41#include "generic.h" 40#include "generic.h"
42 41
43 42
@@ -48,17 +47,29 @@ static void __init onearm_init_early(void)
48 47
49 /* Initialize processor: 18.432 MHz crystal */ 48 /* Initialize processor: 18.432 MHz crystal */
50 at91_initialize(18432000); 49 at91_initialize(18432000);
50
51 /* DBGU on ttyS0. (Rx & Tx only) */
52 at91_register_uart(0, 0, 0);
53
54 /* USART0 on ttyS1 (Rx, Tx, CTS, RTS) */
55 at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
56
57 /* USART1 on ttyS2 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
58 at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS
59 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
60 | ATMEL_UART_RI);
61
62 /* set serial console to ttyS0 (ie, DBGU) */
63 at91_set_serial_console(0);
51} 64}
52 65
53static struct macb_platform_data __initdata onearm_eth_data = { 66static struct at91_eth_data __initdata onearm_eth_data = {
54 .phy_irq_pin = AT91_PIN_PC4, 67 .phy_irq_pin = AT91_PIN_PC4,
55 .is_rmii = 1, 68 .is_rmii = 1,
56}; 69};
57 70
58static struct at91_usbh_data __initdata onearm_usbh_data = { 71static struct at91_usbh_data __initdata onearm_usbh_data = {
59 .ports = 1, 72 .ports = 1,
60 .vbus_pin = {-EINVAL, -EINVAL},
61 .overcurrent_pin= {-EINVAL, -EINVAL},
62}; 73};
63 74
64static struct at91_udc_data __initdata onearm_udc_data = { 75static struct at91_udc_data __initdata onearm_udc_data = {
@@ -69,16 +80,6 @@ static struct at91_udc_data __initdata onearm_udc_data = {
69static void __init onearm_board_init(void) 80static void __init onearm_board_init(void)
70{ 81{
71 /* Serial */ 82 /* Serial */
72 /* DBGU on ttyS0. (Rx & Tx only) */
73 at91_register_uart(0, 0, 0);
74
75 /* USART0 on ttyS1 (Rx, Tx, CTS, RTS) */
76 at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
77
78 /* USART1 on ttyS2 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
79 at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS
80 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
81 | ATMEL_UART_RI);
82 at91_add_device_serial(); 83 at91_add_device_serial();
83 /* Ethernet */ 84 /* Ethernet */
84 at91_add_device_eth(&onearm_eth_data); 85 at91_add_device_eth(&onearm_eth_data);
@@ -92,7 +93,6 @@ MACHINE_START(ONEARM, "Ajeco 1ARM single board computer")
92 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */ 93 /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
93 .timer = &at91rm9200_timer, 94 .timer = &at91rm9200_timer,
94 .map_io = at91_map_io, 95 .map_io = at91_map_io,
95 .handle_irq = at91_aic_handle_irq,
96 .init_early = onearm_init_early, 96 .init_early = onearm_init_early,
97 .init_irq = at91_init_irq_default, 97 .init_irq = at91_init_irq_default,
98 .init_machine = onearm_board_init, 98 .init_machine = onearm_board_init,
diff --git a/arch/arm/mach-at91/board-afeb-9260v1.c b/arch/arm/mach-at91/board-afeb-9260v1.c
index 854b9797428..b0c796d42e4 100644
--- a/arch/arm/mach-at91/board-afeb-9260v1.c
+++ b/arch/arm/mach-at91/board-afeb-9260v1.c
@@ -25,7 +25,6 @@
25 */ 25 */
26 26
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/gpio.h>
29#include <linux/init.h> 28#include <linux/init.h>
30#include <linux/mm.h> 29#include <linux/mm.h>
31#include <linux/module.h> 30#include <linux/module.h>
@@ -43,8 +42,9 @@
43#include <asm/mach/map.h> 42#include <asm/mach/map.h>
44#include <asm/mach/irq.h> 43#include <asm/mach/irq.h>
45 44
46#include "at91_aic.h" 45#include <mach/board.h>
47#include "board.h" 46#include <mach/gpio.h>
47
48#include "generic.h" 48#include "generic.h"
49 49
50 50
@@ -52,6 +52,22 @@ static void __init afeb9260_init_early(void)
52{ 52{
53 /* Initialize processor: 18.432 MHz crystal */ 53 /* Initialize processor: 18.432 MHz crystal */
54 at91_initialize(18432000); 54 at91_initialize(18432000);
55
56 /* DBGU on ttyS0. (Rx & Tx only) */
57 at91_register_uart(0, 0, 0);
58
59 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
60 at91_register_uart(AT91SAM9260_ID_US0, 1,
61 ATMEL_UART_CTS | ATMEL_UART_RTS
62 | ATMEL_UART_DTR | ATMEL_UART_DSR
63 | ATMEL_UART_DCD | ATMEL_UART_RI);
64
65 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
66 at91_register_uart(AT91SAM9260_ID_US1, 2,
67 ATMEL_UART_CTS | ATMEL_UART_RTS);
68
69 /* set serial console to ttyS0 (ie, DBGU) */
70 at91_set_serial_console(0);
55} 71}
56 72
57/* 73/*
@@ -59,8 +75,6 @@ static void __init afeb9260_init_early(void)
59 */ 75 */
60static struct at91_usbh_data __initdata afeb9260_usbh_data = { 76static struct at91_usbh_data __initdata afeb9260_usbh_data = {
61 .ports = 1, 77 .ports = 1,
62 .vbus_pin = {-EINVAL, -EINVAL},
63 .overcurrent_pin= {-EINVAL, -EINVAL},
64}; 78};
65 79
66/* 80/*
@@ -68,7 +82,7 @@ static struct at91_usbh_data __initdata afeb9260_usbh_data = {
68 */ 82 */
69static struct at91_udc_data __initdata afeb9260_udc_data = { 83static struct at91_udc_data __initdata afeb9260_udc_data = {
70 .vbus_pin = AT91_PIN_PC5, 84 .vbus_pin = AT91_PIN_PC5,
71 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 85 .pullup_pin = 0, /* pull-up driven by UDC */
72}; 86};
73 87
74 88
@@ -89,7 +103,7 @@ static struct spi_board_info afeb9260_spi_devices[] = {
89/* 103/*
90 * MACB Ethernet device 104 * MACB Ethernet device
91 */ 105 */
92static struct macb_platform_data __initdata afeb9260_macb_data = { 106static struct at91_eth_data __initdata afeb9260_macb_data = {
93 .phy_irq_pin = AT91_PIN_PA9, 107 .phy_irq_pin = AT91_PIN_PA9,
94 .is_rmii = 0, 108 .is_rmii = 0,
95}; 109};
@@ -116,28 +130,30 @@ static struct mtd_partition __initdata afeb9260_nand_partition[] = {
116 }, 130 },
117}; 131};
118 132
133static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
134{
135 *num_partitions = ARRAY_SIZE(afeb9260_nand_partition);
136 return afeb9260_nand_partition;
137}
138
119static struct atmel_nand_data __initdata afeb9260_nand_data = { 139static struct atmel_nand_data __initdata afeb9260_nand_data = {
120 .ale = 21, 140 .ale = 21,
121 .cle = 22, 141 .cle = 22,
122 .rdy_pin = AT91_PIN_PC13, 142 .rdy_pin = AT91_PIN_PC13,
123 .enable_pin = AT91_PIN_PC14, 143 .enable_pin = AT91_PIN_PC14,
144 .partition_info = nand_partitions,
124 .bus_width_16 = 0, 145 .bus_width_16 = 0,
125 .ecc_mode = NAND_ECC_SOFT,
126 .parts = afeb9260_nand_partition,
127 .num_parts = ARRAY_SIZE(afeb9260_nand_partition),
128 .det_pin = -EINVAL,
129}; 146};
130 147
131 148
132/* 149/*
133 * MCI (SD/MMC) 150 * MCI (SD/MMC)
134 */ 151 */
135static struct mci_platform_data __initdata afeb9260_mci0_data = { 152static struct at91_mmc_data __initdata afeb9260_mmc_data = {
136 .slot[1] = { 153 .det_pin = AT91_PIN_PC9,
137 .bus_width = 4, 154 .wp_pin = AT91_PIN_PC4,
138 .detect_pin = AT91_PIN_PC9, 155 .slot_b = 1,
139 .wp_pin = AT91_PIN_PC4, 156 .wire4 = 1,
140 },
141}; 157};
142 158
143 159
@@ -158,8 +174,6 @@ static struct i2c_board_info __initdata afeb9260_i2c_devices[] = {
158static struct at91_cf_data afeb9260_cf_data = { 174static struct at91_cf_data afeb9260_cf_data = {
159 .chipselect = 4, 175 .chipselect = 4,
160 .irq_pin = AT91_PIN_PA6, 176 .irq_pin = AT91_PIN_PA6,
161 .det_pin = -EINVAL,
162 .vcc_pin = -EINVAL,
163 .rst_pin = AT91_PIN_PA7, 177 .rst_pin = AT91_PIN_PA7,
164 .flags = AT91_CF_TRUE_IDE, 178 .flags = AT91_CF_TRUE_IDE,
165}; 179};
@@ -167,18 +181,6 @@ static struct at91_cf_data afeb9260_cf_data = {
167static void __init afeb9260_board_init(void) 181static void __init afeb9260_board_init(void)
168{ 182{
169 /* Serial */ 183 /* Serial */
170 /* DBGU on ttyS0. (Rx & Tx only) */
171 at91_register_uart(0, 0, 0);
172
173 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
174 at91_register_uart(AT91SAM9260_ID_US0, 1,
175 ATMEL_UART_CTS | ATMEL_UART_RTS
176 | ATMEL_UART_DTR | ATMEL_UART_DSR
177 | ATMEL_UART_DCD | ATMEL_UART_RI);
178
179 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
180 at91_register_uart(AT91SAM9260_ID_US1, 2,
181 ATMEL_UART_CTS | ATMEL_UART_RTS);
182 at91_add_device_serial(); 184 at91_add_device_serial();
183 /* USB Host */ 185 /* USB Host */
184 at91_add_device_usbh(&afeb9260_usbh_data); 186 at91_add_device_usbh(&afeb9260_usbh_data);
@@ -198,7 +200,7 @@ static void __init afeb9260_board_init(void)
198 at91_set_B_periph(AT91_PIN_PA10, 0); /* ETX2 */ 200 at91_set_B_periph(AT91_PIN_PA10, 0); /* ETX2 */
199 at91_set_B_periph(AT91_PIN_PA11, 0); /* ETX3 */ 201 at91_set_B_periph(AT91_PIN_PA11, 0); /* ETX3 */
200 /* MMC */ 202 /* MMC */
201 at91_add_device_mci(0, &afeb9260_mci0_data); 203 at91_add_device_mmc(0, &afeb9260_mmc_data);
202 /* I2C */ 204 /* I2C */
203 at91_add_device_i2c(afeb9260_i2c_devices, 205 at91_add_device_i2c(afeb9260_i2c_devices,
204 ARRAY_SIZE(afeb9260_i2c_devices)); 206 ARRAY_SIZE(afeb9260_i2c_devices));
@@ -212,7 +214,6 @@ MACHINE_START(AFEB9260, "Custom afeb9260 board")
212 /* Maintainer: Sergey Lapin <slapin@ossfans.org> */ 214 /* Maintainer: Sergey Lapin <slapin@ossfans.org> */
213 .timer = &at91sam926x_timer, 215 .timer = &at91sam926x_timer,
214 .map_io = at91_map_io, 216 .map_io = at91_map_io,
215 .handle_irq = at91_aic_handle_irq,
216 .init_early = afeb9260_init_early, 217 .init_early = afeb9260_init_early,
217 .init_irq = at91_init_irq_default, 218 .init_irq = at91_init_irq_default,
218 .init_machine = afeb9260_board_init, 219 .init_machine = afeb9260_board_init,
diff --git a/arch/arm/mach-at91/board-cam60.c b/arch/arm/mach-at91/board-cam60.c
index 28a18ce6d91..d1abd5898e8 100644
--- a/arch/arm/mach-at91/board-cam60.c
+++ b/arch/arm/mach-at91/board-cam60.c
@@ -21,7 +21,6 @@
21 */ 21 */
22 22
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/gpio.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/mm.h> 25#include <linux/mm.h>
27#include <linux/module.h> 26#include <linux/module.h>
@@ -38,10 +37,10 @@
38#include <asm/mach/map.h> 37#include <asm/mach/map.h>
39#include <asm/mach/irq.h> 38#include <asm/mach/irq.h>
40 39
40#include <mach/board.h>
41#include <mach/gpio.h>
41#include <mach/at91sam9_smc.h> 42#include <mach/at91sam9_smc.h>
42 43
43#include "at91_aic.h"
44#include "board.h"
45#include "sam9_smc.h" 44#include "sam9_smc.h"
46#include "generic.h" 45#include "generic.h"
47 46
@@ -50,6 +49,12 @@ static void __init cam60_init_early(void)
50{ 49{
51 /* Initialize processor: 10 MHz crystal */ 50 /* Initialize processor: 10 MHz crystal */
52 at91_initialize(10000000); 51 at91_initialize(10000000);
52
53 /* DBGU on ttyS0. (Rx & Tx only) */
54 at91_register_uart(0, 0, 0);
55
56 /* set serial console to ttyS0 (ie, DBGU) */
57 at91_set_serial_console(0);
53} 58}
54 59
55/* 60/*
@@ -57,8 +62,6 @@ static void __init cam60_init_early(void)
57 */ 62 */
58static struct at91_usbh_data __initdata cam60_usbh_data = { 63static struct at91_usbh_data __initdata cam60_usbh_data = {
59 .ports = 1, 64 .ports = 1,
60 .vbus_pin = {-EINVAL, -EINVAL},
61 .overcurrent_pin= {-EINVAL, -EINVAL},
62}; 65};
63 66
64 67
@@ -112,7 +115,7 @@ static struct spi_board_info cam60_spi_devices[] __initdata = {
112/* 115/*
113 * MACB Ethernet device 116 * MACB Ethernet device
114 */ 117 */
115static struct __initdata macb_platform_data cam60_macb_data = { 118static struct __initdata at91_eth_data cam60_macb_data = {
116 .phy_irq_pin = AT91_PIN_PB5, 119 .phy_irq_pin = AT91_PIN_PB5,
117 .is_rmii = 0, 120 .is_rmii = 0,
118}; 121};
@@ -129,15 +132,19 @@ static struct mtd_partition __initdata cam60_nand_partition[] = {
129 }, 132 },
130}; 133};
131 134
135static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
136{
137 *num_partitions = ARRAY_SIZE(cam60_nand_partition);
138 return cam60_nand_partition;
139}
140
132static struct atmel_nand_data __initdata cam60_nand_data = { 141static struct atmel_nand_data __initdata cam60_nand_data = {
133 .ale = 21, 142 .ale = 21,
134 .cle = 22, 143 .cle = 22,
135 .det_pin = -EINVAL, 144 // .det_pin = ... not there
136 .rdy_pin = AT91_PIN_PA9, 145 .rdy_pin = AT91_PIN_PA9,
137 .enable_pin = AT91_PIN_PA7, 146 .enable_pin = AT91_PIN_PA7,
138 .ecc_mode = NAND_ECC_SOFT, 147 .partition_info = nand_partitions,
139 .parts = cam60_nand_partition,
140 .num_parts = ARRAY_SIZE(cam60_nand_partition),
141}; 148};
142 149
143static struct sam9_smc_config __initdata cam60_nand_smc_config = { 150static struct sam9_smc_config __initdata cam60_nand_smc_config = {
@@ -161,7 +168,7 @@ static struct sam9_smc_config __initdata cam60_nand_smc_config = {
161static void __init cam60_add_device_nand(void) 168static void __init cam60_add_device_nand(void)
162{ 169{
163 /* configure chip-select 3 (NAND) */ 170 /* configure chip-select 3 (NAND) */
164 sam9_smc_configure(0, 3, &cam60_nand_smc_config); 171 sam9_smc_configure(3, &cam60_nand_smc_config);
165 172
166 at91_add_device_nand(&cam60_nand_data); 173 at91_add_device_nand(&cam60_nand_data);
167} 174}
@@ -170,8 +177,6 @@ static void __init cam60_add_device_nand(void)
170static void __init cam60_board_init(void) 177static void __init cam60_board_init(void)
171{ 178{
172 /* Serial */ 179 /* Serial */
173 /* DBGU on ttyS0. (Rx & Tx only) */
174 at91_register_uart(0, 0, 0);
175 at91_add_device_serial(); 180 at91_add_device_serial();
176 /* SPI */ 181 /* SPI */
177 at91_add_device_spi(cam60_spi_devices, ARRAY_SIZE(cam60_spi_devices)); 182 at91_add_device_spi(cam60_spi_devices, ARRAY_SIZE(cam60_spi_devices));
@@ -189,7 +194,6 @@ MACHINE_START(CAM60, "KwikByte CAM60")
189 /* Maintainer: KwikByte */ 194 /* Maintainer: KwikByte */
190 .timer = &at91sam926x_timer, 195 .timer = &at91sam926x_timer,
191 .map_io = at91_map_io, 196 .map_io = at91_map_io,
192 .handle_irq = at91_aic_handle_irq,
193 .init_early = cam60_init_early, 197 .init_early = cam60_init_early,
194 .init_irq = at91_init_irq_default, 198 .init_irq = at91_init_irq_default,
195 .init_machine = cam60_board_init, 199 .init_machine = cam60_board_init,
diff --git a/arch/arm/mach-at91/board-carmeva.c b/arch/arm/mach-at91/board-carmeva.c
index c17bb533a94..c578c5d9072 100644
--- a/arch/arm/mach-at91/board-carmeva.c
+++ b/arch/arm/mach-at91/board-carmeva.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/gpio.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/mm.h> 24#include <linux/mm.h>
26#include <linux/module.h> 25#include <linux/module.h>
@@ -35,9 +34,9 @@
35#include <asm/mach/irq.h> 34#include <asm/mach/irq.h>
36 35
37#include <mach/hardware.h> 36#include <mach/hardware.h>
37#include <mach/board.h>
38#include <mach/gpio.h>
38 39
39#include "at91_aic.h"
40#include "board.h"
41#include "generic.h" 40#include "generic.h"
42 41
43 42
@@ -45,17 +44,26 @@ static void __init carmeva_init_early(void)
45{ 44{
46 /* Initialize processor: 20.000 MHz crystal */ 45 /* Initialize processor: 20.000 MHz crystal */
47 at91_initialize(20000000); 46 at91_initialize(20000000);
47
48 /* DBGU on ttyS0. (Rx & Tx only) */
49 at91_register_uart(0, 0, 0);
50
51 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
52 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
53 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
54 | ATMEL_UART_RI);
55
56 /* set serial console to ttyS0 (ie, DBGU) */
57 at91_set_serial_console(0);
48} 58}
49 59
50static struct macb_platform_data __initdata carmeva_eth_data = { 60static struct at91_eth_data __initdata carmeva_eth_data = {
51 .phy_irq_pin = AT91_PIN_PC4, 61 .phy_irq_pin = AT91_PIN_PC4,
52 .is_rmii = 1, 62 .is_rmii = 1,
53}; 63};
54 64
55static struct at91_usbh_data __initdata carmeva_usbh_data = { 65static struct at91_usbh_data __initdata carmeva_usbh_data = {
56 .ports = 2, 66 .ports = 2,
57 .vbus_pin = {-EINVAL, -EINVAL},
58 .overcurrent_pin= {-EINVAL, -EINVAL},
59}; 67};
60 68
61static struct at91_udc_data __initdata carmeva_udc_data = { 69static struct at91_udc_data __initdata carmeva_udc_data = {
@@ -67,16 +75,15 @@ static struct at91_udc_data __initdata carmeva_udc_data = {
67// static struct at91_cf_data __initdata carmeva_cf_data = { 75// static struct at91_cf_data __initdata carmeva_cf_data = {
68// .det_pin = AT91_PIN_PB0, 76// .det_pin = AT91_PIN_PB0,
69// .rst_pin = AT91_PIN_PC5, 77// .rst_pin = AT91_PIN_PC5,
70 // .irq_pin = -EINVAL, 78 // .irq_pin = ... not connected
71 // .vcc_pin = -EINVAL, 79 // .vcc_pin = ... always powered
72// }; 80// };
73 81
74static struct mci_platform_data __initdata carmeva_mci0_data = { 82static struct at91_mmc_data __initdata carmeva_mmc_data = {
75 .slot[0] = { 83 .slot_b = 0,
76 .bus_width = 4, 84 .wire4 = 1,
77 .detect_pin = AT91_PIN_PB10, 85 .det_pin = AT91_PIN_PB10,
78 .wp_pin = AT91_PIN_PC14, 86 .wp_pin = AT91_PIN_PC14,
79 },
80}; 87};
81 88
82static struct spi_board_info carmeva_spi_devices[] = { 89static struct spi_board_info carmeva_spi_devices[] = {
@@ -129,13 +136,6 @@ static struct gpio_led carmeva_leds[] = {
129static void __init carmeva_board_init(void) 136static void __init carmeva_board_init(void)
130{ 137{
131 /* Serial */ 138 /* Serial */
132 /* DBGU on ttyS0. (Rx & Tx only) */
133 at91_register_uart(0, 0, 0);
134
135 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
136 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
137 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
138 | ATMEL_UART_RI);
139 at91_add_device_serial(); 139 at91_add_device_serial();
140 /* Ethernet */ 140 /* Ethernet */
141 at91_add_device_eth(&carmeva_eth_data); 141 at91_add_device_eth(&carmeva_eth_data);
@@ -150,7 +150,7 @@ static void __init carmeva_board_init(void)
150 /* Compact Flash */ 150 /* Compact Flash */
151// at91_add_device_cf(&carmeva_cf_data); 151// at91_add_device_cf(&carmeva_cf_data);
152 /* MMC */ 152 /* MMC */
153 at91_add_device_mci(0, &carmeva_mci0_data); 153 at91_add_device_mmc(0, &carmeva_mmc_data);
154 /* LEDs */ 154 /* LEDs */
155 at91_gpio_leds(carmeva_leds, ARRAY_SIZE(carmeva_leds)); 155 at91_gpio_leds(carmeva_leds, ARRAY_SIZE(carmeva_leds));
156} 156}
@@ -159,7 +159,6 @@ MACHINE_START(CARMEVA, "Carmeva")
159 /* Maintainer: Conitec Datasystems */ 159 /* Maintainer: Conitec Datasystems */
160 .timer = &at91rm9200_timer, 160 .timer = &at91rm9200_timer,
161 .map_io = at91_map_io, 161 .map_io = at91_map_io,
162 .handle_irq = at91_aic_handle_irq,
163 .init_early = carmeva_init_early, 162 .init_early = carmeva_init_early,
164 .init_irq = at91_init_irq_default, 163 .init_irq = at91_init_irq_default,
165 .init_machine = carmeva_board_init, 164 .init_machine = carmeva_board_init,
diff --git a/arch/arm/mach-at91/board-cpu9krea.c b/arch/arm/mach-at91/board-cpu9krea.c
index 847432441ec..f4da8a16d5d 100644
--- a/arch/arm/mach-at91/board-cpu9krea.c
+++ b/arch/arm/mach-at91/board-cpu9krea.c
@@ -21,7 +21,6 @@
21 */ 21 */
22 22
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/gpio.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/mm.h> 25#include <linux/mm.h>
27#include <linux/module.h> 26#include <linux/module.h>
@@ -40,12 +39,11 @@
40#include <asm/mach/irq.h> 39#include <asm/mach/irq.h>
41 40
42#include <mach/hardware.h> 41#include <mach/hardware.h>
42#include <mach/board.h>
43#include <mach/gpio.h>
43#include <mach/at91sam9_smc.h> 44#include <mach/at91sam9_smc.h>
44#include <mach/at91sam9260_matrix.h> 45#include <mach/at91sam9260_matrix.h>
45#include <mach/at91_matrix.h>
46 46
47#include "at91_aic.h"
48#include "board.h"
49#include "sam9_smc.h" 47#include "sam9_smc.h"
50#include "generic.h" 48#include "generic.h"
51 49
@@ -53,6 +51,34 @@ static void __init cpu9krea_init_early(void)
53{ 51{
54 /* Initialize processor: 18.432 MHz crystal */ 52 /* Initialize processor: 18.432 MHz crystal */
55 at91_initialize(18432000); 53 at91_initialize(18432000);
54
55 /* DGBU on ttyS0. (Rx & Tx only) */
56 at91_register_uart(0, 0, 0);
57
58 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
59 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS |
60 ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |
61 ATMEL_UART_DCD | ATMEL_UART_RI);
62
63 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
64 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS |
65 ATMEL_UART_RTS);
66
67 /* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */
68 at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS |
69 ATMEL_UART_RTS);
70
71 /* USART3 on ttyS4. (Rx, Tx) */
72 at91_register_uart(AT91SAM9260_ID_US3, 4, 0);
73
74 /* USART4 on ttyS5. (Rx, Tx) */
75 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
76
77 /* USART5 on ttyS6. (Rx, Tx) */
78 at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
79
80 /* set serial console to ttyS0 (ie, DBGU) */
81 at91_set_serial_console(0);
56} 82}
57 83
58/* 84/*
@@ -60,8 +86,6 @@ static void __init cpu9krea_init_early(void)
60 */ 86 */
61static struct at91_usbh_data __initdata cpu9krea_usbh_data = { 87static struct at91_usbh_data __initdata cpu9krea_usbh_data = {
62 .ports = 2, 88 .ports = 2,
63 .vbus_pin = {-EINVAL, -EINVAL},
64 .overcurrent_pin= {-EINVAL, -EINVAL},
65}; 89};
66 90
67/* 91/*
@@ -69,14 +93,13 @@ static struct at91_usbh_data __initdata cpu9krea_usbh_data = {
69 */ 93 */
70static struct at91_udc_data __initdata cpu9krea_udc_data = { 94static struct at91_udc_data __initdata cpu9krea_udc_data = {
71 .vbus_pin = AT91_PIN_PC8, 95 .vbus_pin = AT91_PIN_PC8,
72 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 96 .pullup_pin = 0, /* pull-up driven by UDC */
73}; 97};
74 98
75/* 99/*
76 * MACB Ethernet device 100 * MACB Ethernet device
77 */ 101 */
78static struct macb_platform_data __initdata cpu9krea_macb_data = { 102static struct at91_eth_data __initdata cpu9krea_macb_data = {
79 .phy_irq_pin = -EINVAL,
80 .is_rmii = 1, 103 .is_rmii = 1,
81}; 104};
82 105
@@ -89,8 +112,6 @@ static struct atmel_nand_data __initdata cpu9krea_nand_data = {
89 .rdy_pin = AT91_PIN_PC13, 112 .rdy_pin = AT91_PIN_PC13,
90 .enable_pin = AT91_PIN_PC14, 113 .enable_pin = AT91_PIN_PC14,
91 .bus_width_16 = 0, 114 .bus_width_16 = 0,
92 .det_pin = -EINVAL,
93 .ecc_mode = NAND_ECC_SOFT,
94}; 115};
95 116
96#ifdef CONFIG_MACH_CPU9260 117#ifdef CONFIG_MACH_CPU9260
@@ -135,7 +156,7 @@ static struct sam9_smc_config __initdata cpu9krea_nand_smc_config = {
135 156
136static void __init cpu9krea_add_device_nand(void) 157static void __init cpu9krea_add_device_nand(void)
137{ 158{
138 sam9_smc_configure(0, 3, &cpu9krea_nand_smc_config); 159 sam9_smc_configure(3, &cpu9krea_nand_smc_config);
139 at91_add_device_nand(&cpu9krea_nand_data); 160 at91_add_device_nand(&cpu9krea_nand_data);
140} 161}
141 162
@@ -213,11 +234,11 @@ static __init void cpu9krea_add_device_nor(void)
213{ 234{
214 unsigned long csa; 235 unsigned long csa;
215 236
216 csa = at91_matrix_read(AT91_MATRIX_EBICSA); 237 csa = at91_sys_read(AT91_MATRIX_EBICSA);
217 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V); 238 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V);
218 239
219 /* configure chip-select 0 (NOR) */ 240 /* configure chip-select 0 (NOR) */
220 sam9_smc_configure(0, 0, &cpu9krea_nor_smc_config); 241 sam9_smc_configure(0, &cpu9krea_nor_smc_config);
221 242
222 platform_device_register(&cpu9krea_nor_flash); 243 platform_device_register(&cpu9krea_nor_flash);
223} 244}
@@ -254,7 +275,8 @@ static struct gpio_led cpu9krea_leds[] = {
254 275
255static struct i2c_board_info __initdata cpu9krea_i2c_devices[] = { 276static struct i2c_board_info __initdata cpu9krea_i2c_devices[] = {
256 { 277 {
257 I2C_BOARD_INFO("ds1339", 0x68), 278 I2C_BOARD_INFO("rtc-ds1307", 0x68),
279 .type = "ds1339",
258 }, 280 },
259}; 281};
260 282
@@ -311,12 +333,10 @@ static void __init cpu9krea_add_device_buttons(void)
311/* 333/*
312 * MCI (SD/MMC) 334 * MCI (SD/MMC)
313 */ 335 */
314static struct mci_platform_data __initdata cpu9krea_mci0_data = { 336static struct at91_mmc_data __initdata cpu9krea_mmc_data = {
315 .slot[0] = { 337 .slot_b = 0,
316 .bus_width = 4, 338 .wire4 = 1,
317 .detect_pin = AT91_PIN_PA29, 339 .det_pin = AT91_PIN_PA29,
318 .wp_pin = -EINVAL,
319 },
320}; 340};
321 341
322static void __init cpu9krea_board_init(void) 342static void __init cpu9krea_board_init(void)
@@ -324,30 +344,6 @@ static void __init cpu9krea_board_init(void)
324 /* NOR */ 344 /* NOR */
325 cpu9krea_add_device_nor(); 345 cpu9krea_add_device_nor();
326 /* Serial */ 346 /* Serial */
327 /* DGBU on ttyS0. (Rx & Tx only) */
328 at91_register_uart(0, 0, 0);
329
330 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
331 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS |
332 ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |
333 ATMEL_UART_DCD | ATMEL_UART_RI);
334
335 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
336 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS |
337 ATMEL_UART_RTS);
338
339 /* USART2 on ttyS3. (Rx, Tx, RTS, CTS) */
340 at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS |
341 ATMEL_UART_RTS);
342
343 /* USART3 on ttyS4. (Rx, Tx) */
344 at91_register_uart(AT91SAM9260_ID_US3, 4, 0);
345
346 /* USART4 on ttyS5. (Rx, Tx) */
347 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
348
349 /* USART5 on ttyS6. (Rx, Tx) */
350 at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
351 at91_add_device_serial(); 347 at91_add_device_serial();
352 /* USB Host */ 348 /* USB Host */
353 at91_add_device_usbh(&cpu9krea_usbh_data); 349 at91_add_device_usbh(&cpu9krea_usbh_data);
@@ -358,7 +354,7 @@ static void __init cpu9krea_board_init(void)
358 /* Ethernet */ 354 /* Ethernet */
359 at91_add_device_eth(&cpu9krea_macb_data); 355 at91_add_device_eth(&cpu9krea_macb_data);
360 /* MMC */ 356 /* MMC */
361 at91_add_device_mci(0, &cpu9krea_mci0_data); 357 at91_add_device_mmc(0, &cpu9krea_mmc_data);
362 /* I2C */ 358 /* I2C */
363 at91_add_device_i2c(cpu9krea_i2c_devices, 359 at91_add_device_i2c(cpu9krea_i2c_devices,
364 ARRAY_SIZE(cpu9krea_i2c_devices)); 360 ARRAY_SIZE(cpu9krea_i2c_devices));
@@ -376,7 +372,6 @@ MACHINE_START(CPUAT9G20, "Eukrea CPU9G20")
376 /* Maintainer: Eric Benard - EUKREA Electromatique */ 372 /* Maintainer: Eric Benard - EUKREA Electromatique */
377 .timer = &at91sam926x_timer, 373 .timer = &at91sam926x_timer,
378 .map_io = at91_map_io, 374 .map_io = at91_map_io,
379 .handle_irq = at91_aic_handle_irq,
380 .init_early = cpu9krea_init_early, 375 .init_early = cpu9krea_init_early,
381 .init_irq = at91_init_irq_default, 376 .init_irq = at91_init_irq_default,
382 .init_machine = cpu9krea_board_init, 377 .init_machine = cpu9krea_board_init,
diff --git a/arch/arm/mach-at91/board-cpuat91.c b/arch/arm/mach-at91/board-cpuat91.c
index 2a7af786874..2d919f5a4f5 100644
--- a/arch/arm/mach-at91/board-cpuat91.c
+++ b/arch/arm/mach-at91/board-cpuat91.c
@@ -19,7 +19,6 @@
19 */ 19 */
20 20
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/gpio.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/mm.h> 23#include <linux/mm.h>
25#include <linux/module.h> 24#include <linux/module.h>
@@ -36,12 +35,11 @@
36#include <asm/mach/map.h> 35#include <asm/mach/map.h>
37#include <asm/mach/irq.h> 36#include <asm/mach/irq.h>
38 37
38#include <mach/board.h>
39#include <mach/gpio.h>
39#include <mach/at91rm9200_mc.h> 40#include <mach/at91rm9200_mc.h>
40#include <mach/at91_ramc.h>
41#include <mach/cpu.h> 41#include <mach/cpu.h>
42 42
43#include "at91_aic.h"
44#include "board.h"
45#include "generic.h" 43#include "generic.h"
46 44
47static struct gpio_led cpuat91_leds[] = { 45static struct gpio_led cpuat91_leds[] = {
@@ -60,17 +58,36 @@ static void __init cpuat91_init_early(void)
60 58
61 /* Initialize processor: 18.432 MHz crystal */ 59 /* Initialize processor: 18.432 MHz crystal */
62 at91_initialize(18432000); 60 at91_initialize(18432000);
61
62 /* DBGU on ttyS0. (Rx & Tx only) */
63 at91_register_uart(0, 0, 0);
64
65 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
66 at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS |
67 ATMEL_UART_RTS);
68
69 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
70 at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS |
71 ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |
72 ATMEL_UART_DCD | ATMEL_UART_RI);
73
74 /* USART2 on ttyS3 (Rx, Tx) */
75 at91_register_uart(AT91RM9200_ID_US2, 3, 0);
76
77 /* USART3 on ttyS4 (Rx, Tx, CTS, RTS) */
78 at91_register_uart(AT91RM9200_ID_US3, 4, ATMEL_UART_CTS |
79 ATMEL_UART_RTS);
80
81 /* set serial console to ttyS0 (ie, DBGU) */
82 at91_set_serial_console(0);
63} 83}
64 84
65static struct macb_platform_data __initdata cpuat91_eth_data = { 85static struct at91_eth_data __initdata cpuat91_eth_data = {
66 .phy_irq_pin = -EINVAL,
67 .is_rmii = 1, 86 .is_rmii = 1,
68}; 87};
69 88
70static struct at91_usbh_data __initdata cpuat91_usbh_data = { 89static struct at91_usbh_data __initdata cpuat91_usbh_data = {
71 .ports = 1, 90 .ports = 1,
72 .vbus_pin = {-EINVAL, -EINVAL},
73 .overcurrent_pin= {-EINVAL, -EINVAL},
74}; 91};
75 92
76static struct at91_udc_data __initdata cpuat91_udc_data = { 93static struct at91_udc_data __initdata cpuat91_udc_data = {
@@ -78,12 +95,9 @@ static struct at91_udc_data __initdata cpuat91_udc_data = {
78 .pullup_pin = AT91_PIN_PC14, 95 .pullup_pin = AT91_PIN_PC14,
79}; 96};
80 97
81static struct mci_platform_data __initdata cpuat91_mci0_data = { 98static struct at91_mmc_data __initdata cpuat91_mmc_data = {
82 .slot[0] = { 99 .det_pin = AT91_PIN_PC2,
83 .bus_width = 4, 100 .wire4 = 1,
84 .detect_pin = AT91_PIN_PC2,
85 .wp_pin = -EINVAL,
86 },
87}; 101};
88 102
89static struct physmap_flash_data cpuat91_flash_data = { 103static struct physmap_flash_data cpuat91_flash_data = {
@@ -141,24 +155,6 @@ static struct platform_device *platform_devices[] __initdata = {
141static void __init cpuat91_board_init(void) 155static void __init cpuat91_board_init(void)
142{ 156{
143 /* Serial */ 157 /* Serial */
144 /* DBGU on ttyS0. (Rx & Tx only) */
145 at91_register_uart(0, 0, 0);
146
147 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
148 at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS |
149 ATMEL_UART_RTS);
150
151 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
152 at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS |
153 ATMEL_UART_RTS | ATMEL_UART_DTR | ATMEL_UART_DSR |
154 ATMEL_UART_DCD | ATMEL_UART_RI);
155
156 /* USART2 on ttyS3 (Rx, Tx) */
157 at91_register_uart(AT91RM9200_ID_US2, 3, 0);
158
159 /* USART3 on ttyS4 (Rx, Tx, CTS, RTS) */
160 at91_register_uart(AT91RM9200_ID_US3, 4, ATMEL_UART_CTS |
161 ATMEL_UART_RTS);
162 at91_add_device_serial(); 158 at91_add_device_serial();
163 /* LEDs. */ 159 /* LEDs. */
164 at91_gpio_leds(cpuat91_leds, ARRAY_SIZE(cpuat91_leds)); 160 at91_gpio_leds(cpuat91_leds, ARRAY_SIZE(cpuat91_leds));
@@ -169,7 +165,7 @@ static void __init cpuat91_board_init(void)
169 /* USB Device */ 165 /* USB Device */
170 at91_add_device_udc(&cpuat91_udc_data); 166 at91_add_device_udc(&cpuat91_udc_data);
171 /* MMC */ 167 /* MMC */
172 at91_add_device_mci(0, &cpuat91_mci0_data); 168 at91_add_device_mmc(0, &cpuat91_mmc_data);
173 /* I2C */ 169 /* I2C */
174 at91_add_device_i2c(NULL, 0); 170 at91_add_device_i2c(NULL, 0);
175 /* Platform devices */ 171 /* Platform devices */
@@ -180,7 +176,6 @@ MACHINE_START(CPUAT91, "Eukrea")
180 /* Maintainer: Eric Benard - EUKREA Electromatique */ 176 /* Maintainer: Eric Benard - EUKREA Electromatique */
181 .timer = &at91rm9200_timer, 177 .timer = &at91rm9200_timer,
182 .map_io = at91_map_io, 178 .map_io = at91_map_io,
183 .handle_irq = at91_aic_handle_irq,
184 .init_early = cpuat91_init_early, 179 .init_early = cpuat91_init_early,
185 .init_irq = at91_init_irq_default, 180 .init_irq = at91_init_irq_default,
186 .init_machine = cpuat91_board_init, 181 .init_machine = cpuat91_board_init,
diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
index 48a531e05be..17654d5e94e 100644
--- a/arch/arm/mach-at91/board-csb337.c
+++ b/arch/arm/mach-at91/board-csb337.c
@@ -19,7 +19,6 @@
19 */ 19 */
20 20
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/gpio.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/mm.h> 23#include <linux/mm.h>
25#include <linux/module.h> 24#include <linux/module.h>
@@ -38,9 +37,9 @@
38#include <asm/mach/irq.h> 37#include <asm/mach/irq.h>
39 38
40#include <mach/hardware.h> 39#include <mach/hardware.h>
40#include <mach/board.h>
41#include <mach/gpio.h>
41 42
42#include "at91_aic.h"
43#include "board.h"
44#include "generic.h" 43#include "generic.h"
45 44
46 45
@@ -48,24 +47,29 @@ static void __init csb337_init_early(void)
48{ 47{
49 /* Initialize processor: 3.6864 MHz crystal */ 48 /* Initialize processor: 3.6864 MHz crystal */
50 at91_initialize(3686400); 49 at91_initialize(3686400);
50
51 /* Setup the LEDs */
52 at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
53
54 /* DBGU on ttyS0 */
55 at91_register_uart(0, 0, 0);
56
57 /* make console=ttyS0 the default */
58 at91_set_serial_console(0);
51} 59}
52 60
53static struct macb_platform_data __initdata csb337_eth_data = { 61static struct at91_eth_data __initdata csb337_eth_data = {
54 .phy_irq_pin = AT91_PIN_PC2, 62 .phy_irq_pin = AT91_PIN_PC2,
55 .is_rmii = 0, 63 .is_rmii = 0,
56 /* The CSB337 bootloader stores the MAC the wrong-way around */
57 .rev_eth_addr = 1,
58}; 64};
59 65
60static struct at91_usbh_data __initdata csb337_usbh_data = { 66static struct at91_usbh_data __initdata csb337_usbh_data = {
61 .ports = 2, 67 .ports = 2,
62 .vbus_pin = {-EINVAL, -EINVAL},
63 .overcurrent_pin= {-EINVAL, -EINVAL},
64}; 68};
65 69
66static struct at91_udc_data __initdata csb337_udc_data = { 70static struct at91_udc_data __initdata csb337_udc_data = {
71 // this has no VBUS sensing pin
67 .pullup_pin = AT91_PIN_PA24, 72 .pullup_pin = AT91_PIN_PA24,
68 .vbus_pin = -EINVAL,
69}; 73};
70 74
71static struct i2c_board_info __initdata csb337_i2c_devices[] = { 75static struct i2c_board_info __initdata csb337_i2c_devices[] = {
@@ -89,12 +93,11 @@ static struct at91_cf_data __initdata csb337_cf_data = {
89 .rst_pin = AT91_PIN_PD2, 93 .rst_pin = AT91_PIN_PD2,
90}; 94};
91 95
92static struct mci_platform_data __initdata csb337_mci0_data = { 96static struct at91_mmc_data __initdata csb337_mmc_data = {
93 .slot[0] = { 97 .det_pin = AT91_PIN_PD5,
94 .bus_width = 4, 98 .slot_b = 0,
95 .detect_pin = AT91_PIN_PD5, 99 .wire4 = 1,
96 .wp_pin = AT91_PIN_PD6, 100 .wp_pin = AT91_PIN_PD6,
97 },
98}; 101};
99 102
100static struct spi_board_info csb337_spi_devices[] = { 103static struct spi_board_info csb337_spi_devices[] = {
@@ -223,8 +226,6 @@ static struct gpio_led csb_leds[] = {
223static void __init csb337_board_init(void) 226static void __init csb337_board_init(void)
224{ 227{
225 /* Serial */ 228 /* Serial */
226 /* DBGU on ttyS0 */
227 at91_register_uart(0, 0, 0);
228 at91_add_device_serial(); 229 at91_add_device_serial();
229 /* Ethernet */ 230 /* Ethernet */
230 at91_add_device_eth(&csb337_eth_data); 231 at91_add_device_eth(&csb337_eth_data);
@@ -240,7 +241,7 @@ static void __init csb337_board_init(void)
240 /* SPI */ 241 /* SPI */
241 at91_add_device_spi(csb337_spi_devices, ARRAY_SIZE(csb337_spi_devices)); 242 at91_add_device_spi(csb337_spi_devices, ARRAY_SIZE(csb337_spi_devices));
242 /* MMC */ 243 /* MMC */
243 at91_add_device_mci(0, &csb337_mci0_data); 244 at91_add_device_mmc(0, &csb337_mmc_data);
244 /* NOR flash */ 245 /* NOR flash */
245 platform_device_register(&csb_flash); 246 platform_device_register(&csb_flash);
246 /* LEDs */ 247 /* LEDs */
@@ -253,7 +254,6 @@ MACHINE_START(CSB337, "Cogent CSB337")
253 /* Maintainer: Bill Gatliff */ 254 /* Maintainer: Bill Gatliff */
254 .timer = &at91rm9200_timer, 255 .timer = &at91rm9200_timer,
255 .map_io = at91_map_io, 256 .map_io = at91_map_io,
256 .handle_irq = at91_aic_handle_irq,
257 .init_early = csb337_init_early, 257 .init_early = csb337_init_early,
258 .init_irq = at91_init_irq_default, 258 .init_irq = at91_init_irq_default,
259 .init_machine = csb337_board_init, 259 .init_machine = csb337_board_init,
diff --git a/arch/arm/mach-at91/board-csb637.c b/arch/arm/mach-at91/board-csb637.c
index ec0f3abd504..72b55674616 100644
--- a/arch/arm/mach-at91/board-csb637.c
+++ b/arch/arm/mach-at91/board-csb637.c
@@ -20,7 +20,6 @@
20 20
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/gpio.h>
24#include <linux/mm.h> 23#include <linux/mm.h>
25#include <linux/module.h> 24#include <linux/module.h>
26#include <linux/platform_device.h> 25#include <linux/platform_device.h>
@@ -35,9 +34,9 @@
35#include <asm/mach/irq.h> 34#include <asm/mach/irq.h>
36 35
37#include <mach/hardware.h> 36#include <mach/hardware.h>
37#include <mach/board.h>
38#include <mach/gpio.h>
38 39
39#include "at91_aic.h"
40#include "board.h"
41#include "generic.h" 40#include "generic.h"
42 41
43 42
@@ -45,17 +44,21 @@ static void __init csb637_init_early(void)
45{ 44{
46 /* Initialize processor: 3.6864 MHz crystal */ 45 /* Initialize processor: 3.6864 MHz crystal */
47 at91_initialize(3686400); 46 at91_initialize(3686400);
47
48 /* DBGU on ttyS0. (Rx & Tx only) */
49 at91_register_uart(0, 0, 0);
50
51 /* make console=ttyS0 (ie, DBGU) the default */
52 at91_set_serial_console(0);
48} 53}
49 54
50static struct macb_platform_data __initdata csb637_eth_data = { 55static struct at91_eth_data __initdata csb637_eth_data = {
51 .phy_irq_pin = AT91_PIN_PC0, 56 .phy_irq_pin = AT91_PIN_PC0,
52 .is_rmii = 0, 57 .is_rmii = 0,
53}; 58};
54 59
55static struct at91_usbh_data __initdata csb637_usbh_data = { 60static struct at91_usbh_data __initdata csb637_usbh_data = {
56 .ports = 2, 61 .ports = 2,
57 .vbus_pin = {-EINVAL, -EINVAL},
58 .overcurrent_pin= {-EINVAL, -EINVAL},
59}; 62};
60 63
61static struct at91_udc_data __initdata csb637_udc_data = { 64static struct at91_udc_data __initdata csb637_udc_data = {
@@ -113,8 +116,6 @@ static void __init csb637_board_init(void)
113 /* LED(s) */ 116 /* LED(s) */
114 at91_gpio_leds(csb_leds, ARRAY_SIZE(csb_leds)); 117 at91_gpio_leds(csb_leds, ARRAY_SIZE(csb_leds));
115 /* Serial */ 118 /* Serial */
116 /* DBGU on ttyS0. (Rx & Tx only) */
117 at91_register_uart(0, 0, 0);
118 at91_add_device_serial(); 119 at91_add_device_serial();
119 /* Ethernet */ 120 /* Ethernet */
120 at91_add_device_eth(&csb637_eth_data); 121 at91_add_device_eth(&csb637_eth_data);
@@ -134,7 +135,6 @@ MACHINE_START(CSB637, "Cogent CSB637")
134 /* Maintainer: Bill Gatliff */ 135 /* Maintainer: Bill Gatliff */
135 .timer = &at91rm9200_timer, 136 .timer = &at91rm9200_timer,
136 .map_io = at91_map_io, 137 .map_io = at91_map_io,
137 .handle_irq = at91_aic_handle_irq,
138 .init_early = csb637_init_early, 138 .init_early = csb637_init_early,
139 .init_irq = at91_init_irq_default, 139 .init_irq = at91_init_irq_default,
140 .init_machine = csb637_board_init, 140 .init_machine = csb637_board_init,
diff --git a/arch/arm/mach-at91/board-dt.c b/arch/arm/mach-at91/board-dt.c
deleted file mode 100644
index 881170ce61d..00000000000
--- a/arch/arm/mach-at91/board-dt.c
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 * Setup code for AT91SAM Evaluation Kits with Device Tree support
3 *
4 * Copyright (C) 2011 Atmel,
5 * 2011 Nicolas Ferre <nicolas.ferre@atmel.com>
6 *
7 * Licensed under GPLv2 or later.
8 */
9
10#include <linux/types.h>
11#include <linux/init.h>
12#include <linux/module.h>
13#include <linux/gpio.h>
14#include <linux/of.h>
15#include <linux/of_irq.h>
16#include <linux/of_platform.h>
17
18#include <asm/setup.h>
19#include <asm/irq.h>
20#include <asm/mach/arch.h>
21#include <asm/mach/map.h>
22#include <asm/mach/irq.h>
23
24#include "at91_aic.h"
25#include "board.h"
26#include "generic.h"
27
28
29static const struct of_device_id irq_of_match[] __initconst = {
30
31 { .compatible = "atmel,at91rm9200-aic", .data = at91_aic_of_init },
32 { /*sentinel*/ }
33};
34
35static void __init at91_dt_init_irq(void)
36{
37 of_irq_init(irq_of_match);
38}
39
40static void __init at91_dt_device_init(void)
41{
42 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
43}
44
45static const char *at91_dt_board_compat[] __initdata = {
46 "atmel,at91sam9",
47 NULL
48};
49
50DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM (Device Tree)")
51 /* Maintainer: Atmel */
52 .timer = &at91sam926x_timer,
53 .map_io = at91_map_io,
54 .handle_irq = at91_aic_handle_irq,
55 .init_early = at91_dt_initialize,
56 .init_irq = at91_dt_init_irq,
57 .init_machine = at91_dt_device_init,
58 .dt_compat = at91_dt_board_compat,
59MACHINE_END
diff --git a/arch/arm/mach-at91/board-eb01.c b/arch/arm/mach-at91/board-eb01.c
index b489388a6f8..d2023f27c65 100644
--- a/arch/arm/mach-at91/board-eb01.c
+++ b/arch/arm/mach-at91/board-eb01.c
@@ -27,9 +27,7 @@
27#include <mach/hardware.h> 27#include <mach/hardware.h>
28#include <asm/mach/arch.h> 28#include <asm/mach/arch.h>
29#include <asm/mach/map.h> 29#include <asm/mach/map.h>
30 30#include <mach/board.h>
31#include "at91_aic.h"
32#include "board.h"
33#include "generic.h" 31#include "generic.h"
34 32
35static void __init at91eb01_init_irq(void) 33static void __init at91eb01_init_irq(void)
@@ -45,7 +43,6 @@ static void __init at91eb01_init_early(void)
45MACHINE_START(AT91EB01, "Atmel AT91 EB01") 43MACHINE_START(AT91EB01, "Atmel AT91 EB01")
46 /* Maintainer: Greg Ungerer <gerg@snapgear.com> */ 44 /* Maintainer: Greg Ungerer <gerg@snapgear.com> */
47 .timer = &at91x40_timer, 45 .timer = &at91x40_timer,
48 .handle_irq = at91_aic_handle_irq,
49 .init_early = at91eb01_init_early, 46 .init_early = at91eb01_init_early,
50 .init_irq = at91eb01_init_irq, 47 .init_irq = at91eb01_init_irq,
51MACHINE_END 48MACHINE_END
diff --git a/arch/arm/mach-at91/board-eb9200.c b/arch/arm/mach-at91/board-eb9200.c
index 9f5e71c95f0..01170a2766a 100644
--- a/arch/arm/mach-at91/board-eb9200.c
+++ b/arch/arm/mach-at91/board-eb9200.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/gpio.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/mm.h> 24#include <linux/mm.h>
26#include <linux/module.h> 25#include <linux/module.h>
@@ -35,8 +34,9 @@
35#include <asm/mach/map.h> 34#include <asm/mach/map.h>
36#include <asm/mach/irq.h> 35#include <asm/mach/irq.h>
37 36
38#include "at91_aic.h" 37#include <mach/board.h>
39#include "board.h" 38#include <mach/gpio.h>
39
40#include "generic.h" 40#include "generic.h"
41 41
42 42
@@ -44,17 +44,29 @@ static void __init eb9200_init_early(void)
44{ 44{
45 /* Initialize processor: 18.432 MHz crystal */ 45 /* Initialize processor: 18.432 MHz crystal */
46 at91_initialize(18432000); 46 at91_initialize(18432000);
47
48 /* DBGU on ttyS0. (Rx & Tx only) */
49 at91_register_uart(0, 0, 0);
50
51 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
52 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
53 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
54 | ATMEL_UART_RI);
55
56 /* USART2 on ttyS2. (Rx, Tx) - IRDA */
57 at91_register_uart(AT91RM9200_ID_US2, 2, 0);
58
59 /* set serial console to ttyS0 (ie, DBGU) */
60 at91_set_serial_console(0);
47} 61}
48 62
49static struct macb_platform_data __initdata eb9200_eth_data = { 63static struct at91_eth_data __initdata eb9200_eth_data = {
50 .phy_irq_pin = AT91_PIN_PC4, 64 .phy_irq_pin = AT91_PIN_PC4,
51 .is_rmii = 1, 65 .is_rmii = 1,
52}; 66};
53 67
54static struct at91_usbh_data __initdata eb9200_usbh_data = { 68static struct at91_usbh_data __initdata eb9200_usbh_data = {
55 .ports = 2, 69 .ports = 2,
56 .vbus_pin = {-EINVAL, -EINVAL},
57 .overcurrent_pin= {-EINVAL, -EINVAL},
58}; 70};
59 71
60static struct at91_udc_data __initdata eb9200_udc_data = { 72static struct at91_udc_data __initdata eb9200_udc_data = {
@@ -63,18 +75,15 @@ static struct at91_udc_data __initdata eb9200_udc_data = {
63}; 75};
64 76
65static struct at91_cf_data __initdata eb9200_cf_data = { 77static struct at91_cf_data __initdata eb9200_cf_data = {
66 .irq_pin = -EINVAL,
67 .det_pin = AT91_PIN_PB0, 78 .det_pin = AT91_PIN_PB0,
68 .vcc_pin = -EINVAL,
69 .rst_pin = AT91_PIN_PC5, 79 .rst_pin = AT91_PIN_PC5,
80 // .irq_pin = ... not connected
81 // .vcc_pin = ... always powered
70}; 82};
71 83
72static struct mci_platform_data __initdata eb9200_mci0_data = { 84static struct at91_mmc_data __initdata eb9200_mmc_data = {
73 .slot[0] = { 85 .slot_b = 0,
74 .bus_width = 4, 86 .wire4 = 1,
75 .detect_pin = -EINVAL,
76 .wp_pin = -EINVAL,
77 },
78}; 87};
79 88
80static struct i2c_board_info __initdata eb9200_i2c_devices[] = { 89static struct i2c_board_info __initdata eb9200_i2c_devices[] = {
@@ -87,16 +96,6 @@ static struct i2c_board_info __initdata eb9200_i2c_devices[] = {
87static void __init eb9200_board_init(void) 96static void __init eb9200_board_init(void)
88{ 97{
89 /* Serial */ 98 /* Serial */
90 /* DBGU on ttyS0. (Rx & Tx only) */
91 at91_register_uart(0, 0, 0);
92
93 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
94 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
95 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
96 | ATMEL_UART_RI);
97
98 /* USART2 on ttyS2. (Rx, Tx) - IRDA */
99 at91_register_uart(AT91RM9200_ID_US2, 2, 0);
100 at91_add_device_serial(); 99 at91_add_device_serial();
101 /* Ethernet */ 100 /* Ethernet */
102 at91_add_device_eth(&eb9200_eth_data); 101 at91_add_device_eth(&eb9200_eth_data);
@@ -112,13 +111,12 @@ static void __init eb9200_board_init(void)
112 at91_add_device_spi(NULL, 0); 111 at91_add_device_spi(NULL, 0);
113 /* MMC */ 112 /* MMC */
114 /* only supports 1 or 4 bit interface, not wired through to SPI */ 113 /* only supports 1 or 4 bit interface, not wired through to SPI */
115 at91_add_device_mci(0, &eb9200_mci0_data); 114 at91_add_device_mmc(0, &eb9200_mmc_data);
116} 115}
117 116
118MACHINE_START(ATEB9200, "Embest ATEB9200") 117MACHINE_START(ATEB9200, "Embest ATEB9200")
119 .timer = &at91rm9200_timer, 118 .timer = &at91rm9200_timer,
120 .map_io = at91_map_io, 119 .map_io = at91_map_io,
121 .handle_irq = at91_aic_handle_irq,
122 .init_early = eb9200_init_early, 120 .init_early = eb9200_init_early,
123 .init_irq = at91_init_irq_default, 121 .init_irq = at91_init_irq_default,
124 .init_machine = eb9200_board_init, 122 .init_machine = eb9200_board_init,
diff --git a/arch/arm/mach-at91/board-ecbat91.c b/arch/arm/mach-at91/board-ecbat91.c
index ef69e0ebe94..7c0313c51f2 100644
--- a/arch/arm/mach-at91/board-ecbat91.c
+++ b/arch/arm/mach-at91/board-ecbat91.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/gpio.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/mm.h> 24#include <linux/mm.h>
26#include <linux/module.h> 25#include <linux/module.h>
@@ -37,10 +36,10 @@
37#include <asm/mach/map.h> 36#include <asm/mach/map.h>
38#include <asm/mach/irq.h> 37#include <asm/mach/irq.h>
39 38
39#include <mach/board.h>
40#include <mach/gpio.h>
40#include <mach/cpu.h> 41#include <mach/cpu.h>
41 42
42#include "at91_aic.h"
43#include "board.h"
44#include "generic.h" 43#include "generic.h"
45 44
46 45
@@ -51,25 +50,32 @@ static void __init ecb_at91init_early(void)
51 50
52 /* Initialize processor: 18.432 MHz crystal */ 51 /* Initialize processor: 18.432 MHz crystal */
53 at91_initialize(18432000); 52 at91_initialize(18432000);
53
54 /* Setup the LEDs */
55 at91_init_leds(AT91_PIN_PC7, AT91_PIN_PC7);
56
57 /* DBGU on ttyS0. (Rx & Tx only) */
58 at91_register_uart(0, 0, 0);
59
60 /* USART0 on ttyS1. (Rx & Tx only) */
61 at91_register_uart(AT91RM9200_ID_US0, 1, 0);
62
63 /* set serial console to ttyS0 (ie, DBGU) */
64 at91_set_serial_console(0);
54} 65}
55 66
56static struct macb_platform_data __initdata ecb_at91eth_data = { 67static struct at91_eth_data __initdata ecb_at91eth_data = {
57 .phy_irq_pin = AT91_PIN_PC4, 68 .phy_irq_pin = AT91_PIN_PC4,
58 .is_rmii = 0, 69 .is_rmii = 0,
59}; 70};
60 71
61static struct at91_usbh_data __initdata ecb_at91usbh_data = { 72static struct at91_usbh_data __initdata ecb_at91usbh_data = {
62 .ports = 1, 73 .ports = 1,
63 .vbus_pin = {-EINVAL, -EINVAL},
64 .overcurrent_pin= {-EINVAL, -EINVAL},
65}; 74};
66 75
67static struct mci_platform_data __initdata ecbat91_mci0_data = { 76static struct at91_mmc_data __initdata ecb_at91mmc_data = {
68 .slot[0] = { 77 .slot_b = 0,
69 .bus_width = 4, 78 .wire4 = 1,
70 .detect_pin = -EINVAL,
71 .wp_pin = -EINVAL,
72 },
73}; 79};
74 80
75 81
@@ -138,26 +144,9 @@ static struct spi_board_info __initdata ecb_at91spi_devices[] = {
138 }, 144 },
139}; 145};
140 146
141/*
142 * LEDs
143 */
144static struct gpio_led ecb_leds[] = {
145 { /* D1 */
146 .name = "led1",
147 .gpio = AT91_PIN_PC7,
148 .active_low = 1,
149 .default_trigger = "heartbeat",
150 }
151};
152
153static void __init ecb_at91board_init(void) 147static void __init ecb_at91board_init(void)
154{ 148{
155 /* Serial */ 149 /* Serial */
156 /* DBGU on ttyS0. (Rx & Tx only) */
157 at91_register_uart(0, 0, 0);
158
159 /* USART0 on ttyS1. (Rx & Tx only) */
160 at91_register_uart(AT91RM9200_ID_US0, 1, 0);
161 at91_add_device_serial(); 150 at91_add_device_serial();
162 151
163 /* Ethernet */ 152 /* Ethernet */
@@ -170,20 +159,16 @@ static void __init ecb_at91board_init(void)
170 at91_add_device_i2c(NULL, 0); 159 at91_add_device_i2c(NULL, 0);
171 160
172 /* MMC */ 161 /* MMC */
173 at91_add_device_mci(0, &ecbat91_mci0_data); 162 at91_add_device_mmc(0, &ecb_at91mmc_data);
174 163
175 /* SPI */ 164 /* SPI */
176 at91_add_device_spi(ecb_at91spi_devices, ARRAY_SIZE(ecb_at91spi_devices)); 165 at91_add_device_spi(ecb_at91spi_devices, ARRAY_SIZE(ecb_at91spi_devices));
177
178 /* LEDs */
179 at91_gpio_leds(ecb_leds, ARRAY_SIZE(ecb_leds));
180} 166}
181 167
182MACHINE_START(ECBAT91, "emQbit's ECB_AT91") 168MACHINE_START(ECBAT91, "emQbit's ECB_AT91")
183 /* Maintainer: emQbit.com */ 169 /* Maintainer: emQbit.com */
184 .timer = &at91rm9200_timer, 170 .timer = &at91rm9200_timer,
185 .map_io = at91_map_io, 171 .map_io = at91_map_io,
186 .handle_irq = at91_aic_handle_irq,
187 .init_early = ecb_at91init_early, 172 .init_early = ecb_at91init_early,
188 .init_irq = at91_init_irq_default, 173 .init_irq = at91_init_irq_default,
189 .init_machine = ecb_at91board_init, 174 .init_machine = ecb_at91board_init,
diff --git a/arch/arm/mach-at91/board-eco920.c b/arch/arm/mach-at91/board-eco920.c
index 50f3d3795c0..8252c722607 100644
--- a/arch/arm/mach-at91/board-eco920.c
+++ b/arch/arm/mach-at91/board-eco920.c
@@ -24,12 +24,10 @@
24#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
25#include <asm/mach/map.h> 25#include <asm/mach/map.h>
26 26
27#include <mach/board.h>
27#include <mach/at91rm9200_mc.h> 28#include <mach/at91rm9200_mc.h>
28#include <mach/at91_ramc.h>
29#include <mach/cpu.h> 29#include <mach/cpu.h>
30 30
31#include "at91_aic.h"
32#include "board.h"
33#include "generic.h" 31#include "generic.h"
34 32
35static void __init eco920_init_early(void) 33static void __init eco920_init_early(void)
@@ -38,17 +36,24 @@ static void __init eco920_init_early(void)
38 at91rm9200_set_type(ARCH_REVISON_9200_PQFP); 36 at91rm9200_set_type(ARCH_REVISON_9200_PQFP);
39 37
40 at91_initialize(18432000); 38 at91_initialize(18432000);
39
40 /* Setup the LEDs */
41 at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
42
43 /* DBGU on ttyS0. (Rx & Tx only */
44 at91_register_uart(0, 0, 0);
45
46 /* set serial console to ttyS0 (ie, DBGU) */
47 at91_set_serial_console(0);
41} 48}
42 49
43static struct macb_platform_data __initdata eco920_eth_data = { 50static struct at91_eth_data __initdata eco920_eth_data = {
44 .phy_irq_pin = AT91_PIN_PC2, 51 .phy_irq_pin = AT91_PIN_PC2,
45 .is_rmii = 1, 52 .is_rmii = 1,
46}; 53};
47 54
48static struct at91_usbh_data __initdata eco920_usbh_data = { 55static struct at91_usbh_data __initdata eco920_usbh_data = {
49 .ports = 1, 56 .ports = 1,
50 .vbus_pin = {-EINVAL, -EINVAL},
51 .overcurrent_pin= {-EINVAL, -EINVAL},
52}; 57};
53 58
54static struct at91_udc_data __initdata eco920_udc_data = { 59static struct at91_udc_data __initdata eco920_udc_data = {
@@ -56,12 +61,9 @@ static struct at91_udc_data __initdata eco920_udc_data = {
56 .pullup_pin = AT91_PIN_PB13, 61 .pullup_pin = AT91_PIN_PB13,
57}; 62};
58 63
59static struct mci_platform_data __initdata eco920_mci0_data = { 64static struct at91_mmc_data __initdata eco920_mmc_data = {
60 .slot[0] = { 65 .slot_b = 0,
61 .bus_width = 1, 66 .wire4 = 0,
62 .detect_pin = -EINVAL,
63 .wp_pin = -EINVAL,
64 },
65}; 67};
66 68
67static struct physmap_flash_data eco920_flash_data = { 69static struct physmap_flash_data eco920_flash_data = {
@@ -93,37 +95,17 @@ static struct spi_board_info eco920_spi_devices[] = {
93 }, 95 },
94}; 96};
95 97
96/*
97 * LEDs
98 */
99static struct gpio_led eco920_leds[] = {
100 { /* D1 */
101 .name = "led1",
102 .gpio = AT91_PIN_PB0,
103 .active_low = 1,
104 .default_trigger = "heartbeat",
105 },
106 { /* D2 */
107 .name = "led2",
108 .gpio = AT91_PIN_PB1,
109 .active_low = 1,
110 .default_trigger = "timer",
111 }
112};
113
114static void __init eco920_board_init(void) 98static void __init eco920_board_init(void)
115{ 99{
116 /* DBGU on ttyS0. (Rx & Tx only */
117 at91_register_uart(0, 0, 0);
118 at91_add_device_serial(); 100 at91_add_device_serial();
119 at91_add_device_eth(&eco920_eth_data); 101 at91_add_device_eth(&eco920_eth_data);
120 at91_add_device_usbh(&eco920_usbh_data); 102 at91_add_device_usbh(&eco920_usbh_data);
121 at91_add_device_udc(&eco920_udc_data); 103 at91_add_device_udc(&eco920_udc_data);
122 104
123 at91_add_device_mci(0, &eco920_mci0_data); 105 at91_add_device_mmc(0, &eco920_mmc_data);
124 platform_device_register(&eco920_flash); 106 platform_device_register(&eco920_flash);
125 107
126 at91_ramc_write(0, AT91_SMC_CSR(7), AT91_SMC_RWHOLD_(1) 108 at91_sys_write(AT91_SMC_CSR(7), AT91_SMC_RWHOLD_(1)
127 | AT91_SMC_RWSETUP_(1) 109 | AT91_SMC_RWSETUP_(1)
128 | AT91_SMC_DBW_8 110 | AT91_SMC_DBW_8
129 | AT91_SMC_WSEN 111 | AT91_SMC_WSEN
@@ -135,7 +117,7 @@ static void __init eco920_board_init(void)
135 at91_set_deglitch(AT91_PIN_PA23, 1); 117 at91_set_deglitch(AT91_PIN_PA23, 1);
136 118
137/* Initialization of the Static Memory Controller for Chip Select 3 */ 119/* Initialization of the Static Memory Controller for Chip Select 3 */
138 at91_ramc_write(0, AT91_SMC_CSR(3), 120 at91_sys_write(AT91_SMC_CSR(3),
139 AT91_SMC_DBW_16 | /* 16 bit */ 121 AT91_SMC_DBW_16 | /* 16 bit */
140 AT91_SMC_WSEN | 122 AT91_SMC_WSEN |
141 AT91_SMC_NWS_(5) | /* wait states */ 123 AT91_SMC_NWS_(5) | /* wait states */
@@ -143,15 +125,12 @@ static void __init eco920_board_init(void)
143 ); 125 );
144 126
145 at91_add_device_spi(eco920_spi_devices, ARRAY_SIZE(eco920_spi_devices)); 127 at91_add_device_spi(eco920_spi_devices, ARRAY_SIZE(eco920_spi_devices));
146 /* LEDs */
147 at91_gpio_leds(eco920_leds, ARRAY_SIZE(eco920_leds));
148} 128}
149 129
150MACHINE_START(ECO920, "eco920") 130MACHINE_START(ECO920, "eco920")
151 /* Maintainer: Sascha Hauer */ 131 /* Maintainer: Sascha Hauer */
152 .timer = &at91rm9200_timer, 132 .timer = &at91rm9200_timer,
153 .map_io = at91_map_io, 133 .map_io = at91_map_io,
154 .handle_irq = at91_aic_handle_irq,
155 .init_early = eco920_init_early, 134 .init_early = eco920_init_early,
156 .init_irq = at91_init_irq_default, 135 .init_irq = at91_init_irq_default,
157 .init_machine = eco920_board_init, 136 .init_machine = eco920_board_init,
diff --git a/arch/arm/mach-at91/board-flexibity.c b/arch/arm/mach-at91/board-flexibity.c
index 5d44eba0f20..4c3f65d9c59 100644
--- a/arch/arm/mach-at91/board-flexibity.c
+++ b/arch/arm/mach-at91/board-flexibity.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/arch/arm/mach-at91/board-flexibity.c 2 * linux/arch/arm/mach-at91/board-flexibity.c
3 * 3 *
4 * Copyright (C) 2010-2011 Flexibity 4 * Copyright (C) 2010 Flexibity
5 * Copyright (C) 2005 SAN People 5 * Copyright (C) 2005 SAN People
6 * Copyright (C) 2006 Atmel 6 * Copyright (C) 2006 Atmel
7 * 7 *
@@ -33,35 +33,31 @@
33#include <asm/mach/irq.h> 33#include <asm/mach/irq.h>
34 34
35#include <mach/hardware.h> 35#include <mach/hardware.h>
36#include <mach/board.h>
36 37
37#include "at91_aic.h"
38#include "board.h"
39#include "generic.h" 38#include "generic.h"
40 39
41static void __init flexibity_init_early(void) 40static void __init flexibity_init_early(void)
42{ 41{
43 /* Initialize processor: 18.432 MHz crystal */ 42 /* Initialize processor: 18.432 MHz crystal */
44 at91_initialize(18432000); 43 at91_initialize(18432000);
44
45 /* DBGU on ttyS0. (Rx & Tx only) */
46 at91_register_uart(0, 0, 0);
47
48 /* set serial console to ttyS0 (ie, DBGU) */
49 at91_set_serial_console(0);
45} 50}
46 51
47/* USB Host port */ 52/* USB Host port */
48static struct at91_usbh_data __initdata flexibity_usbh_data = { 53static struct at91_usbh_data __initdata flexibity_usbh_data = {
49 .ports = 2, 54 .ports = 2,
50 .vbus_pin = {-EINVAL, -EINVAL},
51 .overcurrent_pin= {-EINVAL, -EINVAL},
52}; 55};
53 56
54/* USB Device port */ 57/* USB Device port */
55static struct at91_udc_data __initdata flexibity_udc_data = { 58static struct at91_udc_data __initdata flexibity_udc_data = {
56 .vbus_pin = AT91_PIN_PC5, 59 .vbus_pin = AT91_PIN_PC5,
57 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 60 .pullup_pin = 0, /* pull-up driven by UDC */
58};
59
60/* I2C devices */
61static struct i2c_board_info __initdata flexibity_i2c_devices[] = {
62 {
63 I2C_BOARD_INFO("ds1307", 0x68),
64 },
65}; 61};
66 62
67/* SPI devices */ 63/* SPI devices */
@@ -75,12 +71,11 @@ static struct spi_board_info flexibity_spi_devices[] = {
75}; 71};
76 72
77/* MCI (SD/MMC) */ 73/* MCI (SD/MMC) */
78static struct mci_platform_data __initdata flexibity_mci0_data = { 74static struct at91_mmc_data __initdata flexibity_mmc_data = {
79 .slot[0] = { 75 .slot_b = 0,
80 .bus_width = 4, 76 .wire4 = 1,
81 .detect_pin = AT91_PIN_PC9, 77 .det_pin = AT91_PIN_PC9,
82 .wp_pin = AT91_PIN_PC4, 78 .wp_pin = AT91_PIN_PC4,
83 },
84}; 79};
85 80
86/* LEDs */ 81/* LEDs */
@@ -138,21 +133,16 @@ static struct gpio_led flexibity_leds[] = {
138static void __init flexibity_board_init(void) 133static void __init flexibity_board_init(void)
139{ 134{
140 /* Serial */ 135 /* Serial */
141 /* DBGU on ttyS0. (Rx & Tx only) */
142 at91_register_uart(0, 0, 0);
143 at91_add_device_serial(); 136 at91_add_device_serial();
144 /* USB Host */ 137 /* USB Host */
145 at91_add_device_usbh(&flexibity_usbh_data); 138 at91_add_device_usbh(&flexibity_usbh_data);
146 /* USB Device */ 139 /* USB Device */
147 at91_add_device_udc(&flexibity_udc_data); 140 at91_add_device_udc(&flexibity_udc_data);
148 /* I2C */
149 at91_add_device_i2c(flexibity_i2c_devices,
150 ARRAY_SIZE(flexibity_i2c_devices));
151 /* SPI */ 141 /* SPI */
152 at91_add_device_spi(flexibity_spi_devices, 142 at91_add_device_spi(flexibity_spi_devices,
153 ARRAY_SIZE(flexibity_spi_devices)); 143 ARRAY_SIZE(flexibity_spi_devices));
154 /* MMC */ 144 /* MMC */
155 at91_add_device_mci(0, &flexibity_mci0_data); 145 at91_add_device_mmc(0, &flexibity_mmc_data);
156 /* LEDs */ 146 /* LEDs */
157 at91_gpio_leds(flexibity_leds, ARRAY_SIZE(flexibity_leds)); 147 at91_gpio_leds(flexibity_leds, ARRAY_SIZE(flexibity_leds));
158} 148}
@@ -161,7 +151,6 @@ MACHINE_START(FLEXIBITY, "Flexibity Connect")
161 /* Maintainer: Maxim Osipov */ 151 /* Maintainer: Maxim Osipov */
162 .timer = &at91sam926x_timer, 152 .timer = &at91sam926x_timer,
163 .map_io = at91_map_io, 153 .map_io = at91_map_io,
164 .handle_irq = at91_aic_handle_irq,
165 .init_early = flexibity_init_early, 154 .init_early = flexibity_init_early,
166 .init_irq = at91_init_irq_default, 155 .init_irq = at91_init_irq_default,
167 .init_machine = flexibity_board_init, 156 .init_machine = flexibity_board_init,
diff --git a/arch/arm/mach-at91/board-foxg20.c b/arch/arm/mach-at91/board-foxg20.c
index 191d37c16ba..f27d1a780cf 100644
--- a/arch/arm/mach-at91/board-foxg20.c
+++ b/arch/arm/mach-at91/board-foxg20.c
@@ -41,10 +41,9 @@
41#include <asm/mach/map.h> 41#include <asm/mach/map.h>
42#include <asm/mach/irq.h> 42#include <asm/mach/irq.h>
43 43
44#include <mach/board.h>
44#include <mach/at91sam9_smc.h> 45#include <mach/at91sam9_smc.h>
45 46
46#include "at91_aic.h"
47#include "board.h"
48#include "sam9_smc.h" 47#include "sam9_smc.h"
49#include "generic.h" 48#include "generic.h"
50 49
@@ -62,6 +61,44 @@ static void __init foxg20_init_early(void)
62{ 61{
63 /* Initialize processor: 18.432 MHz crystal */ 62 /* Initialize processor: 18.432 MHz crystal */
64 at91_initialize(18432000); 63 at91_initialize(18432000);
64
65 /* DBGU on ttyS0. (Rx & Tx only) */
66 at91_register_uart(0, 0, 0);
67
68 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
69 at91_register_uart(AT91SAM9260_ID_US0, 1,
70 ATMEL_UART_CTS
71 | ATMEL_UART_RTS
72 | ATMEL_UART_DTR
73 | ATMEL_UART_DSR
74 | ATMEL_UART_DCD
75 | ATMEL_UART_RI);
76
77 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
78 at91_register_uart(AT91SAM9260_ID_US1, 2,
79 ATMEL_UART_CTS
80 | ATMEL_UART_RTS);
81
82 /* USART2 on ttyS3. (Rx & Tx only) */
83 at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
84
85 /* USART3 on ttyS4. (Rx, Tx, RTS, CTS) */
86 at91_register_uart(AT91SAM9260_ID_US3, 4,
87 ATMEL_UART_CTS
88 | ATMEL_UART_RTS);
89
90 /* USART4 on ttyS5. (Rx & Tx only) */
91 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
92
93 /* USART5 on ttyS6. (Rx & Tx only) */
94 at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
95
96 /* set serial console to ttyS0 (ie, DBGU) */
97 at91_set_serial_console(0);
98
99 /* Set the internal pull-up resistor on DRXD */
100 at91_set_A_periph(AT91_PIN_PB14, 1);
101
65} 102}
66 103
67/* 104/*
@@ -69,8 +106,6 @@ static void __init foxg20_init_early(void)
69 */ 106 */
70static struct at91_usbh_data __initdata foxg20_usbh_data = { 107static struct at91_usbh_data __initdata foxg20_usbh_data = {
71 .ports = 2, 108 .ports = 2,
72 .vbus_pin = {-EINVAL, -EINVAL},
73 .overcurrent_pin= {-EINVAL, -EINVAL},
74}; 109};
75 110
76/* 111/*
@@ -78,7 +113,7 @@ static struct at91_usbh_data __initdata foxg20_usbh_data = {
78 */ 113 */
79static struct at91_udc_data __initdata foxg20_udc_data = { 114static struct at91_udc_data __initdata foxg20_udc_data = {
80 .vbus_pin = AT91_PIN_PC6, 115 .vbus_pin = AT91_PIN_PC6,
81 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 116 .pullup_pin = 0, /* pull-up driven by UDC */
82}; 117};
83 118
84 119
@@ -86,7 +121,7 @@ static struct at91_udc_data __initdata foxg20_udc_data = {
86 * SPI devices. 121 * SPI devices.
87 */ 122 */
88static struct spi_board_info foxg20_spi_devices[] = { 123static struct spi_board_info foxg20_spi_devices[] = {
89#if !IS_ENABLED(CONFIG_MMC_ATMELMCI) 124#if !defined(CONFIG_MMC_AT91)
90 { 125 {
91 .modalias = "mtd_dataflash", 126 .modalias = "mtd_dataflash",
92 .chip_select = 1, 127 .chip_select = 1,
@@ -100,7 +135,7 @@ static struct spi_board_info foxg20_spi_devices[] = {
100/* 135/*
101 * MACB Ethernet device 136 * MACB Ethernet device
102 */ 137 */
103static struct macb_platform_data __initdata foxg20_macb_data = { 138static struct at91_eth_data __initdata foxg20_macb_data = {
104 .phy_irq_pin = AT91_PIN_PA7, 139 .phy_irq_pin = AT91_PIN_PA7,
105 .is_rmii = 1, 140 .is_rmii = 1,
106}; 141};
@@ -109,12 +144,9 @@ static struct macb_platform_data __initdata foxg20_macb_data = {
109 * MCI (SD/MMC) 144 * MCI (SD/MMC)
110 * det_pin, wp_pin and vcc_pin are not connected 145 * det_pin, wp_pin and vcc_pin are not connected
111 */ 146 */
112static struct mci_platform_data __initdata foxg20_mci0_data = { 147static struct at91_mmc_data __initdata foxg20_mmc_data = {
113 .slot[1] = { 148 .slot_b = 1,
114 .bus_width = 4, 149 .wire4 = 1,
115 .detect_pin = -EINVAL,
116 .wp_pin = -EINVAL,
117 },
118}; 150};
119 151
120 152
@@ -204,39 +236,6 @@ static struct i2c_board_info __initdata foxg20_i2c_devices[] = {
204static void __init foxg20_board_init(void) 236static void __init foxg20_board_init(void)
205{ 237{
206 /* Serial */ 238 /* Serial */
207 /* DBGU on ttyS0. (Rx & Tx only) */
208 at91_register_uart(0, 0, 0);
209
210 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
211 at91_register_uart(AT91SAM9260_ID_US0, 1,
212 ATMEL_UART_CTS
213 | ATMEL_UART_RTS
214 | ATMEL_UART_DTR
215 | ATMEL_UART_DSR
216 | ATMEL_UART_DCD
217 | ATMEL_UART_RI);
218
219 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
220 at91_register_uart(AT91SAM9260_ID_US1, 2,
221 ATMEL_UART_CTS
222 | ATMEL_UART_RTS);
223
224 /* USART2 on ttyS3. (Rx & Tx only) */
225 at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
226
227 /* USART3 on ttyS4. (Rx, Tx, RTS, CTS) */
228 at91_register_uart(AT91SAM9260_ID_US3, 4,
229 ATMEL_UART_CTS
230 | ATMEL_UART_RTS);
231
232 /* USART4 on ttyS5. (Rx & Tx only) */
233 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
234
235 /* USART5 on ttyS6. (Rx & Tx only) */
236 at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
237
238 /* Set the internal pull-up resistor on DRXD */
239 at91_set_A_periph(AT91_PIN_PB14, 1);
240 at91_add_device_serial(); 239 at91_add_device_serial();
241 /* USB Host */ 240 /* USB Host */
242 at91_add_device_usbh(&foxg20_usbh_data); 241 at91_add_device_usbh(&foxg20_usbh_data);
@@ -247,7 +246,7 @@ static void __init foxg20_board_init(void)
247 /* Ethernet */ 246 /* Ethernet */
248 at91_add_device_eth(&foxg20_macb_data); 247 at91_add_device_eth(&foxg20_macb_data);
249 /* MMC */ 248 /* MMC */
250 at91_add_device_mci(0, &foxg20_mci0_data); 249 at91_add_device_mmc(0, &foxg20_mmc_data);
251 /* I2C */ 250 /* I2C */
252 at91_add_device_i2c(foxg20_i2c_devices, ARRAY_SIZE(foxg20_i2c_devices)); 251 at91_add_device_i2c(foxg20_i2c_devices, ARRAY_SIZE(foxg20_i2c_devices));
253 /* LEDs */ 252 /* LEDs */
@@ -263,7 +262,6 @@ MACHINE_START(ACMENETUSFOXG20, "Acme Systems srl FOX Board G20")
263 /* Maintainer: Sergio Tanzilli */ 262 /* Maintainer: Sergio Tanzilli */
264 .timer = &at91sam926x_timer, 263 .timer = &at91sam926x_timer,
265 .map_io = at91_map_io, 264 .map_io = at91_map_io,
266 .handle_irq = at91_aic_handle_irq,
267 .init_early = foxg20_init_early, 265 .init_early = foxg20_init_early,
268 .init_irq = at91_init_irq_default, 266 .init_irq = at91_init_irq_default,
269 .init_machine = foxg20_board_init, 267 .init_machine = foxg20_board_init,
diff --git a/arch/arm/mach-at91/board-gsia18s.c b/arch/arm/mach-at91/board-gsia18s.c
index 23a2fa17ab2..2e95949737e 100644
--- a/arch/arm/mach-at91/board-gsia18s.c
+++ b/arch/arm/mach-at91/board-gsia18s.c
@@ -30,18 +30,49 @@
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
32 32
33#include <mach/board.h>
33#include <mach/at91sam9_smc.h> 34#include <mach/at91sam9_smc.h>
35#include <mach/gsia18s.h>
36#include <mach/stamp9g20.h>
34 37
35#include "at91_aic.h"
36#include "board.h"
37#include "sam9_smc.h" 38#include "sam9_smc.h"
38#include "generic.h" 39#include "generic.h"
39#include "gsia18s.h"
40#include "stamp9g20.h"
41 40
42static void __init gsia18s_init_early(void) 41static void __init gsia18s_init_early(void)
43{ 42{
44 stamp9g20_init_early(); 43 stamp9g20_init_early();
44
45 /*
46 * USART0 on ttyS1 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI).
47 * Used for Internal Analog Modem.
48 */
49 at91_register_uart(AT91SAM9260_ID_US0, 1,
50 ATMEL_UART_CTS | ATMEL_UART_RTS |
51 ATMEL_UART_DTR | ATMEL_UART_DSR |
52 ATMEL_UART_DCD | ATMEL_UART_RI);
53 /*
54 * USART1 on ttyS2 (Rx, Tx, CTS, RTS).
55 * Used for GPS or WiFi or Data stream.
56 */
57 at91_register_uart(AT91SAM9260_ID_US1, 2,
58 ATMEL_UART_CTS | ATMEL_UART_RTS);
59 /*
60 * USART2 on ttyS3 (Rx, Tx, CTS, RTS).
61 * Used for External Modem.
62 */
63 at91_register_uart(AT91SAM9260_ID_US2, 3,
64 ATMEL_UART_CTS | ATMEL_UART_RTS);
65 /*
66 * USART3 on ttyS4 (Rx, Tx, RTS).
67 * Used for RS-485.
68 */
69 at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
70
71 /*
72 * USART4 on ttyS5 (Rx, Tx).
73 * Used for TRX433 Radio Module.
74 */
75 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
45} 76}
46 77
47/* 78/*
@@ -49,8 +80,6 @@ static void __init gsia18s_init_early(void)
49 */ 80 */
50static struct at91_usbh_data __initdata usbh_data = { 81static struct at91_usbh_data __initdata usbh_data = {
51 .ports = 2, 82 .ports = 2,
52 .vbus_pin = {-EINVAL, -EINVAL},
53 .overcurrent_pin= {-EINVAL, -EINVAL},
54}; 83};
55 84
56/* 85/*
@@ -58,13 +87,13 @@ static struct at91_usbh_data __initdata usbh_data = {
58 */ 87 */
59static struct at91_udc_data __initdata udc_data = { 88static struct at91_udc_data __initdata udc_data = {
60 .vbus_pin = AT91_PIN_PA22, 89 .vbus_pin = AT91_PIN_PA22,
61 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 90 .pullup_pin = 0, /* pull-up driven by UDC */
62}; 91};
63 92
64/* 93/*
65 * MACB Ethernet device 94 * MACB Ethernet device
66 */ 95 */
67static struct macb_platform_data __initdata macb_data = { 96static struct at91_eth_data __initdata macb_data = {
68 .phy_irq_pin = AT91_PIN_PA28, 97 .phy_irq_pin = AT91_PIN_PA28,
69 .is_rmii = 1, 98 .is_rmii = 1,
70}; 99};
@@ -501,7 +530,6 @@ static struct i2c_board_info __initdata gsia18s_i2c_devices[] = {
501static struct at91_cf_data __initdata gsia18s_cf1_data = { 530static struct at91_cf_data __initdata gsia18s_cf1_data = {
502 .irq_pin = AT91_PIN_PA27, 531 .irq_pin = AT91_PIN_PA27,
503 .det_pin = AT91_PIN_PB30, 532 .det_pin = AT91_PIN_PB30,
504 .vcc_pin = -EINVAL,
505 .rst_pin = AT91_PIN_PB31, 533 .rst_pin = AT91_PIN_PB31,
506 .chipselect = 5, 534 .chipselect = 5,
507 .flags = AT91_CF_TRUE_IDE, 535 .flags = AT91_CF_TRUE_IDE,
@@ -527,37 +555,6 @@ static int __init gsia18s_power_off_init(void)
527 555
528static void __init gsia18s_board_init(void) 556static void __init gsia18s_board_init(void)
529{ 557{
530 /*
531 * USART0 on ttyS1 (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI).
532 * Used for Internal Analog Modem.
533 */
534 at91_register_uart(AT91SAM9260_ID_US0, 1,
535 ATMEL_UART_CTS | ATMEL_UART_RTS |
536 ATMEL_UART_DTR | ATMEL_UART_DSR |
537 ATMEL_UART_DCD | ATMEL_UART_RI);
538 /*
539 * USART1 on ttyS2 (Rx, Tx, CTS, RTS).
540 * Used for GPS or WiFi or Data stream.
541 */
542 at91_register_uart(AT91SAM9260_ID_US1, 2,
543 ATMEL_UART_CTS | ATMEL_UART_RTS);
544 /*
545 * USART2 on ttyS3 (Rx, Tx, CTS, RTS).
546 * Used for External Modem.
547 */
548 at91_register_uart(AT91SAM9260_ID_US2, 3,
549 ATMEL_UART_CTS | ATMEL_UART_RTS);
550 /*
551 * USART3 on ttyS4 (Rx, Tx, RTS).
552 * Used for RS-485.
553 */
554 at91_register_uart(AT91SAM9260_ID_US3, 4, ATMEL_UART_RTS);
555
556 /*
557 * USART4 on ttyS5 (Rx, Tx).
558 * Used for TRX433 Radio Module.
559 */
560 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
561 stamp9g20_board_init(); 558 stamp9g20_board_init();
562 at91_add_device_usbh(&usbh_data); 559 at91_add_device_usbh(&usbh_data);
563 at91_add_device_udc(&udc_data); 560 at91_add_device_udc(&udc_data);
@@ -576,7 +573,6 @@ static void __init gsia18s_board_init(void)
576MACHINE_START(GSIA18S, "GS_IA18_S") 573MACHINE_START(GSIA18S, "GS_IA18_S")
577 .timer = &at91sam926x_timer, 574 .timer = &at91sam926x_timer,
578 .map_io = at91_map_io, 575 .map_io = at91_map_io,
579 .handle_irq = at91_aic_handle_irq,
580 .init_early = gsia18s_init_early, 576 .init_early = gsia18s_init_early,
581 .init_irq = at91_init_irq_default, 577 .init_irq = at91_init_irq_default,
582 .init_machine = gsia18s_board_init, 578 .init_machine = gsia18s_board_init,
diff --git a/arch/arm/mach-at91/board-kafa.c b/arch/arm/mach-at91/board-kafa.c
index 9a43d1e1a03..4a170890b3b 100644
--- a/arch/arm/mach-at91/board-kafa.c
+++ b/arch/arm/mach-at91/board-kafa.c
@@ -19,7 +19,6 @@
19 */ 19 */
20 20
21#include <linux/types.h> 21#include <linux/types.h>
22#include <linux/gpio.h>
23#include <linux/init.h> 22#include <linux/init.h>
24#include <linux/mm.h> 23#include <linux/mm.h>
25#include <linux/module.h> 24#include <linux/module.h>
@@ -34,10 +33,10 @@
34#include <asm/mach/map.h> 33#include <asm/mach/map.h>
35#include <asm/mach/irq.h> 34#include <asm/mach/irq.h>
36 35
36#include <mach/board.h>
37#include <mach/gpio.h>
37#include <mach/cpu.h> 38#include <mach/cpu.h>
38 39
39#include "at91_aic.h"
40#include "board.h"
41#include "generic.h" 40#include "generic.h"
42 41
43 42
@@ -48,17 +47,27 @@ static void __init kafa_init_early(void)
48 47
49 /* Initialize processor: 18.432 MHz crystal */ 48 /* Initialize processor: 18.432 MHz crystal */
50 at91_initialize(18432000); 49 at91_initialize(18432000);
50
51 /* Set up the LEDs */
52 at91_init_leds(AT91_PIN_PB4, AT91_PIN_PB4);
53
54 /* DBGU on ttyS0. (Rx & Tx only) */
55 at91_register_uart(0, 0, 0);
56
57 /* USART0 on ttyS1 (Rx, Tx, CTS, RTS) */
58 at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
59
60 /* set serial console to ttyS0 (ie, DBGU) */
61 at91_set_serial_console(0);
51} 62}
52 63
53static struct macb_platform_data __initdata kafa_eth_data = { 64static struct at91_eth_data __initdata kafa_eth_data = {
54 .phy_irq_pin = AT91_PIN_PC4, 65 .phy_irq_pin = AT91_PIN_PC4,
55 .is_rmii = 0, 66 .is_rmii = 0,
56}; 67};
57 68
58static struct at91_usbh_data __initdata kafa_usbh_data = { 69static struct at91_usbh_data __initdata kafa_usbh_data = {
59 .ports = 1, 70 .ports = 1,
60 .vbus_pin = {-EINVAL, -EINVAL},
61 .overcurrent_pin= {-EINVAL, -EINVAL},
62}; 71};
63 72
64static struct at91_udc_data __initdata kafa_udc_data = { 73static struct at91_udc_data __initdata kafa_udc_data = {
@@ -66,26 +75,9 @@ static struct at91_udc_data __initdata kafa_udc_data = {
66 .pullup_pin = AT91_PIN_PB7, 75 .pullup_pin = AT91_PIN_PB7,
67}; 76};
68 77
69/*
70 * LEDs
71 */
72static struct gpio_led kafa_leds[] = {
73 { /* D1 */
74 .name = "led1",
75 .gpio = AT91_PIN_PB4,
76 .active_low = 1,
77 .default_trigger = "heartbeat",
78 },
79};
80
81static void __init kafa_board_init(void) 78static void __init kafa_board_init(void)
82{ 79{
83 /* Serial */ 80 /* Serial */
84 /* DBGU on ttyS0. (Rx & Tx only) */
85 at91_register_uart(0, 0, 0);
86
87 /* USART0 on ttyS1 (Rx, Tx, CTS, RTS) */
88 at91_register_uart(AT91RM9200_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
89 at91_add_device_serial(); 81 at91_add_device_serial();
90 /* Ethernet */ 82 /* Ethernet */
91 at91_add_device_eth(&kafa_eth_data); 83 at91_add_device_eth(&kafa_eth_data);
@@ -97,15 +89,12 @@ static void __init kafa_board_init(void)
97 at91_add_device_i2c(NULL, 0); 89 at91_add_device_i2c(NULL, 0);
98 /* SPI */ 90 /* SPI */
99 at91_add_device_spi(NULL, 0); 91 at91_add_device_spi(NULL, 0);
100 /* LEDs */
101 at91_gpio_leds(kafa_leds, ARRAY_SIZE(kafa_leds));
102} 92}
103 93
104MACHINE_START(KAFA, "Sperry-Sun KAFA") 94MACHINE_START(KAFA, "Sperry-Sun KAFA")
105 /* Maintainer: Sergei Sharonov */ 95 /* Maintainer: Sergei Sharonov */
106 .timer = &at91rm9200_timer, 96 .timer = &at91rm9200_timer,
107 .map_io = at91_map_io, 97 .map_io = at91_map_io,
108 .handle_irq = at91_aic_handle_irq,
109 .init_early = kafa_init_early, 98 .init_early = kafa_init_early,
110 .init_irq = at91_init_irq_default, 99 .init_irq = at91_init_irq_default,
111 .init_machine = kafa_board_init, 100 .init_machine = kafa_board_init,
diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c
index f168bec2369..9dc8d496ead 100644
--- a/arch/arm/mach-at91/board-kb9202.c
+++ b/arch/arm/mach-at91/board-kb9202.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/gpio.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/mm.h> 24#include <linux/mm.h>
26#include <linux/module.h> 25#include <linux/module.h>
@@ -35,12 +34,11 @@
35#include <asm/mach/map.h> 34#include <asm/mach/map.h>
36#include <asm/mach/irq.h> 35#include <asm/mach/irq.h>
37 36
37#include <mach/board.h>
38#include <mach/gpio.h>
38#include <mach/cpu.h> 39#include <mach/cpu.h>
39#include <mach/at91rm9200_mc.h> 40#include <mach/at91rm9200_mc.h>
40#include <mach/at91_ramc.h>
41 41
42#include "at91_aic.h"
43#include "board.h"
44#include "generic.h" 42#include "generic.h"
45 43
46 44
@@ -51,17 +49,33 @@ static void __init kb9202_init_early(void)
51 49
52 /* Initialize processor: 10 MHz crystal */ 50 /* Initialize processor: 10 MHz crystal */
53 at91_initialize(10000000); 51 at91_initialize(10000000);
52
53 /* Set up the LEDs */
54 at91_init_leds(AT91_PIN_PC19, AT91_PIN_PC18);
55
56 /* DBGU on ttyS0. (Rx & Tx only) */
57 at91_register_uart(0, 0, 0);
58
59 /* USART0 on ttyS1 (Rx & Tx only) */
60 at91_register_uart(AT91RM9200_ID_US0, 1, 0);
61
62 /* USART1 on ttyS2 (Rx & Tx only) - IRDA (optional) */
63 at91_register_uart(AT91RM9200_ID_US1, 2, 0);
64
65 /* USART3 on ttyS3 (Rx, Tx, CTS, RTS) - RS485 (optional) */
66 at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
67
68 /* set serial console to ttyS0 (ie, DBGU) */
69 at91_set_serial_console(0);
54} 70}
55 71
56static struct macb_platform_data __initdata kb9202_eth_data = { 72static struct at91_eth_data __initdata kb9202_eth_data = {
57 .phy_irq_pin = AT91_PIN_PB29, 73 .phy_irq_pin = AT91_PIN_PB29,
58 .is_rmii = 0, 74 .is_rmii = 0,
59}; 75};
60 76
61static struct at91_usbh_data __initdata kb9202_usbh_data = { 77static struct at91_usbh_data __initdata kb9202_usbh_data = {
62 .ports = 1, 78 .ports = 1,
63 .vbus_pin = {-EINVAL, -EINVAL},
64 .overcurrent_pin= {-EINVAL, -EINVAL},
65}; 79};
66 80
67static struct at91_udc_data __initdata kb9202_udc_data = { 81static struct at91_udc_data __initdata kb9202_udc_data = {
@@ -69,12 +83,10 @@ static struct at91_udc_data __initdata kb9202_udc_data = {
69 .pullup_pin = AT91_PIN_PB22, 83 .pullup_pin = AT91_PIN_PB22,
70}; 84};
71 85
72static struct mci_platform_data __initdata kb9202_mci0_data = { 86static struct at91_mmc_data __initdata kb9202_mmc_data = {
73 .slot[0] = { 87 .det_pin = AT91_PIN_PB2,
74 .bus_width = 4, 88 .slot_b = 0,
75 .detect_pin = AT91_PIN_PB2, 89 .wire4 = 1,
76 .wp_pin = -EINVAL,
77 },
78}; 90};
79 91
80static struct mtd_partition __initdata kb9202_nand_partition[] = { 92static struct mtd_partition __initdata kb9202_nand_partition[] = {
@@ -85,49 +97,24 @@ static struct mtd_partition __initdata kb9202_nand_partition[] = {
85 }, 97 },
86}; 98};
87 99
100static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
101{
102 *num_partitions = ARRAY_SIZE(kb9202_nand_partition);
103 return kb9202_nand_partition;
104}
105
88static struct atmel_nand_data __initdata kb9202_nand_data = { 106static struct atmel_nand_data __initdata kb9202_nand_data = {
89 .ale = 22, 107 .ale = 22,
90 .cle = 21, 108 .cle = 21,
91 .det_pin = -EINVAL, 109 // .det_pin = ... not there
92 .rdy_pin = AT91_PIN_PC29, 110 .rdy_pin = AT91_PIN_PC29,
93 .enable_pin = AT91_PIN_PC28, 111 .enable_pin = AT91_PIN_PC28,
94 .ecc_mode = NAND_ECC_SOFT, 112 .partition_info = nand_partitions,
95 .parts = kb9202_nand_partition,
96 .num_parts = ARRAY_SIZE(kb9202_nand_partition),
97};
98
99/*
100 * LEDs
101 */
102static struct gpio_led kb9202_leds[] = {
103 { /* D1 */
104 .name = "led1",
105 .gpio = AT91_PIN_PC19,
106 .active_low = 1,
107 .default_trigger = "heartbeat",
108 },
109 { /* D2 */
110 .name = "led2",
111 .gpio = AT91_PIN_PC18,
112 .active_low = 1,
113 .default_trigger = "timer",
114 }
115}; 113};
116 114
117static void __init kb9202_board_init(void) 115static void __init kb9202_board_init(void)
118{ 116{
119 /* Serial */ 117 /* Serial */
120 /* DBGU on ttyS0. (Rx & Tx only) */
121 at91_register_uart(0, 0, 0);
122
123 /* USART0 on ttyS1 (Rx & Tx only) */
124 at91_register_uart(AT91RM9200_ID_US0, 1, 0);
125
126 /* USART1 on ttyS2 (Rx & Tx only) - IRDA (optional) */
127 at91_register_uart(AT91RM9200_ID_US1, 2, 0);
128
129 /* USART3 on ttyS3 (Rx, Tx, CTS, RTS) - RS485 (optional) */
130 at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
131 at91_add_device_serial(); 118 at91_add_device_serial();
132 /* Ethernet */ 119 /* Ethernet */
133 at91_add_device_eth(&kb9202_eth_data); 120 at91_add_device_eth(&kb9202_eth_data);
@@ -136,22 +123,19 @@ static void __init kb9202_board_init(void)
136 /* USB Device */ 123 /* USB Device */
137 at91_add_device_udc(&kb9202_udc_data); 124 at91_add_device_udc(&kb9202_udc_data);
138 /* MMC */ 125 /* MMC */
139 at91_add_device_mci(0, &kb9202_mci0_data); 126 at91_add_device_mmc(0, &kb9202_mmc_data);
140 /* I2C */ 127 /* I2C */
141 at91_add_device_i2c(NULL, 0); 128 at91_add_device_i2c(NULL, 0);
142 /* SPI */ 129 /* SPI */
143 at91_add_device_spi(NULL, 0); 130 at91_add_device_spi(NULL, 0);
144 /* NAND */ 131 /* NAND */
145 at91_add_device_nand(&kb9202_nand_data); 132 at91_add_device_nand(&kb9202_nand_data);
146 /* LEDs */
147 at91_gpio_leds(kb9202_leds, ARRAY_SIZE(kb9202_leds));
148} 133}
149 134
150MACHINE_START(KB9200, "KB920x") 135MACHINE_START(KB9200, "KB920x")
151 /* Maintainer: KwikByte, Inc. */ 136 /* Maintainer: KwikByte, Inc. */
152 .timer = &at91rm9200_timer, 137 .timer = &at91rm9200_timer,
153 .map_io = at91_map_io, 138 .map_io = at91_map_io,
154 .handle_irq = at91_aic_handle_irq,
155 .init_early = kb9202_init_early, 139 .init_early = kb9202_init_early,
156 .init_irq = at91_init_irq_default, 140 .init_irq = at91_init_irq_default,
157 .init_machine = kb9202_board_init, 141 .init_machine = kb9202_board_init,
diff --git a/arch/arm/mach-at91/board-neocore926.c b/arch/arm/mach-at91/board-neocore926.c
index bc7a1c4a1f6..9bc6ab32e0a 100644
--- a/arch/arm/mach-at91/board-neocore926.c
+++ b/arch/arm/mach-at91/board-neocore926.c
@@ -21,7 +21,6 @@
21 */ 21 */
22 22
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/gpio.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/mm.h> 25#include <linux/mm.h>
27#include <linux/module.h> 26#include <linux/module.h>
@@ -44,10 +43,10 @@
44#include <asm/mach/irq.h> 43#include <asm/mach/irq.h>
45 44
46#include <mach/hardware.h> 45#include <mach/hardware.h>
46#include <mach/board.h>
47#include <mach/gpio.h>
47#include <mach/at91sam9_smc.h> 48#include <mach/at91sam9_smc.h>
48 49
49#include "at91_aic.h"
50#include "board.h"
51#include "sam9_smc.h" 50#include "sam9_smc.h"
52#include "generic.h" 51#include "generic.h"
53 52
@@ -56,6 +55,15 @@ static void __init neocore926_init_early(void)
56{ 55{
57 /* Initialize processor: 20 MHz crystal */ 56 /* Initialize processor: 20 MHz crystal */
58 at91_initialize(20000000); 57 at91_initialize(20000000);
58
59 /* DBGU on ttyS0. (Rx & Tx only) */
60 at91_register_uart(0, 0, 0);
61
62 /* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */
63 at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
64
65 /* set serial console to ttyS0 (ie, DBGU) */
66 at91_set_serial_console(0);
59} 67}
60 68
61/* 69/*
@@ -64,7 +72,6 @@ static void __init neocore926_init_early(void)
64static struct at91_usbh_data __initdata neocore926_usbh_data = { 72static struct at91_usbh_data __initdata neocore926_usbh_data = {
65 .ports = 2, 73 .ports = 2,
66 .vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 }, 74 .vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 },
67 .overcurrent_pin= {-EINVAL, -EINVAL},
68}; 75};
69 76
70/* 77/*
@@ -72,7 +79,7 @@ static struct at91_usbh_data __initdata neocore926_usbh_data = {
72 */ 79 */
73static struct at91_udc_data __initdata neocore926_udc_data = { 80static struct at91_udc_data __initdata neocore926_udc_data = {
74 .vbus_pin = AT91_PIN_PA25, 81 .vbus_pin = AT91_PIN_PA25,
75 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 82 .pullup_pin = 0, /* pull-up driven by UDC */
76}; 83};
77 84
78 85
@@ -129,7 +136,7 @@ static struct spi_board_info neocore926_spi_devices[] = {
129 .max_speed_hz = 125000 * 16, 136 .max_speed_hz = 125000 * 16,
130 .bus_num = 0, 137 .bus_num = 0,
131 .platform_data = &ads_info, 138 .platform_data = &ads_info,
132 .irq = NR_IRQS_LEGACY + AT91SAM9263_ID_IRQ1, 139 .irq = AT91SAM9263_ID_IRQ1,
133 }, 140 },
134#endif 141#endif
135}; 142};
@@ -138,19 +145,17 @@ static struct spi_board_info neocore926_spi_devices[] = {
138/* 145/*
139 * MCI (SD/MMC) 146 * MCI (SD/MMC)
140 */ 147 */
141static struct mci_platform_data __initdata neocore926_mci0_data = { 148static struct at91_mmc_data __initdata neocore926_mmc_data = {
142 .slot[0] = { 149 .wire4 = 1,
143 .bus_width = 4, 150 .det_pin = AT91_PIN_PE18,
144 .detect_pin = AT91_PIN_PE18, 151 .wp_pin = AT91_PIN_PE19,
145 .wp_pin = AT91_PIN_PE19,
146 },
147}; 152};
148 153
149 154
150/* 155/*
151 * MACB Ethernet device 156 * MACB Ethernet device
152 */ 157 */
153static struct macb_platform_data __initdata neocore926_macb_data = { 158static struct at91_eth_data __initdata neocore926_macb_data = {
154 .phy_irq_pin = AT91_PIN_PE31, 159 .phy_irq_pin = AT91_PIN_PE31,
155 .is_rmii = 1, 160 .is_rmii = 1,
156}; 161};
@@ -177,16 +182,19 @@ static struct mtd_partition __initdata neocore926_nand_partition[] = {
177 }, 182 },
178}; 183};
179 184
185static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
186{
187 *num_partitions = ARRAY_SIZE(neocore926_nand_partition);
188 return neocore926_nand_partition;
189}
190
180static struct atmel_nand_data __initdata neocore926_nand_data = { 191static struct atmel_nand_data __initdata neocore926_nand_data = {
181 .ale = 21, 192 .ale = 21,
182 .cle = 22, 193 .cle = 22,
183 .rdy_pin = AT91_PIN_PB19, 194 .rdy_pin = AT91_PIN_PB19,
184 .rdy_pin_active_low = 1, 195 .rdy_pin_active_low = 1,
185 .enable_pin = AT91_PIN_PD15, 196 .enable_pin = AT91_PIN_PD15,
186 .ecc_mode = NAND_ECC_SOFT, 197 .partition_info = nand_partitions,
187 .parts = neocore926_nand_partition,
188 .num_parts = ARRAY_SIZE(neocore926_nand_partition),
189 .det_pin = -EINVAL,
190}; 198};
191 199
192static struct sam9_smc_config __initdata neocore926_nand_smc_config = { 200static struct sam9_smc_config __initdata neocore926_nand_smc_config = {
@@ -210,7 +218,7 @@ static struct sam9_smc_config __initdata neocore926_nand_smc_config = {
210static void __init neocore926_add_device_nand(void) 218static void __init neocore926_add_device_nand(void)
211{ 219{
212 /* configure chip-select 3 (NAND) */ 220 /* configure chip-select 3 (NAND) */
213 sam9_smc_configure(0, 3, &neocore926_nand_smc_config); 221 sam9_smc_configure(3, &neocore926_nand_smc_config);
214 222
215 at91_add_device_nand(&neocore926_nand_data); 223 at91_add_device_nand(&neocore926_nand_data);
216} 224}
@@ -334,11 +342,6 @@ static struct ac97c_platform_data neocore926_ac97_data = {
334static void __init neocore926_board_init(void) 342static void __init neocore926_board_init(void)
335{ 343{
336 /* Serial */ 344 /* Serial */
337 /* DBGU on ttyS0. (Rx & Tx only) */
338 at91_register_uart(0, 0, 0);
339
340 /* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */
341 at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
342 at91_add_device_serial(); 345 at91_add_device_serial();
343 346
344 /* USB Host */ 347 /* USB Host */
@@ -355,7 +358,7 @@ static void __init neocore926_board_init(void)
355 neocore926_add_device_ts(); 358 neocore926_add_device_ts();
356 359
357 /* MMC */ 360 /* MMC */
358 at91_add_device_mci(0, &neocore926_mci0_data); 361 at91_add_device_mmc(1, &neocore926_mmc_data);
359 362
360 /* Ethernet */ 363 /* Ethernet */
361 at91_add_device_eth(&neocore926_macb_data); 364 at91_add_device_eth(&neocore926_macb_data);
@@ -380,7 +383,6 @@ MACHINE_START(NEOCORE926, "ADENEO NEOCORE 926")
380 /* Maintainer: ADENEO */ 383 /* Maintainer: ADENEO */
381 .timer = &at91sam926x_timer, 384 .timer = &at91sam926x_timer,
382 .map_io = at91_map_io, 385 .map_io = at91_map_io,
383 .handle_irq = at91_aic_handle_irq,
384 .init_early = neocore926_init_early, 386 .init_early = neocore926_init_early,
385 .init_irq = at91_init_irq_default, 387 .init_irq = at91_init_irq_default,
386 .init_machine = neocore926_board_init, 388 .init_machine = neocore926_board_init,
diff --git a/arch/arm/mach-at91/board-pcontrol-g20.c b/arch/arm/mach-at91/board-pcontrol-g20.c
index 0299554495d..49e3f699b48 100644
--- a/arch/arm/mach-at91/board-pcontrol-g20.c
+++ b/arch/arm/mach-at91/board-pcontrol-g20.c
@@ -29,18 +29,28 @@
29#include <asm/mach-types.h> 29#include <asm/mach-types.h>
30#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
31 31
32#include <mach/board.h>
32#include <mach/at91sam9_smc.h> 33#include <mach/at91sam9_smc.h>
34#include <mach/stamp9g20.h>
33 35
34#include "at91_aic.h"
35#include "board.h"
36#include "sam9_smc.h" 36#include "sam9_smc.h"
37#include "generic.h" 37#include "generic.h"
38#include "stamp9g20.h"
39 38
40 39
41static void __init pcontrol_g20_init_early(void) 40static void __init pcontrol_g20_init_early(void)
42{ 41{
43 stamp9g20_init_early(); 42 stamp9g20_init_early();
43
44 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) piggyback A2 */
45 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS
46 | ATMEL_UART_RTS);
47
48 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) isolated RS485 X5 */
49 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS
50 | ATMEL_UART_RTS);
51
52 /* USART2 on ttyS3. (Rx, Tx) 9bit-Bus Multidrop-mode X4 */
53 at91_register_uart(AT91SAM9260_ID_US4, 3, 0);
44} 54}
45 55
46static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { { 56static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { {
@@ -86,9 +96,9 @@ static struct sam9_smc_config __initdata pcontrol_smc_config[2] = { {
86static void __init add_device_pcontrol(void) 96static void __init add_device_pcontrol(void)
87{ 97{
88 /* configure chip-select 4 (IO compatible to 8051 X4 ) */ 98 /* configure chip-select 4 (IO compatible to 8051 X4 ) */
89 sam9_smc_configure(0, 4, &pcontrol_smc_config[0]); 99 sam9_smc_configure(4, &pcontrol_smc_config[0]);
90 /* configure chip-select 7 (FerroRAM 256KiBx16bit MR2A16A D4 ) */ 100 /* configure chip-select 7 (FerroRAM 256KiBx16bit MR2A16A D4 ) */
91 sam9_smc_configure(0, 7, &pcontrol_smc_config[1]); 101 sam9_smc_configure(7, &pcontrol_smc_config[1]);
92} 102}
93 103
94 104
@@ -97,8 +107,6 @@ static void __init add_device_pcontrol(void)
97 */ 107 */
98static struct at91_usbh_data __initdata usbh_data = { 108static struct at91_usbh_data __initdata usbh_data = {
99 .ports = 2, 109 .ports = 2,
100 .vbus_pin = {-EINVAL, -EINVAL},
101 .overcurrent_pin= {-EINVAL, -EINVAL},
102}; 110};
103 111
104 112
@@ -114,7 +122,7 @@ static struct at91_udc_data __initdata pcontrol_g20_udc_data = {
114/* 122/*
115 * MACB Ethernet device 123 * MACB Ethernet device
116 */ 124 */
117static struct macb_platform_data __initdata macb_data = { 125static struct at91_eth_data __initdata macb_data = {
118 .phy_irq_pin = AT91_PIN_PA28, 126 .phy_irq_pin = AT91_PIN_PA28,
119 .is_rmii = 1, 127 .is_rmii = 1,
120}; 128};
@@ -189,16 +197,6 @@ static struct spi_board_info pcontrol_g20_spi_devices[] = {
189 197
190static void __init pcontrol_g20_board_init(void) 198static void __init pcontrol_g20_board_init(void)
191{ 199{
192 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) piggyback A2 */
193 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS
194 | ATMEL_UART_RTS);
195
196 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) isolated RS485 X5 */
197 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS
198 | ATMEL_UART_RTS);
199
200 /* USART2 on ttyS3. (Rx, Tx) 9bit-Bus Multidrop-mode X4 */
201 at91_register_uart(AT91SAM9260_ID_US4, 3, 0);
202 stamp9g20_board_init(); 200 stamp9g20_board_init();
203 at91_add_device_usbh(&usbh_data); 201 at91_add_device_usbh(&usbh_data);
204 at91_add_device_eth(&macb_data); 202 at91_add_device_eth(&macb_data);
@@ -219,7 +217,6 @@ MACHINE_START(PCONTROL_G20, "PControl G20")
219 /* Maintainer: pgsellmann@portner-elektronik.at */ 217 /* Maintainer: pgsellmann@portner-elektronik.at */
220 .timer = &at91sam926x_timer, 218 .timer = &at91sam926x_timer,
221 .map_io = at91_map_io, 219 .map_io = at91_map_io,
222 .handle_irq = at91_aic_handle_irq,
223 .init_early = pcontrol_g20_init_early, 220 .init_early = pcontrol_g20_init_early,
224 .init_irq = at91_init_irq_default, 221 .init_irq = at91_init_irq_default,
225 .init_machine = pcontrol_g20_board_init, 222 .init_machine = pcontrol_g20_board_init,
diff --git a/arch/arm/mach-at91/board-picotux200.c b/arch/arm/mach-at91/board-picotux200.c
index 4938f1cd5e1..b7b8390e8a0 100644
--- a/arch/arm/mach-at91/board-picotux200.c
+++ b/arch/arm/mach-at91/board-picotux200.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/gpio.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/mm.h> 24#include <linux/mm.h>
26#include <linux/module.h> 25#include <linux/module.h>
@@ -37,11 +36,10 @@
37#include <asm/mach/map.h> 36#include <asm/mach/map.h>
38#include <asm/mach/irq.h> 37#include <asm/mach/irq.h>
39 38
39#include <mach/board.h>
40#include <mach/gpio.h>
40#include <mach/at91rm9200_mc.h> 41#include <mach/at91rm9200_mc.h>
41#include <mach/at91_ramc.h>
42 42
43#include "at91_aic.h"
44#include "board.h"
45#include "generic.h" 43#include "generic.h"
46 44
47 45
@@ -49,25 +47,33 @@ static void __init picotux200_init_early(void)
49{ 47{
50 /* Initialize processor: 18.432 MHz crystal */ 48 /* Initialize processor: 18.432 MHz crystal */
51 at91_initialize(18432000); 49 at91_initialize(18432000);
50
51 /* DBGU on ttyS0. (Rx & Tx only) */
52 at91_register_uart(0, 0, 0);
53
54 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
55 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
56 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
57 | ATMEL_UART_RI);
58
59 /* set serial console to ttyS0 (ie, DBGU) */
60 at91_set_serial_console(0);
52} 61}
53 62
54static struct macb_platform_data __initdata picotux200_eth_data = { 63static struct at91_eth_data __initdata picotux200_eth_data = {
55 .phy_irq_pin = AT91_PIN_PC4, 64 .phy_irq_pin = AT91_PIN_PC4,
56 .is_rmii = 1, 65 .is_rmii = 1,
57}; 66};
58 67
59static struct at91_usbh_data __initdata picotux200_usbh_data = { 68static struct at91_usbh_data __initdata picotux200_usbh_data = {
60 .ports = 1, 69 .ports = 1,
61 .vbus_pin = {-EINVAL, -EINVAL},
62 .overcurrent_pin= {-EINVAL, -EINVAL},
63}; 70};
64 71
65static struct mci_platform_data __initdata picotux200_mci0_data = { 72static struct at91_mmc_data __initdata picotux200_mmc_data = {
66 .slot[0] = { 73 .det_pin = AT91_PIN_PB27,
67 .bus_width = 4, 74 .slot_b = 0,
68 .detect_pin = AT91_PIN_PB27, 75 .wire4 = 1,
69 .wp_pin = AT91_PIN_PA17, 76 .wp_pin = AT91_PIN_PA17,
70 },
71}; 77};
72 78
73#define PICOTUX200_FLASH_BASE AT91_CHIPSELECT_0 79#define PICOTUX200_FLASH_BASE AT91_CHIPSELECT_0
@@ -96,13 +102,6 @@ static struct platform_device picotux200_flash = {
96static void __init picotux200_board_init(void) 102static void __init picotux200_board_init(void)
97{ 103{
98 /* Serial */ 104 /* Serial */
99 /* DBGU on ttyS0. (Rx & Tx only) */
100 at91_register_uart(0, 0, 0);
101
102 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
103 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
104 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
105 | ATMEL_UART_RI);
106 at91_add_device_serial(); 105 at91_add_device_serial();
107 /* Ethernet */ 106 /* Ethernet */
108 at91_add_device_eth(&picotux200_eth_data); 107 at91_add_device_eth(&picotux200_eth_data);
@@ -112,7 +111,7 @@ static void __init picotux200_board_init(void)
112 at91_add_device_i2c(NULL, 0); 111 at91_add_device_i2c(NULL, 0);
113 /* MMC */ 112 /* MMC */
114 at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */ 113 at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
115 at91_add_device_mci(0, &picotux200_mci0_data); 114 at91_add_device_mmc(0, &picotux200_mmc_data);
116 /* NOR Flash */ 115 /* NOR Flash */
117 platform_device_register(&picotux200_flash); 116 platform_device_register(&picotux200_flash);
118} 117}
@@ -121,7 +120,6 @@ MACHINE_START(PICOTUX2XX, "picotux 200")
121 /* Maintainer: Kleinhenz Elektronik GmbH */ 120 /* Maintainer: Kleinhenz Elektronik GmbH */
122 .timer = &at91rm9200_timer, 121 .timer = &at91rm9200_timer,
123 .map_io = at91_map_io, 122 .map_io = at91_map_io,
124 .handle_irq = at91_aic_handle_irq,
125 .init_early = picotux200_init_early, 123 .init_early = picotux200_init_early,
126 .init_irq = at91_init_irq_default, 124 .init_irq = at91_init_irq_default,
127 .init_machine = picotux200_board_init, 125 .init_machine = picotux200_board_init,
diff --git a/arch/arm/mach-at91/board-qil-a9260.c b/arch/arm/mach-at91/board-qil-a9260.c
index 33b1628467e..81f91103368 100644
--- a/arch/arm/mach-at91/board-qil-a9260.c
+++ b/arch/arm/mach-at91/board-qil-a9260.c
@@ -21,7 +21,6 @@
21 */ 21 */
22 22
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/gpio.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/mm.h> 25#include <linux/mm.h>
27#include <linux/module.h> 26#include <linux/module.h>
@@ -40,11 +39,11 @@
40#include <asm/mach/irq.h> 39#include <asm/mach/irq.h>
41 40
42#include <mach/hardware.h> 41#include <mach/hardware.h>
42#include <mach/board.h>
43#include <mach/gpio.h>
43#include <mach/at91sam9_smc.h> 44#include <mach/at91sam9_smc.h>
45#include <mach/at91_shdwc.h>
44 46
45#include "at91_aic.h"
46#include "at91_shdwc.h"
47#include "board.h"
48#include "sam9_smc.h" 47#include "sam9_smc.h"
49#include "generic.h" 48#include "generic.h"
50 49
@@ -53,6 +52,24 @@ static void __init ek_init_early(void)
53{ 52{
54 /* Initialize processor: 12.000 MHz crystal */ 53 /* Initialize processor: 12.000 MHz crystal */
55 at91_initialize(12000000); 54 at91_initialize(12000000);
55
56 /* DBGU on ttyS0. (Rx & Tx only) */
57 at91_register_uart(0, 0, 0);
58
59 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
60 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
61 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
62 | ATMEL_UART_RI);
63
64 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
65 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
66
67 /* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */
68 at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
69
70 /* set serial console to ttyS1 (ie, USART0) */
71 at91_set_serial_console(1);
72
56} 73}
57 74
58/* 75/*
@@ -60,8 +77,6 @@ static void __init ek_init_early(void)
60 */ 77 */
61static struct at91_usbh_data __initdata ek_usbh_data = { 78static struct at91_usbh_data __initdata ek_usbh_data = {
62 .ports = 2, 79 .ports = 2,
63 .vbus_pin = {-EINVAL, -EINVAL},
64 .overcurrent_pin= {-EINVAL, -EINVAL},
65}; 80};
66 81
67/* 82/*
@@ -69,7 +84,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {
69 */ 84 */
70static struct at91_udc_data __initdata ek_udc_data = { 85static struct at91_udc_data __initdata ek_udc_data = {
71 .vbus_pin = AT91_PIN_PC5, 86 .vbus_pin = AT91_PIN_PC5,
72 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 87 .pullup_pin = 0, /* pull-up driven by UDC */
73}; 88};
74 89
75/* 90/*
@@ -89,7 +104,7 @@ static struct spi_board_info ek_spi_devices[] = {
89/* 104/*
90 * MACB Ethernet device 105 * MACB Ethernet device
91 */ 106 */
92static struct macb_platform_data __initdata ek_macb_data = { 107static struct at91_eth_data __initdata ek_macb_data = {
93 .phy_irq_pin = AT91_PIN_PA31, 108 .phy_irq_pin = AT91_PIN_PA31,
94 .is_rmii = 1, 109 .is_rmii = 1,
95}; 110};
@@ -115,16 +130,19 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
115 }, 130 },
116}; 131};
117 132
133static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
134{
135 *num_partitions = ARRAY_SIZE(ek_nand_partition);
136 return ek_nand_partition;
137}
138
118static struct atmel_nand_data __initdata ek_nand_data = { 139static struct atmel_nand_data __initdata ek_nand_data = {
119 .ale = 21, 140 .ale = 21,
120 .cle = 22, 141 .cle = 22,
121 .det_pin = -EINVAL, 142// .det_pin = ... not connected
122 .rdy_pin = AT91_PIN_PC13, 143 .rdy_pin = AT91_PIN_PC13,
123 .enable_pin = AT91_PIN_PC14, 144 .enable_pin = AT91_PIN_PC14,
124 .ecc_mode = NAND_ECC_SOFT, 145 .partition_info = nand_partitions,
125 .on_flash_bbt = 1,
126 .parts = ek_nand_partition,
127 .num_parts = ARRAY_SIZE(ek_nand_partition),
128}; 146};
129 147
130static struct sam9_smc_config __initdata ek_nand_smc_config = { 148static struct sam9_smc_config __initdata ek_nand_smc_config = {
@@ -148,7 +166,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {
148static void __init ek_add_device_nand(void) 166static void __init ek_add_device_nand(void)
149{ 167{
150 /* configure chip-select 3 (NAND) */ 168 /* configure chip-select 3 (NAND) */
151 sam9_smc_configure(0, 3, &ek_nand_smc_config); 169 sam9_smc_configure(3, &ek_nand_smc_config);
152 170
153 at91_add_device_nand(&ek_nand_data); 171 at91_add_device_nand(&ek_nand_data);
154} 172}
@@ -156,12 +174,12 @@ static void __init ek_add_device_nand(void)
156/* 174/*
157 * MCI (SD/MMC) 175 * MCI (SD/MMC)
158 */ 176 */
159static struct mci_platform_data __initdata ek_mci0_data = { 177static struct at91_mmc_data __initdata ek_mmc_data = {
160 .slot[0] = { 178 .slot_b = 0,
161 .bus_width = 4, 179 .wire4 = 1,
162 .detect_pin = -EINVAL, 180// .det_pin = ... not connected
163 .wp_pin = -EINVAL, 181// .wp_pin = ... not connected
164 }, 182// .vcc_pin = ... not connected
165}; 183};
166 184
167/* 185/*
@@ -218,19 +236,6 @@ static struct gpio_led ek_leds[] = {
218static void __init ek_board_init(void) 236static void __init ek_board_init(void)
219{ 237{
220 /* Serial */ 238 /* Serial */
221 /* DBGU on ttyS0. (Rx & Tx only) */
222 at91_register_uart(0, 0, 0);
223
224 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
225 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
226 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
227 | ATMEL_UART_RI);
228
229 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
230 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
231
232 /* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */
233 at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
234 at91_add_device_serial(); 239 at91_add_device_serial();
235 /* USB Host */ 240 /* USB Host */
236 at91_add_device_usbh(&ek_usbh_data); 241 at91_add_device_usbh(&ek_usbh_data);
@@ -245,13 +250,13 @@ static void __init ek_board_init(void)
245 /* Ethernet */ 250 /* Ethernet */
246 at91_add_device_eth(&ek_macb_data); 251 at91_add_device_eth(&ek_macb_data);
247 /* MMC */ 252 /* MMC */
248 at91_add_device_mci(0, &ek_mci0_data); 253 at91_add_device_mmc(0, &ek_mmc_data);
249 /* Push Buttons */ 254 /* Push Buttons */
250 ek_add_device_buttons(); 255 ek_add_device_buttons();
251 /* LEDs */ 256 /* LEDs */
252 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); 257 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
253 /* shutdown controller, wakeup button (5 msec low) */ 258 /* shutdown controller, wakeup button (5 msec low) */
254 at91_shdwc_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW 259 at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
255 | AT91_SHDW_RTTWKEN); 260 | AT91_SHDW_RTTWKEN);
256} 261}
257 262
@@ -259,7 +264,6 @@ MACHINE_START(QIL_A9260, "CALAO QIL_A9260")
259 /* Maintainer: calao-systems */ 264 /* Maintainer: calao-systems */
260 .timer = &at91sam926x_timer, 265 .timer = &at91sam926x_timer,
261 .map_io = at91_map_io, 266 .map_io = at91_map_io,
262 .handle_irq = at91_aic_handle_irq,
263 .init_early = ek_init_early, 267 .init_early = ek_init_early,
264 .init_irq = at91_init_irq_default, 268 .init_irq = at91_init_irq_default,
265 .init_machine = ek_board_init, 269 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-rm9200-dt.c b/arch/arm/mach-at91/board-rm9200-dt.c
deleted file mode 100644
index 5f9ce3da3fd..00000000000
--- a/arch/arm/mach-at91/board-rm9200-dt.c
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * Setup code for AT91RM9200 Evaluation Kits with Device Tree support
3 *
4 * Copyright (C) 2011 Atmel,
5 * 2011 Nicolas Ferre <nicolas.ferre@atmel.com>
6 * 2012 Joachim Eastwood <manabian@gmail.com>
7 *
8 * Licensed under GPLv2 or later.
9 */
10
11#include <linux/types.h>
12#include <linux/init.h>
13#include <linux/module.h>
14#include <linux/gpio.h>
15#include <linux/of.h>
16#include <linux/of_irq.h>
17#include <linux/of_platform.h>
18
19#include <asm/setup.h>
20#include <asm/irq.h>
21#include <asm/mach/arch.h>
22#include <asm/mach/map.h>
23#include <asm/mach/irq.h>
24
25#include "at91_aic.h"
26#include "generic.h"
27
28
29static const struct of_device_id irq_of_match[] __initconst = {
30 { .compatible = "atmel,at91rm9200-aic", .data = at91_aic_of_init },
31 { /*sentinel*/ }
32};
33
34static void __init at91rm9200_dt_init_irq(void)
35{
36 of_irq_init(irq_of_match);
37}
38
39static void __init at91rm9200_dt_device_init(void)
40{
41 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
42}
43
44static const char *at91rm9200_dt_board_compat[] __initdata = {
45 "atmel,at91rm9200",
46 NULL
47};
48
49DT_MACHINE_START(at91rm9200_dt, "Atmel AT91RM9200 (Device Tree)")
50 .timer = &at91rm9200_timer,
51 .map_io = at91_map_io,
52 .handle_irq = at91_aic_handle_irq,
53 .init_early = at91rm9200_dt_initialize,
54 .init_irq = at91rm9200_dt_init_irq,
55 .init_machine = at91rm9200_dt_device_init,
56 .dt_compat = at91rm9200_dt_board_compat,
57MACHINE_END
diff --git a/arch/arm/mach-at91/board-rm9200dk.c b/arch/arm/mach-at91/board-rm9200dk.c
index 9e5061bef0d..6f08faadb47 100644
--- a/arch/arm/mach-at91/board-rm9200dk.c
+++ b/arch/arm/mach-at91/board-rm9200dk.c
@@ -22,7 +22,6 @@
22 */ 22 */
23 23
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/gpio.h>
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/mm.h> 26#include <linux/mm.h>
28#include <linux/module.h> 27#include <linux/module.h>
@@ -39,11 +38,10 @@
39#include <asm/mach/irq.h> 38#include <asm/mach/irq.h>
40 39
41#include <mach/hardware.h> 40#include <mach/hardware.h>
41#include <mach/board.h>
42#include <mach/gpio.h>
42#include <mach/at91rm9200_mc.h> 43#include <mach/at91rm9200_mc.h>
43#include <mach/at91_ramc.h>
44 44
45#include "at91_aic.h"
46#include "board.h"
47#include "generic.h" 45#include "generic.h"
48 46
49 47
@@ -51,17 +49,29 @@ static void __init dk_init_early(void)
51{ 49{
52 /* Initialize processor: 18.432 MHz crystal */ 50 /* Initialize processor: 18.432 MHz crystal */
53 at91_initialize(18432000); 51 at91_initialize(18432000);
52
53 /* Setup the LEDs */
54 at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
55
56 /* DBGU on ttyS0. (Rx & Tx only) */
57 at91_register_uart(0, 0, 0);
58
59 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
60 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
61 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
62 | ATMEL_UART_RI);
63
64 /* set serial console to ttyS0 (ie, DBGU) */
65 at91_set_serial_console(0);
54} 66}
55 67
56static struct macb_platform_data __initdata dk_eth_data = { 68static struct at91_eth_data __initdata dk_eth_data = {
57 .phy_irq_pin = AT91_PIN_PC4, 69 .phy_irq_pin = AT91_PIN_PC4,
58 .is_rmii = 1, 70 .is_rmii = 1,
59}; 71};
60 72
61static struct at91_usbh_data __initdata dk_usbh_data = { 73static struct at91_usbh_data __initdata dk_usbh_data = {
62 .ports = 2, 74 .ports = 2,
63 .vbus_pin = {-EINVAL, -EINVAL},
64 .overcurrent_pin= {-EINVAL, -EINVAL},
65}; 75};
66 76
67static struct at91_udc_data __initdata dk_udc_data = { 77static struct at91_udc_data __initdata dk_udc_data = {
@@ -70,19 +80,16 @@ static struct at91_udc_data __initdata dk_udc_data = {
70}; 80};
71 81
72static struct at91_cf_data __initdata dk_cf_data = { 82static struct at91_cf_data __initdata dk_cf_data = {
73 .irq_pin = -EINVAL,
74 .det_pin = AT91_PIN_PB0, 83 .det_pin = AT91_PIN_PB0,
75 .vcc_pin = -EINVAL,
76 .rst_pin = AT91_PIN_PC5, 84 .rst_pin = AT91_PIN_PC5,
85 // .irq_pin = ... not connected
86 // .vcc_pin = ... always powered
77}; 87};
78 88
79#ifndef CONFIG_MTD_AT91_DATAFLASH_CARD 89#ifndef CONFIG_MTD_AT91_DATAFLASH_CARD
80static struct mci_platform_data __initdata dk_mci0_data = { 90static struct at91_mmc_data __initdata dk_mmc_data = {
81 .slot[0] = { 91 .slot_b = 0,
82 .bus_width = 4, 92 .wire4 = 1,
83 .detect_pin = -EINVAL,
84 .wp_pin = -EINVAL,
85 },
86}; 93};
87#endif 94#endif
88 95
@@ -131,16 +138,19 @@ static struct mtd_partition __initdata dk_nand_partition[] = {
131 }, 138 },
132}; 139};
133 140
141static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
142{
143 *num_partitions = ARRAY_SIZE(dk_nand_partition);
144 return dk_nand_partition;
145}
146
134static struct atmel_nand_data __initdata dk_nand_data = { 147static struct atmel_nand_data __initdata dk_nand_data = {
135 .ale = 22, 148 .ale = 22,
136 .cle = 21, 149 .cle = 21,
137 .det_pin = AT91_PIN_PB1, 150 .det_pin = AT91_PIN_PB1,
138 .rdy_pin = AT91_PIN_PC2, 151 .rdy_pin = AT91_PIN_PC2,
139 .enable_pin = -EINVAL, 152 // .enable_pin = ... not there
140 .ecc_mode = NAND_ECC_SOFT, 153 .partition_info = nand_partitions,
141 .on_flash_bbt = 1,
142 .parts = dk_nand_partition,
143 .num_parts = ARRAY_SIZE(dk_nand_partition),
144}; 154};
145 155
146#define DK_FLASH_BASE AT91_CHIPSELECT_0 156#define DK_FLASH_BASE AT91_CHIPSELECT_0
@@ -178,13 +188,6 @@ static struct gpio_led dk_leds[] = {
178static void __init dk_board_init(void) 188static void __init dk_board_init(void)
179{ 189{
180 /* Serial */ 190 /* Serial */
181 /* DBGU on ttyS0. (Rx & Tx only) */
182 at91_register_uart(0, 0, 0);
183
184 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
185 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
186 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
187 | ATMEL_UART_RI);
188 at91_add_device_serial(); 191 at91_add_device_serial();
189 /* Ethernet */ 192 /* Ethernet */
190 at91_add_device_eth(&dk_eth_data); 193 at91_add_device_eth(&dk_eth_data);
@@ -205,7 +208,7 @@ static void __init dk_board_init(void)
205#else 208#else
206 /* MMC */ 209 /* MMC */
207 at91_set_gpio_output(AT91_PIN_PB7, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */ 210 at91_set_gpio_output(AT91_PIN_PB7, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
208 at91_add_device_mci(0, &dk_mci0_data); 211 at91_add_device_mmc(0, &dk_mmc_data);
209#endif 212#endif
210 /* NAND */ 213 /* NAND */
211 at91_add_device_nand(&dk_nand_data); 214 at91_add_device_nand(&dk_nand_data);
@@ -221,7 +224,6 @@ MACHINE_START(AT91RM9200DK, "Atmel AT91RM9200-DK")
221 /* Maintainer: SAN People/Atmel */ 224 /* Maintainer: SAN People/Atmel */
222 .timer = &at91rm9200_timer, 225 .timer = &at91rm9200_timer,
223 .map_io = at91_map_io, 226 .map_io = at91_map_io,
224 .handle_irq = at91_aic_handle_irq,
225 .init_early = dk_init_early, 227 .init_early = dk_init_early,
226 .init_irq = at91_init_irq_default, 228 .init_irq = at91_init_irq_default,
227 .init_machine = dk_board_init, 229 .init_machine = dk_board_init,
diff --git a/arch/arm/mach-at91/board-rm9200ek.c b/arch/arm/mach-at91/board-rm9200ek.c
index 58277dbc718..85bcccd7b9e 100644
--- a/arch/arm/mach-at91/board-rm9200ek.c
+++ b/arch/arm/mach-at91/board-rm9200ek.c
@@ -22,7 +22,6 @@
22 */ 22 */
23 23
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/gpio.h>
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/mm.h> 26#include <linux/mm.h>
28#include <linux/module.h> 27#include <linux/module.h>
@@ -39,11 +38,10 @@
39#include <asm/mach/irq.h> 38#include <asm/mach/irq.h>
40 39
41#include <mach/hardware.h> 40#include <mach/hardware.h>
41#include <mach/board.h>
42#include <mach/gpio.h>
42#include <mach/at91rm9200_mc.h> 43#include <mach/at91rm9200_mc.h>
43#include <mach/at91_ramc.h>
44 44
45#include "at91_aic.h"
46#include "board.h"
47#include "generic.h" 45#include "generic.h"
48 46
49 47
@@ -51,17 +49,29 @@ static void __init ek_init_early(void)
51{ 49{
52 /* Initialize processor: 18.432 MHz crystal */ 50 /* Initialize processor: 18.432 MHz crystal */
53 at91_initialize(18432000); 51 at91_initialize(18432000);
52
53 /* Setup the LEDs */
54 at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2);
55
56 /* DBGU on ttyS0. (Rx & Tx only) */
57 at91_register_uart(0, 0, 0);
58
59 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
60 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
61 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
62 | ATMEL_UART_RI);
63
64 /* set serial console to ttyS0 (ie, DBGU) */
65 at91_set_serial_console(0);
54} 66}
55 67
56static struct macb_platform_data __initdata ek_eth_data = { 68static struct at91_eth_data __initdata ek_eth_data = {
57 .phy_irq_pin = AT91_PIN_PC4, 69 .phy_irq_pin = AT91_PIN_PC4,
58 .is_rmii = 1, 70 .is_rmii = 1,
59}; 71};
60 72
61static struct at91_usbh_data __initdata ek_usbh_data = { 73static struct at91_usbh_data __initdata ek_usbh_data = {
62 .ports = 2, 74 .ports = 2,
63 .vbus_pin = {-EINVAL, -EINVAL},
64 .overcurrent_pin= {-EINVAL, -EINVAL},
65}; 75};
66 76
67static struct at91_udc_data __initdata ek_udc_data = { 77static struct at91_udc_data __initdata ek_udc_data = {
@@ -70,12 +80,11 @@ static struct at91_udc_data __initdata ek_udc_data = {
70}; 80};
71 81
72#ifndef CONFIG_MTD_AT91_DATAFLASH_CARD 82#ifndef CONFIG_MTD_AT91_DATAFLASH_CARD
73static struct mci_platform_data __initdata ek_mci0_data = { 83static struct at91_mmc_data __initdata ek_mmc_data = {
74 .slot[0] = { 84 .det_pin = AT91_PIN_PB27,
75 .bus_width = 4, 85 .slot_b = 0,
76 .detect_pin = AT91_PIN_PB27, 86 .wire4 = 1,
77 .wp_pin = AT91_PIN_PA17, 87 .wp_pin = AT91_PIN_PA17,
78 }
79}; 88};
80#endif 89#endif
81 90
@@ -104,7 +113,7 @@ static struct i2c_board_info __initdata ek_i2c_devices[] = {
104}; 113};
105 114
106#define EK_FLASH_BASE AT91_CHIPSELECT_0 115#define EK_FLASH_BASE AT91_CHIPSELECT_0
107#define EK_FLASH_SIZE SZ_8M 116#define EK_FLASH_SIZE SZ_2M
108 117
109static struct physmap_flash_data ek_flash_data = { 118static struct physmap_flash_data ek_flash_data = {
110 .width = 2, 119 .width = 2,
@@ -149,13 +158,6 @@ static struct gpio_led ek_leds[] = {
149static void __init ek_board_init(void) 158static void __init ek_board_init(void)
150{ 159{
151 /* Serial */ 160 /* Serial */
152 /* DBGU on ttyS0. (Rx & Tx only) */
153 at91_register_uart(0, 0, 0);
154
155 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
156 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
157 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
158 | ATMEL_UART_RI);
159 at91_add_device_serial(); 161 at91_add_device_serial();
160 /* Ethernet */ 162 /* Ethernet */
161 at91_add_device_eth(&ek_eth_data); 163 at91_add_device_eth(&ek_eth_data);
@@ -174,7 +176,7 @@ static void __init ek_board_init(void)
174#else 176#else
175 /* MMC */ 177 /* MMC */
176 at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */ 178 at91_set_gpio_output(AT91_PIN_PB22, 1); /* this MMC card slot can optionally use SPI signaling (CS3). */
177 at91_add_device_mci(0, &ek_mci0_data); 179 at91_add_device_mmc(0, &ek_mmc_data);
178#endif 180#endif
179 /* NOR Flash */ 181 /* NOR Flash */
180 platform_device_register(&ek_flash); 182 platform_device_register(&ek_flash);
@@ -188,7 +190,6 @@ MACHINE_START(AT91RM9200EK, "Atmel AT91RM9200-EK")
188 /* Maintainer: SAN People/Atmel */ 190 /* Maintainer: SAN People/Atmel */
189 .timer = &at91rm9200_timer, 191 .timer = &at91rm9200_timer,
190 .map_io = at91_map_io, 192 .map_io = at91_map_io,
191 .handle_irq = at91_aic_handle_irq,
192 .init_early = ek_init_early, 193 .init_early = ek_init_early,
193 .init_irq = at91_init_irq_default, 194 .init_irq = at91_init_irq_default,
194 .init_machine = ek_board_init, 195 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-rsi-ews.c b/arch/arm/mach-at91/board-rsi-ews.c
deleted file mode 100644
index 2e8b8339a20..00000000000
--- a/arch/arm/mach-at91/board-rsi-ews.c
+++ /dev/null
@@ -1,231 +0,0 @@
1/*
2 * board-rsi-ews.c
3 *
4 * Copyright (C)
5 * 2005 SAN People,
6 * 2008-2011 R-S-I Elektrotechnik GmbH & Co. KG
7 *
8 * Licensed under GPLv2 or later.
9 */
10
11#include <linux/types.h>
12#include <linux/init.h>
13#include <linux/mm.h>
14#include <linux/module.h>
15#include <linux/platform_device.h>
16#include <linux/spi/spi.h>
17#include <linux/mtd/physmap.h>
18
19#include <asm/setup.h>
20#include <asm/mach-types.h>
21#include <asm/irq.h>
22
23#include <asm/mach/arch.h>
24#include <asm/mach/map.h>
25#include <asm/mach/irq.h>
26
27#include <mach/hardware.h>
28
29#include <linux/gpio.h>
30
31#include "at91_aic.h"
32#include "board.h"
33#include "generic.h"
34
35static void __init rsi_ews_init_early(void)
36{
37 /* Initialize processor: 18.432 MHz crystal */
38 at91_initialize(18432000);
39}
40
41/*
42 * Ethernet
43 */
44static struct macb_platform_data rsi_ews_eth_data __initdata = {
45 .phy_irq_pin = AT91_PIN_PC4,
46 .is_rmii = 1,
47};
48
49/*
50 * USB Host
51 */
52static struct at91_usbh_data rsi_ews_usbh_data __initdata = {
53 .ports = 1,
54 .vbus_pin = {-EINVAL, -EINVAL},
55 .overcurrent_pin= {-EINVAL, -EINVAL},
56};
57
58/*
59 * SD/MC
60 */
61static struct mci_platform_data __initdata rsi_ews_mci0_data = {
62 .slot[0] = {
63 .bus_width = 4,
64 .detect_pin = AT91_PIN_PB27,
65 .wp_pin = AT91_PIN_PB29,
66 },
67};
68
69/*
70 * I2C
71 */
72static struct i2c_board_info rsi_ews_i2c_devices[] __initdata = {
73 {
74 I2C_BOARD_INFO("ds1337", 0x68),
75 },
76 {
77 I2C_BOARD_INFO("24c01", 0x50),
78 }
79};
80
81/*
82 * LEDs
83 */
84static struct gpio_led rsi_ews_leds[] = {
85 {
86 .name = "led0",
87 .gpio = AT91_PIN_PB6,
88 .active_low = 0,
89 },
90 {
91 .name = "led1",
92 .gpio = AT91_PIN_PB7,
93 .active_low = 0,
94 },
95 {
96 .name = "led2",
97 .gpio = AT91_PIN_PB8,
98 .active_low = 0,
99 },
100 {
101 .name = "led3",
102 .gpio = AT91_PIN_PB9,
103 .active_low = 0,
104 },
105};
106
107/*
108 * DataFlash
109 */
110static struct spi_board_info rsi_ews_spi_devices[] = {
111 { /* DataFlash chip 1*/
112 .modalias = "mtd_dataflash",
113 .chip_select = 0,
114 .max_speed_hz = 5 * 1000 * 1000,
115 },
116 { /* DataFlash chip 2*/
117 .modalias = "mtd_dataflash",
118 .chip_select = 1,
119 .max_speed_hz = 5 * 1000 * 1000,
120 },
121};
122
123/*
124 * NOR flash
125 */
126static struct mtd_partition rsiews_nor_partitions[] = {
127 {
128 .name = "boot",
129 .offset = 0,
130 .size = 3 * SZ_128K,
131 .mask_flags = MTD_WRITEABLE
132 },
133 {
134 .name = "kernel",
135 .offset = MTDPART_OFS_NXTBLK,
136 .size = SZ_2M - (3 * SZ_128K)
137 },
138 {
139 .name = "root",
140 .offset = MTDPART_OFS_NXTBLK,
141 .size = SZ_8M
142 },
143 {
144 .name = "kernelupd",
145 .offset = MTDPART_OFS_NXTBLK,
146 .size = 3 * SZ_512K,
147 .mask_flags = MTD_WRITEABLE
148 },
149 {
150 .name = "rootupd",
151 .offset = MTDPART_OFS_NXTBLK,
152 .size = 9 * SZ_512K,
153 .mask_flags = MTD_WRITEABLE
154 },
155};
156
157static struct physmap_flash_data rsiews_nor_data = {
158 .width = 2,
159 .parts = rsiews_nor_partitions,
160 .nr_parts = ARRAY_SIZE(rsiews_nor_partitions),
161};
162
163#define NOR_BASE AT91_CHIPSELECT_0
164#define NOR_SIZE SZ_16M
165
166static struct resource nor_flash_resources[] = {
167 {
168 .start = NOR_BASE,
169 .end = NOR_BASE + NOR_SIZE - 1,
170 .flags = IORESOURCE_MEM,
171 }
172};
173
174static struct platform_device rsiews_nor_flash = {
175 .name = "physmap-flash",
176 .id = 0,
177 .dev = {
178 .platform_data = &rsiews_nor_data,
179 },
180 .resource = nor_flash_resources,
181 .num_resources = ARRAY_SIZE(nor_flash_resources),
182};
183
184/*
185 * Init Func
186 */
187static void __init rsi_ews_board_init(void)
188{
189 /* Serial */
190 /* DBGU on ttyS0. (Rx & Tx only) */
191 /* This one is for debugging */
192 at91_register_uart(0, 0, 0);
193
194 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
195 /* Dialin/-out modem interface */
196 at91_register_uart(AT91RM9200_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS
197 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
198 | ATMEL_UART_RI);
199
200 /* USART3 on ttyS4. (Rx, Tx, RTS) */
201 /* RS485 communication */
202 at91_register_uart(AT91RM9200_ID_US3, 4, ATMEL_UART_RTS);
203 at91_add_device_serial();
204 at91_set_gpio_output(AT91_PIN_PA21, 0);
205 /* Ethernet */
206 at91_add_device_eth(&rsi_ews_eth_data);
207 /* USB Host */
208 at91_add_device_usbh(&rsi_ews_usbh_data);
209 /* I2C */
210 at91_add_device_i2c(rsi_ews_i2c_devices,
211 ARRAY_SIZE(rsi_ews_i2c_devices));
212 /* SPI */
213 at91_add_device_spi(rsi_ews_spi_devices,
214 ARRAY_SIZE(rsi_ews_spi_devices));
215 /* MMC */
216 at91_add_device_mci(0, &rsi_ews_mci0_data);
217 /* NOR Flash */
218 platform_device_register(&rsiews_nor_flash);
219 /* LEDs */
220 at91_gpio_leds(rsi_ews_leds, ARRAY_SIZE(rsi_ews_leds));
221}
222
223MACHINE_START(RSI_EWS, "RSI EWS")
224 /* Maintainer: Josef Holzmayr <holzmayr@rsi-elektrotechnik.de> */
225 .timer = &at91rm9200_timer,
226 .map_io = at91_map_io,
227 .handle_irq = at91_aic_handle_irq,
228 .init_early = rsi_ews_init_early,
229 .init_irq = at91_init_irq_default,
230 .init_machine = rsi_ews_board_init,
231MACHINE_END
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
index b75fbf6003a..4d3a02f1289 100644
--- a/arch/arm/mach-at91/board-sam9-l9260.c
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -21,7 +21,6 @@
21 */ 21 */
22 22
23#include <linux/types.h> 23#include <linux/types.h>
24#include <linux/gpio.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/mm.h> 25#include <linux/mm.h>
27#include <linux/module.h> 26#include <linux/module.h>
@@ -37,10 +36,10 @@
37#include <asm/mach/map.h> 36#include <asm/mach/map.h>
38#include <asm/mach/irq.h> 37#include <asm/mach/irq.h>
39 38
39#include <mach/board.h>
40#include <mach/gpio.h>
40#include <mach/at91sam9_smc.h> 41#include <mach/at91sam9_smc.h>
41 42
42#include "at91_aic.h"
43#include "board.h"
44#include "sam9_smc.h" 43#include "sam9_smc.h"
45#include "generic.h" 44#include "generic.h"
46 45
@@ -49,6 +48,23 @@ static void __init ek_init_early(void)
49{ 48{
50 /* Initialize processor: 18.432 MHz crystal */ 49 /* Initialize processor: 18.432 MHz crystal */
51 at91_initialize(18432000); 50 at91_initialize(18432000);
51
52 /* Setup the LEDs */
53 at91_init_leds(AT91_PIN_PA9, AT91_PIN_PA6);
54
55 /* DBGU on ttyS0. (Rx & Tx only) */
56 at91_register_uart(0, 0, 0);
57
58 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
59 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
60 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
61 | ATMEL_UART_RI);
62
63 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
64 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
65
66 /* set serial console to ttyS0 (ie, DBGU) */
67 at91_set_serial_console(0);
52} 68}
53 69
54/* 70/*
@@ -56,8 +72,6 @@ static void __init ek_init_early(void)
56 */ 72 */
57static struct at91_usbh_data __initdata ek_usbh_data = { 73static struct at91_usbh_data __initdata ek_usbh_data = {
58 .ports = 2, 74 .ports = 2,
59 .vbus_pin = {-EINVAL, -EINVAL},
60 .overcurrent_pin= {-EINVAL, -EINVAL},
61}; 75};
62 76
63/* 77/*
@@ -65,7 +79,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {
65 */ 79 */
66static struct at91_udc_data __initdata ek_udc_data = { 80static struct at91_udc_data __initdata ek_udc_data = {
67 .vbus_pin = AT91_PIN_PC5, 81 .vbus_pin = AT91_PIN_PC5,
68 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 82 .pullup_pin = 0, /* pull-up driven by UDC */
69}; 83};
70 84
71 85
@@ -73,7 +87,7 @@ static struct at91_udc_data __initdata ek_udc_data = {
73 * SPI devices. 87 * SPI devices.
74 */ 88 */
75static struct spi_board_info ek_spi_devices[] = { 89static struct spi_board_info ek_spi_devices[] = {
76#if !IS_ENABLED(CONFIG_MMC_ATMELMCI) 90#if !defined(CONFIG_MMC_AT91)
77 { /* DataFlash chip */ 91 { /* DataFlash chip */
78 .modalias = "mtd_dataflash", 92 .modalias = "mtd_dataflash",
79 .chip_select = 1, 93 .chip_select = 1,
@@ -95,7 +109,7 @@ static struct spi_board_info ek_spi_devices[] = {
95/* 109/*
96 * MACB Ethernet device 110 * MACB Ethernet device
97 */ 111 */
98static struct macb_platform_data __initdata ek_macb_data = { 112static struct at91_eth_data __initdata ek_macb_data = {
99 .phy_irq_pin = AT91_PIN_PA7, 113 .phy_irq_pin = AT91_PIN_PA7,
100 .is_rmii = 0, 114 .is_rmii = 0,
101}; 115};
@@ -117,15 +131,19 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
117 }, 131 },
118}; 132};
119 133
134static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
135{
136 *num_partitions = ARRAY_SIZE(ek_nand_partition);
137 return ek_nand_partition;
138}
139
120static struct atmel_nand_data __initdata ek_nand_data = { 140static struct atmel_nand_data __initdata ek_nand_data = {
121 .ale = 21, 141 .ale = 21,
122 .cle = 22, 142 .cle = 22,
123 .det_pin = -EINVAL, 143// .det_pin = ... not connected
124 .rdy_pin = AT91_PIN_PC13, 144 .rdy_pin = AT91_PIN_PC13,
125 .enable_pin = AT91_PIN_PC14, 145 .enable_pin = AT91_PIN_PC14,
126 .ecc_mode = NAND_ECC_SOFT, 146 .partition_info = nand_partitions,
127 .parts = ek_nand_partition,
128 .num_parts = ARRAY_SIZE(ek_nand_partition),
129}; 147};
130 148
131static struct sam9_smc_config __initdata ek_nand_smc_config = { 149static struct sam9_smc_config __initdata ek_nand_smc_config = {
@@ -149,7 +167,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {
149static void __init ek_add_device_nand(void) 167static void __init ek_add_device_nand(void)
150{ 168{
151 /* configure chip-select 3 (NAND) */ 169 /* configure chip-select 3 (NAND) */
152 sam9_smc_configure(0, 3, &ek_nand_smc_config); 170 sam9_smc_configure(3, &ek_nand_smc_config);
153 171
154 at91_add_device_nand(&ek_nand_data); 172 at91_add_device_nand(&ek_nand_data);
155} 173}
@@ -158,45 +176,17 @@ static void __init ek_add_device_nand(void)
158/* 176/*
159 * MCI (SD/MMC) 177 * MCI (SD/MMC)
160 */ 178 */
161static struct mci_platform_data __initdata ek_mci0_data = { 179static struct at91_mmc_data __initdata ek_mmc_data = {
162 .slot[1] = { 180 .slot_b = 1,
163 .bus_width = 4, 181 .wire4 = 1,
164 .detect_pin = AT91_PIN_PC8, 182 .det_pin = AT91_PIN_PC8,
165 .wp_pin = AT91_PIN_PC4, 183 .wp_pin = AT91_PIN_PC4,
166 }, 184// .vcc_pin = ... not connected
167};
168
169/*
170 * LEDs
171 */
172static struct gpio_led ek_leds[] = {
173 { /* D1 */
174 .name = "led1",
175 .gpio = AT91_PIN_PA9,
176 .active_low = 1,
177 .default_trigger = "heartbeat",
178 },
179 { /* D2 */
180 .name = "led2",
181 .gpio = AT91_PIN_PA6,
182 .active_low = 1,
183 .default_trigger = "timer",
184 }
185}; 185};
186 186
187static void __init ek_board_init(void) 187static void __init ek_board_init(void)
188{ 188{
189 /* Serial */ 189 /* Serial */
190 /* DBGU on ttyS0. (Rx & Tx only) */
191 at91_register_uart(0, 0, 0);
192
193 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
194 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
195 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
196 | ATMEL_UART_RI);
197
198 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
199 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
200 at91_add_device_serial(); 190 at91_add_device_serial();
201 /* USB Host */ 191 /* USB Host */
202 at91_add_device_usbh(&ek_usbh_data); 192 at91_add_device_usbh(&ek_usbh_data);
@@ -209,18 +199,15 @@ static void __init ek_board_init(void)
209 /* Ethernet */ 199 /* Ethernet */
210 at91_add_device_eth(&ek_macb_data); 200 at91_add_device_eth(&ek_macb_data);
211 /* MMC */ 201 /* MMC */
212 at91_add_device_mci(0, &ek_mci0_data); 202 at91_add_device_mmc(0, &ek_mmc_data);
213 /* I2C */ 203 /* I2C */
214 at91_add_device_i2c(NULL, 0); 204 at91_add_device_i2c(NULL, 0);
215 /* LEDs */
216 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
217} 205}
218 206
219MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260") 207MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")
220 /* Maintainer: Olimex */ 208 /* Maintainer: Olimex */
221 .timer = &at91sam926x_timer, 209 .timer = &at91sam926x_timer,
222 .map_io = at91_map_io, 210 .map_io = at91_map_io,
223 .handle_irq = at91_aic_handle_irq,
224 .init_early = ek_init_early, 211 .init_early = ek_init_early,
225 .init_irq = at91_init_irq_default, 212 .init_irq = at91_init_irq_default,
226 .init_machine = ek_board_init, 213 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c
index f0135cd1d85..8a50c3e6718 100644
--- a/arch/arm/mach-at91/board-sam9260ek.c
+++ b/arch/arm/mach-at91/board-sam9260ek.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/gpio.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/mm.h> 24#include <linux/mm.h>
26#include <linux/module.h> 25#include <linux/module.h>
@@ -41,12 +40,12 @@
41#include <asm/mach/irq.h> 40#include <asm/mach/irq.h>
42 41
43#include <mach/hardware.h> 42#include <mach/hardware.h>
43#include <mach/board.h>
44#include <mach/gpio.h>
44#include <mach/at91sam9_smc.h> 45#include <mach/at91sam9_smc.h>
46#include <mach/at91_shdwc.h>
45#include <mach/system_rev.h> 47#include <mach/system_rev.h>
46 48
47#include "at91_aic.h"
48#include "at91_shdwc.h"
49#include "board.h"
50#include "sam9_smc.h" 49#include "sam9_smc.h"
51#include "generic.h" 50#include "generic.h"
52 51
@@ -55,6 +54,20 @@ static void __init ek_init_early(void)
55{ 54{
56 /* Initialize processor: 18.432 MHz crystal */ 55 /* Initialize processor: 18.432 MHz crystal */
57 at91_initialize(18432000); 56 at91_initialize(18432000);
57
58 /* DBGU on ttyS0. (Rx & Tx only) */
59 at91_register_uart(0, 0, 0);
60
61 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
62 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
63 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
64 | ATMEL_UART_RI);
65
66 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
67 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
68
69 /* set serial console to ttyS0 (ie, DBGU) */
70 at91_set_serial_console(0);
58} 71}
59 72
60/* 73/*
@@ -62,8 +75,6 @@ static void __init ek_init_early(void)
62 */ 75 */
63static struct at91_usbh_data __initdata ek_usbh_data = { 76static struct at91_usbh_data __initdata ek_usbh_data = {
64 .ports = 2, 77 .ports = 2,
65 .vbus_pin = {-EINVAL, -EINVAL},
66 .overcurrent_pin= {-EINVAL, -EINVAL},
67}; 78};
68 79
69/* 80/*
@@ -71,7 +82,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {
71 */ 82 */
72static struct at91_udc_data __initdata ek_udc_data = { 83static struct at91_udc_data __initdata ek_udc_data = {
73 .vbus_pin = AT91_PIN_PC5, 84 .vbus_pin = AT91_PIN_PC5,
74 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 85 .pullup_pin = 0, /* pull-up driven by UDC */
75}; 86};
76 87
77 88
@@ -108,7 +119,7 @@ static void __init at73c213_set_clk(struct at73c213_board_info *info) {}
108 * SPI devices. 119 * SPI devices.
109 */ 120 */
110static struct spi_board_info ek_spi_devices[] = { 121static struct spi_board_info ek_spi_devices[] = {
111#if !IS_ENABLED(CONFIG_MMC_ATMELMCI) 122#if !defined(CONFIG_MMC_AT91)
112 { /* DataFlash chip */ 123 { /* DataFlash chip */
113 .modalias = "mtd_dataflash", 124 .modalias = "mtd_dataflash",
114 .chip_select = 1, 125 .chip_select = 1,
@@ -140,7 +151,7 @@ static struct spi_board_info ek_spi_devices[] = {
140/* 151/*
141 * MACB Ethernet device 152 * MACB Ethernet device
142 */ 153 */
143static struct macb_platform_data __initdata ek_macb_data = { 154static struct at91_eth_data __initdata ek_macb_data = {
144 .phy_irq_pin = AT91_PIN_PA7, 155 .phy_irq_pin = AT91_PIN_PA7,
145 .is_rmii = 1, 156 .is_rmii = 1,
146}; 157};
@@ -162,16 +173,19 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
162 }, 173 },
163}; 174};
164 175
176static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
177{
178 *num_partitions = ARRAY_SIZE(ek_nand_partition);
179 return ek_nand_partition;
180}
181
165static struct atmel_nand_data __initdata ek_nand_data = { 182static struct atmel_nand_data __initdata ek_nand_data = {
166 .ale = 21, 183 .ale = 21,
167 .cle = 22, 184 .cle = 22,
168 .det_pin = -EINVAL, 185// .det_pin = ... not connected
169 .rdy_pin = AT91_PIN_PC13, 186 .rdy_pin = AT91_PIN_PC13,
170 .enable_pin = AT91_PIN_PC14, 187 .enable_pin = AT91_PIN_PC14,
171 .ecc_mode = NAND_ECC_SOFT, 188 .partition_info = nand_partitions,
172 .on_flash_bbt = 1,
173 .parts = ek_nand_partition,
174 .num_parts = ARRAY_SIZE(ek_nand_partition),
175}; 189};
176 190
177static struct sam9_smc_config __initdata ek_nand_smc_config = { 191static struct sam9_smc_config __initdata ek_nand_smc_config = {
@@ -202,7 +216,7 @@ static void __init ek_add_device_nand(void)
202 ek_nand_smc_config.mode |= AT91_SMC_DBW_8; 216 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
203 217
204 /* configure chip-select 3 (NAND) */ 218 /* configure chip-select 3 (NAND) */
205 sam9_smc_configure(0, 3, &ek_nand_smc_config); 219 sam9_smc_configure(3, &ek_nand_smc_config);
206 220
207 at91_add_device_nand(&ek_nand_data); 221 at91_add_device_nand(&ek_nand_data);
208} 222}
@@ -211,12 +225,12 @@ static void __init ek_add_device_nand(void)
211/* 225/*
212 * MCI (SD/MMC) 226 * MCI (SD/MMC)
213 */ 227 */
214static struct mci_platform_data __initdata ek_mci0_data = { 228static struct at91_mmc_data __initdata ek_mmc_data = {
215 .slot[1] = { 229 .slot_b = 1,
216 .bus_width = 4, 230 .wire4 = 1,
217 .detect_pin = -EINVAL, 231// .det_pin = ... not connected
218 .wp_pin = -EINVAL, 232// .wp_pin = ... not connected
219 }, 233// .vcc_pin = ... not connected
220}; 234};
221 235
222 236
@@ -307,16 +321,6 @@ static void __init ek_add_device_buttons(void) {}
307static void __init ek_board_init(void) 321static void __init ek_board_init(void)
308{ 322{
309 /* Serial */ 323 /* Serial */
310 /* DBGU on ttyS0. (Rx & Tx only) */
311 at91_register_uart(0, 0, 0);
312
313 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
314 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
315 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
316 | ATMEL_UART_RI);
317
318 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
319 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
320 at91_add_device_serial(); 324 at91_add_device_serial();
321 /* USB Host */ 325 /* USB Host */
322 at91_add_device_usbh(&ek_usbh_data); 326 at91_add_device_usbh(&ek_usbh_data);
@@ -329,7 +333,7 @@ static void __init ek_board_init(void)
329 /* Ethernet */ 333 /* Ethernet */
330 at91_add_device_eth(&ek_macb_data); 334 at91_add_device_eth(&ek_macb_data);
331 /* MMC */ 335 /* MMC */
332 at91_add_device_mci(0, &ek_mci0_data); 336 at91_add_device_mmc(0, &ek_mmc_data);
333 /* I2C */ 337 /* I2C */
334 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices)); 338 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
335 /* SSC (to AT73C213) */ 339 /* SSC (to AT73C213) */
@@ -345,7 +349,6 @@ MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")
345 /* Maintainer: Atmel */ 349 /* Maintainer: Atmel */
346 .timer = &at91sam926x_timer, 350 .timer = &at91sam926x_timer,
347 .map_io = at91_map_io, 351 .map_io = at91_map_io,
348 .handle_irq = at91_aic_handle_irq,
349 .init_early = ek_init_early, 352 .init_early = ek_init_early,
350 .init_irq = at91_init_irq_default, 353 .init_irq = at91_init_irq_default,
351 .init_machine = ek_board_init, 354 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 13ebaa8e410..5096a0ec50c 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/gpio.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/mm.h> 24#include <linux/mm.h>
26#include <linux/module.h> 25#include <linux/module.h>
@@ -45,12 +44,12 @@
45#include <asm/mach/irq.h> 44#include <asm/mach/irq.h>
46 45
47#include <mach/hardware.h> 46#include <mach/hardware.h>
47#include <mach/board.h>
48#include <mach/gpio.h>
48#include <mach/at91sam9_smc.h> 49#include <mach/at91sam9_smc.h>
50#include <mach/at91_shdwc.h>
49#include <mach/system_rev.h> 51#include <mach/system_rev.h>
50 52
51#include "at91_aic.h"
52#include "at91_shdwc.h"
53#include "board.h"
54#include "sam9_smc.h" 53#include "sam9_smc.h"
55#include "generic.h" 54#include "generic.h"
56 55
@@ -59,6 +58,15 @@ static void __init ek_init_early(void)
59{ 58{
60 /* Initialize processor: 18.432 MHz crystal */ 59 /* Initialize processor: 18.432 MHz crystal */
61 at91_initialize(18432000); 60 at91_initialize(18432000);
61
62 /* Setup the LEDs */
63 at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
64
65 /* DBGU on ttyS0. (Rx & Tx only) */
66 at91_register_uart(0, 0, 0);
67
68 /* set serial console to ttyS0 (ie, DBGU) */
69 at91_set_serial_console(0);
62} 70}
63 71
64/* 72/*
@@ -77,6 +85,8 @@ static struct resource dm9000_resource[] = {
77 .flags = IORESOURCE_MEM 85 .flags = IORESOURCE_MEM
78 }, 86 },
79 [2] = { 87 [2] = {
88 .start = AT91_PIN_PC11,
89 .end = AT91_PIN_PC11,
80 .flags = IORESOURCE_IRQ 90 .flags = IORESOURCE_IRQ
81 | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE, 91 | IORESOURCE_IRQ_LOWEDGE | IORESOURCE_IRQ_HIGHEDGE,
82 } 92 }
@@ -120,10 +130,8 @@ static struct sam9_smc_config __initdata dm9000_smc_config = {
120 130
121static void __init ek_add_device_dm9000(void) 131static void __init ek_add_device_dm9000(void)
122{ 132{
123 struct resource *r = &dm9000_resource[2];
124
125 /* Configure chip-select 2 (DM9000) */ 133 /* Configure chip-select 2 (DM9000) */
126 sam9_smc_configure(0, 2, &dm9000_smc_config); 134 sam9_smc_configure(2, &dm9000_smc_config);
127 135
128 /* Configure Reset signal as output */ 136 /* Configure Reset signal as output */
129 at91_set_gpio_output(AT91_PIN_PC10, 0); 137 at91_set_gpio_output(AT91_PIN_PC10, 0);
@@ -131,7 +139,6 @@ static void __init ek_add_device_dm9000(void)
131 /* Configure Interrupt pin as input, no pull-up */ 139 /* Configure Interrupt pin as input, no pull-up */
132 at91_set_gpio_input(AT91_PIN_PC11, 0); 140 at91_set_gpio_input(AT91_PIN_PC11, 0);
133 141
134 r->start = r->end = gpio_to_irq(AT91_PIN_PC11);
135 platform_device_register(&dm9000_device); 142 platform_device_register(&dm9000_device);
136} 143}
137#else 144#else
@@ -144,8 +151,6 @@ static void __init ek_add_device_dm9000(void) {}
144 */ 151 */
145static struct at91_usbh_data __initdata ek_usbh_data = { 152static struct at91_usbh_data __initdata ek_usbh_data = {
146 .ports = 2, 153 .ports = 2,
147 .vbus_pin = {-EINVAL, -EINVAL},
148 .overcurrent_pin= {-EINVAL, -EINVAL},
149}; 154};
150 155
151 156
@@ -154,7 +159,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {
154 */ 159 */
155static struct at91_udc_data __initdata ek_udc_data = { 160static struct at91_udc_data __initdata ek_udc_data = {
156 .vbus_pin = AT91_PIN_PB29, 161 .vbus_pin = AT91_PIN_PB29,
157 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 162 .pullup_pin = 0, /* pull-up driven by UDC */
158}; 163};
159 164
160 165
@@ -174,16 +179,19 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
174 }, 179 },
175}; 180};
176 181
182static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
183{
184 *num_partitions = ARRAY_SIZE(ek_nand_partition);
185 return ek_nand_partition;
186}
187
177static struct atmel_nand_data __initdata ek_nand_data = { 188static struct atmel_nand_data __initdata ek_nand_data = {
178 .ale = 22, 189 .ale = 22,
179 .cle = 21, 190 .cle = 21,
180 .det_pin = -EINVAL, 191// .det_pin = ... not connected
181 .rdy_pin = AT91_PIN_PC15, 192 .rdy_pin = AT91_PIN_PC15,
182 .enable_pin = AT91_PIN_PC14, 193 .enable_pin = AT91_PIN_PC14,
183 .ecc_mode = NAND_ECC_SOFT, 194 .partition_info = nand_partitions,
184 .on_flash_bbt = 1,
185 .parts = ek_nand_partition,
186 .num_parts = ARRAY_SIZE(ek_nand_partition),
187}; 195};
188 196
189static struct sam9_smc_config __initdata ek_nand_smc_config = { 197static struct sam9_smc_config __initdata ek_nand_smc_config = {
@@ -214,7 +222,7 @@ static void __init ek_add_device_nand(void)
214 ek_nand_smc_config.mode |= AT91_SMC_DBW_8; 222 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
215 223
216 /* configure chip-select 3 (NAND) */ 224 /* configure chip-select 3 (NAND) */
217 sam9_smc_configure(0, 3, &ek_nand_smc_config); 225 sam9_smc_configure(3, &ek_nand_smc_config);
218 226
219 at91_add_device_nand(&ek_nand_data); 227 at91_add_device_nand(&ek_nand_data);
220} 228}
@@ -309,7 +317,7 @@ static struct spi_board_info ek_spi_devices[] = {
309 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */ 317 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
310 .bus_num = 0, 318 .bus_num = 0,
311 .platform_data = &ads_info, 319 .platform_data = &ads_info,
312 .irq = NR_IRQS_LEGACY + AT91SAM9261_ID_IRQ0, 320 .irq = AT91SAM9261_ID_IRQ0,
313 .controller_data = (void *) AT91_PIN_PA28, /* CS pin */ 321 .controller_data = (void *) AT91_PIN_PA28, /* CS pin */
314 }, 322 },
315#endif 323#endif
@@ -340,12 +348,8 @@ static struct spi_board_info ek_spi_devices[] = {
340 * MCI (SD/MMC) 348 * MCI (SD/MMC)
341 * det_pin, wp_pin and vcc_pin are not connected 349 * det_pin, wp_pin and vcc_pin are not connected
342 */ 350 */
343static struct mci_platform_data __initdata mci0_data = { 351static struct at91_mmc_data __initdata ek_mmc_data = {
344 .slot[0] = { 352 .wire4 = 1,
345 .bus_width = 4,
346 .detect_pin = -EINVAL,
347 .wp_pin = -EINVAL,
348 },
349}; 353};
350 354
351#endif /* CONFIG_SPI_ATMEL_* */ 355#endif /* CONFIG_SPI_ATMEL_* */
@@ -571,8 +575,6 @@ static struct gpio_led ek_leds[] = {
571static void __init ek_board_init(void) 575static void __init ek_board_init(void)
572{ 576{
573 /* Serial */ 577 /* Serial */
574 /* DBGU on ttyS0. (Rx & Tx only) */
575 at91_register_uart(0, 0, 0);
576 at91_add_device_serial(); 578 at91_add_device_serial();
577 /* USB Host */ 579 /* USB Host */
578 at91_add_device_usbh(&ek_usbh_data); 580 at91_add_device_usbh(&ek_usbh_data);
@@ -596,7 +598,7 @@ static void __init ek_board_init(void)
596 at91_add_device_ssc(AT91SAM9261_ID_SSC1, ATMEL_SSC_TX); 598 at91_add_device_ssc(AT91SAM9261_ID_SSC1, ATMEL_SSC_TX);
597#else 599#else
598 /* MMC */ 600 /* MMC */
599 at91_add_device_mci(0, &mci0_data); 601 at91_add_device_mmc(0, &ek_mmc_data);
600#endif 602#endif
601 /* LCD Controller */ 603 /* LCD Controller */
602 at91_add_device_lcdc(&ek_lcdc_data); 604 at91_add_device_lcdc(&ek_lcdc_data);
@@ -614,7 +616,6 @@ MACHINE_START(AT91SAM9G10EK, "Atmel AT91SAM9G10-EK")
614 /* Maintainer: Atmel */ 616 /* Maintainer: Atmel */
615 .timer = &at91sam926x_timer, 617 .timer = &at91sam926x_timer,
616 .map_io = at91_map_io, 618 .map_io = at91_map_io,
617 .handle_irq = at91_aic_handle_irq,
618 .init_early = ek_init_early, 619 .init_early = ek_init_early,
619 .init_irq = at91_init_irq_default, 620 .init_irq = at91_init_irq_default,
620 .init_machine = ek_board_init, 621 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index 89b9608742a..ea8f185d3b9 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -20,7 +20,6 @@
20 */ 20 */
21 21
22#include <linux/types.h> 22#include <linux/types.h>
23#include <linux/gpio.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/mm.h> 24#include <linux/mm.h>
26#include <linux/module.h> 25#include <linux/module.h>
@@ -44,12 +43,12 @@
44#include <asm/mach/irq.h> 43#include <asm/mach/irq.h>
45 44
46#include <mach/hardware.h> 45#include <mach/hardware.h>
46#include <mach/board.h>
47#include <mach/gpio.h>
47#include <mach/at91sam9_smc.h> 48#include <mach/at91sam9_smc.h>
49#include <mach/at91_shdwc.h>
48#include <mach/system_rev.h> 50#include <mach/system_rev.h>
49 51
50#include "at91_aic.h"
51#include "at91_shdwc.h"
52#include "board.h"
53#include "sam9_smc.h" 52#include "sam9_smc.h"
54#include "generic.h" 53#include "generic.h"
55 54
@@ -58,6 +57,15 @@ static void __init ek_init_early(void)
58{ 57{
59 /* Initialize processor: 16.367 MHz crystal */ 58 /* Initialize processor: 16.367 MHz crystal */
60 at91_initialize(16367660); 59 at91_initialize(16367660);
60
61 /* DBGU on ttyS0. (Rx & Tx only) */
62 at91_register_uart(0, 0, 0);
63
64 /* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */
65 at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
66
67 /* set serial console to ttyS0 (ie, DBGU) */
68 at91_set_serial_console(0);
61} 69}
62 70
63/* 71/*
@@ -66,8 +74,6 @@ static void __init ek_init_early(void)
66static struct at91_usbh_data __initdata ek_usbh_data = { 74static struct at91_usbh_data __initdata ek_usbh_data = {
67 .ports = 2, 75 .ports = 2,
68 .vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 }, 76 .vbus_pin = { AT91_PIN_PA24, AT91_PIN_PA21 },
69 .vbus_pin_active_low = {1, 1},
70 .overcurrent_pin= {-EINVAL, -EINVAL},
71}; 77};
72 78
73/* 79/*
@@ -75,7 +81,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {
75 */ 81 */
76static struct at91_udc_data __initdata ek_udc_data = { 82static struct at91_udc_data __initdata ek_udc_data = {
77 .vbus_pin = AT91_PIN_PA25, 83 .vbus_pin = AT91_PIN_PA25,
78 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 84 .pullup_pin = 0, /* pull-up driven by UDC */
79}; 85};
80 86
81 87
@@ -132,7 +138,7 @@ static struct spi_board_info ek_spi_devices[] = {
132 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */ 138 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
133 .bus_num = 0, 139 .bus_num = 0,
134 .platform_data = &ads_info, 140 .platform_data = &ads_info,
135 .irq = NR_IRQS_LEGACY + AT91SAM9263_ID_IRQ1, 141 .irq = AT91SAM9263_ID_IRQ1,
136 }, 142 },
137#endif 143#endif
138}; 144};
@@ -141,19 +147,18 @@ static struct spi_board_info ek_spi_devices[] = {
141/* 147/*
142 * MCI (SD/MMC) 148 * MCI (SD/MMC)
143 */ 149 */
144static struct mci_platform_data __initdata mci1_data = { 150static struct at91_mmc_data __initdata ek_mmc_data = {
145 .slot[0] = { 151 .wire4 = 1,
146 .bus_width = 4, 152 .det_pin = AT91_PIN_PE18,
147 .detect_pin = AT91_PIN_PE18, 153 .wp_pin = AT91_PIN_PE19,
148 .wp_pin = AT91_PIN_PE19, 154// .vcc_pin = ... not connected
149 },
150}; 155};
151 156
152 157
153/* 158/*
154 * MACB Ethernet device 159 * MACB Ethernet device
155 */ 160 */
156static struct macb_platform_data __initdata ek_macb_data = { 161static struct at91_eth_data __initdata ek_macb_data = {
157 .phy_irq_pin = AT91_PIN_PE31, 162 .phy_irq_pin = AT91_PIN_PE31,
158 .is_rmii = 1, 163 .is_rmii = 1,
159}; 164};
@@ -175,16 +180,19 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
175 }, 180 },
176}; 181};
177 182
183static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
184{
185 *num_partitions = ARRAY_SIZE(ek_nand_partition);
186 return ek_nand_partition;
187}
188
178static struct atmel_nand_data __initdata ek_nand_data = { 189static struct atmel_nand_data __initdata ek_nand_data = {
179 .ale = 21, 190 .ale = 21,
180 .cle = 22, 191 .cle = 22,
181 .det_pin = -EINVAL, 192// .det_pin = ... not connected
182 .rdy_pin = AT91_PIN_PA22, 193 .rdy_pin = AT91_PIN_PA22,
183 .enable_pin = AT91_PIN_PD15, 194 .enable_pin = AT91_PIN_PD15,
184 .ecc_mode = NAND_ECC_SOFT, 195 .partition_info = nand_partitions,
185 .on_flash_bbt = 1,
186 .parts = ek_nand_partition,
187 .num_parts = ARRAY_SIZE(ek_nand_partition),
188}; 196};
189 197
190static struct sam9_smc_config __initdata ek_nand_smc_config = { 198static struct sam9_smc_config __initdata ek_nand_smc_config = {
@@ -215,7 +223,7 @@ static void __init ek_add_device_nand(void)
215 ek_nand_smc_config.mode |= AT91_SMC_DBW_8; 223 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
216 224
217 /* configure chip-select 3 (NAND) */ 225 /* configure chip-select 3 (NAND) */
218 sam9_smc_configure(0, 3, &ek_nand_smc_config); 226 sam9_smc_configure(3, &ek_nand_smc_config);
219 227
220 at91_add_device_nand(&ek_nand_data); 228 at91_add_device_nand(&ek_nand_data);
221} 229}
@@ -350,7 +358,6 @@ static void __init ek_add_device_buttons(void) {}
350 * reset_pin is not connected: NRST 358 * reset_pin is not connected: NRST
351 */ 359 */
352static struct ac97c_platform_data ek_ac97_data = { 360static struct ac97c_platform_data ek_ac97_data = {
353 .reset_pin = -EINVAL,
354}; 361};
355 362
356 363
@@ -405,11 +412,6 @@ static struct at91_can_data ek_can_data = {
405static void __init ek_board_init(void) 412static void __init ek_board_init(void)
406{ 413{
407 /* Serial */ 414 /* Serial */
408 /* DBGU on ttyS0. (Rx & Tx only) */
409 at91_register_uart(0, 0, 0);
410
411 /* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */
412 at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
413 at91_add_device_serial(); 415 at91_add_device_serial();
414 /* USB Host */ 416 /* USB Host */
415 at91_add_device_usbh(&ek_usbh_data); 417 at91_add_device_usbh(&ek_usbh_data);
@@ -421,7 +423,7 @@ static void __init ek_board_init(void)
421 /* Touchscreen */ 423 /* Touchscreen */
422 ek_add_device_ts(); 424 ek_add_device_ts();
423 /* MMC */ 425 /* MMC */
424 at91_add_device_mci(1, &mci1_data); 426 at91_add_device_mmc(1, &ek_mmc_data);
425 /* Ethernet */ 427 /* Ethernet */
426 at91_add_device_eth(&ek_macb_data); 428 at91_add_device_eth(&ek_macb_data);
427 /* NAND */ 429 /* NAND */
@@ -445,7 +447,6 @@ MACHINE_START(AT91SAM9263EK, "Atmel AT91SAM9263-EK")
445 /* Maintainer: Atmel */ 447 /* Maintainer: Atmel */
446 .timer = &at91sam926x_timer, 448 .timer = &at91sam926x_timer,
447 .map_io = at91_map_io, 449 .map_io = at91_map_io,
448 .handle_irq = at91_aic_handle_irq,
449 .init_early = ek_init_early, 450 .init_early = ek_init_early,
450 .init_irq = at91_init_irq_default, 451 .init_irq = at91_init_irq_default,
451 .init_machine = ek_board_init, 452 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c
index 1b7dd9f688d..817f59d7251 100644
--- a/arch/arm/mach-at91/board-sam9g20ek.c
+++ b/arch/arm/mach-at91/board-sam9g20ek.c
@@ -18,7 +18,6 @@
18 */ 18 */
19 19
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/gpio.h>
22#include <linux/init.h> 21#include <linux/init.h>
23#include <linux/mm.h> 22#include <linux/mm.h>
24#include <linux/module.h> 23#include <linux/module.h>
@@ -32,8 +31,6 @@
32#include <linux/regulator/fixed.h> 31#include <linux/regulator/fixed.h>
33#include <linux/regulator/consumer.h> 32#include <linux/regulator/consumer.h>
34 33
35#include <linux/platform_data/at91_adc.h>
36
37#include <mach/hardware.h> 34#include <mach/hardware.h>
38#include <asm/setup.h> 35#include <asm/setup.h>
39#include <asm/mach-types.h> 36#include <asm/mach-types.h>
@@ -43,11 +40,11 @@
43#include <asm/mach/map.h> 40#include <asm/mach/map.h>
44#include <asm/mach/irq.h> 41#include <asm/mach/irq.h>
45 42
43#include <mach/board.h>
44#include <mach/gpio.h>
46#include <mach/at91sam9_smc.h> 45#include <mach/at91sam9_smc.h>
47#include <mach/system_rev.h> 46#include <mach/system_rev.h>
48 47
49#include "at91_aic.h"
50#include "board.h"
51#include "sam9_smc.h" 48#include "sam9_smc.h"
52#include "generic.h" 49#include "generic.h"
53 50
@@ -68,6 +65,20 @@ static void __init ek_init_early(void)
68{ 65{
69 /* Initialize processor: 18.432 MHz crystal */ 66 /* Initialize processor: 18.432 MHz crystal */
70 at91_initialize(18432000); 67 at91_initialize(18432000);
68
69 /* DBGU on ttyS0. (Rx & Tx only) */
70 at91_register_uart(0, 0, 0);
71
72 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
73 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
74 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
75 | ATMEL_UART_RI);
76
77 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
78 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
79
80 /* set serial console to ttyS0 (ie, DBGU) */
81 at91_set_serial_console(0);
71} 82}
72 83
73/* 84/*
@@ -75,8 +86,6 @@ static void __init ek_init_early(void)
75 */ 86 */
76static struct at91_usbh_data __initdata ek_usbh_data = { 87static struct at91_usbh_data __initdata ek_usbh_data = {
77 .ports = 2, 88 .ports = 2,
78 .vbus_pin = {-EINVAL, -EINVAL},
79 .overcurrent_pin= {-EINVAL, -EINVAL},
80}; 89};
81 90
82/* 91/*
@@ -84,7 +93,7 @@ static struct at91_usbh_data __initdata ek_usbh_data = {
84 */ 93 */
85static struct at91_udc_data __initdata ek_udc_data = { 94static struct at91_udc_data __initdata ek_udc_data = {
86 .vbus_pin = AT91_PIN_PC5, 95 .vbus_pin = AT91_PIN_PC5,
87 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 96 .pullup_pin = 0, /* pull-up driven by UDC */
88}; 97};
89 98
90 99
@@ -92,7 +101,7 @@ static struct at91_udc_data __initdata ek_udc_data = {
92 * SPI devices. 101 * SPI devices.
93 */ 102 */
94static struct spi_board_info ek_spi_devices[] = { 103static struct spi_board_info ek_spi_devices[] = {
95#if !IS_ENABLED(CONFIG_MMC_ATMELMCI) 104#if !(defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_AT91))
96 { /* DataFlash chip */ 105 { /* DataFlash chip */
97 .modalias = "mtd_dataflash", 106 .modalias = "mtd_dataflash",
98 .chip_select = 1, 107 .chip_select = 1,
@@ -114,7 +123,7 @@ static struct spi_board_info ek_spi_devices[] = {
114/* 123/*
115 * MACB Ethernet device 124 * MACB Ethernet device
116 */ 125 */
117static struct macb_platform_data __initdata ek_macb_data = { 126static struct at91_eth_data __initdata ek_macb_data = {
118 .phy_irq_pin = AT91_PIN_PA7, 127 .phy_irq_pin = AT91_PIN_PA7,
119 .is_rmii = 1, 128 .is_rmii = 1,
120}; 129};
@@ -148,17 +157,19 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
148 }, 157 },
149}; 158};
150 159
160static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
161{
162 *num_partitions = ARRAY_SIZE(ek_nand_partition);
163 return ek_nand_partition;
164}
165
151/* det_pin is not connected */ 166/* det_pin is not connected */
152static struct atmel_nand_data __initdata ek_nand_data = { 167static struct atmel_nand_data __initdata ek_nand_data = {
153 .ale = 21, 168 .ale = 21,
154 .cle = 22, 169 .cle = 22,
155 .rdy_pin = AT91_PIN_PC13, 170 .rdy_pin = AT91_PIN_PC13,
156 .enable_pin = AT91_PIN_PC14, 171 .enable_pin = AT91_PIN_PC14,
157 .det_pin = -EINVAL, 172 .partition_info = nand_partitions,
158 .ecc_mode = NAND_ECC_SOFT,
159 .on_flash_bbt = 1,
160 .parts = ek_nand_partition,
161 .num_parts = ARRAY_SIZE(ek_nand_partition),
162}; 173};
163 174
164static struct sam9_smc_config __initdata ek_nand_smc_config = { 175static struct sam9_smc_config __initdata ek_nand_smc_config = {
@@ -189,7 +200,7 @@ static void __init ek_add_device_nand(void)
189 ek_nand_smc_config.mode |= AT91_SMC_DBW_8; 200 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
190 201
191 /* configure chip-select 3 (NAND) */ 202 /* configure chip-select 3 (NAND) */
192 sam9_smc_configure(0, 3, &ek_nand_smc_config); 203 sam9_smc_configure(3, &ek_nand_smc_config);
193 204
194 at91_add_device_nand(&ek_nand_data); 205 at91_add_device_nand(&ek_nand_data);
195} 206}
@@ -199,23 +210,33 @@ static void __init ek_add_device_nand(void)
199 * MCI (SD/MMC) 210 * MCI (SD/MMC)
200 * wp_pin and vcc_pin are not connected 211 * wp_pin and vcc_pin are not connected
201 */ 212 */
213#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
202static struct mci_platform_data __initdata ek_mmc_data = { 214static struct mci_platform_data __initdata ek_mmc_data = {
203 .slot[1] = { 215 .slot[1] = {
204 .bus_width = 4, 216 .bus_width = 4,
205 .detect_pin = AT91_PIN_PC9, 217 .detect_pin = AT91_PIN_PC9,
206 .wp_pin = -EINVAL,
207 }, 218 },
208 219
209}; 220};
221#else
222static struct at91_mmc_data __initdata ek_mmc_data = {
223 .slot_b = 1, /* Only one slot so use slot B */
224 .wire4 = 1,
225 .det_pin = AT91_PIN_PC9,
226};
227#endif
210 228
211static void __init ek_add_device_mmc(void) 229static void __init ek_add_device_mmc(void)
212{ 230{
231#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
213 if (ek_have_2mmc()) { 232 if (ek_have_2mmc()) {
214 ek_mmc_data.slot[0].bus_width = 4; 233 ek_mmc_data.slot[0].bus_width = 4;
215 ek_mmc_data.slot[0].detect_pin = AT91_PIN_PC2; 234 ek_mmc_data.slot[0].detect_pin = AT91_PIN_PC2;
216 ek_mmc_data.slot[0].wp_pin = -1;
217 } 235 }
218 at91_add_device_mci(0, &ek_mmc_data); 236 at91_add_device_mci(0, &ek_mmc_data);
237#else
238 at91_add_device_mmc(0, &ek_mmc_data);
239#endif
219} 240}
220 241
221/* 242/*
@@ -293,16 +314,6 @@ static void __init ek_add_device_buttons(void)
293static void __init ek_add_device_buttons(void) {} 314static void __init ek_add_device_buttons(void) {}
294#endif 315#endif
295 316
296/*
297 * ADCs
298 */
299
300static struct at91_adc_data ek_adc_data = {
301 .channels_used = BIT(0) | BIT(1) | BIT(2) | BIT(3),
302 .use_external_triggers = true,
303 .vref = 3300,
304};
305
306#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) 317#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)
307static struct regulator_consumer_supply ek_audio_consumer_supplies[] = { 318static struct regulator_consumer_supply ek_audio_consumer_supplies[] = {
308 REGULATOR_SUPPLY("AVDD", "0-001b"), 319 REGULATOR_SUPPLY("AVDD", "0-001b"),
@@ -353,30 +364,10 @@ static struct i2c_board_info __initdata ek_i2c_devices[] = {
353 }, 364 },
354}; 365};
355 366
356static struct platform_device sam9g20ek_audio_device = {
357 .name = "at91sam9g20ek-audio",
358 .id = -1,
359};
360
361static void __init ek_add_device_audio(void)
362{
363 platform_device_register(&sam9g20ek_audio_device);
364}
365
366 367
367static void __init ek_board_init(void) 368static void __init ek_board_init(void)
368{ 369{
369 /* Serial */ 370 /* Serial */
370 /* DBGU on ttyS0. (Rx & Tx only) */
371 at91_register_uart(0, 0, 0);
372
373 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
374 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
375 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
376 | ATMEL_UART_RI);
377
378 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
379 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
380 at91_add_device_serial(); 371 at91_add_device_serial();
381 /* USB Host */ 372 /* USB Host */
382 at91_add_device_usbh(&ek_usbh_data); 373 at91_add_device_usbh(&ek_usbh_data);
@@ -398,20 +389,16 @@ static void __init ek_board_init(void)
398 ek_add_device_gpio_leds(); 389 ek_add_device_gpio_leds();
399 /* Push Buttons */ 390 /* Push Buttons */
400 ek_add_device_buttons(); 391 ek_add_device_buttons();
401 /* ADCs */
402 at91_add_device_adc(&ek_adc_data);
403 /* PCK0 provides MCLK to the WM8731 */ 392 /* PCK0 provides MCLK to the WM8731 */
404 at91_set_B_periph(AT91_PIN_PC1, 0); 393 at91_set_B_periph(AT91_PIN_PC1, 0);
405 /* SSC (for WM8731) */ 394 /* SSC (for WM8731) */
406 at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX); 395 at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
407 ek_add_device_audio();
408} 396}
409 397
410MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK") 398MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK")
411 /* Maintainer: Atmel */ 399 /* Maintainer: Atmel */
412 .timer = &at91sam926x_timer, 400 .timer = &at91sam926x_timer,
413 .map_io = at91_map_io, 401 .map_io = at91_map_io,
414 .handle_irq = at91_aic_handle_irq,
415 .init_early = ek_init_early, 402 .init_early = ek_init_early,
416 .init_irq = at91_init_irq_default, 403 .init_irq = at91_init_irq_default,
417 .init_machine = ek_board_init, 404 .init_machine = ek_board_init,
@@ -421,7 +408,6 @@ MACHINE_START(AT91SAM9G20EK_2MMC, "Atmel AT91SAM9G20-EK 2 MMC Slot Mod")
421 /* Maintainer: Atmel */ 408 /* Maintainer: Atmel */
422 .timer = &at91sam926x_timer, 409 .timer = &at91sam926x_timer,
423 .map_io = at91_map_io, 410 .map_io = at91_map_io,
424 .handle_irq = at91_aic_handle_irq,
425 .init_early = ek_init_early, 411 .init_early = ek_init_early,
426 .init_irq = at91_init_irq_default, 412 .init_irq = at91_init_irq_default,
427 .init_machine = ek_board_init, 413 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c
index e4cc375e3a3..ad234ccbf57 100644
--- a/arch/arm/mach-at91/board-sam9m10g45ek.c
+++ b/arch/arm/mach-at91/board-sam9m10g45ek.c
@@ -14,7 +14,6 @@
14 */ 14 */
15 15
16#include <linux/types.h> 16#include <linux/types.h>
17#include <linux/gpio.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/mm.h> 18#include <linux/mm.h>
20#include <linux/module.h> 19#include <linux/module.h>
@@ -24,15 +23,11 @@
24#include <linux/gpio_keys.h> 23#include <linux/gpio_keys.h>
25#include <linux/input.h> 24#include <linux/input.h>
26#include <linux/leds.h> 25#include <linux/leds.h>
26#include <linux/clk.h>
27#include <linux/atmel-mci.h> 27#include <linux/atmel-mci.h>
28#include <linux/delay.h>
29
30#include <linux/platform_data/at91_adc.h>
31 28
32#include <mach/hardware.h> 29#include <mach/hardware.h>
33#include <video/atmel_lcdc.h> 30#include <video/atmel_lcdc.h>
34#include <media/soc_camera.h>
35#include <media/atmel-isi.h>
36 31
37#include <asm/setup.h> 32#include <asm/setup.h>
38#include <asm/mach-types.h> 33#include <asm/mach-types.h>
@@ -42,12 +37,12 @@
42#include <asm/mach/map.h> 37#include <asm/mach/map.h>
43#include <asm/mach/irq.h> 38#include <asm/mach/irq.h>
44 39
40#include <mach/board.h>
41#include <mach/gpio.h>
45#include <mach/at91sam9_smc.h> 42#include <mach/at91sam9_smc.h>
43#include <mach/at91_shdwc.h>
46#include <mach/system_rev.h> 44#include <mach/system_rev.h>
47 45
48#include "at91_aic.h"
49#include "at91_shdwc.h"
50#include "board.h"
51#include "sam9_smc.h" 46#include "sam9_smc.h"
52#include "generic.h" 47#include "generic.h"
53 48
@@ -56,6 +51,16 @@ static void __init ek_init_early(void)
56{ 51{
57 /* Initialize processor: 12.000 MHz crystal */ 52 /* Initialize processor: 12.000 MHz crystal */
58 at91_initialize(12000000); 53 at91_initialize(12000000);
54
55 /* DGBU on ttyS0. (Rx & Tx only) */
56 at91_register_uart(0, 0, 0);
57
58 /* USART0 not connected on the -EK board */
59 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
60 at91_register_uart(AT91SAM9G45_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
61
62 /* set serial console to ttyS0 (ie, DBGU) */
63 at91_set_serial_console(0);
59} 64}
60 65
61/* 66/*
@@ -64,8 +69,6 @@ static void __init ek_init_early(void)
64static struct at91_usbh_data __initdata ek_usbh_hs_data = { 69static struct at91_usbh_data __initdata ek_usbh_hs_data = {
65 .ports = 2, 70 .ports = 2,
66 .vbus_pin = {AT91_PIN_PD1, AT91_PIN_PD3}, 71 .vbus_pin = {AT91_PIN_PD1, AT91_PIN_PD3},
67 .vbus_pin_active_low = {1, 1},
68 .overcurrent_pin= {-EINVAL, -EINVAL},
69}; 72};
70 73
71 74
@@ -97,7 +100,6 @@ static struct mci_platform_data __initdata mci0_data = {
97 .slot[0] = { 100 .slot[0] = {
98 .bus_width = 4, 101 .bus_width = 4,
99 .detect_pin = AT91_PIN_PD10, 102 .detect_pin = AT91_PIN_PD10,
100 .wp_pin = -EINVAL,
101 }, 103 },
102}; 104};
103 105
@@ -113,7 +115,7 @@ static struct mci_platform_data __initdata mci1_data = {
113/* 115/*
114 * MACB Ethernet device 116 * MACB Ethernet device
115 */ 117 */
116static struct macb_platform_data __initdata ek_macb_data = { 118static struct at91_eth_data __initdata ek_macb_data = {
117 .phy_irq_pin = AT91_PIN_PD5, 119 .phy_irq_pin = AT91_PIN_PD5,
118 .is_rmii = 1, 120 .is_rmii = 1,
119}; 121};
@@ -135,17 +137,19 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
135 }, 137 },
136}; 138};
137 139
140static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
141{
142 *num_partitions = ARRAY_SIZE(ek_nand_partition);
143 return ek_nand_partition;
144}
145
138/* det_pin is not connected */ 146/* det_pin is not connected */
139static struct atmel_nand_data __initdata ek_nand_data = { 147static struct atmel_nand_data __initdata ek_nand_data = {
140 .ale = 21, 148 .ale = 21,
141 .cle = 22, 149 .cle = 22,
142 .rdy_pin = AT91_PIN_PC8, 150 .rdy_pin = AT91_PIN_PC8,
143 .enable_pin = AT91_PIN_PC14, 151 .enable_pin = AT91_PIN_PC14,
144 .det_pin = -EINVAL, 152 .partition_info = nand_partitions,
145 .ecc_mode = NAND_ECC_SOFT,
146 .on_flash_bbt = 1,
147 .parts = ek_nand_partition,
148 .num_parts = ARRAY_SIZE(ek_nand_partition),
149}; 153};
150 154
151static struct sam9_smc_config __initdata ek_nand_smc_config = { 155static struct sam9_smc_config __initdata ek_nand_smc_config = {
@@ -176,78 +180,13 @@ static void __init ek_add_device_nand(void)
176 ek_nand_smc_config.mode |= AT91_SMC_DBW_8; 180 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
177 181
178 /* configure chip-select 3 (NAND) */ 182 /* configure chip-select 3 (NAND) */
179 sam9_smc_configure(0, 3, &ek_nand_smc_config); 183 sam9_smc_configure(3, &ek_nand_smc_config);
180 184
181 at91_add_device_nand(&ek_nand_data); 185 at91_add_device_nand(&ek_nand_data);
182} 186}
183 187
184 188
185/* 189/*
186 * ISI
187 */
188static struct isi_platform_data __initdata isi_data = {
189 .frate = ISI_CFG1_FRATE_CAPTURE_ALL,
190 /* to use codec and preview path simultaneously */
191 .full_mode = 1,
192 .data_width_flags = ISI_DATAWIDTH_8 | ISI_DATAWIDTH_10,
193 /* ISI_MCK is provided by programmable clock or external clock */
194 .mck_hz = 25000000,
195};
196
197
198/*
199 * soc-camera OV2640
200 */
201#if defined(CONFIG_SOC_CAMERA_OV2640) || \
202 defined(CONFIG_SOC_CAMERA_OV2640_MODULE)
203static unsigned long isi_camera_query_bus_param(struct soc_camera_link *link)
204{
205 /* ISI board for ek using default 8-bits connection */
206 return SOCAM_DATAWIDTH_8;
207}
208
209static int i2c_camera_power(struct device *dev, int on)
210{
211 /* enable or disable the camera */
212 pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE");
213 at91_set_gpio_output(AT91_PIN_PD13, !on);
214
215 if (!on)
216 goto out;
217
218 /* If enabled, give a reset impulse */
219 at91_set_gpio_output(AT91_PIN_PD12, 0);
220 msleep(20);
221 at91_set_gpio_output(AT91_PIN_PD12, 1);
222 msleep(100);
223
224out:
225 return 0;
226}
227
228static struct i2c_board_info i2c_camera = {
229 I2C_BOARD_INFO("ov2640", 0x30),
230};
231
232static struct soc_camera_link iclink_ov2640 = {
233 .bus_id = 0,
234 .board_info = &i2c_camera,
235 .i2c_adapter_id = 0,
236 .power = i2c_camera_power,
237 .query_bus_param = isi_camera_query_bus_param,
238};
239
240static struct platform_device isi_ov2640 = {
241 .name = "soc-camera-pdrv",
242 .id = 0,
243 .dev = {
244 .platform_data = &iclink_ov2640,
245 },
246};
247#endif
248
249
250/*
251 * LCD Controller 190 * LCD Controller
252 */ 191 */
253#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) 192#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
@@ -308,14 +247,6 @@ static struct at91_tsadcc_data ek_tsadcc_data = {
308 .ts_sample_hold_time = 0x0a, 247 .ts_sample_hold_time = 0x0a,
309}; 248};
310 249
311/*
312 * ADCs
313 */
314static struct at91_adc_data ek_adc_data = {
315 .channels_used = BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | BIT(6) | BIT(7),
316 .use_external_triggers = true,
317 .vref = 3300,
318};
319 250
320/* 251/*
321 * GPIO Buttons 252 * GPIO Buttons
@@ -404,7 +335,6 @@ static void __init ek_add_device_buttons(void) {}
404 * reset_pin is not connected: NRST 335 * reset_pin is not connected: NRST
405 */ 336 */
406static struct ac97c_platform_data ek_ac97_data = { 337static struct ac97c_platform_data ek_ac97_data = {
407 .reset_pin = -EINVAL,
408}; 338};
409 339
410 340
@@ -448,22 +378,11 @@ static struct gpio_led ek_pwm_led[] = {
448#endif 378#endif
449}; 379};
450 380
451static struct platform_device *devices[] __initdata = { 381
452#if defined(CONFIG_SOC_CAMERA_OV2640) || \
453 defined(CONFIG_SOC_CAMERA_OV2640_MODULE)
454 &isi_ov2640,
455#endif
456};
457 382
458static void __init ek_board_init(void) 383static void __init ek_board_init(void)
459{ 384{
460 /* Serial */ 385 /* Serial */
461 /* DGBU on ttyS0. (Rx & Tx only) */
462 at91_register_uart(0, 0, 0);
463
464 /* USART0 not connected on the -EK board */
465 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
466 at91_register_uart(AT91SAM9G45_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
467 at91_add_device_serial(); 386 at91_add_device_serial();
468 /* USB HS Host */ 387 /* USB HS Host */
469 at91_add_device_usbh_ohci(&ek_usbh_hs_data); 388 at91_add_device_usbh_ohci(&ek_usbh_hs_data);
@@ -481,14 +400,10 @@ static void __init ek_board_init(void)
481 ek_add_device_nand(); 400 ek_add_device_nand();
482 /* I2C */ 401 /* I2C */
483 at91_add_device_i2c(0, NULL, 0); 402 at91_add_device_i2c(0, NULL, 0);
484 /* ISI, using programmable clock as ISI_MCK */
485 at91_add_device_isi(&isi_data, true);
486 /* LCD Controller */ 403 /* LCD Controller */
487 at91_add_device_lcdc(&ek_lcdc_data); 404 at91_add_device_lcdc(&ek_lcdc_data);
488 /* Touch Screen */ 405 /* Touch Screen */
489 at91_add_device_tsadcc(&ek_tsadcc_data); 406 at91_add_device_tsadcc(&ek_tsadcc_data);
490 /* ADC */
491 at91_add_device_adc(&ek_adc_data);
492 /* Push Buttons */ 407 /* Push Buttons */
493 ek_add_device_buttons(); 408 ek_add_device_buttons();
494 /* AC97 */ 409 /* AC97 */
@@ -496,15 +411,12 @@ static void __init ek_board_init(void)
496 /* LEDs */ 411 /* LEDs */
497 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); 412 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
498 at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led)); 413 at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led));
499 /* Other platform devices */
500 platform_add_devices(devices, ARRAY_SIZE(devices));
501} 414}
502 415
503MACHINE_START(AT91SAM9M10G45EK, "Atmel AT91SAM9M10G45-EK") 416MACHINE_START(AT91SAM9M10G45EK, "Atmel AT91SAM9M10G45-EK")
504 /* Maintainer: Atmel */ 417 /* Maintainer: Atmel */
505 .timer = &at91sam926x_timer, 418 .timer = &at91sam926x_timer,
506 .map_io = at91_map_io, 419 .map_io = at91_map_io,
507 .handle_irq = at91_aic_handle_irq,
508 .init_early = ek_init_early, 420 .init_early = ek_init_early,
509 .init_irq = at91_init_irq_default, 421 .init_irq = at91_init_irq_default,
510 .init_machine = ek_board_init, 422 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index 377a1097afa..4f14b54b93a 100644
--- a/arch/arm/mach-at91/board-sam9rlek.c
+++ b/arch/arm/mach-at91/board-sam9rlek.c
@@ -8,7 +8,6 @@
8 */ 8 */
9 9
10#include <linux/types.h> 10#include <linux/types.h>
11#include <linux/gpio.h>
12#include <linux/init.h> 11#include <linux/init.h>
13#include <linux/mm.h> 12#include <linux/mm.h>
14#include <linux/module.h> 13#include <linux/module.h>
@@ -30,12 +29,11 @@
30#include <asm/mach/irq.h> 29#include <asm/mach/irq.h>
31 30
32#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <mach/board.h>
33#include <mach/gpio.h>
33#include <mach/at91sam9_smc.h> 34#include <mach/at91sam9_smc.h>
35#include <mach/at91_shdwc.h>
34 36
35
36#include "at91_aic.h"
37#include "at91_shdwc.h"
38#include "board.h"
39#include "sam9_smc.h" 37#include "sam9_smc.h"
40#include "generic.h" 38#include "generic.h"
41 39
@@ -44,6 +42,15 @@ static void __init ek_init_early(void)
44{ 42{
45 /* Initialize processor: 12.000 MHz crystal */ 43 /* Initialize processor: 12.000 MHz crystal */
46 at91_initialize(12000000); 44 at91_initialize(12000000);
45
46 /* DBGU on ttyS0. (Rx & Tx only) */
47 at91_register_uart(0, 0, 0);
48
49 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
50 at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
51
52 /* set serial console to ttyS0 (ie, DBGU) */
53 at91_set_serial_console(0);
47} 54}
48 55
49/* 56/*
@@ -57,12 +64,11 @@ static struct usba_platform_data __initdata ek_usba_udc_data = {
57/* 64/*
58 * MCI (SD/MMC) 65 * MCI (SD/MMC)
59 */ 66 */
60static struct mci_platform_data __initdata mci0_data = { 67static struct at91_mmc_data __initdata ek_mmc_data = {
61 .slot[0] = { 68 .wire4 = 1,
62 .bus_width = 4, 69 .det_pin = AT91_PIN_PA15,
63 .detect_pin = AT91_PIN_PA15, 70// .wp_pin = ... not connected
64 .wp_pin = -EINVAL, 71// .vcc_pin = ... not connected
65 },
66}; 72};
67 73
68 74
@@ -82,16 +88,19 @@ static struct mtd_partition __initdata ek_nand_partition[] = {
82 }, 88 },
83}; 89};
84 90
91static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
92{
93 *num_partitions = ARRAY_SIZE(ek_nand_partition);
94 return ek_nand_partition;
95}
96
85static struct atmel_nand_data __initdata ek_nand_data = { 97static struct atmel_nand_data __initdata ek_nand_data = {
86 .ale = 21, 98 .ale = 21,
87 .cle = 22, 99 .cle = 22,
88 .det_pin = -EINVAL, 100// .det_pin = ... not connected
89 .rdy_pin = AT91_PIN_PD17, 101 .rdy_pin = AT91_PIN_PD17,
90 .enable_pin = AT91_PIN_PB6, 102 .enable_pin = AT91_PIN_PB6,
91 .ecc_mode = NAND_ECC_SOFT, 103 .partition_info = nand_partitions,
92 .on_flash_bbt = 1,
93 .parts = ek_nand_partition,
94 .num_parts = ARRAY_SIZE(ek_nand_partition),
95}; 104};
96 105
97static struct sam9_smc_config __initdata ek_nand_smc_config = { 106static struct sam9_smc_config __initdata ek_nand_smc_config = {
@@ -115,7 +124,7 @@ static struct sam9_smc_config __initdata ek_nand_smc_config = {
115static void __init ek_add_device_nand(void) 124static void __init ek_add_device_nand(void)
116{ 125{
117 /* configure chip-select 3 (NAND) */ 126 /* configure chip-select 3 (NAND) */
118 sam9_smc_configure(0, 3, &ek_nand_smc_config); 127 sam9_smc_configure(3, &ek_nand_smc_config);
119 128
120 at91_add_device_nand(&ek_nand_data); 129 at91_add_device_nand(&ek_nand_data);
121} 130}
@@ -200,7 +209,6 @@ static struct atmel_lcdfb_info __initdata ek_lcdc_data;
200 * reset_pin is not connected: NRST 209 * reset_pin is not connected: NRST
201 */ 210 */
202static struct ac97c_platform_data ek_ac97_data = { 211static struct ac97c_platform_data ek_ac97_data = {
203 .reset_pin = -EINVAL,
204}; 212};
205 213
206 214
@@ -290,11 +298,6 @@ static void __init ek_add_device_buttons(void) {}
290static void __init ek_board_init(void) 298static void __init ek_board_init(void)
291{ 299{
292 /* Serial */ 300 /* Serial */
293 /* DBGU on ttyS0. (Rx & Tx only) */
294 at91_register_uart(0, 0, 0);
295
296 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
297 at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
298 at91_add_device_serial(); 301 at91_add_device_serial();
299 /* USB HS */ 302 /* USB HS */
300 at91_add_device_usba(&ek_usba_udc_data); 303 at91_add_device_usba(&ek_usba_udc_data);
@@ -305,7 +308,7 @@ static void __init ek_board_init(void)
305 /* SPI */ 308 /* SPI */
306 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); 309 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
307 /* MMC */ 310 /* MMC */
308 at91_add_device_mci(0, &mci0_data); 311 at91_add_device_mmc(0, &ek_mmc_data);
309 /* LCD Controller */ 312 /* LCD Controller */
310 at91_add_device_lcdc(&ek_lcdc_data); 313 at91_add_device_lcdc(&ek_lcdc_data);
311 /* AC97 */ 314 /* AC97 */
@@ -322,7 +325,6 @@ MACHINE_START(AT91SAM9RLEK, "Atmel AT91SAM9RL-EK")
322 /* Maintainer: Atmel */ 325 /* Maintainer: Atmel */
323 .timer = &at91sam926x_timer, 326 .timer = &at91sam926x_timer,
324 .map_io = at91_map_io, 327 .map_io = at91_map_io,
325 .handle_irq = at91_aic_handle_irq,
326 .init_early = ek_init_early, 328 .init_early = ek_init_early,
327 .init_irq = at91_init_irq_default, 329 .init_irq = at91_init_irq_default,
328 .init_machine = ek_board_init, 330 .init_machine = ek_board_init,
diff --git a/arch/arm/mach-at91/board-snapper9260.c b/arch/arm/mach-at91/board-snapper9260.c
index 98771500ddb..c73d25e5fae 100644
--- a/arch/arm/mach-at91/board-snapper9260.c
+++ b/arch/arm/mach-at91/board-snapper9260.c
@@ -32,10 +32,9 @@
32#include <asm/mach/arch.h> 32#include <asm/mach/arch.h>
33 33
34#include <mach/hardware.h> 34#include <mach/hardware.h>
35#include <mach/board.h>
35#include <mach/at91sam9_smc.h> 36#include <mach/at91sam9_smc.h>
36 37
37#include "at91_aic.h"
38#include "board.h"
39#include "sam9_smc.h" 38#include "sam9_smc.h"
40#include "generic.h" 39#include "generic.h"
41 40
@@ -44,23 +43,29 @@
44static void __init snapper9260_init_early(void) 43static void __init snapper9260_init_early(void)
45{ 44{
46 at91_initialize(18432000); 45 at91_initialize(18432000);
46
47 /* Debug on ttyS0 */
48 at91_register_uart(0, 0, 0);
49 at91_set_serial_console(0);
50
51 at91_register_uart(AT91SAM9260_ID_US0, 1,
52 ATMEL_UART_CTS | ATMEL_UART_RTS);
53 at91_register_uart(AT91SAM9260_ID_US1, 2,
54 ATMEL_UART_CTS | ATMEL_UART_RTS);
55 at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
47} 56}
48 57
49static struct at91_usbh_data __initdata snapper9260_usbh_data = { 58static struct at91_usbh_data __initdata snapper9260_usbh_data = {
50 .ports = 2, 59 .ports = 2,
51 .vbus_pin = {-EINVAL, -EINVAL},
52 .overcurrent_pin= {-EINVAL, -EINVAL},
53}; 60};
54 61
55static struct at91_udc_data __initdata snapper9260_udc_data = { 62static struct at91_udc_data __initdata snapper9260_udc_data = {
56 .vbus_pin = SNAPPER9260_IO_EXP_GPIO(5), 63 .vbus_pin = SNAPPER9260_IO_EXP_GPIO(5),
57 .vbus_active_low = 1, 64 .vbus_active_low = 1,
58 .vbus_polled = 1, 65 .vbus_polled = 1,
59 .pullup_pin = -EINVAL,
60}; 66};
61 67
62static struct macb_platform_data snapper9260_macb_data = { 68static struct at91_eth_data snapper9260_macb_data = {
63 .phy_irq_pin = -EINVAL,
64 .is_rmii = 1, 69 .is_rmii = 1,
65}; 70};
66 71
@@ -92,16 +97,19 @@ static struct mtd_partition __initdata snapper9260_nand_partitions[] = {
92 }, 97 },
93}; 98};
94 99
100static struct mtd_partition * __init
101snapper9260_nand_partition_info(int size, int *num_partitions)
102{
103 *num_partitions = ARRAY_SIZE(snapper9260_nand_partitions);
104 return snapper9260_nand_partitions;
105}
106
95static struct atmel_nand_data __initdata snapper9260_nand_data = { 107static struct atmel_nand_data __initdata snapper9260_nand_data = {
96 .ale = 21, 108 .ale = 21,
97 .cle = 22, 109 .cle = 22,
98 .rdy_pin = AT91_PIN_PC13, 110 .rdy_pin = AT91_PIN_PC13,
99 .parts = snapper9260_nand_partitions, 111 .partition_info = snapper9260_nand_partition_info,
100 .num_parts = ARRAY_SIZE(snapper9260_nand_partitions),
101 .bus_width_16 = 0, 112 .bus_width_16 = 0,
102 .enable_pin = -EINVAL,
103 .det_pin = -EINVAL,
104 .ecc_mode = NAND_ECC_SOFT,
105}; 113};
106 114
107static struct sam9_smc_config __initdata snapper9260_nand_smc_config = { 115static struct sam9_smc_config __initdata snapper9260_nand_smc_config = {
@@ -137,17 +145,17 @@ static struct i2c_board_info __initdata snapper9260_i2c_devices[] = {
137 /* Audio codec */ 145 /* Audio codec */
138 I2C_BOARD_INFO("tlv320aic23", 0x1a), 146 I2C_BOARD_INFO("tlv320aic23", 0x1a),
139 }, 147 },
140}; 148 {
141
142static struct i2c_board_info __initdata snapper9260_i2c_isl1208 = {
143 /* RTC */ 149 /* RTC */
144 I2C_BOARD_INFO("isl1208", 0x6f), 150 I2C_BOARD_INFO("isl1208", 0x6f),
151 .irq = gpio_to_irq(AT91_PIN_PA31),
152 },
145}; 153};
146 154
147static void __init snapper9260_add_device_nand(void) 155static void __init snapper9260_add_device_nand(void)
148{ 156{
149 at91_set_A_periph(AT91_PIN_PC14, 0); 157 at91_set_A_periph(AT91_PIN_PC14, 0);
150 sam9_smc_configure(0, 3, &snapper9260_nand_smc_config); 158 sam9_smc_configure(3, &snapper9260_nand_smc_config);
151 at91_add_device_nand(&snapper9260_nand_data); 159 at91_add_device_nand(&snapper9260_nand_data);
152} 160}
153 161
@@ -155,18 +163,6 @@ static void __init snapper9260_board_init(void)
155{ 163{
156 at91_add_device_i2c(snapper9260_i2c_devices, 164 at91_add_device_i2c(snapper9260_i2c_devices,
157 ARRAY_SIZE(snapper9260_i2c_devices)); 165 ARRAY_SIZE(snapper9260_i2c_devices));
158
159 snapper9260_i2c_isl1208.irq = gpio_to_irq(AT91_PIN_PA31);
160 i2c_register_board_info(0, &snapper9260_i2c_isl1208, 1);
161
162 /* Debug on ttyS0 */
163 at91_register_uart(0, 0, 0);
164
165 at91_register_uart(AT91SAM9260_ID_US0, 1,
166 ATMEL_UART_CTS | ATMEL_UART_RTS);
167 at91_register_uart(AT91SAM9260_ID_US1, 2,
168 ATMEL_UART_CTS | ATMEL_UART_RTS);
169 at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
170 at91_add_device_serial(); 166 at91_add_device_serial();
171 at91_add_device_usbh(&snapper9260_usbh_data); 167 at91_add_device_usbh(&snapper9260_usbh_data);
172 at91_add_device_udc(&snapper9260_udc_data); 168 at91_add_device_udc(&snapper9260_udc_data);
@@ -179,7 +175,6 @@ static void __init snapper9260_board_init(void)
179MACHINE_START(SNAPPER_9260, "Bluewater Systems Snapper 9260/9G20 module") 175MACHINE_START(SNAPPER_9260, "Bluewater Systems Snapper 9260/9G20 module")
180 .timer = &at91sam926x_timer, 176 .timer = &at91sam926x_timer,
181 .map_io = at91_map_io, 177 .map_io = at91_map_io,
182 .handle_irq = at91_aic_handle_irq,
183 .init_early = snapper9260_init_early, 178 .init_early = snapper9260_init_early,
184 .init_irq = at91_init_irq_default, 179 .init_irq = at91_init_irq_default,
185 .init_machine = snapper9260_board_init, 180 .init_machine = snapper9260_board_init,
diff --git a/arch/arm/mach-at91/board-stamp9g20.c b/arch/arm/mach-at91/board-stamp9g20.c
index 48a962b61fa..936e5fd7f40 100644
--- a/arch/arm/mach-at91/board-stamp9g20.c
+++ b/arch/arm/mach-at91/board-stamp9g20.c
@@ -25,10 +25,9 @@
25#include <asm/mach-types.h> 25#include <asm/mach-types.h>
26#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
27 27
28#include <mach/board.h>
28#include <mach/at91sam9_smc.h> 29#include <mach/at91sam9_smc.h>
29 30
30#include "at91_aic.h"
31#include "board.h"
32#include "sam9_smc.h" 31#include "sam9_smc.h"
33#include "generic.h" 32#include "generic.h"
34 33
@@ -37,6 +36,44 @@ void __init stamp9g20_init_early(void)
37{ 36{
38 /* Initialize processor: 18.432 MHz crystal */ 37 /* Initialize processor: 18.432 MHz crystal */
39 at91_initialize(18432000); 38 at91_initialize(18432000);
39
40 /* DGBU on ttyS0. (Rx & Tx only) */
41 at91_register_uart(0, 0, 0);
42
43 /* set serial console to ttyS0 (ie, DBGU) */
44 at91_set_serial_console(0);
45}
46
47static void __init stamp9g20evb_init_early(void)
48{
49 stamp9g20_init_early();
50
51 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
52 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
53 | ATMEL_UART_DTR | ATMEL_UART_DSR
54 | ATMEL_UART_DCD | ATMEL_UART_RI);
55}
56
57static void __init portuxg20_init_early(void)
58{
59 stamp9g20_init_early();
60
61 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
62 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
63 | ATMEL_UART_DTR | ATMEL_UART_DSR
64 | ATMEL_UART_DCD | ATMEL_UART_RI);
65
66 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
67 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
68
69 /* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */
70 at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
71
72 /* USART4 on ttyS5. (Rx, Tx only) */
73 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
74
75 /* USART5 on ttyS6. (Rx, Tx only) */
76 at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
40} 77}
41 78
42/* 79/*
@@ -48,8 +85,6 @@ static struct atmel_nand_data __initdata nand_data = {
48 .rdy_pin = AT91_PIN_PC13, 85 .rdy_pin = AT91_PIN_PC13,
49 .enable_pin = AT91_PIN_PC14, 86 .enable_pin = AT91_PIN_PC14,
50 .bus_width_16 = 0, 87 .bus_width_16 = 0,
51 .det_pin = -EINVAL,
52 .ecc_mode = NAND_ECC_SOFT,
53}; 88};
54 89
55static struct sam9_smc_config __initdata nand_smc_config = { 90static struct sam9_smc_config __initdata nand_smc_config = {
@@ -73,7 +108,7 @@ static struct sam9_smc_config __initdata nand_smc_config = {
73static void __init add_device_nand(void) 108static void __init add_device_nand(void)
74{ 109{
75 /* configure chip-select 3 (NAND) */ 110 /* configure chip-select 3 (NAND) */
76 sam9_smc_configure(0, 3, &nand_smc_config); 111 sam9_smc_configure(3, &nand_smc_config);
77 112
78 at91_add_device_nand(&nand_data); 113 at91_add_device_nand(&nand_data);
79} 114}
@@ -83,13 +118,18 @@ static void __init add_device_nand(void)
83 * MCI (SD/MMC) 118 * MCI (SD/MMC)
84 * det_pin, wp_pin and vcc_pin are not connected 119 * det_pin, wp_pin and vcc_pin are not connected
85 */ 120 */
121#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
86static struct mci_platform_data __initdata mmc_data = { 122static struct mci_platform_data __initdata mmc_data = {
87 .slot[0] = { 123 .slot[0] = {
88 .bus_width = 4, 124 .bus_width = 4,
89 .detect_pin = -1,
90 .wp_pin = -1,
91 }, 125 },
92}; 126};
127#else
128static struct at91_mmc_data __initdata mmc_data = {
129 .slot_b = 0,
130 .wire4 = 1,
131};
132#endif
93 133
94 134
95/* 135/*
@@ -97,8 +137,6 @@ static struct mci_platform_data __initdata mmc_data = {
97 */ 137 */
98static struct at91_usbh_data __initdata usbh_data = { 138static struct at91_usbh_data __initdata usbh_data = {
99 .ports = 2, 139 .ports = 2,
100 .vbus_pin = {-EINVAL, -EINVAL},
101 .overcurrent_pin= {-EINVAL, -EINVAL},
102}; 140};
103 141
104 142
@@ -107,19 +145,19 @@ static struct at91_usbh_data __initdata usbh_data = {
107 */ 145 */
108static struct at91_udc_data __initdata portuxg20_udc_data = { 146static struct at91_udc_data __initdata portuxg20_udc_data = {
109 .vbus_pin = AT91_PIN_PC7, 147 .vbus_pin = AT91_PIN_PC7,
110 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 148 .pullup_pin = 0, /* pull-up driven by UDC */
111}; 149};
112 150
113static struct at91_udc_data __initdata stamp9g20evb_udc_data = { 151static struct at91_udc_data __initdata stamp9g20evb_udc_data = {
114 .vbus_pin = AT91_PIN_PA22, 152 .vbus_pin = AT91_PIN_PA22,
115 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 153 .pullup_pin = 0, /* pull-up driven by UDC */
116}; 154};
117 155
118 156
119/* 157/*
120 * MACB Ethernet device 158 * MACB Ethernet device
121 */ 159 */
122static struct macb_platform_data __initdata macb_data = { 160static struct at91_eth_data __initdata macb_data = {
123 .phy_irq_pin = AT91_PIN_PA28, 161 .phy_irq_pin = AT91_PIN_PA28,
124 .is_rmii = 1, 162 .is_rmii = 1,
125}; 163};
@@ -207,35 +245,21 @@ void add_w1(void)
207void __init stamp9g20_board_init(void) 245void __init stamp9g20_board_init(void)
208{ 246{
209 /* Serial */ 247 /* Serial */
210 /* DGBU on ttyS0. (Rx & Tx only) */
211 at91_register_uart(0, 0, 0);
212 at91_add_device_serial(); 248 at91_add_device_serial();
213 /* NAND */ 249 /* NAND */
214 add_device_nand(); 250 add_device_nand();
215 /* MMC */ 251 /* MMC */
252#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
216 at91_add_device_mci(0, &mmc_data); 253 at91_add_device_mci(0, &mmc_data);
254#else
255 at91_add_device_mmc(0, &mmc_data);
256#endif
217 /* W1 */ 257 /* W1 */
218 add_w1(); 258 add_w1();
219} 259}
220 260
221static void __init portuxg20_board_init(void) 261static void __init portuxg20_board_init(void)
222{ 262{
223 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
224 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
225 | ATMEL_UART_DTR | ATMEL_UART_DSR
226 | ATMEL_UART_DCD | ATMEL_UART_RI);
227
228 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
229 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
230
231 /* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */
232 at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
233
234 /* USART4 on ttyS5. (Rx, Tx only) */
235 at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
236
237 /* USART5 on ttyS6. (Rx, Tx only) */
238 at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
239 stamp9g20_board_init(); 263 stamp9g20_board_init();
240 /* USB Host */ 264 /* USB Host */
241 at91_add_device_usbh(&usbh_data); 265 at91_add_device_usbh(&usbh_data);
@@ -253,10 +277,6 @@ static void __init portuxg20_board_init(void)
253 277
254static void __init stamp9g20evb_board_init(void) 278static void __init stamp9g20evb_board_init(void)
255{ 279{
256 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
257 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
258 | ATMEL_UART_DTR | ATMEL_UART_DSR
259 | ATMEL_UART_DCD | ATMEL_UART_RI);
260 stamp9g20_board_init(); 280 stamp9g20_board_init();
261 /* USB Host */ 281 /* USB Host */
262 at91_add_device_usbh(&usbh_data); 282 at91_add_device_usbh(&usbh_data);
@@ -274,8 +294,7 @@ MACHINE_START(PORTUXG20, "taskit PortuxG20")
274 /* Maintainer: taskit GmbH */ 294 /* Maintainer: taskit GmbH */
275 .timer = &at91sam926x_timer, 295 .timer = &at91sam926x_timer,
276 .map_io = at91_map_io, 296 .map_io = at91_map_io,
277 .handle_irq = at91_aic_handle_irq, 297 .init_early = portuxg20_init_early,
278 .init_early = stamp9g20_init_early,
279 .init_irq = at91_init_irq_default, 298 .init_irq = at91_init_irq_default,
280 .init_machine = portuxg20_board_init, 299 .init_machine = portuxg20_board_init,
281MACHINE_END 300MACHINE_END
@@ -284,8 +303,7 @@ MACHINE_START(STAMP9G20, "taskit Stamp9G20")
284 /* Maintainer: taskit GmbH */ 303 /* Maintainer: taskit GmbH */
285 .timer = &at91sam926x_timer, 304 .timer = &at91sam926x_timer,
286 .map_io = at91_map_io, 305 .map_io = at91_map_io,
287 .handle_irq = at91_aic_handle_irq, 306 .init_early = stamp9g20evb_init_early,
288 .init_early = stamp9g20_init_early,
289 .init_irq = at91_init_irq_default, 307 .init_irq = at91_init_irq_default,
290 .init_machine = stamp9g20evb_board_init, 308 .init_machine = stamp9g20evb_board_init,
291MACHINE_END 309MACHINE_END
diff --git a/arch/arm/mach-at91/board-usb-a926x.c b/arch/arm/mach-at91/board-usb-a926x.c
deleted file mode 100644
index c1060f96e58..00000000000
--- a/arch/arm/mach-at91/board-usb-a926x.c
+++ /dev/null
@@ -1,384 +0,0 @@
1/*
2 * linux/arch/arm/mach-at91/board-usb-a926x.c
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2007 Atmel Corporation.
6 * Copyright (C) 2007 Calao-systems
7 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <linux/types.h>
25#include <linux/init.h>
26#include <linux/mm.h>
27#include <linux/module.h>
28#include <linux/platform_device.h>
29#include <linux/spi/spi.h>
30#include <linux/gpio_keys.h>
31#include <linux/gpio.h>
32#include <linux/input.h>
33#include <linux/spi/mmc_spi.h>
34
35#include <asm/setup.h>
36#include <asm/mach-types.h>
37#include <asm/irq.h>
38
39#include <asm/mach/arch.h>
40#include <asm/mach/map.h>
41#include <asm/mach/irq.h>
42
43#include <mach/hardware.h>
44#include <mach/at91sam9_smc.h>
45
46#include "at91_aic.h"
47#include "at91_shdwc.h"
48#include "board.h"
49#include "sam9_smc.h"
50#include "generic.h"
51
52
53static void __init ek_init_early(void)
54{
55 /* Initialize processor: 12.00 MHz crystal */
56 at91_initialize(12000000);
57}
58
59/*
60 * USB Host port
61 */
62static struct at91_usbh_data __initdata ek_usbh_data = {
63 .ports = 2,
64 .vbus_pin = {-EINVAL, -EINVAL},
65 .overcurrent_pin= {-EINVAL, -EINVAL},
66};
67
68/*
69 * USB Device port
70 */
71static struct at91_udc_data __initdata ek_udc_data = {
72 .vbus_pin = AT91_PIN_PB11,
73 .pullup_pin = -EINVAL, /* pull-up driven by UDC */
74};
75
76static void __init ek_add_device_udc(void)
77{
78 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
79 ek_udc_data.vbus_pin = AT91_PIN_PC5;
80
81 at91_add_device_udc(&ek_udc_data);
82}
83
84#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
85#define MMC_SPI_CARD_DETECT_INT AT91_PIN_PC4
86static int at91_mmc_spi_init(struct device *dev,
87 irqreturn_t (*detect_int)(int, void *), void *data)
88{
89 /* Configure Interrupt pin as input, no pull-up */
90 at91_set_gpio_input(MMC_SPI_CARD_DETECT_INT, 0);
91 return request_irq(gpio_to_irq(MMC_SPI_CARD_DETECT_INT), detect_int,
92 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
93 "mmc-spi-detect", data);
94}
95
96static void at91_mmc_spi_exit(struct device *dev, void *data)
97{
98 free_irq(gpio_to_irq(MMC_SPI_CARD_DETECT_INT), data);
99}
100
101static struct mmc_spi_platform_data at91_mmc_spi_pdata = {
102 .init = at91_mmc_spi_init,
103 .exit = at91_mmc_spi_exit,
104 .detect_delay = 100, /* msecs */
105};
106#endif
107
108/*
109 * SPI devices.
110 */
111static struct spi_board_info usb_a9263_spi_devices[] = {
112 { /* DataFlash chip */
113 .modalias = "mtd_dataflash",
114 .chip_select = 0,
115 .max_speed_hz = 15 * 1000 * 1000,
116 .bus_num = 0,
117 }
118};
119
120static struct spi_board_info usb_a9g20_spi_devices[] = {
121#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
122 {
123 .modalias = "mmc_spi",
124 .max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
125 .bus_num = 1,
126 .chip_select = 0,
127 .platform_data = &at91_mmc_spi_pdata,
128 .mode = SPI_MODE_3,
129 },
130#endif
131};
132
133static void __init ek_add_device_spi(void)
134{
135 if (machine_is_usb_a9263())
136 at91_add_device_spi(usb_a9263_spi_devices, ARRAY_SIZE(usb_a9263_spi_devices));
137 else if (machine_is_usb_a9g20())
138 at91_add_device_spi(usb_a9g20_spi_devices, ARRAY_SIZE(usb_a9g20_spi_devices));
139}
140
141/*
142 * MACB Ethernet device
143 */
144static struct macb_platform_data __initdata ek_macb_data = {
145 .phy_irq_pin = AT91_PIN_PE31,
146 .is_rmii = 1,
147};
148
149static void __init ek_add_device_eth(void)
150{
151 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
152 ek_macb_data.phy_irq_pin = AT91_PIN_PA31;
153
154 at91_add_device_eth(&ek_macb_data);
155}
156
157/*
158 * NAND flash
159 */
160static struct mtd_partition __initdata ek_nand_partition[] = {
161 {
162 .name = "barebox",
163 .offset = 0,
164 .size = 3 * SZ_128K,
165 }, {
166 .name = "bareboxenv",
167 .offset = MTDPART_OFS_NXTBLK,
168 .size = SZ_128K,
169 }, {
170 .name = "bareboxenv2",
171 .offset = MTDPART_OFS_NXTBLK,
172 .size = SZ_128K,
173 }, {
174 .name = "oftree",
175 .offset = MTDPART_OFS_NXTBLK,
176 .size = SZ_128K,
177 }, {
178 .name = "kernel",
179 .offset = MTDPART_OFS_NXTBLK,
180 .size = 4 * SZ_1M,
181 }, {
182 .name = "rootfs",
183 .offset = MTDPART_OFS_NXTBLK,
184 .size = 120 * SZ_1M,
185 }, {
186 .name = "data",
187 .offset = MTDPART_OFS_NXTBLK,
188 .size = MTDPART_SIZ_FULL,
189 }
190};
191
192static struct atmel_nand_data __initdata ek_nand_data = {
193 .ale = 21,
194 .cle = 22,
195 .det_pin = -EINVAL,
196 .rdy_pin = AT91_PIN_PA22,
197 .enable_pin = AT91_PIN_PD15,
198 .ecc_mode = NAND_ECC_SOFT,
199 .on_flash_bbt = 1,
200 .parts = ek_nand_partition,
201 .num_parts = ARRAY_SIZE(ek_nand_partition),
202};
203
204static struct sam9_smc_config __initdata usb_a9260_nand_smc_config = {
205 .ncs_read_setup = 0,
206 .nrd_setup = 1,
207 .ncs_write_setup = 0,
208 .nwe_setup = 1,
209
210 .ncs_read_pulse = 3,
211 .nrd_pulse = 3,
212 .ncs_write_pulse = 3,
213 .nwe_pulse = 3,
214
215 .read_cycle = 5,
216 .write_cycle = 5,
217
218 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
219 .tdf_cycles = 2,
220};
221
222static struct sam9_smc_config __initdata usb_a9g20_nand_smc_config = {
223 .ncs_read_setup = 0,
224 .nrd_setup = 2,
225 .ncs_write_setup = 0,
226 .nwe_setup = 2,
227
228 .ncs_read_pulse = 4,
229 .nrd_pulse = 4,
230 .ncs_write_pulse = 4,
231 .nwe_pulse = 4,
232
233 .read_cycle = 7,
234 .write_cycle = 7,
235
236 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
237 .tdf_cycles = 3,
238};
239
240static void __init ek_add_device_nand(void)
241{
242 if (machine_is_usb_a9260() || machine_is_usb_a9g20()) {
243 ek_nand_data.rdy_pin = AT91_PIN_PC13;
244 ek_nand_data.enable_pin = AT91_PIN_PC14;
245 }
246
247 /* configure chip-select 3 (NAND) */
248 if (machine_is_usb_a9g20())
249 sam9_smc_configure(0, 3, &usb_a9g20_nand_smc_config);
250 else
251 sam9_smc_configure(0, 3, &usb_a9260_nand_smc_config);
252
253 at91_add_device_nand(&ek_nand_data);
254}
255
256
257/*
258 * GPIO Buttons
259 */
260#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
261static struct gpio_keys_button ek_buttons[] = {
262 { /* USER PUSH BUTTON */
263 .code = KEY_ENTER,
264 .gpio = AT91_PIN_PB10,
265 .active_low = 1,
266 .desc = "user_pb",
267 .wakeup = 1,
268 }
269};
270
271static struct gpio_keys_platform_data ek_button_data = {
272 .buttons = ek_buttons,
273 .nbuttons = ARRAY_SIZE(ek_buttons),
274};
275
276static struct platform_device ek_button_device = {
277 .name = "gpio-keys",
278 .id = -1,
279 .num_resources = 0,
280 .dev = {
281 .platform_data = &ek_button_data,
282 }
283};
284
285static void __init ek_add_device_buttons(void)
286{
287 at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* user push button, pull up enabled */
288 at91_set_deglitch(AT91_PIN_PB10, 1);
289
290 platform_device_register(&ek_button_device);
291}
292#else
293static void __init ek_add_device_buttons(void) {}
294#endif
295
296/*
297 * LEDs
298 */
299static struct gpio_led ek_leds[] = {
300 { /* user_led (green) */
301 .name = "user_led",
302 .gpio = AT91_PIN_PB21,
303 .active_low = 1,
304 .default_trigger = "heartbeat",
305 }
306};
307
308static struct i2c_board_info __initdata ek_i2c_devices[] = {
309 {
310 I2C_BOARD_INFO("rv3029c2", 0x56),
311 },
312};
313
314static void __init ek_add_device_leds(void)
315{
316 if (machine_is_usb_a9260() || machine_is_usb_a9g20())
317 ek_leds[0].active_low = 0;
318
319 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
320}
321
322static void __init ek_board_init(void)
323{
324 /* Serial */
325 /* DBGU on ttyS0. (Rx & Tx only) */
326 at91_register_uart(0, 0, 0);
327 at91_add_device_serial();
328 /* USB Host */
329 at91_add_device_usbh(&ek_usbh_data);
330 /* USB Device */
331 ek_add_device_udc();
332 /* SPI */
333 ek_add_device_spi();
334 /* Ethernet */
335 ek_add_device_eth();
336 /* NAND */
337 ek_add_device_nand();
338 /* Push Buttons */
339 ek_add_device_buttons();
340 /* LEDs */
341 ek_add_device_leds();
342
343 if (machine_is_usb_a9g20()) {
344 /* I2C */
345 at91_add_device_i2c(ek_i2c_devices, ARRAY_SIZE(ek_i2c_devices));
346 } else {
347 /* I2C */
348 at91_add_device_i2c(NULL, 0);
349 /* shutdown controller, wakeup button (5 msec low) */
350 at91_shdwc_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10)
351 | AT91_SHDW_WKMODE0_LOW
352 | AT91_SHDW_RTTWKEN);
353 }
354}
355
356MACHINE_START(USB_A9263, "CALAO USB_A9263")
357 /* Maintainer: calao-systems */
358 .timer = &at91sam926x_timer,
359 .map_io = at91_map_io,
360 .handle_irq = at91_aic_handle_irq,
361 .init_early = ek_init_early,
362 .init_irq = at91_init_irq_default,
363 .init_machine = ek_board_init,
364MACHINE_END
365
366MACHINE_START(USB_A9260, "CALAO USB_A9260")
367 /* Maintainer: calao-systems */
368 .timer = &at91sam926x_timer,
369 .map_io = at91_map_io,
370 .handle_irq = at91_aic_handle_irq,
371 .init_early = ek_init_early,
372 .init_irq = at91_init_irq_default,
373 .init_machine = ek_board_init,
374MACHINE_END
375
376MACHINE_START(USB_A9G20, "CALAO USB_A92G0")
377 /* Maintainer: Jean-Christophe PLAGNIOL-VILLARD */
378 .timer = &at91sam926x_timer,
379 .map_io = at91_map_io,
380 .handle_irq = at91_aic_handle_irq,
381 .init_early = ek_init_early,
382 .init_irq = at91_init_irq_default,
383 .init_machine = ek_board_init,
384MACHINE_END
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
index 8673aebcb85..95edcbd2aec 100644
--- a/arch/arm/mach-at91/board-yl-9200.c
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -22,7 +22,6 @@
22 */ 22 */
23 23
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/gpio.h>
26#include <linux/init.h> 25#include <linux/init.h>
27#include <linux/mm.h> 26#include <linux/mm.h>
28#include <linux/module.h> 27#include <linux/module.h>
@@ -43,12 +42,11 @@
43#include <asm/mach/irq.h> 42#include <asm/mach/irq.h>
44 43
45#include <mach/hardware.h> 44#include <mach/hardware.h>
45#include <mach/board.h>
46#include <mach/gpio.h>
46#include <mach/at91rm9200_mc.h> 47#include <mach/at91rm9200_mc.h>
47#include <mach/at91_ramc.h>
48#include <mach/cpu.h> 48#include <mach/cpu.h>
49 49
50#include "at91_aic.h"
51#include "board.h"
52#include "generic.h" 50#include "generic.h"
53 51
54 52
@@ -59,6 +57,26 @@ static void __init yl9200_init_early(void)
59 57
60 /* Initialize processor: 18.432 MHz crystal */ 58 /* Initialize processor: 18.432 MHz crystal */
61 at91_initialize(18432000); 59 at91_initialize(18432000);
60
61 /* Setup the LEDs D2=PB17 (timer), D3=PB16 (cpu) */
62 at91_init_leds(AT91_PIN_PB16, AT91_PIN_PB17);
63
64 /* DBGU on ttyS0. (Rx & Tx only) */
65 at91_register_uart(0, 0, 0);
66
67 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
68 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
69 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
70 | ATMEL_UART_RI);
71
72 /* USART0 on ttyS2. (Rx & Tx only to JP3) */
73 at91_register_uart(AT91RM9200_ID_US0, 2, 0);
74
75 /* USART3 on ttyS3. (Rx, Tx, RTS - RS485 interface) */
76 at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_RTS);
77
78 /* set serial console to ttyS0 (ie, DBGU) */
79 at91_set_serial_console(0);
62} 80}
63 81
64/* 82/*
@@ -92,7 +110,7 @@ static struct gpio_led yl9200_leds[] = {
92/* 110/*
93 * Ethernet 111 * Ethernet
94 */ 112 */
95static struct macb_platform_data __initdata yl9200_eth_data = { 113static struct at91_eth_data __initdata yl9200_eth_data = {
96 .phy_irq_pin = AT91_PIN_PB28, 114 .phy_irq_pin = AT91_PIN_PB28,
97 .is_rmii = 1, 115 .is_rmii = 1,
98}; 116};
@@ -102,8 +120,6 @@ static struct macb_platform_data __initdata yl9200_eth_data = {
102 */ 120 */
103static struct at91_usbh_data __initdata yl9200_usbh_data = { 121static struct at91_usbh_data __initdata yl9200_usbh_data = {
104 .ports = 1, /* PQFP version of AT91RM9200 */ 122 .ports = 1, /* PQFP version of AT91RM9200 */
105 .vbus_pin = {-EINVAL, -EINVAL},
106 .overcurrent_pin= {-EINVAL, -EINVAL},
107}; 123};
108 124
109/* 125/*
@@ -119,12 +135,10 @@ static struct at91_udc_data __initdata yl9200_udc_data = {
119/* 135/*
120 * MMC 136 * MMC
121 */ 137 */
122static struct mci_platform_data __initdata yl9200_mci0_data = { 138static struct at91_mmc_data __initdata yl9200_mmc_data = {
123 .slot[0] = { 139 .det_pin = AT91_PIN_PB9,
124 .bus_width = 4, 140 // .wp_pin = ... not connected
125 .detect_pin = AT91_PIN_PB9, 141 .wire4 = 1,
126 .wp_pin = -EINVAL,
127 },
128}; 142};
129 143
130/* 144/*
@@ -158,15 +172,19 @@ static struct mtd_partition __initdata yl9200_nand_partition[] = {
158 } 172 }
159}; 173};
160 174
175static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
176{
177 *num_partitions = ARRAY_SIZE(yl9200_nand_partition);
178 return yl9200_nand_partition;
179}
180
161static struct atmel_nand_data __initdata yl9200_nand_data = { 181static struct atmel_nand_data __initdata yl9200_nand_data = {
162 .ale = 6, 182 .ale = 6,
163 .cle = 7, 183 .cle = 7,
164 .det_pin = -EINVAL, 184 // .det_pin = ... not connected
165 .rdy_pin = AT91_PIN_PC14, /* R/!B (Sheet10) */ 185 .rdy_pin = AT91_PIN_PC14, /* R/!B (Sheet10) */
166 .enable_pin = AT91_PIN_PC15, /* !CE (Sheet10) */ 186 .enable_pin = AT91_PIN_PC15, /* !CE (Sheet10) */
167 .ecc_mode = NAND_ECC_SOFT, 187 .partition_info = nand_partitions,
168 .parts = yl9200_nand_partition,
169 .num_parts = ARRAY_SIZE(yl9200_nand_partition),
170}; 188};
171 189
172/* 190/*
@@ -371,13 +389,13 @@ static struct spi_board_info yl9200_spi_devices[] = {
371#include <video/s1d13xxxfb.h> 389#include <video/s1d13xxxfb.h>
372 390
373 391
374static void yl9200_init_video(void) 392static void __init yl9200_init_video(void)
375{ 393{
376 /* NWAIT Signal */ 394 /* NWAIT Signal */
377 at91_set_A_periph(AT91_PIN_PC6, 0); 395 at91_set_A_periph(AT91_PIN_PC6, 0);
378 396
379 /* Initialization of the Static Memory Controller for Chip Select 2 */ 397 /* Initialization of the Static Memory Controller for Chip Select 2 */
380 at91_ramc_write(0, AT91_SMC_CSR(2), AT91_SMC_DBW_16 /* 16 bit */ 398 at91_sys_write(AT91_SMC_CSR(2), AT91_SMC_DBW_16 /* 16 bit */
381 | AT91_SMC_WSEN | AT91_SMC_NWS_(0x4) /* wait states */ 399 | AT91_SMC_WSEN | AT91_SMC_NWS_(0x4) /* wait states */
382 | AT91_SMC_TDF_(0x100) /* float time */ 400 | AT91_SMC_TDF_(0x100) /* float time */
383 ); 401 );
@@ -543,19 +561,6 @@ void __init yl9200_add_device_video(void) {}
543static void __init yl9200_board_init(void) 561static void __init yl9200_board_init(void)
544{ 562{
545 /* Serial */ 563 /* Serial */
546 /* DBGU on ttyS0. (Rx & Tx only) */
547 at91_register_uart(0, 0, 0);
548
549 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
550 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
551 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
552 | ATMEL_UART_RI);
553
554 /* USART0 on ttyS2. (Rx & Tx only to JP3) */
555 at91_register_uart(AT91RM9200_ID_US0, 2, 0);
556
557 /* USART3 on ttyS3. (Rx, Tx, RTS - RS485 interface) */
558 at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_RTS);
559 at91_add_device_serial(); 564 at91_add_device_serial();
560 /* Ethernet */ 565 /* Ethernet */
561 at91_add_device_eth(&yl9200_eth_data); 566 at91_add_device_eth(&yl9200_eth_data);
@@ -566,7 +571,7 @@ static void __init yl9200_board_init(void)
566 /* I2C */ 571 /* I2C */
567 at91_add_device_i2c(yl9200_i2c_devices, ARRAY_SIZE(yl9200_i2c_devices)); 572 at91_add_device_i2c(yl9200_i2c_devices, ARRAY_SIZE(yl9200_i2c_devices));
568 /* MMC */ 573 /* MMC */
569 at91_add_device_mci(0, &yl9200_mci0_data); 574 at91_add_device_mmc(0, &yl9200_mmc_data);
570 /* NAND */ 575 /* NAND */
571 at91_add_device_nand(&yl9200_nand_data); 576 at91_add_device_nand(&yl9200_nand_data);
572 /* NOR Flash */ 577 /* NOR Flash */
@@ -589,7 +594,6 @@ MACHINE_START(YL9200, "uCdragon YL-9200")
589 /* Maintainer: S.Birtles */ 594 /* Maintainer: S.Birtles */
590 .timer = &at91rm9200_timer, 595 .timer = &at91rm9200_timer,
591 .map_io = at91_map_io, 596 .map_io = at91_map_io,
592 .handle_irq = at91_aic_handle_irq,
593 .init_early = yl9200_init_early, 597 .init_early = yl9200_init_early,
594 .init_irq = at91_init_irq_default, 598 .init_irq = at91_init_irq_default,
595 .init_machine = yl9200_board_init, 599 .init_machine = yl9200_board_init,
diff --git a/arch/arm/mach-at91/board.h b/arch/arm/mach-at91/board.h
deleted file mode 100644
index 4a234fb2ab3..00000000000
--- a/arch/arm/mach-at91/board.h
+++ /dev/null
@@ -1,131 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/board.h
3 *
4 * Copyright (C) 2005 HP Labs
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * These are data structures found in platform_device.dev.platform_data,
23 * and describing board-specific data needed by drivers. For example,
24 * which pin is used for a given GPIO role.
25 *
26 * In 2.6, drivers should strongly avoid board-specific knowledge so
27 * that supporting new boards normally won't require driver patches.
28 * Most board-specific knowledge should be in arch/.../board-*.c files.
29 */
30
31#ifndef __ASM_ARCH_BOARD_H
32#define __ASM_ARCH_BOARD_H
33
34#include <linux/platform_data/atmel.h>
35
36 /* USB Device */
37extern void __init at91_add_device_udc(struct at91_udc_data *data);
38
39 /* USB High Speed Device */
40extern void __init at91_add_device_usba(struct usba_platform_data *data);
41
42 /* Compact Flash */
43extern void __init at91_add_device_cf(struct at91_cf_data *data);
44
45 /* MMC / SD */
46 /* atmel-mci platform config */
47extern void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data);
48
49extern void __init at91_add_device_eth(struct macb_platform_data *data);
50
51 /* USB Host */
52extern void __init at91_add_device_usbh(struct at91_usbh_data *data);
53extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data);
54extern void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data);
55
56extern void __init at91_add_device_nand(struct atmel_nand_data *data);
57
58 /* I2C*/
59#if defined(CONFIG_ARCH_AT91SAM9G45)
60extern void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices);
61#else
62extern void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices);
63#endif
64
65 /* SPI */
66extern void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices);
67
68 /* Serial */
69#define ATMEL_UART_CTS 0x01
70#define ATMEL_UART_RTS 0x02
71#define ATMEL_UART_DSR 0x04
72#define ATMEL_UART_DTR 0x08
73#define ATMEL_UART_DCD 0x10
74#define ATMEL_UART_RI 0x20
75
76extern void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins);
77
78extern struct platform_device *atmel_default_console_device;
79
80extern void __init at91_add_device_serial(void);
81
82/*
83 * PWM
84 */
85#define AT91_PWM0 0
86#define AT91_PWM1 1
87#define AT91_PWM2 2
88#define AT91_PWM3 3
89
90extern void __init at91_add_device_pwm(u32 mask);
91
92/*
93 * SSC -- accessed through ssc_request(id). Drivers don't bind to SSC
94 * platform devices. Their SSC ID is part of their configuration data,
95 * along with information about which SSC signals they should use.
96 */
97#define ATMEL_SSC_TK 0x01
98#define ATMEL_SSC_TF 0x02
99#define ATMEL_SSC_TD 0x04
100#define ATMEL_SSC_TX (ATMEL_SSC_TK | ATMEL_SSC_TF | ATMEL_SSC_TD)
101
102#define ATMEL_SSC_RK 0x10
103#define ATMEL_SSC_RF 0x20
104#define ATMEL_SSC_RD 0x40
105#define ATMEL_SSC_RX (ATMEL_SSC_RK | ATMEL_SSC_RF | ATMEL_SSC_RD)
106
107extern void __init at91_add_device_ssc(unsigned id, unsigned pins);
108
109 /* LCD Controller */
110struct atmel_lcdfb_info;
111extern void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data);
112
113 /* AC97 */
114extern void __init at91_add_device_ac97(struct ac97c_platform_data *data);
115
116 /* ISI */
117struct isi_platform_data;
118extern void __init at91_add_device_isi(struct isi_platform_data *data,
119 bool use_pck_as_mck);
120
121 /* Touchscreen Controller */
122extern void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data);
123
124/* CAN */
125extern void __init at91_add_device_can(struct at91_can_data *data);
126
127 /* LEDs */
128extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
129extern void __init at91_pwm_leds(struct gpio_led *leds, int nr);
130
131#endif
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index 33361505c0c..61873f3aa92 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -23,19 +23,14 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/clk.h> 24#include <linux/clk.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/of_address.h>
27 26
28#include <mach/hardware.h> 27#include <mach/hardware.h>
29#include <mach/at91_pmc.h> 28#include <mach/at91_pmc.h>
30#include <mach/cpu.h> 29#include <mach/cpu.h>
31 30
32#include <asm/proc-fns.h>
33
34#include "clock.h" 31#include "clock.h"
35#include "generic.h" 32#include "generic.h"
36 33
37void __iomem *at91_pmc_base;
38EXPORT_SYMBOL_GPL(at91_pmc_base);
39 34
40/* 35/*
41 * There's a lot more which can be done with clocks, including cpufreq 36 * There's a lot more which can be done with clocks, including cpufreq
@@ -52,49 +47,26 @@ EXPORT_SYMBOL_GPL(at91_pmc_base);
52/* 47/*
53 * Chips have some kind of clocks : group them by functionality 48 * Chips have some kind of clocks : group them by functionality
54 */ 49 */
55#define cpu_has_utmi() ( cpu_is_at91sam9rl() \ 50#define cpu_has_utmi() ( cpu_is_at91cap9() \
56 || cpu_is_at91sam9g45() \ 51 || cpu_is_at91sam9rl() \
57 || cpu_is_at91sam9x5()) 52 || cpu_is_at91sam9g45())
58 53
59#define cpu_has_800M_plla() ( cpu_is_at91sam9g20() \ 54#define cpu_has_800M_plla() ( cpu_is_at91sam9g20() \
60 || cpu_is_at91sam9g45() \ 55 || cpu_is_at91sam9g45())
61 || cpu_is_at91sam9x5() \
62 || cpu_is_at91sam9n12())
63 56
64#define cpu_has_300M_plla() (cpu_is_at91sam9g10()) 57#define cpu_has_300M_plla() (cpu_is_at91sam9g10())
65 58
66#define cpu_has_240M_plla() (cpu_is_at91sam9261() \
67 || cpu_is_at91sam9263() \
68 || cpu_is_at91sam9rl())
69
70#define cpu_has_210M_plla() (cpu_is_at91sam9260())
71
72#define cpu_has_pllb() (!(cpu_is_at91sam9rl() \ 59#define cpu_has_pllb() (!(cpu_is_at91sam9rl() \
73 || cpu_is_at91sam9g45() \ 60 || cpu_is_at91sam9g45()))
74 || cpu_is_at91sam9x5() \
75 || cpu_is_at91sam9n12()))
76 61
77#define cpu_has_upll() (cpu_is_at91sam9g45() \ 62#define cpu_has_upll() (cpu_is_at91sam9g45())
78 || cpu_is_at91sam9x5())
79 63
80/* USB host HS & FS */ 64/* USB host HS & FS */
81#define cpu_has_uhp() (!cpu_is_at91sam9rl()) 65#define cpu_has_uhp() (!cpu_is_at91sam9rl())
82 66
83/* USB device FS only */ 67/* USB device FS only */
84#define cpu_has_udpfs() (!(cpu_is_at91sam9rl() \ 68#define cpu_has_udpfs() (!(cpu_is_at91sam9rl() \
85 || cpu_is_at91sam9g45() \ 69 || cpu_is_at91sam9g45()))
86 || cpu_is_at91sam9x5()))
87
88#define cpu_has_plladiv2() (cpu_is_at91sam9g45() \
89 || cpu_is_at91sam9x5() \
90 || cpu_is_at91sam9n12())
91
92#define cpu_has_mdiv3() (cpu_is_at91sam9g45() \
93 || cpu_is_at91sam9x5() \
94 || cpu_is_at91sam9n12())
95
96#define cpu_has_alt_prescaler() (cpu_is_at91sam9x5() \
97 || cpu_is_at91sam9n12())
98 70
99static LIST_HEAD(clocks); 71static LIST_HEAD(clocks);
100static DEFINE_SPINLOCK(clk_lock); 72static DEFINE_SPINLOCK(clk_lock);
@@ -139,11 +111,11 @@ static void pllb_mode(struct clk *clk, int is_on)
139 value = 0; 111 value = 0;
140 112
141 // REVISIT: Add work-around for AT91RM9200 Errata #26 ? 113 // REVISIT: Add work-around for AT91RM9200 Errata #26 ?
142 at91_pmc_write(AT91_CKGR_PLLBR, value); 114 at91_sys_write(AT91_CKGR_PLLBR, value);
143 115
144 do { 116 do {
145 cpu_relax(); 117 cpu_relax();
146 } while ((at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != is_on); 118 } while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != is_on);
147} 119}
148 120
149static struct clk pllb = { 121static struct clk pllb = {
@@ -158,24 +130,31 @@ static struct clk pllb = {
158static void pmc_sys_mode(struct clk *clk, int is_on) 130static void pmc_sys_mode(struct clk *clk, int is_on)
159{ 131{
160 if (is_on) 132 if (is_on)
161 at91_pmc_write(AT91_PMC_SCER, clk->pmc_mask); 133 at91_sys_write(AT91_PMC_SCER, clk->pmc_mask);
162 else 134 else
163 at91_pmc_write(AT91_PMC_SCDR, clk->pmc_mask); 135 at91_sys_write(AT91_PMC_SCDR, clk->pmc_mask);
164} 136}
165 137
166static void pmc_uckr_mode(struct clk *clk, int is_on) 138static void pmc_uckr_mode(struct clk *clk, int is_on)
167{ 139{
168 unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR); 140 unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR);
141
142 if (cpu_is_at91sam9g45()) {
143 if (is_on)
144 uckr |= AT91_PMC_BIASEN;
145 else
146 uckr &= ~AT91_PMC_BIASEN;
147 }
169 148
170 if (is_on) { 149 if (is_on) {
171 is_on = AT91_PMC_LOCKU; 150 is_on = AT91_PMC_LOCKU;
172 at91_pmc_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask); 151 at91_sys_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask);
173 } else 152 } else
174 at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask)); 153 at91_sys_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask));
175 154
176 do { 155 do {
177 cpu_relax(); 156 cpu_relax();
178 } while ((at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on); 157 } while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on);
179} 158}
180 159
181/* USB function clocks (PLLB must be 48 MHz) */ 160/* USB function clocks (PLLB must be 48 MHz) */
@@ -211,9 +190,9 @@ struct clk mck = {
211static void pmc_periph_mode(struct clk *clk, int is_on) 190static void pmc_periph_mode(struct clk *clk, int is_on)
212{ 191{
213 if (is_on) 192 if (is_on)
214 at91_pmc_write(AT91_PMC_PCER, clk->pmc_mask); 193 at91_sys_write(AT91_PMC_PCER, clk->pmc_mask);
215 else 194 else
216 at91_pmc_write(AT91_PMC_PCDR, clk->pmc_mask); 195 at91_sys_write(AT91_PMC_PCDR, clk->pmc_mask);
217} 196}
218 197
219static struct clk __init *at91_css_to_clk(unsigned long css) 198static struct clk __init *at91_css_to_clk(unsigned long css)
@@ -231,24 +210,11 @@ static struct clk __init *at91_css_to_clk(unsigned long css)
231 return &utmi_clk; 210 return &utmi_clk;
232 else if (cpu_has_pllb()) 211 else if (cpu_has_pllb())
233 return &pllb; 212 return &pllb;
234 break;
235 /* alternate PMC: can use master clock */
236 case AT91_PMC_CSS_MASTER:
237 return &mck;
238 } 213 }
239 214
240 return NULL; 215 return NULL;
241} 216}
242 217
243static int pmc_prescaler_divider(u32 reg)
244{
245 if (cpu_has_alt_prescaler()) {
246 return 1 << ((reg & AT91_PMC_ALT_PRES) >> PMC_ALT_PRES_OFFSET);
247 } else {
248 return 1 << ((reg & AT91_PMC_PRES) >> PMC_PRES_OFFSET);
249 }
250}
251
252static void __clk_enable(struct clk *clk) 218static void __clk_enable(struct clk *clk)
253{ 219{
254 if (clk->parent) 220 if (clk->parent)
@@ -350,22 +316,12 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
350{ 316{
351 unsigned long flags; 317 unsigned long flags;
352 unsigned prescale; 318 unsigned prescale;
353 unsigned long prescale_offset, css_mask;
354 unsigned long actual; 319 unsigned long actual;
355 320
356 if (!clk_is_programmable(clk)) 321 if (!clk_is_programmable(clk))
357 return -EINVAL; 322 return -EINVAL;
358 if (clk->users) 323 if (clk->users)
359 return -EBUSY; 324 return -EBUSY;
360
361 if (cpu_has_alt_prescaler()) {
362 prescale_offset = PMC_ALT_PRES_OFFSET;
363 css_mask = AT91_PMC_ALT_PCKR_CSS;
364 } else {
365 prescale_offset = PMC_PRES_OFFSET;
366 css_mask = AT91_PMC_CSS;
367 }
368
369 spin_lock_irqsave(&clk_lock, flags); 325 spin_lock_irqsave(&clk_lock, flags);
370 326
371 actual = clk->parent->rate_hz; 327 actual = clk->parent->rate_hz;
@@ -373,10 +329,10 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
373 if (actual && actual <= rate) { 329 if (actual && actual <= rate) {
374 u32 pckr; 330 u32 pckr;
375 331
376 pckr = at91_pmc_read(AT91_PMC_PCKR(clk->id)); 332 pckr = at91_sys_read(AT91_PMC_PCKR(clk->id));
377 pckr &= css_mask; /* keep clock selection */ 333 pckr &= AT91_PMC_CSS; /* clock selection */
378 pckr |= prescale << prescale_offset; 334 pckr |= prescale << 2;
379 at91_pmc_write(AT91_PMC_PCKR(clk->id), pckr); 335 at91_sys_write(AT91_PMC_PCKR(clk->id), pckr);
380 clk->rate_hz = actual; 336 clk->rate_hz = actual;
381 break; 337 break;
382 } 338 }
@@ -410,7 +366,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
410 366
411 clk->rate_hz = parent->rate_hz; 367 clk->rate_hz = parent->rate_hz;
412 clk->parent = parent; 368 clk->parent = parent;
413 at91_pmc_write(AT91_PMC_PCKR(clk->id), parent->id); 369 at91_sys_write(AT91_PMC_PCKR(clk->id), parent->id);
414 370
415 spin_unlock_irqrestore(&clk_lock, flags); 371 spin_unlock_irqrestore(&clk_lock, flags);
416 return 0; 372 return 0;
@@ -422,17 +378,11 @@ static void __init init_programmable_clock(struct clk *clk)
422{ 378{
423 struct clk *parent; 379 struct clk *parent;
424 u32 pckr; 380 u32 pckr;
425 unsigned int css_mask;
426
427 if (cpu_has_alt_prescaler())
428 css_mask = AT91_PMC_ALT_PCKR_CSS;
429 else
430 css_mask = AT91_PMC_CSS;
431 381
432 pckr = at91_pmc_read(AT91_PMC_PCKR(clk->id)); 382 pckr = at91_sys_read(AT91_PMC_PCKR(clk->id));
433 parent = at91_css_to_clk(pckr & css_mask); 383 parent = at91_css_to_clk(pckr & AT91_PMC_CSS);
434 clk->parent = parent; 384 clk->parent = parent;
435 clk->rate_hz = parent->rate_hz / pmc_prescaler_divider(pckr); 385 clk->rate_hz = parent->rate_hz / (1 << ((pckr & AT91_PMC_PRES) >> 2));
436} 386}
437 387
438#endif /* CONFIG_AT91_PROGRAMMABLE_CLOCKS */ 388#endif /* CONFIG_AT91_PROGRAMMABLE_CLOCKS */
@@ -446,24 +396,19 @@ static int at91_clk_show(struct seq_file *s, void *unused)
446 u32 scsr, pcsr, uckr = 0, sr; 396 u32 scsr, pcsr, uckr = 0, sr;
447 struct clk *clk; 397 struct clk *clk;
448 398
449 scsr = at91_pmc_read(AT91_PMC_SCSR); 399 seq_printf(s, "SCSR = %8x\n", scsr = at91_sys_read(AT91_PMC_SCSR));
450 pcsr = at91_pmc_read(AT91_PMC_PCSR); 400 seq_printf(s, "PCSR = %8x\n", pcsr = at91_sys_read(AT91_PMC_PCSR));
451 sr = at91_pmc_read(AT91_PMC_SR); 401 seq_printf(s, "MOR = %8x\n", at91_sys_read(AT91_CKGR_MOR));
452 seq_printf(s, "SCSR = %8x\n", scsr); 402 seq_printf(s, "MCFR = %8x\n", at91_sys_read(AT91_CKGR_MCFR));
453 seq_printf(s, "PCSR = %8x\n", pcsr); 403 seq_printf(s, "PLLA = %8x\n", at91_sys_read(AT91_CKGR_PLLAR));
454 seq_printf(s, "MOR = %8x\n", at91_pmc_read(AT91_CKGR_MOR));
455 seq_printf(s, "MCFR = %8x\n", at91_pmc_read(AT91_CKGR_MCFR));
456 seq_printf(s, "PLLA = %8x\n", at91_pmc_read(AT91_CKGR_PLLAR));
457 if (cpu_has_pllb()) 404 if (cpu_has_pllb())
458 seq_printf(s, "PLLB = %8x\n", at91_pmc_read(AT91_CKGR_PLLBR)); 405 seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR));
459 if (cpu_has_utmi()) { 406 if (cpu_has_utmi())
460 uckr = at91_pmc_read(AT91_CKGR_UCKR); 407 seq_printf(s, "UCKR = %8x\n", uckr = at91_sys_read(AT91_CKGR_UCKR));
461 seq_printf(s, "UCKR = %8x\n", uckr); 408 seq_printf(s, "MCKR = %8x\n", at91_sys_read(AT91_PMC_MCKR));
462 }
463 seq_printf(s, "MCKR = %8x\n", at91_pmc_read(AT91_PMC_MCKR));
464 if (cpu_has_upll()) 409 if (cpu_has_upll())
465 seq_printf(s, "USB = %8x\n", at91_pmc_read(AT91_PMC_USB)); 410 seq_printf(s, "USB = %8x\n", at91_sys_read(AT91_PMC_USB));
466 seq_printf(s, "SR = %8x\n", sr); 411 seq_printf(s, "SR = %8x\n", sr = at91_sys_read(AT91_PMC_SR));
467 412
468 seq_printf(s, "\n"); 413 seq_printf(s, "\n");
469 414
@@ -625,7 +570,7 @@ fail:
625 return 0; 570 return 0;
626} 571}
627 572
628static struct clk *const standard_pmc_clocks[] __initconst = { 573static struct clk *const standard_pmc_clocks[] __initdata = {
629 /* four primary clocks */ 574 /* four primary clocks */
630 &clk32k, 575 &clk32k,
631 &main_clk, 576 &main_clk,
@@ -651,14 +596,16 @@ static void __init at91_pllb_usbfs_clock_init(unsigned long main_clock)
651 if (cpu_is_at91rm9200()) { 596 if (cpu_is_at91rm9200()) {
652 uhpck.pmc_mask = AT91RM9200_PMC_UHP; 597 uhpck.pmc_mask = AT91RM9200_PMC_UHP;
653 udpck.pmc_mask = AT91RM9200_PMC_UDP; 598 udpck.pmc_mask = AT91RM9200_PMC_UDP;
654 at91_pmc_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP); 599 at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP);
655 } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || 600 } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() ||
656 cpu_is_at91sam9263() || cpu_is_at91sam9g20() || 601 cpu_is_at91sam9263() || cpu_is_at91sam9g20() ||
657 cpu_is_at91sam9g10()) { 602 cpu_is_at91sam9g10()) {
658 uhpck.pmc_mask = AT91SAM926x_PMC_UHP; 603 uhpck.pmc_mask = AT91SAM926x_PMC_UHP;
659 udpck.pmc_mask = AT91SAM926x_PMC_UDP; 604 udpck.pmc_mask = AT91SAM926x_PMC_UDP;
605 } else if (cpu_is_at91cap9()) {
606 uhpck.pmc_mask = AT91CAP9_PMC_UHP;
660 } 607 }
661 at91_pmc_write(AT91_CKGR_PLLBR, 0); 608 at91_sys_write(AT91_CKGR_PLLBR, 0);
662 609
663 udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init); 610 udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
664 uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init); 611 uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
@@ -675,16 +622,16 @@ static void __init at91_upll_usbfs_clock_init(unsigned long main_clock)
675 /* Setup divider by 10 to reach 48 MHz */ 622 /* Setup divider by 10 to reach 48 MHz */
676 usbr |= ((10 - 1) << 8) & AT91_PMC_OHCIUSBDIV; 623 usbr |= ((10 - 1) << 8) & AT91_PMC_OHCIUSBDIV;
677 624
678 at91_pmc_write(AT91_PMC_USB, usbr); 625 at91_sys_write(AT91_PMC_USB, usbr);
679 626
680 /* Now set uhpck values */ 627 /* Now set uhpck values */
681 uhpck.parent = &utmi_clk; 628 uhpck.parent = &utmi_clk;
682 uhpck.pmc_mask = AT91SAM926x_PMC_UHP; 629 uhpck.pmc_mask = AT91SAM926x_PMC_UHP;
683 uhpck.rate_hz = utmi_clk.rate_hz; 630 uhpck.rate_hz = utmi_clk.rate_hz;
684 uhpck.rate_hz /= 1 + ((at91_pmc_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8); 631 uhpck.rate_hz /= 1 + ((at91_sys_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8);
685} 632}
686 633
687static int __init at91_pmc_init(unsigned long main_clock) 634int __init at91_clock_init(unsigned long main_clock)
688{ 635{
689 unsigned tmp, freq, mckr; 636 unsigned tmp, freq, mckr;
690 int i; 637 int i;
@@ -698,26 +645,20 @@ static int __init at91_pmc_init(unsigned long main_clock)
698 */ 645 */
699 if (!main_clock) { 646 if (!main_clock) {
700 do { 647 do {
701 tmp = at91_pmc_read(AT91_CKGR_MCFR); 648 tmp = at91_sys_read(AT91_CKGR_MCFR);
702 } while (!(tmp & AT91_PMC_MAINRDY)); 649 } while (!(tmp & AT91_PMC_MAINRDY));
703 main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16); 650 main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16);
704 } 651 }
705 main_clk.rate_hz = main_clock; 652 main_clk.rate_hz = main_clock;
706 653
707 /* report if PLLA is more than mildly overclocked */ 654 /* report if PLLA is more than mildly overclocked */
708 plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_pmc_read(AT91_CKGR_PLLAR)); 655 plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_sys_read(AT91_CKGR_PLLAR));
709 if (cpu_has_300M_plla()) { 656 if (cpu_has_300M_plla()) {
710 if (plla.rate_hz > 300000000) 657 if (plla.rate_hz > 300000000)
711 pll_overclock = true; 658 pll_overclock = true;
712 } else if (cpu_has_800M_plla()) { 659 } else if (cpu_has_800M_plla()) {
713 if (plla.rate_hz > 800000000) 660 if (plla.rate_hz > 800000000)
714 pll_overclock = true; 661 pll_overclock = true;
715 } else if (cpu_has_240M_plla()) {
716 if (plla.rate_hz > 240000000)
717 pll_overclock = true;
718 } else if (cpu_has_210M_plla()) {
719 if (plla.rate_hz > 210000000)
720 pll_overclock = true;
721 } else { 662 } else {
722 if (plla.rate_hz > 209000000) 663 if (plla.rate_hz > 209000000)
723 pll_overclock = true; 664 pll_overclock = true;
@@ -725,8 +666,8 @@ static int __init at91_pmc_init(unsigned long main_clock)
725 if (pll_overclock) 666 if (pll_overclock)
726 pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000); 667 pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000);
727 668
728 if (cpu_has_plladiv2()) { 669 if (cpu_is_at91sam9g45()) {
729 mckr = at91_pmc_read(AT91_PMC_MCKR); 670 mckr = at91_sys_read(AT91_PMC_MCKR);
730 plla.rate_hz /= (1 << ((mckr & AT91_PMC_PLLADIV2) >> 12)); /* plla divisor by 2 */ 671 plla.rate_hz /= (1 << ((mckr & AT91_PMC_PLLADIV2) >> 12)); /* plla divisor by 2 */
731 } 672 }
732 673
@@ -747,10 +688,6 @@ static int __init at91_pmc_init(unsigned long main_clock)
747 * (obtain the USB High Speed 480 MHz when input is 12 MHz) 688 * (obtain the USB High Speed 480 MHz when input is 12 MHz)
748 */ 689 */
749 utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz; 690 utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz;
750
751 /* UTMI bias and PLL are managed at the same time */
752 if (cpu_has_upll())
753 utmi_clk.pmc_mask |= AT91_PMC_BIASEN;
754 } 691 }
755 692
756 /* 693 /*
@@ -766,10 +703,10 @@ static int __init at91_pmc_init(unsigned long main_clock)
766 * MCK and CPU derive from one of those primary clocks. 703 * MCK and CPU derive from one of those primary clocks.
767 * For now, assume this parentage won't change. 704 * For now, assume this parentage won't change.
768 */ 705 */
769 mckr = at91_pmc_read(AT91_PMC_MCKR); 706 mckr = at91_sys_read(AT91_PMC_MCKR);
770 mck.parent = at91_css_to_clk(mckr & AT91_PMC_CSS); 707 mck.parent = at91_css_to_clk(mckr & AT91_PMC_CSS);
771 freq = mck.parent->rate_hz; 708 freq = mck.parent->rate_hz;
772 freq /= pmc_prescaler_divider(mckr); /* prescale */ 709 freq /= (1 << ((mckr & AT91_PMC_PRES) >> 2)); /* prescale */
773 if (cpu_is_at91rm9200()) { 710 if (cpu_is_at91rm9200()) {
774 mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 711 mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */
775 } else if (cpu_is_at91sam9g20()) { 712 } else if (cpu_is_at91sam9g20()) {
@@ -777,19 +714,13 @@ static int __init at91_pmc_init(unsigned long main_clock)
777 freq / ((mckr & AT91_PMC_MDIV) >> 7) : freq; /* mdiv ; (x >> 7) = ((x >> 8) * 2) */ 714 freq / ((mckr & AT91_PMC_MDIV) >> 7) : freq; /* mdiv ; (x >> 7) = ((x >> 8) * 2) */
778 if (mckr & AT91_PMC_PDIV) 715 if (mckr & AT91_PMC_PDIV)
779 freq /= 2; /* processor clock division */ 716 freq /= 2; /* processor clock division */
780 } else if (cpu_has_mdiv3()) { 717 } else if (cpu_is_at91sam9g45()) {
781 mck.rate_hz = (mckr & AT91_PMC_MDIV) == AT91SAM9_PMC_MDIV_3 ? 718 mck.rate_hz = (mckr & AT91_PMC_MDIV) == AT91SAM9_PMC_MDIV_3 ?
782 freq / 3 : freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 719 freq / 3 : freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */
783 } else { 720 } else {
784 mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 721 mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */
785 } 722 }
786 723
787 if (cpu_has_alt_prescaler()) {
788 /* Programmable clocks can use MCK */
789 mck.type |= CLK_TYPE_PRIMARY;
790 mck.id = 4;
791 }
792
793 /* Register the PMC's standard clocks */ 724 /* Register the PMC's standard clocks */
794 for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++) 725 for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++)
795 at91_clk_add(standard_pmc_clocks[i]); 726 at91_clk_add(standard_pmc_clocks[i]);
@@ -817,55 +748,6 @@ static int __init at91_pmc_init(unsigned long main_clock)
817 return 0; 748 return 0;
818} 749}
819 750
820#if defined(CONFIG_OF)
821static struct of_device_id pmc_ids[] = {
822 { .compatible = "atmel,at91rm9200-pmc" },
823 { /*sentinel*/ }
824};
825
826static struct of_device_id osc_ids[] = {
827 { .compatible = "atmel,osc" },
828 { /*sentinel*/ }
829};
830
831int __init at91_dt_clock_init(void)
832{
833 struct device_node *np;
834 u32 main_clock = 0;
835
836 np = of_find_matching_node(NULL, pmc_ids);
837 if (!np)
838 panic("unable to find compatible pmc node in dtb\n");
839
840 at91_pmc_base = of_iomap(np, 0);
841 if (!at91_pmc_base)
842 panic("unable to map pmc cpu registers\n");
843
844 of_node_put(np);
845
846 /* retrieve the freqency of fixed clocks from device tree */
847 np = of_find_matching_node(NULL, osc_ids);
848 if (np) {
849 u32 rate;
850 if (!of_property_read_u32(np, "clock-frequency", &rate))
851 main_clock = rate;
852 }
853
854 of_node_put(np);
855
856 return at91_pmc_init(main_clock);
857}
858#endif
859
860int __init at91_clock_init(unsigned long main_clock)
861{
862 at91_pmc_base = ioremap(AT91_PMC, 256);
863 if (!at91_pmc_base)
864 panic("Impossible to ioremap AT91_PMC 0x%x\n", AT91_PMC);
865
866 return at91_pmc_init(main_clock);
867}
868
869/* 751/*
870 * Several unused clocks may be active. Turn them off. 752 * Several unused clocks may be active. Turn them off.
871 */ 753 */
@@ -888,15 +770,9 @@ static int __init at91_clock_reset(void)
888 pr_debug("Clocks: disable unused %s\n", clk->name); 770 pr_debug("Clocks: disable unused %s\n", clk->name);
889 } 771 }
890 772
891 at91_pmc_write(AT91_PMC_PCDR, pcdr); 773 at91_sys_write(AT91_PMC_PCDR, pcdr);
892 at91_pmc_write(AT91_PMC_SCDR, scdr); 774 at91_sys_write(AT91_PMC_SCDR, scdr);
893 775
894 return 0; 776 return 0;
895} 777}
896late_initcall(at91_clock_reset); 778late_initcall(at91_clock_reset);
897
898void at91sam9_idle(void)
899{
900 at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
901 cpu_do_idle();
902}
diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c
index 0c6381516a5..1cfeac1483d 100644
--- a/arch/arm/mach-at91/cpuidle.c
+++ b/arch/arm/mach-at91/cpuidle.c
@@ -17,11 +17,8 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/cpuidle.h> 19#include <linux/cpuidle.h>
20#include <linux/io.h>
21#include <linux/export.h>
22#include <asm/proc-fns.h> 20#include <asm/proc-fns.h>
23#include <asm/cpuidle.h> 21#include <linux/io.h>
24#include <mach/cpu.h>
25 22
26#include "pm.h" 23#include "pm.h"
27 24
@@ -29,46 +26,63 @@
29 26
30static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device); 27static DEFINE_PER_CPU(struct cpuidle_device, at91_cpuidle_device);
31 28
29static struct cpuidle_driver at91_idle_driver = {
30 .name = "at91_idle",
31 .owner = THIS_MODULE,
32};
33
32/* Actual code that puts the SoC in different idle states */ 34/* Actual code that puts the SoC in different idle states */
33static int at91_enter_idle(struct cpuidle_device *dev, 35static int at91_enter_idle(struct cpuidle_device *dev,
34 struct cpuidle_driver *drv, 36 struct cpuidle_state *state)
35 int index)
36{ 37{
37 if (cpu_is_at91rm9200()) 38 struct timeval before, after;
38 at91rm9200_standby(); 39 int idle_time;
39 else if (cpu_is_at91sam9g45()) 40 u32 saved_lpr;
40 at91sam9g45_standby();
41 else
42 at91sam9_standby();
43 41
44 return index; 42 local_irq_disable();
43 do_gettimeofday(&before);
44 if (state == &dev->states[0])
45 /* Wait for interrupt state */
46 cpu_do_idle();
47 else if (state == &dev->states[1]) {
48 asm("b 1f; .align 5; 1:");
49 asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */
50 saved_lpr = sdram_selfrefresh_enable();
51 cpu_do_idle();
52 sdram_selfrefresh_disable(saved_lpr);
53 }
54 do_gettimeofday(&after);
55 local_irq_enable();
56 idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC +
57 (after.tv_usec - before.tv_usec);
58 return idle_time;
45} 59}
46 60
47static struct cpuidle_driver at91_idle_driver = {
48 .name = "at91_idle",
49 .owner = THIS_MODULE,
50 .en_core_tk_irqen = 1,
51 .states[0] = ARM_CPUIDLE_WFI_STATE,
52 .states[1] = {
53 .enter = at91_enter_idle,
54 .exit_latency = 10,
55 .target_residency = 100000,
56 .flags = CPUIDLE_FLAG_TIME_VALID,
57 .name = "RAM_SR",
58 .desc = "WFI and DDR Self Refresh",
59 },
60 .state_count = AT91_MAX_STATES,
61};
62
63/* Initialize CPU idle by registering the idle states */ 61/* Initialize CPU idle by registering the idle states */
64static int at91_init_cpuidle(void) 62static int at91_init_cpuidle(void)
65{ 63{
66 struct cpuidle_device *device; 64 struct cpuidle_device *device;
67 65
66 cpuidle_register_driver(&at91_idle_driver);
67
68 device = &per_cpu(at91_cpuidle_device, smp_processor_id()); 68 device = &per_cpu(at91_cpuidle_device, smp_processor_id());
69 device->state_count = AT91_MAX_STATES; 69 device->state_count = AT91_MAX_STATES;
70 70
71 cpuidle_register_driver(&at91_idle_driver); 71 /* Wait for interrupt state */
72 device->states[0].enter = at91_enter_idle;
73 device->states[0].exit_latency = 1;
74 device->states[0].target_residency = 10000;
75 device->states[0].flags = CPUIDLE_FLAG_TIME_VALID;
76 strcpy(device->states[0].name, "WFI");
77 strcpy(device->states[0].desc, "Wait for interrupt");
78
79 /* Wait for interrupt and RAM self refresh state */
80 device->states[1].enter = at91_enter_idle;
81 device->states[1].exit_latency = 10;
82 device->states[1].target_residency = 10000;
83 device->states[1].flags = CPUIDLE_FLAG_TIME_VALID;
84 strcpy(device->states[1].name, "RAM_SR");
85 strcpy(device->states[1].desc, "WFI and RAM Self Refresh");
72 86
73 if (cpuidle_register_device(device)) { 87 if (cpuidle_register_device(device)) {
74 printk(KERN_ERR "at91_init_cpuidle: Failed registering\n"); 88 printk(KERN_ERR "at91_init_cpuidle: Failed registering\n");
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index fc593d615e7..938b34f5774 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -9,7 +9,6 @@
9 */ 9 */
10 10
11#include <linux/clkdev.h> 11#include <linux/clkdev.h>
12#include <linux/of.h>
13 12
14 /* Map io */ 13 /* Map io */
15extern void __init at91_map_io(void); 14extern void __init at91_map_io(void);
@@ -20,33 +19,34 @@ extern void __init at91_init_sram(int bank, unsigned long base,
20extern void __init at91rm9200_set_type(int type); 19extern void __init at91rm9200_set_type(int type);
21extern void __init at91_initialize(unsigned long main_clock); 20extern void __init at91_initialize(unsigned long main_clock);
22extern void __init at91x40_initialize(unsigned long main_clock); 21extern void __init at91x40_initialize(unsigned long main_clock);
23extern void __init at91rm9200_dt_initialize(void);
24extern void __init at91_dt_initialize(void);
25 22
26 /* Interrupts */ 23 /* Interrupts */
27extern void __init at91_init_irq_default(void); 24extern void __init at91_init_irq_default(void);
28extern void __init at91_init_interrupts(unsigned int priority[]); 25extern void __init at91_init_interrupts(unsigned int priority[]);
29extern void __init at91x40_init_interrupts(unsigned int priority[]); 26extern void __init at91x40_init_interrupts(unsigned int priority[]);
30extern void __init at91_aic_init(unsigned int priority[], 27extern void __init at91_aic_init(unsigned int priority[]);
31 unsigned int ext_irq_mask);
32extern int __init at91_aic_of_init(struct device_node *node,
33 struct device_node *parent);
34extern int __init at91_aic5_of_init(struct device_node *node,
35 struct device_node *parent);
36
37 28
38 /* Timer */ 29 /* Timer */
39struct sys_timer; 30struct sys_timer;
40extern void at91rm9200_ioremap_st(u32 addr);
41extern struct sys_timer at91rm9200_timer; 31extern struct sys_timer at91rm9200_timer;
42extern void at91sam926x_ioremap_pit(u32 addr);
43extern struct sys_timer at91sam926x_timer; 32extern struct sys_timer at91sam926x_timer;
44extern struct sys_timer at91x40_timer; 33extern struct sys_timer at91x40_timer;
45 34
46 /* Clocks */ 35 /* Clocks */
36/*
37 * function to specify the clock of the default console. As we do not
38 * use the device/driver bus, the dev_name is not intialize. So we need
39 * to link the clock to a specific con_id only "usart"
40 */
41extern void __init at91rm9200_set_console_clock(int id);
42extern void __init at91sam9260_set_console_clock(int id);
43extern void __init at91sam9261_set_console_clock(int id);
44extern void __init at91sam9263_set_console_clock(int id);
45extern void __init at91sam9rl_set_console_clock(int id);
46extern void __init at91sam9g45_set_console_clock(int id);
47extern void __init at91cap9_set_console_clock(int id);
47#ifdef CONFIG_AT91_PMC_UNIT 48#ifdef CONFIG_AT91_PMC_UNIT
48extern int __init at91_clock_init(unsigned long main_clock); 49extern int __init at91_clock_init(unsigned long main_clock);
49extern int __init at91_dt_clock_init(void);
50#else 50#else
51static int inline at91_clock_init(unsigned long main_clock) { return 0; } 51static int inline at91_clock_init(unsigned long main_clock) { return 0; }
52#endif 52#endif
@@ -56,22 +56,8 @@ struct device;
56extern void at91_irq_suspend(void); 56extern void at91_irq_suspend(void);
57extern void at91_irq_resume(void); 57extern void at91_irq_resume(void);
58 58
59/* idle */
60extern void at91sam9_idle(void);
61
62/* reset */ 59/* reset */
63extern void at91_ioremap_rstc(u32 base_addr); 60extern void at91sam9_alt_reset(void);
64extern void at91sam9_alt_restart(char, const char *);
65extern void at91sam9g45_restart(char, const char *);
66
67/* shutdown */
68extern void at91_ioremap_shdwc(u32 base_addr);
69
70/* Matrix */
71extern void at91_ioremap_matrix(u32 base_addr);
72
73/* Ram Controler */
74extern void at91_ioremap_ramc(int id, u32 addr, u32 size);
75 61
76 /* GPIO */ 62 /* GPIO */
77#define AT91RM9200_PQFP 3 /* AT91RM9200 PQFP package has 3 banks */ 63#define AT91RM9200_PQFP 3 /* AT91RM9200 PQFP package has 3 banks */
@@ -79,11 +65,11 @@ extern void at91_ioremap_ramc(int id, u32 addr, u32 size);
79 65
80struct at91_gpio_bank { 66struct at91_gpio_bank {
81 unsigned short id; /* peripheral ID */ 67 unsigned short id; /* peripheral ID */
82 unsigned long regbase; /* offset from system peripheral base */ 68 unsigned long offset; /* offset from system peripheral base */
69 struct clk *clock; /* associated clock */
83}; 70};
84extern void __init at91_gpio_init(struct at91_gpio_bank *, int nr_banks); 71extern void __init at91_gpio_init(struct at91_gpio_bank *, int nr_banks);
85extern void __init at91_gpio_irq_setup(void); 72extern void __init at91_gpio_irq_setup(void);
86extern int __init at91_gpio_of_irq_setup(struct device_node *node,
87 struct device_node *parent);
88 73
74extern void (*at91_arch_reset)(void);
89extern int at91_extern_irq; 75extern int at91_extern_irq;
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index c5d7e1e9d75..4615528205c 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -11,8 +11,6 @@
11 11
12#include <linux/clk.h> 12#include <linux/clk.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/device.h>
15#include <linux/gpio.h>
16#include <linux/interrupt.h> 14#include <linux/interrupt.h>
17#include <linux/irq.h> 15#include <linux/irq.h>
18#include <linux/debugfs.h> 16#include <linux/debugfs.h>
@@ -21,32 +19,24 @@
21#include <linux/list.h> 19#include <linux/list.h>
22#include <linux/module.h> 20#include <linux/module.h>
23#include <linux/io.h> 21#include <linux/io.h>
24#include <linux/irqdomain.h>
25#include <linux/of_address.h>
26
27#include <asm/mach/irq.h>
28 22
29#include <mach/hardware.h> 23#include <mach/hardware.h>
30#include <mach/at91_pio.h> 24#include <mach/at91_pio.h>
25#include <mach/gpio.h>
31 26
32#include "generic.h" 27#include <asm/gpio.h>
33 28
34#define MAX_NB_GPIO_PER_BANK 32 29#include "generic.h"
35 30
36struct at91_gpio_chip { 31struct at91_gpio_chip {
37 struct gpio_chip chip; 32 struct gpio_chip chip;
38 struct at91_gpio_chip *next; /* Bank sharing same clock */ 33 struct at91_gpio_chip *next; /* Bank sharing same clock */
39 int pioc_hwirq; /* PIO bank interrupt identifier on AIC */ 34 struct at91_gpio_bank *bank; /* Bank definition */
40 int pioc_virq; /* PIO bank Linux virtual interrupt */ 35 void __iomem *regbase; /* Base of register bank */
41 int pioc_idx; /* PIO bank index */
42 void __iomem *regbase; /* PIO bank virtual address */
43 struct clk *clock; /* associated clock */
44 struct irq_domain *domain; /* associated irq domain */
45}; 36};
46 37
47#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) 38#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip)
48 39
49static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset);
50static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip); 40static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip);
51static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val); 41static void at91_gpiolib_set(struct gpio_chip *chip, unsigned offset, int val);
52static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset); 42static int at91_gpiolib_get(struct gpio_chip *chip, unsigned offset);
@@ -54,44 +44,35 @@ static int at91_gpiolib_direction_output(struct gpio_chip *chip,
54 unsigned offset, int val); 44 unsigned offset, int val);
55static int at91_gpiolib_direction_input(struct gpio_chip *chip, 45static int at91_gpiolib_direction_input(struct gpio_chip *chip,
56 unsigned offset); 46 unsigned offset);
57static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset);
58 47
59#define AT91_GPIO_CHIP(name) \ 48#define AT91_GPIO_CHIP(name, base_gpio, nr_gpio) \
60 { \ 49 { \
61 .chip = { \ 50 .chip = { \
62 .label = name, \ 51 .label = name, \
63 .request = at91_gpiolib_request, \
64 .direction_input = at91_gpiolib_direction_input, \ 52 .direction_input = at91_gpiolib_direction_input, \
65 .direction_output = at91_gpiolib_direction_output, \ 53 .direction_output = at91_gpiolib_direction_output, \
66 .get = at91_gpiolib_get, \ 54 .get = at91_gpiolib_get, \
67 .set = at91_gpiolib_set, \ 55 .set = at91_gpiolib_set, \
68 .dbg_show = at91_gpiolib_dbg_show, \ 56 .dbg_show = at91_gpiolib_dbg_show, \
69 .to_irq = at91_gpiolib_to_irq, \ 57 .base = base_gpio, \
70 .ngpio = MAX_NB_GPIO_PER_BANK, \ 58 .ngpio = nr_gpio, \
71 }, \ 59 }, \
72 } 60 }
73 61
74static struct at91_gpio_chip gpio_chip[] = { 62static struct at91_gpio_chip gpio_chip[] = {
75 AT91_GPIO_CHIP("pioA"), 63 AT91_GPIO_CHIP("A", 0x00 + PIN_BASE, 32),
76 AT91_GPIO_CHIP("pioB"), 64 AT91_GPIO_CHIP("B", 0x20 + PIN_BASE, 32),
77 AT91_GPIO_CHIP("pioC"), 65 AT91_GPIO_CHIP("C", 0x40 + PIN_BASE, 32),
78 AT91_GPIO_CHIP("pioD"), 66 AT91_GPIO_CHIP("D", 0x60 + PIN_BASE, 32),
79 AT91_GPIO_CHIP("pioE"), 67 AT91_GPIO_CHIP("E", 0x80 + PIN_BASE, 32),
80}; 68};
81 69
82static int gpio_banks; 70static int gpio_banks;
83static unsigned long at91_gpio_caps;
84
85/* All PIO controllers support PIO3 features */
86#define AT91_GPIO_CAP_PIO3 (1 << 0)
87
88#define has_pio3() (at91_gpio_caps & AT91_GPIO_CAP_PIO3)
89
90/*--------------------------------------------------------------------------*/
91 71
92static inline void __iomem *pin_to_controller(unsigned pin) 72static inline void __iomem *pin_to_controller(unsigned pin)
93{ 73{
94 pin /= MAX_NB_GPIO_PER_BANK; 74 pin -= PIN_BASE;
75 pin /= 32;
95 if (likely(pin < gpio_banks)) 76 if (likely(pin < gpio_banks))
96 return gpio_chip[pin].regbase; 77 return gpio_chip[pin].regbase;
97 78
@@ -100,29 +81,11 @@ static inline void __iomem *pin_to_controller(unsigned pin)
100 81
101static inline unsigned pin_to_mask(unsigned pin) 82static inline unsigned pin_to_mask(unsigned pin)
102{ 83{
103 return 1 << (pin % MAX_NB_GPIO_PER_BANK); 84 pin -= PIN_BASE;
85 return 1 << (pin % 32);
104} 86}
105 87
106 88
107static char peripheral_function(void __iomem *pio, unsigned mask)
108{
109 char ret = 'X';
110 u8 select;
111
112 if (pio) {
113 if (has_pio3()) {
114 select = !!(__raw_readl(pio + PIO_ABCDSR1) & mask);
115 select |= (!!(__raw_readl(pio + PIO_ABCDSR2) & mask) << 1);
116 ret = 'A' + select;
117 } else {
118 ret = __raw_readl(pio + PIO_ABSR) & mask ?
119 'B' : 'A';
120 }
121 }
122
123 return ret;
124}
125
126/*--------------------------------------------------------------------------*/ 89/*--------------------------------------------------------------------------*/
127 90
128/* Not all hardware capabilities are exposed through these calls; they 91/* Not all hardware capabilities are exposed through these calls; they
@@ -170,14 +133,7 @@ int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup)
170 133
171 __raw_writel(mask, pio + PIO_IDR); 134 __raw_writel(mask, pio + PIO_IDR);
172 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); 135 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
173 if (has_pio3()) { 136 __raw_writel(mask, pio + PIO_ASR);
174 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) & ~mask,
175 pio + PIO_ABCDSR1);
176 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) & ~mask,
177 pio + PIO_ABCDSR2);
178 } else {
179 __raw_writel(mask, pio + PIO_ASR);
180 }
181 __raw_writel(mask, pio + PIO_PDR); 137 __raw_writel(mask, pio + PIO_PDR);
182 return 0; 138 return 0;
183} 139}
@@ -197,14 +153,7 @@ int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup)
197 153
198 __raw_writel(mask, pio + PIO_IDR); 154 __raw_writel(mask, pio + PIO_IDR);
199 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); 155 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
200 if (has_pio3()) { 156 __raw_writel(mask, pio + PIO_BSR);
201 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask,
202 pio + PIO_ABCDSR1);
203 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) & ~mask,
204 pio + PIO_ABCDSR2);
205 } else {
206 __raw_writel(mask, pio + PIO_BSR);
207 }
208 __raw_writel(mask, pio + PIO_PDR); 157 __raw_writel(mask, pio + PIO_PDR);
209 return 0; 158 return 0;
210} 159}
@@ -212,50 +161,8 @@ EXPORT_SYMBOL(at91_set_B_periph);
212 161
213 162
214/* 163/*
215 * mux the pin to the "C" internal peripheral role. 164 * mux the pin to the gpio controller (instead of "A" or "B" peripheral), and
216 */ 165 * configure it for an input.
217int __init_or_module at91_set_C_periph(unsigned pin, int use_pullup)
218{
219 void __iomem *pio = pin_to_controller(pin);
220 unsigned mask = pin_to_mask(pin);
221
222 if (!pio || !has_pio3())
223 return -EINVAL;
224
225 __raw_writel(mask, pio + PIO_IDR);
226 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
227 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) & ~mask, pio + PIO_ABCDSR1);
228 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2);
229 __raw_writel(mask, pio + PIO_PDR);
230 return 0;
231}
232EXPORT_SYMBOL(at91_set_C_periph);
233
234
235/*
236 * mux the pin to the "D" internal peripheral role.
237 */
238int __init_or_module at91_set_D_periph(unsigned pin, int use_pullup)
239{
240 void __iomem *pio = pin_to_controller(pin);
241 unsigned mask = pin_to_mask(pin);
242
243 if (!pio || !has_pio3())
244 return -EINVAL;
245
246 __raw_writel(mask, pio + PIO_IDR);
247 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
248 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask, pio + PIO_ABCDSR1);
249 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2);
250 __raw_writel(mask, pio + PIO_PDR);
251 return 0;
252}
253EXPORT_SYMBOL(at91_set_D_periph);
254
255
256/*
257 * mux the pin to the gpio controller (instead of "A", "B", "C"
258 * or "D" peripheral), and configure it for an input.
259 */ 166 */
260int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup) 167int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup)
261{ 168{
@@ -275,8 +182,8 @@ EXPORT_SYMBOL(at91_set_gpio_input);
275 182
276 183
277/* 184/*
278 * mux the pin to the gpio controller (instead of "A", "B", "C" 185 * mux the pin to the gpio controller (instead of "A" or "B" peripheral),
279 * or "D" peripheral), and configure it for an output. 186 * and configure it for an output.
280 */ 187 */
281int __init_or_module at91_set_gpio_output(unsigned pin, int value) 188int __init_or_module at91_set_gpio_output(unsigned pin, int value)
282{ 189{
@@ -306,37 +213,12 @@ int __init_or_module at91_set_deglitch(unsigned pin, int is_on)
306 213
307 if (!pio) 214 if (!pio)
308 return -EINVAL; 215 return -EINVAL;
309
310 if (has_pio3() && is_on)
311 __raw_writel(mask, pio + PIO_IFSCDR);
312 __raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR)); 216 __raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR));
313 return 0; 217 return 0;
314} 218}
315EXPORT_SYMBOL(at91_set_deglitch); 219EXPORT_SYMBOL(at91_set_deglitch);
316 220
317/* 221/*
318 * enable/disable the debounce filter;
319 */
320int __init_or_module at91_set_debounce(unsigned pin, int is_on, int div)
321{
322 void __iomem *pio = pin_to_controller(pin);
323 unsigned mask = pin_to_mask(pin);
324
325 if (!pio || !has_pio3())
326 return -EINVAL;
327
328 if (is_on) {
329 __raw_writel(mask, pio + PIO_IFSCER);
330 __raw_writel(div & PIO_SCDR_DIV, pio + PIO_SCDR);
331 __raw_writel(mask, pio + PIO_IFER);
332 } else {
333 __raw_writel(mask, pio + PIO_IFDR);
334 }
335 return 0;
336}
337EXPORT_SYMBOL(at91_set_debounce);
338
339/*
340 * enable/disable the multi-driver; This is only valid for output and 222 * enable/disable the multi-driver; This is only valid for output and
341 * allows the output pin to run as an open collector output. 223 * allows the output pin to run as an open collector output.
342 */ 224 */
@@ -354,41 +236,6 @@ int __init_or_module at91_set_multi_drive(unsigned pin, int is_on)
354EXPORT_SYMBOL(at91_set_multi_drive); 236EXPORT_SYMBOL(at91_set_multi_drive);
355 237
356/* 238/*
357 * enable/disable the pull-down.
358 * If pull-up already enabled while calling the function, we disable it.
359 */
360int __init_or_module at91_set_pulldown(unsigned pin, int is_on)
361{
362 void __iomem *pio = pin_to_controller(pin);
363 unsigned mask = pin_to_mask(pin);
364
365 if (!pio || !has_pio3())
366 return -EINVAL;
367
368 /* Disable pull-up anyway */
369 __raw_writel(mask, pio + PIO_PUDR);
370 __raw_writel(mask, pio + (is_on ? PIO_PPDER : PIO_PPDDR));
371 return 0;
372}
373EXPORT_SYMBOL(at91_set_pulldown);
374
375/*
376 * disable Schmitt trigger
377 */
378int __init_or_module at91_disable_schmitt_trig(unsigned pin)
379{
380 void __iomem *pio = pin_to_controller(pin);
381 unsigned mask = pin_to_mask(pin);
382
383 if (!pio || !has_pio3())
384 return -EINVAL;
385
386 __raw_writel(__raw_readl(pio + PIO_SCHMITT) | mask, pio + PIO_SCHMITT);
387 return 0;
388}
389EXPORT_SYMBOL(at91_disable_schmitt_trig);
390
391/*
392 * assuming the pin is muxed as a gpio output, set its value. 239 * assuming the pin is muxed as a gpio output, set its value.
393 */ 240 */
394int at91_set_gpio_value(unsigned pin, int value) 241int at91_set_gpio_value(unsigned pin, int value)
@@ -429,9 +276,8 @@ static u32 backups[MAX_GPIO_BANKS];
429 276
430static int gpio_irq_set_wake(struct irq_data *d, unsigned state) 277static int gpio_irq_set_wake(struct irq_data *d, unsigned state)
431{ 278{
432 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); 279 unsigned mask = pin_to_mask(d->irq);
433 unsigned mask = 1 << d->hwirq; 280 unsigned bank = (d->irq - PIN_BASE) / 32;
434 unsigned bank = at91_gpio->pioc_idx;
435 281
436 if (unlikely(bank >= MAX_GPIO_BANKS)) 282 if (unlikely(bank >= MAX_GPIO_BANKS))
437 return -EINVAL; 283 return -EINVAL;
@@ -441,7 +287,7 @@ static int gpio_irq_set_wake(struct irq_data *d, unsigned state)
441 else 287 else
442 wakeups[bank] &= ~mask; 288 wakeups[bank] &= ~mask;
443 289
444 irq_set_irq_wake(at91_gpio->pioc_virq, state); 290 irq_set_irq_wake(gpio_chip[bank].bank->id, state);
445 291
446 return 0; 292 return 0;
447} 293}
@@ -457,10 +303,9 @@ void at91_gpio_suspend(void)
457 __raw_writel(backups[i], pio + PIO_IDR); 303 __raw_writel(backups[i], pio + PIO_IDR);
458 __raw_writel(wakeups[i], pio + PIO_IER); 304 __raw_writel(wakeups[i], pio + PIO_IER);
459 305
460 if (!wakeups[i]) { 306 if (!wakeups[i])
461 clk_unprepare(gpio_chip[i].clock); 307 clk_disable(gpio_chip[i].bank->clock);
462 clk_disable(gpio_chip[i].clock); 308 else {
463 } else {
464#ifdef CONFIG_PM_DEBUG 309#ifdef CONFIG_PM_DEBUG
465 printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", 'A'+i, wakeups[i]); 310 printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", 'A'+i, wakeups[i]);
466#endif 311#endif
@@ -475,10 +320,8 @@ void at91_gpio_resume(void)
475 for (i = 0; i < gpio_banks; i++) { 320 for (i = 0; i < gpio_banks; i++) {
476 void __iomem *pio = gpio_chip[i].regbase; 321 void __iomem *pio = gpio_chip[i].regbase;
477 322
478 if (!wakeups[i]) { 323 if (!wakeups[i])
479 if (clk_prepare(gpio_chip[i].clock) == 0) 324 clk_enable(gpio_chip[i].bank->clock);
480 clk_enable(gpio_chip[i].clock);
481 }
482 325
483 __raw_writel(wakeups[i], pio + PIO_IDR); 326 __raw_writel(wakeups[i], pio + PIO_IDR);
484 __raw_writel(backups[i], pio + PIO_IER); 327 __raw_writel(backups[i], pio + PIO_IER);
@@ -494,10 +337,7 @@ void at91_gpio_resume(void)
494 * To use any AT91_PIN_* as an externally triggered IRQ, first call 337 * To use any AT91_PIN_* as an externally triggered IRQ, first call
495 * at91_set_gpio_input() then maybe enable its glitch filter. 338 * at91_set_gpio_input() then maybe enable its glitch filter.
496 * Then just request_irq() with the pin ID; it works like any ARM IRQ 339 * Then just request_irq() with the pin ID; it works like any ARM IRQ
497 * handler. 340 * handler, though it always triggers on rising and falling edges.
498 * First implementation always triggers on rising and falling edges
499 * whereas the newer PIO3 can be additionally configured to trigger on
500 * level, edge with any polarity.
501 * 341 *
502 * Alternatively, certain pins may be used directly as IRQ0..IRQ6 after 342 * Alternatively, certain pins may be used directly as IRQ0..IRQ6 after
503 * configuring them with at91_set_a_periph() or at91_set_b_periph(). 343 * configuring them with at91_set_a_periph() or at91_set_b_periph().
@@ -506,9 +346,8 @@ void at91_gpio_resume(void)
506 346
507static void gpio_irq_mask(struct irq_data *d) 347static void gpio_irq_mask(struct irq_data *d)
508{ 348{
509 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); 349 void __iomem *pio = pin_to_controller(d->irq);
510 void __iomem *pio = at91_gpio->regbase; 350 unsigned mask = pin_to_mask(d->irq);
511 unsigned mask = 1 << d->hwirq;
512 351
513 if (pio) 352 if (pio)
514 __raw_writel(mask, pio + PIO_IDR); 353 __raw_writel(mask, pio + PIO_IDR);
@@ -516,9 +355,8 @@ static void gpio_irq_mask(struct irq_data *d)
516 355
517static void gpio_irq_unmask(struct irq_data *d) 356static void gpio_irq_unmask(struct irq_data *d)
518{ 357{
519 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); 358 void __iomem *pio = pin_to_controller(d->irq);
520 void __iomem *pio = at91_gpio->regbase; 359 unsigned mask = pin_to_mask(d->irq);
521 unsigned mask = 1 << d->hwirq;
522 360
523 if (pio) 361 if (pio)
524 __raw_writel(mask, pio + PIO_IER); 362 __raw_writel(mask, pio + PIO_IER);
@@ -535,68 +373,26 @@ static int gpio_irq_type(struct irq_data *d, unsigned type)
535 } 373 }
536} 374}
537 375
538/* Alternate irq type for PIO3 support */
539static int alt_gpio_irq_type(struct irq_data *d, unsigned type)
540{
541 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
542 void __iomem *pio = at91_gpio->regbase;
543 unsigned mask = 1 << d->hwirq;
544
545 switch (type) {
546 case IRQ_TYPE_EDGE_RISING:
547 __raw_writel(mask, pio + PIO_ESR);
548 __raw_writel(mask, pio + PIO_REHLSR);
549 break;
550 case IRQ_TYPE_EDGE_FALLING:
551 __raw_writel(mask, pio + PIO_ESR);
552 __raw_writel(mask, pio + PIO_FELLSR);
553 break;
554 case IRQ_TYPE_LEVEL_LOW:
555 __raw_writel(mask, pio + PIO_LSR);
556 __raw_writel(mask, pio + PIO_FELLSR);
557 break;
558 case IRQ_TYPE_LEVEL_HIGH:
559 __raw_writel(mask, pio + PIO_LSR);
560 __raw_writel(mask, pio + PIO_REHLSR);
561 break;
562 case IRQ_TYPE_EDGE_BOTH:
563 /*
564 * disable additional interrupt modes:
565 * fall back to default behavior
566 */
567 __raw_writel(mask, pio + PIO_AIMDR);
568 return 0;
569 case IRQ_TYPE_NONE:
570 default:
571 pr_warn("AT91: No type for irq %d\n", gpio_to_irq(d->irq));
572 return -EINVAL;
573 }
574
575 /* enable additional interrupt modes */
576 __raw_writel(mask, pio + PIO_AIMER);
577
578 return 0;
579}
580
581static struct irq_chip gpio_irqchip = { 376static struct irq_chip gpio_irqchip = {
582 .name = "GPIO", 377 .name = "GPIO",
583 .irq_disable = gpio_irq_mask, 378 .irq_disable = gpio_irq_mask,
584 .irq_mask = gpio_irq_mask, 379 .irq_mask = gpio_irq_mask,
585 .irq_unmask = gpio_irq_unmask, 380 .irq_unmask = gpio_irq_unmask,
586 /* .irq_set_type is set dynamically */ 381 .irq_set_type = gpio_irq_type,
587 .irq_set_wake = gpio_irq_set_wake, 382 .irq_set_wake = gpio_irq_set_wake,
588}; 383};
589 384
590static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) 385static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
591{ 386{
592 struct irq_chip *chip = irq_desc_get_chip(desc); 387 unsigned pin;
593 struct irq_data *idata = irq_desc_get_irq_data(desc); 388 struct irq_data *idata = irq_desc_get_irq_data(desc);
389 struct irq_chip *chip = irq_data_get_irq_chip(idata);
594 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata); 390 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata);
595 void __iomem *pio = at91_gpio->regbase; 391 void __iomem *pio = at91_gpio->regbase;
596 unsigned long isr; 392 u32 isr;
597 int n;
598 393
599 chained_irq_enter(chip, desc); 394 /* temporarily mask (level sensitive) parent IRQ */
395 chip->irq_ack(idata);
600 for (;;) { 396 for (;;) {
601 /* Reading ISR acks pending (edge triggered) GPIO interrupts. 397 /* Reading ISR acks pending (edge triggered) GPIO interrupts.
602 * When there none are pending, we're finished unless we need 398 * When there none are pending, we're finished unless we need
@@ -611,13 +407,16 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
611 continue; 407 continue;
612 } 408 }
613 409
614 n = find_first_bit(&isr, BITS_PER_LONG); 410 pin = at91_gpio->chip.base;
615 while (n < BITS_PER_LONG) { 411
616 generic_handle_irq(irq_find_mapping(at91_gpio->domain, n)); 412 while (isr) {
617 n = find_next_bit(&isr, BITS_PER_LONG, n + 1); 413 if (isr & 1)
414 generic_handle_irq(pin);
415 pin++;
416 isr >>= 1;
618 } 417 }
619 } 418 }
620 chained_irq_exit(chip, desc); 419 chip->irq_unmask(idata);
621 /* now it may re-trigger */ 420 /* now it may re-trigger */
622} 421}
623 422
@@ -625,33 +424,6 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
625 424
626#ifdef CONFIG_DEBUG_FS 425#ifdef CONFIG_DEBUG_FS
627 426
628static void gpio_printf(struct seq_file *s, void __iomem *pio, unsigned mask)
629{
630 char *trigger = NULL;
631 char *polarity = NULL;
632
633 if (__raw_readl(pio + PIO_IMR) & mask) {
634 if (!has_pio3() || !(__raw_readl(pio + PIO_AIMMR) & mask )) {
635 trigger = "edge";
636 polarity = "both";
637 } else {
638 if (__raw_readl(pio + PIO_ELSR) & mask) {
639 trigger = "level";
640 polarity = __raw_readl(pio + PIO_FRLHSR) & mask ?
641 "high" : "low";
642 } else {
643 trigger = "edge";
644 polarity = __raw_readl(pio + PIO_FRLHSR) & mask ?
645 "rising" : "falling";
646 }
647 }
648 seq_printf(s, "IRQ:%s-%s\t", trigger, polarity);
649 } else {
650 seq_printf(s, "GPIO:%s\t\t",
651 __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0");
652 }
653}
654
655static int at91_gpio_show(struct seq_file *s, void *unused) 427static int at91_gpio_show(struct seq_file *s, void *unused)
656{ 428{
657 int bank, j; 429 int bank, j;
@@ -659,7 +431,7 @@ static int at91_gpio_show(struct seq_file *s, void *unused)
659 /* print heading */ 431 /* print heading */
660 seq_printf(s, "Pin\t"); 432 seq_printf(s, "Pin\t");
661 for (bank = 0; bank < gpio_banks; bank++) { 433 for (bank = 0; bank < gpio_banks; bank++) {
662 seq_printf(s, "PIO%c\t\t", 'A' + bank); 434 seq_printf(s, "PIO%c\t", 'A' + bank);
663 }; 435 };
664 seq_printf(s, "\n\n"); 436 seq_printf(s, "\n\n");
665 437
@@ -668,15 +440,16 @@ static int at91_gpio_show(struct seq_file *s, void *unused)
668 seq_printf(s, "%i:\t", j); 440 seq_printf(s, "%i:\t", j);
669 441
670 for (bank = 0; bank < gpio_banks; bank++) { 442 for (bank = 0; bank < gpio_banks; bank++) {
671 unsigned pin = (32 * bank) + j; 443 unsigned pin = PIN_BASE + (32 * bank) + j;
672 void __iomem *pio = pin_to_controller(pin); 444 void __iomem *pio = pin_to_controller(pin);
673 unsigned mask = pin_to_mask(pin); 445 unsigned mask = pin_to_mask(pin);
674 446
675 if (__raw_readl(pio + PIO_PSR) & mask) 447 if (__raw_readl(pio + PIO_PSR) & mask)
676 gpio_printf(s, pio, mask); 448 seq_printf(s, "GPIO:%s", __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0");
677 else 449 else
678 seq_printf(s, "%c\t\t", 450 seq_printf(s, "%s", __raw_readl(pio + PIO_ABSR) & mask ? "B" : "A");
679 peripheral_function(pio, mask)); 451
452 seq_printf(s, "\t");
680 } 453 }
681 454
682 seq_printf(s, "\n"); 455 seq_printf(s, "\n");
@@ -716,90 +489,47 @@ postcore_initcall(at91_gpio_debugfs_init);
716static struct lock_class_key gpio_lock_class; 489static struct lock_class_key gpio_lock_class;
717 490
718/* 491/*
719 * irqdomain initialization: pile up irqdomains on top of AIC range
720 */
721static void __init at91_gpio_irqdomain(struct at91_gpio_chip *at91_gpio)
722{
723 int irq_base;
724
725 irq_base = irq_alloc_descs(-1, 0, at91_gpio->chip.ngpio, 0);
726 if (irq_base < 0)
727 panic("at91_gpio.%d: error %d: couldn't allocate IRQ numbers.\n",
728 at91_gpio->pioc_idx, irq_base);
729 at91_gpio->domain = irq_domain_add_legacy(NULL, at91_gpio->chip.ngpio,
730 irq_base, 0,
731 &irq_domain_simple_ops, NULL);
732 if (!at91_gpio->domain)
733 panic("at91_gpio.%d: couldn't allocate irq domain.\n",
734 at91_gpio->pioc_idx);
735}
736
737/*
738 * Called from the processor-specific init to enable GPIO interrupt support. 492 * Called from the processor-specific init to enable GPIO interrupt support.
739 */ 493 */
740void __init at91_gpio_irq_setup(void) 494void __init at91_gpio_irq_setup(void)
741{ 495{
742 unsigned pioc; 496 unsigned pioc, pin;
743 int gpio_irqnbr = 0;
744 struct at91_gpio_chip *this, *prev; 497 struct at91_gpio_chip *this, *prev;
745 498
746 /* Setup proper .irq_set_type function */ 499 for (pioc = 0, pin = PIN_BASE, this = gpio_chip, prev = NULL;
747 if (has_pio3())
748 gpio_irqchip.irq_set_type = alt_gpio_irq_type;
749 else
750 gpio_irqchip.irq_set_type = gpio_irq_type;
751
752 for (pioc = 0, this = gpio_chip, prev = NULL;
753 pioc++ < gpio_banks; 500 pioc++ < gpio_banks;
754 prev = this, this++) { 501 prev = this, this++) {
755 int offset; 502 unsigned id = this->bank->id;
503 unsigned i;
756 504
757 __raw_writel(~0, this->regbase + PIO_IDR); 505 __raw_writel(~0, this->regbase + PIO_IDR);
758 506
759 /* setup irq domain for this GPIO controller */ 507 for (i = 0, pin = this->chip.base; i < 32; i++, pin++) {
760 at91_gpio_irqdomain(this); 508 irq_set_lockdep_class(pin, &gpio_lock_class);
761
762 for (offset = 0; offset < this->chip.ngpio; offset++) {
763 unsigned int virq = irq_find_mapping(this->domain, offset);
764 irq_set_lockdep_class(virq, &gpio_lock_class);
765 509
766 /* 510 /*
767 * Can use the "simple" and not "edge" handler since it's 511 * Can use the "simple" and not "edge" handler since it's
768 * shorter, and the AIC handles interrupts sanely. 512 * shorter, and the AIC handles interrupts sanely.
769 */ 513 */
770 irq_set_chip_and_handler(virq, &gpio_irqchip, 514 irq_set_chip_and_handler(pin, &gpio_irqchip,
771 handle_simple_irq); 515 handle_simple_irq);
772 set_irq_flags(virq, IRQF_VALID); 516 set_irq_flags(pin, IRQF_VALID);
773 irq_set_chip_data(virq, this);
774
775 gpio_irqnbr++;
776 } 517 }
777 518
778 /* The toplevel handler handles one bank of GPIOs, except 519 /* The toplevel handler handles one bank of GPIOs, except
779 * on some SoC it can handles up to three... 520 * AT91SAM9263_ID_PIOCDE handles three... PIOC is first in
780 * We only set up the handler for the first of the list. 521 * the list, so we only set up that handler.
781 */ 522 */
782 if (prev && prev->next == this) 523 if (prev && prev->next == this)
783 continue; 524 continue;
784 525
785 this->pioc_virq = irq_create_mapping(NULL, this->pioc_hwirq); 526 irq_set_chip_data(id, this);
786 irq_set_chip_data(this->pioc_virq, this); 527 irq_set_chained_handler(id, gpio_irq_handler);
787 irq_set_chained_handler(this->pioc_virq, gpio_irq_handler);
788 } 528 }
789 pr_info("AT91: %d gpio irqs in %d banks\n", gpio_irqnbr, gpio_banks); 529 pr_info("AT91: %d gpio irqs in %d banks\n", pin - PIN_BASE, gpio_banks);
790} 530}
791 531
792/* gpiolib support */ 532/* gpiolib support */
793static int at91_gpiolib_request(struct gpio_chip *chip, unsigned offset)
794{
795 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
796 void __iomem *pio = at91_gpio->regbase;
797 unsigned mask = 1 << offset;
798
799 __raw_writel(mask, pio + PIO_PER);
800 return 0;
801}
802
803static int at91_gpiolib_direction_input(struct gpio_chip *chip, 533static int at91_gpiolib_direction_input(struct gpio_chip *chip,
804 unsigned offset) 534 unsigned offset)
805{ 535{
@@ -862,105 +592,38 @@ static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
862 at91_get_gpio_value(pin) ? 592 at91_get_gpio_value(pin) ?
863 "set" : "clear"); 593 "set" : "clear");
864 else 594 else
865 seq_printf(s, "[periph %c]\n", 595 seq_printf(s, "[periph %s]\n",
866 peripheral_function(pio, mask)); 596 __raw_readl(pio + PIO_ABSR) &
597 mask ? "B" : "A");
867 } 598 }
868 } 599 }
869} 600}
870 601
871static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset)
872{
873 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
874 int virq;
875
876 if (offset < chip->ngpio)
877 virq = irq_create_mapping(at91_gpio->domain, offset);
878 else
879 virq = -ENXIO;
880
881 dev_dbg(chip->dev, "%s: request IRQ for GPIO %d, return %d\n",
882 chip->label, offset + chip->base, virq);
883 return virq;
884}
885
886static int __init at91_gpio_setup_clk(int idx)
887{
888 struct at91_gpio_chip *at91_gpio = &gpio_chip[idx];
889
890 /* retreive PIO controller's clock */
891 at91_gpio->clock = clk_get_sys(NULL, at91_gpio->chip.label);
892 if (IS_ERR(at91_gpio->clock)) {
893 pr_err("at91_gpio.%d, failed to get clock, ignoring.\n", idx);
894 goto err;
895 }
896
897 if (clk_prepare(at91_gpio->clock))
898 goto clk_prep_err;
899
900 /* enable PIO controller's clock */
901 if (clk_enable(at91_gpio->clock)) {
902 pr_err("at91_gpio.%d, failed to enable clock, ignoring.\n", idx);
903 goto clk_err;
904 }
905
906 return 0;
907
908clk_err:
909 clk_unprepare(at91_gpio->clock);
910clk_prep_err:
911 clk_put(at91_gpio->clock);
912err:
913 return -EINVAL;
914}
915
916static void __init at91_gpio_init_one(int idx, u32 regbase, int pioc_hwirq)
917{
918 struct at91_gpio_chip *at91_gpio = &gpio_chip[idx];
919
920 at91_gpio->chip.base = idx * MAX_NB_GPIO_PER_BANK;
921 at91_gpio->pioc_hwirq = pioc_hwirq;
922 at91_gpio->pioc_idx = idx;
923
924 at91_gpio->regbase = ioremap(regbase, 512);
925 if (!at91_gpio->regbase) {
926 pr_err("at91_gpio.%d, failed to map registers, ignoring.\n", idx);
927 return;
928 }
929
930 if (at91_gpio_setup_clk(idx))
931 goto ioremap_err;
932
933 gpio_banks = max(gpio_banks, idx + 1);
934 return;
935
936ioremap_err:
937 iounmap(at91_gpio->regbase);
938}
939
940/* 602/*
941 * Called from the processor-specific init to enable GPIO pin support. 603 * Called from the processor-specific init to enable GPIO pin support.
942 */ 604 */
943void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks) 605void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks)
944{ 606{
945 unsigned i; 607 unsigned i;
946 struct at91_gpio_chip *at91_gpio, *last = NULL; 608 struct at91_gpio_chip *at91_gpio, *last = NULL;
947 609
948 BUG_ON(nr_banks > MAX_GPIO_BANKS); 610 BUG_ON(nr_banks > MAX_GPIO_BANKS);
949 611
950 if (of_have_populated_dt()) 612 gpio_banks = nr_banks;
951 return;
952
953 for (i = 0; i < nr_banks; i++)
954 at91_gpio_init_one(i, data[i].regbase, data[i].id);
955 613
956 for (i = 0; i < gpio_banks; i++) { 614 for (i = 0; i < nr_banks; i++) {
957 at91_gpio = &gpio_chip[i]; 615 at91_gpio = &gpio_chip[i];
958 616
959 /* 617 at91_gpio->bank = &data[i];
960 * GPIO controller are grouped on some SoC: 618 at91_gpio->chip.base = PIN_BASE + i * 32;
961 * PIOC, PIOD and PIOE can share the same IRQ line 619 at91_gpio->regbase = at91_gpio->bank->offset +
962 */ 620 (void __iomem *)AT91_VA_BASE_SYS;
963 if (last && last->pioc_hwirq == at91_gpio->pioc_hwirq) 621
622 /* enable PIO controller's clock */
623 clk_enable(at91_gpio->bank->clock);
624
625 /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */
626 if (last && last->bank->id == at91_gpio->bank->id)
964 last->next = at91_gpio; 627 last->next = at91_gpio;
965 last = at91_gpio; 628 last = at91_gpio;
966 629
diff --git a/arch/arm/mach-at91/gsia18s.h b/arch/arm/mach-at91/gsia18s.h
deleted file mode 100644
index 307c194926f..00000000000
--- a/arch/arm/mach-at91/gsia18s.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/* Buttons */
2#define GPIO_TRIG_NET_IN AT91_PIN_PB21
3#define GPIO_CARD_UNMOUNT_0 AT91_PIN_PB13
4#define GPIO_CARD_UNMOUNT_1 AT91_PIN_PB12
5#define GPIO_KEY_POWER AT91_PIN_PA25
6
7/* PCF8574 0x20 GPIO - U1 on the GS_IA18-CB_V3 board */
8#define GS_IA18_S_PCF_GPIO_BASE0 NR_BUILTIN_GPIO
9#define PCF_GPIO_HDC_POWER (GS_IA18_S_PCF_GPIO_BASE0 + 0)
10#define PCF_GPIO_WIFI_SETUP (GS_IA18_S_PCF_GPIO_BASE0 + 1)
11#define PCF_GPIO_WIFI_ENABLE (GS_IA18_S_PCF_GPIO_BASE0 + 2)
12#define PCF_GPIO_WIFI_RESET (GS_IA18_S_PCF_GPIO_BASE0 + 3)
13#define PCF_GPIO_ETH_DETECT 4 /* this is a GPI */
14#define PCF_GPIO_GPS_SETUP (GS_IA18_S_PCF_GPIO_BASE0 + 5)
15#define PCF_GPIO_GPS_STANDBY (GS_IA18_S_PCF_GPIO_BASE0 + 6)
16#define PCF_GPIO_GPS_POWER (GS_IA18_S_PCF_GPIO_BASE0 + 7)
17
18/* PCF8574 0x22 GPIO - U1 on the GS_2G_OPT1-A_V0 board (Alarm) */
19#define GS_IA18_S_PCF_GPIO_BASE1 (GS_IA18_S_PCF_GPIO_BASE0 + 8)
20#define PCF_GPIO_ALARM1 (GS_IA18_S_PCF_GPIO_BASE1 + 0)
21#define PCF_GPIO_ALARM2 (GS_IA18_S_PCF_GPIO_BASE1 + 1)
22#define PCF_GPIO_ALARM3 (GS_IA18_S_PCF_GPIO_BASE1 + 2)
23#define PCF_GPIO_ALARM4 (GS_IA18_S_PCF_GPIO_BASE1 + 3)
24/* bits 4, 5, 6 not used */
25#define PCF_GPIO_ALARM_V_RELAY_ON (GS_IA18_S_PCF_GPIO_BASE1 + 7)
26
27/* PCF8574 0x24 GPIO U1 on the GS_2G-OPT23-A_V0 board (Modem) */
28#define GS_IA18_S_PCF_GPIO_BASE2 (GS_IA18_S_PCF_GPIO_BASE1 + 8)
29#define PCF_GPIO_MODEM_POWER (GS_IA18_S_PCF_GPIO_BASE2 + 0)
30#define PCF_GPIO_MODEM_RESET (GS_IA18_S_PCF_GPIO_BASE2 + 3)
31/* bits 1, 2, 4, 5 not used */
32#define PCF_GPIO_TRX_RESET (GS_IA18_S_PCF_GPIO_BASE2 + 6)
33/* bit 7 not used */
diff --git a/arch/arm/mach-at91/include/mach/at91_dbgu.h b/arch/arm/mach-at91/include/mach/at91_dbgu.h
index 2aa0c5e1349..dbfe455a4c4 100644
--- a/arch/arm/mach-at91/include/mach/at91_dbgu.h
+++ b/arch/arm/mach-at91/include/mach/at91_dbgu.h
@@ -19,7 +19,7 @@
19#define dbgu_readl(dbgu, field) \ 19#define dbgu_readl(dbgu, field) \
20 __raw_readl(AT91_VA_BASE_SYS + dbgu + AT91_DBGU_ ## field) 20 __raw_readl(AT91_VA_BASE_SYS + dbgu + AT91_DBGU_ ## field)
21 21
22#if !defined(CONFIG_ARCH_AT91X40) 22#ifdef AT91_DBGU
23#define AT91_DBGU_CR (0x00) /* Control Register */ 23#define AT91_DBGU_CR (0x00) /* Control Register */
24#define AT91_DBGU_MR (0x04) /* Mode Register */ 24#define AT91_DBGU_MR (0x04) /* Mode Register */
25#define AT91_DBGU_IER (0x08) /* Interrupt Enable Register */ 25#define AT91_DBGU_IER (0x08) /* Interrupt Enable Register */
diff --git a/arch/arm/mach-at91/include/mach/at91_matrix.h b/arch/arm/mach-at91/include/mach/at91_matrix.h
deleted file mode 100644
index 02fae9de746..00000000000
--- a/arch/arm/mach-at91/include/mach/at91_matrix.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/*
2 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
3 *
4 * Under GPLv2
5 */
6
7#ifndef __MACH_AT91_MATRIX_H__
8#define __MACH_AT91_MATRIX_H__
9
10#ifndef __ASSEMBLY__
11extern void __iomem *at91_matrix_base;
12
13#define at91_matrix_read(field) \
14 __raw_readl(at91_matrix_base + field)
15
16#define at91_matrix_write(field, value) \
17 __raw_writel(value, at91_matrix_base + field);
18
19#else
20.extern at91_matrix_base
21#endif
22
23#endif /* __MACH_AT91_MATRIX_H__ */
diff --git a/arch/arm/mach-at91/include/mach/at91_pio.h b/arch/arm/mach-at91/include/mach/at91_pio.h
index 732b11c37f1..c6a31bf8a5c 100644
--- a/arch/arm/mach-at91/include/mach/at91_pio.h
+++ b/arch/arm/mach-at91/include/mach/at91_pio.h
@@ -40,35 +40,10 @@
40#define PIO_PUER 0x64 /* Pull-up Enable Register */ 40#define PIO_PUER 0x64 /* Pull-up Enable Register */
41#define PIO_PUSR 0x68 /* Pull-up Status Register */ 41#define PIO_PUSR 0x68 /* Pull-up Status Register */
42#define PIO_ASR 0x70 /* Peripheral A Select Register */ 42#define PIO_ASR 0x70 /* Peripheral A Select Register */
43#define PIO_ABCDSR1 0x70 /* Peripheral ABCD Select Register 1 [some sam9 only] */
44#define PIO_BSR 0x74 /* Peripheral B Select Register */ 43#define PIO_BSR 0x74 /* Peripheral B Select Register */
45#define PIO_ABCDSR2 0x74 /* Peripheral ABCD Select Register 2 [some sam9 only] */
46#define PIO_ABSR 0x78 /* AB Status Register */ 44#define PIO_ABSR 0x78 /* AB Status Register */
47#define PIO_IFSCDR 0x80 /* Input Filter Slow Clock Disable Register */
48#define PIO_IFSCER 0x84 /* Input Filter Slow Clock Enable Register */
49#define PIO_IFSCSR 0x88 /* Input Filter Slow Clock Status Register */
50#define PIO_SCDR 0x8c /* Slow Clock Divider Debouncing Register */
51#define PIO_SCDR_DIV (0x3fff << 0) /* Slow Clock Divider Mask */
52#define PIO_PPDDR 0x90 /* Pad Pull-down Disable Register */
53#define PIO_PPDER 0x94 /* Pad Pull-down Enable Register */
54#define PIO_PPDSR 0x98 /* Pad Pull-down Status Register */
55#define PIO_OWER 0xa0 /* Output Write Enable Register */ 45#define PIO_OWER 0xa0 /* Output Write Enable Register */
56#define PIO_OWDR 0xa4 /* Output Write Disable Register */ 46#define PIO_OWDR 0xa4 /* Output Write Disable Register */
57#define PIO_OWSR 0xa8 /* Output Write Status Register */ 47#define PIO_OWSR 0xa8 /* Output Write Status Register */
58#define PIO_AIMER 0xb0 /* Additional Interrupt Modes Enable Register */
59#define PIO_AIMDR 0xb4 /* Additional Interrupt Modes Disable Register */
60#define PIO_AIMMR 0xb8 /* Additional Interrupt Modes Mask Register */
61#define PIO_ESR 0xc0 /* Edge Select Register */
62#define PIO_LSR 0xc4 /* Level Select Register */
63#define PIO_ELSR 0xc8 /* Edge/Level Status Register */
64#define PIO_FELLSR 0xd0 /* Falling Edge/Low Level Select Register */
65#define PIO_REHLSR 0xd4 /* Rising Edge/ High Level Select Register */
66#define PIO_FRLHSR 0xd8 /* Fall/Rise - Low/High Status Register */
67#define PIO_SCHMITT 0x100 /* Schmitt Trigger Register */
68
69#define ABCDSR_PERIPH_A 0x0
70#define ABCDSR_PERIPH_B 0x1
71#define ABCDSR_PERIPH_C 0x2
72#define ABCDSR_PERIPH_D 0x3
73 48
74#endif 49#endif
diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h b/arch/arm/mach-at91/include/mach/at91_pmc.h
index ea2c57a86ca..e46f93e34aa 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -16,27 +16,17 @@
16#ifndef AT91_PMC_H 16#ifndef AT91_PMC_H
17#define AT91_PMC_H 17#define AT91_PMC_H
18 18
19#ifndef __ASSEMBLY__ 19#define AT91_PMC_SCER (AT91_PMC + 0x00) /* System Clock Enable Register */
20extern void __iomem *at91_pmc_base; 20#define AT91_PMC_SCDR (AT91_PMC + 0x04) /* System Clock Disable Register */
21 21
22#define at91_pmc_read(field) \ 22#define AT91_PMC_SCSR (AT91_PMC + 0x08) /* System Clock Status Register */
23 __raw_readl(at91_pmc_base + field)
24
25#define at91_pmc_write(field, value) \
26 __raw_writel(value, at91_pmc_base + field)
27#else
28.extern at91_pmc_base
29#endif
30
31#define AT91_PMC_SCER 0x00 /* System Clock Enable Register */
32#define AT91_PMC_SCDR 0x04 /* System Clock Disable Register */
33
34#define AT91_PMC_SCSR 0x08 /* System Clock Status Register */
35#define AT91_PMC_PCK (1 << 0) /* Processor Clock */ 23#define AT91_PMC_PCK (1 << 0) /* Processor Clock */
36#define AT91RM9200_PMC_UDP (1 << 1) /* USB Devcice Port Clock [AT91RM9200 only] */ 24#define AT91RM9200_PMC_UDP (1 << 1) /* USB Devcice Port Clock [AT91RM9200 only] */
37#define AT91RM9200_PMC_MCKUDP (1 << 2) /* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */ 25#define AT91RM9200_PMC_MCKUDP (1 << 2) /* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */
26#define AT91CAP9_PMC_DDR (1 << 2) /* DDR Clock [CAP9 revC & some SAM9 only] */
38#define AT91RM9200_PMC_UHP (1 << 4) /* USB Host Port Clock [AT91RM9200 only] */ 27#define AT91RM9200_PMC_UHP (1 << 4) /* USB Host Port Clock [AT91RM9200 only] */
39#define AT91SAM926x_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91SAM926x only] */ 28#define AT91SAM926x_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91SAM926x only] */
29#define AT91CAP9_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91CAP9 only] */
40#define AT91SAM926x_PMC_UDP (1 << 7) /* USB Devcice Port Clock [AT91SAM926x only] */ 30#define AT91SAM926x_PMC_UDP (1 << 7) /* USB Devcice Port Clock [AT91SAM926x only] */
41#define AT91_PMC_PCK0 (1 << 8) /* Programmable Clock 0 */ 31#define AT91_PMC_PCK0 (1 << 8) /* Programmable Clock 0 */
42#define AT91_PMC_PCK1 (1 << 9) /* Programmable Clock 1 */ 32#define AT91_PMC_PCK1 (1 << 9) /* Programmable Clock 1 */
@@ -46,31 +36,27 @@ extern void __iomem *at91_pmc_base;
46#define AT91_PMC_HCK0 (1 << 16) /* AHB Clock (USB host) [AT91SAM9261 only] */ 36#define AT91_PMC_HCK0 (1 << 16) /* AHB Clock (USB host) [AT91SAM9261 only] */
47#define AT91_PMC_HCK1 (1 << 17) /* AHB Clock (LCD) [AT91SAM9261 only] */ 37#define AT91_PMC_HCK1 (1 << 17) /* AHB Clock (LCD) [AT91SAM9261 only] */
48 38
49#define AT91_PMC_PCER 0x10 /* Peripheral Clock Enable Register */ 39#define AT91_PMC_PCER (AT91_PMC + 0x10) /* Peripheral Clock Enable Register */
50#define AT91_PMC_PCDR 0x14 /* Peripheral Clock Disable Register */ 40#define AT91_PMC_PCDR (AT91_PMC + 0x14) /* Peripheral Clock Disable Register */
51#define AT91_PMC_PCSR 0x18 /* Peripheral Clock Status Register */ 41#define AT91_PMC_PCSR (AT91_PMC + 0x18) /* Peripheral Clock Status Register */
52 42
53#define AT91_CKGR_UCKR 0x1C /* UTMI Clock Register [some SAM9] */ 43#define AT91_CKGR_UCKR (AT91_PMC + 0x1C) /* UTMI Clock Register [some SAM9, CAP9] */
54#define AT91_PMC_UPLLEN (1 << 16) /* UTMI PLL Enable */ 44#define AT91_PMC_UPLLEN (1 << 16) /* UTMI PLL Enable */
55#define AT91_PMC_UPLLCOUNT (0xf << 20) /* UTMI PLL Start-up Time */ 45#define AT91_PMC_UPLLCOUNT (0xf << 20) /* UTMI PLL Start-up Time */
56#define AT91_PMC_BIASEN (1 << 24) /* UTMI BIAS Enable */ 46#define AT91_PMC_BIASEN (1 << 24) /* UTMI BIAS Enable */
57#define AT91_PMC_BIASCOUNT (0xf << 28) /* UTMI BIAS Start-up Time */ 47#define AT91_PMC_BIASCOUNT (0xf << 28) /* UTMI BIAS Start-up Time */
58 48
59#define AT91_CKGR_MOR 0x20 /* Main Oscillator Register [not on SAM9RL] */ 49#define AT91_CKGR_MOR (AT91_PMC + 0x20) /* Main Oscillator Register [not on SAM9RL] */
60#define AT91_PMC_MOSCEN (1 << 0) /* Main Oscillator Enable */ 50#define AT91_PMC_MOSCEN (1 << 0) /* Main Oscillator Enable */
61#define AT91_PMC_OSCBYPASS (1 << 1) /* Oscillator Bypass */ 51#define AT91_PMC_OSCBYPASS (1 << 1) /* Oscillator Bypass [SAM9x, CAP9] */
62#define AT91_PMC_MOSCRCEN (1 << 3) /* Main On-Chip RC Oscillator Enable [some SAM9] */ 52#define AT91_PMC_OSCOUNT (0xff << 8) /* Main Oscillator Start-up Time */
63#define AT91_PMC_OSCOUNT (0xff << 8) /* Main Oscillator Start-up Time */
64#define AT91_PMC_KEY (0x37 << 16) /* MOR Writing Key */
65#define AT91_PMC_MOSCSEL (1 << 24) /* Main Oscillator Selection [some SAM9] */
66#define AT91_PMC_CFDEN (1 << 25) /* Clock Failure Detector Enable [some SAM9] */
67 53
68#define AT91_CKGR_MCFR 0x24 /* Main Clock Frequency Register */ 54#define AT91_CKGR_MCFR (AT91_PMC + 0x24) /* Main Clock Frequency Register */
69#define AT91_PMC_MAINF (0xffff << 0) /* Main Clock Frequency */ 55#define AT91_PMC_MAINF (0xffff << 0) /* Main Clock Frequency */
70#define AT91_PMC_MAINRDY (1 << 16) /* Main Clock Ready */ 56#define AT91_PMC_MAINRDY (1 << 16) /* Main Clock Ready */
71 57
72#define AT91_CKGR_PLLAR 0x28 /* PLL A Register */ 58#define AT91_CKGR_PLLAR (AT91_PMC + 0x28) /* PLL A Register */
73#define AT91_CKGR_PLLBR 0x2c /* PLL B Register */ 59#define AT91_CKGR_PLLBR (AT91_PMC + 0x2c) /* PLL B Register */
74#define AT91_PMC_DIV (0xff << 0) /* Divider */ 60#define AT91_PMC_DIV (0xff << 0) /* Divider */
75#define AT91_PMC_PLLCOUNT (0x3f << 8) /* PLL Counter */ 61#define AT91_PMC_PLLCOUNT (0x3f << 8) /* PLL Counter */
76#define AT91_PMC_OUT (3 << 14) /* PLL Clock Frequency Range */ 62#define AT91_PMC_OUT (3 << 14) /* PLL Clock Frequency Range */
@@ -81,37 +67,27 @@ extern void __iomem *at91_pmc_base;
81#define AT91_PMC_USBDIV_4 (2 << 28) 67#define AT91_PMC_USBDIV_4 (2 << 28)
82#define AT91_PMC_USB96M (1 << 28) /* Divider by 2 Enable (PLLB only) */ 68#define AT91_PMC_USB96M (1 << 28) /* Divider by 2 Enable (PLLB only) */
83 69
84#define AT91_PMC_MCKR 0x30 /* Master Clock Register */ 70#define AT91_PMC_MCKR (AT91_PMC + 0x30) /* Master Clock Register */
85#define AT91_PMC_CSS (3 << 0) /* Master Clock Selection */ 71#define AT91_PMC_CSS (3 << 0) /* Master Clock Selection */
86#define AT91_PMC_CSS_SLOW (0 << 0) 72#define AT91_PMC_CSS_SLOW (0 << 0)
87#define AT91_PMC_CSS_MAIN (1 << 0) 73#define AT91_PMC_CSS_MAIN (1 << 0)
88#define AT91_PMC_CSS_PLLA (2 << 0) 74#define AT91_PMC_CSS_PLLA (2 << 0)
89#define AT91_PMC_CSS_PLLB (3 << 0) 75#define AT91_PMC_CSS_PLLB (3 << 0)
90#define AT91_PMC_CSS_UPLL (3 << 0) /* [some SAM9 only] */ 76#define AT91_PMC_CSS_UPLL (3 << 0) /* [some SAM9 only] */
91#define PMC_PRES_OFFSET 2 77#define AT91_PMC_PRES (7 << 2) /* Master Clock Prescaler */
92#define AT91_PMC_PRES (7 << PMC_PRES_OFFSET) /* Master Clock Prescaler */ 78#define AT91_PMC_PRES_1 (0 << 2)
93#define AT91_PMC_PRES_1 (0 << PMC_PRES_OFFSET) 79#define AT91_PMC_PRES_2 (1 << 2)
94#define AT91_PMC_PRES_2 (1 << PMC_PRES_OFFSET) 80#define AT91_PMC_PRES_4 (2 << 2)
95#define AT91_PMC_PRES_4 (2 << PMC_PRES_OFFSET) 81#define AT91_PMC_PRES_8 (3 << 2)
96#define AT91_PMC_PRES_8 (3 << PMC_PRES_OFFSET) 82#define AT91_PMC_PRES_16 (4 << 2)
97#define AT91_PMC_PRES_16 (4 << PMC_PRES_OFFSET) 83#define AT91_PMC_PRES_32 (5 << 2)
98#define AT91_PMC_PRES_32 (5 << PMC_PRES_OFFSET) 84#define AT91_PMC_PRES_64 (6 << 2)
99#define AT91_PMC_PRES_64 (6 << PMC_PRES_OFFSET)
100#define PMC_ALT_PRES_OFFSET 4
101#define AT91_PMC_ALT_PRES (7 << PMC_ALT_PRES_OFFSET) /* Master Clock Prescaler [alternate location] */
102#define AT91_PMC_ALT_PRES_1 (0 << PMC_ALT_PRES_OFFSET)
103#define AT91_PMC_ALT_PRES_2 (1 << PMC_ALT_PRES_OFFSET)
104#define AT91_PMC_ALT_PRES_4 (2 << PMC_ALT_PRES_OFFSET)
105#define AT91_PMC_ALT_PRES_8 (3 << PMC_ALT_PRES_OFFSET)
106#define AT91_PMC_ALT_PRES_16 (4 << PMC_ALT_PRES_OFFSET)
107#define AT91_PMC_ALT_PRES_32 (5 << PMC_ALT_PRES_OFFSET)
108#define AT91_PMC_ALT_PRES_64 (6 << PMC_ALT_PRES_OFFSET)
109#define AT91_PMC_MDIV (3 << 8) /* Master Clock Division */ 85#define AT91_PMC_MDIV (3 << 8) /* Master Clock Division */
110#define AT91RM9200_PMC_MDIV_1 (0 << 8) /* [AT91RM9200 only] */ 86#define AT91RM9200_PMC_MDIV_1 (0 << 8) /* [AT91RM9200 only] */
111#define AT91RM9200_PMC_MDIV_2 (1 << 8) 87#define AT91RM9200_PMC_MDIV_2 (1 << 8)
112#define AT91RM9200_PMC_MDIV_3 (2 << 8) 88#define AT91RM9200_PMC_MDIV_3 (2 << 8)
113#define AT91RM9200_PMC_MDIV_4 (3 << 8) 89#define AT91RM9200_PMC_MDIV_4 (3 << 8)
114#define AT91SAM9_PMC_MDIV_1 (0 << 8) /* [SAM9 only] */ 90#define AT91SAM9_PMC_MDIV_1 (0 << 8) /* [SAM9,CAP9 only] */
115#define AT91SAM9_PMC_MDIV_2 (1 << 8) 91#define AT91SAM9_PMC_MDIV_2 (1 << 8)
116#define AT91SAM9_PMC_MDIV_4 (2 << 8) 92#define AT91SAM9_PMC_MDIV_4 (2 << 8)
117#define AT91SAM9_PMC_MDIV_6 (3 << 8) /* [some SAM9 only] */ 93#define AT91SAM9_PMC_MDIV_6 (3 << 8) /* [some SAM9 only] */
@@ -123,55 +99,35 @@ extern void __iomem *at91_pmc_base;
123#define AT91_PMC_PLLADIV2_OFF (0 << 12) 99#define AT91_PMC_PLLADIV2_OFF (0 << 12)
124#define AT91_PMC_PLLADIV2_ON (1 << 12) 100#define AT91_PMC_PLLADIV2_ON (1 << 12)
125 101
126#define AT91_PMC_USB 0x38 /* USB Clock Register [some SAM9 only] */ 102#define AT91_PMC_USB (AT91_PMC + 0x38) /* USB Clock Register [some SAM9 only] */
127#define AT91_PMC_USBS (0x1 << 0) /* USB OHCI Input clock selection */ 103#define AT91_PMC_USBS (0x1 << 0) /* USB OHCI Input clock selection */
128#define AT91_PMC_USBS_PLLA (0 << 0) 104#define AT91_PMC_USBS_PLLA (0 << 0)
129#define AT91_PMC_USBS_UPLL (1 << 0) 105#define AT91_PMC_USBS_UPLL (1 << 0)
130#define AT91_PMC_OHCIUSBDIV (0xF << 8) /* Divider for USB OHCI Clock */ 106#define AT91_PMC_OHCIUSBDIV (0xF << 8) /* Divider for USB OHCI Clock */
131 107
132#define AT91_PMC_SMD 0x3c /* Soft Modem Clock Register [some SAM9 only] */ 108#define AT91_PMC_PCKR(n) (AT91_PMC + 0x40 + ((n) * 4)) /* Programmable Clock 0-N Registers */
133#define AT91_PMC_SMDS (0x1 << 0) /* SMD input clock selection */
134#define AT91_PMC_SMD_DIV (0x1f << 8) /* SMD input clock divider */
135#define AT91_PMC_SMDDIV(n) (((n) << 8) & AT91_PMC_SMD_DIV)
136
137#define AT91_PMC_PCKR(n) (0x40 + ((n) * 4)) /* Programmable Clock 0-N Registers */
138#define AT91_PMC_ALT_PCKR_CSS (0x7 << 0) /* Programmable Clock Source Selection [alternate length] */
139#define AT91_PMC_CSS_MASTER (4 << 0) /* [some SAM9 only] */
140#define AT91_PMC_CSSMCK (0x1 << 8) /* CSS or Master Clock Selection */ 109#define AT91_PMC_CSSMCK (0x1 << 8) /* CSS or Master Clock Selection */
141#define AT91_PMC_CSSMCK_CSS (0 << 8) 110#define AT91_PMC_CSSMCK_CSS (0 << 8)
142#define AT91_PMC_CSSMCK_MCK (1 << 8) 111#define AT91_PMC_CSSMCK_MCK (1 << 8)
143 112
144#define AT91_PMC_IER 0x60 /* Interrupt Enable Register */ 113#define AT91_PMC_IER (AT91_PMC + 0x60) /* Interrupt Enable Register */
145#define AT91_PMC_IDR 0x64 /* Interrupt Disable Register */ 114#define AT91_PMC_IDR (AT91_PMC + 0x64) /* Interrupt Disable Register */
146#define AT91_PMC_SR 0x68 /* Status Register */ 115#define AT91_PMC_SR (AT91_PMC + 0x68) /* Status Register */
147#define AT91_PMC_MOSCS (1 << 0) /* MOSCS Flag */ 116#define AT91_PMC_MOSCS (1 << 0) /* MOSCS Flag */
148#define AT91_PMC_LOCKA (1 << 1) /* PLLA Lock */ 117#define AT91_PMC_LOCKA (1 << 1) /* PLLA Lock */
149#define AT91_PMC_LOCKB (1 << 2) /* PLLB Lock */ 118#define AT91_PMC_LOCKB (1 << 2) /* PLLB Lock */
150#define AT91_PMC_MCKRDY (1 << 3) /* Master Clock */ 119#define AT91_PMC_MCKRDY (1 << 3) /* Master Clock */
151#define AT91_PMC_LOCKU (1 << 6) /* UPLL Lock [some SAM9] */ 120#define AT91_PMC_LOCKU (1 << 6) /* UPLL Lock [some SAM9, AT91CAP9 only] */
121#define AT91_PMC_OSCSEL (1 << 7) /* Slow Clock Oscillator [AT91CAP9 revC only] */
152#define AT91_PMC_PCK0RDY (1 << 8) /* Programmable Clock 0 */ 122#define AT91_PMC_PCK0RDY (1 << 8) /* Programmable Clock 0 */
153#define AT91_PMC_PCK1RDY (1 << 9) /* Programmable Clock 1 */ 123#define AT91_PMC_PCK1RDY (1 << 9) /* Programmable Clock 1 */
154#define AT91_PMC_PCK2RDY (1 << 10) /* Programmable Clock 2 */ 124#define AT91_PMC_PCK2RDY (1 << 10) /* Programmable Clock 2 */
155#define AT91_PMC_PCK3RDY (1 << 11) /* Programmable Clock 3 */ 125#define AT91_PMC_PCK3RDY (1 << 11) /* Programmable Clock 3 */
156#define AT91_PMC_MOSCSELS (1 << 16) /* Main Oscillator Selection [some SAM9] */ 126#define AT91_PMC_IMR (AT91_PMC + 0x6c) /* Interrupt Mask Register */
157#define AT91_PMC_MOSCRCS (1 << 17) /* Main On-Chip RC [some SAM9] */
158#define AT91_PMC_CFDEV (1 << 18) /* Clock Failure Detector Event [some SAM9] */
159#define AT91_PMC_IMR 0x6c /* Interrupt Mask Register */
160
161#define AT91_PMC_PROT 0xe4 /* Write Protect Mode Register [some SAM9] */
162#define AT91_PMC_WPEN (0x1 << 0) /* Write Protect Enable */
163#define AT91_PMC_WPKEY (0xffffff << 8) /* Write Protect Key */
164#define AT91_PMC_PROTKEY (0x504d43 << 8) /* Activation Code */
165 127
166#define AT91_PMC_WPSR 0xe8 /* Write Protect Status Register [some SAM9] */ 128#define AT91_PMC_PROT (AT91_PMC + 0xe4) /* Protect Register [AT91CAP9 revC only] */
167#define AT91_PMC_WPVS (0x1 << 0) /* Write Protect Violation Status */ 129#define AT91_PMC_PROTKEY 0x504d4301 /* Activation Code */
168#define AT91_PMC_WPVSRC (0xffff << 8) /* Write Protect Violation Source */
169 130
170#define AT91_PMC_PCR 0x10c /* Peripheral Control Register [some SAM9] */ 131#define AT91_PMC_VER (AT91_PMC + 0xfc) /* PMC Module Version [AT91CAP9 only] */
171#define AT91_PMC_PCR_PID (0x3f << 0) /* Peripheral ID */
172#define AT91_PMC_PCR_CMD (0x1 << 12) /* Command */
173#define AT91_PMC_PCR_DIV (0x3 << 16) /* Divisor Value */
174#define AT91_PMC_PCRDIV(n) (((n) << 16) & AT91_PMC_PCR_DIV)
175#define AT91_PMC_PCR_EN (0x1 << 28) /* Enable */
176 132
177#endif 133#endif
diff --git a/arch/arm/mach-at91/include/mach/at91_ramc.h b/arch/arm/mach-at91/include/mach/at91_ramc.h
deleted file mode 100644
index d8aeb278614..00000000000
--- a/arch/arm/mach-at91/include/mach/at91_ramc.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * Header file for the Atmel RAM Controller
3 *
4 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
5 *
6 * Under GPLv2 only
7 */
8
9#ifndef __AT91_RAMC_H__
10#define __AT91_RAMC_H__
11
12#ifndef __ASSEMBLY__
13extern void __iomem *at91_ramc_base[];
14
15#define at91_ramc_read(id, field) \
16 __raw_readl(at91_ramc_base[id] + field)
17
18#define at91_ramc_write(id, field, value) \
19 __raw_writel(value, at91_ramc_base[id] + field)
20#else
21.extern at91_ramc_base
22#endif
23
24#define AT91_MEMCTRL_MC 0
25#define AT91_MEMCTRL_SDRAMC 1
26#define AT91_MEMCTRL_DDRSDR 2
27
28#include <mach/at91rm9200_sdramc.h>
29#include <mach/at91sam9_ddrsdr.h>
30#include <mach/at91sam9_sdramc.h>
31
32#endif /* __AT91_RAMC_H__ */
diff --git a/arch/arm/mach-at91/include/mach/at91_st.h b/arch/arm/mach-at91/include/mach/at91_st.h
index 969aac27109..8847173e410 100644
--- a/arch/arm/mach-at91/include/mach/at91_st.h
+++ b/arch/arm/mach-at91/include/mach/at91_st.h
@@ -16,46 +16,34 @@
16#ifndef AT91_ST_H 16#ifndef AT91_ST_H
17#define AT91_ST_H 17#define AT91_ST_H
18 18
19#ifndef __ASSEMBLY__ 19#define AT91_ST_CR (AT91_ST + 0x00) /* Control Register */
20extern void __iomem *at91_st_base;
21
22#define at91_st_read(field) \
23 __raw_readl(at91_st_base + field)
24
25#define at91_st_write(field, value) \
26 __raw_writel(value, at91_st_base + field);
27#else
28.extern at91_st_base
29#endif
30
31#define AT91_ST_CR 0x00 /* Control Register */
32#define AT91_ST_WDRST (1 << 0) /* Watchdog Timer Restart */ 20#define AT91_ST_WDRST (1 << 0) /* Watchdog Timer Restart */
33 21
34#define AT91_ST_PIMR 0x04 /* Period Interval Mode Register */ 22#define AT91_ST_PIMR (AT91_ST + 0x04) /* Period Interval Mode Register */
35#define AT91_ST_PIV (0xffff << 0) /* Period Interval Value */ 23#define AT91_ST_PIV (0xffff << 0) /* Period Interval Value */
36 24
37#define AT91_ST_WDMR 0x08 /* Watchdog Mode Register */ 25#define AT91_ST_WDMR (AT91_ST + 0x08) /* Watchdog Mode Register */
38#define AT91_ST_WDV (0xffff << 0) /* Watchdog Counter Value */ 26#define AT91_ST_WDV (0xffff << 0) /* Watchdog Counter Value */
39#define AT91_ST_RSTEN (1 << 16) /* Reset Enable */ 27#define AT91_ST_RSTEN (1 << 16) /* Reset Enable */
40#define AT91_ST_EXTEN (1 << 17) /* External Signal Assertion Enable */ 28#define AT91_ST_EXTEN (1 << 17) /* External Signal Assertion Enable */
41 29
42#define AT91_ST_RTMR 0x0c /* Real-time Mode Register */ 30#define AT91_ST_RTMR (AT91_ST + 0x0c) /* Real-time Mode Register */
43#define AT91_ST_RTPRES (0xffff << 0) /* Real-time Prescalar Value */ 31#define AT91_ST_RTPRES (0xffff << 0) /* Real-time Prescalar Value */
44 32
45#define AT91_ST_SR 0x10 /* Status Register */ 33#define AT91_ST_SR (AT91_ST + 0x10) /* Status Register */
46#define AT91_ST_PITS (1 << 0) /* Period Interval Timer Status */ 34#define AT91_ST_PITS (1 << 0) /* Period Interval Timer Status */
47#define AT91_ST_WDOVF (1 << 1) /* Watchdog Overflow */ 35#define AT91_ST_WDOVF (1 << 1) /* Watchdog Overflow */
48#define AT91_ST_RTTINC (1 << 2) /* Real-time Timer Increment */ 36#define AT91_ST_RTTINC (1 << 2) /* Real-time Timer Increment */
49#define AT91_ST_ALMS (1 << 3) /* Alarm Status */ 37#define AT91_ST_ALMS (1 << 3) /* Alarm Status */
50 38
51#define AT91_ST_IER 0x14 /* Interrupt Enable Register */ 39#define AT91_ST_IER (AT91_ST + 0x14) /* Interrupt Enable Register */
52#define AT91_ST_IDR 0x18 /* Interrupt Disable Register */ 40#define AT91_ST_IDR (AT91_ST + 0x18) /* Interrupt Disable Register */
53#define AT91_ST_IMR 0x1c /* Interrupt Mask Register */ 41#define AT91_ST_IMR (AT91_ST + 0x1c) /* Interrupt Mask Register */
54 42
55#define AT91_ST_RTAR 0x20 /* Real-time Alarm Register */ 43#define AT91_ST_RTAR (AT91_ST + 0x20) /* Real-time Alarm Register */
56#define AT91_ST_ALMV (0xfffff << 0) /* Alarm Value */ 44#define AT91_ST_ALMV (0xfffff << 0) /* Alarm Value */
57 45
58#define AT91_ST_CRTR 0x24 /* Current Real-time Register */ 46#define AT91_ST_CRTR (AT91_ST + 0x24) /* Current Real-time Register */
59#define AT91_ST_CRTV (0xfffff << 0) /* Current Real-Time Value */ 47#define AT91_ST_CRTV (0xfffff << 0) /* Current Real-Time Value */
60 48
61#endif 49#endif
diff --git a/arch/arm/mach-at91/include/mach/at91rm9200.h b/arch/arm/mach-at91/include/mach/at91rm9200.h
index e67317c6776..e4037b50030 100644
--- a/arch/arm/mach-at91/include/mach/at91rm9200.h
+++ b/arch/arm/mach-at91/include/mach/at91rm9200.h
@@ -77,16 +77,25 @@
77 77
78 78
79/* 79/*
80 * System Peripherals 80 * System Peripherals (offset from AT91_BASE_SYS)
81 */ 81 */
82#define AT91RM9200_BASE_DBGU AT91_BASE_DBGU0 /* Debug Unit */ 82#define AT91_AIC (0xfffff000 - AT91_BASE_SYS) /* Advanced Interrupt Controller */
83#define AT91RM9200_BASE_PIOA 0xfffff400 /* PIO Controller A */ 83#define AT91_DBGU (0xfffff200 - AT91_BASE_SYS) /* Debug Unit */
84#define AT91RM9200_BASE_PIOB 0xfffff600 /* PIO Controller B */ 84#define AT91_PIOA (0xfffff400 - AT91_BASE_SYS) /* PIO Controller A */
85#define AT91RM9200_BASE_PIOC 0xfffff800 /* PIO Controller C */ 85#define AT91_PIOB (0xfffff600 - AT91_BASE_SYS) /* PIO Controller B */
86#define AT91RM9200_BASE_PIOD 0xfffffa00 /* PIO Controller D */ 86#define AT91_PIOC (0xfffff800 - AT91_BASE_SYS) /* PIO Controller C */
87#define AT91RM9200_BASE_ST 0xfffffd00 /* System Timer */ 87#define AT91_PIOD (0xfffffa00 - AT91_BASE_SYS) /* PIO Controller D */
88#define AT91RM9200_BASE_RTC 0xfffffe00 /* Real-Time Clock */ 88#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS) /* Power Management Controller */
89#define AT91RM9200_BASE_MC 0xffffff00 /* Memory Controllers */ 89#define AT91_ST (0xfffffd00 - AT91_BASE_SYS) /* System Timer */
90#define AT91_RTC (0xfffffe00 - AT91_BASE_SYS) /* Real-Time Clock */
91#define AT91_MC (0xffffff00 - AT91_BASE_SYS) /* Memory Controllers */
92
93#define AT91_USART0 AT91RM9200_BASE_US0
94#define AT91_USART1 AT91RM9200_BASE_US1
95#define AT91_USART2 AT91RM9200_BASE_US2
96#define AT91_USART3 AT91RM9200_BASE_US3
97
98#define AT91_MATRIX 0 /* not supported */
90 99
91/* 100/*
92 * Internal Memory. 101 * Internal Memory.
diff --git a/arch/arm/mach-at91/include/mach/at91rm9200_mc.h b/arch/arm/mach-at91/include/mach/at91rm9200_mc.h
index aeaadfb452a..d34e4ed8934 100644
--- a/arch/arm/mach-at91/include/mach/at91rm9200_mc.h
+++ b/arch/arm/mach-at91/include/mach/at91rm9200_mc.h
@@ -17,10 +17,10 @@
17#define AT91RM9200_MC_H 17#define AT91RM9200_MC_H
18 18
19/* Memory Controller */ 19/* Memory Controller */
20#define AT91_MC_RCR 0x00 /* MC Remap Control Register */ 20#define AT91_MC_RCR (AT91_MC + 0x00) /* MC Remap Control Register */
21#define AT91_MC_RCB (1 << 0) /* Remap Command Bit */ 21#define AT91_MC_RCB (1 << 0) /* Remap Command Bit */
22 22
23#define AT91_MC_ASR 0x04 /* MC Abort Status Register */ 23#define AT91_MC_ASR (AT91_MC + 0x04) /* MC Abort Status Register */
24#define AT91_MC_UNADD (1 << 0) /* Undefined Address Abort Status */ 24#define AT91_MC_UNADD (1 << 0) /* Undefined Address Abort Status */
25#define AT91_MC_MISADD (1 << 1) /* Misaligned Address Abort Status */ 25#define AT91_MC_MISADD (1 << 1) /* Misaligned Address Abort Status */
26#define AT91_MC_ABTSZ (3 << 8) /* Abort Size Status */ 26#define AT91_MC_ABTSZ (3 << 8) /* Abort Size Status */
@@ -40,16 +40,16 @@
40#define AT91_MC_SVMST2 (1 << 26) /* Saved UHP Abort Source */ 40#define AT91_MC_SVMST2 (1 << 26) /* Saved UHP Abort Source */
41#define AT91_MC_SVMST3 (1 << 27) /* Saved EMAC Abort Source */ 41#define AT91_MC_SVMST3 (1 << 27) /* Saved EMAC Abort Source */
42 42
43#define AT91_MC_AASR 0x08 /* MC Abort Address Status Register */ 43#define AT91_MC_AASR (AT91_MC + 0x08) /* MC Abort Address Status Register */
44 44
45#define AT91_MC_MPR 0x0c /* MC Master Priority Register */ 45#define AT91_MC_MPR (AT91_MC + 0x0c) /* MC Master Priority Register */
46#define AT91_MPR_MSTP0 (7 << 0) /* ARM920T Priority */ 46#define AT91_MPR_MSTP0 (7 << 0) /* ARM920T Priority */
47#define AT91_MPR_MSTP1 (7 << 4) /* PDC Priority */ 47#define AT91_MPR_MSTP1 (7 << 4) /* PDC Priority */
48#define AT91_MPR_MSTP2 (7 << 8) /* UHP Priority */ 48#define AT91_MPR_MSTP2 (7 << 8) /* UHP Priority */
49#define AT91_MPR_MSTP3 (7 << 12) /* EMAC Priority */ 49#define AT91_MPR_MSTP3 (7 << 12) /* EMAC Priority */
50 50
51/* External Bus Interface (EBI) registers */ 51/* External Bus Interface (EBI) registers */
52#define AT91_EBI_CSA 0x60 /* Chip Select Assignment Register */ 52#define AT91_EBI_CSA (AT91_MC + 0x60) /* Chip Select Assignment Register */
53#define AT91_EBI_CS0A (1 << 0) /* Chip Select 0 Assignment */ 53#define AT91_EBI_CS0A (1 << 0) /* Chip Select 0 Assignment */
54#define AT91_EBI_CS0A_SMC (0 << 0) 54#define AT91_EBI_CS0A_SMC (0 << 0)
55#define AT91_EBI_CS0A_BFC (1 << 0) 55#define AT91_EBI_CS0A_BFC (1 << 0)
@@ -66,7 +66,7 @@
66#define AT91_EBI_DBPUC (1 << 0) /* Data Bus Pull-Up Configuration */ 66#define AT91_EBI_DBPUC (1 << 0) /* Data Bus Pull-Up Configuration */
67 67
68/* Static Memory Controller (SMC) registers */ 68/* Static Memory Controller (SMC) registers */
69#define AT91_SMC_CSR(n) (0x70 + ((n) * 4)) /* SMC Chip Select Register */ 69#define AT91_SMC_CSR(n) (AT91_MC + 0x70 + ((n) * 4))/* SMC Chip Select Register */
70#define AT91_SMC_NWS (0x7f << 0) /* Number of Wait States */ 70#define AT91_SMC_NWS (0x7f << 0) /* Number of Wait States */
71#define AT91_SMC_NWS_(x) ((x) << 0) 71#define AT91_SMC_NWS_(x) ((x) << 0)
72#define AT91_SMC_WSEN (1 << 7) /* Wait State Enable */ 72#define AT91_SMC_WSEN (1 << 7) /* Wait State Enable */
@@ -87,8 +87,52 @@
87#define AT91_SMC_RWHOLD (7 << 28) /* Read & Write Signal Hold Time */ 87#define AT91_SMC_RWHOLD (7 << 28) /* Read & Write Signal Hold Time */
88#define AT91_SMC_RWHOLD_(x) ((x) << 28) 88#define AT91_SMC_RWHOLD_(x) ((x) << 28)
89 89
90/* SDRAM Controller registers */
91#define AT91_SDRAMC_MR (AT91_MC + 0x90) /* Mode Register */
92#define AT91_SDRAMC_MODE (0xf << 0) /* Command Mode */
93#define AT91_SDRAMC_MODE_NORMAL (0 << 0)
94#define AT91_SDRAMC_MODE_NOP (1 << 0)
95#define AT91_SDRAMC_MODE_PRECHARGE (2 << 0)
96#define AT91_SDRAMC_MODE_LMR (3 << 0)
97#define AT91_SDRAMC_MODE_REFRESH (4 << 0)
98#define AT91_SDRAMC_DBW (1 << 4) /* Data Bus Width */
99#define AT91_SDRAMC_DBW_32 (0 << 4)
100#define AT91_SDRAMC_DBW_16 (1 << 4)
101
102#define AT91_SDRAMC_TR (AT91_MC + 0x94) /* Refresh Timer Register */
103#define AT91_SDRAMC_COUNT (0xfff << 0) /* Refresh Timer Count */
104
105#define AT91_SDRAMC_CR (AT91_MC + 0x98) /* Configuration Register */
106#define AT91_SDRAMC_NC (3 << 0) /* Number of Column Bits */
107#define AT91_SDRAMC_NC_8 (0 << 0)
108#define AT91_SDRAMC_NC_9 (1 << 0)
109#define AT91_SDRAMC_NC_10 (2 << 0)
110#define AT91_SDRAMC_NC_11 (3 << 0)
111#define AT91_SDRAMC_NR (3 << 2) /* Number of Row Bits */
112#define AT91_SDRAMC_NR_11 (0 << 2)
113#define AT91_SDRAMC_NR_12 (1 << 2)
114#define AT91_SDRAMC_NR_13 (2 << 2)
115#define AT91_SDRAMC_NB (1 << 4) /* Number of Banks */
116#define AT91_SDRAMC_NB_2 (0 << 4)
117#define AT91_SDRAMC_NB_4 (1 << 4)
118#define AT91_SDRAMC_CAS (3 << 5) /* CAS Latency */
119#define AT91_SDRAMC_CAS_2 (2 << 5)
120#define AT91_SDRAMC_TWR (0xf << 7) /* Write Recovery Delay */
121#define AT91_SDRAMC_TRC (0xf << 11) /* Row Cycle Delay */
122#define AT91_SDRAMC_TRP (0xf << 15) /* Row Precharge Delay */
123#define AT91_SDRAMC_TRCD (0xf << 19) /* Row to Column Delay */
124#define AT91_SDRAMC_TRAS (0xf << 23) /* Active to Precharge Delay */
125#define AT91_SDRAMC_TXSR (0xf << 27) /* Exit Self Refresh to Active Delay */
126
127#define AT91_SDRAMC_SRR (AT91_MC + 0x9c) /* Self Refresh Register */
128#define AT91_SDRAMC_LPR (AT91_MC + 0xa0) /* Low Power Register */
129#define AT91_SDRAMC_IER (AT91_MC + 0xa4) /* Interrupt Enable Register */
130#define AT91_SDRAMC_IDR (AT91_MC + 0xa8) /* Interrupt Disable Register */
131#define AT91_SDRAMC_IMR (AT91_MC + 0xac) /* Interrupt Mask Register */
132#define AT91_SDRAMC_ISR (AT91_MC + 0xb0) /* Interrupt Status Register */
133
90/* Burst Flash Controller register */ 134/* Burst Flash Controller register */
91#define AT91_BFC_MR 0xc0 /* Mode Register */ 135#define AT91_BFC_MR (AT91_MC + 0xc0) /* Mode Register */
92#define AT91_BFC_BFCOM (3 << 0) /* Burst Flash Controller Operating Mode */ 136#define AT91_BFC_BFCOM (3 << 0) /* Burst Flash Controller Operating Mode */
93#define AT91_BFC_BFCOM_DISABLED (0 << 0) 137#define AT91_BFC_BFCOM_DISABLED (0 << 0)
94#define AT91_BFC_BFCOM_ASYNC (1 << 0) 138#define AT91_BFC_BFCOM_ASYNC (1 << 0)
diff --git a/arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h b/arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
deleted file mode 100644
index aa047f458f1..00000000000
--- a/arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
3 *
4 * Copyright (C) 2005 Ivan Kokshaysky
5 * Copyright (C) SAN People
6 *
7 * Memory Controllers (SDRAMC only) - System peripherals registers.
8 * Based on AT91RM9200 datasheet revision E.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 */
15
16#ifndef AT91RM9200_SDRAMC_H
17#define AT91RM9200_SDRAMC_H
18
19/* SDRAM Controller registers */
20#define AT91RM9200_SDRAMC_MR 0x90 /* Mode Register */
21#define AT91RM9200_SDRAMC_MODE (0xf << 0) /* Command Mode */
22#define AT91RM9200_SDRAMC_MODE_NORMAL (0 << 0)
23#define AT91RM9200_SDRAMC_MODE_NOP (1 << 0)
24#define AT91RM9200_SDRAMC_MODE_PRECHARGE (2 << 0)
25#define AT91RM9200_SDRAMC_MODE_LMR (3 << 0)
26#define AT91RM9200_SDRAMC_MODE_REFRESH (4 << 0)
27#define AT91RM9200_SDRAMC_DBW (1 << 4) /* Data Bus Width */
28#define AT91RM9200_SDRAMC_DBW_32 (0 << 4)
29#define AT91RM9200_SDRAMC_DBW_16 (1 << 4)
30
31#define AT91RM9200_SDRAMC_TR 0x94 /* Refresh Timer Register */
32#define AT91RM9200_SDRAMC_COUNT (0xfff << 0) /* Refresh Timer Count */
33
34#define AT91RM9200_SDRAMC_CR 0x98 /* Configuration Register */
35#define AT91RM9200_SDRAMC_NC (3 << 0) /* Number of Column Bits */
36#define AT91RM9200_SDRAMC_NC_8 (0 << 0)
37#define AT91RM9200_SDRAMC_NC_9 (1 << 0)
38#define AT91RM9200_SDRAMC_NC_10 (2 << 0)
39#define AT91RM9200_SDRAMC_NC_11 (3 << 0)
40#define AT91RM9200_SDRAMC_NR (3 << 2) /* Number of Row Bits */
41#define AT91RM9200_SDRAMC_NR_11 (0 << 2)
42#define AT91RM9200_SDRAMC_NR_12 (1 << 2)
43#define AT91RM9200_SDRAMC_NR_13 (2 << 2)
44#define AT91RM9200_SDRAMC_NB (1 << 4) /* Number of Banks */
45#define AT91RM9200_SDRAMC_NB_2 (0 << 4)
46#define AT91RM9200_SDRAMC_NB_4 (1 << 4)
47#define AT91RM9200_SDRAMC_CAS (3 << 5) /* CAS Latency */
48#define AT91RM9200_SDRAMC_CAS_2 (2 << 5)
49#define AT91RM9200_SDRAMC_TWR (0xf << 7) /* Write Recovery Delay */
50#define AT91RM9200_SDRAMC_TRC (0xf << 11) /* Row Cycle Delay */
51#define AT91RM9200_SDRAMC_TRP (0xf << 15) /* Row Precharge Delay */
52#define AT91RM9200_SDRAMC_TRCD (0xf << 19) /* Row to Column Delay */
53#define AT91RM9200_SDRAMC_TRAS (0xf << 23) /* Active to Precharge Delay */
54#define AT91RM9200_SDRAMC_TXSR (0xf << 27) /* Exit Self Refresh to Active Delay */
55
56#define AT91RM9200_SDRAMC_SRR 0x9c /* Self Refresh Register */
57#define AT91RM9200_SDRAMC_LPR 0xa0 /* Low Power Register */
58#define AT91RM9200_SDRAMC_IER 0xa4 /* Interrupt Enable Register */
59#define AT91RM9200_SDRAMC_IDR 0xa8 /* Interrupt Disable Register */
60#define AT91RM9200_SDRAMC_IMR 0xac /* Interrupt Mask Register */
61#define AT91RM9200_SDRAMC_ISR 0xb0 /* Interrupt Status Register */
62
63#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9260.h b/arch/arm/mach-at91/include/mach/at91sam9260.h
index 416c7b6c56d..9a791165913 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9260.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9260.h
@@ -78,22 +78,32 @@
78#define AT91SAM9260_BASE_ADC 0xfffe0000 78#define AT91SAM9260_BASE_ADC 0xfffe0000
79 79
80/* 80/*
81 * System Peripherals 81 * System Peripherals (offset from AT91_BASE_SYS)
82 */ 82 */
83#define AT91SAM9260_BASE_ECC 0xffffe800 83#define AT91_ECC (0xffffe800 - AT91_BASE_SYS)
84#define AT91SAM9260_BASE_SDRAMC 0xffffea00 84#define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS)
85#define AT91SAM9260_BASE_SMC 0xffffec00 85#define AT91_SMC (0xffffec00 - AT91_BASE_SYS)
86#define AT91SAM9260_BASE_MATRIX 0xffffee00 86#define AT91_MATRIX (0xffffee00 - AT91_BASE_SYS)
87#define AT91SAM9260_BASE_DBGU AT91_BASE_DBGU0 87#define AT91_CCFG (0xffffef10 - AT91_BASE_SYS)
88#define AT91SAM9260_BASE_PIOA 0xfffff400 88#define AT91_AIC (0xfffff000 - AT91_BASE_SYS)
89#define AT91SAM9260_BASE_PIOB 0xfffff600 89#define AT91_DBGU (0xfffff200 - AT91_BASE_SYS)
90#define AT91SAM9260_BASE_PIOC 0xfffff800 90#define AT91_PIOA (0xfffff400 - AT91_BASE_SYS)
91#define AT91SAM9260_BASE_RSTC 0xfffffd00 91#define AT91_PIOB (0xfffff600 - AT91_BASE_SYS)
92#define AT91SAM9260_BASE_SHDWC 0xfffffd10 92#define AT91_PIOC (0xfffff800 - AT91_BASE_SYS)
93#define AT91SAM9260_BASE_RTT 0xfffffd20 93#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
94#define AT91SAM9260_BASE_PIT 0xfffffd30 94#define AT91_RSTC (0xfffffd00 - AT91_BASE_SYS)
95#define AT91SAM9260_BASE_WDT 0xfffffd40 95#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)
96#define AT91SAM9260_BASE_GPBR 0xfffffd50 96#define AT91_RTT (0xfffffd20 - AT91_BASE_SYS)
97#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS)
98#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS)
99#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)
100
101#define AT91_USART0 AT91SAM9260_BASE_US0
102#define AT91_USART1 AT91SAM9260_BASE_US1
103#define AT91_USART2 AT91SAM9260_BASE_US2
104#define AT91_USART3 AT91SAM9260_BASE_US3
105#define AT91_USART4 AT91SAM9260_BASE_US4
106#define AT91_USART5 AT91SAM9260_BASE_US5
97 107
98 108
99/* 109/*
@@ -106,8 +116,6 @@
106#define AT91SAM9260_SRAM0_SIZE SZ_4K /* Internal SRAM 0 size (4Kb) */ 116#define AT91SAM9260_SRAM0_SIZE SZ_4K /* Internal SRAM 0 size (4Kb) */
107#define AT91SAM9260_SRAM1_BASE 0x00300000 /* Internal SRAM 1 base address */ 117#define AT91SAM9260_SRAM1_BASE 0x00300000 /* Internal SRAM 1 base address */
108#define AT91SAM9260_SRAM1_SIZE SZ_4K /* Internal SRAM 1 size (4Kb) */ 118#define AT91SAM9260_SRAM1_SIZE SZ_4K /* Internal SRAM 1 size (4Kb) */
109#define AT91SAM9260_SRAM_BASE 0x002FF000 /* Internal SRAM base address */
110#define AT91SAM9260_SRAM_SIZE SZ_8K /* Internal SRAM size (8Kb) */
111 119
112#define AT91SAM9260_UHP_BASE 0x00500000 /* USB Host controller */ 120#define AT91SAM9260_UHP_BASE 0x00500000 /* USB Host controller */
113 121
@@ -121,8 +129,6 @@
121#define AT91SAM9G20_SRAM0_SIZE SZ_16K /* Internal SRAM 0 size (16Kb) */ 129#define AT91SAM9G20_SRAM0_SIZE SZ_16K /* Internal SRAM 0 size (16Kb) */
122#define AT91SAM9G20_SRAM1_BASE 0x00300000 /* Internal SRAM 1 base address */ 130#define AT91SAM9G20_SRAM1_BASE 0x00300000 /* Internal SRAM 1 base address */
123#define AT91SAM9G20_SRAM1_SIZE SZ_16K /* Internal SRAM 1 size (16Kb) */ 131#define AT91SAM9G20_SRAM1_SIZE SZ_16K /* Internal SRAM 1 size (16Kb) */
124#define AT91SAM9G20_SRAM_BASE 0x002FC000 /* Internal SRAM base address */
125#define AT91SAM9G20_SRAM_SIZE SZ_32K /* Internal SRAM size (32Kb) */
126 132
127#define AT91SAM9G20_UHP_BASE 0x00500000 /* USB Host controller */ 133#define AT91SAM9G20_UHP_BASE 0x00500000 /* USB Host controller */
128 134
diff --git a/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h
index f459df42062..020f02ed921 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h
@@ -15,12 +15,12 @@
15#ifndef AT91SAM9260_MATRIX_H 15#ifndef AT91SAM9260_MATRIX_H
16#define AT91SAM9260_MATRIX_H 16#define AT91SAM9260_MATRIX_H
17 17
18#define AT91_MATRIX_MCFG0 0x00 /* Master Configuration Register 0 */ 18#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00) /* Master Configuration Register 0 */
19#define AT91_MATRIX_MCFG1 0x04 /* Master Configuration Register 1 */ 19#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04) /* Master Configuration Register 1 */
20#define AT91_MATRIX_MCFG2 0x08 /* Master Configuration Register 2 */ 20#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08) /* Master Configuration Register 2 */
21#define AT91_MATRIX_MCFG3 0x0C /* Master Configuration Register 3 */ 21#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C) /* Master Configuration Register 3 */
22#define AT91_MATRIX_MCFG4 0x10 /* Master Configuration Register 4 */ 22#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10) /* Master Configuration Register 4 */
23#define AT91_MATRIX_MCFG5 0x14 /* Master Configuration Register 5 */ 23#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14) /* Master Configuration Register 5 */
24#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */ 24#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */
25#define AT91_MATRIX_ULBT_INFINITE (0 << 0) 25#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
26#define AT91_MATRIX_ULBT_SINGLE (1 << 0) 26#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
@@ -28,11 +28,11 @@
28#define AT91_MATRIX_ULBT_EIGHT (3 << 0) 28#define AT91_MATRIX_ULBT_EIGHT (3 << 0)
29#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0) 29#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0)
30 30
31#define AT91_MATRIX_SCFG0 0x40 /* Slave Configuration Register 0 */ 31#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40) /* Slave Configuration Register 0 */
32#define AT91_MATRIX_SCFG1 0x44 /* Slave Configuration Register 1 */ 32#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44) /* Slave Configuration Register 1 */
33#define AT91_MATRIX_SCFG2 0x48 /* Slave Configuration Register 2 */ 33#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48) /* Slave Configuration Register 2 */
34#define AT91_MATRIX_SCFG3 0x4C /* Slave Configuration Register 3 */ 34#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C) /* Slave Configuration Register 3 */
35#define AT91_MATRIX_SCFG4 0x50 /* Slave Configuration Register 4 */ 35#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50) /* Slave Configuration Register 4 */
36#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */ 36#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */
37#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */ 37#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
38#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 38#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -43,11 +43,11 @@
43#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24) 43#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
44#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24) 44#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
45 45
46#define AT91_MATRIX_PRAS0 0x80 /* Priority Register A for Slave 0 */ 46#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80) /* Priority Register A for Slave 0 */
47#define AT91_MATRIX_PRAS1 0x88 /* Priority Register A for Slave 1 */ 47#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88) /* Priority Register A for Slave 1 */
48#define AT91_MATRIX_PRAS2 0x90 /* Priority Register A for Slave 2 */ 48#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90) /* Priority Register A for Slave 2 */
49#define AT91_MATRIX_PRAS3 0x98 /* Priority Register A for Slave 3 */ 49#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98) /* Priority Register A for Slave 3 */
50#define AT91_MATRIX_PRAS4 0xA0 /* Priority Register A for Slave 4 */ 50#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0) /* Priority Register A for Slave 4 */
51#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */ 51#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */
52#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */ 52#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */
53#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */ 53#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */
@@ -55,11 +55,11 @@
55#define AT91_MATRIX_M4PR (3 << 16) /* Master 4 Priority */ 55#define AT91_MATRIX_M4PR (3 << 16) /* Master 4 Priority */
56#define AT91_MATRIX_M5PR (3 << 20) /* Master 5 Priority */ 56#define AT91_MATRIX_M5PR (3 << 20) /* Master 5 Priority */
57 57
58#define AT91_MATRIX_MRCR 0x100 /* Master Remap Control Register */ 58#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100) /* Master Remap Control Register */
59#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ 59#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
60#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ 60#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
61 61
62#define AT91_MATRIX_EBICSA 0x11C /* EBI Chip Select Assignment Register */ 62#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x11C) /* EBI Chip Select Assignment Register */
63#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */ 63#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */
64#define AT91_MATRIX_CS1A_SMC (0 << 1) 64#define AT91_MATRIX_CS1A_SMC (0 << 1)
65#define AT91_MATRIX_CS1A_SDRAMC (1 << 1) 65#define AT91_MATRIX_CS1A_SDRAMC (1 << 1)
diff --git a/arch/arm/mach-at91/include/mach/at91sam9261.h b/arch/arm/mach-at91/include/mach/at91sam9261.h
index a041406d06e..ce596204cef 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9261.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9261.h
@@ -63,21 +63,27 @@
63 63
64 64
65/* 65/*
66 * System Peripherals 66 * System Peripherals (offset from AT91_BASE_SYS)
67 */ 67 */
68#define AT91SAM9261_BASE_SMC 0xffffec00 68#define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS)
69#define AT91SAM9261_BASE_MATRIX 0xffffee00 69#define AT91_SMC (0xffffec00 - AT91_BASE_SYS)
70#define AT91SAM9261_BASE_SDRAMC 0xffffea00 70#define AT91_MATRIX (0xffffee00 - AT91_BASE_SYS)
71#define AT91SAM9261_BASE_DBGU AT91_BASE_DBGU0 71#define AT91_AIC (0xfffff000 - AT91_BASE_SYS)
72#define AT91SAM9261_BASE_PIOA 0xfffff400 72#define AT91_DBGU (0xfffff200 - AT91_BASE_SYS)
73#define AT91SAM9261_BASE_PIOB 0xfffff600 73#define AT91_PIOA (0xfffff400 - AT91_BASE_SYS)
74#define AT91SAM9261_BASE_PIOC 0xfffff800 74#define AT91_PIOB (0xfffff600 - AT91_BASE_SYS)
75#define AT91SAM9261_BASE_RSTC 0xfffffd00 75#define AT91_PIOC (0xfffff800 - AT91_BASE_SYS)
76#define AT91SAM9261_BASE_SHDWC 0xfffffd10 76#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
77#define AT91SAM9261_BASE_RTT 0xfffffd20 77#define AT91_RSTC (0xfffffd00 - AT91_BASE_SYS)
78#define AT91SAM9261_BASE_PIT 0xfffffd30 78#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)
79#define AT91SAM9261_BASE_WDT 0xfffffd40 79#define AT91_RTT (0xfffffd20 - AT91_BASE_SYS)
80#define AT91SAM9261_BASE_GPBR 0xfffffd50 80#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS)
81#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS)
82#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)
83
84#define AT91_USART0 AT91SAM9261_BASE_US0
85#define AT91_USART1 AT91SAM9261_BASE_US1
86#define AT91_USART2 AT91SAM9261_BASE_US2
81 87
82 88
83/* 89/*
diff --git a/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h
index a50cdf8b8ca..69c6501915d 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h
@@ -15,15 +15,15 @@
15#ifndef AT91SAM9261_MATRIX_H 15#ifndef AT91SAM9261_MATRIX_H
16#define AT91SAM9261_MATRIX_H 16#define AT91SAM9261_MATRIX_H
17 17
18#define AT91_MATRIX_MCFG 0x00 /* Master Configuration Register */ 18#define AT91_MATRIX_MCFG (AT91_MATRIX + 0x00) /* Master Configuration Register */
19#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ 19#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
20#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ 20#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
21 21
22#define AT91_MATRIX_SCFG0 0x04 /* Slave Configuration Register 0 */ 22#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x04) /* Slave Configuration Register 0 */
23#define AT91_MATRIX_SCFG1 0x08 /* Slave Configuration Register 1 */ 23#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x08) /* Slave Configuration Register 1 */
24#define AT91_MATRIX_SCFG2 0x0C /* Slave Configuration Register 2 */ 24#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x0C) /* Slave Configuration Register 2 */
25#define AT91_MATRIX_SCFG3 0x10 /* Slave Configuration Register 3 */ 25#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x10) /* Slave Configuration Register 3 */
26#define AT91_MATRIX_SCFG4 0x14 /* Slave Configuration Register 4 */ 26#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x14) /* Slave Configuration Register 4 */
27#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */ 27#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */
28#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */ 28#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
29#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 29#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -31,7 +31,7 @@
31#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16) 31#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16)
32#define AT91_MATRIX_FIXED_DEFMSTR (7 << 18) /* Fixed Index of Default Master */ 32#define AT91_MATRIX_FIXED_DEFMSTR (7 << 18) /* Fixed Index of Default Master */
33 33
34#define AT91_MATRIX_TCR 0x24 /* TCM Configuration Register */ 34#define AT91_MATRIX_TCR (AT91_MATRIX + 0x24) /* TCM Configuration Register */
35#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */ 35#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */
36#define AT91_MATRIX_ITCM_0 (0 << 0) 36#define AT91_MATRIX_ITCM_0 (0 << 0)
37#define AT91_MATRIX_ITCM_16 (5 << 0) 37#define AT91_MATRIX_ITCM_16 (5 << 0)
@@ -43,7 +43,7 @@
43#define AT91_MATRIX_DTCM_32 (6 << 4) 43#define AT91_MATRIX_DTCM_32 (6 << 4)
44#define AT91_MATRIX_DTCM_64 (7 << 4) 44#define AT91_MATRIX_DTCM_64 (7 << 4)
45 45
46#define AT91_MATRIX_EBICSA 0x30 /* EBI Chip Select Assignment Register */ 46#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x30) /* EBI Chip Select Assignment Register */
47#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */ 47#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */
48#define AT91_MATRIX_CS1A_SMC (0 << 1) 48#define AT91_MATRIX_CS1A_SMC (0 << 1)
49#define AT91_MATRIX_CS1A_SDRAMC (1 << 1) 49#define AT91_MATRIX_CS1A_SDRAMC (1 << 1)
@@ -58,7 +58,7 @@
58#define AT91_MATRIX_CS5A_SMC_CF2 (1 << 5) 58#define AT91_MATRIX_CS5A_SMC_CF2 (1 << 5)
59#define AT91_MATRIX_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */ 59#define AT91_MATRIX_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */
60 60
61#define AT91_MATRIX_USBPUCR 0x34 /* USB Pad Pull-Up Control Register */ 61#define AT91_MATRIX_USBPUCR (AT91_MATRIX + 0x34) /* USB Pad Pull-Up Control Register */
62#define AT91_MATRIX_USBPUCR_PUON (1 << 30) /* USB Device PAD Pull-up Enable */ 62#define AT91_MATRIX_USBPUCR_PUON (1 << 30) /* USB Device PAD Pull-up Enable */
63 63
64#endif 64#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9263.h b/arch/arm/mach-at91/include/mach/at91sam9263.h
index d201029d60b..f1b92961a2b 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9263.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9263.h
@@ -72,28 +72,35 @@
72#define AT91SAM9263_BASE_2DGE 0xfffc8000 72#define AT91SAM9263_BASE_2DGE 0xfffc8000
73 73
74/* 74/*
75 * System Peripherals 75 * System Peripherals (offset from AT91_BASE_SYS)
76 */ 76 */
77#define AT91SAM9263_BASE_ECC0 0xffffe000 77#define AT91_ECC0 (0xffffe000 - AT91_BASE_SYS)
78#define AT91SAM9263_BASE_SDRAMC0 0xffffe200 78#define AT91_SDRAMC0 (0xffffe200 - AT91_BASE_SYS)
79#define AT91SAM9263_BASE_SMC0 0xffffe400 79#define AT91_SMC0 (0xffffe400 - AT91_BASE_SYS)
80#define AT91SAM9263_BASE_ECC1 0xffffe600 80#define AT91_ECC1 (0xffffe600 - AT91_BASE_SYS)
81#define AT91SAM9263_BASE_SDRAMC1 0xffffe800 81#define AT91_SDRAMC1 (0xffffe800 - AT91_BASE_SYS)
82#define AT91SAM9263_BASE_SMC1 0xffffea00 82#define AT91_SMC1 (0xffffea00 - AT91_BASE_SYS)
83#define AT91SAM9263_BASE_MATRIX 0xffffec00 83#define AT91_MATRIX (0xffffec00 - AT91_BASE_SYS)
84#define AT91SAM9263_BASE_DBGU AT91_BASE_DBGU1 84#define AT91_CCFG (0xffffed10 - AT91_BASE_SYS)
85#define AT91SAM9263_BASE_PIOA 0xfffff200 85#define AT91_DBGU (0xffffee00 - AT91_BASE_SYS)
86#define AT91SAM9263_BASE_PIOB 0xfffff400 86#define AT91_AIC (0xfffff000 - AT91_BASE_SYS)
87#define AT91SAM9263_BASE_PIOC 0xfffff600 87#define AT91_PIOA (0xfffff200 - AT91_BASE_SYS)
88#define AT91SAM9263_BASE_PIOD 0xfffff800 88#define AT91_PIOB (0xfffff400 - AT91_BASE_SYS)
89#define AT91SAM9263_BASE_PIOE 0xfffffa00 89#define AT91_PIOC (0xfffff600 - AT91_BASE_SYS)
90#define AT91SAM9263_BASE_RSTC 0xfffffd00 90#define AT91_PIOD (0xfffff800 - AT91_BASE_SYS)
91#define AT91SAM9263_BASE_SHDWC 0xfffffd10 91#define AT91_PIOE (0xfffffa00 - AT91_BASE_SYS)
92#define AT91SAM9263_BASE_RTT0 0xfffffd20 92#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
93#define AT91SAM9263_BASE_PIT 0xfffffd30 93#define AT91_RSTC (0xfffffd00 - AT91_BASE_SYS)
94#define AT91SAM9263_BASE_WDT 0xfffffd40 94#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)
95#define AT91SAM9263_BASE_RTT1 0xfffffd50 95#define AT91_RTT0 (0xfffffd20 - AT91_BASE_SYS)
96#define AT91SAM9263_BASE_GPBR 0xfffffd60 96#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS)
97#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS)
98#define AT91_RTT1 (0xfffffd50 - AT91_BASE_SYS)
99#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)
100
101#define AT91_USART0 AT91SAM9263_BASE_US0
102#define AT91_USART1 AT91SAM9263_BASE_US1
103#define AT91_USART2 AT91SAM9263_BASE_US2
97 104
98#define AT91_SMC AT91_SMC0 105#define AT91_SMC AT91_SMC0
99 106
diff --git a/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h
index ebb5fdb565e..9b3efd3eb2f 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h
@@ -15,15 +15,15 @@
15#ifndef AT91SAM9263_MATRIX_H 15#ifndef AT91SAM9263_MATRIX_H
16#define AT91SAM9263_MATRIX_H 16#define AT91SAM9263_MATRIX_H
17 17
18#define AT91_MATRIX_MCFG0 0x00 /* Master Configuration Register 0 */ 18#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00) /* Master Configuration Register 0 */
19#define AT91_MATRIX_MCFG1 0x04 /* Master Configuration Register 1 */ 19#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04) /* Master Configuration Register 1 */
20#define AT91_MATRIX_MCFG2 0x08 /* Master Configuration Register 2 */ 20#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08) /* Master Configuration Register 2 */
21#define AT91_MATRIX_MCFG3 0x0C /* Master Configuration Register 3 */ 21#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C) /* Master Configuration Register 3 */
22#define AT91_MATRIX_MCFG4 0x10 /* Master Configuration Register 4 */ 22#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10) /* Master Configuration Register 4 */
23#define AT91_MATRIX_MCFG5 0x14 /* Master Configuration Register 5 */ 23#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14) /* Master Configuration Register 5 */
24#define AT91_MATRIX_MCFG6 0x18 /* Master Configuration Register 6 */ 24#define AT91_MATRIX_MCFG6 (AT91_MATRIX + 0x18) /* Master Configuration Register 6 */
25#define AT91_MATRIX_MCFG7 0x1C /* Master Configuration Register 7 */ 25#define AT91_MATRIX_MCFG7 (AT91_MATRIX + 0x1C) /* Master Configuration Register 7 */
26#define AT91_MATRIX_MCFG8 0x20 /* Master Configuration Register 8 */ 26#define AT91_MATRIX_MCFG8 (AT91_MATRIX + 0x20) /* Master Configuration Register 8 */
27#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */ 27#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */
28#define AT91_MATRIX_ULBT_INFINITE (0 << 0) 28#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
29#define AT91_MATRIX_ULBT_SINGLE (1 << 0) 29#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
@@ -31,14 +31,14 @@
31#define AT91_MATRIX_ULBT_EIGHT (3 << 0) 31#define AT91_MATRIX_ULBT_EIGHT (3 << 0)
32#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0) 32#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0)
33 33
34#define AT91_MATRIX_SCFG0 0x40 /* Slave Configuration Register 0 */ 34#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40) /* Slave Configuration Register 0 */
35#define AT91_MATRIX_SCFG1 0x44 /* Slave Configuration Register 1 */ 35#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44) /* Slave Configuration Register 1 */
36#define AT91_MATRIX_SCFG2 0x48 /* Slave Configuration Register 2 */ 36#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48) /* Slave Configuration Register 2 */
37#define AT91_MATRIX_SCFG3 0x4C /* Slave Configuration Register 3 */ 37#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C) /* Slave Configuration Register 3 */
38#define AT91_MATRIX_SCFG4 0x50 /* Slave Configuration Register 4 */ 38#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50) /* Slave Configuration Register 4 */
39#define AT91_MATRIX_SCFG5 0x54 /* Slave Configuration Register 5 */ 39#define AT91_MATRIX_SCFG5 (AT91_MATRIX + 0x54) /* Slave Configuration Register 5 */
40#define AT91_MATRIX_SCFG6 0x58 /* Slave Configuration Register 6 */ 40#define AT91_MATRIX_SCFG6 (AT91_MATRIX + 0x58) /* Slave Configuration Register 6 */
41#define AT91_MATRIX_SCFG7 0x5C /* Slave Configuration Register 7 */ 41#define AT91_MATRIX_SCFG7 (AT91_MATRIX + 0x5C) /* Slave Configuration Register 7 */
42#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */ 42#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */
43#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */ 43#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
44#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 44#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -49,22 +49,22 @@
49#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24) 49#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
50#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24) 50#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
51 51
52#define AT91_MATRIX_PRAS0 0x80 /* Priority Register A for Slave 0 */ 52#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80) /* Priority Register A for Slave 0 */
53#define AT91_MATRIX_PRBS0 0x84 /* Priority Register B for Slave 0 */ 53#define AT91_MATRIX_PRBS0 (AT91_MATRIX + 0x84) /* Priority Register B for Slave 0 */
54#define AT91_MATRIX_PRAS1 0x88 /* Priority Register A for Slave 1 */ 54#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88) /* Priority Register A for Slave 1 */
55#define AT91_MATRIX_PRBS1 0x8C /* Priority Register B for Slave 1 */ 55#define AT91_MATRIX_PRBS1 (AT91_MATRIX + 0x8C) /* Priority Register B for Slave 1 */
56#define AT91_MATRIX_PRAS2 0x90 /* Priority Register A for Slave 2 */ 56#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90) /* Priority Register A for Slave 2 */
57#define AT91_MATRIX_PRBS2 0x94 /* Priority Register B for Slave 2 */ 57#define AT91_MATRIX_PRBS2 (AT91_MATRIX + 0x94) /* Priority Register B for Slave 2 */
58#define AT91_MATRIX_PRAS3 0x98 /* Priority Register A for Slave 3 */ 58#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98) /* Priority Register A for Slave 3 */
59#define AT91_MATRIX_PRBS3 0x9C /* Priority Register B for Slave 3 */ 59#define AT91_MATRIX_PRBS3 (AT91_MATRIX + 0x9C) /* Priority Register B for Slave 3 */
60#define AT91_MATRIX_PRAS4 0xA0 /* Priority Register A for Slave 4 */ 60#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0) /* Priority Register A for Slave 4 */
61#define AT91_MATRIX_PRBS4 0xA4 /* Priority Register B for Slave 4 */ 61#define AT91_MATRIX_PRBS4 (AT91_MATRIX + 0xA4) /* Priority Register B for Slave 4 */
62#define AT91_MATRIX_PRAS5 0xA8 /* Priority Register A for Slave 5 */ 62#define AT91_MATRIX_PRAS5 (AT91_MATRIX + 0xA8) /* Priority Register A for Slave 5 */
63#define AT91_MATRIX_PRBS5 0xAC /* Priority Register B for Slave 5 */ 63#define AT91_MATRIX_PRBS5 (AT91_MATRIX + 0xAC) /* Priority Register B for Slave 5 */
64#define AT91_MATRIX_PRAS6 0xB0 /* Priority Register A for Slave 6 */ 64#define AT91_MATRIX_PRAS6 (AT91_MATRIX + 0xB0) /* Priority Register A for Slave 6 */
65#define AT91_MATRIX_PRBS6 0xB4 /* Priority Register B for Slave 6 */ 65#define AT91_MATRIX_PRBS6 (AT91_MATRIX + 0xB4) /* Priority Register B for Slave 6 */
66#define AT91_MATRIX_PRAS7 0xB8 /* Priority Register A for Slave 7 */ 66#define AT91_MATRIX_PRAS7 (AT91_MATRIX + 0xB8) /* Priority Register A for Slave 7 */
67#define AT91_MATRIX_PRBS7 0xBC /* Priority Register B for Slave 7 */ 67#define AT91_MATRIX_PRBS7 (AT91_MATRIX + 0xBC) /* Priority Register B for Slave 7 */
68#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */ 68#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */
69#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */ 69#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */
70#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */ 70#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */
@@ -75,7 +75,7 @@
75#define AT91_MATRIX_M7PR (3 << 28) /* Master 7 Priority */ 75#define AT91_MATRIX_M7PR (3 << 28) /* Master 7 Priority */
76#define AT91_MATRIX_M8PR (3 << 0) /* Master 8 Priority (in Register B) */ 76#define AT91_MATRIX_M8PR (3 << 0) /* Master 8 Priority (in Register B) */
77 77
78#define AT91_MATRIX_MRCR 0x100 /* Master Remap Control Register */ 78#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100) /* Master Remap Control Register */
79#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ 79#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
80#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ 80#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
81#define AT91_MATRIX_RCB2 (1 << 2) 81#define AT91_MATRIX_RCB2 (1 << 2)
@@ -86,7 +86,7 @@
86#define AT91_MATRIX_RCB7 (1 << 7) 86#define AT91_MATRIX_RCB7 (1 << 7)
87#define AT91_MATRIX_RCB8 (1 << 8) 87#define AT91_MATRIX_RCB8 (1 << 8)
88 88
89#define AT91_MATRIX_TCMR 0x114 /* TCM Configuration Register */ 89#define AT91_MATRIX_TCMR (AT91_MATRIX + 0x114) /* TCM Configuration Register */
90#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */ 90#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */
91#define AT91_MATRIX_ITCM_0 (0 << 0) 91#define AT91_MATRIX_ITCM_0 (0 << 0)
92#define AT91_MATRIX_ITCM_16 (5 << 0) 92#define AT91_MATRIX_ITCM_16 (5 << 0)
@@ -96,7 +96,7 @@
96#define AT91_MATRIX_DTCM_16 (5 << 4) 96#define AT91_MATRIX_DTCM_16 (5 << 4)
97#define AT91_MATRIX_DTCM_32 (6 << 4) 97#define AT91_MATRIX_DTCM_32 (6 << 4)
98 98
99#define AT91_MATRIX_EBI0CSA 0x120 /* EBI0 Chip Select Assignment Register */ 99#define AT91_MATRIX_EBI0CSA (AT91_MATRIX + 0x120) /* EBI0 Chip Select Assignment Register */
100#define AT91_MATRIX_EBI0_CS1A (1 << 1) /* Chip Select 1 Assignment */ 100#define AT91_MATRIX_EBI0_CS1A (1 << 1) /* Chip Select 1 Assignment */
101#define AT91_MATRIX_EBI0_CS1A_SMC (0 << 1) 101#define AT91_MATRIX_EBI0_CS1A_SMC (0 << 1)
102#define AT91_MATRIX_EBI0_CS1A_SDRAMC (1 << 1) 102#define AT91_MATRIX_EBI0_CS1A_SDRAMC (1 << 1)
@@ -114,7 +114,7 @@
114#define AT91_MATRIX_EBI0_VDDIOMSEL_1_8V (0 << 16) 114#define AT91_MATRIX_EBI0_VDDIOMSEL_1_8V (0 << 16)
115#define AT91_MATRIX_EBI0_VDDIOMSEL_3_3V (1 << 16) 115#define AT91_MATRIX_EBI0_VDDIOMSEL_3_3V (1 << 16)
116 116
117#define AT91_MATRIX_EBI1CSA 0x124 /* EBI1 Chip Select Assignment Register */ 117#define AT91_MATRIX_EBI1CSA (AT91_MATRIX + 0x124) /* EBI1 Chip Select Assignment Register */
118#define AT91_MATRIX_EBI1_CS1A (1 << 1) /* Chip Select 1 Assignment */ 118#define AT91_MATRIX_EBI1_CS1A (1 << 1) /* Chip Select 1 Assignment */
119#define AT91_MATRIX_EBI1_CS1A_SMC (0 << 1) 119#define AT91_MATRIX_EBI1_CS1A_SMC (0 << 1)
120#define AT91_MATRIX_EBI1_CS1A_SDRAMC (1 << 1) 120#define AT91_MATRIX_EBI1_CS1A_SDRAMC (1 << 1)
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h b/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h
index 0210797abf2..d27b15ba8eb 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h
@@ -46,10 +46,10 @@
46#define AT91_DDRSDRC_CAS_25 (6 << 4) 46#define AT91_DDRSDRC_CAS_25 (6 << 4)
47#define AT91_DDRSDRC_RST_DLL (1 << 7) /* Reset DLL */ 47#define AT91_DDRSDRC_RST_DLL (1 << 7) /* Reset DLL */
48#define AT91_DDRSDRC_DICDS (1 << 8) /* Output impedance control */ 48#define AT91_DDRSDRC_DICDS (1 << 8) /* Output impedance control */
49#define AT91_DDRSDRC_DIS_DLL (1 << 9) /* Disable DLL [SAM9 Only] */ 49#define AT91_DDRSDRC_DIS_DLL (1 << 9) /* Disable DLL */
50#define AT91_DDRSDRC_OCD (1 << 12) /* Off-Chip Driver [SAM9 Only] */ 50#define AT91_DDRSDRC_OCD (1 << 12) /* Off-Chip Driver */
51#define AT91_DDRSDRC_DQMS (1 << 16) /* Mask Data is Shared [SAM9 Only] */ 51#define AT91_DDRSDRC_DQMS (1 << 16) /* Mask Data is Shared */
52#define AT91_DDRSDRC_ACTBST (1 << 18) /* Active Bank X to Burst Stop Read Access Bank Y [SAM9 Only] */ 52#define AT91_DDRSDRC_ACTBST (1 << 18) /* Active Bank X to Burst Stop Read Access Bank Y */
53 53
54#define AT91_DDRSDRC_T0PR 0x0C /* Timing 0 Register */ 54#define AT91_DDRSDRC_T0PR 0x0C /* Timing 0 Register */
55#define AT91_DDRSDRC_TRAS (0xf << 0) /* Active to Precharge delay */ 55#define AT91_DDRSDRC_TRAS (0xf << 0) /* Active to Precharge delay */
@@ -59,7 +59,7 @@
59#define AT91_DDRSDRC_TRP (0xf << 16) /* Row precharge delay */ 59#define AT91_DDRSDRC_TRP (0xf << 16) /* Row precharge delay */
60#define AT91_DDRSDRC_TRRD (0xf << 20) /* Active BankA to BankB */ 60#define AT91_DDRSDRC_TRRD (0xf << 20) /* Active BankA to BankB */
61#define AT91_DDRSDRC_TWTR (0x7 << 24) /* Internal Write to Read delay */ 61#define AT91_DDRSDRC_TWTR (0x7 << 24) /* Internal Write to Read delay */
62#define AT91_DDRSDRC_RED_WRRD (0x1 << 27) /* Reduce Write to Read Delay [SAM9 Only] */ 62#define AT91_DDRSDRC_RED_WRRD (0x1 << 27) /* Reduce Write to Read Delay */
63#define AT91_DDRSDRC_TMRD (0xf << 28) /* Load mode to active/refresh delay */ 63#define AT91_DDRSDRC_TMRD (0xf << 28) /* Load mode to active/refresh delay */
64 64
65#define AT91_DDRSDRC_T1PR 0x10 /* Timing 1 Register */ 65#define AT91_DDRSDRC_T1PR 0x10 /* Timing 1 Register */
@@ -68,7 +68,7 @@
68#define AT91_DDRSDRC_TXSRD (0xff << 16) /* Exit self-refresh to read */ 68#define AT91_DDRSDRC_TXSRD (0xff << 16) /* Exit self-refresh to read */
69#define AT91_DDRSDRC_TXP (0xf << 24) /* Exit power-down delay */ 69#define AT91_DDRSDRC_TXP (0xf << 24) /* Exit power-down delay */
70 70
71#define AT91_DDRSDRC_T2PR 0x14 /* Timing 2 Register [SAM9 Only] */ 71#define AT91_DDRSDRC_T2PR 0x14 /* Timing 2 Register */
72#define AT91_DDRSDRC_TXARD (0xf << 0) /* Exit active power down delay to read command in mode "Fast Exit" */ 72#define AT91_DDRSDRC_TXARD (0xf << 0) /* Exit active power down delay to read command in mode "Fast Exit" */
73#define AT91_DDRSDRC_TXARDS (0xf << 4) /* Exit active power down delay to read command in mode "Slow Exit" */ 73#define AT91_DDRSDRC_TXARDS (0xf << 4) /* Exit active power down delay to read command in mode "Slow Exit" */
74#define AT91_DDRSDRC_TRPA (0xf << 8) /* Row Precharge All delay */ 74#define AT91_DDRSDRC_TRPA (0xf << 8) /* Row Precharge All delay */
@@ -96,7 +96,7 @@
96#define AT91_DDRSDRC_MD_SDR 0 96#define AT91_DDRSDRC_MD_SDR 0
97#define AT91_DDRSDRC_MD_LOW_POWER_SDR 1 97#define AT91_DDRSDRC_MD_LOW_POWER_SDR 1
98#define AT91_DDRSDRC_MD_LOW_POWER_DDR 3 98#define AT91_DDRSDRC_MD_LOW_POWER_DDR 3
99#define AT91_DDRSDRC_MD_DDR2 6 /* [SAM9 Only] */ 99#define AT91_DDRSDRC_MD_DDR2 6
100#define AT91_DDRSDRC_DBW (1 << 4) /* Data Bus Width */ 100#define AT91_DDRSDRC_DBW (1 << 4) /* Data Bus Width */
101#define AT91_DDRSDRC_DBW_32BITS (0 << 4) 101#define AT91_DDRSDRC_DBW_32BITS (0 << 4)
102#define AT91_DDRSDRC_DBW_16BITS (1 << 4) 102#define AT91_DDRSDRC_DBW_16BITS (1 << 4)
@@ -107,18 +107,24 @@
107#define AT91_DDRSDRC_MDOVF (1 << 2) /* Master Delay Overflow */ 107#define AT91_DDRSDRC_MDOVF (1 << 2) /* Master Delay Overflow */
108#define AT91_DDRSDRC_MDVAL (0xff << 8) /* Master Delay value */ 108#define AT91_DDRSDRC_MDVAL (0xff << 8) /* Master Delay value */
109 109
110#define AT91_DDRSDRC_HS 0x2C /* High Speed Register [SAM9 Only] */ 110#define AT91_DDRSDRC_HS 0x2C /* High Speed Register */
111#define AT91_DDRSDRC_DIS_ATCP_RD (1 << 2) /* Anticip read access is disabled */ 111#define AT91_DDRSDRC_DIS_ATCP_RD (1 << 2) /* Anticip read access is disabled */
112 112
113#define AT91_DDRSDRC_DELAY(n) (0x30 + (0x4 * (n))) /* Delay I/O Register n */ 113#define AT91_DDRSDRC_DELAY(n) (0x30 + (0x4 * (n))) /* Delay I/O Register n */
114 114
115#define AT91_DDRSDRC_WPMR 0xE4 /* Write Protect Mode Register [SAM9 Only] */ 115#define AT91_DDRSDRC_WPMR 0xE4 /* Write Protect Mode Register */
116#define AT91_DDRSDRC_WP (1 << 0) /* Write protect enable */ 116#define AT91_DDRSDRC_WP (1 << 0) /* Write protect enable */
117#define AT91_DDRSDRC_WPKEY (0xffffff << 8) /* Write protect key */ 117#define AT91_DDRSDRC_WPKEY (0xffffff << 8) /* Write protect key */
118#define AT91_DDRSDRC_KEY (0x444452 << 8) /* Write protect key = "DDR" */ 118#define AT91_DDRSDRC_KEY (0x444452 << 8) /* Write protect key = "DDR" */
119 119
120#define AT91_DDRSDRC_WPSR 0xE8 /* Write Protect Status Register [SAM9 Only] */ 120#define AT91_DDRSDRC_WPSR 0xE8 /* Write Protect Status Register */
121#define AT91_DDRSDRC_WPVS (1 << 0) /* Write protect violation status */ 121#define AT91_DDRSDRC_WPVS (1 << 0) /* Write protect violation status */
122#define AT91_DDRSDRC_WPVSRC (0xffff << 8) /* Write protect violation source */ 122#define AT91_DDRSDRC_WPVSRC (0xffff << 8) /* Write protect violation source */
123 123
124/* Register access macros */
125#define at91_ramc_read(num, reg) \
126 at91_sys_read(AT91_DDRSDRC##num + reg)
127#define at91_ramc_write(num, reg, value) \
128 at91_sys_write(AT91_DDRSDRC##num + reg, value)
129
124#endif 130#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
index 3d085a9a745..100f5a59292 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
@@ -82,4 +82,10 @@
82#define AT91_SDRAMC_MD_SDRAM 0 82#define AT91_SDRAMC_MD_SDRAM 0
83#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1 83#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1
84 84
85/* Register access macros */
86#define at91_ramc_read(num, reg) \
87 at91_sys_read(AT91_SDRAMC##num + reg)
88#define at91_ramc_write(num, reg, value) \
89 at91_sys_write(AT91_SDRAMC##num + reg, value)
90
85#endif 91#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_smc.h b/arch/arm/mach-at91/include/mach/at91sam9_smc.h
index 175e1fdd9fe..57de6207e57 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_smc.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_smc.h
@@ -16,38 +16,7 @@
16#ifndef AT91SAM9_SMC_H 16#ifndef AT91SAM9_SMC_H
17#define AT91SAM9_SMC_H 17#define AT91SAM9_SMC_H
18 18
19#include <mach/cpu.h> 19#define AT91_SMC_SETUP(n) (AT91_SMC + 0x00 + ((n)*0x10)) /* Setup Register for CS n */
20
21#ifndef __ASSEMBLY__
22struct sam9_smc_config {
23 /* Setup register */
24 u8 ncs_read_setup;
25 u8 nrd_setup;
26 u8 ncs_write_setup;
27 u8 nwe_setup;
28
29 /* Pulse register */
30 u8 ncs_read_pulse;
31 u8 nrd_pulse;
32 u8 ncs_write_pulse;
33 u8 nwe_pulse;
34
35 /* Cycle register */
36 u16 read_cycle;
37 u16 write_cycle;
38
39 /* Mode register */
40 u32 mode;
41 u8 tdf_cycles:4;
42};
43
44extern void sam9_smc_configure(int id, int cs, struct sam9_smc_config *config);
45extern void sam9_smc_read(int id, int cs, struct sam9_smc_config *config);
46extern void sam9_smc_read_mode(int id, int cs, struct sam9_smc_config *config);
47extern void sam9_smc_write_mode(int id, int cs, struct sam9_smc_config *config);
48#endif
49
50#define AT91_SMC_SETUP 0x00 /* Setup Register for CS n */
51#define AT91_SMC_NWESETUP (0x3f << 0) /* NWE Setup Length */ 20#define AT91_SMC_NWESETUP (0x3f << 0) /* NWE Setup Length */
52#define AT91_SMC_NWESETUP_(x) ((x) << 0) 21#define AT91_SMC_NWESETUP_(x) ((x) << 0)
53#define AT91_SMC_NCS_WRSETUP (0x3f << 8) /* NCS Setup Length in Write Access */ 22#define AT91_SMC_NCS_WRSETUP (0x3f << 8) /* NCS Setup Length in Write Access */
@@ -57,7 +26,7 @@ extern void sam9_smc_write_mode(int id, int cs, struct sam9_smc_config *config);
57#define AT91_SMC_NCS_RDSETUP (0x3f << 24) /* NCS Setup Length in Read Access */ 26#define AT91_SMC_NCS_RDSETUP (0x3f << 24) /* NCS Setup Length in Read Access */
58#define AT91_SMC_NCS_RDSETUP_(x) ((x) << 24) 27#define AT91_SMC_NCS_RDSETUP_(x) ((x) << 24)
59 28
60#define AT91_SMC_PULSE 0x04 /* Pulse Register for CS n */ 29#define AT91_SMC_PULSE(n) (AT91_SMC + 0x04 + ((n)*0x10)) /* Pulse Register for CS n */
61#define AT91_SMC_NWEPULSE (0x7f << 0) /* NWE Pulse Length */ 30#define AT91_SMC_NWEPULSE (0x7f << 0) /* NWE Pulse Length */
62#define AT91_SMC_NWEPULSE_(x) ((x) << 0) 31#define AT91_SMC_NWEPULSE_(x) ((x) << 0)
63#define AT91_SMC_NCS_WRPULSE (0x7f << 8) /* NCS Pulse Length in Write Access */ 32#define AT91_SMC_NCS_WRPULSE (0x7f << 8) /* NCS Pulse Length in Write Access */
@@ -67,13 +36,13 @@ extern void sam9_smc_write_mode(int id, int cs, struct sam9_smc_config *config);
67#define AT91_SMC_NCS_RDPULSE (0x7f << 24) /* NCS Pulse Length in Read Access */ 36#define AT91_SMC_NCS_RDPULSE (0x7f << 24) /* NCS Pulse Length in Read Access */
68#define AT91_SMC_NCS_RDPULSE_(x)((x) << 24) 37#define AT91_SMC_NCS_RDPULSE_(x)((x) << 24)
69 38
70#define AT91_SMC_CYCLE 0x08 /* Cycle Register for CS n */ 39#define AT91_SMC_CYCLE(n) (AT91_SMC + 0x08 + ((n)*0x10)) /* Cycle Register for CS n */
71#define AT91_SMC_NWECYCLE (0x1ff << 0 ) /* Total Write Cycle Length */ 40#define AT91_SMC_NWECYCLE (0x1ff << 0 ) /* Total Write Cycle Length */
72#define AT91_SMC_NWECYCLE_(x) ((x) << 0) 41#define AT91_SMC_NWECYCLE_(x) ((x) << 0)
73#define AT91_SMC_NRDCYCLE (0x1ff << 16) /* Total Read Cycle Length */ 42#define AT91_SMC_NRDCYCLE (0x1ff << 16) /* Total Read Cycle Length */
74#define AT91_SMC_NRDCYCLE_(x) ((x) << 16) 43#define AT91_SMC_NRDCYCLE_(x) ((x) << 16)
75 44
76#define AT91_SMC_MODE 0x0c /* Mode Register for CS n */ 45#define AT91_SMC_MODE(n) (AT91_SMC + 0x0c + ((n)*0x10)) /* Mode Register for CS n */
77#define AT91_SMC_READMODE (1 << 0) /* Read Mode */ 46#define AT91_SMC_READMODE (1 << 0) /* Read Mode */
78#define AT91_SMC_WRITEMODE (1 << 1) /* Write Mode */ 47#define AT91_SMC_WRITEMODE (1 << 1) /* Write Mode */
79#define AT91_SMC_EXNWMODE (3 << 4) /* NWAIT Mode */ 48#define AT91_SMC_EXNWMODE (3 << 4) /* NWAIT Mode */
@@ -97,4 +66,11 @@ extern void sam9_smc_write_mode(int id, int cs, struct sam9_smc_config *config);
97#define AT91_SMC_PS_16 (2 << 28) 66#define AT91_SMC_PS_16 (2 << 28)
98#define AT91_SMC_PS_32 (3 << 28) 67#define AT91_SMC_PS_32 (3 << 28)
99 68
69#if defined(AT91_SMC1) /* The AT91SAM9263 has 2 Static Memory contollers */
70#define AT91_SMC1_SETUP(n) (AT91_SMC1 + 0x00 + ((n)*0x10)) /* Setup Register for CS n */
71#define AT91_SMC1_PULSE(n) (AT91_SMC1 + 0x04 + ((n)*0x10)) /* Pulse Register for CS n */
72#define AT91_SMC1_CYCLE(n) (AT91_SMC1 + 0x08 + ((n)*0x10)) /* Cycle Register for CS n */
73#define AT91_SMC1_MODE(n) (AT91_SMC1 + 0x0c + ((n)*0x10)) /* Mode Register for CS n */
74#endif
75
100#endif 76#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45.h b/arch/arm/mach-at91/include/mach/at91sam9g45.h
index 8eba1021f53..2c611b9a013 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9g45.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9g45.h
@@ -84,27 +84,34 @@
84#define AT91SAM9G45_BASE_TC5 0xfffd4080 84#define AT91SAM9G45_BASE_TC5 0xfffd4080
85 85
86/* 86/*
87 * System Peripherals 87 * System Peripherals (offset from AT91_BASE_SYS)
88 */ 88 */
89#define AT91SAM9G45_BASE_ECC 0xffffe200 89#define AT91_ECC (0xffffe200 - AT91_BASE_SYS)
90#define AT91SAM9G45_BASE_DDRSDRC1 0xffffe400 90#define AT91_DDRSDRC1 (0xffffe400 - AT91_BASE_SYS)
91#define AT91SAM9G45_BASE_DDRSDRC0 0xffffe600 91#define AT91_DDRSDRC0 (0xffffe600 - AT91_BASE_SYS)
92#define AT91SAM9G45_BASE_DMA 0xffffec00 92#define AT91_SMC (0xffffe800 - AT91_BASE_SYS)
93#define AT91SAM9G45_BASE_SMC 0xffffe800 93#define AT91_MATRIX (0xffffea00 - AT91_BASE_SYS)
94#define AT91SAM9G45_BASE_MATRIX 0xffffea00 94#define AT91_DMA (0xffffec00 - AT91_BASE_SYS)
95#define AT91SAM9G45_BASE_DBGU AT91_BASE_DBGU1 95#define AT91_DBGU (0xffffee00 - AT91_BASE_SYS)
96#define AT91SAM9G45_BASE_PIOA 0xfffff200 96#define AT91_AIC (0xfffff000 - AT91_BASE_SYS)
97#define AT91SAM9G45_BASE_PIOB 0xfffff400 97#define AT91_PIOA (0xfffff200 - AT91_BASE_SYS)
98#define AT91SAM9G45_BASE_PIOC 0xfffff600 98#define AT91_PIOB (0xfffff400 - AT91_BASE_SYS)
99#define AT91SAM9G45_BASE_PIOD 0xfffff800 99#define AT91_PIOC (0xfffff600 - AT91_BASE_SYS)
100#define AT91SAM9G45_BASE_PIOE 0xfffffa00 100#define AT91_PIOD (0xfffff800 - AT91_BASE_SYS)
101#define AT91SAM9G45_BASE_RSTC 0xfffffd00 101#define AT91_PIOE (0xfffffa00 - AT91_BASE_SYS)
102#define AT91SAM9G45_BASE_SHDWC 0xfffffd10 102#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
103#define AT91SAM9G45_BASE_RTT 0xfffffd20 103#define AT91_RSTC (0xfffffd00 - AT91_BASE_SYS)
104#define AT91SAM9G45_BASE_PIT 0xfffffd30 104#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)
105#define AT91SAM9G45_BASE_WDT 0xfffffd40 105#define AT91_RTT (0xfffffd20 - AT91_BASE_SYS)
106#define AT91SAM9G45_BASE_RTC 0xfffffdb0 106#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS)
107#define AT91SAM9G45_BASE_GPBR 0xfffffd60 107#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS)
108#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)
109#define AT91_RTC (0xfffffdb0 - AT91_BASE_SYS)
110
111#define AT91_USART0 AT91SAM9G45_BASE_US0
112#define AT91_USART1 AT91SAM9G45_BASE_US1
113#define AT91_USART2 AT91SAM9G45_BASE_US2
114#define AT91_USART3 AT91SAM9G45_BASE_US3
108 115
109/* 116/*
110 * Internal Memory. 117 * Internal Memory.
@@ -121,6 +128,8 @@
121#define AT91SAM9G45_EHCI_BASE 0x00800000 /* USB Host controller (EHCI) */ 128#define AT91SAM9G45_EHCI_BASE 0x00800000 /* USB Host controller (EHCI) */
122#define AT91SAM9G45_VDEC_BASE 0x00900000 /* Video Decoder Controller */ 129#define AT91SAM9G45_VDEC_BASE 0x00900000 /* Video Decoder Controller */
123 130
131#define CONSISTENT_DMA_SIZE SZ_4M
132
124/* 133/*
125 * DMA peripheral identifiers 134 * DMA peripheral identifiers
126 * for hardware handshaking interface 135 * for hardware handshaking interface
@@ -136,8 +145,6 @@
136#define AT_DMA_ID_SSC1_RX 8 145#define AT_DMA_ID_SSC1_RX 8
137#define AT_DMA_ID_AC97_TX 9 146#define AT_DMA_ID_AC97_TX 9
138#define AT_DMA_ID_AC97_RX 10 147#define AT_DMA_ID_AC97_RX 10
139#define AT_DMA_ID_AES_TX 11
140#define AT_DMA_ID_AES_RX 12
141#define AT_DMA_ID_MCI1 13 148#define AT_DMA_ID_MCI1 13
142 149
143#endif 150#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h
index b76e2ed2fbc..c972d60e0ae 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h
@@ -15,18 +15,18 @@
15#ifndef AT91SAM9G45_MATRIX_H 15#ifndef AT91SAM9G45_MATRIX_H
16#define AT91SAM9G45_MATRIX_H 16#define AT91SAM9G45_MATRIX_H
17 17
18#define AT91_MATRIX_MCFG0 0x00 /* Master Configuration Register 0 */ 18#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00) /* Master Configuration Register 0 */
19#define AT91_MATRIX_MCFG1 0x04 /* Master Configuration Register 1 */ 19#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04) /* Master Configuration Register 1 */
20#define AT91_MATRIX_MCFG2 0x08 /* Master Configuration Register 2 */ 20#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08) /* Master Configuration Register 2 */
21#define AT91_MATRIX_MCFG3 0x0C /* Master Configuration Register 3 */ 21#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C) /* Master Configuration Register 3 */
22#define AT91_MATRIX_MCFG4 0x10 /* Master Configuration Register 4 */ 22#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10) /* Master Configuration Register 4 */
23#define AT91_MATRIX_MCFG5 0x14 /* Master Configuration Register 5 */ 23#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14) /* Master Configuration Register 5 */
24#define AT91_MATRIX_MCFG6 0x18 /* Master Configuration Register 6 */ 24#define AT91_MATRIX_MCFG6 (AT91_MATRIX + 0x18) /* Master Configuration Register 6 */
25#define AT91_MATRIX_MCFG7 0x1C /* Master Configuration Register 7 */ 25#define AT91_MATRIX_MCFG7 (AT91_MATRIX + 0x1C) /* Master Configuration Register 7 */
26#define AT91_MATRIX_MCFG8 0x20 /* Master Configuration Register 8 */ 26#define AT91_MATRIX_MCFG8 (AT91_MATRIX + 0x20) /* Master Configuration Register 8 */
27#define AT91_MATRIX_MCFG9 0x24 /* Master Configuration Register 9 */ 27#define AT91_MATRIX_MCFG9 (AT91_MATRIX + 0x24) /* Master Configuration Register 9 */
28#define AT91_MATRIX_MCFG10 0x28 /* Master Configuration Register 10 */ 28#define AT91_MATRIX_MCFG10 (AT91_MATRIX + 0x28) /* Master Configuration Register 10 */
29#define AT91_MATRIX_MCFG11 0x2C /* Master Configuration Register 11 */ 29#define AT91_MATRIX_MCFG11 (AT91_MATRIX + 0x2C) /* Master Configuration Register 11 */
30#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */ 30#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */
31#define AT91_MATRIX_ULBT_INFINITE (0 << 0) 31#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
32#define AT91_MATRIX_ULBT_SINGLE (1 << 0) 32#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
@@ -37,14 +37,14 @@
37#define AT91_MATRIX_ULBT_SIXTYFOUR (6 << 0) 37#define AT91_MATRIX_ULBT_SIXTYFOUR (6 << 0)
38#define AT91_MATRIX_ULBT_128 (7 << 0) 38#define AT91_MATRIX_ULBT_128 (7 << 0)
39 39
40#define AT91_MATRIX_SCFG0 0x40 /* Slave Configuration Register 0 */ 40#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40) /* Slave Configuration Register 0 */
41#define AT91_MATRIX_SCFG1 0x44 /* Slave Configuration Register 1 */ 41#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44) /* Slave Configuration Register 1 */
42#define AT91_MATRIX_SCFG2 0x48 /* Slave Configuration Register 2 */ 42#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48) /* Slave Configuration Register 2 */
43#define AT91_MATRIX_SCFG3 0x4C /* Slave Configuration Register 3 */ 43#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C) /* Slave Configuration Register 3 */
44#define AT91_MATRIX_SCFG4 0x50 /* Slave Configuration Register 4 */ 44#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50) /* Slave Configuration Register 4 */
45#define AT91_MATRIX_SCFG5 0x54 /* Slave Configuration Register 5 */ 45#define AT91_MATRIX_SCFG5 (AT91_MATRIX + 0x54) /* Slave Configuration Register 5 */
46#define AT91_MATRIX_SCFG6 0x58 /* Slave Configuration Register 6 */ 46#define AT91_MATRIX_SCFG6 (AT91_MATRIX + 0x58) /* Slave Configuration Register 6 */
47#define AT91_MATRIX_SCFG7 0x5C /* Slave Configuration Register 7 */ 47#define AT91_MATRIX_SCFG7 (AT91_MATRIX + 0x5C) /* Slave Configuration Register 7 */
48#define AT91_MATRIX_SLOT_CYCLE (0x1ff << 0) /* Maximum Number of Allowed Cycles for a Burst */ 48#define AT91_MATRIX_SLOT_CYCLE (0x1ff << 0) /* Maximum Number of Allowed Cycles for a Burst */
49#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */ 49#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
50#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 50#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -52,22 +52,22 @@
52#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16) 52#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16)
53#define AT91_MATRIX_FIXED_DEFMSTR (0xf << 18) /* Fixed Index of Default Master */ 53#define AT91_MATRIX_FIXED_DEFMSTR (0xf << 18) /* Fixed Index of Default Master */
54 54
55#define AT91_MATRIX_PRAS0 0x80 /* Priority Register A for Slave 0 */ 55#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80) /* Priority Register A for Slave 0 */
56#define AT91_MATRIX_PRBS0 0x84 /* Priority Register B for Slave 0 */ 56#define AT91_MATRIX_PRBS0 (AT91_MATRIX + 0x84) /* Priority Register B for Slave 0 */
57#define AT91_MATRIX_PRAS1 0x88 /* Priority Register A for Slave 1 */ 57#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88) /* Priority Register A for Slave 1 */
58#define AT91_MATRIX_PRBS1 0x8C /* Priority Register B for Slave 1 */ 58#define AT91_MATRIX_PRBS1 (AT91_MATRIX + 0x8C) /* Priority Register B for Slave 1 */
59#define AT91_MATRIX_PRAS2 0x90 /* Priority Register A for Slave 2 */ 59#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90) /* Priority Register A for Slave 2 */
60#define AT91_MATRIX_PRBS2 0x94 /* Priority Register B for Slave 2 */ 60#define AT91_MATRIX_PRBS2 (AT91_MATRIX + 0x94) /* Priority Register B for Slave 2 */
61#define AT91_MATRIX_PRAS3 0x98 /* Priority Register A for Slave 3 */ 61#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98) /* Priority Register A for Slave 3 */
62#define AT91_MATRIX_PRBS3 0x9C /* Priority Register B for Slave 3 */ 62#define AT91_MATRIX_PRBS3 (AT91_MATRIX + 0x9C) /* Priority Register B for Slave 3 */
63#define AT91_MATRIX_PRAS4 0xA0 /* Priority Register A for Slave 4 */ 63#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0) /* Priority Register A for Slave 4 */
64#define AT91_MATRIX_PRBS4 0xA4 /* Priority Register B for Slave 4 */ 64#define AT91_MATRIX_PRBS4 (AT91_MATRIX + 0xA4) /* Priority Register B for Slave 4 */
65#define AT91_MATRIX_PRAS5 0xA8 /* Priority Register A for Slave 5 */ 65#define AT91_MATRIX_PRAS5 (AT91_MATRIX + 0xA8) /* Priority Register A for Slave 5 */
66#define AT91_MATRIX_PRBS5 0xAC /* Priority Register B for Slave 5 */ 66#define AT91_MATRIX_PRBS5 (AT91_MATRIX + 0xAC) /* Priority Register B for Slave 5 */
67#define AT91_MATRIX_PRAS6 0xB0 /* Priority Register A for Slave 6 */ 67#define AT91_MATRIX_PRAS6 (AT91_MATRIX + 0xB0) /* Priority Register A for Slave 6 */
68#define AT91_MATRIX_PRBS6 0xB4 /* Priority Register B for Slave 6 */ 68#define AT91_MATRIX_PRBS6 (AT91_MATRIX + 0xB4) /* Priority Register B for Slave 6 */
69#define AT91_MATRIX_PRAS7 0xB8 /* Priority Register A for Slave 7 */ 69#define AT91_MATRIX_PRAS7 (AT91_MATRIX + 0xB8) /* Priority Register A for Slave 7 */
70#define AT91_MATRIX_PRBS7 0xBC /* Priority Register B for Slave 7 */ 70#define AT91_MATRIX_PRBS7 (AT91_MATRIX + 0xBC) /* Priority Register B for Slave 7 */
71#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */ 71#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */
72#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */ 72#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */
73#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */ 73#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */
@@ -81,7 +81,7 @@
81#define AT91_MATRIX_M10PR (3 << 8) /* Master 10 Priority (in Register B) */ 81#define AT91_MATRIX_M10PR (3 << 8) /* Master 10 Priority (in Register B) */
82#define AT91_MATRIX_M11PR (3 << 12) /* Master 11 Priority (in Register B) */ 82#define AT91_MATRIX_M11PR (3 << 12) /* Master 11 Priority (in Register B) */
83 83
84#define AT91_MATRIX_MRCR 0x100 /* Master Remap Control Register */ 84#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100) /* Master Remap Control Register */
85#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ 85#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
86#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ 86#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
87#define AT91_MATRIX_RCB2 (1 << 2) 87#define AT91_MATRIX_RCB2 (1 << 2)
@@ -95,7 +95,7 @@
95#define AT91_MATRIX_RCB10 (1 << 10) 95#define AT91_MATRIX_RCB10 (1 << 10)
96#define AT91_MATRIX_RCB11 (1 << 11) 96#define AT91_MATRIX_RCB11 (1 << 11)
97 97
98#define AT91_MATRIX_TCMR 0x110 /* TCM Configuration Register */ 98#define AT91_MATRIX_TCMR (AT91_MATRIX + 0x110) /* TCM Configuration Register */
99#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */ 99#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */
100#define AT91_MATRIX_ITCM_0 (0 << 0) 100#define AT91_MATRIX_ITCM_0 (0 << 0)
101#define AT91_MATRIX_ITCM_32 (6 << 0) 101#define AT91_MATRIX_ITCM_32 (6 << 0)
@@ -107,12 +107,12 @@
107#define AT91_MATRIX_TCM_NO_WS (0x0 << 11) 107#define AT91_MATRIX_TCM_NO_WS (0x0 << 11)
108#define AT91_MATRIX_TCM_ONE_WS (0x1 << 11) 108#define AT91_MATRIX_TCM_ONE_WS (0x1 << 11)
109 109
110#define AT91_MATRIX_VIDEO 0x118 /* Video Mode Configuration Register */ 110#define AT91_MATRIX_VIDEO (AT91_MATRIX + 0x118) /* Video Mode Configuration Register */
111#define AT91C_VDEC_SEL (0x1 << 0) /* Video Mode Selection */ 111#define AT91C_VDEC_SEL (0x1 << 0) /* Video Mode Selection */
112#define AT91C_VDEC_SEL_OFF (0 << 0) 112#define AT91C_VDEC_SEL_OFF (0 << 0)
113#define AT91C_VDEC_SEL_ON (1 << 0) 113#define AT91C_VDEC_SEL_ON (1 << 0)
114 114
115#define AT91_MATRIX_EBICSA 0x128 /* EBI Chip Select Assignment Register */ 115#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x128) /* EBI Chip Select Assignment Register */
116#define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */ 116#define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */
117#define AT91_MATRIX_EBI_CS1A_SMC (0 << 1) 117#define AT91_MATRIX_EBI_CS1A_SMC (0 << 1)
118#define AT91_MATRIX_EBI_CS1A_SDRAMC (1 << 1) 118#define AT91_MATRIX_EBI_CS1A_SDRAMC (1 << 1)
@@ -138,13 +138,13 @@
138#define AT91_MATRIX_EBI_DDR_IOSR_REDUCED (0 << 18) 138#define AT91_MATRIX_EBI_DDR_IOSR_REDUCED (0 << 18)
139#define AT91_MATRIX_EBI_DDR_IOSR_NORMAL (1 << 18) 139#define AT91_MATRIX_EBI_DDR_IOSR_NORMAL (1 << 18)
140 140
141#define AT91_MATRIX_WPMR 0x1E4 /* Write Protect Mode Register */ 141#define AT91_MATRIX_WPMR (AT91_MATRIX + 0x1E4) /* Write Protect Mode Register */
142#define AT91_MATRIX_WPMR_WPEN (1 << 0) /* Write Protect ENable */ 142#define AT91_MATRIX_WPMR_WPEN (1 << 0) /* Write Protect ENable */
143#define AT91_MATRIX_WPMR_WP_WPDIS (0 << 0) 143#define AT91_MATRIX_WPMR_WP_WPDIS (0 << 0)
144#define AT91_MATRIX_WPMR_WP_WPEN (1 << 0) 144#define AT91_MATRIX_WPMR_WP_WPEN (1 << 0)
145#define AT91_MATRIX_WPMR_WPKEY (0xFFFFFF << 8) /* Write Protect KEY */ 145#define AT91_MATRIX_WPMR_WPKEY (0xFFFFFF << 8) /* Write Protect KEY */
146 146
147#define AT91_MATRIX_WPSR 0x1E8 /* Write Protect Status Register */ 147#define AT91_MATRIX_WPSR (AT91_MATRIX + 0x1E8) /* Write Protect Status Register */
148#define AT91_MATRIX_WPSR_WPVS (1 << 0) /* Write Protect Violation Status */ 148#define AT91_MATRIX_WPSR_WPVS (1 << 0) /* Write Protect Violation Status */
149#define AT91_MATRIX_WPSR_NO_WPV (0 << 0) 149#define AT91_MATRIX_WPSR_NO_WPV (0 << 0)
150#define AT91_MATRIX_WPSR_WPV (1 << 0) 150#define AT91_MATRIX_WPSR_WPV (1 << 0)
diff --git a/arch/arm/mach-at91/include/mach/at91sam9n12.h b/arch/arm/mach-at91/include/mach/at91sam9n12.h
deleted file mode 100644
index d374b87c045..00000000000
--- a/arch/arm/mach-at91/include/mach/at91sam9n12.h
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * SoC specific header file for the AT91SAM9N12
3 *
4 * Copyright (C) 2012 Atmel Corporation
5 *
6 * Common definitions, based on AT91SAM9N12 SoC datasheet
7 *
8 * Licensed under GPLv2 or later
9 */
10
11#ifndef _AT91SAM9N12_H_
12#define _AT91SAM9N12_H_
13
14/*
15 * Peripheral identifiers/interrupts.
16 */
17#define AT91SAM9N12_ID_PIOAB 2 /* Parallel I/O Controller A and B */
18#define AT91SAM9N12_ID_PIOCD 3 /* Parallel I/O Controller C and D */
19#define AT91SAM9N12_ID_FUSE 4 /* FUSE Controller */
20#define AT91SAM9N12_ID_USART0 5 /* USART 0 */
21#define AT91SAM9N12_ID_USART1 6 /* USART 1 */
22#define AT91SAM9N12_ID_USART2 7 /* USART 2 */
23#define AT91SAM9N12_ID_USART3 8 /* USART 3 */
24#define AT91SAM9N12_ID_TWI0 9 /* Two-Wire Interface 0 */
25#define AT91SAM9N12_ID_TWI1 10 /* Two-Wire Interface 1 */
26#define AT91SAM9N12_ID_MCI 12 /* High Speed Multimedia Card Interface */
27#define AT91SAM9N12_ID_SPI0 13 /* Serial Peripheral Interface 0 */
28#define AT91SAM9N12_ID_SPI1 14 /* Serial Peripheral Interface 1 */
29#define AT91SAM9N12_ID_UART0 15 /* UART 0 */
30#define AT91SAM9N12_ID_UART1 16 /* UART 1 */
31#define AT91SAM9N12_ID_TCB 17 /* Timer Counter 0, 1, 2, 3, 4 and 5 */
32#define AT91SAM9N12_ID_PWM 18 /* Pulse Width Modulation Controller */
33#define AT91SAM9N12_ID_ADC 19 /* ADC Controller */
34#define AT91SAM9N12_ID_DMA 20 /* DMA Controller */
35#define AT91SAM9N12_ID_UHP 22 /* USB Host High Speed */
36#define AT91SAM9N12_ID_UDP 23 /* USB Device High Speed */
37#define AT91SAM9N12_ID_LCDC 25 /* LCD Controller */
38#define AT91SAM9N12_ID_ISI 25 /* Image Sensor Interface */
39#define AT91SAM9N12_ID_SSC 28 /* Synchronous Serial Controller */
40#define AT91SAM9N12_ID_TRNG 30 /* TRNG */
41#define AT91SAM9N12_ID_IRQ0 31 /* Advanced Interrupt Controller */
42
43/*
44 * User Peripheral physical base addresses.
45 */
46#define AT91SAM9N12_BASE_USART0 0xf801c000
47#define AT91SAM9N12_BASE_USART1 0xf8020000
48#define AT91SAM9N12_BASE_USART2 0xf8024000
49#define AT91SAM9N12_BASE_USART3 0xf8028000
50
51/*
52 * Internal Memory.
53 */
54#define AT91SAM9N12_SRAM_BASE 0x00300000 /* Internal SRAM base address */
55#define AT91SAM9N12_SRAM_SIZE SZ_32K /* Internal SRAM size (32Kb) */
56
57#define AT91SAM9N12_ROM_BASE 0x00100000 /* Internal ROM base address */
58#define AT91SAM9N12_ROM_SIZE SZ_128K /* Internal ROM size (128Kb) */
59
60#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h
deleted file mode 100644
index 40060cd62fa..00000000000
--- a/arch/arm/mach-at91/include/mach/at91sam9n12_matrix.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * Matrix-centric header file for the AT91SAM9N12
3 *
4 * Copyright (C) 2012 Atmel Corporation.
5 *
6 * Only EBI related registers.
7 * Write Protect register definitions may be useful.
8 *
9 * Licensed under GPLv2 or later.
10 */
11
12#ifndef _AT91SAM9N12_MATRIX_H_
13#define _AT91SAM9N12_MATRIX_H_
14
15#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x118) /* EBI Chip Select Assignment Register */
16#define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */
17#define AT91_MATRIX_EBI_CS1A_SMC (0 << 1)
18#define AT91_MATRIX_EBI_CS1A_SDRAMC (1 << 1)
19#define AT91_MATRIX_EBI_CS3A (1 << 3) /* Chip Select 3 Assignment */
20#define AT91_MATRIX_EBI_CS3A_SMC (0 << 3)
21#define AT91_MATRIX_EBI_CS3A_SMC_NANDFLASH (1 << 3)
22#define AT91_MATRIX_EBI_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */
23#define AT91_MATRIX_EBI_DBPU_ON (0 << 8)
24#define AT91_MATRIX_EBI_DBPU_OFF (1 << 8)
25#define AT91_MATRIX_EBI_VDDIOMSEL (1 << 16) /* Memory voltage selection */
26#define AT91_MATRIX_EBI_VDDIOMSEL_1_8V (0 << 16)
27#define AT91_MATRIX_EBI_VDDIOMSEL_3_3V (1 << 16)
28#define AT91_MATRIX_EBI_EBI_IOSR (1 << 17) /* EBI I/O slew rate selection */
29#define AT91_MATRIX_EBI_EBI_IOSR_REDUCED (0 << 17)
30#define AT91_MATRIX_EBI_EBI_IOSR_NORMAL (1 << 17)
31#define AT91_MATRIX_EBI_DDR_IOSR (1 << 18) /* DDR2 dedicated port I/O slew rate selection */
32#define AT91_MATRIX_EBI_DDR_IOSR_REDUCED (0 << 18)
33#define AT91_MATRIX_EBI_DDR_IOSR_NORMAL (1 << 18)
34#define AT91_MATRIX_NFD0_SELECT (1 << 24) /* NAND Flash Data Bus Selection */
35#define AT91_MATRIX_NFD0_ON_D0 (0 << 24)
36#define AT91_MATRIX_NFD0_ON_D16 (1 << 24)
37#define AT91_MATRIX_DDR_MP_EN (1 << 25) /* DDR Multi-port Enable */
38#define AT91_MATRIX_MP_OFF (0 << 25)
39#define AT91_MATRIX_MP_ON (1 << 25)
40
41#define AT91_MATRIX_WPMR (AT91_MATRIX + 0x1E4) /* Write Protect Mode Register */
42#define AT91_MATRIX_WPMR_WPEN (1 << 0) /* Write Protect ENable */
43#define AT91_MATRIX_WPMR_WP_WPDIS (0 << 0)
44#define AT91_MATRIX_WPMR_WP_WPEN (1 << 0)
45#define AT91_MATRIX_WPMR_WPKEY (0xFFFFFF << 8) /* Write Protect KEY */
46
47#define AT91_MATRIX_WPSR (AT91_MATRIX + 0x1E8) /* Write Protect Status Register */
48#define AT91_MATRIX_WPSR_WPVS (1 << 0) /* Write Protect Violation Status */
49#define AT91_MATRIX_WPSR_NO_WPV (0 << 0)
50#define AT91_MATRIX_WPSR_WPV (1 << 0)
51#define AT91_MATRIX_WPSR_WPVSRC (0xFFFF << 8) /* Write Protect Violation Source */
52
53#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9rl.h b/arch/arm/mach-at91/include/mach/at91sam9rl.h
index a15db56d33f..1aabacd315d 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9rl.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9rl.h
@@ -69,25 +69,32 @@
69/* 69/*
70 * System Peripherals (offset from AT91_BASE_SYS) 70 * System Peripherals (offset from AT91_BASE_SYS)
71 */ 71 */
72#define AT91_DMA (0xffffe600 - AT91_BASE_SYS)
73#define AT91_ECC (0xffffe800 - AT91_BASE_SYS)
74#define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS)
75#define AT91_SMC (0xffffec00 - AT91_BASE_SYS)
76#define AT91_MATRIX (0xffffee00 - AT91_BASE_SYS)
77#define AT91_CCFG (0xffffef10 - AT91_BASE_SYS)
78#define AT91_AIC (0xfffff000 - AT91_BASE_SYS)
79#define AT91_DBGU (0xfffff200 - AT91_BASE_SYS)
80#define AT91_PIOA (0xfffff400 - AT91_BASE_SYS)
81#define AT91_PIOB (0xfffff600 - AT91_BASE_SYS)
82#define AT91_PIOC (0xfffff800 - AT91_BASE_SYS)
83#define AT91_PIOD (0xfffffa00 - AT91_BASE_SYS)
84#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
85#define AT91_RSTC (0xfffffd00 - AT91_BASE_SYS)
86#define AT91_SHDWC (0xfffffd10 - AT91_BASE_SYS)
87#define AT91_RTT (0xfffffd20 - AT91_BASE_SYS)
88#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS)
89#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS)
72#define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS) 90#define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS)
91#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)
92#define AT91_RTC (0xfffffe00 - AT91_BASE_SYS)
73 93
74#define AT91SAM9RL_BASE_DMA 0xffffe600 94#define AT91_USART0 AT91SAM9RL_BASE_US0
75#define AT91SAM9RL_BASE_ECC 0xffffe800 95#define AT91_USART1 AT91SAM9RL_BASE_US1
76#define AT91SAM9RL_BASE_SDRAMC 0xffffea00 96#define AT91_USART2 AT91SAM9RL_BASE_US2
77#define AT91SAM9RL_BASE_SMC 0xffffec00 97#define AT91_USART3 AT91SAM9RL_BASE_US3
78#define AT91SAM9RL_BASE_MATRIX 0xffffee00
79#define AT91SAM9RL_BASE_DBGU AT91_BASE_DBGU0
80#define AT91SAM9RL_BASE_PIOA 0xfffff400
81#define AT91SAM9RL_BASE_PIOB 0xfffff600
82#define AT91SAM9RL_BASE_PIOC 0xfffff800
83#define AT91SAM9RL_BASE_PIOD 0xfffffa00
84#define AT91SAM9RL_BASE_RSTC 0xfffffd00
85#define AT91SAM9RL_BASE_SHDWC 0xfffffd10
86#define AT91SAM9RL_BASE_RTT 0xfffffd20
87#define AT91SAM9RL_BASE_PIT 0xfffffd30
88#define AT91SAM9RL_BASE_WDT 0xfffffd40
89#define AT91SAM9RL_BASE_GPBR 0xfffffd60
90#define AT91SAM9RL_BASE_RTC 0xfffffe00
91 98
92 99
93/* 100/*
diff --git a/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h
index 6d160adadaf..5f9149071fe 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h
@@ -14,12 +14,12 @@
14#ifndef AT91SAM9RL_MATRIX_H 14#ifndef AT91SAM9RL_MATRIX_H
15#define AT91SAM9RL_MATRIX_H 15#define AT91SAM9RL_MATRIX_H
16 16
17#define AT91_MATRIX_MCFG0 0x00 /* Master Configuration Register 0 */ 17#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00) /* Master Configuration Register 0 */
18#define AT91_MATRIX_MCFG1 0x04 /* Master Configuration Register 1 */ 18#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04) /* Master Configuration Register 1 */
19#define AT91_MATRIX_MCFG2 0x08 /* Master Configuration Register 2 */ 19#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08) /* Master Configuration Register 2 */
20#define AT91_MATRIX_MCFG3 0x0C /* Master Configuration Register 3 */ 20#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C) /* Master Configuration Register 3 */
21#define AT91_MATRIX_MCFG4 0x10 /* Master Configuration Register 4 */ 21#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10) /* Master Configuration Register 4 */
22#define AT91_MATRIX_MCFG5 0x14 /* Master Configuration Register 5 */ 22#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14) /* Master Configuration Register 5 */
23#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */ 23#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */
24#define AT91_MATRIX_ULBT_INFINITE (0 << 0) 24#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
25#define AT91_MATRIX_ULBT_SINGLE (1 << 0) 25#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
@@ -27,12 +27,12 @@
27#define AT91_MATRIX_ULBT_EIGHT (3 << 0) 27#define AT91_MATRIX_ULBT_EIGHT (3 << 0)
28#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0) 28#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0)
29 29
30#define AT91_MATRIX_SCFG0 0x40 /* Slave Configuration Register 0 */ 30#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40) /* Slave Configuration Register 0 */
31#define AT91_MATRIX_SCFG1 0x44 /* Slave Configuration Register 1 */ 31#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44) /* Slave Configuration Register 1 */
32#define AT91_MATRIX_SCFG2 0x48 /* Slave Configuration Register 2 */ 32#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48) /* Slave Configuration Register 2 */
33#define AT91_MATRIX_SCFG3 0x4C /* Slave Configuration Register 3 */ 33#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C) /* Slave Configuration Register 3 */
34#define AT91_MATRIX_SCFG4 0x50 /* Slave Configuration Register 4 */ 34#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50) /* Slave Configuration Register 4 */
35#define AT91_MATRIX_SCFG5 0x54 /* Slave Configuration Register 5 */ 35#define AT91_MATRIX_SCFG5 (AT91_MATRIX + 0x54) /* Slave Configuration Register 5 */
36#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */ 36#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */
37#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */ 37#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
38#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 38#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -43,12 +43,12 @@
43#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24) 43#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
44#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24) 44#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
45 45
46#define AT91_MATRIX_PRAS0 0x80 /* Priority Register A for Slave 0 */ 46#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80) /* Priority Register A for Slave 0 */
47#define AT91_MATRIX_PRAS1 0x88 /* Priority Register A for Slave 1 */ 47#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88) /* Priority Register A for Slave 1 */
48#define AT91_MATRIX_PRAS2 0x90 /* Priority Register A for Slave 2 */ 48#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90) /* Priority Register A for Slave 2 */
49#define AT91_MATRIX_PRAS3 0x98 /* Priority Register A for Slave 3 */ 49#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98) /* Priority Register A for Slave 3 */
50#define AT91_MATRIX_PRAS4 0xA0 /* Priority Register A for Slave 4 */ 50#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0) /* Priority Register A for Slave 4 */
51#define AT91_MATRIX_PRAS5 0xA8 /* Priority Register A for Slave 5 */ 51#define AT91_MATRIX_PRAS5 (AT91_MATRIX + 0xA8) /* Priority Register A for Slave 5 */
52#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */ 52#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */
53#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */ 53#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */
54#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */ 54#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */
@@ -56,7 +56,7 @@
56#define AT91_MATRIX_M4PR (3 << 16) /* Master 4 Priority */ 56#define AT91_MATRIX_M4PR (3 << 16) /* Master 4 Priority */
57#define AT91_MATRIX_M5PR (3 << 20) /* Master 5 Priority */ 57#define AT91_MATRIX_M5PR (3 << 20) /* Master 5 Priority */
58 58
59#define AT91_MATRIX_MRCR 0x100 /* Master Remap Control Register */ 59#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100) /* Master Remap Control Register */
60#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ 60#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
61#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ 61#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
62#define AT91_MATRIX_RCB2 (1 << 2) 62#define AT91_MATRIX_RCB2 (1 << 2)
@@ -64,7 +64,7 @@
64#define AT91_MATRIX_RCB4 (1 << 4) 64#define AT91_MATRIX_RCB4 (1 << 4)
65#define AT91_MATRIX_RCB5 (1 << 5) 65#define AT91_MATRIX_RCB5 (1 << 5)
66 66
67#define AT91_MATRIX_TCMR 0x114 /* TCM Configuration Register */ 67#define AT91_MATRIX_TCMR (AT91_MATRIX + 0x114) /* TCM Configuration Register */
68#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */ 68#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */
69#define AT91_MATRIX_ITCM_0 (0 << 0) 69#define AT91_MATRIX_ITCM_0 (0 << 0)
70#define AT91_MATRIX_ITCM_16 (5 << 0) 70#define AT91_MATRIX_ITCM_16 (5 << 0)
@@ -74,7 +74,7 @@
74#define AT91_MATRIX_DTCM_16 (5 << 4) 74#define AT91_MATRIX_DTCM_16 (5 << 4)
75#define AT91_MATRIX_DTCM_32 (6 << 4) 75#define AT91_MATRIX_DTCM_32 (6 << 4)
76 76
77#define AT91_MATRIX_EBICSA 0x120 /* EBI0 Chip Select Assignment Register */ 77#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x120) /* EBI0 Chip Select Assignment Register */
78#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */ 78#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */
79#define AT91_MATRIX_CS1A_SMC (0 << 1) 79#define AT91_MATRIX_CS1A_SMC (0 << 1)
80#define AT91_MATRIX_CS1A_SDRAMC (1 << 1) 80#define AT91_MATRIX_CS1A_SDRAMC (1 << 1)
diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5.h b/arch/arm/mach-at91/include/mach/at91sam9x5.h
deleted file mode 100644
index c75ee19b58d..00000000000
--- a/arch/arm/mach-at91/include/mach/at91sam9x5.h
+++ /dev/null
@@ -1,66 +0,0 @@
1/*
2 * Chip-specific header file for the AT91SAM9x5 family
3 *
4 * Copyright (C) 2009-2012 Atmel Corporation.
5 *
6 * Common definitions.
7 * Based on AT91SAM9x5 datasheet.
8 *
9 * Licensed under GPLv2 or later.
10 */
11
12#ifndef AT91SAM9X5_H
13#define AT91SAM9X5_H
14
15/*
16 * Peripheral identifiers/interrupts.
17 */
18#define AT91SAM9X5_ID_PIOAB 2 /* Parallel I/O Controller A and B */
19#define AT91SAM9X5_ID_PIOCD 3 /* Parallel I/O Controller C and D */
20#define AT91SAM9X5_ID_SMD 4 /* SMD Soft Modem (SMD) */
21#define AT91SAM9X5_ID_USART0 5 /* USART 0 */
22#define AT91SAM9X5_ID_USART1 6 /* USART 1 */
23#define AT91SAM9X5_ID_USART2 7 /* USART 2 */
24#define AT91SAM9X5_ID_USART3 8 /* USART 3 */
25#define AT91SAM9X5_ID_TWI0 9 /* Two-Wire Interface 0 */
26#define AT91SAM9X5_ID_TWI1 10 /* Two-Wire Interface 1 */
27#define AT91SAM9X5_ID_TWI2 11 /* Two-Wire Interface 2 */
28#define AT91SAM9X5_ID_MCI0 12 /* High Speed Multimedia Card Interface 0 */
29#define AT91SAM9X5_ID_SPI0 13 /* Serial Peripheral Interface 0 */
30#define AT91SAM9X5_ID_SPI1 14 /* Serial Peripheral Interface 1 */
31#define AT91SAM9X5_ID_UART0 15 /* UART 0 */
32#define AT91SAM9X5_ID_UART1 16 /* UART 1 */
33#define AT91SAM9X5_ID_TCB 17 /* Timer Counter 0, 1, 2, 3, 4 and 5 */
34#define AT91SAM9X5_ID_PWM 18 /* Pulse Width Modulation Controller */
35#define AT91SAM9X5_ID_ADC 19 /* ADC Controller */
36#define AT91SAM9X5_ID_DMA0 20 /* DMA Controller 0 */
37#define AT91SAM9X5_ID_DMA1 21 /* DMA Controller 1 */
38#define AT91SAM9X5_ID_UHPHS 22 /* USB Host High Speed */
39#define AT91SAM9X5_ID_UDPHS 23 /* USB Device High Speed */
40#define AT91SAM9X5_ID_EMAC0 24 /* Ethernet MAC0 */
41#define AT91SAM9X5_ID_LCDC 25 /* LCD Controller */
42#define AT91SAM9X5_ID_ISI 25 /* Image Sensor Interface */
43#define AT91SAM9X5_ID_MCI1 26 /* High Speed Multimedia Card Interface 1 */
44#define AT91SAM9X5_ID_EMAC1 27 /* Ethernet MAC1 */
45#define AT91SAM9X5_ID_SSC 28 /* Synchronous Serial Controller */
46#define AT91SAM9X5_ID_CAN0 29 /* CAN Controller 0 */
47#define AT91SAM9X5_ID_CAN1 30 /* CAN Controller 1 */
48#define AT91SAM9X5_ID_IRQ0 31 /* Advanced Interrupt Controller */
49
50/*
51 * User Peripheral physical base addresses.
52 */
53#define AT91SAM9X5_BASE_USART0 0xf801c000
54#define AT91SAM9X5_BASE_USART1 0xf8020000
55#define AT91SAM9X5_BASE_USART2 0xf8024000
56
57/*
58 * Internal Memory.
59 */
60#define AT91SAM9X5_SRAM_BASE 0x00300000 /* Internal SRAM base address */
61#define AT91SAM9X5_SRAM_SIZE SZ_32K /* Internal SRAM size (32Kb) */
62
63#define AT91SAM9X5_ROM_BASE 0x00400000 /* Internal ROM base address */
64#define AT91SAM9X5_ROM_SIZE SZ_64K /* Internal ROM size (64Kb) */
65
66#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h
deleted file mode 100644
index a606d396647..00000000000
--- a/arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * Matrix-centric header file for the AT91SAM9x5 family
3 *
4 * Copyright (C) 2009-2012 Atmel Corporation.
5 *
6 * Only EBI related registers.
7 * Write Protect register definitions may be useful.
8 *
9 * Licensed under GPLv2 or later.
10 */
11
12#ifndef AT91SAM9X5_MATRIX_H
13#define AT91SAM9X5_MATRIX_H
14
15#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x120) /* EBI Chip Select Assignment Register */
16#define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */
17#define AT91_MATRIX_EBI_CS1A_SMC (0 << 1)
18#define AT91_MATRIX_EBI_CS1A_SDRAMC (1 << 1)
19#define AT91_MATRIX_EBI_CS3A (1 << 3) /* Chip Select 3 Assignment */
20#define AT91_MATRIX_EBI_CS3A_SMC (0 << 3)
21#define AT91_MATRIX_EBI_CS3A_SMC_NANDFLASH (1 << 3)
22#define AT91_MATRIX_EBI_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */
23#define AT91_MATRIX_EBI_DBPU_ON (0 << 8)
24#define AT91_MATRIX_EBI_DBPU_OFF (1 << 8)
25#define AT91_MATRIX_EBI_VDDIOMSEL (1 << 16) /* Memory voltage selection */
26#define AT91_MATRIX_EBI_VDDIOMSEL_1_8V (0 << 16)
27#define AT91_MATRIX_EBI_VDDIOMSEL_3_3V (1 << 16)
28#define AT91_MATRIX_EBI_EBI_IOSR (1 << 17) /* EBI I/O slew rate selection */
29#define AT91_MATRIX_EBI_EBI_IOSR_REDUCED (0 << 17)
30#define AT91_MATRIX_EBI_EBI_IOSR_NORMAL (1 << 17)
31#define AT91_MATRIX_EBI_DDR_IOSR (1 << 18) /* DDR2 dedicated port I/O slew rate selection */
32#define AT91_MATRIX_EBI_DDR_IOSR_REDUCED (0 << 18)
33#define AT91_MATRIX_EBI_DDR_IOSR_NORMAL (1 << 18)
34#define AT91_MATRIX_NFD0_SELECT (1 << 24) /* NAND Flash Data Bus Selection */
35#define AT91_MATRIX_NFD0_ON_D0 (0 << 24)
36#define AT91_MATRIX_NFD0_ON_D16 (1 << 24)
37#define AT91_MATRIX_DDR_MP_EN (1 << 25) /* DDR Multi-port Enable */
38#define AT91_MATRIX_MP_OFF (0 << 25)
39#define AT91_MATRIX_MP_ON (1 << 25)
40
41#define AT91_MATRIX_WPMR (AT91_MATRIX + 0x1E4) /* Write Protect Mode Register */
42#define AT91_MATRIX_WPMR_WPEN (1 << 0) /* Write Protect ENable */
43#define AT91_MATRIX_WPMR_WP_WPDIS (0 << 0)
44#define AT91_MATRIX_WPMR_WP_WPEN (1 << 0)
45#define AT91_MATRIX_WPMR_WPKEY (0xFFFFFF << 8) /* Write Protect KEY */
46
47#define AT91_MATRIX_WPSR (AT91_MATRIX + 0x1E8) /* Write Protect Status Register */
48#define AT91_MATRIX_WPSR_WPVS (1 << 0) /* Write Protect Violation Status */
49#define AT91_MATRIX_WPSR_NO_WPV (0 << 0)
50#define AT91_MATRIX_WPSR_WPV (1 << 0)
51#define AT91_MATRIX_WPSR_WPVSRC (0xFFFF << 8) /* Write Protect Violation Source */
52
53#endif
diff --git a/arch/arm/mach-at91/include/mach/at91x40.h b/arch/arm/mach-at91/include/mach/at91x40.h
index 90680217064..a152ff87e68 100644
--- a/arch/arm/mach-at91/include/mach/at91x40.h
+++ b/arch/arm/mach-at91/include/mach/at91x40.h
@@ -28,18 +28,19 @@
28#define AT91X40_ID_IRQ2 18 /* External IRQ 2 */ 28#define AT91X40_ID_IRQ2 18 /* External IRQ 2 */
29 29
30/* 30/*
31 * System Peripherals 31 * System Peripherals (offset from AT91_BASE_SYS)
32 */ 32 */
33#define AT91_BASE_SYS 0xffc00000 33#define AT91_BASE_SYS 0xffc00000
34 34
35#define AT91_EBI 0xffe00000 /* External Bus Interface */ 35#define AT91_EBI (0xffe00000 - AT91_BASE_SYS) /* External Bus Interface */
36#define AT91_SF 0xfff00000 /* Special Function */ 36#define AT91_SF (0xfff00000 - AT91_BASE_SYS) /* Special Function */
37#define AT91_USART1 0xfffcc000 /* USART 1 */ 37#define AT91_USART1 (0xfffcc000 - AT91_BASE_SYS) /* USART 1 */
38#define AT91_USART0 0xfffd0000 /* USART 0 */ 38#define AT91_USART0 (0xfffd0000 - AT91_BASE_SYS) /* USART 0 */
39#define AT91_TC 0xfffe0000 /* Timer Counter */ 39#define AT91_TC (0xfffe0000 - AT91_BASE_SYS) /* Timer Counter */
40#define AT91_PIOA 0xffff0000 /* PIO Controller A */ 40#define AT91_PIOA (0xffff0000 - AT91_BASE_SYS) /* PIO Controller A */
41#define AT91_PS 0xffff4000 /* Power Save */ 41#define AT91_PS (0xffff4000 - AT91_BASE_SYS) /* Power Save */
42#define AT91_WD 0xffff8000 /* Watchdog Timer */ 42#define AT91_WD (0xffff8000 - AT91_BASE_SYS) /* Watchdog Timer */
43#define AT91_AIC (0xfffff000 - AT91_BASE_SYS) /* Advanced Interrupt Controller */
43 44
44/* 45/*
45 * The AT91x40 series doesn't have a debug unit like the other AT91 parts. 46 * The AT91x40 series doesn't have a debug unit like the other AT91 parts.
diff --git a/arch/arm/mach-at91/include/mach/atmel-mci.h b/arch/arm/mach-at91/include/mach/atmel-mci.h
index 3069e413557..998cb0c0713 100644
--- a/arch/arm/mach-at91/include/mach/atmel-mci.h
+++ b/arch/arm/mach-at91/include/mach/atmel-mci.h
@@ -1,7 +1,7 @@
1#ifndef __MACH_ATMEL_MCI_H 1#ifndef __MACH_ATMEL_MCI_H
2#define __MACH_ATMEL_MCI_H 2#define __MACH_ATMEL_MCI_H
3 3
4#include <linux/platform_data/dma-atmel.h> 4#include <mach/at_hdmac.h>
5 5
6/** 6/**
7 * struct mci_dma_data - DMA data for MCI interface 7 * struct mci_dma_data - DMA data for MCI interface
@@ -14,4 +14,11 @@ struct mci_dma_data {
14#define slave_data_ptr(s) (&(s)->sdata) 14#define slave_data_ptr(s) (&(s)->sdata)
15#define find_slave_dev(s) ((s)->sdata.dma_dev) 15#define find_slave_dev(s) ((s)->sdata.dma_dev)
16 16
17#define setup_dma_addr(s, t, r) do { \
18 if (s) { \
19 (s)->sdata.tx_reg = (t); \
20 (s)->sdata.rx_reg = (r); \
21 } \
22} while (0)
23
17#endif /* __MACH_ATMEL_MCI_H */ 24#endif /* __MACH_ATMEL_MCI_H */
diff --git a/arch/arm/mach-at91/include/mach/cpu.h b/arch/arm/mach-at91/include/mach/cpu.h
index b6504c19d55..f6ce936dba2 100644
--- a/arch/arm/mach-at91/include/mach/cpu.h
+++ b/arch/arm/mach-at91/include/mach/cpu.h
@@ -25,7 +25,7 @@
25#define ARCH_ID_AT91SAM9G45MRL 0x819b05a2 /* aka 9G45-ES2 & non ES lots */ 25#define ARCH_ID_AT91SAM9G45MRL 0x819b05a2 /* aka 9G45-ES2 & non ES lots */
26#define ARCH_ID_AT91SAM9G45ES 0x819b05a1 /* 9G45-ES (Engineering Sample) */ 26#define ARCH_ID_AT91SAM9G45ES 0x819b05a1 /* 9G45-ES (Engineering Sample) */
27#define ARCH_ID_AT91SAM9X5 0x819a05a0 27#define ARCH_ID_AT91SAM9X5 0x819a05a0
28#define ARCH_ID_AT91SAM9N12 0x819a07a0 28#define ARCH_ID_AT91CAP9 0x039A03A0
29 29
30#define ARCH_ID_AT91SAM9XE128 0x329973a0 30#define ARCH_ID_AT91SAM9XE128 0x329973a0
31#define ARCH_ID_AT91SAM9XE256 0x329a93a0 31#define ARCH_ID_AT91SAM9XE256 0x329a93a0
@@ -51,15 +51,21 @@
51#define ARCH_FAMILY_AT91SAM9 0x01900000 51#define ARCH_FAMILY_AT91SAM9 0x01900000
52#define ARCH_FAMILY_AT91SAM9XE 0x02900000 52#define ARCH_FAMILY_AT91SAM9XE 0x02900000
53 53
54/* PMC revision */
55#define ARCH_REVISION_CAP9_B 0x399
56#define ARCH_REVISION_CAP9_C 0x601
57
54/* RM9200 type */ 58/* RM9200 type */
55#define ARCH_REVISON_9200_BGA (0 << 0) 59#define ARCH_REVISON_9200_BGA (0 << 0)
56#define ARCH_REVISON_9200_PQFP (1 << 0) 60#define ARCH_REVISON_9200_PQFP (1 << 0)
57 61
58#ifndef __ASSEMBLY__
59enum at91_soc_type { 62enum at91_soc_type {
60 /* 920T */ 63 /* 920T */
61 AT91_SOC_RM9200, 64 AT91_SOC_RM9200,
62 65
66 /* CAP */
67 AT91_SOC_CAP9,
68
63 /* SAM92xx */ 69 /* SAM92xx */
64 AT91_SOC_SAM9260, AT91_SOC_SAM9261, AT91_SOC_SAM9263, 70 AT91_SOC_SAM9260, AT91_SOC_SAM9261, AT91_SOC_SAM9263,
65 71
@@ -72,9 +78,6 @@ enum at91_soc_type {
72 /* SAM9X5 */ 78 /* SAM9X5 */
73 AT91_SOC_SAM9X5, 79 AT91_SOC_SAM9X5,
74 80
75 /* SAM9N12 */
76 AT91_SOC_SAM9N12,
77
78 /* Unknown type */ 81 /* Unknown type */
79 AT91_SOC_NONE 82 AT91_SOC_NONE
80}; 83};
@@ -83,6 +86,9 @@ enum at91_soc_subtype {
83 /* RM9200 */ 86 /* RM9200 */
84 AT91_SOC_RM9200_BGA, AT91_SOC_RM9200_PQFP, 87 AT91_SOC_RM9200_BGA, AT91_SOC_RM9200_PQFP,
85 88
89 /* CAP9 */
90 AT91_SOC_CAP9_REV_B, AT91_SOC_CAP9_REV_C,
91
86 /* SAM9260 */ 92 /* SAM9260 */
87 AT91_SOC_SAM9XE, 93 AT91_SOC_SAM9XE,
88 94
@@ -111,7 +117,7 @@ static inline int at91_soc_is_detected(void)
111 return at91_soc_initdata.type != AT91_SOC_NONE; 117 return at91_soc_initdata.type != AT91_SOC_NONE;
112} 118}
113 119
114#ifdef CONFIG_SOC_AT91RM9200 120#ifdef CONFIG_ARCH_AT91RM9200
115#define cpu_is_at91rm9200() (at91_soc_initdata.type == AT91_SOC_RM9200) 121#define cpu_is_at91rm9200() (at91_soc_initdata.type == AT91_SOC_RM9200)
116#define cpu_is_at91rm9200_bga() (at91_soc_initdata.subtype == AT91_SOC_RM9200_BGA) 122#define cpu_is_at91rm9200_bga() (at91_soc_initdata.subtype == AT91_SOC_RM9200_BGA)
117#define cpu_is_at91rm9200_pqfp() (at91_soc_initdata.subtype == AT91_SOC_RM9200_PQFP) 123#define cpu_is_at91rm9200_pqfp() (at91_soc_initdata.subtype == AT91_SOC_RM9200_PQFP)
@@ -121,37 +127,45 @@ static inline int at91_soc_is_detected(void)
121#define cpu_is_at91rm9200_pqfp() (0) 127#define cpu_is_at91rm9200_pqfp() (0)
122#endif 128#endif
123 129
124#ifdef CONFIG_SOC_AT91SAM9260 130#ifdef CONFIG_ARCH_AT91SAM9260
125#define cpu_is_at91sam9xe() (at91_soc_initdata.subtype == AT91_SOC_SAM9XE) 131#define cpu_is_at91sam9xe() (at91_soc_initdata.subtype == AT91_SOC_SAM9XE)
126#define cpu_is_at91sam9260() (at91_soc_initdata.type == AT91_SOC_SAM9260) 132#define cpu_is_at91sam9260() (at91_soc_initdata.type == AT91_SOC_SAM9260)
127#define cpu_is_at91sam9g20() (at91_soc_initdata.type == AT91_SOC_SAM9G20)
128#else 133#else
129#define cpu_is_at91sam9xe() (0) 134#define cpu_is_at91sam9xe() (0)
130#define cpu_is_at91sam9260() (0) 135#define cpu_is_at91sam9260() (0)
136#endif
137
138#ifdef CONFIG_ARCH_AT91SAM9G20
139#define cpu_is_at91sam9g20() (at91_soc_initdata.type == AT91_SOC_SAM9G20)
140#else
131#define cpu_is_at91sam9g20() (0) 141#define cpu_is_at91sam9g20() (0)
132#endif 142#endif
133 143
134#ifdef CONFIG_SOC_AT91SAM9261 144#ifdef CONFIG_ARCH_AT91SAM9261
135#define cpu_is_at91sam9261() (at91_soc_initdata.type == AT91_SOC_SAM9261) 145#define cpu_is_at91sam9261() (at91_soc_initdata.type == AT91_SOC_SAM9261)
136#define cpu_is_at91sam9g10() (at91_soc_initdata.type == AT91_SOC_SAM9G10)
137#else 146#else
138#define cpu_is_at91sam9261() (0) 147#define cpu_is_at91sam9261() (0)
148#endif
149
150#ifdef CONFIG_ARCH_AT91SAM9G10
151#define cpu_is_at91sam9g10() (at91_soc_initdata.type == AT91_SOC_SAM9G10)
152#else
139#define cpu_is_at91sam9g10() (0) 153#define cpu_is_at91sam9g10() (0)
140#endif 154#endif
141 155
142#ifdef CONFIG_SOC_AT91SAM9263 156#ifdef CONFIG_ARCH_AT91SAM9263
143#define cpu_is_at91sam9263() (at91_soc_initdata.type == AT91_SOC_SAM9263) 157#define cpu_is_at91sam9263() (at91_soc_initdata.type == AT91_SOC_SAM9263)
144#else 158#else
145#define cpu_is_at91sam9263() (0) 159#define cpu_is_at91sam9263() (0)
146#endif 160#endif
147 161
148#ifdef CONFIG_SOC_AT91SAM9RL 162#ifdef CONFIG_ARCH_AT91SAM9RL
149#define cpu_is_at91sam9rl() (at91_soc_initdata.type == AT91_SOC_SAM9RL) 163#define cpu_is_at91sam9rl() (at91_soc_initdata.type == AT91_SOC_SAM9RL)
150#else 164#else
151#define cpu_is_at91sam9rl() (0) 165#define cpu_is_at91sam9rl() (0)
152#endif 166#endif
153 167
154#ifdef CONFIG_SOC_AT91SAM9G45 168#ifdef CONFIG_ARCH_AT91SAM9G45
155#define cpu_is_at91sam9g45() (at91_soc_initdata.type == AT91_SOC_SAM9G45) 169#define cpu_is_at91sam9g45() (at91_soc_initdata.type == AT91_SOC_SAM9G45)
156#define cpu_is_at91sam9g45es() (at91_soc_initdata.subtype == AT91_SOC_SAM9G45ES) 170#define cpu_is_at91sam9g45es() (at91_soc_initdata.subtype == AT91_SOC_SAM9G45ES)
157#define cpu_is_at91sam9m10() (at91_soc_initdata.subtype == AT91_SOC_SAM9M10) 171#define cpu_is_at91sam9m10() (at91_soc_initdata.subtype == AT91_SOC_SAM9M10)
@@ -165,7 +179,7 @@ static inline int at91_soc_is_detected(void)
165#define cpu_is_at91sam9m11() (0) 179#define cpu_is_at91sam9m11() (0)
166#endif 180#endif
167 181
168#ifdef CONFIG_SOC_AT91SAM9X5 182#ifdef CONFIG_ARCH_AT91SAM9X5
169#define cpu_is_at91sam9x5() (at91_soc_initdata.type == AT91_SOC_SAM9X5) 183#define cpu_is_at91sam9x5() (at91_soc_initdata.type == AT91_SOC_SAM9X5)
170#define cpu_is_at91sam9g15() (at91_soc_initdata.subtype == AT91_SOC_SAM9G15) 184#define cpu_is_at91sam9g15() (at91_soc_initdata.subtype == AT91_SOC_SAM9G15)
171#define cpu_is_at91sam9g35() (at91_soc_initdata.subtype == AT91_SOC_SAM9G35) 185#define cpu_is_at91sam9g35() (at91_soc_initdata.subtype == AT91_SOC_SAM9G35)
@@ -181,10 +195,14 @@ static inline int at91_soc_is_detected(void)
181#define cpu_is_at91sam9x25() (0) 195#define cpu_is_at91sam9x25() (0)
182#endif 196#endif
183 197
184#ifdef CONFIG_SOC_AT91SAM9N12 198#ifdef CONFIG_ARCH_AT91CAP9
185#define cpu_is_at91sam9n12() (at91_soc_initdata.type == AT91_SOC_SAM9N12) 199#define cpu_is_at91cap9() (at91_soc_initdata.type == AT91_SOC_CAP9)
200#define cpu_is_at91cap9_revB() (at91_soc_initdata.subtype == AT91_SOC_CAP9_REV_B)
201#define cpu_is_at91cap9_revC() (at91_soc_initdata.subtype == AT91_SOC_CAP9_REV_C)
186#else 202#else
187#define cpu_is_at91sam9n12() (0) 203#define cpu_is_at91cap9() (0)
204#define cpu_is_at91cap9_revB() (0)
205#define cpu_is_at91cap9_revC() (0)
188#endif 206#endif
189 207
190/* 208/*
@@ -192,6 +210,5 @@ static inline int at91_soc_is_detected(void)
192 * definitions may reduce clutter in common drivers. 210 * definitions may reduce clutter in common drivers.
193 */ 211 */
194#define cpu_is_at32ap7000() (0) 212#define cpu_is_at32ap7000() (0)
195#endif /* __ASSEMBLY__ */
196 213
197#endif /* __MACH_CPU_H__ */ 214#endif /* __MACH_CPU_H__ */
diff --git a/arch/arm/mach-at91/include/mach/debug-macro.S b/arch/arm/mach-at91/include/mach/debug-macro.S
index c6bb9e2d9ba..bc1e0b2e2f4 100644
--- a/arch/arm/mach-at91/include/mach/debug-macro.S
+++ b/arch/arm/mach-at91/include/mach/debug-macro.S
@@ -14,15 +14,9 @@
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15#include <mach/at91_dbgu.h> 15#include <mach/at91_dbgu.h>
16 16
17#if defined(CONFIG_AT91_DEBUG_LL_DBGU0) 17 .macro addruart, rp, rv
18#define AT91_DBGU AT91_BASE_DBGU0 18 ldr \rp, =(AT91_BASE_SYS + AT91_DBGU) @ System peripherals (phys address)
19#else 19 ldr \rv, =(AT91_VA_BASE_SYS + AT91_DBGU) @ System peripherals (virt address)
20#define AT91_DBGU AT91_BASE_DBGU1
21#endif
22
23 .macro addruart, rp, rv, tmp
24 ldr \rp, =AT91_DBGU @ System peripherals (phys address)
25 ldr \rv, =AT91_IO_P2V(AT91_DBGU) @ System peripherals (virt address)
26 .endm 20 .endm
27 21
28 .macro senduart,rd,rx 22 .macro senduart,rd,rx
diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h
index eed465ab0dd..056dc6674b6 100644
--- a/arch/arm/mach-at91/include/mach/gpio.h
+++ b/arch/arm/mach-at91/include/mach/gpio.h
@@ -16,190 +16,187 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <asm/irq.h> 17#include <asm/irq.h>
18 18
19#define PIN_BASE NR_AIC_IRQS
20
19#define MAX_GPIO_BANKS 5 21#define MAX_GPIO_BANKS 5
20#define NR_BUILTIN_GPIO (MAX_GPIO_BANKS * 32) 22#define NR_BUILTIN_GPIO (PIN_BASE + (MAX_GPIO_BANKS * 32))
21 23
22/* these pin numbers double as IRQ numbers, like AT91xxx_ID_* values */ 24/* these pin numbers double as IRQ numbers, like AT91xxx_ID_* values */
23 25
24#define AT91_PIN_PA0 (0x00 + 0) 26#define AT91_PIN_PA0 (PIN_BASE + 0x00 + 0)
25#define AT91_PIN_PA1 (0x00 + 1) 27#define AT91_PIN_PA1 (PIN_BASE + 0x00 + 1)
26#define AT91_PIN_PA2 (0x00 + 2) 28#define AT91_PIN_PA2 (PIN_BASE + 0x00 + 2)
27#define AT91_PIN_PA3 (0x00 + 3) 29#define AT91_PIN_PA3 (PIN_BASE + 0x00 + 3)
28#define AT91_PIN_PA4 (0x00 + 4) 30#define AT91_PIN_PA4 (PIN_BASE + 0x00 + 4)
29#define AT91_PIN_PA5 (0x00 + 5) 31#define AT91_PIN_PA5 (PIN_BASE + 0x00 + 5)
30#define AT91_PIN_PA6 (0x00 + 6) 32#define AT91_PIN_PA6 (PIN_BASE + 0x00 + 6)
31#define AT91_PIN_PA7 (0x00 + 7) 33#define AT91_PIN_PA7 (PIN_BASE + 0x00 + 7)
32#define AT91_PIN_PA8 (0x00 + 8) 34#define AT91_PIN_PA8 (PIN_BASE + 0x00 + 8)
33#define AT91_PIN_PA9 (0x00 + 9) 35#define AT91_PIN_PA9 (PIN_BASE + 0x00 + 9)
34#define AT91_PIN_PA10 (0x00 + 10) 36#define AT91_PIN_PA10 (PIN_BASE + 0x00 + 10)
35#define AT91_PIN_PA11 (0x00 + 11) 37#define AT91_PIN_PA11 (PIN_BASE + 0x00 + 11)
36#define AT91_PIN_PA12 (0x00 + 12) 38#define AT91_PIN_PA12 (PIN_BASE + 0x00 + 12)
37#define AT91_PIN_PA13 (0x00 + 13) 39#define AT91_PIN_PA13 (PIN_BASE + 0x00 + 13)
38#define AT91_PIN_PA14 (0x00 + 14) 40#define AT91_PIN_PA14 (PIN_BASE + 0x00 + 14)
39#define AT91_PIN_PA15 (0x00 + 15) 41#define AT91_PIN_PA15 (PIN_BASE + 0x00 + 15)
40#define AT91_PIN_PA16 (0x00 + 16) 42#define AT91_PIN_PA16 (PIN_BASE + 0x00 + 16)
41#define AT91_PIN_PA17 (0x00 + 17) 43#define AT91_PIN_PA17 (PIN_BASE + 0x00 + 17)
42#define AT91_PIN_PA18 (0x00 + 18) 44#define AT91_PIN_PA18 (PIN_BASE + 0x00 + 18)
43#define AT91_PIN_PA19 (0x00 + 19) 45#define AT91_PIN_PA19 (PIN_BASE + 0x00 + 19)
44#define AT91_PIN_PA20 (0x00 + 20) 46#define AT91_PIN_PA20 (PIN_BASE + 0x00 + 20)
45#define AT91_PIN_PA21 (0x00 + 21) 47#define AT91_PIN_PA21 (PIN_BASE + 0x00 + 21)
46#define AT91_PIN_PA22 (0x00 + 22) 48#define AT91_PIN_PA22 (PIN_BASE + 0x00 + 22)
47#define AT91_PIN_PA23 (0x00 + 23) 49#define AT91_PIN_PA23 (PIN_BASE + 0x00 + 23)
48#define AT91_PIN_PA24 (0x00 + 24) 50#define AT91_PIN_PA24 (PIN_BASE + 0x00 + 24)
49#define AT91_PIN_PA25 (0x00 + 25) 51#define AT91_PIN_PA25 (PIN_BASE + 0x00 + 25)
50#define AT91_PIN_PA26 (0x00 + 26) 52#define AT91_PIN_PA26 (PIN_BASE + 0x00 + 26)
51#define AT91_PIN_PA27 (0x00 + 27) 53#define AT91_PIN_PA27 (PIN_BASE + 0x00 + 27)
52#define AT91_PIN_PA28 (0x00 + 28) 54#define AT91_PIN_PA28 (PIN_BASE + 0x00 + 28)
53#define AT91_PIN_PA29 (0x00 + 29) 55#define AT91_PIN_PA29 (PIN_BASE + 0x00 + 29)
54#define AT91_PIN_PA30 (0x00 + 30) 56#define AT91_PIN_PA30 (PIN_BASE + 0x00 + 30)
55#define AT91_PIN_PA31 (0x00 + 31) 57#define AT91_PIN_PA31 (PIN_BASE + 0x00 + 31)
56 58
57#define AT91_PIN_PB0 (0x20 + 0) 59#define AT91_PIN_PB0 (PIN_BASE + 0x20 + 0)
58#define AT91_PIN_PB1 (0x20 + 1) 60#define AT91_PIN_PB1 (PIN_BASE + 0x20 + 1)
59#define AT91_PIN_PB2 (0x20 + 2) 61#define AT91_PIN_PB2 (PIN_BASE + 0x20 + 2)
60#define AT91_PIN_PB3 (0x20 + 3) 62#define AT91_PIN_PB3 (PIN_BASE + 0x20 + 3)
61#define AT91_PIN_PB4 (0x20 + 4) 63#define AT91_PIN_PB4 (PIN_BASE + 0x20 + 4)
62#define AT91_PIN_PB5 (0x20 + 5) 64#define AT91_PIN_PB5 (PIN_BASE + 0x20 + 5)
63#define AT91_PIN_PB6 (0x20 + 6) 65#define AT91_PIN_PB6 (PIN_BASE + 0x20 + 6)
64#define AT91_PIN_PB7 (0x20 + 7) 66#define AT91_PIN_PB7 (PIN_BASE + 0x20 + 7)
65#define AT91_PIN_PB8 (0x20 + 8) 67#define AT91_PIN_PB8 (PIN_BASE + 0x20 + 8)
66#define AT91_PIN_PB9 (0x20 + 9) 68#define AT91_PIN_PB9 (PIN_BASE + 0x20 + 9)
67#define AT91_PIN_PB10 (0x20 + 10) 69#define AT91_PIN_PB10 (PIN_BASE + 0x20 + 10)
68#define AT91_PIN_PB11 (0x20 + 11) 70#define AT91_PIN_PB11 (PIN_BASE + 0x20 + 11)
69#define AT91_PIN_PB12 (0x20 + 12) 71#define AT91_PIN_PB12 (PIN_BASE + 0x20 + 12)
70#define AT91_PIN_PB13 (0x20 + 13) 72#define AT91_PIN_PB13 (PIN_BASE + 0x20 + 13)
71#define AT91_PIN_PB14 (0x20 + 14) 73#define AT91_PIN_PB14 (PIN_BASE + 0x20 + 14)
72#define AT91_PIN_PB15 (0x20 + 15) 74#define AT91_PIN_PB15 (PIN_BASE + 0x20 + 15)
73#define AT91_PIN_PB16 (0x20 + 16) 75#define AT91_PIN_PB16 (PIN_BASE + 0x20 + 16)
74#define AT91_PIN_PB17 (0x20 + 17) 76#define AT91_PIN_PB17 (PIN_BASE + 0x20 + 17)
75#define AT91_PIN_PB18 (0x20 + 18) 77#define AT91_PIN_PB18 (PIN_BASE + 0x20 + 18)
76#define AT91_PIN_PB19 (0x20 + 19) 78#define AT91_PIN_PB19 (PIN_BASE + 0x20 + 19)
77#define AT91_PIN_PB20 (0x20 + 20) 79#define AT91_PIN_PB20 (PIN_BASE + 0x20 + 20)
78#define AT91_PIN_PB21 (0x20 + 21) 80#define AT91_PIN_PB21 (PIN_BASE + 0x20 + 21)
79#define AT91_PIN_PB22 (0x20 + 22) 81#define AT91_PIN_PB22 (PIN_BASE + 0x20 + 22)
80#define AT91_PIN_PB23 (0x20 + 23) 82#define AT91_PIN_PB23 (PIN_BASE + 0x20 + 23)
81#define AT91_PIN_PB24 (0x20 + 24) 83#define AT91_PIN_PB24 (PIN_BASE + 0x20 + 24)
82#define AT91_PIN_PB25 (0x20 + 25) 84#define AT91_PIN_PB25 (PIN_BASE + 0x20 + 25)
83#define AT91_PIN_PB26 (0x20 + 26) 85#define AT91_PIN_PB26 (PIN_BASE + 0x20 + 26)
84#define AT91_PIN_PB27 (0x20 + 27) 86#define AT91_PIN_PB27 (PIN_BASE + 0x20 + 27)
85#define AT91_PIN_PB28 (0x20 + 28) 87#define AT91_PIN_PB28 (PIN_BASE + 0x20 + 28)
86#define AT91_PIN_PB29 (0x20 + 29) 88#define AT91_PIN_PB29 (PIN_BASE + 0x20 + 29)
87#define AT91_PIN_PB30 (0x20 + 30) 89#define AT91_PIN_PB30 (PIN_BASE + 0x20 + 30)
88#define AT91_PIN_PB31 (0x20 + 31) 90#define AT91_PIN_PB31 (PIN_BASE + 0x20 + 31)
89 91
90#define AT91_PIN_PC0 (0x40 + 0) 92#define AT91_PIN_PC0 (PIN_BASE + 0x40 + 0)
91#define AT91_PIN_PC1 (0x40 + 1) 93#define AT91_PIN_PC1 (PIN_BASE + 0x40 + 1)
92#define AT91_PIN_PC2 (0x40 + 2) 94#define AT91_PIN_PC2 (PIN_BASE + 0x40 + 2)
93#define AT91_PIN_PC3 (0x40 + 3) 95#define AT91_PIN_PC3 (PIN_BASE + 0x40 + 3)
94#define AT91_PIN_PC4 (0x40 + 4) 96#define AT91_PIN_PC4 (PIN_BASE + 0x40 + 4)
95#define AT91_PIN_PC5 (0x40 + 5) 97#define AT91_PIN_PC5 (PIN_BASE + 0x40 + 5)
96#define AT91_PIN_PC6 (0x40 + 6) 98#define AT91_PIN_PC6 (PIN_BASE + 0x40 + 6)
97#define AT91_PIN_PC7 (0x40 + 7) 99#define AT91_PIN_PC7 (PIN_BASE + 0x40 + 7)
98#define AT91_PIN_PC8 (0x40 + 8) 100#define AT91_PIN_PC8 (PIN_BASE + 0x40 + 8)
99#define AT91_PIN_PC9 (0x40 + 9) 101#define AT91_PIN_PC9 (PIN_BASE + 0x40 + 9)
100#define AT91_PIN_PC10 (0x40 + 10) 102#define AT91_PIN_PC10 (PIN_BASE + 0x40 + 10)
101#define AT91_PIN_PC11 (0x40 + 11) 103#define AT91_PIN_PC11 (PIN_BASE + 0x40 + 11)
102#define AT91_PIN_PC12 (0x40 + 12) 104#define AT91_PIN_PC12 (PIN_BASE + 0x40 + 12)
103#define AT91_PIN_PC13 (0x40 + 13) 105#define AT91_PIN_PC13 (PIN_BASE + 0x40 + 13)
104#define AT91_PIN_PC14 (0x40 + 14) 106#define AT91_PIN_PC14 (PIN_BASE + 0x40 + 14)
105#define AT91_PIN_PC15 (0x40 + 15) 107#define AT91_PIN_PC15 (PIN_BASE + 0x40 + 15)
106#define AT91_PIN_PC16 (0x40 + 16) 108#define AT91_PIN_PC16 (PIN_BASE + 0x40 + 16)
107#define AT91_PIN_PC17 (0x40 + 17) 109#define AT91_PIN_PC17 (PIN_BASE + 0x40 + 17)
108#define AT91_PIN_PC18 (0x40 + 18) 110#define AT91_PIN_PC18 (PIN_BASE + 0x40 + 18)
109#define AT91_PIN_PC19 (0x40 + 19) 111#define AT91_PIN_PC19 (PIN_BASE + 0x40 + 19)
110#define AT91_PIN_PC20 (0x40 + 20) 112#define AT91_PIN_PC20 (PIN_BASE + 0x40 + 20)
111#define AT91_PIN_PC21 (0x40 + 21) 113#define AT91_PIN_PC21 (PIN_BASE + 0x40 + 21)
112#define AT91_PIN_PC22 (0x40 + 22) 114#define AT91_PIN_PC22 (PIN_BASE + 0x40 + 22)
113#define AT91_PIN_PC23 (0x40 + 23) 115#define AT91_PIN_PC23 (PIN_BASE + 0x40 + 23)
114#define AT91_PIN_PC24 (0x40 + 24) 116#define AT91_PIN_PC24 (PIN_BASE + 0x40 + 24)
115#define AT91_PIN_PC25 (0x40 + 25) 117#define AT91_PIN_PC25 (PIN_BASE + 0x40 + 25)
116#define AT91_PIN_PC26 (0x40 + 26) 118#define AT91_PIN_PC26 (PIN_BASE + 0x40 + 26)
117#define AT91_PIN_PC27 (0x40 + 27) 119#define AT91_PIN_PC27 (PIN_BASE + 0x40 + 27)
118#define AT91_PIN_PC28 (0x40 + 28) 120#define AT91_PIN_PC28 (PIN_BASE + 0x40 + 28)
119#define AT91_PIN_PC29 (0x40 + 29) 121#define AT91_PIN_PC29 (PIN_BASE + 0x40 + 29)
120#define AT91_PIN_PC30 (0x40 + 30) 122#define AT91_PIN_PC30 (PIN_BASE + 0x40 + 30)
121#define AT91_PIN_PC31 (0x40 + 31) 123#define AT91_PIN_PC31 (PIN_BASE + 0x40 + 31)
122 124
123#define AT91_PIN_PD0 (0x60 + 0) 125#define AT91_PIN_PD0 (PIN_BASE + 0x60 + 0)
124#define AT91_PIN_PD1 (0x60 + 1) 126#define AT91_PIN_PD1 (PIN_BASE + 0x60 + 1)
125#define AT91_PIN_PD2 (0x60 + 2) 127#define AT91_PIN_PD2 (PIN_BASE + 0x60 + 2)
126#define AT91_PIN_PD3 (0x60 + 3) 128#define AT91_PIN_PD3 (PIN_BASE + 0x60 + 3)
127#define AT91_PIN_PD4 (0x60 + 4) 129#define AT91_PIN_PD4 (PIN_BASE + 0x60 + 4)
128#define AT91_PIN_PD5 (0x60 + 5) 130#define AT91_PIN_PD5 (PIN_BASE + 0x60 + 5)
129#define AT91_PIN_PD6 (0x60 + 6) 131#define AT91_PIN_PD6 (PIN_BASE + 0x60 + 6)
130#define AT91_PIN_PD7 (0x60 + 7) 132#define AT91_PIN_PD7 (PIN_BASE + 0x60 + 7)
131#define AT91_PIN_PD8 (0x60 + 8) 133#define AT91_PIN_PD8 (PIN_BASE + 0x60 + 8)
132#define AT91_PIN_PD9 (0x60 + 9) 134#define AT91_PIN_PD9 (PIN_BASE + 0x60 + 9)
133#define AT91_PIN_PD10 (0x60 + 10) 135#define AT91_PIN_PD10 (PIN_BASE + 0x60 + 10)
134#define AT91_PIN_PD11 (0x60 + 11) 136#define AT91_PIN_PD11 (PIN_BASE + 0x60 + 11)
135#define AT91_PIN_PD12 (0x60 + 12) 137#define AT91_PIN_PD12 (PIN_BASE + 0x60 + 12)
136#define AT91_PIN_PD13 (0x60 + 13) 138#define AT91_PIN_PD13 (PIN_BASE + 0x60 + 13)
137#define AT91_PIN_PD14 (0x60 + 14) 139#define AT91_PIN_PD14 (PIN_BASE + 0x60 + 14)
138#define AT91_PIN_PD15 (0x60 + 15) 140#define AT91_PIN_PD15 (PIN_BASE + 0x60 + 15)
139#define AT91_PIN_PD16 (0x60 + 16) 141#define AT91_PIN_PD16 (PIN_BASE + 0x60 + 16)
140#define AT91_PIN_PD17 (0x60 + 17) 142#define AT91_PIN_PD17 (PIN_BASE + 0x60 + 17)
141#define AT91_PIN_PD18 (0x60 + 18) 143#define AT91_PIN_PD18 (PIN_BASE + 0x60 + 18)
142#define AT91_PIN_PD19 (0x60 + 19) 144#define AT91_PIN_PD19 (PIN_BASE + 0x60 + 19)
143#define AT91_PIN_PD20 (0x60 + 20) 145#define AT91_PIN_PD20 (PIN_BASE + 0x60 + 20)
144#define AT91_PIN_PD21 (0x60 + 21) 146#define AT91_PIN_PD21 (PIN_BASE + 0x60 + 21)
145#define AT91_PIN_PD22 (0x60 + 22) 147#define AT91_PIN_PD22 (PIN_BASE + 0x60 + 22)
146#define AT91_PIN_PD23 (0x60 + 23) 148#define AT91_PIN_PD23 (PIN_BASE + 0x60 + 23)
147#define AT91_PIN_PD24 (0x60 + 24) 149#define AT91_PIN_PD24 (PIN_BASE + 0x60 + 24)
148#define AT91_PIN_PD25 (0x60 + 25) 150#define AT91_PIN_PD25 (PIN_BASE + 0x60 + 25)
149#define AT91_PIN_PD26 (0x60 + 26) 151#define AT91_PIN_PD26 (PIN_BASE + 0x60 + 26)
150#define AT91_PIN_PD27 (0x60 + 27) 152#define AT91_PIN_PD27 (PIN_BASE + 0x60 + 27)
151#define AT91_PIN_PD28 (0x60 + 28) 153#define AT91_PIN_PD28 (PIN_BASE + 0x60 + 28)
152#define AT91_PIN_PD29 (0x60 + 29) 154#define AT91_PIN_PD29 (PIN_BASE + 0x60 + 29)
153#define AT91_PIN_PD30 (0x60 + 30) 155#define AT91_PIN_PD30 (PIN_BASE + 0x60 + 30)
154#define AT91_PIN_PD31 (0x60 + 31) 156#define AT91_PIN_PD31 (PIN_BASE + 0x60 + 31)
155 157
156#define AT91_PIN_PE0 (0x80 + 0) 158#define AT91_PIN_PE0 (PIN_BASE + 0x80 + 0)
157#define AT91_PIN_PE1 (0x80 + 1) 159#define AT91_PIN_PE1 (PIN_BASE + 0x80 + 1)
158#define AT91_PIN_PE2 (0x80 + 2) 160#define AT91_PIN_PE2 (PIN_BASE + 0x80 + 2)
159#define AT91_PIN_PE3 (0x80 + 3) 161#define AT91_PIN_PE3 (PIN_BASE + 0x80 + 3)
160#define AT91_PIN_PE4 (0x80 + 4) 162#define AT91_PIN_PE4 (PIN_BASE + 0x80 + 4)
161#define AT91_PIN_PE5 (0x80 + 5) 163#define AT91_PIN_PE5 (PIN_BASE + 0x80 + 5)
162#define AT91_PIN_PE6 (0x80 + 6) 164#define AT91_PIN_PE6 (PIN_BASE + 0x80 + 6)
163#define AT91_PIN_PE7 (0x80 + 7) 165#define AT91_PIN_PE7 (PIN_BASE + 0x80 + 7)
164#define AT91_PIN_PE8 (0x80 + 8) 166#define AT91_PIN_PE8 (PIN_BASE + 0x80 + 8)
165#define AT91_PIN_PE9 (0x80 + 9) 167#define AT91_PIN_PE9 (PIN_BASE + 0x80 + 9)
166#define AT91_PIN_PE10 (0x80 + 10) 168#define AT91_PIN_PE10 (PIN_BASE + 0x80 + 10)
167#define AT91_PIN_PE11 (0x80 + 11) 169#define AT91_PIN_PE11 (PIN_BASE + 0x80 + 11)
168#define AT91_PIN_PE12 (0x80 + 12) 170#define AT91_PIN_PE12 (PIN_BASE + 0x80 + 12)
169#define AT91_PIN_PE13 (0x80 + 13) 171#define AT91_PIN_PE13 (PIN_BASE + 0x80 + 13)
170#define AT91_PIN_PE14 (0x80 + 14) 172#define AT91_PIN_PE14 (PIN_BASE + 0x80 + 14)
171#define AT91_PIN_PE15 (0x80 + 15) 173#define AT91_PIN_PE15 (PIN_BASE + 0x80 + 15)
172#define AT91_PIN_PE16 (0x80 + 16) 174#define AT91_PIN_PE16 (PIN_BASE + 0x80 + 16)
173#define AT91_PIN_PE17 (0x80 + 17) 175#define AT91_PIN_PE17 (PIN_BASE + 0x80 + 17)
174#define AT91_PIN_PE18 (0x80 + 18) 176#define AT91_PIN_PE18 (PIN_BASE + 0x80 + 18)
175#define AT91_PIN_PE19 (0x80 + 19) 177#define AT91_PIN_PE19 (PIN_BASE + 0x80 + 19)
176#define AT91_PIN_PE20 (0x80 + 20) 178#define AT91_PIN_PE20 (PIN_BASE + 0x80 + 20)
177#define AT91_PIN_PE21 (0x80 + 21) 179#define AT91_PIN_PE21 (PIN_BASE + 0x80 + 21)
178#define AT91_PIN_PE22 (0x80 + 22) 180#define AT91_PIN_PE22 (PIN_BASE + 0x80 + 22)
179#define AT91_PIN_PE23 (0x80 + 23) 181#define AT91_PIN_PE23 (PIN_BASE + 0x80 + 23)
180#define AT91_PIN_PE24 (0x80 + 24) 182#define AT91_PIN_PE24 (PIN_BASE + 0x80 + 24)
181#define AT91_PIN_PE25 (0x80 + 25) 183#define AT91_PIN_PE25 (PIN_BASE + 0x80 + 25)
182#define AT91_PIN_PE26 (0x80 + 26) 184#define AT91_PIN_PE26 (PIN_BASE + 0x80 + 26)
183#define AT91_PIN_PE27 (0x80 + 27) 185#define AT91_PIN_PE27 (PIN_BASE + 0x80 + 27)
184#define AT91_PIN_PE28 (0x80 + 28) 186#define AT91_PIN_PE28 (PIN_BASE + 0x80 + 28)
185#define AT91_PIN_PE29 (0x80 + 29) 187#define AT91_PIN_PE29 (PIN_BASE + 0x80 + 29)
186#define AT91_PIN_PE30 (0x80 + 30) 188#define AT91_PIN_PE30 (PIN_BASE + 0x80 + 30)
187#define AT91_PIN_PE31 (0x80 + 31) 189#define AT91_PIN_PE31 (PIN_BASE + 0x80 + 31)
188 190
189#ifndef __ASSEMBLY__ 191#ifndef __ASSEMBLY__
190/* setup setup routines, called from board init or driver probe() */ 192/* setup setup routines, called from board init or driver probe() */
191extern int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup); 193extern int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup);
192extern int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup); 194extern int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup);
193extern int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup); 195extern int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup);
194extern int __init_or_module at91_set_C_periph(unsigned pin, int use_pullup);
195extern int __init_or_module at91_set_D_periph(unsigned pin, int use_pullup);
196extern int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup); 196extern int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup);
197extern int __init_or_module at91_set_gpio_output(unsigned pin, int value); 197extern int __init_or_module at91_set_gpio_output(unsigned pin, int value);
198extern int __init_or_module at91_set_deglitch(unsigned pin, int is_on); 198extern int __init_or_module at91_set_deglitch(unsigned pin, int is_on);
199extern int __init_or_module at91_set_debounce(unsigned pin, int is_on, int div);
200extern int __init_or_module at91_set_multi_drive(unsigned pin, int is_on); 199extern int __init_or_module at91_set_multi_drive(unsigned pin, int is_on);
201extern int __init_or_module at91_set_pulldown(unsigned pin, int is_on);
202extern int __init_or_module at91_disable_schmitt_trig(unsigned pin);
203 200
204/* callable at any time */ 201/* callable at any time */
205extern int at91_set_gpio_value(unsigned pin, int value); 202extern int at91_set_gpio_value(unsigned pin, int value);
@@ -209,6 +206,23 @@ extern int at91_get_gpio_value(unsigned pin);
209extern void at91_gpio_suspend(void); 206extern void at91_gpio_suspend(void);
210extern void at91_gpio_resume(void); 207extern void at91_gpio_resume(void);
211 208
209/*-------------------------------------------------------------------------*/
210
211/* wrappers for "new style" GPIO calls. the old AT91-specific ones should
212 * eventually be removed (along with this errno.h inclusion), and the
213 * gpio request/free calls should probably be implemented.
214 */
215
216#include <asm/errno.h>
217#include <asm-generic/gpio.h> /* cansleep wrappers */
218
219#define gpio_get_value __gpio_get_value
220#define gpio_set_value __gpio_set_value
221#define gpio_cansleep __gpio_cansleep
222
223#define gpio_to_irq(gpio) (gpio)
224#define irq_to_gpio(irq) (irq)
225
212#endif /* __ASSEMBLY__ */ 226#endif /* __ASSEMBLY__ */
213 227
214#endif 228#endif
diff --git a/arch/arm/mach-at91/include/mach/hardware.h b/arch/arm/mach-at91/include/mach/hardware.h
index a832e070761..483478d8be6 100644
--- a/arch/arm/mach-at91/include/mach/hardware.h
+++ b/arch/arm/mach-at91/include/mach/hardware.h
@@ -16,24 +16,27 @@
16 16
17#include <asm/sizes.h> 17#include <asm/sizes.h>
18 18
19/* DBGU base */ 19#if defined(CONFIG_ARCH_AT91RM9200)
20/* rm9200, 9260/9g20, 9261/9g10, 9rl */
21#define AT91_BASE_DBGU0 0xfffff200
22/* 9263, 9g45 */
23#define AT91_BASE_DBGU1 0xffffee00
24
25#if defined(CONFIG_ARCH_AT91X40)
26#include <mach/at91x40.h>
27#else
28#include <mach/at91rm9200.h> 20#include <mach/at91rm9200.h>
21#elif defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9G20)
29#include <mach/at91sam9260.h> 22#include <mach/at91sam9260.h>
23#elif defined(CONFIG_ARCH_AT91SAM9261) || defined(CONFIG_ARCH_AT91SAM9G10)
30#include <mach/at91sam9261.h> 24#include <mach/at91sam9261.h>
25#elif defined(CONFIG_ARCH_AT91SAM9263)
31#include <mach/at91sam9263.h> 26#include <mach/at91sam9263.h>
27#elif defined(CONFIG_ARCH_AT91SAM9RL)
32#include <mach/at91sam9rl.h> 28#include <mach/at91sam9rl.h>
29#elif defined(CONFIG_ARCH_AT91SAM9G45)
33#include <mach/at91sam9g45.h> 30#include <mach/at91sam9g45.h>
34#include <mach/at91sam9x5.h> 31#elif defined(CONFIG_ARCH_AT91CAP9)
35#include <mach/at91sam9n12.h> 32#include <mach/at91cap9.h>
33#elif defined(CONFIG_ARCH_AT91X40)
34#include <mach/at91x40.h>
35#else
36#error "Unsupported AT91 processor"
37#endif
36 38
39#if !defined(CONFIG_ARCH_AT91X40)
37/* 40/*
38 * On all at91 except rm9200 and x40 have the System Controller starts 41 * On all at91 except rm9200 and x40 have the System Controller starts
39 * at address 0xffffc000 and has a size of 16KiB. 42 * at address 0xffffc000 and has a size of 16KiB.
@@ -49,13 +52,6 @@
49#endif 52#endif
50 53
51/* 54/*
52 * On all at91 have the Advanced Interrupt Controller starts at address
53 * 0xfffff000 and the Power Management Controller starts at 0xfffffc00
54 */
55#define AT91_AIC 0xfffff000
56#define AT91_PMC 0xfffffc00
57
58/*
59 * Peripheral identifiers/interrupts. 55 * Peripheral identifiers/interrupts.
60 */ 56 */
61#define AT91_ID_FIQ 0 /* Advanced Interrupt Controller (FIQ) */ 57#define AT91_ID_FIQ 0 /* Advanced Interrupt Controller (FIQ) */
@@ -67,13 +63,13 @@
67 * to 0xFEF78000 .. 0xFF000000. (544Kb) 63 * to 0xFEF78000 .. 0xFF000000. (544Kb)
68 */ 64 */
69#define AT91_IO_PHYS_BASE 0xFFF78000 65#define AT91_IO_PHYS_BASE 0xFFF78000
70#define AT91_IO_VIRT_BASE IOMEM(0xFF000000 - AT91_IO_SIZE) 66#define AT91_IO_VIRT_BASE (0xFF000000 - AT91_IO_SIZE)
71#else 67#else
72/* 68/*
73 * Identity mapping for the non MMU case. 69 * Identity mapping for the non MMU case.
74 */ 70 */
75#define AT91_IO_PHYS_BASE AT91_BASE_SYS 71#define AT91_IO_PHYS_BASE AT91_BASE_SYS
76#define AT91_IO_VIRT_BASE IOMEM(AT91_IO_PHYS_BASE) 72#define AT91_IO_VIRT_BASE AT91_IO_PHYS_BASE
77#endif 73#endif
78 74
79#define AT91_IO_SIZE (0xFFFFFFFF - AT91_IO_PHYS_BASE + 1) 75#define AT91_IO_SIZE (0xFFFFFFFF - AT91_IO_PHYS_BASE + 1)
@@ -85,11 +81,15 @@
85 * Virtual to Physical Address mapping for IO devices. 81 * Virtual to Physical Address mapping for IO devices.
86 */ 82 */
87#define AT91_VA_BASE_SYS AT91_IO_P2V(AT91_BASE_SYS) 83#define AT91_VA_BASE_SYS AT91_IO_P2V(AT91_BASE_SYS)
84#define AT91_VA_BASE_EMAC AT91_IO_P2V(AT91RM9200_BASE_EMAC)
88 85
89 /* Internal SRAM is mapped below the IO devices */ 86 /* Internal SRAM is mapped below the IO devices */
90#define AT91_SRAM_MAX SZ_1M 87#define AT91_SRAM_MAX SZ_1M
91#define AT91_VIRT_BASE (AT91_IO_VIRT_BASE - AT91_SRAM_MAX) 88#define AT91_VIRT_BASE (AT91_IO_VIRT_BASE - AT91_SRAM_MAX)
92 89
90/* Serial ports */
91#define ATMEL_MAX_UART 7 /* 6 USART3's and one DBGU port (SAM9260) */
92
93/* External Memory Map */ 93/* External Memory Map */
94#define AT91_CHIPSELECT_0 0x10000000 94#define AT91_CHIPSELECT_0 0x10000000
95#define AT91_CHIPSELECT_1 0x20000000 95#define AT91_CHIPSELECT_1 0x20000000
diff --git a/arch/arm/mach-at91/include/mach/io.h b/arch/arm/mach-at91/include/mach/io.h
index 2d9ca045574..4298e7806c7 100644
--- a/arch/arm/mach-at91/include/mach/io.h
+++ b/arch/arm/mach-at91/include/mach/io.h
@@ -21,7 +21,37 @@
21#ifndef __ASM_ARCH_IO_H 21#ifndef __ASM_ARCH_IO_H
22#define __ASM_ARCH_IO_H 22#define __ASM_ARCH_IO_H
23 23
24#include <mach/hardware.h>
25
24#define IO_SPACE_LIMIT 0xFFFFFFFF 26#define IO_SPACE_LIMIT 0xFFFFFFFF
25#define __io(a) __typesafe_io(a) 27
28#define __io(a) __typesafe_io(a)
29#define __mem_pci(a) (a)
30
31#ifndef __ASSEMBLY__
32
33#ifndef CONFIG_ARCH_AT91X40
34#define __arch_ioremap at91_ioremap
35#define __arch_iounmap at91_iounmap
36#endif
37
38void __iomem *at91_ioremap(unsigned long phys, size_t size, unsigned int type);
39void at91_iounmap(volatile void __iomem *addr);
40
41static inline unsigned int at91_sys_read(unsigned int reg_offset)
42{
43 void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS;
44
45 return __raw_readl(addr + reg_offset);
46}
47
48static inline void at91_sys_write(unsigned int reg_offset, unsigned long value)
49{
50 void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS;
51
52 __raw_writel(value, addr + reg_offset);
53}
54
55#endif
26 56
27#endif 57#endif
diff --git a/arch/arm/mach-at91/include/mach/system_rev.h b/arch/arm/mach-at91/include/mach/system_rev.h
index ef79a9aafc0..8f4866045b4 100644
--- a/arch/arm/mach-at91/include/mach/system_rev.h
+++ b/arch/arm/mach-at91/include/mach/system_rev.h
@@ -7,8 +7,6 @@
7#ifndef __ARCH_SYSTEM_REV_H__ 7#ifndef __ARCH_SYSTEM_REV_H__
8#define __ARCH_SYSTEM_REV_H__ 8#define __ARCH_SYSTEM_REV_H__
9 9
10#include <asm/system_info.h>
11
12/* 10/*
13 * board revision encoding 11 * board revision encoding
14 * mach specific 12 * mach specific
@@ -21,7 +19,7 @@
21#define BOARD_HAVE_NAND_16BIT (1 << 31) 19#define BOARD_HAVE_NAND_16BIT (1 << 31)
22static inline int board_have_nand_16bit(void) 20static inline int board_have_nand_16bit(void)
23{ 21{
24 return (system_rev & BOARD_HAVE_NAND_16BIT) ? 1 : 0; 22 return system_rev & BOARD_HAVE_NAND_16BIT;
25} 23}
26 24
27#endif /* __ARCH_SYSTEM_REV_H__ */ 25#endif /* __ARCH_SYSTEM_REV_H__ */
diff --git a/arch/arm/mach-at91/include/mach/timex.h b/arch/arm/mach-at91/include/mach/timex.h
index 5e917a66edd..31ac2d97f14 100644
--- a/arch/arm/mach-at91/include/mach/timex.h
+++ b/arch/arm/mach-at91/include/mach/timex.h
@@ -23,15 +23,65 @@
23 23
24#include <mach/hardware.h> 24#include <mach/hardware.h>
25 25
26#ifdef CONFIG_ARCH_AT91X40 26#if defined(CONFIG_ARCH_AT91RM9200)
27 27
28#define AT91X40_MASTER_CLOCK 40000000 28#define CLOCK_TICK_RATE (AT91_SLOW_CLOCK)
29#define CLOCK_TICK_RATE (AT91X40_MASTER_CLOCK)
30 29
30#elif defined(CONFIG_ARCH_AT91SAM9260)
31
32#if defined(CONFIG_MACH_USB_A9260) || defined(CONFIG_MACH_QIL_A9260)
33#define AT91SAM9_MASTER_CLOCK 90000000
31#else 34#else
35#define AT91SAM9_MASTER_CLOCK 99300000
36#endif
37
38#define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
39
40#elif defined(CONFIG_ARCH_AT91SAM9261)
41
42#define AT91SAM9_MASTER_CLOCK 99300000
43#define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
44
45#elif defined(CONFIG_ARCH_AT91SAM9G10)
46
47#define AT91SAM9_MASTER_CLOCK 133000000
48#define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
49
50#elif defined(CONFIG_ARCH_AT91SAM9263)
51
52#if defined(CONFIG_MACH_USB_A9263)
53#define AT91SAM9_MASTER_CLOCK 90000000
54#else
55#define AT91SAM9_MASTER_CLOCK 99959500
56#endif
32 57
33#define CLOCK_TICK_RATE 12345678 58#define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
59
60#elif defined(CONFIG_ARCH_AT91SAM9RL)
61
62#define AT91SAM9_MASTER_CLOCK 100000000
63#define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
64
65#elif defined(CONFIG_ARCH_AT91SAM9G20)
66
67#define AT91SAM9_MASTER_CLOCK 132096000
68#define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
69
70#elif defined(CONFIG_ARCH_AT91SAM9G45)
71
72#define AT91SAM9_MASTER_CLOCK 133333333
73#define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
74
75#elif defined(CONFIG_ARCH_AT91CAP9)
76
77#define AT91CAP9_MASTER_CLOCK 100000000
78#define CLOCK_TICK_RATE (AT91CAP9_MASTER_CLOCK/16)
79
80#elif defined(CONFIG_ARCH_AT91X40)
81
82#define AT91X40_MASTER_CLOCK 40000000
83#define CLOCK_TICK_RATE (AT91X40_MASTER_CLOCK)
34 84
35#endif 85#endif
36 86
37#endif /* __ASM_ARCH_TIMEX_H */ 87#endif
diff --git a/arch/arm/mach-at91/include/mach/uncompress.h b/arch/arm/mach-at91/include/mach/uncompress.h
index 97ad68a826f..18bdcdeb474 100644
--- a/arch/arm/mach-at91/include/mach/uncompress.h
+++ b/arch/arm/mach-at91/include/mach/uncompress.h
@@ -1,8 +1,7 @@
1/* 1/*
2 * arch/arm/mach-at91/include/mach/uncompress.h 2 * arch/arm/mach-at91/include/mach/uncompress.h
3 * 3 *
4 * Copyright (C) 2003 SAN People 4 * Copyright (C) 2003 SAN People
5 * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
6 * 5 *
7 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -24,149 +23,21 @@
24 23
25#include <linux/io.h> 24#include <linux/io.h>
26#include <linux/atmel_serial.h> 25#include <linux/atmel_serial.h>
27#include <mach/hardware.h>
28 26
29#include <mach/at91_dbgu.h> 27#if defined(CONFIG_AT91_EARLY_DBGU)
30#include <mach/cpu.h> 28#define UART_OFFSET (AT91_DBGU + AT91_BASE_SYS)
31 29#elif defined(CONFIG_AT91_EARLY_USART0)
32void __iomem *at91_uart; 30#define UART_OFFSET AT91_USART0
33 31#elif defined(CONFIG_AT91_EARLY_USART1)
34#if !defined(CONFIG_ARCH_AT91X40) 32#define UART_OFFSET AT91_USART1
35static const u32 uarts_rm9200[] = { 33#elif defined(CONFIG_AT91_EARLY_USART2)
36 AT91_BASE_DBGU0, 34#define UART_OFFSET AT91_USART2
37 AT91RM9200_BASE_US0, 35#elif defined(CONFIG_AT91_EARLY_USART3)
38 AT91RM9200_BASE_US1, 36#define UART_OFFSET AT91_USART3
39 AT91RM9200_BASE_US2, 37#elif defined(CONFIG_AT91_EARLY_USART4)
40 AT91RM9200_BASE_US3, 38#define UART_OFFSET AT91_USART4
41 0, 39#elif defined(CONFIG_AT91_EARLY_USART5)
42}; 40#define UART_OFFSET AT91_USART5
43
44static const u32 uarts_sam9260[] = {
45 AT91_BASE_DBGU0,
46 AT91SAM9260_BASE_US0,
47 AT91SAM9260_BASE_US1,
48 AT91SAM9260_BASE_US2,
49 AT91SAM9260_BASE_US3,
50 AT91SAM9260_BASE_US4,
51 AT91SAM9260_BASE_US5,
52 0,
53};
54
55static const u32 uarts_sam9261[] = {
56 AT91_BASE_DBGU0,
57 AT91SAM9261_BASE_US0,
58 AT91SAM9261_BASE_US1,
59 AT91SAM9261_BASE_US2,
60 0,
61};
62
63static const u32 uarts_sam9263[] = {
64 AT91_BASE_DBGU1,
65 AT91SAM9263_BASE_US0,
66 AT91SAM9263_BASE_US1,
67 AT91SAM9263_BASE_US2,
68 0,
69};
70
71static const u32 uarts_sam9g45[] = {
72 AT91_BASE_DBGU1,
73 AT91SAM9G45_BASE_US0,
74 AT91SAM9G45_BASE_US1,
75 AT91SAM9G45_BASE_US2,
76 AT91SAM9G45_BASE_US3,
77 0,
78};
79
80static const u32 uarts_sam9rl[] = {
81 AT91_BASE_DBGU0,
82 AT91SAM9RL_BASE_US0,
83 AT91SAM9RL_BASE_US1,
84 AT91SAM9RL_BASE_US2,
85 AT91SAM9RL_BASE_US3,
86 0,
87};
88
89static const u32 uarts_sam9x5[] = {
90 AT91_BASE_DBGU0,
91 AT91SAM9X5_BASE_USART0,
92 AT91SAM9X5_BASE_USART1,
93 AT91SAM9X5_BASE_USART2,
94 0,
95};
96
97static inline const u32* decomp_soc_detect(void __iomem *dbgu_base)
98{
99 u32 cidr, socid;
100
101 cidr = __raw_readl(dbgu_base + AT91_DBGU_CIDR);
102 socid = cidr & ~AT91_CIDR_VERSION;
103
104 switch (socid) {
105 case ARCH_ID_AT91RM9200:
106 return uarts_rm9200;
107
108 case ARCH_ID_AT91SAM9G20:
109 case ARCH_ID_AT91SAM9260:
110 return uarts_sam9260;
111
112 case ARCH_ID_AT91SAM9261:
113 return uarts_sam9261;
114
115 case ARCH_ID_AT91SAM9263:
116 return uarts_sam9263;
117
118 case ARCH_ID_AT91SAM9G45:
119 return uarts_sam9g45;
120
121 case ARCH_ID_AT91SAM9RL64:
122 return uarts_sam9rl;
123
124 case ARCH_ID_AT91SAM9X5:
125 return uarts_sam9x5;
126 }
127
128 /* at91sam9g10 */
129 if ((cidr & ~AT91_CIDR_EXT) == ARCH_ID_AT91SAM9G10) {
130 return uarts_sam9261;
131 }
132 /* at91sam9xe */
133 else if ((cidr & AT91_CIDR_ARCH) == ARCH_FAMILY_AT91SAM9XE) {
134 return uarts_sam9260;
135 }
136
137 return NULL;
138}
139
140static inline void arch_decomp_setup(void)
141{
142 int i = 0;
143 const u32* usarts;
144
145 usarts = decomp_soc_detect((void __iomem *)AT91_BASE_DBGU0);
146
147 if (!usarts)
148 usarts = decomp_soc_detect((void __iomem *)AT91_BASE_DBGU1);
149 if (!usarts) {
150 at91_uart = NULL;
151 return;
152 }
153
154 do {
155 /* physical address */
156 at91_uart = (void __iomem *)usarts[i];
157
158 if (__raw_readl(at91_uart + ATMEL_US_BRGR))
159 return;
160 i++;
161 } while (usarts[i]);
162
163 at91_uart = NULL;
164}
165#else
166static inline void arch_decomp_setup(void)
167{
168 at91_uart = NULL;
169}
170#endif 41#endif
171 42
172/* 43/*
@@ -178,24 +49,28 @@ static inline void arch_decomp_setup(void)
178 */ 49 */
179static void putc(int c) 50static void putc(int c)
180{ 51{
181 if (!at91_uart) 52#ifdef UART_OFFSET
182 return; 53 void __iomem *sys = (void __iomem *) UART_OFFSET; /* physical address */
183 54
184 while (!(__raw_readl(at91_uart + ATMEL_US_CSR) & ATMEL_US_TXRDY)) 55 while (!(__raw_readl(sys + ATMEL_US_CSR) & ATMEL_US_TXRDY))
185 barrier(); 56 barrier();
186 __raw_writel(c, at91_uart + ATMEL_US_THR); 57 __raw_writel(c, sys + ATMEL_US_THR);
58#endif
187} 59}
188 60
189static inline void flush(void) 61static inline void flush(void)
190{ 62{
191 if (!at91_uart) 63#ifdef UART_OFFSET
192 return; 64 void __iomem *sys = (void __iomem *) UART_OFFSET; /* physical address */
193 65
194 /* wait for transmission to complete */ 66 /* wait for transmission to complete */
195 while (!(__raw_readl(at91_uart + ATMEL_US_CSR) & ATMEL_US_TXEMPTY)) 67 while (!(__raw_readl(sys + ATMEL_US_CSR) & ATMEL_US_TXEMPTY))
196 barrier(); 68 barrier();
69#endif
197} 70}
198 71
72#define arch_decomp_setup()
73
199#define arch_decomp_wdog() 74#define arch_decomp_wdog()
200 75
201#endif 76#endif
diff --git a/arch/arm/mach-at91/irq.c b/arch/arm/mach-at91/irq.c
index 8e210262aee..9665265ec75 100644
--- a/arch/arm/mach-at91/irq.c
+++ b/arch/arm/mach-at91/irq.c
@@ -23,226 +23,36 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/bitmap.h>
27#include <linux/types.h> 26#include <linux/types.h>
28#include <linux/irq.h>
29#include <linux/of.h>
30#include <linux/of_address.h>
31#include <linux/of_irq.h>
32#include <linux/irqdomain.h>
33#include <linux/err.h>
34#include <linux/slab.h>
35 27
36#include <mach/hardware.h> 28#include <mach/hardware.h>
37#include <asm/irq.h> 29#include <asm/irq.h>
38#include <asm/setup.h> 30#include <asm/setup.h>
39 31
40#include <asm/exception.h>
41#include <asm/mach/arch.h> 32#include <asm/mach/arch.h>
42#include <asm/mach/irq.h> 33#include <asm/mach/irq.h>
43#include <asm/mach/map.h> 34#include <asm/mach/map.h>
44 35
45#include "at91_aic.h"
46
47void __iomem *at91_aic_base;
48static struct irq_domain *at91_aic_domain;
49static struct device_node *at91_aic_np;
50static unsigned int n_irqs = NR_AIC_IRQS;
51static unsigned long at91_aic_caps = 0;
52
53/* AIC5 introduces a Source Select Register */
54#define AT91_AIC_CAP_AIC5 (1 << 0)
55#define has_aic5() (at91_aic_caps & AT91_AIC_CAP_AIC5)
56
57#ifdef CONFIG_PM
58
59static unsigned long *wakeups;
60static unsigned long *backups;
61
62#define set_backup(bit) set_bit(bit, backups)
63#define clear_backup(bit) clear_bit(bit, backups)
64
65static int at91_aic_pm_init(void)
66{
67 backups = kzalloc(BITS_TO_LONGS(n_irqs) * sizeof(*backups), GFP_KERNEL);
68 if (!backups)
69 return -ENOMEM;
70
71 wakeups = kzalloc(BITS_TO_LONGS(n_irqs) * sizeof(*backups), GFP_KERNEL);
72 if (!wakeups) {
73 kfree(backups);
74 return -ENOMEM;
75 }
76
77 return 0;
78}
79
80static int at91_aic_set_wake(struct irq_data *d, unsigned value)
81{
82 if (unlikely(d->hwirq >= n_irqs))
83 return -EINVAL;
84
85 if (value)
86 set_bit(d->hwirq, wakeups);
87 else
88 clear_bit(d->hwirq, wakeups);
89
90 return 0;
91}
92
93void at91_irq_suspend(void)
94{
95 int i = 0, bit;
96
97 if (has_aic5()) {
98 /* disable enabled irqs */
99 while ((bit = find_next_bit(backups, n_irqs, i)) < n_irqs) {
100 at91_aic_write(AT91_AIC5_SSR,
101 bit & AT91_AIC5_INTSEL_MSK);
102 at91_aic_write(AT91_AIC5_IDCR, 1);
103 i = bit;
104 }
105 /* enable wakeup irqs */
106 i = 0;
107 while ((bit = find_next_bit(wakeups, n_irqs, i)) < n_irqs) {
108 at91_aic_write(AT91_AIC5_SSR,
109 bit & AT91_AIC5_INTSEL_MSK);
110 at91_aic_write(AT91_AIC5_IECR, 1);
111 i = bit;
112 }
113 } else {
114 at91_aic_write(AT91_AIC_IDCR, *backups);
115 at91_aic_write(AT91_AIC_IECR, *wakeups);
116 }
117}
118
119void at91_irq_resume(void)
120{
121 int i = 0, bit;
122
123 if (has_aic5()) {
124 /* disable wakeup irqs */
125 while ((bit = find_next_bit(wakeups, n_irqs, i)) < n_irqs) {
126 at91_aic_write(AT91_AIC5_SSR,
127 bit & AT91_AIC5_INTSEL_MSK);
128 at91_aic_write(AT91_AIC5_IDCR, 1);
129 i = bit;
130 }
131 /* enable irqs disabled for suspend */
132 i = 0;
133 while ((bit = find_next_bit(backups, n_irqs, i)) < n_irqs) {
134 at91_aic_write(AT91_AIC5_SSR,
135 bit & AT91_AIC5_INTSEL_MSK);
136 at91_aic_write(AT91_AIC5_IECR, 1);
137 i = bit;
138 }
139 } else {
140 at91_aic_write(AT91_AIC_IDCR, *wakeups);
141 at91_aic_write(AT91_AIC_IECR, *backups);
142 }
143}
144
145#else
146static inline int at91_aic_pm_init(void)
147{
148 return 0;
149}
150
151#define set_backup(bit)
152#define clear_backup(bit)
153#define at91_aic_set_wake NULL
154
155#endif /* CONFIG_PM */
156
157asmlinkage void __exception_irq_entry
158at91_aic_handle_irq(struct pt_regs *regs)
159{
160 u32 irqnr;
161 u32 irqstat;
162
163 irqnr = at91_aic_read(AT91_AIC_IVR);
164 irqstat = at91_aic_read(AT91_AIC_ISR);
165
166 /*
167 * ISR value is 0 when there is no current interrupt or when there is
168 * a spurious interrupt
169 */
170 if (!irqstat)
171 at91_aic_write(AT91_AIC_EOICR, 0);
172 else
173 handle_IRQ(irqnr, regs);
174}
175
176asmlinkage void __exception_irq_entry
177at91_aic5_handle_irq(struct pt_regs *regs)
178{
179 u32 irqnr;
180 u32 irqstat;
181
182 irqnr = at91_aic_read(AT91_AIC5_IVR);
183 irqstat = at91_aic_read(AT91_AIC5_ISR);
184
185 if (!irqstat)
186 at91_aic_write(AT91_AIC5_EOICR, 0);
187 else
188 handle_IRQ(irqnr, regs);
189}
190 36
191static void at91_aic_mask_irq(struct irq_data *d) 37static void at91_aic_mask_irq(struct irq_data *d)
192{ 38{
193 /* Disable interrupt on AIC */ 39 /* Disable interrupt on AIC */
194 at91_aic_write(AT91_AIC_IDCR, 1 << d->hwirq); 40 at91_sys_write(AT91_AIC_IDCR, 1 << d->irq);
195 /* Update ISR cache */
196 clear_backup(d->hwirq);
197}
198
199static void __maybe_unused at91_aic5_mask_irq(struct irq_data *d)
200{
201 /* Disable interrupt on AIC5 */
202 at91_aic_write(AT91_AIC5_SSR, d->hwirq & AT91_AIC5_INTSEL_MSK);
203 at91_aic_write(AT91_AIC5_IDCR, 1);
204 /* Update ISR cache */
205 clear_backup(d->hwirq);
206} 41}
207 42
208static void at91_aic_unmask_irq(struct irq_data *d) 43static void at91_aic_unmask_irq(struct irq_data *d)
209{ 44{
210 /* Enable interrupt on AIC */ 45 /* Enable interrupt on AIC */
211 at91_aic_write(AT91_AIC_IECR, 1 << d->hwirq); 46 at91_sys_write(AT91_AIC_IECR, 1 << d->irq);
212 /* Update ISR cache */
213 set_backup(d->hwirq);
214} 47}
215 48
216static void __maybe_unused at91_aic5_unmask_irq(struct irq_data *d) 49unsigned int at91_extern_irq;
217{
218 /* Enable interrupt on AIC5 */
219 at91_aic_write(AT91_AIC5_SSR, d->hwirq & AT91_AIC5_INTSEL_MSK);
220 at91_aic_write(AT91_AIC5_IECR, 1);
221 /* Update ISR cache */
222 set_backup(d->hwirq);
223}
224
225static void at91_aic_eoi(struct irq_data *d)
226{
227 /*
228 * Mark end-of-interrupt on AIC, the controller doesn't care about
229 * the value written. Moreover it's a write-only register.
230 */
231 at91_aic_write(AT91_AIC_EOICR, 0);
232}
233
234static void __maybe_unused at91_aic5_eoi(struct irq_data *d)
235{
236 at91_aic_write(AT91_AIC5_EOICR, 0);
237}
238
239unsigned long *at91_extern_irq;
240 50
241#define is_extern_irq(hwirq) test_bit(hwirq, at91_extern_irq) 51#define is_extern_irq(irq) ((1 << (irq)) & at91_extern_irq)
242 52
243static int at91_aic_compute_srctype(struct irq_data *d, unsigned type) 53static int at91_aic_set_type(struct irq_data *d, unsigned type)
244{ 54{
245 int srctype; 55 unsigned int smr, srctype;
246 56
247 switch (type) { 57 switch (type) {
248 case IRQ_TYPE_LEVEL_HIGH: 58 case IRQ_TYPE_LEVEL_HIGH:
@@ -252,300 +62,105 @@ static int at91_aic_compute_srctype(struct irq_data *d, unsigned type)
252 srctype = AT91_AIC_SRCTYPE_RISING; 62 srctype = AT91_AIC_SRCTYPE_RISING;
253 break; 63 break;
254 case IRQ_TYPE_LEVEL_LOW: 64 case IRQ_TYPE_LEVEL_LOW:
255 if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq)) /* only supported on external interrupts */ 65 if ((d->irq == AT91_ID_FIQ) || is_extern_irq(d->irq)) /* only supported on external interrupts */
256 srctype = AT91_AIC_SRCTYPE_LOW; 66 srctype = AT91_AIC_SRCTYPE_LOW;
257 else 67 else
258 srctype = -EINVAL; 68 return -EINVAL;
259 break; 69 break;
260 case IRQ_TYPE_EDGE_FALLING: 70 case IRQ_TYPE_EDGE_FALLING:
261 if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq)) /* only supported on external interrupts */ 71 if ((d->irq == AT91_ID_FIQ) || is_extern_irq(d->irq)) /* only supported on external interrupts */
262 srctype = AT91_AIC_SRCTYPE_FALLING; 72 srctype = AT91_AIC_SRCTYPE_FALLING;
263 else 73 else
264 srctype = -EINVAL; 74 return -EINVAL;
265 break; 75 break;
266 default: 76 default:
267 srctype = -EINVAL; 77 return -EINVAL;
268 }
269
270 return srctype;
271}
272
273static int at91_aic_set_type(struct irq_data *d, unsigned type)
274{
275 unsigned int smr;
276 int srctype;
277
278 srctype = at91_aic_compute_srctype(d, type);
279 if (srctype < 0)
280 return srctype;
281
282 if (has_aic5()) {
283 at91_aic_write(AT91_AIC5_SSR,
284 d->hwirq & AT91_AIC5_INTSEL_MSK);
285 smr = at91_aic_read(AT91_AIC5_SMR) & ~AT91_AIC_SRCTYPE;
286 at91_aic_write(AT91_AIC5_SMR, smr | srctype);
287 } else {
288 smr = at91_aic_read(AT91_AIC_SMR(d->hwirq))
289 & ~AT91_AIC_SRCTYPE;
290 at91_aic_write(AT91_AIC_SMR(d->hwirq), smr | srctype);
291 }
292
293 return 0;
294}
295
296static struct irq_chip at91_aic_chip = {
297 .name = "AIC",
298 .irq_mask = at91_aic_mask_irq,
299 .irq_unmask = at91_aic_unmask_irq,
300 .irq_set_type = at91_aic_set_type,
301 .irq_set_wake = at91_aic_set_wake,
302 .irq_eoi = at91_aic_eoi,
303};
304
305static void __init at91_aic_hw_init(unsigned int spu_vector)
306{
307 int i;
308
309 /*
310 * Perform 8 End Of Interrupt Command to make sure AIC
311 * will not Lock out nIRQ
312 */
313 for (i = 0; i < 8; i++)
314 at91_aic_write(AT91_AIC_EOICR, 0);
315
316 /*
317 * Spurious Interrupt ID in Spurious Vector Register.
318 * When there is no current interrupt, the IRQ Vector Register
319 * reads the value stored in AIC_SPU
320 */
321 at91_aic_write(AT91_AIC_SPU, spu_vector);
322
323 /* No debugging in AIC: Debug (Protect) Control Register */
324 at91_aic_write(AT91_AIC_DCR, 0);
325
326 /* Disable and clear all interrupts initially */
327 at91_aic_write(AT91_AIC_IDCR, 0xFFFFFFFF);
328 at91_aic_write(AT91_AIC_ICCR, 0xFFFFFFFF);
329}
330
331static void __init __maybe_unused at91_aic5_hw_init(unsigned int spu_vector)
332{
333 int i;
334
335 /*
336 * Perform 8 End Of Interrupt Command to make sure AIC
337 * will not Lock out nIRQ
338 */
339 for (i = 0; i < 8; i++)
340 at91_aic_write(AT91_AIC5_EOICR, 0);
341
342 /*
343 * Spurious Interrupt ID in Spurious Vector Register.
344 * When there is no current interrupt, the IRQ Vector Register
345 * reads the value stored in AIC_SPU
346 */
347 at91_aic_write(AT91_AIC5_SPU, spu_vector);
348
349 /* No debugging in AIC: Debug (Protect) Control Register */
350 at91_aic_write(AT91_AIC5_DCR, 0);
351
352 /* Disable and clear all interrupts initially */
353 for (i = 0; i < n_irqs; i++) {
354 at91_aic_write(AT91_AIC5_SSR, i & AT91_AIC5_INTSEL_MSK);
355 at91_aic_write(AT91_AIC5_IDCR, 1);
356 at91_aic_write(AT91_AIC5_ICCR, 1);
357 } 78 }
358}
359
360#if defined(CONFIG_OF)
361static unsigned int *at91_aic_irq_priorities;
362
363static int at91_aic_irq_map(struct irq_domain *h, unsigned int virq,
364 irq_hw_number_t hw)
365{
366 /* Put virq number in Source Vector Register */
367 at91_aic_write(AT91_AIC_SVR(hw), virq);
368
369 /* Active Low interrupt, with priority */
370 at91_aic_write(AT91_AIC_SMR(hw),
371 AT91_AIC_SRCTYPE_LOW | at91_aic_irq_priorities[hw]);
372
373 irq_set_chip_and_handler(virq, &at91_aic_chip, handle_fasteoi_irq);
374 set_irq_flags(virq, IRQF_VALID | IRQF_PROBE);
375 79
80 smr = at91_sys_read(AT91_AIC_SMR(d->irq)) & ~AT91_AIC_SRCTYPE;
81 at91_sys_write(AT91_AIC_SMR(d->irq), smr | srctype);
376 return 0; 82 return 0;
377} 83}
378 84
379static int at91_aic5_irq_map(struct irq_domain *h, unsigned int virq, 85#ifdef CONFIG_PM
380 irq_hw_number_t hw)
381{
382 at91_aic_write(AT91_AIC5_SSR, hw & AT91_AIC5_INTSEL_MSK);
383
384 /* Put virq number in Source Vector Register */
385 at91_aic_write(AT91_AIC5_SVR, virq);
386
387 /* Active Low interrupt, with priority */
388 at91_aic_write(AT91_AIC5_SMR,
389 AT91_AIC_SRCTYPE_LOW | at91_aic_irq_priorities[hw]);
390
391 irq_set_chip_and_handler(virq, &at91_aic_chip, handle_fasteoi_irq);
392 set_irq_flags(virq, IRQF_VALID | IRQF_PROBE);
393 86
394 return 0; 87static u32 wakeups;
395} 88static u32 backups;
396 89
397static int at91_aic_irq_domain_xlate(struct irq_domain *d, struct device_node *ctrlr, 90static int at91_aic_set_wake(struct irq_data *d, unsigned value)
398 const u32 *intspec, unsigned int intsize,
399 irq_hw_number_t *out_hwirq, unsigned int *out_type)
400{ 91{
401 if (WARN_ON(intsize < 3)) 92 if (unlikely(d->irq >= 32))
402 return -EINVAL;
403 if (WARN_ON(intspec[0] >= n_irqs))
404 return -EINVAL;
405 if (WARN_ON((intspec[2] < AT91_AIC_IRQ_MIN_PRIORITY)
406 || (intspec[2] > AT91_AIC_IRQ_MAX_PRIORITY)))
407 return -EINVAL; 93 return -EINVAL;
408 94
409 *out_hwirq = intspec[0]; 95 if (value)
410 *out_type = intspec[1] & IRQ_TYPE_SENSE_MASK; 96 wakeups |= (1 << d->irq);
411 at91_aic_irq_priorities[*out_hwirq] = intspec[2]; 97 else
98 wakeups &= ~(1 << d->irq);
412 99
413 return 0; 100 return 0;
414} 101}
415 102
416static struct irq_domain_ops at91_aic_irq_ops = { 103void at91_irq_suspend(void)
417 .map = at91_aic_irq_map,
418 .xlate = at91_aic_irq_domain_xlate,
419};
420
421int __init at91_aic_of_common_init(struct device_node *node,
422 struct device_node *parent)
423{ 104{
424 struct property *prop; 105 backups = at91_sys_read(AT91_AIC_IMR);
425 const __be32 *p; 106 at91_sys_write(AT91_AIC_IDCR, backups);
426 u32 val; 107 at91_sys_write(AT91_AIC_IECR, wakeups);
427
428 at91_extern_irq = kzalloc(BITS_TO_LONGS(n_irqs)
429 * sizeof(*at91_extern_irq), GFP_KERNEL);
430 if (!at91_extern_irq)
431 return -ENOMEM;
432
433 if (at91_aic_pm_init()) {
434 kfree(at91_extern_irq);
435 return -ENOMEM;
436 }
437
438 at91_aic_irq_priorities = kzalloc(n_irqs
439 * sizeof(*at91_aic_irq_priorities),
440 GFP_KERNEL);
441 if (!at91_aic_irq_priorities)
442 return -ENOMEM;
443
444 at91_aic_base = of_iomap(node, 0);
445 at91_aic_np = node;
446
447 at91_aic_domain = irq_domain_add_linear(at91_aic_np, n_irqs,
448 &at91_aic_irq_ops, NULL);
449 if (!at91_aic_domain)
450 panic("Unable to add AIC irq domain (DT)\n");
451
452 of_property_for_each_u32(node, "atmel,external-irqs", prop, p, val) {
453 if (val >= n_irqs)
454 pr_warn("AIC: external irq %d >= %d skip it\n",
455 val, n_irqs);
456 else
457 set_bit(val, at91_extern_irq);
458 }
459
460 irq_set_default_host(at91_aic_domain);
461
462 return 0;
463} 108}
464 109
465int __init at91_aic_of_init(struct device_node *node, 110void at91_irq_resume(void)
466 struct device_node *parent)
467{ 111{
468 int err; 112 at91_sys_write(AT91_AIC_IDCR, wakeups);
469 113 at91_sys_write(AT91_AIC_IECR, backups);
470 err = at91_aic_of_common_init(node, parent);
471 if (err)
472 return err;
473
474 at91_aic_hw_init(n_irqs);
475
476 return 0;
477} 114}
478 115
479int __init at91_aic5_of_init(struct device_node *node, 116#else
480 struct device_node *parent) 117#define at91_aic_set_wake NULL
481{
482 int err;
483
484 at91_aic_caps |= AT91_AIC_CAP_AIC5;
485 n_irqs = NR_AIC5_IRQS;
486 at91_aic_chip.irq_ack = at91_aic5_mask_irq;
487 at91_aic_chip.irq_mask = at91_aic5_mask_irq;
488 at91_aic_chip.irq_unmask = at91_aic5_unmask_irq;
489 at91_aic_chip.irq_eoi = at91_aic5_eoi;
490 at91_aic_irq_ops.map = at91_aic5_irq_map;
491
492 err = at91_aic_of_common_init(node, parent);
493 if (err)
494 return err;
495
496 at91_aic5_hw_init(n_irqs);
497
498 return 0;
499}
500#endif 118#endif
501 119
120static struct irq_chip at91_aic_chip = {
121 .name = "AIC",
122 .irq_ack = at91_aic_mask_irq,
123 .irq_mask = at91_aic_mask_irq,
124 .irq_unmask = at91_aic_unmask_irq,
125 .irq_set_type = at91_aic_set_type,
126 .irq_set_wake = at91_aic_set_wake,
127};
128
502/* 129/*
503 * Initialize the AIC interrupt controller. 130 * Initialize the AIC interrupt controller.
504 */ 131 */
505void __init at91_aic_init(unsigned int *priority, unsigned int ext_irq_mask) 132void __init at91_aic_init(unsigned int priority[NR_AIC_IRQS])
506{ 133{
507 unsigned int i; 134 unsigned int i;
508 int irq_base;
509
510 at91_extern_irq = kzalloc(BITS_TO_LONGS(n_irqs)
511 * sizeof(*at91_extern_irq), GFP_KERNEL);
512
513 if (at91_aic_pm_init() || at91_extern_irq == NULL)
514 panic("Unable to allocate bit maps\n");
515
516 *at91_extern_irq = ext_irq_mask;
517
518 at91_aic_base = ioremap(AT91_AIC, 512);
519 if (!at91_aic_base)
520 panic("Unable to ioremap AIC registers\n");
521
522 /* Add irq domain for AIC */
523 irq_base = irq_alloc_descs(-1, 0, n_irqs, 0);
524 if (irq_base < 0) {
525 WARN(1, "Cannot allocate irq_descs, assuming pre-allocated\n");
526 irq_base = 0;
527 }
528 at91_aic_domain = irq_domain_add_legacy(at91_aic_np, n_irqs,
529 irq_base, 0,
530 &irq_domain_simple_ops, NULL);
531
532 if (!at91_aic_domain)
533 panic("Unable to add AIC irq domain\n");
534
535 irq_set_default_host(at91_aic_domain);
536 135
537 /* 136 /*
538 * The IVR is used by macro get_irqnr_and_base to read and verify. 137 * The IVR is used by macro get_irqnr_and_base to read and verify.
539 * The irq number is NR_AIC_IRQS when a spurious interrupt has occurred. 138 * The irq number is NR_AIC_IRQS when a spurious interrupt has occurred.
540 */ 139 */
541 for (i = 0; i < n_irqs; i++) { 140 for (i = 0; i < NR_AIC_IRQS; i++) {
542 /* Put hardware irq number in Source Vector Register: */ 141 /* Put irq number in Source Vector Register: */
543 at91_aic_write(AT91_AIC_SVR(i), NR_IRQS_LEGACY + i); 142 at91_sys_write(AT91_AIC_SVR(i), i);
544 /* Active Low interrupt, with the specified priority */ 143 /* Active Low interrupt, with the specified priority */
545 at91_aic_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]); 144 at91_sys_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]);
546 irq_set_chip_and_handler(NR_IRQS_LEGACY + i, &at91_aic_chip, handle_fasteoi_irq); 145
146 irq_set_chip_and_handler(i, &at91_aic_chip, handle_level_irq);
547 set_irq_flags(i, IRQF_VALID | IRQF_PROBE); 147 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
148
149 /* Perform 8 End Of Interrupt Command to make sure AIC will not Lock out nIRQ */
150 if (i < 8)
151 at91_sys_write(AT91_AIC_EOICR, 0);
548 } 152 }
549 153
550 at91_aic_hw_init(n_irqs); 154 /*
155 * Spurious Interrupt ID in Spurious Vector Register is NR_AIC_IRQS
156 * When there is no current interrupt, the IRQ Vector Register reads the value stored in AIC_SPU
157 */
158 at91_sys_write(AT91_AIC_SPU, NR_AIC_IRQS);
159
160 /* No debugging in AIC: Debug (Protect) Control Register */
161 at91_sys_write(AT91_AIC_DCR, 0);
162
163 /* Disable and clear all interrupts initially */
164 at91_sys_write(AT91_AIC_IDCR, 0xFFFFFFFF);
165 at91_sys_write(AT91_AIC_ICCR, 0xFFFFFFFF);
551} 166}
diff --git a/arch/arm/mach-at91/leds.c b/arch/arm/mach-at91/leds.c
index 3e22978b554..0415a839e1a 100644
--- a/arch/arm/mach-at91/leds.c
+++ b/arch/arm/mach-at91/leds.c
@@ -9,13 +9,13 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10*/ 10*/
11 11
12#include <linux/gpio.h>
13#include <linux/kernel.h> 12#include <linux/kernel.h>
14#include <linux/module.h> 13#include <linux/module.h>
15#include <linux/init.h> 14#include <linux/init.h>
16#include <linux/platform_device.h> 15#include <linux/platform_device.h>
17 16
18#include "board.h" 17#include <mach/board.h>
18#include <mach/gpio.h>
19 19
20 20
21/* ------------------------------------------------------------------------- */ 21/* ------------------------------------------------------------------------- */
@@ -90,3 +90,108 @@ void __init at91_pwm_leds(struct gpio_led *leds, int nr)
90#else 90#else
91void __init at91_pwm_leds(struct gpio_led *leds, int nr){} 91void __init at91_pwm_leds(struct gpio_led *leds, int nr){}
92#endif 92#endif
93
94
95/* ------------------------------------------------------------------------- */
96
97#if defined(CONFIG_LEDS)
98
99#include <asm/leds.h>
100
101/*
102 * Old ARM-specific LED framework; not fully functional when generic time is
103 * in use.
104 */
105
106static u8 at91_leds_cpu;
107static u8 at91_leds_timer;
108
109static inline void at91_led_on(unsigned int led)
110{
111 at91_set_gpio_value(led, 0);
112}
113
114static inline void at91_led_off(unsigned int led)
115{
116 at91_set_gpio_value(led, 1);
117}
118
119static inline void at91_led_toggle(unsigned int led)
120{
121 unsigned long is_off = at91_get_gpio_value(led);
122 if (is_off)
123 at91_led_on(led);
124 else
125 at91_led_off(led);
126}
127
128
129/*
130 * Handle LED events.
131 */
132static void at91_leds_event(led_event_t evt)
133{
134 unsigned long flags;
135
136 local_irq_save(flags);
137
138 switch(evt) {
139 case led_start: /* System startup */
140 at91_led_on(at91_leds_cpu);
141 break;
142
143 case led_stop: /* System stop / suspend */
144 at91_led_off(at91_leds_cpu);
145 break;
146
147#ifdef CONFIG_LEDS_TIMER
148 case led_timer: /* Every 50 timer ticks */
149 at91_led_toggle(at91_leds_timer);
150 break;
151#endif
152
153#ifdef CONFIG_LEDS_CPU
154 case led_idle_start: /* Entering idle state */
155 at91_led_off(at91_leds_cpu);
156 break;
157
158 case led_idle_end: /* Exit idle state */
159 at91_led_on(at91_leds_cpu);
160 break;
161#endif
162
163 default:
164 break;
165 }
166
167 local_irq_restore(flags);
168}
169
170
171static int __init leds_init(void)
172{
173 if (!at91_leds_timer || !at91_leds_cpu)
174 return -ENODEV;
175
176 leds_event = at91_leds_event;
177
178 leds_event(led_start);
179 return 0;
180}
181
182__initcall(leds_init);
183
184
185void __init at91_init_leds(u8 cpu_led, u8 timer_led)
186{
187 /* Enable GPIO to access the LEDs */
188 at91_set_gpio_output(cpu_led, 1);
189 at91_set_gpio_output(timer_led, 1);
190
191 at91_leds_cpu = cpu_led;
192 at91_leds_timer = timer_led;
193}
194
195#else
196void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
197#endif
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index adb6db888a1..4159eca7894 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -10,7 +10,6 @@
10 * (at your option) any later version. 10 * (at your option) any later version.
11 */ 11 */
12 12
13#include <linux/gpio.h>
14#include <linux/suspend.h> 13#include <linux/suspend.h>
15#include <linux/sched.h> 14#include <linux/sched.h>
16#include <linux/proc_fs.h> 15#include <linux/proc_fs.h>
@@ -26,18 +25,19 @@
26#include <asm/mach/irq.h> 25#include <asm/mach/irq.h>
27 26
28#include <mach/at91_pmc.h> 27#include <mach/at91_pmc.h>
28#include <mach/gpio.h>
29#include <mach/cpu.h> 29#include <mach/cpu.h>
30 30
31#include "at91_aic.h"
32#include "generic.h" 31#include "generic.h"
33#include "pm.h" 32#include "pm.h"
34 33
35/* 34/*
36 * Show the reason for the previous system reset. 35 * Show the reason for the previous system reset.
37 */ 36 */
37#if defined(AT91_SHDWC)
38 38
39#include "at91_rstc.h" 39#include <mach/at91_rstc.h>
40#include "at91_shdwc.h" 40#include <mach/at91_shdwc.h>
41 41
42static void __init show_reset_status(void) 42static void __init show_reset_status(void)
43{ 43{
@@ -58,11 +58,8 @@ static void __init show_reset_status(void)
58 char *reason, *r2 = reset; 58 char *reason, *r2 = reset;
59 u32 reset_type, wake_type; 59 u32 reset_type, wake_type;
60 60
61 if (!at91_shdwc_base || !at91_rstc_base) 61 reset_type = at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_RSTTYP;
62 return; 62 wake_type = at91_sys_read(AT91_SHDW_SR);
63
64 reset_type = at91_rstc_read(AT91_RSTC_SR) & AT91_RSTC_RSTTYP;
65 wake_type = at91_shdwc_read(AT91_SHDW_SR);
66 63
67 switch (reset_type) { 64 switch (reset_type) {
68 case AT91_RSTC_RSTTYP_GENERAL: 65 case AT91_RSTC_RSTTYP_GENERAL:
@@ -102,6 +99,10 @@ static void __init show_reset_status(void)
102 } 99 }
103 pr_info("AT91: Starting after %s %s\n", reason, r2); 100 pr_info("AT91: Starting after %s %s\n", reason, r2);
104} 101}
102#else
103static void __init show_reset_status(void) {}
104#endif
105
105 106
106static int at91_pm_valid_state(suspend_state_t state) 107static int at91_pm_valid_state(suspend_state_t state)
107{ 108{
@@ -137,7 +138,7 @@ static int at91_pm_verify_clocks(void)
137 unsigned long scsr; 138 unsigned long scsr;
138 int i; 139 int i;
139 140
140 scsr = at91_pmc_read(AT91_PMC_SCSR); 141 scsr = at91_sys_read(AT91_PMC_SCSR);
141 142
142 /* USB must not be using PLLB */ 143 /* USB must not be using PLLB */
143 if (cpu_is_at91rm9200()) { 144 if (cpu_is_at91rm9200()) {
@@ -151,11 +152,14 @@ static int at91_pm_verify_clocks(void)
151 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n"); 152 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
152 return 0; 153 return 0;
153 } 154 }
155 } else if (cpu_is_at91cap9()) {
156 if ((scsr & AT91CAP9_PMC_UHP) != 0) {
157 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
158 return 0;
159 }
154 } 160 }
155 161
156 if (!IS_ENABLED(CONFIG_AT91_PROGRAMMABLE_CLOCKS)) 162#ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS
157 return 1;
158
159 /* PCK0..PCK3 must be disabled, or configured to use clk32k */ 163 /* PCK0..PCK3 must be disabled, or configured to use clk32k */
160 for (i = 0; i < 4; i++) { 164 for (i = 0; i < 4; i++) {
161 u32 css; 165 u32 css;
@@ -163,12 +167,13 @@ static int at91_pm_verify_clocks(void)
163 if ((scsr & (AT91_PMC_PCK0 << i)) == 0) 167 if ((scsr & (AT91_PMC_PCK0 << i)) == 0)
164 continue; 168 continue;
165 169
166 css = at91_pmc_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS; 170 css = at91_sys_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
167 if (css != AT91_PMC_CSS_SLOW) { 171 if (css != AT91_PMC_CSS_SLOW) {
168 pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css); 172 pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css);
169 return 0; 173 return 0;
170 } 174 }
171 } 175 }
176#endif
172 177
173 return 1; 178 return 1;
174} 179}
@@ -190,27 +195,27 @@ int at91_suspend_entering_slow_clock(void)
190EXPORT_SYMBOL(at91_suspend_entering_slow_clock); 195EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
191 196
192 197
193static void (*slow_clock)(void __iomem *pmc, void __iomem *ramc0, 198static void (*slow_clock)(void);
194 void __iomem *ramc1, int memctrl);
195 199
196#ifdef CONFIG_AT91_SLOW_CLOCK 200#ifdef CONFIG_AT91_SLOW_CLOCK
197extern void at91_slow_clock(void __iomem *pmc, void __iomem *ramc0, 201extern void at91_slow_clock(void);
198 void __iomem *ramc1, int memctrl);
199extern u32 at91_slow_clock_sz; 202extern u32 at91_slow_clock_sz;
200#endif 203#endif
201 204
205
202static int at91_pm_enter(suspend_state_t state) 206static int at91_pm_enter(suspend_state_t state)
203{ 207{
208 u32 saved_lpr;
204 at91_gpio_suspend(); 209 at91_gpio_suspend();
205 at91_irq_suspend(); 210 at91_irq_suspend();
206 211
207 pr_debug("AT91: PM - wake mask %08x, pm state %d\n", 212 pr_debug("AT91: PM - wake mask %08x, pm state %d\n",
208 /* remember all the always-wake irqs */ 213 /* remember all the always-wake irqs */
209 (at91_pmc_read(AT91_PMC_PCSR) 214 (at91_sys_read(AT91_PMC_PCSR)
210 | (1 << AT91_ID_FIQ) 215 | (1 << AT91_ID_FIQ)
211 | (1 << AT91_ID_SYS) 216 | (1 << AT91_ID_SYS)
212 | (at91_extern_irq)) 217 | (at91_extern_irq))
213 & at91_aic_read(AT91_AIC_IMR), 218 & at91_sys_read(AT91_AIC_IMR),
214 state); 219 state);
215 220
216 switch (state) { 221 switch (state) {
@@ -231,18 +236,11 @@ static int at91_pm_enter(suspend_state_t state)
231 * turning off the main oscillator; reverse on wakeup. 236 * turning off the main oscillator; reverse on wakeup.
232 */ 237 */
233 if (slow_clock) { 238 if (slow_clock) {
234 int memctrl = AT91_MEMCTRL_SDRAMC;
235
236 if (cpu_is_at91rm9200())
237 memctrl = AT91_MEMCTRL_MC;
238 else if (cpu_is_at91sam9g45())
239 memctrl = AT91_MEMCTRL_DDRSDR;
240#ifdef CONFIG_AT91_SLOW_CLOCK 239#ifdef CONFIG_AT91_SLOW_CLOCK
241 /* copy slow_clock handler to SRAM, and call it */ 240 /* copy slow_clock handler to SRAM, and call it */
242 memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz); 241 memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
243#endif 242#endif
244 slow_clock(at91_pmc_base, at91_ramc_base[0], 243 slow_clock();
245 at91_ramc_base[1], memctrl);
246 break; 244 break;
247 } else { 245 } else {
248 pr_info("AT91: PM - no slow clock mode enabled ...\n"); 246 pr_info("AT91: PM - no slow clock mode enabled ...\n");
@@ -263,12 +261,16 @@ static int at91_pm_enter(suspend_state_t state)
263 * For ARM 926 based chips, this requirement is weaker 261 * For ARM 926 based chips, this requirement is weaker
264 * as at91sam9 can access a RAM in self-refresh mode. 262 * as at91sam9 can access a RAM in self-refresh mode.
265 */ 263 */
266 if (cpu_is_at91rm9200()) 264 asm volatile ( "mov r0, #0\n\t"
267 at91rm9200_standby(); 265 "b 1f\n\t"
268 else if (cpu_is_at91sam9g45()) 266 ".align 5\n\t"
269 at91sam9g45_standby(); 267 "1: mcr p15, 0, r0, c7, c10, 4\n\t"
270 else 268 : /* no output */
271 at91sam9_standby(); 269 : /* no input */
270 : "r0");
271 saved_lpr = sdram_selfrefresh_enable();
272 wait_for_interrupt_enable();
273 sdram_selfrefresh_disable(saved_lpr);
272 break; 274 break;
273 275
274 case PM_SUSPEND_ON: 276 case PM_SUSPEND_ON:
@@ -281,7 +283,7 @@ static int at91_pm_enter(suspend_state_t state)
281 } 283 }
282 284
283 pr_debug("AT91: PM - wakeup %08x\n", 285 pr_debug("AT91: PM - wakeup %08x\n",
284 at91_aic_read(AT91_AIC_IPR) & at91_aic_read(AT91_AIC_IMR)); 286 at91_sys_read(AT91_AIC_IPR) & at91_sys_read(AT91_AIC_IMR));
285 287
286error: 288error:
287 target_state = PM_SUSPEND_ON; 289 target_state = PM_SUSPEND_ON;
@@ -314,9 +316,10 @@ static int __init at91_pm_init(void)
314 316
315 pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : "")); 317 pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
316 318
319#ifdef CONFIG_ARCH_AT91RM9200
317 /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */ 320 /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
318 if (cpu_is_at91rm9200()) 321 at91_sys_write(AT91_SDRAMC_LPR, 0);
319 at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0); 322#endif
320 323
321 suspend_set_ops(&at91_pm_ops); 324 suspend_set_ops(&at91_pm_ops);
322 325
diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
index 38f467c6b71..ce9a2069911 100644
--- a/arch/arm/mach-at91/pm.h
+++ b/arch/arm/mach-at91/pm.h
@@ -1,18 +1,5 @@
1/* 1#ifdef CONFIG_ARCH_AT91RM9200
2 * AT91 Power Management 2#include <mach/at91rm9200_mc.h>
3 *
4 * Copyright (C) 2005 David Brownell
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#ifndef __ARCH_ARM_MACH_AT91_PM
12#define __ARCH_ARM_MACH_AT91_PM
13
14#include <mach/at91_ramc.h>
15#include <mach/at91rm9200_sdramc.h>
16 3
17/* 4/*
18 * The AT91RM9200 goes into self-refresh mode with this command, and will 5 * The AT91RM9200 goes into self-refresh mode with this command, and will
@@ -24,33 +11,51 @@
24 * still in self-refresh is "not recommended", but seems to work. 11 * still in self-refresh is "not recommended", but seems to work.
25 */ 12 */
26 13
27static inline void at91rm9200_standby(void) 14static inline u32 sdram_selfrefresh_enable(void)
15{
16 u32 saved_lpr = at91_sys_read(AT91_SDRAMC_LPR);
17
18 at91_sys_write(AT91_SDRAMC_LPR, 0);
19 at91_sys_write(AT91_SDRAMC_SRR, 1);
20 return saved_lpr;
21}
22
23#define sdram_selfrefresh_disable(saved_lpr) at91_sys_write(AT91_SDRAMC_LPR, saved_lpr)
24#define wait_for_interrupt_enable() asm volatile ("mcr p15, 0, %0, c7, c0, 4" \
25 : : "r" (0))
26
27#elif defined(CONFIG_ARCH_AT91CAP9)
28#include <mach/at91cap9_ddrsdr.h>
29
30
31static inline u32 sdram_selfrefresh_enable(void)
28{ 32{
29 u32 lpr = at91_ramc_read(0, AT91RM9200_SDRAMC_LPR); 33 u32 saved_lpr, lpr;
30 34
31 asm volatile( 35 saved_lpr = at91_ramc_read(0, AT91_DDRSDRC_LPR);
32 "b 1f\n\t" 36
33 ".align 5\n\t" 37 lpr = saved_lpr & ~AT91_DDRSDRC_LPCB;
34 "1: mcr p15, 0, %0, c7, c10, 4\n\t" 38 at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr | AT91_DDRSDRC_LPCB_SELF_REFRESH);
35 " str %0, [%1, %2]\n\t" 39 return saved_lpr;
36 " str %3, [%1, %4]\n\t"
37 " mcr p15, 0, %0, c7, c0, 4\n\t"
38 " str %5, [%1, %2]"
39 :
40 : "r" (0), "r" (AT91_BASE_SYS), "r" (AT91RM9200_SDRAMC_LPR),
41 "r" (1), "r" (AT91RM9200_SDRAMC_SRR),
42 "r" (lpr));
43} 40}
44 41
42#define sdram_selfrefresh_disable(saved_lpr) at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr)
43#define wait_for_interrupt_enable() cpu_do_idle()
44
45#elif defined(CONFIG_ARCH_AT91SAM9G45)
46#include <mach/at91sam9_ddrsdr.h>
47
45/* We manage both DDRAM/SDRAM controllers, we need more than one value to 48/* We manage both DDRAM/SDRAM controllers, we need more than one value to
46 * remember. 49 * remember.
47 */ 50 */
48static inline void at91sam9g45_standby(void) 51static u32 saved_lpr1;
52
53static inline u32 sdram_selfrefresh_enable(void)
49{ 54{
50 /* Those two values allow us to delay self-refresh activation 55 /* Those tow values allow us to delay self-refresh activation
51 * to the maximum. */ 56 * to the maximum. */
52 u32 lpr0, lpr1; 57 u32 lpr0, lpr1;
53 u32 saved_lpr0, saved_lpr1; 58 u32 saved_lpr0;
54 59
55 saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR); 60 saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
56 lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB; 61 lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
@@ -64,13 +69,20 @@ static inline void at91sam9g45_standby(void)
64 at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0); 69 at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
65 at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1); 70 at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
66 71
67 cpu_do_idle(); 72 return saved_lpr0;
68
69 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
70 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
71} 73}
72 74
73#ifdef CONFIG_SOC_AT91SAM9263 75#define sdram_selfrefresh_disable(saved_lpr0) \
76 do { \
77 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); \
78 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); \
79 } while (0)
80#define wait_for_interrupt_enable() cpu_do_idle()
81
82#else
83#include <mach/at91sam9_sdramc.h>
84
85#ifdef CONFIG_ARCH_AT91SAM9263
74/* 86/*
75 * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use; 87 * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;
76 * handle those cases both here and in the Suspend-To-RAM support. 88 * handle those cases both here and in the Suspend-To-RAM support.
@@ -78,19 +90,18 @@ static inline void at91sam9g45_standby(void)
78#warning Assuming EB1 SDRAM controller is *NOT* used 90#warning Assuming EB1 SDRAM controller is *NOT* used
79#endif 91#endif
80 92
81static inline void at91sam9_standby(void) 93static inline u32 sdram_selfrefresh_enable(void)
82{ 94{
83 u32 saved_lpr, lpr; 95 u32 saved_lpr, lpr;
84 96
85 saved_lpr = at91_ramc_read(0, AT91_SDRAMC_LPR); 97 saved_lpr = at91_ramc_read(0, AT91_SDRAMC_LPR);
86 98
87 lpr = saved_lpr & ~AT91_SDRAMC_LPCB; 99 lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
88 at91_ramc_write(0, AT91_SDRAMC_LPR, lpr | 100 at91_ramc_write(0, AT91_SDRAMC_LPR, lpr | AT91_SDRAMC_LPCB_SELF_REFRESH);
89 AT91_SDRAMC_LPCB_SELF_REFRESH); 101 return saved_lpr;
90
91 cpu_do_idle();
92
93 at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr);
94} 102}
95 103
104#define sdram_selfrefresh_disable(saved_lpr) at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr)
105#define wait_for_interrupt_enable() cpu_do_idle()
106
96#endif 107#endif
diff --git a/arch/arm/mach-at91/pm_slowclock.S b/arch/arm/mach-at91/pm_slowclock.S
index 098c28ddf02..f7922a43617 100644
--- a/arch/arm/mach-at91/pm_slowclock.S
+++ b/arch/arm/mach-at91/pm_slowclock.S
@@ -15,10 +15,19 @@
15#include <linux/linkage.h> 15#include <linux/linkage.h>
16#include <mach/hardware.h> 16#include <mach/hardware.h>
17#include <mach/at91_pmc.h> 17#include <mach/at91_pmc.h>
18#include <mach/at91_ramc.h> 18
19#if defined(CONFIG_ARCH_AT91RM9200)
20#include <mach/at91rm9200_mc.h>
21#elif defined(CONFIG_ARCH_AT91CAP9)
22#include <mach/at91cap9_ddrsdr.h>
23#elif defined(CONFIG_ARCH_AT91SAM9G45)
24#include <mach/at91sam9_ddrsdr.h>
25#else
26#include <mach/at91sam9_sdramc.h>
27#endif
19 28
20 29
21#ifdef CONFIG_SOC_AT91SAM9263 30#ifdef CONFIG_ARCH_AT91SAM9263
22/* 31/*
23 * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use; 32 * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;
24 * handle those cases both here and in the Suspend-To-RAM support. 33 * handle those cases both here and in the Suspend-To-RAM support.
@@ -39,23 +48,17 @@
39#define PLLALOCK_TIMEOUT 1000 48#define PLLALOCK_TIMEOUT 1000
40#define PLLBLOCK_TIMEOUT 1000 49#define PLLBLOCK_TIMEOUT 1000
41 50
42pmc .req r0
43sdramc .req r1
44ramc1 .req r2
45memctrl .req r3
46tmp1 .req r4
47tmp2 .req r5
48 51
49/* 52/*
50 * Wait until master clock is ready (after switching master clock source) 53 * Wait until master clock is ready (after switching master clock source)
51 */ 54 */
52 .macro wait_mckrdy 55 .macro wait_mckrdy
53 mov tmp2, #MCKRDY_TIMEOUT 56 mov r4, #MCKRDY_TIMEOUT
541: sub tmp2, tmp2, #1 571: sub r4, r4, #1
55 cmp tmp2, #0 58 cmp r4, #0
56 beq 2f 59 beq 2f
57 ldr tmp1, [pmc, #AT91_PMC_SR] 60 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
58 tst tmp1, #AT91_PMC_MCKRDY 61 tst r3, #AT91_PMC_MCKRDY
59 beq 1b 62 beq 1b
602: 632:
61 .endm 64 .endm
@@ -64,12 +67,12 @@ tmp2 .req r5
64 * Wait until master oscillator has stabilized. 67 * Wait until master oscillator has stabilized.
65 */ 68 */
66 .macro wait_moscrdy 69 .macro wait_moscrdy
67 mov tmp2, #MOSCRDY_TIMEOUT 70 mov r4, #MOSCRDY_TIMEOUT
681: sub tmp2, tmp2, #1 711: sub r4, r4, #1
69 cmp tmp2, #0 72 cmp r4, #0
70 beq 2f 73 beq 2f
71 ldr tmp1, [pmc, #AT91_PMC_SR] 74 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
72 tst tmp1, #AT91_PMC_MOSCS 75 tst r3, #AT91_PMC_MOSCS
73 beq 1b 76 beq 1b
742: 772:
75 .endm 78 .endm
@@ -78,12 +81,12 @@ tmp2 .req r5
78 * Wait until PLLA has locked. 81 * Wait until PLLA has locked.
79 */ 82 */
80 .macro wait_pllalock 83 .macro wait_pllalock
81 mov tmp2, #PLLALOCK_TIMEOUT 84 mov r4, #PLLALOCK_TIMEOUT
821: sub tmp2, tmp2, #1 851: sub r4, r4, #1
83 cmp tmp2, #0 86 cmp r4, #0
84 beq 2f 87 beq 2f
85 ldr tmp1, [pmc, #AT91_PMC_SR] 88 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
86 tst tmp1, #AT91_PMC_LOCKA 89 tst r3, #AT91_PMC_LOCKA
87 beq 1b 90 beq 1b
882: 912:
89 .endm 92 .endm
@@ -92,98 +95,80 @@ tmp2 .req r5
92 * Wait until PLLB has locked. 95 * Wait until PLLB has locked.
93 */ 96 */
94 .macro wait_pllblock 97 .macro wait_pllblock
95 mov tmp2, #PLLBLOCK_TIMEOUT 98 mov r4, #PLLBLOCK_TIMEOUT
961: sub tmp2, tmp2, #1 991: sub r4, r4, #1
97 cmp tmp2, #0 100 cmp r4, #0
98 beq 2f 101 beq 2f
99 ldr tmp1, [pmc, #AT91_PMC_SR] 102 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)]
100 tst tmp1, #AT91_PMC_LOCKB 103 tst r3, #AT91_PMC_LOCKB
101 beq 1b 104 beq 1b
1022: 1052:
103 .endm 106 .endm
104 107
105 .text 108 .text
106 109
107/* void at91_slow_clock(void __iomem *pmc, void __iomem *sdramc,
108 * void __iomem *ramc1, int memctrl)
109 */
110ENTRY(at91_slow_clock) 110ENTRY(at91_slow_clock)
111 /* Save registers on stack */ 111 /* Save registers on stack */
112 stmfd sp!, {r4 - r12, lr} 112 stmfd sp!, {r0 - r12, lr}
113 113
114 /* 114 /*
115 * Register usage: 115 * Register usage:
116 * R0 = Base address of AT91_PMC 116 * R1 = Base address of AT91_PMC
117 * R1 = Base address of RAM Controller (SDRAM, DDRSDR, or AT91_SYS) 117 * R2 = Base address of RAM Controller (SDRAM, DDRSDR, or AT91_SYS)
118 * R2 = Base address of second RAM Controller or 0 if not present 118 * R3 = temporary register
119 * R3 = Memory controller
120 * R4 = temporary register 119 * R4 = temporary register
121 * R5 = temporary register 120 * R5 = Base address of second RAM Controller or 0 if not present
122 */ 121 */
122 ldr r1, .at91_va_base_pmc
123 ldr r2, .at91_va_base_sdramc
124 ldr r5, .at91_va_base_ramc1
123 125
124 /* Drain write buffer */ 126 /* Drain write buffer */
125 mov tmp1, #0 127 mov r0, #0
126 mcr p15, 0, tmp1, c7, c10, 4 128 mcr p15, 0, r0, c7, c10, 4
127
128 cmp memctrl, #AT91_MEMCTRL_MC
129 bne ddr_sr_enable
130 129
131 /* 130#ifdef CONFIG_ARCH_AT91RM9200
132 * at91rm9200 Memory controller
133 */
134 /* Put SDRAM in self-refresh mode */ 131 /* Put SDRAM in self-refresh mode */
135 mov tmp1, #1 132 mov r3, #1
136 str tmp1, [sdramc, #AT91RM9200_SDRAMC_SRR] 133 str r3, [r2, #AT91_SDRAMC_SRR]
137 b sdr_sr_done 134#elif defined(CONFIG_ARCH_AT91CAP9) \
138 135 || defined(CONFIG_ARCH_AT91SAM9G45)
139 /*
140 * DDRSDR Memory controller
141 */
142ddr_sr_enable:
143 cmp memctrl, #AT91_MEMCTRL_DDRSDR
144 bne sdr_sr_enable
145 136
146 /* prepare for DDRAM self-refresh mode */ 137 /* prepare for DDRAM self-refresh mode */
147 ldr tmp1, [sdramc, #AT91_DDRSDRC_LPR] 138 ldr r3, [r2, #AT91_DDRSDRC_LPR]
148 str tmp1, .saved_sam9_lpr 139 str r3, .saved_sam9_lpr
149 bic tmp1, #AT91_DDRSDRC_LPCB 140 bic r3, #AT91_DDRSDRC_LPCB
150 orr tmp1, #AT91_DDRSDRC_LPCB_SELF_REFRESH 141 orr r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH
151 142
152 /* figure out if we use the second ram controller */ 143 /* figure out if we use the second ram controller */
153 cmp ramc1, #0 144 cmp r5, #0
154 ldrne tmp2, [ramc1, #AT91_DDRSDRC_LPR] 145 ldrne r4, [r5, #AT91_DDRSDRC_LPR]
155 strne tmp2, .saved_sam9_lpr1 146 strne r4, .saved_sam9_lpr1
156 bicne tmp2, #AT91_DDRSDRC_LPCB 147 bicne r4, #AT91_DDRSDRC_LPCB
157 orrne tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH 148 orrne r4, #AT91_DDRSDRC_LPCB_SELF_REFRESH
158 149
159 /* Enable DDRAM self-refresh mode */ 150 /* Enable DDRAM self-refresh mode */
160 str tmp1, [sdramc, #AT91_DDRSDRC_LPR] 151 str r3, [r2, #AT91_DDRSDRC_LPR]
161 strne tmp2, [ramc1, #AT91_DDRSDRC_LPR] 152 strne r4, [r5, #AT91_DDRSDRC_LPR]
162 153#else
163 b sdr_sr_done
164
165 /*
166 * SDRAMC Memory controller
167 */
168sdr_sr_enable:
169 /* Enable SDRAM self-refresh mode */ 154 /* Enable SDRAM self-refresh mode */
170 ldr tmp1, [sdramc, #AT91_SDRAMC_LPR] 155 ldr r3, [r2, #AT91_SDRAMC_LPR]
171 str tmp1, .saved_sam9_lpr 156 str r3, .saved_sam9_lpr
172 157
173 bic tmp1, #AT91_SDRAMC_LPCB 158 bic r3, #AT91_SDRAMC_LPCB
174 orr tmp1, #AT91_SDRAMC_LPCB_SELF_REFRESH 159 orr r3, #AT91_SDRAMC_LPCB_SELF_REFRESH
175 str tmp1, [sdramc, #AT91_SDRAMC_LPR] 160 str r3, [r2, #AT91_SDRAMC_LPR]
161#endif
176 162
177sdr_sr_done:
178 /* Save Master clock setting */ 163 /* Save Master clock setting */
179 ldr tmp1, [pmc, #AT91_PMC_MCKR] 164 ldr r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
180 str tmp1, .saved_mckr 165 str r3, .saved_mckr
181 166
182 /* 167 /*
183 * Set the Master clock source to slow clock 168 * Set the Master clock source to slow clock
184 */ 169 */
185 bic tmp1, tmp1, #AT91_PMC_CSS 170 bic r3, r3, #AT91_PMC_CSS
186 str tmp1, [pmc, #AT91_PMC_MCKR] 171 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
187 172
188 wait_mckrdy 173 wait_mckrdy
189 174
@@ -193,61 +178,61 @@ sdr_sr_done:
193 * 178 *
194 * See AT91RM9200 errata #27 and #28 for details. 179 * See AT91RM9200 errata #27 and #28 for details.
195 */ 180 */
196 mov tmp1, #0 181 mov r3, #0
197 str tmp1, [pmc, #AT91_PMC_MCKR] 182 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
198 183
199 wait_mckrdy 184 wait_mckrdy
200#endif 185#endif
201 186
202 /* Save PLLA setting and disable it */ 187 /* Save PLLA setting and disable it */
203 ldr tmp1, [pmc, #AT91_CKGR_PLLAR] 188 ldr r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)]
204 str tmp1, .saved_pllar 189 str r3, .saved_pllar
205 190
206 mov tmp1, #AT91_PMC_PLLCOUNT 191 mov r3, #AT91_PMC_PLLCOUNT
207 orr tmp1, tmp1, #(1 << 29) /* bit 29 always set */ 192 orr r3, r3, #(1 << 29) /* bit 29 always set */
208 str tmp1, [pmc, #AT91_CKGR_PLLAR] 193 str r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)]
209 194
210 /* Save PLLB setting and disable it */ 195 /* Save PLLB setting and disable it */
211 ldr tmp1, [pmc, #AT91_CKGR_PLLBR] 196 ldr r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)]
212 str tmp1, .saved_pllbr 197 str r3, .saved_pllbr
213 198
214 mov tmp1, #AT91_PMC_PLLCOUNT 199 mov r3, #AT91_PMC_PLLCOUNT
215 str tmp1, [pmc, #AT91_CKGR_PLLBR] 200 str r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)]
216 201
217 /* Turn off the main oscillator */ 202 /* Turn off the main oscillator */
218 ldr tmp1, [pmc, #AT91_CKGR_MOR] 203 ldr r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
219 bic tmp1, tmp1, #AT91_PMC_MOSCEN 204 bic r3, r3, #AT91_PMC_MOSCEN
220 str tmp1, [pmc, #AT91_CKGR_MOR] 205 str r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
221 206
222 /* Wait for interrupt */ 207 /* Wait for interrupt */
223 mcr p15, 0, tmp1, c7, c0, 4 208 mcr p15, 0, r0, c7, c0, 4
224 209
225 /* Turn on the main oscillator */ 210 /* Turn on the main oscillator */
226 ldr tmp1, [pmc, #AT91_CKGR_MOR] 211 ldr r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
227 orr tmp1, tmp1, #AT91_PMC_MOSCEN 212 orr r3, r3, #AT91_PMC_MOSCEN
228 str tmp1, [pmc, #AT91_CKGR_MOR] 213 str r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)]
229 214
230 wait_moscrdy 215 wait_moscrdy
231 216
232 /* Restore PLLB setting */ 217 /* Restore PLLB setting */
233 ldr tmp1, .saved_pllbr 218 ldr r3, .saved_pllbr
234 str tmp1, [pmc, #AT91_CKGR_PLLBR] 219 str r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)]
235 220
236 tst tmp1, #(AT91_PMC_MUL & 0xff0000) 221 tst r3, #(AT91_PMC_MUL & 0xff0000)
237 bne 1f 222 bne 1f
238 tst tmp1, #(AT91_PMC_MUL & ~0xff0000) 223 tst r3, #(AT91_PMC_MUL & ~0xff0000)
239 beq 2f 224 beq 2f
2401: 2251:
241 wait_pllblock 226 wait_pllblock
2422: 2272:
243 228
244 /* Restore PLLA setting */ 229 /* Restore PLLA setting */
245 ldr tmp1, .saved_pllar 230 ldr r3, .saved_pllar
246 str tmp1, [pmc, #AT91_CKGR_PLLAR] 231 str r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)]
247 232
248 tst tmp1, #(AT91_PMC_MUL & 0xff0000) 233 tst r3, #(AT91_PMC_MUL & 0xff0000)
249 bne 3f 234 bne 3f
250 tst tmp1, #(AT91_PMC_MUL & ~0xff0000) 235 tst r3, #(AT91_PMC_MUL & ~0xff0000)
251 beq 4f 236 beq 4f
2523: 2373:
253 wait_pllalock 238 wait_pllalock
@@ -260,11 +245,11 @@ sdr_sr_done:
260 * 245 *
261 * See AT91RM9200 errata #27 and #28 for details. 246 * See AT91RM9200 errata #27 and #28 for details.
262 */ 247 */
263 ldr tmp1, .saved_mckr 248 ldr r3, .saved_mckr
264 tst tmp1, #AT91_PMC_PRES 249 tst r3, #AT91_PMC_PRES
265 beq 2f 250 beq 2f
266 and tmp1, tmp1, #AT91_PMC_PRES 251 and r3, r3, #AT91_PMC_PRES
267 str tmp1, [pmc, #AT91_PMC_MCKR] 252 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
268 253
269 wait_mckrdy 254 wait_mckrdy
270#endif 255#endif
@@ -272,45 +257,32 @@ sdr_sr_done:
272 /* 257 /*
273 * Restore master clock setting 258 * Restore master clock setting
274 */ 259 */
2752: ldr tmp1, .saved_mckr 2602: ldr r3, .saved_mckr
276 str tmp1, [pmc, #AT91_PMC_MCKR] 261 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)]
277 262
278 wait_mckrdy 263 wait_mckrdy
279 264
280 /* 265#ifdef CONFIG_ARCH_AT91RM9200
281 * at91rm9200 Memory controller 266 /* Do nothing - self-refresh is automatically disabled. */
282 * Do nothing - self-refresh is automatically disabled. 267#elif defined(CONFIG_ARCH_AT91CAP9) \
283 */ 268 || defined(CONFIG_ARCH_AT91SAM9G45)
284 cmp memctrl, #AT91_MEMCTRL_MC
285 beq ram_restored
286
287 /*
288 * DDRSDR Memory controller
289 */
290 cmp memctrl, #AT91_MEMCTRL_DDRSDR
291 bne sdr_en_restore
292 /* Restore LPR on AT91 with DDRAM */ 269 /* Restore LPR on AT91 with DDRAM */
293 ldr tmp1, .saved_sam9_lpr 270 ldr r3, .saved_sam9_lpr
294 str tmp1, [sdramc, #AT91_DDRSDRC_LPR] 271 str r3, [r2, #AT91_DDRSDRC_LPR]
295 272
296 /* if we use the second ram controller */ 273 /* if we use the second ram controller */
297 cmp ramc1, #0 274 cmp r5, #0
298 ldrne tmp2, .saved_sam9_lpr1 275 ldrne r4, .saved_sam9_lpr1
299 strne tmp2, [ramc1, #AT91_DDRSDRC_LPR] 276 strne r4, [r5, #AT91_DDRSDRC_LPR]
300
301 b ram_restored
302 277
303 /* 278#else
304 * SDRAMC Memory controller
305 */
306sdr_en_restore:
307 /* Restore LPR on AT91 with SDRAM */ 279 /* Restore LPR on AT91 with SDRAM */
308 ldr tmp1, .saved_sam9_lpr 280 ldr r3, .saved_sam9_lpr
309 str tmp1, [sdramc, #AT91_SDRAMC_LPR] 281 str r3, [r2, #AT91_SDRAMC_LPR]
282#endif
310 283
311ram_restored:
312 /* Restore registers, and return */ 284 /* Restore registers, and return */
313 ldmfd sp!, {r4 - r12, pc} 285 ldmfd sp!, {r0 - r12, pc}
314 286
315 287
316.saved_mckr: 288.saved_mckr:
@@ -328,5 +300,27 @@ ram_restored:
328.saved_sam9_lpr1: 300.saved_sam9_lpr1:
329 .word 0 301 .word 0
330 302
303.at91_va_base_pmc:
304 .word AT91_VA_BASE_SYS + AT91_PMC
305
306#ifdef CONFIG_ARCH_AT91RM9200
307.at91_va_base_sdramc:
308 .word AT91_VA_BASE_SYS
309#elif defined(CONFIG_ARCH_AT91CAP9) \
310 || defined(CONFIG_ARCH_AT91SAM9G45)
311.at91_va_base_sdramc:
312 .word AT91_VA_BASE_SYS + AT91_DDRSDRC0
313#else
314.at91_va_base_sdramc:
315 .word AT91_VA_BASE_SYS + AT91_SDRAMC0
316#endif
317
318.at91_va_base_ramc1:
319#if defined(CONFIG_ARCH_AT91SAM9G45)
320 .word AT91_VA_BASE_SYS + AT91_DDRSDRC1
321#else
322 .word 0
323#endif
324
331ENTRY(at91_slow_clock_sz) 325ENTRY(at91_slow_clock_sz)
332 .word .-at91_slow_clock 326 .word .-at91_slow_clock
diff --git a/arch/arm/mach-at91/sam9_smc.c b/arch/arm/mach-at91/sam9_smc.c
index 99a0a1d2b7d..5eab6aa621d 100644
--- a/arch/arm/mach-at91/sam9_smc.c
+++ b/arch/arm/mach-at91/sam9_smc.c
@@ -2,7 +2,6 @@
2 * linux/arch/arm/mach-at91/sam9_smc.c 2 * linux/arch/arm/mach-at91/sam9_smc.c
3 * 3 *
4 * Copyright (C) 2008 Andrew Victor 4 * Copyright (C) 2008 Andrew Victor
5 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
6 * 5 *
7 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -11,123 +10,38 @@
11 10
12#include <linux/module.h> 11#include <linux/module.h>
13#include <linux/io.h> 12#include <linux/io.h>
14#include <linux/of.h>
15#include <linux/of_address.h>
16 13
17#include <mach/at91sam9_smc.h> 14#include <mach/at91sam9_smc.h>
18 15
19#include "sam9_smc.h" 16#include "sam9_smc.h"
20 17
21 18void __init sam9_smc_configure(int cs, struct sam9_smc_config* config)
22#define AT91_SMC_CS(id, n) (smc_base_addr[id] + ((n) * 0x10))
23
24static void __iomem *smc_base_addr[2];
25
26static void sam9_smc_cs_write_mode(void __iomem *base,
27 struct sam9_smc_config *config)
28{
29 __raw_writel(config->mode
30 | AT91_SMC_TDF_(config->tdf_cycles),
31 base + AT91_SMC_MODE);
32}
33
34void sam9_smc_write_mode(int id, int cs,
35 struct sam9_smc_config *config)
36{
37 sam9_smc_cs_write_mode(AT91_SMC_CS(id, cs), config);
38}
39
40static void sam9_smc_cs_configure(void __iomem *base,
41 struct sam9_smc_config *config)
42{
43
44 /* Setup register */
45 __raw_writel(AT91_SMC_NWESETUP_(config->nwe_setup)
46 | AT91_SMC_NCS_WRSETUP_(config->ncs_write_setup)
47 | AT91_SMC_NRDSETUP_(config->nrd_setup)
48 | AT91_SMC_NCS_RDSETUP_(config->ncs_read_setup),
49 base + AT91_SMC_SETUP);
50
51 /* Pulse register */
52 __raw_writel(AT91_SMC_NWEPULSE_(config->nwe_pulse)
53 | AT91_SMC_NCS_WRPULSE_(config->ncs_write_pulse)
54 | AT91_SMC_NRDPULSE_(config->nrd_pulse)
55 | AT91_SMC_NCS_RDPULSE_(config->ncs_read_pulse),
56 base + AT91_SMC_PULSE);
57
58 /* Cycle register */
59 __raw_writel(AT91_SMC_NWECYCLE_(config->write_cycle)
60 | AT91_SMC_NRDCYCLE_(config->read_cycle),
61 base + AT91_SMC_CYCLE);
62
63 /* Mode register */
64 sam9_smc_cs_write_mode(base, config);
65}
66
67void sam9_smc_configure(int id, int cs,
68 struct sam9_smc_config *config)
69{ 19{
70 sam9_smc_cs_configure(AT91_SMC_CS(id, cs), config);
71}
72
73static void sam9_smc_cs_read_mode(void __iomem *base,
74 struct sam9_smc_config *config)
75{
76 u32 val = __raw_readl(base + AT91_SMC_MODE);
77
78 config->mode = (val & ~AT91_SMC_NWECYCLE);
79 config->tdf_cycles = (val & AT91_SMC_NWECYCLE) >> 16 ;
80}
81
82void sam9_smc_read_mode(int id, int cs,
83 struct sam9_smc_config *config)
84{
85 sam9_smc_cs_read_mode(AT91_SMC_CS(id, cs), config);
86}
87
88static void sam9_smc_cs_read(void __iomem *base,
89 struct sam9_smc_config *config)
90{
91 u32 val;
92
93 /* Setup register */ 20 /* Setup register */
94 val = __raw_readl(base + AT91_SMC_SETUP); 21 at91_sys_write(AT91_SMC_SETUP(cs),
95 22 AT91_SMC_NWESETUP_(config->nwe_setup)
96 config->nwe_setup = val & AT91_SMC_NWESETUP; 23 | AT91_SMC_NCS_WRSETUP_(config->ncs_write_setup)
97 config->ncs_write_setup = (val & AT91_SMC_NCS_WRSETUP) >> 8; 24 | AT91_SMC_NRDSETUP_(config->nrd_setup)
98 config->nrd_setup = (val & AT91_SMC_NRDSETUP) >> 16; 25 | AT91_SMC_NCS_RDSETUP_(config->ncs_read_setup)
99 config->ncs_read_setup = (val & AT91_SMC_NCS_RDSETUP) >> 24; 26 );
100 27
101 /* Pulse register */ 28 /* Pulse register */
102 val = __raw_readl(base + AT91_SMC_PULSE); 29 at91_sys_write(AT91_SMC_PULSE(cs),
103 30 AT91_SMC_NWEPULSE_(config->nwe_pulse)
104 config->nwe_setup = val & AT91_SMC_NWEPULSE; 31 | AT91_SMC_NCS_WRPULSE_(config->ncs_write_pulse)
105 config->ncs_write_pulse = (val & AT91_SMC_NCS_WRPULSE) >> 8; 32 | AT91_SMC_NRDPULSE_(config->nrd_pulse)
106 config->nrd_pulse = (val & AT91_SMC_NRDPULSE) >> 16; 33 | AT91_SMC_NCS_RDPULSE_(config->ncs_read_pulse)
107 config->ncs_read_pulse = (val & AT91_SMC_NCS_RDPULSE) >> 24; 34 );
108 35
109 /* Cycle register */ 36 /* Cycle register */
110 val = __raw_readl(base + AT91_SMC_CYCLE); 37 at91_sys_write(AT91_SMC_CYCLE(cs),
111 38 AT91_SMC_NWECYCLE_(config->write_cycle)
112 config->write_cycle = val & AT91_SMC_NWECYCLE; 39 | AT91_SMC_NRDCYCLE_(config->read_cycle)
113 config->read_cycle = (val & AT91_SMC_NRDCYCLE) >> 16; 40 );
114 41
115 /* Mode register */ 42 /* Mode register */
116 sam9_smc_cs_read_mode(base, config); 43 at91_sys_write(AT91_SMC_MODE(cs),
117} 44 config->mode
118 45 | AT91_SMC_TDF_(config->tdf_cycles)
119void sam9_smc_read(int id, int cs, struct sam9_smc_config *config) 46 );
120{
121 sam9_smc_cs_read(AT91_SMC_CS(id, cs), config);
122}
123
124void __init at91sam9_ioremap_smc(int id, u32 addr)
125{
126 if (id > 1) {
127 pr_warn("%s: id > 2\n", __func__);
128 return;
129 }
130 smc_base_addr[id] = ioremap(addr, 512);
131 if (!smc_base_addr[id])
132 pr_warn("Impossible to ioremap smc.%d 0x%x\n", id, addr);
133} 47}
diff --git a/arch/arm/mach-at91/sam9_smc.h b/arch/arm/mach-at91/sam9_smc.h
index 3e52dcd4a59..bf72cfb3455 100644
--- a/arch/arm/mach-at91/sam9_smc.h
+++ b/arch/arm/mach-at91/sam9_smc.h
@@ -8,4 +8,26 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11extern void __init at91sam9_ioremap_smc(int id, u32 addr); 11struct sam9_smc_config {
12 /* Setup register */
13 u8 ncs_read_setup;
14 u8 nrd_setup;
15 u8 ncs_write_setup;
16 u8 nwe_setup;
17
18 /* Pulse register */
19 u8 ncs_read_pulse;
20 u8 nrd_pulse;
21 u8 ncs_write_pulse;
22 u8 nwe_pulse;
23
24 /* Cycle register */
25 u16 read_cycle;
26 u16 write_cycle;
27
28 /* Mode register */
29 u32 mode;
30 u8 tdf_cycles:4;
31};
32
33extern void __init sam9_smc_configure(int cs, struct sam9_smc_config* config);
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 9ee866ce047..aa64294c7db 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -8,11 +8,7 @@
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/io.h> 9#include <linux/io.h>
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/pm.h>
12#include <linux/of_address.h>
13#include <linux/pinctrl/machine.h>
14 11
15#include <asm/system_misc.h>
16#include <asm/mach/map.h> 12#include <asm/mach/map.h>
17 13
18#include <mach/hardware.h> 14#include <mach/hardware.h>
@@ -20,7 +16,6 @@
20#include <mach/at91_dbgu.h> 16#include <mach/at91_dbgu.h>
21#include <mach/at91_pmc.h> 17#include <mach/at91_pmc.h>
22 18
23#include "at91_shdwc.h"
24#include "soc.h" 19#include "soc.h"
25#include "generic.h" 20#include "generic.h"
26 21
@@ -32,12 +27,9 @@ EXPORT_SYMBOL(at91_soc_initdata);
32void __init at91rm9200_set_type(int type) 27void __init at91rm9200_set_type(int type)
33{ 28{
34 if (type == ARCH_REVISON_9200_PQFP) 29 if (type == ARCH_REVISON_9200_PQFP)
35 at91_soc_initdata.subtype = AT91_SOC_RM9200_PQFP;
36 else
37 at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA; 30 at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA;
38 31 else
39 pr_info("AT91: filled in soc subtype: %s\n", 32 at91_soc_initdata.subtype = AT91_SOC_RM9200_PQFP;
40 at91_get_soc_subtype(&at91_soc_initdata));
41} 33}
42 34
43void __init at91_init_irq_default(void) 35void __init at91_init_irq_default(void)
@@ -48,33 +40,19 @@ void __init at91_init_irq_default(void)
48void __init at91_init_interrupts(unsigned int *priority) 40void __init at91_init_interrupts(unsigned int *priority)
49{ 41{
50 /* Initialize the AIC interrupt controller */ 42 /* Initialize the AIC interrupt controller */
51 at91_aic_init(priority, at91_extern_irq); 43 at91_aic_init(priority);
52 44
53 /* Enable GPIO interrupts */ 45 /* Enable GPIO interrupts */
54 at91_gpio_irq_setup(); 46 at91_gpio_irq_setup();
55} 47}
56 48
57void __iomem *at91_ramc_base[2];
58EXPORT_SYMBOL_GPL(at91_ramc_base);
59
60void __init at91_ioremap_ramc(int id, u32 addr, u32 size)
61{
62 if (id < 0 || id > 1) {
63 pr_emerg("Wrong RAM controller id (%d), cannot continue\n", id);
64 BUG();
65 }
66 at91_ramc_base[id] = ioremap(addr, size);
67 if (!at91_ramc_base[id])
68 panic("Impossible to ioremap ramc.%d 0x%x\n", id, addr);
69}
70
71static struct map_desc sram_desc[2] __initdata; 49static struct map_desc sram_desc[2] __initdata;
72 50
73void __init at91_init_sram(int bank, unsigned long base, unsigned int length) 51void __init at91_init_sram(int bank, unsigned long base, unsigned int length)
74{ 52{
75 struct map_desc *desc = &sram_desc[bank]; 53 struct map_desc *desc = &sram_desc[bank];
76 54
77 desc->virtual = (unsigned long)AT91_IO_VIRT_BASE - length; 55 desc->virtual = AT91_IO_VIRT_BASE - length;
78 if (bank > 0) 56 if (bank > 0)
79 desc->virtual -= sram_desc[bank - 1].length; 57 desc->virtual -= sram_desc[bank - 1].length;
80 58
@@ -88,13 +66,34 @@ void __init at91_init_sram(int bank, unsigned long base, unsigned int length)
88 iotable_init(desc, 1); 66 iotable_init(desc, 1);
89} 67}
90 68
91static struct map_desc at91_io_desc __initdata __maybe_unused = { 69static struct map_desc at91_io_desc __initdata = {
92 .virtual = (unsigned long)AT91_VA_BASE_SYS, 70 .virtual = AT91_VA_BASE_SYS,
93 .pfn = __phys_to_pfn(AT91_BASE_SYS), 71 .pfn = __phys_to_pfn(AT91_BASE_SYS),
94 .length = SZ_16K, 72 .length = SZ_16K,
95 .type = MT_DEVICE, 73 .type = MT_DEVICE,
96}; 74};
97 75
76void __iomem *at91_ioremap(unsigned long p, size_t size, unsigned int type)
77{
78 if (p >= AT91_BASE_SYS && p <= (AT91_BASE_SYS + SZ_16K - 1))
79 return (void __iomem *)AT91_IO_P2V(p);
80
81 return __arm_ioremap_caller(p, size, type, __builtin_return_address(0));
82}
83EXPORT_SYMBOL(at91_ioremap);
84
85void at91_iounmap(volatile void __iomem *addr)
86{
87 unsigned long virt = (unsigned long)addr;
88
89 if (virt >= VMALLOC_START && virt < VMALLOC_END)
90 __iounmap(addr);
91}
92EXPORT_SYMBOL(at91_iounmap);
93
94#define AT91_DBGU0 0xfffff200
95#define AT91_DBGU1 0xffffee00
96
98static void __init soc_detect(u32 dbgu_base) 97static void __init soc_detect(u32 dbgu_base)
99{ 98{
100 u32 cidr, socid; 99 u32 cidr, socid;
@@ -103,6 +102,20 @@ static void __init soc_detect(u32 dbgu_base)
103 socid = cidr & ~AT91_CIDR_VERSION; 102 socid = cidr & ~AT91_CIDR_VERSION;
104 103
105 switch (socid) { 104 switch (socid) {
105 case ARCH_ID_AT91CAP9: {
106#ifdef CONFIG_AT91_PMC_UNIT
107 u32 pmc_ver = at91_sys_read(AT91_PMC_VER);
108
109 if (pmc_ver == ARCH_REVISION_CAP9_B)
110 at91_soc_initdata.subtype = AT91_SOC_CAP9_REV_B;
111 else if (pmc_ver == ARCH_REVISION_CAP9_C)
112 at91_soc_initdata.subtype = AT91_SOC_CAP9_REV_C;
113#endif
114 at91_soc_initdata.type = AT91_SOC_CAP9;
115 at91_boot_soc = at91cap9_soc;
116 break;
117 }
118
106 case ARCH_ID_AT91RM9200: 119 case ARCH_ID_AT91RM9200:
107 at91_soc_initdata.type = AT91_SOC_RM9200; 120 at91_soc_initdata.type = AT91_SOC_RM9200;
108 at91_boot_soc = at91rm9200_soc; 121 at91_boot_soc = at91rm9200_soc;
@@ -144,15 +157,10 @@ static void __init soc_detect(u32 dbgu_base)
144 at91_soc_initdata.type = AT91_SOC_SAM9X5; 157 at91_soc_initdata.type = AT91_SOC_SAM9X5;
145 at91_boot_soc = at91sam9x5_soc; 158 at91_boot_soc = at91sam9x5_soc;
146 break; 159 break;
147
148 case ARCH_ID_AT91SAM9N12:
149 at91_soc_initdata.type = AT91_SOC_SAM9N12;
150 at91_boot_soc = at91sam9n12_soc;
151 break;
152 } 160 }
153 161
154 /* at91sam9g10 */ 162 /* at91sam9g10 */
155 if ((socid & ~AT91_CIDR_EXT) == ARCH_ID_AT91SAM9G10) { 163 if ((cidr & ~AT91_CIDR_EXT) == ARCH_ID_AT91SAM9G10) {
156 at91_soc_initdata.type = AT91_SOC_SAM9G10; 164 at91_soc_initdata.type = AT91_SOC_SAM9G10;
157 at91_boot_soc = at91sam9261_soc; 165 at91_boot_soc = at91sam9261_soc;
158 } 166 }
@@ -208,6 +216,7 @@ static void __init soc_detect(u32 dbgu_base)
208 216
209static const char *soc_name[] = { 217static const char *soc_name[] = {
210 [AT91_SOC_RM9200] = "at91rm9200", 218 [AT91_SOC_RM9200] = "at91rm9200",
219 [AT91_SOC_CAP9] = "at91cap9",
211 [AT91_SOC_SAM9260] = "at91sam9260", 220 [AT91_SOC_SAM9260] = "at91sam9260",
212 [AT91_SOC_SAM9261] = "at91sam9261", 221 [AT91_SOC_SAM9261] = "at91sam9261",
213 [AT91_SOC_SAM9263] = "at91sam9263", 222 [AT91_SOC_SAM9263] = "at91sam9263",
@@ -216,7 +225,6 @@ static const char *soc_name[] = {
216 [AT91_SOC_SAM9G45] = "at91sam9g45", 225 [AT91_SOC_SAM9G45] = "at91sam9g45",
217 [AT91_SOC_SAM9RL] = "at91sam9rl", 226 [AT91_SOC_SAM9RL] = "at91sam9rl",
218 [AT91_SOC_SAM9X5] = "at91sam9x5", 227 [AT91_SOC_SAM9X5] = "at91sam9x5",
219 [AT91_SOC_SAM9N12] = "at91sam9n12",
220 [AT91_SOC_NONE] = "Unknown" 228 [AT91_SOC_NONE] = "Unknown"
221}; 229};
222 230
@@ -229,6 +237,8 @@ EXPORT_SYMBOL(at91_get_soc_type);
229static const char *soc_subtype_name[] = { 237static const char *soc_subtype_name[] = {
230 [AT91_SOC_RM9200_BGA] = "at91rm9200 BGA", 238 [AT91_SOC_RM9200_BGA] = "at91rm9200 BGA",
231 [AT91_SOC_RM9200_PQFP] = "at91rm9200 PQFP", 239 [AT91_SOC_RM9200_PQFP] = "at91rm9200 PQFP",
240 [AT91_SOC_CAP9_REV_B] = "at91cap9 revB",
241 [AT91_SOC_CAP9_REV_C] = "at91cap9 revC",
232 [AT91_SOC_SAM9XE] = "at91sam9xe", 242 [AT91_SOC_SAM9XE] = "at91sam9xe",
233 [AT91_SOC_SAM9G45ES] = "at91sam9g45es", 243 [AT91_SOC_SAM9G45ES] = "at91sam9g45es",
234 [AT91_SOC_SAM9M10] = "at91sam9m10", 244 [AT91_SOC_SAM9M10] = "at91sam9m10",
@@ -256,9 +266,9 @@ void __init at91_map_io(void)
256 at91_soc_initdata.type = AT91_SOC_NONE; 266 at91_soc_initdata.type = AT91_SOC_NONE;
257 at91_soc_initdata.subtype = AT91_SOC_SUBTYPE_NONE; 267 at91_soc_initdata.subtype = AT91_SOC_SUBTYPE_NONE;
258 268
259 soc_detect(AT91_BASE_DBGU0); 269 soc_detect(AT91_DBGU0);
260 if (!at91_soc_is_detected()) 270 if (!at91_soc_is_detected())
261 soc_detect(AT91_BASE_DBGU1); 271 soc_detect(AT91_DBGU1);
262 272
263 if (!at91_soc_is_detected()) 273 if (!at91_soc_is_detected())
264 panic("AT91: Impossible to detect the SOC type"); 274 panic("AT91: Impossible to detect the SOC type");
@@ -275,203 +285,8 @@ void __init at91_map_io(void)
275 at91_boot_soc.map_io(); 285 at91_boot_soc.map_io();
276} 286}
277 287
278void __iomem *at91_shdwc_base = NULL;
279
280static void at91sam9_poweroff(void)
281{
282 at91_shdwc_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
283}
284
285void __init at91_ioremap_shdwc(u32 base_addr)
286{
287 at91_shdwc_base = ioremap(base_addr, 16);
288 if (!at91_shdwc_base)
289 panic("Impossible to ioremap at91_shdwc_base\n");
290 pm_power_off = at91sam9_poweroff;
291}
292
293void __iomem *at91_rstc_base;
294
295void __init at91_ioremap_rstc(u32 base_addr)
296{
297 at91_rstc_base = ioremap(base_addr, 16);
298 if (!at91_rstc_base)
299 panic("Impossible to ioremap at91_rstc_base\n");
300}
301
302void __iomem *at91_matrix_base;
303EXPORT_SYMBOL_GPL(at91_matrix_base);
304
305void __init at91_ioremap_matrix(u32 base_addr)
306{
307 at91_matrix_base = ioremap(base_addr, 512);
308 if (!at91_matrix_base)
309 panic("Impossible to ioremap at91_matrix_base\n");
310}
311
312#if defined(CONFIG_OF)
313static struct of_device_id rstc_ids[] = {
314 { .compatible = "atmel,at91sam9260-rstc", .data = at91sam9_alt_restart },
315 { .compatible = "atmel,at91sam9g45-rstc", .data = at91sam9g45_restart },
316 { /*sentinel*/ }
317};
318
319static void at91_dt_rstc(void)
320{
321 struct device_node *np;
322 const struct of_device_id *of_id;
323
324 np = of_find_matching_node(NULL, rstc_ids);
325 if (!np)
326 panic("unable to find compatible rstc node in dtb\n");
327
328 at91_rstc_base = of_iomap(np, 0);
329 if (!at91_rstc_base)
330 panic("unable to map rstc cpu registers\n");
331
332 of_id = of_match_node(rstc_ids, np);
333 if (!of_id)
334 panic("AT91: rtsc no restart function availlable\n");
335
336 arm_pm_restart = of_id->data;
337
338 of_node_put(np);
339}
340
341static struct of_device_id ramc_ids[] = {
342 { .compatible = "atmel,at91rm9200-sdramc" },
343 { .compatible = "atmel,at91sam9260-sdramc" },
344 { .compatible = "atmel,at91sam9g45-ddramc" },
345 { /*sentinel*/ }
346};
347
348static void at91_dt_ramc(void)
349{
350 struct device_node *np;
351
352 np = of_find_matching_node(NULL, ramc_ids);
353 if (!np)
354 panic("unable to find compatible ram conroller node in dtb\n");
355
356 at91_ramc_base[0] = of_iomap(np, 0);
357 if (!at91_ramc_base[0])
358 panic("unable to map ramc[0] cpu registers\n");
359 /* the controller may have 2 banks */
360 at91_ramc_base[1] = of_iomap(np, 1);
361
362 of_node_put(np);
363}
364
365static struct of_device_id shdwc_ids[] = {
366 { .compatible = "atmel,at91sam9260-shdwc", },
367 { .compatible = "atmel,at91sam9rl-shdwc", },
368 { .compatible = "atmel,at91sam9x5-shdwc", },
369 { /*sentinel*/ }
370};
371
372static const char *shdwc_wakeup_modes[] = {
373 [AT91_SHDW_WKMODE0_NONE] = "none",
374 [AT91_SHDW_WKMODE0_HIGH] = "high",
375 [AT91_SHDW_WKMODE0_LOW] = "low",
376 [AT91_SHDW_WKMODE0_ANYLEVEL] = "any",
377};
378
379const int at91_dtget_shdwc_wakeup_mode(struct device_node *np)
380{
381 const char *pm;
382 int err, i;
383
384 err = of_property_read_string(np, "atmel,wakeup-mode", &pm);
385 if (err < 0)
386 return AT91_SHDW_WKMODE0_ANYLEVEL;
387
388 for (i = 0; i < ARRAY_SIZE(shdwc_wakeup_modes); i++)
389 if (!strcasecmp(pm, shdwc_wakeup_modes[i]))
390 return i;
391
392 return -ENODEV;
393}
394
395static void at91_dt_shdwc(void)
396{
397 struct device_node *np;
398 int wakeup_mode;
399 u32 reg;
400 u32 mode = 0;
401
402 np = of_find_matching_node(NULL, shdwc_ids);
403 if (!np) {
404 pr_debug("AT91: unable to find compatible shutdown (shdwc) conroller node in dtb\n");
405 return;
406 }
407
408 at91_shdwc_base = of_iomap(np, 0);
409 if (!at91_shdwc_base)
410 panic("AT91: unable to map shdwc cpu registers\n");
411
412 wakeup_mode = at91_dtget_shdwc_wakeup_mode(np);
413 if (wakeup_mode < 0) {
414 pr_warn("AT91: shdwc unknown wakeup mode\n");
415 goto end;
416 }
417
418 if (!of_property_read_u32(np, "atmel,wakeup-counter", &reg)) {
419 if (reg > AT91_SHDW_CPTWK0_MAX) {
420 pr_warn("AT91: shdwc wakeup conter 0x%x > 0x%x reduce it to 0x%x\n",
421 reg, AT91_SHDW_CPTWK0_MAX, AT91_SHDW_CPTWK0_MAX);
422 reg = AT91_SHDW_CPTWK0_MAX;
423 }
424 mode |= AT91_SHDW_CPTWK0_(reg);
425 }
426
427 if (of_property_read_bool(np, "atmel,wakeup-rtc-timer"))
428 mode |= AT91_SHDW_RTCWKEN;
429
430 if (of_property_read_bool(np, "atmel,wakeup-rtt-timer"))
431 mode |= AT91_SHDW_RTTWKEN;
432
433 at91_shdwc_write(AT91_SHDW_MR, wakeup_mode | mode);
434
435end:
436 pm_power_off = at91sam9_poweroff;
437
438 of_node_put(np);
439}
440
441void __init at91rm9200_dt_initialize(void)
442{
443 at91_dt_ramc();
444
445 /* Init clock subsystem */
446 at91_dt_clock_init();
447
448 /* Register the processor-specific clocks */
449 at91_boot_soc.register_clocks();
450
451 at91_boot_soc.init();
452}
453
454void __init at91_dt_initialize(void)
455{
456 at91_dt_rstc();
457 at91_dt_ramc();
458 at91_dt_shdwc();
459
460 /* Init clock subsystem */
461 at91_dt_clock_init();
462
463 /* Register the processor-specific clocks */
464 at91_boot_soc.register_clocks();
465
466 if (at91_boot_soc.init)
467 at91_boot_soc.init();
468}
469#endif
470
471void __init at91_initialize(unsigned long main_clock) 288void __init at91_initialize(unsigned long main_clock)
472{ 289{
473 at91_boot_soc.ioremap_registers();
474
475 /* Init clock subsystem */ 290 /* Init clock subsystem */
476 at91_clock_init(main_clock); 291 at91_clock_init(main_clock);
477 292
@@ -479,6 +294,4 @@ void __init at91_initialize(unsigned long main_clock)
479 at91_boot_soc.register_clocks(); 294 at91_boot_soc.register_clocks();
480 295
481 at91_boot_soc.init(); 296 at91_boot_soc.init();
482
483 pinctrl_provide_dummies();
484} 297}
diff --git a/arch/arm/mach-at91/soc.h b/arch/arm/mach-at91/soc.h
index 9c6d3d4f9a2..21ed8816e6f 100644
--- a/arch/arm/mach-at91/soc.h
+++ b/arch/arm/mach-at91/soc.h
@@ -5,15 +5,14 @@
5 */ 5 */
6 6
7struct at91_init_soc { 7struct at91_init_soc {
8 int builtin;
9 unsigned int *default_irq_priority; 8 unsigned int *default_irq_priority;
10 void (*map_io)(void); 9 void (*map_io)(void);
11 void (*ioremap_registers)(void);
12 void (*register_clocks)(void); 10 void (*register_clocks)(void);
13 void (*init)(void); 11 void (*init)(void);
14}; 12};
15 13
16extern struct at91_init_soc at91_boot_soc; 14extern struct at91_init_soc at91_boot_soc;
15extern struct at91_init_soc at91cap9_soc;
17extern struct at91_init_soc at91rm9200_soc; 16extern struct at91_init_soc at91rm9200_soc;
18extern struct at91_init_soc at91sam9260_soc; 17extern struct at91_init_soc at91sam9260_soc;
19extern struct at91_init_soc at91sam9261_soc; 18extern struct at91_init_soc at91sam9261_soc;
@@ -21,50 +20,40 @@ extern struct at91_init_soc at91sam9263_soc;
21extern struct at91_init_soc at91sam9g45_soc; 20extern struct at91_init_soc at91sam9g45_soc;
22extern struct at91_init_soc at91sam9rl_soc; 21extern struct at91_init_soc at91sam9rl_soc;
23extern struct at91_init_soc at91sam9x5_soc; 22extern struct at91_init_soc at91sam9x5_soc;
24extern struct at91_init_soc at91sam9n12_soc;
25
26#define AT91_SOC_START(_name) \
27struct at91_init_soc __initdata at91##_name##_soc \
28 __used \
29 = { \
30 .builtin = 1, \
31
32#define AT91_SOC_END \
33};
34 23
35static inline int at91_soc_is_enabled(void) 24static inline int at91_soc_is_enabled(void)
36{ 25{
37 return at91_boot_soc.builtin; 26 return at91_boot_soc.init != NULL;
38} 27}
39 28
40#if !defined(CONFIG_SOC_AT91RM9200) 29#if !defined(CONFIG_ARCH_AT91CAP9)
30#define at91cap9_soc at91_boot_soc
31#endif
32
33#if !defined(CONFIG_ARCH_AT91RM9200)
41#define at91rm9200_soc at91_boot_soc 34#define at91rm9200_soc at91_boot_soc
42#endif 35#endif
43 36
44#if !defined(CONFIG_SOC_AT91SAM9260) 37#if !(defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9G20))
45#define at91sam9260_soc at91_boot_soc 38#define at91sam9260_soc at91_boot_soc
46#endif 39#endif
47 40
48#if !defined(CONFIG_SOC_AT91SAM9261) 41#if !(defined(CONFIG_ARCH_AT91SAM9261) || defined(CONFIG_ARCH_AT91SAM9G10))
49#define at91sam9261_soc at91_boot_soc 42#define at91sam9261_soc at91_boot_soc
50#endif 43#endif
51 44
52#if !defined(CONFIG_SOC_AT91SAM9263) 45#if !defined(CONFIG_ARCH_AT91SAM9263)
53#define at91sam9263_soc at91_boot_soc 46#define at91sam9263_soc at91_boot_soc
54#endif 47#endif
55 48
56#if !defined(CONFIG_SOC_AT91SAM9G45) 49#if !defined(CONFIG_ARCH_AT91SAM9G45)
57#define at91sam9g45_soc at91_boot_soc 50#define at91sam9g45_soc at91_boot_soc
58#endif 51#endif
59 52
60#if !defined(CONFIG_SOC_AT91SAM9RL) 53#if !defined(CONFIG_ARCH_AT91SAM9RL)
61#define at91sam9rl_soc at91_boot_soc 54#define at91sam9rl_soc at91_boot_soc
62#endif 55#endif
63 56
64#if !defined(CONFIG_SOC_AT91SAM9X5) 57#if !defined(CONFIG_ARCH_AT91SAM9X5)
65#define at91sam9x5_soc at91_boot_soc 58#define at91sam9x5_soc at91_boot_soc
66#endif 59#endif
67
68#if !defined(CONFIG_SOC_AT91SAM9N12)
69#define at91sam9n12_soc at91_boot_soc
70#endif
diff --git a/arch/arm/mach-at91/stamp9g20.h b/arch/arm/mach-at91/stamp9g20.h
deleted file mode 100644
index f62c0abca4b..00000000000
--- a/arch/arm/mach-at91/stamp9g20.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __MACH_STAMP9G20_H
2#define __MACH_STAMP9G20_H
3
4void stamp9g20_init_early(void);
5void stamp9g20_board_init(void);
6
7#endif