* [PATCH 02/20] bootwrapper: Set timebase_period_ns from dt_fixup_cpu_clocks.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
@ 2007-08-20 17:39 ` Scott Wood
2007-08-21 1:53 ` David Gibson
2007-08-20 17:39 ` [PATCH 03/20] bootwrapper: dt_xlate_range() bugfixes Scott Wood
` (18 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
This lets udelay() work properly on platforms which use dt_fixup_cpu_clocks.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/devtree.c | 2 ++
arch/powerpc/boot/ops.h | 2 ++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
index c995155..ae8b886 100644
--- a/arch/powerpc/boot/devtree.c
+++ b/arch/powerpc/boot/devtree.c
@@ -74,6 +74,8 @@ void dt_fixup_cpu_clocks(u32 cpu, u32 tb, u32 bus)
if (bus > 0)
setprop_val(devp, "bus-frequency", bus);
}
+
+ timebase_period_ns = 1000000000 / tb;
}
void dt_fixup_clock(const char *path, u32 freq)
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 8607706..aebd6ed 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -191,4 +191,6 @@ static inline void exit(void)
static char _bss_stack[size]; \
void *_platform_stack_top = _bss_stack + sizeof(_bss_stack);
+extern unsigned long timebase_period_ns;
+
#endif /* _PPC_BOOT_OPS_H_ */
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* [PATCH 03/20] bootwrapper: dt_xlate_range() bugfixes
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
2007-08-20 17:39 ` [PATCH 02/20] bootwrapper: Set timebase_period_ns from dt_fixup_cpu_clocks Scott Wood
@ 2007-08-20 17:39 ` Scott Wood
2007-08-21 2:01 ` David Gibson
2007-08-20 17:39 ` [PATCH 04/20] bootwrapper: Add dt_is_compatible() Scott Wood
` (17 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
1. The check whether ranges fits in the buffer was using elements rather
than bytes.
2. Empty ranges were not properly treated as transparent, and missing
ranges were treated as transparent.
3. The loop terminated when translating from the root rather than to. Once
bug #2 was fixed, it failed due to a missing ranges in the root node.
4. In decoding the ranges property, the #size-cells used was that of
the parent, not the child.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/devtree.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
index ae8b886..129e6d9 100644
--- a/arch/powerpc/boot/devtree.c
+++ b/arch/powerpc/boot/devtree.c
@@ -218,7 +218,7 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
u32 this_addr[MAX_ADDR_CELLS];
void *parent;
u64 ret_addr, ret_size;
- u32 naddr, nsize, prev_naddr;
+ u32 naddr, nsize, prev_naddr, prev_nsize;
int buflen, offset;
parent = get_parent(node);
@@ -233,7 +233,7 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
offset = (naddr + nsize) * res;
if (reglen < offset + naddr + nsize ||
- sizeof(dt_xlate_buf) < offset + naddr + nsize)
+ sizeof(dt_xlate_buf) < (offset + naddr + nsize) * 4)
return 0;
copy_val(last_addr, dt_xlate_buf + offset, naddr);
@@ -244,20 +244,26 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
ret_size |= dt_xlate_buf[offset + naddr + 1];
}
- while ((node = get_parent(node))) {
+ for (;;) {
prev_naddr = naddr;
+ prev_nsize = nsize;
+ node = parent;
- get_reg_format(node, &naddr, &nsize);
+ parent = get_parent(node);
+ if (!parent)
+ break;
+
+ get_reg_format(parent, &naddr, &nsize);
buflen = getprop(node, "ranges", dt_xlate_buf,
sizeof(dt_xlate_buf));
- if (buflen < 0)
+ if (buflen == 0)
continue;
- if (buflen > sizeof(dt_xlate_buf))
+ if (buflen < 0 || buflen > sizeof(dt_xlate_buf))
return 0;
offset = find_range(last_addr, dt_xlate_buf, prev_naddr,
- naddr, nsize, buflen / 4);
+ naddr, prev_nsize, buflen / 4);
if (offset < 0)
return 0;
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 03/20] bootwrapper: dt_xlate_range() bugfixes
2007-08-20 17:39 ` [PATCH 03/20] bootwrapper: dt_xlate_range() bugfixes Scott Wood
@ 2007-08-21 2:01 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-21 2:01 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:39:46PM -0500, Scott Wood wrote:
> 1. The check whether ranges fits in the buffer was using elements rather
> than bytes.
> 2. Empty ranges were not properly treated as transparent, and missing
> ranges were treated as transparent.
> 3. The loop terminated when translating from the root rather than to. Once
> bug #2 was fixed, it failed due to a missing ranges in the root node.
> 4. In decoding the ranges property, the #size-cells used was that of
> the parent, not the child.
> Signed-off-by: Scott Wood <scottwood@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
--
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] 60+ messages in thread
* [PATCH 04/20] bootwrapper: Add dt_is_compatible().
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
2007-08-20 17:39 ` [PATCH 02/20] bootwrapper: Set timebase_period_ns from dt_fixup_cpu_clocks Scott Wood
2007-08-20 17:39 ` [PATCH 03/20] bootwrapper: dt_xlate_range() bugfixes Scott Wood
@ 2007-08-20 17:39 ` Scott Wood
2007-08-21 2:28 ` David Gibson
2007-08-20 17:39 ` [PATCH 05/20] bootwrapper: flatdevtree fixes Scott Wood
` (16 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
This can be used rather than doing a simple strcmp, which will fail to
handle multiple compatible entries.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/devtree.c | 48 +++++++++++++++++++++++++++++-------------
arch/powerpc/boot/ops.h | 1 +
2 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
index 129e6d9..3a18bfe 100644
--- a/arch/powerpc/boot/devtree.c
+++ b/arch/powerpc/boot/devtree.c
@@ -113,7 +113,6 @@ void __dt_fixup_mac_addresses(u32 startindex, ...)
}
#define MAX_ADDR_CELLS 4
-#define MAX_RANGES 8
static void get_reg_format(void *node, u32 *naddr, u32 *nsize)
{
@@ -209,7 +208,7 @@ static int find_range(u32 *reg, u32 *ranges, int nregaddr,
* In particular, PCI is not supported. Also, only the beginning of the
* reg block is tracked; size is ignored except in ranges.
*/
-static u32 dt_xlate_buf[MAX_ADDR_CELLS * MAX_RANGES * 3];
+static u32 prop_buf[MAX_PROP_LEN / 4];
static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
unsigned long *size)
@@ -233,15 +232,15 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
offset = (naddr + nsize) * res;
if (reglen < offset + naddr + nsize ||
- sizeof(dt_xlate_buf) < (offset + naddr + nsize) * 4)
+ MAX_PROP_LEN < (offset + naddr + nsize) * 4)
return 0;
- copy_val(last_addr, dt_xlate_buf + offset, naddr);
+ copy_val(last_addr, prop_buf + offset, naddr);
- ret_size = dt_xlate_buf[offset + naddr];
+ ret_size = prop_buf[offset + naddr];
if (nsize == 2) {
ret_size <<= 32;
- ret_size |= dt_xlate_buf[offset + naddr + 1];
+ ret_size |= prop_buf[offset + naddr + 1];
}
for (;;) {
@@ -255,25 +254,25 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
get_reg_format(parent, &naddr, &nsize);
- buflen = getprop(node, "ranges", dt_xlate_buf,
- sizeof(dt_xlate_buf));
+ buflen = getprop(node, "ranges", prop_buf,
+ sizeof(prop_buf));
if (buflen == 0)
continue;
- if (buflen < 0 || buflen > sizeof(dt_xlate_buf))
+ if (buflen < 0 || buflen > sizeof(prop_buf))
return 0;
- offset = find_range(last_addr, dt_xlate_buf, prev_naddr,
+ offset = find_range(last_addr, prop_buf, prev_naddr,
naddr, prev_nsize, buflen / 4);
if (offset < 0)
return 0;
- copy_val(this_addr, dt_xlate_buf + offset, prev_naddr);
+ copy_val(this_addr, prop_buf + offset, prev_naddr);
if (!sub_reg(last_addr, this_addr))
return 0;
- copy_val(this_addr, dt_xlate_buf + offset + prev_naddr, naddr);
+ copy_val(this_addr, prop_buf + offset + prev_naddr, naddr);
if (!add_reg(last_addr, this_addr, naddr))
return 0;
@@ -300,16 +299,35 @@ int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size)
{
int reglen;
- reglen = getprop(node, "reg", dt_xlate_buf, sizeof(dt_xlate_buf)) / 4;
+ reglen = getprop(node, "reg", prop_buf, sizeof(prop_buf)) / 4;
return dt_xlate(node, res, reglen, addr, size);
}
int dt_xlate_addr(void *node, u32 *buf, int buflen, unsigned long *xlated_addr)
{
- if (buflen > sizeof(dt_xlate_buf))
+ if (buflen > sizeof(prop_buf))
return 0;
- memcpy(dt_xlate_buf, buf, buflen);
+ memcpy(prop_buf, buf, buflen);
return dt_xlate(node, 0, buflen / 4, xlated_addr, NULL);
}
+
+int dt_is_compatible(void *node, const char *compat)
+{
+ char *buf = (char *)prop_buf;
+ int len, pos;
+
+ len = getprop(node, "compatible", buf, MAX_PROP_LEN);
+ if (len < 0)
+ return 0;
+
+ for (pos = 0; pos < len; pos++) {
+ if (!strcmp(buf + pos, compat))
+ return 1;
+
+ pos += strnlen(&buf[pos], len - pos);
+ }
+
+ return 0;
+}
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index aebd6ed..a10bf5a 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -87,6 +87,7 @@ void *simple_alloc_init(char *base, unsigned long heap_size,
extern void flush_cache(void *, unsigned long);
int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size);
int dt_xlate_addr(void *node, u32 *buf, int buflen, unsigned long *xlated_addr);
+int dt_is_compatible(void *node, const char *compat);
static inline void *finddevice(const char *name)
{
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (2 preceding siblings ...)
2007-08-20 17:39 ` [PATCH 04/20] bootwrapper: Add dt_is_compatible() Scott Wood
@ 2007-08-20 17:39 ` Scott Wood
2007-08-21 2:30 ` David Gibson
2007-08-20 17:39 ` [PATCH 06/20] bootwrapper: Add 16-bit I/O, sync(), eieio(), and barrier() Scott Wood
` (15 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
1. ft_create_node was returning the internal pointer rather than a phandle.
2. ft_find_device_rel was treating a "top" phandle of NULL as an error,
rather than as the root of the tree.
3. Return the node's name when getprop() is called with the "name" property.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/flatdevtree.c | 24 +++++++++++++++++++-----
1 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index 13761bf..61b710f 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -109,9 +109,10 @@ static char *ft_next(struct ft_cxt *cxt, char *p, struct ft_atom *ret)
switch (ret->tag) { /* Tag */
case OF_DT_BEGIN_NODE:
+ ret->size = strlen(p);
ret->name = p;
ret->data = (void *)(p - 4); /* start of node */
- p += _ALIGN(strlen(p) + 1, 4);
+ p += _ALIGN(ret->size + 1, 4);
break;
case OF_DT_PROP:
ret->size = sz = be32_to_cpu(*(u32 *) p);
@@ -641,9 +642,13 @@ void *ft_find_device_rel(struct ft_cxt *cxt, const void *top,
{
char *node;
- node = ft_node_ph2node(cxt, top);
- if (node == NULL)
- return NULL;
+ if (top) {
+ node = ft_node_ph2node(cxt, top);
+ if (node == NULL)
+ return NULL;
+ } else {
+ node = ft_root_node(cxt);
+ }
node = ft_find_descendent(cxt, node, srch_path);
return ft_get_phandle(cxt, node);
@@ -757,10 +762,19 @@ static const void *__ft_get_prop(struct ft_cxt *cxt, void *node,
{
struct ft_atom atom;
int depth = 0;
+ int prop_is_name = !strcmp(propname, "name");
+
while ((node = ft_next(cxt, node, &atom)) != NULL) {
switch (atom.tag) {
case OF_DT_BEGIN_NODE:
+ if (prop_is_name) {
+ if (len)
+ *len = atom.size;
+
+ return atom.name;
+ }
+
++depth;
break;
@@ -972,7 +986,7 @@ void *ft_create_node(struct ft_cxt *cxt, const void *parent, const char *name)
cxt->p = p;
ft_begin_node(cxt, name);
ft_end_node(cxt);
- return p;
+ return ft_find_device_rel(cxt, parent, name);
}
p = next;
}
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-20 17:39 ` [PATCH 05/20] bootwrapper: flatdevtree fixes Scott Wood
@ 2007-08-21 2:30 ` David Gibson
2007-08-21 16:09 ` Scott Wood
0 siblings, 1 reply; 60+ messages in thread
From: David Gibson @ 2007-08-21 2:30 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:39:49PM -0500, Scott Wood wrote:
> 1. ft_create_node was returning the internal pointer rather than a phandle.
> 2. ft_find_device_rel was treating a "top" phandle of NULL as an error,
> rather than as the root of the tree.
> 3. Return the node's name when getprop() is called with the "name"
> property.
Hrm. I'm not convinced. (1) certainly needs fixing. (2) is kind of
unclear - there is an ft_find_device() after all for doing root-based
searches. (3) I really dislike; I just don't see the point.
--
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] 60+ messages in thread
* Re: [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-21 2:30 ` David Gibson
@ 2007-08-21 16:09 ` Scott Wood
2007-08-22 1:09 ` David Gibson
0 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-21 16:09 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, paulus
David Gibson wrote:
> On Mon, Aug 20, 2007 at 12:39:49PM -0500, Scott Wood wrote:
>
>>1. ft_create_node was returning the internal pointer rather than a phandle.
>>2. ft_find_device_rel was treating a "top" phandle of NULL as an error,
>>rather than as the root of the tree.
>>3. Return the node's name when getprop() is called with the "name"
>>property.
>
>
> Hrm. I'm not convinced. (1) certainly needs fixing. (2) is kind of
> unclear - there is an ft_find_device() after all for doing root-based
> searches.
The point of #2 was as part of the fix to #1 -- otherwise, the same
check for NULL would have to be moved into ft_create_node to
conditionally call ft_find_device or ft_find_device_rel.
The non-relative function should probably be removed, though.
> (3) I really dislike; I just don't see the point.
It's needed by dt_get_path().
-Scott
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-21 16:09 ` Scott Wood
@ 2007-08-22 1:09 ` David Gibson
2007-08-22 17:24 ` Scott Wood
0 siblings, 1 reply; 60+ messages in thread
From: David Gibson @ 2007-08-22 1:09 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Tue, Aug 21, 2007 at 11:09:58AM -0500, Scott Wood wrote:
> David Gibson wrote:
> > On Mon, Aug 20, 2007 at 12:39:49PM -0500, Scott Wood wrote:
> >
> >>1. ft_create_node was returning the internal pointer rather than a phandle.
> >>2. ft_find_device_rel was treating a "top" phandle of NULL as an error,
> >>rather than as the root of the tree.
> >>3. Return the node's name when getprop() is called with the "name"
> >>property.
> >
> >
> > Hrm. I'm not convinced. (1) certainly needs fixing. (2) is kind of
> > unclear - there is an ft_find_device() after all for doing root-based
> > searches.
>
> The point of #2 was as part of the fix to #1 -- otherwise, the same
> check for NULL would have to be moved into ft_create_node to
> conditionally call ft_find_device or ft_find_device_rel.
Um... oh, ok, I hadn't spotted that (1) made ft_create() use
find_device_rel(). That sounds doubly wrong: you have the internal
offset pointer, you should be able to create a phandle using the
phandle allocation stuff, rather than having to refind the node you've
just created from the parent.
> The non-relative function should probably be removed, though.
Well, yes, I wouldn't have much problem with just having a relative
version.
Come to that, I don't actually care all that much what happens to
flatdevtree.c, seeing as I intend to replace it with libfdt, just as
soon as I can get enough other things off my plate.
> > (3) I really dislike; I just don't see the point.
>
> It's needed by dt_get_path().
No, it isn't. dt_get_path() needs *some* way of getting the name of a
node, but it could be a separate function, which I think would be
preferable rather than folding it into getprop - you don't need to
search for the name, so a getname() function would have quite a
different structure to getprop().
--
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] 60+ messages in thread
* Re: [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-22 1:09 ` David Gibson
@ 2007-08-22 17:24 ` Scott Wood
2007-08-23 2:01 ` David Gibson
0 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-22 17:24 UTC (permalink / raw)
To: linuxppc-dev, paulus
On Wed, Aug 22, 2007 at 11:09:07AM +1000, David Gibson wrote:
> On Tue, Aug 21, 2007 at 11:09:58AM -0500, Scott Wood wrote:
> > The point of #2 was as part of the fix to #1 -- otherwise, the same
> > check for NULL would have to be moved into ft_create_node to
> > conditionally call ft_find_device or ft_find_device_rel.
>
> Um... oh, ok, I hadn't spotted that (1) made ft_create() use
> find_device_rel(). That sounds doubly wrong: you have the internal
> offset pointer, you should be able to create a phandle using the
> phandle allocation stuff, rather than having to refind the node you've
> just created from the parent.
Yeah, that'd make more sense.
> > > (3) I really dislike; I just don't see the point.
> >
> > It's needed by dt_get_path().
>
> No, it isn't. dt_get_path() needs *some* way of getting the name of a
> node, but it could be a separate function, which I think would be
> preferable rather than folding it into getprop - you don't need to
> search for the name, so a getname() function would have quite a
> different structure to getprop().
I'd rather not add a new entry in ops just for that; it's more of an
attribute of the dtb format that name is handled specially. IIUC, on
real OF you'd use the same code for both.
Plus, something might come along that needs to dynamically look for
either name or something else. It's more flexible this way.
-Scott
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-22 17:24 ` Scott Wood
@ 2007-08-23 2:01 ` David Gibson
2007-08-23 17:48 ` Scott Wood
2007-08-23 18:00 ` Segher Boessenkool
0 siblings, 2 replies; 60+ messages in thread
From: David Gibson @ 2007-08-23 2:01 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Wed, Aug 22, 2007 at 12:24:56PM -0500, Scott Wood wrote:
> On Wed, Aug 22, 2007 at 11:09:07AM +1000, David Gibson wrote:
> > On Tue, Aug 21, 2007 at 11:09:58AM -0500, Scott Wood wrote:
> > > The point of #2 was as part of the fix to #1 -- otherwise, the same
> > > check for NULL would have to be moved into ft_create_node to
> > > conditionally call ft_find_device or ft_find_device_rel.
> >
> > Um... oh, ok, I hadn't spotted that (1) made ft_create() use
> > find_device_rel(). That sounds doubly wrong: you have the internal
> > offset pointer, you should be able to create a phandle using the
> > phandle allocation stuff, rather than having to refind the node you've
> > just created from the parent.
>
> Yeah, that'd make more sense.
>
> > > > (3) I really dislike; I just don't see the point.
> > >
> > > It's needed by dt_get_path().
> >
> > No, it isn't. dt_get_path() needs *some* way of getting the name of a
> > node, but it could be a separate function, which I think would be
> > preferable rather than folding it into getprop - you don't need to
> > search for the name, so a getname() function would have quite a
> > different structure to getprop().
>
> I'd rather not add a new entry in ops just for that; it's more of an
> attribute of the dtb format that name is handled specially. IIUC, on
> real OF you'd use the same code for both.
Actually, no - sorry, that's the other problem with this, which I
forgot to mention. On real OF, the "name" property contains the
node's name *without the unit address*; that is, only the portion
before the '@'. So your getprop change does not match real OF
behaviour - and real OF behaviour will not do what you want for
dt_get_path().
Actually, in any case, I don't think we want to implement get_path()
this way for real OF. Better to have get_path() itself as a callback:
on real OF I believe we can directly ask for the full path to a given
phandle, the get name based implementation can then be made specific
to the flat device tree.
Or actually, I think we might be able to come up with a get_path()
implementation for flat tree that's less hideous than repeatedly
calling get_parent() which is an ugly, ugly operation on the flat tree
(and will get worse with libfdt).
> Plus, something might come along that needs to dynamically look for
> either name or something else. It's more flexible this way.
Hrm... "something might come along" just seems contrived to me.
--
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] 60+ messages in thread
* Re: [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-23 2:01 ` David Gibson
@ 2007-08-23 17:48 ` Scott Wood
2007-08-24 1:01 ` David Gibson
2007-08-23 18:00 ` Segher Boessenkool
1 sibling, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-23 17:48 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, paulus
David Gibson wrote:
> Actually, no - sorry, that's the other problem with this, which I
> forgot to mention. On real OF, the "name" property contains the
> node's name *without the unit address*; that is, only the portion
> before the '@'. So your getprop change does not match real OF
> behaviour - and real OF behaviour will not do what you want for
> dt_get_path().
Ah, OK.
> Actually, in any case, I don't think we want to implement get_path()
> this way for real OF. Better to have get_path() itself as a callback:
> on real OF I believe we can directly ask for the full path to a given
> phandle, the get name based implementation can then be made specific
> to the flat device tree.
>
> Or actually, I think we might be able to come up with a get_path()
> implementation for flat tree that's less hideous than repeatedly
> calling get_parent() which is an ugly, ugly operation on the flat tree
It's likely to be ugly no matter what, though I'll try to come up with
something slightly nicer. If I were doing this code from scratch, I'd
probably liven the tree first and reflatten it to pass to the kernel.
> (and will get worse with libfdt).
Why is that?
>>Plus, something might come along that needs to dynamically look for
>>either name or something else. It's more flexible this way.
>
> Hrm... "something might come along" just seems contrived to me.
Well, I generally prefer doing things the more flexible way in the
absence of a good reason not to. OF returning the bare name is a good
reason not to.
-Scott
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-23 17:48 ` Scott Wood
@ 2007-08-24 1:01 ` David Gibson
2007-08-24 14:48 ` Scott Wood
0 siblings, 1 reply; 60+ messages in thread
From: David Gibson @ 2007-08-24 1:01 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Thu, Aug 23, 2007 at 12:48:30PM -0500, Scott Wood wrote:
> David Gibson wrote:
> > Actually, no - sorry, that's the other problem with this, which I
> > forgot to mention. On real OF, the "name" property contains the
> > node's name *without the unit address*; that is, only the portion
> > before the '@'. So your getprop change does not match real OF
> > behaviour - and real OF behaviour will not do what you want for
> > dt_get_path().
>
> Ah, OK.
>
> > Actually, in any case, I don't think we want to implement get_path()
> > this way for real OF. Better to have get_path() itself as a callback:
> > on real OF I believe we can directly ask for the full path to a given
> > phandle, the get name based implementation can then be made specific
> > to the flat device tree.
> >
> > Or actually, I think we might be able to come up with a get_path()
> > implementation for flat tree that's less hideous than repeatedly
> > calling get_parent() which is an ugly, ugly operation on the flat tree
>
> It's likely to be ugly no matter what, though I'll try to come up with
> something slightly nicer. If I were doing this code from scratch, I'd
> probably liven the tree first and reflatten it to pass to the kernel.
Eh, probably not worth bothering doing an actual implementation at
this stage - I'll have to redo it for libfdt anyway.
> > (and will get worse with libfdt).
>
> Why is that?
flatdevtree uses some of the information it caches in the phandle
context stuff to remember who's the parent of a node. libfdt uses raw
offsets into the structure, so the *only* way to implement
get_parent() is to rescan the dt from the beginning, keeping track of
parents until reaching the given node.
> >>Plus, something might come along that needs to dynamically look for
> >>either name or something else. It's more flexible this way.
> >
> > Hrm... "something might come along" just seems contrived to me.
>
> Well, I generally prefer doing things the more flexible way in the
> absence of a good reason not to. OF returning the bare name is a good
> reason not to.
--
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] 60+ messages in thread
* Re: [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-24 1:01 ` David Gibson
@ 2007-08-24 14:48 ` Scott Wood
2007-08-24 22:17 ` David Gibson
0 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-24 14:48 UTC (permalink / raw)
To: linuxppc-dev, paulus
On Fri, Aug 24, 2007 at 11:01:22AM +1000, David Gibson wrote:
> On Thu, Aug 23, 2007 at 12:48:30PM -0500, Scott Wood wrote:
> > It's likely to be ugly no matter what, though I'll try to come up with
> > something slightly nicer. If I were doing this code from scratch, I'd
> > probably liven the tree first and reflatten it to pass to the kernel.
>
> Eh, probably not worth bothering doing an actual implementation at
> this stage - I'll have to redo it for libfdt anyway.
Too late, I already wrote it -- it wasn't as bad as I thought it would
be.
> flatdevtree uses some of the information it caches in the phandle
> context stuff to remember who's the parent of a node. libfdt uses raw
> offsets into the structure, so the *only* way to implement
> get_parent() is to rescan the dt from the beginning, keeping track of
> parents until reaching the given node.
What is the benefit of doing it that way?
-Scott
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-24 14:48 ` Scott Wood
@ 2007-08-24 22:17 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-24 22:17 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev
On Fri, Aug 24, 2007 at 09:48:37AM -0500, Scott Wood wrote:
> On Fri, Aug 24, 2007 at 11:01:22AM +1000, David Gibson wrote:
> > On Thu, Aug 23, 2007 at 12:48:30PM -0500, Scott Wood wrote:
> > > It's likely to be ugly no matter what, though I'll try to come up with
> > > something slightly nicer. If I were doing this code from scratch, I'd
> > > probably liven the tree first and reflatten it to pass to the kernel.
> >
> > Eh, probably not worth bothering doing an actual implementation at
> > this stage - I'll have to redo it for libfdt anyway.
>
> Too late, I already wrote it -- it wasn't as bad as I thought it would
> be.
Well, there you go.
> > flatdevtree uses some of the information it caches in the phandle
> > context stuff to remember who's the parent of a node. libfdt uses raw
> > offsets into the structure, so the *only* way to implement
> > get_parent() is to rescan the dt from the beginning, keeping track of
> > parents until reaching the given node.
>
> What is the benefit of doing it that way?
Most other operations are simpler like this - no more futzing around
converting between phandles and offsets and back again at the
beginning and end of most functions.
More importantly, it allows libfdt to be "stateless" in the sense that
you can manipulate the device tree without having to maintain any
context or state structure apart from the device tree blob itself.
That's particularly handy for doing read-only accesses really early
with a minimum of fuss.
In particular, it means libfdt does not need malloc(). That can be
rather useful for some that's supposed to be embeddable in a variety
of strange, constrained environments such as bootloaders and
firmwares.
--
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] 60+ messages in thread
* Re: [PATCH 05/20] bootwrapper: flatdevtree fixes
2007-08-23 2:01 ` David Gibson
2007-08-23 17:48 ` Scott Wood
@ 2007-08-23 18:00 ` Segher Boessenkool
1 sibling, 0 replies; 60+ messages in thread
From: Segher Boessenkool @ 2007-08-23 18:00 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, paulus
> Actually, in any case, I don't think we want to implement get_path()
> this way for real OF. Better to have get_path() itself as a callback:
> on real OF I believe we can directly ask for the full path to a given
> phandle,
Yes. "package-to-path" from the client interface.
Segher
^ permalink raw reply [flat|nested] 60+ messages in thread
* [PATCH 06/20] bootwrapper: Add 16-bit I/O, sync(), eieio(), and barrier().
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (3 preceding siblings ...)
2007-08-20 17:39 ` [PATCH 05/20] bootwrapper: flatdevtree fixes Scott Wood
@ 2007-08-20 17:39 ` Scott Wood
2007-08-21 2:31 ` David Gibson
2007-08-20 17:39 ` [PATCH 07/20] bootwrapper: Add TARGET_HAS_ETHn tests to ppcboot.h Scott Wood
` (14 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
Also, include types.h from io.h, so callers don't have to.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/io.h | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/boot/io.h b/arch/powerpc/boot/io.h
index 32974ed..ccaedae 100644
--- a/arch/powerpc/boot/io.h
+++ b/arch/powerpc/boot/io.h
@@ -1,5 +1,8 @@
#ifndef _IO_H
#define __IO_H
+
+#include "types.h"
+
/*
* Low-level I/O routines.
*
@@ -20,6 +23,37 @@ static inline void out_8(volatile unsigned char *addr, int val)
: "=m" (*addr) : "r" (val));
}
+static inline unsigned in_le16(const volatile u16 *addr)
+{
+ unsigned ret;
+
+ __asm__ __volatile__("lhbrx %0,0,%1; twi 0,%0,0; isync"
+ : "=r" (ret) : "r" (addr), "m" (*addr));
+
+ return ret;
+}
+
+static inline unsigned in_be16(const volatile u16 *addr)
+{
+ unsigned ret;
+
+ __asm__ __volatile__("lhz%U1%X1 %0,%1; twi 0,%0,0; isync"
+ : "=r" (ret) : "m" (*addr));
+ return ret;
+}
+
+static inline void out_le16(volatile u16 *addr, int val)
+{
+ __asm__ __volatile__("sthbrx %1,0,%2; sync" : "=m" (*addr)
+ : "r" (val), "r" (addr));
+}
+
+static inline void out_be16(volatile u16 *addr, int val)
+{
+ __asm__ __volatile__("sth%U0%X0 %1,%0; sync"
+ : "=m" (*addr) : "r" (val));
+}
+
static inline unsigned in_le32(const volatile unsigned *addr)
{
unsigned ret;
@@ -50,4 +84,19 @@ static inline void out_be32(volatile unsigned *addr, int val)
: "=m" (*addr) : "r" (val));
}
+static inline void sync(void)
+{
+ asm volatile("sync" : : : "memory");
+}
+
+static inline void eieio(void)
+{
+ asm volatile("eieio" : : : "memory");
+}
+
+static inline void barrier(void)
+{
+ asm volatile("" : : : "memory");
+}
+
#endif /* _IO_H */
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 06/20] bootwrapper: Add 16-bit I/O, sync(), eieio(), and barrier().
2007-08-20 17:39 ` [PATCH 06/20] bootwrapper: Add 16-bit I/O, sync(), eieio(), and barrier() Scott Wood
@ 2007-08-21 2:31 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-21 2:31 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:39:51PM -0500, Scott Wood wrote:
> Also, include types.h from io.h, so callers don't have to.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
Seems reasonable.
Acked-by: David Gibson <david@gibson.dropbear.id.au>
--
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] 60+ messages in thread
* [PATCH 07/20] bootwrapper: Add TARGET_HAS_ETHn tests to ppcboot.h.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (4 preceding siblings ...)
2007-08-20 17:39 ` [PATCH 06/20] bootwrapper: Add 16-bit I/O, sync(), eieio(), and barrier() Scott Wood
@ 2007-08-20 17:39 ` Scott Wood
2007-08-21 3:33 ` David Gibson
2007-08-20 17:39 ` [PATCH 08/20] bootwrapper: serial_console_init() fixes Scott Wood
` (13 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
U-boots more recent than when ppcboot.h was forked allow the board config
file to enable additional ethernet ports explicitly, rather than
using a hardcoded list of targets. This allows bootwrapper platform
files to do the same.
Fortunately, nothing after the ethernet addresses is of interest to
cuboot platforms, so the inevitable mismatches won't be too catastrophic.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/ppcboot.h | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/boot/ppcboot.h b/arch/powerpc/boot/ppcboot.h
index 5290ff2..6ae6f90 100644
--- a/arch/powerpc/boot/ppcboot.h
+++ b/arch/powerpc/boot/ppcboot.h
@@ -78,17 +78,18 @@ typedef struct bd_info {
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)
+ defined(TARGET_85xx) || defined(TARGET_83xx) || defined(TARGET_HAS_ETH1)
/* second onboard ethernet port */
unsigned char bi_enet1addr[6];
#define HAVE_ENET1ADDR
#endif
-#if defined(TARGET_EVB64260) || defined(TARGET_440GX) || defined(TARGET_85xx)
+#if defined(TARGET_EVB64260) || defined(TARGET_440GX) || \
+ defined(TARGET_85xx) || defined(TARGET_HAS_ETH2)
/* third onboard ethernet ports */
unsigned char bi_enet2addr[6];
#define HAVE_ENET2ADDR
#endif
-#if defined(TARGET_440GX)
+#if defined(TARGET_440GX) || defined(TARGET_HAS_ETH3)
/* fourth onboard ethernet ports */
unsigned char bi_enet3addr[6];
#define HAVE_ENET3ADDR
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 07/20] bootwrapper: Add TARGET_HAS_ETHn tests to ppcboot.h.
2007-08-20 17:39 ` [PATCH 07/20] bootwrapper: Add TARGET_HAS_ETHn tests to ppcboot.h Scott Wood
@ 2007-08-21 3:33 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-21 3:33 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:39:52PM -0500, Scott Wood wrote:
> U-boots more recent than when ppcboot.h was forked allow the board config
> file to enable additional ethernet ports explicitly, rather than
> using a hardcoded list of targets. This allows bootwrapper platform
> files to do the same.
>
> Fortunately, nothing after the ethernet addresses is of interest to
> cuboot platforms, so the inevitable mismatches won't be too
> catastrophic.
Good grief. Increases my already considerable wonderment at the fact
that anyone ever thought bd_t was an acceptable way of passing data to
the OS.
> Signed-off-by: Scott Wood <scottwood@freescale.com>
I can't say I'm thrilled at having two basically incompatible ways of
specifying the layout of this vital structure, but bd_t is so fscked
by design anyway, what's one more hack for convenience.
Acked-by: David Gibson <david@gibson.dropbear.id.au>
--
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] 60+ messages in thread
* [PATCH 08/20] bootwrapper: serial_console_init() fixes.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (5 preceding siblings ...)
2007-08-20 17:39 ` [PATCH 07/20] bootwrapper: Add TARGET_HAS_ETHn tests to ppcboot.h Scott Wood
@ 2007-08-20 17:39 ` Scott Wood
2007-08-21 2:38 ` David Gibson
2007-08-20 17:39 ` [PATCH 09/20] bootwrapper: Declare udelay() in ops.h Scott Wood
` (12 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
1. Search the entire compatible list for serial devices.
The serial code previously did a simple strcmp on the compatible
node; this fails when the match string is not the first compatible
listed. Use dt_is_compatible() instead.
2. Don't call serial_edit_cmdline if getc isn't defined.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/serial.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
index eaa0d3a..3ce7f65 100644
--- a/arch/powerpc/boot/serial.c
+++ b/arch/powerpc/boot/serial.c
@@ -114,18 +114,14 @@ int serial_console_init(void)
{
void *devp;
int rc = -1;
- char compat[MAX_PROP_LEN];
devp = serial_get_stdout_devp();
if (devp == NULL)
goto err_out;
- if (getprop(devp, "compatible", compat, sizeof(compat)) < 0)
- goto err_out;
-
- if (!strcmp(compat, "ns16550"))
+ if (dt_is_compatible(devp, "ns16550"))
rc = ns16550_console_init(devp, &serial_cd);
- else if (!strcmp(compat, "marvell,mpsc"))
+ else if (dt_is_compatible(devp, "marvell,mpsc"))
rc = mpsc_console_init(devp, &serial_cd);
/* Add other serial console driver calls here */
@@ -133,10 +129,12 @@ int serial_console_init(void)
if (!rc) {
console_ops.open = serial_open;
console_ops.write = serial_write;
- console_ops.edit_cmdline = serial_edit_cmdline;
console_ops.close = serial_close;
console_ops.data = &serial_cd;
+ if (serial_cd.getc)
+ console_ops.edit_cmdline = serial_edit_cmdline;
+
return 0;
}
err_out:
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 08/20] bootwrapper: serial_console_init() fixes.
2007-08-20 17:39 ` [PATCH 08/20] bootwrapper: serial_console_init() fixes Scott Wood
@ 2007-08-21 2:38 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-21 2:38 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:39:54PM -0500, Scott Wood wrote:
> 1. Search the entire compatible list for serial devices.
>
> The serial code previously did a simple strcmp on the compatible
> node; this fails when the match string is not the first compatible
> listed. Use dt_is_compatible() instead.
>
> 2. Don't call serial_edit_cmdline if getc isn't defined.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
--
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] 60+ messages in thread
* [PATCH 09/20] bootwrapper: Declare udelay() in ops.h.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (6 preceding siblings ...)
2007-08-20 17:39 ` [PATCH 08/20] bootwrapper: serial_console_init() fixes Scott Wood
@ 2007-08-20 17:39 ` Scott Wood
2007-08-21 2:39 ` David Gibson
2007-08-20 17:39 ` [PATCH 10/20] bootwrapper: Add CPM serial driver Scott Wood
` (11 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
Declarations in various users are removed.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/mpsc.c | 1 -
arch/powerpc/boot/mv64x60_i2c.c | 2 --
arch/powerpc/boot/ops.h | 1 +
arch/powerpc/boot/prpmc2800.c | 2 --
arch/powerpc/boot/serial.c | 2 --
5 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/boot/mpsc.c b/arch/powerpc/boot/mpsc.c
index f1c0e96..802ea53 100644
--- a/arch/powerpc/boot/mpsc.c
+++ b/arch/powerpc/boot/mpsc.c
@@ -17,7 +17,6 @@
#include "io.h"
#include "ops.h"
-extern void udelay(long delay);
#define MPSC_CHR_1 0x000c
diff --git a/arch/powerpc/boot/mv64x60_i2c.c b/arch/powerpc/boot/mv64x60_i2c.c
index 435fe85..d085377 100644
--- a/arch/powerpc/boot/mv64x60_i2c.c
+++ b/arch/powerpc/boot/mv64x60_i2c.c
@@ -21,8 +21,6 @@
#include "ops.h"
#include "mv64x60.h"
-extern void udelay(long);
-
/* Register defines */
#define MV64x60_I2C_REG_SLAVE_ADDR 0x00
#define MV64x60_I2C_REG_DATA 0x04
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index a10bf5a..e45b364 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -193,5 +193,6 @@ static inline void exit(void)
void *_platform_stack_top = _bss_stack + sizeof(_bss_stack);
extern unsigned long timebase_period_ns;
+void udelay(long delay);
#endif /* _PPC_BOOT_OPS_H_ */
diff --git a/arch/powerpc/boot/prpmc2800.c b/arch/powerpc/boot/prpmc2800.c
index f428bac..5c6cd36 100644
--- a/arch/powerpc/boot/prpmc2800.c
+++ b/arch/powerpc/boot/prpmc2800.c
@@ -25,8 +25,6 @@ extern char _end[];
extern char _vmlinux_start[], _vmlinux_end[];
extern char _dtb_start[], _dtb_end[];
-extern void udelay(long delay);
-
#define KB 1024U
#define MB (KB*KB)
#define GB (KB*MB)
diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
index 3ce7f65..944f0ee 100644
--- a/arch/powerpc/boot/serial.c
+++ b/arch/powerpc/boot/serial.c
@@ -19,8 +19,6 @@
#include "io.h"
#include "ops.h"
-extern void udelay(long delay);
-
static int serial_open(void)
{
struct serial_console_data *scdp = console_ops.data;
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 09/20] bootwrapper: Declare udelay() in ops.h.
2007-08-20 17:39 ` [PATCH 09/20] bootwrapper: Declare udelay() in ops.h Scott Wood
@ 2007-08-21 2:39 ` David Gibson
2007-08-21 16:12 ` Scott Wood
0 siblings, 1 reply; 60+ messages in thread
From: David Gibson @ 2007-08-21 2:39 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:39:55PM -0500, Scott Wood wrote:
> Declarations in various users are removed.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
Hrm... it should go in a header, certainly, but I wonder if io.h would
be more suitable than the already rather bloated ops.h.
--
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] 60+ messages in thread
* Re: [PATCH 09/20] bootwrapper: Declare udelay() in ops.h.
2007-08-21 2:39 ` David Gibson
@ 2007-08-21 16:12 ` Scott Wood
2007-08-22 1:09 ` David Gibson
0 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-21 16:12 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, paulus
David Gibson wrote:
> On Mon, Aug 20, 2007 at 12:39:55PM -0500, Scott Wood wrote:
>
>>Declarations in various users are removed.
>>
>>Signed-off-by: Scott Wood <scottwood@freescale.com>
>
>
> Hrm... it should go in a header, certainly, but I wonder if io.h would
> be more suitable than the already rather bloated ops.h.
It's not really I/O either... Maybe we should make a misc.h to put
stuff in that doesn't fit anywhere else and doesn't really warrant its
own header file?
-Scott
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [PATCH 09/20] bootwrapper: Declare udelay() in ops.h.
2007-08-21 16:12 ` Scott Wood
@ 2007-08-22 1:09 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-22 1:09 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Tue, Aug 21, 2007 at 11:12:08AM -0500, Scott Wood wrote:
> David Gibson wrote:
> > On Mon, Aug 20, 2007 at 12:39:55PM -0500, Scott Wood wrote:
> >
> >>Declarations in various users are removed.
> >>
> >>Signed-off-by: Scott Wood <scottwood@freescale.com>
> >
> >
> > Hrm... it should go in a header, certainly, but I wonder if io.h would
> > be more suitable than the already rather bloated ops.h.
>
> It's not really I/O either... Maybe we should make a misc.h to put
> stuff in that doesn't fit anywhere else and doesn't really warrant its
> own header file?
It's not I/O, but I believe it's main intended use is for delays to
get I/O timing correct.
--
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] 60+ messages in thread
* [PATCH 10/20] bootwrapper: Add CPM serial driver.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (7 preceding siblings ...)
2007-08-20 17:39 ` [PATCH 09/20] bootwrapper: Declare udelay() in ops.h Scott Wood
@ 2007-08-20 17:39 ` Scott Wood
2007-08-21 2:42 ` David Gibson
2007-08-20 17:39 ` [PATCH 11/20] bootwrapper: Move linker symbols into ops.h Scott Wood
` (10 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
This serial port is used on all 8xx, many 82xx, and some 85xx chips.
The driver requires that the port has already been set up by the firmware
and/or platform code.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/Makefile | 3 +-
arch/powerpc/boot/cpm-serial.c | 249 ++++++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/ops.h | 1 +
arch/powerpc/boot/serial.c | 5 +
4 files changed, 257 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/boot/cpm-serial.c
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 61a6f34..997980f 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -44,7 +44,8 @@ $(addprefix $(obj)/,$(zlib) gunzip_util.o main.o): \
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 elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
- 44x.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c
+ 44x.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c \
+ cpm-serial.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
ps3-head.S ps3-hvcall.S ps3.c
diff --git a/arch/powerpc/boot/cpm-serial.c b/arch/powerpc/boot/cpm-serial.c
new file mode 100644
index 0000000..fcb8b5e
--- /dev/null
+++ b/arch/powerpc/boot/cpm-serial.c
@@ -0,0 +1,249 @@
+/*
+ * CPM serial console support.
+ *
+ * Copyright 2007 Freescale Semiconductor, Inc.
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * It is assumed that the firmware (or the platform file) has already set
+ * up the port.
+ */
+
+#include "types.h"
+#include "io.h"
+#include "ops.h"
+
+struct cpm_scc {
+ u32 gsmrl;
+ u32 gsmrh;
+ u16 psmr;
+ u8 res1[2];
+ u16 todr;
+ u16 dsr;
+ u16 scce;
+ u8 res2[2];
+ u16 sccm;
+ u8 res3;
+ u8 sccs;
+ u8 res4[8];
+};
+
+struct cpm_smc {
+ u8 res1[2];
+ u16 smcmr;
+ u8 res2[2];
+ u8 smce;
+ u8 res3[3];
+ u8 smcm;
+ u8 res4[5];
+};
+
+struct cpm_param {
+ u16 rbase;
+ u16 tbase;
+ u8 rfcr;
+ u8 tfcr;
+};
+
+struct cpm_bd {
+ u16 sc; /* Status and Control */
+ u16 len; /* Data length in buffer */
+ u8 *addr; /* Buffer address in host memory */
+};
+
+static void *cpcr;
+static struct cpm_param *param;
+static struct cpm_smc *smc;
+static struct cpm_scc *scc;
+struct cpm_bd *tbdf, *rbdf;
+static u32 cpm_cmd;
+static u8 *dpram_start;
+
+static void (*do_cmd)(int op);
+static void (*enable_port)(void);
+static void (*disable_port)(void);
+
+#define CPM_CMD_STOP_TX 4
+#define CPM_CMD_RESTART_TX 6
+#define CPM_CMD_INIT_RX_TX 0
+
+static void cpm1_cmd(int op)
+{
+ while (in_be16(cpcr) & 1)
+ ;
+
+ out_be16(cpcr, (op << 8) | cpm_cmd | 1);
+
+ while (in_be16(cpcr) & 1)
+ ;
+}
+
+static void cpm2_cmd(int op)
+{
+ while (in_be32(cpcr) & 0x10000)
+ ;
+
+ out_be32(cpcr, op | cpm_cmd | 0x10000);
+
+ while (in_be32(cpcr) & 0x10000)
+ ;
+}
+
+static void smc_disable_port(void)
+{
+ do_cmd(CPM_CMD_STOP_TX);
+ out_be16(&smc->smcmr, in_be16(&smc->smcmr) & ~3);
+}
+
+static void scc_disable_port(void)
+{
+ do_cmd(CPM_CMD_STOP_TX);
+ out_be32(&scc->gsmrl, in_be32(&scc->gsmrl) & ~0x30);
+}
+
+static void smc_enable_port(void)
+{
+ out_be16(&smc->smcmr, in_be16(&smc->smcmr) | 3);
+ do_cmd(CPM_CMD_RESTART_TX);
+}
+
+static void scc_enable_port(void)
+{
+ out_be32(&scc->gsmrl, in_be32(&scc->gsmrl) | 0x30);
+ do_cmd(CPM_CMD_RESTART_TX);
+}
+
+static int cpm_serial_open(void)
+{
+ int dpaddr = 0x800;
+ disable_port();
+
+ out_8(¶m->rfcr, 0x10);
+ out_8(¶m->tfcr, 0x10);
+
+ rbdf = (struct cpm_bd *)(dpram_start + dpaddr);
+ rbdf->addr = (u8 *)(rbdf + 2);
+ rbdf->sc = 0xa000;
+ rbdf->len = 1;
+
+ tbdf = rbdf + 1;
+ tbdf->addr = (u8 *)(rbdf + 2) + 1;
+ tbdf->sc = 0x2000;
+ tbdf->len = 1;
+
+ sync();
+ out_be16(¶m->rbase, dpaddr);
+ out_be16(¶m->tbase, dpaddr + sizeof(struct cpm_bd));
+
+ do_cmd(CPM_CMD_INIT_RX_TX);
+
+ enable_port();
+ return 0;
+}
+
+static void cpm_serial_putc(unsigned char c)
+{
+ while (tbdf->sc & 0x8000)
+ barrier();
+
+ sync();
+
+ tbdf->addr[0] = c;
+ eieio();
+ tbdf->sc |= 0x8000;
+}
+
+static unsigned char cpm_serial_tstc(void)
+{
+ barrier();
+ return !(rbdf->sc & 0x8000);
+}
+
+static unsigned char cpm_serial_getc(void)
+{
+ unsigned char c;
+
+ while (!cpm_serial_tstc())
+ ;
+
+ sync();
+ c = rbdf->addr[0];
+ eieio();
+ rbdf->sc |= 0x8000;
+
+ return c;
+}
+
+int cpm_console_init(void *devp, struct serial_console_data *scdp)
+{
+ void *reg_virt[2];
+ int is_smc = 0, is_cpm2 = 0, n;
+ unsigned long reg_phys;
+ void *parent;
+
+ if (dt_is_compatible(devp, "fsl,cpm1-smc-uart")) {
+ is_smc = 1;
+ } else if (dt_is_compatible(devp, "fsl,cpm2-scc-uart")) {
+ is_cpm2 = 1;
+ } else if (dt_is_compatible(devp, "fsl,cpm2-smc-uart")) {
+ is_cpm2 = 1;
+ is_smc = 1;
+ }
+
+ if (is_smc) {
+ enable_port = smc_enable_port;
+ disable_port = smc_disable_port;
+ } else {
+ enable_port = scc_enable_port;
+ disable_port = scc_disable_port;
+ }
+
+ if (is_cpm2)
+ do_cmd = cpm2_cmd;
+ else
+ do_cmd = cpm1_cmd;
+
+ n = getprop(devp, "fsl,cpm-command", &cpm_cmd, 4);
+ if (n < 4)
+ return -1;
+
+ n = getprop(devp, "virtual-reg", reg_virt, sizeof(reg_virt));
+ if (n < (int)sizeof(reg_virt)) {
+ for (n = 0; n < 2; n++) {
+ if (!dt_xlate_reg(devp, n, ®_phys, NULL))
+ return -1;
+
+ reg_virt[n] = (void *)reg_phys;
+ }
+ }
+
+ if (is_smc)
+ smc = reg_virt[0];
+ else
+ scc = reg_virt[0];
+
+ param = reg_virt[1];
+
+ parent = get_parent(devp);
+ if (!parent)
+ return -1;
+
+ n = getprop(parent, "virtual-reg", reg_virt, sizeof(reg_virt));
+ if (n < (int)sizeof(reg_virt)) {
+ for (n = 0; n < 2; n++) {
+ if (!dt_xlate_reg(parent, n, ®_phys, NULL))
+ return -1;
+
+ reg_virt[n] = (void *)reg_phys;
+ }
+ }
+
+ cpcr = reg_virt[0];
+ dpram_start = reg_virt[1];
+
+ scdp->open = cpm_serial_open;
+ scdp->putc = cpm_serial_putc;
+ scdp->getc = cpm_serial_getc;
+ scdp->tstc = cpm_serial_tstc;
+
+ return 0;
+}
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index e45b364..2bc2f02 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -82,6 +82,7 @@ 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);
int mpsc_console_init(void *devp, struct serial_console_data *scdp);
+int cpm_console_init(void *devp, struct serial_console_data *scdp);
void *simple_alloc_init(char *base, unsigned long heap_size,
unsigned long granularity, unsigned long max_allocs);
extern void flush_cache(void *, unsigned long);
diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
index 944f0ee..d47f8e0 100644
--- a/arch/powerpc/boot/serial.c
+++ b/arch/powerpc/boot/serial.c
@@ -121,6 +121,11 @@ int serial_console_init(void)
rc = ns16550_console_init(devp, &serial_cd);
else if (dt_is_compatible(devp, "marvell,mpsc"))
rc = mpsc_console_init(devp, &serial_cd);
+ else if (dt_is_compatible(devp, "fsl,cpm1-scc-uart") ||
+ dt_is_compatible(devp, "fsl,cpm1-smc-uart") ||
+ dt_is_compatible(devp, "fsl,cpm2-scc-uart") ||
+ dt_is_compatible(devp, "fsl,cpm2-smc-uart"))
+ rc = cpm_console_init(devp, &serial_cd);
/* Add other serial console driver calls here */
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 10/20] bootwrapper: Add CPM serial driver.
2007-08-20 17:39 ` [PATCH 10/20] bootwrapper: Add CPM serial driver Scott Wood
@ 2007-08-21 2:42 ` David Gibson
2007-08-21 16:15 ` Scott Wood
0 siblings, 1 reply; 60+ messages in thread
From: David Gibson @ 2007-08-21 2:42 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:39:57PM -0500, Scott Wood wrote:
> This serial port is used on all 8xx, many 82xx, and some 85xx chips.
>
> The driver requires that the port has already been set up by the firmware
> and/or platform code.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
[snip]
> diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
> index 944f0ee..d47f8e0 100644
> --- a/arch/powerpc/boot/serial.c
> +++ b/arch/powerpc/boot/serial.c
> @@ -121,6 +121,11 @@ int serial_console_init(void)
> rc = ns16550_console_init(devp, &serial_cd);
> else if (dt_is_compatible(devp, "marvell,mpsc"))
> rc = mpsc_console_init(devp, &serial_cd);
> + else if (dt_is_compatible(devp, "fsl,cpm1-scc-uart") ||
> + dt_is_compatible(devp, "fsl,cpm1-smc-uart") ||
> + dt_is_compatible(devp, "fsl,cpm2-scc-uart") ||
> + dt_is_compatible(devp, "fsl,cpm2-smc-uart"))
> + rc = cpm_console_init(devp, &serial_cd);
If all these variants admit a compatible driver, there really should
be defined a compatible value that they all include in the device
tree. But I guess you'd still need all these tests for device trees
which didn't have it.
--
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] 60+ messages in thread
* Re: [PATCH 10/20] bootwrapper: Add CPM serial driver.
2007-08-21 2:42 ` David Gibson
@ 2007-08-21 16:15 ` Scott Wood
2007-08-22 1:10 ` David Gibson
0 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-21 16:15 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, paulus
David Gibson wrote:
>>diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
>>index 944f0ee..d47f8e0 100644
>>--- a/arch/powerpc/boot/serial.c
>>+++ b/arch/powerpc/boot/serial.c
>>@@ -121,6 +121,11 @@ int serial_console_init(void)
>> rc = ns16550_console_init(devp, &serial_cd);
>> else if (dt_is_compatible(devp, "marvell,mpsc"))
>> rc = mpsc_console_init(devp, &serial_cd);
>>+ else if (dt_is_compatible(devp, "fsl,cpm1-scc-uart") ||
>>+ dt_is_compatible(devp, "fsl,cpm1-smc-uart") ||
>>+ dt_is_compatible(devp, "fsl,cpm2-scc-uart") ||
>>+ dt_is_compatible(devp, "fsl,cpm2-smc-uart"))
>>+ rc = cpm_console_init(devp, &serial_cd);
>
>
> If all these variants admit a compatible driver, there really should
> be defined a compatible value that they all include in the device
> tree.
That's what I did last time, and several people complained. :-)
The issue was that while there is a lot in common between these
variants, there's no one common subset that can be used to drive the
device without knowledge of what variant it is (or knowledge of where
the firmware placed the descriptors).
> But I guess you'd still need all these tests for device trees
> which didn't have it.
Nah, this is a new binding.
-Scott
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [PATCH 10/20] bootwrapper: Add CPM serial driver.
2007-08-21 16:15 ` Scott Wood
@ 2007-08-22 1:10 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-22 1:10 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Tue, Aug 21, 2007 at 11:15:53AM -0500, Scott Wood wrote:
> David Gibson wrote:
> >>diff --git a/arch/powerpc/boot/serial.c b/arch/powerpc/boot/serial.c
> >>index 944f0ee..d47f8e0 100644
> >>--- a/arch/powerpc/boot/serial.c
> >>+++ b/arch/powerpc/boot/serial.c
> >>@@ -121,6 +121,11 @@ int serial_console_init(void)
> >> rc = ns16550_console_init(devp, &serial_cd);
> >> else if (dt_is_compatible(devp, "marvell,mpsc"))
> >> rc = mpsc_console_init(devp, &serial_cd);
> >>+ else if (dt_is_compatible(devp, "fsl,cpm1-scc-uart") ||
> >>+ dt_is_compatible(devp, "fsl,cpm1-smc-uart") ||
> >>+ dt_is_compatible(devp, "fsl,cpm2-scc-uart") ||
> >>+ dt_is_compatible(devp, "fsl,cpm2-smc-uart"))
> >>+ rc = cpm_console_init(devp, &serial_cd);
> >
> >
> > If all these variants admit a compatible driver, there really should
> > be defined a compatible value that they all include in the device
> > tree.
>
> That's what I did last time, and several people complained. :-)
>
> The issue was that while there is a lot in common between these
> variants, there's no one common subset that can be used to drive the
> device without knowledge of what variant it is (or knowledge of where
> the firmware placed the descriptors).
Ah, ok. Fair enough then.
> > But I guess you'd still need all these tests for device trees
> > which didn't have it.
>
> Nah, this is a new binding.
>
> -Scott
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>
--
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] 60+ messages in thread
* [PATCH 11/20] bootwrapper: Move linker symbols into ops.h.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (8 preceding siblings ...)
2007-08-20 17:39 ` [PATCH 10/20] bootwrapper: Add CPM serial driver Scott Wood
@ 2007-08-20 17:39 ` Scott Wood
2007-08-21 2:43 ` David Gibson
2007-08-20 17:40 ` [PATCH 12/20] bootwrapper: Add 8xx cuboot support Scott Wood
` (9 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:39 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
Most of these were previously used by numerous C files and
redeclared in each one.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/cuboot-83xx.c | 1 -
arch/powerpc/boot/cuboot-85xx.c | 1 -
arch/powerpc/boot/cuboot.c | 3 ---
arch/powerpc/boot/ebony.c | 3 ---
arch/powerpc/boot/holly.c | 5 -----
arch/powerpc/boot/main.c | 10 ----------
arch/powerpc/boot/of.c | 2 --
arch/powerpc/boot/ops.h | 10 ++++++++++
arch/powerpc/boot/prpmc2800.c | 4 ----
arch/powerpc/boot/ps3.c | 4 ----
arch/powerpc/boot/treeboot-ebony.c | 2 --
11 files changed, 10 insertions(+), 35 deletions(-)
diff --git a/arch/powerpc/boot/cuboot-83xx.c b/arch/powerpc/boot/cuboot-83xx.c
index 296025d..a050550 100644
--- a/arch/powerpc/boot/cuboot-83xx.c
+++ b/arch/powerpc/boot/cuboot-83xx.c
@@ -18,7 +18,6 @@
#include "ppcboot.h"
static bd_t bd;
-extern char _dtb_start[], _dtb_end[];
static void platform_fixups(void)
{
diff --git a/arch/powerpc/boot/cuboot-85xx.c b/arch/powerpc/boot/cuboot-85xx.c
index 10f0f69..345dcbe 100644
--- a/arch/powerpc/boot/cuboot-85xx.c
+++ b/arch/powerpc/boot/cuboot-85xx.c
@@ -18,7 +18,6 @@
#include "ppcboot.h"
static bd_t bd;
-extern char _dtb_start[], _dtb_end[];
static void platform_fixups(void)
{
diff --git a/arch/powerpc/boot/cuboot.c b/arch/powerpc/boot/cuboot.c
index 6579546..7768b23 100644
--- a/arch/powerpc/boot/cuboot.c
+++ b/arch/powerpc/boot/cuboot.c
@@ -17,9 +17,6 @@
#include "ppcboot.h"
-extern char _end[];
-extern char _dtb_start[], _dtb_end[];
-
void cuboot_init(unsigned long r4, unsigned long r5,
unsigned long r6, unsigned long r7,
unsigned long end_of_ram)
diff --git a/arch/powerpc/boot/ebony.c b/arch/powerpc/boot/ebony.c
index 75daeda..2cf9cc2 100644
--- a/arch/powerpc/boot/ebony.c
+++ b/arch/powerpc/boot/ebony.c
@@ -27,9 +27,6 @@
#include "dcr.h"
#include "44x.h"
-extern char _dtb_start[];
-extern char _dtb_end[];
-
static u8 *ebony_mac0, *ebony_mac1;
/* Calculate 440GP clocks */
diff --git a/arch/powerpc/boot/holly.c b/arch/powerpc/boot/holly.c
index 7d6539f..199e783 100644
--- a/arch/powerpc/boot/holly.c
+++ b/arch/powerpc/boot/holly.c
@@ -21,11 +21,6 @@
#include "ops.h"
#include "io.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)
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 416dc38..1b496b3 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -19,16 +19,6 @@
#include "flatdevtree.h"
#include "reg.h"
-extern char _start[];
-extern char __bss_start[];
-extern char _end[];
-extern char _vmlinux_start[];
-extern char _vmlinux_end[];
-extern char _initrd_start[];
-extern char _initrd_end[];
-extern char _dtb_start[];
-extern char _dtb_end[];
-
static struct gunzip_state gzstate;
struct addr_range {
diff --git a/arch/powerpc/boot/of.c b/arch/powerpc/boot/of.c
index 385e08b..61d9899 100644
--- a/arch/powerpc/boot/of.c
+++ b/arch/powerpc/boot/of.c
@@ -17,8 +17,6 @@
#include "of.h"
-extern char _end[];
-
/* Value picked to match that used by yaboot */
#define PROG_START 0x01400000 /* only used on 64-bit systems */
#define RAM_END (512<<20) /* Fixme: use OF */
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 2bc2f02..e4b6139 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -196,4 +196,14 @@ static inline void exit(void)
extern unsigned long timebase_period_ns;
void udelay(long delay);
+extern char _start[];
+extern char __bss_start[];
+extern char _end[];
+extern char _vmlinux_start[];
+extern char _vmlinux_end[];
+extern char _initrd_start[];
+extern char _initrd_end[];
+extern char _dtb_start[];
+extern char _dtb_end[];
+
#endif /* _PPC_BOOT_OPS_H_ */
diff --git a/arch/powerpc/boot/prpmc2800.c b/arch/powerpc/boot/prpmc2800.c
index 5c6cd36..9614e1d 100644
--- a/arch/powerpc/boot/prpmc2800.c
+++ b/arch/powerpc/boot/prpmc2800.c
@@ -21,10 +21,6 @@
#include "gunzip_util.h"
#include "mv64x60.h"
-extern char _end[];
-extern char _vmlinux_start[], _vmlinux_end[];
-extern char _dtb_start[], _dtb_end[];
-
#define KB 1024U
#define MB (KB*KB)
#define GB (KB*MB)
diff --git a/arch/powerpc/boot/ps3.c b/arch/powerpc/boot/ps3.c
index 893d593..d666115 100644
--- a/arch/powerpc/boot/ps3.c
+++ b/arch/powerpc/boot/ps3.c
@@ -120,10 +120,6 @@ void ps3_copy_vectors(void)
void platform_init(void)
{
- extern char _end[];
- extern char _dtb_start[];
- extern char _initrd_start[];
- extern char _initrd_end[];
const u32 heapsize = 0x1000000 - (u32)_end; /* 16MiB */
void *chosen;
unsigned long ft_addr;
diff --git a/arch/powerpc/boot/treeboot-ebony.c b/arch/powerpc/boot/treeboot-ebony.c
index 8436a9c..21cc483 100644
--- a/arch/powerpc/boot/treeboot-ebony.c
+++ b/arch/powerpc/boot/treeboot-ebony.c
@@ -16,8 +16,6 @@
#include "stdio.h"
#include "44x.h"
-extern char _end[];
-
BSS_STACK(4096);
#define OPENBIOS_MAC_BASE 0xfffffe0c
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 11/20] bootwrapper: Move linker symbols into ops.h.
2007-08-20 17:39 ` [PATCH 11/20] bootwrapper: Move linker symbols into ops.h Scott Wood
@ 2007-08-21 2:43 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-21 2:43 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:39:58PM -0500, Scott Wood wrote:
> Most of these were previously used by numerous C files and
> redeclared in each one.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
Hrm. I like the idea of putting these into a header, but I don't so
much like putting them in ops.h, which is showing a tendency to become
a pile of random junk, rather than actually related to "ops".
--
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] 60+ messages in thread
* [PATCH 12/20] bootwrapper: Add 8xx cuboot support.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (9 preceding siblings ...)
2007-08-20 17:39 ` [PATCH 11/20] bootwrapper: Move linker symbols into ops.h Scott Wood
@ 2007-08-20 17:40 ` Scott Wood
2007-08-21 2:44 ` David Gibson
2007-08-20 17:40 ` [PATCH 13/20] bootwrapper: Add PowerQUICC II (82xx with CPM) " Scott Wood
` (8 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:40 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
This allows booting on legacy, non-device-tree aware versions of U-boot.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/Makefile | 3 +-
arch/powerpc/boot/cuboot-8xx.c | 45 ++++++++++++++++++++++++++++++++
arch/powerpc/platforms/Kconfig.cputype | 1 +
3 files changed, 48 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/boot/cuboot-8xx.c
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 997980f..e75c92b 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -48,7 +48,7 @@ src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
cpm-serial.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
- ps3-head.S ps3-hvcall.S ps3.c
+ ps3-head.S ps3-hvcall.S ps3.c cuboot-8xx.c
src-boot := $(src-wlib) $(src-plat) empty.c
src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -140,6 +140,7 @@ image-$(CONFIG_PPC_ISERIES) += zImage.iseries
image-$(CONFIG_DEFAULT_UIMAGE) += uImage
ifneq ($(CONFIG_DEVICE_TREE),"")
+image-$(CONFIG_PPC_8xx) += cuImage.8xx
image-$(CONFIG_PPC_83xx) += cuImage.83xx
image-$(CONFIG_PPC_85xx) += cuImage.85xx
image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony
diff --git a/arch/powerpc/boot/cuboot-8xx.c b/arch/powerpc/boot/cuboot-8xx.c
new file mode 100644
index 0000000..88ed840
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-8xx.c
@@ -0,0 +1,45 @@
+/*
+ * Old U-boot compatibility for 8xx
+ *
+ * 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"
+#include "cuboot.h"
+
+#define TARGET_8xx
+#define TARGET_HAS_ETH1
+#include "ppcboot.h"
+
+static bd_t bd;
+
+static void platform_fixups(void)
+{
+ void *node;
+
+ 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 / 16, bd.bi_busfreq);
+
+ node = finddevice("/soc/cpm");
+ if (node) {
+ setprop(node, "clock-frequency", &bd.bi_busfreq, 4);
+ setprop(node, "fsl,brg-frequency", &bd.bi_busfreq, 4);
+ }
+}
+
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+ unsigned long r6, unsigned long r7)
+{
+ CUBOOT_INIT();
+ ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
+ serial_console_init();
+ platform_ops.fixups = platform_fixups;
+}
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index e4b2aee..44417bd 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -36,6 +36,7 @@ config PPC_8xx
bool "Freescale 8xx"
select FSL_SOC
select 8xx
+ select WANT_DEVICE_TREE
config 40x
bool "AMCC 40x"
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 12/20] bootwrapper: Add 8xx cuboot support.
2007-08-20 17:40 ` [PATCH 12/20] bootwrapper: Add 8xx cuboot support Scott Wood
@ 2007-08-21 2:44 ` David Gibson
2007-08-21 16:20 ` Scott Wood
0 siblings, 1 reply; 60+ messages in thread
From: David Gibson @ 2007-08-21 2:44 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:40:01PM -0500, Scott Wood wrote:
> This allows booting on legacy, non-device-tree aware versions of
> U-boot.
Is this really sufficient for all 8xx platforms?
--
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] 60+ messages in thread
* Re: [PATCH 12/20] bootwrapper: Add 8xx cuboot support.
2007-08-21 2:44 ` David Gibson
@ 2007-08-21 16:20 ` Scott Wood
2007-08-22 1:47 ` David Gibson
0 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-21 16:20 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, paulus
David Gibson wrote:
> On Mon, Aug 20, 2007 at 12:40:01PM -0500, Scott Wood wrote:
>
>>This allows booting on legacy, non-device-tree aware versions of
>>U-boot.
>
>
> Is this really sufficient for all 8xx platforms?
It should be enough for all u-boot-based 8xx boards, barring some u-boot
which needs special fixups (as is done in cuboot-pq2.c). If such a need
arises, they can be added to cuboot-8xx.c (if they're generic enough to
work on all boards, even if not actually needed) or to a board-specific
platform file (which can coexist just fine with the generic 8xx one).
-Scott
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [PATCH 12/20] bootwrapper: Add 8xx cuboot support.
2007-08-21 16:20 ` Scott Wood
@ 2007-08-22 1:47 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-22 1:47 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Tue, Aug 21, 2007 at 11:20:21AM -0500, Scott Wood wrote:
> David Gibson wrote:
> > On Mon, Aug 20, 2007 at 12:40:01PM -0500, Scott Wood wrote:
> >
> >>This allows booting on legacy, non-device-tree aware versions of
> >>U-boot.
> >
> >
> > Is this really sufficient for all 8xx platforms?
>
> It should be enough for all u-boot-based 8xx boards, barring some u-boot
> which needs special fixups (as is done in cuboot-pq2.c). If such a need
> arises, they can be added to cuboot-8xx.c (if they're generic enough to
> work on all boards, even if not actually needed) or to a board-specific
> platform file (which can coexist just fine with the generic 8xx
> one).
Ok. Presumably our bd_t won't exactly line up for all 8xx (since it
varies from platform to platform, yes?) - but I gather the only bits
we use do match up. That's probably worth a comment, so that someone
doesn't try using some later bd_t field which is only in the right
place for some 8xx systems.
Otherwise,
Acked-by: David Gibson <david@gibson.dropbear.id.au>
--
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] 60+ messages in thread
* [PATCH 13/20] bootwrapper: Add PowerQUICC II (82xx with CPM) cuboot support.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (10 preceding siblings ...)
2007-08-20 17:40 ` [PATCH 12/20] bootwrapper: Add 8xx cuboot support Scott Wood
@ 2007-08-20 17:40 ` Scott Wood
2007-08-21 3:30 ` David Gibson
2007-08-20 17:40 ` [PATCH 14/20] bootwrapper: Add strtoull() Scott Wood
` (7 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:40 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
This allows booting on legacy, non-device-tree aware versions of U-boot.
It also fixes up the hardware to match the PCI and chipselect information
in the device tree, as u-boot is inconsistent in setting these up
correctly (or at all).
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/Makefile | 3 +-
arch/powerpc/boot/cuboot-pq2.c | 283 ++++++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/devtree.c | 6 +-
arch/powerpc/boot/ops.h | 9 ++
arch/powerpc/platforms/Kconfig | 1 +
5 files changed, 298 insertions(+), 4 deletions(-)
create mode 100644 arch/powerpc/boot/cuboot-pq2.c
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index e75c92b..4ab5f75 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -48,7 +48,7 @@ src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \
cpm-serial.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
- ps3-head.S ps3-hvcall.S ps3.c cuboot-8xx.c
+ ps3-head.S ps3-hvcall.S ps3.c cuboot-8xx.c cuboot-pq2.c
src-boot := $(src-wlib) $(src-plat) empty.c
src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -141,6 +141,7 @@ image-$(CONFIG_DEFAULT_UIMAGE) += uImage
ifneq ($(CONFIG_DEVICE_TREE),"")
image-$(CONFIG_PPC_8xx) += cuImage.8xx
+image-$(CONFIG_8260) += cuImage.pq2
image-$(CONFIG_PPC_83xx) += cuImage.83xx
image-$(CONFIG_PPC_85xx) += cuImage.85xx
image-$(CONFIG_EBONY) += treeImage.ebony cuImage.ebony
diff --git a/arch/powerpc/boot/cuboot-pq2.c b/arch/powerpc/boot/cuboot-pq2.c
new file mode 100644
index 0000000..8021fd4
--- /dev/null
+++ b/arch/powerpc/boot/cuboot-pq2.c
@@ -0,0 +1,283 @@
+/*
+ * Old U-boot compatibility for PowerQUICC II
+ * (a.k.a. 82xx with CPM, not the 8240 family of chips)
+ *
+ * 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"
+#include "cuboot.h"
+#include "io.h"
+
+#define TARGET_CPM2
+#define TARGET_HAS_ETH1
+#include "ppcboot.h"
+
+static bd_t bd;
+
+struct cs_range {
+ u32 csnum;
+ u32 base; /* must be zero */
+ u32 addr;
+ u32 size;
+};
+
+struct pci_range {
+ u32 flags;
+ u32 pci_addr[2];
+ u32 phys_addr;
+ u32 size[2];
+};
+
+struct cs_range cs_ranges_buf[MAX_PROP_LEN / sizeof(struct cs_range)];
+struct pci_range pci_ranges_buf[MAX_PROP_LEN / sizeof(struct pci_range)];
+
+/* Different versions of u-boot put the BCSR in different places, and
+ * some don't set up the PCI PIC at all, so we assume the device tree is
+ * sane and update the BRx registers appropriately.
+ *
+ * For any node defined as compatible with fsl,pq2-chipselect,
+ * #address/#size must be 2/1 for chipselect bus, 1/1 for parent bus,
+ * and ranges must be for whole chip selects.
+ */
+static void update_cs_ranges(void)
+{
+ u32 ctrl_ph;
+ void *ctrl_node, *bus_node, *parent_node;
+ u32 *ctrl_addr;
+ unsigned long ctrl_size;
+ u32 naddr, nsize;
+ int len;
+ int i;
+
+ bus_node = finddevice("/chipselect");
+ if (!bus_node || !dt_is_compatible(bus_node, "fsl,pq2-chipselect"))
+ return;
+
+ dt_get_reg_format(bus_node, &naddr, &nsize);
+ if (naddr != 2 || nsize != 1)
+ goto err;
+
+ parent_node = get_parent(bus_node);
+ if (!parent_node)
+ goto err;
+
+ dt_get_reg_format(parent_node, &naddr, &nsize);
+ if (naddr != 1 || nsize != 1)
+ goto err;
+
+ len = getprop(bus_node, "fsl,ctrl", &ctrl_ph, 4);
+ if (len != 4)
+ goto err;
+
+ ctrl_node = find_node_by_prop_value(NULL, "linux,phandle",
+ (char *)&ctrl_ph, 4);
+ if (!ctrl_node)
+ goto err;
+
+ if (!dt_is_compatible(ctrl_node, "fsl,pq2-chipselect-ctrl"))
+ goto err;
+
+ if (!dt_xlate_reg(ctrl_node, 0, (unsigned long *)&ctrl_addr,
+ &ctrl_size))
+ goto err;
+
+ len = getprop(bus_node, "ranges", cs_ranges_buf, sizeof(cs_ranges_buf));
+
+ for (i = 0; i < len / sizeof(struct cs_range); i++) {
+ u32 base, option;
+ int cs = cs_ranges_buf[i].csnum;
+ if (cs >= ctrl_size / 8)
+ goto err;
+
+ if (cs_ranges_buf[i].base != 0)
+ goto err;
+
+ base = in_be32(&ctrl_addr[cs * 2]);
+
+ /* If CS is already valid, use the existing flags.
+ * Otherwise, guess a sane default.
+ */
+ if (base & 1) {
+ base &= 0x7fff;
+ option = in_be32(&ctrl_addr[cs * 2 + 1]) & 0x7fff;
+ } else {
+ base = 0x1801;
+ option = 0x10;
+ }
+
+ out_be32(&ctrl_addr[cs * 2], 0);
+ out_be32(&ctrl_addr[cs * 2 + 1],
+ option | ~(cs_ranges_buf[i].size - 1));
+ out_be32(&ctrl_addr[cs * 2], base | cs_ranges_buf[i].addr);
+ }
+
+ return;
+
+err:
+ printf("Bad /chipselect or fsl,pq2-chipselect-ctrl node\r\n");
+}
+
+/* Older u-boots don't set PCI up properly. Update the hardware to match
+ * the device tree. The prefetch mem region and non-prefetch mem region
+ * must be contiguous in the host bus. As required by the PCI binding,
+ * PCI #addr/#size must be 3/2. The parent bus must be 1/1. Only
+ * 32-bit PCI is supported. All three region types (prefetchable mem,
+ * non-prefetchable mem, and I/O) must be present.
+ */
+static void fixup_pci(void)
+{
+ struct pci_range *mem = NULL, *mmio = NULL,
+ *io = NULL, *mem_base = NULL;
+ u32 *pci_regs[3];
+ u8 *soc_regs;
+ int i, len;
+ void *ctrl_node, *bus_node, *parent_node, *soc_node;
+ u32 naddr, nsize, bus_ph, mem_log2;
+
+ ctrl_node = finddevice("/soc/pci");
+ if (!ctrl_node || !dt_is_compatible(ctrl_node, "fsl,pq2-pci"))
+ return;
+
+ soc_node = finddevice("/soc");
+ if (!soc_node || !dt_is_compatible(soc_node, "fsl,pq2-soc"))
+ goto err;
+
+ for (i = 0; i < 3; i++)
+ if (!dt_xlate_reg(ctrl_node, i,
+ (unsigned long *)&pci_regs[i], NULL))
+ goto err;
+
+ if (!dt_xlate_reg(soc_node, 0, (unsigned long *)&soc_regs, NULL))
+ goto err;
+
+ len = getprop(ctrl_node, "fsl,bus", &bus_ph, 4);
+ if (len != 4)
+ goto err;
+
+ bus_node = find_node_by_prop_value(NULL, "linux,phandle",
+ (char *)&bus_ph, 4);
+ if (!bus_node)
+ goto err;
+
+ dt_get_reg_format(bus_node, &naddr, &nsize);
+ if (naddr != 3 || nsize != 2)
+ goto err;
+
+ parent_node = get_parent(bus_node);
+ if (!parent_node)
+ goto err;
+
+ dt_get_reg_format(parent_node, &naddr, &nsize);
+ if (naddr != 1 || nsize != 1)
+ goto err;
+
+ len = getprop(bus_node, "ranges", pci_ranges_buf,
+ sizeof(pci_ranges_buf));
+
+ for (i = 0; i < len / sizeof(struct pci_range); i++) {
+ u32 flags = pci_ranges_buf[i].flags & 0x43000000;
+
+ if (flags == 0x42000000)
+ mem = &pci_ranges_buf[i];
+ else if (flags == 0x02000000)
+ mmio = &pci_ranges_buf[i];
+ else if (flags == 0x01000000)
+ io = &pci_ranges_buf[i];
+ }
+
+ if (!mem || !mmio || !io)
+ goto err;
+
+ if (mem->phys_addr + mem->size[1] == mmio->phys_addr)
+ mem_base = mem;
+ else if (mmio->phys_addr + mmio->size[1] == mem->phys_addr)
+ mem_base = mmio;
+ else
+ goto err;
+
+ out_be32(&pci_regs[1][0], mem_base->phys_addr | 1);
+ out_be32(&pci_regs[2][0], ~(mem->size[1] + mmio->size[1] - 1));
+
+ out_be32(&pci_regs[1][1], io->phys_addr | 1);
+ out_be32(&pci_regs[2][1], ~(io->size[1] - 1));
+
+ out_le32(&pci_regs[0][0], mem->pci_addr[1] >> 12);
+ out_le32(&pci_regs[0][2], mem->phys_addr >> 12);
+ out_le32(&pci_regs[0][4], (~(mem->size[1] - 1) >> 12) | 0xa0000000);
+
+ out_le32(&pci_regs[0][6], mmio->pci_addr[1] >> 12);
+ out_le32(&pci_regs[0][8], mmio->phys_addr >> 12);
+ out_le32(&pci_regs[0][10], (~(mmio->size[1] - 1) >> 12) | 0x80000000);
+
+ out_le32(&pci_regs[0][12], io->pci_addr[1] >> 12);
+ out_le32(&pci_regs[0][14], io->phys_addr >> 12);
+ out_le32(&pci_regs[0][16], (~(io->size[1] - 1) >> 12) | 0xc0000000);
+
+ /* Inbound translation */
+ out_le32(&pci_regs[0][58], 0);
+ out_le32(&pci_regs[0][60], 0);
+
+ mem_log2 = 1 << (__ilog2_u32(bd.bi_memsize - 1) + 1);
+ out_le32(&pci_regs[0][62], 0xa0000000 | ~((1 << (mem_log2 - 12)) - 1));
+
+ /* If PCI is disabled, drive RST high to enable. */
+ if (!(in_le32(&pci_regs[0][32]) & 1)) {
+ /* Tpvrh (Power valid to RST# high) 100 ms */
+ udelay(100000);
+
+ out_le32(&pci_regs[0][32], 1);
+
+ /* Trhfa (RST# high to first cfg access) 2^25 clocks */
+ udelay(1020000);
+ }
+
+ /* Enable bus master and memory access */
+ out_le32(&pci_regs[0][64], 0x80000004);
+ out_le32(&pci_regs[0][65], in_le32(&pci_regs[0][65]) | 6);
+
+ /* Park the bus on PCI, and elevate PCI's arbitration priority,
+ * as required by section 9.6 of the user's manual.
+ */
+ out_8(&soc_regs[0x10028], 3);
+ out_be32((u32 *)&soc_regs[0x1002c], 0x01236745);
+
+ return;
+
+err:
+ printf("Bad PCI node\r\n");
+}
+
+static void pq2_platform_fixups(void)
+{
+ void *node;
+
+ 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);
+
+ node = finddevice("/soc/cpm");
+ if (node) {
+ setprop(node, "clock-frequency", &bd.bi_cpmfreq, 4);
+ setprop(node, "fsl,brg-frequency", &bd.bi_brgfreq, 4);
+ }
+
+ update_cs_ranges();
+ fixup_pci();
+}
+
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+ unsigned long r6, unsigned long r7)
+{
+ CUBOOT_INIT();
+ ft_init(_dtb_start, _dtb_end - _dtb_start, 32);
+ serial_console_init();
+ platform_ops.fixups = pq2_platform_fixups;
+}
diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
index 3a18bfe..e1b8122 100644
--- a/arch/powerpc/boot/devtree.c
+++ b/arch/powerpc/boot/devtree.c
@@ -114,7 +114,7 @@ void __dt_fixup_mac_addresses(u32 startindex, ...)
#define MAX_ADDR_CELLS 4
-static void get_reg_format(void *node, u32 *naddr, u32 *nsize)
+void dt_get_reg_format(void *node, u32 *naddr, u32 *nsize)
{
if (getprop(node, "#address-cells", naddr, 4) != 4)
*naddr = 2;
@@ -224,7 +224,7 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
if (!parent)
return 0;
- get_reg_format(parent, &naddr, &nsize);
+ dt_get_reg_format(parent, &naddr, &nsize);
if (nsize > 2)
return 0;
@@ -252,7 +252,7 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
if (!parent)
break;
- get_reg_format(parent, &naddr, &nsize);
+ dt_get_reg_format(parent, &naddr, &nsize);
buflen = getprop(node, "ranges", prop_buf,
sizeof(prop_buf));
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index e4b6139..45c2268 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -89,6 +89,7 @@ extern void flush_cache(void *, unsigned long);
int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size);
int dt_xlate_addr(void *node, u32 *buf, int buflen, unsigned long *xlated_addr);
int dt_is_compatible(void *node, const char *compat);
+void dt_get_reg_format(void *node, u32 *naddr, u32 *nsize);
static inline void *finddevice(const char *name)
{
@@ -206,4 +207,12 @@ extern char _initrd_end[];
extern char _dtb_start[];
extern char _dtb_end[];
+static inline __attribute__((const))
+int __ilog2_u32(u32 n)
+{
+ int bit;
+ asm ("cntlzw %0,%1" : "=r" (bit) : "r" (n));
+ return 31 - bit;
+}
+
#endif /* _PPC_BOOT_OPS_H_ */
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index 94b12dc..524a954 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -19,6 +19,7 @@ config EMBEDDED6xx
config PPC_82xx
bool "Freescale 82xx"
depends on 6xx
+ select WANT_DEVICE_TREE
config PPC_83xx
bool "Freescale 83xx"
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* [PATCH 14/20] bootwrapper: Add strtoull().
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (11 preceding siblings ...)
2007-08-20 17:40 ` [PATCH 13/20] bootwrapper: Add PowerQUICC II (82xx with CPM) " Scott Wood
@ 2007-08-20 17:40 ` Scott Wood
2007-08-21 2:47 ` David Gibson
2007-08-20 17:40 ` [PATCH 15/20] bootwrapper: Add dt_get_path() Scott Wood
` (6 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:40 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
This will be needed by PlanetCore firmware support.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/Makefile | 2 +-
arch/powerpc/boot/stdlib.c | 41 +++++++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/stdlib.h | 6 ++++++
3 files changed, 48 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/boot/stdlib.c
create mode 100644 arch/powerpc/boot/stdlib.h
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 4ab5f75..bad54ba 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -45,7 +45,7 @@ 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 elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
44x.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c \
- cpm-serial.c
+ cpm-serial.c stdlib.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
ps3-head.S ps3-hvcall.S ps3.c cuboot-8xx.c cuboot-pq2.c
diff --git a/arch/powerpc/boot/stdlib.c b/arch/powerpc/boot/stdlib.c
new file mode 100644
index 0000000..ed6e728
--- /dev/null
+++ b/arch/powerpc/boot/stdlib.c
@@ -0,0 +1,41 @@
+/*
+ * stdlib functions
+ *
+ * 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 "stdlib.h"
+
+/* Not currently supported: leading whitespace, sign, 0x prefix, zero base */
+unsigned long long int strtoull(const char *ptr, char **end, int base)
+{
+ unsigned long long ret = 0;
+
+ while (*ptr) {
+ int digit;
+
+ if (*ptr >= '0' && *ptr <= '9')
+ digit = *ptr - '0';
+ else if (*ptr >= 'A' && *ptr <= 'Z')
+ digit = *ptr - 'A' + 10;
+ else if (*ptr >= 'a' && *ptr <= 'z')
+ digit = *ptr - 'a' + 10;
+ else
+ break;
+
+ ret *= base;
+ ret += digit;
+ ptr++;
+ }
+
+ if (end)
+ *end = (char *)ptr;
+
+ return ret;
+}
diff --git a/arch/powerpc/boot/stdlib.h b/arch/powerpc/boot/stdlib.h
new file mode 100644
index 0000000..1bf01ac
--- /dev/null
+++ b/arch/powerpc/boot/stdlib.h
@@ -0,0 +1,6 @@
+#ifndef _PPC_BOOT_STDLIB_H_
+#define _PPC_BOOT_STDLIB_H_
+
+unsigned long long int strtoull(const char *ptr, char **end, int base);
+
+#endif
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 14/20] bootwrapper: Add strtoull().
2007-08-20 17:40 ` [PATCH 14/20] bootwrapper: Add strtoull() Scott Wood
@ 2007-08-21 2:47 ` David Gibson
2007-08-21 16:20 ` Scott Wood
0 siblings, 1 reply; 60+ messages in thread
From: David Gibson @ 2007-08-21 2:47 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:40:04PM -0500, Scott Wood wrote:
> This will be needed by PlanetCore firmware support.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> ---
> arch/powerpc/boot/Makefile | 2 +-
> arch/powerpc/boot/stdlib.c | 41 +++++++++++++++++++++++++++++++++++++++++
> arch/powerpc/boot/stdlib.h | 6 ++++++
> 3 files changed, 48 insertions(+), 1 deletions(-)
> create mode 100644 arch/powerpc/boot/stdlib.c
> create mode 100644 arch/powerpc/boot/stdlib.h
>
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index 4ab5f75..bad54ba 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -45,7 +45,7 @@ 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 elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
> 44x.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c \
> - cpm-serial.c
> + cpm-serial.c stdlib.c
> src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
> cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
> ps3-head.S ps3-hvcall.S ps3.c cuboot-8xx.c cuboot-pq2.c
> diff --git a/arch/powerpc/boot/stdlib.c b/arch/powerpc/boot/stdlib.c
> new file mode 100644
> index 0000000..ed6e728
> --- /dev/null
> +++ b/arch/powerpc/boot/stdlib.c
> @@ -0,0 +1,41 @@
> +/*
> + * stdlib functions
> + *
> + * 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 "stdlib.h"
> +
> +/* Not currently supported: leading whitespace, sign, 0x prefix, zero base */
> +unsigned long long int strtoull(const char *ptr, char **end, int base)
> +{
> + unsigned long long ret = 0;
> +
> + while (*ptr) {
> + int digit;
> +
> + if (*ptr >= '0' && *ptr <= '9')
> + digit = *ptr - '0';
> + else if (*ptr >= 'A' && *ptr <= 'Z')
> + digit = *ptr - 'A' + 10;
> + else if (*ptr >= 'a' && *ptr <= 'z')
> + digit = *ptr - 'a' + 10;
> + else
> + break;
Hrm... I note this has no sort of error checking if the string has
digits which don't fit in the given base.
> + ret *= base;
> + ret += digit;
> + ptr++;
> + }
> +
> + if (end)
> + *end = (char *)ptr;
> +
> + return ret;
> +}
> diff --git a/arch/powerpc/boot/stdlib.h b/arch/powerpc/boot/stdlib.h
> new file mode 100644
> index 0000000..1bf01ac
> --- /dev/null
> +++ b/arch/powerpc/boot/stdlib.h
> @@ -0,0 +1,6 @@
> +#ifndef _PPC_BOOT_STDLIB_H_
> +#define _PPC_BOOT_STDLIB_H_
> +
> +unsigned long long int strtoull(const char *ptr, char **end, int base);
> +
> +#endif
--
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] 60+ messages in thread
* Re: [PATCH 14/20] bootwrapper: Add strtoull().
2007-08-21 2:47 ` David Gibson
@ 2007-08-21 16:20 ` Scott Wood
0 siblings, 0 replies; 60+ messages in thread
From: Scott Wood @ 2007-08-21 16:20 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, paulus
David Gibson wrote:
>>+/* Not currently supported: leading whitespace, sign, 0x prefix, zero base */
>>+unsigned long long int strtoull(const char *ptr, char **end, int base)
>>+{
>>+ unsigned long long ret = 0;
>>+
>>+ while (*ptr) {
>>+ int digit;
>>+
>>+ if (*ptr >= '0' && *ptr <= '9')
>>+ digit = *ptr - '0';
>>+ else if (*ptr >= 'A' && *ptr <= 'Z')
>>+ digit = *ptr - 'A' + 10;
>>+ else if (*ptr >= 'a' && *ptr <= 'z')
>>+ digit = *ptr - 'a' + 10;
>>+ else
>>+ break;
>
>
> Hrm... I note this has no sort of error checking if the string has
> digits which don't fit in the given base.
Oops. I'll fix that.
-Scott
^ permalink raw reply [flat|nested] 60+ messages in thread
* [PATCH 15/20] bootwrapper: Add dt_get_path().
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (12 preceding siblings ...)
2007-08-20 17:40 ` [PATCH 14/20] bootwrapper: Add strtoull() Scott Wood
@ 2007-08-20 17:40 ` Scott Wood
2007-08-21 3:03 ` David Gibson
2007-08-20 17:40 ` [PATCH 16/20] bootwrapper: Move strncmp() and strchr() from flatdevtree_env.h to string.h Scott Wood
` (5 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:40 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
This will be used by the PlanetCore firmware support to construct
a linux,stdout-path from the serial node that it finds.
---
arch/powerpc/boot/devtree.c | 29 +++++++++++++++++++++++++++++
arch/powerpc/boot/ops.h | 1 +
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
index e1b8122..a92c8fb 100644
--- a/arch/powerpc/boot/devtree.c
+++ b/arch/powerpc/boot/devtree.c
@@ -331,3 +331,32 @@ int dt_is_compatible(void *node, const char *compat)
return 0;
}
+
+/* Returns the start of the path within the provided buffer, or NULL on
+ * error.
+ */
+char *dt_get_path(void *node, char *buf, int len)
+{
+ char *name = (char *)prop_buf;
+ char *orig_buf = buf;
+
+ buf += len;
+ *--buf = 0;
+
+ while (node) {
+ int len = getprop(node, "name", name, MAX_PROP_LEN);
+ if (len <= 0)
+ break;
+
+ if (len + 1 > buf - orig_buf)
+ return NULL;
+
+ buf -= len + 1;
+ buf[0] = '/';
+ memcpy(buf + 1, name, len);
+
+ node = get_parent(node);
+ }
+
+ return buf;
+}
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h
index 45c2268..5efdf26 100644
--- a/arch/powerpc/boot/ops.h
+++ b/arch/powerpc/boot/ops.h
@@ -90,6 +90,7 @@ int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size);
int dt_xlate_addr(void *node, u32 *buf, int buflen, unsigned long *xlated_addr);
int dt_is_compatible(void *node, const char *compat);
void dt_get_reg_format(void *node, u32 *naddr, u32 *nsize);
+char *dt_get_path(void *node, char *buf, int len);
static inline void *finddevice(const char *name)
{
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* [PATCH 16/20] bootwrapper: Move strncmp() and strchr() from flatdevtree_env.h to string.h.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (13 preceding siblings ...)
2007-08-20 17:40 ` [PATCH 15/20] bootwrapper: Add dt_get_path() Scott Wood
@ 2007-08-20 17:40 ` Scott Wood
2007-08-21 3:06 ` David Gibson
2007-08-20 17:40 ` [PATCH 17/20] bootwrapper: Add PlanetCore firmware support Scott Wood
` (4 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:40 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
strncmp() will be needed for PlanetCore firmware support.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/flatdevtree_env.h | 20 --------------------
arch/powerpc/boot/string.h | 20 ++++++++++++++++++++
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/arch/powerpc/boot/flatdevtree_env.h b/arch/powerpc/boot/flatdevtree_env.h
index 83bc1c7..ad0420d 100644
--- a/arch/powerpc/boot/flatdevtree_env.h
+++ b/arch/powerpc/boot/flatdevtree_env.h
@@ -24,24 +24,4 @@
#define be64_to_cpu(x) (x)
#define cpu_to_be64(x) (x)
-static inline int strncmp(const char *cs, const char *ct, size_t count)
-{
- signed char __res = 0;
-
- while (count) {
- if ((__res = *cs - *ct++) != 0 || !*cs++)
- break;
- count--;
- }
- return __res;
-}
-
-static inline char *strchr(const char *s, int c)
-{
- for (; *s != (char)c; ++s)
- if (*s == '\0')
- return NULL;
- return (char *)s;
-}
-
#endif /* _PPC_BOOT_FLATDEVTREE_ENV_H_ */
diff --git a/arch/powerpc/boot/string.h b/arch/powerpc/boot/string.h
index 9fdff1c..439ff64 100644
--- a/arch/powerpc/boot/string.h
+++ b/arch/powerpc/boot/string.h
@@ -14,4 +14,24 @@ extern void *memmove(void *dest, const void *src, unsigned long n);
extern void *memcpy(void *dest, const void *src, unsigned long n);
extern int memcmp(const void *s1, const void *s2, size_t n);
+static inline int strncmp(const char *cs, const char *ct, size_t count)
+{
+ signed char __res = 0;
+
+ while (count) {
+ if ((__res = *cs - *ct++) != 0 || !*cs++)
+ break;
+ count--;
+ }
+ return __res;
+}
+
+static inline char *strchr(const char *s, int c)
+{
+ for (; *s != (char)c; ++s)
+ if (*s == '\0')
+ return NULL;
+ return (char *)s;
+}
+
#endif /* _PPC_BOOT_STRING_H_ */
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 16/20] bootwrapper: Move strncmp() and strchr() from flatdevtree_env.h to string.h.
2007-08-20 17:40 ` [PATCH 16/20] bootwrapper: Move strncmp() and strchr() from flatdevtree_env.h to string.h Scott Wood
@ 2007-08-21 3:06 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-21 3:06 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:40:07PM -0500, Scott Wood wrote:
> strncmp() will be needed for PlanetCore firmware support.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
Hmm. They should be moved, but if we are, I'm inclined to implement
them in string.S with the rest of the string functions, rather than as
inlines. Below is a patch I've had in my queue for some time which
does exactly that for strchr().
Move bootwrapper's strchr() from .h to string.S
Currently the bootwrapper has an implementation of strchr(), but it's
done as an inline in flatdevtree_env.h, rather than implemented in
string.S with the rest of the string functions. This patch moves it
to string.S, matching the other string functions.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Index: working-2.6/arch/powerpc/boot/string.S
===================================================================
--- working-2.6.orig/arch/powerpc/boot/string.S 2007-06-28 14:30:16.000000000 +1000
+++ working-2.6/arch/powerpc/boot/string.S 2007-06-28 14:38:01.000000000 +1000
@@ -49,6 +49,17 @@
bne 1b
blr
+ .globl strchr
+strchr:
+ addi r3,r3,-1
+1: lbzu r0,1(r3)
+ cmpw 0,r0,r4
+ beqlr
+ cmpwi 0,r0,0
+ bne 1b
+ li r3,0
+ blr
+
.globl strcmp
strcmp:
addi r5,r3,-1
Index: working-2.6/arch/powerpc/boot/string.h
===================================================================
--- working-2.6.orig/arch/powerpc/boot/string.h 2007-06-28 14:38:52.000000000 +1000
+++ working-2.6/arch/powerpc/boot/string.h 2007-06-28 14:39:14.000000000 +1000
@@ -5,6 +5,7 @@
extern char *strcpy(char *dest, const char *src);
extern char *strncpy(char *dest, const char *src, size_t n);
extern char *strcat(char *dest, const char *src);
+extern char *strchr(const char *s, int c);
extern int strcmp(const char *s1, const char *s2);
extern size_t strlen(const char *s);
extern size_t strnlen(const char *s, size_t count);
Index: working-2.6/arch/powerpc/boot/flatdevtree_env.h
===================================================================
--- working-2.6.orig/arch/powerpc/boot/flatdevtree_env.h 2007-06-28 14:39:55.000000000 +1000
+++ working-2.6/arch/powerpc/boot/flatdevtree_env.h 2007-06-28 14:40:00.000000000 +1000
@@ -36,12 +36,4 @@
return __res;
}
-static inline char *strchr(const char *s, int c)
-{
- for (; *s != (char)c; ++s)
- if (*s == '\0')
- return NULL;
- return (char *)s;
-}
-
#endif /* _PPC_BOOT_FLATDEVTREE_ENV_H_ */
--
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] 60+ messages in thread
* [PATCH 17/20] bootwrapper: Add PlanetCore firmware support.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (14 preceding siblings ...)
2007-08-20 17:40 ` [PATCH 16/20] bootwrapper: Move strncmp() and strchr() from flatdevtree_env.h to string.h Scott Wood
@ 2007-08-20 17:40 ` Scott Wood
2007-08-21 3:16 ` David Gibson
2007-08-20 17:40 ` [PATCH 18/20] bootwrapper: Add a zImage.bin.<platform> target Scott Wood
` (3 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:40 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
This is a library that board code can use to extract information from the
PlanetCore configuration keys. PlanetCore is used on various boards from
Embedded Planet.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/Makefile | 2 +-
arch/powerpc/boot/planetcore.c | 160 ++++++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/planetcore.h | 49 ++++++++++++
3 files changed, 210 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/boot/planetcore.c
create mode 100644 arch/powerpc/boot/planetcore.h
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index bad54ba..cd00711 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -45,7 +45,7 @@ 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 elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
44x.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c \
- cpm-serial.c stdlib.c
+ cpm-serial.c stdlib.c planetcore.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
ps3-head.S ps3-hvcall.S ps3.c cuboot-8xx.c cuboot-pq2.c
diff --git a/arch/powerpc/boot/planetcore.c b/arch/powerpc/boot/planetcore.c
new file mode 100644
index 0000000..e0f85e6
--- /dev/null
+++ b/arch/powerpc/boot/planetcore.c
@@ -0,0 +1,160 @@
+/*
+ * PlanetCore configuration data support functions
+ *
+ * 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 "stdio.h"
+#include "stdlib.h"
+#include "ops.h"
+#include "planetcore.h"
+#include "io.h"
+
+void planetcore_prepare_table(char *table)
+{
+ int last_was_newline = 0;
+
+ while (*table != 10 || !last_was_newline) {
+ if (*table == 10) {
+ *table = 0;
+ last_was_newline = 1;
+ } else {
+ last_was_newline = 0;
+ }
+
+ table++;
+ }
+
+ *table = 0;
+}
+
+const char *planetcore_get_key(const char *table, const char *key)
+{
+ int keylen = strlen(key);
+
+ do {
+ if (!strncmp(table, key, keylen) && table[keylen] == '=')
+ return table + keylen + 1;
+
+ table += strlen(table) + 1;
+ } while (strlen(table) != 0);
+
+ return NULL;
+}
+
+int planetcore_get_decimal(const char *table, const char *key, u64 *val)
+{
+ const char *str = planetcore_get_key(table, key);
+ if (!str)
+ return 0;
+
+ *val = strtoull(str, NULL, 10);
+ return 1;
+}
+
+int planetcore_get_hex(const char *table, const char *key, u64 *val)
+{
+ const char *str = planetcore_get_key(table, key);
+ if (!str)
+ return 0;
+
+ *val = strtoull(str, NULL, 16);
+ return 1;
+}
+
+static u64 mac_table[4] = {
+ 0x000000000000,
+ 0x000000800000,
+ 0x000000400000,
+ 0x000000c00000,
+};
+
+void planetcore_set_mac_addrs(const char *table)
+{
+ char addr[4][6];
+ u64 int_addr;
+ int i, j;
+
+ if (!planetcore_get_hex(table, PLANETCORE_KEY_MAC_ADDR, &int_addr))
+ return;
+
+ for (i = 0; i < 4; i++) {
+ u64 this_dev_addr = int_addr | mac_table[i];
+
+ for (j = 5; j >= 0; j--) {
+ addr[i][j] = this_dev_addr & 0xff;
+ this_dev_addr >>= 8;
+ }
+ }
+
+ dt_fixup_mac_addresses(addr[0], addr[1], addr[2], addr[3]);
+}
+
+static char prop_buf[MAX_PROP_LEN];
+
+void planetcore_set_stdout_path(const char *table)
+{
+ char *path;
+ const char *label;
+ void *node, *chosen;
+
+ label = planetcore_get_key(table, PLANETCORE_KEY_SERIAL_PORT);
+ if (!label)
+ return;
+
+ node = find_node_by_prop_value_str(NULL, "linux,planetcore-label",
+ label);
+ if (!node)
+ return;
+
+ path = dt_get_path(node, prop_buf, MAX_PROP_LEN);
+ if (!path)
+ return;
+
+ chosen = finddevice("/chosen");
+ if (!chosen)
+ chosen = create_node(NULL, "chosen");
+ if (!chosen)
+ return;
+
+ setprop_str(chosen, "linux,stdout-path", path);
+}
+
+void planetcore_set_serial_speed(const char *table)
+{
+ void *chosen, *stdout;
+ u64 baud;
+ u32 baud32;
+ int len;
+
+ chosen = finddevice("/chosen");
+ if (!chosen)
+ return;
+
+ len = getprop(chosen, "linux,stdout-path", prop_buf, MAX_PROP_LEN);
+ if (len <= 0)
+ return;
+
+ stdout = finddevice(prop_buf);
+ if (!stdout) {
+ printf("planetcore_set_serial_speed: "
+ "Bad /chosen/linux,stdout-path.\r\n");
+
+ return;
+ }
+
+ if (!planetcore_get_decimal(table, PLANETCORE_KEY_SERIAL_BAUD,
+ &baud)) {
+ printf("planetcore_set_serial_speed: No SB tag.\r\n");
+ return;
+ }
+
+ baud32 = baud;
+ setprop(stdout, "current-speed", &baud32, 4);
+}
diff --git a/arch/powerpc/boot/planetcore.h b/arch/powerpc/boot/planetcore.h
new file mode 100644
index 0000000..0d4094f
--- /dev/null
+++ b/arch/powerpc/boot/planetcore.h
@@ -0,0 +1,49 @@
+#ifndef _PPC_BOOT_PLANETCORE_H_
+#define _PPC_BOOT_PLANETCORE_H_
+
+#include "types.h"
+
+#define PLANETCORE_KEY_BOARD_TYPE "BO"
+#define PLANETCORE_KEY_BOARD_REV "BR"
+#define PLANETCORE_KEY_MB_RAM "D1"
+#define PLANETCORE_KEY_MAC_ADDR "EA"
+#define PLANETCORE_KEY_FLASH_SPEED "FS"
+#define PLANETCORE_KEY_IP_ADDR "IP"
+#define PLANETCORE_KEY_KB_NVRAM "NV"
+#define PLANETCORE_KEY_PROCESSOR "PR"
+#define PLANETCORE_KEY_PROC_VARIANT "PV"
+#define PLANETCORE_KEY_SERIAL_BAUD "SB"
+#define PLANETCORE_KEY_SERIAL_PORT "SP"
+#define PLANETCORE_KEY_SWITCH "SW"
+#define PLANETCORE_KEY_TEMP_OFFSET "TC"
+#define PLANETCORE_KEY_TARGET_IP "TIP"
+#define PLANETCORE_KEY_CRYSTAL_HZ "XT"
+
+/* Prepare the table for processing, by turning all newlines
+ * into NULL bytes.
+ */
+void planetcore_prepare_table(char *table);
+
+/* Return the value associated with a given key in text,
+ * decimal, or hex format.
+ *
+ * Returns zero/NULL on failure, non-zero on success.
+ */
+const char *planetcore_get_key(const char *table, const char *key);
+int planetcore_get_decimal(const char *table, const char *key, u64 *val);
+int planetcore_get_hex(const char *table, const char *key, u64 *val);
+
+/* Updates the device tree local-mac-address properties based
+ * on the EA tag.
+ */
+void planetcore_set_mac_addrs(const char *table);
+
+/* Sets the linux,stdout-path in the /chosen node. This requires the
+ * linux,planetcore-label property in each serial node.
+ */
+void planetcore_set_stdout_path(const char *table);
+
+/* Sets the current-speed property in the serial node. */
+void planetcore_set_serial_speed(const char *table);
+
+#endif
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 17/20] bootwrapper: Add PlanetCore firmware support.
2007-08-20 17:40 ` [PATCH 17/20] bootwrapper: Add PlanetCore firmware support Scott Wood
@ 2007-08-21 3:16 ` David Gibson
2007-08-21 16:29 ` Scott Wood
0 siblings, 1 reply; 60+ messages in thread
From: David Gibson @ 2007-08-21 3:16 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:40:08PM -0500, Scott Wood wrote:
> This is a library that board code can use to extract information from the
> PlanetCore configuration keys. PlanetCore is used on various boards from
> Embedded Planet.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
[snip]
;5B;5B;5B> diff --git a/arch/powerpc/boot/planetcore.c b/arch/powerpc/boot/planetcore.c
> new file mode 100644
> index 0000000..e0f85e6
> --- /dev/null
> +++ b/arch/powerpc/boot/planetcore.c
> @@ -0,0 +1,160 @@
> +/*
> + * PlanetCore configuration data support functions
> + *
> + * 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 "stdio.h"
> +#include "stdlib.h"
> +#include "ops.h"
> +#include "planetcore.h"
> +#include "io.h"
Some comments describing the Planetcore table format wouldn't go
astray. I vaguely recall it from when I worked with an EP405 years
and years ago, but...
> +void planetcore_prepare_table(char *table)
> +{
> + int last_was_newline = 0;
> +
> + while (*table != 10 || !last_was_newline) {
> + if (*table == 10) {
> + *table = 0;
> + last_was_newline = 1;
> + } else {
> + last_was_newline = 0;
> + }
> +
> + table++;
> + }
Hrm.. this loop makes my brain hurt. It's correct as far as I can
determine what it's supposed to be doing, but I think there's got to
be a way to make what it's doing a little more obvious.
> + *table = 0;
> +}
--
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] 60+ messages in thread
* Re: [PATCH 17/20] bootwrapper: Add PlanetCore firmware support.
2007-08-21 3:16 ` David Gibson
@ 2007-08-21 16:29 ` Scott Wood
2007-08-22 1:20 ` David Gibson
0 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-21 16:29 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, paulus
David Gibson wrote:
>>+void planetcore_prepare_table(char *table)
>>+{
>>+ int last_was_newline = 0;
>>+
>>+ while (*table != 10 || !last_was_newline) {
>>+ if (*table == 10) {
>>+ *table = 0;
>>+ last_was_newline = 1;
>>+ } else {
>>+ last_was_newline = 0;
>>+ }
>>+
>>+ table++;
>>+ }
>
>
> Hrm.. this loop makes my brain hurt. It's correct as far as I can
> determine what it's supposed to be doing, but I think there's got to
> be a way to make what it's doing a little more obvious.
How about something like this:
char last = 0;
while (1) {
if (*table == '\n') {
*table = 0;
if (last == *table)
return;
}
last = *table++;
}
-Scott
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [PATCH 17/20] bootwrapper: Add PlanetCore firmware support.
2007-08-21 16:29 ` Scott Wood
@ 2007-08-22 1:20 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-22 1:20 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Tue, Aug 21, 2007 at 11:29:15AM -0500, Scott Wood wrote:
> David Gibson wrote:
> >>+void planetcore_prepare_table(char *table)
> >>+{
> >>+ int last_was_newline = 0;
> >>+
> >>+ while (*table != 10 || !last_was_newline) {
> >>+ if (*table == 10) {
> >>+ *table = 0;
> >>+ last_was_newline = 1;
> >>+ } else {
> >>+ last_was_newline = 0;
> >>+ }
> >>+
> >>+ table++;
> >>+ }
> >
> >
> > Hrm.. this loop makes my brain hurt. It's correct as far as I can
> > determine what it's supposed to be doing, but I think there's got to
> > be a way to make what it's doing a little more obvious.
>
> How about something like this:
>
> char last = 0;
>
> while (1) {
> if (*table == '\n') {
> *table = 0;
>
> if (last == *table)
> return;
> }
>
> last = *table++;
> }
*thinks*
How about:
do {
if (*table == '\n')
*table = '\0';
table++;
} while (*(table-1) || (*table != '\n'));
*table = '\0';
--
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] 60+ messages in thread
* [PATCH 18/20] bootwrapper: Add a zImage.bin.<platform> target.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (15 preceding siblings ...)
2007-08-20 17:40 ` [PATCH 17/20] bootwrapper: Add PlanetCore firmware support Scott Wood
@ 2007-08-20 17:40 ` Scott Wood
2007-08-21 3:27 ` David Gibson
2007-08-20 17:40 ` [PATCH 19/20] bootwrapper: Only print MAC addresses when the node is actually present Scott Wood
` (2 subsequent siblings)
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:40 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
This target produces a flat binary rather than an ELF file, and prints
the start address for the user to jump to (since it is unfortunately not
fixed).
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/Makefile | 5 ++++-
arch/powerpc/boot/wrapper | 11 +++++++++++
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index cd00711..6e7f518 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -124,7 +124,7 @@ endif
# args (to if_changed): 1 = (this rule), 2 = platform, 3 = dts 4=dtb 5=initrd
quiet_cmd_wrap = WRAP $@
cmd_wrap =$(CONFIG_SHELL) $(wrapper) -c -o $@ -p $2 $(CROSSWRAP) \
- $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) vmlinux
+ $(if $3, -s $3)$(if $4, -d $4)$(if $5, -i $5) $6 vmlinux
image-$(CONFIG_PPC_PSERIES) += zImage.pseries
image-$(CONFIG_PPC_MAPLE) += zImage.pseries
@@ -177,6 +177,9 @@ endif
$(obj)/zImage.initrd.%: vmlinux $(wrapperbits) $(dts)
$(call if_changed,wrap,$*,$(dts),,$(obj)/ramdisk.image.gz)
+$(obj)/zImage.bin.%: vmlinux $(wrapperbits) $(dts)
+ $(call if_changed,wrap,$*,$(dts),,,--binary)
+
$(obj)/zImage.%: vmlinux $(wrapperbits) $(dts)
$(call if_changed,wrap,$*,$(dts))
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index 65f6854..09c17fb 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -30,6 +30,7 @@ dtb=
dts=
cacheit=
gzip=.gz
+binary=
# cross-compilation prefix
CROSS=
@@ -44,6 +45,7 @@ usage() {
echo 'Usage: wrapper [-o output] [-p platform] [-i initrd]' >&2
echo ' [-d devtree] [-s tree.dts] [-c] [-C cross-prefix]' >&2
echo ' [-D datadir] [-W workingdir] [--no-gzip] [vmlinux]' >&2
+ echo ' [--binary]' >&2
exit 1
}
@@ -95,6 +97,9 @@ while [ "$#" -gt 0 ]; do
--no-gzip)
gzip=
;;
+ --binary)
+ binary=y
+ ;;
-?)
usage
;;
@@ -295,3 +300,9 @@ ps3)
gzip --force -9 --stdout "$ofile.bin" > "$object/otheros.bld"
;;
esac
+
+if [ -n "$binary" ]; then
+ mv "$ofile" "$ofile".elf
+ ${CROSS}objcopy -O binary "$ofile".elf "$ofile"
+ echo Entry point for $ofile is $entry.
+fi
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* [PATCH 19/20] bootwrapper: Only print MAC addresses when the node is actually present.
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (16 preceding siblings ...)
2007-08-20 17:40 ` [PATCH 18/20] bootwrapper: Add a zImage.bin.<platform> target Scott Wood
@ 2007-08-20 17:40 ` Scott Wood
2007-08-21 3:20 ` David Gibson
2007-08-20 17:40 ` [PATCH 20/20] bootwrapper: Add fsl_get_immr(), mpc885_get_clock(), and pq2_get_clocks() Scott Wood
2007-08-21 1:50 ` [PATCH 01/20] bootwrapper: Update .gitignore David Gibson
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:40 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
Some firmwares (such as PlanetCore) only provide a base MAC address, and
expect the kernel to set certain bits to generate the addresses for the
other ports. As such, MAC addresses are generated that may not correspond
to actual hardware.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/devtree.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
index a92c8fb..73fa5a8 100644
--- a/arch/powerpc/boot/devtree.c
+++ b/arch/powerpc/boot/devtree.c
@@ -100,12 +100,14 @@ void __dt_fixup_mac_addresses(u32 startindex, ...)
devp = find_node_by_prop_value(NULL, "linux,network-index",
(void*)&index, sizeof(index));
- printf("ENET%d: local-mac-address <-"
- " %02x:%02x:%02x:%02x:%02x:%02x\n\r", index,
- addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
+ if (devp) {
+ printf("ENET%d: local-mac-address <-"
+ " %02x:%02x:%02x:%02x:%02x:%02x\n\r", index,
+ addr[0], addr[1], addr[2],
+ addr[3], addr[4], addr[5]);
- if (devp)
setprop(devp, "local-mac-address", addr, 6);
+ }
index++;
}
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* [PATCH 20/20] bootwrapper: Add fsl_get_immr(), mpc885_get_clock(), and pq2_get_clocks().
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (17 preceding siblings ...)
2007-08-20 17:40 ` [PATCH 19/20] bootwrapper: Only print MAC addresses when the node is actually present Scott Wood
@ 2007-08-20 17:40 ` Scott Wood
2007-08-21 3:25 ` David Gibson
2007-08-21 1:50 ` [PATCH 01/20] bootwrapper: Update .gitignore David Gibson
19 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-20 17:40 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
fsl_get_immr() is equivalent to the kernel's get_immrbase() function.
mpc885_get_clock() transforms a crystal frequency into a system frequency
according to the PLL register settings.
pq2_get_clocks() does the same as the above for the PowerQUICC II,
except that it produces several different clocks.
Signed-off-by: Scott Wood <scottwood@freescale.com>
---
arch/powerpc/boot/Makefile | 2 +-
arch/powerpc/boot/fsl-soc.c | 47 +++++++++++++++++++++++++++
arch/powerpc/boot/fsl-soc.h | 8 ++++
arch/powerpc/boot/mpc8xx.c | 56 ++++++++++++++++++++++++++++++++
arch/powerpc/boot/mpc8xx.h | 8 ++++
arch/powerpc/boot/pq2.c | 75 +++++++++++++++++++++++++++++++++++++++++++
arch/powerpc/boot/pq2.h | 9 +++++
7 files changed, 204 insertions(+), 1 deletions(-)
create mode 100644 arch/powerpc/boot/fsl-soc.c
create mode 100644 arch/powerpc/boot/fsl-soc.h
create mode 100644 arch/powerpc/boot/mpc8xx.c
create mode 100644 arch/powerpc/boot/mpc8xx.h
create mode 100644 arch/powerpc/boot/pq2.c
create mode 100644 arch/powerpc/boot/pq2.h
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 6e7f518..6e4cbfa 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -45,7 +45,7 @@ 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 elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \
44x.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c \
- cpm-serial.c stdlib.c planetcore.c
+ cpm-serial.c stdlib.c planetcore.c fsl-soc.c mpc8xx.c pq2.c
src-plat := of.c cuboot-83xx.c cuboot-85xx.c holly.c \
cuboot-ebony.c treeboot-ebony.c prpmc2800.c \
ps3-head.S ps3-hvcall.S ps3.c cuboot-8xx.c cuboot-pq2.c
diff --git a/arch/powerpc/boot/fsl-soc.c b/arch/powerpc/boot/fsl-soc.c
new file mode 100644
index 0000000..e86a1fa
--- /dev/null
+++ b/arch/powerpc/boot/fsl-soc.c
@@ -0,0 +1,47 @@
+/*
+ * Freescale SOC support functions
+ *
+ * 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 "types.h"
+#include "fsl-soc.h"
+#include "stdio.h"
+
+static u32 prop_buf[MAX_PROP_LEN / 4];
+
+u32 *fsl_get_immr(void)
+{
+ void *soc;
+ unsigned long ret;
+
+ soc = find_node_by_devtype(NULL, "soc");
+ if (soc) {
+ int size;
+ u32 naddr;
+
+ size = getprop(soc, "#address-cells", prop_buf, MAX_PROP_LEN);
+ if (size == 4)
+ naddr = prop_buf[0];
+ else
+ naddr = 2;
+
+ size = getprop(soc, "ranges", prop_buf, MAX_PROP_LEN);
+ if (size >= 12) {
+ if (!dt_xlate_addr(soc, prop_buf + naddr, 8, &ret)) {
+ printf("fsl_get_immr: Can't xlate %x\r\n",
+ prop_buf[naddr]);
+ ret = 0;
+ }
+ }
+ } else printf("fsl_get_immr: No SOC node\r\n");
+
+ return (u32 *)ret;
+}
diff --git a/arch/powerpc/boot/fsl-soc.h b/arch/powerpc/boot/fsl-soc.h
new file mode 100644
index 0000000..5da26fc
--- /dev/null
+++ b/arch/powerpc/boot/fsl-soc.h
@@ -0,0 +1,8 @@
+#ifndef _PPC_BOOT_FSL_SOC_H_
+#define _PPC_BOOT_FSL_SOC_H_
+
+#include "types.h"
+
+u32 *fsl_get_immr(void);
+
+#endif
diff --git a/arch/powerpc/boot/mpc8xx.c b/arch/powerpc/boot/mpc8xx.c
new file mode 100644
index 0000000..a859a55
--- /dev/null
+++ b/arch/powerpc/boot/mpc8xx.c
@@ -0,0 +1,56 @@
+/*
+ * MPC8xx support functions
+ *
+ * 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 "types.h"
+#include "fsl-soc.h"
+#include "mpc8xx.h"
+#include "stdio.h"
+#include "io.h"
+
+#define MPC8XX_PLPRCR (0x284/4) /* PLL and Reset Control Register */
+
+/* Return system clock from crystal frequency */
+u32 mpc885_get_clock(u32 crystal)
+{
+ u32 *immr;
+ u32 plprcr;
+ int mfi, mfn, mfd, pdf, div;
+ u32 ret;
+
+ immr = fsl_get_immr();
+ if (!immr) {
+ printf("mpc885_get_clock: Couldn't get IMMR base.\r\n");
+ return 0;
+ }
+
+ plprcr = in_be32(&immr[MPC8XX_PLPRCR]);
+
+ mfi = (plprcr >> 16) & 15;
+ if (mfi < 5) {
+ printf("Warning: PLPRCR[MFI] value of %d out-of-bounds\r\n",
+ mfi);
+ mfi = 5;
+ }
+
+ pdf = (plprcr >> 1) & 0xf;
+ div = (plprcr >> 20) & 3;
+ mfd = (plprcr >> 22) & 0x1f;
+ mfn = (plprcr >> 27) & 0x1f;
+
+ ret = crystal * mfi;
+
+ if (mfn != 0)
+ ret += crystal * mfn / (mfd + 1);
+
+ return ret / (pdf + 1);
+}
diff --git a/arch/powerpc/boot/mpc8xx.h b/arch/powerpc/boot/mpc8xx.h
new file mode 100644
index 0000000..aa19669
--- /dev/null
+++ b/arch/powerpc/boot/mpc8xx.h
@@ -0,0 +1,8 @@
+#ifndef _PPC_BOOT_MPC8xx_H_
+#define _PPC_BOOT_MPC8xx_H_
+
+#include "types.h"
+
+u32 mpc885_get_clock(u32 crystal);
+
+#endif
diff --git a/arch/powerpc/boot/pq2.c b/arch/powerpc/boot/pq2.c
new file mode 100644
index 0000000..8f756dd
--- /dev/null
+++ b/arch/powerpc/boot/pq2.c
@@ -0,0 +1,75 @@
+/*
+ * PowerQUICC II support functions
+ *
+ * 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 "types.h"
+#include "fsl-soc.h"
+#include "pq2.h"
+#include "stdio.h"
+#include "io.h"
+
+#define PQ2_SCCR (0x10c80/4) /* System Clock Configuration Register */
+#define PQ2_SCMR (0x10c88/4) /* System Clock Mode Register */
+
+static int pq2_corecnf_map[] = {
+ 3, 2, 2, 2, 4, 4, 5, 9, 6, 11, 8, 10, 3, 12, 7, -1,
+ 6, 5, 13, 2, 14, 4, 15, 9, 0, 11, 8, 10, 16, 12, 7, -1
+};
+
+/* Get various clocks from crystal frequency.
+ * Returns zero on failure and non-zero on success.
+ */
+int pq2_get_clocks(u32 crystal, u32 *sysfreq, u32 *corefreq,
+ u32 *timebase, u32 *brgfreq)
+{
+ u32 *immr;
+ u32 sccr, scmr, mainclk, busclk;
+ int corecnf, busdf, plldf, pllmf, dfbrg;
+
+ immr = fsl_get_immr();
+ if (!immr) {
+ printf("pq2_get_clocks: Couldn't get IMMR base.\r\n");
+ return 0;
+ }
+
+ sccr = in_be32(&immr[PQ2_SCCR]);
+ scmr = in_be32(&immr[PQ2_SCMR]);
+
+ dfbrg = sccr & 3;
+ corecnf = (scmr >> 24) & 0x1f;
+ busdf = (scmr >> 20) & 0xf;
+ plldf = (scmr >> 12) & 1;
+ pllmf = scmr & 0xfff;
+
+ mainclk = crystal * (pllmf + 1) / (plldf + 1);
+ busclk = mainclk / (busdf + 1);
+
+ if (sysfreq)
+ *sysfreq = mainclk / 2;
+ if (timebase)
+ *timebase = busclk / 4;
+ if (brgfreq)
+ *brgfreq = mainclk / (1 << ((dfbrg + 1) * 2));
+
+ if (corefreq) {
+ int coremult = pq2_corecnf_map[corecnf];
+
+ if (coremult < 0)
+ *corefreq = mainclk / 2;
+ else if (coremult == 0)
+ return 0;
+ else
+ *corefreq = busclk * coremult / 2;
+ }
+
+ return 1;
+}
diff --git a/arch/powerpc/boot/pq2.h b/arch/powerpc/boot/pq2.h
new file mode 100644
index 0000000..1f4700c
--- /dev/null
+++ b/arch/powerpc/boot/pq2.h
@@ -0,0 +1,9 @@
+#ifndef _PPC_BOOT_PQ2_H_
+#define _PPC_BOOT_PQ2_H_
+
+#include "types.h"
+
+int pq2_get_clocks(u32 crystal, u32 *sysfreq, u32 *corefreq,
+ u32 *timebase, u32 *brgfreq);
+
+#endif
--
1.5.0.3
^ permalink raw reply related [flat|nested] 60+ messages in thread
* Re: [PATCH 20/20] bootwrapper: Add fsl_get_immr(), mpc885_get_clock(), and pq2_get_clocks().
2007-08-20 17:40 ` [PATCH 20/20] bootwrapper: Add fsl_get_immr(), mpc885_get_clock(), and pq2_get_clocks() Scott Wood
@ 2007-08-21 3:25 ` David Gibson
2007-08-21 16:34 ` Scott Wood
0 siblings, 1 reply; 60+ messages in thread
From: David Gibson @ 2007-08-21 3:25 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:40:13PM -0500, Scott Wood wrote:
> fsl_get_immr() is equivalent to the kernel's get_immrbase() function.
I notice that this function assumes that P==V. Is that true for all
relevant platforms at this point?
> mpc885_get_clock() transforms a crystal frequency into a system frequency
> according to the PLL register settings.
>
> pq2_get_clocks() does the same as the above for the PowerQUICC II,
> except that it produces several different clocks.
I'd prefer if these functions worked analagously to the
ibm440gp_fixup_clocks() function in ebony.c and fixed up the clock
values in the device tree directly, rather than returning them (where
the caller will presumably poke them into the device tree).
--
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] 60+ messages in thread
* Re: [PATCH 20/20] bootwrapper: Add fsl_get_immr(), mpc885_get_clock(), and pq2_get_clocks().
2007-08-21 3:25 ` David Gibson
@ 2007-08-21 16:34 ` Scott Wood
2007-08-22 1:30 ` David Gibson
0 siblings, 1 reply; 60+ messages in thread
From: Scott Wood @ 2007-08-21 16:34 UTC (permalink / raw)
To: David Gibson; +Cc: linuxppc-dev, paulus
David Gibson wrote:
> On Mon, Aug 20, 2007 at 12:40:13PM -0500, Scott Wood wrote:
>
>>fsl_get_immr() is equivalent to the kernel's get_immrbase() function.
>
> I notice that this function assumes that P==V. Is that true for all
> relevant platforms at this point?
Yes. If that ever changes, we'd probably need to add a virtual-immr or
similar.
>>mpc885_get_clock() transforms a crystal frequency into a system frequency
>>according to the PLL register settings.
>>
>>pq2_get_clocks() does the same as the above for the PowerQUICC II,
>>except that it produces several different clocks.
>
> I'd prefer if these functions worked analagously to the
> ibm440gp_fixup_clocks() function in ebony.c and fixed up the clock
> values in the device tree directly, rather than returning them (where
> the caller will presumably poke them into the device tree).
I wanted to separate the register interpretation from the knowledge of
where things are in the device tree.
-Scott
^ permalink raw reply [flat|nested] 60+ messages in thread
* Re: [PATCH 20/20] bootwrapper: Add fsl_get_immr(), mpc885_get_clock(), and pq2_get_clocks().
2007-08-21 16:34 ` Scott Wood
@ 2007-08-22 1:30 ` David Gibson
0 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-22 1:30 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Tue, Aug 21, 2007 at 11:34:45AM -0500, Scott Wood wrote:
> David Gibson wrote:
> > On Mon, Aug 20, 2007 at 12:40:13PM -0500, Scott Wood wrote:
> >
> >>fsl_get_immr() is equivalent to the kernel's get_immrbase() function.
> >
> > I notice that this function assumes that P==V. Is that true for all
> > relevant platforms at this point?
>
> Yes. If that ever changes, we'd probably need to add a virtual-immr or
> similar.
Ok.
> >>mpc885_get_clock() transforms a crystal frequency into a system frequency
> >>according to the PLL register settings.
> >>
> >>pq2_get_clocks() does the same as the above for the PowerQUICC II,
> >>except that it produces several different clocks.
> >
> > I'd prefer if these functions worked analagously to the
> > ibm440gp_fixup_clocks() function in ebony.c and fixed up the clock
> > values in the device tree directly, rather than returning them (where
> > the caller will presumably poke them into the device tree).
>
> I wanted to separate the register interpretation from the knowledge of
> where things are in the device tree.
Hrm. I considered that for a while with 44x, before deciding it
wasn't worth the extra hassle of passing a bunch of things around. If
you look at the 44x version, you'll see that the device tree poking
part is just the last few lines of the function and more-or-less
independent from the rest of it. So it should be easy to make the
function separable into hw-logic vs. dt-logic portions if we ever need
to.
--
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] 60+ messages in thread
* Re: [PATCH 01/20] bootwrapper: Update .gitignore
2007-08-20 17:39 [PATCH 01/20] bootwrapper: Update .gitignore Scott Wood
` (18 preceding siblings ...)
2007-08-20 17:40 ` [PATCH 20/20] bootwrapper: Add fsl_get_immr(), mpc885_get_clock(), and pq2_get_clocks() Scott Wood
@ 2007-08-21 1:50 ` David Gibson
19 siblings, 0 replies; 60+ messages in thread
From: David Gibson @ 2007-08-21 1:50 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
On Mon, Aug 20, 2007 at 12:39:20PM -0500, Scott Wood wrote:
> All cuImage types are ignored, as well as preprocessed .lds files,
> and the forthcoming zImage.bin files and embedded planet board images.
>
> Signed-off-by: Scott Wood <scottwood@freescale.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
--
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] 60+ messages in thread