2 * Battery driver for iPAQ h3900
4 * Copyright 2005 Phil Blundell
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/module.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/tty.h>
15 #include <linux/sched.h>
16 #include <linux/delay.h>
18 #include <linux/err.h>
19 #include <linux/interrupt.h>
20 #include <linux/platform_device.h>
22 #include <asm/mach-types.h>
23 #include <asm/hardware.h>
25 #include <asm/arch/pxa-regs.h>
27 #include <asm/mach/arch.h>
28 #include <asm/arch/h3900-asic.h>
29 #include <asm/arch/h3900-gpio.h>
31 #include <linux/soc/asic3_base.h>
38 return (GPLR0
& GPIO_H3900_AC_IN_N
) ? 0 : 1;
42 h3900_apm_get_power_status (struct apm_power_info
*info
)
44 info
->ac_line_status
= ac_in
? APM_AC_ONLINE
: APM_AC_OFFLINE
;
48 h3900_ac_in_isr (int irq
, void *dev_id
, struct pt_regs
*regs
)
50 ac_in
= h3900_ac_power ();
56 h3900_battery_init (void)
60 asic3_set_gpio_out_b(&h3900_asic3
.dev
,
61 GPIO3_CH_TIMER
, GPIO3_CH_TIMER
);
63 result
= request_irq (IRQ_GPIO (GPIO_NR_H3900_AC_IN_N
), h3900_ac_in_isr
,
64 SA_INTERRUPT
| SA_SAMPLE_RANDOM
, "AC presence", NULL
);
66 printk (KERN_CRIT
"%s: unable to grab AC in IRQ\n", __FUNCTION__
);
70 apm_get_power_status
= h3900_apm_get_power_status
;
76 h3900_battery_exit (void)
78 free_irq (IRQ_GPIO (GPIO_NR_H3900_AC_IN_N
), NULL
);
79 apm_get_power_status
= NULL
;
82 module_init (h3900_battery_init
)
83 module_exit (h3900_battery_exit
)