Re: spitz battery driver

From: Eric Miao
Date: Mon Nov 09 2009 - 22:50:01 EST


On Mon, Nov 9, 2009 at 9:58 PM, Pavel Machek <pavel@xxxxxx> wrote:
> Hi!
>
> This introduces battery driver for spitz. For now it is
> monitoring&debug-only.
>

This is a good move. However, I assume the patch is still RFC now.
Or basically the coding style cleanup can be separated into another
patch?

> Signed-off-by: Pavel Machek <pavel@xxxxxx> (but not meant for merge)
>
> --- ./drivers/power.ofic/Makefile    2009-10-06 13:51:29.000000000 +0200
> +++ ./drivers/power/Makefile  Â2009-10-11 16:12:09.000000000 +0200
> @@ -24,6 +24,7 @@
> Âobj-$(CONFIG_BATTERY_PMU) Â Â Â+= pmu_battery.o
> Âobj-$(CONFIG_BATTERY_OLPC) Â Â += olpc_battery.o
> Âobj-$(CONFIG_BATTERY_TOSA) Â Â += tosa_battery.o
> +obj-m Â+= spitz_battery.o
> Âobj-$(CONFIG_BATTERY_WM97XX) Â += wm97xx_battery.o
> Âobj-$(CONFIG_BATTERY_BQ27x00) Â+= bq27x00_battery.o
> Âobj-$(CONFIG_BATTERY_DA9030) Â += da9030_battery.o
> diff -ur ./drivers/power.ofic/power_supply_sysfs.c ./drivers/power/power_supply_sysfs.c
> --- ./drivers/power.ofic/power_supply_sysfs.c  2009-10-06 13:51:29.000000000 +0200
> +++ ./drivers/power/power_supply_sysfs.c    Â2009-10-15 05:45:46.000000000 +0200
> @@ -39,7 +39,8 @@
>
> Âstatic ssize_t power_supply_show_property(struct device *dev,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstruct device_attribute *attr,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â char *buf) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â char *buf)
> +{
> Â Â Â Âstatic char *status_text[] = {
> Â Â Â Â Â Â Â Â"Unknown", "Charging", "Discharging", "Not charging", "Full"
> Â Â Â Â};
> @@ -135,7 +136,8 @@
>
> Âstatic ssize_t power_supply_show_static_attrs(struct device *dev,
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstruct device_attribute *attr,
> - Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â char *buf) {
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â char *buf)
> +{
> Â Â Â Âstatic char *type_text[] = { "Battery", "UPS", "Mains", "USB" };
> Â Â Â Âstruct power_supply *psy = dev_get_drvdata(dev);
>
> diff -ur ./drivers/power.ofic/spitz_battery.c ./drivers/power/spitz_battery.c
> --- ./drivers/power.ofic/spitz_battery.c    Â2009-10-11 16:14:11.000000000 +0200
> +++ ./drivers/power/spitz_battery.c   2009-10-22 07:27:52.000000000 +0200
> @@ -0,0 +1,430 @@
> +/*
> + * Battery and Power Management code for the Sharp SL-3000c
> + *
> + * Copyright (c) 2009 Pavel Machek <pavel@xxxxxx>
> + *
> + * 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.
> + *
> + * Li-ion batteries are angry beasts, and they like to explode.
> + * If angry lithium comes your way, the hw was misdesigned.
> + *
> + */
> +#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.h>
> +#include <mach/sharpsl_pm.h>
> +
> +#include "../../arch/arm/mach-pxa/sharpsl.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_max1111(int channel);
> +
> +int basic_current = 125; /* miliAmp */
> +int battery_resistance = 422; /* miliOhm */
> +
> +/* 422 seems to be suitable for very old, 1Ah battery.
> + Â 2Ah battery probably has better resistance */
> +
> +/* Unfortunately, resistance depends on state of charge, current
> + * direction and temperature.
> + *
> + * Ouch, and dependency is actually _not_ too simple. It is lowest
> + * at 3.55V, very slowly rises at 4V (approximately linear dependency),
> + * and quickly rises towards 3.2V (in something exponential-looking).
> + *
> + * It is about same at 25Celsius and 40Celsius, and about 2.5x the value
> + * on 0Celsius, rising _very_ sharply.
> + *
> + * Li-ion should only be charged between 0 and 45 Celsius, and discharged
> + * between -20 and 60 celsius.
> + */
> +
> +extern int backlight_current;
> +
> +int battery_current(void)
> +{
> + Â Â Â int intensity = sharpsl_pm.machinfo->backlight_get_status ? sharpsl_pm.machinfo->backlight_get_status() : 0;
> +
> + Â Â Â return basic_current + backlight_current;
> +}
> +
> +int liion_internal_voltage(int voltage, int current_ma)
> +{
> + Â Â Â return voltage + (battery_resistance * current_ma / 1000);
> +}
> +
> +int liion_expected_voltage(int internal_voltage, int current_ma)
> +{
> + Â Â Â return internal_voltage - (battery_resistance * current_ma / 1000);
> +}
> +
> +/* returns mV */
> +int liion_voltage(void)
> +{
> + Â Â Â /* Thanks to Stanislav B. ADC has 3.3V as reference,
> + Â Â Â Â Âis connected to battery over 47kOhm,
> + Â Â Â Â Âand to ground over 100kOhm. */
> + Â Â Â return (sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT) * 147 * 33)/256;
> +}
> +
> +/* See for example http://www.kokam.com/english/biz/rc.html for
> + * voltage/capacity characteristic. I assume it is going to be
> + * reasonably similar to li-ion used in collie.
> + *
> + */
> +
> +/*
> + { 420, 100 },
> + { 417, 95 }, means it will report 100% between 418 and 420
> + */
> +
> +struct battery_thresh battery_levels[] = {
> + Â Â Â { 3980, 100 },
> + Â Â Â { 3900, 95 },
> + Â Â Â { 3860, 90 },
> + Â Â Â { 3800, 85 },
> + Â Â Â { 3760, 80 },
> + Â Â Â { 3720, 74 },
> + Â Â Â { 3680, 69 },
> + Â Â Â { 3620, 65 },
> + Â Â Â { 3570, 59 },
> + Â Â Â { 3560, 55 },
> + Â Â Â { 3550, 48 },
> + Â Â Â { 3530, 45 },
> + Â Â Â { 3510, 39 },
> + Â Â Â { 3490, 33 },
> + Â Â Â { 3470, 29 },
> + Â Â Â { 3450, 23 },
> + Â Â Â { 3410, 16 },
> + Â Â Â { Â Â0, 0 },
> +};
> +
> +int get_percentage(void)
> +{
> + Â Â Â int i = ARRAY_SIZE(battery_levels);
> + Â Â Â struct battery_thresh *thresh;
> + Â Â Â int voltage = liion_internal_voltage(liion_voltage(), battery_current());
> +
> + Â Â Â thresh = battery_levels;
> +
> + Â Â Â while (i > 0 && (voltage > thresh[i].voltage))
> + Â Â Â Â Â Â Â i--;
> +
> + Â Â Â return thresh[i].percentage;
> +}
> +
> +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;
> +
> + Â Â Â Â Â Â Â if (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN))
> + Â Â Â Â Â Â Â Â Â Â Â val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
> + Â Â Â Â Â Â Â else {
> + Â Â Â Â Â Â Â Â Â Â Â if (gpio_get_value(SPITZ_GPIO_CHRG_ON) == 0)
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â val->intval = POWER_SUPPLY_STATUS_CHARGING;
> + Â Â Â Â Â Â Â Â Â Â Â if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_CHRGFULL))
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â val->intval = POWER_SUPPLY_STATUS_FULL;
> + Â Â Â Â Â Â Â }
> +
> + Â Â Â Â Â Â Â printk("ACIN: %d ", sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN));
> + Â Â Â Â Â Â Â printk("Chrgfull: %d Â", sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_CHRGFULL));
> + Â Â Â Â Â Â Â printk("Fatal: %d Â", sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_FATAL));
> + Â Â Â Â Â Â Â printk("ACIN_volt: %d\n", sharpsl_pm.machinfo->read_devdata(SHARPSL_ACIN_VOLT));
> +
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â Â }
> + Â Â Â case POWER_SUPPLY_PROP_TECHNOLOGY:
> + Â Â Â Â Â Â Â val->intval = POWER_SUPPLY_TECHNOLOGY_LION;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_VOLTAGE_NOW:
> + Â Â Â Â Â Â Â val->intval = liion_voltage()*1000;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
> + Â Â Â Â Â Â Â val->intval = 4200000;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
> + Â Â Â Â Â Â Â val->intval = 3400000;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_TEMP:
> + Â Â Â Â Â Â Â mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP);
> + Â Â Â Â Â Â Â sharpsl_pm.machinfo->measure_temp(1);
> + Â Â Â Â Â Â Â mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP);
> + Â Â Â Â Â Â Â val->intval = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_TEMP);
> + Â Â Â Â Â Â Â sharpsl_pm.machinfo->measure_temp(0);
> + Â Â Â Â Â Â Â /* 121: battery finished charging in 22C room */
> + Â Â Â Â Â Â Â /* 141: outside at 6C */
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_MODEL_NAME:
> + Â Â Â Â Â Â Â val->strval = "spitz-battery";
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_PRESENT:
> + Â Â Â Â Â Â Â val->intval = 1;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â Â Â Â Â /* add these */
> + Â Â Â case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
> + Â Â Â Â Â Â Â val->intval = 2000000;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_CAPACITY:
> + Â Â Â Â Â Â Â val->intval = get_percentage();
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_VOLTAGE_AVG:
> + Â Â Â Â Â Â Â val->intval = liion_internal_voltage(liion_voltage(), battery_current())*1000;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_CURRENT_NOW:
> + Â Â Â Â Â Â Â val->intval = battery_current() * 1000;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â default:
> + Â Â Â Â Â Â Â return -EINVAL;
> + Â Â Â }
> + Â Â Â return -EINVAL;
> +}
> +
> +static int spitz_ac_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_STATUS:
> + Â Â Â Â Â Â Â val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_VOLTAGE_NOW:
> + Â Â Â Â Â Â Â /* Thanks to Stanislav B. ADC has 3.3V as reference,
> + Â Â Â Â Â Â Â Â Âis connected to acin over 2kOhm,
> + Â Â Â Â Â Â Â Â Âand to ground over 1kOhm. */
> + Â Â Â Â Â Â Â val->intval = (sharpsl_pm.machinfo->read_devdata(SHARPSL_ACIN_VOLT) * 3000 * 3300)/256;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
> + Â Â Â Â Â Â Â val->intval = 5250000;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
> + Â Â Â Â Â Â Â val->intval = 4750000;
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_MODEL_NAME:
> + Â Â Â Â Â Â Â val->strval = "spitz-power-supply";
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â case POWER_SUPPLY_PROP_PRESENT:
> + Â Â Â Â Â Â Â val->intval = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
> + Â Â Â Â Â Â Â return 0;
> + Â Â Â default:
> + Â Â Â Â Â Â Â return -EINVAL;
> + Â Â Â }
> + Â Â Â return -EINVAL;
> +}
> +
> +static void spitz_bat_external_power_changed(struct power_supply *psy)
> +{
> +}
> +
> +
> +static enum power_supply_property spitz_bat_main_props[] = {
> + Â Â Â POWER_SUPPLY_PROP_STATUS,
> + Â Â Â POWER_SUPPLY_PROP_TECHNOLOGY,
> + Â Â Â POWER_SUPPLY_PROP_VOLTAGE_NOW,
> + Â Â Â POWER_SUPPLY_PROP_VOLTAGE_AVG,
> + Â Â Â POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
> + Â Â Â POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
> + Â Â Â POWER_SUPPLY_PROP_TEMP,
> + Â Â Â POWER_SUPPLY_PROP_PRESENT,
> + Â Â Â POWER_SUPPLY_PROP_CHARGE_TYPE,
> + Â Â Â POWER_SUPPLY_PROP_HEALTH,
> + Â Â Â POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
> + Â Â Â POWER_SUPPLY_PROP_CURRENT_NOW,
> + Â Â Â POWER_SUPPLY_PROP_CAPACITY,
> +};
> +
> +static struct spitz_bat spitz_bat_main = {
> + Â Â Â .psy = {
> +        .name      = "main-battery",
> +        .type      = POWER_SUPPLY_TYPE_BATTERY,
> +        .properties   = spitz_bat_main_props,
> + Â Â Â Â Â Â Â .num_properties = ARRAY_SIZE(spitz_bat_main_props),
> +        .get_property  = spitz_bat_get_property,
> + Â Â Â Â Â Â Â .external_power_changed = spitz_bat_external_power_changed,
> +        .use_for_apm  Â= 1,
> + Â Â Â },
> +};
> +
> +static enum power_supply_property spitz_ac_props[] = {
> + Â Â Â POWER_SUPPLY_PROP_STATUS,
> + Â Â Â POWER_SUPPLY_PROP_VOLTAGE_NOW,
> + Â Â Â POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
> + Â Â Â POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
> + Â Â Â POWER_SUPPLY_PROP_PRESENT,
> +};
> +
> +static struct spitz_bat spitz_ac = {
> + Â Â Â .psy = {
> +        .name      = "ac",
> +        .type      = POWER_SUPPLY_TYPE_MAINS,
> +        .properties   = spitz_ac_props,
> + Â Â Â Â Â Â Â .num_properties = ARRAY_SIZE(spitz_ac_props),
> +        .get_property  = spitz_ac_get_property,
> + Â Â Â },
> +};
> +
> +#ifdef CONFIG_PM
> +static int spitz_bat_suspend(struct platform_device *dev, pm_message_t state)
> +{
> + Â Â Â return 0;
> +}
> +
> +static int spitz_bat_resume(struct platform_device *dev)
> +{
> + Â Â Â return 0;
> +}
> +#else
> +#define spitz_bat_suspend NULL
> +#define spitz_bat_resume NULL
> +#endif
> +
> +
> +static ssize_t spitz_bat_limit_show(struct device *dev,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct device_attribute *attr,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â char *buf)
> +{
> + Â Â Â sprintf(buf, "Hello :-)");
> + Â Â Â return 9;
> +}
> +
> +static ssize_t spitz_bat_limit_store(struct device *dev,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âstruct device_attribute *attr,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âconst char *buf, size_t count)
> +{
> + Â Â Â if (!strncmp(buf, "fastcharge", 10)) {
> + Â Â Â Â Â Â Â gpio_set_value(SPITZ_GPIO_JK_B, 1);
> + Â Â Â Â Â Â Â gpio_set_value(SPITZ_GPIO_CHRG_ON, 0);
> + Â Â Â Â Â Â Â return 10;
> + Â Â Â }
> + Â Â Â if (!strncmp(buf, "slowcharge", 10)) {
> + Â Â Â Â Â Â Â gpio_set_value(SPITZ_GPIO_JK_B, 0);
> + Â Â Â Â Â Â Â gpio_set_value(SPITZ_GPIO_CHRG_ON, 0);
> + Â Â Â Â Â Â Â return 10;
> + Â Â Â }
> + Â Â Â if (!strncmp(buf, "nonecharge", 10)) {
> + Â Â Â Â Â Â Â gpio_set_value(SPITZ_GPIO_JK_B, 0);
> + Â Â Â Â Â Â Â gpio_set_value(SPITZ_GPIO_CHRG_ON, 1);
> + Â Â Â Â Â Â Â return 10;
> + Â Â Â }
> + Â Â Â return -EINVAL;
> +}
> +
> +
> +static DEVICE_ATTR(limit, S_IRUGO | S_IWUSR, spitz_bat_limit_show, spitz_bat_limit_store);
> +#if 0
> +static struct device_attribute dev_attr_limit = {
> + Â Â Â Â.attr = { .name = "limit", .mode = 0644 },
> + Â Â Â Â.show = spitz_bat_limit_show,
> + Â Â Â Â.store = spitz_bat_limit_store,
> +};
> +#endif
> +
> +static int __devinit spitz_bat_probe(struct platform_device *dev)
> +{
> + Â Â Â int ret;
> + Â Â Â int i;
> +
> + Â Â Â if (!machine_is_spitz())
> + Â Â Â Â Â Â Â return -ENODEV;
> +
> + Â Â Â printk("spitz_bat_probe: register\n");
> + Â Â Â power_supply_register(&dev->dev, &spitz_bat_main.psy);
> + Â Â Â power_supply_register(&dev->dev, &spitz_ac.psy);
> + Â Â Â device_create_file(&dev->dev, &dev_attr_limit);
> +
> + Â Â Â return 0;
> +}
> +
> +static int __devexit spitz_bat_remove(struct platform_device *dev)
> +{
> + Â Â Â int i;
> +
> + Â Â Â device_remove_file(&dev->dev, &dev_attr_limit);
> + Â Â Â power_supply_unregister(&spitz_bat_main.psy);
> + Â Â Â power_supply_unregister(&spitz_ac.psy);
> + Â Â Â return 0;
> +}
> +
> +
> +static struct platform_driver spitz_bat_driver = {
> +    .driver.name  Â= "spitz-battery",
> +    .driver.owner  = THIS_MODULE,
> +    .probe     Â= spitz_bat_probe,
> +    .remove     = __devexit_p(spitz_bat_remove),
> +    .suspend    Â= spitz_bat_suspend,
> +    .resume     = spitz_bat_resume,
> +};
> +
> +static int __init spitz_bat_init(void)
> +{
> + Â Â Â return platform_driver_register(&spitz_bat_driver);
> +}
> +
> +static void __exit spitz_bat_exit(void)
> +{
> + Â Â Â platform_driver_unregister(&spitz_bat_driver);
> +}
> +
> +module_init(spitz_bat_init);
> +module_exit(spitz_bat_exit);
> +
> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Pavel Machek");
> +MODULE_DESCRIPTION("Spitz battery driver");
> +MODULE_ALIAS("platform:spitz-battery");
> diff -ur ./drivers/video/backlight.ofic/corgi_lcd.c ./drivers/video/backlight/corgi_lcd.c
> --- ./drivers/video/backlight.ofic/corgi_lcd.c Â2009-10-18 18:11:36.000000000 +0200
> +++ ./drivers/video/backlight/corgi_lcd.c    2009-10-18 18:37:09.000000000 +0200
> @@ -388,17 +388,33 @@
>    Â.set_mode    = corgi_lcd_set_mode,
> Â};
>
> -static int corgi_bl_get_intensity(struct backlight_device *bd)
> +int corgi_bl_get_intensity(struct backlight_device *bd)
> Â{
> Â Â Â Âstruct corgi_lcd *lcd = dev_get_drvdata(&bd->dev);
>
> Â Â Â Âreturn lcd->intensity;
> Â}
> +EXPORT_SYMBOL(corgi_bl_get_intensity);
> +
> +int backlight_current;
> +EXPORT_SYMBOL(backlight_current);
>
> Âstatic int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity)
> Â{
> Â Â Â Âint cont;
>
> + Â Â Â backlight_current = 0;
> + Â Â Â if (intensity > 0)
> + Â Â Â Â Â Â Â backlight_current = 55;
> + Â Â Â if (intensity > 10)
> + Â Â Â Â Â Â Â backlight_current = 115;
> + Â Â Â if (intensity > 20)
> + Â Â Â Â Â Â Â backlight_current = 140;
> + Â Â Â if (intensity > 30)
> + Â Â Â Â Â Â Â backlight_current = 180;
> + Â Â Â if (intensity > 45)
> + Â Â Â Â Â Â Â backlight_current = 245;
> +
> Â Â Â Âif (intensity > 0x10)
> Â Â Â Â Â Â Â Âintensity += 0x10;
>
> @@ -433,8 +449,9 @@
>
> Â Â Â Âif (corgibl_flags & CORGIBL_SUSPENDED)
> Â Â Â Â Â Â Â Âintensity = 0;
> - Â Â Â if (corgibl_flags & CORGIBL_BATTLOW)
> - Â Â Â Â Â Â Â intensity &= lcd->limit_mask;
> +
> + Â Â Â if ((corgibl_flags & CORGIBL_BATTLOW) && intensity > lcd->limit_mask)
> + Â Â Â Â Â Â Â intensity = lcd->limit_mask;
>
> Â Â Â Âreturn corgi_bl_set_intensity(lcd, intensity);
> Â}
> diff -ur ./arch/arm.ofic/mach-pxa/corgi_pm.c ./arch/arm/mach-pxa/corgi_pm.c
> --- ./arch/arm.ofic/mach-pxa/corgi_pm.c 2009-09-10 00:13:59.000000000 +0200
> +++ ./arch/arm/mach-pxa/corgi_pm.c   Â2009-10-22 19:19:02.000000000 +0200
> @@ -35,6 +35,92 @@
> Â#define SHARPSL_FATAL_ACIN_VOLT Â Â Â Â182 Â /* 3.45V */
> Â#define SHARPSL_FATAL_NOACIN_VOLT Â Â Â170 Â /* 3.40V */
>
> +static const struct battery_thresh corgi_battery_levels_acin[] = {
> + Â Â Â { 213, 100},
> + Â Â Â { 212, Â98},
> + Â Â Â { 211, Â95},
> + Â Â Â { 210, Â93},
> + Â Â Â { 209, Â90},
> + Â Â Â { 208, Â88},
> + Â Â Â { 207, Â85},
> + Â Â Â { 206, Â83},
> + Â Â Â { 205, Â80},
> + Â Â Â { 204, Â78},
> + Â Â Â { 203, Â75},
> + Â Â Â { 202, Â73},
> + Â Â Â { 201, Â70},
> + Â Â Â { 200, Â68},
> + Â Â Â { 199, Â65},
> + Â Â Â { 198, Â63},
> + Â Â Â { 197, Â60},
> + Â Â Â { 196, Â58},
> + Â Â Â { 195, Â55},
> + Â Â Â { 194, Â53},
> + Â Â Â { 193, Â50},
> + Â Â Â { 192, Â48},
> + Â Â Â { 192, Â45},
> + Â Â Â { 191, Â43},
> + Â Â Â { 191, Â40},
> + Â Â Â { 190, Â38},
> + Â Â Â { 190, Â35},
> + Â Â Â { 189, Â33},
> + Â Â Â { 188, Â30},
> + Â Â Â { 187, Â28},
> + Â Â Â { 186, Â25},
> + Â Â Â { 185, Â23},
> + Â Â Â { 184, Â20},
> + Â Â Â { 183, Â18},
> + Â Â Â { 182, Â15},
> + Â Â Â { 181, Â13},
> + Â Â Â { 180, Â10},
> + Â Â Â { 179, Â 8},
> + Â Â Â { 178, Â 5},
> + Â Â Â { Â 0, Â 0},
> +};
> +
> +static const struct battery_thresh Âcorgi_battery_levels_noac[] = {
> + Â Â Â { 213, 100},
> + Â Â Â { 212, Â98},
> + Â Â Â { 211, Â95},
> + Â Â Â { 210, Â93},
> + Â Â Â { 209, Â90},
> + Â Â Â { 208, Â88},
> + Â Â Â { 207, Â85},
> + Â Â Â { 206, Â83},
> + Â Â Â { 205, Â80},
> + Â Â Â { 204, Â78},
> + Â Â Â { 203, Â75},
> + Â Â Â { 202, Â73},
> + Â Â Â { 201, Â70},
> + Â Â Â { 200, Â68},
> + Â Â Â { 199, Â65},
> + Â Â Â { 198, Â63},
> + Â Â Â { 197, Â60},
> + Â Â Â { 196, Â58},
> + Â Â Â { 195, Â55},
> + Â Â Â { 194, Â53},
> + Â Â Â { 193, Â50},
> + Â Â Â { 192, Â48},
> + Â Â Â { 191, Â45},
> + Â Â Â { 190, Â43},
> + Â Â Â { 189, Â40},
> + Â Â Â { 188, Â38},
> + Â Â Â { 187, Â35},
> + Â Â Â { 186, Â33},
> + Â Â Â { 185, Â30},
> + Â Â Â { 184, Â28},
> + Â Â Â { 183, Â25},
> + Â Â Â { 182, Â23},
> + Â Â Â { 181, Â20},
> + Â Â Â { 180, Â18},
> + Â Â Â { 179, Â15},
> + Â Â Â { 178, Â13},
> + Â Â Â { 177, Â10},
> + Â Â Â { 176, Â 8},
> + Â Â Â { 175, Â 5},
> + Â Â Â { Â 0, Â 0},
> +};
> +
> Âstatic void corgi_charger_init(void)
> Â{
> Â Â Â Âpxa_gpio_mode(CORGI_GPIO_ADC_TEMP_ON | GPIO_OUT);
> @@ -214,8 +300,8 @@
> Â Â Â Â.fatal_acin_volt Â= SHARPSL_FATAL_ACIN_VOLT,
> Â Â Â Â.fatal_noacin_volt= SHARPSL_FATAL_NOACIN_VOLT,
>    Â.bat_levels    = 40,
> - Â Â Â .bat_levels_noac Â= spitz_battery_levels_noac,
> - Â Â Â .bat_levels_acin Â= spitz_battery_levels_acin,
> + Â Â Â .bat_levels_noac Â= corgi_battery_levels_noac,
> + Â Â Â .bat_levels_acin Â= corgi_battery_levels_acin,
> Â Â Â Â.status_high_acin = 188,
> Â Â Â Â.status_low_acin Â= 178,
> Â Â Â Â.status_high_noac = 185,
> diff -ur ./arch/arm.ofic/mach-pxa/sharpsl.h ./arch/arm/mach-pxa/sharpsl.h
> --- ./arch/arm.ofic/mach-pxa/sharpsl.h Â2009-09-10 00:13:59.000000000 +0200
> +++ ./arch/arm/mach-pxa/sharpsl.h    2009-10-14 12:12:13.000000000 +0200
> @@ -42,8 +42,23 @@
> Â#define MAX1111_BATT_TEMP Â 2u
> Â#define MAX1111_ACIN_VOLT Â 6u
>
> -extern struct battery_thresh spitz_battery_levels_acin[];
> -extern struct battery_thresh spitz_battery_levels_noac[];
> Âint sharpsl_pm_pxa_read_max1111(int channel);
>
>
> +/*
> + * Constants
> + */
> +#define SHARPSL_CHARGE_ON_TIME_INTERVAL Â Â Â Â(msecs_to_jiffies(1*60*1000)) Â/* 1 min */
> +#define SHARPSL_CHARGE_FINISH_TIME Â Â Â Â Â Â (msecs_to_jiffies(10*60*1000)) /* 10 min */
> +#define SHARPSL_BATCHK_TIME Â Â Â Â Â Â Â Â Â Â(msecs_to_jiffies(15*1000)) Â Â/* 15 sec */
> +#define SHARPSL_BATCHK_TIME_SUSPEND Â Â Â Â Â Â(60*10) Â Â Â Â Â Â Â Â Â Â Â Â/* 10 min */
> +
> +#define SHARPSL_WAIT_CO_TIME Â Â Â Â Â Â Â Â Â 15 Â/* 15 sec */
> +#define SHARPSL_WAIT_DISCHARGE_ON Â Â Â Â Â Â Â100 /* 100 msec */
> +#define SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP Â 10 Â/* 10 msec */
> +#define SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT Â 10 Â/* 10 msec */
> +#define SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN Â 10 Â/* 10 msec */
> +#define SHARPSL_CHARGE_WAIT_TIME Â Â Â Â Â Â Â 15 Â/* 15 msec */
> +#define SHARPSL_CHARGE_CO_CHECK_TIME Â Â Â Â Â 5 Â /* 5 msec */
> +#define SHARPSL_CHARGE_RETRY_CNT Â Â Â Â Â Â Â 1 Â /* eqv. 10 min */
> +
> Only in ./arch/arm/mach-pxa: sharpsl.h~
> diff -ur ./arch/arm.ofic/mach-pxa/sharpsl_pm.c ./arch/arm/mach-pxa/sharpsl_pm.c
> --- ./arch/arm.ofic/mach-pxa/sharpsl_pm.c    2009-10-06 13:48:07.000000000 +0200
> +++ ./arch/arm/mach-pxa/sharpsl_pm.c  Â2009-10-14 12:12:05.000000000 +0200
> @@ -32,25 +32,10 @@
> Â#include <mach/regs-rtc.h>
> Â#include <mach/sharpsl.h>
> Â#include <mach/sharpsl_pm.h>
> +#include <mach/spitz.h>
>
> Â#include "sharpsl.h"
>
> -/*
> - * Constants
> - */
> -#define SHARPSL_CHARGE_ON_TIME_INTERVAL Â Â Â Â(msecs_to_jiffies(1*60*1000)) Â/* 1 min */
> -#define SHARPSL_CHARGE_FINISH_TIME Â Â Â Â Â Â (msecs_to_jiffies(10*60*1000)) /* 10 min */
> -#define SHARPSL_BATCHK_TIME Â Â Â Â Â Â Â Â Â Â(msecs_to_jiffies(15*1000)) Â Â/* 15 sec */
> -#define SHARPSL_BATCHK_TIME_SUSPEND Â Â Â Â Â Â(60*10) Â Â Â Â Â Â Â Â Â Â Â Â/* 10 min */
> -
> -#define SHARPSL_WAIT_CO_TIME Â Â Â Â Â Â Â Â Â 15 Â/* 15 sec */
> -#define SHARPSL_WAIT_DISCHARGE_ON Â Â Â Â Â Â Â100 /* 100 msec */
> -#define SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP Â 10 Â/* 10 msec */
> -#define SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT Â 10 Â/* 10 msec */
> -#define SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN Â 10 Â/* 10 msec */
> -#define SHARPSL_CHARGE_WAIT_TIME Â Â Â Â Â Â Â 15 Â/* 15 msec */
> -#define SHARPSL_CHARGE_CO_CHECK_TIME Â Â Â Â Â 5 Â /* 5 msec */
> -#define SHARPSL_CHARGE_RETRY_CNT Â Â Â Â Â Â Â 1 Â /* eqv. 10 min */
>
> Â/*
> Â* Prototypes
> @@ -72,112 +57,28 @@
> Â* Variables
> Â*/
> Âstruct sharpsl_pm_status sharpsl_pm;
> +EXPORT_SYMBOL(sharpsl_pm);
> Âstatic DECLARE_DELAYED_WORK(toggle_charger, sharpsl_charge_toggle);
> Âstatic DECLARE_DELAYED_WORK(sharpsl_bat, sharpsl_battery_thread);
> ÂDEFINE_LED_TRIGGER(sharpsl_charge_led_trigger);
>
>
>
> -struct battery_thresh spitz_battery_levels_acin[] = {
> - Â Â Â { 213, 100},
> - Â Â Â { 212, Â98},
> - Â Â Â { 211, Â95},
> - Â Â Â { 210, Â93},
> - Â Â Â { 209, Â90},
> - Â Â Â { 208, Â88},
> - Â Â Â { 207, Â85},
> - Â Â Â { 206, Â83},
> - Â Â Â { 205, Â80},
> - Â Â Â { 204, Â78},
> - Â Â Â { 203, Â75},
> - Â Â Â { 202, Â73},
> - Â Â Â { 201, Â70},
> - Â Â Â { 200, Â68},
> - Â Â Â { 199, Â65},
> - Â Â Â { 198, Â63},
> - Â Â Â { 197, Â60},
> - Â Â Â { 196, Â58},
> - Â Â Â { 195, Â55},
> - Â Â Â { 194, Â53},
> - Â Â Â { 193, Â50},
> - Â Â Â { 192, Â48},
> - Â Â Â { 192, Â45},
> - Â Â Â { 191, Â43},
> - Â Â Â { 191, Â40},
> - Â Â Â { 190, Â38},
> - Â Â Â { 190, Â35},
> - Â Â Â { 189, Â33},
> - Â Â Â { 188, Â30},
> - Â Â Â { 187, Â28},
> - Â Â Â { 186, Â25},
> - Â Â Â { 185, Â23},
> - Â Â Â { 184, Â20},
> - Â Â Â { 183, Â18},
> - Â Â Â { 182, Â15},
> - Â Â Â { 181, Â13},
> - Â Â Â { 180, Â10},
> - Â Â Â { 179, Â 8},
> - Â Â Â { 178, Â 5},
> - Â Â Â { Â 0, Â 0},
> -};
> -
> -struct battery_thresh Âspitz_battery_levels_noac[] = {
> - Â Â Â { 213, 100},
> - Â Â Â { 212, Â98},
> - Â Â Â { 211, Â95},
> - Â Â Â { 210, Â93},
> - Â Â Â { 209, Â90},
> - Â Â Â { 208, Â88},
> - Â Â Â { 207, Â85},
> - Â Â Â { 206, Â83},
> - Â Â Â { 205, Â80},
> - Â Â Â { 204, Â78},
> - Â Â Â { 203, Â75},
> - Â Â Â { 202, Â73},
> - Â Â Â { 201, Â70},
> - Â Â Â { 200, Â68},
> - Â Â Â { 199, Â65},
> - Â Â Â { 198, Â63},
> - Â Â Â { 197, Â60},
> - Â Â Â { 196, Â58},
> - Â Â Â { 195, Â55},
> - Â Â Â { 194, Â53},
> - Â Â Â { 193, Â50},
> - Â Â Â { 192, Â48},
> - Â Â Â { 191, Â45},
> - Â Â Â { 190, Â43},
> - Â Â Â { 189, Â40},
> - Â Â Â { 188, Â38},
> - Â Â Â { 187, Â35},
> - Â Â Â { 186, Â33},
> - Â Â Â { 185, Â30},
> - Â Â Â { 184, Â28},
> - Â Â Â { 183, Â25},
> - Â Â Â { 182, Â23},
> - Â Â Â { 181, Â20},
> - Â Â Â { 180, Â18},
> - Â Â Â { 179, Â15},
> - Â Â Â { 178, Â13},
> - Â Â Â { 177, Â10},
> - Â Â Â { 176, Â 8},
> - Â Â Â { 175, Â 5},
> - Â Â Â { Â 0, Â 0},
> -};
> -
> Â/* MAX1111 Commands */
> -#define MAXCTRL_PD0 Â Â Â1u << 0
> -#define MAXCTRL_PD1 Â Â Â1u << 1
> -#define MAXCTRL_SGL Â Â Â1u << 2
> -#define MAXCTRL_UNI Â Â Â1u << 3
> +#define MAXCTRL_PD0 Â Â Â(1u << 0)
> +#define MAXCTRL_PD1 Â Â Â(1u << 1)
> +#define MAXCTRL_SGL Â Â Â(1u << 2)
> +#define MAXCTRL_UNI Â Â Â(1u << 3)
> Â#define MAXCTRL_SEL_SH Â 4
> -#define MAXCTRL_STR Â Â Â1u << 7
> +#define MAXCTRL_STR Â Â Â(1u << 7)
>
> Â/*
> Â* Read MAX1111 ADC
> Â*/
> Âint sharpsl_pm_pxa_read_max1111(int channel)
> Â{
> - Â Â Â if (machine_is_tosa()) // Ugly, better move this function into another module
> + Â Â Â /* Ugly, better move this function into another module */
> + Â Â Â if (machine_is_tosa())
> Â Â Â Â Â Âreturn 0;
>
> Â#ifdef CONFIG_CORGI_SSP_DEPRECATED
> @@ -193,7 +94,7 @@
> Â#endif
> Â}
>
> -static int get_percentage(int voltage)
> +int get_percentage(int voltage)
> Â{
> Â Â Â Âint i = sharpsl_pm.machinfo->bat_levels - 1;
> Â Â Â Âint bl_status = sharpsl_pm.machinfo->backlight_get_status ? sharpsl_pm.machinfo->backlight_get_status() : 0;
> @@ -209,6 +110,7 @@
>
> Â Â Â Âreturn thresh[i].percentage;
> Â}
> +EXPORT_SYMBOL(get_percentage);
>
> Âstatic int get_apm_status(int voltage)
> Â{
> @@ -238,7 +140,7 @@
>
> Âstatic void sharpsl_battery_thread(struct work_struct *private_)
> Â{
> - Â Â Â int voltage, percent, apm_status, i = 0;
> + Â Â Â int voltage, percent, apm_status, i;
>
> Â Â Â Âif (!sharpsl_pm.machinfo)
> Â Â Â Â Â Â Â Âreturn;
> @@ -250,15 +152,14 @@
> Â Â Â Â Â Â Â Â Â Â Â Â&& time_after(jiffies, sharpsl_pm.charge_start_time + ÂSHARPSL_CHARGE_ON_TIME_INTERVAL))
> Â Â Â Â Â Â Â Âschedule_delayed_work(&toggle_charger, 0);
>
> - Â Â Â while(1) {
> + Â Â Â for (i = 0; i < 5; i++) {
> Â Â Â Â Â Â Â Âvoltage = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT);
> -
> - Â Â Â Â Â Â Â if (voltage > 0) break;
> - Â Â Â Â Â Â Â if (i++ > 5) {
> - Â Â Â Â Â Â Â Â Â Â Â voltage = sharpsl_pm.machinfo->bat_levels_noac[0].voltage;
> - Â Â Â Â Â Â Â Â Â Â Â dev_warn(sharpsl_pm.dev, "Warning: Cannot read main battery!\n");
> + Â Â Â Â Â Â Â if (voltage > 0)
> Â Â Â Â Â Â Â Â Â Â Â Âbreak;
> - Â Â Â Â Â Â Â }
> + Â Â Â }
> + Â Â Â if (voltage <= 0) {
> + Â Â Â Â Â Â Â voltage = sharpsl_pm.machinfo->bat_levels_noac[0].voltage;
> + Â Â Â Â Â Â Â dev_warn(sharpsl_pm.dev, "Warning: Cannot read main battery!\n");
> Â Â Â Â}
>
> Â Â Â Âvoltage = sharpsl_average_value(voltage);
> @@ -266,8 +167,10 @@
> Â Â Â Âpercent = get_percentage(voltage);
>
> Â Â Â Â/* At low battery voltages, the voltage has a tendency to start
> - Â Â Â Â Â creeping back up so we try to avoid this here */
> - Â Â Â if ((sharpsl_pm.battstat.ac_status == APM_AC_ONLINE) || (apm_status == APM_BATTERY_STATUS_HIGH) || Âpercent <= sharpsl_pm.battstat.mainbat_percent) {
> + Â Â Â Â Âcreeping back up so we try to avoid this here */
> + Â Â Â if ((sharpsl_pm.battstat.ac_status == APM_AC_ONLINE)
> + Â Â Â Â Â || (apm_status == APM_BATTERY_STATUS_HIGH)
> + Â Â Â Â Â || percent <= sharpsl_pm.battstat.mainbat_percent) {
> Â Â Â Â Â Â Â Âsharpsl_pm.battstat.mainbat_voltage = voltage;
> Â Â Â Â Â Â Â Âsharpsl_pm.battstat.mainbat_status = apm_status;
> Â Â Â Â Â Â Â Âsharpsl_pm.battstat.mainbat_percent = percent;
> @@ -279,8 +182,8 @@
> Â#ifdef CONFIG_BACKLIGHT_CORGI
> Â Â Â Â/* If battery is low. limit backlight intensity to save power. */
> Â Â Â Âif ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE)
> - Â Â Â Â Â Â Â Â Â Â Â && ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW) ||
> - Â Â Â Â Â Â Â Â Â Â Â (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL))) {
> + Â Â Â Â Â && ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW)
> + Â Â Â Â Â || (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL))) {
> Â Â Â Â Â Â Â Âif (!(sharpsl_pm.flags & SHARPSL_BL_LIMIT)) {
> Â Â Â Â Â Â Â Â Â Â Â Âsharpsl_pm.machinfo->backlight_limit(1);
> Â Â Â Â Â Â Â Â Â Â Â Âsharpsl_pm.flags |= SHARPSL_BL_LIMIT;
> @@ -293,8 +196,8 @@
>
> Â Â Â Â/* Suspend if critical battery level */
> Â Â Â Âif ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE)
> - Â Â Â Â Â Â Â Â Â Â Â && (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL)
> - Â Â Â Â Â Â Â Â Â Â Â && !(sharpsl_pm.flags & SHARPSL_APM_QUEUED)) {
> + Â Â Â Â Â Â&& (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL)
> + Â Â Â Â Â Â&& !(sharpsl_pm.flags & SHARPSL_APM_QUEUED)) {
> Â Â Â Â Â Â Â Âsharpsl_pm.flags |= SHARPSL_APM_QUEUED;
> Â Â Â Â Â Â Â Âdev_err(sharpsl_pm.dev, "Fatal Off\n");
> Â Â Â Â Â Â Â Âapm_queue_event(APM_CRITICAL_SUSPEND);
> @@ -339,6 +242,8 @@
>
> Âstatic void sharpsl_charge_error(void)
> Â{
> + Â Â Â dev_warn(sharpsl_pm.dev, "Charger Error\n");
> +
> Â Â Â Âsharpsl_pm_led(SHARPSL_LED_ERROR);
> Â Â Â Âsharpsl_pm.machinfo->charge(0);
> Â Â Â Âsharpsl_pm.charge_mode = CHRG_ERROR;
> @@ -346,7 +251,7 @@
>
> Âstatic void sharpsl_charge_toggle(struct work_struct *private_)
> Â{
> - Â Â Â dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies);
> + Â Â Â dev_dbg(sharpsl_pm.dev, "Toggling Charger at time: %lx\n", jiffies);
>
> Â Â Â Âif (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) {
> Â Â Â Â Â Â Â Âsharpsl_charge_off();
> @@ -368,7 +273,7 @@
> Â{
> Â Â Â Âint acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN);
>
> - Â Â Â dev_dbg(sharpsl_pm.dev, "AC Status: %d\n",acin);
> + Â Â Â dev_dbg(sharpsl_pm.dev, "AC Status: %d\n", acin);
>
> Â Â Â Âsharpsl_average_clear();
> Â Â Â Âif (acin && (sharpsl_pm.charge_mode != CHRG_ON))
> @@ -472,14 +377,14 @@
> Â Â Â Âsharpsl_ad[sharpsl_ad_index] = ad;
> Â Â Â Âsharpsl_ad_index++;
> Â Â Â Âif (sharpsl_ad_index >= SHARPSL_CNV_VALUE_NUM) {
> - Â Â Â Â Â Â Â for (i=0; i < (SHARPSL_CNV_VALUE_NUM-1); i++)
> + Â Â Â Â Â Â Â for (i = 0; i < (SHARPSL_CNV_VALUE_NUM-1); i++)
> Â Â Â Â Â Â Â Â Â Â Â Âsharpsl_ad[i] = sharpsl_ad[i+1];
> Â Â Â Â Â Â Â Âsharpsl_ad_index = SHARPSL_CNV_VALUE_NUM - 1;
> Â Â Â Â}
> - Â Â Â for (i=0; i < sharpsl_ad_index; i++)
> + Â Â Â for (i = 0; i < sharpsl_ad_index; i++)
> Â Â Â Â Â Â Â Âad_val += sharpsl_ad[i];
>
> - Â Â Â return (ad_val / sharpsl_ad_index);
> + Â Â Â return ad_val / sharpsl_ad_index;
> Â}
>
> Â/*
> @@ -492,8 +397,8 @@
>
> Â Â Â Â/* Find MAX val */
> Â Â Â Âtemp = val[0];
> - Â Â Â j=0;
> - Â Â Â for (i=1; i<5; i++) {
> + Â Â Â j = 0;
> + Â Â Â for (i = 1; i < 5; i++) {
> Â Â Â Â Â Â Â Âif (temp < val[i]) {
> Â Â Â Â Â Â Â Â Â Â Â Âtemp = val[i];
> Â Â Â Â Â Â Â Â Â Â Â Âj = i;
> @@ -502,21 +407,21 @@
>
> Â Â Â Â/* Find MIN val */
> Â Â Â Âtemp = val[4];
> - Â Â Â k=4;
> - Â Â Â for (i=3; i>=0; i--) {
> + Â Â Â k = 4;
> + Â Â Â for (i = 3; i >= 0; i--) {
> Â Â Â Â Â Â Â Âif (temp > val[i]) {
> Â Â Â Â Â Â Â Â Â Â Â Âtemp = val[i];
> Â Â Â Â Â Â Â Â Â Â Â Âk = i;
> Â Â Â Â Â Â Â Â}
> Â Â Â Â}
>
> - Â Â Â for (i=0; i<5; i++)
> - Â Â Â Â Â Â Â if (i != j && i != k )
> + Â Â Â for (i = 0; i < 5; i++)
> + Â Â Â Â Â Â Â if (i != j && i != k)
> Â Â Â Â Â Â Â Â Â Â Â Âsum += val[i];
>
> Â Â Â Âdev_dbg(sharpsl_pm.dev, "Average: %d from values: %d, %d, %d, %d, %d\n", sum/3, val[0], val[1], val[2], val[3], val[4]);
>
> - Â Â Â return (sum/3);
> + Â Â Â return sum/3;
> Â}
>
> Âstatic int sharpsl_check_battery_temp(void)
> @@ -524,7 +429,7 @@
> Â Â Â Âint val, i, buff[5];
>
> Â Â Â Â/* Check battery temperature */
> - Â Â Â for (i=0; i<5; i++) {
> + Â Â Â for (i = 0; i < 5; i++) {
> Â Â Â Â Â Â Â Âmdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP);
> Â Â Â Â Â Â Â Âsharpsl_pm.machinfo->measure_temp(1);
> Â Â Â Â Â Â Â Âmdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP);
> @@ -535,8 +440,10 @@
> Â Â Â Âval = get_select_val(buff);
>
> Â Â Â Âdev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val);
> - Â Â Â if (val > sharpsl_pm.machinfo->charge_on_temp) {
> - Â Â Â Â Â Â Â printk(KERN_WARNING "Not charging: temperature out of limits.\n");
> + Â Â Â /* FIXME: this should catch battery read errors, but we should
> + Â Â Â Â Âprobably avoid charging in <0C temperatures, too. */
> + Â Â Â if ((val < 0) || (val > sharpsl_pm.machinfo->charge_on_temp)) {
> + Â Â Â Â Â Â Â dev_warn(sharpsl_pm.dev, "Not charging: temperature %d out of limits.\n", val);
> Â Â Â Â Â Â Â Âreturn -1;
> Â Â Â Â}
>
> @@ -557,7 +464,7 @@
> Â Â Â Â Â Â Â Âsharpsl_pm.machinfo->discharge1(1);
>
> Â Â Â Â/* Check battery voltage */
> - Â Â Â for (i=0; i<5; i++) {
> + Â Â Â for (i = 0; i < 5; i++) {
> Â Â Â Â Â Â Â Âbuff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT);
> Â Â Â Â Â Â Â Âmdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT);
> Â Â Â Â}
> @@ -581,16 +488,16 @@
> Â{
> Â Â Â Âint temp, i, buff[5];
>
> - Â Â Â for (i=0; i<5; i++) {
> + Â Â Â for (i = 0; i < 5; i++) {
> Â Â Â Â Â Â Â Âbuff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_ACIN_VOLT);
> Â Â Â Â Â Â Â Âmdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN);
> Â Â Â Â}
>
> Â Â Â Âtemp = get_select_val(buff);
> - Â Â Â dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp);
> + Â Â Â dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n", temp);
>
> Â Â Â Âif ((temp > sharpsl_pm.machinfo->charge_acin_high) || (temp < sharpsl_pm.machinfo->charge_acin_low)) {
> - Â Â Â Â Â Â Â dev_err(sharpsl_pm.dev, "Error: AC check failed.\n");
> + Â Â Â Â Â Â Â dev_err(sharpsl_pm.dev, "Error: AC check failed: voltage %d.\n", temp);
> Â Â Â Â Â Â Â Âreturn -1;
> Â Â Â Â}
>
> @@ -624,9 +531,9 @@
>
> Âstatic void corgi_goto_sleep(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state)
> Â{
> - Â Â Â dev_dbg(sharpsl_pm.dev, "Time is: %08x\n",RCNR);
> + Â Â Â dev_dbg(sharpsl_pm.dev, "Time is: %08x\n", RCNR);
>
> - Â Â Â dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n",sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG);
> + Â Â Â dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n", sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG);
> Â Â Â Â/* not charging and AC-IN! */
>
> Â Â Â Âif ((sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG) && (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN))) {
> @@ -644,12 +551,12 @@
> Â Â Â Âif ((sharpsl_pm.charge_mode == CHRG_ON) && ((alarm_enable && ((alarm_time - RCNR) > (SHARPSL_BATCHK_TIME_SUSPEND + 30))) || !alarm_enable)) {
> Â Â Â Â Â Â Â ÂRTSR &= RTSR_ALE;
> Â Â Â Â Â Â Â ÂRTAR = RCNR + SHARPSL_BATCHK_TIME_SUSPEND;
> - Â Â Â Â Â Â Â dev_dbg(sharpsl_pm.dev, "Charging alarm at: %08x\n",RTAR);
> + Â Â Â Â Â Â Â dev_dbg(sharpsl_pm.dev, "Charging alarm at: %08x\n", RTAR);
> Â Â Â Â Â Â Â Âsharpsl_pm.flags |= SHARPSL_ALARM_ACTIVE;
> Â Â Â Â} else if (alarm_enable) {
> Â Â Â Â Â Â Â ÂRTSR &= RTSR_ALE;
> Â Â Â Â Â Â Â ÂRTAR = alarm_time;
> - Â Â Â Â Â Â Â dev_dbg(sharpsl_pm.dev, "User alarm at: %08x\n",RTAR);
> + Â Â Â Â Â Â Â dev_dbg(sharpsl_pm.dev, "User alarm at: %08x\n", RTAR);
> Â Â Â Â} else {
> Â Â Â Â Â Â Â Âdev_dbg(sharpsl_pm.dev, "No alarms set.\n");
> Â Â Â Â}
> @@ -658,19 +565,20 @@
>
> Â Â Â Âsharpsl_pm.machinfo->postsuspend();
>
> - Â Â Â dev_dbg(sharpsl_pm.dev, "Corgi woken up from suspend: %08x\n",PEDR);
> +
> + Â Â Â dev_dbg(sharpsl_pm.dev, "Corgi woken up from suspend: %08x\n", PEDR);
> Â}
>
> Âstatic int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state)
> Â{
> - Â Â Â if (!sharpsl_pm.machinfo->should_wakeup(!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE) && alarm_enable) )
> - Â Â Â {
> + Âreturn 0;
> + Â Â Â if (!sharpsl_pm.machinfo->should_wakeup(!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE) && alarm_enable)) {
> Â Â Â Â Â Â Â Âif (!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE)) {
> Â Â Â Â Â Â Â Â Â Â Â Âdev_dbg(sharpsl_pm.dev, "No user triggered wakeup events and not charging. Strange. Suspend.\n");
> Â Â Â Â Â Â Â Â Â Â Â Âcorgi_goto_sleep(alarm_time, alarm_enable, state);
> Â Â Â Â Â Â Â Â Â Â Â Âreturn 1;
> Â Â Â Â Â Â Â Â}
> - Â Â Â Â Â Â Â if(sharpsl_off_charge_battery()) {
> + Â Â Â Â Â Â Â if (sharpsl_off_charge_battery()) {
> Â Â Â Â Â Â Â Â Â Â Â Âdev_dbg(sharpsl_pm.dev, "Charging. Suspend...\n");
> Â Â Â Â Â Â Â Â Â Â Â Âcorgi_goto_sleep(alarm_time, alarm_enable, state);
> Â Â Â Â Â Â Â Â Â Â Â Âreturn 1;
> @@ -697,7 +605,7 @@
>
> Â Â Â Âcorgi_goto_sleep(alarm_time, alarm_status, state);
>
> - Â Â Â while (corgi_enter_suspend(alarm_time,alarm_status,state))
> + Â Â Â while (corgi_enter_suspend(alarm_time, alarm_status, state))
> Â Â Â Â Â Â Â Â{}
>
> Â Â Â Âif (sharpsl_pm.machinfo->earlyresume)
> @@ -732,7 +640,7 @@
> Â Â Â Â Â Â Â Âsharpsl_pm.machinfo->discharge1(1);
>
> Â Â Â Â/* Check battery : check inserting battery ? */
> - Â Â Â for (i=0; i<5; i++) {
> + Â Â Â for (i = 0; i < 5; i++) {
> Â Â Â Â Â Â Â Âbuff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT);
> Â Â Â Â Â Â Â Âmdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT);
> Â Â Â Â}
> @@ -812,7 +720,7 @@
> Â Â Â Â Â Â Â Âmdelay(SHARPSL_CHARGE_CO_CHECK_TIME);
>
> Â Â Â Â Â Â Â Âtime = RCNR;
> - Â Â Â Â Â Â Â while(1) {
> + Â Â Â Â Â Â Â while (1) {
> Â Â Â Â Â Â Â Â Â Â Â Â/* Check if any wakeup event had occurred */
> Â Â Â Â Â Â Â Â Â Â Â Âif (sharpsl_pm.machinfo->charger_wakeup() != 0)
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âreturn 0;
> @@ -835,9 +743,9 @@
> Â Â Â Âmdelay(SHARPSL_CHARGE_CO_CHECK_TIME);
>
> Â Â Â Âtime = RCNR;
> - Â Â Â while(1) {
> + Â Â Â while (1) {
> Â Â Â Â Â Â Â Â/* Check if any wakeup event had occurred */
> - Â Â Â Â Â Â Â if (sharpsl_pm.machinfo->charger_wakeup() != 0)
> + Â Â Â Â Â Â Â if (sharpsl_pm.machinfo->charger_wakeup())
> Â Â Â Â Â Â Â Â Â Â Â Âreturn 0;
> Â Â Â Â Â Â Â Â/* Check for timeout */
> Â Â Â Â Â Â Â Âif ((RCNR-time) > SHARPSL_WAIT_CO_TIME) {
> @@ -864,12 +772,12 @@
>
> Âstatic ssize_t battery_percentage_show(struct device *dev, struct device_attribute *attr, char *buf)
> Â{
> - Â Â Â return sprintf(buf, "%d\n",sharpsl_pm.battstat.mainbat_percent);
> + Â Â Â return sprintf(buf, "%d\n", sharpsl_pm.battstat.mainbat_percent);
> Â}
>
> Âstatic ssize_t battery_voltage_show(struct device *dev, struct device_attribute *attr, char *buf)
> Â{
> - Â Â Â return sprintf(buf, "%d\n",sharpsl_pm.battstat.mainbat_voltage);
> + Â Â Â return sprintf(buf, "%d\n", sharpsl_pm.battstat.mainbat_voltage);
> Â}
>
> Âstatic DEVICE_ATTR(battery_percentage, 0444, battery_percentage_show, NULL);
> @@ -943,7 +851,6 @@
> Â Â Â Â Â Â Â Â}
> Â Â Â Â}
>
> - Â Â Â if (sharpsl_pm.machinfo->batfull_irq)
> - Â Â Â {
> + Â Â Â if (sharpsl_pm.machinfo->batfull_irq) {
> Â Â Â Â Â Â Â Â/* Register interrupt handler. */
> Â Â Â Â Â Â Â Âif (request_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr, IRQF_DISABLED | IRQF_TRIGGER_RISING, "CO", sharpsl_chrg_full_isr)) {
> diff -ur ./arch/arm.ofic/mach-pxa/spitz.c ./arch/arm/mach-pxa/spitz.c
> --- ./arch/arm.ofic/mach-pxa/spitz.c  Â2009-10-06 13:48:07.000000000 +0200
> +++ ./arch/arm/mach-pxa/spitz.c 2009-10-14 11:01:36.000000000 +0200
> @@ -686,12 +733,19 @@
> Â Â Â Â.dev.platform_data = &sharpsl_rom_data,
> Â};
>
> +static struct platform_device spitz_battery_device = {
> +    .name  = "spitz-battery",
> +    .id   = -1,
> +};
> +
> +
> Âstatic struct platform_device *devices[] __initdata = {
> Â Â Â Â&spitzscoop_device,
> Â Â Â Â&spitzkbd_device,
> Â Â Â Â&spitzled_device,
> Â Â Â Â&sharpsl_nand_device,
> Â Â Â Â&sharpsl_rom_device,
> + Â Â Â &spitz_battery_device,
> Â};
>
> Âstatic void spitz_poweroff(void)
> --- ./arch/arm.ofic/mach-pxa/spitz_pm.c 2009-09-10 00:13:59.000000000 +0200
> +++ ./arch/arm/mach-pxa/spitz_pm.c   Â2009-10-19 07:28:42.000000000 +0200
> @@ -37,6 +37,93 @@
>
> Âstatic int spitz_last_ac_status;
>
> +static const struct battery_thresh spitz_battery_levels_acin[] = {
> + Â Â Â { 213, 100},
> + Â Â Â { 212, Â98},
> + Â Â Â { 211, Â95},
> + Â Â Â { 210, Â93},
> + Â Â Â { 209, Â90},
> + Â Â Â { 208, Â88},
> + Â Â Â { 207, Â85},
> + Â Â Â { 206, Â83},
> + Â Â Â { 205, Â80},
> + Â Â Â { 204, Â78},
> + Â Â Â { 203, Â75},
> + Â Â Â { 202, Â73},
> + Â Â Â { 201, Â70},
> + Â Â Â { 200, Â68},
> + Â Â Â { 199, Â65},
> + Â Â Â { 198, Â63},
> + Â Â Â { 197, Â60},
> + Â Â Â { 196, Â58},
> + Â Â Â { 195, Â55},
> + Â Â Â { 194, Â53},
> + Â Â Â { 193, Â50},
> + Â Â Â { 192, Â48},
> + Â Â Â { 192, Â45},
> + Â Â Â { 191, Â43},
> + Â Â Â { 191, Â40},
> + Â Â Â { 190, Â38},
> + Â Â Â { 190, Â35},
> + Â Â Â { 189, Â33},
> + Â Â Â { 188, Â30},
> + Â Â Â { 187, Â28},
> + Â Â Â { 186, Â25},
> + Â Â Â { 185, Â23},
> + Â Â Â { 184, Â20},
> + Â Â Â { 183, Â18},
> + Â Â Â { 182, Â15},
> + Â Â Â { 181, Â13},
> + Â Â Â { 180, Â10},
> + Â Â Â { 179, Â 8},
> + Â Â Â { 178, Â 5},
> + Â Â Â { Â 0, Â 0},
> +};
> +
> +static const struct battery_thresh Âspitz_battery_levels_noac[] = {
> + Â Â Â { 213, 100},
> + Â Â Â { 212, Â98},
> + Â Â Â { 211, Â95},
> + Â Â Â { 210, Â93},
> + Â Â Â { 209, Â90},
> + Â Â Â { 208, Â88},
> + Â Â Â { 207, Â85},
> + Â Â Â { 206, Â83},
> + Â Â Â { 205, Â80},
> + Â Â Â { 204, Â78},
> + Â Â Â { 203, Â75},
> + Â Â Â { 202, Â73},
> + Â Â Â { 201, Â70},
> + Â Â Â { 200, Â68},
> + Â Â Â { 199, Â65},
> + Â Â Â { 198, Â63},
> + Â Â Â { 197, Â60},
> + Â Â Â { 196, Â58},
> + Â Â Â { 195, Â55},
> + Â Â Â { 194, Â53},
> + Â Â Â { 193, Â50},
> + Â Â Â { 192, Â48},
> + Â Â Â { 191, Â45},
> + Â Â Â { 190, Â43},
> + Â Â Â { 189, Â40},
> + Â Â Â { 188, Â38},
> + Â Â Â { 187, Â35},
> + Â Â Â { 186, Â33},
> + Â Â Â { 185, Â30},
> + Â Â Â { 184, Â28},
> + Â Â Â { 183, Â25},
> + Â Â Â { 182, Â23},
> + Â Â Â { 181, Â20},
> + Â Â Â { 180, Â18},
> + Â Â Â { 179, Â15},
> + Â Â Â { 178, Â13},
> + Â Â Â { 177, Â10},
> + Â Â Â { 176, Â 8},
> + Â Â Â { 175, Â 5},
> + Â Â Â { Â 0, Â 0},
> +};
> +
> +
> Âstatic void spitz_charger_init(void)
> Â{
> Â Â Â Âpxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN);
> @@ -103,7 +190,7 @@
> Â Â Â ÂPFER = GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET);
> Â Â Â ÂPWER = GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET) | PWER_RTC;
> Â Â Â ÂPKWR = GPIO_bit(SPITZ_GPIO_SYNC) | GPIO_bit(SPITZ_GPIO_KEY_INT) | GPIO_bit(SPITZ_GPIO_RESET);
> - Â Â Â PKSR = 0xffffffff; // clear
> + Â Â Â PKSR = 0xffffffff; /* clear */
>
> Â Â Â Â/* nRESET_OUT Disable */
> Â Â Â ÂPSLR |= PSLR_SL_ROD;
> @@ -149,7 +236,7 @@
> Â Â Â Âif (resume_on_alarm && (PEDR & PWER_RTC))
> Â Â Â Â Â Â Â Âis_resume |= PWER_RTC;
>
> - Â Â Â dev_dbg(sharpsl_pm.dev, "is_resume: %x\n",is_resume);
> + Â Â Â dev_dbg(sharpsl_pm.dev, "is_resume: %x\n", is_resume);
> Â Â Â Âreturn is_resume;
> Â}
>
> @@ -160,15 +247,15 @@
>
> Âunsigned long spitzpm_read_devdata(int type)
> Â{
> - Â Â Â switch(type) {
> + Â Â Â switch (type) {
> Â Â Â Âcase SHARPSL_STATUS_ACIN:
> Â Â Â Â Â Â Â Âreturn (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0);
> Â Â Â Âcase SHARPSL_STATUS_LOCK:
> - Â Â Â Â Â Â Â return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock);
> + Â Â Â Â Â Â Â return !!READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock);
> Â Â Â Âcase SHARPSL_STATUS_CHRGFULL:
> - Â Â Â Â Â Â Â return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull);
> + Â Â Â Â Â Â Â return !!READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull);
> Â Â Â Âcase SHARPSL_STATUS_FATAL:
> - Â Â Â Â Â Â Â return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal);
> + Â Â Â Â Â Â Â return !!READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal);
> Â Â Â Âcase SHARPSL_ACIN_VOLT:
> Â Â Â Â Â Â Â Âreturn sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT);
> Â Â Â Âcase SHARPSL_BATT_TEMP:
> @@ -179,6 +266,11 @@
> Â Â Â Â}
> Â}
>
> +int backlight_get_status(void)
> +{
> + Â Â Â return 0;
> +}
> +
> Âstruct sharpsl_charger_machinfo spitz_pm_machinfo = {
>    Â.init       = spitz_charger_init,
>    Â.exit       = NULL,
> @@ -199,8 +291,9 @@
> Â#if defined(CONFIG_LCD_CORGI)
> Â Â Â Â.backlight_limit = corgi_lcd_limit_intensity,
> Â#elif defined(CONFIG_BACKLIGHT_CORGI)
> - Â Â Â Â.backlight_limit Â= corgibl_limit_intensity,
> + Â Â Â .backlight_limit Â= corgibl_limit_intensity,
> Â#endif
> +// Â Â .backlight_get_status = backlight_get_status,
>    Â.charge_on_volt  = SHARPSL_CHARGE_ON_VOLT,
>    Â.charge_on_temp  = SHARPSL_CHARGE_ON_TEMP,
> Â Â Â Â.charge_acin_high = SHARPSL_CHARGE_ON_ACIN_HIGH,
> @@ -241,7 +334,7 @@
>
> Âstatic void spitzpm_exit(void)
> Â{
> - Â Â Â platform_device_unregister(spitzpm_device);
> + Â Â Â platform_device_unregister(spitzpm_device);
> Â}
>
> Âmodule_init(spitzpm_init);
>
>
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/