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>

authored by David Brownell and committed by Haavard Skinnemoen 3c26e170 eda3d8f5

+33 -15
+18 -1
arch/avr32/boards/atstk1000/atstk1002.c
··· 21 21 22 22 #include <asm/io.h> 23 23 #include <asm/setup.h> 24 + #include <asm/atmel-mci.h> 25 + 24 26 #include <asm/arch/at32ap700x.h> 25 27 #include <asm/arch/board.h> 26 28 #include <asm/arch/init.h> ··· 262 260 at32_setup_serial_console(0); 263 261 } 264 262 263 + #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM 264 + 265 + /* MMC card detect requires MACB0 *NOT* be used */ 266 + #ifdef CONFIG_BOARD_ATSTK1002_SW6_CUSTOM 267 + static struct mci_platform_data __initdata mci0_data = { 268 + .detect_pin = GPIO_PIN_PC(14), /* gpio30/sdcd */ 269 + .wp_pin = GPIO_PIN_PC(15), /* gpio31/sdwp */ 270 + }; 271 + #define MCI_PDATA &mci0_data 272 + #else 273 + #define MCI_PDATA NULL 274 + #endif /* SW6 for sd{cd,wp} routing */ 275 + 276 + #endif /* SW2 for MMC signal routing */ 277 + 265 278 static int __init atstk1002_init(void) 266 279 { 267 280 /* ··· 326 309 at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); 327 310 #endif 328 311 #ifndef CONFIG_BOARD_ATSTK1002_SW2_CUSTOM 329 - at32_add_device_mci(0, NULL); 312 + at32_add_device_mci(0, MCI_PDATA); 330 313 #endif 331 314 #ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM 332 315 set_hw_addr(at32_add_device_eth(1, &eth_data[1]));
+7 -6
arch/avr32/mach-at32ap/at32ap700x.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/platform_device.h> 14 14 #include <linux/dma-mapping.h> 15 + #include <linux/gpio.h> 15 16 #include <linux/spi/spi.h> 16 17 #include <linux/usb/atmel_usba_udc.h> 17 18 ··· 1300 1299 1301 1300 if (!data) { 1302 1301 data = &_data; 1303 - memset(data, 0, sizeof(struct mci_platform_data)); 1302 + memset(data, -1, sizeof(struct mci_platform_data)); 1304 1303 data->detect_pin = GPIO_PIN_NONE; 1305 1304 data->wp_pin = GPIO_PIN_NONE; 1306 1305 } ··· 1316 1315 select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */ 1317 1316 select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */ 1318 1317 1319 - if (data->detect_pin != GPIO_PIN_NONE) 1318 + if (gpio_is_valid(data->detect_pin)) 1320 1319 at32_select_gpio(data->detect_pin, 0); 1321 - if (data->wp_pin != GPIO_PIN_NONE) 1320 + if (gpio_is_valid(data->wp_pin)) 1322 1321 at32_select_gpio(data->wp_pin, 0); 1323 1322 1324 1323 atmel_mci0_pclk.dev = &pdev->dev; ··· 1853 1852 if (at32_init_ide_or_cf(pdev, data->cs, extint)) 1854 1853 goto fail; 1855 1854 1856 - if (data->detect_pin != GPIO_PIN_NONE) 1855 + if (gpio_is_valid(data->detect_pin)) 1857 1856 at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH); 1858 - if (data->reset_pin != GPIO_PIN_NONE) 1857 + if (gpio_is_valid(data->reset_pin)) 1859 1858 at32_select_gpio(data->reset_pin, 0); 1860 - if (data->vcc_pin != GPIO_PIN_NONE) 1859 + if (gpio_is_valid(data->vcc_pin)) 1861 1860 at32_select_gpio(data->vcc_pin, 0); 1862 1861 /* READY is used as extint, so we can't select it as gpio */ 1863 1862
+8 -8
drivers/mmc/host/atmel-mci.c
··· 12 12 #include <linux/debugfs.h> 13 13 #include <linux/device.h> 14 14 #include <linux/err.h> 15 + #include <linux/gpio.h> 15 16 #include <linux/init.h> 16 17 #include <linux/interrupt.h> 17 18 #include <linux/ioport.h> ··· 29 28 #include <asm/unaligned.h> 30 29 31 30 #include <asm/arch/board.h> 32 - #include <asm/arch/gpio.h> 33 31 34 32 #include "atmel-mci-regs.h" 35 33 ··· 574 574 int read_only = 0; 575 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 578 read_only = gpio_get_value(host->wp_pin); 579 579 dev_dbg(&mmc->class_dev, "card is %s\n", 580 580 read_only ? "read-only" : "read-write"); ··· 636 636 * been freed. 637 637 */ 638 638 smp_rmb(); 639 - if (host->detect_pin < 0) 639 + if (!gpio_is_valid(host->detect_pin)) 640 640 return; 641 641 642 642 enable_irq(gpio_to_irq(host->detect_pin)); ··· 1051 1051 1052 1052 /* Assume card is present if we don't have a detect pin */ 1053 1053 host->present = 1; 1054 - if (host->detect_pin >= 0) { 1054 + if (gpio_is_valid(host->detect_pin)) { 1055 1055 if (gpio_request(host->detect_pin, "mmc_detect")) { 1056 1056 dev_dbg(&mmc->class_dev, "no detect pin available\n"); 1057 1057 host->detect_pin = -1; ··· 1059 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 1063 if (gpio_request(host->wp_pin, "mmc_wp")) { 1064 1064 dev_dbg(&mmc->class_dev, "no WP pin available\n"); 1065 1065 host->wp_pin = -1; ··· 1070 1070 1071 1071 mmc_add_host(mmc); 1072 1072 1073 - if (host->detect_pin >= 0) { 1073 + if (gpio_is_valid(host->detect_pin)) { 1074 1074 setup_timer(&host->detect_timer, atmci_detect_change, 1075 1075 (unsigned long)host); 1076 1076 ··· 1113 1113 if (host) { 1114 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 1117 int pin = host->detect_pin; 1118 1118 1119 1119 /* Make sure the timer doesn't enable the interrupt */ ··· 1133 1133 mci_readl(host, SR); 1134 1134 clk_disable(host->mck); 1135 1135 1136 - if (host->wp_pin >= 0) 1136 + if (gpio_is_valid(host->wp_pin)) 1137 1137 gpio_free(host->wp_pin); 1138 1138 1139 1139 free_irq(platform_get_irq(pdev, 0), host->mmc);