dma_sbus.c (182062) | dma_sbus.c (182876) |
---|---|
1/* $OpenBSD: dma_sbus.c,v 1.12 2005/03/03 01:41:45 miod Exp $ */ 2/* $NetBSD: dma_sbus.c,v 1.5 2000/07/09 20:57:42 pk Exp $ */ 3 4/*- 5 * Copyright (c) 1998 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation --- 49 unchanged lines hidden (view full) --- 58 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 62 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 63 */ 64 65#include <sys/cdefs.h> | 1/* $OpenBSD: dma_sbus.c,v 1.12 2005/03/03 01:41:45 miod Exp $ */ 2/* $NetBSD: dma_sbus.c,v 1.5 2000/07/09 20:57:42 pk Exp $ */ 3 4/*- 5 * Copyright (c) 1998 The NetBSD Foundation, Inc. 6 * All rights reserved. 7 * 8 * This code is derived from software contributed to The NetBSD Foundation --- 49 unchanged lines hidden (view full) --- 58 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 59 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 60 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 61 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 62 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 63 */ 64 65#include <sys/cdefs.h> |
66__FBSDID("$FreeBSD: head/sys/sparc64/sbus/dma_sbus.c 182062 2008-08-23 15:20:33Z marius $"); | 66__FBSDID("$FreeBSD: head/sys/sparc64/sbus/dma_sbus.c 182876 2008-09-08 20:20:44Z marius $"); |
67 68#include <sys/param.h> 69#include <sys/systm.h> 70#include <sys/bus.h> 71#include <sys/kernel.h> 72#include <sys/module.h> | 67 68#include <sys/param.h> 69#include <sys/systm.h> 70#include <sys/bus.h> 71#include <sys/kernel.h> 72#include <sys/module.h> |
73#include <sys/resource.h> | |
74#include <sys/rman.h> 75 76#include <dev/ofw/ofw_bus.h> 77#include <dev/ofw/ofw_bus_subr.h> 78#include <dev/ofw/openfirm.h> 79 80#include <machine/bus.h> 81#include <machine/bus_common.h> --- 91 unchanged lines hidden (view full) --- 173 struct dma_softc *dsc; 174 struct lsi64854_softc *lsc; 175 struct dma_devinfo *ddi; 176 device_t cdev; 177 const char *name; 178 char *cabletype; 179 uint32_t csr; 180 phandle_t child, node; | 73#include <sys/rman.h> 74 75#include <dev/ofw/ofw_bus.h> 76#include <dev/ofw/ofw_bus_subr.h> 77#include <dev/ofw/openfirm.h> 78 79#include <machine/bus.h> 80#include <machine/bus_common.h> --- 91 unchanged lines hidden (view full) --- 172 struct dma_softc *dsc; 173 struct lsi64854_softc *lsc; 174 struct dma_devinfo *ddi; 175 device_t cdev; 176 const char *name; 177 char *cabletype; 178 uint32_t csr; 179 phandle_t child, node; |
181 int error, burst, children; | 180 int error, i; |
182 183 dsc = device_get_softc(dev); 184 lsc = &dsc->sc_lsi64854; 185 186 name = ofw_bus_get_name(dev); 187 node = ofw_bus_get_node(dev); 188 dsc->sc_ign = sbus_get_ign(dev); 189 dsc->sc_slot = sbus_get_slot(dev); 190 | 181 182 dsc = device_get_softc(dev); 183 lsc = &dsc->sc_lsi64854; 184 185 name = ofw_bus_get_name(dev); 186 node = ofw_bus_get_node(dev); 187 dsc->sc_ign = sbus_get_ign(dev); 188 dsc->sc_slot = sbus_get_slot(dev); 189 |
191 lsc->sc_rid = 0; 192 lsc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &lsc->sc_rid, | 190 i = 0; 191 lsc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &i, |
193 RF_ACTIVE); 194 if (lsc->sc_res == NULL) { 195 device_printf(dev, "cannot allocate resources\n"); 196 return (ENXIO); 197 } | 192 RF_ACTIVE); 193 if (lsc->sc_res == NULL) { 194 device_printf(dev, "cannot allocate resources\n"); 195 return (ENXIO); 196 } |
198 lsc->sc_regt = rman_get_bustag(lsc->sc_res); 199 lsc->sc_regh = rman_get_bushandle(lsc->sc_res); | |
200 201 if (strcmp(name, "espdma") == 0 || strcmp(name, "dma") == 0) 202 lsc->sc_channel = L64854_CHANNEL_SCSI; 203 else if (strcmp(name, "ledma") == 0) { 204 /* 205 * Check to see which cable type is currently active and 206 * set the appropriate bit in the ledma csr so that it 207 * gets used. If we didn't netboot, the PROM won't have --- 33 unchanged lines hidden (view full) --- 241 0, /* flags */ 242 NULL, NULL, /* no locking */ 243 &lsc->sc_parent_dmat); 244 if (error != 0) { 245 device_printf(dev, "cannot allocate parent DMA tag\n"); 246 goto fail_lres; 247 } 248 | 197 198 if (strcmp(name, "espdma") == 0 || strcmp(name, "dma") == 0) 199 lsc->sc_channel = L64854_CHANNEL_SCSI; 200 else if (strcmp(name, "ledma") == 0) { 201 /* 202 * Check to see which cable type is currently active and 203 * set the appropriate bit in the ledma csr so that it 204 * gets used. If we didn't netboot, the PROM won't have --- 33 unchanged lines hidden (view full) --- 238 0, /* flags */ 239 NULL, NULL, /* no locking */ 240 &lsc->sc_parent_dmat); 241 if (error != 0) { 242 device_printf(dev, "cannot allocate parent DMA tag\n"); 243 goto fail_lres; 244 } 245 |
249 burst = sbus_get_burstsz(dev); 250 lsc->sc_burst = (burst & SBUS_BURST_32) ? 32 : 251 (burst & SBUS_BURST_16) ? 16 : 0; | 246 i = sbus_get_burstsz(dev); 247 lsc->sc_burst = (i & SBUS_BURST_32) ? 32 : 248 (i & SBUS_BURST_16) ? 16 : 0; |
252 lsc->sc_dev = dev; 253 | 249 lsc->sc_dev = dev; 250 |
254 error = lsi64854_attach(lsc); 255 if (error != 0) { 256 device_printf(dev, "lsi64854_attach failed\n"); 257 goto fail_lpdma; 258 } 259 | |
260 /* Attach children. */ | 251 /* Attach children. */ |
261 children = 0; | 252 i = 0; |
262 for (child = OF_child(node); child != 0; child = OF_peer(child)) { 263 if ((ddi = dma_setup_dinfo(dev, dsc, child)) == NULL) 264 continue; | 253 for (child = OF_child(node); child != 0; child = OF_peer(child)) { 254 if ((ddi = dma_setup_dinfo(dev, dsc, child)) == NULL) 255 continue; |
265 if (children != 0) { | 256 if (i != 0) { |
266 device_printf(dev, 267 "<%s>: only one child per DMA channel supported\n", 268 ddi->ddi_obdinfo.obd_name); 269 dma_destroy_dinfo(ddi); 270 continue; 271 } 272 if ((cdev = device_add_child(dev, NULL, -1)) == NULL) { 273 device_printf(dev, "<%s>: device_add_child failed\n", 274 ddi->ddi_obdinfo.obd_name); 275 dma_destroy_dinfo(ddi); 276 continue; 277 } 278 device_set_ivars(cdev, ddi); | 257 device_printf(dev, 258 "<%s>: only one child per DMA channel supported\n", 259 ddi->ddi_obdinfo.obd_name); 260 dma_destroy_dinfo(ddi); 261 continue; 262 } 263 if ((cdev = device_add_child(dev, NULL, -1)) == NULL) { 264 device_printf(dev, "<%s>: device_add_child failed\n", 265 ddi->ddi_obdinfo.obd_name); 266 dma_destroy_dinfo(ddi); 267 continue; 268 } 269 device_set_ivars(cdev, ddi); |
279 children++; | 270 i++; |
280 } 281 return (bus_generic_attach(dev)); 282 | 271 } 272 return (bus_generic_attach(dev)); 273 |
283 fail_lpdma: 284 bus_dma_tag_destroy(lsc->sc_parent_dmat); | |
285 fail_lres: | 274 fail_lres: |
286 bus_release_resource(dev, SYS_RES_MEMORY, lsc->sc_rid, lsc->sc_res); | 275 bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(lsc->sc_res), 276 lsc->sc_res); |
287 return (error); 288} 289 290static struct dma_devinfo * 291dma_setup_dinfo(device_t dev, struct dma_softc *dsc, phandle_t node) 292{ 293 struct dma_devinfo *ddi; 294 struct sbus_regs *reg; --- 130 unchanged lines hidden --- | 277 return (error); 278} 279 280static struct dma_devinfo * 281dma_setup_dinfo(device_t dev, struct dma_softc *dsc, phandle_t node) 282{ 283 struct dma_devinfo *ddi; 284 struct sbus_regs *reg; --- 130 unchanged lines hidden --- |