at91sam9/at91cap: add new spi framework and spi flash support
PATCH 1/1 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
--- 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(-)
board/afeb9260/afeb9260.c +40 -0
@@ -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 */
board/atmel/at91cap9adk/at91cap9adk.c +23 -1
@@ -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 */
board/atmel/at91sam9260ek/at91sam9260ek.c +39 -1
@@ -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 */
board/atmel/at91sam9261ek/at91sam9261ek.c +39 -1
@@ -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 */
board/atmel/at91sam9263ek/at91sam9263ek.c +25 -1
@@ -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 */
board/atmel/at91sam9rlek/at91sam9rlek.c +23 -1
@@ -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 */
board/ronetix/pm9263/pm9263.c +23 -1
@@ -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 */
cpu/arm926ejs/at91/Makefile +6 -0
@@ -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
include/asm-arm/arch-at91/clk.h +5 -0
@@ -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 ();
include/asm-arm/arch-at91/hardware.h +9 -0
@@ -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 )
include/configs/afeb9260.h +7 -0
@@ -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
include/configs/at91cap9adk.h +7 -0
@@ -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
include/configs/at91sam9260ek.h +7 -0
@@ -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
include/configs/at91sam9261ek.h +7 -0
@@ -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
include/configs/at91sam9263ek.h +7 -0
@@ -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
include/configs/at91sam9rlek.h +7 -0
@@ -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
include/configs/pm9263.h +7 -0
@@ -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
Signature · 1 line
1.6.1.3
PATCH 1/1 at91sam9/at91cap: add new spi framework and spi flash support
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 4 lines · In message <[email protected]> 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 <[email protected]>
...
...
Quoted 4 lines
board/afeb9260/afeb9260.c +0
-0
...
board/afeb9260/afeb9260.c int board_eth_init(bd_t *bis) · line 191
Quoted 3 lines
board/afeb9260/afeb9260.c +3
-0+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
Please no #includes in the middle of the file.
Quoted 20 lines
board/afeb9260/afeb9260.c +20
-0+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) +{
board/afeb9260/afeb9260.c int board_eth_init(bd_t *bis) · line 222
Quoted 10 lines
board/afeb9260/afeb9260.c +10
-0+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?
Quoted 4 lines
board/atmel/at91cap9adk/at91cap9adk.c +0
-0
...
board/atmel/at91cap9adk/at91cap9adk.c
Quoted 3 lines
board/atmel/at91cap9adk/at91cap9adk.c +3
-0+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
See above.
board/atmel/at91cap9adk/at91cap9adk.c int board_eth_init(bd_t *bis) · line 371
Quoted 4 lines
board/atmel/at91cap9adk/at91cap9adk.c +4
-0+int spi_cs_is_valid (unsigned int bus,unsigned int cs) +{ +return bus ==0 && cs ==0 ; +}
Duplicated code. Move to common.
board/atmel/at91cap9adk/at91cap9adk.c int board_eth_init(bd_t *bis) · line 381
Quoted 9 lines
board/atmel/at91cap9adk/at91cap9adk.c +9
-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 ); +}
How about making these inline?
Quoted 4 lines
board/atmel/at91sam9260ek/at91sam9260ek.c +0
-0
...
board/atmel/at91sam9260ek/at91sam9260ek.c
Quoted 3 lines
board/atmel/at91sam9260ek/at91sam9260ek.c +3
-0+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
See above.
board/atmel/at91sam9260ek/at91sam9260ek.c
Quoted 4 lines
board/atmel/at91sam9260ek/at91sam9260ek.c +4
-0+int spi_cs_is_valid (unsigned int bus,unsigned int cs) +{ +return bus ==0 && cs <2 ; +}
Duplicated code. Move to common.
board/atmel/at91sam9260ek/at91sam9260ek.c
Quoted 12 lines
board/atmel/at91sam9260ek/at91sam9260ek.c +12
-0+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.
board/atmel/at91sam9260ek/at91sam9260ek.c
Quoted 12 lines
board/atmel/at91sam9260ek/at91sam9260ek.c +12
-0+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.
Quoted 4 lines
board/atmel/at91sam9261ek/at91sam9261ek.c +0
-0
...
board/atmel/at91sam9261ek/at91sam9261ek.c
Quoted 3 lines
board/atmel/at91sam9261ek/at91sam9261ek.c +3
-0+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h>
See above.
Quoted 20 lines
board/atmel/at91sam9261ek/at91sam9261ek.c +20
-0+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) +{
board/atmel/at91sam9261ek/at91sam9261ek.c void reset_phy(void) · line 285
Quoted 10 lines
board/atmel/at91sam9261ek/at91sam9261ek.c +10
-0+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?
Quoted 4 lines
board/atmel/at91sam9263ek/at91sam9263ek.c +0
-0
...
Quoted 8 lines
board/atmel/at91sam9263ek/at91sam9263ek.c +8
-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 ; +}
board/atmel/at91sam9263ek/at91sam9263ek.c
Quoted 10 lines
board/atmel/at91sam9263ek/at91sam9263ek.c +10
-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.
Quoted 5 lines
board/atmel/at91sam9263ek/at91sam9263ek.c +1
-0+#endif /* CONFIG_ATMEL_SPI */ board/atmel/at91sam9rlek/at91sam9rlek.c +0
-0
...
Quoted 9 lines
board/atmel/at91sam9rlek/at91sam9rlek.c +9
-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 ; +}
board/atmel/at91sam9rlek/at91sam9rlek.c int dram_init(void) · line 226
Quoted 10 lines
board/atmel/at91sam9rlek/at91sam9rlek.c +10
-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.
Quoted 4 lines
board/ronetix/pm9263/pm9263.c +0
-0
...
Quoted 8 lines
board/ronetix/pm9263/pm9263.c +8
-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 ; +}
board/ronetix/pm9263/pm9263.c
Quoted 10 lines
board/ronetix/pm9263/pm9263.c +10
-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.
Quoted 31 lines
cpu/arm926ejs/at91/Makefile +4
-0@@ -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
cpu/arm926ejs/at91/Makefile LIB = $(obj)lib$(SOC).a · line 63
Quoted 10 lines
cpu/arm926ejs/at91/Makefile +2
-0+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.
Quoted 29 lines
include/asm-arm/arch-at91/hardware.h +6
-0@@ -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
include/asm-arm/arch-at91/hardware.h line 54
Quoted 10 lines
include/asm-arm/arch-at91/hardware.h +3
-0+#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.
Quoted 5 lines
include/configs/afeb9260.h +0
-0
include/configs/afeb9260.h line 92
Quoted 9 lines
include/configs/afeb9260.h +6
-0@@ -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
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Harrison's Postulate: For every action, there is an equal and opposite criticism.
PATCH 1/1 at91sam9/at91cap: add new spi framework and spi flash support
Quoted 45 lines · Wolfgang Denk
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 4 lines · In message <[email protected]> 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 <[email protected]>...
...Quoted 4 lines
board/afeb9260/afeb9260.c +0
-0...
board/afeb9260/afeb9260.c int board_eth_init(bd_t *bis) · line 191
Quoted 3 lines
board/afeb9260/afeb9260.c +3
-0+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h> Please no #includes in the middle of the file.
Quoted 25 lines
board/afeb9260/afeb9260.c +25
-0+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 :
Quoted 8 lines
board/afeb9260/afeb9260.c int board_eth_init(bd_t *bis) · line 222
Quoted 5 lines
board/afeb9260/afeb9260.c +5
-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
Quoted 12 lines
Quoted 5 lines
board/atmel/at91cap9adk/at91cap9adk.c +0
-0...
board/atmel/at91cap9adk/at91cap9adk.c
Quoted 3 lines
board/atmel/at91cap9adk/at91cap9adk.c +3
-0+/* SPI chip select control */ +#ifdef CONFIG_ATMEL_SPI +#include <spi.h> See above.
Quoted 6 lines
board/atmel/at91cap9adk/at91cap9adk.c int board_eth_init(bd_t *bis) · line 371
Quoted 4 lines
board/atmel/at91cap9adk/at91cap9adk.c +4
-0+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
Quoted 12 lines
board/atmel/at91cap9adk/at91cap9adk.c int board_eth_init(bd_t *bis) · line 381
Quoted 10 lines
board/atmel/at91cap9adk/at91cap9adk.c +9
-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 ); +}How about making these inline?
it's the spi framework
Quoted 42 lines
Quoted 5 lines
board/atmel/at91sam9260ek/at91sam9260ek.c +0
-0...
Quoted 36 lines
index fbc82d1..e73f450 100644
cpu/arm926ejs/at91/Makefile +5
-0@@ -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
Quoted 8 lines
cpu/arm926ejs/at91/Makefile LIB = $(obj)lib$(SOC).a · line 63
Quoted 4 lines
cpu/arm926ejs/at91/Makefile +1
-0+COBJS-$(CONFIG_ATMEL_SPI) += at91sam9rl_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9rl_spi.o endif COBJS-$(CONFIG_AT91_LED) += led.oThis 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
Quoted 42 lines
COBJS-$(CONFIG_MACB) += $(BOARD)_macb.o COBJS-y += $(BOARD)_serial.o COBJS-$(CONFIG_ATMEL_SPI) += $(BOARD)_spi.o COBJS-$(CONFIG_HAS_DATAFLASH) += $(BOARD)_spi.oinstead of such an endless list if "ifdef"ed code.
Quoted 34 lines
include/asm-arm/arch-at91/hardware.h +7
-0@@ -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
Quoted 8 lines
include/asm-arm/arch-at91/hardware.h line 54
Quoted 5 lines
include/asm-arm/arch-at91/hardware.h +2
-0+#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
Quoted 8 lines
Quoted 8 lines
include/configs/afeb9260.h +0
-0@@ -84,6 +84,12 @@#define PHYS_SDRAM_SIZE 0x04000000/* 64 megs */
Quoted 10 lines
include/configs/afeb9260.h line 92
Quoted 7 lines
include/configs/afeb9260.h +6
-0/* 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.
PATCH 1/1 at91sam9/at91cap: add new spi framework and spi flash support
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 4 lines · In message <[email protected]> you wrote:
Quoted 3 lines
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.
Quoted 7 lines
Quoted 6 lines
board/atmel/at91cap9adk/at91cap9adk.c int board_eth_init(bd_t *bis) · line 371
Quoted 4 lines
board/atmel/at91cap9adk/at91cap9adk.c +4
-0+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.
Quoted 39 lines
Quoted 31 lines
Quoted 31 lines
COBJS-$(CONFIG_MACB) += at91cap9_macb.o
COBJS-y += at91cap9_serial.ocpu/arm926ejs/at91/Makefile +5
-0+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.oQuoted 8 lines
Quoted 4 lines
+COBJS-$(CONFIG_ATMEL_SPI) += at91sam9rl_spi.o
COBJS-$(CONFIG_HAS_DATAFLASH) += at91sam9rl_spi.o
endif
COBJS-$(CONFIG_AT91_LED) += led.oThis 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
Quoted 1 line
it's not board name it's cpu name
So use the CPU name.
Quoted 1 line
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.
Quoted 40 lines
Quoted 32 lines
Quoted 32 lines
include/asm-arm/arch-at91/hardware.h +7
-0@@ -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_SPI0Quoted 8 lines
include/asm-arm/arch-at91/hardware.h line 54
Quoted 5 lines
include/asm-arm/arch-at91/hardware.h +2
-0+#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.
Quoted 1 line
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.
Quoted 15 lines
Quoted 5 lines
Quoted 5 lines
include/configs/afeb9260.h +0
-0@@ -84,6 +84,12 @@#define PHYS_SDRAM_SIZE 0x04000000/* 64 megs */ Quoted 10 lines
include/configs/afeb9260.h line 92
Quoted 7 lines
include/configs/afeb9260.h +6
-0/* 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?
Quoted 2 lines
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
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Artificial Intelligence is the study of how to make real computers act like the ones in movies.