Subject: CompactFlash on PCMCIA problems

From: Ulrich Eckhardt <[email-masked]>
Date: Fri, 8 Apr 2005 16:10:30 +0200

Hi!

I'm trying to code the glue to connect the vanilla ATA drivers with a CF card 
connected to an Au1100. I managed to access the CIS parts of the card but 
then the problems start: the area where I'd expect to find the ATA 
controller's registers mirrors every byte twice, just as if the address used 
was first shifted by one.

Here's a sketch of what I'm doing:

1. Setup SYS_PINFUNC so the PCMCIA interface is used
2. Setup GPIO and GPIO2, they are used for e.g. card detection and power
3. apply power to card via GPIO
4. reset card via GPIO, waiting for it to finish
5. ioremap all three PCMCIA_*_PHYS_ADDR ranges[1]
6. parse CIS in ioremapped PCMCIA_ATTR_PHYS_ADDR
7. setup CISREG_CCSR with 0x00, in particular to reset CCSR_POWER_DOWN
8. setup CISREG_COR with 0x01, configuration #1 is the contiguous memory[1] 
configuration parsed from the CIS

At this moment, I think I should be able to talk to the ATA controller via the 
first few bytes of the ioremapped PCMCIA_IO_PHYS_ADDR, but that area has this 
weird mirrored byte behaviour which I don't understand.

Another thing I don't fully understand yet is the meaning of the three memory 
areas. These are called 'IO', 'attrib' and 'mem'. The 'attrib' area contains 
the CIS and presents no problem. The 'IO' area is where I'd expect to find 
the ATA controller's registers. Now, what I don't understand is the meaning 
of the 'mem' area (PCMCIA_MEM_PHYS_ADDR). The documents I found on the web 
always referred to a 'common memory' area, but funnily they also only 
distinguished between two areas!?

Yet another thing I'm missing is the meaning of CISREG_IOBASE_* and 
CISREG_IOSIZE. When exactly and how do I have to setup those?

I'm pretty lost, I have tried everything I could think of without any success. 
I'll also send this to the PCMCIA mailinglist at sourceforge's, in case it is 
not related to MIPS but rather to PCMCIA.

greetings

Uli

[1] is a particular size required? Also, I used ioremap_nocache(), does that 
matter or should I use plain ioremap()?
[2] yes, it might be more interesting to use one of the non-contiguous modes, 
but that still doesn't solve my problems.

---

From: Ulrich Eckhardt <[email-masked]>
Date: Wed, 13 Apr 2005 16:51:04 +0200

Ulrich Eckhardt wrote:
> I'm trying to code the glue to connect the vanilla ATA drivers with a CF
> card connected to an Au1100. I managed to access the CIS parts of the card
> but then the problems start: the area where I'd expect to find the ATA
> controller's registers mirrors every byte twice, just as if the address
> used was first shifted by one.
>

Well, at least I tried to...

[...]
> At this moment, I think I should be able to talk to the ATA controller via
> the first few bytes of the ioremapped PCMCIA_IO_PHYS_ADDR, but that area
> has this weird mirrored byte behaviour which I don't understand.

Setting the PC flag in SYS_PINFUNC in fact DISables the PCMCIA driver, leaving 
PREG, PCE1, PCE2 and PWE as GPIO pins. These seem unused for 16 bit accesses 
to the attribute memory but required for the 8 bit accesses to the ATA 
controller's registers, causing the funny behaviour.

"Principle of maximum surprise."

oh, well....

Uli