Change the order of ata_dmainit/ata_allocate in preparation of

supporting new chipsets where this is needed.
This commit is contained in:
sos 2004-08-12 08:20:36 +00:00
parent 8745e98dd0
commit a71e43e2c6
4 changed files with 57 additions and 48 deletions

View File

@ -112,6 +112,19 @@ ata_probe(device_t dev)
if (ch->r_irq)
return EEXIST;
return 0;
}
int
ata_attach(device_t dev)
{
struct ata_channel *ch;
int error, rid;
if (!dev || !(ch = device_get_softc(dev)))
return ENXIO;
/* initialize the softc basics */
ch->device[MASTER].channel = ch;
ch->device[MASTER].unit = ATA_MASTER;
@ -126,17 +139,6 @@ ata_probe(device_t dev)
ch->locking(ch, ATA_LF_LOCK);
ch->hw.reset(ch);
ch->locking(ch, ATA_LF_UNLOCK);
return 0;
}
int
ata_attach(device_t dev)
{
struct ata_channel *ch;
int error, rid;
if (!dev || !(ch = device_get_softc(dev)))
return ENXIO;
rid = ATA_IRQ_RID;
ch->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
@ -151,9 +153,6 @@ ata_attach(device_t dev)
return error;
}
if (ch->dma)
ch->dma->alloc(ch);
/* initialize queue and associated lock */
bzero(&ch->queue_mtx, sizeof(struct mtx));
mtx_init(&ch->queue_mtx, "ATA queue lock", NULL, MTX_DEF);
@ -223,9 +222,6 @@ ata_detach(device_t dev)
ch->device[SLAVE].mode = ATA_PIO;
ch->devices = 0;
if (ch->dma)
ch->dma->free(ch);
bus_teardown_intr(dev, ch->r_irq, ch->ih);
bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq);
ch->r_irq = NULL;
@ -306,6 +302,7 @@ ata_suspend(device_t dev)
if (!dev || !(ch = device_get_softc(dev)))
return ENXIO;
ch->locking(ch, ATA_LF_LOCK);
ATA_SLEEPLOCK_CH(ch);
return 0;

View File

@ -185,7 +185,7 @@ ata_sata_setmode(struct ata_device *atadev, int mode)
* if we detect that the device isn't a real SATA device we limit
* the transfer mode to UDMA5/ATA100.
* this works around the problems some devices has with the
* Marvell SATA->PATA converters and UDMA6/ATA133.
* Marvell 88SX8030 SATA->PATA converters and UDMA6/ATA133.
*/
if (atadev->param->satacapabilities != 0x0000 &&
atadev->param->satacapabilities != 0xffff)
@ -1365,7 +1365,6 @@ ata_promise_mio_allocate(device_t dev, struct ata_channel *ch)
ch->r_io[ATA_IDX_ADDR].res = ctlr->r_res2;
ch->flags |= ATA_USE_16BIT;
ctlr->dmainit(ch);
ata_generic_hw(ch);
if (ctlr->chip->cfg2 & PRSX4X)
ch->hw.command = ata_promise_sx4_command;
@ -2141,8 +2140,7 @@ ata_sii_allocate(device_t dev, struct ata_channel *ch)
if (ctlr->chip->max_dma >= ATA_SA150)
ch->flags |= ATA_NO_SLAVE;
ctlr->dmainit(ch);
if (ctlr->chip->cfg2 & SIIBUG)
if ((ctlr->chip->cfg2 & SIIBUG) && ch->dma)
ch->dma->boundary = 8 * 1024;
ata_generic_hw(ch);

View File

@ -59,7 +59,7 @@ static MALLOC_DEFINE(M_ATADMA, "ATA DMA", "ATA driver DMA");
/* misc defines */
#define MAXSEGSZ PAGE_SIZE
#define MAXTABSZ PAGE_SIZE
#define MAXWSPCSZ 256
#define MAXWSPCSZ PAGE_SIZE
#define MAXCTLDMASZ (2 * (MAXTABSZ + MAXPHYS))
struct ata_dc_cb_args {

View File

@ -241,13 +241,8 @@ ata_pci_print_child(device_t dev, device_t child)
int retval = 0;
retval += bus_print_child_header(dev, child);
retval += printf(": at 0x%lx", rman_get_start(ch->r_io[ATA_IDX_ADDR].res));
if (ata_legacy(dev))
retval += printf(" irq %d", 14 + ch->unit);
retval += printf(": channel #%d", ch->unit);
retval += bus_print_child_footer(dev, child);
return retval;
}
@ -428,15 +423,6 @@ ata_pci_allocate(device_t dev, struct ata_channel *ch)
ch->r_io[i].res = ctlr->r_res1;
ch->r_io[i].offset = (i - ATA_BMCMD_PORT)+(ch->unit * ATA_BMIOSIZE);
}
/* if simplex controller, only allow DMA on primary channel */
ATA_IDX_OUTB(ch, ATA_BMSTAT_PORT, ATA_IDX_INB(ch, ATA_BMSTAT_PORT) &
(ATA_BMSTAT_DMA_MASTER | ATA_BMSTAT_DMA_SLAVE));
if (ch->unit > 0 &&
(ATA_IDX_INB(ch, ATA_BMSTAT_PORT) & ATA_BMSTAT_DMA_SIMPLEX))
device_printf(dev, "simplex device, DMA on primary only\n");
else
ctlr->dmainit(ch);
}
ata_generic_hw(ch);
@ -517,12 +503,11 @@ static devclass_t ata_pci_devclass;
DRIVER_MODULE(atapci, pci, ata_pci_driver, ata_pci_devclass, 0, 0);
static int
ata_pcisub_probe(device_t dev)
ata_channel_probe(device_t dev)
{
struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
struct ata_channel *ch = device_get_softc(dev);
device_t *children;
int count, error, i;
int count, i;
/* take care of green memory */
bzero(ch, sizeof(struct ata_channel));
@ -535,31 +520,60 @@ ata_pcisub_probe(device_t dev)
}
free(children, M_TEMP);
return ata_probe(dev);
}
static int
ata_channel_attach(device_t dev)
{
struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
struct ata_channel *ch = device_get_softc(dev);
int error;
ch->device[MASTER].setmode = ctlr->setmode;
ch->device[SLAVE].setmode = ctlr->setmode;
ch->locking = ctlr->locking;
ch->reset = ctlr->reset;
ctlr->dmainit(ch);
if (ch->dma)
ch->dma->alloc(ch);
if ((error = ctlr->allocate(dev, ch)))
return error;
return ata_probe(dev);
return ata_attach(dev);
}
static device_method_t ata_pcisub_methods[] = {
static int
ata_channel_detach(device_t dev)
{
struct ata_channel *ch = device_get_softc(dev);
int error;
if ((error = ata_detach(dev)))
return error;
if (ch->dma)
ch->dma->free(ch);
return 0;
}
static device_method_t ata_channel_methods[] = {
/* device interface */
DEVMETHOD(device_probe, ata_pcisub_probe),
DEVMETHOD(device_attach, ata_attach),
DEVMETHOD(device_detach, ata_detach),
DEVMETHOD(device_probe, ata_channel_probe),
DEVMETHOD(device_attach, ata_channel_attach),
DEVMETHOD(device_detach, ata_channel_detach),
DEVMETHOD(device_suspend, ata_suspend),
DEVMETHOD(device_resume, ata_resume),
{ 0, 0 }
};
static driver_t ata_pcisub_driver = {
static driver_t ata_channel_driver = {
"ata",
ata_pcisub_methods,
ata_channel_methods,
sizeof(struct ata_channel),
};
DRIVER_MODULE(ata, atapci, ata_pcisub_driver, ata_devclass, 0, 0);
DRIVER_MODULE(ata, atapci, ata_channel_driver, ata_devclass, 0, 0);