linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh KUMAR <viresh.kumar@st.com>
To: linux-arm-kernel@lists.infradead.org, rtc-linux@googlegroups.com,
	a.zummo@towertech.it, dbrownell@users.sourceforge.net,
	linux-usb@vger.kernel.org, linux-input@vger.kernel.org, dmitry
Cc: Deepak Sikri <deepak.sikri@st.com>,
	shiraz.hashim@st.com, vipin.kumar@st.com,
	armando.visconti@st.com, vipulkumar.samar@st.com,
	rajeev-dlh.kumar@st.com, pratyush.anand@st.com,
	bhupesh.sharma@st.com, Viresh Kumar <viresh.kumar@st.com>
Subject: [PATCH V2 47/69] ST SPEAr13xx: Adding CPU hotplug support added for SMP platforms
Date: Fri,  1 Oct 2010 17:26:07 +0530	[thread overview]
Message-ID: <af8b5622bfb525dd1bcb2f09bfabc70fe6012f8c.1285933332.git.viresh.kumar@st.com> (raw)
In-Reply-To: <cover.1285933331.git.viresh.kumar@st.com>
In-Reply-To: <cover.1285933331.git.viresh.kumar@st.com>

From: Deepak Sikri <deepak.sikri@st.com>

Signed-off-by: Deepak Sikri <deepak.sikri@st.com>
Signed-off-by: shiraz hashim <shiraz.hashim@st.com>
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
 arch/arm/mach-spear13xx/Makefile  |    1 +
 arch/arm/mach-spear13xx/hotplug.c |  135 +++++++++++++++++++++++++++++++++++++
 2 files changed, 136 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-spear13xx/hotplug.c

diff --git a/arch/arm/mach-spear13xx/Makefile b/arch/arm/mach-spear13xx/Makefile
index 799eefa..869afb4 100644
--- a/arch/arm/mach-spear13xx/Makefile
+++ b/arch/arm/mach-spear13xx/Makefile
@@ -5,6 +5,7 @@
 # common files
 obj-y					+= spear13xx.o clock.o fsmc-nor.o
 obj-$(CONFIG_SMP)			+= platsmp.o headsmp.o
+obj-$(CONFIG_HOTPLUG_CPU)		+= hotplug.o
 obj-$(CONFIG_LOCAL_TIMERS)		+= localtimer.o
 obj-$(CONFIG_PCIEPORTBUS)		+= pcie.o
 obj-$(CONFIG_PM)			+= pm.o sleep.o
diff --git a/arch/arm/mach-spear13xx/hotplug.c b/arch/arm/mach-spear13xx/hotplug.c
new file mode 100644
index 0000000..a3259bf
--- /dev/null
+++ b/arch/arm/mach-spear13xx/hotplug.c
@@ -0,0 +1,135 @@
+/*
+ * linux/arch/arm/mach-spear13xx/hotplug.c
+ *
+ * Copyright (C) 2010 ST Microelectronics Ltd.
+ * Deepak Sikri <deepak.sikri@st.com>
+ *
+ * based upon linux/arch/arm/mach-realview/hotplug.c
+ *
+ * Copyright (C) 2002 ARM Ltd.
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/smp.h>
+#include <linux/completion.h>
+#include <asm/cacheflush.h>
+#include <asm/system.h>
+
+extern volatile int pen_release;
+
+static DECLARE_COMPLETION(cpu_killed);
+
+static inline void cpu_enter_lowpower(void)
+{
+	unsigned int v;
+
+	flush_cache_all();
+	asm volatile(
+	"	mcr	p15, 0, %1, c7, c5, 0\n"
+	"	dsb\n"
+	/*
+	 * Turn off coherency
+	 */
+	"	mrc	p15, 0, %0, c1, c0, 1\n"
+	"	bic	%0, %0, #0x20\n"
+	"	mcr	p15, 0, %0, c1, c0, 1\n"
+	"	mrc	p15, 0, %0, c1, c0, 0\n"
+	"	bic	%0, %0, #0x04\n"
+	"	mcr	p15, 0, %0, c1, c0, 0\n"
+	  : "=&r" (v)
+	  : "r" (0)
+	  : "cc", "memory");
+}
+
+static inline void cpu_leave_lowpower(void)
+{
+	unsigned int v;
+
+	asm volatile("mrc	p15, 0, %0, c1, c0, 0\n"
+	"	orr	%0, %0, #0x04\n"
+	"	mcr	p15, 0, %0, c1, c0, 0\n"
+	"	mrc	p15, 0, %0, c1, c0, 1\n"
+	"	orr	%0, %0, #0x20\n"
+	"	mcr	p15, 0, %0, c1, c0, 1\n"
+	  : "=&r" (v)
+	  :
+	  : "cc");
+}
+
+static inline void platform_do_lowpower(unsigned int cpu)
+{
+	for (;;) {
+		wfi();
+
+		if (pen_release == cpu) {
+			/*
+			 * OK, proper wakeup, we're done
+			 */
+			break;
+		}
+
+		/*
+		 * getting here, means that we have come out of WFI without
+		 * having been woken up - this shouldn't happen
+		 *
+		 * The trouble is, letting people know about this is not really
+		 * possible, since we are currently running incoherently, and
+		 * therefore cannot safely call printk() or anything else
+		 */
+#ifdef DEBUG
+		pr_crit("CPU%u: spurious wakeup call\n", cpu);
+#endif
+	}
+}
+
+int platform_cpu_kill(unsigned int cpu)
+{
+	return wait_for_completion_timeout(&cpu_killed, 5000);
+}
+
+/*
+ * platform-specific code to shutdown a CPU
+ *
+ * Called with IRQs disabled
+ */
+void __cpuinit platform_cpu_die(unsigned int cpu)
+{
+#ifdef DEBUG
+	unsigned int this_cpu = hard_smp_processor_id();
+
+	if (cpu != this_cpu) {
+		pr_crit("Eek! platform_cpu_die running on %u, should\
+				be %u\n", this_cpu, cpu);
+		BUG();
+	}
+#endif
+
+	printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
+	complete(&cpu_killed);
+
+	/*
+	 * we're ready for shutdown now, so do it
+	 */
+	cpu_enter_lowpower();
+	platform_do_lowpower(cpu);
+
+	/*
+	 * bring this CPU back into the world of cache
+	 * coherency, and then restore interrupts
+	 */
+	cpu_leave_lowpower();
+}
+
+int platform_cpu_disable(unsigned int cpu)
+{
+	/*
+	 * we don't allow CPU 0 to be shutdown (it is still too special
+	 * e.g. clock tick interrupts)
+	 */
+	return cpu == 0 ? -EPERM : 0;
+}
-- 
1.7.2.2

  parent reply	other threads:[~2010-10-01 11:56 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1285933331.git.viresh.kumar@st.com>
2010-10-01 11:55 ` [PATCH V2 21/69] Keyboard: Adding support for spear-keyboard Viresh KUMAR
2010-10-05 15:47   ` Dmitry Torokhov
     [not found]     ` <20101005154737.GA19730-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2010-10-06  3:58       ` viresh kumar
     [not found]         ` <4CABF3E0.8010909-qxv4g6HH51o@public.gmane.org>
2010-10-06  6:16           ` Dmitry Torokhov
2010-10-06  7:11             ` viresh kumar
2010-11-10  6:44             ` viresh kumar
2010-10-01 11:55 ` [PATCH V2 22/69] ST SPEAr: Adding machine support for keyboard Viresh KUMAR
2010-10-01 11:55 ` [PATCH V2 25/69] ST SPEAr: Add smi driver for serial NOR flash Viresh KUMAR
2010-10-01 11:55 ` [PATCH V2 26/69] ST SPEAr: Adding support for serial nor flash in all spear platforms Viresh KUMAR
2010-10-01 11:55 ` [PATCH V2 27/69] ST SPEAr: Adding Watchdog support Viresh KUMAR
     [not found] ` <cover.1285933331.git.viresh.kumar-qxv4g6HH51o@public.gmane.org>
2010-10-01 11:55   ` [PATCH V2 23/69] ST SPEAr: Added ARM PL061 GPIO Support on SPEAr13xx and modified resource size Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 24/69] ST SPEAr: Adding support for ST's PWM IP Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 28/69] ST SPEAr: Adding machine support for nand Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 29/69] Newly erased page read workaround Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 30/69] ST SPEAr: Added PCIE host controller base driver support Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 31/69] ST SPEAr: Adding support for SSP PL022 Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 32/69] ST SPEAr: Adding support for SDHCI (SDIO) Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 33/69] ST SPEAr: Changing resource size of amba devices to SZ_4K Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 34/69] ST SPEAr: Replacing SIZE macro's with actual required size Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 35/69] SPEAr: defines base addresses as ulong Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 36/69] ST SPEAr: Adding miscellaneous devices Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 37/69] ST SPEAr 13xx : Adding support for SPEAr1310 Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 38/69] ST SPEAr: Adding support for DDR in clock framework Viresh KUMAR
2010-10-01 11:55   ` [PATCH V2 39/69] ST SPEAr : EMI (Extrenal Memory Interface) controller driver Viresh KUMAR
2010-10-01 11:56   ` [PATCH V2 40/69] ST SPEAr : FSMC (Flexible Static Memory Controller) NOR interface driver Viresh KUMAR
2010-10-01 11:56   ` [PATCH V2 41/69] SPEAr Clock Framework: Adding support for PLL frequency change Viresh KUMAR
2010-10-01 11:56   ` [PATCH V2 43/69] GIC: Added dummy handlers for Power Management Suspend Resume Viresh KUMAR
2010-10-01 11:56   ` [PATCH V2 48/69] ST SPEAr: replace readl, writel with __raw_readl, __raw_writel in uncompress.h Viresh KUMAR
2010-10-01 11:56   ` [PATCH V2 49/69] ST SPEAr13xx: add L2 cache support Viresh KUMAR
2010-10-01 11:56   ` [PATCH V2 51/69] SPEAr: Adding and Updating Clock definitions Viresh KUMAR
2010-10-01 11:56   ` [PATCH V2 54/69] SPEAr : Updating pad multiplexing support Viresh KUMAR
2010-10-01 11:56   ` [PATCH V2 67/69] ST SPEAr: Adding devices & clocks Viresh KUMAR
2010-10-01 11:56   ` [PATCH V2 69/69] ST SPEAr: Updating defconfigs Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 42/69] SPEAr Power Management: Added the support for Standby mode Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 44/69] SPEAr CPU freq: Adding support for CPU Freq framework Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 45/69] ST SPEAr: PCIE gadget suppport Viresh KUMAR
2010-10-19 21:47   ` Andrew Morton
2010-10-21 14:18     ` Pratyush ANAND
2010-10-21 17:25       ` Andrew Morton
2010-10-01 11:56 ` [PATCH V2 46/69] ST SPEAr13xx: Adding machine support for pci gadget Viresh KUMAR
2010-10-01 11:56 ` Viresh KUMAR [this message]
2010-10-01 11:56 ` [PATCH V2 50/69] ST SPEAr13xx: Modified static mappings Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 52/69] SPEAr : Pad multiplexing handling modified Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 53/69] SPEAr13xx : Fixed part devices in SPEAr13xx addded to the generic implementation Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 55/69] ST SPEAr3xx: Passing pmx devices address from machine *.c files Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 56/69] ST SPEAr Clock Framework: Updating for single image solution Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 57/69] SPEAr3xx: Make local structures static Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 58/69] SPEAR3xx: Rename register/irq defines to remove naming conflicts Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 59/69] SPEAr3xx: Rework pmx_dev code to remove conflicts Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 60/69] SPEAr3xx: Rework KConfig to allow all boards to be compiled in Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 61/69] SPEAr3xx: Replace defconfigs with single unified defconfig Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 62/69] ST SPEAr: Appending spear3** with global structures Viresh KUMAR
2010-10-01 16:21   ` viresh kumar
     [not found]     ` <AANLkTi=xNoG2T1Q2JqB7TH+O7AjW++UnSt1Q85VgPbzp-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2010-10-04  6:01       ` viresh kumar
2010-10-01 11:56 ` [PATCH V2 63/69] ST SPEAr3xx: Updating plgpio and emi source to make it compliant with single image strategy Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 64/69] SPEAr6xx: Rework Kconfig for single image solution Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 65/69] ST SPEAR6xx: renaming spear600_defconfig as spear6xx_defconfig Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 66/69] ST SPEAr13xx: Pass default padmux settings as parameter to spear13**_init routine Viresh KUMAR
2010-10-01 11:56 ` [PATCH V2 68/69] ST SPEAr: Adding information in Documentation/ and MAINTAINERS Viresh KUMAR

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=af8b5622bfb525dd1bcb2f09bfabc70fe6012f8c.1285933332.git.viresh.kumar@st.com \
    --to=viresh.kumar@st.com \
    --cc=a.zummo@towertech.it \
    --cc=armando.visconti@st.com \
    --cc=bhupesh.sharma@st.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=deepak.sikri@st.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=pratyush.anand@st.com \
    --cc=rajeev-dlh.kumar@st.com \
    --cc=rtc-linux@googlegroups.com \
    --cc=shiraz.hashim@st.com \
    --cc=vipin.kumar@st.com \
    --cc=vipulkumar.samar@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).