NetBSD Problem Report #7175
Received: (qmail 22654 invoked from network); 17 Mar 1999 05:07:32 -0000
Message-Id: <199903170506.VAA26381@shell9.ba.best.com>
Date: Tue, 16 Mar 1999 21:06:21 -0800
From: C Kane <ckane@best.com>
To: gnats-bugs@gnats.netbsd.org
Subject: Support for new Cyclades serial ports
X-Send-Pr-Version: 3.95
>Number: 7175
>Category: kern
>Synopsis: Cyclades driver does not support new serial processor
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Mar 16 21:20:02 +0000 1999
>Closed-Date: Thu Sep 09 21:52:32 +0000 1999
>Last-Modified: Thu Sep 09 21:52:58 +0000 1999
>Originator: C Kane
>Release: NetBSD 1.3K Tue Mar 9 23:31:26
>Organization:
>Environment:
System: NetBSD ckane4 1.3K NetBSD 1.3K (ckane4) #13: Tue Mar 9 23:31:26 PST 1999 root@ckane4:/usr/netbsd-current/src/sys/arch/i386/compile/ckane4 i386
>Description:
Our Cyclades serial port driver (cy) supports only the older
serial controller; it does not support the newer "Risc II"-based
serial controller.
>How-To-Repeat:
Install a Cyclades PCI card with a new controller and notice
that the baud rate appears to be wrong (and un-fixable).
>Fix:
Install this patch developed with the assistance of Marcio Saito
from Cyclades.
FreeBSD and OpenBSD seem to already have support for the new
controller, but their drivers are sufficiently different from
ours that I am unable to reconcile the two. This patch should
work as-is, since I am using it now on a system with 128 serial
ports; but perhaps someone with more kernal-hacking knowledge
could attempt to merge the three BSD's drivers.
*** /usr/src/sys/dev/ic/cy.c.NetBSD Mon Mar 23 04:14:37 1998
--- /usr/src/sys/dev/ic/cy.c Wed Dec 23 00:55:19 1998
***************
*** 10,19 ****
*
* Supports both ISA and PCI Cyclom cards
*
- * Uses CD1400 automatic CTS flow control, and
- * if CY_HW_RTS is defined, uses CD1400 automatic input flow control.
- * This requires a special cable that exchanges the RTS and DTR lines.
- *
* Lots of debug output can be enabled by defining CY_DEBUG
* Some debugging counters (number of receive/transmit interrupts etc.)
* can be enabled by defining CY_DEBUG1
--- 10,15 ----
***************
*** 52,58 ****
struct cy_port *, int, int));
static void cy_enable_transmitter __P((struct cy_softc *, struct cy_port *));
static void cd1400_channel_cmd __P((struct cy_softc *, struct cy_port *, int));
! static int cy_speed __P((speed_t, int *, int *));
extern struct cfdriver cy_cd;
--- 48,54 ----
struct cy_port *, int, int));
static void cy_enable_transmitter __P((struct cy_softc *, struct cy_port *));
static void cd1400_channel_cmd __P((struct cy_softc *, struct cy_port *, int));
! static int cy_speed __P((speed_t, int *, int *, int));
extern struct cfdriver cy_cd;
***************
*** 168,173 ****
--- 164,170 ----
{
int port, cy_chip, num_chips, cdu, chip;
struct cy_softc *sc = (void *) self;
+ int cy_clock;
num_chips = sc->sc_nchips;
if (num_chips == 0)
***************
*** 193,205 ****
*/
cd_write_reg(sc, cy_chip, CD1400_GCR, 0);
/* set up a receive timeout period (1ms) */
cd_write_reg(sc, cy_chip, CD1400_PPR,
! (CY_CLOCK / CD1400_PPR_PRESCALER / 1000) + 1);
for (cdu = 0; cdu < CD1400_NO_OF_CHANNELS; cdu++) {
sc->sc_ports[port].cy_port_num = port;
sc->sc_ports[port].cy_chip = cy_chip;
/* should we initialize anything else here? */
port++;
--- 190,208 ----
*/
cd_write_reg(sc, cy_chip, CD1400_GCR, 0);
+ if (cd_read_reg(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, cy_chip, CD1400_PPR,
! (cy_clock / CD1400_PPR_PRESCALER / 1000) + 1);
for (cdu = 0; cdu < CD1400_NO_OF_CHANNELS; cdu++) {
sc->sc_ports[port].cy_port_num = port;
sc->sc_ports[port].cy_chip = cy_chip;
+ sc->sc_ports[port].cy_clock = cy_clock;
/* should we initialize anything else here? */
port++;
***************
*** 650,659 ****
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)
return EINVAL;
! if (t->c_ispeed != 0 && cy_speed(t->c_ispeed, &i_clk_opt, &ibpr) < 0)
return EINVAL;
s = spltty();
--- 653,662 ----
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, cy->cy_clock) < 0)
return EINVAL;
! if (t->c_ispeed != 0 && cy_speed(t->c_ispeed, &i_clk_opt, &ibpr, cy->cy_clock) < 0)
return EINVAL;
s = spltty();
***************
*** 742,756 ****
* set modem change option registers to generate interrupts
* on carrier detect changes.
*
! * if hardware RTS handshaking is used (CY_HW_RTS, DTR and RTS lines
! * exchanged), also set the handshaking threshold.
*/
! #ifdef CY_HW_RTS
! cd_write_reg(sc, cy->cy_chip, CD1400_MCOR1, CD1400_MCOR1_CDzd |
! (ISSET(t->c_cflag, CRTSCTS) ? RX_DTR_THRESHOLD : 0));
! #else
! cd_write_reg(sc, cy->cy_chip, CD1400_MCOR1, CD1400_MCOR1_CDzd);
! #endif /* CY_HW_RTS */
cd_write_reg(sc, cy->cy_chip, CD1400_MCOR2, CD1400_MCOR2_CDod);
--- 745,759 ----
* set modem change option registers to generate interrupts
* on carrier detect changes.
*
! * if hardware RTS handshaking is used
! * also set the handshaking threshold.
*/
! if (cy->cy_clock == CY_CLOCK_60) {
! cd_write_reg(sc, cy->cy_chip, CD1400_MCOR1, CD1400_MCOR1_CDzd |
! (ISSET(t->c_cflag, CRTSCTS) ? CY_RX_DTR_THRESHOLD : 0));
! } else {
! cd_write_reg(sc, cy->cy_chip, CD1400_MCOR1, CD1400_MCOR1_CDzd);
! }
cd_write_reg(sc, cy->cy_chip, CD1400_MCOR2, CD1400_MCOR2_CDod);
***************
*** 775,782 ****
*
* bits can be: TIOCM_DTR, TIOCM_RTS, TIOCM_CTS, TIOCM_CD, TIOCM_RI, TIOCM_DSR
*
- * RTS and DTR are exchanged if CY_HW_RTS is set
- *
*/
static int
cy_modem_control(sc, cy, bits, howto)
--- 778,783 ----
***************
*** 802,820 ****
if (cy->cy_channel_control & CD1400_CCR_RCVEN)
bits |= TIOCM_LE;
msvr = cd_read_reg(sc, cy->cy_chip, CD1400_MSVR2);
! #ifdef CY_HW_RTS
! if (cd_read_reg(sc, cy->cy_chip, CD1400_MSVR1) &
! CD1400_MSVR1_RTS)
! bits |= TIOCM_DTR;
! if (msvr & CD1400_MSVR2_DTR)
! bits |= TIOCM_RTS;
! #else
! if (cd_read_reg(sc, cy->cy_chip, CD1400_MSVR1) &
! CD1400_MSVR1_RTS)
! bits |= TIOCM_RTS;
! if (msvr & CD1400_MSVR2_DTR)
! bits |= TIOCM_DTR;
! #endif /* CY_HW_RTS */
if (msvr & CD1400_MSVR2_CTS)
bits |= TIOCM_CTS;
if (msvr & CD1400_MSVR2_CD)
--- 803,821 ----
if (cy->cy_channel_control & CD1400_CCR_RCVEN)
bits |= TIOCM_LE;
msvr = cd_read_reg(sc, cy->cy_chip, CD1400_MSVR2);
! if (cy->cy_clock == CY_CLOCK_60) {
! if (cd_read_reg(sc, cy->cy_chip, CD1400_MSVR1) &
! CD1400_MSVR1_RTS)
! bits |= TIOCM_DTR;
! if (msvr & CD1400_MSVR2_DTR)
! bits |= TIOCM_RTS;
! } else {
! if (cd_read_reg(sc, cy->cy_chip, CD1400_MSVR1) &
! CD1400_MSVR1_RTS)
! bits |= TIOCM_RTS;
! if (msvr & CD1400_MSVR2_DTR)
! bits |= TIOCM_DTR;
! }
if (msvr & CD1400_MSVR2_CTS)
bits |= TIOCM_CTS;
if (msvr & CD1400_MSVR2_CD)
***************
*** 829,879 ****
return bits;
case DMSET: /* replace old values with new ones */
! #ifdef CY_HW_RTS
! if (!ISSET(tp->>t_cflag, CRTSCTS))
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2,
! ((bits & TIOCM_RTS) ? CD1400_MSVR2_DTR : 0));
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1,
! ((bits & TIOCM_DTR) ? CD1400_MSVR1_RTS : 0));
! #else
! if (!ISSET(tp->t_cflag, CRTSCTS))
cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1,
! ((bits & TIOCM_RTS) ? CD1400_MSVR1_RTS : 0));
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2,
! ((bits & TIOCM_DTR) ? CD1400_MSVR2_DTR : 0));
! #endif /* CY_HW_RTS */
break;
case DMBIS: /* set bits */
! #ifdef CY_HW_RTS
! if (!ISSET(tp->t_cflag, CRTSCTS) && (bits & TIOCM_RTS) != 0)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2,
! CD1400_MSVR2_DTR);
! if (bits & TIOCM_DTR)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1,
! CD1400_MSVR1_RTS);
! #else
! if (!ISSET(tp->t_cflag, CRTSCTS) && (bits & TIOCM_RTS) != 0)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1,
! CD1400_MSVR1_RTS);
! if (bits & TIOCM_DTR)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2,
! CD1400_MSVR2_DTR);
! #endif /* CY_HW_RTS */
break;
case DMBIC: /* clear bits */
! #ifdef CY_HW_RTS
! if (!ISSET(tp->t_cflag, CRTSCTS) && (bits & TIOCM_RTS))
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2, 0);
! if (bits & TIOCM_DTR)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1, 0);
! #else
! if (!ISSET(tp->t_cflag, CRTSCTS) && (bits & TIOCM_RTS))
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1, 0);
! if (bits & TIOCM_DTR)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2, 0);
! #endif /* CY_HW_RTS */
break;
}
splx(s);
--- 830,880 ----
return bits;
case DMSET: /* replace old values with new ones */
! if (cy->cy_clock == CY_CLOCK_60) {
! if (!ISSET(tp->t_cflag, CRTSCTS))
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2,
! ((bits & TIOCM_RTS) ? CD1400_MSVR2_DTR : 0));
cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1,
! ((bits & TIOCM_DTR) ? CD1400_MSVR1_RTS : 0));
! } else {
! if (!ISSET(tp->t_cflag, CRTSCTS))
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1,
! ((bits & TIOCM_RTS) ? CD1400_MSVR1_RTS : 0));
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2,
! ((bits & TIOCM_DTR) ? CD1400_MSVR2_DTR : 0));
! }
break;
case DMBIS: /* set bits */
! if (cy->cy_clock == CY_CLOCK_60) {
! if (!ISSET(tp->t_cflag, CRTSCTS) && (bits & TIOCM_RTS) != 0)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2,
! CD1400_MSVR2_DTR);
! if (bits & TIOCM_DTR)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1,
! CD1400_MSVR1_RTS);
! } else {
! if (!ISSET(tp->t_cflag, CRTSCTS) && (bits & TIOCM_RTS) != 0)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1,
! CD1400_MSVR1_RTS);
! if (bits & TIOCM_DTR)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2,
! CD1400_MSVR2_DTR);
! }
break;
case DMBIC: /* clear bits */
! if (cy->cy_clock == CY_CLOCK_60) {
! if (!ISSET(tp->t_cflag, CRTSCTS) && (bits & TIOCM_RTS))
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2, 0);
! if (bits & TIOCM_DTR)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1, 0);
! } else {
! if (!ISSET(tp->t_cflag, CRTSCTS) && (bits & TIOCM_RTS))
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1, 0);
! if (bits & TIOCM_DTR)
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2, 0);
! }
break;
}
splx(s);
***************
*** 961,967 ****
#endif
}
- #ifndef CY_HW_RTS
/*
* If we don't have any received data in ibuf and
* CRTSCTS is on and RTS is turned off, it is time to
--- 962,967 ----
***************
*** 975,990 ****
cd_write_reg(sc, cy->cy_chip, CD1400_CAR,
port & CD1400_CAR_CHAN);
! if ((cd_read_reg(sc, cy->cy_chip,
CD1400_MSVR1) & CD1400_MSVR1_RTS) == 0) {
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1,
! CD1400_MSVR1_RTS);
#ifdef CY_DEBUG1
did_something = 1;
#endif
}
}
- #endif /* CY_HW_RTS */
/*
* handle carrier changes
--- 975,1000 ----
cd_write_reg(sc, cy->cy_chip, CD1400_CAR,
port & CD1400_CAR_CHAN);
! if (cy->cy_clock == CY_CLOCK_60) {
! if ((cd_read_reg(sc, cy->cy_chip,
! CD1400_MSVR2) & CD1400_MSVR2_DTR) == 0) {
! cd_write_reg(sc, cy->cy_chip,
! CD1400_MSVR2,CD1400_MSVR2_DTR);
! #ifdef CY_DEBUG1
! did_something = 1;
! #endif
! }
! } else {
! if ((cd_read_reg(sc, cy->cy_chip,
CD1400_MSVR1) & CD1400_MSVR1_RTS) == 0) {
! cd_write_reg(sc, cy->cy_chip,
! CD1400_MSVR1,CD1400_MSVR1_RTS);
#ifdef CY_DEBUG1
did_something = 1;
#endif
+ }
}
}
/*
* handle carrier changes
***************
*** 1153,1159 ****
cy->cy_ibuf_wr_ptr = buf_p;
- #ifndef CY_HW_RTS
/* RTS handshaking for incoming data */
if (ISSET(cy->cy_tty->t_cflag, CRTSCTS)) {
int bf;
--- 1163,1168 ----
***************
*** 1162,1178 ****
if (bf < 0)
bf += CY_IBUF_SIZE;
! if (bf > (CY_IBUF_SIZE / 2)) /* turn RTS off */
cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1, 0);
}
- #endif /* CY_HW_RTS */
end_rx_serv:
/* terminate service context */
cd_write_reg(sc, cy->cy_chip, CD1400_RIR, save_rir & 0x3f);
cd_write_reg(sc, cy->cy_chip, CD1400_CAR, save_car);
int_serviced = 1;
! } /* if(rx_service...) */
if (ISSET(stat, CD1400_SVRR_MDMCH)) {
u_char save_car, save_mir, serv_type, modem_stat;
--- 1171,1191 ----
if (bf < 0)
bf += CY_IBUF_SIZE;
! if (bf > (CY_IBUF_SIZE / 2)) { /* turn RTS off */
! if (cy->cy_clock == CY_CLOCK_60) {
! cd_write_reg(sc, cy->cy_chip, CD1400_MSVR2, 0);
! } else {
cd_write_reg(sc, cy->cy_chip, CD1400_MSVR1, 0);
+ }
+ }
}
end_rx_serv:
/* terminate service context */
cd_write_reg(sc, cy->cy_chip, CD1400_RIR, save_rir & 0x3f);
cd_write_reg(sc, cy->cy_chip, CD1400_CAR, save_car);
int_serviced = 1;
! } /* if (rx_service...) */
if (ISSET(stat, CD1400_SVRR_MDMCH)) {
u_char save_car, save_mir, serv_type, modem_stat;
***************
*** 1204,1210 ****
cd_write_reg(sc, cy->cy_chip, CD1400_MIR, save_mir & 0x3f);
cd_write_reg(sc, cy->cy_chip, CD1400_CAR, save_car);
int_serviced = 1;
! } /* if(modem_service...) */
if (ISSET(stat, CD1400_SVRR_TXRDY)) {
u_char save_car, save_tir, serv_type,
count, ch;
--- 1217,1223 ----
cd_write_reg(sc, cy->cy_chip, CD1400_MIR, save_mir & 0x3f);
cd_write_reg(sc, cy->cy_chip, CD1400_CAR, save_car);
int_serviced = 1;
! } /* if (modem_service...) */
if (ISSET(stat, CD1400_SVRR_TXRDY)) {
u_char save_car, save_tir, serv_type,
count, ch;
***************
*** 1306,1312 ****
cd_write_reg(sc, cy->cy_chip, CD1400_TIR, save_tir & 0x3f);
cd_write_reg(sc, cy->cy_chip, CD1400_CAR, save_car);
int_serviced = 1;
! } /* if(tx_service...) */
} /* for(...all CD1400s on a card) */
/* ensure an edge for next interrupt */
--- 1319,1325 ----
cd_write_reg(sc, cy->cy_chip, CD1400_TIR, save_tir & 0x3f);
cd_write_reg(sc, cy->cy_chip, CD1400_CAR, save_car);
int_serviced = 1;
! } /* if (tx_service...) */
} /* for(...all CD1400s on a card) */
/* ensure an edge for next interrupt */
***************
*** 1365,1373 ****
* with every speed value between 50 and 150000 bps.
*/
static int
! cy_speed(speed, cor, bpr)
speed_t speed;
! int *cor, *bpr;
{
int c, co, br;
--- 1378,1386 ----
* with every speed value between 50 and 150000 bps.
*/
static int
! cy_speed(speed, cor, bpr, cy_clock)
speed_t speed;
! int *cor, *bpr, cy_clock;
{
int c, co, br;
***************
*** 1375,1381 ****
return -1;
for (c = 0, co = 8; co <= 2048; co <<= 2, c++) {
! br = (CY_CLOCK + (co * speed) / 2) / (co * speed);
if (br < 0x100) {
*bpr = br;
*cor = c;
--- 1388,1394 ----
return -1;
for (c = 0, co = 8; co <= 2048; co <<= 2, c++) {
! br = (cy_clock + (co * speed) / 2) / (co * speed);
if (br < 0x100) {
*bpr = br;
*cor = c;
*** /usr/src/sys/dev/ic/cyreg.h.NetBSD Mon Oct 14 09:33:49 1996
--- /usr/src/sys/dev/ic/cyreg.h Wed Dec 23 00:54:20 1998
***************
*** 56,61 ****
--- 56,62 ----
#define CY_PCI_INTENA 0x68
#define CY_CLOCK 25000000 /* baud rate clock */
+ #define CY_CLOCK_60 60000000 /* new CD14000 */
#define CY_MEMSIZE 0x2000
*** /usr/src/sys/dev/ic/cyvar.h.NetBSD Tue Jun 17 04:54:35 1997
--- /usr/src/sys/dev/ic/cyvar.h Wed Dec 23 00:54:25 1998
***************
*** 58,63 ****
--- 58,64 ----
struct cy_port {
int cy_port_num;
int cy_chip;
+ int cy_clock;
struct tty *cy_tty;
int cy_openflags;
int cy_fifo_overruns;
>Release-Note:
>Audit-Trail:
From: Andreas Wrede <andreas@planix.com>
To: gnats-bugs@netbsd.org
Cc: netbsd-bugs@netbsd.org, C Kane <ckane@best.com>
Subject: Re: kern/7175: Support for new Cyclades serial ports
Date: Wed, 1 Sep 1999 23:58:59 -0400 (EDT)
I have a newer Cyclades 8Y cards which does not work with the stock cy
driver, in NetBSD-1.4.1/i386 - in fact it causes the system to freeze
when I tried to kill a process that had one of the cy ports open.
The board works great after applying the patch supplied with
kern/7175. If someone with an older version of the board can verify
that the patch does not break existing boards, I think it should be
committed.
- aew
State-Changed-From-To: open->closed
State-Changed-By: tron
State-Changed-When: Thu Sep 9 14:52:32 PDT 1999
State-Changed-Why:
Patches were committed, thanks.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.