2002-09-27 19:35:29 +04:00
|
|
|
/* $NetBSD: atapi_wdc.c,v 1.55 2002/09/27 15:37:33 provos Exp $ */
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
/*
|
2001-12-03 03:20:22 +03:00
|
|
|
* Copyright (c) 1998, 2001 Manuel Bouyer.
|
1998-10-12 20:09:10 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
2002-04-24 00:41:13 +04:00
|
|
|
* This product includes software developed by Manuel Bouyer.
|
1998-10-12 20:09:10 +04:00
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
2000-05-15 12:48:25 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1998-10-12 20:09:10 +04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-11-13 09:54:32 +03:00
|
|
|
#include <sys/cdefs.h>
|
2002-09-27 19:35:29 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.55 2002/09/27 15:37:33 provos Exp $");
|
2001-11-13 09:54:32 +03:00
|
|
|
|
1999-02-21 03:52:04 +03:00
|
|
|
#ifndef WDCDEBUG
|
1998-10-12 20:09:10 +04:00
|
|
|
#define WDCDEBUG
|
1999-02-21 03:52:04 +03:00
|
|
|
#endif /* WDCDEBUG */
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/proc.h>
|
2001-01-22 10:00:39 +03:00
|
|
|
#include <sys/dvdio.h>
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
#include <machine/intr.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#ifndef __BUS_SPACE_HAS_STREAM_METHODS
|
|
|
|
#define bus_space_write_multi_stream_2 bus_space_write_multi_2
|
|
|
|
#define bus_space_write_multi_stream_4 bus_space_write_multi_4
|
|
|
|
#define bus_space_read_multi_stream_2 bus_space_read_multi_2
|
|
|
|
#define bus_space_read_multi_stream_4 bus_space_read_multi_4
|
|
|
|
#endif /* __BUS_SPACE_HAS_STREAM_METHODS */
|
|
|
|
|
|
|
|
#include <dev/ata/atareg.h>
|
|
|
|
#include <dev/ata/atavar.h>
|
|
|
|
#include <dev/ic/wdcreg.h>
|
|
|
|
#include <dev/ic/wdcvar.h>
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
#include <dev/scsipi/scsi_all.h> /* for SCSI status */
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
#define DEBUG_INTR 0x01
|
|
|
|
#define DEBUG_XFERS 0x02
|
|
|
|
#define DEBUG_STATUS 0x04
|
|
|
|
#define DEBUG_FUNCS 0x08
|
|
|
|
#define DEBUG_PROBE 0x10
|
|
|
|
#ifdef WDCDEBUG
|
1998-10-13 12:59:45 +04:00
|
|
|
int wdcdebug_atapi_mask = 0;
|
1998-10-12 20:09:10 +04:00
|
|
|
#define WDCDEBUG_PRINT(args, level) \
|
|
|
|
if (wdcdebug_atapi_mask & (level)) \
|
|
|
|
printf args
|
|
|
|
#else
|
|
|
|
#define WDCDEBUG_PRINT(args, level)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ATAPI_DELAY 10 /* 10 ms, this is used only before sending a cmd */
|
2001-04-25 21:53:04 +04:00
|
|
|
int wdc_atapi_get_params __P((struct scsipi_channel *, int, int,
|
|
|
|
struct ataparams *));
|
|
|
|
void wdc_atapi_probe_device __P((struct atapibus_softc *, int));
|
1998-10-12 20:09:10 +04:00
|
|
|
void wdc_atapi_minphys __P((struct buf *bp));
|
|
|
|
void wdc_atapi_start __P((struct channel_softc *,struct wdc_xfer *));
|
1999-04-02 01:46:28 +04:00
|
|
|
int wdc_atapi_intr __P((struct channel_softc *, struct wdc_xfer *, int));
|
1999-10-20 19:22:24 +04:00
|
|
|
void wdc_atapi_kill_xfer __P((struct channel_softc *, struct wdc_xfer *));
|
1999-04-02 01:46:28 +04:00
|
|
|
int wdc_atapi_ctrl __P((struct channel_softc *, struct wdc_xfer *, int));
|
2001-12-01 03:00:29 +03:00
|
|
|
void wdc_atapi_phase_complete __P((struct wdc_xfer *));
|
1998-10-12 20:09:10 +04:00
|
|
|
void wdc_atapi_done __P((struct channel_softc *, struct wdc_xfer *));
|
|
|
|
void wdc_atapi_reset __P((struct channel_softc *, struct wdc_xfer *));
|
2001-04-25 21:53:04 +04:00
|
|
|
void wdc_atapi_scsipi_request __P((struct scsipi_channel *,
|
|
|
|
scsipi_adapter_req_t, void *));
|
|
|
|
void wdc_atapi_kill_pending __P((struct scsipi_periph *));
|
2001-12-01 03:00:29 +03:00
|
|
|
void wdc_atapi_polldsc __P((void *arg));
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
#define MAX_SIZE MAXPHYS
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
const struct scsipi_bustype wdc_atapi_bustype = {
|
|
|
|
SCSIPI_BUSTYPE_ATAPI,
|
|
|
|
atapi_scsipi_cmd,
|
|
|
|
atapi_interpret_sense,
|
|
|
|
atapi_print_addr,
|
|
|
|
wdc_atapi_kill_pending,
|
|
|
|
};
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
void
|
|
|
|
wdc_atapibus_attach(chp)
|
|
|
|
struct channel_softc *chp;
|
|
|
|
{
|
|
|
|
struct wdc_softc *wdc = chp->wdc;
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_adapter *adapt = &wdc->sc_atapi_adapter._generic;
|
|
|
|
struct scsipi_channel *chan = &chp->ch_atapi_channel;
|
1998-10-12 20:09:10 +04:00
|
|
|
|
1998-11-20 00:53:32 +03:00
|
|
|
/*
|
2001-04-25 21:53:04 +04:00
|
|
|
* Fill in the scsipi_adapter.
|
1998-11-20 00:53:32 +03:00
|
|
|
*/
|
2001-04-25 21:53:04 +04:00
|
|
|
adapt->adapt_dev = &wdc->sc_dev;
|
|
|
|
adapt->adapt_nchannels = wdc->nchannels;
|
|
|
|
adapt->adapt_request = wdc_atapi_scsipi_request;
|
|
|
|
adapt->adapt_minphys = wdc_atapi_minphys;
|
2001-06-13 22:17:38 +04:00
|
|
|
if (wdc->cap & WDC_CAPABILITY_NOIRQ)
|
|
|
|
adapt->adapt_flags |= SCSIPI_ADAPT_POLL_ONLY;
|
2001-04-25 21:53:04 +04:00
|
|
|
wdc->sc_atapi_adapter.atapi_probe_device = wdc_atapi_probe_device;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in the scsipi_channel.
|
|
|
|
*/
|
|
|
|
memset(chan, 0, sizeof(*chan));
|
|
|
|
chan->chan_adapter = adapt;
|
|
|
|
chan->chan_bustype = &wdc_atapi_bustype;
|
|
|
|
chan->chan_channel = chp->channel;
|
|
|
|
chan->chan_flags = SCSIPI_CHAN_OPENINGS;
|
|
|
|
chan->chan_openings = 1;
|
|
|
|
chan->chan_max_periph = 1;
|
|
|
|
chan->chan_ntargets = 2;
|
|
|
|
chan->chan_nluns = 1;
|
|
|
|
|
2001-12-03 01:44:32 +03:00
|
|
|
chp->atapibus = config_found(&wdc->sc_dev, chan, atapiprint);
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-25 21:53:04 +04:00
|
|
|
wdc_atapi_minphys(bp)
|
|
|
|
struct buf *bp;
|
1998-10-12 20:09:10 +04:00
|
|
|
{
|
2001-04-25 21:53:04 +04:00
|
|
|
|
|
|
|
if (bp->b_bcount > MAX_SIZE)
|
1998-10-12 20:09:10 +04:00
|
|
|
bp->b_bcount = MAX_SIZE;
|
|
|
|
minphys(bp);
|
|
|
|
}
|
|
|
|
|
1999-10-20 19:22:24 +04:00
|
|
|
/*
|
2001-04-25 21:53:04 +04:00
|
|
|
* Kill off all pending xfers for a periph.
|
1999-10-20 19:22:24 +04:00
|
|
|
*
|
|
|
|
* Must be called at splbio().
|
|
|
|
*/
|
|
|
|
void
|
2001-04-25 21:53:04 +04:00
|
|
|
wdc_atapi_kill_pending(periph)
|
|
|
|
struct scsipi_periph *periph;
|
1999-10-20 19:22:24 +04:00
|
|
|
{
|
2001-04-25 21:53:04 +04:00
|
|
|
struct wdc_softc *wdc =
|
|
|
|
(void *)periph->periph_channel->chan_adapter->adapt_dev;
|
1999-10-20 19:22:24 +04:00
|
|
|
struct channel_softc *chp =
|
2001-04-25 21:53:04 +04:00
|
|
|
wdc->channels[periph->periph_channel->chan_channel];
|
1999-10-20 19:22:24 +04:00
|
|
|
|
|
|
|
wdc_kill_pending(chp);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wdc_atapi_kill_xfer(chp, xfer)
|
|
|
|
struct channel_softc *chp;
|
|
|
|
struct wdc_xfer *xfer;
|
|
|
|
{
|
|
|
|
struct scsipi_xfer *sc_xfer = xfer->cmd;
|
|
|
|
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_stop(&chp->ch_callout);
|
1999-10-20 19:22:24 +04:00
|
|
|
/* remove this command from xfer queue */
|
|
|
|
wdc_free_xfer(chp, xfer);
|
|
|
|
sc_xfer->error = XS_DRIVER_STUFFUP;
|
|
|
|
scsipi_done(sc_xfer);
|
|
|
|
}
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
int
|
2001-04-25 21:53:04 +04:00
|
|
|
wdc_atapi_get_params(chan, drive, flags, id)
|
|
|
|
struct scsipi_channel *chan;
|
|
|
|
int drive, flags;
|
1998-10-12 20:09:10 +04:00
|
|
|
struct ataparams *id;
|
|
|
|
{
|
2001-04-25 21:53:04 +04:00
|
|
|
struct wdc_softc *wdc = (void *)chan->chan_adapter->adapt_dev;
|
|
|
|
struct channel_softc *chp = wdc->channels[chan->chan_channel];
|
1998-10-12 20:09:10 +04:00
|
|
|
struct wdc_command wdc_c;
|
|
|
|
|
|
|
|
/* if no ATAPI device detected at wdc attach time, skip */
|
|
|
|
/*
|
|
|
|
* XXX this will break scsireprobe if this is of any interest for
|
|
|
|
* ATAPI devices one day.
|
|
|
|
*/
|
|
|
|
if ((chp->ch_drive[drive].drive_flags & DRIVE_ATAPI) == 0) {
|
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_get_params: drive %d not present\n",
|
|
|
|
drive), DEBUG_PROBE);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
memset(&wdc_c, 0, sizeof(struct wdc_command));
|
|
|
|
wdc_c.r_command = ATAPI_SOFT_RESET;
|
|
|
|
wdc_c.r_st_bmask = 0;
|
|
|
|
wdc_c.r_st_pmask = 0;
|
|
|
|
wdc_c.flags = AT_POLL;
|
|
|
|
wdc_c.timeout = WDC_RESET_WAIT;
|
|
|
|
if (wdc_exec_command(&chp->ch_drive[drive], &wdc_c) != WDC_COMPLETE) {
|
|
|
|
printf("wdc_atapi_get_params: ATAPI_SOFT_RESET failed for"
|
|
|
|
" drive %s:%d:%d: driver failed\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, drive);
|
|
|
|
panic("wdc_atapi_get_params");
|
|
|
|
}
|
|
|
|
if (wdc_c.flags & (AT_ERROR | AT_TIMEOU | AT_DF)) {
|
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_get_params: ATAPI_SOFT_RESET "
|
|
|
|
"failed for drive %s:%d:%d: error 0x%x\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, drive,
|
|
|
|
wdc_c.r_error), DEBUG_PROBE);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
chp->ch_drive[drive].state = 0;
|
|
|
|
|
|
|
|
bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_status);
|
|
|
|
|
|
|
|
/* Some ATAPI devices need a bit more time after software reset. */
|
|
|
|
delay(5000);
|
|
|
|
if (ata_get_params(&chp->ch_drive[drive], AT_POLL, id) != 0) {
|
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_get_params: ATAPI_IDENTIFY_DEVICE "
|
|
|
|
"failed for drive %s:%d:%d: error 0x%x\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, drive,
|
|
|
|
wdc_c.r_error), DEBUG_PROBE);
|
|
|
|
return -1;
|
|
|
|
}
|
2001-04-25 21:53:04 +04:00
|
|
|
return 0;
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
|
2000-04-01 18:32:22 +04:00
|
|
|
void
|
2001-04-25 21:53:04 +04:00
|
|
|
wdc_atapi_probe_device(sc, target)
|
|
|
|
struct atapibus_softc *sc;
|
2000-04-01 18:32:22 +04:00
|
|
|
int target;
|
|
|
|
{
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_channel *chan = sc->sc_channel;
|
|
|
|
struct scsipi_periph *periph;
|
2000-04-01 18:32:22 +04:00
|
|
|
struct ataparams ids;
|
|
|
|
struct ataparams *id = &ids;
|
2001-12-03 01:44:32 +03:00
|
|
|
struct wdc_softc *wdc = (void *)chan->chan_adapter->adapt_dev;
|
|
|
|
struct channel_softc *chp = wdc->channels[chan->chan_channel];
|
|
|
|
struct ata_drive_datas *drvp = &chp->ch_drive[target];
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipibus_attach_args sa;
|
2000-04-01 18:32:22 +04:00
|
|
|
char serial_number[21], model[41], firmware_revision[9];
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
/* skip if already attached */
|
|
|
|
if (scsipi_lookup_periph(chan, target, 0) != NULL)
|
2000-04-01 18:32:22 +04:00
|
|
|
return;
|
2001-04-25 21:53:04 +04:00
|
|
|
|
|
|
|
if (wdc_atapi_get_params(chan, target,
|
|
|
|
XS_CTL_POLL|XS_CTL_NOSLEEP, id) == 0) {
|
2000-04-01 18:32:22 +04:00
|
|
|
#ifdef ATAPI_DEBUG_PROBE
|
|
|
|
printf("%s drive %d: cmdsz 0x%x drqtype 0x%x\n",
|
2001-04-25 21:53:04 +04:00
|
|
|
sc->sc_dev.dv_xname, target,
|
2000-04-01 18:32:22 +04:00
|
|
|
id->atap_config & ATAPI_CFG_CMD_MASK,
|
|
|
|
id->atap_config & ATAPI_CFG_DRQ_MASK);
|
|
|
|
#endif
|
2001-04-25 21:53:04 +04:00
|
|
|
periph = scsipi_alloc_periph(M_NOWAIT);
|
|
|
|
if (periph == NULL) {
|
|
|
|
printf("%s: unable to allocate periph for drive %d\n",
|
|
|
|
sc->sc_dev.dv_xname, target);
|
|
|
|
return;
|
2000-04-01 18:32:22 +04:00
|
|
|
}
|
2001-04-25 21:53:04 +04:00
|
|
|
periph->periph_dev = NULL;
|
|
|
|
periph->periph_channel = chan;
|
|
|
|
periph->periph_switch = &atapi_probe_periphsw;
|
|
|
|
periph->periph_target = target;
|
|
|
|
periph->periph_lun = 0;
|
|
|
|
|
|
|
|
#ifdef SCSIPI_DEBUG
|
|
|
|
if (SCSIPI_DEBUG_TYPE == SCSIPI_BUSTYPE_ATAPI &&
|
|
|
|
SCSIPI_DEBUG_TARGET == target)
|
|
|
|
periph->periph_dbflags |= SCSIPI_DEBUG_FLAGS;
|
|
|
|
#endif
|
|
|
|
periph->periph_type = ATAPI_CFG_TYPE(id->atap_config);
|
|
|
|
if (id->atap_config & ATAPI_CFG_REMOV)
|
|
|
|
periph->periph_flags |= PERIPH_REMOVABLE;
|
2001-12-01 03:00:29 +03:00
|
|
|
if (periph->periph_type == T_SEQUENTIAL)
|
|
|
|
drvp->drive_flags |= DRIVE_ATAPIST;
|
2001-04-25 21:53:04 +04:00
|
|
|
|
|
|
|
sa.sa_periph = periph;
|
|
|
|
sa.sa_inqbuf.type = ATAPI_CFG_TYPE(id->atap_config);
|
|
|
|
sa.sa_inqbuf.removable = id->atap_config & ATAPI_CFG_REMOV ?
|
|
|
|
T_REMOV : T_FIXED;
|
2000-04-01 18:32:22 +04:00
|
|
|
scsipi_strvis(model, 40, id->atap_model, 40);
|
2001-04-25 21:53:04 +04:00
|
|
|
scsipi_strvis(serial_number, 20, id->atap_serial, 20);
|
2000-04-01 18:32:22 +04:00
|
|
|
scsipi_strvis(firmware_revision, 8, id->atap_revision, 8);
|
|
|
|
sa.sa_inqbuf.vendor = model;
|
|
|
|
sa.sa_inqbuf.product = serial_number;
|
|
|
|
sa.sa_inqbuf.revision = firmware_revision;
|
2001-04-25 21:53:04 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine the operating mode capabilities of the device.
|
|
|
|
*/
|
|
|
|
if ((id->atap_config & ATAPI_CFG_CMD_MASK) == ATAPI_CFG_CMD_16)
|
|
|
|
periph->periph_cap |= PERIPH_CAP_CMD16;
|
|
|
|
/* XXX This is gross. */
|
|
|
|
periph->periph_cap |= (id->atap_config & ATAPI_CFG_DRQ_MASK);
|
|
|
|
|
|
|
|
drvp->drv_softc = atapi_probe_device(sc, target, periph, &sa);
|
|
|
|
|
|
|
|
if (drvp->drv_softc)
|
2000-04-01 18:32:22 +04:00
|
|
|
wdc_probe_caps(drvp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
void
|
|
|
|
wdc_atapi_scsipi_request(chan, req, arg)
|
|
|
|
struct scsipi_channel *chan;
|
|
|
|
scsipi_adapter_req_t req;
|
|
|
|
void *arg;
|
1998-10-12 20:09:10 +04:00
|
|
|
{
|
2001-04-25 21:53:04 +04:00
|
|
|
struct scsipi_adapter *adapt = chan->chan_adapter;
|
|
|
|
struct scsipi_periph *periph;
|
|
|
|
struct scsipi_xfer *sc_xfer;
|
|
|
|
struct wdc_softc *wdc = (void *)adapt->adapt_dev;
|
1998-10-12 20:09:10 +04:00
|
|
|
struct wdc_xfer *xfer;
|
2001-04-25 21:53:04 +04:00
|
|
|
int channel = chan->chan_channel;
|
|
|
|
int drive, s;
|
|
|
|
|
|
|
|
switch (req) {
|
|
|
|
case ADAPTER_REQ_RUN_XFER:
|
|
|
|
sc_xfer = arg;
|
|
|
|
periph = sc_xfer->xs_periph;
|
|
|
|
drive = periph->periph_target;
|
|
|
|
|
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_scsipi_request %s:%d:%d\n",
|
|
|
|
wdc->sc_dev.dv_xname, channel, drive), DEBUG_XFERS);
|
|
|
|
if ((wdc->sc_dev.dv_flags & DVF_ACTIVE) == 0) {
|
|
|
|
sc_xfer->error = XS_DRIVER_STUFFUP;
|
|
|
|
scsipi_done(sc_xfer);
|
|
|
|
return;
|
|
|
|
}
|
2000-03-21 01:57:00 +03:00
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
xfer = wdc_get_xfer(WDC_NOSLEEP);
|
|
|
|
if (xfer == NULL) {
|
|
|
|
sc_xfer->error = XS_RESOURCE_SHORTAGE;
|
|
|
|
scsipi_done(sc_xfer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc_xfer->xs_control & XS_CTL_POLL)
|
|
|
|
xfer->c_flags |= C_POLL;
|
|
|
|
xfer->drive = drive;
|
|
|
|
xfer->c_flags |= C_ATAPI;
|
|
|
|
if (sc_xfer->cmd->opcode == GPCMD_REPORT_KEY ||
|
|
|
|
sc_xfer->cmd->opcode == GPCMD_SEND_KEY ||
|
|
|
|
sc_xfer->cmd->opcode == GPCMD_READ_DVD_STRUCTURE) {
|
|
|
|
/*
|
|
|
|
* DVD authentication commands must always be done in
|
|
|
|
* PIO mode.
|
|
|
|
*/
|
|
|
|
xfer->c_flags |= C_FORCEPIO;
|
|
|
|
}
|
2002-05-18 18:49:55 +04:00
|
|
|
/*
|
|
|
|
* DMA can't deal with transfers which are not a multiple of
|
|
|
|
* 2 bytes. It's a bug to request such transfers for ATAPI
|
|
|
|
* but as the request can come from userland, we have to
|
|
|
|
* protect against it.
|
2002-07-23 00:31:56 +04:00
|
|
|
* Also some devices seems to not handle DMA xfers of less than
|
|
|
|
* 4 bytes.
|
2002-05-18 18:49:55 +04:00
|
|
|
*/
|
2002-07-23 00:31:56 +04:00
|
|
|
if (sc_xfer->datalen < 4 || (sc_xfer->datalen & 0x01))
|
2002-05-18 18:49:55 +04:00
|
|
|
xfer->c_flags |= C_FORCEPIO;
|
|
|
|
|
2001-04-25 21:53:04 +04:00
|
|
|
xfer->cmd = sc_xfer;
|
|
|
|
xfer->databuf = sc_xfer->data;
|
|
|
|
xfer->c_bcount = sc_xfer->datalen;
|
|
|
|
xfer->c_start = wdc_atapi_start;
|
|
|
|
xfer->c_intr = wdc_atapi_intr;
|
|
|
|
xfer->c_kill_xfer = wdc_atapi_kill_xfer;
|
2001-12-01 03:00:29 +03:00
|
|
|
xfer->c_dscpoll = 0;
|
2001-04-25 21:53:04 +04:00
|
|
|
s = splbio();
|
|
|
|
wdc_exec_xfer(wdc->channels[channel], xfer);
|
1998-10-12 20:09:10 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
2001-04-25 21:53:04 +04:00
|
|
|
if ((sc_xfer->xs_control & XS_CTL_POLL) != 0 &&
|
|
|
|
(sc_xfer->xs_status & XS_STS_DONE) == 0)
|
|
|
|
panic("wdc_atapi_scsipi_request: polled command "
|
|
|
|
"not done");
|
1998-10-12 20:09:10 +04:00
|
|
|
#endif
|
2001-04-25 21:53:04 +04:00
|
|
|
splx(s);
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Not supported, nothing to do. */
|
2001-05-15 17:53:20 +04:00
|
|
|
;
|
2001-04-25 21:53:04 +04:00
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wdc_atapi_start(chp, xfer)
|
|
|
|
struct channel_softc *chp;
|
|
|
|
struct wdc_xfer *xfer;
|
|
|
|
{
|
|
|
|
struct scsipi_xfer *sc_xfer = xfer->cmd;
|
|
|
|
struct ata_drive_datas *drvp = &chp->ch_drive[xfer->drive];
|
|
|
|
|
1998-10-13 19:02:41 +04:00
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_start %s:%d:%d, scsi flags 0x%x \n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, drvp->drive,
|
1999-10-01 02:57:52 +04:00
|
|
|
sc_xfer->xs_control), DEBUG_XFERS);
|
1999-03-25 19:17:36 +03:00
|
|
|
/* Adjust C_DMA, it may have changed if we are requesting sense */
|
|
|
|
if ((drvp->drive_flags & (DRIVE_DMA | DRIVE_UDMA)) &&
|
2001-04-25 21:53:04 +04:00
|
|
|
sc_xfer->datalen > 0 && !(xfer->c_flags & C_FORCEPIO)) {
|
2000-01-17 03:01:00 +03:00
|
|
|
if (drvp->n_xfers <= NXFER)
|
|
|
|
drvp->n_xfers++;
|
1999-03-25 19:17:36 +03:00
|
|
|
xfer->c_flags |= C_DMA;
|
2000-01-17 03:01:00 +03:00
|
|
|
} else {
|
1999-03-25 19:17:36 +03:00
|
|
|
xfer->c_flags &= ~C_DMA;
|
2000-01-17 03:01:00 +03:00
|
|
|
}
|
1999-08-06 16:00:23 +04:00
|
|
|
/* start timeout machinery */
|
1999-10-01 02:57:52 +04:00
|
|
|
if ((sc_xfer->xs_control & XS_CTL_POLL) == 0)
|
2002-04-05 22:27:45 +04:00
|
|
|
callout_reset(&chp->ch_callout, mstohz(sc_xfer->timeout),
|
2000-03-23 10:01:25 +03:00
|
|
|
wdctimeout, chp);
|
1998-10-12 20:09:10 +04:00
|
|
|
/* Do control operations specially. */
|
|
|
|
if (drvp->state < READY) {
|
2000-04-01 18:32:22 +04:00
|
|
|
if (drvp->state != RESET) {
|
1998-10-12 20:09:10 +04:00
|
|
|
printf("%s:%d:%d: bad state %d in wdc_atapi_start\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel,
|
|
|
|
xfer->drive, drvp->state);
|
|
|
|
panic("wdc_atapi_start: bad state");
|
|
|
|
}
|
2000-04-01 18:32:22 +04:00
|
|
|
drvp->state = PIOMODE;
|
1999-04-02 01:46:28 +04:00
|
|
|
wdc_atapi_ctrl(chp, xfer, 0);
|
1998-10-12 20:09:10 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
|
|
|
|
WDSD_IBM | (xfer->drive << 4));
|
|
|
|
if (wait_for_unbusy(chp, ATAPI_DELAY) < 0) {
|
|
|
|
printf("wdc_atapi_start: not ready, st = %02x\n",
|
|
|
|
chp->ch_status);
|
1998-10-13 12:59:45 +04:00
|
|
|
sc_xfer->error = XS_TIMEOUT;
|
1998-10-12 20:09:10 +04:00
|
|
|
wdc_atapi_reset(chp, xfer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Even with WDCS_ERR, the device should accept a command packet
|
|
|
|
* Limit length to what can be stuffed into the cylinder register
|
|
|
|
* (16 bits). Some CD-ROMs seem to interpret '0' as 65536,
|
|
|
|
* but not all devices do that and it's not obvious from the
|
|
|
|
* ATAPI spec that that behaviour should be expected. If more
|
|
|
|
* data is necessary, multiple data transfer phases will be done.
|
|
|
|
*/
|
1998-10-13 19:02:41 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
wdccommand(chp, xfer->drive, ATAPI_PKT_CMD,
|
1999-11-05 00:16:53 +03:00
|
|
|
xfer->c_bcount <= 0xffff ? xfer->c_bcount : 0xffff,
|
1998-10-12 20:09:10 +04:00
|
|
|
0, 0, 0,
|
|
|
|
(xfer->c_flags & C_DMA) ? ATAPI_PKT_CMD_FTRE_DMA : 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there is no interrupt for CMD input, busy-wait for it (done in
|
|
|
|
* the interrupt routine. If it is a polled command, call the interrupt
|
|
|
|
* routine until command is done.
|
|
|
|
*/
|
2001-04-25 21:53:04 +04:00
|
|
|
if ((sc_xfer->xs_periph->periph_cap & ATAPI_CFG_DRQ_MASK) !=
|
1999-10-01 02:57:52 +04:00
|
|
|
ATAPI_CFG_IRQ_DRQ || (sc_xfer->xs_control & XS_CTL_POLL)) {
|
1998-10-12 20:09:10 +04:00
|
|
|
/* Wait for at last 400ns for status bit to be valid */
|
1999-04-02 01:46:28 +04:00
|
|
|
DELAY(1);
|
2001-04-25 21:53:04 +04:00
|
|
|
if (chp->ch_flags & WDCF_DMA_WAIT) {
|
|
|
|
wdc_dmawait(chp, xfer, sc_xfer->timeout);
|
|
|
|
chp->ch_flags &= ~WDCF_DMA_WAIT;
|
|
|
|
}
|
1999-04-02 01:46:28 +04:00
|
|
|
wdc_atapi_intr(chp, xfer, 0);
|
1999-04-08 15:29:01 +04:00
|
|
|
} else {
|
|
|
|
chp->ch_flags |= WDCF_IRQ_WAIT;
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
1999-10-01 02:57:52 +04:00
|
|
|
if (sc_xfer->xs_control & XS_CTL_POLL) {
|
|
|
|
while ((sc_xfer->xs_status & XS_STS_DONE) == 0) {
|
1998-10-12 20:09:10 +04:00
|
|
|
/* Wait for at last 400ns for status bit to be valid */
|
1999-04-02 01:46:28 +04:00
|
|
|
DELAY(1);
|
|
|
|
wdc_atapi_intr(chp, xfer, 0);
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-04-02 01:46:28 +04:00
|
|
|
wdc_atapi_intr(chp, xfer, irq)
|
1998-10-12 20:09:10 +04:00
|
|
|
struct channel_softc *chp;
|
|
|
|
struct wdc_xfer *xfer;
|
1999-04-02 01:46:28 +04:00
|
|
|
int irq;
|
1998-10-12 20:09:10 +04:00
|
|
|
{
|
|
|
|
struct scsipi_xfer *sc_xfer = xfer->cmd;
|
|
|
|
struct ata_drive_datas *drvp = &chp->ch_drive[xfer->drive];
|
|
|
|
int len, phase, i, retries=0;
|
2000-04-01 18:32:22 +04:00
|
|
|
int ire;
|
1998-10-12 20:09:10 +04:00
|
|
|
int dma_flags = 0;
|
1998-11-17 17:45:39 +03:00
|
|
|
void *cmd;
|
1998-10-12 20:09:10 +04:00
|
|
|
|
1998-10-13 19:02:41 +04:00
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_intr %s:%d:%d\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, drvp->drive), DEBUG_INTR);
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
/* Is it not a transfer, but a control operation? */
|
|
|
|
if (drvp->state < READY) {
|
|
|
|
printf("%s:%d:%d: bad state %d in wdc_atapi_intr\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive,
|
|
|
|
drvp->state);
|
2002-09-27 19:35:29 +04:00
|
|
|
panic("wdc_atapi_intr: bad state");
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
1999-08-06 16:00:23 +04:00
|
|
|
/*
|
|
|
|
* If we missed an interrupt in a PIO transfer, reset and restart.
|
|
|
|
* Don't try to continue transfer, we may have missed cycles.
|
|
|
|
*/
|
|
|
|
if ((xfer->c_flags & (C_TIMEOU | C_DMA)) == C_TIMEOU) {
|
|
|
|
sc_xfer->error = XS_TIMEOUT;
|
|
|
|
wdc_atapi_reset(chp, xfer);
|
1999-08-09 13:49:48 +04:00
|
|
|
return 1;
|
1999-08-06 16:00:23 +04:00
|
|
|
}
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
/* Ack interrupt done in wait_for_unbusy */
|
|
|
|
bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
|
|
|
|
WDSD_IBM | (xfer->drive << 4));
|
1999-03-25 19:17:36 +03:00
|
|
|
if (wait_for_unbusy(chp,
|
1999-04-02 01:46:28 +04:00
|
|
|
(irq == 0) ? sc_xfer->timeout : 0) != 0) {
|
|
|
|
if (irq && (xfer->c_flags & C_TIMEOU) == 0)
|
1999-03-25 19:17:36 +03:00
|
|
|
return 0; /* IRQ was not for us */
|
1999-02-02 15:59:31 +03:00
|
|
|
printf("%s:%d:%d: device timeout, c_bcount=%d, c_skip=%d\n",
|
1998-10-12 20:09:10 +04:00
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive,
|
|
|
|
xfer->c_bcount, xfer->c_skip);
|
2000-04-01 18:32:22 +04:00
|
|
|
if (xfer->c_flags & C_DMA) {
|
2000-01-17 03:01:00 +03:00
|
|
|
ata_dmaerr(drvp);
|
2000-04-01 18:32:22 +04:00
|
|
|
}
|
1998-10-13 12:59:45 +04:00
|
|
|
sc_xfer->error = XS_TIMEOUT;
|
1998-10-12 20:09:10 +04:00
|
|
|
wdc_atapi_reset(chp, xfer);
|
|
|
|
return 1;
|
|
|
|
}
|
2000-06-13 01:10:40 +04:00
|
|
|
if (chp->wdc->cap & WDC_CAPABILITY_IRQACK)
|
|
|
|
chp->wdc->irqack(chp);
|
|
|
|
|
2002-01-28 01:00:40 +03:00
|
|
|
/*
|
|
|
|
* If we missed an IRQ and were using DMA, flag it as a DMA error
|
|
|
|
* and reset device.
|
|
|
|
*/
|
2000-04-01 18:32:22 +04:00
|
|
|
if ((xfer->c_flags & C_TIMEOU) && (xfer->c_flags & C_DMA)) {
|
2000-01-17 03:01:00 +03:00
|
|
|
ata_dmaerr(drvp);
|
2002-01-28 01:00:40 +03:00
|
|
|
sc_xfer->error = XS_RESET;
|
|
|
|
wdc_atapi_reset(chp, xfer);
|
|
|
|
return (1);
|
2000-04-01 18:32:22 +04:00
|
|
|
}
|
1998-11-17 17:45:39 +03:00
|
|
|
/*
|
|
|
|
* if the request sense command was aborted, report the short sense
|
|
|
|
* previously recorded, else continue normal processing
|
|
|
|
*/
|
|
|
|
|
2000-04-01 18:32:22 +04:00
|
|
|
if (xfer->c_flags & C_DMA)
|
2001-04-25 21:53:04 +04:00
|
|
|
dma_flags = (sc_xfer->xs_control & XS_CTL_DATA_IN)
|
|
|
|
? WDC_DMA_READ : 0;
|
1998-10-12 20:09:10 +04:00
|
|
|
again:
|
|
|
|
len = bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_cyl_lo) +
|
|
|
|
256 * bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_cyl_hi);
|
|
|
|
ire = bus_space_read_1(chp->cmd_iot, chp->cmd_ioh, wd_ireason);
|
|
|
|
phase = (ire & (WDCI_CMD | WDCI_IN)) | (chp->ch_status & WDCS_DRQ);
|
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_intr: c_bcount %d len %d st 0x%x err 0x%x "
|
|
|
|
"ire 0x%x :", xfer->c_bcount,
|
|
|
|
len, chp->ch_status, chp->ch_error, ire), DEBUG_INTR);
|
|
|
|
|
|
|
|
switch (phase) {
|
|
|
|
case PHASE_CMDOUT:
|
2001-04-25 21:53:04 +04:00
|
|
|
cmd = sc_xfer->cmd;
|
1998-10-12 20:09:10 +04:00
|
|
|
WDCDEBUG_PRINT(("PHASE_CMDOUT\n"), DEBUG_INTR);
|
|
|
|
/* Init the DMA channel if necessary */
|
|
|
|
if (xfer->c_flags & C_DMA) {
|
|
|
|
if ((*chp->wdc->dma_init)(chp->wdc->dma_arg,
|
|
|
|
chp->channel, xfer->drive,
|
1998-11-17 17:45:39 +03:00
|
|
|
xfer->databuf, xfer->c_bcount, dma_flags) != 0) {
|
1998-10-12 20:09:10 +04:00
|
|
|
sc_xfer->error = XS_DRIVER_STUFFUP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* send packet command */
|
|
|
|
/* Commands are 12 or 16 bytes long. It's 32-bit aligned */
|
|
|
|
if ((chp->wdc->cap & WDC_CAPABILITY_ATAPI_NOSTREAM)) {
|
|
|
|
if (drvp->drive_flags & DRIVE_CAP32) {
|
|
|
|
bus_space_write_multi_4(chp->data32iot,
|
|
|
|
chp->data32ioh, 0,
|
1998-11-17 17:45:39 +03:00
|
|
|
(u_int32_t *)cmd,
|
1998-10-12 20:09:10 +04:00
|
|
|
sc_xfer->cmdlen >> 2);
|
|
|
|
} else {
|
|
|
|
bus_space_write_multi_2(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_data,
|
1998-11-17 17:45:39 +03:00
|
|
|
(u_int16_t *)cmd,
|
1998-10-12 20:09:10 +04:00
|
|
|
sc_xfer->cmdlen >> 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (drvp->drive_flags & DRIVE_CAP32) {
|
|
|
|
bus_space_write_multi_stream_4(chp->data32iot,
|
|
|
|
chp->data32ioh, 0,
|
1998-11-17 17:45:39 +03:00
|
|
|
(u_int32_t *)cmd,
|
1998-10-12 20:09:10 +04:00
|
|
|
sc_xfer->cmdlen >> 2);
|
|
|
|
} else {
|
|
|
|
bus_space_write_multi_stream_2(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_data,
|
1998-11-17 17:45:39 +03:00
|
|
|
(u_int16_t *)cmd,
|
1998-10-12 20:09:10 +04:00
|
|
|
sc_xfer->cmdlen >> 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Start the DMA channel if necessary */
|
|
|
|
if (xfer->c_flags & C_DMA) {
|
|
|
|
(*chp->wdc->dma_start)(chp->wdc->dma_arg,
|
2000-04-01 18:32:22 +04:00
|
|
|
chp->channel, xfer->drive);
|
|
|
|
chp->ch_flags |= WDCF_DMA_WAIT;
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
|
1999-10-01 02:57:52 +04:00
|
|
|
if ((sc_xfer->xs_control & XS_CTL_POLL) == 0) {
|
1998-10-12 20:09:10 +04:00
|
|
|
chp->ch_flags |= WDCF_IRQ_WAIT;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PHASE_DATAOUT:
|
|
|
|
/* write data */
|
|
|
|
WDCDEBUG_PRINT(("PHASE_DATAOUT\n"), DEBUG_INTR);
|
1999-10-01 02:57:52 +04:00
|
|
|
if ((sc_xfer->xs_control & XS_CTL_DATA_OUT) == 0 ||
|
1998-10-12 20:09:10 +04:00
|
|
|
(xfer->c_flags & C_DMA) != 0) {
|
1999-01-29 14:36:20 +03:00
|
|
|
printf("wdc_atapi_intr: bad data phase DATAOUT\n");
|
1998-10-12 20:09:10 +04:00
|
|
|
if (xfer->c_flags & C_DMA) {
|
2000-01-17 03:01:00 +03:00
|
|
|
ata_dmaerr(drvp);
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
1998-10-13 12:59:45 +04:00
|
|
|
sc_xfer->error = XS_TIMEOUT;
|
1998-10-12 20:09:10 +04:00
|
|
|
wdc_atapi_reset(chp, xfer);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (xfer->c_bcount < len) {
|
|
|
|
printf("wdc_atapi_intr: warning: write only "
|
|
|
|
"%d of %d requested bytes\n", xfer->c_bcount, len);
|
|
|
|
if ((chp->wdc->cap & WDC_CAPABILITY_ATAPI_NOSTREAM)) {
|
|
|
|
bus_space_write_multi_2(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_data,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int16_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1998-10-12 20:09:10 +04:00
|
|
|
xfer->c_bcount >> 1);
|
|
|
|
} else {
|
|
|
|
bus_space_write_multi_stream_2(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_data,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int16_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1998-10-12 20:09:10 +04:00
|
|
|
xfer->c_bcount >> 1);
|
|
|
|
}
|
|
|
|
for (i = xfer->c_bcount; i < len; i += 2)
|
|
|
|
bus_space_write_2(chp->cmd_iot, chp->cmd_ioh,
|
|
|
|
wd_data, 0);
|
|
|
|
xfer->c_skip += xfer->c_bcount;
|
|
|
|
xfer->c_bcount = 0;
|
|
|
|
} else {
|
|
|
|
if (drvp->drive_flags & DRIVE_CAP32) {
|
|
|
|
if ((chp->wdc->cap & WDC_CAPABILITY_ATAPI_NOSTREAM))
|
|
|
|
bus_space_write_multi_4(chp->data32iot,
|
|
|
|
chp->data32ioh, 0,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int32_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1999-01-08 21:10:35 +03:00
|
|
|
len >> 2);
|
1998-10-12 20:09:10 +04:00
|
|
|
else
|
1998-12-17 16:05:05 +03:00
|
|
|
bus_space_write_multi_stream_4(chp->data32iot,
|
|
|
|
chp->data32ioh, wd_data,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int32_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1999-01-08 21:10:35 +03:00
|
|
|
len >> 2);
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
xfer->c_skip += len & 0xfffffffc;
|
|
|
|
xfer->c_bcount -= len & 0xfffffffc;
|
|
|
|
len = len & 0x03;
|
|
|
|
}
|
|
|
|
if (len > 0) {
|
|
|
|
if ((chp->wdc->cap & WDC_CAPABILITY_ATAPI_NOSTREAM))
|
|
|
|
bus_space_write_multi_2(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_data,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int16_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1999-01-08 21:10:35 +03:00
|
|
|
len >> 1);
|
1998-10-12 20:09:10 +04:00
|
|
|
else
|
|
|
|
bus_space_write_multi_stream_2(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_data,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int16_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1999-01-08 21:10:35 +03:00
|
|
|
len >> 1);
|
1998-10-12 20:09:10 +04:00
|
|
|
xfer->c_skip += len;
|
|
|
|
xfer->c_bcount -= len;
|
|
|
|
}
|
|
|
|
}
|
1999-10-01 02:57:52 +04:00
|
|
|
if ((sc_xfer->xs_control & XS_CTL_POLL) == 0) {
|
1998-10-12 20:09:10 +04:00
|
|
|
chp->ch_flags |= WDCF_IRQ_WAIT;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PHASE_DATAIN:
|
|
|
|
/* Read data */
|
|
|
|
WDCDEBUG_PRINT(("PHASE_DATAIN\n"), DEBUG_INTR);
|
2001-04-25 21:53:04 +04:00
|
|
|
if ((sc_xfer->xs_control & XS_CTL_DATA_IN) == 0 ||
|
1998-10-12 20:09:10 +04:00
|
|
|
(xfer->c_flags & C_DMA) != 0) {
|
1999-01-29 14:36:20 +03:00
|
|
|
printf("wdc_atapi_intr: bad data phase DATAIN\n");
|
1998-10-12 20:09:10 +04:00
|
|
|
if (xfer->c_flags & C_DMA) {
|
2000-01-17 03:01:00 +03:00
|
|
|
ata_dmaerr(drvp);
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
1998-10-13 12:59:45 +04:00
|
|
|
sc_xfer->error = XS_TIMEOUT;
|
1998-10-12 20:09:10 +04:00
|
|
|
wdc_atapi_reset(chp, xfer);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (xfer->c_bcount < len) {
|
|
|
|
printf("wdc_atapi_intr: warning: reading only "
|
|
|
|
"%d of %d bytes\n", xfer->c_bcount, len);
|
|
|
|
if ((chp->wdc->cap & WDC_CAPABILITY_ATAPI_NOSTREAM)) {
|
|
|
|
bus_space_read_multi_2(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_data,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int16_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1999-01-08 21:10:35 +03:00
|
|
|
xfer->c_bcount >> 1);
|
1998-10-12 20:09:10 +04:00
|
|
|
} else {
|
|
|
|
bus_space_read_multi_stream_2(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_data,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int16_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1999-01-08 21:10:35 +03:00
|
|
|
xfer->c_bcount >> 1);
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
wdcbit_bucket(chp, len - xfer->c_bcount);
|
|
|
|
xfer->c_skip += xfer->c_bcount;
|
|
|
|
xfer->c_bcount = 0;
|
|
|
|
} else {
|
|
|
|
if (drvp->drive_flags & DRIVE_CAP32) {
|
|
|
|
if ((chp->wdc->cap & WDC_CAPABILITY_ATAPI_NOSTREAM))
|
|
|
|
bus_space_read_multi_4(chp->data32iot,
|
|
|
|
chp->data32ioh, 0,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int32_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1999-01-08 21:10:35 +03:00
|
|
|
len >> 2);
|
1998-10-12 20:09:10 +04:00
|
|
|
else
|
1998-12-17 16:05:05 +03:00
|
|
|
bus_space_read_multi_stream_4(chp->data32iot,
|
|
|
|
chp->data32ioh, wd_data,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int32_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1999-01-08 21:10:35 +03:00
|
|
|
len >> 2);
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
xfer->c_skip += len & 0xfffffffc;
|
|
|
|
xfer->c_bcount -= len & 0xfffffffc;
|
|
|
|
len = len & 0x03;
|
|
|
|
}
|
|
|
|
if (len > 0) {
|
|
|
|
if ((chp->wdc->cap & WDC_CAPABILITY_ATAPI_NOSTREAM))
|
|
|
|
bus_space_read_multi_2(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_data,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int16_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1999-01-08 21:10:35 +03:00
|
|
|
len >> 1);
|
1998-10-12 20:09:10 +04:00
|
|
|
else
|
|
|
|
bus_space_read_multi_stream_2(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_data,
|
1999-01-09 06:16:17 +03:00
|
|
|
(u_int16_t *)((char *)xfer->databuf +
|
|
|
|
xfer->c_skip),
|
1999-01-08 21:10:35 +03:00
|
|
|
len >> 1);
|
1998-10-12 20:09:10 +04:00
|
|
|
xfer->c_skip += len;
|
|
|
|
xfer->c_bcount -=len;
|
|
|
|
}
|
|
|
|
}
|
1999-10-01 02:57:52 +04:00
|
|
|
if ((sc_xfer->xs_control & XS_CTL_POLL) == 0) {
|
1998-10-12 20:09:10 +04:00
|
|
|
chp->ch_flags |= WDCF_IRQ_WAIT;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case PHASE_ABORTED:
|
|
|
|
case PHASE_COMPLETED:
|
|
|
|
WDCDEBUG_PRINT(("PHASE_COMPLETED\n"), DEBUG_INTR);
|
|
|
|
if (xfer->c_flags & C_DMA) {
|
2001-04-25 21:53:04 +04:00
|
|
|
xfer->c_bcount -= sc_xfer->datalen;
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
2001-04-25 21:53:04 +04:00
|
|
|
sc_xfer->resid = xfer->c_bcount;
|
2001-12-01 03:00:29 +03:00
|
|
|
wdc_atapi_phase_complete(xfer);
|
|
|
|
return(1);
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
default:
|
|
|
|
if (++retries<500) {
|
|
|
|
DELAY(100);
|
|
|
|
chp->ch_status = bus_space_read_1(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_status);
|
|
|
|
chp->ch_error = bus_space_read_1(chp->cmd_iot,
|
|
|
|
chp->cmd_ioh, wd_error);
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
printf("wdc_atapi_intr: unknown phase 0x%x\n", phase);
|
|
|
|
if (chp->ch_status & WDCS_ERR) {
|
1998-11-17 17:45:39 +03:00
|
|
|
sc_xfer->error = XS_SHORTSENSE;
|
1998-10-12 20:09:10 +04:00
|
|
|
sc_xfer->sense.atapi_sense = chp->ch_error;
|
|
|
|
} else {
|
2000-04-01 18:32:22 +04:00
|
|
|
if (xfer->c_flags & C_DMA) {
|
2000-01-17 03:01:00 +03:00
|
|
|
ata_dmaerr(drvp);
|
2000-04-01 18:32:22 +04:00
|
|
|
}
|
1999-02-02 15:59:31 +03:00
|
|
|
sc_xfer->error = XS_RESET;
|
|
|
|
wdc_atapi_reset(chp, xfer);
|
|
|
|
return (1);
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_intr: wdc_atapi_done() (end), error 0x%x "
|
|
|
|
"sense 0x%x\n", sc_xfer->error, sc_xfer->sense.atapi_sense),
|
|
|
|
DEBUG_INTR);
|
|
|
|
wdc_atapi_done(chp, xfer);
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-04-02 01:46:28 +04:00
|
|
|
wdc_atapi_ctrl(chp, xfer, irq)
|
1998-10-12 20:09:10 +04:00
|
|
|
struct channel_softc *chp;
|
|
|
|
struct wdc_xfer *xfer;
|
1999-04-02 01:46:28 +04:00
|
|
|
int irq;
|
1998-10-12 20:09:10 +04:00
|
|
|
{
|
|
|
|
struct scsipi_xfer *sc_xfer = xfer->cmd;
|
|
|
|
struct ata_drive_datas *drvp = &chp->ch_drive[xfer->drive];
|
|
|
|
char *errstring = NULL;
|
1999-04-02 01:46:28 +04:00
|
|
|
int delay = (irq == 0) ? ATAPI_DELAY : 0;
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
/* Ack interrupt done in wait_for_unbusy */
|
|
|
|
again:
|
1998-10-13 19:02:41 +04:00
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_ctrl %s:%d:%d state %d\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, drvp->drive, drvp->state),
|
1998-10-13 13:33:59 +04:00
|
|
|
DEBUG_INTR | DEBUG_FUNCS);
|
1998-10-12 20:09:10 +04:00
|
|
|
bus_space_write_1(chp->cmd_iot, chp->cmd_ioh, wd_sdh,
|
|
|
|
WDSD_IBM | (xfer->drive << 4));
|
|
|
|
switch (drvp->state) {
|
|
|
|
case PIOMODE:
|
|
|
|
/* Don't try to set mode if controller can't be adjusted */
|
|
|
|
if ((chp->wdc->cap & WDC_CAPABILITY_MODE) == 0)
|
|
|
|
goto ready;
|
1998-10-13 19:18:46 +04:00
|
|
|
/* Also don't try if the drive didn't report its mode */
|
|
|
|
if ((drvp->drive_flags & DRIVE_MODE) == 0)
|
2000-08-04 03:14:31 +04:00
|
|
|
goto ready;
|
1998-10-12 20:09:10 +04:00
|
|
|
wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
|
|
|
|
0x08 | drvp->PIO_mode, WDSF_SET_MODE);
|
|
|
|
drvp->state = PIOMODE_WAIT;
|
|
|
|
break;
|
|
|
|
case PIOMODE_WAIT:
|
|
|
|
errstring = "piomode";
|
1999-03-25 19:17:36 +03:00
|
|
|
if (wait_for_unbusy(chp, delay))
|
1998-10-12 20:09:10 +04:00
|
|
|
goto timeout;
|
2000-06-13 01:10:40 +04:00
|
|
|
if (chp->wdc->cap & WDC_CAPABILITY_IRQACK)
|
|
|
|
chp->wdc->irqack(chp);
|
1999-04-15 20:21:27 +04:00
|
|
|
if (chp->ch_status & WDCS_ERR) {
|
2000-08-04 03:14:31 +04:00
|
|
|
if (chp->ch_error == WDCE_ABRT) {
|
|
|
|
/*
|
|
|
|
* some ATAPI drives rejects pio settings.
|
|
|
|
* all we can do here is fall back to PIO 0
|
|
|
|
*/
|
|
|
|
drvp->drive_flags &= ~DRIVE_MODE;
|
|
|
|
drvp->drive_flags &= ~(DRIVE_DMA|DRIVE_UDMA);
|
|
|
|
drvp->PIO_mode = 0;
|
|
|
|
drvp->DMA_mode = 0;
|
|
|
|
printf("%s:%d:%d: pio setting rejected, "
|
|
|
|
"falling back to PIO mode 0\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname,
|
|
|
|
chp->channel, xfer->drive);
|
|
|
|
chp->wdc->set_modes(chp);
|
|
|
|
goto ready;
|
1999-04-15 20:21:27 +04:00
|
|
|
}
|
2000-08-04 03:14:31 +04:00
|
|
|
goto error;
|
1999-04-15 20:21:27 +04:00
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
/* fall through */
|
|
|
|
|
|
|
|
case DMAMODE:
|
|
|
|
if (drvp->drive_flags & DRIVE_UDMA) {
|
|
|
|
wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
|
|
|
|
0x40 | drvp->UDMA_mode, WDSF_SET_MODE);
|
|
|
|
} else if (drvp->drive_flags & DRIVE_DMA) {
|
|
|
|
wdccommand(chp, drvp->drive, SET_FEATURES, 0, 0, 0,
|
|
|
|
0x20 | drvp->DMA_mode, WDSF_SET_MODE);
|
|
|
|
} else {
|
|
|
|
goto ready;
|
|
|
|
}
|
|
|
|
drvp->state = DMAMODE_WAIT;
|
|
|
|
break;
|
|
|
|
case DMAMODE_WAIT:
|
|
|
|
errstring = "dmamode";
|
1999-03-25 19:17:36 +03:00
|
|
|
if (wait_for_unbusy(chp, delay))
|
1998-10-12 20:09:10 +04:00
|
|
|
goto timeout;
|
2000-06-13 01:10:40 +04:00
|
|
|
if (chp->wdc->cap & WDC_CAPABILITY_IRQACK)
|
|
|
|
chp->wdc->irqack(chp);
|
1998-10-12 20:09:10 +04:00
|
|
|
if (chp->ch_status & WDCS_ERR)
|
|
|
|
goto error;
|
|
|
|
/* fall through */
|
|
|
|
|
|
|
|
case READY:
|
|
|
|
ready:
|
|
|
|
drvp->state = READY;
|
|
|
|
xfer->c_intr = wdc_atapi_intr;
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_stop(&chp->ch_callout);
|
1998-10-12 20:09:10 +04:00
|
|
|
wdc_atapi_start(chp, xfer);
|
|
|
|
return 1;
|
|
|
|
}
|
1999-10-01 02:57:52 +04:00
|
|
|
if ((sc_xfer->xs_control & XS_CTL_POLL) == 0) {
|
1998-10-12 20:09:10 +04:00
|
|
|
chp->ch_flags |= WDCF_IRQ_WAIT;
|
|
|
|
xfer->c_intr = wdc_atapi_ctrl;
|
|
|
|
} else {
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
timeout:
|
1999-04-02 01:46:28 +04:00
|
|
|
if (irq && (xfer->c_flags & C_TIMEOU) == 0) {
|
1998-10-12 20:09:10 +04:00
|
|
|
return 0; /* IRQ was not for us */
|
|
|
|
}
|
|
|
|
printf("%s:%d:%d: %s timed out\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive, errstring);
|
1998-10-13 12:59:45 +04:00
|
|
|
sc_xfer->error = XS_TIMEOUT;
|
1998-10-12 20:09:10 +04:00
|
|
|
wdc_atapi_reset(chp, xfer);
|
|
|
|
return 1;
|
|
|
|
error:
|
|
|
|
printf("%s:%d:%d: %s ",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive,
|
|
|
|
errstring);
|
1998-10-13 12:59:45 +04:00
|
|
|
printf("error (0x%x)\n", chp->ch_error);
|
1998-11-17 17:45:39 +03:00
|
|
|
sc_xfer->error = XS_SHORTSENSE;
|
1998-10-12 20:09:10 +04:00
|
|
|
sc_xfer->sense.atapi_sense = chp->ch_error;
|
1998-10-13 12:59:45 +04:00
|
|
|
wdc_atapi_reset(chp, xfer);
|
1998-10-12 20:09:10 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-12-01 03:00:29 +03:00
|
|
|
void
|
|
|
|
wdc_atapi_phase_complete(xfer)
|
|
|
|
struct wdc_xfer *xfer;
|
|
|
|
{
|
|
|
|
struct channel_softc *chp = xfer->chp;
|
|
|
|
struct scsipi_xfer *sc_xfer = xfer->cmd;
|
|
|
|
struct ata_drive_datas *drvp = &chp->ch_drive[xfer->drive];
|
|
|
|
|
|
|
|
/* wait for DSC if needed */
|
|
|
|
if (drvp->drive_flags & DRIVE_ATAPIST) {
|
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_phase_complete(%s:%d:%d) "
|
|
|
|
"polldsc %d\n", chp->wdc->sc_dev.dv_xname, chp->channel,
|
|
|
|
xfer->drive, xfer->c_dscpoll), DEBUG_XFERS);
|
|
|
|
if (cold) {
|
|
|
|
if (wdcwait(chp, WDCS_DSC, WDCS_DSC,
|
|
|
|
sc_xfer->timeout)) {
|
|
|
|
printf("%s:%d:%d: wait_for_dsc failed\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel,
|
|
|
|
xfer->drive);
|
|
|
|
sc_xfer->error = XS_TIMEOUT;
|
|
|
|
wdc_atapi_reset(chp, xfer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (wdcwait(chp, WDCS_DSC, WDCS_DSC, 10)) {
|
2002-07-26 05:00:39 +04:00
|
|
|
/* 10ms not enough, try again in 1 tick */
|
2001-12-01 03:00:29 +03:00
|
|
|
if (xfer->c_dscpoll++ >
|
2002-04-05 22:27:45 +04:00
|
|
|
mstohz(sc_xfer->timeout)) {
|
2001-12-01 03:00:29 +03:00
|
|
|
printf("%s:%d:%d: wait_for_dsc "
|
|
|
|
"failed\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname,
|
|
|
|
chp->channel, xfer->drive);
|
|
|
|
sc_xfer->error = XS_TIMEOUT;
|
|
|
|
wdc_atapi_reset(chp, xfer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
callout_reset(&chp->ch_callout, 1,
|
|
|
|
wdc_atapi_polldsc, xfer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some drive occasionally set WDCS_ERR with
|
|
|
|
* "ATA illegal length indication" in the error
|
|
|
|
* register. If we read some data the sense is valid
|
|
|
|
* anyway, so don't report the error.
|
|
|
|
*/
|
|
|
|
if (chp->ch_status & WDCS_ERR &&
|
|
|
|
((sc_xfer->xs_control & XS_CTL_REQSENSE) == 0 ||
|
|
|
|
sc_xfer->resid == sc_xfer->datalen)) {
|
|
|
|
/* save the short sense */
|
|
|
|
sc_xfer->error = XS_SHORTSENSE;
|
|
|
|
sc_xfer->sense.atapi_sense = chp->ch_error;
|
|
|
|
if ((sc_xfer->xs_periph->periph_quirks &
|
|
|
|
PQUIRK_NOSENSE) == 0) {
|
|
|
|
/* ask scsipi to send a REQUEST_SENSE */
|
|
|
|
sc_xfer->error = XS_BUSY;
|
|
|
|
sc_xfer->status = SCSI_CHECK;
|
|
|
|
} else if (chp->wdc->dma_status &
|
|
|
|
(WDC_DMAST_NOIRQ | WDC_DMAST_ERR)) {
|
|
|
|
ata_dmaerr(drvp);
|
|
|
|
sc_xfer->error = XS_RESET;
|
|
|
|
wdc_atapi_reset(chp, xfer);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (xfer->c_bcount != 0) {
|
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_intr: bcount value is "
|
|
|
|
"%d after io\n", xfer->c_bcount), DEBUG_XFERS);
|
|
|
|
}
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (xfer->c_bcount < 0) {
|
|
|
|
printf("wdc_atapi_intr warning: bcount value "
|
|
|
|
"is %d after io\n", xfer->c_bcount);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_phase_complete: wdc_atapi_done(), "
|
|
|
|
"error 0x%x sense 0x%x\n", sc_xfer->error,
|
|
|
|
sc_xfer->sense.atapi_sense), DEBUG_INTR);
|
|
|
|
wdc_atapi_done(chp, xfer);
|
|
|
|
}
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
void
|
|
|
|
wdc_atapi_done(chp, xfer)
|
|
|
|
struct channel_softc *chp;
|
|
|
|
struct wdc_xfer *xfer;
|
|
|
|
{
|
|
|
|
struct scsipi_xfer *sc_xfer = xfer->cmd;
|
|
|
|
|
1998-10-13 19:02:41 +04:00
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_done %s:%d:%d: flags 0x%x\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel, xfer->drive,
|
|
|
|
(u_int)xfer->c_flags), DEBUG_XFERS);
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_stop(&chp->ch_callout);
|
1998-10-12 20:09:10 +04:00
|
|
|
/* remove this command from xfer queue */
|
|
|
|
wdc_free_xfer(chp, xfer);
|
2001-04-25 21:53:04 +04:00
|
|
|
|
1999-08-09 13:49:48 +04:00
|
|
|
WDCDEBUG_PRINT(("wdc_atapi_done: scsipi_done\n"), DEBUG_XFERS);
|
|
|
|
scsipi_done(sc_xfer);
|
1998-10-12 20:09:10 +04:00
|
|
|
WDCDEBUG_PRINT(("wdcstart from wdc_atapi_done, flags 0x%x\n",
|
1998-10-13 13:33:59 +04:00
|
|
|
chp->ch_flags), DEBUG_XFERS);
|
1998-11-21 18:41:41 +03:00
|
|
|
wdcstart(chp);
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
wdc_atapi_reset(chp, xfer)
|
|
|
|
struct channel_softc *chp;
|
|
|
|
struct wdc_xfer *xfer;
|
|
|
|
{
|
|
|
|
struct ata_drive_datas *drvp = &chp->ch_drive[xfer->drive];
|
|
|
|
struct scsipi_xfer *sc_xfer = xfer->cmd;
|
|
|
|
|
|
|
|
wdccommandshort(chp, xfer->drive, ATAPI_SOFT_RESET);
|
|
|
|
drvp->state = 0;
|
|
|
|
if (wait_for_unbusy(chp, WDC_RESET_WAIT) != 0) {
|
|
|
|
printf("%s:%d:%d: reset failed\n",
|
|
|
|
chp->wdc->sc_dev.dv_xname, chp->channel,
|
|
|
|
xfer->drive);
|
|
|
|
sc_xfer->error = XS_SELTIMEOUT;
|
|
|
|
}
|
|
|
|
wdc_atapi_done(chp, xfer);
|
|
|
|
return;
|
|
|
|
}
|
2001-12-01 03:00:29 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
wdc_atapi_polldsc(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
wdc_atapi_phase_complete(arg);
|
|
|
|
}
|