From 62fe8378d949c9a12bc2a5f51cd41fabf70e682c Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Thu, 17 Jul 2008 16:45:11 +0300 Subject: [PATCH 1/7] fix avr32 build errors Commit 7d2be0749a59096a334c94dc48f43294193cb8ed (atmel-mci: Driver for Atmel on-chip MMC controllers) causes build errors like: <-- snip --> ... CC arch/avr32/boards/atstk1000/atstk1003.o /home/bunk/linux/kernel-2.6/git/linux-2.6/arch/avr32/boards/atstk1000/atstk1003.c: In function 'atstk1003_init': /home/bunk/linux/kernel-2.6/git/linux-2.6/arch/avr32/boards/atstk1000/atstk1003.c:157: error: too few arguments to function 'at32_add_device_mci' make[2]: *** [arch/avr32/boards/atstk1000/atstk1003.o] Error 1 <-- snip --> Reported-by: Adrian Bunk Signed-off-by: Adrian Bunk Signed-off-by: Haavard Skinnemoen --- arch/avr32/boards/atstk1000/atstk1003.c | 2 +- arch/avr32/boards/atstk1000/atstk1004.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/avr32/boards/atstk1000/atstk1003.c b/arch/avr32/boards/atstk1000/atstk1003.c index ea109f435a83..591fc73b554a 100644 --- a/arch/avr32/boards/atstk1000/atstk1003.c +++ b/arch/avr32/boards/atstk1000/atstk1003.c @@ -154,7 +154,7 @@ static int __init atstk1003_init(void) at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); #endif #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM - at32_add_device_mci(0); + at32_add_device_mci(0, NULL); #endif at32_add_device_usba(0, NULL); #ifndef CONFIG_BOARD_ATSTK100X_SW3_CUSTOM diff --git a/arch/avr32/boards/atstk1000/atstk1004.c b/arch/avr32/boards/atstk1000/atstk1004.c index c7236df74d74..d9c5e0a21256 100644 --- a/arch/avr32/boards/atstk1000/atstk1004.c +++ b/arch/avr32/boards/atstk1000/atstk1004.c @@ -137,7 +137,7 @@ static int __init atstk1004_init(void) at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); #endif #ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM - at32_add_device_mci(0); + at32_add_device_mci(0, NULL); #endif at32_add_device_lcdc(0, &atstk1000_lcdc_data, fbmem_start, fbmem_size, 0); From fbfca4b8781757c1950b2225ba67d83072e0bc07 Mon Sep 17 00:00:00 2001 From: Ben Nizette Date: Fri, 18 Jul 2008 16:48:09 +1000 Subject: [PATCH 2/7] avr32: clean up mci platform code This patch does a few small cleanups around the atmel mci platform code and in the atmel-mci driver. The platform changes simply removes an unused variable, uses the fact that by the end we always have some form of platform data and notes that GPIO_PIN_NONE != 0. This last point could cause the incorrect attempt to twice reserve pin PA0. While we've got the hood up, add linux/err.h to the atmel-mci.c include list. It needs it and generally pulls it by voodoo but I did once stumble across a config which don't build. This is against Linus' latest git. Signed-off-by: Ben Nizette Signed-off-by: Haavard Skinnemoen --- arch/avr32/mach-at32ap/at32ap700x.c | 13 ++++++------- drivers/mmc/host/atmel-mci.c | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c index 021d51217184..4ac38d28891d 100644 --- a/arch/avr32/mach-at32ap/at32ap700x.c +++ b/arch/avr32/mach-at32ap/at32ap700x.c @@ -1284,7 +1284,6 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) { struct mci_platform_data _data; struct platform_device *pdev; - struct dw_dma_slave *dws; if (id != 0) return NULL; @@ -1300,6 +1299,8 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) if (!data) { data = &_data; memset(data, 0, sizeof(struct mci_platform_data)); + data->detect_pin = GPIO_PIN_NONE; + data->wp_pin = GPIO_PIN_NONE; } if (platform_device_add_data(pdev, data, @@ -1313,12 +1314,10 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */ select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */ - if (data) { - if (data->detect_pin != GPIO_PIN_NONE) - at32_select_gpio(data->detect_pin, 0); - if (data->wp_pin != GPIO_PIN_NONE) - at32_select_gpio(data->wp_pin, 0); - } + if (data->detect_pin != GPIO_PIN_NONE) + at32_select_gpio(data->detect_pin, 0); + if (data->wp_pin != GPIO_PIN_NONE) + at32_select_gpio(data->wp_pin, 0); atmel_mci0_pclk.dev = &pdev->dev; diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index cce873c5a149..c2f8aa840e82 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include From 218df4a25a9b828df4bb44c86e35febe40c82e62 Mon Sep 17 00:00:00 2001 From: Hans-Christian Egtvedt Date: Tue, 1 Jul 2008 14:26:45 +0200 Subject: [PATCH 3/7] avr32: Add platform data for AC97C platform device This patch adds platform data to the AC97C platform device. This will let the board add a GPIO line which is connected to the external codecs reset line. The platform data, ac97c_platform_data, must also contain the DMA controller ID, RX channel ID and TX channel ID. Tested with Wolfson WM9712 and AP7000. Signed-off-by: Hans-Christian Egtvedt Signed-off-by: Haavard Skinnemoen --- arch/avr32/mach-at32ap/at32ap700x.c | 34 +++++++++++++++++++++------ include/asm-avr32/arch-at32ap/board.h | 10 +++++++- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c index 4ac38d28891d..30c7cdab28d0 100644 --- a/arch/avr32/mach-at32ap/at32ap700x.c +++ b/arch/avr32/mach-at32ap/at32ap700x.c @@ -1883,9 +1883,11 @@ static struct clk atmel_ac97c0_pclk = { .index = 10, }; -struct platform_device *__init at32_add_device_ac97c(unsigned int id) +struct platform_device *__init +at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data) { struct platform_device *pdev; + struct ac97c_platform_data _data; if (id != 0) return NULL; @@ -1896,19 +1898,37 @@ struct platform_device *__init at32_add_device_ac97c(unsigned int id) if (platform_device_add_resources(pdev, atmel_ac97c0_resource, ARRAY_SIZE(atmel_ac97c0_resource))) - goto err_add_resources; + goto fail; - select_peripheral(PB(20), PERIPH_B, 0); /* SYNC */ - select_peripheral(PB(21), PERIPH_B, 0); /* SDO */ - select_peripheral(PB(22), PERIPH_B, 0); /* SDI */ - select_peripheral(PB(23), PERIPH_B, 0); /* SCLK */ + if (!data) { + data = &_data; + memset(data, 0, sizeof(struct ac97c_platform_data)); + data->reset_pin = GPIO_PIN_NONE; + } + + data->dma_rx_periph_id = 3; + data->dma_tx_periph_id = 4; + data->dma_controller_id = 0; + + if (platform_device_add_data(pdev, data, + sizeof(struct ac97c_platform_data))) + goto fail; + + select_peripheral(PB(20), PERIPH_B, 0); /* SDO */ + select_peripheral(PB(21), PERIPH_B, 0); /* SYNC */ + select_peripheral(PB(22), PERIPH_B, 0); /* SCLK */ + select_peripheral(PB(23), PERIPH_B, 0); /* SDI */ + + /* TODO: gpio_is_valid(data->reset_pin) with kernel 2.6.26. */ + if (data->reset_pin != GPIO_PIN_NONE) + at32_select_gpio(data->reset_pin, 0); atmel_ac97c0_pclk.dev = &pdev->dev; platform_device_add(pdev); return pdev; -err_add_resources: +fail: platform_device_put(pdev); return NULL; } diff --git a/include/asm-avr32/arch-at32ap/board.h b/include/asm-avr32/arch-at32ap/board.h index a3783861cdd2..203cb4ead2c8 100644 --- a/include/asm-avr32/arch-at32ap/board.h +++ b/include/asm-avr32/arch-at32ap/board.h @@ -82,7 +82,15 @@ struct mci_platform_data; struct platform_device * at32_add_device_mci(unsigned int id, struct mci_platform_data *data); -struct platform_device *at32_add_device_ac97c(unsigned int id); +struct ac97c_platform_data { + unsigned short dma_rx_periph_id; + unsigned short dma_tx_periph_id; + unsigned short dma_controller_id; + int reset_pin; +}; +struct platform_device * +at32_add_device_ac97c(unsigned int id, struct ac97c_platform_data *data); + struct platform_device *at32_add_device_abdac(unsigned int id); struct platform_device *at32_add_device_psif(unsigned int id); From db6ea2c17cef531a58f48c51c3a0892edcaf1380 Mon Sep 17 00:00:00 2001 From: Huang Weiyi Date: Sat, 21 Jun 2008 22:30:43 +0800 Subject: [PATCH 4/7] drivers/misc/atmel-ssc.c: Removed duplicated include Removed duplicated include file in drivers/misc/atmel-ssc.c. Signed-off-by: Huang Weiyi Signed-off-by: Haavard Skinnemoen --- drivers/misc/atmel-ssc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index e171650766ce..bf5e4d065436 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include From 56d3eef2b49b06618981c87edba16a607bf10ddd Mon Sep 17 00:00:00 2001 From: "Voss, Nikolaus" Date: Fri, 18 Jul 2008 14:44:48 +0200 Subject: [PATCH 5/7] avr32: allow system timer to share interrupt to make OProfile work The following patch allows the avr32_comparator interrupt to be shared. This is necessary as the avr32 oprofile driver shares the irq group 0 with the timer. To make OProfile actually work on AVR32, a small patch for oprofiled is also needed (posted to the oprofile mailing list). Signed-off-by: Nikolaus Voss [haavard.skinnemoen@atmel.com: set IRQF_SHARED unconditionally] Signed-off-by: Haavard Skinnemoen --- arch/avr32/kernel/time.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c index abd954fb7ba0..7e7f32771ae1 100644 --- a/arch/avr32/kernel/time.c +++ b/arch/avr32/kernel/time.c @@ -43,6 +43,9 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id) { struct clock_event_device *evdev = dev_id; + if (unlikely(!(intc_get_pending(0) & 1))) + return IRQ_NONE; + /* * Disable the interrupt until the clockevent subsystem * reprograms it. @@ -55,7 +58,8 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id) static struct irqaction timer_irqaction = { .handler = timer_interrupt, - .flags = IRQF_TIMER | IRQF_DISABLED, + /* Oprofile uses the same irq as the timer, so allow it to be shared */ + .flags = IRQF_TIMER | IRQF_DISABLED | IRQF_SHARED, .name = "avr32_comparator", }; From 87a9f704658a40940e740b1d73d861667e9164d3 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 25 Jul 2008 23:03:48 +0300 Subject: [PATCH 6/7] include/video/atmel_lcdc.h must #include This patch fixes the following compile error caused by commit d22579b837358cbef12ccca5adaf7e93ae09ab7a (atmel_lcdfb: FIFO underflow management): <-- snip --> ... CC arch/avr32/boards/atstk1000/atstk1004.o In file included from /home/bunk/linux/kernel-2.6/git/linux-2.6/arch/avr32/boards/atstk1000/atstk1004.c:21: /home/bunk/linux/kernel-2.6/git/linux-2.6/include/video/atmel_lcdc.h:40: error: field 'task' has incomplete type make[2]: *** [arch/avr32/boards/atstk1000/atstk1004.o] Error 1 <-- snip --> Reported-by: Adrian Bunk Signed-off-by: Adrian Bunk Signed-off-by: Haavard Skinnemoen --- include/video/atmel_lcdc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/video/atmel_lcdc.h b/include/video/atmel_lcdc.h index ed64862c4e18..dc934e8edc4f 100644 --- a/include/video/atmel_lcdc.h +++ b/include/video/atmel_lcdc.h @@ -22,6 +22,7 @@ #ifndef __ATMEL_LCDC_H__ #define __ATMEL_LCDC_H__ +#include /* Way LCD wires are connected to the chip: * Some Atmel chips use BGR color mode (instead of standard RGB) From 3c26e17032e42cfbe606882288223ad6146e4c38 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Sun, 27 Jul 2008 02:34:45 -0700 Subject: [PATCH 7/7] 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 Signed-off-by: Haavard Skinnemoen --- arch/avr32/boards/atstk1000/atstk1002.c | 19 ++++++++++++++++++- arch/avr32/mach-at32ap/at32ap700x.c | 13 +++++++------ drivers/mmc/host/atmel-mci.c | 16 ++++++++-------- 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 @@ #include #include +#include + #include #include #include @@ -260,6 +262,21 @@ void __init setup_board(void) at32_setup_serial_console(0); } +#ifndef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM + +/* MMC card detect requires MACB0 *NOT* be used */ +#ifdef CONFIG_BOARD_ATSTK1002_SW6_CUSTOM +static struct mci_platform_data __initdata mci0_data = { + .detect_pin = GPIO_PIN_PC(14), /* gpio30/sdcd */ + .wp_pin = GPIO_PIN_PC(15), /* gpio31/sdwp */ +}; +#define MCI_PDATA &mci0_data +#else +#define MCI_PDATA NULL +#endif /* SW6 for sd{cd,wp} routing */ + +#endif /* SW2 for MMC signal routing */ + static int __init atstk1002_init(void) { /* @@ -309,7 +326,7 @@ static int __init atstk1002_init(void) at32_add_device_spi(1, spi1_board_info, ARRAY_SIZE(spi1_board_info)); #endif #ifndef CONFIG_BOARD_ATSTK1002_SW2_CUSTOM - at32_add_device_mci(0, NULL); + at32_add_device_mci(0, MCI_PDATA); #endif #ifdef CONFIG_BOARD_ATSTK1002_SW5_CUSTOM set_hw_addr(at32_add_device_eth(1, ð_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 @@ #include #include #include +#include #include #include @@ -1299,7 +1300,7 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) if (!data) { data = &_data; - memset(data, 0, sizeof(struct mci_platform_data)); + memset(data, -1, sizeof(struct mci_platform_data)); data->detect_pin = GPIO_PIN_NONE; data->wp_pin = GPIO_PIN_NONE; } @@ -1315,9 +1316,9 @@ at32_add_device_mci(unsigned int id, struct mci_platform_data *data) select_peripheral(PA(14), PERIPH_A, 0); /* DATA2 */ select_peripheral(PA(15), PERIPH_A, 0); /* DATA3 */ - if (data->detect_pin != GPIO_PIN_NONE) + if (gpio_is_valid(data->detect_pin)) at32_select_gpio(data->detect_pin, 0); - if (data->wp_pin != GPIO_PIN_NONE) + if (gpio_is_valid(data->wp_pin)) at32_select_gpio(data->wp_pin, 0); atmel_mci0_pclk.dev = &pdev->dev; @@ -1852,11 +1853,11 @@ at32_add_device_cf(unsigned int id, unsigned int extint, if (at32_init_ide_or_cf(pdev, data->cs, extint)) goto fail; - if (data->detect_pin != GPIO_PIN_NONE) + if (gpio_is_valid(data->detect_pin)) at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH); - if (data->reset_pin != GPIO_PIN_NONE) + if (gpio_is_valid(data->reset_pin)) at32_select_gpio(data->reset_pin, 0); - if (data->vcc_pin != GPIO_PIN_NONE) + if (gpio_is_valid(data->vcc_pin)) at32_select_gpio(data->vcc_pin, 0); /* READY is used as extint, so we can't select it as gpio */ 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 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,6 @@ #include #include -#include #include "atmel-mci-regs.h" @@ -574,7 +574,7 @@ static int atmci_get_ro(struct mmc_host *mmc) int read_only = 0; struct atmel_mci *host = mmc_priv(mmc); - if (host->wp_pin >= 0) { + if (gpio_is_valid(host->wp_pin)) { read_only = gpio_get_value(host->wp_pin); dev_dbg(&mmc->class_dev, "card is %s\n", read_only ? "read-only" : "read-write"); @@ -636,7 +636,7 @@ static void atmci_detect_change(unsigned long data) * been freed. */ smp_rmb(); - if (host->detect_pin < 0) + if (!gpio_is_valid(host->detect_pin)) return; enable_irq(gpio_to_irq(host->detect_pin)); @@ -1051,7 +1051,7 @@ static int __init atmci_probe(struct platform_device *pdev) /* Assume card is present if we don't have a detect pin */ host->present = 1; - if (host->detect_pin >= 0) { + if (gpio_is_valid(host->detect_pin)) { if (gpio_request(host->detect_pin, "mmc_detect")) { dev_dbg(&mmc->class_dev, "no detect pin available\n"); host->detect_pin = -1; @@ -1059,7 +1059,7 @@ static int __init atmci_probe(struct platform_device *pdev) host->present = !gpio_get_value(host->detect_pin); } } - if (host->wp_pin >= 0) { + if (gpio_is_valid(host->wp_pin)) { if (gpio_request(host->wp_pin, "mmc_wp")) { dev_dbg(&mmc->class_dev, "no WP pin available\n"); host->wp_pin = -1; @@ -1070,7 +1070,7 @@ static int __init atmci_probe(struct platform_device *pdev) mmc_add_host(mmc); - if (host->detect_pin >= 0) { + if (gpio_is_valid(host->detect_pin)) { setup_timer(&host->detect_timer, atmci_detect_change, (unsigned long)host); @@ -1113,7 +1113,7 @@ static int __exit atmci_remove(struct platform_device *pdev) if (host) { /* Debugfs stuff is cleaned up by mmc core */ - if (host->detect_pin >= 0) { + if (gpio_is_valid(host->detect_pin)) { int pin = host->detect_pin; /* Make sure the timer doesn't enable the interrupt */ @@ -1133,7 +1133,7 @@ static int __exit atmci_remove(struct platform_device *pdev) mci_readl(host, SR); clk_disable(host->mck); - if (host->wp_pin >= 0) + if (gpio_is_valid(host->wp_pin)) gpio_free(host->wp_pin); free_irq(platform_get_irq(pdev, 0), host->mmc);