OSDN Git Service

Merge "qcom-charger: add support for WiPower"
authorLinux Build Service Account <lnxbuild@localhost>
Wed, 3 Aug 2016 11:58:30 +0000 (04:58 -0700)
committerGerrit - the friendly Code Review server <code-review@localhost>
Wed, 3 Aug 2016 11:58:29 +0000 (04:58 -0700)
1  2 
drivers/power/qcom-charger/qpnp-smb2.c
drivers/power/qcom-charger/smb-lib.c
drivers/power/qcom-charger/smb-lib.h

@@@ -892,32 -876,77 +892,102 @@@ int smblib_set_prop_input_suspend(struc
        return rc;
  }
  
 +int smblib_set_prop_system_temp_level(struct smb_charger *chg,
 +                              const union power_supply_propval *val)
 +{
 +      if (val->intval < 0)
 +              return -EINVAL;
 +
 +      if (chg->thermal_levels <= 0)
 +              return -EINVAL;
 +
 +      if (val->intval > chg->thermal_levels)
 +              return -EINVAL;
 +
 +      chg->system_temp_level = val->intval;
 +      if (chg->system_temp_level == chg->thermal_levels)
 +              return vote(chg->chg_disable_votable, THERMAL_DAEMON, true, 0);
 +
 +      vote(chg->chg_disable_votable, THERMAL_DAEMON, false, 0);
 +      if (chg->system_temp_level == 0)
 +              return vote(chg->fcc_votable, THERMAL_DAEMON, false, 0);
 +
 +      vote(chg->fcc_votable, THERMAL_DAEMON, true,
 +                      chg->thermal_mitigation[chg->system_temp_level]);
 +      return 0;
 +}
 +
  /*******************
+  * DC PSY GETTERS *
+  *******************/
+ int smblib_get_prop_dc_present(struct smb_charger *chg,
+                               union power_supply_propval *val)
+ {
+       int rc = 0;
+       u8 stat;
+       rc = smblib_read(chg, DC_INT_RT_STS_REG, &stat);
+       if (rc < 0) {
+               dev_err(chg->dev, "Couldn't read DC_INT_RT_STS_REG rc=%d\n",
+                       rc);
+               return rc;
+       }
+       smblib_dbg(chg, PR_REGISTER, "DC_INT_RT_STS_REG = 0x%02x\n",
+                  stat);
+       val->intval = (bool)(stat & DCIN_PLUGIN_RT_STS_BIT);
+       return rc;
+ }
+ int smblib_get_prop_dc_online(struct smb_charger *chg,
+                              union power_supply_propval *val)
+ {
+       int rc = 0;
+       u8 stat;
+       if (get_client_vote(chg->dc_suspend_votable, USER_VOTER)) {
+               val->intval = false;
+               return rc;
+       }
+       rc = smblib_read(chg, POWER_PATH_STATUS_REG, &stat);
+       if (rc < 0) {
+               dev_err(chg->dev, "Couldn't read POWER_PATH_STATUS rc=%d\n",
+                       rc);
+               return rc;
+       }
+       smblib_dbg(chg, PR_REGISTER, "POWER_PATH_STATUS = 0x%02x\n",
+                  stat);
+       val->intval = (stat & USE_DCIN_BIT) &&
+                     (stat & VALID_INPUT_POWER_SOURCE_BIT);
+       return rc;
+ }
+ int smblib_get_prop_dc_current_max(struct smb_charger *chg,
+                                   union power_supply_propval *val)
+ {
+       val->intval = get_effective_result_locked(chg->dc_icl_votable);
+       return 0;
+ }
+ /*******************
+  * USB PSY SETTERS *
+  * *****************/
+ int smblib_set_prop_dc_current_max(struct smb_charger *chg,
+                                   const union power_supply_propval *val)
+ {
+       int rc;
+       rc = vote(chg->dc_icl_votable, USER_VOTER, true, val->intval);
+       return rc;
+ }
+ /*******************
   * USB PSY GETTERS *
   *******************/
  
@@@ -179,14 -172,18 +180,23 @@@ int smblib_get_prop_batt_charge_type(st
                                union power_supply_propval *val);
  int smblib_get_prop_batt_health(struct smb_charger *chg,
                                union power_supply_propval *val);
 +int smblib_get_prop_system_temp_level(struct smb_charger *chg,
 +                              union power_supply_propval *val);
 +
  int smblib_set_prop_input_suspend(struct smb_charger *chg,
                                const union power_supply_propval *val);
 +int smblib_set_prop_system_temp_level(struct smb_charger *chg,
 +                              const union power_supply_propval *val);
  
+ int smblib_get_prop_dc_present(struct smb_charger *chg,
+                               union power_supply_propval *val);
+ int smblib_get_prop_dc_online(struct smb_charger *chg,
+                               union power_supply_propval *val);
+ int smblib_get_prop_dc_current_max(struct smb_charger *chg,
+                               union power_supply_propval *val);
+ int smblib_set_prop_dc_current_max(struct smb_charger *chg,
+                               const union power_supply_propval *val);
  int smblib_get_prop_usb_present(struct smb_charger *chg,
                                union power_supply_propval *val);
  int smblib_get_prop_usb_online(struct smb_charger *chg,