blob: bcf973da96573c1788a47943f8fc9bc3fe09d5fc [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 Jonsson074ef902023-01-23 13:05:36 +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;
Jonny Svärd29e4ddb2023-03-24 15:58:09 +010049 struct class *class;
Kristofer Jonssonb42bc0b2023-01-04 17:09:28 +010050 struct ethosu_mailbox mailbox;
Kristofer Jonsson116a6352020-08-20 17:25:23 +020051};
52
Kristofer Jonsson116a6352020-08-20 17:25:23 +020053/****************************************************************************
54 * Functions
55 ****************************************************************************/
56
57/**
58 * ethosu_dev_init() - Initialize the device
59 *
60 * Return: 0 on success, else error code.
61 */
Kristofer Jonssonec477042023-01-20 13:38:13 +010062int ethosu_dev_init(struct rpmsg_device *rpdev,
Kristofer Jonsson116a6352020-08-20 17:25:23 +020063 struct class *class,
Kristofer Jonssond779a082023-01-04 17:09:47 +010064 dev_t devt);
Kristofer Jonsson116a6352020-08-20 17:25:23 +020065
66/**
67 * ethosu_dev_deinit() - Initialize the device
68 */
Kristofer Jonssonec477042023-01-20 13:38:13 +010069void ethosu_dev_deinit(struct rpmsg_device *rpdev);
Kristofer Jonsson116a6352020-08-20 17:25:23 +020070
Kristofer Jonsson116a6352020-08-20 17:25:23 +020071#endif /* ETHOSU_DEVICE_H */