1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef _ASM_S390_DIAG288_H
4 #define _ASM_S390_DIAG288_H
5 
6 #include <asm/asm-extable.h>
7 #include <asm/types.h>
8 
9 #define MIN_INTERVAL 15	    /* Minimal time supported by diag288 */
10 #define MAX_INTERVAL 3600   /* One hour should be enough - pure estimation */
11 
12 #define WDT_DEFAULT_TIMEOUT 30
13 
14 /* Function codes - init, change, cancel */
15 #define WDT_FUNC_INIT 0
16 #define WDT_FUNC_CHANGE 1
17 #define WDT_FUNC_CANCEL 2
18 #define WDT_FUNC_CONCEAL 0x80000000
19 
20 /* Action codes for LPAR watchdog */
21 #define LPARWDT_RESTART 0
22 
23 static inline int __diag288(unsigned int func, unsigned int timeout,
24 			    unsigned long action, unsigned int len)
25 {
26 	union register_pair r1 = { .even = func, .odd = timeout, };
27 	union register_pair r3 = { .even = action, .odd = len, };
28 	int rc = -EINVAL;
29 
30 	asm volatile(
31 		"	diag	%[r1],%[r3],0x288\n"
32 		"0:	lhi	%[rc],0\n"
33 		"1:"
34 		EX_TABLE(0b, 1b)
35 		: [rc] "+d" (rc)
36 		: [r1] "d" (r1.pair), [r3] "d" (r3.pair)
37 		: "cc", "memory");
38 	return rc;
39 }
40 
41 #endif /* _ASM_S390_DIAG288_H */
42