Open main menu

DAVE Developer's Wiki β

Enabling SPI1 on Linux (Diva)

Revision as of 07:31, 1 July 2013 by DevWikiAdmin (talk | contribs) (Patch download)

Info Box
Diva-am335x-overview.png Applies to Diva
Tux.png Applies to Linux

Contents

IntroductionEdit

This article shows how to enable the SPI1 interface (with CS0 and CS1 chip selects) which can be used in a standard Linux application.

Pin Mux OptionEdit

SPI1 signals are available at different Diva pins. We chose the following configuration:

Signal Diva Connector Phisical Pin CPU Ball
SPI1_SCLK J1.109 C18
SPI1_D0 J1.31 E18
SPI1_D1 J1.29 E17
SPI1_CS0 J1.144 C12
SPI1_CS1 J1.69 A15

Linux kernel patchesEdit

The patches below applies to DIVELK 1.0.0 Linux source tree.

The files arch/arm/mach-omap2/board-diva.c and arch/arm/mach-omap2/diva_pinmux_table.h must be modified according to the following patches:

diff --git a/arch/arm/mach-omap2/board-diva.c b/arch/arm/mach-omap2/board-diva.c
index f6b77fc..a8b3996 100644
--- a/arch/arm/mach-omap2/board-diva.c
+++ b/arch/arm/mach-omap2/board-diva.c
@@ -356,6 +356,30 @@ static void spi0_init(int evm_id, int profile)
 			ARRAY_SIZE(diva_spi0_slave_info));
 }
 
+/* -------------- SPI 1 Platform Data -----------------------------*/
+struct spi_board_info __initdata diva_spi1_slave_info[] = {
+	{
+		.modalias = "spidev",
+		.max_speed_hz = 2000000,     /* max spi clock (SCK) speed in HZ */
+		.bus_num = 2,
+		.chip_select = 0,
+	},
+	{
+		.modalias = "spidev",
+		.max_speed_hz = 2000000,     /* max spi clock (SCK) speed in HZ */
+		.bus_num = 2,
+		.chip_select = 1,
+	},
+};
+
+/* setup spi0 */
+
+static void spi1_init(int evm_id, int profile)
+{
+	setup_pin_mux(spi1_pin_mux);
+	spi_register_board_info(diva_spi1_slave_info,
+			ARRAY_SIZE(diva_spi1_slave_info));
+}
 
 /* ----------- NAND Init ---------------------------------------*/
 
@@ -878,6 +902,7 @@ static struct evm_dev_cfg diva_dev_cfg[] = {
 	{mmc0_init,	DEV_ON_BASEBOARD, PROFILE_NONE},
 	{rmii1_init,	DEV_ON_BASEBOARD, PROFILE_NONE},
 	{spi0_init,	DEV_ON_BASEBOARD, PROFILE_NONE},
+	{spi1_init,	DEV_ON_BASEBOARD, PROFILE_NONE},
 	{usb0_init,	DEV_ON_BASEBOARD, PROFILE_NONE},
 	{usb1_init,	DEV_ON_BASEBOARD, PROFILE_NONE},
diff --git a/arch/arm/mach-omap2/diva_pinmux_table.h b/arch/arm/mach-omap2/diva_pinmux_table.h
index 5a2646a..9509b46 100644
--- a/arch/arm/mach-omap2/diva_pinmux_table.h
+++ b/arch/arm/mach-omap2/diva_pinmux_table.h
@@ -180,6 +180,21 @@ static struct pinmux_config w1_gpio_pin_mux[] = {
 	{NULL, 0},
 };
 
+/* Module pin mux for SPI fash */
+static struct pinmux_config spi1_pin_mux[] = {
+	{"ecap0_in_pwm0_out.spi1_sclk", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL
+							| AM33XX_INPUT_EN},
+	{"uart0_ctsn.spi1_d0", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP
+							| AM33XX_INPUT_EN},
+	{"uart0_rtsn.spi1_d1", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL
+							| AM33XX_INPUT_EN},
+	{"mcasp0_ahclkr.spi1_cs0", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP
+							| AM33XX_INPUT_EN},
+	{"xdma_event_intr0.spi1_cs1", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL | AM33XX_PULL_UP
+							| AM33XX_INPUT_EN},
+	{NULL, 0},
+};
+
 /*
  * the following mux configurations are un-tested but are left here for
  * reference. They are all comment-out to avoid "defined but not used" warning

The kernel must be rebuilt to make these modifications effective.

Using the interfaceEdit

Users can access the peripherals connected to the SP1 bus through the spidev interface. For further information, please refer to

Patch downloadEdit