aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-sa1100
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2006-07-11 17:56:13 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-07-11 17:56:13 -0400
commit3821589c3becb4620dd56bf7f85c14084be1cf22 (patch)
treecb392ebae0b62185209d7c4a46db0e3d8b04a63b /arch/arm/mach-sa1100
parentf7ede370a2aac96903d6e25f3b04345fa6d066f2 (diff)
[ARM] 3723/1: collie charging
Patch from Pavel Machek It seems that sharp had charger on by default... This at least turns it off. Also battery reading now works and is useful. Signed-off-by: Pavel Machek <pavel@suse.cz> Acked-by: Richard Purdie <rpurdie@rpsys.net> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-sa1100')
-rw-r--r--arch/arm/mach-sa1100/collie_pm.c69
1 files changed, 45 insertions, 24 deletions
diff --git a/arch/arm/mach-sa1100/collie_pm.c b/arch/arm/mach-sa1100/collie_pm.c
index 45b1e71f111d..1e25b1d19fce 100644
--- a/arch/arm/mach-sa1100/collie_pm.c
+++ b/arch/arm/mach-sa1100/collie_pm.c
@@ -9,6 +9,9 @@
9 * Li-ion batteries are angry beasts, and they like to explode. This driver is not finished, 9 * Li-ion batteries are angry beasts, and they like to explode. This driver is not finished,
10 * and sometimes charges them when it should not. If it makes angry lithium to come your way... 10 * and sometimes charges them when it should not. If it makes angry lithium to come your way...
11 * ...well, you have been warned. 11 * ...well, you have been warned.
12 *
13 * Actually, this should be quite safe, it seems sharp leaves charger enabled by default,
14 * and my collie did not explode (yet).
12 */ 15 */
13 16
14#include <linux/module.h> 17#include <linux/module.h>
@@ -40,9 +43,8 @@ static void collie_charger_init(void)
40{ 43{
41 int err; 44 int err;
42 45
43 if (sharpsl_param.adadj != -1) { 46 if (sharpsl_param.adadj != -1)
44 ad_revise = sharpsl_param.adadj; 47 ad_revise = sharpsl_param.adadj;
45 }
46 48
47 /* Register interrupt handler. */ 49 /* Register interrupt handler. */
48 if ((err = request_irq(COLLIE_IRQ_GPIO_AC_IN, sharpsl_ac_isr, IRQF_DISABLED, 50 if ((err = request_irq(COLLIE_IRQ_GPIO_AC_IN, sharpsl_ac_isr, IRQF_DISABLED,
@@ -72,27 +74,17 @@ static void collie_measure_temp(int on)
72 74
73static void collie_charge(int on) 75static void collie_charge(int on)
74{ 76{
75 if (on) { 77 extern struct platform_device colliescoop_device;
76 printk("Should start charger\n");
77 } else {
78 printk("Should stop charger\n");
79 }
80#ifdef I_AM_SURE
81 78
82 /* Zaurus seems to contain LTC1731 ; it should know when to 79 /* Zaurus seems to contain LTC1731; it should know when to
83 * stop charging itself, so setting charge on should be 80 * stop charging itself, so setting charge on should be
84 * relatively harmless (as long as it is not done too often). 81 * relatively harmless (as long as it is not done too often).
85 */ 82 */
86#define CF_BUF_CTRL_BASE 0xF0800000
87#define SCOOP_REG(adr) (*(volatile unsigned short*)(CF_BUF_CTRL_BASE+(adr)))
88#define SCOOP_REG_GPWR SCOOP_REG(SCOOP_GPWR)
89
90 if (on) { 83 if (on) {
91 set_scoop_gpio(&colliescoop_device.dev, COLLIE_SCP_CHARGE_ON); 84 set_scoop_gpio(&colliescoop_device.dev, COLLIE_SCP_CHARGE_ON);
92 } else { 85 } else {
93 reset_scoop_gpio(&colliescoop_device.dev, COLLIE_SCP_CHARGE_ON); 86 reset_scoop_gpio(&colliescoop_device.dev, COLLIE_SCP_CHARGE_ON);
94 } 87 }
95#endif
96} 88}
97 89
98static void collie_discharge(int on) 90static void collie_discharge(int on)
@@ -127,7 +119,6 @@ int collie_read_backup_battery(void)
127 119
128 ucb1x00_adc_enable(ucb); 120 ucb1x00_adc_enable(ucb);
129 121
130 /* Gives 75..130 */
131 ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_BBAT_ON, 0); 122 ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_BBAT_ON, 0);
132 voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD1, UCB_SYNC); 123 voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD1, UCB_SYNC);
133 124
@@ -146,9 +137,8 @@ int collie_read_main_battery(void)
146 ucb1x00_adc_enable(ucb); 137 ucb1x00_adc_enable(ucb);
147 ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_BBAT_ON); 138 ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_BBAT_ON);
148 ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_MBAT_ON, 0); 139 ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_MBAT_ON, 0);
149 /* gives values 160..255 with battery removed... and 140
150 145..255 with battery inserted. (on AC), goes as low as 141 mdelay(1);
151 80 on DC. */
152 voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD1, UCB_SYNC); 142 voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD1, UCB_SYNC);
153 143
154 ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_MBAT_ON); 144 ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_MBAT_ON);
@@ -192,7 +182,7 @@ static unsigned long read_devdata(int which)
192 case SHARPSL_BATT_TEMP: 182 case SHARPSL_BATT_TEMP:
193 return collie_read_temp(); 183 return collie_read_temp();
194 case SHARPSL_ACIN_VOLT: 184 case SHARPSL_ACIN_VOLT:
195 return 0x1; 185 return 500;
196 case SHARPSL_STATUS_ACIN: { 186 case SHARPSL_STATUS_ACIN: {
197 int ret = GPLR & COLLIE_GPIO_AC_IN; 187 int ret = GPLR & COLLIE_GPIO_AC_IN;
198 printk("AC status = %d\n", ret); 188 printk("AC status = %d\n", ret);
@@ -208,10 +198,33 @@ static unsigned long read_devdata(int which)
208 } 198 }
209} 199}
210 200
201struct battery_thresh collie_battery_levels_acin[] = {
202 { 420, 100},
203 { 417, 95},
204 { 415, 90},
205 { 413, 80},
206 { 411, 75},
207 { 408, 70},
208 { 406, 60},
209 { 403, 50},
210 { 398, 40},
211 { 391, 25},
212 { 10, 5},
213 { 0, 0},
214};
215
211struct battery_thresh collie_battery_levels[] = { 216struct battery_thresh collie_battery_levels[] = {
212 { 368, 100}, 217 { 394, 100},
213 { 358, 25}, 218 { 390, 95},
214 { 356, 5}, 219 { 380, 90},
220 { 370, 80},
221 { 368, 75}, /* From sharp code: battery high with frontlight */
222 { 366, 70}, /* 60..90 -- fake values invented by me for testing */
223 { 364, 60},
224 { 362, 50},
225 { 360, 40},
226 { 358, 25}, /* From sharp code: battery low with frontlight */
227 { 356, 5}, /* From sharp code: battery verylow with frontlight */
215 { 0, 0}, 228 { 0, 0},
216}; 229};
217 230
@@ -226,13 +239,21 @@ struct sharpsl_charger_machinfo collie_pm_machinfo = {
226 .postsuspend = collie_postsuspend, 239 .postsuspend = collie_postsuspend,
227 .charger_wakeup = collie_charger_wakeup, 240 .charger_wakeup = collie_charger_wakeup,
228 .should_wakeup = collie_should_wakeup, 241 .should_wakeup = collie_should_wakeup,
229 .bat_levels = 3, 242 .bat_levels = 12,
230 .bat_levels_noac = collie_battery_levels, 243 .bat_levels_noac = collie_battery_levels,
231 .bat_levels_acin = collie_battery_levels, 244 .bat_levels_acin = collie_battery_levels_acin,
232 .status_high_acin = 368, 245 .status_high_acin = 368,
233 .status_low_acin = 358, 246 .status_low_acin = 358,
234 .status_high_noac = 368, 247 .status_high_noac = 368,
235 .status_low_noac = 358, 248 .status_low_noac = 358,
249 .charge_on_volt = 350, /* spitz uses 2.90V, but lets play it safe. */
250 .charge_on_temp = 550,
251 .charge_acin_high = 550, /* collie does not seem to have sensor for this, anyway */
252 .charge_acin_low = 450, /* ignored, too */
253 .fatal_acin_volt = 356,
254 .fatal_noacin_volt = 356,
255
256 .batfull_irq = 1, /* We do not want periodical charge restarts */
236}; 257};
237 258
238static int __init collie_pm_ucb_add(struct ucb1x00_dev *pdev) 259static int __init collie_pm_ucb_add(struct ucb1x00_dev *pdev)