Skip to contentSkip to conversation

arm, at91: add spi dataflash support for the taurus board

PATCH New Heiko Schocher 2 participants 3 messages Oct 1, 2014 – Oct 2, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm, at91: add spi dataflash support for the taurus board

Cc Andreas Bie?mann <[email protected]>
Cc Bo Shen <[email protected]>
---
 board/siemens/taurus/taurus.c | 22 ++++++++++++++++++++++
 include/configs/taurus.h      | 11 +++++++++++
 2 files changed, 33 insertions(+)
board/siemens/taurus/taurus.c +22 -0
index 673b302..98ce441 100644
@@ -22,6 +22,8 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/at91sam9_sdramc.h>
 #include <atmel_mci.h>
+#include <asm/arch/at91_spi.h>
+#include <spi.h>
 
 #include <net.h>
 #include <netdev.h>
@@ -127,6 +129,25 @@ int board_early_init_f(void)
 	return 0;
 }
 
+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(TAURUS_SPI_CS_PIN, 0);
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+	at91_set_gpio_value(TAURUS_SPI_CS_PIN, 1);
+}
+
+void spi_init_f(void)
+{
+	/* everything done in board_init */
+}
 int board_init(void)
 {
 	/* adress of boot parameters */
@@ -139,6 +160,7 @@ int board_init(void)
 #ifdef CONFIG_MACB
 	taurus_macb_hw_init();
 #endif
+	at91_spi0_hw_init(TAURUS_SPI_MASK);
 
 	return 0;
 }
include/configs/taurus.h +11 -0
index aadf4cd..e30542d 100644
@@ -127,6 +127,17 @@
 #define CONFIG_USB_STORAGE
 #endif
 
+/* SPI EEPROM */
+#define CONFIG_SPI
+#define CONFIG_CMD_SPI
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_ATMEL_SPI
+#define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SYS_SPI_WRITE_TOUT		(5 * CONFIG_SYS_HZ)
+#define TAURUS_SPI_MASK (1 << 4)
+#define TAURUS_SPI_CS_PIN	AT91_PIN_PA3
+
 /* load address */
 #define CONFIG_SYS_LOAD_ADDR			0x22000000
 
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 arm, at91: add spi dataflash support for the taurus board

Quoted 34 lines · Heiko Schocher
Cc Andreas Bie?mann <[email protected]>
Cc Bo Shen <[email protected]>
---
 board/siemens/taurus/taurus.c | 22 ++++++++++++++++++++++
 include/configs/taurus.h      | 11 +++++++++++
 2 files changed, 33 insertions(+)
board/siemens/taurus/taurus.c +11 -0
index 673b302..98ce441 100644
@@ -22,6 +22,8 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/at91sam9_sdramc.h>
 #include <atmel_mci.h>
+#include <asm/arch/at91_spi.h>
+#include <spi.h>
 
 #include <net.h>
 #include <netdev.h>
@@ -127,6 +129,25 @@ int board_early_init_f(void)
        return 0;
 }
 
+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(TAURUS_SPI_CS_PIN, 0);
+}

board/siemens/taurus/taurus.c int board_early_init_f(void) · line 150

Quoted 10 lines
board/siemens/taurus/taurus.c +10 -0
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+       at91_set_gpio_value(TAURUS_SPI_CS_PIN, 1);
+}
+
+void spi_init_f(void)
+{
+       /* everything done in board_init */
+}

Please don't hold spi variant calls on board files, I guess most of the atmel boards does
the same but try to add them on driver itself.

Quoted 17 lines
board/siemens/taurus/taurus.c +1 -0
 int board_init(void)
 {
        /* adress of boot parameters */
@@ -139,6 +160,7 @@ int board_init(void)
 #ifdef CONFIG_MACB
        taurus_macb_hw_init();
 #endif
+       at91_spi0_hw_init(TAURUS_SPI_MASK);
 
        return 0;
 }
include/configs/taurus.h +0 -0
index aadf4cd..e30542d 100644
@@ -127,6 +127,17 @@
 #define CONFIG_USB_STORAGE

include/configs/taurus.h line 137

Quoted 10 lines
include/configs/taurus.h +8 -0
 #endif
 
+/* SPI EEPROM */
+#define CONFIG_SPI
+#define CONFIG_CMD_SPI
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_ATMEL_SPI
+#define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SYS_SPI_WRITE_TOUT              (5 * CONFIG_SYS_HZ)

Don't make this as a config option instead define it on driver file.

Quoted 9 lines
include/configs/taurus.h +3 -1
+#define TAURUS_SPI_MASK (1 << 4)
+#define TAURUS_SPI_CS_PIN      AT91_PIN_PA3
+
 /* load address */
 #define CONFIG_SYS_LOAD_ADDR                   0x22000000
 
--

1.8.3.1

Quoted 4 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

thanks!

Signature · 1 line
Jagan.
#2 lore raw

PATCH 1/1 arm, at91: add spi dataflash support for the taurus board

Hello Jagan,

Am 01.10.2014 16:30, schrieb Jagan Teki:

Quoted 41 lines · Heiko Schocher
Quoted 40 lines
Cc Andreas Bie?mann<[email protected]>
Cc Bo Shen<[email protected]>
---
  board/siemens/taurus/taurus.c | 22 ++++++++++++++++++++++
  include/configs/taurus.h      | 11 +++++++++++
  2 files changed, 33 insertions(+)
board/siemens/taurus/taurus.c +17 -0
index 673b302..98ce441 100644
@@ -22,6 +22,8 @@
  #include<asm/arch/gpio.h>
  #include<asm/arch/at91sam9_sdramc.h>
  #include<atmel_mci.h>
+#include<asm/arch/at91_spi.h>
+#include<spi.h>
 
  #include<net.h>
  #include<netdev.h>
@@ -127,6 +129,25 @@ int board_early_init_f(void)
         return 0;
  }
 
+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(TAURUS_SPI_CS_PIN, 0);
+}
+
+void spi_cs_deactivate(struct spi_slave *slave)
+{
+       at91_set_gpio_value(TAURUS_SPI_CS_PIN, 1);
+}
+
Quoted 8 lines

board/siemens/taurus/taurus.c int board_early_init_f(void) · line 150

Quoted 4 lines
board/siemens/taurus/taurus.c +4 -0
+void spi_init_f(void)
+{
+       /* everything done in board_init */
+}

Please don't hold spi variant calls on board files, I guess most of the atmel boards does
the same but try to add them on driver itself.

Heh, good catch ... I did this like the

board/calao/tny_a9260/spi.c
board/calao/sbc35_a9g20/spi.c

boards ... I greped for this function, and it turned out, I did not need it! So, I remove it in v2.... thanks!

Quoted 19 lines
Quoted 19 lines
board/siemens/taurus/taurus.c +1 -0
  int board_init(void)
  {
         /* adress of boot parameters */
@@ -139,6 +160,7 @@ int board_init(void)
  #ifdef CONFIG_MACB
         taurus_macb_hw_init();
  #endif
+       at91_spi0_hw_init(TAURUS_SPI_MASK);
 
         return 0;
  }
include/configs/taurus.h +0 -0
index aadf4cd..e30542d 100644
@@ -127,6 +127,17 @@
  #define CONFIG_USB_STORAGE
  #endif
 
Quoted 10 lines

include/configs/taurus.h line 137

Quoted 8 lines
include/configs/taurus.h +8 -0
+/* SPI EEPROM */
+#define CONFIG_SPI
+#define CONFIG_CMD_SPI
+#define CONFIG_CMD_SF
+#define CONFIG_SPI_FLASH
+#define CONFIG_ATMEL_SPI
+#define CONFIG_SPI_FLASH_STMICRO
+#define CONFIG_SYS_SPI_WRITE_TOUT              (5 * CONFIG_SYS_HZ)

Don't make this as a config option instead define it on driver file.

Ah, I see, this is defined in more than 10 at91 board config files, and all with the same value ... Ok, I add in drivers/spi/atmel_spi.h

#if !defined(CONFIG_SYS_SPI_WRITE_TOUT) #define CONFIG_SYS_SPI_WRITE_TOUT (5 * CONFIG_SYS_HZ) #endif

and remove this define from the board files ...

Quoted 5 lines

include/configs/taurus.h line 142

Quoted 5 lines
include/configs/taurus.h +3 -0
+#define TAURUS_SPI_MASK (1<<  4)
+#define TAURUS_SPI_CS_PIN      AT91_PIN_PA3
+
  /* load address */
  #define CONFIG_SYS_LOAD_ADDR                   0x22000000

Thanks!

bye,
Heiko

Signature · 2 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany