aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sh/boards
diff options
context:
space:
mode:
Diffstat (limited to 'arch/sh/boards')
-rw-r--r--arch/sh/boards/hp6xx/hp6xx_apm.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/arch/sh/boards/hp6xx/hp6xx_apm.c b/arch/sh/boards/hp6xx/hp6xx_apm.c
index 640ca2a74f16..76b6776235df 100644
--- a/arch/sh/boards/hp6xx/hp6xx_apm.c
+++ b/arch/sh/boards/hp6xx/hp6xx_apm.c
@@ -2,6 +2,7 @@
2 * bios-less APM driver for hp680 2 * bios-less APM driver for hp680
3 * 3 *
4 * Copyright 2005 (c) Andriy Skulysh <askulysh@gmail.com> 4 * Copyright 2005 (c) Andriy Skulysh <askulysh@gmail.com>
5 * Copyright 2008 (c) Kristoffer Ericson <kristoffer.ericson@gmail.com>
5 * 6 *
6 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License. 8 * modify it under the terms of the GNU General Public License.
@@ -15,11 +16,11 @@
15#include <asm/adc.h> 16#include <asm/adc.h>
16#include <asm/hp6xx.h> 17#include <asm/hp6xx.h>
17 18
18#define SH7709_PGDR 0xa400012c 19/* percentage values */
19
20#define APM_CRITICAL 10 20#define APM_CRITICAL 10
21#define APM_LOW 30 21#define APM_LOW 30
22 22
23/* resonably sane values */
23#define HP680_BATTERY_MAX 898 24#define HP680_BATTERY_MAX 898
24#define HP680_BATTERY_MIN 486 25#define HP680_BATTERY_MIN 486
25#define HP680_BATTERY_AC_ON 1023 26#define HP680_BATTERY_AC_ON 1023
@@ -38,17 +39,26 @@ static void hp6x0_apm_get_power_status(struct apm_power_info *info)
38 percentage = 100 * (battery - HP680_BATTERY_MIN) / 39 percentage = 100 * (battery - HP680_BATTERY_MIN) /
39 (HP680_BATTERY_MAX - HP680_BATTERY_MIN); 40 (HP680_BATTERY_MAX - HP680_BATTERY_MIN);
40 41
42 /* % of full battery */
43 info->battery_life = percentage;
44
45 /* We want our estimates in minutes */
46 info->units = 0;
47
48 /* Extremely(!!) rough estimate, we will replace this with a datalist later on */
49 info->time = (2 * battery);
50
41 info->ac_line_status = (battery > HP680_BATTERY_AC_ON) ? 51 info->ac_line_status = (battery > HP680_BATTERY_AC_ON) ?
42 APM_AC_ONLINE : APM_AC_OFFLINE; 52 APM_AC_ONLINE : APM_AC_OFFLINE;
43 53
44 pgdr = ctrl_inb(SH7709_PGDR); 54 pgdr = ctrl_inb(PGDR);
45 if (pgdr & PGDR_MAIN_BATTERY_OUT) { 55 if (pgdr & PGDR_MAIN_BATTERY_OUT) {
46 info->battery_status = APM_BATTERY_STATUS_NOT_PRESENT; 56 info->battery_status = APM_BATTERY_STATUS_NOT_PRESENT;
47 info->battery_flag = 0x80; 57 info->battery_flag = 0x80;
48 } else if (charging < 8) { 58 } else if (charging < 8) {
49 info->battery_status = APM_BATTERY_STATUS_CHARGING; 59 info->battery_status = APM_BATTERY_STATUS_CHARGING;
50 info->battery_flag = 0x08; 60 info->battery_flag = 0x08;
51 info->ac_line_status = 0xff; 61 info->ac_line_status = 0x01;
52 } else if (percentage <= APM_CRITICAL) { 62 } else if (percentage <= APM_CRITICAL) {
53 info->battery_status = APM_BATTERY_STATUS_CRITICAL; 63 info->battery_status = APM_BATTERY_STATUS_CRITICAL;
54 info->battery_flag = 0x04; 64 info->battery_flag = 0x04;
@@ -59,8 +69,6 @@ static void hp6x0_apm_get_power_status(struct apm_power_info *info)
59 info->battery_status = APM_BATTERY_STATUS_HIGH; 69 info->battery_status = APM_BATTERY_STATUS_HIGH;
60 info->battery_flag = 0x01; 70 info->battery_flag = 0x01;
61 } 71 }
62
63 info->units = 0;
64} 72}
65 73
66static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev) 74static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev)