summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Fradkin <alexf@codeaurora.org>2016-06-16 16:23:18 +0300
committerLoic Poulain <loic.poulain@linaro.org>2018-06-11 16:53:23 +0200
commitb12a70c475895027eecae08d18247132a23f7e80 (patch)
tree484d16d398fea97afab733ce1dc641c81cce051c
parent3be1d459a546a24f2bf10b9551663a3e69a8214e (diff)
Enable proper SW/HW shutdown for Dragonboard 410cshutdown-keep
This fix behavior of shutdown: 1) when shutdown initiated from SW (e.g. shutdown 0 in Linux command line) device will shutdown and not automatically rebooted 2) when HW power button pressed for 10 seconds device will shutdown and not automatically rebooted Signed-off-by: Alex Fradkin <alexf@codeaurora.org> Change-Id: I73f9911a718366422caac31dcc22fe6c47f2e77b
-rw-r--r--dev/pmic/pm8x41/include/pm8x41.h3
-rw-r--r--dev/pmic/pm8x41/include/pm8x41_hw.h5
-rw-r--r--dev/pmic/pm8x41/pm8x41.c37
-rw-r--r--target/msm8916/init.c5
4 files changed, 50 insertions, 0 deletions
diff --git a/dev/pmic/pm8x41/include/pm8x41.h b/dev/pmic/pm8x41/include/pm8x41.h
index 6dfc10a7..0e384a91 100644
--- a/dev/pmic/pm8x41/include/pm8x41.h
+++ b/dev/pmic/pm8x41/include/pm8x41.h
@@ -219,6 +219,7 @@ void pm8x41_set_boot_done();
uint32_t pm8x41_v2_resin_status();
uint32_t pm8x41_resin_status();
void pm8x41_reset_configure(uint8_t);
+void pm8x41_powerkey_configure(uint8_t);
void pm8x41_v2_reset_configure(uint8_t);
int pm8x41_ldo_set_voltage(struct pm8x41_ldo *ldo, uint32_t voltage);
int pm8x41_ldo_control(struct pm8x41_ldo *ldo, uint8_t enable);
@@ -226,6 +227,8 @@ uint8_t pm8x41_get_pmic_rev();
uint8_t pm8x41_get_pon_reason();
uint8_t pm8x41_get_pon_poff_reason1();
uint8_t pm8x41_get_pon_poff_reason2();
+uint8_t pm8x41_get_pon_get_triggers();
+uint8_t pm8x41_get_pon_set_trigger(uint8_t trigger, bool enable);
uint32_t pm8x41_get_pwrkey_is_pressed();
void pm8x41_config_output_mpp(struct pm8x41_mpp *mpp);
void pm8x41_enable_mpp(struct pm8x41_mpp *mpp, enum mpp_en_ctl enable);
diff --git a/dev/pmic/pm8x41/include/pm8x41_hw.h b/dev/pmic/pm8x41/include/pm8x41_hw.h
index db4473c2..4b6efe31 100644
--- a/dev/pmic/pm8x41/include/pm8x41_hw.h
+++ b/dev/pmic/pm8x41/include/pm8x41_hw.h
@@ -75,12 +75,17 @@
#define PON_INT_EN_SET 0x815
#define PON_INT_LATCHED_STS 0x818
#define PON_INT_PENDING_STS 0x819
+#define PON_KPDPWR_N_RESET_S1_TIMER 0x840 /* bits 0:3 : S1_TIMER */
+#define PON_KPDPWR_N_RESET_S2_TIMER 0x841 /* bits 0:2 : S2_TIMER */
+#define PON_KPDPWR_N_RESET_S2_CTL 0x842 /* bit 0:3 : RESET_TYPE */
+#define PON_KPDPWR_N_RESET_S2_CTL2 0x843 /* bit 7: S2_RESET_EN */
#define PON_RESIN_N_RESET_S1_TIMER 0x844 /* bits 0:3 : S1_TIMER */
#define PON_RESIN_N_RESET_S2_TIMER 0x845 /* bits 0:2 : S2_TIMER */
#define PON_RESIN_N_RESET_S2_CTL 0x846 /* bit 7: S2_RESET_EN, bit 0:3 : RESET_TYPE */
#define PON_PS_HOLD_RESET_CTL 0x85A /* bit 7: S2_RESET_EN, bit 0:3 : RESET_TYPE */
#define PON_PS_HOLD_RESET_CTL2 0x85B
#define PMIC_WD_RESET_S2_CTL2 0x857
+#define PON_TRIGGER_EN 0x880
/* PON Peripheral register bit values */
#define RESIN_ON_INT_BIT 1
diff --git a/dev/pmic/pm8x41/pm8x41.c b/dev/pmic/pm8x41/pm8x41.c
index 9315f722..58a2ad04 100644
--- a/dev/pmic/pm8x41/pm8x41.c
+++ b/dev/pmic/pm8x41/pm8x41.c
@@ -353,6 +353,22 @@ void pm8x41_reset_configure(uint8_t reset_type)
REG_WRITE(PON_PS_HOLD_RESET_CTL2, BIT(S2_RESET_EN_BIT));
}
+void pm8x41_powerkey_configure(uint8_t reset_type)
+{
+ /* disable PS_HOLD_RESET */
+ REG_WRITE(PON_KPDPWR_N_RESET_S2_CTL2, 0x0);
+
+ /* Delay needed for disable to kick in. */
+ udelay(300);
+
+ /* configure reset type */
+ REG_WRITE(PON_KPDPWR_N_RESET_S2_CTL, reset_type);
+
+ /* enable PS_HOLD_RESET */
+ REG_WRITE(PON_KPDPWR_N_RESET_S2_CTL2, BIT(S2_RESET_EN_BIT));
+}
+
+
/*
* LDO set voltage, takes ldo name & voltage in UV as input
*/
@@ -491,6 +507,27 @@ uint8_t pm8x41_get_pon_poff_reason2()
return REG_READ(PON_POFF_REASON2);
}
+uint8_t pm8x41_get_pon_get_triggers()
+{
+ return REG_READ(PON_TRIGGER_EN);
+}
+
+uint8_t pm8x41_get_pon_set_trigger(uint8_t trigger, bool enable)
+{
+ uint8_t old_triggers = pm8x41_get_pon_get_triggers();
+ uint8_t new_triggers = old_triggers;
+
+ if (enable)
+ new_triggers |= trigger;
+ else
+ new_triggers &= ~trigger;
+
+ if (old_triggers != new_triggers)
+ REG_WRITE(PON_TRIGGER_EN,new_triggers);
+
+ return new_triggers;
+}
+
void pm8x41_enable_mvs(struct pm8x41_mvs *mvs, enum mvs_en_ctl enable)
{
ASSERT(mvs);
diff --git a/target/msm8916/init.c b/target/msm8916/init.c
index 4a2960ee..ac7e6663 100644
--- a/target/msm8916/init.c
+++ b/target/msm8916/init.c
@@ -196,6 +196,11 @@ void target_init(void)
ASSERT(0);
}
+ pm8x41_get_pon_set_trigger(CBLPWR_N,false);
+ pm8x41_get_pon_set_trigger(USB_CHG,false);
+ pm8x41_powerkey_configure(PON_PSHOLD_SHUTDOWN);
+ pm8x41_reset_configure(PON_PSHOLD_SHUTDOWN);
+
#if LONG_PRESS_POWER_ON
shutdown_detect();
#endif