Lines Matching +full:port +full:-
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
86 while (i < PUC_PCI_BARS && sc->sc_bar[i].b_rid != rid)
89 return (&sc->sc_bar[i]);
92 if (rid == -1)
96 bar = puc_get_bar(sc, -1);
99 bar->b_rid = rid;
100 bar->b_type = SYS_RES_IOPORT;
101 bar->b_res = bus_alloc_resource_any(sc->sc_dev, bar->b_type,
102 &bar->b_rid, RF_ACTIVE);
103 if (bar->b_res == NULL) {
104 bar->b_rid = rid;
105 bar->b_type = SYS_RES_MEMORY;
106 bar->b_res = bus_alloc_resource_any(sc->sc_dev, bar->b_type,
107 &bar->b_rid, RF_ACTIVE);
108 if (bar->b_res == NULL) {
109 bar->b_rid = -1;
115 rm = (bar->b_type == SYS_RES_IOPORT) ? &sc->sc_ioport : &sc->sc_iomem;
116 start = rman_get_start(bar->b_res);
117 end = rman_get_end(bar->b_res);
120 bus_release_resource(sc->sc_dev, bar->b_type, bar->b_rid,
121 bar->b_res);
122 bar->b_res = NULL;
123 bar->b_rid = -1;
133 struct puc_port *port;
144 devs = sc->sc_serdevs;
145 if (sc->sc_ilr == PUC_ILR_DIGI) {
148 ilr = ~bus_read_1(sc->sc_port[idx].p_rres, 7);
152 } else if (sc->sc_ilr == PUC_ILR_QUATECH) {
157 * lead to false positives on 8-port boards.
159 ilr = bus_read_1(sc->sc_port[0].p_rres, 7);
160 if (ilr != (sc->sc_cfg_data & 0xff))
177 port = &sc->sc_port[idx];
178 port->p_ipend = SERDEV_IPEND(port->p_dev);
179 ipend |= port->p_ipend;
196 port = &sc->sc_port[idx];
197 if (!(port->p_ipend & isrc))
199 if (port->p_ihsrc[i] != NULL)
200 (*port->p_ihsrc[i])(port->p_iharg);
214 struct puc_port *port;
227 sc->sc_bar[idx].b_rid = -1;
230 sc->sc_ioport.rm_type = RMAN_ARRAY;
231 error = rman_init(&sc->sc_ioport);
233 sc->sc_iomem.rm_type = RMAN_ARRAY;
234 error = rman_init(&sc->sc_iomem);
236 sc->sc_irq.rm_type = RMAN_ARRAY;
237 error = rman_init(&sc->sc_irq);
240 rman_fini(&sc->sc_iomem);
242 rman_fini(&sc->sc_ioport);
247 snprintf(buffer, sizeof(buffer), "%s I/O port mapping",
249 sc->sc_ioport.rm_descr = strdup(buffer, M_PUC);
252 sc->sc_iomem.rm_descr = strdup(buffer, M_PUC);
253 snprintf(buffer, sizeof(buffer), "%s port numbers",
255 sc->sc_irq.rm_descr = strdup(buffer, M_PUC);
259 sc->sc_nports = (int)res;
260 sc->sc_port = malloc(sc->sc_nports * sizeof(struct puc_port),
263 error = rman_manage_region(&sc->sc_irq, 1, sc->sc_nports);
271 for (idx = 0; idx < sc->sc_nports; idx++) {
272 port = &sc->sc_port[idx];
273 port->p_nr = idx + 1;
277 port->p_type = res;
286 port->p_bar = bar;
287 start = rman_get_start(bar->b_res);
296 rm = (bar->b_type == SYS_RES_IOPORT)
297 ? &sc->sc_ioport: &sc->sc_iomem;
298 port->p_rres = rman_reserve_resource(rm, start + ofs,
299 start + ofs + size - 1, size, 0, NULL);
300 if (port->p_rres != NULL) {
301 bsh = rman_get_bushandle(bar->b_res);
302 bst = rman_get_bustag(bar->b_res);
304 rman_set_bushandle(port->p_rres, bsh);
305 rman_set_bustag(port->p_rres, bst);
307 port->p_ires = rman_reserve_resource(&sc->sc_irq, port->p_nr,
308 port->p_nr, 1, 0, NULL);
309 if (port->p_ires == NULL) {
316 port->p_rclk = res;
318 port->p_dev = device_add_child(dev, NULL, DEVICE_UNIT_ANY);
319 if (port->p_dev != NULL)
320 device_set_ivars(port->p_dev, (void *)port);
326 sc->sc_ilr = res;
327 if (bootverbose && sc->sc_ilr != 0)
330 sc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sc_irid,
332 if (sc->sc_ires != NULL) {
333 error = bus_setup_intr(dev, sc->sc_ires,
334 INTR_TYPE_TTY, puc_intr, NULL, sc, &sc->sc_icookie);
336 error = bus_setup_intr(dev, sc->sc_ires,
338 (driver_intr_t *)puc_intr, sc, &sc->sc_icookie);
340 sc->sc_fastintr = 1;
344 bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irid,
345 sc->sc_ires);
346 sc->sc_ires = NULL;
349 if (sc->sc_ires == NULL) {
351 sc->sc_polled = 1;
355 for (idx = 0; idx < sc->sc_nports; idx++) {
356 port = &sc->sc_port[idx];
357 if (port->p_dev == NULL)
359 error = device_probe_and_attach(port->p_dev);
361 device_delete_child(dev, port->p_dev);
362 port->p_dev = NULL;
370 if (sc->sc_serdevs == 0UL)
371 bus_teardown_intr(dev, sc->sc_ires, sc->sc_icookie);
376 for (idx = 0; idx < sc->sc_nports; idx++) {
377 port = &sc->sc_port[idx];
378 if (port->p_dev != NULL)
379 device_delete_child(dev, port->p_dev);
380 if (port->p_rres != NULL)
381 rman_release_resource(port->p_rres);
382 if (port->p_ires != NULL)
383 rman_release_resource(port->p_ires);
386 bar = &sc->sc_bar[idx];
387 if (bar->b_res != NULL)
388 bus_release_resource(sc->sc_dev, bar->b_type,
389 bar->b_rid, bar->b_res);
391 rman_fini(&sc->sc_irq);
392 free(__DECONST(void *, sc->sc_irq.rm_descr), M_PUC);
393 rman_fini(&sc->sc_iomem);
394 free(__DECONST(void *, sc->sc_iomem.rm_descr), M_PUC);
395 rman_fini(&sc->sc_ioport);
396 free(__DECONST(void *, sc->sc_ioport.rm_descr), M_PUC);
397 free(sc->sc_port, M_PUC);
405 struct puc_port *port;
413 for (idx = 0; idx < sc->sc_nports; idx++) {
414 port = &sc->sc_port[idx];
415 if (port->p_dev == NULL)
417 if (device_delete_child(dev, port->p_dev) == 0) {
418 if (port->p_rres != NULL)
419 rman_release_resource(port->p_rres);
420 if (port->p_ires != NULL)
421 rman_release_resource(port->p_ires);
428 if (sc->sc_serdevs != 0UL)
429 bus_teardown_intr(dev, sc->sc_ires, sc->sc_icookie);
430 bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irid, sc->sc_ires);
433 bar = &sc->sc_bar[idx];
434 if (bar->b_res != NULL)
435 bus_release_resource(sc->sc_dev, bar->b_type,
436 bar->b_rid, bar->b_res);
439 rman_fini(&sc->sc_irq);
440 free(__DECONST(void *, sc->sc_irq.rm_descr), M_PUC);
441 rman_fini(&sc->sc_iomem);
442 free(__DECONST(void *, sc->sc_iomem.rm_descr), M_PUC);
443 rman_fini(&sc->sc_ioport);
444 free(__DECONST(void *, sc->sc_ioport.rm_descr), M_PUC);
445 free(sc->sc_port, M_PUC);
457 sc->sc_dev = dev;
458 sc->sc_cfg = cfg;
460 /* We don't attach to single-port serial cards. */
461 if (cfg->ports == PUC_PORT_1S || cfg->ports == PUC_PORT_1P)
478 struct puc_port *port;
490 port = device_get_ivars(child);
491 KASSERT(port != NULL, ("%s %d", __func__, __LINE__));
500 if (type == port->p_bar->b_type)
501 res = port->p_rres;
503 res = port->p_ires;
531 struct puc_port *port;
541 port = device_get_ivars(child);
542 KASSERT(port != NULL, ("%s %d", __func__, __LINE__));
547 if (res == port->p_ires) {
548 if (port->p_hasintr)
550 } else if (res != port->p_rres)
565 struct puc_port *port;
575 port = device_get_ivars(child);
576 KASSERT(port != NULL, ("%s %d", __func__, __LINE__));
578 if (type == port->p_bar->b_type)
579 res = port->p_rres;
581 res = port->p_ires;
592 *countp = rman_get_end(res) - start + 1;
600 struct puc_port *port;
614 port = device_get_ivars(child);
615 KASSERT(port != NULL, ("%s %d", __func__, __LINE__));
617 if (cookiep == NULL || res != port->p_ires)
620 if (port->p_type == PUC_TYPE_SERIAL && ihand != NULL)
622 if (rman_get_device(port->p_ires) != originator)
626 * Have non-serdev ports handled by the bus implementation. It
631 if (port->p_type == PUC_TYPE_SERIAL) {
634 port->p_ihsrc[i] = SERDEV_IHAND(originator, isrc);
635 if (port->p_ihsrc[i] != NULL)
642 sc->sc_ires, flags, filt, ihand, arg, cookiep));
644 sc->sc_serdevs |= 1UL << (port->p_nr - 1);
646 port->p_hasintr = 1;
647 port->p_iharg = arg;
649 *cookiep = port;
657 struct puc_port *port;
671 port = device_get_ivars(child);
672 KASSERT(port != NULL, ("%s %d", __func__, __LINE__));
674 if (res != port->p_ires)
676 if (rman_get_device(port->p_ires) != originator)
679 if (!port->p_hasintr)
681 sc->sc_ires, cookie));
683 if (cookie != port)
686 port->p_hasintr = 0;
687 port->p_iharg = NULL;
690 port->p_ihsrc[i] = NULL;
698 struct puc_port *port;
706 port = device_get_ivars(child);
707 KASSERT(port != NULL, ("%s %d", __func__, __LINE__));
714 *result = port->p_rclk;
717 *result = port->p_type;
728 struct puc_port *port;
731 port = device_get_ivars(child);
735 retval += printf(" at port %d", port->p_nr);
744 struct puc_port *port;
746 port = device_get_ivars(child);
747 sbuf_printf(sb, "port=%d", port->p_nr);
754 struct puc_port *port;
756 port = device_get_ivars(child);
757 sbuf_printf(sb, "type=%d", port->p_type);