Skip to content

Commit 8b03c04

Browse files
Kristoffer Ericsonpmundt
authored andcommitted
sh: hp6xx: Correct APM output.
This patch fixes the old non-verbose hp6xx apm code and enables some very basic apm output. We now get percentage (battery) output and basic time estimate. Signed-off-by: Kristoffer Ericson <kristoffer.ericson@gmail.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent 56546b1 commit 8b03c04

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

‎arch/sh/boards/hp6xx/hp6xx_apm.c‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* bios-less APM driver for hp680
33
*
44
* Copyright 2005 (c) Andriy Skulysh <askulysh@gmail.com>
5+
* Copyright 2008 (c) Kristoffer Ericson <kristoffer.ericson@gmail.com>
56
*
67
* This program is free software; you can redistribute it and/or
78
* modify it under the terms of the GNU General Public License.
@@ -15,11 +16,11 @@
1516
#include <asm/adc.h>
1617
#include <asm/hp6xx.h>
1718

18-
#define SH7709_PGDR 0xa400012c
19-
19+
/* percentage values */
2020
#define APM_CRITICAL 10
2121
#define APM_LOW 30
2222

23+
/* resonably sane values */
2324
#define HP680_BATTERY_MAX 898
2425
#define HP680_BATTERY_MIN 486
2526
#define HP680_BATTERY_AC_ON 1023
@@ -38,17 +39,26 @@ static void hp6x0_apm_get_power_status(struct apm_power_info *info)
3839
percentage = 100 * (battery - HP680_BATTERY_MIN) /
3940
(HP680_BATTERY_MAX - HP680_BATTERY_MIN);
4041

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+
4151
info->ac_line_status = (battery > HP680_BATTERY_AC_ON) ?
4252
APM_AC_ONLINE : APM_AC_OFFLINE;
4353

44-
pgdr = ctrl_inb(SH7709_PGDR);
54+
pgdr = ctrl_inb(PGDR);
4555
if (pgdr & PGDR_MAIN_BATTERY_OUT) {
4656
info->battery_status = APM_BATTERY_STATUS_NOT_PRESENT;
4757
info->battery_flag = 0x80;
4858
} else if (charging < 8) {
4959
info->battery_status = APM_BATTERY_STATUS_CHARGING;
5060
info->battery_flag = 0x08;
51-
info->ac_line_status = 0xff;
61+
info->ac_line_status = 0x01;
5262
} else if (percentage <= APM_CRITICAL) {
5363
info->battery_status = APM_BATTERY_STATUS_CRITICAL;
5464
info->battery_flag = 0x04;
@@ -59,8 +69,6 @@ static void hp6x0_apm_get_power_status(struct apm_power_info *info)
5969
info->battery_status = APM_BATTERY_STATUS_HIGH;
6070
info->battery_flag = 0x01;
6171
}
62-
63-
info->units = 0;
6472
}
6573

6674
static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev)

0 commit comments

Comments
 (0)