Re: Resending: [PATCH] BQ27000/BQ27200 battery monitoring driver for OMAP34xx

2008-05-02 Thread Tony Lindgren
* Madhusudhan Chikkature Rajashekar [EMAIL PROTECTED] [080429 01:59]:
 Hi,
 
 I am resending the patch after fixing the comments provided by Felipe.

Pushing today. Can you please send this to appropriate maintainer too?

Tony

 
 Regards,
 Madhu
 
 This patch provides the battery driver to support BQ27000 and BQ27200 chips.
 
 Signed-off-by: Madhusudhan Chikkature[EMAIL PROTECTED]
 
 ---
  drivers/power/Kconfig   |   21 +
  drivers/power/Makefile  |1 
  drivers/power/bq27x00_battery.c |  564 
 
  3 files changed, 586 insertions(+)
 
 Index: linux-omap-2.6/drivers/power/bq27x00_battery.c
 ===
 --- /dev/null 1970-01-01 00:00:00.0 +
 +++ linux-omap-2.6/drivers/power/bq27x00_battery.c2008-04-29 
 11:27:42.962321458 +0530
 @@ -0,0 +1,564 @@
 +/*
 + * linux/drivers/power/bq27x00_battery.c
 + *
 + * BQ27000/BQ27200 battery driver
 + *
 + * Copyright (C) 2008 Texas Instruments, Inc.
 + *
 + * Author: Texas Instruments
 + *
 + * This package 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.
 + *
 + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 + *
 + */
 +#include linux/module.h
 +#include linux/param.h
 +#include linux/jiffies.h
 +#include linux/workqueue.h
 +#include linux/delay.h
 +#include linux/platform_device.h
 +#include linux/power_supply.h
 +
 +#ifdef CONFIG_BATTERY_BQ27000
 +#include ../w1/w1.h
 +#endif
 +#ifdef CONFIG_BATTERY_BQ27200
 +#include linux/i2c.h
 +#endif
 +
 +#define BQ27x00_REG_TEMP 0x06
 +#define BQ27x00_REG_VOLT 0x08
 +#define BQ27x00_REG_RSOC 0x0B /* Relative State-of-Charge */
 +#define BQ27x00_REG_AI   0x14
 +#define BQ27x00_REG_FLAGS0x0A
 +#define HIGH_BYTE(A) ((A)  8)
 +
 +#ifdef CONFIG_BATTERY_BQ27000
 +extern int w1_bq27000_read(struct device *dev, u8 reg);
 +#endif
 +
 +struct bq27x00_device_info;
 +struct bq27x00_access_methods {
 + int (*read)(u8 reg, int *rt_value, int b_single,
 + struct bq27x00_device_info *di);
 +};
 +
 +struct bq27x00_device_info {
 + struct device   *dev;
 +#ifdef CONFIG_BATTERY_BQ27000
 + struct device   *w1_dev;
 +#endif
 +#ifdef CONFIG_BATTERY_BQ27200
 + struct i2c_client *client;
 +#endif
 + unsigned long   update_time;
 + int voltage_uV;
 + int current_uA;
 + int temp_C;
 + int charge_rsoc;
 + struct bq27x00_access_methods   *bus;
 + struct power_supply bat;
 + struct delayed_work monitor_work;
 +};
 +
 +static unsigned int cache_time = 6;
 +module_param(cache_time, uint, 0644);
 +MODULE_PARM_DESC(cache_time, cache time in milliseconds);
 +
 +static enum power_supply_property bq27x00_battery_props[] = {
 + POWER_SUPPLY_PROP_PRESENT,
 + POWER_SUPPLY_PROP_VOLTAGE_NOW,
 + POWER_SUPPLY_PROP_CURRENT_NOW,
 + POWER_SUPPLY_PROP_CHARGE_NOW,
 + POWER_SUPPLY_PROP_CAPACITY,
 + POWER_SUPPLY_PROP_TEMP,
 +};
 +
 +static int bq27x00_read(u8 reg, int *rt_value, int b_single,
 + struct bq27x00_device_info *di);
 +
 +#ifdef CONFIG_BATTERY_BQ27000
 +static int bq27000_battery_probe(struct platform_device *dev);
 +static int bq27000_battery_remove(struct platform_device *dev);
 +#ifdef CONFIG_PM
 +static int bq27000_battery_suspend(struct platform_device *dev,
 + pm_message_t state);
 +static int bq27000_battery_resume(struct platform_device *dev);
 +#endif /* CONFIG_PM */
 +
 +static struct platform_driver bq27000_battery_driver = {
 + .probe = bq27000_battery_probe,
 + .remove = bq27000_battery_remove,
 +#ifdef CONFIG_PM
 + .suspend = bq27000_battery_suspend,
 + .resume = bq27000_battery_resume,
 +#endif /* CONFIG_PM */
 + .driver = {
 + .name = bq27000-battery,
 + },
 +};
 +#endif /* CONFIG_BATTERY_BQ27000 */
 +
 +#ifdef CONFIG_BATTERY_BQ27200
 +static int bq27200_battery_probe(struct i2c_client *client);
 +static int bq27200_battery_remove(struct i2c_client *client);
 +#ifdef CONFIG_PM
 +static int bq27200_battery_suspend(struct i2c_client *client,
 + pm_message_t mesg);
 +static int bq27200_battery_resume(struct i2c_client *client);
 +#endif /* CONFIG_PM */
 +static struct i2c_driver bq27200_battery_driver = {
 + .driver = {
 + .name   = bq27200-bat,
 + },
 + .probe  = bq27200_battery_probe,
 + .remove = bq27200_battery_remove,
 +#ifdef CONFIG_PM
 + .suspend = bq27200_battery_suspend,
 + .resume = 

Resending: [PATCH] BQ27000/BQ27200 battery monitoring driver for OMAP34xx

2008-04-29 Thread Madhusudhan Chikkature Rajashekar
Hi,

I am resending the patch after fixing the comments provided by Felipe.

Regards,
Madhu

This patch provides the battery driver to support BQ27000 and BQ27200 chips.

Signed-off-by: Madhusudhan Chikkature[EMAIL PROTECTED]

---
 drivers/power/Kconfig   |   21 +
 drivers/power/Makefile  |1 
 drivers/power/bq27x00_battery.c |  564 
 3 files changed, 586 insertions(+)

Index: linux-omap-2.6/drivers/power/bq27x00_battery.c
===
--- /dev/null   1970-01-01 00:00:00.0 +
+++ linux-omap-2.6/drivers/power/bq27x00_battery.c  2008-04-29 
11:27:42.962321458 +0530
@@ -0,0 +1,564 @@
+/*
+ * linux/drivers/power/bq27x00_battery.c
+ *
+ * BQ27000/BQ27200 battery driver
+ *
+ * Copyright (C) 2008 Texas Instruments, Inc.
+ *
+ * Author: Texas Instruments
+ *
+ * This package 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.
+ *
+ * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+#include linux/module.h
+#include linux/param.h
+#include linux/jiffies.h
+#include linux/workqueue.h
+#include linux/delay.h
+#include linux/platform_device.h
+#include linux/power_supply.h
+
+#ifdef CONFIG_BATTERY_BQ27000
+#include ../w1/w1.h
+#endif
+#ifdef CONFIG_BATTERY_BQ27200
+#include linux/i2c.h
+#endif
+
+#define BQ27x00_REG_TEMP   0x06
+#define BQ27x00_REG_VOLT   0x08
+#define BQ27x00_REG_RSOC   0x0B /* Relative State-of-Charge */
+#define BQ27x00_REG_AI 0x14
+#define BQ27x00_REG_FLAGS  0x0A
+#define HIGH_BYTE(A)   ((A)  8)
+
+#ifdef CONFIG_BATTERY_BQ27000
+extern int w1_bq27000_read(struct device *dev, u8 reg);
+#endif
+
+struct bq27x00_device_info;
+struct bq27x00_access_methods {
+   int (*read)(u8 reg, int *rt_value, int b_single,
+   struct bq27x00_device_info *di);
+};
+
+struct bq27x00_device_info {
+   struct device   *dev;
+#ifdef CONFIG_BATTERY_BQ27000
+   struct device   *w1_dev;
+#endif
+#ifdef CONFIG_BATTERY_BQ27200
+   struct i2c_client *client;
+#endif
+   unsigned long   update_time;
+   int voltage_uV;
+   int current_uA;
+   int temp_C;
+   int charge_rsoc;
+   struct bq27x00_access_methods   *bus;
+   struct power_supply bat;
+   struct delayed_work monitor_work;
+};
+
+static unsigned int cache_time = 6;
+module_param(cache_time, uint, 0644);
+MODULE_PARM_DESC(cache_time, cache time in milliseconds);
+
+static enum power_supply_property bq27x00_battery_props[] = {
+   POWER_SUPPLY_PROP_PRESENT,
+   POWER_SUPPLY_PROP_VOLTAGE_NOW,
+   POWER_SUPPLY_PROP_CURRENT_NOW,
+   POWER_SUPPLY_PROP_CHARGE_NOW,
+   POWER_SUPPLY_PROP_CAPACITY,
+   POWER_SUPPLY_PROP_TEMP,
+};
+
+static int bq27x00_read(u8 reg, int *rt_value, int b_single,
+   struct bq27x00_device_info *di);
+
+#ifdef CONFIG_BATTERY_BQ27000
+static int bq27000_battery_probe(struct platform_device *dev);
+static int bq27000_battery_remove(struct platform_device *dev);
+#ifdef CONFIG_PM
+static int bq27000_battery_suspend(struct platform_device *dev,
+   pm_message_t state);
+static int bq27000_battery_resume(struct platform_device *dev);
+#endif /* CONFIG_PM */
+
+static struct platform_driver bq27000_battery_driver = {
+   .probe = bq27000_battery_probe,
+   .remove = bq27000_battery_remove,
+#ifdef CONFIG_PM
+   .suspend = bq27000_battery_suspend,
+   .resume = bq27000_battery_resume,
+#endif /* CONFIG_PM */
+   .driver = {
+   .name = bq27000-battery,
+   },
+};
+#endif /* CONFIG_BATTERY_BQ27000 */
+
+#ifdef CONFIG_BATTERY_BQ27200
+static int bq27200_battery_probe(struct i2c_client *client);
+static int bq27200_battery_remove(struct i2c_client *client);
+#ifdef CONFIG_PM
+static int bq27200_battery_suspend(struct i2c_client *client,
+   pm_message_t mesg);
+static int bq27200_battery_resume(struct i2c_client *client);
+#endif /* CONFIG_PM */
+static struct i2c_driver bq27200_battery_driver = {
+   .driver = {
+   .name   = bq27200-bat,
+   },
+   .probe  = bq27200_battery_probe,
+   .remove = bq27200_battery_remove,
+#ifdef CONFIG_PM
+   .suspend = bq27200_battery_suspend,
+   .resume = bq27200_battery_resume,
+#endif /* CONFIG_PM */
+};
+#endif /* CONFIG_BATTERY_BQ27200 */
+
+/*
+ * Return the battery temperature in Celcius degrees
+ * Or  0 if something fails.
+ */
+static int bq27x00_battery_temperature(struct