12874c5fdSThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-or-later */
22e1ae9c0SLiu Yu-B13201/*
32e1ae9c0SLiu Yu-B13201 * Copyright (C) 2012 Freescale Semiconductor, Inc.
42e1ae9c0SLiu Yu-B13201 */
52e1ae9c0SLiu Yu-B13201
62e1ae9c0SLiu Yu-B13201#include <linux/threads.h>
72f979de8SLiu Yu-B13201#include <asm/epapr_hcalls.h>
82e1ae9c0SLiu Yu-B13201#include <asm/reg.h>
92e1ae9c0SLiu Yu-B13201#include <asm/page.h>
102e1ae9c0SLiu Yu-B13201#include <asm/cputable.h>
112e1ae9c0SLiu Yu-B13201#include <asm/thread_info.h>
122e1ae9c0SLiu Yu-B13201#include <asm/ppc_asm.h>
132f979de8SLiu Yu-B13201#include <asm/asm-compat.h>
142e1ae9c0SLiu Yu-B13201#include <asm/asm-offsets.h>
159445aa1aSAl Viro#include <asm/export.h>
162e1ae9c0SLiu Yu-B13201
17f070986aSStuart Yoder#ifndef CONFIG_PPC64
182f979de8SLiu Yu-B13201/* epapr_ev_idle() was derived from e500_idle() */
192f979de8SLiu Yu-B13201_GLOBAL(epapr_ev_idle)
20f7354ccaSChristophe Leroy	PPC_LL	r4, TI_LOCAL_FLAGS(r2)	/* set napping bit */
212f979de8SLiu Yu-B13201	ori	r4, r4,_TLF_NAPPING	/* so when we take an exception */
22f7354ccaSChristophe Leroy	PPC_STL	r4, TI_LOCAL_FLAGS(r2)	/* it will return to our caller */
232f979de8SLiu Yu-B13201
242f979de8SLiu Yu-B13201	wrteei	1
252f979de8SLiu Yu-B13201
262f979de8SLiu Yu-B13201idle_loop:
272f979de8SLiu Yu-B13201	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
282f979de8SLiu Yu-B13201
292f979de8SLiu Yu-B13201.global epapr_ev_idle_start
302f979de8SLiu Yu-B13201epapr_ev_idle_start:
312f979de8SLiu Yu-B13201	li	r3, -1
322f979de8SLiu Yu-B13201	nop
332f979de8SLiu Yu-B13201	nop
342f979de8SLiu Yu-B13201	nop
352f979de8SLiu Yu-B13201
362f979de8SLiu Yu-B13201	/*
372f979de8SLiu Yu-B13201	 * Guard against spurious wakeups from a hypervisor --
382f979de8SLiu Yu-B13201	 * only interrupt will cause us to return to LR due to
392f979de8SLiu Yu-B13201	 * _TLF_NAPPING.
402f979de8SLiu Yu-B13201	 */
412f979de8SLiu Yu-B13201	b	idle_loop
42f070986aSStuart Yoder#endif
432f979de8SLiu Yu-B13201
442e1ae9c0SLiu Yu-B13201/* Hypercall entry point. Will be patched with device tree instructions. */
452e1ae9c0SLiu Yu-B13201.global epapr_hypercall_start
462e1ae9c0SLiu Yu-B13201epapr_hypercall_start:
472e1ae9c0SLiu Yu-B13201	li	r3, -1
482e1ae9c0SLiu Yu-B13201	nop
492e1ae9c0SLiu Yu-B13201	nop
502e1ae9c0SLiu Yu-B13201	nop
512e1ae9c0SLiu Yu-B13201	blr
529445aa1aSAl ViroEXPORT_SYMBOL(epapr_hypercall_start)
53