Use ATA timing, instead of busmaster wait, for adding waits.

Use default wait value 0x01.
This commit is contained in:
itohy 2006-10-01 09:53:08 +00:00
parent 69522b1b54
commit b2d7fb48f1
9 changed files with 50 additions and 42 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: njata.4,v 1.2 2006/09/10 21:53:36 wiz Exp $
.\" $NetBSD: njata.4,v 1.3 2006/10/01 09:53:09 itohy Exp $
.\"
.\" Copyright (c) 2006 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -42,7 +42,7 @@
.Nd Workbit NinjaATA-32 CardBus IDE controller driver
.Sh SYNOPSIS
.Cd "njata* at cardbus? function ?"
.Cd "njata* at cardbus? function ? flags 1 # with wait 1"
.Cd "njata* at cardbus? function ? flags 0x01 # with wait 0x01"
.Sh DESCRIPTION
The
.Nm
@ -73,13 +73,14 @@ The optional flags parameter is the
.Dq wait
value for ATA transfers.
Some combinations of host and device may fail without flags parameter or
.Tn flags 0 .
In this case try wait values between
.Tn flags 1
and
.Tn flags 3 .
.Tn flags 0x00 .
In this case try adding wait values like
.Tn flags 0x01
or
.Tn flags 0x11
(wait parameter is composed of two 4bit values).
Smaller wait values should be faster.
Too long waits may cause DMA error.
Too long waits may cause transfer error.
.Sh SEE ALSO
.Xr ata 4 ,
.Xr atapi 4 ,

View File

@ -1,4 +1,4 @@
# $NetBSD: OPENBLOCKS266_OPT,v 1.4 2006/09/07 14:23:44 itohy Exp $
# $NetBSD: OPENBLOCKS266_OPT,v 1.5 2006/10/01 09:53:08 itohy Exp $
#
include "arch/evbppc/conf/OPENBLOCKS266"
@ -45,7 +45,7 @@ uk* at scsibus? target ? lun ? # SCSI unknown
wdc* at pcmcia? function ?
# CardBus IDE controllers
#njata* at cardbus? function ? flags 0 # Workbit NinjaATA-32
#njata* at cardbus? function ? flags 0x01 # Workbit NinjaATA-32
# ATA (IDE) bus support
atabus* at ata?

View File

@ -1,4 +1,4 @@
# $NetBSD: ALL,v 1.63 2006/09/19 13:58:55 jmmv Exp $
# $NetBSD: ALL,v 1.64 2006/10/01 09:53:08 itohy Exp $
# From: NetBSD: GENERIC,v 1.776 2006/08/14 09:34:43 itohy Exp
#
# ALL machine description file
@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "ALL-$Revision: 1.63 $"
#ident "ALL-$Revision: 1.64 $"
maxusers 32 # estimated number of users
@ -737,7 +737,7 @@ wdc* at isapnp?
wdc* at pcmcia? function ?
# CardBus IDE controllers
njata* at cardbus? function ? flags 0 # Workbit NinjaATA-32
njata* at cardbus? function ? flags 0x01 # Workbit NinjaATA-32
# ISA ST506, ESDI, and IDE controllers
# Use flags 0x01 if you want to try to use 32bits data I/O (the driver will

View File

@ -1,4 +1,4 @@
# $NetBSD: CARDBUS,v 1.77 2006/09/07 14:23:44 itohy Exp $
# $NetBSD: CARDBUS,v 1.78 2006/10/01 09:53:08 itohy Exp $
#
# CARDBUS: GENERIC + CardBus support
@ -41,7 +41,7 @@ ahc* at cardbus? function ? # Adaptec ADP-1480
njs* at cardbus? function ? # Workbit NinjaSCSI-32
# CardBus IDE controllers
njata* at cardbus? function ? flags 0 # Workbit NinjaATA-32
njata* at cardbus? function ? flags 0x01 # Workbit NinjaATA-32
# CardBus network cards
ath* at cardbus? function ? # Atheros 5210/5211/5212 802.11

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.785 2006/09/27 23:58:50 hubertf Exp $
# $NetBSD: GENERIC,v 1.786 2006/10/01 09:53:08 itohy Exp $
#
# GENERIC machine description file
#
@ -22,7 +22,7 @@ include "arch/i386/conf/std.i386"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.785 $"
#ident "GENERIC-$Revision: 1.786 $"
maxusers 32 # estimated number of users
@ -756,7 +756,7 @@ wdc* at isapnp?
wdc* at pcmcia? function ?
# CardBus IDE controllers
#njata* at cardbus? function ? flags 0 # Workbit NinjaATA-32
#njata* at cardbus? function ? flags 0x01 # Workbit NinjaATA-32
# ISA ST506, ESDI, and IDE controllers
# Use flags 0x01 if you want to try to use 32bits data I/O (the driver will

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC_LAPTOP,v 1.207 2006/09/19 13:58:56 jmmv Exp $
# $NetBSD: GENERIC_LAPTOP,v 1.208 2006/10/01 09:53:08 itohy Exp $
# From: NetBSD: GENERIC,v 1.414 2001/07/30 19:59:05 ad Exp
#
# GENERIC_LAPTOP -- GENERIC with cardbus and some USB devices enabled
@ -8,7 +8,7 @@ include "arch/i386/conf/std.i386"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.207 $"
#ident "GENERIC-$Revision: 1.208 $"
maxusers 32 # estimated number of users
@ -547,7 +547,7 @@ wdc* at isapnp?
wdc* at pcmcia? function ?
# CardBus IDE controllers
njata* at cardbus? function ? flags 0 # Workbit NinjaATA-32
njata* at cardbus? function ? flags 0x01 # Workbit NinjaATA-32
# ISA ST506, ESDI, and IDE controllers
# Use flags 0x01 if you want to try to use 32bits data I/O (the driver will

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.68 2006/09/26 14:30:27 elad Exp $
# $NetBSD: GENERIC,v 1.69 2006/10/01 09:53:09 itohy Exp $
#
# GENERIC machine description file
#
@ -22,7 +22,7 @@ include "arch/sparc64/conf/std.sparc64"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.68 $"
#ident "GENERIC-$Revision: 1.69 $"
maxusers 64
@ -721,7 +721,7 @@ pseudo-device stf # 6to4 IPv6 over IPv4 encapsulation
#njs* at cardbus? function ? # Workbit NinjaSCSI-32
# CardBus IDE controllers
#njata* at cardbus? function ? flags 0 # Workbit NinjaATA-32
#njata* at cardbus? function ? flags 0x01 # Workbit NinjaATA-32
# CardBus network interfaces
#ath* at cardbus? function ? # Atheros 5210/5211/5212 802.11

View File

@ -1,4 +1,4 @@
/* $Id: ninjaata32.c,v 1.1 2006/09/07 14:22:07 itohy Exp $ */
/* $Id: ninjaata32.c,v 1.2 2006/10/01 09:53:09 itohy Exp $ */
/*
* Copyright (c) 2006 ITOH Yasufumi <itohy@NetBSD.org>.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ninjaata32.c,v 1.1 2006/09/07 14:22:07 itohy Exp $");
__KERNEL_RCSID(0, "$NetBSD: ninjaata32.c,v 1.2 2006/10/01 09:53:09 itohy Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -94,7 +94,7 @@ njata32_init(sc, nosleep)
/* initial transfer speed */
bus_space_write_1(NJATA32_REGT(sc), NJATA32_REGH(sc),
NJATA32_REG_TIMING, NJATA32_TIMING_PIO0);
NJATA32_REG_TIMING, NJATA32_TIMING_PIO0 + sc->sc_atawait);
/* setup busmaster mode */
bus_space_write_1(NJATA32_REGT(sc), NJATA32_REGH(sc), NJATA32_REG_IOBM,
@ -224,11 +224,10 @@ njata32_attach(sc)
sc->sc_flags |= NJATA32_CMDPG_MAPPED;
/* use flags value as busmaster wait */
if ((sc->sc_bmwait =
device_cfdata(&sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags &
(NJATA32_BM_WAIT_MASK >> NJATA32_BM_WAIT_SHIFT)) > 0)
aprint_normal("%s: busmaster wait = %d\n",
NJATA32NAME(sc), sc->sc_bmwait);
if ((sc->sc_atawait =
(uint8_t)device_cfdata(&sc->sc_wdcdev.sc_atac.atac_dev)->cf_flags))
aprint_normal("%s: ATA wait = %#x\n",
NJATA32NAME(sc), sc->sc_atawait);
njata32_init(sc, cold);
@ -284,7 +283,7 @@ njata32_irqack(chp)
/* disable busmaster */
bus_space_write_1(NJATA32_REGT(sc), NJATA32_REGH(sc),
NJATA32_REG_BM, (sc->sc_bmwait << NJATA32_BM_WAIT_SHIFT));
NJATA32_REG_BM, NJATA32_BM_WAIT0);
}
static void
@ -360,6 +359,8 @@ njata32_setup_channel(chp)
sc->sc_timing_pio = njata32_timing_pio[mode];
}
sc->sc_timing_pio += sc->sc_atawait;
/* set timing for PIO */
bus_space_write_1(NJATA32_REGT(sc), NJATA32_REGH(sc),
NJATA32_REG_TIMING, sc->sc_timing_pio);
@ -514,8 +515,7 @@ njata32_piobm_start(v, channel, drive, skip, xferlen, flags)
}
/* enable scatter/gather busmaster transfer */
bmreg = NJATA32_BM_EN | NJATA32_BM_SG |
(sc->sc_bmwait << NJATA32_BM_WAIT_SHIFT) |
bmreg = NJATA32_BM_EN | NJATA32_BM_SG | NJATA32_BM_WAIT0 |
((dev->d_flags & NJATA32_DEV_DMA_READ) ? NJATA32_BM_RD : 0);
bus_space_write_1(NJATA32_REGT(sc), NJATA32_REGH(sc), NJATA32_REG_BM,
bmreg);
@ -593,13 +593,20 @@ njata32_dma_finish(v, channel, drive, force)
* For unknown reason, PIOBM transfer sometimes fails in the middle,
* in which case the bit #7 of BM register becomes 0.
* Increasing the wait value seems to improve the situation.
*
* XXX
* PIO transfer may also fail, but it seems it can't be detected.
*/
if ((bm & NJATA32_BM_DONE) == 0) {
error |= WDC_DMAST_ERR;
printf("%s: busmaster error", NJATA32NAME(sc));
if (sc->sc_bmwait < 1 /* XXX */) {
sc->sc_bmwait++;
printf(", new busmaster wait = %d", sc->sc_bmwait);
if (sc->sc_atawait < 0x11) {
if ((sc->sc_atawait & 0xf) == 0)
sc->sc_atawait++;
else
sc->sc_atawait += 0x10;
printf(", new ATA wait = %#x", sc->sc_atawait);
njata32_setup_channel(&sc->sc_ch[0].ch_ata_channel);
}
printf("\n");
}
@ -608,7 +615,7 @@ njata32_dma_finish(v, channel, drive, force)
bus_space_write_1(NJATA32_REGT(sc), NJATA32_REGH(sc), NJATA32_REG_AS,
NJATA32_AS_WAIT0);
bus_space_write_1(NJATA32_REGT(sc), NJATA32_REGH(sc), NJATA32_REG_BM,
(sc->sc_bmwait << NJATA32_BM_WAIT_SHIFT));
NJATA32_BM_WAIT0);
/* set timing for PIO */
bus_space_write_1(NJATA32_REGT(sc), NJATA32_REGH(sc),
@ -701,7 +708,7 @@ njata32_intr(arg)
* transfer done, wait for device interrupt
*/
bus_space_write_1(NJATA32_REGT(sc), NJATA32_REGH(sc),
NJATA32_REG_BM, (sc->sc_bmwait << NJATA32_BM_WAIT_SHIFT));
NJATA32_REG_BM, NJATA32_BM_WAIT0);
return 1;
}

View File

@ -1,4 +1,4 @@
/* $Id: ninjaata32var.h,v 1.1 2006/09/07 14:22:08 itohy Exp $ */
/* $Id: ninjaata32var.h,v 1.2 2006/10/01 09:53:09 itohy Exp $ */
/*
* Copyright (c) 2006 ITOH Yasufumi <itohy@NetBSD.org>.
@ -91,7 +91,7 @@ struct njata32_softc {
uint8_t sc_timing_dma;
#endif
uint8_t sc_bmwait;
uint8_t sc_atawait;
/* per-device structure */
struct njata32_device {