Commit 9fe1f23c2bcb263a91a2044cb0105963844dcc06

Authored by Sanshan Zhang
Committed by Ye Li
1 parent dcba1e63bb

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>
(cherry picked from commit 4c60cba3a017b921aebb84dd1268c898e549c99a)
Signed-off-by: Ye Li <ye.li@nxp.com>

Showing 5 changed files with 206 additions and 0 deletions Side-by-side Diff

arch/arm/cpu/armv7/mx7ulp/soc.c
... ... @@ -362,4 +362,49 @@
362 362  
363 363 return boot_dev;
364 364 }
  365 +
  366 +#ifdef CONFIG_FSL_FASTBOOT
  367 +#ifdef CONFIG_SERIAL_TAG
  368 +void get_board_serial(struct tag_serialnr *serialnr)
  369 +{
  370 +
  371 + struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
  372 + struct fuse_bank *bank = &ocotp->bank[1];
  373 + struct fuse_bank1_regs *fuse =
  374 + (struct fuse_bank1_regs *)bank->fuse_regs;
  375 + serialnr->low = (fuse->cfg0 & 0xFFFF) + ((fuse->cfg1 & 0xFFFF) << 16);
  376 + serialnr->high = (fuse->cfg2 & 0xFFFF) + ((fuse->cfg3 & 0xFFFF) << 16);
  377 +}
  378 +#endif
  379 +#ifdef CONFIG_ANDROID_RECOVERY
  380 +/*
  381 + * check if the recovery filed is set by kernel, it can be set by kernel
  382 + * issue a command '# reboot recovery'
  383 + */
  384 +int recovery_check_and_clean_flag(void)
  385 +{
  386 +/*
  387 + * TODO: will implement this part after porting BCB
  388 + */
  389 + return 0;
  390 +}
  391 +#endif /*CONFIG_ANDROID_RECOVERY*/
  392 +/*
  393 + * check if the recovery field is set by kernel, it can be set by kernel
  394 + * issue a command '# reboot fastboot'
  395 + */
  396 +int fastboot_check_and_clean_flag(void)
  397 +{
  398 +/*
  399 + * TODO: will implement this part after porting BCB
  400 + */
  401 + return 0;
  402 +}
  403 +void fastboot_enable_flag(void)
  404 +{
  405 +/*
  406 + * TODO: will implement this part after porting BCB
  407 + */
  408 +}
  409 +#endif /*CONFIG_FSL_FASTBOOT*/
board/freescale/mx7ulp_evk/mx7ulp_evk.c
... ... @@ -14,6 +14,14 @@
14 14 #include <dm.h>
15 15 #include <asm/imx-common/video.h>
16 16  
  17 +#ifdef CONFIG_FSL_FASTBOOT
  18 +#include <fastboot.h>
  19 +#include <asm/imx-common/boot_mode.h>
  20 +#ifdef CONFIG_ANDROID_RECOVERY
  21 +#include <recovery.h>
  22 +#endif /*CONFIG_ANDROID_RECOVERY*/
  23 +#endif /*CONFIG_FASTBOOT*/
  24 +
17 25 DECLARE_GLOBAL_DATA_PTR;
18 26  
19 27 #define UART_PAD_CTRL (PAD_CTL_PUS_UP)
... ... @@ -204,4 +212,54 @@
204 212  
205 213 return 0;
206 214 }
  215 +
  216 +#ifdef CONFIG_FSL_FASTBOOT
  217 +void board_fastboot_setup(void)
  218 +{
  219 + switch (get_boot_device()) {
  220 +#if defined(CONFIG_FASTBOOT_STORAGE_MMC)
  221 + case SD1_BOOT:
  222 + case MMC1_BOOT:
  223 + if (!getenv("fastboot_dev"))
  224 + setenv("fastboot_dev", "mmc0");
  225 + if (!getenv("bootcmd"))
  226 + setenv("bootcmd", "boota mmc0");
  227 + break;
  228 +#endif /*CONFIG_FASTBOOT_STORAGE_MMC*/
  229 + default:
  230 + printf("unsupported boot devices\n");
  231 + break;
  232 + }
  233 +}
  234 +
  235 +#ifdef CONFIG_ANDROID_RECOVERY
  236 +int check_recovery_cmd_file(void)
  237 +{
  238 + int recovery_mode = 0;
  239 + recovery_mode = recovery_check_and_clean_flag();
  240 + return recovery_mode;
  241 +}
  242 +
  243 +void board_recovery_setup(void)
  244 +{
  245 + int bootdev = get_boot_device();
  246 + switch (bootdev) {
  247 +#if defined(CONFIG_FASTBOOT_STORAGE_MMC)
  248 + case SD1_BOOT:
  249 + case MMC1_BOOT:
  250 + if (!getenv("bootcmd_android_recovery"))
  251 + setenv("bootcmd_android_recovery", "boota mmc0 recovery");
  252 + break;
  253 +#endif /*CONFIG_FASTBOOT_STORAGE_MMC*/
  254 + default:
  255 + printf("Unsupported bootup device for recovery: dev: %d\n",
  256 + bootdev);
  257 + return;
  258 + }
  259 +
  260 + printf("setup env for recovery..\n");
  261 + setenv("bootcmd", "run bootcmd_android_recovery");
  262 +}
  263 +#endif /*CONFIG_ANDROID_RECOVERY*/
  264 +#endif /*CONFIG_FSL_FASTBOOT*/
configs/mx7ulp_evk_android_defconfig
  1 +CONFIG_ARM=y
  2 +CONFIG_ARCH_MX7ULP=y
  3 +CONFIG_TARGET_MX7ULP_EVK=y
  4 +CONFIG_DEFAULT_DEVICE_TREE="imx7ulp-evk-qspi"
  5 +CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx7ulp_evk/imximage.cfg"
  6 +CONFIG_FASTBOOT=y
  7 +CONFIG_BOARD_LATE_INIT=y
  8 +CONFIG_BOARD_EARLY_INIT_F=y
  9 +CONFIG_HUSH_PARSER=y
  10 +CONFIG_CMD_I2C=y
  11 +CONFIG_CMD_PING=y
  12 +CONFIG_CMD_DHCP=y
  13 +CONFIG_OF_CONTROL=y
  14 +CONFIG_DM=y
  15 +CONFIG_DM_GPIO=y
  16 +CONFIG_IMX_RGPIO2P=y
  17 +CONFIG_DM_I2C=y
  18 +CONFIG_SYS_I2C_IMX_LPI2C=y
  19 +CONFIG_PINCTRL=y
  20 +CONFIG_PINCTRL_IMX7ULP=y
  21 +CONFIG_DM_SERIAL=y
  22 +CONFIG_FSL_LPUART=y
  23 +CONFIG_CMD_MMC=y
  24 +CONFIG_DM_MMC=y
  25 +# CONFIG_DM_MMC_OPS is not set
  26 +# CONFIG_BLK is not set
  27 +CONFIG_DM_REGULATOR=y
  28 +CONFIG_DM_REGULATOR_FIXED=y
  29 +CONFIG_DM_REGULATOR_GPIO=y
  30 +CONFIG_CMD_GPIO=y
  31 +CONFIG_CMD_SF=y
  32 +CONFIG_FSL_QSPI=y
  33 +CONFIG_DM_SPI=y
  34 +CONFIG_DM_SPI_FLASH=y
  35 +CONFIG_SPI_FLASH=y
  36 +CONFIG_SPI_FLASH_MACRONIX=y
  37 +CONFIG_ULP_WATCHDOG=y
  38 +CONFIG_CMD_USB=y
  39 +CONFIG_USB=y
  40 +CONFIG_DM_USB=y
  41 +CONFIG_USB_EHCI_HCD=y
  42 +CONFIG_MXC_USB_OTG_HACTIVE=y
  43 +CONFIG_USB_STORAGE=y
  44 +CONFIG_VIDEO=y
include/configs/mx7ulp_evk.h
... ... @@ -248,5 +248,9 @@
248 248  
249 249 #define CONFIG_OF_SYSTEM_SETUP
250 250  
  251 +#if defined(CONFIG_FASTBOOT)
  252 +#include "mx7ulp_evk_android.h"
  253 +#endif
  254 +
251 255 #endif /* __CONFIG_H */
include/configs/mx7ulp_evk_android.h
  1 +
  2 +/*
  3 + * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
  4 + *
  5 + * SPDX-License-Identifier: GPL-2.0+
  6 + */
  7 +
  8 +#ifndef __MX7ULP_EVK_ANDROID_H
  9 +#define __MX7ULP_EVK_ANDROID_H
  10 +
  11 +#define CONFIG_CI_UDC
  12 +#define CONFIG_USBD_HS
  13 +#define CONFIG_USB_GADGET_DUALSPEED
  14 +
  15 +#define CONFIG_USB_GADGET
  16 +#define CONFIG_CMD_USB_MASS_STORAGE
  17 +#define CONFIG_USB_FUNCTION_MASS_STORAGE
  18 +#define CONFIG_USB_GADGET_DOWNLOAD
  19 +#define CONFIG_USB_GADGET_VBUS_DRAW 2
  20 +
  21 +#define CONFIG_G_DNL_VENDOR_NUM 0x18d1
  22 +#define CONFIG_G_DNL_PRODUCT_NUM 0x0d02
  23 +#define CONFIG_G_DNL_MANUFACTURER "FSL"
  24 +
  25 +#define CONFIG_CMD_FS_GENERIC
  26 +#define CONFIG_CMD_EXT4
  27 +#define CONFIG_CMD_EXT4_WRITE
  28 +
  29 +#define CONFIG_USB_FUNCTION_FASTBOOT
  30 +#define CONFIG_CMD_FASTBOOT
  31 +#define CONFIG_ANDROID_BOOT_IMAGE
  32 +#define CONFIG_FASTBOOT_FLASH
  33 +
  34 +#define CONFIG_FSL_FASTBOOT
  35 +#define CONFIG_ANDROID_RECOVERY
  36 +#define CONFIG_FASTBOOT_STORAGE_MMC
  37 +
  38 +#define CONFIG_CMD_BOOTA
  39 +#define CONFIG_SUPPORT_RAW_INITRD
  40 +#define CONFIG_SERIAL_TAG
  41 +
  42 +#undef CONFIG_EXTRA_ENV_SETTINGS
  43 +#undef CONFIG_BOOTCOMMAND
  44 +
  45 +#define CONFIG_EXTRA_ENV_SETTINGS \
  46 + "splashpos=m,m\0" \
  47 + "fdt_high=0xffffffff\0" \
  48 + "initrd_high=0xffffffff\0" \
  49 +
  50 +
  51 +#define CONFIG_FASTBOOT_BUF_ADDR CONFIG_SYS_LOAD_ADDR
  52 +#define CONFIG_FASTBOOT_BUF_SIZE 0x19000000
  53 +
  54 +
  55 +#endif