[U-Boot] [PATCH] at91sam9/at91cap: add new spi framework and spi flash support

The new Framework is not yet activated by default, it will be next release at the same time of the removal of the DATAFLASH support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com --- board/afeb9260/afeb9260.c | 40 +++++++++++++++++++++++++++++ board/atmel/at91cap9adk/at91cap9adk.c | 24 ++++++++++++++++- board/atmel/at91sam9260ek/at91sam9260ek.c | 40 ++++++++++++++++++++++++++++- board/atmel/at91sam9261ek/at91sam9261ek.c | 40 ++++++++++++++++++++++++++++- board/atmel/at91sam9263ek/at91sam9263ek.c | 26 ++++++++++++++++++- board/atmel/at91sam9rlek/at91sam9rlek.c | 24 ++++++++++++++++- board/ronetix/pm9263/pm9263.c | 24 ++++++++++++++++- cpu/arm926ejs/at91/Makefile | 6 ++++ include/asm-arm/arch-at91/clk.h | 5 +++ include/asm-arm/arch-at91/hardware.h | 9 ++++++ include/configs/afeb9260.h | 7 +++++ include/configs/at91cap9adk.h | 7 +++++ include/configs/at91sam9260ek.h | 7 +++++ include/configs/at91sam9261ek.h | 7 +++++ include/configs/at91sam9263ek.h | 7 +++++ include/configs/at91sam9rlek.h | 7 +++++ include/configs/pm9263.h | 7 +++++ 17 files changed, 281 insertions(+), 6 deletions(-)
diff --git a/board/afeb9260/afeb9260.c b/board/afeb9260/afeb9260.c index 024db2b..d1606b6 100644 --- a/board/afeb9260/afeb9260.c +++ b/board/afeb9260/afeb9260.c @@ -145,7 +145,11 @@ int board_init(void) #ifdef CONFIG_CMD_NAND afeb9260_nand_hw_init(); #endif +#if defined(CONFIG_ATMEL_SPI) + at91_spi0_hw_init((1 << 4) || (1 << 5)); +#elif defined(CONFIG_HAS_DATAFLASH) at91_spi0_hw_init((1 << 0) || (1 << 1)); +#endif #ifdef CONFIG_MACB afeb9260_macb_hw_init(); #endif @@ -181,3 +185,39 @@ int board_eth_init(bd_t *bis) #endif return rc; } + +/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h> + +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + return bus == 0 && cs < 2; +} + +void spi_cs_activate(struct spi_slave *slave) +{ + switch(slave->cs) { + case 1: + at91_set_gpio_value(AT91_PIN_PC11, 0); + break; + case 0: + default: + at91_set_gpio_value(AT91_PIN_PA3, 0); + break; + } +} + +void spi_cs_deactivate(struct spi_slave *slave) +{ + switch(slave->cs) { + case 1: + at91_set_gpio_value(AT91_PIN_PC11, 1); + break; + case 0: + default: + at91_set_gpio_value(AT91_PIN_PA3, 1); + break; + } +} +#endif /* CONFIG_ATMEL_SPI */ diff --git a/board/atmel/at91cap9adk/at91cap9adk.c b/board/atmel/at91cap9adk/at91cap9adk.c index f52edaa..1e99bba 100644 --- a/board/atmel/at91cap9adk/at91cap9adk.c +++ b/board/atmel/at91cap9adk/at91cap9adk.c @@ -315,7 +315,9 @@ int board_init(void) #ifdef CONFIG_CMD_NAND at91cap9_nand_hw_init(); #endif -#ifdef CONFIG_HAS_DATAFLASH +#if defined(CONFIG_ATMEL_SPI) + at91_spi0_hw_init(1 << 4); +#elif defined(CONFIG_HAS_DATAFLASH) at91_spi0_hw_init(1 << 0); #endif #ifdef CONFIG_MACB @@ -358,3 +360,23 @@ int board_eth_init(bd_t *bis) #endif return rc; } + +/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h> + +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + return bus == 0 && cs == 0; +} + +void spi_cs_activate(struct spi_slave *slave) +{ + at91_set_gpio_value(AT91_PIN_PA5, 0); +} + +void spi_cs_deactivate(struct spi_slave *slave) +{ + at91_set_gpio_value(AT91_PIN_PA5, 1); +} +#endif /* CONFIG_ATMEL_SPI */ diff --git a/board/atmel/at91sam9260ek/at91sam9260ek.c b/board/atmel/at91sam9260ek/at91sam9260ek.c index 6bd3b44..c4eaafd 100644 --- a/board/atmel/at91sam9260ek/at91sam9260ek.c +++ b/board/atmel/at91sam9260ek/at91sam9260ek.c @@ -155,7 +155,9 @@ int board_init(void) #ifdef CONFIG_CMD_NAND at91sam9260ek_nand_hw_init(); #endif -#ifdef CONFIG_HAS_DATAFLASH +#if defined(CONFIG_ATMEL_SPI) + at91_spi0_hw_init((1 << 4) || (1 << 5)); +#elif defined(CONFIG_HAS_DATAFLASH) at91_spi0_hw_init((1 << 0) || (1 << 1)); #endif #ifdef CONFIG_MACB @@ -193,3 +195,39 @@ int board_eth_init(bd_t *bis) #endif return rc; } + +/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h> + +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + return bus == 0 && cs < 2; +} + +void spi_cs_activate(struct spi_slave *slave) +{ + switch(slave->cs) { + case 1: + at91_set_gpio_value(AT91_PIN_PC11, 0); + break; + case 0: + default: + at91_set_gpio_value(AT91_PIN_PA3, 0); + break; + } +} + +void spi_cs_deactivate(struct spi_slave *slave) +{ + switch(slave->cs) { + case 1: + at91_set_gpio_value(AT91_PIN_PC11, 1); + break; + case 0: + default: + at91_set_gpio_value(AT91_PIN_PA3, 1); + break; + } +} +#endif /* CONFIG_ATMEL_SPI */ diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c b/board/atmel/at91sam9261ek/at91sam9261ek.c index a89cb8b..9d31324 100644 --- a/board/atmel/at91sam9261ek/at91sam9261ek.c +++ b/board/atmel/at91sam9261ek/at91sam9261ek.c @@ -215,7 +215,9 @@ int board_init(void) #ifdef CONFIG_CMD_NAND at91sam9261ek_nand_hw_init(); #endif -#ifdef CONFIG_HAS_DATAFLASH +#if defined(CONFIG_ATMEL_SPI) + at91_spi0_hw_init((1 << 4) || (1 << 7)); +#elif defined(CONFIG_HAS_DATAFLASH) at91_spi0_hw_init(1 << 0); #endif #ifdef CONFIG_DRIVER_DM9000 @@ -246,3 +248,39 @@ void reset_phy(void) #endif } #endif + +/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h> + +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + return bus == 0 && (cs == 0 || cs == 3); +} + +void spi_cs_activate(struct spi_slave *slave) +{ + switch(slave->cs) { + case 3: + at91_set_gpio_value(AT91_PIN_PA6, 0); + break; + case 0: + default: + at91_set_gpio_value(AT91_PIN_PA3, 0); + break; + } +} + +void spi_cs_deactivate(struct spi_slave *slave) +{ + switch(slave->cs) { + case 3: + at91_set_gpio_value(AT91_PIN_PA6, 1); + break; + case 0: + default: + at91_set_gpio_value(AT91_PIN_PA3, 1); + break; + } +} +#endif /* CONFIG_ATMEL_SPI */ diff --git a/board/atmel/at91sam9263ek/at91sam9263ek.c b/board/atmel/at91sam9263ek/at91sam9263ek.c index 57d5c95..e9c73af 100644 --- a/board/atmel/at91sam9263ek/at91sam9263ek.c +++ b/board/atmel/at91sam9263ek/at91sam9263ek.c @@ -236,10 +236,14 @@ int board_init(void) #ifdef CONFIG_CMD_NAND at91sam9263ek_nand_hw_init(); #endif -#ifdef CONFIG_HAS_DATAFLASH +#if defined(CONFIG_HAS_DATAFLASH) || defined(CONFIG_ATMEL_SPI) at91_set_gpio_output(AT91_PIN_PE20, 1); /* select spi0 clock */ +#if defined(CONFIG_ATMEL_SPI) + at91_spi0_hw_init(1 << 4); +#else at91_spi0_hw_init(1 << 0); #endif +#endif #ifdef CONFIG_MACB at91sam9263ek_macb_hw_init(); #endif @@ -280,3 +284,23 @@ int board_eth_init(bd_t *bis) #endif return rc; } + +/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h> + +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + return bus == 0 && cs == 0; +} + +void spi_cs_activate(struct spi_slave *slave) +{ + at91_set_gpio_value(AT91_PIN_PA5, 0); +} + +void spi_cs_deactivate(struct spi_slave *slave) +{ + at91_set_gpio_value(AT91_PIN_PA5, 1); +} +#endif /* CONFIG_ATMEL_SPI */ diff --git a/board/atmel/at91sam9rlek/at91sam9rlek.c b/board/atmel/at91sam9rlek/at91sam9rlek.c index 7013ba2..35adfcd 100644 --- a/board/atmel/at91sam9rlek/at91sam9rlek.c +++ b/board/atmel/at91sam9rlek/at91sam9rlek.c @@ -188,7 +188,9 @@ int board_init(void) #ifdef CONFIG_CMD_NAND at91sam9rlek_nand_hw_init(); #endif -#ifdef CONFIG_HAS_DATAFLASH +#if defined(CONFIG_ATMEL_SPI) + at91_spi0_hw_init(1 << 4); +#elif defined(CONFIG_HAS_DATAFLASH) at91_spi0_hw_init(1 << 0); #endif #ifdef CONFIG_LCD @@ -203,3 +205,23 @@ int dram_init(void) gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE; return 0; } + +/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h> + +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + return bus == 0 && cs == 0; +} + +void spi_cs_activate(struct spi_slave *slave) +{ + at91_set_gpio_value(AT91_PIN_PA28, 0); +} + +void spi_cs_deactivate(struct spi_slave *slave) +{ + at91_set_gpio_value(AT91_PIN_PA28, 1); +} +#endif /* CONFIG_ATMEL_SPI */ diff --git a/board/ronetix/pm9263/pm9263.c b/board/ronetix/pm9263/pm9263.c index 801b268..c16bea0 100644 --- a/board/ronetix/pm9263/pm9263.c +++ b/board/ronetix/pm9263/pm9263.c @@ -334,7 +334,9 @@ int board_init(void) #ifdef CONFIG_CMD_NAND pm9263_nand_hw_init(); #endif -#ifdef CONFIG_HAS_DATAFLASH +#if defined(CONFIG_ATMEL_SPI) + at91_spi0_hw_init(1 << 4); +#elif defined(CONFIG_HAS_DATAFLASH) at91_spi0_hw_init(1 << 0); #endif #ifdef CONFIG_MACB @@ -411,3 +413,23 @@ int checkboard (void) return 0; } #endif + +/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h> + +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + return bus == 0 && cs == 0; +} + +void spi_cs_activate(struct spi_slave *slave) +{ + at91_set_gpio_value(AT91_PIN_PA5, 0); +} + +void spi_cs_deactivate(struct spi_slave *slave) +{ + at91_set_gpio_value(AT91_PIN_PA5, 1); +} +#endif /* CONFIG_ATMEL_SPI */ diff --git a/cpu/arm926ejs/at91/Makefile b/cpu/arm926ejs/at91/Makefile index fbc82d1..e73f450 100644 --- a/cpu/arm926ejs/at91/Makefile +++ b/cpu/arm926ejs/at91/Makefile @@ -28,30 +28,36 @@ LIB = $(obj)lib$(SOC).a ifdef CONFIG_AT91CAP9 COBJS-$(CONFIG_MACB) += at91cap9_macb.o COBJS-y += at91cap9_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91cap9_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91cap9_spi.o endif ifdef CONFIG_AT91SAM9260 COBJS-$(CONFIG_MACB) += at91sam9260_macb.o COBJS-y += at91sam9260_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9260_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9260_spi.o endif ifdef CONFIG_AT91SAM9G20 COBJS-$(CONFIG_MACB) += at91sam9260_macb.o COBJS-y += at91sam9260_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9260_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9260_spi.o endif ifdef CONFIG_AT91SAM9261 COBJS-y += at91sam9261_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9261_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9261_spi.o endif ifdef CONFIG_AT91SAM9263 COBJS-$(CONFIG_MACB) += at91sam9263_macb.o COBJS-y += at91sam9263_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9263_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9263_spi.o COBJS-$(CONFIG_USB_OHCI_NEW) += at91sam9263_usb.o endif ifdef CONFIG_AT91SAM9RL COBJS-y += at91sam9rl_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9rl_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9rl_spi.o endif COBJS-$(CONFIG_AT91_LED) += led.o diff --git a/include/asm-arm/arch-at91/clk.h b/include/asm-arm/arch-at91/clk.h index 6aaf82e..f642dd9 100644 --- a/include/asm-arm/arch-at91/clk.h +++ b/include/asm-arm/arch-at91/clk.h @@ -49,6 +49,11 @@ static inline unsigned long get_lcdc_clk_rate(unsigned int dev_id) return get_mck_clk_rate(); }
+static inline unsigned long get_spi_clk_rate(unsigned int dev_id) +{ + return get_mck_clk_rate(); +} + static inline unsigned long get_twi_clk_rate(unsigned int dev_id) { return get_mck_clk_rate(); diff --git a/include/asm-arm/arch-at91/hardware.h b/include/asm-arm/arch-at91/hardware.h index 8704106..0403b09 100644 --- a/include/asm-arm/arch-at91/hardware.h +++ b/include/asm-arm/arch-at91/hardware.h @@ -21,25 +21,34 @@ #elif defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9G20) #include <asm/arch/at91sam9260.h> #define AT91_BASE_SPI AT91SAM9260_BASE_SPI0 +#define SPI0_BASE AT91SAM9260_BASE_SPI0 +#define SPI1_BASE AT91SAM9260_BASE_SPI1 #define AT91_ID_UHP AT91SAM9260_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9261) #include <asm/arch/at91sam9261.h> #define AT91_BASE_SPI AT91SAM9261_BASE_SPI0 +#define SPI0_BASE AT91SAM9261_BASE_SPI0 +#define SPI1_BASE AT91SAM9261_BASE_SPI1 #define AT91_ID_UHP AT91SAM9261_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9263) #include <asm/arch/at91sam9263.h> #define AT91_BASE_SPI AT91SAM9263_BASE_SPI0 +#define SPI0_BASE AT91SAM9263_BASE_SPI0 +#define SPI1_BASE AT91SAM9263_BASE_SPI1 #define AT91_ID_UHP AT91SAM9263_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9RL) #include <asm/arch/at91sam9rl.h> #define AT91_BASE_SPI AT91SAM9RL_BASE_SPI +#define SPI0_BASE AT91SAM9RL_BASE_SPI #define AT91_ID_UHP AT91SAM9RL_ID_UHP #elif defined(CONFIG_AT91CAP9) #include <asm/arch/at91cap9.h> #define AT91_BASE_SPI AT91CAP9_BASE_SPI0 +#define SPI0_BASE AT91CAP9_BASE_SPI0 +#define SPI1_BASE AT91CAP9_BASE_SPI1 #define AT91_ID_UHP AT91CAP9_ID_UHP #define AT91_PMC_UHP AT91CAP9_PMC_UHP #elif defined(CONFIG_AT91X40) diff --git a/include/configs/afeb9260.h b/include/configs/afeb9260.h index 89b16fe..a897c62 100644 --- a/include/configs/afeb9260.h +++ b/include/configs/afeb9260.h @@ -84,6 +84,12 @@ #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */
/* DataFlash */ +#ifdef CONFIG_ATMEL_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI +#define CONFIG_SPI_FLASH 1 +#define CONFIG_SPI_FLASH_ATMEL 1 +#else #define CONFIG_ATMEL_DATAFLASH_SPI #define CONFIG_HAS_DATAFLASH 1 #define CONFIG_SYS_SPI_WRITE_TOUT (5 * CONFIG_SYS_HZ) @@ -93,6 +99,7 @@ #define AT91_SPI_CLK 15000000 #define DATAFLASH_TCSS (0x1a << 16) #define DATAFLASH_TCHS (0x1 << 24) +#endif
/* NAND flash */ #ifdef CONFIG_CMD_NAND diff --git a/include/configs/at91cap9adk.h b/include/configs/at91cap9adk.h index 749c5a9..758a779 100644 --- a/include/configs/at91cap9adk.h +++ b/include/configs/at91cap9adk.h @@ -103,6 +103,12 @@ #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */
/* DataFlash */ +#ifdef CONFIG_ATMEL_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI +#define CONFIG_SPI_FLASH 1 +#define CONFIG_SPI_FLASH_ATMEL 1 +#else #define CONFIG_ATMEL_DATAFLASH_SPI #define CONFIG_HAS_DATAFLASH 1 #define CONFIG_SYS_SPI_WRITE_TOUT (5*CONFIG_SYS_HZ) @@ -111,6 +117,7 @@ #define AT91_SPI_CLK 15000000 #define DATAFLASH_TCSS (0x1a << 16) #define DATAFLASH_TCHS (0x1 << 24) +#endif
/* NOR flash */ #define CONFIG_SYS_FLASH_CFI 1 diff --git a/include/configs/at91sam9260ek.h b/include/configs/at91sam9260ek.h index 2e49455..240f888 100644 --- a/include/configs/at91sam9260ek.h +++ b/include/configs/at91sam9260ek.h @@ -97,6 +97,12 @@ #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */
/* DataFlash */ +#ifdef CONFIG_ATMEL_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI +#define CONFIG_SPI_FLASH 1 +#define CONFIG_SPI_FLASH_ATMEL 1 +#else #define CONFIG_ATMEL_DATAFLASH_SPI #define CONFIG_HAS_DATAFLASH 1 #define CONFIG_SYS_SPI_WRITE_TOUT (5*CONFIG_SYS_HZ) @@ -111,6 +117,7 @@ #define DATAFLASH_TCSS (0x1a << 16) #endif #define DATAFLASH_TCHS (0x1 << 24) +#endif
/* NAND flash */ #ifdef CONFIG_CMD_NAND diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h index b890912..f2843b7 100644 --- a/include/configs/at91sam9261ek.h +++ b/include/configs/at91sam9261ek.h @@ -104,6 +104,12 @@ #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */
/* DataFlash */ +#ifdef CONFIG_ATMEL_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI +#define CONFIG_SPI_FLASH 1 +#define CONFIG_SPI_FLASH_ATMEL 1 +#else #define CONFIG_ATMEL_DATAFLASH_SPI #define CONFIG_HAS_DATAFLASH 1 #define CONFIG_SYS_SPI_WRITE_TOUT (5*CONFIG_SYS_HZ) @@ -113,6 +119,7 @@ #define AT91_SPI_CLK 15000000 #define DATAFLASH_TCSS (0x1a << 16) #define DATAFLASH_TCHS (0x1 << 24) +#endif
/* NAND flash */ #ifdef CONFIG_CMD_NAND diff --git a/include/configs/at91sam9263ek.h b/include/configs/at91sam9263ek.h index d86f2c5..3d035fc 100644 --- a/include/configs/at91sam9263ek.h +++ b/include/configs/at91sam9263ek.h @@ -104,6 +104,12 @@ #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */
/* DataFlash */ +#ifdef CONFIG_ATMEL_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI +#define CONFIG_SPI_FLASH 1 +#define CONFIG_SPI_FLASH_ATMEL 1 +#else #define CONFIG_ATMEL_DATAFLASH_SPI #define CONFIG_HAS_DATAFLASH 1 #define CONFIG_SYS_SPI_WRITE_TOUT (5*CONFIG_SYS_HZ) @@ -112,6 +118,7 @@ #define AT91_SPI_CLK 15000000 #define DATAFLASH_TCSS (0x1a << 16) #define DATAFLASH_TCHS (0x1 << 24) +#endif
/* NOR flash, if populated */ #if 1 diff --git a/include/configs/at91sam9rlek.h b/include/configs/at91sam9rlek.h index 728f73f..386e7c0 100644 --- a/include/configs/at91sam9rlek.h +++ b/include/configs/at91sam9rlek.h @@ -95,6 +95,12 @@ #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */
/* DataFlash */ +#ifdef CONFIG_ATMEL_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI +#define CONFIG_SPI_FLASH 1 +#define CONFIG_SPI_FLASH_ATMEL 1 +#else #define CONFIG_ATMEL_DATAFLASH_SPI #define CONFIG_HAS_DATAFLASH 1 #define CONFIG_SYS_SPI_WRITE_TOUT (5*CONFIG_SYS_HZ) @@ -103,6 +109,7 @@ #define AT91_SPI_CLK 15000000 #define DATAFLASH_TCSS (0x1a << 16) #define DATAFLASH_TCHS (0x1 << 24) +#endif
/* NOR flash - not present */ #define CONFIG_SYS_NO_FLASH 1 diff --git a/include/configs/pm9263.h b/include/configs/pm9263.h index 9ae737f..33e320c 100644 --- a/include/configs/pm9263.h +++ b/include/configs/pm9263.h @@ -184,6 +184,12 @@ #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */
/* DataFlash */ +#ifdef CONFIG_ATMEL_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI +#define CONFIG_SPI_FLASH 1 +#define CONFIG_SPI_FLASH_ATMEL 1 +#else #define CONFIG_ATMEL_DATAFLASH_SPI #define CONFIG_HAS_DATAFLASH 1 #define CONFIG_SYS_SPI_WRITE_TOUT (5 * CONFIG_SYS_HZ) @@ -192,6 +198,7 @@ #define AT91_SPI_CLK 15000000 #define DATAFLASH_TCSS (0x1a << 16) #define DATAFLASH_TCHS (0x1 << 24) +#endif
/* NOR flash, if populated */ #define CONFIG_SYS_FLASH_CFI 1

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1238840105-19029-1-git-send-email-plagnioj@jcrosoft.com you wrote:
The new Framework is not yet activated by default, it will be next release at the same time of the removal of the DATAFLASH support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
... ...
diff --git a/board/afeb9260/afeb9260.c b/board/afeb9260/afeb9260.c index 024db2b..d1606b6 100644 --- a/board/afeb9260/afeb9260.c +++ b/board/afeb9260/afeb9260.c
...
+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
Please no #includes in the middle of the file.
+int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{
- return bus == 0 && cs < 2;
+}
+void spi_cs_activate(struct spi_slave *slave) +{
- switch(slave->cs) {
- case 1:
at91_set_gpio_value(AT91_PIN_PC11, 0);
break;
- case 0:
- default:
at91_set_gpio_value(AT91_PIN_PA3, 0);
break;
- }
+}
+void spi_cs_deactivate(struct spi_slave *slave) +{
- switch(slave->cs) {
- case 1:
at91_set_gpio_value(AT91_PIN_PC11, 1);
break;
- case 0:
- default:
at91_set_gpio_value(AT91_PIN_PA3, 1);
break;
- }
+}
Are these really board specific, or is it likely that we will see the same code for other boards as well?
diff --git a/board/atmel/at91cap9adk/at91cap9adk.c b/board/atmel/at91cap9adk/at91cap9adk.c index f52edaa..1e99bba 100644 --- a/board/atmel/at91cap9adk/at91cap9adk.c +++ b/board/atmel/at91cap9adk/at91cap9adk.c
...
+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
See above.
+int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{
- return bus == 0 && cs == 0;
+}
Duplicated code. Move to common.
+void spi_cs_activate(struct spi_slave *slave) +{
- at91_set_gpio_value(AT91_PIN_PA5, 0);
+}
+void spi_cs_deactivate(struct spi_slave *slave) +{
- at91_set_gpio_value(AT91_PIN_PA5, 1);
+}
How about making these inline?
diff --git a/board/atmel/at91sam9260ek/at91sam9260ek.c b/board/atmel/at91sam9260ek/at91sam9260ek.c index 6bd3b44..c4eaafd 100644 --- a/board/atmel/at91sam9260ek/at91sam9260ek.c +++ b/board/atmel/at91sam9260ek/at91sam9260ek.c
...
+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
See above.
+int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{
- return bus == 0 && cs < 2;
+}
Duplicated code. Move to common.
+void spi_cs_activate(struct spi_slave *slave) +{
- switch(slave->cs) {
- case 1:
at91_set_gpio_value(AT91_PIN_PC11, 0);
break;
- case 0:
- default:
at91_set_gpio_value(AT91_PIN_PA3, 0);
break;
- }
+}
Duplicated code. Move to common.
+void spi_cs_deactivate(struct spi_slave *slave) +{
- switch(slave->cs) {
- case 1:
at91_set_gpio_value(AT91_PIN_PC11, 1);
break;
- case 0:
- default:
at91_set_gpio_value(AT91_PIN_PA3, 1);
break;
- }
+}
Duplicated code. Move to common.
diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c b/board/atmel/at91sam9261ek/at91sam9261ek.c index a89cb8b..9d31324 100644 --- a/board/atmel/at91sam9261ek/at91sam9261ek.c +++ b/board/atmel/at91sam9261ek/at91sam9261ek.c
...
+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
See above.
+int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{
- return bus == 0 && (cs == 0 || cs == 3);
+}
+void spi_cs_activate(struct spi_slave *slave) +{
- switch(slave->cs) {
- case 3:
at91_set_gpio_value(AT91_PIN_PA6, 0);
break;
- case 0:
- default:
at91_set_gpio_value(AT91_PIN_PA3, 0);
break;
- }
+}
+void spi_cs_deactivate(struct spi_slave *slave) +{
- switch(slave->cs) {
- case 3:
at91_set_gpio_value(AT91_PIN_PA6, 1);
break;
- case 0:
- default:
at91_set_gpio_value(AT91_PIN_PA3, 1);
break;
- }
+}
This is again nearly the same code as before.
May be it can be generalized with some parameters so we don;t need to duplicate it again and again?
diff --git a/board/atmel/at91sam9263ek/at91sam9263ek.c b/board/atmel/at91sam9263ek/at91sam9263ek.c index 57d5c95..e9c73af 100644 --- a/board/atmel/at91sam9263ek/at91sam9263ek.c +++ b/board/atmel/at91sam9263ek/at91sam9263ek.c
...
+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
+int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{
- return bus == 0 && cs == 0;
+}
+void spi_cs_activate(struct spi_slave *slave) +{
- at91_set_gpio_value(AT91_PIN_PA5, 0);
+}
+void spi_cs_deactivate(struct spi_slave *slave) +{
- at91_set_gpio_value(AT91_PIN_PA5, 1);
+}
Gain: all repeated code.
+#endif /* CONFIG_ATMEL_SPI */ diff --git a/board/atmel/at91sam9rlek/at91sam9rlek.c b/board/atmel/at91sam9rlek/at91sam9rlek.c index 7013ba2..35adfcd 100644 --- a/board/atmel/at91sam9rlek/at91sam9rlek.c +++ b/board/atmel/at91sam9rlek/at91sam9rlek.c
...
+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
+int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{
- return bus == 0 && cs == 0;
+}
+void spi_cs_activate(struct spi_slave *slave) +{
- at91_set_gpio_value(AT91_PIN_PA28, 0);
+}
+void spi_cs_deactivate(struct spi_slave *slave) +{
- at91_set_gpio_value(AT91_PIN_PA28, 1);
+}
And again.
diff --git a/board/ronetix/pm9263/pm9263.c b/board/ronetix/pm9263/pm9263.c index 801b268..c16bea0 100644 --- a/board/ronetix/pm9263/pm9263.c +++ b/board/ronetix/pm9263/pm9263.c
...
+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
+int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{
- return bus == 0 && cs == 0;
+}
+void spi_cs_activate(struct spi_slave *slave) +{
- at91_set_gpio_value(AT91_PIN_PA5, 0);
+}
+void spi_cs_deactivate(struct spi_slave *slave) +{
- at91_set_gpio_value(AT91_PIN_PA5, 1);
+}
And again.
Sorry, I'm not going to accept this.
diff --git a/cpu/arm926ejs/at91/Makefile b/cpu/arm926ejs/at91/Makefile index fbc82d1..e73f450 100644 --- a/cpu/arm926ejs/at91/Makefile +++ b/cpu/arm926ejs/at91/Makefile @@ -28,30 +28,36 @@ LIB = $(obj)lib$(SOC).a ifdef CONFIG_AT91CAP9 COBJS-$(CONFIG_MACB) += at91cap9_macb.o COBJS-y += at91cap9_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91cap9_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91cap9_spi.o endif ifdef CONFIG_AT91SAM9260 COBJS-$(CONFIG_MACB) += at91sam9260_macb.o COBJS-y += at91sam9260_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9260_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9260_spi.o endif ifdef CONFIG_AT91SAM9G20 COBJS-$(CONFIG_MACB) += at91sam9260_macb.o COBJS-y += at91sam9260_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9260_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9260_spi.o endif ifdef CONFIG_AT91SAM9261 COBJS-y += at91sam9261_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9261_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9261_spi.o endif ifdef CONFIG_AT91SAM9263 COBJS-$(CONFIG_MACB) += at91sam9263_macb.o COBJS-y += at91sam9263_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9263_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9263_spi.o COBJS-$(CONFIG_USB_OHCI_NEW) += at91sam9263_usb.o endif ifdef CONFIG_AT91SAM9RL COBJS-y += at91sam9rl_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9rl_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9rl_spi.o endif COBJS-$(CONFIG_AT91_LED) += led.o
This needs to be cleand up as well. Define some variable for the board name (don't we actually have one already?), and then use a single copy of
COBJS-$(CONFIG_MACB) += $(BOARD)_macb.o COBJS-y += $(BOARD)_serial.o COBJS-$(CONFIG_ATMEL_SPI) += $(BOARD)_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += $(BOARD)_spi.o
instead of such an endless list if "ifdef"ed code.
diff --git a/include/asm-arm/arch-at91/hardware.h b/include/asm-arm/arch-at91/hardware.h index 8704106..0403b09 100644 --- a/include/asm-arm/arch-at91/hardware.h +++ b/include/asm-arm/arch-at91/hardware.h @@ -21,25 +21,34 @@ #elif defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9G20) #include <asm/arch/at91sam9260.h> #define AT91_BASE_SPI AT91SAM9260_BASE_SPI0 +#define SPI0_BASE AT91SAM9260_BASE_SPI0 +#define SPI1_BASE AT91SAM9260_BASE_SPI1 #define AT91_ID_UHP AT91SAM9260_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9261) #include <asm/arch/at91sam9261.h> #define AT91_BASE_SPI AT91SAM9261_BASE_SPI0 +#define SPI0_BASE AT91SAM9261_BASE_SPI0 +#define SPI1_BASE AT91SAM9261_BASE_SPI1 #define AT91_ID_UHP AT91SAM9261_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9263) #include <asm/arch/at91sam9263.h> #define AT91_BASE_SPI AT91SAM9263_BASE_SPI0 +#define SPI0_BASE AT91SAM9263_BASE_SPI0 +#define SPI1_BASE AT91SAM9263_BASE_SPI1 #define AT91_ID_UHP AT91SAM9263_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9RL) #include <asm/arch/at91sam9rl.h> #define AT91_BASE_SPI AT91SAM9RL_BASE_SPI +#define SPI0_BASE AT91SAM9RL_BASE_SPI #define AT91_ID_UHP AT91SAM9RL_ID_UHP #elif defined(CONFIG_AT91CAP9) #include <asm/arch/at91cap9.h> #define AT91_BASE_SPI AT91CAP9_BASE_SPI0 +#define SPI0_BASE AT91CAP9_BASE_SPI0 +#define SPI1_BASE AT91CAP9_BASE_SPI1 #define AT91_ID_UHP AT91CAP9_ID_UHP #define AT91_PMC_UHP AT91CAP9_PMC_UHP #elif defined(CONFIG_AT91X40)
Same here. With a little clever use of macros we probably can get rid of all these "if defined" stuff.
diff --git a/include/configs/afeb9260.h b/include/configs/afeb9260.h index 89b16fe..a897c62 100644 --- a/include/configs/afeb9260.h +++ b/include/configs/afeb9260.h @@ -84,6 +84,12 @@ #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */
/* DataFlash */ +#ifdef CONFIG_ATMEL_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI +#define CONFIG_SPI_FLASH 1 +#define CONFIG_SPI_FLASH_ATMEL 1 +#else
In which way is this board specific configuration when you copy it to all (?) AT91 boards?
Best regards,
Wolfgang Denk

On 21:52 Sat 04 Apr , Wolfgang Denk wrote:
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 1238840105-19029-1-git-send-email-plagnioj@jcrosoft.com you wrote:
The new Framework is not yet activated by default, it will be next release at the same time of the removal of the DATAFLASH support
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD plagnioj@jcrosoft.com
... ...
diff --git a/board/afeb9260/afeb9260.c b/board/afeb9260/afeb9260.c index 024db2b..d1606b6 100644 --- a/board/afeb9260/afeb9260.c +++ b/board/afeb9260/afeb9260.c
...
+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
Please no #includes in the middle of the file.
+int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{
- return bus == 0 && cs < 2;
+}
+void spi_cs_activate(struct spi_slave *slave) +{
- switch(slave->cs) {
- case 1:
at91_set_gpio_value(AT91_PIN_PC11, 0);
break;
- case 0:
- default:
at91_set_gpio_value(AT91_PIN_PA3, 0);
break;
- }
+}
+void spi_cs_deactivate(struct spi_slave *slave) +{
- switch(slave->cs) {
- case 1:
at91_set_gpio_value(AT91_PIN_PC11, 1);
break;
- case 0:
- default:
at91_set_gpio_value(AT91_PIN_PA3, 1);
break;
- }
+}
Are these really board specific, or is it likely that we will see the same code for other boards as well?
yes these code are board specific because you can use the cs you want
diff --git a/board/atmel/at91cap9adk/at91cap9adk.c b/board/atmel/at91cap9adk/at91cap9adk.c index f52edaa..1e99bba 100644 --- a/board/atmel/at91cap9adk/at91cap9adk.c +++ b/board/atmel/at91cap9adk/at91cap9adk.c
...
+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
See above.
+int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{
- return bus == 0 && cs == 0;
+}
Duplicated code. Move to common.
It's board specific
+void spi_cs_activate(struct spi_slave *slave) +{
- at91_set_gpio_value(AT91_PIN_PA5, 0);
+}
+void spi_cs_deactivate(struct spi_slave *slave) +{
- at91_set_gpio_value(AT91_PIN_PA5, 1);
+}
How about making these inline?
it's the spi framework
diff --git a/board/atmel/at91sam9260ek/at91sam9260ek.c b/board/atmel/at91sam9260ek/at91sam9260ek.c index 6bd3b44..c4eaafd 100644 --- a/board/atmel/at91sam9260ek/at91sam9260ek.c +++ b/board/atmel/at91sam9260ek/at91sam9260ek.c
...
index fbc82d1..e73f450 100644 --- a/cpu/arm926ejs/at91/Makefile +++ b/cpu/arm926ejs/at91/Makefile @@ -28,30 +28,36 @@ LIB = $(obj)lib$(SOC).a ifdef CONFIG_AT91CAP9 COBJS-$(CONFIG_MACB) += at91cap9_macb.o COBJS-y += at91cap9_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91cap9_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91cap9_spi.o endif ifdef CONFIG_AT91SAM9260 COBJS-$(CONFIG_MACB) += at91sam9260_macb.o COBJS-y += at91sam9260_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9260_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9260_spi.o endif ifdef CONFIG_AT91SAM9G20 COBJS-$(CONFIG_MACB) += at91sam9260_macb.o COBJS-y += at91sam9260_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9260_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9260_spi.o endif ifdef CONFIG_AT91SAM9261 COBJS-y += at91sam9261_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9261_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9261_spi.o endif ifdef CONFIG_AT91SAM9263 COBJS-$(CONFIG_MACB) += at91sam9263_macb.o COBJS-y += at91sam9263_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9263_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9263_spi.o COBJS-$(CONFIG_USB_OHCI_NEW) += at91sam9263_usb.o endif ifdef CONFIG_AT91SAM9RL COBJS-y += at91sam9rl_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9rl_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9rl_spi.o endif COBJS-$(CONFIG_AT91_LED) += led.o
This needs to be cleand up as well. Define some variable for the board name (don't we actually have one already?), and then use a single copy of
it's not board name it's cpu name
and due to multiple soc support for one file we can not do this
COBJS-$(CONFIG_MACB) += $(BOARD)_macb.o COBJS-y += $(BOARD)_serial.o COBJS-$(CONFIG_ATMEL_SPI) += $(BOARD)_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += $(BOARD)_spi.o
instead of such an endless list if "ifdef"ed code.
diff --git a/include/asm-arm/arch-at91/hardware.h b/include/asm-arm/arch-at91/hardware.h index 8704106..0403b09 100644 --- a/include/asm-arm/arch-at91/hardware.h +++ b/include/asm-arm/arch-at91/hardware.h @@ -21,25 +21,34 @@ #elif defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9G20) #include <asm/arch/at91sam9260.h> #define AT91_BASE_SPI AT91SAM9260_BASE_SPI0 +#define SPI0_BASE AT91SAM9260_BASE_SPI0 +#define SPI1_BASE AT91SAM9260_BASE_SPI1 #define AT91_ID_UHP AT91SAM9260_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9261) #include <asm/arch/at91sam9261.h> #define AT91_BASE_SPI AT91SAM9261_BASE_SPI0 +#define SPI0_BASE AT91SAM9261_BASE_SPI0 +#define SPI1_BASE AT91SAM9261_BASE_SPI1 #define AT91_ID_UHP AT91SAM9261_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9263) #include <asm/arch/at91sam9263.h> #define AT91_BASE_SPI AT91SAM9263_BASE_SPI0 +#define SPI0_BASE AT91SAM9263_BASE_SPI0 +#define SPI1_BASE AT91SAM9263_BASE_SPI1 #define AT91_ID_UHP AT91SAM9263_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9RL) #include <asm/arch/at91sam9rl.h> #define AT91_BASE_SPI AT91SAM9RL_BASE_SPI +#define SPI0_BASE AT91SAM9RL_BASE_SPI #define AT91_ID_UHP AT91SAM9RL_ID_UHP #elif defined(CONFIG_AT91CAP9) #include <asm/arch/at91cap9.h> #define AT91_BASE_SPI AT91CAP9_BASE_SPI0 +#define SPI0_BASE AT91CAP9_BASE_SPI0 +#define SPI1_BASE AT91CAP9_BASE_SPI1 #define AT91_ID_UHP AT91CAP9_ID_UHP #define AT91_PMC_UHP AT91CAP9_PMC_UHP #elif defined(CONFIG_AT91X40)
Same here. With a little clever use of macros we probably can get rid of all these "if defined" stuff.
we can not because it's shared with diffent soc and with AVR32
diff --git a/include/configs/afeb9260.h b/include/configs/afeb9260.h index 89b16fe..a897c62 100644 --- a/include/configs/afeb9260.h +++ b/include/configs/afeb9260.h @@ -84,6 +84,12 @@ #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */
/* DataFlash */ +#ifdef CONFIG_ATMEL_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI +#define CONFIG_SPI_FLASH 1 +#define CONFIG_SPI_FLASH_ATMEL 1 +#else
In which way is this board specific configuration when you copy it to all (?) AT91 boards?
you can enalbe what you want as flash I can not force at91 boards evenif actually they use the same
It's be more generic when we will have Kconfig
Best Regards, J.

Dear Jean-Christophe PLAGNIOL-VILLARD,
In message 20090404194842.GH32409@game.jcrosoft.org you wrote:
Are these really board specific, or is it likely that we will see the same code for other boards as well?
yes these code are board specific because you can use the cs you want
No, it is not, as many boards use exactly the same code.
+int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{
- return bus == 0 && cs == 0;
+}
Duplicated code. Move to common.
It's board specific
It's DUPLICATED.
COBJS-$(CONFIG_MACB) += at91cap9_macb.o COBJS-y += at91cap9_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91cap9_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91cap9_spi.o endif ifdef CONFIG_AT91SAM9260 COBJS-$(CONFIG_MACB) += at91sam9260_macb.o COBJS-y += at91sam9260_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9260_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9260_spi.o endif ifdef CONFIG_AT91SAM9G20 COBJS-$(CONFIG_MACB) += at91sam9260_macb.o COBJS-y += at91sam9260_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9260_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9260_spi.o endif ifdef CONFIG_AT91SAM9261 COBJS-y += at91sam9261_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9261_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9261_spi.o endif ifdef CONFIG_AT91SAM9263 COBJS-$(CONFIG_MACB) += at91sam9263_macb.o COBJS-y += at91sam9263_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9263_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9263_spi.o COBJS-$(CONFIG_USB_OHCI_NEW) += at91sam9263_usb.o endif ifdef CONFIG_AT91SAM9RL COBJS-y += at91sam9rl_serial.o +COBJS-$(CONFIG_ATMEL_SPI) += at91sam9rl_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9rl_spi.o endif COBJS-$(CONFIG_AT91_LED) += led.o
This needs to be cleand up as well. Define some variable for the board name (don't we actually have one already?), and then use a single copy of
it's not board name it's cpu name
So use the CPU name.
and due to multiple soc support for one file we can not do this
I think we can do this. Please try, and you will see how it will work out.
--- a/include/asm-arm/arch-at91/hardware.h +++ b/include/asm-arm/arch-at91/hardware.h @@ -21,25 +21,34 @@ #elif defined(CONFIG_AT91SAM9260) || defined(CONFIG_AT91SAM9G20) #include <asm/arch/at91sam9260.h> #define AT91_BASE_SPI AT91SAM9260_BASE_SPI0 +#define SPI0_BASE AT91SAM9260_BASE_SPI0 +#define SPI1_BASE AT91SAM9260_BASE_SPI1 #define AT91_ID_UHP AT91SAM9260_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9261) #include <asm/arch/at91sam9261.h> #define AT91_BASE_SPI AT91SAM9261_BASE_SPI0 +#define SPI0_BASE AT91SAM9261_BASE_SPI0 +#define SPI1_BASE AT91SAM9261_BASE_SPI1 #define AT91_ID_UHP AT91SAM9261_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9263) #include <asm/arch/at91sam9263.h> #define AT91_BASE_SPI AT91SAM9263_BASE_SPI0 +#define SPI0_BASE AT91SAM9263_BASE_SPI0 +#define SPI1_BASE AT91SAM9263_BASE_SPI1 #define AT91_ID_UHP AT91SAM9263_ID_UHP #define AT91_PMC_UHP AT91SAM926x_PMC_UHP #elif defined(CONFIG_AT91SAM9RL) #include <asm/arch/at91sam9rl.h> #define AT91_BASE_SPI AT91SAM9RL_BASE_SPI +#define SPI0_BASE AT91SAM9RL_BASE_SPI #define AT91_ID_UHP AT91SAM9RL_ID_UHP #elif defined(CONFIG_AT91CAP9) #include <asm/arch/at91cap9.h> #define AT91_BASE_SPI AT91CAP9_BASE_SPI0 +#define SPI0_BASE AT91CAP9_BASE_SPI0 +#define SPI1_BASE AT91CAP9_BASE_SPI1 #define AT91_ID_UHP AT91CAP9_ID_UHP #define AT91_PMC_UHP AT91CAP9_PMC_UHP #elif defined(CONFIG_AT91X40)
Same here. With a little clever use of macros we probably can get rid of all these "if defined" stuff.
we can not because it's shared with diffent soc and with AVR32
The resulting code (when compiled) would be 100% the same, so why do you think it cannot be done?
Just look at the cleanup Detlev Zundel just performed on the 16550 code. It is a wothwile goal to clean this up.
--- a/include/configs/afeb9260.h +++ b/include/configs/afeb9260.h @@ -84,6 +84,12 @@ #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */
/* DataFlash */ +#ifdef CONFIG_ATMEL_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SPI +#define CONFIG_SPI_FLASH 1 +#define CONFIG_SPI_FLASH_ATMEL 1 +#else
In which way is this board specific configuration when you copy it to all (?) AT91 boards?
you can enalbe what you want as flash I can not force at91 boards evenif actually they use the same
As long as you add it to ALL boards you can hardly call this board specific.
Best regards,
Wolfgang Denk
participants (2)
-
Jean-Christophe PLAGNIOL-VILLARD
-
Wolfgang Denk