blob: 7d8791aee24155093276c0e38e2fcb74158ad6d4 [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>
36#include <linux/workqueue.h>
Davide Grohmann35ce6c82021-06-01 15:03:51 +020037#include <linux/completion.h>
Kristofer Jonsson116a6352020-08-20 17:25:23 +020038
39/****************************************************************************
40 * Types
41 ****************************************************************************/
42
43/**
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;
54 struct list_head capabilities_list;
55 struct list_head inference_list;
56 struct list_head network_info_list;
Kristofer Jonsson116a6352020-08-20 17:25:23 +020057};
58
Davide Grohmann35ce6c82021-06-01 15:03:51 +020059/**
60 * struct ethosu_capabilities - Capabilities internal struct
61 */
62struct ethosu_capabilities {
63 struct ethosu_device *edev;
64 struct completion done;
65 struct kref refcount;
66 struct ethosu_uapi_device_capabilities *capabilities;
67 struct list_head list;
68};
69
Kristofer Jonsson116a6352020-08-20 17:25:23 +020070/****************************************************************************
71 * Functions
72 ****************************************************************************/
73
74/**
75 * ethosu_dev_init() - Initialize the device
76 *
77 * Return: 0 on success, else error code.
78 */
79int ethosu_dev_init(struct ethosu_device *edev,
80 struct device *dev,
81 struct class *class,
Kristofer Jonsson4aec3762021-10-13 17:09:27 +020082 dev_t devt,
Kristofer Jonsson116a6352020-08-20 17:25:23 +020083 struct resource *in_queue,
84 struct resource *out_queue);
85
86/**
87 * ethosu_dev_deinit() - Initialize the device
88 */
89void ethosu_dev_deinit(struct ethosu_device *edev);
90
91#endif /* ETHOSU_DEVICE_H */