summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2003-01-18 02:54:16 +0000
committermarcel <marcel@FreeBSD.org>2003-01-18 02:54:16 +0000
commit1f8dd35ac4ae56da5878261f226a2969c523ee58 (patch)
tree8c35fc3cbbc88c615f1042fe6663eb00a5e0ccf7
parentabee30eb6816567f7f95473c8caf14560d960da9 (diff)
downloadFreeBSD-src-1f8dd35ac4ae56da5878261f226a2969c523ee58.zip
FreeBSD-src-1f8dd35ac4ae56da5878261f226a2969c523ee58.tar.gz
MFp4: Add support for memory mapped UARTs, but don't add any devices
yet that depend on it because sio(4) needs support for it before it can be used. There's no reason why zs(4) couldn't attach to puc(4) in the (near?) future (in principle), so don't make memory mapped I/O support in sio(4) a precondition for this change.
-rw-r--r--sys/dev/puc/puc.c24
-rw-r--r--sys/dev/puc/pucvar.h3
2 files changed, 18 insertions, 9 deletions
diff --git a/sys/dev/puc/puc.c b/sys/dev/puc/puc.c
index 3bce20b..18d2fba 100644
--- a/sys/dev/puc/puc.c
+++ b/sys/dev/puc/puc.c
@@ -134,7 +134,7 @@ int
puc_attach(device_t dev, const struct puc_device_description *desc)
{
char *typestr;
- int bidx, childunit, i, irq_setup, rid;
+ int bidx, childunit, i, irq_setup, rid, type;
struct puc_softc *sc;
struct puc_device *pdev;
struct resource *res;
@@ -183,15 +183,21 @@ puc_attach(device_t dev, const struct puc_device_description *desc)
if (sc->sc_bar_mappings[bidx].res != NULL)
continue;
- res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0ul, ~0ul, 1, RF_ACTIVE);
+
+ type = (sc->sc_desc->ports[i].flags & PUC_FLAGS_MEMORY)
+ ? SYS_RES_MEMORY : SYS_RES_IOPORT;
+
+ res = bus_alloc_resource(dev, type, &rid, 0ul, ~0ul, 1,
+ RF_ACTIVE);
if (res == NULL) {
printf("could not get resource\n");
continue;
}
+ sc->sc_bar_mappings[bidx].type = type;
sc->sc_bar_mappings[bidx].res = res;
#ifdef PUC_DEBUG
- printf("port rid %d bst %x, start %x, end %x\n", rid,
+ printf("%s rid %d bst %x, start %x, end %x\n",
+ (type == SYS_RES_MEMORY) ? "memory" : "port", rid,
(u_int)rman_get_bustag(res), (u_int)rman_get_start(res),
(u_int)rman_get_end(res));
#endif
@@ -229,13 +235,14 @@ puc_attach(device_t dev, const struct puc_device_description *desc)
rle = resource_list_find(&pdev->resources, SYS_RES_IRQ, 0);
rle->res = sc->irqres;
- /* Now fake an IOPORT resource */
+ /* Now fake an IOPORT or MEMORY resource */
res = sc->sc_bar_mappings[bidx].res;
- resource_list_add(&pdev->resources, SYS_RES_IOPORT, 0,
+ type = sc->sc_bar_mappings[bidx].type;
+ resource_list_add(&pdev->resources, type, 0,
rman_get_start(res) + sc->sc_desc->ports[i].offset,
rman_get_start(res) + sc->sc_desc->ports[i].offset + 8 - 1,
8);
- rle = resource_list_find(&pdev->resources, SYS_RES_IOPORT, 0);
+ rle = resource_list_find(&pdev->resources, type, 0);
if (sc->barmuxed == 0) {
rle->res = sc->sc_bar_mappings[bidx].res;
@@ -264,8 +271,7 @@ puc_attach(device_t dev, const struct puc_device_description *desc)
if (sc->sc_ports[i].dev == NULL) {
if (sc->barmuxed) {
bus_space_unmap(rman_get_bustag(rle->res),
- rman_get_bushandle(rle->res),
- 8);
+ rman_get_bushandle(rle->res), 8);
free(rle->res, M_DEVBUF);
free(pdev, M_DEVBUF);
}
diff --git a/sys/dev/puc/pucvar.h b/sys/dev/puc/pucvar.h
index 22f8ff3..fcbb0eb 100644
--- a/sys/dev/puc/pucvar.h
+++ b/sys/dev/puc/pucvar.h
@@ -91,6 +91,8 @@ struct puc_device_description {
#define PUC_PORT_TYPE_COM 1
#define PUC_PORT_TYPE_LPT 2
+#define PUC_FLAGS_MEMORY 0x0001 /* Use memory mapped I/O. */
+
#define PUC_PORT_VALID(desc, port) \
((port) < PUC_MAX_PORTS && (desc)->ports[(port)].type != PUC_PORT_TYPE_NONE)
@@ -128,6 +130,7 @@ struct puc_softc {
struct {
int used;
int bar;
+ int type; /* SYS_RES_IOPORT or SYS_RES_MEMORY. */
struct resource *res;
} sc_bar_mappings[PUC_MAX_BAR];
OpenPOWER on IntegriCloud