summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2010-08-25 21:38:00 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2010-08-25 21:38:00 +0000
commit1983c3805b3ebdcf9306dd80538f44e4947dcb23 (patch)
treedb58344e83e8ec2da5c5a683d543bb6323d20f30 /sys
parent5fa7cbf2720de57e4ec997758522caff75547a8a (diff)
Make CardBus ral(4) suspend and resume properly on machines that keep the
CardBus bridge powered up during suspend. Step zero on the long road towards fully suspending CardBus on all machines. ok deraadt@, damien@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/cardbus/cardbus.c5
-rw-r--r--sys/dev/cardbus/cardslot.c5
-rw-r--r--sys/dev/cardbus/if_ral_cardbus.c61
-rw-r--r--sys/dev/ic/rt2560.c4
-rw-r--r--sys/dev/ic/rt2661.c4
-rw-r--r--sys/dev/ic/rt2860.c4
-rw-r--r--sys/dev/pci/pccbb.c5
7 files changed, 61 insertions, 27 deletions
diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c
index 6b094139fec..6786f0fb293 100644
--- a/sys/dev/cardbus/cardbus.c
+++ b/sys/dev/cardbus/cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cardbus.c,v 1.44 2010/03/27 21:40:13 jsg Exp $ */
+/* $OpenBSD: cardbus.c,v 1.45 2010/08/25 21:37:59 kettenis Exp $ */
/* $NetBSD: cardbus.c,v 1.24 2000/04/02 19:11:37 mycroft Exp $ */
/*
@@ -83,7 +83,8 @@ STATIC void disable_function(struct cardbus_softc *, int);
struct cfattach cardbus_ca = {
- sizeof(struct cardbus_softc), cardbusmatch, cardbusattach
+ sizeof(struct cardbus_softc), cardbusmatch, cardbusattach,
+ NULL, config_activate_children
};
struct cfdriver cardbus_cd = {
diff --git a/sys/dev/cardbus/cardslot.c b/sys/dev/cardbus/cardslot.c
index f7a982ec298..0061e48ec32 100644
--- a/sys/dev/cardbus/cardslot.c
+++ b/sys/dev/cardbus/cardslot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cardslot.c,v 1.13 2010/01/13 09:10:33 jsg Exp $ */
+/* $OpenBSD: cardslot.c,v 1.14 2010/08/25 21:37:59 kettenis Exp $ */
/* $NetBSD: cardslot.c,v 1.9 2000/03/22 09:35:06 haya Exp $ */
/*
@@ -68,7 +68,8 @@ STATIC int cardslot_16_print(void *, const char *);
STATIC int cardslot_16_submatch(struct device *, void *,void *);
struct cfattach cardslot_ca = {
- sizeof(struct cardslot_softc), cardslotmatch, cardslotattach
+ sizeof(struct cardslot_softc), cardslotmatch, cardslotattach,
+ NULL, config_activate_children
};
struct cfdriver cardslot_cd = {
diff --git a/sys/dev/cardbus/if_ral_cardbus.c b/sys/dev/cardbus/if_ral_cardbus.c
index 1592363f53e..8b4444c0b0c 100644
--- a/sys/dev/cardbus/if_ral_cardbus.c
+++ b/sys/dev/cardbus/if_ral_cardbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ral_cardbus.c,v 1.18 2010/04/05 14:14:02 damien Exp $ */
+/* $OpenBSD: if_ral_cardbus.c,v 1.19 2010/08/25 21:37:59 kettenis Exp $ */
/*-
* Copyright (c) 2005-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -31,6 +31,7 @@
#include <sys/malloc.h>
#include <sys/timeout.h>
#include <sys/device.h>
+#include <sys/workq.h>
#include <machine/bus.h>
#include <machine/intr.h>
@@ -59,21 +60,29 @@
static struct ral_opns {
int (*attach)(void *, int);
int (*detach)(void *);
+ void (*suspend)(void *);
+ void (*resume)(void *);
int (*intr)(void *);
} ral_rt2560_opns = {
rt2560_attach,
rt2560_detach,
+ rt2560_suspend,
+ rt2560_resume,
rt2560_intr
}, ral_rt2661_opns = {
rt2661_attach,
rt2661_detach,
+ rt2661_suspend,
+ rt2661_resume,
rt2661_intr
}, ral_rt2860_opns = {
rt2860_attach,
rt2860_detach,
+ rt2860_suspend,
+ rt2860_resume,
rt2860_intr
};
@@ -94,15 +103,18 @@ struct ral_cardbus_softc {
pcireg_t sc_bar_val;
int sc_intrline;
pci_chipset_tag_t sc_pc;
+ struct workq_task sc_resume_wqt;
};
int ral_cardbus_match(struct device *, void *, void *);
void ral_cardbus_attach(struct device *, struct device *, void *);
int ral_cardbus_detach(struct device *, int);
+int ral_cardbus_activate(struct device *, int);
struct cfattach ral_cardbus_ca = {
sizeof (struct ral_cardbus_softc), ral_cardbus_match,
- ral_cardbus_attach, ral_cardbus_detach
+ ral_cardbus_attach, ral_cardbus_detach,
+ ral_cardbus_activate
};
static const struct pci_matchid ral_cardbus_devices[] = {
@@ -133,8 +145,8 @@ static const struct pci_matchid ral_cardbus_devices[] = {
int ral_cardbus_enable(struct rt2560_softc *);
void ral_cardbus_disable(struct rt2560_softc *);
-void ral_cardbus_power(struct rt2560_softc *, int);
void ral_cardbus_setup(struct ral_cardbus_softc *);
+void ral_cardbus_resume(void *, void *);
int
ral_cardbus_match(struct device *parent, void *match, void *aux)
@@ -180,7 +192,6 @@ ral_cardbus_attach(struct device *parent, struct device *self, void *aux)
/* power management hooks */
sc->sc_enable = ral_cardbus_enable;
sc->sc_disable = ral_cardbus_disable;
- sc->sc_power = ral_cardbus_power;
/* map control/status registers */
error = Cardbus_mapreg_map(ct, CARDBUS_BASE0_REG,
@@ -231,6 +242,25 @@ ral_cardbus_detach(struct device *self, int flags)
}
int
+ral_cardbus_activate(struct device *self, int act)
+{
+ struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)self;
+ struct rt2560_softc *sc = &csc->sc_sc;
+
+ switch (act) {
+ case DVACT_SUSPEND:
+ (*csc->sc_opns->suspend)(sc);
+ break;
+ case DVACT_RESUME:
+ workq_queue_task(NULL, &csc->sc_resume_wqt, 0,
+ ral_cardbus_resume, csc, NULL);
+ break;
+ }
+
+ return 0;
+}
+
+int
ral_cardbus_enable(struct rt2560_softc *sc)
{
struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)sc;
@@ -274,17 +304,6 @@ ral_cardbus_disable(struct rt2560_softc *sc)
}
void
-ral_cardbus_power(struct rt2560_softc *sc, int why)
-{
- struct ral_cardbus_softc *csc = (struct ral_cardbus_softc *)sc;
-
- if (why == PWR_RESUME) {
- /* kick the PCI configuration registers */
- ral_cardbus_setup(csc);
- }
-}
-
-void
ral_cardbus_setup(struct ral_cardbus_softc *csc)
{
cardbus_devfunc_t ct = csc->sc_ct;
@@ -308,3 +327,15 @@ ral_cardbus_setup(struct ral_cardbus_softc *csc)
pci_conf_write(pc, csc->sc_tag, PCI_COMMAND_STATUS_REG,
reg);
}
+
+void
+ral_cardbus_resume(void *arg1, void *arg2)
+{
+ struct ral_cardbus_softc *csc = arg1;
+ struct rt2560_softc *sc = &csc->sc_sc;
+ int s;
+
+ s = splnet();
+ (*csc->sc_opns->resume)(sc);
+ splx(s);
+}
diff --git a/sys/dev/ic/rt2560.c b/sys/dev/ic/rt2560.c
index 51499087a4a..258059d8aad 100644
--- a/sys/dev/ic/rt2560.c
+++ b/sys/dev/ic/rt2560.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2560.c,v 1.49 2010/08/04 19:48:33 damien Exp $ */
+/* $OpenBSD: rt2560.c,v 1.50 2010/08/25 21:37:59 kettenis Exp $ */
/*-
* Copyright (c) 2005, 2006
@@ -341,7 +341,7 @@ rt2560_suspend(void *xsc)
struct ifnet *ifp = &sc->sc_ic.ic_if;
if (ifp->if_flags & IFF_RUNNING)
- rt2560_stop(ifp, 0);
+ rt2560_stop(ifp, 1);
}
void
diff --git a/sys/dev/ic/rt2661.c b/sys/dev/ic/rt2661.c
index ca351be844b..541d2941719 100644
--- a/sys/dev/ic/rt2661.c
+++ b/sys/dev/ic/rt2661.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2661.c,v 1.55 2010/08/04 19:48:33 damien Exp $ */
+/* $OpenBSD: rt2661.c,v 1.56 2010/08/25 21:37:59 kettenis Exp $ */
/*-
* Copyright (c) 2006
@@ -408,7 +408,7 @@ rt2661_suspend(void *xsc)
struct ifnet *ifp = &sc->sc_ic.ic_if;
if (ifp->if_flags & IFF_RUNNING)
- rt2661_stop(ifp, 0);
+ rt2661_stop(ifp, 1);
}
void
diff --git a/sys/dev/ic/rt2860.c b/sys/dev/ic/rt2860.c
index 25b6a782968..3dc0d81a66c 100644
--- a/sys/dev/ic/rt2860.c
+++ b/sys/dev/ic/rt2860.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2860.c,v 1.57 2010/08/04 19:48:33 damien Exp $ */
+/* $OpenBSD: rt2860.c,v 1.58 2010/08/25 21:37:59 kettenis Exp $ */
/*-
* Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -429,7 +429,7 @@ rt2860_suspend(void *xsc)
struct ifnet *ifp = &sc->sc_ic.ic_if;
if (ifp->if_flags & IFF_RUNNING)
- rt2860_stop(ifp, 0);
+ rt2860_stop(ifp, 1);
}
void
diff --git a/sys/dev/pci/pccbb.c b/sys/dev/pci/pccbb.c
index 51517a241a6..499be28f01b 100644
--- a/sys/dev/pci/pccbb.c
+++ b/sys/dev/pci/pccbb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pccbb.c,v 1.76 2010/06/30 19:46:30 blambert Exp $ */
+/* $OpenBSD: pccbb.c,v 1.77 2010/08/25 21:37:59 kettenis Exp $ */
/* $NetBSD: pccbb.c,v 1.96 2004/03/28 09:49:31 nakayama Exp $ */
/*
@@ -176,7 +176,8 @@ void cb_show_regs(pci_chipset_tag_t, pcitag_t, bus_space_tag_t,
#endif
struct cfattach cbb_pci_ca = {
- sizeof(struct pccbb_softc), pcicbbmatch, pccbbattach
+ sizeof(struct pccbb_softc), pcicbbmatch, pccbbattach, NULL,
+ config_activate_children
};
static struct pcmcia_chip_functions pccbb_pcmcia_funcs = {