diff -ur FreeBSD/src/sys/dev/exca/exca.c p4/newcard/src/sys/dev/exca/exca.c --- FreeBSD/src/sys/dev/exca/exca.c Thu Feb 13 23:21:18 2003 +++ p4/newcard/src/sys/dev/exca/exca.c Mon Apr 28 06:51:56 2003 @@ -56,11 +56,14 @@ #include #include +#include #include #include #include #include #include +#include +#include #include #include @@ -636,6 +639,9 @@ { uint8_t c; + /* Assume the worst */ + exca->chipset = EXCA_BOGUS; + /* * see if there's a PCMCIA controller here * Intel PCMCIA controllers use 0x82 and 0x83 @@ -757,6 +763,72 @@ err = 0; } return (err); +} + +void +exca_insert(struct exca_softc *exca) +{ + if (exca->pccarddev != NULL) { + if (CARD_ATTACH_CARD(exca->pccarddev) != 0) + device_printf(exca->dev, + "PC Card card activation failed\n"); + } else { + device_printf(exca->dev, + "PC Card inserted, but no pccard bus.\n"); + } +} + + +void +exca_removal(struct exca_softc *exca) +{ + if (exca->pccarddev != NULL) + CARD_DETACH_CARD(exca->pccarddev); +} + +int +exca_activate_resource(struct exca_softc *exca, device_t child, int type, + int rid, struct resource *res) +{ + int err; + if (!(rman_get_flags(res) & RF_ACTIVE)) { /* not already activated */ + switch (type) { + case SYS_RES_IOPORT: + err = exca_io_map(exca, 0, res); + break; + case SYS_RES_MEMORY: + err = exca_mem_map(exca, 0, res); + break; + default: + err = 0; + break; + } + if (err) + return (err); + + } + return (BUS_ACTIVATE_RESOURCE(device_get_parent(exca->dev), child, + type, rid, res)); +} + +int +exca_deactivate_resource(struct exca_softc *exca, device_t child, int type, + int rid, struct resource *res) +{ + if (rman_get_flags(res) & RF_ACTIVE) { /* if activated */ + switch (type) { + case SYS_RES_IOPORT: + if (exca_io_unmap_res(exca, res)) + return (ENOENT); + break; + case SYS_RES_MEMORY: + if (exca_mem_unmap_res(exca, res)) + return (ENOENT); + break; + } + } + return (BUS_DEACTIVATE_RESOURCE(device_get_parent(exca->dev), child, + type, rid, res)); } static int diff -ur FreeBSD/src/sys/dev/exca/excareg.h p4/newcard/src/sys/dev/exca/excareg.h --- FreeBSD/src/sys/dev/exca/excareg.h Thu Feb 13 23:21:18 2003 +++ p4/newcard/src/sys/dev/exca/excareg.h Sat May 24 20:58:04 2003 @@ -395,6 +395,13 @@ #define EXCA_RID_296 0x32 #define EXCA_RID_396 0xb2 +/* + * o2 micro specific registers + */ +#define EXCA_O2MICRO_CTRL_C 0x3a +#define EXCA_O2CC_IREQ_INTC 0x80 +#define EXCA_O2CC_STSCHG_INTC 0x20 + /* Plug and play */ #define EXCA_PNP_ACTIONTEC 0x1802A904 /* AEI0218 */ #define EXCA_PNP_IBM3765 0x65374d24 /* IBM3765 */ diff -ur FreeBSD/src/sys/dev/exca/excavar.h p4/newcard/src/sys/dev/exca/excavar.h --- FreeBSD/src/sys/dev/exca/excavar.h Thu Feb 13 23:21:18 2003 +++ p4/newcard/src/sys/dev/exca/excavar.h Mon Apr 28 06:51:56 2003 @@ -76,6 +76,9 @@ uint32_t flags; #define EXCA_SOCKET_PRESENT 0x00000001 #define EXCA_HAS_MEMREG_WIN 0x00000002 +#define EXCA_CARD_OK 0x00000004 +#define EXCA_KTHREAD_RUNNING 0x00000008 +#define EXCA_KTHREAD_DONE 0x00000010 uint32_t offset; int chipset; #define EXCA_CARDBUS 0 @@ -93,12 +96,18 @@ #define EXCA_RF5C396 12 /* Ricoh RF5C396 */ #define EXCA_IBM 13 /* IBM clone */ #define EXCA_IBM_KING 14 /* IBM KING PCMCIA Controller */ +#define EXCA_BOGUS -1 /* Invalid/not present/etc */ exca_getb_fn *getb; exca_putb_fn *putb; + struct proc *event_thread; + struct mtx mtx; + struct cv cv; + device_t pccarddev; }; void exca_init(struct exca_softc *sc, device_t dev, bus_space_tag_t, bus_space_handle_t, uint32_t); +void exca_insert(struct exca_softc *sc); int exca_io_map(struct exca_softc *sc, int width, struct resource *r); int exca_io_unmap_res(struct exca_softc *sc, struct resource *res); int exca_is_pcic(struct exca_softc *sc); @@ -110,7 +119,14 @@ int exca_mem_unmap_res(struct exca_softc *sc, struct resource *res); int exca_probe_slots(device_t dev, struct exca_softc *exca, bus_space_tag_t iot, bus_space_handle_t ioh); +void exca_removal(struct exca_softc *); void exca_reset(struct exca_softc *, device_t child); + +/* bus/device interfaces */ +int exca_activate_resource(struct exca_softc *exca, device_t child, int type, + int rid, struct resource *res); +int exca_deactivate_resource(struct exca_softc *exca, device_t child, int type, + int rid, struct resource *res); static __inline uint8_t exca_getb(struct exca_softc *sc, int reg) diff -ur FreeBSD/src/sys/dev/pccbb/pccbb.c p4/newcard/src/sys/dev/pccbb/pccbb.c --- FreeBSD/src/sys/dev/pccbb/pccbb.c Tue May 6 08:28:23 2003 +++ p4/newcard/src/sys/dev/pccbb/pccbb.c Sun May 25 15:46:23 2003 @@ -172,12 +172,12 @@ {PCIC_ID_CLPD6834, "CLPD6834 PCI-CardBus Bridge", CB_CIRRUS}, /* 02Micro */ - {PCIC_ID_OZ6832, "O2Micro OZ6832/6833 PCI-CardBus Bridge", CB_CIRRUS}, - {PCIC_ID_OZ6860, "O2Micro OZ6836/6860 PCI-CardBus Bridge", CB_CIRRUS}, - {PCIC_ID_OZ6872, "O2Micro OZ6812/6872 PCI-CardBus Bridge", CB_CIRRUS}, - {PCIC_ID_OZ6912, "O2Micro OZ6912/6972 PCI-CardBus Bridge", CB_CIRRUS}, - {PCIC_ID_OZ6922, "O2Micro OZ6922 PCI-CardBus Bridge", CB_CIRRUS}, - {PCIC_ID_OZ6933, "O2Micro OZ6933 PCI-CardBus Bridge", CB_CIRRUS}, + {PCIC_ID_OZ6832, "O2Micro OZ6832/6833 PCI-CardBus Bridge", CB_O2MICRO}, + {PCIC_ID_OZ6860, "O2Micro OZ6836/6860 PCI-CardBus Bridge", CB_O2MICRO}, + {PCIC_ID_OZ6872, "O2Micro OZ6812/6872 PCI-CardBus Bridge", CB_O2MICRO}, + {PCIC_ID_OZ6912, "O2Micro OZ6912/6972 PCI-CardBus Bridge", CB_O2MICRO}, + {PCIC_ID_OZ6922, "O2Micro OZ6922 PCI-CardBus Bridge", CB_O2MICRO}, + {PCIC_ID_OZ6933, "O2Micro OZ6933 PCI-CardBus Bridge", CB_O2MICRO}, /* sentinel */ {0 /* null id */, "unknown", CB_UNKNOWN}, @@ -403,6 +403,7 @@ cbb_chipinit(struct cbb_softc *sc) { uint32_t mux, sysctrl; + uint8_t reg; /* Set CardBus latency timer */ if (pci_read_config(sc->dev, PCIR_SECLAT_1, 1) < 0x20) @@ -487,6 +488,36 @@ */ pci_write_config(sc->dev, CBBR_MMCTRL, 0, 4); break; + case CB_O2MICRO: + /* + * Issue #1: INT# generated at the same time as + * selected ISA IRQ. When IREQ# or STSCHG# is active, + * in addition to the ISA IRQ being generated, INT# + * will also be generated at the same time. + * + * Some of our older controllers have an issue in + * which the slot's PCI INT# will be asserted whenever + * IREQ# or STSCGH# is asserted even if ExCA registers + * 03h or 05h have an ISA IRQ selected. + * + * The fix for this issue, which will work for any + * controller (old or new), is to set ExCA registers + * 3Ah (slot 0) & 7Ah (slot 1) bits 7:4 = 1010b. + * These bits are undocumented. By setting this + * register (of each slot) to '1010xxxxb' a routing of + * IREQ# to INTC# and STSCHG# to INTC# is selected. + * Since INTC# isn't connected there will be no + * unexpected PCI INT when IREQ# or STSCHG# is active. + * However, INTA# (slot 0) or INTB# (slot 1) will + * still be correctly generated if NO ISA IRQ is + * selected (ExCA regs 03h or 05h are cleared). + */ + reg = exca_getb(&sc->exca, EXCA_O2MICRO_CTRL_C); + reg = (reg & 0x0f) | + EXCA_O2CC_IREQ_INTC | EXCA_O2CC_STSCHG_INTC; + exca_putb(&sc->exca, EXCA_O2MICRO_CTRL_C, reg); + + break; case CB_TOPIC97: /* * Disable Zoom Video, ToPIC 97, 100. @@ -555,45 +586,6 @@ pci_write_config(sc->dev, CBBR_IOLIMIT1, 0, 4); } -static void -cbb_powerstate_d0(device_t dev) -{ - u_int32_t membase, irq; - - if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) { - /* Save important PCI config data. */ - membase = pci_read_config(dev, CBBR_SOCKBASE, 4); - irq = pci_read_config(dev, PCIR_INTLINE, 4); - - /* Reset the power state. */ - device_printf(dev, "chip is in D%d power mode " - "-- setting to D0\n", pci_get_powerstate(dev)); - - pci_set_powerstate(dev, PCI_POWERSTATE_D0); - - /* Restore PCI config data. */ - pci_write_config(dev, CBBR_SOCKBASE, membase, 4); - pci_write_config(dev, PCIR_INTLINE, irq, 4); - } -} - -/* - * Print out the config space - */ -static void -cbb_print_config(device_t dev) -{ - int i; - - device_printf(dev, "PCI Configuration space:"); - for (i = 0; i < 256; i += 4) { - if (i % 16 == 0) - printf("\n 0x%02x: ", i); - printf("0x%08x ", pci_read_config(dev, i, 4)); - } - printf("\n"); -} - static int cbb_attach(device_t brdev) { @@ -605,14 +597,12 @@ sc->chipset = cbb_chipset(pci_get_devid(brdev), NULL); sc->dev = brdev; sc->cbdev = NULL; - sc->pccarddev = NULL; + sc->exca.pccarddev = NULL; sc->secbus = pci_read_config(brdev, PCIR_SECBUS_2, 1); sc->subbus = pci_read_config(brdev, PCIR_SUBBUS_2, 1); SLIST_INIT(&sc->rl); STAILQ_INIT(&sc->intr_handlers); - cbb_powerstate_d0(brdev); - #ifndef BURN_THE_BOATS /* * The PCI bus code should assign us memory in the absense @@ -662,11 +652,8 @@ DEVPRINTF((brdev, "PCI Memory allocated: %08lx\n", rman_get_start(sc->base_res))); #endif - } else { - DEVPRINTF((brdev, "Found memory at %08lx\n", - rman_get_start(sc->base_res))); } - + sc->bst = rman_get_bustag(sc->base_res); sc->bsh = rman_get_bushandle(sc->base_res); exca_init(&sc->exca, brdev, sc->bst, sc->bsh, CBB_EXCA_OFFSET); @@ -683,12 +670,12 @@ sc->cbdev = NULL; } - sc->pccarddev = device_add_child(brdev, "pccard", -1); - if (sc->pccarddev == NULL) + sc->exca.pccarddev = device_add_child(brdev, "pccard", -1); + if (sc->exca.pccarddev == NULL) DEVPRINTF((brdev, "WARNING: cannot add pccard bus.\n")); - else if (device_probe_and_attach(sc->pccarddev) != 0) { + else if (device_probe_and_attach(sc->exca.pccarddev) != 0) { DEVPRINTF((brdev, "WARNING: cannot attach pccard bus.\n")); - sc->pccarddev = NULL; + sc->exca.pccarddev = NULL; } /* Map and establish the interrupt. */ @@ -711,7 +698,7 @@ exca_clrb(&sc->exca, EXCA_INTR, EXCA_INTR_RESET); /* turn off power */ - cbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); + cbb_power(brdev, CARD_OFF); /* CSC Interrupt: Card detect interrupt on */ cbb_setb(sc, CBB_SOCKET_MASK, CBB_SOCKET_MASK_CD); @@ -719,14 +706,11 @@ /* reset interrupt */ cbb_set(sc, CBB_SOCKET_EVENT, cbb_get(sc, CBB_SOCKET_EVENT)); - if (bootverbose) - cbb_print_config(brdev); - /* Start the thread */ if (kthread_create(cbb_event_thread, sc, &sc->event_thread, 0, 0, - "%s%d", device_get_name(brdev), device_get_unit(brdev))) { - device_printf(brdev, "unable to create event thread.\n"); - panic("cbb_create_event_thread"); + "%s%d", device_get_name(sc->dev), device_get_unit(sc->dev))) { + device_printf (sc->dev, "unable to create event thread.\n"); + panic ("cbb_create_event_thread"); } return (0); @@ -801,7 +785,7 @@ cbb_set(sc, CBB_SOCKET_MASK, 0); - cbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); + cbb_power(brdev, CARD_OFF); exca_putb(&sc->exca, EXCA_ADDRWIN_ENABLE, 0); pci_write_config(brdev, CBBR_MEMBASE0, 0, 4); @@ -892,7 +876,7 @@ { struct cbb_softc *sc = device_get_softc(brdev); - if (child != sc->cbdev && child != sc->pccarddev) + if (child != sc->cbdev && child != sc->exca.pccarddev) device_printf(brdev, "Unknown child detached: %s\n", device_get_nameunit(child)); } @@ -966,16 +950,9 @@ sockevent, sockstate)); if (sockstate & CBB_SOCKET_STAT_16BIT) { - if (sc->pccarddev != NULL) { - sc->flags |= CBB_16BIT_CARD; - sc->flags |= CBB_CARD_OK; - if (CARD_ATTACH_CARD(sc->pccarddev) != 0) - device_printf(sc->dev, - "PC Card card activation failed\n"); - } else { - device_printf(sc->dev, - "PC Card inserted, but no pccard bus.\n"); - } + if (sc->exca.pccarddev) + sc->flags |= CBB_16BIT_CARD | CBB_CARD_OK; + exca_insert(&sc->exca); } else if (sockstate & CBB_SOCKET_STAT_CB) { if (sc->cbdev != NULL) { sc->flags &= ~CBB_16BIT_CARD; @@ -1000,8 +977,7 @@ cbb_removal(struct cbb_softc *sc) { if (sc->flags & CBB_16BIT_CARD) { - if (sc->pccarddev != NULL) - CARD_DETACH_CARD(sc->pccarddev); + exca_removal(&sc->exca); } else { if (sc->cbdev != NULL) CARD_DETACH_CARD(sc->cbdev); @@ -1089,6 +1065,53 @@ return (vol); } +static uint8_t +cbb_o2micro_power_hack(struct cbb_softc *sc) +{ + uint8_t reg; + + /* + * Issue #2: INT# not qualified with IRQ Routing Bit. An + * unexpected PCI INT# may be generated during PC-Card + * initialization even with the IRQ Routing Bit Set with some + * PC-Cards. + * + * This is a two part issue. The first part is that some of + * our older controllers have an issue in which the slot's PCI + * INT# is NOT qualified by the IRQ routing bit (PCI reg. 3Eh + * bit 7). Regardless of the IRQ routing bit, if NO ISA IRQ + * is selected (ExCA register 03h bits 3:0, of the slot, are + * cleared) we will generate INT# if IREQ# is asserted. The + * second part is because some PC-Cards prematurally assert + * IREQ# before the ExCA registers are fully programmed. This + * in turn asserts INT# because ExCA register 03h bits 3:0 + * (ISA IRQ Select) are not yet programmed. + * + * The fix for this issue, which will work for any controller + * (old or new), is to set ExCA register 03h bits 3:0 = 0001b + * (select IRQ1), of the slot, before turning on slot power. + * Selecting IRQ1 will result in INT# NOT being asserted + * (because IRQ1 is selected), and IRQ1 won't be asserted + * because our controllers don't generate IRQ1. + */ + reg = exca_getb(&sc->exca, EXCA_INTR); + exca_putb(&sc->exca, EXCA_INTR, (reg & 0xf0) | 1); + return (reg); +} + +/* + * Restore the damage that cbb_o2micro_power_hack does to EXCA_INTR so + * we don't have an interrupt storm on power on. This has the efect of + * disabling card status change interrupts for the duration of poweron. + */ +static void +cbb_o2micro_power_hack2(struct cbb_softc *sc, uint8_t reg) +{ + exca_putb(&sc->exca, EXCA_INTR, reg); +} + + + static int cbb_power(device_t brdev, int volts) { @@ -1096,72 +1119,42 @@ struct cbb_softc *sc = device_get_softc(brdev); int timeout; uint32_t sockevent; - - DEVPRINTF((sc->dev, "cbb_power: %s and %s [%x]\n", - (volts & CARD_VCCMASK) == CARD_VCC_UC ? "CARD_VCC_UC" : - (volts & CARD_VCCMASK) == CARD_VCC_5V ? "CARD_VCC_5V" : - (volts & CARD_VCCMASK) == CARD_VCC_3V ? "CARD_VCC_3V" : - (volts & CARD_VCCMASK) == CARD_VCC_XV ? "CARD_VCC_XV" : - (volts & CARD_VCCMASK) == CARD_VCC_YV ? "CARD_VCC_YV" : - (volts & CARD_VCCMASK) == CARD_VCC_0V ? "CARD_VCC_0V" : - "VCC-UNKNOWN", - (volts & CARD_VPPMASK) == CARD_VPP_UC ? "CARD_VPP_UC" : - (volts & CARD_VPPMASK) == CARD_VPP_12V ? "CARD_VPP_12V" : - (volts & CARD_VPPMASK) == CARD_VPP_VCC ? "CARD_VPP_VCC" : - (volts & CARD_VPPMASK) == CARD_VPP_0V ? "CARD_VPP_0V" : - "VPP-UNKNOWN", - volts)); + uint8_t reg = 0; + int retval = 0; status = cbb_get(sc, CBB_SOCKET_STATE); sock_ctrl = cbb_get(sc, CBB_SOCKET_CONTROL); + sock_ctrl &= ~CBB_SOCKET_CTRL_VCCMASK; switch (volts & CARD_VCCMASK) { - case CARD_VCC_UC: + case 5: + sock_ctrl |= CBB_SOCKET_CTRL_VCC_5V; break; - case CARD_VCC_5V: - if (CBB_SOCKET_STAT_5VCARD & status) { /* check 5 V card */ - sock_ctrl &= ~CBB_SOCKET_CTRL_VCCMASK; - sock_ctrl |= CBB_SOCKET_CTRL_VCC_5V; - } else { - device_printf(sc->dev, - "BAD voltage request: no 5 V card\n"); - } + case 3: + sock_ctrl |= CBB_SOCKET_CTRL_VCC_3V; break; - case CARD_VCC_3V: - if (CBB_SOCKET_STAT_3VCARD & status) { - sock_ctrl &= ~CBB_SOCKET_CTRL_VCCMASK; - sock_ctrl |= CBB_SOCKET_CTRL_VCC_3V; - } else { - device_printf(sc->dev, - "BAD voltage request: no 3.3 V card\n"); - } + case XV: + sock_ctrl |= CBB_SOCKET_CTRL_VCC_XV; break; - case CARD_VCC_0V: - sock_ctrl &= ~CBB_SOCKET_CTRL_VCCMASK; + case YV: + sock_ctrl |= CBB_SOCKET_CTRL_VCC_YV; + break; + case 0: break; default: return (0); /* power NEVER changed */ break; } - switch (volts & CARD_VPPMASK) { - case CARD_VPP_UC: - break; - case CARD_VPP_0V: - sock_ctrl &= ~CBB_SOCKET_CTRL_VPPMASK; - break; - case CARD_VPP_VCC: - sock_ctrl &= ~CBB_SOCKET_CTRL_VPPMASK; - sock_ctrl |= ((sock_ctrl >> 4) & 0x07); - break; - case CARD_VPP_12V: - sock_ctrl &= ~CBB_SOCKET_CTRL_VPPMASK; - sock_ctrl |= CBB_SOCKET_CTRL_VPP_12V; - break; - } + /* VPP == VCC */ + sock_ctrl &= ~CBB_SOCKET_CTRL_VPPMASK; + sock_ctrl |= ((sock_ctrl >> 4) & 0x07); if (cbb_get(sc, CBB_SOCKET_CONTROL) == sock_ctrl) return (1); /* no change necessary */ + DEVPRINTF((sc->dev, "cbb_power: %dV\n", volts)); + if (volts != 0 && sc->chipset == CB_O2MICRO) + reg = cbb_o2micro_power_hack(sc); cbb_set(sc, CBB_SOCKET_CONTROL, sock_ctrl); status = cbb_get(sc, CBB_SOCKET_STATE); @@ -1170,7 +1163,7 @@ * XXX This busy wait is bogus. We should wait for a power * interrupt and then whine if the status is bad. If we're * worried about the card not coming up, then we should also - * schedule a timeout which we can cacel in the power interrupt. + * schedule a timeout which we can cancel in the power interrupt. */ timeout = 20; do { @@ -1182,7 +1175,7 @@ cbb_set(sc, CBB_SOCKET_EVENT, sockevent); if (timeout < 0) { printf ("VCC supply failed.\n"); - return (0); + goto done; } /* XXX @@ -1197,23 +1190,15 @@ device_printf(sc->dev, "bad Vcc request. ctrl=0x%x, status=0x%x\n", sock_ctrl ,status); - printf("cbb_power: %s and %s [%x]\n", - (volts & CARD_VCCMASK) == CARD_VCC_UC ? "CARD_VCC_UC" : - (volts & CARD_VCCMASK) == CARD_VCC_5V ? "CARD_VCC_5V" : - (volts & CARD_VCCMASK) == CARD_VCC_3V ? "CARD_VCC_3V" : - (volts & CARD_VCCMASK) == CARD_VCC_XV ? "CARD_VCC_XV" : - (volts & CARD_VCCMASK) == CARD_VCC_YV ? "CARD_VCC_YV" : - (volts & CARD_VCCMASK) == CARD_VCC_0V ? "CARD_VCC_0V" : - "VCC-UNKNOWN", - (volts & CARD_VPPMASK) == CARD_VPP_UC ? "CARD_VPP_UC" : - (volts & CARD_VPPMASK) == CARD_VPP_12V ? "CARD_VPP_12V": - (volts & CARD_VPPMASK) == CARD_VPP_VCC ? "CARD_VPP_VCC": - (volts & CARD_VPPMASK) == CARD_VPP_0V ? "CARD_VPP_0V" : - "VPP-UNKNOWN", - volts); - return (0); + printf("cbb_power: %d\n", volts); + goto done; } - return (1); /* power changed correctly */ + + retval = 1; /* power changed correctly */ +done:; + if (volts != 0 && sc->chipset == CB_O2MICRO) + cbb_o2micro_power_hack2(sc, reg); + return retval; } /* @@ -1229,15 +1214,15 @@ /* Prefer lowest voltage supported */ voltage = cbb_detect_voltage(brdev); - cbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); + cbb_power(brdev, CARD_OFF); if (voltage & CARD_YV_CARD) - cbb_power(brdev, CARD_VCC_YV | CARD_VPP_VCC); + cbb_power(brdev, CARD_VCC(YV)); else if (voltage & CARD_XV_CARD) - cbb_power(brdev, CARD_VCC_XV | CARD_VPP_VCC); + cbb_power(brdev, CARD_VCC(XV)); else if (voltage & CARD_3V_CARD) - cbb_power(brdev, CARD_VCC_3V | CARD_VPP_VCC); + cbb_power(brdev, CARD_VCC(3)); else if (voltage & CARD_5V_CARD) - cbb_power(brdev, CARD_VCC_5V | CARD_VPP_VCC); + cbb_power(brdev, CARD_VCC(5)); else { device_printf(brdev, "Unknown card voltage\n"); return (ENXIO); @@ -1289,7 +1274,7 @@ static void cbb_cardbus_power_disable_socket(device_t brdev, device_t child) { - cbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); + cbb_power(brdev, CARD_OFF); cbb_cardbus_reset(brdev); } @@ -1575,7 +1560,7 @@ DELAY(2*1000); /* power down the socket */ - cbb_power(brdev, CARD_VCC_0V | CARD_VPP_0V); + cbb_power(brdev, CARD_OFF); exca_clrb(&sc->exca, EXCA_PWRCTL, EXCA_PWRCTL_OE); /* wait 300ms until power fails (Tpf). */ @@ -1606,30 +1591,13 @@ else cbb_cardbus_power_disable_socket(brdev, child); } + static int cbb_pcic_activate_resource(device_t brdev, device_t child, int type, int rid, struct resource *res) { - int err; struct cbb_softc *sc = device_get_softc(brdev); - if (!(rman_get_flags(res) & RF_ACTIVE)) { /* not already activated */ - switch (type) { - case SYS_RES_IOPORT: - err = exca_io_map(&sc->exca, 0, res); - break; - case SYS_RES_MEMORY: - err = exca_mem_map(&sc->exca, 0, res); - break; - default: - err = 0; - break; - } - if (err) - return (err); - - } - return (BUS_ACTIVATE_RESOURCE(device_get_parent(brdev), child, - type, rid, res)); + return (exca_activate_resource(&sc->exca, child, type, rid, res)); } static int @@ -1637,21 +1605,7 @@ int rid, struct resource *res) { struct cbb_softc *sc = device_get_softc(brdev); - - if (rman_get_flags(res) & RF_ACTIVE) { /* if activated */ - switch (type) { - case SYS_RES_IOPORT: - if (exca_io_unmap_res(&sc->exca, res)) - return (ENOENT); - break; - case SYS_RES_MEMORY: - if (exca_mem_unmap_res(&sc->exca, res)) - return (ENOENT); - break; - } - } - return (BUS_DEACTIVATE_RESOURCE(device_get_parent(brdev), child, - type, rid, res)); + return (exca_deactivate_resource(&sc->exca, child, type, rid, res)); } static struct resource * diff -ur FreeBSD/src/sys/dev/pccbb/pccbbvar.h p4/newcard/src/sys/dev/pccbb/pccbbvar.h --- FreeBSD/src/sys/dev/pccbb/pccbbvar.h Mon Oct 7 17:11:29 2002 +++ p4/newcard/src/sys/dev/pccbb/pccbbvar.h Sun May 25 15:46:23 2003 @@ -80,12 +80,11 @@ #define CB_CIRRUS 6 /* Cirrus Logic CLPD683x */ #define CB_TOPIC95 7 /* Toshiba ToPIC95 */ #define CB_TOPIC97 8 /* Toshiba ToPIC97/100 */ +#define CB_O2MICRO 9 /* O2Micro chips */ SLIST_HEAD(, cbb_reslist) rl; STAILQ_HEAD(, cbb_intrhand) intr_handlers; device_t cbdev; - device_t pccarddev; - struct proc *event_thread; }; @@ -97,15 +96,11 @@ #define CARD_YV_CARD 0x08 /* for power_socket */ -#define CARD_VCC_UC 0x0000 -#define CARD_VCC_3V 0x0001 -#define CARD_VCC_XV 0x0002 -#define CARD_VCC_YV 0x0003 -#define CARD_VCC_0V 0x0004 -#define CARD_VCC_5V 0x0005 -#define CARD_VCCMASK 0x000f -#define CARD_VPP_UC 0x0000 -#define CARD_VPP_VCC 0x0010 -#define CARD_VPP_12V 0x0030 -#define CARD_VPP_0V 0x0040 -#define CARD_VPPMASK 0x00f0 +#define CARD_VCC(X) (X) +#define CARD_VPP_VCC 0xf0 +#define CARD_VCCMASK 0xf +#define CARD_VCCSHIFT 0 +#define XV 2 +#define YV 1 + +#define CARD_OFF (CARD_VCC(0))