Skip to contentSkip to conversation

SPI: OMAP2 Driver (David Brownell's fwk)

PATCH New Komal Shah 1 participant 1 message Jan 6, 2006

Subsystems (8)
lore
Share & tools
lore

Komal Shah

author
#0 lore raw

PATCH 1/1 SPI: OMAP2 Driver (David Brownell's fwk)

Tony,

Attached patch is my first attempt to follow David Brownell's SPI fwk (as per 2.6.15-rc5-mm3 SPI fwk patches) to implement SPI master controller driver for OMAP2.

o Also includes tsc2101 driver - Derived from ads7846 patch by David Brownell.

Status:
- OMAP2 SPI master controller tries to do interrupt based txrx, but I am trying to test tx only with first tweleve 16 bit configuration commands of tsc2101. It stops after 8th message as of now..and I don't know the reason yet..You can see that Interrupt routine is also in bad shape :).

I am posting it on mailing list as to reduce duplicate work!!!. Hoping that everyone sees my patches.

- It will not apply cleanly to the latest git head. I will rebase once clock fwk changes are pushed.

I will appreciate all the review comments. Thanx.

---Komal Shah
http://komalshah.blogspot.com/

__________________________________________
Yahoo! DSL – Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com

arch/arm/mach-omap2/devices.c +115 -0
index 7181edb..917f20e 100644
@@ -15,6 +15,9 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 
+#include <linux/spi/spi.h>
+#include <linux/spi/tsc2101.h>
+
 #include <asm/hardware.h>
 #include <asm/io.h>
 #include <asm/mach-types.h>
@@ -24,6 +27,7 @@
 #include <asm/arch/board.h>
 #include <asm/arch/mux.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/spi.h>
 
 extern void omap_nop_release(struct device *dev);
 
@@ -74,6 +78,116 @@ static void omap_init_i2c(void) {}
 
 #endif
 
+#if 	defined(CONFIG_SPI_OMAP2) || defined(CONFIG_SPI_OMAP2_MODULE)
+
+#define OMAP2_SPI_BASE1		0x48098000
+#define OMAP2_SPI_INT1		65
+
+#define OMAP2_SPI_BASE2		0x4809A000
+#define OMAP2_SPI_INT2		66
+
+static struct resource spi_resources1[] = {
+	{
+		.start		= OMAP2_SPI_BASE1,
+		.end		= OMAP2_SPI_BASE1 + 0x3f,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= OMAP2_SPI_INT1,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+
+static struct omap_spi_platform_info spi1_info = {
+	.bus_num 	= 1,
+	.num_chipselect = 4,
+};
+
+static struct platform_device omap_spi_device1 = {
+	.name           = "spi_omap",
+	.id             = 1,
+	.dev = {
+		.release        = omap_nop_release,
+		.platform_data	= &spi1_info,
+	},
+	.num_resources	= ARRAY_SIZE(spi_resources1),
+	.resource	= spi_resources1,
+};
+
+static struct resource spi_resources2[] = {
+	{
+		.start		= OMAP2_SPI_BASE2,
+		.end		= OMAP2_SPI_BASE2 + 0x3f,
+		.flags		= IORESOURCE_MEM,
+	},
+	{
+		.start		= OMAP2_SPI_INT2,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+
+static struct omap_spi_platform_info spi2_info = {
+	.bus_num 	= 2,
+	.num_chipselect = 2,
+};
+
+static struct platform_device omap_spi_device2 = {
+	.name           = "spi_omap",
+	.id             = 2,
+	.dev = {
+		.release        = omap_nop_release,
+		.platform_data	= &spi2_info,
+	},
+	.num_resources	= ARRAY_SIZE(spi_resources2),
+	.resource	= spi_resources2,
+};
+
+/* REVISIT This should be moved to board-h4.c */
+static struct tsc2101_platform_data tsc2101_platform_info = {
+	.x_plate_ohms = 500,	
+};
+
+/* Chip connected to OMAP spi bus - controller data */
+static struct omap_spi_chip tsc2101_chip_info = {
+	.mode		= SPI_MODE_1,
+	.master		= 0,
+	.txrx		= OMAP_MCSPI_TXRX,
+	.bits_per_word	= 16,
+	.clkdiv		= 3,
+	.cspol		= SPI_CS_HIGH,
+	.endianess	= 0,
+};
+
+static struct spi_board_info h4_spi_board_info[] __initdata = {
+	{
+		.modalias	= "tsc2101",
+		.platform_data	= &tsc2101_platform_info,
+		.controller_data= &tsc2101_chip_info,
+		.irq		= OMAP_GPIO_IRQ(93), /*PENIRQ*/
+		.max_speed_hz 	= 48000000,
+		.bus_num	= 1,
+		.chip_select	= 0,
+	},
+};
+
+/* See also arch/arm/plat-omap/devices.c for first SPI on 24xx */
+static void omap_init_spi(void)
+{
+	/* TODO: Add mux tables for H4 SPI*/
+	if (machine_is_omap_h4()) {
+		omap_cfg_reg(P20_24XX_TSC_IRQ);
+	}
+	(void) platform_device_register(&omap_spi_device1);
+	(void) platform_device_register(&omap_spi_device2);
+	spi_register_board_info(h4_spi_board_info, ARRAY_SIZE(h4_spi_board_info));
+}
+
+#else
+
+static void omap_init_spi(void) {}
+
+#endif
+
 /*-------------------------------------------------------------------------*/
 
 static int __init omap2_init_devices(void)
@@ -82,6 +196,7 @@ static int __init omap2_init_devices(voi
 	 * in alphabetical order so they're easier to sort through.
 	 */
 	omap_init_i2c();
+	omap_init_spi();
 
 	return 0;
 }
arch/arm/mach-omap2/mux.c +3 -0
index ea46548..ede2c93 100644
@@ -54,6 +54,9 @@ MUX_CFG_24XX("W19_24XX_SYS_NIRQ",	0x12c,
 MUX_CFG_24XX("Y20_24XX_GPIO60",		0x12c,	3,	0,	0,	1)
 MUX_CFG_24XX("M15_24XX_GPIO92",		0x10a,	3,	0,	0,	1)
 
+/* TSC IRQ */
+MUX_CFG_24XX("P20_24XX_TSC_IRQ",	0x108,	0,	0,	0,	1)
+
 };
 
 int __init omap2_mux_init(void)
drivers/i2c/busses/i2c-omap.c +0 -0
drivers/input/touchscreen/Kconfig +14 -0
index 68d0440..05901e6 100644
@@ -24,6 +24,20 @@ config TOUCHSCREEN_ADS7846
 	  To compile this driver as a module, choose M here: the
 	  module will be called ads7846.
 
+config TOUCHSCREEN_TSC2101
+	tristate "TSC 2101 based touchscreens"
+	depends on SPI_MASTER
+	help
+	  Say Y here if you have a touchscreen interface using the
+	  TSC2101 controller, and your board-specific initialization
+	  code includes that in its table of SPI devices.
+
+	  If unsure, say N (but it's safe to say "Y").
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ads7846.
+
+
 config TOUCHSCREEN_BITSY
 	tristate "Compaq iPAQ H3600 (Bitsy) touchscreen"
 	depends on SA1100_BITSY
drivers/input/touchscreen/Makefile +1 -0
index b5866f9..bf28fd0 100644
@@ -5,6 +5,7 @@
 # Each configuration option enables a list of files.
 
 obj-$(CONFIG_TOUCHSCREEN_ADS7846)	+= ads7846.o
+obj-$(CONFIG_TOUCHSCREEN_TSC2101)	+= tsc2101.o
 obj-$(CONFIG_TOUCHSCREEN_BITSY)	+= h3600_ts_input.o
 obj-$(CONFIG_TOUCHSCREEN_CORGI)	+= corgi_ts.o
 obj-$(CONFIG_TOUCHSCREEN_GUNZE)	+= gunze.o
drivers/input/touchscreen/tsc2101.c new file +429 -0

429 lines not on this page · raw message

drivers/spi/Kconfig +6 -0
index 022446c..f6ac536 100644
@@ -90,6 +90,12 @@ config SPI_BUTTERFLY
 	  inexpensive battery powered microcontroller evaluation board.
 	  This same cable can be used to flash new firmware.
 
+config SPI_OMAP2
+	tristate "OMAP2 SPI master"
+	depends on SPI_MASTER && EXPERIMENTAL
+	help
+	  OMAP2 SPI master driver. More help later.
+
 #
 # Add new SPI master controllers in alphabetical order above this line
 #
drivers/spi/Makefile +1 -0
index c2c87e8..443f7be 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_SPI_MASTER)		+= spi.o
 # SPI master controller drivers (bus)
 obj-$(CONFIG_SPI_BITBANG)		+= spi_bitbang.o
 obj-$(CONFIG_SPI_BUTTERFLY)		+= spi_butterfly.o
+obj-$(CONFIG_SPI_OMAP2)			+= spi_omap2.o
 # 	... add above this line ...
 
 # SPI protocol drivers (device/link on bus)
drivers/spi/spi.c +0 -0
drivers/spi/spi_butterfly.c +0 -0
drivers/spi/spi_omap2.c new file +806 -0

806 lines not on this page · raw message

include/asm-arm/arch-omap/mux.h +3 -0
index 8d1c62e..b12b8f2 100644
@@ -410,6 +410,9 @@ enum omap24xx_index {
 	/* 24xx GPIO */
 	Y20_24XX_GPIO60,
 	M15_24XX_GPIO92,
+	
+	/* TSC IRQ*/
+	P20_24XX_TSC_IRQ,
 };
 
 #ifdef	CONFIG_OMAP_MUX
include/asm-arm/arch-omap/spi.h new file +43 -0

43 lines not on this page · raw message

include/asm-arm/hardware/tsc2101.h +0 -0
include/linux/list.h +0 -0
include/linux/spi/spi.h +0 -0
include/linux/spi/tsc2101.h new file +18 -0
new file mode 100644
index 0000000..f483b07
@@ -0,0 +1,18 @@
+/* linux/spi/tsc2101.h */
+
+/* Touchscreen characteristics vary between boards and models.  The
+ * platform_data for the device's "struct device" holds this information.
+ *
+ * It's OK if the min/max values are zero.
+ */
+struct tsc2101_platform_data {
+	u16	model;			/* 7843, 7845, 7846. */
+	u16	vref_delay_usecs;	/* 0 for external vref; etc */
+	u16	x_plate_ohms;
+	u16	y_plate_ohms;
+
+	u16	x_min, x_max;
+	u16	y_min, y_max;
+	u16	pressure_min, pressure_max;
+};
+