diff options
Diffstat (limited to 'sys/dev/cardbus')
-rw-r--r-- | sys/dev/cardbus/com_cardbus.c | 184 |
1 files changed, 9 insertions, 175 deletions
diff --git a/sys/dev/cardbus/com_cardbus.c b/sys/dev/cardbus/com_cardbus.c index 0c9a7fdb3b9..0690e63492f 100644 --- a/sys/dev/cardbus/com_cardbus.c +++ b/sys/dev/cardbus/com_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com_cardbus.c,v 1.17 2005/07/25 01:38:15 pascoe Exp $ */ +/* $OpenBSD: com_cardbus.c,v 1.18 2005/09/26 22:32:06 miod Exp $ */ /* $NetBSD: com_cardbus.c,v 1.4 2000/04/17 09:21:59 joda Exp $ */ /* @@ -101,7 +101,6 @@ void com_cardbus_disable(struct com_softc *); struct csdev *com_cardbus_find_csdev(struct cardbus_attach_args *); int com_cardbus_gofigure(struct cardbus_attach_args *, struct com_cardbus_softc *); -void com_cardbus_attach2(struct com_softc *, u_char); #if NCOM_CARDBUS struct cfattach com_cardbus_ca = { @@ -276,9 +275,6 @@ com_cardbus_attach(struct device *parent, struct device *self, void *aux) sc->sc_iobase = csc->cc_addr; sc->sc_frequency = COM_FREQ; - timeout_set(&sc->sc_dtr_tmo, com_raisedtr, sc); - timeout_set(&sc->sc_diag_tmo, comdiag, sc); - sc->enable = com_cardbus_enable; sc->disable = com_cardbus_disable; sc->enabled = 0; @@ -292,7 +288,14 @@ com_cardbus_attach(struct device *parent, struct device *self, void *aux) if (com_cardbus_enable(sc)) printf(": function enable failed\n"); sc->enabled = 1; - com_cardbus_attach2(sc, csc->cc_bug); + + sc->sc_hwflags = 0; + sc->sc_swflags = 0; + + if (csc->cc_bug & BUG_BROADCOM) + sc->sc_fifolen = 15; + + com_attach_subr(sc); } void @@ -384,172 +387,3 @@ com_cardbus_detach(struct device *self, int flags) return (0); } - - -/* - * XXX This should be handled by a generic attach - */ -void -com_cardbus_attach2(struct com_softc *sc, u_char bug) -{ - bus_space_tag_t iot = sc->sc_iot; - bus_space_handle_t ioh = sc->sc_ioh; - u_int8_t lcr; - - sc->sc_hwflags = 0; - sc->sc_swflags = 0; - - /* - * Probe for all known forms of UART. - */ - lcr = bus_space_read_1(iot, ioh, com_lcr); - - bus_space_write_1(iot, ioh, com_lcr, LCR_EFR); - bus_space_write_1(iot, ioh, com_efr, 0); - bus_space_write_1(iot, ioh, com_lcr, 0); - - bus_space_write_1(iot, ioh, com_fifo, FIFO_ENABLE); - delay(100); - - switch(bus_space_read_1(iot, ioh, com_iir) >> 6) { - case 0: - sc->sc_uarttype = COM_UART_16450; - break; - case 2: - sc->sc_uarttype = COM_UART_16550; - break; - case 3: - sc->sc_uarttype = COM_UART_16550A; - break; - default: - sc->sc_uarttype = COM_UART_UNKNOWN; - break; - } - - if (sc->sc_uarttype == COM_UART_16550A) { /* Probe for ST16650s */ - bus_space_write_1(iot, ioh, com_lcr, lcr | LCR_DLAB); - if (bus_space_read_1(iot, ioh, com_efr) == 0) { - sc->sc_uarttype = COM_UART_ST16650; - } else { - bus_space_write_1(iot, ioh, com_lcr, LCR_EFR); - if (bus_space_read_1(iot, ioh, com_efr) == 0) - sc->sc_uarttype = COM_UART_ST16650V2; - } - } - - if (sc->sc_uarttype == COM_UART_16550A) { /* Probe for TI16750s */ - bus_space_write_1(iot, ioh, com_lcr, lcr | LCR_DLAB); - bus_space_write_1(iot, ioh, com_fifo, - FIFO_ENABLE | FIFO_ENABLE_64BYTE); - if ((bus_space_read_1(iot, ioh, com_iir) >> 5) == 7) { -#if 0 - bus_space_write_1(iot, ioh, com_lcr, 0); - if ((bus_space_read_1(iot, ioh, com_iir) >> 5) == 6) -#endif - sc->sc_uarttype = COM_UART_TI16750; - } - bus_space_write_1(iot, ioh, com_fifo, FIFO_ENABLE); - } - -#if NPCCOM > 0 -#ifdef i386 - if (sc->sc_uarttype == COM_UART_ST16650V2) { /* Probe for XR16850s */ - u_int8_t dlbl, dlbh; - - /* Enable latch access and get the current values. */ - bus_space_write_1(iot, ioh, com_lcr, lcr | LCR_DLAB); - dlbl = bus_space_read_1(iot, ioh, com_dlbl); - dlbh = bus_space_read_1(iot, ioh, com_dlbh); - - /* Zero out the latch divisors */ - bus_space_write_1(iot, ioh, com_dlbl, 0); - bus_space_write_1(iot, ioh, com_dlbh, 0); - - if (bus_space_read_1(iot, ioh, com_dlbh) == 0x10) { - sc->sc_uarttype = COM_UART_XR16850; - sc->sc_uartrev = bus_space_read_1(iot, ioh, com_dlbl); - } - - /* Reset to original. */ - bus_space_write_1(iot, ioh, com_dlbl, dlbl); - bus_space_write_1(iot, ioh, com_dlbh, dlbh); - } -#endif -#endif - - /* Reset the LCR (latch access is probably enabled). */ - bus_space_write_1(iot, ioh, com_lcr, lcr); - if (sc->sc_uarttype == COM_UART_16450) { /* Probe for 8250 */ - u_int8_t scr0, scr1, scr2; - - scr0 = bus_space_read_1(iot, ioh, com_scratch); - bus_space_write_1(iot, ioh, com_scratch, 0xa5); - scr1 = bus_space_read_1(iot, ioh, com_scratch); - bus_space_write_1(iot, ioh, com_scratch, 0x5a); - scr2 = bus_space_read_1(iot, ioh, com_scratch); - bus_space_write_1(iot, ioh, com_scratch, scr0); - - if ((scr1 != 0xa5) || (scr2 != 0x5a)) - sc->sc_uarttype = COM_UART_8250; - } - - /* - * Print UART type and initialize ourself. - */ - sc->sc_fifolen = 1; /* default */ - printf(" "); - switch (sc->sc_uarttype) { - case COM_UART_UNKNOWN: - printf("unknown uart\n"); - break; - case COM_UART_8250: - printf("ns8250, no fifo\n"); - break; - case COM_UART_16450: - printf("ns16450, no fifo\n"); - break; - case COM_UART_16550: - printf("ns16550, no working fifo\n"); - break; - case COM_UART_16550A: - if (bug & BUG_BROADCOM) { - printf("Broadcom ns16550a, 15 byte fifo\n"); - SET(sc->sc_hwflags, COM_HW_FIFO); - sc->sc_fifolen = 15; - break; - } - printf("ns16550a, 16 byte fifo\n"); - SET(sc->sc_hwflags, COM_HW_FIFO); - sc->sc_fifolen = 16; - break; - case COM_UART_ST16650: - printf("st16650, no working fifo\n"); - break; - case COM_UART_ST16650V2: - printf("st16650, 32 byte fifo\n"); - SET(sc->sc_hwflags, COM_HW_FIFO); - sc->sc_fifolen = 32; - break; - case COM_UART_TI16750: - printf("ti16750, 64 byte fifo\n"); - SET(sc->sc_hwflags, COM_HW_FIFO); - sc->sc_fifolen = 64; - break; -#if NPCCOM > 0 -#ifdef i386 - case COM_UART_XR16850: - printf("xr16850 (rev %d), 128 byte fifo\n", sc->sc_uartrev); - SET(sc->sc_hwflags, COM_HW_FIFO); - sc->sc_fifolen = 128; - break; -#endif -#endif - default: - panic("comattach: bad fifo type"); - } - - /* clear and disable fifo */ - bus_space_write_1(iot, ioh, com_fifo, FIFO_RCV_RST | FIFO_XMT_RST); - (void)bus_space_read_1(iot, ioh, com_data); - bus_space_write_1(iot, ioh, com_fifo, 0); -} |