David Collins | 073a2c329 | 2016-11-30 14:27:24 -0800 | [diff] [blame] | 1 | /* 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 | */ |
| 28 | enum 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 | */ |
| 45 | enum 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 | |
| 53 | enum pon_restart_reason { |
Lijuan Gao | 8bcfa3c | 2017-12-06 16:20:35 +0800 | [diff] [blame] | 54 | /* 0 ~ 31 for common defined features */ |
David Collins | 073a2c329 | 2016-11-30 14:27:24 -0800 | [diff] [blame] | 55 | 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 Gao | 8bcfa3c | 2017-12-06 16:20:35 +0800 | [diff] [blame] | 62 | |
| 63 | /* 32 ~ 63 for OEMs/ODMs secific features */ |
| 64 | PON_RESTART_REASON_OEM_MIN = 0x20, |
| 65 | PON_RESTART_REASON_OEM_MAX = 0x3f, |
David Collins | 073a2c329 | 2016-11-30 14:27:24 -0800 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | #ifdef CONFIG_INPUT_QPNP_POWER_ON |
| 69 | int qpnp_pon_system_pwr_off(enum pon_power_off_type type); |
| 70 | int qpnp_pon_is_warm_reset(void); |
| 71 | int qpnp_pon_trigger_config(enum pon_trigger_source pon_src, bool enable); |
| 72 | int qpnp_pon_wd_config(bool enable); |
| 73 | int qpnp_pon_set_restart_reason(enum pon_restart_reason reason); |
| 74 | bool qpnp_pon_check_hard_reset_stored(void); |
| 75 | |
| 76 | #else |
| 77 | static int qpnp_pon_system_pwr_off(enum pon_power_off_type type) |
| 78 | { |
| 79 | return -ENODEV; |
| 80 | } |
| 81 | static inline int qpnp_pon_is_warm_reset(void) { return -ENODEV; } |
| 82 | static inline int qpnp_pon_trigger_config(enum pon_trigger_source pon_src, |
| 83 | bool enable) |
| 84 | { |
| 85 | return -ENODEV; |
| 86 | } |
| 87 | int qpnp_pon_wd_config(bool enable) |
| 88 | { |
| 89 | return -ENODEV; |
| 90 | } |
| 91 | static inline int qpnp_pon_set_restart_reason(enum pon_restart_reason reason) |
| 92 | { |
| 93 | return -ENODEV; |
| 94 | } |
| 95 | static inline bool qpnp_pon_check_hard_reset_stored(void) |
| 96 | { |
| 97 | return false; |
| 98 | } |
| 99 | #endif |
| 100 | |
| 101 | #endif |