Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 87013
b: refs/heads/master
c: 8b03c04
h: refs/heads/master
i:
  87011: 1233ee8
v: v3
  • Loading branch information
Kristoffer Ericson authored and Paul Mundt committed Mar 6, 2008
1 parent ffeef83 commit e0b114e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 56546b18969eb808af0c1a6ff68988678bd0a8b7
refs/heads/master: 8b03c040e4efaaad3fc09f07f6af6e449205c75a
20 changes: 14 additions & 6 deletions trunk/arch/sh/boards/hp6xx/hp6xx_apm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -15,11 +16,11 @@
#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
Expand All @@ -38,17 +39,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;
Expand All @@ -59,8 +69,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)
Expand Down

0 comments on commit e0b114e

Please sign in to comment.