davinci: add spi devices support for da8xx based platforms
Subsystems (3)
v4 cover davinci: add spi devices support for da8xx based platforms
This patch series adds SPI bus support and devices for the MityDSP-L138, MityARM-1808, da850 evm, and da830 evm platforms. This patch series is against the staging tree at [1] as per Sekhar's instructions.
This series has been tested on the MityDSP-L138 platform.
[1] http://arago-project.org/git/projects/?p=linux-davinci.git;a=shortlog;h=refs/heads/next-for-kevin
---
changes since v3:
-- first 5 patches of series are incorporated in [1] and not included
in this submission
-- refactored common spi registration code into da8xx_register_spi
routine, reducing effective lines of code for multiple platform support.
Michael Williamson (2):
davinci: da8xx: add spi resources and registration routine
davinci: add spi devices support for MityDSP-L138/MityARM-1808
platform
Sekhar Nori (2):
davinci: add spi devices support for da850/omap-l138/am18x evm
davinci: add spi devices support for da830/omap-l137/am17x evm
arch/arm/mach-davinci/board-da830-evm.c | 67 ++++++++++++++++++ arch/arm/mach-davinci/board-da850-evm.c | 73 +++++++++++++++++++ arch/arm/mach-davinci/board-mityomapl138.c | 84 ++++++++++++++++++++++ arch/arm/mach-davinci/devices-da8xx.c | 104 ++++++++++++++++++++++++++++ arch/arm/mach-davinci/include/mach/da8xx.h | 4 + 5 files changed, 332 insertions(+), 0 deletions(-)
PATCH v4 1/4 davinci: da8xx: add spi resources and registration routine
Add IO resource structures, platform data, and a registration routine in order to support spi device on DA850/OMAP-L138/AM18x and DA830/OMAP-L137/AM17x platforms.
--- arch/arm/mach-davinci/devices-da8xx.c | 104 ++++++++++++++++++++++++++++ arch/arm/mach-davinci/include/mach/da8xx.h | 4 + 2 files changed, 108 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/devices-da8xx.c +104 -0
@@ -38,14 +38,20 @@#define DA8XX_EMAC_MDIO_BASE 0x01e24000#define DA8XX_GPIO_BASE 0x01e26000#define DA8XX_I2C1_BASE 0x01e28000 +#define DA8XX_SPI0_BASE 0x01c41000 +#define DA8XX_SPI1_BASE 0x01f0e000#define DA8XX_EMAC_CTRL_REG_OFFSET 0x3000#define DA8XX_EMAC_MOD_REG_OFFSET 0x2000#define DA8XX_EMAC_RAM_OFFSET 0x0000#define DA8XX_EMAC_CTRL_RAM_SIZE SZ_8K +#define DA8XX_DMA_SPI0_RX EDMA_CTLR_CHAN(0, 14) +#define DA8XX_DMA_SPI0_TX EDMA_CTLR_CHAN(0, 15)#define DA8XX_DMA_MMCSD0_RX EDMA_CTLR_CHAN(0, 16)#define DA8XX_DMA_MMCSD0_TX EDMA_CTLR_CHAN(0, 17) +#define DA8XX_DMA_SPI1_RX EDMA_CTLR_CHAN(0, 18) +#define DA8XX_DMA_SPI1_TX EDMA_CTLR_CHAN(0, 19)#define DA850_DMA_MMCSD1_RX EDMA_CTLR_CHAN(1, 28)#define DA850_DMA_MMCSD1_TX EDMA_CTLR_CHAN(1, 29)
@@ -730,3 +736,101 @@ int __init da8xx_register_cpuidle(void)return platform_device_register (&da8xx_cpuidle_device); } + +static struct resource da8xx_spi0_resources[] = { + [0 ] = { + .start =DA8XX_SPI0_BASE , + .end =DA8XX_SPI0_BASE +SZ_4K -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =IRQ_DA8XX_SPINT0 , + .end =IRQ_DA8XX_SPINT0 , + .flags =IORESOURCE_IRQ , + }, + [2 ] = { + .start =DA8XX_DMA_SPI0_RX , + .end =DA8XX_DMA_SPI0_RX , + .flags =IORESOURCE_DMA , + }, + [3 ] = { + .start =DA8XX_DMA_SPI0_TX , + .end =DA8XX_DMA_SPI0_TX , + .flags =IORESOURCE_DMA , + }, +}; + +static struct resource da8xx_spi1_resources[] = { + [0 ] = { + .start =DA8XX_SPI1_BASE , + .end =DA8XX_SPI1_BASE +SZ_4K -1 , + .flags =IORESOURCE_MEM , + }, + [1 ] = { + .start =IRQ_DA8XX_SPINT1 , + .end =IRQ_DA8XX_SPINT1 , + .flags =IORESOURCE_IRQ , + }, + [2 ] = { + .start =DA8XX_DMA_SPI1_RX , + .end =DA8XX_DMA_SPI1_RX , + .flags =IORESOURCE_DMA , + }, + [3 ] = { + .start =DA8XX_DMA_SPI1_TX , + .end =DA8XX_DMA_SPI1_TX , + .flags =IORESOURCE_DMA , + }, +}; + +struct davinci_spi_platform_data da8xx_spi_pdata[] = { + [0 ] = { + .version =SPI_VERSION_2 , + .intr_line =1 , + .dma_event_q =EVENTQ_0 , + }, + [1 ] = { + .version =SPI_VERSION_2 , + .intr_line =1 , + .dma_event_q =EVENTQ_0 , + }, +}; + +static struct platform_device da8xx_spi_device[] = { + [0 ] = { + .name ="spi_davinci" , + .id =0 , + .num_resources =ARRAY_SIZE (da8xx_spi0_resources), + .resource = da8xx_spi0_resources, + .dev = { + .platform_data = &da8xx_spi_pdata[0 ], + }, + }, + [1 ] = { + .name ="spi_davinci" , + .id =1 , + .num_resources =ARRAY_SIZE (da8xx_spi1_resources), + .resource = da8xx_spi1_resources, + .dev = { + .platform_data = &da8xx_spi_pdata[1 ], + }, + }, +}; + +int __init da8xx_register_spi (int instance,struct spi_board_info *info, +unsigned len) +{ +int ret; + +if (instance <0 || instance >1 ) +return -EINVAL ; + + ret =spi_register_board_info (info, len); +if (ret) +pr_warning ("%s: failed to register board info for spi %d :" +" %d\n" , __func__, instance, ret); + + da8xx_spi_pdata[instance].num_chipselect = len; + +return platform_device_register (&da8xx_spi_device[instance]); +}
arch/arm/mach-davinci/include/mach/da8xx.h +4 -0
@@ -15,6 +15,7 @@#include <linux/platform_device.h> #include <linux/davinci_emac.h> +#include <linux/spi/spi.h> #include <mach/serial.h> #include <mach/edma.h>
@@ -23,6 +24,7 @@#include <mach/mmc.h> #include <mach/usb.h> #include <mach/pm.h> +#include <mach/spi.h> extern void __iomem *da8xx_syscfg0_base;extern void __iomem *da8xx_syscfg1_base;
@@ -77,6 +79,7 @@ void __init da850_init(void);int da830_register_edma (struct edma_rsv_info *rsv);int da850_register_edma (struct edma_rsv_info *rsv[2 ]);int da8xx_register_i2c (int instance,struct davinci_i2c_platform_data *pdata); +int da8xx_register_spi (int instance,struct spi_board_info *info,unsigned len);int da8xx_register_watchdog (void );int da8xx_register_usb20 (unsigned mA,unsigned potpgt);int da8xx_register_usb11 (struct da8xx_ohci_root_hub *pdata);
@@ -95,6 +98,7 @@ extern struct platform_device da8xx_serial_device;extern struct emac_platform_data da8xx_emac_pdata;extern struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata;extern struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata; +extern struct davinci_spi_platform_data da8xx_spi_pdata[];extern struct platform_device da8xx_wdt_device;
Signature · 1 line
1.7.0.4
PATCH v4 1/4 davinci: da8xx: add spi resources and registration routine
Quoted 15 lines · Michael Williamson
Add IO resource structures, platform data, and a registration routine in order to support spi device on DA850/OMAP-L138/AM18x and DA830/OMAP-L137/AM17x platforms.
Signed-off-by Michael Williamson <[email protected]>--- arch/arm/mach-davinci/devices-da8xx.c | 104 ++++++++++++++++++++++++++++ arch/arm/mach-davinci/include/mach/da8xx.h | 4 + 2 files changed, 108 insertions(+), 0 deletions(-)arch/arm/mach-davinci/devices-da8xx.c +0
-0
arch/arm/mach-davinci/devices-da8xx.c line 42
Quoted 5 lines
arch/arm/mach-davinci/devices-da8xx.c +2
-0@@ -38,14 +38,20 @@#define DA8XX_EMAC_MDIO_BASE 0x01e24000#define DA8XX_GPIO_BASE 0x01e26000#define DA8XX_I2C1_BASE 0x01e28000 +#define DA8XX_SPI0_BASE 0x01c41000 +#define DA8XX_SPI1_BASE 0x01f0e000
Unfortunately, DA830 and DA850 have SPI#1 mapped at different addresses, so
this will work only on DA850. I'll send a patch...
WBR, Sergei
PATCH v4 2/4 davinci: add spi devices support for MityDSP-L138/MityARM-1808 platform
In reply to Michael WilliamsonThis patch adds support for accessing the on board SPI NOR FLASH device for MityDSP-L138 and MityARM-1808 SoMs.
--- arch/arm/mach-davinci/board-mityomapl138.c | 84 ++++++++++++++++++++++++++++ 1 files changed, 84 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-mityomapl138.c +84 -0
@@ -17,6 +17,8 @@#include <linux/i2c.h> #include <linux/i2c/at24.h> #include <linux/etherdevice.h> +#include <linux/spi/spi.h> +#include <linux/spi/flash.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -25,6 +27,7 @@#include <mach/da8xx.h> #include <mach/nand.h> #include <mach/mux.h> +#include <mach/spi.h> #define MITYOMAPL138_PHY_ID "0:03"
@@ -294,6 +297,82 @@ static int __init pmic_tps65023_init(void) }/* +* SPI Devices: +* SPI1_CS0: 8M Flash ST-M25P64-VME6G +*/ +static struct mtd_partition spi_flash_partitions[] = { + [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 ="periph-config" , + .offset =MTDPART_OFS_APPEND , + .size =SZ_64K , + .mask_flags =MTD_WRITEABLE , + }, + [4 ] = { + .name ="reserved" , + .offset =MTDPART_OFS_APPEND , + .size =SZ_256K +SZ_64K , + }, + [5 ] = { + .name ="kernel" , + .offset =MTDPART_OFS_APPEND , + .size =SZ_2M +SZ_1M , + }, + [6 ] = { + .name ="fpga" , + .offset =MTDPART_OFS_APPEND , + .size =SZ_2M , + }, + [7 ] = { + .name ="spare" , + .offset =MTDPART_OFS_APPEND , + .size =MTDPART_SIZ_FULL , + }, +}; + +static struct flash_platform_data mityomapl138_spi_flash_data = { + .name ="m25p80" , + .parts = spi_flash_partitions, + .nr_parts =ARRAY_SIZE (spi_flash_partitions), + .type ="m24p64" , +}; + +static struct davinci_spi_config spi_eprom_config = { + .io_type =SPI_IO_TYPE_DMA , + .c2tdelay =8 , + .t2cdelay =8 , +}; + +static struct spi_board_info mityomapl138_spi_flash_info[] = { + { + .modalias ="m25p80" , + .platform_data = &mityomapl138_spi_flash_data, + .controller_data = &spi_eprom_config, + .mode =SPI_MODE_0 , + .max_speed_hz =30000000 , + .bus_num =1 , + .chip_select =0 , + }, +}; + +/* * MityDSP-L138 includes a 256 MByte large-page NAND flash * (128K blocks). */
@@ -448,6 +527,11 @@ static void __init mityomapl138_init(void)mityomapl138_setup_nand (); + ret =da8xx_register_spi (1 , mityomapl138_spi_flash_info, +ARRAY_SIZE (mityomapl138_spi_flash_info)); +if (ret) +pr_warning ("spi 1 registration failed: %d\n" , ret); +mityomapl138_config_emac (); ret =da8xx_register_rtc ();
Signature · 1 line
1.7.0.4
PATCH v4 3/4 davinci: add spi devices support for da850/omap-l138/am18x evm
In reply to Michael WilliamsonFrom: Sekhar Nori <[email protected]>
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.
--- arch/arm/mach-davinci/board-da850-evm.c | 73 +++++++++++++++++++++++++++++++ 1 files changed, 73 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +73 -0
@@ -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)
@@ -48,6 +51,70 @@#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
Signature · 1 line
1.7.0.4
PATCH v4 4/4 davinci: add spi devices support for da830/omap-l137/am17x evm
In reply to Michael WilliamsonFrom: Sekhar Nori <[email protected]>
This patch adds the on-board SPI flash device to the DA830/OMAP-L137/AM17x EVM. It also registers the SPI flash device to the MTD subsystem.
Based on SPI flash device support for MityDSP-L138F platform.
--- arch/arm/mach-davinci/board-da830-evm.c | 67 +++++++++++++++++++++++++++++++ 1 files changed, 67 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-da830-evm.c +67 -0
@@ -20,6 +20,8 @@#include <linux/i2c/at24.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> +#include <linux/spi/spi.h> +#include <linux/spi/flash.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -30,6 +32,7 @@#include <mach/da8xx.h> #include <mach/usb.h> #include <mach/aemif.h> +#include <mach/spi.h> #define DA830_EVM_PHY_ID ""/*
@@ -534,6 +537,64 @@ static struct edma_rsv_info da830_edma_rsv[] = { }, }; +static struct mtd_partition da830evm_spiflash_part[] = { + [0 ] = { + .name ="DSP-UBL" , + .offset =0 , + .size =SZ_8K , + .mask_flags =MTD_WRITEABLE , + }, + [1 ] = { + .name ="ARM-UBL" , + .offset =MTDPART_OFS_APPEND , + .size =SZ_16K +SZ_8K , + .mask_flags =MTD_WRITEABLE , + }, + [2 ] = { + .name ="U-Boot" , + .offset =MTDPART_OFS_APPEND , + .size =SZ_256K -SZ_32K , + .mask_flags =MTD_WRITEABLE , + }, + [3 ] = { + .name ="U-Boot-Environment" , + .offset =MTDPART_OFS_APPEND , + .size =SZ_16K , + .mask_flags =0 , + }, + [4 ] = { + .name ="Kernel" , + .offset =MTDPART_OFS_APPEND , + .size =MTDPART_SIZ_FULL , + .mask_flags =0 , + }, +}; + +static struct flash_platform_data da830evm_spiflash_data = { + .name ="m25p80" , + .parts = da830evm_spiflash_part, + .nr_parts =ARRAY_SIZE (da830evm_spiflash_part), + .type ="w25x32" , +}; + +static struct davinci_spi_config da830evm_spiflash_cfg = { + .io_type =SPI_IO_TYPE_DMA , + .c2tdelay =8 , + .t2cdelay =8 , +}; + +static struct spi_board_info da830evm_spi_info[] = { + { + .modalias ="m25p80" , + .platform_data = &da830evm_spiflash_data, + .controller_data = &da830evm_spiflash_cfg, + .mode =SPI_MODE_0 , + .max_speed_hz =30000000 , + .bus_num =0 , + .chip_select =0 , + }, +}; +static __init void da830_evm_init (void ) {struct davinci_soc_info *soc_info = &davinci_soc_info;
@@ -590,6 +651,12 @@ static __init void da830_evm_init(void) ret =da8xx_register_rtc ();if (ret)pr_warning ("da830_evm_init: rtc setup failed: %d\n" , ret); + + ret =da8xx_register_spi (0 , da830evm_spi_info, +ARRAY_SIZE (da830evm_spi_info)); +if (ret) +pr_warning ("da830_evm_init: spi 0 registration failed: %d\n" , + ret); }#ifdef CONFIG_SERIAL_8250_CONSOLE
Signature · 1 line
1.7.0.4
Nori, Sekhar
Appliedv4 cover davinci: add spi devices support for da8xx based platforms
In reply to Michael WilliamsonHi Mike,
Quoted 5 lines · Michael Williamson
This patch series adds SPI bus support and devices for the MityDSP-L138, MityARM-1808, da850 evm, and da830 evm platforms. This patch series is against the staging tree at [1] as per Sekhar's instructions.
This series has been tested on the MityDSP-L138 platform.
I queued these patches for Kevin to pick-up for 2.6.39
Thanks for your efforts on this.
Best Regards,
Sekhar