From patchwork Mon Mar 15 02:44:33 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gamari X-Patchwork-Id: 85867 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2F2iahL006645 for ; Mon, 15 Mar 2010 02:44:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756526Ab0COCog (ORCPT ); Sun, 14 Mar 2010 22:44:36 -0400 Received: from mail-vw0-f46.google.com ([209.85.212.46]:59719 "EHLO mail-vw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756198Ab0COCof (ORCPT ); Sun, 14 Mar 2010 22:44:35 -0400 Received: by vws12 with SMTP id 12so28501vws.19 for ; Sun, 14 Mar 2010 19:44:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject; bh=9kR0oy4twSNDpX7GU7o2wxXIxyYJA7j+2JBxERr0nOI=; b=GbH1iYQHO0hoyxkIUT0HSUSUkKG9yd0GPbey69Nz8jeQy2lnLM1MqWkmE34Nw+CJ1F pccbpTkc20vtrQVPQFd/r/KitU+n/W9suygWzhjkCu23OAcfpo31HXalVEKZAB6Y5cen wqy1mYN5nvOFb8naaRYIsqix/MqioTaeHBZAo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject; b=e2q5lWVS8vgc6xmAln0hAwoYbnmVyECE3Le4zAli2si0JtE80TEnxTTxllbCzEeT8T hPAN83fES3ZOZQYYmOzfMUOj5a7RXS28cxgE3M7+p66AzHrcS1lYVLjSDX0N9SZZsPtF UVUIx+ikaalRTptL79EnOqBz3kkneQxG29Hi8= Received: by 10.220.124.170 with SMTP id u42mr2886400vcr.170.1268621074089; Sun, 14 Mar 2010 19:44:34 -0700 (PDT) Received: from localhost (physnat56.physics.umass.edu [128.119.50.56]) by mx.google.com with ESMTPS id 26sm33614821vws.3.2010.03.14.19.44.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 14 Mar 2010 19:44:33 -0700 (PDT) Message-ID: <4b9d9f11.9a15f10a.3902.6dc3@mx.google.com> Date: Sun, 14 Mar 2010 19:44:33 -0700 (PDT) From: Ben Gamari To: beagleboard@googlegroups.com, spi-devel-general@lists.sourceforge.net, linux-omap@vger.kernel.org Subject: SPI troubles Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 15 Mar 2010 02:44:37 +0000 (UTC) diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c index 231cb4e..b23c5a5 100644 --- a/arch/arm/mach-omap2/board-omap3beagle.c +++ b/arch/arm/mach-omap2/board-omap3beagle.c @@ -12,6 +12,10 @@ * published by the Free Software Foundation. */ +//#define BEAGLE_GPIO_SPI + + + #include #include #include @@ -28,6 +32,7 @@ #include #include +#include #include #include @@ -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 + +#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,