imx: add macro to detect whether USB has been initialized
authorStefan Agner <stefan.agner@toradex.com>
Wed, 30 May 2018 17:01:45 +0000 (19:01 +0200)
committerStefano Babic <sbabic@denx.de>
Mon, 23 Jul 2018 08:12:00 +0000 (10:12 +0200)
This macro allows to detect whether the boot ROM initialized USB
already (serial downloader). This is helpful to reliably detect
if the system has been recovered via USB serial downloader.

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
arch/arm/include/asm/arch-mx6/imx-regs.h

index 431439218dd1ca8aed42adee317245eb04cc0573..4f01b20aedf8565d1b38ad2552b951617ecbe8d0 100644 (file)
@@ -996,5 +996,12 @@ struct pwm_regs {
        u32     pr;
        u32     cnr;
 };
+
+/*
+ * If ROM fail back to USB recover mode, USBPH0_PWD will be clear to use USB
+ * If boot from the other mode, USB0_PWD will keep reset value
+ */
+#define        is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
+
 #endif /* __ASSEMBLER__*/
 #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */