提交 3ad1f3b3 编写于 作者: L Linus Torvalds

Merge branch 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6

* 'next-devicetree' of git://git.secretlab.ca/git/linux-2.6:
  of: merge of_find_all_nodes() implementations
  of: merge other miscellaneous prototypes
  of: merge of_*_flat_dt*() functions
  of: merge of_node_get(), of_node_put() and of_find_all_nodes()
  of: merge of_read_number() an of_read_ulong()
  of: merge of_node_*_flag() and set_node_proc_entry()
  of: merge struct boot_param_header from Microblaze and PowerPC
  of: add common header for flattened device tree representation
  of: Move OF_IS_DYNAMIC and OF_MARK_DYNAMIC macros to of.h
  of: merge struct device_node
  of: merge phandle, ihandle and struct property
  of: Rework linux/of.h and asm/prom.h include ordering
...@@ -12,23 +12,15 @@ ...@@ -12,23 +12,15 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#include <linux/of.h> /* linux/of.h gets to determine #include ordering */
#ifndef _ASM_MICROBLAZE_PROM_H #ifndef _ASM_MICROBLAZE_PROM_H
#define _ASM_MICROBLAZE_PROM_H #define _ASM_MICROBLAZE_PROM_H
#ifdef __KERNEL__ #ifdef __KERNEL__
/* Definitions used by the flattened device tree */
#define OF_DT_HEADER 0xd00dfeed /* marker */
#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */
#define OF_DT_END_NODE 0x2 /* End node */
#define OF_DT_PROP 0x3 /* Property: name off, size, content */
#define OF_DT_NOP 0x4 /* nop */
#define OF_DT_END 0x9
#define OF_DT_VERSION 0x10
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <linux/types.h> #include <linux/types.h>
#include <linux/of_fdt.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -41,122 +33,19 @@ ...@@ -41,122 +33,19 @@
#define of_prop_cmp(s1, s2) strcmp((s1), (s2)) #define of_prop_cmp(s1, s2) strcmp((s1), (s2))
#define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) #define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
/*
* This is what gets passed to the kernel by prom_init or kexec
*
* The dt struct contains the device tree structure, full pathes and
* property contents. The dt strings contain a separate block with just
* the strings for the property names, and is fully page aligned and
* self contained in a page, so that it can be kept around by the kernel,
* each property name appears only once in this page (cheap compression)
*
* the mem_rsvmap contains a map of reserved ranges of physical memory,
* passing it here instead of in the device-tree itself greatly simplifies
* the job of everybody. It's just a list of u64 pairs (base/size) that
* ends when size is 0
*/
struct boot_param_header {
u32 magic; /* magic word OF_DT_HEADER */
u32 totalsize; /* total size of DT block */
u32 off_dt_struct; /* offset to structure */
u32 off_dt_strings; /* offset to strings */
u32 off_mem_rsvmap; /* offset to memory reserve map */
u32 version; /* format version */
u32 last_comp_version; /* last compatible version */
/* version 2 fields below */
u32 boot_cpuid_phys; /* Physical CPU id we're booting on */
/* version 3 fields below */
u32 dt_strings_size; /* size of the DT strings block */
/* version 17 fields below */
u32 dt_struct_size; /* size of the DT structure block */
};
typedef u32 phandle;
typedef u32 ihandle;
struct property {
char *name;
int length;
void *value;
struct property *next;
};
struct device_node {
const char *name;
const char *type;
phandle node;
phandle linux_phandle;
char *full_name;
struct property *properties;
struct property *deadprops; /* removed properties */
struct device_node *parent;
struct device_node *child;
struct device_node *sibling;
struct device_node *next; /* next device of same type */
struct device_node *allnext; /* next in list of all nodes */
struct proc_dir_entry *pde; /* this node's proc directory */
struct kref kref;
unsigned long _flags;
void *data;
};
extern struct device_node *of_chosen; extern struct device_node *of_chosen;
static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
{
return test_bit(flag, &n->_flags);
}
static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
{
set_bit(flag, &n->_flags);
}
#define HAVE_ARCH_DEVTREE_FIXUPS #define HAVE_ARCH_DEVTREE_FIXUPS
static inline void set_node_proc_entry(struct device_node *dn,
struct proc_dir_entry *de)
{
dn->pde = de;
}
extern struct device_node *allnodes; /* temporary while merging */ extern struct device_node *allnodes; /* temporary while merging */
extern rwlock_t devtree_lock; /* temporary while merging */ extern rwlock_t devtree_lock; /* temporary while merging */
extern struct device_node *of_find_all_nodes(struct device_node *prev);
extern struct device_node *of_node_get(struct device_node *node);
extern void of_node_put(struct device_node *node);
/* For scanning the flat device-tree at boot time */
extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
const char *uname, int depth,
void *data),
void *data);
extern void *__init of_get_flat_dt_prop(unsigned long node, const char *name,
unsigned long *size);
extern int __init
of_flat_dt_is_compatible(unsigned long node, const char *name);
extern unsigned long __init of_get_flat_dt_root(void);
/* For updating the device tree at runtime */ /* For updating the device tree at runtime */
extern void of_attach_node(struct device_node *); extern void of_attach_node(struct device_node *);
extern void of_detach_node(struct device_node *); extern void of_detach_node(struct device_node *);
/* Other Prototypes */ /* Other Prototypes */
extern void finish_device_tree(void);
extern void unflatten_device_tree(void);
extern int early_uartlite_console(void); extern int early_uartlite_console(void);
extern void early_init_devtree(void *);
extern int machine_is_compatible(const char *compat);
extern void print_properties(struct device_node *node);
extern int prom_n_intr_cells(struct device_node *np);
extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
extern int prom_add_property(struct device_node *np, struct property *prop);
extern int prom_remove_property(struct device_node *np, struct property *prop);
extern int prom_update_property(struct device_node *np,
struct property *newprop,
struct property *oldprop);
extern struct resource *request_OF_resource(struct device_node *node, extern struct resource *request_OF_resource(struct device_node *node,
int index, const char *name_postfix); int index, const char *name_postfix);
...@@ -166,18 +55,6 @@ extern int release_OF_resource(struct device_node *node, int index); ...@@ -166,18 +55,6 @@ extern int release_OF_resource(struct device_node *node, int index);
* OF address retreival & translation * OF address retreival & translation
*/ */
/* Helper to read a big number; size is in cells (not bytes) */
static inline u64 of_read_number(const u32 *cell, int size)
{
u64 r = 0;
while (size--)
r = (r << 32) | *(cell++);
return r;
}
/* Like of_read_number, but we want an unsigned long result */
#define of_read_ulong(cell, size) of_read_number(cell, size)
/* Translate an OF address block into a CPU physical address /* Translate an OF address block into a CPU physical address
*/ */
extern u64 of_translate_address(struct device_node *np, const u32 *addr); extern u64 of_translate_address(struct device_node *np, const u32 *addr);
...@@ -305,12 +182,6 @@ extern int of_irq_to_resource(struct device_node *dev, int index, ...@@ -305,12 +182,6 @@ extern int of_irq_to_resource(struct device_node *dev, int index,
*/ */
extern void __iomem *of_iomap(struct device_node *device, int index); extern void __iomem *of_iomap(struct device_node *device, int index);
/*
* NB: This is here while we transition from using asm/prom.h
* to linux/of.h
*/
#include <linux/of.h>
#endif /* __ASSEMBLY__ */ #endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _ASM_MICROBLAZE_PROM_H */ #endif /* _ASM_MICROBLAZE_PROM_H */
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/prom.h> /* for OF_DT_HEADER */ #include <linux/of_fdt.h> /* for OF_DT_HEADER */
#ifdef CONFIG_MMU #ifdef CONFIG_MMU
#include <asm/setup.h> /* COMMAND_LINE_SIZE */ #include <asm/setup.h> /* COMMAND_LINE_SIZE */
......
...@@ -859,29 +859,6 @@ struct device_node *of_find_node_by_phandle(phandle handle) ...@@ -859,29 +859,6 @@ struct device_node *of_find_node_by_phandle(phandle handle)
} }
EXPORT_SYMBOL(of_find_node_by_phandle); EXPORT_SYMBOL(of_find_node_by_phandle);
/**
* of_find_all_nodes - Get next node in global list
* @prev: Previous node or NULL to start iteration
* of_node_put() will be called on it
*
* Returns a node pointer with refcount incremented, use
* of_node_put() on it when done.
*/
struct device_node *of_find_all_nodes(struct device_node *prev)
{
struct device_node *np;
read_lock(&devtree_lock);
np = prev ? prev->allnext : allnodes;
for (; np != NULL; np = np->allnext)
if (of_node_get(np))
break;
of_node_put(prev);
read_unlock(&devtree_lock);
return np;
}
EXPORT_SYMBOL(of_find_all_nodes);
/** /**
* of_node_get - Increment refcount of a node * of_node_get - Increment refcount of a node
* @node: Node to inc refcount, NULL is supported to * @node: Node to inc refcount, NULL is supported to
......
#include <linux/of.h> /* linux/of.h gets to determine #include ordering */
#ifndef _POWERPC_PROM_H #ifndef _POWERPC_PROM_H
#define _POWERPC_PROM_H #define _POWERPC_PROM_H
#ifdef __KERNEL__ #ifdef __KERNEL__
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#include <linux/types.h> #include <linux/types.h>
#include <linux/of_fdt.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <asm/irq.h> #include <asm/irq.h>
...@@ -28,133 +30,14 @@ ...@@ -28,133 +30,14 @@
#define of_prop_cmp(s1, s2) strcmp((s1), (s2)) #define of_prop_cmp(s1, s2) strcmp((s1), (s2))
#define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) #define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
/* Definitions used by the flattened device tree */
#define OF_DT_HEADER 0xd00dfeed /* marker */
#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */
#define OF_DT_END_NODE 0x2 /* End node */
#define OF_DT_PROP 0x3 /* Property: name off, size,
* content */
#define OF_DT_NOP 0x4 /* nop */
#define OF_DT_END 0x9
#define OF_DT_VERSION 0x10
/*
* This is what gets passed to the kernel by prom_init or kexec
*
* The dt struct contains the device tree structure, full pathes and
* property contents. The dt strings contain a separate block with just
* the strings for the property names, and is fully page aligned and
* self contained in a page, so that it can be kept around by the kernel,
* each property name appears only once in this page (cheap compression)
*
* the mem_rsvmap contains a map of reserved ranges of physical memory,
* passing it here instead of in the device-tree itself greatly simplifies
* the job of everybody. It's just a list of u64 pairs (base/size) that
* ends when size is 0
*/
struct boot_param_header
{
u32 magic; /* magic word OF_DT_HEADER */
u32 totalsize; /* total size of DT block */
u32 off_dt_struct; /* offset to structure */
u32 off_dt_strings; /* offset to strings */
u32 off_mem_rsvmap; /* offset to memory reserve map */
u32 version; /* format version */
u32 last_comp_version; /* last compatible version */
/* version 2 fields below */
u32 boot_cpuid_phys; /* Physical CPU id we're booting on */
/* version 3 fields below */
u32 dt_strings_size; /* size of the DT strings block */
/* version 17 fields below */
u32 dt_struct_size; /* size of the DT structure block */
};
typedef u32 phandle;
typedef u32 ihandle;
struct property {
char *name;
int length;
void *value;
struct property *next;
};
struct device_node {
const char *name;
const char *type;
phandle node;
phandle linux_phandle;
char *full_name;
struct property *properties;
struct property *deadprops; /* removed properties */
struct device_node *parent;
struct device_node *child;
struct device_node *sibling;
struct device_node *next; /* next device of same type */
struct device_node *allnext; /* next in list of all nodes */
struct proc_dir_entry *pde; /* this node's proc directory */
struct kref kref;
unsigned long _flags;
void *data;
};
extern struct device_node *of_chosen; extern struct device_node *of_chosen;
static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
{
return test_bit(flag, &n->_flags);
}
static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
{
set_bit(flag, &n->_flags);
}
#define HAVE_ARCH_DEVTREE_FIXUPS #define HAVE_ARCH_DEVTREE_FIXUPS
static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
{
dn->pde = de;
}
extern struct device_node *of_find_all_nodes(struct device_node *prev);
extern struct device_node *of_node_get(struct device_node *node);
extern void of_node_put(struct device_node *node);
/* For scanning the flat device-tree at boot time */
extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
const char *uname, int depth,
void *data),
void *data);
extern void* __init of_get_flat_dt_prop(unsigned long node, const char *name,
unsigned long *size);
extern int __init of_flat_dt_is_compatible(unsigned long node, const char *name);
extern unsigned long __init of_get_flat_dt_root(void);
/* For updating the device tree at runtime */ /* For updating the device tree at runtime */
extern void of_attach_node(struct device_node *); extern void of_attach_node(struct device_node *);
extern void of_detach_node(struct device_node *); extern void of_detach_node(struct device_node *);
/* Other Prototypes */
extern void finish_device_tree(void);
extern void unflatten_device_tree(void);
extern void early_init_devtree(void *);
extern int machine_is_compatible(const char *compat);
extern void print_properties(struct device_node *node);
extern int prom_n_intr_cells(struct device_node* np);
extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
extern int prom_add_property(struct device_node* np, struct property* prop);
extern int prom_remove_property(struct device_node *np, struct property *prop);
extern int prom_update_property(struct device_node *np,
struct property *newprop,
struct property *oldprop);
#ifdef CONFIG_PPC32 #ifdef CONFIG_PPC32
/* /*
* PCI <-> OF matching functions * PCI <-> OF matching functions
...@@ -178,26 +61,6 @@ extern int release_OF_resource(struct device_node* node, int index); ...@@ -178,26 +61,6 @@ extern int release_OF_resource(struct device_node* node, int index);
* OF address retreival & translation * OF address retreival & translation
*/ */
/* Helper to read a big number; size is in cells (not bytes) */
static inline u64 of_read_number(const u32 *cell, int size)
{
u64 r = 0;
while (size--)
r = (r << 32) | *(cell++);
return r;
}
/* Like of_read_number, but we want an unsigned long result */
#ifdef CONFIG_PPC32
static inline unsigned long of_read_ulong(const u32 *cell, int size)
{
return cell[size-1];
}
#else
#define of_read_ulong(cell, size) of_read_number(cell, size)
#endif
/* Translate an OF address block into a CPU physical address /* Translate an OF address block into a CPU physical address
*/ */
extern u64 of_translate_address(struct device_node *np, const u32 *addr); extern u64 of_translate_address(struct device_node *np, const u32 *addr);
...@@ -349,11 +212,5 @@ extern int of_irq_to_resource(struct device_node *dev, int index, ...@@ -349,11 +212,5 @@ extern int of_irq_to_resource(struct device_node *dev, int index,
*/ */
extern void __iomem *of_iomap(struct device_node *device, int index); extern void __iomem *of_iomap(struct device_node *device, int index);
/*
* NB: This is here while we transition from using asm/prom.h
* to linux/of.h
*/
#include <linux/of.h>
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _POWERPC_PROM_H */ #endif /* _POWERPC_PROM_H */
...@@ -1316,29 +1316,6 @@ struct device_node *of_find_next_cache_node(struct device_node *np) ...@@ -1316,29 +1316,6 @@ struct device_node *of_find_next_cache_node(struct device_node *np)
return NULL; return NULL;
} }
/**
* of_find_all_nodes - Get next node in global list
* @prev: Previous node or NULL to start iteration
* of_node_put() will be called on it
*
* Returns a node pointer with refcount incremented, use
* of_node_put() on it when done.
*/
struct device_node *of_find_all_nodes(struct device_node *prev)
{
struct device_node *np;
read_lock(&devtree_lock);
np = prev ? prev->allnext : allnodes;
for (; np != 0; np = np->allnext)
if (of_node_get(np))
break;
of_node_put(prev);
read_unlock(&devtree_lock);
return np;
}
EXPORT_SYMBOL(of_find_all_nodes);
/** /**
* of_node_get - Increment refcount of a node * of_node_get - Increment refcount of a node
* @node: Node to inc refcount, NULL is supported to * @node: Node to inc refcount, NULL is supported to
......
#include <linux/of.h> /* linux/of.h gets to determine #include ordering */
#ifndef _SPARC_PROM_H #ifndef _SPARC_PROM_H
#define _SPARC_PROM_H #define _SPARC_PROM_H
#ifdef __KERNEL__ #ifdef __KERNEL__
...@@ -28,50 +29,11 @@ ...@@ -28,50 +29,11 @@
#define of_prop_cmp(s1, s2) strcasecmp((s1), (s2)) #define of_prop_cmp(s1, s2) strcasecmp((s1), (s2))
#define of_node_cmp(s1, s2) strcmp((s1), (s2)) #define of_node_cmp(s1, s2) strcmp((s1), (s2))
typedef u32 phandle;
typedef u32 ihandle;
struct property {
char *name;
int length;
void *value;
struct property *next;
unsigned long _flags;
unsigned int unique_id;
};
struct of_irq_controller;
struct device_node {
const char *name;
const char *type;
phandle node;
char *path_component_name;
char *full_name;
struct property *properties;
struct property *deadprops; /* removed properties */
struct device_node *parent;
struct device_node *child;
struct device_node *sibling;
struct device_node *next; /* next device of same type */
struct device_node *allnext; /* next in list of all nodes */
struct proc_dir_entry *pde; /* this node's proc directory */
struct kref kref;
unsigned long _flags;
void *data;
unsigned int unique_id;
struct of_irq_controller *irq_trans;
};
struct of_irq_controller { struct of_irq_controller {
unsigned int (*irq_build)(struct device_node *, unsigned int, void *); unsigned int (*irq_build)(struct device_node *, unsigned int, void *);
void *data; void *data;
}; };
#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
extern struct device_node *of_find_node_by_cpuid(int cpuid); extern struct device_node *of_find_node_by_cpuid(int cpuid);
extern int of_set_property(struct device_node *node, const char *name, void *val, int len); extern int of_set_property(struct device_node *node, const char *name, void *val, int len);
extern struct mutex of_set_property_mutex; extern struct mutex of_set_property_mutex;
...@@ -89,15 +51,6 @@ extern void prom_build_devicetree(void); ...@@ -89,15 +51,6 @@ extern void prom_build_devicetree(void);
extern void of_populate_present_mask(void); extern void of_populate_present_mask(void);
extern void of_fill_in_cpu_data(void); extern void of_fill_in_cpu_data(void);
/* Dummy ref counting routines - to be implemented later */
static inline struct device_node *of_node_get(struct device_node *node)
{
return node;
}
static inline void of_node_put(struct device_node *node)
{
}
/* These routines are here to provide compatibility with how powerpc /* These routines are here to provide compatibility with how powerpc
* handles IRQ mapping for OF device nodes. We precompute and permanently * handles IRQ mapping for OF device nodes. We precompute and permanently
* register them in the of_device objects, whereas powerpc computes them * register them in the of_device objects, whereas powerpc computes them
...@@ -108,12 +61,6 @@ static inline void irq_dispose_mapping(unsigned int virq) ...@@ -108,12 +61,6 @@ static inline void irq_dispose_mapping(unsigned int virq)
{ {
} }
/*
* NB: This is here while we transition from using asm/prom.h
* to linux/of.h
*/
#include <linux/of.h>
extern struct device_node *of_console_device; extern struct device_node *of_console_device;
extern char *of_console_path; extern char *of_console_path;
extern char *of_console_options; extern char *of_console_options;
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
* *
* Adapted for sparc and sparc64 by David S. Miller davem@davemloft.net * Adapted for sparc and sparc64 by David S. Miller davem@davemloft.net
* *
* Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell. * Reconsolidated from arch/x/kernel/prom.c by Stephen Rothwell and
* Grant Likely.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
...@@ -82,6 +83,29 @@ struct property *of_find_property(const struct device_node *np, ...@@ -82,6 +83,29 @@ struct property *of_find_property(const struct device_node *np,
} }
EXPORT_SYMBOL(of_find_property); EXPORT_SYMBOL(of_find_property);
/**
* of_find_all_nodes - Get next node in global list
* @prev: Previous node or NULL to start iteration
* of_node_put() will be called on it
*
* Returns a node pointer with refcount incremented, use
* of_node_put() on it when done.
*/
struct device_node *of_find_all_nodes(struct device_node *prev)
{
struct device_node *np;
read_lock(&devtree_lock);
np = prev ? prev->allnext : allnodes;
for (; np != NULL; np = np->allnext)
if (of_node_get(np))
break;
of_node_put(prev);
read_unlock(&devtree_lock);
return np;
}
EXPORT_SYMBOL(of_find_all_nodes);
/* /*
* Find a property with a given name for a given node * Find a property with a given name for a given node
* and return the value. * and return the value.
......
...@@ -17,14 +17,117 @@ ...@@ -17,14 +17,117 @@
*/ */
#include <linux/types.h> #include <linux/types.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/kref.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
typedef u32 phandle;
typedef u32 ihandle;
struct property {
char *name;
int length;
void *value;
struct property *next;
unsigned long _flags;
unsigned int unique_id;
};
#if defined(CONFIG_SPARC)
struct of_irq_controller;
#endif
struct device_node {
const char *name;
const char *type;
phandle node;
#if !defined(CONFIG_SPARC)
phandle linux_phandle;
#endif
char *full_name;
struct property *properties;
struct property *deadprops; /* removed properties */
struct device_node *parent;
struct device_node *child;
struct device_node *sibling;
struct device_node *next; /* next device of same type */
struct device_node *allnext; /* next in list of all nodes */
struct proc_dir_entry *pde; /* this node's proc directory */
struct kref kref;
unsigned long _flags;
void *data;
#if defined(CONFIG_SPARC)
char *path_component_name;
unsigned int unique_id;
struct of_irq_controller *irq_trans;
#endif
};
static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
{
return test_bit(flag, &n->_flags);
}
static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
{
set_bit(flag, &n->_flags);
}
static inline void
set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
{
dn->pde = de;
}
extern struct device_node *of_find_all_nodes(struct device_node *prev);
#if defined(CONFIG_SPARC)
/* Dummy ref counting routines - to be implemented later */
static inline struct device_node *of_node_get(struct device_node *node)
{
return node;
}
static inline void of_node_put(struct device_node *node)
{
}
#else
extern struct device_node *of_node_get(struct device_node *node);
extern void of_node_put(struct device_node *node);
#endif
/*
* OF address retreival & translation
*/
/* Helper to read a big number; size is in cells (not bytes) */
static inline u64 of_read_number(const u32 *cell, int size)
{
u64 r = 0;
while (size--)
r = (r << 32) | *(cell++);
return r;
}
/* Like of_read_number, but we want an unsigned long result */
#ifdef CONFIG_PPC32
static inline unsigned long of_read_ulong(const u32 *cell, int size)
{
return cell[size-1];
}
#else
#define of_read_ulong(cell, size) of_read_number(cell, size)
#endif
#include <asm/prom.h> #include <asm/prom.h>
/* flag descriptions */ /* flag descriptions */
#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */ #define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
#define OF_DETACHED 2 /* node has been detached from the device tree */ #define OF_DETACHED 2 /* node has been detached from the device tree */
#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
#define OF_BAD_ADDR ((u64)-1) #define OF_BAD_ADDR ((u64)-1)
extern struct device_node *of_find_node_by_name(struct device_node *from, extern struct device_node *of_find_node_by_name(struct device_node *from,
......
/*
* Definitions for working with the Flattened Device Tree data format
*
* Copyright 2009 Benjamin Herrenschmidt, IBM Corp
* benh@kernel.crashing.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*/
#ifndef _LINUX_OF_FDT_H
#define _LINUX_OF_FDT_H
#include <linux/types.h>
#include <linux/init.h>
/* Definitions used by the flattened device tree */
#define OF_DT_HEADER 0xd00dfeed /* marker */
#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */
#define OF_DT_END_NODE 0x2 /* End node */
#define OF_DT_PROP 0x3 /* Property: name off, size,
* content */
#define OF_DT_NOP 0x4 /* nop */
#define OF_DT_END 0x9
#define OF_DT_VERSION 0x10
#ifndef __ASSEMBLY__
/*
* This is what gets passed to the kernel by prom_init or kexec
*
* The dt struct contains the device tree structure, full pathes and
* property contents. The dt strings contain a separate block with just
* the strings for the property names, and is fully page aligned and
* self contained in a page, so that it can be kept around by the kernel,
* each property name appears only once in this page (cheap compression)
*
* the mem_rsvmap contains a map of reserved ranges of physical memory,
* passing it here instead of in the device-tree itself greatly simplifies
* the job of everybody. It's just a list of u64 pairs (base/size) that
* ends when size is 0
*/
struct boot_param_header {
u32 magic; /* magic word OF_DT_HEADER */
u32 totalsize; /* total size of DT block */
u32 off_dt_struct; /* offset to structure */
u32 off_dt_strings; /* offset to strings */
u32 off_mem_rsvmap; /* offset to memory reserve map */
u32 version; /* format version */
u32 last_comp_version; /* last compatible version */
/* version 2 fields below */
u32 boot_cpuid_phys; /* Physical CPU id we're booting on */
/* version 3 fields below */
u32 dt_strings_size; /* size of the DT strings block */
/* version 17 fields below */
u32 dt_struct_size; /* size of the DT structure block */
};
/* For scanning the flat device-tree at boot time */
extern int __init of_scan_flat_dt(int (*it)(unsigned long node,
const char *uname, int depth,
void *data),
void *data);
extern void __init *of_get_flat_dt_prop(unsigned long node, const char *name,
unsigned long *size);
extern int __init of_flat_dt_is_compatible(unsigned long node,
const char *name);
extern unsigned long __init of_get_flat_dt_root(void);
/* Other Prototypes */
extern void finish_device_tree(void);
extern void unflatten_device_tree(void);
extern void early_init_devtree(void *);
extern int machine_is_compatible(const char *compat);
extern void print_properties(struct device_node *node);
extern int prom_n_intr_cells(struct device_node* np);
extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
extern int prom_add_property(struct device_node* np, struct property* prop);
extern int prom_remove_property(struct device_node *np, struct property *prop);
extern int prom_update_property(struct device_node *np,
struct property *newprop,
struct property *oldprop);
#endif /* __ASSEMBLY__ */
#endif /* _LINUX_OF_FDT_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册