Commit 389d0a8a authored by Rob Herring's avatar Rob Herring

Merge branch 'dt/cpu-type-rework' into dt/next

parents da08d8cb 4c29e593
...@@ -87,14 +87,11 @@ void __init arm_dt_init_cpu_maps(void) ...@@ -87,14 +87,11 @@ void __init arm_dt_init_cpu_maps(void)
if (!cpus) if (!cpus)
return; return;
for_each_child_of_node(cpus, cpu) { for_each_of_cpu_node(cpu) {
const __be32 *cell; const __be32 *cell;
int prop_bytes; int prop_bytes;
u32 hwid; u32 hwid;
if (of_node_cmp(cpu->type, "cpu"))
continue;
pr_debug(" * %pOF...\n", cpu); pr_debug(" * %pOF...\n", cpu);
/* /*
* A device tree containing CPU nodes with missing "reg" * A device tree containing CPU nodes with missing "reg"
......
...@@ -94,12 +94,6 @@ static void __init parse_dt_topology(void) ...@@ -94,12 +94,6 @@ static void __init parse_dt_topology(void)
__cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity), __cpu_capacity = kcalloc(nr_cpu_ids, sizeof(*__cpu_capacity),
GFP_NOWAIT); GFP_NOWAIT);
cn = of_find_node_by_path("/cpus");
if (!cn) {
pr_err("No CPU information found in DT\n");
return;
}
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
const u32 *rate; const u32 *rate;
int len; int len;
......
...@@ -50,7 +50,7 @@ void __init rcar_gen2_pm_init(void) ...@@ -50,7 +50,7 @@ void __init rcar_gen2_pm_init(void)
void __iomem *p; void __iomem *p;
u32 bar; u32 bar;
static int once; static int once;
struct device_node *np, *cpus; struct device_node *np;
bool has_a7 = false; bool has_a7 = false;
bool has_a15 = false; bool has_a15 = false;
struct resource res; struct resource res;
...@@ -59,11 +59,7 @@ void __init rcar_gen2_pm_init(void) ...@@ -59,11 +59,7 @@ void __init rcar_gen2_pm_init(void)
if (once++) if (once++)
return; return;
cpus = of_find_node_by_path("/cpus"); for_each_of_cpu_node(np) {
if (!cpus)
return;
for_each_child_of_node(cpus, np) {
if (of_device_is_compatible(np, "arm,cortex-a15")) if (of_device_is_compatible(np, "arm,cortex-a15"))
has_a15 = true; has_a15 = true;
else if (of_device_is_compatible(np, "arm,cortex-a7")) else if (of_device_is_compatible(np, "arm,cortex-a7"))
......
...@@ -202,7 +202,7 @@ static void __init get_special_pds(void) ...@@ -202,7 +202,7 @@ static void __init get_special_pds(void)
const struct of_device_id *id; const struct of_device_id *id;
/* PM domains containing CPUs */ /* PM domains containing CPUs */
for_each_node_by_type(np, "cpu") for_each_of_cpu_node(np)
add_special_pd(np, PD_CPU); add_special_pd(np, PD_CPU);
/* PM domain containing console */ /* PM domain containing console */
......
...@@ -22,22 +22,16 @@ ...@@ -22,22 +22,16 @@
void __init shmobile_init_delay(void) void __init shmobile_init_delay(void)
{ {
struct device_node *np, *cpus; struct device_node *np;
u32 max_freq = 0; u32 max_freq = 0;
cpus = of_find_node_by_path("/cpus"); for_each_of_cpu_node(np) {
if (!cpus)
return;
for_each_child_of_node(cpus, np) {
u32 freq; u32 freq;
if (!of_property_read_u32(np, "clock-frequency", &freq)) if (!of_property_read_u32(np, "clock-frequency", &freq))
max_freq = max(max_freq, freq); max_freq = max(max_freq, freq);
} }
of_node_put(cpus);
if (!max_freq) if (!max_freq)
return; return;
......
...@@ -602,7 +602,7 @@ static void __init of_parse_and_init_cpus(void) ...@@ -602,7 +602,7 @@ static void __init of_parse_and_init_cpus(void)
{ {
struct device_node *dn; struct device_node *dn;
for_each_node_by_type(dn, "cpu") { for_each_of_cpu_node(dn) {
u64 hwid = of_get_cpu_mpidr(dn); u64 hwid = of_get_cpu_mpidr(dn);
if (hwid == INVALID_HWID) if (hwid == INVALID_HWID)
......
...@@ -96,7 +96,7 @@ static void __init get_cpuinfo(void) ...@@ -96,7 +96,7 @@ static void __init get_cpuinfo(void)
unsigned long core_khz; unsigned long core_khz;
u64 tmp; u64 tmp;
struct cpuinfo_c6x *p; struct cpuinfo_c6x *p;
struct device_node *node, *np; struct device_node *node;
p = &per_cpu(cpu_data, smp_processor_id()); p = &per_cpu(cpu_data, smp_processor_id());
...@@ -190,13 +190,8 @@ static void __init get_cpuinfo(void) ...@@ -190,13 +190,8 @@ static void __init get_cpuinfo(void)
p->core_id = get_coreid(); p->core_id = get_coreid();
node = of_find_node_by_name(NULL, "cpus"); for_each_of_cpu_node(node)
if (node) { ++c6x_num_cores;
for_each_child_of_node(node, np)
if (!strcmp("cpu", np->name))
++c6x_num_cores;
of_node_put(node);
}
node = of_find_node_by_name(NULL, "soc"); node = of_find_node_by_name(NULL, "soc");
if (node) { if (node) {
......
...@@ -89,9 +89,9 @@ static struct device_node *cpu; ...@@ -89,9 +89,9 @@ static struct device_node *cpu;
void __init setup_cpuinfo(void) void __init setup_cpuinfo(void)
{ {
cpu = (struct device_node *) of_find_node_by_type(NULL, "cpu"); cpu = of_get_cpu_node(0, NULL);
if (!cpu) if (!cpu)
pr_err("You don't have cpu!!!\n"); pr_err("You don't have cpu or are missing cpu reg property!!!\n");
pr_info("%s: initialising\n", __func__); pr_info("%s: initialising\n", __func__);
...@@ -117,6 +117,8 @@ void __init setup_cpuinfo(void) ...@@ -117,6 +117,8 @@ void __init setup_cpuinfo(void)
if (cpuinfo.mmu_privins) if (cpuinfo.mmu_privins)
pr_warn("%s: Stream instructions enabled" pr_warn("%s: Stream instructions enabled"
" - USERSPACE CAN LOCK THIS KERNEL!\n", __func__); " - USERSPACE CAN LOCK THIS KERNEL!\n", __func__);
of_node_put(cpu);
} }
void __init setup_cpuinfo_clk(void) void __init setup_cpuinfo_clk(void)
......
...@@ -47,7 +47,7 @@ void __init setup_cpuinfo(void) ...@@ -47,7 +47,7 @@ void __init setup_cpuinfo(void)
const char *str; const char *str;
int len; int len;
cpu = of_find_node_by_type(NULL, "cpu"); cpu = of_get_cpu_node(0, NULL);
if (!cpu) if (!cpu)
panic("%s: No CPU found in devicetree!\n", __func__); panic("%s: No CPU found in devicetree!\n", __func__);
...@@ -120,6 +120,8 @@ void __init setup_cpuinfo(void) ...@@ -120,6 +120,8 @@ void __init setup_cpuinfo(void)
cpuinfo.reset_addr = fcpu(cpu, "altr,reset-addr"); cpuinfo.reset_addr = fcpu(cpu, "altr,reset-addr");
cpuinfo.exception_addr = fcpu(cpu, "altr,exception-addr"); cpuinfo.exception_addr = fcpu(cpu, "altr,exception-addr");
cpuinfo.fast_tlb_miss_exc_addr = fcpu(cpu, "altr,fast-tlb-miss-addr"); cpuinfo.fast_tlb_miss_exc_addr = fcpu(cpu, "altr,fast-tlb-miss-addr");
of_node_put(cpu);
} }
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
......
...@@ -158,9 +158,8 @@ static struct device_node *setup_find_cpu_node(int cpu) ...@@ -158,9 +158,8 @@ static struct device_node *setup_find_cpu_node(int cpu)
{ {
u32 hwid; u32 hwid;
struct device_node *cpun; struct device_node *cpun;
struct device_node *cpus = of_find_node_by_path("/cpus");
for_each_available_child_of_node(cpus, cpun) { for_each_of_cpu_node(cpun) {
if (of_property_read_u32(cpun, "reg", &hwid)) if (of_property_read_u32(cpun, "reg", &hwid))
continue; continue;
if (hwid == cpu) if (hwid == cpu)
......
...@@ -200,7 +200,7 @@ void ppc4xx_reset_system(char *cmd) ...@@ -200,7 +200,7 @@ void ppc4xx_reset_system(char *cmd)
u32 reset_type = DBCR0_RST_SYSTEM; u32 reset_type = DBCR0_RST_SYSTEM;
const u32 *prop; const u32 *prop;
np = of_find_node_by_type(NULL, "cpu"); np = of_get_cpu_node(0, NULL);
if (np) { if (np) {
prop = of_get_property(np, "reset-type", NULL); prop = of_get_property(np, "reset-type", NULL);
......
...@@ -66,7 +66,7 @@ static int __init get_freq(char *name, unsigned long *val) ...@@ -66,7 +66,7 @@ static int __init get_freq(char *name, unsigned long *val)
int found = 0; int found = 0;
/* The cpu node should have timebase and clock frequency properties */ /* The cpu node should have timebase and clock frequency properties */
cpu = of_find_node_by_type(NULL, "cpu"); cpu = of_get_cpu_node(0, NULL);
if (cpu) { if (cpu) {
fp = of_get_property(cpu, name, NULL); fp = of_get_property(cpu, name, NULL);
...@@ -147,8 +147,9 @@ void __init mpc8xx_calibrate_decr(void) ...@@ -147,8 +147,9 @@ void __init mpc8xx_calibrate_decr(void)
* we have to enable the timebase). The decrementer interrupt * we have to enable the timebase). The decrementer interrupt
* is wired into the vector table, nothing to do here for that. * is wired into the vector table, nothing to do here for that.
*/ */
cpu = of_find_node_by_type(NULL, "cpu"); cpu = of_get_cpu_node(0, NULL);
virq= irq_of_parse_and_map(cpu, 0); virq= irq_of_parse_and_map(cpu, 0);
of_node_put(cpu);
irq = virq_to_hw(virq); irq = virq_to_hw(virq);
sys_tmr2 = immr_map(im_sit); sys_tmr2 = immr_map(im_sit);
......
...@@ -1049,7 +1049,6 @@ core99_reset_cpu(struct device_node *node, long param, long value) ...@@ -1049,7 +1049,6 @@ core99_reset_cpu(struct device_node *node, long param, long value)
unsigned long flags; unsigned long flags;
struct macio_chip *macio; struct macio_chip *macio;
struct device_node *np; struct device_node *np;
struct device_node *cpus;
const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0, const int dflt_reset_lines[] = { KL_GPIO_RESET_CPU0,
KL_GPIO_RESET_CPU1, KL_GPIO_RESET_CPU1,
KL_GPIO_RESET_CPU2, KL_GPIO_RESET_CPU2,
...@@ -1059,10 +1058,7 @@ core99_reset_cpu(struct device_node *node, long param, long value) ...@@ -1059,10 +1058,7 @@ core99_reset_cpu(struct device_node *node, long param, long value)
if (macio->type != macio_keylargo) if (macio->type != macio_keylargo)
return -ENODEV; return -ENODEV;
cpus = of_find_node_by_path("/cpus"); for_each_of_cpu_node(np) {
if (cpus == NULL)
return -ENODEV;
for (np = cpus->child; np != NULL; np = np->sibling) {
const u32 *num = of_get_property(np, "reg", NULL); const u32 *num = of_get_property(np, "reg", NULL);
const u32 *rst = of_get_property(np, "soft-reset", NULL); const u32 *rst = of_get_property(np, "soft-reset", NULL);
if (num == NULL || rst == NULL) if (num == NULL || rst == NULL)
...@@ -1072,7 +1068,6 @@ core99_reset_cpu(struct device_node *node, long param, long value) ...@@ -1072,7 +1068,6 @@ core99_reset_cpu(struct device_node *node, long param, long value)
break; break;
} }
} }
of_node_put(cpus);
if (np == NULL || reset_io == 0) if (np == NULL || reset_io == 0)
reset_io = dflt_reset_lines[param]; reset_io = dflt_reset_lines[param];
...@@ -1504,16 +1499,12 @@ static long g5_reset_cpu(struct device_node *node, long param, long value) ...@@ -1504,16 +1499,12 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
unsigned long flags; unsigned long flags;
struct macio_chip *macio; struct macio_chip *macio;
struct device_node *np; struct device_node *np;
struct device_node *cpus;
macio = &macio_chips[0]; macio = &macio_chips[0];
if (macio->type != macio_keylargo2 && macio->type != macio_shasta) if (macio->type != macio_keylargo2 && macio->type != macio_shasta)
return -ENODEV; return -ENODEV;
cpus = of_find_node_by_path("/cpus"); for_each_of_cpu_node(np) {
if (cpus == NULL)
return -ENODEV;
for (np = cpus->child; np != NULL; np = np->sibling) {
const u32 *num = of_get_property(np, "reg", NULL); const u32 *num = of_get_property(np, "reg", NULL);
const u32 *rst = of_get_property(np, "soft-reset", NULL); const u32 *rst = of_get_property(np, "soft-reset", NULL);
if (num == NULL || rst == NULL) if (num == NULL || rst == NULL)
...@@ -1523,7 +1514,6 @@ static long g5_reset_cpu(struct device_node *node, long param, long value) ...@@ -1523,7 +1514,6 @@ static long g5_reset_cpu(struct device_node *node, long param, long value)
break; break;
} }
} }
of_node_put(cpus);
if (np == NULL || reset_io == 0) if (np == NULL || reset_io == 0)
return -ENODEV; return -ENODEV;
...@@ -2515,31 +2505,26 @@ static int __init probe_motherboard(void) ...@@ -2515,31 +2505,26 @@ static int __init probe_motherboard(void)
* supposed to be set when not supported, but I'm not very confident * supposed to be set when not supported, but I'm not very confident
* that all Apple OF revs did it properly, I do it the paranoid way. * that all Apple OF revs did it properly, I do it the paranoid way.
*/ */
while (uninorth_base && uninorth_rev > 3) { if (uninorth_base && uninorth_rev > 3) {
struct device_node *cpus = of_find_node_by_path("/cpus");
struct device_node *np; struct device_node *np;
if (!cpus || !cpus->child) { for_each_of_cpu_node(np) {
printk(KERN_WARNING "Can't find CPU(s) in device tree !\n"); int cpu_count = 1;
of_node_put(cpus);
break; /* Nap mode not supported on SMP */
} if (of_get_property(np, "flush-on-lock", NULL) ||
np = cpus->child; (cpu_count > 1)) {
/* Nap mode not supported on SMP */ powersave_nap = 0;
if (np->sibling) { of_node_put(np);
of_node_put(cpus); break;
break; }
}
/* Nap mode not supported if flush-on-lock property is present */ cpu_count++;
if (of_get_property(np, "flush-on-lock", NULL)) { powersave_nap = 1;
of_node_put(cpus);
break;
} }
of_node_put(cpus);
powersave_nap = 1;
printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n");
break;
} }
if (powersave_nap)
printk(KERN_DEBUG "Processor NAP mode on idle enabled.\n");
/* On CPUs that support it (750FX), lowspeed by default during /* On CPUs that support it (750FX), lowspeed by default during
* NAP mode * NAP mode
......
...@@ -243,10 +243,9 @@ static void __init l2cr_init(void) ...@@ -243,10 +243,9 @@ static void __init l2cr_init(void)
{ {
/* Checks "l2cr-value" property in the registry */ /* Checks "l2cr-value" property in the registry */
if (cpu_has_feature(CPU_FTR_L2CR)) { if (cpu_has_feature(CPU_FTR_L2CR)) {
struct device_node *np = of_find_node_by_name(NULL, "cpus"); struct device_node *np;
if (!np)
np = of_find_node_by_type(NULL, "cpu"); for_each_of_cpu_node(np) {
if (np) {
const unsigned int *l2cr = const unsigned int *l2cr =
of_get_property(np, "l2cr-value", NULL); of_get_property(np, "l2cr-value", NULL);
if (l2cr) { if (l2cr) {
...@@ -256,6 +255,7 @@ static void __init l2cr_init(void) ...@@ -256,6 +255,7 @@ static void __init l2cr_init(void)
_set_L2CR(ppc_override_l2cr_value); _set_L2CR(ppc_override_l2cr_value);
} }
of_node_put(np); of_node_put(np);
break;
} }
} }
...@@ -279,8 +279,8 @@ static void __init pmac_setup_arch(void) ...@@ -279,8 +279,8 @@ static void __init pmac_setup_arch(void)
/* Set loops_per_jiffy to a half-way reasonable value, /* Set loops_per_jiffy to a half-way reasonable value,
for use until calibrate_delay gets called. */ for use until calibrate_delay gets called. */
loops_per_jiffy = 50000000 / HZ; loops_per_jiffy = 50000000 / HZ;
cpu = of_find_node_by_type(NULL, "cpu");
if (cpu != NULL) { for_each_of_cpu_node(cpu) {
fp = of_get_property(cpu, "clock-frequency", NULL); fp = of_get_property(cpu, "clock-frequency", NULL);
if (fp != NULL) { if (fp != NULL) {
if (pvr >= 0x30 && pvr < 0x80) if (pvr >= 0x30 && pvr < 0x80)
...@@ -292,8 +292,9 @@ static void __init pmac_setup_arch(void) ...@@ -292,8 +292,9 @@ static void __init pmac_setup_arch(void)
else else
/* 601, 603, etc. */ /* 601, 603, etc. */
loops_per_jiffy = *fp / (2 * HZ); loops_per_jiffy = *fp / (2 * HZ);
of_node_put(cpu);
break;
} }
of_node_put(cpu);
} }
/* See if newworld or oldworld */ /* See if newworld or oldworld */
......
...@@ -64,7 +64,7 @@ static void sh_of_smp_probe(void) ...@@ -64,7 +64,7 @@ static void sh_of_smp_probe(void)
init_cpu_possible(cpumask_of(0)); init_cpu_possible(cpumask_of(0));
for_each_node_by_type(np, "cpu") { for_each_of_cpu_node(np) {
const __be32 *cell = of_get_property(np, "reg", NULL); const __be32 *cell = of_get_property(np, "reg", NULL);
u64 id = -1; u64 id = -1;
if (cell) id = of_read_number(cell, of_n_addr_cells(np)); if (cell) id = of_read_number(cell, of_n_addr_cells(np));
......
...@@ -140,7 +140,7 @@ static void __init dtb_cpu_setup(void) ...@@ -140,7 +140,7 @@ static void __init dtb_cpu_setup(void)
int ret; int ret;
version = GET_APIC_VERSION(apic_read(APIC_LVR)); version = GET_APIC_VERSION(apic_read(APIC_LVR));
for_each_node_by_type(dn, "cpu") { for_each_of_cpu_node(dn) {
ret = of_property_read_u32(dn, "reg", &apic_id); ret = of_property_read_u32(dn, "reg", &apic_id);
if (ret < 0) { if (ret < 0) {
pr_warn("%pOF: missing local APIC ID\n", dn); pr_warn("%pOF: missing local APIC ID\n", dn);
......
...@@ -183,7 +183,7 @@ static void __init of_cpu_clk_setup(struct device_node *node) ...@@ -183,7 +183,7 @@ static void __init of_cpu_clk_setup(struct device_node *node)
pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n", pr_warn("%s: pmu-dfs base register not set, dynamic frequency scaling not available\n",
__func__); __func__);
for_each_node_by_type(dn, "cpu") for_each_of_cpu_node(dn)
ncpus++; ncpus++;
cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL); cpuclk = kcalloc(ncpus, sizeof(*cpuclk), GFP_KERNEL);
...@@ -194,7 +194,7 @@ static void __init of_cpu_clk_setup(struct device_node *node) ...@@ -194,7 +194,7 @@ static void __init of_cpu_clk_setup(struct device_node *node)
if (WARN_ON(!clks)) if (WARN_ON(!clks))
goto clks_out; goto clks_out;
for_each_node_by_type(dn, "cpu") { for_each_of_cpu_node(dn) {
struct clk_init_data init; struct clk_init_data init;
struct clk *clk; struct clk *clk;
char *clk_name = kzalloc(5, GFP_KERNEL); char *clk_name = kzalloc(5, GFP_KERNEL);
......
...@@ -593,8 +593,7 @@ static void cpc925_mc_check(struct mem_ctl_info *mci) ...@@ -593,8 +593,7 @@ static void cpc925_mc_check(struct mem_ctl_info *mci)
/******************** CPU err device********************************/ /******************** CPU err device********************************/
static u32 cpc925_cpu_mask_disabled(void) static u32 cpc925_cpu_mask_disabled(void)
{ {
struct device_node *cpus; struct device_node *cpunode;
struct device_node *cpunode = NULL;
static u32 mask = 0; static u32 mask = 0;
/* use cached value if available */ /* use cached value if available */
...@@ -603,20 +602,8 @@ static u32 cpc925_cpu_mask_disabled(void) ...@@ -603,20 +602,8 @@ static u32 cpc925_cpu_mask_disabled(void)
mask = APIMASK_ADI0 | APIMASK_ADI1; mask = APIMASK_ADI0 | APIMASK_ADI1;
cpus = of_find_node_by_path("/cpus"); for_each_of_cpu_node(cpunode) {
if (cpus == NULL) {
cpc925_printk(KERN_DEBUG, "No /cpus node !\n");
return 0;
}
while ((cpunode = of_get_next_child(cpus, cpunode)) != NULL) {
const u32 *reg = of_get_property(cpunode, "reg", NULL); const u32 *reg = of_get_property(cpunode, "reg", NULL);
if (strcmp(cpunode->type, "cpu")) {
cpc925_printk(KERN_ERR, "Not a cpu node in /cpus: %s\n", cpunode->name);
continue;
}
if (reg == NULL || *reg > 2) { if (reg == NULL || *reg > 2) {
cpc925_printk(KERN_ERR, "Bad reg value at %pOF\n", cpunode); cpc925_printk(KERN_ERR, "Bad reg value at %pOF\n", cpunode);
continue; continue;
...@@ -633,9 +620,6 @@ static u32 cpc925_cpu_mask_disabled(void) ...@@ -633,9 +620,6 @@ static u32 cpc925_cpu_mask_disabled(void)
"Assuming PI id is equal to CPU MPIC id!\n"); "Assuming PI id is equal to CPU MPIC id!\n");
} }
of_node_put(cpunode);
of_node_put(cpus);
return mask; return mask;
} }
......
...@@ -543,7 +543,7 @@ u32 get_stash_id(u32 stash_dest_hint, u32 vcpu) ...@@ -543,7 +543,7 @@ u32 get_stash_id(u32 stash_dest_hint, u32 vcpu)
return ~(u32)0; return ~(u32)0;
} }
for_each_node_by_type(node, "cpu") { for_each_of_cpu_node(node) {
prop = of_get_property(node, "reg", &len); prop = of_get_property(node, "reg", &len);
for (i = 0; i < len / sizeof(u32); i++) { for (i = 0; i < len / sizeof(u32); i++) {
if (be32_to_cpup(&prop[i]) == vcpu) { if (be32_to_cpup(&prop[i]) == vcpu) {
......
...@@ -330,6 +330,8 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun, ...@@ -330,6 +330,8 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun,
ac = of_n_addr_cells(cpun); ac = of_n_addr_cells(cpun);
cell = of_get_property(cpun, prop_name, &prop_len); cell = of_get_property(cpun, prop_name, &prop_len);
if (!cell && !ac && arch_match_cpu_phys_id(cpu, 0))
return true;
if (!cell || !ac) if (!cell || !ac)
return false; return false;
prop_len /= sizeof(*cell) * ac; prop_len /= sizeof(*cell) * ac;
...@@ -390,7 +392,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) ...@@ -390,7 +392,7 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
{ {
struct device_node *cpun; struct device_node *cpun;
for_each_node_by_type(cpun, "cpu") { for_each_of_cpu_node(cpun) {
if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread)) if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread))
return cpun; return cpun;
} }
...@@ -744,6 +746,45 @@ struct device_node *of_get_next_available_child(const struct device_node *node, ...@@ -744,6 +746,45 @@ struct device_node *of_get_next_available_child(const struct device_node *node,
} }
EXPORT_SYMBOL(of_get_next_available_child); EXPORT_SYMBOL(of_get_next_available_child);
/**
* of_get_next_cpu_node - Iterate on cpu nodes
* @prev: previous child of the /cpus node, or NULL to get first
*
* Returns a cpu node pointer with refcount incremented, use of_node_put()
* on it when done. Returns NULL when prev is the last child. Decrements
* the refcount of prev.
*/
struct device_node *of_get_next_cpu_node(struct device_node *prev)
{
struct device_node *next = NULL;
unsigned long flags;
struct device_node *node;
if (!prev)
node = of_find_node_by_path("/cpus");
raw_spin_lock_irqsave(&devtree_lock, flags);
if (prev)
next = prev->sibling;
else if (node) {
next = node->child;
of_node_put(node);
}
for (; next; next = next->sibling) {
if (!(of_node_name_eq(next, "cpu") ||
(next->type && !of_node_cmp(next->type, "cpu"))))
continue;
if (!__of_device_is_available(next))
continue;
if (of_node_get(next))
break;
}
of_node_put(prev);
raw_spin_unlock_irqrestore(&devtree_lock, flags);
return next;
}
EXPORT_SYMBOL(of_get_next_cpu_node);
/** /**
* of_get_compatible_child - Find compatible child node * of_get_compatible_child - Find compatible child node
* @parent: parent node * @parent: parent node
......
...@@ -24,18 +24,9 @@ static void __init of_numa_parse_cpu_nodes(void) ...@@ -24,18 +24,9 @@ static void __init of_numa_parse_cpu_nodes(void)
{ {
u32 nid; u32 nid;
int r; int r;
struct device_node *cpus; struct device_node *np;
struct device_node *np = NULL;
cpus = of_find_node_by_path("/cpus");
if (!cpus)
return;
for_each_child_of_node(cpus, np) {
/* Skip things that are not CPUs */
if (of_node_cmp(np->type, "cpu") != 0)
continue;
for_each_of_cpu_node(np) {
r = of_property_read_u32(np, "numa-node-id", &nid); r = of_property_read_u32(np, "numa-node-id", &nid);
if (r) if (r)
continue; continue;
...@@ -46,8 +37,6 @@ static void __init of_numa_parse_cpu_nodes(void) ...@@ -46,8 +37,6 @@ static void __init of_numa_parse_cpu_nodes(void)
else else
node_set(nid, numa_nodes_parsed); node_set(nid, numa_nodes_parsed);
} }
of_node_put(cpus);
} }
static int __init of_numa_parse_memory_nodes(void) static int __init of_numa_parse_memory_nodes(void)
......
...@@ -1925,7 +1925,7 @@ static int __init fsl_diu_init(void) ...@@ -1925,7 +1925,7 @@ static int __init fsl_diu_init(void)
pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n"); pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n");
#ifdef CONFIG_NOT_COHERENT_CACHE #ifdef CONFIG_NOT_COHERENT_CACHE
np = of_find_node_by_type(NULL, "cpu"); np = of_get_cpu_node(0, NULL);
if (!np) { if (!np) {
pr_err("fsl-diu-fb: can't find 'cpu' device node\n"); pr_err("fsl-diu-fb: can't find 'cpu' device node\n");
return -ENODEV; return -ENODEV;
......
...@@ -347,6 +347,8 @@ extern const void *of_get_property(const struct device_node *node, ...@@ -347,6 +347,8 @@ extern const void *of_get_property(const struct device_node *node,
const char *name, const char *name,
int *lenp); int *lenp);
extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread); extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
extern struct device_node *of_get_next_cpu_node(struct device_node *prev);
#define for_each_property_of_node(dn, pp) \ #define for_each_property_of_node(dn, pp) \
for (pp = dn->properties; pp != NULL; pp = pp->next) for (pp = dn->properties; pp != NULL; pp = pp->next)
...@@ -748,6 +750,11 @@ static inline struct device_node *of_get_cpu_node(int cpu, ...@@ -748,6 +750,11 @@ static inline struct device_node *of_get_cpu_node(int cpu,
return NULL; return NULL;
} }
static inline struct device_node *of_get_next_cpu_node(struct device_node *prev)
{
return NULL;
}
static inline int of_n_addr_cells(struct device_node *np) static inline int of_n_addr_cells(struct device_node *np)
{ {
return 0; return 0;
...@@ -1211,6 +1218,10 @@ static inline int of_property_read_s32(const struct device_node *np, ...@@ -1211,6 +1218,10 @@ static inline int of_property_read_s32(const struct device_node *np,
for (child = of_get_next_available_child(parent, NULL); child != NULL; \ for (child = of_get_next_available_child(parent, NULL); child != NULL; \
child = of_get_next_available_child(parent, child)) child = of_get_next_available_child(parent, child))
#define for_each_of_cpu_node(cpu) \
for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \
cpu = of_get_next_cpu_node(cpu))
#define for_each_node_with_property(dn, prop_name) \ #define for_each_node_with_property(dn, prop_name) \
for (dn = of_find_node_with_property(NULL, prop_name); dn; \ for (dn = of_find_node_with_property(NULL, prop_name); dn; \
dn = of_find_node_with_property(dn, prop_name)) dn = of_find_node_with_property(dn, prop_name))
......
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