Deleted Added
full compact
si_eisa.c (67882) si_eisa.c (119419)
1/*
2 * Device driver for Specialix range (SI/XIO) of serial line multiplexors.
3 *
4 * Copyright (C) 2000, Peter Wemm <peter@netplex.com.au>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notices, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notices, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHORS BE LIABLE.
19 *
1/*
2 * Device driver for Specialix range (SI/XIO) of serial line multiplexors.
3 *
4 * Copyright (C) 2000, Peter Wemm <peter@netplex.com.au>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notices, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notices, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHORS BE LIABLE.
19 *
20 * $FreeBSD: head/sys/dev/si/si_eisa.c 67882 2000-10-29 13:57:19Z phk $
21 */
22
20 */
21
22#include <sys/cdefs.h>
23__FBSDID("$FreeBSD: head/sys/dev/si/si_eisa.c 119419 2003-08-24 18:03:45Z obrien $");
24
23#include <sys/param.h>
24#include <sys/systm.h>
25#include <sys/kernel.h>
26#include <sys/bus.h>
27#include <machine/bus.h>
28#include <sys/rman.h>
29#include <machine/resource.h>
30
31#include <dev/si/sireg.h>
32#include <dev/si/sivar.h>
33
34#include <dev/eisa/eisaconf.h>
35
36static int
37si_eisa_probe(device_t dev)
38{
39 u_long iobase;
40 u_long maddr;
41 int irq;
42
43 if (eisa_get_id(dev) != SIEISADEVID)
44 return ENXIO;
45
46 device_set_desc(dev, "Specialix SI/XIO EISA host card");
47
48 iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + SIEISABASE;
49 eisa_add_iospace(dev, iobase, SIEISAIOSIZE, RESVADDR_NONE);
50
51 maddr = (inb(iobase+1) << 24) | (inb(iobase) << 16);
52 eisa_add_mspace(dev, maddr, SIEISA_MEMSIZE, RESVADDR_NONE);
53
54 irq = ((inb(iobase+2) >> 4) & 0xf);
55 eisa_add_intr(dev, irq, EISA_TRIGGER_LEVEL); /* XXX shared? */
56
57 return (0);
58}
59
60static int
61si_eisa_attach(device_t dev)
62{
63 struct si_softc *sc;
64 void *ih;
65 int error;
66
67 error = 0;
68 ih = NULL;
69 sc = device_get_softc(dev);
70
71 sc->sc_type = SIEISA;
72
73 sc->sc_port_rid = 0;
74 sc->sc_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
75 &sc->sc_port_rid,
76 0, ~0, 1, RF_ACTIVE);
77 if (!sc->sc_port_res) {
78 device_printf(dev, "couldn't allocate ioports\n");
79 goto fail;
80 }
81 sc->sc_iobase = rman_get_start(sc->sc_port_res);
82
83 sc->sc_mem_rid = 0;
84 sc->sc_mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY,
85 &sc->sc_mem_rid,
86 0, ~0, 1, RF_ACTIVE);
87 if (!sc->sc_mem_res) {
88 device_printf(dev, "couldn't allocate iomemory");
89 goto fail;
90 }
91 sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res);
92 sc->sc_maddr = rman_get_virtual(sc->sc_mem_res);
93
94 sc->sc_irq_rid = 0;
95 sc->sc_irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->sc_irq_rid,
96 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
97 if (!sc->sc_irq_res) {
98 device_printf(dev, "couldn't allocate interrupt");
99 goto fail;
100 }
101 sc->sc_irq = rman_get_start(sc->sc_irq_res);
102 error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY,
103 si_intr, sc,&ih);
104 if (error) {
105 device_printf(dev, "couldn't activate interrupt");
106 goto fail;
107 }
108
109 error = siattach(dev);
110 if (error)
111 goto fail;
112 return (0); /* success */
113
114fail:
115 if (error == 0)
116 error = ENXIO;
117 if (sc->sc_irq_res) {
118 if (ih)
119 bus_teardown_intr(dev, sc->sc_irq_res, ih);
120 bus_release_resource(dev, SYS_RES_IRQ,
121 sc->sc_irq_rid, sc->sc_irq_res);
122 sc->sc_irq_res = 0;
123 }
124 if (sc->sc_mem_res) {
125 bus_release_resource(dev, SYS_RES_MEMORY,
126 sc->sc_mem_rid, sc->sc_mem_res);
127 sc->sc_mem_res = 0;
128 }
129 if (sc->sc_port_res) {
130 bus_release_resource(dev, SYS_RES_IOPORT,
131 sc->sc_port_rid, sc->sc_port_res);
132 sc->sc_port_res = 0;
133 }
134 return (error);
135}
136
137static device_method_t si_eisa_methods[] = {
138 /* Device interface */
139 DEVMETHOD(device_probe, si_eisa_probe),
140 DEVMETHOD(device_attach, si_eisa_attach),
141
142 { 0, 0 }
143};
144
145static driver_t si_eisa_driver = {
146 "si",
147 si_eisa_methods,
148 sizeof(struct si_softc),
149};
150
151DRIVER_MODULE(si, eisa, si_eisa_driver, si_devclass, 0, 0);
25#include <sys/param.h>
26#include <sys/systm.h>
27#include <sys/kernel.h>
28#include <sys/bus.h>
29#include <machine/bus.h>
30#include <sys/rman.h>
31#include <machine/resource.h>
32
33#include <dev/si/sireg.h>
34#include <dev/si/sivar.h>
35
36#include <dev/eisa/eisaconf.h>
37
38static int
39si_eisa_probe(device_t dev)
40{
41 u_long iobase;
42 u_long maddr;
43 int irq;
44
45 if (eisa_get_id(dev) != SIEISADEVID)
46 return ENXIO;
47
48 device_set_desc(dev, "Specialix SI/XIO EISA host card");
49
50 iobase = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + SIEISABASE;
51 eisa_add_iospace(dev, iobase, SIEISAIOSIZE, RESVADDR_NONE);
52
53 maddr = (inb(iobase+1) << 24) | (inb(iobase) << 16);
54 eisa_add_mspace(dev, maddr, SIEISA_MEMSIZE, RESVADDR_NONE);
55
56 irq = ((inb(iobase+2) >> 4) & 0xf);
57 eisa_add_intr(dev, irq, EISA_TRIGGER_LEVEL); /* XXX shared? */
58
59 return (0);
60}
61
62static int
63si_eisa_attach(device_t dev)
64{
65 struct si_softc *sc;
66 void *ih;
67 int error;
68
69 error = 0;
70 ih = NULL;
71 sc = device_get_softc(dev);
72
73 sc->sc_type = SIEISA;
74
75 sc->sc_port_rid = 0;
76 sc->sc_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT,
77 &sc->sc_port_rid,
78 0, ~0, 1, RF_ACTIVE);
79 if (!sc->sc_port_res) {
80 device_printf(dev, "couldn't allocate ioports\n");
81 goto fail;
82 }
83 sc->sc_iobase = rman_get_start(sc->sc_port_res);
84
85 sc->sc_mem_rid = 0;
86 sc->sc_mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY,
87 &sc->sc_mem_rid,
88 0, ~0, 1, RF_ACTIVE);
89 if (!sc->sc_mem_res) {
90 device_printf(dev, "couldn't allocate iomemory");
91 goto fail;
92 }
93 sc->sc_paddr = (caddr_t)rman_get_start(sc->sc_mem_res);
94 sc->sc_maddr = rman_get_virtual(sc->sc_mem_res);
95
96 sc->sc_irq_rid = 0;
97 sc->sc_irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->sc_irq_rid,
98 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE);
99 if (!sc->sc_irq_res) {
100 device_printf(dev, "couldn't allocate interrupt");
101 goto fail;
102 }
103 sc->sc_irq = rman_get_start(sc->sc_irq_res);
104 error = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_TTY,
105 si_intr, sc,&ih);
106 if (error) {
107 device_printf(dev, "couldn't activate interrupt");
108 goto fail;
109 }
110
111 error = siattach(dev);
112 if (error)
113 goto fail;
114 return (0); /* success */
115
116fail:
117 if (error == 0)
118 error = ENXIO;
119 if (sc->sc_irq_res) {
120 if (ih)
121 bus_teardown_intr(dev, sc->sc_irq_res, ih);
122 bus_release_resource(dev, SYS_RES_IRQ,
123 sc->sc_irq_rid, sc->sc_irq_res);
124 sc->sc_irq_res = 0;
125 }
126 if (sc->sc_mem_res) {
127 bus_release_resource(dev, SYS_RES_MEMORY,
128 sc->sc_mem_rid, sc->sc_mem_res);
129 sc->sc_mem_res = 0;
130 }
131 if (sc->sc_port_res) {
132 bus_release_resource(dev, SYS_RES_IOPORT,
133 sc->sc_port_rid, sc->sc_port_res);
134 sc->sc_port_res = 0;
135 }
136 return (error);
137}
138
139static device_method_t si_eisa_methods[] = {
140 /* Device interface */
141 DEVMETHOD(device_probe, si_eisa_probe),
142 DEVMETHOD(device_attach, si_eisa_attach),
143
144 { 0, 0 }
145};
146
147static driver_t si_eisa_driver = {
148 "si",
149 si_eisa_methods,
150 sizeof(struct si_softc),
151};
152
153DRIVER_MODULE(si, eisa, si_eisa_driver, si_devclass, 0, 0);