dev: pmic: Add power key detection support
Add one function: pm8x41_get_pwrkey_is_pressed to detect if
power key is pressed or not.
Change-Id: Id86070e4c03e82d73cf0e6e1912809cb83ad2236
diff --git a/dev/pmic/pm8x41/pm8x41.c b/dev/pmic/pm8x41/pm8x41.c
index b846d9c..1e9f16c 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;