Use standard PCI power management definitions from pcireg.h instead

of homegrown ones.

suggested by Soren
This commit is contained in:
pooka 2002-01-14 19:24:39 +00:00
parent 70e85fb54b
commit 09dfdacac8
4 changed files with 27 additions and 39 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: esa.c,v 1.6 2002/01/13 15:07:28 jmcneill Exp $ */
/* $NetBSD: esa.c,v 1.7 2002/01/14 19:24:39 pooka Exp $ */
/*
* Copyright (c) 2001, 2002 Jared D. McNeill <jmcneill@invisible.yi.org>
@ -56,7 +56,6 @@
#include <dev/ic/ac97var.h>
#include <dev/ic/ac97reg.h>
#include <dev/pci/esareg.h>
#include <dev/pci/esadsp.h>
#include <dev/pci/esavar.h>
@ -952,7 +951,7 @@ esa_attach(struct device *parent, struct device *self, void *aux)
printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
/* Power up chip */
esa_power(sc, ESA_PPMI_D0);
esa_power(sc, PCI_PMCSR_STATE_D0);
/* Init chip */
if (esa_init(sc) == -1) {
@ -1402,12 +1401,15 @@ esa_power(struct esa_softc *sc, int state)
{
pcitag_t tag = sc->sc_tag;
pci_chipset_tag_t pc = sc->sc_pct;
u_int32_t data;
pcireg_t data;
int pmcapreg;
data = pci_conf_read(pc, tag, ESA_CONF_PM_PTR);
if (pci_conf_read(pc, tag, data) == 1)
pci_conf_write(pc, tag, data + 4, state);
if (pci_get_capability(pc, tag, PCI_CAP_PWRMGMT, &pmcapreg, 0)) {
data = pci_conf_read(pc, tag, pmcapreg + 4);
if ((data && PCI_PMCSR_STATE_MASK) != state)
pci_conf_write(pc, tag, pmcapreg + 4, state);
}
return (0);
}
@ -1457,7 +1459,7 @@ esa_suspend(struct esa_softc *sc)
sc->savemem[index++] = esa_read_assp(sc,
ESA_MEMTYPE_INTERNAL_DATA, i);
esa_power(sc, ESA_PPMI_D3);
esa_power(sc, PCI_PMCSR_STATE_D3);
return (0);
}
@ -1471,7 +1473,7 @@ esa_resume(struct esa_softc *sc) {
index = 0;
esa_power(sc, ESA_PPMI_D0);
esa_power(sc, PCI_PMCSR_STATE_D0);
delay(10000);
esa_config(sc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: esareg.h,v 1.5 2002/01/13 14:48:01 jmcneill Exp $ */
/* $NetBSD: esareg.h,v 1.6 2002/01/14 19:24:39 pooka Exp $ */
/*
* Copyright (c) 2002 Lennart Augustsson
@ -38,13 +38,6 @@
#define PCI_LEGACY_AUDIO_CTRL 0x40
#define DISABLE_LEGACY 0x00008000
/* Power management */
#define ESA_CONF_PM_PTR 0x34
#define ESA_PPMI_D0 0
#define ESA_PPMI_D1 1
#define ESA_PPMI_D2 2
#define ESA_PPMI_D3 3
#define ESA_PCI_ALLEGRO_CONFIG 0x50
#define ESA_SB_ADDR_240 0x00000004
#define ESA_MPU_ADDR_MASK 0x00000018

View File

@ -1,4 +1,4 @@
/* $NetBSD: esm.c,v 1.12 2001/11/13 07:48:42 lukem Exp $ */
/* $NetBSD: esm.c,v 1.13 2002/01/14 19:24:39 pooka Exp $ */
/*-
* Copyright (c) 2000, 2001 Rene Hexel <rh@netbsd.org>
@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.12 2001/11/13 07:48:42 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: esm.c,v 1.13 2002/01/14 19:24:39 pooka Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -507,11 +507,15 @@ wc_wrchctl(struct esm_softc *ess, int ch, u_int16_t data)
void
esm_power(struct esm_softc *ess, int status)
{
u_int8_t data;
pcireg_t data;
int pmcapreg;
data = pci_conf_read(ess->pc, ess->tag, CONF_PM_PTR);
if ((pci_conf_read(ess->pc, ess->tag, data) & 0xff) == PPMI_CID)
pci_conf_write(ess->pc, ess->tag, data + PM_CTRL, status);
if (pci_get_capability(ess->pc, ess->tag, PCI_CAP_PWRMGMT,
&pmcapreg, 0)) {
data = pci_conf_read(ess->pc, ess->tag, pmcapreg + 4);
if ((data && PCI_PMCSR_STATE_MASK) != status)
pci_conf_write(ess->pc, ess->tag, pmcapreg + 4, status);
}
}
@ -1362,7 +1366,7 @@ esm_attach(struct device *parent, struct device *self, void *aux)
*/
/* set to power state D0 */
esm_power(ess, PPMI_D0);
esm_power(ess, PCI_PMCSR_STATE_D0);
delay(100000);
/* Disable all legacy emulations. */
@ -1459,7 +1463,7 @@ esm_suspend(struct esm_softc *ess)
delay(20);
bus_space_write_4(ess->st, ess->sh, PORT_RINGBUS_CTRL, 0);
delay(1);
esm_power(ess, PPMI_D3);
esm_power(ess, PCI_PMCSR_STATE_D3);
return 0;
}
@ -1469,7 +1473,7 @@ esm_resume(struct esm_softc *ess)
{
int x;
esm_power(ess, PPMI_D0);
esm_power(ess, PCI_PMCSR_STATE_D0);
delay(100000);
esm_init(ess);

View File

@ -1,4 +1,4 @@
/* $NetBSD: esmreg.h,v 1.2 2001/01/18 17:48:04 tv Exp $ */
/* $NetBSD: esmreg.h,v 1.3 2002/01/14 19:24:39 pooka Exp $ */
/*-
* Copyright (c) 2000, 2001 Rene Hexel <rh@netbsd.org>
@ -70,17 +70,6 @@
#define ACPI_PART_GAME_PORT 1
#define ACPI_PART_WP 0
/* Power management */
#define CONF_PM_PTR 0x34 /* BYTE R */
#define PM_CID 0 /* BYTE R */
#define PPMI_CID 1
#define PM_CTRL 4 /* BYTE RW */
#define PPMI_D0 0 /* Full power */
#define PPMI_D1 1 /* Medium power */
#define PPMI_D2 2 /* Low power */
#define PPMI_D3 3 /* Turned off */
/* -----------------------------
* I/O ports
*/