Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *  linux/arch/arm/mach-vexpress/platsmp.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *  Copyright (C) 2002 ARM Ltd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *  All Rights Reserved
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/of_address.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/vexpress.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/mcpm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/smp_scu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <asm/mach/map.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <plat/platsmp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) bool __init vexpress_smp_init_ops(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #ifdef CONFIG_MCPM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	int cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	struct device_node *cpu_node, *cci_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	 * The best way to detect a multi-cluster configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	 * is to detect if the kernel can take over CCI ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	 * control. Loop over possible CPUs and check if CCI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	 * port control is available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	 * Override the default vexpress_smp_ops if so.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	for_each_possible_cpu(cpu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		bool available;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		cpu_node = of_get_cpu_node(cpu, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		if (WARN(!cpu_node, "Missing cpu device node!"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 			return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		cci_node = of_parse_phandle(cpu_node, "cci-control-port", 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 		available = cci_node && of_device_is_available(cci_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		of_node_put(cci_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		of_node_put(cpu_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		if (!available)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 			return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	mcpm_smp_set_ops();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static const struct of_device_id vexpress_smp_dt_scu_match[] __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	{ .compatible = "arm,cortex-a5-scu", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	{ .compatible = "arm,cortex-a9-scu", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	{}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static void __init vexpress_smp_dt_prepare_cpus(unsigned int max_cpus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 	struct device_node *scu = of_find_matching_node(NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 			vexpress_smp_dt_scu_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 	if (scu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 		scu_enable(of_iomap(scu, 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	 * Write the address of secondary startup into the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	 * system-wide flags register. The boot monitor waits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 	 * until it receives a soft interrupt, and then the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 	 * secondary CPU branches to this address.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) 	vexpress_flags_set(__pa_symbol(versatile_secondary_startup));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #ifdef CONFIG_HOTPLUG_CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static void vexpress_cpu_die(unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 	versatile_immitation_cpu_die(cpu, 0x40);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) const struct smp_operations vexpress_smp_dt_ops __initconst = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) 	.smp_prepare_cpus	= vexpress_smp_dt_prepare_cpus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 	.smp_secondary_init	= versatile_secondary_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) 	.smp_boot_secondary	= versatile_boot_secondary,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #ifdef CONFIG_HOTPLUG_CPU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 	.cpu_die		= vexpress_cpu_die,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) };