mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-17 17:24:17 +08:00
5fd200f3b3
Merge common code between PowerPC and microblaze. This patch merges the code that scans the tree and registers devices. The functions merged are of_platform_bus_probe(), of_platform_bus_create(), and of_platform_device_create(). This patch also move the of_default_bus_ids[] table out of a Microblaze header file and makes it non-static. The device ids table isn't merged because powerpc and microblaze use different default data. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> CC: Michal Simek <monstr@monstr.eu> CC: Grant Likely <grant.likely@secretlab.ca> CC: Benjamin Herrenschmidt <benh@kernel.crashing.org> CC: Stephen Rothwell <sfr@canb.auug.org.au> CC: microblaze-uclinux@itee.uq.edu.au CC: linuxppc-dev@ozlabs.org
96 lines
2.4 KiB
C
96 lines
2.4 KiB
C
/*
|
|
* Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corp.
|
|
* <benh@kernel.crashing.org>
|
|
* and Arnd Bergmann, IBM Corp.
|
|
*
|
|
* 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.
|
|
*
|
|
*/
|
|
|
|
#undef DEBUG
|
|
|
|
#include <linux/string.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <linux/mod_devicetable.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/of_platform.h>
|
|
|
|
#include <linux/errno.h>
|
|
#include <linux/topology.h>
|
|
#include <asm/atomic.h>
|
|
|
|
struct bus_type of_platform_bus_type = {
|
|
.uevent = of_device_uevent,
|
|
};
|
|
EXPORT_SYMBOL(of_platform_bus_type);
|
|
|
|
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);
|
|
|
|
/*
|
|
* 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", },
|
|
{ .type = "plb5", },
|
|
{ .type = "plb4", },
|
|
{ .type = "opb", },
|
|
{ .type = "simple", },
|
|
{},
|
|
};
|
|
|
|
static int of_dev_node_match(struct device *dev, void *data)
|
|
{
|
|
return to_of_device(dev)->dev.of_node == data;
|
|
}
|
|
|
|
struct of_device *of_find_device_by_node(struct device_node *np)
|
|
{
|
|
struct device *dev;
|
|
|
|
dev = bus_find_device(&of_platform_bus_type,
|
|
NULL, np, of_dev_node_match);
|
|
if (dev)
|
|
return to_of_device(dev);
|
|
return NULL;
|
|
}
|
|
EXPORT_SYMBOL(of_find_device_by_node);
|
|
|
|
static int of_dev_phandle_match(struct device *dev, void *data)
|
|
{
|
|
phandle *ph = data;
|
|
return to_of_device(dev)->dev.of_node->phandle == *ph;
|
|
}
|
|
|
|
struct of_device *of_find_device_by_phandle(phandle ph)
|
|
{
|
|
struct device *dev;
|
|
|
|
dev = bus_find_device(&of_platform_bus_type,
|
|
NULL, &ph, of_dev_phandle_match);
|
|
if (dev)
|
|
return to_of_device(dev);
|
|
return NULL;
|
|
}
|
|
EXPORT_SYMBOL(of_find_device_by_phandle);
|