]> git.sur5r.net Git - u-boot/commitdiff
at91: move dataflash spi driver to drivers/spi
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Fri, 27 Mar 2009 22:26:44 +0000 (23:26 +0100)
committerJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Sat, 4 Apr 2009 18:42:22 +0000 (20:42 +0200)
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
cpu/arm926ejs/at91/Makefile
cpu/arm926ejs/at91/spi.c [deleted file]
drivers/spi/Makefile
drivers/spi/atmel_dataflash_spi.c [new file with mode: 0644]
include/configs/afeb9260.h
include/configs/at91cap9adk.h
include/configs/at91sam9260ek.h
include/configs/at91sam9261ek.h
include/configs/at91sam9263ek.h
include/configs/at91sam9rlek.h

index d0d47e67485cefc6cfd961e9772b45cbaf0c35b9..34e746182a654686762a46929dc436c91067eea3 100644 (file)
@@ -55,7 +55,6 @@ COBJS-y                               += at91sam9rl_serial.o
 COBJS-$(CONFIG_HAS_DATAFLASH)  += at91sam9rl_spi.o
 endif
 COBJS-$(CONFIG_AT91_LED)       += led.o
-COBJS-$(CONFIG_HAS_DATAFLASH)  += spi.o
 COBJS-y        += timer.o
 SOBJS  = lowlevel_init.o
 
diff --git a/cpu/arm926ejs/at91/spi.c b/cpu/arm926ejs/at91/spi.c
deleted file mode 100644 (file)
index 3eb252c..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Driver for ATMEL DataFlash support
- * Author : Hamid Ikdoumi (Atmel)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
- */
-
-#include <common.h>
-#include <asm/arch/hardware.h>
-#include <asm/arch/gpio.h>
-#include <asm/arch/io.h>
-#include <asm/arch/at91_pio.h>
-#include <asm/arch/at91_spi.h>
-
-#include <dataflash.h>
-
-#define AT91_SPI_PCS0_DATAFLASH_CARD   0xE     /* Chip Select 0: NPCS0%1110 */
-#define AT91_SPI_PCS1_DATAFLASH_CARD   0xD     /* Chip Select 0: NPCS0%1101 */
-#define AT91_SPI_PCS3_DATAFLASH_CARD   0x7     /* Chip Select 3: NPCS3%0111 */
-
-void AT91F_SpiInit(void)
-{
-       /* Reset the SPI */
-       writel(AT91_SPI_SWRST, AT91_BASE_SPI + AT91_SPI_CR);
-
-       /* Configure SPI in Master Mode with No CS selected !!! */
-       writel(AT91_SPI_MSTR | AT91_SPI_MODFDIS | AT91_SPI_PCS,
-              AT91_BASE_SPI + AT91_SPI_MR);
-
-       /* Configure CS0 */
-       writel(AT91_SPI_NCPHA |
-              (AT91_SPI_DLYBS & DATAFLASH_TCSS) |
-              (AT91_SPI_DLYBCT & DATAFLASH_TCHS) |
-              ((AT91_MASTER_CLOCK / AT91_SPI_CLK) << 8),
-              AT91_BASE_SPI + AT91_SPI_CSR(0));
-
-#ifdef CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1
-       /* Configure CS1 */
-       writel(AT91_SPI_NCPHA |
-              (AT91_SPI_DLYBS & DATAFLASH_TCSS) |
-              (AT91_SPI_DLYBCT & DATAFLASH_TCHS) |
-              ((AT91_MASTER_CLOCK / AT91_SPI_CLK) << 8),
-              AT91_BASE_SPI + AT91_SPI_CSR(1));
-#endif
-
-#ifdef CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS3
-       /* Configure CS3 */
-       writel(AT91_SPI_NCPHA |
-              (AT91_SPI_DLYBS & DATAFLASH_TCSS) |
-              (AT91_SPI_DLYBCT & DATAFLASH_TCHS) |
-              ((AT91_MASTER_CLOCK / AT91_SPI_CLK) << 8),
-              AT91_BASE_SPI + AT91_SPI_CSR(3));
-#endif
-
-       /* SPI_Enable */
-       writel(AT91_SPI_SPIEN, AT91_BASE_SPI + AT91_SPI_CR);
-
-       while (!(readl(AT91_BASE_SPI + AT91_SPI_SR) & AT91_SPI_SPIENS));
-
-       /*
-        * Add tempo to get SPI in a safe state.
-        * Should not be needed for new silicon (Rev B)
-        */
-       udelay(500000);
-       readl(AT91_BASE_SPI + AT91_SPI_SR);
-       readl(AT91_BASE_SPI + AT91_SPI_RDR);
-
-}
-
-void AT91F_SpiEnable(int cs)
-{
-       unsigned long mode;
-
-       switch (cs) {
-       case 0: /* Configure SPI CS0 for Serial DataFlash AT45DBxx */
-               mode = readl(AT91_BASE_SPI + AT91_SPI_MR);
-               mode &= 0xFFF0FFFF;
-               writel(mode | ((AT91_SPI_PCS0_DATAFLASH_CARD<<16) & AT91_SPI_PCS),
-                      AT91_BASE_SPI + AT91_SPI_MR);
-               break;
-       case 1: /* Configure SPI CS1 for Serial DataFlash AT45DBxx */
-               mode = readl(AT91_BASE_SPI + AT91_SPI_MR);
-               mode &= 0xFFF0FFFF;
-               writel(mode | ((AT91_SPI_PCS1_DATAFLASH_CARD<<16) & AT91_SPI_PCS),
-                      AT91_BASE_SPI + AT91_SPI_MR);
-               break;
-       case 3:
-               mode = readl(AT91_BASE_SPI + AT91_SPI_MR);
-               mode &= 0xFFF0FFFF;
-               writel(mode | ((AT91_SPI_PCS3_DATAFLASH_CARD<<16) & AT91_SPI_PCS),
-                      AT91_BASE_SPI + AT91_SPI_MR);
-               break;
-       }
-
-       /* SPI_Enable */
-       writel(AT91_SPI_SPIEN, AT91_BASE_SPI + AT91_SPI_CR);
-}
-
-unsigned int AT91F_SpiWrite1(AT91PS_DataflashDesc pDesc);
-
-unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc)
-{
-       unsigned int timeout;
-
-       pDesc->state = BUSY;
-
-       writel(AT91_SPI_TXTDIS + AT91_SPI_RXTDIS, AT91_BASE_SPI + AT91_SPI_PTCR);
-
-       /* Initialize the Transmit and Receive Pointer */
-       writel((unsigned int)pDesc->rx_cmd_pt, AT91_BASE_SPI + AT91_SPI_RPR);
-       writel((unsigned int)pDesc->tx_cmd_pt, AT91_BASE_SPI + AT91_SPI_TPR);
-
-       /* Intialize the Transmit and Receive Counters */
-       writel(pDesc->rx_cmd_size, AT91_BASE_SPI + AT91_SPI_RCR);
-       writel(pDesc->tx_cmd_size, AT91_BASE_SPI + AT91_SPI_TCR);
-
-       if (pDesc->tx_data_size != 0) {
-               /* Initialize the Next Transmit and Next Receive Pointer */
-               writel((unsigned int)pDesc->rx_data_pt, AT91_BASE_SPI + AT91_SPI_RNPR);
-               writel((unsigned int)pDesc->tx_data_pt, AT91_BASE_SPI + AT91_SPI_TNPR);
-
-               /* Intialize the Next Transmit and Next Receive Counters */
-               writel(pDesc->rx_data_size, AT91_BASE_SPI + AT91_SPI_RNCR);
-               writel(pDesc->tx_data_size, AT91_BASE_SPI + AT91_SPI_TNCR);
-       }
-
-       /* arm simple, non interrupt dependent timer */
-       reset_timer_masked();
-       timeout = 0;
-
-       writel(AT91_SPI_TXTEN + AT91_SPI_RXTEN, AT91_BASE_SPI + AT91_SPI_PTCR);
-       while (!(readl(AT91_BASE_SPI + AT91_SPI_SR) & AT91_SPI_RXBUFF) &&
-               ((timeout = get_timer_masked()) < CONFIG_SYS_SPI_WRITE_TOUT));
-       writel(AT91_SPI_TXTDIS + AT91_SPI_RXTDIS, AT91_BASE_SPI + AT91_SPI_PTCR);
-       pDesc->state = IDLE;
-
-       if (timeout >= CONFIG_SYS_SPI_WRITE_TOUT) {
-               printf("Error Timeout\n\r");
-               return DATAFLASH_ERROR;
-       }
-
-       return DATAFLASH_OK;
-}
index 6e2c121d67b2f3e422e82aa1e235b6fe2d8c1d70..1350f3e0bff660a7b88e81497e38545ce621b23d 100644 (file)
@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB    := $(obj)libspi.a
 
+COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o
 COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o
 COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.o
 COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o
diff --git a/drivers/spi/atmel_dataflash_spi.c b/drivers/spi/atmel_dataflash_spi.c
new file mode 100644 (file)
index 0000000..3eb252c
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * Driver for ATMEL DataFlash support
+ * Author : Hamid Ikdoumi (Atmel)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+#include <common.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/io.h>
+#include <asm/arch/at91_pio.h>
+#include <asm/arch/at91_spi.h>
+
+#include <dataflash.h>
+
+#define AT91_SPI_PCS0_DATAFLASH_CARD   0xE     /* Chip Select 0: NPCS0%1110 */
+#define AT91_SPI_PCS1_DATAFLASH_CARD   0xD     /* Chip Select 0: NPCS0%1101 */
+#define AT91_SPI_PCS3_DATAFLASH_CARD   0x7     /* Chip Select 3: NPCS3%0111 */
+
+void AT91F_SpiInit(void)
+{
+       /* Reset the SPI */
+       writel(AT91_SPI_SWRST, AT91_BASE_SPI + AT91_SPI_CR);
+
+       /* Configure SPI in Master Mode with No CS selected !!! */
+       writel(AT91_SPI_MSTR | AT91_SPI_MODFDIS | AT91_SPI_PCS,
+              AT91_BASE_SPI + AT91_SPI_MR);
+
+       /* Configure CS0 */
+       writel(AT91_SPI_NCPHA |
+              (AT91_SPI_DLYBS & DATAFLASH_TCSS) |
+              (AT91_SPI_DLYBCT & DATAFLASH_TCHS) |
+              ((AT91_MASTER_CLOCK / AT91_SPI_CLK) << 8),
+              AT91_BASE_SPI + AT91_SPI_CSR(0));
+
+#ifdef CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS1
+       /* Configure CS1 */
+       writel(AT91_SPI_NCPHA |
+              (AT91_SPI_DLYBS & DATAFLASH_TCSS) |
+              (AT91_SPI_DLYBCT & DATAFLASH_TCHS) |
+              ((AT91_MASTER_CLOCK / AT91_SPI_CLK) << 8),
+              AT91_BASE_SPI + AT91_SPI_CSR(1));
+#endif
+
+#ifdef CONFIG_SYS_DATAFLASH_LOGIC_ADDR_CS3
+       /* Configure CS3 */
+       writel(AT91_SPI_NCPHA |
+              (AT91_SPI_DLYBS & DATAFLASH_TCSS) |
+              (AT91_SPI_DLYBCT & DATAFLASH_TCHS) |
+              ((AT91_MASTER_CLOCK / AT91_SPI_CLK) << 8),
+              AT91_BASE_SPI + AT91_SPI_CSR(3));
+#endif
+
+       /* SPI_Enable */
+       writel(AT91_SPI_SPIEN, AT91_BASE_SPI + AT91_SPI_CR);
+
+       while (!(readl(AT91_BASE_SPI + AT91_SPI_SR) & AT91_SPI_SPIENS));
+
+       /*
+        * Add tempo to get SPI in a safe state.
+        * Should not be needed for new silicon (Rev B)
+        */
+       udelay(500000);
+       readl(AT91_BASE_SPI + AT91_SPI_SR);
+       readl(AT91_BASE_SPI + AT91_SPI_RDR);
+
+}
+
+void AT91F_SpiEnable(int cs)
+{
+       unsigned long mode;
+
+       switch (cs) {
+       case 0: /* Configure SPI CS0 for Serial DataFlash AT45DBxx */
+               mode = readl(AT91_BASE_SPI + AT91_SPI_MR);
+               mode &= 0xFFF0FFFF;
+               writel(mode | ((AT91_SPI_PCS0_DATAFLASH_CARD<<16) & AT91_SPI_PCS),
+                      AT91_BASE_SPI + AT91_SPI_MR);
+               break;
+       case 1: /* Configure SPI CS1 for Serial DataFlash AT45DBxx */
+               mode = readl(AT91_BASE_SPI + AT91_SPI_MR);
+               mode &= 0xFFF0FFFF;
+               writel(mode | ((AT91_SPI_PCS1_DATAFLASH_CARD<<16) & AT91_SPI_PCS),
+                      AT91_BASE_SPI + AT91_SPI_MR);
+               break;
+       case 3:
+               mode = readl(AT91_BASE_SPI + AT91_SPI_MR);
+               mode &= 0xFFF0FFFF;
+               writel(mode | ((AT91_SPI_PCS3_DATAFLASH_CARD<<16) & AT91_SPI_PCS),
+                      AT91_BASE_SPI + AT91_SPI_MR);
+               break;
+       }
+
+       /* SPI_Enable */
+       writel(AT91_SPI_SPIEN, AT91_BASE_SPI + AT91_SPI_CR);
+}
+
+unsigned int AT91F_SpiWrite1(AT91PS_DataflashDesc pDesc);
+
+unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc)
+{
+       unsigned int timeout;
+
+       pDesc->state = BUSY;
+
+       writel(AT91_SPI_TXTDIS + AT91_SPI_RXTDIS, AT91_BASE_SPI + AT91_SPI_PTCR);
+
+       /* Initialize the Transmit and Receive Pointer */
+       writel((unsigned int)pDesc->rx_cmd_pt, AT91_BASE_SPI + AT91_SPI_RPR);
+       writel((unsigned int)pDesc->tx_cmd_pt, AT91_BASE_SPI + AT91_SPI_TPR);
+
+       /* Intialize the Transmit and Receive Counters */
+       writel(pDesc->rx_cmd_size, AT91_BASE_SPI + AT91_SPI_RCR);
+       writel(pDesc->tx_cmd_size, AT91_BASE_SPI + AT91_SPI_TCR);
+
+       if (pDesc->tx_data_size != 0) {
+               /* Initialize the Next Transmit and Next Receive Pointer */
+               writel((unsigned int)pDesc->rx_data_pt, AT91_BASE_SPI + AT91_SPI_RNPR);
+               writel((unsigned int)pDesc->tx_data_pt, AT91_BASE_SPI + AT91_SPI_TNPR);
+
+               /* Intialize the Next Transmit and Next Receive Counters */
+               writel(pDesc->rx_data_size, AT91_BASE_SPI + AT91_SPI_RNCR);
+               writel(pDesc->tx_data_size, AT91_BASE_SPI + AT91_SPI_TNCR);
+       }
+
+       /* arm simple, non interrupt dependent timer */
+       reset_timer_masked();
+       timeout = 0;
+
+       writel(AT91_SPI_TXTEN + AT91_SPI_RXTEN, AT91_BASE_SPI + AT91_SPI_PTCR);
+       while (!(readl(AT91_BASE_SPI + AT91_SPI_SR) & AT91_SPI_RXBUFF) &&
+               ((timeout = get_timer_masked()) < CONFIG_SYS_SPI_WRITE_TOUT));
+       writel(AT91_SPI_TXTDIS + AT91_SPI_RXTDIS, AT91_BASE_SPI + AT91_SPI_PTCR);
+       pDesc->state = IDLE;
+
+       if (timeout >= CONFIG_SYS_SPI_WRITE_TOUT) {
+               printf("Error Timeout\n\r");
+               return DATAFLASH_ERROR;
+       }
+
+       return DATAFLASH_OK;
+}
index 72881abc441f1e74f4e9cff1cd277dbfb7c98490..de938f7a29169a2fcb1fa21d0a4669fa08f6bb23 100644 (file)
@@ -87,6 +87,7 @@
 #define PHYS_SDRAM_SIZE                        0x04000000      /* 64 megs */
 
 /* DataFlash */
+#define CONFIG_ATMEL_DATAFLASH_SPI
 #define CONFIG_HAS_DATAFLASH           1
 #define CONFIG_SYS_SPI_WRITE_TOUT              (5 * CONFIG_SYS_HZ)
 #define CONFIG_SYS_MAX_DATAFLASH_BANKS         2
index 2f4baed44b2965a2f2dc55be996a2639ee78d26b..b978731bcecc05714973489b6124f387acf63454 100644 (file)
 #define PHYS_SDRAM_SIZE                        0x04000000      /* 64 megs */
 
 /* DataFlash */
+#define CONFIG_ATMEL_DATAFLASH_SPI
 #define CONFIG_HAS_DATAFLASH           1
 #define CONFIG_SYS_SPI_WRITE_TOUT              (5*CONFIG_SYS_HZ)
 #define CONFIG_SYS_MAX_DATAFLASH_BANKS         1
index 29cabcfd3e8653c0d8b3dc01a0631ffbbc2589d7..bcc65bdd64a0bb01688cb167415f999dc2908dcf 100644 (file)
 #define PHYS_SDRAM_SIZE                        0x04000000      /* 64 megs */
 
 /* DataFlash */
+#define CONFIG_ATMEL_DATAFLASH_SPI
 #define CONFIG_HAS_DATAFLASH           1
 #define CONFIG_SYS_SPI_WRITE_TOUT              (5*CONFIG_SYS_HZ)
 #define CONFIG_SYS_MAX_DATAFLASH_BANKS         2
index d6d140a964e9ba664b94b18310aa863313de5e35..cc40d7bda719ed1f26ff67c2f42df999c52b1196 100644 (file)
 #define PHYS_SDRAM_SIZE                        0x04000000      /* 64 megs */
 
 /* DataFlash */
+#define CONFIG_ATMEL_DATAFLASH_SPI
 #define CONFIG_HAS_DATAFLASH           1
 #define CONFIG_SYS_SPI_WRITE_TOUT              (5*CONFIG_SYS_HZ)
 #define CONFIG_SYS_MAX_DATAFLASH_BANKS         2
index 83baf67ea862f120f4715918898db7d854d9ec7d..cd0c15c97d07c41ca4e6abf77bdc683f8a472eab 100644 (file)
 #define PHYS_SDRAM_SIZE                        0x04000000      /* 64 megs */
 
 /* DataFlash */
+#define CONFIG_ATMEL_DATAFLASH_SPI
 #define CONFIG_HAS_DATAFLASH           1
 #define CONFIG_SYS_SPI_WRITE_TOUT              (5*CONFIG_SYS_HZ)
 #define CONFIG_SYS_MAX_DATAFLASH_BANKS         1
index a48f2cba5a1fa8d339670dfc2de7f4b248d80f1c..fec48b6b26572c4997bea247651beff9b9bd3349 100644 (file)
@@ -98,6 +98,7 @@
 #define PHYS_SDRAM_SIZE                        0x04000000      /* 64 megs */
 
 /* DataFlash */
+#define CONFIG_ATMEL_DATAFLASH_SPI
 #define CONFIG_HAS_DATAFLASH           1
 #define CONFIG_SYS_SPI_WRITE_TOUT              (5*CONFIG_SYS_HZ)
 #define CONFIG_SYS_MAX_DATAFLASH_BANKS         1