summaryrefslogtreecommitdiffstats
path: root/sys/pc98/cbus/sio.c
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>1999-11-03 09:02:23 +0000
committernyan <nyan@FreeBSD.org>1999-11-03 09:02:23 +0000
commit95cb80cbf80629171a9ffe707620e68fcd634ee8 (patch)
treed12967911756161eb475dcdc30c5cb0fb0cb735c /sys/pc98/cbus/sio.c
parent8ffdd77380726d167c9b22ba6e565bb7b918f05e (diff)
downloadFreeBSD-src-95cb80cbf80629171a9ffe707620e68fcd634ee8.zip
FreeBSD-src-95cb80cbf80629171a9ffe707620e68fcd634ee8.tar.gz
Sync with sys/isa/sio.c revision from 1.269 to 1.273.
Diffstat (limited to 'sys/pc98/cbus/sio.c')
-rw-r--r--sys/pc98/cbus/sio.c210
1 files changed, 101 insertions, 109 deletions
diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c
index f66b740..a59d8dac 100644
--- a/sys/pc98/cbus/sio.c
+++ b/sys/pc98/cbus/sio.c
@@ -180,16 +180,14 @@
#include <i386/isa/ic/rsa.h>
#endif
-#if 0
#include "card.h"
#if NCARD > 0
+/* XXX should die XXX */
+#include <sys/select.h>
#include <sys/module.h>
#include <pccard/cardinfo.h>
#include <pccard/slot.h>
#endif
-#else
-#define NCARD 0
-#endif
#ifndef __i386__
#define disable_intr()
@@ -413,6 +411,7 @@ struct com_s {
static int espattach __P((struct com_s *com, Port_t esp_port));
#endif
static int sioattach __P((device_t dev));
+static int sio_isa_attach __P((device_t dev));
static timeout_t siobusycheck;
static timeout_t siodtrwakeup;
@@ -424,6 +423,7 @@ static int commctl __P((struct com_s *com, int bits, int how));
static int comparam __P((struct tty *tp, struct termios *t));
static swihand_t siopoll;
static int sioprobe __P((device_t dev));
+static int sio_isa_probe __P((device_t dev));
static void siosettimeout __P((void));
static int siosetwater __P((struct com_s *com, speed_t speed));
static void comstart __P((struct tty *tp));
@@ -432,6 +432,11 @@ static timeout_t comwakeup;
static void disc_optim __P((struct tty *tp, struct termios *t,
struct com_s *com));
+#if NCARD > 0
+static int sio_pccard_attach __P((device_t dev));
+static void sio_pccard_detach __P((device_t dev));
+static int sio_pccard_probe __P((device_t dev));
+#endif /* NCARD > 0 */
static char driver_name[] = "sio";
@@ -440,19 +445,36 @@ static devclass_t sio_devclass;
#define com_addr(unit) ((struct com_s *) \
devclass_get_softc(sio_devclass, unit))
-static device_method_t sio_methods[] = {
+static device_method_t sio_isa_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, sio_isa_probe),
+ DEVMETHOD(device_attach, sio_isa_attach),
+
+ { 0, 0 }
+};
+
+static driver_t sio_isa_driver = {
+ driver_name,
+ sio_isa_methods,
+ sizeof(struct com_s),
+};
+
+#if NCARD > 0
+static device_method_t sio_pccard_methods[] = {
/* Device interface */
- DEVMETHOD(device_probe, sioprobe),
- DEVMETHOD(device_attach, sioattach),
+ DEVMETHOD(device_probe, sio_pccard_probe),
+ DEVMETHOD(device_attach, sio_pccard_attach),
+ DEVMETHOD(device_detach, sio_pccard_detach),
{ 0, 0 }
};
-static driver_t sio_driver = {
+static driver_t sio_pccard_driver = {
driver_name,
- sio_methods,
+ sio_pccard_methods,
sizeof(struct com_s),
};
+#endif (NCARD > 0)
static d_open_t sioopen;
static d_close_t sioclose;
@@ -854,43 +876,22 @@ SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW,
0, 0, sysctl_machdep_comdefaultrate, "I", "");
#if NCARD > 0
-/*
- * PC-Card (PCMCIA) specific code.
- */
-static int sioinit __P((struct pccard_devinfo *));
-static void siounload __P((struct pccard_devinfo *));
-static int card_intr __P((struct pccard_devinfo *));
-
-PCCARD_MODULE(sio, sioinit, siounload, card_intr, 0, tty_imask);
-
-/*
- * Initialize the device - called from Slot manager.
- */
-int
-sioinit(struct pccard_devinfo *devi)
+static int
+sio_pccard_probe(dev)
+ device_t dev;
{
+ return (sioprobe(dev));
+}
- /* validate unit number. */
- if (devi->isahd.id_unit >= (NSIOTOT))
- return(ENODEV);
- /* Make sure it isn't already probed. */
- if (com_addr(devi->isahd.id_unit))
- return(EBUSY);
-
- /* It's already probed as serial by Upper */
- devi->isahd.id_flags |= COM_C_NOPROBE;
-
- /*
- * attach the device.
- */
- if (sioattach(devi->isahd.id_device) == 0)
- return(ENXIO);
-
- return(0);
+static int
+sio_pccard_attach(dev)
+ device_t dev;
+{
+ return (sioattach(dev));
}
/*
- * siounload - unload the driver and clear the table.
+ * sio_detach - unload the driver and clear the table.
* XXX TODO:
* This is usually called when the card is ejected, but
* can be caused by a modunload of a controller driver.
@@ -899,26 +900,23 @@ sioinit(struct pccard_devinfo *devi)
* read and write do not hang.
*/
static void
-siounload(struct pccard_devinfo *devi)
+sio_pccard_detach(dev)
+ device_t dev;
{
struct com_s *com;
- if (!devi) {
- printf("NULL devi in siounload\n");
- return;
- }
- com = com_addr(devi->isahd.id_unit);
+ com = (struct com_s *) device_get_softc(dev);
if (!com) {
- printf("NULL com in siounload\n");
+ device_printf(dev, "NULL com in siounload\n");
return;
}
if (!com->iobase) {
- printf("sio%d already unloaded!\n",devi->isahd.id_unit);
+ device_printf(dev, "already unloaded!\n");
return;
}
if (com->tp && (com->tp->t_state & TS_ISOPEN)) {
com->gone = 1;
- printf("sio%d: unload\n", devi->isahd.id_unit);
+ device_printf(dev, "unload\n");
com->tp->t_gen++;
ttyclose(com->tp);
ttwakeup(com->tp);
@@ -927,26 +925,9 @@ siounload(struct pccard_devinfo *devi)
if (com->ibuf != NULL)
free(com->ibuf, M_DEVBUF);
free(com, M_DEVBUF);
- printf("sio%d: unload,gone\n", devi->isahd.id_unit);
+ device_printf(dev, "unload,gone\n");
}
}
-
-/*
- * card_intr - Shared interrupt called from
- * front end of PC-Card handler.
- */
-static int
-card_intr(struct pccard_devinfo *devi)
-{
- struct com_s *com;
-
- COM_LOCK();
- com = com_addr(devi->isahd.id_unit);
- if (com && !com->gone)
- siointr1(com_addr(devi->isahd.id_unit));
- COM_UNLOCK();
- return(1);
-}
#endif /* NCARD > 0 */
#define SET_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) | (bit))
@@ -958,11 +939,25 @@ static struct isa_pnp_id sio_ids[] = {
{0x0205d041, "Multiport serial device (non-intelligent 16550)"}, /* PNP0502 */
{0x1005d041, "Generic IRDA-compatible device"}, /* PNP0510 */
{0x1105d041, "Generic IRDA-compatible device"}, /* PNP0511 */
- {0x31307256, "USR3031"}, /* USR3031 */
+ {0x01017256, NULL}, /* USR0101 */
+ {0x30207256, NULL}, /* USR2030 */
+ {0x31307256, NULL}, /* USR3031 */
+ {0x8020b04e, NULL}, /* SUP2080 */
+ {0x8024b04e, NULL}, /* SUP2480 */
{0}
};
static int
+sio_isa_probe(dev)
+ device_t dev;
+{
+ /* Check isapnp ids */
+ if (ISA_PNP_PROBE(device_get_parent(dev), dev, sio_ids) == ENXIO)
+ return (ENXIO);
+ return (sioprobe(dev));
+}
+
+static int
sioprobe(dev)
device_t dev;
{
@@ -987,10 +982,6 @@ sioprobe(dev)
Port_t rsabase = NULL;
#endif
- /* Check isapnp ids */
- if (ISA_PNP_PROBE(device_get_parent(dev), dev, sio_ids) == ENXIO)
- return (ENXIO);
-
rid = 0;
#ifdef PC98
port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
@@ -1273,51 +1264,42 @@ sioprobe(dev)
#endif /* PC98 */
/*
- * It's a definitly Serial PCMCIA(16550A), but still be required
+ * Some pcmcia cards have the "TXRDY bug", so we check everyone
* for IIR_TXRDY implementation ( Palido 321s, DC-1S... )
+ * XXX Bruce, is this OK? XXX
*/
- if ( COM_NOPROBE(flags) ) {
- /* Reading IIR register twice */
- for ( fn = 0; fn < 2; fn ++ ) {
- DELAY(10000);
+#if 0
+ /* Reading IIR register twice */
+ for ( fn = 0; fn < 2; fn ++ ) {
+ DELAY(10000);
#ifdef PC98
- failures[6] = inb(iobase + (com_iir << port_shift));
+ failures[6] = inb(iobase + (com_iir << port_shift));
#else
- failures[6] = inb(iobase + com_iir);
+ failures[6] = inb(iobase + com_iir);
#endif
- }
- /* Check IIR_TXRDY clear ? */
- result = 0;
- if ( failures[6] & IIR_TXRDY ) {
- /* Nop, Double check with clearing IER */
+ }
+ /* Check IIR_TXRDY clear ? */
+ result = 0;
+ if ( failures[6] & IIR_TXRDY ) {
+ /* Nop, Double check with clearing IER */
#ifdef PC98
- outb(iobase + (com_ier << port_shift), 0);
- if (inb(iobase +
- (com_iir << port_shift)) & IIR_NOPEND) {
+ outb(iobase + (com_ier << port_shift), 0);
+ if (inb(iobase + (com_iir << port_shift)) & IIR_NOPEND) {
#else
- outb(iobase + com_ier, 0);
- if ( inb(iobase + com_iir) & IIR_NOPEND ) {
+ outb(iobase + com_ier, 0);
+ if ( inb(iobase + com_iir) & IIR_NOPEND ) {
#endif
- /* Ok. we're familia this gang */
- SET_FLAG(dev, COM_C_IIR_TXRDYBUG); /* Set IIR_TXRDYBUG */
- } else {
- /* Unknown, Just omit this chip.. XXX */
- result = ENXIO;
- }
+ /* Ok. we're familia this gang */
+ SET_FLAG(dev, COM_C_IIR_TXRDYBUG); /* Set IIR_TXRDYBUG */
} else {
- /* OK. this is well-known guys */
- CLR_FLAG(dev, COM_C_IIR_TXRDYBUG); /*Clear IIR_TXRDYBUG*/
+ /* Unknown, Just omit this chip.. XXX */
+ result = ENXIO;
}
-#ifdef PC98
- outb(iobase + (com_cfcr << port_shift), CFCR_8BITS);
-#else
- outb(iobase + com_cfcr, CFCR_8BITS);
-#endif
- enable_intr();
- bus_release_resource(dev, SYS_RES_IOPORT, rid, port);
- return (iobase == siocniobase ? 0 : result);
+ } else {
+ /* OK. this is well-known guys */
+ CLR_FLAG(dev, COM_C_IIR_TXRDYBUG); /*Clear IIR_TXRDYBUG*/
}
-
+#endif
/*
* Check that
* o the CFCR, IER and MCR in UART hold the values written to them
@@ -1506,6 +1488,13 @@ espattach(com, esp_port)
#endif /* COM_ESP */
static int
+sio_isa_attach(dev)
+ device_t dev;
+{
+ return (sioattach(dev));
+}
+
+static int
sioattach(dev)
device_t dev;
{
@@ -1940,8 +1929,8 @@ open_top:
* callout, and to complete a callin open after DCD rises.
*/
tp->t_oproc = comstart;
- tp->t_stop = comstop;
tp->t_param = comparam;
+ tp->t_stop = comstop;
tp->t_dev = dev;
tp->t_termios = mynor & CALLOUT_MASK
? com->it_out : com->it_in;
@@ -4337,7 +4326,10 @@ siogdbputc(c)
}
#endif
-DEV_DRIVER_MODULE(sio, isa, sio_driver, sio_devclass, sio_cdevsw, 0, 0);
+DRIVER_MODULE(sio, isa, sio_isa_driver, sio_devclass, 0, 0);
+#if NCARD > 0
+DRIVER_MODULE(sio, pccard, sio_pccard_driver, sio_devclass, 0, 0);
+#endif
#ifdef PC98
/*
OpenPOWER on IntegriCloud