2 * cyclades cyclom-y serial driver
3 * Andrew Herbert <andrew@werple.apana.org.au>, 17 August 1993
5 * SPDX-License-Identifier: BSD-3-Clause
7 * Copyright (c) 1993 Andrew Herbert.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. The name Andrew Herbert may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
24 * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 * Cyclades Y ISA serial interface driver
37 #include <sys/cdefs.h>
38 __FBSDID("$FreeBSD$");
40 #include <sys/param.h>
41 #include <sys/systm.h>
43 #include <sys/kernel.h>
44 #include <sys/module.h>
46 #include <machine/bus.h>
48 #include <machine/resource.h>
50 #include <isa/isavar.h>
52 #include <dev/cy/cyreg.h>
53 #include <dev/cy/cyvar.h>
55 static int cy_isa_attach(device_t dev);
56 static int cy_isa_probe(device_t dev);
58 static device_method_t cy_isa_methods[] = {
59 /* Device interface. */
60 DEVMETHOD(device_probe, cy_isa_probe),
61 DEVMETHOD(device_attach, cy_isa_attach),
66 static driver_t cy_isa_driver = {
72 DRIVER_MODULE(cy, isa, cy_isa_driver, cy_devclass, 0, 0);
75 cy_isa_probe(device_t dev)
77 struct resource *mem_res;
81 if (isa_get_logicalid(dev) != 0) /* skip PnP probes */
85 mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &mem_rid,
87 if (mem_res == NULL) {
88 device_printf(dev, "ioport resource allocation failed\n");
91 iobase = rman_get_virtual(mem_res);
93 /* Cyclom-16Y hardware reset (Cyclom-8Ys don't care) */
94 cy_inb(iobase, CY16_RESET, 0); /* XXX? */
95 DELAY(500); /* wait for the board to get its act together */
97 /* this is needed to get the board out of reset */
98 cy_outb(iobase, CY_CLEAR_INTR, 0, 0);
101 error = (cy_units(iobase, 0) == 0 ? ENXIO : 0);
102 bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);
107 cy_isa_attach(device_t dev)
109 struct resource *irq_res, *mem_res;
110 void *irq_cookie, *vaddr, *vsc;
111 int irq_rid, mem_rid;
117 mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &mem_rid,
119 if (mem_res == NULL) {
120 device_printf(dev, "memory resource allocation failed\n");
123 vaddr = rman_get_virtual(mem_res);
125 vsc = cyattach_common(vaddr, 0);
127 device_printf(dev, "no ports found!\n");
132 irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &irq_rid,
133 RF_SHAREABLE | RF_ACTIVE);
134 if (irq_res == NULL) {
135 device_printf(dev, "interrupt resource allocation failed\n");
138 if (bus_setup_intr(dev, irq_res, INTR_TYPE_TTY,
139 cyintr, NULL, vsc, &irq_cookie) != 0) {
140 device_printf(dev, "interrupt setup failed\n");
148 bus_release_resource(dev, SYS_RES_IRQ, irq_rid, irq_res);
150 bus_release_resource(dev, SYS_RES_MEMORY, mem_rid, mem_res);