Skip to contentSkip to conversation

Add spi100k driver and arch support

PATCH In review Cory Maccarrone 2 participants 7 messages Dec 13, 2009 – Jan 9, 2010

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

v2 cover Add spi100k driver and arch support

This patch set implements the spi100k driver we use in the linwizard and wing-linux projects. This SPI driver is used for many omap7xx devices, particularly omap850 HTC smartphones.

The first patch is directed at the SPI subsystem mailing list primarily for review. The other two are directed primarily at linux-omap for review. All three are sent to both to preserve complete context for all to see.

This is a resubmit of the entire patch series to account for comments recieved on the first one.

Cory Maccarrone (3):
[SPI] [OMAP] Add OMAP spi100k driver
[OMAP] Add spi100k configuration to OMAP1
[OMAP] Add OMAP 7xx pin muxes for SPI

 arch/arm/mach-omap1/clock.c               |    4 +
 arch/arm/mach-omap1/devices.c             |   34 ++
 arch/arm/mach-omap1/mux.c                 |    8 +
 arch/arm/plat-omap/include/plat/mux.h     |    8 +
 arch/arm/plat-omap/include/plat/omap7xx.h |    3 +
 drivers/spi/Kconfig                       |    6 +
 drivers/spi/Makefile                      |    1 +
 drivers/spi/omap_spi_100k.c               |  635 +++++++++++++++++++++++++++++
 8 files changed, 699 insertions(+), 0 deletions(-)
 create mode 100644 drivers/spi/omap_spi_100k.c
#1 lore raw

PATCH v3 1/3 Add OMAP spi100k driver

This change adds the OMAP SPI 100k driver created by Fabrice Crohas <[email protected]>. This SPI bus is found on OMAP7xx-series smartphones, and for many, the touchscreen is attached to this bus.

The lion's share of the work was done by Fabrice on this driver -- I am merely porting it from the Linwizard project on his behalf.

---
 drivers/spi/Kconfig         |    6 +
 drivers/spi/Makefile        |    1 +
 drivers/spi/omap_spi_100k.c |  635 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 642 insertions(+), 0 deletions(-)
 create mode 100644 drivers/spi/omap_spi_100k.c
drivers/spi/Kconfig +6 -0
index 4b6f7cb..7ef9b12 100644
@@ -164,6 +164,12 @@ config SPI_OMAP24XX
 	  SPI master controller for OMAP24xx/OMAP34xx Multichannel SPI
 	  (McSPI) modules.
 
+config SPI_OMAP_100K
+	tristate "OMAP SPI 100K"
+	depends on SPI_MASTER && (ARCH_OMAP850 || ARCH_OMAP730)
+	help
+	  OMAP SPI 100K master controller for omap7xx boards.
+
 config SPI_ORION
 	tristate "Orion SPI master (EXPERIMENTAL)"
 	depends on PLAT_ORION && EXPERIMENTAL
drivers/spi/Makefile +1 -0
index 21a1182..55f670d 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_SPI_LM70_LLP)		+= spi_lm70llp.o
 obj-$(CONFIG_SPI_PXA2XX)		+= pxa2xx_spi.o
 obj-$(CONFIG_SPI_OMAP_UWIRE)		+= omap_uwire.o
 obj-$(CONFIG_SPI_OMAP24XX)		+= omap2_mcspi.o
+obj-$(CONFIG_SPI_OMAP_100K)		+= omap_spi_100k.o
 obj-$(CONFIG_SPI_ORION)			+= orion_spi.o
 obj-$(CONFIG_SPI_PL022)			+= amba-pl022.o
 obj-$(CONFIG_SPI_MPC52xx_PSC)		+= mpc52xx_psc_spi.o
drivers/spi/omap_spi_100k.c new file +635 -0

635 lines not on this page · raw message

Signature · 6 lines
1.6.3.3

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH v2 2/3 Add spi100k configuration to OMAP1

In reply to Cory Maccarrone

This change implements the clocks, platform driver, and register information necessary to use the spi100k bus with OMAP 7xx systems.

The clocks added are dummy clocks because, although we're pretty sure there are clocks used for SPI, all current booting methods result in proper operation without the enabling of any other clocks.

---
 arch/arm/mach-omap1/clock.c               |    4 +++
 arch/arm/mach-omap1/devices.c             |   34 +++++++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/omap7xx.h |    3 ++
 3 files changed, 41 insertions(+), 0 deletions(-)
arch/arm/mach-omap1/clock.c +4 -0
index dc8ca91..e584c0f 100644
@@ -135,6 +135,10 @@ static struct omap_clk omap_clks[] = {
 	CLK("i2c_omap.1", "fck",	&i2c_fck,	CK_16XX | CK_1510 | CK_310 | CK_7XX),
 	CLK("i2c_omap.1", "ick",	&i2c_ick,	CK_16XX),
 	CLK("i2c_omap.1", "ick",	&dummy_ck,	CK_1510 | CK_310 | CK_7XX),
+	CLK("omap1_spi100k.1", "fck",	&dummy_ck,	CK_7XX),
+	CLK("omap1_spi100k.1", "ick",	&dummy_ck,	CK_7XX),
+	CLK("omap1_spi100k.2", "fck",	&dummy_ck,	CK_7XX),
+	CLK("omap1_spi100k.2", "ick",	&dummy_ck,	CK_7XX),
 	CLK("omap_uwire", "fck",	&armxor_ck.clk,	CK_16XX | CK_1510 | CK_310),
 	CLK("omap-mcbsp.1", "ick",	&dspper_ck,	CK_16XX),
 	CLK("omap-mcbsp.1", "ick",	&dummy_ck,	CK_1510 | CK_310),
arch/arm/mach-omap1/devices.c +34 -0
index 23ded2d..20bc62c 100644
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/spi/spi.h>
 
 #include <mach/hardware.h>
 #include <asm/mach/map.h>
@@ -23,6 +24,7 @@
 #include <plat/mux.h>
 #include <mach/gpio.h>
 #include <plat/mmc.h>
+#include <plat/omap7xx.h>
 
 /*-------------------------------------------------------------------------*/
 
@@ -196,6 +198,37 @@ void __init omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
 
 /*-------------------------------------------------------------------------*/
 
+/* OMAP7xx SPI support */
+#if defined(CONFIG_SPI_OMAP_100K) || defined(CONFIG_SPI_OMAP_100K_MODULE)
+
+struct platform_device omap_spi1 = {
+	.name           = "omap1_spi100k",
+	.id             = 1,
+};
+
+struct platform_device omap_spi2 = {
+	.name           = "omap1_spi100k",
+	.id             = 2,
+};
+
+static void omap_init_spi100k(void)
+{
+	omap_spi1.dev.platform_data = ioremap(OMAP7XX_SPI1_BASE, 0x7ff);
+	BUG_ON(!omap_spi1.dev.platform_data);
+
+	omap_spi2.dev.platform_data = ioremap(OMAP7XX_SPI2_BASE, 0x7ff);
+	BUG_ON(!omap_spi2.dev.platform_data);
+
+	platform_device_register(&omap_spi1);
+	platform_device_register(&omap_spi2);
+}
+
+#else
+static inline void omap_init_spi100k(void) {}
+#endif
+
+/*-------------------------------------------------------------------------*/
+
 #if defined(CONFIG_OMAP_STI)
 
 #define OMAP1_STI_BASE		0xfffea000
@@ -263,6 +296,7 @@ static int __init omap1_init_devices(void)
 
 	omap_init_mbox();
 	omap_init_rtc();
+	omap_init_spi100k();
 	omap_init_sti();
 
 	return 0;
arch/arm/plat-omap/include/plat/omap7xx.h +3 -0
index 53f5241..48e4757 100644
@@ -46,6 +46,9 @@
 #define OMAP7XX_DSPREG_SIZE	SZ_128K
 #define OMAP7XX_DSPREG_START	0xE1000000
 
+#define OMAP7XX_SPI1_BASE	0xfffc0800
+#define OMAP7XX_SPI2_BASE	0xfffc1000
+
 /*
  * ----------------------------------------------------------------------------
  * OMAP7XX specific configuration registers
Signature · 1 line
1.6.3.3
reviewer
#3 lore raw

Re: [PATCH v2 2/3] [OMAP] Add spi100k configuration to OMAP1

Hi,

Quoted 6 lines · Cory Maccarrone

This change implements the clocks, platform driver, and register information necessary to use the spi100k bus with OMAP 7xx systems.

The clocks added are dummy clocks because, although we're pretty sure there are clocks used for SPI, all current booting methods result in proper operation without the enabling of any other clocks.

Looks like the driver is in mainline, so let's try to make it working..

Quoted 20 lines
arch/arm/mach-omap1/devices.c +14 -0
@@ -196,6 +198,37 @@ void __init omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
 
 /*-------------------------------------------------------------------------*/
 
+/* OMAP7xx SPI support */
+#if defined(CONFIG_SPI_OMAP_100K) || defined(CONFIG_SPI_OMAP_100K_MODULE)
+
+struct platform_device omap_spi1 = {
+	.name           = "omap1_spi100k",
+	.id             = 1,
+};
+
+struct platform_device omap_spi2 = {
+	.name           = "omap1_spi100k",
+	.id             = 2,
+};
+
+static void omap_init_spi100k(void)

arch/arm/mach-omap1/devices.c void __init omap1_init_mmc(struct omap_mmc_platform_data **mmc_data, · line 224

Quoted 10 lines
arch/arm/mach-omap1/devices.c +10 -0
+{
+	omap_spi1.dev.platform_data = ioremap(OMAP7XX_SPI1_BASE, 0x7ff);
+	BUG_ON(!omap_spi1.dev.platform_data);
+
+	omap_spi2.dev.platform_data = ioremap(OMAP7XX_SPI2_BASE, 0x7ff);
+	BUG_ON(!omap_spi2.dev.platform_data);
+
+	platform_device_register(&omap_spi1);
+	platform_device_register(&omap_spi2);
+}

I've updated your patch to just check the return value of ioremap instead of BUG_ON. I've also merged it with the mux patch, see below. Can you please try it out and make sure everything is OK?

Regards,

Tony

Quoted 1 line

From b6e8076018f8a492c225114d517b2d4a0408ea4c Mon Sep 17 00:00:00 2001

From: Cory Maccarrone <[email protected]>
Date: Sun, 13 Dec 2009 01:34:48 +0000
Subject: [PATCH] omap1: Add 7xx clocks and pin muxes for SPI

Commit 35c9049b27040d09461bc90928ad770be7ddf661 added drivers/spi/omap_spi_100k.c.

This patch add the related clocks and pin muxing entries to make the driver work on omap7xx platforms.

arch/arm/mach-omap1/clock_data.c +4 -0
index 31fba07..2ac5796 100644
@@ -658,6 +658,10 @@ static struct omap_clk omap_clks[] = {
 	CLK("i2c_omap.1", "fck",	&i2c_fck,	CK_16XX | CK_1510 | CK_310 | CK_7XX),
 	CLK("i2c_omap.1", "ick",	&i2c_ick,	CK_16XX),
 	CLK("i2c_omap.1", "ick",	&dummy_ck,	CK_1510 | CK_310 | CK_7XX),
+	CLK("omap1_spi100k.1", "fck",	&dummy_ck,	CK_7XX),
+	CLK("omap1_spi100k.1", "ick",	&dummy_ck,	CK_7XX),
+	CLK("omap1_spi100k.2", "fck",	&dummy_ck,	CK_7XX),
+	CLK("omap1_spi100k.2", "ick",	&dummy_ck,	CK_7XX),
 	CLK("omap_uwire", "fck",	&armxor_ck.clk,	CK_16XX | CK_1510 | CK_310),
 	CLK("omap-mcbsp.1", "ick",	&dspper_ck,	CK_16XX),
 	CLK("omap-mcbsp.1", "ick",	&dummy_ck,	CK_1510 | CK_310),
arch/arm/mach-omap1/devices.c +35 -0
index 23ded2d..17ebb47 100644
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/spi/spi.h>
 
 #include <mach/hardware.h>
 #include <asm/mach/map.h>
@@ -23,6 +24,7 @@
 #include <plat/mux.h>
 #include <mach/gpio.h>
 #include <plat/mmc.h>
+#include <plat/omap7xx.h>
 
 /*-------------------------------------------------------------------------*/
 
@@ -196,6 +198,38 @@ void __init omap1_init_mmc(struct omap_mmc_platform_data **mmc_data,
 
 /*-------------------------------------------------------------------------*/
 
+/* OMAP7xx SPI support */
+#if defined(CONFIG_SPI_OMAP_100K) || defined(CONFIG_SPI_OMAP_100K_MODULE)
+
+struct platform_device omap_spi1 = {
+	.name           = "omap1_spi100k",
+	.id             = 1,
+};
+
+struct platform_device omap_spi2 = {
+	.name           = "omap1_spi100k",
+	.id             = 2,
+};
+
+static void omap_init_spi100k(void)
+{
+	omap_spi1.dev.platform_data = ioremap(OMAP7XX_SPI1_BASE, 0x7ff);
+	if (omap_spi1.dev.platform_data)
+		platform_device_register(&omap_spi1);
+
+	omap_spi2.dev.platform_data = ioremap(OMAP7XX_SPI2_BASE, 0x7ff);
+	ifi (omap_spi2.dev.platform_data)
+		platform_device_register(&omap_spi2);
+}
+
+#else
+static inline void omap_init_spi100k(void)
+{
+}
+#endif
+
+/*-------------------------------------------------------------------------*/
+
 #if defined(CONFIG_OMAP_STI)
 
 #define OMAP1_STI_BASE		0xfffea000
@@ -263,6 +297,7 @@ static int __init omap1_init_devices(void)
 
 	omap_init_mbox();
 	omap_init_rtc();
+	omap_init_spi100k();
 	omap_init_sti();
 
 	return 0;
arch/arm/mach-omap1/mux.c +8 -0
index 07212cc..8434137 100644
@@ -62,6 +62,14 @@ MUX_CFG_7XX("MMC_7XX_DAT0",        2,   17,    0,   16,   1, 0)
 /* I2C interface */
 MUX_CFG_7XX("I2C_7XX_SCL",         5,    1,    0,    0,   1, 0)
 MUX_CFG_7XX("I2C_7XX_SDA",         5,    5,    0,    0,   1, 0)
+
+/* SPI pins */
+MUX_CFG_7XX("SPI_7XX_1",           6,    5,    4,    4,   1, 0)
+MUX_CFG_7XX("SPI_7XX_2",           6,    9,    4,    8,   1, 0)
+MUX_CFG_7XX("SPI_7XX_3",           6,   13,    4,   12,   1, 0)
+MUX_CFG_7XX("SPI_7XX_4",           6,   17,    4,   16,   1, 0)
+MUX_CFG_7XX("SPI_7XX_5",           8,   25,    0,   24,   0, 0)
+MUX_CFG_7XX("SPI_7XX_6",           9,    5,    0,    4,   0, 0)
 };
 #define OMAP7XX_PINS_SZ		ARRAY_SIZE(omap7xx_pins)
 #else
arch/arm/plat-omap/include/plat/mux.h +8 -0
index 8f069cc..692c90e 100644
@@ -183,6 +183,14 @@ enum omap7xx_index {
 	/* I2C */
 	I2C_7XX_SCL,
 	I2C_7XX_SDA,
+
+	/* SPI */
+	SPI_7XX_1,
+	SPI_7XX_2,
+	SPI_7XX_3,
+	SPI_7XX_4,
+	SPI_7XX_5,
+	SPI_7XX_6,
 };
 
 enum omap1xxx_index {
arch/arm/plat-omap/include/plat/omap7xx.h +3 -0
index 53f5241..48e4757 100644
@@ -46,6 +46,9 @@
 #define OMAP7XX_DSPREG_SIZE	SZ_128K
 #define OMAP7XX_DSPREG_START	0xE1000000
 
+#define OMAP7XX_SPI1_BASE	0xfffc0800
+#define OMAP7XX_SPI2_BASE	0xfffc1000
+
 /*
  * ----------------------------------------------------------------------------
  * OMAP7XX specific configuration registers
#4 lore raw

Re: [PATCH v2 2/3] [OMAP] Add spi100k configuration to OMAP1

Quoted 8 lines · Tony Lindgren

Hi,

Looks like the driver is in mainline, so let's try to make it working..

I've updated your patch to just check the return value of ioremap instead of BUG_ON. I've also merged it with the mux patch, see below. Can you please try it out and make sure everything is OK?

Just finished testing it -- with the one fix in device.c that's covered in a different email thread, the changes work perfectly.

- Cory

#5 lore raw

PATCH v2 3/3 Add OMAP 7xx pin muxes for SPI

In reply to Cory Maccarrone

This change adds pin mux configuration for SPI100k on omap7xx platforms.

---
 arch/arm/mach-omap1/mux.c             |    8 ++++++++
 arch/arm/plat-omap/include/plat/mux.h |    8 ++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)
arch/arm/mach-omap1/mux.c +8 -0
index 07212cc..8434137 100644
@@ -62,6 +62,14 @@ MUX_CFG_7XX("MMC_7XX_DAT0",        2,   17,    0,   16,   1, 0)
 /* I2C interface */
 MUX_CFG_7XX("I2C_7XX_SCL",         5,    1,    0,    0,   1, 0)
 MUX_CFG_7XX("I2C_7XX_SDA",         5,    5,    0,    0,   1, 0)
+
+/* SPI pins */
+MUX_CFG_7XX("SPI_7XX_1",           6,    5,    4,    4,   1, 0)
+MUX_CFG_7XX("SPI_7XX_2",           6,    9,    4,    8,   1, 0)
+MUX_CFG_7XX("SPI_7XX_3",           6,   13,    4,   12,   1, 0)
+MUX_CFG_7XX("SPI_7XX_4",           6,   17,    4,   16,   1, 0)
+MUX_CFG_7XX("SPI_7XX_5",           8,   25,    0,   24,   0, 0)
+MUX_CFG_7XX("SPI_7XX_6",           9,    5,    0,    4,   0, 0)
 };
 #define OMAP7XX_PINS_SZ		ARRAY_SIZE(omap7xx_pins)
 #else
arch/arm/plat-omap/include/plat/mux.h +8 -0
index 8f069cc..692c90e 100644
@@ -183,6 +183,14 @@ enum omap7xx_index {
 	/* I2C */
 	I2C_7XX_SCL,
 	I2C_7XX_SDA,
+
+	/* SPI */
+	SPI_7XX_1,
+	SPI_7XX_2,
+	SPI_7XX_3,
+	SPI_7XX_4,
+	SPI_7XX_5,
+	SPI_7XX_6,
 };
 
 enum omap1xxx_index {
Signature · 1 line
1.6.3.3
reviewer
#6 lore raw

PATCH v2 3/3 Add OMAP 7xx pin muxes for SPI

This patch has been applied to the linux-omap
by youw fwiendly patch wobot.

Branch in linux-omap: omap-fixes

Initial commit ID (Likely to change): 8c0378165f84b2c8fabd3bac978e59bfa859f126

PatchWorks
http://patchwork.kernel.org/patch/66943/

Git (Likely to change, and takes a while to get mirrored)
http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git;a=commit;h=8c0378165f84b2c8fabd3bac978e59bfa859f126