diff options
Diffstat (limited to 'linux/3.1.6/0009-n30-Add-battery-status-for-Acer-n30-n35.patch')
-rw-r--r-- | linux/3.1.6/0009-n30-Add-battery-status-for-Acer-n30-n35.patch | 197 |
1 files changed, 197 insertions, 0 deletions
diff --git a/linux/3.1.6/0009-n30-Add-battery-status-for-Acer-n30-n35.patch b/linux/3.1.6/0009-n30-Add-battery-status-for-Acer-n30-n35.patch new file mode 100644 index 0000000..d9ac7e5 --- /dev/null +++ b/linux/3.1.6/0009-n30-Add-battery-status-for-Acer-n30-n35.patch @@ -0,0 +1,197 @@ +From f28776d590b9f75bde803a37ae63de66b3069c56 Mon Sep 17 00:00:00 2001 +From: Jiri Pinkava <jiri.pinkava@vscht.cz> +Date: Mon, 24 May 2010 10:48:10 +0200 +Subject: [PATCH 09/14] n30: Add battery status for Acer n30 / n35 + +Signed-off-by: Jiri Pinkava <jiri.pinkava@vscht.cz> +--- + arch/arm/mach-s3c2410/mach-n30.c | 7 ++ + drivers/power/Kconfig | 6 ++ + drivers/power/Makefile | 1 + + drivers/power/n30_battery.c | 116 ++++++++++++++++++++++++++++++++++++++ + 4 files changed, 130 insertions(+), 0 deletions(-) + create mode 100644 drivers/power/n30_battery.c + +diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c2410/mach-n30.c +index c492f5d..36ed810 100644 +--- a/arch/arm/mach-s3c2410/mach-n30.c ++++ b/arch/arm/mach-s3c2410/mach-n30.c +@@ -185,6 +185,11 @@ static struct s3c2410_ts_mach_info n30_ts_cfg __initdata = { + .cfg_gpio = s3c24xx_ts_cfg_gpio, + }; + ++static struct platform_device n30_battery = { ++ .name = "n30-battery", ++ .id = -1, ++}; ++ + static struct gpio_keys_button n30_buttons[] = { + { + .gpio = S3C2410_GPF(0), +@@ -539,6 +544,7 @@ static struct platform_device *n30_devices[] __initdata = { + &s3c_device_sdi, + &s3c_device_adc, + &s3c_device_ts, ++ &n30_battery, + &n30_button_device, + &n30_blue_led, + &n30_warning_led, +@@ -559,6 +565,7 @@ static struct platform_device *n35_devices[] __initdata = { + &s3c_device_ts, + &s3c_device_timer[0], + &n35_backlight, ++ &n30_battery, + &n35_button_device, + &n35_blue_led, + &n35_warning_led, +diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig +index 0734356..0f4559c 100644 +--- a/drivers/power/Kconfig ++++ b/drivers/power/Kconfig +@@ -76,6 +76,12 @@ config BATTERY_DS2782 + Say Y here to enable support for the DS2782/DS2786 standalone battery + gas-gauge. + ++config BATTERY_N30 ++ tristate "Acer n30/n35 battery driver" ++ depends on (MACH_N30 || MACH_N35) && I2C ++ help ++ Say Y here to enable support for batteries on the Acer n30 family. ++ + config BATTERY_PMU + tristate "Apple PMU battery" + depends on PPC32 && ADB_PMU +diff --git a/drivers/power/Makefile b/drivers/power/Makefile +index 10143aa..ee8dad2 100644 +--- a/drivers/power/Makefile ++++ b/drivers/power/Makefile +@@ -37,3 +37,4 @@ obj-$(CONFIG_BATTERY_S3C_ADC) += s3c_adc_battery.o + obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o + obj-$(CONFIG_BATTERY_JZ4740) += jz4740-battery.o + obj-$(CONFIG_BATTERY_INTEL_MID) += intel_mid_battery.o ++obj-$(CONFIG_BATTERY_N30) += n30_battery.o +diff --git a/drivers/power/n30_battery.c b/drivers/power/n30_battery.c +new file mode 100644 +index 0000000..c7d34aa +--- /dev/null ++++ b/drivers/power/n30_battery.c +@@ -0,0 +1,116 @@ ++/* Acer n30 battery driver. ++ * ++ * The Acer n30 family has a battery controller which sits on the I2C ++ * bus and which can report the battery charge in percent. Two GPIO ++ * pins tells if the PDA is being powered from a charger or via USB. ++ * ++ * Copyright (c) 2008 Christer Weinigel <christer@weinigel.se> ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation. ++ */ ++ ++#include <linux/kernel.h> ++#include <linux/types.h> ++#include <linux/i2c.h> ++#include <linux/platform_device.h> ++#include <linux/power_supply.h> ++ ++#include <mach/hardware.h> ++#include <mach/regs-gpio.h> ++ ++#include <asm/mach-types.h> ++ ++static int n30_battery_get_capacity(struct device *dev) ++{ ++ u8 value; ++ struct i2c_adapter *adap; ++ struct i2c_msg msg[] = { ++ { .addr = 0x0b, .flags = I2C_M_RD, .buf = &value, .len = 1 } ++ }; ++ int capacity = -EIO; ++ ++ adap = i2c_get_adapter(0); ++ if (adap != NULL) { ++ if (i2c_transfer(adap, msg, 1) == 1) ++ capacity = value; ++ else ++ dev_err(dev, "failed to read capacity\n"); ++ i2c_put_adapter(adap); ++ } else ++ dev_err(dev, "failed to get i2c adapter\n"); ++ ++ return capacity; ++} ++ ++static int n30_battery_get_property(struct power_supply *psy, ++ enum power_supply_property psp, ++ union power_supply_propval *val) ++{ ++ switch (psp) { ++ case POWER_SUPPLY_PROP_CAPACITY: ++ val->intval = n30_battery_get_capacity(psy->dev); ++ return 0; ++ default: ++ return -EINVAL; ++ } ++ return 0; ++} ++ ++static enum power_supply_property n30_battery_props[] = { ++ POWER_SUPPLY_PROP_CAPACITY, ++}; ++ ++static struct power_supply n30_battery = { ++ .name = "battery", ++ .type = POWER_SUPPLY_TYPE_BATTERY, ++ .properties = n30_battery_props, ++ .num_properties = ARRAY_SIZE(n30_battery_props), ++ .get_property = n30_battery_get_property, ++ .use_for_apm = 1, ++}; ++ ++static int __devinit n30_battery_probe(struct platform_device *pdev) ++{ ++ int ret; ++ ++ dev_info(&pdev->dev, "Acer n30 battery driver\n"); ++ ++ ret = power_supply_register(&pdev->dev, &n30_battery); ++ if (ret) ++ return ret; ++ ++ return 0; ++} ++ ++static int n30_battery_remove(struct platform_device *pdev) ++{ ++ power_supply_unregister(&n30_battery); ++ return 0; ++} ++ ++static struct platform_driver n30_battery_driver = { ++ .driver = { ++ .name = "n30-battery", ++ }, ++ .probe = n30_battery_probe, ++ .remove = n30_battery_remove, ++}; ++ ++static int __init n30_battery_init(void) ++{ ++ return platform_driver_register(&n30_battery_driver); ++} ++ ++static void __exit n30_battery_exit(void) ++{ ++ platform_driver_unregister(&n30_battery_driver); ++} ++ ++module_init(n30_battery_init); ++module_exit(n30_battery_exit); ++ ++MODULE_AUTHOR("Christer Weinigel <christer@weinigel.se>"); ++MODULE_DESCRIPTION("Acer n30 battery driver"); ++MODULE_LICENSE("GPL"); +-- +1.7.3.1 + |