Welcome to AVR32 Linux... Users Groups

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:

  • libata programs the internal registers of the CompactFlash cards to perform data transfers. It presents the card as a SCSI disk device through the SCSI layer
  • pata_pcmcia is a libata low-level driver which uses the PCMCIA layer to initialize the card
  • The PCMCIA layer contains common code for setting up various memory regions through which the card is configured and accessed.
  • at32_cf is a low-level PCMCIA driver responsible for configuring the bus timings, dealing with card detection and other signaling, as well as configuring the various I/O memory regions.

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.


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.


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-

  File Size Date By Actions
else 0001-at32_cf-Set-up-SMC-timings-properly.patch
at32_cf: Set up SMC timings properly
1.8 K 2007-10-18 - 10:41 HaavardSkinnemoen props, move
else 0001-cistpl-Use-get_unaligned-when-accessing-possibly-un.patch
Use get_unaligned() in cistpl.c
5.0 K 2007-07-09 - 15:35 HaavardSkinnemoen props, move
else 0002-pcmcia-ioaddr_t-should-be-32-bits-on-AVR32.patch
Make ioaddr_t 32 bits on AVR32
0.9 K 2007-07-09 - 15:37 HaavardSkinnemoen props, move
else 0003-AVR32-CompactFlash-platform-code.patch
CompactFlash platform code
5.8 K 2007-07-09 - 15:38 HaavardSkinnemoen props, move
else 0004-Add-CompactFlash-glue-driver-for-AT32AP-CPUs.patch
CompactFlash glue driver
15.3 K 2007-07-09 - 15:38 HaavardSkinnemoen props, move
else add-compactflash-glue-for-at32ap7000.patch
Add CompactFlash glue for AT32AP7000
15.0 K 2007-03-02 - 16:19 HaavardSkinnemoen props, move
else at32_cf-fix-compile-errors-and-warnings-for-
at32_cf: fix compile errors and warnings
1.5 K 2007-05-30 - 05:22 HansChristianEgtvedt props, move
else avr32-ap7000-add-platform_device-for-compactflash.patch
[AVR32] AP7000: Add platform_device for CompactFlash
10.5 K 2007-02-28 - 14:50 HaavardSkinnemoen props, move
else avr32-make-i-o-access-macros-work-with-external-devices.patch
[AVR32] Make I/O access macros work with external devices
14.8 K 2007-02-28 - 14:48 HaavardSkinnemoen props, move
else avr32-wire-up-compactflash-on-stk1000.patch
[AVR32] Wire up CompactFlash on STK1000
1.2 K 2007-02-28 - 14:50 HaavardSkinnemoen props, move
else cistpl-fix-misaligned-load.patch
cistpl: Fix misaligned load
1.3 K 2007-02-28 - 14:49 HaavardSkinnemoen props, move
else pcmcia-ioaddr_t-is-32-bits-on-avr32.patch
PCMCIA: ioaddr_t is 32 bits on AVR32
0.8 K 2007-02-28 - 14:49 HaavardSkinnemoen props, move
r7 - 2007-10-18 - 10:41:53 - HaavardSkinnemoen
Copyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.
Atmel®, AVR® and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries.
All other trademarks are the property of their respective owners.
Syndicate this site RSSATOM