aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-at91')
-rw-r--r--arch/arm/mach-at91/Kconfig87
-rw-r--r--arch/arm/mach-at91/Makefile11
-rw-r--r--arch/arm/mach-at91/at91cap9.c9
-rw-r--r--arch/arm/mach-at91/at91cap9_devices.c171
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c92
-rw-r--r--arch/arm/mach-at91/at91sam9260.c24
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c203
-rw-r--r--arch/arm/mach-at91/at91sam9261.c8
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c125
-rw-r--r--arch/arm/mach-at91/at91sam9263.c8
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c104
-rw-r--r--arch/arm/mach-at91/at91sam926x_time.c171
-rw-r--r--arch/arm/mach-at91/at91sam9rl.c8
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c231
-rw-r--r--arch/arm/mach-at91/at91x40.c18
-rw-r--r--arch/arm/mach-at91/board-cam60.c180
-rw-r--r--arch/arm/mach-at91/board-cap9adk.c11
-rw-r--r--arch/arm/mach-at91/board-carmeva.c23
-rw-r--r--arch/arm/mach-at91/board-csb337.c21
-rw-r--r--arch/arm/mach-at91/board-csb637.c30
-rw-r--r--arch/arm/mach-at91/board-dk.c28
-rw-r--r--arch/arm/mach-at91/board-eb9200.c29
-rw-r--r--arch/arm/mach-at91/board-ecbat91.c178
-rw-r--r--arch/arm/mach-at91/board-ek.c25
-rw-r--r--arch/arm/mach-at91/board-kb9202.c29
-rw-r--r--arch/arm/mach-at91/board-qil-a9260.c255
-rw-r--r--arch/arm/mach-at91/board-sam9-l9260.c199
-rw-r--r--arch/arm/mach-at91/board-sam9260ek.c83
-rw-r--r--arch/arm/mach-at91/board-sam9261ek.c83
-rw-r--r--arch/arm/mach-at91/board-sam9263ek.c25
-rw-r--r--arch/arm/mach-at91/board-sam9g20ek.c218
-rw-r--r--arch/arm/mach-at91/board-sam9rlek.c33
-rw-r--r--arch/arm/mach-at91/board-usb-a9260.c215
-rw-r--r--arch/arm/mach-at91/board-usb-a9263.c230
-rwxr-xr-xarch/arm/mach-at91/board-yl-9200.c604
-rw-r--r--arch/arm/mach-at91/clock.c65
-rw-r--r--arch/arm/mach-at91/pm.c171
37 files changed, 3513 insertions, 492 deletions
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 074dcd5d9a7e..5bad6b9b00d7 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -12,18 +12,33 @@ config ARCH_AT91RM9200
12 12
13config ARCH_AT91SAM9260 13config ARCH_AT91SAM9260
14 bool "AT91SAM9260 or AT91SAM9XE" 14 bool "AT91SAM9260 or AT91SAM9XE"
15 select GENERIC_TIME
16 select GENERIC_CLOCKEVENTS
15 17
16config ARCH_AT91SAM9261 18config ARCH_AT91SAM9261
17 bool "AT91SAM9261" 19 bool "AT91SAM9261"
20 select GENERIC_TIME
21 select GENERIC_CLOCKEVENTS
18 22
19config ARCH_AT91SAM9263 23config ARCH_AT91SAM9263
20 bool "AT91SAM9263" 24 bool "AT91SAM9263"
25 select GENERIC_TIME
26 select GENERIC_CLOCKEVENTS
21 27
22config ARCH_AT91SAM9RL 28config ARCH_AT91SAM9RL
23 bool "AT91SAM9RL" 29 bool "AT91SAM9RL"
30 select GENERIC_TIME
31 select GENERIC_CLOCKEVENTS
32
33config ARCH_AT91SAM9G20
34 bool "AT91SAM9G20"
35 select GENERIC_TIME
36 select GENERIC_CLOCKEVENTS
24 37
25config ARCH_AT91CAP9 38config ARCH_AT91CAP9
26 bool "AT91CAP9" 39 bool "AT91CAP9"
40 select GENERIC_TIME
41 select GENERIC_CLOCKEVENTS
27 42
28config ARCH_AT91X40 43config ARCH_AT91X40
29 bool "AT91x40" 44 bool "AT91x40"
@@ -109,6 +124,19 @@ config MACH_KAFA
109 help 124 help
110 Select this if you are using Sperry-Sun's KAFA board. 125 Select this if you are using Sperry-Sun's KAFA board.
111 126
127config MACH_ECBAT91
128 bool "emQbit ECB_AT91 SBC"
129 depends on ARCH_AT91RM9200
130 help
131 Select this if you are using emQbit's ECB_AT91 board.
132 <http://wiki.emqbit.com/free-ecb-at91>
133
134config MACH_YL9200
135 bool "ucDragon YL-9200"
136 depends on ARCH_AT91RM9200
137 help
138 Select this if you are using the ucDragon YL-9200 board.
139
112endif 140endif
113 141
114# ---------------------------------------------------------- 142# ----------------------------------------------------------
@@ -133,6 +161,34 @@ config MACH_AT91SAM9260EK
133 Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit 161 Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit
134 <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933> 162 <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>
135 163
164config MACH_CAM60
165 bool "KwikByte KB9260 (CAM60) board"
166 depends on ARCH_AT91SAM9260
167 help
168 Select this if you are using KwikByte's KB9260 (CAM60) board based on the Atmel AT91SAM9260.
169 <http://www.kwikbyte.com/KB9260.html>
170
171config MACH_SAM9_L9260
172 bool "Olimex SAM9-L9260 board"
173 depends on ARCH_AT91SAM9260
174 help
175 Select this if you are using Olimex's SAM9-L9260 board based on the Atmel AT91SAM9260.
176 <http://www.olimex.com/dev/sam9-L9260.html>
177
178config MACH_USB_A9260
179 bool "CALAO USB-A9260"
180 depends on ARCH_AT91SAM9260
181 help
182 Select this if you are using a Calao Systems USB-A9260.
183 <http://www.calao-systems.com>
184
185config MACH_QIL_A9260
186 bool "CALAO QIL-A9260 board"
187 depends on ARCH_AT91SAM9260
188 help
189 Select this if you are using a Calao Systems QIL-A9260 Board.
190 <http://www.calao-systems.com>
191
136endif 192endif
137 193
138# ---------------------------------------------------------- 194# ----------------------------------------------------------
@@ -163,6 +219,13 @@ config MACH_AT91SAM9263EK
163 Select this if you are using Atmel's AT91SAM9263-EK Evaluation Kit. 219 Select this if you are using Atmel's AT91SAM9263-EK Evaluation Kit.
164 <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4057> 220 <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4057>
165 221
222config MACH_USB_A9263
223 bool "CALAO USB-A9263"
224 depends on ARCH_AT91SAM9263
225 help
226 Select this if you are using a Calao Systems USB-A9263.
227 <http://www.calao-systems.com>
228
166endif 229endif
167 230
168# ---------------------------------------------------------- 231# ----------------------------------------------------------
@@ -181,6 +244,20 @@ endif
181 244
182# ---------------------------------------------------------- 245# ----------------------------------------------------------
183 246
247if ARCH_AT91SAM9G20
248
249comment "AT91SAM9G20 Board Type"
250
251config MACH_AT91SAM9G20EK
252 bool "Atmel AT91SAM9G20-EK Evaluation Kit"
253 depends on ARCH_AT91SAM9G20
254 help
255 Select this if you are using Atmel's AT91SAM9G20-EK Evaluation Kit.
256
257endif
258
259# ----------------------------------------------------------
260
184if ARCH_AT91CAP9 261if ARCH_AT91CAP9
185 262
186comment "AT91CAP9 Board Type" 263comment "AT91CAP9 Board Type"
@@ -216,13 +293,13 @@ comment "AT91 Board Options"
216 293
217config MTD_AT91_DATAFLASH_CARD 294config MTD_AT91_DATAFLASH_CARD
218 bool "Enable DataFlash Card support" 295 bool "Enable DataFlash Card support"
219 depends on (ARCH_AT91RM9200DK || MACH_AT91RM9200EK || MACH_AT91SAM9260EK || MACH_AT91SAM9261EK || MACH_AT91SAM9263EK || MACH_AT91CAP9ADK) 296 depends on (ARCH_AT91RM9200DK || MACH_AT91RM9200EK || MACH_AT91SAM9260EK || MACH_AT91SAM9261EK || MACH_AT91SAM9263EK || MACH_AT91SAM9G20EK || MACH_ECBAT91 || MACH_SAM9_L9260 || MACH_AT91CAP9ADK)
220 help 297 help
221 Enable support for the DataFlash card. 298 Enable support for the DataFlash card.
222 299
223config MTD_NAND_AT91_BUSWIDTH_16 300config MTD_NAND_AT91_BUSWIDTH_16
224 bool "Enable 16-bit data bus interface to NAND flash" 301 bool "Enable 16-bit data bus interface to NAND flash"
225 depends on (MACH_AT91SAM9260EK || MACH_AT91SAM9261EK || MACH_AT91SAM9263EK || MACH_AT91CAP9ADK) 302 depends on (MACH_AT91SAM9260EK || MACH_AT91SAM9261EK || MACH_AT91SAM9263EK || MACH_AT91SAM9G20EK || MACH_AT91CAP9ADK)
226 help 303 help
227 On AT91SAM926x boards both types of NAND flash can be present 304 On AT91SAM926x boards both types of NAND flash can be present
228 (8 and 16 bit data bus width). 305 (8 and 16 bit data bus width).
@@ -271,15 +348,15 @@ config AT91_EARLY_USART2
271 348
272config AT91_EARLY_USART3 349config AT91_EARLY_USART3
273 bool "USART3" 350 bool "USART3"
274 depends on (ARCH_AT91RM9200 || ARCH_AT91SAM9RL || ARCH_AT91SAM9260) 351 depends on (ARCH_AT91RM9200 || ARCH_AT91SAM9RL || ARCH_AT91SAM9260 || ARCH_AT91SAM9G20)
275 352
276config AT91_EARLY_USART4 353config AT91_EARLY_USART4
277 bool "USART4" 354 bool "USART4"
278 depends on ARCH_AT91SAM9260 355 depends on ARCH_AT91SAM9260 || ARCH_AT91SAM9G20
279 356
280config AT91_EARLY_USART5 357config AT91_EARLY_USART5
281 bool "USART5" 358 bool "USART5"
282 depends on ARCH_AT91SAM9260 359 depends on ARCH_AT91SAM9260 || ARCH_AT91SAM9G20
283 360
284endchoice 361endchoice
285 362
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index bf5f293dccf8..7d641f97516b 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_ARCH_AT91SAM9260) += at91sam9260.o at91sam926x_time.o at91sam9260_d
15obj-$(CONFIG_ARCH_AT91SAM9261) += at91sam9261.o at91sam926x_time.o at91sam9261_devices.o 15obj-$(CONFIG_ARCH_AT91SAM9261) += at91sam9261.o at91sam926x_time.o at91sam9261_devices.o
16obj-$(CONFIG_ARCH_AT91SAM9263) += at91sam9263.o at91sam926x_time.o at91sam9263_devices.o 16obj-$(CONFIG_ARCH_AT91SAM9263) += at91sam9263.o at91sam926x_time.o at91sam9263_devices.o
17obj-$(CONFIG_ARCH_AT91SAM9RL) += at91sam9rl.o at91sam926x_time.o at91sam9rl_devices.o 17obj-$(CONFIG_ARCH_AT91SAM9RL) += at91sam9rl.o at91sam926x_time.o at91sam9rl_devices.o
18obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o
18obj-$(CONFIG_ARCH_AT91CAP9) += at91cap9.o at91sam926x_time.o at91cap9_devices.o 19obj-$(CONFIG_ARCH_AT91CAP9) += at91cap9.o at91sam926x_time.o at91cap9_devices.o
19obj-$(CONFIG_ARCH_AT91X40) += at91x40.o at91x40_time.o 20obj-$(CONFIG_ARCH_AT91X40) += at91x40.o at91x40_time.o
20 21
@@ -29,19 +30,29 @@ obj-$(CONFIG_MACH_KB9200) += board-kb9202.o
29obj-$(CONFIG_MACH_ATEB9200) += board-eb9200.o 30obj-$(CONFIG_MACH_ATEB9200) += board-eb9200.o
30obj-$(CONFIG_MACH_KAFA) += board-kafa.o 31obj-$(CONFIG_MACH_KAFA) += board-kafa.o
31obj-$(CONFIG_MACH_PICOTUX2XX) += board-picotux200.o 32obj-$(CONFIG_MACH_PICOTUX2XX) += board-picotux200.o
33obj-$(CONFIG_MACH_ECBAT91) += board-ecbat91.o
34obj-$(CONFIG_MACH_YL9200) += board-yl-9200.o
32 35
33# AT91SAM9260 board-specific support 36# AT91SAM9260 board-specific support
34obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o 37obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
38obj-$(CONFIG_MACH_CAM60) += board-cam60.o
39obj-$(CONFIG_MACH_SAM9_L9260) += board-sam9-l9260.o
40obj-$(CONFIG_MACH_USB_A9260) += board-usb-a9260.o
41obj-$(CONFIG_MACH_QIL_A9260) += board-qil-a9260.o
35 42
36# AT91SAM9261 board-specific support 43# AT91SAM9261 board-specific support
37obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o 44obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o
38 45
39# AT91SAM9263 board-specific support 46# AT91SAM9263 board-specific support
40obj-$(CONFIG_MACH_AT91SAM9263EK) += board-sam9263ek.o 47obj-$(CONFIG_MACH_AT91SAM9263EK) += board-sam9263ek.o
48obj-$(CONFIG_MACH_USB_A9263) += board-usb-a9263.o
41 49
42# AT91SAM9RL board-specific support 50# AT91SAM9RL board-specific support
43obj-$(CONFIG_MACH_AT91SAM9RLEK) += board-sam9rlek.o 51obj-$(CONFIG_MACH_AT91SAM9RLEK) += board-sam9rlek.o
44 52
53# AT91SAM9G20 board-specific support
54obj-$(CONFIG_MACH_AT91SAM9G20EK) += board-sam9g20ek.o
55
45# AT91CAP9 board-specific support 56# AT91CAP9 board-specific support
46obj-$(CONFIG_MACH_AT91CAP9ADK) += board-cap9adk.o 57obj-$(CONFIG_MACH_AT91CAP9ADK) += board-cap9adk.o
47 58
diff --git a/arch/arm/mach-at91/at91cap9.c b/arch/arm/mach-at91/at91cap9.c
index 48d27d8000b0..933fa8f55cbc 100644
--- a/arch/arm/mach-at91/at91cap9.c
+++ b/arch/arm/mach-at91/at91cap9.c
@@ -13,12 +13,14 @@
13 */ 13 */
14 14
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/pm.h>
16 17
17#include <asm/mach/arch.h> 18#include <asm/mach/arch.h>
18#include <asm/mach/map.h> 19#include <asm/mach/map.h>
19#include <asm/arch/at91cap9.h> 20#include <asm/arch/at91cap9.h>
20#include <asm/arch/at91_pmc.h> 21#include <asm/arch/at91_pmc.h>
21#include <asm/arch/at91_rstc.h> 22#include <asm/arch/at91_rstc.h>
23#include <asm/arch/at91_shdwc.h>
22 24
23#include "generic.h" 25#include "generic.h"
24#include "clock.h" 26#include "clock.h"
@@ -288,6 +290,12 @@ static void at91cap9_reset(void)
288 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); 290 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
289} 291}
290 292
293static void at91cap9_poweroff(void)
294{
295 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
296}
297
298
291/* -------------------------------------------------------------------- 299/* --------------------------------------------------------------------
292 * AT91CAP9 processor initialization 300 * AT91CAP9 processor initialization
293 * -------------------------------------------------------------------- */ 301 * -------------------------------------------------------------------- */
@@ -298,6 +306,7 @@ void __init at91cap9_initialize(unsigned long main_clock)
298 iotable_init(at91cap9_io_desc, ARRAY_SIZE(at91cap9_io_desc)); 306 iotable_init(at91cap9_io_desc, ARRAY_SIZE(at91cap9_io_desc));
299 307
300 at91_arch_reset = at91cap9_reset; 308 at91_arch_reset = at91cap9_reset;
309 pm_power_off = at91cap9_poweroff;
301 at91_extern_irq = (1 << AT91CAP9_ID_IRQ0) | (1 << AT91CAP9_ID_IRQ1); 310 at91_extern_irq = (1 << AT91CAP9_ID_IRQ0) | (1 << AT91CAP9_ID_IRQ1);
302 311
303 /* Init clock subsystem */ 312 /* Init clock subsystem */
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
index c50fad9cd143..747b9dedab88 100644
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ b/arch/arm/mach-at91/at91cap9_devices.c
@@ -16,15 +16,15 @@
16 16
17#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/mtd/physmap.h> 19#include <linux/i2c-gpio.h>
20 20
21#include <video/atmel_lcdc.h> 21#include <video/atmel_lcdc.h>
22 22
23#include <asm/arch/board.h> 23#include <asm/arch/board.h>
24#include <asm/arch/gpio.h> 24#include <asm/arch/gpio.h>
25#include <asm/arch/at91cap9.h> 25#include <asm/arch/at91cap9.h>
26#include <asm/arch/at91sam926x_mc.h>
27#include <asm/arch/at91cap9_matrix.h> 26#include <asm/arch/at91cap9_matrix.h>
27#include <asm/arch/at91sam9_smc.h>
28 28
29#include "generic.h" 29#include "generic.h"
30 30
@@ -84,6 +84,105 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
84 84
85 85
86/* -------------------------------------------------------------------- 86/* --------------------------------------------------------------------
87 * USB HS Device (Gadget)
88 * -------------------------------------------------------------------- */
89
90#if defined(CONFIG_USB_GADGET_ATMEL_USBA) || defined(CONFIG_USB_GADGET_ATMEL_USBA_MODULE)
91
92static struct resource usba_udc_resources[] = {
93 [0] = {
94 .start = AT91CAP9_UDPHS_FIFO,
95 .end = AT91CAP9_UDPHS_FIFO + SZ_512K - 1,
96 .flags = IORESOURCE_MEM,
97 },
98 [1] = {
99 .start = AT91CAP9_BASE_UDPHS,
100 .end = AT91CAP9_BASE_UDPHS + SZ_1K - 1,
101 .flags = IORESOURCE_MEM,
102 },
103 [2] = {
104 .start = AT91CAP9_ID_UDPHS,
105 .end = AT91CAP9_ID_UDPHS,
106 .flags = IORESOURCE_IRQ,
107 },
108};
109
110#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
111 [idx] = { \
112 .name = nam, \
113 .index = idx, \
114 .fifo_size = maxpkt, \
115 .nr_banks = maxbk, \
116 .can_dma = dma, \
117 .can_isoc = isoc, \
118 }
119
120static struct usba_ep_data usba_udc_ep[] = {
121 EP("ep0", 0, 64, 1, 0, 0),
122 EP("ep1", 1, 1024, 3, 1, 1),
123 EP("ep2", 2, 1024, 3, 1, 1),
124 EP("ep3", 3, 1024, 2, 1, 1),
125 EP("ep4", 4, 1024, 2, 1, 1),
126 EP("ep5", 5, 1024, 2, 1, 0),
127 EP("ep6", 6, 1024, 2, 1, 0),
128 EP("ep7", 7, 1024, 2, 0, 0),
129};
130
131#undef EP
132
133/*
134 * pdata doesn't have room for any endpoints, so we need to
135 * append room for the ones we need right after it.
136 */
137static struct {
138 struct usba_platform_data pdata;
139 struct usba_ep_data ep[8];
140} usba_udc_data;
141
142static struct platform_device at91_usba_udc_device = {
143 .name = "atmel_usba_udc",
144 .id = -1,
145 .dev = {
146 .platform_data = &usba_udc_data.pdata,
147 },
148 .resource = usba_udc_resources,
149 .num_resources = ARRAY_SIZE(usba_udc_resources),
150};
151
152void __init at91_add_device_usba(struct usba_platform_data *data)
153{
154 at91_sys_write(AT91_MATRIX_UDPHS, AT91_MATRIX_SELECT_UDPHS |
155 AT91_MATRIX_UDPHS_BYPASS_LOCK);
156
157 /*
158 * Invalid pins are 0 on AT91, but the usba driver is shared
159 * with AVR32, which use negative values instead. Once/if
160 * gpio_is_valid() is ported to AT91, revisit this code.
161 */
162 usba_udc_data.pdata.vbus_pin = -EINVAL;
163 usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
164 memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));;
165
166 if (data && data->vbus_pin > 0) {
167 at91_set_gpio_input(data->vbus_pin, 0);
168 at91_set_deglitch(data->vbus_pin, 1);
169 usba_udc_data.pdata.vbus_pin = data->vbus_pin;
170 }
171
172 /* Pullup pin is handled internally by USB device peripheral */
173
174 /* Clocks */
175 at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk");
176 at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk");
177
178 platform_device_register(&at91_usba_udc_device);
179}
180#else
181void __init at91_add_device_usba(struct usba_platform_data *data) {}
182#endif
183
184
185/* --------------------------------------------------------------------
87 * Ethernet 186 * Ethernet
88 * -------------------------------------------------------------------- */ 187 * -------------------------------------------------------------------- */
89 188
@@ -246,7 +345,7 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
246 } 345 }
247 346
248 mmc0_data = *data; 347 mmc0_data = *data;
249 at91_clock_associate("mci0_clk", &at91cap9_mmc1_device.dev, "mci_clk"); 348 at91_clock_associate("mci0_clk", &at91cap9_mmc0_device.dev, "mci_clk");
250 platform_device_register(&at91cap9_mmc0_device); 349 platform_device_register(&at91cap9_mmc0_device);
251 } else { /* MCI1 */ 350 } else { /* MCI1 */
252 /* CLK */ 351 /* CLK */
@@ -283,10 +382,15 @@ static struct at91_nand_data nand_data;
283#define NAND_BASE AT91_CHIPSELECT_3 382#define NAND_BASE AT91_CHIPSELECT_3
284 383
285static struct resource nand_resources[] = { 384static struct resource nand_resources[] = {
286 { 385 [0] = {
287 .start = NAND_BASE, 386 .start = NAND_BASE,
288 .end = NAND_BASE + SZ_256M - 1, 387 .end = NAND_BASE + SZ_256M - 1,
289 .flags = IORESOURCE_MEM, 388 .flags = IORESOURCE_MEM,
389 },
390 [1] = {
391 .start = AT91_BASE_SYS + AT91_ECC,
392 .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
393 .flags = IORESOURCE_MEM,
290 } 394 }
291}; 395};
292 396
@@ -344,6 +448,7 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
344void __init at91_add_device_nand(struct at91_nand_data *data) {} 448void __init at91_add_device_nand(struct at91_nand_data *data) {}
345#endif 449#endif
346 450
451
347/* -------------------------------------------------------------------- 452/* --------------------------------------------------------------------
348 * TWI (i2c) 453 * TWI (i2c)
349 * -------------------------------------------------------------------- */ 454 * -------------------------------------------------------------------- */
@@ -532,13 +637,59 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
532 637
533 638
534/* -------------------------------------------------------------------- 639/* --------------------------------------------------------------------
640 * Timer/Counter block
641 * -------------------------------------------------------------------- */
642
643#ifdef CONFIG_ATMEL_TCLIB
644
645static struct resource tcb_resources[] = {
646 [0] = {
647 .start = AT91CAP9_BASE_TCB0,
648 .end = AT91CAP9_BASE_TCB0 + SZ_16K - 1,
649 .flags = IORESOURCE_MEM,
650 },
651 [1] = {
652 .start = AT91CAP9_ID_TCB,
653 .end = AT91CAP9_ID_TCB,
654 .flags = IORESOURCE_IRQ,
655 },
656};
657
658static struct platform_device at91cap9_tcb_device = {
659 .name = "atmel_tcb",
660 .id = 0,
661 .resource = tcb_resources,
662 .num_resources = ARRAY_SIZE(tcb_resources),
663};
664
665static void __init at91_add_device_tc(void)
666{
667 /* this chip has one clock and irq for all three TC channels */
668 at91_clock_associate("tcb_clk", &at91cap9_tcb_device.dev, "t0_clk");
669 platform_device_register(&at91cap9_tcb_device);
670}
671#else
672static void __init at91_add_device_tc(void) { }
673#endif
674
675
676/* --------------------------------------------------------------------
535 * RTT 677 * RTT
536 * -------------------------------------------------------------------- */ 678 * -------------------------------------------------------------------- */
537 679
680static struct resource rtt_resources[] = {
681 {
682 .start = AT91_BASE_SYS + AT91_RTT,
683 .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
684 .flags = IORESOURCE_MEM,
685 }
686};
687
538static struct platform_device at91cap9_rtt_device = { 688static struct platform_device at91cap9_rtt_device = {
539 .name = "at91_rtt", 689 .name = "at91_rtt",
540 .id = -1, 690 .id = 0,
541 .num_resources = 0, 691 .resource = rtt_resources,
692 .num_resources = ARRAY_SIZE(rtt_resources),
542}; 693};
543 694
544static void __init at91_add_device_rtt(void) 695static void __init at91_add_device_rtt(void)
@@ -990,7 +1141,7 @@ static inline void configure_usart2_pins(unsigned pins)
990 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */ 1141 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
991} 1142}
992 1143
993static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1144static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
994struct platform_device *atmel_default_console_device; /* the serial console device */ 1145struct platform_device *atmel_default_console_device; /* the serial console device */
995 1146
996void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1147void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
@@ -1031,8 +1182,6 @@ void __init at91_set_serial_console(unsigned portnr)
1031{ 1182{
1032 if (portnr < ATMEL_MAX_UART) 1183 if (portnr < ATMEL_MAX_UART)
1033 atmel_default_console_device = at91_uarts[portnr]; 1184 atmel_default_console_device = at91_uarts[portnr];
1034 if (!atmel_default_console_device)
1035 printk(KERN_INFO "AT91: No default serial console defined.\n");
1036} 1185}
1037 1186
1038void __init at91_add_device_serial(void) 1187void __init at91_add_device_serial(void)
@@ -1043,6 +1192,9 @@ void __init at91_add_device_serial(void)
1043 if (at91_uarts[i]) 1192 if (at91_uarts[i])
1044 platform_device_register(at91_uarts[i]); 1193 platform_device_register(at91_uarts[i]);
1045 } 1194 }
1195
1196 if (!atmel_default_console_device)
1197 printk(KERN_INFO "AT91: No default serial console defined.\n");
1046} 1198}
1047#else 1199#else
1048void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1200void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
@@ -1060,6 +1212,7 @@ static int __init at91_add_standard_devices(void)
1060{ 1212{
1061 at91_add_device_rtt(); 1213 at91_add_device_rtt();
1062 at91_add_device_watchdog(); 1214 at91_add_device_watchdog();
1215 at91_add_device_tc();
1063 return 0; 1216 return 0;
1064} 1217}
1065 1218
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index ef6aeb86e980..de19bee83f75 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -577,6 +577,90 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
577 577
578 578
579/* -------------------------------------------------------------------- 579/* --------------------------------------------------------------------
580 * Timer/Counter blocks
581 * -------------------------------------------------------------------- */
582
583#ifdef CONFIG_ATMEL_TCLIB
584
585static struct resource tcb0_resources[] = {
586 [0] = {
587 .start = AT91RM9200_BASE_TCB0,
588 .end = AT91RM9200_BASE_TCB0 + SZ_16K - 1,
589 .flags = IORESOURCE_MEM,
590 },
591 [1] = {
592 .start = AT91RM9200_ID_TC0,
593 .end = AT91RM9200_ID_TC0,
594 .flags = IORESOURCE_IRQ,
595 },
596 [2] = {
597 .start = AT91RM9200_ID_TC1,
598 .end = AT91RM9200_ID_TC1,
599 .flags = IORESOURCE_IRQ,
600 },
601 [3] = {
602 .start = AT91RM9200_ID_TC2,
603 .end = AT91RM9200_ID_TC2,
604 .flags = IORESOURCE_IRQ,
605 },
606};
607
608static struct platform_device at91rm9200_tcb0_device = {
609 .name = "atmel_tcb",
610 .id = 0,
611 .resource = tcb0_resources,
612 .num_resources = ARRAY_SIZE(tcb0_resources),
613};
614
615static struct resource tcb1_resources[] = {
616 [0] = {
617 .start = AT91RM9200_BASE_TCB1,
618 .end = AT91RM9200_BASE_TCB1 + SZ_16K - 1,
619 .flags = IORESOURCE_MEM,
620 },
621 [1] = {
622 .start = AT91RM9200_ID_TC3,
623 .end = AT91RM9200_ID_TC3,
624 .flags = IORESOURCE_IRQ,
625 },
626 [2] = {
627 .start = AT91RM9200_ID_TC4,
628 .end = AT91RM9200_ID_TC4,
629 .flags = IORESOURCE_IRQ,
630 },
631 [3] = {
632 .start = AT91RM9200_ID_TC5,
633 .end = AT91RM9200_ID_TC5,
634 .flags = IORESOURCE_IRQ,
635 },
636};
637
638static struct platform_device at91rm9200_tcb1_device = {
639 .name = "atmel_tcb",
640 .id = 1,
641 .resource = tcb1_resources,
642 .num_resources = ARRAY_SIZE(tcb1_resources),
643};
644
645static void __init at91_add_device_tc(void)
646{
647 /* this chip has a separate clock and irq for each TC channel */
648 at91_clock_associate("tc0_clk", &at91rm9200_tcb0_device.dev, "t0_clk");
649 at91_clock_associate("tc1_clk", &at91rm9200_tcb0_device.dev, "t1_clk");
650 at91_clock_associate("tc2_clk", &at91rm9200_tcb0_device.dev, "t2_clk");
651 platform_device_register(&at91rm9200_tcb0_device);
652
653 at91_clock_associate("tc3_clk", &at91rm9200_tcb1_device.dev, "t0_clk");
654 at91_clock_associate("tc4_clk", &at91rm9200_tcb1_device.dev, "t1_clk");
655 at91_clock_associate("tc5_clk", &at91rm9200_tcb1_device.dev, "t2_clk");
656 platform_device_register(&at91rm9200_tcb1_device);
657}
658#else
659static void __init at91_add_device_tc(void) { }
660#endif
661
662
663/* --------------------------------------------------------------------
580 * RTC 664 * RTC
581 * -------------------------------------------------------------------- */ 665 * -------------------------------------------------------------------- */
582 666
@@ -1019,7 +1103,7 @@ static inline void configure_usart3_pins(unsigned pins)
1019 at91_set_B_periph(AT91_PIN_PB0, 0); /* RTS3 */ 1103 at91_set_B_periph(AT91_PIN_PB0, 0); /* RTS3 */
1020} 1104}
1021 1105
1022static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1106static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1023struct platform_device *atmel_default_console_device; /* the serial console device */ 1107struct platform_device *atmel_default_console_device; /* the serial console device */
1024 1108
1025void __init __deprecated at91_init_serial(struct at91_uart_config *config) 1109void __init __deprecated at91_init_serial(struct at91_uart_config *config)
@@ -1110,8 +1194,6 @@ void __init at91_set_serial_console(unsigned portnr)
1110{ 1194{
1111 if (portnr < ATMEL_MAX_UART) 1195 if (portnr < ATMEL_MAX_UART)
1112 atmel_default_console_device = at91_uarts[portnr]; 1196 atmel_default_console_device = at91_uarts[portnr];
1113 if (!atmel_default_console_device)
1114 printk(KERN_INFO "AT91: No default serial console defined.\n");
1115} 1197}
1116 1198
1117void __init at91_add_device_serial(void) 1199void __init at91_add_device_serial(void)
@@ -1122,6 +1204,9 @@ void __init at91_add_device_serial(void)
1122 if (at91_uarts[i]) 1204 if (at91_uarts[i])
1123 platform_device_register(at91_uarts[i]); 1205 platform_device_register(at91_uarts[i]);
1124 } 1206 }
1207
1208 if (!atmel_default_console_device)
1209 printk(KERN_INFO "AT91: No default serial console defined.\n");
1125} 1210}
1126#else 1211#else
1127void __init __deprecated at91_init_serial(struct at91_uart_config *config) {} 1212void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
@@ -1141,6 +1226,7 @@ static int __init at91_add_standard_devices(void)
1141{ 1226{
1142 at91_add_device_rtc(); 1227 at91_add_device_rtc();
1143 at91_add_device_watchdog(); 1228 at91_add_device_watchdog();
1229 at91_add_device_tc();
1144 return 0; 1230 return 0;
1145} 1231}
1146 1232
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 18d06612ce8a..380f12a12200 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -11,6 +11,7 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pm.h>
14 15
15#include <asm/mach/arch.h> 16#include <asm/mach/arch.h>
16#include <asm/mach/map.h> 17#include <asm/mach/map.h>
@@ -18,6 +19,7 @@
18#include <asm/arch/at91sam9260.h> 19#include <asm/arch/at91sam9260.h>
19#include <asm/arch/at91_pmc.h> 20#include <asm/arch/at91_pmc.h>
20#include <asm/arch/at91_rstc.h> 21#include <asm/arch/at91_rstc.h>
22#include <asm/arch/at91_shdwc.h>
21 23
22#include "generic.h" 24#include "generic.h"
23#include "clock.h" 25#include "clock.h"
@@ -45,6 +47,20 @@ static struct map_desc at91sam9260_sram_desc[] __initdata = {
45 } 47 }
46}; 48};
47 49
50static struct map_desc at91sam9g20_sram_desc[] __initdata = {
51 {
52 .virtual = AT91_IO_VIRT_BASE - AT91SAM9G20_SRAM0_SIZE,
53 .pfn = __phys_to_pfn(AT91SAM9G20_SRAM0_BASE),
54 .length = AT91SAM9G20_SRAM0_SIZE,
55 .type = MT_DEVICE,
56 }, {
57 .virtual = AT91_IO_VIRT_BASE - AT91SAM9G20_SRAM0_SIZE - AT91SAM9G20_SRAM1_SIZE,
58 .pfn = __phys_to_pfn(AT91SAM9G20_SRAM1_BASE),
59 .length = AT91SAM9G20_SRAM1_SIZE,
60 .type = MT_DEVICE,
61 }
62};
63
48static struct map_desc at91sam9xe_sram_desc[] __initdata = { 64static struct map_desc at91sam9xe_sram_desc[] __initdata = {
49 { 65 {
50 .pfn = __phys_to_pfn(AT91SAM9XE_SRAM_BASE), 66 .pfn = __phys_to_pfn(AT91SAM9XE_SRAM_BASE),
@@ -267,6 +283,11 @@ static void at91sam9260_reset(void)
267 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); 283 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
268} 284}
269 285
286static void at91sam9260_poweroff(void)
287{
288 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
289}
290
270 291
271/* -------------------------------------------------------------------- 292/* --------------------------------------------------------------------
272 * AT91SAM9260 processor initialization 293 * AT91SAM9260 processor initialization
@@ -300,10 +321,13 @@ void __init at91sam9260_initialize(unsigned long main_clock)
300 321
301 if (cpu_is_at91sam9xe()) 322 if (cpu_is_at91sam9xe())
302 at91sam9xe_initialize(); 323 at91sam9xe_initialize();
324 else if (cpu_is_at91sam9g20())
325 iotable_init(at91sam9g20_sram_desc, ARRAY_SIZE(at91sam9g20_sram_desc));
303 else 326 else
304 iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc)); 327 iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc));
305 328
306 at91_arch_reset = at91sam9260_reset; 329 at91_arch_reset = at91sam9260_reset;
330 pm_power_off = at91sam9260_poweroff;
307 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1) 331 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1)
308 | (1 << AT91SAM9260_ID_IRQ2); 332 | (1 << AT91SAM9260_ID_IRQ2);
309 333
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 105f8403860b..86cba4ac29b1 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -18,9 +18,10 @@
18 18
19#include <asm/arch/board.h> 19#include <asm/arch/board.h>
20#include <asm/arch/gpio.h> 20#include <asm/arch/gpio.h>
21#include <asm/arch/cpu.h>
21#include <asm/arch/at91sam9260.h> 22#include <asm/arch/at91sam9260.h>
22#include <asm/arch/at91sam926x_mc.h>
23#include <asm/arch/at91sam9260_matrix.h> 23#include <asm/arch/at91sam9260_matrix.h>
24#include <asm/arch/at91sam9_smc.h>
24 25
25#include "generic.h" 26#include "generic.h"
26 27
@@ -288,10 +289,15 @@ static struct at91_nand_data nand_data;
288#define NAND_BASE AT91_CHIPSELECT_3 289#define NAND_BASE AT91_CHIPSELECT_3
289 290
290static struct resource nand_resources[] = { 291static struct resource nand_resources[] = {
291 { 292 [0] = {
292 .start = NAND_BASE, 293 .start = NAND_BASE,
293 .end = NAND_BASE + SZ_256M - 1, 294 .end = NAND_BASE + SZ_256M - 1,
294 .flags = IORESOURCE_MEM, 295 .flags = IORESOURCE_MEM,
296 },
297 [1] = {
298 .start = AT91_BASE_SYS + AT91_ECC,
299 .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
300 .flags = IORESOURCE_MEM,
295 } 301 }
296}; 302};
297 303
@@ -315,20 +321,41 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
315 csa = at91_sys_read(AT91_MATRIX_EBICSA); 321 csa = at91_sys_read(AT91_MATRIX_EBICSA);
316 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); 322 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
317 323
318 /* set the bus interface characteristics */ 324 if (cpu_is_at91sam9260()) {
319 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0) 325 /* Timing for sam9260 */
320 | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0)); 326 /* set the bus interface characteristics */
327 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(1) | AT91_SMC_NCS_WRSETUP_(0)
328 | AT91_SMC_NRDSETUP_(1) | AT91_SMC_NCS_RDSETUP_(0));
329
330 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3)
331 | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
332
333 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
334
335 if (data->bus_width_16)
336 mode = AT91_SMC_DBW_16;
337 else
338 mode = AT91_SMC_DBW_8;
339 at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(2));
340 }
341
342 if (cpu_is_at91sam9g20()) {
343 /* Timing for sam9g20 */
344 /* set the bus interface characteristics */
345 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(2) | AT91_SMC_NCS_WRSETUP_(0)
346 | AT91_SMC_NRDSETUP_(2) | AT91_SMC_NCS_RDSETUP_(0));
321 347
322 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3) 348 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(4) | AT91_SMC_NCS_WRPULSE_(4)
323 | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3)); 349 | AT91_SMC_NRDPULSE_(4) | AT91_SMC_NCS_RDPULSE_(4));
324 350
325 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5)); 351 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7));
326 352
327 if (data->bus_width_16) 353 if (data->bus_width_16)
328 mode = AT91_SMC_DBW_16; 354 mode = AT91_SMC_DBW_16;
329 else 355 else
330 mode = AT91_SMC_DBW_8; 356 mode = AT91_SMC_DBW_8;
331 at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(2)); 357 at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(3));
358 }
332 359
333 /* enable pin */ 360 /* enable pin */
334 if (data->enable_pin) 361 if (data->enable_pin)
@@ -540,6 +567,90 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
540 567
541 568
542/* -------------------------------------------------------------------- 569/* --------------------------------------------------------------------
570 * Timer/Counter blocks
571 * -------------------------------------------------------------------- */
572
573#ifdef CONFIG_ATMEL_TCLIB
574
575static struct resource tcb0_resources[] = {
576 [0] = {
577 .start = AT91SAM9260_BASE_TCB0,
578 .end = AT91SAM9260_BASE_TCB0 + SZ_16K - 1,
579 .flags = IORESOURCE_MEM,
580 },
581 [1] = {
582 .start = AT91SAM9260_ID_TC0,
583 .end = AT91SAM9260_ID_TC0,
584 .flags = IORESOURCE_IRQ,
585 },
586 [2] = {
587 .start = AT91SAM9260_ID_TC1,
588 .end = AT91SAM9260_ID_TC1,
589 .flags = IORESOURCE_IRQ,
590 },
591 [3] = {
592 .start = AT91SAM9260_ID_TC2,
593 .end = AT91SAM9260_ID_TC2,
594 .flags = IORESOURCE_IRQ,
595 },
596};
597
598static struct platform_device at91sam9260_tcb0_device = {
599 .name = "atmel_tcb",
600 .id = 0,
601 .resource = tcb0_resources,
602 .num_resources = ARRAY_SIZE(tcb0_resources),
603};
604
605static struct resource tcb1_resources[] = {
606 [0] = {
607 .start = AT91SAM9260_BASE_TCB1,
608 .end = AT91SAM9260_BASE_TCB1 + SZ_16K - 1,
609 .flags = IORESOURCE_MEM,
610 },
611 [1] = {
612 .start = AT91SAM9260_ID_TC3,
613 .end = AT91SAM9260_ID_TC3,
614 .flags = IORESOURCE_IRQ,
615 },
616 [2] = {
617 .start = AT91SAM9260_ID_TC4,
618 .end = AT91SAM9260_ID_TC4,
619 .flags = IORESOURCE_IRQ,
620 },
621 [3] = {
622 .start = AT91SAM9260_ID_TC5,
623 .end = AT91SAM9260_ID_TC5,
624 .flags = IORESOURCE_IRQ,
625 },
626};
627
628static struct platform_device at91sam9260_tcb1_device = {
629 .name = "atmel_tcb",
630 .id = 1,
631 .resource = tcb1_resources,
632 .num_resources = ARRAY_SIZE(tcb1_resources),
633};
634
635static void __init at91_add_device_tc(void)
636{
637 /* this chip has a separate clock and irq for each TC channel */
638 at91_clock_associate("tc0_clk", &at91sam9260_tcb0_device.dev, "t0_clk");
639 at91_clock_associate("tc1_clk", &at91sam9260_tcb0_device.dev, "t1_clk");
640 at91_clock_associate("tc2_clk", &at91sam9260_tcb0_device.dev, "t2_clk");
641 platform_device_register(&at91sam9260_tcb0_device);
642
643 at91_clock_associate("tc3_clk", &at91sam9260_tcb1_device.dev, "t0_clk");
644 at91_clock_associate("tc4_clk", &at91sam9260_tcb1_device.dev, "t1_clk");
645 at91_clock_associate("tc5_clk", &at91sam9260_tcb1_device.dev, "t2_clk");
646 platform_device_register(&at91sam9260_tcb1_device);
647}
648#else
649static void __init at91_add_device_tc(void) { }
650#endif
651
652
653/* --------------------------------------------------------------------
543 * RTT 654 * RTT
544 * -------------------------------------------------------------------- */ 655 * -------------------------------------------------------------------- */
545 656
@@ -553,7 +664,7 @@ static struct resource rtt_resources[] = {
553 664
554static struct platform_device at91sam9260_rtt_device = { 665static struct platform_device at91sam9260_rtt_device = {
555 .name = "at91_rtt", 666 .name = "at91_rtt",
556 .id = -1, 667 .id = 0,
557 .resource = rtt_resources, 668 .resource = rtt_resources,
558 .num_resources = ARRAY_SIZE(rtt_resources), 669 .num_resources = ARRAY_SIZE(rtt_resources),
559}; 670};
@@ -962,64 +1073,9 @@ static inline void configure_usart5_pins(void)
962 at91_set_A_periph(AT91_PIN_PB13, 0); /* RXD5 */ 1073 at91_set_A_periph(AT91_PIN_PB13, 0); /* RXD5 */
963} 1074}
964 1075
965static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1076static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
966struct platform_device *atmel_default_console_device; /* the serial console device */ 1077struct platform_device *atmel_default_console_device; /* the serial console device */
967 1078
968void __init __deprecated at91_init_serial(struct at91_uart_config *config)
969{
970 int i;
971
972 /* Fill in list of supported UARTs */
973 for (i = 0; i < config->nr_tty; i++) {
974 switch (config->tty_map[i]) {
975 case 0:
976 configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS | ATMEL_UART_DSR | ATMEL_UART_DTR | ATMEL_UART_DCD | ATMEL_UART_RI);
977 at91_uarts[i] = &at91sam9260_uart0_device;
978 at91_clock_associate("usart0_clk", &at91sam9260_uart0_device.dev, "usart");
979 break;
980 case 1:
981 configure_usart1_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
982 at91_uarts[i] = &at91sam9260_uart1_device;
983 at91_clock_associate("usart1_clk", &at91sam9260_uart1_device.dev, "usart");
984 break;
985 case 2:
986 configure_usart2_pins(0);
987 at91_uarts[i] = &at91sam9260_uart2_device;
988 at91_clock_associate("usart2_clk", &at91sam9260_uart2_device.dev, "usart");
989 break;
990 case 3:
991 configure_usart3_pins(0);
992 at91_uarts[i] = &at91sam9260_uart3_device;
993 at91_clock_associate("usart3_clk", &at91sam9260_uart3_device.dev, "usart");
994 break;
995 case 4:
996 configure_usart4_pins();
997 at91_uarts[i] = &at91sam9260_uart4_device;
998 at91_clock_associate("usart4_clk", &at91sam9260_uart4_device.dev, "usart");
999 break;
1000 case 5:
1001 configure_usart5_pins();
1002 at91_uarts[i] = &at91sam9260_uart5_device;
1003 at91_clock_associate("usart5_clk", &at91sam9260_uart5_device.dev, "usart");
1004 break;
1005 case 6:
1006 configure_dbgu_pins();
1007 at91_uarts[i] = &at91sam9260_dbgu_device;
1008 at91_clock_associate("mck", &at91sam9260_dbgu_device.dev, "usart");
1009 break;
1010 default:
1011 continue;
1012 }
1013 at91_uarts[i]->id = i; /* update ID number to mapped ID */
1014 }
1015
1016 /* Set serial console device */
1017 if (config->console_tty < ATMEL_MAX_UART)
1018 atmel_default_console_device = at91_uarts[config->console_tty];
1019 if (!atmel_default_console_device)
1020 printk(KERN_INFO "AT91: No default serial console defined.\n");
1021}
1022
1023void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1079void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1024{ 1080{
1025 struct platform_device *pdev; 1081 struct platform_device *pdev;
@@ -1073,8 +1129,6 @@ void __init at91_set_serial_console(unsigned portnr)
1073{ 1129{
1074 if (portnr < ATMEL_MAX_UART) 1130 if (portnr < ATMEL_MAX_UART)
1075 atmel_default_console_device = at91_uarts[portnr]; 1131 atmel_default_console_device = at91_uarts[portnr];
1076 if (!atmel_default_console_device)
1077 printk(KERN_INFO "AT91: No default serial console defined.\n");
1078} 1132}
1079 1133
1080void __init at91_add_device_serial(void) 1134void __init at91_add_device_serial(void)
@@ -1085,9 +1139,11 @@ void __init at91_add_device_serial(void)
1085 if (at91_uarts[i]) 1139 if (at91_uarts[i])
1086 platform_device_register(at91_uarts[i]); 1140 platform_device_register(at91_uarts[i]);
1087 } 1141 }
1142
1143 if (!atmel_default_console_device)
1144 printk(KERN_INFO "AT91: No default serial console defined.\n");
1088} 1145}
1089#else 1146#else
1090void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
1091void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1147void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1092void __init at91_set_serial_console(unsigned portnr) {} 1148void __init at91_set_serial_console(unsigned portnr) {}
1093void __init at91_add_device_serial(void) {} 1149void __init at91_add_device_serial(void) {}
@@ -1103,6 +1159,7 @@ static int __init at91_add_standard_devices(void)
1103{ 1159{
1104 at91_add_device_rtt(); 1160 at91_add_device_rtt();
1105 at91_add_device_watchdog(); 1161 at91_add_device_watchdog();
1162 at91_add_device_tc();
1106 return 0; 1163 return 0;
1107} 1164}
1108 1165
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 90b87e1877d9..35bf6fd52516 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -11,12 +11,14 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pm.h>
14 15
15#include <asm/mach/arch.h> 16#include <asm/mach/arch.h>
16#include <asm/mach/map.h> 17#include <asm/mach/map.h>
17#include <asm/arch/at91sam9261.h> 18#include <asm/arch/at91sam9261.h>
18#include <asm/arch/at91_pmc.h> 19#include <asm/arch/at91_pmc.h>
19#include <asm/arch/at91_rstc.h> 20#include <asm/arch/at91_rstc.h>
21#include <asm/arch/at91_shdwc.h>
20 22
21#include "generic.h" 23#include "generic.h"
22#include "clock.h" 24#include "clock.h"
@@ -245,6 +247,11 @@ static void at91sam9261_reset(void)
245 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); 247 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
246} 248}
247 249
250static void at91sam9261_poweroff(void)
251{
252 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
253}
254
248 255
249/* -------------------------------------------------------------------- 256/* --------------------------------------------------------------------
250 * AT91SAM9261 processor initialization 257 * AT91SAM9261 processor initialization
@@ -256,6 +263,7 @@ void __init at91sam9261_initialize(unsigned long main_clock)
256 iotable_init(at91sam9261_io_desc, ARRAY_SIZE(at91sam9261_io_desc)); 263 iotable_init(at91sam9261_io_desc, ARRAY_SIZE(at91sam9261_io_desc));
257 264
258 at91_arch_reset = at91sam9261_reset; 265 at91_arch_reset = at91sam9261_reset;
266 pm_power_off = at91sam9261_poweroff;
259 at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1) 267 at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1)
260 | (1 << AT91SAM9261_ID_IRQ2); 268 | (1 << AT91SAM9261_ID_IRQ2);
261 269
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 245641263fce..ec1891375dfb 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -24,7 +24,7 @@
24#include <asm/arch/gpio.h> 24#include <asm/arch/gpio.h>
25#include <asm/arch/at91sam9261.h> 25#include <asm/arch/at91sam9261.h>
26#include <asm/arch/at91sam9261_matrix.h> 26#include <asm/arch/at91sam9261_matrix.h>
27#include <asm/arch/at91sam926x_mc.h> 27#include <asm/arch/at91sam9_smc.h>
28 28
29#include "generic.h" 29#include "generic.h"
30 30
@@ -232,19 +232,19 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
232 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); 232 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
233 233
234 /* set the bus interface characteristics */ 234 /* set the bus interface characteristics */
235 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0) 235 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(1) | AT91_SMC_NCS_WRSETUP_(0)
236 | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0)); 236 | AT91_SMC_NRDSETUP_(1) | AT91_SMC_NCS_RDSETUP_(0));
237 237
238 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(2) | AT91_SMC_NCS_WRPULSE_(5) 238 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3)
239 | AT91_SMC_NRDPULSE_(2) | AT91_SMC_NCS_RDPULSE_(5)); 239 | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
240 240
241 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7)); 241 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
242 242
243 if (data->bus_width_16) 243 if (data->bus_width_16)
244 mode = AT91_SMC_DBW_16; 244 mode = AT91_SMC_DBW_16;
245 else 245 else
246 mode = AT91_SMC_DBW_8; 246 mode = AT91_SMC_DBW_8;
247 at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(1)); 247 at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(2));
248 248
249 /* enable pin */ 249 /* enable pin */
250 if (data->enable_pin) 250 if (data->enable_pin)
@@ -539,6 +539,17 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
539 at91_set_B_periph(AT91_PIN_PB28, 0); /* LCDD23 */ 539 at91_set_B_periph(AT91_PIN_PB28, 0); /* LCDD23 */
540#endif 540#endif
541 541
542 if (ARRAY_SIZE(lcdc_resources) > 2) {
543 void __iomem *fb;
544 struct resource *fb_res = &lcdc_resources[2];
545 size_t fb_len = fb_res->end - fb_res->start + 1;
546
547 fb = ioremap(fb_res->start, fb_len);
548 if (fb) {
549 memset(fb, 0, fb_len);
550 iounmap(fb);
551 }
552 }
542 lcdc_data = *data; 553 lcdc_data = *data;
543 platform_device_register(&at91_lcdc_device); 554 platform_device_register(&at91_lcdc_device);
544} 555}
@@ -548,6 +559,55 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
548 559
549 560
550/* -------------------------------------------------------------------- 561/* --------------------------------------------------------------------
562 * Timer/Counter block
563 * -------------------------------------------------------------------- */
564
565#ifdef CONFIG_ATMEL_TCLIB
566
567static struct resource tcb_resources[] = {
568 [0] = {
569 .start = AT91SAM9261_BASE_TCB0,
570 .end = AT91SAM9261_BASE_TCB0 + SZ_16K - 1,
571 .flags = IORESOURCE_MEM,
572 },
573 [1] = {
574 .start = AT91SAM9261_ID_TC0,
575 .end = AT91SAM9261_ID_TC0,
576 .flags = IORESOURCE_IRQ,
577 },
578 [2] = {
579 .start = AT91SAM9261_ID_TC1,
580 .end = AT91SAM9261_ID_TC1,
581 .flags = IORESOURCE_IRQ,
582 },
583 [3] = {
584 .start = AT91SAM9261_ID_TC2,
585 .end = AT91SAM9261_ID_TC2,
586 .flags = IORESOURCE_IRQ,
587 },
588};
589
590static struct platform_device at91sam9261_tcb_device = {
591 .name = "atmel_tcb",
592 .id = 0,
593 .resource = tcb_resources,
594 .num_resources = ARRAY_SIZE(tcb_resources),
595};
596
597static void __init at91_add_device_tc(void)
598{
599 /* this chip has a separate clock and irq for each TC channel */
600 at91_clock_associate("tc0_clk", &at91sam9261_tcb_device.dev, "t0_clk");
601 at91_clock_associate("tc1_clk", &at91sam9261_tcb_device.dev, "t1_clk");
602 at91_clock_associate("tc2_clk", &at91sam9261_tcb_device.dev, "t2_clk");
603 platform_device_register(&at91sam9261_tcb_device);
604}
605#else
606static void __init at91_add_device_tc(void) { }
607#endif
608
609
610/* --------------------------------------------------------------------
551 * RTT 611 * RTT
552 * -------------------------------------------------------------------- */ 612 * -------------------------------------------------------------------- */
553 613
@@ -561,7 +621,7 @@ static struct resource rtt_resources[] = {
561 621
562static struct platform_device at91sam9261_rtt_device = { 622static struct platform_device at91sam9261_rtt_device = {
563 .name = "at91_rtt", 623 .name = "at91_rtt",
564 .id = -1, 624 .id = 0,
565 .resource = rtt_resources, 625 .resource = rtt_resources,
566 .num_resources = ARRAY_SIZE(rtt_resources), 626 .num_resources = ARRAY_SIZE(rtt_resources),
567}; 627};
@@ -938,49 +998,9 @@ static inline void configure_usart2_pins(unsigned pins)
938 at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */ 998 at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */
939} 999}
940 1000
941static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1001static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
942struct platform_device *atmel_default_console_device; /* the serial console device */ 1002struct platform_device *atmel_default_console_device; /* the serial console device */
943 1003
944void __init __deprecated at91_init_serial(struct at91_uart_config *config)
945{
946 int i;
947
948 /* Fill in list of supported UARTs */
949 for (i = 0; i < config->nr_tty; i++) {
950 switch (config->tty_map[i]) {
951 case 0:
952 configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
953 at91_uarts[i] = &at91sam9261_uart0_device;
954 at91_clock_associate("usart0_clk", &at91sam9261_uart0_device.dev, "usart");
955 break;
956 case 1:
957 configure_usart1_pins(0);
958 at91_uarts[i] = &at91sam9261_uart1_device;
959 at91_clock_associate("usart1_clk", &at91sam9261_uart1_device.dev, "usart");
960 break;
961 case 2:
962 configure_usart2_pins(0);
963 at91_uarts[i] = &at91sam9261_uart2_device;
964 at91_clock_associate("usart2_clk", &at91sam9261_uart2_device.dev, "usart");
965 break;
966 case 3:
967 configure_dbgu_pins();
968 at91_uarts[i] = &at91sam9261_dbgu_device;
969 at91_clock_associate("mck", &at91sam9261_dbgu_device.dev, "usart");
970 break;
971 default:
972 continue;
973 }
974 at91_uarts[i]->id = i; /* update ID number to mapped ID */
975 }
976
977 /* Set serial console device */
978 if (config->console_tty < ATMEL_MAX_UART)
979 atmel_default_console_device = at91_uarts[config->console_tty];
980 if (!atmel_default_console_device)
981 printk(KERN_INFO "AT91: No default serial console defined.\n");
982}
983
984void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1004void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
985{ 1005{
986 struct platform_device *pdev; 1006 struct platform_device *pdev;
@@ -1019,8 +1039,6 @@ void __init at91_set_serial_console(unsigned portnr)
1019{ 1039{
1020 if (portnr < ATMEL_MAX_UART) 1040 if (portnr < ATMEL_MAX_UART)
1021 atmel_default_console_device = at91_uarts[portnr]; 1041 atmel_default_console_device = at91_uarts[portnr];
1022 if (!atmel_default_console_device)
1023 printk(KERN_INFO "AT91: No default serial console defined.\n");
1024} 1042}
1025 1043
1026void __init at91_add_device_serial(void) 1044void __init at91_add_device_serial(void)
@@ -1031,9 +1049,11 @@ void __init at91_add_device_serial(void)
1031 if (at91_uarts[i]) 1049 if (at91_uarts[i])
1032 platform_device_register(at91_uarts[i]); 1050 platform_device_register(at91_uarts[i]);
1033 } 1051 }
1052
1053 if (!atmel_default_console_device)
1054 printk(KERN_INFO "AT91: No default serial console defined.\n");
1034} 1055}
1035#else 1056#else
1036void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
1037void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1057void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1038void __init at91_set_serial_console(unsigned portnr) {} 1058void __init at91_set_serial_console(unsigned portnr) {}
1039void __init at91_add_device_serial(void) {} 1059void __init at91_add_device_serial(void) {}
@@ -1050,6 +1070,7 @@ static int __init at91_add_standard_devices(void)
1050{ 1070{
1051 at91_add_device_rtt(); 1071 at91_add_device_rtt();
1052 at91_add_device_watchdog(); 1072 at91_add_device_watchdog();
1073 at91_add_device_tc();
1053 return 0; 1074 return 0;
1054} 1075}
1055 1076
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index a53ba0f74351..052074a9f2d3 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -11,12 +11,14 @@
11 */ 11 */
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/pm.h>
14 15
15#include <asm/mach/arch.h> 16#include <asm/mach/arch.h>
16#include <asm/mach/map.h> 17#include <asm/mach/map.h>
17#include <asm/arch/at91sam9263.h> 18#include <asm/arch/at91sam9263.h>
18#include <asm/arch/at91_pmc.h> 19#include <asm/arch/at91_pmc.h>
19#include <asm/arch/at91_rstc.h> 20#include <asm/arch/at91_rstc.h>
21#include <asm/arch/at91_shdwc.h>
20 22
21#include "generic.h" 23#include "generic.h"
22#include "clock.h" 24#include "clock.h"
@@ -271,6 +273,11 @@ static void at91sam9263_reset(void)
271 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); 273 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
272} 274}
273 275
276static void at91sam9263_poweroff(void)
277{
278 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
279}
280
274 281
275/* -------------------------------------------------------------------- 282/* --------------------------------------------------------------------
276 * AT91SAM9263 processor initialization 283 * AT91SAM9263 processor initialization
@@ -282,6 +289,7 @@ void __init at91sam9263_initialize(unsigned long main_clock)
282 iotable_init(at91sam9263_io_desc, ARRAY_SIZE(at91sam9263_io_desc)); 289 iotable_init(at91sam9263_io_desc, ARRAY_SIZE(at91sam9263_io_desc));
283 290
284 at91_arch_reset = at91sam9263_reset; 291 at91_arch_reset = at91sam9263_reset;
292 pm_power_off = at91sam9263_poweroff;
285 at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1); 293 at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1);
286 294
287 /* Init clock subsystem */ 295 /* Init clock subsystem */
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 0b12e1adcc8e..8a81f76f0200 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -22,8 +22,8 @@
22#include <asm/arch/board.h> 22#include <asm/arch/board.h>
23#include <asm/arch/gpio.h> 23#include <asm/arch/gpio.h>
24#include <asm/arch/at91sam9263.h> 24#include <asm/arch/at91sam9263.h>
25#include <asm/arch/at91sam926x_mc.h>
26#include <asm/arch/at91sam9263_matrix.h> 25#include <asm/arch/at91sam9263_matrix.h>
26#include <asm/arch/at91sam9_smc.h>
27 27
28#include "generic.h" 28#include "generic.h"
29 29
@@ -308,7 +308,7 @@ void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
308 } 308 }
309 309
310 mmc0_data = *data; 310 mmc0_data = *data;
311 at91_clock_associate("mci0_clk", &at91sam9263_mmc1_device.dev, "mci_clk"); 311 at91_clock_associate("mci0_clk", &at91sam9263_mmc0_device.dev, "mci_clk");
312 platform_device_register(&at91sam9263_mmc0_device); 312 platform_device_register(&at91sam9263_mmc0_device);
313 } else { /* MCI1 */ 313 } else { /* MCI1 */
314 /* CLK */ 314 /* CLK */
@@ -358,10 +358,15 @@ static struct at91_nand_data nand_data;
358#define NAND_BASE AT91_CHIPSELECT_3 358#define NAND_BASE AT91_CHIPSELECT_3
359 359
360static struct resource nand_resources[] = { 360static struct resource nand_resources[] = {
361 { 361 [0] = {
362 .start = NAND_BASE, 362 .start = NAND_BASE,
363 .end = NAND_BASE + SZ_256M - 1, 363 .end = NAND_BASE + SZ_256M - 1,
364 .flags = IORESOURCE_MEM, 364 .flags = IORESOURCE_MEM,
365 },
366 [1] = {
367 .start = AT91_BASE_SYS + AT91_ECC0,
368 .end = AT91_BASE_SYS + AT91_ECC0 + SZ_512 - 1,
369 .flags = IORESOURCE_MEM,
365 } 370 }
366}; 371};
367 372
@@ -386,8 +391,8 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
386 at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA); 391 at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA);
387 392
388 /* set the bus interface characteristics */ 393 /* set the bus interface characteristics */
389 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0) 394 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(1) | AT91_SMC_NCS_WRSETUP_(0)
390 | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0)); 395 | AT91_SMC_NRDSETUP_(1) | AT91_SMC_NCS_RDSETUP_(0));
391 396
392 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3) 397 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3)
393 | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3)); 398 | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
@@ -783,6 +788,43 @@ void __init at91_add_device_isi(void) {}
783 788
784 789
785/* -------------------------------------------------------------------- 790/* --------------------------------------------------------------------
791 * Timer/Counter block
792 * -------------------------------------------------------------------- */
793
794#ifdef CONFIG_ATMEL_TCLIB
795
796static struct resource tcb_resources[] = {
797 [0] = {
798 .start = AT91SAM9263_BASE_TCB0,
799 .end = AT91SAM9263_BASE_TCB0 + SZ_16K - 1,
800 .flags = IORESOURCE_MEM,
801 },
802 [1] = {
803 .start = AT91SAM9263_ID_TCB,
804 .end = AT91SAM9263_ID_TCB,
805 .flags = IORESOURCE_IRQ,
806 },
807};
808
809static struct platform_device at91sam9263_tcb_device = {
810 .name = "atmel_tcb",
811 .id = 0,
812 .resource = tcb_resources,
813 .num_resources = ARRAY_SIZE(tcb_resources),
814};
815
816static void __init at91_add_device_tc(void)
817{
818 /* this chip has one clock and irq for all three TC channels */
819 at91_clock_associate("tcb_clk", &at91sam9263_tcb_device.dev, "t0_clk");
820 platform_device_register(&at91sam9263_tcb_device);
821}
822#else
823static void __init at91_add_device_tc(void) { }
824#endif
825
826
827/* --------------------------------------------------------------------
786 * RTT 828 * RTT
787 * -------------------------------------------------------------------- */ 829 * -------------------------------------------------------------------- */
788 830
@@ -933,9 +975,6 @@ static inline void configure_ssc1_pins(unsigned pins)
933} 975}
934 976
935/* 977/*
936 * Return the device node so that board init code can use it as the
937 * parent for the device node reflecting how it's used on this board.
938 *
939 * SSC controllers are accessed through library code, instead of any 978 * SSC controllers are accessed through library code, instead of any
940 * kind of all-singing/all-dancing driver. For example one could be 979 * kind of all-singing/all-dancing driver. For example one could be
941 * used by a particular I2S audio codec's driver, while another one 980 * used by a particular I2S audio codec's driver, while another one
@@ -1146,49 +1185,9 @@ static inline void configure_usart2_pins(unsigned pins)
1146 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */ 1185 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
1147} 1186}
1148 1187
1149static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1188static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1150struct platform_device *atmel_default_console_device; /* the serial console device */ 1189struct platform_device *atmel_default_console_device; /* the serial console device */
1151 1190
1152void __init __deprecated at91_init_serial(struct at91_uart_config *config)
1153{
1154 int i;
1155
1156 /* Fill in list of supported UARTs */
1157 for (i = 0; i < config->nr_tty; i++) {
1158 switch (config->tty_map[i]) {
1159 case 0:
1160 configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
1161 at91_uarts[i] = &at91sam9263_uart0_device;
1162 at91_clock_associate("usart0_clk", &at91sam9263_uart0_device.dev, "usart");
1163 break;
1164 case 1:
1165 configure_usart1_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
1166 at91_uarts[i] = &at91sam9263_uart1_device;
1167 at91_clock_associate("usart1_clk", &at91sam9263_uart1_device.dev, "usart");
1168 break;
1169 case 2:
1170 configure_usart2_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
1171 at91_uarts[i] = &at91sam9263_uart2_device;
1172 at91_clock_associate("usart2_clk", &at91sam9263_uart2_device.dev, "usart");
1173 break;
1174 case 3:
1175 configure_dbgu_pins();
1176 at91_uarts[i] = &at91sam9263_dbgu_device;
1177 at91_clock_associate("mck", &at91sam9263_dbgu_device.dev, "usart");
1178 break;
1179 default:
1180 continue;
1181 }
1182 at91_uarts[i]->id = i; /* update ID number to mapped ID */
1183 }
1184
1185 /* Set serial console device */
1186 if (config->console_tty < ATMEL_MAX_UART)
1187 atmel_default_console_device = at91_uarts[config->console_tty];
1188 if (!atmel_default_console_device)
1189 printk(KERN_INFO "AT91: No default serial console defined.\n");
1190}
1191
1192void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1191void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1193{ 1192{
1194 struct platform_device *pdev; 1193 struct platform_device *pdev;
@@ -1227,8 +1226,6 @@ void __init at91_set_serial_console(unsigned portnr)
1227{ 1226{
1228 if (portnr < ATMEL_MAX_UART) 1227 if (portnr < ATMEL_MAX_UART)
1229 atmel_default_console_device = at91_uarts[portnr]; 1228 atmel_default_console_device = at91_uarts[portnr];
1230 if (!atmel_default_console_device)
1231 printk(KERN_INFO "AT91: No default serial console defined.\n");
1232} 1229}
1233 1230
1234void __init at91_add_device_serial(void) 1231void __init at91_add_device_serial(void)
@@ -1239,9 +1236,11 @@ void __init at91_add_device_serial(void)
1239 if (at91_uarts[i]) 1236 if (at91_uarts[i])
1240 platform_device_register(at91_uarts[i]); 1237 platform_device_register(at91_uarts[i]);
1241 } 1238 }
1239
1240 if (!atmel_default_console_device)
1241 printk(KERN_INFO "AT91: No default serial console defined.\n");
1242} 1242}
1243#else 1243#else
1244void __init at91_init_serial(struct at91_uart_config *config) {}
1245void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1244void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1246void __init at91_set_serial_console(unsigned portnr) {} 1245void __init at91_set_serial_console(unsigned portnr) {}
1247void __init at91_add_device_serial(void) {} 1246void __init at91_add_device_serial(void) {}
@@ -1257,6 +1256,7 @@ static int __init at91_add_standard_devices(void)
1257{ 1256{
1258 at91_add_device_rtt(); 1257 at91_add_device_rtt();
1259 at91_add_device_watchdog(); 1258 at91_add_device_watchdog();
1259 at91_add_device_tc();
1260 return 0; 1260 return 0;
1261} 1261}
1262 1262
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index e38d23770992..5cecbd7de6a6 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -1,23 +1,20 @@
1/* 1/*
2 * linux/arch/arm/mach-at91/at91sam926x_time.c 2 * at91sam926x_time.c - Periodic Interval Timer (PIT) for at91sam926x
3 * 3 *
4 * Copyright (C) 2005-2006 M. Amine SAYA, ATMEL Rousset, France 4 * Copyright (C) 2005-2006 M. Amine SAYA, ATMEL Rousset, France
5 * Revision 2005 M. Nicolas Diremdjian, ATMEL Rousset, France 5 * Revision 2005 M. Nicolas Diremdjian, ATMEL Rousset, France
6 * Converted to ClockSource/ClockEvents by David Brownell.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * 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 9 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
10 */ 11 */
11
12#include <linux/init.h>
13#include <linux/interrupt.h> 12#include <linux/interrupt.h>
14#include <linux/irq.h> 13#include <linux/irq.h>
15#include <linux/kernel.h> 14#include <linux/kernel.h>
16#include <linux/sched.h> 15#include <linux/clk.h>
17#include <linux/time.h> 16#include <linux/clockchips.h>
18 17
19#include <asm/hardware.h>
20#include <asm/io.h>
21#include <asm/mach/time.h> 18#include <asm/mach/time.h>
22 19
23#include <asm/arch/at91_pit.h> 20#include <asm/arch/at91_pit.h>
@@ -26,85 +23,167 @@
26#define PIT_CPIV(x) ((x) & AT91_PIT_CPIV) 23#define PIT_CPIV(x) ((x) & AT91_PIT_CPIV)
27#define PIT_PICNT(x) (((x) & AT91_PIT_PICNT) >> 20) 24#define PIT_PICNT(x) (((x) & AT91_PIT_PICNT) >> 20)
28 25
26static u32 pit_cycle; /* write-once */
27static u32 pit_cnt; /* access only w/system irq blocked */
28
29
29/* 30/*
30 * Returns number of microseconds since last timer interrupt. Note that interrupts 31 * Clocksource: just a monotonic counter of MCK/16 cycles.
31 * will have been disabled by do_gettimeofday() 32 * We don't care whether or not PIT irqs are enabled.
32 * 'LATCH' is hwclock ticks (see CLOCK_TICK_RATE in timex.h) per jiffy.
33 */ 33 */
34static unsigned long at91sam926x_gettimeoffset(void) 34static cycle_t read_pit_clk(void)
35{ 35{
36 unsigned long elapsed; 36 unsigned long flags;
37 unsigned long t = at91_sys_read(AT91_PIT_PIIR); 37 u32 elapsed;
38 u32 t;
39
40 raw_local_irq_save(flags);
41 elapsed = pit_cnt;
42 t = at91_sys_read(AT91_PIT_PIIR);
43 raw_local_irq_restore(flags);
44
45 elapsed += PIT_PICNT(t) * pit_cycle;
46 elapsed += PIT_CPIV(t);
47 return elapsed;
48}
49
50static struct clocksource pit_clk = {
51 .name = "pit",
52 .rating = 175,
53 .read = read_pit_clk,
54 .shift = 20,
55 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
56};
38 57
39 elapsed = (PIT_PICNT(t) * LATCH) + PIT_CPIV(t); /* hardware clock cycles */
40 58
41 return (unsigned long)(elapsed * jiffies_to_usecs(1)) / LATCH; 59/*
60 * Clockevent device: interrupts every 1/HZ (== pit_cycles * MCK/16)
61 */
62static void
63pit_clkevt_mode(enum clock_event_mode mode, struct clock_event_device *dev)
64{
65 unsigned long flags;
66
67 switch (mode) {
68 case CLOCK_EVT_MODE_PERIODIC:
69 /* update clocksource counter, then enable the IRQ */
70 raw_local_irq_save(flags);
71 pit_cnt += pit_cycle * PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
72 at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN
73 | AT91_PIT_PITIEN);
74 raw_local_irq_restore(flags);
75 break;
76 case CLOCK_EVT_MODE_ONESHOT:
77 BUG();
78 /* FALLTHROUGH */
79 case CLOCK_EVT_MODE_SHUTDOWN:
80 case CLOCK_EVT_MODE_UNUSED:
81 /* disable irq, leaving the clocksource active */
82 at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
83 break;
84 case CLOCK_EVT_MODE_RESUME:
85 break;
86 }
42} 87}
43 88
89static struct clock_event_device pit_clkevt = {
90 .name = "pit",
91 .features = CLOCK_EVT_FEAT_PERIODIC,
92 .shift = 32,
93 .rating = 100,
94 .cpumask = CPU_MASK_CPU0,
95 .set_mode = pit_clkevt_mode,
96};
97
98
44/* 99/*
45 * IRQ handler for the timer. 100 * IRQ handler for the timer.
46 */ 101 */
47static irqreturn_t at91sam926x_timer_interrupt(int irq, void *dev_id) 102static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
48{ 103{
49 volatile long nr_ticks;
50 104
51 if (at91_sys_read(AT91_PIT_SR) & AT91_PIT_PITS) { /* This is a shared interrupt */ 105 /* The PIT interrupt may be disabled, and is shared */
52 /* Get number to ticks performed before interrupt and clear PIT interrupt */ 106 if ((pit_clkevt.mode == CLOCK_EVT_MODE_PERIODIC)
107 && (at91_sys_read(AT91_PIT_SR) & AT91_PIT_PITS)) {
108 unsigned nr_ticks;
109
110 /* Get number of ticks performed before irq, and ack it */
53 nr_ticks = PIT_PICNT(at91_sys_read(AT91_PIT_PIVR)); 111 nr_ticks = PIT_PICNT(at91_sys_read(AT91_PIT_PIVR));
54 do { 112 do {
55 timer_tick(); 113 pit_cnt += pit_cycle;
114 pit_clkevt.event_handler(&pit_clkevt);
56 nr_ticks--; 115 nr_ticks--;
57 } while (nr_ticks); 116 } while (nr_ticks);
58 117
59 return IRQ_HANDLED; 118 return IRQ_HANDLED;
60 } else 119 }
61 return IRQ_NONE; /* not handled */ 120
121 return IRQ_NONE;
62} 122}
63 123
64static struct irqaction at91sam926x_timer_irq = { 124static struct irqaction at91sam926x_pit_irq = {
65 .name = "at91_tick", 125 .name = "at91_tick",
66 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, 126 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
67 .handler = at91sam926x_timer_interrupt 127 .handler = at91sam926x_pit_interrupt
68}; 128};
69 129
70void at91sam926x_timer_reset(void) 130static void at91sam926x_pit_reset(void)
71{ 131{
72 /* Disable timer */ 132 /* Disable timer and irqs */
73 at91_sys_write(AT91_PIT_MR, 0); 133 at91_sys_write(AT91_PIT_MR, 0);
74 134
75 /* Clear any pending interrupts */ 135 /* Clear any pending interrupts, wait for PIT to stop counting */
76 (void) at91_sys_read(AT91_PIT_PIVR); 136 while (PIT_CPIV(at91_sys_read(AT91_PIT_PIVR)) != 0)
137 cpu_relax();
77 138
78 /* Set Period Interval timer and enable its interrupt */ 139 /* Start PIT but don't enable IRQ */
79 at91_sys_write(AT91_PIT_MR, (LATCH & AT91_PIT_PIV) | AT91_PIT_PITIEN | AT91_PIT_PITEN); 140 at91_sys_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
80} 141}
81 142
82/* 143/*
83 * Set up timer interrupt. 144 * Set up both clocksource and clockevent support.
84 */ 145 */
85void __init at91sam926x_timer_init(void) 146static void __init at91sam926x_pit_init(void)
86{ 147{
87 /* Initialize and enable the timer */ 148 unsigned long pit_rate;
88 at91sam926x_timer_reset(); 149 unsigned bits;
150
151 /*
152 * Use our actual MCK to figure out how many MCK/16 ticks per
153 * 1/HZ period (instead of a compile-time constant LATCH).
154 */
155 pit_rate = clk_get_rate(clk_get(NULL, "mck")) / 16;
156 pit_cycle = (pit_rate + HZ/2) / HZ;
157 WARN_ON(((pit_cycle - 1) & ~AT91_PIT_PIV) != 0);
89 158
90 /* Make IRQs happen for the system timer. */ 159 /* Initialize and enable the timer */
91 setup_irq(AT91_ID_SYS, &at91sam926x_timer_irq); 160 at91sam926x_pit_reset();
161
162 /*
163 * Register clocksource. The high order bits of PIV are unused,
164 * so this isn't a 32-bit counter unless we get clockevent irqs.
165 */
166 pit_clk.mult = clocksource_hz2mult(pit_rate, pit_clk.shift);
167 bits = 12 /* PICNT */ + ilog2(pit_cycle) /* PIV */;
168 pit_clk.mask = CLOCKSOURCE_MASK(bits);
169 clocksource_register(&pit_clk);
170
171 /* Set up irq handler */
172 setup_irq(AT91_ID_SYS, &at91sam926x_pit_irq);
173
174 /* Set up and register clockevents */
175 pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift);
176 clockevents_register_device(&pit_clkevt);
92} 177}
93 178
94#ifdef CONFIG_PM 179static void at91sam926x_pit_suspend(void)
95static void at91sam926x_timer_suspend(void)
96{ 180{
97 /* Disable timer */ 181 /* Disable timer */
98 at91_sys_write(AT91_PIT_MR, 0); 182 at91_sys_write(AT91_PIT_MR, 0);
99} 183}
100#else
101#define at91sam926x_timer_suspend NULL
102#endif
103 184
104struct sys_timer at91sam926x_timer = { 185struct sys_timer at91sam926x_timer = {
105 .init = at91sam926x_timer_init, 186 .init = at91sam926x_pit_init,
106 .offset = at91sam926x_gettimeoffset, 187 .suspend = at91sam926x_pit_suspend,
107 .suspend = at91sam926x_timer_suspend, 188 .resume = at91sam926x_pit_reset,
108 .resume = at91sam926x_timer_reset,
109}; 189};
110
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index 4813a35f6cf5..902c79893ec7 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/pm.h>
13 14
14#include <asm/mach/arch.h> 15#include <asm/mach/arch.h>
15#include <asm/mach/map.h> 16#include <asm/mach/map.h>
@@ -17,6 +18,7 @@
17#include <asm/arch/at91sam9rl.h> 18#include <asm/arch/at91sam9rl.h>
18#include <asm/arch/at91_pmc.h> 19#include <asm/arch/at91_pmc.h>
19#include <asm/arch/at91_rstc.h> 20#include <asm/arch/at91_rstc.h>
21#include <asm/arch/at91_shdwc.h>
20 22
21#include "generic.h" 23#include "generic.h"
22#include "clock.h" 24#include "clock.h"
@@ -244,6 +246,11 @@ static void at91sam9rl_reset(void)
244 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); 246 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
245} 247}
246 248
249static void at91sam9rl_poweroff(void)
250{
251 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
252}
253
247 254
248/* -------------------------------------------------------------------- 255/* --------------------------------------------------------------------
249 * AT91SAM9RL processor initialization 256 * AT91SAM9RL processor initialization
@@ -274,6 +281,7 @@ void __init at91sam9rl_initialize(unsigned long main_clock)
274 iotable_init(at91sam9rl_sram_desc, ARRAY_SIZE(at91sam9rl_sram_desc)); 281 iotable_init(at91sam9rl_sram_desc, ARRAY_SIZE(at91sam9rl_sram_desc));
275 282
276 at91_arch_reset = at91sam9rl_reset; 283 at91_arch_reset = at91sam9rl_reset;
284 pm_power_off = at91sam9rl_poweroff;
277 at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0); 285 at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0);
278 286
279 /* Init clock subsystem */ 287 /* Init clock subsystem */
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index f43b5c33e45d..ae28101e7542 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -20,12 +20,107 @@
20#include <asm/arch/gpio.h> 20#include <asm/arch/gpio.h>
21#include <asm/arch/at91sam9rl.h> 21#include <asm/arch/at91sam9rl.h>
22#include <asm/arch/at91sam9rl_matrix.h> 22#include <asm/arch/at91sam9rl_matrix.h>
23#include <asm/arch/at91sam926x_mc.h> 23#include <asm/arch/at91sam9_smc.h>
24 24
25#include "generic.h" 25#include "generic.h"
26 26
27 27
28/* -------------------------------------------------------------------- 28/* --------------------------------------------------------------------
29 * USB HS Device (Gadget)
30 * -------------------------------------------------------------------- */
31
32#if defined(CONFIG_USB_GADGET_ATMEL_USBA) || defined(CONFIG_USB_GADGET_ATMEL_USBA_MODULE)
33
34static struct resource usba_udc_resources[] = {
35 [0] = {
36 .start = AT91SAM9RL_UDPHS_FIFO,
37 .end = AT91SAM9RL_UDPHS_FIFO + SZ_512K - 1,
38 .flags = IORESOURCE_MEM,
39 },
40 [1] = {
41 .start = AT91SAM9RL_BASE_UDPHS,
42 .end = AT91SAM9RL_BASE_UDPHS + SZ_1K - 1,
43 .flags = IORESOURCE_MEM,
44 },
45 [2] = {
46 .start = AT91SAM9RL_ID_UDPHS,
47 .end = AT91SAM9RL_ID_UDPHS,
48 .flags = IORESOURCE_IRQ,
49 },
50};
51
52#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
53 [idx] = { \
54 .name = nam, \
55 .index = idx, \
56 .fifo_size = maxpkt, \
57 .nr_banks = maxbk, \
58 .can_dma = dma, \
59 .can_isoc = isoc, \
60 }
61
62static struct usba_ep_data usba_udc_ep[] __initdata = {
63 EP("ep0", 0, 64, 1, 0, 0),
64 EP("ep1", 1, 1024, 2, 1, 1),
65 EP("ep2", 2, 1024, 2, 1, 1),
66 EP("ep3", 3, 1024, 3, 1, 0),
67 EP("ep4", 4, 1024, 3, 1, 0),
68 EP("ep5", 5, 1024, 3, 1, 1),
69 EP("ep6", 6, 1024, 3, 1, 1),
70};
71
72#undef EP
73
74/*
75 * pdata doesn't have room for any endpoints, so we need to
76 * append room for the ones we need right after it.
77 */
78static struct {
79 struct usba_platform_data pdata;
80 struct usba_ep_data ep[7];
81} usba_udc_data;
82
83static struct platform_device at91_usba_udc_device = {
84 .name = "atmel_usba_udc",
85 .id = -1,
86 .dev = {
87 .platform_data = &usba_udc_data.pdata,
88 },
89 .resource = usba_udc_resources,
90 .num_resources = ARRAY_SIZE(usba_udc_resources),
91};
92
93void __init at91_add_device_usba(struct usba_platform_data *data)
94{
95 /*
96 * Invalid pins are 0 on AT91, but the usba driver is shared
97 * with AVR32, which use negative values instead. Once/if
98 * gpio_is_valid() is ported to AT91, revisit this code.
99 */
100 usba_udc_data.pdata.vbus_pin = -EINVAL;
101 usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
102 memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));;
103
104 if (data && data->vbus_pin > 0) {
105 at91_set_gpio_input(data->vbus_pin, 0);
106 at91_set_deglitch(data->vbus_pin, 1);
107 usba_udc_data.pdata.vbus_pin = data->vbus_pin;
108 }
109
110 /* Pullup pin is handled internally by USB device peripheral */
111
112 /* Clocks */
113 at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk");
114 at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk");
115
116 platform_device_register(&at91_usba_udc_device);
117}
118#else
119void __init at91_add_device_usba(struct usba_platform_data *data) {}
120#endif
121
122
123/* --------------------------------------------------------------------
29 * MMC / SD 124 * MMC / SD
30 * -------------------------------------------------------------------- */ 125 * -------------------------------------------------------------------- */
31 126
@@ -105,10 +200,15 @@ static struct at91_nand_data nand_data;
105#define NAND_BASE AT91_CHIPSELECT_3 200#define NAND_BASE AT91_CHIPSELECT_3
106 201
107static struct resource nand_resources[] = { 202static struct resource nand_resources[] = {
108 { 203 [0] = {
109 .start = NAND_BASE, 204 .start = NAND_BASE,
110 .end = NAND_BASE + SZ_256M - 1, 205 .end = NAND_BASE + SZ_256M - 1,
111 .flags = IORESOURCE_MEM, 206 .flags = IORESOURCE_MEM,
207 },
208 [1] = {
209 .start = AT91_BASE_SYS + AT91_ECC,
210 .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
211 .flags = IORESOURCE_MEM,
112 } 212 }
113}; 213};
114 214
@@ -133,15 +233,15 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
133 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); 233 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
134 234
135 /* set the bus interface characteristics */ 235 /* set the bus interface characteristics */
136 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0) 236 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(1) | AT91_SMC_NCS_WRSETUP_(0)
137 | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0)); 237 | AT91_SMC_NRDSETUP_(1) | AT91_SMC_NCS_RDSETUP_(0));
138 238
139 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(2) | AT91_SMC_NCS_WRPULSE_(5) 239 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3)
140 | AT91_SMC_NRDPULSE_(2) | AT91_SMC_NCS_RDPULSE_(5)); 240 | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
141 241
142 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7)); 242 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
143 243
144 at91_sys_write(AT91_SMC_MODE(3), AT91_SMC_DBW_8 | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(1)); 244 at91_sys_write(AT91_SMC_MODE(3), AT91_SMC_DBW_8 | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(2));
145 245
146 /* enable pin */ 246 /* enable pin */
147 if (data->enable_pin) 247 if (data->enable_pin)
@@ -327,13 +427,6 @@ static struct resource lcdc_resources[] = {
327 .end = AT91SAM9RL_ID_LCDC, 427 .end = AT91SAM9RL_ID_LCDC,
328 .flags = IORESOURCE_IRQ, 428 .flags = IORESOURCE_IRQ,
329 }, 429 },
330#if defined(CONFIG_FB_INTSRAM)
331 [2] = {
332 .start = AT91SAM9RL_SRAM_BASE,
333 .end = AT91SAM9RL_SRAM_BASE + AT91SAM9RL_SRAM_SIZE - 1,
334 .flags = IORESOURCE_MEM,
335 },
336#endif
337}; 430};
338 431
339static struct platform_device at91_lcdc_device = { 432static struct platform_device at91_lcdc_device = {
@@ -385,6 +478,55 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
385 478
386 479
387/* -------------------------------------------------------------------- 480/* --------------------------------------------------------------------
481 * Timer/Counter block
482 * -------------------------------------------------------------------- */
483
484#ifdef CONFIG_ATMEL_TCLIB
485
486static struct resource tcb_resources[] = {
487 [0] = {
488 .start = AT91SAM9RL_BASE_TCB0,
489 .end = AT91SAM9RL_BASE_TCB0 + SZ_16K - 1,
490 .flags = IORESOURCE_MEM,
491 },
492 [1] = {
493 .start = AT91SAM9RL_ID_TC0,
494 .end = AT91SAM9RL_ID_TC0,
495 .flags = IORESOURCE_IRQ,
496 },
497 [2] = {
498 .start = AT91SAM9RL_ID_TC1,
499 .end = AT91SAM9RL_ID_TC1,
500 .flags = IORESOURCE_IRQ,
501 },
502 [3] = {
503 .start = AT91SAM9RL_ID_TC2,
504 .end = AT91SAM9RL_ID_TC2,
505 .flags = IORESOURCE_IRQ,
506 },
507};
508
509static struct platform_device at91sam9rl_tcb_device = {
510 .name = "atmel_tcb",
511 .id = 0,
512 .resource = tcb_resources,
513 .num_resources = ARRAY_SIZE(tcb_resources),
514};
515
516static void __init at91_add_device_tc(void)
517{
518 /* this chip has a separate clock and irq for each TC channel */
519 at91_clock_associate("tc0_clk", &at91sam9rl_tcb_device.dev, "t0_clk");
520 at91_clock_associate("tc1_clk", &at91sam9rl_tcb_device.dev, "t1_clk");
521 at91_clock_associate("tc2_clk", &at91sam9rl_tcb_device.dev, "t2_clk");
522 platform_device_register(&at91sam9rl_tcb_device);
523}
524#else
525static void __init at91_add_device_tc(void) { }
526#endif
527
528
529/* --------------------------------------------------------------------
388 * RTC 530 * RTC
389 * -------------------------------------------------------------------- */ 531 * -------------------------------------------------------------------- */
390 532
@@ -418,7 +560,7 @@ static struct resource rtt_resources[] = {
418 560
419static struct platform_device at91sam9rl_rtt_device = { 561static struct platform_device at91sam9rl_rtt_device = {
420 .name = "at91_rtt", 562 .name = "at91_rtt",
421 .id = -1, 563 .id = 0,
422 .resource = rtt_resources, 564 .resource = rtt_resources,
423 .num_resources = ARRAY_SIZE(rtt_resources), 565 .num_resources = ARRAY_SIZE(rtt_resources),
424}; 566};
@@ -539,9 +681,6 @@ static inline void configure_ssc1_pins(unsigned pins)
539} 681}
540 682
541/* 683/*
542 * Return the device node so that board init code can use it as the
543 * parent for the device node reflecting how it's used on this board.
544 *
545 * SSC controllers are accessed through library code, instead of any 684 * SSC controllers are accessed through library code, instead of any
546 * kind of all-singing/all-dancing driver. For example one could be 685 * kind of all-singing/all-dancing driver. For example one could be
547 * used by a particular I2S audio codec's driver, while another one 686 * used by a particular I2S audio codec's driver, while another one
@@ -802,54 +941,9 @@ static inline void configure_usart3_pins(unsigned pins)
802 at91_set_B_periph(AT91_PIN_PD3, 0); /* CTS3 */ 941 at91_set_B_periph(AT91_PIN_PD3, 0); /* CTS3 */
803} 942}
804 943
805static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 944static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
806struct platform_device *atmel_default_console_device; /* the serial console device */ 945struct platform_device *atmel_default_console_device; /* the serial console device */
807 946
808void __init __deprecated at91_init_serial(struct at91_uart_config *config)
809{
810 int i;
811
812 /* Fill in list of supported UARTs */
813 for (i = 0; i < config->nr_tty; i++) {
814 switch (config->tty_map[i]) {
815 case 0:
816 configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
817 at91_uarts[i] = &at91sam9rl_uart0_device;
818 at91_clock_associate("usart0_clk", &at91sam9rl_uart0_device.dev, "usart");
819 break;
820 case 1:
821 configure_usart1_pins(0);
822 at91_uarts[i] = &at91sam9rl_uart1_device;
823 at91_clock_associate("usart1_clk", &at91sam9rl_uart1_device.dev, "usart");
824 break;
825 case 2:
826 configure_usart2_pins(0);
827 at91_uarts[i] = &at91sam9rl_uart2_device;
828 at91_clock_associate("usart2_clk", &at91sam9rl_uart2_device.dev, "usart");
829 break;
830 case 3:
831 configure_usart3_pins(0);
832 at91_uarts[i] = &at91sam9rl_uart3_device;
833 at91_clock_associate("usart3_clk", &at91sam9rl_uart3_device.dev, "usart");
834 break;
835 case 4:
836 configure_dbgu_pins();
837 at91_uarts[i] = &at91sam9rl_dbgu_device;
838 at91_clock_associate("mck", &at91sam9rl_dbgu_device.dev, "usart");
839 break;
840 default:
841 continue;
842 }
843 at91_uarts[i]->id = i; /* update ID number to mapped ID */
844 }
845
846 /* Set serial console device */
847 if (config->console_tty < ATMEL_MAX_UART)
848 atmel_default_console_device = at91_uarts[config->console_tty];
849 if (!atmel_default_console_device)
850 printk(KERN_INFO "AT91: No default serial console defined.\n");
851}
852
853void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 947void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
854{ 948{
855 struct platform_device *pdev; 949 struct platform_device *pdev;
@@ -893,8 +987,6 @@ void __init at91_set_serial_console(unsigned portnr)
893{ 987{
894 if (portnr < ATMEL_MAX_UART) 988 if (portnr < ATMEL_MAX_UART)
895 atmel_default_console_device = at91_uarts[portnr]; 989 atmel_default_console_device = at91_uarts[portnr];
896 if (!atmel_default_console_device)
897 printk(KERN_INFO "AT91: No default serial console defined.\n");
898} 990}
899 991
900void __init at91_add_device_serial(void) 992void __init at91_add_device_serial(void)
@@ -905,9 +997,11 @@ void __init at91_add_device_serial(void)
905 if (at91_uarts[i]) 997 if (at91_uarts[i])
906 platform_device_register(at91_uarts[i]); 998 platform_device_register(at91_uarts[i]);
907 } 999 }
1000
1001 if (!atmel_default_console_device)
1002 printk(KERN_INFO "AT91: No default serial console defined.\n");
908} 1003}
909#else 1004#else
910void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
911void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1005void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
912void __init at91_set_serial_console(unsigned portnr) {} 1006void __init at91_set_serial_console(unsigned portnr) {}
913void __init at91_add_device_serial(void) {} 1007void __init at91_add_device_serial(void) {}
@@ -925,6 +1019,7 @@ static int __init at91_add_standard_devices(void)
925 at91_add_device_rtc(); 1019 at91_add_device_rtc();
926 at91_add_device_rtt(); 1020 at91_add_device_rtt();
927 at91_add_device_watchdog(); 1021 at91_add_device_watchdog();
1022 at91_add_device_tc();
928 return 0; 1023 return 0;
929} 1024}
930 1025
diff --git a/arch/arm/mach-at91/at91x40.c b/arch/arm/mach-at91/at91x40.c
index 1de121fc55f4..f44647738ee4 100644
--- a/arch/arm/mach-at91/at91x40.c
+++ b/arch/arm/mach-at91/at91x40.c
@@ -16,16 +16,32 @@
16#include <asm/mach/arch.h> 16#include <asm/mach/arch.h>
17#include <asm/arch/at91x40.h> 17#include <asm/arch/at91x40.h>
18#include <asm/arch/at91_st.h> 18#include <asm/arch/at91_st.h>
19#include <asm/arch/timex.h>
19#include "generic.h" 20#include "generic.h"
20 21
21/* 22/*
22 * This is used in the gpio code, stub locally. 23 * Export the clock functions for the AT91X40. Some external code common
24 * to all AT91 family parts relys on this, like the gpio and serial support.
23 */ 25 */
24int clk_enable(struct clk *clk) 26int clk_enable(struct clk *clk)
25{ 27{
26 return 0; 28 return 0;
27} 29}
28 30
31void clk_disable(struct clk *clk)
32{
33}
34
35unsigned long clk_get_rate(struct clk *clk)
36{
37 return AT91X40_MASTER_CLOCK;
38}
39
40struct clk *clk_get(struct device *dev, const char *id)
41{
42 return NULL;
43}
44
29void __init at91x40_initialize(unsigned long main_clock) 45void __init at91x40_initialize(unsigned long main_clock)
30{ 46{
31 at91_extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1) 47 at91_extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1)
diff --git a/arch/arm/mach-at91/board-cam60.c b/arch/arm/mach-at91/board-cam60.c
new file mode 100644
index 000000000000..b22a1a004055
--- /dev/null
+++ b/arch/arm/mach-at91/board-cam60.c
@@ -0,0 +1,180 @@
1/*
2 * KwikByte CAM60 (KB9260)
3 *
4 * based on board-sam9260ek.c
5 * Copyright (C) 2005 SAN People
6 * Copyright (C) 2006 Atmel
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/types.h>
24#include <linux/init.h>
25#include <linux/mm.h>
26#include <linux/module.h>
27#include <linux/platform_device.h>
28#include <linux/spi/spi.h>
29#include <linux/spi/flash.h>
30
31#include <asm/hardware.h>
32#include <asm/setup.h>
33#include <asm/mach-types.h>
34#include <asm/irq.h>
35
36#include <asm/mach/arch.h>
37#include <asm/mach/map.h>
38#include <asm/mach/irq.h>
39
40#include <asm/arch/board.h>
41#include <asm/arch/gpio.h>
42
43#include "generic.h"
44
45
46static void __init cam60_map_io(void)
47{
48 /* Initialize processor: 10 MHz crystal */
49 at91sam9260_initialize(10000000);
50
51 /* DGBU on ttyS0. (Rx & Tx only) */
52 at91_register_uart(0, 0, 0);
53
54 /* set serial console to ttyS0 (ie, DBGU) */
55 at91_set_serial_console(0);
56}
57
58static void __init cam60_init_irq(void)
59{
60 at91sam9260_init_interrupts(NULL);
61}
62
63
64/*
65 * USB Host
66 */
67static struct at91_usbh_data __initdata cam60_usbh_data = {
68 .ports = 1,
69};
70
71
72/*
73 * SPI devices.
74 */
75#if defined(CONFIG_MTD_DATAFLASH)
76static struct mtd_partition __initdata cam60_spi_partitions[] = {
77 {
78 .name = "BOOT1",
79 .offset = 0,
80 .size = 4 * 1056,
81 },
82 {
83 .name = "BOOT2",
84 .offset = MTDPART_OFS_NXTBLK,
85 .size = 256 * 1056,
86 },
87 {
88 .name = "kernel",
89 .offset = MTDPART_OFS_NXTBLK,
90 .size = 2222 * 1056,
91 },
92 {
93 .name = "file system",
94 .offset = MTDPART_OFS_NXTBLK,
95 .size = MTDPART_SIZ_FULL,
96 },
97};
98
99static struct flash_platform_data __initdata cam60_spi_flash_platform_data = {
100 .name = "spi_flash",
101 .parts = cam60_spi_partitions,
102 .nr_parts = ARRAY_SIZE(cam60_spi_partitions)
103};
104#endif
105
106static struct spi_board_info cam60_spi_devices[] = {
107#if defined(CONFIG_MTD_DATAFLASH)
108 { /* DataFlash chip */
109 .modalias = "mtd_dataflash",
110 .chip_select = 0,
111 .max_speed_hz = 15 * 1000 * 1000,
112 .bus_num = 0,
113 .platform_data = &cam60_spi_flash_platform_data
114 },
115#endif
116};
117
118
119/*
120 * MACB Ethernet device
121 */
122static struct __initdata at91_eth_data cam60_macb_data = {
123 .phy_irq_pin = AT91_PIN_PB5,
124 .is_rmii = 0,
125};
126
127
128/*
129 * NAND Flash
130 */
131static struct mtd_partition __initdata cam60_nand_partition[] = {
132 {
133 .name = "nand_fs",
134 .offset = 0,
135 .size = MTDPART_SIZ_FULL,
136 },
137};
138
139static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
140{
141 *num_partitions = ARRAY_SIZE(cam60_nand_partition);
142 return cam60_nand_partition;
143}
144
145static struct at91_nand_data __initdata cam60_nand_data = {
146 .ale = 21,
147 .cle = 22,
148 // .det_pin = ... not there
149 .rdy_pin = AT91_PIN_PA9,
150 .enable_pin = AT91_PIN_PA7,
151 .partition_info = nand_partitions,
152};
153
154
155static void __init cam60_board_init(void)
156{
157 /* Serial */
158 at91_add_device_serial();
159 /* SPI */
160 at91_add_device_spi(cam60_spi_devices, ARRAY_SIZE(cam60_spi_devices));
161 /* Ethernet */
162 at91_add_device_eth(&cam60_macb_data);
163 /* USB Host */
164 /* enable USB power supply circuit */
165 at91_set_gpio_output(AT91_PIN_PB18, 1);
166 at91_add_device_usbh(&cam60_usbh_data);
167 /* NAND */
168 at91_add_device_nand(&cam60_nand_data);
169}
170
171MACHINE_START(CAM60, "KwikByte CAM60")
172 /* Maintainer: KwikByte */
173 .phys_io = AT91_BASE_SYS,
174 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
175 .boot_params = AT91_SDRAM_BASE + 0x100,
176 .timer = &at91sam926x_timer,
177 .map_io = cam60_map_io,
178 .init_irq = cam60_init_irq,
179 .init_machine = cam60_board_init,
180MACHINE_END
diff --git a/arch/arm/mach-at91/board-cap9adk.c b/arch/arm/mach-at91/board-cap9adk.c
index 185437131541..8a2a958639db 100644
--- a/arch/arm/mach-at91/board-cap9adk.c
+++ b/arch/arm/mach-at91/board-cap9adk.c
@@ -45,7 +45,7 @@
45#include <asm/arch/board.h> 45#include <asm/arch/board.h>
46#include <asm/arch/gpio.h> 46#include <asm/arch/gpio.h>
47#include <asm/arch/at91cap9_matrix.h> 47#include <asm/arch/at91cap9_matrix.h>
48#include <asm/arch/at91sam926x_mc.h> 48#include <asm/arch/at91sam9_smc.h>
49 49
50#include "generic.h" 50#include "generic.h"
51 51
@@ -78,6 +78,12 @@ static struct at91_usbh_data __initdata cap9adk_usbh_data = {
78 .ports = 2, 78 .ports = 2,
79}; 79};
80 80
81/*
82 * USB HS Device port
83 */
84static struct usba_platform_data __initdata cap9adk_usba_udc_data = {
85 .vbus_pin = AT91_PIN_PB31,
86};
81 87
82/* 88/*
83 * ADS7846 Touchscreen 89 * ADS7846 Touchscreen
@@ -326,6 +332,9 @@ static void __init cap9adk_board_init(void)
326 /* USB Host */ 332 /* USB Host */
327 set_irq_type(AT91CAP9_ID_UHP, IRQT_HIGH); 333 set_irq_type(AT91CAP9_ID_UHP, IRQT_HIGH);
328 at91_add_device_usbh(&cap9adk_usbh_data); 334 at91_add_device_usbh(&cap9adk_usbh_data);
335 /* USB HS */
336 set_irq_type(AT91CAP9_ID_UDPHS, IRQT_HIGH);
337 at91_add_device_usba(&cap9adk_usba_udc_data);
329 /* SPI */ 338 /* SPI */
330 at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices)); 339 at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices));
331 /* Touchscreen */ 340 /* Touchscreen */
diff --git a/arch/arm/mach-at91/board-carmeva.c b/arch/arm/mach-at91/board-carmeva.c
index 0f0878294a67..9854fc3dd1f2 100644
--- a/arch/arm/mach-at91/board-carmeva.c
+++ b/arch/arm/mach-at91/board-carmeva.c
@@ -40,24 +40,21 @@
40#include "generic.h" 40#include "generic.h"
41 41
42 42
43/*
44 * Serial port configuration.
45 * 0 .. 3 = USART0 .. USART3
46 * 4 = DBGU
47 */
48static struct at91_uart_config __initdata carmeva_uart_config = {
49 .console_tty = 0, /* ttyS0 */
50 .nr_tty = 2,
51 .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
52};
53
54static void __init carmeva_map_io(void) 43static void __init carmeva_map_io(void)
55{ 44{
56 /* Initialize processor: 20.000 MHz crystal */ 45 /* Initialize processor: 20.000 MHz crystal */
57 at91rm9200_initialize(20000000, AT91RM9200_BGA); 46 at91rm9200_initialize(20000000, AT91RM9200_BGA);
58 47
59 /* Setup the serial ports and console */ 48 /* DBGU on ttyS0. (Rx & Tx only) */
60 at91_init_serial(&carmeva_uart_config); 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);
61} 58}
62 59
63static void __init carmeva_init_irq(void) 60static void __init carmeva_init_irq(void)
diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
index 0e2a11fc5bbd..81f1ebb4e964 100644
--- a/arch/arm/mach-at91/board-csb337.c
+++ b/arch/arm/mach-at91/board-csb337.c
@@ -43,17 +43,6 @@
43#include "generic.h" 43#include "generic.h"
44 44
45 45
46/*
47 * Serial port configuration.
48 * 0 .. 3 = USART0 .. USART3
49 * 4 = DBGU
50 */
51static struct at91_uart_config __initdata csb337_uart_config = {
52 .console_tty = 0, /* ttyS0 */
53 .nr_tty = 2,
54 .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
55};
56
57static void __init csb337_map_io(void) 46static void __init csb337_map_io(void)
58{ 47{
59 /* Initialize processor: 3.6864 MHz crystal */ 48 /* Initialize processor: 3.6864 MHz crystal */
@@ -62,8 +51,11 @@ static void __init csb337_map_io(void)
62 /* Setup the LEDs */ 51 /* Setup the LEDs */
63 at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1); 52 at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
64 53
65 /* Setup the serial ports and console */ 54 /* DBGU on ttyS0 */
66 at91_init_serial(&csb337_uart_config); 55 at91_register_uart(0, 0, 0);
56
57 /* make console=ttyS0 the default */
58 at91_set_serial_console(0);
67} 59}
68 60
69static void __init csb337_init_irq(void) 61static void __init csb337_init_irq(void)
@@ -87,8 +79,7 @@ static struct at91_udc_data __initdata csb337_udc_data = {
87 79
88static struct i2c_board_info __initdata csb337_i2c_devices[] = { 80static struct i2c_board_info __initdata csb337_i2c_devices[] = {
89 { 81 {
90 I2C_BOARD_INFO("rtc-ds1307", 0x68), 82 I2C_BOARD_INFO("ds1307", 0x68),
91 .type = "ds1307",
92 }, 83 },
93}; 84};
94 85
diff --git a/arch/arm/mach-at91/board-csb637.c b/arch/arm/mach-at91/board-csb637.c
index c5c721d27f42..bb1a5474ddab 100644
--- a/arch/arm/mach-at91/board-csb637.c
+++ b/arch/arm/mach-at91/board-csb637.c
@@ -40,27 +40,16 @@
40#include "generic.h" 40#include "generic.h"
41 41
42 42
43/*
44 * Serial port configuration.
45 * 0 .. 3 = USART0 .. USART3
46 * 4 = DBGU
47 */
48static struct at91_uart_config __initdata csb637_uart_config = {
49 .console_tty = 0, /* ttyS0 */
50 .nr_tty = 2,
51 .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
52};
53
54static void __init csb637_map_io(void) 43static void __init csb637_map_io(void)
55{ 44{
56 /* Initialize processor: 3.6864 MHz crystal */ 45 /* Initialize processor: 3.6864 MHz crystal */
57 at91rm9200_initialize(3686400, AT91RM9200_BGA); 46 at91rm9200_initialize(3686400, AT91RM9200_BGA);
58 47
59 /* Setup the LEDs */ 48 /* DBGU on ttyS0. (Rx & Tx only) */
60 at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2); 49 at91_register_uart(0, 0, 0);
61 50
62 /* Setup the serial ports and console */ 51 /* make console=ttyS0 (ie, DBGU) the default */
63 at91_init_serial(&csb637_uart_config); 52 at91_set_serial_console(0);
64} 53}
65 54
66static void __init csb637_init_irq(void) 55static void __init csb637_init_irq(void)
@@ -118,8 +107,19 @@ static struct platform_device csb_flash = {
118 .num_resources = ARRAY_SIZE(csb_flash_resources), 107 .num_resources = ARRAY_SIZE(csb_flash_resources),
119}; 108};
120 109
110static struct gpio_led csb_leds[] = {
111 { /* "d1", red */
112 .name = "d1",
113 .gpio = AT91_PIN_PB2,
114 .active_low = 1,
115 .default_trigger = "heartbeat",
116 },
117};
118
121static void __init csb637_board_init(void) 119static void __init csb637_board_init(void)
122{ 120{
121 /* LED(s) */
122 at91_gpio_leds(csb_leds, ARRAY_SIZE(csb_leds));
123 /* Serial */ 123 /* Serial */
124 at91_add_device_serial(); 124 at91_add_device_serial();
125 /* Ethernet */ 125 /* Ethernet */
diff --git a/arch/arm/mach-at91/board-dk.c b/arch/arm/mach-at91/board-dk.c
index 0a897efeba8e..dab958d25926 100644
--- a/arch/arm/mach-at91/board-dk.c
+++ b/arch/arm/mach-at91/board-dk.c
@@ -45,17 +45,6 @@
45#include "generic.h" 45#include "generic.h"
46 46
47 47
48/*
49 * Serial port configuration.
50 * 0 .. 3 = USART0 .. USART3
51 * 4 = DBGU
52 */
53static struct at91_uart_config __initdata dk_uart_config = {
54 .console_tty = 0, /* ttyS0 */
55 .nr_tty = 2,
56 .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
57};
58
59static void __init dk_map_io(void) 48static void __init dk_map_io(void)
60{ 49{
61 /* Initialize processor: 18.432 MHz crystal */ 50 /* Initialize processor: 18.432 MHz crystal */
@@ -64,8 +53,16 @@ static void __init dk_map_io(void)
64 /* Setup the LEDs */ 53 /* Setup the LEDs */
65 at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2); 54 at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
66 55
67 /* Setup the serial ports and console */ 56 /* DBGU on ttyS0. (Rx & Tx only) */
68 at91_init_serial(&dk_uart_config); 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);
69} 66}
70 67
71static void __init dk_init_irq(void) 68static void __init dk_init_irq(void)
@@ -132,8 +129,7 @@ static struct i2c_board_info __initdata dk_i2c_devices[] = {
132 I2C_BOARD_INFO("x9429", 0x28), 129 I2C_BOARD_INFO("x9429", 0x28),
133 }, 130 },
134 { 131 {
135 I2C_BOARD_INFO("at24c", 0x50), 132 I2C_BOARD_INFO("24c1024", 0x50),
136 .type = "24c1024",
137 } 133 }
138}; 134};
139 135
@@ -164,7 +160,7 @@ static struct at91_nand_data __initdata dk_nand_data = {
164#define DK_FLASH_SIZE 0x200000 160#define DK_FLASH_SIZE 0x200000
165 161
166static struct physmap_flash_data dk_flash_data = { 162static struct physmap_flash_data dk_flash_data = {
167 .width = 2, 163 .width = 2,
168}; 164};
169 165
170static struct resource dk_flash_resource = { 166static struct resource dk_flash_resource = {
diff --git a/arch/arm/mach-at91/board-eb9200.c b/arch/arm/mach-at91/board-eb9200.c
index b7b79bb9d6c4..3fe054e0056b 100644
--- a/arch/arm/mach-at91/board-eb9200.c
+++ b/arch/arm/mach-at91/board-eb9200.c
@@ -40,24 +40,24 @@
40#include "generic.h" 40#include "generic.h"
41 41
42 42
43/*
44 * Serial port configuration.
45 * 0 .. 3 = USART0 .. USART3
46 * 4 = DBGU
47 */
48static struct at91_uart_config __initdata eb9200_uart_config = {
49 .console_tty = 0, /* ttyS0 */
50 .nr_tty = 2,
51 .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
52};
53
54static void __init eb9200_map_io(void) 43static void __init eb9200_map_io(void)
55{ 44{
56 /* Initialize processor: 18.432 MHz crystal */ 45 /* Initialize processor: 18.432 MHz crystal */
57 at91rm9200_initialize(18432000, AT91RM9200_BGA); 46 at91rm9200_initialize(18432000, AT91RM9200_BGA);
58 47
59 /* Setup the serial ports and console */ 48 /* DBGU on ttyS0. (Rx & Tx only) */
60 at91_init_serial(&eb9200_uart_config); 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);
61} 61}
62 62
63static void __init eb9200_init_irq(void) 63static void __init eb9200_init_irq(void)
@@ -93,8 +93,7 @@ static struct at91_mmc_data __initdata eb9200_mmc_data = {
93 93
94static struct i2c_board_info __initdata eb9200_i2c_devices[] = { 94static struct i2c_board_info __initdata eb9200_i2c_devices[] = {
95 { 95 {
96 I2C_BOARD_INFO("at24c", 0x50), 96 I2C_BOARD_INFO("24c512", 0x50),
97 .type = "24c512",
98 }, 97 },
99}; 98};
100 99
diff --git a/arch/arm/mach-at91/board-ecbat91.c b/arch/arm/mach-at91/board-ecbat91.c
new file mode 100644
index 000000000000..e77fad443835
--- /dev/null
+++ b/arch/arm/mach-at91/board-ecbat91.c
@@ -0,0 +1,178 @@
1/*
2 * linux/arch/arm/mach-at91rm9200/board-ecbat91.c
3 * Copyright (C) 2007 emQbit.com.
4 *
5 * We started from board-dk.c, which is Copyright (C) 2005 SAN People.
6 *
7 * 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
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <linux/types.h>
23#include <linux/init.h>
24#include <linux/mm.h>
25#include <linux/module.h>
26#include <linux/platform_device.h>
27#include <linux/spi/spi.h>
28#include <linux/spi/flash.h>
29
30#include <asm/hardware.h>
31#include <asm/setup.h>
32#include <asm/mach-types.h>
33#include <asm/irq.h>
34
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37#include <asm/mach/irq.h>
38
39#include <asm/arch/board.h>
40#include <asm/arch/gpio.h>
41
42#include "generic.h"
43
44
45static void __init ecb_at91map_io(void)
46{
47 /* Initialize processor: 18.432 MHz crystal */
48 at91rm9200_initialize(18432000, AT91RM9200_PQFP);
49
50 /* Setup the LEDs */
51 at91_init_leds(AT91_PIN_PC7, AT91_PIN_PC7);
52
53 /* DBGU on ttyS0. (Rx & Tx only) */
54 at91_register_uart(0, 0, 0);
55
56 /* USART0 on ttyS1. (Rx & Tx only) */
57 at91_register_uart(AT91RM9200_ID_US0, 1, 0);
58
59 /* set serial console to ttyS0 (ie, DBGU) */
60 at91_set_serial_console(0);
61}
62
63static void __init ecb_at91init_irq(void)
64{
65 at91rm9200_init_interrupts(NULL);
66}
67
68static struct at91_eth_data __initdata ecb_at91eth_data = {
69 .phy_irq_pin = AT91_PIN_PC4,
70 .is_rmii = 0,
71};
72
73static struct at91_usbh_data __initdata ecb_at91usbh_data = {
74 .ports = 1,
75};
76
77static struct at91_mmc_data __initdata ecb_at91mmc_data = {
78 .slot_b = 0,
79 .wire4 = 1,
80};
81
82
83#if defined(CONFIG_MTD_DATAFLASH)
84static struct mtd_partition __initdata my_flash0_partitions[] =
85{
86 { /* 0x8400 */
87 .name = "Darrell-loader",
88 .offset = 0,
89 .size = 12* 1056,
90 },
91 {
92 .name = "U-boot",
93 .offset = MTDPART_OFS_NXTBLK,
94 .size = 110 * 1056,
95 },
96 { /* 1336 (167 blocks) pages * 1056 bytes = 0x158700 bytes */
97 .name = "UBoot-env",
98 .offset = MTDPART_OFS_NXTBLK,
99 .size = 8 * 1056,
100 },
101 { /* 1336 (167 blocks) pages * 1056 bytes = 0x158700 bytes */
102 .name = "Kernel",
103 .offset = MTDPART_OFS_NXTBLK,
104 .size = 1534 * 1056,
105 },
106 { /* 190200 - jffs2 root filesystem */
107 .name = "Filesystem",
108 .offset = MTDPART_OFS_NXTBLK,
109 .size = MTDPART_SIZ_FULL, /* 26 sectors */
110 }
111};
112
113static struct flash_platform_data __initdata my_flash0_platform = {
114 .name = "Removable flash card",
115 .parts = my_flash0_partitions,
116 .nr_parts = ARRAY_SIZE(my_flash0_partitions)
117};
118
119#endif
120
121static struct spi_board_info __initdata ecb_at91spi_devices[] = {
122 { /* DataFlash chip */
123 .modalias = "mtd_dataflash",
124 .chip_select = 0,
125 .max_speed_hz = 10 * 1000 * 1000,
126 .bus_num = 0,
127#if defined(CONFIG_MTD_DATAFLASH)
128 .platform_data = &my_flash0_platform,
129#endif
130 },
131 { /* User accessable spi - cs1 (250KHz) */
132 .modalias = "spi-cs1",
133 .chip_select = 1,
134 .max_speed_hz = 250 * 1000,
135 },
136 { /* User accessable spi - cs2 (1MHz) */
137 .modalias = "spi-cs2",
138 .chip_select = 2,
139 .max_speed_hz = 1 * 1000 * 1000,
140 },
141 { /* User accessable spi - cs3 (10MHz) */
142 .modalias = "spi-cs3",
143 .chip_select = 3,
144 .max_speed_hz = 10 * 1000 * 1000,
145 },
146};
147
148static void __init ecb_at91board_init(void)
149{
150 /* Serial */
151 at91_add_device_serial();
152
153 /* Ethernet */
154 at91_add_device_eth(&ecb_at91eth_data);
155
156 /* USB Host */
157 at91_add_device_usbh(&ecb_at91usbh_data);
158
159 /* I2C */
160 at91_add_device_i2c(NULL, 0);
161
162 /* MMC */
163 at91_add_device_mmc(0, &ecb_at91mmc_data);
164
165 /* SPI */
166 at91_add_device_spi(ecb_at91spi_devices, ARRAY_SIZE(ecb_at91spi_devices));
167}
168
169MACHINE_START(ECBAT91, "emQbit's ECB_AT91")
170 /* Maintainer: emQbit.com */
171 .phys_io = AT91_BASE_SYS,
172 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
173 .boot_params = AT91_SDRAM_BASE + 0x100,
174 .timer = &at91rm9200_timer,
175 .map_io = ecb_at91map_io,
176 .init_irq = ecb_at91init_irq,
177 .init_machine = ecb_at91board_init,
178MACHINE_END
diff --git a/arch/arm/mach-at91/board-ek.c b/arch/arm/mach-at91/board-ek.c
index 0574e50a30dd..74aa4325eab3 100644
--- a/arch/arm/mach-at91/board-ek.c
+++ b/arch/arm/mach-at91/board-ek.c
@@ -45,17 +45,6 @@
45#include "generic.h" 45#include "generic.h"
46 46
47 47
48/*
49 * Serial port configuration.
50 * 0 .. 3 = USART0 .. USART3
51 * 4 = DBGU
52 */
53static struct at91_uart_config __initdata ek_uart_config = {
54 .console_tty = 0, /* ttyS0 */
55 .nr_tty = 2,
56 .tty_map = { 4, 1, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
57};
58
59static void __init ek_map_io(void) 48static void __init ek_map_io(void)
60{ 49{
61 /* Initialize processor: 18.432 MHz crystal */ 50 /* Initialize processor: 18.432 MHz crystal */
@@ -64,8 +53,16 @@ static void __init ek_map_io(void)
64 /* Setup the LEDs */ 53 /* Setup the LEDs */
65 at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2); 54 at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2);
66 55
67 /* Setup the serial ports and console */ 56 /* DBGU on ttyS0. (Rx & Tx only) */
68 at91_init_serial(&ek_uart_config); 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);
69} 66}
70 67
71static void __init ek_init_irq(void) 68static void __init ek_init_irq(void)
@@ -122,7 +119,7 @@ static struct i2c_board_info __initdata ek_i2c_devices[] = {
122#define EK_FLASH_SIZE 0x200000 119#define EK_FLASH_SIZE 0x200000
123 120
124static struct physmap_flash_data ek_flash_data = { 121static struct physmap_flash_data ek_flash_data = {
125 .width = 2, 122 .width = 2,
126}; 123};
127 124
128static struct resource ek_flash_resource = { 125static struct resource ek_flash_resource = {
diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c
index 4b39b9cda75b..cb065febd95e 100644
--- a/arch/arm/mach-at91/board-kb9202.c
+++ b/arch/arm/mach-at91/board-kb9202.c
@@ -37,19 +37,10 @@
37#include <asm/arch/board.h> 37#include <asm/arch/board.h>
38#include <asm/arch/gpio.h> 38#include <asm/arch/gpio.h>
39 39
40#include "generic.h" 40#include <asm/arch/at91rm9200_mc.h>
41 41
42#include "generic.h"
42 43
43/*
44 * Serial port configuration.
45 * 0 .. 3 = USART0 .. USART3
46 * 4 = DBGU
47 */
48static struct at91_uart_config __initdata kb9202_uart_config = {
49 .console_tty = 0, /* ttyS0 */
50 .nr_tty = 3,
51 .tty_map = { 4, 0, 1, -1, -1 } /* ttyS0, ..., ttyS4 */
52};
53 44
54static void __init kb9202_map_io(void) 45static void __init kb9202_map_io(void)
55{ 46{
@@ -59,8 +50,20 @@ static void __init kb9202_map_io(void)
59 /* Set up the LEDs */ 50 /* Set up the LEDs */
60 at91_init_leds(AT91_PIN_PC19, AT91_PIN_PC18); 51 at91_init_leds(AT91_PIN_PC19, AT91_PIN_PC18);
61 52
62 /* Setup the serial ports and console */ 53 /* DBGU on ttyS0. (Rx & Tx only) */
63 at91_init_serial(&kb9202_uart_config); 54 at91_register_uart(0, 0, 0);
55
56 /* USART0 on ttyS1 (Rx & Tx only) */
57 at91_register_uart(AT91RM9200_ID_US0, 1, 0);
58
59 /* USART1 on ttyS2 (Rx & Tx only) - IRDA (optional) */
60 at91_register_uart(AT91RM9200_ID_US1, 2, 0);
61
62 /* USART3 on ttyS3 (Rx, Tx, CTS, RTS) - RS485 (optional) */
63 at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
64
65 /* set serial console to ttyS0 (ie, DBGU) */
66 at91_set_serial_console(0);
64} 67}
65 68
66static void __init kb9202_init_irq(void) 69static void __init kb9202_init_irq(void)
diff --git a/arch/arm/mach-at91/board-qil-a9260.c b/arch/arm/mach-at91/board-qil-a9260.c
new file mode 100644
index 000000000000..99b4ec3818d6
--- /dev/null
+++ b/arch/arm/mach-at91/board-qil-a9260.c
@@ -0,0 +1,255 @@
1/*
2 * linux/arch/arm/mach-at91/board-qil-a9260.c
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2006 Atmel
6 * Copyright (C) 2007 Calao-systems
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/types.h>
24#include <linux/init.h>
25#include <linux/mm.h>
26#include <linux/module.h>
27#include <linux/platform_device.h>
28#include <linux/spi/spi.h>
29#include <linux/gpio_keys.h>
30#include <linux/input.h>
31#include <linux/clk.h>
32
33#include <asm/hardware.h>
34#include <asm/setup.h>
35#include <asm/mach-types.h>
36#include <asm/irq.h>
37
38#include <asm/mach/arch.h>
39#include <asm/mach/map.h>
40#include <asm/mach/irq.h>
41
42#include <asm/arch/board.h>
43#include <asm/arch/gpio.h>
44#include <asm/arch/at91_shdwc.h>
45
46#include "generic.h"
47
48
49static void __init ek_map_io(void)
50{
51 /* Initialize processor: 12.000 MHz crystal */
52 at91sam9260_initialize(12000000);
53
54 /* DGBU on ttyS0. (Rx & Tx only) */
55 at91_register_uart(0, 0, 0);
56
57 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
58 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
59 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
60 | ATMEL_UART_RI);
61
62 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
63 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
64
65 /* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */
66 at91_register_uart(AT91SAM9260_ID_US2, 3, ATMEL_UART_CTS | ATMEL_UART_RTS);
67
68 /* set serial console to ttyS1 (ie, USART0) */
69 at91_set_serial_console(1);
70
71}
72
73static void __init ek_init_irq(void)
74{
75 at91sam9260_init_interrupts(NULL);
76}
77
78
79/*
80 * USB Host port
81 */
82static struct at91_usbh_data __initdata ek_usbh_data = {
83 .ports = 2,
84};
85
86/*
87 * USB Device port
88 */
89static struct at91_udc_data __initdata ek_udc_data = {
90 .vbus_pin = AT91_PIN_PC5,
91 .pullup_pin = 0, /* pull-up driven by UDC */
92};
93
94/*
95 * SPI devices.
96 */
97static struct spi_board_info ek_spi_devices[] = {
98#if defined(CONFIG_RTC_DRV_M41T94)
99 { /* M41T94 RTC */
100 .modalias = "m41t94",
101 .chip_select = 0,
102 .max_speed_hz = 1 * 1000 * 1000,
103 .bus_num = 0,
104 }
105#endif
106};
107
108/*
109 * MACB Ethernet device
110 */
111static struct at91_eth_data __initdata ek_macb_data = {
112 .phy_irq_pin = AT91_PIN_PA31,
113 .is_rmii = 1,
114};
115
116/*
117 * NAND flash
118 */
119static struct mtd_partition __initdata ek_nand_partition[] = {
120 {
121 .name = "Uboot & Kernel",
122 .offset = 0x00000000,
123 .size = 16 * 1024 * 1024,
124 },
125 {
126 .name = "Root FS",
127 .offset = 0x01000000,
128 .size = 120 * 1024 * 1024,
129 },
130 {
131 .name = "FS",
132 .offset = 0x08800000,
133 .size = 120 * 1024 * 1024,
134 },
135};
136
137static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
138{
139 *num_partitions = ARRAY_SIZE(ek_nand_partition);
140 return ek_nand_partition;
141}
142
143static struct at91_nand_data __initdata ek_nand_data = {
144 .ale = 21,
145 .cle = 22,
146// .det_pin = ... not connected
147 .rdy_pin = AT91_PIN_PC13,
148 .enable_pin = AT91_PIN_PC14,
149 .partition_info = nand_partitions,
150#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
151 .bus_width_16 = 1,
152#else
153 .bus_width_16 = 0,
154#endif
155};
156
157/*
158 * MCI (SD/MMC)
159 */
160static struct at91_mmc_data __initdata ek_mmc_data = {
161 .slot_b = 0,
162 .wire4 = 1,
163// .det_pin = ... not connected
164// .wp_pin = ... not connected
165// .vcc_pin = ... not connected
166};
167
168/*
169 * GPIO Buttons
170 */
171#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
172static struct gpio_keys_button ek_buttons[] = {
173 { /* USER PUSH BUTTON */
174 .code = KEY_ENTER,
175 .gpio = AT91_PIN_PB10,
176 .active_low = 1,
177 .desc = "user_pb",
178 .wakeup = 1,
179 }
180};
181
182static struct gpio_keys_platform_data ek_button_data = {
183 .buttons = ek_buttons,
184 .nbuttons = ARRAY_SIZE(ek_buttons),
185};
186
187static struct platform_device ek_button_device = {
188 .name = "gpio-keys",
189 .id = -1,
190 .num_resources = 0,
191 .dev = {
192 .platform_data = &ek_button_data,
193 }
194};
195
196static void __init ek_add_device_buttons(void)
197{
198 at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* user push button, pull up enabled */
199 at91_set_deglitch(AT91_PIN_PB10, 1);
200
201 platform_device_register(&ek_button_device);
202}
203#else
204static void __init ek_add_device_buttons(void) {}
205#endif
206
207/*
208 * LEDs
209 */
210static struct gpio_led ek_leds[] = {
211 { /* user_led (green) */
212 .name = "user_led",
213 .gpio = AT91_PIN_PB21,
214 .active_low = 0,
215 .default_trigger = "heartbeat",
216 }
217};
218
219static void __init ek_board_init(void)
220{
221 /* Serial */
222 at91_add_device_serial();
223 /* USB Host */
224 at91_add_device_usbh(&ek_usbh_data);
225 /* USB Device */
226 at91_add_device_udc(&ek_udc_data);
227 /* SPI */
228 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
229 /* NAND */
230 at91_add_device_nand(&ek_nand_data);
231 /* I2C */
232 at91_add_device_i2c(NULL, 0);
233 /* Ethernet */
234 at91_add_device_eth(&ek_macb_data);
235 /* MMC */
236 at91_add_device_mmc(0, &ek_mmc_data);
237 /* Push Buttons */
238 ek_add_device_buttons();
239 /* LEDs */
240 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
241 /* shutdown controller, wakeup button (5 msec low) */
242 at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
243 | AT91_SHDW_RTTWKEN);
244}
245
246MACHINE_START(QIL_A9260, "CALAO QIL_A9260")
247 /* Maintainer: calao-systems */
248 .phys_io = AT91_BASE_SYS,
249 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
250 .boot_params = AT91_SDRAM_BASE + 0x100,
251 .timer = &at91sam926x_timer,
252 .map_io = ek_map_io,
253 .init_irq = ek_init_irq,
254 .init_machine = ek_board_init,
255MACHINE_END
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
new file mode 100644
index 000000000000..8f76af5e219a
--- /dev/null
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -0,0 +1,199 @@
1/*
2 * linux/arch/arm/mach-at91/board-sam9-l9260.c
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2006 Atmel
6 * Copyright (C) 2007 Olimex Ltd
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/types.h>
24#include <linux/init.h>
25#include <linux/mm.h>
26#include <linux/module.h>
27#include <linux/platform_device.h>
28#include <linux/spi/spi.h>
29
30#include <asm/hardware.h>
31#include <asm/setup.h>
32#include <asm/mach-types.h>
33#include <asm/irq.h>
34
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37#include <asm/mach/irq.h>
38
39#include <asm/arch/board.h>
40#include <asm/arch/gpio.h>
41
42#include "generic.h"
43
44
45static void __init ek_map_io(void)
46{
47 /* Initialize processor: 18.432 MHz crystal */
48 at91sam9260_initialize(18432000);
49
50 /* Setup the LEDs */
51 at91_init_leds(AT91_PIN_PA9, AT91_PIN_PA6);
52
53 /* DBGU on ttyS0. (Rx & Tx only) */
54 at91_register_uart(0, 0, 0);
55
56 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
57 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
58 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
59 | ATMEL_UART_RI);
60
61 /* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
62 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
63
64 /* set serial console to ttyS0 (ie, DBGU) */
65 at91_set_serial_console(0);
66}
67
68static void __init ek_init_irq(void)
69{
70 at91sam9260_init_interrupts(NULL);
71}
72
73
74/*
75 * USB Host port
76 */
77static struct at91_usbh_data __initdata ek_usbh_data = {
78 .ports = 2,
79};
80
81/*
82 * USB Device port
83 */
84static struct at91_udc_data __initdata ek_udc_data = {
85 .vbus_pin = AT91_PIN_PC5,
86 .pullup_pin = 0, /* pull-up driven by UDC */
87};
88
89
90/*
91 * SPI devices.
92 */
93static struct spi_board_info ek_spi_devices[] = {
94#if !defined(CONFIG_MMC_AT91)
95 { /* DataFlash chip */
96 .modalias = "mtd_dataflash",
97 .chip_select = 1,
98 .max_speed_hz = 15 * 1000 * 1000,
99 .bus_num = 0,
100 },
101#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
102 { /* DataFlash card */
103 .modalias = "mtd_dataflash",
104 .chip_select = 0,
105 .max_speed_hz = 15 * 1000 * 1000,
106 .bus_num = 0,
107 },
108#endif
109#endif
110};
111
112
113/*
114 * MACB Ethernet device
115 */
116static struct at91_eth_data __initdata ek_macb_data = {
117 .phy_irq_pin = AT91_PIN_PA7,
118 .is_rmii = 0,
119};
120
121
122/*
123 * NAND flash
124 */
125static struct mtd_partition __initdata ek_nand_partition[] = {
126 {
127 .name = "Bootloader Area",
128 .offset = 0,
129 .size = 10 * 1024 * 1024,
130 },
131 {
132 .name = "User Area",
133 .offset = 10 * 1024 * 1024,
134 .size = MTDPART_SIZ_FULL,
135 },
136};
137
138static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
139{
140 *num_partitions = ARRAY_SIZE(ek_nand_partition);
141 return ek_nand_partition;
142}
143
144static struct at91_nand_data __initdata ek_nand_data = {
145 .ale = 21,
146 .cle = 22,
147// .det_pin = ... not connected
148 .rdy_pin = AT91_PIN_PC13,
149 .enable_pin = AT91_PIN_PC14,
150 .partition_info = nand_partitions,
151#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
152 .bus_width_16 = 1,
153#else
154 .bus_width_16 = 0,
155#endif
156};
157
158
159/*
160 * MCI (SD/MMC)
161 */
162static struct at91_mmc_data __initdata ek_mmc_data = {
163 .slot_b = 1,
164 .wire4 = 1,
165 .det_pin = AT91_PIN_PC8,
166 .wp_pin = AT91_PIN_PC4,
167// .vcc_pin = ... not connected
168};
169
170static void __init ek_board_init(void)
171{
172 /* Serial */
173 at91_add_device_serial();
174 /* USB Host */
175 at91_add_device_usbh(&ek_usbh_data);
176 /* USB Device */
177 at91_add_device_udc(&ek_udc_data);
178 /* SPI */
179 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
180 /* NAND */
181 at91_add_device_nand(&ek_nand_data);
182 /* Ethernet */
183 at91_add_device_eth(&ek_macb_data);
184 /* MMC */
185 at91_add_device_mmc(0, &ek_mmc_data);
186 /* I2C */
187 at91_add_device_i2c(NULL, 0);
188}
189
190MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")
191 /* Maintainer: Olimex */
192 .phys_io = AT91_BASE_SYS,
193 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
194 .boot_params = AT91_SDRAM_BASE + 0x100,
195 .timer = &at91sam926x_timer,
196 .map_io = ek_map_io,
197 .init_irq = ek_init_irq,
198 .init_machine = ek_board_init,
199MACHINE_END
diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c
index b343a6c28120..4d1d9c777084 100644
--- a/arch/arm/mach-at91/board-sam9260ek.c
+++ b/arch/arm/mach-at91/board-sam9260ek.c
@@ -25,6 +25,8 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/spi/at73c213.h>
29#include <linux/clk.h>
28 30
29#include <asm/hardware.h> 31#include <asm/hardware.h>
30#include <asm/setup.h> 32#include <asm/setup.h>
@@ -37,29 +39,28 @@
37 39
38#include <asm/arch/board.h> 40#include <asm/arch/board.h>
39#include <asm/arch/gpio.h> 41#include <asm/arch/gpio.h>
40#include <asm/arch/at91sam926x_mc.h>
41 42
42#include "generic.h" 43#include "generic.h"
43 44
44 45
45/*
46 * Serial port configuration.
47 * 0 .. 5 = USART0 .. USART5
48 * 6 = DBGU
49 */
50static struct at91_uart_config __initdata ek_uart_config = {
51 .console_tty = 0, /* ttyS0 */
52 .nr_tty = 3,
53 .tty_map = { 6, 0, 1, -1, -1, -1, -1 } /* ttyS0, ..., ttyS6 */
54};
55
56static void __init ek_map_io(void) 46static void __init ek_map_io(void)
57{ 47{
58 /* Initialize processor: 18.432 MHz crystal */ 48 /* Initialize processor: 18.432 MHz crystal */
59 at91sam9260_initialize(18432000); 49 at91sam9260_initialize(18432000);
60 50
61 /* Setup the serial ports and console */ 51 /* DGBU on ttyS0. (Rx & Tx only) */
62 at91_init_serial(&ek_uart_config); 52 at91_register_uart(0, 0, 0);
53
54 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
55 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
56 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
57 | ATMEL_UART_RI);
58
59 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
60 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
61
62 /* set serial console to ttyS0 (ie, DBGU) */
63 at91_set_serial_console(0);
63} 64}
64 65
65static void __init ek_init_irq(void) 66static void __init ek_init_irq(void)
@@ -85,6 +86,35 @@ static struct at91_udc_data __initdata ek_udc_data = {
85 86
86 87
87/* 88/*
89 * Audio
90 */
91static struct at73c213_board_info at73c213_data = {
92 .ssc_id = 0,
93 .shortname = "AT91SAM9260-EK external DAC",
94};
95
96#if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
97static void __init at73c213_set_clk(struct at73c213_board_info *info)
98{
99 struct clk *pck0;
100 struct clk *plla;
101
102 pck0 = clk_get(NULL, "pck0");
103 plla = clk_get(NULL, "plla");
104
105 /* AT73C213 MCK Clock */
106 at91_set_B_periph(AT91_PIN_PC1, 0); /* PCK0 */
107
108 clk_set_parent(pck0, plla);
109 clk_put(plla);
110
111 info->dac_clk = pck0;
112}
113#else
114static void __init at73c213_set_clk(struct at73c213_board_info *info) {}
115#endif
116
117/*
88 * SPI devices. 118 * SPI devices.
89 */ 119 */
90static struct spi_board_info ek_spi_devices[] = { 120static struct spi_board_info ek_spi_devices[] = {
@@ -110,6 +140,8 @@ static struct spi_board_info ek_spi_devices[] = {
110 .chip_select = 0, 140 .chip_select = 0,
111 .max_speed_hz = 10 * 1000 * 1000, 141 .max_speed_hz = 10 * 1000 * 1000,
112 .bus_num = 1, 142 .bus_num = 1,
143 .mode = SPI_MODE_1,
144 .platform_data = &at73c213_data,
113 }, 145 },
114#endif 146#endif
115}; 147};
@@ -172,6 +204,24 @@ static struct at91_mmc_data __initdata ek_mmc_data = {
172// .vcc_pin = ... not connected 204// .vcc_pin = ... not connected
173}; 205};
174 206
207
208/*
209 * LEDs
210 */
211static struct gpio_led ek_leds[] = {
212 { /* "bottom" led, green, userled1 to be defined */
213 .name = "ds5",
214 .gpio = AT91_PIN_PA6,
215 .active_low = 1,
216 .default_trigger = "none",
217 },
218 { /* "power" led, yellow */
219 .name = "ds1",
220 .gpio = AT91_PIN_PA9,
221 .default_trigger = "heartbeat",
222 }
223};
224
175static void __init ek_board_init(void) 225static void __init ek_board_init(void)
176{ 226{
177 /* Serial */ 227 /* Serial */
@@ -190,6 +240,11 @@ static void __init ek_board_init(void)
190 at91_add_device_mmc(0, &ek_mmc_data); 240 at91_add_device_mmc(0, &ek_mmc_data);
191 /* I2C */ 241 /* I2C */
192 at91_add_device_i2c(NULL, 0); 242 at91_add_device_i2c(NULL, 0);
243 /* SSC (to AT73C213) */
244 at73c213_set_clk(&at73c213_data);
245 at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
246 /* LEDs */
247 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
193} 248}
194 249
195MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK") 250MACHINE_START(AT91SAM9260EK, "Atmel AT91SAM9260-EK")
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 0ce38dfa6ebe..08382c0df221 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -26,6 +26,8 @@
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
28#include <linux/spi/ads7846.h> 28#include <linux/spi/ads7846.h>
29#include <linux/spi/at73c213.h>
30#include <linux/clk.h>
29#include <linux/dm9000.h> 31#include <linux/dm9000.h>
30#include <linux/fb.h> 32#include <linux/fb.h>
31#include <linux/gpio_keys.h> 33#include <linux/gpio_keys.h>
@@ -44,22 +46,11 @@
44 46
45#include <asm/arch/board.h> 47#include <asm/arch/board.h>
46#include <asm/arch/gpio.h> 48#include <asm/arch/gpio.h>
47#include <asm/arch/at91sam926x_mc.h> 49#include <asm/arch/at91sam9_smc.h>
48 50
49#include "generic.h" 51#include "generic.h"
50 52
51 53
52/*
53 * Serial port configuration.
54 * 0 .. 2 = USART0 .. USART2
55 * 3 = DBGU
56 */
57static struct at91_uart_config __initdata ek_uart_config = {
58 .console_tty = 0, /* ttyS0 */
59 .nr_tty = 1,
60 .tty_map = { 3, -1, -1, -1 } /* ttyS0, ..., ttyS3 */
61};
62
63static void __init ek_map_io(void) 54static void __init ek_map_io(void)
64{ 55{
65 /* Initialize processor: 18.432 MHz crystal */ 56 /* Initialize processor: 18.432 MHz crystal */
@@ -68,8 +59,11 @@ static void __init ek_map_io(void)
68 /* Setup the LEDs */ 59 /* Setup the LEDs */
69 at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14); 60 at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
70 61
71 /* Setup the serial ports and console */ 62 /* DGBU on ttyS0. (Rx & Tx only) */
72 at91_init_serial(&ek_uart_config); 63 at91_register_uart(0, 0, 0);
64
65 /* set serial console to ttyS0 (ie, DBGU) */
66 at91_set_serial_console(0);
73} 67}
74 68
75static void __init ek_init_irq(void) 69static void __init ek_init_irq(void)
@@ -239,6 +233,35 @@ static void __init ek_add_device_ts(void) {}
239#endif 233#endif
240 234
241/* 235/*
236 * Audio
237 */
238static struct at73c213_board_info at73c213_data = {
239 .ssc_id = 1,
240 .shortname = "AT91SAM9261-EK external DAC",
241};
242
243#if defined(CONFIG_SND_AT73C213) || defined(CONFIG_SND_AT73C213_MODULE)
244static void __init at73c213_set_clk(struct at73c213_board_info *info)
245{
246 struct clk *pck2;
247 struct clk *plla;
248
249 pck2 = clk_get(NULL, "pck2");
250 plla = clk_get(NULL, "plla");
251
252 /* AT73C213 MCK Clock */
253 at91_set_B_periph(AT91_PIN_PB31, 0); /* PCK2 */
254
255 clk_set_parent(pck2, plla);
256 clk_put(plla);
257
258 info->dac_clk = pck2;
259}
260#else
261static void __init at73c213_set_clk(struct at73c213_board_info *info) {}
262#endif
263
264/*
242 * SPI devices 265 * SPI devices
243 */ 266 */
244static struct spi_board_info ek_spi_devices[] = { 267static struct spi_board_info ek_spi_devices[] = {
@@ -256,6 +279,7 @@ static struct spi_board_info ek_spi_devices[] = {
256 .bus_num = 0, 279 .bus_num = 0,
257 .platform_data = &ads_info, 280 .platform_data = &ads_info,
258 .irq = AT91SAM9261_ID_IRQ0, 281 .irq = AT91SAM9261_ID_IRQ0,
282 .controller_data = (void *) AT91_PIN_PA28, /* CS pin */
259 }, 283 },
260#endif 284#endif
261#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD) 285#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
@@ -271,6 +295,9 @@ static struct spi_board_info ek_spi_devices[] = {
271 .chip_select = 3, 295 .chip_select = 3,
272 .max_speed_hz = 10 * 1000 * 1000, 296 .max_speed_hz = 10 * 1000 * 1000,
273 .bus_num = 0, 297 .bus_num = 0,
298 .mode = SPI_MODE_1,
299 .platform_data = &at73c213_data,
300 .controller_data = (void*) AT91_PIN_PA29, /* default for CS3 is PA6, but it must be PA29 */
274 }, 301 },
275#endif 302#endif
276}; 303};
@@ -460,6 +487,29 @@ static void __init ek_add_device_buttons(void)
460static void __init ek_add_device_buttons(void) {} 487static void __init ek_add_device_buttons(void) {}
461#endif 488#endif
462 489
490/*
491 * LEDs
492 */
493static struct gpio_led ek_leds[] = {
494 { /* "bottom" led, green, userled1 to be defined */
495 .name = "ds7",
496 .gpio = AT91_PIN_PA14,
497 .active_low = 1,
498 .default_trigger = "none",
499 },
500 { /* "top" led, green, userled2 to be defined */
501 .name = "ds8",
502 .gpio = AT91_PIN_PA13,
503 .active_low = 1,
504 .default_trigger = "none",
505 },
506 { /* "power" led, yellow */
507 .name = "ds1",
508 .gpio = AT91_PIN_PA23,
509 .default_trigger = "heartbeat",
510 }
511};
512
463static void __init ek_board_init(void) 513static void __init ek_board_init(void)
464{ 514{
465 /* Serial */ 515 /* Serial */
@@ -481,6 +531,9 @@ static void __init ek_board_init(void)
481 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices)); 531 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
482 /* Touchscreen */ 532 /* Touchscreen */
483 ek_add_device_ts(); 533 ek_add_device_ts();
534 /* SSC (to AT73C213) */
535 at73c213_set_clk(&at73c213_data);
536 at91_add_device_ssc(AT91SAM9261_ID_SSC1, ATMEL_SSC_TX);
484#else 537#else
485 /* MMC */ 538 /* MMC */
486 at91_add_device_mmc(0, &ek_mmc_data); 539 at91_add_device_mmc(0, &ek_mmc_data);
@@ -489,6 +542,8 @@ static void __init ek_board_init(void)
489 at91_add_device_lcdc(&ek_lcdc_data); 542 at91_add_device_lcdc(&ek_lcdc_data);
490 /* Push Buttons */ 543 /* Push Buttons */
491 ek_add_device_buttons(); 544 ek_add_device_buttons();
545 /* LEDs */
546 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
492} 547}
493 548
494MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK") 549MACHINE_START(AT91SAM9261EK, "Atmel AT91SAM9261-EK")
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index bf103b24c937..b4cd5d0ed597 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -43,29 +43,24 @@
43 43
44#include <asm/arch/board.h> 44#include <asm/arch/board.h>
45#include <asm/arch/gpio.h> 45#include <asm/arch/gpio.h>
46#include <asm/arch/at91sam926x_mc.h> 46#include <asm/arch/at91sam9_smc.h>
47 47
48#include "generic.h" 48#include "generic.h"
49 49
50 50
51/*
52 * Serial port configuration.
53 * 0 .. 2 = USART0 .. USART2
54 * 3 = DBGU
55 */
56static struct at91_uart_config __initdata ek_uart_config = {
57 .console_tty = 0, /* ttyS0 */
58 .nr_tty = 2,
59 .tty_map = { 3, 0, -1, -1, } /* ttyS0, ..., ttyS3 */
60};
61
62static void __init ek_map_io(void) 51static void __init ek_map_io(void)
63{ 52{
64 /* Initialize processor: 16.367 MHz crystal */ 53 /* Initialize processor: 16.367 MHz crystal */
65 at91sam9263_initialize(16367660); 54 at91sam9263_initialize(16367660);
66 55
67 /* Setup the serial ports and console */ 56 /* DGBU on ttyS0. (Rx & Tx only) */
68 at91_init_serial(&ek_uart_config); 57 at91_register_uart(0, 0, 0);
58
59 /* USART0 on ttyS1. (Rx, Tx, RTS, CTS) */
60 at91_register_uart(AT91SAM9263_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
61
62 /* set serial console to ttyS0 (ie, DBGU) */
63 at91_set_serial_console(0);
69} 64}
70 65
71static void __init ek_init_irq(void) 66static void __init ek_init_irq(void)
@@ -341,7 +336,7 @@ static struct gpio_led ek_leds[] = {
341 .name = "ds3", 336 .name = "ds3",
342 .gpio = AT91_PIN_PB7, 337 .gpio = AT91_PIN_PB7,
343 .default_trigger = "heartbeat", 338 .default_trigger = "heartbeat",
344 }, 339 }
345}; 340};
346 341
347 342
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c
new file mode 100644
index 000000000000..45617c201240
--- /dev/null
+++ b/arch/arm/mach-at91/board-sam9g20ek.c
@@ -0,0 +1,218 @@
1/*
2 * Copyright (C) 2005 SAN People
3 * Copyright (C) 2008 Atmel
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#include <linux/types.h>
21#include <linux/init.h>
22#include <linux/mm.h>
23#include <linux/module.h>
24#include <linux/platform_device.h>
25#include <linux/spi/spi.h>
26#include <linux/spi/at73c213.h>
27#include <linux/clk.h>
28
29#include <asm/hardware.h>
30#include <asm/setup.h>
31#include <asm/mach-types.h>
32#include <asm/irq.h>
33
34#include <asm/mach/arch.h>
35#include <asm/mach/map.h>
36#include <asm/mach/irq.h>
37
38#include <asm/arch/board.h>
39#include <asm/arch/gpio.h>
40
41#include "generic.h"
42
43
44static void __init ek_map_io(void)
45{
46 /* Initialize processor: 18.432 MHz crystal */
47 at91sam9260_initialize(18432000);
48
49 /* DGBU on ttyS0. (Rx & Tx only) */
50 at91_register_uart(0, 0, 0);
51
52 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
53 at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
54 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
55 | ATMEL_UART_RI);
56
57 /* USART1 on ttyS2. (Rx, Tx, RTS, CTS) */
58 at91_register_uart(AT91SAM9260_ID_US1, 2, ATMEL_UART_CTS | ATMEL_UART_RTS);
59
60 /* set serial console to ttyS0 (ie, DBGU) */
61 at91_set_serial_console(0);
62}
63
64static void __init ek_init_irq(void)
65{
66 at91sam9260_init_interrupts(NULL);
67}
68
69
70/*
71 * USB Host port
72 */
73static struct at91_usbh_data __initdata ek_usbh_data = {
74 .ports = 2,
75};
76
77/*
78 * USB Device port
79 */
80static struct at91_udc_data __initdata ek_udc_data = {
81 .vbus_pin = AT91_PIN_PC5,
82 .pullup_pin = 0, /* pull-up driven by UDC */
83};
84
85
86/*
87 * SPI devices.
88 */
89static struct spi_board_info ek_spi_devices[] = {
90#if !defined(CONFIG_MMC_AT91)
91 { /* DataFlash chip */
92 .modalias = "mtd_dataflash",
93 .chip_select = 1,
94 .max_speed_hz = 15 * 1000 * 1000,
95 .bus_num = 0,
96 },
97#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
98 { /* DataFlash card */
99 .modalias = "mtd_dataflash",
100 .chip_select = 0,
101 .max_speed_hz = 15 * 1000 * 1000,
102 .bus_num = 0,
103 },
104#endif
105#endif
106};
107
108
109/*
110 * MACB Ethernet device
111 */
112static struct at91_eth_data __initdata ek_macb_data = {
113 .phy_irq_pin = AT91_PIN_PA7,
114 .is_rmii = 1,
115};
116
117
118/*
119 * NAND flash
120 */
121static struct mtd_partition __initdata ek_nand_partition[] = {
122 {
123 .name = "Bootstrap",
124 .offset = 0,
125 .size = 4 * 1024 * 1024,
126 },
127 {
128 .name = "Partition 1",
129 .offset = 4 * 1024 * 1024,
130 .size = 60 * 1024 * 1024,
131 },
132 {
133 .name = "Partition 2",
134 .offset = 64 * 1024 * 1024,
135 .size = MTDPART_SIZ_FULL,
136 },
137};
138
139static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
140{
141 *num_partitions = ARRAY_SIZE(ek_nand_partition);
142 return ek_nand_partition;
143}
144
145/* det_pin is not connected */
146static struct at91_nand_data __initdata ek_nand_data = {
147 .ale = 21,
148 .cle = 22,
149 .rdy_pin = AT91_PIN_PC13,
150 .enable_pin = AT91_PIN_PC14,
151 .partition_info = nand_partitions,
152#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
153 .bus_width_16 = 1,
154#else
155 .bus_width_16 = 0,
156#endif
157};
158
159
160/*
161 * MCI (SD/MMC)
162 * det_pin, wp_pin and vcc_pin are not connected
163 */
164static struct at91_mmc_data __initdata ek_mmc_data = {
165 .slot_b = 1,
166 .wire4 = 1,
167};
168
169
170/*
171 * LEDs
172 */
173static struct gpio_led ek_leds[] = {
174 { /* "bottom" led, green, userled1 to be defined */
175 .name = "ds5",
176 .gpio = AT91_PIN_PA6,
177 .active_low = 1,
178 .default_trigger = "none",
179 },
180 { /* "power" led, yellow */
181 .name = "ds1",
182 .gpio = AT91_PIN_PA9,
183 .default_trigger = "heartbeat",
184 }
185};
186
187static void __init ek_board_init(void)
188{
189 /* Serial */
190 at91_add_device_serial();
191 /* USB Host */
192 at91_add_device_usbh(&ek_usbh_data);
193 /* USB Device */
194 at91_add_device_udc(&ek_udc_data);
195 /* SPI */
196 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
197 /* NAND */
198 at91_add_device_nand(&ek_nand_data);
199 /* Ethernet */
200 at91_add_device_eth(&ek_macb_data);
201 /* MMC */
202 at91_add_device_mmc(0, &ek_mmc_data);
203 /* I2C */
204 at91_add_device_i2c(NULL, 0);
205 /* LEDs */
206 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
207}
208
209MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK")
210 /* Maintainer: Atmel */
211 .phys_io = AT91_BASE_SYS,
212 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
213 .boot_params = AT91_SDRAM_BASE + 0x100,
214 .timer = &at91sam926x_timer,
215 .map_io = ek_map_io,
216 .init_irq = ek_init_irq,
217 .init_machine = ek_board_init,
218MACHINE_END
diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index bc0546d7245f..b6a70fc735c3 100644
--- a/arch/arm/mach-at91/board-sam9rlek.c
+++ b/arch/arm/mach-at91/board-sam9rlek.c
@@ -29,29 +29,24 @@
29 29
30#include <asm/arch/board.h> 30#include <asm/arch/board.h>
31#include <asm/arch/gpio.h> 31#include <asm/arch/gpio.h>
32#include <asm/arch/at91sam926x_mc.h> 32#include <asm/arch/at91sam9_smc.h>
33 33
34#include "generic.h" 34#include "generic.h"
35 35
36 36
37/*
38 * Serial port configuration.
39 * 0 .. 3 = USART0 .. USART3
40 * 4 = DBGU
41 */
42static struct at91_uart_config __initdata ek_uart_config = {
43 .console_tty = 0, /* ttyS0 */
44 .nr_tty = 2,
45 .tty_map = { 4, 0, -1, -1, -1 } /* ttyS0, ..., ttyS4 */
46};
47
48static void __init ek_map_io(void) 37static void __init ek_map_io(void)
49{ 38{
50 /* Initialize processor: 12.000 MHz crystal */ 39 /* Initialize processor: 12.000 MHz crystal */
51 at91sam9rl_initialize(12000000); 40 at91sam9rl_initialize(12000000);
52 41
53 /* Setup the serial ports and console */ 42 /* DGBU on ttyS0. (Rx & Tx only) */
54 at91_init_serial(&ek_uart_config); 43 at91_register_uart(0, 0, 0);
44
45 /* USART0 on ttyS1. (Rx, Tx, CTS, RTS) */
46 at91_register_uart(AT91SAM9RL_ID_US0, 1, ATMEL_UART_CTS | ATMEL_UART_RTS);
47
48 /* set serial console to ttyS0 (ie, DBGU) */
49 at91_set_serial_console(0);
55} 50}
56 51
57static void __init ek_init_irq(void) 52static void __init ek_init_irq(void)
@@ -61,6 +56,14 @@ static void __init ek_init_irq(void)
61 56
62 57
63/* 58/*
59 * USB HS Device port
60 */
61static struct usba_platform_data __initdata ek_usba_udc_data = {
62 .vbus_pin = AT91_PIN_PA8,
63};
64
65
66/*
64 * MCI (SD/MMC) 67 * MCI (SD/MMC)
65 */ 68 */
66static struct at91_mmc_data __initdata ek_mmc_data = { 69static struct at91_mmc_data __initdata ek_mmc_data = {
@@ -180,6 +183,8 @@ static void __init ek_board_init(void)
180{ 183{
181 /* Serial */ 184 /* Serial */
182 at91_add_device_serial(); 185 at91_add_device_serial();
186 /* USB HS */
187 at91_add_device_usba(&ek_usba_udc_data);
183 /* I2C */ 188 /* I2C */
184 at91_add_device_i2c(NULL, 0); 189 at91_add_device_i2c(NULL, 0);
185 /* NAND */ 190 /* NAND */
diff --git a/arch/arm/mach-at91/board-usb-a9260.c b/arch/arm/mach-at91/board-usb-a9260.c
new file mode 100644
index 000000000000..837aedf8ffeb
--- /dev/null
+++ b/arch/arm/mach-at91/board-usb-a9260.c
@@ -0,0 +1,215 @@
1/*
2 * linux/arch/arm/mach-at91/board-usb-a9260.c
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2006 Atmel
6 * Copyright (C) 2007 Calao-systems
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/types.h>
24#include <linux/init.h>
25#include <linux/mm.h>
26#include <linux/module.h>
27#include <linux/platform_device.h>
28#include <linux/spi/spi.h>
29#include <linux/gpio_keys.h>
30#include <linux/input.h>
31#include <linux/clk.h>
32
33#include <asm/hardware.h>
34#include <asm/setup.h>
35#include <asm/mach-types.h>
36#include <asm/irq.h>
37
38#include <asm/mach/arch.h>
39#include <asm/mach/map.h>
40#include <asm/mach/irq.h>
41
42#include <asm/arch/board.h>
43#include <asm/arch/gpio.h>
44#include <asm/arch/at91_shdwc.h>
45
46#include "generic.h"
47
48
49static void __init ek_map_io(void)
50{
51 /* Initialize processor: 12.000 MHz crystal */
52 at91sam9260_initialize(12000000);
53
54 /* DGBU on ttyS0. (Rx & Tx only) */
55 at91_register_uart(0, 0, 0);
56
57 /* set serial console to ttyS0 (ie, DBGU) */
58 at91_set_serial_console(0);
59}
60
61static void __init ek_init_irq(void)
62{
63 at91sam9260_init_interrupts(NULL);
64}
65
66
67/*
68 * USB Host port
69 */
70static struct at91_usbh_data __initdata ek_usbh_data = {
71 .ports = 2,
72};
73
74/*
75 * USB Device port
76 */
77static struct at91_udc_data __initdata ek_udc_data = {
78 .vbus_pin = AT91_PIN_PC5,
79 .pullup_pin = 0, /* pull-up driven by UDC */
80};
81
82/*
83 * MACB Ethernet device
84 */
85static struct at91_eth_data __initdata ek_macb_data = {
86 .phy_irq_pin = AT91_PIN_PA31,
87 .is_rmii = 1,
88};
89
90/*
91 * NAND flash
92 */
93static struct mtd_partition __initdata ek_nand_partition[] = {
94 {
95 .name = "Uboot & Kernel",
96 .offset = 0x00000000,
97 .size = 16 * 1024 * 1024,
98 },
99 {
100 .name = "Root FS",
101 .offset = 0x01000000,
102 .size = 120 * 1024 * 1024,
103 },
104 {
105 .name = "FS",
106 .offset = 0x08800000,
107 .size = 120 * 1024 * 1024,
108 }
109};
110
111static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
112{
113 *num_partitions = ARRAY_SIZE(ek_nand_partition);
114 return ek_nand_partition;
115}
116
117static struct at91_nand_data __initdata ek_nand_data = {
118 .ale = 21,
119 .cle = 22,
120// .det_pin = ... not connected
121 .rdy_pin = AT91_PIN_PC13,
122 .enable_pin = AT91_PIN_PC14,
123 .partition_info = nand_partitions,
124#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
125 .bus_width_16 = 1,
126#else
127 .bus_width_16 = 0,
128#endif
129};
130
131/*
132 * GPIO Buttons
133 */
134
135#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
136static struct gpio_keys_button ek_buttons[] = {
137 { /* USER PUSH BUTTON */
138 .code = KEY_ENTER,
139 .gpio = AT91_PIN_PB10,
140 .active_low = 1,
141 .desc = "user_pb",
142 .wakeup = 1,
143 }
144};
145
146static struct gpio_keys_platform_data ek_button_data = {
147 .buttons = ek_buttons,
148 .nbuttons = ARRAY_SIZE(ek_buttons),
149};
150
151static struct platform_device ek_button_device = {
152 .name = "gpio-keys",
153 .id = -1,
154 .num_resources = 0,
155 .dev = {
156 .platform_data = &ek_button_data,
157 }
158};
159
160static void __init ek_add_device_buttons(void)
161{
162 at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* user push button, pull up enabled */
163 at91_set_deglitch(AT91_PIN_PB10, 1);
164
165 platform_device_register(&ek_button_device);
166}
167#else
168static void __init ek_add_device_buttons(void) {}
169#endif
170
171/*
172 * LEDs
173 */
174static struct gpio_led ek_leds[] = {
175 { /* user_led (green) */
176 .name = "user_led",
177 .gpio = AT91_PIN_PB21,
178 .active_low = 0,
179 .default_trigger = "heartbeat",
180 }
181};
182
183static void __init ek_board_init(void)
184{
185 /* Serial */
186 at91_add_device_serial();
187 /* USB Host */
188 at91_add_device_usbh(&ek_usbh_data);
189 /* USB Device */
190 at91_add_device_udc(&ek_udc_data);
191 /* NAND */
192 at91_add_device_nand(&ek_nand_data);
193 /* I2C */
194 at91_add_device_i2c(NULL, 0);
195 /* Ethernet */
196 at91_add_device_eth(&ek_macb_data);
197 /* Push Buttons */
198 ek_add_device_buttons();
199 /* LEDs */
200 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
201 /* shutdown controller, wakeup button (5 msec low) */
202 at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
203 | AT91_SHDW_RTTWKEN);
204}
205
206MACHINE_START(USB_A9260, "CALAO USB_A9260")
207 /* Maintainer: calao-systems */
208 .phys_io = AT91_BASE_SYS,
209 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
210 .boot_params = AT91_SDRAM_BASE + 0x100,
211 .timer = &at91sam926x_timer,
212 .map_io = ek_map_io,
213 .init_irq = ek_init_irq,
214 .init_machine = ek_board_init,
215MACHINE_END
diff --git a/arch/arm/mach-at91/board-usb-a9263.c b/arch/arm/mach-at91/board-usb-a9263.c
new file mode 100644
index 000000000000..95800d32bd49
--- /dev/null
+++ b/arch/arm/mach-at91/board-usb-a9263.c
@@ -0,0 +1,230 @@
1/*
2 * linux/arch/arm/mach-at91/board-usb-a9263.c
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2007 Atmel Corporation.
6 * Copyright (C) 2007 Calao-systems
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/types.h>
24#include <linux/init.h>
25#include <linux/mm.h>
26#include <linux/module.h>
27#include <linux/platform_device.h>
28#include <linux/spi/spi.h>
29#include <linux/gpio_keys.h>
30#include <linux/input.h>
31
32#include <asm/hardware.h>
33#include <asm/setup.h>
34#include <asm/mach-types.h>
35#include <asm/irq.h>
36
37#include <asm/mach/arch.h>
38#include <asm/mach/map.h>
39#include <asm/mach/irq.h>
40
41#include <asm/arch/board.h>
42#include <asm/arch/gpio.h>
43#include <asm/arch/at91_shdwc.h>
44
45#include "generic.h"
46
47
48static void __init ek_map_io(void)
49{
50 /* Initialize processor: 12.00 MHz crystal */
51 at91sam9263_initialize(12000000);
52
53 /* DGBU 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);
58}
59
60static void __init ek_init_irq(void)
61{
62 at91sam9263_init_interrupts(NULL);
63}
64
65
66/*
67 * USB Host port
68 */
69static struct at91_usbh_data __initdata ek_usbh_data = {
70 .ports = 2,
71};
72
73/*
74 * USB Device port
75 */
76static struct at91_udc_data __initdata ek_udc_data = {
77 .vbus_pin = AT91_PIN_PB11,
78 .pullup_pin = 0, /* pull-up driven by UDC */
79};
80
81/*
82 * SPI devices.
83 */
84static struct spi_board_info ek_spi_devices[] = {
85#if !defined(CONFIG_MMC_AT91)
86 { /* DataFlash chip */
87 .modalias = "mtd_dataflash",
88 .chip_select = 0,
89 .max_speed_hz = 15 * 1000 * 1000,
90 .bus_num = 0,
91 }
92#endif
93};
94
95/*
96 * MACB Ethernet device
97 */
98static struct at91_eth_data __initdata ek_macb_data = {
99 .phy_irq_pin = AT91_PIN_PE31,
100 .is_rmii = 1,
101};
102
103/*
104 * NAND flash
105 */
106static struct mtd_partition __initdata ek_nand_partition[] = {
107 {
108 .name = "Linux Kernel",
109 .offset = 0x00000000,
110 .size = 16 * 1024 * 1024,
111 },
112 {
113 .name = "Root FS",
114 .offset = 0x01000000,
115 .size = 120 * 1024 * 1024,
116 },
117 {
118 .name = "FS",
119 .offset = 0x08800000,
120 .size = 120 * 1024 * 1024,
121 }
122};
123
124static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
125{
126 *num_partitions = ARRAY_SIZE(ek_nand_partition);
127 return ek_nand_partition;
128}
129
130static struct at91_nand_data __initdata ek_nand_data = {
131 .ale = 21,
132 .cle = 22,
133// .det_pin = ... not connected
134 .rdy_pin = AT91_PIN_PA22,
135 .enable_pin = AT91_PIN_PD15,
136 .partition_info = nand_partitions,
137#if defined(CONFIG_MTD_NAND_AT91_BUSWIDTH_16)
138 .bus_width_16 = 1,
139#else
140 .bus_width_16 = 0,
141#endif
142};
143
144/*
145 * GPIO Buttons
146 */
147#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
148static struct gpio_keys_button ek_buttons[] = {
149 { /* USER PUSH BUTTON */
150 .code = KEY_ENTER,
151 .gpio = AT91_PIN_PB10,
152 .active_low = 1,
153 .desc = "user_pb",
154 .wakeup = 1,
155 }
156};
157
158static struct gpio_keys_platform_data ek_button_data = {
159 .buttons = ek_buttons,
160 .nbuttons = ARRAY_SIZE(ek_buttons),
161};
162
163static struct platform_device ek_button_device = {
164 .name = "gpio-keys",
165 .id = -1,
166 .num_resources = 0,
167 .dev = {
168 .platform_data = &ek_button_data,
169 }
170};
171
172static void __init ek_add_device_buttons(void)
173{
174 at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* user push button, pull up enabled */
175 at91_set_deglitch(AT91_PIN_PB10, 1);
176
177 platform_device_register(&ek_button_device);
178}
179#else
180static void __init ek_add_device_buttons(void) {}
181#endif
182
183/*
184 * LEDs
185 */
186static struct gpio_led ek_leds[] = {
187 { /* user_led (green) */
188 .name = "user_led",
189 .gpio = AT91_PIN_PB21,
190 .active_low = 1,
191 .default_trigger = "heartbeat",
192 }
193};
194
195
196static void __init ek_board_init(void)
197{
198 /* Serial */
199 at91_add_device_serial();
200 /* USB Host */
201 at91_add_device_usbh(&ek_usbh_data);
202 /* USB Device */
203 at91_add_device_udc(&ek_udc_data);
204 /* SPI */
205 at91_add_device_spi(ek_spi_devices, ARRAY_SIZE(ek_spi_devices));
206 /* Ethernet */
207 at91_add_device_eth(&ek_macb_data);
208 /* NAND */
209 at91_add_device_nand(&ek_nand_data);
210 /* I2C */
211 at91_add_device_i2c(NULL, 0);
212 /* Push Buttons */
213 ek_add_device_buttons();
214 /* LEDs */
215 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
216 /* shutdown controller, wakeup button (5 msec low) */
217 at91_sys_write(AT91_SHDW_MR, AT91_SHDW_CPTWK0_(10) | AT91_SHDW_WKMODE0_LOW
218 | AT91_SHDW_RTTWKEN);
219}
220
221MACHINE_START(USB_A9263, "CALAO USB_A9263")
222 /* Maintainer: calao-systems */
223 .phys_io = AT91_BASE_SYS,
224 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
225 .boot_params = AT91_SDRAM_BASE + 0x100,
226 .timer = &at91sam926x_timer,
227 .map_io = ek_map_io,
228 .init_irq = ek_init_irq,
229 .init_machine = ek_board_init,
230MACHINE_END
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
new file mode 100755
index 000000000000..7079050ab88d
--- /dev/null
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -0,0 +1,604 @@
1/*
2 * linux/arch/arm/mach-at91/board-yl-9200.c
3 *
4 * Adapted from various board files in arch/arm/mach-at91
5 *
6 * Modifications for YL-9200 platform:
7 * Copyright (C) 2007 S. Birtles
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/dma-mapping.h>
29#include <linux/platform_device.h>
30#include <linux/spi/spi.h>
31#include <linux/spi/ads7846.h>
32#include <linux/mtd/physmap.h>
33#include <linux/gpio_keys.h>
34#include <linux/input.h>
35
36#include <asm/hardware.h>
37#include <asm/setup.h>
38#include <asm/mach-types.h>
39#include <asm/irq.h>
40
41#include <asm/mach/arch.h>
42#include <asm/mach/map.h>
43#include <asm/mach/irq.h>
44
45#include <asm/arch/board.h>
46#include <asm/arch/gpio.h>
47#include <asm/arch/at91rm9200_mc.h>
48
49#include "generic.h"
50
51
52static void __init yl9200_map_io(void)
53{
54 /* Initialize processor: 18.432 MHz crystal */
55 at91rm9200_initialize(18432000, AT91RM9200_PQFP);
56
57 /* Setup the LEDs D2=PB17 (timer), D3=PB16 (cpu) */
58 at91_init_leds(AT91_PIN_PB16, AT91_PIN_PB17);
59
60 /* DBGU on ttyS0. (Rx & Tx only) */
61 at91_register_uart(0, 0, 0);
62
63 /* USART1 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
64 at91_register_uart(AT91RM9200_ID_US1, 1, ATMEL_UART_CTS | ATMEL_UART_RTS
65 | ATMEL_UART_DTR | ATMEL_UART_DSR | ATMEL_UART_DCD
66 | ATMEL_UART_RI);
67
68 /* USART0 on ttyS2. (Rx & Tx only to JP3) */
69 at91_register_uart(AT91RM9200_ID_US0, 2, 0);
70
71 /* USART3 on ttyS3. (Rx, Tx, RTS - RS485 interface) */
72 at91_register_uart(AT91RM9200_ID_US3, 3, ATMEL_UART_RTS);
73
74 /* set serial console to ttyS0 (ie, DBGU) */
75 at91_set_serial_console(0);
76}
77
78static void __init yl9200_init_irq(void)
79{
80 at91rm9200_init_interrupts(NULL);
81}
82
83
84/*
85 * LEDs
86 */
87static struct gpio_led yl9200_leds[] = {
88 { /* D2 */
89 .name = "led2",
90 .gpio = AT91_PIN_PB17,
91 .active_low = 1,
92 .default_trigger = "timer",
93 },
94 { /* D3 */
95 .name = "led3",
96 .gpio = AT91_PIN_PB16,
97 .active_low = 1,
98 .default_trigger = "heartbeat",
99 },
100 { /* D4 */
101 .name = "led4",
102 .gpio = AT91_PIN_PB15,
103 .active_low = 1,
104 },
105 { /* D5 */
106 .name = "led5",
107 .gpio = AT91_PIN_PB8,
108 .active_low = 1,
109 }
110};
111
112/*
113 * Ethernet
114 */
115static struct at91_eth_data __initdata yl9200_eth_data = {
116 .phy_irq_pin = AT91_PIN_PB28,
117 .is_rmii = 1,
118};
119
120/*
121 * USB Host
122 */
123static struct at91_usbh_data __initdata yl9200_usbh_data = {
124 .ports = 1, /* PQFP version of AT91RM9200 */
125};
126
127/*
128 * USB Device
129 */
130static struct at91_udc_data __initdata yl9200_udc_data = {
131 .pullup_pin = AT91_PIN_PC4,
132 .vbus_pin = AT91_PIN_PC5,
133 .pullup_active_low = 1, /* Active Low due to PNP transistor (pg 7) */
134
135};
136
137/*
138 * MMC
139 */
140static struct at91_mmc_data __initdata yl9200_mmc_data = {
141 .det_pin = AT91_PIN_PB9,
142 // .wp_pin = ... not connected
143 .wire4 = 1,
144};
145
146/*
147 * NAND Flash
148 */
149static struct mtd_partition __initdata yl9200_nand_partition[] = {
150 {
151 .name = "AT91 NAND partition 1, boot",
152 .offset = 0,
153 .size = 1 * SZ_256K
154 },
155 {
156 .name = "AT91 NAND partition 2, kernel",
157 .offset = 1 * SZ_256K,
158 .size = 2 * SZ_1M - 1 * SZ_256K
159 },
160 {
161 .name = "AT91 NAND partition 3, filesystem",
162 .offset = 2 * SZ_1M,
163 .size = 14 * SZ_1M
164 },
165 {
166 .name = "AT91 NAND partition 4, storage",
167 .offset = 16 * SZ_1M,
168 .size = 16 * SZ_1M
169 },
170 {
171 .name = "AT91 NAND partition 5, ext-fs",
172 .offset = 32 * SZ_1M,
173 .size = 32 * SZ_1M
174 }
175};
176
177static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
178{
179 *num_partitions = ARRAY_SIZE(yl9200_nand_partition);
180 return yl9200_nand_partition;
181}
182
183static struct at91_nand_data __initdata yl9200_nand_data = {
184 .ale = 6,
185 .cle = 7,
186 // .det_pin = ... not connected
187 .rdy_pin = AT91_PIN_PC14, /* R/!B (Sheet10) */
188 .enable_pin = AT91_PIN_PC15, /* !CE (Sheet10) */
189 .partition_info = nand_partitions,
190};
191
192/*
193 * NOR Flash
194 */
195#define YL9200_FLASH_BASE AT91_CHIPSELECT_0
196#define YL9200_FLASH_SIZE 0x1000000
197
198static struct mtd_partition yl9200_flash_partitions[] = {
199 {
200 .name = "Bootloader",
201 .size = 0x00040000,
202 .offset = 0,
203 .mask_flags = MTD_WRITEABLE, /* force read-only */
204 },
205 {
206 .name = "Kernel",
207 .size = 0x001C0000,
208 .offset = 0x00040000,
209 },
210 {
211 .name = "Filesystem",
212 .size = MTDPART_SIZ_FULL,
213 .offset = 0x00200000
214 }
215};
216
217static struct physmap_flash_data yl9200_flash_data = {
218 .width = 2,
219 .parts = yl9200_flash_partitions,
220 .nr_parts = ARRAY_SIZE(yl9200_flash_partitions),
221};
222
223static struct resource yl9200_flash_resources[] = {
224 {
225 .start = YL9200_FLASH_BASE,
226 .end = YL9200_FLASH_BASE + YL9200_FLASH_SIZE - 1,
227 .flags = IORESOURCE_MEM,
228 }
229};
230
231static struct platform_device yl9200_flash = {
232 .name = "physmap-flash",
233 .id = 0,
234 .dev = {
235 .platform_data = &yl9200_flash_data,
236 },
237 .resource = yl9200_flash_resources,
238 .num_resources = ARRAY_SIZE(yl9200_flash_resources),
239};
240
241/*
242 * I2C (TWI)
243 */
244static struct i2c_board_info __initdata yl9200_i2c_devices[] = {
245 { /* EEPROM */
246 I2C_BOARD_INFO("24c128", 0x50),
247 }
248};
249
250/*
251 * GPIO Buttons
252*/
253#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
254static struct gpio_keys_button yl9200_buttons[] = {
255 {
256 .gpio = AT91_PIN_PA24,
257 .code = BTN_2,
258 .desc = "SW2",
259 .active_low = 1,
260 .wakeup = 1,
261 },
262 {
263 .gpio = AT91_PIN_PB1,
264 .code = BTN_3,
265 .desc = "SW3",
266 .active_low = 1,
267 .wakeup = 1,
268 },
269 {
270 .gpio = AT91_PIN_PB2,
271 .code = BTN_4,
272 .desc = "SW4",
273 .active_low = 1,
274 .wakeup = 1,
275 },
276 {
277 .gpio = AT91_PIN_PB6,
278 .code = BTN_5,
279 .desc = "SW5",
280 .active_low = 1,
281 .wakeup = 1,
282 }
283};
284
285static struct gpio_keys_platform_data yl9200_button_data = {
286 .buttons = yl9200_buttons,
287 .nbuttons = ARRAY_SIZE(yl9200_buttons),
288};
289
290static struct platform_device yl9200_button_device = {
291 .name = "gpio-keys",
292 .id = -1,
293 .num_resources = 0,
294 .dev = {
295 .platform_data = &yl9200_button_data,
296 }
297};
298
299static void __init yl9200_add_device_buttons(void)
300{
301 at91_set_gpio_input(AT91_PIN_PA24, 1); /* SW2 */
302 at91_set_deglitch(AT91_PIN_PA24, 1);
303 at91_set_gpio_input(AT91_PIN_PB1, 1); /* SW3 */
304 at91_set_deglitch(AT91_PIN_PB1, 1);
305 at91_set_gpio_input(AT91_PIN_PB2, 1); /* SW4 */
306 at91_set_deglitch(AT91_PIN_PB2, 1);
307 at91_set_gpio_input(AT91_PIN_PB6, 1); /* SW5 */
308 at91_set_deglitch(AT91_PIN_PB6, 1);
309
310 /* Enable buttons (Sheet 5) */
311 at91_set_gpio_output(AT91_PIN_PB7, 1);
312
313 platform_device_register(&yl9200_button_device);
314}
315#else
316static void __init yl9200_add_device_buttons(void) {}
317#endif
318
319/*
320 * Touchscreen
321 */
322#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
323static int ads7843_pendown_state(void)
324{
325 return !at91_get_gpio_value(AT91_PIN_PB11); /* Touchscreen PENIRQ */
326}
327
328static struct ads7846_platform_data ads_info = {
329 .model = 7843,
330 .x_min = 150,
331 .x_max = 3830,
332 .y_min = 190,
333 .y_max = 3830,
334 .vref_delay_usecs = 100,
335
336 /* For a 8" touch-screen */
337 // .x_plate_ohms = 603,
338 // .y_plate_ohms = 332,
339
340 /* For a 10.4" touch-screen */
341 // .x_plate_ohms = 611,
342 // .y_plate_ohms = 325,
343
344 .x_plate_ohms = 576,
345 .y_plate_ohms = 366,
346
347 .pressure_max = 15000, /* generally nonsense on the 7843 */
348 .debounce_max = 1,
349 .debounce_rep = 0,
350 .debounce_tol = (~0),
351 .get_pendown_state = ads7843_pendown_state,
352};
353
354static void __init yl9200_add_device_ts(void)
355{
356 at91_set_gpio_input(AT91_PIN_PB11, 1); /* Touchscreen interrupt pin */
357 at91_set_gpio_input(AT91_PIN_PB10, 1); /* Touchscreen BUSY signal - not used! */
358}
359#else
360static void __init yl9200_add_device_ts(void) {}
361#endif
362
363/*
364 * SPI devices
365 */
366static struct spi_board_info yl9200_spi_devices[] = {
367#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
368 { /* Touchscreen */
369 .modalias = "ads7846",
370 .chip_select = 0,
371 .max_speed_hz = 5000 * 26,
372 .platform_data = &ads_info,
373 .irq = AT91_PIN_PB11,
374 },
375#endif
376 { /* CAN */
377 .modalias = "mcp2510",
378 .chip_select = 1,
379 .max_speed_hz = 25000 * 26,
380 .irq = AT91_PIN_PC0,
381 }
382};
383
384/*
385 * LCD / VGA
386 *
387 * EPSON S1D13806 FB (discontinued chip)
388 * EPSON S1D13506 FB
389 */
390#if defined(CONFIG_FB_S1D135XX) || defined(CONFIG_FB_S1D13XXX_MODULE)
391#include <video/s1d13xxxfb.h>
392
393#define AT91_FB_REG_BASE 0x80000000L
394#define AT91_FB_REG_SIZE 0x200
395#define AT91_FB_VMEM_BASE 0x80200000L
396#define AT91_FB_VMEM_SIZE 0x200000L
397
398static void __init yl9200_init_video(void)
399{
400 /* NWAIT Signal */
401 at91_set_A_periph(AT91_PIN_PC6, 0);
402
403 /* Initialization of the Static Memory Controller for Chip Select 2 */
404 at91_sys_write(AT91_SMC_CSR(2), AT91_SMC_DBW_16 /* 16 bit */
405 | AT91_SMC_WSEN | AT91_SMC_NWS_(0x4) /* wait states */
406 | AT91_SMC_TDF_(0x100) /* float time */
407 );
408}
409
410static struct s1d13xxxfb_regval yl9200_s1dfb_initregs[] =
411{
412 {S1DREG_MISC, 0x00}, /* Miscellaneous Register*/
413 {S1DREG_COM_DISP_MODE, 0x01}, /* Display Mode Register, LCD only*/
414 {S1DREG_GPIO_CNF0, 0x00}, /* General IO Pins Configuration Register*/
415 {S1DREG_GPIO_CTL0, 0x00}, /* General IO Pins Control Register*/
416 {S1DREG_CLK_CNF, 0x11}, /* Memory Clock Configuration Register*/
417 {S1DREG_LCD_CLK_CNF, 0x10}, /* LCD Pixel Clock Configuration Register*/
418 {S1DREG_CRT_CLK_CNF, 0x12}, /* CRT/TV Pixel Clock Configuration Register*/
419 {S1DREG_MPLUG_CLK_CNF, 0x01}, /* MediaPlug Clock Configuration Register*/
420 {S1DREG_CPU2MEM_WST_SEL, 0x02}, /* CPU To Memory Wait State Select Register*/
421 {S1DREG_MEM_CNF, 0x00}, /* Memory Configuration Register*/
422 {S1DREG_SDRAM_REF_RATE, 0x04}, /* DRAM Refresh Rate Register, MCLK source*/
423 {S1DREG_SDRAM_TC0, 0x12}, /* DRAM Timings Control Register 0*/
424 {S1DREG_SDRAM_TC1, 0x02}, /* DRAM Timings Control Register 1*/
425 {S1DREG_PANEL_TYPE, 0x25}, /* Panel Type Register*/
426 {S1DREG_MOD_RATE, 0x00}, /* MOD Rate Register*/
427 {S1DREG_LCD_DISP_HWIDTH, 0x4F}, /* LCD Horizontal Display Width Register*/
428 {S1DREG_LCD_NDISP_HPER, 0x13}, /* LCD Horizontal Non-Display Period Register*/
429 {S1DREG_TFT_FPLINE_START, 0x01}, /* TFT FPLINE Start Position Register*/
430 {S1DREG_TFT_FPLINE_PWIDTH, 0x0c}, /* TFT FPLINE Pulse Width Register*/
431 {S1DREG_LCD_DISP_VHEIGHT0, 0xDF}, /* LCD Vertical Display Height Register 0*/
432 {S1DREG_LCD_DISP_VHEIGHT1, 0x01}, /* LCD Vertical Display Height Register 1*/
433 {S1DREG_LCD_NDISP_VPER, 0x2c}, /* LCD Vertical Non-Display Period Register*/
434 {S1DREG_TFT_FPFRAME_START, 0x0a}, /* TFT FPFRAME Start Position Register*/
435 {S1DREG_TFT_FPFRAME_PWIDTH, 0x02}, /* TFT FPFRAME Pulse Width Register*/
436 {S1DREG_LCD_DISP_MODE, 0x05}, /* LCD Display Mode Register*/
437 {S1DREG_LCD_MISC, 0x01}, /* LCD Miscellaneous Register*/
438 {S1DREG_LCD_DISP_START0, 0x00}, /* LCD Display Start Address Register 0*/
439 {S1DREG_LCD_DISP_START1, 0x00}, /* LCD Display Start Address Register 1*/
440 {S1DREG_LCD_DISP_START2, 0x00}, /* LCD Display Start Address Register 2*/
441 {S1DREG_LCD_MEM_OFF0, 0x80}, /* LCD Memory Address Offset Register 0*/
442 {S1DREG_LCD_MEM_OFF1, 0x02}, /* LCD Memory Address Offset Register 1*/
443 {S1DREG_LCD_PIX_PAN, 0x03}, /* LCD Pixel Panning Register*/
444 {S1DREG_LCD_DISP_FIFO_HTC, 0x00}, /* LCD Display FIFO High Threshold Control Register*/
445 {S1DREG_LCD_DISP_FIFO_LTC, 0x00}, /* LCD Display FIFO Low Threshold Control Register*/
446 {S1DREG_CRT_DISP_HWIDTH, 0x4F}, /* CRT/TV Horizontal Display Width Register*/
447 {S1DREG_CRT_NDISP_HPER, 0x13}, /* CRT/TV Horizontal Non-Display Period Register*/
448 {S1DREG_CRT_HRTC_START, 0x01}, /* CRT/TV HRTC Start Position Register*/
449 {S1DREG_CRT_HRTC_PWIDTH, 0x0B}, /* CRT/TV HRTC Pulse Width Register*/
450 {S1DREG_CRT_DISP_VHEIGHT0, 0xDF}, /* CRT/TV Vertical Display Height Register 0*/
451 {S1DREG_CRT_DISP_VHEIGHT1, 0x01}, /* CRT/TV Vertical Display Height Register 1*/
452 {S1DREG_CRT_NDISP_VPER, 0x2B}, /* CRT/TV Vertical Non-Display Period Register*/
453 {S1DREG_CRT_VRTC_START, 0x09}, /* CRT/TV VRTC Start Position Register*/
454 {S1DREG_CRT_VRTC_PWIDTH, 0x01}, /* CRT/TV VRTC Pulse Width Register*/
455 {S1DREG_TV_OUT_CTL, 0x18}, /* TV Output Control Register */
456 {S1DREG_CRT_DISP_MODE, 0x05}, /* CRT/TV Display Mode Register, 16BPP*/
457 {S1DREG_CRT_DISP_START0, 0x00}, /* CRT/TV Display Start Address Register 0*/
458 {S1DREG_CRT_DISP_START1, 0x00}, /* CRT/TV Display Start Address Register 1*/
459 {S1DREG_CRT_DISP_START2, 0x00}, /* CRT/TV Display Start Address Register 2*/
460 {S1DREG_CRT_MEM_OFF0, 0x80}, /* CRT/TV Memory Address Offset Register 0*/
461 {S1DREG_CRT_MEM_OFF1, 0x02}, /* CRT/TV Memory Address Offset Register 1*/
462 {S1DREG_CRT_PIX_PAN, 0x00}, /* CRT/TV Pixel Panning Register*/
463 {S1DREG_CRT_DISP_FIFO_HTC, 0x00}, /* CRT/TV Display FIFO High Threshold Control Register*/
464 {S1DREG_CRT_DISP_FIFO_LTC, 0x00}, /* CRT/TV Display FIFO Low Threshold Control Register*/
465 {S1DREG_LCD_CUR_CTL, 0x00}, /* LCD Ink/Cursor Control Register*/
466 {S1DREG_LCD_CUR_START, 0x01}, /* LCD Ink/Cursor Start Address Register*/
467 {S1DREG_LCD_CUR_XPOS0, 0x00}, /* LCD Cursor X Position Register 0*/
468 {S1DREG_LCD_CUR_XPOS1, 0x00}, /* LCD Cursor X Position Register 1*/
469 {S1DREG_LCD_CUR_YPOS0, 0x00}, /* LCD Cursor Y Position Register 0*/
470 {S1DREG_LCD_CUR_YPOS1, 0x00}, /* LCD Cursor Y Position Register 1*/
471 {S1DREG_LCD_CUR_BCTL0, 0x00}, /* LCD Ink/Cursor Blue Color 0 Register*/
472 {S1DREG_LCD_CUR_GCTL0, 0x00}, /* LCD Ink/Cursor Green Color 0 Register*/
473 {S1DREG_LCD_CUR_RCTL0, 0x00}, /* LCD Ink/Cursor Red Color 0 Register*/
474 {S1DREG_LCD_CUR_BCTL1, 0x1F}, /* LCD Ink/Cursor Blue Color 1 Register*/
475 {S1DREG_LCD_CUR_GCTL1, 0x3F}, /* LCD Ink/Cursor Green Color 1 Register*/
476 {S1DREG_LCD_CUR_RCTL1, 0x1F}, /* LCD Ink/Cursor Red Color 1 Register*/
477 {S1DREG_LCD_CUR_FIFO_HTC, 0x00}, /* LCD Ink/Cursor FIFO Threshold Register*/
478 {S1DREG_CRT_CUR_CTL, 0x00}, /* CRT/TV Ink/Cursor Control Register*/
479 {S1DREG_CRT_CUR_START, 0x01}, /* CRT/TV Ink/Cursor Start Address Register*/
480 {S1DREG_CRT_CUR_XPOS0, 0x00}, /* CRT/TV Cursor X Position Register 0*/
481 {S1DREG_CRT_CUR_XPOS1, 0x00}, /* CRT/TV Cursor X Position Register 1*/
482 {S1DREG_CRT_CUR_YPOS0, 0x00}, /* CRT/TV Cursor Y Position Register 0*/
483 {S1DREG_CRT_CUR_YPOS1, 0x00}, /* CRT/TV Cursor Y Position Register 1*/
484 {S1DREG_CRT_CUR_BCTL0, 0x00}, /* CRT/TV Ink/Cursor Blue Color 0 Register*/
485 {S1DREG_CRT_CUR_GCTL0, 0x00}, /* CRT/TV Ink/Cursor Green Color 0 Register*/
486 {S1DREG_CRT_CUR_RCTL0, 0x00}, /* CRT/TV Ink/Cursor Red Color 0 Register*/
487 {S1DREG_CRT_CUR_BCTL1, 0x1F}, /* CRT/TV Ink/Cursor Blue Color 1 Register*/
488 {S1DREG_CRT_CUR_GCTL1, 0x3F}, /* CRT/TV Ink/Cursor Green Color 1 Register*/
489 {S1DREG_CRT_CUR_RCTL1, 0x1F}, /* CRT/TV Ink/Cursor Red Color 1 Register*/
490 {S1DREG_CRT_CUR_FIFO_HTC, 0x00}, /* CRT/TV Ink/Cursor FIFO Threshold Register*/
491 {S1DREG_BBLT_CTL0, 0x00}, /* BitBlt Control Register 0*/
492 {S1DREG_BBLT_CTL1, 0x01}, /* BitBlt Control Register 1*/
493 {S1DREG_BBLT_CC_EXP, 0x00}, /* BitBlt ROP Code/Color Expansion Register*/
494 {S1DREG_BBLT_OP, 0x00}, /* BitBlt Operation Register*/
495 {S1DREG_BBLT_SRC_START0, 0x00}, /* BitBlt Source Start Address Register 0*/
496 {S1DREG_BBLT_SRC_START1, 0x00}, /* BitBlt Source Start Address Register 1*/
497 {S1DREG_BBLT_SRC_START2, 0x00}, /* BitBlt Source Start Address Register 2*/
498 {S1DREG_BBLT_DST_START0, 0x00}, /* BitBlt Destination Start Address Register 0*/
499 {S1DREG_BBLT_DST_START1, 0x00}, /* BitBlt Destination Start Address Register 1*/
500 {S1DREG_BBLT_DST_START2, 0x00}, /* BitBlt Destination Start Address Register 2*/
501 {S1DREG_BBLT_MEM_OFF0, 0x00}, /* BitBlt Memory Address Offset Register 0*/
502 {S1DREG_BBLT_MEM_OFF1, 0x00}, /* BitBlt Memory Address Offset Register 1*/
503 {S1DREG_BBLT_WIDTH0, 0x00}, /* BitBlt Width Register 0*/
504 {S1DREG_BBLT_WIDTH1, 0x00}, /* BitBlt Width Register 1*/
505 {S1DREG_BBLT_HEIGHT0, 0x00}, /* BitBlt Height Register 0*/
506 {S1DREG_BBLT_HEIGHT1, 0x00}, /* BitBlt Height Register 1*/
507 {S1DREG_BBLT_BGC0, 0x00}, /* BitBlt Background Color Register 0*/
508 {S1DREG_BBLT_BGC1, 0x00}, /* BitBlt Background Color Register 1*/
509 {S1DREG_BBLT_FGC0, 0x00}, /* BitBlt Foreground Color Register 0*/
510 {S1DREG_BBLT_FGC1, 0x00}, /* BitBlt Foreground Color Register 1*/
511 {S1DREG_LKUP_MODE, 0x00}, /* Look-Up Table Mode Register*/
512 {S1DREG_LKUP_ADDR, 0x00}, /* Look-Up Table Address Register*/
513 {S1DREG_PS_CNF, 0x00}, /* Power Save Configuration Register*/
514 {S1DREG_PS_STATUS, 0x00}, /* Power Save Status Register*/
515 {S1DREG_CPU2MEM_WDOGT, 0x00}, /* CPU-to-Memory Access Watchdog Timer Register*/
516 {S1DREG_COM_DISP_MODE, 0x01}, /* Display Mode Register, LCD only*/
517};
518
519static u64 s1dfb_dmamask = DMA_BIT_MASK(32);
520
521static struct s1d13xxxfb_pdata yl9200_s1dfb_pdata = {
522 .initregs = yl9200_s1dfb_initregs,
523 .initregssize = ARRAY_SIZE(yl9200_s1dfb_initregs),
524 .platform_init_video = yl9200_init_video,
525};
526
527static struct resource yl9200_s1dfb_resource[] = {
528 [0] = { /* video mem */
529 .name = "s1d13xxxfb memory",
530 .start = AT91_FB_VMEM_BASE,
531 .end = AT91_FB_VMEM_BASE + AT91_FB_VMEM_SIZE -1,
532 .flags = IORESOURCE_MEM,
533 },
534 [1] = { /* video registers */
535 .name = "s1d13xxxfb registers",
536 .start = AT91_FB_REG_BASE,
537 .end = AT91_FB_REG_BASE + AT91_FB_REG_SIZE -1,
538 .flags = IORESOURCE_MEM,
539 },
540};
541
542static struct platform_device yl9200_s1dfb_device = {
543 .name = "s1d13806fb",
544 .id = -1,
545 .dev = {
546 .dma_mask = &s1dfb_dmamask,
547 .coherent_dma_mask = DMA_BIT_MASK(32),
548 .platform_data = &yl9200_s1dfb_pdata,
549 },
550 .resource = yl9200_s1dfb_resource,
551 .num_resources = ARRAY_SIZE(yl9200_s1dfb_resource),
552};
553
554void __init yl9200_add_device_video(void)
555{
556 platform_device_register(&yl9200_s1dfb_device);
557}
558#else
559void __init yl9200_add_device_video(void) {}
560#endif
561
562
563static void __init yl9200_board_init(void)
564{
565 /* Serial */
566 at91_add_device_serial();
567 /* Ethernet */
568 at91_add_device_eth(&yl9200_eth_data);
569 /* USB Host */
570 at91_add_device_usbh(&yl9200_usbh_data);
571 /* USB Device */
572 at91_add_device_udc(&yl9200_udc_data);
573 /* I2C */
574 at91_add_device_i2c(yl9200_i2c_devices, ARRAY_SIZE(yl9200_i2c_devices));
575 /* MMC */
576 at91_add_device_mmc(0, &yl9200_mmc_data);
577 /* NAND */
578 at91_add_device_nand(&yl9200_nand_data);
579 /* NOR Flash */
580 platform_device_register(&yl9200_flash);
581#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
582 /* SPI */
583 at91_add_device_spi(yl9200_spi_devices, ARRAY_SIZE(yl9200_spi_devices));
584 /* Touchscreen */
585 yl9200_add_device_ts();
586#endif
587 /* LEDs. */
588 at91_gpio_leds(yl9200_leds, ARRAY_SIZE(yl9200_leds));
589 /* Push Buttons */
590 yl9200_add_device_buttons();
591 /* VGA */
592 yl9200_add_device_video();
593}
594
595MACHINE_START(YL9200, "uCdragon YL-9200")
596 /* Maintainer: S.Birtles */
597 .phys_io = AT91_BASE_SYS,
598 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
599 .boot_params = AT91_SDRAM_BASE + 0x100,
600 .timer = &at91rm9200_timer,
601 .map_io = yl9200_map_io,
602 .init_irq = yl9200_init_irq,
603 .init_machine = yl9200_board_init,
604MACHINE_END
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index de6424e9ac02..464bdbbf74df 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -23,7 +23,6 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/clk.h> 24#include <linux/clk.h>
25 25
26#include <asm/semaphore.h>
27#include <asm/io.h> 26#include <asm/io.h>
28#include <asm/mach-types.h> 27#include <asm/mach-types.h>
29 28
@@ -113,12 +112,34 @@ static void pmc_sys_mode(struct clk *clk, int is_on)
113 at91_sys_write(AT91_PMC_SCDR, clk->pmc_mask); 112 at91_sys_write(AT91_PMC_SCDR, clk->pmc_mask);
114} 113}
115 114
115static void pmc_uckr_mode(struct clk *clk, int is_on)
116{
117 unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR);
118
119 if (is_on) {
120 is_on = AT91_PMC_LOCKU;
121 at91_sys_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask);
122 } else
123 at91_sys_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask));
124
125 do {
126 cpu_relax();
127 } while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on);
128}
129
116/* USB function clocks (PLLB must be 48 MHz) */ 130/* USB function clocks (PLLB must be 48 MHz) */
117static struct clk udpck = { 131static struct clk udpck = {
118 .name = "udpck", 132 .name = "udpck",
119 .parent = &pllb, 133 .parent = &pllb,
120 .mode = pmc_sys_mode, 134 .mode = pmc_sys_mode,
121}; 135};
136static struct clk utmi_clk = {
137 .name = "utmi_clk",
138 .parent = &main_clk,
139 .pmc_mask = AT91_PMC_UPLLEN, /* in CKGR_UCKR */
140 .mode = pmc_uckr_mode,
141 .type = CLK_TYPE_PLL,
142};
122static struct clk uhpck = { 143static struct clk uhpck = {
123 .name = "uhpck", 144 .name = "uhpck",
124 .parent = &pllb, 145 .parent = &pllb,
@@ -362,7 +383,7 @@ static void __init init_programmable_clock(struct clk *clk)
362 383
363static int at91_clk_show(struct seq_file *s, void *unused) 384static int at91_clk_show(struct seq_file *s, void *unused)
364{ 385{
365 u32 scsr, pcsr, sr; 386 u32 scsr, pcsr, uckr = 0, sr;
366 struct clk *clk; 387 struct clk *clk;
367 388
368 seq_printf(s, "SCSR = %8x\n", scsr = at91_sys_read(AT91_PMC_SCSR)); 389 seq_printf(s, "SCSR = %8x\n", scsr = at91_sys_read(AT91_PMC_SCSR));
@@ -370,7 +391,10 @@ static int at91_clk_show(struct seq_file *s, void *unused)
370 seq_printf(s, "MOR = %8x\n", at91_sys_read(AT91_CKGR_MOR)); 391 seq_printf(s, "MOR = %8x\n", at91_sys_read(AT91_CKGR_MOR));
371 seq_printf(s, "MCFR = %8x\n", at91_sys_read(AT91_CKGR_MCFR)); 392 seq_printf(s, "MCFR = %8x\n", at91_sys_read(AT91_CKGR_MCFR));
372 seq_printf(s, "PLLA = %8x\n", at91_sys_read(AT91_CKGR_PLLAR)); 393 seq_printf(s, "PLLA = %8x\n", at91_sys_read(AT91_CKGR_PLLAR));
373 seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR)); 394 if (!cpu_is_at91sam9rl())
395 seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR));
396 if (cpu_is_at91cap9() || cpu_is_at91sam9rl())
397 seq_printf(s, "UCKR = %8x\n", uckr = at91_sys_read(AT91_CKGR_UCKR));
374 seq_printf(s, "MCKR = %8x\n", at91_sys_read(AT91_PMC_MCKR)); 398 seq_printf(s, "MCKR = %8x\n", at91_sys_read(AT91_PMC_MCKR));
375 seq_printf(s, "SR = %8x\n", sr = at91_sys_read(AT91_PMC_SR)); 399 seq_printf(s, "SR = %8x\n", sr = at91_sys_read(AT91_PMC_SR));
376 400
@@ -383,6 +407,8 @@ static int at91_clk_show(struct seq_file *s, void *unused)
383 state = (scsr & clk->pmc_mask) ? "on" : "off"; 407 state = (scsr & clk->pmc_mask) ? "on" : "off";
384 else if (clk->mode == pmc_periph_mode) 408 else if (clk->mode == pmc_periph_mode)
385 state = (pcsr & clk->pmc_mask) ? "on" : "off"; 409 state = (pcsr & clk->pmc_mask) ? "on" : "off";
410 else if (clk->mode == pmc_uckr_mode)
411 state = (uckr & clk->pmc_mask) ? "on" : "off";
386 else if (clk->pmc_mask) 412 else if (clk->pmc_mask)
387 state = (sr & clk->pmc_mask) ? "on" : "off"; 413 state = (sr & clk->pmc_mask) ? "on" : "off";
388 else if (clk == &clk32k || clk == &main_clk) 414 else if (clk == &clk32k || clk == &main_clk)
@@ -489,14 +515,19 @@ static unsigned __init at91_pll_calc(unsigned main_freq, unsigned out_freq)
489 /* 515 /*
490 * PLL input between 1MHz and 32MHz per spec, but lower 516 * PLL input between 1MHz and 32MHz per spec, but lower
491 * frequences seem necessary in some cases so allow 100K. 517 * frequences seem necessary in some cases so allow 100K.
518 * Warning: some newer products need 2MHz min.
492 */ 519 */
493 input = main_freq / i; 520 input = main_freq / i;
521 if (cpu_is_at91sam9g20() && input < 2000000)
522 continue;
494 if (input < 100000) 523 if (input < 100000)
495 continue; 524 continue;
496 if (input > 32000000) 525 if (input > 32000000)
497 continue; 526 continue;
498 527
499 mul1 = out_freq / input; 528 mul1 = out_freq / input;
529 if (cpu_is_at91sam9g20() && mul > 63)
530 continue;
500 if (mul1 > 2048) 531 if (mul1 > 2048)
501 continue; 532 continue;
502 if (mul1 < 2) 533 if (mul1 < 2)
@@ -556,7 +587,8 @@ int __init at91_clock_init(unsigned long main_clock)
556 587
557 /* report if PLLA is more than mildly overclocked */ 588 /* report if PLLA is more than mildly overclocked */
558 plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_sys_read(AT91_CKGR_PLLAR)); 589 plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_sys_read(AT91_CKGR_PLLAR));
559 if (plla.rate_hz > 209000000) 590 if ((!cpu_is_at91sam9g20() && plla.rate_hz > 209000000)
591 || (cpu_is_at91sam9g20() && plla.rate_hz > 800000000))
560 pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000); 592 pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000);
561 593
562 /* 594 /*
@@ -571,7 +603,7 @@ int __init at91_clock_init(unsigned long main_clock)
571 uhpck.pmc_mask = AT91RM9200_PMC_UHP; 603 uhpck.pmc_mask = AT91RM9200_PMC_UHP;
572 udpck.pmc_mask = AT91RM9200_PMC_UDP; 604 udpck.pmc_mask = AT91RM9200_PMC_UDP;
573 at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP); 605 at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP);
574 } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263()) { 606 } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) {
575 uhpck.pmc_mask = AT91SAM926x_PMC_UHP; 607 uhpck.pmc_mask = AT91SAM926x_PMC_UHP;
576 udpck.pmc_mask = AT91SAM926x_PMC_UDP; 608 udpck.pmc_mask = AT91SAM926x_PMC_UDP;
577 } else if (cpu_is_at91cap9()) { 609 } else if (cpu_is_at91cap9()) {
@@ -583,6 +615,17 @@ int __init at91_clock_init(unsigned long main_clock)
583 uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init); 615 uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
584 616
585 /* 617 /*
618 * USB HS clock init
619 */
620 if (cpu_is_at91cap9() || cpu_is_at91sam9rl()) {
621 /*
622 * multiplier is hard-wired to 40
623 * (obtain the USB High Speed 480 MHz when input is 12 MHz)
624 */
625 utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz;
626 }
627
628 /*
586 * MCK and CPU derive from one of those primary clocks. 629 * MCK and CPU derive from one of those primary clocks.
587 * For now, assume this parentage won't change. 630 * For now, assume this parentage won't change.
588 */ 631 */
@@ -592,13 +635,21 @@ int __init at91_clock_init(unsigned long main_clock)
592 freq /= (1 << ((mckr & AT91_PMC_PRES) >> 2)); /* prescale */ 635 freq /= (1 << ((mckr & AT91_PMC_PRES) >> 2)); /* prescale */
593 if (cpu_is_at91rm9200()) 636 if (cpu_is_at91rm9200())
594 mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 637 mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */
595 else 638 else if (cpu_is_at91sam9g20()) {
596 mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 639 mck.rate_hz = (mckr & AT91_PMC_MDIV) ?
640 freq / ((mckr & AT91_PMC_MDIV) >> 7) : freq; /* mdiv ; (x >> 7) = ((x >> 8) * 2) */
641 if (mckr & AT91_PMC_PDIV)
642 freq /= 2; /* processor clock division */
643 } else
644 mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */
597 645
598 /* Register the PMC's standard clocks */ 646 /* Register the PMC's standard clocks */
599 for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++) 647 for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++)
600 list_add_tail(&standard_pmc_clocks[i]->node, &clocks); 648 list_add_tail(&standard_pmc_clocks[i]->node, &clocks);
601 649
650 if (cpu_is_at91cap9() || cpu_is_at91sam9rl())
651 list_add_tail(&utmi_clk.node, &clocks);
652
602 /* MCK and CPU clock are "always on" */ 653 /* MCK and CPU clock are "always on" */
603 clk_enable(&mck); 654 clk_enable(&mck);
604 655
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index a67defd50438..8ab4feb1ec5b 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -26,12 +26,139 @@
26#include <asm/mach-types.h> 26#include <asm/mach-types.h>
27 27
28#include <asm/arch/at91_pmc.h> 28#include <asm/arch/at91_pmc.h>
29#include <asm/arch/at91rm9200_mc.h>
30#include <asm/arch/gpio.h> 29#include <asm/arch/gpio.h>
31#include <asm/arch/cpu.h> 30#include <asm/arch/cpu.h>
32 31
33#include "generic.h" 32#include "generic.h"
34 33
34#ifdef CONFIG_ARCH_AT91RM9200
35#include <asm/arch/at91rm9200_mc.h>
36
37/*
38 * The AT91RM9200 goes into self-refresh mode with this command, and will
39 * terminate self-refresh automatically on the next SDRAM access.
40 */
41#define sdram_selfrefresh_enable() at91_sys_write(AT91_SDRAMC_SRR, 1)
42#define sdram_selfrefresh_disable() do {} while (0)
43
44#elif defined(CONFIG_ARCH_AT91CAP9)
45#include <asm/arch/at91cap9_ddrsdr.h>
46
47static u32 saved_lpr;
48
49static inline void sdram_selfrefresh_enable(void)
50{
51 u32 lpr;
52
53 saved_lpr = at91_sys_read(AT91_DDRSDRC_LPR);
54
55 lpr = saved_lpr & ~AT91_DDRSDRC_LPCB;
56 at91_sys_write(AT91_DDRSDRC_LPR, lpr | AT91_DDRSDRC_LPCB_SELF_REFRESH);
57}
58
59#define sdram_selfrefresh_disable() at91_sys_write(AT91_DDRSDRC_LPR, saved_lpr)
60
61#else
62#include <asm/arch/at91sam9_sdramc.h>
63
64#ifdef CONFIG_ARCH_AT91SAM9263
65/*
66 * FIXME either or both the SDRAM controllers (EB0, EB1) might be in use;
67 * handle those cases both here and in the Suspend-To-RAM support.
68 */
69#define AT91_SDRAMC AT91_SDRAMC0
70#warning Assuming EB1 SDRAM controller is *NOT* used
71#endif
72
73static u32 saved_lpr;
74
75static inline void sdram_selfrefresh_enable(void)
76{
77 u32 lpr;
78
79 saved_lpr = at91_sys_read(AT91_SDRAMC_LPR);
80
81 lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
82 at91_sys_write(AT91_SDRAMC_LPR, lpr | AT91_SDRAMC_LPCB_SELF_REFRESH);
83}
84
85#define sdram_selfrefresh_disable() at91_sys_write(AT91_SDRAMC_LPR, saved_lpr)
86
87#endif
88
89
90/*
91 * Show the reason for the previous system reset.
92 */
93#if defined(AT91_SHDWC)
94
95#include <asm/arch/at91_rstc.h>
96#include <asm/arch/at91_shdwc.h>
97
98static void __init show_reset_status(void)
99{
100 static char reset[] __initdata = "reset";
101
102 static char general[] __initdata = "general";
103 static char wakeup[] __initdata = "wakeup";
104 static char watchdog[] __initdata = "watchdog";
105 static char software[] __initdata = "software";
106 static char user[] __initdata = "user";
107 static char unknown[] __initdata = "unknown";
108
109 static char signal[] __initdata = "signal";
110 static char rtc[] __initdata = "rtc";
111 static char rtt[] __initdata = "rtt";
112 static char restore[] __initdata = "power-restored";
113
114 char *reason, *r2 = reset;
115 u32 reset_type, wake_type;
116
117 reset_type = at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_RSTTYP;
118 wake_type = at91_sys_read(AT91_SHDW_SR);
119
120 switch (reset_type) {
121 case AT91_RSTC_RSTTYP_GENERAL:
122 reason = general;
123 break;
124 case AT91_RSTC_RSTTYP_WAKEUP:
125 /* board-specific code enabled the wakeup sources */
126 reason = wakeup;
127
128 /* "wakeup signal" */
129 if (wake_type & AT91_SHDW_WAKEUP0)
130 r2 = signal;
131 else {
132 r2 = reason;
133 if (wake_type & AT91_SHDW_RTTWK) /* rtt wakeup */
134 reason = rtt;
135 else if (wake_type & AT91_SHDW_RTCWK) /* rtc wakeup */
136 reason = rtc;
137 else if (wake_type == 0) /* power-restored wakeup */
138 reason = restore;
139 else /* unknown wakeup */
140 reason = unknown;
141 }
142 break;
143 case AT91_RSTC_RSTTYP_WATCHDOG:
144 reason = watchdog;
145 break;
146 case AT91_RSTC_RSTTYP_SOFTWARE:
147 reason = software;
148 break;
149 case AT91_RSTC_RSTTYP_USER:
150 reason = user;
151 break;
152 default:
153 reason = unknown;
154 break;
155 }
156 pr_info("AT91: Starting after %s %s\n", reason, r2);
157}
158#else
159static void __init show_reset_status(void) {}
160#endif
161
35 162
36static int at91_pm_valid_state(suspend_state_t state) 163static int at91_pm_valid_state(suspend_state_t state)
37{ 164{
@@ -75,7 +202,7 @@ static int at91_pm_verify_clocks(void)
75 pr_debug("AT91: PM - Suspend-to-RAM with USB still active\n"); 202 pr_debug("AT91: PM - Suspend-to-RAM with USB still active\n");
76 return 0; 203 return 0;
77 } 204 }
78 } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263()) { 205 } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || cpu_is_at91sam9263() || cpu_is_at91sam9g20()) {
79 if ((scsr & (AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP)) != 0) { 206 if ((scsr & (AT91SAM926x_PMC_UHP | AT91SAM926x_PMC_UDP)) != 0) {
80 pr_debug("AT91: PM - Suspend-to-RAM with USB still active\n"); 207 pr_debug("AT91: PM - Suspend-to-RAM with USB still active\n");
81 return 0; 208 return 0;
@@ -125,6 +252,11 @@ EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
125 252
126static void (*slow_clock)(void); 253static void (*slow_clock)(void);
127 254
255#ifdef CONFIG_AT91_SLOW_CLOCK
256extern void at91_slow_clock(void);
257extern u32 at91_slow_clock_sz;
258#endif
259
128 260
129static int at91_pm_enter(suspend_state_t state) 261static int at91_pm_enter(suspend_state_t state)
130{ 262{
@@ -158,11 +290,14 @@ static int at91_pm_enter(suspend_state_t state)
158 * turning off the main oscillator; reverse on wakeup. 290 * turning off the main oscillator; reverse on wakeup.
159 */ 291 */
160 if (slow_clock) { 292 if (slow_clock) {
293#ifdef CONFIG_AT91_SLOW_CLOCK
294 /* copy slow_clock handler to SRAM, and call it */
295 memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
296#endif
161 slow_clock(); 297 slow_clock();
162 break; 298 break;
163 } else { 299 } else {
164 /* DEVELOPMENT ONLY */ 300 pr_info("AT91: PM - no slow clock mode enabled ...\n");
165 pr_info("AT91: PM - no slow clock mode yet ...\n");
166 /* FALLTHROUGH leaving master clock alone */ 301 /* FALLTHROUGH leaving master clock alone */
167 } 302 }
168 303
@@ -175,13 +310,15 @@ static int at91_pm_enter(suspend_state_t state)
175 case PM_SUSPEND_STANDBY: 310 case PM_SUSPEND_STANDBY:
176 /* 311 /*
177 * NOTE: the Wait-for-Interrupt instruction needs to be 312 * NOTE: the Wait-for-Interrupt instruction needs to be
178 * in icache so the SDRAM stays in self-refresh mode until 313 * in icache so no SDRAM accesses are needed until the
179 * the wakeup IRQ occurs. 314 * wakeup IRQ occurs and self-refresh is terminated.
180 */ 315 */
181 asm("b 1f; .align 5; 1:"); 316 asm("b 1f; .align 5; 1:");
182 asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */ 317 asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */
183 at91_sys_write(AT91_SDRAMC_SRR, 1); /* self-refresh mode */ 318 sdram_selfrefresh_enable();
184 /* fall though to next state */ 319 asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */
320 sdram_selfrefresh_disable();
321 break;
185 322
186 case PM_SUSPEND_ON: 323 case PM_SUSPEND_ON:
187 asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */ 324 asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */
@@ -196,6 +333,7 @@ static int at91_pm_enter(suspend_state_t state)
196 at91_sys_read(AT91_AIC_IPR) & at91_sys_read(AT91_AIC_IMR)); 333 at91_sys_read(AT91_AIC_IPR) & at91_sys_read(AT91_AIC_IMR));
197 334
198error: 335error:
336 sdram_selfrefresh_disable();
199 target_state = PM_SUSPEND_ON; 337 target_state = PM_SUSPEND_ON;
200 at91_irq_resume(); 338 at91_irq_resume();
201 at91_gpio_resume(); 339 at91_gpio_resume();
@@ -220,21 +358,20 @@ static struct platform_suspend_ops at91_pm_ops ={
220 358
221static int __init at91_pm_init(void) 359static int __init at91_pm_init(void)
222{ 360{
223 printk("AT91: Power Management\n"); 361#ifdef CONFIG_AT91_SLOW_CLOCK
224 362 slow_clock = (void *) (AT91_IO_VIRT_BASE - at91_slow_clock_sz);
225#ifdef CONFIG_AT91_PM_SLOW_CLOCK
226 /* REVISIT allocations of SRAM should be dynamically managed.
227 * FIQ handlers and other components will want SRAM/TCM too...
228 */
229 slow_clock = (void *) (AT91_VA_BASE_SRAM + (3 * SZ_4K));
230 memcpy(slow_clock, at91rm9200_slow_clock, at91rm9200_slow_clock_sz);
231#endif 363#endif
232 364
233 /* Disable SDRAM low-power mode. Cannot be used with self-refresh. */ 365 pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
366
367#ifdef CONFIG_ARCH_AT91RM9200
368 /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
234 at91_sys_write(AT91_SDRAMC_LPR, 0); 369 at91_sys_write(AT91_SDRAMC_LPR, 0);
370#endif
235 371
236 suspend_set_ops(&at91_pm_ops); 372 suspend_set_ops(&at91_pm_ops);
237 373
374 show_reset_status();
238 return 0; 375 return 0;
239} 376}
240arch_initcall(at91_pm_init); 377arch_initcall(at91_pm_init);