blob: d288af4cc080e8d0d5db3912658d967dc468fd7c [file] [log] [blame]
Kristofer Jonssonf5b98c92022-03-14 16:09:12 +01001/*
2 * Copyright (c) 2022 Arm Limited.
3 *
4 * This program is free software and is provided to you under the terms of the
5 * GNU General Public License version 2 as published by the Free Software
6 * Foundation, and any use by you of this program is subject to the terms
7 * of such GNU licence.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, you can access it online at
16 * http://www.gnu.org/licenses/gpl-2.0.html.
17 *
18 * SPDX-License-Identifier: GPL-2.0-only
19 */
20
21#ifndef ETHOSU_WATCHDOG_H
22#define ETHOSU_WATCHDOG_H
23
24/****************************************************************************
25 * Includes
26 ****************************************************************************/
27
28#include <linux/types.h>
29#include <linux/timer.h>
30#include <linux/workqueue.h>
31
32/****************************************************************************
33 * Types
34 ****************************************************************************/
35
36struct device;
37struct ethosu_watchdog;
38
39typedef void (*ethosu_watchdog_cb)(struct ethosu_watchdog *wdog);
40
41struct ethosu_watchdog {
42 struct device *dev;
43 ethosu_watchdog_cb callback;
44 struct timer_list timer;
45 struct work_struct work;
46 atomic_t refcount;
47};
48
49/****************************************************************************
50 * Functions
51 ****************************************************************************/
52
53/**
54 * ethosu_watchdog_init() - Initialize watchdog
55 *
56 * Return: 0 on success, else error code.
57 */
58int ethosu_watchdog_init(struct ethosu_watchdog *wdog,
59 struct device *dev,
60 ethosu_watchdog_cb callback);
61
62/**
63 * ethosu_watchdog_deinit() - Deinitialize watchdog
64 */
65void ethosu_watchdog_deinit(struct ethosu_watchdog *wdog);
66
67/**
68 * ethosu_watchdog_reset() - Reset watchdog
69 */
70int ethosu_watchdog_reset(struct ethosu_watchdog *wdog);
71
72/**
73 * ethosu_watchdog_inc() - Increment reference count
74 */
75void ethosu_watchdog_inc(struct ethosu_watchdog *wdog);
76
77/**
78 * ethosu_watchdog_dec() - Decrement reference count
79 */
80void ethosu_watchdog_dec(struct ethosu_watchdog *wdog);
81
82#endif /* ETHOSU_WATCHDOG_H */