Rearrange the way the reset code is called.

Prepare for different looking controllers.
This commit is contained in:
Søren Schmidt 2005-04-28 22:08:08 +00:00
parent e01de6cda3
commit 8dad6b7be5
6 changed files with 19 additions and 15 deletions

View File

@ -126,7 +126,7 @@ ata_attach(device_t dev)
/* reset the controller HW, the channel and device(s) */
while (ATA_LOCKING(dev, ATA_LF_LOCK) != ch->unit)
tsleep(&error, PRIBIO, "ataatch", 1);
ch->hw.reset(ch);
ATA_RESET(dev);
ATA_LOCKING(dev, ATA_LF_UNLOCK);
/* setup interrupt delivery */
@ -201,7 +201,7 @@ ata_reinit(device_t dev)
mtx_unlock(&ch->state_mtx);
/* reset the controller HW, the channel and device(s) */
ch->hw.reset(ch);
ATA_RESET(dev);
/* reinit the children and delete any that fails */
if (!device_get_children(dev, &children, &nchildren)) {

View File

@ -387,7 +387,6 @@ struct ata_dma {
struct ata_lowlevel {
int (*begin_transaction)(struct ata_request *request);
int (*end_transaction)(struct ata_request *request);
void (*reset)(struct ata_channel *ch);
int (*command)(struct ata_device *atadev, u_int8_t command, u_int64_t lba, u_int16_t count, u_int16_t feature);
};
@ -472,9 +471,10 @@ void ata_fail_requests(struct ata_channel *ch, device_t dev);
char *ata_cmd2str(struct ata_request *request);
/* ata-lowlevel.c: */
void ata_generic_hw(struct ata_channel *ch);
int ata_generic_command(struct ata_device *atadev, u_int8_t command, u_int64_t lba, u_int16_t count, u_int16_t feature);
int ata_getparam(device_t parent, struct ata_device *atadev, u_int8_t command);
void ata_generic_hw(struct ata_channel *ch);
void ata_generic_reset(struct ata_channel *ch);
int ata_generic_command(struct ata_device *atadev, u_int8_t command, u_int64_t lba, u_int16_t count, u_int16_t feature);
/* macros for alloc/free of struct ata_request */
extern uma_zone_t ata_request_zone;

View File

@ -1142,6 +1142,7 @@ ata_intel_reset(struct ata_channel *ch)
break;
ata_udelay(10000);
}
ata_generic_reset(ch);
}
static void
@ -2039,6 +2040,7 @@ ata_promise_mio_reset(struct ata_channel *ch)
(ATA_INL(ctlr->r_res2, 0xc012c) & ~0x00000f9f));
hpktp->busy = 0;
mtx_unlock(&hpktp->mtx);
ata_generic_reset(ch);
break;
case PRCMBO:
@ -2065,6 +2067,8 @@ ata_promise_mio_reset(struct ata_channel *ch)
/* reset and enable plug/unplug intr */
ATA_OUTL(ctlr->r_res2, 0x06c, (0x00000011 << ch->unit));
}
else
ata_generic_reset(ch);
break;
case PRCMBO2:
@ -2101,7 +2105,10 @@ ata_promise_mio_reset(struct ata_channel *ch)
/* set portmultiplier port */
ATA_OUTL(ctlr->r_res2, 0x4e8 + (ch->unit << 8), 0x00);
}
else
ata_generic_reset(ch);
break;
}
}

View File

@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
/* prototypes */
static int ata_begin_transaction(struct ata_request *);
static int ata_end_transaction(struct ata_request *);
static void ata_generic_reset(struct ata_channel *);
static int ata_wait(struct ata_channel *ch, struct ata_device *, u_int8_t);
static void ata_pio_read(struct ata_request *, int);
static void ata_pio_write(struct ata_request *, int);
@ -158,7 +157,6 @@ ata_generic_hw(struct ata_channel *ch)
{
ch->hw.begin_transaction = ata_begin_transaction;
ch->hw.end_transaction = ata_end_transaction;
ch->hw.reset = ata_generic_reset;
ch->hw.command = ata_generic_command;
}
@ -623,16 +621,13 @@ end_continue:
}
/* must be called with ATA channel locked */
static void
void
ata_generic_reset(struct ata_channel *ch)
{
u_int8_t ostat0 = 0, stat0 = 0, ostat1 = 0, stat1 = 0;
u_int8_t err = 0, lsb = 0, msb = 0;
int mask = 0, timeout;
/* reset controller (host) */
ATA_RESET(ch->dev);
/* do we have any signs of ATA/ATAPI HW being present ? */
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_MASTER);
DELAY(10);

View File

@ -574,6 +574,8 @@ ata_pcichannel_reset(device_t dev)
/* reset the controller HW */
if (ctlr->reset)
ctlr->reset(ch);
else
ata_generic_reset(ch);
}
static void

View File

@ -58,15 +58,15 @@ HEADER {
#define ATA_LF_WHICH 0x0004
};
METHOD void reset {
device_t channel;
};
METHOD void setmode {
device_t channel;
device_t dev;
};
METHOD void reset {
device_t channel;
} DEFAULT ata_generic_reset;
METHOD int reinit {
device_t dev;
};