12e1ae9c0SLiu Yu-B13201/*
22e1ae9c0SLiu Yu-B13201 * Copyright (C) 2012 Freescale Semiconductor, Inc.
32e1ae9c0SLiu Yu-B13201 *
42e1ae9c0SLiu Yu-B13201 * This program is free software; you can redistribute it and/or
52e1ae9c0SLiu Yu-B13201 * modify it under the terms of the GNU General Public License
62e1ae9c0SLiu Yu-B13201 * as published by the Free Software Foundation; either version
72e1ae9c0SLiu Yu-B13201 * 2 of the License, or (at your option) any later version.
82e1ae9c0SLiu Yu-B13201 */
92e1ae9c0SLiu Yu-B13201
102e1ae9c0SLiu Yu-B13201#include <linux/threads.h>
112f979de8SLiu Yu-B13201#include <asm/epapr_hcalls.h>
122e1ae9c0SLiu Yu-B13201#include <asm/reg.h>
132e1ae9c0SLiu Yu-B13201#include <asm/page.h>
142e1ae9c0SLiu Yu-B13201#include <asm/cputable.h>
152e1ae9c0SLiu Yu-B13201#include <asm/thread_info.h>
162e1ae9c0SLiu Yu-B13201#include <asm/ppc_asm.h>
172f979de8SLiu Yu-B13201#include <asm/asm-compat.h>
182e1ae9c0SLiu Yu-B13201#include <asm/asm-offsets.h>
199445aa1aSAl Viro#include <asm/export.h>
202e1ae9c0SLiu Yu-B13201
21f070986aSStuart Yoder#ifndef CONFIG_PPC64
222f979de8SLiu Yu-B13201/* epapr_ev_idle() was derived from e500_idle() */
232f979de8SLiu Yu-B13201_GLOBAL(epapr_ev_idle)
24f7354ccaSChristophe Leroy	PPC_LL	r4, TI_LOCAL_FLAGS(r2)	/* set napping bit */
252f979de8SLiu Yu-B13201	ori	r4, r4,_TLF_NAPPING	/* so when we take an exception */
26f7354ccaSChristophe Leroy	PPC_STL	r4, TI_LOCAL_FLAGS(r2)	/* it will return to our caller */
272f979de8SLiu Yu-B13201
282f979de8SLiu Yu-B13201	wrteei	1
292f979de8SLiu Yu-B13201
302f979de8SLiu Yu-B13201idle_loop:
312f979de8SLiu Yu-B13201	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
322f979de8SLiu Yu-B13201
332f979de8SLiu Yu-B13201.global epapr_ev_idle_start
342f979de8SLiu Yu-B13201epapr_ev_idle_start:
352f979de8SLiu Yu-B13201	li	r3, -1
362f979de8SLiu Yu-B13201	nop
372f979de8SLiu Yu-B13201	nop
382f979de8SLiu Yu-B13201	nop
392f979de8SLiu Yu-B13201
402f979de8SLiu Yu-B13201	/*
412f979de8SLiu Yu-B13201	 * Guard against spurious wakeups from a hypervisor --
422f979de8SLiu Yu-B13201	 * only interrupt will cause us to return to LR due to
432f979de8SLiu Yu-B13201	 * _TLF_NAPPING.
442f979de8SLiu Yu-B13201	 */
452f979de8SLiu Yu-B13201	b	idle_loop
46f070986aSStuart Yoder#endif
472f979de8SLiu Yu-B13201
482e1ae9c0SLiu Yu-B13201/* Hypercall entry point. Will be patched with device tree instructions. */
492e1ae9c0SLiu Yu-B13201.global epapr_hypercall_start
502e1ae9c0SLiu Yu-B13201epapr_hypercall_start:
512e1ae9c0SLiu Yu-B13201	li	r3, -1
522e1ae9c0SLiu Yu-B13201	nop
532e1ae9c0SLiu Yu-B13201	nop
542e1ae9c0SLiu Yu-B13201	nop
552e1ae9c0SLiu Yu-B13201	blr
569445aa1aSAl ViroEXPORT_SYMBOL(epapr_hypercall_start)
57