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/Kconfig33
-rw-r--r--arch/arm/mach-at91/Makefile3
-rw-r--r--arch/arm/mach-at91/at91cap9.c9
-rw-r--r--arch/arm/mach-at91/at91cap9_devices.c70
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c92
-rw-r--r--arch/arm/mach-at91/at91sam9260.c8
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c159
-rw-r--r--arch/arm/mach-at91/at91sam9261.c8
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c102
-rw-r--r--arch/arm/mach-at91/at91sam9263.c8
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c98
-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.c117
-rw-r--r--arch/arm/mach-at91/board-cam60.c180
-rw-r--r--arch/arm/mach-at91/board-cap9adk.c2
-rw-r--r--arch/arm/mach-at91/board-csb337.c18
-rw-r--r--arch/arm/mach-at91/board-csb637.c30
-rw-r--r--arch/arm/mach-at91/board-ecbat91.c178
-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-sam9rlek.c23
-rwxr-xr-xarch/arm/mach-at91/board-yl-9200.c683
-rw-r--r--arch/arm/mach-at91/pm.c165
26 files changed, 2183 insertions, 372 deletions
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 074dcd5d9a7e..0fc07b6db749 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -12,18 +12,28 @@ 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
24 32
25config ARCH_AT91CAP9 33config ARCH_AT91CAP9
26 bool "AT91CAP9" 34 bool "AT91CAP9"
35 select GENERIC_TIME
36 select GENERIC_CLOCKEVENTS
27 37
28config ARCH_AT91X40 38config ARCH_AT91X40
29 bool "AT91x40" 39 bool "AT91x40"
@@ -109,6 +119,13 @@ config MACH_KAFA
109 help 119 help
110 Select this if you are using Sperry-Sun's KAFA board. 120 Select this if you are using Sperry-Sun's KAFA board.
111 121
122config MACH_ECBAT91
123 bool "emQbit ECB_AT91 SBC"
124 depends on ARCH_AT91RM9200
125 help
126 Select this if you are using emQbit's ECB_AT91 board.
127 <http://wiki.emqbit.com/free-ecb-at91>
128
112endif 129endif
113 130
114# ---------------------------------------------------------- 131# ----------------------------------------------------------
@@ -133,6 +150,20 @@ config MACH_AT91SAM9260EK
133 Select this if you are using Atmel's AT91SAM9260-EK or AT91SAM9XE Evaluation Kit 150 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> 151 <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=3933>
135 152
153config MACH_CAM60
154 bool "KwikByte KB9260 (CAM60) board"
155 depends on ARCH_AT91SAM9260
156 help
157 Select this if you are using KwikByte's KB9260 (CAM60) board based on the Atmel AT91SAM9260.
158 <http://www.kwikbyte.com/KB9260.html>
159
160config MACH_SAM9_L9260
161 bool "Olimex SAM9-L9260 board"
162 depends on ARCH_AT91SAM9260
163 help
164 Select this if you are using Olimex's SAM9-L9260 board based on the Atmel AT91SAM9260.
165 <http://www.olimex.com/dev/sam9-L9260.html>
166
136endif 167endif
137 168
138# ---------------------------------------------------------- 169# ----------------------------------------------------------
@@ -216,7 +247,7 @@ comment "AT91 Board Options"
216 247
217config MTD_AT91_DATAFLASH_CARD 248config MTD_AT91_DATAFLASH_CARD
218 bool "Enable DataFlash Card support" 249 bool "Enable DataFlash Card support"
219 depends on (ARCH_AT91RM9200DK || MACH_AT91RM9200EK || MACH_AT91SAM9260EK || MACH_AT91SAM9261EK || MACH_AT91SAM9263EK || MACH_AT91CAP9ADK) 250 depends on (ARCH_AT91RM9200DK || MACH_AT91RM9200EK || MACH_AT91SAM9260EK || MACH_AT91SAM9261EK || MACH_AT91SAM9263EK || MACH_AT91CAP9ADK || MACH_SAM9_L9260 || MACH_ECBAT91)
220 help 251 help
221 Enable support for the DataFlash card. 252 Enable support for the DataFlash card.
222 253
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index bf5f293dccf8..8d9bc0153b18 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -29,9 +29,12 @@ obj-$(CONFIG_MACH_KB9200) += board-kb9202.o
29obj-$(CONFIG_MACH_ATEB9200) += board-eb9200.o 29obj-$(CONFIG_MACH_ATEB9200) += board-eb9200.o
30obj-$(CONFIG_MACH_KAFA) += board-kafa.o 30obj-$(CONFIG_MACH_KAFA) += board-kafa.o
31obj-$(CONFIG_MACH_PICOTUX2XX) += board-picotux200.o 31obj-$(CONFIG_MACH_PICOTUX2XX) += board-picotux200.o
32obj-$(CONFIG_MACH_ECBAT91) += board-ecbat91.o
32 33
33# AT91SAM9260 board-specific support 34# AT91SAM9260 board-specific support
34obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o 35obj-$(CONFIG_MACH_AT91SAM9260EK) += board-sam9260ek.o
36obj-$(CONFIG_MACH_CAM60) += board-cam60.o
37obj-$(CONFIG_MACH_SAM9_L9260) += board-sam9-l9260.o
35 38
36# AT91SAM9261 board-specific support 39# AT91SAM9261 board-specific support
37obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o 40obj-$(CONFIG_MACH_AT91SAM9261EK) += board-sam9261ek.o
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..f1a80d74a4b6 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
@@ -283,10 +283,15 @@ static struct at91_nand_data nand_data;
283#define NAND_BASE AT91_CHIPSELECT_3 283#define NAND_BASE AT91_CHIPSELECT_3
284 284
285static struct resource nand_resources[] = { 285static struct resource nand_resources[] = {
286 { 286 [0] = {
287 .start = NAND_BASE, 287 .start = NAND_BASE,
288 .end = NAND_BASE + SZ_256M - 1, 288 .end = NAND_BASE + SZ_256M - 1,
289 .flags = IORESOURCE_MEM, 289 .flags = IORESOURCE_MEM,
290 },
291 [1] = {
292 .start = AT91_BASE_SYS + AT91_ECC,
293 .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
294 .flags = IORESOURCE_MEM,
290 } 295 }
291}; 296};
292 297
@@ -344,6 +349,7 @@ void __init at91_add_device_nand(struct at91_nand_data *data)
344void __init at91_add_device_nand(struct at91_nand_data *data) {} 349void __init at91_add_device_nand(struct at91_nand_data *data) {}
345#endif 350#endif
346 351
352
347/* -------------------------------------------------------------------- 353/* --------------------------------------------------------------------
348 * TWI (i2c) 354 * TWI (i2c)
349 * -------------------------------------------------------------------- */ 355 * -------------------------------------------------------------------- */
@@ -532,13 +538,59 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
532 538
533 539
534/* -------------------------------------------------------------------- 540/* --------------------------------------------------------------------
541 * Timer/Counter block
542 * -------------------------------------------------------------------- */
543
544#ifdef CONFIG_ATMEL_TCLIB
545
546static struct resource tcb_resources[] = {
547 [0] = {
548 .start = AT91CAP9_BASE_TCB0,
549 .end = AT91CAP9_BASE_TCB0 + SZ_16K - 1,
550 .flags = IORESOURCE_MEM,
551 },
552 [1] = {
553 .start = AT91CAP9_ID_TCB,
554 .end = AT91CAP9_ID_TCB,
555 .flags = IORESOURCE_IRQ,
556 },
557};
558
559static struct platform_device at91cap9_tcb_device = {
560 .name = "atmel_tcb",
561 .id = 0,
562 .resource = tcb_resources,
563 .num_resources = ARRAY_SIZE(tcb_resources),
564};
565
566static void __init at91_add_device_tc(void)
567{
568 /* this chip has one clock and irq for all three TC channels */
569 at91_clock_associate("tcb_clk", &at91cap9_tcb_device.dev, "t0_clk");
570 platform_device_register(&at91cap9_tcb_device);
571}
572#else
573static void __init at91_add_device_tc(void) { }
574#endif
575
576
577/* --------------------------------------------------------------------
535 * RTT 578 * RTT
536 * -------------------------------------------------------------------- */ 579 * -------------------------------------------------------------------- */
537 580
581static struct resource rtt_resources[] = {
582 {
583 .start = AT91_BASE_SYS + AT91_RTT,
584 .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
585 .flags = IORESOURCE_MEM,
586 }
587};
588
538static struct platform_device at91cap9_rtt_device = { 589static struct platform_device at91cap9_rtt_device = {
539 .name = "at91_rtt", 590 .name = "at91_rtt",
540 .id = -1, 591 .id = 0,
541 .num_resources = 0, 592 .resource = rtt_resources,
593 .num_resources = ARRAY_SIZE(rtt_resources),
542}; 594};
543 595
544static void __init at91_add_device_rtt(void) 596static void __init at91_add_device_rtt(void)
@@ -990,7 +1042,7 @@ static inline void configure_usart2_pins(unsigned pins)
990 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */ 1042 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
991} 1043}
992 1044
993static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1045static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
994struct platform_device *atmel_default_console_device; /* the serial console device */ 1046struct platform_device *atmel_default_console_device; /* the serial console device */
995 1047
996void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1048void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
@@ -1031,8 +1083,6 @@ void __init at91_set_serial_console(unsigned portnr)
1031{ 1083{
1032 if (portnr < ATMEL_MAX_UART) 1084 if (portnr < ATMEL_MAX_UART)
1033 atmel_default_console_device = at91_uarts[portnr]; 1085 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} 1086}
1037 1087
1038void __init at91_add_device_serial(void) 1088void __init at91_add_device_serial(void)
@@ -1043,6 +1093,9 @@ void __init at91_add_device_serial(void)
1043 if (at91_uarts[i]) 1093 if (at91_uarts[i])
1044 platform_device_register(at91_uarts[i]); 1094 platform_device_register(at91_uarts[i]);
1045 } 1095 }
1096
1097 if (!atmel_default_console_device)
1098 printk(KERN_INFO "AT91: No default serial console defined.\n");
1046} 1099}
1047#else 1100#else
1048void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1101void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
@@ -1060,6 +1113,7 @@ static int __init at91_add_standard_devices(void)
1060{ 1113{
1061 at91_add_device_rtt(); 1114 at91_add_device_rtt();
1062 at91_add_device_watchdog(); 1115 at91_add_device_watchdog();
1116 at91_add_device_tc();
1063 return 0; 1117 return 0;
1064} 1118}
1065 1119
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..ee26550cdc21 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"
@@ -267,6 +269,11 @@ static void at91sam9260_reset(void)
267 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST); 269 at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_PROCRST | AT91_RSTC_PERRST);
268} 270}
269 271
272static void at91sam9260_poweroff(void)
273{
274 at91_sys_write(AT91_SHDW_CR, AT91_SHDW_KEY | AT91_SHDW_SHDW);
275}
276
270 277
271/* -------------------------------------------------------------------- 278/* --------------------------------------------------------------------
272 * AT91SAM9260 processor initialization 279 * AT91SAM9260 processor initialization
@@ -304,6 +311,7 @@ void __init at91sam9260_initialize(unsigned long main_clock)
304 iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc)); 311 iotable_init(at91sam9260_sram_desc, ARRAY_SIZE(at91sam9260_sram_desc));
305 312
306 at91_arch_reset = at91sam9260_reset; 313 at91_arch_reset = at91sam9260_reset;
314 pm_power_off = at91sam9260_poweroff;
307 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1) 315 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1)
308 | (1 << AT91SAM9260_ID_IRQ2); 316 | (1 << AT91SAM9260_ID_IRQ2);
309 317
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 105f8403860b..393a32aefce5 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -19,8 +19,8 @@
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/at91sam9260.h> 21#include <asm/arch/at91sam9260.h>
22#include <asm/arch/at91sam926x_mc.h>
23#include <asm/arch/at91sam9260_matrix.h> 22#include <asm/arch/at91sam9260_matrix.h>
23#include <asm/arch/at91sam9_smc.h>
24 24
25#include "generic.h" 25#include "generic.h"
26 26
@@ -288,10 +288,15 @@ static struct at91_nand_data nand_data;
288#define NAND_BASE AT91_CHIPSELECT_3 288#define NAND_BASE AT91_CHIPSELECT_3
289 289
290static struct resource nand_resources[] = { 290static struct resource nand_resources[] = {
291 { 291 [0] = {
292 .start = NAND_BASE, 292 .start = NAND_BASE,
293 .end = NAND_BASE + SZ_256M - 1, 293 .end = NAND_BASE + SZ_256M - 1,
294 .flags = IORESOURCE_MEM, 294 .flags = IORESOURCE_MEM,
295 },
296 [1] = {
297 .start = AT91_BASE_SYS + AT91_ECC,
298 .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
299 .flags = IORESOURCE_MEM,
295 } 300 }
296}; 301};
297 302
@@ -540,6 +545,90 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
540 545
541 546
542/* -------------------------------------------------------------------- 547/* --------------------------------------------------------------------
548 * Timer/Counter blocks
549 * -------------------------------------------------------------------- */
550
551#ifdef CONFIG_ATMEL_TCLIB
552
553static struct resource tcb0_resources[] = {
554 [0] = {
555 .start = AT91SAM9260_BASE_TCB0,
556 .end = AT91SAM9260_BASE_TCB0 + SZ_16K - 1,
557 .flags = IORESOURCE_MEM,
558 },
559 [1] = {
560 .start = AT91SAM9260_ID_TC0,
561 .end = AT91SAM9260_ID_TC0,
562 .flags = IORESOURCE_IRQ,
563 },
564 [2] = {
565 .start = AT91SAM9260_ID_TC1,
566 .end = AT91SAM9260_ID_TC1,
567 .flags = IORESOURCE_IRQ,
568 },
569 [3] = {
570 .start = AT91SAM9260_ID_TC2,
571 .end = AT91SAM9260_ID_TC2,
572 .flags = IORESOURCE_IRQ,
573 },
574};
575
576static struct platform_device at91sam9260_tcb0_device = {
577 .name = "atmel_tcb",
578 .id = 0,
579 .resource = tcb0_resources,
580 .num_resources = ARRAY_SIZE(tcb0_resources),
581};
582
583static struct resource tcb1_resources[] = {
584 [0] = {
585 .start = AT91SAM9260_BASE_TCB1,
586 .end = AT91SAM9260_BASE_TCB1 + SZ_16K - 1,
587 .flags = IORESOURCE_MEM,
588 },
589 [1] = {
590 .start = AT91SAM9260_ID_TC3,
591 .end = AT91SAM9260_ID_TC3,
592 .flags = IORESOURCE_IRQ,
593 },
594 [2] = {
595 .start = AT91SAM9260_ID_TC4,
596 .end = AT91SAM9260_ID_TC4,
597 .flags = IORESOURCE_IRQ,
598 },
599 [3] = {
600 .start = AT91SAM9260_ID_TC5,
601 .end = AT91SAM9260_ID_TC5,
602 .flags = IORESOURCE_IRQ,
603 },
604};
605
606static struct platform_device at91sam9260_tcb1_device = {
607 .name = "atmel_tcb",
608 .id = 1,
609 .resource = tcb1_resources,
610 .num_resources = ARRAY_SIZE(tcb1_resources),
611};
612
613static void __init at91_add_device_tc(void)
614{
615 /* this chip has a separate clock and irq for each TC channel */
616 at91_clock_associate("tc0_clk", &at91sam9260_tcb0_device.dev, "t0_clk");
617 at91_clock_associate("tc1_clk", &at91sam9260_tcb0_device.dev, "t1_clk");
618 at91_clock_associate("tc2_clk", &at91sam9260_tcb0_device.dev, "t2_clk");
619 platform_device_register(&at91sam9260_tcb0_device);
620
621 at91_clock_associate("tc3_clk", &at91sam9260_tcb1_device.dev, "t0_clk");
622 at91_clock_associate("tc4_clk", &at91sam9260_tcb1_device.dev, "t1_clk");
623 at91_clock_associate("tc5_clk", &at91sam9260_tcb1_device.dev, "t2_clk");
624 platform_device_register(&at91sam9260_tcb1_device);
625}
626#else
627static void __init at91_add_device_tc(void) { }
628#endif
629
630
631/* --------------------------------------------------------------------
543 * RTT 632 * RTT
544 * -------------------------------------------------------------------- */ 633 * -------------------------------------------------------------------- */
545 634
@@ -553,7 +642,7 @@ static struct resource rtt_resources[] = {
553 642
554static struct platform_device at91sam9260_rtt_device = { 643static struct platform_device at91sam9260_rtt_device = {
555 .name = "at91_rtt", 644 .name = "at91_rtt",
556 .id = -1, 645 .id = 0,
557 .resource = rtt_resources, 646 .resource = rtt_resources,
558 .num_resources = ARRAY_SIZE(rtt_resources), 647 .num_resources = ARRAY_SIZE(rtt_resources),
559}; 648};
@@ -962,64 +1051,9 @@ static inline void configure_usart5_pins(void)
962 at91_set_A_periph(AT91_PIN_PB13, 0); /* RXD5 */ 1051 at91_set_A_periph(AT91_PIN_PB13, 0); /* RXD5 */
963} 1052}
964 1053
965static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1054static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
966struct platform_device *atmel_default_console_device; /* the serial console device */ 1055struct platform_device *atmel_default_console_device; /* the serial console device */
967 1056
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) 1057void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1024{ 1058{
1025 struct platform_device *pdev; 1059 struct platform_device *pdev;
@@ -1073,8 +1107,6 @@ void __init at91_set_serial_console(unsigned portnr)
1073{ 1107{
1074 if (portnr < ATMEL_MAX_UART) 1108 if (portnr < ATMEL_MAX_UART)
1075 atmel_default_console_device = at91_uarts[portnr]; 1109 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} 1110}
1079 1111
1080void __init at91_add_device_serial(void) 1112void __init at91_add_device_serial(void)
@@ -1085,9 +1117,11 @@ void __init at91_add_device_serial(void)
1085 if (at91_uarts[i]) 1117 if (at91_uarts[i])
1086 platform_device_register(at91_uarts[i]); 1118 platform_device_register(at91_uarts[i]);
1087 } 1119 }
1120
1121 if (!atmel_default_console_device)
1122 printk(KERN_INFO "AT91: No default serial console defined.\n");
1088} 1123}
1089#else 1124#else
1090void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
1091void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1125void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1092void __init at91_set_serial_console(unsigned portnr) {} 1126void __init at91_set_serial_console(unsigned portnr) {}
1093void __init at91_add_device_serial(void) {} 1127void __init at91_add_device_serial(void) {}
@@ -1103,6 +1137,7 @@ static int __init at91_add_standard_devices(void)
1103{ 1137{
1104 at91_add_device_rtt(); 1138 at91_add_device_rtt();
1105 at91_add_device_watchdog(); 1139 at91_add_device_watchdog();
1140 at91_add_device_tc();
1106 return 0; 1141 return 0;
1107} 1142}
1108 1143
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..37cd547855b1 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
@@ -548,6 +548,55 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
548 548
549 549
550/* -------------------------------------------------------------------- 550/* --------------------------------------------------------------------
551 * Timer/Counter block
552 * -------------------------------------------------------------------- */
553
554#ifdef CONFIG_ATMEL_TCLIB
555
556static struct resource tcb_resources[] = {
557 [0] = {
558 .start = AT91SAM9261_BASE_TCB0,
559 .end = AT91SAM9261_BASE_TCB0 + SZ_16K - 1,
560 .flags = IORESOURCE_MEM,
561 },
562 [1] = {
563 .start = AT91SAM9261_ID_TC0,
564 .end = AT91SAM9261_ID_TC0,
565 .flags = IORESOURCE_IRQ,
566 },
567 [2] = {
568 .start = AT91SAM9261_ID_TC1,
569 .end = AT91SAM9261_ID_TC1,
570 .flags = IORESOURCE_IRQ,
571 },
572 [3] = {
573 .start = AT91SAM9261_ID_TC2,
574 .end = AT91SAM9261_ID_TC2,
575 .flags = IORESOURCE_IRQ,
576 },
577};
578
579static struct platform_device at91sam9261_tcb_device = {
580 .name = "atmel_tcb",
581 .id = 0,
582 .resource = tcb_resources,
583 .num_resources = ARRAY_SIZE(tcb_resources),
584};
585
586static void __init at91_add_device_tc(void)
587{
588 /* this chip has a separate clock and irq for each TC channel */
589 at91_clock_associate("tc0_clk", &at91sam9261_tcb_device.dev, "t0_clk");
590 at91_clock_associate("tc1_clk", &at91sam9261_tcb_device.dev, "t1_clk");
591 at91_clock_associate("tc2_clk", &at91sam9261_tcb_device.dev, "t2_clk");
592 platform_device_register(&at91sam9261_tcb_device);
593}
594#else
595static void __init at91_add_device_tc(void) { }
596#endif
597
598
599/* --------------------------------------------------------------------
551 * RTT 600 * RTT
552 * -------------------------------------------------------------------- */ 601 * -------------------------------------------------------------------- */
553 602
@@ -561,7 +610,7 @@ static struct resource rtt_resources[] = {
561 610
562static struct platform_device at91sam9261_rtt_device = { 611static struct platform_device at91sam9261_rtt_device = {
563 .name = "at91_rtt", 612 .name = "at91_rtt",
564 .id = -1, 613 .id = 0,
565 .resource = rtt_resources, 614 .resource = rtt_resources,
566 .num_resources = ARRAY_SIZE(rtt_resources), 615 .num_resources = ARRAY_SIZE(rtt_resources),
567}; 616};
@@ -938,49 +987,9 @@ static inline void configure_usart2_pins(unsigned pins)
938 at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */ 987 at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */
939} 988}
940 989
941static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 990static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
942struct platform_device *atmel_default_console_device; /* the serial console device */ 991struct platform_device *atmel_default_console_device; /* the serial console device */
943 992
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) 993void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
985{ 994{
986 struct platform_device *pdev; 995 struct platform_device *pdev;
@@ -1019,8 +1028,6 @@ void __init at91_set_serial_console(unsigned portnr)
1019{ 1028{
1020 if (portnr < ATMEL_MAX_UART) 1029 if (portnr < ATMEL_MAX_UART)
1021 atmel_default_console_device = at91_uarts[portnr]; 1030 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} 1031}
1025 1032
1026void __init at91_add_device_serial(void) 1033void __init at91_add_device_serial(void)
@@ -1031,9 +1038,11 @@ void __init at91_add_device_serial(void)
1031 if (at91_uarts[i]) 1038 if (at91_uarts[i])
1032 platform_device_register(at91_uarts[i]); 1039 platform_device_register(at91_uarts[i]);
1033 } 1040 }
1041
1042 if (!atmel_default_console_device)
1043 printk(KERN_INFO "AT91: No default serial console defined.\n");
1034} 1044}
1035#else 1045#else
1036void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
1037void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 1046void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1038void __init at91_set_serial_console(unsigned portnr) {} 1047void __init at91_set_serial_console(unsigned portnr) {}
1039void __init at91_add_device_serial(void) {} 1048void __init at91_add_device_serial(void) {}
@@ -1050,6 +1059,7 @@ static int __init at91_add_standard_devices(void)
1050{ 1059{
1051 at91_add_device_rtt(); 1060 at91_add_device_rtt();
1052 at91_add_device_watchdog(); 1061 at91_add_device_watchdog();
1062 at91_add_device_tc();
1053 return 0; 1063 return 0;
1054} 1064}
1055 1065
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..b6454c525962 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
@@ -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
@@ -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..dbb9a5fc2090 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -20,7 +20,7 @@
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
@@ -105,10 +105,15 @@ static struct at91_nand_data nand_data;
105#define NAND_BASE AT91_CHIPSELECT_3 105#define NAND_BASE AT91_CHIPSELECT_3
106 106
107static struct resource nand_resources[] = { 107static struct resource nand_resources[] = {
108 { 108 [0] = {
109 .start = NAND_BASE, 109 .start = NAND_BASE,
110 .end = NAND_BASE + SZ_256M - 1, 110 .end = NAND_BASE + SZ_256M - 1,
111 .flags = IORESOURCE_MEM, 111 .flags = IORESOURCE_MEM,
112 },
113 [1] = {
114 .start = AT91_BASE_SYS + AT91_ECC,
115 .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
116 .flags = IORESOURCE_MEM,
112 } 117 }
113}; 118};
114 119
@@ -385,6 +390,55 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
385 390
386 391
387/* -------------------------------------------------------------------- 392/* --------------------------------------------------------------------
393 * Timer/Counter block
394 * -------------------------------------------------------------------- */
395
396#ifdef CONFIG_ATMEL_TCLIB
397
398static struct resource tcb_resources[] = {
399 [0] = {
400 .start = AT91SAM9RL_BASE_TCB0,
401 .end = AT91SAM9RL_BASE_TCB0 + SZ_16K - 1,
402 .flags = IORESOURCE_MEM,
403 },
404 [1] = {
405 .start = AT91SAM9RL_ID_TC0,
406 .end = AT91SAM9RL_ID_TC0,
407 .flags = IORESOURCE_IRQ,
408 },
409 [2] = {
410 .start = AT91SAM9RL_ID_TC1,
411 .end = AT91SAM9RL_ID_TC1,
412 .flags = IORESOURCE_IRQ,
413 },
414 [3] = {
415 .start = AT91SAM9RL_ID_TC2,
416 .end = AT91SAM9RL_ID_TC2,
417 .flags = IORESOURCE_IRQ,
418 },
419};
420
421static struct platform_device at91sam9rl_tcb_device = {
422 .name = "atmel_tcb",
423 .id = 0,
424 .resource = tcb_resources,
425 .num_resources = ARRAY_SIZE(tcb_resources),
426};
427
428static void __init at91_add_device_tc(void)
429{
430 /* this chip has a separate clock and irq for each TC channel */
431 at91_clock_associate("tc0_clk", &at91sam9rl_tcb_device.dev, "t0_clk");
432 at91_clock_associate("tc1_clk", &at91sam9rl_tcb_device.dev, "t1_clk");
433 at91_clock_associate("tc2_clk", &at91sam9rl_tcb_device.dev, "t2_clk");
434 platform_device_register(&at91sam9rl_tcb_device);
435}
436#else
437static void __init at91_add_device_tc(void) { }
438#endif
439
440
441/* --------------------------------------------------------------------
388 * RTC 442 * RTC
389 * -------------------------------------------------------------------- */ 443 * -------------------------------------------------------------------- */
390 444
@@ -418,7 +472,7 @@ static struct resource rtt_resources[] = {
418 472
419static struct platform_device at91sam9rl_rtt_device = { 473static struct platform_device at91sam9rl_rtt_device = {
420 .name = "at91_rtt", 474 .name = "at91_rtt",
421 .id = -1, 475 .id = 0,
422 .resource = rtt_resources, 476 .resource = rtt_resources,
423 .num_resources = ARRAY_SIZE(rtt_resources), 477 .num_resources = ARRAY_SIZE(rtt_resources),
424}; 478};
@@ -539,9 +593,6 @@ static inline void configure_ssc1_pins(unsigned pins)
539} 593}
540 594
541/* 595/*
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 596 * SSC controllers are accessed through library code, instead of any
546 * kind of all-singing/all-dancing driver. For example one could be 597 * 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 598 * used by a particular I2S audio codec's driver, while another one
@@ -802,54 +853,9 @@ static inline void configure_usart3_pins(unsigned pins)
802 at91_set_B_periph(AT91_PIN_PD3, 0); /* CTS3 */ 853 at91_set_B_periph(AT91_PIN_PD3, 0); /* CTS3 */
803} 854}
804 855
805static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 856static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
806struct platform_device *atmel_default_console_device; /* the serial console device */ 857struct platform_device *atmel_default_console_device; /* the serial console device */
807 858
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) 859void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
854{ 860{
855 struct platform_device *pdev; 861 struct platform_device *pdev;
@@ -893,8 +899,6 @@ void __init at91_set_serial_console(unsigned portnr)
893{ 899{
894 if (portnr < ATMEL_MAX_UART) 900 if (portnr < ATMEL_MAX_UART)
895 atmel_default_console_device = at91_uarts[portnr]; 901 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} 902}
899 903
900void __init at91_add_device_serial(void) 904void __init at91_add_device_serial(void)
@@ -905,9 +909,11 @@ void __init at91_add_device_serial(void)
905 if (at91_uarts[i]) 909 if (at91_uarts[i])
906 platform_device_register(at91_uarts[i]); 910 platform_device_register(at91_uarts[i]);
907 } 911 }
912
913 if (!atmel_default_console_device)
914 printk(KERN_INFO "AT91: No default serial console defined.\n");
908} 915}
909#else 916#else
910void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
911void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} 917void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
912void __init at91_set_serial_console(unsigned portnr) {} 918void __init at91_set_serial_console(unsigned portnr) {}
913void __init at91_add_device_serial(void) {} 919void __init at91_add_device_serial(void) {}
@@ -925,6 +931,7 @@ static int __init at91_add_standard_devices(void)
925 at91_add_device_rtc(); 931 at91_add_device_rtc();
926 at91_add_device_rtt(); 932 at91_add_device_rtt();
927 at91_add_device_watchdog(); 933 at91_add_device_watchdog();
934 at91_add_device_tc();
928 return 0; 935 return 0;
929} 936}
930 937
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..e5512d1ff217 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
diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
index 0e2a11fc5bbd..26fea4dcc3a0 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)
diff --git a/arch/arm/mach-at91/board-csb637.c b/arch/arm/mach-at91/board-csb637.c
index c5c721d27f42..419fd19b620b 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 */
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 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-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-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-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index bc0546d7245f..ffc0597aee8d 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)
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..b5717108991d
--- /dev/null
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -0,0 +1,683 @@
1/*
2 * linux/arch/arm/mach-at91/board-yl-9200.c
3 *
4 * Adapted from:
5 *various board files in
6 * /arch/arm/mach-at91
7 * modifications to convert to YL-9200 platform
8 * Copyright (C) 2007 S.Birtles
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25#include <linux/types.h>
26#include <linux/init.h>
27#include <linux/mm.h>
28#include <linux/module.h>
29#include <linux/platform_device.h>
30#include <linux/spi/spi.h>
31/*#include <linux/can_bus/candata.h>*/
32#include <linux/spi/ads7846.h>
33#include <linux/mtd/physmap.h>
34
35/*#include <sound/gpio_sounder.h>*/
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#include <linux/gpio_keys.h>
49#include <linux/input.h>
50
51#include "generic.h"
52#include <asm/arch/at91_pio.h>
53
54#define YL_9200_FLASH_BASE AT91_CHIPSELECT_0
55#define YL_9200_FLASH_SIZE 0x800000
56
57/*
58 * Serial port configuration.
59 * 0 .. 3 = USART0 .. USART3
60 * 4 = DBGU
61 *atmel_usart.0: ttyS0 at MMIO 0xfefff200 (irq = 1) is a ATMEL_SERIAL
62 *atmel_usart.1: ttyS1 at MMIO 0xfffc0000 (irq = 6) is a ATMEL_SERIAL
63 *atmel_usart.2: ttyS2 at MMIO 0xfffc4000 (irq = 7) is a ATMEL_SERIAL
64 *atmel_usart.3: ttyS3 at MMIO 0xfffc8000 (irq = 8) is a ATMEL_SERIAL
65 *atmel_usart.4: ttyS4 at MMIO 0xfffcc000 (irq = 9) is a ATMEL_SERIAL
66 * on the YL-9200 we are sitting at the following
67 *ttyS0 at MMIO 0xfefff200 (irq = 1) is a AT91_SERIAL
68 *ttyS1 at MMIO 0xfefc4000 (irq = 7) is a AT91_SERIAL
69 */
70
71/* extern void __init yl_9200_add_device_sounder(struct gpio_sounder *sounders, int nr);*/
72
73static struct at91_uart_config __initdata yl_9200_uart_config = {
74 .console_tty = 0, /* ttyS0 */
75 .nr_tty = 3,
76 .tty_map = { 4, 1, 0, -1, -1 } /* ttyS0, ..., ttyS4 */
77};
78
79static void __init yl_9200_map_io(void)
80{
81 /* Initialize processor: 18.432 MHz crystal */
82 /*Also initialises register clocks & gpio*/
83 at91rm9200_initialize(18432000, AT91RM9200_PQFP); /*we have a 3 bank system*/
84
85 /* Setup the serial ports and console */
86 at91_init_serial(&yl_9200_uart_config);
87
88 /* Setup the LEDs D2=PB17,D3=PB16 */
89 at91_init_leds(AT91_PIN_PB16,AT91_PIN_PB17); /*cpu-led,timer-led*/
90}
91
92static void __init yl_9200_init_irq(void)
93{
94 at91rm9200_init_interrupts(NULL);
95}
96
97static struct at91_eth_data __initdata yl_9200_eth_data = {
98 .phy_irq_pin = AT91_PIN_PB28,
99 .is_rmii = 1,
100};
101
102static struct at91_usbh_data __initdata yl_9200_usbh_data = {
103 .ports = 1, /* this should be 1 not 2 for the Yl9200*/
104};
105
106static struct at91_udc_data __initdata yl_9200_udc_data = {
107/*on sheet 7 Schemitic rev 1.0*/
108 .pullup_pin = AT91_PIN_PC4,
109 .vbus_pin= AT91_PIN_PC5,
110 .pullup_active_low = 1, /*ACTIVE LOW!! due to PNP transistor on page 7*/
111
112};
113/*
114static struct at91_cf_data __initdata yl_9200_cf_data = {
115TODO S.BIRTLES
116 .det_pin = AT91_PIN_xxx,
117 .rst_pin = AT91_PIN_xxx,
118 .irq_pin = ... not connected
119 .vcc_pin = ... always powered
120
121};
122*/
123static struct at91_mmc_data __initdata yl_9200_mmc_data = {
124 .det_pin = AT91_PIN_PB9, /*THIS LOOKS CORRECT SHEET7*/
125/* .wp_pin = ... not connected SHEET7*/
126 .slot_b = 0,
127 .wire4 = 1,
128
129};
130
131/* --------------------------------------------------------------------
132 * Touch screen
133 * -------------------------------------------------------------------- */
134#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
135static int ads7843_pendown_state(void)
136{
137 return !at91_get_gpio_value(AT91_PIN_PB11); /* Touchscreen PENIRQ */
138}
139
140static void __init at91_init_device_ts(void)
141{
142/*IMPORTANT NOTE THE SPI INTERFACE IS ALREADY CONFIGURED BY XXX_DEVICES.C
143THAT IS TO SAY THAT MISO,MOSI,SPCK AND CS are already configured
144we only need to enable the other datapins which are:
145PB10/RK1 BUSY
146*/
147/* Touchscreen BUSY signal , pin,use pullup ( TODO not currently used in the ADS7843/6.c driver)*/
148at91_set_gpio_input(AT91_PIN_PB10, 1);
149}
150
151#else
152static void __init at91_init_device_ts(void) {}
153#endif
154
155static struct ads7846_platform_data ads_info = {
156 .model = 7843,
157 .x_min = 150,
158 .x_max = 3830,
159 .y_min = 190,
160 .y_max = 3830,
161 .vref_delay_usecs = 100,
162/* for a 8" touch screen*/
163 //.x_plate_ohms = 603, //= 450, S.Birtles TODO
164 //.y_plate_ohms = 332, //= 250, S.Birtles TODO
165/*for a 10.4" touch screen*/
166 //.x_plate_ohms =611,
167 //.y_plate_ohms =325,
168
169 .x_plate_ohms = 576,
170 .y_plate_ohms = 366,
171 //
172 .pressure_max = 15000, /*generally nonsense on the 7843*/
173 /*number of times to send query to chip in a given run 0 equals one time (do not set to 0!! ,there is a bug in ADS 7846 code)*/
174 .debounce_max = 1,
175 .debounce_rep = 0,
176 .debounce_tol = (~0),
177 .get_pendown_state = ads7843_pendown_state,
178};
179
180/*static struct canbus_platform_data can_info = {
181 .model = 2510,
182};
183*/
184
185static struct spi_board_info yl_9200_spi_devices[] = {
186/*this sticks it at:
187 /sys/devices/platform/atmel_spi.0/spi0.0
188 /sys/bus/platform/devices/
189Documentation/spi IIRC*/
190
191#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
192 /*(this IS correct 04-NOV-2007)*/
193 {
194 .modalias = "ads7846", /* because the driver is called ads7846*/
195 .chip_select = 0, /*THIS MUST BE AN INDEX INTO AN ARRAY OF pins */
196/*this is ONLY TO BE USED if chipselect above is not used, it passes a pin directly for the chip select*/
197 /*.controller_data =AT91_PIN_PA3 ,*/
198 .max_speed_hz = 5000*26, /*(4700 * 26)-125000 * 26, (max sample rate @ 3V) * (cmd + data + overhead) */
199 .bus_num = 0,
200 .platform_data = &ads_info,
201 .irq = AT91_PIN_PB11,
202 },
203#endif
204/*we need to put our CAN driver data here!!*/
205/*THIS IS ALL DUMMY DATA*/
206/* {
207 .modalias = "mcp2510", //DUMMY for MCP2510 chip
208 .chip_select = 1,*/ /*THIS MUST BE AN INDEX INTO AN ARRAY OF pins */
209 /*this is ONLY TO BE USED if chipselect above is not used, it passes a pin directly for the chip select */
210 /* .controller_data =AT91_PIN_PA4 ,
211 .max_speed_hz = 25000 * 26,
212 .bus_num = 0,
213 .platform_data = &can_info,
214 .irq = AT91_PIN_PC0,
215 },
216 */
217 //max SPI chip needs to go here
218};
219
220static struct mtd_partition __initdata yl_9200_nand_partition[] = {
221 {
222 .name = "AT91 NAND partition 1, boot",
223 .offset = 0,
224 .size = 1 * SZ_256K
225 },
226 {
227 .name = "AT91 NAND partition 2, kernel",
228 .offset = 1 * SZ_256K,
229 .size = 2 * SZ_1M - 1 * SZ_256K
230 },
231 {
232 .name = "AT91 NAND partition 3, filesystem",
233 .offset = 2 * SZ_1M,
234 .size = 14 * SZ_1M
235 },
236 {
237 .name = "AT91 NAND partition 4, storage",
238 .offset = 16 * SZ_1M,
239 .size = 16 * SZ_1M
240 },
241 {
242 .name = "AT91 NAND partition 5, ext-fs",
243 .offset = 32 * SZ_1M,
244 .size = 32 * SZ_1M
245 },
246};
247
248static struct mtd_partition * __init nand_partitions(int size, int *num_partitions)
249{
250 *num_partitions = ARRAY_SIZE(yl_9200_nand_partition);
251 return yl_9200_nand_partition;
252}
253
254static struct at91_nand_data __initdata yl_9200_nand_data = {
255 .ale= 6,
256 .cle= 7,
257 /*.det_pin = AT91_PIN_PCxx,*/ /*we don't have a det pin because NandFlash is fixed to board*/
258 .rdy_pin = AT91_PIN_PC14, /*R/!B Sheet10*/
259 .enable_pin = AT91_PIN_PC15, /*!CE Sheet10 */
260 .partition_info = nand_partitions,
261};
262
263
264
265/*
266TODO S.Birtles
267potentially a problem with the size above
268physmap platform flash device: 00800000 at 10000000
269physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank
270NOR chip too large to fit in mapping. Attempting to cope...
271 Intel/Sharp Extended Query Table at 0x0031
272Using buffer write method
273cfi_cmdset_0001: Erase suspend on write enabled
274Reducing visibility of 16384KiB chip to 8192KiB
275*/
276
277static struct mtd_partition yl_9200_flash_partitions[] = {
278 {
279 .name = "Bootloader",
280 .size = 0x00040000,
281 .offset = 0,
282 .mask_flags = MTD_WRITEABLE /* force read-only */
283 },{
284 .name = "Kernel",
285 .size = 0x001C0000,
286 .offset = 0x00040000,
287 },{
288 .name = "Filesystem",
289 .size = MTDPART_SIZ_FULL,
290 .offset = 0x00200000
291 }
292
293};
294
295static struct physmap_flash_data yl_9200_flash_data = {
296 .width = 2,
297 .parts = yl_9200_flash_partitions,
298 .nr_parts = ARRAY_SIZE(yl_9200_flash_partitions),
299};
300
301static struct resource yl_9200_flash_resources[] = {
302{
303 .start = YL_9200_FLASH_BASE,
304 .end = YL_9200_FLASH_BASE + YL_9200_FLASH_SIZE - 1,
305 .flags = IORESOURCE_MEM,
306 }
307};
308
309static struct platform_device yl_9200_flash = {
310 .name = "physmap-flash",
311 .id = 0,
312 .dev = {
313 .platform_data = &yl_9200_flash_data,
314 },
315 .resource = yl_9200_flash_resources,
316 .num_resources = ARRAY_SIZE(yl_9200_flash_resources),
317};
318
319
320static struct gpio_led yl_9200_leds[] = {
321/*D2 &D3 are passed directly in via at91_init_leds*/
322 {
323 .name = "led4", /*D4*/
324 .gpio = AT91_PIN_PB15,
325 .active_low = 1,
326 .default_trigger = "heartbeat",
327 /*.default_trigger = "timer",*/
328 },
329 {
330 .name = "led5", /*D5*/
331 .gpio = AT91_PIN_PB8,
332 .active_low = 1,
333 .default_trigger = "heartbeat",
334 }
335};
336
337//static struct gpio_sounder yl_9200_sounder[] = {*/
338/*This is a simple speaker attached to a gpo line*/
339
340// {
341// .name = "Speaker", /*LS1*/
342// .gpio = AT91_PIN_PA22,
343// .active_low = 0,
344// .default_trigger = "heartbeat",
345 /*.default_trigger = "timer",*/
346// },
347//};
348
349
350
351static struct i2c_board_info __initdata yl_9200_i2c_devices[] = {
352 {
353 /*TODO*/
354 I2C_BOARD_INFO("CS4334", 0x00),
355 }
356};
357
358
359 /*
360 * GPIO Buttons
361 */
362#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
363static struct gpio_keys_button yl_9200_buttons[] = {
364 {
365 .gpio = AT91_PIN_PA24,
366 .code = BTN_2,
367 .desc = "SW2",
368 .active_low = 1,
369 .wakeup = 1,
370 },
371 {
372 .gpio = AT91_PIN_PB1,
373 .code = BTN_3,
374 .desc = "SW3",
375 .active_low = 1,
376 .wakeup = 1,
377 },
378 {
379 .gpio = AT91_PIN_PB2,
380 .code = BTN_4,
381 .desc = "SW4",
382 .active_low = 1,
383 .wakeup = 1,
384 },
385 {
386 .gpio = AT91_PIN_PB6,
387 .code = BTN_5,
388 .desc = "SW5",
389 .active_low = 1,
390 .wakeup = 1,
391 },
392
393};
394
395static struct gpio_keys_platform_data yl_9200_button_data = {
396 .buttons = yl_9200_buttons,
397 .nbuttons = ARRAY_SIZE(yl_9200_buttons),
398};
399
400static struct platform_device yl_9200_button_device = {
401 .name = "gpio-keys",
402 .id = -1,
403 .num_resources = 0,
404 .dev = {
405 .platform_data = &yl_9200_button_data,
406 }
407};
408
409static void __init yl_9200_add_device_buttons(void)
410{
411 //SW2
412 at91_set_gpio_input(AT91_PIN_PA24, 0);
413 at91_set_deglitch(AT91_PIN_PA24, 1);
414
415 //SW3
416 at91_set_gpio_input(AT91_PIN_PB1, 0);
417 at91_set_deglitch(AT91_PIN_PB1, 1);
418 //SW4
419 at91_set_gpio_input(AT91_PIN_PB2, 0);
420 at91_set_deglitch(AT91_PIN_PB2, 1);
421
422 //SW5
423 at91_set_gpio_input(AT91_PIN_PB6, 0);
424 at91_set_deglitch(AT91_PIN_PB6, 1);
425
426
427 at91_set_gpio_output(AT91_PIN_PB7, 1); /* #TURN BUTTONS ON, SHEET 5 of schematics */
428 platform_device_register(&yl_9200_button_device);
429}
430#else
431static void __init yl_9200_add_device_buttons(void) {}
432#endif
433
434#if defined(CONFIG_FB_S1D135XX) || defined(CONFIG_FB_S1D13XXX_MODULE)
435#include <video/s1d13xxxfb.h>
436
437/* EPSON S1D13806 FB (discontinued chip)*/
438/* EPSON S1D13506 FB */
439
440#define AT91_FB_REG_BASE 0x80000000L
441#define AT91_FB_REG_SIZE 0x200
442#define AT91_FB_VMEM_BASE 0x80200000L
443#define AT91_FB_VMEM_SIZE 0x200000L
444
445/*#define S1D_DISPLAY_WIDTH 640*/
446/*#define S1D_DISPLAY_HEIGHT 480*/
447
448
449static void __init yl_9200_init_video(void)
450{
451 at91_sys_write(AT91_PIOC + PIO_ASR,AT91_PIN_PC6);
452 at91_sys_write(AT91_PIOC + PIO_BSR,0);
453 at91_sys_write(AT91_PIOC + PIO_ASR,AT91_PIN_PC6);
454
455 at91_sys_write( AT91_SMC_CSR(2),
456 AT91_SMC_NWS_(0x4) |
457 AT91_SMC_WSEN |
458 AT91_SMC_TDF_(0x100) |
459 AT91_SMC_DBW
460 );
461
462
463
464}
465
466
467static struct s1d13xxxfb_regval yl_9200_s1dfb_initregs[] =
468{
469 {S1DREG_MISC, 0x00}, /* Miscellaneous Register*/
470 {S1DREG_COM_DISP_MODE, 0x01}, /* Display Mode Register, LCD only*/
471 {S1DREG_GPIO_CNF0, 0x00}, /* General IO Pins Configuration Register*/
472 {S1DREG_GPIO_CTL0, 0x00}, /* General IO Pins Control Register*/
473 {S1DREG_CLK_CNF, 0x11}, /* Memory Clock Configuration Register*/
474 {S1DREG_LCD_CLK_CNF, 0x10}, /* LCD Pixel Clock Configuration Register*/
475 {S1DREG_CRT_CLK_CNF, 0x12}, /* CRT/TV Pixel Clock Configuration Register*/
476 {S1DREG_MPLUG_CLK_CNF, 0x01}, /* MediaPlug Clock Configuration Register*/
477 {S1DREG_CPU2MEM_WST_SEL, 0x02}, /* CPU To Memory Wait State Select Register*/
478 {S1DREG_MEM_CNF, 0x00}, /* Memory Configuration Register*/
479 {S1DREG_SDRAM_REF_RATE, 0x04}, /* DRAM Refresh Rate Register, MCLK source*/
480 {S1DREG_SDRAM_TC0, 0x12}, /* DRAM Timings Control Register 0*/
481 {S1DREG_SDRAM_TC1, 0x02}, /* DRAM Timings Control Register 1*/
482 {S1DREG_PANEL_TYPE, 0x25}, /* Panel Type Register*/
483 {S1DREG_MOD_RATE, 0x00}, /* MOD Rate Register*/
484 {S1DREG_LCD_DISP_HWIDTH, 0x4F}, /* LCD Horizontal Display Width Register*/
485 {S1DREG_LCD_NDISP_HPER, 0x13}, /* LCD Horizontal Non-Display Period Register*/
486 {S1DREG_TFT_FPLINE_START, 0x01}, /* TFT FPLINE Start Position Register*/
487 {S1DREG_TFT_FPLINE_PWIDTH, 0x0c}, /* TFT FPLINE Pulse Width Register*/
488 {S1DREG_LCD_DISP_VHEIGHT0, 0xDF}, /* LCD Vertical Display Height Register 0*/
489 {S1DREG_LCD_DISP_VHEIGHT1, 0x01}, /* LCD Vertical Display Height Register 1*/
490 {S1DREG_LCD_NDISP_VPER, 0x2c}, /* LCD Vertical Non-Display Period Register*/
491 {S1DREG_TFT_FPFRAME_START, 0x0a}, /* TFT FPFRAME Start Position Register*/
492 {S1DREG_TFT_FPFRAME_PWIDTH, 0x02}, /* TFT FPFRAME Pulse Width Register*/
493 {S1DREG_LCD_DISP_MODE, 0x05}, /* LCD Display Mode Register*/
494 {S1DREG_LCD_MISC, 0x01}, /* LCD Miscellaneous Register*/
495 {S1DREG_LCD_DISP_START0, 0x00}, /* LCD Display Start Address Register 0*/
496 {S1DREG_LCD_DISP_START1, 0x00}, /* LCD Display Start Address Register 1*/
497 {S1DREG_LCD_DISP_START2, 0x00}, /* LCD Display Start Address Register 2*/
498 {S1DREG_LCD_MEM_OFF0, 0x80}, /* LCD Memory Address Offset Register 0*/
499 {S1DREG_LCD_MEM_OFF1, 0x02}, /* LCD Memory Address Offset Register 1*/
500 {S1DREG_LCD_PIX_PAN, 0x03}, /* LCD Pixel Panning Register*/
501 {S1DREG_LCD_DISP_FIFO_HTC, 0x00}, /* LCD Display FIFO High Threshold Control Register*/
502 {S1DREG_LCD_DISP_FIFO_LTC, 0x00}, /* LCD Display FIFO Low Threshold Control Register*/
503 {S1DREG_CRT_DISP_HWIDTH, 0x4F}, /* CRT/TV Horizontal Display Width Register*/
504 {S1DREG_CRT_NDISP_HPER, 0x13}, /* CRT/TV Horizontal Non-Display Period Register*/
505 {S1DREG_CRT_HRTC_START, 0x01}, /* CRT/TV HRTC Start Position Register*/
506 {S1DREG_CRT_HRTC_PWIDTH, 0x0B}, /* CRT/TV HRTC Pulse Width Register*/
507 {S1DREG_CRT_DISP_VHEIGHT0, 0xDF}, /* CRT/TV Vertical Display Height Register 0*/
508 {S1DREG_CRT_DISP_VHEIGHT1, 0x01}, /* CRT/TV Vertical Display Height Register 1*/
509 {S1DREG_CRT_NDISP_VPER, 0x2B}, /* CRT/TV Vertical Non-Display Period Register*/
510 {S1DREG_CRT_VRTC_START, 0x09}, /* CRT/TV VRTC Start Position Register*/
511 {S1DREG_CRT_VRTC_PWIDTH, 0x01}, /* CRT/TV VRTC Pulse Width Register*/
512 {S1DREG_TV_OUT_CTL, 0x18}, /* TV Output Control Register */
513 {S1DREG_CRT_DISP_MODE, 0x05}, /* CRT/TV Display Mode Register, 16BPP*/
514 {S1DREG_CRT_DISP_START0, 0x00}, /* CRT/TV Display Start Address Register 0*/
515 {S1DREG_CRT_DISP_START1, 0x00}, /* CRT/TV Display Start Address Register 1*/
516 {S1DREG_CRT_DISP_START2, 0x00}, /* CRT/TV Display Start Address Register 2*/
517 {S1DREG_CRT_MEM_OFF0, 0x80}, /* CRT/TV Memory Address Offset Register 0*/
518 {S1DREG_CRT_MEM_OFF1, 0x02}, /* CRT/TV Memory Address Offset Register 1*/
519 {S1DREG_CRT_PIX_PAN, 0x00}, /* CRT/TV Pixel Panning Register*/
520 {S1DREG_CRT_DISP_FIFO_HTC, 0x00}, /* CRT/TV Display FIFO High Threshold Control Register*/
521 {S1DREG_CRT_DISP_FIFO_LTC, 0x00}, /* CRT/TV Display FIFO Low Threshold Control Register*/
522 {S1DREG_LCD_CUR_CTL, 0x00}, /* LCD Ink/Cursor Control Register*/
523 {S1DREG_LCD_CUR_START, 0x01}, /* LCD Ink/Cursor Start Address Register*/
524 {S1DREG_LCD_CUR_XPOS0, 0x00}, /* LCD Cursor X Position Register 0*/
525 {S1DREG_LCD_CUR_XPOS1, 0x00}, /* LCD Cursor X Position Register 1*/
526 {S1DREG_LCD_CUR_YPOS0, 0x00}, /* LCD Cursor Y Position Register 0*/
527 {S1DREG_LCD_CUR_YPOS1, 0x00}, /* LCD Cursor Y Position Register 1*/
528 {S1DREG_LCD_CUR_BCTL0, 0x00}, /* LCD Ink/Cursor Blue Color 0 Register*/
529 {S1DREG_LCD_CUR_GCTL0, 0x00}, /* LCD Ink/Cursor Green Color 0 Register*/
530 {S1DREG_LCD_CUR_RCTL0, 0x00}, /* LCD Ink/Cursor Red Color 0 Register*/
531 {S1DREG_LCD_CUR_BCTL1, 0x1F}, /* LCD Ink/Cursor Blue Color 1 Register*/
532 {S1DREG_LCD_CUR_GCTL1, 0x3F}, /* LCD Ink/Cursor Green Color 1 Register*/
533 {S1DREG_LCD_CUR_RCTL1, 0x1F}, /* LCD Ink/Cursor Red Color 1 Register*/
534 {S1DREG_LCD_CUR_FIFO_HTC, 0x00}, /* LCD Ink/Cursor FIFO Threshold Register*/
535 {S1DREG_CRT_CUR_CTL, 0x00}, /* CRT/TV Ink/Cursor Control Register*/
536 {S1DREG_CRT_CUR_START, 0x01}, /* CRT/TV Ink/Cursor Start Address Register*/
537 {S1DREG_CRT_CUR_XPOS0, 0x00}, /* CRT/TV Cursor X Position Register 0*/
538 {S1DREG_CRT_CUR_XPOS1, 0x00}, /* CRT/TV Cursor X Position Register 1*/
539 {S1DREG_CRT_CUR_YPOS0, 0x00}, /* CRT/TV Cursor Y Position Register 0*/
540 {S1DREG_CRT_CUR_YPOS1, 0x00}, /* CRT/TV Cursor Y Position Register 1*/
541 {S1DREG_CRT_CUR_BCTL0, 0x00}, /* CRT/TV Ink/Cursor Blue Color 0 Register*/
542 {S1DREG_CRT_CUR_GCTL0, 0x00}, /* CRT/TV Ink/Cursor Green Color 0 Register*/
543 {S1DREG_CRT_CUR_RCTL0, 0x00}, /* CRT/TV Ink/Cursor Red Color 0 Register*/
544 {S1DREG_CRT_CUR_BCTL1, 0x1F}, /* CRT/TV Ink/Cursor Blue Color 1 Register*/
545 {S1DREG_CRT_CUR_GCTL1, 0x3F}, /* CRT/TV Ink/Cursor Green Color 1 Register*/
546 {S1DREG_CRT_CUR_RCTL1, 0x1F}, /* CRT/TV Ink/Cursor Red Color 1 Register*/
547 {S1DREG_CRT_CUR_FIFO_HTC, 0x00}, /* CRT/TV Ink/Cursor FIFO Threshold Register*/
548 {S1DREG_BBLT_CTL0, 0x00}, /* BitBlt Control Register 0*/
549 {S1DREG_BBLT_CTL1, 0x01}, /* BitBlt Control Register 1*/
550 {S1DREG_BBLT_CC_EXP, 0x00}, /* BitBlt ROP Code/Color Expansion Register*/
551 {S1DREG_BBLT_OP, 0x00}, /* BitBlt Operation Register*/
552 {S1DREG_BBLT_SRC_START0, 0x00}, /* BitBlt Source Start Address Register 0*/
553 {S1DREG_BBLT_SRC_START1, 0x00}, /* BitBlt Source Start Address Register 1*/
554 {S1DREG_BBLT_SRC_START2, 0x00}, /* BitBlt Source Start Address Register 2*/
555 {S1DREG_BBLT_DST_START0, 0x00}, /* BitBlt Destination Start Address Register 0*/
556 {S1DREG_BBLT_DST_START1, 0x00}, /* BitBlt Destination Start Address Register 1*/
557 {S1DREG_BBLT_DST_START2, 0x00}, /* BitBlt Destination Start Address Register 2*/
558 {S1DREG_BBLT_MEM_OFF0, 0x00}, /* BitBlt Memory Address Offset Register 0*/
559 {S1DREG_BBLT_MEM_OFF1, 0x00}, /* BitBlt Memory Address Offset Register 1*/
560 {S1DREG_BBLT_WIDTH0, 0x00}, /* BitBlt Width Register 0*/
561 {S1DREG_BBLT_WIDTH1, 0x00}, /* BitBlt Width Register 1*/
562 {S1DREG_BBLT_HEIGHT0, 0x00}, /* BitBlt Height Register 0*/
563 {S1DREG_BBLT_HEIGHT1, 0x00}, /* BitBlt Height Register 1*/
564 {S1DREG_BBLT_BGC0, 0x00}, /* BitBlt Background Color Register 0*/
565 {S1DREG_BBLT_BGC1, 0x00}, /* BitBlt Background Color Register 1*/
566 {S1DREG_BBLT_FGC0, 0x00}, /* BitBlt Foreground Color Register 0*/
567 {S1DREG_BBLT_FGC1, 0x00}, /* BitBlt Foreground Color Register 1*/
568 {S1DREG_LKUP_MODE, 0x00}, /* Look-Up Table Mode Register*/
569 {S1DREG_LKUP_ADDR, 0x00}, /* Look-Up Table Address Register*/
570 {S1DREG_PS_CNF, 0x00}, /* Power Save Configuration Register*/
571 {S1DREG_PS_STATUS, 0x00}, /* Power Save Status Register*/
572 {S1DREG_CPU2MEM_WDOGT, 0x00}, /* CPU-to-Memory Access Watchdog Timer Register*/
573 {S1DREG_COM_DISP_MODE, 0x01}, /* Display Mode Register, LCD only*/
574};
575
576static u64 s1dfb_dmamask = 0xffffffffUL;
577
578static struct s1d13xxxfb_pdata yl_9200_s1dfb_pdata = {
579 .initregs = yl_9200_s1dfb_initregs,
580 .initregssize = ARRAY_SIZE(yl_9200_s1dfb_initregs),
581 .platform_init_video = yl_9200_init_video,
582};
583
584static struct resource yl_9200_s1dfb_resource[] = {
585 [0] = { /* video mem */
586 .name = "s1d13xxxfb memory",
587 /* .name = "s1d13806 memory",*/
588 .start = AT91_FB_VMEM_BASE,
589 .end = AT91_FB_VMEM_BASE + AT91_FB_VMEM_SIZE -1,
590 .flags = IORESOURCE_MEM,
591 },
592 [1] = { /* video registers */
593 .name = "s1d13xxxfb registers",
594 /* .name = "s1d13806 registers",*/
595 .start = AT91_FB_REG_BASE,
596 .end = AT91_FB_REG_BASE + AT91_FB_REG_SIZE -1,
597 .flags = IORESOURCE_MEM,
598 },
599};
600
601static struct platform_device yl_9200_s1dfb_device = {
602 /*TODO S.Birtles , really we need the chip revision in here as well*/
603 .name = "s1d13806fb",
604 /* .name = "s1d13506fb",*/
605 .id = -1,
606 .dev = {
607 /*TODO theres a waring here!!*/
608 /*WARNING: vmlinux.o(.data+0x2dbc): Section mismatch: reference to .init.text: (between 'yl_9200_s1dfb_pdata' and 's1dfb_dmamask')*/
609 .dma_mask = &s1dfb_dmamask,
610 .coherent_dma_mask = 0xffffffff,
611 .platform_data = &yl_9200_s1dfb_pdata,
612 },
613 .resource = yl_9200_s1dfb_resource,
614 .num_resources = ARRAY_SIZE(yl_9200_s1dfb_resource),
615};
616
617void __init yl_9200_add_device_video(void)
618{
619 platform_device_register(&yl_9200_s1dfb_device);
620}
621#else
622 void __init yl_9200_add_device_video(void) {}
623#endif
624
625/*this is not called first , yl_9200_map_io is called first*/
626static void __init yl_9200_board_init(void)
627{
628 /* Serial */
629 at91_add_device_serial();
630 /* Ethernet */
631 at91_add_device_eth(&yl_9200_eth_data);
632 /* USB Host */
633 at91_add_device_usbh(&yl_9200_usbh_data);
634 /* USB Device */
635 at91_add_device_udc(&yl_9200_udc_data);
636 /* pullup_pin it is actually active low, but this is not needed, driver sets it up */
637 /*at91_set_multi_drive(yl_9200_udc_data.pullup_pin, 0);*/
638
639 /* Compact Flash */
640 /*at91_add_device_cf(&yl_9200_cf_data);*/
641
642 /* I2C */
643 at91_add_device_i2c(yl_9200_i2c_devices, ARRAY_SIZE(yl_9200_i2c_devices));
644 /* SPI */
645 /*TODO YL9200 we have 2 spi interfaces touch screen & CAN*/
646 /* AT91_PIN_PA5, AT91_PIN_PA6 , are used on the max 485 NOT SPI*/
647
648 /*touch screen and CAN*/
649 at91_add_device_spi(yl_9200_spi_devices, ARRAY_SIZE(yl_9200_spi_devices));
650
651 /*Basically the TS uses PB11 & PB10 , PB11 is configured by the SPI system BP10 IS NOT USED!!*/
652 /* we need this incase the board is running without a touch screen*/
653 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
654 at91_init_device_ts(); /*init the touch screen device*/
655 #endif
656 /* DataFlash card */
657 at91_add_device_mmc(0, &yl_9200_mmc_data);
658 /* NAND */
659 at91_add_device_nand(&yl_9200_nand_data);
660 /* NOR Flash */
661 platform_device_register(&yl_9200_flash);
662 /* LEDs. Note!! this does not include the led's we passed for the processor status */
663 at91_gpio_leds(yl_9200_leds, ARRAY_SIZE(yl_9200_leds));
664 /* VGA */
665 /*this is self registered by including the s1d13xxx chip in the kernel build*/
666 yl_9200_add_device_video();
667 /* Push Buttons */
668 yl_9200_add_device_buttons();
669 /*TODO fixup the Sounder */
670// yl_9200_add_device_sounder(yl_9200_sounder,ARRAY_SIZE(yl_9200_sounder));
671
672}
673
674MACHINE_START(YL9200, "uCdragon YL-9200")
675 /* Maintainer: S.Birtles*/
676 .phys_io = AT91_BASE_SYS,
677 .io_pg_offst = (AT91_VA_BASE_SYS >> 18) & 0xfffc,
678 .boot_params = AT91_SDRAM_BASE + 0x100,
679 .timer = &at91rm9200_timer,
680 .map_io = yl_9200_map_io,
681 .init_irq = yl_9200_init_irq,
682 .init_machine = yl_9200_board_init,
683MACHINE_END
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index a67defd50438..39733b6992aa 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -26,12 +26,135 @@
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
64static u32 saved_lpr;
65
66static inline void sdram_selfrefresh_enable(void)
67{
68 u32 lpr;
69
70 saved_lpr = at91_sys_read(AT91_SDRAMC_LPR);
71
72 lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
73 at91_sys_write(AT91_SDRAMC_LPR, lpr | AT91_SDRAMC_LPCB_SELF_REFRESH);
74}
75
76#define sdram_selfrefresh_disable() at91_sys_write(AT91_SDRAMC_LPR, saved_lpr)
77
78/*
79 * FIXME: The AT91SAM9263 has a second EBI controller which may have
80 * additional SDRAM. pm_slowclock.S will require a similar fix.
81 */
82
83#endif
84
85
86/*
87 * Show the reason for the previous system reset.
88 */
89#if defined(AT91_SHDWC)
90
91#include <asm/arch/at91_rstc.h>
92#include <asm/arch/at91_shdwc.h>
93
94static void __init show_reset_status(void)
95{
96 static char reset[] __initdata = "reset";
97
98 static char general[] __initdata = "general";
99 static char wakeup[] __initdata = "wakeup";
100 static char watchdog[] __initdata = "watchdog";
101 static char software[] __initdata = "software";
102 static char user[] __initdata = "user";
103 static char unknown[] __initdata = "unknown";
104
105 static char signal[] __initdata = "signal";
106 static char rtc[] __initdata = "rtc";
107 static char rtt[] __initdata = "rtt";
108 static char restore[] __initdata = "power-restored";
109
110 char *reason, *r2 = reset;
111 u32 reset_type, wake_type;
112
113 reset_type = at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_RSTTYP;
114 wake_type = at91_sys_read(AT91_SHDW_SR);
115
116 switch (reset_type) {
117 case AT91_RSTC_RSTTYP_GENERAL:
118 reason = general;
119 break;
120 case AT91_RSTC_RSTTYP_WAKEUP:
121 /* board-specific code enabled the wakeup sources */
122 reason = wakeup;
123
124 /* "wakeup signal" */
125 if (wake_type & AT91_SHDW_WAKEUP0)
126 r2 = signal;
127 else {
128 r2 = reason;
129 if (wake_type & AT91_SHDW_RTTWK) /* rtt wakeup */
130 reason = rtt;
131 else if (wake_type & AT91_SHDW_RTCWK) /* rtc wakeup */
132 reason = rtc;
133 else if (wake_type == 0) /* power-restored wakeup */
134 reason = restore;
135 else /* unknown wakeup */
136 reason = unknown;
137 }
138 break;
139 case AT91_RSTC_RSTTYP_WATCHDOG:
140 reason = watchdog;
141 break;
142 case AT91_RSTC_RSTTYP_SOFTWARE:
143 reason = software;
144 break;
145 case AT91_RSTC_RSTTYP_USER:
146 reason = user;
147 break;
148 default:
149 reason = unknown;
150 break;
151 }
152 pr_info("AT91: Starting after %s %s\n", reason, r2);
153}
154#else
155static void __init show_reset_status(void) {}
156#endif
157
35 158
36static int at91_pm_valid_state(suspend_state_t state) 159static int at91_pm_valid_state(suspend_state_t state)
37{ 160{
@@ -125,6 +248,11 @@ EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
125 248
126static void (*slow_clock)(void); 249static void (*slow_clock)(void);
127 250
251#ifdef CONFIG_AT91_SLOW_CLOCK
252extern void at91_slow_clock(void);
253extern u32 at91_slow_clock_sz;
254#endif
255
128 256
129static int at91_pm_enter(suspend_state_t state) 257static int at91_pm_enter(suspend_state_t state)
130{ 258{
@@ -158,11 +286,14 @@ static int at91_pm_enter(suspend_state_t state)
158 * turning off the main oscillator; reverse on wakeup. 286 * turning off the main oscillator; reverse on wakeup.
159 */ 287 */
160 if (slow_clock) { 288 if (slow_clock) {
289#ifdef CONFIG_AT91_SLOW_CLOCK
290 /* copy slow_clock handler to SRAM, and call it */
291 memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
292#endif
161 slow_clock(); 293 slow_clock();
162 break; 294 break;
163 } else { 295 } else {
164 /* DEVELOPMENT ONLY */ 296 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 */ 297 /* FALLTHROUGH leaving master clock alone */
167 } 298 }
168 299
@@ -175,13 +306,15 @@ static int at91_pm_enter(suspend_state_t state)
175 case PM_SUSPEND_STANDBY: 306 case PM_SUSPEND_STANDBY:
176 /* 307 /*
177 * NOTE: the Wait-for-Interrupt instruction needs to be 308 * NOTE: the Wait-for-Interrupt instruction needs to be
178 * in icache so the SDRAM stays in self-refresh mode until 309 * in icache so no SDRAM accesses are needed until the
179 * the wakeup IRQ occurs. 310 * wakeup IRQ occurs and self-refresh is terminated.
180 */ 311 */
181 asm("b 1f; .align 5; 1:"); 312 asm("b 1f; .align 5; 1:");
182 asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */ 313 asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */
183 at91_sys_write(AT91_SDRAMC_SRR, 1); /* self-refresh mode */ 314 sdram_selfrefresh_enable();
184 /* fall though to next state */ 315 asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */
316 sdram_selfrefresh_disable();
317 break;
185 318
186 case PM_SUSPEND_ON: 319 case PM_SUSPEND_ON:
187 asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */ 320 asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */
@@ -196,6 +329,7 @@ static int at91_pm_enter(suspend_state_t state)
196 at91_sys_read(AT91_AIC_IPR) & at91_sys_read(AT91_AIC_IMR)); 329 at91_sys_read(AT91_AIC_IPR) & at91_sys_read(AT91_AIC_IMR));
197 330
198error: 331error:
332 sdram_selfrefresh_disable();
199 target_state = PM_SUSPEND_ON; 333 target_state = PM_SUSPEND_ON;
200 at91_irq_resume(); 334 at91_irq_resume();
201 at91_gpio_resume(); 335 at91_gpio_resume();
@@ -220,21 +354,20 @@ static struct platform_suspend_ops at91_pm_ops ={
220 354
221static int __init at91_pm_init(void) 355static int __init at91_pm_init(void)
222{ 356{
223 printk("AT91: Power Management\n"); 357#ifdef CONFIG_AT91_SLOW_CLOCK
224 358 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 359#endif
232 360
233 /* Disable SDRAM low-power mode. Cannot be used with self-refresh. */ 361 pr_info("AT91: Power Management%s\n", (slow_clock ? " (with slow clock mode)" : ""));
362
363#ifdef CONFIG_ARCH_AT91RM9200
364 /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
234 at91_sys_write(AT91_SDRAMC_LPR, 0); 365 at91_sys_write(AT91_SDRAMC_LPR, 0);
366#endif
235 367
236 suspend_set_ops(&at91_pm_ops); 368 suspend_set_ops(&at91_pm_ops);
237 369
370 show_reset_status();
238 return 0; 371 return 0;
239} 372}
240arch_initcall(at91_pm_init); 373arch_initcall(at91_pm_init);