qpnp-power-on: Print system timestamp on Power key event

Print system timestamp on Power key press and release events.
This would make debugging easy

Ported from: https://gerrit.mot.com/#/c/1320467/

Change-Id: I2c810e4b59c2d3bd8a705d407a339d9efe6fad3d
Reviewed-on: https://gerrit.mot.com/1320467
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Ryan Lattrel <ryanl@motorola.com>
Reviewed-by: Ling Jin <lingjin@motorola.com>
Submit-Approved: Jira Key
Reviewed-on: https://gerrit.mot.com/1456668
Reviewed-on: https://gerrit.mot.com/1509721
Reviewed-by: Wang Wang <wangwang1@lenovo.com>
This commit is contained in:
Ling Jin authored and Gilberto Gambugge committed 2023-06-01 00:47:05 -03:00
1 parent def7cd0482
commit e5b870ee13
1 file changed
+15
+15
View File
@@ -25,6 +25,7 @@
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/time.h>
#define PMIC_VER_8941 0x01
#define PMIC_VERSION_REG 0x0105
@@ -963,6 +964,9 @@ static int qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type)
uint pon_rt_sts;
u64 elapsed_us;
int rc;
struct timeval timestamp;
struct tm tm;
char buff[255];
cfg = qpnp_get_cfg(pon, pon_type);
if (!cfg)
@@ -989,6 +993,17 @@ static int qpnp_pon_input_dispatch(struct qpnp_pon *pon, u32 pon_type)
switch (cfg->pon_type) {
case PON_KPDPWR:
pon_rt_bit = QPNP_PON_KPDPWR_N_SET;
/* get the time stamp in readable format to print*/
do_gettimeofday(&timestamp);
time_to_tm((time_t)(timestamp.tv_sec), 0, &tm);
snprintf(buff, sizeof(buff),
"%u-%02d-%02d %02d:%02d:%02d UTC",
(int) tm.tm_year + 1900, tm.tm_mon + 1,
tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
pr_info("Report pwrkey %s event at: %s\n", pon_rt_bit &
pon_rt_sts ? "press" : "release", buff);
break;
case PON_RESIN:
pon_rt_bit = QPNP_PON_RESIN_N_SET;