summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Yurchenko <grange@cvs.openbsd.org>2003-06-07 19:49:51 +0000
committerAlexander Yurchenko <grange@cvs.openbsd.org>2003-06-07 19:49:51 +0000
commit4b3f7222020d342fc7467c63691c8920a9ebd84a (patch)
treed6c5811cd7a4b3bed113ec584078823b4767d545
parentd4698cdbb1255a7f35fefaaa2138566fcfa32e04 (diff)
Add a generic channel setup routine for SATA devices; from NetBSD
-rw-r--r--sys/dev/pci/pciide.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/sys/dev/pci/pciide.c b/sys/dev/pci/pciide.c
index 4857ac3297b..82f4d24c937 100644
--- a/sys/dev/pci/pciide.c
+++ b/sys/dev/pci/pciide.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pciide.c,v 1.129 2003/06/06 11:28:41 grange Exp $ */
+/* $OpenBSD: pciide.c,v 1.130 2003/06/07 19:49:50 grange Exp $ */
/* $NetBSD: pciide.c,v 1.127 2001/08/03 01:31:08 tsutsui Exp $ */
/*
@@ -203,6 +203,8 @@ struct pciide_softc {
void default_chip_map(struct pciide_softc*, struct pci_attach_args*);
+void sata_setup_channel(struct channel_softc *);
+
void piix_chip_map(struct pciide_softc*, struct pci_attach_args*);
void piix_setup_channel(struct channel_softc*);
void piix3_4_setup_channel(struct channel_softc*);
@@ -1613,6 +1615,47 @@ next:
}
void
+sata_setup_channel(struct channel_softc *chp)
+{
+ struct ata_drive_datas *drvp;
+ int drive;
+ u_int32_t idedma_ctl;
+ struct pciide_channel *cp = (struct pciide_channel*)chp;
+ struct pciide_softc *sc = (struct pciide_softc*)cp->wdc_channel.wdc;
+
+ /* setup DMA if needed */
+ pciide_channel_dma_setup(cp);
+
+ idedma_ctl = 0;
+
+ for (drive = 0; drive < 2; drive++) {
+ drvp = &chp->ch_drive[drive];
+ /* If no drive, skip */
+ if ((drvp->drive_flags & DRIVE) == 0)
+ continue;
+ if (drvp->drive_flags & DRIVE_UDMA) {
+ /* use Ultra/DMA */
+ drvp->drive_flags &= ~DRIVE_DMA;
+ idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
+ } else if (drvp->drive_flags & DRIVE_DMA) {
+ idedma_ctl |= IDEDMA_CTL_DRV_DMA(drive);
+ }
+ }
+
+ /*
+ * Nothing to do to setup modes; it is meaningless in S-ATA
+ * (but many S-ATA drives still want to get the SET_FEATURE
+ * command).
+ */
+ if (idedma_ctl != 0) {
+ /* Add software bits in status register */
+ bus_space_write_1(sc->sc_dma_iot, sc->sc_dma_ioh,
+ IDEDMA_CTL(chp->channel), idedma_ctl);
+ }
+ pciide_print_modes(cp);
+}
+
+void
piix_chip_map(sc, pa)
struct pciide_softc *sc;
struct pci_attach_args *pa;