Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6
* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6: mtd/m25p80: add support to parse the partitions by OF node of/irq: of_irq.c needs to include linux/irq.h of/mips: Cleanup some include directives/files. of/mips: Add device tree support to MIPS of/flattree: Eliminate need to provide early_init_dt_scan_chosen_arch of/device: Rework to use common platform_device_alloc() for allocating devices of/xsysace: Fix OF probing on little-endian systems of: use __be32 types for big-endian device tree data of/irq: remove references to NO_IRQ in drivers/of/platform.c of/promtree: add package-to-path support to pdt of/promtree: add of_pdt namespace to pdt code of/promtree: no longer call prom_ functions directly; use an ops structure of/promtree: make drivers/of/pdt.c no longer sparc-only sparc: break out some PROM device-tree building code out into drivers/of of/sparc: convert various prom_* functions to use phandle sparc: stop exporting openprom.h header powerpc, of_serial: Endianness issues setting up the serial ports of: MTD: Fix OF probing on little-endian systems of: GPIO: Fix OF probing on little-endian systems
This commit is contained in:
@ -23,7 +23,7 @@ static DEFINE_SPINLOCK(auxio_lock);
|
||||
|
||||
void __init auxio_probe(void)
|
||||
{
|
||||
int node, auxio_nd;
|
||||
phandle node, auxio_nd;
|
||||
struct linux_prom_registers auxregs[1];
|
||||
struct resource r;
|
||||
|
||||
@ -113,7 +113,7 @@ volatile unsigned char * auxio_power_register = NULL;
|
||||
void __init auxio_power_probe(void)
|
||||
{
|
||||
struct linux_prom_registers regs;
|
||||
int node;
|
||||
phandle node;
|
||||
struct resource r;
|
||||
|
||||
/* Attempt to find the sun4m power control node. */
|
||||
|
@ -40,7 +40,7 @@ static unsigned char *dispDeviceBase __force_data;
|
||||
|
||||
static unsigned char vga_font[cmapsz];
|
||||
|
||||
static int __init btext_initialize(unsigned int node)
|
||||
static int __init btext_initialize(phandle node)
|
||||
{
|
||||
unsigned int width, height, depth, pitch;
|
||||
unsigned long address = 0;
|
||||
@ -309,7 +309,7 @@ static struct console btext_console = {
|
||||
|
||||
int __init btext_find_display(void)
|
||||
{
|
||||
unsigned int node;
|
||||
phandle node;
|
||||
char type[32];
|
||||
int ret;
|
||||
|
||||
|
@ -31,9 +31,9 @@ static char *cpu_mid_prop(void)
|
||||
return "mid";
|
||||
}
|
||||
|
||||
static int check_cpu_node(int nd, int *cur_inst,
|
||||
int (*compare)(int, int, void *), void *compare_arg,
|
||||
int *prom_node, int *mid)
|
||||
static int check_cpu_node(phandle nd, int *cur_inst,
|
||||
int (*compare)(phandle, int, void *), void *compare_arg,
|
||||
phandle *prom_node, int *mid)
|
||||
{
|
||||
if (!compare(nd, *cur_inst, compare_arg)) {
|
||||
if (prom_node)
|
||||
@ -51,8 +51,8 @@ static int check_cpu_node(int nd, int *cur_inst,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
|
||||
int *prom_node, int *mid)
|
||||
static int __cpu_find_by(int (*compare)(phandle, int, void *),
|
||||
void *compare_arg, phandle *prom_node, int *mid)
|
||||
{
|
||||
struct device_node *dp;
|
||||
int cur_inst;
|
||||
@ -71,7 +71,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static int cpu_instance_compare(int nd, int instance, void *_arg)
|
||||
static int cpu_instance_compare(phandle nd, int instance, void *_arg)
|
||||
{
|
||||
int desired_instance = (int) _arg;
|
||||
|
||||
@ -80,13 +80,13 @@ static int cpu_instance_compare(int nd, int instance, void *_arg)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
int cpu_find_by_instance(int instance, int *prom_node, int *mid)
|
||||
int cpu_find_by_instance(int instance, phandle *prom_node, int *mid)
|
||||
{
|
||||
return __cpu_find_by(cpu_instance_compare, (void *)instance,
|
||||
prom_node, mid);
|
||||
}
|
||||
|
||||
static int cpu_mid_compare(int nd, int instance, void *_arg)
|
||||
static int cpu_mid_compare(phandle nd, int instance, void *_arg)
|
||||
{
|
||||
int desired_mid = (int) _arg;
|
||||
int this_mid;
|
||||
@ -98,7 +98,7 @@ static int cpu_mid_compare(int nd, int instance, void *_arg)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
int cpu_find_by_mid(int mid, int *prom_node)
|
||||
int cpu_find_by_mid(int mid, phandle *prom_node)
|
||||
{
|
||||
return __cpu_find_by(cpu_mid_compare, (void *)mid,
|
||||
prom_node, NULL);
|
||||
@ -108,7 +108,7 @@ int cpu_find_by_mid(int mid, int *prom_node)
|
||||
* address (0-3). This gives us the true hardware mid, which might have
|
||||
* some other bits set. On 4d hardware and software mids are the same.
|
||||
*/
|
||||
int cpu_get_hwmid(int prom_node)
|
||||
int cpu_get_hwmid(phandle prom_node)
|
||||
{
|
||||
return prom_getintdefault(prom_node, cpu_mid_prop(), -ENODEV);
|
||||
}
|
||||
@ -119,7 +119,8 @@ void __init device_scan(void)
|
||||
|
||||
#ifndef CONFIG_SMP
|
||||
{
|
||||
int err, cpu_node;
|
||||
phandle cpu_node;
|
||||
int err;
|
||||
err = cpu_find_by_instance(0, &cpu_node, NULL);
|
||||
if (err) {
|
||||
/* Probably a sun4e, Sun is trying to trick us ;-) */
|
||||
|
@ -282,5 +282,5 @@ void __init leon_init_IRQ(void)
|
||||
|
||||
void __init leon_init(void)
|
||||
{
|
||||
prom_build_more = &leon_node_init;
|
||||
of_pdt_build_more = &leon_node_init;
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ int __init pcic_probe(void)
|
||||
struct linux_prom_registers regs[PROMREG_MAX];
|
||||
struct linux_pbm_info* pbm;
|
||||
char namebuf[64];
|
||||
int node;
|
||||
phandle node;
|
||||
int err;
|
||||
|
||||
if (pcic0_up) {
|
||||
@ -440,7 +440,7 @@ static int __devinit pdev_to_pnode(struct linux_pbm_info *pbm,
|
||||
{
|
||||
struct linux_prom_pci_registers regs[PROMREG_MAX];
|
||||
int err;
|
||||
int node = prom_getchild(pbm->prom_node);
|
||||
phandle node = prom_getchild(pbm->prom_node);
|
||||
|
||||
while(node) {
|
||||
err = prom_getproperty(node, "reg",
|
||||
|
@ -4,12 +4,6 @@
|
||||
#include <linux/spinlock.h>
|
||||
#include <asm/prom.h>
|
||||
|
||||
extern void * prom_early_alloc(unsigned long size);
|
||||
extern void irq_trans_init(struct device_node *dp);
|
||||
|
||||
extern unsigned int prom_unique_id;
|
||||
|
||||
extern char *build_path_component(struct device_node *dp);
|
||||
extern void of_console_init(void);
|
||||
|
||||
extern unsigned int prom_early_allocated;
|
||||
|
@ -20,14 +20,13 @@
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_pdt.h>
|
||||
#include <asm/prom.h>
|
||||
#include <asm/oplib.h>
|
||||
#include <asm/leon.h>
|
||||
|
||||
#include "prom.h"
|
||||
|
||||
void (*prom_build_more)(struct device_node *dp, struct device_node ***nextp);
|
||||
|
||||
struct device_node *of_console_device;
|
||||
EXPORT_SYMBOL(of_console_device);
|
||||
|
||||
@ -119,192 +118,47 @@ int of_find_in_proplist(const char *list, const char *match, int len)
|
||||
}
|
||||
EXPORT_SYMBOL(of_find_in_proplist);
|
||||
|
||||
unsigned int prom_unique_id;
|
||||
|
||||
static struct property * __init build_one_prop(phandle node, char *prev,
|
||||
char *special_name,
|
||||
void *special_val,
|
||||
int special_len)
|
||||
/*
|
||||
* SPARC32 and SPARC64's prom_nextprop() do things differently
|
||||
* here, despite sharing the same interface. SPARC32 doesn't fill in 'buf',
|
||||
* returning NULL on an error. SPARC64 fills in 'buf', but sets it to an
|
||||
* empty string upon error.
|
||||
*/
|
||||
static int __init handle_nextprop_quirks(char *buf, const char *name)
|
||||
{
|
||||
if (!name || strlen(name) == 0)
|
||||
return -1;
|
||||
|
||||
#ifdef CONFIG_SPARC32
|
||||
strcpy(buf, name);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
|
||||
{
|
||||
static struct property *tmp = NULL;
|
||||
struct property *p;
|
||||
const char *name;
|
||||
|
||||
if (tmp) {
|
||||
p = tmp;
|
||||
memset(p, 0, sizeof(*p) + 32);
|
||||
tmp = NULL;
|
||||
} else {
|
||||
p = prom_early_alloc(sizeof(struct property) + 32);
|
||||
p->unique_id = prom_unique_id++;
|
||||
}
|
||||
|
||||
p->name = (char *) (p + 1);
|
||||
if (special_name) {
|
||||
strcpy(p->name, special_name);
|
||||
p->length = special_len;
|
||||
p->value = prom_early_alloc(special_len);
|
||||
memcpy(p->value, special_val, special_len);
|
||||
} else {
|
||||
if (prev == NULL) {
|
||||
name = prom_firstprop(node, p->name);
|
||||
} else {
|
||||
name = prom_nextprop(node, prev, p->name);
|
||||
}
|
||||
|
||||
if (!name || strlen(name) == 0) {
|
||||
tmp = p;
|
||||
return NULL;
|
||||
}
|
||||
#ifdef CONFIG_SPARC32
|
||||
strcpy(p->name, name);
|
||||
#endif
|
||||
p->length = prom_getproplen(node, p->name);
|
||||
if (p->length <= 0) {
|
||||
p->length = 0;
|
||||
} else {
|
||||
int len;
|
||||
|
||||
p->value = prom_early_alloc(p->length + 1);
|
||||
len = prom_getproperty(node, p->name, p->value,
|
||||
p->length);
|
||||
if (len <= 0)
|
||||
p->length = 0;
|
||||
((unsigned char *)p->value)[p->length] = '\0';
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
static struct property * __init build_prop_list(phandle node)
|
||||
{
|
||||
struct property *head, *tail;
|
||||
|
||||
head = tail = build_one_prop(node, NULL,
|
||||
".node", &node, sizeof(node));
|
||||
|
||||
tail->next = build_one_prop(node, NULL, NULL, NULL, 0);
|
||||
tail = tail->next;
|
||||
while(tail) {
|
||||
tail->next = build_one_prop(node, tail->name,
|
||||
NULL, NULL, 0);
|
||||
tail = tail->next;
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
static char * __init get_one_property(phandle node, const char *name)
|
||||
{
|
||||
char *buf = "<NULL>";
|
||||
int len;
|
||||
|
||||
len = prom_getproplen(node, name);
|
||||
if (len > 0) {
|
||||
buf = prom_early_alloc(len);
|
||||
len = prom_getproperty(node, name, buf, len);
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static struct device_node * __init prom_create_node(phandle node,
|
||||
struct device_node *parent)
|
||||
{
|
||||
struct device_node *dp;
|
||||
|
||||
if (!node)
|
||||
return NULL;
|
||||
|
||||
dp = prom_early_alloc(sizeof(*dp));
|
||||
dp->unique_id = prom_unique_id++;
|
||||
dp->parent = parent;
|
||||
|
||||
kref_init(&dp->kref);
|
||||
|
||||
dp->name = get_one_property(node, "name");
|
||||
dp->type = get_one_property(node, "device_type");
|
||||
dp->phandle = node;
|
||||
|
||||
dp->properties = build_prop_list(node);
|
||||
|
||||
irq_trans_init(dp);
|
||||
|
||||
return dp;
|
||||
}
|
||||
|
||||
char * __init build_full_name(struct device_node *dp)
|
||||
{
|
||||
int len, ourlen, plen;
|
||||
char *n;
|
||||
|
||||
plen = strlen(dp->parent->full_name);
|
||||
ourlen = strlen(dp->path_component_name);
|
||||
len = ourlen + plen + 2;
|
||||
|
||||
n = prom_early_alloc(len);
|
||||
strcpy(n, dp->parent->full_name);
|
||||
if (!of_node_is_root(dp->parent)) {
|
||||
strcpy(n + plen, "/");
|
||||
plen++;
|
||||
}
|
||||
strcpy(n + plen, dp->path_component_name);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static struct device_node * __init prom_build_tree(struct device_node *parent,
|
||||
phandle node,
|
||||
struct device_node ***nextp)
|
||||
{
|
||||
struct device_node *ret = NULL, *prev_sibling = NULL;
|
||||
struct device_node *dp;
|
||||
|
||||
while (1) {
|
||||
dp = prom_create_node(node, parent);
|
||||
if (!dp)
|
||||
break;
|
||||
|
||||
if (prev_sibling)
|
||||
prev_sibling->sibling = dp;
|
||||
|
||||
if (!ret)
|
||||
ret = dp;
|
||||
prev_sibling = dp;
|
||||
|
||||
*(*nextp) = dp;
|
||||
*nextp = &dp->allnext;
|
||||
|
||||
dp->path_component_name = build_path_component(dp);
|
||||
dp->full_name = build_full_name(dp);
|
||||
|
||||
dp->child = prom_build_tree(dp, prom_getchild(node), nextp);
|
||||
|
||||
if (prom_build_more)
|
||||
prom_build_more(dp, nextp);
|
||||
|
||||
node = prom_getsibling(node);
|
||||
}
|
||||
|
||||
return ret;
|
||||
buf[0] = '\0';
|
||||
name = prom_nextprop(node, prev, buf);
|
||||
return handle_nextprop_quirks(buf, name);
|
||||
}
|
||||
|
||||
unsigned int prom_early_allocated __initdata;
|
||||
|
||||
static struct of_pdt_ops prom_sparc_ops __initdata = {
|
||||
.nextprop = prom_common_nextprop,
|
||||
.getproplen = prom_getproplen,
|
||||
.getproperty = prom_getproperty,
|
||||
.getchild = prom_getchild,
|
||||
.getsibling = prom_getsibling,
|
||||
};
|
||||
|
||||
void __init prom_build_devicetree(void)
|
||||
{
|
||||
struct device_node **nextp;
|
||||
|
||||
allnodes = prom_create_node(prom_root_node, NULL);
|
||||
allnodes->path_component_name = "";
|
||||
allnodes->full_name = "/";
|
||||
|
||||
nextp = &allnodes->allnext;
|
||||
allnodes->child = prom_build_tree(allnodes,
|
||||
prom_getchild(allnodes->phandle),
|
||||
&nextp);
|
||||
of_pdt_build_devicetree(prom_root_node, &prom_sparc_ops);
|
||||
of_console_init();
|
||||
|
||||
printk("PROM: Built device tree with %u bytes of memory.\n",
|
||||
prom_early_allocated);
|
||||
pr_info("PROM: Built device tree with %u bytes of memory.\n",
|
||||
prom_early_allocated);
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ void __init setup_arch(char **cmdline_p)
|
||||
|
||||
#ifdef CONFIG_IP_PNP
|
||||
if (!ic_set_manually) {
|
||||
int chosen = prom_finddevice ("/chosen");
|
||||
phandle chosen = prom_finddevice("/chosen");
|
||||
u32 cl, sv, gw;
|
||||
|
||||
cl = prom_getintdefault (chosen, "client-ip", 0);
|
||||
|
@ -23,7 +23,7 @@ int this_is_starfire = 0;
|
||||
|
||||
void check_if_starfire(void)
|
||||
{
|
||||
int ssnode = prom_finddevice("/ssp-serial");
|
||||
phandle ssnode = prom_finddevice("/ssp-serial");
|
||||
if (ssnode != 0 && ssnode != -1)
|
||||
this_is_starfire = 1;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ static void swift_clockstop(void)
|
||||
|
||||
void __init clock_stop_probe(void)
|
||||
{
|
||||
unsigned int node, clk_nd;
|
||||
phandle node, clk_nd;
|
||||
char name[20];
|
||||
|
||||
prom_getstring(prom_root_node, "name", name, sizeof(name));
|
||||
|
Reference in New Issue
Block a user