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 { |
| 54 | PON_RESTART_REASON_UNKNOWN = 0x00, |
| 55 | PON_RESTART_REASON_RECOVERY = 0x01, |
| 56 | PON_RESTART_REASON_BOOTLOADER = 0x02, |
| 57 | PON_RESTART_REASON_RTC = 0x03, |
| 58 | PON_RESTART_REASON_DMVERITY_CORRUPTED = 0x04, |
| 59 | PON_RESTART_REASON_DMVERITY_ENFORCE = 0x05, |
| 60 | PON_RESTART_REASON_KEYS_CLEAR = 0x06, |
| 61 | }; |
| 62 | |
| 63 | #ifdef CONFIG_INPUT_QPNP_POWER_ON |
| 64 | int qpnp_pon_system_pwr_off(enum pon_power_off_type type); |
| 65 | int qpnp_pon_is_warm_reset(void); |
| 66 | int qpnp_pon_trigger_config(enum pon_trigger_source pon_src, bool enable); |
| 67 | int qpnp_pon_wd_config(bool enable); |
| 68 | int qpnp_pon_set_restart_reason(enum pon_restart_reason reason); |
| 69 | bool qpnp_pon_check_hard_reset_stored(void); |
| 70 | |
| 71 | #else |
| 72 | static int qpnp_pon_system_pwr_off(enum pon_power_off_type type) |
| 73 | { |
| 74 | return -ENODEV; |
| 75 | } |
| 76 | static inline int qpnp_pon_is_warm_reset(void) { return -ENODEV; } |
| 77 | static inline int qpnp_pon_trigger_config(enum pon_trigger_source pon_src, |
| 78 | bool enable) |
| 79 | { |
| 80 | return -ENODEV; |
| 81 | } |
| 82 | int qpnp_pon_wd_config(bool enable) |
| 83 | { |
| 84 | return -ENODEV; |
| 85 | } |
| 86 | static inline int qpnp_pon_set_restart_reason(enum pon_restart_reason reason) |
| 87 | { |
| 88 | return -ENODEV; |
| 89 | } |
| 90 | static inline bool qpnp_pon_check_hard_reset_stored(void) |
| 91 | { |
| 92 | return false; |
| 93 | } |
| 94 | #endif |
| 95 | |
| 96 | #endif |