Merge "[msm8660]: Add support to read status of specific GPIO pins for PM8058"
diff --git a/platform/msm8x60/include/platform/pmic.h b/platform/msm8x60/include/platform/pmic.h
index cb8ab3a..94f4b8f 100755
--- a/platform/msm8x60/include/platform/pmic.h
+++ b/platform/msm8x60/include/platform/pmic.h
@@ -83,4 +83,60 @@
#define GPIO24_GPIO_CNTRL (0x167)
#define GPIO25_GPIO_CNTRL (0x168)
+#define IRQ_BLOCK_SEL_USR_ADDR 0x1C0
+#define IRQ_STATUS_RT_USR_ADDR 0x1C3
+
+typedef enum
+{
+ /* Block 24 Interrupts */
+ PM_GPIO01_CHGED_ST_IRQ_ID = 192,
+ PM_GPIO02_CHGED_ST_IRQ_ID = 193,
+ PM_GPIO03_CHGED_ST_IRQ_ID = 194,
+ PM_GPIO04_CHGED_ST_IRQ_ID = 195,
+ PM_GPIO05_CHGED_ST_IRQ_ID = 196,
+ PM_GPIO06_CHGED_ST_IRQ_ID = 197,
+ PM_GPIO07_CHGED_ST_IRQ_ID = 198,
+ PM_GPIO08_CHGED_ST_IRQ_ID = 199,
+
+ /* Block 25 Interrupts */
+ PM_GPIO09_CHGED_ST_IRQ_ID = 200,
+ PM_GPIO10_CHGED_ST_IRQ_ID = 201,
+ PM_GPIO11_CHGED_ST_IRQ_ID = 202,
+ PM_GPIO12_CHGED_ST_IRQ_ID = 203,
+ PM_GPIO13_CHGED_ST_IRQ_ID = 204,
+ PM_GPIO14_CHGED_ST_IRQ_ID = 205,
+ PM_GPIO15_CHGED_ST_IRQ_ID = 206,
+ PM_GPIO16_CHGED_ST_IRQ_ID = 207,
+
+ /* Block 26 Interrupts */
+ PM_GPIO17_CHGED_ST_IRQ_ID = 208,
+ PM_GPIO18_CHGED_ST_IRQ_ID = 209,
+ PM_GPIO19_CHGED_ST_IRQ_ID = 210,
+ PM_GPIO20_CHGED_ST_IRQ_ID = 211,
+ PM_GPIO21_CHGED_ST_IRQ_ID = 212,
+ PM_GPIO22_CHGED_ST_IRQ_ID = 213,
+ PM_GPIO23_CHGED_ST_IRQ_ID = 214,
+ PM_GPIO24_CHGED_ST_IRQ_ID = 215,
+
+ /* Block 27 Interrupts */
+ PM_GPIO25_CHGED_ST_IRQ_ID = 216,
+ PM_GPIO26_CHGED_ST_IRQ_ID = 217,
+ PM_GPIO27_CHGED_ST_IRQ_ID = 218,
+ PM_GPIO28_CHGED_ST_IRQ_ID = 219,
+ PM_GPIO29_CHGED_ST_IRQ_ID = 220,
+ PM_GPIO30_CHGED_ST_IRQ_ID = 221,
+ PM_GPIO31_CHGED_ST_IRQ_ID = 222,
+ PM_GPIO32_CHGED_ST_IRQ_ID = 223,
+
+ /* Block 28 Interrupts */
+ PM_GPIO33_CHGED_ST_IRQ_ID = 224,
+ PM_GPIO34_CHGED_ST_IRQ_ID = 225,
+ PM_GPIO35_CHGED_ST_IRQ_ID = 226,
+ PM_GPIO36_CHGED_ST_IRQ_ID = 227,
+ PM_GPIO37_CHGED_ST_IRQ_ID = 228,
+ PM_GPIO38_CHGED_ST_IRQ_ID = 229,
+ PM_GPIO39_CHGED_ST_IRQ_ID = 230,
+ PM_GPIO40_CHGED_ST_IRQ_ID = 231,
+}pm_sec_gpio_irq_id_type;
+
#endif
diff --git a/platform/msm8x60/pmic.c b/platform/msm8x60/pmic.c
index 24c044e..1dd0c23 100755
--- a/platform/msm8x60/pmic.c
+++ b/platform/msm8x60/pmic.c
@@ -32,6 +32,12 @@
#include <platform/iomap.h>
#include <platform/pmic.h>
+#define TRUE 1
+#define FALSE 0
+
+#define PM_IRQ_ID_TO_BLOCK_INDEX(id) (uint8_t)(id / 8)
+#define PM_IRQ_ID_TO_BIT_MASK(id) (uint8_t)(1 << (id % 8))
+
typedef int (*pm8058_write_func) (unsigned char *, unsigned short,
unsigned short);
extern int pa1_ssbi2_write_bytes(unsigned char *buffer, unsigned short length,
@@ -48,6 +54,43 @@
}
+int pm8058_get_gpio_status( pm_sec_gpio_irq_id_type gpio_irq, bool *rt_status)
+{
+ unsigned block_index, reg_data, reg_mask;
+ int errFlag;
+
+ block_index = PM_IRQ_ID_TO_BLOCK_INDEX(gpio_irq);
+
+ /* select the irq block */
+ errFlag =pa1_ssbi2_write_bytes(&block_index,1,IRQ_BLOCK_SEL_USR_ADDR);
+ if(errFlag)
+ {
+ dprintf(INFO,"Device Timeout");
+ return 1;
+ }
+
+ /* read real time status */
+ errFlag =pa1_ssbi2_read_bytes(®_data,1,IRQ_STATUS_RT_USR_ADDR);
+ if(errFlag)
+ {
+ dprintf(INFO,"Device Timeout");
+ return 1;
+ }
+ reg_mask = PM_IRQ_ID_TO_BIT_MASK(gpio_irq);
+
+ if ((reg_data & reg_mask) == reg_mask )
+ {
+ /* The RT Status is high. */
+ *rt_status = TRUE;
+ }
+ else
+ {
+ /* The RT Status is low. */
+ *rt_status = FALSE;
+ }
+ return 0;
+}
+
/*PM8901*/
extern int pa2_ssbi2_write_bytes(unsigned char *buffer, unsigned short length,
unsigned short slave_addr);