All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH RFC] at91sam9/at91cap: move common initialisation to cpu
Date: Fri,  7 Nov 2008 20:38:26 +0100	[thread overview]
Message-ID: <1226086706-5419-1-git-send-email-plagnioj@jcrosoft.com> (raw)

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
The idea is to reduce common code initialisation which is actually in board.
as done on afeb9260 and Ronetix eval board for 9260 & 9263

Best Regards,
J.
 board/afeb9260/afeb9260.c                 |   32 ++----------
 board/atmel/at91cap9adk/at91cap9adk.c     |   33 ++-----------
 board/atmel/at91sam9260ek/at91sam9260ek.c |   34 ++-----------
 board/atmel/at91sam9261ek/at91sam9261ek.c |   33 ++-----------
 board/atmel/at91sam9263ek/at91sam9263ek.c |   33 ++-----------
 board/atmel/at91sam9rlek/at91sam9rlek.c   |   33 ++-----------
 cpu/arm926ejs/at91/Makefile               |   19 +++++++-
 cpu/arm926ejs/at91/at91cap9_serial.c      |   73 +++++++++++++++++++++++++++++
 cpu/arm926ejs/at91/at91cap9_spi.c         |   41 ++++++++++++++++
 cpu/arm926ejs/at91/at91sam9260_serial.c   |   73 +++++++++++++++++++++++++++++
 cpu/arm926ejs/at91/at91sam9260_spi.c      |   42 ++++++++++++++++
 cpu/arm926ejs/at91/at91sam9261_serial.c   |   73 +++++++++++++++++++++++++++++
 cpu/arm926ejs/at91/at91sam9261_spi.c      |   41 ++++++++++++++++
 cpu/arm926ejs/at91/at91sam9263_serial.c   |   73 +++++++++++++++++++++++++++++
 cpu/arm926ejs/at91/at91sam9263_spi.c      |   41 ++++++++++++++++
 cpu/arm926ejs/at91/at91sam9rl_serial.c    |   73 +++++++++++++++++++++++++++++
 cpu/arm926ejs/at91/at91sam9rl_spi.c       |   41 ++++++++++++++++
 include/asm-arm/arch-at91/at91_common.h   |   31 ++++++++++++
 18 files changed, 656 insertions(+), 163 deletions(-)
 create mode 100644 cpu/arm926ejs/at91/at91cap9_serial.c
 create mode 100644 cpu/arm926ejs/at91/at91cap9_spi.c
 create mode 100644 cpu/arm926ejs/at91/at91sam9260_serial.c
 create mode 100644 cpu/arm926ejs/at91/at91sam9260_spi.c
 create mode 100644 cpu/arm926ejs/at91/at91sam9261_serial.c
 create mode 100644 cpu/arm926ejs/at91/at91sam9261_spi.c
 create mode 100644 cpu/arm926ejs/at91/at91sam9263_serial.c
 create mode 100644 cpu/arm926ejs/at91/at91sam9263_spi.c
 create mode 100644 cpu/arm926ejs/at91/at91sam9rl_serial.c
 create mode 100644 cpu/arm926ejs/at91/at91sam9rl_spi.c
 create mode 100644 include/asm-arm/arch-at91/at91_common.h

diff --git a/board/afeb9260/afeb9260.c b/board/afeb9260/afeb9260.c
index 32445ab..e1d52ad 100644
--- a/board/afeb9260/afeb9260.c
+++ b/board/afeb9260/afeb9260.c
@@ -27,6 +27,7 @@
 #include <asm/arch/at91sam9260.h>
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/gpio.h>
@@ -47,27 +48,19 @@ DECLARE_GLOBAL_DATA_PTR;
 static void afeb9260_serial_hw_init(void)
 {
 #ifdef CONFIG_USART0
-	at91_set_A_periph(AT91_PIN_PB4, 1);		/* TXD0 */
-	at91_set_A_periph(AT91_PIN_PB5, 0);		/* RXD0 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US0);
+	at91_serial_hw_init(0);
 #endif
 
 #ifdef CONFIG_USART1
-	at91_set_A_periph(AT91_PIN_PB6, 1);		/* TXD1 */
-	at91_set_A_periph(AT91_PIN_PB7, 0);		/* RXD1 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US1);
+	at91_serial_hw_init(1);
 #endif
 
 #ifdef CONFIG_USART2
-	at91_set_A_periph(AT91_PIN_PB8, 1);		/* TXD2 */
-	at91_set_A_periph(AT91_PIN_PB9, 0);		/* RXD2 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US2);
+	at91_serial_hw_init(2);
 #endif
 
 #ifdef CONFIG_USART3	/* DBGU */
-	at91_set_A_periph(AT91_PIN_PB14, 0);		/* DRXD */
-	at91_set_A_periph(AT91_PIN_PB15, 1);		/* DTXD */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+	at91_serial_hw_init(3);
 #endif
 }
 
@@ -104,19 +97,6 @@ static void afeb9260_nand_hw_init(void)
 	at91_set_gpio_output(AT91_PIN_PC14, 1);
 }
 
-static void afeb9260_spi_hw_init(void)
-{
-	at91_set_A_periph(AT91_PIN_PA3, 0);	/* SPI0_NPCS0 */
-	at91_set_B_periph(AT91_PIN_PC11, 0);	/* SPI0_NPCS1 */
-
-	at91_set_A_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */
-	at91_set_A_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */
-	at91_set_A_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */
-
-	/* Enable clock */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_SPI0);
-}
-
 #ifdef CONFIG_MACB
 static void afeb9260_macb_hw_init(void)
 {
@@ -205,7 +185,7 @@ int board_init(void)
 #ifdef CONFIG_CMD_NAND
 	afeb9260_nand_hw_init();
 #endif
-	afeb9260_spi_hw_init();
+	at91_spi_hw_init();
 #ifdef CONFIG_MACB
 	afeb9260_macb_hw_init();
 #endif
diff --git a/board/atmel/at91cap9adk/at91cap9adk.c b/board/atmel/at91cap9adk/at91cap9adk.c
index f7d68b7..2d2cfe5 100644
--- a/board/atmel/at91cap9adk/at91cap9adk.c
+++ b/board/atmel/at91cap9adk/at91cap9adk.c
@@ -26,6 +26,7 @@
 #include <asm/arch/at91cap9.h>
 #include <asm/arch/at91cap9_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/gpio.h>
@@ -50,27 +51,19 @@ DECLARE_GLOBAL_DATA_PTR;
 static void at91cap9_serial_hw_init(void)
 {
 #ifdef CONFIG_USART0
-	at91_set_A_periph(AT91_PIN_PA22, 1);		/* TXD0 */
-	at91_set_A_periph(AT91_PIN_PA23, 0);		/* RXD0 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91CAP9_ID_US0);
+	at91_serial_hw_init(0);
 #endif
 
 #ifdef CONFIG_USART1
-	at91_set_A_periph(AT91_PIN_PD0, 1);		/* TXD1 */
-	at91_set_A_periph(AT91_PIN_PD1, 0);		/* RXD1 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91CAP9_ID_US1);
+	at91_serial_hw_init(1);
 #endif
 
 #ifdef CONFIG_USART2
-	at91_set_A_periph(AT91_PIN_PD2, 1);		/* TXD2 */
-	at91_set_A_periph(AT91_PIN_PD3, 0);		/* RXD2 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91CAP9_ID_US2);
+	at91_serial_hw_init(2);
 #endif
 
 #ifdef CONFIG_USART3	/* DBGU */
-	at91_set_A_periph(AT91_PIN_PC30, 0);		/* DRXD */
-	at91_set_A_periph(AT91_PIN_PC31, 1);		/* DTXD */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+	at91_serial_hw_init(3);
 #endif
 }
 
@@ -163,20 +156,6 @@ static void at91cap9_nand_hw_init(void)
 }
 #endif
 
-#ifdef CONFIG_HAS_DATAFLASH
-static void at91cap9_spi_hw_init(void)
-{
-	at91_set_B_periph(AT91_PIN_PA5, 0);	/* SPI0_NPCS0 */
-
-	at91_set_B_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */
-	at91_set_B_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */
-	at91_set_B_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */
-
-	/* Enable clock */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91CAP9_ID_SPI0);
-}
-#endif
-
 #ifdef CONFIG_MACB
 static void at91cap9_macb_hw_init(void)
 {
@@ -374,7 +353,7 @@ int board_init(void)
 	at91cap9_nand_hw_init();
 #endif
 #ifdef CONFIG_HAS_DATAFLASH
-	at91cap9_spi_hw_init();
+	at91_spi_hw_init();
 #endif
 #ifdef CONFIG_MACB
 	at91cap9_macb_hw_init();
diff --git a/board/atmel/at91sam9260ek/at91sam9260ek.c b/board/atmel/at91sam9260ek/at91sam9260ek.c
index ef99b8b..b51e8dc 100644
--- a/board/atmel/at91sam9260ek/at91sam9260ek.c
+++ b/board/atmel/at91sam9260ek/at91sam9260ek.c
@@ -26,6 +26,7 @@
 #include <asm/arch/at91sam9260.h>
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/gpio.h>
@@ -46,27 +47,19 @@ DECLARE_GLOBAL_DATA_PTR;
 static void at91sam9260ek_serial_hw_init(void)
 {
 #ifdef CONFIG_USART0
-	at91_set_A_periph(AT91_PIN_PB4, 1);		/* TXD0 */
-	at91_set_A_periph(AT91_PIN_PB5, 0);		/* RXD0 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US0);
+	at91_serial_hw_init(0);
 #endif
 
 #ifdef CONFIG_USART1
-	at91_set_A_periph(AT91_PIN_PB6, 1);		/* TXD1 */
-	at91_set_A_periph(AT91_PIN_PB7, 0);		/* RXD1 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US1);
+	at91_serial_hw_init(1);
 #endif
 
 #ifdef CONFIG_USART2
-	at91_set_A_periph(AT91_PIN_PB8, 1);		/* TXD2 */
-	at91_set_A_periph(AT91_PIN_PB9, 0);		/* RXD2 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US2);
+	at91_serial_hw_init(2);
 #endif
 
 #ifdef CONFIG_USART3	/* DBGU */
-	at91_set_A_periph(AT91_PIN_PB14, 0);		/* DRXD */
-	at91_set_A_periph(AT91_PIN_PB15, 1);		/* DTXD */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+	at91_serial_hw_init(3);
 #endif
 }
 
@@ -109,21 +102,6 @@ static void at91sam9260ek_nand_hw_init(void)
 }
 #endif
 
-#ifdef CONFIG_HAS_DATAFLASH
-static void at91sam9260ek_spi_hw_init(void)
-{
-	at91_set_A_periph(AT91_PIN_PA3, 0);	/* SPI0_NPCS0 */
-	at91_set_B_periph(AT91_PIN_PC11, 0);	/* SPI0_NPCS1 */
-
-	at91_set_A_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */
-	at91_set_A_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */
-	at91_set_A_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */
-
-	/* Enable clock */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_SPI0);
-}
-#endif
-
 #ifdef CONFIG_MACB
 static void at91sam9260ek_macb_hw_init(void)
 {
@@ -222,7 +200,7 @@ int board_init(void)
 	at91sam9260ek_nand_hw_init();
 #endif
 #ifdef CONFIG_HAS_DATAFLASH
-	at91sam9260ek_spi_hw_init();
+	at91_spi_hw_init();
 #endif
 #ifdef CONFIG_MACB
 	at91sam9260ek_macb_hw_init();
diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c b/board/atmel/at91sam9261ek/at91sam9261ek.c
index 14f236d..82dffde 100644
--- a/board/atmel/at91sam9261ek/at91sam9261ek.c
+++ b/board/atmel/at91sam9261ek/at91sam9261ek.c
@@ -26,6 +26,7 @@
 #include <asm/arch/at91sam9261.h>
 #include <asm/arch/at91sam9261_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/gpio.h>
@@ -46,27 +47,19 @@ DECLARE_GLOBAL_DATA_PTR;
 static void at91sam9261ek_serial_hw_init(void)
 {
 #ifdef CONFIG_USART0
-	at91_set_A_periph(AT91_PIN_PC8, 1);		/* TXD0 */
-	at91_set_A_periph(AT91_PIN_PC9, 0);		/* RXD0 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9261_ID_US0);
+	at91_serial_hw_init(0);
 #endif
 
 #ifdef CONFIG_USART1
-	at91_set_A_periph(AT91_PIN_PC12, 1);		/* TXD1 */
-	at91_set_A_periph(AT91_PIN_PC13, 0);		/* RXD1 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9261_ID_US1);
+	at91_serial_hw_init(1);
 #endif
 
 #ifdef CONFIG_USART2
-	at91_set_A_periph(AT91_PIN_PC14, 1);		/* TXD2 */
-	at91_set_A_periph(AT91_PIN_PC15, 0);		/* RXD2 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9261_ID_US2);
+	at91_serial_hw_init(2);
 #endif
 
 #ifdef CONFIG_USART3	/* DBGU */
-	at91_set_A_periph(AT91_PIN_PA9, 0);		/* DRXD */
-	at91_set_A_periph(AT91_PIN_PA10, 1);		/* DTXD */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+	at91_serial_hw_init(3);
 #endif
 }
 
@@ -112,20 +105,6 @@ static void at91sam9261ek_nand_hw_init(void)
 }
 #endif
 
-#ifdef CONFIG_HAS_DATAFLASH
-static void at91sam9261ek_spi_hw_init(void)
-{
-	at91_set_A_periph(AT91_PIN_PA3, 0);	/* SPI0_NPCS0 */
-
-	at91_set_A_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */
-	at91_set_A_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */
-	at91_set_A_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */
-
-	/* Enable clock */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9261_ID_SPI0);
-}
-#endif
-
 #ifdef CONFIG_DRIVER_DM9000
 static void at91sam9261ek_dm9000_hw_init(void)
 {
@@ -255,7 +234,7 @@ int board_init(void)
 	at91sam9261ek_nand_hw_init();
 #endif
 #ifdef CONFIG_HAS_DATAFLASH
-	at91sam9261ek_spi_hw_init();
+	at91_spi_hw_init();
 #endif
 #ifdef CONFIG_DRIVER_DM9000
 	at91sam9261ek_dm9000_hw_init();
diff --git a/board/atmel/at91sam9263ek/at91sam9263ek.c b/board/atmel/at91sam9263ek/at91sam9263ek.c
index ebd4649..872a369 100644
--- a/board/atmel/at91sam9263ek/at91sam9263ek.c
+++ b/board/atmel/at91sam9263ek/at91sam9263ek.c
@@ -27,6 +27,7 @@
 #include <asm/arch/at91sam9263.h>
 #include <asm/arch/at91sam9263_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/gpio.h>
@@ -49,27 +50,19 @@ DECLARE_GLOBAL_DATA_PTR;
 static void at91sam9263ek_serial_hw_init(void)
 {
 #ifdef CONFIG_USART0
-	at91_set_A_periph(AT91_PIN_PA26, 1);		/* TXD0 */
-	at91_set_A_periph(AT91_PIN_PA27, 0);		/* RXD0 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9263_ID_US0);
+	at91_serial_hw_init(0);
 #endif
 
 #ifdef CONFIG_USART1
-	at91_set_A_periph(AT91_PIN_PD0, 1);		/* TXD1 */
-	at91_set_A_periph(AT91_PIN_PD1, 0);		/* RXD1 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9263_ID_US1);
+	at91_serial_hw_init(1);
 #endif
 
 #ifdef CONFIG_USART2
-	at91_set_A_periph(AT91_PIN_PD2, 1);		/* TXD2 */
-	at91_set_A_periph(AT91_PIN_PD3, 0);		/* RXD2 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9263_ID_US2);
+	at91_serial_hw_init(2);
 #endif
 
 #ifdef CONFIG_USART3	/* DBGU */
-	at91_set_A_periph(AT91_PIN_PC30, 0);		/* DRXD */
-	at91_set_A_periph(AT91_PIN_PC31, 1);		/* DTXD */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+	at91_serial_hw_init(3);
 #endif
 }
 
@@ -113,20 +106,6 @@ static void at91sam9263ek_nand_hw_init(void)
 }
 #endif
 
-#ifdef CONFIG_HAS_DATAFLASH
-static void at91sam9263ek_spi_hw_init(void)
-{
-	at91_set_B_periph(AT91_PIN_PA5, 0);	/* SPI0_NPCS0 */
-
-	at91_set_B_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */
-	at91_set_B_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */
-	at91_set_B_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */
-
-	/* Enable clock */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9263_ID_SPI0);
-}
-#endif
-
 #ifdef CONFIG_MACB
 static void at91sam9263ek_macb_hw_init(void)
 {
@@ -306,7 +285,7 @@ int board_init(void)
 	at91sam9263ek_nand_hw_init();
 #endif
 #ifdef CONFIG_HAS_DATAFLASH
-	at91sam9263ek_spi_hw_init();
+	at91_spi_hw_init();
 #endif
 #ifdef CONFIG_MACB
 	at91sam9263ek_macb_hw_init();
diff --git a/board/atmel/at91sam9rlek/at91sam9rlek.c b/board/atmel/at91sam9rlek/at91sam9rlek.c
index b6fef9d..b42565f 100644
--- a/board/atmel/at91sam9rlek/at91sam9rlek.c
+++ b/board/atmel/at91sam9rlek/at91sam9rlek.c
@@ -26,6 +26,7 @@
 #include <asm/arch/at91sam9rl.h>
 #include <asm/arch/at91sam9rl_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
+#include <asm/arch/at91_common.h>
 #include <asm/arch/at91_pmc.h>
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/gpio.h>
@@ -46,27 +47,19 @@ DECLARE_GLOBAL_DATA_PTR;
 static void at91sam9rlek_serial_hw_init(void)
 {
 #ifdef CONFIG_USART0
-	at91_set_A_periph(AT91_PIN_PA6, 1);		/* TXD0 */
-	at91_set_A_periph(AT91_PIN_PA7, 0);		/* RXD0 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9RL_ID_US0);
+	at91_serial_hw_init(0);
 #endif
 
 #ifdef CONFIG_USART1
-	at91_set_A_periph(AT91_PIN_PA11, 1);		/* TXD1 */
-	at91_set_A_periph(AT91_PIN_PA12, 0);		/* RXD1 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9RL_ID_US1);
+	at91_serial_hw_init(1);
 #endif
 
 #ifdef CONFIG_USART2
-	at91_set_A_periph(AT91_PIN_PA13, 1);		/* TXD2 */
-	at91_set_A_periph(AT91_PIN_PA14, 0);		/* RXD2 */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9RL_ID_US2);
+	at91_serial_hw_init(2);
 #endif
 
 #ifdef CONFIG_USART3	/* DBGU */
-	at91_set_A_periph(AT91_PIN_PA21, 0);		/* DRXD */
-	at91_set_A_periph(AT91_PIN_PA22, 1);		/* DTXD */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+	at91_serial_hw_init(3);
 #endif
 }
 
@@ -112,20 +105,6 @@ static void at91sam9rlek_nand_hw_init(void)
 }
 #endif
 
-#ifdef CONFIG_HAS_DATAFLASH
-static void at91sam9rlek_spi_hw_init(void)
-{
-	at91_set_A_periph(AT91_PIN_PA28, 0);	/* SPI0_NPCS0 */
-
-	at91_set_A_periph(AT91_PIN_PA25, 0);	/* SPI0_MISO */
-	at91_set_A_periph(AT91_PIN_PA26, 0);	/* SPI0_MOSI */
-	at91_set_A_periph(AT91_PIN_PA27, 0);	/* SPI0_SPCK */
-
-	/* Enable clock */
-	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9RL_ID_SPI);
-}
-#endif
-
 #ifdef CONFIG_LCD
 vidinfo_t panel_info = {
 	vl_col:		240,
@@ -228,7 +207,7 @@ int board_init(void)
 	at91sam9rlek_nand_hw_init();
 #endif
 #ifdef CONFIG_HAS_DATAFLASH
-	at91sam9rlek_spi_hw_init();
+	at91_spi_hw_init();
 #endif
 #ifdef CONFIG_LCD
 	at91sam9rlek_lcd_hw_init();
diff --git a/cpu/arm926ejs/at91/Makefile b/cpu/arm926ejs/at91/Makefile
index 2d2a888..502271e 100644
--- a/cpu/arm926ejs/at91/Makefile
+++ b/cpu/arm926ejs/at91/Makefile
@@ -25,8 +25,25 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(SOC).a
 
+COBJS-$(CONFIG_AT91CAP9)	+= at91cap9_serial.o
+ifdef CONFIG_AT91SAM9260
+COBJS-y				+= at91sam9260_serial.o
+COBJS-$(CONFIG_HAS_DATAFLASH)	+= at91sam9260_spi.o
+endif
+ifdef CONFIG_AT91SAM9261
+COBJS-y				+= at91sam9261_serial.o
+COBJS-$(CONFIG_HAS_DATAFLASH)	+= at91sam9261_spi.o
+endif
+ifdef CONFIG_AT91SAM9263
+COBJS-y				+= at91sam9263_serial.o
+COBJS-$(CONFIG_HAS_DATAFLASH)	+= at91sam9263_spi.o
+endif
+ifdef CONFIG_AT91SAM9RL
+COBJS-y				+= at91sam9rl_serial.o
+COBJS-$(CONFIG_HAS_DATAFLASH)	+= at91sam9rl_spi.o
+endif
+COBJS-$(CONFIG_HAS_DATAFLASH)	+= spi.o
 COBJS-y	+= timer.o
-COBJS-$(CONFIG_HAS_DATAFLASH) +=spi.o
 COBJS-y	+= usb.o
 SOBJS	= lowlevel_init.o
 
diff --git a/cpu/arm926ejs/at91/at91cap9_serial.c b/cpu/arm926ejs/at91/at91cap9_serial.c
new file mode 100644
index 0000000..c7dbad9
--- /dev/null
+++ b/cpu/arm926ejs/at91/at91cap9_serial.c
@@ -0,0 +1,73 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+int at91_serial_hw_init(int uart)
+{
+	int err = -1;
+
+	switch(uart) {
+	case 0:
+#ifdef CONFIG_USART0
+		at91_set_A_periph(AT91_PIN_PA22, 1);		/* TXD0 */
+		at91_set_A_periph(AT91_PIN_PA23, 0);		/* RXD0 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91CAP9_ID_US0);
+		err = 0;
+#endif
+		break;
+	case 1:
+#ifdef CONFIG_USART1
+		at91_set_A_periph(AT91_PIN_PD0, 1);		/* TXD1 */
+		at91_set_A_periph(AT91_PIN_PD1, 0);		/* RXD1 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91CAP9_ID_US1);
+		err = 0;
+#endif
+		break;
+	case 2:
+#ifdef CONFIG_USART2
+		at91_set_A_periph(AT91_PIN_PD2, 1);		/* TXD2 */
+		at91_set_A_periph(AT91_PIN_PD3, 0);		/* RXD2 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91CAP9_ID_US2);
+		err = 0;
+#endif
+		break;
+	case 3:
+#ifdef CONFIG_USART3	/* DBGU */
+		at91_set_A_periph(AT91_PIN_PC30, 0);		/* DRXD */
+		at91_set_A_periph(AT91_PIN_PC31, 1);		/* DTXD */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+		err = 0;
+#endif
+		break;
+	default:
+		printf(" uart%d configuration failled\n", err);
+	}
+
+	return err;
+}
diff --git a/cpu/arm926ejs/at91/at91cap9_spi.c b/cpu/arm926ejs/at91/at91cap9_spi.c
new file mode 100644
index 0000000..2ceb6a1
--- /dev/null
+++ b/cpu/arm926ejs/at91/at91cap9_spi.c
@@ -0,0 +1,41 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+void at91_spi_hw_init(void)
+{
+	at91_set_B_periph(AT91_PIN_PA5, 0);	/* SPI0_NPCS0 */
+
+	at91_set_B_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */
+	at91_set_B_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */
+	at91_set_B_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */
+
+	/* Enable clock */
+	at91_sys_write(AT91_PMC_PCER, 1 << AT91CAP9_ID_SPI0);
+}
diff --git a/cpu/arm926ejs/at91/at91sam9260_serial.c b/cpu/arm926ejs/at91/at91sam9260_serial.c
new file mode 100644
index 0000000..4dd7c95
--- /dev/null
+++ b/cpu/arm926ejs/at91/at91sam9260_serial.c
@@ -0,0 +1,73 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+int at91_serial_hw_init(int uart)
+{
+	int err = -1;
+
+	switch(uart) {
+	case 0:
+#ifdef CONFIG_USART0
+		at91_set_A_periph(AT91_PIN_PB4, 1);		/* TXD0 */
+		at91_set_A_periph(AT91_PIN_PB5, 0);		/* RXD0 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US0);
+		err = 0;
+#endif
+		break;
+	case 1:
+#ifdef CONFIG_USART1
+		at91_set_A_periph(AT91_PIN_PB6, 1);		/* TXD1 */
+		at91_set_A_periph(AT91_PIN_PB7, 0);		/* RXD1 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US1);
+		err = 0;
+#endif
+		break;
+	case 2:
+#ifdef CONFIG_USART2
+		at91_set_A_periph(AT91_PIN_PB8, 1);		/* TXD2 */
+		at91_set_A_periph(AT91_PIN_PB9, 0);		/* RXD2 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_US2);
+		err = 0;
+#endif
+		break;
+	case 3:
+#ifdef CONFIG_USART3	/* DBGU */
+		at91_set_A_periph(AT91_PIN_PB14, 0);		/* DRXD */
+		at91_set_A_periph(AT91_PIN_PB15, 1);		/* DTXD */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+		err = 0;
+#endif
+		break;
+	default:
+		printf(" uart%d configuration failled\n", err);
+	}
+
+	return err;
+}
diff --git a/cpu/arm926ejs/at91/at91sam9260_spi.c b/cpu/arm926ejs/at91/at91sam9260_spi.c
new file mode 100644
index 0000000..fba9699
--- /dev/null
+++ b/cpu/arm926ejs/at91/at91sam9260_spi.c
@@ -0,0 +1,42 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+void at91_spi_hw_init(void)
+{
+	at91_set_A_periph(AT91_PIN_PA3, 0);	/* SPI0_NPCS0 */
+	at91_set_B_periph(AT91_PIN_PC11, 0);	/* SPI0_NPCS1 */
+
+	at91_set_A_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */
+	at91_set_A_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */
+	at91_set_A_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */
+
+	/* Enable clock */
+	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9260_ID_SPI0);
+}
diff --git a/cpu/arm926ejs/at91/at91sam9261_serial.c b/cpu/arm926ejs/at91/at91sam9261_serial.c
new file mode 100644
index 0000000..bf3c450
--- /dev/null
+++ b/cpu/arm926ejs/at91/at91sam9261_serial.c
@@ -0,0 +1,73 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+int at91_serial_hw_init(int uart)
+{
+	int err = -1;
+
+	switch(uart) {
+	case 0:
+#ifdef CONFIG_USART0
+		at91_set_A_periph(AT91_PIN_PC8, 1);		/* TXD0 */
+		at91_set_A_periph(AT91_PIN_PC9, 0);		/* RXD0 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9261_ID_US0);
+		err = 0;
+#endif
+		break;
+	case 1:
+#ifdef CONFIG_USART1
+		at91_set_A_periph(AT91_PIN_PC12, 1);		/* TXD1 */
+		at91_set_A_periph(AT91_PIN_PC13, 0);		/* RXD1 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9261_ID_US1);
+		err = 0;
+#endif
+		break;
+	case 2:
+#ifdef CONFIG_USART2
+		at91_set_A_periph(AT91_PIN_PC14, 1);		/* TXD2 */
+		at91_set_A_periph(AT91_PIN_PC15, 0);		/* RXD2 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9261_ID_US2);
+		err = 0;
+#endif
+		break;
+	case 3:
+#ifdef CONFIG_USART3	/* DBGU */
+		at91_set_A_periph(AT91_PIN_PA9, 0);		/* DRXD */
+		at91_set_A_periph(AT91_PIN_PA10, 1);		/* DTXD */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+		err = 0;
+#endif
+		break;
+	default:
+		printf(" uart%d configuration failled\n", err);
+	}
+
+	return err;
+}
diff --git a/cpu/arm926ejs/at91/at91sam9261_spi.c b/cpu/arm926ejs/at91/at91sam9261_spi.c
new file mode 100644
index 0000000..8eda600
--- /dev/null
+++ b/cpu/arm926ejs/at91/at91sam9261_spi.c
@@ -0,0 +1,41 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+void at91_spi_hw_init(void)
+{
+	at91_set_A_periph(AT91_PIN_PA3, 0);	/* SPI0_NPCS0 */
+
+	at91_set_A_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */
+	at91_set_A_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */
+	at91_set_A_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */
+
+	/* Enable clock */
+	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9261_ID_SPI0);
+}
diff --git a/cpu/arm926ejs/at91/at91sam9263_serial.c b/cpu/arm926ejs/at91/at91sam9263_serial.c
new file mode 100644
index 0000000..c20699a
--- /dev/null
+++ b/cpu/arm926ejs/at91/at91sam9263_serial.c
@@ -0,0 +1,73 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+int at91_serial_hw_init(int uart)
+{
+	int err = -1;
+
+	switch(uart) {
+	case 0:
+#ifdef CONFIG_USART0
+		at91_set_A_periph(AT91_PIN_PA26, 1);		/* TXD0 */
+		at91_set_A_periph(AT91_PIN_PA27, 0);		/* RXD0 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9263_ID_US0);
+		err = 0;
+#endif
+		break;
+	case 1:
+#ifdef CONFIG_USART1
+		at91_set_A_periph(AT91_PIN_PD0, 1);		/* TXD1 */
+		at91_set_A_periph(AT91_PIN_PD1, 0);		/* RXD1 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9263_ID_US1);
+		err = 0;
+#endif
+		break;
+	case 2:
+#ifdef CONFIG_USART2
+		at91_set_A_periph(AT91_PIN_PD2, 1);		/* TXD2 */
+		at91_set_A_periph(AT91_PIN_PD3, 0);		/* RXD2 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9263_ID_US2);
+		err = 0;
+#endif
+		break;
+	case 3:
+#ifdef CONFIG_USART3	/* DBGU */
+		at91_set_A_periph(AT91_PIN_PC30, 0);		/* DRXD */
+		at91_set_A_periph(AT91_PIN_PC31, 1);		/* DTXD */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+		err = 0;
+#endif
+		break;
+	default:
+		printf(" uart%d configuration failled\n", err);
+	}
+
+	return err;
+}
diff --git a/cpu/arm926ejs/at91/at91sam9263_spi.c b/cpu/arm926ejs/at91/at91sam9263_spi.c
new file mode 100644
index 0000000..b01541c
--- /dev/null
+++ b/cpu/arm926ejs/at91/at91sam9263_spi.c
@@ -0,0 +1,41 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+void at91_spi_hw_init(void)
+{
+	at91_set_B_periph(AT91_PIN_PA5, 0);	/* SPI0_NPCS0 */
+
+	at91_set_B_periph(AT91_PIN_PA0, 0);	/* SPI0_MISO */
+	at91_set_B_periph(AT91_PIN_PA1, 0);	/* SPI0_MOSI */
+	at91_set_B_periph(AT91_PIN_PA2, 0);	/* SPI0_SPCK */
+
+	/* Enable clock */
+	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9263_ID_SPI0);
+}
diff --git a/cpu/arm926ejs/at91/at91sam9rl_serial.c b/cpu/arm926ejs/at91/at91sam9rl_serial.c
new file mode 100644
index 0000000..0effb8d
--- /dev/null
+++ b/cpu/arm926ejs/at91/at91sam9rl_serial.c
@@ -0,0 +1,73 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+int at91_serial_hw_init(int uart)
+{
+	int err = -1;
+
+	switch(uart) {
+	case 0:
+#ifdef CONFIG_USART0
+		at91_set_A_periph(AT91_PIN_PA6, 1);		/* TXD0 */
+		at91_set_A_periph(AT91_PIN_PA7, 0);		/* RXD0 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9RL_ID_US0);
+		err = 0;
+#endif
+		break;
+	case 1:
+#ifdef CONFIG_USART1
+		at91_set_A_periph(AT91_PIN_PA11, 1);		/* TXD1 */
+		at91_set_A_periph(AT91_PIN_PA12, 0);		/* RXD1 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9RL_ID_US1);
+		err = 0;
+#endif
+		break;
+	case 2:
+#ifdef CONFIG_USART2
+		at91_set_A_periph(AT91_PIN_PA13, 1);		/* TXD2 */
+		at91_set_A_periph(AT91_PIN_PA14, 0);		/* RXD2 */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9RL_ID_US2);
+		err = 0;
+#endif
+		break;
+	case 3:
+#ifdef CONFIG_USART3	/* DBGU */
+		at91_set_A_periph(AT91_PIN_PA21, 0);		/* DRXD */
+		at91_set_A_periph(AT91_PIN_PA22, 1);		/* DTXD */
+		at91_sys_write(AT91_PMC_PCER, 1 << AT91_ID_SYS);
+		err = 0;
+#endif
+		break;
+	default:
+		printf(" uart%d configuration failled\n", err);
+	}
+
+	return err;
+}
diff --git a/cpu/arm926ejs/at91/at91sam9rl_spi.c b/cpu/arm926ejs/at91/at91sam9rl_spi.c
new file mode 100644
index 0000000..8196092
--- /dev/null
+++ b/cpu/arm926ejs/at91/at91sam9rl_spi.c
@@ -0,0 +1,41 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_pmc.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+
+void at91_spi_hw_init(void)
+{
+	at91_set_A_periph(AT91_PIN_PA28, 0);	/* SPI0_NPCS0 */
+
+	at91_set_A_periph(AT91_PIN_PA25, 0);	/* SPI0_MISO */
+	at91_set_A_periph(AT91_PIN_PA26, 0);	/* SPI0_MOSI */
+	at91_set_A_periph(AT91_PIN_PA27, 0);	/* SPI0_SPCK */
+
+	/* Enable clock */
+	at91_sys_write(AT91_PMC_PCER, 1 << AT91SAM9RL_ID_SPI);
+}
diff --git a/include/asm-arm/arch-at91/at91_common.h b/include/asm-arm/arch-at91/at91_common.h
new file mode 100644
index 0000000..507e4d3
--- /dev/null
+++ b/include/asm-arm/arch-at91/at91_common.h
@@ -0,0 +1,31 @@
+/*
+ * (C) Copyright 2007-2008
+ * Stelian Pop <stelian.pop@leadtechdesign.com>
+ * Lead Tech Design <www.leadtechdesign.com>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef AT91_COMMON_H
+#define AT91_COMMON_H
+
+int at91_serial_hw_init(int uart);
+void at91_spi_hw_init(void);
+
+#endif /* AT91_COMMON_H */
-- 
1.5.6.5

             reply	other threads:[~2008-11-07 19:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-07 19:38 Jean-Christophe PLAGNIOL-VILLARD [this message]
2008-11-13 21:28 ` [U-Boot] [PATCH RFC] at91sam9/at91cap: move common initialisation to cpu Stelian Pop
2008-11-13 22:32   ` Jean-Christophe PLAGNIOL-VILLARD
2008-11-14  9:17     ` Stelian Pop
2008-11-16 12:28   ` Remy Bohmer
2009-02-05 21:38 ` Jean-Christophe PLAGNIOL-VILLARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1226086706-5419-1-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.