blob: 3afdda84862d3e095dee50cac64d436734dafae5 [file] [log] [blame]
Kristofer Jonsson116a6352020-08-20 17:25:23 +02001/*
2 * (C) COPYRIGHT 2020 ARM Limited. All rights reserved.
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_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"
30
31#include <linux/device.h>
32#include <linux/cdev.h>
33#include <linux/io.h>
34#include <linux/mutex.h>
35#include <linux/workqueue.h>
Davide Grohmann35ce6c82021-06-01 15:03:51 +020036#include <linux/completion.h>
Kristofer Jonsson116a6352020-08-20 17:25:23 +020037
38/****************************************************************************
39 * Types
40 ****************************************************************************/
41
42/**
43 * struct ethosu_device - Device structure
44 */
45struct ethosu_device {
46 struct device *dev;
47 struct cdev cdev;
48 struct class *class;
49 dev_t devt;
50 struct mutex mutex;
51 struct ethosu_mailbox mailbox;
Davide Grohmann35ce6c82021-06-01 15:03:51 +020052 struct list_head capabilities_list;
Kristofer Jonsson116a6352020-08-20 17:25:23 +020053 struct list_head inference_list;
54};
55
Davide Grohmann35ce6c82021-06-01 15:03:51 +020056/**
57 * struct ethosu_capabilities - Capabilities internal struct
58 */
59struct ethosu_capabilities {
60 struct ethosu_device *edev;
61 struct completion done;
62 struct kref refcount;
63 struct ethosu_uapi_device_capabilities *capabilities;
64 struct list_head list;
65};
66
Kristofer Jonsson116a6352020-08-20 17:25:23 +020067/****************************************************************************
68 * Functions
69 ****************************************************************************/
70
71/**
72 * ethosu_dev_init() - Initialize the device
73 *
74 * Return: 0 on success, else error code.
75 */
76int ethosu_dev_init(struct ethosu_device *edev,
77 struct device *dev,
78 struct class *class,
Kristofer Jonsson4aec3762021-10-13 17:09:27 +020079 dev_t devt,
Kristofer Jonsson116a6352020-08-20 17:25:23 +020080 struct resource *in_queue,
81 struct resource *out_queue);
82
83/**
84 * ethosu_dev_deinit() - Initialize the device
85 */
86void ethosu_dev_deinit(struct ethosu_device *edev);
87
88#endif /* ETHOSU_DEVICE_H */