AC Power handling broken for desktops

10 messages, 3 authors, 2005-10-10 · open the first message on its own page

AC Power handling broken for desktops

From: Olaf Hering <hidden>
Date: 2005-08-24 11:54:58

My G4/450 runs without AC Power, according to /proc/pmu/info:

PMU driver version     : 2
PMU firmware version   : 0c
AC Power               : 0
Battery count          : 0

It should report 1. Where is the best place to get the
PMU_PWR_AC_PRESENT into ac_line_status?

Re: AC Power handling broken for desktops

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2005-08-24 22:34:07

On Wed, 2005-08-24 at 13:54 +0200, Olaf Hering wrote:
My G4/450 runs without AC Power, according to /proc/pmu/info:

PMU driver version     : 2
PMU firmware version   : 0c
AC Power               : 0
Battery count          : 0

It should report 1. Where is the best place to get the
PMU_PWR_AC_PRESENT into ac_line_status?
Do we get the bit set from the PMU ? If not, maybe we should hard code
that value on non-laptops

Ben.

Re: AC Power handling broken for desktops

From: Olaf Hering <hidden>
Date: 2005-08-25 04:51:13

 On Thu, Aug 25, Benjamin Herrenschmidt wrote:
On Wed, 2005-08-24 at 13:54 +0200, Olaf Hering wrote:
quoted
My G4/450 runs without AC Power, according to /proc/pmu/info:

PMU driver version     : 2
PMU firmware version   : 0c
AC Power               : 0
Battery count          : 0

It should report 1. Where is the best place to get the
PMU_PWR_AC_PRESENT into ac_line_status?
Do we get the bit set from the PMU ? If not, maybe we should hard code
that value on non-laptops
Appearently not, how do I check it?

Re: AC Power handling broken for desktops

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2005-08-25 05:09:38

On Thu, 2005-08-25 at 06:51 +0200, Olaf Hering wrote:
 On Thu, Aug 25, Benjamin Herrenschmidt wrote:
quoted
On Wed, 2005-08-24 at 13:54 +0200, Olaf Hering wrote:
quoted
My G4/450 runs without AC Power, according to /proc/pmu/info:

PMU driver version     : 2
PMU firmware version   : 0c
AC Power               : 0
Battery count          : 0

It should report 1. Where is the best place to get the
PMU_PWR_AC_PRESENT into ac_line_status?
Do we get the bit set from the PMU ? If not, maybe we should hard code
that value on non-laptops
Appearently not, how do I check it?
Not sure :) I don't fully know how to decode those power things in the
device-tree... There are bits in darwin tho.

Ben

Re: AC Power handling broken for desktops

From: Olaf Hering <hidden>
Date: 2005-08-25 05:15:33

 On Thu, Aug 25, Benjamin Herrenschmidt wrote:
Not sure :) I don't fully know how to decode those power things in the
device-tree... There are bits in darwin tho.
Maybe just check for !PowerBook and force PMU_PWR_AC_PRESENT in this case.

Re: AC Power handling broken for desktops

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2005-08-25 05:36:07

On Thu, 2005-08-25 at 07:15 +0200, Olaf Hering wrote:
 On Thu, Aug 25, Benjamin Herrenschmidt wrote:
quoted
Not sure :) I don't fully know how to decode those power things in the
device-tree... There are bits in darwin tho.
Maybe just check for !PowerBook and force PMU_PWR_AC_PRESENT in this case.
Yah, you can check that with pmac_feature, there is a "mobile" flag.

Ben

Re: AC Power handling broken for desktops

From: Segher Boessenkool <hidden>
Date: 2005-08-25 15:10:28

quoted
Not sure :) I don't fully know how to decode those power things in the
device-tree... There are bits in darwin tho.
Maybe just check for !PowerBook and force PMU_PWR_AC_PRESENT in this 
case.
Or just if battery count is 0, assume AC power ;-)


Segher

Re: AC Power handling broken for desktops

From: Olaf Hering <hidden>
Date: 2005-08-26 11:38:32

 On Thu, Aug 25, Benjamin Herrenschmidt wrote:
On Thu, 2005-08-25 at 07:15 +0200, Olaf Hering wrote:
quoted
 On Thu, Aug 25, Benjamin Herrenschmidt wrote:
quoted
Not sure :) I don't fully know how to decode those power things in the
device-tree... There are bits in darwin tho.
Maybe just check for !PowerBook and force PMU_PWR_AC_PRESENT in this case.
Yah, you can check that with pmac_feature, there is a "mobile" flag.
Its not obvious how to get to that flag. Is this patch acceptable?
No batteries present should mean AC Power == 1.

 drivers/macintosh/apm_emu.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Index: linux-2.6.13-rc7-ac-power/drivers/macintosh/apm_emu.c
===================================================================
--- linux-2.6.13-rc7-ac-power.orig/drivers/macintosh/apm_emu.c
+++ linux-2.6.13-rc7-ac-power/drivers/macintosh/apm_emu.c
@@ -430,8 +430,8 @@ static int apm_emu_get_info(char *buf, c
 	      -1: Unknown
 	   8) min = minutes; sec = seconds */
 
-	unsigned short  ac_line_status = 0xff;
-	unsigned short  battery_status = 0xff;
+	unsigned short  ac_line_status;
+	unsigned short  battery_status = 0;
 	unsigned short  battery_flag   = 0xff;
 	int		percentage     = -1;
 	int             time_units     = -1;
@@ -446,6 +446,7 @@ static int apm_emu_get_info(char *buf, c
 	ac_line_status = ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0);
 	for (i=0; i<pmu_battery_count; i++) {
 		if (pmu_batteries[i].flags & PMU_BATT_PRESENT) {
+			battery_status++;
 			if (percentage < 0)
 				percentage = 0;
 			if (charge < 0)
@@ -461,6 +462,9 @@ static int apm_emu_get_info(char *buf, c
 				charging++;
 		}
 	}
+	if (0 == battery_status)
+		ac_line_status = 1;
+	battery_status = 0xff;
 	if (real_count) {
 		if (amperage < 0) {
 			if (btype == PMU_BATT_TYPE_SMART)

Re: AC Power handling broken for desktops

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2005-09-19 00:44:22

On Fri, 2005-08-26 at 13:38 +0200, Olaf Hering wrote:
 On Thu, Aug 25, Benjamin Herrenschmidt wrote:
quoted
On Thu, 2005-08-25 at 07:15 +0200, Olaf Hering wrote:
quoted
 On Thu, Aug 25, Benjamin Herrenschmidt wrote:
quoted
Not sure :) I don't fully know how to decode those power things in the
device-tree... There are bits in darwin tho.
Maybe just check for !PowerBook and force PMU_PWR_AC_PRESENT in this case.
Yah, you can check that with pmac_feature, there is a "mobile" flag.
Its not obvious how to get to that flag. Is this patch acceptable?
No batteries present should mean AC Power == 1.

 drivers/macintosh/apm_emu.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
Looks good to me.

Ben

[PATCH] AC Power handling broken for desktops

From: Olaf Hering <hidden>
Date: 2005-10-10 17:09:02

Currently, AC Power is 0 on a desktop G4.
No batteries present should mean AC Power == 1.

Signed-off-by: Olaf Hering <redacted>

 drivers/macintosh/apm_emu.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

Index: linux-2.6.13-rc7-ac-power/drivers/macintosh/apm_emu.c
===================================================================
--- linux-2.6.13-rc7-ac-power.orig/drivers/macintosh/apm_emu.c
+++ linux-2.6.13-rc7-ac-power/drivers/macintosh/apm_emu.c
@@ -430,8 +430,8 @@ static int apm_emu_get_info(char *buf, c
 	      -1: Unknown
 	   8) min = minutes; sec = seconds */
 
-	unsigned short  ac_line_status = 0xff;
-	unsigned short  battery_status = 0xff;
+	unsigned short  ac_line_status;
+	unsigned short  battery_status = 0;
 	unsigned short  battery_flag   = 0xff;
 	int		percentage     = -1;
 	int             time_units     = -1;
@@ -446,6 +446,7 @@ static int apm_emu_get_info(char *buf, c
 	ac_line_status = ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0);
 	for (i=0; i<pmu_battery_count; i++) {
 		if (pmu_batteries[i].flags & PMU_BATT_PRESENT) {
+			battery_status++;
 			if (percentage < 0)
 				percentage = 0;
 			if (charge < 0)
@@ -461,6 +462,9 @@ static int apm_emu_get_info(char *buf, c
 				charging++;
 		}
 	}
+	if (0 == battery_status)
+		ac_line_status = 1;
+	battery_status = 0xff;
 	if (real_count) {
 		if (amperage < 0) {
 			if (btype == PMU_BATT_TYPE_SMART)
-- 
short story of a lazy sysadmin:
 alias appserv=wotan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help