summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanshan Zhang <sanshan.zhang@nxp.com>2017-01-25 09:13:35 +0800
committerSanshan Zhang <sanshan.zhang@nxp.com>2017-01-25 13:37:01 +0800
commit4c60cba3a017b921aebb84dd1268c898e549c99a (patch)
tree90dcdf948a328824953045d5fd47738c4f4c4c09
parentaa3e2f4dc91bdc2df22f208bad0cd24414fe8a63 (diff)
downloadu-boot-imx-4c60cba3a017b921aebb84dd1268c898e549c99a.zip
u-boot-imx-4c60cba3a017b921aebb84dd1268c898e549c99a.tar.gz
u-boot-imx-4c60cba3a017b921aebb84dd1268c898e549c99a.tar.bz2
MA-9213 imx: mx7ulp-evk: Add android support
Add android features on i.MX7ULP EVK board. Implement the code to get boot device and the serial number on mx7ulp. TODO: will add the code which check misc partition after porting BCB. Change-Id: I9d06fecba303fa4dfdcaf73da1b6246444697bba Signed-off-by: Sanshan Zhang <sanshan.zhang@nxp.com>
-rw-r--r--arch/arm/cpu/armv7/mx7ulp/soc.c64
-rw-r--r--board/freescale/mx7ulp_evk/mx7ulp_evk.c70
-rw-r--r--configs/mx7ulp_evk_android_defconfig10
-rw-r--r--include/configs/mx7ulp_evk.h3
-rw-r--r--include/configs/mx7ulp_evk_android.h62
5 files changed, 209 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv7/mx7ulp/soc.c b/arch/arm/cpu/armv7/mx7ulp/soc.c
index 871dfcd..711fc75 100644
--- a/arch/arm/cpu/armv7/mx7ulp/soc.c
+++ b/arch/arm/cpu/armv7/mx7ulp/soc.c
@@ -10,6 +10,9 @@
#include <asm/arch/sys_proto.h>
#include <dm.h>
#include <asm/imx-common/hab.h>
+#ifdef CONFIG_FSL_FASTBOOT
+#include <asm/imx-common/boot_mode.h>
+#endif
#include <fdt_support.h>
struct lpuart_serial_platdata {
@@ -382,3 +385,64 @@ add:
return 0;
}
#endif
+
+
+#ifdef CONFIG_FSL_FASTBOOT
+enum boot_device get_boot_device(void)
+{
+ bool type;
+ u32 bt1_cfg = 0;
+ enum boot_device boot_dev = UNKNOWN_BOOT;
+
+ bt1_cfg = readl(CMC1_RBASE + 0x40);
+ type = (bt1_cfg >> 8) & 0x1;
+
+ if (type)
+ boot_dev = MMC1_BOOT;
+ else
+ boot_dev = SD1_BOOT;
+ return boot_dev;
+}
+#ifdef CONFIG_SERIAL_TAG
+void get_board_serial(struct tag_serialnr *serialnr)
+{
+
+ struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
+ struct fuse_bank *bank = &ocotp->bank[1];
+ struct fuse_bank1_regs *fuse =
+ (struct fuse_bank1_regs *)bank->fuse_regs;
+ serialnr->low = (fuse->cfg0 & 0xFFFF) + ((fuse->cfg1 & 0xFFFF) << 16);
+ serialnr->high = (fuse->cfg2 & 0xFFFF) + ((fuse->cfg3 & 0xFFFF) << 16);
+}
+#endif
+#ifdef CONFIG_ANDROID_RECOVERY
+/*
+ * check if the recovery filed is set by kernel, it can be set by kernel
+ * issue a command '# reboot recovery'
+ */
+int recovery_check_and_clean_flag(void)
+{
+/*
+ * TODO: will implement this part after porting BCB
+ */
+ return 0;
+}
+#endif /*CONFIG_ANDROID_RECOVERY*/
+/*
+ * check if the recovery field is set by kernel, it can be set by kernel
+ * issue a command '# reboot fastboot'
+ */
+int fastboot_check_and_clean_flag(void)
+{
+/*
+ * TODO: will implement this part after porting BCB
+ */
+ return 0;
+}
+void fastboot_enable_flag(void)
+{
+/*
+ * TODO: will implement this part after porting BCB
+ */
+}
+#endif /*CONFIG_FSL_FASTBOOT*/
diff --git a/board/freescale/mx7ulp_evk/mx7ulp_evk.c b/board/freescale/mx7ulp_evk/mx7ulp_evk.c
index 5ba35cf..76d2ca2 100644
--- a/board/freescale/mx7ulp_evk/mx7ulp_evk.c
+++ b/board/freescale/mx7ulp_evk/mx7ulp_evk.c
@@ -15,6 +15,14 @@
#include <mmc.h>
#include <usb.h>
+#ifdef CONFIG_FSL_FASTBOOT
+#include <fastboot.h>
+#include <asm/imx-common/boot_mode.h>
+#ifdef CONFIG_ANDROID_RECOVERY
+#include <recovery.h>
+#endif /*CONFIG_ANDROID_RECOVERY*/
+#endif /*CONFIG_FASTBOOT*/
+
DECLARE_GLOBAL_DATA_PTR;
#define ESDHC_PAD_CTRL (PAD_CTL_PUS_UP | PAD_CTL_DSE)
@@ -281,3 +289,65 @@ int checkboard(void)
return 0;
}
+
+#ifdef CONFIG_FSL_FASTBOOT
+void board_fastboot_setup(void)
+{
+ switch (get_boot_device()) {
+#if defined(CONFIG_FASTBOOT_STORAGE_MMC)
+ case SD1_BOOT:
+ case MMC1_BOOT:
+ if (!getenv("fastboot_dev"))
+ setenv("fastboot_dev", "mmc0");
+ if (!getenv("bootcmd"))
+ setenv("bootcmd", "boota mmc0");
+ break;
+ case SD3_BOOT:
+ case MMC3_BOOT:
+ if (!getenv("fastboot_dev"))
+ setenv("fastboot_dev", "mmc1");
+ if (!getenv("bootcmd"))
+ setenv("bootcmd", "boota mmc1");
+ break;
+#endif /*CONFIG_FASTBOOT_STORAGE_MMC*/
+ default:
+ printf("unsupported boot devices\n");
+ break;
+ }
+}
+
+#ifdef CONFIG_ANDROID_RECOVERY
+int check_recovery_cmd_file(void)
+{
+ int recovery_mode = 0;
+ recovery_mode = recovery_check_and_clean_flag();
+ return recovery_mode;
+}
+
+void board_recovery_setup(void)
+{
+ int bootdev = get_boot_device();
+ switch (bootdev) {
+#if defined(CONFIG_FASTBOOT_STORAGE_MMC)
+ case SD1_BOOT:
+ case MMC1_BOOT:
+ if (!getenv("bootcmd_android_recovery"))
+ setenv("bootcmd_android_recovery", "boota mmc0 recovery");
+ break;
+ case SD2_BOOT:
+ case MMC2_BOOT:
+ if (!getenv("bootcmd_android_recovery"))
+ setenv("bootcmd_android_recovery", "boota mmc1 recovery");
+ break;
+#endif /*CONFIG_FASTBOOT_STORAGE_MMC*/
+ default:
+ printf("Unsupported bootup device for recovery: dev: %d\n",
+ bootdev);
+ return;
+ }
+
+ printf("setup env for recovery..\n");
+ setenv("bootcmd", "run bootcmd_android_recovery");
+}
+#endif /*CONFIG_ANDROID_RECOVERY*/
+#endif /*CONFIG_FSL_FASTBOOT*/
diff --git a/configs/mx7ulp_evk_android_defconfig b/configs/mx7ulp_evk_android_defconfig
new file mode 100644
index 0000000..6b26259
--- /dev/null
+++ b/configs/mx7ulp_evk_android_defconfig
@@ -0,0 +1,10 @@
+CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx7ulp_evk/imximage.cfg,ANDROID_SUPPORT"
+CONFIG_ARM=y
+CONFIG_ARCH_MX7ULP=y
+CONFIG_TARGET_MX7ULP_EVK=y
+CONFIG_SYS_MALLOC_F=y
+CONFIG_SYS_MALLOC_F_LEN=0x400
+CONFIG_DM=y
+CONFIG_DM_SERIAL=y
+CONFIG_DM_GPIO=y
+CONFIG_IMX_RGPIO2P=y
diff --git a/include/configs/mx7ulp_evk.h b/include/configs/mx7ulp_evk.h
index c8a1eff..e58afdc 100644
--- a/include/configs/mx7ulp_evk.h
+++ b/include/configs/mx7ulp_evk.h
@@ -293,5 +293,8 @@
#endif
#define CONFIG_OF_SYSTEM_SETUP
+#if defined(CONFIG_ANDROID_SUPPORT)
+#include "mx7ulp_evk_android.h"
+#endif
#endif /* __CONFIG_H */
diff --git a/include/configs/mx7ulp_evk_android.h b/include/configs/mx7ulp_evk_android.h
new file mode 100644
index 0000000..eddb781
--- /dev/null
+++ b/include/configs/mx7ulp_evk_android.h
@@ -0,0 +1,62 @@
+
+/*
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef __MX7ULP_EVK_ANDROID_H
+#define __MX7ULP_EVK_ANDROID_H
+
+#define CONFIG_CI_UDC
+#define CONFIG_USBD_HS
+#define CONFIG_USB_GADGET_DUALSPEED
+
+#define CONFIG_USB_GADGET
+#define CONFIG_CMD_USB_MASS_STORAGE
+#define CONFIG_USB_FUNCTION_MASS_STORAGE
+#define CONFIG_USB_GADGET_DOWNLOAD
+#define CONFIG_USB_GADGET_VBUS_DRAW 2
+
+#define CONFIG_G_DNL_VENDOR_NUM 0x18d1
+#define CONFIG_G_DNL_PRODUCT_NUM 0x0d02
+#define CONFIG_G_DNL_MANUFACTURER "FSL"
+
+#define CONFIG_CMD_FS_GENERIC
+#define CONFIG_CMD_EXT4
+#define CONFIG_CMD_EXT4_WRITE
+
+#define CONFIG_USB_FUNCTION_FASTBOOT
+#define CONFIG_CMD_FASTBOOT
+#define CONFIG_ANDROID_BOOT_IMAGE
+#define CONFIG_FASTBOOT_FLASH
+
+#define CONFIG_FSL_FASTBOOT
+#define CONFIG_ANDROID_RECOVERY
+#define CONFIG_FASTBOOT_STORAGE_MMC
+
+#define CONFIG_ANDROID_MAIN_MMC_BUS 2
+#define CONFIG_ANDROID_BOOT_PARTITION_MMC 1
+#define CONFIG_ANDROID_SYSTEM_PARTITION_MMC 5
+#define CONFIG_ANDROID_RECOVERY_PARTITION_MMC 2
+#define CONFIG_ANDROID_CACHE_PARTITION_MMC 6
+#define CONFIG_ANDROID_DATA_PARTITION_MMC 4
+
+#define CONFIG_CMD_BOOTA
+#define CONFIG_SUPPORT_RAW_INITRD
+#define CONFIG_SERIAL_TAG
+
+#undef CONFIG_EXTRA_ENV_SETTINGS
+#undef CONFIG_BOOTCOMMAND
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+ "splashpos=m,m\0" \
+ "fdt_high=0xffffffff\0" \
+ "initrd_high=0xffffffff\0" \
+
+
+#define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR
+#define CONFIG_FASTBOOT_BUF_SIZE 0x19000000
+
+
+#endif