blob: cc4271d3afc326a4a1009b59345cef920bbb5a94 [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 Jonssond779a082023-01-04 17:09:47 +010035#include <linux/rpmsg.h>
Kristofer Jonsson116a6352020-08-20 17:25:23 +020036
37/****************************************************************************
38 * Types
39 ****************************************************************************/
40
41/**
42 * struct ethosu_device - Device structure
43 */
44struct ethosu_device {
Kristofer Jonssonb42bc0b2023-01-04 17:09:28 +010045 struct device *dev;
Kristofer Jonssond779a082023-01-04 17:09:47 +010046 struct rpmsg_device *rpdev;
47 struct rpmsg_endpoint *ept;
Kristofer Jonssonb42bc0b2023-01-04 17:09:28 +010048 struct cdev cdev;
49 struct class *class;
50 dev_t devt;
51 struct mutex mutex;
52 struct ethosu_mailbox mailbox;
Kristofer Jonsson116a6352020-08-20 17:25:23 +020053};
54
Kristofer Jonsson116a6352020-08-20 17:25:23 +020055/****************************************************************************
56 * Functions
57 ****************************************************************************/
58
59/**
60 * ethosu_dev_init() - Initialize the device
61 *
62 * Return: 0 on success, else error code.
63 */
64int ethosu_dev_init(struct ethosu_device *edev,
Kristofer Jonssond779a082023-01-04 17:09:47 +010065 struct rpmsg_device *rpdev,
Kristofer Jonsson116a6352020-08-20 17:25:23 +020066 struct class *class,
Kristofer Jonssond779a082023-01-04 17:09:47 +010067 dev_t devt);
Kristofer Jonsson116a6352020-08-20 17:25:23 +020068
69/**
70 * ethosu_dev_deinit() - Initialize the device
71 */
72void ethosu_dev_deinit(struct ethosu_device *edev);
73
Kristofer Jonsson116a6352020-08-20 17:25:23 +020074#endif /* ETHOSU_DEVICE_H */