aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/spitz_pm.c
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2006-01-05 15:44:55 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-01-05 15:44:55 -0500
commitb7557de41a04346cb545d4dda7088760cb96e713 (patch)
treedf9acef34fdf1460858ed39b35d447f6bfdc95d1 /arch/arm/mach-pxa/spitz_pm.c
parent3125c68d70e3433c21234431a9df9e7336efa29f (diff)
[ARM] 3228/1: SharpSL: Move PM code to arch/arm/common
Patch from Richard Purdie This patch moves a large chunk of the sharpsl_pm driver to arch/arm/common so that it can be reused on other devices such as the SL-5500 (collie). It also abstracts some functions from the core into the machine and platform specific parts of the driver to aid reuse. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-pxa/spitz_pm.c')
-rw-r--r--arch/arm/mach-pxa/spitz_pm.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c
index 3ce7486daa51..76a5c26dea0b 100644
--- a/arch/arm/mach-pxa/spitz_pm.c
+++ b/arch/arm/mach-pxa/spitz_pm.c
@@ -21,6 +21,7 @@
21#include <asm/mach-types.h> 21#include <asm/mach-types.h>
22#include <asm/hardware.h> 22#include <asm/hardware.h>
23#include <asm/hardware/scoop.h> 23#include <asm/hardware/scoop.h>
24#include <asm/hardware/sharpsl_pm.h>
24 25
25#include <asm/arch/sharpsl.h> 26#include <asm/arch/sharpsl.h>
26#include <asm/arch/spitz.h> 27#include <asm/arch/spitz.h>
@@ -33,19 +34,7 @@ static void spitz_charger_init(void)
33{ 34{
34 pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN); 35 pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN);
35 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN); 36 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN);
36} 37 sharpsl_pm_pxa_init();
37
38static void spitz_charge_led(int val)
39{
40 if (val == SHARPSL_LED_ERROR) {
41 dev_dbg(sharpsl_pm.dev, "Charge LED Error\n");
42 } else if (val == SHARPSL_LED_ON) {
43 dev_dbg(sharpsl_pm.dev, "Charge LED On\n");
44 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE);
45 } else {
46 dev_dbg(sharpsl_pm.dev, "Charge LED Off\n");
47 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE);
48 }
49} 38}
50 39
51static void spitz_measure_temp(int on) 40static void spitz_measure_temp(int on)
@@ -92,7 +81,7 @@ static void spitz_discharge1(int on)
92 81
93static void spitz_presuspend(void) 82static void spitz_presuspend(void)
94{ 83{
95 spitz_last_ac_status = STATUS_AC_IN(); 84 spitz_last_ac_status = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
96 85
97 /* GPIO Sleep Register */ 86 /* GPIO Sleep Register */
98 PGSR0 = 0x00144018; 87 PGSR0 = 0x00144018;
@@ -138,7 +127,7 @@ static void spitz_postsuspend(void)
138static int spitz_should_wakeup(unsigned int resume_on_alarm) 127static int spitz_should_wakeup(unsigned int resume_on_alarm)
139{ 128{
140 int is_resume = 0; 129 int is_resume = 0;
141 int acin = STATUS_AC_IN(); 130 int acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
142 131
143 if (spitz_last_ac_status != acin) { 132 if (spitz_last_ac_status != acin) {
144 if (acin) { 133 if (acin) {
@@ -148,8 +137,8 @@ static int spitz_should_wakeup(unsigned int resume_on_alarm)
148 } else { 137 } else {
149 /* charge off */ 138 /* charge off */
150 dev_dbg(sharpsl_pm.dev, "AC Removed\n"); 139 dev_dbg(sharpsl_pm.dev, "AC Removed\n");
151 CHARGE_LED_OFF(); 140 sharpsl_pm_led(SHARPSL_LED_OFF);
152 CHARGE_OFF(); 141 sharpsl_pm.machinfo->charge(0);
153 sharpsl_pm.charge_mode = CHRG_OFF; 142 sharpsl_pm.charge_mode = CHRG_OFF;
154 } 143 }
155 spitz_last_ac_status = acin; 144 spitz_last_ac_status = acin;
@@ -175,25 +164,41 @@ static unsigned long spitz_charger_wakeup(void)
175 return (~GPLR0 & GPIO_bit(SPITZ_GPIO_KEY_INT)) | (GPLR0 & GPIO_bit(SPITZ_GPIO_SYNC)); 164 return (~GPLR0 & GPIO_bit(SPITZ_GPIO_KEY_INT)) | (GPLR0 & GPIO_bit(SPITZ_GPIO_SYNC));
176} 165}
177 166
178static int spitz_acin_status(void) 167unsigned long spitzpm_read_devdata(int type)
179{ 168{
180 return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0); 169 switch(type) {
170 case SHARPSL_STATUS_ACIN:
171 return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0);
172 case SHARPSL_STATUS_LOCK:
173 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock);
174 case SHARPSL_STATUS_CHRGFULL:
175 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull);
176 case SHARPSL_STATUS_FATAL:
177 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal);
178 case SHARPSL_ACIN_VOLT:
179 return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT);
180 case SHARPSL_BATT_TEMP:
181 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP);
182 case SHARPSL_BATT_VOLT:
183 default:
184 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT);
185 }
181} 186}
182 187
183struct sharpsl_charger_machinfo spitz_pm_machinfo = { 188struct sharpsl_charger_machinfo spitz_pm_machinfo = {
184 .init = spitz_charger_init, 189 .init = spitz_charger_init,
190 .exit = sharpsl_pm_pxa_remove,
185 .gpio_batlock = SPITZ_GPIO_BAT_COVER, 191 .gpio_batlock = SPITZ_GPIO_BAT_COVER,
186 .gpio_acin = SPITZ_GPIO_AC_IN, 192 .gpio_acin = SPITZ_GPIO_AC_IN,
187 .gpio_batfull = SPITZ_GPIO_CHRG_FULL, 193 .gpio_batfull = SPITZ_GPIO_CHRG_FULL,
188 .gpio_fatal = SPITZ_GPIO_FATAL_BAT, 194 .gpio_fatal = SPITZ_GPIO_FATAL_BAT,
189 .status_acin = spitz_acin_status,
190 .discharge = spitz_discharge, 195 .discharge = spitz_discharge,
191 .discharge1 = spitz_discharge1, 196 .discharge1 = spitz_discharge1,
192 .charge = spitz_charge, 197 .charge = spitz_charge,
193 .chargeled = spitz_charge_led,
194 .measure_temp = spitz_measure_temp, 198 .measure_temp = spitz_measure_temp,
195 .presuspend = spitz_presuspend, 199 .presuspend = spitz_presuspend,
196 .postsuspend = spitz_postsuspend, 200 .postsuspend = spitz_postsuspend,
201 .read_devdata = spitzpm_read_devdata,
197 .charger_wakeup = spitz_charger_wakeup, 202 .charger_wakeup = spitz_charger_wakeup,
198 .should_wakeup = spitz_should_wakeup, 203 .should_wakeup = spitz_should_wakeup,
199 .bat_levels = 40, 204 .bat_levels = 40,