Skip to contentSkip to conversation

SPI: DaVinci: Adding SPI driver for DaVinci

PATCH New Pablo Bitton 1 participant 1 message Aug 18, 2009

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 SPI: DaVinci: Adding SPI driver for DaVinci

This patch adds support for SPI in DaVinci DM6446
(and tries to keep support for DM355/DM365/DM6467 and DA8xx).
Mostly the same as the patch by Sandeep Paulraj in davinci-linux-open-source.

This has been tested on the DM6446 by defining a spidev device and using a oscilloscope (to check correctness) and a hardware loopback.
This was NOT tested on DM355, DM365 and DM6467 as the previous patch - in fact, it will probably not work "as is" because its default mode is CS low-inactive (default mode of SPI in kernel) - need to set CS_HIGH mode to work as in the previous patch.

Changes from the patch by Sandeep Paulraj:

Bug fixes:
* Additional word written with chip select up after each transfer. Particulary problematic with NO_CS mode where this word can't be distiguished from correct words. Problem was in davinci_chip_select.
* setup() for one chip select may interfere with transfer for another
* Small nitpicks (bits that can be changed only on VERSION_2)

Features added:
* Support DM6446
* Support CS_HIGH mode (using SPIDEF register). Note that CS low is default.

Other:
* Less accesses to registers used.
* Once-per-device configuration is done only in probe(), not each transfer.

Uglyness still there:
* VERSION_X definitions for different SPI controllers - added VERSION_3 for the dm6446, which is ugly.

NOTE:
This patch is based on following patches:

SPI: DaVinci: Adding SPI driver for DM3xx/DM6467/DA8xx

The patch adds support for SPI in DaVinci
DM355/DM365/DM6467 and DA8xx.

This has been tested on the DM355, DM365 and DM6467 EVMs using the EEPROM connected to SPI0

DaVinci: DM646x: Adding Support for SPI

The patch does the following

1) Adds a clock for SPI
2) Defines resources specific to DM646x SOC

---
 arch/arm/mach-davinci/dm644x.c              |   50 ++-
 arch/arm/mach-davinci/dm646x.c              |   53 ++
 arch/arm/mach-davinci/include/mach/dm644x.h |    3 +
 arch/arm/mach-davinci/include/mach/dm646x.h |    2 +
 arch/arm/mach-davinci/include/mach/spi.h    |   46 ++
 drivers/spi/Kconfig                         |    7 +
 drivers/spi/Makefile                        |    1 +
 drivers/spi/davinci_spi.c                   |  771 +++++++++++++++++++++++++++
 drivers/spi/davinci_spi.h                   |  178 ++++++
 12 files changed, 1149 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-davinci/include/mach/spi.h
 create mode 100644 drivers/spi/davinci_spi.c
 create mode 100644 drivers/spi/davinci_spi.h
arch/arm/mach-davinci/dm644x.c +49 -1
index 55317b1..d395354 100644
@@ -14,6 +14,7 @@
 #include <linux/serial_8250.h>
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
+#include <linux/spi/spi.h>
 
 #include <asm/mach/map.h>
 
@@ -28,6 +29,7 @@
 #include <mach/serial.h>
 #include <mach/common.h>
 #include <mach/asp.h>
+#include <mach/spi.h>
 
 #include "clock.h"
 #include "mux.h"
@@ -306,7 +308,7 @@ struct davinci_clk dm644x_clks[] = {
 	CLK("palm_bk3710", NULL, &ide_clk),
 	CLK("davinci-asp", NULL, &asp_clk),
 	CLK("davinci_mmc.0", NULL, &mmcsd_clk),
-	CLK(NULL, "spi", &spi_clk),
+	CLK("spi_davinci.0", NULL, &spi_clk),
 	CLK(NULL, "gpio", &gpio_clk),
 	CLK(NULL, "usb", &usb_clk),
 	CLK(NULL, "vlynq", &vlynq_clk),
@@ -320,6 +322,52 @@ struct davinci_clk dm644x_clks[] = {
 	CLK(NULL, NULL, NULL),
 };
 
+
+static u64 dm644x_spi_dma_mask = DMA_BIT_MASK(32);
+
+static struct davinci_spi_platform_data dm644x_spi_pdata = {
+	.version 	= SPI_VERSION_3,
+	.num_chipselect = 2,
+	.clk_internal	= 1,
+	.cs_hold	= 0,
+	.intr_level	= 0,
+	.poll_mode	= 1,
+	.c2tdelay	= 8,
+	.t2cdelay	= 8,
+};
+
+static struct resource dm644x_spi_resources[] = {
+	{
+		.start = 0x01c66800,
+		.end   = 0x01c66fff,
+		.flags = IORESOURCE_MEM,
+	},
+	{
+		.start = IRQ_SPINT0,
+		.flags = IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device dm644x_spi_device = {
+	.name = "spi_davinci",
+	.id = 0,
+	.dev = {
+		.dma_mask = &dm644x_spi_dma_mask,
+		.coherent_dma_mask = DMA_BIT_MASK(32),
+		.platform_data = &dm644x_spi_pdata,
+	},
+	.num_resources = ARRAY_SIZE(dm644x_spi_resources),
+	.resource = dm644x_spi_resources,
+};
+
+void __init dm644x_init_spi(struct spi_board_info *info, unsigned len)
+{
+	spi_register_board_info(info, len);
+
+	platform_device_register(&dm644x_spi_device);
+}
+
+
 static struct emac_platform_data dm644x_emac_pdata = {
 	.ctrl_reg_offset	= DM644X_EMAC_CNTRL_OFFSET,
 	.ctrl_mod_reg_offset	= DM644X_EMAC_CNTRL_MOD_OFFSET,
arch/arm/mach-davinci/dm646x.c +53 -0

83 lines not on this page · raw message

arch/arm/mach-davinci/include/mach/dm644x.h +3 -0
index 8b157ce..0710596 100644
@@ -36,5 +36,8 @@
 
 void __init dm644x_init(void);
 void __init dm644x_init_asp(struct snd_platform_data *pdata);
+struct spi_board_info;
+void __init dm644x_init_spi(struct spi_board_info *info, unsigned len);
+
 
 #endif /* __ASM_ARCH_DM644X_H */
arch/arm/mach-davinci/include/mach/dm646x.h +2 -0
index 0585484..498163f 100644
@@ -25,5 +25,7 @@
 void __init dm646x_init_ide(void);
 void __init dm646x_init_mcasp0(struct snd_platform_data *pdata);
 void __init dm646x_init_mcasp1(struct snd_platform_data *pdata);
+struct spi_board_info;
+void dm646x_init_spi0(struct spi_board_info *info, unsigned len);
 
 void dm646x_video_init(void);
arch/arm/mach-davinci/include/mach/spi.h new file +46 -0

46 lines not on this page · raw message

drivers/spi/Kconfig +7 -0
index 2c733c2..7fe9211 100644
@@ -77,6 +77,13 @@ config SPI_AU1550
 	  This driver can also be built as a module.  If so, the module
 	  will be called au1550_spi.
 
+config SPI_DAVINCI
+	tristate "SPI controller driver for DaVinci/DA8xx SoC's"
+	depends on SPI_MASTER && ARCH_DAVINCI
+	select SPI_BITBANG
+	help
+	  SPI master controller for DaVinci and DA8xx SPI modules.
+
 config SPI_BITBANG
 	tristate "Utilities for Bitbanging SPI masters"
 	help
drivers/spi/Makefile +1 -0
index 3de408d..910ac6d 100644
@@ -31,6 +31,7 @@ obj-$(CONFIG_SPI_S3C24XX)		+= spi_s3c24xx.o
 obj-$(CONFIG_SPI_TXX9)			+= spi_txx9.o
 obj-$(CONFIG_SPI_XILINX)		+= xilinx_spi.o
 obj-$(CONFIG_SPI_SH_SCI)		+= spi_sh_sci.o
+obj-$(CONFIG_SPI_DAVINCI)		+= davinci_spi.o
 # 	... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
drivers/spi/davinci_spi.c new file +776 -0

776 lines not on this page · raw message

drivers/spi/davinci_spi.h new file +178 -0

178 lines not on this page · raw message

Signature · 11 lines
1.5.4.3


-- 
Pablo Bitton <[email protected]>

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july