Skip to contentSkip to conversation

ARM/early-printk: Improve reusability and add Calxeda support

PATCH Superseded Andre Przywara 3 participants 11 messages May 24, 2013 Arm Samsung Exynos

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover ARM/early-printk: Improve reusability and add Calxeda support

The current early-printk support for ARM is rather hard-coded, making it hard to add machines or tweak settings.
This series slightly moves some code to gather UART settings in xen/arch/arm/Rules.mk instead of the actual .c files. Also it allows two different machines with different settings to share the same driver, which the last patch exploits to add support the Calxeda Midway hardware.

This haven't been extensively tested, but I looked at the generated assembly and did some quick checks on Versatile Express.

Andre Przywara (4):
arm/early-printk: calculate baud rate divisor from user provided
value
arm/early-printk: allow skipping of UART init arm/early-printk: move UART base address to Rules.mk arm/early-printk: add Calxeda Midway UART support

 xen/arch/arm/Rules.mk                   | 13 +++++++++++++
 xen/arch/arm/arm32/debug-exynos4210.inc |  6 ++----
 xen/arch/arm/arm32/debug-pl011.inc      |  6 ++----
 xen/arch/arm/arm32/head.S               |  2 ++
 xen/arch/arm/arm64/debug-pl011.inc      |  6 ++----
 xen/arch/arm/arm64/head.S               |  2 ++
 6 files changed, 23 insertions(+), 12 deletions(-)
Signature · 1 line
1.7.12.1
#1 lore raw

PATCH 1/4 arm/early-printk: calculate baud rate divisor from user provided value

For early-printk the used baud rate was hardcoded in the code, using precalculated divisor values.
Let the calculation of these values be done by the preprocessor and use a human readable value in xen/arch/arm/Rules.mk to drive this.

---
 xen/arch/arm/Rules.mk                   | 3 +++
 xen/arch/arm/arm32/debug-exynos4210.inc | 4 ++--
 xen/arch/arm/arm32/debug-pl011.inc      | 4 ++--
 xen/arch/arm/arm64/debug-pl011.inc      | 4 ++--
 4 files changed, 9 insertions(+), 6 deletions(-)
xen/arch/arm/Rules.mk +3 -0
index b6a6890..b4d6907 100644
@@ -45,9 +45,11 @@ ifeq ($(debug),y)
 # TODO handle UART base address from make command line
 ifeq ($(CONFIG_EARLY_PRINTK), vexpress)
 EARLY_PRINTK_INC := pl011
+EARLY_PRINTK_BAUD := 38400
 endif
 ifeq ($(CONFIG_EARLY_PRINTK), exynos5250)
 EARLY_PRINTK_INC := exynos4210
+EARLY_PRINTK_BAUD := 115200
 endif
 
 ifneq ($(EARLY_PRINTK_INC),)
@@ -56,4 +58,5 @@ endif
 
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\"
+CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD)
 endif
xen/arch/arm/arm32/debug-exynos4210.inc +2 -2
index 4241640..4922148 100644
@@ -38,9 +38,9 @@
         orr   \rd, \rd, #(0x7<<8)
         str   \rd, [\rc, #0x558]
 
-        mov   \rc, #4
+        mov   \rc, #(100000000 / EARLY_PRINTK_BAUD % 16)
         str   \rc, [\rb, #UFRACVAL]     /* -> UFRACVAL (Baud divisor fraction) */
-        mov   \rc, #53
+        mov   \rc, #(100000000 / EARLY_PRINTK_BAUD / 16 - 1)
         str   \rc, [\rb, #UBRDIV]       /* -> UBRDIV (Baud divisor integer) */
         mov   \rc, #3                   /* 8n1 */
         str   \rc, [\rb, #ULCON]        /* -> (Line control) */
xen/arch/arm/arm32/debug-pl011.inc +2 -2
index 6954aeb..2d970ea 100644
@@ -23,9 +23,9 @@
  * rc: scratch register 1
  * rd: scratch register 2 (unused here) */
 .macro early_uart_init rb, rc, rd
-        mov   \rc, #0x0
+        mov   \rc, #(7372800 / EARLY_PRINTK_BAUD % 16)
         str   \rc, [\rb, #0x28]     /* -> UARTFBRD (Baud divisor fraction) */
-        mov   \rc, #0x4             /* 7.3728MHz / 0x4 == 16 * 115200 */
+        mov   \rc, #(7372800 / EARLY_PRINTK_BAUD / 16)
         str   \rc, [\rb, #0x24]     /* -> UARTIBRD (Baud divisor integer) */
         mov   \rc, #0x60            /* 8n1 */
         str   \rc, [\rb, #0x2C]     /* -> UARTLCR_H (Line control) */
xen/arch/arm/arm64/debug-pl011.inc +2 -2
index ee6e0e0..7220940 100644
@@ -24,9 +24,9 @@
  * xb: register which containts the UART base address
  * c: scratch register number */
 .macro early_uart_init xb, c
-        mov   x\c, #0x0
+        mov   x\c, #(7372800 / EARLY_PRINTK_BAUD % 16)
         strh  w\c, [\xb, #0x28]      /* -> UARTFBRD (Baud divisor fraction) */
-        mov   x\c, #0x4              /* 7.3728MHz / 0x4 == 16 * 115200 */
+        mov   x\c, #(7372800 / EARLY_PRINTK_BAUD / 16)
         strh  w\c, [\xb, #0x24]      /* -> UARTIBRD (Baud divisor integer) */
         mov   x\c, #0x60             /* 8n1 */
         str   w\c, [\xb, #0x2C]      /* -> UARTLCR_H (Line control) */
Signature · 1 line
1.7.12.1
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] arm/early-printk: calculate baud rate divisor from user provided value

Quoted 6 lines · Andre Przywara

For early-printk the used baud rate was hardcoded in the code, using precalculated divisor values.
Let the calculation of these values be done by the preprocessor and use a human readable value in xen/arch/arm/Rules.mk to drive this.

Quoted 77 lines
---
 xen/arch/arm/Rules.mk                   | 3 +++
 xen/arch/arm/arm32/debug-exynos4210.inc | 4 ++--
 xen/arch/arm/arm32/debug-pl011.inc      | 4 ++--
 xen/arch/arm/arm64/debug-pl011.inc      | 4 ++--
 4 files changed, 9 insertions(+), 6 deletions(-)
xen/arch/arm/Rules.mk +3 -0
index b6a6890..b4d6907 100644
@@ -45,9 +45,11 @@ ifeq ($(debug),y)
 # TODO handle UART base address from make command line
 ifeq ($(CONFIG_EARLY_PRINTK), vexpress)
 EARLY_PRINTK_INC := pl011
+EARLY_PRINTK_BAUD := 38400
 endif
 ifeq ($(CONFIG_EARLY_PRINTK), exynos5250)
 EARLY_PRINTK_INC := exynos4210
+EARLY_PRINTK_BAUD := 115200
 endif
 
 ifneq ($(EARLY_PRINTK_INC),)
@@ -56,4 +58,5 @@ endif
 
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\"
+CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD)
 endif
xen/arch/arm/arm32/debug-exynos4210.inc +2 -2
index 4241640..4922148 100644
@@ -38,9 +38,9 @@
         orr   \rd, \rd, #(0x7<<8)
         str   \rd, [\rc, #0x558]
 
-        mov   \rc, #4
+        mov   \rc, #(100000000 / EARLY_PRINTK_BAUD % 16)
         str   \rc, [\rb, #UFRACVAL]     /* -> UFRACVAL (Baud divisor fraction) */
-        mov   \rc, #53
+        mov   \rc, #(100000000 / EARLY_PRINTK_BAUD / 16 - 1)
         str   \rc, [\rb, #UBRDIV]       /* -> UBRDIV (Baud divisor integer) */
         mov   \rc, #3                   /* 8n1 */
         str   \rc, [\rb, #ULCON]        /* -> (Line control) */
xen/arch/arm/arm32/debug-pl011.inc +2 -2
index 6954aeb..2d970ea 100644
@@ -23,9 +23,9 @@
  * rc: scratch register 1
  * rd: scratch register 2 (unused here) */
 .macro early_uart_init rb, rc, rd
-        mov   \rc, #0x0
+        mov   \rc, #(7372800 / EARLY_PRINTK_BAUD % 16)
         str   \rc, [\rb, #0x28]     /* -> UARTFBRD (Baud divisor fraction) */
-        mov   \rc, #0x4             /* 7.3728MHz / 0x4 == 16 * 115200 */
+        mov   \rc, #(7372800 / EARLY_PRINTK_BAUD / 16)
         str   \rc, [\rb, #0x24]     /* -> UARTIBRD (Baud divisor integer) */
         mov   \rc, #0x60            /* 8n1 */
         str   \rc, [\rb, #0x2C]     /* -> UARTLCR_H (Line control) */
xen/arch/arm/arm64/debug-pl011.inc +2 -2
index ee6e0e0..7220940 100644
@@ -24,9 +24,9 @@
  * xb: register which containts the UART base address
  * c: scratch register number */
 .macro early_uart_init xb, c
-        mov   x\c, #0x0
+        mov   x\c, #(7372800 / EARLY_PRINTK_BAUD % 16)
         strh  w\c, [\xb, #0x28]      /* -> UARTFBRD (Baud divisor fraction) */
-        mov   x\c, #0x4              /* 7.3728MHz / 0x4 == 16 * 115200 */
+        mov   x\c, #(7372800 / EARLY_PRINTK_BAUD / 16)
         strh  w\c, [\xb, #0x24]      /* -> UARTIBRD (Baud divisor integer) */
         mov   x\c, #0x60             /* 8n1 */
         str   w\c, [\xb, #0x2C]      /* -> UARTLCR_H (Line control) */
#3 lore raw

PATCH 2/4 arm/early-printk: allow skipping of UART init

In reply to Andre Przywara

While it seems obvious to initialize the UART before using it, chances are that some firmware code or the bootloader already did this. So it may actually be a good idea to skip the initialization, in fact this fixes early printk on my TC2 Versatile Express.
So provide an option in xen/arch/arm/Rules.mk to only initialize the UART when needed.

---
 xen/arch/arm/Rules.mk     | 2 ++
 xen/arch/arm/arm32/head.S | 2 ++
 xen/arch/arm/arm64/head.S | 2 ++
 3 files changed, 6 insertions(+)
xen/arch/arm/Rules.mk +2 -0
index b4d6907..fdcf73e 100644
@@ -49,6 +49,7 @@ EARLY_PRINTK_BAUD := 38400
 endif
 ifeq ($(CONFIG_EARLY_PRINTK), exynos5250)
 EARLY_PRINTK_INC := exynos4210
+EARLY_PRINTK_INIT_UART := y
 EARLY_PRINTK_BAUD := 115200
 endif
 
@@ -57,6 +58,7 @@ EARLY_PRINTK := y
 endif
 
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK
+CFLAGS-$(EARLY_PRINTK_INIT_UART) += -DEARLY_PRINTK_INIT_UART
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\"
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD)
 endif
xen/arch/arm/arm32/head.S +2 -0
index ec7f640..0588d54 100644
@@ -369,7 +369,9 @@ fail:   PRINT("- Boot failed -\r\n")
  * r11: Early UART base address
  * Clobbers r0-r2 */
 init_uart:
+#ifdef EARLY_PRINTK_INIT_UART
         early_uart_init r11, r1, r2
+#endif
         adr   r0, 1f
         b     puts                  /* Jump to puts */
 1:      .asciz "- UART enabled -\r\n"
xen/arch/arm/arm64/head.S +2 -0
index 8955946..21b7e4d 100644
@@ -116,7 +116,9 @@ boot_cpu:
 #ifdef EARLY_PRINTK
         ldr   x23, =EARLY_UART_BASE_ADDRESS /* x23 := UART base address */
         cbnz  x22, 1f
+#ifdef EARLY_PRINTK_INIT_UART
         bl    init_uart                 /* CPU 0 sets up the UART too */
+#endif
 1:      PRINT("- CPU ")
         mov   x0, x22
         bl    putn
Signature · 1 line
1.7.12.1
#4 lore raw

Re: [PATCH 2/4] arm/early-printk: allow skipping of UART init

Quoted 7 lines · Andre Przywara

While it seems obvious to initialize the UART before using it, chances are that some firmware code or the bootloader already did this. So it may actually be a good idea to skip the initialization, in fact this fixes early printk on my TC2 Versatile Express.
So provide an option in xen/arch/arm/Rules.mk to only initialize the

UART when needed.

I'm using the fast model: Fast Models [8.0.60 (Mar 7 2013)] and the UART initialization is needed.

Could you do one of the following option:
1) add fastmodel early printk (with EARLY_PRINTK_INIT_UART=y)
2) document the behavior in docs/misc/arm/early-printk.txt

Quoted 55 lines
---
 xen/arch/arm/Rules.mk     | 2 ++
 xen/arch/arm/arm32/head.S | 2 ++
 xen/arch/arm/arm64/head.S | 2 ++
 3 files changed, 6 insertions(+)
xen/arch/arm/Rules.mk +2 -0
index b4d6907..fdcf73e 100644
@@ -49,6 +49,7 @@ EARLY_PRINTK_BAUD := 38400
 endif
 ifeq ($(CONFIG_EARLY_PRINTK), exynos5250)
 EARLY_PRINTK_INC := exynos4210
+EARLY_PRINTK_INIT_UART := y
 EARLY_PRINTK_BAUD := 115200
 endif
 
@@ -57,6 +58,7 @@ EARLY_PRINTK := y
 endif
 
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK
+CFLAGS-$(EARLY_PRINTK_INIT_UART) += -DEARLY_PRINTK_INIT_UART
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\"
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD)
 endif
xen/arch/arm/arm32/head.S +2 -0
index ec7f640..0588d54 100644
@@ -369,7 +369,9 @@ fail:   PRINT("- Boot failed -\r\n")
  * r11: Early UART base address
  * Clobbers r0-r2 */
 init_uart:
+#ifdef EARLY_PRINTK_INIT_UART
         early_uart_init r11, r1, r2
+#endif
         adr   r0, 1f
         b     puts                  /* Jump to puts */
 1:      .asciz "- UART enabled -\r\n"
xen/arch/arm/arm64/head.S +2 -0
index 8955946..21b7e4d 100644
@@ -116,7 +116,9 @@ boot_cpu:
 #ifdef EARLY_PRINTK
         ldr   x23, =EARLY_UART_BASE_ADDRESS /* x23 := UART base address */
         cbnz  x22, 1f
+#ifdef EARLY_PRINTK_INIT_UART
         bl    init_uart                 /* CPU 0 sets up the UART too */
+#endif
 1:      PRINT("- CPU ")
         mov   x0, x22
         bl    putn
Signature · 1 line
Julien
#5 lore raw

PATCH 3/4 arm/early-printk: move UART base address to Rules.mk

In reply to Andre Przywara

The UART memory mapped base address is currently hardcoded in the early-printk UART driver, which denies the driver to be used by two machines with a different mapping.
Move this definition out to xen/arch/arm/Rules.mk, allowing easier user access and later sharing of the driver.

---
 xen/arch/arm/Rules.mk                   | 3 +++
 xen/arch/arm/arm32/debug-exynos4210.inc | 2 --
 xen/arch/arm/arm32/debug-pl011.inc      | 2 --
 xen/arch/arm/arm64/debug-pl011.inc      | 2 --
 4 files changed, 3 insertions(+), 6 deletions(-)
xen/arch/arm/Rules.mk +3 -0
index fdcf73e..37a8271 100644
@@ -46,11 +46,13 @@ ifeq ($(debug),y)
 ifeq ($(CONFIG_EARLY_PRINTK), vexpress)
 EARLY_PRINTK_INC := pl011
 EARLY_PRINTK_BAUD := 38400
+EARLY_UART_BASE_ADDRESS := 0x1c090000
 endif
 ifeq ($(CONFIG_EARLY_PRINTK), exynos5250)
 EARLY_PRINTK_INC := exynos4210
 EARLY_PRINTK_INIT_UART := y
 EARLY_PRINTK_BAUD := 115200
+EARLY_UART_BASE_ADDRESS := 0x12c20000
 endif
 
 ifneq ($(EARLY_PRINTK_INC),)
@@ -61,4 +63,5 @@ CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK
 CFLAGS-$(EARLY_PRINTK_INIT_UART) += -DEARLY_PRINTK_INIT_UART
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\"
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD)
+CFLAGS-$(EARLY_PRINTK) += -DEARLY_UART_BASE_ADDRESS=$(EARLY_UART_BASE_ADDRESS)
 endif
xen/arch/arm/arm32/debug-exynos4210.inc +0 -2
index 4922148..d746c35 100644
@@ -18,8 +18,6 @@
 
 #include <asm/exynos4210-uart.h>
 
-#define EARLY_UART_BASE_ADDRESS 0x12c20000
-
 /* Exynos 5 UART initialization
  * rb: register which contains the UART base address
  * rc: scratch register 1
xen/arch/arm/arm32/debug-pl011.inc +0 -2
index 2d970ea..8b085b8 100644
@@ -16,8 +16,6 @@
  * GNU General Public License for more details.
  */
 
-#define EARLY_UART_BASE_ADDRESS 0x1c090000
-
 /* PL011 UART initialization
  * rb: register which contains the UART base address
  * rc: scratch register 1
xen/arch/arm/arm64/debug-pl011.inc +0 -2
index 7220940..b416235 100644
@@ -18,8 +18,6 @@
 
 #include <asm/asm_defns.h>
 
-#define EARLY_UART_BASE_ADDRESS 0x1c090000
-
 /* PL011 UART initialization
  * xb: register which containts the UART base address
  * c: scratch register number */
Signature · 1 line
1.7.12.1
Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH 3/4] arm/early-printk: move UART base address to Rules.mk

Quoted 7 lines · Andre Przywara

The UART memory mapped base address is currently hardcoded in the early-printk UART driver, which denies the driver to be used by two machines with a different mapping.
Move this definition out to xen/arch/arm/Rules.mk, allowing easier user access and later sharing of the driver.

Quoted 70 lines
---
 xen/arch/arm/Rules.mk                   | 3 +++
 xen/arch/arm/arm32/debug-exynos4210.inc | 2 --
 xen/arch/arm/arm32/debug-pl011.inc      | 2 --
 xen/arch/arm/arm64/debug-pl011.inc      | 2 --
 4 files changed, 3 insertions(+), 6 deletions(-)
xen/arch/arm/Rules.mk +3 -0
index fdcf73e..37a8271 100644
@@ -46,11 +46,13 @@ ifeq ($(debug),y)
 ifeq ($(CONFIG_EARLY_PRINTK), vexpress)
 EARLY_PRINTK_INC := pl011
 EARLY_PRINTK_BAUD := 38400
+EARLY_UART_BASE_ADDRESS := 0x1c090000
 endif
 ifeq ($(CONFIG_EARLY_PRINTK), exynos5250)
 EARLY_PRINTK_INC := exynos4210
 EARLY_PRINTK_INIT_UART := y
 EARLY_PRINTK_BAUD := 115200
+EARLY_UART_BASE_ADDRESS := 0x12c20000
 endif
 
 ifneq ($(EARLY_PRINTK_INC),)
@@ -61,4 +63,5 @@ CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK
 CFLAGS-$(EARLY_PRINTK_INIT_UART) += -DEARLY_PRINTK_INIT_UART
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\"
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD)
+CFLAGS-$(EARLY_PRINTK) += -DEARLY_UART_BASE_ADDRESS=$(EARLY_UART_BASE_ADDRESS)
 endif
xen/arch/arm/arm32/debug-exynos4210.inc +0 -2
index 4922148..d746c35 100644
@@ -18,8 +18,6 @@
 
 #include <asm/exynos4210-uart.h>
 
-#define EARLY_UART_BASE_ADDRESS 0x12c20000
-
 /* Exynos 5 UART initialization
  * rb: register which contains the UART base address
  * rc: scratch register 1
xen/arch/arm/arm32/debug-pl011.inc +0 -2
index 2d970ea..8b085b8 100644
@@ -16,8 +16,6 @@
  * GNU General Public License for more details.
  */
 
-#define EARLY_UART_BASE_ADDRESS 0x1c090000
-
 /* PL011 UART initialization
  * rb: register which contains the UART base address
  * rc: scratch register 1
xen/arch/arm/arm64/debug-pl011.inc +0 -2
index 7220940..b416235 100644
@@ -18,8 +18,6 @@
 
 #include <asm/asm_defns.h>
 
-#define EARLY_UART_BASE_ADDRESS 0x1c090000
-
 /* PL011 UART initialization
  * xb: register which containts the UART base address
  * c: scratch register number */
#7 lore raw

Re: [PATCH 3/4] arm/early-printk: move UART base address to Rules.mk

Quoted 11 lines · Julien Grall
Quoted 7 lines · Andre Przywara

The UART memory mapped base address is currently hardcoded in the early-printk UART driver, which denies the driver to be used by two machines with a different mapping.
Move this definition out to xen/arch/arm/Rules.mk, allowing easier user access and later sharing of the driver.

By the way, could you remove the "# TODO handle UART..." in arch/arm/Rules.mk as you have implemented it?

Thanks,

Julien

Quoted 77 lines
Quoted 62 lines
---
 xen/arch/arm/Rules.mk                   | 3 +++
 xen/arch/arm/arm32/debug-exynos4210.inc | 2 --
 xen/arch/arm/arm32/debug-pl011.inc      | 2 --
 xen/arch/arm/arm64/debug-pl011.inc      | 2 --
 4 files changed, 3 insertions(+), 6 deletions(-)
xen/arch/arm/Rules.mk +3 -0
index fdcf73e..37a8271 100644
@@ -46,11 +46,13 @@ ifeq ($(debug),y)
 ifeq ($(CONFIG_EARLY_PRINTK), vexpress)
 EARLY_PRINTK_INC := pl011
 EARLY_PRINTK_BAUD := 38400
+EARLY_UART_BASE_ADDRESS := 0x1c090000
 endif
 ifeq ($(CONFIG_EARLY_PRINTK), exynos5250)
 EARLY_PRINTK_INC := exynos4210
 EARLY_PRINTK_INIT_UART := y
 EARLY_PRINTK_BAUD := 115200
+EARLY_UART_BASE_ADDRESS := 0x12c20000
 endif
 
 ifneq ($(EARLY_PRINTK_INC),)
@@ -61,4 +63,5 @@ CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK
 CFLAGS-$(EARLY_PRINTK_INIT_UART) += -DEARLY_PRINTK_INIT_UART
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\"
 CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD)
+CFLAGS-$(EARLY_PRINTK) += -DEARLY_UART_BASE_ADDRESS=$(EARLY_UART_BASE_ADDRESS)
 endif
xen/arch/arm/arm32/debug-exynos4210.inc +0 -2
index 4922148..d746c35 100644
@@ -18,8 +18,6 @@
 
 #include <asm/exynos4210-uart.h>
 
-#define EARLY_UART_BASE_ADDRESS 0x12c20000
-
 /* Exynos 5 UART initialization
  * rb: register which contains the UART base address
  * rc: scratch register 1
xen/arch/arm/arm32/debug-pl011.inc +0 -2
index 2d970ea..8b085b8 100644
@@ -16,8 +16,6 @@
  * GNU General Public License for more details.
  */
 
-#define EARLY_UART_BASE_ADDRESS 0x1c090000
-
 /* PL011 UART initialization
  * rb: register which contains the UART base address
  * rc: scratch register 1
xen/arch/arm/arm64/debug-pl011.inc +0 -0
index 7220940..b416235 100644

xen/arch/arm/arm64/debug-pl011.inc line 23

Quoted 8 lines
xen/arch/arm/arm64/debug-pl011.inc +0 -2
@@ -18,8 +18,6 @@
 
 #include <asm/asm_defns.h>
 
-#define EARLY_UART_BASE_ADDRESS 0x1c090000
-
 /* PL011 UART initialization
  * xb: register which containts the UART base address
  * c: scratch register number */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#8 lore raw

PATCH 4/4 arm/early-printk: add Calxeda Midway UART support

In reply to Andre Przywara

With the help of the last three patches add a stanza to xen/arch/arm/Rules.mk to specify the UART configuration of the Calxeda Midway machine.
The information has been taken from the Linux kernel's .dts file. This can be enabled by adding "CONFIG_EARLY_PRINTK=midway" to Config.mk.

---
 xen/arch/arm/Rules.mk | 5 +++++
 1 file changed, 5 insertions(+)
xen/arch/arm/Rules.mk +5 -0
index 37a8271..cfc9e4d 100644
@@ -54,6 +54,11 @@ EARLY_PRINTK_INIT_UART := y
 EARLY_PRINTK_BAUD := 115200
 EARLY_UART_BASE_ADDRESS := 0x12c20000
 endif
+ifeq ($(CONFIG_EARLY_PRINTK), midway)
+EARLY_PRINTK_INC := pl011
+EARLY_PRINTK_BAUD := 115200
+EARLY_UART_BASE_ADDRESS := 0xfff36000
+endif
 
 ifneq ($(EARLY_PRINTK_INC),)
 EARLY_PRINTK := y
Signature · 1 line
1.7.12.1
#9 lore raw

Re: [PATCH 4/4] arm/early-printk: add Calxeda Midway UART support

Quoted 6 lines · Andre Przywara

With the help of the last three patches add a stanza to xen/arch/arm/Rules.mk to specify the UART configuration of the Calxeda Midway machine.
The information has been taken from the Linux kernel's .dts file. This can be enabled by adding "CONFIG_EARLY_PRINTK=midway" to Config.mk.

Could add a line in docs/misc/arm/early-printk.txt to document this new early printk?

Thanks,

Julien

Quoted 21 lines
---
 xen/arch/arm/Rules.mk | 5 +++++
 1 file changed, 5 insertions(+)
xen/arch/arm/Rules.mk +5 -0
index 37a8271..cfc9e4d 100644
@@ -54,6 +54,11 @@ EARLY_PRINTK_INIT_UART := y
 EARLY_PRINTK_BAUD := 115200
 EARLY_UART_BASE_ADDRESS := 0x12c20000
 endif
+ifeq ($(CONFIG_EARLY_PRINTK), midway)
+EARLY_PRINTK_INC := pl011
+EARLY_PRINTK_BAUD := 115200
+EARLY_UART_BASE_ADDRESS := 0xfff36000
+endif
 
 ifneq ($(EARLY_PRINTK_INC),)
 EARLY_PRINTK := y
#10 lore raw
In reply to Andre Przywara
Quoted 10 lines · Andre Przywara

The current early-printk support for ARM is rather hard-coded, making it hard to add machines or tweak settings.
This series slightly moves some code to gather UART settings in xen/arch/arm/Rules.mk instead of the actual .c files. Also it allows two different machines with different settings to share the same driver, which the last patch exploits to add support the Calxeda Midway hardware.

This haven't been extensively tested, but I looked at the generated assembly and did some quick checks on Versatile Express.

Thanks for this patch series, the UART code is now more generic :).

I tried all these patches on the fast model and the arndale board. I didn't see any specific issue.

Cheers,

Julien

Quoted 18 lines

Andre Przywara (4):
arm/early-printk: calculate baud rate divisor from user provided
value
arm/early-printk: allow skipping of UART init arm/early-printk: move UART base address to Rules.mk arm/early-printk: add Calxeda Midway UART support

 xen/arch/arm/Rules.mk                   | 13 +++++++++++++
 xen/arch/arm/arm32/debug-exynos4210.inc |  6 ++----
 xen/arch/arm/arm32/debug-pl011.inc      |  6 ++----
 xen/arch/arm/arm32/head.S               |  2 ++
 xen/arch/arm/arm64/debug-pl011.inc      |  6 ++----
 xen/arch/arm/arm64/head.S               |  2 ++
 6 files changed, 23 insertions(+), 12 deletions(-)