dpt_eisa.c (104710) | dpt_eisa.c (112780) |
---|---|
1/*- 2 * Copyright (c) 1997, 2000 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 unchanged lines hidden (view full) --- 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 * | 1/*- 2 * Copyright (c) 1997, 2000 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 unchanged lines hidden (view full) --- 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 * $FreeBSD: head/sys/dev/dpt/dpt_eisa.c 104710 2002-10-09 08:54:32Z peter $ | 26 * $FreeBSD: head/sys/dev/dpt/dpt_eisa.c 112780 2003-03-29 08:30:45Z mdodd $ |
27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/kernel.h> 32#include <sys/module.h> 33#include <sys/bus.h> 34 35#include <machine/bus_pio.h> 36#include <machine/bus.h> 37#include <machine/resource.h> 38#include <sys/rman.h> 39 40#include <dev/eisa/eisaconf.h> 41 42#include <cam/scsi/scsi_all.h> 43 44#include <dev/dpt/dpt.h> 45 | 27 */ 28 29#include <sys/param.h> 30#include <sys/systm.h> 31#include <sys/kernel.h> 32#include <sys/module.h> 33#include <sys/bus.h> 34 35#include <machine/bus_pio.h> 36#include <machine/bus.h> 37#include <machine/resource.h> 38#include <sys/rman.h> 39 40#include <dev/eisa/eisaconf.h> 41 42#include <cam/scsi/scsi_all.h> 43 44#include <dev/dpt/dpt.h> 45 |
46#define DPT_EISA_IOSIZE 0x100 | 46#define DPT_EISA_IOSIZE 0x9 |
47#define DPT_EISA_SLOT_OFFSET 0x0c00 48#define DPT_EISA_EATA_REG_OFFSET 0x0088 49 50#define DPT_EISA_DPT2402 0x12142402 /* DPT PM2012A/9X */ 51#define DPT_EISA_DPTA401 0x1214A401 /* DPT PM2012B/9X */ 52#define DPT_EISA_DPTA402 0x1214A402 /* DPT PM2012B2/9X */ 53#define DPT_EISA_DPTA410 0x1214A410 /* DPT PM2x22A/9X */ 54#define DPT_EISA_DPTA411 0x1214A411 /* DPT Spectre */ --- 7 unchanged lines hidden (view full) --- 62#define DPT_EISA_DPT2408 0x12142408 /* ATT EATA SCSI */ 63 64/* Function Prototypes */ 65 66static const char * dpt_eisa_match (eisa_id_t); 67static int dpt_eisa_probe (device_t); 68static int dpt_eisa_attach (device_t); 69 | 47#define DPT_EISA_SLOT_OFFSET 0x0c00 48#define DPT_EISA_EATA_REG_OFFSET 0x0088 49 50#define DPT_EISA_DPT2402 0x12142402 /* DPT PM2012A/9X */ 51#define DPT_EISA_DPTA401 0x1214A401 /* DPT PM2012B/9X */ 52#define DPT_EISA_DPTA402 0x1214A402 /* DPT PM2012B2/9X */ 53#define DPT_EISA_DPTA410 0x1214A410 /* DPT PM2x22A/9X */ 54#define DPT_EISA_DPTA411 0x1214A411 /* DPT Spectre */ --- 7 unchanged lines hidden (view full) --- 62#define DPT_EISA_DPT2408 0x12142408 /* ATT EATA SCSI */ 63 64/* Function Prototypes */ 65 66static const char * dpt_eisa_match (eisa_id_t); 67static int dpt_eisa_probe (device_t); 68static int dpt_eisa_attach (device_t); 69 |
70 | |
71static int 72dpt_eisa_probe (device_t dev) 73{ 74 const char * desc; 75 u_int32_t io_base; 76 dpt_conf_t * conf; 77 78 desc = dpt_eisa_match(eisa_get_id(dev)); 79 if (!desc) 80 return (ENXIO); 81 device_set_desc(dev, desc); 82 | 70static int 71dpt_eisa_probe (device_t dev) 72{ 73 const char * desc; 74 u_int32_t io_base; 75 dpt_conf_t * conf; 76 77 desc = dpt_eisa_match(eisa_get_id(dev)); 78 if (!desc) 79 return (ENXIO); 80 device_set_desc(dev, desc); 81 |
83 io_base = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + DPT_EISA_SLOT_OFFSET; | 82 io_base = (eisa_get_slot(dev) * EISA_SLOT_SIZE) + 83 DPT_EISA_SLOT_OFFSET + 84 DPT_EISA_EATA_REG_OFFSET; |
84 | 85 |
85 conf = dpt_pio_get_conf(io_base + DPT_EISA_EATA_REG_OFFSET); | 86 conf = dpt_pio_get_conf(io_base); |
86 if (!conf) { 87 printf("dpt: dpt_pio_get_conf() failed.\n"); 88 return (ENXIO); 89 } 90 91 eisa_add_iospace(dev, io_base, DPT_EISA_IOSIZE, RESVADDR_NONE); 92 eisa_add_intr(dev, conf->IRQ, 93 (conf->IRQ_TR ? EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE)); 94 95 return 0; 96} 97 98static int 99dpt_eisa_attach (device_t dev) 100{ | 87 if (!conf) { 88 printf("dpt: dpt_pio_get_conf() failed.\n"); 89 return (ENXIO); 90 } 91 92 eisa_add_iospace(dev, io_base, DPT_EISA_IOSIZE, RESVADDR_NONE); 93 eisa_add_intr(dev, conf->IRQ, 94 (conf->IRQ_TR ? EISA_TRIGGER_LEVEL : EISA_TRIGGER_EDGE)); 95 96 return 0; 97} 98 99static int 100dpt_eisa_attach (device_t dev) 101{ |
101 dpt_softc_t * dpt; 102 struct resource *io = 0; 103 struct resource *irq = 0; | 102 dpt_softc_t * dpt; |
104 int s; | 103 int s; |
105 int rid; 106 void * ih; | |
107 int error = 0; 108 | 104 int error = 0; 105 |
109 rid = 0; 110 io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE); 111 if (!io) { 112 device_printf(dev, "No I/O space?!\n"); 113 error = ENOMEM; 114 goto bad; 115 } | 106 dpt = device_get_softc(dev); |
116 | 107 |
117 rid = 0; 118 irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, RF_ACTIVE); 119 if (!irq) { 120 device_printf(dev, "No irq?!\n"); 121 error = ENOMEM; 122 goto bad; 123 } | 108 dpt->io_rid = 0; 109 dpt->io_type = SYS_RES_IOPORT; 110 dpt->irq_rid = 0; |
124 | 111 |
125 dpt = dpt_alloc(dev, rman_get_bustag(io), 126 rman_get_bushandle(io) + DPT_EISA_EATA_REG_OFFSET); 127 if (dpt == NULL) { 128 error = ENOMEM; | 112 error = dpt_alloc_resources(dev); 113 if (error) { |
129 goto bad; 130 } 131 | 114 goto bad; 115 } 116 |
117 dpt_alloc(dev); 118 |
|
132 /* Allocate a dmatag representing the capabilities of this attachment */ 133 /* XXX Should be a child of the EISA bus dma tag */ 134 if (bus_dma_tag_create( /* parent */ NULL, 135 /* alignemnt */ 1, 136 /* boundary */ 0, 137 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT, 138 /* highaddr */ BUS_SPACE_MAXADDR, 139 /* filter */ NULL, 140 /* filterarg */ NULL, 141 /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, 142 /* nsegments */ ~0, 143 /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, 144 /* flags */0, 145 &dpt->parent_dmat) != 0) { | 119 /* Allocate a dmatag representing the capabilities of this attachment */ 120 /* XXX Should be a child of the EISA bus dma tag */ 121 if (bus_dma_tag_create( /* parent */ NULL, 122 /* alignemnt */ 1, 123 /* boundary */ 0, 124 /* lowaddr */ BUS_SPACE_MAXADDR_32BIT, 125 /* highaddr */ BUS_SPACE_MAXADDR, 126 /* filter */ NULL, 127 /* filterarg */ NULL, 128 /* maxsize */ BUS_SPACE_MAXSIZE_32BIT, 129 /* nsegments */ ~0, 130 /* maxsegsz */ BUS_SPACE_MAXSIZE_32BIT, 131 /* flags */0, 132 &dpt->parent_dmat) != 0) { |
146 dpt_free(dpt); | |
147 error = ENXIO; 148 goto bad; 149 } 150 151 s = splcam(); 152 153 if (dpt_init(dpt) != 0) { | 133 error = ENXIO; 134 goto bad; 135 } 136 137 s = splcam(); 138 139 if (dpt_init(dpt) != 0) { |
154 dpt_free(dpt); | 140 splx(s); |
155 error = ENXIO; 156 goto bad; 157 } 158 159 /* Register with the XPT */ 160 dpt_attach(dpt); 161 162 splx(s); 163 | 141 error = ENXIO; 142 goto bad; 143 } 144 145 /* Register with the XPT */ 146 dpt_attach(dpt); 147 148 splx(s); 149 |
164 if (bus_setup_intr(dev, irq, INTR_TYPE_CAM | INTR_ENTROPY, dpt_intr, 165 dpt, &ih)) { | 150 if (bus_setup_intr(dev, dpt->irq_res, INTR_TYPE_CAM | INTR_ENTROPY, 151 dpt_intr, dpt, &dpt->ih)) { |
166 device_printf(dev, "Unable to register interrupt handler\n"); 167 error = ENXIO; 168 goto bad; 169 } 170 171 return (error); 172 173 bad: | 152 device_printf(dev, "Unable to register interrupt handler\n"); 153 error = ENXIO; 154 goto bad; 155 } 156 157 return (error); 158 159 bad: |
174 if (io) 175 bus_release_resource(dev, SYS_RES_IOPORT, 0, io); 176 if (irq) 177 bus_release_resource(dev, SYS_RES_IRQ, 0, irq); | 160 dpt_release_resources(dev); |
178 | 161 |
162 if (dpt) 163 dpt_free(dpt); 164 |
|
179 return (error); 180} 181 182static const char * 183dpt_eisa_match(type) 184 eisa_id_t type; 185{ 186 switch (type) { --- 18 unchanged lines hidden (view full) --- 205 206 return (NULL); 207} 208 209static device_method_t dpt_eisa_methods[] = { 210 /* Device interface */ 211 DEVMETHOD(device_probe, dpt_eisa_probe), 212 DEVMETHOD(device_attach, dpt_eisa_attach), | 165 return (error); 166} 167 168static const char * 169dpt_eisa_match(type) 170 eisa_id_t type; 171{ 172 switch (type) { --- 18 unchanged lines hidden (view full) --- 191 192 return (NULL); 193} 194 195static device_method_t dpt_eisa_methods[] = { 196 /* Device interface */ 197 DEVMETHOD(device_probe, dpt_eisa_probe), 198 DEVMETHOD(device_attach, dpt_eisa_attach), |
199 DEVMETHOD(device_detach, dpt_detach), |
|
213 214 { 0, 0 } 215}; 216 217static driver_t dpt_eisa_driver = { 218 "dpt", 219 dpt_eisa_methods, 220 sizeof(dpt_softc_t), 221}; 222 | 200 201 { 0, 0 } 202}; 203 204static driver_t dpt_eisa_driver = { 205 "dpt", 206 dpt_eisa_methods, 207 sizeof(dpt_softc_t), 208}; 209 |
223static devclass_t dpt_devclass; 224 | |
225DRIVER_MODULE(dpt, eisa, dpt_eisa_driver, dpt_devclass, 0, 0); | 210DRIVER_MODULE(dpt, eisa, dpt_eisa_driver, dpt_devclass, 0, 0); |