Merge git://git.kernel.org/pub/scm/linux/kernel/git/nico/orion into fixes
[pandora-kernel.git] / arch / arm / mach-davinci / board-da850-evm.c
index b01fb2a..a7b41bf 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",
@@ -231,8 +298,6 @@ static const short da850_evm_nor_pins[] = {
        -1
 };
 
-static u32 ui_card_detected;
-
 #if defined(CONFIG_MMC_DAVINCI) || \
     defined(CONFIG_MMC_DAVINCI_MODULE)
 #define HAS_MMC 1
@@ -244,7 +309,7 @@ static inline void da850_evm_setup_nor_nand(void)
 {
        int ret = 0;
 
-       if (ui_card_detected & !HAS_MMC) {
+       if (!HAS_MMC) {
                ret = davinci_cfg_reg_list(da850_evm_nand_pins);
                if (ret)
                        pr_warning("da850_evm_init: nand mux setup failed: "
@@ -394,7 +459,6 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
                goto exp_setup_keys_fail;
        }
 
-       ui_card_detected = 1;
        pr_info("DA850/OMAP-L138 EVM UI card detected\n");
 
        da850_evm_setup_nor_nand();
@@ -664,6 +728,13 @@ static struct snd_platform_data da850_evm_snd_data = {
        .rxnumevt       = 1,
 };
 
+static const short da850_evm_mcasp_pins[] __initconst = {
+       DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
+       DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
+       DA850_AXR_11, DA850_AXR_12,
+       -1
+};
+
 static int da850_evm_mmc_get_ro(int index)
 {
        return gpio_get_value(DA850_MMCSD_WP_PIN);
@@ -683,6 +754,13 @@ static struct davinci_mmc_config da850_mmc_config = {
        .version        = MMC_CTLR_VERSION_2,
 };
 
+static const short da850_evm_mmcsd0_pins[] __initconst = {
+       DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
+       DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
+       DA850_GPIO4_0, DA850_GPIO4_1,
+       -1
+};
+
 static void da850_panel_power_ctrl(int val)
 {
        /* lcd backlight */
@@ -1070,7 +1148,7 @@ static __init void da850_evm_init(void)
                                ret);
 
        if (HAS_MMC) {
-               ret = davinci_cfg_reg_list(da850_mmcsd0_pins);
+               ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
                if (ret)
                        pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
                                        " %d\n", ret);
@@ -1106,7 +1184,7 @@ static __init void da850_evm_init(void)
        __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
        __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
 
-       ret = davinci_cfg_reg_list(da850_mcasp_pins);
+       ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
        if (ret)
                pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
                                ret);
@@ -1153,6 +1231,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