-/* $OpenBSD: pciide.c,v 1.308 2010/04/20 06:59:47 jsg Exp $ */
+/* $OpenBSD: pciide.c,v 1.309 2010/07/22 18:11:16 deraadt Exp $ */
/* $NetBSD: pciide.c,v 1.127 2001/08/03 01:31:08 tsutsui Exp $ */
/*
pciide_activate(struct device *self, int act)
{
int rv = 0;
+ struct pciide_softc *sc = (struct pciide_softc *)self;
+ int i;
switch (act) {
case DVACT_SUSPEND:
+ rv = config_activate_children(self, act);
+
+ for (i = 0; i < nitems(sc->sc_save); i++)
+ sc->sc_save[i] = pci_conf_read(sc->sc_pc,
+ sc->sc_tag, PCI_MAPREG_END + 0x18 + (i * 4));
+
+ if (sc->sc_pp->chip_map == sch_chip_map) {
+ sc->sc_save2[0] = pci_conf_read(sc->sc_pc,
+ sc->sc_tag, SCH_D0TIM);
+ sc->sc_save2[1] = pci_conf_read(sc->sc_pc,
+ sc->sc_tag, SCH_D1TIM);
+ } else if (sc->sc_pp->chip_map == piixsata_chip_map) {
+ sc->sc_save2[0] = pciide_pci_read(sc->sc_pc,
+ sc->sc_tag, ICH5_SATA_MAP);
+ sc->sc_save2[1] = pciide_pci_read(sc->sc_pc,
+ sc->sc_tag, ICH5_SATA_PI);
+ sc->sc_save2[2] = pciide_pci_read(sc->sc_pc,
+ sc->sc_tag, ICH_SATA_PCS);
+ } else if (sc->sc_pp->chip_map == piix_chip_map) {
+ /* nothing to save */
+ } else if (sc->sc_pp->chip_map == phison_chip_map) {
+ /* nothing to save */
+ }
+ break;
case DVACT_RESUME:
+ for (i = 0; i < nitems(sc->sc_save); i++)
+ pci_conf_write(sc->sc_pc, sc->sc_tag,
+ PCI_MAPREG_END + 0x18 + (i * 4),
+ sc->sc_save[i]);
+
+ if (sc->sc_pp->chip_map == sch_chip_map) {
+ pci_conf_write(sc->sc_pc, sc->sc_tag,
+ SCH_D0TIM, sc->sc_save2[0]);
+ pci_conf_write(sc->sc_pc, sc->sc_tag,
+ SCH_D1TIM, sc->sc_save2[1]);
+ } else if (sc->sc_pp->chip_map == piixsata_chip_map) {
+ pciide_pci_write(sc->sc_pc, sc->sc_tag,
+ ICH5_SATA_MAP, sc->sc_save2[0]);
+ pciide_pci_write(sc->sc_pc, sc->sc_tag,
+ ICH5_SATA_PI, sc->sc_save2[1]);
+ pciide_pci_write(sc->sc_pc, sc->sc_tag,
+ ICH_SATA_PCS, sc->sc_save2[2]);
+ } else if (sc->sc_pp->chip_map == piix_chip_map) {
+ /* nothing more to restore */
+ } else if (sc->sc_pp->chip_map == phison_chip_map) {
+ /* nothing more to restore */
+ } else {
+ printf("%s: restore for unknown chip map %x\n",
+ sc->sc_wdcdev.sc_dev.dv_xname,
+ sc->sc_pp->ide_product);
+ }
+
rv = config_activate_children(self, act);
break;
}
-
return (rv);
}
-/* $OpenBSD: pciidevar.h,v 1.19 2009/10/05 20:01:40 jsg Exp $ */
+/* $OpenBSD: pciidevar.h,v 1.20 2010/07/22 18:11:16 deraadt Exp $ */
/* $NetBSD: pciidevar.h,v 1.6 2001/01/12 16:04:00 bouyer Exp $ */
/*
bus_size_t sc_dma_maxsegsz;
bus_size_t sc_dma_boundary;
+ /*
+ * Used as a register save space by pciide_activate()
+ *
+ * sc_save[] is for the 6 pci regs starting at PCI_MAPREG_END + 0x18 --
+ * most IDE chipsets need a subset of those saved. sc_save2 is for
+ * up to 6 other registers, which specific chips might need saved.
+ */
+ pcireg_t sc_save[6];
+ pcireg_t sc_save2[6];
+
/* Chip description */
const struct pciide_product_desc *sc_pp;
/* unmap/detach */