From 3ae1eb0bad66b990ac0eb7f985a40359a8bdaa94 Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Mon, 9 Jul 2007 17:21:47 +0200 Subject: [PATCH] [AVR32] CompactFlash platform code Implement at32_add_device_cf() for AP7000 and wire up CompactFlash on STK1000. Signed-off-by: Haavard Skinnemoen --- arch/avr32/boards/atstk1000/Kconfig | 31 +++++++++++++ arch/avr32/boards/atstk1000/atstk1002.c | 9 ++++ arch/avr32/mach-at32ap/at32ap7000.c | 72 +++++++++++++++++++++++++++++++ include/asm-avr32/arch-at32ap/board.h | 11 +++++ 4 files changed, 123 insertions(+), 0 deletions(-) diff --git a/arch/avr32/boards/atstk1000/Kconfig b/arch/avr32/boards/atstk1000/Kconfig index 718578f..6e8fa6c 100644 --- a/arch/avr32/boards/atstk1000/Kconfig +++ b/arch/avr32/boards/atstk1000/Kconfig @@ -76,4 +76,35 @@ config BOARD_ATSTK1002_J2_RGB endchoice +config BOARD_ATSTK1002_CF_HACKS + bool "ATSTK1002 CompactFlash hacks" + depends on !BOARD_ATSTK1002_SW4_CUSTOM + help + Select this if you have re-routed the CompactFlash RESET and + CD signals to GPIOs on your STK1000/STK1002. This is + necessary for reset and card detection to work properly, + although some CF cards may be able to cope without reset. + +config BOARD_ATSTK1002_CF_RESET_PIN + hex "CompactFlash RESET pin" + default 0x30 + depends on BOARD_ATSTK1002_CF_HACKS + help + Select which GPIO pin to use for the CompactFlash RESET + signal. This is specified as a hexadecimal number and should + be defined as 0x20 * gpio_port + pin. + + The default is 0x30, which is pin 16 on PIOB, aka GPIO14. + +config BOARD_ATSTK1002_CF_DETECT_PIN + hex "CompactFlash DETECT pin" + default 0x3e + depends on BOARD_ATSTK1002_CF_HACKS + help + Select which GPIO pin to use for the CompactFlash CD + signal. This is specified as a hexadecimal number and should + be defined as 0x20 * gpio_port + pin. + + The default is 0x3e, which is pin 30 on PIOB, aka GPIO15. + endif # stk 1002 diff --git a/arch/avr32/boards/atstk1000/atstk1002.c b/arch/avr32/boards/atstk1000/atstk1002.c index 5bdd95e..8d8b694 100644 --- a/arch/avr32/boards/atstk1000/atstk1002.c +++ b/arch/avr32/boards/atstk1000/atstk1002.c @@ -59,6 +59,14 @@ static struct mci_platform_data __initdata mci0_data = { .wp_pin = GPIO_PIN_NONE, }; +static struct cf_platform_data __initdata cf0_data = { +#ifdef CONFIG_BOARD_ATSTK1002_CF_HACKS + .detect_pin = CONFIG_BOARD_ATSTK1002_CF_DETECT_PIN, + .reset_pin = CONFIG_BOARD_ATSTK1002_CF_RESET_PIN, +#endif + .ready_pin = GPIO_PIN_PB(27), +}; + /* * The next two functions should go away as the boot loader is * supposed to initialize the macb address registers with a valid @@ -241,6 +249,7 @@ static int __init atstk1002_init(void) #endif at32_add_device_usba(0, NULL); at32_add_device_abdac(0); + at32_add_device_cf(0, 2, &cf0_data); #ifndef CONFIG_BOARD_ATSTK1002_SW3_CUSTOM at32_add_device_ssc(0, ATMEL_SSC_TX); #endif diff --git a/arch/avr32/mach-at32ap/at32ap7000.c b/arch/avr32/mach-at32ap/at32ap7000.c index 1130c8a..9a6a8e7 100644 --- a/arch/avr32/mach-at32ap/at32ap7000.c +++ b/arch/avr32/mach-at32ap/at32ap7000.c @@ -1396,6 +1396,78 @@ at32_add_device_abdac(unsigned int id) } /* -------------------------------------------------------------------- + * CompactFlash + * -------------------------------------------------------------------- */ +static struct cf_platform_data at32_cf0_data; +static struct resource at32_cf0_resource[] = { + { + .start = 0x04000000, + .end = 0x07ffffff, + .flags = IORESOURCE_MEM, + }, + IRQ(~0UL), +}; +DEFINE_DEV_DATA(at32_cf, 0); + +struct platform_device *__init +at32_add_device_cf(unsigned int id, unsigned int extint, + struct cf_platform_data *data) +{ + struct platform_device *pdev; + unsigned int extint_pin; + + switch (extint) { + case 0: + extint_pin = GPIO_PIN_PB(25); + break; + case 1: + extint_pin = GPIO_PIN_PB(26); + break; + case 2: + extint_pin = GPIO_PIN_PB(27); + break; + case 3: + extint_pin = GPIO_PIN_PB(28); + break; + default: + return NULL; + } + + switch (id) { + case 0: + pdev = &at32_cf0_device; + select_peripheral(PE(19), PERIPH_A, 0); /* CFCE1 */ + select_peripheral(PE(20), PERIPH_A, 0); /* CFCE2 */ + select_peripheral(PE(21), PERIPH_A, 0); /* NCS4 */ + select_peripheral(PE(23), PERIPH_A, 0); /* CFNRW */ + select_peripheral(PE(24), PERIPH_A, 0); /* NWAIT */ + set_ebi_sfr_bits(HMATRIX_BIT(CS4A)); + data->cs = 4; + break; + default: + return NULL; + } + + if (data->detect_pin) + at32_select_gpio(data->detect_pin, AT32_GPIOF_DEGLITCH); + if (data->reset_pin) + at32_select_gpio(data->reset_pin, 0); + if (data->vcc_pin) + at32_select_gpio(data->vcc_pin, 0); + /* READY is used as extint, so we can't select it as gpio */ + + at32_select_periph(extint_pin, GPIO_PERIPH_A, AT32_GPIOF_PULLUP); + pdev->resource[1].start = EIM_IRQ_BASE + extint; + pdev->resource[1].end = pdev->resource[1].start; + + memcpy(pdev->dev.platform_data, data, + sizeof(struct cf_platform_data)); + + platform_device_register(pdev); + return pdev; +} + +/* -------------------------------------------------------------------- * GCLK * -------------------------------------------------------------------- */ static struct clk gclk0 = { diff --git a/include/asm-avr32/arch-at32ap/board.h b/include/asm-avr32/arch-at32ap/board.h index 9b36eb8..b15968f 100644 --- a/include/asm-avr32/arch-at32ap/board.h +++ b/include/asm-avr32/arch-at32ap/board.h @@ -70,4 +70,15 @@ struct platform_device *at32_add_device_abdac(unsigned int id); struct platform_device * at32_add_device_ssc(unsigned int id, unsigned int flags); +struct cf_platform_data { + int detect_pin; + int reset_pin; + int vcc_pin; + int ready_pin; + u8 cs; +}; +struct platform_device * +at32_add_device_cf(unsigned int id, unsigned int extint, + struct cf_platform_data *data); + #endif /* __ASM_ARCH_BOARD_H */ -- 1.5.2.3