copper: Add support for fastboot and recovery keys
Change-Id: Ia430dd32c1a8211845afb3923f1bc34b85b47cf5
diff --git a/target/copper/init.c b/target/copper/init.c
index 7e9f2c6..a11e23b 100644
--- a/target/copper/init.c
+++ b/target/copper/init.c
@@ -39,7 +39,8 @@
#include <board.h>
#include <smem.h>
#include <baseband.h>
-
+#include <dev/keys.h>
+#include <pm8x41.h>
static unsigned int target_id;
@@ -57,6 +58,50 @@
#endif
}
+/* Return 1 if vol_up pressed */
+static int target_volume_up()
+{
+ uint8_t status = 0;
+ struct pm8x41_gpio gpio;
+
+ /* CDP vol_up seems to be always grounded. So gpio status is read as 0,
+ * whether key is pressed or not.
+ * Ignore volume_up key on CDP for now.
+ */
+ if (board_hardware_id() == HW_PLATFORM_SURF)
+ return 0;
+
+ /* Configure the GPIO */
+ gpio.direction = PM_GPIO_DIR_IN;
+ gpio.function = 0;
+ gpio.pull = PM_GPIO_PULL_UP_30;
+ gpio.vin_sel = 0;
+
+ pm8x41_gpio_config(5, &gpio);
+
+ /* Get status of P_GPIO_5 */
+ pm8x41_gpio_get(5, &status);
+
+ return !status; /* active low */
+}
+
+/* Return 1 if vol_down pressed */
+int target_volume_down()
+{
+ return pm8x41_vol_down_key_status();
+}
+
+static void target_keystatus()
+{
+ keys_init();
+
+ if(target_volume_down())
+ keys_post_event(KEY_VOLUMEDOWN, 1);
+
+ if(target_volume_up())
+ keys_post_event(KEY_VOLUMEUP, 1);
+}
+
void target_init(void)
{
uint32_t base_addr;
@@ -67,6 +112,8 @@
spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
+ target_keystatus();
+
/* Trying Slot 1*/
slot = 1;
base_addr = mmc_sdc_base[slot - 1];
@@ -91,7 +138,8 @@
/* Do any target specific intialization needed before entering fastboot mode */
void target_fastboot_init(void)
{
-
+ /* Set the BOOT_DONE flag in PM8921 */
+ pm8x41_set_boot_done();
}
/* Detect the target type */
@@ -109,3 +157,12 @@
else
board->baseband = BASEBAND_MSM;
}
+
+void target_serialno(unsigned char *buf)
+{
+ unsigned int serialno;
+ if (target_is_emmc_boot()) {
+ serialno = mmc_get_psn();
+ snprintf((char *)buf, 13, "%x", serialno);
+ }
+}