android_kernel_oneplus_msm8998/include/linux/input/qpnp-power-on.h
liochen 8148b9d900 Synchronize codes for OnePlus5 & 5T OxygenOS 9.0.0
kernel device tree source code for OnePlus 5 & 5T P device

Change-Id: I84f40e66833ea1ce30eb1d9a710d6e1529e9e637
2018-12-26 11:02:39 +08:00

154 lines
4.4 KiB
C

/* Copyright (c) 2012-2015, 2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef QPNP_PON_H
#define QPNP_PON_H
#include <linux/errno.h>
/**
* enum pon_trigger_source: List of PON trigger sources
* %PON_SMPL: PON triggered by SMPL - Sudden Momentary Power Loss
* %PON_RTC: PON triggered by RTC alarm
* %PON_DC_CHG: PON triggered by insertion of DC charger
* %PON_USB_CHG: PON triggered by insertion of USB
* %PON_PON1: PON triggered by other PMIC (multi-PMIC option)
* %PON_CBLPWR_N: PON triggered by power-cable insertion
* %PON_KPDPWR_N: PON triggered by long press of the power-key
*/
enum pon_trigger_source {
PON_SMPL = 1,
PON_RTC,
PON_DC_CHG,
PON_USB_CHG,
PON_PON1,
PON_CBLPWR_N,
PON_KPDPWR_N,
};
/**
* enum pon_power_off_type: Possible power off actions to perform
* %PON_POWER_OFF_RESERVED: Reserved, not used
* %PON_POWER_OFF_WARM_RESET: Reset the MSM but not all PMIC peripherals
* %PON_POWER_OFF_SHUTDOWN: Shutdown the MSM and PMIC completely
* %PON_POWER_OFF_HARD_RESET: Reset the MSM and all PMIC peripherals
*/
enum pon_power_off_type {
PON_POWER_OFF_RESERVED = 0x00,
PON_POWER_OFF_WARM_RESET = 0x01,
PON_POWER_OFF_SHUTDOWN = 0x04,
PON_POWER_OFF_HARD_RESET = 0x07,
PON_POWER_OFF_MAX_TYPE = 0x10,
};
struct qpnp_pon {
struct platform_device *pdev;
struct regmap *regmap;
struct input_dev *pon_input;
struct qpnp_pon_config *pon_cfg;
struct pon_regulator *pon_reg_cfg;
struct list_head list;
struct delayed_work bark_work;
struct delayed_work press_work;
struct work_struct up_work;
atomic_t press_count;
struct dentry *debugfs;
int pon_trigger_reason;
int pon_power_off_reason;
int num_pon_reg;
int num_pon_config;
u32 dbc_time_us;
u32 uvlo;
int warm_reset_poff_type;
int hard_reset_poff_type;
int shutdown_poff_type;
u16 base;
u8 subtype;
u8 pon_ver;
u8 warm_reset_reason1;
u8 warm_reset_reason2;
bool is_spon;
bool store_hard_reset_reason;
bool kpdpwr_dbc_enable;
ktime_t kpdpwr_last_release_time;
};
enum pon_restart_reason {
/* 0 ~ 31 for common defined features */
PON_RESTART_REASON_UNKNOWN = 0x00,
PON_RESTART_REASON_RECOVERY = 0x01,
PON_RESTART_REASON_BOOTLOADER = 0x02,
PON_RESTART_REASON_RTC = 0x03,
PON_RESTART_REASON_DMVERITY_CORRUPTED = 0x04,
PON_RESTART_REASON_DMVERITY_ENFORCE = 0x05,
PON_RESTART_REASON_KEYS_CLEAR = 0x06,
PON_RESTART_REASON_AGING = 0x07,
PON_RESTART_REASON_REBOOT = 0x10,
PON_RESTART_REASON_FACTORY = 0x11,
PON_RESTART_REASON_WLAN = 0x12,
PON_RESTART_REASON_RF = 0x13,
PON_RESTART_REASON_MOS = 0x14,
PON_RESTART_REASON_KERNEL = 0x15,
PON_RESTART_REASON_ANDROID = 0x16,
PON_RESTART_REASON_MODEM = 0x17,
PON_RESTART_REASON_PANIC = 0x18,
/* 32 ~ 63 for OEMs/ODMs secific features */
PON_RESTART_REASON_OEM_MIN = 0x20,
PON_RESTART_REASON_OEM_MAX = 0x3f,
};
/* Define OEM reboot mode magic*/
#define AGING_MODE 0x77665510
#define FACTORY_MODE 0x77665504
#define WLAN_MODE 0x77665505
#define RF_MODE 0x77665506
#define MOS_MODE 0x77665507
#define KERNEL_MODE 0x7766550d
#define ANDROID_MODE 0x7766550c
#define MODEM_MODE 0x7766550b
#define OEM_PANIC 0x77665518
#ifdef CONFIG_INPUT_QPNP_POWER_ON
int qpnp_pon_system_pwr_off(enum pon_power_off_type type);
int qpnp_pon_is_warm_reset(void);
int qpnp_pon_trigger_config(enum pon_trigger_source pon_src, bool enable);
int qpnp_pon_wd_config(bool enable);
int qpnp_pon_set_restart_reason(enum pon_restart_reason reason);
bool qpnp_pon_check_hard_reset_stored(void);
#else
static int qpnp_pon_system_pwr_off(enum pon_power_off_type type)
{
return -ENODEV;
}
static inline int qpnp_pon_is_warm_reset(void) { return -ENODEV; }
static inline int qpnp_pon_trigger_config(enum pon_trigger_source pon_src,
bool enable)
{
return -ENODEV;
}
int qpnp_pon_wd_config(bool enable)
{
return -ENODEV;
}
static inline int qpnp_pon_set_restart_reason(enum pon_restart_reason reason)
{
return -ENODEV;
}
static inline bool qpnp_pon_check_hard_reset_stored(void)
{
return false;
}
#endif
#endif