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: 85868 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2F2ipaA006687 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 15 Mar 2010 02:45:27 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nr0IN-0001TN-AF; Mon, 15 Mar 2010 02:44:43 +0000 Received: from sfi-mx-2.v28.ch3.sourceforge.com ([172.29.28.122] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nr0IL-0001TF-8g for spi-devel-general@lists.sourceforge.net; Mon, 15 Mar 2010 02:44:41 +0000 Received-SPF: pass (sfi-mx-2.v28.ch3.sourceforge.com: domain of gmail.com designates 209.85.212.47 as permitted sender) client-ip=209.85.212.47; envelope-from=bgamari.foss@gmail.com; helo=mail-vw0-f47.google.com; Received: from mail-vw0-f47.google.com ([209.85.212.47]) by sfi-mx-2.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1Nr0IJ-0001TA-Vk for spi-devel-general@lists.sourceforge.net; Mon, 15 Mar 2010 02:44:41 +0000 Received: by vws10 with SMTP id 10so568016vws.34 for ; Sun, 14 Mar 2010 19:44:34 -0700 (PDT) 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 X-Spam-Score: -0.8 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 DKIM_VERIFIED Domain Keys Identified Mail: signature passes verification 0.0 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.8 AWL AWL: From: address is in the auto white-list X-Headers-End: 1Nr0IJ-0001TA-Vk Subject: [spi-devel-general] SPI troubles X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net 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:45:27 +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,