power: rename ALLOW_DETECTION to DPF_DMF
The ALLOW_DETECTION property is meant to reflect that the power supply controller should relinquish USB's DP and DM lines and put them in a floating state. Change to use the DP_DM property with DPF_DMF values for floating and DPR_DMR values for removing the float of DP/DM lines. USB: phy: msm: rename ALLOW_DETECTION prop to DP_DM Power supply driver has changes the ALLOW_DETECTION property to use the DP_DM property with DPF_DMF values for floating and DPR_DMR values for removing the float of DP/DM lines. Make changes in phy msm driver to handle it accordingly Change-Id: I1fdfaceb88058a6d1d3f21205a1a9b0e5058e7e7 Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org> Signed-off-by: Tarun Gupta <tarung@codeaurora.org> Signed-off-by: Vijayavardhan Vennapusa <vvreddy@codeaurora.org>
This commit is contained in:
parent
2b304c13e0
commit
0861965af5
|
@ -266,22 +266,6 @@ int power_supply_set_low_power_state(struct power_supply *psy, int value)
|
|||
}
|
||||
EXPORT_SYMBOL(power_supply_set_low_power_state);
|
||||
|
||||
/**
|
||||
* power_supply_set_allow_detection - set allow_detection for power_supply
|
||||
* @psy: the power supply to control
|
||||
* @value: value to be passed to the power_supply
|
||||
*/
|
||||
int power_supply_set_allow_detection(struct power_supply *psy, int value)
|
||||
{
|
||||
const union power_supply_propval ret = {value, };
|
||||
|
||||
if (psy->set_property)
|
||||
return psy->set_property(psy, POWER_SUPPLY_PROP_ALLOW_DETECTION,
|
||||
&ret);
|
||||
return -ENXIO;
|
||||
}
|
||||
EXPORT_SYMBOL(power_supply_set_allow_detection);
|
||||
|
||||
/**
|
||||
* power_supply_set_dp_dm -
|
||||
* @psy: the power supply to control
|
||||
|
|
|
@ -223,7 +223,6 @@ static struct device_attribute power_supply_attrs[] = {
|
|||
POWER_SUPPLY_ATTR(esr_count),
|
||||
POWER_SUPPLY_ATTR(safety_timer_enabled),
|
||||
POWER_SUPPLY_ATTR(charge_done),
|
||||
POWER_SUPPLY_ATTR(allow_detection),
|
||||
POWER_SUPPLY_ATTR(flash_active),
|
||||
POWER_SUPPLY_ATTR(force_tlim),
|
||||
POWER_SUPPLY_ATTR(dp_dm),
|
||||
|
|
|
@ -3881,8 +3881,9 @@ static void handle_usb_removal(struct smbchg_chip *chip)
|
|||
pr_smb(PR_MISC, "setting usb psy present = %d\n",
|
||||
chip->usb_present);
|
||||
power_supply_set_present(chip->usb_psy, chip->usb_present);
|
||||
pr_smb(PR_MISC, "setting usb psy allow detection 0\n");
|
||||
power_supply_set_allow_detection(chip->usb_psy, 0);
|
||||
pr_smb(PR_MISC, "setting usb psy dp=r dm=r\n");
|
||||
power_supply_set_dp_dm(chip->usb_psy,
|
||||
POWER_SUPPLY_DP_DM_DPR_DMR);
|
||||
schedule_work(&chip->usb_set_online_work);
|
||||
rc = power_supply_set_health_state(chip->usb_psy,
|
||||
POWER_SUPPLY_HEALTH_UNKNOWN);
|
||||
|
@ -4683,12 +4684,13 @@ static irqreturn_t usbin_uv_handler(int irq, void *_chip)
|
|||
chip->usb_present, reg, aicl_level);
|
||||
|
||||
/*
|
||||
* set usb_psy's allow_detection if this is a new insertion, i.e. it is
|
||||
* set usb_psy's dp=f dm=f if this is a new insertion, i.e. it is
|
||||
* not already src_detected and usbin_uv is seen falling
|
||||
*/
|
||||
if (!(reg & USBIN_UV_BIT) && !(reg & USBIN_SRC_DET_BIT)) {
|
||||
pr_smb(PR_MISC, "setting usb psy allow detection 1\n");
|
||||
power_supply_set_allow_detection(chip->usb_psy, 1);
|
||||
pr_smb(PR_MISC, "setting usb psy dp=f dm=f\n");
|
||||
power_supply_set_dp_dm(chip->usb_psy,
|
||||
POWER_SUPPLY_DP_DM_DPF_DMF);
|
||||
}
|
||||
|
||||
if ((reg & USBIN_UV_BIT) && (reg & USBIN_SRC_DET_BIT)) {
|
||||
|
|
|
@ -1850,17 +1850,16 @@ static int smb1351_apsd_complete_handler(struct smb1351_charger *chip,
|
|||
if (!chip->battery_missing && !chip->apsd_rerun
|
||||
&& chip->usb_psy) {
|
||||
if (type == POWER_SUPPLY_TYPE_USB) {
|
||||
pr_debug("Setting usb psy allow detection 1 SDP and rerun\n");
|
||||
power_supply_set_allow_detection(
|
||||
chip->usb_psy, 1);
|
||||
pr_debug("Setting usb psy dp=f dm=f SDP and rerun\n");
|
||||
power_supply_set_dp_dm(chip->usb_psy,
|
||||
POWER_SUPPLY_DP_DM_DPF_DMF);
|
||||
chip->apsd_rerun = true;
|
||||
rerun_apsd(chip);
|
||||
return 0;
|
||||
} else {
|
||||
pr_debug("Setting usb psy allow detection 1 DCP and no rerun\n");
|
||||
power_supply_set_allow_detection(
|
||||
chip->usb_psy, 1);
|
||||
}
|
||||
pr_debug("Set usb psy dp=f dm=f DCP and no rerun\n");
|
||||
power_supply_set_dp_dm(chip->usb_psy,
|
||||
POWER_SUPPLY_DP_DM_DPF_DMF);
|
||||
}
|
||||
/*
|
||||
* If defined force hvdcp 2p0 property,
|
||||
|
@ -1892,8 +1891,9 @@ static int smb1351_apsd_complete_handler(struct smb1351_charger *chip,
|
|||
POWER_SUPPLY_TYPE_UNKNOWN);
|
||||
power_supply_set_present(chip->usb_psy,
|
||||
chip->chg_present);
|
||||
pr_debug("Setting usb psy allow detection 0\n");
|
||||
power_supply_set_allow_detection(chip->usb_psy, 0);
|
||||
pr_debug("Set usb psy dm=r df=r\n");
|
||||
power_supply_set_dp_dm(chip->usb_psy,
|
||||
POWER_SUPPLY_DP_DM_DPR_DMR);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -2642,8 +2642,9 @@ static int handle_usb_removal(struct smb135x_chg *chip)
|
|||
POWER_SUPPLY_TYPE_UNKNOWN);
|
||||
pr_debug("setting usb psy present = %d\n", chip->usb_present);
|
||||
power_supply_set_present(chip->usb_psy, chip->usb_present);
|
||||
pr_debug("setting usb psy allow detection 0\n");
|
||||
power_supply_set_allow_detection(chip->usb_psy, 0);
|
||||
pr_debug("Setting usb psy dp=r dm=r\n");
|
||||
power_supply_set_dp_dm(chip->usb_psy,
|
||||
POWER_SUPPLY_DP_DM_DPR_DMR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -2703,15 +2704,17 @@ static int handle_usb_insertion(struct smb135x_chg *chip)
|
|||
|
||||
if (chip->batt_present && !chip->apsd_rerun && chip->usb_psy) {
|
||||
if (usb_supply_type == POWER_SUPPLY_TYPE_USB) {
|
||||
pr_debug("setting usb psy allow detection 1 SDP and rerun\n");
|
||||
power_supply_set_allow_detection(chip->usb_psy, 1);
|
||||
pr_debug("Setting usb psy dp=f dm=f SDP and rerun\n");
|
||||
power_supply_set_dp_dm(chip->usb_psy,
|
||||
POWER_SUPPLY_DP_DM_DPF_DMF);
|
||||
chip->apsd_rerun = true;
|
||||
rerun_apsd(chip);
|
||||
/* rising edge of src detect will happen in few mS */
|
||||
return 0;
|
||||
} else {
|
||||
pr_debug("setting usb psy allow detection 1 DCP and no rerun\n");
|
||||
power_supply_set_allow_detection(chip->usb_psy, 1);
|
||||
pr_debug("Set usb psy dp=f dm=f DCP and no rerun\n");
|
||||
power_supply_set_dp_dm(chip->usb_psy,
|
||||
POWER_SUPPLY_DP_DM_DPF_DMF);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2257,6 +2257,36 @@ get_prop_usbin_voltage_now(struct dwc3_msm *mdwc)
|
|||
}
|
||||
}
|
||||
|
||||
static int dwc3_msm_pmic_dp_dm(struct dwc3_msm *mdwc, int value)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (value) {
|
||||
case POWER_SUPPLY_DP_DM_DPF_DMF:
|
||||
if (!mdwc->rm_pulldown) {
|
||||
ret = dwc3_msm_remove_pulldown(mdwc, true);
|
||||
if (!ret) {
|
||||
mdwc->rm_pulldown = true;
|
||||
dbg_event(0xFF, "RM PuDwn", mdwc->rm_pulldown);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case POWER_SUPPLY_DP_DM_DPR_DMR:
|
||||
if (mdwc->rm_pulldown) {
|
||||
ret = dwc3_msm_remove_pulldown(mdwc, false);
|
||||
if (!ret) {
|
||||
mdwc->rm_pulldown = false;
|
||||
dbg_event(0xFF, "RM PuDwn", mdwc->rm_pulldown);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dwc3_msm_power_get_property_usb(struct power_supply *psy,
|
||||
enum power_supply_property psp,
|
||||
union power_supply_propval *val)
|
||||
|
@ -2325,14 +2355,9 @@ static int dwc3_msm_power_set_property_usb(struct power_supply *psy,
|
|||
mdwc->ss_phy->flags &= ~PHY_HOST_MODE;
|
||||
}
|
||||
break;
|
||||
/* PMIC notification to remove pull down on Dp and Dm */
|
||||
case POWER_SUPPLY_PROP_ALLOW_DETECTION:
|
||||
if (mdwc->rm_pulldown == val->intval)
|
||||
break;
|
||||
|
||||
mdwc->rm_pulldown = val->intval;
|
||||
dbg_event(0xFF, "RM PuDwn", val->intval);
|
||||
dwc3_msm_remove_pulldown(mdwc, mdwc->rm_pulldown);
|
||||
/* PMIC notification for DP_DM state */
|
||||
case POWER_SUPPLY_PROP_DP_DM:
|
||||
dwc3_msm_pmic_dp_dm(mdwc, val->intval);
|
||||
break;
|
||||
/* Process PMIC notification in PRESENT prop */
|
||||
case POWER_SUPPLY_PROP_PRESENT:
|
||||
|
|
|
@ -4737,6 +4737,39 @@ otg_get_prop_usbin_voltage_now(struct msm_otg *motg)
|
|||
}
|
||||
}
|
||||
|
||||
static int msm_otg_pmic_dp_dm(struct msm_otg *motg, int value)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
switch (value) {
|
||||
case POWER_SUPPLY_DP_DM_DPF_DMF:
|
||||
if (!motg->rm_pulldown) {
|
||||
ret = msm_hsusb_ldo_enable(motg, USB_PHY_REG_ON);
|
||||
if (!ret) {
|
||||
motg->rm_pulldown = true;
|
||||
msm_otg_dbg_log_event(&motg->phy, "RM Pulldown",
|
||||
motg->rm_pulldown, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case POWER_SUPPLY_DP_DM_DPR_DMR:
|
||||
if (motg->rm_pulldown) {
|
||||
ret = msm_hsusb_ldo_enable(motg, USB_PHY_REG_OFF);
|
||||
if (!ret) {
|
||||
motg->rm_pulldown = false;
|
||||
msm_otg_dbg_log_event(&motg->phy, "RM Pulldown",
|
||||
motg->rm_pulldown, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int otg_power_get_property_usb(struct power_supply *psy,
|
||||
enum power_supply_property psp,
|
||||
union power_supply_propval *val)
|
||||
|
@ -4758,7 +4791,7 @@ static int otg_power_get_property_usb(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_PRESENT:
|
||||
val->intval = !!test_bit(B_SESS_VLD, &motg->inputs);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_ALLOW_DETECTION:
|
||||
case POWER_SUPPLY_PROP_DP_DM:
|
||||
val->intval = motg->rm_pulldown;
|
||||
break;
|
||||
/* Reflect USB enumeration */
|
||||
|
@ -4795,16 +4828,9 @@ static int otg_power_set_property_usb(struct power_supply *psy,
|
|||
motg->id_state = val->intval ? USB_ID_GROUND : USB_ID_FLOAT;
|
||||
queue_delayed_work(motg->otg_wq, &motg->id_status_work, 0);
|
||||
break;
|
||||
/* PMIC notification to remove pull down on Dp and Dm */
|
||||
case POWER_SUPPLY_PROP_ALLOW_DETECTION:
|
||||
if (motg->rm_pulldown == val->intval)
|
||||
break;
|
||||
|
||||
motg->rm_pulldown = val->intval;
|
||||
msm_otg_dbg_log_event(&motg->phy, "RM Pulldown",
|
||||
motg->rm_pulldown, 0);
|
||||
msm_hsusb_ldo_enable(motg, motg->rm_pulldown ?
|
||||
USB_PHY_REG_ON : USB_PHY_REG_OFF);
|
||||
/* PMIC notification for DP DM state */
|
||||
case POWER_SUPPLY_PROP_DP_DM:
|
||||
msm_otg_pmic_dp_dm(motg, val->intval);
|
||||
break;
|
||||
/* Process PMIC notification in PRESENT prop */
|
||||
case POWER_SUPPLY_PROP_PRESENT:
|
||||
|
@ -4890,7 +4916,7 @@ static int otg_power_property_is_writeable_usb(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_ONLINE:
|
||||
case POWER_SUPPLY_PROP_VOLTAGE_MAX:
|
||||
case POWER_SUPPLY_PROP_CURRENT_MAX:
|
||||
case POWER_SUPPLY_PROP_ALLOW_DETECTION:
|
||||
case POWER_SUPPLY_PROP_DP_DM:
|
||||
case POWER_SUPPLY_PROP_USB_OTG:
|
||||
return 1;
|
||||
default:
|
||||
|
@ -4913,7 +4939,7 @@ static enum power_supply_property otg_pm_power_props_usb[] = {
|
|||
POWER_SUPPLY_PROP_SCOPE,
|
||||
POWER_SUPPLY_PROP_TYPE,
|
||||
POWER_SUPPLY_PROP_VOLTAGE_NOW,
|
||||
POWER_SUPPLY_PROP_ALLOW_DETECTION,
|
||||
POWER_SUPPLY_PROP_DP_DM,
|
||||
POWER_SUPPLY_PROP_USB_OTG,
|
||||
};
|
||||
|
||||
|
|
|
@ -187,7 +187,6 @@ enum power_supply_property {
|
|||
POWER_SUPPLY_PROP_ESR_COUNT,
|
||||
POWER_SUPPLY_PROP_SAFETY_TIMER_ENABLE,
|
||||
POWER_SUPPLY_PROP_CHARGE_DONE,
|
||||
POWER_SUPPLY_PROP_ALLOW_DETECTION,
|
||||
POWER_SUPPLY_PROP_FLASH_ACTIVE,
|
||||
POWER_SUPPLY_PROP_FORCE_TLIM,
|
||||
POWER_SUPPLY_PROP_DP_DM,
|
||||
|
@ -316,8 +315,6 @@ extern int power_supply_set_supply_type(struct power_supply *psy,
|
|||
extern int power_supply_set_hi_power_state(struct power_supply *psy, int value);
|
||||
extern int power_supply_set_low_power_state(struct power_supply *psy,
|
||||
int value);
|
||||
extern int power_supply_set_allow_detection(struct power_supply *psy,
|
||||
int value);
|
||||
extern int power_supply_set_dp_dm(struct power_supply *psy,
|
||||
int value);
|
||||
extern int power_supply_is_system_supplied(void);
|
||||
|
|
Loading…
Reference in New Issue