mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-11 23:24:22 -04:00
Add force_charging_enabled sysfs
Add missing sysfs to allow Factory to re-enable charging while in factory mode or when using factory software. Change-Id: If39b3d5f56495b7d89445629bc1541f0b22a296a Reviewed-on: https://gerrit.mot.com/1949637 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Jianqi Yang <yangj@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
5fc33ebcee
commit
c94d7986fc
1 changed files with 58 additions and 0 deletions
|
|
@ -194,6 +194,7 @@ struct mmi_charger_chip {
|
|||
bool factory_version;
|
||||
bool factory_kill_armed;
|
||||
bool force_charger_disabled;
|
||||
bool force_charging_enabled;
|
||||
|
||||
int dcp_pmax;
|
||||
int hvdcp_pmax;
|
||||
|
|
@ -672,6 +673,52 @@ static DEVICE_ATTR(force_charger_suspend, 0644,
|
|||
force_charger_suspend_show,
|
||||
force_charger_suspend_store);
|
||||
|
||||
static ssize_t force_charging_enable_show(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
int state;
|
||||
|
||||
if (!this_chip) {
|
||||
pr_err("mmi_charger: chip not valid\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
state = this_chip->force_charging_enabled;
|
||||
|
||||
return scnprintf(buf, CHG_SHOW_MAX_SIZE, "%d\n", state);
|
||||
}
|
||||
|
||||
static ssize_t force_charging_enable_store(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
unsigned long r;
|
||||
unsigned long mode;
|
||||
|
||||
if (!this_chip) {
|
||||
pr_err("mmi_charger: chip not valid\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
r = kstrtoul(buf, 0, &mode);
|
||||
if (r) {
|
||||
pr_err("mmi_charger: Invalid charger enable value = %lu\n", mode);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
this_chip->force_charging_enabled = (mode) ? true : false;
|
||||
cancel_delayed_work(&this_chip->heartbeat_work);
|
||||
schedule_delayed_work(&this_chip->heartbeat_work, msecs_to_jiffies(0));
|
||||
mmi_info(this_chip, "%s force_charging_enabled\n", (mode)? "set" : "clear");
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(force_charging_enable, 0644,
|
||||
force_charging_enable_show,
|
||||
force_charging_enable_store);
|
||||
|
||||
static struct attribute * mmi_g[] = {
|
||||
&dev_attr_charge_rate.attr,
|
||||
&dev_attr_age.attr,
|
||||
|
|
@ -728,6 +775,11 @@ static void mmi_battery_supply_init(struct mmi_charger_chip *chip)
|
|||
if (rc)
|
||||
mmi_err(chip, "couldn't create force_charger_suspend\n");
|
||||
|
||||
rc = device_create_file(chip->batt_psy->dev.parent,
|
||||
&dev_attr_force_charging_enable);
|
||||
if (rc)
|
||||
mmi_err(chip, "couldn't create force_charging_enable\n");
|
||||
|
||||
mmi_info(chip, "battery supply is initialized\n");
|
||||
}
|
||||
|
||||
|
|
@ -1374,6 +1426,10 @@ static void mmi_configure_charger(struct mmi_charger_chip *chip,
|
|||
if (chip->force_charger_disabled || status->demo_chrg_suspend)
|
||||
cfg->charger_suspend = true;
|
||||
|
||||
if (chip->force_charging_enabled) {
|
||||
cfg->charging_disable = false;
|
||||
}
|
||||
|
||||
charger->driver->set_constraint(charger->driver->data, &charger->constraint);
|
||||
charger->driver->config_charge(charger->driver->data, cfg);
|
||||
|
||||
|
|
@ -2488,6 +2544,8 @@ static int mmi_charger_remove(struct platform_device *pdev)
|
|||
&dev_attr_factory_charge_upper);
|
||||
device_remove_file(chip->batt_psy->dev.parent,
|
||||
&dev_attr_force_charger_suspend);
|
||||
device_remove_file(chip->batt_psy->dev.parent,
|
||||
&dev_attr_force_charging_enable);
|
||||
sysfs_remove_group(&chip->batt_psy->dev.kobj,
|
||||
&power_supply_mmi_attr_group);
|
||||
power_supply_put(chip->batt_psy);
|
||||
|
|
|
|||
Loading…
Reference in a new issue