All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] bootwrapper/cuboot
@ 2007-03-22 19:46 Scott Wood
  2007-03-22 19:49 ` [PATCH 1/6] bootwrapper: Add dt_xlate_reg(), and use it to find serial registers Scott Wood
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Scott Wood @ 2007-03-22 19:46 UTC (permalink / raw)
  To: linuxppc-dev

This patchset applies to David's "Further zImage work (spin 2)" patchset.

-Scott

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

* [PATCH 1/6] bootwrapper: Add dt_xlate_reg(), and use it to find serial registers.
  2007-03-22 19:46 [PATCH 0/6] bootwrapper/cuboot Scott Wood
@ 2007-03-22 19:49 ` Scott Wood
  2007-03-22 19:49 ` [PATCH 2/6] bootwrapper: Add ppcboot.h Scott Wood
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 18+ messages in thread
From: Scott Wood @ 2007-03-22 19:49 UTC (permalink / raw)
  To: linuxppc-dev

dt_xlate_reg() uses the ranges properties of a node's parentage to find
the absolute physical address of the node's registers.

The ns16550 driver uses this when no virtual-reg property is found.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
This version's a little smaller, simpler, and more correct than the last
one.

 arch/powerpc/boot/devtree.c |  178 +++++++++++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/ns16550.c |    9 ++-
 arch/powerpc/boot/ops.h     |    2 +
 3 files changed, 187 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
index 708cade..23492d7 100644
--- a/arch/powerpc/boot/devtree.c
+++ b/arch/powerpc/boot/devtree.c
@@ -109,3 +109,181 @@ void __dt_fixup_mac_addresses(u32 startindex, ...)
 	}
 	va_end(ap);
 }
+
+#define MAX_ADDR_CELLS 4
+#define MAX_RANGES 8
+
+static void get_reg_format(void *node, u32 *naddr, u32 *nsize)
+{
+	if (getprop(node, "#address-cells", naddr, 4) != 4)
+		*naddr = 2;
+	if (getprop(node, "#size-cells", nsize, 4) != 4)
+		*nsize = 1;
+}
+
+static void copy_val(u32 *dest, u32 *src, int naddr)
+{
+	memset(dest, 0, (MAX_ADDR_CELLS - naddr) * 4);
+	memcpy(dest, src, naddr * 4);
+}
+
+static int sub_reg(u32 *reg, u32 *sub)
+{
+	int i, borrow = 0;
+
+	for (i = 0; i < MAX_ADDR_CELLS; i++) {
+		int prev_borrow = borrow;
+		borrow = reg[i] < sub[i] + prev_borrow;
+		reg[i] -= sub[i] + prev_borrow;
+	}
+
+	return !borrow;
+}
+
+static int add_reg(u32 *reg, u32 *add)
+{
+	int i, carry = 0;
+
+	for (i = 0; i < MAX_ADDR_CELLS; i++) {
+		u64 tmp = (u64)reg[i] + add[i] + carry;
+		carry = tmp >> 32;
+		reg[i] = (u32)tmp;
+	}
+
+	return !carry;
+}
+
+/* It is assumed that if the first byte of reg fits in a
+ * range, then the whole reg block fits.
+ */
+static int compare_reg(u32 *reg, u32 *range, u32 *rangesize)
+{
+	int i;
+	u32 end;
+
+	for (i = 0; i < MAX_ADDR_CELLS; i++) {
+		if (reg[i] < range[i])
+			return 0;
+		if (reg[i] > range[i])
+			break;
+	}
+
+	for (i = 0; i < MAX_ADDR_CELLS; i++) {
+		end = range[i] + rangesize[i];
+
+		if (reg[i] < end)
+			break;
+		if (reg[i] > end)
+			return 0;
+	}
+
+	return reg[i] != end;
+}
+
+/* reg must be MAX_ADDR_CELLS */
+static int find_range(u32 *reg, u32 *ranges, int nregaddr,
+                      int naddr, int nsize, int buflen)
+{
+	int nrange = nregaddr + naddr + nsize;
+	int i;
+
+	for (i = 0; i + nrange <= buflen; i += nrange) {
+		u32 range_addr[MAX_ADDR_CELLS];
+		u32 range_size[MAX_ADDR_CELLS];
+
+		copy_val(range_addr, ranges + i, naddr);
+		copy_val(range_size, ranges + i + nregaddr + naddr, nsize);
+
+		if (compare_reg(reg, range_addr, range_size))
+			return i;
+	}
+
+	return -1;
+}
+
+/* Currently only generic buses without special encodings are supported.
+ * In particular, PCI is not supported.  Also, only the beginning of the
+ * reg block is tracked; size is ignored except in ranges.
+ */
+int dt_xlate_reg(void *node, int res, unsigned long *addr,
+                 unsigned long *size)
+{
+	u32 last_addr[MAX_ADDR_CELLS];
+	u32 this_addr[MAX_ADDR_CELLS];
+	u32 buf[MAX_ADDR_CELLS * MAX_RANGES * 3];
+	void *parent;
+	u64 ret_addr, ret_size;
+	u32 naddr, nsize, prev_naddr;
+	int buflen, offset;
+
+	parent = get_parent(node);
+	if (!parent)
+		return 0;
+
+	get_reg_format(parent, &naddr, &nsize);
+
+	if (nsize > 2)
+		return 0;
+
+	buflen = getprop(node, "reg", buf, sizeof(buf)) / 4;
+	offset = (naddr + nsize) * res;
+
+	if (buflen < offset + naddr + nsize)
+		return 0;
+
+	copy_val(last_addr, buf + offset, naddr);
+
+	ret_size = buf[offset + naddr];
+	if (nsize == 2) {
+		ret_size <<= 32;
+		ret_size |= buf[offset + naddr + 1];
+	}
+
+	while ((node = get_parent(node))) {
+		prev_naddr = naddr;
+
+		get_reg_format(node, &naddr, &nsize);
+
+		buflen = getprop(node, "ranges", buf, sizeof(buf));
+		if (buflen < 0)
+			continue;
+		if (buflen > sizeof(buf))
+			return 0;
+
+		offset = find_range(last_addr, buf, prev_naddr,
+		                    naddr, nsize, buflen / 4);
+
+		if (offset < 0)
+			return 0;
+
+		copy_val(this_addr, buf + offset, prev_naddr);
+
+		if (!sub_reg(last_addr, this_addr))
+			return 0;
+
+		copy_val(this_addr, buf + offset + prev_naddr, naddr);
+
+		if (!add_reg(last_addr, this_addr))
+			return 0;
+	}
+
+	if (naddr > 2)
+		return 0;
+
+	ret_addr = last_addr[0];
+	if (naddr == 2) {
+		ret_addr <<= 32;
+		ret_addr |= last_addr[1];
+	}
+
+	if (sizeof(void *) == 4 &&
+	    (ret_addr >= 0x100000000ULL || ret_size > 0x100000000ULL ||
+	     ret_addr + ret_size > 0x100000000ULL))
+		return 0;
+
+	*addr = ret_addr;
+	if (size)
+		*size = ret_size;
+
+	return 1;
+}
diff --git a/arch/powerpc/boot/ns16550.c b/arch/powerpc/boot/ns16550.c
index 1ffe72e..f8f1b2f 100644
--- a/arch/powerpc/boot/ns16550.c
+++ b/arch/powerpc/boot/ns16550.c
@@ -55,10 +55,15 @@ static u8 ns16550_tstc(void)
 int ns16550_console_init(void *devp, struct serial_console_data *scdp)
 {
 	int n;
+	unsigned long reg_phys;
 
 	n = getprop(devp, "virtual-reg", &reg_base, sizeof(reg_base));
-	if (n != sizeof(reg_base))
-		return -1;
+	if (n != sizeof(reg_base)) {
+		if (!dt_xlate_reg(devp, 0, &reg_phys, NULL))
+			return -1;
+
+		reg_base = (void *)reg_phys;
+	}
 
 	n = getprop(devp, "reg-shift", &reg_shift, sizeof(reg_shift));
 	if (n != sizeof(reg_shift))
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 8008d61..fbd9030 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -82,6 +82,8 @@ int ns16550_console_init(void *devp, struct serial_console_data *scdp);
 void *simple_alloc_init(char *base, u32 heap_size, u32 granularity,
 		u32 max_allocs);
 extern void flush_cache(void *, unsigned long);
+int dt_xlate_reg(void *node, int res, unsigned long *addr,
+                 unsigned long *size);
 
 static inline void *finddevice(const char *name)
 {
-- 
1.5.0.3

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

* [PATCH 2/6] bootwrapper: Add ppcboot.h.
  2007-03-22 19:46 [PATCH 0/6] bootwrapper/cuboot Scott Wood
  2007-03-22 19:49 ` [PATCH 1/6] bootwrapper: Add dt_xlate_reg(), and use it to find serial registers Scott Wood
@ 2007-03-22 19:49 ` Scott Wood
  2007-03-22 19:49 ` [PATCH 3/6] bootwrapper: Add support for cuboot platforms Scott Wood
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 18+ messages in thread
From: Scott Wood @ 2007-03-22 19:49 UTC (permalink / raw)
  To: linuxppc-dev

This file describes the bd_t struct, which is used by old versions of
U-boot to pass information to the kernel.  Platform code that needs to
interoperate with such firmware can use this; it should not be used for
anything new.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/ppcboot.h |  108 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 108 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/boot/ppcboot.h

diff --git a/arch/powerpc/boot/ppcboot.h b/arch/powerpc/boot/ppcboot.h
new file mode 100644
index 0000000..5290ff2
--- /dev/null
+++ b/arch/powerpc/boot/ppcboot.h
@@ -0,0 +1,108 @@
+/*
+ * This interface is used for compatibility with old U-boots *ONLY*.
+ * Please do not imitate or extend this.
+ */
+
+/*
+ * (C) Copyright 2000, 2001
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __PPCBOOT_H__
+#define __PPCBOOT_H__
+
+/*
+ * Board information passed to kernel from PPCBoot
+ *
+ * include/asm-ppc/ppcboot.h
+ */
+
+#include "types.h"
+
+typedef struct bd_info {
+	unsigned long	bi_memstart;	/* start of DRAM memory */
+	unsigned long	bi_memsize;	/* size	 of DRAM memory in bytes */
+	unsigned long	bi_flashstart;	/* start of FLASH memory */
+	unsigned long	bi_flashsize;	/* size	 of FLASH memory */
+	unsigned long	bi_flashoffset; /* reserved area for startup monitor */
+	unsigned long	bi_sramstart;	/* start of SRAM memory */
+	unsigned long	bi_sramsize;	/* size	 of SRAM memory */
+#if defined(TARGET_8xx) || defined(TARGET_CPM2) || defined(TARGET_85xx) ||\
+	defined(TARGET_83xx)
+	unsigned long	bi_immr_base;	/* base of IMMR register */
+#endif
+#if defined(TARGET_PPC_MPC52xx)
+	unsigned long   bi_mbar_base;   /* base of internal registers */
+#endif
+	unsigned long	bi_bootflags;	/* boot / reboot flag (for LynxOS) */
+	unsigned long	bi_ip_addr;	/* IP Address */
+	unsigned char	bi_enetaddr[6];	/* Ethernet address */
+	unsigned short	bi_ethspeed;	/* Ethernet speed in Mbps */
+	unsigned long	bi_intfreq;	/* Internal Freq, in MHz */
+	unsigned long	bi_busfreq;	/* Bus Freq, in MHz */
+#if defined(TARGET_CPM2)
+	unsigned long	bi_cpmfreq;	/* CPM_CLK Freq, in MHz */
+	unsigned long	bi_brgfreq;	/* BRG_CLK Freq, in MHz */
+	unsigned long	bi_sccfreq;	/* SCC_CLK Freq, in MHz */
+	unsigned long	bi_vco;		/* VCO Out from PLL, in MHz */
+#endif
+#if defined(TARGET_PPC_MPC52xx)
+	unsigned long   bi_ipbfreq;     /* IPB Bus Freq, in MHz */
+	unsigned long   bi_pcifreq;     /* PCI Bus Freq, in MHz */
+#endif
+	unsigned long	bi_baudrate;	/* Console Baudrate */
+#if defined(TARGET_4xx)
+	unsigned char	bi_s_version[4];	/* Version of this structure */
+	unsigned char	bi_r_version[32];	/* Version of the ROM (IBM) */
+	unsigned int	bi_procfreq;	/* CPU (Internal) Freq, in Hz */
+	unsigned int	bi_plb_busfreq;	/* PLB Bus speed, in Hz */
+	unsigned int	bi_pci_busfreq;	/* PCI Bus speed, in Hz */
+	unsigned char	bi_pci_enetaddr[6];	/* PCI Ethernet MAC address */
+#endif
+#if defined(TARGET_HYMOD)
+	hymod_conf_t	bi_hymod_conf;	/* hymod configuration information */
+#endif
+#if defined(TARGET_EVB64260) || defined(TARGET_405EP) || defined(TARGET_44x) || \
+	defined(TARGET_85xx) ||	defined(TARGET_83xx)
+	/* second onboard ethernet port */
+	unsigned char	bi_enet1addr[6];
+#define HAVE_ENET1ADDR
+#endif
+#if defined(TARGET_EVB64260) || defined(TARGET_440GX) || defined(TARGET_85xx)
+	/* third onboard ethernet ports */
+	unsigned char	bi_enet2addr[6];
+#define HAVE_ENET2ADDR
+#endif
+#if defined(TARGET_440GX)
+	/* fourth onboard ethernet ports */
+	unsigned char	bi_enet3addr[6];
+#define HAVE_ENET3ADDR
+#endif
+#if defined(TARGET_4xx)
+	unsigned int	bi_opbfreq;		/* OB clock in Hz */
+	int		bi_iic_fast[2];		/* Use fast i2c mode */
+#endif
+#if defined(TARGET_440GX)
+	int		bi_phynum[4];		/* phy mapping */
+	int		bi_phymode[4];		/* phy mode */
+#endif
+} bd_t;
+
+#define bi_tbfreq	bi_intfreq
+
+#endif	/* __PPCBOOT_H__ */
-- 
1.5.0.3

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

* [PATCH 3/6] bootwrapper: Add support for cuboot platforms.
  2007-03-22 19:46 [PATCH 0/6] bootwrapper/cuboot Scott Wood
  2007-03-22 19:49 ` [PATCH 1/6] bootwrapper: Add dt_xlate_reg(), and use it to find serial registers Scott Wood
  2007-03-22 19:49 ` [PATCH 2/6] bootwrapper: Add ppcboot.h Scott Wood
@ 2007-03-22 19:49 ` Scott Wood
  2007-03-23  5:25   ` David Gibson
  2007-03-22 19:49 ` [PATCH 4/6] bootwrapper: Add CONFIG_DEVICE_TREE Scott Wood
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Scott Wood @ 2007-03-22 19:49 UTC (permalink / raw)
  To: linuxppc-dev

Platforms beginning with "cuboot" have the bootwrapper code built in,
unlike the regular uboot platform.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/wrapper |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index f9238f5..1c666f9 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -141,6 +141,9 @@ miboot|uboot)
     ksection=image
     isection=initrd
     ;;
+cuboot*)
+    gzip=
+    ;;
 esac
 
 vmz="$tmpdir/`basename \"$kernel\"`.$ext"
@@ -161,13 +164,17 @@ fi
 vmz="$vmz$gzip"
 
 case "$platform" in
-uboot)
-    rm -f "$ofile"
+uboot|cuboot*)
     version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \
 	cut -d' ' -f3`
     if [ -n "$version" ]; then
 	version="-n Linux-$version"
     fi
+esac
+
+case "$platform" in
+uboot)
+    rm -f "$ofile"
     mkimage -A ppc -O linux -T kernel -C gzip -a 00000000 -e 00000000 \
 	$version -d "$vmz" "$ofile"
     if [ -z "$cacheit" ]; then
@@ -216,4 +223,14 @@ pmaccoff)
     ${CROSS}objcopy -O aixcoff-rs6000 --set-start "$entry" "$ofile"
     $object/hack-coff "$ofile"
     ;;
+cuboot*)
+    base=`${CROSS}nm "$ofile" | grep ' _start$' | cut -d' ' -f1`
+    entry=`${CROSS}objdump -f "$ofile" | grep '^start address ' | \
+           cut -d' ' -f3`
+    mv "$ofile" "$ofile".elf
+    ${CROSS}objcopy -O binary "$ofile".elf "$ofile".bin
+    gzip -f -9 "$ofile".bin
+    mkimage -A ppc -O linux -T kernel -C gzip -a "$base" -e "$entry" \
+            $version -d "$ofile".bin.gz "$ofile"
+    ;;
 esac
-- 
1.5.0.3

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

* [PATCH 4/6] bootwrapper: Add CONFIG_DEVICE_TREE
  2007-03-22 19:46 [PATCH 0/6] bootwrapper/cuboot Scott Wood
                   ` (2 preceding siblings ...)
  2007-03-22 19:49 ` [PATCH 3/6] bootwrapper: Add support for cuboot platforms Scott Wood
@ 2007-03-22 19:49 ` Scott Wood
  2007-03-22 19:49 ` [PATCH 5/6] bootwrapper: Add a cuImage target Scott Wood
  2007-03-22 19:49 ` [PATCH 6/6] bootwrapper: cuboot for 83xx Scott Wood
  5 siblings, 0 replies; 18+ messages in thread
From: Scott Wood @ 2007-03-22 19:49 UTC (permalink / raw)
  To: linuxppc-dev

This provides a way to tell the bootwrapper makefile which
device tree to include.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/Kconfig |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e720527..2f8f05b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -967,6 +967,22 @@ config SECCOMP
 
 	  If unsure, say Y. Only embedded should say N here.
 
+config DEVICE_TREE
+	string "Static device tree source file"
+	help
+	  This specifies the device tree source (.dts) file to be
+	  compiled and included when building the bootwrapper.
+	  If a relative filename is given, then it will be relative
+	  to arch/powerpc/boot/dts.
+
+	  This is required when building a cuImage target for an
+	  older U-Boot, which cannot pass a device tree itself.
+	  Such a kernel will not work with a newer U-Boot that
+	  tries to pass a device tree (unless you tell it not to).
+	  If your U-Boot does not mention a device tree in
+	  "help bootm", then use the cuImage target and specify
+	  a device tree here.  Otherwise, use the uImage target.
+
 endmenu
 
 config ISA_DMA_API
-- 
1.5.0.3

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

* [PATCH 5/6] bootwrapper: Add a cuImage target.
  2007-03-22 19:46 [PATCH 0/6] bootwrapper/cuboot Scott Wood
                   ` (3 preceding siblings ...)
  2007-03-22 19:49 ` [PATCH 4/6] bootwrapper: Add CONFIG_DEVICE_TREE Scott Wood
@ 2007-03-22 19:49 ` Scott Wood
  2007-03-23  5:40   ` David Gibson
  2007-03-22 19:49 ` [PATCH 6/6] bootwrapper: cuboot for 83xx Scott Wood
  5 siblings, 1 reply; 18+ messages in thread
From: Scott Wood @ 2007-03-22 19:49 UTC (permalink / raw)
  To: linuxppc-dev

The cuImage target calls the wrapper with a cuboot platform chosen
based on the kernel config, as opposed to the uboot platform.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/Makefile        |    2 +-
 arch/powerpc/boot/.gitignore |    3 +++
 arch/powerpc/boot/Makefile   |   13 +++++++++++--
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a00fe72..e6c3add 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -148,7 +148,7 @@ all: $(KBUILD_IMAGE)
 
 CPPFLAGS_vmlinux.lds	:= -Upowerpc
 
-BOOT_TARGETS = zImage zImage.initrd uImage
+BOOT_TARGETS = zImage zImage.initrd uImage cuImage
 
 PHONY += $(BOOT_TARGETS)
 
diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
index 0734b2f..eec7af7 100644
--- a/arch/powerpc/boot/.gitignore
+++ b/arch/powerpc/boot/.gitignore
@@ -18,6 +18,9 @@ kernel-vmlinux.strip.c
 kernel-vmlinux.strip.gz
 mktree
 uImage
+cuImage
+cuImage.bin.gz
+cuImage.elf
 zImage
 zImage.chrp
 zImage.coff
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 43179b4..93c25f8 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -43,7 +43,8 @@ $(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) \
 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) devtree.c
-src-plat := of.c
+cuboot-plats :=
+src-plat := of.c $(cuboot-plats:%=cuboot-%.c)
 src-boot := $(src-wlib) $(src-plat) empty.c
 
 src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -129,7 +130,7 @@ image-$(CONFIG_PPC_CELLEB)		+= zImage.pseries
 image-$(CONFIG_PPC_CHRP)		+= zImage.chrp
 image-$(CONFIG_PPC_EFIKA)		+= zImage.chrp
 image-$(CONFIG_PPC_PMAC)		+= zImage.pmac
-image-$(CONFIG_DEFAULT_UIMAGE)		+= uImage
+image-$(CONFIG_DEFAULT_UIMAGE)		+= uImage cuImage
 
 # For 32-bit powermacs, build the COFF and miboot images
 # as well as the ELF images.
@@ -162,6 +163,14 @@ $(obj)/zImage.initrd.ps3: vmlinux
 $(obj)/uImage: vmlinux $(wrapperbits)
 	$(call if_changed,wrap,uboot)
 
+cuboot-plat-y += unknown-platform
+
+dts = $(if $(shell echo $(CONFIG_) | grep '^/'),\
+       ,$(srctree)/$(src)/dts/)$(CONFIG_DEVICE_TREE)
+
+$(obj)/cuImage: vmlinux $(wrapperbits)
+	$(call if_changed,wrap,cuboot-$(word 1,$(cuboot-plat-y)),$(dts))
+
 $(obj)/zImage:		$(addprefix $(obj)/, $(image-y))
 	@rm -f $@; ln $< $@
 $(obj)/zImage.initrd:	$(addprefix $(obj)/, $(initrd-y))
-- 
1.5.0.3

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

* [PATCH 6/6] bootwrapper: cuboot for 83xx
  2007-03-22 19:46 [PATCH 0/6] bootwrapper/cuboot Scott Wood
                   ` (4 preceding siblings ...)
  2007-03-22 19:49 ` [PATCH 5/6] bootwrapper: Add a cuImage target Scott Wood
@ 2007-03-22 19:49 ` Scott Wood
  2007-03-23  5:54   ` David Gibson
  5 siblings, 1 reply; 18+ messages in thread
From: Scott Wood @ 2007-03-22 19:49 UTC (permalink / raw)
  To: linuxppc-dev

This adds cuboot support for MPC83xx platforms.

A device tree used with this must have linux,stdout-path in /chosen and
linux,network-index in any network device nodes that need mac addresses
assigned.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/Makefile      |    3 +-
 arch/powerpc/boot/cuboot-83xx.c |   70 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 1 deletions(-)
 create mode 100644 arch/powerpc/boot/cuboot-83xx.c

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 93c25f8..1c6c2e1 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -43,7 +43,7 @@ $(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) \
 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) devtree.c
-cuboot-plats :=
+cuboot-plats := 83xx
 src-plat := of.c $(cuboot-plats:%=cuboot-%.c)
 src-boot := $(src-wlib) $(src-plat) empty.c
 
@@ -163,6 +163,7 @@ $(obj)/zImage.initrd.ps3: vmlinux
 $(obj)/uImage: vmlinux $(wrapperbits)
 	$(call if_changed,wrap,uboot)
 
+cuboot-plat-$(CONFIG_83xx) += 83xx
 cuboot-plat-y += unknown-platform
 
 dts = $(if $(shell echo $(CONFIG_) | grep '^/'),\
diff --git a/arch/powerpc/boot/cuboot-83xx.c b/arch/powerpc/boot/cuboot-83xx.c
new file mode 100644
index 0000000..76895a7
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-83xx.c
@@ -0,0 +1,70 @@
+/*
+ * Old U-boot compatibility for 83xx
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "ops.h"
+#include "stdio.h"
+
+#define TARGET_83xx
+#include "ppcboot.h"
+
+static bd_t bd;
+extern char _end[];
+extern char _dtb_start[], _dtb_end[];
+
+static void *vmlinux_alloc(unsigned long size)
+{
+	void *p = malloc(size);
+
+	if (!p)
+		fatal("Can't allocate memory for kernel image!\n\r");
+
+	return p;
+}
+
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+                   unsigned long r6, unsigned long r7)
+{
+	unsigned long end_of_ram = bd.bi_memstart + bd.bi_memsize;
+	unsigned long avail_ram = end_of_ram - (unsigned long)_end;
+	void *soc;
+
+	memcpy(&bd, (bd_t *)r3, sizeof(bd));
+	loader_info.initrd_addr = r4;
+	loader_info.initrd_size = r4 ? r5 : 0;
+	loader_info.cmdline = (char *)r6;
+	loader_info.cmdline_len = r7 - r6;
+
+	simple_alloc_init(_end, avail_ram, 32, 64);
+	ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
+	serial_console_init();
+	platform_ops.vmlinux_alloc = vmlinux_alloc;
+
+	dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
+	dt_fixup_mac_addresses(bd.bi_enetaddr, bd.bi_enet1addr);
+	dt_fixup_cpu_clocks(bd.bi_intfreq, bd.bi_busfreq / 4, bd.bi_busfreq);
+
+	soc = find_node_by_devtype(NULL, "soc");
+	if (soc) {
+		void *serial = NULL;
+
+		setprop(soc, "bus-frequency", &bd.bi_busfreq,
+		        sizeof(bd.bi_busfreq));
+
+		while ((serial = find_node_by_devtype(serial, "serial"))) {
+			if (get_parent(serial) != soc)
+				continue;
+
+			setprop(serial, "clock-frequency", &bd.bi_busfreq,
+			        sizeof(bd.bi_busfreq));
+		}
+	}
+}
-- 
1.5.0.3

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

* Re: [PATCH 3/6] bootwrapper: Add support for cuboot platforms.
  2007-03-22 19:49 ` [PATCH 3/6] bootwrapper: Add support for cuboot platforms Scott Wood
@ 2007-03-23  5:25   ` David Gibson
  0 siblings, 0 replies; 18+ messages in thread
From: David Gibson @ 2007-03-23  5:25 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

On Thu, Mar 22, 2007 at 02:49:24PM -0500, Scott Wood wrote:
> Platforms beginning with "cuboot" have the bootwrapper code built in,
> unlike the regular uboot platform.

I think 3, 4 and 5 of this series should be merged into a single
patch.  They're not much use without each other.

-- 
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] 18+ messages in thread

* Re: [PATCH 5/6] bootwrapper: Add a cuImage target.
  2007-03-22 19:49 ` [PATCH 5/6] bootwrapper: Add a cuImage target Scott Wood
@ 2007-03-23  5:40   ` David Gibson
  2007-03-23 15:18     ` Scott Wood
  0 siblings, 1 reply; 18+ messages in thread
From: David Gibson @ 2007-03-23  5:40 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

On Thu, Mar 22, 2007 at 02:49:28PM -0500, Scott Wood wrote:
> The cuImage target calls the wrapper with a cuboot platform chosen
> based on the kernel config, as opposed to the uboot platform.
> 
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
>  arch/powerpc/Makefile        |    2 +-
>  arch/powerpc/boot/.gitignore |    3 +++
>  arch/powerpc/boot/Makefile   |   13 +++++++++++--
>  3 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index a00fe72..e6c3add 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -148,7 +148,7 @@ all: $(KBUILD_IMAGE)
>  
>  CPPFLAGS_vmlinux.lds	:= -Upowerpc
>  
> -BOOT_TARGETS = zImage zImage.initrd uImage
> +BOOT_TARGETS = zImage zImage.initrd uImage cuImage
>  
>  PHONY += $(BOOT_TARGETS)
>  
> diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
> index 0734b2f..eec7af7 100644
> --- a/arch/powerpc/boot/.gitignore
> +++ b/arch/powerpc/boot/.gitignore
> @@ -18,6 +18,9 @@ kernel-vmlinux.strip.c
>  kernel-vmlinux.strip.gz
>  mktree
>  uImage
> +cuImage
> +cuImage.bin.gz
> +cuImage.elf
>  zImage
>  zImage.chrp
>  zImage.coff
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index 43179b4..93c25f8 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -43,7 +43,8 @@ $(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) \
>  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) devtree.c
> -src-plat := of.c
> +cuboot-plats :=
> +src-plat := of.c $(cuboot-plats:%=cuboot-%.c)

Rather than this special cuboot-plats stuff, I suggest you just list
each cuboot platform in src-plat independently.  We can also git rid
of the need for a CONFIG option specifying the dts (and thereby taking
us back to the one-config-per-board era) by using rules like:

$(obj)/uImage.83xx.%: vmlinux $(wrapperbits) $(srctree)/$(src)/dts/%.dts
	$(call if_changed,wrap,cuboot-83xx,$(srctree)/$(src)/dts/$*)

And to get the right things built use something like:
image-$(CONFIG-83xx)	+= $(mpx83xx-boards:%=uImage.83xx.%)

Or optionally add a batch of bool config options for each board
variant.

-- 
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] 18+ messages in thread

* Re: [PATCH 6/6] bootwrapper: cuboot for 83xx
  2007-03-22 19:49 ` [PATCH 6/6] bootwrapper: cuboot for 83xx Scott Wood
@ 2007-03-23  5:54   ` David Gibson
  2007-03-23 15:30     ` Scott Wood
  0 siblings, 1 reply; 18+ messages in thread
From: David Gibson @ 2007-03-23  5:54 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

On Thu, Mar 22, 2007 at 02:49:30PM -0500, Scott Wood wrote:
> This adds cuboot support for MPC83xx platforms.
> 
> A device tree used with this must have linux,stdout-path in /chosen and
> linux,network-index in any network device nodes that need mac addresses
> assigned.

[snip]
> +++ b/arch/powerpc/boot/cuboot-83xx.c
> @@ -0,0 +1,70 @@
> +/*
> + * Old U-boot compatibility for 83xx
> + *
> + * Author: Scott Wood <scottwood@freescale.com>
> + *
> + * Copyright (c) 2007 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License version 2 as published
> + * by the Free Software Foundation.
> + */
> +
> +#include "ops.h"
> +#include "stdio.h"
> +
> +#define TARGET_83xx
> +#include "ppcboot.h"
> +
> +static bd_t bd;
> +extern char _end[];
> +extern char _dtb_start[], _dtb_end[];
> +
> +static void *vmlinux_alloc(unsigned long size)
> +{
> +	void *p = malloc(size);
> +
> +	if (!p)
> +		fatal("Can't allocate memory for kernel image!\n\r");
> +
> +	return p;
> +}

I don't think you should need a vmlinux_alloc for this platform.

> +void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
> +                   unsigned long r6, unsigned long r7)
> +{
> +	unsigned long end_of_ram = bd.bi_memstart + bd.bi_memsize;
> +	unsigned long avail_ram = end_of_ram - (unsigned long)_end;
> +	void *soc;
> +
> +	memcpy(&bd, (bd_t *)r3, sizeof(bd));
> +	loader_info.initrd_addr = r4;
> +	loader_info.initrd_size = r4 ? r5 : 0;
> +	loader_info.cmdline = (char *)r6;
> +	loader_info.cmdline_len = r7 - r6;
> +
> +	simple_alloc_init(_end, avail_ram, 32, 64);
> +	ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
> +	serial_console_init();
> +	platform_ops.vmlinux_alloc = vmlinux_alloc;


I think this should be the end of platform_init.  The actual device
tree mangling should instead be done from the .fixups hook function.
The simple reason is that in general we want to defer as much as
possible until after the console_open so that we can get error
messages.  The more complicated reason is that looking ahead to when
we're using libfdt instead of flatdevtree.c, we may need an extra step
that prepares the device tree for read/write access (with libfdt, an
fdt_open_into()).  That won't happen until after platform_init(), but
will be before .fixups().

> +	dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
> +	dt_fixup_mac_addresses(bd.bi_enetaddr, bd.bi_enet1addr);
> +	dt_fixup_cpu_clocks(bd.bi_intfreq, bd.bi_busfreq / 4, bd.bi_busfreq);
> +
> +	soc = find_node_by_devtype(NULL, "soc");

Hrm... more-or-less by definition, cuboot will be using the device
trees included in the kernel tree.  So why can't we just fix the mpc
device trees so the soc node is just called "/soc" instead of having to
use this find by type stuff.

> +	if (soc) {
> +		void *serial = NULL;
> +
> +		setprop(soc, "bus-frequency", &bd.bi_busfreq,
> +		        sizeof(bd.bi_busfreq));

This should probably just be 'clock-frequency' on the soc node (since
the soc node represents the on-chip bus).  But to fix that I guess
we'd need parallel changes to the kernel proper.

> +		while ((serial = find_node_by_devtype(serial, "serial"))) {
> +			if (get_parent(serial) != soc)
> +				continue;
> +
> +			setprop(serial, "clock-frequency", &bd.bi_busfreq,
> +			        sizeof(bd.bi_busfreq));
> +		}
> +	}
> +}

-- 
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] 18+ messages in thread

* Re: [PATCH 5/6] bootwrapper: Add a cuImage target.
  2007-03-23  5:40   ` David Gibson
@ 2007-03-23 15:18     ` Scott Wood
  2007-03-23 23:39       ` David Gibson
  0 siblings, 1 reply; 18+ messages in thread
From: Scott Wood @ 2007-03-23 15:18 UTC (permalink / raw)
  To: linuxppc-dev

On Fri, Mar 23, 2007 at 04:40:48PM +1100, David Gibson wrote:
> > +cuboot-plats :=
> > +src-plat := of.c $(cuboot-plats:%=cuboot-%.c)
> 
> Rather than this special cuboot-plats stuff, I suggest you just list
> each cuboot platform in src-plat independently.

OK, I suppose the number of platforms will be few enough for that.

> We can also git rid of the need for a CONFIG option specifying the dts
> (and thereby taking us back to the one-config-per-board era) by using
> rules like:
> 
> $(obj)/uImage.83xx.%: vmlinux $(wrapperbits) $(srctree)/$(src)/dts/%.dts
> 	$(call if_changed,wrap,cuboot-83xx,$(srctree)/$(src)/dts/$*)

But then you can't build with an out-of-tree dts.  It's not a huge deal,
but still...  What's wrong with a config option?

> And to get the right things built use something like:
> image-$(CONFIG-83xx)	+= $(mpx83xx-boards:%=uImage.83xx.%)

And then I'd have to determine which boards are supported by the kernel
that was built, so I don't trick the user into thinking that valid images
were produced for every single 83xx.  I'd also have to enumerate every
single board in the makefile, which would suck.

> Or optionally add a batch of bool config options for each board
> variant.

I don't want to do that.  There shouldn't have to be a 1-1 correspondence
between each dts file and anything in the kernel.

-Scott

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

* Re: [PATCH 6/6] bootwrapper: cuboot for 83xx
  2007-03-23  5:54   ` David Gibson
@ 2007-03-23 15:30     ` Scott Wood
  2007-03-23 23:37       ` David Gibson
  0 siblings, 1 reply; 18+ messages in thread
From: Scott Wood @ 2007-03-23 15:30 UTC (permalink / raw)
  To: linuxppc-dev

On Fri, Mar 23, 2007 at 04:54:42PM +1100, David Gibson wrote:
> I don't think you should need a vmlinux_alloc for this platform.

Without it, the kernel has to fit in 4MiB.  As others pointed out, that
can be too small if an initramfs is used.  Unlike 8xx (which was what
caused me to stick the kernel at 0 in previous patches), 83xx platforms
should have plenty of memory above the wrapper.

In fact, it should probably be the default to use ordinary malloc for the
vmlinux, at least if it doesn't fit at 0.  If a platform *needs* it at
zero, it can supply a vmlinux_alloc that always either returns 0 or
fails.

> > +	simple_alloc_init(_end, avail_ram, 32, 64);
> > +	ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
> > +	serial_console_init();
> > +	platform_ops.vmlinux_alloc = vmlinux_alloc;
> 
> 
> I think this should be the end of platform_init.  The actual device
> tree mangling should instead be done from the .fixups hook function.
> The simple reason is that in general we want to defer as much as
> possible until after the console_open so that we can get error
> messages. 

Serial output with ns16550.c works after serial_console_init() even
before open() is called, but I agree in principle.

> The more complicated reason is that looking ahead to when we're using
> libfdt instead of flatdevtree.c, we may need an extra step that
> prepares the device tree for read/write access (with libfdt, an
> fdt_open_into()).  That won't happen until after platform_init(), but
> will be before .fixups().

OK.

> > +	dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
> > +	dt_fixup_mac_addresses(bd.bi_enetaddr, bd.bi_enet1addr);
> > +	dt_fixup_cpu_clocks(bd.bi_intfreq, bd.bi_busfreq / 4, bd.bi_busfreq);
> > +
> > +	soc = find_node_by_devtype(NULL, "soc");
> 
> Hrm... more-or-less by definition, cuboot will be using the device
> trees included in the kernel tree.  So why can't we just fix the mpc
> device trees so the soc node is just called "/soc" instead of having to
> use this find by type stuff.

I'm not sure that it's true that only in-tree device trees would be used
-- I can imagine customers having old firmware on custom boards that
would like to upgrade the kernel, but do not want to upgrade the
firmware.

I'd be happy to see the name be changed to just be "/soc", though it
would require u-boot changes.

> > +	if (soc) {
> > +		void *serial = NULL;
> > +
> > +		setprop(soc, "bus-frequency", &bd.bi_busfreq,
> > +		        sizeof(bd.bi_busfreq));
> 
> This should probably just be 'clock-frequency' on the soc node (since
> the soc node represents the on-chip bus).  But to fix that I guess
> we'd need parallel changes to the kernel proper.

And to u-boot, if we don't want to have to support both properties.

-Scott

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

* Re: [PATCH 6/6] bootwrapper: cuboot for 83xx
  2007-03-23 15:30     ` Scott Wood
@ 2007-03-23 23:37       ` David Gibson
  2007-03-26 15:53         ` Scott Wood
  2007-04-04  2:06         ` Mark A. Greer
  0 siblings, 2 replies; 18+ messages in thread
From: David Gibson @ 2007-03-23 23:37 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

On Fri, Mar 23, 2007 at 10:30:56AM -0500, Scott Wood wrote:
> On Fri, Mar 23, 2007 at 04:54:42PM +1100, David Gibson wrote:
> > I don't think you should need a vmlinux_alloc for this platform.
> 
> Without it, the kernel has to fit in 4MiB.  As others pointed out, that
> can be too small if an initramfs is used.  Unlike 8xx (which was what
> caused me to stick the kernel at 0 in previous patches), 83xx platforms
> should have plenty of memory above the wrapper.

I think we ought to be able to find a better way.  Thing is, when we
have a huge initramfs/kernel is the same case that having the kernel
relocate itself hurts the most.

Is there any reasonable way we can determine the memory size early
enough for the zImage to relocate itself to (approximately) the top of
RAM first thing?

Or we could get the wrapper script to base the link/load address on
the vmlinux size.

> In fact, it should probably be the default to use ordinary malloc for the
> vmlinux, at least if it doesn't fit at 0.  If a platform *needs* it at
> zero, it can supply a vmlinux_alloc that always either returns 0 or
> fails.

I'd actually really like to get rid of malloc() from the zImage
entirely.  I think it's possible when we switch to libfdt..

> > > +	simple_alloc_init(_end, avail_ram, 32, 64);
> > > +	ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
> > > +	serial_console_init();
> > > +	platform_ops.vmlinux_alloc = vmlinux_alloc;
> > 
> > 
> > I think this should be the end of platform_init.  The actual device
> > tree mangling should instead be done from the .fixups hook function.
> > The simple reason is that in general we want to defer as much as
> > possible until after the console_open so that we can get error
> > messages. 
> 
> Serial output with ns16550.c works after serial_console_init() even
> before open() is called, but I agree in principle.

Yes I know, but I'm making the suggestion in principle ;-).

> > The more complicated reason is that looking ahead to when we're using
> > libfdt instead of flatdevtree.c, we may need an extra step that
> > prepares the device tree for read/write access (with libfdt, an
> > fdt_open_into()).  That won't happen until after platform_init(), but
> > will be before .fixups().
> 
> OK.

Actually, to be clearer here: this reason actually degenerates to the
first; I want the "ft_open" step to go after console_open so we can
get error messages from it.

> > > +	dt_fixup_memory(bd.bi_memstart, bd.bi_memsize);
> > > +	dt_fixup_mac_addresses(bd.bi_enetaddr, bd.bi_enet1addr);
> > > +	dt_fixup_cpu_clocks(bd.bi_intfreq, bd.bi_busfreq / 4, bd.bi_busfreq);
> > > +
> > > +	soc = find_node_by_devtype(NULL, "soc");
> > 
> > Hrm... more-or-less by definition, cuboot will be using the device
> > trees included in the kernel tree.  So why can't we just fix the mpc
> > device trees so the soc node is just called "/soc" instead of having to
> > use this find by type stuff.
> 
> I'm not sure that it's true that only in-tree device trees would be used
> -- I can imagine customers having old firmware on custom boards that
> would like to upgrade the kernel, but do not want to upgrade the
> firmware.

Um.. since the zImage's tree comes from the kernel, what does
upgrading the firmware have to do with it?

> I'd be happy to see the name be changed to just be "/soc", though it
> would require u-boot changes.

Err.. why?

> > > +	if (soc) {
> > > +		void *serial = NULL;
> > > +
> > > +		setprop(soc, "bus-frequency", &bd.bi_busfreq,
> > > +		        sizeof(bd.bi_busfreq));
> > 
> > This should probably just be 'clock-frequency' on the soc node (since
> > the soc node represents the on-chip bus).  But to fix that I guess
> > we'd need parallel changes to the kernel proper.
> 
> And to u-boot, if we don't want to have to support both properties.

-- 
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] 18+ messages in thread

* Re: [PATCH 5/6] bootwrapper: Add a cuImage target.
  2007-03-23 15:18     ` Scott Wood
@ 2007-03-23 23:39       ` David Gibson
  0 siblings, 0 replies; 18+ messages in thread
From: David Gibson @ 2007-03-23 23:39 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

On Fri, Mar 23, 2007 at 10:18:36AM -0500, Scott Wood wrote:
> On Fri, Mar 23, 2007 at 04:40:48PM +1100, David Gibson wrote:
> > > +cuboot-plats :=
> > > +src-plat := of.c $(cuboot-plats:%=cuboot-%.c)
> > 
> > Rather than this special cuboot-plats stuff, I suggest you just list
> > each cuboot platform in src-plat independently.
> 
> OK, I suppose the number of platforms will be few enough for that.
> 
> > We can also git rid of the need for a CONFIG option specifying the dts
> > (and thereby taking us back to the one-config-per-board era) by using
> > rules like:
> > 
> > $(obj)/uImage.83xx.%: vmlinux $(wrapperbits) $(srctree)/$(src)/dts/%.dts
> > 	$(call if_changed,wrap,cuboot-83xx,$(srctree)/$(src)/dts/$*)
> 
> But then you can't build with an out-of-tree dts.  It's not a huge deal,
> but still...  What's wrong with a config option?

Because it takes us back to reconfigure the kernel for each different
device tree, even though both the vmlinux and the zImage can run
happily on multiple device trees.

> > And to get the right things built use something like:
> > image-$(CONFIG-83xx)	+= $(mpx83xx-boards:%=uImage.83xx.%)
> 
> And then I'd have to determine which boards are supported by the kernel
> that was built, so I don't trick the user into thinking that valid images
> were produced for every single 83xx.  I'd also have to enumerate every
> single board in the makefile, which would suck.

Hrm, yeah that is a bit sucky.  Could we use a wildcard?  Or make
per-platform subdirectories of arch/powerpc/boot/dts?

> > Or optionally add a batch of bool config options for each board
> > variant.
> 
> I don't want to do that.  There shouldn't have to be a 1-1 correspondence
> between each dts file and anything in the kernel.

Yeah, fair enough.

-- 
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] 18+ messages in thread

* Re: [PATCH 6/6] bootwrapper: cuboot for 83xx
  2007-03-23 23:37       ` David Gibson
@ 2007-03-26 15:53         ` Scott Wood
  2007-04-04  2:06         ` Mark A. Greer
  1 sibling, 0 replies; 18+ messages in thread
From: Scott Wood @ 2007-03-26 15:53 UTC (permalink / raw)
  To: linuxppc-dev

On Sat, Mar 24, 2007 at 10:37:12AM +1100, David Gibson wrote:
> Is there any reasonable way we can determine the memory size early
> enough for the zImage to relocate itself to (approximately) the top of
> RAM first thing?

We can with cuboot (and it's at the beginning of the bd_t, so it's not
affected by the ifdef mess), but some platforms might require accessing
the device tree to get that information.

> Or we could get the wrapper script to base the link/load address on
> the vmlinux size.

That'd be nice.

> > I'm not sure that it's true that only in-tree device trees would be used
> > -- I can imagine customers having old firmware on custom boards that
> > would like to upgrade the kernel, but do not want to upgrade the
> > firmware.
> 
> Um.. since the zImage's tree comes from the kernel, what does
> upgrading the firmware have to do with it?

My point was simply that it's not just the reference boards with
in-kernel dts files that this would be useful on.  Thus, it makes sense
to allow out-of-tree dts files.

> > I'd be happy to see the name be changed to just be "/soc", though it
> > would require u-boot changes.
> 
> Err.. why?

So we don't have to partition the dts files into "works with cuimage" and
"works with dt-aware u-boot".  U-boot has hardcoded references to the soc
node with model number.

-Scott

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

* Re: [PATCH 6/6] bootwrapper: cuboot for 83xx
  2007-03-23 23:37       ` David Gibson
  2007-03-26 15:53         ` Scott Wood
@ 2007-04-04  2:06         ` Mark A. Greer
  2007-04-04  6:38           ` David Gibson
  1 sibling, 1 reply; 18+ messages in thread
From: Mark A. Greer @ 2007-04-04  2:06 UTC (permalink / raw)
  To: Scott Wood, linuxppc-dev

On Sat, Mar 24, 2007 at 10:37:12AM +1100, David Gibson wrote:
> On Fri, Mar 23, 2007 at 10:30:56AM -0500, Scott Wood wrote:
> > On Fri, Mar 23, 2007 at 04:54:42PM +1100, David Gibson wrote:
> > > I don't think you should need a vmlinux_alloc for this platform.
> > 
> > Without it, the kernel has to fit in 4MiB.  As others pointed out, that
> > can be too small if an initramfs is used.  Unlike 8xx (which was what
> > caused me to stick the kernel at 0 in previous patches), 83xx platforms
> > should have plenty of memory above the wrapper.

> Or we could get the wrapper script to base the link/load address on
> the vmlinux size.

That might be handy for some but it won't work for everyone.  Some
platforms require a specific link/load address.  We can provide what
you said as a default but allow it to be overridden by platform code
somehow.

> > > The more complicated reason is that looking ahead to when we're using
> > > libfdt instead of flatdevtree.c, we may need an extra step that
> > > prepares the device tree for read/write access (with libfdt, an
> > > fdt_open_into()).  That won't happen until after platform_init(), but
> > > will be before .fixups().
> > 
> > OK.
> 
> Actually, to be clearer here: this reason actually degenerates to the
> first; I want the "ft_open" step to go after console_open so we can
> get error messages from it.

The problem is,  the console device is specified in the dt so you have
to ft_open before you console_open.

Mark

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

* Re: [PATCH 6/6] bootwrapper: cuboot for 83xx
  2007-04-04  2:06         ` Mark A. Greer
@ 2007-04-04  6:38           ` David Gibson
  2007-04-04 16:01             ` Mark A. Greer
  0 siblings, 1 reply; 18+ messages in thread
From: David Gibson @ 2007-04-04  6:38 UTC (permalink / raw)
  To: Mark A. Greer; +Cc: linuxppc-dev

On Tue, Apr 03, 2007 at 07:06:29PM -0700, Mark A. Greer wrote:
> On Sat, Mar 24, 2007 at 10:37:12AM +1100, David Gibson wrote:
> > On Fri, Mar 23, 2007 at 10:30:56AM -0500, Scott Wood wrote:
> > > On Fri, Mar 23, 2007 at 04:54:42PM +1100, David Gibson wrote:
> > > > I don't think you should need a vmlinux_alloc for this platform.
> > > 
> > > Without it, the kernel has to fit in 4MiB.  As others pointed out, that
> > > can be too small if an initramfs is used.  Unlike 8xx (which was what
> > > caused me to stick the kernel at 0 in previous patches), 83xx platforms
> > > should have plenty of memory above the wrapper.
> 
> > Or we could get the wrapper script to base the link/load address on
> > the vmlinux size.
> 
> That might be handy for some but it won't work for everyone.  Some
> platforms require a specific link/load address.  We can provide what
> you said as a default but allow it to be overridden by platform code
> somehow.

Sure.  The wrapper already does platform dependent things, so I was
assuming it would only do this for some platforms.

> > > > The more complicated reason is that looking ahead to when we're using
> > > > libfdt instead of flatdevtree.c, we may need an extra step that
> > > > prepares the device tree for read/write access (with libfdt, an
> > > > fdt_open_into()).  That won't happen until after platform_init(), but
> > > > will be before .fixups().
> > > 
> > > OK.
> > 
> > Actually, to be clearer here: this reason actually degenerates to the
> > first; I want the "ft_open" step to go after console_open so we can
> > get error messages from it.
> 
> The problem is,  the console device is specified in the dt so you have
> to ft_open before you console_open.

Sorry, I should clarify.  In the context of libfdt, I was thinking
*read* access to the fdt can happen at any point - right from
platform_init().  ft_open() would mark the point at which write access
to the tree can begin.

-- 
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] 18+ messages in thread

* Re: [PATCH 6/6] bootwrapper: cuboot for 83xx
  2007-04-04  6:38           ` David Gibson
@ 2007-04-04 16:01             ` Mark A. Greer
  0 siblings, 0 replies; 18+ messages in thread
From: Mark A. Greer @ 2007-04-04 16:01 UTC (permalink / raw)
  To: Mark A. Greer, Scott Wood, linuxppc-dev

On Wed, Apr 04, 2007 at 04:38:34PM +1000, David Gibson wrote:
> On Tue, Apr 03, 2007 at 07:06:29PM -0700, Mark A. Greer wrote:
> > On Sat, Mar 24, 2007 at 10:37:12AM +1100, David Gibson wrote:
> > > On Fri, Mar 23, 2007 at 10:30:56AM -0500, Scott Wood wrote:

> > > Actually, to be clearer here: this reason actually degenerates to the
> > > first; I want the "ft_open" step to go after console_open so we can
> > > get error messages from it.
> > 
> > The problem is,  the console device is specified in the dt so you have
> > to ft_open before you console_open.
> 
> Sorry, I should clarify.  In the context of libfdt, I was thinking
> *read* access to the fdt can happen at any point - right from
> platform_init().  ft_open() would mark the point at which write access
> to the tree can begin.

Ah, okay.

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

end of thread, other threads:[~2007-04-04 16:00 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-22 19:46 [PATCH 0/6] bootwrapper/cuboot Scott Wood
2007-03-22 19:49 ` [PATCH 1/6] bootwrapper: Add dt_xlate_reg(), and use it to find serial registers Scott Wood
2007-03-22 19:49 ` [PATCH 2/6] bootwrapper: Add ppcboot.h Scott Wood
2007-03-22 19:49 ` [PATCH 3/6] bootwrapper: Add support for cuboot platforms Scott Wood
2007-03-23  5:25   ` David Gibson
2007-03-22 19:49 ` [PATCH 4/6] bootwrapper: Add CONFIG_DEVICE_TREE Scott Wood
2007-03-22 19:49 ` [PATCH 5/6] bootwrapper: Add a cuImage target Scott Wood
2007-03-23  5:40   ` David Gibson
2007-03-23 15:18     ` Scott Wood
2007-03-23 23:39       ` David Gibson
2007-03-22 19:49 ` [PATCH 6/6] bootwrapper: cuboot for 83xx Scott Wood
2007-03-23  5:54   ` David Gibson
2007-03-23 15:30     ` Scott Wood
2007-03-23 23:37       ` David Gibson
2007-03-26 15:53         ` Scott Wood
2007-04-04  2:06         ` Mark A. Greer
2007-04-04  6:38           ` David Gibson
2007-04-04 16:01             ` Mark A. Greer

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.