CompactFlash driver for AT32AP7000

This is not really a driver per se, but rather a collection of architecture-dependent patches necessary to access CompactFlash storage cards using the standard pata_pcmcia driver. The overall picture looks something like this:

The at32_cf driver has also been tested with the orinoco_cs driver and a Linksys 801.11b CF card. It should also be usable with the legacy ide-cs driver, but this has not been tested (yet.) CardBus? devices will most likely not work.

STK1000 hacks

For the driver to work on STK1000, one minor hack is necessary. An additional hack is necessary for card detection to work.

Wiring up the -READY interrupt

On the STK1000, the -READY interrupt is connected to EIM_EXTINT_5, which doesn't exist on the AT32AP7000. Both EIM_EXTINT_5 and EIM_EXTINT_3 (which the driver is set up to use as default) are present on the J29 header, located between the ATSTK1002 daughterboard and the LCD panel. To route the -READY interrupt to the AP7000 external interrupt module, simply connect pins 27 and 29 on J29 together using a jumper or a short piece of wire.

Re-routing RESET

On a standard STK1000 card, the CF RESET signal is hooked up to the board reset. Some cards may be able to cope with this, but for the driver to be able to reset the card, RESET must be re-wired to a GPIO signal. The 2.6.20 patches are hard-wired to use GPIO14 for RESET, while the 2.6.22 patches default to not controlling the RESET line.

To use RESET, set CONFIG_BOARD_ATSTK1002_CF_HACKS = y and select the GPIO pin to use. The you need to lift the -CD1 pin at the CF connector from the PCB and strap it to the selected GPIO line (i.e. pin 7 on J2, one of the four 10-pin GPIO headers, when using GPIO14.)

Re-routing the card detection signals

This hack isn't entirely necessary -- if you set the detect_pin member of cf0_data in arch/avr32/boards/atstk1000/atstk1002.c to 0, the driver will simply assume the card is always present.

On a standard STK1000 card, the -CD1 signal is connected to GPIO29, which is multiplexed with MACB0_RXER on the STK1002. Unfortunately, this means that if you want CompactFlash card detection to work, you need to disable MACB0.

If you want to both have card detection work, and still be able to use MACB0, you need to wire the -CD1 to a different GPIO line. The driver is set up to not use card detection by default, but this can be changed by running "make menuconfig" by setting CONFIG_BOARD_ATSTK1002_CF_HACKS = y. For example, to use GPIO15 for -CD1 (the default when the hack option is enabled) you need to lift the -CD1 pin at the CF connector from the PCB and strap it to pin 8 on J2 (one of the four 10-pin GPIO headers.) Don't forget to add a pull-up resistor to 3.3V.

Note that the 2.6.20 and 2.6.21 patches use different defaults and aren't as configurable.

Patches

Against 2.6.22.atmel.1

The following patches add CompactFlash support to the 2.6.22.atmel.1 kernel, which can be downloaded from the LinuxPatches page. Note that the external interrupt has changed from 3 to 2 and that the GPIO signals for -CD1 and RESET are now really optional as well as configurable.

Against 2.6.22.atmel.5 / 2.6.23.atmel.1

The patches for 2.6.22.atmel.1 should apply with some minor rejects. In addition, the following patch is needed:

The latest atmel-2.6.22, atmel-2.6.23 and master branches from git includes the latest incarnation of the at32_cf driver, including the above patch.

Against 2.6.20-avr2

The following patches are necessary to use CompactFlash with the 2.6.20-avr2 kernel, which can be downloaded from the LinuxPatches page. It is recommended to apply the patches in the order they are listed.

Note: These patches uses EXTINT3 as an external interrupt and are hardwired to use RESET pm GPIO14 and -CD1 on GPIO13. This has changed in the newer patches above.

  1. avr32-make-i-o-access-macros-work-with-external-devices.patch: [AVR32] Make I/O access macros work with external devices
  2. cistpl-fix-misaligned-load.patch: cistpl: Fix misaligned load
  3. pcmcia-ioaddr_t-is-32-bits-on-avr32.patch: PCMCIA: ioaddr_t is 32 bits on AVR32
  4. add-compactflash-glue-for-at32ap7000.patch: Add CompactFlash glue for AT32AP7000
  5. avr32-ap7000-add-platform_device-for-compactflash.patch: [AVR32] AP7000: Add platform_device for CompactFlash
  6. avr32-wire-up-compactflash-on-stk1000.patch: [AVR32] Wire up CompactFlash on STK1000

Older kernels should work as well, with a few minor changes. The platform code (i.e. the platform_device definitions) is most likely to cause conflicts. If you do the necessary tweaking to apply these patches on top of older kernel, feel free to attach the modified patches here.

Note that avr32-make-i-o-access-macros-work-with-external-devices.patch breaks the serial driver in the 2.6.20-avr1 kernel, and possibly other kernels as well. The atmel_serial driver has been fixed upstream, so 2.6.21-rc should be fine.

Also note that some CompactFlash cards may be buggy in various ways. Some cards refuse PIO mode setting; a workaround for this has been merged in the upstream kernel, but not in time for the 2.6.20 release. Yet other cards may come up as both master and slave. No workarounds exists for this problem AFAIK, but such cards should work just fine apart from the fact that they show up as two different devices.

Against 2.6.21.1

Do as above, but drop the patch "avr32-make-i-o-access-macros-work-with-external-devices.patch" and apply at32_cf-fix-compile-errors-and-warnings-for-2.6.21.1.patch.

Attachment sort Action Size Date Who Comment
elseavr32-make-i-o-access-macros-work-with-external-devices.patch manage 14.8 K 28 Feb 2007 - 14:48 HaavardSkinnemoen [AVR32] Make I/O access macros work with external devices
else0002-pcmcia-ioaddr_t-should-be-32-bits-on-AVR32.patch manage 0.9 K 09 Jul 2007 - 15:37 HaavardSkinnemoen Make ioaddr_t 32 bits on AVR32
else0004-Add-CompactFlash-glue-driver-for-AT32AP-CPUs.patch manage 15.3 K 09 Jul 2007 - 15:38 HaavardSkinnemoen CompactFlash glue driver
elseavr32-wire-up-compactflash-on-stk1000.patch manage 1.2 K 28 Feb 2007 - 14:50 HaavardSkinnemoen [AVR32] Wire up CompactFlash on STK1000
elsepcmcia-ioaddr_t-is-32-bits-on-avr32.patch manage 0.8 K 28 Feb 2007 - 14:49 HaavardSkinnemoen PCMCIA: ioaddr_t is 32 bits on AVR32
elsecistpl-fix-misaligned-load.patch manage 1.3 K 28 Feb 2007 - 14:49 HaavardSkinnemoen cistpl: Fix misaligned load
elseavr32-ap7000-add-platform_device-for-compactflash.patch manage 10.5 K 28 Feb 2007 - 14:50 HaavardSkinnemoen [AVR32] AP7000: Add platform_device for CompactFlash
else0001-at32_cf-Set-up-SMC-timings-properly.patch manage 1.8 K 18 Oct 2007 - 10:41 HaavardSkinnemoen at32_cf: Set up SMC timings properly
elseat32_cf-fix-compile-errors-and-warnings-for-2.6.21.1.patch manage 1.5 K 30 May 2007 - 05:22 HansChristianEgtvedt at32_cf: fix compile errors and warnings
else0001-cistpl-Use-get_unaligned-when-accessing-possibly-un.patch manage 5.0 K 09 Jul 2007 - 15:35 HaavardSkinnemoen Use get_unaligned() in cistpl.c
elseadd-compactflash-glue-for-at32ap7000.patch manage 15.0 K 02 Mar 2007 - 16:19 HaavardSkinnemoen Add CompactFlash glue for AT32AP7000
else0003-AVR32-CompactFlash-platform-code.patch manage 5.8 K 09 Jul 2007 - 15:38 HaavardSkinnemoen CompactFlash platform code