77 * modify it under the terms of the GNU General Public License.
88 */
99#include <linux/module.h>
10- #include <linux/apm_bios.h>
1110#include <linux/kernel.h>
1211#include <linux/init.h>
1312#include <linux/interrupt.h>
14- #include <asm/io .h>
15- #include <asm/apm .h>
13+ #include <linux/apm-emulation .h>
14+ #include <linux/io .h>
1615#include <asm/adc.h>
1716#include <asm/hp6xx.h>
1817
2726
2827#define MODNAME "hp6x0_apm"
2928
30- static int hp6x0_apm_get_info ( char * buf , char * * start , off_t fpos , int length )
29+ static void hp6x0_apm_get_power_status ( struct apm_power_info * info )
3130{
31+ int battery , backup , charging , percentage ;
3232 u8 pgdr ;
33- char * p ;
34- int battery_status ;
35- int battery_flag ;
36- int ac_line_status ;
37- int time_units = APM_BATTERY_LIFE_UNKNOWN ;
3833
39- int battery = adc_single (ADC_CHANNEL_BATTERY );
40- int backup = adc_single (ADC_CHANNEL_BACKUP );
41- int charging = adc_single (ADC_CHANNEL_CHARGE );
42- int percentage ;
34+ battery = adc_single (ADC_CHANNEL_BATTERY );
35+ backup = adc_single (ADC_CHANNEL_BACKUP );
36+ charging = adc_single (ADC_CHANNEL_CHARGE );
4337
4438 percentage = 100 * (battery - HP680_BATTERY_MIN ) /
4539 (HP680_BATTERY_MAX - HP680_BATTERY_MIN );
4640
47- ac_line_status = (battery > HP680_BATTERY_AC_ON ) ?
41+ info -> ac_line_status = (battery > HP680_BATTERY_AC_ON ) ?
4842 APM_AC_ONLINE : APM_AC_OFFLINE ;
4943
50- p = buf ;
51-
5244 pgdr = ctrl_inb (SH7709_PGDR );
5345 if (pgdr & PGDR_MAIN_BATTERY_OUT ) {
54- battery_status = APM_BATTERY_STATUS_NOT_PRESENT ;
55- battery_flag = 0x80 ;
56- percentage = -1 ;
57- } else if (charging < 8 ) {
58- battery_status = APM_BATTERY_STATUS_CHARGING ;
59- battery_flag = 0x08 ;
60- ac_line_status = 0xff ;
46+ info -> battery_status = APM_BATTERY_STATUS_NOT_PRESENT ;
47+ info -> battery_flag = 0x80 ;
48+ } else if (charging < 8 ) {
49+ info -> battery_status = APM_BATTERY_STATUS_CHARGING ;
50+ info -> battery_flag = 0x08 ;
51+ info -> ac_line_status = 0xff ;
6152 } else if (percentage <= APM_CRITICAL ) {
62- battery_status = APM_BATTERY_STATUS_CRITICAL ;
63- battery_flag = 0x04 ;
53+ info -> battery_status = APM_BATTERY_STATUS_CRITICAL ;
54+ info -> battery_flag = 0x04 ;
6455 } else if (percentage <= APM_LOW ) {
65- battery_status = APM_BATTERY_STATUS_LOW ;
66- battery_flag = 0x02 ;
56+ info -> battery_status = APM_BATTERY_STATUS_LOW ;
57+ info -> battery_flag = 0x02 ;
6758 } else {
68- battery_status = APM_BATTERY_STATUS_HIGH ;
69- battery_flag = 0x01 ;
59+ info -> battery_status = APM_BATTERY_STATUS_HIGH ;
60+ info -> battery_flag = 0x01 ;
7061 }
7162
72- p += sprintf (p , "1.0 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n" ,
73- APM_32_BIT_SUPPORT ,
74- ac_line_status ,
75- battery_status ,
76- battery_flag ,
77- percentage ,
78- time_units ,
79- "min" );
80- p += sprintf (p , "bat=%d backup=%d charge=%d\n" ,
81- battery , backup , charging );
82-
83- return p - buf ;
63+ info -> units = 0 ;
8464}
8565
8666static irqreturn_t hp6x0_apm_interrupt (int irq , void * dev )
@@ -96,22 +76,22 @@ static int __init hp6x0_apm_init(void)
9676 int ret ;
9777
9878 ret = request_irq (HP680_BTN_IRQ , hp6x0_apm_interrupt ,
99- IRQF_DISABLED , MODNAME , 0 );
79+ IRQF_DISABLED , MODNAME , NULL );
10080 if (unlikely (ret < 0 )) {
10181 printk (KERN_ERR MODNAME ": IRQ %d request failed\n" ,
10282 HP680_BTN_IRQ );
10383 return ret ;
10484 }
10585
106- apm_get_info = hp6x0_apm_get_info ;
86+ apm_get_power_status = hp6x0_apm_get_power_status ;
10787
10888 return ret ;
10989}
11090
11191static void __exit hp6x0_apm_exit (void )
11292{
11393 free_irq (HP680_BTN_IRQ , 0 );
114- apm_get_info = 0 ;
94+ apm_get_info = NULL ;
11595}
11696
11797module_init (hp6x0_apm_init );
0 commit comments