summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkato <kato@FreeBSD.org>2000-04-01 11:27:31 +0000
committerkato <kato@FreeBSD.org>2000-04-01 11:27:31 +0000
commitcd1c73cd7d0ac9047e6a1c331c3b09ef9ef4c19b (patch)
tree76bb46d7f4de1bcf2ccc70fdf96cb7c933202b04
parent7ede7c8f0f7217a17eb141f4587f2c0ebd6ec6e8 (diff)
downloadFreeBSD-src-cd1c73cd7d0ac9047e6a1c331c3b09ef9ef4c19b.zip
FreeBSD-src-cd1c73cd7d0ac9047e6a1c331c3b09ef9ef4c19b.tar.gz
Merged from sys/isa/sio.c revisions 1.293 and 1.294.
-rw-r--r--sys/pc98/cbus/sio.c137
-rw-r--r--sys/pc98/pc98/sio.c137
2 files changed, 246 insertions, 28 deletions
diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c
index 227f64d..492b7ee 100644
--- a/sys/pc98/cbus/sio.c
+++ b/sys/pc98/cbus/sio.c
@@ -40,6 +40,7 @@
#include "opt_ddb.h"
#include "opt_sio.h"
#include "card.h"
+#include "pci.h"
#include "sio.h"
/*
@@ -166,6 +167,10 @@
#include <isa/isareg.h>
#endif
#include <isa/isavar.h>
+#if NPCI > 0
+#include <pci/pcireg.h>
+#include <pci/pcivar.h>
+#endif
#include <machine/lock.h>
#include <machine/clock.h>
@@ -404,7 +409,7 @@ struct com_s {
#ifdef COM_ESP
static int espattach __P((struct com_s *com, Port_t esp_port));
#endif
-static int sioattach __P((device_t dev));
+static int sioattach __P((device_t dev, int rid));
static int sio_isa_attach __P((device_t dev));
static timeout_t siobusycheck;
@@ -416,7 +421,7 @@ static void siointr __P((void *arg));
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 sioprobe __P((device_t dev, int xrid));
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));
@@ -432,6 +437,12 @@ static int sio_pccard_detach __P((device_t dev));
static int sio_pccard_probe __P((device_t dev));
#endif /* NCARD > 0 */
+#if NPCI > 0
+static int sio_pci_attach __P((device_t dev));
+static void sio_pci_kludge_unit __P((device_t dev));
+static int sio_pci_probe __P((device_t dev));
+#endif /* NPCI > 0 */
+
static char driver_name[] = "sio";
/* table and macro for fast conversion from a unit number to its com struct */
@@ -468,7 +479,23 @@ static driver_t sio_pccard_driver = {
sio_pccard_methods,
sizeof(struct com_s),
};
-#endif (NCARD > 0)
+#endif /* NCARD > 0 */
+
+#if NPCI > 0
+static device_method_t sio_pci_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, sio_pci_probe),
+ DEVMETHOD(device_attach, sio_pci_attach),
+
+ { 0, 0 }
+};
+
+static driver_t sio_pci_driver = {
+ driver_name,
+ sio_pci_methods,
+ sizeof(struct com_s),
+};
+#endif /* NPCI > 0 */
static d_open_t sioopen;
static d_close_t sioclose;
@@ -893,14 +920,14 @@ sio_pccard_probe(dev)
/* until bus_setup_intr */
SET_FLAG(dev, COM_C_NOPROBE);
- return (sioprobe(dev));
+ return (sioprobe(dev, 0));
}
static int
sio_pccard_attach(dev)
device_t dev;
{
- return (sioattach(dev));
+ return (sioattach(dev, 0));
}
/*
@@ -949,6 +976,82 @@ sio_pccard_detach(dev)
}
#endif /* NCARD > 0 */
+#if NPCI > 0
+struct pci_ids {
+ u_int32_t type;
+ const char *desc;
+ int rid;
+};
+
+static struct pci_ids pci_ids[] = {
+ { 0x100812b9, "3COM PCI FaxModem", 0x10 },
+ { 0x048011c1, "ActionTec 56k FAX PCI Modem", 0x14 },
+ { 0x00000000, NULL, 0 }
+};
+
+static int
+sio_pci_attach(dev)
+ device_t dev;
+{
+ u_int32_t type;
+ struct pci_ids *id;
+
+ type = pci_get_devid(dev);
+ id = pci_ids;
+ while (id->type && id->type != type)
+ id++;
+ if (id->desc == NULL)
+ return (ENXIO);
+ sio_pci_kludge_unit(dev);
+ return (sioattach(dev, id->rid));
+}
+
+/*
+ * Don't cut and paste this to other drivers. It is a horrible kludge
+ * which will fail to work and also be unnecessary in future versions.
+ */
+static void
+sio_pci_kludge_unit(dev)
+ device_t dev;
+{
+ devclass_t dc;
+ int err;
+ int start;
+ int unit;
+
+ unit = 0;
+ start = 0;
+ while (resource_int_value("sio", unit, "port", &start) == 0 &&
+ start > 0)
+ unit++;
+ if (device_get_unit(dev) < unit) {
+ dc = device_get_devclass(dev);
+ while (devclass_get_device(dc, unit))
+ unit++;
+ device_printf(dev, "moving to sio%d\n", unit);
+ err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */
+ if (err)
+ device_printf(dev, "error moving device %d\n", err);
+ }
+}
+
+static int
+sio_pci_probe(dev)
+ device_t dev;
+{
+ u_int32_t type;
+ struct pci_ids *id;
+
+ type = pci_get_devid(dev);
+ id = pci_ids;
+ while (id->type && id->type != type)
+ id++;
+ if (id->desc == NULL)
+ return (ENXIO);
+ device_set_desc(dev, id->desc);
+ return (sioprobe(dev, id->rid));
+}
+#endif /* NPCI > 0 */
static struct isa_pnp_id sio_ids[] = {
{0x0005d041, "Standard PC COM port"}, /* PNP0500 */
@@ -1005,6 +1108,7 @@ static struct isa_pnp_id sio_ids[] = {
{0x70207256, NULL}, /* USR2070 - U.S.Robotics Inc. Sportster 560 */
{0x30307256, NULL}, /* USR3030 - U.S. Robotics 56K FAX INT */
{0x31307256, NULL}, /* USR3031 - U.S. Robotics 56K FAX INT */
+ {0x50307256, NULL}, /* USR3050 - U.S. Robotics 56K FAX INT */
{0x70307256, NULL}, /* USR3070 - U.S. Robotics 56K Voice INT */
{0x90307256, NULL}, /* USR3090 - USR ? */
{0x90917256, NULL}, /* USR9190 - USR 56k Voice INT */
@@ -1033,12 +1137,13 @@ sio_isa_probe(dev)
if (logical_id == 0x0100e4a5) /* RSA-98III */
device_set_flags(dev, COM_IF_RSA98III << 24);
#endif
- return (sioprobe(dev));
+ return (sioprobe(dev, 0));
}
static int
-sioprobe(dev)
+sioprobe(dev, xrid)
device_t dev;
+ int xrid;
{
#if 0
static bool_t already_init;
@@ -1064,7 +1169,7 @@ sioprobe(dev)
Port_t rsabase;
#endif
- rid = 0;
+ rid = xrid;
#ifdef PC98
port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
0, ~0, 1, RF_ACTIVE); /* XXX */
@@ -1607,12 +1712,13 @@ static int
sio_isa_attach(dev)
device_t dev;
{
- return (sioattach(dev));
+ return (sioattach(dev, 0));
}
static int
-sioattach(dev)
+sioattach(dev, xrid)
device_t dev;
+ int xrid;
{
struct com_s *com;
#ifdef COM_ESP
@@ -1630,7 +1736,7 @@ sioattach(dev)
u_long obufsize;
#endif
- rid = 0;
+ rid = xrid;
#ifdef PC98
port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
0, ~0, 1, RF_ACTIVE); /* XXX */
@@ -4165,7 +4271,7 @@ siocngetspeed(iobase, table)
if (table->sp_code == code)
return (table->sp_speed);
- return 0; /* didn't match anything sane */
+ return (0); /* didn't match anything sane */
}
static void
@@ -4386,7 +4492,7 @@ siocnattach(port, speed)
splx(s);
cn_tab = &sio_consdev;
- return 0;
+ return (0);
}
int
@@ -4423,7 +4529,7 @@ siogdbattach(port, speed)
siocnopen(&sp, siogdbiobase, gdbdefaultrate);
splx(s);
- return 0;
+ return (0);
}
#endif
@@ -4544,6 +4650,9 @@ 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
+#if NPCI > 0
+DRIVER_MODULE(sio, pci, sio_pci_driver, sio_devclass, 0, 0);
+#endif
#ifdef PC98
/*
diff --git a/sys/pc98/pc98/sio.c b/sys/pc98/pc98/sio.c
index 227f64d..492b7ee 100644
--- a/sys/pc98/pc98/sio.c
+++ b/sys/pc98/pc98/sio.c
@@ -40,6 +40,7 @@
#include "opt_ddb.h"
#include "opt_sio.h"
#include "card.h"
+#include "pci.h"
#include "sio.h"
/*
@@ -166,6 +167,10 @@
#include <isa/isareg.h>
#endif
#include <isa/isavar.h>
+#if NPCI > 0
+#include <pci/pcireg.h>
+#include <pci/pcivar.h>
+#endif
#include <machine/lock.h>
#include <machine/clock.h>
@@ -404,7 +409,7 @@ struct com_s {
#ifdef COM_ESP
static int espattach __P((struct com_s *com, Port_t esp_port));
#endif
-static int sioattach __P((device_t dev));
+static int sioattach __P((device_t dev, int rid));
static int sio_isa_attach __P((device_t dev));
static timeout_t siobusycheck;
@@ -416,7 +421,7 @@ static void siointr __P((void *arg));
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 sioprobe __P((device_t dev, int xrid));
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));
@@ -432,6 +437,12 @@ static int sio_pccard_detach __P((device_t dev));
static int sio_pccard_probe __P((device_t dev));
#endif /* NCARD > 0 */
+#if NPCI > 0
+static int sio_pci_attach __P((device_t dev));
+static void sio_pci_kludge_unit __P((device_t dev));
+static int sio_pci_probe __P((device_t dev));
+#endif /* NPCI > 0 */
+
static char driver_name[] = "sio";
/* table and macro for fast conversion from a unit number to its com struct */
@@ -468,7 +479,23 @@ static driver_t sio_pccard_driver = {
sio_pccard_methods,
sizeof(struct com_s),
};
-#endif (NCARD > 0)
+#endif /* NCARD > 0 */
+
+#if NPCI > 0
+static device_method_t sio_pci_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, sio_pci_probe),
+ DEVMETHOD(device_attach, sio_pci_attach),
+
+ { 0, 0 }
+};
+
+static driver_t sio_pci_driver = {
+ driver_name,
+ sio_pci_methods,
+ sizeof(struct com_s),
+};
+#endif /* NPCI > 0 */
static d_open_t sioopen;
static d_close_t sioclose;
@@ -893,14 +920,14 @@ sio_pccard_probe(dev)
/* until bus_setup_intr */
SET_FLAG(dev, COM_C_NOPROBE);
- return (sioprobe(dev));
+ return (sioprobe(dev, 0));
}
static int
sio_pccard_attach(dev)
device_t dev;
{
- return (sioattach(dev));
+ return (sioattach(dev, 0));
}
/*
@@ -949,6 +976,82 @@ sio_pccard_detach(dev)
}
#endif /* NCARD > 0 */
+#if NPCI > 0
+struct pci_ids {
+ u_int32_t type;
+ const char *desc;
+ int rid;
+};
+
+static struct pci_ids pci_ids[] = {
+ { 0x100812b9, "3COM PCI FaxModem", 0x10 },
+ { 0x048011c1, "ActionTec 56k FAX PCI Modem", 0x14 },
+ { 0x00000000, NULL, 0 }
+};
+
+static int
+sio_pci_attach(dev)
+ device_t dev;
+{
+ u_int32_t type;
+ struct pci_ids *id;
+
+ type = pci_get_devid(dev);
+ id = pci_ids;
+ while (id->type && id->type != type)
+ id++;
+ if (id->desc == NULL)
+ return (ENXIO);
+ sio_pci_kludge_unit(dev);
+ return (sioattach(dev, id->rid));
+}
+
+/*
+ * Don't cut and paste this to other drivers. It is a horrible kludge
+ * which will fail to work and also be unnecessary in future versions.
+ */
+static void
+sio_pci_kludge_unit(dev)
+ device_t dev;
+{
+ devclass_t dc;
+ int err;
+ int start;
+ int unit;
+
+ unit = 0;
+ start = 0;
+ while (resource_int_value("sio", unit, "port", &start) == 0 &&
+ start > 0)
+ unit++;
+ if (device_get_unit(dev) < unit) {
+ dc = device_get_devclass(dev);
+ while (devclass_get_device(dc, unit))
+ unit++;
+ device_printf(dev, "moving to sio%d\n", unit);
+ err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */
+ if (err)
+ device_printf(dev, "error moving device %d\n", err);
+ }
+}
+
+static int
+sio_pci_probe(dev)
+ device_t dev;
+{
+ u_int32_t type;
+ struct pci_ids *id;
+
+ type = pci_get_devid(dev);
+ id = pci_ids;
+ while (id->type && id->type != type)
+ id++;
+ if (id->desc == NULL)
+ return (ENXIO);
+ device_set_desc(dev, id->desc);
+ return (sioprobe(dev, id->rid));
+}
+#endif /* NPCI > 0 */
static struct isa_pnp_id sio_ids[] = {
{0x0005d041, "Standard PC COM port"}, /* PNP0500 */
@@ -1005,6 +1108,7 @@ static struct isa_pnp_id sio_ids[] = {
{0x70207256, NULL}, /* USR2070 - U.S.Robotics Inc. Sportster 560 */
{0x30307256, NULL}, /* USR3030 - U.S. Robotics 56K FAX INT */
{0x31307256, NULL}, /* USR3031 - U.S. Robotics 56K FAX INT */
+ {0x50307256, NULL}, /* USR3050 - U.S. Robotics 56K FAX INT */
{0x70307256, NULL}, /* USR3070 - U.S. Robotics 56K Voice INT */
{0x90307256, NULL}, /* USR3090 - USR ? */
{0x90917256, NULL}, /* USR9190 - USR 56k Voice INT */
@@ -1033,12 +1137,13 @@ sio_isa_probe(dev)
if (logical_id == 0x0100e4a5) /* RSA-98III */
device_set_flags(dev, COM_IF_RSA98III << 24);
#endif
- return (sioprobe(dev));
+ return (sioprobe(dev, 0));
}
static int
-sioprobe(dev)
+sioprobe(dev, xrid)
device_t dev;
+ int xrid;
{
#if 0
static bool_t already_init;
@@ -1064,7 +1169,7 @@ sioprobe(dev)
Port_t rsabase;
#endif
- rid = 0;
+ rid = xrid;
#ifdef PC98
port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
0, ~0, 1, RF_ACTIVE); /* XXX */
@@ -1607,12 +1712,13 @@ static int
sio_isa_attach(dev)
device_t dev;
{
- return (sioattach(dev));
+ return (sioattach(dev, 0));
}
static int
-sioattach(dev)
+sioattach(dev, xrid)
device_t dev;
+ int xrid;
{
struct com_s *com;
#ifdef COM_ESP
@@ -1630,7 +1736,7 @@ sioattach(dev)
u_long obufsize;
#endif
- rid = 0;
+ rid = xrid;
#ifdef PC98
port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
0, ~0, 1, RF_ACTIVE); /* XXX */
@@ -4165,7 +4271,7 @@ siocngetspeed(iobase, table)
if (table->sp_code == code)
return (table->sp_speed);
- return 0; /* didn't match anything sane */
+ return (0); /* didn't match anything sane */
}
static void
@@ -4386,7 +4492,7 @@ siocnattach(port, speed)
splx(s);
cn_tab = &sio_consdev;
- return 0;
+ return (0);
}
int
@@ -4423,7 +4529,7 @@ siogdbattach(port, speed)
siocnopen(&sp, siogdbiobase, gdbdefaultrate);
splx(s);
- return 0;
+ return (0);
}
#endif
@@ -4544,6 +4650,9 @@ 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
+#if NPCI > 0
+DRIVER_MODULE(sio, pci, sio_pci_driver, sio_devclass, 0, 0);
+#endif
#ifdef PC98
/*
OpenPOWER on IntegriCloud