blob: d1e43345dabb250ca63a5599c3113a38d68280ca [file] [log] [blame]
Kristofer Jonsson116a6352020-08-20 17:25:23 +02001/*
Kristofer Jonsson35de9e62022-03-08 13:25:45 +01002 * Copyright (c) 2020-2022 Arm Limited.
Kristofer Jonsson116a6352020-08-20 17:25:23 +02003 *
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_DEVICE_H
22#define ETHOSU_DEVICE_H
23
24/****************************************************************************
25 * Includes
26 ****************************************************************************/
27
Davide Grohmann35ce6c82021-06-01 15:03:51 +020028#include "uapi/ethosu.h"
Kristofer Jonsson116a6352020-08-20 17:25:23 +020029#include "ethosu_mailbox.h"
Kristofer Jonssonf5b98c92022-03-14 16:09:12 +010030#include "ethosu_watchdog.h"
Kristofer Jonsson116a6352020-08-20 17:25:23 +020031
32#include <linux/device.h>
33#include <linux/cdev.h>
34#include <linux/io.h>
35#include <linux/mutex.h>
Kristofer Jonsson116a6352020-08-20 17:25:23 +020036
37/****************************************************************************
38 * Types
39 ****************************************************************************/
40
Kristofer Jonsson442fefb2022-03-17 17:15:52 +010041struct reset_control;
42
Kristofer Jonsson116a6352020-08-20 17:25:23 +020043/**
44 * struct ethosu_device - Device structure
45 */
46struct ethosu_device {
Kristofer Jonssonf5b98c92022-03-14 16:09:12 +010047 struct device *dev;
48 struct cdev cdev;
49 struct class *class;
50 dev_t devt;
51 struct mutex mutex;
52 struct ethosu_mailbox mailbox;
53 struct ethosu_watchdog watchdog;
Kristofer Jonsson442fefb2022-03-17 17:15:52 +010054 struct reset_control *reset;
Kristofer Jonsson116a6352020-08-20 17:25:23 +020055};
56
Kristofer Jonsson116a6352020-08-20 17:25:23 +020057/****************************************************************************
58 * Functions
59 ****************************************************************************/
60
61/**
62 * ethosu_dev_init() - Initialize the device
63 *
64 * Return: 0 on success, else error code.
65 */
66int ethosu_dev_init(struct ethosu_device *edev,
67 struct device *dev,
68 struct class *class,
Kristofer Jonsson4aec3762021-10-13 17:09:27 +020069 dev_t devt,
Kristofer Jonsson116a6352020-08-20 17:25:23 +020070 struct resource *in_queue,
71 struct resource *out_queue);
72
73/**
74 * ethosu_dev_deinit() - Initialize the device
75 */
76void ethosu_dev_deinit(struct ethosu_device *edev);
77
Davide Grohmann8b1fe552022-04-07 16:58:32 +020078/**
79 * ethosu_firmware_reset() - Reset the device running firmware
80 */
81int ethosu_firmware_reset(struct ethosu_device *edev);
82
Kristofer Jonsson116a6352020-08-20 17:25:23 +020083#endif /* ETHOSU_DEVICE_H */