[PATCH v8 1/2] power: max77843_charger: Add Max77843 charger device driver

2015-03-31 Thread Beomho Seo
This patch adds device driver of max77843 charger. This driver provide
initialize each charging mode(e.g. fast charge, top-off mode and constant
charging mode so on.). Additionally, control charging paramters to use
i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Lee Jones lee.jo...@linaro.org
Reviewed-by: Sebastian Reichel s...@kernel.org
Signed-off-by: Beomho Seo beomho@samsung.com
---
 drivers/power/Kconfig|7 +
 drivers/power/Makefile   |1 +
 drivers/power/max77843_charger.c |  508 ++
 3 files changed, 516 insertions(+)
 create mode 100644 drivers/power/max77843_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 27b751b..994793d 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -337,6 +337,13 @@ config CHARGER_MAX77693
help
  Say Y to enable support for the Maxim MAX77693 battery charger.
 
+config CHARGER_MAX77843
+   tristate Maxim MAX77843 battery charger driver
+   depends on MFD_MAX77843
+   help
+ Say Y to enable support for the battery charger control sysfs and
+ platform data of MAX77843
+
 config CHARGER_MAX8997
tristate Maxim MAX8997/MAX8966 PMIC battery charger driver
depends on MFD_MAX8997  REGULATOR_MAX8997
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 36f9e0d..ed69cea 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_CHARGER_GPIO)+= gpio-charger.o
 obj-$(CONFIG_CHARGER_MANAGER)  += charger-manager.o
 obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.o
 obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o
+obj-$(CONFIG_CHARGER_MAX77843) += max77843_charger.o
 obj-$(CONFIG_CHARGER_MAX8997)  += max8997_charger.o
 obj-$(CONFIG_CHARGER_MAX8998)  += max8998_charger.o
 obj-$(CONFIG_CHARGER_BQ2415X)  += bq2415x_charger.o
diff --git a/drivers/power/max77843_charger.c b/drivers/power/max77843_charger.c
new file mode 100644
index 000..d4cce17
--- /dev/null
+++ b/drivers/power/max77843_charger.c
@@ -0,0 +1,508 @@
+/*
+ * Charger 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 by the 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_charger_info {
+   u32 fast_charge_uamp;
+   u32 top_off_uamp;
+   u32 input_uamp_limit;
+};
+
+struct max77843_charger {
+   struct device   *dev;
+   struct max77843 *max77843;
+   struct i2c_client   *client;
+   struct regmap   *regmap;
+   struct power_supply psy;
+
+   struct max77843_charger_info*info;
+};
+
+static int max77843_charger_get_max_current(struct max77843_charger *charger)
+{
+   struct regmap *regmap = charger-regmap;
+   int ret, val = 0;
+   unsigned int reg_data;
+
+   ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_CNFG_09, reg_data);
+   if (ret) {
+   dev_err(charger-dev,
+   Failed to read max current register: %d\n, ret);
+   return ret;
+   }
+
+   if (reg_data = 0x03) {
+   val = MAX77843_CHG_INPUT_CURRENT_LIMIT_MIN;
+   } else if (reg_data = 0x78) {
+   val = MAX77843_CHG_INPUT_CURRENT_LIMIT_MAX;
+   } else {
+   val = reg_data / 3;
+   if (reg_data % 3 == 0)
+   val *= 10;
+   else if (reg_data % 3 == 1)
+   val = val * 10 + 33000;
+   else
+   val = val * 10 + 67000;
+   }
+
+   return val;
+}
+
+static int max77843_charger_get_now_current(struct max77843_charger *charger)
+{
+   struct regmap *regmap = charger-regmap;
+   int ret, val = 0;
+   unsigned int reg_data;
+
+   ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_CNFG_02, reg_data);
+   if (ret) {
+   dev_err(charger-dev,
+   Failed to read charge current register: %d\n, ret);
+   return ret;
+   }
+
+   reg_data = MAX77843_CHG_FAST_CHG_CURRENT_MASK;
+
+   if (reg_data = 0x02)
+   val = MAX77843_CHG_FAST_CHG_CURRENT_MIN;
+   else if (reg_data = 0x3f)
+   val = MAX77843_CHG_FAST_CHG_CURRENT_MAX;
+   else
+   val = reg_data * MAX77843_CHG_FAST_CHG_CURRENT_STEP;
+
+   return val;
+}
+
+static int max77843_charger_get_online(struct max77843_charger *charger)
+{
+   struct regmap *regmap = charger-regmap;
+   int ret, val = 0;
+   unsigned int reg_data;
+
+   ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_INT_OK, reg_data

[PATCH v8 2/2] Documentation: Add device tree bindings document for max77843

2015-03-31 Thread Beomho Seo
From: Jaewon Kim jaewon02@samsung.com

Add document describing device tree bindings for max77843 MFD.
Drivers: MFD core, regulator, extcon, charger and fuelgauge.

Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian Campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Cc: Lee Jones lee.jo...@linaro.org
Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Torokhov dmitry.torok...@gmail.com

Signed-off-by: Jaewon Kim jaewon02@samsung.com
Signed-off-by: Beomho Seo beomho@samsung.com
---
 Documentation/devicetree/bindings/mfd/max77843.txt |  100 
 1 file changed, 100 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/max77843.txt

diff --git a/Documentation/devicetree/bindings/mfd/max77843.txt 
b/Documentation/devicetree/bindings/mfd/max77843.txt
new file mode 100644
index 000..4111f84
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/max77843.txt
@@ -0,0 +1,100 @@
+Maxim MAX77843 multi-function device
+
+MAX77843 is a Multi-Function Device with the following submodules:
+- PMIC   : 2 SAFEOUT LDOs for USB device
+- CHARGER : Li+ battery charger with Fuel Gauge
+- MUIC   : Micro USB Interface Controller
+- HAPTIC  : Motor Controller for tactile feedback
+
+It is interfaced to host controller using I2C.
+
+Required properties:
+- compatible : Must be maxim,max77843.
+- reg : I2C slave address of PMIC block.
+- interrupts : I2C line for main SoCs.
+- interrupt-parent : The parent of interrupt controller.
+
+Optional properties:
+- regulators : The regulators of max77843 have to be instantiated under subnode
+   named regulators using the following format.
+
+   [*]refer : Documentation/devicetree/bindings/regulator/regulator.txt
+
+   regulators {
+   SAFEOUT {
+   regulator-name = SAFEOUT;
+   };
+   }
+
+   List of valid regulator names:
+   - SAFEOUT1, SAFEOUT2, CHARGER.
+
+- max77843-muic : This properties used by extcon consumers.
+   Required properties:
+   - compatible : Must be maxim,max77842-muic.
+
+- max77843-charger : There battery charger of MAX77843 have to be instantiated
+   under sub-node named max77843-charger using the following format.
+   Required properties:
+   - compatible : Must be maxim,max77842-charger.
+   - maxim,fast-charge-uamp : Fast charge current levels are
+   100 mA to 3150 mA programmed by I2C per 100 mA.
+   - maxim,top-off-uamp : Top off current threshold levels are
+   125 mA to 650 mA programmed by I2C per 75 mA.
+   - maxim,input-uamp-limit : Input current limit levels are
+   100 mA to 3533 mA programmed by I2C per 33 mA.
+
+- max77843-haptic : The MAX77843 haptic device provides the tactile feedback
+   to the user by using PWM(Pulse Width Modulation) signal.
+   Required properties:
+   - compatible : Must be maxim,max77843-hpatic.
+   - haptic-supply : Power supply for the haptic motor.
+   [*] refer Documentation/devicetree/
+   bindings/regulator/regulator.txt
+   - pwms : phandle for the PWM(Pulse Width Modulation) device.
+   PWM properties should be named pwms.
+   [*] refer Documentation/devicetree/bindings/pwm/pwm.txt
+
+Example:
+   max77843@66 {
+   compatible = samsung,max77843;
+   reg = 0x66;
+   interrupt-parent = gpa1;
+   interrupts = 5 2;
+
+   regulators {
+   SAFEOUT1 {
+   regulator-name = SAFEOUT1;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 495;
+   };
+   SAFEOUT2 {
+   regulator-name = SAFEOUT2;
+   regulator-min-microvolt = 330;
+   regulator-max-microvolt = 495;
+   };
+   CHARGER {
+   regulator-name = CHARGER;
+   regulator-min-microamp = 10;
+   regulator-max-microamp = 315;
+   };
+   };
+
+   haptic {
+   compatible = maxim,max77843-haptic;
+   haptic-supply = haptic_supply;
+   pwms = pwm 0 4 0;
+   pwm-names = haptic;
+   };
+
+   max77843-muic {
+   compatible = maxim,max77843-muic;
+   };
+
+   max77843-charger {
+   compatible = maxim,max77843-charger;
+   maxim,fast

[PATCH v8 0/2] Add new MFD driver for MAX77843

2015-03-31 Thread Beomho Seo
This patch series adds MAX77843(Multi Function Device) driver.
The MAX77843 includes MUIC(Micro USB Interface Controller), Li+ Charger
with Fuel Gauge, 2 safeout LDOs for USB device and haptic controller using PWM.
It is interfaced to host controller using I2C.

Changes in v8:
Charger:
 - Add Reviewed-by: Sebastian Reichel He reviewed this patch on Sun 8 Mar 
2015.

Fuelgauge:
 - Remove patch.

Doc:
 - Remove about fuelgague.

Changes in v7:
MFD Core
 - Fix indentation
 - Remove file name, MODULE information
POWER
 - Fix typos

Changes in v6:
HAPTIC
 - fixed a situation where holding a Mutex return.
 
Changes in v5: 
MFD Core
 - Use bracket in complex define.
 - Delete unnecessary letter '++' 
Charger
 - fix Kconfig merge conflict with Kernel version4.0
 
Changes in v4:
MFD Core
 - Fix indentation
 - Add haptic register define in header
HAPTIC
 - Add haptic driver

Changes in v3:
MFD Core
 - Fix wrong description and indentation in header.
 - Remove unnecessary variable.
Regulator
 - Use ARRAY_SIZE() instead of define.
   
Changes in v2:
MFD Core
 - Fix charger regmap handle and typo.
MUIC
 - Cleanup enum list.
 - Set path before send excon event.
 - Fix variable names and typos for readability.
Charger
 - Remove unnecessary header.
 - Chnage error message more readable.
 - Remove unnecessary lines.
Fuelgauge
 - Fix regmap_config and use regmap_read.
 - Add i2c_unregister_device function on *_remove function.
 - Fix typo in Kconfig.
Doc
 - Remove unnecessary lines.
 - Add example of charger regulator.

Beomho Seo (1):
  power: max77843_charger: Add Max77843 charger device driver

Jaewon Kim (1):
  Documentation: Add device tree bindings document for max77843

 Documentation/devicetree/bindings/mfd/max77843.txt |  100 
 drivers/power/Kconfig  |7 +
 drivers/power/Makefile |1 +
 drivers/power/max77843_charger.c   |  508 
 4 files changed, 616 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/max77843.txt
 create mode 100644 drivers/power/max77843_charger.c

-- 
1.7.9.5

--
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 v7 2/5] power: max77843_charger: Add Max77843 charger device driver

2015-03-27 Thread Beomho Seo
On 03/27/2015 04:57 PM, Lee Jones wrote:
 On Fri, 27 Mar 2015, Beomho Seo wrote:
 On 03/26/2015 10:54 PM, Lee Jones wrote:
 On Thu, 26 Mar 2015, Beomho Seo wrote:
 On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
 2015-03-24 9:01 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/10/2015 10:44 PM, Beomho Seo wrote:
 On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
 On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
 On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
 2015-03-09 1:35 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
 On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
 From: Beomho Seo beomho@samsung.com

 This patch adds device driver of max77843 charger. This driver 
 provide
 initialize each charging mode(e.g. fast charge, top-off mode and 
 constant
 charging mode so on.). Additionally, control charging paramters 
 to use
 i2c interface.

 Cc: Sebastian Reichel s...@kernel.org
 Signed-off-by: Beomho Seo beomho@samsung.com

 Reviewed-By: Sebastian Reichel s...@kernel.org

 I can't take it as is, since it depends on the private header file
 of PATCHv1.

 -- Sebastian


 This patch reviewed by Sebastian.
 Could you Please merge that your git tree ?

 Hi,

 ... and again we are adding a new driver for very similar chipset to
 already supported. I looked at spec and the charger's registers are
 almost the same as for max77693. Their layout and addresses are the
 same. I see some minor differences, probably the most important would
 be different values current (fast-charge, top-off). But still 90% of
 registers are the same... Do we really have to add new driver?

 Best regards,
 Krzysztof


 Hi,

 Thank you for your comment. As you say, both chip set are similar.
 But new driver need for support max77843. It is support different 
 below
 - Provide Battery presence information.

 Another set of power supply properties could be added for that chip.
 This way the get_property() function would be the same but actually the
 POWER_SUPPLY_PROP_PRESENT won't be called for max77693.

 - Can OTG FET control.

 Where the OTG FET feature is it enabled in your driver? I couldn't find
 it.


 Sorry. This driver don't control OTG FET feature.

 - Bigger Fast charge current, Top Off current Threshold selection.
 - Various and bigger OTG current limitation.
 - Bigger primary charger termination voltage setting.
 - Different maximum input current limit selection(Different step).

 Yes, I mentioned some of these differences (the Fast/top-off
 differences). These are differences in values so it does not require 
 new
 driver. There is need to develop new driver just to support different
 current (3.0 A instead of 2.1 A) or voltage threshold.


 They are different charging current, OTG current limitation, top off 
 current,
 charging limitation value. In case OTG current limitation different not
 limitation value but using register bit(max77843 use[7:6] max77693 
 use[7]
 bit only). Even if this driver not support all feature, some register
 different with max77693(support value, use register bit).

 If this driver will combined with max77693 may even be beneficial for
 new Maxim driver. But the present, this driver is related with
 max77843 core driver and max77843-regulator. So I hope this driver
 merge first. And then will extend two driver(max77843 charger and 
 max77693 charger).

 I still prefer merging common drivers into one instead of creating
 some more of them.
 However I understand your point and I am not entirely opposed against.
 Especially that you invested quite a bit of time for developing this
 and my feedback was quite late. To summarize I am fine with your
 approach.

 Best regards,
 Krzysztof


 Dear Lee Jones,

 Could you please merge that your git tree ?

 Sorry, I'm lost.  Why am I taking this though the MFD tree?  What
 patches are left?  Where are they going?  Am I taking any other
 patches?


 Max77843 charger driver is max77843 mfd core dependency.
 
 What kind of dependancy?  Runtime or build?  Where is the patch that
 it depends on?  Is it in -next for in Mainline already?
 

Build. Max77843 charger driver use max77843-private.h. It is in for-mfd-next 
branch.

c7f585f mfd: max77843: Add max77843 MFD driver core driver

 If you think this patch will suitable for battery tree(or other tree),
 I would like request for merge battery tree.
 
 If this patch has no build dependencies on patches which are in -next,
 but not in Mainline then it will have to go in via the same tree that
 the dependencies were applied to.  If the dependencies are already in
 Mainline, or they are not build-deps, then it should go in via the
 correct tree, which I believe is Sebastian's tree.
 
 Also, I will send again this patch and device tree binding document.
 
 Either way you should do that.  Mark them as RESEND instead of PATCH
 and apply all of the Acks you have accumulated so far.
 

I will send new version because binding document

Re: [PATCH v7 2/5] power: max77843_charger: Add Max77843 charger device driver

2015-03-26 Thread Beomho Seo
On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
 2015-03-24 9:01 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/10/2015 10:44 PM, Beomho Seo wrote:
 On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
 On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
 On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
 2015-03-09 1:35 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
 On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
 From: Beomho Seo beomho@samsung.com

 This patch adds device driver of max77843 charger. This driver provide
 initialize each charging mode(e.g. fast charge, top-off mode and 
 constant
 charging mode so on.). Additionally, control charging paramters to use
 i2c interface.

 Cc: Sebastian Reichel s...@kernel.org
 Signed-off-by: Beomho Seo beomho@samsung.com

 Reviewed-By: Sebastian Reichel s...@kernel.org

 I can't take it as is, since it depends on the private header file
 of PATCHv1.

 -- Sebastian


 This patch reviewed by Sebastian.
 Could you Please merge that your git tree ?

 Hi,

 ... and again we are adding a new driver for very similar chipset to
 already supported. I looked at spec and the charger's registers are
 almost the same as for max77693. Their layout and addresses are the
 same. I see some minor differences, probably the most important would
 be different values current (fast-charge, top-off). But still 90% of
 registers are the same... Do we really have to add new driver?

 Best regards,
 Krzysztof
 --
 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


 Hi,

 Thank you for your comment. As you say, both chip set are similar.
 But new driver need for support max77843. It is support different below
 - Provide Battery presence information.

 Another set of power supply properties could be added for that chip.
 This way the get_property() function would be the same but actually the
 POWER_SUPPLY_PROP_PRESENT won't be called for max77693.

 - Can OTG FET control.

 Where the OTG FET feature is it enabled in your driver? I couldn't find
 it.


 Sorry. This driver don't control OTG FET feature.

 - Bigger Fast charge current, Top Off current Threshold selection.
 - Various and bigger OTG current limitation.
 - Bigger primary charger termination voltage setting.
 - Different maximum input current limit selection(Different step).

 Yes, I mentioned some of these differences (the Fast/top-off
 differences). These are differences in values so it does not require new
 driver. There is need to develop new driver just to support different
 current (3.0 A instead of 2.1 A) or voltage threshold.


 They are different charging current, OTG current limitation, top off 
 current,
 charging limitation value. In case OTG current limitation different not
 limitation value but using register bit(max77843 use[7:6] max77693 use[7]
 bit only). Even if this driver not support all feature, some register
 different with max77693(support value, use register bit).

 If this driver will combined with max77693 may even be beneficial for
 new Maxim driver. But the present, this driver is related with
 max77843 core driver and max77843-regulator. So I hope this driver
 merge first. And then will extend two driver(max77843 charger and max77693 
 charger).
 
 I still prefer merging common drivers into one instead of creating
 some more of them.
 However I understand your point and I am not entirely opposed against.
 Especially that you invested quite a bit of time for developing this
 and my feedback was quite late. To summarize I am fine with your
 approach.
 
 Best regards,
 Krzysztof


Dear Lee Jones,

Could you please merge that your git tree ?

Best regards,
Beomho Seo
--
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 v7 2/5] power: max77843_charger: Add Max77843 charger device driver

2015-03-26 Thread Beomho Seo
On 03/26/2015 10:54 PM, Lee Jones wrote:
 On Thu, 26 Mar 2015, Beomho Seo wrote:
 On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
 2015-03-24 9:01 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/10/2015 10:44 PM, Beomho Seo wrote:
 On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
 On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
 On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
 2015-03-09 1:35 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
 On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
 From: Beomho Seo beomho@samsung.com

 This patch adds device driver of max77843 charger. This driver 
 provide
 initialize each charging mode(e.g. fast charge, top-off mode and 
 constant
 charging mode so on.). Additionally, control charging paramters to 
 use
 i2c interface.

 Cc: Sebastian Reichel s...@kernel.org
 Signed-off-by: Beomho Seo beomho@samsung.com

 Reviewed-By: Sebastian Reichel s...@kernel.org

 I can't take it as is, since it depends on the private header file
 of PATCHv1.

 -- Sebastian


 This patch reviewed by Sebastian.
 Could you Please merge that your git tree ?

 Hi,

 ... and again we are adding a new driver for very similar chipset to
 already supported. I looked at spec and the charger's registers are
 almost the same as for max77693. Their layout and addresses are the
 same. I see some minor differences, probably the most important would
 be different values current (fast-charge, top-off). But still 90% of
 registers are the same... Do we really have to add new driver?

 Best regards,
 Krzysztof


 Hi,

 Thank you for your comment. As you say, both chip set are similar.
 But new driver need for support max77843. It is support different below
 - Provide Battery presence information.

 Another set of power supply properties could be added for that chip.
 This way the get_property() function would be the same but actually the
 POWER_SUPPLY_PROP_PRESENT won't be called for max77693.

 - Can OTG FET control.

 Where the OTG FET feature is it enabled in your driver? I couldn't find
 it.


 Sorry. This driver don't control OTG FET feature.

 - Bigger Fast charge current, Top Off current Threshold selection.
 - Various and bigger OTG current limitation.
 - Bigger primary charger termination voltage setting.
 - Different maximum input current limit selection(Different step).

 Yes, I mentioned some of these differences (the Fast/top-off
 differences). These are differences in values so it does not require new
 driver. There is need to develop new driver just to support different
 current (3.0 A instead of 2.1 A) or voltage threshold.


 They are different charging current, OTG current limitation, top off 
 current,
 charging limitation value. In case OTG current limitation different not
 limitation value but using register bit(max77843 use[7:6] max77693 use[7]
 bit only). Even if this driver not support all feature, some register
 different with max77693(support value, use register bit).

 If this driver will combined with max77693 may even be beneficial for
 new Maxim driver. But the present, this driver is related with
 max77843 core driver and max77843-regulator. So I hope this driver
 merge first. And then will extend two driver(max77843 charger and 
 max77693 charger).

 I still prefer merging common drivers into one instead of creating
 some more of them.
 However I understand your point and I am not entirely opposed against.
 Especially that you invested quite a bit of time for developing this
 and my feedback was quite late. To summarize I am fine with your
 approach.

 Best regards,
 Krzysztof


 Dear Lee Jones,

 Could you please merge that your git tree ?
 
 Sorry, I'm lost.  Why am I taking this though the MFD tree?  What
 patches are left?  Where are they going?  Am I taking any other
 patches?
 

Max77843 charger driver is max77843 mfd core dependency.
If you think this patch will suitable for battery tree(or other tree),
I would like request for merge battery tree.
Also, I will send again this patch and device tree binding document.

Best regards,
Beomho Seo
--
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 v7 2/5] power: max77843_charger: Add Max77843 charger device driver

2015-03-24 Thread Beomho Seo
On 03/24/2015 05:38 PM, Krzysztof Kozlowski wrote:
 2015-03-24 9:01 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/10/2015 10:44 PM, Beomho Seo wrote:
 On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
 On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
 On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
 2015-03-09 1:35 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
 On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
 From: Beomho Seo beomho@samsung.com

 This patch adds device driver of max77843 charger. This driver provide
 initialize each charging mode(e.g. fast charge, top-off mode and 
 constant
 charging mode so on.). Additionally, control charging paramters to use
 i2c interface.

 Cc: Sebastian Reichel s...@kernel.org
 Signed-off-by: Beomho Seo beomho@samsung.com

 Reviewed-By: Sebastian Reichel s...@kernel.org

 I can't take it as is, since it depends on the private header file
 of PATCHv1.

 -- Sebastian


 This patch reviewed by Sebastian.
 Could you Please merge that your git tree ?

 Hi,

 ... and again we are adding a new driver for very similar chipset to
 already supported. I looked at spec and the charger's registers are
 almost the same as for max77693. Their layout and addresses are the
 same. I see some minor differences, probably the most important would
 be different values current (fast-charge, top-off). But still 90% of
 registers are the same... Do we really have to add new driver?

 Best regards,
 Krzysztof
 --
 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


 Hi,

 Thank you for your comment. As you say, both chip set are similar.
 But new driver need for support max77843. It is support different below
 - Provide Battery presence information.

 Another set of power supply properties could be added for that chip.
 This way the get_property() function would be the same but actually the
 POWER_SUPPLY_PROP_PRESENT won't be called for max77693.

 - Can OTG FET control.

 Where the OTG FET feature is it enabled in your driver? I couldn't find
 it.


 Sorry. This driver don't control OTG FET feature.

 - Bigger Fast charge current, Top Off current Threshold selection.
 - Various and bigger OTG current limitation.
 - Bigger primary charger termination voltage setting.
 - Different maximum input current limit selection(Different step).

 Yes, I mentioned some of these differences (the Fast/top-off
 differences). These are differences in values so it does not require new
 driver. There is need to develop new driver just to support different
 current (3.0 A instead of 2.1 A) or voltage threshold.


 They are different charging current, OTG current limitation, top off 
 current,
 charging limitation value. In case OTG current limitation different not
 limitation value but using register bit(max77843 use[7:6] max77693 use[7]
 bit only). Even if this driver not support all feature, some register
 different with max77693(support value, use register bit).

 If this driver will combined with max77693 may even be beneficial for
 new Maxim driver. But the present, this driver is related with
 max77843 core driver and max77843-regulator. So I hope this driver
 merge first. And then will extend two driver(max77843 charger and max77693 
 charger).
 
 I still prefer merging common drivers into one instead of creating
 some more of them.
 However I understand your point and I am not entirely opposed against.
 Especially that you invested quite a bit of time for developing this
 and my feedback was quite late. To summarize I am fine with your
 approach.
 
 Best regards,
 Krzysztof
 

Then, Can I request merge this patch ?

Best regards,
Beomho
--
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 v7 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver

2015-03-24 Thread Beomho Seo
On 03/10/2015 10:44 PM, Beomho Seo wrote:
 On 03/09/2015 07:01 PM, Krzysztof Kozlowski wrote:
 2015-03-09 1:36 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/08/2015 05:14 AM, Sebastian Reichel wrote:
 Hi,

 On Mon, Mar 02, 2015 at 07:10:36PM +0900, Jaewon Kim wrote:
 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

 Reviewed-By: Sebastian Reichel s...@kernel.org

 I can't take it as is, since it depends on the private header file
 of PATCH 1.

 -- Sebastian


 This patch reviewed by Sebastian.
 Could you Please merge that your git tree ?

 Hi,

 Sorry for late response, but I finally got some time to look at this.
 This driver looks very similar to max17042_battery.c fuel gauge
 driver. Obtaining some properties looks exactly the same. The
 difference seems to be in new properties. The I2C address is the same.

 I highly recommend to extend the max17042 driver instead. It already
 supports also max17047, max17050 and max77693.

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

 
 OK. I will follow your opinion about fuel gauge. I will extend the max17042 
 driver.
 After test on my board, I will send a new patch set.
 
 Best regards,
 Beomho Seo

Krzysztof, gentle ping?

I will extend the max17042 driver.

Best regards,
Beomho Seo

--
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 v7 2/5] power: max77843_charger: Add Max77843 charger device driver

2015-03-24 Thread Beomho Seo
On 03/10/2015 10:44 PM, Beomho Seo wrote:
 On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
 On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
 On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
 2015-03-09 1:35 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
 On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
 From: Beomho Seo beomho@samsung.com

 This patch adds device driver of max77843 charger. This driver provide
 initialize each charging mode(e.g. fast charge, top-off mode and 
 constant
 charging mode so on.). Additionally, control charging paramters to use
 i2c interface.

 Cc: Sebastian Reichel s...@kernel.org
 Signed-off-by: Beomho Seo beomho@samsung.com

 Reviewed-By: Sebastian Reichel s...@kernel.org

 I can't take it as is, since it depends on the private header file
 of PATCHv1.

 -- Sebastian


 This patch reviewed by Sebastian.
 Could you Please merge that your git tree ?

 Hi,

 ... and again we are adding a new driver for very similar chipset to
 already supported. I looked at spec and the charger's registers are
 almost the same as for max77693. Their layout and addresses are the
 same. I see some minor differences, probably the most important would
 be different values current (fast-charge, top-off). But still 90% of
 registers are the same... Do we really have to add new driver?

 Best regards,
 Krzysztof
 --
 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


 Hi,

 Thank you for your comment. As you say, both chip set are similar.
 But new driver need for support max77843. It is support different below
 - Provide Battery presence information.

 Another set of power supply properties could be added for that chip.
 This way the get_property() function would be the same but actually the
 POWER_SUPPLY_PROP_PRESENT won't be called for max77693.

 - Can OTG FET control.

 Where the OTG FET feature is it enabled in your driver? I couldn't find
 it.

 
 Sorry. This driver don't control OTG FET feature.
 
 - Bigger Fast charge current, Top Off current Threshold selection.
 - Various and bigger OTG current limitation.
 - Bigger primary charger termination voltage setting.
 - Different maximum input current limit selection(Different step).

 Yes, I mentioned some of these differences (the Fast/top-off
 differences). These are differences in values so it does not require new
 driver. There is need to develop new driver just to support different
 current (3.0 A instead of 2.1 A) or voltage threshold.

 
 They are different charging current, OTG current limitation, top off current,
 charging limitation value. In case OTG current limitation different not
 limitation value but using register bit(max77843 use[7:6] max77693 use[7]
 bit only). Even if this driver not support all feature, some register
 different with max77693(support value, use register bit).
 
 If this driver will combined with max77693 may even be beneficial for
 new Maxim driver. But the present, this driver is related with
 max77843 core driver and max77843-regulator. So I hope this driver
 merge first. And then will extend two driver(max77843 charger and max77693 
 charger).
 
 So the only new feature - battery presence - can be easily added to
 existing driver. The driver can be extended for different
 current/voltage values. Such extension may even be beneficial for new
 Maxim MUIC/PMIC chipsets.


 Best regards,
 Krzysztof

 
 Best regards,
 Beomho Seo

Krzysztof, gentle ping?

Best regards,
Beomho Seo

--
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 v5 1/2] power: rt5033_charger: Add RT5033 charger device driver

2015-03-11 Thread Beomho Seo
On 03/11/2015 08:06 PM, Paul Bolle wrote:
 On Mon, 2015-03-09 at 10:23 +0900, Beomho Seo wrote:
 --- /dev/null
 +++ b/drivers/power/rt5033_charger.c
 @@ -0,0 +1,485 @@
 +/*
 + * Battery charger driver for RT5033
 + *
 + * Copyright (C) 2014 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.
 + */
 
 (bythe?)
 
 This states the license is GPL v2.
 
 +MODULE_LICENSE(GPL);
 
 So you probably meant
 MODULE_LICENSE(GPL v2);
 
 
 Paul Bolle
 

OK I will fix wrong spacing and state the license.
Additionally, fix wrong spacing all rt5033-* driver.

Best regards,
Beomho Seo
--
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 v7 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver

2015-03-10 Thread Beomho Seo
On 03/09/2015 07:01 PM, Krzysztof Kozlowski wrote:
 2015-03-09 1:36 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/08/2015 05:14 AM, Sebastian Reichel wrote:
 Hi,

 On Mon, Mar 02, 2015 at 07:10:36PM +0900, Jaewon Kim wrote:
 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

 Reviewed-By: Sebastian Reichel s...@kernel.org

 I can't take it as is, since it depends on the private header file
 of PATCH 1.

 -- Sebastian


 This patch reviewed by Sebastian.
 Could you Please merge that your git tree ?
 
 Hi,
 
 Sorry for late response, but I finally got some time to look at this.
 This driver looks very similar to max17042_battery.c fuel gauge
 driver. Obtaining some properties looks exactly the same. The
 difference seems to be in new properties. The I2C address is the same.
 
 I highly recommend to extend the max17042 driver instead. It already
 supports also max17047, max17050 and max77693.
 
 Best regards,
 Krzysztof
 --
 To unsubscribe from this list: send the line unsubscribe linux-pm in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 

OK. I will follow your opinion about fuel gauge. I will extend the max17042 
driver.
After test on my board, I will send a new patch set.

Best regards,
Beomho Seo
--
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 v7 2/5] power: max77843_charger: Add Max77843 charger device driver

2015-03-10 Thread Beomho Seo
On 03/09/2015 09:13 PM, Krzysztof Kozlowski wrote:
 On pon, 2015-03-09 at 20:46 +0900, Beomho Seo wrote:
 On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
 2015-03-09 1:35 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
 On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
 From: Beomho Seo beomho@samsung.com

 This patch adds device driver of max77843 charger. This driver provide
 initialize each charging mode(e.g. fast charge, top-off mode and constant
 charging mode so on.). Additionally, control charging paramters to use
 i2c interface.

 Cc: Sebastian Reichel s...@kernel.org
 Signed-off-by: Beomho Seo beomho@samsung.com

 Reviewed-By: Sebastian Reichel s...@kernel.org

 I can't take it as is, since it depends on the private header file
 of PATCHv1.

 -- Sebastian


 This patch reviewed by Sebastian.
 Could you Please merge that your git tree ?

 Hi,

 ... and again we are adding a new driver for very similar chipset to
 already supported. I looked at spec and the charger's registers are
 almost the same as for max77693. Their layout and addresses are the
 same. I see some minor differences, probably the most important would
 be different values current (fast-charge, top-off). But still 90% of
 registers are the same... Do we really have to add new driver?

 Best regards,
 Krzysztof
 --
 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


 Hi,

 Thank you for your comment. As you say, both chip set are similar.
 But new driver need for support max77843. It is support different below
 - Provide Battery presence information.
 
 Another set of power supply properties could be added for that chip.
 This way the get_property() function would be the same but actually the
 POWER_SUPPLY_PROP_PRESENT won't be called for max77693.
 
 - Can OTG FET control.
 
 Where the OTG FET feature is it enabled in your driver? I couldn't find
 it.
 

Sorry. This driver don't control OTG FET feature.

 - Bigger Fast charge current, Top Off current Threshold selection.
 - Various and bigger OTG current limitation.
 - Bigger primary charger termination voltage setting.
 - Different maximum input current limit selection(Different step).
 
 Yes, I mentioned some of these differences (the Fast/top-off
 differences). These are differences in values so it does not require new
 driver. There is need to develop new driver just to support different
 current (3.0 A instead of 2.1 A) or voltage threshold.
 

They are different charging current, OTG current limitation, top off current,
charging limitation value. In case OTG current limitation different not
limitation value but using register bit(max77843 use[7:6] max77693 use[7]
bit only). Even if this driver not support all feature, some register
different with max77693(support value, use register bit).

If this driver will combined with max77693 may even be beneficial for
new Maxim driver. But the present, this driver is related with
max77843 core driver and max77843-regulator. So I hope this driver
merge first. And then will extend two driver(max77843 charger and max77693 
charger).

 So the only new feature - battery presence - can be easily added to
 existing driver. The driver can be extended for different
 current/voltage values. Such extension may even be beneficial for new
 Maxim MUIC/PMIC chipsets.
 
 
 Best regards,
 Krzysztof
 

Best regards,
Beomho Seo
--
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 v7 2/5] power: max77843_charger: Add Max77843 charger device driver

2015-03-09 Thread Beomho Seo
On 03/09/2015 08:02 PM, Krzysztof Kozlowski wrote:
 2015-03-09 1:35 GMT+01:00 Beomho Seo beomho@samsung.com:
 On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
 On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
 From: Beomho Seo beomho@samsung.com

 This patch adds device driver of max77843 charger. This driver provide
 initialize each charging mode(e.g. fast charge, top-off mode and constant
 charging mode so on.). Additionally, control charging paramters to use
 i2c interface.

 Cc: Sebastian Reichel s...@kernel.org
 Signed-off-by: Beomho Seo beomho@samsung.com

 Reviewed-By: Sebastian Reichel s...@kernel.org

 I can't take it as is, since it depends on the private header file
 of PATCHv1.

 -- Sebastian


 This patch reviewed by Sebastian.
 Could you Please merge that your git tree ?
 
 Hi,
 
 ... and again we are adding a new driver for very similar chipset to
 already supported. I looked at spec and the charger's registers are
 almost the same as for max77693. Their layout and addresses are the
 same. I see some minor differences, probably the most important would
 be different values current (fast-charge, top-off). But still 90% of
 registers are the same... Do we really have to add new driver?
 
 Best regards,
 Krzysztof
 --
 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
 

Hi,

Thank you for your comment. As you say, both chip set are similar.
But new driver need for support max77843. It is support different below
- Provide Battery presence information.
- Can OTG FET control.
- Bigger Fast charge current, Top Off current Threshold selection.
- Various and bigger OTG current limitation.
- Bigger primary charger termination voltage setting.
- Different maximum input current limit selection(Different step).

I respect your opinion but I think add new driver better.

Best regards,
Beomho Seo


--
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 v7 3/5] power: max77843_battery: Add Max77843 fuel gauge device driver

2015-03-08 Thread Beomho Seo
On 03/08/2015 05:14 AM, Sebastian Reichel wrote:
 Hi,
 
 On Mon, Mar 02, 2015 at 07:10:36PM +0900, Jaewon Kim wrote:
 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
 
 Reviewed-By: Sebastian Reichel s...@kernel.org
 
 I can't take it as is, since it depends on the private header file
 of PATCH 1.
 
 -- Sebastian
 

This patch reviewed by Sebastian.
Could you Please merge that your git tree ?

Best regards,
Beomho Seo
--
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 v7 2/5] power: max77843_charger: Add Max77843 charger device driver

2015-03-08 Thread Beomho Seo
On 03/08/2015 05:13 AM, Sebastian Reichel wrote:
 On Mon, Mar 02, 2015 at 07:10:35PM +0900, Jaewon Kim wrote:
 From: Beomho Seo beomho@samsung.com

 This patch adds device driver of max77843 charger. This driver provide
 initialize each charging mode(e.g. fast charge, top-off mode and constant
 charging mode so on.). Additionally, control charging paramters to use
 i2c interface.

 Cc: Sebastian Reichel s...@kernel.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 
 Reviewed-By: Sebastian Reichel s...@kernel.org
 
 I can't take it as is, since it depends on the private header file
 of PATCHv1.
 
 -- Sebastian
 

This patch reviewed by Sebastian.
Could you Please merge that your git tree ?

Best regards,
Beomho Seo
--
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 v5 1/2] power: rt5033_charger: Add RT5033 charger device driver

2015-03-08 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v5
- none.
Changes in v4
- Change power supply type to POWER_SUPPLY_TYPE_MAINS.
Changes in v3
Changes in v2
- none

 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 27b751b..67e9af7 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -418,6 +418,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 36f9e0d..c5d72e0 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -59,6 +59,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..7f8f6c3
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT)
+   state = RT5033_CHG_MAX_CURRENT;
+
+   data = state * 100 + 700;
+
+   return data;
+}
+
+static int rt5033_get_charge_voltage(struct

[PATCH 2/2] Documentation: Add documentation for rt5033 multifunction device

2015-03-08 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Sebastian Reichel s...@kernel.org
Cc: Lee Jones lee.jo...@linaro.org
Cc: Mark Brown broo...@kernel.org
Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v5
- Remove wrong Acked-by.
Changes in v4
- none.
Changes in v3
- Add Acked-by
Changes in v2
- Fix incorrect typo.
- Align -uamp and -uvolt names with regulator binding suffixes.
- Drop incorrect phandle.
- Fix incorrect example.
---
 Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 102 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..64b23e8
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,101 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators using the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,fast-uamp = 200;
+   richtek,eoc-uamp = 25;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,const-uvolt = 435;
+
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   rt5033@35 {
+   compatible = richtek,rt5033-battery;
+   interrupt-parent = gpx2;
+   interrupts = 3 0;
+   reg = 0x35;
+   };
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,fast-uamp = 200;
+   richtek,eoc-uamp = 25;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,const-uvolt = 435;
+   };
+
+   };
+
+   rt5033@35 {
+   compatible

[PATCH v5 0/2] power: rt5033: Add Richtek RT533 drivers

2015-03-08 Thread Beomho Seo
This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge.
Additionally, This includes document for device tree of RT5033 device.

RT5033 charger driver and DT documentation merged by Sebastian.
But now, removed both patches from his git tree. Because, It would be nice to
get an ACK of a DT binding maintainer. Could you plase review or some acked?

http://marc.info/?l=linux-pmm=142195148111292w=2

RT5033 core driver is applied by Lee Jones.
RT5033 regulator driver is applied by Mark Brown.
RT5033 fuelgauge driver is applied by Sebastian Reichel.

Changes in v5:
- Remove wrong acked-by.

Changes in v4:
- Change power supply type.

Changes in v3:
- Applied one of patchset.
- Add acked-by.

Changes in v2:
- Revise binding documentation.

Beomho Seo (2):
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 5 files changed, 596 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/power/rt5033_charger.c

-- 
1.7.9.5

--
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 v5 1/2] power: rt5033_charger: Add RT5033 charger device driver

2015-03-08 Thread Beomho Seo
On 03/09/2015 10:50 AM, Sebastian Reichel wrote:
 Hi Beomho,
 
 On Mon, Mar 09, 2015 at 10:23:10AM +0900, Beomho Seo wrote:
 This patch add device driver of Richtek RT5033 PMIC. The driver support
 switching charger. rt5033 charger provide three charging mode.
 Three charging mode are pre charge mode, fast cahrge mode and constant 
 voltage
 mode. They are have vary charge rate, charge parameters. The charge 
 parameters
 can be controlled by i2c interface.
 
 Driver looks mostly ok, but I have some comments [inline].
 
 Cc: Sebastian Reichel s...@kernel.org
 Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
 Cc: David Woodhouse dw...@infradead.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
 Changes in v5
 - none.
 Changes in v4
 - Change power supply type to POWER_SUPPLY_TYPE_MAINS.
 Changes in v3
 Changes in v2
 - none

  drivers/power/Kconfig  |8 +
  drivers/power/Makefile |1 +
  drivers/power/rt5033_charger.c |  485 
 
  3 files changed, 494 insertions(+)
  create mode 100644 drivers/power/rt5033_charger.c

 diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
 index 27b751b..67e9af7 100644
 --- a/drivers/power/Kconfig
 +++ b/drivers/power/Kconfig
 @@ -418,6 +418,14 @@ config BATTERY_RT5033
The fuelgauge calculates and determines the battery state of charge
according to battery open circuit voltage.
  
 +config CHARGER_RT5033
 +tristate RT5033 battery charger support
 +depends on MFD_RT5033
 +help
 +  This adds support for battery charger in Richtek RT5033 PMIC.
 +  The device supports pre-charge mode, fast charge mode and
 +  constant voltage mode.
 +
  source drivers/power/reset/Kconfig
  
  endif # POWER_SUPPLY
 diff --git a/drivers/power/Makefile b/drivers/power/Makefile
 index 36f9e0d..c5d72e0 100644
 --- a/drivers/power/Makefile
 +++ b/drivers/power/Makefile
 @@ -59,6 +59,7 @@ obj-$(CONFIG_CHARGER_BQ2415X)  += bq2415x_charger.o
  obj-$(CONFIG_CHARGER_BQ24190)   += bq24190_charger.o
  obj-$(CONFIG_CHARGER_BQ24735)   += bq24735-charger.o
  obj-$(CONFIG_POWER_AVS) += avs/
 +obj-$(CONFIG_POWER_RT5033)  += rt5033_charger.o
 
 this should be 
 
 obj-$(CONFIG_CHARGER_RT5033) += rt5033_charger.o
 
 according to your Kconfig patch. How did you test it actually?
 

Sorry, My mistake. This patch have been tested on my board.
I will double-check before send patch set.

  obj-$(CONFIG_CHARGER_SMB347)+= smb347-charger.o
  obj-$(CONFIG_CHARGER_TPS65090)  += tps65090-charger.o
  obj-$(CONFIG_POWER_RESET)   += reset/
 diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
 new file mode 100644
 index 000..7f8f6c3
 --- /dev/null
 +++ b/drivers/power/rt5033_charger.c

 [...]

 +static int rt5033_get_charger_current(struct rt5033_charger *charger,
 +enum power_supply_property psp)
 +{
 +struct regmap *regmap = charger-rt5033-regmap;
 +unsigned int state, reg_data, data;
 +
 +if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
 +return RT5033_CHG_MAX_CURRENT;
 
 drop this psp check and the psp parameter to this function, so that
 the function only takes care of the current current.
 

OK. I will remove above lines.

 +regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
 +
 +state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
 +
 +if (state  RT5033_CHG_MAX_CURRENT)
 +state = RT5033_CHG_MAX_CURRENT;
 +
 +data = state * 100 + 700;
 +
 +return data;
 +}
 +
 +static int rt5033_get_charge_voltage(struct rt5033_charger *charger,
 +enum power_supply_property psp)
 +{
 +struct regmap *regmap = charger-rt5033-regmap;
 +unsigned int state, reg_data, data;
 +
 +if (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX)
 +return RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MAX;
 
 drop this psp check and the psp parameter to this function, so that
 the function only takes care of the current voltage.
 

OK. I will remove above lines.

 +regmap_read(regmap, RT5033_REG_CHG_CTRL2, reg_data);
 +
 +state = reg_data  2;
 +
 +data = RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MIN +
 +RT5033_CHARGER_CONST_VOLTAGE_STEP_NUM * state;
 +
 +if (data  RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MAX)
 +data = RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MAX;
 +
 +return data;
 +}

 [...]

 +
 +static enum power_supply_property rt5033_charger_props[] = {
 +POWER_SUPPLY_PROP_STATUS,
 +POWER_SUPPLY_PROP_CHARGE_TYPE,
 +POWER_SUPPLY_PROP_CURRENT_NOW,
 +POWER_SUPPLY_PROP_CURRENT_MAX,
 +POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
 +POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
 +POWER_SUPPLY_PROP_MODEL_NAME,
 +POWER_SUPPLY_PROP_MANUFACTURER,
 +};
 +
 +static int rt5033_charger_get_property(struct power_supply *psy,
 +enum power_supply_property psp,
 +union

Re: [PATCH v5 1/2] power: rt5033_charger: Add RT5033 charger device driver

2015-03-08 Thread Beomho Seo
On 03/09/2015 12:46 PM, Beomho Seo wrote:
 On 03/09/2015 10:50 AM, Sebastian Reichel wrote:
 Hi Beomho,

 On Mon, Mar 09, 2015 at 10:23:10AM +0900, Beomho Seo wrote:
 This patch add device driver of Richtek RT5033 PMIC. The driver support
 switching charger. rt5033 charger provide three charging mode.
 Three charging mode are pre charge mode, fast cahrge mode and constant 
 voltage
 mode. They are have vary charge rate, charge parameters. The charge 
 parameters
 can be controlled by i2c interface.

 Driver looks mostly ok, but I have some comments [inline].

 Cc: Sebastian Reichel s...@kernel.org
 Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
 Cc: David Woodhouse dw...@infradead.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
 Changes in v5
 - none.
 Changes in v4
 - Change power supply type to POWER_SUPPLY_TYPE_MAINS.
 Changes in v3
 Changes in v2
 - none

  drivers/power/Kconfig  |8 +
  drivers/power/Makefile |1 +
  drivers/power/rt5033_charger.c |  485 
 
  3 files changed, 494 insertions(+)
  create mode 100644 drivers/power/rt5033_charger.c

 diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
 index 27b751b..67e9af7 100644
 --- a/drivers/power/Kconfig
 +++ b/drivers/power/Kconfig
 @@ -418,6 +418,14 @@ config BATTERY_RT5033
   The fuelgauge calculates and determines the battery state of charge
   according to battery open circuit voltage.
  
 +config CHARGER_RT5033
 +   tristate RT5033 battery charger support
 +   depends on MFD_RT5033
 +   help
 + This adds support for battery charger in Richtek RT5033 PMIC.
 + The device supports pre-charge mode, fast charge mode and
 + constant voltage mode.
 +
  source drivers/power/reset/Kconfig
  
  endif # POWER_SUPPLY
 diff --git a/drivers/power/Makefile b/drivers/power/Makefile
 index 36f9e0d..c5d72e0 100644
 --- a/drivers/power/Makefile
 +++ b/drivers/power/Makefile
 @@ -59,6 +59,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
  obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
  obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
  obj-$(CONFIG_POWER_AVS)+= avs/
 +obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o

 this should be 

 obj-$(CONFIG_CHARGER_RT5033) += rt5033_charger.o

 according to your Kconfig patch. How did you test it actually?

 
 Sorry, My mistake. This patch have been tested on my board.
 I will double-check before send patch set.
 
  obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
  obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
  obj-$(CONFIG_POWER_RESET)  += reset/
 diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
 new file mode 100644
 index 000..7f8f6c3
 --- /dev/null
 +++ b/drivers/power/rt5033_charger.c

 [...]

 +static int rt5033_get_charger_current(struct rt5033_charger *charger,
 +   enum power_supply_property psp)
 +{
 +   struct regmap *regmap = charger-rt5033-regmap;
 +   unsigned int state, reg_data, data;
 +
 +   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
 +   return RT5033_CHG_MAX_CURRENT;

 drop this psp check and the psp parameter to this function, so that
 the function only takes care of the current current.

 
 OK. I will remove above lines.
 
 +   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
 +
 +   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
 +
 +   if (state  RT5033_CHG_MAX_CURRENT)
 +   state = RT5033_CHG_MAX_CURRENT;
 +
 +   data = state * 100 + 700;
 +
 +   return data;
 +}
 +
 +static int rt5033_get_charge_voltage(struct rt5033_charger *charger,
 +   enum power_supply_property psp)
 +{
 +   struct regmap *regmap = charger-rt5033-regmap;
 +   unsigned int state, reg_data, data;
 +
 +   if (psp == POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX)
 +   return RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MAX;

 drop this psp check and the psp parameter to this function, so that
 the function only takes care of the current voltage.

 
 OK. I will remove above lines.
 
 +   regmap_read(regmap, RT5033_REG_CHG_CTRL2, reg_data);
 +
 +   state = reg_data  2;
 +
 +   data = RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MIN +
 +   RT5033_CHARGER_CONST_VOLTAGE_STEP_NUM * state;
 +
 +   if (data  RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MAX)
 +   data = RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MAX;
 +
 +   return data;
 +}

 [...]

 +
 +static enum power_supply_property rt5033_charger_props[] = {
 +   POWER_SUPPLY_PROP_STATUS,
 +   POWER_SUPPLY_PROP_CHARGE_TYPE,
 +   POWER_SUPPLY_PROP_CURRENT_NOW,
 +   POWER_SUPPLY_PROP_CURRENT_MAX,
 +   POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
 +   POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
 +   POWER_SUPPLY_PROP_MODEL_NAME,
 +   POWER_SUPPLY_PROP_MANUFACTURER,
 +};
 +
 +static int rt5033_charger_get_property(struct power_supply *psy,
 +   enum power_supply_property psp,
 +   union

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 2/5] power: max77843_charger: Add Max77843 charger device driver

2015-03-01 Thread Beomho Seo
On 03/01/2015 05:03 AM, Paul Bolle wrote:
 On Tue, 2015-02-24 at 10:29 +0900, Jaewon Kim wrote:
 diff --git a/drivers/power/max77843_charger.c 
 b/drivers/power/max77843_charger.c
 new file mode 100644
 index 000..392eebc1a
 --- /dev/null
 +++ b/drivers/power/max77843_charger.c
 @@ -0,0 +1,508 @@
 +/*
 + * Charger 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.
 
 There's bythe again.
 
 + */
 
 [...]
 

OK, I will add spacer.

 +MODULE_LICENSE(GPL);
 
 And that should probably be
 MODULE_LICENSE(GPL v2);
 
 
 Paul Bolle
 
 

OK, I will change license.
Thank you for your review.

Thanks,
Beomho Seo

--
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 4/6] power: max77843_battery: Add Max77843 fuel gauge device driver

2015-01-25 Thread Beomho Seo
Hi,

Thanks for your review.

I'll fix patch as your advice.

Thanks,
Beomho Seo

On 01/25/2015 10:53 PM, Sebastian Reichel wrote:
 Hi,
 
 On Fri, Jan 23, 2015 at 02:02:45PM +0900, Jaewon Kim wrote:
 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 |  283 
 ++
  3 files changed, 293 insertions(+)
  create mode 100644 drivers/power/max77843_battery.c

 diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
 index a054a28..0039bbb 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 add support for battery fuel gauge in Maxim MAX77843.
 
 add - adds
 
 +  It is fuel-gauge systems for lithuum-ion (Li+) batteries in handled 
 and
 +  portable devices. The MAX17040 is configured to operate with a single
 +  lithium cell.
 
 It is a fuel-gauge for a lithium-ion batteries with a single
 cell and can be found in portable devices.
 
 +
  config BATTERY_Z2
  tristate Z2 battery driver
  depends on I2C  MACH_ZIPIT2
 diff --git a/drivers/power/Makefile b/drivers/power/Makefile
 index 212c6a2..ae0d795 100644
 --- a/drivers/power/Makefile
 +++ b/drivers/power/Makefile
 @@ -33,6 +33,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_S3C_ADC)   += s3c_adc_battery.o
  obj-$(CONFIG_BATTERY_TWL4030_MADC)  += twl4030_madc_battery.o
 diff --git a/drivers/power/max77843_battery.c 
 b/drivers/power/max77843_battery.c
 new file mode 100644
 index 000..a08dd0c
 --- /dev/null
 +++ b/drivers/power/max77843_battery.c
 @@ -0,0 +1,283 @@
 +/*
 + * Fuel gauge driver for Maxim MAX77843
 + *
 + * Copyright (C) 2014 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;
 +u8 reg_data[2];
 +
 +ret = regmap_bulk_read(regmap, MAX77843_FG_REG_SOCREP, reg_data, 2);
 +if (ret) {
 +dev_err(battery-dev, Failed to read fuelgauge register\n);
 +return ret;
 +}
 +
 +val =  ((reg_data[1] * 100) + (reg_data[0] * 100 / 256)) / 100;
 
 so
 
 val = reg_data[1]?
 
 +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;
 +u8 reg_data[2];
 +
 +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_bulk_read(regmap, reg, reg_data, 2);
 +if (ret) {
 +dev_err(battery-dev, Failed to read fuelgauge register\n);
 +return ret;
 +}
 +
 +val = (reg_data[1]  8) | reg_data[0];
 +
 +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;
 +u8 reg_data[2];
 +
 +switch (psp) {
 +case POWER_SUPPLY_PROP_CURRENT_NOW:
 +reg

Re: [PATCH 1/6] mfd: max77843: Add max77843 MFD driver core driver

2015-01-23 Thread Beomho Seo
On 01/23/2015 08:18 PM, Krzysztof Kozlowski wrote:
 On piÄ…, 2015-01-23 at 20:10 +0900, Beomho Seo wrote:
 On 01/23/2015 04:16 PM, Krzysztof Kozlowski wrote:
 On piÄ…, 2015-01-23 at 15:41 +0900, Beomho Seo wrote:
 On 01/23/2015 03:32 PM, Krzysztof Kozlowski wrote:
 2015-01-23 6:02 GMT+01:00 Jaewon Kim jaewon02@samsung.com:
 This patch adds MAX77843 core/irq driver to support PMIC,
 MUIC(Micro USB Interface Controller), Charger, Fuel Gauge,
 LED and Haptic device.

 Cc: Lee Jones lee.jo...@linaro.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Signed-off-by: Jaewon Kim jaewon02@samsung.com
 ---
  drivers/mfd/Kconfig  |   14 ++
  drivers/mfd/Makefile |1 +
  drivers/mfd/max77843.c   |  241 
  include/linux/mfd/max77843-private.h |  410 
 ++
  4 files changed, 666 insertions(+)
  create mode 100644 drivers/mfd/max77843.c
  create mode 100644 include/linux/mfd/max77843-private.h

 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index 2e6b731..0c67c79 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -442,6 +442,20 @@ config MFD_MAX77693
   additional drivers must be enabled in order to use the 
 functionality
   of the device.

 +config MFD_MAX77843
 +   bool Maxim Semiconductor MAX77843 PMIC Support
 +   depends on I2C=y
 +   select MFD_CORE
 +   select REGMAP_I2C
 +   select REGMAP_IRQ
 +   help
 + Say yes here to add support for Maxim Semiconductor MAX77843.
 + This is companion Power Management IC with LEDs, Haptic, 
 Charger,
 + Fuel Gauge, MUIC(Micro USB Interface Controller) controls on 
 chip.
 + This driver provides common support for accessing the device;
 + additional drivers must be enabled in order to use the 
 functionality
 + of the device.
 +
  config MFD_MAX8907
 tristate Maxim Semiconductor MAX8907 PMIC Support
 select MFD_CORE
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 53467e2..fe4f75c 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -117,6 +117,7 @@ obj-$(CONFIG_MFD_DA9063)+= da9063.o
  obj-$(CONFIG_MFD_MAX14577) += max14577.o
  obj-$(CONFIG_MFD_MAX77686) += max77686.o
  obj-$(CONFIG_MFD_MAX77693) += max77693.o
 +obj-$(CONFIG_MFD_MAX77843) += max77843.o
  obj-$(CONFIG_MFD_MAX8907)  += max8907.o
  max8925-objs   := max8925-core.o max8925-i2c.o
  obj-$(CONFIG_MFD_MAX8925)  += max8925.o
 diff --git a/drivers/mfd/max77843.c b/drivers/mfd/max77843.c
 new file mode 100644
 index 000..d7f8b76
 --- /dev/null
 +++ b/drivers/mfd/max77843.c
 @@ -0,0 +1,241 @@
 +/*
 + * max77843.c - MFD core driver for the Maxim MAX77843
 + *
 + * Copyright (C) 2014 Samsung Electrnoics
 + * Author: Jaewon Kim jaewon02@samsung.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + */
 +
 +#include linux/err.h
 +#include linux/i2c.h
 +#include linux/init.h
 +#include linux/interrupt.h
 +#include linux/module.h
 +#include linux/mfd/core.h
 +#include linux/mfd/max77843-private.h
 +#include linux/of_device.h
 +#include linux/platform_device.h
 +
 +static const struct mfd_cell max77843_devs[] = {
 +   {
 +   .name = max77843-muic,
 +   .of_compatible = maxim,max77843-muic,
 +   }, {
 +   .name = max77843-regulator,
 +   .of_compatible = maxim,max77843-regulator,
 +   }, {
 +   .name = max77843-charger,
 +   .of_compatible = maxim,max77843-charger
 +   }, {
 +   .name = max77843-fuelgauge,
 +   .of_compatible = maxim,max77843-fuelgauge,
 +   },
 +};
 +
 +static const struct regmap_config max77843_charger_regmap_config = {
 +   .reg_bits   = 8,
 +   .val_bits   = 8,
 +   .max_register   = MAX77843_CHG_REG_END,
 +};
 +
 +static const struct regmap_config max77843_regmap_config = {
 +   .reg_bits   = 8,
 +   .val_bits   = 8,
 +   .max_register   = MAX77843_SYS_REG_END,
 +};
 +
 +static const struct regmap_irq max77843_irqs[] = {
 +   /* TOPSYS interrupts */
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_SYSUVLO_INT, },
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_SYSOVLO_INT, },
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_TSHDN_INT, },
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_TM_INT, },
 +};
 +
 +static const struct regmap_irq_chip max77843_irq_chip = {
 +   .name   = max77843,
 +   .status_base= MAX77843_SYS_REG_SYSINTSRC,
 +   .mask_base  = MAX77843_SYS_REG_SYSINTMASK,
 +   .mask_invert= false,
 +   .num_regs   = 1,
 +   .irqs

Re: [PATCH 1/6] mfd: max77843: Add max77843 MFD driver core driver

2015-01-23 Thread Beomho Seo
On 01/23/2015 04:16 PM, Krzysztof Kozlowski wrote:
 On piÄ…, 2015-01-23 at 15:41 +0900, Beomho Seo wrote:
 On 01/23/2015 03:32 PM, Krzysztof Kozlowski wrote:
 2015-01-23 6:02 GMT+01:00 Jaewon Kim jaewon02@samsung.com:
 This patch adds MAX77843 core/irq driver to support PMIC,
 MUIC(Micro USB Interface Controller), Charger, Fuel Gauge,
 LED and Haptic device.

 Cc: Lee Jones lee.jo...@linaro.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Signed-off-by: Jaewon Kim jaewon02@samsung.com
 ---
  drivers/mfd/Kconfig  |   14 ++
  drivers/mfd/Makefile |1 +
  drivers/mfd/max77843.c   |  241 
  include/linux/mfd/max77843-private.h |  410 
 ++
  4 files changed, 666 insertions(+)
  create mode 100644 drivers/mfd/max77843.c
  create mode 100644 include/linux/mfd/max77843-private.h

 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index 2e6b731..0c67c79 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -442,6 +442,20 @@ config MFD_MAX77693
   additional drivers must be enabled in order to use the 
 functionality
   of the device.

 +config MFD_MAX77843
 +   bool Maxim Semiconductor MAX77843 PMIC Support
 +   depends on I2C=y
 +   select MFD_CORE
 +   select REGMAP_I2C
 +   select REGMAP_IRQ
 +   help
 + Say yes here to add support for Maxim Semiconductor MAX77843.
 + This is companion Power Management IC with LEDs, Haptic, Charger,
 + Fuel Gauge, MUIC(Micro USB Interface Controller) controls on 
 chip.
 + This driver provides common support for accessing the device;
 + additional drivers must be enabled in order to use the 
 functionality
 + of the device.
 +
  config MFD_MAX8907
 tristate Maxim Semiconductor MAX8907 PMIC Support
 select MFD_CORE
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 53467e2..fe4f75c 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -117,6 +117,7 @@ obj-$(CONFIG_MFD_DA9063)+= da9063.o
  obj-$(CONFIG_MFD_MAX14577) += max14577.o
  obj-$(CONFIG_MFD_MAX77686) += max77686.o
  obj-$(CONFIG_MFD_MAX77693) += max77693.o
 +obj-$(CONFIG_MFD_MAX77843) += max77843.o
  obj-$(CONFIG_MFD_MAX8907)  += max8907.o
  max8925-objs   := max8925-core.o max8925-i2c.o
  obj-$(CONFIG_MFD_MAX8925)  += max8925.o
 diff --git a/drivers/mfd/max77843.c b/drivers/mfd/max77843.c
 new file mode 100644
 index 000..d7f8b76
 --- /dev/null
 +++ b/drivers/mfd/max77843.c
 @@ -0,0 +1,241 @@
 +/*
 + * max77843.c - MFD core driver for the Maxim MAX77843
 + *
 + * Copyright (C) 2014 Samsung Electrnoics
 + * Author: Jaewon Kim jaewon02@samsung.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + */
 +
 +#include linux/err.h
 +#include linux/i2c.h
 +#include linux/init.h
 +#include linux/interrupt.h
 +#include linux/module.h
 +#include linux/mfd/core.h
 +#include linux/mfd/max77843-private.h
 +#include linux/of_device.h
 +#include linux/platform_device.h
 +
 +static const struct mfd_cell max77843_devs[] = {
 +   {
 +   .name = max77843-muic,
 +   .of_compatible = maxim,max77843-muic,
 +   }, {
 +   .name = max77843-regulator,
 +   .of_compatible = maxim,max77843-regulator,
 +   }, {
 +   .name = max77843-charger,
 +   .of_compatible = maxim,max77843-charger
 +   }, {
 +   .name = max77843-fuelgauge,
 +   .of_compatible = maxim,max77843-fuelgauge,
 +   },
 +};
 +
 +static const struct regmap_config max77843_charger_regmap_config = {
 +   .reg_bits   = 8,
 +   .val_bits   = 8,
 +   .max_register   = MAX77843_CHG_REG_END,
 +};
 +
 +static const struct regmap_config max77843_regmap_config = {
 +   .reg_bits   = 8,
 +   .val_bits   = 8,
 +   .max_register   = MAX77843_SYS_REG_END,
 +};
 +
 +static const struct regmap_irq max77843_irqs[] = {
 +   /* TOPSYS interrupts */
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_SYSUVLO_INT, },
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_SYSOVLO_INT, },
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_TSHDN_INT, },
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_TM_INT, },
 +};
 +
 +static const struct regmap_irq_chip max77843_irq_chip = {
 +   .name   = max77843,
 +   .status_base= MAX77843_SYS_REG_SYSINTSRC,
 +   .mask_base  = MAX77843_SYS_REG_SYSINTMASK,
 +   .mask_invert= false,
 +   .num_regs   = 1,
 +   .irqs   = max77843_irqs,
 +   .num_irqs   = ARRAY_SIZE(max77843_irqs),
 +};
 +
 +static int max77843_chg_init(struct

Re: [PATCH v4 2/2] Documentation: Add documentation for rt5033 multifunction device

2015-01-22 Thread Beomho Seo
On 01/22/2015 04:41 PM, Lee Jones wrote:
 On Thu, 22 Jan 2015, Beomho Seo wrote:
 
 This patch device tree binding documentation for rt5033 multifunction device.

 Cc: Sebastian Reichel s...@kernel.org
 Cc: Lee Jones lee.jo...@linaro.org
 Cc: Mark Brown broo...@kernel.org
 Cc: Rob Herring robh...@kernel.org
 Cc: Pawel Moll pawel.m...@arm.com
 Cc: Mark Rutland mark.rutl...@arm.com
 Cc: Ian campbell ijc+devicet...@hellion.org.uk
 Cc: Kumar Gala ga...@codeaurora.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 Acked-by: Lee Jones lee.jo...@linaro.org
 
 I did not Ack this patch.
 
 Your new vendor bindings require a DT Ack.
 
 Although, as the ones I'm concerned with are Regulator related, and
 Ack from Mark Brown will also suffice.
 

I want to apologize for my mistake. I completely misunderstood your reply.
Unfortunately, This patch merged by Sebastian at his git.
Please tell me what to do.

 ---
 Changes in v4
 - none.
 Changes in v3
 - Add Acked-by
 Changes in v2
 - Fix incorrect typo.
 - Align -uamp and -uvolt names with regulator binding suffixes.
 - Drop incorrect phandle.
 - Fix incorrect example.
 ---

  Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
 
  .../devicetree/bindings/vendor-prefixes.txt|1 +
  2 files changed, 102 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

 diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
 b/Documentation/devicetree/bindings/mfd/rt5033.txt
 new file mode 100644
 index 000..64b23e8
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
 @@ -0,0 +1,101 @@
 +Richtek RT5033 Power management Integrated Circuit
 +
 +RT5033 is a Multifunction device which includes battery charger, fuel gauge,
 +flash LED current source, LDO and synchronous Buck converter for portable
 +applications. It is interfaced to host controller using i2c interface.
 +
 +Required properties:
 +- compatible : Must be richtek,rt5033
 +- reg : Specifies the i2c slave address of general part.
 +- interrupts : This i2c devices has an IRQ line connected to the main SoC.
 +- interrupt-parent : The parent interrupt controller.
 +
 +Optional node:
 +Regulators: The regulators of RT5033 have to be instantiated under sub-node
 +named regulators using the following format.
 +
 +regulators {
 +regulator-name {
 +regulator-name = LDO/BUCK
 +regulator subnodes called X, Y and Z
 +};
 +};
 +refer Documentation/devicetree/bindings/regulator/regulator.txt
 +
 +
 +Battery charger: There battery charger of RT5033 have to be instantiated 
 under
 +sub-node named charger using the following format.
 +
 +Required properties:
 +- compatible : Must be richtek,rt5033-charger.
 +- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current 
 levels
 +  are 350 mA to 650 mA programmed by I2C per 100 mA.
 +- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
 +  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
 +- richtek,eoc-uamp : This property is end of charge current. Its level 150 
 mA
 +  to 200 mA.
 +- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. 
 Battery
 +  voltage is below pre-charge threshold voltage, the charger is in 
 pre-charge
 +  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
 +  by I2C per 0.1 V.
 +- richtek,const-uvolt :  Battery regulation voltage of constant voltage 
 mode.
 +  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
 +
 +charger {
 +compatible = richtek,rt5033-charger;
 +richtek,pre-uamp = 35;
 +richtek,fast-uamp = 200;
 +richtek,eoc-uamp = 25;
 +richtek,pre-threshold-uvolt = 340;
 +richtek,const-uvolt = 435;
 +
 +};
 +
 +
 +Fuelgauge: There fuelgauge of RT5033 to be instantiated node named 
 fuelgauge
 +using the following format.
 +
 +Required properties:
 +- compatible = Must be richtek,rt5033-battery.
 +
 +rt5033@35 {
 +compatible = richtek,rt5033-battery;
 +interrupt-parent = gpx2;
 +interrupts = 3 0;
 +reg = 0x35;
 +};
 +
 +Example:
 +
 +rt5033@34 {
 +compatible = richtek,rt5033;
 +reg = 0x34;
 +interrupt-parent = gpx1;
 +interrupts = 5 0;
 +
 +regulators {
 +buck_reg: BUCK {
 +regulator-name = BUCK;
 +regulator-min-microvolt = 120;
 +regulator-max-microvolt = 120;
 +regulator-always-on;
 +};
 +};
 +
 +charger {
 +compatible

Re: [PATCH v4 2/2] Documentation: Add documentation for rt5033 multifunction device

2015-01-22 Thread Beomho Seo
On 01/22/2015 06:02 PM, Lee Jones wrote:
 On Thu, 22 Jan 2015, Beomho Seo wrote:
 
 On 01/22/2015 04:41 PM, Lee Jones wrote:
 On Thu, 22 Jan 2015, Beomho Seo wrote:

 This patch device tree binding documentation for rt5033 multifunction 
 device.

 Cc: Sebastian Reichel s...@kernel.org
 Cc: Lee Jones lee.jo...@linaro.org
 Cc: Mark Brown broo...@kernel.org
 Cc: Rob Herring robh...@kernel.org
 Cc: Pawel Moll pawel.m...@arm.com
 Cc: Mark Rutland mark.rutl...@arm.com
 Cc: Ian campbell ijc+devicet...@hellion.org.uk
 Cc: Kumar Gala ga...@codeaurora.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 Acked-by: Lee Jones lee.jo...@linaro.org

 I did not Ack this patch.

 Your new vendor bindings require a DT Ack.

 Although, as the ones I'm concerned with are Regulator related, and
 Ack from Mark Brown will also suffice.


 I want to apologize for my mistake. I completely misunderstood your reply.
 Unfortunately, This patch merged by Sebastian at his git.
 Please tell me what to do.
 
 That's strange, as I haven't heard anything from Sebastian.
 
 Anyway, he needs to remove it from his tree until we receive a
 suitable Ack.
 

OK, If Sebastian remove it from his tree, I will fix Acked-by. And then
wait receive a suitable Ack.

 ---
 Changes in v4
 - none.
 Changes in v3
 - Add Acked-by
 Changes in v2
 - Fix incorrect typo.
 - Align -uamp and -uvolt names with regulator binding suffixes.
 - Drop incorrect phandle.
 - Fix incorrect example.
 ---

  Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
 
  .../devicetree/bindings/vendor-prefixes.txt|1 +
  2 files changed, 102 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

 diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
 b/Documentation/devicetree/bindings/mfd/rt5033.txt
 new file mode 100644
 index 000..64b23e8
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
 @@ -0,0 +1,101 @@
 +Richtek RT5033 Power management Integrated Circuit
 +
 +RT5033 is a Multifunction device which includes battery charger, fuel 
 gauge,
 +flash LED current source, LDO and synchronous Buck converter for portable
 +applications. It is interfaced to host controller using i2c interface.
 +
 +Required properties:
 +- compatible : Must be richtek,rt5033
 +- reg : Specifies the i2c slave address of general part.
 +- interrupts : This i2c devices has an IRQ line connected to the main SoC.
 +- interrupt-parent : The parent interrupt controller.
 +
 +Optional node:
 +Regulators: The regulators of RT5033 have to be instantiated under 
 sub-node
 +named regulators using the following format.
 +
 +  regulators {
 +  regulator-name {
 +  regulator-name = LDO/BUCK
 +  regulator subnodes called X, Y and Z
 +  };
 +  };
 +  refer Documentation/devicetree/bindings/regulator/regulator.txt
 +
 +
 +Battery charger: There battery charger of RT5033 have to be instantiated 
 under
 +sub-node named charger using the following format.
 +
 +Required properties:
 +- compatible : Must be richtek,rt5033-charger.
 +- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current 
 levels
 +  are 350 mA to 650 mA programmed by I2C per 100 mA.
 +- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
 +  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
 +- richtek,eoc-uamp : This property is end of charge current. Its level 
 150 mA
 +  to 200 mA.
 +- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. 
 Battery
 +  voltage is below pre-charge threshold voltage, the charger is in 
 pre-charge
 +  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
 +  by I2C per 0.1 V.
 +- richtek,const-uvolt :  Battery regulation voltage of constant voltage 
 mode.
 +  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
 +
 +  charger {
 +  compatible = richtek,rt5033-charger;
 +  richtek,pre-uamp = 35;
 +  richtek,fast-uamp = 200;
 +  richtek,eoc-uamp = 25;
 +  richtek,pre-threshold-uvolt = 340;
 +  richtek,const-uvolt = 435;
 +
 +  };
 +
 +
 +Fuelgauge: There fuelgauge of RT5033 to be instantiated node named 
 fuelgauge
 +using the following format.
 +
 +Required properties:
 +- compatible = Must be richtek,rt5033-battery.
 +
 +  rt5033@35 {
 +  compatible = richtek,rt5033-battery;
 +  interrupt-parent = gpx2;
 +  interrupts = 3 0;
 +  reg = 0x35;
 +  };
 +
 +Example:
 +
 +  rt5033@34 {
 +  compatible = richtek,rt5033;
 +  reg = 0x34;
 +  interrupt-parent = gpx1;
 +  interrupts = 5 0;
 +
 +  regulators {
 +  buck_reg: BUCK {
 +  regulator-name = BUCK;
 +  regulator-min-microvolt

Re: [PATCH 6/6] Documentation: Add device tree bindings document for max77843

2015-01-22 Thread Beomho Seo
On 01/23/2015 03:25 PM, Chanwoo Choi wrote:
 Hi Jaewon,
 
 On 01/23/2015 02:02 PM, Jaewon Kim wrote:
 Add document describing device tree bindings for max77843 MFD.
 Drivers: MFD core, regulator, extcon, charger and fuelgauge.

 Cc: Rob Herring robh...@kernel.org
 Cc: Pawel Moll pawel.m...@arm.com
 Cc: Mark Rutland mark.rutl...@arm.com
 Cc: Ian Campbell ijc+devicet...@hellion.org.uk
 Cc: Kumar Gala ga...@codeaurora.org
 Cc: Lee Jones lee.jo...@linaro.org
 Cc: Chanwoo Choi cw00.c...@samsung.com
 Cc: Sebastian Reichel s...@kernel.org
 Cc: Mark Brown broo...@kernel.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Signed-off-by: Jaewon Kim jaewon02@samsung.com
 ---
  Documentation/devicetree/bindings/mfd/max77843.txt |   87 
 
  1 file changed, 87 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/mfd/max77843.txt

 diff --git a/Documentation/devicetree/bindings/mfd/max77843.txt 
 b/Documentation/devicetree/bindings/mfd/max77843.txt
 new file mode 100644
 index 000..6895604
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/max77843.txt
 @@ -0,0 +1,87 @@
 +Maxim MAX77843 multi-function device
 +
 +MAX77843 is a Multi-Function Device with the following submodules:
 +- PMIC: 2 SAFEOUT LDOs for USB device
 +- CHARGER : Li+ battery charger with Fuel Gauge
 +- MUIC: Micro USB Interface Circuit
 +- HAPTIC  : motor control driver for haptics
 
 HAPTIC ?
 
 +- LED : 4 channel RGBW LED
 
 LED ?
 
 This patchset don't include andy haptic/led drivers.
 I think it is un-necessary information.
 
 When you implement the haptic/led driver, you will add the information
 for haptic/led driver.
 

OK. I will remove them.

 +
 +It is interfaced to host controller using I2C.
 +
 +Required properties:
 +- compatible : Must be maxim,max77843.
 +- reg : I2C slave address of PMIC block.
 +- interrupts : I2C line for main SoCs.
 +- interrupt-parent : The parent of interrupt controller.
 +
 +Optional properties:
 +- regulators : The regulators of max77843 have to be instantiated under 
 subnode
 +named regulators using the following format.
 +
 +[*]refer : Documentation/devicetree/bindings/regulator/regulator.txt
 +
 +regulators {
 +SAFEOUT {
 +regulator-name = SAFEOUT;
 +};
 +}
 +
 +List of valid regulator names:
 +- SAFEOUT1, SAFEOUT2, CHARGER.
 +
 +- max77843-muic : This properties used by extcon consumers.
 +Required properties:
 +- compatible : Must be maxim,max77842-muic.
 +
 +- max77843-charger : There battery charger of MAX77843 have to be 
 instantiated
 +under sub-node named max77843-charger using the following format.
 +Required properties:
 +- compatible : Must be maxim,max77842-charger.
 +- maxim,fast-charge-uamp : Fast charge current levels are
 +100 mA to 3150 mA programmed by I2C per 100 mA.
 +- maxim,top-off-uamp : Top off current threshold levels are
 +125 mA to 650 mA programmed by I2C per 75 mA.
 +- maxim,input-uamp-limit : Input current limit levels are
 +100 mA to 3533 mA programmed by I2C per 33 mA.
 +- max77843-fuelgauge : There fuelgauge of MAX77843 have to be instantiated
 +under sub-node named max77843-fuelgauge using the following format.
 +Required properties:
 +- compatible : Must be maxim,max77842-fuelgauge.
 +
 +Example:
 +max77843@66 {
 +compatible = samsung,max77843;
 +reg = 0x66;
 +interrupt-parent = gpa1;
 +interrupts = 5 2;
 +
 +regulators {
 +SAFEOUT1 {
 +regulator-name = SAFEOUT1;
 +regulator-min-microvolt = 330;
 +regulator-max-microvolt = 495;
 +};
 +SAFEOUT2 {
 +regulator-name = SAFEOUT2;
 +regulator-min-microvolt = 330;
 +regulator-max-microvolt = 495;
 +};
 
 As I knew, max77843 regulator driver supprot 'CHARGER' regulator.
 I think you have to add the 'CHARGER' dt node for regulators.
 
 

Right, I will include charger regulator.

 +};
 +
 +max77843-muic {
 +compatible = maxim,max77843-muic;
 +};
 +
 +max77843-charger {
 +compatible = maxim,max77843-charger;
 +maxim,fast-charge-uamp = 45;
 +maxim,top-off-uamp = 125000;
 +maxim,input-uamp-limit = 50;
 +};
 +
 +max77843-fuelgauge {
 +compatible = maxim,max77843-fuelgauge;
 +};
 +
 +};

 
 Thanks,
 Chanwoo Choi
 --
 To unsubscribe from this list: send the line unsubscribe linux-pm in
 the body of a message

Re: [PATCH 3/6] power: max77843_charger: Add Max77843 charger device driver

2015-01-22 Thread Beomho Seo
Thank you for review.

On 01/23/2015 04:04 PM, Krzysztof Kozłowski wrote:
 2015-01-23 6:02 GMT+01:00 Jaewon Kim jaewon02@samsung.com:
 From: Beomho Seo beomho@samsung.com

 This patch adds device driver of max77843 charger. This driver provide
 initialize each charging mode(e.g. fast charge, top-off mode and constant
 charging mode so on.). Additionally, control charging paramters to use
 i2c interface.

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

 diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
 index 0108c2a..a054a28 100644
 --- a/drivers/power/Kconfig
 +++ b/drivers/power/Kconfig
 @@ -332,6 +332,13 @@ config CHARGER_MAX14577
   Say Y to enable support for the battery charger control sysfs and
   platform data of MAX14577/77836 MUICs.

 +config CHARGER_MAX77843
 +   tristate Maxim MAX77843 battery charger driver
 +   depends on MFD_MAX77843
 +   help
 + Say Y to enable support for the battery charger control sysfs and
 + platform data of MAX77843
 +
  config CHARGER_MAX8997
 tristate Maxim MAX8997/MAX8966 PMIC battery charger driver
 depends on MFD_MAX8997  REGULATOR_MAX8997
 diff --git a/drivers/power/Makefile b/drivers/power/Makefile
 index dfa8942..212c6a2 100644
 --- a/drivers/power/Makefile
 +++ b/drivers/power/Makefile
 @@ -50,6 +50,7 @@ obj-$(CONFIG_CHARGER_LP8788)  += lp8788-charger.o
  obj-$(CONFIG_CHARGER_GPIO) += gpio-charger.o
  obj-$(CONFIG_CHARGER_MANAGER)  += charger-manager.o
  obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.o
 +obj-$(CONFIG_CHARGER_MAX77843) += max77843_charger.o
  obj-$(CONFIG_CHARGER_MAX8997)  += max8997_charger.o
  obj-$(CONFIG_CHARGER_MAX8998)  += max8998_charger.o
  obj-$(CONFIG_CHARGER_BQ2415X)  += bq2415x_charger.o
 diff --git a/drivers/power/max77843_charger.c 
 b/drivers/power/max77843_charger.c
 new file mode 100644
 index 000..317b2cc
 --- /dev/null
 +++ b/drivers/power/max77843_charger.c
 @@ -0,0 +1,506 @@
 +/*
 + * Charger driver for Maxim MAX77843
 + *
 + * Copyright (C) 2014 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/interrupt.h
 +#include linux/platform_device.h
 +#include linux/power_supply.h
 +#include linux/mfd/max77843-private.h
 +
 +struct max77843_charger_info {
 +   u32 fast_charge_uamp;
 +   u32 top_off_uamp;
 +   u32 input_uamp_limit;
 +};
 +
 +struct max77843_charger {
 +   struct device   *dev;
 +   struct max77843 *max77843;
 +   struct i2c_client   *client;
 +   struct regmap   *regmap;
 +   struct power_supply psy;
 +
 +   struct max77843_charger_info*info;
 +};
 
 Why creating two separate structures?
 

max77843_charger_info structure just have property of charger.
If you want to merge one structure, I will revise above structure.

 +
 +static int max77843_charger_get_max_current(struct max77843_charger 
 *charger)
 +{
 +   struct regmap *regmap = charger-regmap;
 +   int ret, val = 0;
 +   unsigned int reg_data;
 +
 +   ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_CNFG_09, reg_data);
 +   if (ret) {
 +   dev_err(charger-dev, Failed to read charger register\n);
 +   return ret;
 +   }
 +
 +   if (reg_data = 0x03) {
 +   val = MAX77843_CHG_INPUT_CURRENT_LIMIT_MIN;
 +   } else if (reg_data = 0x78) {
 +   val = MAX77843_CHG_INPUT_CURRENT_LIMIT_MAX;
 +   } else {
 +   val = reg_data / 3;
 +   if (reg_data % 3 == 0)
 +   val *= 10;
 +   else if (reg_data % 3 == 1)
 +   val = val * 10 + 33000;
 +   else
 +   val = val * 10 + 67000;
 +   }
 +
 +   return val;
 +}
 +
 +static int max77843_charger_get_now_current(struct max77843_charger 
 *charger)
 +{
 +   struct regmap *regmap = charger-regmap;
 +   int ret, val = 0;
 +   unsigned int reg_data;
 +
 +   ret = regmap_read(regmap, MAX77843_CHG_REG_CHG_CNFG_02, reg_data);
 +   if (ret) {
 +   dev_err(charger-dev, Failed to read charger register\n);
 
 This error log shows up in many places. Please print also error code.
 
 Additionally I think it could be useful to print also details about
 register which failed. Currently user would not know which register
 access failed. Consider adding short description like

Re: [PATCH 1/6] mfd: max77843: Add max77843 MFD driver core driver

2015-01-22 Thread Beomho Seo
On 01/23/2015 03:32 PM, Krzysztof Kozlowski wrote:
 2015-01-23 6:02 GMT+01:00 Jaewon Kim jaewon02@samsung.com:
 This patch adds MAX77843 core/irq driver to support PMIC,
 MUIC(Micro USB Interface Controller), Charger, Fuel Gauge,
 LED and Haptic device.

 Cc: Lee Jones lee.jo...@linaro.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Signed-off-by: Jaewon Kim jaewon02@samsung.com
 ---
  drivers/mfd/Kconfig  |   14 ++
  drivers/mfd/Makefile |1 +
  drivers/mfd/max77843.c   |  241 
  include/linux/mfd/max77843-private.h |  410 
 ++
  4 files changed, 666 insertions(+)
  create mode 100644 drivers/mfd/max77843.c
  create mode 100644 include/linux/mfd/max77843-private.h

 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index 2e6b731..0c67c79 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -442,6 +442,20 @@ config MFD_MAX77693
   additional drivers must be enabled in order to use the 
 functionality
   of the device.

 +config MFD_MAX77843
 +   bool Maxim Semiconductor MAX77843 PMIC Support
 +   depends on I2C=y
 +   select MFD_CORE
 +   select REGMAP_I2C
 +   select REGMAP_IRQ
 +   help
 + Say yes here to add support for Maxim Semiconductor MAX77843.
 + This is companion Power Management IC with LEDs, Haptic, Charger,
 + Fuel Gauge, MUIC(Micro USB Interface Controller) controls on chip.
 + This driver provides common support for accessing the device;
 + additional drivers must be enabled in order to use the 
 functionality
 + of the device.
 +
  config MFD_MAX8907
 tristate Maxim Semiconductor MAX8907 PMIC Support
 select MFD_CORE
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 53467e2..fe4f75c 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -117,6 +117,7 @@ obj-$(CONFIG_MFD_DA9063)+= da9063.o
  obj-$(CONFIG_MFD_MAX14577) += max14577.o
  obj-$(CONFIG_MFD_MAX77686) += max77686.o
  obj-$(CONFIG_MFD_MAX77693) += max77693.o
 +obj-$(CONFIG_MFD_MAX77843) += max77843.o
  obj-$(CONFIG_MFD_MAX8907)  += max8907.o
  max8925-objs   := max8925-core.o max8925-i2c.o
  obj-$(CONFIG_MFD_MAX8925)  += max8925.o
 diff --git a/drivers/mfd/max77843.c b/drivers/mfd/max77843.c
 new file mode 100644
 index 000..d7f8b76
 --- /dev/null
 +++ b/drivers/mfd/max77843.c
 @@ -0,0 +1,241 @@
 +/*
 + * max77843.c - MFD core driver for the Maxim MAX77843
 + *
 + * Copyright (C) 2014 Samsung Electrnoics
 + * Author: Jaewon Kim jaewon02@samsung.com
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; either version 2 of the License, or
 + * (at your option) any later version.
 + */
 +
 +#include linux/err.h
 +#include linux/i2c.h
 +#include linux/init.h
 +#include linux/interrupt.h
 +#include linux/module.h
 +#include linux/mfd/core.h
 +#include linux/mfd/max77843-private.h
 +#include linux/of_device.h
 +#include linux/platform_device.h
 +
 +static const struct mfd_cell max77843_devs[] = {
 +   {
 +   .name = max77843-muic,
 +   .of_compatible = maxim,max77843-muic,
 +   }, {
 +   .name = max77843-regulator,
 +   .of_compatible = maxim,max77843-regulator,
 +   }, {
 +   .name = max77843-charger,
 +   .of_compatible = maxim,max77843-charger
 +   }, {
 +   .name = max77843-fuelgauge,
 +   .of_compatible = maxim,max77843-fuelgauge,
 +   },
 +};
 +
 +static const struct regmap_config max77843_charger_regmap_config = {
 +   .reg_bits   = 8,
 +   .val_bits   = 8,
 +   .max_register   = MAX77843_CHG_REG_END,
 +};
 +
 +static const struct regmap_config max77843_regmap_config = {
 +   .reg_bits   = 8,
 +   .val_bits   = 8,
 +   .max_register   = MAX77843_SYS_REG_END,
 +};
 +
 +static const struct regmap_irq max77843_irqs[] = {
 +   /* TOPSYS interrupts */
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_SYSUVLO_INT, },
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_SYSOVLO_INT, },
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_TSHDN_INT, },
 +   { .reg_offset = 0, .mask = MAX77843_SYS_IRQ_TM_INT, },
 +};
 +
 +static const struct regmap_irq_chip max77843_irq_chip = {
 +   .name   = max77843,
 +   .status_base= MAX77843_SYS_REG_SYSINTSRC,
 +   .mask_base  = MAX77843_SYS_REG_SYSINTMASK,
 +   .mask_invert= false,
 +   .num_regs   = 1,
 +   .irqs   = max77843_irqs,
 +   .num_irqs   = ARRAY_SIZE(max77843_irqs),
 +};
 +
 +static int max77843_chg_init(struct max77843 *max77843)
 +{
 
 Could this function be moved to the charger driver? This way the
 driver will manage

[PATCH v3 2/2] Documentation: Add documentation for rt5033 multifunction device

2015-01-21 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Sebastian Reichel s...@kernel.org
Cc: Lee Jones lee.jo...@linaro.org
Cc: Mark Brown broo...@kernel.org
Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
Acked-by: Lee Jones lee.jo...@linaro.org
---
Changes in v3
- Add Acked-by
Changes in v2
- Fix incorrect typo.
- Align -uamp and -uvolt names with regulator binding suffixes.
- Drop incorrect phandle.
- Fix incorrect example.
---
 Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 102 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..64b23e8
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,101 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators using the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,fast-uamp = 200;
+   richtek,eoc-uamp = 25;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,const-uvolt = 435;
+
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   rt5033@35 {
+   compatible = richtek,rt5033-battery;
+   interrupt-parent = gpx2;
+   interrupts = 3 0;
+   reg = 0x35;
+   };
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,fast-uamp = 200;
+   richtek,eoc-uamp = 25;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,const-uvolt = 435;
+   };
+
+   };
+
+   rt5033@35 {
+   compatible = richtek,rt5033-battery

[PATCH v3 0/2] power: rt5033: Add Richtek RT533 drivers

2015-01-21 Thread Beomho Seo
This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge.
Additionally, This includes document for device tree of RT5033 device.

RT5033 core driver is applied by Lee Jones.
RT5033 regulator driver is applied by Mark Brown.
RT5033 fuelgauge driver is applied by Sebastian Reichel.

Changes in v3:
- Applied one of patchset.
- Add acked-by.

Changes in v2:
- Revise binding documentation..

Beomho Seo (2):
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 5 files changed, 596 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/power/rt5033_charger.c

-- 
1.7.9.5

--
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 v3 1/2] power: rt5033_charger: Add RT5033 charger device driver

2015-01-21 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v3
Changes in v2
- none
---
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..9dcaef4
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT)
+   state = RT5033_CHG_MAX_CURRENT;
+
+   data = state * 100 + 700;
+
+   return data;
+}
+
+static int rt5033_get_charge_voltage(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap

Re: [PATCH v3 1/2] power: rt5033_charger: Add RT5033 charger device driver

2015-01-21 Thread Beomho Seo
Thank you for review.

On 01/22/2015 12:12 PM, Sebastian Reichel wrote:
 Hi,
 
 On Thu, Jan 22, 2015 at 09:38:11AM +0900, Beomho Seo wrote:
 This patch add device driver of Richtek RT5033 PMIC. The driver
 support switching charger. rt5033 charger provide three charging
 mode.  Three charging mode are pre charge mode, fast cahrge mode
 and constant voltage mode. They are have vary charge rate, charge
 parameters. The charge parameters can be controlled by i2c
 interface.

 [...]

 +charger-psy.name = rt5033-charger,
 +charger-psy.type = POWER_SUPPLY_TYPE_BATTERY,

 [...]
 
 POWER_SUPPLY_TYPE_MAINS?
 
 -- Sebastian
 

OK I will change power supply type.

Thanks,
Beomho Seo

--
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 v4 2/2] Documentation: Add documentation for rt5033 multifunction device

2015-01-21 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Sebastian Reichel s...@kernel.org
Cc: Lee Jones lee.jo...@linaro.org
Cc: Mark Brown broo...@kernel.org
Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
Acked-by: Lee Jones lee.jo...@linaro.org
---
Changes in v4
- none.
Changes in v3
- Add Acked-by
Changes in v2
- Fix incorrect typo.
- Align -uamp and -uvolt names with regulator binding suffixes.
- Drop incorrect phandle.
- Fix incorrect example.
---

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 102 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..64b23e8
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,101 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators using the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,fast-uamp = 200;
+   richtek,eoc-uamp = 25;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,const-uvolt = 435;
+
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   rt5033@35 {
+   compatible = richtek,rt5033-battery;
+   interrupt-parent = gpx2;
+   interrupts = 3 0;
+   reg = 0x35;
+   };
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,fast-uamp = 200;
+   richtek,eoc-uamp = 25;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,const-uvolt = 435;
+   };
+
+   };
+
+   rt5033@35 {
+   compatible

[PATCH v4 1/2] power: rt5033_charger: Add RT5033 charger device driver

2015-01-21 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v4
- Change power supply type to POWER_SUPPLY_TYPE_MAINS.
Changes in v3
Changes in v2
- none
---

 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..7f8f6c3
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT)
+   state = RT5033_CHG_MAX_CURRENT;
+
+   data = state * 100 + 700;
+
+   return data;
+}
+
+static int rt5033_get_charge_voltage(struct rt5033_charger *charger

[PATCH v4 0/2] power: rt5033: Add Richtek RT533 drivers

2015-01-21 Thread Beomho Seo
This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge.
Additionally, This includes document for device tree of RT5033 device.

RT5033 core driver is applied by Lee Jones.
RT5033 regulator driver is applied by Mark Brown.
RT5033 fuelgauge driver is applied by Sebastian Reichel.

Changes in v4:
- Change power supply type.

Changes in v3:
- Applied one of patchset.
- Add acked-by.

Changes in v2:
- Revise binding documentation..

Beomho Seo (2):
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 5 files changed, 596 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/power/rt5033_charger.c

-- 
1.7.9.5

--
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 v2 0/3] power: rt5033: Add Richtek RT533 drivers

2015-01-12 Thread Beomho Seo
Thank you reply.

On 01/12/2015 07:40 PM, Paul Bolle wrote:
 Beomho,
 
 On Fri, 2015-01-09 at 17:45 +0900, Beomho Seo wrote:
 This patchset adds driver for Richtek rt5033 chip The chip contains
 switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge.
 Additionally, This includes document for device tree of RT5033 device.

 RT5033 core driver is applied by Lee Jones.
 RT5033 regulator driver have been merged by Mark Brown. commit is below,

 commit b1917578fd5d8efa67afa05a0d6d7e323f2802da

 Changes in v2:
 - Revise binding documentation..
  
 Beomho Seo (3):
   power: rt5033_battery: Add RT5033 Fuel gauge device driver
   power: rt5033_charger: Add RT5033 charger device driver
   Documentation: Add documentation for rt5033 multifunction device

  Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
  .../devicetree/bindings/vendor-prefixes.txt|1 +
  drivers/power/Kconfig  |   16 +
  drivers/power/Makefile |2 +
  drivers/power/rt5033_battery.c |  177 +++
  drivers/power/rt5033_charger.c |  485 
 
  6 files changed, 782 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
  create mode 100644 drivers/power/rt5033_battery.c
  create mode 100644 drivers/power/rt5033_charger.c
 
 This series adds two drivers that depend on MFD_RT5033. But there's
 currently no Kconfig symbol MFD_RT5033.
 
 The regulator driver mentioned above is another driver that depends on
 MFD_RT5033. It was included first in next-20141117. It is also included
 in mainline since v3.19-rc1. That regulator driver has never been
 buildable, even if one bypasses its dependency on MFD_RT5033. That is
 because it includes two headers that are not yet part of the tree
 (linux/mfd/rt5033.h and linux/mfd/rt5033-private.h).
 
 When is the Kconfig symbol MFD_RT5033 expected to be included in the
 tree?
 
 
 Paul Bolle
 
 

MFD_RT5033 have been applied in 09 Dec 2014.
http://marc.info/?l=linux-pmm=141822463218774w=2
According to the mail, That is expected to include next version.

Best regards,
Beomho Seo
--
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 v2 1/3] power: rt5033_battery: Add RT5033 Fuel gauge device driver

2015-01-09 Thread Beomho Seo
This patch adds device driver of Richtek PMIC.
The driver support battery fuel gange. Fuel gauge calculates and determines the
battery state of charge(SOC) according to battery open circuit voltage(OCV).
Also, this driver provides battery average voltage, voltage and bettery present
property.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v2
- none.
---
 drivers/power/Kconfig  |8 ++
 drivers/power/Makefile |1 +
 drivers/power/rt5033_battery.c |  177 
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/power/rt5033_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 0108c2a..da6981f 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -397,6 +397,14 @@ config BATTERY_GOLDFISH
  Say Y to enable support for the battery and AC power in the
  Goldfish emulator.
 
+config BATTERY_RT5033
+   tristate RT5033 fuel gauge support
+   depends on MFD_RT5033
+   help
+ This adds support for battery fuel gauge in Richtek RT5033 PMIC.
+ The fuelgauge calculates and determines the battery state of charge
+ according to battery open circuit voltage.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index dfa8942..b83a0c7 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9052)  += da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042) += max17042_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
 obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c
new file mode 100644
index 000..7b898f4
--- /dev/null
+++ b/drivers/power/rt5033_battery.c
@@ -0,0 +1,177 @@
+/*
+ * Fuel gauge driver for Richtek RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_battery_get_capacity(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 msb;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_SOC_H, msb);
+
+   return msb;
+}
+
+static int rt5033_battery_get_present(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 val;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_CONFIG_L, val);
+
+   return (val  RT5033_FUEL_BAT_PRESENT) ? true : false;
+}
+
+static int rt5033_battery_get_watt_prop(struct i2c_client *client,
+   enum power_supply_property psp)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   unsigned int regh, regl;
+   int ret;
+   u32 msb, lsb;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   regh = RT5033_FUEL_REG_VBAT_H;
+   regl = RT5033_FUEL_REG_VBAT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   regh = RT5033_FUEL_REG_AVG_VOLT_H;
+   regl = RT5033_FUEL_REG_AVG_VOLT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   regh = RT5033_FUEL_REG_OCV_H;
+   regl = RT5033_FUEL_REG_OCV_L;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   regmap_read(battery-regmap, regh, msb);
+   regmap_read(battery-regmap, regl, lsb);
+
+   ret = ((msb  4) + (lsb  4)) * 1250 / 1000;
+
+   return ret;
+}
+
+static int rt5033_battery_get_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   union power_supply_propval *val)
+{
+   struct rt5033_battery *battery = container_of(psy,
+   struct rt5033_battery, psy);
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   val-intval = rt5033_battery_get_watt_prop(battery-client,
+   psp);
+   break;
+   case POWER_SUPPLY_PROP_PRESENT:
+   val

[PATCH v2 3/3] Documentation: Add documentation for rt5033 multifunction device

2015-01-09 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Sebastian Reichel s...@kernel.org
Cc: Lee Jones lee.jo...@linaro.org
Cc: Mark Brown broo...@kernel.org
Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v2
- Fix incorrect typo.
- Align -uamp and -uvolt names with regulator binding suffixes.
- Drop incorrect phandle.
- Fix incorrect example.
---
 Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 102 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..64b23e8
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,101 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators using the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,fast-uamp = 200;
+   richtek,eoc-uamp = 25;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,const-uvolt = 435;
+
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   rt5033@35 {
+   compatible = richtek,rt5033-battery;
+   interrupt-parent = gpx2;
+   interrupts = 3 0;
+   reg = 0x35;
+   };
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,fast-uamp = 200;
+   richtek,eoc-uamp = 25;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,const-uvolt = 435;
+   };
+
+   };
+
+   rt5033@35 {
+   compatible = richtek,rt5033-battery;
+   interrupt-parent = gpx2

[PATCH v2 0/3] power: rt5033: Add Richtek RT533 drivers

2015-01-09 Thread Beomho Seo
This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge.
Additionally, This includes document for device tree of RT5033 device.

RT5033 core driver is applied by Lee Jones.
RT5033 regulator driver have been merged by Mark Brown. commit is below,

commit b1917578fd5d8efa67afa05a0d6d7e323f2802da

Changes in v2:
- Revise binding documentation..
 
Beomho Seo (3):
  power: rt5033_battery: Add RT5033 Fuel gauge device driver
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  101 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/power/Kconfig  |   16 +
 drivers/power/Makefile |2 +
 drivers/power/rt5033_battery.c |  177 +++
 drivers/power/rt5033_charger.c |  485 
 6 files changed, 782 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/power/rt5033_battery.c
 create mode 100644 drivers/power/rt5033_charger.c

-- 
1.7.9.5

--
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 v2 2/3] power: rt5033_charger: Add RT5033 charger device driver

2015-01-09 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v2
- none
---
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..9dcaef4
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT)
+   state = RT5033_CHG_MAX_CURRENT;
+
+   data = state * 100 + 700;
+
+   return data;
+}
+
+static int rt5033_get_charge_voltage(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap

Re: [PATCH RESEND 3/3] Documentation: Add documentation for rt5033 multifunction device

2015-01-06 Thread Beomho Seo
Thank you for review.

On 01/07/2015 01:54 AM, Rob Herring wrote:
 On Mon, Jan 5, 2015 at 11:45 PM, Beomho Seo beomho@samsung.com wrote:
 This patch device tree binding documentation for rt5033 multifunction device.

 Cc: Sebastian Reichel s...@kernel.org
 Cc: Lee Jones lee.jo...@linaro.org
 Cc: Mark Brown broo...@kernel.org
 Cc: Rob Herring robh...@kernel.org
 Cc: Pawel Moll pawel.m...@arm.com
 Cc: Mark Rutland mark.rutl...@arm.com
 Cc: Ian campbell ijc+devicet...@hellion.org.uk
 Cc: Kumar Gala ga...@codeaurora.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
  Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 
 
  .../devicetree/bindings/vendor-prefixes.txt|1 +
  2 files changed, 109 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

 diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
 b/Documentation/devicetree/bindings/mfd/rt5033.txt
 new file mode 100644
 index 000..52a6d33
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
 @@ -0,0 +1,108 @@
 +Richtek RT5033 Power management Integrated Circuit
 +
 +RT5033 is a Multifunction device which includes battery charger, fuel gauge,
 +flash LED current source, LDO and synchronous Buck converter for portable
 +applications. It is interfaced to host controller using i2c interface.
 +
 +Required properties:
 +- compatible : Must be richtek,rt5033
 +- reg : Specifies the i2c slave address of general part.
 +- interrupts : This i2c devices has an IRQ line connected to the main SoC.
 +- interrupt-parent : The parent interrupt controller.
 +
 +Optional node:
 +Regulators: The regulators of RT5033 have to be instantiated under sub-node
 +named regulators usinge the following format.
 
 s/usinge/using/
 

I will fix wrong typo.

 +
 +   regulators {
 +   regulator-name {
 +   regulator-name = LDO/BUCK
 +   regulator subnodes called X, Y and Z
 +   };
 +   };
 +   refer Documentation/devicetree/bindings/regulator/regulator.txt
 +
 +
 +Battery charger: There battery charger of RT5033 have to be instantiated 
 under
 +sub-node named charger using the following format.
 +
 +Required properties:
 +- compatible : Must be richtek,rt5033-charger.
 +- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current 
 levels
 +  are 350 mA to 650 mA programmed by I2C per 100 mA.
 +- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. 
 Battery
 +  voltage is below pre-charge threshold voltage, the charger is in 
 pre-charge
 +  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
 +  by I2C per 0.1 V.
 +- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
 +  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
 +- richtek,const-uvolt :  Battery regulation voltage of constant voltage 
 mode.
 +  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
 +- richtek,eoc-uamp : This property is end of charge current. Its level 150 
 mA
 +  to 200 mA.
 
 Please align -uamp and -uvolt names with regulator binding suffixes.
 

OK. I will fix it.

 +   charger {
 +   compatible = richtek,rt5033-charger;
 +   richtek,pre-uamp = 35;
 +   richtek,pre-threshold-uvolt = 340;
 +   richtek,fast-uamp = 200;
 +   richtek,const-uvolt = 435;
 +   richtek,eoc-uamp = 25;
 +   };
 +
 +
 +Fuelgauge: There fuelgauge of RT5033 to be instantiated node named 
 fuelgauge
 +using the following format.
 +
 +Required properties:
 +- compatible = Must be richtek,rt5033-battery.
 +
 +   i2c_fuel: i2c@1 {
 
 Drop the @1.
 

OK. I will fix it.

 +   compatible = i2c-gpio;
 +   standard i2c-gpio constraints...
 +   fuelgauge {
 +   compatible = richtek,rt5033-battery.
 +   };
 +   };
 
 I'm a bit confused by this. The fuelgauge is an i2c device hanging off
 the rt5033 or a 2nd i2c slave on the rt5033?


It is 2nd i2c slave on the rt5033.

 +
 +
 +Example:
 +
 +   rt5033@34 {
 +   compatible = richtek,rt5033;
 +   reg = 0x34;
 +   interrupt-parent = gpx1;
 +   interrupts = 5 0;
 +
 +   regulators {
 +   buck_reg: BUCK {
 +   regulator-name = BUCK;
 +   regulator-min-microvolt = 120;
 +   regulator-max-microvolt = 120;
 +   regulator-always-on;
 +   };
 +   };
 +
 +   charger {
 +   compatible = richtek,rt5033-charger

[PATCH RESEND 2/3] power: rt5033_charger: Add RT5033 charger device driver

2015-01-05 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..9dcaef4
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT)
+   state = RT5033_CHG_MAX_CURRENT;
+
+   data = state * 100 + 700;
+
+   return data;
+}
+
+static int rt5033_get_charge_voltage(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap

[PATCH RESEND 0/3] power: rt5033: Add Richtek RT533 drivers

2015-01-05 Thread Beomho Seo
This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge.
Additionally, This includes document for device tree of RT5033 device.

RT5033 core driver is applied by Lee Jones.
RT5033 regulator driver have been merged by Mark Brown. commit is below,

commit b1917578fd5d8efa67afa05a0d6d7e323f2802da

Beomho Seo (3):
  power: rt5033_battery: Add RT5033 Fuel gauge device driver
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/power/Kconfig  |   16 +
 drivers/power/Makefile |2 +
 drivers/power/rt5033_battery.c |  177 +++
 drivers/power/rt5033_charger.c |  485 
 6 files changed, 789 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/power/rt5033_battery.c
 create mode 100644 drivers/power/rt5033_charger.c

-- 
1.7.9.5

--
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 RESEND 1/3] power: rt5033_battery: Add RT5033 Fuel gauge device driver

2015-01-05 Thread Beomho Seo
This patch adds device driver of Richtek PMIC.
The driver support battery fuel gange. Fuel gauge calculates and determines the
battery state of charge(SOC) according to battery open circuit voltage(OCV).
Also, this driver provides battery average voltage, voltage and bettery present
property.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
 drivers/power/Kconfig  |8 ++
 drivers/power/Makefile |1 +
 drivers/power/rt5033_battery.c |  177 
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/power/rt5033_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 0108c2a..da6981f 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -397,6 +397,14 @@ config BATTERY_GOLDFISH
  Say Y to enable support for the battery and AC power in the
  Goldfish emulator.
 
+config BATTERY_RT5033
+   tristate RT5033 fuel gauge support
+   depends on MFD_RT5033
+   help
+ This adds support for battery fuel gauge in Richtek RT5033 PMIC.
+ The fuelgauge calculates and determines the battery state of charge
+ according to battery open circuit voltage.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index dfa8942..b83a0c7 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9052)  += da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042) += max17042_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
 obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c
new file mode 100644
index 000..7b898f4
--- /dev/null
+++ b/drivers/power/rt5033_battery.c
@@ -0,0 +1,177 @@
+/*
+ * Fuel gauge driver for Richtek RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_battery_get_capacity(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 msb;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_SOC_H, msb);
+
+   return msb;
+}
+
+static int rt5033_battery_get_present(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 val;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_CONFIG_L, val);
+
+   return (val  RT5033_FUEL_BAT_PRESENT) ? true : false;
+}
+
+static int rt5033_battery_get_watt_prop(struct i2c_client *client,
+   enum power_supply_property psp)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   unsigned int regh, regl;
+   int ret;
+   u32 msb, lsb;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   regh = RT5033_FUEL_REG_VBAT_H;
+   regl = RT5033_FUEL_REG_VBAT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   regh = RT5033_FUEL_REG_AVG_VOLT_H;
+   regl = RT5033_FUEL_REG_AVG_VOLT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   regh = RT5033_FUEL_REG_OCV_H;
+   regl = RT5033_FUEL_REG_OCV_L;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   regmap_read(battery-regmap, regh, msb);
+   regmap_read(battery-regmap, regl, lsb);
+
+   ret = ((msb  4) + (lsb  4)) * 1250 / 1000;
+
+   return ret;
+}
+
+static int rt5033_battery_get_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   union power_supply_propval *val)
+{
+   struct rt5033_battery *battery = container_of(psy,
+   struct rt5033_battery, psy);
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   val-intval = rt5033_battery_get_watt_prop(battery-client,
+   psp);
+   break;
+   case POWER_SUPPLY_PROP_PRESENT:
+   val-intval

[PATCH RESEND 3/3] Documentation: Add documentation for rt5033 multifunction device

2015-01-05 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Sebastian Reichel s...@kernel.org
Cc: Lee Jones lee.jo...@linaro.org
Cc: Mark Brown broo...@kernel.org
Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..52a6d33
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,108 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators usinge the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   i2c_fuel: i2c@1 {
+   compatible = i2c-gpio;
+   standard i2c-gpio constraints...
+   fuelgauge {
+   compatible = richtek,rt5033-battery.
+   };
+   };
+
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+   };
+
+   i2c_fuel: i2c@10 {
+   compatible = i2c-gpio;
+   gpios = gpm3 1 0
+   gpm3 0 0;
+
+   fuel: rt5033-battery@35 {
+   compatible = richtek

[PATCH RESEND 2/2] ARM: dts: exynos3250: replace number by macro in gpio keys

2015-01-05 Thread Beomho Seo
This patch replace number by macro in gpio keys for exynos 3250 boards.

Cc: Kukjin Kim kg...@kernel.org
Cc: Youngjun Cho yj44@samsung.com
Cc: Chanwoo Choi cw00.c...@samsung.com
Reviewed-by: Chanwoo Choi cw00.c...@samsung.com
Signed-off-by: Beomho Seo beomho@samsung.com
---
 arch/arm/boot/dts/exynos3250-monk.dts   |3 ++-
 arch/arm/boot/dts/exynos3250-rinato.dts |3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/exynos3250-monk.dts 
b/arch/arm/boot/dts/exynos3250-monk.dts
index 2129ab98..792a2c7 100644
--- a/arch/arm/boot/dts/exynos3250-monk.dts
+++ b/arch/arm/boot/dts/exynos3250-monk.dts
@@ -15,6 +15,7 @@
 /dts-v1/;
 #include exynos3250.dtsi
 #include dt-bindings/input/input.h
+#include dt-bindings/gpio/gpio.h
 
 / {
model = Samsung Monk board;
@@ -37,7 +38,7 @@
compatible = gpio-keys;
 
power_key {
-   gpios = gpx2 7 1;
+   gpios = gpx2 7 GPIO_ACTIVE_LOW;
linux,code = KEY_POWER;
label = power key;
debounce-interval = 10;
diff --git a/arch/arm/boot/dts/exynos3250-rinato.dts 
b/arch/arm/boot/dts/exynos3250-rinato.dts
index c186ac6..3493bca 100644
--- a/arch/arm/boot/dts/exynos3250-rinato.dts
+++ b/arch/arm/boot/dts/exynos3250-rinato.dts
@@ -15,6 +15,7 @@
 /dts-v1/;
 #include exynos3250.dtsi
 #include dt-bindings/input/input.h
+#include dt-bindings/gpio/gpio.h
 
 / {
model = Samsung Rinato board;
@@ -37,7 +38,7 @@
compatible = gpio-keys;
 
power_key {
-   gpios = gpx2 7 1;
+   gpios = gpx2 7 GPIO_ACTIVE_LOW;
linux,code = KEY_POWER;
label = power key;
debounce-interval = 10;
-- 
1.7.9.5

--
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 RESEND 1/2] ARM: dts: exynos3250: remove unecessary property of gpio-keys node

2015-01-05 Thread Beomho Seo
This patch remove unecessary property of gpio-keys node.
gpio-keys driver do not uses interrupts and interrupt-parent.

Cc: Kukjin Kim kg...@kernel.org
Cc: Youngjun Cho yj44@samsung.com
Cc: Chanwoo Choi cw00.c...@samsung.com
Reviewed-by: Chanwoo Choi cw00.c...@samsung.com
Signed-off-by: Beomho Seo beomho@samsung.com
---
 arch/arm/boot/dts/exynos3250-monk.dts   |2 --
 arch/arm/boot/dts/exynos3250-rinato.dts |2 --
 2 files changed, 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos3250-monk.dts 
b/arch/arm/boot/dts/exynos3250-monk.dts
index 24822aa..2129ab98 100644
--- a/arch/arm/boot/dts/exynos3250-monk.dts
+++ b/arch/arm/boot/dts/exynos3250-monk.dts
@@ -37,8 +37,6 @@
compatible = gpio-keys;
 
power_key {
-   interrupt-parent = gpx2;
-   interrupts = 7 0;
gpios = gpx2 7 1;
linux,code = KEY_POWER;
label = power key;
diff --git a/arch/arm/boot/dts/exynos3250-rinato.dts 
b/arch/arm/boot/dts/exynos3250-rinato.dts
index 80aa8b4..c186ac6 100644
--- a/arch/arm/boot/dts/exynos3250-rinato.dts
+++ b/arch/arm/boot/dts/exynos3250-rinato.dts
@@ -37,8 +37,6 @@
compatible = gpio-keys;
 
power_key {
-   interrupt-parent = gpx2;
-   interrupts = 7 0;
gpios = gpx2 7 1;
linux,code = KEY_POWER;
label = power key;
-- 
1.7.9.5

--
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 RESEND 0/2] ARM: dts: exynos3250: revise property for gpio-keys node

2015-01-05 Thread Beomho Seo
This patch revises property of gpio-keys node.
The first patch remove unecessary property.
And then, replace by macro in gpio keys.

Beomho Seo (2):
  ARM: dts: exynos3250: remove unecessary property of gpio-keys node
  ARM: dts: exynos3250: replace number by macro in gpio keys

 arch/arm/boot/dts/exynos3250-monk.dts   |5 ++---
 arch/arm/boot/dts/exynos3250-rinato.dts |5 ++---
 2 files changed, 4 insertions(+), 6 deletions(-)

-- 
1.7.9.5

--
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 1/2] ARM: dts: exynos3250: remove unecessary property of gpio-keys node

2014-12-19 Thread Beomho Seo
This patch remove unecessary property of gpio-keys node.
gpio-keys driver do not uses interrupts and interrupt-parent.

Cc: Youngjun Cho yj44@samsung.com
Cc: Chanwoo Choi cw00.c...@samsung.com
Signed-off-by: Beomho Seo beomho@samsung.com
---
 arch/arm/boot/dts/exynos3250-monk.dts   |2 --
 arch/arm/boot/dts/exynos3250-rinato.dts |2 --
 2 files changed, 4 deletions(-)

diff --git a/arch/arm/boot/dts/exynos3250-monk.dts 
b/arch/arm/boot/dts/exynos3250-monk.dts
index 24822aa..2129ab98 100644
--- a/arch/arm/boot/dts/exynos3250-monk.dts
+++ b/arch/arm/boot/dts/exynos3250-monk.dts
@@ -37,8 +37,6 @@
compatible = gpio-keys;
 
power_key {
-   interrupt-parent = gpx2;
-   interrupts = 7 0;
gpios = gpx2 7 1;
linux,code = KEY_POWER;
label = power key;
diff --git a/arch/arm/boot/dts/exynos3250-rinato.dts 
b/arch/arm/boot/dts/exynos3250-rinato.dts
index 80aa8b4..c186ac6 100644
--- a/arch/arm/boot/dts/exynos3250-rinato.dts
+++ b/arch/arm/boot/dts/exynos3250-rinato.dts
@@ -37,8 +37,6 @@
compatible = gpio-keys;
 
power_key {
-   interrupt-parent = gpx2;
-   interrupts = 7 0;
gpios = gpx2 7 1;
linux,code = KEY_POWER;
label = power key;
-- 
1.7.9.5

--
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 2/2] ARM: dts: exynos3250: replace number by macro in gpio keys

2014-12-19 Thread Beomho Seo
This patch replace number by macro in gpio keys for exynos 3250 boards.

Cc: Youngjun Cho yj44@samsung.com
Cc: Chanwoo Choi cw00.c...@samsung.com
Signed-off-by: Beomho Seo beomho@samsung.com
---
 arch/arm/boot/dts/exynos3250-monk.dts   |3 ++-
 arch/arm/boot/dts/exynos3250-rinato.dts |3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/exynos3250-monk.dts 
b/arch/arm/boot/dts/exynos3250-monk.dts
index 2129ab98..792a2c7 100644
--- a/arch/arm/boot/dts/exynos3250-monk.dts
+++ b/arch/arm/boot/dts/exynos3250-monk.dts
@@ -15,6 +15,7 @@
 /dts-v1/;
 #include exynos3250.dtsi
 #include dt-bindings/input/input.h
+#include dt-bindings/gpio/gpio.h
 
 / {
model = Samsung Monk board;
@@ -37,7 +38,7 @@
compatible = gpio-keys;
 
power_key {
-   gpios = gpx2 7 1;
+   gpios = gpx2 7 GPIO_ACTIVE_LOW;
linux,code = KEY_POWER;
label = power key;
debounce-interval = 10;
diff --git a/arch/arm/boot/dts/exynos3250-rinato.dts 
b/arch/arm/boot/dts/exynos3250-rinato.dts
index c186ac6..3493bca 100644
--- a/arch/arm/boot/dts/exynos3250-rinato.dts
+++ b/arch/arm/boot/dts/exynos3250-rinato.dts
@@ -15,6 +15,7 @@
 /dts-v1/;
 #include exynos3250.dtsi
 #include dt-bindings/input/input.h
+#include dt-bindings/gpio/gpio.h
 
 / {
model = Samsung Rinato board;
@@ -37,7 +38,7 @@
compatible = gpio-keys;
 
power_key {
-   gpios = gpx2 7 1;
+   gpios = gpx2 7 GPIO_ACTIVE_LOW;
linux,code = KEY_POWER;
label = power key;
debounce-interval = 10;
-- 
1.7.9.5

--
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 1/3] power: rt5033_battery: Add RT5033 Fuel gauge device driver

2014-12-18 Thread Beomho Seo
This patch adds device driver of Richtek PMIC.
The driver support battery fuel gange. Fuel gauge calculates and determines the
battery state of charge(SOC) according to battery open circuit voltage(OCV).
Also, this driver provides battery average voltage, voltage and bettery present
property.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
 drivers/power/Kconfig  |8 ++
 drivers/power/Makefile |1 +
 drivers/power/rt5033_battery.c |  177 
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/power/rt5033_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 0108c2a..da6981f 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -397,6 +397,14 @@ config BATTERY_GOLDFISH
  Say Y to enable support for the battery and AC power in the
  Goldfish emulator.
 
+config BATTERY_RT5033
+   tristate RT5033 fuel gauge support
+   depends on MFD_RT5033
+   help
+ This adds support for battery fuel gauge in Richtek RT5033 PMIC.
+ The fuelgauge calculates and determines the battery state of charge
+ according to battery open circuit voltage.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index dfa8942..b83a0c7 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9052)  += da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042) += max17042_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
 obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c
new file mode 100644
index 000..7b898f4
--- /dev/null
+++ b/drivers/power/rt5033_battery.c
@@ -0,0 +1,177 @@
+/*
+ * Fuel gauge driver for Richtek RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_battery_get_capacity(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 msb;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_SOC_H, msb);
+
+   return msb;
+}
+
+static int rt5033_battery_get_present(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 val;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_CONFIG_L, val);
+
+   return (val  RT5033_FUEL_BAT_PRESENT) ? true : false;
+}
+
+static int rt5033_battery_get_watt_prop(struct i2c_client *client,
+   enum power_supply_property psp)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   unsigned int regh, regl;
+   int ret;
+   u32 msb, lsb;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   regh = RT5033_FUEL_REG_VBAT_H;
+   regl = RT5033_FUEL_REG_VBAT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   regh = RT5033_FUEL_REG_AVG_VOLT_H;
+   regl = RT5033_FUEL_REG_AVG_VOLT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   regh = RT5033_FUEL_REG_OCV_H;
+   regl = RT5033_FUEL_REG_OCV_L;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   regmap_read(battery-regmap, regh, msb);
+   regmap_read(battery-regmap, regl, lsb);
+
+   ret = ((msb  4) + (lsb  4)) * 1250 / 1000;
+
+   return ret;
+}
+
+static int rt5033_battery_get_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   union power_supply_propval *val)
+{
+   struct rt5033_battery *battery = container_of(psy,
+   struct rt5033_battery, psy);
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   val-intval = rt5033_battery_get_watt_prop(battery-client,
+   psp);
+   break;
+   case POWER_SUPPLY_PROP_PRESENT:
+   val-intval

[PATCH 3/3] Documentation: Add documentation for rt5033 multifunction device

2014-12-18 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..52a6d33
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,108 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators usinge the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   i2c_fuel: i2c@1 {
+   compatible = i2c-gpio;
+   standard i2c-gpio constraints...
+   fuelgauge {
+   compatible = richtek,rt5033-battery.
+   };
+   };
+
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+   };
+
+   i2c_fuel: i2c@10 {
+   compatible = i2c-gpio;
+   gpios = gpm3 1 0
+   gpm3 0 0;
+
+   fuel: rt5033-battery@35 {
+   compatible = richtek,rt5033-battery;
+   interrupt-parent = gpx2

[PATCH 0/3] power: rt5033: Add Richtek RT533 drivers

2014-12-18 Thread Beomho Seo
This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge.
Additionally, This includes document for device tree of RT5033 device.

RT5033 core driver is applied by Lee Jones.
RT5033 regulator driver have been merged by Mark Brown. commit is below,

commit b1917578fd5d8efa67afa05a0d6d7e323f2802da

Beomho Seo (3):
  power: rt5033_battery: Add RT5033 Fuel gauge device driver
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/power/Kconfig  |   16 +
 drivers/power/Makefile |2 +
 drivers/power/rt5033_battery.c |  177 +++
 drivers/power/rt5033_charger.c |  485 
 6 files changed, 789 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/power/rt5033_battery.c
 create mode 100644 drivers/power/rt5033_charger.c

-- 
1.7.9.5

--
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 2/3] power: rt5033_charger: Add RT5033 charger device driver

2014-12-18 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..9dcaef4
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT)
+   state = RT5033_CHG_MAX_CURRENT;
+
+   data = state * 100 + 700;
+
+   return data;
+}
+
+static int rt5033_get_charge_voltage(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap

Re: [PATCH v8 1/4] mfd: rt5033: Add Richtek RT5033 driver core.

2014-12-10 Thread Beomho Seo
On 12/09/2014 11:01 PM, Lee Jones wrote:
 On Tue, 09 Dec 2014, Beomho Seo wrote:
 
 This patch adds a new driver for Richtek RT5033 driver.
 RT5033 is a Multifunction device which includes battery charger, fuel gauge,
 flash LED current source, LDO and synchronous Buck converter. It is 
 interfaced
 to host controller using I2C interface.

 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Lee Jones lee.j...@linaro.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
 Changes in v8
 - Add description of hardware.
 - Move structure.

 Changes in v7
 - Use small description.
 - Change some names for a variable.
 - Revise of_device_id struct style.

 Changes in v6
 - Fix white space issue in mfd cell struct.

 Changes in v5
 - Change possible built as a module.
 - Revise rt5033_dev mfd cell entry.
 - Fix incorrect typo.
 - Add module alias.

 Changes in v4
 - none.

 Changes in v3
 - Correct sentence errors.
 - Add author information the top of each drivers.
 - Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
 - Change some return check.
 - Use bool and of_match_ptr().

 Changes in v2
 - Remove volatile_reg callback. Because this driver not in use regmap cache.
 - Revmoe unnecessary subnode of_compatible.
 - Add define for set_high impedance mode of charger.
 ---
  drivers/mfd/Kconfig|   12 ++
  drivers/mfd/Makefile   |1 +
  drivers/mfd/rt5033.c   |  142 
  include/linux/mfd/rt5033-private.h |  260 
 
  include/linux/mfd/rt5033.h |   62 +
  5 files changed, 477 insertions(+)
  create mode 100644 drivers/mfd/rt5033.c
  create mode 100644 include/linux/mfd/rt5033-private.h
  create mode 100644 include/linux/mfd/rt5033.h
 
 Much better.
 
 For my own reference:
 
 Acked-by: Lee Jones lee.jo...@linaro.org
 
 So what's the plan with this set?
 

This patch have been made on for-next-mfd branch of your git repository.
So I hope this patch to be merged at your git repository.
Another patch set(RT5033 regulator driver) have been merged on for-next branch 
of regulator git repository.

https://git.kernel.org/cgit/linux/kernel/git/broonie/regulator.git/commit/?h=for-nextid=b1917578fd5d8efa67afa05a0d6d7e323f2802da

Other patches(about charger, fuelgague and devicetree doc) will be re-sent to 
each maintainers.

Thank you for response.

 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index 2e6b731..9cd2af6 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -623,6 +623,18 @@ config MFD_RTSX_PCI
types of memory cards, such as Memory Stick, Memory Stick Pro,
Secure Digital and MultiMediaCard.
  
 +config MFD_RT5033
 +tristate Richtek RT5033 Power Management IC
 +depends on I2C=y
 +select MFD_CORE
 +select REGMAP_I2C
 +help
 +  This driver provides for the Richtek RT5033 Power Management IC,
 +  which includes the I2C driver and the Core APIs. This driver provides
 +  common support for accessing the device. The device supports multiple
 +  sub-devices like charger, fuel gauge, flash LED, current source,
 +  LDO and Buck.
 +
  config MFD_RTSX_USB
  tristate Realtek USB card reader
  depends on USB
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 53467e2..4059c24 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o
  obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o
  obj-$(CONFIG_MFD_HI6421_PMIC)   += hi6421-pmic-core.o
  obj-$(CONFIG_MFD_DLN2)  += dln2.o
 +obj-$(CONFIG_MFD_RT5033)+= rt5033.o
  
  intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o
  obj-$(CONFIG_INTEL_SOC_PMIC)+= intel-soc-pmic.o
 diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
 new file mode 100644
 index 000..db395a6
 --- /dev/null
 +++ b/drivers/mfd/rt5033.c
 @@ -0,0 +1,142 @@
 +/*
 + * MFD core driver for the Richtek RT5033.
 + *
 + * RT5033 comprises multiple sub-devices switcing charger, fuel gauge,
 + * flash LED, current source, LDO and BUCK regulators.
 + *
 + * Copyright (C) 2014 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/err.h
 +#include linux/module.h
 +#include linux/interrupt.h
 +#include linux/of_device.h
 +#include linux/mfd/core.h
 +#include linux/mfd/rt5033.h
 +#include linux/mfd/rt5033-private.h
 +
 +static const struct regmap_irq rt5033_irqs[] = {
 +{ .mask = RT5033_PMIC_IRQ_BUCKOCP, },
 +{ .mask = RT5033_PMIC_IRQ_BUCKLV, },
 +{ .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
 +{ .mask = RT5033_PMIC_IRQ_LDOLV, },
 +{ .mask = RT5033_PMIC_IRQ_OT

Re: [PATCH v8 1/4] mfd: rt5033: Add Richtek RT5033 driver core.

2014-12-10 Thread Beomho Seo
On 12/10/2014 09:13 PM, Lee Jones wrote:
 On Wed, 10 Dec 2014, Beomho Seo wrote:
 
 On 12/09/2014 11:01 PM, Lee Jones wrote:
 On Tue, 09 Dec 2014, Beomho Seo wrote:

 This patch adds a new driver for Richtek RT5033 driver.
 RT5033 is a Multifunction device which includes battery charger, fuel 
 gauge,
 flash LED current source, LDO and synchronous Buck converter. It is 
 interfaced
 to host controller using I2C interface.

 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Lee Jones lee.j...@linaro.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
  drivers/mfd/Kconfig|   12 ++
  drivers/mfd/Makefile   |1 +
  drivers/mfd/rt5033.c   |  142 
  include/linux/mfd/rt5033-private.h |  260 
 
  include/linux/mfd/rt5033.h |   62 +
  5 files changed, 477 insertions(+)
  create mode 100644 drivers/mfd/rt5033.c
  create mode 100644 include/linux/mfd/rt5033-private.h
  create mode 100644 include/linux/mfd/rt5033.h

 Much better.

 For my own reference:

 Acked-by: Lee Jones lee.jo...@linaro.org

 So what's the plan with this set?


 This patch have been made on for-next-mfd branch of your git repository.
 So I hope this patch to be merged at your git repository.
 Another patch set(RT5033 regulator driver) have been merged on for-next 
 branch of regulator git repository.

 https://git.kernel.org/cgit/linux/kernel/git/broonie/regulator.git/commit/?h=for-nextid=b1917578fd5d8efa67afa05a0d6d7e323f2802da

 Other patches(about charger, fuelgague and devicetree doc) will be re-sent 
 to each maintainers.
 
 Okay, so all patches are indipendant/othognal of each other for sure?
 

Yes, rt5033 core driver merge before other patches with no problem.
It is do not have dependency other patches.


Best regards,
Beomho Seo
--
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 v8 0/4] mfd: rt5033: Add Richtek RT5033 drivers

2014-12-09 Thread Beomho Seo
 This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge, regulators.
This patchset provides common support for accessing the device.
This patchset have been tested base on exynos board.

Changes in v8
- Add description of hardware.
- Move structure.

Changes in v7
- Use small description.
- Change some names for a variable.
- Revise of_device_id struct style.

Changes in v6
- Fix white space issue in mfd cell struct.

Changes in v5
- Change possible built as a module.
- Revise rt5033_dev mfd cell entry.
- Fix incorrect typo.
- Add module alias.

Changes in v4
- rt5033 regulator patch is applied by Mark Brown.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Remove unnecessary subnode of_compatible.
- Add definde for set high impedance mode of charger.
- Remove unnecessary device specific code.
- Fix wrong register name.
- Fix wrong error message.
- Fix return vallue at error case.
- Revise binding documentation.

Beomho Seo (4):
  mfd: rt5033: Add Richtek RT5033 driver core.
  power: rt5033_battery: Add RT5033 Fuel gauge device driver
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/mfd/Kconfig|   12 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  142 ++
 drivers/power/Kconfig  |   16 +
 drivers/power/Makefile |2 +
 drivers/power/rt5033_battery.c |  177 +++
 drivers/power/rt5033_charger.c |  485 
 include/linux/mfd/rt5033-private.h |  260 +++
 include/linux/mfd/rt5033.h |   62 +++
 11 files changed, 1266 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 drivers/power/rt5033_battery.c
 create mode 100644 drivers/power/rt5033_charger.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

-- 
1.7.9.5

--
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 v8 1/4] mfd: rt5033: Add Richtek RT5033 driver core.

2014-12-09 Thread Beomho Seo
This patch adds a new driver for Richtek RT5033 driver.
RT5033 is a Multifunction device which includes battery charger, fuel gauge,
flash LED current source, LDO and synchronous Buck converter. It is interfaced
to host controller using I2C interface.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.j...@linaro.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v8
- Add description of hardware.
- Move structure.

Changes in v7
- Use small description.
- Change some names for a variable.
- Revise of_device_id struct style.

Changes in v6
- Fix white space issue in mfd cell struct.

Changes in v5
- Change possible built as a module.
- Revise rt5033_dev mfd cell entry.
- Fix incorrect typo.
- Add module alias.

Changes in v4
- none.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Revmoe unnecessary subnode of_compatible.
- Add define for set_high impedance mode of charger.
---
 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  142 
 include/linux/mfd/rt5033-private.h |  260 
 include/linux/mfd/rt5033.h |   62 +
 5 files changed, 477 insertions(+)
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2e6b731..9cd2af6 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -623,6 +623,18 @@ config MFD_RTSX_PCI
  types of memory cards, such as Memory Stick, Memory Stick Pro,
  Secure Digital and MultiMediaCard.
 
+config MFD_RT5033
+   tristate Richtek RT5033 Power Management IC
+   depends on I2C=y
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ This driver provides for the Richtek RT5033 Power Management IC,
+ which includes the I2C driver and the Core APIs. This driver provides
+ common support for accessing the device. The device supports multiple
+ sub-devices like charger, fuel gauge, flash LED, current source,
+ LDO and Buck.
+
 config MFD_RTSX_USB
tristate Realtek USB card reader
depends on USB
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 53467e2..4059c24 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO)+= ipaq-micro.o
 obj-$(CONFIG_MFD_MENF21BMC)+= menf21bmc.o
 obj-$(CONFIG_MFD_HI6421_PMIC)  += hi6421-pmic-core.o
 obj-$(CONFIG_MFD_DLN2) += dln2.o
+obj-$(CONFIG_MFD_RT5033)   += rt5033.o
 
 intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
new file mode 100644
index 000..db395a6
--- /dev/null
+++ b/drivers/mfd/rt5033.c
@@ -0,0 +1,142 @@
+/*
+ * MFD core driver for the Richtek RT5033.
+ *
+ * RT5033 comprises multiple sub-devices switcing charger, fuel gauge,
+ * flash LED, current source, LDO and BUCK regulators.
+ *
+ * Copyright (C) 2014 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/err.h
+#include linux/module.h
+#include linux/interrupt.h
+#include linux/of_device.h
+#include linux/mfd/core.h
+#include linux/mfd/rt5033.h
+#include linux/mfd/rt5033-private.h
+
+static const struct regmap_irq rt5033_irqs[] = {
+   { .mask = RT5033_PMIC_IRQ_BUCKOCP, },
+   { .mask = RT5033_PMIC_IRQ_BUCKLV, },
+   { .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
+   { .mask = RT5033_PMIC_IRQ_LDOLV, },
+   { .mask = RT5033_PMIC_IRQ_OT, },
+   { .mask = RT5033_PMIC_IRQ_VDDA_UV, },
+};
+
+static const struct regmap_irq_chip rt5033_irq_chip = {
+   .name   = rt5033,
+   .status_base= RT5033_REG_PMIC_IRQ_STAT,
+   .mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
+   .mask_invert= true,
+   .num_regs   = 1,
+   .irqs   = rt5033_irqs,
+   .num_irqs   = ARRAY_SIZE(rt5033_irqs),
+};
+
+static const struct mfd_cell rt5033_devs[] = {
+   { .name = rt5033-regulator, },
+   {
+   .name = rt5033-charger,
+   .of_compatible = richtek,rt5033-charger,
+   }, {
+   .name = rt5033-battery,
+   .of_compatible = richtek,rt5033-battery,
+   },
+};
+
+static const struct regmap_config

[PATCH v8 3/4] power: rt5033_charger: Add RT5033 charger device driver

2014-12-09 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v8
- none.

Changes in v7
- Changes some variable name.

Changes in v6
Changes in v5
Changes in v4
- none.

Changes in v3
- Add author information the top of driver.

Changes in v2
- Fix wrong error message.
- Fix return value at error case. Because  charger-data null, probe function
return zero.
- Use define for set control register.
---
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..9dcaef4
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data

[PATCH v8 4/4] Documentation: Add documentation for rt5033 multifunction device

2014-12-09 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v8
Changes in v7
Changes in v6
Changes in v5
Changes in v4
Changes in v3
- none.

Changes in v2
- Revise binding documentation.
---

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..52a6d33
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,108 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators usinge the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   i2c_fuel: i2c@1 {
+   compatible = i2c-gpio;
+   standard i2c-gpio constraints...
+   fuelgauge {
+   compatible = richtek,rt5033-battery.
+   };
+   };
+
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+   };
+
+   i2c_fuel: i2c@10 {
+   compatible = i2c-gpio;
+   gpios = gpm3 1 0
+   gpm3 0 0;
+
+   fuel: rt5033-battery@35

[PATCH v8 2/4] power: rt5033_battery: Add RT5033 Fuel gauge device driver

2014-12-09 Thread Beomho Seo
This patch adds device driver of Richtek PMIC.
The driver support battery fuel gange. Fuel gauge calculates and determines the
battery state of charge(SOC) according to battery open circuit voltage(OCV).
Also, this driver provides battery average voltage, voltage and bettery present
property.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v8:
Changes in v7:
Changes in v6:
Changes in v5:
Changes in v4:
- none.

Changes in v3:
- Add author information the top of driver.

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Fix wrong register name.
---
 drivers/power/Kconfig  |8 ++
 drivers/power/Makefile |1 +
 drivers/power/rt5033_battery.c |  177 
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/power/rt5033_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 0108c2a..da6981f 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -397,6 +397,14 @@ config BATTERY_GOLDFISH
  Say Y to enable support for the battery and AC power in the
  Goldfish emulator.
 
+config BATTERY_RT5033
+   tristate RT5033 fuel gauge support
+   depends on MFD_RT5033
+   help
+ This adds support for battery fuel gauge in Richtek RT5033 PMIC.
+ The fuelgauge calculates and determines the battery state of charge
+ according to battery open circuit voltage.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index dfa8942..b83a0c7 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9052)  += da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042) += max17042_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
 obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c
new file mode 100644
index 000..7b898f4
--- /dev/null
+++ b/drivers/power/rt5033_battery.c
@@ -0,0 +1,177 @@
+/*
+ * Fuel gauge driver for Richtek RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_battery_get_capacity(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 msb;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_SOC_H, msb);
+
+   return msb;
+}
+
+static int rt5033_battery_get_present(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 val;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_CONFIG_L, val);
+
+   return (val  RT5033_FUEL_BAT_PRESENT) ? true : false;
+}
+
+static int rt5033_battery_get_watt_prop(struct i2c_client *client,
+   enum power_supply_property psp)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   unsigned int regh, regl;
+   int ret;
+   u32 msb, lsb;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   regh = RT5033_FUEL_REG_VBAT_H;
+   regl = RT5033_FUEL_REG_VBAT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   regh = RT5033_FUEL_REG_AVG_VOLT_H;
+   regl = RT5033_FUEL_REG_AVG_VOLT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   regh = RT5033_FUEL_REG_OCV_H;
+   regl = RT5033_FUEL_REG_OCV_L;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   regmap_read(battery-regmap, regh, msb);
+   regmap_read(battery-regmap, regl, lsb);
+
+   ret = ((msb  4) + (lsb  4)) * 1250 / 1000;
+
+   return ret;
+}
+
+static int rt5033_battery_get_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   union power_supply_propval *val)
+{
+   struct rt5033_battery *battery = container_of(psy,
+   struct rt5033_battery, psy);
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV

[PATCH v7 0/4] mfd: rt5033: Add Richtek RT5033 drivers

2014-12-02 Thread Beomho Seo
 This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge, regulators.
This patchset provides common support for accessing the device.
This patchset have been tested base on exynos board.

Changes in v7
- Use small description.
- Change some names for a variable.
- Revise of_device_id struct style.

Changes in v6
- Fix white space issue in mfd cell struct.

Changes in v5
- Change possible built as a module.
- Revise rt5033_dev mfd cell entry.
- Fix incorrect typo.
- Add module alias.

Changes in v4
- rt5033 regulator patch is applied by Mark Brown.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Remove unnecessary subnode of_compatible.
- Add definde for set high impedance mode of charger.
- Remove unnecessary device specific code.
- Fix wrong register name.
- Fix wrong error message.
- Fix return vallue at error case.
- Revise binding documentation.

Beomho Seo (4):
  mfd: rt5033: Add Richtek RT5033 driver core.
  power: rt5033_battery: Add RT5033 Fuel gauge device driver
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/mfd/Kconfig|   12 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  141 ++
 drivers/power/Kconfig  |   16 +
 drivers/power/Makefile |2 +
 drivers/power/rt5033_battery.c |  177 +++
 drivers/power/rt5033_charger.c |  485 
 include/linux/mfd/rt5033-private.h |  260 +++
 include/linux/mfd/rt5033.h |   62 +++
 11 files changed, 1265 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 drivers/power/rt5033_battery.c
 create mode 100644 drivers/power/rt5033_charger.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

-- 
1.7.9.5

--
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 v7 4/4] Documentation: Add documentation for rt5033 multifunction device

2014-12-02 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v7
Changes in v6
Changes in v5
Changes in v4
Changes in v3
- none.

Changes in v2
- Revise binding documentation.
---
 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..52a6d33
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,108 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators usinge the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   i2c_fuel: i2c@1 {
+   compatible = i2c-gpio;
+   standard i2c-gpio constraints...
+   fuelgauge {
+   compatible = richtek,rt5033-battery.
+   };
+   };
+
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+   };
+
+   i2c_fuel: i2c@10 {
+   compatible = i2c-gpio;
+   gpios = gpm3 1 0
+   gpm3 0 0;
+
+   fuel: rt5033-battery@35

[PATCH v7 3/4] power: rt5033_charger: Add RT5033 charger device driver

2014-12-02 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v7
- Changes some variable name.

Changes in v6
Changes in v5
Changes in v4
- none.

Changes in v3
- Add author information the top of driver.

Changes in v2
- Fix wrong error message.
- Fix return value at error case. Because  charger-data null, probe function
return zero.
- Use define for set control register.
---
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..9dcaef4
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf

[PATCH v7 1/4] mfd: rt5033: Add Richtek RT5033 driver core.

2014-12-02 Thread Beomho Seo
This patch adds a new driver for Richtek RT5033 driver.
RT5033 is a Multifunction device which includes battery charger, fuel gauge,
flash LED current source, LDO and synchronous Buck converter. It is interfaced
to host controller using I2C interface.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.j...@linaro.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v7
- Use small description.
- Change some names for a variable.
- Revise of_device_id struct style.

Changes in v6
- Fix white space issue in mfd cell struct.

Changes in v5
- Change possible built as a module.
- Revise rt5033_dev mfd cell entry.
- Fix incorrect typo.
- Add module alias.

Changes in v4
- none.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Revmoe unnecessary subnode of_compatible.
- Add define for set_high impedance mode of charger.
---
 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  141 +++
 include/linux/mfd/rt5033-private.h |  260 
 include/linux/mfd/rt5033.h |   62 +
 5 files changed, 476 insertions(+)
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2e6b731..9cd2af6 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -623,6 +623,18 @@ config MFD_RTSX_PCI
  types of memory cards, such as Memory Stick, Memory Stick Pro,
  Secure Digital and MultiMediaCard.
 
+config MFD_RT5033
+   tristate Richtek RT5033 Power Management IC
+   depends on I2C=y
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ This driver provides for the Richtek RT5033 Power Management IC,
+ which includes the I2C driver and the Core APIs. This driver provides
+ common support for accessing the device. The device supports multiple
+ sub-devices like charger, fuel gauge, flash LED, current source,
+ LDO and Buck.
+
 config MFD_RTSX_USB
tristate Realtek USB card reader
depends on USB
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 53467e2..4059c24 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO)+= ipaq-micro.o
 obj-$(CONFIG_MFD_MENF21BMC)+= menf21bmc.o
 obj-$(CONFIG_MFD_HI6421_PMIC)  += hi6421-pmic-core.o
 obj-$(CONFIG_MFD_DLN2) += dln2.o
+obj-$(CONFIG_MFD_RT5033)   += rt5033.o
 
 intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
new file mode 100644
index 000..2d2bfbe
--- /dev/null
+++ b/drivers/mfd/rt5033.c
@@ -0,0 +1,141 @@
+/*
+ * RT5033 core driver.
+ *
+ * Copyright (C) 2014 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/err.h
+#include linux/module.h
+#include linux/interrupt.h
+#include linux/of_device.h
+#include linux/mfd/core.h
+#include linux/mfd/rt5033.h
+#include linux/mfd/rt5033-private.h
+
+static const struct regmap_irq rt5033_irqs[] = {
+   { .mask = RT5033_PMIC_IRQ_BUCKOCP, },
+   { .mask = RT5033_PMIC_IRQ_BUCKLV, },
+   { .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
+   { .mask = RT5033_PMIC_IRQ_LDOLV, },
+   { .mask = RT5033_PMIC_IRQ_OT, },
+   { .mask = RT5033_PMIC_IRQ_VDDA_UV, },
+};
+
+static const struct regmap_irq_chip rt5033_irq_chip = {
+   .name   = rt5033,
+   .status_base= RT5033_REG_PMIC_IRQ_STAT,
+   .mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
+   .mask_invert= true,
+   .num_regs   = 1,
+   .irqs   = rt5033_irqs,
+   .num_irqs   = ARRAY_SIZE(rt5033_irqs),
+};
+
+static const struct mfd_cell rt5033_devs[] = {
+   { .name = rt5033-regulator, },
+   {
+   .name = rt5033-charger,
+   .of_compatible = richtek,rt5033-charger,
+   }, {
+   .name = rt5033-battery,
+   .of_compatible = richtek,rt5033-battery,
+   },
+};
+
+static const struct of_device_id rt5033_dt_match[] = {
+   {
+   .compatible = richtek,rt5033,
+   },
+   { }
+};
+
+static const struct regmap_config rt5033_regmap_config = {
+   .reg_bits   = 8,
+   .val_bits   = 8

Re: [PATCH v6 1/4] mfd: rt5033: Add Richtek RT5033 driver core.

2014-12-01 Thread Beomho Seo
Thank you for advices.
On 12/01/2014 09:39 PM, Lee Jones wrote:
 Sorry for the delay.
 
 This patch adds a new driver for Richtek RT5033 driver.
 RT5033 is a Multifunction device which includes battery charger, fuel gauge,
 flash LED current source, LDO and synchronous Buck converter. It is 
 interfaced
 to host controller using I2C interface.

 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Lee Jones lee.j...@linaro.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
 Changes in v6
 - Fix white space issue in mfd cell struct.

 Changes in v5
 - Change possible built as a module.
 - Revise rt5033_dev mfd cell entry.
 - Fix incorrect typo.
 - Add module alias.

 Changes in v4
 - none.

 Changes in v3
 - Correct sentence errors.
 - Add author information the top of each drivers.
 - Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
 - Change some return check.
 - Use bool and of_match_ptr().

 Changes in v2
 - Remove volatile_reg callback. Because this driver not in use regmap cache.
 - Revmoe unnecessary subnode of_compatible.
 - Add define for set_high impedance mode of charger.

  drivers/mfd/Kconfig|   12 ++
  drivers/mfd/Makefile   |1 +
  drivers/mfd/rt5033.c   |  141 +++
  include/linux/mfd/rt5033-private.h |  260 
 
  include/linux/mfd/rt5033.h |   62 +
  5 files changed, 476 insertions(+)
  create mode 100644 drivers/mfd/rt5033.c
  create mode 100644 include/linux/mfd/rt5033-private.h
  create mode 100644 include/linux/mfd/rt5033.h

 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index 72d3808..9c13170 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -618,6 +618,18 @@ config MFD_RTSX_PCI
types of memory cards, such as Memory Stick, Memory Stick Pro,
Secure Digital and MultiMediaCard.
  
 +config MFD_RT5033
 +tristate Richtek RT5033 Power Management IC
 +depends on I2C=y
 +select MFD_CORE
 +select REGMAP_I2C
 +help
 +  This driver provides for the Richtek RT5033 Power Management IC,
 +  which includes the I2C driver and the Core APIs. This driver provides
 +  common support for accessing the device. The device supports multiple
 +  sub-devices like charger, fuel gauge, flash LED, current source,
 +  LDO and Buck.
 +
  config MFD_RTSX_USB
  tristate Realtek USB card reader
  depends on USB
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 53467e2..4059c24 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o
  obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o
  obj-$(CONFIG_MFD_HI6421_PMIC)   += hi6421-pmic-core.o
  obj-$(CONFIG_MFD_DLN2)  += dln2.o
 +obj-$(CONFIG_MFD_RT5033)+= rt5033.o
  
  intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o
  obj-$(CONFIG_INTEL_SOC_PMIC)+= intel-soc-pmic.o
 diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
 new file mode 100644
 index 000..e2877c0
 --- /dev/null
 +++ b/drivers/mfd/rt5033.c
 @@ -0,0 +1,141 @@
 +/*
 + * MFD core driver for the Richtek RT5033.
 
 Nicer to put a small description of the h/w here.
 

OK. I will put a small description.

 + * Copyright (C) 2014 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/err.h
 +#include linux/module.h
 +#include linux/interrupt.h
 +#include linux/of_device.h
 +#include linux/mfd/core.h
 +#include linux/mfd/rt5033.h
 +#include linux/mfd/rt5033-private.h
 +
 +static const struct regmap_irq rt5033_irqs[] = {
 +{ .mask = RT5033_PMIC_IRQ_BUCKOCP, },
 +{ .mask = RT5033_PMIC_IRQ_BUCKLV, },
 +{ .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
 +{ .mask = RT5033_PMIC_IRQ_LDOLV, },
 +{ .mask = RT5033_PMIC_IRQ_OT, },
 +{ .mask = RT5033_PMIC_IRQ_VDDA_UV, },
 +};
 +
 +static const struct regmap_irq_chip rt5033_irq_chip = {
 +.name   = rt5033,
 +.status_base= RT5033_REG_PMIC_IRQ_STAT,
 +.mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
 +.mask_invert= true,
 +.num_regs   = 1,
 +.irqs   = rt5033_irqs,
 +.num_irqs   = ARRAY_SIZE(rt5033_irqs),
 +};
 +
 +static const struct mfd_cell rt5033_devs[] = {
 +{ .name = rt5033-regulator, },
 +{
 +.name = rt5033-charger,
 +.of_compatible = richtek,rt5033-charger,
 +}, {
 +.name = rt5033-battery,
 +.of_compatible = richtek,rt5033-battery,
 +},
 +};
 +
 +static const struct of_device_id rt5033_dt_match[] = {
 +{ .compatible = richtek,rt5033, },
 +{ }
 +};
 
 Put this just above where you use

[PATCH v6 0/4] mfd: rt5033: Add Richtek RT5033 drivers

2014-11-20 Thread Beomho Seo
 This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge, regulators.
This patchset provides common support for accessing the device.
This patchset have been tested base on exynos board.

Changes in v6
- Fix white space issue in mfd cell struct.

Changes in v5
- Change possible built as a module.
- Revise rt5033_dev mfd cell entry.
- Fix incorrect typo.
- Add module alias.

Changes in v4
- rt5033 regulator patch is applied by Mark Brown.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Remove unnecessary subnode of_compatible.
- Add definde for set high impedance mode of charger.
- Remove unnecessary device specific code.
- Fix wrong register name.
- Fix wrong error message.
- Fix return vallue at error case.
- Revise binding documentation.

Beomho Seo (4):
  mfd: rt5033: Add Richtek RT5033 driver core.
  power: rt5033_battery: Add RT5033 Fuel gauge device driver
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/mfd/Kconfig|   12 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  141 ++
 drivers/power/Kconfig  |   16 +
 drivers/power/Makefile |2 +
 drivers/power/rt5033_battery.c |  177 +++
 drivers/power/rt5033_charger.c |  485 
 include/linux/mfd/rt5033-private.h |  260 +++
 include/linux/mfd/rt5033.h |   62 +++
 11 files changed, 1265 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 drivers/power/rt5033_battery.c
 create mode 100644 drivers/power/rt5033_charger.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

-- 
1.7.9.5

--
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 1/4] mfd: rt5033: Add Richtek RT5033 driver core.

2014-11-20 Thread Beomho Seo
This patch adds a new driver for Richtek RT5033 driver.
RT5033 is a Multifunction device which includes battery charger, fuel gauge,
flash LED current source, LDO and synchronous Buck converter. It is interfaced
to host controller using I2C interface.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.j...@linaro.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v6
- Fix white space issue in mfd cell struct.

Changes in v5
- Change possible built as a module.
- Revise rt5033_dev mfd cell entry.
- Fix incorrect typo.
- Add module alias.

Changes in v4
- none.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Revmoe unnecessary subnode of_compatible.
- Add define for set_high impedance mode of charger.

 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  141 +++
 include/linux/mfd/rt5033-private.h |  260 
 include/linux/mfd/rt5033.h |   62 +
 5 files changed, 476 insertions(+)
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 72d3808..9c13170 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -618,6 +618,18 @@ config MFD_RTSX_PCI
  types of memory cards, such as Memory Stick, Memory Stick Pro,
  Secure Digital and MultiMediaCard.
 
+config MFD_RT5033
+   tristate Richtek RT5033 Power Management IC
+   depends on I2C=y
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ This driver provides for the Richtek RT5033 Power Management IC,
+ which includes the I2C driver and the Core APIs. This driver provides
+ common support for accessing the device. The device supports multiple
+ sub-devices like charger, fuel gauge, flash LED, current source,
+ LDO and Buck.
+
 config MFD_RTSX_USB
tristate Realtek USB card reader
depends on USB
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 53467e2..4059c24 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO)+= ipaq-micro.o
 obj-$(CONFIG_MFD_MENF21BMC)+= menf21bmc.o
 obj-$(CONFIG_MFD_HI6421_PMIC)  += hi6421-pmic-core.o
 obj-$(CONFIG_MFD_DLN2) += dln2.o
+obj-$(CONFIG_MFD_RT5033)   += rt5033.o
 
 intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
new file mode 100644
index 000..e2877c0
--- /dev/null
+++ b/drivers/mfd/rt5033.c
@@ -0,0 +1,141 @@
+/*
+ * MFD core driver for the Richtek RT5033.
+ *
+ * Copyright (C) 2014 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/err.h
+#include linux/module.h
+#include linux/interrupt.h
+#include linux/of_device.h
+#include linux/mfd/core.h
+#include linux/mfd/rt5033.h
+#include linux/mfd/rt5033-private.h
+
+static const struct regmap_irq rt5033_irqs[] = {
+   { .mask = RT5033_PMIC_IRQ_BUCKOCP, },
+   { .mask = RT5033_PMIC_IRQ_BUCKLV, },
+   { .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
+   { .mask = RT5033_PMIC_IRQ_LDOLV, },
+   { .mask = RT5033_PMIC_IRQ_OT, },
+   { .mask = RT5033_PMIC_IRQ_VDDA_UV, },
+};
+
+static const struct regmap_irq_chip rt5033_irq_chip = {
+   .name   = rt5033,
+   .status_base= RT5033_REG_PMIC_IRQ_STAT,
+   .mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
+   .mask_invert= true,
+   .num_regs   = 1,
+   .irqs   = rt5033_irqs,
+   .num_irqs   = ARRAY_SIZE(rt5033_irqs),
+};
+
+static const struct mfd_cell rt5033_devs[] = {
+   { .name = rt5033-regulator, },
+   {
+   .name = rt5033-charger,
+   .of_compatible = richtek,rt5033-charger,
+   }, {
+   .name = rt5033-battery,
+   .of_compatible = richtek,rt5033-battery,
+   },
+};
+
+static const struct of_device_id rt5033_dt_match[] = {
+   { .compatible = richtek,rt5033, },
+   { }
+};
+
+static const struct regmap_config rt5033_regmap_config = {
+   .reg_bits   = 8,
+   .val_bits   = 8,
+   .max_register   = RT5033_REG_END,
+};
+
+static int rt5033_i2c_probe(struct i2c_client *i2c

[PATCH v6 4/4] Documentation: Add documentation for rt5033 multifunction device

2014-11-20 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v6:
Changes in v5:
Changes in v4:
Changes in v3:
- none.

Changes in v2:
- Revise binding documentation.

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..52a6d33
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,108 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators usinge the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   i2c_fuel: i2c@1 {
+   compatible = i2c-gpio;
+   standard i2c-gpio constraints...
+   fuelgauge {
+   compatible = richtek,rt5033-battery.
+   };
+   };
+
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+   };
+
+   i2c_fuel: i2c@10 {
+   compatible = i2c-gpio;
+   gpios = gpm3 1 0
+   gpm3 0 0;
+
+   fuel: rt5033-battery@35 {
+   compatible

[PATCH v6 3/4] power: rt5033_charger: Add RT5033 charger device driver

2014-11-20 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v6:
Changes in v5:
Changes in v4:
- none.

Changes in v3:
- Add author information the top of driver.

Changes in v2:
- Fix wrong error message.
- Fix return value at error case. Because  charger-data null, probe function
return zero.
- Use define for set control register.

 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..634f2f1
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT

[PATCH v6 2/4] power: rt5033_battery: Add RT5033 Fuel gauge device driver

2014-11-20 Thread Beomho Seo
This patch adds device driver of Richtek PMIC.
The driver support battery fuel gange. Fuel gauge calculates and determines the
battery state of charge(SOC) according to battery open circuit voltage(OCV).
Also, this driver provides battery average voltage, voltage and bettery present
property.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v6:
Changes in v5:
Changes in v4:
- none.

Changes in v3:
- Add author information the top of driver.

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Fix wrong register name.

 drivers/power/Kconfig  |8 ++
 drivers/power/Makefile |1 +
 drivers/power/rt5033_battery.c |  177 
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/power/rt5033_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 0108c2a..da6981f 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -397,6 +397,14 @@ config BATTERY_GOLDFISH
  Say Y to enable support for the battery and AC power in the
  Goldfish emulator.
 
+config BATTERY_RT5033
+   tristate RT5033 fuel gauge support
+   depends on MFD_RT5033
+   help
+ This adds support for battery fuel gauge in Richtek RT5033 PMIC.
+ The fuelgauge calculates and determines the battery state of charge
+ according to battery open circuit voltage.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index dfa8942..b83a0c7 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9052)  += da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042) += max17042_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
 obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c
new file mode 100644
index 000..7b898f4
--- /dev/null
+++ b/drivers/power/rt5033_battery.c
@@ -0,0 +1,177 @@
+/*
+ * Fuel gauge driver for Richtek RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_battery_get_capacity(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 msb;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_SOC_H, msb);
+
+   return msb;
+}
+
+static int rt5033_battery_get_present(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 val;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_CONFIG_L, val);
+
+   return (val  RT5033_FUEL_BAT_PRESENT) ? true : false;
+}
+
+static int rt5033_battery_get_watt_prop(struct i2c_client *client,
+   enum power_supply_property psp)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   unsigned int regh, regl;
+   int ret;
+   u32 msb, lsb;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   regh = RT5033_FUEL_REG_VBAT_H;
+   regl = RT5033_FUEL_REG_VBAT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   regh = RT5033_FUEL_REG_AVG_VOLT_H;
+   regl = RT5033_FUEL_REG_AVG_VOLT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   regh = RT5033_FUEL_REG_OCV_H;
+   regl = RT5033_FUEL_REG_OCV_L;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   regmap_read(battery-regmap, regh, msb);
+   regmap_read(battery-regmap, regl, lsb);
+
+   ret = ((msb  4) + (lsb  4)) * 1250 / 1000;
+
+   return ret;
+}
+
+static int rt5033_battery_get_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   union power_supply_propval *val)
+{
+   struct rt5033_battery *battery = container_of(psy,
+   struct rt5033_battery, psy);
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   val-intval

Re: [PATCH v5 1/4] mfd: rt5033: Add Richtek RT5033 driver core.

2014-11-19 Thread Beomho Seo
On 11/20/2014 01:37 AM, Lee Jones wrote:
 On Wed, 19 Nov 2014, Beomho Seo wrote:
 
 This patch adds a new driver for Richtek RT5033 driver.
 RT5033 is a Multifunction device which includes battery charger, fuel gauge,
 flash LED current source, LDO and synchronous Buck converter. It is 
 interfaced
 to host controller using I2C interface.

 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Lee Jones lee.j...@linaro.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
 Changes in v5
 - Change possible built as a module.
 - Revise rt5033_dev mfd cell entry.
 - Fix incorrect typo.
 - Add module alias.

 Changes in v4
 - none.

 Changes in v3
 - Correct sentence errors.
 - Add author information the top of each drivers.
 - Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
 - Change some return check.
 - Use bool and of_match_ptr().

 Changes in v2
 - Remove volatile_reg callback. Because this driver not in use regmap cache.
 - Revmoe unnecessary subnode of_compatible.
 - Add define for set_high impedance mode of charger.
 ---
  drivers/mfd/Kconfig|   12 ++
  drivers/mfd/Makefile   |1 +
  drivers/mfd/rt5033.c   |  136 +++
  include/linux/mfd/rt5033-private.h |  260 
 
  include/linux/mfd/rt5033.h |   62 +
  5 files changed, 471 insertions(+)
  create mode 100644 drivers/mfd/rt5033.c
  create mode 100644 include/linux/mfd/rt5033-private.h
  create mode 100644 include/linux/mfd/rt5033.h

 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index 72d3808..9c13170 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -618,6 +618,18 @@ config MFD_RTSX_PCI
types of memory cards, such as Memory Stick, Memory Stick Pro,
Secure Digital and MultiMediaCard.
  
 +config MFD_RT5033
 +tristate Richtek RT5033 Power Management IC
 +depends on I2C=y
 +select MFD_CORE
 +select REGMAP_I2C
 +help
 +  This driver provides for the Richtek RT5033 Power Management IC,
 +  which includes the I2C driver and the Core APIs. This driver provides
 +  common support for accessing the device. The device supports multiple
 +  sub-devices like charger, fuel gauge, flash LED, current source,
 +  LDO and Buck.
 +
  config MFD_RTSX_USB
  tristate Realtek USB card reader
  depends on USB
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 53467e2..4059c24 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o
  obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o
  obj-$(CONFIG_MFD_HI6421_PMIC)   += hi6421-pmic-core.o
  obj-$(CONFIG_MFD_DLN2)  += dln2.o
 +obj-$(CONFIG_MFD_RT5033)+= rt5033.o
  
  intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o
  obj-$(CONFIG_INTEL_SOC_PMIC)+= intel-soc-pmic.o
 diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
 new file mode 100644
 index 000..4d289b9
 --- /dev/null
 +++ b/drivers/mfd/rt5033.c
 @@ -0,0 +1,136 @@
 +/*
 + * MFD core driver for the Richtek RT5033.
 + *
 + * Copyright (C) 2014 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/err.h
 +#include linux/module.h
 +#include linux/interrupt.h
 +#include linux/of_device.h
 +#include linux/mfd/core.h
 +#include linux/mfd/rt5033.h
 +#include linux/mfd/rt5033-private.h
 +
 +static const struct regmap_irq rt5033_irqs[] = {
 +{ .mask = RT5033_PMIC_IRQ_BUCKOCP, },
 +{ .mask = RT5033_PMIC_IRQ_BUCKLV, },
 +{ .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
 +{ .mask = RT5033_PMIC_IRQ_LDOLV, },
 +{ .mask = RT5033_PMIC_IRQ_OT, },
 +{ .mask = RT5033_PMIC_IRQ_VDDA_UV, },
 +};
 +
 +static const struct regmap_irq_chip rt5033_irq_chip = {
 +.name   = rt5033,
 +.status_base= RT5033_REG_PMIC_IRQ_STAT,
 +.mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
 +.mask_invert= true,
 +.num_regs   = 1,
 +.irqs   = rt5033_irqs,
 +.num_irqs   = ARRAY_SIZE(rt5033_irqs),
 +};
 +
 +static const struct mfd_cell rt5033_devs[] = {
 +{ .name = rt5033-regulator, },
 +{ .name = rt5033-charger, .of_compatible = richtek,rt5033-charger,},
 +{ .name = rt5033-battery, .of_compatible = richtek,rt5033-battery,},
 +};
 
 Perhaps I wasn't clear enough in my previous review -- sorry for
 that.  I only want to see the single entry on one line i.e. one with
 .name, but no .of_compatible.  I probably wouldn't have requested a
 re-spin, but you have white space issues at the end of those two lines
 too.
 

I will follow your previous review. I will only change the single entry
 on one line

[PATCH v4 0/4] mfd: rt5033: Add Richtek RT5033 drivers

2014-11-18 Thread Beomho Seo
 This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge, regulators.
This patchset provides common support for accessing the device.
This patchset have been tested base on exynos board.

Changes in v4
- rt5033 regulator patch is applied by Mark Brown.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Remove unnecessary subnode of_compatible.
- Add definde for set high impedance mode of charger.
- Remove unnecessary device specific code.
- Fix wrong register name.
- Fix wrong error message.
- Fix return vallue at error case.
- Revise binding documentation.

Beomho Seo (4):
  mfd: rt5033: Add Richtek RT5033 driver core.
  power: rt5033_battery: Add RT5033 Fuel gauge device driver
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/mfd/Kconfig|   12 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  141 ++
 drivers/power/Kconfig  |   16 +
 drivers/power/Makefile |2 +
 drivers/power/rt5033_battery.c |  177 +++
 drivers/power/rt5033_charger.c |  485 
 include/linux/mfd/rt5033-private.h |  260 +++
 include/linux/mfd/rt5033.h |   62 +++
 11 files changed, 1265 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 drivers/power/rt5033_battery.c
 create mode 100644 drivers/power/rt5033_charger.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

-- 
1.7.9.5

--
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 v4 4/4] Documentation: Add documentation for rt5033 multifunction device

2014-11-18 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v4:
Changes in v3:
- none.

Changes in v2:
- Revise binding documentation.
---
Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..52a6d33
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,108 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators usinge the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   i2c_fuel: i2c@1 {
+   compatible = i2c-gpio;
+   standard i2c-gpio constraints...
+   fuelgauge {
+   compatible = richtek,rt5033-battery.
+   };
+   };
+
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+   };
+
+   i2c_fuel: i2c@10 {
+   compatible = i2c-gpio;
+   gpios = gpm3 1 0
+   gpm3 0 0;
+
+   fuel: rt5033-battery@35 {
+   compatible = richtek,rt5033-battery

[PATCH v4 3/4] power: rt5033_charger: Add RT5033 charger device driver

2014-11-18 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v4:
- none.

Changes in v3:
- Add author information the top of driver.

Changes in v2:
- Fix wrong error message.
- Fix return value at error case. Because  charger-data null, probe function
return zero.
- Use define for set control register.
---
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..634f2f1
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT)
+   state

[PATCH v4 2/4] power: rt5033_battery: Add RT5033 Fuel gauge device driver

2014-11-18 Thread Beomho Seo
This patch adds device driver of Richtek PMIC.
The driver support battery fuel gange. Fuel gauge calculates and determines the
battery state of charge(SOC) according to battery open circuit voltage(OCV).
Also, this driver provides battery average voltage, voltage and bettery present
property.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v4:
- none.

Changes in v3:
- Add author information the top of driver.

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Fix wrong register name.
---
 drivers/power/Kconfig  |8 ++
 drivers/power/Makefile |1 +
 drivers/power/rt5033_battery.c |  177 
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/power/rt5033_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 0108c2a..da6981f 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -397,6 +397,14 @@ config BATTERY_GOLDFISH
  Say Y to enable support for the battery and AC power in the
  Goldfish emulator.
 
+config BATTERY_RT5033
+   tristate RT5033 fuel gauge support
+   depends on MFD_RT5033
+   help
+ This adds support for battery fuel gauge in Richtek RT5033 PMIC.
+ The fuelgauge calculates and determines the battery state of charge
+ according to battery open circuit voltage.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index dfa8942..b83a0c7 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9052)  += da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042) += max17042_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
 obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c
new file mode 100644
index 000..7b898f4
--- /dev/null
+++ b/drivers/power/rt5033_battery.c
@@ -0,0 +1,177 @@
+/*
+ * Fuel gauge driver for Richtek RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_battery_get_capacity(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 msb;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_SOC_H, msb);
+
+   return msb;
+}
+
+static int rt5033_battery_get_present(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 val;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_CONFIG_L, val);
+
+   return (val  RT5033_FUEL_BAT_PRESENT) ? true : false;
+}
+
+static int rt5033_battery_get_watt_prop(struct i2c_client *client,
+   enum power_supply_property psp)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   unsigned int regh, regl;
+   int ret;
+   u32 msb, lsb;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   regh = RT5033_FUEL_REG_VBAT_H;
+   regl = RT5033_FUEL_REG_VBAT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   regh = RT5033_FUEL_REG_AVG_VOLT_H;
+   regl = RT5033_FUEL_REG_AVG_VOLT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   regh = RT5033_FUEL_REG_OCV_H;
+   regl = RT5033_FUEL_REG_OCV_L;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   regmap_read(battery-regmap, regh, msb);
+   regmap_read(battery-regmap, regl, lsb);
+
+   ret = ((msb  4) + (lsb  4)) * 1250 / 1000;
+
+   return ret;
+}
+
+static int rt5033_battery_get_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   union power_supply_propval *val)
+{
+   struct rt5033_battery *battery = container_of(psy,
+   struct rt5033_battery, psy);
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   val-intval = rt5033_battery_get_watt_prop

[PATCH v4 1/4] mfd: rt5033: Add Richtek RT5033 driver core.

2014-11-18 Thread Beomho Seo
This patch adds a new driver for Richtek RT5033 driver.
RT5033 is a Multifunction device which includes battery charger, fuel gauge,
flash LED current source, LDO and synchronous Buck converter. It is interfaced
to host controller using I2C interface.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.j...@linaro.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v4
- none.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Revmoe unnecessary subnode of_compatible.
- Add define for set_high impedance mode of charger.
---

 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  141 +++
 include/linux/mfd/rt5033-private.h |  260 
 include/linux/mfd/rt5033.h |   62 +
 5 files changed, 476 insertions(+)
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 72d3808..55b6551 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -618,6 +618,18 @@ config MFD_RTSX_PCI
  types of memory cards, such as Memory Stick, Memory Stick Pro,
  Secure Digital and MultiMediaCard.
 
+config MFD_RT5033
+   bool Richtek RT5033 Power Management IC
+   depends on I2C=y
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ This driver provides for the Richtek RT5033 Power Management IC,
+ which includes the I2C driver and the Core APIs. This driver provides
+ common support for accessing the device. The device supports multiple
+ sub-devices like charger, fuel gauge, flash LED, current source,
+ LDO and Buck.
+
 config MFD_RTSX_USB
tristate Realtek USB card reader
depends on USB
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 53467e2..4059c24 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO)+= ipaq-micro.o
 obj-$(CONFIG_MFD_MENF21BMC)+= menf21bmc.o
 obj-$(CONFIG_MFD_HI6421_PMIC)  += hi6421-pmic-core.o
 obj-$(CONFIG_MFD_DLN2) += dln2.o
+obj-$(CONFIG_MFD_RT5033)   += rt5033.o
 
 intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
new file mode 100644
index 000..e29c6d9
--- /dev/null
+++ b/drivers/mfd/rt5033.c
@@ -0,0 +1,141 @@
+/*
+ * MFD core driver for the Richtek RT5033.
+ *
+ * Copyright (C) 2014 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/err.h
+#include linux/module.h
+#include linux/interrupt.h
+#include linux/of_device.h
+#include linux/mfd/core.h
+#include linux/mfd/rt5033.h
+#include linux/mfd/rt5033-private.h
+
+static const struct regmap_irq rt5033_irqs[] = {
+   { .mask = RT5033_PMIC_IRQ_BUCKOCP, },
+   { .mask = RT5033_PMIC_IRQ_BUCKLV, },
+   { .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
+   { .mask = RT5033_PMIC_IRQ_LDOLV, },
+   { .mask = RT5033_PMIC_IRQ_OT, },
+   { .mask = RT5033_PMIC_IRQ_VDDA_UV, },
+};
+
+static const struct regmap_irq_chip rt5033_irq_chip = {
+   .name   = rt5033,
+   .status_base= RT5033_REG_PMIC_IRQ_STAT,
+   .mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
+   .mask_invert= true,
+   .num_regs   = 1,
+   .irqs   = rt5033_irqs,
+   .num_irqs   = ARRAY_SIZE(rt5033_irqs),
+};
+
+static const struct mfd_cell rt5033_devs[] = {
+   {
+   .name = rt5033-regulator,
+   }, {
+   .name = rt5033-charger,
+   .of_compatible = richtek,rt5033-charger,
+   }, {
+   .name = rt5033-battery,
+   .of_compatible = richtek,rt5033-battery,
+   },
+};
+
+static const struct of_device_id rt5033_dt_match[] = {
+   { .compatible = richtek,rt5033, },
+   { }
+};
+
+static const struct regmap_config rt5033_regmap_config = {
+   .reg_bits   = 8,
+   .val_bits   = 8,
+   .max_register   = RT5033_REG_END,
+};
+
+static int rt5033_i2c_probe(struct i2c_client *i2c,
+   const struct i2c_device_id *id)
+{
+   struct rt5033_dev *rt5033;
+   unsigned int data;
+   int ret;
+
+   rt5033 = devm_kzalloc(i2c-dev, sizeof

Re: [PATCH v3 1/5] mfd: rt5033: Add Richtek RT5033 driver core.

2014-11-18 Thread Beomho Seo
Thank you for review.

On 11/19/2014 01:25 AM, Lee Jones wrote:
 On Wed, 12 Nov 2014, Beomho Seo wrote:
 
 This patch adds a new driver for Richtek RT5033 driver.
 RT5033 is a Multifunction device which includes battery charger, fuel gauge,
 flash LED current source, LDO and synchronous Buck converter. It is 
 interfaced
 to host controller using I2C interface.

 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Lee Jones lee.j...@linaro.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
 Changes in v3
 - Correct sentence errors.
 - Add author information the top of each drivers.
 - Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
 - Change some return check.
 - Use bool and of_match_ptr().

 Changes in v2
 - Remove volatile_reg callback. Because this driver not in use regmap cache.
 - Revmoe unnecessary subnode of_compatible.
 - Add define for set_high impedance mode of charger.
 ---

  drivers/mfd/Kconfig|   12 ++
  drivers/mfd/Makefile   |1 +
  drivers/mfd/rt5033.c   |  141 +++
  include/linux/mfd/rt5033-private.h |  260 
 
  include/linux/mfd/rt5033.h |   62 +
  5 files changed, 476 insertions(+)
  create mode 100644 drivers/mfd/rt5033.c
  create mode 100644 include/linux/mfd/rt5033-private.h
  create mode 100644 include/linux/mfd/rt5033.h

 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index 72d3808..55b6551 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -618,6 +618,18 @@ config MFD_RTSX_PCI
types of memory cards, such as Memory Stick, Memory Stick Pro,
Secure Digital and MultiMediaCard.
  
 +config MFD_RT5033
 +bool Richtek RT5033 Power Management IC
 +depends on I2C=y
 +select MFD_CORE
 +select REGMAP_I2C
 +help
 +  This driver provides for the Richtek RT5033 Power Management IC,
 +  which includes the I2C driver and the Core APIs. This driver provides
 +  common support for accessing the device. The device supports multiple
 +  sub-devices like charger, fuel gauge, flash LED, current source,
 +  LDO and Buck.
 
 What's stopping this from being built as a module?
 

I will change to possible building as a module.

  config MFD_RTSX_USB
  tristate Realtek USB card reader
  depends on USB
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 53467e2..4059c24 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o
  obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o
  obj-$(CONFIG_MFD_HI6421_PMIC)   += hi6421-pmic-core.o
  obj-$(CONFIG_MFD_DLN2)  += dln2.o
 +obj-$(CONFIG_MFD_RT5033)+= rt5033.o
  
  intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o
  obj-$(CONFIG_INTEL_SOC_PMIC)+= intel-soc-pmic.o
 diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
 new file mode 100644
 index 000..e29c6d9
 --- /dev/null
 +++ b/drivers/mfd/rt5033.c
 @@ -0,0 +1,141 @@
 +/*
 + * MFD core driver for the Richtek RT5033.
 + *
 + * Copyright (C) 2014 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/err.h
 +#include linux/module.h
 
 Why have you included this if you can't build as a module?
 

I will change that driver can build as a module.

 +#include linux/interrupt.h
 +#include linux/of_device.h
 +#include linux/mfd/core.h
 +#include linux/mfd/rt5033.h
 +#include linux/mfd/rt5033-private.h
 +
 +static const struct regmap_irq rt5033_irqs[] = {
 +{ .mask = RT5033_PMIC_IRQ_BUCKOCP, },
 +{ .mask = RT5033_PMIC_IRQ_BUCKLV, },
 +{ .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
 +{ .mask = RT5033_PMIC_IRQ_LDOLV, },
 +{ .mask = RT5033_PMIC_IRQ_OT, },
 +{ .mask = RT5033_PMIC_IRQ_VDDA_UV, },
 +};
 +
 +static const struct regmap_irq_chip rt5033_irq_chip = {
 +.name   = rt5033,
 +.status_base= RT5033_REG_PMIC_IRQ_STAT,
 +.mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
 +.mask_invert= true,
 +.num_regs   = 1,
 +.irqs   = rt5033_irqs,
 +.num_irqs   = ARRAY_SIZE(rt5033_irqs),
 +};
 +
 +static const struct mfd_cell rt5033_devs[] = {
 +{
 +.name = rt5033-regulator,
 +}, {
 
 Place this entry on one line.  Like you did in rt5033_irqs.


OK, I will fix it like rt5033_irqs style.

 +.name = rt5033-charger,
 +.of_compatible = richtek,rt5033-charger,
 +}, {
 +.name = rt5033-battery,
 +.of_compatible = richtek,rt5033-battery,
 +},
 +};
 +
 +static const struct of_device_id rt5033_dt_match[] = {
 +{ .compatible = richtek,rt5033

[PATCH v5 0/4] mfd: rt5033: Add Richtek RT5033 drivers

2014-11-18 Thread Beomho Seo
 This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge, regulators.
This patchset provides common support for accessing the device.
This patchset have been tested base on exynos board.

Changes in v5
- Change possible built as a module.
- Revise rt5033_dev mfd cell entry.
- Fix incorrect typo.
- Add module alias.

Changes in v4
- rt5033 regulator patch is applied by Mark Brown.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Remove unnecessary subnode of_compatible.
- Add definde for set high impedance mode of charger.
- Remove unnecessary device specific code.
- Fix wrong register name.
- Fix wrong error message.
- Fix return vallue at error case.
- Revise binding documentation.

Beomho Seo (4):
  mfd: rt5033: Add Richtek RT5033 driver core.
  power: rt5033_battery: Add RT5033 Fuel gauge device driver
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/mfd/Kconfig|   12 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  136 ++
 drivers/power/Kconfig  |   16 +
 drivers/power/Makefile |2 +
 drivers/power/rt5033_battery.c |  177 +++
 drivers/power/rt5033_charger.c |  485 
 include/linux/mfd/rt5033-private.h |  260 +++
 include/linux/mfd/rt5033.h |   62 +++
 11 files changed, 1260 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 drivers/power/rt5033_battery.c
 create mode 100644 drivers/power/rt5033_charger.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

-- 
1.7.9.5

--
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 v5 1/4] mfd: rt5033: Add Richtek RT5033 driver core.

2014-11-18 Thread Beomho Seo
This patch adds a new driver for Richtek RT5033 driver.
RT5033 is a Multifunction device which includes battery charger, fuel gauge,
flash LED current source, LDO and synchronous Buck converter. It is interfaced
to host controller using I2C interface.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.j...@linaro.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v5
- Change possible built as a module.
- Revise rt5033_dev mfd cell entry.
- Fix incorrect typo.
- Add module alias.

Changes in v4
- none.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Revmoe unnecessary subnode of_compatible.
- Add define for set_high impedance mode of charger.
---
 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  136 +++
 include/linux/mfd/rt5033-private.h |  260 
 include/linux/mfd/rt5033.h |   62 +
 5 files changed, 471 insertions(+)
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 72d3808..9c13170 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -618,6 +618,18 @@ config MFD_RTSX_PCI
  types of memory cards, such as Memory Stick, Memory Stick Pro,
  Secure Digital and MultiMediaCard.
 
+config MFD_RT5033
+   tristate Richtek RT5033 Power Management IC
+   depends on I2C=y
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ This driver provides for the Richtek RT5033 Power Management IC,
+ which includes the I2C driver and the Core APIs. This driver provides
+ common support for accessing the device. The device supports multiple
+ sub-devices like charger, fuel gauge, flash LED, current source,
+ LDO and Buck.
+
 config MFD_RTSX_USB
tristate Realtek USB card reader
depends on USB
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 53467e2..4059c24 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO)+= ipaq-micro.o
 obj-$(CONFIG_MFD_MENF21BMC)+= menf21bmc.o
 obj-$(CONFIG_MFD_HI6421_PMIC)  += hi6421-pmic-core.o
 obj-$(CONFIG_MFD_DLN2) += dln2.o
+obj-$(CONFIG_MFD_RT5033)   += rt5033.o
 
 intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
new file mode 100644
index 000..4d289b9
--- /dev/null
+++ b/drivers/mfd/rt5033.c
@@ -0,0 +1,136 @@
+/*
+ * MFD core driver for the Richtek RT5033.
+ *
+ * Copyright (C) 2014 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/err.h
+#include linux/module.h
+#include linux/interrupt.h
+#include linux/of_device.h
+#include linux/mfd/core.h
+#include linux/mfd/rt5033.h
+#include linux/mfd/rt5033-private.h
+
+static const struct regmap_irq rt5033_irqs[] = {
+   { .mask = RT5033_PMIC_IRQ_BUCKOCP, },
+   { .mask = RT5033_PMIC_IRQ_BUCKLV, },
+   { .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
+   { .mask = RT5033_PMIC_IRQ_LDOLV, },
+   { .mask = RT5033_PMIC_IRQ_OT, },
+   { .mask = RT5033_PMIC_IRQ_VDDA_UV, },
+};
+
+static const struct regmap_irq_chip rt5033_irq_chip = {
+   .name   = rt5033,
+   .status_base= RT5033_REG_PMIC_IRQ_STAT,
+   .mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
+   .mask_invert= true,
+   .num_regs   = 1,
+   .irqs   = rt5033_irqs,
+   .num_irqs   = ARRAY_SIZE(rt5033_irqs),
+};
+
+static const struct mfd_cell rt5033_devs[] = {
+   { .name = rt5033-regulator, },
+   { .name = rt5033-charger, .of_compatible = richtek,rt5033-charger,},
+   { .name = rt5033-battery, .of_compatible = richtek,rt5033-battery,},
+};
+
+static const struct of_device_id rt5033_dt_match[] = {
+   { .compatible = richtek,rt5033, },
+   { }
+};
+
+static const struct regmap_config rt5033_regmap_config = {
+   .reg_bits   = 8,
+   .val_bits   = 8,
+   .max_register   = RT5033_REG_END,
+};
+
+static int rt5033_i2c_probe(struct i2c_client *i2c,
+   const struct i2c_device_id *id)
+{
+   struct rt5033_dev *rt5033;
+   unsigned int data;
+   int ret

[PATCH v5 3/4] power: rt5033_charger: Add RT5033 charger device driver

2014-11-18 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v5:
Changes in v4:
- none.

Changes in v3:
- Add author information the top of driver.

Changes in v2:
- Fix wrong error message.
- Fix return value at error case. Because  charger-data null, probe function
return zero.
- Use define for set control register.
---
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..634f2f1
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT

[PATCH v5 2/4] power: rt5033_battery: Add RT5033 Fuel gauge device driver

2014-11-18 Thread Beomho Seo
This patch adds device driver of Richtek PMIC.
The driver support battery fuel gange. Fuel gauge calculates and determines the
battery state of charge(SOC) according to battery open circuit voltage(OCV).
Also, this driver provides battery average voltage, voltage and bettery present
property.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v5:
Changes in v4:
- none.

Changes in v3:
- Add author information the top of driver.

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Fix wrong register name.
---
 drivers/power/Kconfig  |8 ++
 drivers/power/Makefile |1 +
 drivers/power/rt5033_battery.c |  177 
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/power/rt5033_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 0108c2a..da6981f 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -397,6 +397,14 @@ config BATTERY_GOLDFISH
  Say Y to enable support for the battery and AC power in the
  Goldfish emulator.
 
+config BATTERY_RT5033
+   tristate RT5033 fuel gauge support
+   depends on MFD_RT5033
+   help
+ This adds support for battery fuel gauge in Richtek RT5033 PMIC.
+ The fuelgauge calculates and determines the battery state of charge
+ according to battery open circuit voltage.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index dfa8942..b83a0c7 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9052)  += da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042) += max17042_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
 obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c
new file mode 100644
index 000..7b898f4
--- /dev/null
+++ b/drivers/power/rt5033_battery.c
@@ -0,0 +1,177 @@
+/*
+ * Fuel gauge driver for Richtek RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_battery_get_capacity(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 msb;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_SOC_H, msb);
+
+   return msb;
+}
+
+static int rt5033_battery_get_present(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 val;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_CONFIG_L, val);
+
+   return (val  RT5033_FUEL_BAT_PRESENT) ? true : false;
+}
+
+static int rt5033_battery_get_watt_prop(struct i2c_client *client,
+   enum power_supply_property psp)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   unsigned int regh, regl;
+   int ret;
+   u32 msb, lsb;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   regh = RT5033_FUEL_REG_VBAT_H;
+   regl = RT5033_FUEL_REG_VBAT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   regh = RT5033_FUEL_REG_AVG_VOLT_H;
+   regl = RT5033_FUEL_REG_AVG_VOLT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   regh = RT5033_FUEL_REG_OCV_H;
+   regl = RT5033_FUEL_REG_OCV_L;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   regmap_read(battery-regmap, regh, msb);
+   regmap_read(battery-regmap, regl, lsb);
+
+   ret = ((msb  4) + (lsb  4)) * 1250 / 1000;
+
+   return ret;
+}
+
+static int rt5033_battery_get_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   union power_supply_propval *val)
+{
+   struct rt5033_battery *battery = container_of(psy,
+   struct rt5033_battery, psy);
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   val-intval

[PATCH v5 4/4] Documentation: Add documentation for rt5033 multifunction device

2014-11-18 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v5:
Changes in v4:
Changes in v3:
- none.

Changes in v2:
- Revise binding documentation.
---
 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..52a6d33
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,108 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators usinge the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   i2c_fuel: i2c@1 {
+   compatible = i2c-gpio;
+   standard i2c-gpio constraints...
+   fuelgauge {
+   compatible = richtek,rt5033-battery.
+   };
+   };
+
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+   };
+
+   i2c_fuel: i2c@10 {
+   compatible = i2c-gpio;
+   gpios = gpm3 1 0
+   gpm3 0 0;
+
+   fuel: rt5033-battery@35 {
+   compatible = richtek,rt5033

[PATCH v3 0/5] mfd: rt5033: Add Richtek RT5033 drivers

2014-11-12 Thread Beomho Seo
 This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge, regulators.
This patchset provides common support for accessing the device.
This patchset have been tested base on exynos board.

Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Remove unnecessary subnode of_compatible.
- Add definde for set high impedance mode of charger.
- Remove unnecessary device specific code.
- Fix wrong register name.
- Fix wrong error message.
- Fix return vallue at error case.
- Revise binding documentation.

Beomho Seo (5):
  mfd: rt5033: Add Richtek RT5033 driver core.
  regulator: rt5033: Add RT5033 Regulator device driver
  power: rt5033_battery: Add RT5033 Fuel gauge device driver
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/mfd/Kconfig|   12 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  141 ++
 drivers/power/Kconfig  |   16 +
 drivers/power/Makefile |2 +
 drivers/power/rt5033_battery.c |  177 +++
 drivers/power/rt5033_charger.c |  485 
 drivers/regulator/Kconfig  |8 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/rt5033-regulator.c   |  123 +
 include/linux/mfd/rt5033-private.h |  260 +++
 include/linux/mfd/rt5033.h |   62 +++
 14 files changed, 1397 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 drivers/power/rt5033_battery.c
 create mode 100644 drivers/power/rt5033_charger.c
 create mode 100644 drivers/regulator/rt5033-regulator.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

-- 
1.7.9.5

--
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 v3 4/5] power: rt5033_charger: Add RT5033 charger device driver

2014-11-12 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v3:
- Add author information the top of driver.

Changes in v2:
- Fix wrong error message.
- Fix return value at error case. Because  charger-data null, probe function
return zero.
- Use define for set control register.
---
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..634f2f1
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT)
+   state = RT5033_CHG_MAX_CURRENT

[PATCH v3 1/5] mfd: rt5033: Add Richtek RT5033 driver core.

2014-11-12 Thread Beomho Seo
This patch adds a new driver for Richtek RT5033 driver.
RT5033 is a Multifunction device which includes battery charger, fuel gauge,
flash LED current source, LDO and synchronous Buck converter. It is interfaced
to host controller using I2C interface.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.j...@linaro.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v3
- Correct sentence errors.
- Add author information the top of each drivers.
- Remove unnecessary pre-initialise, struct member(rt5033-i2c) and blink.
- Change some return check.
- Use bool and of_match_ptr().

Changes in v2
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Revmoe unnecessary subnode of_compatible.
- Add define for set_high impedance mode of charger.
---

 drivers/mfd/Kconfig|   12 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  141 +++
 include/linux/mfd/rt5033-private.h |  260 
 include/linux/mfd/rt5033.h |   62 +
 5 files changed, 476 insertions(+)
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 72d3808..55b6551 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -618,6 +618,18 @@ config MFD_RTSX_PCI
  types of memory cards, such as Memory Stick, Memory Stick Pro,
  Secure Digital and MultiMediaCard.
 
+config MFD_RT5033
+   bool Richtek RT5033 Power Management IC
+   depends on I2C=y
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ This driver provides for the Richtek RT5033 Power Management IC,
+ which includes the I2C driver and the Core APIs. This driver provides
+ common support for accessing the device. The device supports multiple
+ sub-devices like charger, fuel gauge, flash LED, current source,
+ LDO and Buck.
+
 config MFD_RTSX_USB
tristate Realtek USB card reader
depends on USB
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 53467e2..4059c24 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -176,6 +176,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO)+= ipaq-micro.o
 obj-$(CONFIG_MFD_MENF21BMC)+= menf21bmc.o
 obj-$(CONFIG_MFD_HI6421_PMIC)  += hi6421-pmic-core.o
 obj-$(CONFIG_MFD_DLN2) += dln2.o
+obj-$(CONFIG_MFD_RT5033)   += rt5033.o
 
 intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
new file mode 100644
index 000..e29c6d9
--- /dev/null
+++ b/drivers/mfd/rt5033.c
@@ -0,0 +1,141 @@
+/*
+ * MFD core driver for the Richtek RT5033.
+ *
+ * Copyright (C) 2014 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/err.h
+#include linux/module.h
+#include linux/interrupt.h
+#include linux/of_device.h
+#include linux/mfd/core.h
+#include linux/mfd/rt5033.h
+#include linux/mfd/rt5033-private.h
+
+static const struct regmap_irq rt5033_irqs[] = {
+   { .mask = RT5033_PMIC_IRQ_BUCKOCP, },
+   { .mask = RT5033_PMIC_IRQ_BUCKLV, },
+   { .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
+   { .mask = RT5033_PMIC_IRQ_LDOLV, },
+   { .mask = RT5033_PMIC_IRQ_OT, },
+   { .mask = RT5033_PMIC_IRQ_VDDA_UV, },
+};
+
+static const struct regmap_irq_chip rt5033_irq_chip = {
+   .name   = rt5033,
+   .status_base= RT5033_REG_PMIC_IRQ_STAT,
+   .mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
+   .mask_invert= true,
+   .num_regs   = 1,
+   .irqs   = rt5033_irqs,
+   .num_irqs   = ARRAY_SIZE(rt5033_irqs),
+};
+
+static const struct mfd_cell rt5033_devs[] = {
+   {
+   .name = rt5033-regulator,
+   }, {
+   .name = rt5033-charger,
+   .of_compatible = richtek,rt5033-charger,
+   }, {
+   .name = rt5033-battery,
+   .of_compatible = richtek,rt5033-battery,
+   },
+};
+
+static const struct of_device_id rt5033_dt_match[] = {
+   { .compatible = richtek,rt5033, },
+   { }
+};
+
+static const struct regmap_config rt5033_regmap_config = {
+   .reg_bits   = 8,
+   .val_bits   = 8,
+   .max_register   = RT5033_REG_END,
+};
+
+static int rt5033_i2c_probe(struct i2c_client *i2c,
+   const struct i2c_device_id *id)
+{
+   struct rt5033_dev *rt5033;
+   unsigned int data;
+   int ret;
+
+   rt5033 = devm_kzalloc(i2c-dev, sizeof(*rt5033), GFP_KERNEL

[PATCH v3 2/5] regulator: rt5033: Add RT5033 Regulator device driver

2014-11-12 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC.
The driver support multiple regulator like LDO and synchronous Buck.
The integrated synchronous buck converter is designed to provide 0.6 A
application with high efficiency. Two LDOs are integrated. One safe LDO is
for 60mA and the other one LDO is for 150 mA.

Cc: Liam Girdwood lgirdw...@gmail.com
Cc: Mark Brown broo...@kernel.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v3:
- Add author information the top of driver.

Changes in v2:
- Remove unnecessary device specific code.
---
 drivers/regulator/Kconfig|8 +++
 drivers/regulator/Makefile   |1 +
 drivers/regulator/rt5033-regulator.c |  123 ++
 3 files changed, 132 insertions(+)
 create mode 100644 drivers/regulator/rt5033-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 55d7b7b..8558e1b 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -521,6 +521,14 @@ config REGULATOR_RN5T618
help
  Say y here to support the regulators found on Ricoh RN5T618 PMIC.
 
+config REGULATOR_RT5033
+   tristate Richtek RT5033 Regulators
+   depends on MFD_RT5033
+   help
+ This adds support for voltage and current regulators in Richtek
+ RT5033 PMIC. The device supports multiple regulators like
+ current source, LDO and Buck.
+
 config REGULATOR_S2MPA01
tristate Samsung S2MPA01 voltage regulator
depends on MFD_SEC_CORE
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 1029ed3..1f28ebf 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
 obj-$(CONFIG_REGULATOR_RC5T583)  += rc5t583-regulator.o
 obj-$(CONFIG_REGULATOR_RK808)   += rk808-regulator.o
 obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o
+obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o
 obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
 obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
diff --git a/drivers/regulator/rt5033-regulator.c 
b/drivers/regulator/rt5033-regulator.c
new file mode 100644
index 000..870cc49
--- /dev/null
+++ b/drivers/regulator/rt5033-regulator.c
@@ -0,0 +1,123 @@
+/*
+ * Regulator driver for the Richtek RT5033
+ *
+ * Copyright (C) 2014 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/regulator/driver.h
+#include linux/mfd/rt5033.h
+#include linux/mfd/rt5033-private.h
+#include linux/regulator/of_regulator.h
+
+static struct regulator_ops rt5033_safe_ldo_ops = {
+   .is_enabled = regulator_is_enabled_regmap,
+   .enable = regulator_enable_regmap,
+   .disable= regulator_disable_regmap,
+   .list_voltage   = regulator_list_voltage_linear,
+};
+
+static struct regulator_ops rt5033_buck_ops = {
+   .is_enabled = regulator_is_enabled_regmap,
+   .enable = regulator_enable_regmap,
+   .disable= regulator_disable_regmap,
+   .list_voltage   = regulator_list_voltage_linear,
+   .map_voltage= regulator_map_voltage_linear,
+   .get_voltage_sel= regulator_get_voltage_sel_regmap,
+   .set_voltage_sel= regulator_set_voltage_sel_regmap,
+};
+
+static const struct regulator_desc rt5033_supported_regulators[] = {
+   [RT5033_BUCK] = {
+   .name   = BUCK,
+   .id = RT5033_BUCK,
+   .ops= rt5033_buck_ops,
+   .type   = REGULATOR_VOLTAGE,
+   .owner  = THIS_MODULE,
+   .n_voltages = RT5033_REGULATOR_BUCK_VOLTAGE_STEP_NUM,
+   .min_uV = RT5033_REGULATOR_BUCK_VOLTAGE_MIN,
+   .uV_step= RT5033_REGULATOR_BUCK_VOLTAGE_STEP,
+   .enable_reg = RT5033_REG_CTRL,
+   .enable_mask= RT5033_CTRL_EN_BUCK_MASK,
+   .vsel_reg   = RT5033_REG_BUCK_CTRL,
+   .vsel_mask  = RT5033_BUCK_CTRL_MASK,
+   },
+   [RT5033_LDO] = {
+   .name   = LDO,
+   .id = RT5033_LDO,
+   .ops= rt5033_buck_ops,
+   .type   = REGULATOR_VOLTAGE,
+   .owner  = THIS_MODULE,
+   .n_voltages = RT5033_REGULATOR_LDO_VOLTAGE_STEP_NUM,
+   .min_uV = RT5033_REGULATOR_LDO_VOLTAGE_MIN,
+   .uV_step

[PATCH v3 3/5] power: rt5033_battery: Add RT5033 Fuel gauge device driver

2014-11-12 Thread Beomho Seo
This patch adds device driver of Richtek PMIC.
The driver support battery fuel gange. Fuel gauge calculates and determines the
battery state of charge(SOC) according to battery open circuit voltage(OCV).
Also, this driver provides battery average voltage, voltage and bettery present
property.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v3:
- Add author information the top of driver.

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Fix wrong register name.
---
 drivers/power/Kconfig  |8 ++
 drivers/power/Makefile |1 +
 drivers/power/rt5033_battery.c |  177 
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/power/rt5033_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 0108c2a..da6981f 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -397,6 +397,14 @@ config BATTERY_GOLDFISH
  Say Y to enable support for the battery and AC power in the
  Goldfish emulator.
 
+config BATTERY_RT5033
+   tristate RT5033 fuel gauge support
+   depends on MFD_RT5033
+   help
+ This adds support for battery fuel gauge in Richtek RT5033 PMIC.
+ The fuelgauge calculates and determines the battery state of charge
+ according to battery open circuit voltage.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index dfa8942..b83a0c7 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9052)  += da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042) += max17042_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
 obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c
new file mode 100644
index 000..7b898f4
--- /dev/null
+++ b/drivers/power/rt5033_battery.c
@@ -0,0 +1,177 @@
+/*
+ * Fuel gauge driver for Richtek RT5033
+ *
+ * Copyright (C) 2014 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_battery_get_capacity(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 msb;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_SOC_H, msb);
+
+   return msb;
+}
+
+static int rt5033_battery_get_present(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 val;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_CONFIG_L, val);
+
+   return (val  RT5033_FUEL_BAT_PRESENT) ? true : false;
+}
+
+static int rt5033_battery_get_watt_prop(struct i2c_client *client,
+   enum power_supply_property psp)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   unsigned int regh, regl;
+   int ret;
+   u32 msb, lsb;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   regh = RT5033_FUEL_REG_VBAT_H;
+   regl = RT5033_FUEL_REG_VBAT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   regh = RT5033_FUEL_REG_AVG_VOLT_H;
+   regl = RT5033_FUEL_REG_AVG_VOLT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   regh = RT5033_FUEL_REG_OCV_H;
+   regl = RT5033_FUEL_REG_OCV_L;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   regmap_read(battery-regmap, regh, msb);
+   regmap_read(battery-regmap, regl, lsb);
+
+   ret = ((msb  4) + (lsb  4)) * 1250 / 1000;
+
+   return ret;
+}
+
+static int rt5033_battery_get_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   union power_supply_propval *val)
+{
+   struct rt5033_battery *battery = container_of(psy,
+   struct rt5033_battery, psy);
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   val-intval = rt5033_battery_get_watt_prop(battery-client

[PATCH v3 5/5] Documentation: Add documentation for rt5033 multifunction device

2014-11-12 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v3:
- none.

Changes in v2:
- Revise binding documentation.
---
 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..52a6d33
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,108 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators usinge the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   i2c_fuel: i2c@1 {
+   compatible = i2c-gpio;
+   standard i2c-gpio constraints...
+   fuelgauge {
+   compatible = richtek,rt5033-battery.
+   };
+   };
+
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+   };
+
+   i2c_fuel: i2c@10 {
+   compatible = i2c-gpio;
+   gpios = gpm3 1 0
+   gpm3 0 0;
+
+   fuel: rt5033-battery@35 {
+   compatible = richtek,rt5033-battery

Re: [PATCH v2 2/5] regulator: rt5033: Add RT5033 Regulator device driver

2014-11-11 Thread Beomho Seo
Sorry, I will include your e-mail address next revision all patch-set.

On 11/11/2014 04:04 AM, Mark Brown wrote:
 On Mon, Nov 10, 2014 at 04:19:44PM +0900, Beomho Seo wrote:
 This patch add device driver of Richtek RT5033 PMIC.
 The driver support multiple regulator like LDO and synchronous Buck.
 The integrated synchronous buck converter is designed to provide 0.6 A
 application with high efficiency. Two LDOs are integrated. One safe LDO is
 for 60mA and the other one LDO is for 150 mA.
 
 I'm missing all the other patches in this series...
 

Regards,
Beomho Seo

--
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 v2 1/5] mfd: rt5033: Add Richtek RT5033 driver core.

2014-11-10 Thread Beomho Seo
Thank you for your review.

On 11/10/2014 09:39 PM, Lee Jones wrote:
 On Mon, 10 Nov 2014, Beomho Seo wrote:
 
 This patch adds a new driver for Richtek RT5033 driver.
 RT5033 is a Multifunction device which includes battery charger, fuel gauge,
 flash LED current source, LDO and synchronous Buck converter. It is 
 interfaced
 to host controller using I2C interface.

 Cc: Samuel Ortiz sa...@linux.intel.com
 Cc: Lee Jones lee.j...@linaro.org
 Signed-off-by: Beomho Seo beomho@samsung.com
 Acked-by: Chanwoo Choi cw00.c...@samsung.com
 ---
 Changes in v2
 - Remove volatile_reg callback. Because this driver not in use regmap cache.
 - Revmoe unnecessary subnode of_compatible.
 - Add define for set_high impedance mode of charger.
 ---

  drivers/mfd/Kconfig|   11 ++
  drivers/mfd/Makefile   |1 +
  drivers/mfd/rt5033.c   |  142 
  include/linux/mfd/rt5033-private.h |  260 
 
  include/linux/mfd/rt5033.h |   64 +
  5 files changed, 478 insertions(+)
  create mode 100644 drivers/mfd/rt5033.c
  create mode 100644 include/linux/mfd/rt5033-private.h
  create mode 100644 include/linux/mfd/rt5033.h

 diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
 index cbdb109..6800068 100644
 --- a/drivers/mfd/Kconfig
 +++ b/drivers/mfd/Kconfig
 @@ -607,6 +607,17 @@ config MFD_RTSX_PCI
types of memory cards, such as Memory Stick, Memory Stick Pro,
Secure Digital and MultiMediaCard.
  
 +config MFD_RT5033
 +bool Richtek RT5033 Power Management IC
 +depends on I2C=y
 +select MFD_CORE
 +select REGMAP_I2C
 +help
 +  This support for Richtek RT5033 Power Management IC. This includes
 
 s/This /This driver provides/
 
 s/for /for the
 
 s/. This/, which
 

Ok, I will revise above sentence.

 +  the I2C driver and the Core APIs. This driver provides common support
 +  for accessing the device. The device supports multiple sub-devices
 +  like charger, fuel gauge, flash LED, current source, LDO and Buck.
 +
  config MFD_RTSX_USB
  tristate Realtek USB card reader
  depends on USB
 diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
 index 8e679d6..94e0f1c 100644
 --- a/drivers/mfd/Makefile
 +++ b/drivers/mfd/Makefile
 @@ -175,6 +175,7 @@ obj-$(CONFIG_MFD_STW481X)+= stw481x.o
  obj-$(CONFIG_MFD_IPAQ_MICRO)+= ipaq-micro.o
  obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o
  obj-$(CONFIG_MFD_HI6421_PMIC)   += hi6421-pmic-core.o
 +obj-$(CONFIG_MFD_RT5033)+= rt5033.o
  
  intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o
  obj-$(CONFIG_INTEL_SOC_PMIC)+= intel-soc-pmic.o
 diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
 new file mode 100644
 index 000..8f5aee0
 --- /dev/null
 +++ b/drivers/mfd/rt5033.c
 @@ -0,0 +1,142 @@
 +/*
 + * MFD core driver for the Richtek RT5033.
 + *
 + * Copyright (C) 2014 Samsung Electronics, Co., Ltd.
 + * Beomho Seo beomho@samsung.com
 
 Babysitter, butcher, pool cleaner or author?
 

OK, I will add author.

 + * 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/err.h
 +#include linux/module.h
 +#include linux/interrupt.h
 +#include linux/of_device.h
 +#include linux/mfd/core.h
 +#include linux/mfd/rt5033.h
 +#include linux/mfd/rt5033-private.h
 +
 +static const struct regmap_irq rt5033_irqs[] = {
 +{ .mask = RT5033_PMIC_IRQ_BUCKOCP, },
 +{ .mask = RT5033_PMIC_IRQ_BUCKLV, },
 +{ .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
 +{ .mask = RT5033_PMIC_IRQ_LDOLV, },
 +{ .mask = RT5033_PMIC_IRQ_OT, },
 +{ .mask = RT5033_PMIC_IRQ_VDDA_UV, },
 +};
 +
 +static const struct regmap_irq_chip rt5033_irq_chip = {
 +.name   = rt5033,
 +.status_base= RT5033_REG_PMIC_IRQ_STAT,
 +.mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
 +.mask_invert= true,
 +.num_regs   = 1,
 +.irqs   = rt5033_irqs,
 +.num_irqs   = ARRAY_SIZE(rt5033_irqs),
 +};
 +
 +static const struct mfd_cell rt5033_devs[] = {
 +{
 +.name = rt5033-regulator,
 +}, {
 +.name = rt5033-charger,
 +.of_compatible = richtek,rt5033-charger,
 +}, {
 +.name = rt5033-battery,
 +.of_compatible = richtek,rt5033-battery,
 +},
 +};
 +
 +static const struct of_device_id rt5033_dt_match[] = {
 +{ .compatible = richtek,rt5033, },
 +{ }
 +};
 +
 +static const struct regmap_config rt5033_regmap_config = {
 +.reg_bits   = 8,
 +.val_bits   = 8,
 +.max_register   = RT5033_REG_END,
 +};
 +
 +static int rt5033_i2c_probe(struct i2c_client *i2c,
 +const struct i2c_device_id *id)
 +{
 +struct rt5033_dev *rt5033;
 +unsigned int data;
 +int ret = 0;
 
 No need to pre-initialise

Re: [PATCH 5/5] Documentation: Add documentation for rt5033 multifunction device

2014-11-09 Thread Beomho Seo
Thank you for your advice.
I'll fix them and send v2 patch soon.

On 11/07/2014 07:34 PM, Mark Brown wrote:
 On Fri, Nov 07, 2014 at 11:52:07AM +0900, Beomho Seo wrote:
 
 +Required properties:
 +- compatible = Must be richtek,rt5033-regulator
 +
 +regulators {
 +compatible = richtek,rt5033-regulator;
 
 There should be no need for this extra compatible, it's not adding
 anything we didn't know from the fact that it's part of the MFD.
 
 +regulator-name {
 +regulator-name = LDO/BUCK
 +standard regulator constraints...
 +};
 
 Better to just say something like regulator subnodes called X, Y and Z
 described using the standard regulator binding in...
 

Best regards,
Beomho Seo
--
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 v2 5/5] Documentation: Add documentation for rt5033 multifunction device

2014-11-09 Thread Beomho Seo
This patch device tree binding documentation for rt5033 multifunction device.

Cc: Rob Herring robh...@kernel.org
Cc: Pawel Moll pawel.m...@arm.com
Cc: Mark Rutland mark.rutl...@arm.com
Cc: Ian campbell ijc+devicet...@hellion.org.uk
Cc: Kumar Gala ga...@codeaurora.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v2:
- Revise binding documentation.
---
 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 2 files changed, 109 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt

diff --git a/Documentation/devicetree/bindings/mfd/rt5033.txt 
b/Documentation/devicetree/bindings/mfd/rt5033.txt
new file mode 100644
index 000..52a6d33
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/rt5033.txt
@@ -0,0 +1,108 @@
+Richtek RT5033 Power management Integrated Circuit
+
+RT5033 is a Multifunction device which includes battery charger, fuel gauge,
+flash LED current source, LDO and synchronous Buck converter for portable
+applications. It is interfaced to host controller using i2c interface.
+
+Required properties:
+- compatible : Must be richtek,rt5033
+- reg : Specifies the i2c slave address of general part.
+- interrupts : This i2c devices has an IRQ line connected to the main SoC.
+- interrupt-parent : The parent interrupt controller.
+
+Optional node:
+Regulators: The regulators of RT5033 have to be instantiated under sub-node
+named regulators usinge the following format.
+
+   regulators {
+   regulator-name {
+   regulator-name = LDO/BUCK
+   regulator subnodes called X, Y and Z
+   };
+   };
+   refer Documentation/devicetree/bindings/regulator/regulator.txt
+
+
+Battery charger: There battery charger of RT5033 have to be instantiated under
+sub-node named charger using the following format.
+
+Required properties:
+- compatible : Must be richtek,rt5033-charger.
+- richtek,pre-uamp : Current of pre-charge mode. The pre-charge current levels
+  are 350 mA to 650 mA programmed by I2C per 100 mA.
+- richtek,pre-threshold-uvolt : Voltage of threshold pre-charge mode. Battery
+  voltage is below pre-charge threshold voltage, the charger is in pre-charge
+  mode with pre-charge current. Its levels are 2.3 V  to 3.8 V programmed
+  by I2C per 0.1 V.
+- richtek,fast-uamp : Current of fast-charge mode. The fast-charge current
+  levels are 700 mA to 2000 mA programmed by I2C per 100 mA.
+- richtek,const-uvolt :  Battery regulation voltage of constant voltage mode.
+  This voltage level 3.65 V to 4.4 V bye I2C per 0.025 V.
+- richtek,eoc-uamp : This property is end of charge current. Its level 150 mA
+  to 200 mA.
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+
+Fuelgauge: There fuelgauge of RT5033 to be instantiated node named fuelgauge
+using the following format.
+
+Required properties:
+- compatible = Must be richtek,rt5033-battery.
+
+   i2c_fuel: i2c@1 {
+   compatible = i2c-gpio;
+   standard i2c-gpio constraints...
+   fuelgauge {
+   compatible = richtek,rt5033-battery.
+   };
+   };
+
+
+Example:
+
+   rt5033@34 {
+   compatible = richtek,rt5033;
+   reg = 0x34;
+   interrupt-parent = gpx1;
+   interrupts = 5 0;
+
+   regulators {
+   buck_reg: BUCK {
+   regulator-name = BUCK;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   };
+   };
+
+   charger {
+   compatible = richtek,rt5033-charger;
+   richtek,pre-uamp = 35;
+   richtek,pre-threshold-uvolt = 340;
+   richtek,fast-uamp = 200;
+   richtek,const-uvolt = 435;
+   richtek,eoc-uamp = 25;
+   };
+
+   };
+
+   i2c_fuel: i2c@10 {
+   compatible = i2c-gpio;
+   gpios = gpm3 1 0
+   gpm3 0 0;
+
+   fuel: rt5033-battery@35 {
+   compatible = richtek,rt5033-battery;
+   interrupt

[PATCH v2 2/5] regulator: rt5033: Add RT5033 Regulator device driver

2014-11-09 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC.
The driver support multiple regulator like LDO and synchronous Buck.
The integrated synchronous buck converter is designed to provide 0.6 A
application with high efficiency. Two LDOs are integrated. One safe LDO is
for 60mA and the other one LDO is for 150 mA.

Cc: Liam Girdwood lgirdw...@gmail.com
Cc: Mark Brown broo...@kernel.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v2:
- Remove unnecessary device specific code.
---
 drivers/regulator/Kconfig|8 +++
 drivers/regulator/Makefile   |1 +
 drivers/regulator/rt5033-regulator.c |  123 ++
 3 files changed, 132 insertions(+)
 create mode 100644 drivers/regulator/rt5033-regulator.c

diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 55d7b7b..8558e1b 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -521,6 +521,14 @@ config REGULATOR_RN5T618
help
  Say y here to support the regulators found on Ricoh RN5T618 PMIC.
 
+config REGULATOR_RT5033
+   tristate Richtek RT5033 Regulators
+   depends on MFD_RT5033
+   help
+ This adds support for voltage and current regulators in Richtek
+ RT5033 PMIC. The device supports multiple regulators like
+ current source, LDO and Buck.
+
 config REGULATOR_S2MPA01
tristate Samsung S2MPA01 voltage regulator
depends on MFD_SEC_CORE
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 1029ed3..1f28ebf 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
 obj-$(CONFIG_REGULATOR_RC5T583)  += rc5t583-regulator.o
 obj-$(CONFIG_REGULATOR_RK808)   += rk808-regulator.o
 obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o
+obj-$(CONFIG_REGULATOR_RT5033) += rt5033-regulator.o
 obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
 obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
 obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
diff --git a/drivers/regulator/rt5033-regulator.c 
b/drivers/regulator/rt5033-regulator.c
new file mode 100644
index 000..782ba2d
--- /dev/null
+++ b/drivers/regulator/rt5033-regulator.c
@@ -0,0 +1,123 @@
+/*
+ * Regulator driver for the Richtek RT5033
+ *
+ * Copyright (C) 2014 Samsung Electronics, Co., Ltd.
+ * 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/regulator/driver.h
+#include linux/mfd/rt5033.h
+#include linux/mfd/rt5033-private.h
+#include linux/regulator/of_regulator.h
+
+static struct regulator_ops rt5033_safe_ldo_ops = {
+   .is_enabled = regulator_is_enabled_regmap,
+   .enable = regulator_enable_regmap,
+   .disable= regulator_disable_regmap,
+   .list_voltage   = regulator_list_voltage_linear,
+};
+
+static struct regulator_ops rt5033_buck_ops = {
+   .is_enabled = regulator_is_enabled_regmap,
+   .enable = regulator_enable_regmap,
+   .disable= regulator_disable_regmap,
+   .list_voltage   = regulator_list_voltage_linear,
+   .map_voltage= regulator_map_voltage_linear,
+   .get_voltage_sel= regulator_get_voltage_sel_regmap,
+   .set_voltage_sel= regulator_set_voltage_sel_regmap,
+};
+
+static const struct regulator_desc rt5033_supported_regulators[] = {
+   [RT5033_BUCK] = {
+   .name   = BUCK,
+   .id = RT5033_BUCK,
+   .ops= rt5033_buck_ops,
+   .type   = REGULATOR_VOLTAGE,
+   .owner  = THIS_MODULE,
+   .n_voltages = RT5033_REGULATOR_BUCK_VOLTAGE_STEP_NUM,
+   .min_uV = RT5033_REGULATOR_BUCK_VOLTAGE_MIN,
+   .uV_step= RT5033_REGULATOR_BUCK_VOLTAGE_STEP,
+   .enable_reg = RT5033_REG_CTRL,
+   .enable_mask= RT5033_CTRL_EN_BUCK_MASK,
+   .vsel_reg   = RT5033_REG_BUCK_CTRL,
+   .vsel_mask  = RT5033_BUCK_CTRL_MASK,
+   },
+   [RT5033_LDO] = {
+   .name   = LDO,
+   .id = RT5033_LDO,
+   .ops= rt5033_buck_ops,
+   .type   = REGULATOR_VOLTAGE,
+   .owner  = THIS_MODULE,
+   .n_voltages = RT5033_REGULATOR_LDO_VOLTAGE_STEP_NUM,
+   .min_uV = RT5033_REGULATOR_LDO_VOLTAGE_MIN,
+   .uV_step= RT5033_REGULATOR_LDO_VOLTAGE_STEP,
+   .enable_reg = RT5033_REG_CTRL

[PATCH v2 3/5] power: rt5033_battery: Add RT5033 Fuel gauge device driver

2014-11-09 Thread Beomho Seo
This patch adds device driver of Richtek PMIC.
The driver support battery fuel gange. Fuel gauge calculates and determines the
battery state of charge(SOC) according to battery open circuit voltage(OCV).
Also, this driver provides battery average voltage, voltage and bettery present
property.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Fix wrong register name.
---
 drivers/power/Kconfig  |8 ++
 drivers/power/Makefile |1 +
 drivers/power/rt5033_battery.c |  177 
 3 files changed, 186 insertions(+)
 create mode 100644 drivers/power/rt5033_battery.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 0108c2a..da6981f 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -397,6 +397,14 @@ config BATTERY_GOLDFISH
  Say Y to enable support for the battery and AC power in the
  Goldfish emulator.
 
+config BATTERY_RT5033
+   tristate RT5033 fuel gauge support
+   depends on MFD_RT5033
+   help
+ This adds support for battery fuel gauge in Richtek RT5033 PMIC.
+ The fuelgauge calculates and determines the battery state of charge
+ according to battery open circuit voltage.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index dfa8942..b83a0c7 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_BATTERY_DA9052)  += da9052-battery.o
 obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
 obj-$(CONFIG_BATTERY_MAX17042) += max17042_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
 obj-$(CONFIG_BATTERY_TWL4030_MADC) += twl4030_madc_battery.o
 obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c
new file mode 100644
index 000..70af2c3
--- /dev/null
+++ b/drivers/power/rt5033_battery.c
@@ -0,0 +1,177 @@
+/*
+ * Fuel gauge driver for Richtek RT5033
+ *
+ * Copyright (C) 2014 Samsung Electronics, Co., Ltd.
+ * 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_battery_get_capacity(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 msb;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_SOC_H, msb);
+
+   return msb;
+}
+
+static int rt5033_battery_get_present(struct i2c_client *client)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   u32 val;
+
+   regmap_read(battery-regmap, RT5033_FUEL_REG_CONFIG_L, val);
+
+   return (val  RT5033_FUEL_BAT_PRESENT) ? true : false;
+}
+
+static int rt5033_battery_get_watt_prop(struct i2c_client *client,
+   enum power_supply_property psp)
+{
+   struct rt5033_battery *battery = i2c_get_clientdata(client);
+   unsigned int regh, regl;
+   int ret;
+   u32 msb, lsb;
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   regh = RT5033_FUEL_REG_VBAT_H;
+   regl = RT5033_FUEL_REG_VBAT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   regh = RT5033_FUEL_REG_AVG_VOLT_H;
+   regl = RT5033_FUEL_REG_AVG_VOLT_L;
+   break;
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   regh = RT5033_FUEL_REG_OCV_H;
+   regl = RT5033_FUEL_REG_OCV_L;
+   break;
+   default:
+   return -EINVAL;
+   }
+
+   regmap_read(battery-regmap, regh, msb);
+   regmap_read(battery-regmap, regl, lsb);
+
+   ret = ((msb  4) + (lsb  4)) * 1250 / 1000;
+
+   return ret;
+}
+
+static int rt5033_battery_get_property(struct power_supply *psy,
+   enum power_supply_property psp,
+   union power_supply_propval *val)
+{
+   struct rt5033_battery *battery = container_of(psy,
+   struct rt5033_battery, psy);
+
+   switch (psp) {
+   case POWER_SUPPLY_PROP_VOLTAGE_NOW:
+   case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+   case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+   val-intval = rt5033_battery_get_watt_prop(battery-client,
+   psp

[PATCH v2 0/5] mfd: rt5033: Add Richtek RT5033 drivers

2014-11-09 Thread Beomho Seo
 This patchset adds driver for Richtek rt5033 chip The chip contains
switching charge mode Li-Ion/Li-Polymer battery charger, fuelgauge, regulators.
This patchset provides common support for accessing the device.
This patchset have been tested base on exynos board.

Changes in v2:
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Remove unnecessary subnode of_compatible.
- Add definde for set high impedance mode of charger.
- Remove unnecessary device specific code.
- Fix wrong register name.
- Fix wrong error message.
- Fix return vallue at error case.
- Revise binding documentation.

Beomho Seo (5):
  mfd: rt5033: Add Richtek RT5033 driver core.
  regulator: rt5033: Add RT5033 Regulator device driver
  power: rt5033_battery: Add RT5033 Fuel gauge device driver
  power: rt5033_charger: Add RT5033 charger device driver
  Documentation: Add documentation for rt5033 multifunction device

 Documentation/devicetree/bindings/mfd/rt5033.txt   |  108 +
 .../devicetree/bindings/vendor-prefixes.txt|1 +
 drivers/mfd/Kconfig|   11 +
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  156 +++
 drivers/power/Kconfig  |   16 +
 drivers/power/Makefile |2 +
 drivers/power/rt5033_battery.c |  177 +++
 drivers/power/rt5033_charger.c |  485 
 drivers/regulator/Kconfig  |8 +
 drivers/regulator/Makefile |1 +
 drivers/regulator/rt5033-regulator.c   |  123 +
 include/linux/mfd/rt5033-private.h |  260 +++
 include/linux/mfd/rt5033.h |   64 +++
 14 files changed, 1413 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/rt5033.txt
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 drivers/power/rt5033_battery.c
 create mode 100644 drivers/power/rt5033_charger.c
 create mode 100644 drivers/regulator/rt5033-regulator.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

-- 
1.7.9.5

--
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 v2 4/5] power: rt5033_charger: Add RT5033 charger device driver

2014-11-09 Thread Beomho Seo
This patch add device driver of Richtek RT5033 PMIC. The driver support
switching charger. rt5033 charger provide three charging mode.
Three charging mode are pre charge mode, fast cahrge mode and constant voltage
mode. They are have vary charge rate, charge parameters. The charge parameters
can be controlled by i2c interface.

Cc: Sebastian Reichel s...@kernel.org
Cc: Dmitry Eremin-Solenikov dbarysh...@gmail.com
Cc: David Woodhouse dw...@infradead.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v2:
- Fix wrong error message.
- Fix return value at error case. Because  charger-data null, probe function
return zero.
- Use define for set control register.
---
 drivers/power/Kconfig  |8 +
 drivers/power/Makefile |1 +
 drivers/power/rt5033_charger.c |  485 
 3 files changed, 494 insertions(+)
 create mode 100644 drivers/power/rt5033_charger.c

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index da6981f..629b101 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -405,6 +405,14 @@ config BATTERY_RT5033
  The fuelgauge calculates and determines the battery state of charge
  according to battery open circuit voltage.
 
+config CHARGER_RT5033
+   tristate RT5033 battery charger support
+   depends on MFD_RT5033
+   help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
 source drivers/power/reset/Kconfig
 
 endif # POWER_SUPPLY
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index b83a0c7..bb8cce3 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)  += bq24190_charger.o
 obj-$(CONFIG_CHARGER_BQ24735)  += bq24735-charger.o
 obj-$(CONFIG_POWER_AVS)+= avs/
+obj-$(CONFIG_POWER_RT5033) += rt5033_charger.o
 obj-$(CONFIG_CHARGER_SMB347)   += smb347-charger.o
 obj-$(CONFIG_CHARGER_TPS65090) += tps65090-charger.o
 obj-$(CONFIG_POWER_RESET)  += reset/
diff --git a/drivers/power/rt5033_charger.c b/drivers/power/rt5033_charger.c
new file mode 100644
index 000..f2a7233
--- /dev/null
+++ b/drivers/power/rt5033_charger.c
@@ -0,0 +1,485 @@
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 Samsung Electronics, Co., Ltd.
+ * 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/rt5033-private.h
+#include linux/mfd/rt5033.h
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_STATUS_UNKNOWN;
+   u32 reg_data;
+
+   if (!regmap)
+   return state;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_MASK) {
+   case RT5033_CHG_STAT_DISCHARGING:
+   state = POWER_SUPPLY_STATUS_DISCHARGING;
+   break;
+   case RT5033_CHG_STAT_CHARGING:
+   state = POWER_SUPPLY_STATUS_CHARGING;
+   break;
+   case RT5033_CHG_STAT_FULL:
+   state = POWER_SUPPLY_STATUS_FULL;
+   break;
+   case RT5033_CHG_STAT_NOT_CHARGING:
+   state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   int state = POWER_SUPPLY_CHARGE_TYPE_UNKNOWN;
+   u32 reg_data;
+
+   regmap_read(regmap, RT5033_REG_CHG_STAT, reg_data);
+
+   switch (reg_data  RT5033_CHG_STAT_TYPE_MASK) {
+   case RT5033_CHG_STAT_TYPE_FAST:
+   state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+   break;
+   case RT5033_CHG_STAT_TYPE_PRE:
+   state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+   break;
+   }
+
+   return state;
+}
+
+static int rt5033_get_charger_current(struct rt5033_charger *charger,
+   enum power_supply_property psp)
+{
+   struct regmap *regmap = charger-rt5033-regmap;
+   unsigned int state, reg_data, data;
+
+   if (psp == POWER_SUPPLY_PROP_CURRENT_MAX)
+   return RT5033_CHG_MAX_CURRENT;
+
+   regmap_read(regmap, RT5033_REG_CHG_CTRL5, reg_data);
+
+   state = (reg_data  RT5033_CHGCTRL5_ICHG_SHIFT)  0xf;
+
+   if (state  RT5033_CHG_MAX_CURRENT)
+   state = RT5033_CHG_MAX_CURRENT;
+
+   data = state * 100 + 700;
+
+   return data;
+}
+
+static int

[PATCH v2 1/5] mfd: rt5033: Add Richtek RT5033 driver core.

2014-11-09 Thread Beomho Seo
This patch adds a new driver for Richtek RT5033 driver.
RT5033 is a Multifunction device which includes battery charger, fuel gauge,
flash LED current source, LDO and synchronous Buck converter. It is interfaced
to host controller using I2C interface.

Cc: Samuel Ortiz sa...@linux.intel.com
Cc: Lee Jones lee.j...@linaro.org
Signed-off-by: Beomho Seo beomho@samsung.com
Acked-by: Chanwoo Choi cw00.c...@samsung.com
---
Changes in v2
- Remove volatile_reg callback. Because this driver not in use regmap cache.
- Revmoe unnecessary subnode of_compatible.
- Add define for set_high impedance mode of charger.
---

 drivers/mfd/Kconfig|   11 ++
 drivers/mfd/Makefile   |1 +
 drivers/mfd/rt5033.c   |  142 
 include/linux/mfd/rt5033-private.h |  260 
 include/linux/mfd/rt5033.h |   64 +
 5 files changed, 478 insertions(+)
 create mode 100644 drivers/mfd/rt5033.c
 create mode 100644 include/linux/mfd/rt5033-private.h
 create mode 100644 include/linux/mfd/rt5033.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index cbdb109..6800068 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -607,6 +607,17 @@ config MFD_RTSX_PCI
  types of memory cards, such as Memory Stick, Memory Stick Pro,
  Secure Digital and MultiMediaCard.
 
+config MFD_RT5033
+   bool Richtek RT5033 Power Management IC
+   depends on I2C=y
+   select MFD_CORE
+   select REGMAP_I2C
+   help
+ This support for Richtek RT5033 Power Management IC. This includes
+ the I2C driver and the Core APIs. This driver provides common support
+ for accessing the device. The device supports multiple sub-devices
+ like charger, fuel gauge, flash LED, current source, LDO and Buck.
+
 config MFD_RTSX_USB
tristate Realtek USB card reader
depends on USB
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8e679d6..94e0f1c 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -175,6 +175,7 @@ obj-$(CONFIG_MFD_STW481X)   += stw481x.o
 obj-$(CONFIG_MFD_IPAQ_MICRO)   += ipaq-micro.o
 obj-$(CONFIG_MFD_MENF21BMC)+= menf21bmc.o
 obj-$(CONFIG_MFD_HI6421_PMIC)  += hi6421-pmic-core.o
+obj-$(CONFIG_MFD_RT5033)   += rt5033.o
 
 intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
new file mode 100644
index 000..8f5aee0
--- /dev/null
+++ b/drivers/mfd/rt5033.c
@@ -0,0 +1,142 @@
+/*
+ * MFD core driver for the Richtek RT5033.
+ *
+ * Copyright (C) 2014 Samsung Electronics, Co., Ltd.
+ * 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/err.h
+#include linux/module.h
+#include linux/interrupt.h
+#include linux/of_device.h
+#include linux/mfd/core.h
+#include linux/mfd/rt5033.h
+#include linux/mfd/rt5033-private.h
+
+static const struct regmap_irq rt5033_irqs[] = {
+   { .mask = RT5033_PMIC_IRQ_BUCKOCP, },
+   { .mask = RT5033_PMIC_IRQ_BUCKLV, },
+   { .mask = RT5033_PMIC_IRQ_SAFELDOLV, },
+   { .mask = RT5033_PMIC_IRQ_LDOLV, },
+   { .mask = RT5033_PMIC_IRQ_OT, },
+   { .mask = RT5033_PMIC_IRQ_VDDA_UV, },
+};
+
+static const struct regmap_irq_chip rt5033_irq_chip = {
+   .name   = rt5033,
+   .status_base= RT5033_REG_PMIC_IRQ_STAT,
+   .mask_base  = RT5033_REG_PMIC_IRQ_CTRL,
+   .mask_invert= true,
+   .num_regs   = 1,
+   .irqs   = rt5033_irqs,
+   .num_irqs   = ARRAY_SIZE(rt5033_irqs),
+};
+
+static const struct mfd_cell rt5033_devs[] = {
+   {
+   .name = rt5033-regulator,
+   }, {
+   .name = rt5033-charger,
+   .of_compatible = richtek,rt5033-charger,
+   }, {
+   .name = rt5033-battery,
+   .of_compatible = richtek,rt5033-battery,
+   },
+};
+
+static const struct of_device_id rt5033_dt_match[] = {
+   { .compatible = richtek,rt5033, },
+   { }
+};
+
+static const struct regmap_config rt5033_regmap_config = {
+   .reg_bits   = 8,
+   .val_bits   = 8,
+   .max_register   = RT5033_REG_END,
+};
+
+static int rt5033_i2c_probe(struct i2c_client *i2c,
+   const struct i2c_device_id *id)
+{
+   struct rt5033_dev *rt5033;
+   unsigned int data;
+   int ret = 0;
+
+   rt5033 = devm_kzalloc(i2c-dev, sizeof(*rt5033), GFP_KERNEL);
+   if (!rt5033)
+   return -ENOMEM;
+
+   i2c_set_clientdata(i2c, rt5033);
+   rt5033-dev = i2c-dev;
+   rt5033-i2c = i2c;
+   rt5033-irq = i2c-irq;
+   rt5033-wakeup = 1;
+
+   rt5033-regmap = devm_regmap_init_i2c(i2c

  1   2   >