diff options
author | Richard Purdie <rpurdie@rpsys.net> | 2006-01-05 15:44:55 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2006-01-05 15:44:55 -0500 |
commit | b7557de41a04346cb545d4dda7088760cb96e713 (patch) | |
tree | df9acef34fdf1460858ed39b35d447f6bfdc95d1 /arch/arm/mach-pxa/corgi_pm.c | |
parent | 3125c68d70e3433c21234431a9df9e7336efa29f (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/corgi_pm.c')
-rw-r--r-- | arch/arm/mach-pxa/corgi_pm.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/arch/arm/mach-pxa/corgi_pm.c b/arch/arm/mach-pxa/corgi_pm.c index 599be14754f9..de8b2403c929 100644 --- a/arch/arm/mach-pxa/corgi_pm.c +++ b/arch/arm/mach-pxa/corgi_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/corgi.h> | 27 | #include <asm/arch/corgi.h> |
@@ -33,19 +34,7 @@ static void corgi_charger_init(void) | |||
33 | pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT); | 34 | pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT); |
34 | pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT); | 35 | pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT); |
35 | pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN); | 36 | pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN); |
36 | } | 37 | sharpsl_pm_pxa_init(); |
37 | |||
38 | static void corgi_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 | GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE); | ||
45 | } else { | ||
46 | dev_dbg(sharpsl_pm.dev, "Charge LED Off\n"); | ||
47 | GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE); | ||
48 | } | ||
49 | } | 38 | } |
50 | 39 | ||
51 | static void corgi_measure_temp(int on) | 40 | static void corgi_measure_temp(int on) |
@@ -138,15 +127,15 @@ static int corgi_should_wakeup(unsigned int resume_on_alarm) | |||
138 | dev_dbg(sharpsl_pm.dev, "GPLR0 = %x,%x\n", GPLR0, PEDR); | 127 | dev_dbg(sharpsl_pm.dev, "GPLR0 = %x,%x\n", GPLR0, PEDR); |
139 | 128 | ||
140 | if ((PEDR & GPIO_bit(CORGI_GPIO_AC_IN))) { | 129 | if ((PEDR & GPIO_bit(CORGI_GPIO_AC_IN))) { |
141 | if (STATUS_AC_IN()) { | 130 | if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) { |
142 | /* charge on */ | 131 | /* charge on */ |
143 | dev_dbg(sharpsl_pm.dev, "ac insert\n"); | 132 | dev_dbg(sharpsl_pm.dev, "ac insert\n"); |
144 | sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG; | 133 | sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG; |
145 | } else { | 134 | } else { |
146 | /* charge off */ | 135 | /* charge off */ |
147 | dev_dbg(sharpsl_pm.dev, "ac remove\n"); | 136 | dev_dbg(sharpsl_pm.dev, "ac remove\n"); |
148 | CHARGE_LED_OFF(); | 137 | sharpsl_pm_led(SHARPSL_LED_OFF); |
149 | CHARGE_OFF(); | 138 | sharpsl_pm.machinfo->charge(0); |
150 | sharpsl_pm.charge_mode = CHRG_OFF; | 139 | sharpsl_pm.charge_mode = CHRG_OFF; |
151 | } | 140 | } |
152 | } | 141 | } |
@@ -172,23 +161,39 @@ static unsigned long corgi_charger_wakeup(void) | |||
172 | return ~GPLR0 & ( GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) ); | 161 | return ~GPLR0 & ( GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) ); |
173 | } | 162 | } |
174 | 163 | ||
175 | static int corgi_acin_status(void) | 164 | unsigned long corgipm_read_devdata(int type) |
176 | { | 165 | { |
177 | return ((GPLR(CORGI_GPIO_AC_IN) & GPIO_bit(CORGI_GPIO_AC_IN)) != 0); | 166 | switch(type) { |
167 | case SHARPSL_STATUS_ACIN: | ||
168 | return ((GPLR(CORGI_GPIO_AC_IN) & GPIO_bit(CORGI_GPIO_AC_IN)) != 0); | ||
169 | case SHARPSL_STATUS_LOCK: | ||
170 | return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock); | ||
171 | case SHARPSL_STATUS_CHRGFULL: | ||
172 | return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull); | ||
173 | case SHARPSL_STATUS_FATAL: | ||
174 | return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal); | ||
175 | case SHARPSL_ACIN_VOLT: | ||
176 | return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT); | ||
177 | case SHARPSL_BATT_TEMP: | ||
178 | return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP); | ||
179 | case SHARPSL_BATT_VOLT: | ||
180 | default: | ||
181 | return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT); | ||
182 | } | ||
178 | } | 183 | } |
179 | 184 | ||
180 | static struct sharpsl_charger_machinfo corgi_pm_machinfo = { | 185 | static struct sharpsl_charger_machinfo corgi_pm_machinfo = { |
181 | .init = corgi_charger_init, | 186 | .init = corgi_charger_init, |
187 | .exit = sharpsl_pm_pxa_remove, | ||
182 | .gpio_batlock = CORGI_GPIO_BAT_COVER, | 188 | .gpio_batlock = CORGI_GPIO_BAT_COVER, |
183 | .gpio_acin = CORGI_GPIO_AC_IN, | 189 | .gpio_acin = CORGI_GPIO_AC_IN, |
184 | .gpio_batfull = CORGI_GPIO_CHRG_FULL, | 190 | .gpio_batfull = CORGI_GPIO_CHRG_FULL, |
185 | .status_acin = corgi_acin_status, | ||
186 | .discharge = corgi_discharge, | 191 | .discharge = corgi_discharge, |
187 | .charge = corgi_charge, | 192 | .charge = corgi_charge, |
188 | .chargeled = corgi_charge_led, | ||
189 | .measure_temp = corgi_measure_temp, | 193 | .measure_temp = corgi_measure_temp, |
190 | .presuspend = corgi_presuspend, | 194 | .presuspend = corgi_presuspend, |
191 | .postsuspend = corgi_postsuspend, | 195 | .postsuspend = corgi_postsuspend, |
196 | .read_devdata = corgipm_read_devdata, | ||
192 | .charger_wakeup = corgi_charger_wakeup, | 197 | .charger_wakeup = corgi_charger_wakeup, |
193 | .should_wakeup = corgi_should_wakeup, | 198 | .should_wakeup = corgi_should_wakeup, |
194 | .bat_levels = 40, | 199 | .bat_levels = 40, |