Add powerhooks for PIIX IDE driver.

This commit is contained in:
jmcneill 2005-01-26 21:50:31 +00:00
parent 5283ca74ad
commit 5a6c12cd3b
2 changed files with 34 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: pciidevar.h,v 1.26 2004/11/24 19:52:50 bouyer Exp $ */
/* $NetBSD: pciidevar.h,v 1.27 2005/01/26 21:50:31 jmcneill Exp $ */
/*
* Copyright (c) 1998 Christopher G. Demetriou. All rights reserved.
@ -142,6 +142,10 @@ struct pciide_softc {
*/
uint8_t idedma_cmd;
} pciide_channels[PCIIDE_MAX_CHANNELS];
/* Power management */
void *sc_powerhook;
struct pci_conf_state sc_pciconf; /* Restore buffer */
};
/* Given an ata_channel, get the pciide_softc. */

View File

@ -1,4 +1,4 @@
/* $NetBSD: piixide.c,v 1.17 2004/11/10 17:19:05 cube Exp $ */
/* $NetBSD: piixide.c,v 1.18 2005/01/26 21:50:31 jmcneill Exp $ */
/*
* Copyright (c) 1999, 2000, 2001 Manuel Bouyer.
@ -46,6 +46,7 @@ static u_int32_t piix_setup_idetim_drvs(struct ata_drive_datas *);
static u_int32_t piix_setup_sidetim_timings(u_int8_t, u_int8_t, u_int8_t);
static void piixsata_chip_map(struct pciide_softc*, struct pci_attach_args *);
static void piixide_powerhook(int, void *);
static int piixide_match(struct device *, struct cfdata *, void *);
static void piixide_attach(struct device *, struct device *, void *);
@ -186,6 +187,33 @@ piixide_attach(struct device *parent, struct device *self, void *aux)
pciide_common_attach(sc, pa,
pciide_lookup_product(pa->pa_id, pciide_intel_products));
/* Setup our powerhook */
sc->sc_powerhook = powerhook_establish(piixide_powerhook, sc);
if (sc->sc_powerhook == NULL)
printf("%s: WARNING: unable to establish PCI power hook\n",
sc->sc_wdcdev.sc_atac.atac_dev.dv_xname);
}
static void
piixide_powerhook(int why, void *hdl)
{
struct pciide_softc *sc = (struct pciide_softc *)hdl;
switch (why) {
case PWR_SUSPEND:
case PWR_STANDBY:
pci_conf_capture(sc->sc_pc, sc->sc_tag, &sc->sc_pciconf);
break;
case PWR_RESUME:
pci_conf_restore(sc->sc_pc, sc->sc_tag, &sc->sc_pciconf);
break;
case PWR_SOFTSUSPEND:
case PWR_SOFTSTANDBY:
case PWR_SOFTRESUME:
break;
}
return;
}
static void