Subject: Re: CompactFlash
To: Jukka Marin <jmarin@pyy.jmp.fi>
From: Stefan Grefen <grefen@hprc.tandem.com>
List: tech-kern
Date: 09/04/1998 22:38:02
In message <19980904211929.05112@pyy.jmp.fi>  Jukka Marin wrote:
> On Fri, Sep 04, 1998 at 08:12:28PM +0200, Lennart Augustsson wrote:
> 
> In early July, Stefan Grefen (grefen@hprc.tandem.com) said it works
> for him, at least with some patches.  Here's what he wrote on this
> mailing list:
> 
> ! 
> ! I do have a memory mapping driver somewhere (for a pre 1.3 NetBSD
> ! because some COMPAQ's seem to only bridge IO-addresses dicovered at
> ! boottime to ISA (and I had a ISA/PCMCIA card in that system).
> ! 
> ! I'm using one to get the pictures of my digital camera into the
> ! machine.

I'm still using it now on a Toshiba Libretto (don't have to fight that 
stupid COMPAQ junk).

NetBSD billy 1.3G NetBSD 1.3G (VIPI) #57: Mon Aug 31 19:45:19 CEST 1998     \
    grefen@billy:/homes/grefen/work/vino/sys/arch/i386/compile/VIPI i386
(billy is the name of a AI-computer in David Feintuchs 'Prisoners hope',
 there is no partition on that disk which would make Bill happy, 
 nor are the pictures for the other Bill:-)) )

> 
> I patched my wdc_pcmcia.c, but as the machine doesn't get that far
> when the CF card is plugged in, I don't know if the patch would work
> for me.  I'm trying to use the CF cards on a ThinkPad 310E.

I'll append my patches, they work on my Libretto, and I include the 
diffs against -current.

( option PCMCIA_VERBOSE)
dmesg 


NetBSD 1.3G (VIPI) #57: Mon Aug 31 19:45:19 CEST 1998
    grefen@billy:/homes/grefen/work/vino/sys/arch/i386/compile/VIPI
cpu0: family 5 model 2 step c
cpu0: Intel Pentium (P54C) (586-class)
real mem  = 33292288
avail mem = 26636288
using 432 buffers containing 1769472 bytes of memory
mainbus0 (root)
isa0 at mainbus0
com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
com1 at isa0 port 0x2f8-0x2ff irq 3: ns16550a, working fifo
lpt0 at isa0 port 0x378-0x37b irq 7
wdc0 at isa0 port 0x1f0-0x1f7 irq 14
wd0 at wdc0 drive 0: <IBM-DYKA-23240>
wd0: using 16-sector 16-bit pio transfers, lba mode
wd0 3102MB, 6304 cyl, 16 head, 63 sec, 512 bytes/sect x 6354432 sectors
sb0 at isa0 port 0x220-0x237 irq 5 drq 0: dsp v3.01
audio0 at sb0
midi0 at sb0: <SB MIDI UART>
pcppi0 at isa0 port 0x61
sysbeep0 at pcppi0
isapnp0 at isa0 port 0x279: ISA Plug 'n Play device support
npx0 at isa0 port 0xf0-0xff: using exception 16
vt0 at isa0 port 0x60-0x6f irq 1
vt0: generic, 80 col, color, 8 scr, mf2-kbd, [R3.32]
pms0 at vt0 irq 12
vt0: console
pcic0 at isa0 port 0x3e0-0x3e1 iomem 0xd0000-0xd3fff irq 11
pcic0: controller 0 (Intel 82365SL Revision 1) has sockets A and B
pcmcia0 at pcic0 controller 0 socket 0
pcmcia0: CIS version 2.0 or 2.01
pcmcia0: CIS info: SunDisk, SDP, 5/3 0.6
pcmcia0: Manufacturer code 0x45, product 0x401
pcmcia0: function 0: fixed disk, ccr addr 200 mask f
pcmcia0: function 0, config table entry 0: memory card; irq mask 0; memspace 0-7ff0; maxtwins 1; powerdown
pcmcia0: function 0, config table entry 1: I/O card; irq mask ffff; iomask 4, iospace 0-f; memspace 0-7ff0; maxtwins 1; powerdown
pcmcia0: function 0, config table entry 2: I/O card; irq mask 4000; iomask a, iospace 1f0-1f7 3f6-3f7; memspace 0-7ff0; maxtwins 1; powerdown
pcmcia0: function 0, config table entry 3: I/O card; irq mask 4000; iomask a, iospace 170-177 376-377; memspace 0-7ff0; maxtwins 1; powerdown
pcmcia0: function 0, config table entry 7: I/O card; irq mask 4000; iomask a, iospace 170-177 376-377; memspace 0-7ff0; maxtwins 1; powerdown
wdc matched
wdc1 at pcmcia0 function 0 port 0x170-0x177 port 0x376-0x377
pcmcia0: card irq 15
wd1 at wdc1 drive 0: <SunDisk SDCFB-15>
wd1: using 1-sector 16-bit pio transfers, lba mode
wd1 14MB, 458 cyl, 2 head, 32 sec, 512 bytes/sect x 29312 sectors
wd2 at wdc1 drive 1: <SunDisk SDCFB-15>
wd2: using 1-sector 16-bit pio transfers, lba mode
wd2 14MB, 458 cyl, 2 head, 32 sec, 512 bytes/sect x 29312 sectors
pcmcia1 at pcic0 controller 0 socket 1
isapnp0: no ISA Plug 'n Play devices found
apm0 at mainbus0: Power Management spec V1.1
apm0: battery life expectancy: 100%
apm0: A/C state: on
apm0: battery charge state: high
biomask c000 netmask c000 ttymask d882

====

*** /usr/sup/src/sys/dev/pcmcia/wdc_pcmcia.c	Sat Aug 15 13:13:35 1998
--- pcmcia/wdc_pcmcia.c	Mon Aug 17 17:17:05 1998
***************
*** 1,11 ****
! /*	$NetBSD: wdc_pcmcia.c,v 1.8 1998/08/15 10:10:55 mycroft Exp $ */
  
! /*-
!  * Copyright (c) 1998 The NetBSD Foundation, Inc.
!  * All rights reserved.
   *
!  * This code is derived from software contributed to The NetBSD Foundation
!  * by Charles M. Hannum, by Onno van der Linden and by Manuel Bouyer.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
--- 1,12 ----
! /*	$NetBSD: wdc_pcmcia.c,v 1.7 1998/06/09 07:32:57 thorpej Exp $ */
  
! /*
!  * Copyright (c) 1994, 1995 Charles M. Hannum.  All rights reserved.
   *
!  * DMA and multi-sector PIO handling are derived from code contributed by
!  * Onno van der Linden.
!  *
!  * Atapi support added by Manuel Bouyer.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
***************
*** 17,39 ****
   *    documentation and/or other materials provided with the distribution.
   * 3. All advertising materials mentioning features or use of this software
   *    must display the following acknowledgement:
!  *        This product includes software developed by the NetBSD
!  *        Foundation, Inc. and its contributors.
!  * 4. Neither the name of The NetBSD Foundation nor the names of its
!  *    contributors may be used to endorse or promote products derived
!  *    from this software without specific prior written permission.
   *
!  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
!  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
!  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
!  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
!  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
!  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
!  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
!  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
!  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
!  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
!  * POSSIBILITY OF SUCH DAMAGE.
   */
  
  #include <sys/param.h>
--- 18,37 ----
   *    documentation and/or other materials provided with the distribution.
   * 3. All advertising materials mentioning features or use of this software
   *    must display the following acknowledgement:
!  *	This product includes software developed by Charles M. Hannum.
!  * 4. The name of the author may not be used to endorse or promote products
!  *    derived from this software without specific prior written permission.
   *
!  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
!  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
!  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
!  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
!  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
!  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
!  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
!  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
!  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
!  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   */
  
  #include <sys/param.h>
***************
*** 90,102 ****
  	void *aux;
  {
  	struct pcmcia_attach_args *pa = aux;
! 
  	if (pa->card->manufacturer == 0x100 && pa->card->product == 0xd00) {
  		if (pa->card->cis1_info[1] != NULL &&
  		    strcmp(pa->card->cis1_info[1], "Digital Mobile Media CD-ROM") == 0)
  			return 1;
  	}
! 
  
  	return 0;
  }
--- 88,109 ----
  	void *aux;
  {
  	struct pcmcia_attach_args *pa = aux;
! 	struct pcmcia_function *pf;
! 		
! 	for (pf = pa->card->pf_head.sqh_first; pf != NULL;
! 	    pf = pf->pf_list.sqe_next) {
! 		if (pf->function == 4 ) {
! 			printf("wdc matched\n");
! 			return 1;
! 		}
! 	}
! #if 0
  	if (pa->card->manufacturer == 0x100 && pa->card->product == 0xd00) {
  		if (pa->card->cis1_info[1] != NULL &&
  		    strcmp(pa->card->cis1_info[1], "Digital Mobile Media CD-ROM") == 0)
  			return 1;
  	}
! #endif
  
  	return 0;
  }
***************
*** 113,118 ****
--- 120,128 ----
  
  	for (cfe = SIMPLEQ_FIRST(&pa->pf->cfe_head); cfe != NULL;
  	    cfe = SIMPLEQ_NEXT(cfe, cfe_list)) {
+ 		if (cfe->num_iospace ==0 ||  cfe->iospace[1].start == 0 ) {
+ 			continue;
+ 		}
  		if (pcmcia_io_alloc(pa->pf, cfe->iospace[0].start,
  		    cfe->iospace[0].length, 0, &sc->sc_pioh))
  			continue;
> 
>   -jm
> 

--
Stefan Grefen                                Tandem Computers Europe Inc.
grefen@hprc.tandem.com                       High Performance Research Center
 --- Hacking's just another word for nothing left to kludge. ---