diff options
-rw-r--r-- | arch/arm/mach-pxa/corgi_pm.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-pxa/include/mach/sharpsl_pm.h | 8 | ||||
-rw-r--r-- | arch/arm/mach-pxa/sharpsl.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-pxa/sharpsl_pm.c | 104 | ||||
-rw-r--r-- | arch/arm/mach-pxa/spitz_pm.c | 3 |
5 files changed, 54 insertions, 66 deletions
diff --git a/arch/arm/mach-pxa/corgi_pm.c b/arch/arm/mach-pxa/corgi_pm.c index 7f04b3a761d1..a093282fe4db 100644 --- a/arch/arm/mach-pxa/corgi_pm.c +++ b/arch/arm/mach-pxa/corgi_pm.c | |||
@@ -41,7 +41,6 @@ static void corgi_charger_init(void) | |||
41 | pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT); | 41 | pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT); |
42 | pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT); | 42 | pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT); |
43 | pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN); | 43 | pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN); |
44 | sharpsl_pm_pxa_init(); | ||
45 | } | 44 | } |
46 | 45 | ||
47 | static void corgi_measure_temp(int on) | 46 | static void corgi_measure_temp(int on) |
@@ -191,7 +190,7 @@ unsigned long corgipm_read_devdata(int type) | |||
191 | 190 | ||
192 | static struct sharpsl_charger_machinfo corgi_pm_machinfo = { | 191 | static struct sharpsl_charger_machinfo corgi_pm_machinfo = { |
193 | .init = corgi_charger_init, | 192 | .init = corgi_charger_init, |
194 | .exit = sharpsl_pm_pxa_remove, | 193 | .exit = NULL, |
195 | .gpio_batlock = CORGI_GPIO_BAT_COVER, | 194 | .gpio_batlock = CORGI_GPIO_BAT_COVER, |
196 | .gpio_acin = CORGI_GPIO_AC_IN, | 195 | .gpio_acin = CORGI_GPIO_AC_IN, |
197 | .gpio_batfull = CORGI_GPIO_CHRG_FULL, | 196 | .gpio_batfull = CORGI_GPIO_CHRG_FULL, |
diff --git a/arch/arm/mach-pxa/include/mach/sharpsl_pm.h b/arch/arm/mach-pxa/include/mach/sharpsl_pm.h index 2d00db22b981..1920dc6b05dc 100644 --- a/arch/arm/mach-pxa/include/mach/sharpsl_pm.h +++ b/arch/arm/mach-pxa/include/mach/sharpsl_pm.h | |||
@@ -8,8 +8,8 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | 11 | #ifndef _MACH_SHARPSL_PM | |
12 | #include <linux/interrupt.h> | 12 | #define _MACH_SHARPSL_PM |
13 | 13 | ||
14 | struct sharpsl_charger_machinfo { | 14 | struct sharpsl_charger_machinfo { |
15 | void (*init)(void); | 15 | void (*init)(void); |
@@ -100,7 +100,5 @@ extern struct sharpsl_pm_status sharpsl_pm; | |||
100 | 100 | ||
101 | void sharpsl_battery_kick(void); | 101 | void sharpsl_battery_kick(void); |
102 | void sharpsl_pm_led(int val); | 102 | void sharpsl_pm_led(int val); |
103 | irqreturn_t sharpsl_ac_isr(int irq, void *dev_id); | ||
104 | irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id); | ||
105 | irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id); | ||
106 | 103 | ||
104 | #endif | ||
diff --git a/arch/arm/mach-pxa/sharpsl.h b/arch/arm/mach-pxa/sharpsl.h index f1cd00ea0322..55259f4756c8 100644 --- a/arch/arm/mach-pxa/sharpsl.h +++ b/arch/arm/mach-pxa/sharpsl.h | |||
@@ -44,8 +44,6 @@ void corgi_lcdtg_hw_init(int mode); | |||
44 | 44 | ||
45 | extern struct battery_thresh spitz_battery_levels_acin[]; | 45 | extern struct battery_thresh spitz_battery_levels_acin[]; |
46 | extern struct battery_thresh spitz_battery_levels_noac[]; | 46 | extern struct battery_thresh spitz_battery_levels_noac[]; |
47 | void sharpsl_pm_pxa_init(void); | ||
48 | void sharpsl_pm_pxa_remove(void); | ||
49 | int sharpsl_pm_pxa_read_max1111(int channel); | 47 | int sharpsl_pm_pxa_read_max1111(int channel); |
50 | 48 | ||
51 | 49 | ||
diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c index 9d61c4916968..540b567278f5 100644 --- a/arch/arm/mach-pxa/sharpsl_pm.c +++ b/arch/arm/mach-pxa/sharpsl_pm.c | |||
@@ -15,19 +15,16 @@ | |||
15 | #undef DEBUG | 15 | #undef DEBUG |
16 | 16 | ||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/init.h> | ||
19 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
20 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
21 | #include <linux/irq.h> | 20 | #include <linux/irq.h> |
22 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
23 | #include <linux/apm-emulation.h> | 22 | #include <linux/apm-emulation.h> |
24 | #include <linux/timer.h> | 23 | #include <linux/timer.h> |
25 | #include <linux/apm_bios.h> | ||
26 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
27 | #include <linux/leds.h> | 25 | #include <linux/leds.h> |
28 | #include <linux/suspend.h> | 26 | #include <linux/suspend.h> |
29 | 27 | ||
30 | #include <mach/hardware.h> | ||
31 | #include <asm/mach-types.h> | 28 | #include <asm/mach-types.h> |
32 | #include <mach/pm.h> | 29 | #include <mach/pm.h> |
33 | #include <mach/pxa2xx-regs.h> | 30 | #include <mach/pxa2xx-regs.h> |
@@ -36,6 +33,8 @@ | |||
36 | #include <mach/sharpsl.h> | 33 | #include <mach/sharpsl.h> |
37 | #include <mach/sharpsl_pm.h> | 34 | #include <mach/sharpsl_pm.h> |
38 | 35 | ||
36 | #include "sharpsl.h" | ||
37 | |||
39 | /* | 38 | /* |
40 | * Constants | 39 | * Constants |
41 | */ | 40 | */ |
@@ -73,8 +72,8 @@ static void sharpsl_battery_thread(struct work_struct *private_); | |||
73 | * Variables | 72 | * Variables |
74 | */ | 73 | */ |
75 | struct sharpsl_pm_status sharpsl_pm; | 74 | struct sharpsl_pm_status sharpsl_pm; |
76 | DECLARE_DELAYED_WORK(toggle_charger, sharpsl_charge_toggle); | 75 | static DECLARE_DELAYED_WORK(toggle_charger, sharpsl_charge_toggle); |
77 | DECLARE_DELAYED_WORK(sharpsl_bat, sharpsl_battery_thread); | 76 | static DECLARE_DELAYED_WORK(sharpsl_bat, sharpsl_battery_thread); |
78 | DEFINE_LED_TRIGGER(sharpsl_charge_led_trigger); | 77 | DEFINE_LED_TRIGGER(sharpsl_charge_led_trigger); |
79 | 78 | ||
80 | 79 | ||
@@ -194,52 +193,6 @@ int sharpsl_pm_pxa_read_max1111(int channel) | |||
194 | #endif | 193 | #endif |
195 | } | 194 | } |
196 | 195 | ||
197 | void sharpsl_pm_pxa_init(void) | ||
198 | { | ||
199 | pxa_gpio_mode(sharpsl_pm.machinfo->gpio_acin | GPIO_IN); | ||
200 | pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batfull | GPIO_IN); | ||
201 | pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batlock | GPIO_IN); | ||
202 | |||
203 | /* Register interrupt handlers */ | ||
204 | if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr, IRQF_DISABLED, "AC Input Detect", sharpsl_ac_isr)) { | ||
205 | dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin)); | ||
206 | } | ||
207 | else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin),IRQ_TYPE_EDGE_BOTH); | ||
208 | |||
209 | if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr, IRQF_DISABLED, "Battery Cover", sharpsl_fatal_isr)) { | ||
210 | dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock)); | ||
211 | } | ||
212 | else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock),IRQ_TYPE_EDGE_FALLING); | ||
213 | |||
214 | if (sharpsl_pm.machinfo->gpio_fatal) { | ||
215 | if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr, IRQF_DISABLED, "Fatal Battery", sharpsl_fatal_isr)) { | ||
216 | dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal)); | ||
217 | } | ||
218 | else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal),IRQ_TYPE_EDGE_FALLING); | ||
219 | } | ||
220 | |||
221 | if (sharpsl_pm.machinfo->batfull_irq) | ||
222 | { | ||
223 | /* Register interrupt handler. */ | ||
224 | if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, IRQF_DISABLED, "CO", sharpsl_chrg_full_isr)) { | ||
225 | dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull)); | ||
226 | } | ||
227 | else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQ_TYPE_EDGE_RISING); | ||
228 | } | ||
229 | } | ||
230 | |||
231 | void sharpsl_pm_pxa_remove(void) | ||
232 | { | ||
233 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr); | ||
234 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr); | ||
235 | |||
236 | if (sharpsl_pm.machinfo->gpio_fatal) | ||
237 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr); | ||
238 | |||
239 | if (sharpsl_pm.machinfo->batfull_irq) | ||
240 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr); | ||
241 | } | ||
242 | |||
243 | static int get_percentage(int voltage) | 196 | static int get_percentage(int voltage) |
244 | { | 197 | { |
245 | int i = sharpsl_pm.machinfo->bat_levels - 1; | 198 | int i = sharpsl_pm.machinfo->bat_levels - 1; |
@@ -427,7 +380,7 @@ static void sharpsl_ac_timer(unsigned long data) | |||
427 | } | 380 | } |
428 | 381 | ||
429 | 382 | ||
430 | irqreturn_t sharpsl_ac_isr(int irq, void *dev_id) | 383 | static irqreturn_t sharpsl_ac_isr(int irq, void *dev_id) |
431 | { | 384 | { |
432 | /* Delay the event slightly to debounce */ | 385 | /* Delay the event slightly to debounce */ |
433 | /* Must be a smaller delay than the chrg_full_isr below */ | 386 | /* Must be a smaller delay than the chrg_full_isr below */ |
@@ -462,7 +415,7 @@ static void sharpsl_chrg_full_timer(unsigned long data) | |||
462 | /* Charging Finished Interrupt (Not present on Corgi) */ | 415 | /* Charging Finished Interrupt (Not present on Corgi) */ |
463 | /* Can trigger at the same time as an AC status change so | 416 | /* Can trigger at the same time as an AC status change so |
464 | delay until after that has been processed */ | 417 | delay until after that has been processed */ |
465 | irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id) | 418 | static irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id) |
466 | { | 419 | { |
467 | if (sharpsl_pm.flags & SHARPSL_SUSPENDED) | 420 | if (sharpsl_pm.flags & SHARPSL_SUSPENDED) |
468 | return IRQ_HANDLED; | 421 | return IRQ_HANDLED; |
@@ -473,7 +426,7 @@ irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id) | |||
473 | return IRQ_HANDLED; | 426 | return IRQ_HANDLED; |
474 | } | 427 | } |
475 | 428 | ||
476 | irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id) | 429 | static irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id) |
477 | { | 430 | { |
478 | int is_fatal = 0; | 431 | int is_fatal = 0; |
479 | 432 | ||
@@ -966,6 +919,37 @@ static int __init sharpsl_pm_probe(struct platform_device *pdev) | |||
966 | 919 | ||
967 | sharpsl_pm.machinfo->init(); | 920 | sharpsl_pm.machinfo->init(); |
968 | 921 | ||
922 | pxa_gpio_mode(sharpsl_pm.machinfo->gpio_acin | GPIO_IN); | ||
923 | pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batfull | GPIO_IN); | ||
924 | pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batlock | GPIO_IN); | ||
925 | |||
926 | /* Register interrupt handlers */ | ||
927 | if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr, IRQF_DISABLED, "AC Input Detect", sharpsl_ac_isr)) { | ||
928 | dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin)); | ||
929 | } | ||
930 | else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin),IRQ_TYPE_EDGE_BOTH); | ||
931 | |||
932 | if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr, IRQF_DISABLED, "Battery Cover", sharpsl_fatal_isr)) { | ||
933 | dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock)); | ||
934 | } | ||
935 | else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock),IRQ_TYPE_EDGE_FALLING); | ||
936 | |||
937 | if (sharpsl_pm.machinfo->gpio_fatal) { | ||
938 | if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr, IRQF_DISABLED, "Fatal Battery", sharpsl_fatal_isr)) { | ||
939 | dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal)); | ||
940 | } | ||
941 | else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal),IRQ_TYPE_EDGE_FALLING); | ||
942 | } | ||
943 | |||
944 | if (sharpsl_pm.machinfo->batfull_irq) | ||
945 | { | ||
946 | /* Register interrupt handler. */ | ||
947 | if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, IRQF_DISABLED, "CO", sharpsl_chrg_full_isr)) { | ||
948 | dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull)); | ||
949 | } | ||
950 | else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQ_TYPE_EDGE_RISING); | ||
951 | } | ||
952 | |||
969 | ret = device_create_file(&pdev->dev, &dev_attr_battery_percentage); | 953 | ret = device_create_file(&pdev->dev, &dev_attr_battery_percentage); |
970 | ret |= device_create_file(&pdev->dev, &dev_attr_battery_voltage); | 954 | ret |= device_create_file(&pdev->dev, &dev_attr_battery_voltage); |
971 | if (ret != 0) | 955 | if (ret != 0) |
@@ -991,7 +975,17 @@ static int sharpsl_pm_remove(struct platform_device *pdev) | |||
991 | 975 | ||
992 | led_trigger_unregister_simple(sharpsl_charge_led_trigger); | 976 | led_trigger_unregister_simple(sharpsl_charge_led_trigger); |
993 | 977 | ||
994 | sharpsl_pm.machinfo->exit(); | 978 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr); |
979 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr); | ||
980 | |||
981 | if (sharpsl_pm.machinfo->gpio_fatal) | ||
982 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr); | ||
983 | |||
984 | if (sharpsl_pm.machinfo->batfull_irq) | ||
985 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr); | ||
986 | |||
987 | if (sharpsl_pm.machinfo->exit) | ||
988 | sharpsl_pm.machinfo->exit(); | ||
995 | 989 | ||
996 | del_timer_sync(&sharpsl_pm.chrg_full_timer); | 990 | del_timer_sync(&sharpsl_pm.chrg_full_timer); |
997 | del_timer_sync(&sharpsl_pm.ac_timer); | 991 | del_timer_sync(&sharpsl_pm.ac_timer); |
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c index 2e4490562c9e..724ffb030317 100644 --- a/arch/arm/mach-pxa/spitz_pm.c +++ b/arch/arm/mach-pxa/spitz_pm.c | |||
@@ -41,7 +41,6 @@ static void spitz_charger_init(void) | |||
41 | { | 41 | { |
42 | pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN); | 42 | pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN); |
43 | pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN); | 43 | pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN); |
44 | sharpsl_pm_pxa_init(); | ||
45 | } | 44 | } |
46 | 45 | ||
47 | static void spitz_measure_temp(int on) | 46 | static void spitz_measure_temp(int on) |
@@ -182,7 +181,7 @@ unsigned long spitzpm_read_devdata(int type) | |||
182 | 181 | ||
183 | struct sharpsl_charger_machinfo spitz_pm_machinfo = { | 182 | struct sharpsl_charger_machinfo spitz_pm_machinfo = { |
184 | .init = spitz_charger_init, | 183 | .init = spitz_charger_init, |
185 | .exit = sharpsl_pm_pxa_remove, | 184 | .exit = NULL, |
186 | .gpio_batlock = SPITZ_GPIO_BAT_COVER, | 185 | .gpio_batlock = SPITZ_GPIO_BAT_COVER, |
187 | .gpio_acin = SPITZ_GPIO_AC_IN, | 186 | .gpio_acin = SPITZ_GPIO_AC_IN, |
188 | .gpio_batfull = SPITZ_GPIO_CHRG_FULL, | 187 | .gpio_batfull = SPITZ_GPIO_CHRG_FULL, |