davinci: add spi devices support for da850/omap-l138/am18x evm
authorSekhar Nori <nsekhar@ti.com>
Thu, 24 Feb 2011 05:09:27 +0000 (10:39 +0530)
committerKevin Hilman <khilman@ti.com>
Fri, 11 Mar 2011 18:48:29 +0000 (10:48 -0800)
This patch adds the on-board SPI flash device to the
DA850/OMAP-L138/AM18x EVM. It also registers the SPI flash
device to the MTD subsystem.

Based on SPI flash device support for MityDSP-L138F platform.

Signed-off-by: Sekhar Nori <nsekhar@ti.com>
[michael.williamson@criticallink.com: moved da850_evm_spi1_pdata to devices-da8xx.c]
[michael.williamson@criticallink.com: moved da850evm_init_spi1 to devices-da8xx.c]
Signed-off-by: Michael Williamson <michael.williamson@criticallink.com>
Signed-off-by: Kevin Hilman <khilman@ti.com>
arch/arm/mach-davinci/board-da850-evm.c

index 11f986bec89d412eb986d5e5a1a58847758da3a3..0aef6b2eb13d25b5ca50055556a3fbb663eb4cb3 100644 (file)
@@ -29,6 +29,8 @@
 #include <linux/regulator/machine.h>
 #include <linux/regulator/tps6507x.h>
 #include <linux/input/tps6507x-ts.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/flash.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -38,6 +40,7 @@
 #include <mach/nand.h>
 #include <mach/mux.h>
 #include <mach/aemif.h>
+#include <mach/spi.h>
 
 #define DA850_EVM_PHY_ID               "0:00"
 #define DA850_LCD_PWR_PIN              GPIO_TO_PIN(2, 8)
 
 #define DA850_MII_MDIO_CLKEN_PIN       GPIO_TO_PIN(2, 6)
 
+static struct mtd_partition da850evm_spiflash_part[] = {
+       [0] = {
+               .name = "UBL",
+               .offset = 0,
+               .size = SZ_64K,
+               .mask_flags = MTD_WRITEABLE,
+       },
+       [1] = {
+               .name = "U-Boot",
+               .offset = MTDPART_OFS_APPEND,
+               .size = SZ_512K,
+               .mask_flags = MTD_WRITEABLE,
+       },
+       [2] = {
+               .name = "U-Boot-Env",
+               .offset = MTDPART_OFS_APPEND,
+               .size = SZ_64K,
+               .mask_flags = MTD_WRITEABLE,
+       },
+       [3] = {
+               .name = "Kernel",
+               .offset = MTDPART_OFS_APPEND,
+               .size = SZ_2M + SZ_512K,
+               .mask_flags = 0,
+       },
+       [4] = {
+               .name = "Filesystem",
+               .offset = MTDPART_OFS_APPEND,
+               .size = SZ_4M,
+               .mask_flags = 0,
+       },
+       [5] = {
+               .name = "MAC-Address",
+               .offset = SZ_8M - SZ_64K,
+               .size = SZ_64K,
+               .mask_flags = MTD_WRITEABLE,
+       },
+};
+
+static struct flash_platform_data da850evm_spiflash_data = {
+       .name           = "m25p80",
+       .parts          = da850evm_spiflash_part,
+       .nr_parts       = ARRAY_SIZE(da850evm_spiflash_part),
+       .type           = "m25p64",
+};
+
+static struct davinci_spi_config da850evm_spiflash_cfg = {
+       .io_type        = SPI_IO_TYPE_DMA,
+       .c2tdelay       = 8,
+       .t2cdelay       = 8,
+};
+
+static struct spi_board_info da850evm_spi_info[] = {
+       {
+               .modalias               = "m25p80",
+               .platform_data          = &da850evm_spiflash_data,
+               .controller_data        = &da850evm_spiflash_cfg,
+               .mode                   = SPI_MODE_0,
+               .max_speed_hz           = 30000000,
+               .bus_num                = 1,
+               .chip_select            = 0,
+       },
+};
+
 static struct mtd_partition da850_evm_norflash_partition[] = {
        {
                .name           = "bootloaders + env",
@@ -1167,6 +1234,12 @@ static __init void da850_evm_init(void)
        if (ret)
                pr_warning("da850_evm_init: suspend registration failed: %d\n",
                                ret);
+
+       ret = da8xx_register_spi(1, da850evm_spi_info,
+                                ARRAY_SIZE(da850evm_spi_info));
+       if (ret)
+               pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
+                               ret);
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE