mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-10 22:40:54 -04:00
Add factory kill time debounce support
Add factory kill time debounce support to debounce the factory kill event for charger/usb online shake during boot in factory mode. Change-Id: I1ca70dbfebd1fa8555ca36dda2b7b6ab2dbc8a2d Signed-off-by: yanyh2 <yanyh2@motorola.com> Reviewed-on: https://gerrit.mot.com/2242975 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Zhenxin Xi <xizx@motorola.com> Submit-Approved: Jira Key
This commit is contained in:
parent
aa23f31c41
commit
dec0712199
1 changed files with 23 additions and 4 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include <linux/delay.h>
|
||||
#include <linux/mmi_wake_lock.h>
|
||||
#include <soc/qcom/mmi_boot_info.h>
|
||||
#include <linux/time64.h>
|
||||
|
||||
#include "mmi_charger.h"
|
||||
|
||||
|
|
@ -240,6 +241,7 @@ struct mmi_charger_chip {
|
|||
|
||||
struct mmi_vote suspend_charger_vote;
|
||||
struct mmi_vote disable_charging_vote;
|
||||
uint32_t factory_kill_debounce_ms;
|
||||
};
|
||||
|
||||
static int mmi_vote(struct mmi_vote *vote, const char *voter,
|
||||
|
|
@ -1958,7 +1960,7 @@ static void mmi_update_battery_status(struct mmi_charger_chip *chip)
|
|||
mmi_changed = true;
|
||||
chip->max_charger_rate = max_charger_rate;
|
||||
mmi_notify_charger_event(chip, NOTIFY_EVENT_TYPE_CHG_RATE);
|
||||
mmi_info(chip, "%s charger is detected\n",
|
||||
mmi_err(chip, "%s charger is detected\n",
|
||||
charge_rate[chip->max_charger_rate]);
|
||||
}
|
||||
|
||||
|
|
@ -2024,6 +2026,9 @@ static void mmi_charger_heartbeat_work(struct work_struct *work)
|
|||
struct mmi_charger_chip *chip = container_of(work,
|
||||
struct mmi_charger_chip,
|
||||
heartbeat_work.work);
|
||||
struct timespec64 now;
|
||||
static struct timespec64 start;
|
||||
uint32_t elapsed_ms;
|
||||
|
||||
/* Have not been resumed so wait another 100 ms */
|
||||
if (chip->suspended & IS_SUSPENDED) {
|
||||
|
|
@ -2066,13 +2071,22 @@ static void mmi_charger_heartbeat_work(struct work_struct *work)
|
|||
if (chip->max_charger_rate > MMI_POWER_SUPPLY_CHARGE_RATE_NONE) {
|
||||
mmi_dbg(chip, "Factory Kill Armed\n");
|
||||
chip->factory_kill_armed = true;
|
||||
ktime_get_real_ts64(&start);
|
||||
} else if (chip->factory_kill_armed && !factory_kill_disable) {
|
||||
mmi_warn(chip, "Factory kill power off\n");
|
||||
ktime_get_real_ts64(&now);
|
||||
elapsed_ms = (now.tv_sec - start.tv_sec) * 1000;
|
||||
elapsed_ms += (now.tv_nsec - start.tv_nsec) / 1000000;
|
||||
if (elapsed_ms < chip->factory_kill_debounce_ms) {
|
||||
mmi_err(chip, "Factory kill debounce elapsed_ms:%d\n",
|
||||
elapsed_ms);
|
||||
} else {
|
||||
mmi_err(chip, "Factory kill power off\n");
|
||||
#if (KERNEL_VERSION(5, 10, 0) > LINUX_VERSION_CODE) || defined(MMI_GKI_API_ALLOWANCE)
|
||||
orderly_poweroff(true);
|
||||
orderly_poweroff(true);
|
||||
#else
|
||||
kernel_power_off();
|
||||
kernel_power_off();
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
chip->factory_kill_armed = false;
|
||||
}
|
||||
|
|
@ -2575,6 +2589,11 @@ static int mmi_parse_dt(struct mmi_charger_chip *chip)
|
|||
chip->start_factory_kill_disabled =
|
||||
of_property_read_bool(node, "mmi,start-factory-kill-disabled");
|
||||
|
||||
rc = of_property_read_u32(node, "mmi,factory-kill-debounce-ms",
|
||||
&chip->factory_kill_debounce_ms);
|
||||
if (rc)
|
||||
chip->factory_kill_debounce_ms = 0;
|
||||
|
||||
rc = of_property_read_u32(node, "mmi,upper-limit-capacity",
|
||||
&chip->upper_limit_capacity);
|
||||
if (rc)
|
||||
|
|
|
|||
Loading…
Reference in a new issue