Commit 6ebdc661 authored by Linus Torvalds's avatar 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: (41 commits)
  of: remove undefined request_OF_resource & release_OF_resource
  of/sparc: Remove sparc-local declaration of allnodes and devtree_lock
  of: move definition of of_chosen into common code.
  of: remove unused extern reference to devtree_lock
  of: put default string compare and #a/s-cell values into common header
  of/flattree: Don't assume HAVE_LMB
  of: protect linux/of.h with CONFIG_OF
  proc_devtree: fix THIS_MODULE without module.h
  of: Remove old and misplaced function declarations
  of/flattree: Make the kernel accept ePAPR style phandle information
  of/flattree: endian-convert members of boot_param_header
  of: assume big-endian properties, adding conversions where necessary
  of: use __be32 for cell value accessors
  of/flattree: use OF_ROOT_NODE_{SIZE,ADDR}_CELLS DEFAULT for fdt parsing
  of/flattree: use callback to setup initrd from /chosen
  proc_devtree: include linux/of.h
  of: make set_node_proc_entry private to proc_devtree.c
  of: include linux/proc_fs.h
  of/flattree: merge early_init_dt_scan_memory() common code
  of: add 'of_' prefix to machine_is_compatible()
  ...
parents d7930c9e df0edeb5
...@@ -130,6 +130,7 @@ config CMDLINE_FORCE ...@@ -130,6 +130,7 @@ config CMDLINE_FORCE
config OF config OF
def_bool y def_bool y
select OF_FLATTREE
config PROC_DEVICETREE config PROC_DEVICETREE
bool "Support for device tree in /proc" bool "Support for device tree in /proc"
......
...@@ -26,31 +26,11 @@ ...@@ -26,31 +26,11 @@
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/atomic.h> #include <asm/atomic.h>
#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
#define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l))
#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
extern struct device_node *of_chosen;
#define HAVE_ARCH_DEVTREE_FIXUPS #define HAVE_ARCH_DEVTREE_FIXUPS
extern struct device_node *allnodes; /* temporary while merging */
extern rwlock_t devtree_lock; /* temporary while merging */
/* For updating the device tree at runtime */
extern void of_attach_node(struct device_node *);
extern void of_detach_node(struct device_node *);
/* Other Prototypes */ /* Other Prototypes */
extern int early_uartlite_console(void); extern int early_uartlite_console(void);
extern struct resource *request_OF_resource(struct device_node *node,
int index, const char *name_postfix);
extern int release_OF_resource(struct device_node *node, int index);
/* /*
* OF address retreival & translation * OF address retreival & translation
*/ */
......
...@@ -185,7 +185,7 @@ EXPORT_SYMBOL(of_find_device_by_node); ...@@ -185,7 +185,7 @@ EXPORT_SYMBOL(of_find_device_by_node);
static int of_dev_phandle_match(struct device *dev, void *data) static int of_dev_phandle_match(struct device *dev, void *data)
{ {
phandle *ph = data; phandle *ph = data;
return to_of_device(dev)->node->linux_phandle == *ph; return to_of_device(dev)->node->phandle == *ph;
} }
struct of_device *of_find_device_by_phandle(phandle ph) struct of_device *of_find_device_by_phandle(phandle ph)
......
This diff is collapsed.
...@@ -173,6 +173,7 @@ config PPC_OF ...@@ -173,6 +173,7 @@ config PPC_OF
config OF config OF
def_bool y def_bool y
select OF_FLATTREE
config PPC_UDBG_16550 config PPC_UDBG_16550
bool bool
......
...@@ -23,21 +23,8 @@ ...@@ -23,21 +23,8 @@
#include <asm/irq.h> #include <asm/irq.h>
#include <asm/atomic.h> #include <asm/atomic.h>
#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
#define of_compat_cmp(s1, s2, l) strcasecmp((s1), (s2))
#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
extern struct device_node *of_chosen;
#define HAVE_ARCH_DEVTREE_FIXUPS #define HAVE_ARCH_DEVTREE_FIXUPS
/* For updating the device tree at runtime */
extern void of_attach_node(struct device_node *);
extern void of_detach_node(struct device_node *);
#ifdef CONFIG_PPC32 #ifdef CONFIG_PPC32
/* /*
* PCI <-> OF matching functions * PCI <-> OF matching functions
...@@ -52,11 +39,6 @@ extern struct device_node* pci_device_to_OF_node(struct pci_dev *); ...@@ -52,11 +39,6 @@ extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
extern void pci_create_OF_bus_map(void); extern void pci_create_OF_bus_map(void);
#endif #endif
extern struct resource *request_OF_resource(struct device_node* node,
int index, const char* name_postfix);
extern int release_OF_resource(struct device_node* node, int index);
/* /*
* OF address retreival & translation * OF address retreival & translation
*/ */
......
...@@ -214,7 +214,7 @@ EXPORT_SYMBOL(of_find_device_by_node); ...@@ -214,7 +214,7 @@ EXPORT_SYMBOL(of_find_device_by_node);
static int of_dev_phandle_match(struct device *dev, void *data) static int of_dev_phandle_match(struct device *dev, void *data)
{ {
phandle *ph = data; phandle *ph = data;
return to_of_device(dev)->node->linux_phandle == *ph; return to_of_device(dev)->node->phandle == *ph;
} }
struct of_device *of_find_device_by_phandle(phandle ph) struct of_device *of_find_device_by_phandle(phandle ph)
......
...@@ -224,7 +224,7 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus, ...@@ -224,7 +224,7 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
* G5 machines... So when something asks for bus 0 io base * G5 machines... So when something asks for bus 0 io base
* (bus 0 is HT root), we return the AGP one instead. * (bus 0 is HT root), we return the AGP one instead.
*/ */
if (in_bus == 0 && machine_is_compatible("MacRISC4")) { if (in_bus == 0 && of_machine_is_compatible("MacRISC4")) {
struct device_node *agp; struct device_node *agp;
agp = of_find_compatible_node(NULL, NULL, "u3-agp"); agp = of_find_compatible_node(NULL, NULL, "u3-agp");
......
This diff is collapsed.
...@@ -80,8 +80,8 @@ static void xes_mpc85xx_configure_l2(void __iomem *l2_base) ...@@ -80,8 +80,8 @@ static void xes_mpc85xx_configure_l2(void __iomem *l2_base)
printk(KERN_INFO "xes_mpc85xx: Enabling L2 as cache\n"); printk(KERN_INFO "xes_mpc85xx: Enabling L2 as cache\n");
ctl = MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2I; ctl = MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2I;
if (machine_is_compatible("MPC8540") || if (of_machine_is_compatible("MPC8540") ||
machine_is_compatible("MPC8560")) of_machine_is_compatible("MPC8560"))
/* /*
* Assume L2 SRAM is used fully for cache, so set * Assume L2 SRAM is used fully for cache, so set
* L2BLKSZ (bits 4:5) to match L2SIZ (bits 2:3). * L2BLKSZ (bits 4:5) to match L2SIZ (bits 2:3).
......
...@@ -48,7 +48,7 @@ static int __init cbe_powerbutton_init(void) ...@@ -48,7 +48,7 @@ static int __init cbe_powerbutton_init(void)
int ret = 0; int ret = 0;
struct input_dev *dev; struct input_dev *dev;
if (!machine_is_compatible("IBM,CBPLUS-1.0")) { if (!of_machine_is_compatible("IBM,CBPLUS-1.0")) {
printk(KERN_ERR "%s: Not a cell blade.\n", __func__); printk(KERN_ERR "%s: Not a cell blade.\n", __func__);
ret = -ENODEV; ret = -ENODEV;
goto out; goto out;
......
...@@ -255,7 +255,7 @@ static int __init cbe_sysreset_init(void) ...@@ -255,7 +255,7 @@ static int __init cbe_sysreset_init(void)
{ {
struct cbe_pmd_regs __iomem *regs; struct cbe_pmd_regs __iomem *regs;
sysreset_hack = machine_is_compatible("IBM,CBPLUS-1.0"); sysreset_hack = of_machine_is_compatible("IBM,CBPLUS-1.0");
if (!sysreset_hack) if (!sysreset_hack)
return 0; return 0;
......
...@@ -457,7 +457,7 @@ neighbour_spu(int cbe, struct device_node *target, struct device_node *avoid) ...@@ -457,7 +457,7 @@ neighbour_spu(int cbe, struct device_node *target, struct device_node *avoid)
continue; continue;
vic_handles = of_get_property(spu_dn, "vicinity", &lenp); vic_handles = of_get_property(spu_dn, "vicinity", &lenp);
for (i=0; i < (lenp / sizeof(phandle)); i++) { for (i=0; i < (lenp / sizeof(phandle)); i++) {
if (vic_handles[i] == target->linux_phandle) if (vic_handles[i] == target->phandle)
return spu; return spu;
} }
} }
...@@ -499,7 +499,7 @@ static void init_affinity_node(int cbe) ...@@ -499,7 +499,7 @@ static void init_affinity_node(int cbe)
if (strcmp(name, "spe") == 0) { if (strcmp(name, "spe") == 0) {
spu = devnode_spu(cbe, vic_dn); spu = devnode_spu(cbe, vic_dn);
avoid_ph = last_spu_dn->linux_phandle; avoid_ph = last_spu_dn->phandle;
} else { } else {
/* /*
* "mic-tm" and "bif0" nodes do not have * "mic-tm" and "bif0" nodes do not have
...@@ -514,7 +514,7 @@ static void init_affinity_node(int cbe) ...@@ -514,7 +514,7 @@ static void init_affinity_node(int cbe)
last_spu->has_mem_affinity = 1; last_spu->has_mem_affinity = 1;
spu->has_mem_affinity = 1; spu->has_mem_affinity = 1;
} }
avoid_ph = vic_dn->linux_phandle; avoid_ph = vic_dn->phandle;
} }
list_add_tail(&spu->aff_list, &last_spu->aff_list); list_add_tail(&spu->aff_list, &last_spu->aff_list);
......
...@@ -304,8 +304,8 @@ static struct cpufreq_driver pas_cpufreq_driver = { ...@@ -304,8 +304,8 @@ static struct cpufreq_driver pas_cpufreq_driver = {
static int __init pas_cpufreq_init(void) static int __init pas_cpufreq_init(void)
{ {
if (!machine_is_compatible("PA6T-1682M") && if (!of_machine_is_compatible("PA6T-1682M") &&
!machine_is_compatible("pasemi,pwrficient")) !of_machine_is_compatible("pasemi,pwrficient"))
return -ENODEV; return -ENODEV;
return cpufreq_register_driver(&pas_cpufreq_driver); return cpufreq_register_driver(&pas_cpufreq_driver);
......
...@@ -657,31 +657,31 @@ static int __init pmac_cpufreq_setup(void) ...@@ -657,31 +657,31 @@ static int __init pmac_cpufreq_setup(void)
cur_freq = (*value) / 1000; cur_freq = (*value) / 1000;
/* Check for 7447A based MacRISC3 */ /* Check for 7447A based MacRISC3 */
if (machine_is_compatible("MacRISC3") && if (of_machine_is_compatible("MacRISC3") &&
of_get_property(cpunode, "dynamic-power-step", NULL) && of_get_property(cpunode, "dynamic-power-step", NULL) &&
PVR_VER(mfspr(SPRN_PVR)) == 0x8003) { PVR_VER(mfspr(SPRN_PVR)) == 0x8003) {
pmac_cpufreq_init_7447A(cpunode); pmac_cpufreq_init_7447A(cpunode);
/* Check for other MacRISC3 machines */ /* Check for other MacRISC3 machines */
} else if (machine_is_compatible("PowerBook3,4") || } else if (of_machine_is_compatible("PowerBook3,4") ||
machine_is_compatible("PowerBook3,5") || of_machine_is_compatible("PowerBook3,5") ||
machine_is_compatible("MacRISC3")) { of_machine_is_compatible("MacRISC3")) {
pmac_cpufreq_init_MacRISC3(cpunode); pmac_cpufreq_init_MacRISC3(cpunode);
/* Else check for iBook2 500/600 */ /* Else check for iBook2 500/600 */
} else if (machine_is_compatible("PowerBook4,1")) { } else if (of_machine_is_compatible("PowerBook4,1")) {
hi_freq = cur_freq; hi_freq = cur_freq;
low_freq = 400000; low_freq = 400000;
set_speed_proc = pmu_set_cpu_speed; set_speed_proc = pmu_set_cpu_speed;
is_pmu_based = 1; is_pmu_based = 1;
} }
/* Else check for TiPb 550 */ /* Else check for TiPb 550 */
else if (machine_is_compatible("PowerBook3,3") && cur_freq == 550000) { else if (of_machine_is_compatible("PowerBook3,3") && cur_freq == 550000) {
hi_freq = cur_freq; hi_freq = cur_freq;
low_freq = 500000; low_freq = 500000;
set_speed_proc = pmu_set_cpu_speed; set_speed_proc = pmu_set_cpu_speed;
is_pmu_based = 1; is_pmu_based = 1;
} }
/* Else check for TiPb 400 & 500 */ /* Else check for TiPb 400 & 500 */
else if (machine_is_compatible("PowerBook3,2")) { else if (of_machine_is_compatible("PowerBook3,2")) {
/* We only know about the 400 MHz and the 500Mhz model /* We only know about the 400 MHz and the 500Mhz model
* they both have 300 MHz as low frequency * they both have 300 MHz as low frequency
*/ */
......
...@@ -398,11 +398,11 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus) ...@@ -398,11 +398,11 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
int rc = -ENODEV; int rc = -ENODEV;
/* Check supported platforms */ /* Check supported platforms */
if (machine_is_compatible("PowerMac8,1") || if (of_machine_is_compatible("PowerMac8,1") ||
machine_is_compatible("PowerMac8,2") || of_machine_is_compatible("PowerMac8,2") ||
machine_is_compatible("PowerMac9,1")) of_machine_is_compatible("PowerMac9,1"))
use_volts_smu = 1; use_volts_smu = 1;
else if (machine_is_compatible("PowerMac11,2")) else if (of_machine_is_compatible("PowerMac11,2"))
use_volts_vdnap = 1; use_volts_vdnap = 1;
else else
return -ENODEV; return -ENODEV;
...@@ -729,9 +729,9 @@ static int __init g5_cpufreq_init(void) ...@@ -729,9 +729,9 @@ static int __init g5_cpufreq_init(void)
return -ENODEV; return -ENODEV;
} }
if (machine_is_compatible("PowerMac7,2") || if (of_machine_is_compatible("PowerMac7,2") ||
machine_is_compatible("PowerMac7,3") || of_machine_is_compatible("PowerMac7,3") ||
machine_is_compatible("RackMac3,1")) of_machine_is_compatible("RackMac3,1"))
rc = g5_pm72_cpufreq_init(cpus); rc = g5_pm72_cpufreq_init(cpus);
#ifdef CONFIG_PMAC_SMU #ifdef CONFIG_PMAC_SMU
else else
......
...@@ -2426,7 +2426,7 @@ static int __init probe_motherboard(void) ...@@ -2426,7 +2426,7 @@ static int __init probe_motherboard(void)
} }
} }
for(i=0; i<ARRAY_SIZE(pmac_mb_defs); i++) { for(i=0; i<ARRAY_SIZE(pmac_mb_defs); i++) {
if (machine_is_compatible(pmac_mb_defs[i].model_string)) { if (of_machine_is_compatible(pmac_mb_defs[i].model_string)) {
pmac_mb = pmac_mb_defs[i]; pmac_mb = pmac_mb_defs[i];
goto found; goto found;
} }
......
...@@ -842,7 +842,7 @@ struct pmf_function *__pmf_find_function(struct device_node *target, ...@@ -842,7 +842,7 @@ struct pmf_function *__pmf_find_function(struct device_node *target,
list_for_each_entry(func, &dev->functions, link) { list_for_each_entry(func, &dev->functions, link) {
if (name && strcmp(name, func->name)) if (name && strcmp(name, func->name))
continue; continue;
if (func->phandle && target->node != func->phandle) if (func->phandle && target->phandle != func->phandle)
continue; continue;
if ((func->flags & flags) == 0) if ((func->flags & flags) == 0)
continue; continue;
......
...@@ -693,9 +693,9 @@ static void __init smp_core99_setup(int ncpus) ...@@ -693,9 +693,9 @@ static void __init smp_core99_setup(int ncpus)
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
/* i2c based HW sync on some G5s */ /* i2c based HW sync on some G5s */
if (machine_is_compatible("PowerMac7,2") || if (of_machine_is_compatible("PowerMac7,2") ||
machine_is_compatible("PowerMac7,3") || of_machine_is_compatible("PowerMac7,3") ||
machine_is_compatible("RackMac3,1")) of_machine_is_compatible("RackMac3,1"))
smp_core99_setup_i2c_hwsync(ncpus); smp_core99_setup_i2c_hwsync(ncpus);
/* pfunc based HW sync on recent G5s */ /* pfunc based HW sync on recent G5s */
...@@ -713,7 +713,7 @@ static void __init smp_core99_setup(int ncpus) ...@@ -713,7 +713,7 @@ static void __init smp_core99_setup(int ncpus)
#else /* CONFIG_PPC64 */ #else /* CONFIG_PPC64 */
/* GPIO based HW sync on ppc32 Core99 */ /* GPIO based HW sync on ppc32 Core99 */
if (pmac_tb_freeze == NULL && !machine_is_compatible("MacRISC4")) { if (pmac_tb_freeze == NULL && !of_machine_is_compatible("MacRISC4")) {
struct device_node *cpu; struct device_node *cpu;
const u32 *tbprop = NULL; const u32 *tbprop = NULL;
...@@ -750,7 +750,7 @@ static void __init smp_core99_setup(int ncpus) ...@@ -750,7 +750,7 @@ static void __init smp_core99_setup(int ncpus)
#endif #endif
/* 32 bits SMP can't NAP */ /* 32 bits SMP can't NAP */
if (!machine_is_compatible("MacRISC4")) if (!of_machine_is_compatible("MacRISC4"))
powersave_nap = 0; powersave_nap = 0;
} }
...@@ -852,7 +852,7 @@ static void __devinit smp_core99_setup_cpu(int cpu_nr) ...@@ -852,7 +852,7 @@ static void __devinit smp_core99_setup_cpu(int cpu_nr)
/* If we didn't start the second CPU, we must take /* If we didn't start the second CPU, we must take
* it off the bus * it off the bus
*/ */
if (machine_is_compatible("MacRISC4") && if (of_machine_is_compatible("MacRISC4") &&
num_online_cpus() < 2) num_online_cpus() < 2)
g5_phy_disable_cpu1(); g5_phy_disable_cpu1();
#endif /* CONFIG_PPC64 */ #endif /* CONFIG_PPC64 */
......
...@@ -317,9 +317,9 @@ void __init pmac_calibrate_decr(void) ...@@ -317,9 +317,9 @@ void __init pmac_calibrate_decr(void)
* calibration. That's better since the VIA itself seems * calibration. That's better since the VIA itself seems
* to be slightly off. --BenH * to be slightly off. --BenH
*/ */
if (!machine_is_compatible("MacRISC2") && if (!of_machine_is_compatible("MacRISC2") &&
!machine_is_compatible("MacRISC3") && !of_machine_is_compatible("MacRISC3") &&
!machine_is_compatible("MacRISC4")) !of_machine_is_compatible("MacRISC4"))
if (via_calibrate_decr()) if (via_calibrate_decr())
return; return;
...@@ -328,7 +328,7 @@ void __init pmac_calibrate_decr(void) ...@@ -328,7 +328,7 @@ void __init pmac_calibrate_decr(void)
* probably implement calibration based on the KL timer on these * probably implement calibration based on the KL timer on these
* machines anyway... -BenH * machines anyway... -BenH
*/ */
if (machine_is_compatible("PowerMac3,5")) if (of_machine_is_compatible("PowerMac3,5"))
if (via_calibrate_decr()) if (via_calibrate_decr())
return; return;
#endif #endif
......
...@@ -132,9 +132,9 @@ void udbg_scc_init(int force_scc) ...@@ -132,9 +132,9 @@ void udbg_scc_init(int force_scc)
scc_inittab[1] = in_8(sccc); scc_inittab[1] = in_8(sccc);
out_8(sccc, 12); out_8(sccc, 12);
scc_inittab[3] = in_8(sccc); scc_inittab[3] = in_8(sccc);
} else if (machine_is_compatible("RackMac1,1") } else if (of_machine_is_compatible("RackMac1,1")
|| machine_is_compatible("RackMac1,2") || of_machine_is_compatible("RackMac1,2")
|| machine_is_compatible("MacRISC4")) { || of_machine_is_compatible("MacRISC4")) {
/* Xserves and G5s default to 57600 */ /* Xserves and G5s default to 57600 */
scc_inittab[1] = 0; scc_inittab[1] = 0;
scc_inittab[3] = 0; scc_inittab[3] = 0;
......
...@@ -56,9 +56,9 @@ static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable) ...@@ -56,9 +56,9 @@ static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable)
void __init setup_grackle(struct pci_controller *hose) void __init setup_grackle(struct pci_controller *hose)
{ {
setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0); setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
if (machine_is_compatible("PowerMac1,1")) if (of_machine_is_compatible("PowerMac1,1"))
ppc_pci_add_flags(PPC_PCI_REASSIGN_ALL_BUS); ppc_pci_add_flags(PPC_PCI_REASSIGN_ALL_BUS);
if (machine_is_compatible("AAPL,PowerBook1998")) if (of_machine_is_compatible("AAPL,PowerBook1998"))
grackle_set_loop_snoop(hose, 1); grackle_set_loop_snoop(hose, 1);
#if 0 /* Disabled for now, HW problems ??? */ #if 0 /* Disabled for now, HW problems ??? */
grackle_set_stg(hose, 1); grackle_set_stg(hose, 1);
......
...@@ -59,7 +59,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, ...@@ -59,7 +59,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
cur_inst = 0; cur_inst = 0;
for_each_node_by_type(dp, "cpu") { for_each_node_by_type(dp, "cpu") {
int err = check_cpu_node(dp->node, &cur_inst, int err = check_cpu_node(dp->phandle, &cur_inst,
compare, compare_arg, compare, compare_arg,
prom_node, mid); prom_node, mid);
if (!err) { if (!err) {
......
...@@ -433,7 +433,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, ...@@ -433,7 +433,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
if (!parent) if (!parent)
dev_set_name(&op->dev, "root"); dev_set_name(&op->dev, "root");
else else
dev_set_name(&op->dev, "%08x", dp->node); dev_set_name(&op->dev, "%08x", dp->phandle);
if (of_device_register(op)) { if (of_device_register(op)) {
printk("%s: Could not register of device.\n", printk("%s: Could not register of device.\n",
......
...@@ -676,7 +676,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp, ...@@ -676,7 +676,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,
if (!parent) if (!parent)
dev_set_name(&op->dev, "root"); dev_set_name(&op->dev, "root");
else else
dev_set_name(&op->dev, "%08x", dp->node); dev_set_name(&op->dev, "%08x", dp->phandle);
if (of_device_register(op)) { if (of_device_register(op)) {
printk("%s: Could not register of device.\n", printk("%s: Could not register of device.\n",
......
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/prom.h> #include <asm/prom.h>
extern struct device_node *allnodes; /* temporary while merging */
extern rwlock_t devtree_lock; /* temporary while merging */
extern void * prom_early_alloc(unsigned long size); extern void * prom_early_alloc(unsigned long size);
extern void irq_trans_init(struct device_node *dp); extern void irq_trans_init(struct device_node *dp);
......
...@@ -37,18 +37,6 @@ EXPORT_SYMBOL(of_console_path); ...@@ -37,18 +37,6 @@ EXPORT_SYMBOL(of_console_path);
char *of_console_options; char *of_console_options;
EXPORT_SYMBOL(of_console_options); EXPORT_SYMBOL(of_console_options);
struct device_node *of_find_node_by_phandle(phandle handle)
{
struct device_node *np;
for (np = allnodes; np; np = np->allnext)
if (np->node == handle)
break;
return np;
}
EXPORT_SYMBOL(of_find_node_by_phandle);
int of_getintprop_default(struct device_node *np, const char *name, int def) int of_getintprop_default(struct device_node *np, const char *name, int def)
{ {
struct property *prop; struct property *prop;
...@@ -89,7 +77,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len ...@@ -89,7 +77,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
void *old_val = prop->value; void *old_val = prop->value;
int ret; int ret;
ret = prom_setprop(dp->node, name, val, len); ret = prom_setprop(dp->phandle, name, val, len);
err = -EINVAL; err = -EINVAL;
if (ret >= 0) { if (ret >= 0) {
...@@ -236,7 +224,7 @@ static struct device_node * __init prom_create_node(phandle node, ...@@ -236,7 +224,7 @@ static struct device_node * __init prom_create_node(phandle node,
dp->name = get_one_property(node, "name"); dp->name = get_one_property(node, "name");
dp->type = get_one_property(node, "device_type"); dp->type = get_one_property(node, "device_type");
dp->node = node; dp->phandle = node;
dp->properties = build_prop_list(node); dp->properties = build_prop_list(node);
...@@ -313,7 +301,7 @@ void __init prom_build_devicetree(void) ...@@ -313,7 +301,7 @@ void __init prom_build_devicetree(void)
nextp = &allnodes->allnext; nextp = &allnodes->allnext;
allnodes->child = prom_build_tree(allnodes, allnodes->child = prom_build_tree(allnodes,
prom_getchild(allnodes->node), prom_getchild(allnodes->phandle),
&nextp); &nextp);
of_console_init(); of_console_init();
......
...@@ -370,7 +370,7 @@ static int __cpuinit smp_boot_one_cpu(unsigned int cpu) ...@@ -370,7 +370,7 @@ static int __cpuinit smp_boot_one_cpu(unsigned int cpu)
} else { } else {
struct device_node *dp = of_find_node_by_cpuid(cpu); struct device_node *dp = of_find_node_by_cpuid(cpu);
prom_startcpu(dp->node, entry, cookie); prom_startcpu(dp->phandle, entry, cookie);
} }
for (timeout = 0; timeout < 50000; timeout++) { for (timeout = 0; timeout < 50000; timeout++) {
......
...@@ -99,7 +99,7 @@ static int hvc_beat_config(char *p) ...@@ -99,7 +99,7 @@ static int hvc_beat_config(char *p)
static int __init hvc_beat_console_init(void) static int __init hvc_beat_console_init(void)
{ {
if (hvc_beat_useit && machine_is_compatible("Beat")) { if (hvc_beat_useit && of_machine_is_compatible("Beat")) {
hvc_instantiate(0, 0, &hvc_beat_get_put_ops); hvc_instantiate(0, 0, &hvc_beat_get_put_ops);
} }
return 0; return 0;
......
...@@ -1279,47 +1279,47 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev) ...@@ -1279,47 +1279,47 @@ bool radeon_get_legacy_connector_info_from_table(struct drm_device *dev)
rdev->mode_info.connector_table = radeon_connector_table; rdev->mode_info.connector_table = radeon_connector_table;
if (rdev->mode_info.connector_table == CT_NONE) { if (rdev->mode_info.connector_table == CT_NONE) {
#ifdef CONFIG_PPC_PMAC #ifdef CONFIG_PPC_PMAC
if (machine_is_compatible("PowerBook3,3")) { if (of_machine_is_compatible("PowerBook3,3")) {
/* powerbook with VGA */ /* powerbook with VGA */
rdev->mode_info.connector_table = CT_POWERBOOK_VGA; rdev->mode_info.connector_table = CT_POWERBOOK_VGA;
} else if (machine_is_compatible("PowerBook3,4") || } else if (of_machine_is_compatible("PowerBook3,4") ||
machine_is_compatible("PowerBook3,5")) { of_machine_is_compatible("PowerBook3,5")) {
/* powerbook with internal tmds */ /* powerbook with internal tmds */
rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL; rdev->mode_info.connector_table = CT_POWERBOOK_INTERNAL;
} else if (machine_is_compatible("PowerBook5,1") || } else if (of_machine_is_compatible("PowerBook5,1") ||
machine_is_compatible("PowerBook5,2") || of_machine_is_compatible("PowerBook5,2") ||
machine_is_compatible("PowerBook5,3") || of_machine_is_compatible("PowerBook5,3") ||
machine_is_compatible("PowerBook5,4") || of_machine_is_compatible("PowerBook5,4") ||
machine_is_compatible("PowerBook5,5")) { of_machine_is_compatible("PowerBook5,5")) {
/* powerbook with external single link tmds (sil164) */ /* powerbook with external single link tmds (sil164) */
rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
} else if (machine_is_compatible("PowerBook5,6")) { } else if (of_machine_is_compatible("PowerBook5,6")) {
/* powerbook with external dual or single link tmds */ /* powerbook with external dual or single link tmds */
rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
} else if (machine_is_compatible("PowerBook5,7") || } else if (of_machine_is_compatible("PowerBook5,7") ||
machine_is_compatible("PowerBook5,8") || of_machine_is_compatible("PowerBook5,8") ||
machine_is_compatible("PowerBook5,9")) { of_machine_is_compatible("PowerBook5,9")) {
/* PowerBook6,2 ? */ /* PowerBook6,2 ? */
/* powerbook with external dual link tmds (sil1178?) */ /* powerbook with external dual link tmds (sil1178?) */
rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL; rdev->mode_info.connector_table = CT_POWERBOOK_EXTERNAL;
} else if (machine_is_compatible("PowerBook4,1") || } else if (of_machine_is_compatible("PowerBook4,1") ||
machine_is_compatible("PowerBook4,2") || of_machine_is_compatible("PowerBook4,2") ||
machine_is_compatible("PowerBook4,3") || of_machine_is_compatible("PowerBook4,3") ||
machine_is_compatible("PowerBook6,3") || of_machine_is_compatible("PowerBook6,3") ||
machine_is_compatible("PowerBook6,5") || of_machine_is_compatible("PowerBook6,5") ||
machine_is_compatible("PowerBook6,7")) { of_machine_is_compatible("PowerBook6,7")) {
/* ibook */ /* ibook */
rdev->mode_info.connector_table = CT_IBOOK; rdev->mode_info.connector_table = CT_IBOOK;
} else if (machine_is_compatible("PowerMac4,4")) { } else if (of_machine_is_compatible("PowerMac4,4")) {
/* emac */ /* emac */
rdev->mode_info.connector_table = CT_EMAC; rdev->mode_info.connector_table = CT_EMAC;
} else if (machine_is_compatible("PowerMac10,1")) { } else if (of_machine_is_compatible("PowerMac10,1")) {
/* mini with internal tmds */ /* mini with internal tmds */
rdev->mode_info.connector_table = CT_MINI_INTERNAL; rdev->mode_info.connector_table = CT_MINI_INTERNAL;
} else if (machine_is_compatible("PowerMac10,2")) { } else if (of_machine_is_compatible("PowerMac10,2")) {
/* mini with external tmds */ /* mini with external tmds */
rdev->mode_info.connector_table = CT_MINI_EXTERNAL; rdev->mode_info.connector_table = CT_MINI_EXTERNAL;
} else if (machine_is_compatible("PowerMac12,1")) { } else if (of_machine_is_compatible("PowerMac12,1")) {
/* PowerMac8,1 ? */ /* PowerMac8,1 ? */
/* imac g5 isight */ /* imac g5 isight */
rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT; rdev->mode_info.connector_table = CT_IMAC_G5_ISIGHT;
......
...@@ -322,8 +322,8 @@ static int __init adb_init(void) ...@@ -322,8 +322,8 @@ static int __init adb_init(void)
adb_controller = NULL; adb_controller = NULL;
} else { } else {
#ifdef CONFIG_PPC #ifdef CONFIG_PPC
if (machine_is_compatible("AAPL,PowerBook1998") || if (of_machine_is_compatible("AAPL,PowerBook1998") ||
machine_is_compatible("PowerBook1,1")) of_machine_is_compatible("PowerBook1,1"))
sleepy_trackpad = 1; sleepy_trackpad = 1;
#endif /* CONFIG_PPC */ #endif /* CONFIG_PPC */
......
...@@ -1899,7 +1899,7 @@ static int create_control_loops(void) ...@@ -1899,7 +1899,7 @@ static int create_control_loops(void)
*/ */
if (rackmac) if (rackmac)
cpu_pid_type = CPU_PID_TYPE_RACKMAC; cpu_pid_type = CPU_PID_TYPE_RACKMAC;
else if (machine_is_compatible("PowerMac7,3") else if (of_machine_is_compatible("PowerMac7,3")
&& (cpu_count > 1) && (cpu_count > 1)
&& fcu_fans[CPUA_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID && fcu_fans[CPUA_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID
&& fcu_fans[CPUB_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID) { && fcu_fans[CPUB_PUMP_RPM_INDEX].id != FCU_FAN_ABSENT_ID) {
...@@ -2234,10 +2234,10 @@ static int __init therm_pm72_init(void) ...@@ -2234,10 +2234,10 @@ static int __init therm_pm72_init(void)
{ {
struct device_node *np; struct device_node *np;
rackmac = machine_is_compatible("RackMac3,1"); rackmac = of_machine_is_compatible("RackMac3,1");
if (!machine_is_compatible("PowerMac7,2") && if (!of_machine_is_compatible("PowerMac7,2") &&
!machine_is_compatible("PowerMac7,3") && !of_machine_is_compatible("PowerMac7,3") &&
!rackmac) !rackmac)
return -ENODEV; return -ENODEV;
......
...@@ -490,7 +490,7 @@ g4fan_init( void ) ...@@ -490,7 +490,7 @@ g4fan_init( void )
info = of_get_property(np, "thermal-info", NULL); info = of_get_property(np, "thermal-info", NULL);
of_node_put(np); of_node_put(np);
if( !info || !machine_is_compatible("PowerMac3,6") ) if( !info || !of_machine_is_compatible("PowerMac3,6") )
return -ENODEV; return -ENODEV;
if( info->id != 3 ) { if( info->id != 3 ) {
......
...@@ -150,13 +150,13 @@ void __init pmu_backlight_init() ...@@ -150,13 +150,13 @@ void __init pmu_backlight_init()
/* Special case for the old PowerBook since I can't test on it */ /* Special case for the old PowerBook since I can't test on it */
autosave = autosave =
machine_is_compatible("AAPL,3400/2400") || of_machine_is_compatible("AAPL,3400/2400") ||
machine_is_compatible("AAPL,3500"); of_machine_is_compatible("AAPL,3500");
if (!autosave && if (!autosave &&
!pmac_has_backlight_type("pmu") && !pmac_has_backlight_type("pmu") &&
!machine_is_compatible("AAPL,PowerBook1998") && !of_machine_is_compatible("AAPL,PowerBook1998") &&
!machine_is_compatible("PowerBook1,1")) !of_machine_is_compatible("PowerBook1,1"))
return; return;
snprintf(name, sizeof(name), "pmubl"); snprintf(name, sizeof(name), "pmubl");
......
...@@ -463,8 +463,8 @@ static int __init via_pmu_dev_init(void) ...@@ -463,8 +463,8 @@ static int __init via_pmu_dev_init(void)
#endif #endif
#ifdef CONFIG_PPC32 #ifdef CONFIG_PPC32
if (machine_is_compatible("AAPL,3400/2400") || if (of_machine_is_compatible("AAPL,3400/2400") ||
machine_is_compatible("AAPL,3500")) { of_machine_is_compatible("AAPL,3500")) {
int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO, int mb = pmac_call_feature(PMAC_FTR_GET_MB_INFO,
NULL, PMAC_MB_INFO_MODEL, 0); NULL, PMAC_MB_INFO_MODEL, 0);
pmu_battery_count = 1; pmu_battery_count = 1;
...@@ -472,8 +472,8 @@ static int __init via_pmu_dev_init(void) ...@@ -472,8 +472,8 @@ static int __init via_pmu_dev_init(void)
pmu_batteries[0].flags |= PMU_BATT_TYPE_COMET; pmu_batteries[0].flags |= PMU_BATT_TYPE_COMET;
else else
pmu_batteries[0].flags |= PMU_BATT_TYPE_HOOPER; pmu_batteries[0].flags |= PMU_BATT_TYPE_HOOPER;
} else if (machine_is_compatible("AAPL,PowerBook1998") || } else if (of_machine_is_compatible("AAPL,PowerBook1998") ||
machine_is_compatible("PowerBook1,1")) { of_machine_is_compatible("PowerBook1,1")) {
pmu_battery_count = 2; pmu_battery_count = 2;
pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART; pmu_batteries[0].flags |= PMU_BATT_TYPE_SMART;
pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART; pmu_batteries[1].flags |= PMU_BATT_TYPE_SMART;
......
...@@ -468,9 +468,9 @@ static int __init windfarm_core_init(void) ...@@ -468,9 +468,9 @@ static int __init windfarm_core_init(void)
DBG("wf: core loaded\n"); DBG("wf: core loaded\n");
/* Don't register on old machines that use therm_pm72 for now */ /* Don't register on old machines that use therm_pm72 for now */
if (machine_is_compatible("PowerMac7,2") || if (of_machine_is_compatible("PowerMac7,2") ||
machine_is_compatible("PowerMac7,3") || of_machine_is_compatible("PowerMac7,3") ||
machine_is_compatible("RackMac3,1")) of_machine_is_compatible("RackMac3,1"))
return -ENODEV; return -ENODEV;
platform_device_register(&wf_platform_device); platform_device_register(&wf_platform_device);
return 0; return 0;
......
...@@ -76,9 +76,9 @@ static int __init wf_cpufreq_clamp_init(void) ...@@ -76,9 +76,9 @@ static int __init wf_cpufreq_clamp_init(void)
struct wf_control *clamp; struct wf_control *clamp;
/* Don't register on old machines that use therm_pm72 for now */ /* Don't register on old machines that use therm_pm72 for now */
if (machine_is_compatible("PowerMac7,2") || if (of_machine_is_compatible("PowerMac7,2") ||
machine_is_compatible("PowerMac7,3") || of_machine_is_compatible("PowerMac7,3") ||
machine_is_compatible("RackMac3,1")) of_machine_is_compatible("RackMac3,1"))
return -ENODEV; return -ENODEV;
clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL); clamp = kmalloc(sizeof(struct wf_control), GFP_KERNEL);
......
...@@ -239,9 +239,9 @@ static struct i2c_driver wf_lm75_driver = { ...@@ -239,9 +239,9 @@ static struct i2c_driver wf_lm75_driver = {
static int __init wf_lm75_sensor_init(void) static int __init wf_lm75_sensor_init(void)
{ {
/* Don't register on old machines that use therm_pm72 for now */ /* Don't register on old machines that use therm_pm72 for now */
if (machine_is_compatible("PowerMac7,2") || if (of_machine_is_compatible("PowerMac7,2") ||
machine_is_compatible("PowerMac7,3") || of_machine_is_compatible("PowerMac7,3") ||
machine_is_compatible("RackMac3,1")) of_machine_is_compatible("RackMac3,1"))
return -ENODEV; return -ENODEV;
return i2c_add_driver(&wf_lm75_driver); return i2c_add_driver(&wf_lm75_driver);
} }
......
...@@ -188,9 +188,9 @@ static struct i2c_driver wf_max6690_driver = { ...@@ -188,9 +188,9 @@ static struct i2c_driver wf_max6690_driver = {
static int __init wf_max6690_sensor_init(void) static int __init wf_max6690_sensor_init(void)
{ {
/* Don't register on old machines that use therm_pm72 for now */ /* Don't register on old machines that use therm_pm72 for now */
if (machine_is_compatible("PowerMac7,2") || if (of_machine_is_compatible("PowerMac7,2") ||
machine_is_compatible("PowerMac7,3") || of_machine_is_compatible("PowerMac7,3") ||
machine_is_compatible("RackMac3,1")) of_machine_is_compatible("RackMac3,1"))
return -ENODEV; return -ENODEV;
return i2c_add_driver(&wf_max6690_driver); return i2c_add_driver(&wf_max6690_driver);
} }
......
...@@ -676,7 +676,7 @@ static int __init wf_pm112_init(void) ...@@ -676,7 +676,7 @@ static int __init wf_pm112_init(void)
{ {
struct device_node *cpu; struct device_node *cpu;
if (!machine_is_compatible("PowerMac11,2")) if (!of_machine_is_compatible("PowerMac11,2"))
return -ENODEV; return -ENODEV;
/* Count the number of CPU cores */ /* Count the number of CPU cores */
......
...@@ -1008,7 +1008,7 @@ static int __init pm121_init(void) ...@@ -1008,7 +1008,7 @@ static int __init pm121_init(void)
{ {
int rc = -ENODEV; int rc = -ENODEV;
if (machine_is_compatible("PowerMac12,1")) if (of_machine_is_compatible("PowerMac12,1"))
rc = pm121_init_pm(); rc = pm121_init_pm();
if (rc == 0) { if (rc == 0) {
......
...@@ -779,8 +779,8 @@ static int __init wf_smu_init(void) ...@@ -779,8 +779,8 @@ static int __init wf_smu_init(void)
{ {
int rc = -ENODEV; int rc = -ENODEV;
if (machine_is_compatible("PowerMac8,1") || if (of_machine_is_compatible("PowerMac8,1") ||
machine_is_compatible("PowerMac8,2")) of_machine_is_compatible("PowerMac8,2"))
rc = wf_init_pm(); rc = wf_init_pm();
if (rc == 0) { if (rc == 0) {
......
...@@ -711,7 +711,7 @@ static int __init wf_smu_init(void) ...@@ -711,7 +711,7 @@ static int __init wf_smu_init(void)
{ {
int rc = -ENODEV; int rc = -ENODEV;
if (machine_is_compatible("PowerMac9,1")) if (of_machine_is_compatible("PowerMac9,1"))
rc = wf_init_pm(); rc = wf_init_pm();
if (rc == 0) { if (rc == 0) {
......
...@@ -363,9 +363,9 @@ smu_cpu_power_create(struct wf_sensor *volts, struct wf_sensor *amps) ...@@ -363,9 +363,9 @@ smu_cpu_power_create(struct wf_sensor *volts, struct wf_sensor *amps)
* I yet have to figure out what's up with 8,2 and will have to * I yet have to figure out what's up with 8,2 and will have to
* adjust for later, unless we can 100% trust the SDB partition... * adjust for later, unless we can 100% trust the SDB partition...
*/ */
if ((machine_is_compatible("PowerMac8,1") || if ((of_machine_is_compatible("PowerMac8,1") ||
machine_is_compatible("PowerMac8,2") || of_machine_is_compatible("PowerMac8,2") ||
machine_is_compatible("PowerMac9,1")) && of_machine_is_compatible("PowerMac9,1")) &&
cpuvcp_version >= 2) { cpuvcp_version >= 2) {
pow->quadratic = 1; pow->quadratic = 1;
DBG("windfarm: CPU Power using quadratic transform\n"); DBG("windfarm: CPU Power using quadratic transform\n");
......
...@@ -206,7 +206,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i ...@@ -206,7 +206,7 @@ static int __devinit mace_probe(struct macio_dev *mdev, const struct of_device_i
mp->port_aaui = port_aaui; mp->port_aaui = port_aaui;
else { else {
/* Apple Network Server uses the AAUI port */ /* Apple Network Server uses the AAUI port */
if (machine_is_compatible("AAPL,ShinerESB")) if (of_machine_is_compatible("AAPL,ShinerESB"))
mp->port_aaui = 1; mp->port_aaui = 1;
else { else {
#ifdef CONFIG_MACE_AAUI_PORT #ifdef CONFIG_MACE_AAUI_PORT
......
config OF_FLATTREE
bool
depends on OF
config OF_DYNAMIC
def_bool y
depends on OF && PPC_OF
config OF_DEVICE config OF_DEVICE
def_bool y def_bool y
depends on OF && (SPARC || PPC_OF || MICROBLAZE) depends on OF && (SPARC || PPC_OF || MICROBLAZE)
......
obj-y = base.o obj-y = base.o
obj-$(CONFIG_OF_FLATTREE) += fdt.o
obj-$(CONFIG_OF_DEVICE) += device.o platform.o obj-$(CONFIG_OF_DEVICE) += device.o platform.o
obj-$(CONFIG_OF_GPIO) += gpio.o obj-$(CONFIG_OF_GPIO) += gpio.o
obj-$(CONFIG_OF_I2C) += of_i2c.o obj-$(CONFIG_OF_I2C) += of_i2c.o
......
...@@ -20,8 +20,10 @@ ...@@ -20,8 +20,10 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/proc_fs.h>
struct device_node *allnodes; struct device_node *allnodes;
struct device_node *of_chosen;
/* use when traversing tree through the allnext, child, sibling, /* use when traversing tree through the allnext, child, sibling,
* or parent members of struct device_node. * or parent members of struct device_node.
...@@ -37,7 +39,7 @@ int of_n_addr_cells(struct device_node *np) ...@@ -37,7 +39,7 @@ int of_n_addr_cells(struct device_node *np)
np = np->parent; np = np->parent;
ip = of_get_property(np, "#address-cells", NULL); ip = of_get_property(np, "#address-cells", NULL);
if (ip) if (ip)
return *ip; return be32_to_cpup(ip);
} while (np->parent); } while (np->parent);
/* No #address-cells property for the root node */ /* No #address-cells property for the root node */
return OF_ROOT_NODE_ADDR_CELLS_DEFAULT; return OF_ROOT_NODE_ADDR_CELLS_DEFAULT;
...@@ -53,13 +55,88 @@ int of_n_size_cells(struct device_node *np) ...@@ -53,13 +55,88 @@ int of_n_size_cells(struct device_node *np)
np = np->parent; np = np->parent;
ip = of_get_property(np, "#size-cells", NULL); ip = of_get_property(np, "#size-cells", NULL);
if (ip) if (ip)
return *ip; return be32_to_cpup(ip);
} while (np->parent); } while (np->parent);
/* No #size-cells property for the root node */ /* No #size-cells property for the root node */
return OF_ROOT_NODE_SIZE_CELLS_DEFAULT; return OF_ROOT_NODE_SIZE_CELLS_DEFAULT;
} }
EXPORT_SYMBOL(of_n_size_cells); EXPORT_SYMBOL(of_n_size_cells);
#if !defined(CONFIG_SPARC) /* SPARC doesn't do ref counting (yet) */
/**
* of_node_get - Increment refcount of a node
* @node: Node to inc refcount, NULL is supported to
* simplify writing of callers
*
* Returns node.
*/
struct device_node *of_node_get(struct device_node *node)
{
if (node)
kref_get(&node->kref);
return node;
}
EXPORT_SYMBOL(of_node_get);
static inline struct device_node *kref_to_device_node(struct kref *kref)
{
return container_of(kref, struct device_node, kref);
}
/**
* of_node_release - release a dynamically allocated node
* @kref: kref element of the node to be released
*
* In of_node_put() this function is passed to kref_put()
* as the destructor.
*/
static void of_node_release(struct kref *kref)
{
struct device_node *node = kref_to_device_node(kref);
struct property *prop = node->properties;
/* We should never be releasing nodes that haven't been detached. */
if (!of_node_check_flag(node, OF_DETACHED)) {
pr_err("ERROR: Bad of_node_put() on %s\n", node->full_name);
dump_stack();
kref_init(&node->kref);
return;
}
if (!of_node_check_flag(node, OF_DYNAMIC))
return;
while (prop) {
struct property *next = prop->next;
kfree(prop->name);
kfree(prop->value);
kfree(prop);
prop = next;
if (!prop) {
prop = node->deadprops;
node->deadprops = NULL;
}
}
kfree(node->full_name);
kfree(node->data);
kfree(node);
}
/**
* of_node_put - Decrement refcount of a node
* @node: Node to dec refcount, NULL is supported to
* simplify writing of callers
*
*/
void of_node_put(struct device_node *node)
{
if (node)
kref_put(&node->kref, of_node_release);
}
EXPORT_SYMBOL(of_node_put);
#endif /* !CONFIG_SPARC */
struct property *of_find_property(const struct device_node *np, struct property *of_find_property(const struct device_node *np,
const char *name, const char *name,
int *lenp) int *lenp)
...@@ -143,6 +220,27 @@ int of_device_is_compatible(const struct device_node *device, ...@@ -143,6 +220,27 @@ int of_device_is_compatible(const struct device_node *device,
} }
EXPORT_SYMBOL(of_device_is_compatible); EXPORT_SYMBOL(of_device_is_compatible);
/**
* of_machine_is_compatible - Test root of device tree for a given compatible value
* @compat: compatible string to look for in root node's compatible property.
*
* Returns true if the root node has the given value in its
* compatible property.
*/
int of_machine_is_compatible(const char *compat)
{
struct device_node *root;
int rc = 0;
root = of_find_node_by_path("/");
if (root) {
rc = of_device_is_compatible(root, compat);
of_node_put(root);
}
return rc;
}
EXPORT_SYMBOL(of_machine_is_compatible);
/** /**
* of_device_is_available - check if a device is available for use * of_device_is_available - check if a device is available for use
* *
...@@ -518,6 +616,27 @@ int of_modalias_node(struct device_node *node, char *modalias, int len) ...@@ -518,6 +616,27 @@ int of_modalias_node(struct device_node *node, char *modalias, int len)
} }
EXPORT_SYMBOL_GPL(of_modalias_node); EXPORT_SYMBOL_GPL(of_modalias_node);
/**
* of_find_node_by_phandle - Find a node given a phandle
* @handle: phandle of the node to find
*
* Returns a node pointer with refcount incremented, use
* of_node_put() on it when done.
*/
struct device_node *of_find_node_by_phandle(phandle handle)
{
struct device_node *np;
read_lock(&devtree_lock);
for (np = allnodes; np; np = np->allnext)
if (np->phandle == handle)
break;
of_node_get(np);
read_unlock(&devtree_lock);
return np;
}
EXPORT_SYMBOL(of_find_node_by_phandle);
/** /**
* of_parse_phandle - Resolve a phandle property to a device_node pointer * of_parse_phandle - Resolve a phandle property to a device_node pointer
* @np: Pointer to device node holding phandle property * @np: Pointer to device node holding phandle property
...@@ -578,8 +697,8 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name, ...@@ -578,8 +697,8 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
const void **out_args) const void **out_args)
{ {
int ret = -EINVAL; int ret = -EINVAL;
const u32 *list; const __be32 *list;
const u32 *list_end; const __be32 *list_end;
int size; int size;
int cur_index = 0; int cur_index = 0;
struct device_node *node = NULL; struct device_node *node = NULL;
...@@ -593,7 +712,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name, ...@@ -593,7 +712,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
list_end = list + size / sizeof(*list); list_end = list + size / sizeof(*list);
while (list < list_end) { while (list < list_end) {
const u32 *cells; const __be32 *cells;
const phandle *phandle; const phandle *phandle;
phandle = list++; phandle = list++;
...@@ -617,7 +736,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name, ...@@ -617,7 +736,7 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
goto err1; goto err1;
} }
list += *cells; list += be32_to_cpup(cells);
if (list > list_end) { if (list > list_end) {
pr_debug("%s: insufficient arguments length\n", pr_debug("%s: insufficient arguments length\n",
np->full_name); np->full_name);
...@@ -658,3 +777,190 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name, ...@@ -658,3 +777,190 @@ int of_parse_phandles_with_args(struct device_node *np, const char *list_name,
return ret; return ret;
} }
EXPORT_SYMBOL(of_parse_phandles_with_args); EXPORT_SYMBOL(of_parse_phandles_with_args);
/**
* prom_add_property - Add a property to a node
*/
int prom_add_property(struct device_node *np, struct property *prop)
{
struct property **next;
unsigned long flags;
prop->next = NULL;
write_lock_irqsave(&devtree_lock, flags);
next = &np->properties;
while (*next) {
if (strcmp(prop->name, (*next)->name) == 0) {
/* duplicate ! don't insert it */
write_unlock_irqrestore(&devtree_lock, flags);
return -1;
}
next = &(*next)->next;
}
*next = prop;
write_unlock_irqrestore(&devtree_lock, flags);
#ifdef CONFIG_PROC_DEVICETREE
/* try to add to proc as well if it was initialized */
if (np->pde)
proc_device_tree_add_prop(np->pde, prop);
#endif /* CONFIG_PROC_DEVICETREE */
return 0;
}
/**
* prom_remove_property - Remove a property from a node.
*
* Note that we don't actually remove it, since we have given out
* who-knows-how-many pointers to the data using get-property.
* Instead we just move the property to the "dead properties"
* list, so it won't be found any more.
*/
int prom_remove_property(struct device_node *np, struct property *prop)
{
struct property **next;
unsigned long flags;
int found = 0;
write_lock_irqsave(&devtree_lock, flags);
next = &np->properties;
while (*next) {
if (*next == prop) {
/* found the node */
*next = prop->next;
prop->next = np->deadprops;
np->deadprops = prop;
found = 1;
break;
}
next = &(*next)->next;
}
write_unlock_irqrestore(&devtree_lock, flags);
if (!found)
return -ENODEV;
#ifdef CONFIG_PROC_DEVICETREE
/* try to remove the proc node as well */
if (np->pde)
proc_device_tree_remove_prop(np->pde, prop);
#endif /* CONFIG_PROC_DEVICETREE */
return 0;
}
/*
* prom_update_property - Update a property in a node.
*
* Note that we don't actually remove it, since we have given out
* who-knows-how-many pointers to the data using get-property.
* Instead we just move the property to the "dead properties" list,
* and add the new property to the property list
*/
int prom_update_property(struct device_node *np,
struct property *newprop,
struct property *oldprop)
{
struct property **next;
unsigned long flags;
int found = 0;
write_lock_irqsave(&devtree_lock, flags);
next = &np->properties;
while (*next) {
if (*next == oldprop) {
/* found the node */
newprop->next = oldprop->next;
*next = newprop;
oldprop->next = np->deadprops;
np->deadprops = oldprop;
found = 1;
break;
}
next = &(*next)->next;
}
write_unlock_irqrestore(&devtree_lock, flags);
if (!found)
return -ENODEV;
#ifdef CONFIG_PROC_DEVICETREE
/* try to add to proc as well if it was initialized */
if (np->pde)
proc_device_tree_update_prop(np->pde, newprop, oldprop);
#endif /* CONFIG_PROC_DEVICETREE */
return 0;
}
#if defined(CONFIG_OF_DYNAMIC)
/*
* Support for dynamic device trees.
*
* On some platforms, the device tree can be manipulated at runtime.
* The routines in this section support adding, removing and changing
* device tree nodes.
*/
/**
* of_attach_node - Plug a device node into the tree and global list.
*/
void of_attach_node(struct device_node *np)
{
unsigned long flags;
write_lock_irqsave(&devtree_lock, flags);
np->sibling = np->parent->child;
np->allnext = allnodes;
np->parent->child = np;
allnodes = np;
write_unlock_irqrestore(&devtree_lock, flags);
}
/**
* of_detach_node - "Unplug" a node from the device tree.
*
* The caller must hold a reference to the node. The memory associated with
* the node is not freed until its refcount goes to zero.
*/
void of_detach_node(struct device_node *np)
{
struct device_node *parent;
unsigned long flags;
write_lock_irqsave(&devtree_lock, flags);
parent = np->parent;
if (!parent)
goto out_unlock;
if (allnodes == np)
allnodes = np->allnext;
else {
struct device_node *prev;
for (prev = allnodes;
prev->allnext != np;
prev = prev->allnext)
;
prev->allnext = np->allnext;
}
if (parent->child == np)
parent->child = np->sibling;
else {
struct device_node *prevsib;
for (prevsib = np->parent->child;
prevsib->sibling != np;
prevsib = prevsib->sibling)
;
prevsib->sibling = np->sibling;
}
of_node_set_flag(np, OF_DETACHED);
out_unlock:
write_unlock_irqrestore(&devtree_lock, flags);
}
#endif /* defined(CONFIG_OF_DYNAMIC) */
This diff is collapsed.
...@@ -36,7 +36,7 @@ int of_get_gpio_flags(struct device_node *np, int index, ...@@ -36,7 +36,7 @@ int of_get_gpio_flags(struct device_node *np, int index,
struct of_gpio_chip *of_gc = NULL; struct of_gpio_chip *of_gc = NULL;
int size; int size;
const void *gpio_spec; const void *gpio_spec;
const u32 *gpio_cells; const __be32 *gpio_cells;
ret = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index, ret = of_parse_phandles_with_args(np, "gpios", "#gpio-cells", index,
&gc, &gpio_spec); &gc, &gpio_spec);
...@@ -55,7 +55,7 @@ int of_get_gpio_flags(struct device_node *np, int index, ...@@ -55,7 +55,7 @@ int of_get_gpio_flags(struct device_node *np, int index,
gpio_cells = of_get_property(gc, "#gpio-cells", &size); gpio_cells = of_get_property(gc, "#gpio-cells", &size);
if (!gpio_cells || size != sizeof(*gpio_cells) || if (!gpio_cells || size != sizeof(*gpio_cells) ||
*gpio_cells != of_gc->gpio_cells) { be32_to_cpup(gpio_cells) != of_gc->gpio_cells) {
pr_debug("%s: wrong #gpio-cells for %s\n", pr_debug("%s: wrong #gpio-cells for %s\n",
np->full_name, gc->full_name); np->full_name, gc->full_name);
ret = -EINVAL; ret = -EINVAL;
...@@ -127,7 +127,8 @@ EXPORT_SYMBOL(of_gpio_count); ...@@ -127,7 +127,8 @@ EXPORT_SYMBOL(of_gpio_count);
int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np, int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,
const void *gpio_spec, enum of_gpio_flags *flags) const void *gpio_spec, enum of_gpio_flags *flags)
{ {
const u32 *gpio = gpio_spec; const __be32 *gpio = gpio_spec;
const u32 n = be32_to_cpup(gpio);
/* /*
* We're discouraging gpio_cells < 2, since that way you'll have to * We're discouraging gpio_cells < 2, since that way you'll have to
...@@ -140,13 +141,13 @@ int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np, ...@@ -140,13 +141,13 @@ int of_gpio_simple_xlate(struct of_gpio_chip *of_gc, struct device_node *np,
return -EINVAL; return -EINVAL;
} }
if (*gpio > of_gc->gc.ngpio) if (n > of_gc->gc.ngpio)
return -EINVAL; return -EINVAL;
if (flags) if (flags)
*flags = gpio[1]; *flags = be32_to_cpu(gpio[1]);
return *gpio; return n;
} }
EXPORT_SYMBOL(of_gpio_simple_xlate); EXPORT_SYMBOL(of_gpio_simple_xlate);
......
...@@ -25,7 +25,7 @@ void of_register_i2c_devices(struct i2c_adapter *adap, ...@@ -25,7 +25,7 @@ void of_register_i2c_devices(struct i2c_adapter *adap,
for_each_child_of_node(adap_node, node) { for_each_child_of_node(adap_node, node) {
struct i2c_board_info info = {}; struct i2c_board_info info = {};
struct dev_archdata dev_ad = {}; struct dev_archdata dev_ad = {};
const u32 *addr; const __be32 *addr;
int len; int len;
if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) if (of_modalias_node(node, info.type, sizeof(info.type)) < 0)
...@@ -40,7 +40,7 @@ void of_register_i2c_devices(struct i2c_adapter *adap, ...@@ -40,7 +40,7 @@ void of_register_i2c_devices(struct i2c_adapter *adap,
info.irq = irq_of_parse_and_map(node, 0); info.irq = irq_of_parse_and_map(node, 0);
info.addr = *addr; info.addr = be32_to_cpup(addr);
dev_archdata_set_node(&dev_ad, node); dev_archdata_set_node(&dev_ad, node);
info.archdata = &dev_ad; info.archdata = &dev_ad;
......
...@@ -51,7 +51,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) ...@@ -51,7 +51,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
/* Loop over the child nodes and register a phy_device for each one */ /* Loop over the child nodes and register a phy_device for each one */
for_each_child_of_node(np, child) { for_each_child_of_node(np, child) {
const u32 *addr; const __be32 *addr;
int len; int len;
/* A PHY must have a reg property in the range [0-31] */ /* A PHY must have a reg property in the range [0-31] */
...@@ -68,7 +68,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) ...@@ -68,7 +68,7 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
mdio->irq[*addr] = PHY_POLL; mdio->irq[*addr] = PHY_POLL;
} }
phy = get_phy_device(mdio, *addr); phy = get_phy_device(mdio, be32_to_cpup(addr));
if (!phy) { if (!phy) {
dev_err(&mdio->dev, "error probing PHY at address %i\n", dev_err(&mdio->dev, "error probing PHY at address %i\n",
*addr); *addr);
...@@ -160,7 +160,7 @@ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev, ...@@ -160,7 +160,7 @@ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,
struct device_node *net_np; struct device_node *net_np;
char bus_id[MII_BUS_ID_SIZE + 3]; char bus_id[MII_BUS_ID_SIZE + 3];
struct phy_device *phy; struct phy_device *phy;
const u32 *phy_id; const __be32 *phy_id;
int sz; int sz;
if (!dev->dev.parent) if (!dev->dev.parent)
...@@ -174,7 +174,7 @@ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev, ...@@ -174,7 +174,7 @@ struct phy_device *of_phy_connect_fixed_link(struct net_device *dev,
if (!phy_id || sz < sizeof(*phy_id)) if (!phy_id || sz < sizeof(*phy_id))
return NULL; return NULL;
sprintf(bus_id, PHY_ID_FMT, "0", phy_id[0]); sprintf(bus_id, PHY_ID_FMT, "0", be32_to_cpu(phy_id[0]));
phy = phy_connect(dev, bus_id, hndlr, 0, iface); phy = phy_connect(dev, bus_id, hndlr, 0, iface);
return IS_ERR(phy) ? NULL : phy; return IS_ERR(phy) ? NULL : phy;
......
...@@ -23,7 +23,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np) ...@@ -23,7 +23,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np)
{ {
struct spi_device *spi; struct spi_device *spi;
struct device_node *nc; struct device_node *nc;
const u32 *prop; const __be32 *prop;
int rc; int rc;
int len; int len;
...@@ -54,7 +54,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np) ...@@ -54,7 +54,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np)
spi_dev_put(spi); spi_dev_put(spi);
continue; continue;
} }
spi->chip_select = *prop; spi->chip_select = be32_to_cpup(prop);
/* Mode (clock phase/polarity/etc.) */ /* Mode (clock phase/polarity/etc.) */
if (of_find_property(nc, "spi-cpha", NULL)) if (of_find_property(nc, "spi-cpha", NULL))
...@@ -72,7 +72,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np) ...@@ -72,7 +72,7 @@ void of_register_spi_devices(struct spi_master *master, struct device_node *np)
spi_dev_put(spi); spi_dev_put(spi);
continue; continue;
} }
spi->max_speed_hz = *prop; spi->max_speed_hz = be32_to_cpup(prop);
/* IRQ */ /* IRQ */
spi->irq = irq_of_parse_and_map(nc, 0); spi->irq = irq_of_parse_and_map(nc, 0);
......
...@@ -233,7 +233,7 @@ static int opromnext(void __user *argp, unsigned int cmd, struct device_node *dp ...@@ -233,7 +233,7 @@ static int opromnext(void __user *argp, unsigned int cmd, struct device_node *dp
ph = 0; ph = 0;
if (dp) if (dp)
ph = dp->node; ph = dp->phandle;
data->current_node = dp; data->current_node = dp;
*((int *) op->oprom_array) = ph; *((int *) op->oprom_array) = ph;
...@@ -256,7 +256,7 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp ...@@ -256,7 +256,7 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp
dp = pci_device_to_OF_node(pdev); dp = pci_device_to_OF_node(pdev);
data->current_node = dp; data->current_node = dp;
*((int *)op->oprom_array) = dp->node; *((int *)op->oprom_array) = dp->phandle;
op->oprom_size = sizeof(int); op->oprom_size = sizeof(int);
err = copyout(argp, op, bufsize + sizeof(int)); err = copyout(argp, op, bufsize + sizeof(int));
...@@ -273,7 +273,7 @@ static int oprompath2node(void __user *argp, struct device_node *dp, struct open ...@@ -273,7 +273,7 @@ static int oprompath2node(void __user *argp, struct device_node *dp, struct open
dp = of_find_node_by_path(op->oprom_array); dp = of_find_node_by_path(op->oprom_array);
if (dp) if (dp)
ph = dp->node; ph = dp->phandle;
data->current_node = dp; data->current_node = dp;
*((int *)op->oprom_array) = ph; *((int *)op->oprom_array) = ph;
op->oprom_size = sizeof(int); op->oprom_size = sizeof(int);
...@@ -540,7 +540,7 @@ static int opiocgetnext(unsigned int cmd, void __user *argp) ...@@ -540,7 +540,7 @@ static int opiocgetnext(unsigned int cmd, void __user *argp)
} }
} }
if (dp) if (dp)
nd = dp->node; nd = dp->phandle;
if (copy_to_user(argp, &nd, sizeof(phandle))) if (copy_to_user(argp, &nd, sizeof(phandle)))
return -EFAULT; return -EFAULT;
...@@ -570,7 +570,7 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file, ...@@ -570,7 +570,7 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,
case OPIOCGETOPTNODE: case OPIOCGETOPTNODE:
BUILD_BUG_ON(sizeof(phandle) != sizeof(int)); BUILD_BUG_ON(sizeof(phandle) != sizeof(int));
if (copy_to_user(argp, &options_node->node, sizeof(phandle))) if (copy_to_user(argp, &options_node->phandle, sizeof(phandle)))
return -EFAULT; return -EFAULT;
return 0; return 0;
......
...@@ -2031,9 +2031,9 @@ static int __init pmz_console_setup(struct console *co, char *options) ...@@ -2031,9 +2031,9 @@ static int __init pmz_console_setup(struct console *co, char *options)
/* /*
* XServe's default to 57600 bps * XServe's default to 57600 bps
*/ */
if (machine_is_compatible("RackMac1,1") if (of_machine_is_compatible("RackMac1,1")
|| machine_is_compatible("RackMac1,2") || of_machine_is_compatible("RackMac1,2")
|| machine_is_compatible("MacRISC4")) || of_machine_is_compatible("MacRISC4"))
baud = 57600; baud = 57600;
/* /*
......
...@@ -1931,22 +1931,22 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i ...@@ -1931,22 +1931,22 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
* PowerMac2,2 summer 2000 iMacs * PowerMac2,2 summer 2000 iMacs
* PowerMac4,1 january 2001 iMacs "flower power" * PowerMac4,1 january 2001 iMacs "flower power"
*/ */
if (machine_is_compatible("PowerMac2,1") || if (of_machine_is_compatible("PowerMac2,1") ||
machine_is_compatible("PowerMac2,2") || of_machine_is_compatible("PowerMac2,2") ||
machine_is_compatible("PowerMac4,1")) of_machine_is_compatible("PowerMac4,1"))
default_vmode = VMODE_1024_768_75; default_vmode = VMODE_1024_768_75;
/* iBook SE */ /* iBook SE */
if (machine_is_compatible("PowerBook2,2")) if (of_machine_is_compatible("PowerBook2,2"))
default_vmode = VMODE_800_600_60; default_vmode = VMODE_800_600_60;
/* PowerBook Firewire (Pismo), iBook Dual USB */ /* PowerBook Firewire (Pismo), iBook Dual USB */
if (machine_is_compatible("PowerBook3,1") || if (of_machine_is_compatible("PowerBook3,1") ||
machine_is_compatible("PowerBook4,1")) of_machine_is_compatible("PowerBook4,1"))
default_vmode = VMODE_1024_768_60; default_vmode = VMODE_1024_768_60;
/* PowerBook Titanium */ /* PowerBook Titanium */
if (machine_is_compatible("PowerBook3,2")) if (of_machine_is_compatible("PowerBook3,2"))
default_vmode = VMODE_1152_768_60; default_vmode = VMODE_1152_768_60;
if (default_cmode > 16) if (default_cmode > 16)
......
...@@ -2439,7 +2439,7 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2439,7 +2439,7 @@ static int __devinit aty_init(struct fb_info *info)
* The Apple iBook1 uses non-standard memory frequencies. * The Apple iBook1 uses non-standard memory frequencies.
* We detect it and set the frequency manually. * We detect it and set the frequency manually.
*/ */
if (machine_is_compatible("PowerBook2,1")) { if (of_machine_is_compatible("PowerBook2,1")) {
par->pll_limits.mclk = 70; par->pll_limits.mclk = 70;
par->pll_limits.xclk = 53; par->pll_limits.xclk = 53;
} }
...@@ -2659,7 +2659,7 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2659,7 +2659,7 @@ static int __devinit aty_init(struct fb_info *info)
FBINFO_HWACCEL_YPAN; FBINFO_HWACCEL_YPAN;
#ifdef CONFIG_PMAC_BACKLIGHT #ifdef CONFIG_PMAC_BACKLIGHT
if (M64_HAS(G3_PB_1_1) && machine_is_compatible("PowerBook1,1")) { if (M64_HAS(G3_PB_1_1) && of_machine_is_compatible("PowerBook1,1")) {
/* /*
* these bits let the 101 powerbook * these bits let the 101 powerbook
* wake up from sleep -- paulus * wake up from sleep -- paulus
...@@ -2690,9 +2690,9 @@ static int __devinit aty_init(struct fb_info *info) ...@@ -2690,9 +2690,9 @@ static int __devinit aty_init(struct fb_info *info)
if (M64_HAS(G3_PB_1024x768)) if (M64_HAS(G3_PB_1024x768))
/* G3 PowerBook with 1024x768 LCD */ /* G3 PowerBook with 1024x768 LCD */
default_vmode = VMODE_1024_768_60; default_vmode = VMODE_1024_768_60;
else if (machine_is_compatible("iMac")) else if (of_machine_is_compatible("iMac"))
default_vmode = VMODE_1024_768_75; default_vmode = VMODE_1024_768_75;
else if (machine_is_compatible("PowerBook2,1")) else if (of_machine_is_compatible("PowerBook2,1"))
/* iBook with 800x600 LCD */ /* iBook with 800x600 LCD */
default_vmode = VMODE_800_600_60; default_vmode = VMODE_800_600_60;
else else
...@@ -3104,7 +3104,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, ...@@ -3104,7 +3104,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev,
} }
dp = pci_device_to_OF_node(pdev); dp = pci_device_to_OF_node(pdev);
if (node == dp->node) { if (node == dp->phandle) {
struct fb_var_screeninfo *var = &default_var; struct fb_var_screeninfo *var = &default_var;
unsigned int N, P, Q, M, T, R; unsigned int N, P, Q, M, T, R;
u32 v_total, h_total; u32 v_total, h_total;
......
...@@ -175,9 +175,9 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo) ...@@ -175,9 +175,9 @@ void radeonfb_bl_init(struct radeonfb_info *rinfo)
#ifdef CONFIG_PMAC_BACKLIGHT #ifdef CONFIG_PMAC_BACKLIGHT
pdata->negative = pdata->negative || pdata->negative = pdata->negative ||
machine_is_compatible("PowerBook4,3") || of_machine_is_compatible("PowerBook4,3") ||
machine_is_compatible("PowerBook6,3") || of_machine_is_compatible("PowerBook6,3") ||
machine_is_compatible("PowerBook6,5"); of_machine_is_compatible("PowerBook6,5");
#endif #endif
rinfo->info->bl_dev = bd; rinfo->info->bl_dev = bd;
......
...@@ -10,16 +10,19 @@ ...@@ -10,16 +10,19 @@
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/of.h>
#include <linux/module.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include "internal.h" #include "internal.h"
#ifndef HAVE_ARCH_DEVTREE_FIXUPS
static inline void set_node_proc_entry(struct device_node *np, static inline void set_node_proc_entry(struct device_node *np,
struct proc_dir_entry *de) struct proc_dir_entry *de)
{ {
} #ifdef HAVE_ARCH_DEVTREE_FIXUPS
np->pde = de;
#endif #endif
}
static struct proc_dir_entry *proc_device_tree; static struct proc_dir_entry *proc_device_tree;
......
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/kref.h> #include <linux/kref.h>
#include <linux/mod_devicetable.h> #include <linux/mod_devicetable.h>
#include <linux/spinlock.h>
#include <asm/byteorder.h>
#ifdef CONFIG_OF
typedef u32 phandle; typedef u32 phandle;
typedef u32 ihandle; typedef u32 ihandle;
...@@ -39,10 +44,7 @@ struct of_irq_controller; ...@@ -39,10 +44,7 @@ struct of_irq_controller;
struct device_node { struct device_node {
const char *name; const char *name;
const char *type; const char *type;
phandle node; phandle phandle;
#if !defined(CONFIG_SPARC)
phandle linux_phandle;
#endif
char *full_name; char *full_name;
struct property *properties; struct property *properties;
...@@ -63,6 +65,11 @@ struct device_node { ...@@ -63,6 +65,11 @@ struct device_node {
#endif #endif
}; };
/* Pointer for first entry in chain of all nodes. */
extern struct device_node *allnodes;
extern struct device_node *of_chosen;
extern rwlock_t devtree_lock;
static inline int of_node_check_flag(struct device_node *n, unsigned long flag) static inline int of_node_check_flag(struct device_node *n, unsigned long flag)
{ {
return test_bit(flag, &n->_flags); return test_bit(flag, &n->_flags);
...@@ -73,12 +80,6 @@ static inline void of_node_set_flag(struct device_node *n, unsigned long flag) ...@@ -73,12 +80,6 @@ static inline void of_node_set_flag(struct device_node *n, unsigned long flag)
set_bit(flag, &n->_flags); 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); extern struct device_node *of_find_all_nodes(struct device_node *prev);
#if defined(CONFIG_SPARC) #if defined(CONFIG_SPARC)
...@@ -101,26 +102,36 @@ extern void of_node_put(struct device_node *node); ...@@ -101,26 +102,36 @@ extern void of_node_put(struct device_node *node);
*/ */
/* Helper to read a big number; size is in cells (not bytes) */ /* Helper to read a big number; size is in cells (not bytes) */
static inline u64 of_read_number(const u32 *cell, int size) static inline u64 of_read_number(const __be32 *cell, int size)
{ {
u64 r = 0; u64 r = 0;
while (size--) while (size--)
r = (r << 32) | *(cell++); r = (r << 32) | be32_to_cpu(*(cell++));
return r; return r;
} }
/* Like of_read_number, but we want an unsigned long result */ /* Like of_read_number, but we want an unsigned long result */
#ifdef CONFIG_PPC32 static inline unsigned long of_read_ulong(const __be32 *cell, int size)
static inline unsigned long of_read_ulong(const u32 *cell, int size)
{ {
return cell[size-1]; /* toss away upper bits if unsigned long is smaller than u64 */
return of_read_number(cell, size);
} }
#else
#define of_read_ulong(cell, size) of_read_number(cell, size)
#endif
#include <asm/prom.h> #include <asm/prom.h>
/* Default #address and #size cells. Allow arch asm/prom.h to override */
#if !defined(OF_ROOT_NODE_ADDR_CELLS_DEFAULT)
#define OF_ROOT_NODE_ADDR_CELLS_DEFAULT 1
#define OF_ROOT_NODE_SIZE_CELLS_DEFAULT 1
#endif
/* Default string compare functions, Allow arch asm/prom.h to override */
#if !defined(of_compat_cmp)
#define of_compat_cmp(s1, s2, l) strncasecmp((s1), (s2), (l))
#define of_prop_cmp(s1, s2) strcmp((s1), (s2))
#define of_node_cmp(s1, s2) strcasecmp((s1), (s2))
#endif
/* 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 */
...@@ -187,4 +198,19 @@ extern int of_parse_phandles_with_args(struct device_node *np, ...@@ -187,4 +198,19 @@ extern int of_parse_phandles_with_args(struct device_node *np,
const char *list_name, const char *cells_name, int index, const char *list_name, const char *cells_name, int index,
struct device_node **out_node, const void **out_args); struct device_node **out_node, const void **out_args);
extern int of_machine_is_compatible(const char *compat);
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);
#if defined(CONFIG_OF_DYNAMIC)
/* For updating the device tree at runtime */
extern void of_attach_node(struct device_node *);
extern void of_detach_node(struct device_node *);
#endif
#endif /* CONFIG_OF */
#endif /* _LINUX_OF_H */ #endif /* _LINUX_OF_H */
...@@ -42,45 +42,62 @@ ...@@ -42,45 +42,62 @@
* ends when size is 0 * ends when size is 0
*/ */
struct boot_param_header { struct boot_param_header {
u32 magic; /* magic word OF_DT_HEADER */ __be32 magic; /* magic word OF_DT_HEADER */
u32 totalsize; /* total size of DT block */ __be32 totalsize; /* total size of DT block */
u32 off_dt_struct; /* offset to structure */ __be32 off_dt_struct; /* offset to structure */
u32 off_dt_strings; /* offset to strings */ __be32 off_dt_strings; /* offset to strings */
u32 off_mem_rsvmap; /* offset to memory reserve map */ __be32 off_mem_rsvmap; /* offset to memory reserve map */
u32 version; /* format version */ __be32 version; /* format version */
u32 last_comp_version; /* last compatible version */ __be32 last_comp_version; /* last compatible version */
/* version 2 fields below */ /* version 2 fields below */
u32 boot_cpuid_phys; /* Physical CPU id we're booting on */ __be32 boot_cpuid_phys; /* Physical CPU id we're booting on */
/* version 3 fields below */ /* version 3 fields below */
u32 dt_strings_size; /* size of the DT strings block */ __be32 dt_strings_size; /* size of the DT strings block */
/* version 17 fields below */ /* version 17 fields below */
u32 dt_struct_size; /* size of the DT structure block */ __be32 dt_struct_size; /* size of the DT structure block */
}; };
/* TBD: Temporary export of fdt globals - remove when code fully merged */
extern int __initdata dt_root_addr_cells;
extern int __initdata dt_root_size_cells;
extern struct boot_param_header *initial_boot_params;
/* For scanning the flat device-tree at boot time */ /* For scanning the flat device-tree at boot time */
extern int __init of_scan_flat_dt(int (*it)(unsigned long node, extern char *find_flat_dt_string(u32 offset);
const char *uname, int depth, extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
void *data), int depth, void *data),
void *data); void *data);
extern void __init *of_get_flat_dt_prop(unsigned long node, const char *name, extern void *of_get_flat_dt_prop(unsigned long node, const char *name,
unsigned long *size); unsigned long *size);
extern int __init of_flat_dt_is_compatible(unsigned long node, extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
const char *name); extern unsigned long of_get_flat_dt_root(void);
extern unsigned long __init of_get_flat_dt_root(void); extern void early_init_dt_scan_chosen_arch(unsigned long node);
extern int early_init_dt_scan_chosen(unsigned long node, const char *uname,
int depth, void *data);
extern void early_init_dt_check_for_initrd(unsigned long node);
extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
int depth, void *data);
extern void early_init_dt_add_memory_arch(u64 base, u64 size);
extern u64 early_init_dt_alloc_memory_arch(u64 size, u64 align);
extern u64 dt_mem_next_cell(int s, __be32 **cellp);
/*
* If BLK_DEV_INITRD, the fdt early init code will call this function,
* to be provided by the arch code. start and end are specified as
* physical addresses.
*/
#ifdef CONFIG_BLK_DEV_INITRD
extern void early_init_dt_setup_initrd_arch(unsigned long start,
unsigned long end);
#endif
/* Early flat tree scan hooks */
extern int early_init_dt_scan_root(unsigned long node, const char *uname,
int depth, void *data);
/* Other Prototypes */ /* Other Prototypes */
extern void finish_device_tree(void);
extern void unflatten_device_tree(void); extern void unflatten_device_tree(void);
extern void early_init_devtree(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 /* __ASSEMBLY__ */
#endif /* _LINUX_OF_FDT_H */ #endif /* _LINUX_OF_FDT_H */
...@@ -768,7 +768,7 @@ static int check_codec(struct aoa_codec *codec, ...@@ -768,7 +768,7 @@ static int check_codec(struct aoa_codec *codec,
"required property %s not present\n", propname); "required property %s not present\n", propname);
return -ENODEV; return -ENODEV;
} }
if (*ref != codec->node->linux_phandle) { if (*ref != codec->node->phandle) {
printk(KERN_INFO "snd-aoa-fabric-layout: " printk(KERN_INFO "snd-aoa-fabric-layout: "
"%s doesn't match!\n", propname); "%s doesn't match!\n", propname);
return -ENODEV; return -ENODEV;
......
...@@ -751,8 +751,8 @@ static void snd_pmac_awacs_suspend(struct snd_pmac *chip) ...@@ -751,8 +751,8 @@ static void snd_pmac_awacs_suspend(struct snd_pmac *chip)
static void snd_pmac_awacs_resume(struct snd_pmac *chip) static void snd_pmac_awacs_resume(struct snd_pmac *chip)
{ {
if (machine_is_compatible("PowerBook3,1") if (of_machine_is_compatible("PowerBook3,1")
|| machine_is_compatible("PowerBook3,2")) { || of_machine_is_compatible("PowerBook3,2")) {
msleep(100); msleep(100);
snd_pmac_awacs_write_reg(chip, 1, snd_pmac_awacs_write_reg(chip, 1,
chip->awacs_reg[1] & ~MASK_PAROUT); chip->awacs_reg[1] & ~MASK_PAROUT);
...@@ -780,16 +780,16 @@ static void snd_pmac_awacs_resume(struct snd_pmac *chip) ...@@ -780,16 +780,16 @@ static void snd_pmac_awacs_resume(struct snd_pmac *chip)
} }
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
#define IS_PM7500 (machine_is_compatible("AAPL,7500") \ #define IS_PM7500 (of_machine_is_compatible("AAPL,7500") \
|| machine_is_compatible("AAPL,8500") \ || of_machine_is_compatible("AAPL,8500") \
|| machine_is_compatible("AAPL,9500")) || of_machine_is_compatible("AAPL,9500"))
#define IS_PM5500 (machine_is_compatible("AAPL,e411")) #define IS_PM5500 (of_machine_is_compatible("AAPL,e411"))
#define IS_BEIGE (machine_is_compatible("AAPL,Gossamer")) #define IS_BEIGE (of_machine_is_compatible("AAPL,Gossamer"))
#define IS_IMAC1 (machine_is_compatible("PowerMac2,1")) #define IS_IMAC1 (of_machine_is_compatible("PowerMac2,1"))
#define IS_IMAC2 (machine_is_compatible("PowerMac2,2") \ #define IS_IMAC2 (of_machine_is_compatible("PowerMac2,2") \
|| machine_is_compatible("PowerMac4,1")) || of_machine_is_compatible("PowerMac4,1"))
#define IS_G4AGP (machine_is_compatible("PowerMac3,1")) #define IS_G4AGP (of_machine_is_compatible("PowerMac3,1"))
#define IS_LOMBARD (machine_is_compatible("PowerBook1,1")) #define IS_LOMBARD (of_machine_is_compatible("PowerBook1,1"))
static int imac1, imac2; static int imac1, imac2;
......
...@@ -582,7 +582,7 @@ static int snd_pmac_burgundy_detect_headphone(struct snd_pmac *chip) ...@@ -582,7 +582,7 @@ static int snd_pmac_burgundy_detect_headphone(struct snd_pmac *chip)
static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify) static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify)
{ {
if (chip->auto_mute) { if (chip->auto_mute) {
int imac = machine_is_compatible("iMac"); int imac = of_machine_is_compatible("iMac");
int reg, oreg; int reg, oreg;
reg = oreg = snd_pmac_burgundy_rcb(chip, reg = oreg = snd_pmac_burgundy_rcb(chip,
MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES); MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES);
...@@ -620,7 +620,7 @@ static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_noti ...@@ -620,7 +620,7 @@ static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_noti
*/ */
int __devinit snd_pmac_burgundy_init(struct snd_pmac *chip) int __devinit snd_pmac_burgundy_init(struct snd_pmac *chip)
{ {
int imac = machine_is_compatible("iMac"); int imac = of_machine_is_compatible("iMac");
int i, err; int i, err;
/* Checks to see the chip is alive and kicking */ /* Checks to see the chip is alive and kicking */
......
...@@ -922,11 +922,11 @@ static void __devinit detect_byte_swap(struct snd_pmac *chip) ...@@ -922,11 +922,11 @@ static void __devinit detect_byte_swap(struct snd_pmac *chip)
} }
/* it seems the Pismo & iBook can't byte-swap in hardware. */ /* it seems the Pismo & iBook can't byte-swap in hardware. */
if (machine_is_compatible("PowerBook3,1") || if (of_machine_is_compatible("PowerBook3,1") ||
machine_is_compatible("PowerBook2,1")) of_machine_is_compatible("PowerBook2,1"))
chip->can_byte_swap = 0 ; chip->can_byte_swap = 0 ;
if (machine_is_compatible("PowerBook2,1")) if (of_machine_is_compatible("PowerBook2,1"))
chip->can_duplex = 0; chip->can_duplex = 0;
} }
...@@ -959,11 +959,11 @@ static int __devinit snd_pmac_detect(struct snd_pmac *chip) ...@@ -959,11 +959,11 @@ static int __devinit snd_pmac_detect(struct snd_pmac *chip)
chip->control_mask = MASK_IEPC | MASK_IEE | 0x11; /* default */ chip->control_mask = MASK_IEPC | MASK_IEE | 0x11; /* default */
/* check machine type */ /* check machine type */
if (machine_is_compatible("AAPL,3400/2400") if (of_machine_is_compatible("AAPL,3400/2400")
|| machine_is_compatible("AAPL,3500")) || of_machine_is_compatible("AAPL,3500"))
chip->is_pbook_3400 = 1; chip->is_pbook_3400 = 1;
else if (machine_is_compatible("PowerBook1,1") else if (of_machine_is_compatible("PowerBook1,1")
|| machine_is_compatible("AAPL,PowerBook1998")) || of_machine_is_compatible("AAPL,PowerBook1998"))
chip->is_pbook_G3 = 1; chip->is_pbook_G3 = 1;
chip->node = of_find_node_by_name(NULL, "awacs"); chip->node = of_find_node_by_name(NULL, "awacs");
sound = of_node_get(chip->node); sound = of_node_get(chip->node);
...@@ -1033,8 +1033,8 @@ static int __devinit snd_pmac_detect(struct snd_pmac *chip) ...@@ -1033,8 +1033,8 @@ static int __devinit snd_pmac_detect(struct snd_pmac *chip)
} }
if (of_device_is_compatible(sound, "tumbler")) { if (of_device_is_compatible(sound, "tumbler")) {
chip->model = PMAC_TUMBLER; chip->model = PMAC_TUMBLER;
chip->can_capture = machine_is_compatible("PowerMac4,2") chip->can_capture = of_machine_is_compatible("PowerMac4,2")
|| machine_is_compatible("PowerBook4,1"); || of_machine_is_compatible("PowerBook4,1");
chip->can_duplex = 0; chip->can_duplex = 0;
// chip->can_byte_swap = 0; /* FIXME: check this */ // chip->can_byte_swap = 0; /* FIXME: check this */
chip->num_freqs = ARRAY_SIZE(tumbler_freqs); chip->num_freqs = ARRAY_SIZE(tumbler_freqs);
......
...@@ -55,7 +55,7 @@ static __init int efika_fabric_init(void) ...@@ -55,7 +55,7 @@ static __init int efika_fabric_init(void)
struct platform_device *pdev; struct platform_device *pdev;
int rc; int rc;
if (!machine_is_compatible("bplan,efika")) if (!of_machine_is_compatible("bplan,efika"))
return -ENODEV; return -ENODEV;
card.platform = &mpc5200_audio_dma_platform; card.platform = &mpc5200_audio_dma_platform;
......
...@@ -55,7 +55,7 @@ static __init int pcm030_fabric_init(void) ...@@ -55,7 +55,7 @@ static __init int pcm030_fabric_init(void)
struct platform_device *pdev; struct platform_device *pdev;
int rc; int rc;
if (!machine_is_compatible("phytec,pcm030")) if (!of_machine_is_compatible("phytec,pcm030"))
return -ENODEV; return -ENODEV;
card.platform = &mpc5200_audio_dma_platform; card.platform = &mpc5200_audio_dma_platform;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment