aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-s3c2440/mach-rx1950.c
diff options
context:
space:
mode:
authorVasily Khoruzhick <anarsoul@gmail.com>2010-09-26 17:17:48 -0400
committerBen Dooks <ben-linux@fluff.org>2010-09-26 19:26:16 -0400
commitecab01d46c68370f347b2c1125cb90070813c799 (patch)
tree604e8bf2dd12fc9b283a890f92644a6be60b94d6 /arch/arm/mach-s3c2440/mach-rx1950.c
parent56162badadb91aae93843d8d6558c7d7780e3cb2 (diff)
ARM: rx1950: Add battery device
This patch adds registration of appropriate device for s3c-adc-battery driver, so battery monitoring and charging are available on RX1950 PDA now. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/mach-s3c2440/mach-rx1950.c')
-rw-r--r--arch/arm/mach-s3c2440/mach-rx1950.c160
1 files changed, 160 insertions, 0 deletions
diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c2440/mach-rx1950.c
index 142d1f921176..a4d8c15da251 100644
--- a/arch/arm/mach-s3c2440/mach-rx1950.c
+++ b/arch/arm/mach-s3c2440/mach-rx1950.c
@@ -25,8 +25,10 @@
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/gpio_keys.h> 26#include <linux/gpio_keys.h>
27#include <linux/sysdev.h> 27#include <linux/sysdev.h>
28#include <linux/pda_power.h>
28#include <linux/pwm_backlight.h> 29#include <linux/pwm_backlight.h>
29#include <linux/pwm.h> 30#include <linux/pwm.h>
31#include <linux/s3c_adc_battery.h>
30 32
31#include <linux/mtd/mtd.h> 33#include <linux/mtd/mtd.h>
32#include <linux/mtd/partitions.h> 34#include <linux/mtd/partitions.h>
@@ -127,6 +129,162 @@ static struct s3c2410fb_display rx1950_display = {
127 129
128}; 130};
129 131
132static int power_supply_init(struct device *dev)
133{
134 return gpio_request(S3C2410_GPF(2), "cable plugged");
135}
136
137static int rx1950_is_ac_online(void)
138{
139 return !gpio_get_value(S3C2410_GPF(2));
140}
141
142static void power_supply_exit(struct device *dev)
143{
144 gpio_free(S3C2410_GPF(2));
145}
146
147static char *rx1950_supplicants[] = {
148 "main-battery"
149};
150
151static struct pda_power_pdata power_supply_info = {
152 .init = power_supply_init,
153 .is_ac_online = rx1950_is_ac_online,
154 .exit = power_supply_exit,
155 .supplied_to = rx1950_supplicants,
156 .num_supplicants = ARRAY_SIZE(rx1950_supplicants),
157};
158
159static struct resource power_supply_resources[] = {
160 [0] = {
161 .name = "ac",
162 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE |
163 IORESOURCE_IRQ_HIGHEDGE,
164 .start = IRQ_EINT2,
165 .end = IRQ_EINT2,
166 },
167};
168
169static struct platform_device power_supply = {
170 .name = "pda-power",
171 .id = -1,
172 .dev = {
173 .platform_data =
174 &power_supply_info,
175 },
176 .resource = power_supply_resources,
177 .num_resources = ARRAY_SIZE(power_supply_resources),
178};
179
180static const struct s3c_adc_bat_thresh bat_lut_noac[] = {
181 { .volt = 4100, .cur = 156, .level = 100},
182 { .volt = 4050, .cur = 156, .level = 95},
183 { .volt = 4025, .cur = 141, .level = 90},
184 { .volt = 3995, .cur = 144, .level = 85},
185 { .volt = 3957, .cur = 162, .level = 80},
186 { .volt = 3931, .cur = 147, .level = 75},
187 { .volt = 3902, .cur = 147, .level = 70},
188 { .volt = 3863, .cur = 153, .level = 65},
189 { .volt = 3838, .cur = 150, .level = 60},
190 { .volt = 3800, .cur = 153, .level = 55},
191 { .volt = 3765, .cur = 153, .level = 50},
192 { .volt = 3748, .cur = 172, .level = 45},
193 { .volt = 3740, .cur = 153, .level = 40},
194 { .volt = 3714, .cur = 175, .level = 35},
195 { .volt = 3710, .cur = 156, .level = 30},
196 { .volt = 3963, .cur = 156, .level = 25},
197 { .volt = 3672, .cur = 178, .level = 20},
198 { .volt = 3651, .cur = 178, .level = 15},
199 { .volt = 3629, .cur = 178, .level = 10},
200 { .volt = 3612, .cur = 162, .level = 5},
201 { .volt = 3605, .cur = 162, .level = 0},
202};
203
204static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
205 { .volt = 4200, .cur = 0, .level = 100},
206 { .volt = 4190, .cur = 0, .level = 99},
207 { .volt = 4178, .cur = 0, .level = 95},
208 { .volt = 4110, .cur = 0, .level = 70},
209 { .volt = 4076, .cur = 0, .level = 65},
210 { .volt = 4046, .cur = 0, .level = 60},
211 { .volt = 4021, .cur = 0, .level = 55},
212 { .volt = 3999, .cur = 0, .level = 50},
213 { .volt = 3982, .cur = 0, .level = 45},
214 { .volt = 3965, .cur = 0, .level = 40},
215 { .volt = 3957, .cur = 0, .level = 35},
216 { .volt = 3948, .cur = 0, .level = 30},
217 { .volt = 3936, .cur = 0, .level = 25},
218 { .volt = 3927, .cur = 0, .level = 20},
219 { .volt = 3906, .cur = 0, .level = 15},
220 { .volt = 3880, .cur = 0, .level = 10},
221 { .volt = 3829, .cur = 0, .level = 5},
222 { .volt = 3820, .cur = 0, .level = 0},
223};
224
225int rx1950_bat_init(void)
226{
227 int ret;
228
229 ret = gpio_request(S3C2410_GPJ(2), "rx1950-charger-enable-1");
230 if (ret)
231 goto err_gpio1;
232 ret = gpio_request(S3C2410_GPJ(3), "rx1950-charger-enable-2");
233 if (ret)
234 goto err_gpio2;
235
236 return 0;
237
238err_gpio2:
239 gpio_free(S3C2410_GPJ(2));
240err_gpio1:
241 return ret;
242}
243
244void rx1950_bat_exit(void)
245{
246 gpio_free(S3C2410_GPJ(2));
247 gpio_free(S3C2410_GPJ(3));
248}
249
250void rx1950_enable_charger(void)
251{
252 gpio_direction_output(S3C2410_GPJ(2), 1);
253 gpio_direction_output(S3C2410_GPJ(3), 1);
254}
255
256void rx1950_disable_charger(void)
257{
258 gpio_direction_output(S3C2410_GPJ(2), 0);
259 gpio_direction_output(S3C2410_GPJ(3), 0);
260}
261
262static struct s3c_adc_bat_pdata rx1950_bat_cfg = {
263 .init = rx1950_bat_init,
264 .exit = rx1950_bat_exit,
265 .enable_charger = rx1950_enable_charger,
266 .disable_charger = rx1950_disable_charger,
267 .gpio_charge_finished = S3C2410_GPF(3),
268 .lut_noac = bat_lut_noac,
269 .lut_noac_cnt = ARRAY_SIZE(bat_lut_noac),
270 .lut_acin = bat_lut_acin,
271 .lut_acin_cnt = ARRAY_SIZE(bat_lut_acin),
272 .volt_channel = 0,
273 .current_channel = 1,
274 .volt_mult = 4235,
275 .current_mult = 2900,
276 .internal_impedance = 200,
277};
278
279static struct platform_device rx1950_battery = {
280 .name = "s3c-adc-battery",
281 .id = -1,
282 .dev = {
283 .parent = &s3c_device_adc.dev,
284 .platform_data = &rx1950_bat_cfg,
285 },
286};
287
130static struct s3c2410fb_mach_info rx1950_lcd_cfg = { 288static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
131 .displays = &rx1950_display, 289 .displays = &rx1950_display,
132 .num_displays = 1, 290 .num_displays = 1,
@@ -503,6 +661,8 @@ static struct platform_device *rx1950_devices[] __initdata = {
503 &s3c_device_timer[1], 661 &s3c_device_timer[1],
504 &rx1950_backlight, 662 &rx1950_backlight,
505 &rx1950_device_gpiokeys, 663 &rx1950_device_gpiokeys,
664 &power_supply,
665 &rx1950_battery,
506}; 666};
507 667
508static struct clk *rx1950_clocks[] __initdata = { 668static struct clk *rx1950_clocks[] __initdata = {