summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2017-03-02 11:35:49 +0800
committerYe Li <ye.li@nxp.com>2017-04-05 17:24:35 +0800
commit001798e98623b131898b0d9edad59d2b0fb3082d (patch)
tree085d18b49a3937113f47f72d5980ff3886f27112
parent63c2e1de37e1e24f35279f50efa5a330e2cb3d07 (diff)
downloadu-boot-imx-001798e98623b131898b0d9edad59d2b0fb3082d.zip
u-boot-imx-001798e98623b131898b0d9edad59d2b0fb3082d.tar.gz
u-boot-imx-001798e98623b131898b0d9edad59d2b0fb3082d.tar.bz2
MLK-14312 mx7ulp: Fix incorrect DTB modification after using USB
u-boot has feature that when booting for mfgtool, the u-boot will modify the DTB to disable SD 1.8v switch. But the judgement for mfgtool boot has a problem, it only checks whether the USB PHY power status is enabled. When a USB device (for example a USB ethernet) is used in u-boot, the power status is also enabled. So the u-boot incorrectly disable the SD 1.8v switch. The patch changes the get_boot_device to use the boot SW info provided by ROM. Only if it is a USB boot, we will start the DTB modification for SD. Signed-off-by: Ye Li <ye.li@nxp.com> (cherry picked from commit 1fb61cd80af59c39d1ca01d833f566628ba48f32)
-rw-r--r--arch/arm/cpu/armv7/mx7ulp/soc.c31
-rw-r--r--arch/arm/include/asm/arch-mx7ulp/imx-regs.h19
-rw-r--r--arch/arm/include/asm/imx-common/boot_mode.h4
3 files changed, 51 insertions, 3 deletions
diff --git a/arch/arm/cpu/armv7/mx7ulp/soc.c b/arch/arm/cpu/armv7/mx7ulp/soc.c
index 231759c..8ff8329 100644
--- a/arch/arm/cpu/armv7/mx7ulp/soc.c
+++ b/arch/arm/cpu/armv7/mx7ulp/soc.c
@@ -10,6 +10,7 @@
#include <asm/sections.h>
#include <asm/arch/sys_proto.h>
#include <asm/imx-common/hab.h>
+#include <asm/imx-common/boot_mode.h>
#include <fdt_support.h>
static char *get_reset_cause(char *);
@@ -304,8 +305,7 @@ int mmc_get_env_dev(void)
#ifdef CONFIG_OF_SYSTEM_SETUP
int ft_system_setup(void *blob, bd_t *bd)
{
-#if !defined(CONFIG_FSL_FASTBOOT) && defined(is_boot_from_usb)
- if (is_boot_from_usb()) {
+ if (get_boot_device() == USB_BOOT) {
int rc;
int nodeoff = fdt_path_offset(blob, "/ahb-bridge0@40000000/usdhc@40370000");
if (nodeoff < 0)
@@ -333,7 +333,32 @@ add:
}
}
}
-#endif
return 0;
}
#endif
+
+enum boot_device get_boot_device(void)
+{
+ struct bootrom_sw_info **p =
+ (struct bootrom_sw_info **)ROM_SW_INFO_ADDR;
+
+ enum boot_device boot_dev = SD1_BOOT;
+ u8 boot_type = (*p)->boot_dev_type;
+ u8 boot_instance = (*p)->boot_dev_instance;
+
+ switch (boot_type) {
+ case BOOT_TYPE_SD:
+ boot_dev = boot_instance + SD1_BOOT;
+ break;
+ case BOOT_TYPE_MMC:
+ boot_dev = boot_instance + MMC1_BOOT;
+ break;
+ case BOOT_TYPE_USB:
+ boot_dev = USB_BOOT;
+ break;
+ default:
+ break;
+ }
+
+ return boot_dev;
+}
diff --git a/arch/arm/include/asm/arch-mx7ulp/imx-regs.h b/arch/arm/include/asm/arch-mx7ulp/imx-regs.h
index ecc7218..ea71ffb 100644
--- a/arch/arm/include/asm/arch-mx7ulp/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx7ulp/imx-regs.h
@@ -10,6 +10,8 @@
#include <linux/sizes.h>
+#define ROM_SW_INFO_ADDR 0x000001E8
+
#define CAAM_SEC_SRAM_BASE (0x26000000)
#define CAAM_SEC_SRAM_SIZE (SZ_32K)
#define CAAM_SEC_SRAM_END (CAAM_SEC_SRAM_BASE + CAAM_SEC_SRAM_SIZE - 1)
@@ -1128,6 +1130,23 @@ struct usbphy_regs {
#define is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
#define disconnect_from_pc(void) writel(0x0, USBOTG0_RBASE + 0x140)
+/* Boot device type */
+#define BOOT_TYPE_SD 0x1
+#define BOOT_TYPE_MMC 0x2
+#define BOOT_TYPE_USB 0xf
+
+struct bootrom_sw_info {
+ u8 reserved_1;
+ u8 boot_dev_instance;
+ u8 boot_dev_type;
+ u8 reserved_2;
+ u32 core_freq;
+ u32 axi_freq;
+ u32 ddr_freq;
+ u32 rom_tick_freq;
+ u32 reserved_3[3];
+};
+
#endif
#endif /* _MX7ULP_REGS_H_*/
diff --git a/arch/arm/include/asm/imx-common/boot_mode.h b/arch/arm/include/asm/imx-common/boot_mode.h
index a8239f2..accfcf9 100644
--- a/arch/arm/include/asm/imx-common/boot_mode.h
+++ b/arch/arm/include/asm/imx-common/boot_mode.h
@@ -1,5 +1,7 @@
/*
* Copyright (C) 2012 Boundary Devices Inc.
+ * Copyright (C) 2015-2016 Freescale Semiconductor, Inc.
+ * Copyright 2017 NXP
*
* SPDX-License-Identifier: GPL-2.0+
*/
@@ -26,6 +28,7 @@ enum boot_device {
MMC4_BOOT,
NAND_BOOT,
QSPI_BOOT,
+ USB_BOOT,
UNKNOWN_BOOT,
BOOT_DEV_NUM = UNKNOWN_BOOT,
};
@@ -37,5 +40,6 @@ struct boot_mode {
void add_board_boot_modes(const struct boot_mode *p);
void boot_mode_apply(unsigned cfg_val);
+enum boot_device get_boot_device(void);
extern const struct boot_mode soc_boot_modes[];
#endif