aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2003-01-18 02:54:16 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2003-01-18 02:54:16 +0000
commitda5e9a5bd6b87442ac00fcb57a128d4ac222730c (patch)
tree8c35fc3cbbc88c615f1042fe6663eb00a5e0ccf7 /sys/dev
parent5f85bb36eec666d5ce2353fb12a976179fb51c99 (diff)
downloadsrc-da5e9a5bd6b87442ac00fcb57a128d4ac222730c.tar.gz
src-da5e9a5bd6b87442ac00fcb57a128d4ac222730c.zip
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.
Notes
Notes: svn path=/head/; revision=109458
Diffstat (limited to 'sys/dev')
-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 3bce20b8d36f..18d2fbabc0f5 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 22f8ff32f6c1..fcbb0eb86b66 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];