GTA02: add support for dumb battery driver
authorPaul Fertser <fercerpav@gmail.com>
Sun, 26 Jul 2009 14:09:13 +0000 (18:09 +0400)
committerPaul Fertser <fercerpav@gmail.com>
Sun, 2 Aug 2009 08:25:30 +0000 (12:25 +0400)
This allows to use gta01 battery driver on gta02.

echo bq27000-battery.0 > /sys/bus/platform/drivers/bq27000-battery/unbind
modprobe gta01_battery

Signed-off-by: Paul Fertser <fercerpav@gmail.com>
arch/arm/configs/gta02_moredrivers_defconfig
arch/arm/configs/gta02_packaging_defconfig
arch/arm/mach-s3c2442/mach-gta02.c

index 8d06cd6..bd66869 100644 (file)
@@ -1177,7 +1177,7 @@ CONFIG_APM_POWER=y
 CONFIG_CHARGER_PCF50633=y
 CONFIG_BATTERY_BQ27000_HDQ=y
 CONFIG_HDQ_GPIO_BITBANG=y
-# CONFIG_BATTERY_GTA01 is not set
+CONFIG_BATTERY_GTA01=m
 CONFIG_HWMON=y
 # CONFIG_HWMON_VID is not set
 # CONFIG_SENSORS_AD7414 is not set
index 755e416..15defd2 100644 (file)
@@ -1180,7 +1180,7 @@ CONFIG_APM_POWER=y
 CONFIG_CHARGER_PCF50633=y
 CONFIG_BATTERY_BQ27000_HDQ=y
 CONFIG_HDQ_GPIO_BITBANG=y
-# CONFIG_BATTERY_GTA01 is not set
+CONFIG_BATTERY_GTA01=m
 CONFIG_HWMON=y
 # CONFIG_HWMON_VID is not set
 # CONFIG_SENSORS_AD7414 is not set
index cb272fd..5de85c0 100644 (file)
 
 #include <linux/hdq.h>
 #include <linux/bq27000_battery.h>
+#include <linux/gta01_battery.h>
 
 #include "../plat-s3c24xx/neo1973_pm_gps.h"
 
@@ -747,6 +748,34 @@ static void mangle_pmu_pdata_by_system_rev(void)
        }
 }
 
+static int gta02_bat_get_voltage(void)
+{
+       struct pcf50633 *pcf = gta02_pcf;
+       u16 adc, mv = 0;
+       adc = pcf50633_adc_sync_read(pcf,
+               PCF50633_ADCC1_MUX_BATSNS_RES,
+               PCF50633_ADCC1_AVERAGE_16);
+       /* The formula from DS is for divide-by-two mode, current driver uses
+       divide-by-three */
+       mv = (adc * 6000) / 1023;
+       return mv * 1000;
+}
+
+static struct gta01_bat_platform_data gta01_bat_pdata = {
+#ifdef CONFIG_CHARGER_PCF50633
+       .get_charging_status = gta02_get_charger_active_status,
+#endif
+       .get_voltage = gta02_bat_get_voltage,
+};
+
+struct platform_device gta01_bat = {
+       .name = "gta01_battery",
+       .id = -1,
+       .dev = {
+               .platform_data = &gta01_bat_pdata,
+       }
+};
+
 #ifdef CONFIG_HDQ_GPIO_BITBANG
 /* BQ27000 Battery */
 
@@ -1550,6 +1579,7 @@ static struct platform_device *gta02_devices_pmu_children[] = {
        &gta02_spi_gpio_dev, /* input 2 and 3 */
        &gta02_button_dev, /* input 4 */
        &gta02_resume_reason_device,
+       &gta01_bat,
 };
 
 static void gta02_pmu_regulator_registered(struct pcf50633 *pcf, int id)