xref: /linux/arch/powerpc/platforms/85xx/p2020.c (revision 24168c5e6dfbdd5b414f048f47f75d64533296ca)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Freescale P2020 board Setup
4  *
5  * Copyright 2007,2009,2012-2013 Freescale Semiconductor Inc.
6  * Copyright 2022-2023 Pali Rohár <pali@kernel.org>
7  */
8 
9 #include <linux/stddef.h>
10 #include <linux/kernel.h>
11 #include <linux/of.h>
12 
13 #include <asm/machdep.h>
14 #include <asm/udbg.h>
15 #include <asm/mpic.h>
16 #include <asm/swiotlb.h>
17 #include <asm/ppc-pci.h>
18 
19 #include <sysdev/fsl_pci.h>
20 
21 #include "smp.h"
22 #include "mpc85xx.h"
23 
24 static void __init p2020_pic_init(void)
25 {
26 	struct mpic *mpic;
27 	int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU;
28 
29 	mpic = mpic_alloc(NULL, 0, flags, 0, 256, " OpenPIC  ");
30 
31 	if (WARN_ON(!mpic))
32 		return;
33 
34 	mpic_init(mpic);
35 	mpc85xx_8259_init();
36 }
37 
38 /*
39  * Setup the architecture
40  */
41 static void __init p2020_setup_arch(void)
42 {
43 	swiotlb_detect_4g();
44 	fsl_pci_assign_primary();
45 	uli_init();
46 	mpc85xx_smp_init();
47 	mpc85xx_qe_par_io_init();
48 }
49 
50 /*
51  * Called very early, device-tree isn't unflattened
52  */
53 static int __init p2020_probe(void)
54 {
55 	struct device_node *p2020_cpu;
56 
57 	/*
58 	 * There is no common compatible string for all P2020 boards.
59 	 * The only common thing is "PowerPC,P2020@0" cpu node.
60 	 * So check for P2020 board via this cpu node.
61 	 */
62 	p2020_cpu = of_find_node_by_path("/cpus/PowerPC,P2020@0");
63 	of_node_put(p2020_cpu);
64 
65 	return !!p2020_cpu;
66 }
67 
68 machine_arch_initcall(p2020, mpc85xx_common_publish_devices);
69 
70 define_machine(p2020) {
71 	.name			= "Freescale P2020",
72 	.probe			= p2020_probe,
73 	.setup_arch		= p2020_setup_arch,
74 	.init_IRQ		= p2020_pic_init,
75 #ifdef CONFIG_PCI
76 	.pcibios_fixup_bus	= fsl_pcibios_fixup_bus,
77 	.pcibios_fixup_phb	= fsl_pcibios_fixup_phb,
78 #endif
79 	.get_irq		= mpic_get_irq,
80 	.progress		= udbg_progress,
81 };
82