summaryrefslogtreecommitdiffstats
path: root/sys/dev/puc/puc.c
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 /sys/dev/puc/puc.c
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.
Diffstat (limited to 'sys/dev/puc/puc.c')
-rw-r--r--sys/dev/puc/puc.c24
1 files changed, 15 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);
}
OpenPOWER on IntegriCloud