summaryrefslogtreecommitdiffstats
path: root/arch/sh/boards/hp6xx/hp6xx_apm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards/hp6xx/hp6xx_apm.c')
-rw-r--r--arch/sh/boards/hp6xx/hp6xx_apm.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/arch/sh/boards/hp6xx/hp6xx_apm.c b/arch/sh/boards/hp6xx/hp6xx_apm.c
index 640ca2a74f16..177f4f028e0d 100644
--- a/arch/sh/boards/hp6xx/hp6xx_apm.c
+++ b/arch/sh/boards/hp6xx/hp6xx_apm.c
@@ -2,6 +2,7 @@
* bios-less APM driver for hp680
*
* Copyright 2005 (c) Andriy Skulysh <askulysh@gmail.com>
+ * Copyright 2008 (c) Kristoffer Ericson <kristoffer.ericson@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License.
@@ -15,17 +16,19 @@
#include <asm/adc.h>
#include <asm/hp6xx.h>
-#define SH7709_PGDR 0xa400012c
-
+/* percentage values */
#define APM_CRITICAL 10
#define APM_LOW 30
+/* resonably sane values */
#define HP680_BATTERY_MAX 898
#define HP680_BATTERY_MIN 486
#define HP680_BATTERY_AC_ON 1023
#define MODNAME "hp6x0_apm"
+#define PGDR 0xa400012c
+
static void hp6x0_apm_get_power_status(struct apm_power_info *info)
{
int battery, backup, charging, percentage;
@@ -38,17 +41,26 @@ static void hp6x0_apm_get_power_status(struct apm_power_info *info)
percentage = 100 * (battery - HP680_BATTERY_MIN) /
(HP680_BATTERY_MAX - HP680_BATTERY_MIN);
+ /* % of full battery */
+ info->battery_life = percentage;
+
+ /* We want our estimates in minutes */
+ info->units = 0;
+
+ /* Extremely(!!) rough estimate, we will replace this with a datalist later on */
+ info->time = (2 * battery);
+
info->ac_line_status = (battery > HP680_BATTERY_AC_ON) ?
APM_AC_ONLINE : APM_AC_OFFLINE;
- pgdr = ctrl_inb(SH7709_PGDR);
+ pgdr = ctrl_inb(PGDR);
if (pgdr & PGDR_MAIN_BATTERY_OUT) {
info->battery_status = APM_BATTERY_STATUS_NOT_PRESENT;
info->battery_flag = 0x80;
} else if (charging < 8) {
info->battery_status = APM_BATTERY_STATUS_CHARGING;
info->battery_flag = 0x08;
- info->ac_line_status = 0xff;
+ info->ac_line_status = 0x01;
} else if (percentage <= APM_CRITICAL) {
info->battery_status = APM_BATTERY_STATUS_CRITICAL;
info->battery_flag = 0x04;
@@ -59,8 +71,6 @@ static void hp6x0_apm_get_power_status(struct apm_power_info *info)
info->battery_status = APM_BATTERY_STATUS_HIGH;
info->battery_flag = 0x01;
}
-
- info->units = 0;
}
static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev)