Merge tag 'u-boot-atmel-2019.07-b' of git://git.denx.de/u-boot-atmel
[oweals/u-boot.git] / board / toradex / apalis_imx6 / apalis_imx6.c
index 407ed1e22e9f8752d4743f600409919f4858ee35..3e59185438063bb4e33a5f59e6e0a22c93c8671b 100644 (file)
@@ -238,8 +238,11 @@ iomux_v3_cfg_t const usb_pads[] = {
  * UARTs are used in DTE mode, switch the mode on all UARTs before
  * any pinmuxing connects a (DCE) output to a transceiver output.
  */
+#define UCR3           0x88    /* FIFO Control Register */
+#define UCR3_RI                BIT(8)  /* RIDELT DTE mode */
+#define UCR3_DCD       BIT(9)  /* DCDDELT DTE mode */
 #define UFCR           0x90    /* FIFO Control Register */
-#define UFCR_DCEDTE    (1<<6)  /* DCE=0 */
+#define UFCR_DCEDTE    BIT(6)  /* DCE=0 */
 
 static void setup_dtemode_uart(void)
 {
@@ -247,6 +250,11 @@ static void setup_dtemode_uart(void)
        setbits_le32((u32 *)(UART2_BASE + UFCR), UFCR_DCEDTE);
        setbits_le32((u32 *)(UART4_BASE + UFCR), UFCR_DCEDTE);
        setbits_le32((u32 *)(UART5_BASE + UFCR), UFCR_DCEDTE);
+
+       clrbits_le32((u32 *)(UART1_BASE + UCR3), UCR3_DCD | UCR3_RI);
+       clrbits_le32((u32 *)(UART2_BASE + UCR3), UCR3_DCD | UCR3_RI);
+       clrbits_le32((u32 *)(UART4_BASE + UCR3), UCR3_DCD | UCR3_RI);
+       clrbits_le32((u32 *)(UART5_BASE + UCR3), UCR3_DCD | UCR3_RI);
 }
 static void setup_dcemode_uart(void)
 {
@@ -715,6 +723,14 @@ int board_late_init(void)
 #endif /* CONFIG_TDX_APALIS_IMX6_V1_0 */
 #endif /* CONFIG_REVISION_TAG */
 
+#ifdef CONFIG_CMD_USB_SDP
+       if (is_boot_from_usb()) {
+               printf("Serial Downloader recovery mode, using sdp command\n");
+               env_set("bootdelay", "0");
+               env_set("bootcmd", "sdp 0");
+       }
+#endif /* CONFIG_CMD_USB_SDP */
+
        return 0;
 }
 #endif /* CONFIG_BOARD_LATE_INIT */