Subject: Serial port fixes
To: None <port-mac68k@NetBSD.ORG>
From: Dr. Bill Studenmund <wrstuden@loki.stanford.edu>
List: port-mac68k
Date: 06/30/1998 10:45:09
Here's the current version of a fix to get rid of the crashes just after
zsc0 gets configured. Paul Goyette tested them, and got serial console to
work. He didn't get serial echo to work, but we're not sure if that's a
serial echo problem, or a his-kernel problem.
These changes are basically the ones I checked in (I updated the copyright
dates in the checked in version).
Let me know how it works! Unfortunatly I'm not able to compile kernels
right now - I'm in the middle of changing the driver to eventually support
NuBus serial cards. It's not compiling at the moment. :-(
Take care,
Bill
--- zs.c.orig Tue Jun 30 10:34:06 1998
+++ zs.c Tue Jun 30 11:02:27 1998
@@ -139,6 +139,9 @@
dev_t mac68k_zsdev;
/* Mac stuff */
volatile unsigned char *sccA = 0;
+int nzsc_attached = 0; /* needed as long as we have spurious
+ * interupt problems.
+ */
int zs_cn_check_speed __P((int bps));
@@ -289,6 +292,9 @@
cs->cs_reg_csr = &zc->zc_csr;
cs->cs_reg_data = &zc->zc_data;
+ if (channel == 0) /* Double check interupts are off */
+ zs_write_reg(cs, 9, 0);
+
bcopy(zs_init_reg, cs->cs_creg, 16);
bcopy(zs_init_reg, cs->cs_preg, 16);
@@ -405,6 +411,7 @@
zs_write_reg(cs, 2, zs_init_reg[2]);
/* master interrupt control (enable) */
zs_write_reg(cs, 9, zs_init_reg[9]);
+ nzsc_attached++;
splx(s);
}
@@ -467,7 +474,7 @@
int unit, rval;
rval = 0;
- for (unit = 0; unit < zsc_cd.cd_ndevs; unit++) {
+ for (unit = 0; unit < nzsc_attached; unit++) {
zsc = zsc_cd.cd_devs[unit];
if (zsc == NULL)
continue;
@@ -900,8 +907,10 @@
* signal sources, and it's not worth it for now
*/
- cs->cs_preg[9] &= ~ZSWR9_MASTER_IE;
- /* no interrupts until later, after attach. */
+ /*
+ * As zs_loadchannelregs doesn't touch reg 9 (interupt control),
+ * we won't accidentally turn on interupts below
+ */
s = splhigh();
zs_loadchannelregs(cs);
splx(s);
@@ -973,9 +982,13 @@
* Now turn off interrupts for the chip. Note: this code piece is the
* only vestage of the NetBSD 1.0 ser driver. :-)
*/
- sccA[2] = 9; sccA[2] = 0; /* write 0 to register 9, clearing MIE */
+ unit = sccA[2]; /* reset reg. access */
+ unit = sccA[0];
+ sccA[2] = 9; sccA[2] = 0; /* write 0 to reg. 9, clearing MIE */
+ sccA[2] = ZSWR0_CLR_INTR; unit = sccA[2]; /* reset any pending ints. */
+ sccA[0] = ZSWR0_CLR_INTR; unit = sccA[0];
- if (mac68k_machine.serial_boot_echo)
+ if (mac68k_machine.serial_boot_echo)
zscnsetup();
return;
}