diff options
author | mav <mav@FreeBSD.org> | 2009-12-06 00:10:13 +0000 |
---|---|---|
committer | mav <mav@FreeBSD.org> | 2009-12-06 00:10:13 +0000 |
commit | 6a3018e7cff16ab166672e276b4b39154ad09739 (patch) | |
tree | 8def18d183a8f2ec2847c5ef06fe2fac081d798e /sys/powerpc/powermac | |
parent | 9bb92ae41af45cc801f28a880e08648aad72e241 (diff) | |
download | FreeBSD-src-6a3018e7cff16ab166672e276b4b39154ad09739.zip FreeBSD-src-6a3018e7cff16ab166672e276b4b39154ad09739.tar.gz |
MFp4:
Introduce ATA_CAM kernel option, turning ata(4) controller drivers into
cam(4) interface modules. When enabled, this options deprecates all ata(4)
peripheral drivers (ad, acd, ...) and interfaces and allows cam(4) drivers
(ada, cd, ...) and interfaces to be natively used instead.
As side effect of this, ata(4) mode setting code was completely rewritten
to make controller API more strict and permit above change. While doing
this, SATA revision was separated from PATA mode. It allows DMA-incapable
SATA devices to operate and makes hw.ata.atapi_dma tunable work again.
Also allow ata(4) controller drivers (except some specific or broken ones)
to handle larger data transfers. Previous constraint of 64K was artificial
and is not really required by PCI ATA BM specification or hardware.
Submitted by: nwitehorn (powerpc part)
Diffstat (limited to 'sys/powerpc/powermac')
-rw-r--r-- | sys/powerpc/powermac/ata_dbdma.c | 3 | ||||
-rw-r--r-- | sys/powerpc/powermac/ata_kauai.c | 41 | ||||
-rw-r--r-- | sys/powerpc/powermac/ata_macio.c | 40 |
3 files changed, 33 insertions, 51 deletions
diff --git a/sys/powerpc/powermac/ata_dbdma.c b/sys/powerpc/powermac/ata_dbdma.c index b08ade6..c8f3758 100644 --- a/sys/powerpc/powermac/ata_dbdma.c +++ b/sys/powerpc/powermac/ata_dbdma.c @@ -204,7 +204,6 @@ static int ata_dbdma_load(struct ata_request *request, void *addr, int *entries) { struct ata_channel *ch = device_get_softc(request->parent); - struct ata_device *atadev = device_get_softc(request->dev); struct ata_dbdma_dmaload_args args; int error; @@ -230,7 +229,7 @@ ata_dbdma_load(struct ata_request *request, void *addr, int *entries) return EIO; } - request->dma = &ch->dma.slot[atadev->unit]; + request->dma = &ch->dma.slot[0]; if ((error = bus_dmamap_load(request->dma->data_tag, request->dma->data_map, request->data, request->bytecount, diff --git a/sys/powerpc/powermac/ata_kauai.c b/sys/powerpc/powermac/ata_kauai.c index 415d0fb..f7b6daa 100644 --- a/sys/powerpc/powermac/ata_kauai.c +++ b/sys/powerpc/powermac/ata_kauai.c @@ -85,7 +85,7 @@ __FBSDID("$FreeBSD$"); */ static int ata_kauai_probe(device_t dev); static int ata_kauai_attach(device_t dev); -static void ata_kauai_setmode(device_t parent, device_t dev); +static int ata_kauai_setmode(device_t dev, int target, int mode); static int ata_kauai_begin_transaction(struct ata_request *request); static device_method_t ata_kauai_methods[] = { @@ -307,34 +307,26 @@ ata_kauai_attach(device_t dev) return ata_attach(dev); } -static void -ata_kauai_setmode(device_t parent, device_t dev) +static int +ata_kauai_setmode(device_t dev, int target, int mode) { - struct ata_device *atadev = device_get_softc(dev); - struct ata_kauai_softc *sc = device_get_softc(parent); - uint32_t mode; - - mode = ata_limit_mode(dev,atadev->mode, - (sc->shasta) ? ATA_UDMA6 : ATA_UDMA5); - - if (ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode)) - return; + struct ata_kauai_softc *sc = device_get_softc(dev); - atadev->mode = mode; + mode = min(mode,sc->shasta ? ATA_UDMA6 : ATA_UDMA5); if (sc->shasta) { switch (mode & ATA_DMA_MASK) { case ATA_UDMA0: - sc->udmaconf[atadev->unit] + sc->udmaconf[target] = udma_timing_shasta[mode & ATA_MODE_MASK]; break; case ATA_WDMA0: - sc->udmaconf[atadev->unit] = 0; - sc->wdmaconf[atadev->unit] + sc->udmaconf[target] = 0; + sc->wdmaconf[target] = dma_timing_shasta[mode & ATA_MODE_MASK]; break; default: - sc->pioconf[atadev->unit] + sc->pioconf[target] = pio_timing_shasta[(mode & ATA_MODE_MASK) - ATA_PIO0]; break; @@ -342,32 +334,33 @@ ata_kauai_setmode(device_t parent, device_t dev) } else { switch (mode & ATA_DMA_MASK) { case ATA_UDMA0: - sc->udmaconf[atadev->unit] + sc->udmaconf[target] = udma_timing_kauai[mode & ATA_MODE_MASK]; break; case ATA_WDMA0: - sc->udmaconf[atadev->unit] = 0; - sc->wdmaconf[atadev->unit] + sc->udmaconf[target] = 0; + sc->wdmaconf[target] = dma_timing_kauai[mode & ATA_MODE_MASK]; break; default: - sc->pioconf[atadev->unit] + sc->pioconf[target] = pio_timing_kauai[(mode & ATA_MODE_MASK) - ATA_PIO0]; break; } } + + return (mode); } static int ata_kauai_begin_transaction(struct ata_request *request) { - struct ata_device *atadev = device_get_softc(request->dev); struct ata_kauai_softc *sc = device_get_softc(request->parent); - bus_write_4(sc->sc_memr, UDMA_CONFIG_REG, sc->udmaconf[atadev->unit]); + bus_write_4(sc->sc_memr, UDMA_CONFIG_REG, sc->udmaconf[request->unit]); bus_write_4(sc->sc_memr, PIO_CONFIG_REG, - sc->wdmaconf[atadev->unit] | sc->pioconf[atadev->unit]); + sc->wdmaconf[request->unit] | sc->pioconf[request->unit]); return ata_begin_transaction(request); } diff --git a/sys/powerpc/powermac/ata_macio.c b/sys/powerpc/powermac/ata_macio.c index 320e86e..447009d 100644 --- a/sys/powerpc/powermac/ata_macio.c +++ b/sys/powerpc/powermac/ata_macio.c @@ -111,7 +111,7 @@ static const struct ide_timings udma_timings[5] = { * Define the macio ata bus attachment. */ static int ata_macio_probe(device_t dev); -static void ata_macio_setmode(device_t parent, device_t dev); +static int ata_macio_setmode(device_t dev, int target, int mode); static int ata_macio_attach(device_t dev); static int ata_macio_begin_transaction(struct ata_request *request); @@ -193,7 +193,7 @@ ata_macio_probe(device_t dev) ata_default_registers(dev); ch->unit = 0; - ch->flags |= ATA_USE_16BIT; + ch->flags |= ATA_USE_16BIT | ATA_NO_ATAPI_DMA; ata_generic_hw(dev); return (ata_probe(dev)); @@ -247,26 +247,15 @@ ata_macio_attach(device_t dev) return ata_attach(dev); } -static void -ata_macio_setmode(device_t parent, device_t dev) +static int +ata_macio_setmode(device_t dev, int target, int mode) { - struct ata_device *atadev = device_get_softc(dev); - struct ata_macio_softc *sc = device_get_softc(parent); - int mode = atadev->mode; + struct ata_macio_softc *sc = device_get_softc(dev); int min_cycle = 0, min_active = 0; int cycle_tick = 0, act_tick = 0, inact_tick = 0, half_tick; - mode = ata_limit_mode(dev, mode, sc->max_mode); - - /* XXX Some controllers don't work correctly with ATAPI DMA */ - if (atadev->param.config & ATA_PROTO_ATAPI) - mode = ata_limit_mode(dev, mode, ATA_PIO_MAX); - - if (ata_controlcmd(dev, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode)) - return; - - atadev->mode = mode; + mode = min(mode, sc->max_mode); if ((mode & ATA_DMA_MASK) == ATA_UDMA0) { min_cycle = udma_timings[mode & ATA_MODE_MASK].cycle; @@ -276,7 +265,7 @@ ata_macio_setmode(device_t parent, device_t dev) act_tick = ATA_TIME_TO_TICK(sc->rev,min_active); /* mask: 0x1ff00000 */ - sc->udmaconf[atadev->unit] = + sc->udmaconf[target] = (cycle_tick << 21) | (act_tick << 25) | 0x100000; } else if ((mode & ATA_DMA_MASK) == ATA_WDMA0) { min_cycle = dma_timings[mode & ATA_MODE_MASK].cycle; @@ -288,7 +277,7 @@ ata_macio_setmode(device_t parent, device_t dev) if (sc->rev == 4) { inact_tick = cycle_tick - act_tick; /* mask: 0x001ffc00 */ - sc->wdmaconf[atadev->unit] = + sc->wdmaconf[target] = (act_tick << 10) | (inact_tick << 15); } else { inact_tick = cycle_tick - act_tick - DMA_REC_OFFSET; @@ -297,7 +286,7 @@ ata_macio_setmode(device_t parent, device_t dev) half_tick = 0; /* XXX */ /* mask: 0xfffff800 */ - sc->wdmaconf[atadev->unit] = (half_tick << 21) + sc->wdmaconf[target] = (half_tick << 21) | (inact_tick << 16) | (act_tick << 11); } } else { @@ -313,7 +302,7 @@ ata_macio_setmode(device_t parent, device_t dev) inact_tick = cycle_tick - act_tick; /* mask: 0x000003ff */ - sc->pioconf[atadev->unit] = + sc->pioconf[target] = (inact_tick << 5) | act_tick; } else { if (act_tick < PIO_ACT_MIN) @@ -324,21 +313,22 @@ ata_macio_setmode(device_t parent, device_t dev) inact_tick = PIO_REC_MIN; /* mask: 0x000007ff */ - sc->pioconf[atadev->unit] = + sc->pioconf[target] = (inact_tick << 5) | act_tick; } } + + return (mode); } static int ata_macio_begin_transaction(struct ata_request *request) { - struct ata_device *atadev = device_get_softc(request->dev); struct ata_macio_softc *sc = device_get_softc(request->parent); bus_write_4(sc->sc_mem, ATA_MACIO_TIMINGREG, - sc->udmaconf[atadev->unit] | sc->wdmaconf[atadev->unit] - | sc->pioconf[atadev->unit]); + sc->udmaconf[request->unit] | sc->wdmaconf[request->unit] + | sc->pioconf[request->unit]); return ata_begin_transaction(request); } |