From 260bfb6fa20c977982797af696f44fe174e28115 Mon Sep 17 00:00:00 2001
From: Alexey Firago <alexey_firago@mentor.com>
Date: Thu, 5 Mar 2015 13:59:34 +0300
Subject: [PATCH] test: nitrogen6x: fastboot: add reboot-bootloader support
Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
---
board/boundary/nitrogen6x/nitrogen6x.c | 37 ++++++++++++++++++++++++++++++++++
include/configs/nitrogen6x.h | 11 +++++++---
2 files changed, 45 insertions(+), 3 deletions(-)
@@ -1009,6 +1009,36 @@ static const struct boot_mode board_boot_modes[] = {
};
#endif
+#ifdef CONFIG_CMD_FASTBOOT
+#define SNVS_LPGPR 0x68
+#define ANDROID_FASTBOOT_FLAG (1 << 8)
+
+int fb_set_reboot_flag(void)
+{
+ u32 reg;
+ reg = readl(SNVS_BASE_ADDR + SNVS_LPGPR);
+ reg |= ANDROID_FASTBOOT_FLAG;
+ writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR);
+ return 0;
+}
+
+static int fb_check_and_clean_flag(void)
+{
+ int flag_set = 0;
+ u32 reg;
+
+ reg = readl(SNVS_BASE_ADDR + SNVS_LPGPR);
+ flag_set = !!(reg & ANDROID_FASTBOOT_FLAG);
+
+ /* clean it in case looping infinite here.... */
+ if (flag_set) {
+ reg &= ~ANDROID_FASTBOOT_FLAG;
+ writel(reg, SNVS_BASE_ADDR + SNVS_LPGPR);
+ }
+ return flag_set;
+}
+#endif
+
int misc_init_r(void)
{
#ifdef CONFIG_PREBOOT
@@ -1018,5 +1048,12 @@ int misc_init_r(void)
#ifdef CONFIG_CMD_BMODE
add_board_boot_modes(board_boot_modes);
#endif
+
+#ifdef CONFIG_CMD_FASTBOOT
+ if (fb_check_and_clean_flag())
+ setenv("fastboot_flag", "1");
+ else
+ setenv("fastboot_flag", "0");
+#endif
return 0;
}
@@ -268,10 +268,15 @@
"bootdevs=" CONFIG_DRIVE_TYPES "\0" \
"umsdevs=" CONFIG_UMSDEVS "\0" \
"console=ttymxc1\0" \
+ "fastboot_flag=0\0" \
"clearenv=if sf probe || sf probe || sf probe 1 ; then " \
"sf erase 0xc0000 0x2000 && " \
"echo restored environment to factory default ; fi\0" \
- "bootcmd=for dtype in ${bootdevs}" \
+ "bootcmd="\
+ "if test '1' -eq $fastboot_flag; then " \
+ "echo 'Entering fastboot'; fastboot; " \
+ "fi; " \
+ "for dtype in ${bootdevs}" \
"; do " \
"if itest.s \"xusb\" == \"x${dtype}\" ; then " \
"usb start ;" \
@@ -411,8 +416,8 @@
#define CONFIG_USB_GADGET_VBUS_DRAW 2
/* Netchip IDs */
-#define CONFIG_G_DNL_VENDOR_NUM 0x0525
-#define CONFIG_G_DNL_PRODUCT_NUM 0xa4a5
+#define CONFIG_G_DNL_VENDOR_NUM 0x18d1
+#define CONFIG_G_DNL_PRODUCT_NUM 0xd02
#define CONFIG_G_DNL_MANUFACTURER "Boundary"
#define CONFIG_CMD_FASTBOOT
--
1.9.1