[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH V3 2/2] xen/arm: Add i.MX lpuart early printk support


  • To: sstabellini@xxxxxxxxxx, julien@xxxxxxx, Volodymyr_Babchuk@xxxxxxxx, bertrand.marquis@xxxxxxx
  • From: "Peng Fan (OSS)" <peng.fan@xxxxxxxxxxx>
  • Date: Thu, 7 Apr 2022 10:44:18 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aJJ17xML25oDlOV39Kw3EgsKV4hvJLgWZl9kJev+dnA=; b=MaZOOUBtXOC9Ku52fBFRIoxBKordXEbkvVuGN3vg3X9vrcwpbz0gq1NXS+AJx9N9Buk/uWLJrjC/kROFENpdSlhsXsjBQZNjd4304L66mb4vf/yC+twYKPBKuZjdnzIm3lg64yfz/BQ/l9NesR2dj1JR7u0ib6MjiqP1sBjT+T4rTHbFY2P4pxJ7OteEwNyu689I7H4s8+jzTMvEIDAbyAM8YtK+KY/Q4J1omREURb/LmuDnK2144xSjxnbUONoG3ct1TrM3iV9LFxeqy+hqvppte/QkPi71C41EgAIxr2lTUhKX/W/lll/+7jgNwTaSufbj5P1FAnSZ1hrjGxh4nw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WlZa2PGZC81sksg1MbgpAPy+UpeX3hzwnIhf9LyKqcA57O3fCbAxThO8EcWNA8uS2yYuCQcp3xlYfnJwlLuvoKJGTQXs+hnYN5K7VTK/J3zmLljBQRkHWi6aK56Pkbcab5mICpr1xhV0dCV6fyBqeywplFeSm6bXA+F5v1BCRVkmOa8qt2CNiFQpk3P0AxBomNviu52BYBg7O09d5+lIGBbxRpybqZEEyNIgaeQn7hapaY64A796H4t/GXzIZdDuuOnYDvs+c6c61RmPxowE6Q88T1/NpFRMfCsWTezaEKwgYrg+G84ThurXcaLJnyg/bJz4JVhy/C661L3K0djjIQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com;
  • Cc: andrew.cooper3@xxxxxxxxxx, george.dunlap@xxxxxxxxxx, jbeulich@xxxxxxxx, wl@xxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, van.freenix@xxxxxxxxx, michal.orzel@xxxxxxx, Peng Fan <peng.fan@xxxxxxx>
  • Delivery-date: Thu, 07 Apr 2022 02:03:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Peng Fan <peng.fan@xxxxxxx>

Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
---
 xen/arch/arm/Kconfig.debug              | 14 +++++++
 xen/arch/arm/arm64/debug-imx-lpuart.inc | 52 +++++++++++++++++++++++++
 xen/arch/arm/include/asm/imx-lpuart.h   | 22 +++++------
 3 files changed, 77 insertions(+), 11 deletions(-)
 create mode 100644 xen/arch/arm/arm64/debug-imx-lpuart.inc

diff --git a/xen/arch/arm/Kconfig.debug b/xen/arch/arm/Kconfig.debug
index 35ccd13273..842d768280 100644
--- a/xen/arch/arm/Kconfig.debug
+++ b/xen/arch/arm/Kconfig.debug
@@ -58,6 +58,16 @@ choice
                        This option is preferred over the platform specific
                        options; the platform specific options are deprecated
                        and will soon be removed.
+       config EARLY_UART_CHOICE_IMX_LPUART
+               select EARLY_UART_IMX_LPUART
+               depends on ARM_64
+               bool "Early printk via i.MX LPUART"
+               help
+                       Say Y here if you wish the early printk to direct their
+                       output to a i.MX LPUART. You can use this option to
+                       provide the parameters for the i.MX LPUART rather than
+                       selecting one of the platform specific options below if
+                       you know the parameters for the port.
        config EARLY_UART_CHOICE_MESON
                select EARLY_UART_MESON
                depends on ARM_64
@@ -186,6 +196,9 @@ config EARLY_UART_CADENCE
 config EARLY_UART_EXYNOS4210
        select EARLY_PRINTK
        bool
+config EARLY_UART_IMX_LPUART
+       select EARLY_PRINTK
+       bool
 config EARLY_UART_MESON
        select EARLY_PRINTK
        bool
@@ -283,6 +296,7 @@ config EARLY_PRINTK_INC
        default "debug-8250.inc" if EARLY_UART_8250
        default "debug-cadence.inc" if EARLY_UART_CADENCE
        default "debug-exynos4210.inc" if EARLY_UART_EXYNOS4210
+       default "debug-imx-lpuart.inc" if EARLY_UART_IMX_LPUART
        default "debug-meson.inc" if EARLY_UART_MESON
        default "debug-mvebu.inc" if EARLY_UART_MVEBU
        default "debug-pl011.inc" if EARLY_UART_PL011
diff --git a/xen/arch/arm/arm64/debug-imx-lpuart.inc 
b/xen/arch/arm/arm64/debug-imx-lpuart.inc
new file mode 100644
index 0000000000..f68252da86
--- /dev/null
+++ b/xen/arch/arm/arm64/debug-imx-lpuart.inc
@@ -0,0 +1,52 @@
+/*
+ * xen/arch/arm/arm64/debug-imx-lpuart.inc
+ *
+ * i.MX8QM specific debug code
+ *
+ * Peng Fan <peng.fan@xxxxxxx>
+ * Copyright 2022 NXP
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <asm/imx-lpuart.h>
+
+.macro early_uart_init wb wc wd
+/* Already initialized in bootloader */
+.endm
+
+/*
+ * Wait LPUART to be ready to transmit
+ * rb: register which contains the UART base address
+ * rc: scratch register
+ */
+.macro early_uart_ready xb, c
+1:
+        ldr   w\c, [\xb, #UARTSTAT]   /* <- Flag register */
+        tst   w\c, #UARTSTAT_TDRE     /* Check FIFO EMPTY bit */
+        beq   1b                      /* Wait for the UART to be ready */
+.endm
+
+/*
+ * LPUART transmit character
+ * rb: register which contains the UART base address
+ * rt: register which contains the character to transmit
+ */
+.macro early_uart_transmit xb, wt
+        str   \wt, [\xb, #UARTDATA]  /* -> Data Register */
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/arch/arm/include/asm/imx-lpuart.h 
b/xen/arch/arm/include/asm/imx-lpuart.h
index 111640edb4..26e2cf0249 100644
--- a/xen/arch/arm/include/asm/imx-lpuart.h
+++ b/xen/arch/arm/include/asm/imx-lpuart.h
@@ -30,10 +30,10 @@
 #define UARTFIFO          (0x28)
 #define UARTWATER         (0x2c)
 
-#define UARTSTAT_TDRE     BIT(23)
-#define UARTSTAT_TC       BIT(22)
-#define UARTSTAT_RDRF     BIT(21)
-#define UARTSTAT_OR       BIT(19)
+#define UARTSTAT_TDRE     BIT(23, UL)
+#define UARTSTAT_TC       BIT(22, UL)
+#define UARTSTAT_RDRF     BIT(21, UL)
+#define UARTSTAT_OR       BIT(19, UL)
 
 #define UARTBAUD_OSR_SHIFT (24)
 #define UARTBAUD_OSR_MASK (0x1f)
@@ -42,13 +42,13 @@
 #define UARTBAUD_TDMAE    (0x00800000)
 #define UARTBAUD_RDMAE    (0x00200000)
 
-#define UARTCTRL_TIE      BIT(23)
-#define UARTCTRL_TCIE     BIT(22)
-#define UARTCTRL_RIE      BIT(21)
-#define UARTCTRL_ILIE     BIT(20)
-#define UARTCTRL_TE       BIT(19)
-#define UARTCTRL_RE       BIT(18)
-#define UARTCTRL_M        BIT(4)
+#define UARTCTRL_TIE      BIT(23, UL)
+#define UARTCTRL_TCIE     BIT(22, UL)
+#define UARTCTRL_RIE      BIT(21, UL)
+#define UARTCTRL_ILIE     BIT(20, UL)
+#define UARTCTRL_TE       BIT(19, UL)
+#define UARTCTRL_RE       BIT(18, UL)
+#define UARTCTRL_M        BIT(4, UL)
 
 #define UARTWATER_RXCNT_OFF     24
 
-- 
2.35.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.