forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/arch/powerpc/platforms/powermac/setup.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Powermac setup and early boot code plus other random bits.
34 *
....@@ -11,12 +12,6 @@
1112 * Copyright (C) 1995 Linus Torvalds
1213 *
1314 * 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
- *
2015 */
2116
2217 /*
....@@ -56,7 +51,6 @@
5651 #include <asm/reg.h>
5752 #include <asm/sections.h>
5853 #include <asm/prom.h>
59
-#include <asm/pgtable.h>
6054 #include <asm/io.h>
6155 #include <asm/pci-bridge.h>
6256 #include <asm/ohare.h>
....@@ -243,10 +237,9 @@
243237 {
244238 /* Checks "l2cr-value" property in the registry */
245239 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) {
250243 const unsigned int *l2cr =
251244 of_get_property(np, "l2cr-value", NULL);
252245 if (l2cr) {
....@@ -256,6 +249,7 @@
256249 _set_L2CR(ppc_override_l2cr_value);
257250 }
258251 of_node_put(np);
252
+ break;
259253 }
260254 }
261255
....@@ -279,8 +273,8 @@
279273 /* Set loops_per_jiffy to a half-way reasonable value,
280274 for use until calibrate_delay gets called. */
281275 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) {
284278 fp = of_get_property(cpu, "clock-frequency", NULL);
285279 if (fp != NULL) {
286280 if (pvr >= 0x30 && pvr < 0x80)
....@@ -290,10 +284,11 @@
290284 /* 604, G3, G4 etc. */
291285 loops_per_jiffy = *fp / HZ;
292286 else
293
- /* 601, 603, etc. */
287
+ /* 603, etc. */
294288 loops_per_jiffy = *fp / (2 * HZ);
289
+ of_node_put(cpu);
290
+ break;
295291 }
296
- of_node_put(cpu);
297292 }
298293
299294 /* See if newworld or oldworld */
....@@ -315,8 +310,7 @@
315310 find_via_pmu();
316311 smu_init();
317312
318
-#if defined(CONFIG_NVRAM) || defined(CONFIG_NVRAM_MODULE) || \
319
- defined(CONFIG_PPC64)
313
+#if IS_ENABLED(CONFIG_NVRAM)
320314 pmac_nvram_init();
321315 #endif
322316 #ifdef CONFIG_PPC32
....@@ -559,15 +553,9 @@
559553 }
560554 pr_debug("stdout is %pOF\n", prom_stdout);
561555
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"))
569557 offset = 0;
570
- else if (strcmp(name, "ch-b") == 0)
558
+ else if (of_node_name_eq(prom_stdout, "ch-b"))
571559 offset = 1;
572560 else
573561 goto not_found;
....@@ -597,7 +585,6 @@
597585
598586 #ifdef CONFIG_PPC32
599587 /* isa_io_base gets set in pmac_pci_init */
600
- ISA_DMA_THRESHOLD = ~0L;
601588 DMA_MODE_READ = 1;
602589 DMA_MODE_WRITE = 2;
603590 #endif /* CONFIG_PPC32 */