#include <linux/mfd/wm831x/auxadc.h>
#include <linux/mfd/wm831x/pmu.h>
#include <linux/mfd/wm831x/pdata.h>
+#include <linux/mfd/wm831x/irq.h>
#define WM831X_DEBUG
#undef WM831X_DEBUG
#define batt_num 52
static int batt_step_table[batt_num] = {
- 3370,3405,3440,3475,3505,3530,
- 3550,3567,3584,3600,3615,
+ 3380,3405,3440,3475,3505,3525,
+ 3540,3557,3570,3580,3610,
3630,3643,3655,3665,3673,
3680,3687,3693,3699,3705,
3710,3714,3718,3722,3726,
"START",
};
-#if 0
static irqreturn_t wm831x_bat_irq(int irq, void *data)
{
struct wm831x_power *wm831x_power = data;
struct wm831x *wm831x = wm831x_power->wm831x;
-
- dev_dbg(wm831x->dev, "Battery status changed: %d\n", irq);
- WM_BATT_DBG("%s:Battery status changed %d\n", __FUNCTION__, irq);
+ int irq0;
+
+ irq0 = wm831x->irq_base + WM831X_IRQ_CHG_BATT_HOT + 1;
+ dev_crit(wm831x->dev, "battery changed: i=%d\n", irq-irq0);
+
/* The battery charger is autonomous so we don't need to do
* anything except kick user space */
power_supply_changed(&wm831x_power->battery);
return IRQ_HANDLED;
}
-#endif
/*********************************************************************
* Initialisation
*level = wm831x_power->batt_info.level;
if (*level >= 100)
- *level = 99;
+ *level = 100;
if (*level < 0)
*level = 0;
}
struct power_supply *usb;
struct power_supply *battery;
struct power_supply *wall;
- int ret, irq;
+ int ret, irq, i;
power = kzalloc(sizeof(struct wm831x_power), GFP_KERNEL);
if (power == NULL)
irq, ret);
goto err_syslo;
}
-#if 0 //ʹÓòéѯµÄ·½Ê½
+
for (i = 0; i < ARRAY_SIZE(wm831x_bat_irqs); i++) {
irq = platform_get_irq_byname(pdev, wm831x_bat_irqs[i]);
ret = request_threaded_irq(irq, NULL, wm831x_bat_irq,
goto err_bat_irq;
}
}
-#endif
+
power->interval = TIMER_MS_COUNTS;
power->batt_info.level = 100;
power->batt_info.voltage = 4200;
printk("%s:wm831x_power initialized\n",__FUNCTION__);
power_test_sysfs_init();
return ret;
-#if 0
+
err_bat_irq:
for (; i >= 0; i--) {
irq = platform_get_irq_byname(pdev, wm831x_bat_irqs[i]);
}
irq = platform_get_irq_byname(pdev, "PWR SRC");
free_irq(irq, power);
-#endif
+
err_syslo:
irq = platform_get_irq_byname(pdev, "SYSLO");
free_irq(irq, power);
#ifdef CONFIG_PM
static int wm831x_battery_suspend(struct platform_device *dev, pm_message_t state)
{
- //struct wm831x_power *power = (struct wm831x_power *)platform_get_drvdata(dev);
- //flush_scheduled_work();
- //del_timer(&power->timer);
+ struct wm831x_power *power = (struct wm831x_power *)platform_get_drvdata(dev);
+ flush_scheduled_work();
+ del_timer(&power->timer);
return 0;
}
static int wm831x_battery_resume(struct platform_device *dev)
{
- //struct wm831x_power *power = (struct wm831x_power *)platform_get_drvdata(dev);
- //power->timer.expires = jiffies + msecs_to_jiffies(power->interval);
- //add_timer(&power->timer);
+ struct wm831x_power *power = (struct wm831x_power *)platform_get_drvdata(dev);
+ power->timer.expires = jiffies + msecs_to_jiffies(power->interval);
+ add_timer(&power->timer);
return 0;
}
#else