@@ -12,6 +12,10 @@
* published by the Free Software Foundation.
*/
+//#define BEAGLE_GPIO_SPI
+
+
+
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
@@ -28,6 +32,7 @@
#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
+#include <linux/spi/spi.h>
#include <linux/regulator/machine.h>
#include <linux/i2c/twl.h>
@@ -372,6 +377,159 @@ static struct platform_device *omap3_beagle_devices[] __initdata = {
&keys_gpio,
};
+#ifndef BEAGLE_GPIO_SPI
+
+static void __init omap3_beagle_config_mcspi3_mux(void)
+{
+ omap_mux_init_signal("sdmmc2_clk.mcspi3_clk", OMAP_PIN_OUTPUT);
+ omap_mux_init_signal("sdmmc2_dat3.mcspi3_cs0", OMAP_PIN_OUTPUT);
+ omap_mux_init_signal("sdmmc2_dat2.mcspi3_cs1", OMAP_PIN_OUTPUT);
+ omap_mux_init_signal("sdmmc2_cmd.mcspi3_simo", OMAP_PIN_OUTPUT);
+ omap_mux_init_signal("sdmmc2_dat0.mcspi3_somi", OMAP_PIN_INPUT_PULLUP);
+}
+
+static void __init omap3_beagle_config_mcspi4_mux(void)
+{
+ omap_mux_init_signal("mcbsp1_clkr.mcspi4_clk", OMAP_PIN_OUTPUT);
+ omap_mux_init_signal("mcbsp1_fsx.mcspi4_cs0", OMAP_PIN_OUTPUT);
+ omap_mux_init_signal("mcbsp1_dx.mcspi4_simo", OMAP_PIN_OUTPUT);
+ omap_mux_init_signal("mcbsp1_dr.mcspi4_somi", OMAP_PIN_INPUT_PULLUP);
+}
+
+static struct spi_board_info beagle_mcspi_board_info[] = {
+ // spi 3.0
+ {
+ .modalias = "spidev",
+ .max_speed_hz = 48000000, //48 Mbps
+ .bus_num = 3,
+ .chip_select = 0,
+ .mode = SPI_MODE_1,
+ },
+
+ // spi 3.1
+ {
+ .modalias = "spidev",
+ .max_speed_hz = 48000000, //48 Mbps
+ .bus_num = 3,
+ .chip_select = 1,
+ .mode = SPI_MODE_1,
+ },
+
+ // spi 4.0
+ {
+ .modalias = "spidev",
+ .max_speed_hz = 48000000, //48 Mbps
+ .bus_num = 4,
+ .chip_select = 0,
+ .mode = SPI_MODE_1,
+ },
+};
+
+#else /* BEAGLE_GPIO_SPI */
+#include <linux/spi/spi_gpio.h>
+
+#define SPI3_CLK 130
+#define SPI3_SOMI 132
+#define SPI3_SIMO 131
+#define SPI3_CS0 135
+#define SPI3_CS1 134
+
+#define SPI4_CLK 156
+#define SPI4_SOMI 159
+#define SPI4_SIMO 158
+#define SPI4_CS0 161
+
+#define GPIO_SPI_PIN(pin, dir, name) \
+ omap_mux_init_gpio(pin, OMAP_PIN_##dir); \
+ gpio_request(pin, name); \
+ gpio_export(pin, true);
+
+static void __init omap3_beagle_config_gpio_spi3_mux(void)
+{
+ GPIO_SPI_PIN(SPI3_CLK, OUTPUT, "spi3_clk");
+ GPIO_SPI_PIN(SPI3_SIMO, OUTPUT, "spi3_simo");
+ GPIO_SPI_PIN(SPI3_SOMI, INPUT, "spi3_somi");
+ GPIO_SPI_PIN(SPI3_CS0, OUTPUT, "spi3_cs0");
+ GPIO_SPI_PIN(SPI3_CS1, OUTPUT, "spi3_cs1");
+}
+
+static void __init omap3_beagle_config_gpio_spi4_mux(void)
+{
+ GPIO_SPI_PIN(SPI4_CLK, OUTPUT, "spi4_clk");
+ GPIO_SPI_PIN(SPI4_SIMO, OUTPUT, "spi4_simo");
+ GPIO_SPI_PIN(SPI4_SOMI, INPUT, "spi4_somi");
+ GPIO_SPI_PIN(SPI4_CS0, OUTPUT, "spi4_cs0");
+}
+
+static struct spi_gpio_platform_data beagle_gpio_spi_platform_data[] = {
+ // spi 3
+ {
+ .sck = SPI3_CLK,
+ .miso = SPI3_SOMI,
+ .mosi = SPI3_SIMO,
+ .num_chipselect = 2,
+ },
+
+ // spi 4
+ {
+ .sck = SPI4_CLK,
+ .miso = SPI4_SOMI,
+ .mosi = SPI4_SIMO,
+ .num_chipselect = 1,
+ },
+};
+
+static struct platform_device beagle_gpio_spi_platform_device[] = {
+ // spi .
+ {
+ .name = "spi_gpio",
+ .id = 3,
+ .dev = {
+ .platform_data = &beagle_gpio_spi_platform_data[0],
+ },
+ },
+
+ // spi 4
+ {
+ .name = "spi_gpio",
+ .id = 4,
+ .dev = {
+ .platform_data = &beagle_gpio_spi_platform_data[1],
+ },
+ },
+};
+
+static struct spi_board_info beagle_gpio_spi_board_info[] = {
+ // spi 3.0
+ {
+ .modalias = "spidev",
+ .max_speed_hz = 48000000, //48 Mbps
+ .bus_num = 3,
+ .mode = SPI_MODE_1,
+ .controller_data = (void *) SPI3_CS0,
+ },
+
+ // spi 3.1
+ {
+ .modalias = "spidev",
+ .max_speed_hz = 48000000, //48 Mbps
+ .bus_num = 3,
+ .mode = SPI_MODE_1,
+ .controller_data = (void *) SPI3_CS1,
+ },
+
+ // spi 4.0
+ {
+ .modalias = "spidev",
+ .max_speed_hz = 48000000, //48 Mbps
+ .bus_num = 4,
+ .mode = SPI_MODE_1,
+ .controller_data = (void *) SPI4_CS0,
+ },
+};
+
+#endif /* BEAGLE_GPIO_SPI */
+
static void __init omap3beagle_flash_init(void)
{
u8 cs = 0;
@@ -432,12 +590,30 @@ static struct omap_board_mux board_mux[] __initdata = {
static void __init omap3_beagle_init(void)
{
+ int i;
+
omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
omap3_beagle_i2c_init();
platform_add_devices(omap3_beagle_devices,
ARRAY_SIZE(omap3_beagle_devices));
omap_serial_init();
+#ifndef BEAGLE_GPIO_SPI
+ printk(KERN_ERR "Using McSPI for SPI\n");
+ omap3_beagle_config_mcspi3_mux();
+ omap3_beagle_config_mcspi4_mux();
+ spi_register_board_info(beagle_mcspi_board_info,
+ ARRAY_SIZE(beagle_mcspi_board_info));
+#else
+ printk(KERN_ERR "Using GPIO for SPI\n");
+ omap3_beagle_config_gpio_spi3_mux();
+ omap3_beagle_config_gpio_spi4_mux();
+ for (i=0; i<3; i++)
+ platform_device_register(&beagle_gpio_spi_platform_device[i]);
+ spi_register_board_info(beagle_gpio_spi_board_info,
+ ARRAY_SIZE(beagle_gpio_spi_board_info));
+#endif
+
omap_mux_init_gpio(170, OMAP_PIN_INPUT);
gpio_request(170, "DVI_nPD");
/* REVISIT leave DVI powered down until it's needed ... */
@@ -458,6 +634,7 @@ static void __init omap3_beagle_map_io(void)
omap2_map_common_io();
}
+
MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
/* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
.phys_io = 0x48000000,