Subject: PCMCIA on Compaq Elite 4/40
To: None <port-i386@NetBSD.ORG>
From: Johan Danielsson <joda@pdc.kth.se>
List: port-i386
Date: 12/19/1997 23:18:43
--Multipart_Fri_Dec_19_23:18:43_1997-1
Content-Type: text/plain; charset=US-ASCII


Some time ago (like last summer) I tried to get John Kohl's
PCMCIA-patches to work on a Compaq Elite 4/40. It turned out that
there were two problems with those patches. It found only one card
slot, and for some reason froze later on when probing the actual
cards.

With 1.3_BETA the freeze problem has gone away. The undetected slot is
still just that, though. After consulting some old notes of mine, and
looking at current Linux source, we have been able to get this to
work.  These patches are just an ugly hack, but might be of interest
to someone that is really knows something about this code (or perhaps
this has already been fixed in the improved code that Perry
mentioned).

Disclaimer: I don't know anything about PCMCIA.

/Johan


--Multipart_Fri_Dec_19_23:18:43_1997-1
Content-Type: text/plain; charset=US-ASCII

Index: i82365.c
===================================================================
RCS file: /afs/pdc.kth.se/home/j/joda/src/netbsd/CVSROOT/netbsd/src/sys/dev/ic/i82365.c,v
retrieving revision 1.1.1.1
diff -w -u -r1.1.1.1 i82365.c
--- i82365.c	1997/11/22 12:20:26	1.1.1.1
+++ i82365.c	1997/12/19 20:49:35
@@ -184,6 +184,7 @@
 
 	sc->handle[0].sc = sc;
 	sc->handle[0].sock = C0SA;
+	sc->handle[0].reg_offset = 0;
 	if (pcic_ident_ok(reg = pcic_read(&sc->handle[0], PCIC_IDENT))) {
 		sc->handle[0].flags = PCIC_FLAG_SOCKETP;
 		count++;
@@ -195,6 +196,11 @@
 
 	sc->handle[1].sc = sc;
 	sc->handle[1].sock = C0SB;
+#ifdef PCIC_VLSI_82C146_HACK
+	sc->handle[1].reg_offset = 4;
+#else
+	sc->handle[1].reg_offset = 0;
+#endif
 	if (pcic_ident_ok(reg = pcic_read(&sc->handle[1], PCIC_IDENT))) {
 		sc->handle[1].flags = PCIC_FLAG_SOCKETP;
 		count++;
@@ -206,6 +212,11 @@
 
 	sc->handle[2].sc = sc;
 	sc->handle[2].sock = C1SA;
+#ifdef PCIC_VLSI_82C146_HACK
+	sc->handle[2].reg_offset = 2;
+#else
+	sc->handle[2].reg_offset = 0;
+#endif
 	if (pcic_ident_ok(reg = pcic_read(&sc->handle[2], PCIC_IDENT))) {
 		sc->handle[2].flags = PCIC_FLAG_SOCKETP;
 		count++;
@@ -217,6 +228,11 @@
 
 	sc->handle[3].sc = sc;
 	sc->handle[3].sock = C1SB;
+#ifdef PCIC_VLSI_82C146_HACK
+	sc->handle[3].reg_offset = 6;
+#else
+	sc->handle[3].reg_offset = 0;
+#endif
 	if (pcic_ident_ok(reg = pcic_read(&sc->handle[3], PCIC_IDENT))) {
 		sc->handle[3].flags = PCIC_FLAG_SOCKETP;
 		count++;
@@ -404,6 +420,8 @@
 			return 0;
 
 		break;
+#ifndef PCIC_VLSI_82C146_HACK
+		/* XXX C0SA and C1SA has the same value */
 	case C1SA:
 		if (cf->cf_loc[PCICCF_CONTROLLER] !=
 		    PCICCF_CONTROLLER_DEFAULT &&
@@ -424,6 +442,7 @@
 			return 0;
 
 		break;
+#endif
 	default:
 		panic("unknown pcic socket");
 	}
@@ -450,12 +469,15 @@
 	case C0SB:
 		printf(" controller 0 socket 1");
 		break;
+#ifndef PCIC_VLSI_82C146_HACK
+		/* XXX C0SA and C1SA has the same value */
 	case C1SA:
 		printf(" controller 1 socket 0");
 		break;
 	case C1SB:
 		printf(" controller 1 socket 1");
 		break;
+#endif
 	default:
 		panic("unknown pcic socket");
 	}
Index: i82365var.h
===================================================================
RCS file: /afs/pdc.kth.se/home/j/joda/src/netbsd/CVSROOT/netbsd/src/sys/dev/ic/i82365var.h,v
retrieving revision 1.1.1.1
diff -w -u -r1.1.1.1 i82365var.h
--- i82365var.h	1997/11/22 12:20:25	1.1.1.1
+++ i82365var.h	1997/12/19 20:34:30
@@ -40,6 +40,7 @@
 	struct pcic_softc *sc;
 	int	vendor;
 	int	sock;
+	int	reg_offset;
 	int	flags;
 	int	memalloc;
 	struct {
@@ -150,9 +151,11 @@
 	int idx;
 {
 	if (idx != -1)
-		bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_INDEX,
+		bus_space_write_1(h->sc->iot, h->sc->ioh, 
+		    h->reg_offset + PCIC_REG_INDEX,
 		    h->sock + idx);
-	return (bus_space_read_1(h->sc->iot, h->sc->ioh, PCIC_REG_DATA));
+	return (bus_space_read_1(h->sc->iot, h->sc->ioh, 
+		    h->reg_offset + PCIC_REG_DATA));
 }
 
 static __inline void pcic_write __P((struct pcic_handle *, int, int));
@@ -163,9 +166,11 @@
 	int data;
 {
 	if (idx != -1)
-		bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_INDEX,
+		bus_space_write_1(h->sc->iot, h->sc->ioh, 
+		    h->reg_offset + PCIC_REG_INDEX,
 		    h->sock + idx);
-	bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_DATA, (data));
+	bus_space_write_1(h->sc->iot, h->sc->ioh, 
+                    h->reg_offset + PCIC_REG_DATA, (data));
 }
 
 static __inline void pcic_wait_ready __P((struct pcic_handle *));
Index: i82365reg.h
===================================================================
RCS file: /afs/pdc.kth.se/home/j/joda/src/netbsd/CVSROOT/netbsd/src/sys/dev/ic/i82365reg.h,v
retrieving revision 1.1.1.1
diff -w -u -r1.1.1.1 i82365reg.h
--- i82365reg.h	1997/11/22 12:20:25	1.1.1.1
+++ i82365reg.h	1997/12/19 20:33:14
@@ -35,7 +35,11 @@
  * 1993.
  */
 
+#ifdef PCIC_VLSI_82C146_HACK
+#define PCIC_IOSIZE		8
+#else
 #define	PCIC_IOSIZE		2
+#endif
 
 #define	PCIC_REG_INDEX		0
 #define	PCIC_REG_DATA		1
@@ -46,13 +50,23 @@
  * the same device.
  */
 
+#ifdef PCIC_VLSI_82C146_HACK
+#define PCIC_CHIP0_BASE		0x00
+#define PCIC_CHIP1_BASE		0x00 /* XXX this won't work, see i82365.c */
+#else
 #define	PCIC_CHIP0_BASE		0x00
 #define	PCIC_CHIP1_BASE		0x80
+#endif
 
 /* Each PCIC chip can drive two sockets */
 
+#ifdef PCIC_VLSI_82C146_HACK
+#define	PCIC_SOCKETA_INDEX	0x00
+#define	PCIC_SOCKETB_INDEX	0x80
+#else
 #define	PCIC_SOCKETA_INDEX	0x00
 #define	PCIC_SOCKETB_INDEX	0x40
+#endif
 
 /* general setup registers */
 

--Multipart_Fri_Dec_19_23:18:43_1997-1
Content-Type: text/plain; charset=US-ASCII

Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 1.3_BETA (HABA) #13: Fri Dec 19 21:50:26 CET 1997
    root@pezen.pdc.kth.se:/usr/src/haba/src/sys/arch/i386/compile/HABA
cpu0: family 4 model 3 step 5
cpu0: Intel 486DX2 (486-class)
real mem  = 12185600
avail mem = 9461760
using 174 buffers containing 712704 bytes of memory
mainbus0 (root)
isa0 at mainbus0
com0 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, working fifo
lptprobe: mask ff data 55 failed
lpt1 at isa0 port 0x278-0x27b: polled
lptprobe: mask ff data 55 failed
sea0: board type unknown at address 0xc8000
wdc0 at isa0 port 0x1f0-0x1f7 irq 14
wd0 at wdc0 drive 0: <QUANTUM DAYTONA514A>
wd0: 490MB, 996 cyl, 16 head, 63 sec, 512 bytes/sec
wd0: using 16-sector 16-bit pio transfers, lba addressing
npx0 at isa0 port 0xf0-0xff: using exception 16
pc0 at isa0 port 0x60-0x6f irq 1: color
spkr0 at pc0 port 0x61
pc0: console
fdc0 at isa0 port 0x3f0-0x3f7 irq 6 drq 2
fd0 at fdc0 drive 0: 1.44MB, 80 cyl, 2 head, 18 sec
pcic0 at isa0 port 0x3e0-0x3e7 iomem 0xd0000-0xd3fff: using irq 3
pcic0: controller 0 (Intel 82365SL Revision 1) has sockets A and B
pcmcia0 at pcic0 controller 0 socket 0
ne2 at pcmcia0 function 0 port 0x300-0x30f port 0x310-0x31f
ne2: Linksys EthernetCard Ethernet
ne2: Ethernet address 00:80:22:0b:9d:5d
pcmcia1 at pcic0 controller 0 socket 1
com3 at pcmcia1 function 0 port 0x2f8-0x2ff: ns16550a, working fifo
pcmcia1: card irq 5
biomask 4040 netmask 4040 ttymask 404a
boot device: wd0
root on wd0a dumps on wd0b
mountroot: trying ffs...
root file system type: ffs
init: copying out path `/sbin/init' 11
pcmcia0: card irq 7


--Multipart_Fri_Dec_19_23:18:43_1997-1--