diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2006-06-19 14:58:52 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-06-19 14:58:52 -0400 |
commit | f8703dc8cb10eca7f6fe6ef364d8e106fe07f034 (patch) | |
tree | 371f01b78f7fa205128b9ba9127b30904dfdd7b7 | |
parent | 88660351cb6daa85baf9700f12dff3af564dc14a (diff) |
[ARM] 3564/1: sharpsl_pm: Abstract some machine specific parameters
Patch from Richard Purdie
Abstract some machine specific parameters from the sharpsl_pm core
into the machine specific drivers. This allows the core to support
tosa/poodle.
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/common/sharpsl_pm.c | 28 | ||||
-rw-r--r-- | arch/arm/mach-pxa/corgi_pm.c | 23 | ||||
-rw-r--r-- | arch/arm/mach-pxa/sharpsl_pm.c | 7 | ||||
-rw-r--r-- | arch/arm/mach-pxa/spitz_pm.c | 15 | ||||
-rw-r--r-- | include/asm-arm/hardware/sharpsl_pm.h | 11 |
5 files changed, 62 insertions, 22 deletions
diff --git a/arch/arm/common/sharpsl_pm.c b/arch/arm/common/sharpsl_pm.c index 3cd8c9ee4510..045e37e07330 100644 --- a/arch/arm/common/sharpsl_pm.c +++ b/arch/arm/common/sharpsl_pm.c | |||
@@ -49,13 +49,6 @@ | |||
49 | #define SHARPSL_CHARGE_CO_CHECK_TIME 5 /* 5 msec */ | 49 | #define SHARPSL_CHARGE_CO_CHECK_TIME 5 /* 5 msec */ |
50 | #define SHARPSL_CHARGE_RETRY_CNT 1 /* eqv. 10 min */ | 50 | #define SHARPSL_CHARGE_RETRY_CNT 1 /* eqv. 10 min */ |
51 | 51 | ||
52 | #define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */ | ||
53 | #define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */ | ||
54 | #define SHARPSL_CHARGE_ON_ACIN_HIGH 0x9b /* 6V */ | ||
55 | #define SHARPSL_CHARGE_ON_ACIN_LOW 0x34 /* 2V */ | ||
56 | #define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */ | ||
57 | #define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */ | ||
58 | |||
59 | /* | 52 | /* |
60 | * Prototypes | 53 | * Prototypes |
61 | */ | 54 | */ |
@@ -82,12 +75,13 @@ DEFINE_LED_TRIGGER(sharpsl_charge_led_trigger); | |||
82 | static int get_percentage(int voltage) | 75 | static int get_percentage(int voltage) |
83 | { | 76 | { |
84 | int i = sharpsl_pm.machinfo->bat_levels - 1; | 77 | int i = sharpsl_pm.machinfo->bat_levels - 1; |
78 | int bl_status = sharpsl_pm.machinfo->backlight_get_status ? sharpsl_pm.machinfo->backlight_get_status() : 0; | ||
85 | struct battery_thresh *thresh; | 79 | struct battery_thresh *thresh; |
86 | 80 | ||
87 | if (sharpsl_pm.charge_mode == CHRG_ON) | 81 | if (sharpsl_pm.charge_mode == CHRG_ON) |
88 | thresh=sharpsl_pm.machinfo->bat_levels_acin; | 82 | thresh = bl_status ? sharpsl_pm.machinfo->bat_levels_acin_bl : sharpsl_pm.machinfo->bat_levels_acin; |
89 | else | 83 | else |
90 | thresh=sharpsl_pm.machinfo->bat_levels_noac; | 84 | thresh = bl_status ? sharpsl_pm.machinfo->bat_levels_noac_bl : sharpsl_pm.machinfo->bat_levels_noac; |
91 | 85 | ||
92 | while (i > 0 && (voltage > thresh[i].voltage)) | 86 | while (i > 0 && (voltage > thresh[i].voltage)) |
93 | i--; | 87 | i--; |
@@ -131,7 +125,7 @@ static void sharpsl_battery_thread(void *private_) | |||
131 | sharpsl_pm.battstat.ac_status = (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN) ? APM_AC_ONLINE : APM_AC_OFFLINE); | 125 | sharpsl_pm.battstat.ac_status = (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN) ? APM_AC_ONLINE : APM_AC_OFFLINE); |
132 | 126 | ||
133 | /* Corgi cannot confirm when battery fully charged so periodically kick! */ | 127 | /* Corgi cannot confirm when battery fully charged so periodically kick! */ |
134 | if (machine_is_corgi() && (sharpsl_pm.charge_mode == CHRG_ON) | 128 | if (!sharpsl_pm.machinfo->batfull_irq && (sharpsl_pm.charge_mode == CHRG_ON) |
135 | && time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_ON_TIME_INTERVAL)) | 129 | && time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_ON_TIME_INTERVAL)) |
136 | schedule_work(&toggle_charger); | 130 | schedule_work(&toggle_charger); |
137 | 131 | ||
@@ -166,11 +160,11 @@ static void sharpsl_battery_thread(void *private_) | |||
166 | && ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW) || | 160 | && ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW) || |
167 | (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL))) { | 161 | (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL))) { |
168 | if (!(sharpsl_pm.flags & SHARPSL_BL_LIMIT)) { | 162 | if (!(sharpsl_pm.flags & SHARPSL_BL_LIMIT)) { |
169 | corgibl_limit_intensity(1); | 163 | sharpsl_pm.machinfo->backlight_limit(1); |
170 | sharpsl_pm.flags |= SHARPSL_BL_LIMIT; | 164 | sharpsl_pm.flags |= SHARPSL_BL_LIMIT; |
171 | } | 165 | } |
172 | } else if (sharpsl_pm.flags & SHARPSL_BL_LIMIT) { | 166 | } else if (sharpsl_pm.flags & SHARPSL_BL_LIMIT) { |
173 | corgibl_limit_intensity(0); | 167 | sharpsl_pm.machinfo->backlight_limit(0); |
174 | sharpsl_pm.flags &= ~SHARPSL_BL_LIMIT; | 168 | sharpsl_pm.flags &= ~SHARPSL_BL_LIMIT; |
175 | } | 169 | } |
176 | 170 | ||
@@ -418,7 +412,7 @@ static int sharpsl_check_battery_temp(void) | |||
418 | val = get_select_val(buff); | 412 | val = get_select_val(buff); |
419 | 413 | ||
420 | dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val); | 414 | dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val); |
421 | if (val > SHARPSL_CHARGE_ON_TEMP) | 415 | if (val > sharpsl_pm.machinfo->charge_on_temp) |
422 | return -1; | 416 | return -1; |
423 | 417 | ||
424 | return 0; | 418 | return 0; |
@@ -450,7 +444,7 @@ static int sharpsl_check_battery_voltage(void) | |||
450 | val = get_select_val(buff); | 444 | val = get_select_val(buff); |
451 | dev_dbg(sharpsl_pm.dev, "Battery Voltage: %d\n", val); | 445 | dev_dbg(sharpsl_pm.dev, "Battery Voltage: %d\n", val); |
452 | 446 | ||
453 | if (val < SHARPSL_CHARGE_ON_VOLT) | 447 | if (val < sharpsl_pm.machinfo->charge_on_volt) |
454 | return -1; | 448 | return -1; |
455 | 449 | ||
456 | return 0; | 450 | return 0; |
@@ -468,7 +462,7 @@ static int sharpsl_ac_check(void) | |||
468 | temp = get_select_val(buff); | 462 | temp = get_select_val(buff); |
469 | dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp); | 463 | dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp); |
470 | 464 | ||
471 | if ((temp > SHARPSL_CHARGE_ON_ACIN_HIGH) || (temp < SHARPSL_CHARGE_ON_ACIN_LOW)) { | 465 | if ((temp > sharpsl_pm.machinfo->charge_acin_high) || (temp < sharpsl_pm.machinfo->charge_acin_low)) { |
472 | dev_err(sharpsl_pm.dev, "Error: AC check failed.\n"); | 466 | dev_err(sharpsl_pm.dev, "Error: AC check failed.\n"); |
473 | return -1; | 467 | return -1; |
474 | } | 468 | } |
@@ -627,8 +621,8 @@ static int sharpsl_fatal_check(void) | |||
627 | temp = get_select_val(buff); | 621 | temp = get_select_val(buff); |
628 | dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT)); | 622 | dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT)); |
629 | 623 | ||
630 | if ((acin && (temp < SHARPSL_FATAL_ACIN_VOLT)) || | 624 | if ((acin && (temp < sharpsl_pm.machinfo->fatal_acin_volt)) || |
631 | (!acin && (temp < SHARPSL_FATAL_NOACIN_VOLT))) | 625 | (!acin && (temp < sharpsl_pm.machinfo->fatal_noacin_volt))) |
632 | return -1; | 626 | return -1; |
633 | return 0; | 627 | return 0; |
634 | } | 628 | } |
diff --git a/arch/arm/mach-pxa/corgi_pm.c b/arch/arm/mach-pxa/corgi_pm.c index 7a1ab73e9e10..4c3de4008a43 100644 --- a/arch/arm/mach-pxa/corgi_pm.c +++ b/arch/arm/mach-pxa/corgi_pm.c | |||
@@ -27,6 +27,13 @@ | |||
27 | #include <asm/arch/pxa-regs.h> | 27 | #include <asm/arch/pxa-regs.h> |
28 | #include "sharpsl.h" | 28 | #include "sharpsl.h" |
29 | 29 | ||
30 | #define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */ | ||
31 | #define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */ | ||
32 | #define SHARPSL_CHARGE_ON_ACIN_HIGH 0x9b /* 6V */ | ||
33 | #define SHARPSL_CHARGE_ON_ACIN_LOW 0x34 /* 2V */ | ||
34 | #define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */ | ||
35 | #define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */ | ||
36 | |||
30 | static void corgi_charger_init(void) | 37 | static void corgi_charger_init(void) |
31 | { | 38 | { |
32 | pxa_gpio_mode(CORGI_GPIO_ADC_TEMP_ON | GPIO_OUT); | 39 | pxa_gpio_mode(CORGI_GPIO_ADC_TEMP_ON | GPIO_OUT); |
@@ -195,9 +202,16 @@ static struct sharpsl_charger_machinfo corgi_pm_machinfo = { | |||
195 | .read_devdata = corgipm_read_devdata, | 202 | .read_devdata = corgipm_read_devdata, |
196 | .charger_wakeup = corgi_charger_wakeup, | 203 | .charger_wakeup = corgi_charger_wakeup, |
197 | .should_wakeup = corgi_should_wakeup, | 204 | .should_wakeup = corgi_should_wakeup, |
198 | .bat_levels = 40, | 205 | .backlight_limit = corgibl_limit_intensity, |
199 | .bat_levels_noac = spitz_battery_levels_noac, | 206 | .charge_on_volt = SHARPSL_CHARGE_ON_VOLT, |
200 | .bat_levels_acin = spitz_battery_levels_acin, | 207 | .charge_on_temp = SHARPSL_CHARGE_ON_TEMP, |
208 | .charge_acin_high = SHARPSL_CHARGE_ON_ACIN_HIGH, | ||
209 | .charge_acin_low = SHARPSL_CHARGE_ON_ACIN_LOW, | ||
210 | .fatal_acin_volt = SHARPSL_FATAL_ACIN_VOLT, | ||
211 | .fatal_noacin_volt= SHARPSL_FATAL_NOACIN_VOLT, | ||
212 | .bat_levels = 40, | ||
213 | .bat_levels_noac = spitz_battery_levels_noac, | ||
214 | .bat_levels_acin = spitz_battery_levels_acin, | ||
201 | .status_high_acin = 188, | 215 | .status_high_acin = 188, |
202 | .status_low_acin = 178, | 216 | .status_low_acin = 178, |
203 | .status_high_noac = 185, | 217 | .status_high_noac = 185, |
@@ -214,6 +228,9 @@ static int __devinit corgipm_init(void) | |||
214 | if (!corgipm_device) | 228 | if (!corgipm_device) |
215 | return -ENOMEM; | 229 | return -ENOMEM; |
216 | 230 | ||
231 | if (!machine_is_corgi()) | ||
232 | corgi_pm_machinfo.batfull_irq = 1; | ||
233 | |||
217 | corgipm_device->dev.platform_data = &corgi_pm_machinfo; | 234 | corgipm_device->dev.platform_data = &corgi_pm_machinfo; |
218 | ret = platform_device_add(corgipm_device); | 235 | ret = platform_device_add(corgipm_device); |
219 | 236 | ||
diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c index 6d402b262d8a..0f1648780c41 100644 --- a/arch/arm/mach-pxa/sharpsl_pm.c +++ b/arch/arm/mach-pxa/sharpsl_pm.c | |||
@@ -128,6 +128,9 @@ struct battery_thresh spitz_battery_levels_noac[] = { | |||
128 | */ | 128 | */ |
129 | int sharpsl_pm_pxa_read_max1111(int channel) | 129 | int sharpsl_pm_pxa_read_max1111(int channel) |
130 | { | 130 | { |
131 | if (machine_is_tosa()) // Ugly, better move this function into another module | ||
132 | return 0; | ||
133 | |||
131 | return corgi_ssp_max1111_get((channel << MAXCTRL_SEL_SH) | MAXCTRL_PD0 | MAXCTRL_PD1 | 134 | return corgi_ssp_max1111_get((channel << MAXCTRL_SEL_SH) | MAXCTRL_PD0 | MAXCTRL_PD1 |
132 | | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR); | 135 | | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR); |
133 | } | 136 | } |
@@ -156,7 +159,7 @@ void sharpsl_pm_pxa_init(void) | |||
156 | else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal),IRQT_FALLING); | 159 | else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal),IRQT_FALLING); |
157 | } | 160 | } |
158 | 161 | ||
159 | if (!machine_is_corgi()) | 162 | if (sharpsl_pm.machinfo->batfull_irq) |
160 | { | 163 | { |
161 | /* Register interrupt handler. */ | 164 | /* Register interrupt handler. */ |
162 | if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, SA_INTERRUPT, "CO", sharpsl_chrg_full_isr)) { | 165 | if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, SA_INTERRUPT, "CO", sharpsl_chrg_full_isr)) { |
@@ -174,6 +177,6 @@ void sharpsl_pm_pxa_remove(void) | |||
174 | if (sharpsl_pm.machinfo->gpio_fatal) | 177 | if (sharpsl_pm.machinfo->gpio_fatal) |
175 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr); | 178 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr); |
176 | 179 | ||
177 | if (!machine_is_corgi()) | 180 | if (sharpsl_pm.machinfo->batfull_irq) |
178 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr); | 181 | free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr); |
179 | } | 182 | } |
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c index 5e5bdc898482..40be833079c7 100644 --- a/arch/arm/mach-pxa/spitz_pm.c +++ b/arch/arm/mach-pxa/spitz_pm.c | |||
@@ -27,6 +27,13 @@ | |||
27 | #include <asm/arch/pxa-regs.h> | 27 | #include <asm/arch/pxa-regs.h> |
28 | #include "sharpsl.h" | 28 | #include "sharpsl.h" |
29 | 29 | ||
30 | #define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */ | ||
31 | #define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */ | ||
32 | #define SHARPSL_CHARGE_ON_ACIN_HIGH 0x9b /* 6V */ | ||
33 | #define SHARPSL_CHARGE_ON_ACIN_LOW 0x34 /* 2V */ | ||
34 | #define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */ | ||
35 | #define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */ | ||
36 | |||
30 | static int spitz_last_ac_status; | 37 | static int spitz_last_ac_status; |
31 | 38 | ||
32 | static void spitz_charger_init(void) | 39 | static void spitz_charger_init(void) |
@@ -190,6 +197,7 @@ struct sharpsl_charger_machinfo spitz_pm_machinfo = { | |||
190 | .gpio_batlock = SPITZ_GPIO_BAT_COVER, | 197 | .gpio_batlock = SPITZ_GPIO_BAT_COVER, |
191 | .gpio_acin = SPITZ_GPIO_AC_IN, | 198 | .gpio_acin = SPITZ_GPIO_AC_IN, |
192 | .gpio_batfull = SPITZ_GPIO_CHRG_FULL, | 199 | .gpio_batfull = SPITZ_GPIO_CHRG_FULL, |
200 | .batfull_irq = 1, | ||
193 | .gpio_fatal = SPITZ_GPIO_FATAL_BAT, | 201 | .gpio_fatal = SPITZ_GPIO_FATAL_BAT, |
194 | .discharge = spitz_discharge, | 202 | .discharge = spitz_discharge, |
195 | .discharge1 = spitz_discharge1, | 203 | .discharge1 = spitz_discharge1, |
@@ -200,6 +208,13 @@ struct sharpsl_charger_machinfo spitz_pm_machinfo = { | |||
200 | .read_devdata = spitzpm_read_devdata, | 208 | .read_devdata = spitzpm_read_devdata, |
201 | .charger_wakeup = spitz_charger_wakeup, | 209 | .charger_wakeup = spitz_charger_wakeup, |
202 | .should_wakeup = spitz_should_wakeup, | 210 | .should_wakeup = spitz_should_wakeup, |
211 | .backlight_limit = corgibl_limit_intensity, | ||
212 | .charge_on_volt = SHARPSL_CHARGE_ON_VOLT, | ||
213 | .charge_on_temp = SHARPSL_CHARGE_ON_TEMP, | ||
214 | .charge_acin_high = SHARPSL_CHARGE_ON_ACIN_HIGH, | ||
215 | .charge_acin_low = SHARPSL_CHARGE_ON_ACIN_LOW, | ||
216 | .fatal_acin_volt = SHARPSL_FATAL_ACIN_VOLT, | ||
217 | .fatal_noacin_volt= SHARPSL_FATAL_NOACIN_VOLT, | ||
203 | .bat_levels = 40, | 218 | .bat_levels = 40, |
204 | .bat_levels_noac = spitz_battery_levels_noac, | 219 | .bat_levels_noac = spitz_battery_levels_noac, |
205 | .bat_levels_acin = spitz_battery_levels_acin, | 220 | .bat_levels_acin = spitz_battery_levels_acin, |
diff --git a/include/asm-arm/hardware/sharpsl_pm.h b/include/asm-arm/hardware/sharpsl_pm.h index 36983e5f3665..ecf15b83956f 100644 --- a/include/asm-arm/hardware/sharpsl_pm.h +++ b/include/asm-arm/hardware/sharpsl_pm.h | |||
@@ -16,6 +16,7 @@ struct sharpsl_charger_machinfo { | |||
16 | void (*exit)(void); | 16 | void (*exit)(void); |
17 | int gpio_acin; | 17 | int gpio_acin; |
18 | int gpio_batfull; | 18 | int gpio_batfull; |
19 | int batfull_irq; | ||
19 | int gpio_batlock; | 20 | int gpio_batlock; |
20 | int gpio_fatal; | 21 | int gpio_fatal; |
21 | void (*discharge)(int); | 22 | void (*discharge)(int); |
@@ -34,9 +35,19 @@ struct sharpsl_charger_machinfo { | |||
34 | #define SHARPSL_STATUS_FATAL 7 | 35 | #define SHARPSL_STATUS_FATAL 7 |
35 | unsigned long (*charger_wakeup)(void); | 36 | unsigned long (*charger_wakeup)(void); |
36 | int (*should_wakeup)(unsigned int resume_on_alarm); | 37 | int (*should_wakeup)(unsigned int resume_on_alarm); |
38 | void (*backlight_limit)(int); | ||
39 | int (*backlight_get_status) (void); | ||
40 | int charge_on_volt; | ||
41 | int charge_on_temp; | ||
42 | int charge_acin_high; | ||
43 | int charge_acin_low; | ||
44 | int fatal_acin_volt; | ||
45 | int fatal_noacin_volt; | ||
37 | int bat_levels; | 46 | int bat_levels; |
38 | struct battery_thresh *bat_levels_noac; | 47 | struct battery_thresh *bat_levels_noac; |
39 | struct battery_thresh *bat_levels_acin; | 48 | struct battery_thresh *bat_levels_acin; |
49 | struct battery_thresh *bat_levels_noac_bl; | ||
50 | struct battery_thresh *bat_levels_acin_bl; | ||
40 | int status_high_acin; | 51 | int status_high_acin; |
41 | int status_low_acin; | 52 | int status_low_acin; |
42 | int status_high_noac; | 53 | int status_high_noac; |