mmi-smbcharger-iio: Add charging power interface

CQA factory test need to get the charging power,
so we add it.
The unit of chg_watt is W.

Change-Id: I861d8fcfa5bedcbd992a6943b6b4d885beba65fb
Signed-off-by: Guocheng Wang <wanggc6@motorola.com>
Reviewed-on: https://gerrit.mot.com/2696461
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Yuecai Liu <liuyc20@motorola.com>
Reviewed-by: Haijian Ma <mahj8@motorola.com>
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Guocheng Wang 2023-08-01 20:59:36 +08:00
commit e2e260f135

View file

@ -1623,6 +1623,28 @@ static DEVICE_ATTR(force_chg_itrick, 0664,
force_chg_itrick_show,
force_chg_itrick_store);
static ssize_t chg_watt_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
int power_watt = -ENODEV;
struct platform_device *pdev = to_platform_device(dev);
struct smb_mmi_charger *mmi_chip = platform_get_drvdata(pdev);
if (mmi_chip) {
power_watt = mmi_chip->power_watt / 1000;
mmi_info(mmi_chip, "power_watt %dW\n", power_watt);
} else {
pr_err("chip not valid\n");
}
return scnprintf(buf, CHG_SHOW_MAX_SIZE, "%d\n", power_watt);
}
static DEVICE_ATTR(chg_watt, 0444,
chg_watt_show,
NULL);
enum {
MMI_FACTORY_MODE,
MMI_FACTORY_BUILD,
@ -5049,6 +5071,12 @@ static int smb_mmi_probe(struct platform_device *pdev)
if (rc)
mmi_err(chip, "Couldn't create force_pd_power_max\n");
rc = device_create_file(chip->dev,
&dev_attr_chg_watt);
if (rc) {
mmi_err(chip, "Couldn't create chg_watt\n");
}
/* Register the notifier for the psy updates*/
chip->mmi_psy_notifier.notifier_call = mmi_psy_notifier_call;
rc = power_supply_reg_notifier(&chip->mmi_psy_notifier);