linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* AC Power handling broken for desktops
@ 2005-08-24 11:54 Olaf Hering
  2005-08-24 22:32 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 10+ messages in thread
From: Olaf Hering @ 2005-08-24 11:54 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev


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?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: AC Power handling broken for desktops
  2005-08-24 11:54 AC Power handling broken for desktops Olaf Hering
@ 2005-08-24 22:32 ` Benjamin Herrenschmidt
  2005-08-25  4:51   ` Olaf Hering
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2005-08-24 22:32 UTC (permalink / raw)
  To: Olaf Hering; +Cc: linuxppc-dev

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: AC Power handling broken for desktops
  2005-08-24 22:32 ` Benjamin Herrenschmidt
@ 2005-08-25  4:51   ` Olaf Hering
  2005-08-25  5:08     ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 10+ messages in thread
From: Olaf Hering @ 2005-08-25  4:51 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev

 On Thu, Aug 25, Benjamin Herrenschmidt wrote:

> 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

Appearently not, how do I check it?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: AC Power handling broken for desktops
  2005-08-25  4:51   ` Olaf Hering
@ 2005-08-25  5:08     ` Benjamin Herrenschmidt
  2005-08-25  5:15       ` Olaf Hering
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2005-08-25  5:08 UTC (permalink / raw)
  To: Olaf Hering; +Cc: linuxppc-dev

On Thu, 2005-08-25 at 06:51 +0200, Olaf Hering wrote:
>  On Thu, Aug 25, Benjamin Herrenschmidt wrote:
> 
> > 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
> 
> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: AC Power handling broken for desktops
  2005-08-25  5:08     ` Benjamin Herrenschmidt
@ 2005-08-25  5:15       ` Olaf Hering
  2005-08-25  5:34         ` Benjamin Herrenschmidt
  2005-08-25 15:10         ` Segher Boessenkool
  0 siblings, 2 replies; 10+ messages in thread
From: Olaf Hering @ 2005-08-25  5:15 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev

 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: AC Power handling broken for desktops
  2005-08-25  5:15       ` Olaf Hering
@ 2005-08-25  5:34         ` Benjamin Herrenschmidt
  2005-08-26 11:38           ` Olaf Hering
  2005-08-25 15:10         ` Segher Boessenkool
  1 sibling, 1 reply; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2005-08-25  5:34 UTC (permalink / raw)
  To: Olaf Hering; +Cc: linuxppc-dev

On Thu, 2005-08-25 at 07:15 +0200, Olaf Hering wrote:
>  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.

Yah, you can check that with pmac_feature, there is a "mobile" flag.

Ben

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: AC Power handling broken for desktops
  2005-08-25  5:15       ` Olaf Hering
  2005-08-25  5:34         ` Benjamin Herrenschmidt
@ 2005-08-25 15:10         ` Segher Boessenkool
  1 sibling, 0 replies; 10+ messages in thread
From: Segher Boessenkool @ 2005-08-25 15:10 UTC (permalink / raw)
  To: Olaf Hering; +Cc: linuxppc-dev

>> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: AC Power handling broken for desktops
  2005-08-25  5:34         ` Benjamin Herrenschmidt
@ 2005-08-26 11:38           ` Olaf Hering
  2005-09-19  0:44             ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 10+ messages in thread
From: Olaf Hering @ 2005-08-26 11:38 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev

 On Thu, Aug 25, Benjamin Herrenschmidt wrote:

> On Thu, 2005-08-25 at 07:15 +0200, Olaf Hering wrote:
> >  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.
> 
> 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)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: AC Power handling broken for desktops
  2005-08-26 11:38           ` Olaf Hering
@ 2005-09-19  0:44             ` Benjamin Herrenschmidt
  2005-10-10 17:08               ` [PATCH] " Olaf Hering
  0 siblings, 1 reply; 10+ messages in thread
From: Benjamin Herrenschmidt @ 2005-09-19  0:44 UTC (permalink / raw)
  To: Olaf Hering; +Cc: linuxppc-dev

On Fri, 2005-08-26 at 13:38 +0200, Olaf Hering wrote:
>  On Thu, Aug 25, Benjamin Herrenschmidt wrote:
> 
> > On Thu, 2005-08-25 at 07:15 +0200, Olaf Hering wrote:
> > >  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.
> > 
> > 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] AC Power handling broken for desktops
  2005-09-19  0:44             ` Benjamin Herrenschmidt
@ 2005-10-10 17:08               ` Olaf Hering
  0 siblings, 0 replies; 10+ messages in thread
From: Olaf Hering @ 2005-10-10 17:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Andrew Morton; +Cc: linuxppc-dev


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

Signed-off-by: Olaf Hering <olh@suse.de>

 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-10-10 17:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-24 11:54 AC Power handling broken for desktops Olaf Hering
2005-08-24 22:32 ` Benjamin Herrenschmidt
2005-08-25  4:51   ` Olaf Hering
2005-08-25  5:08     ` Benjamin Herrenschmidt
2005-08-25  5:15       ` Olaf Hering
2005-08-25  5:34         ` Benjamin Herrenschmidt
2005-08-26 11:38           ` Olaf Hering
2005-09-19  0:44             ` Benjamin Herrenschmidt
2005-10-10 17:08               ` [PATCH] " Olaf Hering
2005-08-25 15:10         ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).