- change drive_flags from u_int8_t to u_int16_t

- keep the modes supported by the drive in struct ata_drive_datas (will be
  later used for downgrading the DMA/PIO mode on error)
- use config flags to force/disable PIO/DMA/UDMA modes
- For the CMD PCI0643/6 setup DMA mode to DMA Read multiple.
This commit is contained in:
bouyer 1998-12-02 10:52:24 +00:00
parent 4787b2ea75
commit 45675ab14b
4 changed files with 68 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: atavar.h,v 1.6 1998/11/23 23:00:26 kenh Exp $ */
/* $NetBSD: atavar.h,v 1.7 1998/12/02 10:52:24 bouyer Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer.
@ -38,12 +38,12 @@
/* Datas common to drives and controller drivers */
struct ata_drive_datas {
u_int8_t drive; /* drive number */
u_int8_t drive_flags; /* bitmask for drives present/absent and cap */
u_int16_t drive_flags; /* bitmask for drives present/absent and cap */
#define DRIVE_ATA 0x01
#define DRIVE_ATAPI 0x02
#define DRIVE (DRIVE_ATA|DRIVE_ATAPI)
#define DRIVE_CAP32 0x04
#define DRIVE_DMA 0x08
#define DRIVE_DMA 0x08
#define DRIVE_UDMA 0x10
#define DRIVE_MODE 0x20 /* the drive reported its mode */
#define DRIVE_RESET 0x40 /* reset the drive state at next xfer */
@ -55,6 +55,10 @@ struct ata_drive_datas {
u_int8_t PIO_mode; /* Current setting of drive's PIO mode */
u_int8_t DMA_mode; /* Current setting of drive's DMA mode */
u_int8_t UDMA_mode; /* Current setting of drive's UDMA mode */
/* Supported modes for this drive */
u_int8_t PIO_cap; /* supported drive's PIO mode */
u_int8_t DMA_cap; /* supported drive's DMA mode */
u_int8_t UDMA_cap; /* supported drive's UDMA mode */
/*
* Drive state. This is drive-type (ATA or ATAPI) dependant
* This is reset to 0 after a channel reset.
@ -76,8 +80,18 @@ struct ata_atapi_attach {
void *aa_bus_private; /* infos specifics to this bus */
};
/* User config flags that force (or disable) the use of a mode */
#define ATA_CONFIG_PIO_MODES 0x0007
#define ATA_CONFIG_PIO_SET 0x0008
#define ATA_CONFIG_PIO_OFF 0
#define ATA_CONFIG_DMA_MODES 0x0070
#define ATA_CONFIG_DMA_SET 0x0080
#define ATA_CONFIG_DMA_DISABLE 0x0070
#define ATA_CONFIG_DMA_OFF 4
#define ATA_CONFIG_UDMA_MODES 0x0700
#define ATA_CONFIG_UDMA_SET 0x0800
#define ATA_CONFIG_UDMA_DISABLE 0x0700
#define ATA_CONFIG_UDMA_OFF 8
/*
* ATA/ATAPI commands description

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc.c,v 1.47 1998/11/29 17:34:49 bouyer Exp $ */
/* $NetBSD: wdc.c,v 1.48 1998/12/02 10:52:25 bouyer Exp $ */
/*
@ -726,6 +726,7 @@ wdc_probe_caps(drvp)
struct wdc_softc *wdc = chp->wdc;
int i, printed;
char *sep = "";
int cf_flags;
if (ata_get_params(drvp, AT_POLL, &params) != CMD_OK) {
/* IDENTIFY failed. Can't tell more about the device */
@ -793,6 +794,7 @@ wdc_probe_caps(drvp)
if ((wdc->cap & WDC_CAPABILITY_MODE) == 0 ||
wdc->pio_mode >= i + 3) {
drvp->PIO_mode = i + 3;
drvp->PIO_cap = i + 3;
break;
}
}
@ -823,6 +825,7 @@ wdc_probe_caps(drvp)
wdc->dma_mode < i)
continue;
drvp->DMA_mode = i;
drvp->DMA_cap = i;
drvp->drive_flags |= DRIVE_DMA;
}
break;
@ -846,6 +849,7 @@ wdc_probe_caps(drvp)
*/
if (wdc->cap & WDC_CAPABILITY_UDMA) {
drvp->UDMA_mode = i;
drvp->UDMA_cap = i;
drvp->drive_flags |= DRIVE_UDMA;
}
break;
@ -853,6 +857,36 @@ wdc_probe_caps(drvp)
}
printf("\n");
}
cf_flags = drv_dev->dv_cfdata->cf_flags;
if (cf_flags & ATA_CONFIG_PIO_SET) {
drvp->PIO_mode =
(cf_flags & ATA_CONFIG_PIO_MODES) >> ATA_CONFIG_PIO_OFF;
drvp->drive_flags |= DRIVE_MODE;
}
if ((wdc->cap & WDC_CAPABILITY_DMA) == 0) {
/* don't care about DMA modes */
return;
}
if (cf_flags & ATA_CONFIG_DMA_SET) {
if ((cf_flags & ATA_CONFIG_DMA_MODES) ==
ATA_CONFIG_DMA_DISABLE) {
drvp->drive_flags &= ~DRIVE_DMA;
} else {
drvp->DMA_mode = (cf_flags & ATA_CONFIG_DMA_MODES) >>
ATA_CONFIG_DMA_OFF;
drvp->drive_flags |= DRIVE_DMA | DRIVE_MODE;
}
}
if (cf_flags & ATA_CONFIG_UDMA_SET) {
if ((cf_flags & ATA_CONFIG_UDMA_MODES) ==
ATA_CONFIG_UDMA_DISABLE) {
drvp->drive_flags &= ~DRIVE_UDMA;
} else {
drvp->UDMA_mode = (cf_flags & ATA_CONFIG_UDMA_MODES) >>
ATA_CONFIG_UDMA_OFF;
drvp->drive_flags |= DRIVE_UDMA | DRIVE_MODE;
}
}
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: pciide.c,v 1.19 1998/11/24 19:54:20 drochner Exp $ */
/* $NetBSD: pciide.c,v 1.20 1998/12/02 10:52:25 bouyer Exp $ */
/*
* Copyright (c) 1996, 1998 Christopher G. Demetriou. All rights reserved.
@ -1762,13 +1762,6 @@ cmd0643_6_setup_chip(sc, pc, tag)
end: pciide_pci_write(pc, tag,
CMD_DATA_TIM(channel, drive), tim);
printf("%s(%s:%d:%d): using PIO mode %d",
drvp->drv_softc->dv_xname,
sc->sc_wdcdev.sc_dev.dv_xname,
channel, drive, drvp->PIO_mode);
if (drvp->drive_flags & DRIVE_DMA)
printf(", DMA mode %d", drvp->DMA_mode);
printf("\n");
}
if (idedma_ctl != 0) {
/* Add software bits in status register */
@ -1777,9 +1770,13 @@ end: pciide_pci_write(pc, tag,
idedma_ctl);
}
}
/* print modes */
pciide_print_modes(sc);
/* configure for DMA read multiple */
pciide_pci_write(pc, tag, CMD_DMA_MODE, CMD_DMA_MULTIPLE);
WDCDEBUG_PRINT(("cmd0643_6_setup_chip: timings reg now 0x%x 0x%x\n",
pci_conf_read(pc, tag, 0x54), pci_conf_read(pc, tag, 0x58)),
DEBUG_PROBE);
pci_conf_read(pc, tag, 0x54), pci_conf_read(pc, tag, 0x58)),
DEBUG_PROBE);
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: pciide_cmd_reg.h,v 1.3 1998/11/09 09:21:10 bouyer Exp $ */
/* $NetBSD: pciide_cmd_reg.h,v 1.4 1998/12/02 10:52:25 bouyer Exp $ */
/*
* Copyright (c) 1998 Manuel Bouyer.
@ -67,6 +67,12 @@
((drive) == 0) ? 0x54: 0x56 \
: \
((drive) == 0) ? 0x58 : 0x5b)
/* DMA master read mode select */
#define CMD_DMA_MODE 0x71
#define CMD_DMA 0x00
#define CMD_DMA_MULTIPLE 0x01
#define CMD_DMA_LINE 0x10
/*