diff options
author | nwhitehorn <nwhitehorn@FreeBSD.org> | 2008-09-23 02:12:47 +0000 |
---|---|---|
committer | nwhitehorn <nwhitehorn@FreeBSD.org> | 2008-09-23 02:12:47 +0000 |
commit | 4c77244de081407f9c0ca3df71360f80e6a0edd2 (patch) | |
tree | c455aad037341a9253ffbfdee47dc3338ecbc2ca | |
parent | 3c671d9bb6a8e709ab8fd0a8e3b874acf6ea4fac (diff) | |
download | FreeBSD-src-4c77244de081407f9c0ca3df71360f80e6a0edd2.zip FreeBSD-src-4c77244de081407f9c0ca3df71360f80e6a0edd2.tar.gz |
Change the DBDMA API to allow DBDMA registers in a subregion of a resource. This is necessary to allow future support of DMA for the various Apple on-board ATA controllers.
MFC after: 1 week
-rw-r--r-- | sys/dev/bm/if_bm.c | 4 | ||||
-rw-r--r-- | sys/powerpc/include/dbdma.h | 2 | ||||
-rw-r--r-- | sys/powerpc/powermac/dbdma.c | 14 | ||||
-rw-r--r-- | sys/powerpc/powermac/dbdmavar.h | 5 |
4 files changed, 14 insertions, 11 deletions
diff --git a/sys/dev/bm/if_bm.c b/sys/dev/bm/if_bm.c index 9f881e6..6c3789c 100644 --- a/sys/dev/bm/if_bm.c +++ b/sys/dev/bm/if_bm.c @@ -488,9 +488,9 @@ bm_attach(device_t dev) return (ENXIO); } - error = dbdma_allocate_channel(sc->sc_txdmar, bus_get_dma_tag(dev), + error = dbdma_allocate_channel(sc->sc_txdmar, 0, bus_get_dma_tag(dev), BM_MAX_DMA_COMMANDS, &sc->sc_txdma); - error += dbdma_allocate_channel(sc->sc_rxdmar, bus_get_dma_tag(dev), + error += dbdma_allocate_channel(sc->sc_rxdmar, 0, bus_get_dma_tag(dev), BM_MAX_DMA_COMMANDS, &sc->sc_rxdma); if (error) { diff --git a/sys/powerpc/include/dbdma.h b/sys/powerpc/include/dbdma.h index 0f035d4..becfbc8 100644 --- a/sys/powerpc/include/dbdma.h +++ b/sys/powerpc/include/dbdma.h @@ -78,7 +78,7 @@ typedef struct dbdma_command dbdma_command_t; struct dbdma_channel; typedef struct dbdma_channel dbdma_channel_t; -int dbdma_allocate_channel(struct resource *dbdma_regs, +int dbdma_allocate_channel(struct resource *dbdma_regs, u_int offset, bus_dma_tag_t parent_dma, int slots, dbdma_channel_t **chan); int dbdma_resize_channel(dbdma_channel_t *chan, int newslots); diff --git a/sys/powerpc/powermac/dbdma.c b/sys/powerpc/powermac/dbdma.c index 71bf417..edae6e2 100644 --- a/sys/powerpc/powermac/dbdma.c +++ b/sys/powerpc/powermac/dbdma.c @@ -56,8 +56,8 @@ dbdma_phys_callback(void *chan, bus_dma_segment_t *segs, int nsegs, int error) } int -dbdma_allocate_channel(struct resource *dbdma_regs, bus_dma_tag_t parent_dma, - int slots, dbdma_channel_t **chan) +dbdma_allocate_channel(struct resource *dbdma_regs, u_int offset, + bus_dma_tag_t parent_dma, int slots, dbdma_channel_t **chan) { int error = 0; dbdma_channel_t *channel; @@ -65,8 +65,8 @@ dbdma_allocate_channel(struct resource *dbdma_regs, bus_dma_tag_t parent_dma, channel = *chan = malloc(sizeof(struct dbdma_channel), M_DBDMA, M_WAITOK | M_ZERO); - channel->sc_bt = rman_get_bustag(dbdma_regs); - channel->sc_bh = rman_get_bushandle(dbdma_regs); + channel->sc_regs = dbdma_regs; + channel->sc_off = offset; dbdma_stop(channel); channel->sc_slots_pa = 0; @@ -82,6 +82,8 @@ dbdma_allocate_channel(struct resource *dbdma_regs, bus_dma_tag_t parent_dma, error = bus_dmamap_load(channel->sc_dmatag, channel->sc_dmamap, channel->sc_slots, PAGE_SIZE, dbdma_phys_callback, channel, 0); + dbdma_write_reg(channel, CHAN_CMDPTR_HI, 0); + channel->sc_nslots = slots; return (error); @@ -320,12 +322,12 @@ static uint32_t dbdma_read_reg(dbdma_channel_t *chan, u_int offset) { - return (bus_space_read_4(chan->sc_bt, chan->sc_bh, offset)); + return (bus_read_4(chan->sc_regs, chan->sc_off + offset)); } static void dbdma_write_reg(dbdma_channel_t *chan, u_int offset, uint32_t val) { - bus_space_write_4(chan->sc_bt, chan->sc_bh, offset, val); + bus_write_4(chan->sc_regs, chan->sc_off + offset, val); } diff --git a/sys/powerpc/powermac/dbdmavar.h b/sys/powerpc/powermac/dbdmavar.h index c69da13..88c3185 100644 --- a/sys/powerpc/powermac/dbdmavar.h +++ b/sys/powerpc/powermac/dbdmavar.h @@ -51,8 +51,8 @@ struct dbdma_command { }; struct dbdma_channel { - bus_space_tag_t sc_bt; - bus_space_handle_t sc_bh; + struct resource *sc_regs; + u_int sc_off; struct dbdma_command *sc_slots; int sc_nslots; @@ -78,6 +78,7 @@ struct dbdma_channel { #define CHAN_CONTROL_REG 0x00 #define CHAN_STATUS_REG 0x04 +#define CHAN_CMDPTR_HI 0x08 #define CHAN_CMDPTR 0x0C #define CHAN_INTR_SELECT 0x10 #define CHAN_BRANCH_SELECT 0x14 |