Subject: CardBus on Libretto L2
To: None <tech-kern@netbsd.org>
From: Curt Sampson <cjs@cynic.net>
List: tech-kern
Date: 08/13/2001 22:34:23
There was a Linux kernel patch which someone claimed made the CardBus on
his Libretto L1 work for him; all it did was force the interrupt to 6.
I did the same in dev/pci/pccbb.c (diff appended to this message) and
it appears to configure now:

cbb0 at pci0 dev 18 function 0: Toshiba ToPIC100 CardBus-PCI Bridge (rev. 0x32) (chipflags 2)
cbb0: socket base address 0x7001000
cbb0: Forcing interrupt to 6.
cbb0: intrpin A, intrtag 6
...
CardBus latency timer 0x20 (10100)
PCI latency timer 0x40 (824000)
pccbb_power: CARDBUS_VCC_0V and CARDBUS_VPP_0V [44]
cbb0: bad Vcc request. sock_ctrl 0xffffff88, sock_status 0xffffffff
pccbb_power: CARDBUS_VCC_0V and CARDBUS_VPP_0V [44]
cbb0: interrupting at irq 6
cardslot0 at cbb0 slot 0 flags 0
cardslot0 attaching CardBus bus...
cardbus0 at cardslot0: bus 1 device 0 cacheline 0x0, lattimer 0x0
cardslotattach: found cardbus on cardslot0
cardbusmatch: busname differs pcmcia <=> cardbus
pcmcia0 at cardslot0
cardslotattach: found 16-bit pcmcia bus
pccbb_pcmcia_card_detect
pccbbattach: found cardslot

But it doesn't detect a card when I've inserted one, or even if I boot
with one in. (I'm not really sure what's supposed to happen on insertion,
if anything, as I've never used CardBus under NetBSD before.)

Thoughts, anyone?

cjs
-- 
Curt Sampson <cjs@cynic.net>  +81 3 5778 0123   de gustibus, aut bene aut nihil
	    "The chain which can be yanked is not the eternal chain."
			    -- G. Fitch

Index: pccbb.c
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/pci/pccbb.c,v
retrieving revision 1.65
diff -u -r1.65 pccbb.c
--- pccbb.c     2001/07/06 18:06:59     1.65
+++ pccbb.c     2001/08/13 13:27:43
@@ -489,9 +489,26 @@
         * not kill pcic-compatible port.
         */
        if ((0 == pa->pa_intrline) || (255 == pa->pa_intrline)) {
-               printf("%s: NOT USED because of unconfigured interrupt\n",
-                   sc->sc_dev.dv_xname);
-               return;
+               int id, wanted_id, intr;
+               id = pci_conf_read(pc, pa->pa_tag, PCI_ID_REG);
+               /* 0x11790617 */
+               wanted_id = PCI_ID_CODE(PCI_VENDOR_TOSHIBA2,
+                   PCI_PRODUCT_TOSHIBA2_ToPIC100);
+               if (id != wanted_id) {
+                   printf("%s: NOT USED because of unconfigured interrupt\n",
+                       sc->sc_dev.dv_xname);
+                   return;
+               } else {
+                   /* XXX cjs's ugly hack, no kidding! */
+                   printf("%s: Forcing interrupt to 6.\n",
+                       sc->sc_dev.dv_xname);
+                   intr = pci_conf_read(pc, pa->pa_tag, PCI_INTERRUPT_REG);
+                   intr &= ~(PCI_INTERRUPT_LINE_MASK
+                       << PCI_INTERRUPT_LINE_SHIFT);
+                   intr |= (6 << PCI_INTERRUPT_LINE_SHIFT);
+                   pci_conf_write(pc, pa->pa_tag, PCI_INTERRUPT_REG, intr);
+                   pa->pa_intrline = 6;
+               }
        }

        /*