Re: [PATCH v6 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver

2015-03-01 Thread Beomho Seo
On 03/01/2015 05:00 AM, Paul Bolle wrote:
 On Tue, 2015-02-24 at 10:29 +0900, Jaewon Kim wrote:
 diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
 index 994793d..555e436 100644
 --- a/drivers/power/Kconfig
 +++ b/drivers/power/Kconfig
 @@ -212,6 +212,15 @@ config BATTERY_MAX17042
with MAX17042. This driver also supports max17047/50 chips which are
improved version of max17042.
  
 +config BATTERY_MAX77843
 +tristate Maxim MAX77843 Fuel Gauge
 +depends on MFD_MAX77843
 +help
 +  This adds support for battery fuel gauge in Maxim MAX77843. It is
 +  fuel-gauge for a lithium-ion batteries with a single cell and can be
 +  found in portable devices. The MAX17040 is configured to operate with
 
 Could MAX17040 be a copy/paste error?
 
 +  a single lithium cell.
 +
  config BATTERY_Z2
  tristate Z2 battery driver
  depends on I2C  MACH_ZIPIT2
 
 [...]
 
 diff --git a/drivers/power/max77843_battery.c 
 b/drivers/power/max77843_battery.c
 new file mode 100644
 index 000..0c59a16
 --- /dev/null
 +++ b/drivers/power/max77843_battery.c
 @@ -0,0 +1,286 @@
 +/*
 + * Fuel gauge driver for Maxim MAX77843
 + *
 + * Copyright (C) 2015 Samsung Electronics, Co., Ltd.
 + * Author: Beomho Seo beomho@samsung.com
 + *
 + * 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 bythe Free Software Foundation.
 + */
 
 I did
 git grep bythe Free next-20150227
 
 and it returned five hits. This would be the sixth.
 
 Anyhow, this states that this file is licensed GPL v2.
 
 [...]
 
 +MODULE_LICENSE(GPL);
 
 So this should probably be
 MODULE_LICENSE(GPL v2);
 
 
 Paul Bolle
 

Thank you for your review.
I will fix next revision.

Thanks,

Beomho Seo

 --
 To unsubscribe from this list: send the line unsubscribe linux-input in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 

--
To unsubscribe from this list: send the line unsubscribe devicetree in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v6 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver

2015-02-28 Thread Paul Bolle
On Tue, 2015-02-24 at 10:29 +0900, Jaewon Kim wrote:
 diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
 index 994793d..555e436 100644
 --- a/drivers/power/Kconfig
 +++ b/drivers/power/Kconfig
 @@ -212,6 +212,15 @@ config BATTERY_MAX17042
 with MAX17042. This driver also supports max17047/50 chips which are
 improved version of max17042.
  
 +config BATTERY_MAX77843
 + tristate Maxim MAX77843 Fuel Gauge
 + depends on MFD_MAX77843
 + help
 +   This adds support for battery fuel gauge in Maxim MAX77843. It is
 +   fuel-gauge for a lithium-ion batteries with a single cell and can be
 +   found in portable devices. The MAX17040 is configured to operate with

Could MAX17040 be a copy/paste error?

 +   a single lithium cell.
 +
  config BATTERY_Z2
   tristate Z2 battery driver
   depends on I2C  MACH_ZIPIT2

[...]

 diff --git a/drivers/power/max77843_battery.c 
 b/drivers/power/max77843_battery.c
 new file mode 100644
 index 000..0c59a16
 --- /dev/null
 +++ b/drivers/power/max77843_battery.c
 @@ -0,0 +1,286 @@
 +/*
 + * Fuel gauge driver for Maxim MAX77843
 + *
 + * Copyright (C) 2015 Samsung Electronics, Co., Ltd.
 + * Author: Beomho Seo beomho@samsung.com
 + *
 + * 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 bythe Free Software Foundation.
 + */

I did
git grep bythe Free next-20150227

and it returned five hits. This would be the sixth.

Anyhow, this states that this file is licensed GPL v2.

[...]

 +MODULE_LICENSE(GPL);

So this should probably be
MODULE_LICENSE(GPL v2);


Paul Bolle

--
To unsubscribe from this list: send the line unsubscribe devicetree in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver

2015-02-23 Thread Jaewon Kim
From: Beomho Seo beomho@samsung.com

This patch adds device driver of max77843 fuel gauge.
The driver support for battery fuel gauge in Maxim Max77843.
It is fuel-gauge systems for lithuum-ion batteries in handled and
portable devices.

Cc: Sebastian Reichel s...@kernel.org
Signed-off-by: Beomho Seo beomho@samsung.com
---
 drivers/power/Kconfig|9 ++
 drivers/power/Makefile   |1 +
 drivers/power/max77843_battery.c |  286 ++
 3 files changed, 296 insertions(+)
 create mode 100644 drivers/power/max77843_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 994793d..555e436 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -212,6 +212,15 @@ config BATTERY_MAX17042
  with MAX17042. This driver also supports max17047/50 chips which are
  improved version of max17042.
 
+config BATTERY_MAX77843
+   tristate Maxim MAX77843 Fuel Gauge
+   depends on MFD_MAX77843
+   help
+ This adds support for battery fuel gauge in Maxim MAX77843. It is
+ fuel-gauge for a lithium-ion batteries with a single cell and can be
+ found in portable devices. The MAX17040 is configured to operate with
+ a single lithium cell.
+
 config BATTERY_Z2
tristate Z2 battery driver
depends on I2C  MACH_ZIPIT2
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index ed69cea..59e3945 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9030)  += da9030_battery.o
 obj-$(CONFIG_BATTERY_DA9052)   += da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o
+obj-$(CONFIG_BATTERY_MAX77843) += max77843_battery.o
 obj-$(CONFIG_BATTERY_Z2)   += z2_battery.o
 obj-$(CONFIG_BATTERY_RT5033)   += rt5033_battery.o
 obj-$(CONFIG_BATTERY_S3C_ADC)  += s3c_adc_battery.o
diff --git a/drivers/power/max77843_battery.c b/drivers/power/max77843_battery.c
new file mode 100644
index 000..0c59a16
--- /dev/null
+++ b/drivers/power/max77843_battery.c
@@ -0,0 +1,286 @@
+/*
+ * Fuel gauge driver for Maxim MAX77843
+ *
+ * Copyright (C) 2015 Samsung Electronics, Co., Ltd.
+ * Author: Beomho Seo beomho@samsung.com
+ *
+ * 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 bythe Free Software Foundation.
+ */
+
+#include linux/module.h
+#include linux/platform_device.h
+#include linux/power_supply.h
+#include linux/mfd/max77843-private.h
+
+struct max77843_battery {
+   struct device   *dev;
+   struct max77843 *max77843;
+   struct i2c_client   *client;
+   struct regmap   *regmap;
+   struct power_supply psy;
+};
+
+static int max77843_battery_get_capacity(struct max77843_battery *battery)
+{
+   struct regmap *regmap = battery-regmap;
+   int ret, val;
+   unsigned int reg_data;
+
+   ret = regmap_read(regmap, MAX77843_FG_REG_SOCREP, reg_data);
+   if (ret) {
+   dev_err(battery-dev, Failed to read fuelgauge register\n);
+   return ret;
+   }
+
+   val = reg_data  8;
+
+   return val;
+}
+
+static int max77843_battery_get_energy_prop(struct max77843_battery *battery,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = battery-regmap;
+   unsigned int reg;
+   int ret, val;
+   unsigned int reg_data;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_ENERGY_FULL:
+   reg = MAX77843_FG_REG_FULLCAP;
+   break;
+   case POWER_SUPPLY_PROP_ENERGY_NOW:
+   reg = MAX77843_FG_REG_REMCAP_REP;
+   break;
+   case POWER_SUPPLY_PROP_ENERGY_AVG:
+   reg = MAX77843_FG_REG_REMCAP_AV;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   ret = regmap_read(regmap, reg, reg_data);
+   if (ret) {
+   dev_err(battery-dev, Failed to read fuelgauge register\n);
+   return ret;
+   }
+
+   val = reg_data;
+
+   return val;
+}
+
+static int max77843_battery_get_current_prop(struct max77843_battery *battery,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = battery-regmap;
+   unsigned int reg;
+   int ret, val;
+   unsigned int reg_data;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_CURRENT_NOW:
+   reg = MAX77843_FG_REG_CURRENT;
+   break;
+   case POWER_SUPPLY_PROP_CURRENT_AVG:
+   reg = MAX77843_FG_REG_AVG_CURRENT;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   ret = regmap_read(regmap, reg, reg_data);
+   if (ret) {
+   dev_err(battery-dev, Failed to read fuelgauge register\n);
+   return ret;
+   }
+
+