power: max77660-charger: update max77660 register values
Venkat Reddy [Fri, 7 Jun 2013 14:00:01 +0000 (19:00 +0530)]
AS DUT draws only 250mA when nvcharger is connected and 190mA when usb
connected , updating the register values to draw more current

bug 1284514
Change-Id: Ie4e460a0b48bab089520c1061ecc741975bd9140
Signed-off-by: Venkat Reddy <vreddytalla@nvidia.com>
Reviewed-on: http://git-master/r/237893
(Cherrypicked commit 32bf875c86b7abd1f721243b095d755c7e2911cf)
Reviewed-on: http://git-master/r/241971
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Tested-by: Laxman Dewangan <ldewangan@nvidia.com>

drivers/power/max77660-charger-extcon.c
include/linux/mfd/max77660/max77660-core.h

index 3112ceb..c22906d 100644 (file)
@@ -135,12 +135,9 @@ static int max77660_charger_init(struct max77660_chg_extcon *chip, int enable)
        charger->in_current_lim = fchg_current(charger->in_current_lim);
 
        /* unlock charger protection */
-       reg_val = MAX77660_CHGPROT_UNLOCKED<<MAX77660_CHGPROT_SHIFT;
        ret = max77660_reg_write(chip->parent, MAX77660_CHG_SLAVE,
                MAX77660_CHARGER_CHGCTRL1,
-               MAX77660_CHARGER_CHGPROT_MASK |
-               MAX77660_CHARGER_BUCK_EN_MASK |
-               MAX77660_CHARGER_JEITA_EN_MASK);
+               MAX77660_CHGCC_MASK);
        if (ret < 0)
                return ret;
 
@@ -150,16 +147,14 @@ static int max77660_charger_init(struct max77660_chg_extcon *chip, int enable)
                ret = max77660_reg_write(chip->parent,
                                MAX77660_CHG_SLAVE,
                                MAX77660_CHARGER_DCCRNT,
-                               MAX77660_DCLIMIT_1A |
-                               MAX77660_DC_WC_CNTL_DC);
+                               MAX77660_DCILMT_CNTL);
                if (ret < 0)
                        return ret;
 
                /* Fast charge to 5 hours, fast charge current to 1.1A */
-               ret = max77660_reg_update(chip->parent,
+               ret = max77660_reg_write(chip->parent,
                                MAX77660_CHG_SLAVE, MAX77660_CHARGER_FCHGCRNT,
-                               chip->charger->in_current_lim,
-                               MAX77660_CHGCC_MASK);
+                               MAX77660_FCHG_CRNT);
                if (ret < 0)
                        return ret;
 
@@ -198,13 +193,35 @@ static int max77660_charger_init(struct max77660_chg_extcon *chip, int enable)
                                MAX77660_CHARGER_CHGCTRL2,
                                MAX77660_VSYSREG_3600MV |
                                MAX77660_CEN_MASK |
-                               MAX77660_PREQ_CUR_MASK |
+                               MAX77660_PREQ_CURNT |
                                MAX77660_DCILIM_EN_MASK);
                if (ret < 0)
                        return ret;
+
+               /* Enable register settings for charging*/
+               ret = max77660_reg_write(chip->parent,
+                               MAX77660_CHG_SLAVE,
+                               MAX77660_CHARGER_CHGCCMAX,
+                               MAX77660_CHGCCMAX_CRNT);
+
+               if (ret < 0)
+                       return ret;
+
                /* Enable top level charging */
-               ret = max77660_reg_set_bits(chip->parent, MAX77660_PWR_SLAVE,
-                       MAX77660_REG_GLOBAL_CFG1, MAX77660_GLBLCNFG1_ENCHGTL);
+               ret = max77660_reg_write(chip->parent, MAX77660_PWR_SLAVE,
+                               MAX77660_REG_GLOBAL_CFG1,
+                               MAX77660_GLBLCNFG1_MASK);
+               if (ret < 0)
+                       return ret;
+               ret = max77660_reg_write(chip->parent, MAX77660_PWR_SLAVE,
+                               MAX77660_REG_GLOBAL_CFG4,
+                               MAX77660_GLBLCNFG4_WDTC_SYS_CLR);
+               if (ret < 0)
+                       return ret;
+
+               ret = max77660_reg_write(chip->parent, MAX77660_PWR_SLAVE,
+                               MAX77660_REG_GLOBAL_CFG6,
+                               MAX77660_GLBLCNFG6_MASK);
                if (ret < 0)
                        return ret;
 
index 5ceeff7..1e8d71b 100644 (file)
 #define MAX77660_GLBLCNFG1_SHDN_WRST           BIT(2)
 #define MAX77660_GLBLCNFG1_ENCHGTL             BIT(1)
 #define MAX77660_GLBLCNFG1_ENPGOC              BIT(0)
+#define MAX77660_GLBLCNFG1_MASK                        0x12
 
 /* GLBLCNFG2: Global Configuration Register 2 */
 #define MAX77660_GLBLCNFG2_TWD_CHG_MASK                0xC0
 #define GLBLCNFG5_TRSTO_MASK                   (BIT(0) | BIT(1))
 #define GLBLCNFG5_TRSTO_SHIFT                  0
 
+#define MAX77660_GLBLCNFG6_MASK                        0x1
 
 #define GLBLCNFG7_EN4_MASK_MASK                        BIT(2)
 #define GLBLCNFG7_EN4_MASK_SHIFT               2
 #define MAX77660_CHGCC_SHIFT                   0
 #define MAX77660_FCHGTIME_MASK                 0xE0
 #define MAX77660_FCHGTIME_SHIFT                        5
+#define MAX77660_FCHG_CRNT                     0x1C
 
 #define MAX77660_CHARGER_FCHGCRNT              0x65
 #define MAX77660_CHARGER_TOPOFF                        0x66
 #define MAX77660_CHGRSTRT_SHIFT                        6
 #define MAX77660_DCILMT_MASK                   0x3F
 #define MAX77660_DCILMT_SHIFT                  0
+#define MAX77660_DCILMT_CNTL                   0xB4
 
 #define MAX77660_CHARGER_AICLCNTL              0x69
 #define MAX77660_CHARGER_RBOOST                        0x6A
 #define MAX77660_PREQ_CUR_SHIFT                        5
 #define MAX77660_DCILIM_EN_MASK                        BIT(7)
 #define MAX77660_DCILIM_EN_SHIFT               7
+#define MAX77660_PREQ_CURNT                    BIT(5)
 
 #define MAX77660_CHARGER_BATDET                        0x6C
 #define MAX77660_CHARGER_CHGCCMAX              0x6D
 #define MAX77660_CHARGER_MBATREGMAX            0x6E
 
+#define MAX77660_CHGCCMAX_CRNT                 0x1F
 #define MAX77660_BATDET_DTLS                   0x03
 #define MAX77660_BATDET_DTLS_NO_BAT            0x03
 #define MAX77660_CHG_CHGINT_DC_UVP             BIT(4)