PERFORCE change 96202 for review
Marcel Moolenaar
marcel at FreeBSD.org
Thu Apr 27 07:22:58 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=96202
Change 96202 by marcel at marcel_nfs on 2006/04/27 07:21:57
Add a whole bunch of Timedia cards. There are so many of them
that a shorthand is needed. We match all Timedia serial cards
and select at runtime on the subdevice. In order to allow a
meaning device description, create a config command for it so
that they can be generated on the fly.
Information obtained from Linux.
Affected files ...
.. //depot/projects/uart/dev/puc/puc.c#38 edit
.. //depot/projects/uart/dev/puc/puc_cfg.c#4 edit
.. //depot/projects/uart/dev/puc/puc_cfg.h#4 edit
.. //depot/projects/uart/dev/puc/pucdata.c#38 edit
Differences ...
==== //depot/projects/uart/dev/puc/puc.c#38 (text+ko) ====
@@ -431,9 +431,11 @@
error = puc_config(sc, PUC_CFG_GET_NPORTS, 0, &res);
if (error)
return (error);
-
- if (cfg->name != NULL)
- device_set_desc(dev, cfg->name);
+ error = puc_config(sc, PUC_CFG_GET_DESC, 0, &res);
+ if (error)
+ return (error);
+ if (res != 0)
+ device_set_desc(dev, (const char *)res);
return (BUS_PROBE_DEFAULT);
}
==== //depot/projects/uart/dev/puc/puc_cfg.c#4 (text+ko) ====
@@ -55,6 +55,11 @@
return (error);
*r = cfg->clock;
return (0);
+ case PUC_CFG_GET_DESC:
+ if (cfg->desc == NULL)
+ return (error);
+ *r = (intptr_t)cfg->desc;
+ return (0);
case PUC_CFG_GET_ILR:
*r = PUC_ILR_NONE;
return (0);
==== //depot/projects/uart/dev/puc/puc_cfg.h#4 (text+ko) ====
@@ -54,6 +54,7 @@
/* Configuration queries. */
enum puc_cfg_cmd {
PUC_CFG_GET_CLOCK,
+ PUC_CFG_GET_DESC,
PUC_CFG_GET_ILR,
PUC_CFG_GET_LEN,
PUC_CFG_GET_NPORTS,
@@ -72,7 +73,7 @@
uint16_t device;
uint16_t subvendor;
uint16_t subdevice;
- const char *name;
+ const char *desc;
int clock;
int8_t ports;
int8_t rid; /* Rid of first port */
==== //depot/projects/uart/dev/puc/pucdata.c#38 (text+ko) ====
@@ -40,6 +40,8 @@
#include <machine/resource.h>
#include <sys/rman.h>
+#include <dev/pci/pcivar.h>
+
#include <dev/puc/puc_bfe.h>
#include <dev/puc/puc_cfg.h>
@@ -49,6 +51,7 @@
static puc_config_f puc_config_quatech;
static puc_config_f puc_config_syba;
static puc_config_f puc_config_siig;
+static puc_config_f puc_config_timedia;
static puc_config_f puc_config_titan;
const struct puc_cfg puc_pci_devices[] = {
@@ -550,14 +553,11 @@
PUC_PORT_4S, 0x10, 4, 0,
},
- /*
- * Dolphin Peripherals 4036 (dual serial port) card.
- * (Dolpin 4025 has the same ID but only one port)
- */
{ 0x1409, 0x7168, 0xffff, 0,
- "Dolphin Peripherals 4036",
+ NULL,
DEFAULT_RCLK * 8,
- PUC_PORT_2S, 0x10, 0, 8,
+ PUC_PORT_NONSTANDARD, 0x10, -1, -1,
+ .config_function = puc_config_timedia
},
/*
@@ -972,6 +972,74 @@
}
static int
+puc_config_timedia(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
+ intptr_t *res)
+{
+ static uint16_t dual[] = {
+ 0x0002, 0x4036, 0x4037, 0x4038, 0x4078, 0x4079, 0x4085,
+ 0x4088, 0x4089, 0x5037, 0x5078, 0x5079, 0x5085, 0x6079,
+ 0x7079, 0x8079, 0x8137, 0x8138, 0x8237, 0x8238, 0x9079,
+ 0x9137, 0x9138, 0x9237, 0x9238, 0xA079, 0xB079, 0xC079,
+ 0xD079, 0
+ };
+ static uint16_t quad[] = {
+ 0x4055, 0x4056, 0x4095, 0x4096, 0x5056, 0x8156, 0x8157,
+ 0x8256, 0x8257, 0x9056, 0x9156, 0x9157, 0x9158, 0x9159,
+ 0x9256, 0x9257, 0xA056, 0xA157, 0xA158, 0xA159, 0xB056,
+ 0xB157, 0
+ };
+ static uint16_t octa[] = {
+ 0x4065, 0x4066, 0x5065, 0x5066, 0x8166, 0x9066, 0x9166,
+ 0x9167, 0x9168, 0xA066, 0xA167, 0xA168, 0
+ };
+ static struct {
+ int ports;
+ uint16_t *ids;
+ } subdevs[] = {
+ { 2, dual },
+ { 4, quad },
+ { 8, octa },
+ { 0, NULL }
+ };
+ static char desc[64];
+ int dev, id;
+ uint16_t subdev;
+
+ switch (cmd) {
+ case PUC_CFG_GET_DESC:
+ snprintf(desc, sizeof(desc),
+ "Timedia technology %d Port Serial", (int)sc->sc_cfg_data);
+ *res = (intptr_t)desc;
+ return (0);
+ case PUC_CFG_GET_NPORTS:
+ subdev = pci_get_subdevice(sc->sc_dev);
+ dev = 0;
+ while (subdevs[dev].ports != 0) {
+ id = 0;
+ while (subdevs[dev].ids[id] != 0) {
+ if (subdev == subdevs[dev].ids[id]) {
+ sc->sc_cfg_data = subdevs[dev].ports;
+ *res = sc->sc_cfg_data;
+ return (0);
+ }
+ id++;
+ }
+ dev++;
+ }
+ return (ENXIO);
+ case PUC_CFG_GET_OFS:
+ *res = (port == 1 || port == 3) ? 8 : 0;
+ return (0);
+ case PUC_CFG_GET_RID:
+ *res = (port > 3) ? port - 2 : port >> 1;
+ return (0);
+ default:
+ break;
+ }
+ return (ENXIO);
+}
+
+static int
puc_config_titan(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
intptr_t *res)
{
More information about the p4-projects
mailing list