From bb7197516282c3226942f5bac55f6aa8ee4b62cf Mon Sep 17 00:00:00 2001 From: Troy Kisky <troy.kisky@boundarydevices.com> Date: Fri, 20 Jul 2018 17:03:42 -0700 Subject: [PATCH] arm: mach-imx: cpu: add is_usb_boot Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com> --- arch/arm/include/asm/arch-mx5/sys_proto.h | 1 + arch/arm/include/asm/arch-mx6/sys_proto.h | 1 + arch/arm/include/asm/arch-mx7/sys_proto.h | 1 + arch/arm/mach-imx/cpu.c | 41 +++++++++++++++++++++++ arch/arm/mach-imx/mx8m/soc.c | 5 --- 5 files changed, 44 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/arch-mx5/sys_proto.h b/arch/arm/include/asm/arch-mx5/sys_proto.h index c8aff2b65dc..e94b7da9919 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 4bf7dff8b4d..a3884160586 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 e46a02198d6..42663a43887 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 5036c25175c..ba04b77ba31 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 593a7dfb111..f67dad49ecf 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) { -- GitLab