xref: /openbmc/linux/arch/arm/mach-omap2/omap-hotplug.c (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
27d35b8d0SSantosh Shilimkar /*
37d35b8d0SSantosh Shilimkar  * OMAP4 SMP cpu-hotplug support
47d35b8d0SSantosh Shilimkar  *
57d35b8d0SSantosh Shilimkar  * Copyright (C) 2010 Texas Instruments, Inc.
67d35b8d0SSantosh Shilimkar  * Author:
77d35b8d0SSantosh Shilimkar  *      Santosh Shilimkar <santosh.shilimkar@ti.com>
87d35b8d0SSantosh Shilimkar  *
97d35b8d0SSantosh Shilimkar  * Platform file needed for the OMAP4 SMP. This file is based on arm
107d35b8d0SSantosh Shilimkar  * realview smp platform.
117d35b8d0SSantosh Shilimkar  * Copyright (c) 2002 ARM Limited.
127d35b8d0SSantosh Shilimkar  */
137d35b8d0SSantosh Shilimkar 
147d35b8d0SSantosh Shilimkar #include <linux/kernel.h>
157d35b8d0SSantosh Shilimkar #include <linux/errno.h>
167d35b8d0SSantosh Shilimkar #include <linux/smp.h>
17247c445cSSantosh Shilimkar #include <linux/io.h>
187d35b8d0SSantosh Shilimkar 
19732231a7STony Lindgren #include "omap-wakeupgen.h"
204e65331cSTony Lindgren #include "common.h"
21b5b4f288SSantosh Shilimkar #include "powerdomain.h"
22b5b4f288SSantosh Shilimkar 
237d35b8d0SSantosh Shilimkar /*
247d35b8d0SSantosh Shilimkar  * platform-specific code to shutdown a CPU
257d35b8d0SSantosh Shilimkar  * Called with IRQs disabled
267d35b8d0SSantosh Shilimkar  */
omap4_cpu_die(unsigned int cpu)27b96fc2f3SStephen Boyd void omap4_cpu_die(unsigned int cpu)
287d35b8d0SSantosh Shilimkar {
29247c445cSSantosh Shilimkar 	unsigned int boot_cpu = 0;
30247c445cSSantosh Shilimkar 	void __iomem *base = omap_get_wakeupgen_base();
31b5b4f288SSantosh Shilimkar 
327d35b8d0SSantosh Shilimkar 	/*
337d35b8d0SSantosh Shilimkar 	 * we're ready for shutdown now, so do it
347d35b8d0SSantosh Shilimkar 	 */
35247c445cSSantosh Shilimkar 	if (omap_secure_apis_support()) {
367d35b8d0SSantosh Shilimkar 		if (omap_modify_auxcoreboot0(0x0, 0x200) != 0x0)
37b5b4f288SSantosh Shilimkar 			pr_err("Secure clear status failed\n");
38247c445cSSantosh Shilimkar 	} else {
39edfaf05cSVictor Kamensky 		writel_relaxed(0, base + OMAP_AUX_CORE_BOOT_0);
40247c445cSSantosh Shilimkar 	}
41247c445cSSantosh Shilimkar 
427d35b8d0SSantosh Shilimkar 
437d35b8d0SSantosh Shilimkar 	for (;;) {
447d35b8d0SSantosh Shilimkar 		/*
45b5b4f288SSantosh Shilimkar 		 * Enter into low power state
467d35b8d0SSantosh Shilimkar 		 */
47b5b4f288SSantosh Shilimkar 		omap4_hotplug_cpu(cpu, PWRDM_POWER_OFF);
48247c445cSSantosh Shilimkar 
49247c445cSSantosh Shilimkar 		if (omap_secure_apis_support())
50351b7c49STony Lindgren 			boot_cpu = omap_read_auxcoreboot0() >> 9;
51247c445cSSantosh Shilimkar 		else
52247c445cSSantosh Shilimkar 			boot_cpu =
53edfaf05cSVictor Kamensky 				readl_relaxed(base + OMAP_AUX_CORE_BOOT_0) >> 5;
54247c445cSSantosh Shilimkar 
55247c445cSSantosh Shilimkar 		if (boot_cpu == smp_processor_id()) {
567d35b8d0SSantosh Shilimkar 			/*
577d35b8d0SSantosh Shilimkar 			 * OK, proper wakeup, we're done
587d35b8d0SSantosh Shilimkar 			 */
597d35b8d0SSantosh Shilimkar 			break;
607d35b8d0SSantosh Shilimkar 		}
617d35b8d0SSantosh Shilimkar 		pr_debug("CPU%u: spurious wakeup call\n", cpu);
627d35b8d0SSantosh Shilimkar 	}
637d35b8d0SSantosh Shilimkar }
643696203cSTony Lindgren 
653696203cSTony Lindgren /* Needed by kexec and platform_can_cpu_hotplug() */
omap4_cpu_kill(unsigned int cpu)663696203cSTony Lindgren int omap4_cpu_kill(unsigned int cpu)
673696203cSTony Lindgren {
683696203cSTony Lindgren 	return 1;
693696203cSTony Lindgren }
70