linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Make ide-cs work for hardware with 8-bit CF-Interface
@ 2005-09-06 16:47 Thomas Kleffel (LKML)
  2005-09-06 22:20 ` David Hinds
  2005-09-06 23:30 ` Alan Cox
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Kleffel (LKML) @ 2005-09-06 16:47 UTC (permalink / raw)
  To: B.Zolnierkiewicz; +Cc: linux-kernel, linux-ide, linux-pcmcia

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
--- a/drivers/ide/legacy/ide-cs.c       2005-08-08 15:30:35.000000000 +0200
+++ b/drivers/ide/legacy/ide-cs.c       2005-09-05 02:09:47.000000000 +0200
@@ -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);


Signed-off-by: Thomas Kleffel <tk@maintech.de>


Best regards,

Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make ide-cs work for hardware with 8-bit CF-Interface
  2005-09-06 16:47 [PATCH] Make ide-cs work for hardware with 8-bit CF-Interface Thomas Kleffel (LKML)
@ 2005-09-06 22:20 ` David Hinds
  2005-09-06 23:30 ` Alan Cox
  1 sibling, 0 replies; 3+ messages in thread
From: David Hinds @ 2005-09-06 22:20 UTC (permalink / raw)
  To: Thomas Kleffel (LKML)
  Cc: B.Zolnierkiewicz, linux-ide, linux-pcmcia, linux-kernel

On Tue, Sep 06, 2005 at 06:47:08PM +0200, Thomas Kleffel (LKML) wrote:
> 
> 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
> --- a/drivers/ide/legacy/ide-cs.c       2005-08-08 15:30:35.000000000 +0200
> +++ b/drivers/ide/legacy/ide-cs.c       2005-09-05 02:09:47.000000000 +0200
> @@ -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Make ide-cs work for hardware with 8-bit CF-Interface
  2005-09-06 16:47 [PATCH] Make ide-cs work for hardware with 8-bit CF-Interface Thomas Kleffel (LKML)
  2005-09-06 22:20 ` David Hinds
@ 2005-09-06 23:30 ` Alan Cox
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Cox @ 2005-09-06 23:30 UTC (permalink / raw)
  To: Thomas Kleffel (LKML)
  Cc: B.Zolnierkiewicz, linux-kernel, linux-ide, linux-pcmcia

On Maw, 2005-09-06 at 18:47 +0200, Thomas Kleffel (LKML) wrote:
> 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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-09-06 23:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-06 16:47 [PATCH] Make ide-cs work for hardware with 8-bit CF-Interface Thomas Kleffel (LKML)
2005-09-06 22:20 ` David Hinds
2005-09-06 23:30 ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).