aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2008-07-27 05:34:45 -0400
committerHaavard Skinnemoen <haavard.skinnemoen@atmel.com>2008-07-27 07:57:36 -0400
commit3c26e17032e42cfbe606882288223ad6146e4c38 (patch)
tree1c537eb20767ccbf4a7ab85063d2dca8ec03956c
parenteda3d8f5604860aae1bb9996bb5efc4213778369 (diff)
avr32: some mmc/sd cleanups
Minor cleanups for the MMC/SD support on avr32: - Make at32_add_device_mci() properly initialize "missing" platform data ... so boards like STK1002 won't try GPIO 0. - Switch over to gpio_is_valid() instead of testing for only one designated value. - Provide STK1002 platform data for the unlikely case that switches are set so first Ethernet controller isn't in use. (That's the only way to get card detect and writeprotect switch sensing on the STK1000.) And get rid of one "unused variable" warning. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
-rw-r--r--arch/avr32/boards/atstk1000/atstk1002.c19
-rw-r--r--arch/avr32/mach-at32ap/at32ap700x.c13
-rw-r--r--drivers/mmc/host/atmel-mci.c16
3 files changed, 33 insertions, 15 deletions
diff --git a/arch/avr32/boards/atstk1000/atstk1002.c b/arch/avr32/boards/atstk1000/atstk1002.c
index 14dc5a143695..8538ba75ef92 100644
--- a/arch/avr32/boards/atstk1000/atstk1002.c
+++ b/arch/avr32/boards/atstk1000/atstk1002.c
@@ -21,6 +21,8 @@
21 21
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/setup.h> 23#include <asm/setup.h>
24#include <asm/atmel-mci.h>
25
24#include <asm/arch/at32ap700x.h> 26#include <asm/arch/at32ap700x.h>
25#include <asm/arch/board.h> 27#include <asm/arch/board.h>
26#include <asm/arch/init.h> 28#include <asm/arch/init.h>
@@ -260,6 +262,21 @@ void __init setup_board(void)
260 at32_setup_serial_console(0); 262 at32_setup_serial_console(0);
261} 263}
262 264
265#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
266
267/* MMC card detect requires MACB0 *NOT* be used */
268#ifdef CONFIG_BOARD_ATSTK1002_SW6_CUSTOM
269static struct mci_platform_data __initdata mci0_data = {
270 .detect_pin = GPIO_PIN_PC(14), /* gpio30/sdcd */
271 .wp_pin = GPIO_PIN_PC(15), /* gpio31/sdwp */
272};
273#define MCI_PDATA &mci0_data
274#else
275#define MCI_PDATA NULL
276#endif /* SW6 for sd{cd,wp} routing */
277
278#endif /* SW2 for MMC signal routing */
279
263static int __init atstk1002_init(void) 280static int __init atstk1002_init(void)
264{ 281{
265 /* 282 /*
@@ -309,7 +326,7 @@ static int __init atstk1002_init(void)
309 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); 326 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info));
310#endif 327#endif
311#ifndef CONFIG_BOARD_ATSTK1002_SW2_CUSTOM 328#ifndef CONFIG_BOARD_ATSTK1002_SW2_CUSTOM
312 at32_add_device_mci(0, NULL); 329 at32_add_device_mci(0, MCI_PDATA);
313#endif 330#endif
314#ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM 331#ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM
315 set_hw_addr(at32_add_device_eth(1, &eth_data[1])); 332 set_hw_addr(at32_add_device_eth(1, &eth_data[1]));
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
index 5f30b353a27f..1617048c86c5 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -12,6 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
15#include <linux/gpio.h>
15#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
16#include <linux/usb/atmel_usba_udc.h> 17#include <linux/usb/atmel_usba_udc.h>
17 18
@@ -1299,7 +1300,7 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
1299 1300
1300 if (!data) { 1301 if (!data) {
1301 data = &_data; 1302 data = &_data;
1302 memset(data, 0, sizeof(struct mci_platform_data)); 1303 memset(data, -1, sizeof(struct mci_platform_data));
1303 data->detect_pin = GPIO_PIN_NONE; 1304 data->detect_pin = GPIO_PIN_NONE;
1304 data->wp_pin = GPIO_PIN_NONE; 1305 data->wp_pin = GPIO_PIN_NONE;
1305 } 1306 }
@@ -1315,9 +1316,9 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data)
1315 select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */ 1316 select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */
1316 select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */ 1317 select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */
1317 1318
1318 if (data->detect_pin != GPIO_PIN_NONE) 1319 if (gpio_is_valid(data->detect_pin))
1319 at32_select_gpio(data->detect_pin, 0); 1320 at32_select_gpio(data->detect_pin, 0);
1320 if (data->wp_pin != GPIO_PIN_NONE) 1321 if (gpio_is_valid(data->wp_pin))
1321 at32_select_gpio(data->wp_pin, 0); 1322 at32_select_gpio(data->wp_pin, 0);
1322 1323
1323 atmel_mci0_pclk.dev = &pdev->dev; 1324 atmel_mci0_pclk.dev = &pdev->dev;
@@ -1852,11 +1853,11 @@ at32_add_device_cf(unsigned int id, unsigned int extint,
1852 if (at32_init_ide_or_cf(pdev, data->cs, extint)) 1853 if (at32_init_ide_or_cf(pdev, data->cs, extint))
1853 goto fail; 1854 goto fail;
1854 1855
1855 if (data->detect_pin != GPIO_PIN_NONE) 1856 if (gpio_is_valid(data->detect_pin))
1856 at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH); 1857 at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH);
1857 if (data->reset_pin != GPIO_PIN_NONE) 1858 if (gpio_is_valid(data->reset_pin))
1858 at32_select_gpio(data->reset_pin, 0); 1859 at32_select_gpio(data->reset_pin, 0);
1859 if (data->vcc_pin != GPIO_PIN_NONE) 1860 if (gpio_is_valid(data->vcc_pin))
1860 at32_select_gpio(data->vcc_pin, 0); 1861 at32_select_gpio(data->vcc_pin, 0);
1861 /* READY is used as extint, so we can't select it as gpio */ 1862 /* READY is used as extint, so we can't select it as gpio */
1862 1863
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 82bbbe998169..992b4beb757c 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -12,6 +12,7 @@
12#include <linux/debugfs.h> 12#include <linux/debugfs.h>
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/err.h> 14#include <linux/err.h>
15#include <linux/gpio.h>
15#include <linux/init.h> 16#include <linux/init.h>
16#include <linux/interrupt.h> 17#include <linux/interrupt.h>
17#include <linux/ioport.h> 18#include <linux/ioport.h>
@@ -28,7 +29,6 @@
28#include <asm/unaligned.h> 29#include <asm/unaligned.h>
29 30
30#include <asm/arch/board.h> 31#include <asm/arch/board.h>
31#include <asm/arch/gpio.h>
32 32
33#include "atmel-mci-regs.h" 33#include "atmel-mci-regs.h"
34 34
@@ -574,7 +574,7 @@ static int atmci_get_ro(struct mmc_host *mmc)
574 int read_only = 0; 574 int read_only = 0;
575 struct atmel_mci *host = mmc_priv(mmc); 575 struct atmel_mci *host = mmc_priv(mmc);
576 576
577 if (host->wp_pin >= 0) { 577 if (gpio_is_valid(host->wp_pin)) {
578 read_only = gpio_get_value(host->wp_pin); 578 read_only = gpio_get_value(host->wp_pin);
579 dev_dbg(&mmc->class_dev, "card is %s\n", 579 dev_dbg(&mmc->class_dev, "card is %s\n",
580 read_only ? "read-only" : "read-write"); 580 read_only ? "read-only" : "read-write");
@@ -636,7 +636,7 @@ static void atmci_detect_change(unsigned long data)
636 * been freed. 636 * been freed.
637 */ 637 */
638 smp_rmb(); 638 smp_rmb();
639 if (host->detect_pin < 0) 639 if (!gpio_is_valid(host->detect_pin))
640 return; 640 return;
641 641
642 enable_irq(gpio_to_irq(host->detect_pin)); 642 enable_irq(gpio_to_irq(host->detect_pin));
@@ -1051,7 +1051,7 @@ static int __init atmci_probe(struct platform_device *pdev)
1051 1051
1052 /* Assume card is present if we don't have a detect pin */ 1052 /* Assume card is present if we don't have a detect pin */
1053 host->present = 1; 1053 host->present = 1;
1054 if (host->detect_pin >= 0) { 1054 if (gpio_is_valid(host->detect_pin)) {
1055 if (gpio_request(host->detect_pin, "mmc_detect")) { 1055 if (gpio_request(host->detect_pin, "mmc_detect")) {
1056 dev_dbg(&mmc->class_dev, "no detect pin available\n"); 1056 dev_dbg(&mmc->class_dev, "no detect pin available\n");
1057 host->detect_pin = -1; 1057 host->detect_pin = -1;
@@ -1059,7 +1059,7 @@ static int __init atmci_probe(struct platform_device *pdev)
1059 host->present = !gpio_get_value(host->detect_pin); 1059 host->present = !gpio_get_value(host->detect_pin);
1060 } 1060 }
1061 } 1061 }
1062 if (host->wp_pin >= 0) { 1062 if (gpio_is_valid(host->wp_pin)) {
1063 if (gpio_request(host->wp_pin, "mmc_wp")) { 1063 if (gpio_request(host->wp_pin, "mmc_wp")) {
1064 dev_dbg(&mmc->class_dev, "no WP pin available\n"); 1064 dev_dbg(&mmc->class_dev, "no WP pin available\n");
1065 host->wp_pin = -1; 1065 host->wp_pin = -1;
@@ -1070,7 +1070,7 @@ static int __init atmci_probe(struct platform_device *pdev)
1070 1070
1071 mmc_add_host(mmc); 1071 mmc_add_host(mmc);
1072 1072
1073 if (host->detect_pin >= 0) { 1073 if (gpio_is_valid(host->detect_pin)) {
1074 setup_timer(&host->detect_timer, atmci_detect_change, 1074 setup_timer(&host->detect_timer, atmci_detect_change,
1075 (unsigned long)host); 1075 (unsigned long)host);
1076 1076
@@ -1113,7 +1113,7 @@ static int __exit atmci_remove(struct platform_device *pdev)
1113 if (host) { 1113 if (host) {
1114 /* Debugfs stuff is cleaned up by mmc core */ 1114 /* Debugfs stuff is cleaned up by mmc core */
1115 1115
1116 if (host->detect_pin >= 0) { 1116 if (gpio_is_valid(host->detect_pin)) {
1117 int pin = host->detect_pin; 1117 int pin = host->detect_pin;
1118 1118
1119 /* Make sure the timer doesn't enable the interrupt */ 1119 /* Make sure the timer doesn't enable the interrupt */
@@ -1133,7 +1133,7 @@ static int __exit atmci_remove(struct platform_device *pdev)
1133 mci_readl(host, SR); 1133 mci_readl(host, SR);
1134 clk_disable(host->mck); 1134 clk_disable(host->mck);
1135 1135
1136 if (host->wp_pin >= 0) 1136 if (gpio_is_valid(host->wp_pin))
1137 gpio_free(host->wp_pin); 1137 gpio_free(host->wp_pin);
1138 1138
1139 free_irq(platform_get_irq(pdev, 0), host->mmc); 1139 free_irq(platform_get_irq(pdev, 0), host->mmc);