Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 165513
b: refs/heads/master
c: b8bdc1d
h: refs/heads/master
i:
  165511: 1698114
v: v3
  • Loading branch information
Marek Vasut authored and Anton Vorontsov committed Sep 4, 2009
1 parent cd6e761 commit f1d258e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 32bb0e0c778a4a6cd4534a5b98f08cd45e9ab5b9
refs/heads/master: b8bdc1d0cfc488ac0d94724639f9a61b0a5a1d40
32 changes: 27 additions & 5 deletions trunk/drivers/power/wm97xx_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,29 @@
#include <linux/spinlock.h>
#include <linux/interrupt.h>
#include <linux/gpio.h>
#include <linux/wm97xx_batt.h>

static DEFINE_MUTEX(bat_lock);
static struct work_struct bat_work;
struct mutex work_lock;
static int bat_status = POWER_SUPPLY_STATUS_UNKNOWN;
static struct wm97xx_batt_info *pdata;
static struct wm97xx_batt_info *gpdata;
static enum power_supply_property *prop;

static unsigned long wm97xx_read_bat(struct power_supply *bat_ps)
{
struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;

return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
pdata->batt_aux) * pdata->batt_mult /
pdata->batt_div;
}

static unsigned long wm97xx_read_temp(struct power_supply *bat_ps)
{
struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;

return wm97xx_read_aux_adc(bat_ps->dev->parent->driver_data,
pdata->temp_aux) * pdata->temp_mult /
pdata->temp_div;
Expand All @@ -49,6 +54,9 @@ static int wm97xx_bat_get_property(struct power_supply *bat_ps,
enum power_supply_property psp,
union power_supply_propval *val)
{
struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;

switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
val->intval = bat_status;
Expand Down Expand Up @@ -97,6 +105,8 @@ static void wm97xx_bat_external_power_changed(struct power_supply *bat_ps)
static void wm97xx_bat_update(struct power_supply *bat_ps)
{
int old_status = bat_status;
struct wm97xx_pdata *wmdata = bat_ps->dev->parent->platform_data;
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;

mutex_lock(&work_lock);

Expand Down Expand Up @@ -149,14 +159,23 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
int ret = 0;
int props = 1; /* POWER_SUPPLY_PROP_PRESENT */
int i = 0;
struct wm97xx_pdata *wmdata = dev->dev.platform_data;
struct wm97xx_batt_pdata *pdata;

if (gpdata) {
dev_err(&dev->dev, "Do not pass platform_data through "
"wm97xx_bat_set_pdata!\n");
return -EINVAL;
} else
pdata = wmdata->batt_pdata;

if (dev->id != -1)
return -EINVAL;

mutex_init(&work_lock);

if (!pdata) {
dev_err(&dev->dev, "Please use wm97xx_bat_set_pdata\n");
dev_err(&dev->dev, "No platform_data supplied\n");
return -EINVAL;
}

Expand Down Expand Up @@ -229,6 +248,9 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)

static int __devexit wm97xx_bat_remove(struct platform_device *dev)
{
struct wm97xx_pdata *wmdata = dev->dev.platform_data;
struct wm97xx_batt_pdata *pdata = wmdata->batt_pdata;

if (pdata && pdata->charge_gpio && pdata->charge_gpio >= 0)
gpio_free(pdata->charge_gpio);
flush_scheduled_work();
Expand Down Expand Up @@ -258,9 +280,9 @@ static void __exit wm97xx_bat_exit(void)
platform_driver_unregister(&wm97xx_bat_driver);
}

void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data)
void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data)
{
pdata = data;
gpdata = data;
}
EXPORT_SYMBOL_GPL(wm97xx_bat_set_pdata);

Expand Down
18 changes: 18 additions & 0 deletions trunk/include/linux/wm97xx.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,24 @@ struct wm97xx {
u16 suspend_mode; /* PRP in suspend mode */
};

struct wm97xx_batt_pdata {
int batt_aux;
int temp_aux;
int charge_gpio;
int min_voltage;
int max_voltage;
int batt_div;
int batt_mult;
int temp_div;
int temp_mult;
int batt_tech;
char *batt_name;
};

struct wm97xx_pdata {
struct wm97xx_batt_pdata *batt_pdata; /* battery data */
};

/*
* Codec GPIO access (not supported on WM9705)
* This can be used to set/get codec GPIO and Virtual GPIO status.
Expand Down
18 changes: 4 additions & 14 deletions trunk/include/linux/wm97xx_batt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,12 @@

#include <linux/wm97xx.h>

struct wm97xx_batt_info {
int batt_aux;
int temp_aux;
int charge_gpio;
int min_voltage;
int max_voltage;
int batt_div;
int batt_mult;
int temp_div;
int temp_mult;
int batt_tech;
char *batt_name;
};
#warning This file will be removed soon, use wm97xx.h instead!

#define wm97xx_batt_info wm97xx_batt_pdata

#ifdef CONFIG_BATTERY_WM97XX
void __init wm97xx_bat_set_pdata(struct wm97xx_batt_info *data);
void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data);
#else
static inline void wm97xx_bat_set_pdata(struct wm97xx_batt_info *data) {}
#endif
Expand Down

0 comments on commit f1d258e

Please sign in to comment.