Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Jun 1999 02:24:53 -0400
From:      Christopher Masto <chris@netmonger.net>
To:        hardware@freebsd.org
Subject:   Ugly patches for PCMCIA flash ATA
Message-ID:  <19990602022453.A23670@netmonger.net>

next in thread | raw e-mail | index | archive | help
It's a pain to hook up the port replicator, serial cable, etc. every
time I want to download some pictures from my camera, so I hacked the
pccard support back into the -current wd driver.  I know that Warner
is working on the pccard newbus stuff; this was just an interim
workaround.  Anyway, I did it for me, but this subject comes up once
in a while, so I thought I'd mention it here so it'll at least be in
the archives if someone needs it.

The actual patch is on http://www.netmonger.net/~chris/freebsd/

The README follows:

This is an ugly hack to make my SanDisk PC card compact flash adapter
work on current (as of 1-Jun-1999).  It probably work with other ATA
flash cards as well.  The following things are done:

1. PCCARD interface added
   Minor adjustments for -current.  I removed the static configuration
   thing since I didn't understand it.

2. Attempts to allow removal/reinsertion
   This is based on code that I believe came from Tatsumi Hosokawa at
   some point.  I took out some of the TODOs because this whole thing is
   going away soon anyway.  In my experimentation, if the flash card is
   unmounted before being ejected, it's perfectly safe.  I have switched
   between a 3C509 and the SanDisk card several times with no ill
   effects.  It appears to be Good Enough For Now.

3. Workaround for funky I/O ports
   This is the really ugly part.  The wd driver makes assumptions that
   pretty much limit you to having two IDE controllers, at 0x1f0 and
   0x170.  While my VAIO only has one IDE controller onboard, and the
   SanDisk card is able to appear at 0x170, it didn't seem to work
   properly unless I booted with the card in.  Perhaps the VAIO reserves
   that space for the optional CDROM.  In any event, the SanDisk card has
   a configuration that allows it to be put at any location.  The catch
   is that wd also assumes that the alternate status register is located
   0x206 above the base port.  In the case of the SanDisk's "anywhere"
   configuration, this is not true - the ports are all lumped together.
   So there's a little hack that uses a different offset if the base
   port is not 0x170 or 0x1f0.

To use (assuming your hardware is identical to mine):

Patch.
Configure kernel.  Add an extra wdc, disabled.  Add a drive to it.
> controller      wdc1    at isa? disable port IO_WD2 irq 15
> disk            wd2     at wdc1 drive 0
Configure pccard.conf.  If you have the SanDisk card I have, it would
  go like this:
> card "SunDisk" "SDP"
>         config  0x1 "wdc1" 15
>         insert  echo SunDisk Flash ATA Inserted
>         remove  echo SunDisk Flash ATA Removed
Note that the configuration is changed from the sample file's 3 to 1.
  config 3 has it at 0x170, which isn't happy on my laptop.

That should do it.  On my machine, when I pop the Compact Flash from
my Kodak DC210 into the SanDisk adapter, and into the card slot,
I see:

> Card inserted, slot 0
> wdc1: unit 0 (wd2): <SunDisk SDCFB-8>
> wd2: 7MB (15680 sectors), 245 cyls, 2 heads, 32 S/T, 512 B/S
> wd2: ATA INQUIRE valid = 0001, dmamword = 0000, apio = 0000, udma = 0000

I can then mount -t msdos /dev/wd2s1 /flash   and access the files.

As I said, this works _for me_.  My primary objective was to regain
convenient use of my digital camera under -current while waiting for
the pccard newbusification.  I know this is ugly and wrong and
incomplete, but it does what I need for now.  I am putting it here in
case it is of use to someone else.

And thanks to SanDisk for putting extremely detailed documentation on
their web site, and for making such a nifty adapter.



-- 
Christopher Masto         Senior Network Monkey      NetMonger Communications
chris@netmonger.net        info@netmonger.net        http://www.netmonger.net

Free yourself, free your machine, free the daemon -- http://www.freebsd.org/


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hardware" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990602022453.A23670>