smb5: Only allow Moto pd policy to set pdo voltage max

Base on Kernel built-in Moto PD controlling policy, pdo select depends
on PD voltage max, so the product should decide which USB PD voltage is
allowed, including the USB PD input power(Hardcode 18W in current code).
Different product design may require different USB PD voltage allowance
and USB PD input power max allowance.

Current Moto PD controlling policy only applies to FIXED pdo but not
programmable pdo(PPS), which requires periodic PD output power
acknowledgement(at least 10s interval). So it has to redesign current
Moto PD controlling policy to support PPS pdo selection.

In order to avoid any PD controlling policy conflict with third party
disable the PD controlling policy modification interfaces for user space
(may be used by hvdcp_opti daemon in Qcom platform).

Change-Id: I7565e187e2619252bc6d611b7f4aabc90b72c687
Signed-off-by: xuwt2 <xuwt2@lenovo.com>
Reviewed-on: https://gerrit.mot.com/1461008
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Haijian Ma <mahj8@motorola.com>
Reviewed-by: Yonghua Yan <yanyh2@motorola.com>
Reviewed-by: Jianqi Yang <yangj@motorola.com>
Submit-Approved: Jira Key
Reviewed-on: https://gerrit.mot.com/1771065
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
This commit is contained in:
xuwt2 2019-11-25 19:18:47 +08:00 • committed by Xiaojun Ji
commit c1717e45fa
3 changed files with 22 additions and 0 deletions

View file

@ -314,10 +314,14 @@ int smb5_iio_set_prop(struct smb_charger *chg, int channel, int val)
rc = smblib_set_prop_pr_swap_in_progress(chg, val);
break;
case PSY_IIO_PD_VOLTAGE_MAX:
#ifdef QCOM_BASE
rc = smblib_set_prop_pd_voltage_max(chg, val);
#endif
break;
case PSY_IIO_PD_VOLTAGE_MIN:
#ifdef QCOM_BASE
rc = smblib_set_prop_pd_voltage_min(chg, val);
#endif
break;
case PSY_IIO_CONNECTOR_HEALTH:
chg->connector_health = val;

View file

@ -7401,6 +7401,23 @@ static void smblib_pd_contract_work(struct work_struct *work)
if (!chg->pd || !chg->pd_active)
return;
if (!chg->pd_voltage_max_uv) {
rc = of_property_read_u32(chg->dev->of_node,
"qcom,pd-voltage-max-uv",
&chg->pd_voltage_max_uv);
if (rc < 0) {
chg->pd_voltage_max_uv = MICRO_5V;
smblib_err(chg, "Failed to get pd_voltage_max_uv"
"from device tree, rc = %d\n", rc);
}
if (chg->pd_voltage_max_uv < MICRO_5V)
chg->pd_voltage_max_uv = MICRO_5V;
else if (chg->pd_voltage_max_uv > MICRO_12V)
chg->pd_voltage_max_uv = MICRO_12V;
}
chg->voltage_max_uv = chg->pd_voltage_max_uv;
chg->pd_contract_uv = usbpd_select_pdo_match(chg->pd);
if (chg->pd_contract_uv == -ENOTSUPP)

View file

@ -613,6 +613,7 @@ struct smb_charger {
/* USB PD interactions */
struct usbpd *pd;
int pd_contract_uv;
int pd_voltage_max_uv;
struct delayed_work pd_contract_work;
/* battery profile */