Andre Przywara
2013-May-24 13:47 UTC
[PATCH v2 0/5] 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. Signed-off-by: Andre Przywara <andre.przywara@calxeda.com> Changes from v1: - add documentation - add extra support for ARM Fastmodel software emulators Andre Przywara (5): 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 support for ARM Fastmodel arm/early-printk: add Calxeda Midway UART support docs/misc/arm/early-printk.txt | 9 +++++++++ xen/arch/arm/Rules.mk | 20 +++++++++++++++++++- 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 ++ 7 files changed, 38 insertions(+), 13 deletions(-) -- 1.7.12.1
Andre Przywara
2013-May-24 13:47 UTC
[PATCH v2 1/5] 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. Signed-off-by: Andre Przywara <andre.przywara@calxeda.com> --- docs/misc/arm/early-printk.txt | 3 +++ 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 ++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt index d5cae85..10c3053 100644 --- a/docs/misc/arm/early-printk.txt +++ b/docs/misc/arm/early-printk.txt @@ -12,4 +12,7 @@ where mach is the name of the machine: - vexpress: printk with pl011 for versatile express - exynos5250: printk with the second UART +The baud rate is hardcoded in xen/arch/arm/Rules.mk, +see there when adding support for new machines. + By default early printk is disabled. diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk index b6a6890..b4d6907 100644 --- a/xen/arch/arm/Rules.mk +++ b/xen/arch/arm/Rules.mk @@ -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 diff --git a/xen/arch/arm/arm32/debug-exynos4210.inc b/xen/arch/arm/arm32/debug-exynos4210.inc index 4241640..4922148 100644 --- a/xen/arch/arm/arm32/debug-exynos4210.inc +++ b/xen/arch/arm/arm32/debug-exynos4210.inc @@ -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) */ diff --git a/xen/arch/arm/arm32/debug-pl011.inc b/xen/arch/arm/arm32/debug-pl011.inc index 6954aeb..2d970ea 100644 --- a/xen/arch/arm/arm32/debug-pl011.inc +++ b/xen/arch/arm/arm32/debug-pl011.inc @@ -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) */ diff --git a/xen/arch/arm/arm64/debug-pl011.inc b/xen/arch/arm/arm64/debug-pl011.inc index ee6e0e0..7220940 100644 --- a/xen/arch/arm/arm64/debug-pl011.inc +++ b/xen/arch/arm/arm64/debug-pl011.inc @@ -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) */ -- 1.7.12.1
Andre Przywara
2013-May-24 13:47 UTC
[PATCH v2 2/5] arm/early-printk: allow skipping of UART init
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. Signed-off-by: Andre Przywara <andre.przywara@calxeda.com> --- docs/misc/arm/early-printk.txt | 4 ++++ xen/arch/arm/Rules.mk | 2 ++ xen/arch/arm/arm32/head.S | 2 ++ xen/arch/arm/arm64/head.S | 2 ++ 4 files changed, 10 insertions(+) diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt index 10c3053..965add5 100644 --- a/docs/misc/arm/early-printk.txt +++ b/docs/misc/arm/early-printk.txt @@ -14,5 +14,9 @@ where mach is the name of the machine: The baud rate is hardcoded in xen/arch/arm/Rules.mk, see there when adding support for new machines. +If not explicitly requested with "EARLY_PRINTK_INIT_UART := y" in Rules.mk, +the code will not try to initialize the UART, so that bootloader or +firmware settings can be used for maximum compatibility. The baud rate +parameter is ignored in this case. By default early printk is disabled. diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk index b4d6907..fdcf73e 100644 --- a/xen/arch/arm/Rules.mk +++ b/xen/arch/arm/Rules.mk @@ -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 diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index ec7f640..0588d54 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -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" diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 8955946..21b7e4d 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -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 -- 1.7.12.1
Andre Przywara
2013-May-24 13:47 UTC
[PATCH v2 3/5] arm/early-printk: move UART base address to Rules.mk
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. Signed-off-by: Andre Przywara <andre.przywara@calxeda.com> --- docs/misc/arm/early-printk.txt | 2 +- xen/arch/arm/Rules.mk | 4 +++- xen/arch/arm/arm32/debug-exynos4210.inc | 2 -- xen/arch/arm/arm32/debug-pl011.inc | 2 -- xen/arch/arm/arm64/debug-pl011.inc | 2 -- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt index 965add5..9220113 100644 --- a/docs/misc/arm/early-printk.txt +++ b/docs/misc/arm/early-printk.txt @@ -12,7 +12,7 @@ where mach is the name of the machine: - vexpress: printk with pl011 for versatile express - exynos5250: printk with the second UART -The baud rate is hardcoded in xen/arch/arm/Rules.mk, +The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk, see there when adding support for new machines. If not explicitly requested with "EARLY_PRINTK_INIT_UART := y" in Rules.mk, the code will not try to initialize the UART, so that bootloader or diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk index fdcf73e..902bddb 100644 --- a/xen/arch/arm/Rules.mk +++ b/xen/arch/arm/Rules.mk @@ -42,15 +42,16 @@ EARLY_PRINTK := n ifeq ($(debug),y) # Early printk for versatile express -# TODO handle UART base address from make command line 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 +62,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 diff --git a/xen/arch/arm/arm32/debug-exynos4210.inc b/xen/arch/arm/arm32/debug-exynos4210.inc index 4922148..d746c35 100644 --- a/xen/arch/arm/arm32/debug-exynos4210.inc +++ b/xen/arch/arm/arm32/debug-exynos4210.inc @@ -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 diff --git a/xen/arch/arm/arm32/debug-pl011.inc b/xen/arch/arm/arm32/debug-pl011.inc index 2d970ea..8b085b8 100644 --- a/xen/arch/arm/arm32/debug-pl011.inc +++ b/xen/arch/arm/arm32/debug-pl011.inc @@ -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 diff --git a/xen/arch/arm/arm64/debug-pl011.inc b/xen/arch/arm/arm64/debug-pl011.inc index 7220940..b416235 100644 --- a/xen/arch/arm/arm64/debug-pl011.inc +++ b/xen/arch/arm/arm64/debug-pl011.inc @@ -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 */ -- 1.7.12.1
Andre Przywara
2013-May-24 13:47 UTC
[PATCH v2 4/5] arm/early-printk: add support for ARM Fastmodel
Though the ARM Fastmodel software emulator mimics a Versatile Express board, the boot process is different compared to the real hardware, so the early printk differs slightly. Create a new early-printk target to model this correctly. Signed-off-by: Andre Przywara <andre.przywara@calxeda.com> --- docs/misc/arm/early-printk.txt | 1 + xen/arch/arm/Rules.mk | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt index 9220113..e423cc4 100644 --- a/docs/misc/arm/early-printk.txt +++ b/docs/misc/arm/early-printk.txt @@ -11,6 +11,7 @@ CONFIG_EARLY_PRINTK=mach where mach is the name of the machine: - vexpress: printk with pl011 for versatile express - exynos5250: printk with the second UART + - fastmodel: printk on ARM Fastmodel software emulators The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk, see there when adding support for new machines. diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk index 902bddb..d010c69 100644 --- a/xen/arch/arm/Rules.mk +++ b/xen/arch/arm/Rules.mk @@ -47,6 +47,12 @@ EARLY_PRINTK_INC := pl011 EARLY_PRINTK_BAUD := 38400 EARLY_UART_BASE_ADDRESS := 0x1c090000 endif +ifeq ($(CONFIG_EARLY_PRINTK), fastmodel) +EARLY_PRINTK_INC := pl011 +EARLY_PRINTK_INIT_UART := y +EARLY_PRINTK_BAUD := 115200 +EARLY_UART_BASE_ADDRESS := 0x1c090000 +endif ifeq ($(CONFIG_EARLY_PRINTK), exynos5250) EARLY_PRINTK_INC := exynos4210 EARLY_PRINTK_INIT_UART := y -- 1.7.12.1
Andre Przywara
2013-May-24 13:47 UTC
[PATCH v2 5/5] arm/early-printk: add Calxeda Midway UART support
With the help of the previous 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. Signed-off-by: Andre Przywara <andre.przywara@calxeda.com> --- docs/misc/arm/early-printk.txt | 1 + xen/arch/arm/Rules.mk | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt index e423cc4..fbc3208 100644 --- a/docs/misc/arm/early-printk.txt +++ b/docs/misc/arm/early-printk.txt @@ -11,6 +11,7 @@ CONFIG_EARLY_PRINTK=mach where mach is the name of the machine: - vexpress: printk with pl011 for versatile express - exynos5250: printk with the second UART + - midway: printk with the pl011 on Calxeda Midway processors - fastmodel: printk on ARM Fastmodel software emulators The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk, diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk index d010c69..422ed04 100644 --- a/xen/arch/arm/Rules.mk +++ b/xen/arch/arm/Rules.mk @@ -59,6 +59,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 -- 1.7.12.1
Julien Grall
2013-May-24 14:01 UTC
Re: [PATCH v2 1/5] arm/early-printk: calculate baud rate divisor from user provided value
On 05/24/2013 02:47 PM, Andre Przywara wrote:> 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. > > Signed-off-by: Andre Przywara <andre.przywara@calxeda.com>Reviewed-by: Julien Grall <julien.grall@linaro.org>> --- > docs/misc/arm/early-printk.txt | 3 +++ > 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 ++-- > 5 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt > index d5cae85..10c3053 100644 > --- a/docs/misc/arm/early-printk.txt > +++ b/docs/misc/arm/early-printk.txt > @@ -12,4 +12,7 @@ where mach is the name of the machine: > - vexpress: printk with pl011 for versatile express > - exynos5250: printk with the second UART > > +The baud rate is hardcoded in xen/arch/arm/Rules.mk, > +see there when adding support for new machines. > + > By default early printk is disabled. > diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk > index b6a6890..b4d6907 100644 > --- a/xen/arch/arm/Rules.mk > +++ b/xen/arch/arm/Rules.mk > @@ -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 > diff --git a/xen/arch/arm/arm32/debug-exynos4210.inc b/xen/arch/arm/arm32/debug-exynos4210.inc > index 4241640..4922148 100644 > --- a/xen/arch/arm/arm32/debug-exynos4210.inc > +++ b/xen/arch/arm/arm32/debug-exynos4210.inc > @@ -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) */ > diff --git a/xen/arch/arm/arm32/debug-pl011.inc b/xen/arch/arm/arm32/debug-pl011.inc > index 6954aeb..2d970ea 100644 > --- a/xen/arch/arm/arm32/debug-pl011.inc > +++ b/xen/arch/arm/arm32/debug-pl011.inc > @@ -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) */ > diff --git a/xen/arch/arm/arm64/debug-pl011.inc b/xen/arch/arm/arm64/debug-pl011.inc > index ee6e0e0..7220940 100644 > --- a/xen/arch/arm/arm64/debug-pl011.inc > +++ b/xen/arch/arm/arm64/debug-pl011.inc > @@ -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) */
Julien Grall
2013-May-24 14:02 UTC
Re: [PATCH v2 2/5] arm/early-printk: allow skipping of UART init
On 05/24/2013 02:47 PM, Andre Przywara wrote:> 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. > > Signed-off-by: Andre Przywara <andre.przywara@calxeda.com>Reviewed-by: Julien Grall <julien.grall@linaro.org>> --- > docs/misc/arm/early-printk.txt | 4 ++++ > xen/arch/arm/Rules.mk | 2 ++ > xen/arch/arm/arm32/head.S | 2 ++ > xen/arch/arm/arm64/head.S | 2 ++ > 4 files changed, 10 insertions(+) > > diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt > index 10c3053..965add5 100644 > --- a/docs/misc/arm/early-printk.txt > +++ b/docs/misc/arm/early-printk.txt > @@ -14,5 +14,9 @@ where mach is the name of the machine: > > The baud rate is hardcoded in xen/arch/arm/Rules.mk, > see there when adding support for new machines. > +If not explicitly requested with "EARLY_PRINTK_INIT_UART := y" in Rules.mk, > +the code will not try to initialize the UART, so that bootloader or > +firmware settings can be used for maximum compatibility. The baud rate > +parameter is ignored in this case. > > By default early printk is disabled. > diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk > index b4d6907..fdcf73e 100644 > --- a/xen/arch/arm/Rules.mk > +++ b/xen/arch/arm/Rules.mk > @@ -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 > diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S > index ec7f640..0588d54 100644 > --- a/xen/arch/arm/arm32/head.S > +++ b/xen/arch/arm/arm32/head.S > @@ -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" > diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S > index 8955946..21b7e4d 100644 > --- a/xen/arch/arm/arm64/head.S > +++ b/xen/arch/arm/arm64/head.S > @@ -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
Julien Grall
2013-May-24 14:02 UTC
Re: [PATCH v2 3/5] arm/early-printk: move UART base address to Rules.mk
On 05/24/2013 02:47 PM, Andre Przywara wrote:> 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. > > Signed-off-by: Andre Przywara <andre.przywara@calxeda.com>Reviewed-by: Julien Grall <julien.grall@linaro.org>> --- > docs/misc/arm/early-printk.txt | 2 +- > xen/arch/arm/Rules.mk | 4 +++- > xen/arch/arm/arm32/debug-exynos4210.inc | 2 -- > xen/arch/arm/arm32/debug-pl011.inc | 2 -- > xen/arch/arm/arm64/debug-pl011.inc | 2 -- > 5 files changed, 4 insertions(+), 8 deletions(-) > > diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt > index 965add5..9220113 100644 > --- a/docs/misc/arm/early-printk.txt > +++ b/docs/misc/arm/early-printk.txt > @@ -12,7 +12,7 @@ where mach is the name of the machine: > - vexpress: printk with pl011 for versatile express > - exynos5250: printk with the second UART > > -The baud rate is hardcoded in xen/arch/arm/Rules.mk, > +The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk, > see there when adding support for new machines. > If not explicitly requested with "EARLY_PRINTK_INIT_UART := y" in Rules.mk, > the code will not try to initialize the UART, so that bootloader or > diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk > index fdcf73e..902bddb 100644 > --- a/xen/arch/arm/Rules.mk > +++ b/xen/arch/arm/Rules.mk > @@ -42,15 +42,16 @@ EARLY_PRINTK := n > ifeq ($(debug),y) > > # Early printk for versatile express > -# TODO handle UART base address from make command line > 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 +62,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 > diff --git a/xen/arch/arm/arm32/debug-exynos4210.inc b/xen/arch/arm/arm32/debug-exynos4210.inc > index 4922148..d746c35 100644 > --- a/xen/arch/arm/arm32/debug-exynos4210.inc > +++ b/xen/arch/arm/arm32/debug-exynos4210.inc > @@ -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 > diff --git a/xen/arch/arm/arm32/debug-pl011.inc b/xen/arch/arm/arm32/debug-pl011.inc > index 2d970ea..8b085b8 100644 > --- a/xen/arch/arm/arm32/debug-pl011.inc > +++ b/xen/arch/arm/arm32/debug-pl011.inc > @@ -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 > diff --git a/xen/arch/arm/arm64/debug-pl011.inc b/xen/arch/arm/arm64/debug-pl011.inc > index 7220940..b416235 100644 > --- a/xen/arch/arm/arm64/debug-pl011.inc > +++ b/xen/arch/arm/arm64/debug-pl011.inc > @@ -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 */
Julien Grall
2013-May-24 14:03 UTC
Re: [PATCH v2 4/5] arm/early-printk: add support for ARM Fastmodel
On 05/24/2013 02:47 PM, Andre Przywara wrote:> Though the ARM Fastmodel software emulator mimics a Versatile Express > board, the boot process is different compared to the real hardware, > so the early printk differs slightly. Create a new early-printk > target to model this correctly. > > Signed-off-by: Andre Przywara <andre.przywara@calxeda.com>Reviewed-by: Julien Grall <julien.grall@linaro.org>> --- > docs/misc/arm/early-printk.txt | 1 + > xen/arch/arm/Rules.mk | 6 ++++++ > 2 files changed, 7 insertions(+) > > diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt > index 9220113..e423cc4 100644 > --- a/docs/misc/arm/early-printk.txt > +++ b/docs/misc/arm/early-printk.txt > @@ -11,6 +11,7 @@ CONFIG_EARLY_PRINTK=mach > where mach is the name of the machine: > - vexpress: printk with pl011 for versatile express > - exynos5250: printk with the second UART > + - fastmodel: printk on ARM Fastmodel software emulators > > The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk, > see there when adding support for new machines. > diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk > index 902bddb..d010c69 100644 > --- a/xen/arch/arm/Rules.mk > +++ b/xen/arch/arm/Rules.mk > @@ -47,6 +47,12 @@ EARLY_PRINTK_INC := pl011 > EARLY_PRINTK_BAUD := 38400 > EARLY_UART_BASE_ADDRESS := 0x1c090000 > endif > +ifeq ($(CONFIG_EARLY_PRINTK), fastmodel) > +EARLY_PRINTK_INC := pl011 > +EARLY_PRINTK_INIT_UART := y > +EARLY_PRINTK_BAUD := 115200 > +EARLY_UART_BASE_ADDRESS := 0x1c090000 > +endif > ifeq ($(CONFIG_EARLY_PRINTK), exynos5250) > EARLY_PRINTK_INC := exynos4210 > EARLY_PRINTK_INIT_UART := y
Julien Grall
2013-May-24 14:03 UTC
Re: [PATCH v2 5/5] arm/early-printk: add Calxeda Midway UART support
On 05/24/2013 02:47 PM, Andre Przywara wrote:> With the help of the previous 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. > > Signed-off-by: Andre Przywara <andre.przywara@calxeda.com>Reviewed-by: Julien Grall <julien.grall@linaro.org>> --- > docs/misc/arm/early-printk.txt | 1 + > xen/arch/arm/Rules.mk | 5 +++++ > 2 files changed, 6 insertions(+) > > diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt > index e423cc4..fbc3208 100644 > --- a/docs/misc/arm/early-printk.txt > +++ b/docs/misc/arm/early-printk.txt > @@ -11,6 +11,7 @@ CONFIG_EARLY_PRINTK=mach > where mach is the name of the machine: > - vexpress: printk with pl011 for versatile express > - exynos5250: printk with the second UART > + - midway: printk with the pl011 on Calxeda Midway processors > - fastmodel: printk on ARM Fastmodel software emulators > > The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk, > diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk > index d010c69..422ed04 100644 > --- a/xen/arch/arm/Rules.mk > +++ b/xen/arch/arm/Rules.mk > @@ -59,6 +59,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
Ian Campbell
2013-May-30 08:59 UTC
Re: [PATCH v2 0/5] arm/early-printk: Improve reusability and add Calxeda support
On Fri, 2013-05-24 at 15:47 +0200, Andre Przywara wrote:> 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. > > Signed-off-by: Andre Przywara <andre.przywara@calxeda.com>All Acked + applied, thanks. I did wonder vaguely about: pulling the per board configs out of Rules.mk into earlyprintk-<board>.mk and doing: ifneq($(CONFIG_EARLY_PRINTK),) include earlyprintk-$(CONFIG_EARLY_PRINTK).mk endif and using the presence or absence of EARLY_PRINTK_BAUD instead of using a separate EARLY_PRINTK_INIT_UART. Neither of which affect the correctness of this series though.
Andre Przywara
2013-May-30 09:14 UTC
Re: [PATCH v2 0/5] arm/early-printk: Improve reusability and add Calxeda support
On 05/30/2013 10:59 AM, Ian Campbell wrote:> On Fri, 2013-05-24 at 15:47 +0200, Andre Przywara wrote: >> 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. >> >> Signed-off-by: Andre Przywara <andre.przywara@calxeda.com> > > All Acked + applied, thanks.Thanks!> I did wonder vaguely about: > > pulling the per board configs out of Rules.mk into > earlyprintk-<board>.mk and doing: > ifneq($(CONFIG_EARLY_PRINTK),) > include earlyprintk-$(CONFIG_EARLY_PRINTK).mk > endifYeah, I also found it being in kind of the wrong place. Just wasn''t sure if early_printk justifies <n> extra files to be created. What about moving all the boards definitions into one file and including this? This keeps Rules.mk clean and avoids too much clutter.> and > > using the presence or absence of EARLY_PRINTK_BAUD instead of using a > separate EARLY_PRINTK_INIT_UART.I was also wondering about this redundancy, this seems to be a nice solution for this. Thanks, will make a patch. Regards, Andre.
Ian Campbell
2013-May-30 09:22 UTC
Re: [PATCH v2 0/5] arm/early-printk: Improve reusability and add Calxeda support
On Thu, 2013-05-30 at 11:14 +0200, Andre Przywara wrote:> On 05/30/2013 10:59 AM, Ian Campbell wrote: > > On Fri, 2013-05-24 at 15:47 +0200, Andre Przywara wrote: > >> 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. > >> > >> Signed-off-by: Andre Przywara <andre.przywara@calxeda.com> > > > > All Acked + applied, thanks. > > Thanks! > > > I did wonder vaguely about: > > > > pulling the per board configs out of Rules.mk into > > earlyprintk-<board>.mk and doing: > > ifneq($(CONFIG_EARLY_PRINTK),) > > include earlyprintk-$(CONFIG_EARLY_PRINTK).mk > > endif > > Yeah, I also found it being in kind of the wrong place. > Just wasn''t sure if early_printk justifies <n> extra files to be > created. What about moving all the boards definitions into one file and > including this? This keeps Rules.mk clean and avoids too much clutter.That sounds reasonable.> > > and > > > > using the presence or absence of EARLY_PRINTK_BAUD instead of using a > > separate EARLY_PRINTK_INIT_UART. > > I was also wondering about this redundancy, this seems to be a nice > solution for this. Thanks, will make a patch.Cheers! Lets hope we don''t have to implement 9n1 vs 7n0 and stuff too, things other than 8n1 are pretty uncommon now though I think... Ian.