aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/spitz_pm.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-01-07 13:45:22 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-07 13:45:22 -0500
commit8995b161eb142b843094dd614b80e4cce1d66352 (patch)
treeffd9988879441d5ec45ab96b2e06f4fcb1210158 /arch/arm/mach-pxa/spitz_pm.c
parentcc918c7ab7da017bfaf9661420bb5c462e057cfb (diff)
parentfe5dd7c73d328b255286b6b65ca19dd34447f709 (diff)
Merge master.kernel.org:/home/rmk/linux-2.6-arm
Diffstat (limited to 'arch/arm/mach-pxa/spitz_pm.c')
-rw-r--r--arch/arm/mach-pxa/spitz_pm.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c
index 3ce7486daa51..5e5bdc898482 100644
--- a/arch/arm/mach-pxa/spitz_pm.c
+++ b/arch/arm/mach-pxa/spitz_pm.c
@@ -33,19 +33,7 @@ static void spitz_charger_init(void)
33{ 33{
34 pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN); 34 pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN);
35 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN); 35 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN);
36} 36 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} 37}
50 38
51static void spitz_measure_temp(int on) 39static void spitz_measure_temp(int on)
@@ -92,7 +80,7 @@ static void spitz_discharge1(int on)
92 80
93static void spitz_presuspend(void) 81static void spitz_presuspend(void)
94{ 82{
95 spitz_last_ac_status = STATUS_AC_IN(); 83 spitz_last_ac_status = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
96 84
97 /* GPIO Sleep Register */ 85 /* GPIO Sleep Register */
98 PGSR0 = 0x00144018; 86 PGSR0 = 0x00144018;
@@ -138,7 +126,7 @@ static void spitz_postsuspend(void)
138static int spitz_should_wakeup(unsigned int resume_on_alarm) 126static int spitz_should_wakeup(unsigned int resume_on_alarm)
139{ 127{
140 int is_resume = 0; 128 int is_resume = 0;
141 int acin = STATUS_AC_IN(); 129 int acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
142 130
143 if (spitz_last_ac_status != acin) { 131 if (spitz_last_ac_status != acin) {
144 if (acin) { 132 if (acin) {
@@ -148,8 +136,8 @@ static int spitz_should_wakeup(unsigned int resume_on_alarm)
148 } else { 136 } else {
149 /* charge off */ 137 /* charge off */
150 dev_dbg(sharpsl_pm.dev, "AC Removed\n"); 138 dev_dbg(sharpsl_pm.dev, "AC Removed\n");
151 CHARGE_LED_OFF(); 139 sharpsl_pm_led(SHARPSL_LED_OFF);
152 CHARGE_OFF(); 140 sharpsl_pm.machinfo->charge(0);
153 sharpsl_pm.charge_mode = CHRG_OFF; 141 sharpsl_pm.charge_mode = CHRG_OFF;
154 } 142 }
155 spitz_last_ac_status = acin; 143 spitz_last_ac_status = acin;
@@ -175,25 +163,41 @@ static unsigned long spitz_charger_wakeup(void)
175 return (~GPLR0 & GPIO_bit(SPITZ_GPIO_KEY_INT)) | (GPLR0 & GPIO_bit(SPITZ_GPIO_SYNC)); 163 return (~GPLR0 & GPIO_bit(SPITZ_GPIO_KEY_INT)) | (GPLR0 & GPIO_bit(SPITZ_GPIO_SYNC));
176} 164}
177 165
178static int spitz_acin_status(void) 166unsigned long spitzpm_read_devdata(int type)
179{ 167{
180 return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0); 168 switch(type) {
169 case SHARPSL_STATUS_ACIN:
170 return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0);
171 case SHARPSL_STATUS_LOCK:
172 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock);
173 case SHARPSL_STATUS_CHRGFULL:
174 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull);
175 case SHARPSL_STATUS_FATAL:
176 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal);
177 case SHARPSL_ACIN_VOLT:
178 return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT);
179 case SHARPSL_BATT_TEMP:
180 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP);
181 case SHARPSL_BATT_VOLT:
182 default:
183 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT);
184 }
181} 185}
182 186
183struct sharpsl_charger_machinfo spitz_pm_machinfo = { 187struct sharpsl_charger_machinfo spitz_pm_machinfo = {
184 .init = spitz_charger_init, 188 .init = spitz_charger_init,
189 .exit = sharpsl_pm_pxa_remove,
185 .gpio_batlock = SPITZ_GPIO_BAT_COVER, 190 .gpio_batlock = SPITZ_GPIO_BAT_COVER,
186 .gpio_acin = SPITZ_GPIO_AC_IN, 191 .gpio_acin = SPITZ_GPIO_AC_IN,
187 .gpio_batfull = SPITZ_GPIO_CHRG_FULL, 192 .gpio_batfull = SPITZ_GPIO_CHRG_FULL,
188 .gpio_fatal = SPITZ_GPIO_FATAL_BAT, 193 .gpio_fatal = SPITZ_GPIO_FATAL_BAT,
189 .status_acin = spitz_acin_status,
190 .discharge = spitz_discharge, 194 .discharge = spitz_discharge,
191 .discharge1 = spitz_discharge1, 195 .discharge1 = spitz_discharge1,
192 .charge = spitz_charge, 196 .charge = spitz_charge,
193 .chargeled = spitz_charge_led,
194 .measure_temp = spitz_measure_temp, 197 .measure_temp = spitz_measure_temp,
195 .presuspend = spitz_presuspend, 198 .presuspend = spitz_presuspend,
196 .postsuspend = spitz_postsuspend, 199 .postsuspend = spitz_postsuspend,
200 .read_devdata = spitzpm_read_devdata,
197 .charger_wakeup = spitz_charger_wakeup, 201 .charger_wakeup = spitz_charger_wakeup,
198 .should_wakeup = spitz_should_wakeup, 202 .should_wakeup = spitz_should_wakeup,
199 .bat_levels = 40, 203 .bat_levels = 40,