smb5: Add syfs node to offer usb_dcp_icl_ua setting

To provide a sysfs node to reset the usb_dcp_icl_ua threshold,
For handle different DCP icl setting for different SKU regions,
Add a sysfs node in smb5 for that.
Force rerun APSD after rewriting usb_dcp_icl_ua

Change-Id: If7fcd97de95457dea5bcabcb41612bd1c9abdecb
Signed-off-by: xuwt2 <xuwt2@lenovo.com>
Reviewed-on: https://gerrit.mot.com/1686899
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Yonghua Yan <yanyh2@motorola.com>
Reviewed-by: Jianqi Yang <yangj@motorola.com>
Submit-Approved: Jira Key
Reviewed-on: https://gerrit.mot.com/1771138
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
This commit is contained in:
xuwt2 2020-07-16 19:30:05 +08:00 • committed by Xiaojun Ji
commit afae98dffe

View file

@ -281,9 +281,38 @@ static ssize_t weak_chg_icl_ua_store(struct device *dev, struct device_attribute
}
static DEVICE_ATTR_RW(weak_chg_icl_ua);
static ssize_t usb_dcp_icl_ua_show(struct device *dev, struct device_attribute
*attr, char *buf)
{
struct smb5 *chip = dev_get_drvdata(dev);
struct smb_charger *chg = &chip->chg;
return snprintf(buf, PAGE_SIZE, "%d\n", chg->usb_dcp_curr_max);
}
static ssize_t usb_dcp_icl_ua_store(struct device *dev, struct device_attribute
*attr, const char *buf, size_t count)
{
int val;
struct smb5 *chip = dev_get_drvdata(dev);
struct smb_charger *chg = &chip->chg;
if (kstrtos32(buf, 0, &val))
return -EINVAL;
chg->usb_dcp_curr_max = val;
pr_info("USB dcp icl was rewritten as %dua\n", chg->usb_dcp_curr_max);
if (chg->real_charger_type == POWER_SUPPLY_TYPE_USB_DCP)
smblib_rerun_apsd_if_required(chg);
return count;
}
static DEVICE_ATTR_RW(usb_dcp_icl_ua);
static struct attribute *smb5_attrs[] = {
&dev_attr_pd_disabled.attr,
&dev_attr_weak_chg_icl_ua.attr,
&dev_attr_usb_dcp_icl_ua.attr,
NULL,
};
ATTRIBUTE_GROUPS(smb5);