Commit 2c041f4b9be5cecbd0a042ecd9122a9db6f50416

Authored by Richard Purdie
Committed by Russell King
1 parent f99c89297c

[ARM] 3235/1: SharpSL PM: Fix a gcc4 build error

Patch from Richard Purdie

Fix a gcc4 build error (incomplete element type) in the pxa SharpSL
PM code.

Signed-off-by: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

Showing 4 changed files with 1 additions and 3 deletions Inline Diff

arch/arm/mach-pxa/corgi_pm.c
1 /* 1 /*
2 * Battery and Power Management code for the Sharp SL-C7xx 2 * Battery and Power Management code for the Sharp SL-C7xx
3 * 3 *
4 * Copyright (c) 2005 Richard Purdie 4 * Copyright (c) 2005 Richard Purdie
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 */ 10 */
11 11
12 #include <linux/module.h> 12 #include <linux/module.h>
13 #include <linux/stat.h> 13 #include <linux/stat.h>
14 #include <linux/init.h> 14 #include <linux/init.h>
15 #include <linux/kernel.h> 15 #include <linux/kernel.h>
16 #include <linux/delay.h> 16 #include <linux/delay.h>
17 #include <linux/interrupt.h> 17 #include <linux/interrupt.h>
18 #include <linux/platform_device.h> 18 #include <linux/platform_device.h>
19 #include <asm/apm.h> 19 #include <asm/apm.h>
20 #include <asm/irq.h> 20 #include <asm/irq.h>
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>
25 24
26 #include <asm/arch/sharpsl.h> 25 #include <asm/arch/sharpsl.h>
27 #include <asm/arch/corgi.h> 26 #include <asm/arch/corgi.h>
28 #include <asm/arch/pxa-regs.h> 27 #include <asm/arch/pxa-regs.h>
29 #include "sharpsl.h" 28 #include "sharpsl.h"
30 29
31 static void corgi_charger_init(void) 30 static void corgi_charger_init(void)
32 { 31 {
33 pxa_gpio_mode(CORGI_GPIO_ADC_TEMP_ON | GPIO_OUT); 32 pxa_gpio_mode(CORGI_GPIO_ADC_TEMP_ON | GPIO_OUT);
34 pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT); 33 pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT);
35 pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT); 34 pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT);
36 pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN); 35 pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN);
37 sharpsl_pm_pxa_init(); 36 sharpsl_pm_pxa_init();
38 } 37 }
39 38
40 static void corgi_measure_temp(int on) 39 static void corgi_measure_temp(int on)
41 { 40 {
42 if (on) 41 if (on)
43 GPSR(CORGI_GPIO_ADC_TEMP_ON) = GPIO_bit(CORGI_GPIO_ADC_TEMP_ON); 42 GPSR(CORGI_GPIO_ADC_TEMP_ON) = GPIO_bit(CORGI_GPIO_ADC_TEMP_ON);
44 else 43 else
45 GPCR(CORGI_GPIO_ADC_TEMP_ON) = GPIO_bit(CORGI_GPIO_ADC_TEMP_ON); 44 GPCR(CORGI_GPIO_ADC_TEMP_ON) = GPIO_bit(CORGI_GPIO_ADC_TEMP_ON);
46 } 45 }
47 46
48 static void corgi_charge(int on) 47 static void corgi_charge(int on)
49 { 48 {
50 if (on) { 49 if (on) {
51 if (machine_is_corgi() && (sharpsl_pm.flags & SHARPSL_SUSPENDED)) { 50 if (machine_is_corgi() && (sharpsl_pm.flags & SHARPSL_SUSPENDED)) {
52 GPCR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON); 51 GPCR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON);
53 GPSR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN); 52 GPSR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN);
54 } else { 53 } else {
55 GPSR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON); 54 GPSR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON);
56 GPCR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN); 55 GPCR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN);
57 } 56 }
58 } else { 57 } else {
59 GPCR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON); 58 GPCR(CORGI_GPIO_CHRG_ON) = GPIO_bit(CORGI_GPIO_CHRG_ON);
60 GPCR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN); 59 GPCR(CORGI_GPIO_CHRG_UKN) = GPIO_bit(CORGI_GPIO_CHRG_UKN);
61 } 60 }
62 } 61 }
63 62
64 static void corgi_discharge(int on) 63 static void corgi_discharge(int on)
65 { 64 {
66 if (on) 65 if (on)
67 GPSR(CORGI_GPIO_DISCHARGE_ON) = GPIO_bit(CORGI_GPIO_DISCHARGE_ON); 66 GPSR(CORGI_GPIO_DISCHARGE_ON) = GPIO_bit(CORGI_GPIO_DISCHARGE_ON);
68 else 67 else
69 GPCR(CORGI_GPIO_DISCHARGE_ON) = GPIO_bit(CORGI_GPIO_DISCHARGE_ON); 68 GPCR(CORGI_GPIO_DISCHARGE_ON) = GPIO_bit(CORGI_GPIO_DISCHARGE_ON);
70 } 69 }
71 70
72 static void corgi_presuspend(void) 71 static void corgi_presuspend(void)
73 { 72 {
74 int i; 73 int i;
75 unsigned long wakeup_mask; 74 unsigned long wakeup_mask;
76 75
77 /* charging , so CHARGE_ON bit is HIGH during OFF. */ 76 /* charging , so CHARGE_ON bit is HIGH during OFF. */
78 if (READ_GPIO_BIT(CORGI_GPIO_CHRG_ON)) 77 if (READ_GPIO_BIT(CORGI_GPIO_CHRG_ON))
79 PGSR1 |= GPIO_bit(CORGI_GPIO_CHRG_ON); 78 PGSR1 |= GPIO_bit(CORGI_GPIO_CHRG_ON);
80 else 79 else
81 PGSR1 &= ~GPIO_bit(CORGI_GPIO_CHRG_ON); 80 PGSR1 &= ~GPIO_bit(CORGI_GPIO_CHRG_ON);
82 81
83 if (READ_GPIO_BIT(CORGI_GPIO_LED_ORANGE)) 82 if (READ_GPIO_BIT(CORGI_GPIO_LED_ORANGE))
84 PGSR0 |= GPIO_bit(CORGI_GPIO_LED_ORANGE); 83 PGSR0 |= GPIO_bit(CORGI_GPIO_LED_ORANGE);
85 else 84 else
86 PGSR0 &= ~GPIO_bit(CORGI_GPIO_LED_ORANGE); 85 PGSR0 &= ~GPIO_bit(CORGI_GPIO_LED_ORANGE);
87 86
88 if (READ_GPIO_BIT(CORGI_GPIO_CHRG_UKN)) 87 if (READ_GPIO_BIT(CORGI_GPIO_CHRG_UKN))
89 PGSR1 |= GPIO_bit(CORGI_GPIO_CHRG_UKN); 88 PGSR1 |= GPIO_bit(CORGI_GPIO_CHRG_UKN);
90 else 89 else
91 PGSR1 &= ~GPIO_bit(CORGI_GPIO_CHRG_UKN); 90 PGSR1 &= ~GPIO_bit(CORGI_GPIO_CHRG_UKN);
92 91
93 /* Resume on keyboard power key */ 92 /* Resume on keyboard power key */
94 PGSR2 = (PGSR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(0); 93 PGSR2 = (PGSR2 & ~CORGI_GPIO_ALL_STROBE_BIT) | CORGI_GPIO_STROBE_BIT(0);
95 94
96 wakeup_mask = GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) | GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_CHRG_FULL); 95 wakeup_mask = GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) | GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_CHRG_FULL);
97 96
98 if (!machine_is_corgi()) 97 if (!machine_is_corgi())
99 wakeup_mask |= GPIO_bit(CORGI_GPIO_MAIN_BAT_LOW); 98 wakeup_mask |= GPIO_bit(CORGI_GPIO_MAIN_BAT_LOW);
100 99
101 PWER = wakeup_mask | PWER_RTC; 100 PWER = wakeup_mask | PWER_RTC;
102 PRER = wakeup_mask; 101 PRER = wakeup_mask;
103 PFER = wakeup_mask; 102 PFER = wakeup_mask;
104 103
105 for (i = 0; i <=15; i++) { 104 for (i = 0; i <=15; i++) {
106 if (PRER & PFER & GPIO_bit(i)) { 105 if (PRER & PFER & GPIO_bit(i)) {
107 if (GPLR0 & GPIO_bit(i) ) 106 if (GPLR0 & GPIO_bit(i) )
108 PRER &= ~GPIO_bit(i); 107 PRER &= ~GPIO_bit(i);
109 else 108 else
110 PFER &= ~GPIO_bit(i); 109 PFER &= ~GPIO_bit(i);
111 } 110 }
112 } 111 }
113 } 112 }
114 113
115 static void corgi_postsuspend(void) 114 static void corgi_postsuspend(void)
116 { 115 {
117 } 116 }
118 117
119 /* 118 /*
120 * Check what brought us out of the suspend. 119 * Check what brought us out of the suspend.
121 * Return: 0 to sleep, otherwise wake 120 * Return: 0 to sleep, otherwise wake
122 */ 121 */
123 static int corgi_should_wakeup(unsigned int resume_on_alarm) 122 static int corgi_should_wakeup(unsigned int resume_on_alarm)
124 { 123 {
125 int is_resume = 0; 124 int is_resume = 0;
126 125
127 dev_dbg(sharpsl_pm.dev, "GPLR0 = %x,%x\n", GPLR0, PEDR); 126 dev_dbg(sharpsl_pm.dev, "GPLR0 = %x,%x\n", GPLR0, PEDR);
128 127
129 if ((PEDR & GPIO_bit(CORGI_GPIO_AC_IN))) { 128 if ((PEDR & GPIO_bit(CORGI_GPIO_AC_IN))) {
130 if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) { 129 if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) {
131 /* charge on */ 130 /* charge on */
132 dev_dbg(sharpsl_pm.dev, "ac insert\n"); 131 dev_dbg(sharpsl_pm.dev, "ac insert\n");
133 sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG; 132 sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG;
134 } else { 133 } else {
135 /* charge off */ 134 /* charge off */
136 dev_dbg(sharpsl_pm.dev, "ac remove\n"); 135 dev_dbg(sharpsl_pm.dev, "ac remove\n");
137 sharpsl_pm_led(SHARPSL_LED_OFF); 136 sharpsl_pm_led(SHARPSL_LED_OFF);
138 sharpsl_pm.machinfo->charge(0); 137 sharpsl_pm.machinfo->charge(0);
139 sharpsl_pm.charge_mode = CHRG_OFF; 138 sharpsl_pm.charge_mode = CHRG_OFF;
140 } 139 }
141 } 140 }
142 141
143 if ((PEDR & GPIO_bit(CORGI_GPIO_CHRG_FULL))) 142 if ((PEDR & GPIO_bit(CORGI_GPIO_CHRG_FULL)))
144 dev_dbg(sharpsl_pm.dev, "Charge full interrupt\n"); 143 dev_dbg(sharpsl_pm.dev, "Charge full interrupt\n");
145 144
146 if (PEDR & GPIO_bit(CORGI_GPIO_KEY_INT)) 145 if (PEDR & GPIO_bit(CORGI_GPIO_KEY_INT))
147 is_resume |= GPIO_bit(CORGI_GPIO_KEY_INT); 146 is_resume |= GPIO_bit(CORGI_GPIO_KEY_INT);
148 147
149 if (PEDR & GPIO_bit(CORGI_GPIO_WAKEUP)) 148 if (PEDR & GPIO_bit(CORGI_GPIO_WAKEUP))
150 is_resume |= GPIO_bit(CORGI_GPIO_WAKEUP); 149 is_resume |= GPIO_bit(CORGI_GPIO_WAKEUP);
151 150
152 if (resume_on_alarm && (PEDR & PWER_RTC)) 151 if (resume_on_alarm && (PEDR & PWER_RTC))
153 is_resume |= PWER_RTC; 152 is_resume |= PWER_RTC;
154 153
155 dev_dbg(sharpsl_pm.dev, "is_resume: %x\n",is_resume); 154 dev_dbg(sharpsl_pm.dev, "is_resume: %x\n",is_resume);
156 return is_resume; 155 return is_resume;
157 } 156 }
158 157
159 static unsigned long corgi_charger_wakeup(void) 158 static unsigned long corgi_charger_wakeup(void)
160 { 159 {
161 return ~GPLR0 & ( GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) ); 160 return ~GPLR0 & ( GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) );
162 } 161 }
163 162
164 unsigned long corgipm_read_devdata(int type) 163 unsigned long corgipm_read_devdata(int type)
165 { 164 {
166 switch(type) { 165 switch(type) {
167 case SHARPSL_STATUS_ACIN: 166 case SHARPSL_STATUS_ACIN:
168 return ((GPLR(CORGI_GPIO_AC_IN) & GPIO_bit(CORGI_GPIO_AC_IN)) != 0); 167 return ((GPLR(CORGI_GPIO_AC_IN) & GPIO_bit(CORGI_GPIO_AC_IN)) != 0);
169 case SHARPSL_STATUS_LOCK: 168 case SHARPSL_STATUS_LOCK:
170 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock); 169 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock);
171 case SHARPSL_STATUS_CHRGFULL: 170 case SHARPSL_STATUS_CHRGFULL:
172 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull); 171 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull);
173 case SHARPSL_STATUS_FATAL: 172 case SHARPSL_STATUS_FATAL:
174 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal); 173 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal);
175 case SHARPSL_ACIN_VOLT: 174 case SHARPSL_ACIN_VOLT:
176 return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT); 175 return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT);
177 case SHARPSL_BATT_TEMP: 176 case SHARPSL_BATT_TEMP:
178 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP); 177 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP);
179 case SHARPSL_BATT_VOLT: 178 case SHARPSL_BATT_VOLT:
180 default: 179 default:
181 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT); 180 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT);
182 } 181 }
183 } 182 }
184 183
185 static struct sharpsl_charger_machinfo corgi_pm_machinfo = { 184 static struct sharpsl_charger_machinfo corgi_pm_machinfo = {
186 .init = corgi_charger_init, 185 .init = corgi_charger_init,
187 .exit = sharpsl_pm_pxa_remove, 186 .exit = sharpsl_pm_pxa_remove,
188 .gpio_batlock = CORGI_GPIO_BAT_COVER, 187 .gpio_batlock = CORGI_GPIO_BAT_COVER,
189 .gpio_acin = CORGI_GPIO_AC_IN, 188 .gpio_acin = CORGI_GPIO_AC_IN,
190 .gpio_batfull = CORGI_GPIO_CHRG_FULL, 189 .gpio_batfull = CORGI_GPIO_CHRG_FULL,
191 .discharge = corgi_discharge, 190 .discharge = corgi_discharge,
192 .charge = corgi_charge, 191 .charge = corgi_charge,
193 .measure_temp = corgi_measure_temp, 192 .measure_temp = corgi_measure_temp,
194 .presuspend = corgi_presuspend, 193 .presuspend = corgi_presuspend,
195 .postsuspend = corgi_postsuspend, 194 .postsuspend = corgi_postsuspend,
196 .read_devdata = corgipm_read_devdata, 195 .read_devdata = corgipm_read_devdata,
197 .charger_wakeup = corgi_charger_wakeup, 196 .charger_wakeup = corgi_charger_wakeup,
198 .should_wakeup = corgi_should_wakeup, 197 .should_wakeup = corgi_should_wakeup,
199 .bat_levels = 40, 198 .bat_levels = 40,
200 .bat_levels_noac = spitz_battery_levels_noac, 199 .bat_levels_noac = spitz_battery_levels_noac,
201 .bat_levels_acin = spitz_battery_levels_acin, 200 .bat_levels_acin = spitz_battery_levels_acin,
202 .status_high_acin = 188, 201 .status_high_acin = 188,
203 .status_low_acin = 178, 202 .status_low_acin = 178,
204 .status_high_noac = 185, 203 .status_high_noac = 185,
205 .status_low_noac = 175, 204 .status_low_noac = 175,
206 }; 205 };
207 206
208 static struct platform_device *corgipm_device; 207 static struct platform_device *corgipm_device;
209 208
210 static int __devinit corgipm_init(void) 209 static int __devinit corgipm_init(void)
211 { 210 {
212 int ret; 211 int ret;
213 212
214 corgipm_device = platform_device_alloc("sharpsl-pm", -1); 213 corgipm_device = platform_device_alloc("sharpsl-pm", -1);
215 if (!corgipm_device) 214 if (!corgipm_device)
216 return -ENOMEM; 215 return -ENOMEM;
217 216
218 corgipm_device->dev.platform_data = &corgi_pm_machinfo; 217 corgipm_device->dev.platform_data = &corgi_pm_machinfo;
219 ret = platform_device_add(corgipm_device); 218 ret = platform_device_add(corgipm_device);
220 219
221 if (ret) 220 if (ret)
222 platform_device_put(corgipm_device); 221 platform_device_put(corgipm_device);
223 222
224 return ret; 223 return ret;
225 } 224 }
226 225
227 static void corgipm_exit(void) 226 static void corgipm_exit(void)
228 { 227 {
229 platform_device_unregister(corgipm_device); 228 platform_device_unregister(corgipm_device);
230 } 229 }
231 230
232 module_init(corgipm_init); 231 module_init(corgipm_init);
233 module_exit(corgipm_exit); 232 module_exit(corgipm_exit);
234 233
arch/arm/mach-pxa/sharpsl.h
1 /* 1 /*
2 * Copyright (c) 2004-2005 Richard Purdie 2 * Copyright (c) 2004-2005 Richard Purdie
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 * 7 *
8 */ 8 */
9 9
10 #include <asm/hardware/sharpsl_pm.h>
10 11
11 /* 12 /*
12 * SharpSL SSP Driver 13 * SharpSL SSP Driver
13 */ 14 */
14 struct corgissp_machinfo { 15 struct corgissp_machinfo {
15 int port; 16 int port;
16 int cs_lcdcon; 17 int cs_lcdcon;
17 int cs_ads7846; 18 int cs_ads7846;
18 int cs_max1111; 19 int cs_max1111;
19 int clk_lcdcon; 20 int clk_lcdcon;
20 int clk_ads7846; 21 int clk_ads7846;
21 int clk_max1111; 22 int clk_max1111;
22 }; 23 };
23 24
24 void corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo); 25 void corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo);
25 26
26 27
27 /* 28 /*
28 * SharpSL Backlight 29 * SharpSL Backlight
29 */ 30 */
30 void corgi_bl_set_intensity(int intensity); 31 void corgi_bl_set_intensity(int intensity);
31 void spitz_bl_set_intensity(int intensity); 32 void spitz_bl_set_intensity(int intensity);
32 void akita_bl_set_intensity(int intensity); 33 void akita_bl_set_intensity(int intensity);
33 34
34 35
35 /* 36 /*
36 * SharpSL Touchscreen Driver 37 * SharpSL Touchscreen Driver
37 */ 38 */
38 unsigned long corgi_get_hsync_len(void); 39 unsigned long corgi_get_hsync_len(void);
39 unsigned long spitz_get_hsync_len(void); 40 unsigned long spitz_get_hsync_len(void);
40 void corgi_put_hsync(void); 41 void corgi_put_hsync(void);
41 void spitz_put_hsync(void); 42 void spitz_put_hsync(void);
42 void corgi_wait_hsync(void); 43 void corgi_wait_hsync(void);
43 void spitz_wait_hsync(void); 44 void spitz_wait_hsync(void);
44 45
45 46
46 /* 47 /*
47 * SharpSL Battery/PM Driver 48 * SharpSL Battery/PM Driver
48 */ 49 */
49 50
50 #define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x)) 51 #define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x))
51 52
52 /* MAX1111 Channel Definitions */ 53 /* MAX1111 Channel Definitions */
53 #define MAX1111_BATT_VOLT 4u 54 #define MAX1111_BATT_VOLT 4u
54 #define MAX1111_BATT_TEMP 2u 55 #define MAX1111_BATT_TEMP 2u
55 #define MAX1111_ACIN_VOLT 6u 56 #define MAX1111_ACIN_VOLT 6u
56 57
57 extern struct battery_thresh spitz_battery_levels_acin[]; 58 extern struct battery_thresh spitz_battery_levels_acin[];
58 extern struct battery_thresh spitz_battery_levels_noac[]; 59 extern struct battery_thresh spitz_battery_levels_noac[];
59 void sharpsl_pm_pxa_init(void); 60 void sharpsl_pm_pxa_init(void);
60 void sharpsl_pm_pxa_remove(void); 61 void sharpsl_pm_pxa_remove(void);
61 int sharpsl_pm_pxa_read_max1111(int channel); 62 int sharpsl_pm_pxa_read_max1111(int channel);
62 63
63 64
64 65
arch/arm/mach-pxa/sharpsl_pm.c
1 /* 1 /*
2 * Battery and Power Management code for the Sharp SL-C7xx and SL-Cxx00 2 * Battery and Power Management code for the Sharp SL-C7xx and SL-Cxx00
3 * series of PDAs 3 * series of PDAs
4 * 4 *
5 * Copyright (c) 2004-2005 Richard Purdie 5 * Copyright (c) 2004-2005 Richard Purdie
6 * 6 *
7 * Based on code written by Sharp for 2.4 kernels 7 * Based on code written by Sharp for 2.4 kernels
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 * 12 *
13 */ 13 */
14 14
15 #undef DEBUG 15 #undef DEBUG
16 16
17 #include <linux/module.h> 17 #include <linux/module.h>
18 #include <linux/init.h> 18 #include <linux/init.h>
19 #include <linux/kernel.h> 19 #include <linux/kernel.h>
20 #include <linux/interrupt.h> 20 #include <linux/interrupt.h>
21 #include <linux/platform_device.h> 21 #include <linux/platform_device.h>
22 22
23 #include <asm/hardware.h> 23 #include <asm/hardware.h>
24 #include <asm/mach-types.h> 24 #include <asm/mach-types.h>
25 #include <asm/irq.h> 25 #include <asm/irq.h>
26 #include <asm/apm.h> 26 #include <asm/apm.h>
27 #include <asm/arch/pm.h> 27 #include <asm/arch/pm.h>
28 #include <asm/arch/pxa-regs.h> 28 #include <asm/arch/pxa-regs.h>
29 #include <asm/arch/sharpsl.h> 29 #include <asm/arch/sharpsl.h>
30 #include <asm/hardware/sharpsl_pm.h>
31 #include "sharpsl.h" 30 #include "sharpsl.h"
32 31
33 struct battery_thresh spitz_battery_levels_acin[] = { 32 struct battery_thresh spitz_battery_levels_acin[] = {
34 { 213, 100}, 33 { 213, 100},
35 { 212, 98}, 34 { 212, 98},
36 { 211, 95}, 35 { 211, 95},
37 { 210, 93}, 36 { 210, 93},
38 { 209, 90}, 37 { 209, 90},
39 { 208, 88}, 38 { 208, 88},
40 { 207, 85}, 39 { 207, 85},
41 { 206, 83}, 40 { 206, 83},
42 { 205, 80}, 41 { 205, 80},
43 { 204, 78}, 42 { 204, 78},
44 { 203, 75}, 43 { 203, 75},
45 { 202, 73}, 44 { 202, 73},
46 { 201, 70}, 45 { 201, 70},
47 { 200, 68}, 46 { 200, 68},
48 { 199, 65}, 47 { 199, 65},
49 { 198, 63}, 48 { 198, 63},
50 { 197, 60}, 49 { 197, 60},
51 { 196, 58}, 50 { 196, 58},
52 { 195, 55}, 51 { 195, 55},
53 { 194, 53}, 52 { 194, 53},
54 { 193, 50}, 53 { 193, 50},
55 { 192, 48}, 54 { 192, 48},
56 { 192, 45}, 55 { 192, 45},
57 { 191, 43}, 56 { 191, 43},
58 { 191, 40}, 57 { 191, 40},
59 { 190, 38}, 58 { 190, 38},
60 { 190, 35}, 59 { 190, 35},
61 { 189, 33}, 60 { 189, 33},
62 { 188, 30}, 61 { 188, 30},
63 { 187, 28}, 62 { 187, 28},
64 { 186, 25}, 63 { 186, 25},
65 { 185, 23}, 64 { 185, 23},
66 { 184, 20}, 65 { 184, 20},
67 { 183, 18}, 66 { 183, 18},
68 { 182, 15}, 67 { 182, 15},
69 { 181, 13}, 68 { 181, 13},
70 { 180, 10}, 69 { 180, 10},
71 { 179, 8}, 70 { 179, 8},
72 { 178, 5}, 71 { 178, 5},
73 { 0, 0}, 72 { 0, 0},
74 }; 73 };
75 74
76 struct battery_thresh spitz_battery_levels_noac[] = { 75 struct battery_thresh spitz_battery_levels_noac[] = {
77 { 213, 100}, 76 { 213, 100},
78 { 212, 98}, 77 { 212, 98},
79 { 211, 95}, 78 { 211, 95},
80 { 210, 93}, 79 { 210, 93},
81 { 209, 90}, 80 { 209, 90},
82 { 208, 88}, 81 { 208, 88},
83 { 207, 85}, 82 { 207, 85},
84 { 206, 83}, 83 { 206, 83},
85 { 205, 80}, 84 { 205, 80},
86 { 204, 78}, 85 { 204, 78},
87 { 203, 75}, 86 { 203, 75},
88 { 202, 73}, 87 { 202, 73},
89 { 201, 70}, 88 { 201, 70},
90 { 200, 68}, 89 { 200, 68},
91 { 199, 65}, 90 { 199, 65},
92 { 198, 63}, 91 { 198, 63},
93 { 197, 60}, 92 { 197, 60},
94 { 196, 58}, 93 { 196, 58},
95 { 195, 55}, 94 { 195, 55},
96 { 194, 53}, 95 { 194, 53},
97 { 193, 50}, 96 { 193, 50},
98 { 192, 48}, 97 { 192, 48},
99 { 191, 45}, 98 { 191, 45},
100 { 190, 43}, 99 { 190, 43},
101 { 189, 40}, 100 { 189, 40},
102 { 188, 38}, 101 { 188, 38},
103 { 187, 35}, 102 { 187, 35},
104 { 186, 33}, 103 { 186, 33},
105 { 185, 30}, 104 { 185, 30},
106 { 184, 28}, 105 { 184, 28},
107 { 183, 25}, 106 { 183, 25},
108 { 182, 23}, 107 { 182, 23},
109 { 181, 20}, 108 { 181, 20},
110 { 180, 18}, 109 { 180, 18},
111 { 179, 15}, 110 { 179, 15},
112 { 178, 13}, 111 { 178, 13},
113 { 177, 10}, 112 { 177, 10},
114 { 176, 8}, 113 { 176, 8},
115 { 175, 5}, 114 { 175, 5},
116 { 0, 0}, 115 { 0, 0},
117 }; 116 };
118 117
119 /* MAX1111 Commands */ 118 /* MAX1111 Commands */
120 #define MAXCTRL_PD0 1u << 0 119 #define MAXCTRL_PD0 1u << 0
121 #define MAXCTRL_PD1 1u << 1 120 #define MAXCTRL_PD1 1u << 1
122 #define MAXCTRL_SGL 1u << 2 121 #define MAXCTRL_SGL 1u << 2
123 #define MAXCTRL_UNI 1u << 3 122 #define MAXCTRL_UNI 1u << 3
124 #define MAXCTRL_SEL_SH 4 123 #define MAXCTRL_SEL_SH 4
125 #define MAXCTRL_STR 1u << 7 124 #define MAXCTRL_STR 1u << 7
126 125
127 /* 126 /*
128 * Read MAX1111 ADC 127 * Read MAX1111 ADC
129 */ 128 */
130 int sharpsl_pm_pxa_read_max1111(int channel) 129 int sharpsl_pm_pxa_read_max1111(int channel)
131 { 130 {
132 return corgi_ssp_max1111_get((channel << MAXCTRL_SEL_SH) | MAXCTRL_PD0 | MAXCTRL_PD1 131 return corgi_ssp_max1111_get((channel << MAXCTRL_SEL_SH) | MAXCTRL_PD0 | MAXCTRL_PD1
133 | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR); 132 | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR);
134 } 133 }
135 134
136 void sharpsl_pm_pxa_init(void) 135 void sharpsl_pm_pxa_init(void)
137 { 136 {
138 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_acin | GPIO_IN); 137 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_acin | GPIO_IN);
139 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batfull | GPIO_IN); 138 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batfull | GPIO_IN);
140 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batlock | GPIO_IN); 139 pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batlock | GPIO_IN);
141 140
142 /* Register interrupt handlers */ 141 /* Register interrupt handlers */
143 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr, SA_INTERRUPT, "AC Input Detect", sharpsl_ac_isr)) { 142 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr, SA_INTERRUPT, "AC Input Detect", sharpsl_ac_isr)) {
144 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin)); 143 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin));
145 } 144 }
146 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin),IRQT_BOTHEDGE); 145 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin),IRQT_BOTHEDGE);
147 146
148 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr, SA_INTERRUPT, "Battery Cover", sharpsl_fatal_isr)) { 147 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr, SA_INTERRUPT, "Battery Cover", sharpsl_fatal_isr)) {
149 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock)); 148 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock));
150 } 149 }
151 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock),IRQT_FALLING); 150 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock),IRQT_FALLING);
152 151
153 if (sharpsl_pm.machinfo->gpio_fatal) { 152 if (sharpsl_pm.machinfo->gpio_fatal) {
154 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr, SA_INTERRUPT, "Fatal Battery", sharpsl_fatal_isr)) { 153 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr, SA_INTERRUPT, "Fatal Battery", sharpsl_fatal_isr)) {
155 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal)); 154 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal));
156 } 155 }
157 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal),IRQT_FALLING); 156 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal),IRQT_FALLING);
158 } 157 }
159 158
160 if (!machine_is_corgi()) 159 if (!machine_is_corgi())
161 { 160 {
162 /* Register interrupt handler. */ 161 /* Register interrupt handler. */
163 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, SA_INTERRUPT, "CO", sharpsl_chrg_full_isr)) { 162 if (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, SA_INTERRUPT, "CO", sharpsl_chrg_full_isr)) {
164 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull)); 163 dev_err(sharpsl_pm.dev, "Could not get irq %d.\n", IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull));
165 } 164 }
166 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQT_RISING); 165 else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQT_RISING);
167 } 166 }
168 } 167 }
169 168
170 void sharpsl_pm_pxa_remove(void) 169 void sharpsl_pm_pxa_remove(void)
171 { 170 {
172 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr); 171 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr);
173 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr); 172 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr);
174 173
175 if (sharpsl_pm.machinfo->gpio_fatal) 174 if (sharpsl_pm.machinfo->gpio_fatal)
176 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr); 175 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_fatal), sharpsl_fatal_isr);
177 176
178 if (!machine_is_corgi()) 177 if (!machine_is_corgi())
179 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr); 178 free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr);
180 } 179 }
181 180
arch/arm/mach-pxa/spitz_pm.c
1 /* 1 /*
2 * Battery and Power Management code for the Sharp SL-Cxx00 2 * Battery and Power Management code for the Sharp SL-Cxx00
3 * 3 *
4 * Copyright (c) 2005 Richard Purdie 4 * Copyright (c) 2005 Richard Purdie
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 */ 10 */
11 11
12 #include <linux/module.h> 12 #include <linux/module.h>
13 #include <linux/stat.h> 13 #include <linux/stat.h>
14 #include <linux/init.h> 14 #include <linux/init.h>
15 #include <linux/kernel.h> 15 #include <linux/kernel.h>
16 #include <linux/delay.h> 16 #include <linux/delay.h>
17 #include <linux/interrupt.h> 17 #include <linux/interrupt.h>
18 #include <linux/platform_device.h> 18 #include <linux/platform_device.h>
19 #include <asm/apm.h> 19 #include <asm/apm.h>
20 #include <asm/irq.h> 20 #include <asm/irq.h>
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>
25 24
26 #include <asm/arch/sharpsl.h> 25 #include <asm/arch/sharpsl.h>
27 #include <asm/arch/spitz.h> 26 #include <asm/arch/spitz.h>
28 #include <asm/arch/pxa-regs.h> 27 #include <asm/arch/pxa-regs.h>
29 #include "sharpsl.h" 28 #include "sharpsl.h"
30 29
31 static int spitz_last_ac_status; 30 static int spitz_last_ac_status;
32 31
33 static void spitz_charger_init(void) 32 static void spitz_charger_init(void)
34 { 33 {
35 pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN); 34 pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN);
36 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN); 35 pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN);
37 sharpsl_pm_pxa_init(); 36 sharpsl_pm_pxa_init();
38 } 37 }
39 38
40 static void spitz_measure_temp(int on) 39 static void spitz_measure_temp(int on)
41 { 40 {
42 if (on) 41 if (on)
43 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON); 42 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON);
44 else 43 else
45 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON); 44 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_ADC_TEMP_ON);
46 } 45 }
47 46
48 static void spitz_charge(int on) 47 static void spitz_charge(int on)
49 { 48 {
50 if (on) { 49 if (on) {
51 if (sharpsl_pm.flags & SHARPSL_SUSPENDED) { 50 if (sharpsl_pm.flags & SHARPSL_SUSPENDED) {
52 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); 51 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B);
53 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); 52 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON);
54 } else { 53 } else {
55 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); 54 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B);
56 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); 55 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON);
57 } 56 }
58 } else { 57 } else {
59 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B); 58 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_B);
60 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON); 59 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CHRG_ON);
61 } 60 }
62 } 61 }
63 62
64 static void spitz_discharge(int on) 63 static void spitz_discharge(int on)
65 { 64 {
66 if (on) 65 if (on)
67 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A); 66 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A);
68 else 67 else
69 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A); 68 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_JK_A);
70 } 69 }
71 70
72 /* HACK - For unknown reasons, accurate voltage readings are only made with a load 71 /* HACK - For unknown reasons, accurate voltage readings are only made with a load
73 on the power bus which the green led on spitz provides */ 72 on the power bus which the green led on spitz provides */
74 static void spitz_discharge1(int on) 73 static void spitz_discharge1(int on)
75 { 74 {
76 if (on) 75 if (on)
77 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN); 76 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
78 else 77 else
79 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN); 78 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_GREEN);
80 } 79 }
81 80
82 static void spitz_presuspend(void) 81 static void spitz_presuspend(void)
83 { 82 {
84 spitz_last_ac_status = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN); 83 spitz_last_ac_status = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
85 84
86 /* GPIO Sleep Register */ 85 /* GPIO Sleep Register */
87 PGSR0 = 0x00144018; 86 PGSR0 = 0x00144018;
88 PGSR1 = 0x00EF0000; 87 PGSR1 = 0x00EF0000;
89 if (machine_is_akita()) { 88 if (machine_is_akita()) {
90 PGSR2 = 0x2121C000; 89 PGSR2 = 0x2121C000;
91 PGSR3 = 0x00600400; 90 PGSR3 = 0x00600400;
92 } else { 91 } else {
93 PGSR2 = 0x0121C000; 92 PGSR2 = 0x0121C000;
94 PGSR3 = 0x00600000; 93 PGSR3 = 0x00600000;
95 } 94 }
96 95
97 PGSR0 &= ~SPITZ_GPIO_G0_STROBE_BIT; 96 PGSR0 &= ~SPITZ_GPIO_G0_STROBE_BIT;
98 PGSR1 &= ~SPITZ_GPIO_G1_STROBE_BIT; 97 PGSR1 &= ~SPITZ_GPIO_G1_STROBE_BIT;
99 PGSR2 &= ~SPITZ_GPIO_G2_STROBE_BIT; 98 PGSR2 &= ~SPITZ_GPIO_G2_STROBE_BIT;
100 PGSR3 &= ~SPITZ_GPIO_G3_STROBE_BIT; 99 PGSR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
101 PGSR2 |= GPIO_bit(SPITZ_GPIO_KEY_STROBE0); 100 PGSR2 |= GPIO_bit(SPITZ_GPIO_KEY_STROBE0);
102 101
103 pxa_gpio_mode(GPIO18_RDY|GPIO_OUT | GPIO_DFLT_HIGH); 102 pxa_gpio_mode(GPIO18_RDY|GPIO_OUT | GPIO_DFLT_HIGH);
104 103
105 PRER = GPIO_bit(SPITZ_GPIO_KEY_INT); 104 PRER = GPIO_bit(SPITZ_GPIO_KEY_INT);
106 PFER = GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET); 105 PFER = GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET);
107 PWER = GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET) | PWER_RTC; 106 PWER = GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET) | PWER_RTC;
108 PKWR = GPIO_bit(SPITZ_GPIO_SYNC) | GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET); 107 PKWR = GPIO_bit(SPITZ_GPIO_SYNC) | GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET);
109 PKSR = 0xffffffff; // clear 108 PKSR = 0xffffffff; // clear
110 109
111 /* nRESET_OUT Disable */ 110 /* nRESET_OUT Disable */
112 PSLR |= PSLR_SL_ROD; 111 PSLR |= PSLR_SL_ROD;
113 112
114 /* Clear reset status */ 113 /* Clear reset status */
115 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR; 114 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
116 115
117 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ 116 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
118 PCFR = PCFR_GPR_EN | PCFR_OPDE; 117 PCFR = PCFR_GPR_EN | PCFR_OPDE;
119 } 118 }
120 119
121 static void spitz_postsuspend(void) 120 static void spitz_postsuspend(void)
122 { 121 {
123 pxa_gpio_mode(GPIO18_RDY_MD); 122 pxa_gpio_mode(GPIO18_RDY_MD);
124 pxa_gpio_mode(10 | GPIO_IN); 123 pxa_gpio_mode(10 | GPIO_IN);
125 } 124 }
126 125
127 static int spitz_should_wakeup(unsigned int resume_on_alarm) 126 static int spitz_should_wakeup(unsigned int resume_on_alarm)
128 { 127 {
129 int is_resume = 0; 128 int is_resume = 0;
130 int acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN); 129 int acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
131 130
132 if (spitz_last_ac_status != acin) { 131 if (spitz_last_ac_status != acin) {
133 if (acin) { 132 if (acin) {
134 /* charge on */ 133 /* charge on */
135 sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG; 134 sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG;
136 dev_dbg(sharpsl_pm.dev, "AC Inserted\n"); 135 dev_dbg(sharpsl_pm.dev, "AC Inserted\n");
137 } else { 136 } else {
138 /* charge off */ 137 /* charge off */
139 dev_dbg(sharpsl_pm.dev, "AC Removed\n"); 138 dev_dbg(sharpsl_pm.dev, "AC Removed\n");
140 sharpsl_pm_led(SHARPSL_LED_OFF); 139 sharpsl_pm_led(SHARPSL_LED_OFF);
141 sharpsl_pm.machinfo->charge(0); 140 sharpsl_pm.machinfo->charge(0);
142 sharpsl_pm.charge_mode = CHRG_OFF; 141 sharpsl_pm.charge_mode = CHRG_OFF;
143 } 142 }
144 spitz_last_ac_status = acin; 143 spitz_last_ac_status = acin;
145 /* Return to suspend as this must be what we were woken for */ 144 /* Return to suspend as this must be what we were woken for */
146 return 0; 145 return 0;
147 } 146 }
148 147
149 if (PEDR & GPIO_bit(SPITZ_GPIO_KEY_INT)) 148 if (PEDR & GPIO_bit(SPITZ_GPIO_KEY_INT))
150 is_resume |= GPIO_bit(SPITZ_GPIO_KEY_INT); 149 is_resume |= GPIO_bit(SPITZ_GPIO_KEY_INT);
151 150
152 if (PKSR & GPIO_bit(SPITZ_GPIO_SYNC)) 151 if (PKSR & GPIO_bit(SPITZ_GPIO_SYNC))
153 is_resume |= GPIO_bit(SPITZ_GPIO_SYNC); 152 is_resume |= GPIO_bit(SPITZ_GPIO_SYNC);
154 153
155 if (resume_on_alarm && (PEDR & PWER_RTC)) 154 if (resume_on_alarm && (PEDR & PWER_RTC))
156 is_resume |= PWER_RTC; 155 is_resume |= PWER_RTC;
157 156
158 dev_dbg(sharpsl_pm.dev, "is_resume: %x\n",is_resume); 157 dev_dbg(sharpsl_pm.dev, "is_resume: %x\n",is_resume);
159 return is_resume; 158 return is_resume;
160 } 159 }
161 160
162 static unsigned long spitz_charger_wakeup(void) 161 static unsigned long spitz_charger_wakeup(void)
163 { 162 {
164 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));
165 } 164 }
166 165
167 unsigned long spitzpm_read_devdata(int type) 166 unsigned long spitzpm_read_devdata(int type)
168 { 167 {
169 switch(type) { 168 switch(type) {
170 case SHARPSL_STATUS_ACIN: 169 case SHARPSL_STATUS_ACIN:
171 return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0); 170 return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0);
172 case SHARPSL_STATUS_LOCK: 171 case SHARPSL_STATUS_LOCK:
173 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock); 172 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock);
174 case SHARPSL_STATUS_CHRGFULL: 173 case SHARPSL_STATUS_CHRGFULL:
175 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull); 174 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull);
176 case SHARPSL_STATUS_FATAL: 175 case SHARPSL_STATUS_FATAL:
177 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal); 176 return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal);
178 case SHARPSL_ACIN_VOLT: 177 case SHARPSL_ACIN_VOLT:
179 return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT); 178 return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT);
180 case SHARPSL_BATT_TEMP: 179 case SHARPSL_BATT_TEMP:
181 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP); 180 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP);
182 case SHARPSL_BATT_VOLT: 181 case SHARPSL_BATT_VOLT:
183 default: 182 default:
184 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT); 183 return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT);
185 } 184 }
186 } 185 }
187 186
188 struct sharpsl_charger_machinfo spitz_pm_machinfo = { 187 struct sharpsl_charger_machinfo spitz_pm_machinfo = {
189 .init = spitz_charger_init, 188 .init = spitz_charger_init,
190 .exit = sharpsl_pm_pxa_remove, 189 .exit = sharpsl_pm_pxa_remove,
191 .gpio_batlock = SPITZ_GPIO_BAT_COVER, 190 .gpio_batlock = SPITZ_GPIO_BAT_COVER,
192 .gpio_acin = SPITZ_GPIO_AC_IN, 191 .gpio_acin = SPITZ_GPIO_AC_IN,
193 .gpio_batfull = SPITZ_GPIO_CHRG_FULL, 192 .gpio_batfull = SPITZ_GPIO_CHRG_FULL,
194 .gpio_fatal = SPITZ_GPIO_FATAL_BAT, 193 .gpio_fatal = SPITZ_GPIO_FATAL_BAT,
195 .discharge = spitz_discharge, 194 .discharge = spitz_discharge,
196 .discharge1 = spitz_discharge1, 195 .discharge1 = spitz_discharge1,
197 .charge = spitz_charge, 196 .charge = spitz_charge,
198 .measure_temp = spitz_measure_temp, 197 .measure_temp = spitz_measure_temp,
199 .presuspend = spitz_presuspend, 198 .presuspend = spitz_presuspend,
200 .postsuspend = spitz_postsuspend, 199 .postsuspend = spitz_postsuspend,
201 .read_devdata = spitzpm_read_devdata, 200 .read_devdata = spitzpm_read_devdata,
202 .charger_wakeup = spitz_charger_wakeup, 201 .charger_wakeup = spitz_charger_wakeup,
203 .should_wakeup = spitz_should_wakeup, 202 .should_wakeup = spitz_should_wakeup,
204 .bat_levels = 40, 203 .bat_levels = 40,
205 .bat_levels_noac = spitz_battery_levels_noac, 204 .bat_levels_noac = spitz_battery_levels_noac,
206 .bat_levels_acin = spitz_battery_levels_acin, 205 .bat_levels_acin = spitz_battery_levels_acin,
207 .status_high_acin = 188, 206 .status_high_acin = 188,
208 .status_low_acin = 178, 207 .status_low_acin = 178,
209 .status_high_noac = 185, 208 .status_high_noac = 185,
210 .status_low_noac = 175, 209 .status_low_noac = 175,
211 }; 210 };
212 211
213 static struct platform_device *spitzpm_device; 212 static struct platform_device *spitzpm_device;
214 213
215 static int __devinit spitzpm_init(void) 214 static int __devinit spitzpm_init(void)
216 { 215 {
217 int ret; 216 int ret;
218 217
219 spitzpm_device = platform_device_alloc("sharpsl-pm", -1); 218 spitzpm_device = platform_device_alloc("sharpsl-pm", -1);
220 if (!spitzpm_device) 219 if (!spitzpm_device)
221 return -ENOMEM; 220 return -ENOMEM;
222 221
223 spitzpm_device->dev.platform_data = &spitz_pm_machinfo; 222 spitzpm_device->dev.platform_data = &spitz_pm_machinfo;
224 ret = platform_device_add(spitzpm_device); 223 ret = platform_device_add(spitzpm_device);
225 224
226 if (ret) 225 if (ret)
227 platform_device_put(spitzpm_device); 226 platform_device_put(spitzpm_device);
228 227
229 return ret; 228 return ret;
230 } 229 }
231 230
232 static void spitzpm_exit(void) 231 static void spitzpm_exit(void)
233 { 232 {
234 platform_device_unregister(spitzpm_device); 233 platform_device_unregister(spitzpm_device);
235 } 234 }
236 235
237 module_init(spitzpm_init); 236 module_init(spitzpm_init);
238 module_exit(spitzpm_exit); 237 module_exit(spitzpm_exit);
239 238