power: supply: qti_battery_charger: Add support for 33W reverse wireless charging

Change-Id: Ic77236a573db6d8aeef04a423d6f1e005f474bc9
This commit is contained in:
Arian 2024-03-12 01:20:11 +01:00 committed by Jens Reidel
parent 4476fa019f
commit 7a605eafc4
No known key found for this signature in database
GPG Key ID: 23C1E5F512C12303
3 changed files with 143 additions and 0 deletions

View File

@ -869,6 +869,11 @@ config MI_ENABLE_DP
help
Say Y here to enable create node to support dp function
config REVERSE_33W
tristate "enable or disable reverse 33W config"
help
Say Y here to enable create node to support reverse_33W of downshift function
config MI_DTPT
tristate "mi dtpt config"
help

View File

@ -398,6 +398,12 @@ enum xm_property_id {
#if defined(CONFIG_MI_ENABLE_DP)
XM_PROP_HAS_DP,
#endif
#if defined(CONFIG_REVERSE_33W)
XM_PROP_DOWNSHIFT,
XM_PROP_SNK_PROTOCOL,
XM_PROP_SCREEN_UNLOCK,
XM_PROP_REVERSE_THERMAL,
#endif
#ifdef CONFIG_MI_CHARGER_M81
XM_PROP_ATEST,
#endif /* CONFIG_MI_CHARGER_M81 */

View File

@ -4635,6 +4635,132 @@ static ssize_t sport_mode_show(struct class *c,
}
static CLASS_ATTR_RW(sport_mode);
#if defined(CONFIG_REVERSE_33W)
static ssize_t downshift_show(struct class *c,
struct class_attribute *attr, char *buf)
{
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
battery_class);
struct psy_state *pst = &bcdev->psy_list[PSY_TYPE_XM];
int rc;
rc = read_property_id(bcdev, pst, XM_PROP_DOWNSHIFT);
if (rc < 0)
return rc;
return scnprintf(buf, PAGE_SIZE, "%d\n", pst->prop[XM_PROP_DOWNSHIFT]);
}
static ssize_t downshift_store(struct class *c,
struct class_attribute *attr,
const char *buf, size_t count)
{
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
battery_class);
struct psy_state *pst = &bcdev->psy_list[PSY_TYPE_XM];
int val;
int rc;
if (kstrtoint(buf, 10, &val))
return -EINVAL;
rc = write_property_id(bcdev, pst, XM_PROP_DOWNSHIFT, val);
if (rc < 0)
return rc;
return count;
}
static CLASS_ATTR_RW(downshift);
static ssize_t snk_protocol_show(struct class *c,
struct class_attribute *attr, char *buf)
{
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
battery_class);
struct psy_state *pst = &bcdev->psy_list[PSY_TYPE_XM];
int rc;
rc = read_property_id(bcdev, pst, XM_PROP_SNK_PROTOCOL);
if (rc < 0)
return rc;
return scnprintf(buf, PAGE_SIZE, "%d\n", pst->prop[XM_PROP_SNK_PROTOCOL]);
}
static CLASS_ATTR_RO(snk_protocol);
static ssize_t screen_unlock_show(struct class *c,
struct class_attribute *attr, char *buf)
{
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
battery_class);
struct psy_state *pst = &bcdev->psy_list[PSY_TYPE_XM];
int rc;
rc = read_property_id(bcdev, pst, XM_PROP_SCREEN_UNLOCK);
if (rc < 0)
return rc;
return scnprintf(buf, PAGE_SIZE, "%d\n", pst->prop[XM_PROP_SCREEN_UNLOCK]);
}
static ssize_t screen_unlock_store(struct class *c,
struct class_attribute *attr,
const char *buf, size_t count)
{
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
battery_class);
struct psy_state *pst = &bcdev->psy_list[PSY_TYPE_XM];
int val;
int rc;
if (kstrtoint(buf, 10, &val))
return -EINVAL;
rc = write_property_id(bcdev, pst, XM_PROP_SCREEN_UNLOCK, val);
if (rc < 0)
return rc;
return count;
}
static CLASS_ATTR_RW(screen_unlock);
static ssize_t reverse_thermal_show(struct class *c,
struct class_attribute *attr, char *buf)
{
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
battery_class);
struct psy_state *pst = &bcdev->psy_list[PSY_TYPE_XM];
int rc;
rc = read_property_id(bcdev, pst, XM_PROP_REVERSE_THERMAL);
if (rc < 0)
return rc;
return scnprintf(buf, PAGE_SIZE, "%d\n", pst->prop[XM_PROP_REVERSE_THERMAL]);
}
static ssize_t reverse_thermal_store(struct class *c,
struct class_attribute *attr,
const char *buf, size_t count)
{
struct battery_chg_dev *bcdev = container_of(c, struct battery_chg_dev,
battery_class);
struct psy_state *pst = &bcdev->psy_list[PSY_TYPE_XM];
int val;
int rc;
if (kstrtoint(buf, 10, &val))
return -EINVAL;
rc = write_property_id(bcdev, pst, XM_PROP_REVERSE_THERMAL, val);
if (rc < 0)
return rc;
return count;
}
static CLASS_ATTR_RW(reverse_thermal);
#endif
#ifdef CONFIG_MI_CHARGER_M81
static ssize_t atest_store(struct class *c,
struct class_attribute *attr,
@ -4952,6 +5078,12 @@ static struct attribute *xiaomi_battery_class_attrs[] = {
#if defined(CONFIG_MI_ENABLE_DP)
&class_attr_has_dp.attr,
#endif
#if defined(CONFIG_REVERSE_33W)
&class_attr_downshift.attr,
&class_attr_snk_protocol.attr,
&class_attr_screen_unlock.attr,
&class_attr_reverse_thermal.attr,
#endif
#ifndef CONFIG_MI_CHARGER_M81
&class_attr_thermal_board_temp.attr,
#endif /* !CONFIG_MI_CHARGER_M81 */