at91sam9/at91cap: move common initialisation to cpu
RFC PATCH 1/1 at91sam9/at91cap: move common initialisation to cpu
---
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
board/afeb9260/afeb9260.c +6 -26
@@ -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
board/atmel/at91cap9adk/at91cap9adk.c +6 -27
@@ -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 ();
board/atmel/at91sam9260ek/at91sam9260ek.c +6 -28
@@ -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 ();
board/atmel/at91sam9261ek/at91sam9261ek.c +6 -27
@@ -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 ();
board/atmel/at91sam9263ek/at91sam9263ek.c +6 -27
@@ -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 ();
board/atmel/at91sam9rlek/at91sam9rlek.c +6 -27
@@ -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 ();
cpu/arm926ejs/at91/Makefile +18 -1
@@ -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
cpu/arm926ejs/at91/at91cap9_serial.c new file +73 -0
73 lines not on this page · raw message
cpu/arm926ejs/at91/at91cap9_spi.c new file +41 -0
41 lines not on this page · raw message
cpu/arm926ejs/at91/at91sam9260_serial.c new file +73 -0
73 lines not on this page · raw message
cpu/arm926ejs/at91/at91sam9260_spi.c new file +42 -0
42 lines not on this page · raw message
cpu/arm926ejs/at91/at91sam9261_serial.c new file +73 -0
73 lines not on this page · raw message
cpu/arm926ejs/at91/at91sam9261_spi.c new file +41 -0
41 lines not on this page · raw message
cpu/arm926ejs/at91/at91sam9263_serial.c new file +73 -0
73 lines not on this page · raw message
cpu/arm926ejs/at91/at91sam9263_spi.c new file +41 -0
41 lines not on this page · raw message
cpu/arm926ejs/at91/at91sam9rl_serial.c new file +73 -0
73 lines not on this page · raw message
cpu/arm926ejs/at91/at91sam9rl_spi.c new file +41 -0
41 lines not on this page · raw message
include/asm-arm/arch-at91/at91_common.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* (C) Copyright 2007-2008 +* Stelian Pop <[email protected]> +* 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 */
Signature · 1 line
1.5.6.5
RFC PATCH 1/1 at91sam9/at91cap: move common initialisation to cpu
Le vendredi 07 novembre 2008 ? 20:38 +0100, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
Quoted 4 lines
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>---
The idea is to reduce common code initialisation which is actually in board. as done onafeb9260and Ronetix eval board for 9260 & 9263
[...]
I agree with the general idea of moving the serial and spi from board specific files to the cpu specific files.
Note however that serial and spi are not the only initialisations that can be moved: the very same thing can be done with all the other device initialisations. Some devices will need to specify which GPIOs are used when it's board specific, and this can be passed as arguments to the cpu specfic function. One can look at the Linux kernel files which nicely separates the cpu specific GPIOs (in arch/arm/mach-at91/XXX_devices.c) and the board specific GPIOs (in arch/arm/mach-at91/board-YYY.c). Or one can also RTFM of course.
I also don't like this:
board/atmel/at91cap9adk/at91cap9adk.c DECLARE_GLOBAL_DATA_PTR; · line 55
Quoted 9 lines
board/atmel/at91cap9adk/at91cap9adk.c +1
-3#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
Why don't just do at91_serial_hw_init() once, and test the CONFIG_USART* inside the cpu specific at91_serial_hw_init function() ?
This also eliminates that unneeded switch case in that function.
Stelian.
Signature · 1 line
Stelian Pop <[email protected]>
RFC PATCH 1/1 at91sam9/at91cap: move common initialisation to cpu
Quoted 8 lines · Stelian Pop
Le vendredi 07 novembre 2008 ? 20:38 +0100, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
Quoted 4 lines
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>---
The idea is to reduce common code initialisation which is actually in board. as done onafeb9260and Ronetix eval board for 9260 & 9263
Quoted 8 lines
[...]
I agree with the general idea of moving the serial and spi from board specific files to the cpu specific files.
Note however that serial and spi are not the only initialisations that can be moved: the very same thing can be done with all the other device initialisations.
I've just put serial & spi for the RFC
Quoted 5 lines
Some devices will need to specify which GPIOs are used
when it's board specific, and this can be passed as arguments to the cpu specfic function. One can look at the Linux kernel files which nicely separates the cpu specific GPIOs (inarch/arm/mach-at91/XXX_devices.c) and the board specific GPIOs (inarch/arm/mach-at91/board-YYY.c).
This the idea
Quoted 16 lines
I also don't like this:
board/atmel/at91cap9adk/at91cap9adk.c DECLARE_GLOBAL_DATA_PTR; · line 55
Quoted 9 lines
board/atmel/at91cap9adk/at91cap9adk.c +1
-3#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 Why don't just do
at91_serial_hw_init()once, and test the CONFIG_USART* inside the cpu specificat91_serial_hw_initfunction()?
Quoted 1 line
This also eliminates that unneeded switch case in that function.
The idea is too allow multiple serial at the same time.
I've plan to add the multi serial support to the at91 serial drivers
Best Regards,
J.
RFC PATCH 1/1 at91sam9/at91cap: move common initialisation to cpu
Le jeudi 13 novembre 2008 ? 23:32 +0100, Jean-Christophe PLAGNIOL-VILLARD a ?crit :
Quoted 4 lines
Quoted 3 lines
Note however that serial and spi are not the only initialisations that can be moved: the very same thing can be done with all the other device initialisations.
I've just put serial & spi for the RFC
Ok then.
[...]
Quoted 7 lines
Quoted 4 lines
Why don't just do
at91_serial_hw_init()once, and test the CONFIG_USART* inside the cpu specificat91_serial_hw_initfunction()?This also eliminates that unneeded switch case in that function.
The idea is too allow multiple serial at the same time.
I've plan to add the multi serial support to the at91 serial drivers
I'm not sure exactly what you mean by "multi serial support" but isn't this orthogonal to what I'm saying (putting the #ifdef CONFIG_USART0 inside the cpu specific file instead of board specific file) ?
Stelian.
Signature · 1 line
Stelian Pop <[email protected]>
RFC PATCH 1/1 at91sam9/at91cap: move common initialisation to cpu
In reply to Stelian PopHello Stelian and Jean-Christophe,
Quoted 2 lines
I agree with the general idea of moving the serial and spi from board specific files to the cpu specific files.
I agree partly on this, but I do not like with the way this patch is doing it, and this is the reason why:
PIN multiplexing is board specific, not only SoC specific. pins can be multiplexed in different ways per board per SoC.
In this patch all this 'knowledge' is moved to the generic SoC code, where the assumption is made that all boards use the same pin layout. This is _not_ true; in the generic code is, for example(!!), assumed that all 9261 SoC derived boards only configure NPCS0, while a board can utilise all NPCS pins and can have multiple dataflashes. It may be true that all boards, currently existing in U-boot, use a similar pin layout per SoC, but that does not mean that that is a valid assumption for all future boards. The framework should be that flexible that boards that are currently not in mainline can be added in the future, without reverting patches like this, or creating standalone copies from this framework. We should make it easier for others to integrate their custom boards, instead of making it harder...
The current code makes it very easy to create custom boards, this patch makes that harder!
So, in short: pin layout must be specified by the board specific files, not by the generic SoC code, although the generic SoC code can provide (all) the possible options to choose from...
Kind Regards,
Remy
Quoted 36 lines
Note however that serial and spi are not the only initialisations that can be moved: the very same thing can be done with all the other device initialisations. Some devices will need to specify which GPIOs are used when it's board specific, and this can be passed as arguments to the cpu specfic function. One can look at the Linux kernel files which nicely separates the cpu specific GPIOs (in
arch/arm/mach-at91/XXX_devices.c) and the board specific GPIOs (inarch/arm/mach-at91/board-YYY.c). Or one can also RTFM of course.I also don't like this:
board/atmel/at91cap9adk/at91cap9adk.c DECLARE_GLOBAL_DATA_PTR; · line 55
Quoted 9 lines
board/atmel/at91cap9adk/at91cap9adk.c +1
-3#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 Why don't just do
at91_serial_hw_init()once, and test the CONFIG_USART* inside the cpu specificat91_serial_hw_initfunction()?This also eliminates that unneeded switch case in that function.
Stelian.
--
Stelian Pop <[email protected]>_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
RFC PATCH 1/1 at91sam9/at91cap: move common initialisation to cpu
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 2 lines · Jean-Christophe PLAGNIOL-VILLARD
Signed-off-by Jean-Christophe PLAGNIOL-VILLARD <[email protected]>---
The idea is to reduce common code initialisation which is actually in board. as done on afeb9260 and Ronetix eval board for 9260 & 9263
Any help to improve and continue this work is welcome
Best Regards,
J.