Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code generic, v2

2010-01-23 Thread Tony Lindgren
* Pandita, Vikram vikram.pand...@ti.com [100122 15:08]:
 Tony
 
 -Original Message-
 From: Tony Lindgren [mailto:t...@atomide.com]
 Sent: Friday, January 22, 2010 3:11 PM
 To: Pandita, Vikram
 Cc: Russell King - ARM Linux; linux-arm-ker...@lists.infradead.org; 
 linux-omap@vger.kernel.org
 Subject: Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code 
 generic, v2
 
 * Pandita, Vikram vikram.pand...@ti.com [100122 12:56]:
 
 
  -Original Message-
  From: Tony Lindgren [mailto:t...@atomide.com]
  Sent: Friday, January 22, 2010 2:55 PM
  To: Pandita, Vikram
  Cc: Russell King - ARM Linux; linux-arm-ker...@lists.infradead.org; 
  linux-omap@vger.kernel.org
  Subject: Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code 
  generic, v2
  
  * Pandita, Vikram vikram.pand...@ti.com [100122 06:46]:
   
   OK, I've added that too, but for mach-omap2 only. I've also
   added an experimental zoom2/3 support.
   
   Care to take try it out and see what happens on a zoom?
  
   Test on zoom3 failed with multi-omap branch.
   Debugging the same, should have a zoom correction patch out today.
  
  Heh OK. I just pushed more updates into the multi-omap branch
  if you want to try to boot zoom2/zoom3 using the same .config.
 
  Refreshed my tree and I don't see your patches yet.
 
 Takes a few minutes to get mirrored from master.kernel.org..
 
 Yes I tried with new branch and zoom2/3 does not work.
 Root cause: 
 There is a very basic issue in low level code.
 
 We are allowed to create only one Physical to Virtual mapping using 
 MACHINE_START() phys_io and io_pg_offst of size 0x10(1MB).
 
 Now for zoom2/3 we need to do following:
 MACHINE_START(OMAP_ZOOM3, OMAP Zoom3 board)
 -   .phys_io= 0x4800,
 -   .io_pg_offst= ((0xfa00)  18)  0xfffc,
 +   .phys_io= 0x100, /*ZOOM_UART_BASE*/
 +   .io_pg_offst= ((0xfb00)  18)  0xfffc, /*ZOOM_UART_VIRT*/
 .boot_params= 0x8100,
 .map_io = omap_zoom_map_io,
 .init_irq   = omap_zoom_init_irq,
 
 This will create mapping:
 0x100 - 0xfb00 of 1MB
 
 Now that leaves the phy address 0x480 omap register mapping, unmapped.

Right, we really need 0x4800 mapped :)
 
 So the code to get scratchpad contents will abort:
 arch/arm/mach-omap2/include/mach/debug-macro.S
   moveq   \rx, #0x4800@ physical base address
   movne   \rx, #0xfa00@ virtual base
   orr \rx, \rx, #0x0006a000   @ uart1 on omap2/3/4
 
 
 This seems to be a basic limitation of low level code and I have not clue how 
 to circumvent this.
 Thoughts?

Please take a look at arch/arm/kernel/head.S where you can add
the extra mapping early on.

Hmm, I wonder if we cand nowadays do the extra mapping for zoom
external uart in arch/arm/kernel/early_printk.c?

Are you getting anything out of the zoom uart before MMU is
enabled?

To test this you can temporarily break your kernel by commenting
out the start_kernel line in head-common.S. Then the code falls
through to __error_p and prints out a processor error..

Regards,

Tony
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code generic, v2

2010-01-22 Thread Pandita, Vikram


-Original Message-
From: Tony Lindgren [mailto:t...@atomide.com]
Sent: Thursday, January 21, 2010 9:07 PM
To: Pandita, Vikram
Cc: Russell King - ARM Linux; linux-arm-ker...@lists.infradead.org; 
linux-omap@vger.kernel.org
Subject: Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code generic, 
v2

* Pandita, Vikram vikram.pand...@ti.com [100118 17:48]:

 * Russell King - ARM Linux li...@arm.linux.org.uk [100116 11:31]:
 
  Why not do something like this:
 
.pushsection .data
  omap_uart_phys:   .word 0
  omap_uart_virt:   .word 0
.popsection

Updated patch below using .data. This assumes getting an additional
tmp register passed to addruart as in the patch I posted earlier.

 Also We may need a:
   omap_uart_shift: .word 0
 Since shift also varies depending on different omap boards
 (external debug board shift=1, internal omap has shift=2)

OK, I've added that too, but for mach-omap2 only. I've also
added an experimental zoom2/3 support.

Care to take try it out and see what happens on a zoom?

Test on zoom3 failed with multi-omap branch.
Debugging the same, should have a zoom correction patch out today.


--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code generic, v2

2010-01-22 Thread Tony Lindgren
* Pandita, Vikram vikram.pand...@ti.com [100122 06:46]:
 
 OK, I've added that too, but for mach-omap2 only. I've also
 added an experimental zoom2/3 support.
 
 Care to take try it out and see what happens on a zoom?
 
 Test on zoom3 failed with multi-omap branch.
 Debugging the same, should have a zoom correction patch out today.

Heh OK. I just pushed more updates into the multi-omap branch
if you want to try to boot zoom2/zoom3 using the same .config.

There are still issues with booting 2420 though..

Tony
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code generic, v2

2010-01-22 Thread Pandita, Vikram


-Original Message-
From: Tony Lindgren [mailto:t...@atomide.com]
Sent: Friday, January 22, 2010 2:55 PM
To: Pandita, Vikram
Cc: Russell King - ARM Linux; linux-arm-ker...@lists.infradead.org; 
linux-omap@vger.kernel.org
Subject: Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code generic, 
v2

* Pandita, Vikram vikram.pand...@ti.com [100122 06:46]:
 
 OK, I've added that too, but for mach-omap2 only. I've also
 added an experimental zoom2/3 support.
 
 Care to take try it out and see what happens on a zoom?

 Test on zoom3 failed with multi-omap branch.
 Debugging the same, should have a zoom correction patch out today.

Heh OK. I just pushed more updates into the multi-omap branch
if you want to try to boot zoom2/zoom3 using the same .config.

Refreshed my tree and I don't see your patches yet.


There are still issues with booting 2420 though..

Tony
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code generic, v2

2010-01-22 Thread Tony Lindgren
* Pandita, Vikram vikram.pand...@ti.com [100122 12:56]:
 
 
 -Original Message-
 From: Tony Lindgren [mailto:t...@atomide.com]
 Sent: Friday, January 22, 2010 2:55 PM
 To: Pandita, Vikram
 Cc: Russell King - ARM Linux; linux-arm-ker...@lists.infradead.org; 
 linux-omap@vger.kernel.org
 Subject: Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code 
 generic, v2
 
 * Pandita, Vikram vikram.pand...@ti.com [100122 06:46]:
  
  OK, I've added that too, but for mach-omap2 only. I've also
  added an experimental zoom2/3 support.
  
  Care to take try it out and see what happens on a zoom?
 
  Test on zoom3 failed with multi-omap branch.
  Debugging the same, should have a zoom correction patch out today.
 
 Heh OK. I just pushed more updates into the multi-omap branch
 if you want to try to boot zoom2/zoom3 using the same .config.
 
 Refreshed my tree and I don't see your patches yet.

Takes a few minutes to get mirrored from master.kernel.org..

Tony
--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code generic, v2

2010-01-22 Thread Pandita, Vikram
Tony

-Original Message-
From: Tony Lindgren [mailto:t...@atomide.com]
Sent: Friday, January 22, 2010 3:11 PM
To: Pandita, Vikram
Cc: Russell King - ARM Linux; linux-arm-ker...@lists.infradead.org; 
linux-omap@vger.kernel.org
Subject: Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code generic, 
v2

* Pandita, Vikram vikram.pand...@ti.com [100122 12:56]:


 -Original Message-
 From: Tony Lindgren [mailto:t...@atomide.com]
 Sent: Friday, January 22, 2010 2:55 PM
 To: Pandita, Vikram
 Cc: Russell King - ARM Linux; linux-arm-ker...@lists.infradead.org; 
 linux-omap@vger.kernel.org
 Subject: Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code 
 generic, v2
 
 * Pandita, Vikram vikram.pand...@ti.com [100122 06:46]:
  
  OK, I've added that too, but for mach-omap2 only. I've also
  added an experimental zoom2/3 support.
  
  Care to take try it out and see what happens on a zoom?
 
  Test on zoom3 failed with multi-omap branch.
  Debugging the same, should have a zoom correction patch out today.
 
 Heh OK. I just pushed more updates into the multi-omap branch
 if you want to try to boot zoom2/zoom3 using the same .config.

 Refreshed my tree and I don't see your patches yet.

Takes a few minutes to get mirrored from master.kernel.org..

Yes I tried with new branch and zoom2/3 does not work.
Root cause: 
There is a very basic issue in low level code.

We are allowed to create only one Physical to Virtual mapping using 
MACHINE_START() phys_io and io_pg_offst of size 0x10(1MB).

Now for zoom2/3 we need to do following:
MACHINE_START(OMAP_ZOOM3, OMAP Zoom3 board)
-   .phys_io= 0x4800,
-   .io_pg_offst= ((0xfa00)  18)  0xfffc,
+   .phys_io= 0x100, /*ZOOM_UART_BASE*/
+   .io_pg_offst= ((0xfb00)  18)  0xfffc, /*ZOOM_UART_VIRT*/
.boot_params= 0x8100,
.map_io = omap_zoom_map_io,
.init_irq   = omap_zoom_init_irq,

This will create mapping:
0x100 - 0xfb00 of 1MB

Now that leaves the phy address 0x480 omap register mapping, unmapped.

So the code to get scratchpad contents will abort:
arch/arm/mach-omap2/include/mach/debug-macro.S
moveq   \rx, #0x4800@ physical base address
movne   \rx, #0xfa00@ virtual base
orr \rx, \rx, #0x0006a000   @ uart1 on omap2/3/4


This seems to be a basic limitation of low level code and I have not clue how 
to circumvent this.
Thoughts?

Regards,
Vikram 

--
To unsubscribe from this list: send the line unsubscribe linux-omap in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] omap: Make uncompress code and DEBUG_LL code generic, v2

2010-01-21 Thread Tony Lindgren
* Pandita, Vikram vikram.pand...@ti.com [100118 17:48]:

 * Russell King - ARM Linux li...@arm.linux.org.uk [100116 11:31]:
 
  Why not do something like this:
 
 .pushsection .data
  omap_uart_phys:.word 0
  omap_uart_virt:.word 0
 .popsection

Updated patch below using .data. This assumes getting an additional
tmp register passed to addruart as in the patch I posted earlier.
 
 Also We may need a:
omap_uart_shift: .word 0 
 Since shift also varies depending on different omap boards
 (external debug board shift=1, internal omap has shift=2)

OK, I've added that too, but for mach-omap2 only. I've also
added an experimental zoom2/3 support.

Care to take try it out and see what happens on a zoom?
 
 Bingo..I think this was the key solution to the problem.
 I had posted long ago similar kind of implementation [1] 
 and I wish rmk had given this nice idea then :)
 
 [1] http://marc.info/?l=linux-omapm=125269221820632w=2
   See this part: 
   +   .align
   +   .type   __phy_uart_addr, #object
   +__phy_uart_addr:   .word   0xFF
   +   .type   __virt_uart_addr, #object
   +__virt_uart_addr:   .word   0xFF

Yeah hopefully we're pretty close to better DEBUG_LL support
for omaps now :)

BTW, I've also pushed these patches into a temporary multi-omap
branch in the linux-omap tree:

http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git;a=shortlog;h=refs/heads/multi-omap

I'll update also the entry-macro.S tomorrow.

Regards,

Tony
From 94e3a455b9fb6bdfa1c6b3594d85fee313546e85 Mon Sep 17 00:00:00 2001
From: Tony Lindgren t...@atomide.com
Date: Thu, 21 Jan 2010 18:53:30 -0800
Subject: [PATCH] omap: Make uncompress code and DEBUG_LL code generic

Define arch_decomp_setup() the same way as some other
architectures do. Use arch_id to configure the debug uart
based on the machine_is by storing it into the uart
scratchpad register for DEBUG_LL code to use.

Signed-off-by: Tony Lindgren t...@atomide.com

diff --git a/arch/arm/mach-omap1/include/mach/debug-macro.S b/arch/arm/mach-omap1/include/mach/debug-macro.S
index 9ea12f2..b6d9584 100644
--- a/arch/arm/mach-omap1/include/mach/debug-macro.S
+++ b/arch/arm/mach-omap1/include/mach/debug-macro.S
@@ -15,18 +15,76 @@
 
 #include plat/serial.h
 
+		.pushsection .data
+omap_uart_phys:	.word	0x0
+omap_uart_virt:	.word	0x0
+		.popsection
+
+		/*
+		 * 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.
+		 */
 		.macro	addruart, rx, tmp
+
+		/* Use omap_uart_phys/virt if already configured */
+9:		mrc	p15, 0, \rx, c1, c0
+		tst	\rx, #1			@ MMU enabled?
+		ldreq	\rx, =omap_uart_phys	@ physical base address
+		ldrne	\rx, =omap_uart_virt	@ virtual base
+		ldr	\rx, [\rx, #0]
+		cmp	\rx, #0			@ is port configured?
+		bne	99f			@ already configured
+
+		/* Check 7XX UART1 scratchpad register for uart to use */
+		mrc	p15, 0, \rx, c1, c0
+		tst	\rx, #1			@ MMU enabled?
+		moveq	\rx, #0xff00	@ physical base address
+		movne	\rx, #0xfe00	@ virtual base
+		orr	\rx, \rx, #0x00fb	@ OMAP1UART1
+		ldrb	\rx, [\rx, #(UART_SCR  OMAP7XX_PORT_SHIFT)]
+		cmp	\rx, #0			@ anything in 7XX scratchpad?
+		bne	10f			@ found 7XX uart
+
+		/* Check 15xx/16xx UART1 scratchpad register for uart to use */
 		mrc	p15, 0, \rx, c1, c0
 		tst	\rx, #1			@ MMU enabled?
 		moveq	\rx, #0xff00	@ physical base address
 		movne	\rx, #0xfe00	@ virtual base
-		orr	\rx, \rx, #0x00fb
-#ifdef CONFIG_OMAP_LL_DEBUG_UART3
-		orr	\rx, \rx, #0x9000	@ UART 3
-#endif
-#if defined(CONFIG_OMAP_LL_DEBUG_UART2) || defined(CONFIG_OMAP_LL_DEBUG_UART3)
-		orr	\rx, \rx, #0x0800	@ UART 2  3
-#endif
+		orr	\rx, \rx, #0x00fb	@ OMAP1UART1
+		ldrb	\rx, [\rx, #(UART_SCR  OMAP_PORT_SHIFT)]
+
+		/* Select the UART to use based on the UART1 scratchpad value */
+10:		cmp	\rx, #0			@ no port configured?
+		beq	11f			@ if none, try to use UART1
+		cmp	\rx, #OMAP1UART1
+		beq	11f			@ configure OMAP1UART1
+		cmp	\rx, #OMAP1UART2
+		beq	12f			@ configure OMAP1UART2
+		cmp	\rx, #OMAP1UART3
+		beq	13f			@ configure OMAP2UART3
+
+		/* Configure the UART offset from the phys/virt base */
+11:		mov	\rx, #0x00fb	@ OMAP1UART1
+		b	98f
+12:		mov	\rx, #0x00fb	@ OMAP1UART1
+		orr	\rx, \rx, #0x0800	@ OMAP1UART2
+		b	98f
+13:		mov	\rx, #0x00fb	@ OMAP1UART1
+		orr	\rx, \rx, #0x0800	@ OMAP1UART2
+		orr	\rx, \rx, #0x9000	@ OMAP1UART3
+
+		/* Store both phys and virt address for the uart */
+98:		add	\rx, \rx, #0xff00	@ phys base
+		ldr	\tmp, =omap_uart_phys
+		str	\rx, [\tmp, #0]
+		sub	\rx, \rx, #0xff00	@ phys base
+		add	\rx, \rx, #0xfe00	@ virt base
+		ldr	\tmp, =omap_uart_virt
+		str	\rx, [\tmp, #0]
+		b	9b
+99:
 		.endm
 
 		.macro	senduart,rd,rx
diff --git