Difference between revisions of "Enabling SPI1 on Linux (Diva)"

From DAVE Developer's Wiki
Jump to: navigation, search
(Created page with "{{InfoBoxTop}} {{Applies To Diva}} {{Applies To Linux}} {{InfoBoxBottom}} === Introduction === This article shows how to enable the SPI1 interface (with CS0 and CS1 chip sel...")
 
m
Line 7: Line 7:
  
 
This article shows how to enable the SPI1 interface (with CS0 and CS1 chip selects) which can be used in a standard Linux application.
 
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 Option ===
 +
 +
SPI1 signals are available at different Diva pins. We chose the following configuration:
 +
 +
{|class="wikitable" style="text-align:right"
 +
!| 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 patches ===
 +
 +
{{ImportantMessage|text=The patches below applies to DIVELK 1.0.0 Linux source tree.}}
 +
 +
The files <code>arch/arm/mach-omap2/board-diva.c</code> and <code>arch/arm/mach-omap2/diva_pinmux_table.h</code> must be modified according to the following patches:
 +
 +
<diff>
 +
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>
 +
 +
<diff>
 +
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
 +
</diff>
 +
 +
The kernel must be rebuilt to make these modifications effective.
 +
 +
=== Using the interface ===
 +
 +
Users can access the peripherals connected to the SP1 bus through the <code>spidev</code> interface
 +
 +
=== Download patch ===

Revision as of 10:22, 21 June 2013

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

Introduction[edit | edit source]

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 Option[edit | edit source]

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 patches[edit | edit source]

200px-Emblem-important.svg.png

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 interface[edit | edit source]

Users can access the peripherals connected to the SP1 bus through the spidev interface

Download patch[edit | edit source]