blob: 414083b427df7a4abff4ed98c2ae11e3a715f0a4 [file] [log] [blame]
Santosh Shilimkar7d35b8d2010-08-02 13:18:19 +03001/*
2 * OMAP4 SMP cpu-hotplug support
3 *
4 * Copyright (C) 2010 Texas Instruments, Inc.
5 * Author:
6 * Santosh Shilimkar <santosh.shilimkar@ti.com>
7 *
8 * Platform file needed for the OMAP4 SMP. This file is based on arm
9 * realview smp platform.
10 * Copyright (c) 2002 ARM Limited.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/kernel.h>
18#include <linux/errno.h>
19#include <linux/smp.h>
Santosh Shilimkar247c4452012-05-09 20:38:35 +053020#include <linux/io.h>
Santosh Shilimkar7d35b8d2010-08-02 13:18:19 +030021
22#include <asm/cacheflush.h>
Santosh Shilimkar247c4452012-05-09 20:38:35 +053023#include <mach/omap-wakeupgen.h>
Tony Lindgren4e653312011-11-10 22:45:17 +010024
25#include "common.h"
Santosh Shilimkar7d35b8d2010-08-02 13:18:19 +030026
Santosh Shilimkarb5b4f282010-06-16 22:19:48 +053027#include "powerdomain.h"
28
Santosh Shilimkar7d35b8d2010-08-02 13:18:19 +030029int platform_cpu_kill(unsigned int cpu)
30{
Russell King3c030be2010-11-30 11:07:35 +000031 return 1;
Santosh Shilimkar7d35b8d2010-08-02 13:18:19 +030032}
33
34/*
35 * platform-specific code to shutdown a CPU
36 * Called with IRQs disabled
37 */
Santosh Shilimkar82dfcbf2012-02-22 16:10:04 +053038void __ref platform_cpu_die(unsigned int cpu)
Santosh Shilimkar7d35b8d2010-08-02 13:18:19 +030039{
Santosh Shilimkar247c4452012-05-09 20:38:35 +053040 unsigned int boot_cpu = 0;
41 void __iomem *base = omap_get_wakeupgen_base();
Santosh Shilimkarb5b4f282010-06-16 22:19:48 +053042
Santosh Shilimkar7d35b8d2010-08-02 13:18:19 +030043 flush_cache_all();
44 dsb();
45
46 /*
47 * we're ready for shutdown now, so do it
48 */
Santosh Shilimkar247c4452012-05-09 20:38:35 +053049 if (omap_secure_apis_support()) {
50 if (omap_modify_auxcoreboot0(0x0, 0x200) != 0x0)
51 pr_err("Secure clear status failed\n");
52 } else {
53 __raw_writel(0, base + OMAP_AUX_CORE_BOOT_0);
54 }
55
Santosh Shilimkar7d35b8d2010-08-02 13:18:19 +030056
57 for (;;) {
58 /*
Santosh Shilimkarb5b4f282010-06-16 22:19:48 +053059 * Enter into low power state
Santosh Shilimkar7d35b8d2010-08-02 13:18:19 +030060 */
Santosh Shilimkarb5b4f282010-06-16 22:19:48 +053061 omap4_hotplug_cpu(cpu, PWRDM_POWER_OFF);
Santosh Shilimkar247c4452012-05-09 20:38:35 +053062
63 if (omap_secure_apis_support())
64 boot_cpu = omap_read_auxcoreboot0();
65 else
66 boot_cpu =
67 __raw_readl(base + OMAP_AUX_CORE_BOOT_0) >> 5;
68
69 if (boot_cpu == smp_processor_id()) {
Santosh Shilimkar7d35b8d2010-08-02 13:18:19 +030070 /*
71 * OK, proper wakeup, we're done
72 */
73 break;
74 }
75 pr_debug("CPU%u: spurious wakeup call\n", cpu);
76 }
77}
78
79int platform_cpu_disable(unsigned int cpu)
80{
81 /*
82 * we don't allow CPU 0 to be shutdown (it is still too special
83 * e.g. clock tick interrupts)
84 */
85 return cpu == 0 ? -EPERM : 0;
86}