summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMarek Vašut <marek.vasut@gmail.com>2008-07-07 17:31:58 +0100
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-07-10 12:15:32 +0100
commitd4b19c42ca558273ab99a1093621f267d9d073fc (patch)
treedb35f3770fea579ba25891962c75903e3cfb12bb /arch
parent359784084f3da86e2c7621fd9266e04b50287834 (diff)
downloadblackbird-op-linux-d4b19c42ca558273ab99a1093621f267d9d073fc.tar.gz
blackbird-op-linux-d4b19c42ca558273ab99a1093621f267d9d073fc.zip
[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 @@
#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>
@@ -279,6 +280,66 @@ static struct pxa2xx_udc_mach_info palmtx_udc_info __initdata = {
};
/******************************************************************************
+ * 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
******************************************************************************/
static struct pxafb_mode_info palmtx_lcd_modes[] = {
@@ -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 = {
OpenPOWER on IntegriCloud