diff --git a/arch/arm/include/asm/arch-mx5/sys_proto.h b/arch/arm/include/asm/arch-mx5/sys_proto.h index c8aff2b65dc9db22bb6ebdac081f2824cba73703..e94b7da9919393db6cf8fa28e33f0212d90e5e62 100644 --- a/arch/arm/include/asm/arch-mx5/sys_proto.h +++ b/arch/arm/include/asm/arch-mx5/sys_proto.h @@ -8,4 +8,5 @@ #include <asm/mach-imx/sys_proto.h> +bool is_usb_boot(void); #endif /* __SYS_PROTO_IMX5_ */ diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h index 4bf7dff8b4d0f93b13af81266eb916eece338e82..a38841605863347826b4c880c50368c4808aae2d 100644 --- a/arch/arm/include/asm/arch-mx6/sys_proto.h +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h @@ -30,4 +30,5 @@ static inline void iomuxc_set_rgmii_io_voltage(int io_vol) __raw_writel(io_vol, IOMUXC_SW_PAD_CTL_GRP_DDR_TYPE_RGMII); } +bool is_usb_boot(void); #endif /* __SYS_PROTO_IMX6_ */ diff --git a/arch/arm/include/asm/arch-mx7/sys_proto.h b/arch/arm/include/asm/arch-mx7/sys_proto.h index e46a02198d663aeb06d213f4523204b068009369..42663a4388799b6dd2329e0b0a778532763edfda 100644 --- a/arch/arm/include/asm/arch-mx7/sys_proto.h +++ b/arch/arm/include/asm/arch-mx7/sys_proto.h @@ -9,5 +9,6 @@ void set_wdog_reset(struct wdog_regs *wdog); enum boot_device get_boot_device(void); +bool is_usb_boot(void); #endif /* __SYS_PROTO_IMX7_ */ diff --git a/arch/arm/mach-imx/cpu.c b/arch/arm/mach-imx/cpu.c index 5036c25175cfaf8c3813694dbc273322c4f0f8ff..ba04b77ba31a713bcfec9772704f1f486985f150 100644 --- a/arch/arm/mach-imx/cpu.c +++ b/arch/arm/mach-imx/cpu.c @@ -471,6 +471,47 @@ enum boot_device get_boot_device(void) return boot_dev; } + +bool is_usb_boot(void) +{ + return get_boot_device() == USB_BOOT; +} +#elif defined(CONFIG_MX6) +bool is_usb_boot(void) +{ + unsigned int bmode = readl(&src_base->sbmr2); + u32 reg; + + /* + * Check for BMODE if serial downloader is enabled + * BOOT_MODE - see IMX6DQRM Table 8-1 + */ + if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */ + return true; + + /* + * The above method does not detect that the boot ROM used + * serial downloader in case the boot ROM decided to use the + * serial downloader as a fall back (primary boot source failed). + * + * Infer that the boot ROM used the USB serial downloader by + * checking whether the USB PHY is currently active... This + * assumes that SPL did not (yet) initialize the USB PHY... + */ + if (is_usbotg_phy_active()) + return true; + + reg = (imx6_src_get_boot_mode() & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT; + + if (reg == IMX6_BMODE_RESERVED) + return true; + return false; +} +#else +bool is_usb_boot(void) +{ + return false; +} #endif #ifdef CONFIG_NXP_BOARD_REVISION diff --git a/arch/arm/mach-imx/mx8m/soc.c b/arch/arm/mach-imx/mx8m/soc.c index 593a7dfb111b375d6b9e6065a9cf32d5da521d4f..f67dad49ecf00e045510926fc8569d8847908de8 100644 --- a/arch/arm/mach-imx/mx8m/soc.c +++ b/arch/arm/mach-imx/mx8m/soc.c @@ -167,11 +167,6 @@ int arch_cpu_init(void) return 0; } -bool is_usb_boot(void) -{ - return get_boot_device() == USB_BOOT; -} - #ifdef CONFIG_OF_SYSTEM_SETUP int ft_system_setup(void *blob, bd_t *bd) {