From 88ce6a793bbd2a78527646ab82a0dd7282bc28c0 Mon Sep 17 00:00:00 2001 From: Guru Das Srinagesh Date: Fri, 1 Feb 2019 13:40:55 -0800 Subject: [PATCH 1/2] power: smb5: Support HW-autonomous HVDCP operation Add boolean DT parameter "hvdcp-autonomous-enable" to enable HVDCP HW-autonomous operation. Change-Id: Ib0bf2db764d81debb0c9c6f906486415cdfee85b Signed-off-by: Guru Das Srinagesh --- drivers/power/supply/qcom/qpnp-smb5.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/qcom/qpnp-smb5.c b/drivers/power/supply/qcom/qpnp-smb5.c index 1225a248783b..4eae836eb8c2 100644 --- a/drivers/power/supply/qcom/qpnp-smb5.c +++ b/drivers/power/supply/qcom/qpnp-smb5.c @@ -173,6 +173,7 @@ struct smb_dt_props { int chg_inhibit_thr_mv; bool no_battery; bool hvdcp_disable; + bool hvdcp_autonomous; int sec_charger_config; int auto_recharge_soc; int auto_recharge_vbat_mv; @@ -401,6 +402,9 @@ static int smb5_parse_dt_misc(struct smb5 *chip, struct device_node *node) "qcom,hvdcp-disable"); chg->hvdcp_disable = chip->dt.hvdcp_disable; + chip->dt.hvdcp_autonomous = of_property_read_bool(node, + "qcom,hvdcp-autonomous-enable"); + chip->dt.auto_recharge_soc = -EINVAL; rc = of_property_read_u32(node, "qcom,auto-recharge-soc", &chip->dt.auto_recharge_soc); @@ -1915,11 +1919,15 @@ static int smb5_init_hw(struct smb5 *chip) } /* - * Disable HVDCP autonomous mode operation by default. Additionally, if - * specified in DT: disable HVDCP and HVDCP authentication algorithm. + * Disable HVDCP autonomous mode operation by default, providing a DT + * knob to turn it on if required. Additionally, if specified in DT, + * disable HVDCP and HVDCP authentication algorithm. */ val = (chg->hvdcp_disable) ? 0 : (HVDCP_AUTH_ALG_EN_CFG_BIT | HVDCP_EN_BIT); + if (chip->dt.hvdcp_autonomous) + val |= HVDCP_AUTONOMOUS_MODE_EN_CFG_BIT; + rc = smblib_masked_write(chg, USBIN_OPTIONS_1_CFG_REG, (HVDCP_AUTH_ALG_EN_CFG_BIT | HVDCP_EN_BIT | HVDCP_AUTONOMOUS_MODE_EN_CFG_BIT), From 36514f1bb3ab57085e4c7691fd3a8aedf6208dbe Mon Sep 17 00:00:00 2001 From: Guru Das Srinagesh Date: Fri, 1 Feb 2019 14:19:45 -0800 Subject: [PATCH 2/2] dt-bindings: qpnp-smb5: Support disabling of USB-PD via DT Add DT property "qcom,usb-pd-disable" to disable USB-PD operation entirely. Change-Id: I052049ac2c275cc56ca9513f27599c02733dd0db Signed-off-by: Guru Das Srinagesh --- .../devicetree/bindings/power/supply/qcom/qpnp-smb5.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/power/supply/qcom/qpnp-smb5.txt b/Documentation/devicetree/bindings/power/supply/qcom/qpnp-smb5.txt index 454f2a573ca9..d173819db9a7 100644 --- a/Documentation/devicetree/bindings/power/supply/qcom/qpnp-smb5.txt +++ b/Documentation/devicetree/bindings/power/supply/qcom/qpnp-smb5.txt @@ -275,6 +275,11 @@ Charger specific properties: Definition: Boolean flag which when present enables hardware-controlled operation of HVDCP. +- qcom,usb-pd-disable + Usage: optional + Value type: bool + Definition: Boolean flag which when present disables USB-PD operation. + ============================================= Second Level Nodes - SMB5 Charger Peripherals =============================================