summaryrefslogtreecommitdiff
path: root/sys/arch/macppc
diff options
context:
space:
mode:
authorGordon Willem Klok <gwk@cvs.openbsd.org>2007-02-18 19:33:49 +0000
committerGordon Willem Klok <gwk@cvs.openbsd.org>2007-02-18 19:33:49 +0000
commitc29494f636d313b82ec048cc20aa98c0fc2a6ba0 (patch)
treeea99b9200c5c46eec79581f7cacb0c53a827cc9e /sys/arch/macppc
parentf149671a2f7a6e3251f61c2557a855c0904897d9 (diff)
Correct yo-yo shutdowns:
Apparently some machines don't detect a clean (i.e. software initiated) shutdown; and ignore the 'wake on AC loss' bit, meaning they wake up immediatly after being told to shutdown e.g. via shutdown -hp. So now we continue preserve the wake on AC loss behaivour, howerver if we initiate a clean shutdown we clear this bit so that it the machine does not immediately power back up again. ok kettenis@
Diffstat (limited to 'sys/arch/macppc')
-rw-r--r--sys/arch/macppc/dev/adb.c16
-rw-r--r--sys/arch/macppc/dev/pm_direct.c13
-rw-r--r--sys/arch/macppc/dev/pm_direct.h4
3 files changed, 21 insertions, 12 deletions
diff --git a/sys/arch/macppc/dev/adb.c b/sys/arch/macppc/dev/adb.c
index 3dc6552ff39..d8644b94ba7 100644
--- a/sys/arch/macppc/dev/adb.c
+++ b/sys/arch/macppc/dev/adb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: adb.c,v 1.20 2007/02/12 21:01:11 gwk Exp $ */
+/* $OpenBSD: adb.c,v 1.21 2007/02/18 19:33:48 gwk Exp $ */
/* $NetBSD: adb.c,v 1.6 1999/08/16 06:28:09 tsubai Exp $ */
/* $NetBSD: adb_direct.c,v 1.14 2000/06/08 22:10:45 tsubai Exp $ */
@@ -278,7 +278,7 @@ void setsoftadb(void);
int adb_intr(void *arg);
void adb_cuda_autopoll(void);
-void adb_cuda_fileserver_mode(void);
+void adb_cuda_fileserver_mode(int);
#ifdef ADB_DEBUG
/*
@@ -1516,6 +1516,8 @@ adb_poweroff(void)
switch (adbHardware) {
case ADB_HW_PMU:
+ /* Clear the wake on AC loss event */
+ pmu_fileserver_mode(0);
pm_adb_poweroff();
for (;;); /* wait for power off */
@@ -1523,6 +1525,8 @@ adb_poweroff(void)
return 0;
case ADB_HW_CUDA:
+ /* Clear the wake on AC loss event */
+ adb_cuda_fileserver_mode(0);
output[0] = 0x02; /* 2 byte message */
output[1] = 0x01; /* to pram/rtc/soft-power device */
output[2] = 0x0a; /* set poweroff */
@@ -1568,7 +1572,7 @@ adb_cuda_autopoll()
}
void
-adb_cuda_fileserver_mode()
+adb_cuda_fileserver_mode(int on)
{
volatile int flag = 0;
int result;
@@ -1577,7 +1581,7 @@ adb_cuda_fileserver_mode()
output[0] = 0x03; /* 3-byte message */
output[1] = 0x01; /* to pram/rtc device/soft-power device */
output[2] = 0x13; /* cuda file server mode */
- output[3] = 0x01; /* True */
+ output[3] = on;
result = send_adb_cuda(output, output, adb_op_comprout,
(void *)&flag, 0);
@@ -1739,7 +1743,7 @@ adbattach(struct device *parent, struct device *self, void *aux)
}
if (adbHardware == ADB_HW_CUDA)
- adb_cuda_fileserver_mode();
+ adb_cuda_fileserver_mode(1);
if (adbHardware == ADB_HW_PMU)
- pmu_fileserver_mode();
+ pmu_fileserver_mode(1);
}
diff --git a/sys/arch/macppc/dev/pm_direct.c b/sys/arch/macppc/dev/pm_direct.c
index 21dadafacd3..0f83fc61df2 100644
--- a/sys/arch/macppc/dev/pm_direct.c
+++ b/sys/arch/macppc/dev/pm_direct.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pm_direct.c,v 1.21 2007/02/12 21:01:11 gwk Exp $ */
+/* $OpenBSD: pm_direct.c,v 1.22 2007/02/18 19:33:48 gwk Exp $ */
/* $NetBSD: pm_direct.c,v 1.9 2000/06/08 22:10:46 tsubai Exp $ */
/*
@@ -839,7 +839,7 @@ pm_battery_info(int battery, struct pmu_battery_info *info)
}
void
-pmu_fileserver_mode()
+pmu_fileserver_mode(int on)
{
PMData p;
@@ -853,7 +853,12 @@ pmu_fileserver_mode()
p.num_data = 3;
p.s_buf = p.r_buf = p.data;
p.data[1] = p.data[0]; /* result from the get */
- p.data[0] = PMU_PWR_SET_POWERUP_EVENTS;
- p.data[2] |= PMU_WAKE_AC_LOSS;
+ if (on) {
+ p.data[0] = PMU_PWR_SET_POWERUP_EVENTS;
+ p.data[2] = PMU_WAKE_AC_LOSS;
+ } else {
+ p.data[0] = PMU_PWR_CLR_POWERUP_EVENTS;
+ p.data[2] = PMU_WAKE_AC_LOSS;
+ }
pmgrop(&p);
}
diff --git a/sys/arch/macppc/dev/pm_direct.h b/sys/arch/macppc/dev/pm_direct.h
index 8213ffe9a0c..680d19dd2fe 100644
--- a/sys/arch/macppc/dev/pm_direct.h
+++ b/sys/arch/macppc/dev/pm_direct.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pm_direct.h,v 1.10 2007/02/12 21:01:11 gwk Exp $ */
+/* $OpenBSD: pm_direct.h,v 1.11 2007/02/18 19:33:48 gwk Exp $ */
/* $NetBSD: pm_direct.h,v 1.5 1999/07/12 15:54:55 tsubai Exp $ */
/*
@@ -68,7 +68,7 @@ struct pmu_battery_info
int pm_battery_info(int, struct pmu_battery_info *);
void pm_eject_pcmcia(int);
-void pmu_fileserver_mode(void);
+void pmu_fileserver_mode(int);
/* PMU commands */
#define PMU_RESET_ADB 0x00 /* Reset ADB */