1/*- 2 * Copyright (c) 1999 Matthew N. Dodd <winter@jurai.net> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * Based on aha_isa.c 27 */ 28 29#include <sys/cdefs.h>
| 1/*- 2 * Copyright (c) 1999 Matthew N. Dodd <winter@jurai.net> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * Based on aha_isa.c 27 */ 28 29#include <sys/cdefs.h>
|
93 94 desc = mca_match_id(id, aha_mca_devs); 95 if (!desc) 96 return (ENXIO); 97 device_set_desc(dev, desc); 98 99 pos = mca_pos_read(dev, AHA_MCA_IOPORT_POS); 100 iobase = AHA_MCA_IOPORT(pos); 101 iosize = AHA_MCA_IOPORT_SIZE; 102 103 pos = mca_pos_read(dev, AHA_MCA_DRQ_POS); 104 drq = AHA_MCA_DRQ(pos); 105 106 pos = mca_pos_read(dev, AHA_MCA_IRQ_POS); 107 irq = AHA_MCA_IRQ(pos); 108 109 mca_add_iospace(dev, iobase, iosize); 110 mca_add_drq(dev, drq); 111 mca_add_irq(dev, irq); 112 113 aha_unit++; 114 115 return (0); 116} 117 118static int 119aha_mca_attach (device_t dev) 120{ 121 struct aha_softc * sc = NULL; 122 struct resource * io = NULL; 123 struct resource * irq = NULL; 124 struct resource * drq = NULL; 125 int error = 0; 126 int unit = device_get_unit(dev); 127 int rid; 128 void * ih; 129 130 rid = 0; 131 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 132 0, ~0, 1, RF_ACTIVE); 133 if (!io) { 134 device_printf(dev, "No I/O space?!\n"); 135 error = ENOMEM; 136 goto bad; 137 } 138 139 rid = 0; 140 irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 141 0, ~0, 1, RF_ACTIVE); 142 if (irq == NULL) { 143 device_printf(dev, "No IRQ?!\n"); 144 error = ENOMEM; 145 goto bad; 146 } 147 148 rid = 0; 149 drq = bus_alloc_resource(dev, SYS_RES_DRQ, &rid, 150 0, ~0, 1, RF_ACTIVE); 151 if (drq == NULL) { 152 device_printf(dev, "No DRQ?!\n"); 153 error = ENOMEM; 154 goto bad; 155 } 156 157 sc = aha_alloc(unit, rman_get_bustag(io), rman_get_bushandle(io)); 158 if (sc == NULL) { 159 device_printf(dev, "aha_alloc() failed!\n"); 160 error = ENOMEM; 161 goto bad; 162 } 163 164 error = aha_probe(sc); 165 if (error) { 166 device_printf(dev, "aha_probe() failed!\n"); 167 goto bad; 168 } 169 170 error = aha_fetch_adapter_info(sc); 171 if (error) { 172 device_printf(dev, "aha_fetch_adapter_info() failed!\n"); 173 goto bad; 174 } 175 176 isa_dmacascade(rman_get_start(drq)); 177 178 error = bus_dma_tag_create( 179 /* parent */ NULL, 180 /* alignemnt */ 1, 181 /* boundary */ 0, 182 /* lowaddr */ BUS_SPACE_MAXADDR_24BIT, 183 /* highaddr */ BUS_SPACE_MAXADDR, 184 /* filter */ NULL, 185 /* filterarg */ NULL, 186 /* maxsize */ BUS_SPACE_MAXSIZE_24BIT, 187 /* nsegments */ ~0, 188 /* maxsegsz */ BUS_SPACE_MAXSIZE_24BIT, 189 /* flags */ 0, 190 /* lockfunc */ busdma_lock_mutex, 191 /* lockarg */ &Giant, 192 &sc->parent_dmat); 193 if (error) { 194 device_printf(dev, "bus_dma_tag_create() failed!\n"); 195 goto bad; 196 } 197 198 error = aha_init(sc); 199 if (error) { 200 device_printf(dev, "aha_init() failed\n"); 201 goto bad; 202 } 203 204 error = aha_attach(sc); 205 if (error) { 206 device_printf(dev, "aha_attach() failed\n"); 207 goto bad; 208 } 209 210 error = bus_setup_intr(dev, irq, INTR_TYPE_CAM|INTR_ENTROPY, aha_intr, sc, &ih); 211 if (error) { 212 device_printf(dev, "Unable to register interrupt handler\n"); 213 goto bad; 214 } 215 216 return (0); 217 218bad: 219 aha_free(sc); 220 221 if (io) 222 bus_release_resource(dev, SYS_RES_IOPORT, 0, io); 223 if (irq) 224 bus_release_resource(dev, SYS_RES_IRQ, 0, irq); 225 if (drq) 226 bus_release_resource(dev, SYS_RES_DRQ, 0, drq); 227 228 return (error); 229} 230 231static device_method_t aha_mca_methods[] = { 232 DEVMETHOD(device_probe, aha_mca_probe), 233 DEVMETHOD(device_attach, aha_mca_attach), 234 235 { 0, 0 } 236}; 237 238static driver_t aha_mca_driver = { 239 "aha", 240 aha_mca_methods, 241 1, 242/* 243 sizeof(struct aha_softc *), 244 */ 245}; 246 247static devclass_t aha_devclass; 248 249DRIVER_MODULE(aha, mca, aha_mca_driver, aha_devclass, 0, 0);
| 93 94 desc = mca_match_id(id, aha_mca_devs); 95 if (!desc) 96 return (ENXIO); 97 device_set_desc(dev, desc); 98 99 pos = mca_pos_read(dev, AHA_MCA_IOPORT_POS); 100 iobase = AHA_MCA_IOPORT(pos); 101 iosize = AHA_MCA_IOPORT_SIZE; 102 103 pos = mca_pos_read(dev, AHA_MCA_DRQ_POS); 104 drq = AHA_MCA_DRQ(pos); 105 106 pos = mca_pos_read(dev, AHA_MCA_IRQ_POS); 107 irq = AHA_MCA_IRQ(pos); 108 109 mca_add_iospace(dev, iobase, iosize); 110 mca_add_drq(dev, drq); 111 mca_add_irq(dev, irq); 112 113 aha_unit++; 114 115 return (0); 116} 117 118static int 119aha_mca_attach (device_t dev) 120{ 121 struct aha_softc * sc = NULL; 122 struct resource * io = NULL; 123 struct resource * irq = NULL; 124 struct resource * drq = NULL; 125 int error = 0; 126 int unit = device_get_unit(dev); 127 int rid; 128 void * ih; 129 130 rid = 0; 131 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 132 0, ~0, 1, RF_ACTIVE); 133 if (!io) { 134 device_printf(dev, "No I/O space?!\n"); 135 error = ENOMEM; 136 goto bad; 137 } 138 139 rid = 0; 140 irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 141 0, ~0, 1, RF_ACTIVE); 142 if (irq == NULL) { 143 device_printf(dev, "No IRQ?!\n"); 144 error = ENOMEM; 145 goto bad; 146 } 147 148 rid = 0; 149 drq = bus_alloc_resource(dev, SYS_RES_DRQ, &rid, 150 0, ~0, 1, RF_ACTIVE); 151 if (drq == NULL) { 152 device_printf(dev, "No DRQ?!\n"); 153 error = ENOMEM; 154 goto bad; 155 } 156 157 sc = aha_alloc(unit, rman_get_bustag(io), rman_get_bushandle(io)); 158 if (sc == NULL) { 159 device_printf(dev, "aha_alloc() failed!\n"); 160 error = ENOMEM; 161 goto bad; 162 } 163 164 error = aha_probe(sc); 165 if (error) { 166 device_printf(dev, "aha_probe() failed!\n"); 167 goto bad; 168 } 169 170 error = aha_fetch_adapter_info(sc); 171 if (error) { 172 device_printf(dev, "aha_fetch_adapter_info() failed!\n"); 173 goto bad; 174 } 175 176 isa_dmacascade(rman_get_start(drq)); 177 178 error = bus_dma_tag_create( 179 /* parent */ NULL, 180 /* alignemnt */ 1, 181 /* boundary */ 0, 182 /* lowaddr */ BUS_SPACE_MAXADDR_24BIT, 183 /* highaddr */ BUS_SPACE_MAXADDR, 184 /* filter */ NULL, 185 /* filterarg */ NULL, 186 /* maxsize */ BUS_SPACE_MAXSIZE_24BIT, 187 /* nsegments */ ~0, 188 /* maxsegsz */ BUS_SPACE_MAXSIZE_24BIT, 189 /* flags */ 0, 190 /* lockfunc */ busdma_lock_mutex, 191 /* lockarg */ &Giant, 192 &sc->parent_dmat); 193 if (error) { 194 device_printf(dev, "bus_dma_tag_create() failed!\n"); 195 goto bad; 196 } 197 198 error = aha_init(sc); 199 if (error) { 200 device_printf(dev, "aha_init() failed\n"); 201 goto bad; 202 } 203 204 error = aha_attach(sc); 205 if (error) { 206 device_printf(dev, "aha_attach() failed\n"); 207 goto bad; 208 } 209 210 error = bus_setup_intr(dev, irq, INTR_TYPE_CAM|INTR_ENTROPY, aha_intr, sc, &ih); 211 if (error) { 212 device_printf(dev, "Unable to register interrupt handler\n"); 213 goto bad; 214 } 215 216 return (0); 217 218bad: 219 aha_free(sc); 220 221 if (io) 222 bus_release_resource(dev, SYS_RES_IOPORT, 0, io); 223 if (irq) 224 bus_release_resource(dev, SYS_RES_IRQ, 0, irq); 225 if (drq) 226 bus_release_resource(dev, SYS_RES_DRQ, 0, drq); 227 228 return (error); 229} 230 231static device_method_t aha_mca_methods[] = { 232 DEVMETHOD(device_probe, aha_mca_probe), 233 DEVMETHOD(device_attach, aha_mca_attach), 234 235 { 0, 0 } 236}; 237 238static driver_t aha_mca_driver = { 239 "aha", 240 aha_mca_methods, 241 1, 242/* 243 sizeof(struct aha_softc *), 244 */ 245}; 246 247static devclass_t aha_devclass; 248 249DRIVER_MODULE(aha, mca, aha_mca_driver, aha_devclass, 0, 0);
|