--- arch/i386/kernel/apm.c	2003/07/10 18:49:23	1.1
+++ arch/i386/kernel/apm.c	2003/07/09 21:03:58
@@ -1007,9 +1007,39 @@
  *	if reported is a lifetime in secodnds/minutes at current powwer
  *	consumption.
  */
+#include <asm/io.h>
+#include <asm/delay.h>
  
+static unsigned short get_ec_byte(unsigned char address)
+{
+	int timeout;
+	outb(0x80,0x66);
+	timeout=100;
+	while((inb(0x66)&2)&&timeout)
+	{
+		udelay(100);
+		timeout--;
+	}
+	if(!timeout) return 0xffff;
+	outb(address,0x62);
+	timeout=100;
+	while((!(inb(0x66)&1))&&timeout)
+	{
+		udelay(100);
+		timeout--;
+	}
+	if(!timeout) return 0xffff;
+	return inb(0x62);
+}
+
+static unsigned short get_ec_word(unsigned char address)
+{
+	return (get_ec_byte(address)<<8)+(get_ec_byte(address+1)&0xff);
+}
+
 static int apm_get_power_status(u_short *status, u_short *bat, u_short *life)
 {
+#if 0
 	u32	eax;
 	u32	ebx;
 	u32	ecx;
@@ -1029,6 +1059,21 @@
 	} else
 		*life = edx;
 	return APM_SUCCESS;
+#endif
+	unsigned char b1ex,b1st;
+	b1ex=get_ec_byte(0x80);
+	*status=(b1ex&4)?0x100:0;	// AC status
+	*bat=get_ec_word(0xa0);		// remaining percentage
+		
+	*life=get_ec_word(0xd0)|0x8000;	// B1TI
+	
+	b1st=get_ec_byte(0x84);		// battery status, B1ST
+	if(b1st&2) *status+=3;		// charging, B1ST&2
+	else if(b1st&4) *status+=2; 	// critical, B1ST&4
+	else if(get_ec_word(0xa2)<get_ec_word(0xb6)) *status+=1; // low (B1RA < B1DL)
+	else if(!(b1ex&1)) *status+=4;	// battery not present, high (0) otherwise
+	
+	return APM_SUCCESS;
 }
 
 #if 0
@@ -1271,6 +1316,7 @@
 
 static void standby(void)
 {
+#if 0
 	int	err;
 
 	/* If needed, notify drivers here */
@@ -1278,6 +1324,8 @@
 	err = set_system_power_state(APM_STATE_STANDBY);
 	if ((err != APM_SUCCESS) && (err != APM_NO_ERROR))
 		apm_error("standby", err);
+#endif
+	suspend(1);
 }
 
 static apm_event_t get_event(void)
