| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Powermac setup and early boot code plus other random bits. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 11 | 12 | * Copyright (C) 1995 Linus Torvalds |
|---|
| 12 | 13 | * |
|---|
| 13 | 14 | * Maintained by Benjamin Herrenschmidt (benh@kernel.crashing.org) |
|---|
| 14 | | - * |
|---|
| 15 | | - * This program is free software; you can redistribute it and/or |
|---|
| 16 | | - * modify it under the terms of the GNU General Public License |
|---|
| 17 | | - * as published by the Free Software Foundation; either version |
|---|
| 18 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 19 | | - * |
|---|
| 20 | 15 | */ |
|---|
| 21 | 16 | |
|---|
| 22 | 17 | /* |
|---|
| .. | .. |
|---|
| 56 | 51 | #include <asm/reg.h> |
|---|
| 57 | 52 | #include <asm/sections.h> |
|---|
| 58 | 53 | #include <asm/prom.h> |
|---|
| 59 | | -#include <asm/pgtable.h> |
|---|
| 60 | 54 | #include <asm/io.h> |
|---|
| 61 | 55 | #include <asm/pci-bridge.h> |
|---|
| 62 | 56 | #include <asm/ohare.h> |
|---|
| .. | .. |
|---|
| 243 | 237 | { |
|---|
| 244 | 238 | /* Checks "l2cr-value" property in the registry */ |
|---|
| 245 | 239 | if (cpu_has_feature(CPU_FTR_L2CR)) { |
|---|
| 246 | | - struct device_node *np = of_find_node_by_name(NULL, "cpus"); |
|---|
| 247 | | - if (!np) |
|---|
| 248 | | - np = of_find_node_by_type(NULL, "cpu"); |
|---|
| 249 | | - if (np) { |
|---|
| 240 | + struct device_node *np; |
|---|
| 241 | + |
|---|
| 242 | + for_each_of_cpu_node(np) { |
|---|
| 250 | 243 | const unsigned int *l2cr = |
|---|
| 251 | 244 | of_get_property(np, "l2cr-value", NULL); |
|---|
| 252 | 245 | if (l2cr) { |
|---|
| .. | .. |
|---|
| 256 | 249 | _set_L2CR(ppc_override_l2cr_value); |
|---|
| 257 | 250 | } |
|---|
| 258 | 251 | of_node_put(np); |
|---|
| 252 | + break; |
|---|
| 259 | 253 | } |
|---|
| 260 | 254 | } |
|---|
| 261 | 255 | |
|---|
| .. | .. |
|---|
| 279 | 273 | /* Set loops_per_jiffy to a half-way reasonable value, |
|---|
| 280 | 274 | for use until calibrate_delay gets called. */ |
|---|
| 281 | 275 | loops_per_jiffy = 50000000 / HZ; |
|---|
| 282 | | - cpu = of_find_node_by_type(NULL, "cpu"); |
|---|
| 283 | | - if (cpu != NULL) { |
|---|
| 276 | + |
|---|
| 277 | + for_each_of_cpu_node(cpu) { |
|---|
| 284 | 278 | fp = of_get_property(cpu, "clock-frequency", NULL); |
|---|
| 285 | 279 | if (fp != NULL) { |
|---|
| 286 | 280 | if (pvr >= 0x30 && pvr < 0x80) |
|---|
| .. | .. |
|---|
| 290 | 284 | /* 604, G3, G4 etc. */ |
|---|
| 291 | 285 | loops_per_jiffy = *fp / HZ; |
|---|
| 292 | 286 | else |
|---|
| 293 | | - /* 601, 603, etc. */ |
|---|
| 287 | + /* 603, etc. */ |
|---|
| 294 | 288 | loops_per_jiffy = *fp / (2 * HZ); |
|---|
| 289 | + of_node_put(cpu); |
|---|
| 290 | + break; |
|---|
| 295 | 291 | } |
|---|
| 296 | | - of_node_put(cpu); |
|---|
| 297 | 292 | } |
|---|
| 298 | 293 | |
|---|
| 299 | 294 | /* See if newworld or oldworld */ |
|---|
| .. | .. |
|---|
| 315 | 310 | find_via_pmu(); |
|---|
| 316 | 311 | smu_init(); |
|---|
| 317 | 312 | |
|---|
| 318 | | -#if defined(CONFIG_NVRAM) || defined(CONFIG_NVRAM_MODULE) || \ |
|---|
| 319 | | - defined(CONFIG_PPC64) |
|---|
| 313 | +#if IS_ENABLED(CONFIG_NVRAM) |
|---|
| 320 | 314 | pmac_nvram_init(); |
|---|
| 321 | 315 | #endif |
|---|
| 322 | 316 | #ifdef CONFIG_PPC32 |
|---|
| .. | .. |
|---|
| 559 | 553 | } |
|---|
| 560 | 554 | pr_debug("stdout is %pOF\n", prom_stdout); |
|---|
| 561 | 555 | |
|---|
| 562 | | - name = of_get_property(prom_stdout, "name", NULL); |
|---|
| 563 | | - if (!name) { |
|---|
| 564 | | - pr_debug(" stdout package has no name !\n"); |
|---|
| 565 | | - goto not_found; |
|---|
| 566 | | - } |
|---|
| 567 | | - |
|---|
| 568 | | - if (strcmp(name, "ch-a") == 0) |
|---|
| 556 | + if (of_node_name_eq(prom_stdout, "ch-a")) |
|---|
| 569 | 557 | offset = 0; |
|---|
| 570 | | - else if (strcmp(name, "ch-b") == 0) |
|---|
| 558 | + else if (of_node_name_eq(prom_stdout, "ch-b")) |
|---|
| 571 | 559 | offset = 1; |
|---|
| 572 | 560 | else |
|---|
| 573 | 561 | goto not_found; |
|---|
| .. | .. |
|---|
| 597 | 585 | |
|---|
| 598 | 586 | #ifdef CONFIG_PPC32 |
|---|
| 599 | 587 | /* isa_io_base gets set in pmac_pci_init */ |
|---|
| 600 | | - ISA_DMA_THRESHOLD = ~0L; |
|---|
| 601 | 588 | DMA_MODE_READ = 1; |
|---|
| 602 | 589 | DMA_MODE_WRITE = 2; |
|---|
| 603 | 590 | #endif /* CONFIG_PPC32 */ |
|---|