This adds battery/charge monitoring driver for spitz.
This is still not 100% done; spitz.c parts need small cleanups to fit
with the rest of code, and limit interface needs to be done.
Question is... who merges this when its done? Would it be ok to go
through PXA tree?
Signed-off-by: Pavel Machek pa...@ucw.cz
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 01c5769..5bf7f0e 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -921,6 +921,15 @@ static inline void spitz_i2c_init(void) {}
#endif
/**
+ * Battery
+
**/
+
+static struct platform_device spitz_battery_device = {
+ .name = spitz-battery,
+ .id = -1,
+};
+
+/**
* Machine init
**/
static void spitz_poweroff(void)
@@ -968,6 +977,7 @@ static void __init spitz_init(void)
spitz_nor_init();
spitz_nand_init();
spitz_i2c_init();
+ platform_device_register(spitz_battery_device);
}
static void __init spitz_fixup(struct machine_desc *desc,
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 52a462f..df54d70 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -102,6 +102,12 @@ config BATTERY_COLLIE
Say Y to enable support for the battery on the Sharp Zaurus
SL-5500 (collie) models.
+config BATTERY_SPITZ
+ tristate Sharp SL-3000C (spitz) battery
+ help
+ Say Y to enable support for the battery on the Sharp Zaurus
+ SL-3000C (spitz) models.
+
config BATTERY_WM97XX
bool WM97xx generic battery driver
depends on TOUCHSCREEN_WM97XX=y
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 8385bfa..7a82c1e 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_BATTERY_PMU) += pmu_battery.o
obj-$(CONFIG_BATTERY_OLPC) += olpc_battery.o
obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o
obj-$(CONFIG_BATTERY_COLLIE) += collie_battery.o
+obj-$(CONFIG_BATTERY_SPITZ)+= spitz_battery.o
obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o
obj-$(CONFIG_BATTERY_BQ20Z75) += bq20z75.o
obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o
diff --git a/drivers/power/spitz_battery.c b/drivers/power/spitz_battery.c
new file mode 100644
index 000..a612ff8
--- /dev/null
+++ b/drivers/power/spitz_battery.c
@@ -0,0 +1,318 @@
+/*
+ * Battery and Power Management code for the Sharp SL-3000c
+ *
+ * Copyright (c) 2009 Pavel Machek pa...@ucw.cz
+ *
+ * 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/platform_device.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/power_supply.h
+#include linux/delay.h
+#include linux/spinlock.h
+#include linux/interrupt.h
+#include linux/gpio.h
+
+#include asm/mach-types.h
+#include mach/spitz.h
+#include mach/sharpsl_pm.h
+
+extern struct sharpsl_pm_status sharpsl_pm;
+
+struct spitz_bat {
+ struct power_supply psy;
+
+ bool (*is_present)(struct spitz_bat *bat);
+};
+
+static struct spitz_bat spitz_bat_main, spitz_ac;
+
+extern int sharpsl_pm_pxa_read_max(int channel);
+
+
+static int spitz_bat_get_property(struct power_supply *psy,
+ enum power_supply_property psp,
+ union power_supply_propval *val)
+{
+ int ret = 0;
+ struct spitz_bat *bat = container_of(psy, struct spitz_bat, psy);
+
+ val-intval = 0;
+
+ switch (psp) {
+ case POWER_SUPPLY_PROP_HEALTH:
+ /* POWER_SUPPLY_HEALTH_OVERHEAT , POWER_SUPPLY_HEALTH_COLD,
+ POWER_SUPPLY_HEALTH_OVERVOLTAGE,
POWER_SUPPLY_HEALTH_UNSPEC_FAILURE, POWER_SUPPLY_HEALTH_GOOD
+*/
+ return 0;
+ case POWER_SUPPLY_PROP_CHARGE_TYPE:
+ val-intval = POWER_SUPPLY_CHARGE_TYPE_NONE;
+ if (gpio_get_value(SPITZ_GPIO_CHRG_ON) == 0) {
+ if (gpio_get_value(SPITZ_GPIO_JK_B) == 1)
+ val-intval = POWER_SUPPLY_CHARGE_TYPE_FAST;
+ else
+ val-intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+ }
+ return 0;
+ case POWER_SUPPLY_PROP_STATUS:
+ {
+ int status = 0;
+
+ if (gpio_get_value(SPITZ_GPIO_CHRG_ON) == 0)
+ printk(Chrg bit on. );
+ if (gpio_get_value(SPITZ_GPIO_JK_B) == 0)
+ printk(Slow charge bit on. );
+
+ val-intval = POWER_SUPPLY_STATUS_UNKNOWN;
+
+