Some (early) acpi machines leave the cardbus bridge unconfigured.  In
particular, those machines don't configure the bus number for the
cardbus bus.  This makes our driver skip attaching the 32-bit cardbus
handling and only support 16-bit pcmcia cards.

Diff below makes our driver assign an available bus number and
configure the bridge with it.  This makes cardbus work on a machine in
the class mentioned above.

ok?


Index: pccbb.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/pccbb.c,v
retrieving revision 1.94
diff -u -p -r1.94 pccbb.c
--- pccbb.c     19 Jul 2015 05:37:38 -0000      1.94
+++ pccbb.c     19 Jul 2015 23:59:24 -0000
@@ -372,6 +372,7 @@ pccbbattach(struct device *parent, struc
        pci_chipset_tag_t pc = pa->pa_pc;
        pci_intr_handle_t ih;
        const char *intrstr = NULL;
+       u_long busnum;
        int flags;
 
        pccbb_attach_hook(parent, self, pa);
@@ -447,8 +448,19 @@ pccbbattach(struct device *parent, struc
        printf(": %s", intrstr);
 
        /*
-        * When bus number isn't set correctly, give up using 32-bit CardBus
-        * mode.
+        * When the bus number isn't configured, try to allocate one
+        * ourselves.
+        */
+       if ((sc->sc_busnum & 0x00ffff00) == 0 && pa->pa_busex &&
+           extent_alloc(pa->pa_busex, 1, 1, 0, 0, EX_NOWAIT, &busnum) == 0) {
+               sc->sc_busnum |= (busnum << 8);
+               sc->sc_busnum |= (busnum << 16);
+               pci_conf_write(pc, pa->pa_tag, PCI_BUSNUM, sc->sc_busnum);
+       }
+
+       /*
+        * When the bus number still isn't set correctly, give up
+        * using 32-bit CardBus mode.
         */
        if (((sc->sc_busnum >> 8) & 0xff) == 0) {
                printf(", CardBus support disabled");

Reply via email to