blob: 5944f0fd341424627a66500e3a9fb52d6e49585d [file] [log] [blame]
David Collins073a2c3292016-11-30 14:27:24 -08001/* Copyright (c) 2012-2015, 2017, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef QPNP_PON_H
14#define QPNP_PON_H
15
16#include <linux/errno.h>
17
18/**
19 * enum pon_trigger_source: List of PON trigger sources
20 * %PON_SMPL: PON triggered by SMPL - Sudden Momentary Power Loss
21 * %PON_RTC: PON triggered by RTC alarm
22 * %PON_DC_CHG: PON triggered by insertion of DC charger
23 * %PON_USB_CHG: PON triggered by insertion of USB
24 * %PON_PON1: PON triggered by other PMIC (multi-PMIC option)
25 * %PON_CBLPWR_N: PON triggered by power-cable insertion
26 * %PON_KPDPWR_N: PON triggered by long press of the power-key
27 */
28enum pon_trigger_source {
29 PON_SMPL = 1,
30 PON_RTC,
31 PON_DC_CHG,
32 PON_USB_CHG,
33 PON_PON1,
34 PON_CBLPWR_N,
35 PON_KPDPWR_N,
36};
37
38/**
39 * enum pon_power_off_type: Possible power off actions to perform
40 * %PON_POWER_OFF_RESERVED: Reserved, not used
41 * %PON_POWER_OFF_WARM_RESET: Reset the MSM but not all PMIC peripherals
42 * %PON_POWER_OFF_SHUTDOWN: Shutdown the MSM and PMIC completely
43 * %PON_POWER_OFF_HARD_RESET: Reset the MSM and all PMIC peripherals
44 */
45enum pon_power_off_type {
46 PON_POWER_OFF_RESERVED = 0x00,
47 PON_POWER_OFF_WARM_RESET = 0x01,
48 PON_POWER_OFF_SHUTDOWN = 0x04,
49 PON_POWER_OFF_HARD_RESET = 0x07,
50 PON_POWER_OFF_MAX_TYPE = 0x10,
51};
52
53enum pon_restart_reason {
Lijuan Gao8bcfa3c2017-12-06 16:20:35 +080054 /* 0 ~ 31 for common defined features */
David Collins073a2c3292016-11-30 14:27:24 -080055 PON_RESTART_REASON_UNKNOWN = 0x00,
56 PON_RESTART_REASON_RECOVERY = 0x01,
57 PON_RESTART_REASON_BOOTLOADER = 0x02,
58 PON_RESTART_REASON_RTC = 0x03,
59 PON_RESTART_REASON_DMVERITY_CORRUPTED = 0x04,
60 PON_RESTART_REASON_DMVERITY_ENFORCE = 0x05,
61 PON_RESTART_REASON_KEYS_CLEAR = 0x06,
Lijuan Gao8bcfa3c2017-12-06 16:20:35 +080062
63 /* 32 ~ 63 for OEMs/ODMs secific features */
64 PON_RESTART_REASON_OEM_MIN = 0x20,
65 PON_RESTART_REASON_OEM_MAX = 0x3f,
David Collins073a2c3292016-11-30 14:27:24 -080066};
67
68#ifdef CONFIG_INPUT_QPNP_POWER_ON
69int qpnp_pon_system_pwr_off(enum pon_power_off_type type);
70int qpnp_pon_is_warm_reset(void);
71int qpnp_pon_trigger_config(enum pon_trigger_source pon_src, bool enable);
72int qpnp_pon_wd_config(bool enable);
73int qpnp_pon_set_restart_reason(enum pon_restart_reason reason);
74bool qpnp_pon_check_hard_reset_stored(void);
75
76#else
77static int qpnp_pon_system_pwr_off(enum pon_power_off_type type)
78{
79 return -ENODEV;
80}
81static inline int qpnp_pon_is_warm_reset(void) { return -ENODEV; }
82static inline int qpnp_pon_trigger_config(enum pon_trigger_source pon_src,
83 bool enable)
84{
85 return -ENODEV;
86}
87int qpnp_pon_wd_config(bool enable)
88{
89 return -ENODEV;
90}
91static inline int qpnp_pon_set_restart_reason(enum pon_restart_reason reason)
92{
93 return -ENODEV;
94}
95static inline bool qpnp_pon_check_hard_reset_stored(void)
96{
97 return false;
98}
99#endif
100
101#endif