Merge "target: rename splash screen display configuration functions"
diff --git a/dev/pmic/pm8x41/include/pm8x41.h b/dev/pmic/pm8x41/include/pm8x41.h
index 82d3c1d..8a5eaff 100644
--- a/dev/pmic/pm8x41/include/pm8x41.h
+++ b/dev/pmic/pm8x41/include/pm8x41.h
@@ -201,6 +201,7 @@
int pm8x41_ldo_control(struct pm8x41_ldo *ldo, uint8_t enable);
uint8_t pm8x41_get_pmic_rev();
uint8_t pm8x41_get_pon_reason();
+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);
uint8_t pm8x41_get_is_cold_boot();
diff --git a/dev/pmic/pm8x41/include/pm8x41_hw.h b/dev/pmic/pm8x41/include/pm8x41_hw.h
index 7664f37..672514a 100644
--- a/dev/pmic/pm8x41/include/pm8x41_hw.h
+++ b/dev/pmic/pm8x41/include/pm8x41_hw.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -81,6 +81,7 @@
/* PON Peripheral register bit values */
#define RESIN_ON_INT_BIT 1
+#define KPDPWR_ON_INT_BIT 0
#define RESIN_BARK_INT_BIT 4
#define S2_RESET_EN_BIT 7
diff --git a/dev/pmic/pm8x41/include/pm_vib.h b/dev/pmic/pm8x41/include/pm_vib.h
new file mode 100644
index 0000000..9b10327
--- /dev/null
+++ b/dev/pmic/pm8x41/include/pm_vib.h
@@ -0,0 +1,38 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __DEV_PMIC_VIB_VIBRATOR_H
+#define __DEV_PMIC_VIB_VIBRATOR_H
+
+#define QPNP_VIB_EN_CTL 0x1c046
+#define QPNP_VIB_VTG_CTL 0x1c041
+#define QPNP_VIB_VTG_SET_MASK 0x1F
+#define QPNP_VIB_DEFAULT_VTG_LVL 22
+
+void pm_vib_turn_on(void);
+void pm_vib_turn_off(void);
+#endif/* __DEV_PMIC_VIB_VIBRATOR_H */
diff --git a/dev/pmic/pm8x41/pm8x41.c b/dev/pmic/pm8x41/pm8x41.c
index 4ea7643..2c14d3b 100644
--- a/dev/pmic/pm8x41/pm8x41.c
+++ b/dev/pmic/pm8x41/pm8x41.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -219,6 +219,19 @@
return (rt_sts & BIT(RESIN_ON_INT_BIT));
}
+/* Return 1 if power key is pressed */
+uint32_t pm8x41_get_pwrkey_is_pressed()
+{
+ uint8_t pwr_sts = 0;
+
+ pwr_sts = REG_READ(PON_INT_RT_STS);
+
+ if (pwr_sts & BIT(KPDPWR_ON_INT_BIT))
+ return 1;
+ else
+ return 0;
+}
+
void pm8x41_v2_reset_configure(uint8_t reset_type)
{
uint8_t val;
diff --git a/dev/pmic/pm8x41/pm8x41_vib.c b/dev/pmic/pm8x41/pm8x41_vib.c
new file mode 100644
index 0000000..7dbba77
--- /dev/null
+++ b/dev/pmic/pm8x41/pm8x41_vib.c
@@ -0,0 +1,60 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <bits.h>
+#include <debug.h>
+#include <reg.h>
+#include <pm8x41.h>
+#include <pm_vib.h>
+
+#define QPNP_VIB_EN BIT(7)
+
+/* Turn on vibrator */
+void pm_vib_turn_on(void)
+{
+ uint8_t val;
+
+ val = pm8x41_reg_read(QPNP_VIB_VTG_CTL);
+ val &= ~QPNP_VIB_VTG_SET_MASK;
+ val |= (QPNP_VIB_DEFAULT_VTG_LVL & QPNP_VIB_VTG_SET_MASK);
+ pm8x41_reg_write(QPNP_VIB_VTG_CTL, val);
+
+ val = pm8x41_reg_read(QPNP_VIB_EN_CTL);
+ val |= QPNP_VIB_EN;
+ pm8x41_reg_write(QPNP_VIB_EN_CTL, val);
+}
+
+/* Turn off vibrator */
+void pm_vib_turn_off(void)
+{
+ uint8_t val;
+
+ val = pm8x41_reg_read(QPNP_VIB_EN_CTL);
+ val &= ~QPNP_VIB_EN;
+ pm8x41_reg_write(QPNP_VIB_EN_CTL, val);
+}
diff --git a/dev/pmic/pm8x41/rules.mk b/dev/pmic/pm8x41/rules.mk
index 1cecf27..3713a4e 100644
--- a/dev/pmic/pm8x41/rules.mk
+++ b/dev/pmic/pm8x41/rules.mk
@@ -6,3 +6,8 @@
$(LOCAL_DIR)/pm8x41.o \
$(LOCAL_DIR)/pm8x41_adc.o \
$(LOCAL_DIR)/pm8x41_wled.o
+
+ifeq ($(ENABLE_PON_VIB_SUPPORT),true)
+OBJS += \
+ $(LOCAL_DIR)/pm8x41_vib.o
+endif
diff --git a/dev/vib/include/vibrator.h b/dev/vib/include/vibrator.h
new file mode 100644
index 0000000..d6fb8bf
--- /dev/null
+++ b/dev/vib/include/vibrator.h
@@ -0,0 +1,37 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef __DEV_VIB_VIBRATOR_H
+#define __DEV_VIB_VIBRATOR_H
+
+#define VIB_TIMER_DEFAULT_TIMEOUT 250
+
+void vib_turn_on(void);
+void vib_turn_off(void);
+void vib_timed_turn_on(const uint32_t);
+void wait_vib_timeout(void);
+#endif /* __DEV_VIB_VIBRATOR_H */
diff --git a/dev/vib/rules.mk b/dev/vib/rules.mk
new file mode 100644
index 0000000..e9e1d10
--- /dev/null
+++ b/dev/vib/rules.mk
@@ -0,0 +1,6 @@
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+INCLUDES += -I$(LOCAL_DIR)/include
+
+OBJS += \
+ $(LOCAL_DIR)/vibrator.o
diff --git a/dev/vib/vibrator.c b/dev/vib/vibrator.c
new file mode 100644
index 0000000..e8cb8c7
--- /dev/null
+++ b/dev/vib/vibrator.c
@@ -0,0 +1,83 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <debug.h>
+#include <reg.h>
+#include <stdlib.h>
+#include <kernel/timer.h>
+#include <platform/timer.h>
+#include <vibrator.h>
+#include <pm_vib.h>
+
+#define CHECK_VIB_TIMER_FREQUENCY 50
+
+static struct timer vib_timer;
+static uint32_t vib_timeout;
+
+/* Function to turn on vibrator */
+void vib_turn_on()
+{
+ pm_vib_turn_on();
+}
+
+/* Function to turn off vibrator */
+void vib_turn_off()
+{
+ pm_vib_turn_off();
+}
+
+/* Function to turn off vibrator when the vib_timer is expired. */
+static enum handler_return vib_timer_func(struct timer *v_timer, void *arg)
+{
+ timer_cancel(&vib_timer);
+ vib_turn_off();
+ vib_timeout=1;
+
+ return INT_RESCHEDULE;
+}
+
+/*
+ * Function to turn on vibrator.
+ * vibrate_time - the time of phone vibrate.
+ */
+void vib_timed_turn_on(const uint32_t vibrate_time)
+{
+ vib_turn_on();
+ vib_timeout=0;
+ timer_initialize(&vib_timer);
+ timer_set_oneshot(&vib_timer, vibrate_time, vib_timer_func, NULL);
+}
+
+/* Wait for vibrator timer expired */
+void wait_vib_timeout(void)
+{
+ while (!vib_timeout) {
+ /* every 50ms to check if the vibrator timer is timeout*/
+ thread_sleep(CHECK_VIB_TIMER_FREQUENCY);
+ }
+}
diff --git a/platform/msm_shared/debug.c b/platform/msm_shared/debug.c
index 3349db7..28c053e 100644
--- a/platform/msm_shared/debug.c
+++ b/platform/msm_shared/debug.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
- * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -39,6 +39,10 @@
#include <platform/timer.h>
#include <platform.h>
+#if PON_VIB_SUPPORT
+#include <vibrator.h>
+#endif
+
static void write_dcc(char c)
{
uint32_t timeout = 10;
@@ -134,6 +138,9 @@
void platform_halt(void)
{
+#if PON_VIB_SUPPORT
+ vib_turn_off();
+#endif
if (set_download_mode(NORMAL_DLOAD) == 0)
{
dprintf(CRITICAL, "HALT: reboot into dload mode...\n");
diff --git a/platform/msm_shared/include/shutdown_detect.h b/platform/msm_shared/include/shutdown_detect.h
new file mode 100644
index 0000000..23690c9
--- /dev/null
+++ b/platform/msm_shared/include/shutdown_detect.h
@@ -0,0 +1,33 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __PLATFORM_MSM_SHARED_SHUTDOWN_DETECT_H
+#define __PLATFORM_MSM_SHARED_SHUTDOWN_DETECT_H
+
+void shutdown_detect(void);
+#endif /* __PLATFORM_MSM_SHARED_SHUTDOWN_DETECT_H */
diff --git a/platform/msm_shared/rules.mk b/platform/msm_shared/rules.mk
index 7f48e01..632de53 100755
--- a/platform/msm_shared/rules.mk
+++ b/platform/msm_shared/rules.mk
@@ -132,7 +132,8 @@
$(LOCAL_DIR)/crypto5_wrapper.o \
$(LOCAL_DIR)/dev_tree.o \
$(LOCAL_DIR)/gpio.o \
- $(LOCAL_DIR)/dload_util.o
+ $(LOCAL_DIR)/dload_util.o \
+ $(LOCAL_DIR)/shutdown_detect.o
endif
ifeq ($(PLATFORM),mpq8092)
diff --git a/platform/msm_shared/shutdown_detect.c b/platform/msm_shared/shutdown_detect.c
new file mode 100644
index 0000000..a51c9ae
--- /dev/null
+++ b/platform/msm_shared/shutdown_detect.c
@@ -0,0 +1,160 @@
+/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <debug.h>
+#include <reg.h>
+#include <stdlib.h>
+#include <pm8x41.h>
+#include <pm8x41_hw.h>
+#include <kernel/timer.h>
+#include <platform/timer.h>
+#include <shutdown_detect.h>
+
+/* sleep clock is 32.768 khz, 0x8000 count per second */
+#define MPM_SLEEP_TIMETICK_COUNT 0x8000
+#define PWRKEY_LONG_PRESS_COUNT 0xC000
+#define QPNP_DEFAULT_TIMEOUT 250
+#define PWRKEY_DETECT_FREQUENCY 50
+
+static struct timer pon_timer;
+static uint32_t pon_timer_complete = 0;
+
+/*
+ * Function to check if the the power key is pressed long enough.
+ * Return 0 if boot time more than PWRKEY_LONG_PRESS_COUNT.
+ * Return 1 if boot time less than PWRKEY_LONG_PRESS_COUNT.
+ */
+static uint32_t is_pwrkey_time_expired()
+{
+ /* power on button tied in with PMIC KPDPWR. */
+ uint32_t sclk_count = platform_get_sclk_count();
+
+ /* Here check if the long press power-key lasts for 1.5s */
+ if (sclk_count > PWRKEY_LONG_PRESS_COUNT)
+ return 0;
+ else
+ return 1;
+}
+
+/*
+ * Function to check if the power on reason is power key triggered.
+ * Return 1 if it is triggered by power key.
+ * Return 0 if it is not triggered by power key.
+ */
+static uint32_t is_pwrkey_pon_reason()
+{
+ uint8_t pon_reason = pm8x41_get_pon_reason();
+
+ if (pm8x41_get_is_cold_boot() && (pon_reason == KPDPWR_N))
+ return 1;
+ else
+ return 0;
+}
+
+/*
+ * Main timer handle: check every PWRKEY_DETECT_FREQUENCY to see
+ * if power key is pressed.
+ * Shutdown the device if power key is release before
+ * (PWRKEY_LONG_PRESS_COUNT/MPM_SLEEP_TIMETICK_COUNT) seconds.
+ */
+static enum handler_return long_press_pwrkey_timer_func(struct timer *p_timer,
+ void *arg)
+{
+ uint32_t sclk_count = platform_get_sclk_count();
+
+ /*
+ * The following condition is treated as the power key
+ * is pressed long enough.
+ * 1. if the power key is pressed last for PWRKEY_LONG_PRESS_COUNT.
+ */
+ if (sclk_count > PWRKEY_LONG_PRESS_COUNT) {
+ timer_cancel(p_timer);
+ pon_timer_complete = 1;
+ } else {
+ if (pm8x41_get_pwrkey_is_pressed()) {
+ /*
+ * For normal man response is > 0.1 secs, so we use 0.05 secs default
+ * for software to be safely detect if there is a key release action.
+ */
+ timer_set_oneshot(p_timer, PWRKEY_DETECT_FREQUENCY,
+ long_press_pwrkey_timer_func, NULL);
+ } else {
+ shutdown_device();
+ }
+ }
+
+ return INT_RESCHEDULE;
+}
+
+/*
+ * Function to wait until the power key is pressed long enough
+ */
+static void wait_for_long_pwrkey_pressed()
+{
+ uint32_t sclk_count = 0;
+
+ while (!pon_timer_complete) {
+ sclk_count = platform_get_sclk_count();
+ if (sclk_count > PWRKEY_LONG_PRESS_COUNT) {
+ timer_cancel(&pon_timer);
+ break;
+ }
+ }
+}
+
+/*
+ * Function to support for shutdown detection
+ * If below condition is met, the function will shut down
+ * the device. Otherwise it will do nothing and return to
+ * normal boot.
+ * condition:
+ * 1. it is triggered by power key &&
+ * 2. the power key is released before
+ * (PWRKEY_LONG_PRESS_COUNT/MPM_SLEEP_TIMETICK_COUNT) seconds.
+ */
+void shutdown_detect()
+{
+ /*
+ * If it is booted by power key tirigger.
+ * Initialize pon_timer and call long_press_pwrkey_timer_func
+ * function to check if the power key is last press long enough.
+ */
+ if (is_pwrkey_pon_reason() && is_pwrkey_time_expired()) {
+ timer_initialize(&pon_timer);
+ timer_set_oneshot(&pon_timer, 0, long_press_pwrkey_timer_func, NULL);
+
+ /*
+ * Wait until long press power key timeout
+ *
+ * It will be confused to end users if we shutdown the device
+ * after the splash screen displayed. But it can be moved the
+ * wait here if the boot time is much more considered.
+ */
+ wait_for_long_pwrkey_pressed();
+ }
+}
diff --git a/project/msm8226.mk b/project/msm8226.mk
index 1e94e03..2c97294 100644
--- a/project/msm8226.mk
+++ b/project/msm8226.mk
@@ -10,6 +10,9 @@
EMMC_BOOT := 1
ENABLE_SDHCI_SUPPORT := 1
+#enable power on vibrator feature
+ENABLE_PON_VIB_SUPPORT := true
+
#DEFINES += WITH_DEBUG_DCC=1
DEFINES += WITH_DEBUG_UART=1
DEFINES += WITH_DEBUG_LOG_BUF=1
@@ -26,6 +29,10 @@
#Disable thumb mode
ENABLE_THUMB := false
+ifeq ($(ENABLE_PON_VIB_SUPPORT),true)
+DEFINES += PON_VIB_SUPPORT=1
+endif
+
ifeq ($(ENABLE_SDHCI_SUPPORT),1)
DEFINES += MMC_SDHCI_SUPPORT=1
endif
diff --git a/target/msm8226/init.c b/target/msm8226/init.c
index 3c2bc74..484706a 100644
--- a/target/msm8226/init.c
+++ b/target/msm8226/init.c
@@ -48,6 +48,8 @@
#include <scm.h>
#include <stdlib.h>
#include <partition_parser.h>
+#include <shutdown_detect.h>
+#include <vibrator.h>
extern bool target_use_signed_kernel(void);
static void set_sdc_power_ctrl(void);
@@ -65,6 +67,7 @@
#define CRYPTO_ENGINE_CMD_ARRAY_SIZE 20
#define TLMM_VOL_UP_BTN_GPIO 106
+#define VIBRATE_TIME 250
#define SSD_CE_INSTANCE 1
@@ -247,6 +250,11 @@
target_sdc_init();
+ shutdown_detect();
+
+ /* turn on vibrator to indicate that phone is booting up to end user */
+ vib_timed_turn_on(VIBRATE_TIME);
+
/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
dprintf(SPEW, "Display Init: Start\n");
@@ -369,6 +377,24 @@
dprintf(CRITICAL, "Rebooting failed\n");
}
+/* Configure PMIC and Drop PS_HOLD for shutdown */
+void shutdown_device()
+{
+ dprintf(CRITICAL, "Going down for shutdown.\n");
+
+ /* Configure PMIC for shutdown */
+ pm8x41_reset_configure(PON_PSHOLD_SHUTDOWN);
+
+ /* Drop PS_HOLD for MSM */
+ writel(0x00, MPM2_MPM_PS_HOLD);
+
+ mdelay(5000);
+
+ dprintf(CRITICAL, "shutdown failed\n");
+
+ ASSERT(0);
+}
+
crypto_engine_type board_ce_type(void)
{
return CRYPTO_ENGINE_TYPE_HW;
@@ -387,6 +413,9 @@
void target_uninit(void)
{
+ /* wait for the vibrator timer is expried */
+ wait_vib_timeout();
+
mmc_put_card_to_sleep(dev);
if (target_is_ssd_enabled())
diff --git a/target/msm8226/rules.mk b/target/msm8226/rules.mk
index f5c9596..3f9d1a3 100755
--- a/target/msm8226/rules.mk
+++ b/target/msm8226/rules.mk
@@ -26,6 +26,7 @@
dev/pmic/pm8x41 \
dev/panel/msm \
dev/gcdb/display \
+ dev/vib \
lib/libfdt
DEFINES += \