msm8960: msm8930: Enable PMIC GPIO based keypad.
Change-Id: Ic23ace4b6c04332d7601944af6cf3ed5ffc53e1b
diff --git a/dev/keys/gpio_keypad.c b/dev/keys/gpio_keypad.c
index f7a8673..efe0a02 100644
--- a/dev/keys/gpio_keypad.c
+++ b/dev/keys/gpio_keypad.c
@@ -2,7 +2,7 @@
* Copyright (c) 2009, Google Inc.
* All rights reserved.
*
- * Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -437,6 +437,58 @@
event_wait(&qwerty_keypad->full_scan);
}
+static enum handler_return
+scan_qwerty_gpio_keypad(struct timer *timer, time_t now, void *arg)
+{
+ int i=0;
+ int num =0;
+ uint8_t key_status;
+ struct qwerty_keypad_info *keypad = qwerty_keypad->keypad_info;
+
+ num = keypad->mapsize;
+
+ for(i=0; i < num; i++)
+ {
+ /*continue if not interested in key*/
+ if(!keypad->keymap[i])
+ continue;
+
+ /*read key gpio*/
+ keypad->key_gpio_get(keypad->gpiomap[i], &key_status);
+
+ /*Post event if key pressed*/
+ if(key_status)
+ {
+ keys_post_event(keypad->keymap[i], 1);
+ goto done;
+ }
+ }
+
+done:
+ event_signal(&qwerty_keypad->full_scan, false);
+ return INT_RESCHEDULE;
+}
+
+void ssbi_gpio_keypad_init(struct qwerty_keypad_info *qwerty_kp)
+{
+ int len;
+
+ len = sizeof(struct gpio_qwerty_kp);
+ qwerty_keypad = malloc(len);
+ ASSERT(qwerty_keypad);
+
+ memset(qwerty_keypad, 0, len);
+ qwerty_keypad->keypad_info = qwerty_kp;
+
+ event_init(&qwerty_keypad->full_scan, false, EVENT_FLAG_AUTOUNSIGNAL);
+ timer_initialize(&qwerty_keypad->timer);
+
+ timer_set_oneshot(&qwerty_keypad->timer, 0, scan_qwerty_gpio_keypad, NULL);
+
+ /* wait for the keypad to complete one full scan */
+ event_wait(&qwerty_keypad->full_scan);
+}
+
void pmic_write(unsigned address, unsigned data)
{
write_func wr_function = &i2c_ssbi_write_bytes;
diff --git a/dev/pmic/pm8921/include/dev/pm8921.h b/dev/pmic/pm8921/include/dev/pm8921.h
index e2c185b..bff76e9 100644
--- a/dev/pmic/pm8921/include/dev/pm8921.h
+++ b/dev/pmic/pm8921/include/dev/pm8921.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -37,6 +37,7 @@
#define PM_GPIO_DIR_BOTH (PM_GPIO_DIR_OUT | PM_GPIO_DIR_IN)
#define PM_GPIO_PULL_UP_30 0
+#define PM_GPIO_PULL_UP_1_5 1
#define PM_GPIO_PULL_UP_31_5 2
/* 1.5uA + 30uA boost */
#define PM_GPIO_PULL_UP_1_5_30 3