Merge "power: qpnp-smbcharger: add support to control hvdcp3 detection dynamically"
This commit is contained in:
commit
ff694c5bf8
|
@ -233,6 +233,7 @@ static struct device_attribute power_supply_attrs[] = {
|
|||
POWER_SUPPLY_ATTR(cycle_count_id),
|
||||
POWER_SUPPLY_ATTR(safety_timer_expired),
|
||||
POWER_SUPPLY_ATTR(restricted_charging),
|
||||
POWER_SUPPLY_ATTR(allow_hvdcp3),
|
||||
/* Local extensions of type int64_t */
|
||||
POWER_SUPPLY_ATTR(charge_counter_ext),
|
||||
/* Properties of type `const char *' */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -139,6 +139,7 @@ struct smbchg_chip {
|
|||
bool vbat_above_headroom;
|
||||
bool force_aicl_rerun;
|
||||
bool hvdcp3_supported;
|
||||
bool allow_hvdcp3_detection;
|
||||
bool restricted_charging;
|
||||
bool cfg_override_usb_current;
|
||||
u8 original_usbin_allowance;
|
||||
|
@ -4886,6 +4887,25 @@ static int fake_insertion_removal(struct smbchg_chip *chip, bool insertion)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void smbchg_handle_hvdcp3_disable(struct smbchg_chip *chip)
|
||||
{
|
||||
enum power_supply_type usb_supply_type;
|
||||
char *usb_type_name = "NULL";
|
||||
|
||||
chip->pulse_cnt = 0;
|
||||
|
||||
if (is_hvdcp_present(chip)) {
|
||||
smbchg_change_usb_supply_type(chip,
|
||||
POWER_SUPPLY_TYPE_USB_HVDCP);
|
||||
} else {
|
||||
read_usb_type(chip, &usb_type_name, &usb_supply_type);
|
||||
smbchg_change_usb_supply_type(chip, usb_supply_type);
|
||||
if (usb_supply_type == POWER_SUPPLY_TYPE_USB_DCP)
|
||||
schedule_delayed_work(&chip->hvdcp_det_work,
|
||||
msecs_to_jiffies(HVDCP_NOTIFY_MS));
|
||||
}
|
||||
}
|
||||
|
||||
static int smbchg_prepare_for_pulsing(struct smbchg_chip *chip)
|
||||
{
|
||||
int rc = 0;
|
||||
|
@ -5091,6 +5111,11 @@ out:
|
|||
pr_smb(PR_MISC, "HVDCP removed\n");
|
||||
update_usb_status(chip, 0, 0);
|
||||
}
|
||||
|
||||
/* This could be because allow_hvdcp3 set to false runtime */
|
||||
if (is_usb_present(chip) && !chip->allow_hvdcp3_detection)
|
||||
smbchg_handle_hvdcp3_disable(chip);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -5275,6 +5300,10 @@ static int smbchg_unprepare_for_pulsing_lite(struct smbchg_chip *chip)
|
|||
if (rc < 0)
|
||||
pr_err("Couldn't retract HVDCP ICL vote rc=%d\n", rc);
|
||||
|
||||
/* This could be because allow_hvdcp3 set to false runtime */
|
||||
if (is_usb_present(chip) && !chip->allow_hvdcp3_detection)
|
||||
smbchg_handle_hvdcp3_disable(chip);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -5449,6 +5478,7 @@ static enum power_supply_property smbchg_battery_properties[] = {
|
|||
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED,
|
||||
POWER_SUPPLY_PROP_RERUN_AICL,
|
||||
POWER_SUPPLY_PROP_RESTRICTED_CHARGING,
|
||||
POWER_SUPPLY_PROP_ALLOW_HVDCP3,
|
||||
};
|
||||
|
||||
static int smbchg_battery_set_property(struct power_supply *psy,
|
||||
|
@ -5508,6 +5538,12 @@ static int smbchg_battery_set_property(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_RESTRICTED_CHARGING:
|
||||
rc = smbchg_restricted_charging(chip, val->intval);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
|
||||
if (chip->allow_hvdcp3_detection != val->intval) {
|
||||
chip->allow_hvdcp3_detection = !!val->intval;
|
||||
power_supply_changed(&chip->batt_psy);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -5531,6 +5567,7 @@ static int smbchg_battery_is_writeable(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_DP_DM:
|
||||
case POWER_SUPPLY_PROP_RERUN_AICL:
|
||||
case POWER_SUPPLY_PROP_RESTRICTED_CHARGING:
|
||||
case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
|
||||
rc = 1;
|
||||
break;
|
||||
default:
|
||||
|
@ -5628,6 +5665,9 @@ static int smbchg_battery_get_property(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_INPUT_CURRENT_NOW:
|
||||
val->intval = smbchg_get_iusb(chip);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_ALLOW_HVDCP3:
|
||||
val->intval = chip->allow_hvdcp3_detection;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
@ -7512,6 +7552,7 @@ static int smbchg_check_chg_version(struct smbchg_chip *chip)
|
|||
pr_err("PMIC subtype %d not supported, WA flags not set\n",
|
||||
pmic_rev_id->pmic_subtype);
|
||||
}
|
||||
chip->allow_hvdcp3_detection = true;
|
||||
|
||||
pr_smb(PR_STATUS, "pmic=%s, wa_flags=0x%x\n",
|
||||
pmic_rev_id->pmic_name, chip->wa_flags);
|
||||
|
|
|
@ -200,6 +200,7 @@ enum power_supply_property {
|
|||
POWER_SUPPLY_PROP_CYCLE_COUNT_ID,
|
||||
POWER_SUPPLY_PROP_SAFETY_TIMER_EXPIRED,
|
||||
POWER_SUPPLY_PROP_RESTRICTED_CHARGING,
|
||||
POWER_SUPPLY_PROP_ALLOW_HVDCP3,
|
||||
/* Local extensions of type int64_t */
|
||||
POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT,
|
||||
/* Properties of type `const char *' */
|
||||
|
|
Loading…
Reference in New Issue