From 3c9aa14a4470fc459443b306b7c047781ea8f77e Mon Sep 17 00:00:00 2001 From: xuwt2 Date: Tue, 27 Sep 2022 16:57:02 +0800 Subject: [PATCH] qti_glink_charger: Add wls tx capability To be compatible with the next generation wireless charger Add to support ask Tx Capability from wireless charger Change-Id: Ib137027bfd5cbe9bbd6a9f44a44cfe67bbf06bf2 Signed-off-by: xuwt2 Reviewed-on: https://gerrit.mot.com/2392470 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Jianqi Yang Submit-Approved: Jira Key --- .../qti_glink_charger/qti_glink_charger.c | 33 +++++++++++++++++++ .../qti_glink_charger/qti_glink_charger.h | 1 + 2 files changed, 34 insertions(+) diff --git a/drivers/power/qti_glink_charger/qti_glink_charger.c b/drivers/power/qti_glink_charger/qti_glink_charger.c index 331035d77a58..b163f398c1b1 100644 --- a/drivers/power/qti_glink_charger/qti_glink_charger.c +++ b/drivers/power/qti_glink_charger/qti_glink_charger.c @@ -235,6 +235,7 @@ struct qti_charger { u32 wlc_status; u32 wlc_tx_type; u32 wlc_tx_power; + u32 wlc_tx_capability; bool *debug_enabled; u32 wls_curr_max; u32 rx_connected; @@ -1711,6 +1712,30 @@ static DEVICE_ATTR(wlc_tx_power, S_IRUGO, wlc_tx_power_show, NULL); +static ssize_t wlc_tx_capability_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + u32 capability = 0; + struct qti_charger *chg = this_chip; + + if (!chg) { + pr_err("QTI: chip not valid\n"); + return -ENODEV; + } + + qti_charger_read(chg, OEM_PROP_WLS_WLC_TX_CAPABILITY, + &capability, + sizeof(capability)); + + chg->wlc_tx_capability = capability; + return scnprintf(buf, CHG_SHOW_MAX_SIZE, "%d\n", capability); +} + +static DEVICE_ATTR(wlc_tx_capability, S_IRUGO, + wlc_tx_capability_show, + NULL); + static ssize_t rx_connected_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -2106,6 +2131,11 @@ static void wireless_psy_init(struct qti_charger *chg) if (rc) pr_err("couldn't create wireless wlc tx power capacity error\n"); + rc = device_create_file(chg->wls_psy->dev.parent, + &dev_attr_wlc_tx_capability); + if (rc) + pr_err("couldn't create wireless wlc tx capability error\n"); + rc = device_create_file(chg->wls_psy->dev.parent, &dev_attr_wlc_st_changed); if (rc) @@ -2149,6 +2179,9 @@ static void wireless_psy_deinit(struct qti_charger *chg) device_remove_file(chg->wls_psy->dev.parent, &dev_attr_wlc_tx_power); + device_remove_file(chg->wls_psy->dev.parent, + &dev_attr_wlc_tx_capability); + device_remove_file(chg->wls_psy->dev.parent, &dev_attr_wlc_st_changed); diff --git a/drivers/power/qti_glink_charger/qti_glink_charger.h b/drivers/power/qti_glink_charger/qti_glink_charger.h index f2456dee2420..fdb2bf1ce7d3 100644 --- a/drivers/power/qti_glink_charger/qti_glink_charger.h +++ b/drivers/power/qti_glink_charger/qti_glink_charger.h @@ -65,6 +65,7 @@ enum oem_property_type { OEM_PROP_WLS_WLC_TX_POWER, OEM_PROP_SKU_TYPE, OEM_PROP_HW_REVISION, + OEM_PROP_WLS_WLC_TX_CAPABILITY, OEM_PROP_MAX, };