Skip to contentSkip to conversation

xen/arm: add i.MX lpuart and i.MX8QM initial support

PATCH Superseded Peng Fan (OSS) 3 participants 9 messages Apr 8, 2022 – Apr 11, 2022 Arm i.MX and Layerscape

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover xen/arm: add i.MX lpuart and i.MX8QM initial support

From: Peng Fan <[email protected]>

V4:
Wrong v3 version, some BIT definition are mixed in patch 1,2.

V3:
Addressed Michal's comments.
Add Henry's T-b

V2:
Per Julien's comments, fix coding style issue, drop unneeded code

Add i.MX lpuart driver and i.MX8QM platform support.
- lpuart is the uart IP used in i.MX8QM/QXP/93.
- Very basic i.MX8QM platform support.

Peng Fan (2):
xen/arm: Add i.MX lpuart driver
xen/arm: Add i.MX lpuart early printk support

 xen/arch/arm/Kconfig.debug              |  14 ++
 xen/arch/arm/arm64/debug-imx-lpuart.inc |  52 +++++
 xen/arch/arm/include/asm/imx-lpuart.h   |  64 ++++++
 xen/drivers/char/Kconfig                |   7 +
 xen/drivers/char/Makefile               |   1 +
 xen/drivers/char/imx-lpuart.c           | 276 ++++++++++++++++++++++++
 6 files changed, 414 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-imx-lpuart.inc
 create mode 100644 xen/arch/arm/include/asm/imx-lpuart.h
 create mode 100644 xen/drivers/char/imx-lpuart.c
Signature · 1 line
2.35.1
#1 lore raw

PATCH v4 1/2 xen/arm: Add i.MX lpuart driver

From: Peng Fan <[email protected]>

The i.MX LPUART Documentation:
https://www.nxp.com/webapp/Download?colCode=IMX8QMIEC
Chatper 13.6 Low Power Universal Asynchronous Receiver/ Transmitter (LPUART)

---
 xen/arch/arm/include/asm/imx-lpuart.h |  64 ++++++
 xen/drivers/char/Kconfig              |   7 +
 xen/drivers/char/Makefile             |   1 +
 xen/drivers/char/imx-lpuart.c         | 276 ++++++++++++++++++++++++++
 4 files changed, 348 insertions(+)
 create mode 100644 xen/arch/arm/include/asm/imx-lpuart.h
 create mode 100644 xen/drivers/char/imx-lpuart.c
xen/arch/arm/include/asm/imx-lpuart.h new file +64 -0
new file mode 100644
index 0000000000..26e2cf0249
@@ -0,0 +1,64 @@
+/*
+ * xen/arch/arm/include/asm/imx-lpuart.h
+ *
+ * Common constant definition between early printk and the LPUART driver
+ *
+ * Peng Fan <[email protected]>
+ * 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.
+ */
+
+#ifndef __ASM_ARM_IMX_LPUART_H__
+#define __ASM_ARM_IMX_LPUART_H__
+
+/* 32-bit register definition */
+#define UARTBAUD          (0x10)
+#define UARTSTAT          (0x14)
+#define UARTCTRL          (0x18)
+#define UARTDATA          (0x1C)
+#define UARTMATCH         (0x20)
+#define UARTMODIR         (0x24)
+#define UARTFIFO          (0x28)
+#define UARTWATER         (0x2c)
+
+#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)
+#define UARTBAUD_SBR_MASK (0x1fff)
+#define UARTBAUD_BOTHEDGE (0x00020000)
+#define UARTBAUD_TDMAE    (0x00800000)
+#define UARTBAUD_RDMAE    (0x00200000)
+
+#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
+
+#endif /* __ASM_ARM_IMX_LPUART_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/drivers/char/Kconfig +7 -0
index 2ff5b288e2..e5f7b1d8eb 100644
@@ -13,6 +13,13 @@ config HAS_CADENCE_UART
 	  This selects the Xilinx Zynq Cadence UART. If you have a Xilinx Zynq
 	  based board, say Y.
 
+config HAS_IMX_LPUART
+	bool "i.MX LPUART driver"
+	default y
+	depends on ARM_64
+	help
+	  This selects the i.MX LPUART. If you have i.MX8QM based board, say Y.
+
 config HAS_MVEBU
 	bool "Marvell MVEBU UART driver"
 	default y
xen/drivers/char/Makefile +1 -0
index 7c646d771c..14e67cf072 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_HAS_MVEBU) += mvebu-uart.o
 obj-$(CONFIG_HAS_OMAP) += omap-uart.o
 obj-$(CONFIG_HAS_SCIF) += scif-uart.o
 obj-$(CONFIG_HAS_EHCI) += ehci-dbgp.o
+obj-$(CONFIG_HAS_IMX_LPUART) += imx-lpuart.o
 obj-$(CONFIG_ARM) += arm-uart.o
 obj-y += serial.o
 obj-$(CONFIG_XEN_GUEST) += xen_pv_console.o
xen/drivers/char/imx-lpuart.c new file +276 -0

276 lines not on this page · raw message

Signature · 1 line
2.35.1
#2 lore raw

Re: [PATCH V4 1/2] xen/arm: Add i.MX lpuart driver

Hi Peng,

Quoted 57 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

The i.MX LPUART Documentation:
https://www.nxp.com/webapp/Download?colCode=IMX8QMIEC
Chatper 13.6 Low Power Universal Asynchronous Receiver/ Transmitter (LPUART)

---
 xen/arch/arm/include/asm/imx-lpuart.h |  64 ++++++
 xen/drivers/char/Kconfig              |   7 +
 xen/drivers/char/Makefile             |   1 +
 xen/drivers/char/imx-lpuart.c         | 276 ++++++++++++++++++++++++++
 4 files changed, 348 insertions(+)
 create mode 100644 xen/arch/arm/include/asm/imx-lpuart.h
 create mode 100644 xen/drivers/char/imx-lpuart.c
xen/arch/arm/include/asm/imx-lpuart.h new file +33 -0
new file mode 100644
index 0000000000..26e2cf0249
@@ -0,0 +1,64 @@
+/*
+ * xen/arch/arm/include/asm/imx-lpuart.h
+ *
+ * Common constant definition between early printk and the LPUART driver
+ *
+ * Peng Fan <[email protected]>
+ * 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.
+ */
+
+#ifndef __ASM_ARM_IMX_LPUART_H__
+#define __ASM_ARM_IMX_LPUART_H__
+
+/* 32-bit register definition */
+#define UARTBAUD          (0x10)
+#define UARTSTAT          (0x14)
+#define UARTCTRL          (0x18)
+#define UARTDATA          (0x1C)
+#define UARTMATCH         (0x20)
+#define UARTMODIR         (0x24)
+#define UARTFIFO          (0x28)
+#define UARTWATER         (0x2c)
+
+#define UARTSTAT_TDRE     BIT(23, UL)

xen/arch/arm/include/asm/imx-lpuart.h line 43

Quoted 10 lines
xen/arch/arm/include/asm/imx-lpuart.h new file +10 -0
+#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)
+#define UARTBAUD_SBR_MASK (0x1fff)
+#define UARTBAUD_BOTHEDGE (0x00020000)
+#define UARTBAUD_TDMAE    (0x00800000)
+#define UARTBAUD_RDMAE    (0x00200000)It seems like you missed my comment about alignment from the previous patch version.

Please keep the same alignment of values within the same section.

Cheers,
Michal

#3 lore raw

Re: [PATCH V4 1/2] xen/arm: Add i.MX lpuart driver

Hi,

Quoted 61 lines · Michal Orzel
Quoted 60 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

The i.MX LPUART Documentation:
https://www.nxp.com/webapp/Download?colCode=IMX8QMIEC
Chatper 13.6 Low Power Universal Asynchronous Receiver/ Transmitter (LPUART)

---
  xen/arch/arm/include/asm/imx-lpuart.h |  64 ++++++
  xen/drivers/char/Kconfig              |   7 +
  xen/drivers/char/Makefile             |   1 +
  xen/drivers/char/imx-lpuart.c         | 276 ++++++++++++++++++++++++++
  4 files changed, 348 insertions(+)

create mode 100644 xen/arch/arm/include/asm/imx-lpuart.h create mode 100644 xen/drivers/char/imx-lpuart.c

xen/arch/arm/include/asm/imx-lpuart.h new file +36 -0
new file mode 100644
index 0000000000..26e2cf0249
@@ -0,0 +1,64 @@
+/*
+ * xen/arch/arm/include/asm/imx-lpuart.h
+ *
+ * Common constant definition between early printk and the LPUART driver
+ *
+ * Peng Fan <[email protected]>
+ * 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.
+ */
+
+#ifndef __ASM_ARM_IMX_LPUART_H__
+#define __ASM_ARM_IMX_LPUART_H__
+
+/* 32-bit register definition */
+#define UARTBAUD          (0x10)
+#define UARTSTAT          (0x14)
+#define UARTCTRL          (0x18)
+#define UARTDATA          (0x1C)
+#define UARTMATCH         (0x20)
+#define UARTMODIR         (0x24)
+#define UARTFIFO          (0x28)
+#define UARTWATER         (0x2c)
+
+#define UARTSTAT_TDRE     BIT(23, UL)
+#define UARTSTAT_TC       BIT(22, UL)
+#define UARTSTAT_RDRF     BIT(21, UL)
+#define UARTSTAT_OR       BIT(19, UL)
Quoted 8 lines

xen/arch/arm/include/asm/imx-lpuart.h

Quoted 7 lines
xen/arch/arm/include/asm/imx-lpuart.h new file +7 -0
+
+#define UARTBAUD_OSR_SHIFT (24)
+#define UARTBAUD_OSR_MASK (0x1f)
+#define UARTBAUD_SBR_MASK (0x1fff)
+#define UARTBAUD_BOTHEDGE (0x00020000)
+#define UARTBAUD_TDMAE    (0x00800000)
+#define UARTBAUD_RDMAE    (0x00200000)It seems like you missed my comment about alignment from the previous patch version.

Please keep the same alignment of values within the same section.

I haven't yet reviewed this patch. But if this is the only comment, then I can update the alignment on commit.

Cheers,

Signature · 1 line
Julien Grall
#4 lore raw

Re: [PATCH V4 1/2] xen/arm: Add i.MX lpuart driver

Hi Julien,

Quoted 73 lines · Julien Grall

Hi,

Quoted 61 lines · Michal Orzel
Quoted 60 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

The i.MX LPUART Documentation:
https://www.nxp.com/webapp/Download?colCode=IMX8QMIEC
Chatper 13.6 Low Power Universal Asynchronous Receiver/ Transmitter (LPUART)

---
  xen/arch/arm/include/asm/imx-lpuart.h |  64 ++++++ xen/drivers/char/Kconfig              |   7 + xen/drivers/char/Makefile             |   1 + xen/drivers/char/imx-lpuart.c         | 276 ++++++++++++++++++++++++++

  4 files changed, 348 insertions(+)

  create mode 100644 xen/arch/arm/include/asm/imx-lpuart.h create mode 100644 xen/drivers/char/imx-lpuart.c

xen/arch/arm/include/asm/imx-lpuart.h new file +36 -0
new file mode 100644
index 0000000000..26e2cf0249
@@ -0,0 +1,64 @@
+/*
+ * xen/arch/arm/include/asm/imx-lpuart.h
+ *
+ * Common constant definition between early printk and the LPUART driver
+ *
+ * Peng Fan <[email protected]>
+ * 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.
+ */
+
+#ifndef __ASM_ARM_IMX_LPUART_H__
+#define __ASM_ARM_IMX_LPUART_H__
+
+/* 32-bit register definition */
+#define UARTBAUD          (0x10)
+#define UARTSTAT          (0x14)
+#define UARTCTRL          (0x18)
+#define UARTDATA          (0x1C)
+#define UARTMATCH         (0x20)
+#define UARTMODIR         (0x24)
+#define UARTFIFO          (0x28)
+#define UARTWATER         (0x2c)
+
+#define UARTSTAT_TDRE     BIT(23, UL)
+#define UARTSTAT_TC       BIT(22, UL)
+#define UARTSTAT_RDRF     BIT(21, UL)
+#define UARTSTAT_OR       BIT(19, UL)
Quoted 8 lines

xen/arch/arm/include/asm/imx-lpuart.h

Quoted 7 lines
xen/arch/arm/include/asm/imx-lpuart.h new file +7 -0
+
+#define UARTBAUD_OSR_SHIFT (24)
+#define UARTBAUD_OSR_MASK (0x1f)
+#define UARTBAUD_SBR_MASK (0x1fff)
+#define UARTBAUD_BOTHEDGE (0x00020000)
+#define UARTBAUD_TDMAE    (0x00800000)
+#define UARTBAUD_RDMAE    (0x00200000)It seems like you missed my comment about alignment from the previous patch version.

Please keep the same alignment of values within the same section.

Quoted 4 lines

I haven't yet reviewed this patch. But if this is the only comment, then I can update the alignment on commit.

Cheers,

All my other findings have already been fixed by Peng. This is the last one as it was forgotten. Patch 2/2 still has sth to be fixed so the alignment can be fixed in the same shot as well.

Cheers,
Michal

#5 lore raw

PATCH v4 2/2 xen/arm: Add i.MX lpuart early printk support

In reply to Peng Fan (OSS)

From: Peng Fan <[email protected]>

---
 xen/arch/arm/Kconfig.debug              | 14 +++++++
 xen/arch/arm/arm64/debug-imx-lpuart.inc | 52 +++++++++++++++++++++++++
 2 files changed, 66 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-imx-lpuart.inc
xen/arch/arm/Kconfig.debug +14 -0
index 35ccd13273..842d768280 100644
@@ -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
xen/arch/arm/arm64/debug-imx-lpuart.inc new file +52 -0

52 lines not on this page · raw message

Signature · 1 line
2.35.1
#6 lore raw

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

Hi Peng,

Quoted 69 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

---
 xen/arch/arm/Kconfig.debug              | 14 +++++++
 xen/arch/arm/arm64/debug-imx-lpuart.inc | 52 +++++++++++++++++++++++++
 2 files changed, 66 insertions(+)
 create mode 100644 xen/arch/arm/arm64/debug-imx-lpuart.inc
xen/arch/arm/Kconfig.debug +14 -0
index 35ccd13273..842d768280 100644
@@ -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
xen/arch/arm/arm64/debug-imx-lpuart.inc new file +15 -0
new file mode 100644
index 0000000000..f68252da86
@@ -0,0 +1,52 @@
+/*
+ * xen/arch/arm/arm64/debug-imx-lpuart.inc
+ *
+ * i.MX8QM specific debug code
+ *
+ * Peng Fan <[email protected]>
+ * 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

xen/arch/arm/arm64/debug-imx-lpuart.inc line 25

Quoted 10 lines
xen/arch/arm/arm64/debug-imx-lpuart.inc new file +10 -0
+ * 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
+

FWICS, early_uart_init call is protected with CONFIG_EARLY_UART_INIT that is set only for PL011 UART. So I think there is no need to implement this empty macro, unless we want to keep the same macros across the files no matter whether in use or not. I think you need to ask Julien.

Cheers,
Michal

#7 lore raw

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

Hi,

Quoted 76 lines · Michal Orzel
Quoted 75 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

---
  xen/arch/arm/Kconfig.debug              | 14 +++++++
  xen/arch/arm/arm64/debug-imx-lpuart.inc | 52 +++++++++++++++++++++++++
  2 files changed, 66 insertions(+)

create mode 100644 xen/arch/arm/arm64/debug-imx-lpuart.inc

xen/arch/arm/Kconfig.debug +14 -0
index 35ccd13273..842d768280 100644
@@ -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
xen/arch/arm/arm64/debug-imx-lpuart.inc new file +21 -0
new file mode 100644
index 0000000000..f68252da86
@@ -0,0 +1,52 @@
+/*
+ * xen/arch/arm/arm64/debug-imx-lpuart.inc
+ *
+ * i.MX8QM specific debug code
+ *
+ * Peng Fan <[email protected]>
+ * 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>
+
Quoted 8 lines

xen/arch/arm/arm64/debug-imx-lpuart.inc line 25

Quoted 4 lines
xen/arch/arm/arm64/debug-imx-lpuart.inc new file +4 -0
+.macro early_uart_init wb wc wd
+/* Already initialized in bootloader */
+.endm
+

FWICS, early_uart_init call is protected with CONFIG_EARLY_UART_INIT that is set only for PL011 UART. So I think there is no need to implement this empty macro, unless we want to keep the same macros across the files no matter whether in use or not. I think you need to ask Julien.

The call to early_uart_init is indeed protected by #ifdef CONFIG_EARLY_UART_INIT. The goal was to avoid having all debug-*.inc to implement dummy helper.

So I would prefer if early_uart_init is not implemented for debug-imx-lpuart.inc.

Cheers,

Signature · 1 line
Julien Grall
#8 lore raw

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

Hi Julien,

Quoted 88 lines · Julien Grall

Hi,

Quoted 76 lines · Michal Orzel
Quoted 75 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

---
  xen/arch/arm/Kconfig.debug              | 14 +++++++ xen/arch/arm/arm64/debug-imx-lpuart.inc | 52 +++++++++++++++++++++++++

  2 files changed, 66 insertions(+)

  create mode 100644 xen/arch/arm/arm64/debug-imx-lpuart.inc

xen/arch/arm/Kconfig.debug +0 -0
index 35ccd13273..842d768280 100644
@@ -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

xen/arch/arm/Kconfig.debug +0 -0
@@ -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

xen/arch/arm/Kconfig.debug +0 -0
@@ -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

xen/arch/arm/arm64/debug-imx-lpuart.inc new file +21 -0
new file mode 100644
index 0000000000..f68252da86
@@ -0,0 +1,52 @@
+/*
+ * xen/arch/arm/arm64/debug-imx-lpuart.inc
+ *
+ * i.MX8QM specific debug code
+ *
+ * Peng Fan <[email protected]>
+ * 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>
+
Quoted 8 lines

xen/arch/arm/arm64/debug-imx-lpuart.inc line 25

Quoted 4 lines
xen/arch/arm/arm64/debug-imx-lpuart.inc new file +4 -0
+.macro early_uart_init wb wc wd
+/* Already initialized in bootloader */
+.endm
+

FWICS, early_uart_init call is protected with CONFIG_EARLY_UART_INIT that is set only for PL011 UART. So I think there is no need to implement this empty macro, unless we want to keep the same macros across the files no matter whether in use or not. I think you need to ask Julien.

Quoted 6 lines

The call to early_uart_init is indeed protected by #ifdef CONFIG_EARLY_UART_INIT. The goal was to avoid having all debug-*.inc to implement dummy helper.

So I would prefer if early_uart_init is not implemented for debug-imx-lpuart.inc.

Cheers,

I agree.
As a side note, do we still need to support platform specific options for early printk? If not, I am happy to send a patch removing them.

Cheers,
Michal