PERFORCE change 94334 for review
Marcel Moolenaar
marcel at FreeBSD.org
Thu Mar 30 23:48:14 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=94334
Change 94334 by marcel at marcel_nfs on 2006/03/30 23:47:36
Strip-down puc(4):
o Remove PUC_PORT_TYPE_UART: we always use uart(4) now, so we
can use PUC_PORT_TYPE_COM for that.
o Remove PUC_PORT_UART_*: we don't support UART sub-types. All
UARTs are standard ns8250 again.
o Remove PUC_FLAGS_MEMORY and PUC_FLAGS_ALTRES: we try I/O ports
first and if that fails, we try memory.
o Remove PUC_FASTINTR: we try setting up a fast handler first,
and if that fails we try a MPSAFE one.
Affected files ...
.. //depot/projects/uart/dev/puc/puc.c#18 edit
.. //depot/projects/uart/dev/puc/pucdata.c#15 edit
.. //depot/projects/uart/dev/puc/pucvar.h#13 edit
.. //depot/projects/uart/dev/uart/uart_bus_puc.c#11 edit
Differences ...
==== //depot/projects/uart/dev/puc/puc.c#18 (text+ko) ====
@@ -105,7 +105,6 @@
int port;
int regshft;
u_int serialfreq;
- u_int subtype;
};
static void puc_intr(void *arg);
@@ -170,7 +169,7 @@
puc_attach(device_t dev, const struct puc_device_description *desc)
{
char *typestr;
- int bidx, childunit, i, irq_setup, ressz, rid, type;
+ int bidx, childunit, i, error, ressz, rid, type;
struct puc_softc *sc;
struct puc_device *pdev;
struct resource *res;
@@ -189,6 +188,7 @@
printf("puc: name: %s\n", sc->sc_desc.name);
#endif
+
rid = 0;
res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
RF_ACTIVE | RF_SHAREABLE);
@@ -197,18 +197,15 @@
sc->irqres = res;
sc->irqrid = rid;
-#ifdef PUC_FASTINTR
- irq_setup = bus_setup_intr(dev, res,
- INTR_TYPE_TTY | INTR_FAST, puc_intr, sc, &sc->intr_cookie);
- if (irq_setup == 0)
+ error = bus_setup_intr(dev, res, INTR_TYPE_TTY | INTR_FAST,
+ puc_intr, sc, &sc->intr_cookie);
+ if (error) {
+ error = bus_setup_intr(dev, res, INTR_TYPE_TTY | INTR_MPSAFE,
+ puc_intr, sc, &sc->intr_cookie);
+ if (error)
+ return (error);
+ } else
sc->fastintr = INTR_FAST;
- else
-#else
- irq_setup = bus_setup_intr(dev, res,
- INTR_TYPE_TTY, puc_intr, sc, &sc->intr_cookie);
-#endif
- if (irq_setup != 0)
- return (ENXIO);
rid = 0;
for (i = 0; PUC_PORT_VALID(sc->sc_desc, i); i++) {
@@ -220,15 +217,10 @@
if (bidx < 0 || sc->sc_bar_mappings[bidx].res != NULL)
continue;
- type = (sc->sc_desc.ports[i].flags & PUC_FLAGS_MEMORY)
- ? SYS_RES_MEMORY : SYS_RES_IOPORT;
-
- res = bus_alloc_resource_any(dev, type, &rid,
- RF_ACTIVE);
- if (res == NULL &&
- sc->sc_desc.ports[i].flags & PUC_FLAGS_ALTRES) {
- type = (type == SYS_RES_IOPORT)
- ? SYS_RES_MEMORY : SYS_RES_IOPORT;
+ type = SYS_RES_IOPORT;
+ res = bus_alloc_resource_any(dev, type, &rid, RF_ACTIVE);
+ if (res == NULL) {
+ type = SYS_RES_MEMORY;
res = bus_alloc_resource_any(dev, type, &rid,
RF_ACTIVE);
}
@@ -266,30 +258,19 @@
if (bidx < 0 || sc->sc_bar_mappings[bidx].res == NULL)
continue;
- switch (sc->sc_desc.ports[i].type & ~PUC_PORT_SUBTYPE_MASK) {
+ switch (sc->sc_desc.ports[i].type) {
case PUC_PORT_TYPE_COM:
- typestr = "sio";
+ typestr = "uart";
+ ressz = 8;
break;
case PUC_PORT_TYPE_LPT:
typestr = "ppc";
+ ressz = 8;
break;
- case PUC_PORT_TYPE_UART:
- typestr = "uart";
- break;
default:
continue;
}
- switch (sc->sc_desc.ports[i].type & PUC_PORT_SUBTYPE_MASK) {
- case PUC_PORT_UART_SAB82532:
- ressz = 64;
- break;
- case PUC_PORT_UART_Z8530:
- ressz = 2;
- break;
- default:
- ressz = 8;
- break;
- }
+
pdev = malloc(sizeof(struct puc_device), M_DEVBUF,
M_NOWAIT | M_ZERO);
if (!pdev)
@@ -335,15 +316,9 @@
pdev->port = i + 1;
pdev->serialfreq = sc->sc_desc.ports[i].serialfreq;
- pdev->subtype = sc->sc_desc.ports[i].type &
- PUC_PORT_SUBTYPE_MASK;
pdev->regshft = sc->sc_desc.ports[i].regshft;
childunit = puc_find_free_unit(typestr);
- if (childunit < 0 && strcmp(typestr, "uart") != 0) {
- typestr = "uart";
- childunit = puc_find_free_unit(typestr);
- }
sc->sc_ports[i].dev = device_add_child(dev, typestr,
childunit);
if (sc->sc_ports[i].dev == NULL) {
@@ -358,7 +333,7 @@
device_set_ivars(sc->sc_ports[i].dev, pdev);
device_set_desc(sc->sc_ports[i].dev, sc->sc_desc.name);
#ifdef PUC_DEBUG
- printf("puc: type %d, bar %x, offset %x\n",
+ printf("puc: type %s(%d), bar %x, offset %x\n", typestr,
sc->sc_desc.ports[i].type,
sc->sc_desc.ports[i].bar,
sc->sc_desc.ports[i].offset);
@@ -607,9 +582,6 @@
case PUC_IVAR_REGSHFT:
*result = pdev->regshft;
break;
- case PUC_IVAR_SUBTYPE:
- *result = pdev->subtype;
- break;
default:
return (ENOENT);
}
==== //depot/projects/uart/dev/puc/pucdata.c#15 (text+ko) ====
@@ -64,9 +64,9 @@
{ 0x103c, 0x1048, 0x103c, 0x1282 },
{ 0xffff, 0xffff, 0xffff, 0xffff },
{
- { PUC_PORT_TYPE_UART, 0x10, 0x00, 0, PUC_FLAGS_MEMORY },
- { PUC_PORT_TYPE_UART, 0x10, 0x10, 0, PUC_FLAGS_MEMORY },
- { PUC_PORT_TYPE_UART, 0x10, 0x38, 0, PUC_FLAGS_MEMORY },
+ { PUC_PORT_TYPE_COM, 0x10, 0x00, 0 },
+ { PUC_PORT_TYPE_COM, 0x10, 0x10, 0 },
+ { PUC_PORT_TYPE_COM, 0x10, 0x38, 0 },
},
},
@@ -1211,14 +1211,14 @@
{ 0x13a8, 0x0158, 0, 0 },
{ 0xffff, 0xffff, 0, 0 },
{
- { PUC_PORT_TYPE_UART, 0x010, 0x000, COM_FREQ * 8, PUC_FLAGS_MEMORY },
- { PUC_PORT_TYPE_UART, 0x010, 0x200, COM_FREQ * 8, PUC_FLAGS_MEMORY },
- { PUC_PORT_TYPE_UART, 0x010, 0x400, COM_FREQ * 8, PUC_FLAGS_MEMORY },
- { PUC_PORT_TYPE_UART, 0x010, 0x600, COM_FREQ * 8, PUC_FLAGS_MEMORY },
- { PUC_PORT_TYPE_UART, 0x010, 0x800, COM_FREQ * 8, PUC_FLAGS_MEMORY },
- { PUC_PORT_TYPE_UART, 0x010, 0xA00, COM_FREQ * 8, PUC_FLAGS_MEMORY },
- { PUC_PORT_TYPE_UART, 0x010, 0xC00, COM_FREQ * 8, PUC_FLAGS_MEMORY },
- { PUC_PORT_TYPE_UART, 0x010, 0xE00, COM_FREQ * 8, PUC_FLAGS_MEMORY },
+ { PUC_PORT_TYPE_COM, 0x010, 0x000, COM_FREQ * 8 },
+ { PUC_PORT_TYPE_COM, 0x010, 0x200, COM_FREQ * 8 },
+ { PUC_PORT_TYPE_COM, 0x010, 0x400, COM_FREQ * 8 },
+ { PUC_PORT_TYPE_COM, 0x010, 0x600, COM_FREQ * 8 },
+ { PUC_PORT_TYPE_COM, 0x010, 0x800, COM_FREQ * 8 },
+ { PUC_PORT_TYPE_COM, 0x010, 0xA00, COM_FREQ * 8 },
+ { PUC_PORT_TYPE_COM, 0x010, 0xC00, COM_FREQ * 8 },
+ { PUC_PORT_TYPE_COM, 0x010, 0xE00, COM_FREQ * 8 },
},
},
==== //depot/projects/uart/dev/puc/pucvar.h#13 (text+ko) ====
@@ -93,21 +93,11 @@
#define PUC_PORT_TYPE_NONE 0
#define PUC_PORT_TYPE_COM 1
#define PUC_PORT_TYPE_LPT 2
-#define PUC_PORT_TYPE_UART 3
-/* UART subtypes. */
-#define PUC_PORT_SUBTYPE_MASK (~0xff)
-#define PUC_PORT_UART_NS8250 (0<<8)
-#define PUC_PORT_UART_SAB82532 (1<<8)
-#define PUC_PORT_UART_Z8530 (2<<8)
-
/* Interrupt Latch Register (ILR) types */
#define PUC_ILR_TYPE_NONE 0
#define PUC_ILR_TYPE_DIGI 1
-#define PUC_FLAGS_MEMORY 0x0001 /* Use memory mapped I/O. */
-#define PUC_FLAGS_ALTRES 0x0002 /* Use alternate I/O type. */
-
#define PUC_PORT_VALID(desc, port) \
((port) < PUC_MAX_PORTS && (desc).ports[(port)].type != PUC_PORT_TYPE_NONE)
@@ -115,7 +105,6 @@
enum puc_device_ivars {
PUC_IVAR_FREQ,
- PUC_IVAR_SUBTYPE,
PUC_IVAR_REGSHFT,
PUC_IVAR_PORT
};
==== //depot/projects/uart/dev/uart/uart_bus_puc.c#11 (text+ko) ====
@@ -63,37 +63,18 @@
{
device_t parent;
struct uart_softc *sc;
- uintptr_t port, rclk, regshft, type;
+ uintptr_t rclk, regshft;
parent = device_get_parent(dev);
sc = device_get_softc(dev);
- if (BUS_READ_IVAR(parent, dev, PUC_IVAR_SUBTYPE, &type))
- return (ENXIO);
- switch (type) {
- case PUC_PORT_UART_NS8250:
- sc->sc_class = &uart_ns8250_class;
- port = 0;
- break;
- case PUC_PORT_UART_SAB82532:
- sc->sc_class = &uart_sab82532_class;
- if (BUS_READ_IVAR(parent, dev, PUC_IVAR_PORT, &port))
- port = 0;
- break;
- case PUC_PORT_UART_Z8530:
- sc->sc_class = &uart_z8530_class;
- if (BUS_READ_IVAR(parent, dev, PUC_IVAR_PORT, &port))
- port = 0;
- break;
- default:
- return (ENXIO);
- }
+ sc->sc_class = &uart_ns8250_class;
if (BUS_READ_IVAR(parent, dev, PUC_IVAR_FREQ, &rclk))
rclk = 0;
if (BUS_READ_IVAR(parent, dev, PUC_IVAR_REGSHFT, ®shft))
regshft = 0;
- return (uart_bus_probe(dev, regshft, rclk, 0, port));
+ return (uart_bus_probe(dev, regshft, rclk, 0, 0));
}
DRIVER_MODULE(uart, puc, uart_puc_driver, uart_devclass, 0, 0);
More information about the p4-projects
mailing list