[ARM] 5155/1: PalmTX battery monitor
authorMarek Vašut <marek.vasut@gmail.com>
Mon, 7 Jul 2008 16:31:58 +0000 (17:31 +0100)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Thu, 10 Jul 2008 11:15:32 +0000 (12:15 +0100)
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>
arch/arm/mach-pxa/palmtx.c
drivers/power/Kconfig
drivers/power/Makefile
drivers/power/palmtx_battery.c [new file with mode: 0644]

index 0ca2f17..408657a 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/irq.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
+#include <linux/pda_power.h>
 #include <linux/pwm_backlight.h>
 #include <linux/gpio.h>
 
@@ -278,6 +279,66 @@ static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
        .udc_command            = palmtx_udc_command,
 };
 
+/******************************************************************************
+ * Power supply
+ ******************************************************************************/
+static int power_supply_init(struct device *dev)
+{
+       int ret;
+
+       ret = gpio_request(GPIO_NR_PALMTX_POWER_DETECT, "CABLE_STATE_AC");
+       if (ret)
+               goto err_cs_ac;
+
+       ret = gpio_request(GPIO_NR_PALMTX_USB_DETECT_N, "CABLE_STATE_USB");
+       if (ret)
+               goto err_cs_usb;
+
+       return 0;
+
+err_cs_usb:
+       gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
+err_cs_ac:
+       return ret;
+}
+
+static int palmtx_is_ac_online(void)
+{
+       return gpio_get_value(GPIO_NR_PALMTX_POWER_DETECT);
+}
+
+static int palmtx_is_usb_online(void)
+{
+       return !gpio_get_value(GPIO_NR_PALMTX_USB_DETECT_N);
+}
+
+static void power_supply_exit(struct device *dev)
+{
+       gpio_free(GPIO_NR_PALMTX_USB_DETECT_N);
+       gpio_free(GPIO_NR_PALMTX_POWER_DETECT);
+}
+
+static char *palmtx_supplicants[] = {
+       "main-battery",
+};
+
+static struct pda_power_pdata power_supply_info = {
+       .init            = power_supply_init,
+       .is_ac_online    = palmtx_is_ac_online,
+       .is_usb_online   = palmtx_is_usb_online,
+       .exit            = power_supply_exit,
+       .supplied_to     = palmtx_supplicants,
+       .num_supplicants = ARRAY_SIZE(palmtx_supplicants),
+};
+
+static struct platform_device power_supply = {
+       .name = "pda-power",
+       .id   = -1,
+       .dev  = {
+               .platform_data = &power_supply_info,
+       },
+};
+
 /******************************************************************************
  * Framebuffer
  ******************************************************************************/
@@ -312,6 +373,7 @@ static struct platform_device *devices[] __initdata = {
        &palmtx_pxa_keys,
 #endif
        &palmtx_backlight,
+       &power_supply,
 };
 
 static struct map_desc palmtx_io_desc[] __initdata = {
index 58c806e..4d17d38 100644 (file)
@@ -49,4 +49,10 @@ config BATTERY_OLPC
        help
          Say Y to enable support for the battery on the OLPC laptop.
 
+config BATTERY_PALMTX
+       tristate "Palm T|X battery"
+       depends on MACH_PALMTX
+       help
+         Say Y to enable support for the battery in Palm T|X.
+
 endif # POWER_SUPPLY
index 6413ded..6f43a54 100644 (file)
@@ -20,3 +20,4 @@ obj-$(CONFIG_APM_POWER)               += apm_power.o
 obj-$(CONFIG_BATTERY_DS2760)   += ds2760_battery.o
 obj-$(CONFIG_BATTERY_PMU)      += pmu_battery.o
 obj-$(CONFIG_BATTERY_OLPC)     += olpc_battery.o
+obj-$(CONFIG_BATTERY_PALMTX)   += palmtx_battery.o
Simple merge