xen/arm: add i.MX lpuart and i.MX8QM initial support
v3 cover xen/arm: add i.MX lpuart and i.MX8QM initial support
From: Peng Fan <[email protected]>
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
PATCH v3 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
@@ -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) +#define UARTSTAT_TC BIT(22) +#define UARTSTAT_RDRF BIT(21) +#define UARTSTAT_OR BIT(19) + +#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) +#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 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
@@ -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
@@ -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
Re: [PATCH V3 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)Tested-by Henry Wang <[email protected]>Signed-off-by Peng Fan <[email protected]>--- 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.cxen/arch/arm/include/asm/imx-lpuart.h new file +33
-0@@ -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)
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) +#define UARTSTAT_RDRF BIT(21) +#define UARTSTAT_OR BIT(19) + +#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)
Could you please align the values at least within the section?
Cheers,
Michal
PATCH v3 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 +++++++++++++++++++++++++ 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
xen/arch/arm/Kconfig.debug +14 -0
@@ -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
xen/arch/arm/include/asm/imx-lpuart.h +11 -11
@@ -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
Signature · 1 line
2.35.1
Re: [PATCH V3 2/2] xen/arm: Add i.MX lpuart early printk support
Hi Peng,
Quoted 40 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Signed-off-by Peng Fan <[email protected]>--- 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.incxen/arch/arm/include/asm/imx-lpuart.h +4
-11@@ -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)
xen/arch/arm/include/asm/imx-lpuart.h line 54
Quoted 10 lines
xen/arch/arm/include/asm/imx-lpuart.h +7
-0+#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
I find it a bit strange that you fix the header file in the patch 2/2 while patch 1/2 introduces it. Could you do these fixes in the patch where you create this file?
Cheers,
Michal
RE: [PATCH V3 2/2] xen/arm: Add i.MX lpuart early printk support
Hi Michal,
Quoted 64 lines
-----Original Message-----
From: Michal Orzel [mailto:[email protected]]
Sent: 2022年4月8日 18:23
To: Peng Fan (OSS) <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Peng Fan <[email protected]>
Subject: Re: [PATCH V3 2/2] xen/arm: Add i.MX lpuart early printk supportHi Peng,
Quoted 6 lines · Peng Fan (OSS)
From: Peng Fan <[email protected]>
Signed-off-by Peng Fan <[email protected]>--- xen/arch/arm/Kconfig.debug | 14 +++++++ xen/arch/arm/arm64/debug-imx-lpuart.inc | 52+++++++++++++++++++++++++
Quoted 43 lines
xen/arch/arm/include/asm/imx-lpuart.h | 22 +++++------ 3 files changed, 77 insertions(+), 11 deletions(-) create mode100644 xen/arch/arm/arm64/debug-imx-lpuart.inc
xen/arch/arm/include/asm/imx-lpuart.h +11
-11@@ -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)
Quoted 6 lines
xen/arch/arm/include/asm/imx-lpuart.h line 54
Quoted 2 lines
xen/arch/arm/include/asm/imx-lpuart.h +0
-0#define UARTWATER_RXCNT_OFF 24I find it a bit strange that you fix the header file in the patch 2/2 while patch 1/2 introduces it. Could you do these fixes in the patch where you create this file?
Oops. I missed to merge that BIT fix into patch 1. Just send out V4.
Thanks,
Peng.
Quoted 3 lines
Cheers,
Michal