diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2000-12-10 11:12:08 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2000-12-10 11:12:08 +0000 |
commit | 4d7878d261f2fba8dd9d5e0c98a2168aad5943a8 (patch) | |
tree | 5752367e9025cb94da2e7304529417166133ad1a /sys/dev | |
parent | bc792b215ac2b057c916d0b8dd6913eb46768430 (diff) |
support newer cy cards; elektrosatan@voltagenoir.org, pr#1479
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/cy.c | 23 | ||||
-rw-r--r-- | sys/dev/ic/cyreg.h | 13 | ||||
-rw-r--r-- | sys/dev/pci/cy_pci.c | 20 |
3 files changed, 42 insertions, 14 deletions
diff --git a/sys/dev/ic/cy.c b/sys/dev/ic/cy.c index 6305b51c824..0ff584d4346 100644 --- a/sys/dev/ic/cy.c +++ b/sys/dev/ic/cy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cy.c,v 1.9 1999/11/30 23:54:07 aaron Exp $ */ +/* $OpenBSD: cy.c,v 1.10 2000/12/10 11:12:00 deraadt Exp $ */ /* * cy.c @@ -75,7 +75,7 @@ void cy_poll __P((void *)); int cy_modem_control __P((struct cy_port *, int, int)); void cy_enable_transmitter __P((struct cy_port *)); void cd1400_channel_cmd __P((struct cy_port *, int)); -int cy_speed __P((speed_t, int *, int *)); +int cy_speed __P((speed_t, int *, int *, int)); struct cfdriver cy_cd = { NULL, "cy", DV_TTY @@ -202,7 +202,7 @@ cyattach(parent, self, aux) void *aux; { struct cy_softc *sc = (void *)self; - int card, port, cy_chip, num_chips, cdu, chip_offs; + int card, port, cy_chip, num_chips, cdu, chip_offs, cy_clock; card = sc->sc_dev.dv_unit; num_chips = cy_nr_cd1400s[card]; @@ -243,9 +243,15 @@ cyattach(parent, self, aux) /* configure port 0 as serial port (should already be after reset) */ cd_write_reg_sc(sc, cy_chip, CD1400_GCR, 0); + /* Set cy_clock depending on firmware version */ + if (cd_read_reg_sc(sc, cy_chip, CD1400_GFRCR) <= 0x46) + cy_clock = CY_CLOCK; + else + cy_clock = CY_CLOCK_60; + /* set up a receive timeout period (1ms) */ cd_write_reg_sc(sc, cy_chip, CD1400_PPR, - (CY_CLOCK / CD1400_PPR_PRESCALER / 1000) + 1); + (cy_clock / CD1400_PPR_PRESCALER / 1000) + 1); for(cdu = 0; cdu < CD1400_NO_OF_CHANNELS; cdu++) { sc->sc_ports[port].cy_port_num = port; @@ -253,6 +259,7 @@ cyattach(parent, self, aux) sc->sc_ports[port].cy_memh = sc->sc_memh; sc->sc_ports[port].cy_chip_offs = chip_offs; sc->sc_ports[port].cy_bustype = sc->sc_bustype; + sc->sc_ports[port].cy_clock = cy_clock; /* should we initialize anything else here? */ port++; @@ -752,10 +759,10 @@ cyparam(tp, t) printf("ispeed %d ospeed %d\n", t->c_ispeed, t->c_ospeed); #endif - if(t->c_ospeed != 0 && cy_speed(t->c_ospeed, &o_clk_opt, &obpr) < 0) + if(t->c_ospeed != 0 && cy_speed(t->c_ospeed, &o_clk_opt, &obpr, cy->cy_clock) < 0) return EINVAL; - if(t->c_ispeed != 0 && cy_speed(t->c_ispeed, &i_clk_opt, &ibpr) < 0) + if(t->c_ispeed != 0 && cy_speed(t->c_ispeed, &i_clk_opt, &ibpr, cy->cy_clock) < 0) return EINVAL; s = spltty(); @@ -1441,7 +1448,7 @@ cd1400_channel_cmd(cy, cmd) * with every speed value between 50 and 150000 bps. */ int -cy_speed(speed_t speed, int *cor, int *bpr) +cy_speed(speed_t speed, int *cor, int *bpr, int cy_clock) { int c, co, br; @@ -1449,7 +1456,7 @@ cy_speed(speed_t speed, int *cor, int *bpr) return -1; for(c = 0, co = 8; co <= 2048; co <<= 2, c++) { - br = (CY_CLOCK + (co * speed) / 2) / (co * speed); + br = (cy_clock + (co * speed) / 2) / (co * speed); if(br < 0x100) { *bpr = br; *cor = c; diff --git a/sys/dev/ic/cyreg.h b/sys/dev/ic/cyreg.h index da24575513e..3d6d43b2387 100644 --- a/sys/dev/ic/cyreg.h +++ b/sys/dev/ic/cyreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cyreg.h,v 1.2 1996/11/28 23:27:49 niklas Exp $ */ +/* $OpenBSD: cyreg.h,v 1.3 2000/12/10 11:12:01 deraadt Exp $ */ /* $FreeBSD: cyreg.h,v 1.1 1995/07/05 12:15:51 bde Exp $ */ /*- @@ -53,8 +53,16 @@ /* I/O location for enabling interrupts on PCI Cyclom cards */ #define CY_PCI_INTENA 0x68 +#define CY_PCI_INTENA_9050 0x4c -#define CY_CLOCK 25000000 /* baud rate clock */ +/* Cyclom-Y Custom Register for PLX ID (PCI only) */ +#define CY_PLX_VER 0x3400 /* PLX version */ +#define CY_PLX_9050 0x0b +#define CY_PLX_9060 0x0c +#define CY_PLX_9080 0x0d + +#define CY_CLOCK 25000000 /* baud rate clock */ +#define CY_CLOCK_60 60000000 /* baud rate clock for newer cd1400s */ /* * bustype is actually the shift count for the offset @@ -123,6 +131,7 @@ struct cy_port { 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; diff --git a/sys/dev/pci/cy_pci.c b/sys/dev/pci/cy_pci.c index 6a055b4ba8c..f174dbe2df5 100644 --- a/sys/dev/pci/cy_pci.c +++ b/sys/dev/pci/cy_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cy_pci.c,v 1.4 1997/08/12 18:33:25 niklas Exp $ */ +/* $OpenBSD: cy_pci.c,v 1.5 2000/12/10 11:12:07 deraadt Exp $ */ /* * cy.c @@ -83,6 +83,7 @@ cy_probe_pci(parent, match, aux) bus_addr_t iobase; bus_size_t iosize; int cacheable; + int plx_ver; if(!(PCI_VENDOR(pa->pa_id) == PCI_VENDOR_CYCLADES && (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CYCLADES_CYCLOMY_1 || @@ -133,9 +134,20 @@ cy_probe_pci(parent, match, aux) return 0; } - /* Enable PCI card interrupts */ - bus_space_write_2(iot, ioh, CY_PCI_INTENA, - bus_space_read_2(iot, ioh, CY_PCI_INTENA) | 0x900); + /* Get PLX version */ + plx_ver = bus_space_read_1(memt, memh, CY_PLX_VER) & 0x0f; + /* Enable PCI card interrupts */ + switch (plx_ver) { + case CY_PLX_9050: + bus_space_write_2(iot, ioh, CY_PCI_INTENA_9050, + bus_space_read_2(iot, ioh, CY_PCI_INTENA_9050) | 0x40); + break; + case CY_PLX_9060: + case CY_PLX_9080: + default: + bus_space_write_2(iot, ioh, CY_PCI_INTENA, + bus_space_read_2(iot, ioh, CY_PCI_INTENA) | 0x900); + } return 1; } |