Skip to contentSkip to conversation

add MAX17040 Fuel Gauge driver

PATCH In review Minkyu Kang 4 participants 9 messages Jun 5, 2009 – Jun 9, 2009 I2C subsystem host drivers

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 add MAX17040 Fuel Gauge driver

The MAX17040 is a I2C interfaced Fuel Gauge systems for lithium-ion batteries This patch adds support the MAX17040 Fuel Gauge

Cc Anton Vorontsov <[email protected]>
---
 drivers/power/Kconfig            |    8 +
 drivers/power/Makefile           |    3 +-
 drivers/power/max17040_battery.c |  306 ++++++++++++++++++++++++++++++++++++++
 include/linux/max17040_battery.h |   19 +++
 4 files changed, 335 insertions(+), 1 deletions(-)
 create mode 100644 drivers/power/max17040_battery.c
 create mode 100644 include/linux/max17040_battery.h
drivers/power/Kconfig +8 -0
index 33da112..6af5798 100644
@@ -88,4 +88,12 @@ config CHARGER_PCF50633
 	help
 	 Say Y to include support for NXP PCF50633 Main Battery Charger.
 
+config BATTERY_MAX17040
+	tristate "Maxim MAX17040 Fuel Gauge"
+	depends on I2C
+	help
+	  MAX17040 is fuel-gauge systems for lithium-ion (Li+) batteries
+	  in handheld and portable equipment. The MAX17040 is configured
+	  to operate with a single lithium cell
+
 endif # POWER_SUPPLY
drivers/power/Makefile +2 -1
index 2fcf41d..9c48995 100644
@@ -25,4 +25,5 @@ obj-$(CONFIG_BATTERY_TOSA)	+= tosa_battery.o
 obj-$(CONFIG_BATTERY_WM97XX)	+= wm97xx_battery.o
 obj-$(CONFIG_BATTERY_BQ27x00)	+= bq27x00_battery.o
 obj-$(CONFIG_BATTERY_DA9030)	+= da9030_battery.o
-obj-$(CONFIG_CHARGER_PCF50633)	+= pcf50633-charger.o
\ No newline at end of file
+obj-$(CONFIG_BATTERY_MAX17040))	+= max17040_battery.o
+obj-$(CONFIG_CHARGER_PCF50633)	+= pcf50633-charger.o
drivers/power/max17040_battery.c new file +306 -0

306 lines not on this page · raw message

include/linux/max17040_battery.h new file +19 -0
new file mode 100644
index 0000000..ad97b06
@@ -0,0 +1,19 @@
+/*
+ *  Copyright (C) 2009 Samsung Electronics
+ *  Minkyu Kang <[email protected]>
+ *
+ * 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.
+ */
+
+#ifndef __MAX17040_BATTERY_H_
+#define __MAX17040_BATTERY_H_
+
+struct max17040_platform_data {
+	int (*battery_online)(void);
+	int (*charger_online)(void);
+	int (*charger_enable)(void);
+};
+
+#endif
Signature · 1 line
1.5.4.3
#1 lore raw

Hi Minkyu Kang,

Quoted 3 lines · Minkyu Kang

The MAX17040 is a I2C interfaced Fuel Gauge systems for lithium-ion batteries This patch adds support the MAX17040 Fuel Gauge

Thanks for making change. Some more comments.

drivers/power/Makefile obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o · line 28

Quoted 12 lines

 endif # POWER_SUPPLY

drivers/power/Makefile +0 -0
index 2fcf41d..9c48995 100644
@@ -25,4 +25,5 @@ obj-$(CONFIG_BATTERY_TOSA)    += tosa_battery.o

 obj-$(CONFIG_BATTERY_WM97XX)   += wm97xx_battery.o obj-$(CONFIG_BATTERY_BQ27x00)  += bq27x00_battery.o obj-$(CONFIG_BATTERY_DA9030)   += da9030_battery.o

drivers/power/Makefile +1 -1
-obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
\ No newline at end of file
+obj-$(CONFIG_BATTERY_MAX17040))        += max17040_battery.o

Are we following any alphabetical order in this Makefile?

Quoted 7 lines
drivers/power/Makefile +7 -0
+static int max17040_suspend(struct i2c_client *client,
+               pm_message_t state)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       cancel_delayed_work(&chip->work);
+       return 0;

drivers/power/Makefile

Quoted 10 lines
drivers/power/Makefile +10 -0
+}
+
+static int max17040_resume(struct i2c_client *client)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       schedule_delayed_work(&chip->work, MAX17040_DELAY);
+       return 0;
+}
+

Please add #ifdef CONFIG_PM around suspend resume functions.

Signature · 3 lines
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni
#2 lore raw

Dear Trilok Soni,

Thanks for review

Quoted 9 lines

Hi Minkyu Kang,

Quoted 3 lines · Minkyu Kang

The MAX17040 is a I2C interfaced Fuel Gauge systems for lithium-ion batteries This patch adds support the MAX17040 Fuel Gauge

Thanks for making change. Some more comments.

Quoted 15 lines

drivers/power/Makefile obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o · line 28

Quoted 12 lines

endif # POWER_SUPPLY

drivers/power/Makefile +1 -1
index 2fcf41d..9c48995 100644
@@ -25,4 +25,5 @@ obj-$(CONFIG_BATTERY_TOSA)    += tosa_battery.o
 obj-$(CONFIG_BATTERY_WM97XX)   += wm97xx_battery.o
 obj-$(CONFIG_BATTERY_BQ27x00)  += bq27x00_battery.o
 obj-$(CONFIG_BATTERY_DA9030)   += da9030_battery.o
-obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
\ No newline at end of file
+obj-$(CONFIG_BATTERY_MAX17040))        += max17040_battery.o

Are we following any alphabetical order in this Makefile?

I'm not sure either. :(
I just grouping with batteries.

Quoted 11 lines
Quoted 11 lines
drivers/power/Makefile +11 -0
+static int max17040_suspend(struct i2c_client *client,
+               pm_message_t state)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       cancel_delayed_work(&chip->work);
+       return 0;
+}
+
+static int max17040_resume(struct i2c_client *client)
+{
Quoted 9 lines

drivers/power/Makefile

Quoted 6 lines
drivers/power/Makefile +6 -0
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       schedule_delayed_work(&chip->work, MAX17040_DELAY);
+       return 0;
+}
+

Please add #ifdef CONFIG_PM around suspend resume functions.

Ok, I will.
Thanks

---
from, prom.

#3 lore raw
Quoted 13 lines · Minkyu Kang

Dear Trilok Soni,

Thanks for review

Quoted 9 lines

Hi Minkyu Kang,

Quoted 3 lines · Minkyu Kang

The MAX17040 is a I2C interfaced Fuel Gauge systems for lithium-ion batteries This patch adds support the MAX17040 Fuel Gauge

Thanks for making change. Some more comments.

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines

endif # POWER_SUPPLY

drivers/power/Makefile +0 -1
index 2fcf41d..9c48995 100644
--- a/drivers/power/Makefile
Quoted 8 lines

drivers/power/Makefile obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o · line 28

Quoted 8 lines

+++ b/drivers/power/Makefile

drivers/power/Makefile +1 -1
@@ -25,4 +25,5 @@ obj-$(CONFIG_BATTERY_TOSA)    += tosa_battery.o
 obj-$(CONFIG_BATTERY_WM97XX)   += wm97xx_battery.o
 obj-$(CONFIG_BATTERY_BQ27x00)  += bq27x00_battery.o
 obj-$(CONFIG_BATTERY_DA9030)   += da9030_battery.o
-obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
\ No newline at end of file
+obj-$(CONFIG_BATTERY_MAX17040))        += max17040_battery.o

There is a typo: "))" should be just ")". I fixed this.

I also fixed "‘max17040_set_rcomp’ defined but not used" warning (just removed this function).

Quoted 5 lines
Quoted 2 lines

Are we following any alphabetical order in this Makefile?

I'm not sure either. :(
I just grouping with batteries.

It's fine as is. I always wonder when somebody try to sort things alphabetically. Humans should not bother with sorting, that's what computers are for! ;-)

Quoted 21 lines
Quoted 11 lines
Quoted 11 lines
drivers/power/Makefile +11 -0
+static int max17040_suspend(struct i2c_client *client,
+               pm_message_t state)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       cancel_delayed_work(&chip->work);
+       return 0;
+}
+
+static int max17040_resume(struct i2c_client *client)
+{
Quoted 9 lines

drivers/power/Makefile

Quoted 6 lines
drivers/power/Makefile +6 -0
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       schedule_delayed_work(&chip->work, MAX17040_DELAY);
+       return 0;
+}
+

Please add #ifdef CONFIG_PM around suspend resume functions.

Quoted 1 line

Ok, I will.

Just did it myself, and queued this patch for 2.6.31.

Thanks!

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#4 lore raw

Dear, Anton Vorontsov

2009/6/9 Anton Vorontsov <[email protected]>:

Quoted 29 lines · Minkyu Kang
Quoted 13 lines

Dear Trilok Soni,

Thanks for review

Quoted 9 lines

Hi Minkyu Kang,

Quoted 3 lines · Minkyu Kang

The MAX17040 is a I2C interfaced Fuel Gauge systems for lithium-ion batteries This patch adds support the MAX17040 Fuel Gauge

Thanks for making change. Some more comments.

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines

 endif # POWER_SUPPLY

drivers/power/Makefile +0 -1
index 2fcf41d..9c48995 100644
--- a/drivers/power/Makefile
Quoted 8 lines

drivers/power/Makefile obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o · line 28

Quoted 8 lines

+++ b/drivers/power/Makefile

drivers/power/Makefile +0 -0
@@ -25,4 +25,5 @@ obj-$(CONFIG_BATTERY_TOSA)    += tosa_battery.o

 obj-$(CONFIG_BATTERY_WM97XX)   += wm97xx_battery.o obj-$(CONFIG_BATTERY_BQ27x00)  += bq27x00_battery.o obj-$(CONFIG_BATTERY_DA9030)   += da9030_battery.o

drivers/power/Makefile +1 -1
-obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
\ No newline at end of file
+obj-$(CONFIG_BATTERY_MAX17040))        += max17040_battery.o

There is a typo: "))" should be just ")". I fixed this.

Quoted 2 lines

I also fixed "‘max17040_set_rcomp’ defined but not used" warning (just removed this function).

I missed it. thanks.

Quoted 31 lines
Quoted 5 lines
Quoted 2 lines

Are we following any alphabetical order in this Makefile?

I'm not sure either. :(
I just grouping with batteries.

It's fine as is. I always wonder when somebody try to sort things alphabetically. Humans should not bother with sorting, that's what computers are for! ;-)

Quoted 21 lines
Quoted 20 lines
Quoted 7 lines
drivers/power/Makefile +7 -0
+static int max17040_suspend(struct i2c_client *client,
+               pm_message_t state)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       cancel_delayed_work(&chip->work);
+       return 0;

drivers/power/Makefile

Quoted 10 lines
drivers/power/Makefile +10 -0
+}
+
+static int max17040_resume(struct i2c_client *client)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       schedule_delayed_work(&chip->work, MAX17040_DELAY);
+       return 0;
+}
+

Please add #ifdef CONFIG_PM around suspend resume functions.

Quoted 6 lines
Quoted 1 line

Ok, I will.

Just did it myself, and queued this patch for 2.6.31.

Thanks!

Ok, I appreciate your help.
Many Thanks :)

Signature · 2 lines
from. prom.
promsoft.net
#5 lore raw
In reply to Anton Vorontsov

Dear, Anton Vorontsov

2009/6/9 Anton Vorontsov <[email protected]>:

Quoted 29 lines · Minkyu Kang
Quoted 13 lines

Dear Trilok Soni,

Thanks for review

Quoted 9 lines

Hi Minkyu Kang,

Quoted 3 lines · Minkyu Kang

The MAX17040 is a I2C interfaced Fuel Gauge systems for lithium-ion batteries This patch adds support the MAX17040 Fuel Gauge

Thanks for making change. Some more comments.

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines

 endif # POWER_SUPPLY

drivers/power/Makefile +0 -1
index 2fcf41d..9c48995 100644
--- a/drivers/power/Makefile
Quoted 8 lines

drivers/power/Makefile obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o · line 28

Quoted 8 lines

+++ b/drivers/power/Makefile

drivers/power/Makefile +0 -0
@@ -25,4 +25,5 @@ obj-$(CONFIG_BATTERY_TOSA)    += tosa_battery.o

 obj-$(CONFIG_BATTERY_WM97XX)   += wm97xx_battery.o obj-$(CONFIG_BATTERY_BQ27x00)  += bq27x00_battery.o obj-$(CONFIG_BATTERY_DA9030)   += da9030_battery.o

drivers/power/Makefile +1 -1
-obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
\ No newline at end of file
+obj-$(CONFIG_BATTERY_MAX17040))        += max17040_battery.o

There is a typo: "))" should be just ")". I fixed this.

Quoted 2 lines

I also fixed "‘max17040_set_rcomp’ defined but not used" warning (just removed this function).

I missed it. thanks.

Quoted 31 lines
Quoted 5 lines
Quoted 2 lines

Are we following any alphabetical order in this Makefile?

I'm not sure either. :(
I just grouping with batteries.

It's fine as is. I always wonder when somebody try to sort things alphabetically. Humans should not bother with sorting, that's what computers are for! ;-)

Quoted 21 lines
Quoted 20 lines
Quoted 7 lines
drivers/power/Makefile +7 -0
+static int max17040_suspend(struct i2c_client *client,
+               pm_message_t state)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       cancel_delayed_work(&chip->work);
+       return 0;

drivers/power/Makefile

Quoted 10 lines
drivers/power/Makefile +10 -0
+}
+
+static int max17040_resume(struct i2c_client *client)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       schedule_delayed_work(&chip->work, MAX17040_DELAY);
+       return 0;
+}
+

Please add #ifdef CONFIG_PM around suspend resume functions.

Quoted 6 lines
Quoted 1 line

Ok, I will.

Just did it myself, and queued this patch for 2.6.31.

Thanks!

Ok, I appreciate your help.
Many Thanks :)

Signature · 2 lines
from. prom.
promsoft.net
#6 lore raw
In reply to Minkyu Kang
Quoted 13 lines · Minkyu Kang

Dear Trilok Soni,

Thanks for review

Quoted 9 lines

Hi Minkyu Kang,

Quoted 3 lines · Minkyu Kang

The MAX17040 is a I2C interfaced Fuel Gauge systems for lithium-ion batteries This patch adds support the MAX17040 Fuel Gauge

Thanks for making change. Some more comments.

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines

endif # POWER_SUPPLY

drivers/power/Makefile +0 -1
index 2fcf41d..9c48995 100644
--- a/drivers/power/Makefile
Quoted 8 lines

drivers/power/Makefile obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o · line 28

Quoted 8 lines

+++ b/drivers/power/Makefile

drivers/power/Makefile +1 -1
@@ -25,4 +25,5 @@ obj-$(CONFIG_BATTERY_TOSA)    += tosa_battery.o
 obj-$(CONFIG_BATTERY_WM97XX)   += wm97xx_battery.o
 obj-$(CONFIG_BATTERY_BQ27x00)  += bq27x00_battery.o
 obj-$(CONFIG_BATTERY_DA9030)   += da9030_battery.o
-obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
\ No newline at end of file
+obj-$(CONFIG_BATTERY_MAX17040))        += max17040_battery.o

There is a typo: "))" should be just ")". I fixed this.

I also fixed "‘max17040_set_rcomp’ defined but not used" warning (just removed this function).

Quoted 5 lines
Quoted 2 lines

Are we following any alphabetical order in this Makefile?

I'm not sure either. :(
I just grouping with batteries.

It's fine as is. I always wonder when somebody try to sort things alphabetically. Humans should not bother with sorting, that's what computers are for! ;-)

Quoted 21 lines
Quoted 11 lines
Quoted 11 lines
drivers/power/Makefile +11 -0
+static int max17040_suspend(struct i2c_client *client,
+               pm_message_t state)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       cancel_delayed_work(&chip->work);
+       return 0;
+}
+
+static int max17040_resume(struct i2c_client *client)
+{
Quoted 9 lines

drivers/power/Makefile

Quoted 6 lines
drivers/power/Makefile +6 -0
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       schedule_delayed_work(&chip->work, MAX17040_DELAY);
+       return 0;
+}
+

Please add #ifdef CONFIG_PM around suspend resume functions.

Quoted 1 line

Ok, I will.

Just did it myself, and queued this patch for 2.6.31.

Thanks!

Signature · 7 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm
#7 lore raw
In reply to Trilok Soni

Dear Trilok Soni,

Thanks for review

Quoted 9 lines

Hi Minkyu Kang,

Quoted 3 lines · Minkyu Kang

The MAX17040 is a I2C interfaced Fuel Gauge systems for lithium-ion batteries This patch adds support the MAX17040 Fuel Gauge

Thanks for making change. Some more comments.

Quoted 15 lines

drivers/power/Makefile obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o · line 28

Quoted 12 lines

endif # POWER_SUPPLY

drivers/power/Makefile +1 -1
index 2fcf41d..9c48995 100644
@@ -25,4 +25,5 @@ obj-$(CONFIG_BATTERY_TOSA)    += tosa_battery.o
 obj-$(CONFIG_BATTERY_WM97XX)   += wm97xx_battery.o
 obj-$(CONFIG_BATTERY_BQ27x00)  += bq27x00_battery.o
 obj-$(CONFIG_BATTERY_DA9030)   += da9030_battery.o
-obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
\ No newline at end of file
+obj-$(CONFIG_BATTERY_MAX17040))        += max17040_battery.o

Are we following any alphabetical order in this Makefile?

I'm not sure either. :(
I just grouping with batteries.

Quoted 11 lines
Quoted 11 lines
drivers/power/Makefile +11 -0
+static int max17040_suspend(struct i2c_client *client,
+               pm_message_t state)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       cancel_delayed_work(&chip->work);
+       return 0;
+}
+
+static int max17040_resume(struct i2c_client *client)
+{
Quoted 9 lines

drivers/power/Makefile

Quoted 6 lines
drivers/power/Makefile +6 -0
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       schedule_delayed_work(&chip->work, MAX17040_DELAY);
+       return 0;
+}
+

Please add #ifdef CONFIG_PM around suspend resume functions.

Ok, I will.
Thanks

---
from, prom.

#8 lore raw
In reply to Minkyu Kang

Hi Minkyu Kang,

Quoted 3 lines · Minkyu Kang

The MAX17040 is a I2C interfaced Fuel Gauge systems for lithium-ion batteries This patch adds support the MAX17040 Fuel Gauge

Thanks for making change. Some more comments.

drivers/power/Makefile obj-$(CONFIG_BATTERY_TOSA) += tosa_battery.o · line 28

Quoted 12 lines

 endif # POWER_SUPPLY

drivers/power/Makefile +0 -0
index 2fcf41d..9c48995 100644
@@ -25,4 +25,5 @@ obj-$(CONFIG_BATTERY_TOSA)    += tosa_battery.o

 obj-$(CONFIG_BATTERY_WM97XX)   += wm97xx_battery.o obj-$(CONFIG_BATTERY_BQ27x00)  += bq27x00_battery.o obj-$(CONFIG_BATTERY_DA9030)   += da9030_battery.o

drivers/power/Makefile +1 -1
-obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
\ No newline at end of file
+obj-$(CONFIG_BATTERY_MAX17040))        += max17040_battery.o

Are we following any alphabetical order in this Makefile?

Quoted 7 lines
drivers/power/Makefile +7 -0
+static int max17040_suspend(struct i2c_client *client,
+               pm_message_t state)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       cancel_delayed_work(&chip->work);
+       return 0;

drivers/power/Makefile

Quoted 10 lines
drivers/power/Makefile +10 -0
+}
+
+static int max17040_resume(struct i2c_client *client)
+{
+       struct max17040_chip *chip = i2c_get_clientdata(client);
+
+       schedule_delayed_work(&chip->work, MAX17040_DELAY);
+       return 0;
+}
+

Please add #ifdef CONFIG_PM around suspend resume functions.

Signature · 3 lines
---Trilok Soni
http://triloksoni.wordpress.com
http://www.linkedin.com/in/triloksoni