Re: [PATCH 4/4] x86: OLPC: add OLPC device-tree support
From: Andres Salomon
Date: Tue Jun 29 2010 - 10:23:54 EST
On Tue, 29 Jun 2010 01:12:36 -0700
Grant Likely <grant.likely@xxxxxxxxxxxx> wrote:
> Hi Andres, comments below....
Thanks!
>
> On Mon, Jun 28, 2010 at 7:00 PM, Andres Salomon <dilinger@xxxxxxxxxx>
> wrote:
> >
> > Make use of PROC_DEVICETREE to export the tree, and sparc's
> > PROMTREE code to call into OLPC's Open Firmware to build the tree.
> >
> > (Yes, I know this leaks memory by simply using kmalloc)
> >
> > Signed-off-by: Andres Salomon <dilinger@xxxxxxxxxx>
> > ---
> > Âarch/x86/Kconfig         |  Â5 ++
> > Âarch/x86/include/asm/olpc_prom.h | Â 42 +++++++++++
> > Âarch/x86/include/asm/prom.h   Â|  Â5 ++
> > Âarch/x86/kernel/Makefile     |  Â1 +
> > Âarch/x86/kernel/olpc_ofw.c    |  13 ++++
> > Âarch/x86/kernel/olpc_prom.c   Â| Â148
> > ++++++++++++++++++++++++++++++++++++++ fs/proc/Kconfig
> > Â Â Â| Â Â2 +- 7 files changed, 215 insertions(+), 1 deletions(-)
> > Âcreate mode 100644 arch/x86/include/asm/olpc_prom.h
> > Âcreate mode 100644 arch/x86/include/asm/prom.h
> > Âcreate mode 100644 arch/x86/kernel/olpc_prom.c
> >
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > index 71c194d..7aea004 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -2071,6 +2071,11 @@ config OLPC_OPENFIRMWARE
> > Â Â Â Â Âthat is used on the OLPC XO-1 Children's Machine.
> > Â Â Â Â ÂIf unsure, say N here.
> >
> > +config OF
> > + Â Â Â def_bool y
> > + Â Â Â depends on OLPC_OPENFIRMWARE
> > + Â Â Â select OF_PROMTREE
> > +
>
> This hunk will need to be respun on top of Stephen's CONFIG_OF change.
> It's currently in my test-devicetree branch on
> git://git.secretlab.ca/git/linux-2.6
Yep, I've changed it locally.
>
> > Âendif # X86_32
> >
> > Âconfig K8_NB
> > diff --git a/arch/x86/include/asm/olpc_prom.h
> > b/arch/x86/include/asm/olpc_prom.h new file mode 100644
> > index 0000000..96cdcee
> > --- /dev/null
> > +++ b/arch/x86/include/asm/olpc_prom.h
> > @@ -0,0 +1,42 @@
> > +#include <linux/of.h> Â/* linux/of.h gets to determine #include
> > ordering */ +/*
> > + * Definitions for talking to the Open Firmware PROM on
> > + * Power Macintosh computers.
> > + *
> > + * Copyright (C) 1996-2005 Paul Mackerras.
> > + *
> > + * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM
> > Corp.
> > + * Updates for SPARC by David S. Miller
> > + * Updates for x86/OLPC by Andres Salomon
> > + *
> > + * This program is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU General Public License
> > + * as published by the Free Software Foundation; either version
> > + * 2 of the License, or (at your option) any later version.
> > + */
> > +
> > +#ifndef _X86_PROM_OLPC_H
> > +#define _X86_PROM_OLPC_H
> > +#ifdef __KERNEL__
> > +
> > +#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 2
> > +#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
>
> Do you really need to override these from the default?
>
> > +#define of_compat_cmp(s1, s2, l) Â Â Â strncmp((s1), (s2), (l))
> > +#define of_prop_cmp(s1, s2) Â Â Â Â Â Âstrcasecmp((s1), (s2))
> > +#define of_node_cmp(s1, s2) Â Â Â Â Â Âstrcmp((s1), (s2))
>
> Ditto here?
They're based upon what the old promfs patch used. I need to test and
verify that strings are being mangled in the same way before I start
making changes here.
>
> > +extern void prom_build_devicetree(void);
> > +
> > +extern void *prom_early_alloc(unsigned long size);
> > +
> > +extern char *prom_firstprop(phandle node, char *buf);
> > +extern char *prom_nextprop(phandle node, const char *prev, char
> > *buf); +extern int prom_getproplen(phandle node, const char *prop);
> > +extern int prom_getproperty(phandle node, const char *prop,
> > + Â Â Â Â Â Â Â Â Â Â Â Â Â Âchar *buffer, int bufsize);
> > +extern phandle prom_getchild(phandle node);
> > +extern phandle prom_getsibling(phandle node);
> > +
> > +#endif /* __KERNEL__ */
> > +#endif /* _X86_PROM_OLPC_H */
> > diff --git a/arch/x86/include/asm/prom.h
> > b/arch/x86/include/asm/prom.h new file mode 100644
> > index 0000000..7b561b2
> > --- /dev/null
> > +++ b/arch/x86/include/asm/prom.h
> > @@ -0,0 +1,5 @@
> > +#ifdef CONFIG_OLPC_OPENFIRMWARE
> > +# include <asm/olpc_prom.h>
> > +#else
> > +# error "No OFW prom defined for x86!"
> > +#endif
>
> Personally, I wouldn't bother with the header file redirection.
The reason for the header file redirection is because this is
OLPC-only; the x86 folks don't want me claiming this to be the One
True x86 OFW.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/