mdm9x15: Using gpio49 to read boot config5 as fastboot key
Boot config5 dip switch is used for a trigger to enter
fastboot for 9x15 MTP.
Change-Id: I031581c72feb3935e789750d7465b88d3bb350ab
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 2b7821f..fabccb1 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -107,7 +107,9 @@
extern int emmc_recovery_init(void);
-
+#if NO_KEYPAD_DRIVER
+extern int fastboot_trigger(void);
+#endif
static void ptentry_to_tag(unsigned **ptr, struct ptentry *ptn)
{
@@ -1204,11 +1206,7 @@
}
#if NO_KEYPAD_DRIVER
- /* With no keypad implementation, check the status of USB connection. */
- /* If USB is connected then go into fastboot mode. */
- usb_init = 1;
- udc_init(&surf_udc_device);
- if (usb_cable_status())
+ if (fastboot_trigger())
goto fastboot;
#endif
diff --git a/target/mdm9615/init.c b/target/mdm9615/init.c
index b98dcc3..3788bc3 100644
--- a/target/mdm9615/init.c
+++ b/target/mdm9615/init.c
@@ -66,6 +66,7 @@
extern void reboot(unsigned reboot_reason);
void update_ptable_apps_partitions(void);
void update_ptable_modem_partitions(void);
+extern int fake_key_get_state(void);
void target_init(void)
{
@@ -155,10 +156,14 @@
return uart_gsbi_id;
}
-uint32_t usb_cable_status(void) {
- //TODO: Implement
- uint32_t ret = 1;
- return ret;
+/*
+ * Return 1 to trigger to fastboot
+ */
+int fastboot_trigger(void) {
+ int ret;
+ ret = fake_key_get_state();
+ /* Want to trigger when dip switch is off */
+ return (!ret);
}
void update_ptable_modem_partitions(void)
diff --git a/target/mdm9615/keypad.c b/target/mdm9615/keypad.c
new file mode 100644
index 0000000..afbe879
--- /dev/null
+++ b/target/mdm9615/keypad.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011, 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 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 Code Aurora 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 BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 <reg.h>
+#include <platform/gpio.h>
+#include <platform/iomap.h>
+
+/*
+ * Fake keypad for 9x15
+ * Returns 1 if dip switch is on, 0 if off
+ */
+int fake_key_get_state(void)
+{
+ int ret;
+ /* GPIO 49 connects to Boot Config5 */
+ gpio_tlmm_config(49, 0, GPIO_OUTPUT, GPIO_PULL_DOWN,
+ GPIO_2MA, GPIO_ENABLE);
+
+ ret = readl(GPIO_IN_OUT_ADDR(49));
+ return ret;
+}
diff --git a/target/mdm9615/rules.mk b/target/mdm9615/rules.mk
index 6ab270b..605bc63 100644
--- a/target/mdm9615/rules.mk
+++ b/target/mdm9615/rules.mk
@@ -29,4 +29,5 @@
OBJS += \
$(LOCAL_DIR)/init.o \
- $(LOCAL_DIR)/atags.o
+ $(LOCAL_DIR)/atags.o \
+ $(LOCAL_DIR)/keypad.o