Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: x86: Introduce pci_map_biosrom() x86, olpc: Use device tree for platform identification
This commit is contained in:
@@ -1,4 +1,2 @@
|
||||
obj-$(CONFIG_OLPC) += olpc.o
|
||||
obj-$(CONFIG_OLPC) += olpc.o olpc_ofw.o olpc_dt.o
|
||||
obj-$(CONFIG_OLPC_XO1) += olpc-xo1.o
|
||||
obj-$(CONFIG_OLPC) += olpc_ofw.o
|
||||
obj-$(CONFIG_OF_PROMTREE) += olpc_dt.o
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <linux/io.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/of.h>
|
||||
|
||||
#include <asm/geode.h>
|
||||
#include <asm/setup.h>
|
||||
@@ -187,41 +188,43 @@ err:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(olpc_ec_cmd);
|
||||
|
||||
static bool __init check_ofw_architecture(void)
|
||||
static bool __init check_ofw_architecture(struct device_node *root)
|
||||
{
|
||||
size_t propsize;
|
||||
char olpc_arch[5];
|
||||
const void *args[] = { NULL, "architecture", olpc_arch, (void *)5 };
|
||||
void *res[] = { &propsize };
|
||||
const char *olpc_arch;
|
||||
int propsize;
|
||||
|
||||
if (olpc_ofw("getprop", args, res)) {
|
||||
printk(KERN_ERR "ofw: getprop call failed!\n");
|
||||
return false;
|
||||
}
|
||||
olpc_arch = of_get_property(root, "architecture", &propsize);
|
||||
return propsize == 5 && strncmp("OLPC", olpc_arch, 5) == 0;
|
||||
}
|
||||
|
||||
static u32 __init get_board_revision(void)
|
||||
static u32 __init get_board_revision(struct device_node *root)
|
||||
{
|
||||
size_t propsize;
|
||||
__be32 rev;
|
||||
const void *args[] = { NULL, "board-revision-int", &rev, (void *)4 };
|
||||
void *res[] = { &propsize };
|
||||
int propsize;
|
||||
const __be32 *rev;
|
||||
|
||||
if (olpc_ofw("getprop", args, res) || propsize != 4) {
|
||||
printk(KERN_ERR "ofw: getprop call failed!\n");
|
||||
return cpu_to_be32(0);
|
||||
}
|
||||
return be32_to_cpu(rev);
|
||||
rev = of_get_property(root, "board-revision-int", &propsize);
|
||||
if (propsize != 4)
|
||||
return 0;
|
||||
|
||||
return be32_to_cpu(*rev);
|
||||
}
|
||||
|
||||
static bool __init platform_detect(void)
|
||||
{
|
||||
if (!check_ofw_architecture())
|
||||
struct device_node *root = of_find_node_by_path("/");
|
||||
bool success;
|
||||
|
||||
if (!root)
|
||||
return false;
|
||||
olpc_platform_info.flags |= OLPC_F_PRESENT;
|
||||
olpc_platform_info.boardrev = get_board_revision();
|
||||
return true;
|
||||
|
||||
success = check_ofw_architecture(root);
|
||||
if (success) {
|
||||
olpc_platform_info.boardrev = get_board_revision(root);
|
||||
olpc_platform_info.flags |= OLPC_F_PRESENT;
|
||||
}
|
||||
|
||||
of_node_put(root);
|
||||
return success;
|
||||
}
|
||||
|
||||
static int __init add_xo1_platform_devices(void)
|
||||
|
@@ -19,7 +19,9 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/bootmem.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_platform.h>
|
||||
#include <linux/of_pdt.h>
|
||||
#include <asm/olpc.h>
|
||||
#include <asm/olpc_ofw.h>
|
||||
|
||||
static phandle __init olpc_dt_getsibling(phandle node)
|
||||
@@ -180,3 +182,20 @@ void __init olpc_dt_build_devicetree(void)
|
||||
pr_info("PROM DT: Built device tree with %u bytes of memory.\n",
|
||||
prom_early_allocated);
|
||||
}
|
||||
|
||||
/* A list of DT node/bus matches that we want to expose as platform devices */
|
||||
static struct of_device_id __initdata of_ids[] = {
|
||||
{ .compatible = "olpc,xo1-battery" },
|
||||
{ .compatible = "olpc,xo1-dcon" },
|
||||
{ .compatible = "olpc,xo1-rtc" },
|
||||
{},
|
||||
};
|
||||
|
||||
static int __init olpc_create_platform_devices(void)
|
||||
{
|
||||
if (machine_is_olpc())
|
||||
return of_platform_bus_probe(NULL, of_ids, NULL);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
device_initcall(olpc_create_platform_devices);
|
||||
|
Reference in New Issue
Block a user