All of lore.kernel.org
 help / color / mirror / Atom feed
* [0/14] Ebony support, 2nd spin
@ 2007-02-20  2:08 David Gibson
  2007-02-20  2:12 ` [PATCH 3/14] Define FIXED_PORT flag for serial_core David Gibson
                   ` (14 more replies)
  0 siblings, 15 replies; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:08 UTC (permalink / raw)
  To: linuxppc-dev

Here is a 2nd spin of my patch series adding support for the Ebony
440GP evaluation board to the arch/powerpc tree.  Notable changes from
the last spin:

	- I no longer use legacy_serial for the serial ports and
	  console, instead I'm using Arnd's of_serial system.
	- Rebased on my recent clean/flexibility patches for the
	  zImage loader
	- Includes a general re-orgranization of the arch/powerpc
	  Kconfig code for 4xx, allowing a kernel to support multiple
	  boards at once (well, in theory, Ebony is the only supported
	  one so far).
	- The early serial hacks no longer use an entire 64-bit
	  constant, so should work on non-64-bit aware assemblers

Again, some of the earlier patches I'm about to push to Paulus or
others, so they could appear in upstream trees.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 1/14] powerpc: Allow duplicate lmb_reserve() calls
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (2 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 4/14] Use resource_size_t for serial port IO addresses David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20  2:12 ` [PATCH 5/14] zImage: Add more flexible gunzip convenience functions David Gibson
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

At present calling lmb_reserve() (and hence lmb_add_region()) twice
for exactly the same memory region will cause strange behaviour.

This makes life difficult when booting from a flat device tree with
memory reserve map.  Which regions are automatically reserved by the
kernel has changed over time, so it's quite possible a newer kernel
could attempt to auto-reserve a region which is also explicitly listed
in the device tree's reserve map, leading to trouble.

This patch avoids the problem by making lmb_reserve() ignore a call to
reserve a previously reserved region.  It also removes a now redundant
test designed to avoid one specific case of the problem noted above.

At present, this patch deals only with duplicate reservations of an
identical region.  Attempting to reserve two different, but
overlapping regions will still cause problems.  I might post another
patch later dealing with this case, but I'm avoiding it now since it
is substantially more complicated to deal with, less likely to occur
and more likely to indicate a genuine bug elsewhere if it does occur.

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


 arch/powerpc/kernel/prom.c |    3 ---
 arch/powerpc/mm/lmb.c      |    4 ++++
 2 files changed, 4 insertions(+), 3 deletions(-)

Index: working-2.6/arch/powerpc/mm/lmb.c
===================================================================
--- working-2.6.orig/arch/powerpc/mm/lmb.c	2007-02-06 16:21:02.000000000 +1100
+++ working-2.6/arch/powerpc/mm/lmb.c	2007-02-06 16:22:32.000000000 +1100
@@ -146,6 +146,10 @@ static long __init lmb_add_region(struct
 		unsigned long rgnbase = rgn->region[i].base;
 		unsigned long rgnsize = rgn->region[i].size;
 
+		if ((rgnbase == base) && (rgnsize == size))
+			/* Already have this region, so we're done */
+			return 0;
+
 		adjacent = lmb_addrs_adjacent(base,size,rgnbase,rgnsize);
 		if ( adjacent > 0 ) {
 			rgn->region[i].base -= size;
Index: working-2.6/arch/powerpc/kernel/prom.c
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/prom.c	2007-02-06 16:22:48.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/prom.c	2007-02-06 16:22:57.000000000 +1100
@@ -954,9 +954,6 @@ static void __init early_reserve_mem(voi
 		size = *(reserve_map++);
 		if (size == 0)
 			break;
-		/* skip if the reservation is for the blob */
-		if (base == self_base && size == self_size)
-			continue;
 		DBG("reserving: %llx -> %llx\n", base, size);
 		lmb_reserve(base, size);
 	}

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 2/14] Automatically lmb_reserve() initrd
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
  2007-02-20  2:12 ` [PATCH 3/14] Define FIXED_PORT flag for serial_core David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20  2:12 ` [PATCH 4/14] Use resource_size_t for serial port IO addresses David Gibson
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

At present, when an initrd is passed to the kernel used flat device
tree properties, the memory the initrd occupies must also be reserved
in the flat tree's reserve map, or the kernel may overwrite it.  That
makes life more complicated than it could be for the bootwrapper.

This patch makes the kernel automatically reserve the initrd's space.
That in turn requires parsing the initrd parameters earlier than they
are currently, in early_init_dt_scan_chosen() instead of
check_for_initrd().

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

 arch/powerpc/kernel/prom.c         |   23 +++++++++++++++++++++++
 arch/powerpc/kernel/setup-common.c |   22 ++--------------------
 2 files changed, 25 insertions(+), 20 deletions(-)

Index: working-2.6/arch/powerpc/kernel/prom.c
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/prom.c	2007-02-09 15:12:00.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/prom.c	2007-02-09 15:14:27.000000000 +1100
@@ -719,6 +719,7 @@ static int __init early_init_dt_scan_cho
 					    const char *uname, int depth, void *data)
 {
 	unsigned long *lprop;
+	u32 *prop;
 	unsigned long l;
 	char *p;
 
@@ -760,6 +761,22 @@ static int __init early_init_dt_scan_cho
                crashk_res.end = crashk_res.start + *lprop - 1;
 #endif
 
+#ifdef CONFIG_BLK_DEV_INITRD
+	DBG("Looking for initrd properties... ");
+	prop = of_get_flat_dt_prop(node, "linux,initrd-start", &l);
+	if (prop) {
+		initrd_start = (unsigned long)__va(of_read_ulong(prop, l/4));
+		prop = of_get_flat_dt_prop(node, "linux,initrd-end", &l);
+		if (prop) {
+			initrd_end = (unsigned long)__va(of_read_ulong(prop, l/4));
+			initrd_below_start_ok = 1;
+		} else {
+			initrd_start = 0;
+		}
+	}
+	DBG("initrd_start=0x%lx  initrd_end=0x%lx\n", initrd_start, initrd_end);
+#endif /* CONFIG_BLK_DEV_INITRD */
+
 	/* Retreive command line */
  	p = of_get_flat_dt_prop(node, "bootargs", &l);
 	if (p != NULL && l > 0)
@@ -926,6 +943,12 @@ static void __init early_reserve_mem(voi
 	self_size = initial_boot_params->totalsize;
 	lmb_reserve(self_base, self_size);
 
+#ifdef CONFIG_BLK_DEV_INITRD
+	/* then reserve the initrd, if any */
+	if (initrd_start && (initrd_end > initrd_start))
+		lmb_reserve(__pa(initrd_start), initrd_end - initrd_start);
+#endif /* CONFIG_BLK_DEV_INITRD */
+
 #ifdef CONFIG_PPC32
 	/* 
 	 * Handle the case where we might be booting from an old kexec
Index: working-2.6/arch/powerpc/kernel/setup-common.c
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/setup-common.c	2007-01-24 12:01:17.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/setup-common.c	2007-02-09 15:15:15.000000000 +1100
@@ -304,26 +304,8 @@ struct seq_operations cpuinfo_op = {
 void __init check_for_initrd(void)
 {
 #ifdef CONFIG_BLK_DEV_INITRD
-	const unsigned int *prop;
-	int len;
-
-	DBG(" -> check_for_initrd()\n");
-
-	if (of_chosen) {
-		prop = get_property(of_chosen, "linux,initrd-start", &len);
-		if (prop != NULL) {
-			initrd_start = (unsigned long)
-				__va(of_read_ulong(prop, len / 4));
-			prop = get_property(of_chosen,
-					"linux,initrd-end", &len);
-			if (prop != NULL) {
-				initrd_end = (unsigned long)
-					__va(of_read_ulong(prop, len / 4));
-				initrd_below_start_ok = 1;
-			} else
-				initrd_start = 0;
-		}
-	}
+	DBG(" -> check_for_initrd()  initrd_start=0x%lx  initrd_end=0x%lx\n",
+	    initrd_start, initrd_end);
 
 	/* If we were passed an initrd, set the ROOT_DEV properly if the values
 	 * look sensible. If not, clear initrd reference.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 3/14] Define FIXED_PORT flag for serial_core
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20  2:12 ` [PATCH 2/14] Automatically lmb_reserve() initrd David Gibson
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

At present, the serial core always allows setserial in userspace to
change the port address, irq and base clock of any serial port.  That
makes sense for legacy ISA ports, but not for (say) embedded ns16550
compatible serial ports at peculiar addresses.  In these cases, the
kernel code configuring the ports must know exactly where they are,
and their clocking arrangements (which can be unusual on embedded
boards).  It doesn't make sense for userspace to change these
settings.

Therefore, this patch defines a UPF_FIXED_PORT flag for the uart_port
structure.  If this flag is set when the serial port is configured,
any attempts to alter the port's type, io address, irq or base clock
with setserial are ignored.

In addition this patch uses the new flag for on-chip serial ports
probed in arch/powerpc/kernel/legacy_serial.c, and for other
hard-wired serial ports probed by drivers/serial/of_serial.c.

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

 arch/powerpc/kernel/legacy_serial.c |    3 ++-
 drivers/serial/of_serial.c          |    3 ++-
 drivers/serial/serial_core.c        |   22 +++++++++++++---------
 include/linux/serial_core.h         |    1 +
 4 files changed, 18 insertions(+), 11 deletions(-)

Index: working-2.6/drivers/serial/serial_core.c
===================================================================
--- working-2.6.orig/drivers/serial/serial_core.c	2007-02-19 11:05:32.000000000 +1100
+++ working-2.6/drivers/serial/serial_core.c	2007-02-20 11:38:08.000000000 +1100
@@ -672,19 +672,21 @@ static int uart_set_info(struct uart_sta
 	 */
 	mutex_lock(&state->mutex);
 
-	change_irq  = new_serial.irq != port->irq;
+	change_irq  = !(port->flags & UPF_FIXED_PORT)
+		&& new_serial.irq != port->irq;
 
 	/*
 	 * Since changing the 'type' of the port changes its resource
 	 * allocations, we should treat type changes the same as
 	 * IO port changes.
 	 */
-	change_port = new_port != port->iobase ||
-		      (unsigned long)new_serial.iomem_base != port->mapbase ||
-		      new_serial.hub6 != port->hub6 ||
-		      new_serial.io_type != port->iotype ||
-		      new_serial.iomem_reg_shift != port->regshift ||
-		      new_serial.type != port->type;
+	change_port = !(port->flags & UPF_FIXED_PORT)
+		&& (new_port != port->iobase ||
+		    (unsigned long)new_serial.iomem_base != port->mapbase ||
+		    new_serial.hub6 != port->hub6 ||
+		    new_serial.io_type != port->iotype ||
+		    new_serial.iomem_reg_shift != port->regshift ||
+		    new_serial.type != port->type);
 
 	old_flags = port->flags;
 	new_flags = new_serial.flags;
@@ -796,8 +798,10 @@ static int uart_set_info(struct uart_sta
 		}
 	}
 
-	port->irq              = new_serial.irq;
-	port->uartclk          = new_serial.baud_base * 16;
+	if (change_irq)
+		port->irq      = new_serial.irq;
+	if (! (port->flags & UPF_FIXED_PORT))
+		port->uartclk  = new_serial.baud_base * 16;
 	port->flags            = (port->flags & ~UPF_CHANGE_MASK) |
 				 (new_flags & UPF_CHANGE_MASK);
 	port->custom_divisor   = new_serial.custom_divisor;
Index: working-2.6/include/linux/serial_core.h
===================================================================
--- working-2.6.orig/include/linux/serial_core.h	2007-02-19 11:05:32.000000000 +1100
+++ working-2.6/include/linux/serial_core.h	2007-02-20 11:38:08.000000000 +1100
@@ -260,6 +260,7 @@ struct uart_port {
 #define UPF_CONS_FLOW		((__force upf_t) (1 << 23))
 #define UPF_SHARE_IRQ		((__force upf_t) (1 << 24))
 #define UPF_BOOT_AUTOCONF	((__force upf_t) (1 << 28))
+#define UPF_FIXED_PORT		((__force upf_t) (1 << 29))
 #define UPF_DEAD		((__force upf_t) (1 << 30))
 #define UPF_IOREMAP		((__force upf_t) (1 << 31))
 
Index: working-2.6/arch/powerpc/kernel/legacy_serial.c
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/legacy_serial.c	2007-02-15 10:05:18.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/legacy_serial.c	2007-02-20 10:50:16.000000000 +1100
@@ -115,7 +115,8 @@ static int __init add_legacy_soc_port(st
 {
 	u64 addr;
 	const u32 *addrp;
-	upf_t flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ;
+	upf_t flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ
+		| UPF_FIXED_PORT;
 	struct device_node *tsi = of_get_parent(np);
 
 	/* We only support ports that have a clock frequency properly
Index: working-2.6/drivers/serial/of_serial.c
===================================================================
--- working-2.6.orig/drivers/serial/of_serial.c	2007-02-20 11:38:16.000000000 +1100
+++ working-2.6/drivers/serial/of_serial.c	2007-02-20 11:38:30.000000000 +1100
@@ -48,7 +48,8 @@ static int __devinit of_platform_serial_
 	port->iotype = UPIO_MEM;
 	port->type = type;
 	port->uartclk = *clk;
-	port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP;
+	port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
+		| UPF_FIXED_PORT;
 	port->dev = &ofdev->dev;
 	port->custom_divisor = *clk / (16 * (*spd));
 

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 4/14] Use resource_size_t for serial port IO addresses
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
  2007-02-20  2:12 ` [PATCH 3/14] Define FIXED_PORT flag for serial_core David Gibson
  2007-02-20  2:12 ` [PATCH 2/14] Automatically lmb_reserve() initrd David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20 14:44   ` Sergei Shtylyov
  2007-02-20  2:12 ` [PATCH 1/14] powerpc: Allow duplicate lmb_reserve() calls David Gibson
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

At present, various parts of the serial code use unsigned long to
define resource addresses.  This is a problem, because some 32-bit
platforms have physical addresses larger than 32-bits, and have mmio
serial uarts located above the 4GB point.

This patch changes the type of mapbase in both struct uart_port and
struct plat_serial8250_port to resource_size_t, which can be
configured to be 64 bits on such platforms.  The mapbase in
serial_struct can't safely be changed, because that structure is user
visible.

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

 drivers/serial/8250.c        |    5 +++--
 drivers/serial/8250_early.c  |   16 +++++++++-------
 drivers/serial/serial_core.c |    9 +++++----
 include/linux/serial_8250.h  |    2 +-
 include/linux/serial_core.h  |    2 +-
 5 files changed, 19 insertions(+), 15 deletions(-)

Index: working-2.6/include/linux/serial_core.h
===================================================================
--- working-2.6.orig/include/linux/serial_core.h	2007-02-19 11:07:42.000000000 +1100
+++ working-2.6/include/linux/serial_core.h	2007-02-19 11:07:43.000000000 +1100
@@ -273,7 +273,7 @@ struct uart_port {
 	const struct uart_ops	*ops;
 	unsigned int		custom_divisor;
 	unsigned int		line;			/* port index */
-	unsigned long		mapbase;		/* for ioremap */
+	resource_size_t		mapbase;		/* for ioremap */
 	struct device		*dev;			/* parent device */
 	unsigned char		hub6;			/* this should be in the 8250 driver */
 	unsigned char		unused[3];
Index: working-2.6/drivers/serial/serial_core.c
===================================================================
--- working-2.6.orig/drivers/serial/serial_core.c	2007-02-19 11:07:42.000000000 +1100
+++ working-2.6/drivers/serial/serial_core.c	2007-02-19 11:07:43.000000000 +1100
@@ -633,7 +633,7 @@ static int uart_get_info(struct uart_sta
 	tmp.hub6	    = port->hub6;
 	tmp.io_type         = port->iotype;
 	tmp.iomem_reg_shift = port->regshift;
-	tmp.iomem_base      = (void *)port->mapbase;
+	tmp.iomem_base      = (void *)(unsigned long)port->mapbase;
 
 	if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
 		return -EFAULT;
@@ -1673,10 +1673,11 @@ static int uart_line_info(char *buf, str
 		return 0;
 
 	mmio = port->iotype >= UPIO_MEM;
-	ret = sprintf(buf, "%d: uart:%s %s%08lX irq:%d",
+	ret = sprintf(buf, "%d: uart:%s %s%08llX irq:%d",
 			port->line, uart_type(port),
 			mmio ? "mmio:0x" : "port:",
-			mmio ? port->mapbase : (unsigned long) port->iobase,
+			mmio ? (unsigned long long)port->mapbase
+		             : (unsigned long long) port->iobase,
 			port->irq);
 
 	if (port->type == PORT_UNKNOWN) {
@@ -2069,7 +2070,7 @@ uart_report_port(struct uart_driver *drv
 	case UPIO_AU:
 	case UPIO_TSI:
 		snprintf(address, sizeof(address),
-			 "MMIO 0x%lx", port->mapbase);
+			 "MMIO 0x%llx", (unsigned long long)port->mapbase);
 		break;
 	default:
 		strlcpy(address, "*unknown*", sizeof(address));
Index: working-2.6/drivers/serial/8250_early.c
===================================================================
--- working-2.6.orig/drivers/serial/8250_early.c	2007-02-19 11:07:40.000000000 +1100
+++ working-2.6/drivers/serial/8250_early.c	2007-02-19 11:07:43.000000000 +1100
@@ -145,8 +145,9 @@ static int __init parse_options(struct e
 		port->mapbase = simple_strtoul(options + 5, &options, 0);
 		port->membase = ioremap(port->mapbase, mapsize);
 		if (!port->membase) {
-			printk(KERN_ERR "%s: Couldn't ioremap 0x%lx\n",
-				__FUNCTION__, port->mapbase);
+			printk(KERN_ERR "%s: Couldn't ioremap 0x%llx\n",
+				__FUNCTION__,
+			       (unsigned long long)port->mapbase);
 			return -ENOMEM;
 		}
 		mmio = 1;
@@ -168,9 +169,10 @@ static int __init parse_options(struct e
 			device->baud);
 	}
 
-	printk(KERN_INFO "Early serial console at %s 0x%lx (options '%s')\n",
+	printk(KERN_INFO "Early serial console at %s 0x%llx (options '%s')\n",
 		mmio ? "MMIO" : "I/O port",
-		mmio ? port->mapbase : (unsigned long) port->iobase,
+		mmio ? (unsigned long long) port->mapbase
+	             : (unsigned long long) port->iobase,
 		device->options);
 	return 0;
 }
@@ -236,10 +238,10 @@ static int __init early_uart_console_swi
 	mmio = (port->iotype == UPIO_MEM);
 	line = serial8250_start_console(port, device->options);
 	if (line < 0)
-		printk("No ttyS device at %s 0x%lx for console\n",
+		printk("No ttyS device at %s 0x%llx for console\n",
 			mmio ? "MMIO" : "I/O port",
-			mmio ? port->mapbase :
-			    (unsigned long) port->iobase);
+			mmio ? (unsigned long long) port->mapbase
+		             : (unsigned long long) port->iobase);
 
 	unregister_console(&early_uart_console);
 	if (mmio)
Index: working-2.6/include/linux/serial_8250.h
===================================================================
--- working-2.6.orig/include/linux/serial_8250.h	2007-02-19 11:07:40.000000000 +1100
+++ working-2.6/include/linux/serial_8250.h	2007-02-19 11:07:43.000000000 +1100
@@ -20,7 +20,7 @@
 struct plat_serial8250_port {
 	unsigned long	iobase;		/* io base address */
 	void __iomem	*membase;	/* ioremap cookie or NULL */
-	unsigned long	mapbase;	/* resource base */
+	resource_size_t	mapbase;	/* resource base */
 	unsigned int	irq;		/* interrupt number */
 	unsigned int	uartclk;	/* UART clock rate */
 	unsigned char	regshift;	/* register shift */
Index: working-2.6/drivers/serial/8250.c
===================================================================
--- working-2.6.orig/drivers/serial/8250.c	2007-02-19 11:07:40.000000000 +1100
+++ working-2.6/drivers/serial/8250.c	2007-02-19 11:07:43.000000000 +1100
@@ -2550,8 +2550,9 @@ static int __devinit serial8250_probe(st
 		ret = serial8250_register_port(&port);
 		if (ret < 0) {
 			dev_err(&dev->dev, "unable to register port at index %d "
-				"(IO%lx MEM%lx IRQ%d): %d\n", i,
-				p->iobase, p->mapbase, p->irq, ret);
+				"(IO%lx MEM%llx IRQ%d): %d\n", i,
+				p->iobase, (unsigned long long)p->mapbase,
+				p->irq, ret);
 		}
 	}
 	return 0;

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 5/14] zImage: Add more flexible gunzip convenience functions
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (3 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 1/14] powerpc: Allow duplicate lmb_reserve() calls David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-21  0:56   ` Geoff Levand
  2007-02-20  2:12 ` [PATCH 11/14] Add arch/powerpc driver for UIC, PPC4xx interrupt controller David Gibson
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

At present, arch/powerpc/boot/main.c includes a gunzip() function
which is a convenient wrapper around zlib.  However, it doesn't
conveniently allow decompressing part of an image to one location,
then the remainder to a different address.

This patch adds a new set of more flexible convenience wrappers around
zlib, moving them to their own file, gunzip_util.c, in the process.
These wrappers allow decompressing sections of the compressed image to
different locations.  In addition, they transparently handle
uncompressed data, avoiding special case code to handle uncompressed
vmlinux images.

The patch also converts main.c to use the new wrappers, using the new
flexibility to avoid decompressing the vmlinux's ELF header twice as
we did previously.  That in turn means we avoid extending our
allocations for the vmlinux to allow space for the extra copy of the
ELF header.

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

 arch/powerpc/boot/Makefile      |    3 
 arch/powerpc/boot/gunzip_util.c |  140 ++++++++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/gunzip_util.h |   30 ++++++++
 arch/powerpc/boot/main.c        |  113 +++++---------------------------
 4 files changed, 192 insertions(+), 94 deletions(-)

Index: working-2.6/arch/powerpc/boot/gunzip_util.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/arch/powerpc/boot/gunzip_util.c	2007-02-19 13:52:02.000000000 +1100
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2007 David Gibson, IBM Corporation.
+ * Based on earlier work, Copyright (C) Paul Mackerras 1997.
+ *
+ * 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 <stddef.h>
+#include "string.h"
+#include "stdio.h"
+#include "ops.h"
+#include "gunzip_util.h"
+
+struct gunzip_state state;
+
+#define HEAD_CRC	2
+#define EXTRA_FIELD	4
+#define ORIG_NAME	8
+#define COMMENT		0x10
+#define RESERVED	0xe0
+
+void gunzip_start(struct gunzip_state *state, void *src, int srclen)
+{
+	char *hdr = src;
+	int hdrlen = 0;
+
+	memset(state, 0, sizeof(*state));
+
+	/* Check for gzip magic number */
+	if ((hdr[0] == 0x1f) && (hdr[1] == 0x8b)) {
+		/* gzip data, initialize zlib parameters */
+		int r, flags;
+
+		state->s.workspace = state->scratch;
+		if (zlib_inflate_workspacesize() > sizeof(state->scratch)) {
+			printf("insufficient scratch space for gunzip\n\r");
+			exit();
+		}
+
+		/* skip header */
+		hdrlen = 10;
+		flags = hdr[3];
+		if (hdr[2] != Z_DEFLATED || (flags & RESERVED) != 0) {
+			printf("bad gzipped data\n\r");
+			exit();
+		}
+		if ((flags & EXTRA_FIELD) != 0)
+			hdrlen = 12 + hdr[10] + (hdr[11] << 8);
+		if ((flags & ORIG_NAME) != 0)
+			while (hdr[hdrlen++] != 0)
+				;
+		if ((flags & COMMENT) != 0)
+			while (hdr[hdrlen++] != 0)
+				;
+		if ((flags & HEAD_CRC) != 0)
+			hdrlen += 2;
+		if (hdrlen >= srclen) {
+			printf("gunzip_start: ran out of data in header\n\r");
+			exit();
+		}
+
+		r = zlib_inflateInit2(&state->s, -MAX_WBITS);
+		if (r != Z_OK) {
+			printf("inflateInit2 returned %d\n\r", r);
+			exit();
+		}
+	}
+
+	state->s.next_in = src + hdrlen;
+	state->s.avail_in = srclen - hdrlen;
+}
+
+int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen)
+{
+	int len;
+
+	if (state->s.workspace) {
+		/* gunzipping */
+		int r;
+
+		state->s.next_out = dst;
+		state->s.avail_out = dstlen;
+		r = zlib_inflate(&state->s, Z_FULL_FLUSH);
+		if (r != Z_OK && r != Z_STREAM_END) {
+			printf("inflate returned %d msg: %s\n\r", r, state->s.msg);
+			exit();
+		}
+		len = state->s.next_out - (unsigned char *)dst;
+	} else {
+		/* uncompressed image */
+		len = min(state->s.avail_in, (unsigned)dstlen);
+		memcpy(dst, state->s.next_in, len);
+		state->s.next_in += len;
+		state->s.avail_in -= len;
+	}
+	return len;
+}
+
+void gunzip_exactly(struct gunzip_state *state, void *dst, int dstlen)
+{
+	int len;
+
+	len  = gunzip_partial(state, dst, dstlen);
+	if (len < dstlen) {
+		printf("gunzip_block: ran out of data\n\r");
+		exit();
+	}
+}
+
+void gunzip_discard(struct gunzip_state *state, int len)
+{
+	static char discard_buf[128];
+
+	while (len > sizeof(discard_buf)) {
+		gunzip_exactly(state, discard_buf, sizeof(discard_buf));
+		len -= sizeof(discard_buf);
+	}
+
+	if (len > 0)
+		gunzip_exactly(state, discard_buf, len);
+}
+
+int gunzip_finish(struct gunzip_state *state, void *dst, int dstlen)
+{
+	int len;
+
+	if (state->s.workspace) {
+		len = gunzip_partial(state, dst, dstlen);
+		zlib_inflateEnd(&state->s);
+	} else {
+		/* uncompressed image */
+		len = min(state->s.avail_in, (unsigned)dstlen);
+		memcpy(dst, state->s.next_in, len);
+	}
+
+	return len;
+}
Index: working-2.6/arch/powerpc/boot/main.c
===================================================================
--- working-2.6.orig/arch/powerpc/boot/main.c	2007-02-19 13:51:27.000000000 +1100
+++ working-2.6/arch/powerpc/boot/main.c	2007-02-19 14:01:15.000000000 +1100
@@ -14,8 +14,8 @@
 #include "page.h"
 #include "string.h"
 #include "stdio.h"
-#include "zlib.h"
 #include "ops.h"
+#include "gunzip_util.h"
 #include "flatdevtree.h"
 
 extern void flush_cache(void *, unsigned long);
@@ -30,6 +30,8 @@ extern char _initrd_end[];
 extern char _dtb_start[];
 extern char _dtb_end[];
 
+static struct gunzip_state gzstate;
+
 struct addr_range {
 	unsigned long addr;
 	unsigned long size;
@@ -42,71 +44,12 @@ static struct addr_range initrd;
 static unsigned long elfoffset;
 static int is_64bit;
 
-/* scratch space for gunzip; 46912 is from zlib_inflate_workspacesize() */
-static char scratch[46912];
 static char elfheader[256];
 
 typedef void (*kernel_entry_t)(unsigned long, unsigned long, void *);
 
 #undef DEBUG
 
-#define HEAD_CRC	2
-#define EXTRA_FIELD	4
-#define ORIG_NAME	8
-#define COMMENT		0x10
-#define RESERVED	0xe0
-
-static void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
-{
-	z_stream s;
-	int r, i, flags;
-
-	/* skip header */
-	i = 10;
-	flags = src[3];
-	if (src[2] != Z_DEFLATED || (flags & RESERVED) != 0) {
-		printf("bad gzipped data\n\r");
-		exit();
-	}
-	if ((flags & EXTRA_FIELD) != 0)
-		i = 12 + src[10] + (src[11] << 8);
-	if ((flags & ORIG_NAME) != 0)
-		while (src[i++] != 0)
-			;
-	if ((flags & COMMENT) != 0)
-		while (src[i++] != 0)
-			;
-	if ((flags & HEAD_CRC) != 0)
-		i += 2;
-	if (i >= *lenp) {
-		printf("gunzip: ran out of data in header\n\r");
-		exit();
-	}
-
-	if (zlib_inflate_workspacesize() > sizeof(scratch)) {
-		printf("gunzip needs more mem\n");
-		exit();
-	}
-	memset(&s, 0, sizeof(s));
-	s.workspace = scratch;
-	r = zlib_inflateInit2(&s, -MAX_WBITS);
-	if (r != Z_OK) {
-		printf("inflateInit2 returned %d\n\r", r);
-		exit();
-	}
-	s.next_in = src + i;
-	s.avail_in = *lenp - i;
-	s.next_out = dst;
-	s.avail_out = dstlen;
-	r = zlib_inflate(&s, Z_FULL_FLUSH);
-	if (r != Z_OK && r != Z_STREAM_END) {
-		printf("inflate returned %d msg: %s\n\r", r, s.msg);
-		exit();
-	}
-	*lenp = s.next_out - (unsigned char *) dst;
-	zlib_inflateEnd(&s);
-}
-
 static int is_elf64(void *hdr)
 {
 	Elf64_Ehdr *elf64 = hdr;
@@ -132,8 +75,8 @@ static int is_elf64(void *hdr)
 		return 0;
 
 	elfoffset = (unsigned long)elf64ph->p_offset;
-	vmlinux.size = (unsigned long)elf64ph->p_filesz + elfoffset;
-	vmlinux.memsize = (unsigned long)elf64ph->p_memsz + elfoffset;
+	vmlinux.size = (unsigned long)elf64ph->p_filesz;
+	vmlinux.memsize = (unsigned long)elf64ph->p_memsz;
 
 	is_64bit = 1;
 	return 1;
@@ -164,8 +107,8 @@ static int is_elf32(void *hdr)
 		return 0;
 
 	elfoffset = elf32ph->p_offset;
-	vmlinux.size = elf32ph->p_filesz + elf32ph->p_offset;
-	vmlinux.memsize = elf32ph->p_memsz + elf32ph->p_offset;
+	vmlinux.size = elf32ph->p_filesz;
+	vmlinux.memsize = elf32ph->p_memsz;
 	return 1;
 }
 
@@ -177,13 +120,8 @@ static void prep_kernel(unsigned long a1
 	vmlinuz.size = (unsigned long)(_vmlinux_end - _vmlinux_start);
 
 	/* gunzip the ELF header of the kernel */
-	if (*(unsigned short *)vmlinuz.addr == 0x1f8b) {
-		len = vmlinuz.size;
-		gunzip(elfheader, sizeof(elfheader),
-				(unsigned char *)vmlinuz.addr, &len);
-	} else
-		memcpy(elfheader, (const void *)vmlinuz.addr,
-		       sizeof(elfheader));
+	gunzip_start(&gzstate, (void *)vmlinuz.addr, vmlinuz.size);
+	gunzip_exactly(&gzstate, elfheader, sizeof(elfheader));
 
 	if (!is_elf64(elfheader) && !is_elf32(elfheader)) {
 		printf("Error: not a valid PPC32 or PPC64 ELF file!\n\r");
@@ -192,10 +130,10 @@ static void prep_kernel(unsigned long a1
 	if (platform_ops.image_hdr)
 		platform_ops.image_hdr(elfheader);
 
-	/* We need to alloc the memsize plus the file offset since gzip
-	 * will expand the header (file offset), then the kernel, then
-	 * possible rubbish we don't care about. But the kernel bss must
-	 * be claimed (it will be zero'd by the kernel itself)
+	/* We need to alloc the memsize: gzip will expand the kernel
+	 * text/data, then possible rubbish we don't care about. But
+	 * the kernel bss must be claimed (it will be zero'd by the
+	 * kernel itself)
 	 */
 	printf("Allocating 0x%lx bytes for kernel ...\n\r", vmlinux.memsize);
 	vmlinux.addr = (unsigned long)malloc(vmlinux.memsize);
@@ -237,24 +175,13 @@ static void prep_kernel(unsigned long a1
 	}
 
 	/* Eventually gunzip the kernel */
-	if (*(unsigned short *)vmlinuz.addr == 0x1f8b) {
-		printf("gunzipping (0x%lx <- 0x%lx:0x%0lx)...",
-		       vmlinux.addr, vmlinuz.addr, vmlinuz.addr+vmlinuz.size);
-		len = vmlinuz.size;
-		gunzip((void *)vmlinux.addr, vmlinux.memsize,
-			(unsigned char *)vmlinuz.addr, &len);
-		printf("done 0x%lx bytes\n\r", len);
-	} else {
-		memmove((void *)vmlinux.addr,(void *)vmlinuz.addr,
-			vmlinuz.size);
-	}
-
-	/* Skip over the ELF header */
-#ifdef DEBUG
-	printf("... skipping 0x%lx bytes of ELF header\n\r",
-			elfoffset);
-#endif
-	vmlinux.addr += elfoffset;
+	printf("gunzipping (0x%lx <- 0x%lx:0x%0lx)...",
+	       vmlinux.addr, vmlinuz.addr, vmlinuz.addr+vmlinuz.size);
+	/* discard up to the actual load data */
+	gunzip_discard(&gzstate, elfoffset - sizeof(elfheader));
+	len = gunzip_finish(&gzstate, (void *)vmlinux.addr,
+			    vmlinux.memsize);
+	printf("done 0x%lx bytes\n\r", len);
 
 	flush_cache((void *)vmlinux.addr, vmlinux.size);
 }
Index: working-2.6/arch/powerpc/boot/Makefile
===================================================================
--- working-2.6.orig/arch/powerpc/boot/Makefile	2007-02-19 13:51:30.000000000 +1100
+++ working-2.6/arch/powerpc/boot/Makefile	2007-02-19 14:00:50.000000000 +1100
@@ -41,7 +41,8 @@ $(addprefix $(obj)/,$(zlib) main.o): $(a
 		$(addprefix $(obj)/,$(zlibheader))
 
 src-wlib := string.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
-		ns16550.c serial.c simple_alloc.c div64.S util.S $(zlib)
+		ns16550.c serial.c simple_alloc.c div64.S util.S \
+		gunzip_util.c $(zlib)
 src-plat := of.c
 src-boot := crt0.S $(src-wlib) $(src-plat) empty.c
 
Index: working-2.6/arch/powerpc/boot/gunzip_util.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/arch/powerpc/boot/gunzip_util.h	2007-02-19 13:51:52.000000000 +1100
@@ -0,0 +1,30 @@
+/*
+ * Decompression convenience functions
+ *
+ * Copyright 2007 David Gibson, IBM Corporation.
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+#ifndef _PPC_BOOT_GUNZIP_UTIL_H_
+#define _PPC_BOOT_GUNZIP_UTIL_H_
+
+#include "zlib.h"
+
+/* scratch space for gunzip; 46912 is from zlib_inflate_workspacesize() */
+#define GUNZIP_SCRATCH_SIZE	46912
+
+struct gunzip_state {
+	z_stream s;
+	char scratch[46912];
+};
+
+void gunzip_start(struct gunzip_state *state, void *src, int srclen);
+int gunzip_partial(struct gunzip_state *state, void *dst, int dstlen);
+void gunzip_exactly(struct gunzip_state *state, void *dst, int len);
+void gunzip_discard(struct gunzip_state *state, int len);
+int gunzip_finish(struct gunzip_state *state, void *dst, int len);
+
+#endif /* _PPC_BOOT_GUNZIP_UTIL_H_ */
+

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 6/14] zImage: Cleanup and improve prep_kernel()
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (8 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 9/14] Port 44x MMU definitions to ARCH=powerpc David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-21  0:56   ` Geoff Levand
  2007-02-20  2:12 ` [PATCH 12/14] Add device tree for Ebony David Gibson
                   ` (4 subsequent siblings)
  14 siblings, 1 reply; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

This patch rewrites prep_kernel() in the zImage wrapper code to be
clearer and more flexible.  Notable changes:

	- Handling of the initrd image from prep_kernel() has moved
into a new prep_initrd() function.
	- The address of the initrd image is now added as device tree
properties, as the kernel expects.
	- We only copy a packaged initrd image to a new location if it
is in danger of being clobbered when the kernel moves to its final
location, instead of always.
	- By default we decompress the kernel directly to address 0,
instead of requiring it to relocate itself.  Platforms (such as OF)
where doing this could clobber still-live firmware data structures can
override the vmlinux_alloc hook to provide an alternate place to
decompress the kernel.
	- We no longer pass lots of information between functions in
global variables.

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

 arch/powerpc/boot/main.c |  171 ++++++++++++++++++++++++++++-------------------
 arch/powerpc/boot/of.c   |   12 +++
 arch/powerpc/boot/ops.h  |    1 
 3 files changed, 116 insertions(+), 68 deletions(-)

Index: working-2.6/arch/powerpc/boot/main.c
===================================================================
--- working-2.6.orig/arch/powerpc/boot/main.c	2007-02-19 14:01:15.000000000 +1100
+++ working-2.6/arch/powerpc/boot/main.c	2007-02-19 14:01:38.000000000 +1100
@@ -33,24 +33,21 @@ extern char _dtb_end[];
 static struct gunzip_state gzstate;
 
 struct addr_range {
-	unsigned long addr;
+	void *addr;
 	unsigned long size;
-	unsigned long memsize;
 };
-static struct addr_range vmlinux;
-static struct addr_range vmlinuz;
-static struct addr_range initrd;
-
-static unsigned long elfoffset;
-static int is_64bit;
 
-static char elfheader[256];
+struct elf_info {
+	unsigned long loadsize;
+	unsigned long memsize;
+	unsigned long elfoffset;
+};
 
 typedef void (*kernel_entry_t)(unsigned long, unsigned long, void *);
 
 #undef DEBUG
 
-static int is_elf64(void *hdr)
+static int parse_elf64(void *hdr, struct elf_info *info)
 {
 	Elf64_Ehdr *elf64 = hdr;
 	Elf64_Phdr *elf64ph;
@@ -74,15 +71,14 @@ static int is_elf64(void *hdr)
 	if (i >= (unsigned int)elf64->e_phnum)
 		return 0;
 
-	elfoffset = (unsigned long)elf64ph->p_offset;
-	vmlinux.size = (unsigned long)elf64ph->p_filesz;
-	vmlinux.memsize = (unsigned long)elf64ph->p_memsz;
+	info->loadsize = (unsigned long)elf64ph->p_filesz;
+	info->memsize = (unsigned long)elf64ph->p_memsz;
+	info->elfoffset = (unsigned long)elf64ph->p_offset;
 
-	is_64bit = 1;
 	return 1;
 }
 
-static int is_elf32(void *hdr)
+static int parse_elf32(void *hdr, struct elf_info *info)
 {
 	Elf32_Ehdr *elf32 = hdr;
 	Elf32_Phdr *elf32ph;
@@ -98,7 +94,6 @@ static int is_elf32(void *hdr)
 	      elf32->e_machine         == EM_PPC))
 		return 0;
 
-	elf32 = (Elf32_Ehdr *)elfheader;
 	elf32ph = (Elf32_Phdr *) ((unsigned long)elf32 + elf32->e_phoff);
 	for (i = 0; i < elf32->e_phnum; i++, elf32ph++)
 		if (elf32ph->p_type == PT_LOAD)
@@ -106,24 +101,26 @@ static int is_elf32(void *hdr)
 	if (i >= elf32->e_phnum)
 		return 0;
 
-	elfoffset = elf32ph->p_offset;
-	vmlinux.size = elf32ph->p_filesz;
-	vmlinux.memsize = elf32ph->p_memsz;
+	info->loadsize = elf32ph->p_filesz;
+	info->memsize = elf32ph->p_memsz;
+	info->elfoffset = elf32ph->p_offset;
 	return 1;
 }
 
-static void prep_kernel(unsigned long a1, unsigned long a2)
+static struct addr_range prep_kernel(void)
 {
+	char elfheader[256];
+	void *vmlinuz_addr = _vmlinux_start;
+	unsigned long vmlinuz_size = _vmlinux_end - _vmlinux_start;
+	void *addr = 0;
+	struct elf_info ei;
 	int len;
 
-	vmlinuz.addr = (unsigned long)_vmlinux_start;
-	vmlinuz.size = (unsigned long)(_vmlinux_end - _vmlinux_start);
-
 	/* gunzip the ELF header of the kernel */
-	gunzip_start(&gzstate, (void *)vmlinuz.addr, vmlinuz.size);
+	gunzip_start(&gzstate, vmlinuz_addr, vmlinuz_size);
 	gunzip_exactly(&gzstate, elfheader, sizeof(elfheader));
 
-	if (!is_elf64(elfheader) && !is_elf32(elfheader)) {
+	if (!parse_elf64(elfheader, &ei) && !parse_elf32(elfheader, &ei)) {
 		printf("Error: not a valid PPC32 or PPC64 ELF file!\n\r");
 		exit();
 	}
@@ -135,55 +132,92 @@ static void prep_kernel(unsigned long a1
 	 * the kernel bss must be claimed (it will be zero'd by the
 	 * kernel itself)
 	 */
-	printf("Allocating 0x%lx bytes for kernel ...\n\r", vmlinux.memsize);
-	vmlinux.addr = (unsigned long)malloc(vmlinux.memsize);
-	if (vmlinux.addr == 0) {
-		printf("Can't allocate memory for kernel image !\n\r");
-		exit();
+	printf("Allocating 0x%lx bytes for kernel ...\n\r", ei.memsize);
+
+	if (platform_ops.vmlinux_alloc) {
+		addr = platform_ops.vmlinux_alloc(ei.memsize);
+	} else {
+		if ((unsigned long)_start < ei.memsize) {
+			printf("Insufficient memory for kernel at address 0!"
+			       " (_start=%lx)\n\r", _start);
+			exit();
+		}
 	}
 
+	/* Finally, gunzip the kernel */
+	printf("gunzipping (0x%p <- 0x%p:0x%p)...", addr,
+	       vmlinuz_addr, vmlinuz_addr+vmlinuz_size);
+	/* discard up to the actual load data */
+	gunzip_discard(&gzstate, ei.elfoffset - sizeof(elfheader));
+	len = gunzip_finish(&gzstate, addr, ei.memsize);
+	printf("done 0x%lx bytes\n\r", len);
+
+	flush_cache(addr, ei.loadsize);
+
+	return (struct addr_range){addr, ei.memsize};
+}
+
+static struct addr_range prep_initrd(struct addr_range vmlinux,
+				     unsigned long initrd_addr,
+				     unsigned long initrd_size)
+{
+	void *devp;
+	u32 initrd_start, initrd_end;
+
+	/* If we have an image attached to us, it overrides anything
+	 * supplied by the loader. */
+	if (_initrd_end > _initrd_start) {
+		printf("Attached initrd image at 0x%p-0x%p\n\r",
+		       _initrd_start, _initrd_end);
+		initrd_addr = (unsigned long)_initrd_start;
+		initrd_size = _initrd_end - _initrd_start;
+	} else if (initrd_size > 0) {
+		printf("Using loader supplied ramdisk at 0x%lx-0x%lx\n\r",
+		       initrd_addr, initrd_addr + initrd_size);
+	}
+
+	/* If there's no initrd at all, we're done */
+	if (! initrd_size)
+		return (struct addr_range){0, 0};
+
 	/*
-	 * Now find the initrd
-	 *
-	 * First see if we have an image attached to us.  If so
-	 * allocate memory for it and copy it there.
+	 * If the initrd is too low it will be clobbered when the
+	 * kernel relocates to its final location.  In this case,
+	 * allocate a safer place and move it.
 	 */
-	initrd.size = (unsigned long)(_initrd_end - _initrd_start);
-	initrd.memsize = initrd.size;
-	if (initrd.size > 0) {
+	if (initrd_addr < vmlinux.size) {
+		void *old_addr = (void *)initrd_addr;
+
 		printf("Allocating 0x%lx bytes for initrd ...\n\r",
-		       initrd.size);
-		initrd.addr = (unsigned long)malloc((u32)initrd.size);
-		if (initrd.addr == 0) {
+		       initrd_size);
+		initrd_addr = (unsigned long)malloc(initrd_size);
+		if (! initrd_addr) {
 			printf("Can't allocate memory for initial "
-					"ramdisk !\n\r");
+			       "ramdisk !\n\r");
 			exit();
 		}
-		printf("initial ramdisk moving 0x%lx <- 0x%lx "
-			"(0x%lx bytes)\n\r", initrd.addr,
-			(unsigned long)_initrd_start, initrd.size);
-		memmove((void *)initrd.addr, (void *)_initrd_start,
-			initrd.size);
-		printf("initrd head: 0x%lx\n\r",
-				*((unsigned long *)initrd.addr));
-	} else if (a2 != 0) {
-		/* Otherwise, see if yaboot or another loader gave us an initrd */
-		initrd.addr = a1;
-		initrd.memsize = initrd.size = a2;
-		printf("Using loader supplied initrd at 0x%lx (0x%lx bytes)\n\r",
-		       initrd.addr, initrd.size);
-	}
-
-	/* Eventually gunzip the kernel */
-	printf("gunzipping (0x%lx <- 0x%lx:0x%0lx)...",
-	       vmlinux.addr, vmlinuz.addr, vmlinuz.addr+vmlinuz.size);
-	/* discard up to the actual load data */
-	gunzip_discard(&gzstate, elfoffset - sizeof(elfheader));
-	len = gunzip_finish(&gzstate, (void *)vmlinux.addr,
-			    vmlinux.memsize);
-	printf("done 0x%lx bytes\n\r", len);
+		printf("Relocating initrd 0x%p <- 0x%p (0x%lx bytes)\n\r",
+		       initrd_addr, old_addr, initrd_size);
+		memmove((void *)initrd_addr, old_addr, initrd_size);
+	}
+
+	printf("initrd head: 0x%lx\n\r", *((unsigned long *)initrd_addr));
+
+	/* Tell the kernel initrd address via device tree */
+	devp = finddevice("/chosen");
+	if (! devp) {
+		printf("Device tree has no chosen node!\n\r");
+		exit();
+	}
+
+	initrd_start = (u32)initrd_addr;
+	initrd_end = (u32)initrd_addr + initrd_size;
+
+	setprop(devp, "linux,initrd-start", &initrd_start,
+		sizeof(initrd_start));
+	setprop(devp, "linux,initrd-end", &initrd_end, sizeof(initrd_end));
 
-	flush_cache((void *)vmlinux.addr, vmlinux.size);
+	return (struct addr_range){(void *)initrd_addr, initrd_size};
 }
 
 /* A buffer that may be edited by tools operating on a zImage binary so as to
@@ -223,6 +257,7 @@ struct console_ops console_ops;
 
 void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
 {
+	struct addr_range vmlinux, initrd;
 	kernel_entry_t kentry;
 	char cmdline[COMMAND_LINE_SIZE];
 	unsigned long ft_addr = 0;
@@ -242,7 +277,8 @@ void start(unsigned long a1, unsigned lo
 	printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r",
 	       _start, sp);
 
-	prep_kernel(a1, a2);
+	vmlinux = prep_kernel();
+	initrd = prep_initrd(vmlinux, a1, a2);
 
 	/* If cmdline came from zimage wrapper or if we can edit the one
 	 * in the dt, print it out and edit it, if possible.
@@ -271,8 +307,7 @@ void start(unsigned long a1, unsigned lo
 	if (ft_addr)
 		kentry(ft_addr, 0, NULL);
 	else
-		/* XXX initrd addr/size should be passed in properties */
-		kentry(initrd.addr, initrd.size, promptr);
+		kentry((unsigned long)initrd.addr, initrd.size, promptr);
 
 	/* console closed so printf below may not work */
 	printf("Error: Linux kernel returned to zImage boot wrapper!\n\r");
Index: working-2.6/arch/powerpc/boot/ops.h
===================================================================
--- working-2.6.orig/arch/powerpc/boot/ops.h	2007-02-19 14:00:51.000000000 +1100
+++ working-2.6/arch/powerpc/boot/ops.h	2007-02-19 14:01:38.000000000 +1100
@@ -25,6 +25,7 @@ struct platform_ops {
 	void	(*free)(void *ptr);
 	void *	(*realloc)(void *ptr, unsigned long size);
 	void	(*exit)(void);
+	void *	(*vmlinux_alloc)(unsigned long size);
 };
 extern struct platform_ops platform_ops;
 
Index: working-2.6/arch/powerpc/boot/of.c
===================================================================
--- working-2.6.orig/arch/powerpc/boot/of.c	2007-02-19 14:00:51.000000000 +1100
+++ working-2.6/arch/powerpc/boot/of.c	2007-02-19 14:01:38.000000000 +1100
@@ -208,6 +208,17 @@ static void of_image_hdr(const void *hdr
 	}
 }
 
+static void *of_vmlinux_alloc(unsigned long size)
+{
+	void *p = malloc(size);
+
+	if (!p) {
+		printf("Can't allocate memory for kernel image!\n\r");
+		exit();
+	}
+	return p;
+}
+
 static void of_exit(void)
 {
 	call_prom("exit", 0, 0);
@@ -261,6 +272,7 @@ int platform_init(void *promptr, char *d
 	platform_ops.image_hdr = of_image_hdr;
 	platform_ops.malloc = of_try_claim;
 	platform_ops.exit = of_exit;
+	platform_ops.vmlinux_alloc = of_vmlinux_alloc;
 
 	dt_ops.finddevice = of_finddevice;
 	dt_ops.getprop = of_getprop;

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 7/14] zImage: Cleanup and improve zImage entry point
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (5 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 11/14] Add arch/powerpc driver for UIC, PPC4xx interrupt controller David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-21  0:57   ` Geoff Levand
  2007-02-20  2:12 ` [PATCH 8/14] zImage wrapper for Ebony David Gibson
                   ` (7 subsequent siblings)
  14 siblings, 1 reply; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

This patch re-organises the way the zImage wrapper code is entered, to
allow more flexibility on platforms with unusual entry conditions.
After this patch, a platform .o file has two options:

1) It can define a _zimage_start, in which case the platform code gets
   control from the very beginning of execution.  In this case the
   platform code is responsible for relocating the zImage if necessary,
   clearing the BSS, performing any platform specific initialization, and
   finally calling start() to load and enter the kernel.

2) It can define platform_init().  In this case the generic crt0.S
   handles initial entry, and calls platform_init() before calling
   start().  The signature of platform_init() is changed, however, to
   take up to 5 parameters (in r3..r7) as they come from the platform's
   initial loader, instead of a fixed set of parameters based on OF's
   usage.

   When using the generic crt0.S, the platform .o can optionally
   supply a custom stack to use, using the BSS_STACK() macro.  If this
   is not supplied, the crt0.S will assume that the loader has
   supplied a usable stack.

In either case, the platform code communicates information to the
generic code (specifically, a PROM pointer for OF systems, and/or an
initrd image address supplied by the bootloader) via a global
structure "loader_info".

In addition the wrapper script is rearranged to ensure that the
platform .o is always linked first.  This means that platforms where
the zImage entry point is at a fixed address or offset, rather than
being encoded in the binary header can be supported using option (1).

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

 arch/powerpc/boot/Makefile          |    6 +++---
 arch/powerpc/boot/crt0.S            |   32 +++++++++++++++++++++++++++++---
 arch/powerpc/boot/main.c            |   18 +++++++-----------
 arch/powerpc/boot/of.c              |    6 ++++--
 arch/powerpc/boot/ops.h             |   12 +++++++++++-
 arch/powerpc/boot/wrapper           |    6 ++++--
 arch/powerpc/boot/zImage.coff.lds.S |    3 ++-
 arch/powerpc/boot/zImage.lds.S      |    1 +
 8 files changed, 61 insertions(+), 23 deletions(-)

Index: working-2.6/arch/powerpc/boot/crt0.S
===================================================================
--- working-2.6.orig/arch/powerpc/boot/crt0.S	2007-02-19 14:00:50.000000000 +1100
+++ working-2.6/arch/powerpc/boot/crt0.S	2007-02-19 14:01:43.000000000 +1100
@@ -16,6 +16,7 @@
 _zimage_start_opd:
 	.long	_zimage_start, 0, 0, 0
 
+	.weak	_zimage_start
 	.globl	_zimage_start
 _zimage_start:
 	/* Work out the offset between the address we were linked at
@@ -44,7 +45,7 @@ _zimage_start:
 	addi	r9,r9,4
 	bdnz	2b
 
-	/* Do a cache flush for our text, in case OF didn't */
+	/* Do a cache flush for our text, in case the loader didn't */
 3:	lis	r9,_start@ha
 	addi	r9,r9,_start@l
 	add	r9,r0,r9
@@ -59,6 +60,31 @@ _zimage_start:
 	sync
 	isync
 
-	mr	r6,r1
-	b	start
+	/* Clear the BSS */
+	lis	r9,__bss_start@ha
+	addi	r9,r9,__bss_start@l
+	lis	r8,_end@ha
+	addi	r8,r8,_end@l
+	li	r0,0
+5:	stw	r0,0(r9)
+	addi	r9,r9,4
+	cmplw	cr0,r9,r8
+	blt	5b
 
+	/* Possibly set up a custom stack */
+.weak	_platform_stack_top
+	lis	r8,_platform_stack_top@ha
+	addi	r8,r8,_platform_stack_top@l
+	cmpwi	r8,0
+	beq	6f
+	lwz	r1,0(r8)
+	li	r0,0
+	stwu	r0,-16(r1)	/* establish a stack frame */
+6:
+
+	/* Call platform_init() */
+	bl	platform_init
+
+	/* Call start */
+	mr	r3,r1
+	b	start
Index: working-2.6/arch/powerpc/boot/ops.h
===================================================================
--- working-2.6.orig/arch/powerpc/boot/ops.h	2007-02-19 14:01:38.000000000 +1100
+++ working-2.6/arch/powerpc/boot/ops.h	2007-02-19 14:01:43.000000000 +1100
@@ -59,7 +59,13 @@ struct serial_console_data {
 	void		(*close)(void);
 };
 
-int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end);
+struct loader_info {
+	void *promptr;
+	unsigned long initrd_addr, initrd_size;
+};
+extern struct loader_info loader_info;
+
+void start(void *sp);
 int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device);
 int serial_console_init(void);
 int ns16550_console_init(void *devp, struct serial_console_data *scdp);
@@ -100,4 +106,8 @@ static inline void exit(void)
 	for(;;);
 }
 
+#define BSS_STACK(size) \
+	static char _bss_stack[size]; \
+	void *_platform_stack_top = _bss_stack + sizeof(_bss_stack);
+
 #endif /* _PPC_BOOT_OPS_H_ */
Index: working-2.6/arch/powerpc/boot/main.c
===================================================================
--- working-2.6.orig/arch/powerpc/boot/main.c	2007-02-19 14:01:38.000000000 +1100
+++ working-2.6/arch/powerpc/boot/main.c	2007-02-19 14:01:43.000000000 +1100
@@ -254,21 +254,15 @@ static void set_cmdline(char *buf)
 struct platform_ops platform_ops;
 struct dt_ops dt_ops;
 struct console_ops console_ops;
+struct loader_info loader_info;
 
-void start(unsigned long a1, unsigned long a2, void *promptr, void *sp)
+void start(void *sp)
 {
 	struct addr_range vmlinux, initrd;
 	kernel_entry_t kentry;
 	char cmdline[COMMAND_LINE_SIZE];
 	unsigned long ft_addr = 0;
 
-	memset(__bss_start, 0, _end - __bss_start);
-	memset(&platform_ops, 0, sizeof(platform_ops));
-	memset(&dt_ops, 0, sizeof(dt_ops));
-	memset(&console_ops, 0, sizeof(console_ops));
-
-	if (platform_init(promptr, _dtb_start, _dtb_end))
-		exit();
 	if (console_ops.open && (console_ops.open() < 0))
 		exit();
 	if (platform_ops.fixups)
@@ -278,7 +272,8 @@ void start(unsigned long a1, unsigned lo
 	       _start, sp);
 
 	vmlinux = prep_kernel();
-	initrd = prep_initrd(vmlinux, a1, a2);
+	initrd = prep_initrd(vmlinux, loader_info.initrd_addr,
+			     loader_info.initrd_size);
 
 	/* If cmdline came from zimage wrapper or if we can edit the one
 	 * in the dt, print it out and edit it, if possible.
@@ -298,7 +293,7 @@ void start(unsigned long a1, unsigned lo
 	if (ft_addr)
 		printf(" flat tree at 0x%lx\n\r", ft_addr);
 	else
-		printf(" using OF tree (promptr=%p)\n\r", promptr);
+		printf(" using OF tree (promptr=%p)\n\r", loader_info.promptr);
 
 	if (console_ops.close)
 		console_ops.close();
@@ -307,7 +302,8 @@ void start(unsigned long a1, unsigned lo
 	if (ft_addr)
 		kentry(ft_addr, 0, NULL);
 	else
-		kentry((unsigned long)initrd.addr, initrd.size, promptr);
+		kentry((unsigned long)initrd.addr, initrd.size,
+		       loader_info.promptr);
 
 	/* console closed so printf below may not work */
 	printf("Error: Linux kernel returned to zImage boot wrapper!\n\r");
Index: working-2.6/arch/powerpc/boot/of.c
===================================================================
--- working-2.6.orig/arch/powerpc/boot/of.c	2007-02-19 14:01:38.000000000 +1100
+++ working-2.6/arch/powerpc/boot/of.c	2007-02-19 14:01:43.000000000 +1100
@@ -267,7 +267,7 @@ static void of_console_write(char *buf, 
 	call_prom("write", 3, 1, of_stdout_handle, buf, len);
 }
 
-int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end)
+void platform_init(unsigned long a1, unsigned long a2, void *promptr)
 {
 	platform_ops.image_hdr = of_image_hdr;
 	platform_ops.malloc = of_try_claim;
@@ -282,5 +282,7 @@ int platform_init(void *promptr, char *d
 	console_ops.write = of_console_write;
 
 	prom = (int (*)(void *))promptr;
-	return 0;
+	loader_info.promptr = promptr;
+	loader_info.initrd_addr = a1;
+	loader_info.initrd_size = a2;
 }
Index: working-2.6/arch/powerpc/boot/Makefile
===================================================================
--- working-2.6.orig/arch/powerpc/boot/Makefile	2007-02-19 14:00:50.000000000 +1100
+++ working-2.6/arch/powerpc/boot/Makefile	2007-02-19 14:01:43.000000000 +1100
@@ -40,11 +40,11 @@ zliblinuxheader := zlib.h zconf.h zutil.
 $(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) \
 		$(addprefix $(obj)/,$(zlibheader))
 
-src-wlib := string.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
+src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
 		ns16550.c serial.c simple_alloc.c div64.S util.S \
 		gunzip_util.c $(zlib)
 src-plat := of.c
-src-boot := crt0.S $(src-wlib) $(src-plat) empty.c
+src-boot := $(src-wlib) $(src-plat) empty.c
 
 src-boot := $(addprefix $(obj)/, $(src-boot))
 obj-boot := $(addsuffix .o, $(basename $(src-boot)))
@@ -97,7 +97,7 @@ $(obj)/wrapper.a: $(obj-wlib)
 
 hostprogs-y	:= addnote addRamDisk hack-coff mktree
 
-extra-y		:= $(obj)/crt0.o $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
+extra-y		:= $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
 		   $(obj)/zImage.lds $(obj)/zImage.coff.lds
 
 wrapper		:=$(srctree)/$(src)/wrapper
Index: working-2.6/arch/powerpc/boot/wrapper
===================================================================
--- working-2.6.orig/arch/powerpc/boot/wrapper	2007-02-19 14:00:50.000000000 +1100
+++ working-2.6/arch/powerpc/boot/wrapper	2007-02-19 14:01:43.000000000 +1100
@@ -191,7 +191,7 @@ fi
 
 if [ "$platform" != "miboot" ]; then
     ${CROSS}ld -m elf32ppc -T $lds -o "$ofile" \
-	$object/crt0.o $platformo $tmp $object/wrapper.a
+	$platformo $tmp $object/wrapper.a
     rm $tmp
 fi
 
@@ -201,7 +201,9 @@ pseries|chrp)
     $object/addnote "$ofile"
     ;;
 pmaccoff)
-    ${CROSS}objcopy -O aixcoff-rs6000 --set-start 0x500000 "$ofile"
+    entry=`objdump -f "$ofile" | grep '^start address ' | \
+	cut -d' ' -f3`
+    ${CROSS}objcopy -O aixcoff-rs6000 --set-start "$entry" "$ofile"
     $object/hack-coff "$ofile"
     ;;
 esac
Index: working-2.6/arch/powerpc/boot/zImage.lds.S
===================================================================
--- working-2.6.orig/arch/powerpc/boot/zImage.lds.S	2007-02-19 14:00:50.000000000 +1100
+++ working-2.6/arch/powerpc/boot/zImage.lds.S	2007-02-19 14:01:43.000000000 +1100
@@ -1,5 +1,6 @@
 OUTPUT_ARCH(powerpc:common)
 ENTRY(_zimage_start)
+EXTERN(_zimage_start)
 SECTIONS
 {
   . = (4*1024*1024);
Index: working-2.6/arch/powerpc/boot/zImage.coff.lds.S
===================================================================
--- working-2.6.orig/arch/powerpc/boot/zImage.coff.lds.S	2007-02-19 14:00:50.000000000 +1100
+++ working-2.6/arch/powerpc/boot/zImage.coff.lds.S	2007-02-19 14:01:43.000000000 +1100
@@ -1,5 +1,6 @@
 OUTPUT_ARCH(powerpc:common)
-ENTRY(_start)
+ENTRY(_zimage_start_opd)
+EXTERN(_zimage_start_opd)
 SECTIONS
 {
   . = (5*1024*1024);

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 8/14] zImage wrapper for Ebony
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (6 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 7/14] zImage: Cleanup and improve zImage entry point David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20  2:12 ` [PATCH 9/14] Port 44x MMU definitions to ARCH=powerpc David Gibson
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

This patch adds support for building a zImage wrapper suitable for the
Ebony (440GP) evaluation board.  This supports booting both from uboot
(old versions which don't supply a flattened device tree) and IBM
Openbios (aka "treeboot").

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

 arch/powerpc/boot/Makefile |   33 ++++++++++++++++++++++++++++++++-
 arch/powerpc/boot/ebony.c  |   32 ++++++++++++++++++++++++++++++++
 arch/powerpc/boot/mktree.c |   10 ++++------
 arch/powerpc/boot/wrapper  |   33 +++++++++++++++++++++++++++++++++
 4 files changed, 101 insertions(+), 7 deletions(-)

Index: working-2.6/arch/powerpc/boot/Makefile
===================================================================
--- working-2.6.orig/arch/powerpc/boot/Makefile	2007-02-16 15:12:06.000000000 +1100
+++ working-2.6/arch/powerpc/boot/Makefile	2007-02-16 15:13:40.000000000 +1100
@@ -43,7 +43,7 @@ $(addprefix $(obj)/,$(zlib) main.o): $(a
 src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
 		ns16550.c serial.c simple_alloc.c div64.S util.S \
 		gunzip_util.c $(zlib)
-src-plat := of.c
+src-plat := of.c ebony.c
 src-boot := $(src-wlib) $(src-plat) empty.c
 
 src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -95,6 +95,12 @@ $(patsubst %.S,%.o, $(filter %.S, $(src-
 $(obj)/wrapper.a: $(obj-wlib)
 	$(call cmd,bootar)
 
+quiet_cmd_dtc = DTC     $@
+      cmd_dtc = $(dtc) -O dtb -o $@ -b 0 -V 16 $<
+
+$(obj)/%.dtb: $(srctree)/$(src)/dts/%.dts
+	$(call if_changed,dtc)
+
 hostprogs-y	:= addnote addRamDisk hack-coff mktree
 
 extra-y		:= $(obj)/wrapper.a $(obj-plat) $(obj)/empty.o \
@@ -103,6 +109,8 @@ extra-y		:= $(obj)/wrapper.a $(obj-plat)
 wrapper		:=$(srctree)/$(src)/wrapper
 wrapperbits	:= $(extra-y) $(addprefix $(obj)/,addnote hack-coff mktree)
 
+dtc		:= dtc
+
 #############
 # Bits for building various flavours of zImage
 
@@ -120,6 +128,13 @@ quiet_cmd_wrap_initrd = WRAP    $@
       cmd_wrap_initrd =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
 				-i $(obj)/ramdisk.image.gz vmlinux
 
+quiet_cmd_wrap_dtb	= WRAP    $@
+      cmd_wrap_dtb	=$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
+				-d $3 vmlinux
+quiet_cmd_wrap_dtb_initrd = WRAP    $@
+      cmd_wrap_dtb_initrd =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
+				-d $3 -i $(obj)/ramdisk.image.gz vmlinux
+
 $(obj)/zImage.chrp: vmlinux $(wrapperbits)
 	$(call cmd,wrap,chrp)
 
@@ -156,6 +171,21 @@ $(obj)/zImage.ps3: vmlinux
 $(obj)/zImage.initrd.ps3: vmlinux
 	@echo "  WARNING zImage.initrd.ps3 not supported (yet)"
 
+$(obj)/zImage.ebony-elf: vmlinux $(wrapperbits) $(obj)/ebony.dtb
+	$(call cmd,wrap_dtb,ebony,$(obj)/ebony.dtb)
+
+$(obj)/zImage.initrd.ebony-elf: vmlinux $(wrapperbits) $(obj)/ebony.dtb $(obj)/ramdisk.image.gz
+	$(call cmd,wrap_dtb_initrd,ebony,$(obj)/ebony.dtb)
+
+$(obj)/zImage.ebony: vmlinux $(wrapperbits) $(obj)/ebony.dtb $(obj)/mktree
+	$(call cmd,wrap_dtb,ebony-tree,$(obj)/ebony.dtb)
+
+$(obj)/zImage.initrd.ebony: vmlinux $(wrapperbits) $(obj)/ebony.dtb $(obj)/mktree
+	$(call cmd,wrap_dtb_initrd,ebony-tree,$(obj)/ebony.dtb)
+
+$(obj)/uImage.ebony: vmlinux $(wrapperbits)  $(obj)/ebony.dtb
+	$(call cmd,wrap_dtb,ebony-uboot,$(obj)/ebony.dtb)
+
 $(obj)/uImage: vmlinux $(wrapperbits)
 	$(call cmd,wrap,uboot)
 
@@ -167,6 +197,7 @@ image-$(CONFIG_PPC_CELLEB)		+= zImage.ps
 image-$(CONFIG_PPC_CHRP)		+= zImage.chrp
 image-$(CONFIG_PPC_EFIKA)		+= zImage.chrp
 image-$(CONFIG_PPC_PMAC)		+= zImage.pmac
+image-$(CONFIG_EBONY)			+= zImage.ebony-elf zImage.ebony uImage.ebony
 image-$(CONFIG_DEFAULT_UIMAGE)		+= uImage
 
 # For 32-bit powermacs, build the COFF and miboot images
Index: working-2.6/arch/powerpc/boot/ebony.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/arch/powerpc/boot/ebony.c	2007-02-16 15:13:40.000000000 +1100
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) Paul Mackerras 1997.
+ *
+ * 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 <stdarg.h>
+#include <stddef.h>
+#include "types.h"
+#include "elf.h"
+#include "string.h"
+#include "stdio.h"
+#include "page.h"
+#include "ops.h"
+
+extern char _start[];
+extern char _end[];
+extern char _dtb_start[];
+extern char _dtb_end[];
+
+BSS_STACK(4096);
+
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5)
+{
+	u32 heapsize = 0x8000000 - (u32)_end; /* 128M */
+
+	simple_alloc_init(_end, heapsize, 32, 64);
+	ft_init(_dtb_start, 0, 4);
+	serial_console_init();
+}
Index: working-2.6/arch/powerpc/boot/wrapper
===================================================================
--- working-2.6.orig/arch/powerpc/boot/wrapper	2007-02-16 15:13:36.000000000 +1100
+++ working-2.6/arch/powerpc/boot/wrapper	2007-02-16 15:13:40.000000000 +1100
@@ -137,6 +137,12 @@ miboot|uboot)
     ksection=image
     isection=initrd
     ;;
+*-tree)
+    platformo=$object/"${platform%%-tree}".o
+    ;;
+*-uboot)
+    platformo=$object/"${platform%%-uboot}".o
+    ;;
 esac
 
 vmz="$tmpdir/`basename \"$kernel\"`.$ext"
@@ -206,4 +212,31 @@ pmaccoff)
     ${CROSS}objcopy -O aixcoff-rs6000 --set-start "$entry" "$ofile"
     $object/hack-coff "$ofile"
     ;;
+*-tree)
+    mv "$ofile" "$ofile.elf"
+    entry=`objdump -f "$ofile.elf" | grep '^start address ' | \
+	cut -d' ' -f3`
+    $object/mktree "$ofile.elf" "$ofile" 0x00400000 "$entry"
+    if [ -z "$cacheit" ]; then
+	rm -f "$ofile.elf"
+    fi
+    exit 0
+    ;;
+*-uboot)
+    mv "$ofile" "$ofile.elf"
+    version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \
+	cut -d' ' -f3`
+    if [ -n "$version" ]; then
+	version="-n Linux-$version"
+    fi
+    entry=`objdump -f "$ofile.elf" | grep '^start address ' | \
+	cut -d' ' -f3`
+    ${CROSS}objcopy -O binary "$ofile.elf" "$ofile.bin"
+    mkimage -A ppc -O linux -T kernel -C none -a 0x00400000 -e $entry \
+	$version -d "$ofile.bin" "$ofile"
+    if [ -z "$cacheit" ]; then
+	rm -f "$ofile.elf" "$ofile.bin"
+    fi
+    exit 0
+    ;;
 esac
Index: working-2.6/arch/powerpc/boot/mktree.c
===================================================================
--- working-2.6.orig/arch/powerpc/boot/mktree.c	2007-02-16 15:12:06.000000000 +1100
+++ working-2.6/arch/powerpc/boot/mktree.c	2007-02-16 15:13:40.000000000 +1100
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
 	struct	stat	st;
 	boot_block_t	bt;
 
-	if (argc < 3) {
-		fprintf(stderr, "usage: %s <zImage-file> <boot-image> [entry-point]\n",argv[0]);
+	if (argc < 5) {
+		fprintf(stderr, "usage: %s <zImage-file> <boot-image> <load address> <entry point>\n",argv[0]);
 		exit(1);
 	}
 
@@ -61,10 +61,8 @@ int main(int argc, char *argv[])
 	bt.bb_magic = htonl(0x0052504F);
 
 	/* If we have the optional entry point parameter, use it */
-	if (argc == 4)
-		bt.bb_dest = bt.bb_entry_point = htonl(strtoul(argv[3], NULL, 0));
-	else
-		bt.bb_dest = bt.bb_entry_point = htonl(0x500000);
+	bt.bb_dest = htonl(strtoul(argv[3], NULL, 0));
+	bt.bb_entry_point = htonl(strtoul(argv[4], NULL, 0));
 
 	/* We know these from the linker command.
 	 * ...and then move it up into memory a little more so the

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 9/14] Port 44x MMU definitions to ARCH=powerpc
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (7 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 8/14] zImage wrapper for Ebony David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20  2:12 ` [PATCH 6/14] zImage: Cleanup and improve prep_kernel() David Gibson
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

This patch moves the mmu.h definitions which are still relevant for
ARCH=powerpc from include/asm-ppc/mmu.h to their own file,
include/asm-powerpc/mmu_44x.h.  The new file is included from
asm-powerpc/mmu.h, and a couple of other tweaks to correct mmu
definitions for 44x are made.

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

 arch/powerpc/kernel/head_44x.S |    4 +-
 arch/powerpc/mm/44x_mmu.c      |   81 ++++++++---------------------------------
 arch/powerpc/mm/mmu_decl.h     |    2 +
 include/asm-powerpc/mmu.h      |    4 +-
 include/asm-powerpc/mmu_44x.h  |   74 +++++++++++++++++++++++++++++++++++++
 5 files changed, 98 insertions(+), 67 deletions(-)

Index: working-2.6/include/asm-powerpc/mmu.h
===================================================================
--- working-2.6.orig/include/asm-powerpc/mmu.h	2007-01-24 12:01:20.000000000 +1100
+++ working-2.6/include/asm-powerpc/mmu.h	2007-02-05 14:24:52.000000000 +1100
@@ -2,7 +2,9 @@
 #define _ASM_POWERPC_MMU_H_
 #ifdef __KERNEL__
 
-#ifndef CONFIG_PPC64
+#ifdef CONFIG_44x
+#include <asm/mmu_44x.h>
+#elif !defined(CONFIG_PPC64)
 #include <asm-ppc/mmu.h>
 #else
 
Index: working-2.6/include/asm-powerpc/mmu_44x.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/include/asm-powerpc/mmu_44x.h	2007-02-05 15:25:11.000000000 +1100
@@ -0,0 +1,74 @@
+#ifndef _ASM_POWERPC_MMU_44X_H_
+#define _ASM_POWERPC_MMU_44X_H_
+
+#ifndef __ASSEMBLY__
+
+typedef unsigned long long phys_addr_t;
+extern phys_addr_t fixup_bigphys_addr(phys_addr_t, phys_addr_t);
+#define PHYS_FMT	"%16Lx"
+
+typedef struct {
+	unsigned long id;
+	unsigned long vdso_base;
+} mm_context_t;
+
+#endif /* !__ASSEMBLY__ */
+
+/*
+ * PPC440 support
+ */
+#define PPC44x_MMUCR_TID	0x000000ff
+#define PPC44x_MMUCR_STS	0x00010000
+
+#define	PPC44x_TLB_PAGEID	0
+#define	PPC44x_TLB_XLAT		1
+#define	PPC44x_TLB_ATTRIB	2
+
+/* Page identification fields */
+#define PPC44x_TLB_EPN_MASK	0xfffffc00      /* Effective Page Number */
+#define	PPC44x_TLB_VALID	0x00000200      /* Valid flag */
+#define PPC44x_TLB_TS		0x00000100	/* Translation address space */
+#define PPC44x_TLB_1K		0x00000000	/* Page sizes */
+#define PPC44x_TLB_4K		0x00000010
+#define PPC44x_TLB_16K		0x00000020
+#define PPC44x_TLB_64K		0x00000030
+#define PPC44x_TLB_256K		0x00000040
+#define PPC44x_TLB_1M		0x00000050
+#define PPC44x_TLB_16M		0x00000070
+#define	PPC44x_TLB_256M		0x00000090
+
+/* Translation fields */
+#define PPC44x_TLB_RPN_MASK	0xfffffc00      /* Real Page Number */
+#define	PPC44x_TLB_ERPN_MASK	0x0000000f
+
+/* Storage attribute and access control fields */
+#define PPC44x_TLB_ATTR_MASK	0x0000ff80
+#define PPC44x_TLB_U0		0x00008000      /* User 0 */
+#define PPC44x_TLB_U1		0x00004000      /* User 1 */
+#define PPC44x_TLB_U2		0x00002000      /* User 2 */
+#define PPC44x_TLB_U3		0x00001000      /* User 3 */
+#define PPC44x_TLB_W		0x00000800      /* Caching is write-through */
+#define PPC44x_TLB_I		0x00000400      /* Caching is inhibited */
+#define PPC44x_TLB_M		0x00000200      /* Memory is coherent */
+#define PPC44x_TLB_G		0x00000100      /* Memory is guarded */
+#define PPC44x_TLB_E		0x00000080      /* Memory is guarded */
+
+#define PPC44x_TLB_PERM_MASK	0x0000003f
+#define PPC44x_TLB_UX		0x00000020      /* User execution */
+#define PPC44x_TLB_UW		0x00000010      /* User write */
+#define PPC44x_TLB_UR		0x00000008      /* User read */
+#define PPC44x_TLB_SX		0x00000004      /* Super execution */
+#define PPC44x_TLB_SW		0x00000002      /* Super write */
+#define PPC44x_TLB_SR		0x00000001      /* Super read */
+
+/* Number of TLB entries */
+#define PPC44x_TLB_SIZE		64
+
+/* TLB entry offset/size used for pinning kernel lowmem */
+#define PPC44x_PIN_SHIFT	28
+#define PPC_PIN_SIZE		(1 << PPC44x_PIN_SHIFT)
+
+#define PPC44x_EARLY_TLBS	1
+
+#endif /* _ASM_POWERPC_MMU_44X_H_ */
+
Index: working-2.6/arch/powerpc/mm/44x_mmu.c
===================================================================
--- working-2.6.orig/arch/powerpc/mm/44x_mmu.c	2006-12-08 10:42:48.000000000 +1100
+++ working-2.6/arch/powerpc/mm/44x_mmu.c	2007-02-05 15:25:19.000000000 +1100
@@ -24,73 +24,35 @@
  *
  */
 
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/mman.h>
-#include <linux/mm.h>
-#include <linux/swap.h>
-#include <linux/stddef.h>
-#include <linux/vmalloc.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/highmem.h>
-
-#include <asm/pgalloc.h>
-#include <asm/prom.h>
-#include <asm/io.h>
-#include <asm/mmu_context.h>
-#include <asm/pgtable.h>
 #include <asm/mmu.h>
-#include <asm/uaccess.h>
-#include <asm/smp.h>
-#include <asm/bootx.h>
-#include <asm/machdep.h>
-#include <asm/setup.h>
 
 #include "mmu_decl.h"
 
-extern char etext[], _stext[];
-
 /* Used by the 44x TLB replacement exception handler.
  * Just needed it declared someplace.
  */
-unsigned int tlb_44x_index = 0;
-unsigned int tlb_44x_hwater = 62;
+unsigned int tlb_44x_index; /* = 0 */
+unsigned int tlb_44x_hwater = PPC44x_TLB_SIZE - 1 - PPC44x_EARLY_TLBS;
 
 /*
  * "Pins" a 256MB TLB entry in AS0 for kernel lowmem
  */
-static void __init
-ppc44x_pin_tlb(int slot, unsigned int virt, unsigned int phys)
+static void __init ppc44x_pin_tlb(unsigned int virt, unsigned int phys)
 {
-	unsigned long attrib = 0;
-
-	__asm__ __volatile__("\
-	clrrwi	%2,%2,10\n\
-	ori	%2,%2,%4\n\
-	clrrwi	%1,%1,10\n\
-	li	%0,0\n\
-	ori	%0,%0,%5\n\
-	tlbwe	%2,%3,%6\n\
-	tlbwe	%1,%3,%7\n\
-	tlbwe	%0,%3,%8"
+	__asm__ __volatile__(
+		"tlbwe	%2,%3,%4\n"
+		"tlbwe	%1,%3,%5\n"
+		"tlbwe	%0,%3,%6\n"
 	:
-	: "r" (attrib), "r" (phys), "r" (virt), "r" (slot),
-	  "i" (PPC44x_TLB_VALID | PPC44x_TLB_256M),
-	  "i" (PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G),
+	: "r" (PPC44x_TLB_SW | PPC44x_TLB_SR | PPC44x_TLB_SX | PPC44x_TLB_G),
+	  "r" (phys),
+	  "r" (virt | PPC44x_TLB_VALID | PPC44x_TLB_256M),
+	  "r" (tlb_44x_hwater--), /* slot for this TLB entry */
 	  "i" (PPC44x_TLB_PAGEID),
 	  "i" (PPC44x_TLB_XLAT),
 	  "i" (PPC44x_TLB_ATTRIB));
 }
 
-/*
- * MMU_init_hw does the chip-specific initialization of the MMU hardware.
- */
 void __init MMU_init_hw(void)
 {
 	flush_instruction_cache();
@@ -98,22 +60,13 @@ void __init MMU_init_hw(void)
 
 unsigned long __init mmu_mapin_ram(void)
 {
-	unsigned int pinned_tlbs = 1;
-	int i;
+	unsigned long addr;
 
-	/* Determine number of entries necessary to cover lowmem */
-	pinned_tlbs = (unsigned int)
-		(_ALIGN(total_lowmem, PPC_PIN_SIZE) >> PPC44x_PIN_SHIFT);
-
-	/* Write upper watermark to save location */
-	tlb_44x_hwater = PPC44x_LOW_SLOT - pinned_tlbs;
-
-	/* If necessary, set additional pinned TLBs */
-	if (pinned_tlbs > 1)
-		for (i = (PPC44x_LOW_SLOT-(pinned_tlbs-1)); i < PPC44x_LOW_SLOT; i++) {
-			unsigned int phys_addr = (PPC44x_LOW_SLOT-i) * PPC_PIN_SIZE;
-			ppc44x_pin_tlb(i, phys_addr+PAGE_OFFSET, phys_addr);
-		}
+	/* Pin in enough TLBs to cover any lowmem not covered by the
+	 * initial 256M mapping established in head_44x.S */
+	for (addr = PPC_PIN_SIZE; addr < total_lowmem;
+	     addr += PPC_PIN_SIZE)
+		ppc44x_pin_tlb(addr + PAGE_OFFSET, addr);
 
 	return total_lowmem;
 }
Index: working-2.6/arch/powerpc/mm/mmu_decl.h
===================================================================
--- working-2.6.orig/arch/powerpc/mm/mmu_decl.h	2006-12-08 10:42:48.000000000 +1100
+++ working-2.6/arch/powerpc/mm/mmu_decl.h	2007-02-05 14:24:52.000000000 +1100
@@ -35,8 +35,10 @@ extern int __map_without_bats;
 extern unsigned long ioremap_base;
 extern unsigned int rtas_data, rtas_size;
 
+#ifdef CONFIG_CLASSIC32
 extern PTE *Hash, *Hash_end;
 extern unsigned long Hash_size, Hash_mask;
+#endif /* CONFIG_CLASSIC32 */
 
 extern unsigned int num_tlbcam_entries;
 #endif
Index: working-2.6/arch/powerpc/kernel/head_44x.S
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/head_44x.S	2007-02-05 14:24:52.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/head_44x.S	2007-02-05 15:25:11.000000000 +1100
@@ -120,8 +120,8 @@ skpinv:	addi	r4,r4,1				/* Increment */
  * Configure and load pinned entry into TLB slot 63.
  */
 
-	lis	r3,KERNELBASE@h		/* Load the kernel virtual address */
-	ori	r3,r3,KERNELBASE@l
+	lis	r3,PAGE_OFFSET@h
+	ori	r3,r3,PAGE_OFFSET@l
 
 	/* Kernel is at the base of RAM */
 	li r4, 0			/* Load the kernel physical address */

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 10/14] Early serial debug support for PPC44x
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (10 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 12/14] Add device tree for Ebony David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20 13:26   ` Segher Boessenkool
  2007-02-20  2:12 ` [PATCH 13/14] Re-organize Kconfig code for 4xx in arch/powerpc David Gibson
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

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/Makefile      |    1 
 arch/powerpc/kernel/head_44x.S    |   34 ++++++++++------------------
 arch/powerpc/kernel/misc_44x.S    |   46 ++++++++++++++++++++++++++++++++++++++
 arch/powerpc/kernel/of_platform.c |    1 
 arch/powerpc/kernel/udbg.c        |    3 ++
 arch/powerpc/kernel/udbg_16550.c  |   24 +++++++++++++++++++
 include/asm-powerpc/mmu_44x.h     |    7 ++++-
 include/asm-powerpc/udbg.h        |    1 
 9 files changed, 112 insertions(+), 28 deletions(-)

Index: working-2.6/arch/powerpc/Kconfig.debug
===================================================================
--- working-2.6.orig/arch/powerpc/Kconfig.debug	2007-02-20 11:06:54.000000000 +1100
+++ working-2.6/arch/powerpc/Kconfig.debug	2007-02-20 11:07:36.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 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-02-20 11:06:54.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/head_44x.S	2007-02-20 11:07:36.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-02-20 11:06:54.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/udbg_16550.c	2007-02-20 11:07:36.000000000 +1100
@@ -191,3 +191,27 @@ void udbg_init_pas_realmode(void)
 	udbg_getc_poll = NULL;
 }
 #endif /* CONFIG_PPC_MAPLE */
+
+#ifdef CONFIG_PPC_EARLY_DEBUG_44x
+extern u8 as1_readb(volatile u8 __iomem  *addr);
+extern void as1_writeb(u8 data, volatile u8 __iomem *addr);
+
+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.h
===================================================================
--- working-2.6.orig/include/asm-powerpc/mmu_44x.h	2007-02-20 11:06:54.000000000 +1100
+++ working-2.6/include/asm-powerpc/mmu_44x.h	2007-02-20 11:07:36.000000000 +1100
@@ -68,7 +68,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_H_ */
-
Index: working-2.6/arch/powerpc/kernel/udbg.c
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/udbg.c	2007-02-20 11:06:54.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/udbg.c	2007-02-20 11:07:36.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-02-20 11:06:54.000000000 +1100
+++ working-2.6/include/asm-powerpc/udbg.h	2007-02-20 11:07:36.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/Makefile
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/Makefile	2007-02-20 11:06:54.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/Makefile	2007-02-20 11:07:36.000000000 +1100
@@ -53,6 +53,7 @@ obj-y				+= time.o prom.o traps.o setup-
 				   udbg.o misc.o io.o
 obj-$(CONFIG_PPC32)		+= entry_32.o setup_32.o misc_32.o
 obj-$(CONFIG_PPC64)		+= misc_64.o dma_64.o iommu.o
+obj-$(CONFIG_44x)		+= misc_44x.o
 obj-$(CONFIG_PPC_MULTIPLATFORM)	+= prom_init.o
 obj-$(CONFIG_MODULES)		+= ppc_ksyms.o
 obj-$(CONFIG_BOOTX_TEXT)	+= btext.o
Index: working-2.6/arch/powerpc/kernel/misc_44x.S
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/arch/powerpc/kernel/misc_44x.S	2007-02-20 11:07:36.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/kernel/of_platform.c
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/of_platform.c	2007-02-20 11:06:54.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/of_platform.c	2007-02-20 11:16:56.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.

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 12/14] Add device tree for Ebony
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (9 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 6/14] zImage: Cleanup and improve prep_kernel() David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20 15:09   ` Josh Boyer
  2007-02-20 19:22   ` Yoder Stuart-B08248
  2007-02-20  2:12 ` [PATCH 10/14] Early serial debug support for PPC44x David Gibson
                   ` (3 subsequent siblings)
  14 siblings, 2 replies; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

Add a device tree for the Ebony evaluation board (440GP based).  This
tree is not complete or finalized.  This tree needs a very recent
version of dtc to process.

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

 arch/powerpc/boot/dts/ebony.dts |  225 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 225 insertions(+)

Index: working-2.6/arch/powerpc/boot/dts/ebony.dts
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/arch/powerpc/boot/dts/ebony.dts	2007-02-19 15:31:36.000000000 +1100
@@ -0,0 +1,225 @@
+/*
+ * Device Tree Source for IBM Ebony
+ *
+ * Copyright (c) 2006, 2007 IBM Corp.
+ * Josh Boyer <jdub@us.ibm.com>, David Gibson <dwg@au1.ibm.com>
+ *
+ * FIXME: Draft only!
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without
+ * any warranty of any kind, whether express or implied.
+ *
+ * To build:
+ *   dtc -I dts -O asm -o ebony.S -b 0 -V 16 ebony.dts
+ *   dtc -I dts -O dtb -o ebony.dtb -b 0 -V 16 ebony.dts
+ */
+
+/ {
+	#address-cells = <2>;
+	#size-cells = <1>;
+	model = "Ebony";
+	compatible = "Ebony";
+	dcr-parent = <&/cpus/PowerPC,440GP@0>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		PowerPC,440GP@0 {
+			model = "440GP Rev. C";
+			device_type = "cpu";
+			reg = <0>;
+			clock-frequency = <17d78400>; /* 400MHz FIXME: poke in zImage */
+			timebase-frequency = <17d78400>; /* 400MHz FIXME: wrong, poke in zImage */
+			i-cache-line-size = <32>;
+			d-cache-line-size = <32>;
+			i-cache-size = <0>;
+			d-cache-size = <0>;
+			dcr-controller;
+			dcr-access-method = "native";
+		};
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0 00000000 08000000>; /* Set by bootwrapper */
+	};
+
+	UIC0: interrupt-controller { /* UIC0 */
+		device_type = "interrupt-controller";
+		compatible = "ibm,uic440gp", "ibm,uic";
+		interrupt-controller;
+		cell-index = <0>;
+		dcr-reg = <0c0 009>;
+		#address-cells = <0>;
+		#size-cells = <0>;
+		#interrupt-cells = <2>;
+
+		UIC1: interrupt-controller@1 { /* UIC1 */
+			device_type = "interrupt-controller";
+			compatible = "ibm,uic440gp", "ibm,uic";
+			interrupt-controller;
+			cell-index = <1>;
+			dcr-reg = <0d0 009>;
+			#address-cells = <0>;
+			#size-cells = <0>;
+			#interrupt-cells = <2>;
+			interrupts = <1e 4 1f 4>; /* cascade */
+		};
+	};
+
+	plb {
+		device_type = "ibm,plb";
+		compatible = "ibm,plb-440gp", "ibm,plb4";
+		#address-cells = <2>;
+		#size-cells = <1>;
+		ranges;
+
+		POB0: opb@0 {
+			device_type = "ibm,opb";
+			compatible = "ibm,opb-440gp", "ibm,opb";
+			ranges;
+			dcr-reg = <090 00b>;
+			interrupt-parent = <&UIC1>;
+			interrupts = <7 4>;
+			clock-frequency = <3ef1480>; // FIXME: 66MHz
+
+			UART0: serial@140000200 {
+				device_type = "serial";
+				compatible = "ns16550";
+				reg = <1 40000200 8>;
+				virtual-reg = <e0000200>;
+				clock-frequency = <A8C000>;
+				current-speed = <2580>;
+				interrupt-parent = <&UIC0>;
+				interrupts = <0 4>;
+			};
+
+			UART1: serial@140000300 {
+				device_type = "serial";
+				compatible = "ns16550";
+				reg = <1 40000300 8>;
+				virtual-reg = <e0000300>;
+				clock-frequency = <A8C000>;
+				current-speed = <2580>; /* FIXME */
+				interrupt-parent = <&UIC0>;
+				interrupts = <1 4>;
+			};
+
+			IIC0: i2c@140000400 {
+				/* FIXME */
+				device_type = "i2c";
+				compatible = "ibm,iic-440gp", "ibm,iic";
+				reg = <1 40000400 14>;
+				interrupt-parent = <&UIC0>;
+				interrupts = <2 4>;
+			};
+			IIC1: i2c@140000500 {
+				/* FIXME */
+				device_type = "i2c";
+				compatible = "ibm,iic-440gp", "ibm,iic";
+				reg = <1 40000500 14>;
+				interrupt-parent = <&UIC0>;
+				interrupts = <3 4>;
+			};
+
+			GPIO0: gpio@140000700 {
+				/* FIXME */
+				device_type = "gpio";
+				compatible = "ibm,gpio-440gp";
+				reg = <1 40000700 20>;
+			};
+
+			ZMII0: emac-zmii@140000780 {
+				device_type = "emac-zmii";
+				compatible = "ibm,zmii-440gp", "ibm,zmii";
+				reg = <1 40000780 c>;
+			};
+
+			EMAC0: ethernet@140000800 {
+				device_type = "network";
+				compatible = "ibm,emac-440gp", "ibm,emac";
+				interrupt-parent = <&UIC1>;
+				interrupts = <1c 4 1d 4>;
+				reg = <1 40000800 70>;
+				local-mac-address = [0004ace31b1e]; // FIXME
+				mal-device = <&MAL0>;
+				mal-tx-channel = <0 1>;
+				mal-rx-channel = <0>;
+				cell-index = <0>;
+				max-frame-size = <5dc>;
+				rx-fifo-size = <1000>;
+				tx-fifo-size = <800>;
+				phy-mode = "rmii";
+				phy-map = <00000001>;
+				zmii-device = <&ZMII0>;
+				zmii-channel = <0>;
+			};
+			EMAC1: ethernet@140000900 {
+				device_type = "network";
+				compatible = "ibm,emac-440gp", "ibm,emac";
+				interrupt-parent = <&UIC1>;
+				interrupts = <1e 4 1f 4>;
+				reg = <1 40000900 70>;
+				local-mac-address = [0004ace31b1f]; // FIXME
+				mal-device = <&MAL0>;
+				mal-tx-channel = <2 3>;
+				mal-rx-channel = <1>;
+				cell-index = <1>;
+				max-frame-size = <5dc>;
+				rx-fifo-size = <1000>;
+				tx-fifo-size = <800>;
+				phy-mode = "rmii";
+				phy-map = <00000001>;
+				zmii-device = <&ZMII0>;
+				zmii-channel = <1>;
+			};
+
+
+			GPT0: gpt@140000a00 {
+				/* FIXME */
+				reg = <1 40000a00 d4>;
+				interrupt-parent = <&UIC0>;
+				interrupts = <12 4 13 4 14 4 15 4 16 4>;
+			};
+
+		};
+
+		PCIX0: pci@1234 {
+			device_type = "pci";
+			/* FIXME */
+			reg = <2 0ec00000 8
+			       2 0ec80000 f0
+			       2 0ec80100 fc>;
+		};
+
+		MAL0: mcmal {
+			/* FIXME */
+			device_type = "mcmal-dma";
+			compatible = "ibm,mcmal-440gp", "ibm,mcmal";
+			dcr-reg = <180 62>;
+			num-tx-chans = <4>;
+			num-rx-chans = <4>;
+			interrupt-parent = <&MAL0>;
+			interrupts = <0 1 2 3 4>;
+			#interrupt-cells = <1>;
+			#address-cells = <0>;
+			#size-cells = <0>;
+			interrupt-map = </*TXEOB*/ 0 &UIC0 a 4
+					 /*RXEOB*/ 1 &UIC0 b 4
+					 /*SERR*/  2 &UIC1 0 4
+					 /*TXDE*/  3 &UIC1 1 4
+					 /*RXDE*/  4 &UIC1 2 4>;
+			interrupt-map-mask = <ffffffff>;
+		};
+	};
+
+	chosen {
+		linux,stdout-path = "/plb/opb@0/serial@140000200";
+		linux,initrd-start = <0>; /* FIXME */
+		linux,initrd-end = <0>;
+		interrupt-controller = <&UIC0>;
+	};
+};
+

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 11/14] Add arch/powerpc driver for UIC, PPC4xx interrupt controller
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (4 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 5/14] zImage: Add more flexible gunzip convenience functions David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20  2:12 ` [PATCH 7/14] zImage: Cleanup and improve zImage entry point David Gibson
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

This patch adds a driver to arch/powerpc/sysdev for the UIC, the
on-chip interrupt controller from IBM/AMCC 4xx chips.  It uses the new
irq host mapping infrastructure.

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

 arch/powerpc/sysdev/Makefile |    1 
 arch/powerpc/sysdev/uic.c    |  335 +++++++++++++++++++++++++++++++++++++++++++
 include/asm-powerpc/uic.h    |   23 ++
 3 files changed, 359 insertions(+)

Index: working-2.6/arch/powerpc/sysdev/uic.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/arch/powerpc/sysdev/uic.c	2007-02-19 15:13:51.000000000 +1100
@@ -0,0 +1,335 @@
+/*
+ * arch/powerpc/sysdev/uic.c
+ *
+ * IBM PowerPC 4xx Universal Interrupt Controller
+ *
+ * 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 <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/reboot.h>
+#include <linux/slab.h>
+#include <linux/stddef.h>
+#include <linux/sched.h>
+#include <linux/signal.h>
+#include <linux/sysdev.h>
+#include <linux/device.h>
+#include <linux/bootmem.h>
+#include <linux/spinlock.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <asm/irq.h>
+#include <asm/io.h>
+#include <asm/prom.h>
+#include <asm/dcr.h>
+
+#define NR_UIC_INTS	32
+
+#define UIC_SR		0x0
+#define UIC_ER		0x2
+#define UIC_CR		0x3
+#define UIC_PR		0x4
+#define UIC_TR		0x5
+#define UIC_MSR		0x6
+#define UIC_VR		0x7
+#define UIC_VCR		0x8
+
+#define uic_irq_to_hw(virq)	(irq_map[virq].hwirq)
+
+struct uic *primary_uic;
+
+struct uic {
+	int index;
+	int dcrbase;
+
+	spinlock_t lock;
+
+	/* The remapper for this UIC */
+	struct irq_host	*irqhost;
+
+	/* For secondary UICs, the cascade interrupt's irqaction */
+	struct irqaction cascade;
+
+	/* The device node of the interrupt controller */
+	struct device_node *of_node;
+};
+
+static void uic_unmask_irq(unsigned int virq)
+{
+	struct uic *uic = get_irq_chip_data(virq);
+	unsigned int src = uic_irq_to_hw(virq);
+	unsigned long flags;
+	u32 er;
+
+	spin_lock_irqsave(&uic->lock, flags);
+	er = mfdcr(uic->dcrbase + UIC_ER);
+	er |= 1 << (31 - src);
+	mtdcr(uic->dcrbase + UIC_ER, er);
+	spin_unlock_irqrestore(&uic->lock, flags);
+}
+
+static void uic_mask_irq(unsigned int virq)
+{
+	struct uic *uic = get_irq_chip_data(virq);
+	unsigned int src = uic_irq_to_hw(virq);
+	unsigned long flags;
+	u32 er;
+
+	spin_lock_irqsave(&uic->lock, flags);
+	er = mfdcr(uic->dcrbase + UIC_ER);
+	er &= ~(1 << (31 - src));
+	mtdcr(uic->dcrbase + UIC_ER, er);
+	spin_unlock_irqrestore(&uic->lock, flags);
+}
+
+static void uic_ack_irq(unsigned int virq)
+{
+	struct uic *uic = get_irq_chip_data(virq);
+	unsigned int src = uic_irq_to_hw(virq);
+	unsigned long flags;
+
+	spin_lock_irqsave(&uic->lock, flags);
+	mtdcr(uic->dcrbase + UIC_SR, 1 << (31-src));
+	spin_unlock_irqrestore(&uic->lock, flags);
+}
+
+static int uic_set_irq_type(unsigned int virq, unsigned int flow_type)
+{
+	struct uic *uic = get_irq_chip_data(virq);
+	unsigned int src = uic_irq_to_hw(virq);
+	struct irq_desc *desc = get_irq_desc(virq);
+	unsigned long flags;
+	int trigger, polarity;
+	u32 tr, pr, mask;
+
+	switch (flow_type & IRQ_TYPE_SENSE_MASK) {
+	case IRQ_TYPE_NONE:
+		uic_mask_irq(virq);
+		return 0;
+
+	case IRQ_TYPE_EDGE_RISING:
+		trigger = 1; polarity = 1;
+		break;
+	case IRQ_TYPE_EDGE_FALLING:
+		trigger = 1; polarity = 0;
+		break;
+	case IRQ_TYPE_LEVEL_HIGH:
+		trigger = 0; polarity = 1;
+		break;
+	case IRQ_TYPE_LEVEL_LOW:
+		trigger = 0; polarity = 1;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	mask = ~(1 << (31 - src));
+
+	spin_lock_irqsave(&uic->lock, flags);
+	tr = mfdcr(uic->dcrbase + UIC_TR);
+	pr = mfdcr(uic->dcrbase + UIC_PR);
+	tr = (tr & mask) | (trigger << (31-src));
+	pr = (pr & mask) | (polarity << (31-src));
+
+	mtdcr(uic->dcrbase + UIC_PR, pr);
+	mtdcr(uic->dcrbase + UIC_TR, tr);
+
+	desc->status &= ~(IRQ_TYPE_SENSE_MASK | IRQ_LEVEL);
+	desc->status |= flow_type & IRQ_TYPE_SENSE_MASK;
+	if (trigger)
+		desc->status |= IRQ_LEVEL;
+
+	spin_unlock_irqrestore(&uic->lock, flags);
+
+	return 0;
+}
+
+static struct irq_chip uic_irq_chip = {
+	.typename	= " UIC  ",
+	.unmask		= uic_unmask_irq,
+	.mask		= uic_mask_irq,
+/* 	.mask_ack	= uic_mask_irq_and_ack, */
+	.ack		= uic_ack_irq,
+	.set_type	= uic_set_irq_type,
+};
+
+static int uic_host_match(struct irq_host *h, struct device_node *node)
+{
+	struct uic *uic = h->host_data;
+	return uic->of_node == node;
+}
+
+static int uic_host_map(struct irq_host *h, unsigned int virq,
+			irq_hw_number_t hw)
+{
+	struct uic *uic = h->host_data;
+
+	set_irq_chip_data(virq, uic);
+	/* Despite the name, handle_level_irq() works for both level
+	 * and edge irqs on UIC.  FIXME: check this is correct */
+	set_irq_chip_and_handler(virq, &uic_irq_chip, handle_level_irq);
+
+	/* Set default irq type */
+	set_irq_type(virq, IRQ_TYPE_NONE);
+
+	return 0;
+}
+
+static int uic_host_xlate(struct irq_host *h, struct device_node *ct,
+			  u32 *intspec, unsigned int intsize,
+			  irq_hw_number_t *out_hwirq, unsigned int *out_type)
+
+{
+	/* UIC intspecs must have 2 cells */
+	BUG_ON(intsize != 2);
+	*out_hwirq = intspec[0];
+	*out_type = intspec[1];
+	return 0;
+}
+
+static struct irq_host_ops uic_host_ops = {
+	.match	= uic_host_match,
+	.map	= uic_host_map,
+	.xlate	= uic_host_xlate,
+};
+
+irqreturn_t uic_cascade(int virq, void *data)
+{
+	struct uic *uic = data;
+	u32 msr;
+	int src;
+	int subvirq;
+
+	msr = mfdcr(uic->dcrbase + UIC_MSR);
+	src = 32 - ffs(msr);
+
+	subvirq = irq_linear_revmap(uic->irqhost, src);
+	generic_handle_irq(subvirq);
+
+	return IRQ_HANDLED;
+}
+
+void __init uic_init_one(struct device_node *node)
+{
+	struct uic *uic;
+	const u32 *indexp, *dcrreg, *interrupts;
+	int len;
+
+	uic = alloc_bootmem(sizeof(*uic));
+	if (! uic)
+		return; /* FIXME: panic? */
+
+	memset(uic, 0, sizeof(*uic));
+	uic->of_node = of_node_get(node);
+	indexp = get_property(node, "cell-index", &len);
+	if (!indexp || (len != sizeof(u32))) {
+		printk(KERN_ERR "uic: Device node %s has missing or invalid "
+		       "cell-index property\n", node->full_name);
+		return;
+	}
+	uic->index = *indexp;
+
+	dcrreg = get_property(node, "dcr-reg", &len);
+	if (!dcrreg || (len != 2*sizeof(u32))) {
+		printk(KERN_ERR "uic: Device node %s has missing or invalid "
+		       "dcr-reg property\n", node->full_name);
+		return;
+	}
+	uic->dcrbase = *dcrreg;
+
+	uic->irqhost = irq_alloc_host(IRQ_HOST_MAP_LINEAR, NR_UIC_INTS,
+				      &uic_host_ops, -1);
+	if (! uic->irqhost) {
+		of_node_put(node);
+		return; /* FIXME: panic? */
+	}
+
+	uic->irqhost->host_data = uic;
+
+	/* Start with all interrupts disable and non-critical */
+	mtdcr(uic->dcrbase + UIC_ER, 0);
+	mtdcr(uic->dcrbase + UIC_CR, 0);
+
+	printk ("UIC%d (%d IRQ sources) at DCR 0x%x\n", uic->index,
+		NR_UIC_INTS, uic->dcrbase);
+
+	interrupts = get_property(node, "interrupts", &len);
+
+	if (! interrupts) {
+		/* This is the top level controller */
+		primary_uic = uic;
+		irq_set_default_host(primary_uic->irqhost);
+		return;
+	} else {
+		/* Secondary UIC */
+		int cascade_virq;
+		int ret;
+
+		cascade_virq = irq_of_parse_and_map(node, 0);
+
+		uic->cascade.handler = uic_cascade;
+		uic->cascade.name = "UIC cascade";
+		uic->cascade.dev_id = uic;
+
+		ret = setup_irq(cascade_virq, &uic->cascade);
+		if (ret)
+			printk(KERN_ERR "Failed to setup_irq(%d) for "
+			       "UIC%d cascade\n", cascade_virq, uic->index);
+
+		/* FIXME: setup critical cascade?? */
+	}
+}
+
+void __init uic_init_tree(void)
+{
+	const phandle *ic_phandle;
+	struct device_node *top, *sub, *prev;
+	int len;
+
+	ic_phandle = get_property(of_chosen, "interrupt-controller", &len);
+	if (!ic_phandle || (len != sizeof(*ic_phandle))) {
+		printk(KERN_CRIT "uic: Couldn't find interrupt-controller property "
+		       "in /chosen\n");
+		return;
+	}
+
+	top = of_find_node_by_phandle(*ic_phandle);
+	if (! top) {
+		printk(KERN_CRIT "uic: Couldn't find top-level UIC, phandle=%x\n",
+		       *ic_phandle);
+	}
+
+	uic_init_one(top);
+
+	prev = NULL;
+	while ((sub = of_get_next_child(top, prev)) != NULL) {
+		if (prev)
+			of_node_put(prev);
+
+		uic_init_one(sub);
+
+		prev = sub;
+	}
+
+	of_node_put(top);
+}
+
+/* Return an interrupt vector or NO_IRQ if no interrupt is pending. */
+unsigned int uic_get_irq(void)
+{
+	u32 msr;
+	int src;
+
+	BUG_ON(primary_uic == NULL);
+
+	msr = mfdcr(primary_uic->dcrbase + UIC_MSR);
+	src = 32 - ffs(msr);
+
+	return irq_linear_revmap(primary_uic->irqhost, src);
+}
Index: working-2.6/arch/powerpc/sysdev/Makefile
===================================================================
--- working-2.6.orig/arch/powerpc/sysdev/Makefile	2007-02-19 11:05:31.000000000 +1100
+++ working-2.6/arch/powerpc/sysdev/Makefile	2007-02-19 14:01:53.000000000 +1100
@@ -17,6 +17,7 @@ obj-$(CONFIG_QUICC_ENGINE)	+= qe_lib/
 ifeq ($(CONFIG_PPC_MERGE),y)
 obj-$(CONFIG_PPC_I8259)		+= i8259.o
 obj-$(CONFIG_PPC_83xx)		+= ipic.o
+obj-$(CONFIG_4xx)		+= uic.o
 endif
 
 # Temporary hack until we have migrated to asm-powerpc
Index: working-2.6/include/asm-powerpc/uic.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/include/asm-powerpc/uic.h	2007-02-19 14:01:53.000000000 +1100
@@ -0,0 +1,23 @@
+/*
+ * include/asm-powerpc/uic.h
+ *
+ * IBM PPC4xx UIC external definitions and structure.
+ *
+ * Maintainer: David Gibson <dwg@au1.ibm.com>
+ * Copyright 2007 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.
+ */
+#ifndef _ASM_POWERPC_UIC_H
+#define _ASM_POWERPC_UIC_H
+
+#ifdef __KERNEL__
+
+extern void __init uic_init_tree(void);
+extern unsigned int uic_get_irq(void);
+
+#endif /* __KERNEL__ */
+#endif /* _ASM_POWERPC_UIC_H */

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 13/14] Re-organize Kconfig code for 4xx in arch/powerpc
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (11 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 10/14] Early serial debug support for PPC44x David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20 13:51   ` Josh Boyer
  2007-02-20  2:12 ` [PATCH 14/14] Support for Ebony " David Gibson
  2007-02-20 14:05 ` [0/14] Ebony support, 2nd spin Josh Boyer
  14 siblings, 1 reply; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

Now that we always take a device tree in arch/powerpc, there's no good
reason not to allow a single kernel to support multiple embedded 4xx
boards - the correct platform code can be selected based on the device
tree information.

Therefore, this patch re-arranges the 4xx Kconfig code to allow this.
In addition we:
	- use "select" instead of depends to configure the correct
	  config options for specific 4xx CPUs and workarounds, which
	  makes the information about specific boards and CPUs less
	  scattered.
	- Some old, unused (in arch/powerpc) config options are
	  removed: WANT_EARLY_SERIAL, IBM_OCP, etc.

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

 arch/powerpc/platforms/4xx/Kconfig |  377 +++++++++++++++----------------------
 1 file changed, 153 insertions(+), 224 deletions(-)

Index: working-2.6/arch/powerpc/platforms/4xx/Kconfig
===================================================================
--- working-2.6.orig/arch/powerpc/platforms/4xx/Kconfig	2007-02-19 13:28:06.000000000 +1100
+++ working-2.6/arch/powerpc/platforms/4xx/Kconfig	2007-02-19 13:38:05.000000000 +1100
@@ -3,278 +3,207 @@ config 4xx
 	depends on 40x || 44x
 	default y
 
-config WANT_EARLY_SERIAL
+config BOOKE
 	bool
-	select SERIAL_8250
-	default n
-
-menu "AMCC 4xx options"
-	depends on 4xx
-
-choice
-	prompt "Machine Type"
-	depends on 40x
-	default WALNUT
-
-config BUBINGA
-	bool "Bubinga"
-	select WANT_EARLY_SERIAL
-	help
-	  This option enables support for the IBM 405EP evaluation board.
-
-config CPCI405
-	bool "CPCI405"
-	help
-	  This option enables support for the CPCI405 board.
-
-config EP405
-	bool "EP405/EP405PC"
-	help
-	  This option enables support for the EP405/EP405PC boards.
-
-config REDWOOD_5
-	bool "Redwood-5"
-	help
-	  This option enables support for the IBM STB04 evaluation board.
-
-config REDWOOD_6
-	bool "Redwood-6"
-	help
-	  This option enables support for the IBM STBx25xx evaluation board.
-
-config SYCAMORE
-	bool "Sycamore"
-	help
-	  This option enables support for the IBM PPC405GPr evaluation board.
-
-config WALNUT
-	bool "Walnut"
-	help
-	  This option enables support for the IBM PPC405GP evaluation board.
-
-config XILINX_ML300
-	bool "Xilinx-ML300"
-	help
-	  This option enables support for the Xilinx ML300 evaluation board.
-
-endchoice
-
-choice
-	prompt "Machine Type"
 	depends on 44x
-	default EBONY
-
-config BAMBOO
-	bool "Bamboo"
-	select WANT_EARLY_SERIAL
-	help
-	  This option enables support for the IBM PPC440EP evaluation board.
-
-config EBONY
-	bool "Ebony"
-	select WANT_EARLY_SERIAL
-	help
-	  This option enables support for the IBM PPC440GP evaluation board.
-
-config LUAN
-	bool "Luan"
-	select WANT_EARLY_SERIAL
-	help
-	  This option enables support for the IBM PPC440SP evaluation board.
-
-config OCOTEA
-	bool "Ocotea"
-	select WANT_EARLY_SERIAL
-	help
-	  This option enables support for the IBM PPC440GX evaluation board.
+	default y
 
-endchoice
+menu "AMCC 40x options"
+	depends on 40x
 
-config EP405PC
-	bool "EP405PC Support"
-	depends on EP405
+#config BUBINGA
+#	bool "Bubinga"
+#	depends on 40x
+#	default n
+#	select 405EP
+#	help
+#	  This option enables support for the IBM 405EP evaluation board.
+
+#config CPCI405
+#	bool "CPCI405"
+#	depends on 40x
+#	default n
+#	select 405GP
+#	help
+#	  This option enables support for the CPCI405 board.
+
+#config EP405
+#	bool "EP405/EP405PC"
+#	depends on 40x
+#	default n
+#	select 405GP
+#	help
+#	  This option enables support for the EP405/EP405PC boards.
+
+#config EP405PC
+#	bool "EP405PC Support"
+#	depends on EP405
+#	default y
+#	help
+#	  This option enables support for the extra features of the EP405PC board.
+
+#config REDWOOD_5
+#	bool "Redwood-5"
+#	depends on 40x
+#	default n
+#	select STB03xxx
+#	help
+#	  This option enables support for the IBM STB04 evaluation board.
+
+#config REDWOOD_6
+#	bool "Redwood-6"
+#	depends on 40x
+#	default n
+#	select STB03xxx
+#	help
+#	  This option enables support for the IBM STBx25xx evaluation board.
+
+#config SYCAMORE
+#	bool "Sycamore"
+#	depends on 40x
+#	default n
+#	select 405GPR
+#	help
+#	  This option enables support for the IBM PPC405GPr evaluation board.
+
+#config WALNUT
+#	bool "Walnut"
+#	depends on 40x
+#	default y
+#	select 405GP
+#	help
+#	  This option enables support for the IBM PPC405GP evaluation board.
+
+#config XILINX_ML300
+#	bool "Xilinx-ML300"
+#	depends on 40x
+#	default y
+#	select VIRTEX_II_PRO
+#	help
+#	  This option enables support for the Xilinx ML300 evaluation board.
 
+endmenu
 
-# It's often necessary to know the specific 4xx processor type.
-# Fortunately, it is impled (so far) from the board type, so we
-# don't need to ask more redundant questions.
+# 40x specific CPU modules, selected based on the board above.
 config NP405H
 	bool
-	depends on ASH
+	#depends on ASH
 	default y
 
-config 440EP
+# OAK doesn't exist but wanted to keep this around for any future 403GCX boards
+config 403GCX
 	bool
-	depends on BAMBOO
-	select PPC_FPU
-	default y
+	#depends on OAK
+	select IBM405_ERR51
 
-config 440GP
+config 405GP
 	bool
-	depends on EBONY
-	default y
+	select IBM405_ERR77
+	select IBM405_ERR51
 
-config 440GX
+config 405EP
 	bool
-	depends on OCOTEA
-	default y
 
-config 440SP
+config 405GPR
 	bool
-	depends on LUAN
-	default y
 
-config 440
+config VIRTEX_II_PRO
 	bool
-	depends on 440GP || 440SP || 440EP
-	default y
+	select IBM405_ERR77
+	select IBM405_ERR51
 
-config 440A
+config STB03xxx
 	bool
-	depends on 440GX
-	default y
+	select IBM405_ERR77
+	select IBM405_ERR51
 
-config IBM440EP_ERR42
-	bool
-	depends on 440EP
-	default y
+# 40x errata/workaround config symbols, selected by the CPU models above
 
 # All 405-based cores up until the 405GPR and 405EP have this errata.
 config IBM405_ERR77
 	bool
-	depends on 40x && !403GCX && !405GPR && !405EP
-	default y
 
 # All 40x-based cores, up until the 405GPR and 405EP have this errata.
 config IBM405_ERR51
 	bool
-	depends on 40x && !405GPR && !405EP
-	default y
 
-config BOOKE
-	bool
+menu "AMCC 44x options"
 	depends on 44x
-	default y
-
-config IBM_OCP
-	bool
-	depends on ASH || BAMBOO || BUBINGA || CPCI405 || EBONY || EP405 || LUAN || OCOTEA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT
-	default y
 
-config XILINX_OCP
-	bool
-	depends on XILINX_ML300
-	default y
-
-config IBM_EMAC4
-	bool
-	depends on 440GX || 440SP
-	default y
-
-config BIOS_FIXUP
-	bool
-	depends on BUBINGA || EP405 || SYCAMORE || WALNUT
-	default y
-
-# OAK doesn't exist but wanted to keep this around for any future 403GCX boards
-config 403GCX
-	bool
-	depends on OAK
-	default y
-
-config 405EP
-	bool
-	depends on BUBINGA
-	default y
+#config BAMBOO
+#	bool "Bamboo"
+#	depends on 44x
+#	default n
+#	select 440EP
+#	help
+#	  This option enables support for the IBM PPC440EP evaluation board.
 
-config 405GP
-	bool
-	depends on CPCI405 || EP405 || WALNUT
-	default y
-
-config 405GPR
-	bool
-	depends on SYCAMORE
-	default y
-
-config VIRTEX_II_PRO
-	bool
-	depends on XILINX_ML300
-	default y
-
-config STB03xxx
-	bool
-	depends on REDWOOD_5 || REDWOOD_6
-	default y
-
-config EMBEDDEDBOOT
-	bool
-	depends on EP405 || XILINX_ML300
+config EBONY
+	bool "Ebony"
+	depends on 44x
 	default y
+	select 440GP
+	help
+	  This option enables support for the IBM PPC440GP evaluation board.
 
-config IBM_OPENBIOS
-	bool
-	depends on ASH || BUBINGA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT
-	default y
+#config LUAN
+#	bool "Luan"
+#	depends on 44x
+#	default n
+#	select 440SP
+#	help
+#	  This option enables support for the IBM PPC440SP evaluation board.
+
+#config OCOTEA
+#	bool "Ocotea"
+#	depends on 44x
+#	default n
+#	select 440GX
+#	help
+#	  This option enables support for the IBM PPC440GX evaluation board.
 
-config PPC4xx_DMA
-	bool "PPC4xx DMA controller support"
-	depends on 4xx
+endmenu
 
-config PPC4xx_EDMA
+# 44x specific CPU modules, selected based on the board above.
+config 440EP
 	bool
-	depends on !STB03xxx && PPC4xx_DMA
-	default y
+	select PPC_FPU
+	select IBM440EP_ERR42
 
-config PPC_GEN550
+config 440GP
 	bool
-	depends on 4xx
-	default y
-
-choice
-	prompt "TTYS0 device and default console"
-	depends on 40x
-	default UART0_TTYS0
-
-config UART0_TTYS0
-	bool "UART0"
-
-config UART0_TTYS1
-	bool "UART1"
+	select IBM_NEW_EMAC_ZMII
 
-endchoice
-
-config SERIAL_SICC
-	bool "SICC Serial port support"
-	depends on STB03xxx
-
-config UART1_DFLT_CONSOLE
+config 440GX
 	bool
-	depends on SERIAL_SICC && UART0_TTYS1
-	default y
 
-config SERIAL_SICC_CONSOLE
+config 440SP
 	bool
-	depends on SERIAL_SICC && UART0_TTYS1
-	default y
-endmenu
-
 
-menu "IBM 40x options"
-	depends on 40x
-
-config SERIAL_SICC
-	bool "SICC Serial port"
-	depends on STB03xxx
-
-config UART1_DFLT_CONSOLE
+config 440A
 	bool
-	depends on SERIAL_SICC && UART0_TTYS1
+	depends on 440GX
 	default y
 
-config SERIAL_SICC_CONSOLE
+# 44x errata/workaround config symbols, selected by the CPU models above
+config IBM440EP_ERR42
 	bool
-	depends on SERIAL_SICC && UART0_TTYS1
-	default y
 
-endmenu
+#config XILINX_OCP
+#	bool
+#	depends on XILINX_ML300
+#	default y
+
+#config BIOS_FIXUP
+#	bool
+#	depends on BUBINGA || EP405 || SYCAMORE || WALNUT
+#	default y
+
+#config PPC4xx_DMA
+#	bool "PPC4xx DMA controller support"
+#	depends on 4xx
+
+#config PPC4xx_EDMA
+#	bool
+#	depends on !STB03xxx && PPC4xx_DMA
+#	default y

^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 14/14] Support for Ebony in arch/powerpc
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (12 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 13/14] Re-organize Kconfig code for 4xx in arch/powerpc David Gibson
@ 2007-02-20  2:12 ` David Gibson
  2007-02-20 14:05 ` [0/14] Ebony support, 2nd spin Josh Boyer
  14 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-20  2:12 UTC (permalink / raw)
  To: linuxppc-dev

This patch adds platform support code for the Ebony (440GP) evaluation
board.

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

 arch/powerpc/platforms/4xx/Makefile |    2 -
 arch/powerpc/platforms/4xx/ebony.c  |   69 ++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 1 deletion(-)

Index: working-2.6/arch/powerpc/platforms/4xx/Makefile
===================================================================
--- working-2.6.orig/arch/powerpc/platforms/4xx/Makefile	2006-12-08 10:42:48.000000000 +1100
+++ working-2.6/arch/powerpc/platforms/4xx/Makefile	2007-02-20 10:50:16.000000000 +1100
@@ -1 +1 @@
-# empty makefile so make clean works
\ No newline at end of file
+obj-$(CONFIG_EBONY)	:= ebony.o
Index: working-2.6/arch/powerpc/platforms/4xx/ebony.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ working-2.6/arch/powerpc/platforms/4xx/ebony.c	2007-02-20 11:07:31.000000000 +1100
@@ -0,0 +1,69 @@
+/*
+ * Ebony board specific routines
+ *
+ * Matt Porter <mporter@kernel.crashing.org>
+ * Copyright 2002-2005 MontaVista Software Inc.
+ *
+ * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
+ * Copyright (c) 2003-2005 Zultys Technologies
+ *
+ * Rewritten and ported to the merged powerpc tree:
+ * 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 <linux/init.h>
+#include <asm/machdep.h>
+#include <asm/prom.h>
+#include <asm/udbg.h>
+#include <asm/time.h>
+#include <asm/uic.h>
+#include <asm/of_platform.h>
+
+static struct of_device_id ebony_of_bus[] = {
+	{ .type = "ibm,plb", },
+	{ .type = "ibm,opb", },
+	{},
+};
+
+static int __init ebony_device_probe(void)
+{
+	if (! machine_is(ebony))
+		return 0;
+
+	of_platform_bus_probe(NULL, ebony_of_bus, NULL);
+
+	return 0;
+}
+device_initcall(ebony_device_probe);
+
+/*
+ * Called very early, MMU is off, device-tree isn't unflattened
+ */
+static int __init ebony_probe(void)
+{
+	unsigned long root = of_get_flat_dt_root();
+
+	if (!of_flat_dt_is_compatible(root, "Ebony"))
+		return 0;
+
+	return 1;
+}
+
+static void __init ebony_setup_arch(void)
+{
+}
+
+define_machine(ebony) {
+	.name			= "Ebony",
+	.probe			= ebony_probe,
+	.setup_arch		= ebony_setup_arch,
+	.progress		= udbg_progress,
+	.init_IRQ		= uic_init_tree,
+	.get_irq		= uic_get_irq,
+	.calibrate_decr		= generic_calibrate_decr,
+};

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 10/14] Early serial debug support for PPC44x
  2007-02-20  2:12 ` [PATCH 10/14] Early serial debug support for PPC44x David Gibson
@ 2007-02-20 13:26   ` Segher Boessenkool
  2007-02-21  0:20     ` David Gibson
  0 siblings, 1 reply; 50+ messages in thread
From: Segher Boessenkool @ 2007-02-20 13:26 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

> +config PPC_EARLY_DEBUG_44x
> +	bool "Early serial debugging for IBM 44x CPUs"

Change this to IBM/AMCC 44x, like the patch description
says?


Segher

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 13/14] Re-organize Kconfig code for 4xx in arch/powerpc
  2007-02-20  2:12 ` [PATCH 13/14] Re-organize Kconfig code for 4xx in arch/powerpc David Gibson
@ 2007-02-20 13:51   ` Josh Boyer
  2007-02-21  0:26     ` David Gibson
  0 siblings, 1 reply; 50+ messages in thread
From: Josh Boyer @ 2007-02-20 13:51 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

On Tue, 2007-02-20 at 13:12 +1100, David Gibson wrote:
> 
> -# It's often necessary to know the specific 4xx processor type.
> -# Fortunately, it is impled (so far) from the board type, so we
> -# don't need to ask more redundant questions.
> +# 40x specific CPU modules, selected based on the board above.
>  config NP405H
>  	bool
> -	depends on ASH
> +	#depends on ASH
>  	default y

This always turns this option on, even for Ebony builds.  Should
probably comment out the 'default y' for now as well.

josh

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spin
  2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
                   ` (13 preceding siblings ...)
  2007-02-20  2:12 ` [PATCH 14/14] Support for Ebony " David Gibson
@ 2007-02-20 14:05 ` Josh Boyer
  2007-02-20 14:14   ` Josh Boyer
  2007-02-20 14:16   ` Arnd Bergmann
  14 siblings, 2 replies; 50+ messages in thread
From: Josh Boyer @ 2007-02-20 14:05 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

On Tue, 2007-02-20 at 13:08 +1100, David Gibson wrote:

> 	- The early serial hacks no longer use an entire 64-bit
> 	  constant, so should work on non-64-bit aware assemblers

Yes, this compiles now with my toolchain.  However, I get no output
after this:

Linux/PowerPC load:                                                             
Finalizing device tree... flat tree at 0x408568                                 
id mach(): done                                                                 
MMU:enter                                                                       
MMU:hw init                                                                     
MMU:mapin                                                                       
MMU:setio                                                                       
MMU:exit                                                                        
[    0.000000] Using Ebony machine description                                  
[    0.000000] Linux version 2.6.20-gc9ce2283-dirty (jwboyer@zod.rchland.ibm.co7
setup_arch: bootmem                                                             
arch: exit                                                                      
[    0.000000] Zone PFN ranges:                                                 
[    0.000000]   DMA             0 ->    32768                                  
[    0.000000]   Normal      32768 ->    32768                                  
[    0.000000] early_node_map[1] active PFN ranges                              
[    0.000000]     0:        0 ->    32768                                      
[    0.000000] Built 1 zonelists.  Total pages: 32512                           
[    0.000000] Kernel command line: ip=on                                       
[    0.000000] UIC0 (32 IRQ sources) at DCR 0xc0                                
[    0.000000] UIC1 (32 IRQ sources) at DCR 0xd0                                
[    0.000000] PID hash table entries: 512 (order: 9, 2048 bytes)               

Which probably has something to do with the of_serial driver being used
now.  Just an FYI.

josh

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spin
  2007-02-20 14:05 ` [0/14] Ebony support, 2nd spin Josh Boyer
@ 2007-02-20 14:14   ` Josh Boyer
  2007-02-20 14:16   ` Arnd Bergmann
  1 sibling, 0 replies; 50+ messages in thread
From: Josh Boyer @ 2007-02-20 14:14 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

On Tue, 2007-02-20 at 08:05 -0600, Josh Boyer wrote:
> On Tue, 2007-02-20 at 13:08 +1100, David Gibson wrote:
> 
> > 	- The early serial hacks no longer use an entire 64-bit
> > 	  constant, so should work on non-64-bit aware assemblers
> 
> Yes, this compiles now with my toolchain.  However, I get no output
> after this:

Ignore this part.  It would have helped if I actually turned the config
option for the of_serial driver on.

josh

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spin
  2007-02-20 14:05 ` [0/14] Ebony support, 2nd spin Josh Boyer
  2007-02-20 14:14   ` Josh Boyer
@ 2007-02-20 14:16   ` Arnd Bergmann
  2007-02-20 14:46     ` Josh Boyer
  2007-02-21  0:35     ` David Gibson
  1 sibling, 2 replies; 50+ messages in thread
From: Arnd Bergmann @ 2007-02-20 14:16 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: David Gibson

On Tuesday 20 February 2007 15:05, Josh Boyer wrote:
> Which probably has something to do with the of_serial driver being used
> now. =A0Just an FYI.

If you want to use of_serial together with serial console, you need
to make sure that the detection logic in arch/powerpc/kernel/legacy_serial.c
finds the port. It currently finds the serial port on axon, but that
requires that the bus it's on is of type "opb" and the device itself
is listed as "stdout" and has type "serial" and is compatible with
"ns16750" (note: the others look for "ns16550" here).

	Arnd <><

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 4/14] Use resource_size_t for serial port IO addresses
  2007-02-20  2:12 ` [PATCH 4/14] Use resource_size_t for serial port IO addresses David Gibson
@ 2007-02-20 14:44   ` Sergei Shtylyov
  2007-02-21  0:19     ` David Gibson
  0 siblings, 1 reply; 50+ messages in thread
From: Sergei Shtylyov @ 2007-02-20 14:44 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

Hello.

David Gibson wrote:
> At present, various parts of the serial code use unsigned long to
> define resource addresses.  This is a problem, because some 32-bit
> platforms have physical addresses larger than 32-bits, and have mmio
> serial uarts located above the 4GB point.
> 
> This patch changes the type of mapbase in both struct uart_port and
> struct plat_serial8250_port to resource_size_t, which can be
> configured to be 64 bits on such platforms.  The mapbase in
> serial_struct can't safely be changed, because that structure is user
> visible.

    Erm, isn't linux-serial@vger.kernel.org more proper list for such patches?
Also, as serial drivers are now unmaintained, this probably needs to go to -mm 
tree.

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

> Index: working-2.6/drivers/serial/serial_core.c
> ===================================================================
> --- working-2.6.orig/drivers/serial/serial_core.c	2007-02-19 11:07:42.000000000 +1100
> +++ working-2.6/drivers/serial/serial_core.c	2007-02-19 11:07:43.000000000 +1100
> @@ -633,7 +633,7 @@ static int uart_get_info(struct uart_sta
>  	tmp.hub6	    = port->hub6;
>  	tmp.io_type         = port->iotype;
>  	tmp.iomem_reg_shift = port->regshift;
> -	tmp.iomem_base      = (void *)port->mapbase;
> +	tmp.iomem_base      = (void *)(unsigned long)port->mapbase;

    For 32-bit kernels this may result in a meaningless address. Have you 
considered also changing iomem_base's type?

MBR, Sergei

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spin
  2007-02-20 14:16   ` Arnd Bergmann
@ 2007-02-20 14:46     ` Josh Boyer
  2007-02-20 15:03       ` Josh Boyer
  2007-02-21  0:35     ` David Gibson
  1 sibling, 1 reply; 50+ messages in thread
From: Josh Boyer @ 2007-02-20 14:46 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev, David Gibson

On Tue, 2007-02-20 at 15:16 +0100, Arnd Bergmann wrote:
> On Tuesday 20 February 2007 15:05, Josh Boyer wrote:
> > Which probably has something to do with the of_serial driver being used
> > now.  Just an FYI.
> 
> If you want to use of_serial together with serial console, you need
> to make sure that the detection logic in arch/powerpc/kernel/legacy_serial.c
> finds the port. It currently finds the serial port on axon, but that
> requires that the bus it's on is of type "opb" and the device itself
> is listed as "stdout" and has type "serial" and is compatible with
> "ns16750" (note: the others look for "ns16550" here).

The ebony dts has the ports as ns16550.  That is required for the
bootwrapper to find the port to use for it's output at the moment.

josh

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spin
  2007-02-20 14:46     ` Josh Boyer
@ 2007-02-20 15:03       ` Josh Boyer
  2007-02-20 15:07         ` [0/14] Ebony support, 2nd spi Arnd Bergmann
                           ` (2 more replies)
  0 siblings, 3 replies; 50+ messages in thread
From: Josh Boyer @ 2007-02-20 15:03 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev, David Gibson

On Tue, 2007-02-20 at 08:46 -0600, Josh Boyer wrote:
> On Tue, 2007-02-20 at 15:16 +0100, Arnd Bergmann wrote:
> > On Tuesday 20 February 2007 15:05, Josh Boyer wrote:
> > > Which probably has something to do with the of_serial driver being used
> > > now.  Just an FYI.
> > 
> > If you want to use of_serial together with serial console, you need
> > to make sure that the detection logic in arch/powerpc/kernel/legacy_serial.c
> > finds the port. It currently finds the serial port on axon, but that
> > requires that the bus it's on is of type "opb" and the device itself
> > is listed as "stdout" and has type "serial" and is compatible with
> > "ns16750" (note: the others look for "ns16550" here).
> 
> The ebony dts has the ports as ns16550.  That is required for the
> bootwrapper to find the port to use for it's output at the moment.

And the ebony dts also has the a bus type of "ibm,opb" as well.

I hacked legacy_serial.c to look for ns16550 compatible devices with a
parent OPB node of type "ibm,opb" and I got serial output on the Ebony
board even with of_serial turned off.

We should look for both "ns16550" and "ns16750" compatible devices in
legacy_serial.c.  As for the bus type, we could look for both types or
the ebony.dts could change to use "opb" instead of "ibm,opb".

josh

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spi
  2007-02-20 15:03       ` Josh Boyer
@ 2007-02-20 15:07         ` Arnd Bergmann
  2007-02-20 15:17           ` Josh Boyer
                             ` (2 more replies)
  2007-02-20 15:11         ` [0/14] Ebony support, 2nd spin Segher Boessenkool
  2007-02-21  0:33         ` David Gibson
  2 siblings, 3 replies; 50+ messages in thread
From: Arnd Bergmann @ 2007-02-20 15:07 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, Christian Rund, Hartmut Penner, David Gibson

On Tuesday 20 February 2007 16:03, Josh Boyer wrote:
> And the ebony dts also has the a bus type of "ibm,opb" as well.

We should really get a common name for these. I don't remember
what the discussions were, but it seems we came up with different
results for Axon and ppc4xx, which is very bad.

Using type "ibm,opb" rather than just "opb" makes sense to me,
but I don't know if we already have shipping systems that use
"opb" here.

There is probably a similar problem with the nodes for "plb4",
"plb5" and "ebc", as well as the "compatible" property of the
serial port, which, as you noted earlier is "ns16550" on 
ebony and "ns16750" on axon, although it is exactly the same
macro.

	Arnd <><

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 12/14] Add device tree for Ebony
  2007-02-20  2:12 ` [PATCH 12/14] Add device tree for Ebony David Gibson
@ 2007-02-20 15:09   ` Josh Boyer
  2007-02-21  0:24     ` David Gibson
  2007-02-20 19:22   ` Yoder Stuart-B08248
  1 sibling, 1 reply; 50+ messages in thread
From: Josh Boyer @ 2007-02-20 15:09 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

On Tue, 2007-02-20 at 13:12 +1100, David Gibson wrote:
> Add a device tree for the Ebony evaluation board (440GP based).  This
> tree is not complete or finalized.  This tree needs a very recent
> version of dtc to process.
> 
> Signed-off-by: David Gibson <dwg@au1.ibm.com>
> ---
> 
>  arch/powerpc/boot/dts/ebony.dts |  225 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 225 insertions(+)
> 
> Index: working-2.6/arch/powerpc/boot/dts/ebony.dts
> ===================================================================
> --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> +++ working-2.6/arch/powerpc/boot/dts/ebony.dts	2007-02-19 15:31:36.000000000 +1100
> @@ -0,0 +1,225 @@
> +/*
> + * Device Tree Source for IBM Ebony
> + *
> + * Copyright (c) 2006, 2007 IBM Corp.
> + * Josh Boyer <jdub@us.ibm.com>, David Gibson <dwg@au1.ibm.com>

That email address died about 2 weeks ago.  Feel free to change it to
this one: jwboyer@linux.vnet.ibm.com

> + *
> + * FIXME: Draft only!
> + *
> + * This file is licensed under the terms of the GNU General Public
> + * License version 2.  This program is licensed "as is" without
> + * any warranty of any kind, whether express or implied.
> + *
> + * To build:
> + *   dtc -I dts -O asm -o ebony.S -b 0 -V 16 ebony.dts
> + *   dtc -I dts -O dtb -o ebony.dtb -b 0 -V 16 ebony.dts
> + */
> +
> +/ {
> +	#address-cells = <2>;
> +	#size-cells = <1>;
> +	model = "Ebony";
> +	compatible = "Ebony";
> +	dcr-parent = <&/cpus/PowerPC,440GP@0>;
> +
> +	cpus {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +
> +		PowerPC,440GP@0 {
> +			model = "440GP Rev. C";
> +			device_type = "cpu";
> +			reg = <0>;
> +			clock-frequency = <17d78400>; /* 400MHz FIXME: poke in zImage */
> +			timebase-frequency = <17d78400>; /* 400MHz FIXME: wrong, poke in zImage */
> +			i-cache-line-size = <32>;
> +			d-cache-line-size = <32>;
> +			i-cache-size = <0>;
> +			d-cache-size = <0>;
> +			dcr-controller;
> +			dcr-access-method = "native";
> +		};
> +	};
> +
> +	memory {
> +		device_type = "memory";
> +		reg = <0 00000000 08000000>; /* Set by bootwrapper */
> +	};
> +
> +	UIC0: interrupt-controller { /* UIC0 */
> +		device_type = "interrupt-controller";
> +		compatible = "ibm,uic440gp", "ibm,uic";
> +		interrupt-controller;
> +		cell-index = <0>;
> +		dcr-reg = <0c0 009>;
> +		#address-cells = <0>;
> +		#size-cells = <0>;
> +		#interrupt-cells = <2>;
> +
> +		UIC1: interrupt-controller@1 { /* UIC1 */
> +			device_type = "interrupt-controller";
> +			compatible = "ibm,uic440gp", "ibm,uic";
> +			interrupt-controller;
> +			cell-index = <1>;
> +			dcr-reg = <0d0 009>;
> +			#address-cells = <0>;
> +			#size-cells = <0>;
> +			#interrupt-cells = <2>;
> +			interrupts = <1e 4 1f 4>; /* cascade */
> +		};
> +	};
> +
> +	plb {
> +		device_type = "ibm,plb";
> +		compatible = "ibm,plb-440gp", "ibm,plb4";
> +		#address-cells = <2>;
> +		#size-cells = <1>;
> +		ranges;
> +
> +		POB0: opb@0 {

I think you meant "OPB0:" for the label.

> +			device_type = "ibm,opb";
> +			compatible = "ibm,opb-440gp", "ibm,opb";

As I pointed out in an earlier email, this breaks working with the
current legacy_serial driver.  It's looking for a device_type of "opb".
I'm not sure if we should fix the driver or fix this and the
ebony_of_bus types in arch/powerpc/platforms/4xx/ebony.c

josh

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spin
  2007-02-20 15:03       ` Josh Boyer
  2007-02-20 15:07         ` [0/14] Ebony support, 2nd spi Arnd Bergmann
@ 2007-02-20 15:11         ` Segher Boessenkool
  2007-02-21  0:33         ` David Gibson
  2 siblings, 0 replies; 50+ messages in thread
From: Segher Boessenkool @ 2007-02-20 15:11 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, Arnd Bergmann, David Gibson

> We should look for both "ns16550" and "ns16750" compatible devices in
> legacy_serial.c.

And 16450 and 8250.

> As for the bus type, we could look for both types or
> the ebony.dts could change to use "opb" instead of "ibm,opb".

The "IBM," name is OF best practice so please keep it.


Segher

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spi
  2007-02-20 15:07         ` [0/14] Ebony support, 2nd spi Arnd Bergmann
@ 2007-02-20 15:17           ` Josh Boyer
  2007-02-20 15:25           ` Segher Boessenkool
  2007-02-21  0:44           ` David Gibson
  2 siblings, 0 replies; 50+ messages in thread
From: Josh Boyer @ 2007-02-20 15:17 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev, Christian Rund, Hartmut Penner, David Gibson

On Tue, 2007-02-20 at 16:07 +0100, Arnd Bergmann wrote:
> On Tuesday 20 February 2007 16:03, Josh Boyer wrote:
> > And the ebony dts also has the a bus type of "ibm,opb" as well.
> 
> We should really get a common name for these. I don't remember
> what the discussions were, but it seems we came up with different
> results for Axon and ppc4xx, which is very bad.

Yes, using common types would be a very good idea. There's no published
DTS for Axon so we have no idea what has been previously defined.

> Using type "ibm,opb" rather than just "opb" makes sense to me,
> but I don't know if we already have shipping systems that use
> "opb" here.

I would prefer "ibm,xxx" as well if it's possible.

> There is probably a similar problem with the nodes for "plb4",
> "plb5" and "ebc", as well as the "compatible" property of the
> serial port, which, as you noted earlier is "ns16550" on 
> ebony and "ns16750" on axon, although it is exactly the same
> macro.

Right, ebony is currently using "ibm,plb".  We haven't defined an EBC
node yet for 4xx.

josh

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spi
  2007-02-20 15:07         ` [0/14] Ebony support, 2nd spi Arnd Bergmann
  2007-02-20 15:17           ` Josh Boyer
@ 2007-02-20 15:25           ` Segher Boessenkool
  2007-02-20 18:02             ` Arnd Bergmann
  2007-02-21  0:44           ` David Gibson
  2 siblings, 1 reply; 50+ messages in thread
From: Segher Boessenkool @ 2007-02-20 15:25 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev, Christian Rund, Hartmut Penner, David Gibson

>> And the ebony dts also has the a bus type of "ibm,opb" as well.
>
> We should really get a common name for these. I don't remember
> what the discussions were, but it seems we came up with different
> results for Axon and ppc4xx, which is very bad.

"Very bad"...  Well sure it's less than desirable, but
we have to deal with this problem anyway already.

> Using type "ibm,opb" rather than just "opb" makes sense to me,
> but I don't know if we already have shipping systems that use
> "opb" here.
>
> There is probably a similar problem with the nodes for "plb4",
> "plb5" and "ebc",

It makes sense for generic code to always if it is asked
to match for "vendor-code,some-name" also to match on
plain "some-name".  Well unless people start doing crazy
things like naming something "vendor-code,pci" which
isn't PCI compatible or something -- in that case there
could be a function that matches on exact name only, or
the caller can deal with it itself perhaps.

But in most cases the matching-without-prefix should work
fine.

> as well as the "compatible" property of the
> serial port, which, as you noted earlier is "ns16550" on
> ebony and "ns16750" on axon, although it is exactly the same
> macro.

So the "compatible" property should read ns16750, ns16550,
ns16450, i8250.  The kernel really only needs the device
to be compatible to the 8250; but since lots of device trees
mention only the newer UART types, you have to match on those
too.


Segher

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spi
  2007-02-20 15:25           ` Segher Boessenkool
@ 2007-02-20 18:02             ` Arnd Bergmann
  2007-02-20 19:51               ` Segher Boessenkool
  0 siblings, 1 reply; 50+ messages in thread
From: Arnd Bergmann @ 2007-02-20 18:02 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Christian Rund, Hartmut Penner, David Gibson

[-- Attachment #1: Type: text/plain, Size: 2614 bytes --]

On Tuesday 20 February 2007 16:25, Segher Boessenkool wrote:
> >> And the ebony dts also has the a bus type of "ibm,opb" as well.
> >
> > We should really get a common name for these. I don't remember
> > what the discussions were, but it seems we came up with different
> > results for Axon and ppc4xx, which is very bad.
> 
> "Very bad"...  Well sure it's less than desirable, but
> we have to deal with this problem anyway already.
> 
> > Using type "ibm,opb" rather than just "opb" makes sense to me,
> > but I don't know if we already have shipping systems that use
> > "opb" here.
> >
> > There is probably a similar problem with the nodes for "plb4",
> > "plb5" and "ebc",
> 
> It makes sense for generic code to always if it is asked
> to match for "vendor-code,some-name" also to match on
> plain "some-name".  Well unless people start doing crazy
> things like naming something "vendor-code,pci" which
> isn't PCI compatible or something -- in that case there
> could be a function that matches on exact name only, or
> the caller can deal with it itself perhaps.
> 
> But in most cases the matching-without-prefix should work
> fine.

but is it really the right thing to call it "ibm,plb"
when the identical macro is used on amcc based systems?

I think that was our reasoning when we introduced the
code in linux to scan for "plb5", "plb4" and "opb" buses.

Changing the "device-type" now would result in the final
product to not work on the 2.6.20 kernel, which was released
with the code only scanning for the short names.

Still, it's probably a good idea to list both variants
in compatible, e.g.

type="plb4", compatible="ibm,plb\0ibm,plb4\0plb"

on CAB/axon, and

type="ibm,plb", compatible="ibm,plb4\0plb4\0plb"

on ebony and others. Do you think it makes sense to do it this
way, or should we rather adopt the axon style on the 440 boards?

> > as well as the "compatible" property of the
> > serial port, which, as you noted earlier is "ns16550" on
> > ebony and "ns16750" on axon, although it is exactly the same
> > macro.
> 
> So the "compatible" property should read ns16750, ns16550,
> ns16450, i8250.  The kernel really only needs the device
> to be compatible to the 8250; but since lots of device trees
> mention only the newer UART types, you have to match on those
> too.

Right, that sounds completely correct. I think I've done the
right thing in of_serial already. Christian, please check
what the firmware does today, and make sure to change it
accordingly.
We probably also need a volunteer to clean up the legacy_serial
code for this, it's grown pretty messy by now.

	Arnd <><

[-- Attachment #2: Type: text/html, Size: 3629 bytes --]

^ permalink raw reply	[flat|nested] 50+ messages in thread

* RE: [PATCH 12/14] Add device tree for Ebony
  2007-02-20  2:12 ` [PATCH 12/14] Add device tree for Ebony David Gibson
  2007-02-20 15:09   ` Josh Boyer
@ 2007-02-20 19:22   ` Yoder Stuart-B08248
  2007-02-20 19:56     ` Segher Boessenkool
  1 sibling, 1 reply; 50+ messages in thread
From: Yoder Stuart-B08248 @ 2007-02-20 19:22 UTC (permalink / raw)
  To: David Gibson, linuxppc-dev


A couple of minor nits...

> +	UIC0: interrupt-controller { /* UIC0 */
> +		device_type =3D "interrupt-controller";
> +		compatible =3D "ibm,uic440gp", "ibm,uic";
> +		interrupt-controller;
> +		cell-index =3D <0>;
> +		dcr-reg =3D <0c0 009>;
> +		#address-cells =3D <0>;
> +		#size-cells =3D <0>;
> +		#interrupt-cells =3D <2>;
> +
> +		UIC1: interrupt-controller@1 { /* UIC1 */
> +			device_type =3D "interrupt-controller";
> +			compatible =3D "ibm,uic440gp", "ibm,uic";
> +			interrupt-controller;
> +			cell-index =3D <1>;
> +			dcr-reg =3D <0d0 009>;
> +			#address-cells =3D <0>;
> +			#size-cells =3D <0>;
> +			#interrupt-cells =3D <2>;
> +			interrupts =3D <1e 4 1f 4>; /* cascade */
> +		};
> +	};

Since UIC1 is cascaded off UIC0 in the interrupt tree,
UIC1 should have an interrupt-parent pointing to UIC0
so the interrupt tree can be traversed to the root.

I know this was beaten to death last week, but I would
still argue that in the device tree UIC0 and UIC1 should
be siblings.  (In the interrupt tree the cascade relationship
is described through interrupt-parent).

> +	chosen {
> +		linux,stdout-path =3D "/plb/opb@0/serial@140000200";
> +		linux,initrd-start =3D <0>; /* FIXME */
> +		linux,initrd-end =3D <0>;
> +		interrupt-controller =3D <&UIC0>;
> +	};
> +};

I thought there was agreement (last week) that interrupt-controller
would no longer be under /chosen.  I submitted a patch to
booting-without-of.txt to make this obsolete.   The kernel
does not use the property, and we can find a different place for
it in the future if we need it.

Stuart

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spi
  2007-02-20 18:02             ` Arnd Bergmann
@ 2007-02-20 19:51               ` Segher Boessenkool
  2007-02-20 20:29                 ` Josh Boyer
  0 siblings, 1 reply; 50+ messages in thread
From: Segher Boessenkool @ 2007-02-20 19:51 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Christian Rund, David Gibson, Hartmut Penner, linuxppc-dev

> but is it really the right thing to call it "ibm,plb"
>
> when the identical macro is used on amcc based systems?
>
> I think that was our reasoning when we introduced the
>
> code in linux to scan for "plb5", "plb4" and "opb" buses.

Yes, the vendor-code is there only as a unique marker
so different vendors won't have clashing namespaces.
Seen from that viewpoint, if a company buys stuff from
another company, or the whole company is bought or something,
it makes sense to keep the original name.

> Changing the "device-type" now would result in the final
>
> product to not work on the 2.6.20 kernel, which was released
>
> with the code only scanning for the short names.

If it's important for you to support .20, you obviously
shouldn't change this in the device tree anymore.
Unfortunate.

> Still, it's probably a good idea to list both variants
>
> in compatible, e.g.
>
> type="plb4", compatible="ibm,plb\0ibm,plb4\0plb"

No, that's a very bad idea.

> Do you think it makes sense to do it this
>
> way, or should we rather adopt the axon style on the 440 boards?

Like I said, it is probably best to have the device_is_compatible()
function return true if it is asked for "some-vendor,some-name"
and the actual property contains just "some-name".  The device
tree isn't more specific in that case, so any matcher can easily
be hurt by a namespace clash -- too bad, nothing the kernel
can do about it, but at least it can do the right thing for
device trees that *do* comply to best practice.

> > So the "compatible" property should read ns16750, ns16550,
>
> > ns16450, i8250. The kernel really only needs the device
>
> > to be compatible to the 8250; but since lots of device trees
>
> > mention only the newer UART types, you have to match on those
>
> > too.
>
> Right, that sounds completely correct. I think I've done the
>
> right thing in of_serial already.

Yeah I think so.

> Christian, please check
>
> what the firmware does today, and make sure to change it
>
> accordingly.

Note that it doesn't matter much for Linux if you change the
"compatible" property for serial now; the kernel will have to
support ns16550, ns16750 for ever since there are device
trees in the wild that don't include the more generic devices
in their "compatible" property.  Not only Axon etc. device
trees, don't get me wrong :-)

> We probably also need a volunteer to clean up the legacy_serial
>
> code for this, it's grown pretty messy by now.

I nominate you :-)


Segher

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 12/14] Add device tree for Ebony
  2007-02-20 19:22   ` Yoder Stuart-B08248
@ 2007-02-20 19:56     ` Segher Boessenkool
  2007-02-21  4:57       ` David Gibson
  2007-02-22  6:49       ` Segher Boessenkool
  0 siblings, 2 replies; 50+ messages in thread
From: Segher Boessenkool @ 2007-02-20 19:56 UTC (permalink / raw)
  To: Yoder Stuart-B08248; +Cc: linuxppc-dev, David Gibson

> Since UIC1 is cascaded off UIC0 in the interrupt tree,
> UIC1 should have an interrupt-parent pointing to UIC0
> so the interrupt tree can be traversed to the root.

Not necessary if UIC0 is the device tree parent of UIC1.
(And in fact it would be "bad style").  But...

> I know this was beaten to death last week, but I would
> still argue that in the device tree UIC0 and UIC1 should
> be siblings.  (In the interrupt tree the cascade relationship
> is described through interrupt-parent).

... that is my opinion as well (as I'm sure you know ;-) ),
and then of course you _do_ need the interrupt-parent property.


Segher

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spi
  2007-02-20 19:51               ` Segher Boessenkool
@ 2007-02-20 20:29                 ` Josh Boyer
  2007-02-21  0:38                   ` David Gibson
  0 siblings, 1 reply; 50+ messages in thread
From: Josh Boyer @ 2007-02-20 20:29 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: linuxppc-dev, Christian Rund, Hartmut Penner, Arnd Bergmann,
	David Gibson

On Tue, 2007-02-20 at 20:51 +0100, Segher Boessenkool wrote:
> 
> > We probably also need a volunteer to clean up the legacy_serial
> >
> > code for this, it's grown pretty messy by now.
> 
> I nominate you :-)

In the absence of someone actually cleaning up the code, the following
ugly patch should work for both Axon and 4xx until we can settle on
settle on something.  It booted on my Ebony board with David's
FIXED_PORT flag patch also applied anyway.

josh

Make legacy_serial look for multiple compatible serial types on the OBP bus.

Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>

--

diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 325f490..3cb2f51 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -291,7 +291,14 @@ void __init find_legacy_serial_ports(void)
 {
 	struct device_node *np, *stdout = NULL;
 	const char *path;
-	int index;
+	int index, i;
+	const char *compat[] = {
+		"ns16750",
+		"ns16550",
+		"ns16450",
+		"i8250",
+		NULL,
+	};
 
 	DBG(" -> find_legacy_serial_port()\n");
 
@@ -339,14 +346,19 @@ void __init find_legacy_serial_ports(void)
 	}
 
 	/* First fill our array with opb bus ports */
-	for (np = NULL; (np = of_find_compatible_node(np, "serial", "ns16750")) != NULL;) {
-		struct device_node *opb = of_get_parent(np);
-		if (opb && !strcmp(opb->type, "opb")) {
-			index = add_legacy_soc_port(np, np);
-			if (index >= 0 && np == stdout)
-				legacy_serial_console = index;
+	for (i = 0; compat[i] != NULL; i++) {
+		for (np = NULL;
+			(np = of_find_compatible_node(np, "serial", compat[i])) != NULL;) {
+
+			struct device_node *opb = of_get_parent(np);
+			if (opb &&
+				(!strcmp(opb->type, "opb") || !strcmp(opb->type, "ibm,opb"))) {
+				index = add_legacy_soc_port(np, np);
+				if (index >= 0 && np == stdout)
+					legacy_serial_console = index;
+			}
+			of_node_put(opb);
 		}
-		of_node_put(opb);
 	}
 
 #ifdef CONFIG_PCI

^ permalink raw reply related	[flat|nested] 50+ messages in thread

* Re: [PATCH 4/14] Use resource_size_t for serial port IO addresses
  2007-02-20 14:44   ` Sergei Shtylyov
@ 2007-02-21  0:19     ` David Gibson
  0 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-21  0:19 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linuxppc-dev

On Tue, Feb 20, 2007 at 05:44:26PM +0300, Sergei Shtylyov wrote:
> Hello.
> 
> David Gibson wrote:
> > At present, various parts of the serial code use unsigned long to
> > define resource addresses.  This is a problem, because some 32-bit
> > platforms have physical addresses larger than 32-bits, and have mmio
> > serial uarts located above the 4GB point.
> > 
> > This patch changes the type of mapbase in both struct uart_port and
> > struct plat_serial8250_port to resource_size_t, which can be
> > configured to be 64 bits on such platforms.  The mapbase in
> > serial_struct can't safely be changed, because that structure is user
> > visible.
> 
>     Erm, isn't linux-serial@vger.kernel.org more proper list for
> such patches?  Also, as serial drivers are now unmaintained, this
> probably needs to go to -mm tree.

I've also sent this to rmk, akpm and lkml for inclusion in -mm.  It's
just copied here so that all the patches necessary for Ebony are
convenient in one place.

> > Index: working-2.6/drivers/serial/serial_core.c
> > ===================================================================
> > --- working-2.6.orig/drivers/serial/serial_core.c	2007-02-19 11:07:42.000000000 +1100
> > +++ working-2.6/drivers/serial/serial_core.c	2007-02-19 11:07:43.000000000 +1100
> > @@ -633,7 +633,7 @@ static int uart_get_info(struct uart_sta
> >  	tmp.hub6	    = port->hub6;
> >  	tmp.io_type         = port->iotype;
> >  	tmp.iomem_reg_shift = port->regshift;
> > -	tmp.iomem_base      = (void *)port->mapbase;
> > +	tmp.iomem_base      = (void *)(unsigned long)port->mapbase;
> 
>     For 32-bit kernels this may result in a meaningless address. Have you 
> considered also changing iomem_base's type?

Impossible; that's the serial_struct, which is userland visible.  Yes,
it will result in a meaningless address, but I don't see what else can
be done.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 10/14] Early serial debug support for PPC44x
  2007-02-20 13:26   ` Segher Boessenkool
@ 2007-02-21  0:20     ` David Gibson
  0 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-21  0:20 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev

On Tue, Feb 20, 2007 at 02:26:05PM +0100, Segher Boessenkool wrote:
> > +config PPC_EARLY_DEBUG_44x
> > +	bool "Early serial debugging for IBM 44x CPUs"
> 
> Change this to IBM/AMCC 44x, like the patch description
> says?

Done.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 12/14] Add device tree for Ebony
  2007-02-20 15:09   ` Josh Boyer
@ 2007-02-21  0:24     ` David Gibson
  2007-02-21 12:25       ` Segher Boessenkool
  0 siblings, 1 reply; 50+ messages in thread
From: David Gibson @ 2007-02-21  0:24 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev

On Tue, Feb 20, 2007 at 09:09:51AM -0600, Josh Boyer wrote:
> On Tue, 2007-02-20 at 13:12 +1100, David Gibson wrote:
> > Add a device tree for the Ebony evaluation board (440GP based).  This
> > tree is not complete or finalized.  This tree needs a very recent
> > version of dtc to process.
> > 
> > Signed-off-by: David Gibson <dwg@au1.ibm.com>
> > ---
> > 
> >  arch/powerpc/boot/dts/ebony.dts |  225 ++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 225 insertions(+)
> > 
> > Index: working-2.6/arch/powerpc/boot/dts/ebony.dts
> > ===================================================================
> > --- /dev/null	1970-01-01 00:00:00.000000000 +0000
> > +++ working-2.6/arch/powerpc/boot/dts/ebony.dts	2007-02-19 15:31:36.000000000 +1100
> > @@ -0,0 +1,225 @@
> > +/*
> > + * Device Tree Source for IBM Ebony
> > + *
> > + * Copyright (c) 2006, 2007 IBM Corp.
> > + * Josh Boyer <jdub@us.ibm.com>, David Gibson <dwg@au1.ibm.com>
> 
> That email address died about 2 weeks ago.  Feel free to change it to
> this one: jwboyer@linux.vnet.ibm.com

Done

[snip]
> > +	plb {
> > +		device_type = "ibm,plb";
> > +		compatible = "ibm,plb-440gp", "ibm,plb4";
> > +		#address-cells = <2>;
> > +		#size-cells = <1>;
> > +		ranges;
> > +
> > +		POB0: opb@0 {
> 
> I think you meant "OPB0:" for the label.

Not really.  The 440GP user manual refers to the bridge (as opposed to
the bus) as POB0.  The label is meant to reflect that.

> > +			device_type = "ibm,opb";
> > +			compatible = "ibm,opb-440gp", "ibm,opb";
> 
> As I pointed out in an earlier email, this breaks working with the
> current legacy_serial driver.  It's looking for a device_type of "opb".
> I'm not sure if we should fix the driver or fix this and the
> ebony_of_bus types in arch/powerpc/platforms/4xx/ebony.c

That's kind of deliberate.  The idea is to use the of_serial stuff
instead of legacy_serial.  legacy_serial was really meant for *legacy*
(i.e. ISA) serial ports, not these on chip things.

The revised version of ebony.c already scans ibm,plb and ibm,opb
busses for OF devices.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 13/14] Re-organize Kconfig code for 4xx in arch/powerpc
  2007-02-20 13:51   ` Josh Boyer
@ 2007-02-21  0:26     ` David Gibson
  0 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-21  0:26 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev

On Tue, Feb 20, 2007 at 07:51:29AM -0600, Josh Boyer wrote:
> On Tue, 2007-02-20 at 13:12 +1100, David Gibson wrote:
> > 
> > -# It's often necessary to know the specific 4xx processor type.
> > -# Fortunately, it is impled (so far) from the board type, so we
> > -# don't need to ask more redundant questions.
> > +# 40x specific CPU modules, selected based on the board above.
> >  config NP405H
> >  	bool
> > -	depends on ASH
> > +	#depends on ASH
> >  	default y
> 
> This always turns this option on, even for Ebony builds.  Should
> probably comment out the 'default y' for now as well.

Oops, yes.  Fixed.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spin
  2007-02-20 15:03       ` Josh Boyer
  2007-02-20 15:07         ` [0/14] Ebony support, 2nd spi Arnd Bergmann
  2007-02-20 15:11         ` [0/14] Ebony support, 2nd spin Segher Boessenkool
@ 2007-02-21  0:33         ` David Gibson
  2 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-21  0:33 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, Arnd Bergmann

On Tue, Feb 20, 2007 at 09:03:26AM -0600, Josh Boyer wrote:
> On Tue, 2007-02-20 at 08:46 -0600, Josh Boyer wrote:
> > On Tue, 2007-02-20 at 15:16 +0100, Arnd Bergmann wrote:
> > > On Tuesday 20 February 2007 15:05, Josh Boyer wrote:
> > > > Which probably has something to do with the of_serial driver being used
> > > > now.  Just an FYI.
> > > 
> > > If you want to use of_serial together with serial console, you need
> > > to make sure that the detection logic in arch/powerpc/kernel/legacy_serial.c
> > > finds the port. It currently finds the serial port on axon, but that
> > > requires that the bus it's on is of type "opb" and the device itself
> > > is listed as "stdout" and has type "serial" and is compatible with
> > > "ns16750" (note: the others look for "ns16550" here).
> > 
> > The ebony dts has the ports as ns16550.  That is required for the
> > bootwrapper to find the port to use for it's output at the moment.
> 
> And the ebony dts also has the a bus type of "ibm,opb" as well.
> 
> I hacked legacy_serial.c to look for ns16550 compatible devices with a
> parent OPB node of type "ibm,opb" and I got serial output on the Ebony
> board even with of_serial turned off.

No, the idea is that Ebony *should not* be using legacy_serial.  It
uses of_serial instead.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spin
  2007-02-20 14:16   ` Arnd Bergmann
  2007-02-20 14:46     ` Josh Boyer
@ 2007-02-21  0:35     ` David Gibson
  2007-02-21  9:06       ` Arnd Bergmann
  1 sibling, 1 reply; 50+ messages in thread
From: David Gibson @ 2007-02-21  0:35 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev

On Tue, Feb 20, 2007 at 03:16:24PM +0100, Arnd Bergmann wrote:
> On Tuesday 20 February 2007 15:05, Josh Boyer wrote:
> > Which probably has something to do with the of_serial driver being used
> > now.  Just an FYI.
> 
> If you want to use of_serial together with serial console, you need
> to make sure that the detection logic in arch/powerpc/kernel/legacy_serial.c
> finds the port. It currently finds the serial port on axon, but that
> requires that the bus it's on is of type "opb" and the device itself
> is listed as "stdout" and has type "serial" and is compatible with
> "ns16750" (note: the others look for "ns16550" here).

Err.. no.  On my system legacy_serial doesn't touch the ports, but I'm
getting console output via of_serial just fine.  The console is
initialized rather later than would be ideal, but it works.

I know that BenH has expressed the strong preference that
legacy_serial should be reverted to only handling legacy ISA ports,
not SoC and other hardwired ports.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spi
  2007-02-20 20:29                 ` Josh Boyer
@ 2007-02-21  0:38                   ` David Gibson
  2007-02-21  1:30                     ` Josh Boyer
  0 siblings, 1 reply; 50+ messages in thread
From: David Gibson @ 2007-02-21  0:38 UTC (permalink / raw)
  To: Josh Boyer; +Cc: linuxppc-dev, Arnd Bergmann, Hartmut Penner, Christian Rund

On Tue, Feb 20, 2007 at 02:29:25PM -0600, Josh Boyer wrote:
> On Tue, 2007-02-20 at 20:51 +0100, Segher Boessenkool wrote:
> > 
> > > We probably also need a volunteer to clean up the legacy_serial
> > >
> > > code for this, it's grown pretty messy by now.
> > 
> > I nominate you :-)
> 
> In the absence of someone actually cleaning up the code, the following
> ugly patch should work for both Axon and 4xx until we can settle on
> settle on something.  It booted on my Ebony board with David's
> FIXED_PORT flag patch also applied anyway.
> 
> josh
> 
> Make legacy_serial look for multiple compatible serial types on the OBP bus.

Again: legacy_serial is not necessary for Ebony console support with
the current patches.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spi
  2007-02-20 15:07         ` [0/14] Ebony support, 2nd spi Arnd Bergmann
  2007-02-20 15:17           ` Josh Boyer
  2007-02-20 15:25           ` Segher Boessenkool
@ 2007-02-21  0:44           ` David Gibson
  2 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-21  0:44 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev, Hartmut Penner, Christian Rund

On Tue, Feb 20, 2007 at 04:07:32PM +0100, Arnd Bergmann wrote:
> On Tuesday 20 February 2007 16:03, Josh Boyer wrote:
> > And the ebony dts also has the a bus type of "ibm,opb" as well.
> 
> We should really get a common name for these. I don't remember
> what the discussions were, but it seems we came up with different
> results for Axon and ppc4xx, which is very bad.
> 
> Using type "ibm,opb" rather than just "opb" makes sense to me,
> but I don't know if we already have shipping systems that use
> "opb" here.
> 
> There is probably a similar problem with the nodes for "plb4",
> "plb5" and "ebc", as well as the "compatible" property of the
> serial port, which, as you noted earlier is "ns16550" on 
> ebony and "ns16750" on axon, although it is exactly the same
> macro.

Yes, we should have some common names.  I didn't like using bare
"plb", because I was worried that, being such a bland generic name,
some other vendor might apply the same name to their own "processor
local bus" which could be something entirely different.  But, if we
have things in the wild that use "plb" and "opb", then I'll change it
over.

That said, this doesn't actually break anything at present.
legacy_serial is not supposed to find any ports on Ebony, and ebony.c
specifies the bus types to be probed for of_platform devices,
including of_serial.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 5/14] zImage: Add more flexible gunzip convenience functions
  2007-02-20  2:12 ` [PATCH 5/14] zImage: Add more flexible gunzip convenience functions David Gibson
@ 2007-02-21  0:56   ` Geoff Levand
  0 siblings, 0 replies; 50+ messages in thread
From: Geoff Levand @ 2007-02-21  0:56 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

David Gibson wrote:
> This patch adds a new set of more flexible convenience wrappers around
> zlib, moving them to their own file, gunzip_util.c, in the process.
> These wrappers allow decompressing sections of the compressed image to
> different locations.  In addition, they transparently handle
> uncompressed data, avoiding special case code to handle uncompressed
> vmlinux images.

I tested this on on PS3 without trouble.

Acked-by: Geoff Levand <geoffrey.levand@am.sony.com>

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 6/14] zImage: Cleanup and improve prep_kernel()
  2007-02-20  2:12 ` [PATCH 6/14] zImage: Cleanup and improve prep_kernel() David Gibson
@ 2007-02-21  0:56   ` Geoff Levand
  0 siblings, 0 replies; 50+ messages in thread
From: Geoff Levand @ 2007-02-21  0:56 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

David Gibson wrote:
> This patch rewrites prep_kernel() in the zImage wrapper code to be
> clearer and more flexible.  Notable changes:

I tested this on on PS3 (no initrd case) without trouble.

Acked-by: Geoff Levand <geoffrey.levand@am.sony.com>

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 7/14] zImage: Cleanup and improve zImage entry point
  2007-02-20  2:12 ` [PATCH 7/14] zImage: Cleanup and improve zImage entry point David Gibson
@ 2007-02-21  0:57   ` Geoff Levand
  0 siblings, 0 replies; 50+ messages in thread
From: Geoff Levand @ 2007-02-21  0:57 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

David Gibson wrote:
> This patch re-organises the way the zImage wrapper code is entered, to
> allow more flexibility on platforms with unusual entry conditions.
> After this patch, a platform .o file has two options:

I tested this on on PS3 without trouble.

Acked-by: Geoff Levand <geoffrey.levand@am.sony.com>

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spi
  2007-02-21  0:38                   ` David Gibson
@ 2007-02-21  1:30                     ` Josh Boyer
  0 siblings, 0 replies; 50+ messages in thread
From: Josh Boyer @ 2007-02-21  1:30 UTC (permalink / raw)
  To: Segher Boessenkool, linuxppc-dev, Christian Rund, Hartmut Penner,
	Arnd Bergmann

On Wed, Feb 21, 2007 at 11:38:56AM +1100, David Gibson wrote:
> On Tue, Feb 20, 2007 at 02:29:25PM -0600, Josh Boyer wrote:
> > On Tue, 2007-02-20 at 20:51 +0100, Segher Boessenkool wrote:
> > > 
> > > > We probably also need a volunteer to clean up the legacy_serial
> > > >
> > > > code for this, it's grown pretty messy by now.
> > > 
> > > I nominate you :-)
> > 
> > In the absence of someone actually cleaning up the code, the following
> > ugly patch should work for both Axon and 4xx until we can settle on
> > settle on something.  It booted on my Ebony board with David's
> > FIXED_PORT flag patch also applied anyway.
> > 
> > josh
> > 
> > Make legacy_serial look for multiple compatible serial types on the OBP bus.
> 
> Again: legacy_serial is not necessary for Ebony console support with
> the current patches.

Ok, that's fine.  But we should select of_serial from the Ebony Kconfig entry
if that's the one you'd like to use.

josh

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 12/14] Add device tree for Ebony
  2007-02-20 19:56     ` Segher Boessenkool
@ 2007-02-21  4:57       ` David Gibson
  2007-02-22  6:49       ` Segher Boessenkool
  1 sibling, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-21  4:57 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev, Yoder Stuart-B08248

On Tue, Feb 20, 2007 at 08:56:04PM +0100, Segher Boessenkool wrote:
> > Since UIC1 is cascaded off UIC0 in the interrupt tree,
> > UIC1 should have an interrupt-parent pointing to UIC0
> > so the interrupt tree can be traversed to the root.
> 
> Not necessary if UIC0 is the device tree parent of UIC1.
> (And in fact it would be "bad style").  But...
> 
> > I know this was beaten to death last week, but I would
> > still argue that in the device tree UIC0 and UIC1 should
> > be siblings.  (In the interrupt tree the cascade relationship
> > is described through interrupt-parent).
> 
> ... that is my opinion as well (as I'm sure you know ;-) ),
> and then of course you _do_ need the interrupt-parent property.

Ok, there are enough people of this opinion (including Paul), that
I've changed to representing the UICs as siblings.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spin
  2007-02-21  0:35     ` David Gibson
@ 2007-02-21  9:06       ` Arnd Bergmann
  2007-02-25 23:57         ` David Gibson
  0 siblings, 1 reply; 50+ messages in thread
From: Arnd Bergmann @ 2007-02-21  9:06 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

On Wednesday 21 February 2007 01:35, David Gibson wrote:
> Err.. no. =A0On my system legacy_serial doesn't touch the ports, but I'm
> getting console output via of_serial just fine. =A0The console is
> initialized rather later than would be ideal, but it works.
>=20
> I know that BenH has expressed the strong preference that
> legacy_serial should be reverted to only handling legacy ISA ports,
> not SoC and other hardwired ports.

Ok, my impression on this was that of_serial is the right solution
in general, but it often gets initialized too late to debug some
of the interesting parts of the boot sequence.

Unless we take handling of soc serial ports completely out of
legacy_serial, I think it should handle ebony just like the other
boards.

Because of the way the serial layer works, it does exactly the
right thing if you have both drivers enabled, i.e. it starts
out using the first port when legacy_serial detects it, but later
of_serial finds it as well, and wires up all the logic to connect
both the serial ports to the right device tree nodes.

	Arnd <><

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 12/14] Add device tree for Ebony
  2007-02-21  0:24     ` David Gibson
@ 2007-02-21 12:25       ` Segher Boessenkool
  0 siblings, 0 replies; 50+ messages in thread
From: Segher Boessenkool @ 2007-02-21 12:25 UTC (permalink / raw)
  To: David Gibson; +Cc: linuxppc-dev

>>> +		POB0: opb@0 {
>>
>> I think you meant "OPB0:" for the label.
>
> Not really.  The 440GP user manual refers to the bridge (as opposed to
> the bus) as POB0.  The label is meant to reflect that.

The device node represents both the bridge _and_ the bus
behind it, so you could use OPB just as well as POB, and
it probably would be less confusing ;-)

But it's just a label, who cares.


Segher

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 12/14] Add device tree for Ebony
  2007-02-20 19:56     ` Segher Boessenkool
  2007-02-21  4:57       ` David Gibson
@ 2007-02-22  6:49       ` Segher Boessenkool
  1 sibling, 0 replies; 50+ messages in thread
From: Segher Boessenkool @ 2007-02-22  6:49 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev, Yoder Stuart-B08248, David Gibson

>> Since UIC1 is cascaded off UIC0 in the interrupt tree,
>> UIC1 should have an interrupt-parent pointing to UIC0
>> so the interrupt tree can be traversed to the root.
>
> Not necessary if UIC0 is the device tree parent of UIC1.

For the archives: this is wrong, all interrupt controllers
(except the root one) are required to have an "interrupt-parent"
property -- this is how the root interrupt controller is
determined.


Segher

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [0/14] Ebony support, 2nd spin
  2007-02-21  9:06       ` Arnd Bergmann
@ 2007-02-25 23:57         ` David Gibson
  0 siblings, 0 replies; 50+ messages in thread
From: David Gibson @ 2007-02-25 23:57 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linuxppc-dev

On Wed, Feb 21, 2007 at 10:06:58AM +0100, Arnd Bergmann wrote:
> On Wednesday 21 February 2007 01:35, David Gibson wrote:
> > Err.. no.  On my system legacy_serial doesn't touch the ports, but I'm
> > getting console output via of_serial just fine.  The console is
> > initialized rather later than would be ideal, but it works.
> > 
> > I know that BenH has expressed the strong preference that
> > legacy_serial should be reverted to only handling legacy ISA ports,
> > not SoC and other hardwired ports.
> 
> Ok, my impression on this was that of_serial is the right solution
> in general, but it often gets initialized too late to debug some
> of the interesting parts of the boot sequence.
> 
> Unless we take handling of soc serial ports completely out of
> legacy_serial, I think it should handle ebony just like the other
> boards.

Well, Ben has said to me that he'd like to remove handling of SoC
serial ports (indeed everything excepy legacy ISA) from
legacy_serial.c.


-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2007-02-25 23:57 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-20  2:08 [0/14] Ebony support, 2nd spin David Gibson
2007-02-20  2:12 ` [PATCH 3/14] Define FIXED_PORT flag for serial_core David Gibson
2007-02-20  2:12 ` [PATCH 2/14] Automatically lmb_reserve() initrd David Gibson
2007-02-20  2:12 ` [PATCH 4/14] Use resource_size_t for serial port IO addresses David Gibson
2007-02-20 14:44   ` Sergei Shtylyov
2007-02-21  0:19     ` David Gibson
2007-02-20  2:12 ` [PATCH 1/14] powerpc: Allow duplicate lmb_reserve() calls David Gibson
2007-02-20  2:12 ` [PATCH 5/14] zImage: Add more flexible gunzip convenience functions David Gibson
2007-02-21  0:56   ` Geoff Levand
2007-02-20  2:12 ` [PATCH 11/14] Add arch/powerpc driver for UIC, PPC4xx interrupt controller David Gibson
2007-02-20  2:12 ` [PATCH 7/14] zImage: Cleanup and improve zImage entry point David Gibson
2007-02-21  0:57   ` Geoff Levand
2007-02-20  2:12 ` [PATCH 8/14] zImage wrapper for Ebony David Gibson
2007-02-20  2:12 ` [PATCH 9/14] Port 44x MMU definitions to ARCH=powerpc David Gibson
2007-02-20  2:12 ` [PATCH 6/14] zImage: Cleanup and improve prep_kernel() David Gibson
2007-02-21  0:56   ` Geoff Levand
2007-02-20  2:12 ` [PATCH 12/14] Add device tree for Ebony David Gibson
2007-02-20 15:09   ` Josh Boyer
2007-02-21  0:24     ` David Gibson
2007-02-21 12:25       ` Segher Boessenkool
2007-02-20 19:22   ` Yoder Stuart-B08248
2007-02-20 19:56     ` Segher Boessenkool
2007-02-21  4:57       ` David Gibson
2007-02-22  6:49       ` Segher Boessenkool
2007-02-20  2:12 ` [PATCH 10/14] Early serial debug support for PPC44x David Gibson
2007-02-20 13:26   ` Segher Boessenkool
2007-02-21  0:20     ` David Gibson
2007-02-20  2:12 ` [PATCH 13/14] Re-organize Kconfig code for 4xx in arch/powerpc David Gibson
2007-02-20 13:51   ` Josh Boyer
2007-02-21  0:26     ` David Gibson
2007-02-20  2:12 ` [PATCH 14/14] Support for Ebony " David Gibson
2007-02-20 14:05 ` [0/14] Ebony support, 2nd spin Josh Boyer
2007-02-20 14:14   ` Josh Boyer
2007-02-20 14:16   ` Arnd Bergmann
2007-02-20 14:46     ` Josh Boyer
2007-02-20 15:03       ` Josh Boyer
2007-02-20 15:07         ` [0/14] Ebony support, 2nd spi Arnd Bergmann
2007-02-20 15:17           ` Josh Boyer
2007-02-20 15:25           ` Segher Boessenkool
2007-02-20 18:02             ` Arnd Bergmann
2007-02-20 19:51               ` Segher Boessenkool
2007-02-20 20:29                 ` Josh Boyer
2007-02-21  0:38                   ` David Gibson
2007-02-21  1:30                     ` Josh Boyer
2007-02-21  0:44           ` David Gibson
2007-02-20 15:11         ` [0/14] Ebony support, 2nd spin Segher Boessenkool
2007-02-21  0:33         ` David Gibson
2007-02-21  0:35     ` David Gibson
2007-02-21  9:06       ` Arnd Bergmann
2007-02-25 23:57         ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.