OSDN Git Service

qpnp-smb2: support POWER_SUPPLY_PROP_CTM_CURRENT_MAX
authorNicholas Troast <ntroast@codeaurora.org>
Thu, 9 Feb 2017 18:05:03 +0000 (10:05 -0800)
committerAshay Jaiswal <ashayj@codeaurora.org>
Fri, 10 Feb 2017 07:22:15 +0000 (12:52 +0530)
CTM needs to vote for USB ICL. Add support for it.

Change-Id: I88b146000f7327cf5dc7310fb721309f08dc3035
Signed-off-by: Nicholas Troast <ntroast@codeaurora.org>
drivers/power/supply/qcom/qpnp-smb2.c
drivers/power/supply/qcom/smb-lib.h

index a5575ee..125a39b 100644 (file)
@@ -412,6 +412,7 @@ static enum power_supply_property smb2_usb_props[] = {
        POWER_SUPPLY_PROP_INPUT_CURRENT_NOW,
        POWER_SUPPLY_PROP_BOOST_CURRENT,
        POWER_SUPPLY_PROP_PE_START,
+       POWER_SUPPLY_PROP_CTM_CURRENT_MAX,
 };
 
 static int smb2_usb_get_prop(struct power_supply *psy,
@@ -497,6 +498,9 @@ static int smb2_usb_get_prop(struct power_supply *psy,
        case POWER_SUPPLY_PROP_PE_START:
                rc = smblib_get_pe_start(chg, val);
                break;
+       case POWER_SUPPLY_PROP_CTM_CURRENT_MAX:
+               val->intval = get_client_vote(chg->usb_icl_votable, CTM_VOTER);
+               break;
        default:
                pr_err("get prop %d is not supported in usb\n", psp);
                rc = -EINVAL;
@@ -545,6 +549,10 @@ static int smb2_usb_set_prop(struct power_supply *psy,
        case POWER_SUPPLY_PROP_BOOST_CURRENT:
                rc = smblib_set_prop_boost_current(chg, val);
                break;
+       case POWER_SUPPLY_PROP_CTM_CURRENT_MAX:
+               rc = vote(chg->usb_icl_votable, CTM_VOTER,
+                                               val->intval >= 0, val->intval);
+               break;
        default:
                pr_err("set prop %d is not supported\n", psp);
                rc = -EINVAL;
@@ -559,6 +567,7 @@ static int smb2_usb_prop_is_writeable(struct power_supply *psy,
 {
        switch (psp) {
        case POWER_SUPPLY_PROP_TYPEC_POWER_ROLE:
+       case POWER_SUPPLY_PROP_CTM_CURRENT_MAX:
                return 1;
        default:
                break;
index 1a5ea25..864e7d6 100644 (file)
@@ -55,6 +55,7 @@ enum print_reason {
 #define DEBUG_BOARD_VOTER              "DEBUG_BOARD_VOTER"
 #define PD_SUSPEND_SUPPORTED_VOTER     "PD_SUSPEND_SUPPORTED_VOTER"
 #define PL_DISABLE_HVDCP_VOTER         "PL_DISABLE_HVDCP_VOTER"
+#define CTM_VOTER                      "CTM_VOTER"
 
 #define VCONN_MAX_ATTEMPTS     3
 #define OTG_MAX_ATTEMPTS       3