Skip to contentSkip to conversation

Make ide-cs work for hardware with 8-bit CF-Interface

PATCH In review Thomas Kleffel (LKML) 3 participants 3 messages Sep 6, 2005 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make ide-cs work for hardware with 8-bit CF-Interface

Hello,

it is technically possible to access a CF-Card with an 8-bit width bus.

The problem with the current code is that the IDE code does a 16 (or 32) bit read on the IDE data register. If the bus interface for a 8-bit bus would then do two reads to offsets 0 and 1.

The second read (to offset 1) then reads the error register instead of the data register's odd byte.

To fix this problem I've changed the ide-cs code to use the duplicated data registers at offset 8 and 9 which are not overlapped with anything.

According to the specs, those registers should be there in every CF card. I've tested this with a couple of CFs, including SanDisk, Microdrive and several NoNames.

The specific architechture I'm using this on is a AT91RM9200 with kernel 2.6.13 and the patches from http://maxim.org.za/AT91RM9200/2.6/.

For more information on the overlapped / non-overlapped registers see http://www.compactflash.org/cfspc3_0.pdf - page 96

The following patch is against vanilla 2.6.13.

ldiff -uprN a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c

drivers/ide/legacy/ide-cs.c 2005-09-05 02:09:47.000000000 +0200 renamed from drivers/ide/legacy/ide-cs.c 2005-08-08 15:30:35.000000000 +0200 +2 -1
@@ -186,7 +186,8 @@ static int idecs_register(unsigned long
 {
     hw_regs_t hw;
     memset(&hw, 0, sizeof(hw));
-    ide_init_hwif_ports(&hw, io, ctl, NULL);
+    ide_std_init_ports(&hw, io, ctl);
+    hw.io_ports[IDE_DATA_OFFSET] = io + 0x08;
     hw.irq = irq;
     hw.chipset = ide_pci;
     return ide_register_hw_with_fixup(&hw, NULL, ide_undecoded_slave);

Best regards,

Thomas

#1 lore raw
Quoted 7 lines · Thomas Kleffel (LKML)

The following patch is against vanilla 2.6.13.

ldiff -uprN a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c

drivers/ide/legacy/ide-cs.c 2005-09-05 02:09:47.000000000 +0200 static int idecs_register(unsigned long · line 193

Quoted 9 lines
drivers/ide/legacy/ide-cs.c 2005-09-05 02:09:47.000000000 +0200 renamed from drivers/ide/legacy/ide-cs.c 2005-08-08 15:30:35.000000000 +0200 +2 -1
@@ -186,7 +186,8 @@ static int idecs_register(unsigned long
 {
     hw_regs_t hw;
     memset(&hw, 0, sizeof(hw));
-    ide_init_hwif_ports(&hw, io, ctl, NULL);
+    ide_std_init_ports(&hw, io, ctl);
+    hw.io_ports[IDE_DATA_OFFSET] = io + 0x08;
     hw.irq = irq;
     hw.chipset = ide_pci;
     return ide_register_hw_with_fixup(&hw, NULL, ide_undecoded_slave);

You can't do this, at least not exactly this way. io + 0x08 may not be a mapped IO address; it is only valid when a card is mapped with one contiguous 16-bit IO window. PCMCIA IDE cards are not necessarily mapped that way: they may be mapped with one 8-port window and one 1-port window, to match standard IBM PC IDE port locations. In that case, the registers at 0x08 and 0x09 are not available. The CF spec may impose more uniformity here than the PCMCIA spec does. I do know that some IDE cards do end up configured with discontiguous register allocations when used with ide-cs.c.

-- Dave

#2 lore raw
In reply to Thomas Kleffel (LKML)
Quoted 3 lines · Thomas Kleffel (LKML)

According to the specs, those registers should be there in every CF card. I've tested this with a couple of CFs, including SanDisk, Microdrive and several NoNames.

ide-cs handles a lot more than just CF cards so it might not be a wise approach fpr general consumption.