diff options
author | smart <smart@cvs.openbsd.org> | 2001-08-20 04:41:40 +0000 |
---|---|---|
committer | smart <smart@cvs.openbsd.org> | 2001-08-20 04:41:40 +0000 |
commit | 7910f09fd6fad4008fe999de0d01ad855b2a386b (patch) | |
tree | a3462c05fb4bec6b268b856031520b8e7b820bff /sys/dev/ic | |
parent | d9bf3f8295bf4b2983561258d7e4e682174b9b27 (diff) |
Allow driver to recognize Cyclades 4Y and 8Y cards.
Not finished yet, but cleaned up and moved around code for
better organization. Inspired by NetBSD and other PCI drivers.
From my dmesg:
cy1 at pci0 dev 10 function 0 "Cyclades Cyclom-8Y" rev 0x01
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/cy.c | 61 | ||||
-rw-r--r-- | sys/dev/ic/cyreg.h | 75 |
2 files changed, 64 insertions, 72 deletions
diff --git a/sys/dev/ic/cy.c b/sys/dev/ic/cy.c index 1e4fcd14382..9117d0870ad 100644 --- a/sys/dev/ic/cy.c +++ b/sys/dev/ic/cy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cy.c,v 1.14 2001/08/19 19:58:56 smart Exp $ */ +/* $OpenBSD: cy.c,v 1.15 2001/08/20 04:41:39 smart Exp $ */ /* * cy.c @@ -22,9 +22,6 @@ * */ -#undef CY_DEBUG -#undef CY_DEBUG1 - /* NCY is the number of Cyclom cards in the machine */ #include "cy.h" #if NCY > 0 @@ -66,9 +63,9 @@ #define ISSET(t, f) ((t) & (f)) -void cyattach __P((struct device *, struct device *, void *)); +void cy_attach __P((struct device *, struct device *, void *)); int cy_probe_common __P((int, bus_space_tag_t, bus_space_handle_t, int)); -int cyintr __P((void *)); +int cy_intr __P((void *)); int cyparam __P((struct tty *, struct termios *)); void cystart __P((struct tty *)); void cy_poll __P((void *)); @@ -114,13 +111,13 @@ cy_probe_common(card, memt, memh, bustype) for (cy_chip = 0, chip_offs = 0; cy_chip < CY_MAX_CD1400s; - cy_chip++, chip_offs += (CY_CD1400_MEMSPACING<<bustype)) { + cy_chip++, chip_offs += (CY_CD1400_MEMSPACING << bustype)) { int i; /* the last 4 cd1400s are 'interleaved' with the first 4 on 32-port boards */ if (cy_chip == 4) - chip_offs -= (CY32_ADDR_FIX<<bustype); + chip_offs -= (CY32_ADDR_FIX << bustype); #ifdef CY_DEBUG printf("cy%d probe chip %d offset 0x%lx ... ", @@ -130,7 +127,7 @@ cy_probe_common(card, memt, memh, bustype) /* wait until the chip is ready for command */ DELAY(1000); if (bus_space_read_1(memt, memh, chip_offs + - ((CD1400_CCR<<1) << bustype)) != 0) { + ((CD1400_CCR << 1) << bustype)) != 0) { #ifdef CY_DEBUG printf("not ready for command\n"); #endif @@ -139,7 +136,7 @@ cy_probe_common(card, memt, memh, bustype) /* clear the firmware version reg. */ bus_space_write_1(memt, memh, chip_offs + - ((CD1400_GFRCR<<1) << bustype), 0); + ((CD1400_GFRCR << 1) << bustype), 0); /* * On Cyclom-16 references to non-existent chip 4 @@ -149,19 +146,19 @@ cy_probe_common(card, memt, memh, bustype) */ if (cy_chip == 4 && bus_space_read_1(memt, memh, chip_offs + - ((CD1400_GFRCR<<1) << bustype)) == 0) + ((CD1400_GFRCR << 1) << bustype)) == 0) break; /* reset the chip */ bus_space_write_1(memt, memh, chip_offs + - ((CD1400_CCR<<1) << bustype), + ((CD1400_CCR << 1) << bustype), CD1400_CCR_CMDRESET | CD1400_CCR_FULLRESET); /* wait for the chip to initialize itself */ for (i = 0; i < 200; i++) { DELAY(50); firmware_ver = bus_space_read_1(memt, memh, chip_offs + - ((CD1400_GFRCR<<1) << bustype)); + ((CD1400_GFRCR << 1) << bustype)); if ((firmware_ver & 0xf0) == 0x40) /* found a CD1400 */ break; } @@ -193,16 +190,13 @@ cy_probe_common(card, memt, memh, bustype) return (1); } -/* - * Attach (ISA/PCI) - */ void -cyattach(parent, self, aux) +cy_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct cy_softc *sc = (void *)self; int card, port, cy_chip, num_chips, cdu, chip_offs, cy_clock; + struct cy_softc *sc = (void *)self; card = sc->sc_dev.dv_unit; num_chips = cy_nr_cd1400s[card]; @@ -269,7 +263,9 @@ cyattach(parent, self, aux) } /* for(each CD1400 on a card... ) */ - printf(" (%d ports)\n", port); +#if CY_DEBUG + printf("cy: %d ports\n", port); +#endif /* ensure an edge for the next interrupt */ bus_space_write_1(sc->sc_memt, sc->sc_memh, @@ -282,33 +278,18 @@ cyattach(parent, self, aux) struct isa_attach_args *ia = aux; sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, - IST_EDGE, IPL_TTY, cyintr, sc, sc->sc_dev.dv_xname); + IST_EDGE, IPL_TTY, cy_intr, sc, sc->sc_dev.dv_xname); + + if (sc->sc_ih == NULL) + panic("cy: couldn't establish interrupt"); } break; #endif /* NCY_ISA > 0 */ -#if NCY_PCI > 0 case CY_BUSTYPE_PCI: - { - pci_intr_handle_t intrhandle; - struct pci_attach_args *pa = aux; - - if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin, - pa->pa_intrline, &intrhandle) != 0) - panic("cy: couldn't map PCI interrupt"); - - sc->sc_ih = pci_intr_establish(pa->pa_pc, intrhandle, - IPL_TTY, cyintr, sc, sc->sc_dev.dv_xname); - } - break; -#endif /* NCY_PCI > 0 */ + break; } - - if (sc->sc_ih == NULL) - panic("cy: couldn't establish interrupt"); } -#undef CY_DEBUG /*!!*/ - /* * open routine. returns zero if successfull, else error code */ @@ -1167,7 +1148,7 @@ out: * hardware interrupt routine */ int -cyintr(arg) +cy_intr(arg) void *arg; { struct cy_softc *sc = arg; diff --git a/sys/dev/ic/cyreg.h b/sys/dev/ic/cyreg.h index a364c8a8610..ea4c82b52d0 100644 --- a/sys/dev/ic/cyreg.h +++ b/sys/dev/ic/cyreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cyreg.h,v 1.5 2001/03/25 11:54:00 art Exp $ */ +/* $OpenBSD: cyreg.h,v 1.6 2001/08/20 04:41:39 smart Exp $ */ /* $FreeBSD: cyreg.h,v 1.1 1995/07/05 12:15:51 bde Exp $ */ /*- @@ -32,6 +32,9 @@ * SUCH DAMAGE. */ +#ifndef _DEV_IC_CYREG_H_ +#define _DEV_IC_CYREG_H_ + #include <sys/timeout.h> /* @@ -99,8 +102,8 @@ /* * read/write cd1400 registers (when cy_port-structure is available) */ -#define cd_read_reg(cy,reg) bus_space_read_1(cy->cy_memt, cy->cy_memh, \ - cy->cy_chip_offs+(((reg<<1))<<cy->cy_bustype)) +#define cd_read_reg(cy,reg) bus_space_read_1(cy->cy_memt, cy->cy_memh, \ + cy->cy_chip_offs+(((reg<<1))<<cy->cy_bustype)) #define cd_write_reg(cy,reg,val) bus_space_write_1(cy->cy_memt, cy->cy_memh, \ cy->cy_chip_offs+(((reg<<1))<<cy->cy_bustype), \ @@ -128,26 +131,28 @@ /* software state for one port */ struct cy_port { - int cy_port_num; - bus_space_tag_t cy_memt; - bus_space_handle_t cy_memh; - int cy_chip_offs; - int cy_bustype; - int cy_clock; - struct tty *cy_tty; - int cy_openflags; - int cy_fifo_overruns; - int cy_ibuf_overruns; - u_char cy_channel_control; /* last CCR channel control command bits */ - u_char cy_carrier_stat; /* copied from MSVR2 */ - u_char cy_flags; - u_char *cy_ibuf, *cy_ibuf_end; - u_char *cy_ibuf_rd_ptr, *cy_ibuf_wr_ptr; + int cy_port_num; + bus_space_tag_t cy_memt; + bus_space_handle_t cy_memh; + int cy_chip_offs; + int cy_bustype; + int cy_clock; + struct tty *cy_tty; + int cy_openflags; + int cy_fifo_overruns; + int cy_ibuf_overruns; + u_char cy_channel_control; /* last CCR channel + * control command + * bits */ + u_char cy_carrier_stat; /* copied from MSVR2 */ + u_char cy_flags; + u_char *cy_ibuf, *cy_ibuf_end; + u_char *cy_ibuf_rd_ptr, *cy_ibuf_wr_ptr; #ifdef CY_DEBUG1 - int cy_rx_int_count; - int cy_tx_int_count; - int cy_modem_int_count; - int cy_start_count; + int cy_rx_int_count; + int cy_tx_int_count; + int cy_modem_int_count; + int cy_start_count; #endif /* CY_DEBUG1 */ }; @@ -160,16 +165,22 @@ struct cy_port { /* software state for one card */ struct cy_softc { - struct device sc_dev; - void *sc_ih; - bus_space_tag_t sc_memt; - bus_space_handle_t sc_memh; - int sc_bustype; - int sc_nports; /* number of ports on this card */ - int sc_cd1400_offs[CY_MAX_CD1400s]; - struct cy_port sc_ports[CY_MAX_PORTS]; + struct device sc_dev; + void *sc_ih; + bus_space_tag_t sc_memt; + bus_space_handle_t sc_memh; + int sc_bustype; + int sc_nports; /* number of ports on this card */ + int sc_cd1400_offs[CY_MAX_CD1400s]; + struct cy_port sc_ports[CY_MAX_PORTS]; #ifdef CY_DEBUG1 - int sc_poll_count1; - int sc_poll_count2; + int sc_poll_count1; + int sc_poll_count2; #endif }; + +int cy_probe_common __P((int, bus_space_tag_t, bus_space_handle_t, int)); +void cy_attach __P((struct device *, struct device *, void *)); +int cy_intr __P((void *)); + +#endif /* _DEV_IC_CYREG_H_ */ |