diff options
author | sos <sos@FreeBSD.org> | 2003-11-11 14:55:36 +0000 |
---|---|---|
committer | sos <sos@FreeBSD.org> | 2003-11-11 14:55:36 +0000 |
commit | ebe00702c098c0916afe0d89edaa94a771bb84ba (patch) | |
tree | b93b5859823fc318c3edb66ca4d40ba5346ccfe6 /sys/dev/ata/ata-all.c | |
parent | d8c1d25645a2a83d9c7cd0415d462ddb33f11fa5 (diff) | |
download | FreeBSD-src-ebe00702c098c0916afe0d89edaa94a771bb84ba.zip FreeBSD-src-ebe00702c098c0916afe0d89edaa94a771bb84ba.tar.gz |
Centralise mode setting. Instead of doing it in all subdrivers, do
it in ata-all.c where it belongs.
Prime controller HW by always setting PIO mode first in attach.
Diffstat (limited to 'sys/dev/ata/ata-all.c')
-rw-r--r-- | sys/dev/ata/ata-all.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index a04f806..c5f1b44 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -73,6 +73,16 @@ static void btrim(int8_t *, int); static void bpack(int8_t *, int8_t *, int); static void ata_init(void); +/* global vars */ +struct intr_config_hook *ata_delayed_attach = NULL; +devclass_t ata_devclass; +int ata_wc = 1; + +/* local vars */ +static MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer"); +static int ata_dma = 1; +static int atapi_dma = 0; + /* sysctl vars */ SYSCTL_NODE(_hw, OID_AUTO, ata, CTLFLAG_RD, 0, "ATA driver parameters"); TUNABLE_INT("hw.ata.ata_dma", &ata_dma); @@ -84,16 +94,6 @@ SYSCTL_INT(_hw_ata, OID_AUTO, wc, CTLFLAG_RDTUN, &ata_wc, 0, TUNABLE_INT("hw.ata.atapi_dma", &atapi_dma); SYSCTL_INT(_hw_ata, OID_AUTO, atapi_dma, CTLFLAG_RDTUN, &atapi_dma, 0, "ATAPI device DMA mode control"); -int ata_dma = 1; -int ata_wc = 1; -int atapi_dma = 0; - -/* global vars */ -struct intr_config_hook *ata_delayed_attach = NULL; -devclass_t ata_devclass; - -/* local vars */ -static MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer"); /* * newbus device interface related functions @@ -675,6 +675,23 @@ ata_identify_devices(struct ata_channel *ch) } } } + + /* setup basic transfer mode by setting PIO mode and DMA if supported */ + if (ch->device[MASTER].attach) { + ch->device[MASTER].setmode(&ch->device[MASTER], ATA_PIO_MAX); + if ((((ch->devices & ATA_ATAPI_MASTER) && atapi_dma && + (ch->device[MASTER].param->config&ATA_DRQ_MASK) != ATA_DRQ_INTR)|| + ((ch->devices & ATA_ATA_MASTER) && ata_dma)) && ch->dma) + ch->device[MASTER].setmode(&ch->device[MASTER], ATA_DMA_MAX); + + } + if (ch->device[SLAVE].attach) { + ch->device[SLAVE].setmode(&ch->device[SLAVE], ATA_PIO_MAX); + if ((((ch->devices & ATA_ATAPI_SLAVE) && atapi_dma && + (ch->device[SLAVE].param->config&ATA_DRQ_MASK) != ATA_DRQ_INTR) || + ((ch->devices & ATA_ATA_SLAVE) && ata_dma)) && ch->dma) + ch->device[SLAVE].setmode(&ch->device[SLAVE], ATA_DMA_MAX); + } } static void |