aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMarek VaĊĦut <marek.vasut@gmail.com>2008-07-07 12:31:58 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-07-10 07:15:32 -0400
commitd4b19c42ca558273ab99a1093621f267d9d073fc (patch)
treedb35f3770fea579ba25891962c75903e3cfb12bb /arch
parent359784084f3da86e2c7621fd9266e04b50287834 (diff)
[ARM] 5155/1: PalmTX battery monitor
This patch adds battery monitoring driver for PalmTX. It can read voltage from the battery and temperature. It also monitors charging/discharging status. Signed-off-by: Marek Vasut <marek.vasut@gmail.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-pxa/palmtx.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index 0ca2f17402b7..408657a24f8c 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -22,6 +22,7 @@
22#include <linux/irq.h> 22#include <linux/irq.h>
23#include <linux/gpio_keys.h> 23#include <linux/gpio_keys.h>
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/pda_power.h>
25#include <linux/pwm_backlight.h> 26#include <linux/pwm_backlight.h>
26#include <linux/gpio.h> 27#include <linux/gpio.h>
27 28
@@ -279,6 +280,66 @@ static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
279}; 280};
280 281
281/****************************************************************************** 282/******************************************************************************
283 * Power supply
284 ******************************************************************************/
285static int power_supply_init(struct device *dev)
286{
287 int ret;
288
289 ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
290 if (ret)
291 goto err_cs_ac;
292
293 ret = gpio_request(GPIO_NR_PALMTX_USB_DETECT_N, "CABLE_STATE_USB");
294 if (ret)
295 goto err_cs_usb;
296
297 return 0;
298
299err_cs_usb:
300 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
301err_cs_ac:
302 return ret;
303}
304
305static int palmtx_is_ac_online(void)
306{
307 return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
308}
309
310static int palmtx_is_usb_online(void)
311{
312 return !gpio_get_value(GPIO_NR_PALMTX_USB_DETECT_N);
313}
314
315static void power_supply_exit(struct device *dev)
316{
317 gpio_free(GPIO_NR_PALMTX_USB_DETECT_N);
318 gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
319}
320
321static char *palmtx_supplicants[] = {
322 "main-battery",
323};
324
325static struct pda_power_pdata power_supply_info = {
326 .init = power_supply_init,
327 .is_ac_online = palmtx_is_ac_online,
328 .is_usb_online = palmtx_is_usb_online,
329 .exit = power_supply_exit,
330 .supplied_to = palmtx_supplicants,
331 .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
332};
333
334static struct platform_device power_supply = {
335 .name = "pda-power",
336 .id = -1,
337 .dev = {
338 .platform_data = &power_supply_info,
339 },
340};
341
342/******************************************************************************
282 * Framebuffer 343 * Framebuffer
283 ******************************************************************************/ 344 ******************************************************************************/
284static struct pxafb_mode_info palmtx_lcd_modes[] = { 345static struct pxafb_mode_info palmtx_lcd_modes[] = {
@@ -312,6 +373,7 @@ static struct platform_device *devices[] __initdata = {
312 &palmtx_pxa_keys, 373 &palmtx_pxa_keys,
313#endif 374#endif
314 &palmtx_backlight, 375 &palmtx_backlight,
376 &power_supply,
315}; 377};
316 378
317static struct map_desc palmtx_io_desc[] __initdata = { 379static struct map_desc palmtx_io_desc[] __initdata = {