2004-10-27 01:21:59 +04:00
|
|
|
/* $NetBSD: wdc.c,v 1.215 2004/10/26 21:21:59 bouyer Exp $ */
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
/*
|
2003-10-08 14:58:12 +04:00
|
|
|
* Copyright (c) 1998, 2001, 2003 Manuel Bouyer. All rights reserved.
|
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:
|
|
|
|
* This product includes software developed by Manuel Bouyer.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-08-15 14:10:47 +04:00
|
|
|
/*-
|
2003-09-20 01:35:56 +04:00
|
|
|
* Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
|
1998-08-15 14:10:47 +04:00
|
|
|
* All rights reserved.
|
1997-08-27 15:22:52 +04:00
|
|
|
*
|
1998-08-15 14:10:47 +04:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Charles M. Hannum, by Onno van der Linden and by Manuel Bouyer.
|
1998-01-15 02:41:59 +03:00
|
|
|
*
|
1997-08-27 15:22:52 +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:
|
1998-08-15 14:10:47 +04:00
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
1997-08-27 15:22:52 +04:00
|
|
|
*
|
1998-08-15 14:10:47 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``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 FOUNDATION OR CONTRIBUTORS
|
|
|
|
* 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.
|
1997-08-27 15:22:52 +04:00
|
|
|
*/
|
|
|
|
|
1998-01-15 02:41:59 +03:00
|
|
|
/*
|
|
|
|
* CODE UNTESTED IN THE CURRENT REVISION:
|
|
|
|
*/
|
|
|
|
|
2001-11-13 16:14:31 +03:00
|
|
|
#include <sys/cdefs.h>
|
2004-10-27 01:21:59 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: wdc.c,v 1.215 2004/10/26 21:21:59 bouyer Exp $");
|
2001-11-13 16:14:31 +03:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
#ifndef ATADEBUG
|
|
|
|
#define ATADEBUG
|
|
|
|
#endif /* ATADEBUG */
|
1998-10-12 20:09:10 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/device.h>
|
1998-10-12 20:09:10 +04:00
|
|
|
#include <sys/malloc.h>
|
1997-08-27 15:22:52 +04:00
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
|
|
|
#include <machine/intr.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
1998-02-04 17:13:40 +03:00
|
|
|
#ifndef __BUS_SPACE_HAS_STREAM_METHODS
|
1998-10-12 20:09:10 +04:00
|
|
|
#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
|
1998-02-04 17:13:40 +03:00
|
|
|
#endif /* __BUS_SPACE_HAS_STREAM_METHODS */
|
1998-02-03 07:26:45 +03:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
#include <dev/ata/atavar.h>
|
|
|
|
#include <dev/ata/atareg.h>
|
1998-01-15 02:41:59 +03:00
|
|
|
#include <dev/ic/wdcreg.h>
|
|
|
|
#include <dev/ic/wdcvar.h>
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2003-10-08 14:58:12 +04:00
|
|
|
#include "locators.h"
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
#include "atapibus.h"
|
2001-12-05 23:43:00 +03:00
|
|
|
#include "wd.h"
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
#define WDCDELAY 100 /* 100 microseconds */
|
|
|
|
#define WDCNDELAY_RST (WDC_RESET_WAIT * 1000 / WDCDELAY)
|
1997-08-27 15:22:52 +04:00
|
|
|
#if 0
|
1998-10-12 20:09:10 +04:00
|
|
|
/* If you enable this, it will report any delays more than WDCDELAY * N long. */
|
1997-08-27 15:22:52 +04:00
|
|
|
#define WDCNDELAY_DEBUG 50
|
|
|
|
#endif
|
|
|
|
|
2003-10-08 14:58:12 +04:00
|
|
|
/* When polling wait that much and then tsleep for 1/hz seconds */
|
|
|
|
#define WDCDELAY_POLL 1 /* ms */
|
|
|
|
|
|
|
|
/* timeout for the control commands */
|
|
|
|
#define WDC_CTRL_DELAY 10000 /* 10s, for the recall command */
|
|
|
|
|
2001-12-05 23:43:00 +03:00
|
|
|
#if NWD > 0
|
2001-12-03 03:11:15 +03:00
|
|
|
extern const struct ata_bustype wdc_ata_bustype; /* in ata_wdc.c */
|
2001-12-05 23:43:00 +03:00
|
|
|
#else
|
|
|
|
/* A fake one, the autoconfig will print "wd at foo ... not configured */
|
|
|
|
const struct ata_bustype wdc_ata_bustype = {
|
|
|
|
SCSIPI_BUSTYPE_ATA,
|
2004-10-26 02:42:09 +04:00
|
|
|
NULL, /* wdc_ata_bio */
|
|
|
|
NULL, /* wdc_reset_drive */
|
|
|
|
wdc_reset_channel,
|
|
|
|
wdc_exec_command,
|
|
|
|
NULL, /* ata_get_params */
|
|
|
|
NULL, /* wdc_ata_addref */
|
|
|
|
NULL, /* wdc_ata_delref */
|
|
|
|
NULL /* ata_kill_pending */
|
2001-12-05 23:43:00 +03:00
|
|
|
};
|
|
|
|
#endif
|
2001-12-03 01:44:32 +03:00
|
|
|
|
2004-08-21 05:51:46 +04:00
|
|
|
/* Flags to wdcreset(). */
|
|
|
|
#define RESET_POLL 1
|
|
|
|
#define RESET_SLEEP 0 /* wdcreset() will use tsleep() */
|
|
|
|
|
|
|
|
static int wdcprobe1(struct ata_channel *, int);
|
|
|
|
static int wdcreset(struct ata_channel *, int);
|
|
|
|
static void __wdcerror(struct ata_channel *, char *);
|
2004-08-14 19:08:04 +04:00
|
|
|
static int __wdcwait_reset(struct ata_channel *, int, int);
|
|
|
|
static void __wdccommand_done(struct ata_channel *, struct ata_xfer *);
|
|
|
|
static void __wdccommand_done_end(struct ata_channel *, struct ata_xfer *);
|
|
|
|
static void __wdccommand_kill_xfer(struct ata_channel *,
|
2004-08-01 01:26:42 +04:00
|
|
|
struct ata_xfer *, int);
|
2004-08-14 19:08:04 +04:00
|
|
|
static void __wdccommand_start(struct ata_channel *, struct ata_xfer *);
|
|
|
|
static int __wdccommand_intr(struct ata_channel *, struct ata_xfer *, int);
|
|
|
|
static int __wdcwait(struct ata_channel *, int, int, int);
|
1998-10-12 20:09:10 +04:00
|
|
|
|
2004-08-21 05:51:46 +04:00
|
|
|
static void wdc_datain_pio(struct ata_channel *, int, void *, size_t);
|
|
|
|
static void wdc_dataout_pio(struct ata_channel *, int, void *, size_t);
|
|
|
|
|
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
|
1999-09-23 15:04:29 +04:00
|
|
|
#define DEBUG_DETACH 0x20
|
2000-04-04 16:43:13 +04:00
|
|
|
#define DEBUG_DELAY 0x40
|
2004-08-13 08:10:49 +04:00
|
|
|
#ifdef ATADEBUG
|
|
|
|
extern int atadebug_mask; /* init'ed in ata.c */
|
1998-10-12 20:09:10 +04:00
|
|
|
int wdc_nxfer = 0;
|
2004-08-13 08:10:49 +04:00
|
|
|
#define ATADEBUG_PRINT(args, level) if (atadebug_mask & (level)) printf args
|
1997-08-27 15:22:52 +04:00
|
|
|
#else
|
2004-08-13 08:10:49 +04:00
|
|
|
#define ATADEBUG_PRINT(args, level)
|
1997-08-27 15:22:52 +04:00
|
|
|
#endif
|
|
|
|
|
2004-05-26 00:42:40 +04:00
|
|
|
/*
|
|
|
|
* Initialize the "shadow register" handles for a standard wdc controller.
|
|
|
|
*/
|
|
|
|
void
|
2004-08-14 19:08:04 +04:00
|
|
|
wdc_init_shadow_regs(struct ata_channel *chp)
|
2004-05-26 00:42:40 +04:00
|
|
|
{
|
2004-08-20 03:25:35 +04:00
|
|
|
struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
|
2004-05-26 00:42:40 +04:00
|
|
|
|
2004-08-14 19:08:04 +04:00
|
|
|
wdr->cmd_iohs[wd_status] = wdr->cmd_iohs[wd_command];
|
|
|
|
wdr->cmd_iohs[wd_features] = wdr->cmd_iohs[wd_error];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate a wdc_regs array, based on the number of channels.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
wdc_allocate_regs(struct wdc_softc *wdc)
|
|
|
|
{
|
|
|
|
|
2004-08-20 10:39:37 +04:00
|
|
|
wdc->regs = malloc(wdc->sc_atac.atac_nchannels *
|
|
|
|
sizeof(struct wdc_regs), M_DEVBUF, M_WAITOK);
|
2004-05-26 00:42:40 +04:00
|
|
|
}
|
|
|
|
|
2003-12-30 19:28:37 +03:00
|
|
|
/* Test to see controller with at last one attached drive is there.
|
|
|
|
* Returns a bit for each possible drive found (0x01 for drive 0,
|
|
|
|
* 0x02 for drive 1).
|
|
|
|
* Logic:
|
|
|
|
* - If a status register is at 0xff, assume there is no drive here
|
|
|
|
* (ISA has pull-up resistors). Similarly if the status register has
|
|
|
|
* the value we last wrote to the bus (for IDE interfaces without pullups).
|
|
|
|
* If no drive at all -> return.
|
|
|
|
* - reset the controller, wait for it to complete (may take up to 31s !).
|
|
|
|
* If timeout -> return.
|
|
|
|
* - test ATA/ATAPI signatures. If at last one drive found -> return.
|
|
|
|
* - try an ATA command on the master.
|
|
|
|
*/
|
2003-09-20 01:35:56 +04:00
|
|
|
|
2003-12-30 20:18:11 +03:00
|
|
|
static void
|
2004-08-14 19:08:04 +04:00
|
|
|
wdc_drvprobe(struct ata_channel *chp)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
1999-03-10 16:11:43 +03:00
|
|
|
struct ataparams params;
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
2003-10-25 12:30:46 +04:00
|
|
|
u_int8_t st0 = 0, st1 = 0;
|
2004-08-21 04:28:34 +04:00
|
|
|
int i, error, s;
|
2000-03-23 10:01:25 +03:00
|
|
|
|
2003-12-30 20:18:11 +03:00
|
|
|
if (wdcprobe1(chp, 0) == 0) {
|
|
|
|
/* No drives, abort the attach here. */
|
|
|
|
return;
|
2003-12-15 03:27:13 +03:00
|
|
|
}
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2003-10-08 14:58:12 +04:00
|
|
|
/* for ATA/OLD drives, wait for DRDY, 3s timeout */
|
|
|
|
for (i = 0; i < mstohz(3000); i++) {
|
2004-05-15 21:15:09 +04:00
|
|
|
if (chp->ch_drive[0].drive_flags & (DRIVE_ATA|DRIVE_OLD)) {
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->select)
|
2004-05-15 21:15:09 +04:00
|
|
|
wdc->select(chp,0);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
|
2004-05-15 21:15:09 +04:00
|
|
|
0, WDSD_IBM);
|
|
|
|
delay(10); /* 400ns delay */
|
2004-08-14 19:08:04 +04:00
|
|
|
st0 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_status], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2004-05-15 21:15:09 +04:00
|
|
|
if (chp->ch_drive[1].drive_flags & (DRIVE_ATA|DRIVE_OLD)) {
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->select)
|
2004-05-15 21:15:09 +04:00
|
|
|
wdc->select(chp,1);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
|
2004-05-15 21:15:09 +04:00
|
|
|
0, WDSD_IBM | 0x10);
|
|
|
|
delay(10); /* 400ns delay */
|
2004-08-14 19:08:04 +04:00
|
|
|
st1 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_status], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2003-10-08 14:58:12 +04:00
|
|
|
|
|
|
|
if (((chp->ch_drive[0].drive_flags & (DRIVE_ATA|DRIVE_OLD))
|
|
|
|
== 0 ||
|
|
|
|
(st0 & WDCS_DRDY)) &&
|
|
|
|
((chp->ch_drive[1].drive_flags & (DRIVE_ATA|DRIVE_OLD))
|
|
|
|
== 0 ||
|
|
|
|
(st1 & WDCS_DRDY)))
|
|
|
|
break;
|
2003-12-30 20:18:11 +03:00
|
|
|
tsleep(¶ms, PRIBIO, "atadrdy", 1);
|
1999-03-10 16:11:43 +03:00
|
|
|
}
|
2004-08-21 04:28:34 +04:00
|
|
|
s = splbio();
|
2003-10-08 14:58:12 +04:00
|
|
|
if ((st0 & WDCS_DRDY) == 0)
|
|
|
|
chp->ch_drive[0].drive_flags &= ~(DRIVE_ATA|DRIVE_OLD);
|
|
|
|
if ((st1 & WDCS_DRDY) == 0)
|
|
|
|
chp->ch_drive[1].drive_flags &= ~(DRIVE_ATA|DRIVE_OLD);
|
2004-08-21 04:28:34 +04:00
|
|
|
splx(s);
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d: wait DRDY st0 0x%x st1 0x%x\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, st0, st1), DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
|
|
|
|
/* Wait a bit, some devices are weird just after a reset. */
|
|
|
|
delay(5000);
|
1999-03-10 16:11:43 +03:00
|
|
|
|
|
|
|
for (i = 0; i < 2; i++) {
|
2004-01-08 01:03:56 +03:00
|
|
|
/* XXX This should be done by other code. */
|
1999-03-10 16:11:43 +03:00
|
|
|
chp->ch_drive[i].chnl_softc = chp;
|
|
|
|
chp->ch_drive[i].drive = i;
|
2004-01-08 01:03:56 +03:00
|
|
|
|
2000-01-17 03:01:00 +03:00
|
|
|
/*
|
|
|
|
* Init error counter so that an error withing the first xfers
|
|
|
|
* will trigger a downgrade
|
|
|
|
*/
|
|
|
|
chp->ch_drive[i].n_dmaerrs = NERRS_MAX-1;
|
|
|
|
|
1999-03-10 16:11:43 +03:00
|
|
|
/* If controller can't do 16bit flag the drives as 32bit */
|
2004-08-20 10:39:37 +04:00
|
|
|
if ((atac->atac_cap &
|
2004-08-21 04:28:34 +04:00
|
|
|
(ATAC_CAP_DATA16 | ATAC_CAP_DATA32)) == ATAC_CAP_DATA32) {
|
|
|
|
s = splbio();
|
1999-03-10 16:11:43 +03:00
|
|
|
chp->ch_drive[i].drive_flags |= DRIVE_CAP32;
|
2004-08-21 04:28:34 +04:00
|
|
|
splx(s);
|
|
|
|
}
|
Fix probe code for IDE devices:
- Don't rely on ATA signature: some ide controllers seems to not transmit it
properly (SIMIDE on arm32 machines). Instead, when we guess a drive is here
after reset, just mark it as ATA and OLD is it's not ATAPI.
- at attach time, use IDENTIFY to eliminate ghost from the probe. If the
drive had the old flag and IDENTIFY failed, issue a WDCC_RECAL command
to detect a pre-ATA disk. If IDENTIFY succeded, remove the OLD flag,
it's obviously not a pre-ATA disk.
- add a new controller flag, WDC_CAPABILITY_PREATA, used to shorcut parts
of the probe (not necessary, but makes the probe/attach faster). This is
only set by the ISA front-end, all other controllers supported can't have
pre-ATA drives attached.
The mechanism used are more or less the same as before, they have just been
reordered. Should solve port-arm32/7324 (waiting for feedback).
1999-04-12 00:50:28 +04:00
|
|
|
if ((chp->ch_drive[i].drive_flags & DRIVE) == 0)
|
|
|
|
continue;
|
1999-03-10 16:11:43 +03:00
|
|
|
|
2003-10-23 03:59:00 +04:00
|
|
|
/* Shortcut in case we've been shutdown */
|
2004-08-14 19:08:04 +04:00
|
|
|
if (chp->ch_flags & ATACH_SHUTDOWN)
|
2003-12-30 20:18:11 +03:00
|
|
|
return;
|
2003-10-23 03:59:00 +04:00
|
|
|
|
2003-10-08 14:58:12 +04:00
|
|
|
/* issue an identify, to try to detect ghosts */
|
2004-10-27 01:21:59 +04:00
|
|
|
error = ata_get_params(&chp->ch_drive[i], AT_WAIT, ¶ms);
|
2000-04-04 13:25:51 +04:00
|
|
|
if (error != CMD_OK) {
|
2003-12-30 20:18:11 +03:00
|
|
|
tsleep(¶ms, PRIBIO, "atacnf", mstohz(1000));
|
2003-10-23 03:59:00 +04:00
|
|
|
|
|
|
|
/* Shortcut in case we've been shutdown */
|
2004-08-14 19:08:04 +04:00
|
|
|
if (chp->ch_flags & ATACH_SHUTDOWN)
|
2003-12-30 20:18:11 +03:00
|
|
|
return;
|
2003-10-23 03:59:00 +04:00
|
|
|
|
2003-10-07 01:51:31 +04:00
|
|
|
error = ata_get_params(&chp->ch_drive[i],
|
2004-10-27 01:21:59 +04:00
|
|
|
AT_WAIT, ¶ms);
|
2000-04-04 13:25:51 +04:00
|
|
|
}
|
1999-11-28 23:04:22 +03:00
|
|
|
if (error == CMD_OK) {
|
2003-11-02 14:07:44 +03:00
|
|
|
/* If IDENTIFY succeeded, this is not an OLD ctrl */
|
2004-08-21 04:28:34 +04:00
|
|
|
s = splbio();
|
|
|
|
/* XXXJRT ch_ndrive */
|
Fix probe code for IDE devices:
- Don't rely on ATA signature: some ide controllers seems to not transmit it
properly (SIMIDE on arm32 machines). Instead, when we guess a drive is here
after reset, just mark it as ATA and OLD is it's not ATAPI.
- at attach time, use IDENTIFY to eliminate ghost from the probe. If the
drive had the old flag and IDENTIFY failed, issue a WDCC_RECAL command
to detect a pre-ATA disk. If IDENTIFY succeded, remove the OLD flag,
it's obviously not a pre-ATA disk.
- add a new controller flag, WDC_CAPABILITY_PREATA, used to shorcut parts
of the probe (not necessary, but makes the probe/attach faster). This is
only set by the ISA front-end, all other controllers supported can't have
pre-ATA drives attached.
The mechanism used are more or less the same as before, they have just been
reordered. Should solve port-arm32/7324 (waiting for feedback).
1999-04-12 00:50:28 +04:00
|
|
|
chp->ch_drive[0].drive_flags &= ~DRIVE_OLD;
|
|
|
|
chp->ch_drive[1].drive_flags &= ~DRIVE_OLD;
|
2004-08-21 04:28:34 +04:00
|
|
|
splx(s);
|
Fix probe code for IDE devices:
- Don't rely on ATA signature: some ide controllers seems to not transmit it
properly (SIMIDE on arm32 machines). Instead, when we guess a drive is here
after reset, just mark it as ATA and OLD is it's not ATAPI.
- at attach time, use IDENTIFY to eliminate ghost from the probe. If the
drive had the old flag and IDENTIFY failed, issue a WDCC_RECAL command
to detect a pre-ATA disk. If IDENTIFY succeded, remove the OLD flag,
it's obviously not a pre-ATA disk.
- add a new controller flag, WDC_CAPABILITY_PREATA, used to shorcut parts
of the probe (not necessary, but makes the probe/attach faster). This is
only set by the ISA front-end, all other controllers supported can't have
pre-ATA drives attached.
The mechanism used are more or less the same as before, they have just been
reordered. Should solve port-arm32/7324 (waiting for feedback).
1999-04-12 00:50:28 +04:00
|
|
|
} else {
|
2004-08-21 04:28:34 +04:00
|
|
|
s = splbio();
|
2003-11-17 23:01:35 +03:00
|
|
|
chp->ch_drive[i].drive_flags &=
|
1999-03-10 16:11:43 +03:00
|
|
|
~(DRIVE_ATA | DRIVE_ATAPI);
|
2004-08-21 04:28:34 +04:00
|
|
|
splx(s);
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d:%d: IDENTIFY failed (%d)\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, i, error), DEBUG_PROBE);
|
Fix probe code for IDE devices:
- Don't rely on ATA signature: some ide controllers seems to not transmit it
properly (SIMIDE on arm32 machines). Instead, when we guess a drive is here
after reset, just mark it as ATA and OLD is it's not ATAPI.
- at attach time, use IDENTIFY to eliminate ghost from the probe. If the
drive had the old flag and IDENTIFY failed, issue a WDCC_RECAL command
to detect a pre-ATA disk. If IDENTIFY succeded, remove the OLD flag,
it's obviously not a pre-ATA disk.
- add a new controller flag, WDC_CAPABILITY_PREATA, used to shorcut parts
of the probe (not necessary, but makes the probe/attach faster). This is
only set by the ISA front-end, all other controllers supported can't have
pre-ATA drives attached.
The mechanism used are more or less the same as before, they have just been
reordered. Should solve port-arm32/7324 (waiting for feedback).
1999-04-12 00:50:28 +04:00
|
|
|
if ((chp->ch_drive[i].drive_flags & DRIVE_OLD) == 0)
|
|
|
|
continue;
|
1999-06-23 23:00:17 +04:00
|
|
|
/*
|
|
|
|
* Pre-ATA drive ?
|
|
|
|
* Test registers writability (Error register not
|
|
|
|
* writable, but cyllo is), then try an ATA command.
|
|
|
|
*/
|
2004-08-13 07:12:59 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,i);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sdh], 0, WDSD_IBM | (i << 4));
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
delay(10); /* 400ns delay */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_error],
|
There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.
To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.
bus_space_write_4(tag, handle, offset, value)
becomes
bus_space_write_4(tag, handles[offset], 0, value)
Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
2003-11-28 02:02:40 +03:00
|
|
|
0, 0x58);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0, 0xa5);
|
|
|
|
if (bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_error], 0) == 0x58 ||
|
|
|
|
bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0) != 0xa5) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d:%d: register "
|
1999-06-23 23:00:17 +04:00
|
|
|
"writability failed\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, i), DEBUG_PROBE);
|
2004-08-21 04:28:34 +04:00
|
|
|
s = splbio();
|
1999-06-23 23:00:17 +04:00
|
|
|
chp->ch_drive[i].drive_flags &= ~DRIVE_OLD;
|
2004-08-21 04:28:34 +04:00
|
|
|
splx(s);
|
2003-11-17 23:01:35 +03:00
|
|
|
continue;
|
1999-06-23 23:00:17 +04:00
|
|
|
}
|
2004-01-01 23:25:22 +03:00
|
|
|
if (wdc_wait_for_ready(chp, 10000, 0) == WDCWAIT_TOUT) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d:%d: not ready\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, i), DEBUG_PROBE);
|
2004-08-21 04:28:34 +04:00
|
|
|
s = splbio();
|
Fix probe code for IDE devices:
- Don't rely on ATA signature: some ide controllers seems to not transmit it
properly (SIMIDE on arm32 machines). Instead, when we guess a drive is here
after reset, just mark it as ATA and OLD is it's not ATAPI.
- at attach time, use IDENTIFY to eliminate ghost from the probe. If the
drive had the old flag and IDENTIFY failed, issue a WDCC_RECAL command
to detect a pre-ATA disk. If IDENTIFY succeded, remove the OLD flag,
it's obviously not a pre-ATA disk.
- add a new controller flag, WDC_CAPABILITY_PREATA, used to shorcut parts
of the probe (not necessary, but makes the probe/attach faster). This is
only set by the ISA front-end, all other controllers supported can't have
pre-ATA drives attached.
The mechanism used are more or less the same as before, they have just been
reordered. Should solve port-arm32/7324 (waiting for feedback).
1999-04-12 00:50:28 +04:00
|
|
|
chp->ch_drive[i].drive_flags &= ~DRIVE_OLD;
|
2004-08-21 04:28:34 +04:00
|
|
|
splx(s);
|
Fix probe code for IDE devices:
- Don't rely on ATA signature: some ide controllers seems to not transmit it
properly (SIMIDE on arm32 machines). Instead, when we guess a drive is here
after reset, just mark it as ATA and OLD is it's not ATAPI.
- at attach time, use IDENTIFY to eliminate ghost from the probe. If the
drive had the old flag and IDENTIFY failed, issue a WDCC_RECAL command
to detect a pre-ATA disk. If IDENTIFY succeded, remove the OLD flag,
it's obviously not a pre-ATA disk.
- add a new controller flag, WDC_CAPABILITY_PREATA, used to shorcut parts
of the probe (not necessary, but makes the probe/attach faster). This is
only set by the ISA front-end, all other controllers supported can't have
pre-ATA drives attached.
The mechanism used are more or less the same as before, they have just been
reordered. Should solve port-arm32/7324 (waiting for feedback).
1999-04-12 00:50:28 +04:00
|
|
|
continue;
|
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_command], 0, WDCC_RECAL);
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
delay(10); /* 400ns delay */
|
2004-01-01 23:25:22 +03:00
|
|
|
if (wdc_wait_for_ready(chp, 10000, 0) == WDCWAIT_TOUT) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d:%d: WDCC_RECAL failed\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, i), DEBUG_PROBE);
|
2004-08-21 04:28:34 +04:00
|
|
|
s = splbio();
|
Fix probe code for IDE devices:
- Don't rely on ATA signature: some ide controllers seems to not transmit it
properly (SIMIDE on arm32 machines). Instead, when we guess a drive is here
after reset, just mark it as ATA and OLD is it's not ATAPI.
- at attach time, use IDENTIFY to eliminate ghost from the probe. If the
drive had the old flag and IDENTIFY failed, issue a WDCC_RECAL command
to detect a pre-ATA disk. If IDENTIFY succeded, remove the OLD flag,
it's obviously not a pre-ATA disk.
- add a new controller flag, WDC_CAPABILITY_PREATA, used to shorcut parts
of the probe (not necessary, but makes the probe/attach faster). This is
only set by the ISA front-end, all other controllers supported can't have
pre-ATA drives attached.
The mechanism used are more or less the same as before, they have just been
reordered. Should solve port-arm32/7324 (waiting for feedback).
1999-04-12 00:50:28 +04:00
|
|
|
chp->ch_drive[i].drive_flags &= ~DRIVE_OLD;
|
2004-08-21 04:28:34 +04:00
|
|
|
splx(s);
|
2003-11-17 23:01:35 +03:00
|
|
|
} else {
|
2004-08-21 04:28:34 +04:00
|
|
|
s = splbio();
|
|
|
|
/* XXXJRT ch_ndrive */
|
2003-11-17 23:01:35 +03:00
|
|
|
chp->ch_drive[0].drive_flags &=
|
|
|
|
~(DRIVE_ATA | DRIVE_ATAPI);
|
|
|
|
chp->ch_drive[1].drive_flags &=
|
|
|
|
~(DRIVE_ATA | DRIVE_ATAPI);
|
2004-08-21 04:28:34 +04:00
|
|
|
splx(s);
|
Fix probe code for IDE devices:
- Don't rely on ATA signature: some ide controllers seems to not transmit it
properly (SIMIDE on arm32 machines). Instead, when we guess a drive is here
after reset, just mark it as ATA and OLD is it's not ATAPI.
- at attach time, use IDENTIFY to eliminate ghost from the probe. If the
drive had the old flag and IDENTIFY failed, issue a WDCC_RECAL command
to detect a pre-ATA disk. If IDENTIFY succeded, remove the OLD flag,
it's obviously not a pre-ATA disk.
- add a new controller flag, WDC_CAPABILITY_PREATA, used to shorcut parts
of the probe (not necessary, but makes the probe/attach faster). This is
only set by the ISA front-end, all other controllers supported can't have
pre-ATA drives attached.
The mechanism used are more or less the same as before, they have just been
reordered. Should solve port-arm32/7324 (waiting for feedback).
1999-04-12 00:50:28 +04:00
|
|
|
}
|
1999-03-10 16:11:43 +03:00
|
|
|
}
|
|
|
|
}
|
2003-12-30 20:18:11 +03:00
|
|
|
}
|
|
|
|
|
2003-10-08 14:58:12 +04:00
|
|
|
int
|
2004-08-14 19:08:04 +04:00
|
|
|
wdcprobe(struct ata_channel *chp)
|
2003-10-08 14:58:12 +04:00
|
|
|
{
|
2003-12-30 19:40:12 +03:00
|
|
|
|
|
|
|
return (wdcprobe1(chp, 1));
|
2003-10-08 14:58:12 +04:00
|
|
|
}
|
|
|
|
|
2004-01-02 00:18:28 +03:00
|
|
|
static int
|
2004-08-14 19:08:04 +04:00
|
|
|
wdcprobe1(struct ata_channel *chp, int poll)
|
2003-10-08 14:58:12 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
2003-10-08 14:58:12 +04:00
|
|
|
u_int8_t st0, st1, sc, sn, cl, ch;
|
|
|
|
u_int8_t ret_value = 0x03;
|
|
|
|
u_int8_t drive;
|
2003-11-26 00:03:15 +03:00
|
|
|
int s;
|
2003-10-08 14:58:12 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check to see if the wdc channel responds at all.
|
|
|
|
*/
|
|
|
|
|
2004-05-15 21:15:09 +04:00
|
|
|
s = splbio();
|
2004-08-20 10:39:37 +04:00
|
|
|
if ((wdc->cap & WDC_CAPABILITY_NO_EXTRA_RESETS) == 0) {
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,0);
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
|
2003-10-08 14:58:12 +04:00
|
|
|
WDSD_IBM);
|
|
|
|
delay(10); /* 400ns delay */
|
2004-08-14 19:08:04 +04:00
|
|
|
st0 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_status], 0);
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,1);
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
|
2003-10-08 14:58:12 +04:00
|
|
|
WDSD_IBM | 0x10);
|
|
|
|
delay(10); /* 400ns delay */
|
2004-08-14 19:08:04 +04:00
|
|
|
st1 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_status], 0);
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d: before reset, st0=0x%x, st1=0x%x\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, st0, st1), DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2003-10-16 00:26:33 +04:00
|
|
|
if (st0 == 0xff || st0 == WDSD_IBM)
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x01;
|
2003-10-16 00:26:33 +04:00
|
|
|
if (st1 == 0xff || st1 == (WDSD_IBM | 0x10))
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x02;
|
|
|
|
/* Register writability test, drive 0. */
|
|
|
|
if (ret_value & 0x01) {
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,0);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
|
There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.
To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.
bus_space_write_4(tag, handle, offset, value)
becomes
bus_space_write_4(tag, handles[offset], 0, value)
Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
2003-11-28 02:02:40 +03:00
|
|
|
0, WDSD_IBM);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0, 0x02);
|
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
if (cl != 0x02) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d drive 0 wd_cyl_lo: "
|
2004-05-15 21:15:09 +04:00
|
|
|
"got 0x%x != 0x02\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-05-15 21:15:09 +04:00
|
|
|
chp->ch_channel, cl),
|
|
|
|
DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x01;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0, 0x01);
|
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
if (cl != 0x01) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d drive 0 wd_cyl_lo: "
|
2004-05-15 21:15:09 +04:00
|
|
|
"got 0x%x != 0x01\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-05-15 21:15:09 +04:00
|
|
|
chp->ch_channel, cl),
|
|
|
|
DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x01;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0, 0x01);
|
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
if (cl != 0x01) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d drive 0 wd_sector: "
|
2004-05-15 21:15:09 +04:00
|
|
|
"got 0x%x != 0x01\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-05-15 21:15:09 +04:00
|
|
|
chp->ch_channel, cl),
|
|
|
|
DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x01;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0, 0x02);
|
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
if (cl != 0x02) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d drive 0 wd_sector: "
|
2004-05-15 21:15:09 +04:00
|
|
|
"got 0x%x != 0x02\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-05-15 21:15:09 +04:00
|
|
|
chp->ch_channel, cl),
|
|
|
|
DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x01;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
if (cl != 0x01) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d drive 0 wd_cyl_lo(2): "
|
2004-05-15 21:15:09 +04:00
|
|
|
"got 0x%x != 0x01\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-05-15 21:15:09 +04:00
|
|
|
chp->ch_channel, cl),
|
|
|
|
DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x01;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2003-10-08 14:58:12 +04:00
|
|
|
}
|
|
|
|
/* Register writability test, drive 1. */
|
|
|
|
if (ret_value & 0x02) {
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,1);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
|
There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.
To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.
bus_space_write_4(tag, handle, offset, value)
becomes
bus_space_write_4(tag, handles[offset], 0, value)
Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
2003-11-28 02:02:40 +03:00
|
|
|
0, WDSD_IBM | 0x10);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0, 0x02);
|
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
if (cl != 0x02) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d drive 1 wd_cyl_lo: "
|
2004-05-15 21:15:09 +04:00
|
|
|
"got 0x%x != 0x02\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-05-15 21:15:09 +04:00
|
|
|
chp->ch_channel, cl),
|
|
|
|
DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x02;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0, 0x01);
|
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
if (cl != 0x01) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d drive 1 wd_cyl_lo: "
|
2004-05-15 21:15:09 +04:00
|
|
|
"got 0x%x != 0x01\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-05-15 21:15:09 +04:00
|
|
|
chp->ch_channel, cl),
|
|
|
|
DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x02;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0, 0x01);
|
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
if (cl != 0x01) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d drive 1 wd_sector: "
|
2004-05-15 21:15:09 +04:00
|
|
|
"got 0x%x != 0x01\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-05-15 21:15:09 +04:00
|
|
|
chp->ch_channel, cl),
|
|
|
|
DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x02;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0, 0x02);
|
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
if (cl != 0x02) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d drive 1 wd_sector: "
|
2004-05-15 21:15:09 +04:00
|
|
|
"got 0x%x != 0x02\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-05-15 21:15:09 +04:00
|
|
|
chp->ch_channel, cl),
|
|
|
|
DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x02;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0);
|
2004-05-15 21:15:09 +04:00
|
|
|
if (cl != 0x01) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d drive 1 wd_cyl_lo(2): "
|
2004-05-15 21:15:09 +04:00
|
|
|
"got 0x%x != 0x01\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-05-15 21:15:09 +04:00
|
|
|
chp->ch_channel, cl),
|
|
|
|
DEBUG_PROBE);
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value &= ~0x02;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2003-10-08 14:58:12 +04:00
|
|
|
}
|
|
|
|
|
2004-05-15 21:15:09 +04:00
|
|
|
if (ret_value == 0) {
|
|
|
|
splx(s);
|
2003-10-08 14:58:12 +04:00
|
|
|
return 0;
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
2003-10-08 14:58:12 +04:00
|
|
|
}
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2004-05-15 21:15:09 +04:00
|
|
|
|
2004-06-24 01:10:52 +04:00
|
|
|
#if 0 /* XXX this break some ATA or ATAPI devices */
|
2004-05-15 21:15:09 +04:00
|
|
|
/*
|
|
|
|
* reset bus. Also send an ATAPI_RESET to devices, in case there are
|
|
|
|
* ATAPI device out there which don't react to the bus reset
|
|
|
|
*/
|
|
|
|
if (ret_value & 0x01) {
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->select)
|
2004-05-15 21:15:09 +04:00
|
|
|
wdc->select(chp,0);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
|
2004-05-15 21:15:09 +04:00
|
|
|
0, WDSD_IBM);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_command], 0,
|
2004-05-15 21:15:09 +04:00
|
|
|
ATAPI_SOFT_RESET);
|
|
|
|
}
|
|
|
|
if (ret_value & 0x02) {
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->select)
|
2004-05-15 21:15:09 +04:00
|
|
|
wdc->select(chp,0);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
|
2004-05-15 21:15:09 +04:00
|
|
|
0, WDSD_IBM | 0x10);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_command], 0,
|
2004-05-15 21:15:09 +04:00
|
|
|
ATAPI_SOFT_RESET);
|
|
|
|
}
|
2003-11-26 00:03:15 +03:00
|
|
|
|
2004-05-25 00:45:30 +04:00
|
|
|
delay(5000);
|
2004-06-24 01:10:52 +04:00
|
|
|
#endif
|
2004-05-25 00:45:30 +04:00
|
|
|
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,0);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0, WDSD_IBM);
|
2003-10-08 14:58:12 +04:00
|
|
|
delay(10); /* 400ns delay */
|
2004-05-15 21:15:09 +04:00
|
|
|
/* assert SRST, wait for reset to complete */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr,
|
2003-10-08 14:58:12 +04:00
|
|
|
WDCTL_RST | WDCTL_IDS | WDCTL_4BIT);
|
2004-03-25 22:45:09 +03:00
|
|
|
DELAY(1000);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr,
|
2004-03-25 22:45:09 +03:00
|
|
|
WDCTL_IDS | WDCTL_4BIT);
|
2003-10-08 14:58:12 +04:00
|
|
|
DELAY(2000);
|
2004-08-14 19:08:04 +04:00
|
|
|
(void) bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_error], 0);
|
|
|
|
bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, WDCTL_4BIT);
|
2003-10-08 14:58:12 +04:00
|
|
|
delay(10); /* 400ns delay */
|
2003-11-26 00:03:15 +03:00
|
|
|
/* ACK interrupt in case there is one pending left (Promise ATA100) */
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->irqack != NULL)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->irqack(chp);
|
2003-11-26 00:03:15 +03:00
|
|
|
splx(s);
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value = __wdcwait_reset(chp, ret_value, poll);
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d: after reset, ret_value=0x%d\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel,
|
2003-10-08 14:58:12 +04:00
|
|
|
ret_value), DEBUG_PROBE);
|
|
|
|
|
|
|
|
/* if reset failed, there's nothing here */
|
|
|
|
if (ret_value == 0)
|
|
|
|
return 0;
|
Fix probe code for IDE devices:
- Don't rely on ATA signature: some ide controllers seems to not transmit it
properly (SIMIDE on arm32 machines). Instead, when we guess a drive is here
after reset, just mark it as ATA and OLD is it's not ATAPI.
- at attach time, use IDENTIFY to eliminate ghost from the probe. If the
drive had the old flag and IDENTIFY failed, issue a WDCC_RECAL command
to detect a pre-ATA disk. If IDENTIFY succeded, remove the OLD flag,
it's obviously not a pre-ATA disk.
- add a new controller flag, WDC_CAPABILITY_PREATA, used to shorcut parts
of the probe (not necessary, but makes the probe/attach faster). This is
only set by the ISA front-end, all other controllers supported can't have
pre-ATA drives attached.
The mechanism used are more or less the same as before, they have just been
reordered. Should solve port-arm32/7324 (waiting for feedback).
1999-04-12 00:50:28 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
/*
|
2004-01-02 00:18:28 +03:00
|
|
|
* Test presence of drives. First test register signatures looking
|
|
|
|
* for ATAPI devices. If it's not an ATAPI and reset said there may
|
|
|
|
* be something here assume it's ATA or OLD. Ghost will be killed
|
|
|
|
* later in attach routine.
|
1997-08-27 15:22:52 +04:00
|
|
|
*/
|
2003-10-08 14:58:12 +04:00
|
|
|
for (drive = 0; drive < 2; drive++) {
|
|
|
|
if ((ret_value & (0x01 << drive)) == 0)
|
|
|
|
continue;
|
2004-08-20 10:39:37 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,drive);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
|
2003-10-08 14:58:12 +04:00
|
|
|
WDSD_IBM | (drive << 4));
|
|
|
|
delay(10); /* 400ns delay */
|
|
|
|
/* Save registers contents */
|
2004-08-14 19:08:04 +04:00
|
|
|
sc = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_seccnt], 0);
|
|
|
|
sn = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0);
|
|
|
|
cl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0);
|
|
|
|
ch = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_hi], 0);
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d:%d: after reset, sc=0x%x sn=0x%x "
|
2003-10-08 14:58:12 +04:00
|
|
|
"cl=0x%x ch=0x%x\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, drive, sc, sn, cl, ch), DEBUG_PROBE);
|
1998-10-12 20:09:10 +04:00
|
|
|
/*
|
2003-10-08 14:58:12 +04:00
|
|
|
* sc & sn are supposted to be 0x1 for ATAPI but in some cases
|
|
|
|
* we get wrong values here, so ignore it.
|
1998-10-12 20:09:10 +04:00
|
|
|
*/
|
2004-08-21 04:28:34 +04:00
|
|
|
s = splbio();
|
2003-10-08 14:58:12 +04:00
|
|
|
if (cl == 0x14 && ch == 0xeb) {
|
|
|
|
chp->ch_drive[drive].drive_flags |= DRIVE_ATAPI;
|
|
|
|
} else {
|
|
|
|
chp->ch_drive[drive].drive_flags |= DRIVE_ATA;
|
2004-01-04 01:56:52 +03:00
|
|
|
if (wdc == NULL ||
|
|
|
|
(wdc->cap & WDC_CAPABILITY_PREATA) != 0)
|
2003-10-08 14:58:12 +04:00
|
|
|
chp->ch_drive[drive].drive_flags |= DRIVE_OLD;
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
2004-08-21 04:28:34 +04:00
|
|
|
splx(s);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
2003-10-08 14:58:12 +04:00
|
|
|
return (ret_value);
|
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
|
2003-10-08 14:58:12 +04:00
|
|
|
void
|
2004-08-14 19:08:04 +04:00
|
|
|
wdcattach(struct ata_channel *chp)
|
2003-10-08 14:58:12 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
1998-10-13 12:59:45 +04:00
|
|
|
|
2004-08-14 19:08:04 +04:00
|
|
|
/*
|
|
|
|
* Start out assuming 2 drives. This may change as we probe
|
|
|
|
* drives.
|
|
|
|
*/
|
|
|
|
chp->ch_ndrive = 2;
|
|
|
|
|
2004-08-11 22:41:46 +04:00
|
|
|
/* default data transfer methods */
|
2004-08-21 02:17:06 +04:00
|
|
|
if (wdc->datain_pio == NULL)
|
2004-08-11 22:41:46 +04:00
|
|
|
wdc->datain_pio = wdc_datain_pio;
|
2004-08-21 02:17:06 +04:00
|
|
|
if (wdc->dataout_pio == NULL)
|
2004-08-11 22:41:46 +04:00
|
|
|
wdc->dataout_pio = wdc_dataout_pio;
|
|
|
|
|
2003-10-08 14:58:12 +04:00
|
|
|
/* initialise global data */
|
2004-08-21 00:52:31 +04:00
|
|
|
if (atac->atac_bustype_ata == NULL)
|
|
|
|
atac->atac_bustype_ata = &wdc_ata_bustype;
|
2004-08-20 10:39:37 +04:00
|
|
|
if (atac->atac_probe == NULL)
|
|
|
|
atac->atac_probe = wdc_drvprobe;
|
2004-08-21 00:52:31 +04:00
|
|
|
#if NATAPIBUS > 0
|
|
|
|
if (atac->atac_atapibus_attach == NULL)
|
|
|
|
atac->atac_atapibus_attach = wdc_atapibus_attach;
|
|
|
|
#endif
|
2004-08-13 01:34:52 +04:00
|
|
|
|
2004-08-21 02:17:06 +04:00
|
|
|
ata_channel_attach(chp);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
|
2003-12-30 19:40:12 +03:00
|
|
|
int
|
|
|
|
wdcactivate(struct device *self, enum devact act)
|
2003-10-08 14:58:12 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = (struct atac_softc *) self;
|
2003-10-08 14:58:12 +04:00
|
|
|
int s, i, error = 0;
|
|
|
|
|
|
|
|
s = splbio();
|
|
|
|
switch (act) {
|
|
|
|
case DVACT_ACTIVATE:
|
|
|
|
error = EOPNOTSUPP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DVACT_DEACTIVATE:
|
2004-08-20 10:39:37 +04:00
|
|
|
for (i = 0; i < atac->atac_nchannels; i++) {
|
|
|
|
error =
|
|
|
|
config_deactivate(atac->atac_channels[i]->atabus);
|
2003-10-08 14:58:12 +04:00
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2003-12-30 19:40:12 +03:00
|
|
|
wdcdetach(struct device *self, int flags)
|
2003-10-08 14:58:12 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = (struct atac_softc *) self;
|
2004-08-14 19:08:04 +04:00
|
|
|
struct ata_channel *chp;
|
2004-08-20 10:39:37 +04:00
|
|
|
struct scsipi_adapter *adapt = &atac->atac_atapi_adapter._generic;
|
2003-10-08 14:58:12 +04:00
|
|
|
int i, error = 0;
|
|
|
|
|
2004-08-20 10:39:37 +04:00
|
|
|
for (i = 0; i < atac->atac_nchannels; i++) {
|
|
|
|
chp = atac->atac_channels[i];
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("wdcdetach: %s: detaching %s\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->atabus->dv_xname),
|
|
|
|
DEBUG_DETACH);
|
2003-10-08 14:58:12 +04:00
|
|
|
error = config_detach(chp->atabus, flags);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
2004-08-10 06:40:51 +04:00
|
|
|
if (adapt->adapt_refcnt != 0) {
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
printf("wdcdetach: refcnt should be 0 here??\n");
|
|
|
|
#endif
|
2004-08-20 10:39:37 +04:00
|
|
|
(void) (*adapt->adapt_enable)(&atac->atac_dev, 0);
|
2004-08-10 06:40:51 +04:00
|
|
|
}
|
2003-10-08 14:58:12 +04:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
/* restart an interrupted I/O */
|
|
|
|
void
|
2003-12-30 19:40:12 +03:00
|
|
|
wdcrestart(void *v)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
2004-08-14 19:08:04 +04:00
|
|
|
struct ata_channel *chp = v;
|
1998-10-12 20:09:10 +04:00
|
|
|
int s;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
s = splbio();
|
2004-08-13 06:16:40 +04:00
|
|
|
atastart(chp);
|
1998-10-12 20:09:10 +04:00
|
|
|
splx(s);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
/*
|
|
|
|
* Interrupt routine for the controller. Acknowledge the interrupt, check for
|
|
|
|
* errors on the current operation, mark it done if necessary, and start the
|
|
|
|
* next request. Also check for a partially done transfer, and continue with
|
|
|
|
* the next chunk if so.
|
|
|
|
*/
|
|
|
|
int
|
2003-12-30 19:40:12 +03:00
|
|
|
wdcintr(void *arg)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
2004-08-14 19:08:04 +04:00
|
|
|
struct ata_channel *chp = arg;
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
2004-01-01 20:18:53 +03:00
|
|
|
struct ata_xfer *xfer;
|
1999-10-21 18:37:58 +04:00
|
|
|
int ret;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2004-08-20 10:39:37 +04:00
|
|
|
if ((atac->atac_dev.dv_flags & DVF_ACTIVE) == 0) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("wdcintr: deactivated controller\n"),
|
2000-03-21 01:53:36 +03:00
|
|
|
DEBUG_INTR);
|
|
|
|
return (0);
|
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
if ((chp->ch_flags & ATACH_IRQ_WAIT) == 0) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("wdcintr: inactive controller\n"), DEBUG_INTR);
|
2002-03-29 01:51:58 +03:00
|
|
|
/* try to clear the pending interrupt anyway */
|
2004-08-14 19:08:04 +04:00
|
|
|
(void)bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_status], 0);
|
2000-03-21 01:53:36 +03:00
|
|
|
return (0);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("wdcintr\n"), DEBUG_INTR);
|
2004-08-04 22:24:10 +04:00
|
|
|
xfer = chp->ch_queue->active_xfer;
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (xfer == NULL)
|
|
|
|
panic("wdcintr: no xfer");
|
|
|
|
#endif
|
2004-08-14 19:08:04 +04:00
|
|
|
if (chp->ch_flags & ATACH_DMA_WAIT) {
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->dma_status =
|
|
|
|
(*wdc->dma_finish)(wdc->dma_arg, chp->ch_channel,
|
2004-08-03 02:20:54 +04:00
|
|
|
xfer->c_drive, WDC_DMAEND_END);
|
2004-01-04 01:56:52 +03:00
|
|
|
if (wdc->dma_status & WDC_DMAST_NOIRQ) {
|
2000-04-01 18:32:22 +04:00
|
|
|
/* IRQ not for us, not detected by DMA engine */
|
|
|
|
return 0;
|
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
chp->ch_flags &= ~ATACH_DMA_WAIT;
|
2000-04-01 18:32:22 +04:00
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
chp->ch_flags &= ~ATACH_IRQ_WAIT;
|
1999-10-21 18:37:58 +04:00
|
|
|
ret = xfer->c_intr(chp, xfer, 1);
|
|
|
|
if (ret == 0) /* irq was not for us, still waiting for irq */
|
2004-08-14 19:08:04 +04:00
|
|
|
chp->ch_flags |= ATACH_IRQ_WAIT;
|
1999-10-21 18:37:58 +04:00
|
|
|
return (ret);
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Put all disk in RESET state */
|
2003-09-20 01:35:56 +04:00
|
|
|
void
|
2004-08-02 01:40:41 +04:00
|
|
|
wdc_reset_drive(struct ata_drive_datas *drvp, int flags)
|
1998-10-12 20:09:10 +04:00
|
|
|
{
|
2004-08-14 19:08:04 +04:00
|
|
|
struct ata_channel *chp = drvp->chnl_softc;
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
|
2004-08-21 03:26:53 +04:00
|
|
|
ATADEBUG_PRINT(("wdc_reset_drive %s:%d for drive %d\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel, drvp->drive),
|
1998-10-13 19:02:41 +04:00
|
|
|
DEBUG_FUNCS);
|
2004-08-01 01:26:42 +04:00
|
|
|
|
2004-08-21 03:26:53 +04:00
|
|
|
ata_reset_channel(chp, flags);
|
2004-08-01 01:26:42 +04:00
|
|
|
}
|
|
|
|
|
2004-08-02 01:40:41 +04:00
|
|
|
void
|
2004-08-14 19:08:04 +04:00
|
|
|
wdc_reset_channel(struct ata_channel *chp, int flags)
|
2004-08-01 01:26:42 +04:00
|
|
|
{
|
2004-08-04 22:24:10 +04:00
|
|
|
TAILQ_HEAD(, ata_xfer) reset_xfer;
|
2004-08-02 01:40:41 +04:00
|
|
|
struct ata_xfer *xfer, *next_xfer;
|
2004-08-20 10:39:37 +04:00
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-01 01:26:42 +04:00
|
|
|
|
2004-08-04 22:24:10 +04:00
|
|
|
TAILQ_INIT(&reset_xfer);
|
2004-08-03 02:02:35 +04:00
|
|
|
|
2004-08-14 19:08:04 +04:00
|
|
|
chp->ch_flags &= ~ATACH_IRQ_WAIT;
|
2004-08-21 03:26:53 +04:00
|
|
|
|
2004-08-04 22:24:10 +04:00
|
|
|
/*
|
|
|
|
* if the current command if on an ATAPI device, issue a
|
|
|
|
* ATAPI_SOFT_RESET
|
|
|
|
*/
|
|
|
|
xfer = chp->ch_queue->active_xfer;
|
|
|
|
if (xfer && xfer->c_chp == chp && (xfer->c_flags & C_ATAPI)) {
|
|
|
|
wdccommandshort(chp, xfer->c_drive, ATAPI_SOFT_RESET);
|
|
|
|
if (flags & AT_WAIT)
|
|
|
|
tsleep(&flags, PRIBIO, "atardl", mstohz(1) + 1);
|
|
|
|
else
|
|
|
|
delay(1000);
|
2004-08-03 02:02:35 +04:00
|
|
|
}
|
|
|
|
|
2004-08-04 22:24:10 +04:00
|
|
|
/* reset the channel */
|
|
|
|
if (flags & AT_WAIT)
|
|
|
|
(void) wdcreset(chp, RESET_SLEEP);
|
|
|
|
else
|
|
|
|
(void) wdcreset(chp, RESET_POLL);
|
|
|
|
|
2004-08-03 02:02:35 +04:00
|
|
|
/*
|
2004-08-04 22:24:10 +04:00
|
|
|
* wait a bit after reset; in case the DMA engines needs some time
|
2004-08-03 02:02:35 +04:00
|
|
|
* to recover.
|
|
|
|
*/
|
|
|
|
if (flags & AT_WAIT)
|
2004-08-04 22:24:10 +04:00
|
|
|
tsleep(&flags, PRIBIO, "atardl", mstohz(1) + 1);
|
2004-08-03 02:02:35 +04:00
|
|
|
else
|
|
|
|
delay(1000);
|
2004-08-01 01:26:42 +04:00
|
|
|
/*
|
|
|
|
* look for pending xfers. If we have a shared queue, we'll also reset
|
|
|
|
* the other channel if the current xfer is running on it.
|
2004-08-03 02:02:35 +04:00
|
|
|
* Then we'll dequeue only the xfers for this channel.
|
2004-08-01 01:26:42 +04:00
|
|
|
*/
|
|
|
|
if ((flags & AT_RST_NOCMD) == 0) {
|
2004-08-04 22:24:10 +04:00
|
|
|
/*
|
|
|
|
* move all xfers queued for this channel to the reset queue,
|
|
|
|
* and then process the current xfer and then the reset queue.
|
|
|
|
* We have to use a temporary queue because c_kill_xfer()
|
|
|
|
* may requeue commands.
|
|
|
|
*/
|
|
|
|
for (xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer);
|
|
|
|
xfer != NULL; xfer = next_xfer) {
|
|
|
|
next_xfer = TAILQ_NEXT(xfer, c_xferchain);
|
|
|
|
if (xfer->c_chp != chp)
|
|
|
|
continue;
|
|
|
|
TAILQ_REMOVE(&chp->ch_queue->queue_xfer,
|
|
|
|
xfer, c_xferchain);
|
|
|
|
TAILQ_INSERT_TAIL(&reset_xfer, xfer, c_xferchain);
|
|
|
|
}
|
|
|
|
xfer = chp->ch_queue->active_xfer;
|
2004-08-03 02:02:35 +04:00
|
|
|
if (xfer) {
|
|
|
|
if (xfer->c_chp != chp)
|
2004-08-21 03:26:53 +04:00
|
|
|
ata_reset_channel(xfer->c_chp, flags);
|
2004-08-03 02:02:35 +04:00
|
|
|
else {
|
2004-08-04 22:24:10 +04:00
|
|
|
callout_stop(&chp->ch_callout);
|
2004-08-03 02:02:35 +04:00
|
|
|
/*
|
|
|
|
* If we're waiting for DMA, stop the
|
|
|
|
* DMA engine
|
|
|
|
*/
|
2004-08-14 19:08:04 +04:00
|
|
|
if (chp->ch_flags & ATACH_DMA_WAIT) {
|
2004-08-20 10:39:37 +04:00
|
|
|
(*wdc->dma_finish)(
|
|
|
|
wdc->dma_arg,
|
2004-08-03 02:02:35 +04:00
|
|
|
chp->ch_channel,
|
|
|
|
xfer->c_drive,
|
2004-08-03 02:20:54 +04:00
|
|
|
WDC_DMAEND_ABRT_QUIET);
|
2004-08-14 19:08:04 +04:00
|
|
|
chp->ch_flags &= ~ATACH_DMA_WAIT;
|
2004-08-03 02:02:35 +04:00
|
|
|
}
|
2004-08-04 22:24:10 +04:00
|
|
|
chp->ch_queue->active_xfer = NULL;
|
|
|
|
if ((flags & AT_RST_EMERG) == 0)
|
|
|
|
xfer->c_kill_xfer(
|
|
|
|
chp, xfer, KILL_RESET);
|
2004-08-03 02:02:35 +04:00
|
|
|
}
|
|
|
|
}
|
2004-08-04 22:24:10 +04:00
|
|
|
|
|
|
|
for (xfer = TAILQ_FIRST(&reset_xfer);
|
2004-08-02 01:40:41 +04:00
|
|
|
xfer != NULL; xfer = next_xfer) {
|
|
|
|
next_xfer = TAILQ_NEXT(xfer, c_xferchain);
|
2004-08-04 22:24:10 +04:00
|
|
|
TAILQ_REMOVE(&reset_xfer, xfer, c_xferchain);
|
2004-08-01 01:26:42 +04:00
|
|
|
if ((flags & AT_RST_EMERG) == 0)
|
|
|
|
xfer->c_kill_xfer(chp, xfer, KILL_RESET);
|
|
|
|
}
|
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2004-08-21 05:51:46 +04:00
|
|
|
static int
|
2004-08-14 19:08:04 +04:00
|
|
|
wdcreset(struct ata_channel *chp, int poll)
|
1998-10-12 20:09:10 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
1998-10-12 20:09:10 +04:00
|
|
|
int drv_mask1, drv_mask2;
|
2003-11-26 00:03:15 +03:00
|
|
|
int s = 0;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2004-08-13 07:12:59 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,0);
|
2003-11-26 00:03:15 +03:00
|
|
|
if (poll != RESET_SLEEP)
|
|
|
|
s = splbio();
|
There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.
To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.
bus_space_write_4(tag, handle, offset, value)
becomes
bus_space_write_4(tag, handles[offset], 0, value)
Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
2003-11-28 02:02:40 +03:00
|
|
|
/* master */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0, WDSD_IBM);
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
delay(10); /* 400ns delay */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr,
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
WDCTL_RST | WDCTL_IDS | WDCTL_4BIT);
|
|
|
|
delay(2000);
|
2004-08-14 19:08:04 +04:00
|
|
|
(void) bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_error], 0);
|
|
|
|
bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr,
|
2003-10-08 14:58:12 +04:00
|
|
|
WDCTL_4BIT | WDCTL_IDS);
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
delay(10); /* 400ns delay */
|
2003-11-26 00:03:15 +03:00
|
|
|
if (poll != RESET_SLEEP) {
|
2004-08-13 07:12:59 +04:00
|
|
|
if (wdc->irqack)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->irqack(chp);
|
2003-11-26 00:03:15 +03:00
|
|
|
splx(s);
|
|
|
|
}
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
drv_mask1 = (chp->ch_drive[0].drive_flags & DRIVE) ? 0x01:0x00;
|
|
|
|
drv_mask1 |= (chp->ch_drive[1].drive_flags & DRIVE) ? 0x02:0x00;
|
2003-10-08 14:58:12 +04:00
|
|
|
drv_mask2 = __wdcwait_reset(chp, drv_mask1,
|
|
|
|
(poll == RESET_SLEEP) ? 0 : 1);
|
|
|
|
if (drv_mask2 != drv_mask1) {
|
1998-10-12 20:09:10 +04:00
|
|
|
printf("%s channel %d: reset failed for",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel);
|
1998-10-12 20:09:10 +04:00
|
|
|
if ((drv_mask1 & 0x01) != 0 && (drv_mask2 & 0x01) == 0)
|
|
|
|
printf(" drive 0");
|
|
|
|
if ((drv_mask1 & 0x02) != 0 && (drv_mask2 & 0x02) == 0)
|
|
|
|
printf(" drive 1");
|
|
|
|
printf("\n");
|
|
|
|
}
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr, WDCTL_4BIT);
|
1998-10-12 20:09:10 +04:00
|
|
|
return (drv_mask1 != drv_mask2) ? 1 : 0;
|
|
|
|
}
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
static int
|
2004-08-14 19:08:04 +04:00
|
|
|
__wdcwait_reset(struct ata_channel *chp, int drv_mask, int poll)
|
1998-10-12 20:09:10 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
2003-10-08 14:58:12 +04:00
|
|
|
int timeout, nloop;
|
2003-10-30 01:09:41 +03:00
|
|
|
u_int8_t st0 = 0, st1 = 0;
|
2004-08-13 08:10:49 +04:00
|
|
|
#ifdef ATADEBUG
|
2003-10-25 12:37:00 +04:00
|
|
|
u_int8_t sc0 = 0, sn0 = 0, cl0 = 0, ch0 = 0;
|
|
|
|
u_int8_t sc1 = 0, sn1 = 0, cl1 = 0, ch1 = 0;
|
1999-08-06 16:00:23 +04:00
|
|
|
#endif
|
2003-10-08 14:58:12 +04:00
|
|
|
|
|
|
|
if (poll)
|
|
|
|
nloop = WDCNDELAY_RST;
|
|
|
|
else
|
|
|
|
nloop = WDC_RESET_WAIT * hz / 1000;
|
1998-10-12 20:09:10 +04:00
|
|
|
/* wait for BSY to deassert */
|
2003-10-08 14:58:12 +04:00
|
|
|
for (timeout = 0; timeout < nloop; timeout++) {
|
2004-05-15 21:15:09 +04:00
|
|
|
if ((drv_mask & 0x01) != 0) {
|
2004-08-13 07:12:59 +04:00
|
|
|
if (wdc && wdc->select)
|
2004-05-15 21:15:09 +04:00
|
|
|
wdc->select(chp,0);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
|
2004-05-15 21:15:09 +04:00
|
|
|
0, WDSD_IBM); /* master */
|
|
|
|
delay(10);
|
2004-08-14 19:08:04 +04:00
|
|
|
st0 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_status], 0);
|
2004-08-13 08:10:49 +04:00
|
|
|
#ifdef ATADEBUG
|
2004-08-14 19:08:04 +04:00
|
|
|
sc0 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_seccnt], 0);
|
|
|
|
sn0 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0);
|
|
|
|
cl0 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0);
|
|
|
|
ch0 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_hi], 0);
|
1999-08-06 16:00:23 +04:00
|
|
|
#endif
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
|
|
|
if ((drv_mask & 0x02) != 0) {
|
2004-08-13 07:12:59 +04:00
|
|
|
if (wdc && wdc->select)
|
2004-05-15 21:15:09 +04:00
|
|
|
wdc->select(chp,1);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh],
|
2004-05-15 21:15:09 +04:00
|
|
|
0, WDSD_IBM | 0x10); /* slave */
|
|
|
|
delay(10);
|
2004-08-14 19:08:04 +04:00
|
|
|
st1 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_status], 0);
|
2004-08-13 08:10:49 +04:00
|
|
|
#ifdef ATADEBUG
|
2004-08-14 19:08:04 +04:00
|
|
|
sc1 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_seccnt], 0);
|
|
|
|
sn1 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0);
|
|
|
|
cl1 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0);
|
|
|
|
ch1 = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_hi], 0);
|
1999-08-06 16:00:23 +04:00
|
|
|
#endif
|
2004-05-15 21:15:09 +04:00
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
if ((drv_mask & 0x01) == 0) {
|
|
|
|
/* no master */
|
|
|
|
if ((drv_mask & 0x02) != 0 && (st1 & WDCS_BSY) == 0) {
|
|
|
|
/* No master, slave is ready, it's done */
|
1999-03-31 15:18:31 +04:00
|
|
|
goto end;
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
} else if ((drv_mask & 0x02) == 0) {
|
|
|
|
/* no slave */
|
|
|
|
if ((drv_mask & 0x01) != 0 && (st0 & WDCS_BSY) == 0) {
|
|
|
|
/* No slave, master is ready, it's done */
|
1999-03-31 15:18:31 +04:00
|
|
|
goto end;
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
} else {
|
1998-10-12 20:09:10 +04:00
|
|
|
/* Wait for both master and slave to be ready */
|
|
|
|
if ((st0 & WDCS_BSY) == 0 && (st1 & WDCS_BSY) == 0) {
|
1999-03-31 15:18:31 +04:00
|
|
|
goto end;
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
2003-10-08 14:58:12 +04:00
|
|
|
if (poll)
|
|
|
|
delay(WDCDELAY);
|
|
|
|
else
|
|
|
|
tsleep(&nloop, PRIBIO, "atarst", 1);
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
2002-07-26 18:10:22 +04:00
|
|
|
/* Reset timed out. Maybe it's because drv_mask was not right */
|
1998-10-12 20:09:10 +04:00
|
|
|
if (st0 & WDCS_BSY)
|
|
|
|
drv_mask &= ~0x01;
|
|
|
|
if (st1 & WDCS_BSY)
|
|
|
|
drv_mask &= ~0x02;
|
1999-03-31 15:18:31 +04:00
|
|
|
end:
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d:0: after reset, sc=0x%x sn=0x%x "
|
1999-08-06 16:00:23 +04:00
|
|
|
"cl=0x%x ch=0x%x\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, sc0, sn0, cl0, ch0), DEBUG_PROBE);
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d:1: after reset, sc=0x%x sn=0x%x "
|
1999-08-06 16:00:23 +04:00
|
|
|
"cl=0x%x ch=0x%x\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, sc1, sn1, cl1, ch1), DEBUG_PROBE);
|
1999-08-06 16:00:23 +04:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("%s:%d: wdcwait_reset() end, st0=0x%x st1=0x%x\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel,
|
2003-10-30 01:09:41 +03:00
|
|
|
st0, st1), DEBUG_PROBE);
|
1999-03-31 15:18:31 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
return drv_mask;
|
|
|
|
}
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
/*
|
|
|
|
* Wait for a drive to be !BSY, and have mask in its status register.
|
|
|
|
* return -1 for a timeout after "timeout" ms.
|
|
|
|
*/
|
2004-01-02 00:18:28 +03:00
|
|
|
static int
|
2004-08-14 19:08:04 +04:00
|
|
|
__wdcwait(struct ata_channel *chp, int mask, int bits, int timeout)
|
1998-10-12 20:09:10 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
1998-10-12 20:09:10 +04:00
|
|
|
u_char status;
|
|
|
|
int time = 0;
|
1999-02-21 05:07:52 +03:00
|
|
|
|
2004-08-20 10:39:37 +04:00
|
|
|
ATADEBUG_PRINT(("__wdcwait %s:%d\n",
|
|
|
|
atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel), DEBUG_STATUS);
|
1998-10-12 20:09:10 +04:00
|
|
|
chp->ch_error = 0;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
timeout = timeout * 1000 / WDCDELAY; /* delay uses microseconds */
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
for (;;) {
|
|
|
|
chp->ch_status = status =
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_status], 0);
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
if ((status & (WDCS_BSY | mask)) == bits)
|
1997-08-27 15:22:52 +04:00
|
|
|
break;
|
1998-10-12 20:09:10 +04:00
|
|
|
if (++time > timeout) {
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("__wdcwait: timeout (time=%d), "
|
2000-04-04 16:43:13 +04:00
|
|
|
"status %x error %x (mask 0x%x bits 0x%x)\n",
|
|
|
|
time, status,
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_error], 0), mask, bits),
|
2000-04-04 16:43:13 +04:00
|
|
|
DEBUG_STATUS | DEBUG_PROBE | DEBUG_DELAY);
|
2003-10-08 14:58:12 +04:00
|
|
|
return(WDCWAIT_TOUT);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
delay(WDCDELAY);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
2004-08-13 08:10:49 +04:00
|
|
|
#ifdef ATADEBUG
|
|
|
|
if (time > 0 && (atadebug_mask & DEBUG_DELAY))
|
2003-10-08 14:58:12 +04:00
|
|
|
printf("__wdcwait: did busy-wait, time=%d\n", time);
|
2000-04-04 16:43:13 +04:00
|
|
|
#endif
|
1998-10-12 20:09:10 +04:00
|
|
|
if (status & WDCS_ERR)
|
2004-08-14 19:08:04 +04:00
|
|
|
chp->ch_error = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_error], 0);
|
1998-10-12 20:09:10 +04:00
|
|
|
#ifdef WDCNDELAY_DEBUG
|
|
|
|
/* After autoconfig, there should be no long delays. */
|
|
|
|
if (!cold && time > WDCNDELAY_DEBUG) {
|
2004-08-04 22:24:10 +04:00
|
|
|
struct ata_xfer *xfer = chp->ch_queue->active_xfer;
|
1998-10-12 20:09:10 +04:00
|
|
|
if (xfer == NULL)
|
|
|
|
printf("%s channel %d: warning: busy-wait took %dus\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel,
|
1998-10-12 20:09:10 +04:00
|
|
|
WDCDELAY * time);
|
|
|
|
else
|
|
|
|
printf("%s:%d:%d: warning: busy-wait took %dus\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel,
|
1998-10-12 20:09:10 +04:00
|
|
|
xfer->drive,
|
|
|
|
WDCDELAY * time);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
#endif
|
2003-10-08 14:58:12 +04:00
|
|
|
return(WDCWAIT_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call __wdcwait(), polling using tsleep() or waking up the kernel
|
|
|
|
* thread if possible
|
|
|
|
*/
|
|
|
|
int
|
2004-08-14 19:08:04 +04:00
|
|
|
wdcwait(struct ata_channel *chp, int mask, int bits, int timeout, int flags)
|
2003-10-08 14:58:12 +04:00
|
|
|
{
|
|
|
|
int error, i, timeout_hz = mstohz(timeout);
|
|
|
|
|
|
|
|
if (timeout_hz == 0 ||
|
|
|
|
(flags & (AT_WAIT | AT_POLL)) == AT_POLL)
|
|
|
|
error = __wdcwait(chp, mask, bits, timeout);
|
|
|
|
else {
|
|
|
|
error = __wdcwait(chp, mask, bits, WDCDELAY_POLL);
|
|
|
|
if (error != 0) {
|
2004-08-14 19:08:04 +04:00
|
|
|
if ((chp->ch_flags & ATACH_TH_RUN) ||
|
2003-10-30 00:44:41 +03:00
|
|
|
(flags & AT_WAIT)) {
|
2003-10-08 14:58:12 +04:00
|
|
|
/*
|
2003-10-30 00:44:41 +03:00
|
|
|
* we're running in the channel thread
|
|
|
|
* or some userland thread context
|
2003-10-08 14:58:12 +04:00
|
|
|
*/
|
|
|
|
for (i = 0; i < timeout_hz; i++) {
|
|
|
|
if (__wdcwait(chp, mask, bits,
|
|
|
|
WDCDELAY_POLL) == 0) {
|
|
|
|
error = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tsleep(&chp, PRIBIO, "atapoll", 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* we're probably in interrupt context,
|
|
|
|
* ask the thread to come back here
|
|
|
|
*/
|
2003-10-30 00:44:41 +03:00
|
|
|
#ifdef DIAGNOSTIC
|
2003-10-30 01:05:15 +03:00
|
|
|
if (chp->ch_queue->queue_freeze > 0)
|
|
|
|
panic("wdcwait: queue_freeze");
|
2003-10-30 00:44:41 +03:00
|
|
|
#endif
|
2003-10-30 01:05:15 +03:00
|
|
|
chp->ch_queue->queue_freeze++;
|
2004-01-04 02:59:58 +03:00
|
|
|
wakeup(&chp->ch_thread);
|
2003-10-08 14:58:12 +04:00
|
|
|
return(WDCWAIT_THR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-12-30 19:40:12 +03:00
|
|
|
return (error);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2000-04-01 18:32:22 +04:00
|
|
|
/*
|
|
|
|
* Busy-wait for DMA to complete
|
|
|
|
*/
|
|
|
|
int
|
2004-08-14 19:08:04 +04:00
|
|
|
wdc_dmawait(struct ata_channel *chp, struct ata_xfer *xfer, int timeout)
|
2000-04-01 18:32:22 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2000-04-01 18:32:22 +04:00
|
|
|
int time;
|
2004-01-04 01:56:52 +03:00
|
|
|
|
2000-04-01 18:32:22 +04:00
|
|
|
for (time = 0; time < timeout * 1000 / WDCDELAY; time++) {
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->dma_status =
|
|
|
|
(*wdc->dma_finish)(wdc->dma_arg,
|
2004-08-03 02:20:54 +04:00
|
|
|
chp->ch_channel, xfer->c_drive, WDC_DMAEND_END);
|
2004-01-04 01:56:52 +03:00
|
|
|
if ((wdc->dma_status & WDC_DMAST_NOIRQ) == 0)
|
2000-04-01 18:32:22 +04:00
|
|
|
return 0;
|
|
|
|
delay(WDCDELAY);
|
|
|
|
}
|
|
|
|
/* timeout, force a DMA halt */
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->dma_status = (*wdc->dma_finish)(wdc->dma_arg,
|
2004-08-03 02:20:54 +04:00
|
|
|
chp->ch_channel, xfer->c_drive, WDC_DMAEND_ABRT);
|
2000-04-01 18:32:22 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
void
|
2003-12-30 19:40:12 +03:00
|
|
|
wdctimeout(void *arg)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
2004-08-14 19:08:04 +04:00
|
|
|
struct ata_channel *chp = (struct ata_channel *)arg;
|
2004-08-20 10:39:37 +04:00
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-04 22:24:10 +04:00
|
|
|
struct ata_xfer *xfer = chp->ch_queue->active_xfer;
|
1998-10-12 20:09:10 +04:00
|
|
|
int s;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("wdctimeout\n"), DEBUG_FUNCS);
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
s = splbio();
|
2004-08-14 19:08:04 +04:00
|
|
|
if ((chp->ch_flags & ATACH_IRQ_WAIT) != 0) {
|
1998-10-12 20:09:10 +04:00
|
|
|
__wdcerror(chp, "lost interrupt");
|
2000-04-05 10:27:36 +04:00
|
|
|
printf("\ttype: %s tc_bcount: %d tc_skip: %d\n",
|
|
|
|
(xfer->c_flags & C_ATAPI) ? "atapi" : "ata",
|
|
|
|
xfer->c_bcount,
|
|
|
|
xfer->c_skip);
|
2004-08-14 19:08:04 +04:00
|
|
|
if (chp->ch_flags & ATACH_DMA_WAIT) {
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->dma_status =
|
|
|
|
(*wdc->dma_finish)(wdc->dma_arg,
|
2004-08-03 02:20:54 +04:00
|
|
|
chp->ch_channel, xfer->c_drive,
|
|
|
|
WDC_DMAEND_ABRT);
|
2004-08-14 19:08:04 +04:00
|
|
|
chp->ch_flags &= ~ATACH_DMA_WAIT;
|
2000-04-01 18:32:22 +04:00
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
/*
|
2002-12-06 17:05:34 +03:00
|
|
|
* Call the interrupt routine. If we just missed an interrupt,
|
1998-10-12 20:09:10 +04:00
|
|
|
* it will do what's needed. Else, it will take the needed
|
|
|
|
* action (reset the device).
|
1999-08-06 16:00:23 +04:00
|
|
|
* Before that we need to reinstall the timeout callback,
|
|
|
|
* in case it will miss another irq while in this transfer
|
|
|
|
* We arbitray chose it to be 1s
|
1998-10-12 20:09:10 +04:00
|
|
|
*/
|
2000-03-23 10:01:25 +03:00
|
|
|
callout_reset(&chp->ch_callout, hz, wdctimeout, chp);
|
1998-10-12 20:09:10 +04:00
|
|
|
xfer->c_flags |= C_TIMEOU;
|
2004-08-14 19:08:04 +04:00
|
|
|
chp->ch_flags &= ~ATACH_IRQ_WAIT;
|
1999-04-02 01:46:28 +04:00
|
|
|
xfer->c_intr(chp, xfer, 1);
|
1998-10-12 20:09:10 +04:00
|
|
|
} else
|
|
|
|
__wdcerror(chp, "missing untimeout");
|
|
|
|
splx(s);
|
|
|
|
}
|
1997-08-27 15:22:52 +04:00
|
|
|
|
|
|
|
int
|
2004-08-12 08:57:19 +04:00
|
|
|
wdc_exec_command(struct ata_drive_datas *drvp, struct ata_command *ata_c)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
2004-08-14 19:08:04 +04:00
|
|
|
struct ata_channel *chp = drvp->chnl_softc;
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
2004-01-01 20:18:53 +03:00
|
|
|
struct ata_xfer *xfer;
|
1998-10-12 20:09:10 +04:00
|
|
|
int s, ret;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("wdc_exec_command %s:%d:%d\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel, drvp->drive),
|
1998-10-13 19:02:41 +04:00
|
|
|
DEBUG_FUNCS);
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
/* set up an xfer and queue. Wait for completion */
|
2004-08-13 01:34:52 +04:00
|
|
|
xfer = ata_get_xfer(ata_c->flags & AT_WAIT ? ATAXF_CANSLEEP :
|
|
|
|
ATAXF_NOSLEEP);
|
1998-10-12 20:09:10 +04:00
|
|
|
if (xfer == NULL) {
|
2004-08-12 09:02:50 +04:00
|
|
|
return ATACMD_TRY_AGAIN;
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
|
|
|
|
2004-08-20 10:39:37 +04:00
|
|
|
if (atac->atac_cap & ATAC_CAP_NOIRQ)
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_POLL;
|
|
|
|
if (ata_c->flags & AT_POLL)
|
1998-10-12 20:09:10 +04:00
|
|
|
xfer->c_flags |= C_POLL;
|
2004-01-01 20:18:53 +03:00
|
|
|
xfer->c_drive = drvp->drive;
|
2004-08-12 08:57:19 +04:00
|
|
|
xfer->c_databuf = ata_c->data;
|
|
|
|
xfer->c_bcount = ata_c->bcount;
|
|
|
|
xfer->c_cmd = ata_c;
|
1998-10-12 20:09:10 +04:00
|
|
|
xfer->c_start = __wdccommand_start;
|
|
|
|
xfer->c_intr = __wdccommand_intr;
|
2004-08-01 01:26:42 +04:00
|
|
|
xfer->c_kill_xfer = __wdccommand_kill_xfer;
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
s = splbio();
|
2004-08-13 06:10:43 +04:00
|
|
|
ata_exec_xfer(chp, xfer);
|
1998-10-12 20:09:10 +04:00
|
|
|
#ifdef DIAGNOSTIC
|
2004-08-12 08:57:19 +04:00
|
|
|
if ((ata_c->flags & AT_POLL) != 0 &&
|
|
|
|
(ata_c->flags & AT_DONE) == 0)
|
2002-09-27 19:35:29 +04:00
|
|
|
panic("wdc_exec_command: polled command not done");
|
1997-08-27 15:22:52 +04:00
|
|
|
#endif
|
2004-08-12 08:57:19 +04:00
|
|
|
if (ata_c->flags & AT_DONE) {
|
2004-08-12 09:02:50 +04:00
|
|
|
ret = ATACMD_COMPLETE;
|
1998-10-12 20:09:10 +04:00
|
|
|
} else {
|
2004-08-12 08:57:19 +04:00
|
|
|
if (ata_c->flags & AT_WAIT) {
|
|
|
|
while ((ata_c->flags & AT_DONE) == 0) {
|
|
|
|
tsleep(ata_c, PRIBIO, "wdccmd", 0);
|
1999-07-30 18:59:10 +04:00
|
|
|
}
|
2004-08-12 09:02:50 +04:00
|
|
|
ret = ATACMD_COMPLETE;
|
1998-10-12 20:09:10 +04:00
|
|
|
} else {
|
2004-08-12 09:02:50 +04:00
|
|
|
ret = ATACMD_QUEUED;
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
splx(s);
|
1998-10-12 20:09:10 +04:00
|
|
|
return ret;
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
|
2004-01-02 00:18:28 +03:00
|
|
|
static void
|
2004-08-14 19:08:04 +04:00
|
|
|
__wdccommand_start(struct ata_channel *chp, struct ata_xfer *xfer)
|
1998-10-12 20:09:10 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
2004-01-01 20:18:53 +03:00
|
|
|
int drive = xfer->c_drive;
|
2004-08-12 08:57:19 +04:00
|
|
|
struct ata_command *ata_c = xfer->c_cmd;
|
1998-10-12 20:09:10 +04:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("__wdccommand_start %s:%d:%d\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive),
|
1998-10-13 19:02:41 +04:00
|
|
|
DEBUG_FUNCS);
|
1998-10-12 20:09:10 +04:00
|
|
|
|
2004-08-13 07:12:59 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,drive);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
|
1998-10-12 20:09:10 +04:00
|
|
|
WDSD_IBM | (drive << 4));
|
2004-08-12 08:57:19 +04:00
|
|
|
switch(wdcwait(chp, ata_c->r_st_bmask | WDCS_DRQ,
|
|
|
|
ata_c->r_st_bmask, ata_c->timeout, ata_c->flags)) {
|
2003-10-08 14:58:12 +04:00
|
|
|
case WDCWAIT_OK:
|
|
|
|
break;
|
|
|
|
case WDCWAIT_TOUT:
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_TIMEOU;
|
1998-10-12 20:09:10 +04:00
|
|
|
__wdccommand_done(chp, xfer);
|
1998-12-08 16:29:31 +03:00
|
|
|
return;
|
2003-10-08 14:58:12 +04:00
|
|
|
case WDCWAIT_THR:
|
|
|
|
return;
|
|
|
|
}
|
2004-08-12 08:57:19 +04:00
|
|
|
if (ata_c->flags & AT_POLL) {
|
2003-10-08 14:58:12 +04:00
|
|
|
/* polled command, disable interrupts */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr,
|
2003-10-08 14:58:12 +04:00
|
|
|
WDCTL_4BIT | WDCTL_IDS);
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
2004-08-12 08:57:19 +04:00
|
|
|
wdccommand(chp, drive, ata_c->r_command, ata_c->r_cyl, ata_c->r_head,
|
|
|
|
ata_c->r_sector, ata_c->r_count, ata_c->r_features);
|
2003-10-09 22:40:19 +04:00
|
|
|
|
2004-08-12 08:57:19 +04:00
|
|
|
if ((ata_c->flags & AT_POLL) == 0) {
|
2004-08-14 19:08:04 +04:00
|
|
|
chp->ch_flags |= ATACH_IRQ_WAIT; /* wait for interrupt */
|
2004-08-12 08:57:19 +04:00
|
|
|
callout_reset(&chp->ch_callout, ata_c->timeout / 1000 * hz,
|
2000-03-23 10:01:25 +03:00
|
|
|
wdctimeout, chp);
|
1998-10-12 20:09:10 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Polled command. Wait for drive ready or drq. Done in intr().
|
|
|
|
* Wait for at last 400ns for status bit to be valid.
|
|
|
|
*/
|
2003-09-25 23:29:48 +04:00
|
|
|
delay(10); /* 400ns delay */
|
1999-04-02 01:46:28 +04:00
|
|
|
__wdccommand_intr(chp, xfer, 0);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
|
2004-01-02 00:18:28 +03:00
|
|
|
static int
|
2004-08-14 19:08:04 +04:00
|
|
|
__wdccommand_intr(struct ata_channel *chp, struct ata_xfer *xfer, int irq)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
2004-08-12 08:57:19 +04:00
|
|
|
struct ata_command *ata_c = xfer->c_cmd;
|
|
|
|
int bcount = ata_c->bcount;
|
|
|
|
char *data = ata_c->data;
|
2003-10-08 14:58:12 +04:00
|
|
|
int wflags;
|
|
|
|
|
2004-08-12 08:57:19 +04:00
|
|
|
if ((ata_c->flags & (AT_WAIT | AT_POLL)) == (AT_WAIT | AT_POLL)) {
|
2003-10-08 14:58:12 +04:00
|
|
|
/* both wait and poll, we can tsleep here */
|
2003-10-30 00:44:41 +03:00
|
|
|
wflags = AT_WAIT | AT_POLL;
|
2003-10-08 14:58:12 +04:00
|
|
|
} else {
|
|
|
|
wflags = AT_POLL;
|
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
|
2003-12-30 19:40:12 +03:00
|
|
|
again:
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("__wdccommand_intr %s:%d:%d\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive),
|
2004-01-01 20:18:53 +03:00
|
|
|
DEBUG_INTR);
|
2003-10-08 14:58:12 +04:00
|
|
|
/*
|
|
|
|
* after a ATAPI_SOFT_RESET, the device will have released the bus.
|
|
|
|
* Reselect again, it doesn't hurt for others commands, and the time
|
|
|
|
* penalty for the extra regiter write is acceptable,
|
|
|
|
* wdc_exec_command() isn't called often (mosly for autoconfig)
|
|
|
|
*/
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
|
2004-01-01 20:18:53 +03:00
|
|
|
WDSD_IBM | (xfer->c_drive << 4));
|
2004-08-12 08:57:19 +04:00
|
|
|
if ((ata_c->flags & AT_XFDONE) != 0) {
|
2002-04-10 01:17:53 +04:00
|
|
|
/*
|
|
|
|
* We have completed a data xfer. The drive should now be
|
|
|
|
* in its initial state
|
|
|
|
*/
|
2004-08-12 08:57:19 +04:00
|
|
|
if (wdcwait(chp, ata_c->r_st_bmask | WDCS_DRQ,
|
|
|
|
ata_c->r_st_bmask, (irq == 0) ? ata_c->timeout : 0,
|
2003-10-08 14:58:12 +04:00
|
|
|
wflags) == WDCWAIT_TOUT) {
|
2002-04-10 01:17:53 +04:00
|
|
|
if (irq && (xfer->c_flags & C_TIMEOU) == 0)
|
|
|
|
return 0; /* IRQ was not for us */
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_TIMEOU;
|
2002-04-10 01:17:53 +04:00
|
|
|
}
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
goto out;
|
2002-04-10 01:17:53 +04:00
|
|
|
}
|
2004-08-12 08:57:19 +04:00
|
|
|
if (wdcwait(chp, ata_c->r_st_pmask, ata_c->r_st_pmask,
|
|
|
|
(irq == 0) ? ata_c->timeout : 0, wflags) == WDCWAIT_TOUT) {
|
1999-04-02 01:46:28 +04:00
|
|
|
if (irq && (xfer->c_flags & C_TIMEOU) == 0)
|
1999-03-25 19:17:36 +03:00
|
|
|
return 0; /* IRQ was not for us */
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_TIMEOU;
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
goto out;
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
2004-08-13 07:12:59 +04:00
|
|
|
if (wdc->irqack)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->irqack(chp);
|
2004-08-12 08:57:19 +04:00
|
|
|
if (ata_c->flags & AT_READ) {
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
if ((chp->ch_status & WDCS_DRQ) == 0) {
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_TIMEOU;
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
goto out;
|
|
|
|
}
|
2004-01-01 20:18:53 +03:00
|
|
|
if (chp->ch_drive[xfer->c_drive].drive_flags & DRIVE_CAP32) {
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_read_multi_4(wdr->data32iot, wdr->data32ioh,
|
1998-10-12 20:09:10 +04:00
|
|
|
0, (u_int32_t*)data, bcount >> 2);
|
|
|
|
data += bcount & 0xfffffffc;
|
|
|
|
bcount = bcount & 0x03;
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
if (bcount > 0)
|
2004-08-11 22:41:46 +04:00
|
|
|
wdc->datain_pio(chp, DRIVE_NOSTREAM, data, bcount);
|
2002-04-10 01:17:53 +04:00
|
|
|
/* at this point the drive should be in its initial state */
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_XFDONE;
|
2003-10-08 14:58:12 +04:00
|
|
|
/* XXX should read status register here ? */
|
2004-08-12 08:57:19 +04:00
|
|
|
} else if (ata_c->flags & AT_WRITE) {
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
if ((chp->ch_status & WDCS_DRQ) == 0) {
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_TIMEOU;
|
Fix more probe delay and/or failure problems:
1) Don't wait for DRQ on an IDENTIFY command -- if it's not set when we see
BSY clear, abort the command and ignore the drive. (Do this by testing
for DRQ in the read/write cases in __wdccommand_intr().)
2) Don't wait for DRQ to deassert when we finish an IDENTIFY (or any other
non-block command that reads data) -- we don't do this for block I/O, and
empirically it doesn't clear on my CF cards at all, causing a pointless 1s
delay.
3) Add comments to some of the delay()s, and add missing ones in wdcreset()
and the WDCC_RECAL in the so-called "pre-ATA" probe.
4) Slightly simplify the reset sequence -- we were doing an extra I/O.
5) Modify the register writability test to make sure that registers are not
overlapped -- this can happen in some weird cases with a missing device 1.
6) Check the error register value after the reset -- if it's not 01h or 81h,
as appropriate (see ATA spec), punt.
Tested with a number of ATA-only, ATAPI-only, mixed ATA-ATAPI, CF, and IDE
disk configurations.
Also remove the SINGLE_DRIVE nonsense again.
2003-09-23 13:19:22 +04:00
|
|
|
goto out;
|
|
|
|
}
|
2004-01-01 20:18:53 +03:00
|
|
|
if (chp->ch_drive[xfer->c_drive].drive_flags & DRIVE_CAP32) {
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_multi_4(wdr->data32iot, wdr->data32ioh,
|
1998-10-12 20:09:10 +04:00
|
|
|
0, (u_int32_t*)data, bcount >> 2);
|
|
|
|
data += bcount & 0xfffffffc;
|
|
|
|
bcount = bcount & 0x03;
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
1998-10-12 20:09:10 +04:00
|
|
|
if (bcount > 0)
|
2004-08-11 22:41:46 +04:00
|
|
|
wdc->dataout_pio(chp, DRIVE_NOSTREAM, data, bcount);
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_XFDONE;
|
|
|
|
if ((ata_c->flags & AT_POLL) == 0) {
|
2004-08-14 19:08:04 +04:00
|
|
|
chp->ch_flags |= ATACH_IRQ_WAIT; /* wait for interrupt */
|
2002-04-10 01:17:53 +04:00
|
|
|
callout_reset(&chp->ch_callout,
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->timeout / 1000 * hz, wdctimeout, chp);
|
2002-04-10 01:17:53 +04:00
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
goto again;
|
|
|
|
}
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
2003-12-30 19:40:12 +03:00
|
|
|
out:
|
1998-10-12 20:09:10 +04:00
|
|
|
__wdccommand_done(chp, xfer);
|
|
|
|
return 1;
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
|
2004-01-02 00:18:28 +03:00
|
|
|
static void
|
2004-08-14 19:08:04 +04:00
|
|
|
__wdccommand_done(struct ata_channel *chp, struct ata_xfer *xfer)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
2004-08-12 08:57:19 +04:00
|
|
|
struct ata_command *ata_c = xfer->c_cmd;
|
1998-10-12 20:09:10 +04:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("__wdccommand_done %s:%d:%d\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel, xfer->c_drive),
|
2004-01-01 20:18:53 +03:00
|
|
|
DEBUG_FUNCS);
|
1999-08-06 16:00:23 +04:00
|
|
|
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
if (chp->ch_status & WDCS_DWF)
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_DF;
|
1998-10-12 20:09:10 +04:00
|
|
|
if (chp->ch_status & WDCS_ERR) {
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_ERROR;
|
|
|
|
ata_c->r_error = chp->ch_error;
|
1998-10-12 20:09:10 +04:00
|
|
|
}
|
2004-08-12 08:57:19 +04:00
|
|
|
if ((ata_c->flags & AT_READREG) != 0 &&
|
2004-08-20 10:39:37 +04:00
|
|
|
(atac->atac_dev.dv_flags & DVF_ACTIVE) != 0 &&
|
2004-08-12 08:57:19 +04:00
|
|
|
(ata_c->flags & (AT_ERROR | AT_DF)) == 0) {
|
2004-08-14 19:08:04 +04:00
|
|
|
ata_c->r_head = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sdh], 0);
|
|
|
|
ata_c->r_count = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_seccnt], 0);
|
|
|
|
ata_c->r_sector = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_sector], 0);
|
|
|
|
ata_c->r_cyl |= bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_lo], 0);
|
|
|
|
ata_c->r_cyl = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_cyl_hi], 0) << 8;
|
|
|
|
ata_c->r_error = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_error], 0);
|
|
|
|
ata_c->r_features = bus_space_read_1(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_features], 0);
|
1998-11-24 02:02:11 +03:00
|
|
|
}
|
2004-08-04 22:24:10 +04:00
|
|
|
callout_stop(&chp->ch_callout);
|
2004-08-05 02:44:04 +04:00
|
|
|
chp->ch_queue->active_xfer = NULL;
|
2004-08-12 08:57:19 +04:00
|
|
|
if (ata_c->flags & AT_POLL) {
|
2004-08-05 02:44:04 +04:00
|
|
|
/* enable interrupts */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->ctl_iot, wdr->ctl_ioh, wd_aux_ctlr,
|
2004-08-05 02:44:04 +04:00
|
|
|
WDCTL_4BIT);
|
|
|
|
delay(10); /* some drives need a little delay here */
|
|
|
|
}
|
|
|
|
if (chp->ch_drive[xfer->c_drive].drive_flags & DRIVE_WAITDRAIN) {
|
|
|
|
__wdccommand_kill_xfer(chp, xfer, KILL_GONE);
|
|
|
|
chp->ch_drive[xfer->c_drive].drive_flags &= ~DRIVE_WAITDRAIN;
|
|
|
|
wakeup(&chp->ch_queue->active_xfer);
|
|
|
|
} else
|
|
|
|
__wdccommand_done_end(chp, xfer);
|
2004-08-01 01:26:42 +04:00
|
|
|
}
|
2003-10-08 14:58:12 +04:00
|
|
|
|
2004-08-01 01:26:42 +04:00
|
|
|
static void
|
2004-08-14 19:08:04 +04:00
|
|
|
__wdccommand_done_end(struct ata_channel *chp, struct ata_xfer *xfer)
|
2004-08-01 01:26:42 +04:00
|
|
|
{
|
2004-08-12 08:57:19 +04:00
|
|
|
struct ata_command *ata_c = xfer->c_cmd;
|
2004-08-01 01:26:42 +04:00
|
|
|
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_DONE;
|
2004-08-13 01:34:52 +04:00
|
|
|
ata_free_xfer(chp, xfer);
|
2004-08-12 08:57:19 +04:00
|
|
|
if (ata_c->flags & AT_WAIT)
|
|
|
|
wakeup(ata_c);
|
|
|
|
else if (ata_c->callback)
|
|
|
|
ata_c->callback(ata_c->callback_arg);
|
2004-08-13 06:16:40 +04:00
|
|
|
atastart(chp);
|
1998-10-12 20:09:10 +04:00
|
|
|
return;
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
|
2004-08-01 01:26:42 +04:00
|
|
|
static void
|
2004-08-14 19:08:04 +04:00
|
|
|
__wdccommand_kill_xfer(struct ata_channel *chp, struct ata_xfer *xfer,
|
2004-08-01 01:26:42 +04:00
|
|
|
int reason)
|
|
|
|
{
|
2004-08-12 08:57:19 +04:00
|
|
|
struct ata_command *ata_c = xfer->c_cmd;
|
2004-08-01 01:26:42 +04:00
|
|
|
|
|
|
|
switch (reason) {
|
|
|
|
case KILL_GONE:
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_GONE;
|
2004-08-01 01:26:42 +04:00
|
|
|
break;
|
|
|
|
case KILL_RESET:
|
2004-08-12 08:57:19 +04:00
|
|
|
ata_c->flags |= AT_RESET;
|
2004-08-01 01:26:42 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("__wdccommand_kill_xfer: unknown reason %d\n",
|
|
|
|
reason);
|
|
|
|
panic("__wdccommand_kill_xfer");
|
|
|
|
}
|
|
|
|
__wdccommand_done_end(chp, xfer);
|
|
|
|
}
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
/*
|
1998-10-12 20:09:10 +04:00
|
|
|
* Send a command. The drive should be ready.
|
1997-08-27 15:22:52 +04:00
|
|
|
* Assumes interrupts are blocked.
|
|
|
|
*/
|
1998-10-12 20:09:10 +04:00
|
|
|
void
|
2004-08-14 19:08:04 +04:00
|
|
|
wdccommand(struct ata_channel *chp, u_int8_t drive, u_int8_t command,
|
2003-12-30 19:40:12 +03:00
|
|
|
u_int16_t cylin, u_int8_t head, u_int8_t sector, u_int8_t count,
|
2004-05-27 06:23:12 +04:00
|
|
|
u_int8_t features)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
2003-12-30 19:40:12 +03:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("wdccommand %s:%d:%d: command=0x%x cylin=%d head=%d "
|
2004-08-20 10:39:37 +04:00
|
|
|
"sector=%d count=%d features=%d\n", atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, drive, command, cylin, head, sector, count,
|
2004-05-27 06:23:12 +04:00
|
|
|
features), DEBUG_FUNCS);
|
1998-10-12 20:09:10 +04:00
|
|
|
|
2004-08-13 07:12:59 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,drive);
|
2002-01-08 01:11:17 +03:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
/* Select drive, head, and addressing mode. */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
|
1998-10-12 20:09:10 +04:00
|
|
|
WDSD_IBM | (drive << 4) | head);
|
2004-05-27 06:09:26 +04:00
|
|
|
/* Load parameters into the wd_features register. */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_features], 0,
|
2004-05-27 06:23:12 +04:00
|
|
|
features);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_seccnt], 0, count);
|
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sector], 0, sector);
|
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_cyl_lo], 0, cylin);
|
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_cyl_hi],
|
There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.
To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.
bus_space_write_4(tag, handle, offset, value)
becomes
bus_space_write_4(tag, handles[offset], 0, value)
Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
2003-11-28 02:02:40 +03:00
|
|
|
0, cylin >> 8);
|
1998-10-12 20:09:10 +04:00
|
|
|
|
|
|
|
/* Send command. */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_command], 0, command);
|
1998-10-12 20:09:10 +04:00
|
|
|
return;
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
|
2002-01-13 20:24:28 +03:00
|
|
|
/*
|
|
|
|
* Send a 48-bit addressing command. The drive should be ready.
|
|
|
|
* Assumes interrupts are blocked.
|
|
|
|
*/
|
|
|
|
void
|
2004-08-14 19:08:04 +04:00
|
|
|
wdccommandext(struct ata_channel *chp, u_int8_t drive, u_int8_t command,
|
2003-12-30 19:40:12 +03:00
|
|
|
u_int64_t blkno, u_int16_t count)
|
2002-01-13 20:24:28 +03:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
2003-12-30 19:40:12 +03:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("wdccommandext %s:%d:%d: command=0x%x blkno=%d "
|
2004-08-20 10:39:37 +04:00
|
|
|
"count=%d\n", atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, drive, command, (u_int32_t) blkno, count),
|
2002-01-13 20:24:28 +03:00
|
|
|
DEBUG_FUNCS);
|
|
|
|
|
2004-08-13 07:12:59 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,drive);
|
2002-01-13 20:24:28 +03:00
|
|
|
|
|
|
|
/* Select drive, head, and addressing mode. */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
|
2002-01-13 20:24:28 +03:00
|
|
|
(drive << 4) | WDSD_LBA);
|
|
|
|
|
|
|
|
/* previous */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_features], 0, 0);
|
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_seccnt],
|
There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.
To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.
bus_space_write_4(tag, handle, offset, value)
becomes
bus_space_write_4(tag, handles[offset], 0, value)
Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
2003-11-28 02:02:40 +03:00
|
|
|
0, count >> 8);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_lba_lo],
|
There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.
To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.
bus_space_write_4(tag, handle, offset, value)
becomes
bus_space_write_4(tag, handles[offset], 0, value)
Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
2003-11-28 02:02:40 +03:00
|
|
|
0, blkno >> 24);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_lba_mi],
|
2004-05-27 20:47:35 +04:00
|
|
|
0, blkno >> 32);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_lba_hi],
|
2004-05-27 20:47:35 +04:00
|
|
|
0, blkno >> 40);
|
2002-01-13 20:24:28 +03:00
|
|
|
|
|
|
|
/* current */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_features], 0, 0);
|
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_seccnt], 0, count);
|
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_lba_lo], 0, blkno);
|
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_lba_mi],
|
There are some cards that map the ATA control and IDE DMA registers
in a different fashion. Individually, they have the same functionality,
but their layout is different. An example of such a chipset is
the Promise 203xx.
To be able to deal with this, transform the cmd and dma bus_space handles
into an array of handles, each seperately created with bus_space_subregion.
The code generated by using the extra indirection shouldn't change much,
since the extra indirection is negated by having the offset calculation
already done in bus_space_subregion. E.g.
bus_space_write_4(tag, handle, offset, value)
becomes
bus_space_write_4(tag, handles[offset], 0, value)
Reviewed by Manuel Bouyer. Tested on wdc_isa, wdc_pcmcia, viaide, piixide (i386)
and on cmdide (sparc64).
2003-11-28 02:02:40 +03:00
|
|
|
0, blkno >> 8);
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_lba_hi],
|
2004-05-27 20:47:35 +04:00
|
|
|
0, blkno >> 16);
|
2002-01-13 20:24:28 +03:00
|
|
|
|
|
|
|
/* Send command. */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_command], 0, command);
|
2002-01-13 20:24:28 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
/*
|
1998-10-12 20:09:10 +04:00
|
|
|
* Simplified version of wdccommand(). Unbusy/ready/drq must be
|
|
|
|
* tested by the caller.
|
1997-08-27 15:22:52 +04:00
|
|
|
*/
|
1998-10-12 20:09:10 +04:00
|
|
|
void
|
2004-08-14 19:08:04 +04:00
|
|
|
wdccommandshort(struct ata_channel *chp, int drive, int command)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
|
|
|
struct wdc_softc *wdc = CHAN_TO_WDC(chp);
|
2004-08-14 19:08:04 +04:00
|
|
|
struct wdc_regs *wdr = &wdc->regs[chp->ch_channel];
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2004-08-13 08:10:49 +04:00
|
|
|
ATADEBUG_PRINT(("wdccommandshort %s:%d:%d command 0x%x\n",
|
2004-08-20 10:39:37 +04:00
|
|
|
atac->atac_dev.dv_xname, chp->ch_channel, drive, command),
|
1998-10-12 20:09:10 +04:00
|
|
|
DEBUG_FUNCS);
|
2002-01-08 01:11:17 +03:00
|
|
|
|
2004-08-13 07:12:59 +04:00
|
|
|
if (wdc->select)
|
2004-01-04 01:56:52 +03:00
|
|
|
wdc->select(chp,drive);
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
/* Select drive. */
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_sdh], 0,
|
1998-10-12 20:09:10 +04:00
|
|
|
WDSD_IBM | (drive << 4));
|
1997-08-27 15:22:52 +04:00
|
|
|
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_1(wdr->cmd_iot, wdr->cmd_iohs[wd_command], 0, command);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
|
1998-10-12 20:09:10 +04:00
|
|
|
static void
|
2004-08-14 19:08:04 +04:00
|
|
|
__wdcerror(struct ata_channel *chp, char *msg)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct atac_softc *atac = chp->ch_atac;
|
2004-01-01 20:18:53 +03:00
|
|
|
struct ata_xfer *xfer = TAILQ_FIRST(&chp->ch_queue->queue_xfer);
|
2000-04-05 10:27:36 +04:00
|
|
|
|
1997-08-27 15:22:52 +04:00
|
|
|
if (xfer == NULL)
|
2004-08-20 10:39:37 +04:00
|
|
|
printf("%s:%d: %s\n", atac->atac_dev.dv_xname, chp->ch_channel,
|
1998-10-12 20:09:10 +04:00
|
|
|
msg);
|
1997-08-27 15:22:52 +04:00
|
|
|
else
|
2004-08-20 10:39:37 +04:00
|
|
|
printf("%s:%d:%d: %s\n", atac->atac_dev.dv_xname,
|
2004-01-04 01:56:52 +03:00
|
|
|
chp->ch_channel, xfer->c_drive, msg);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* the bit bucket
|
|
|
|
*/
|
|
|
|
void
|
2004-08-14 19:08:04 +04:00
|
|
|
wdcbit_bucket(struct ata_channel *chp, int size)
|
1997-08-27 15:22:52 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
|
1997-08-27 15:22:52 +04:00
|
|
|
|
1998-01-15 02:41:59 +03:00
|
|
|
for (; size >= 2; size -= 2)
|
2004-08-14 19:08:04 +04:00
|
|
|
(void)bus_space_read_2(wdr->cmd_iot, wdr->cmd_iohs[wd_data], 0);
|
1998-01-15 02:41:59 +03:00
|
|
|
if (size)
|
2004-08-14 19:08:04 +04:00
|
|
|
(void)bus_space_read_1(wdr->cmd_iot, wdr->cmd_iohs[wd_data], 0);
|
1997-08-27 15:22:52 +04:00
|
|
|
}
|
1998-11-20 04:22:37 +03:00
|
|
|
|
2004-08-21 05:51:46 +04:00
|
|
|
static void
|
2004-08-14 19:08:04 +04:00
|
|
|
wdc_datain_pio(struct ata_channel *chp, int flags, void *buf, size_t len)
|
2004-08-11 21:49:27 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
|
2004-08-11 21:49:27 +04:00
|
|
|
|
|
|
|
if (flags & DRIVE_NOSTREAM) {
|
|
|
|
if (flags & DRIVE_CAP32) {
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_read_multi_4(wdr->data32iot,
|
|
|
|
wdr->data32ioh, 0, buf, len >> 2);
|
2004-08-11 21:49:27 +04:00
|
|
|
buf = (char *)buf + (len & ~3);
|
|
|
|
len &= 3;
|
|
|
|
}
|
|
|
|
if (len) {
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_read_multi_2(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_data], 0, buf, len >> 1);
|
2004-08-11 21:49:27 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (flags & DRIVE_CAP32) {
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_read_multi_stream_4(wdr->data32iot,
|
|
|
|
wdr->data32ioh, 0, buf, len >> 2);
|
2004-08-11 21:49:27 +04:00
|
|
|
buf = (char *)buf + (len & ~3);
|
|
|
|
len &= 3;
|
|
|
|
}
|
|
|
|
if (len) {
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_read_multi_stream_2(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_data], 0, buf, len >> 1);
|
2004-08-11 21:49:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-21 05:51:46 +04:00
|
|
|
static void
|
2004-08-14 19:08:04 +04:00
|
|
|
wdc_dataout_pio(struct ata_channel *chp, int flags, void *buf, size_t len)
|
2004-08-11 21:49:27 +04:00
|
|
|
{
|
2004-08-20 10:39:37 +04:00
|
|
|
struct wdc_regs *wdr = CHAN_TO_WDC_REGS(chp);
|
2004-08-11 21:49:27 +04:00
|
|
|
|
|
|
|
if (flags & DRIVE_NOSTREAM) {
|
|
|
|
if (flags & DRIVE_CAP32) {
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_multi_4(wdr->data32iot,
|
|
|
|
wdr->data32ioh, 0, buf, len >> 2);
|
2004-08-11 21:49:27 +04:00
|
|
|
buf = (char *)buf + (len & ~3);
|
|
|
|
len &= 3;
|
|
|
|
}
|
|
|
|
if (len) {
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_multi_2(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_data], 0, buf, len >> 1);
|
2004-08-11 21:49:27 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (flags & DRIVE_CAP32) {
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_multi_stream_4(wdr->data32iot,
|
|
|
|
wdr->data32ioh, 0, buf, len >> 2);
|
2004-08-11 21:49:27 +04:00
|
|
|
buf = (char *)buf + (len & ~3);
|
|
|
|
len &= 3;
|
|
|
|
}
|
|
|
|
if (len) {
|
2004-08-14 19:08:04 +04:00
|
|
|
bus_space_write_multi_stream_2(wdr->cmd_iot,
|
|
|
|
wdr->cmd_iohs[wd_data], 0, buf, len >> 1);
|
2004-08-11 21:49:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|