* [PATCH 1/5] bootwrapper: Add dt_xlate_reg(), and use it to find serial registers.
2007-03-26 20:51 [PATCH 0/5] bootwrapper: cuImage Scott Wood
@ 2007-03-26 20:52 ` Scott Wood
2007-03-26 20:52 ` [PATCH 2/5] bootwrapper: Add CONFIG_DEVICE_TREE Scott Wood
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Scott Wood @ 2007-03-26 20:52 UTC (permalink / raw)
To: paulus; +Cc: 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>
---
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", ®_base, sizeof(reg_base));
- if (n != sizeof(reg_base))
- return -1;
+ if (n != sizeof(reg_base)) {
+ if (!dt_xlate_reg(devp, 0, ®_phys, NULL))
+ return -1;
+
+ reg_base = (void *)reg_phys;
+ }
n = getprop(devp, "reg-shift", ®_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] 11+ messages in thread
* [PATCH 2/5] bootwrapper: Add CONFIG_DEVICE_TREE
2007-03-26 20:51 [PATCH 0/5] bootwrapper: cuImage Scott Wood
2007-03-26 20:52 ` [PATCH 1/5] bootwrapper: Add dt_xlate_reg(), and use it to find serial registers Scott Wood
@ 2007-03-26 20:52 ` Scott Wood
2007-04-12 4:42 ` Paul Mackerras
2007-03-26 20:52 ` [PATCH 3/5] bootwrapper: Add a cuboot platform and a cuImage target Scott Wood
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Scott Wood @ 2007-03-26 20:52 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
This provides a way to tell the bootwrapper makefile which device tree to
include by default. The wrapper can still be invoked standalone to wrap
with a different device tree without reconfiguring the kernel, if that is
desired.
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 20a8fdc..3b458e1 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -590,6 +590,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] 11+ messages in thread
* Re: [PATCH 2/5] bootwrapper: Add CONFIG_DEVICE_TREE
2007-03-26 20:52 ` [PATCH 2/5] bootwrapper: Add CONFIG_DEVICE_TREE Scott Wood
@ 2007-04-12 4:42 ` Paul Mackerras
2007-04-12 15:36 ` Scott Wood
0 siblings, 1 reply; 11+ messages in thread
From: Paul Mackerras @ 2007-04-12 4:42 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
Scott Wood writes:
> This provides a way to tell the bootwrapper makefile which device tree to
> include by default. The wrapper can still be invoked standalone to wrap
> with a different device tree without reconfiguring the kernel, if that is
> desired.
...
> +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.
Hmmm, I'm not sure that I want to be asked about CONFIG_DEVICE_TREE on
*all* powerpc platforms... Surely this option should depend on
something that says we're including support for a uBoot-able platform?
Paul.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] bootwrapper: Add CONFIG_DEVICE_TREE
2007-04-12 4:42 ` Paul Mackerras
@ 2007-04-12 15:36 ` Scott Wood
2007-04-12 16:11 ` Kumar Gala
0 siblings, 1 reply; 11+ messages in thread
From: Scott Wood @ 2007-04-12 15:36 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev
Paul Mackerras wrote:
> Hmmm, I'm not sure that I want to be asked about CONFIG_DEVICE_TREE on
> *all* powerpc platforms... Surely this option should depend on
> something that says we're including support for a uBoot-able platform?
That's how I originally had it, but I was asked to make it more general.
One non-uboot usage is Mark Greer's "Add Makefile rule to wrap dts
file in zImage" patch.
What about a CONFIG_WANT_DEVICE_TREE that platforms can select if they
want to ask the user for a device tree?
-Scott
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] bootwrapper: Add CONFIG_DEVICE_TREE
2007-04-12 15:36 ` Scott Wood
@ 2007-04-12 16:11 ` Kumar Gala
2007-04-12 16:17 ` Scott Wood
0 siblings, 1 reply; 11+ messages in thread
From: Kumar Gala @ 2007-04-12 16:11 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, Paul Mackerras
On Apr 12, 2007, at 10:36 AM, Scott Wood wrote:
> Paul Mackerras wrote:
>> Hmmm, I'm not sure that I want to be asked about
>> CONFIG_DEVICE_TREE on
>> *all* powerpc platforms... Surely this option should depend on
>> something that says we're including support for a uBoot-able
>> platform?
>
> That's how I originally had it, but I was asked to make it more
> general.
> One non-uboot usage is Mark Greer's "Add Makefile rule to wrap dts
> file in zImage" patch.
>
> What about a CONFIG_WANT_DEVICE_TREE that platforms can select if they
> want to ask the user for a device tree?
Wouldn't we want this for all systems that don't have true OF?
- k
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] bootwrapper: Add CONFIG_DEVICE_TREE
2007-04-12 16:11 ` Kumar Gala
@ 2007-04-12 16:17 ` Scott Wood
2007-04-12 16:49 ` Kumar Gala
0 siblings, 1 reply; 11+ messages in thread
From: Scott Wood @ 2007-04-12 16:17 UTC (permalink / raw)
To: Kumar Gala; +Cc: linuxppc-dev, Paul Mackerras
Kumar Gala wrote:
> On Apr 12, 2007, at 10:36 AM, Scott Wood wrote:
>
>> Paul Mackerras wrote:
>>
>>> Hmmm, I'm not sure that I want to be asked about CONFIG_DEVICE_TREE on
>>> *all* powerpc platforms... Surely this option should depend on
>>> something that says we're including support for a uBoot-able platform?
>>
>>
>> That's how I originally had it, but I was asked to make it more general.
>> One non-uboot usage is Mark Greer's "Add Makefile rule to wrap dts
>> file in zImage" patch.
>>
>> What about a CONFIG_WANT_DEVICE_TREE that platforms can select if they
>> want to ask the user for a device tree?
>
> Wouldn't we want this for all systems that don't have true OF?
Not if there's a non-OF firmware that doesn't need to go through the
bootwrapper (such as modern u-boot).
-Scott
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/5] bootwrapper: Add CONFIG_DEVICE_TREE
2007-04-12 16:17 ` Scott Wood
@ 2007-04-12 16:49 ` Kumar Gala
0 siblings, 0 replies; 11+ messages in thread
From: Kumar Gala @ 2007-04-12 16:49 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, Paul Mackerras
On Apr 12, 2007, at 11:17 AM, Scott Wood wrote:
> Kumar Gala wrote:
>> On Apr 12, 2007, at 10:36 AM, Scott Wood wrote:
>>> Paul Mackerras wrote:
>>>
>>>> Hmmm, I'm not sure that I want to be asked about
>>>> CONFIG_DEVICE_TREE on
>>>> *all* powerpc platforms... Surely this option should depend on
>>>> something that says we're including support for a uBoot-able
>>>> platform?
>>>
>>>
>>> That's how I originally had it, but I was asked to make it more
>>> general.
>>> One non-uboot usage is Mark Greer's "Add Makefile rule to wrap dts
>>> file in zImage" patch.
>>>
>>> What about a CONFIG_WANT_DEVICE_TREE that platforms can select if
>>> they
>>> want to ask the user for a device tree?
>> Wouldn't we want this for all systems that don't have true OF?
>
> Not if there's a non-OF firmware that doesn't need to go through
> the bootwrapper (such as modern u-boot).
I guess my intent with asking for the CONFIG_DEVICE_TREE to be more
generic was to have it point to a .dts for the board/system in
question. The kernel proper wouldn't ever use this, but any other
build mechanism could.
For example, I might have scripts outside of u-boot/kernel that build
my images to flash into a board and they could parse .config to get
the location of the .dts to create the dtb and produce my flash images.
- k
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/5] bootwrapper: Add a cuboot platform and a cuImage target.
2007-03-26 20:51 [PATCH 0/5] bootwrapper: cuImage Scott Wood
2007-03-26 20:52 ` [PATCH 1/5] bootwrapper: Add dt_xlate_reg(), and use it to find serial registers Scott Wood
2007-03-26 20:52 ` [PATCH 2/5] bootwrapper: Add CONFIG_DEVICE_TREE Scott Wood
@ 2007-03-26 20:52 ` Scott Wood
2007-03-26 20:52 ` [PATCH 4/5] bootwrapper: Add ppcboot.h Scott Wood
2007-03-26 20:52 ` [PATCH 5/5] bootwrapper: cuboot for 83xx Scott Wood
4 siblings, 0 replies; 11+ messages in thread
From: Scott Wood @ 2007-03-26 20:52 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
The cuImage target will build a uImage with bootwrapper code and a device
tree. The default device tree and platform file are determined by the
kernel configuration.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/Makefile | 2 +-
arch/powerpc/boot/.gitignore | 3 +++
arch/powerpc/boot/Makefile | 10 +++++++++-
arch/powerpc/boot/wrapper | 21 +++++++++++++++++++--
4 files changed, 32 insertions(+), 4 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 fac6ed0..988e29c 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -129,7 +129,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 +162,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))
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] 11+ messages in thread
* [PATCH 4/5] bootwrapper: Add ppcboot.h.
2007-03-26 20:51 [PATCH 0/5] bootwrapper: cuImage Scott Wood
` (2 preceding siblings ...)
2007-03-26 20:52 ` [PATCH 3/5] bootwrapper: Add a cuboot platform and a cuImage target Scott Wood
@ 2007-03-26 20:52 ` Scott Wood
2007-03-26 20:52 ` [PATCH 5/5] bootwrapper: cuboot for 83xx Scott Wood
4 siblings, 0 replies; 11+ messages in thread
From: Scott Wood @ 2007-03-26 20:52 UTC (permalink / raw)
To: paulus; +Cc: 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] 11+ messages in thread
* [PATCH 5/5] bootwrapper: cuboot for 83xx
2007-03-26 20:51 [PATCH 0/5] bootwrapper: cuImage Scott Wood
` (3 preceding siblings ...)
2007-03-26 20:52 ` [PATCH 4/5] bootwrapper: Add ppcboot.h Scott Wood
@ 2007-03-26 20:52 ` Scott Wood
4 siblings, 0 replies; 11+ messages in thread
From: Scott Wood @ 2007-03-26 20:52 UTC (permalink / raw)
To: paulus; +Cc: 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 | 68 +++++++++++++++++++++++++++++++++++++++
2 files changed, 70 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 988e29c..8b1e49b 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
-src-plat := of.c
+src-plat := of.c cuboot-83xx.c
src-boot := $(src-wlib) $(src-plat) empty.c
src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -162,6 +162,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..8f11d1e
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-83xx.c
@@ -0,0 +1,68 @@
+/*
+ * 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 platform_fixups(void)
+{
+ void *soc;
+
+ 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);
+
+ /* Unfortunately, the specific model number is encoded in the
+ * soc node name in existing dts files -- once that is fixed,
+ * this can do a simple path lookup.
+ */
+ 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));
+ }
+ }
+}
+
+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;
+
+ 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.fixups = platform_fixups;
+}
--
1.5.0.3
^ permalink raw reply related [flat|nested] 11+ messages in thread