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)
242f979de8SLiu Yu-B13201	CURRENT_THREAD_INFO(r3, r1)
252f979de8SLiu Yu-B13201	PPC_LL	r4, TI_LOCAL_FLAGS(r3)	/* set napping bit */
262f979de8SLiu Yu-B13201	ori	r4, r4,_TLF_NAPPING	/* so when we take an exception */
272f979de8SLiu Yu-B13201	PPC_STL	r4, TI_LOCAL_FLAGS(r3)	/* it will return to our caller */
282f979de8SLiu Yu-B13201
292f979de8SLiu Yu-B13201	wrteei	1
302f979de8SLiu Yu-B13201
312f979de8SLiu Yu-B13201idle_loop:
322f979de8SLiu Yu-B13201	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
332f979de8SLiu Yu-B13201
342f979de8SLiu Yu-B13201.global epapr_ev_idle_start
352f979de8SLiu Yu-B13201epapr_ev_idle_start:
362f979de8SLiu Yu-B13201	li	r3, -1
372f979de8SLiu Yu-B13201	nop
382f979de8SLiu Yu-B13201	nop
392f979de8SLiu Yu-B13201	nop
402f979de8SLiu Yu-B13201
412f979de8SLiu Yu-B13201	/*
422f979de8SLiu Yu-B13201	 * Guard against spurious wakeups from a hypervisor --
432f979de8SLiu Yu-B13201	 * only interrupt will cause us to return to LR due to
442f979de8SLiu Yu-B13201	 * _TLF_NAPPING.
452f979de8SLiu Yu-B13201	 */
462f979de8SLiu Yu-B13201	b	idle_loop
47f070986aSStuart Yoder#endif
482f979de8SLiu Yu-B13201
492e1ae9c0SLiu Yu-B13201/* Hypercall entry point. Will be patched with device tree instructions. */
502e1ae9c0SLiu Yu-B13201.global epapr_hypercall_start
512e1ae9c0SLiu Yu-B13201epapr_hypercall_start:
522e1ae9c0SLiu Yu-B13201	li	r3, -1
532e1ae9c0SLiu Yu-B13201	nop
542e1ae9c0SLiu Yu-B13201	nop
552e1ae9c0SLiu Yu-B13201	nop
562e1ae9c0SLiu Yu-B13201	blr
579445aa1aSAl ViroEXPORT_SYMBOL(epapr_hypercall_start)
58