linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: <linuxppc-dev@ozlabs.org>
Subject: [PATCH 14/15] Early serial debug support for PPC44x
Date: Mon,  5 Mar 2007 14:24:53 +1100 (EST)	[thread overview]
Message-ID: <20070305032453.6B56ADDF1E@ozlabs.org> (raw)
In-Reply-To: <20070305032307.GB31417@localhost.localdomain>

This patch adds support for early serial debugging via the built in
port on IBM/AMCC PowerPC 44x CPUs.  It uses a bolted TLB entry in
address space 1 for the UART's mapping, allowing robust debugging both
before and after the initialization of the MMU.

Signed-off-by: David Gibson <dwg@au1.ibm.com>
---

 arch/powerpc/Kconfig.debug            |   23 +++++++++++++----
 arch/powerpc/kernel/head_44x.S        |   34 +++++++++----------------
 arch/powerpc/kernel/of_platform.c     |    1 
 arch/powerpc/kernel/udbg.c            |    3 ++
 arch/powerpc/kernel/udbg_16550.c      |   23 +++++++++++++++++
 arch/powerpc/platforms/4xx/44x.h      |    8 +++++
 arch/powerpc/platforms/4xx/Makefile   |    1 
 arch/powerpc/platforms/4xx/misc_44x.S |   46 ++++++++++++++++++++++++++++++++++
 include/asm-powerpc/mmu-44x/mmu.h     |    7 ++++-
 include/asm-powerpc/udbg.h            |    1 
 10 files changed, 119 insertions(+), 28 deletions(-)

Index: working-2.6/arch/powerpc/Kconfig.debug
===================================================================
--- working-2.6.orig/arch/powerpc/Kconfig.debug	2007-03-02 16:57:36.000000000 +1100
+++ working-2.6/arch/powerpc/Kconfig.debug	2007-03-02 16:57:37.000000000 +1100
@@ -130,11 +130,6 @@ config BOOTX_TEXT
 	  Say Y here to see progress messages from the boot firmware in text
 	  mode. Requires either BootX or Open Firmware.
 
-config SERIAL_TEXT_DEBUG
-	bool "Support for early boot texts over serial port"
-	depends on 4xx || LOPEC || MV64X60 || PPLUS || PRPMC800 || \
-		PPC_GEN550 || PPC_MPC52xx
-
 config PPC_EARLY_DEBUG
 	bool "Early debugging (dangerous)"
 
@@ -199,6 +194,24 @@ config PPC_EARLY_DEBUG_BEAT
 	help
 	  Select this to enable early debugging for Celleb with Beat.
 
+config PPC_EARLY_DEBUG_44x
+	bool "Early serial debugging for IBM/AMCC 44x CPUs"
+	depends on 44x
+	select PPC_UDBG_16550
+	help
+	  Select this to enable early debugging for IBM 44x chips via the
+	  inbuilt serial port.
+
 endchoice
 
+config PPC_EARLY_DEBUG_44x_PHYSLOW
+	hex
+	depends PPC_EARLY_DEBUG_44x
+	default "0x40000200"
+
+config PPC_EARLY_DEBUG_44x_PHYSHIGH
+	hex
+	depends PPC_EARLY_DEBUG_44x
+	default "0x1"
+
 endmenu
Index: working-2.6/arch/powerpc/kernel/head_44x.S
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/head_44x.S	2007-03-02 16:57:36.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/head_44x.S	2007-03-02 17:12:00.000000000 +1100
@@ -172,36 +172,28 @@ skpinv:	addi	r4,r4,1				/* Increment */
 	isync
 
 4:
-#ifdef CONFIG_SERIAL_TEXT_DEBUG
-	/*
-	 * Add temporary UART mapping for early debug.
-	 * We can map UART registers wherever we want as long as they don't
-	 * interfere with other system mappings (e.g. with pinned entries).
-	 * For an example of how we handle this - see ocotea.h.       --ebs
-	 */
+#ifdef CONFIG_PPC_EARLY_DEBUG_44x
+	/* Add UART mapping for early debug. */
+
  	/* pageid fields */
-	lis	r3,UART0_IO_BASE@h
-	ori	r3,r3,PPC44x_TLB_VALID | PPC44x_TLB_4K
+	lis	r3,PPC44x_EARLY_DEBUG_VIRTADDR@h
+	ori	r3,r3,PPC44x_TLB_VALID|PPC44x_TLB_TS|PPC44x_TLB_64K
 
 	/* xlat fields */
-	lis	r4,UART0_PHYS_IO_BASE@h		/* RPN depends on SoC */
-#ifndef CONFIG_440EP
-	ori	r4,r4,0x0001		/* ERPN is 1 for second 4GB page */
-#endif
+	lis	r4,CONFIG_PPC_EARLY_DEBUG_44x_PHYSLOW@h
+	ori	r4,r4,CONFIG_PPC_EARLY_DEBUG_44x_PHYSHIGH
 
 	/* attrib fields */
-	li	r5,0
-	ori	r5,r5,(PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_I | PPC44x_TLB_G)
-
-        li      r0,0                    /* TLB slot 0 */
+	li	r5,(PPC44x_TLB_SW|PPC44x_TLB_SR|PPC44x_TLB_I|PPC44x_TLB_G)
+        li      r0,62                    /* TLB slot 0 */
 
-	tlbwe	r3,r0,PPC44x_TLB_PAGEID	/* Load the pageid fields */
-	tlbwe	r4,r0,PPC44x_TLB_XLAT	/* Load the translation fields */
-	tlbwe	r5,r0,PPC44x_TLB_ATTRIB	/* Load the attrib/access fields */
+	tlbwe	r3,r0,PPC44x_TLB_PAGEID
+	tlbwe	r4,r0,PPC44x_TLB_XLAT
+	tlbwe	r5,r0,PPC44x_TLB_ATTRIB
 
 	/* Force context change */
 	isync
-#endif /* CONFIG_SERIAL_TEXT_DEBUG */
+#endif /* CONFIG_PPC_EARLY_DEBUG_44x */
 
 	/* Establish the interrupt vector offsets */
 	SET_IVOR(0,  CriticalInput);
Index: working-2.6/arch/powerpc/kernel/udbg_16550.c
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/udbg_16550.c	2007-03-02 16:57:36.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/udbg_16550.c	2007-03-02 17:12:13.000000000 +1100
@@ -191,3 +191,26 @@ void udbg_init_pas_realmode(void)
 	udbg_getc_poll = NULL;
 }
 #endif /* CONFIG_PPC_MAPLE */
+
+#ifdef CONFIG_PPC_EARLY_DEBUG_44x
+#include <platforms/4xx/44x.h>
+
+static void udbg_44x_as1_putc(char c)
+{
+	if (udbg_comport) {
+		while ((as1_readb(&udbg_comport->lsr) & LSR_THRE) == 0)
+			/* wait for idle */;
+		as1_writeb(c, &udbg_comport->thr); eieio();
+		if (c == '\n')
+			udbg_44x_as1_putc('\r');
+	}
+}
+
+void __init udbg_init_44x_as1(void)
+{
+	udbg_comport =
+		(volatile struct NS16550 __iomem *)PPC44x_EARLY_DEBUG_VIRTADDR;
+
+	udbg_putc = udbg_44x_as1_putc;
+}
+#endif /* CONFIG_PPC_EARLY_DEBUG_44x */
Index: working-2.6/include/asm-powerpc/mmu-44x/mmu.h
===================================================================
--- working-2.6.orig/include/asm-powerpc/mmu-44x/mmu.h	2007-03-02 16:57:37.000000000 +1100
+++ working-2.6/include/asm-powerpc/mmu-44x/mmu.h	2007-03-02 16:57:37.000000000 +1100
@@ -69,7 +69,12 @@ typedef struct {
 #define PPC44x_PIN_SHIFT	28
 #define PPC_PIN_SIZE		(1 << PPC44x_PIN_SHIFT)
 
+#ifndef CONFIG_PPC_EARLY_DEBUG_44x
 #define PPC44x_EARLY_TLBS	1
+#else
+#define PPC44x_EARLY_TLBS	2
+#define PPC44x_EARLY_DEBUG_VIRTADDR	(ASM_CONST(0xf0000000) \
+	| (ASM_CONST(CONFIG_PPC_EARLY_DEBUG_44x_PHYSLOW) & 0xffff))
+#endif
 
 #endif /* _ASM_POWERPC_MMU_44X_MMU_H_ */
-
Index: working-2.6/arch/powerpc/kernel/udbg.c
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/udbg.c	2007-03-02 16:57:36.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/udbg.c	2007-03-02 16:57:37.000000000 +1100
@@ -51,6 +51,9 @@ void __init udbg_early_init(void)
 	udbg_init_pas_realmode();
 #elif defined(CONFIG_BOOTX_TEXT)
 	udbg_init_btext();
+#elif defined(CONFIG_PPC_EARLY_DEBUG_44x)
+	/* PPC44x debug */
+	udbg_init_44x_as1();
 #endif
 }
 
Index: working-2.6/include/asm-powerpc/udbg.h
===================================================================
--- working-2.6.orig/include/asm-powerpc/udbg.h	2007-03-02 16:57:37.000000000 +1100
+++ working-2.6/include/asm-powerpc/udbg.h	2007-03-02 16:57:37.000000000 +1100
@@ -47,6 +47,7 @@ extern void __init udbg_init_rtas_panel(
 extern void __init udbg_init_rtas_console(void);
 extern void __init udbg_init_debug_beat(void);
 extern void __init udbg_init_btext(void);
+extern void __init udbg_init_44x_as1(void);
 
 #endif /* __KERNEL__ */
 #endif /* _ASM_POWERPC_UDBG_H */
Index: working-2.6/arch/powerpc/kernel/of_platform.c
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/of_platform.c	2007-03-02 16:57:36.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/of_platform.c	2007-03-02 16:57:37.000000000 +1100
@@ -29,7 +29,6 @@
 #include <asm/ppc-pci.h>
 #include <asm/atomic.h>
 
-
 /*
  * The list of OF IDs below is used for matching bus types in the
  * system whose devices are to be exposed as of_platform_devices.
Index: working-2.6/arch/powerpc/platforms/4xx/Makefile
===================================================================
--- working-2.6.orig/arch/powerpc/platforms/4xx/Makefile	2007-03-02 16:57:36.000000000 +1100
+++ working-2.6/arch/powerpc/platforms/4xx/Makefile	2007-03-02 17:10:52.000000000 +1100
@@ -1 +1,2 @@
 obj-$(CONFIG_EBONY)	:= ebony.o
+obj-$(CONFIG_44x)	+= misc_44x.o
Index: working-2.6/arch/powerpc/platforms/4xx/misc_44x.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/arch/powerpc/platforms/4xx/misc_44x.S	2007-03-02 17:12:00.000000000 +1100
@@ -0,0 +1,46 @@
+/*
+ * This file contains miscellaneous low-level functions for PPC 44x.
+ *    Copyright 2007 David Gibson <dwg@au1.ibm.com>, IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ */
+
+#include <asm/reg.h>
+#include <asm/ppc_asm.h>
+
+	.text
+
+/*
+ * Do an IO access in AS1
+ */
+_GLOBAL(as1_readb)
+	mfmsr	r7
+	ori	r0,r7,MSR_DS
+	sync
+	mtmsr	r0
+	sync
+	isync
+	lbz	r3,0(r3)
+	sync
+	mtmsr	r7
+	sync
+	isync
+	blr
+
+_GLOBAL(as1_writeb)
+	mfmsr	r7
+	ori	r0,r7,MSR_DS
+	sync
+	mtmsr	r0
+	sync
+	isync
+	stb	r3,0(r4)
+	sync
+	mtmsr	r7
+	sync
+	isync
+	blr
Index: working-2.6/arch/powerpc/platforms/4xx/44x.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/arch/powerpc/platforms/4xx/44x.h	2007-03-02 17:12:00.000000000 +1100
@@ -0,0 +1,8 @@
+#ifndef __POWERPC_PLATFORMS_4XX_44X_H
+#define __POWERPC_PLATFORMS_4XX_44X_H
+
+extern u8 as1_readb(volatile u8 __iomem  *addr);
+extern void as1_writeb(u8 data, volatile u8 __iomem *addr);
+
+#endif /* __POWERPC_PLATFORMS_4XX_44X_H */
+

  parent reply	other threads:[~2007-03-05  3:24 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-05  3:23 [0/15] Ebony support, spin 3 David Gibson
2007-03-05  3:24 ` [PATCH 1/15] powerpc: Allow duplicate lmb_reserve() calls David Gibson
2007-03-05  3:24 ` [PATCH 3/15] Define FIXED_PORT flag for serial_core David Gibson
2007-03-05  3:24 ` [PATCH 2/15] Automatically lmb_reserve() initrd David Gibson
2007-04-18 11:43   ` Uytterhoeven, Geert
2007-03-05  3:24 ` [PATCH 9/15] Add arch/powerpc driver for UIC, PPC4xx interrupt controller David Gibson
2007-03-05  3:24 ` [PATCH 6/15] zImage: Add more flexible gunzip convenience functions David Gibson
2007-03-16 16:24   ` Geoff Levand
2007-03-17 12:59     ` David Gibson
2007-03-05  3:24 ` [PATCH 10/15] Add device tree for Ebony David Gibson
2007-03-05 14:23   ` Josh Boyer
2007-03-06  0:04     ` David Gibson
2007-03-05  3:24 ` [PATCH 7/15] zImage: Cleanup and improve prep_kernel() David Gibson
2007-03-05  3:24 ` [PATCH 8/15] zImage: Cleanup and improve zImage entry point David Gibson
2007-03-15 22:35   ` Mark A. Greer
2007-03-16  0:14     ` David Gibson
2007-03-16  1:01       ` Mark A. Greer
2007-03-16  1:50         ` David Gibson
2007-03-16  3:36           ` Mark A. Greer
2007-03-20 20:20             ` Mark A. Greer
2007-03-15 23:02   ` Mark A. Greer
2007-03-16  0:18     ` David Gibson
2007-03-16  0:47       ` Mark A. Greer
2007-03-16  0:50         ` David Gibson
2007-03-16  3:45           ` Mark A. Greer
2007-03-16  4:02             ` David Gibson
2007-03-16 16:21           ` Scott Wood
2007-03-17  1:38             ` David Gibson
2007-03-17  3:15               ` Geoff Levand
2007-03-19 15:06               ` Scott Wood
2007-03-20  0:45                 ` David Gibson
2007-03-05  3:24 ` [PATCH 4/15] Use resource_size_t for serial port IO addresses David Gibson
2007-03-05  3:24 ` [PATCH 11/15] zImage wrapper for Ebony David Gibson
2007-03-05 17:10   ` Mark A. Greer
2007-03-06  0:09     ` David Gibson
2007-03-07 19:47       ` Scott Wood
2007-03-08  0:24         ` David Gibson
2007-03-08  0:54           ` Mark A. Greer
2007-03-08  1:35             ` Josh Boyer
2007-03-09 17:50   ` Josh Boyer
2007-03-10  4:08     ` David Gibson
2007-03-05  3:24 ` [PATCH 5/15] Re-organize Kconfig code for 4xx in arch/powerpc David Gibson
2007-03-05  3:24 ` [PATCH 12/15] Support for Ebony " David Gibson
2007-03-05  3:24 ` [PATCH 15/15] Add support for reset on Ebony David Gibson
2007-03-05  3:24 ` David Gibson [this message]
2007-03-08 19:44   ` [PATCH 14/15] Early serial debug support for PPC44x Josh Boyer
2007-03-09 17:42     ` Josh Boyer
2007-03-09 23:43       ` David Gibson
2007-03-05  3:24 ` [PATCH 13/15] Port 44x MMU definitions to ARCH=powerpc David Gibson
2007-03-05  8:02 ` Real time clock support in arch/powerpc Zang Roy-r61911
2007-03-05 15:10   ` Kumar Gala
2007-03-05 17:04     ` Mark A. Greer
2007-03-05 13:57 ` [0/15] Ebony support, spin 3 Josh Boyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070305032453.6B56ADDF1E@ozlabs.org \
    --to=david@gibson.dropbear.id.au \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).