Date: Sun, 29 Jun 2003 16:27:15 -0700 (PDT) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 33858 for review Message-ID: <200306292327.h5TNRF2P017417@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=33858 Change 33858 by marcel@marcel_nfs on 2003/06/29 16:26:55 Add a bus front-end for ebus to puc(4). This allows us to use puc(4) to attach to dual channel UARTs like the Siemens SAB 82532. Since puc_devices is specific to the PIC front-end, keep it out of puc.c. Also, handle non-static puc_device_descriptions by copying the information to the softc instead of having a pointer there. This is experimental. Affected files ... .. //depot/projects/uart/conf/files#3 edit .. //depot/projects/uart/dev/puc/puc.c#2 edit .. //depot/projects/uart/dev/puc/puc_ebus.c#1 add .. //depot/projects/uart/dev/puc/puc_pci.c#2 edit .. //depot/projects/uart/dev/puc/pucdata.c#2 edit .. //depot/projects/uart/dev/puc/pucvar.h#2 edit Differences ... ==== //depot/projects/uart/conf/files#3 (text+ko) ==== @@ -578,6 +578,7 @@ dev/pst/pst-iop.c optional pst dev/pst/pst-raid.c optional pst dev/puc/puc.c optional puc +dev/puc/puc_ebus.c optional puc ebus dev/puc/puc_pci.c optional puc pci dev/puc/puc_pccard.c optional puc pccard dev/puc/pucdata.c optional puc pci ==== //depot/projects/uart/dev/puc/puc.c#2 (text+ko) ==== @@ -136,18 +136,18 @@ u_char t1, t2; int i; - switch (sc->sc_desc->ilr_type) { + switch (sc->sc_desc.ilr_type) { case PUC_ILR_TYPE_DIGI: sc->ilr_st = rman_get_bustag(res); sc->ilr_sh = rman_get_bushandle(res); - for (i = 0; i < 2 && sc->sc_desc->ilr_offset[i] != 0; i++) { + for (i = 0; i < 2 && sc->sc_desc.ilr_offset[i] != 0; i++) { t1 = bus_space_read_1(sc->ilr_st, sc->ilr_sh, - sc->sc_desc->ilr_offset[i]); + sc->sc_desc.ilr_offset[i]); t1 = ~t1; bus_space_write_1(sc->ilr_st, sc->ilr_sh, - sc->sc_desc->ilr_offset[i], t1); + sc->sc_desc.ilr_offset[i], t1); t2 = bus_space_read_1(sc->ilr_st, sc->ilr_sh, - sc->sc_desc->ilr_offset[i]); + sc->sc_desc.ilr_offset[i]); if (t2 == t1) return (0); } @@ -169,16 +169,17 @@ struct resource *res; struct resource_list_entry *rle; + if (desc == NULL) + return (ENXIO); + sc = (struct puc_softc *)device_get_softc(dev); bzero(sc, sizeof(*sc)); - sc->sc_desc = desc; - if (sc->sc_desc == NULL) - return (ENXIO); + sc->sc_desc = *desc; #ifdef PUC_DEBUG bootverbose = 1; - printf("puc: name: %s\n", sc->sc_desc->name); + printf("puc: name: %s\n", sc->sc_desc.name); #endif rid = 0; res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, @@ -205,15 +206,15 @@ rid = 0; for (i = 0; PUC_PORT_VALID(sc->sc_desc, i); i++) { - if (i > 0 && rid == sc->sc_desc->ports[i].bar) + if (i > 0 && rid == sc->sc_desc.ports[i].bar) sc->barmuxed = 1; - rid = sc->sc_desc->ports[i].bar; + rid = sc->sc_desc.ports[i].bar; bidx = puc_port_bar_index(sc, rid); if (sc->sc_bar_mappings[bidx].res != NULL) continue; - type = (sc->sc_desc->ports[i].flags & PUC_FLAGS_MEMORY) + 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, @@ -225,7 +226,7 @@ sc->sc_bar_mappings[bidx].type = type; sc->sc_bar_mappings[bidx].res = res; - if (sc->sc_desc->ilr_type != PUC_ILR_TYPE_NONE) { + if (sc->sc_desc.ilr_type != PUC_ILR_TYPE_NONE) { sc->ilr_enabled = puc_probe_ilr(sc, res); if (sc->ilr_enabled) device_printf(dev, "ILR enabled\n"); @@ -247,12 +248,12 @@ } for (i = 0; PUC_PORT_VALID(sc->sc_desc, i); i++) { - rid = sc->sc_desc->ports[i].bar; + rid = sc->sc_desc.ports[i].bar; bidx = puc_port_bar_index(sc, rid); if (sc->sc_bar_mappings[bidx].res == NULL) continue; - switch (sc->sc_desc->ports[i].type) { + switch (sc->sc_desc.ports[i].type) { case PUC_PORT_TYPE_COM: typestr = "sio"; break; @@ -276,8 +277,8 @@ res = sc->sc_bar_mappings[bidx].res; 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, + 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, type, 0); @@ -292,16 +293,16 @@ } rle->res->r_start = rman_get_start(res) + - sc->sc_desc->ports[i].offset; + sc->sc_desc.ports[i].offset; rle->res->r_end = rle->res->r_start + 8 - 1; rle->res->r_bustag = rman_get_bustag(res); bus_space_subregion(rle->res->r_bustag, rman_get_bushandle(res), - sc->sc_desc->ports[i].offset, 8, + sc->sc_desc.ports[i].offset, 8, &rle->res->r_bushandle); } - pdev->serialfreq = sc->sc_desc->ports[i].serialfreq; + pdev->serialfreq = sc->sc_desc.ports[i].serialfreq; childunit = puc_find_free_unit(typestr); sc->sc_ports[i].dev = device_add_child(dev, typestr, childunit); @@ -315,18 +316,18 @@ continue; } device_set_ivars(sc->sc_ports[i].dev, pdev); - device_set_desc(sc->sc_ports[i].dev, sc->sc_desc->name); + device_set_desc(sc->sc_ports[i].dev, sc->sc_desc.name); if (!bootverbose) device_quiet(sc->sc_ports[i].dev); #ifdef PUC_DEBUG printf("puc: type %d, bar %x, offset %x\n", - sc->sc_desc->ports[i].type, - sc->sc_desc->ports[i].bar, - sc->sc_desc->ports[i].offset); + sc->sc_desc.ports[i].type, + sc->sc_desc.ports[i].bar, + sc->sc_desc.ports[i].offset); puc_print_resource_list(&pdev->resources); #endif device_set_flags(sc->sc_ports[i].dev, - sc->sc_desc->ports[i].flags); + sc->sc_desc.ports[i].flags); if (device_probe_and_attach(sc->sc_ports[i].dev) != 0) { if (sc->barmuxed) { bus_space_unmap(rman_get_bustag(rle->res), @@ -351,11 +352,11 @@ int i; mask = 0; - switch (sc->sc_desc->ilr_type) { + switch (sc->sc_desc.ilr_type) { case PUC_ILR_TYPE_DIGI: - for (i = 1; i >= 0 && sc->sc_desc->ilr_offset[i] != 0; i--) { + for (i = 1; i >= 0 && sc->sc_desc.ilr_offset[i] != 0; i--) { mask = (mask << 8) | (bus_space_read_1(sc->ilr_st, - sc->ilr_sh, sc->sc_desc->ilr_offset[i]) & 0xff); + sc->ilr_sh, sc->sc_desc.ilr_offset[i]) & 0xff); } break; @@ -388,28 +389,6 @@ (sc->sc_ports[i].ihand)(sc->sc_ports[i].ihandarg); } -const struct puc_device_description * -puc_find_description(uint32_t vend, uint32_t prod, uint32_t svend, - uint32_t sprod) -{ - int i; - -#define checkreg(val, index) \ - (((val) & puc_devices[i].rmask[(index)]) == puc_devices[i].rval[(index)]) - - for (i = 0; puc_devices[i].name != NULL; i++) { - if (checkreg(vend, PUC_REG_VEND) && - checkreg(prod, PUC_REG_PROD) && - checkreg(svend, PUC_REG_SVEND) && - checkreg(sprod, PUC_REG_SPROD)) - return (&puc_devices[i]); - } - -#undef checkreg - - return (NULL); -} - static int puc_find_free_unit(char *name) { ==== //depot/projects/uart/dev/puc/puc_pci.c#2 (text+ko) ==== @@ -79,6 +79,32 @@ #define PUC_ENTRAILS 1 #include <dev/puc/pucvar.h> +extern const struct puc_device_description puc_devices[]; + +int puc_config_win877(struct puc_softc *); + +static const struct puc_device_description * +puc_find_description(uint32_t vend, uint32_t prod, uint32_t svend, + uint32_t sprod) +{ + int i; + +#define checkreg(val, index) \ + (((val) & puc_devices[i].rmask[(index)]) == puc_devices[i].rval[(index)]) + + for (i = 0; puc_devices[i].name != NULL; i++) { + if (checkreg(vend, PUC_REG_VEND) && + checkreg(prod, PUC_REG_PROD) && + checkreg(svend, PUC_REG_SVEND) && + checkreg(sprod, PUC_REG_SPROD)) + return (&puc_devices[i]); + } + +#undef checkreg + + return (NULL); +} + static int puc_pci_probe(device_t dev) { ==== //depot/projects/uart/dev/puc/pucdata.c#2 (text+ko) ==== @@ -47,6 +47,8 @@ #define COM_FREQ DEFAULT_RCLK +int puc_config_win877(struct puc_softc *); + const struct puc_device_description puc_devices[] = { { "Comtrol RocketPort 550/4 RJ45", ==== //depot/projects/uart/dev/puc/pucvar.h#2 (text+ko) ==== @@ -93,6 +93,10 @@ #define PUC_PORT_TYPE_COM 1 #define PUC_PORT_TYPE_LPT 2 +/* UART subtypes. */ +#define PUC_PORT_COM_NS8250 (0<<8) +#define PUC_PORT_COM_SAB82532 (1<<8) + /* Interrupt Latch Register (ILR) types */ #define PUC_ILR_TYPE_NONE 0 #define PUC_ILR_TYPE_DIGI 1 @@ -100,12 +104,13 @@ #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) + ((port) < PUC_MAX_PORTS && (desc).ports[(port)].type != PUC_PORT_TYPE_NONE) #define PUC_MAX_BAR 6 enum puc_device_ivars { - PUC_IVAR_FREQ + PUC_IVAR_FREQ, + PUC_IVAR_SUBTYPE }; #ifdef PUC_ENTRAILS @@ -120,11 +125,9 @@ void (*)(void *), void *, void **); int puc_teardown_intr(device_t, device_t, struct resource *, void *); -const struct puc_device_description *puc_find_description(uint32_t, - uint32_t, uint32_t, uint32_t); struct puc_softc { - const struct puc_device_description *sc_desc; + struct puc_device_description sc_desc; /* card-global dynamic data */ int fastintr; @@ -153,6 +156,3 @@ }; #endif /* PUC_ENTRAILS */ - -int puc_config_win877(struct puc_softc *); -extern const struct puc_device_description puc_devices[];
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200306292327.h5TNRF2P017417>