Skip to contentSkip to conversation

Change omap DEBUG_LL code to use inituart for AUTO_ZRELADDR and ARM_PATCH_PHYS_VIRT

PATCH New Tony Lindgren 5 participants 16 messages Feb 4, 2011 – Feb 9, 2011

Subsystems (4)
lore
Share & tools
lore

Tony Lindgren

author maintainer
#0 lore raw

cover Change omap DEBUG_LL code to use inituart for AUTO_ZRELADDR and ARM_PATCH_PHYS_VIRT

Here are the changes to make omap DEBUG_LL code generic using the new inituart macro posted in a separate series. This allows leaving out the dependency to the uncompress code and allows error messages when trying to boot a wrong zImage.

Adding support for new machines should be only additional two lines of assembly per machine after these patches.

Regards,

Tony

---

Tony Lindgren (5):
omap: Remove code configuring the DEBUG_LL serial port using uncompress code
omap: Use inituart to configure the debug serial port based on machine ID
omap: Add support for CONFIG_AUTO_ZRELADDR for DEBUG_LL
omap: Combine debug-macro.S for omap1 and omap2+
omap: Add CONFIG_AUTO_ZRELADDR and CONFIG_ARM_PATCH_PHYS_VIRT to defconfigs

 arch/arm/configs/omap1_defconfig               |    2 
 arch/arm/configs/omap2plus_defconfig           |    2 
 arch/arm/mach-omap1/include/mach/debug-macro.S |   98 ---------
 arch/arm/mach-omap1/serial.c                   |    7 +
 arch/arm/mach-omap2/include/mach/debug-macro.S |  138 -------------
 arch/arm/mach-omap2/serial.c                   |    7 +
 arch/arm/plat-omap/include/plat/debug-macro.S  |  257 ++++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/serial.h       |   34 ---
 arch/arm/plat-omap/include/plat/uncompress.h   |   32 +--
 9 files changed, 284 insertions(+), 293 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/debug-macro.S
Signature · 1 line
Signature
author maintainer
#1 lore raw

PATCH 1/5 omap: Remove code configuring the DEBUG_LL serial port using uncompress code

This code gets too complex and has a dependency to the uncompress code for initializing the serial port. The following patches will use inituart for machine specific debug uart init.

---
 arch/arm/mach-omap1/include/mach/debug-macro.S |   47 -------------
 arch/arm/mach-omap2/include/mach/debug-macro.S |   84 ------------------------
 arch/arm/plat-omap/include/plat/serial.h       |   34 ----------
 arch/arm/plat-omap/include/plat/uncompress.h   |   32 ++-------
 4 files changed, 9 insertions(+), 188 deletions(-)
arch/arm/mach-omap1/include/mach/debug-macro.S +1 -46
index bf0cc57..db2cdf4 100644
@@ -18,7 +18,6 @@
 #include <plat/serial.h>
 
 #define omap_uart_v2p(x)	((x) - PAGE_OFFSET + PLAT_PHYS_OFFSET)
-#define omap_uart_p2v(x)	((x) - PLAT_PHYS_OFFSET + PAGE_OFFSET)
 
 		.pushsection .data
 omap_uart_phys:	.word	0x0
@@ -37,57 +36,13 @@ omap_uart_virt:	.word	0x0
 		.macro	addruart, rp, rv
 
 		/* Use omap_uart_phys/virt if already configured */
-9:		mrc	p15, 0, \rp, c1, c0
+		mrc	p15, 0, \rp, c1, c0
 		tst	\rp, #1			@ MMU enabled?
 		ldreq	\rp, =omap_uart_v2p(omap_uart_phys)	@ MMU disabled
 		ldrne	\rp, =omap_uart_phys	@ MMU enabled
 		add	\rv, \rp, #4		@ omap_uart_virt
 		ldr	\rp, [\rp, #0]
 		ldr	\rv, [\rv, #0]
-		cmp	\rp, #0			@ is port configured?
-		cmpne	\rv, #0
-		bne	99f			@ already configured
-
-		/* Check the debug UART configuration set in uncompress.h */
-		mrc	p15, 0, \rp, c1, c0
-		tst	\rp, #1			@ MMU enabled?
-		ldreq	\rp, =OMAP_UART_INFO	@ MMU not enabled
-		ldrne	\rp, =omap_uart_p2v(OMAP_UART_INFO)	@ MMU enabled
-		ldr	\rp, [\rp, #0]
-
-		/* Select the UART to use based on the UART1 scratchpad value */
-10:		cmp	\rp, #0			@ no port configured?
-		beq	11f			@ if none, try to use UART1
-		cmp	\rp, #OMAP1UART1
-		beq	11f			@ configure OMAP1UART1
-		cmp	\rp, #OMAP1UART2
-		beq	12f			@ configure OMAP1UART2
-		cmp	\rp, #OMAP1UART3
-		beq	13f			@ configure OMAP2UART3
-
-		/* Configure the UART offset from the phys/virt base */
-11:		mov	\rp, #0x00fb0000	@ OMAP1UART1
-		b	98f
-12:		mov	\rp, #0x00fb0000	@ OMAP1UART1
-		orr	\rp, \rp, #0x00000800	@ OMAP1UART2
-		b	98f
-13:		mov	\rp, #0x00fb0000	@ OMAP1UART1
-		orr	\rp, \rp, #0x00000800	@ OMAP1UART2
-		orr	\rp, \rp, #0x00009000	@ OMAP1UART3
-
-		/* Store both phys and virt address for the uart */
-98:		add	\rp, \rp, #0xff000000	@ phys base
-		mrc	p15, 0, \rv, c1, c0
-		tst	\rv, #1			@ MMU enabled?
-		ldreq	\rv, =omap_uart_v2p(omap_uart_phys)	@ MMU disabled
-		ldrne	\rv, =omap_uart_phys	@ MMU enabled
-		str	\rp, [\rv, #0]
-		sub	\rp, \rp, #0xff000000	@ phys base
-		add	\rp, \rp, #0xfe000000	@ virt base
-		add	\rv, \rv, #4		@ omap_uart_lsr
-		str	\rp, [\rv, #0]
-		b	9b
-99:
 		.endm
 
 		.macro	senduart,rd,rx
arch/arm/mach-omap2/include/mach/debug-macro.S +1 -83

102 lines not on this page · raw message

arch/arm/plat-omap/include/plat/serial.h +0 -34
index 8ff605c..7d9ed90 100644
@@ -15,20 +15,6 @@
 
 #include <linux/init.h>
 
-/*
- * Memory entry used for the DEBUG_LL UART configuration. See also
- * uncompress.h and debug-macro.S.
- *
- * Note that using a memory location for storing the UART configuration
- * has at least two limitations:
- *
- * 1. Kernel uncompress code cannot overlap OMAP_UART_INFO as the
- *    uncompress code could then partially overwrite itself
- * 2. We assume printascii is called at least once before paging_init,
- *    and addruart has a chance to read OMAP_UART_INFO
- */
-#define OMAP_UART_INFO		(PLAT_PHYS_OFFSET + 0x3ffc)
-
 /* OMAP1 serial ports */
 #define OMAP1_UART1_BASE	0xfffb0000
 #define OMAP1_UART2_BASE	0xfffb0800
@@ -63,26 +49,6 @@
 #define OMAP16XX_BASE_BAUD	(48000000/16)
 #define OMAP24XX_BASE_BAUD	(48000000/16)
 
-/*
- * DEBUG_LL port encoding stored into the UART1 scratchpad register by
- * decomp_setup in uncompress.h
- */
-#define OMAP1UART1		11
-#define OMAP1UART2		12
-#define OMAP1UART3		13
-#define OMAP2UART1		21
-#define OMAP2UART2		22
-#define OMAP2UART3		23
-#define OMAP3UART1		OMAP2UART1
-#define OMAP3UART2		OMAP2UART2
-#define OMAP3UART3		33
-#define OMAP3UART4		34		/* Only on 36xx */
-#define OMAP4UART1		OMAP2UART1
-#define OMAP4UART2		OMAP2UART2
-#define OMAP4UART3		43
-#define OMAP4UART4		44
-#define ZOOM_UART		95		/* Only on zoom2/3 */
-
 /* This is only used by 8250.c for omap1510 */
 #define is_omap_port(pt)	({int __ret = 0;			\
 			if ((pt)->port.mapbase == OMAP1_UART1_BASE ||	\
arch/arm/plat-omap/include/plat/uncompress.h +7 -25
index ad98b85..ea1ffe4 100644
@@ -30,15 +30,6 @@
 static volatile u8 *uart_base;
 static int uart_shift;
 
-/*
- * Store the DEBUG_LL uart number into memory.
- * See also debug-macro.S, and serial.c for related code.
- */
-static void set_omap_uart_info(unsigned char port)
-{
-	*(volatile u32 *)OMAP_UART_INFO = port;
-}
-
 static void putc(int c)
 {
 	if (!uart_base)
@@ -60,43 +51,34 @@ static inline void flush(void)
 /*
  * Macros to configure UART1 and debug UART
  */
-#define _DEBUG_LL_ENTRY(mach, dbg_uart, dbg_shft, dbg_id)		\
+#define _DEBUG_LL_ENTRY(mach, dbg_uart, dbg_shft)			\
 	if (machine_is_##mach()) {					\
 		uart_base = (volatile u8 *)(dbg_uart);			\
 		uart_shift = (dbg_shft);				\
-		port = (dbg_id);					\
-		set_omap_uart_info(port);				\
 		break;							\
 	}
 
 #define DEBUG_LL_OMAP7XX(p, mach)					\
-	_DEBUG_LL_ENTRY(mach, OMAP1_UART##p##_BASE, OMAP7XX_PORT_SHIFT,	\
-		OMAP1UART##p)
+	_DEBUG_LL_ENTRY(mach, OMAP1_UART##p##_BASE, OMAP7XX_PORT_SHIFT)
 
 #define DEBUG_LL_OMAP1(p, mach)						\
-	_DEBUG_LL_ENTRY(mach, OMAP1_UART##p##_BASE, OMAP_PORT_SHIFT,	\
-		OMAP1UART##p)
+	_DEBUG_LL_ENTRY(mach, OMAP1_UART##p##_BASE, OMAP_PORT_SHIFT)
 
 #define DEBUG_LL_OMAP2(p, mach)						\
-	_DEBUG_LL_ENTRY(mach, OMAP2_UART##p##_BASE, OMAP_PORT_SHIFT,	\
-		OMAP2UART##p)
+	_DEBUG_LL_ENTRY(mach, OMAP2_UART##p##_BASE, OMAP_PORT_SHIFT)
 
 #define DEBUG_LL_OMAP3(p, mach)						\
-	_DEBUG_LL_ENTRY(mach, OMAP3_UART##p##_BASE, OMAP_PORT_SHIFT,	\
-		OMAP3UART##p)
+	_DEBUG_LL_ENTRY(mach, OMAP3_UART##p##_BASE, OMAP_PORT_SHIFT)
 
 #define DEBUG_LL_OMAP4(p, mach)						\
-	_DEBUG_LL_ENTRY(mach, OMAP4_UART##p##_BASE, OMAP_PORT_SHIFT,	\
-		OMAP4UART##p)
+	_DEBUG_LL_ENTRY(mach, OMAP4_UART##p##_BASE, OMAP_PORT_SHIFT)
 
 /* Zoom2/3 shift is different for UART1 and external port */
 #define DEBUG_LL_ZOOM(mach)						\
-	_DEBUG_LL_ENTRY(mach, ZOOM_UART_BASE, ZOOM_PORT_SHIFT, ZOOM_UART)
+	_DEBUG_LL_ENTRY(mach, ZOOM_UART_BASE, ZOOM_PORT_SHIFT)
 
 static inline void __arch_decomp_setup(unsigned long arch_id)
 {
-	int port = 0;
-
 	/*
 	 * Initialize the port based on the machine ID from the bootloader.
 	 * Note that we're using macros here instead of switch statement
author maintainer
#2 lore raw

PATCH 2/5 omap: Use inituart to configure the debug serial port based on machine ID

In reply to Tony Lindgren

Set the debug serial port based on machine ID. Note that most of the patch is just trivial checking for the machine ID.

Also note that this code won't work for debugging the uncompress code.

---
 arch/arm/mach-omap1/include/mach/debug-macro.S |   77 +++++++++++++-
 arch/arm/mach-omap1/serial.c                   |    7 +
 arch/arm/mach-omap2/include/mach/debug-macro.S |  130 ++++++++++++++++++++++--
 arch/arm/mach-omap2/serial.c                   |    7 +
 4 files changed, 204 insertions(+), 17 deletions(-)
arch/arm/mach-omap1/include/mach/debug-macro.S +70 -7
index db2cdf4..80dcf18 100644
@@ -14,24 +14,87 @@
 #include <linux/serial_reg.h>
 
 #include <asm/memory.h>
+#include <asm/mach-types.h>
 
+#include <plat/io.h>
 #include <plat/serial.h>
 
 #define omap_uart_v2p(x)	((x) - PAGE_OFFSET + PLAT_PHYS_OFFSET)
 
-		.pushsection .data
-omap_uart_phys:	.word	0x0
-omap_uart_virt:	.word	0x0
-		.popsection
-
+		/*
+		 * Intialize the debug serial port based on machine ID
+		 */
 		.macro	inituart, id, a, v
+		mrc	p15, 0, \a, c1, c0
+		tst	\a, #1			@ MMU enabled?
+		ldreq	\a, =omap_uart_v2p(omap_uart_phys)
+		ldrne	\a, =omap_uart_phys
+		mov	\v, #(UART_LSR << OMAP_PORT_SHIFT)
+		str	\v, [\a, #8]		@ save lsr, different for 7xx
+
+		/* omap7xx/8xx based boards using uart1 with shift 0 */
+		ldr	\v, =MACH_TYPE_HERALD
+		cmp	\id, \v
+		ldrne	\v, =MACH_TYPE_OMAP_PERSEUS2
+		cmpne	\id, \v
+		ldreq	\v, =OMAP1_UART1_BASE
+		streq	\v, [\a, #0]		@ save port phys addr
+		ldreq	\v, =(OMAP1_UART1_BASE - OMAP1_IO_OFFSET)
+		streq	\v, [\a, #4]		@ save port virt addr
+		moveq	\v, #(UART_LSR << OMAP7XX_PORT_SHIFT)
+		streq	\v, [\a, #8]		@ save lsr, different for 7xx
+		beq	999f
+
+		/* omap15xx/16xx based boards using uart1 */
+		ldr	\v, =MACH_TYPE_AMS_DELTA
+		cmp	\id, \v
+		ldrne	\v, =MACH_TYPE_NOKIA770
+		cmpne	\id, \v
+		ldrne	\v, =MACH_TYPE_OMAP_H2
+		cmpne	\id, \v
+		ldrne	\v, =MACH_TYPE_OMAP_H3
+		cmpne	\id, \v
+		ldrne	\v, =MACH_TYPE_OMAP_INNOVATOR
+		cmpne	\id, \v
+		ldrne	\v, =MACH_TYPE_OMAP_OSK
+		cmpne	\id, \v
+		ldrne	\v, =MACH_TYPE_OMAP_PALMTE
+		cmpne	\id, \v
+		ldrne	\v, =MACH_TYPE_OMAP_PALMZ71
+		cmpne	\id, \v
+		ldreq	\v, =OMAP1_UART1_BASE
+		streq	\v, [\a, #0]		@ save port phys addr
+		ldreq	\v, =(OMAP1_UART1_BASE - OMAP1_IO_OFFSET)
+		streq	\v, [\a, #4]		@ save port virt addr
+		beq	999f
+
+		/* omap15xx/16xx based boards using uart2 */
+		ldr	\v, =MACH_TYPE_OMAP_PALMTT
+		cmp	\id, \v
+		ldreq	\v, =OMAP1_UART2_BASE
+		streq	\v, [\a, #0]		@ save port phys addr
+		ldreq	\v, =(OMAP1_UART2_BASE - OMAP1_IO_OFFSET)
+		streq	\v, [\a, #4]		@ save port virt addr
+		beq	999f
+
+		/* omap15xx/16xx based boards using uart3 */
+		ldr	\v, =MACH_TYPE_SX1
+		cmp	\id, \v
+		ldreq	\v, =OMAP1_UART3_BASE
+		streq	\v, [\a, #0]		@ save port phys addr
+		ldreq	\v, =(OMAP1_UART3_BASE - OMAP1_IO_OFFSET)
+		streq	\v, [\a, #4]		@ save port virt addr
+		beq	999f
+
+999:
 		.endm
 
 		/*
 		 * Note that this code won't work if the bootloader passes
 		 * a wrong machine ID number in r1. To debug, just hardcode
-		 * the desired UART phys and virt addresses temporarily into
-		 * the omap_uart_phys and omap_uart_virt above.
+		 * the desired omap_uart_phys, omap_uart_virt and omap_uart_lsr
+		 * temporarily into mach-omap[12]/serial.c and comment out
+		 * the inituart macro above.
 		 */
 		.macro	addruart, rp, rv
 
arch/arm/mach-omap1/serial.c +7 -0
index 550ca9d..8b4ce4a 100644
@@ -29,6 +29,13 @@
 
 #include "pm.h"
 
+#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
+/* Used by inituart, addruart and busyuart. See debug-macro.S */
+void __iomem *omap_uart_phys;
+void __iomem *omap_uart_virt;
+void __iomem *omap_uart_lsr;
+#endif
+
 static struct clk * uart1_ck;
 static struct clk * uart2_ck;
 static struct clk * uart3_ck;
arch/arm/mach-omap2/include/mach/debug-macro.S +120 -10

147 lines not on this page · raw message

arch/arm/mach-omap2/serial.c +7 -0
index 32e91a9..9a41d6c 100644
@@ -104,6 +104,13 @@ struct omap_uart_state {
 #endif
 };
 
+#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
+/* Used by inituart, addruart and busyuart. See debug-macro.S */
+void __iomem *omap_uart_phys;
+void __iomem *omap_uart_virt;
+void __iomem *omap_uart_lsr;
+#endif
+
 static LIST_HEAD(uart_list);
 static u8 num_uarts;
 
#3 lore raw

PATCH 2/5 omap: Use inituart to configure the debug serial port based on machine ID

Quoted 7 lines · Tony Lindgren

Set the debug serial port based on machine ID. Note that most of the patch is just trivial checking for the machine ID.

Also note that this code won't work for debugging the uncompress code.

---

<snip>

Quoted 4 lines
arch/arm/mach-omap2/include/mach/debug-macro.S +0 -0
index 336a838..45c29e3 100644

<snip>

Quoted 27 lines

+
+ ? ? ? ? ? ? ? /* omap3 based boards using uart3 */
+ ? ? ? ? ? ? ? ldr ? ? \v, =MACH_TYPE_CM_T35
+ ? ? ? ? ? ? ? cmp ? ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_CM_T3517
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_CRANEBOARD
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_DEVKIT8000
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_IGEP0020
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_IGEP0030
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_NOKIA_RM680
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_NOKIA_RX51
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_OMAP3517EVM
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_OMAP3_BEAGLE
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_OMAP3_PANDORA
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_OMAP_LDP
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_OVERO

Quoted 8 lines

+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldrne ? \v, =MACH_TYPE_TOUCHBOOK
+ ? ? ? ? ? ? ? cmpne ? \id, \v
+ ? ? ? ? ? ? ? ldreq ? \v, =OMAP3_UART3_BASE
+ ? ? ? ? ? ? ? streq ? \v, [\a, #0] ? ? ? ? ? ?@ save port phys addr
+ ? ? ? ? ? ? ? ldreq ? \v, =(OMAP3_UART3_BASE + OMAP2_L4_IO_OFFSET)
+ ? ? ? ? ? ? ? streq ? \v, [\a, #4] ? ? ? ? ? ?@ save port virt addr
+ ? ? ? ? ? ? ? beq ? ? 999f

This looks a bit wasteful not only because of repeated CMPs, but also LDRs are generating a large literal pool. Maybe something like that be better:

adr r0, uart3_machines
0:

    ldrh    \v, [r0], #2
    tst     \v, \v
    beq     999f                    @ end of list
    cmp     \id, \v
    bne     0b
    ldr     \v, =OMAP3_UART3_BASE
    str     \v, [\a, #0]            @ save port phys addr
    ldr     \v, =(OMAP3_UART3_BASE + OMAP2_L4_IO_OFFSET)
    str     \v, [\a, #4]            @ save port virt addr
    b       999f
    uart3_machines:
    .short MACH_TYPE_CM_T35
    .short MACH_TYPE_CM_T3517
    ...
    .short 0

of course this needs an extra register..

author maintainer
#4 lore raw

PATCH 2/5 omap: Use inituart to configure the debug serial port based on machine ID

Quoted 4 lines · Grazvydas Ignotas
Quoted 3 lines · Tony Lindgren

Set the debug serial port based on machine ID. Note that most of the patch is just trivial checking for the machine ID.

..

Quoted 17 lines

This looks a bit wasteful not only because of repeated CMPs, but also LDRs are generating a large literal pool. Maybe something like that be better:

adr r0, uart3_machines
0:

    ldrh    \v, [r0], #2
    tst     \v, \v
    beq     999f                    @ end of list
    cmp     \id, \v
    bne     0b
    ldr     \v, =OMAP3_UART3_BASE
    str     \v, [\a, #0]            @ save port phys addr
    ldr     \v, =(OMAP3_UART3_BASE + OMAP2_L4_IO_OFFSET)
    str     \v, [\a, #4]            @ save port virt addr
    b       999f
Quoted 7 lines
    uart3_machines:
    .short MACH_TYPE_CM_T35
    .short MACH_TYPE_CM_T3517
    ...
    .short 0

of course this needs an extra register..

Hmm, addruart and busyuart are limited with registers, but inituart may not be. I'll take a look if that can be done.

Regards,

Tony

author maintainer
#5 lore raw

PATCH 3/5 omap: Add support for CONFIG_AUTO_ZRELADDR for DEBUG_LL

In reply to Tony Lindgren

This way we can have the debug-macro.S be common for omap1 and omap2+ and get sensible error messages booting the wrong zImage with CONFIG_AUTO_ZRELADDR selected. Note that this does not seem to work with u-boot and uImage.

---
 arch/arm/mach-omap1/include/mach/debug-macro.S |   36 ++++++++++++++++++++----
 arch/arm/mach-omap2/include/mach/debug-macro.S |   27 +++++++++++++++++-
 2 files changed, 56 insertions(+), 7 deletions(-)
arch/arm/mach-omap1/include/mach/debug-macro.S +30 -6
index 80dcf18..bae924e 100644
@@ -27,7 +27,15 @@
 		.macro	inituart, id, a, v
 		mrc	p15, 0, \a, c1, c0
 		tst	\a, #1			@ MMU enabled?
+#ifdef CONFIG_AUTO_ZRELADDR
+		ldreq	\a, =omap_uart_phys
+		biceq	\a, \a, #0xf8000000	@ clear top bits of virt addr
+		moveq	\v, pc			@ copy pc
+		andeq	\v, \v, #0xf8000000	@ clear lower bits
+		orreq	\a, \v			@ combile to get phys addr
+#else
 		ldreq	\a, =omap_uart_v2p(omap_uart_phys)
+#endif
 		ldrne	\a, =omap_uart_phys
 		mov	\v, #(UART_LSR << OMAP_PORT_SHIFT)
 		str	\v, [\a, #8]		@ save lsr, different for 7xx
@@ -101,7 +109,15 @@
 		/* Use omap_uart_phys/virt if already configured */
 		mrc	p15, 0, \rp, c1, c0
 		tst	\rp, #1			@ MMU enabled?
+#ifdef CONFIG_AUTO_ZRELADDR
+		ldreq	\rp, =omap_uart_phys	@ MMU disabled
+		biceq	\rp, \rp, #0xf8000000	@ clear top bits of virt addr
+		moveq	\rv, pc			@ copy pc
+		andeq	\rv, \rv, #0xf8000000	@ clear lower bits
+		orreq	\rp, \rv		@ combine to get phys addr
+#else
 		ldreq	\rp, =omap_uart_v2p(omap_uart_phys)	@ MMU disabled
+#endif
 		ldrne	\rp, =omap_uart_phys	@ MMU enabled
 		add	\rv, \rp, #4		@ omap_uart_virt
 		ldr	\rp, [\rp, #0]
@@ -113,15 +129,23 @@
 		.endm
 
 		.macro	busyuart,rd,rx
-1001:		ldrb	\rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)]
-		and	\rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
-		teq	\rd, #(UART_LSR_TEMT | UART_LSR_THRE)
-		beq	1002f
-		ldrb	\rd, [\rx, #(UART_LSR << OMAP7XX_PORT_SHIFT)]
+1001:		mrc	p15, 0, \rd, c1, c0
+		tst	\rd, #1			@ MMU enabled?
+#ifdef CONFIG_AUTO_ZRELADDR
+		ldreq	\rd, =omap_uart_lsr	@ MMU disabled
+		biceq	\rd, \rd, #0xf8000000	@ clear top bits of virt addr
+		roreq	\rd, \rd, #27		@ rotate bits
+		orreq	\rd, pc, lsr #27	@ orr with top bits of pc
+		roreq	\rd, \rd, #5		@ rotate bits back
+#else
+		ldreq	\rd, =omap_uart_v2p(omap_uart_lsr)	@ MMU disabled
+#endif
+		ldrne	\rd, =omap_uart_lsr	@ MMU enabled
+		ldr	\rd, [\rd, #0]
+		ldrb	\rd, [\rx, \rd]
 		and	\rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
 		teq	\rd, #(UART_LSR_TEMT | UART_LSR_THRE)
 		bne	1001b
-1002:
 		.endm
 
 		.macro	waituart,rd,rx
arch/arm/mach-omap2/include/mach/debug-macro.S +26 -1
index 45c29e3..80e0bdc 100644
@@ -27,8 +27,17 @@
 		.macro	inituart, id, a, v
 		mrc	p15, 0, \a, c1, c0
 		tst	\a, #1			@ MMU enabled?
+		ldreq	\a, =omap_uart_phys
+#ifdef CONFIG_AUTO_ZRELADDR
+		ldreq	\a, =omap_uart_phys
+		biceq	\a, \a, #0xf8000000	@ clear top bits of virt addr
+		moveq	\v, pc			@ copy pc
+		andeq	\v, \v, #0xf8000000	@ clear lower bits
+		orreq	\a, \v			@ combile to get phys addr
+#else
 		ldreq	\a, =omap_uart_v2p(omap_uart_phys)
-		ldrne	\a, =omap_uart_phys
+#endif
+		ldrne	\a, =omap_uart_phys	@ MMU enabled
 		mov	\v, #(UART_LSR << OMAP_PORT_SHIFT)
 		str	\v, [\a, #8]		@ save lsr, different for zoom
 
@@ -151,7 +160,15 @@
 		/* Use omap_uart_phys/virt if already configured */
 		mrc	p15, 0, \rp, c1, c0
 		tst	\rp, #1			@ MMU enabled?
+#ifdef CONFIG_AUTO_ZRELADDR
+		ldreq	\rp, =omap_uart_phys	@ MMU disabled
+		biceq	\rp, \rp, #0xf8000000	@ clear top bits of virt addr
+		moveq	\rv, pc			@ copy pc
+		andeq	\rv, \rv, #0xf8000000	@ clear lower bits
+		orreq	\rp, \rv		@ combine to get phys addr
+#else
 		ldreq	\rp, =omap_uart_v2p(omap_uart_phys)	@ MMU disabled
+#endif
 		ldrne	\rp, =omap_uart_phys	@ MMU enabled
 		add	\rv, \rp, #4		@ omap_uart_virt
 		ldr	\rp, [\rp, #0]
@@ -165,7 +182,15 @@
 		.macro	busyuart,rd,rx
 1001:		mrc	p15, 0, \rd, c1, c0
 		tst	\rd, #1			@ MMU enabled?
+#ifdef CONFIG_AUTO_ZRELADDR
+		ldreq	\rd, =omap_uart_lsr	@ MMU disabled
+		biceq	\rd, \rd, #0xf8000000	@ clear top bits of virt addr
+		roreq	\rd, \rd, #27		@ rotate bits
+		orreq	\rd, pc, lsr #27	@ orr with top bits of pc
+		roreq	\rd, \rd, #5		@ rotate bits back
+#else
 		ldreq	\rd, =omap_uart_v2p(omap_uart_lsr)	@ MMU disabled
+#endif
 		ldrne	\rd, =omap_uart_lsr	@ MMU enabled
 		ldr	\rd, [\rd, #0]
 		ldrb	\rd, [\rx, \rd]
#6 lore raw

PATCH 3/5 omap: Add support for CONFIG_AUTO_ZRELADDR for DEBUG_LL

Quoted 19 lines · Tony Lindgren

This way we can have the debug-macro.S be common for omap1 and omap2+ and get sensible error messages booting the wrong zImage with CONFIG_AUTO_ZRELADDR selected. Note that this does not seem to work with u-boot and uImage.

---
 arch/arm/mach-omap1/include/mach/debug-macro.S |   36 ++++++++++++++++++++----
 arch/arm/mach-omap2/include/mach/debug-macro.S |   27 +++++++++++++++++-
 2 files changed, 56 insertions(+), 7 deletions(-)
arch/arm/mach-omap1/include/mach/debug-macro.S +0 -0
index 80dcf18..bae924e 100644
@@ -27,7 +27,15 @@
 		.macro	inituart, id, a, v
 		mrc	p15, 0, \a, c1, c0
 		tst	\a, #1			@ MMU enabled?

arch/arm/mach-omap1/include/mach/debug-macro.S line 39

Quoted 10 lines
arch/arm/mach-omap1/include/mach/debug-macro.S +8 -0
+#ifdef CONFIG_AUTO_ZRELADDR
+		ldreq	\a, =omap_uart_phys
+		biceq	\a, \a, #0xf8000000	@ clear top bits of virt addr
+		moveq	\v, pc			@ copy pc
+		andeq	\v, \v, #0xf8000000	@ clear lower bits
+		orreq	\a, \v			@ combile to get phys addr
+#else
 		ldreq	\a, =omap_uart_v2p(omap_uart_phys)
+#endif
 		ldrne	\a, =omap_uart_phys

Gaaaaah! This is horrible.

OK, you do want to store data in memory, right? So the best way to always be position independent, even cross section, is to do the following (inspired by RMK's trick in the p2v series):

.data

foo: .word 0 @ value for sput
.word 0 @ value for nik

.text

bar: .word .
.word foo

sputnik:

adr r0, bar @ get relative address of bar
ldr r1, [r0] @ get absolute address of bar
sub r1, r1, r0 @ difference between abs and rel address
ldr r0, [r0, #4] @ get absolute address of foo
sub r0, r0, r1 @ turn that into a relative address

ldmia r0, {r1, r2} @ retrieve sput and nik
add r0, r1, r2
mov pc, lr

This code is totally position independent, so it works whether or not the MMU is active. Therefore a similar technique in your macro (you could even put it into a macro for it) would allow you to get rid of the mrc and test for MMU active, get rid of the #ifdef, and not be limited to a 128 MB mask, etc. And it is just one word longer than your shortest version i.e. 2 constants + 5 instructions vs 4 instructions + 2 literal pool entries.

Nicolas

author maintainer
#7 lore raw

PATCH 3/5 omap: Add support for CONFIG_AUTO_ZRELADDR for DEBUG_LL

Quoted 6 lines · Nicolas Pitre
Quoted 4 lines · Tony Lindgren

This way we can have the debug-macro.S be common for omap1 and omap2+ and get sensible error messages booting the wrong zImage with CONFIG_AUTO_ZRELADDR selected. Note that this does not seem to work with u-boot and uImage.

...

Quoted 1 line

Gaaaaah! This is horrible.

-ENOREGISTERS :)

Quoted 26 lines

OK, you do want to store data in memory, right? So the best way to always be position independent, even cross section, is to do the following (inspired by RMK's trick in the p2v series):

.data

foo: .word 0 @ value for sput
.word 0 @ value for nik

.text

bar: .word .
.word foo

sputnik:

adr r0, bar @ get relative address of bar
ldr r1, [r0] @ get absolute address of bar
sub r1, r1, r0 @ difference between abs and rel address
ldr r0, [r0, #4] @ get absolute address of foo
sub r0, r0, r1 @ turn that into a relative address

ldmia r0, {r1, r2} @ retrieve sput and nik
add r0, r1, r2
mov pc, lr

Quoted 7 lines

This code is totally position independent, so it works whether or not the MMU is active. Therefore a similar technique in your macro (you could even put it into a macro for it) would allow you to get rid of the mrc and test for MMU active, get rid of the #ifdef, and not be limited to a 128 MB mask, etc. And it is just one word longer than your shortest version i.e. 2 constants + 5 instructions vs 4 instructions + 2 literal pool entries.

I think if we keep the address of the memory location in rx instead of the port address value, then this could be done.

That would limit all the trickery to inituart only. Then addruart and busyuart could just do ldr from the memory location to get the port data without any trickery.

In that case the mapping of IO space for the serial port in head.S would have to be changed as that relies on rx containing the port IO address..

Regards,

Tony

#8 lore raw

PATCH 3/5 omap: Add support for CONFIG_AUTO_ZRELADDR for DEBUG_LL

Quoted 47 lines · Tony Lindgren
Quoted 6 lines · Nicolas Pitre
Quoted 4 lines · Tony Lindgren

This way we can have the debug-macro.S be common for omap1 and omap2+ and get sensible error messages booting the wrong zImage with CONFIG_AUTO_ZRELADDR selected. Note that this does not seem to work with u-boot and uImage.

...

Quoted 1 line

Gaaaaah! This is horrible.

-ENOREGISTERS :)

Quoted 26 lines

OK, you do want to store data in memory, right? So the best way to always be position independent, even cross section, is to do the following (inspired by RMK's trick in the p2v series):

.data

foo: .word 0 @ value for sput
.word 0 @ value for nik

.text

bar: .word .
.word foo

sputnik:

adr r0, bar @ get relative address of bar
ldr r1, [r0] @ get absolute address of bar
sub r1, r1, r0 @ difference between abs and rel address
ldr r0, [r0, #4] @ get absolute address of foo
sub r0, r0, r1 @ turn that into a relative address

ldmia r0, {r1, r2} @ retrieve sput and nik
add r0, r1, r2
mov pc, lr

Quoted 7 lines

This code is totally position independent, so it works whether or not the MMU is active. Therefore a similar technique in your macro (you could even put it into a macro for it) would allow you to get rid of the mrc and test for MMU active, get rid of the #ifdef, and not be limited to a 128 MB mask, etc. And it is just one word longer than your shortest version i.e. 2 constants + 5 instructions vs 4 instructions + 2 literal pool entries.

Quoted 6 lines

I think if we keep the address of the memory location in rx instead of the port address value, then this could be done.

That would limit all the trickery to inituart only. Then addruart and busyuart could just do ldr from the memory location to get the port data without any trickery.

Just create a get_config_ptr macro or similar and the trickery will be nicely encapsulated. You'd have:

	.macro get_config_ptr ptr, tmp
	b	9002f
	.align
9001:	.long	.
	.long	uart_param_storage
9002:	adr	\ptr, 9001b
	ldr	\tmp, [\ptr]
	sub	\tmp, \tmp, \ptr
	ldr	\ptr, [\ptr, #4]
	sub	\ptr, \ptr, \tmp
	.endm

	.macro addruart rp, rv
	get_config_ptr \rv
	ldr	\rp, [\rv]
	ldr	\rv, [\rv, #4]
	.endm

And for the other macros, you get the hardware address to use already, but you can still use get_config_ptr for extra config values you need if necessary.

Quoted 3 lines

In that case the mapping of IO space for the serial port in head.S would have to be changed as that relies on rx containing the port IO address..

Yes, and I'm not sure if it is worth changing that at this point when it is possible to do it without introducing such a change which would affect all machines again.

Nicolas

author maintainer
#9 lore raw

PATCH 3/5 omap: Add support for CONFIG_AUTO_ZRELADDR for DEBUG_LL

Quoted 22 lines · Nicolas Pitre

Just create a get_config_ptr macro or similar and the trickery will be nicely encapsulated. You'd have:

	.macro get_config_ptr ptr, tmp
	b	9002f
	.align
9001:	.long	.
	.long	uart_param_storage
9002:	adr	\ptr, 9001b
	ldr	\tmp, [\ptr]
	sub	\tmp, \tmp, \ptr
	ldr	\ptr, [\ptr, #4]
	sub	\ptr, \ptr, \tmp
	.endm

	.macro addruart rp, rv
	get_config_ptr \rv
	ldr	\rp, [\rv]
	ldr	\rv, [\rv, #4]
	.endm
Quoted 3 lines

And for the other macros, you get the hardware address to use already, but you can still use get_config_ptr for extra config values you need if necessary.

Thanks, will try that out next week. That might run into problems with busyuart as it only has rd register to play with.

Quoted 7 lines
Quoted 3 lines

In that case the mapping of IO space for the serial port in head.S would have to be changed as that relies on rx containing the port IO address..

Yes, and I'm not sure if it is worth changing that at this point when it is possible to do it without introducing such a change which would affect all machines again.

Agreed, let's see how far we can get with the existing setup.

What might need to be done is to save and restore rx in busyuart to be able to use your macro above.

Tony

#10 lore raw

PATCH 3/5 omap: Add support for CONFIG_AUTO_ZRELADDR for DEBUG_LL

Quoted 23 lines · Tony Lindgren
Quoted 22 lines · Nicolas Pitre

Just create a get_config_ptr macro or similar and the trickery will be nicely encapsulated. You'd have:

	.macro get_config_ptr ptr, tmp
	b	9002f
	.align
9001:	.long	.
	.long	uart_param_storage
9002:	adr	\ptr, 9001b
	ldr	\tmp, [\ptr]
	sub	\tmp, \tmp, \ptr
	ldr	\ptr, [\ptr, #4]
	sub	\ptr, \ptr, \tmp
	.endm

	.macro addruart rp, rv
	get_config_ptr \rv
	ldr	\rp, [\rv]
	ldr	\rv, [\rv, #4]
	.endm
Quoted 6 lines
Quoted 3 lines

And for the other macros, you get the hardware address to use already, but you can still use get_config_ptr for extra config values you need if necessary.

Thanks, will try that out next week. That might run into problems with busyuart as it only has rd register to play with.

With some code auditing we could declare ip as being callee clobberable with those macros.

Nicolas

#11 lore raw

PATCH 3/5 omap: Add support for CONFIG_AUTO_ZRELADDR for DEBUG_LL

In reply to Nicolas Pitre
Quoted 34 lines · Nicolas Pitre
Quoted 19 lines · Tony Lindgren

This way we can have the debug-macro.S be common for omap1 and omap2+ and get sensible error messages booting the wrong zImage with CONFIG_AUTO_ZRELADDR selected. Note that this does not seem to work with u-boot and uImage.

---
 arch/arm/mach-omap1/include/mach/debug-macro.S |   36 ++++++++++++++++++++----
 arch/arm/mach-omap2/include/mach/debug-macro.S |   27 +++++++++++++++++-
 2 files changed, 56 insertions(+), 7 deletions(-)
arch/arm/mach-omap1/include/mach/debug-macro.S +0 -0
index 80dcf18..bae924e 100644
@@ -27,7 +27,15 @@
 		.macro	inituart, id, a, v
 		mrc	p15, 0, \a, c1, c0
 		tst	\a, #1			@ MMU enabled?

arch/arm/mach-omap1/include/mach/debug-macro.S line 39

Quoted 10 lines
arch/arm/mach-omap1/include/mach/debug-macro.S +8 -0
+#ifdef CONFIG_AUTO_ZRELADDR
+		ldreq	\a, =omap_uart_phys
+		biceq	\a, \a, #0xf8000000	@ clear top bits of virt addr
+		moveq	\v, pc			@ copy pc
+		andeq	\v, \v, #0xf8000000	@ clear lower bits
+		orreq	\a, \v			@ combile to get phys addr
+#else
 		ldreq	\a, =omap_uart_v2p(omap_uart_phys)
+#endif
 		ldrne	\a, =omap_uart_phys

Gaaaaah! This is horrible.

Quoted 3 lines

OK, you do want to store data in memory, right? So the best way to always be position independent, even cross section, is to do the following (inspired by RMK's trick in the p2v series):

The other point to make is that for every machine in OMAP1, the serial port is located at 0xffXXXXXX virtual, 0xfeXXXXXX physical. For OMAP2, that's 0xfaXXXXXX virtual and 0x48XXXXXX physical.

So it's pointless storing both the virtual and physical addresses as we can compute one from the other with a single instruction. That gets rid of some of the complexity found in the debugging code.

author maintainer
#12 lore raw

PATCH 3/5 omap: Add support for CONFIG_AUTO_ZRELADDR for DEBUG_LL

Quoted 8 lines · Russell King - ARM Linux

The other point to make is that for every machine in OMAP1, the serial port is located at 0xffXXXXXX virtual, 0xfeXXXXXX physical. For OMAP2, that's 0xfaXXXXXX virtual and 0x48XXXXXX physical.

So it's pointless storing both the virtual and physical addresses as we can compute one from the other with a single instruction. That gets rid of some of the complexity found in the debugging code.

OK. The zoom boards have external 8250 on the GPMC bus.

Tony

author maintainer
#13 lore raw

PATCH 4/5 omap: Combine debug-macro.S for omap1 and omap2+

In reply to Tony Lindgren

Now the DEBUG_LL code is the same for all omaps.

---
 arch/arm/mach-omap1/include/mach/debug-macro.S |  140 -------------
 arch/arm/mach-omap2/include/mach/debug-macro.S |  191 ------------------
 arch/arm/plat-omap/include/plat/debug-macro.S  |  257 ++++++++++++++++++++++++
 3 files changed, 259 insertions(+), 329 deletions(-)
 create mode 100644 arch/arm/plat-omap/include/plat/debug-macro.S
arch/arm/mach-omap1/include/mach/debug-macro.S +1 -139
index bae924e..fbf6f34 100644
@@ -11,142 +11,4 @@
  *
 */
 
-#include <linux/serial_reg.h>
-
-#include <asm/memory.h>
-#include <asm/mach-types.h>
-
-#include <plat/io.h>
-#include <plat/serial.h>
-
-#define omap_uart_v2p(x)	((x) - PAGE_OFFSET + PLAT_PHYS_OFFSET)
-
-		/*
-		 * Intialize the debug serial port based on machine ID
-		 */
-		.macro	inituart, id, a, v
-		mrc	p15, 0, \a, c1, c0
-		tst	\a, #1			@ MMU enabled?
-#ifdef CONFIG_AUTO_ZRELADDR
-		ldreq	\a, =omap_uart_phys
-		biceq	\a, \a, #0xf8000000	@ clear top bits of virt addr
-		moveq	\v, pc			@ copy pc
-		andeq	\v, \v, #0xf8000000	@ clear lower bits
-		orreq	\a, \v			@ combile to get phys addr
-#else
-		ldreq	\a, =omap_uart_v2p(omap_uart_phys)
-#endif
-		ldrne	\a, =omap_uart_phys
-		mov	\v, #(UART_LSR << OMAP_PORT_SHIFT)
-		str	\v, [\a, #8]		@ save lsr, different for 7xx
-
-		/* omap7xx/8xx based boards using uart1 with shift 0 */
-		ldr	\v, =MACH_TYPE_HERALD
-		cmp	\id, \v
-		ldrne	\v, =MACH_TYPE_OMAP_PERSEUS2
-		cmpne	\id, \v
-		ldreq	\v, =OMAP1_UART1_BASE
-		streq	\v, [\a, #0]		@ save port phys addr
-		ldreq	\v, =(OMAP1_UART1_BASE - OMAP1_IO_OFFSET)
-		streq	\v, [\a, #4]		@ save port virt addr
-		moveq	\v, #(UART_LSR << OMAP7XX_PORT_SHIFT)
-		streq	\v, [\a, #8]		@ save lsr, different for 7xx
-		beq	999f
-
-		/* omap15xx/16xx based boards using uart1 */
-		ldr	\v, =MACH_TYPE_AMS_DELTA
-		cmp	\id, \v
-		ldrne	\v, =MACH_TYPE_NOKIA770
-		cmpne	\id, \v
-		ldrne	\v, =MACH_TYPE_OMAP_H2
-		cmpne	\id, \v
-		ldrne	\v, =MACH_TYPE_OMAP_H3
-		cmpne	\id, \v
-		ldrne	\v, =MACH_TYPE_OMAP_INNOVATOR
-		cmpne	\id, \v
-		ldrne	\v, =MACH_TYPE_OMAP_OSK
-		cmpne	\id, \v
-		ldrne	\v, =MACH_TYPE_OMAP_PALMTE
-		cmpne	\id, \v
-		ldrne	\v, =MACH_TYPE_OMAP_PALMZ71
-		cmpne	\id, \v
-		ldreq	\v, =OMAP1_UART1_BASE
-		streq	\v, [\a, #0]		@ save port phys addr
-		ldreq	\v, =(OMAP1_UART1_BASE - OMAP1_IO_OFFSET)
-		streq	\v, [\a, #4]		@ save port virt addr
-		beq	999f
-
-		/* omap15xx/16xx based boards using uart2 */
-		ldr	\v, =MACH_TYPE_OMAP_PALMTT
-		cmp	\id, \v
-		ldreq	\v, =OMAP1_UART2_BASE
-		streq	\v, [\a, #0]		@ save port phys addr
-		ldreq	\v, =(OMAP1_UART2_BASE - OMAP1_IO_OFFSET)
-		streq	\v, [\a, #4]		@ save port virt addr
-		beq	999f
-
-		/* omap15xx/16xx based boards using uart3 */
-		ldr	\v, =MACH_TYPE_SX1
-		cmp	\id, \v
-		ldreq	\v, =OMAP1_UART3_BASE
-		streq	\v, [\a, #0]		@ save port phys addr
-		ldreq	\v, =(OMAP1_UART3_BASE - OMAP1_IO_OFFSET)
-		streq	\v, [\a, #4]		@ save port virt addr
-		beq	999f
-
-999:
-		.endm
-
-		/*
-		 * Note that this code won't work if the bootloader passes
-		 * a wrong machine ID number in r1. To debug, just hardcode
-		 * the desired omap_uart_phys, omap_uart_virt and omap_uart_lsr
-		 * temporarily into mach-omap[12]/serial.c and comment out
-		 * the inituart macro above.
-		 */
-		.macro	addruart, rp, rv
-
-		/* Use omap_uart_phys/virt if already configured */
-		mrc	p15, 0, \rp, c1, c0
-		tst	\rp, #1			@ MMU enabled?
-#ifdef CONFIG_AUTO_ZRELADDR
-		ldreq	\rp, =omap_uart_phys	@ MMU disabled
-		biceq	\rp, \rp, #0xf8000000	@ clear top bits of virt addr
-		moveq	\rv, pc			@ copy pc
-		andeq	\rv, \rv, #0xf8000000	@ clear lower bits
-		orreq	\rp, \rv		@ combine to get phys addr
-#else
-		ldreq	\rp, =omap_uart_v2p(omap_uart_phys)	@ MMU disabled
-#endif
-		ldrne	\rp, =omap_uart_phys	@ MMU enabled
-		add	\rv, \rp, #4		@ omap_uart_virt
-		ldr	\rp, [\rp, #0]
-		ldr	\rv, [\rv, #0]
-		.endm
-
-		.macro	senduart,rd,rx
-		strb	\rd, [\rx]
-		.endm
-
-		.macro	busyuart,rd,rx
-1001:		mrc	p15, 0, \rd, c1, c0
-		tst	\rd, #1			@ MMU enabled?
-#ifdef CONFIG_AUTO_ZRELADDR
-		ldreq	\rd, =omap_uart_lsr	@ MMU disabled
-		biceq	\rd, \rd, #0xf8000000	@ clear top bits of virt addr
-		roreq	\rd, \rd, #27		@ rotate bits
-		orreq	\rd, pc, lsr #27	@ orr with top bits of pc
-		roreq	\rd, \rd, #5		@ rotate bits back
-#else
-		ldreq	\rd, =omap_uart_v2p(omap_uart_lsr)	@ MMU disabled
-#endif
-		ldrne	\rd, =omap_uart_lsr	@ MMU enabled
-		ldr	\rd, [\rd, #0]
-		ldrb	\rd, [\rx, \rd]
-		and	\rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
-		teq	\rd, #(UART_LSR_TEMT | UART_LSR_THRE)
-		bne	1001b
-		.endm
-
-		.macro	waituart,rd,rx
-		.endm
+#include <plat/debug-macro.S>
arch/arm/mach-omap2/include/mach/debug-macro.S +1 -190

194 lines not on this page · raw message

arch/arm/plat-omap/include/plat/debug-macro.S new file +257 -0

257 lines not on this page · raw message

author maintainer
#14 lore raw

PATCH 5/5 omap: Add CONFIG_AUTO_ZRELADDR and CONFIG_ARM_PATCH_PHYS_VIRT to defconfigs

In reply to Tony Lindgren

Add CONFIG_AUTO_ZRELADDR and CONFIG_ARM_PATCH_PHYS_VIRT to defconfigs.

---
 arch/arm/configs/omap1_defconfig     |    2 ++
 arch/arm/configs/omap2plus_defconfig |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/configs/omap1_defconfig +2 -0
index 7b63462..261d37a 100644
@@ -1,3 +1,4 @@
+CONFIG_ARM_PATCH_PHYS_VIRT=y
 CONFIG_EXPERIMENTAL=y
 # CONFIG_SWAP is not set
 CONFIG_SYSVIPC=y
@@ -67,6 +68,7 @@ CONFIG_LEDS_CPU=y
 CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
 CONFIG_CMDLINE="root=1f03 rootfstype=jffs2"
+CONFIG_AUTO_ZRELADDR=y
 CONFIG_FPE_NWFPE=y
 CONFIG_BINFMT_MISC=y
 CONFIG_PM=y
arch/arm/configs/omap2plus_defconfig +2 -0
index ae890ca..8c9d734 100644
@@ -1,3 +1,4 @@
+CONFIG_ARM_PATCH_PHYS_VIRT=y
 CONFIG_EXPERIMENTAL=y
 CONFIG_SYSVIPC=y
 CONFIG_POSIX_MQUEUE=y
@@ -65,6 +66,7 @@ CONFIG_ZBOOT_ROM_TEXT=0x0
 CONFIG_ZBOOT_ROM_BSS=0x0
 CONFIG_CMDLINE="root=/dev/mmcblk0p2 rootwait console=ttyO2,115200"
 CONFIG_KEXEC=y
+CONFIG_AUTO_ZRELADDR=y
 CONFIG_FPE_NWFPE=y
 CONFIG_VFP=y
 CONFIG_NEON=y
#15 lore raw

cover Change omap DEBUG_LL code to use inituart for AUTO_ZRELADDR and ARM_PATCH_PHYS_VIRT

In reply to Tony Lindgren
Quoted 31 lines · Tony Lindgren

Here are the changes to make omap DEBUG_LL code generic using the new inituart macro posted in a separate series. This allows leaving out the dependency to the uncompress code and allows error messages when trying to boot a wrong zImage.

Adding support for new machines should be only additional two lines of assembly per machine after these patches.

Regards,

Tony

---

Tony Lindgren (5):
? ? ?omap: Remove code configuring the DEBUG_LL serial port using uncompress code ? ? ?omap: Use inituart to configure the debug serial port based on machine ID ? ? ?omap: Add support for CONFIG_AUTO_ZRELADDR for DEBUG_LL
? ? ?omap: Combine debug-macro.S for omap1 and omap2+
? ? ?omap: Add CONFIG_AUTO_ZRELADDR and CONFIG_ARM_PATCH_PHYS_VIRT to defconfigs

?arch/arm/configs/omap1_defconfig ? ? ? ? ? ? ? | ? ?2
?arch/arm/configs/omap2plus_defconfig ? ? ? ? ? | ? ?2
?arch/arm/mach-omap1/include/mach/debug-macro.S | ? 98 ---------
?arch/arm/mach-omap1/serial.c ? ? ? ? ? ? ? ? ? | ? ?7 +
?arch/arm/mach-omap2/include/mach/debug-macro.S | ?138 -------------
?arch/arm/mach-omap2/serial.c ? ? ? ? ? ? ? ? ? | ? ?7 +
?arch/arm/plat-omap/include/plat/debug-macro.S ?| ?257 ++++++++++++++++++++++++
?arch/arm/plat-omap/include/plat/serial.h ? ? ? | ? 34 ---
?arch/arm/plat-omap/include/plat/uncompress.h ? | ? 32 +--
Quoted 2 lines

?9 files changed, 284 insertions(+), 293 deletions(-) ?create mode 100644 arch/arm/plat-omap/include/plat/debug-macro.

Boot tested linux-next branch with omap2plus_defconfig using NFS filesystem along with the above 5 patch series and
2 patch series (Allow using machine ID for DEBUG_LL macros)
on Omap 2420,2430,3430 SDPs and Omap4 blaze.