Early printk code cleanup
cover Early printk code cleanup
This patch series performs simple early printk code cleanup around PL011. No functional changes has been made.
Michal Orzel (3):
xen/arm: Drop early_uart_init macro from debug-meson.inc xen/arm: debug-pl011.inc: Use macros instead of hardcoded values xen/arm: Define WLEN_8 macro and use it in debug-pl011
xen/arch/arm/arm32/debug-pl011.inc | 2 +- xen/arch/arm/arm64/debug-meson.inc | 7 ++++--- xen/arch/arm/arm64/debug-pl011.inc | 22 ++++++++++++---------- xen/arch/arm/include/asm/pl011-uart.h | 1 + 4 files changed, 18 insertions(+), 14 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/3 xen/arm: Drop early_uart_init macro from debug-meson.inc
early_uart_init macro is only used if CONFIG_EARLY_UART_INIT is set. This config option depends on EARLY_UART_PL011, so there is no point in defining it for MESON, especially if it is empty. Remove it and adapt the existing comment.
--- xen/arch/arm/arm64/debug-meson.inc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
xen/arch/arm/arm64/debug-meson.inc +4 -3
@@ -23,9 +23,10 @@ #define AML_UART_TX_FIFO_FULL 21 -.macro early_uart_init xb, c -/* Uart has already been initialized by Firmware, for instance by TF-A */ -.endm +/* + * No need for early_uart_init, as UART has already been initialized + * by Firmware, for instance by TF-A. + */ /* * MESON UART wait UART to be ready to transmit
Signature · 1 line
2.25.1
Re: [PATCH 1/3] xen/arm: Drop early_uart_init macro from debug-meson.inc
Hi Michal,
Quoted 6 lines · Michal Orzel
early_uart_initmacro is only used ifCONFIG_EARLY_UART_INITis set. This config option depends onEARLY_UART_PL011, so there is no point in defining it for MESON, especially if it is empty. Remove it and adapt the existing comment.Signed-off-by Michal Orzel <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
PATCH 2/3 xen/arm: debug-pl011.inc: Use macros instead of hardcoded values
In reply to Michal OrzelMake use of the macros defined in asm/pl011-uart.h instead of hardcoding the values. Also, take the opportunity to fix the file extension in a top-level comment.
No functional change intended.
---
This patch has already been reviewed/acked when pushed as a standalone one. Added to the series for ease of merging.
--- xen/arch/arm/arm64/debug-pl011.inc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
xen/arch/arm/arm64/debug-pl011.inc +11 -9
@@ -1,5 +1,5 @@ /* - * xen/arch/arm/arm64/debug-pl011.S + * xen/arch/arm/arm64/debug-pl011.inc * * PL011 specific debug code *
@@ -16,6 +16,8 @@ * GNU General Public License for more details. */ + #include <asm/pl011-uart.h> + /* * PL011 UART initialization * xb: register which containts the UART base address
@@ -23,13 +25,13 @@ */ .macro early_uart_init xb, c mov x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE % 16) - strh w\c, [\xb, #0x28] /* -> UARTFBRD (Baud divisor fraction) */ + strh w\c, [\xb, #FBRD] /* -> UARTFBRD (Baud divisor fraction) */ mov x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16) - strh w\c, [\xb, #0x24] /* -> UARTIBRD (Baud divisor integer) */ + strh w\c, [\xb, #IBRD] /* -> UARTIBRD (Baud divisor integer) */ mov x\c, #0x60 /* 8n1 */ - str w\c, [\xb, #0x2C] /* -> UARTLCR_H (Line control) */ - ldr x\c, =0x00000301 /* RXE | TXE | UARTEN */ - str w\c, [\xb, #0x30] /* -> UARTCR (Control Register) */ + str w\c, [\xb, #LCR_H] /* -> UARTLCR_H (Line control) */ + ldr x\c, =(RXE | TXE | UARTEN) + str w\c, [\xb, #CR] /* -> UARTCR (Control Register) */ .endm /*
@@ -39,8 +41,8 @@ */ .macro early_uart_ready xb, c 1: - ldrh w\c, [\xb, #0x18] /* <- UARTFR (Flag register) */ - tst w\c, #0x8 /* Check BUSY bit */ + ldrh w\c, [\xb, #FR] /* <- UARTFR (Flag register) */ + tst w\c, #BUSY /* Check BUSY bit */ b.ne 1b /* Wait for the UART to be ready */ .endm
@@ -50,7 +52,7 @@ * wt: register which contains the character to transmit */ .macro early_uart_transmit xb, wt - strb \wt, [\xb] /* -> UARTDR (Data Register) */ + strb \wt, [\xb, #DR] /* -> UARTDR (Data Register) */ .endm /*
Signature · 1 line
2.25.1
PATCH 3/3 xen/arm: Define WLEN_8 macro and use it in debug-pl011
In reply to Michal OrzelAt the moment, early printk code for pl011 uses a hardcoded value for 8n1 LCR configuration. Define and use macro WLEN_8 for that purpose (no parity and 1 stop bit are defined as 0).
--- xen/arch/arm/arm32/debug-pl011.inc | 2 +- xen/arch/arm/arm64/debug-pl011.inc | 2 +- xen/arch/arm/include/asm/pl011-uart.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
xen/arch/arm/arm32/debug-pl011.inc +1 -1
@@ -29,7 +29,7 @@ str \rc, [\rb, #FBRD] /* -> UARTFBRD (Baud divisor fraction) */ mov \rc, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16) str \rc, [\rb, #IBRD] /* -> UARTIBRD (Baud divisor integer) */ - mov \rc, #0x60 /* 8n1 */ + mov \rc, #WLEN_8 /* 8n1 */ str \rc, [\rb, #LCR_H] /* -> UARTLCR_H (Line control) */ ldr \rc, =(RXE | TXE | UARTEN) /* RXE | TXE | UARTEN */ str \rc, [\rb, #CR] /* -> UARTCR (Control Register) */
xen/arch/arm/arm64/debug-pl011.inc +1 -1
@@ -28,7 +28,7 @@ strh w\c, [\xb, #FBRD] /* -> UARTFBRD (Baud divisor fraction) */ mov x\c, #(7372800 / CONFIG_EARLY_UART_PL011_BAUD_RATE / 16) strh w\c, [\xb, #IBRD] /* -> UARTIBRD (Baud divisor integer) */ - mov x\c, #0x60 /* 8n1 */ + mov x\c, #WLEN_8 /* 8n1 */ str w\c, [\xb, #LCR_H] /* -> UARTLCR_H (Line control) */ ldr x\c, =(RXE | TXE | UARTEN) str w\c, [\xb, #CR] /* -> UARTCR (Control Register) */
xen/arch/arm/include/asm/pl011-uart.h +1 -0
@@ -55,6 +55,7 @@/* LCR_H bits */ #define SPS (1<<7)/* Stick parity select */ +#define WLEN_8 (_AC(0x3, U) << 5)/* 8 bits word length */ #define FEN (1<<4)/* FIFO enable */ #define STP2 (1<<3)/* Two stop bits select */ #define EPS (1<<2)/* Even parity select */
Signature · 1 line
2.25.1
Re: [PATCH 3/3] xen/arm: Define WLEN_8 macro and use it in debug-pl011
Hi Michal,
Quoted 5 lines · Michal Orzel
At the moment, early printk code for pl011 uses a hardcoded value for 8n1 LCR configuration. Define and use macro
WLEN_8for that purpose (no parity and 1 stop bit are defined as 0).Signed-off-by Michal Orzel <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
Hi,
Quoted 7 lines · Michal Orzel
This patch series performs simple early printk code cleanup around PL011. No functional changes has been made.
Michal Orzel (3):
xen/arm: Dropearly_uart_initmacro from debug-meson.inc xen/arm: debug-pl011.inc: Use macros instead of hardcoded values xen/arm: DefineWLEN_8macro and use it in debug-pl011
I have committed everything in a branch for-next/4.18 which will be merged once the tree re-open.
Cheers,
Signature · 1 line
Julien Grall