[PATCH 5/9] arch/x86: Add support for device tree code.

Grant Likely grant.likely at secretlab.ca
Wed Aug 11 04:00:34 EST 2010


On Fri, Jul 23, 2010 at 2:57 PM, Stephen Neuendorffer
<stephen.neuendorffer at xilinx.com> wrote:
> A few support device-tree related support functions that x86 didn't
> have before.
>
> Signed-off-by: Stephen Neuendorffer <stephen.neuendorffer at xilinx.com>
>
> ----
>
>  I have no idea if continuing to add these functions to every arch is
> a good thing or whether they should (for instance) be weak symbols
> with a generic definition.
> ---
>  arch/x86/include/asm/device.h |    3 ++
>  arch/x86/include/asm/irq.h    |    4 ++
>  arch/x86/kernel/Makefile      |    1 +
>  arch/x86/kernel/device_tree.c |   63 +++++++++++++++++++++++++++++++++++++++++
>  drivers/of/platform.c         |    2 +
>  include/linux/of_irq.h        |    1 +
>  6 files changed, 74 insertions(+), 0 deletions(-)
>  create mode 100644 arch/x86/kernel/device_tree.c
>
> diff --git a/arch/x86/include/asm/device.h b/arch/x86/include/asm/device.h
> index 029f230..0bf0a17 100644
> --- a/arch/x86/include/asm/device.h
> +++ b/arch/x86/include/asm/device.h
> @@ -16,4 +16,7 @@ struct dma_map_ops *dma_ops;
>  struct pdev_archdata {
>  };
>
> +/* Don't override the default bus id behaviour */
> +#define of_device_make_bus_id __of_device_make_bus_id

This should be unnecessary now.

>  #endif /* _ASM_X86_DEVICE_H */
> diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h
> index 5458380..6c61992 100644
> --- a/arch/x86/include/asm/irq.h
> +++ b/arch/x86/include/asm/irq.h
> @@ -10,6 +10,10 @@
>  #include <asm/apicdef.h>
>  #include <asm/irq_vectors.h>
>
> +#define NO_IRQ (-1)
> +

Remove

> +#define irq_dispose_mapping(...)

I need to create a default implementation for this.

>
>  static inline int irq_canonicalize(int irq)
>  {
>        return ((irq == 2) ? 9 : irq);
> diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
> index e77b220..a5c20e8 100644
> --- a/arch/x86/kernel/Makefile
> +++ b/arch/x86/kernel/Makefile
> @@ -105,6 +105,7 @@ scx200-y                    += scx200_32.o
>
>  obj-$(CONFIG_OLPC)             += olpc.o
>  obj-$(CONFIG_X86_MRST)         += mrst.o
> +obj-$(CONFIG_OF)               += device_tree.o
>
>  microcode-y                            := microcode_core.o
>  microcode-$(CONFIG_MICROCODE_INTEL)    += microcode_intel.o
> diff --git a/arch/x86/kernel/device_tree.c b/arch/x86/kernel/device_tree.c
> new file mode 100644
> index 0000000..543884c
> --- /dev/null
> +++ b/arch/x86/kernel/device_tree.c
> @@ -0,0 +1,63 @@
> +#undef DEBUG
> +
> +#include <linux/kernel.h>
> +#include <linux/string.h>
> +#include <linux/pci_regs.h>
> +#include <linux/module.h>
> +#include <linux/ioport.h>
> +#include <linux/etherdevice.h>
> +#include <linux/of.h>
> +#include <linux/of_device.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>
> +
> +struct bus_type of_platform_bus_type = {
> +       .uevent = of_device_uevent,
> +};
> +EXPORT_SYMBOL(of_platform_bus_type);

Remove

> +
> +static int __init of_bus_driver_init(void)
> +{
> +       return of_bus_type_init(&of_platform_bus_type, "of_platform");
> +}
> +postcore_initcall(of_bus_driver_init);

remove

> +
> +/*
> + * The list of OF IDs below is used for matching bus types in the
> + * system whose devices are to be exposed as of_platform_devices.
> + *
> + * This is the default list valid for most platforms. This file provides
> + * functions who can take an explicit list if necessary though
> + *
> + * The search is always performed recursively looking for children of
> + * the provided device_node and recursively if such a children matches
> + * a bus type in the list
> + */
> +
> +const struct of_device_id of_default_bus_ids[] = {
> +       { .type = "soc", },
> +       { .compatible = "soc", },
> +       { .compatible = "simple-bus", },
> +       { .type = "plb5", },
> +       { .type = "plb4", },
> +       { .type = "opb", },
> +       { .type = "simple", },
> +       {},
> +};

I believe this can also be removed.

> +
> +/*
> + * Interrupt remapper
> + */
> +
> +struct device_node *of_irq_find_parent_by_phandle(phandle p)
> +{
> +       return of_find_node_by_phandle(p);
> +}
> +

remove

> +unsigned int irq_create_of_mapping(struct device_node *controller,
> +                                  const u32 *intspec, unsigned int intsize)
> +{
> +       return intspec[0] + 1;
> +}

Hmmm.  I need to bring up more of the OF irq infrastructure so that
this is handled correctly.

> +EXPORT_SYMBOL_GPL(irq_create_of_mapping);
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index 9d3d932..0221125 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -20,6 +20,8 @@
>  #include <linux/of_device.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_platform.h>
> +#include <linux/of_address.h>
> +#include <linux/of_irq.h>

fixed in mainline.

>
>  #if defined(CONFIG_PPC_DCR)
>  #include <asm/dcr.h>
> diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
> index 5929781..25fc90d 100644
> --- a/include/linux/of_irq.h
> +++ b/include/linux/of_irq.h
> @@ -7,6 +7,7 @@ struct of_irq;
>  #include <linux/errno.h>
>  #include <linux/ioport.h>
>  #include <linux/of.h>
> +#include <linux/irq.h>

irq.h shouldn't actually be needed by this header.


More information about the devicetree-discuss mailing list