From: Nicholas Troast Date: Wed, 27 Jul 2016 18:29:30 +0000 (-0700) Subject: qcom-charger: smb138x-charger: add parallel enable status properties X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=081e422149b9a683d859fc79023ce0948328b4bc;p=sagit-ice-cold%2Fkernel_xiaomi_msm8998.git qcom-charger: smb138x-charger: add parallel enable status properties There are several ways that the parallel charger can be enabled, and disabled. Currently charging is enabled by default, but the hardware has the option to disable the parallel charger via the CHG_EN pin on the parallel charger. The parallel charger driver controls when the parallel charger is enabled via the input suspend bit. To better understand the state of the parallel charger add two power supply properties to the parallel power supply: CHARGING_ENABLED - Reflects whether the parallel charger is enabled by any source. PIN_ENABLED - Reflects whether hardware has voted to enable the parallel charger. Change-Id: I725245178ab02c5ec39b89998f5c2ca3d494c8ee Signed-off-by: Nicholas Troast --- diff --git a/drivers/power/qcom-charger/smb138x-charger.c b/drivers/power/qcom-charger/smb138x-charger.c index 9a6baff27dac..6bd795595f19 100644 --- a/drivers/power/qcom-charger/smb138x-charger.c +++ b/drivers/power/qcom-charger/smb138x-charger.c @@ -357,6 +357,8 @@ static int smb138x_init_batt_psy(struct smb138x *chip) *****************************/ static enum power_supply_property smb138x_parallel_props[] = { + POWER_SUPPLY_PROP_CHARGING_ENABLED, + POWER_SUPPLY_PROP_PIN_ENABLED, POWER_SUPPLY_PROP_INPUT_SUSPEND, POWER_SUPPLY_PROP_VOLTAGE_MAX, POWER_SUPPLY_PROP_CURRENT_MAX, @@ -368,8 +370,21 @@ static int smb138x_parallel_get_prop(struct power_supply *psy, { struct smb_charger *chg = power_supply_get_drvdata(psy); int rc = 0; + u8 temp; switch (prop) { + case POWER_SUPPLY_PROP_CHARGING_ENABLED: + rc = smblib_read(chg, BATTERY_CHARGER_STATUS_5_REG, + &temp); + if (rc >= 0) + val->intval = (bool)(temp & CHARGING_ENABLE_BIT); + break; + case POWER_SUPPLY_PROP_PIN_ENABLED: + rc = smblib_read(chg, BATTERY_CHARGER_STATUS_5_REG, + &temp); + if (rc >= 0) + val->intval = !(temp & DISABLE_CHARGING_BIT); + break; case POWER_SUPPLY_PROP_INPUT_SUSPEND: rc = smblib_get_usb_suspend(chg, &val->intval); break;