blob: 8e81f9136c7559b77ce05fdc4299c5925b2adbbe [file] [log] [blame]
Kristofer Jonsson116a6352020-08-20 17:25:23 +02001/*
Kristofer Jonssonb42bc0b2023-01-04 17:09:28 +01002 * Copyright 2020-2023 Arm Limited and/or its affiliates
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"
30
31#include <linux/device.h>
32#include <linux/cdev.h>
33#include <linux/io.h>
34#include <linux/mutex.h>
Kristofer Jonsson116a6352020-08-20 17:25:23 +020035
36/****************************************************************************
37 * Types
38 ****************************************************************************/
39
40/**
41 * struct ethosu_device - Device structure
42 */
43struct ethosu_device {
Kristofer Jonssonb42bc0b2023-01-04 17:09:28 +010044 struct device *dev;
45 struct cdev cdev;
46 struct class *class;
47 dev_t devt;
48 struct mutex mutex;
49 struct ethosu_mailbox mailbox;
Kristofer Jonsson116a6352020-08-20 17:25:23 +020050};
51
Kristofer Jonsson116a6352020-08-20 17:25:23 +020052/****************************************************************************
53 * Functions
54 ****************************************************************************/
55
56/**
57 * ethosu_dev_init() - Initialize the device
58 *
59 * Return: 0 on success, else error code.
60 */
61int ethosu_dev_init(struct ethosu_device *edev,
62 struct device *dev,
63 struct class *class,
Kristofer Jonsson4aec3762021-10-13 17:09:27 +020064 dev_t devt,
Kristofer Jonsson116a6352020-08-20 17:25:23 +020065 struct resource *in_queue,
66 struct resource *out_queue);
67
68/**
69 * ethosu_dev_deinit() - Initialize the device
70 */
71void ethosu_dev_deinit(struct ethosu_device *edev);
72
Kristofer Jonsson116a6352020-08-20 17:25:23 +020073#endif /* ETHOSU_DEVICE_H */