aboutsummaryrefslogtreecommitdiffstats
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 @@
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,17 +16,19 @@
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
26 27
27#define MODNAME "hp6x0_apm" 28#define MODNAME "hp6x0_apm"
28 29
30#define PGDR 0xa400012c
31
29static void hp6x0_apm_get_power_status(struct apm_power_info *info) 32static void hp6x0_apm_get_power_status(struct apm_power_info *info)
30{ 33{
31 int battery, backup, charging, percentage; 34 int battery, backup, charging, percentage;
@@ -38,17 +41,26 @@ static void hp6x0_apm_get_power_status(struct apm_power_info *info)
38 percentage = 100 * (battery - HP680_BATTERY_MIN) / 41 percentage = 100 * (battery - HP680_BATTERY_MIN) /
39 (HP680_BATTERY_MAX - HP680_BATTERY_MIN); 42 (HP680_BATTERY_MAX - HP680_BATTERY_MIN);
40 43
44 /* % of full battery */
45 info->battery_life = percentage;
46
47 /* We want our estimates in minutes */
48 info->units = 0;
49
50 /* Extremely(!!) rough estimate, we will replace this with a datalist later on */
51 info->time = (2 * battery);
52
41 info->ac_line_status = (battery > HP680_BATTERY_AC_ON) ? 53 info->ac_line_status = (battery > HP680_BATTERY_AC_ON) ?
42 APM_AC_ONLINE : APM_AC_OFFLINE; 54 APM_AC_ONLINE : APM_AC_OFFLINE;
43 55
44 pgdr = ctrl_inb(SH7709_PGDR); 56 pgdr = ctrl_inb(PGDR);
45 if (pgdr & PGDR_MAIN_BATTERY_OUT) { 57 if (pgdr & PGDR_MAIN_BATTERY_OUT) {
46 info->battery_status = APM_BATTERY_STATUS_NOT_PRESENT; 58 info->battery_status = APM_BATTERY_STATUS_NOT_PRESENT;
47 info->battery_flag = 0x80; 59 info->battery_flag = 0x80;
48 } else if (charging < 8) { 60 } else if (charging < 8) {
49 info->battery_status = APM_BATTERY_STATUS_CHARGING; 61 info->battery_status = APM_BATTERY_STATUS_CHARGING;
50 info->battery_flag = 0x08; 62 info->battery_flag = 0x08;
51 info->ac_line_status = 0xff; 63 info->ac_line_status = 0x01;
52 } else if (percentage <= APM_CRITICAL) { 64 } else if (percentage <= APM_CRITICAL) {
53 info->battery_status = APM_BATTERY_STATUS_CRITICAL; 65 info->battery_status = APM_BATTERY_STATUS_CRITICAL;
54 info->battery_flag = 0x04; 66 info->battery_flag = 0x04;
@@ -59,8 +71,6 @@ static void hp6x0_apm_get_power_status(struct apm_power_info *info)
59 info->battery_status = APM_BATTERY_STATUS_HIGH; 71 info->battery_status = APM_BATTERY_STATUS_HIGH;
60 info->battery_flag = 0x01; 72 info->battery_flag = 0x01;
61 } 73 }
62
63 info->units = 0;
64} 74}
65 75
66static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev) 76static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev)