Re: [PATCH 4/4] power: smb347-charger: Summit SMB345 charger IC

2016-09-16 Thread Rob Herring
On Wed, Sep 07, 2016 at 03:50:13PM +0530, Vinay Simha BN wrote:
> Summit microelectronics SMB345 charger chip added.
> 
> Cc: Jonghwa Lee 
> Cc: Chanwoo Choi 
> Cc: Myungjoo Ham 
> Cc: Sumit Semwal 
> Cc: John Stultz 
> Signed-off-by: Vinay Simha BN 
> ---
>  .../bindings/power/supply/smb347_charger.txt   |  21 +++-

The binding should be combined with the previous patch.

>  drivers/power/supply/smb347-charger.c  | 123 
> ++---
>  2 files changed, 81 insertions(+), 63 deletions(-)
> 


Re: [PATCH 4/4] power: smb347-charger: Summit SMB345 charger IC

2016-09-16 Thread Rob Herring
On Wed, Sep 07, 2016 at 03:50:13PM +0530, Vinay Simha BN wrote:
> Summit microelectronics SMB345 charger chip added.
> 
> Cc: Jonghwa Lee 
> Cc: Chanwoo Choi 
> Cc: Myungjoo Ham 
> Cc: Sumit Semwal 
> Cc: John Stultz 
> Signed-off-by: Vinay Simha BN 
> ---
>  .../bindings/power/supply/smb347_charger.txt   |  21 +++-

The binding should be combined with the previous patch.

>  drivers/power/supply/smb347-charger.c  | 123 
> ++---
>  2 files changed, 81 insertions(+), 63 deletions(-)
> 


[PATCH 4/4] power: smb347-charger: Summit SMB345 charger IC

2016-09-07 Thread Vinay Simha BN
Summit microelectronics SMB345 charger chip added.

Cc: Jonghwa Lee 
Cc: Chanwoo Choi 
Cc: Myungjoo Ham 
Cc: Sumit Semwal 
Cc: John Stultz 
Signed-off-by: Vinay Simha BN 
---
 .../bindings/power/supply/smb347_charger.txt   |  21 +++-
 drivers/power/supply/smb347-charger.c  | 123 ++---
 2 files changed, 81 insertions(+), 63 deletions(-)

diff --git a/Documentation/devicetree/bindings/power/supply/smb347_charger.txt 
b/Documentation/devicetree/bindings/power/supply/smb347_charger.txt
index 91570a5..939a86d 100644
--- a/Documentation/devicetree/bindings/power/supply/smb347_charger.txt
+++ b/Documentation/devicetree/bindings/power/supply/smb347_charger.txt
@@ -2,7 +2,8 @@ smb347_charger bindings
 
 
 [Required porperties]
-- compatible : "summit,smb347"
+- compatible : "summit,smb345"
+  "summit,smb347"
 - reg : Slave address for i2c interface
 # At least one of followings should be set
   - enable-usb-charging
@@ -39,6 +40,24 @@ smb347_charger bindings
<2> : Voltage compensation
 
 Example:
+   smb345@6a {
+   compatible = "summit,smb345";
+   reg = <0x6a>;
+   status = "okay";
+   interrupt-parent = <_pinmux>;
+   interrupts = <23 IRQ_TYPE_EDGE_BOTH>;
+
+   max-chg-curr = <180>;
+   usb-curr-limit = <45>;
+
+   chip-temp-thershold = <110>;
+
+   enable-usb-charging;
+   enable-otg-charging;
+
+   enable-chg-ctrl = <0>;  /* SW (i2c interface) */
+   };
+
smb347@7f {
compatible = "summit,smb347";
reg = <0x7f>;
diff --git a/drivers/power/supply/smb347-charger.c 
b/drivers/power/supply/smb347-charger.c
index 472f5e2..c1a9b73 100644
--- a/drivers/power/supply/smb347-charger.c
+++ b/drivers/power/supply/smb347-charger.c
@@ -124,6 +124,7 @@
 
 /**
  * struct smb347_charger - smb347 charger instance
+ * @id: smb charger id
  * @lock: protects concurrent access to online variables
  * @dev: pointer to device
  * @regmap: pointer to driver regmap
@@ -136,6 +137,7 @@
  * @pdata: pointer to platform data
  */
 struct smb347_charger {
+   int id;
struct mutexlock; /* protects concurrent access */
struct device   *dev;
struct regmap   *regmap;
@@ -148,58 +150,46 @@ struct smb347_charger {
const struct smb347_charger_platform_data *pdata;
 };
 
+enum smb_charger_chipid {
+   SMB345,
+   SMB347,
+   NUM_CHIP_TYPES,
+};
+
 /* Fast charge current in uA */
-static const unsigned int fcc_tbl[] = {
-   70,
-   90,
-   120,
-   150,
-   180,
-   200,
-   220,
-   250,
+static const unsigned int fcc_tbl[NUM_CHIP_TYPES][8] = {
+   [SMB345] = { 20, 45, 60, 90,
+   130, 150, 180, 200 },
+   [SMB347] = { 70, 90, 120, 150,
+   180, 200, 220, 250 },
 };
 
 /* Pre-charge current in uA */
-static const unsigned int pcc_tbl[] = {
-   10,
-   15,
-   20,
-   25,
+static const unsigned int pcc_tbl[NUM_CHIP_TYPES][4] = {
+   [SMB345] = { 15, 25, 35, 45 },
+   [SMB347] = { 10, 15, 20, 25 },
 };
 
 /* Termination current in uA */
-static const unsigned int tc_tbl[] = {
-   37500,
-   5,
-   10,
-   15,
-   20,
-   25,
-   50,
-   60,
+static const unsigned int tc_tbl[NUM_CHIP_TYPES][8] = {
+   [SMB345] = { 3, 4, 6, 8,
+   10, 125000, 15, 20 },
+   [SMB347] = { 37500, 5, 10, 15,
+   20, 25, 50, 60 },
 };
 
 /* Input current limit in uA */
-static const unsigned int icl_tbl[] = {
-   30,
-   50,
-   70,
-   90,
-   120,
-   150,
-   180,
-   200,
-   220,
-   250,
+static const unsigned int icl_tbl[NUM_CHIP_TYPES][10] = {
+   [SMB345] = { 30, 50, 70, 100, 150,
+   180, 200, 200, 200, 200 },
+   [SMB347] = { 30, 50, 70, 90, 120,
+   150, 180, 200, 220, 250 },
 };
 
 /* Charge current compensation in uA */
-static const unsigned int ccc_tbl[] = {
-   25,
-   70,
-   90,
-   120,
+static const unsigned int ccc_tbl[NUM_CHIP_TYPES][4] = {
+   [SMB345] = { 20, 45, 60, 90 },
+   [SMB347] = { 25, 70, 90, 120 },
 };
 
 /* Convert register value to current using lookup table 

[PATCH 4/4] power: smb347-charger: Summit SMB345 charger IC

2016-09-07 Thread Vinay Simha BN
Summit microelectronics SMB345 charger chip added.

Cc: Jonghwa Lee 
Cc: Chanwoo Choi 
Cc: Myungjoo Ham 
Cc: Sumit Semwal 
Cc: John Stultz 
Signed-off-by: Vinay Simha BN 
---
 .../bindings/power/supply/smb347_charger.txt   |  21 +++-
 drivers/power/supply/smb347-charger.c  | 123 ++---
 2 files changed, 81 insertions(+), 63 deletions(-)

diff --git a/Documentation/devicetree/bindings/power/supply/smb347_charger.txt 
b/Documentation/devicetree/bindings/power/supply/smb347_charger.txt
index 91570a5..939a86d 100644
--- a/Documentation/devicetree/bindings/power/supply/smb347_charger.txt
+++ b/Documentation/devicetree/bindings/power/supply/smb347_charger.txt
@@ -2,7 +2,8 @@ smb347_charger bindings
 
 
 [Required porperties]
-- compatible : "summit,smb347"
+- compatible : "summit,smb345"
+  "summit,smb347"
 - reg : Slave address for i2c interface
 # At least one of followings should be set
   - enable-usb-charging
@@ -39,6 +40,24 @@ smb347_charger bindings
<2> : Voltage compensation
 
 Example:
+   smb345@6a {
+   compatible = "summit,smb345";
+   reg = <0x6a>;
+   status = "okay";
+   interrupt-parent = <_pinmux>;
+   interrupts = <23 IRQ_TYPE_EDGE_BOTH>;
+
+   max-chg-curr = <180>;
+   usb-curr-limit = <45>;
+
+   chip-temp-thershold = <110>;
+
+   enable-usb-charging;
+   enable-otg-charging;
+
+   enable-chg-ctrl = <0>;  /* SW (i2c interface) */
+   };
+
smb347@7f {
compatible = "summit,smb347";
reg = <0x7f>;
diff --git a/drivers/power/supply/smb347-charger.c 
b/drivers/power/supply/smb347-charger.c
index 472f5e2..c1a9b73 100644
--- a/drivers/power/supply/smb347-charger.c
+++ b/drivers/power/supply/smb347-charger.c
@@ -124,6 +124,7 @@
 
 /**
  * struct smb347_charger - smb347 charger instance
+ * @id: smb charger id
  * @lock: protects concurrent access to online variables
  * @dev: pointer to device
  * @regmap: pointer to driver regmap
@@ -136,6 +137,7 @@
  * @pdata: pointer to platform data
  */
 struct smb347_charger {
+   int id;
struct mutexlock; /* protects concurrent access */
struct device   *dev;
struct regmap   *regmap;
@@ -148,58 +150,46 @@ struct smb347_charger {
const struct smb347_charger_platform_data *pdata;
 };
 
+enum smb_charger_chipid {
+   SMB345,
+   SMB347,
+   NUM_CHIP_TYPES,
+};
+
 /* Fast charge current in uA */
-static const unsigned int fcc_tbl[] = {
-   70,
-   90,
-   120,
-   150,
-   180,
-   200,
-   220,
-   250,
+static const unsigned int fcc_tbl[NUM_CHIP_TYPES][8] = {
+   [SMB345] = { 20, 45, 60, 90,
+   130, 150, 180, 200 },
+   [SMB347] = { 70, 90, 120, 150,
+   180, 200, 220, 250 },
 };
 
 /* Pre-charge current in uA */
-static const unsigned int pcc_tbl[] = {
-   10,
-   15,
-   20,
-   25,
+static const unsigned int pcc_tbl[NUM_CHIP_TYPES][4] = {
+   [SMB345] = { 15, 25, 35, 45 },
+   [SMB347] = { 10, 15, 20, 25 },
 };
 
 /* Termination current in uA */
-static const unsigned int tc_tbl[] = {
-   37500,
-   5,
-   10,
-   15,
-   20,
-   25,
-   50,
-   60,
+static const unsigned int tc_tbl[NUM_CHIP_TYPES][8] = {
+   [SMB345] = { 3, 4, 6, 8,
+   10, 125000, 15, 20 },
+   [SMB347] = { 37500, 5, 10, 15,
+   20, 25, 50, 60 },
 };
 
 /* Input current limit in uA */
-static const unsigned int icl_tbl[] = {
-   30,
-   50,
-   70,
-   90,
-   120,
-   150,
-   180,
-   200,
-   220,
-   250,
+static const unsigned int icl_tbl[NUM_CHIP_TYPES][10] = {
+   [SMB345] = { 30, 50, 70, 100, 150,
+   180, 200, 200, 200, 200 },
+   [SMB347] = { 30, 50, 70, 90, 120,
+   150, 180, 200, 220, 250 },
 };
 
 /* Charge current compensation in uA */
-static const unsigned int ccc_tbl[] = {
-   25,
-   70,
-   90,
-   120,
+static const unsigned int ccc_tbl[NUM_CHIP_TYPES][4] = {
+   [SMB345] = { 20, 45, 60, 90 },
+   [SMB347] = { 25, 70, 90, 120 },
 };
 
 /* Convert register value to current using lookup table */
@@ -354,10 +344,10 @@ static int smb347_start_stop_charging(struct 
smb347_charger *smb)
 
 static int smb347_set_charge_current(struct