1 /* 2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef _LINUX_WATCHDOG_H 17 #define _LINUX_WATCHDOG_H 18 19 #include <linux/types.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif /* __cplusplus */ 24 25 int watchdog_init(void); 26 void watchdog_exit(void); 27 28 #define WATCHDOG_IOCTL_BASE 'W' 29 30 struct watchdog_info { 31 unsigned int options; /* Options the card/driver supports */ 32 unsigned int firmware_version; /* Firmware version of the card */ 33 unsigned char identity[32]; /* 32 bit Identity of the board */ 34 }; 35 36 #define WDIOC_GETSUPPORT _IOR(WATCHDOG_IOCTL_BASE, 0, struct watchdog_info) 37 #define WDIOC_GETSTATUS _IOR(WATCHDOG_IOCTL_BASE, 1, int) 38 #define WDIOC_GETBOOTSTATUS _IOR(WATCHDOG_IOCTL_BASE, 2, int) 39 40 #define WDIOC_SETOPTIONS _IOWR(WATCHDOG_IOCTL_BASE, 4, int) 41 #define WDIOC_KEEPALIVE _IO(WATCHDOG_IOCTL_BASE, 5) 42 #define WDIOC_SETTIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 6, int) 43 #define WDIOC_GETTIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 7, int) 44 45 #define WDIOF_UNKNOWN (-1) /* Unknown flag error */ 46 #define WDIOS_UNKNOWN (-1) /* Unknown status error */ 47 48 #define WDIOF_OVERHEAT 0x0001 /* Reset due to CPU overheat */ 49 #define WDIOF_FANFAULT 0x0002 /* Fan failed */ 50 #define WDIOF_EXTERN1 0x0004 /* External relay 1 */ 51 #define WDIOF_EXTERN2 0x0008 /* External relay 2 */ 52 #define WDIOF_POWERUNDER 0x0010 /* Power bad/power fault */ 53 #define WDIOF_CARDRESET 0x0020 /* Card previously reset the CPU */ 54 #define WDIOF_POWEROVER 0x0040 /* Power over voltage */ 55 #define WDIOF_SETTIMEOUT 0x0080 /* Set timeout (in seconds) */ 56 #define WDIOF_MAGICCLOSE 0x0100 /* Supports magic close char */ 57 #define WDIOF_PRETIMEOUT 0x0200 /* Pretimeout (in seconds), get/set */ 58 #define WDIOF_KEEPALIVEPING 0x8000 /* Keep alive ping reply */ 59 60 #define WDIOS_DISABLECARD 0x0001 /* Turn off the watchdog timer */ 61 #define WDIOS_ENABLECARD 0x0002 /* Turn on the watchdog timer */ 62 #define WDIOS_TEMPPANIC 0x0004 /* Kernel panic on temperature trip */ 63 64 #ifdef __cplusplus 65 } 66 #endif /* __cplusplus */ 67 68 #endif 69