diff options
-rw-r--r-- | sys/arch/arm/arm/bus_dma.c | 162 | ||||
-rw-r--r-- | sys/arch/arm/cortex/cortex.c | 5 | ||||
-rw-r--r-- | sys/arch/arm/include/bus.h | 29 | ||||
-rw-r--r-- | sys/arch/arm/mainbus/mainbus.c | 5 | ||||
-rw-r--r-- | sys/arch/arm/simplebus/simplebus.c | 82 | ||||
-rw-r--r-- | sys/arch/arm/simplebus/simplebusvar.h | 5 | ||||
-rw-r--r-- | sys/arch/armv7/armv7/armv7.c | 5 | ||||
-rw-r--r-- | sys/arch/armv7/broadcom/bcm2835_dwctwo.c | 15 |
8 files changed, 107 insertions, 201 deletions
diff --git a/sys/arch/arm/arm/bus_dma.c b/sys/arch/arm/arm/bus_dma.c index 5f0f9898cf0..ffb5536ba0b 100644 --- a/sys/arch/arm/arm/bus_dma.c +++ b/sys/arch/arm/arm/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.39 2018/09/06 11:50:54 jsg Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.40 2020/04/29 15:25:07 kettenis Exp $ */ /* $NetBSD: bus_dma.c,v 1.38 2003/10/30 08:44:13 scw Exp $ */ /*- @@ -49,54 +49,8 @@ #include <machine/bus.h> #include <machine/cpu.h> - #include <arm/cpufunc.h> -int _bus_dmamap_load_buffer(bus_dma_tag_t, bus_dmamap_t, void *, - bus_size_t, struct proc *, int, paddr_t *, int *, int); -struct arm32_dma_range *_bus_dma_inrange(struct arm32_dma_range *, - int, bus_addr_t); - - -/* - * Check to see if the specified busaddr is in an allowed DMA range. - */ -static inline paddr_t -_bus_dma_busaddr_to_paddr(bus_dma_tag_t t, bus_addr_t curaddr) -{ - struct arm32_dma_range *dr; - u_int i; - - if (t->_nranges == 0) - return curaddr; - - for (i = 0, dr = t->_ranges; i < t->_nranges; i++, dr++) { - if (dr->dr_busbase <= curaddr - && round_page(curaddr) <= dr->dr_busbase + dr->dr_len) - return curaddr - dr->dr_busbase + dr->dr_sysbase; - } - panic("%s: curaddr %#lx not in range", __func__, curaddr); -} - -/* - * Check to see if the specified page is in an allowed DMA range. - */ -__inline struct arm32_dma_range * -_bus_dma_inrange(struct arm32_dma_range *ranges, int nranges, - bus_addr_t curaddr) -{ - struct arm32_dma_range *dr; - int i; - - for (i = 0, dr = ranges; i < nranges; i++, dr++) { - if (curaddr >= dr->dr_sysbase && - round_page(curaddr) <= (dr->dr_sysbase + dr->dr_len)) - return (dr); - } - - return (NULL); -} - /* * Common function for DMA map creation. May be called by bus-specific * DMA map creation functions. @@ -198,7 +152,7 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, map->_dm_flags |= ARM32_DMAMAP_COHERENT; seg = 0; - error = _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, + error = (*t->_dmamap_load_buffer)(t, map, buf, buflen, p, flags, &lastaddr, &seg, 1); if (error == 0) { map->dm_mapsize = buflen; @@ -220,9 +174,6 @@ int _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0, int flags) { -#if 0 - struct arm32_dma_range *dr; -#endif paddr_t lastaddr; int seg, error, first; struct mbuf *m; @@ -258,7 +209,7 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0, for (m = m0; m != NULL && error == 0; m = m->m_next) { if (m->m_len == 0) continue; - error = _bus_dmamap_load_buffer(t, map, m->m_data, m->m_len, + error = (*t->_dmamap_load_buffer)(t, map, m->m_data, m->m_len, NULL, flags, &lastaddr, &seg, first); first = 0; } @@ -320,7 +271,7 @@ _bus_dmamap_load_uio(bus_dma_tag_t t, bus_dmamap_t map, struct uio *uio, minlen = resid < iov[i].iov_len ? resid : iov[i].iov_len; addr = (caddr_t)iov[i].iov_base; - error = _bus_dmamap_load_buffer(t, map, addr, minlen, + error = (*t->_dmamap_load_buffer)(t, map, addr, minlen, p, flags, &lastaddr, &seg, first); first = 0; @@ -344,7 +295,6 @@ int _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs, int nsegs, bus_size_t size, int flags) { - struct arm32_dma_range *dr; bus_addr_t paddr, baddr, bmask, lastaddr = 0; bus_size_t plen, sgsize, mapsize; vaddr_t vaddr; @@ -379,23 +329,6 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, while (plen > 0) { /* - * Make sure we're in an allowed DMA range. - */ - if (t->_ranges != NULL) { - /* XXX cache last result? */ - dr = _bus_dma_inrange(t->_ranges, t->_nranges, - paddr); - if (dr == NULL) - return (EINVAL); - - /* - * In a valid DMA range. Translate the physical - * memory address to an address in the DMA window. - */ - paddr = (paddr - dr->dr_sysbase) + dr->dr_busbase; - } - - /* * Compute the segment size, and adjust counts. */ sgsize = PAGE_SIZE - ((u_long)paddr & PGOFSET); @@ -558,7 +491,7 @@ _bus_dmamap_sync_linear(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset, ds++; } - paddr_t pa = _bus_dma_busaddr_to_paddr(t, ds->ds_addr + offset); + paddr_t pa = ds->ds_addr + offset; size_t seglen = min(len, ds->ds_len - offset); _bus_dmamap_sync_segment(va + offset, pa, seglen, ops); @@ -595,7 +528,7 @@ _bus_dmamap_sync_mbuf(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset, */ vsize_t seglen = min(len, min(m->m_len - voff, ds->ds_len - ds_off)); vaddr_t va = mtod(m, vaddr_t) + voff; - paddr_t pa = _bus_dma_busaddr_to_paddr(t, ds->ds_addr + ds_off); + paddr_t pa = ds->ds_addr + ds_off; /* * We can save a lot of work here if we know the mapping @@ -650,7 +583,7 @@ _bus_dmamap_sync_uio(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset, */ vsize_t seglen = min(len, min(iov->iov_len - voff, ds->ds_len - ds_off)); vaddr_t va = (vaddr_t) iov->iov_base + voff; - paddr_t pa = _bus_dma_busaddr_to_paddr(t, ds->ds_addr + ds_off); + paddr_t pa = ds->ds_addr + ds_off; _bus_dmamap_sync_segment(va, pa, seglen, ops); @@ -673,7 +606,7 @@ _bus_dmamap_sync_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_addr_t offset, } vaddr_t va = ds->_ds_vaddr + offset; - paddr_t pa = _bus_dma_busaddr_to_paddr(t, ds->ds_addr + offset); + paddr_t pa = ds->ds_addr + offset; size_t seglen = min(len, ds->ds_len - offset); _bus_dmamap_sync_segment(va, pa, seglen, ops); @@ -795,8 +728,7 @@ _bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags) { - struct arm32_dma_range *dr; - int error, i; + int error; #ifdef DEBUG_DMA printf("dmamem_alloc t=%p size=%lx align=%lx boundary=%lx " @@ -804,22 +736,8 @@ _bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, boundary, segs, nsegs, rsegs, flags); #endif - if ((dr = t->_ranges) != NULL) { - error = ENOMEM; - for (i = 0; i < t->_nranges; i++, dr++) { - if (dr->dr_len == 0) - continue; - error = _bus_dmamem_alloc_range(t, size, alignment, - boundary, segs, nsegs, rsegs, flags, - trunc_page(dr->dr_sysbase), - trunc_page(dr->dr_sysbase + dr->dr_len) - 1); - if (error == 0) - break; - } - } else { - error = _bus_dmamem_alloc_range(t, size, alignment, boundary, - segs, nsegs, rsegs, flags, 0, -1); - } + error = _bus_dmamem_alloc_range(t, size, alignment, boundary, + segs, nsegs, rsegs, flags, 0, -1); #ifdef DEBUG_DMA printf("dmamem_alloc: =%d\n", error); @@ -987,7 +905,6 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf, bus_size_t buflen, struct proc *p, int flags, paddr_t *lastaddrp, int *segp, int first) { - struct arm32_dma_range *dr; bus_size_t sgsize; bus_addr_t curaddr, lastaddr, baddr, bmask; vaddr_t vaddr = (vaddr_t)buf; @@ -1052,23 +969,6 @@ _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf, } /* - * Make sure we're in an allowed DMA range. - */ - if (t->_ranges != NULL) { - /* XXX cache last result? */ - dr = _bus_dma_inrange(t->_ranges, t->_nranges, - curaddr); - if (dr == NULL) - return (EINVAL); - - /* - * In a valid DMA range. Translate the physical - * memory address to an address in the DMA window. - */ - curaddr = (curaddr - dr->dr_sysbase) + dr->dr_busbase; - } - - /* * Compute the segment size, and adjust counts. */ sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET); @@ -1200,46 +1100,6 @@ _bus_dmamem_alloc_range(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, } /* - * Check if a memory region intersects with a DMA range, and return the - * page-rounded intersection if it does. - */ -int -arm32_dma_range_intersect(struct arm32_dma_range *ranges, int nranges, - paddr_t pa, psize_t size, paddr_t *pap, psize_t *sizep) -{ - struct arm32_dma_range *dr; - int i; - - if (ranges == NULL) - return (0); - - for (i = 0, dr = ranges; i < nranges; i++, dr++) { - if (dr->dr_sysbase <= pa && - pa < (dr->dr_sysbase + dr->dr_len)) { - /* - * Beginning of region intersects with this range. - */ - *pap = trunc_page(pa); - *sizep = round_page(min(pa + size, - dr->dr_sysbase + dr->dr_len) - pa); - return (1); - } - if (pa < dr->dr_sysbase && dr->dr_sysbase < (pa + size)) { - /* - * End of region intersects with this range. - */ - *pap = trunc_page(dr->dr_sysbase); - *sizep = round_page(min((pa + size) - dr->dr_sysbase, - dr->dr_len)); - return (1); - } - } - - /* No intersection found. */ - return (0); -} - -/* * probably should be ppc_space_copy */ diff --git a/sys/arch/arm/cortex/cortex.c b/sys/arch/arm/cortex/cortex.c index d2d6aa508b6..3259001bd2b 100644 --- a/sys/arch/arm/cortex/cortex.c +++ b/sys/arch/arm/cortex/cortex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cortex.c,v 1.5 2016/05/02 08:15:55 patrick Exp $ */ +/* $OpenBSD: cortex.c,v 1.6 2020/04/29 15:25:07 kettenis Exp $ */ /* $NetBSD: mainbus.c,v 1.3 2001/06/13 17:52:43 nathanw Exp $ */ /* @@ -54,8 +54,6 @@ #include <arm/mainbus/mainbus.h> struct arm32_bus_dma_tag cortex_bus_dma_tag = { - 0, - 0, NULL, _bus_dmamap_create, _bus_dmamap_destroy, @@ -63,6 +61,7 @@ struct arm32_bus_dma_tag cortex_bus_dma_tag = { _bus_dmamap_load_mbuf, _bus_dmamap_load_uio, _bus_dmamap_load_raw, + _bus_dmamap_load_buffer, _bus_dmamap_unload, _bus_dmamap_sync, _bus_dmamem_alloc, diff --git a/sys/arch/arm/include/bus.h b/sys/arch/arm/include/bus.h index bb540d8acac..93ceb83b17c 100644 --- a/sys/arch/arm/include/bus.h +++ b/sys/arch/arm/include/bus.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bus.h,v 1.17 2017/05/08 00:27:45 dlg Exp $ */ +/* $OpenBSD: bus.h,v 1.18 2020/04/29 15:25:07 kettenis Exp $ */ /* $NetBSD: bus.h,v 1.12 2003/10/23 15:03:24 scw Exp $ */ /*- @@ -663,17 +663,6 @@ struct arm32_bus_dma_segment { typedef struct arm32_bus_dma_segment bus_dma_segment_t; /* - * arm32_dma_range - * - * This structure describes a valid DMA range. - */ -struct arm32_dma_range { - bus_addr_t dr_sysbase; /* system base address */ - bus_addr_t dr_busbase; /* appears here on bus */ - bus_size_t dr_len; /* length of range */ -}; - -/* * bus_dma_tag_t * * A machine-dependent opaque type describing the implementation of @@ -682,15 +671,6 @@ struct arm32_dma_range { struct arm32_bus_dma_tag { /* - * DMA range for this tag. If the page doesn't fall within - * one of these ranges, an error is returned. The caller - * may then decide what to do with the transfer. If the - * range pointer is NULL, it is ignored. - */ - struct arm32_dma_range *_ranges; - int _nranges; - - /* * Opaque cookie for use by back-end. */ void *_cookie; @@ -709,6 +689,8 @@ struct arm32_bus_dma_tag { struct uio *, int); int (*_dmamap_load_raw) (bus_dma_tag_t, bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int); + int (*_dmamap_load_buffer)(bus_dma_tag_t, bus_dmamap_t, void *, + bus_size_t, struct proc *, int, paddr_t *, int *, int); void (*_dmamap_unload) (bus_dma_tag_t, bus_dmamap_t); void (*_dmamap_sync) (bus_dma_tag_t, bus_dmamap_t, bus_addr_t, bus_size_t, int); @@ -794,9 +776,6 @@ struct arm32_bus_dmamap { #define ARM32_BUFTYPE_UIO 3 #define ARM32_BUFTYPE_RAW 4 -int arm32_dma_range_intersect(struct arm32_dma_range *, int, - paddr_t pa, psize_t size, paddr_t *pap, psize_t *sizep); - int _bus_dmamap_create (bus_dma_tag_t, bus_size_t, int, bus_size_t, bus_size_t, int, bus_dmamap_t *); void _bus_dmamap_destroy (bus_dma_tag_t, bus_dmamap_t); @@ -808,6 +787,8 @@ int _bus_dmamap_load_uio (bus_dma_tag_t, bus_dmamap_t, struct uio *, int); int _bus_dmamap_load_raw (bus_dma_tag_t, bus_dmamap_t, bus_dma_segment_t *, int, bus_size_t, int); +int _bus_dmamap_load_buffer(bus_dma_tag_t, bus_dmamap_t, void *, + bus_size_t, struct proc *, int, paddr_t *, int *, int); void _bus_dmamap_unload (bus_dma_tag_t, bus_dmamap_t); void _bus_dmamap_sync (bus_dma_tag_t, bus_dmamap_t, bus_addr_t, bus_size_t, int); diff --git a/sys/arch/arm/mainbus/mainbus.c b/sys/arch/arm/mainbus/mainbus.c index aa2e4436e7d..309a96ec42d 100644 --- a/sys/arch/arm/mainbus/mainbus.c +++ b/sys/arch/arm/mainbus/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.21 2019/10/23 09:27:43 patrick Exp $ */ +/* $OpenBSD: mainbus.c,v 1.22 2020/04/29 15:25:07 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> * Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org> @@ -60,8 +60,6 @@ struct cfdriver mainbus_cd = { }; struct arm32_bus_dma_tag mainbus_dma_tag = { - 0, - 0, NULL, _bus_dmamap_create, _bus_dmamap_destroy, @@ -69,6 +67,7 @@ struct arm32_bus_dma_tag mainbus_dma_tag = { _bus_dmamap_load_mbuf, _bus_dmamap_load_uio, _bus_dmamap_load_raw, + _bus_dmamap_load_buffer, _bus_dmamap_unload, _bus_dmamap_sync, _bus_dmamem_alloc, diff --git a/sys/arch/arm/simplebus/simplebus.c b/sys/arch/arm/simplebus/simplebus.c index 94feea46df2..e1bad2687e2 100644 --- a/sys/arch/arm/simplebus/simplebus.c +++ b/sys/arch/arm/simplebus/simplebus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: simplebus.c,v 1.15 2019/04/16 13:16:06 kettenis Exp $ */ +/* $OpenBSD: simplebus.c,v 1.16 2020/04/29 15:25:07 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> * @@ -32,6 +32,8 @@ void simplebus_attach(struct device *, struct device *, void *); void simplebus_attach_node(struct device *, int); int simplebus_bs_map(void *, uint64_t, bus_size_t, int, bus_space_handle_t *); +int simplebus_dmamap_load_buffer(bus_dma_tag_t, bus_dmamap_t, void *, + bus_size_t, struct proc *, int, paddr_t *, int *, int); struct cfattach simplebus_ca = { sizeof(struct simplebus_softc), simplebus_match, simplebus_attach @@ -88,12 +90,26 @@ simplebus_attach(struct device *parent, struct device *self, void *aux) sc->sc_bus.bs_map = simplebus_bs_map; sc->sc_rangeslen = OF_getproplen(sc->sc_node, "ranges"); - if (sc->sc_rangeslen > 0 && !(sc->sc_rangeslen % sizeof(uint32_t))) { + if (sc->sc_rangeslen > 0 && + (sc->sc_rangeslen % sizeof(uint32_t)) == 0) { sc->sc_ranges = malloc(sc->sc_rangeslen, M_TEMP, M_WAITOK); OF_getpropintarray(sc->sc_node, "ranges", sc->sc_ranges, sc->sc_rangeslen); } + memcpy(&sc->sc_dma, sc->sc_dmat, sizeof(sc->sc_dma)); + sc->sc_dma._dmamap_load_buffer = simplebus_dmamap_load_buffer; + sc->sc_dma._cookie = sc; + + sc->sc_dmarangeslen = OF_getproplen(sc->sc_node, "dma-ranges"); + if (sc->sc_dmarangeslen > 0 && + (sc->sc_dmarangeslen % sizeof(uint32_t)) == 0) { + sc->sc_dmaranges = malloc(sc->sc_dmarangeslen, + M_TEMP, M_WAITOK); + OF_getpropintarray(sc->sc_node, "dma-ranges", + sc->sc_dmaranges, sc->sc_dmarangeslen); + } + /* Scan the whole tree. */ sc->sc_early = 1; for (node = OF_child(sc->sc_node); node; node = OF_peer(node)) @@ -167,7 +183,7 @@ simplebus_attach_node(struct device *self, int node) fa.fa_name = ""; fa.fa_node = node; fa.fa_iot = &sc->sc_bus; - fa.fa_dmat = sc->sc_dmat; + fa.fa_dmat = &sc->sc_dma; fa.fa_acells = sc->sc_acells; fa.fa_scells = sc->sc_scells; @@ -279,3 +295,63 @@ simplebus_bs_map(void *t, uint64_t bpa, bus_size_t size, return ESRCH; } + +int +simplebus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf, + bus_size_t buflen, struct proc *p, int flags, paddr_t *lastaddrp, + int *segp, int first) +{ + struct simplebus_softc *sc = t->_cookie; + int rlen, rone, seg; + int firstseg = *segp; + int error; + + error = sc->sc_dmat->_dmamap_load_buffer(sc->sc_dmat, map, buf, buflen, + p, flags, lastaddrp, segp, first); + if (error) + return error; + + if (sc->sc_dmaranges == NULL) + return 0; + + rlen = sc->sc_dmarangeslen / sizeof(uint32_t); + rone = sc->sc_pacells + sc->sc_acells + sc->sc_scells; + + /* For each segment. */ + for (seg = firstseg; seg <= *segp; seg++) { + uint64_t addr, size, rfrom, rto, rsize; + uint32_t *range; + + addr = map->dm_segs[seg].ds_addr; + size = map->dm_segs[seg].ds_len; + + /* For each range. */ + for (range = sc->sc_dmaranges; rlen >= rone; + rlen -= rone, range += rone) { + /* Extract from and size, so we can see if we fit. */ + rfrom = range[sc->sc_acells]; + if (sc->sc_pacells == 2) + rfrom = (rfrom << 32) + range[sc->sc_acells + 1]; + + rsize = range[sc->sc_acells + sc->sc_pacells]; + if (sc->sc_scells == 2) + rsize = (rsize << 32) + + range[sc->sc_acells + sc->sc_pacells + 1]; + + /* Try next, if we're not in the range. */ + if (addr < rfrom || (addr + size) > (rfrom + rsize)) + continue; + + /* All good, extract to address and translate. */ + rto = range[0]; + if (sc->sc_acells == 2) + rto = (rto << 32) + range[1]; + + map->dm_segs[seg].ds_addr -= rfrom; + map->dm_segs[seg].ds_addr += rto; + break; + } + } + + return 0; +} diff --git a/sys/arch/arm/simplebus/simplebusvar.h b/sys/arch/arm/simplebus/simplebusvar.h index 0e044f5d2a2..dd6670dd143 100644 --- a/sys/arch/arm/simplebus/simplebusvar.h +++ b/sys/arch/arm/simplebus/simplebusvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: simplebusvar.h,v 1.2 2019/04/16 13:16:06 kettenis Exp $ */ +/* $OpenBSD: simplebusvar.h,v 1.3 2020/04/29 15:25:07 kettenis Exp $ */ /* * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> * @@ -25,8 +25,11 @@ struct simplebus_softc { int sc_pacells; int sc_pscells; struct bus_space sc_bus; + struct arm32_bus_dma_tag sc_dma; int *sc_ranges; int sc_rangeslen; + int *sc_dmaranges; + int sc_dmarangeslen; int sc_early; int sc_early_nodes[64]; }; diff --git a/sys/arch/armv7/armv7/armv7.c b/sys/arch/armv7/armv7/armv7.c index 8c7ec795bf8..036efcfad1b 100644 --- a/sys/arch/armv7/armv7/armv7.c +++ b/sys/arch/armv7/armv7/armv7.c @@ -1,4 +1,4 @@ -/* $OpenBSD: armv7.c,v 1.16 2020/04/07 09:32:44 kettenis Exp $ */ +/* $OpenBSD: armv7.c,v 1.17 2020/04/29 15:25:07 kettenis Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com> * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> @@ -27,8 +27,6 @@ #include <armv7/armv7/armv7_machdep.h> struct arm32_bus_dma_tag armv7_bus_dma_tag = { - 0, - 0, NULL, _bus_dmamap_create, _bus_dmamap_destroy, @@ -36,6 +34,7 @@ struct arm32_bus_dma_tag armv7_bus_dma_tag = { _bus_dmamap_load_mbuf, _bus_dmamap_load_uio, _bus_dmamap_load_raw, + _bus_dmamap_load_buffer, _bus_dmamap_unload, _bus_dmamap_sync, _bus_dmamem_alloc, diff --git a/sys/arch/armv7/broadcom/bcm2835_dwctwo.c b/sys/arch/armv7/broadcom/bcm2835_dwctwo.c index fce99723746..af5e55d31f7 100644 --- a/sys/arch/armv7/broadcom/bcm2835_dwctwo.c +++ b/sys/arch/armv7/broadcom/bcm2835_dwctwo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcm2835_dwctwo.c,v 1.3 2019/10/11 15:12:43 jsg Exp $ */ +/* $OpenBSD: bcm2835_dwctwo.c,v 1.4 2020/04/29 15:25:07 kettenis Exp $ */ /* * Copyright (c) 2015 Masao Uebayashi <uebayasi@tombiinc.com> * @@ -41,9 +41,6 @@ struct bcm_dwctwo_softc { struct dwc2_softc sc_dwc2; - struct arm32_bus_dma_tag sc_dmat; - struct arm32_dma_range sc_dmarange[1]; - void *sc_ih; }; @@ -101,21 +98,13 @@ bcm_dwctwo_attach(struct device *parent, struct device *self, void *aux) { struct bcm_dwctwo_softc *sc = (struct bcm_dwctwo_softc *)self; struct fdt_attach_args *faa = aux; - extern int physmem; int idx; printf("\n"); - memcpy(&sc->sc_dmat, faa->fa_dmat, sizeof(sc->sc_dmat)); - sc->sc_dmarange[0].dr_sysbase = 0; - sc->sc_dmarange[0].dr_busbase = 0xC0000000; - sc->sc_dmarange[0].dr_len = physmem * PAGE_SIZE; - sc->sc_dmat._ranges = sc->sc_dmarange; - sc->sc_dmat._nranges = 1; - sc->sc_dwc2.sc_iot = faa->fa_iot; sc->sc_dwc2.sc_bus.pipe_size = sizeof(struct usbd_pipe); - sc->sc_dwc2.sc_bus.dmatag = &sc->sc_dmat; + sc->sc_dwc2.sc_bus.dmatag = faa->fa_dmat; sc->sc_dwc2.sc_params = &bcm_dwctwo_params; if (bus_space_map(faa->fa_iot, faa->fa_reg[0].addr, |