14898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song/*
24898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song * CPU hotplug support for CSR Marco dual-core SMP SoCs
34898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song *
44898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song * Copyright (c) 2012 Cambridge Silicon Radio Limited, a CSR plc group company.
54898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song *
64898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song * Licensed under GPLv2 or later.
74898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song */
84898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song
94898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song#include <linux/kernel.h>
104898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song#include <linux/errno.h>
114898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song#include <linux/smp.h>
124898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song
134898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song#include <asm/smp_plat.h>
144898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song
154898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Songstatic inline void platform_do_lowpower(unsigned int cpu)
164898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song{
174898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song	/* we put the platform to just WFI */
184898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song	for (;;) {
194898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song		__asm__ __volatile__("dsb\n\t" "wfi\n\t"
204898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song			: : : "memory");
214898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song		if (pen_release == cpu_logical_map(cpu)) {
224898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song			/*
234898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song			 * OK, proper wakeup, we're done
244898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song			 */
254898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song			break;
264898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song		}
274898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song	}
284898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song}
294898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song
304898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song/*
314898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song * platform-specific code to shutdown a CPU
324898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song *
334898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song * Called with IRQs disabled
344898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song */
35b0db321ba14daca748d5c8ca89298fdb637f9ba8Arnd Bergmannvoid __ref sirfsoc_cpu_die(unsigned int cpu)
364898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song{
374898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song	platform_do_lowpower(cpu);
384898de3d15d8ba34aa7a1b0f753a476d52ebdf92Barry Song}
39