]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
DaVinci DM365: Adding DM365 SPI support
authorSandeep Paulraj <s-paulraj@ti.com>
Mon, 1 Feb 2010 14:51:31 +0000 (09:51 -0500)
committerKevin Hilman <khilman@deeprootsystems.com>
Mon, 1 Mar 2010 18:20:24 +0000 (10:20 -0800)
This patch adds SPI init for DM365.
It does the following
1) Initializes SPI0
2) Defines resources to be used by SPI0
3) Adds platform data for SPI0

Signed-off-by: Sandeep Paulraj <s-paulraj@ti.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
arch/arm/mach-davinci/dm365.c
arch/arm/mach-davinci/include/mach/dm365.h

index e88f2624df68447b5a8a936ad68517047625e699..27772e18e45b948014b18e6294e08eaee1846afb 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/dma-mapping.h>
 #include <linux/gpio.h>
+#include <linux/spi/spi.h>
 
 #include <asm/mach/map.h>
 
@@ -32,6 +33,8 @@
 #include <mach/common.h>
 #include <mach/asp.h>
 #include <mach/keyscan.h>
+#include <mach/spi.h>
+
 
 #include "clock.h"
 #include "mux.h"
@@ -611,6 +614,73 @@ EVT_CFG(DM365,     EVT3_VC_RX,          1,     1,    1,     false)
 #endif
 };
 
+static u64 dm365_spi0_dma_mask = DMA_BIT_MASK(32);
+
+static struct davinci_spi_platform_data dm365_spi0_pdata = {
+       .version        = SPI_VERSION_1,
+       .num_chipselect = 2,
+       .clk_internal   = 1,
+       .cs_hold        = 1,
+       .intr_level     = 0,
+       .poll_mode      = 1,    /* 0 -> interrupt mode 1-> polling mode */
+       .c2tdelay       = 0,
+       .t2cdelay       = 0,
+};
+
+static struct resource dm365_spi0_resources[] = {
+       {
+               .start = 0x01c66000,
+               .end   = 0x01c667ff,
+               .flags = IORESOURCE_MEM,
+       },
+       {
+               .start = IRQ_DM365_SPIINT0_0,
+               .flags = IORESOURCE_IRQ,
+       },
+       {
+               .start = 17,
+               .flags = IORESOURCE_DMA,
+       },
+       {
+               .start = 16,
+               .flags = IORESOURCE_DMA,
+       },
+       {
+               .start = EVENTQ_3,
+               .flags = IORESOURCE_DMA,
+       },
+};
+
+static struct platform_device dm365_spi0_device = {
+       .name = "spi_davinci",
+       .id = 0,
+       .dev = {
+               .dma_mask = &dm365_spi0_dma_mask,
+               .coherent_dma_mask = DMA_BIT_MASK(32),
+               .platform_data = &dm365_spi0_pdata,
+       },
+       .num_resources = ARRAY_SIZE(dm365_spi0_resources),
+       .resource = dm365_spi0_resources,
+};
+
+void __init dm365_init_spi0(unsigned chipselect_mask,
+               struct spi_board_info *info, unsigned len)
+{
+       davinci_cfg_reg(DM365_SPI0_SCLK);
+       davinci_cfg_reg(DM365_SPI0_SDI);
+       davinci_cfg_reg(DM365_SPI0_SDO);
+
+       /* not all slaves will be wired up */
+       if (chipselect_mask & BIT(0))
+               davinci_cfg_reg(DM365_SPI0_SDENA0);
+       if (chipselect_mask & BIT(1))
+               davinci_cfg_reg(DM365_SPI0_SDENA1);
+
+       spi_register_board_info(info, len);
+
+       platform_device_register(&dm365_spi0_device);
+}
+
 static struct emac_platform_data dm365_emac_pdata = {
        .ctrl_reg_offset        = DM365_EMAC_CNTRL_OFFSET,
        .ctrl_mod_reg_offset    = DM365_EMAC_CNTRL_MOD_OFFSET,
index fdf6f8507cc3301cc280eb6d341a03cb9f5f85e5..3a37b5a6983ca034bd91bebf2a53a6ac3c0bff7e 100644 (file)
@@ -41,6 +41,8 @@ void __init dm365_init_asp(struct snd_platform_data *pdata);
 void __init dm365_init_vc(struct snd_platform_data *pdata);
 void __init dm365_init_ks(struct davinci_ks_platform_data *pdata);
 void __init dm365_init_rtc(void);
+void dm365_init_spi0(unsigned chipselect_mask,
+                       struct spi_board_info *info, unsigned len);
 
 void dm365_set_vpfe_config(struct vpfe_config *cfg);
 #endif /* __ASM_ARCH_DM365_H */