]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
arm/early-printk: calculate baud rate divisor from user provided value
authorAndre Przywara <andre.przywara@calxeda.com>
Fri, 24 May 2013 13:47:26 +0000 (15:47 +0200)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 30 May 2013 08:20:10 +0000 (09:20 +0100)
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>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
docs/misc/arm/early-printk.txt
xen/arch/arm/Rules.mk
xen/arch/arm/arm32/debug-exynos4210.inc
xen/arch/arm/arm32/debug-pl011.inc
xen/arch/arm/arm64/debug-pl011.inc

index d5cae85ddb9c97c69d6eafd956dcd2d28ea1ceff..10c30531f6111cdb9004f18b1664bae2f0d74437 100644 (file)
@@ -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.
index b6a68902bba390f38421660a5dd5dcd7d2d7f2d1..b4d690716a8f6288f8bae45b378e155d11e9ec15 100644 (file)
@@ -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
index 42416406ca3f2c33591656ed73a8d18b65056be4..4922148ac1df0d147b58b3e8d06d242871327157 100644 (file)
@@ -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) */
index 6954aeb66096d19d45236e2faf50b4fba9db65a3..2d970ea364dc6ed975392c81cf32a68c99a1ddd7 100644 (file)
@@ -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) */
index ee6e0e03e7d67e7ad3fa0bbda6af264c37449861..722094036d89bcfc96ce6fe31b467957db0371b2 100644 (file)
@@ -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) */