From patchwork Mon Dec 7 14:05:45 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 65524 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB7EBeGe030294 for ; Mon, 7 Dec 2009 14:11:40 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NHeJP-0002RE-K4; Mon, 07 Dec 2009 14:11:39 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.123] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NHeJO-0002R5-0z for spi-devel-general@lists.sourceforge.net; Mon, 07 Dec 2009 14:11:38 +0000 Received-SPF: pass (sfi-mx-3.v28.ch3.sourceforge.com: domain of gmail.com designates 209.85.210.202 as permitted sender) client-ip=209.85.210.202; envelope-from=magnus.damm@gmail.com; helo=mail-yx0-f202.google.com; Received: from mail-yx0-f202.google.com ([209.85.210.202]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1NHeJG-0004U1-OE for spi-devel-general@lists.sourceforge.net; Mon, 07 Dec 2009 14:11:37 +0000 Received: by yxe40 with SMTP id 40so713113yxe.28 for ; Mon, 07 Dec 2009 06:11:25 -0800 (PST) Received: by 10.100.244.26 with SMTP id r26mr1251574anh.1.1260195085018; Mon, 07 Dec 2009 06:11:25 -0800 (PST) Received: from rxone.opensource.se (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id 4sm2540162yxd.70.2009.12.07.06.11.22 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 07 Dec 2009 06:11:23 -0800 (PST) From: Magnus Damm To: linux-sh@vger.kernel.org Date: Mon, 07 Dec 2009 23:05:45 +0900 Message-Id: <20091207140545.6294.90256.sendpatchset@rxone.opensource.se> X-Spam-Score: -2.3 (--) 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: 1NHeJG-0004U1-OE Cc: spi-devel-general@lists.sourceforge.net, akpm@linux-foundation.org, lethal@linux-sh.org, Magnus Damm Subject: [spi-devel-general] [PATCH] sh: MSIOF/mmc_spi platform data for the Ecovec24 board 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 --- 0001/arch/sh/boards/mach-ecovec24/setup.c +++ work/arch/sh/boards/mach-ecovec24/setup.c 2009-12-07 22:37:51.000000000 +0900 @@ -19,6 +19,10 @@ #include #include #include +#include +#include +#include +#include #include #include #include @@ -421,6 +425,7 @@ static struct i2c_board_info ts_i2c_clie .irq = IRQ0, }; +#ifdef CONFIG_MFD_SH_MOBILE_SDHI /* SHDI0 */ static void sdhi0_set_pwr(struct platform_device *pdev, int state) { @@ -493,6 +498,73 @@ static struct platform_device sdhi1_devi }, }; +#else + +static int mmc_spi_get_ro(struct device *dev) +{ + return gpio_get_value(GPIO_PTY6); +} + +static int mmc_spi_get_cd(struct device *dev) +{ + return !gpio_get_value(GPIO_PTY7); +} + +static void mmc_spi_setpower(struct device *dev, unsigned int maskval) +{ + gpio_set_value(GPIO_PTB6, maskval ? 1 : 0); +} + +static struct mmc_spi_platform_data mmc_spi_info = { + .get_ro = mmc_spi_get_ro, + .get_cd = mmc_spi_get_cd, + .caps = MMC_CAP_NEEDS_POLL, + .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */ + .setpower = mmc_spi_setpower, +}; + +static struct spi_board_info spi_bus[] = { + { + .modalias = "mmc_spi", + .platform_data = &mmc_spi_info, + .max_speed_hz = 5000000, + .mode = SPI_MODE_0, + .controller_data = (void *) GPIO_PTM4, + }, +}; + +static struct sh_msiof_spi_info msiof0_data = { + .num_chipselect = 1, +}; + +static struct resource msiof0_resources[] = { + [0] = { + .name = "MSIOF0", + .start = 0xa4c40000, + .end = 0xa4c40063, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = 84, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct platform_device msiof0_device = { + .name = "spi_sh_msiof", + .id = 0, /* MSIOF0 */ + .dev = { + .platform_data = &msiof0_data, + }, + .num_resources = ARRAY_SIZE(msiof0_resources), + .resource = msiof0_resources, + .archdata = { + .hwblk_id = HWBLK_MSIOF0, + }, +}; + +#endif + static struct platform_device *ecovec_devices[] __initdata = { &heartbeat_device, &nor_flash_device, @@ -503,8 +575,12 @@ static struct platform_device *ecovec_de &ceu0_device, &ceu1_device, &keysc_device, +#ifdef CONFIG_MFD_SH_MOBILE_SDHI &sdhi0_device, &sdhi1_device, +#else + &msiof0_device, +#endif }; #define EEPROM_ADDR 0x50 @@ -773,7 +849,8 @@ static int __init arch_setup(void) gpio_direction_input(GPIO_PTR5); gpio_direction_input(GPIO_PTR6); - /* enable SDHI0 (needs DS2.4 set to ON) */ +#ifdef CONFIG_MFD_SH_MOBILE_SDHI + /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */ gpio_request(GPIO_FN_SDHI0CD, NULL); gpio_request(GPIO_FN_SDHI0WP, NULL); gpio_request(GPIO_FN_SDHI0CMD, NULL); @@ -785,7 +862,7 @@ static int __init arch_setup(void) gpio_request(GPIO_PTB6, NULL); gpio_direction_output(GPIO_PTB6, 0); - /* enable SDHI1 (needs DS2.6,7 set to ON,OFF) */ + /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */ gpio_request(GPIO_FN_SDHI1CD, NULL); gpio_request(GPIO_FN_SDHI1WP, NULL); gpio_request(GPIO_FN_SDHI1CMD, NULL); @@ -799,6 +876,22 @@ static int __init arch_setup(void) /* I/O buffer drive ability is high for SDHI1 */ ctrl_outw((ctrl_inw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA); +#else + /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */ + gpio_request(GPIO_FN_MSIOF0_TXD, NULL); + gpio_request(GPIO_FN_MSIOF0_RXD, NULL); + gpio_request(GPIO_FN_MSIOF0_TSCK, NULL); + gpio_request(GPIO_PTM4, NULL); /* software CS control of TSYNC pin */ + gpio_direction_output(GPIO_PTM4, 1); /* active low CS */ + gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */ + gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */ + gpio_request(GPIO_PTY6, NULL); /* write protect */ + gpio_direction_input(GPIO_PTY6); + gpio_request(GPIO_PTY7, NULL); /* card detect */ + gpio_direction_input(GPIO_PTY7); + + spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); +#endif /* enable I2C device */ i2c_register_board_info(1, i2c1_devices,