Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 47304
b: refs/heads/master
c: 0a9b0db
h: refs/heads/master
v: v3
  • Loading branch information
Paul Mundt authored and Ralf Baechle committed Feb 9, 2007
1 parent 553ff69 commit 7fed17b
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 633 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: 2116245ee121af820225834e9695005ab07d1e84
refs/heads/master: 0a9b0db19262dbb09f3a34195e68cafd5dc3fa10
7 changes: 4 additions & 3 deletions trunk/arch/sh/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ config GENERIC_IOMAP
config GENERIC_TIME
def_bool n

config SYS_SUPPORTS_APM_EMULATION
bool

config ARCH_MAY_HAVE_PC_FDC
bool

Expand Down Expand Up @@ -126,6 +129,7 @@ config SH_7751_SYSTEMH

config SH_HP6XX
bool "HP6XX"
select SYS_SUPPORTS_APM_EMULATION
help
Select HP6XX if configuring for a HP jornada HP6xx.
More information (hardware only) at
Expand Down Expand Up @@ -694,9 +698,6 @@ depends on EXPERIMENTAL

source kernel/power/Kconfig

config APM
bool "Advanced Power Management Emulation"
depends on PM
endmenu

source "net/Kconfig"
Expand Down
68 changes: 24 additions & 44 deletions trunk/arch/sh/boards/hp6xx/hp6xx_apm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
* modify it under the terms of the GNU General Public License.
*/
#include <linux/module.h>
#include <linux/apm_bios.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#include <asm/apm.h>
#include <linux/apm-emulation.h>
#include <linux/io.h>
#include <asm/adc.h>
#include <asm/hp6xx.h>

Expand All @@ -27,60 +26,41 @@

#define MODNAME "hp6x0_apm"

static int hp6x0_apm_get_info(char *buf, char **start, off_t fpos, int length)
static void hp6x0_apm_get_power_status(struct apm_power_info *info)
{
int battery, backup, charging, percentage;
u8 pgdr;
char *p;
int battery_status;
int battery_flag;
int ac_line_status;
int time_units = APM_BATTERY_LIFE_UNKNOWN;

int battery = adc_single(ADC_CHANNEL_BATTERY);
int backup = adc_single(ADC_CHANNEL_BACKUP);
int charging = adc_single(ADC_CHANNEL_CHARGE);
int percentage;
battery = adc_single(ADC_CHANNEL_BATTERY);
backup = adc_single(ADC_CHANNEL_BACKUP);
charging = adc_single(ADC_CHANNEL_CHARGE);

percentage = 100 * (battery - HP680_BATTERY_MIN) /
(HP680_BATTERY_MAX - HP680_BATTERY_MIN);

ac_line_status = (battery > HP680_BATTERY_AC_ON) ?
info->ac_line_status = (battery > HP680_BATTERY_AC_ON) ?
APM_AC_ONLINE : APM_AC_OFFLINE;

p = buf;

pgdr = ctrl_inb(SH7709_PGDR);
if (pgdr & PGDR_MAIN_BATTERY_OUT) {
battery_status = APM_BATTERY_STATUS_NOT_PRESENT;
battery_flag = 0x80;
percentage = -1;
} else if (charging < 8 ) {
battery_status = APM_BATTERY_STATUS_CHARGING;
battery_flag = 0x08;
ac_line_status = 0xff;
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;
} else if (percentage <= APM_CRITICAL) {
battery_status = APM_BATTERY_STATUS_CRITICAL;
battery_flag = 0x04;
info->battery_status = APM_BATTERY_STATUS_CRITICAL;
info->battery_flag = 0x04;
} else if (percentage <= APM_LOW) {
battery_status = APM_BATTERY_STATUS_LOW;
battery_flag = 0x02;
info->battery_status = APM_BATTERY_STATUS_LOW;
info->battery_flag = 0x02;
} else {
battery_status = APM_BATTERY_STATUS_HIGH;
battery_flag = 0x01;
info->battery_status = APM_BATTERY_STATUS_HIGH;
info->battery_flag = 0x01;
}

p += sprintf(p, "1.0 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
APM_32_BIT_SUPPORT,
ac_line_status,
battery_status,
battery_flag,
percentage,
time_units,
"min");
p += sprintf(p, "bat=%d backup=%d charge=%d\n",
battery, backup, charging);

return p - buf;
info->units = 0;
}

static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev)
Expand All @@ -96,22 +76,22 @@ static int __init hp6x0_apm_init(void)
int ret;

ret = request_irq(HP680_BTN_IRQ, hp6x0_apm_interrupt,
IRQF_DISABLED, MODNAME, 0);
IRQF_DISABLED, MODNAME, NULL);
if (unlikely(ret < 0)) {
printk(KERN_ERR MODNAME ": IRQ %d request failed\n",
HP680_BTN_IRQ);
return ret;
}

apm_get_info = hp6x0_apm_get_info;
apm_get_power_status = hp6x0_apm_get_power_status;

return ret;
}

static void __exit hp6x0_apm_exit(void)
{
free_irq(HP680_BTN_IRQ, 0);
apm_get_info = 0;
apm_get_info = NULL;
}

module_init(hp6x0_apm_init);
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/sh/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ obj-$(CONFIG_SH_CPU_FREQ) += cpufreq.o
obj-$(CONFIG_MODULES) += module.o
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
obj-$(CONFIG_APM) += apm.o
obj-$(CONFIG_PM) += pm.o
obj-$(CONFIG_STACKTRACE) += stacktrace.o
Loading

0 comments on commit 7fed17b

Please sign in to comment.