blob: af14c850476df47874d7a925b2ace3c6bf8147fe [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 {
Mikael Olsson252ed6a2023-05-29 18:07:55 +020045 struct device dev;
46 struct rpmsg_device *rpdev;
47 struct rpmsg_endpoint *ept;
48 struct cdev cdev;
49 struct class *class;
50 struct ethosu_mailbox mailbox;
51 struct ethosu_uapi_device_capabilities capabilities;
Kristofer Jonsson116a6352020-08-20 17:25:23 +020052};
53
Kristofer Jonsson116a6352020-08-20 17:25:23 +020054/****************************************************************************
55 * Functions
56 ****************************************************************************/
57
58/**
59 * ethosu_dev_init() - Initialize the device
60 *
61 * Return: 0 on success, else error code.
62 */
Kristofer Jonssonec477042023-01-20 13:38:13 +010063int ethosu_dev_init(struct rpmsg_device *rpdev,
Kristofer Jonsson116a6352020-08-20 17:25:23 +020064 struct class *class,
Kristofer Jonssond779a082023-01-04 17:09:47 +010065 dev_t devt);
Kristofer Jonsson116a6352020-08-20 17:25:23 +020066
67/**
68 * ethosu_dev_deinit() - Initialize the device
69 */
Kristofer Jonssonec477042023-01-20 13:38:13 +010070void ethosu_dev_deinit(struct rpmsg_device *rpdev);
Kristofer Jonsson116a6352020-08-20 17:25:23 +020071
Kristofer Jonsson116a6352020-08-20 17:25:23 +020072#endif /* ETHOSU_DEVICE_H */