Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 1 | /* |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 2 | * Copyright (c) 2020-2022 Arm Limited. |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 3 | * |
| 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 Grohmann | 35ce6c8 | 2021-06-01 15:03:51 +0200 | [diff] [blame] | 28 | #include "uapi/ethosu.h" |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 29 | #include "ethosu_mailbox.h" |
Kristofer Jonsson | f5b98c9 | 2022-03-14 16:09:12 +0100 | [diff] [blame] | 30 | #include "ethosu_watchdog.h" |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 31 | |
| 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 Grohmann | 35ce6c8 | 2021-06-01 15:03:51 +0200 | [diff] [blame] | 37 | #include <linux/completion.h> |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 38 | |
| 39 | /**************************************************************************** |
| 40 | * Types |
| 41 | ****************************************************************************/ |
| 42 | |
Kristofer Jonsson | 442fefb | 2022-03-17 17:15:52 +0100 | [diff] [blame] | 43 | struct reset_control; |
| 44 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 45 | /** |
| 46 | * struct ethosu_device - Device structure |
| 47 | */ |
| 48 | struct ethosu_device { |
Kristofer Jonsson | f5b98c9 | 2022-03-14 16:09:12 +0100 | [diff] [blame] | 49 | struct device *dev; |
| 50 | struct cdev cdev; |
| 51 | struct class *class; |
| 52 | dev_t devt; |
| 53 | struct mutex mutex; |
| 54 | struct ethosu_mailbox mailbox; |
| 55 | struct ethosu_watchdog watchdog; |
Kristofer Jonsson | 442fefb | 2022-03-17 17:15:52 +0100 | [diff] [blame] | 56 | struct reset_control *reset; |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 57 | }; |
| 58 | |
Davide Grohmann | 35ce6c8 | 2021-06-01 15:03:51 +0200 | [diff] [blame] | 59 | /** |
| 60 | * struct ethosu_capabilities - Capabilities internal struct |
| 61 | */ |
| 62 | struct ethosu_capabilities { |
| 63 | struct ethosu_device *edev; |
| 64 | struct completion done; |
| 65 | struct kref refcount; |
| 66 | struct ethosu_uapi_device_capabilities *capabilities; |
Kristofer Jonsson | 442fefb | 2022-03-17 17:15:52 +0100 | [diff] [blame] | 67 | struct ethosu_mailbox_msg msg; |
| 68 | int errno; |
Davide Grohmann | 35ce6c8 | 2021-06-01 15:03:51 +0200 | [diff] [blame] | 69 | }; |
| 70 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 71 | /**************************************************************************** |
| 72 | * Functions |
| 73 | ****************************************************************************/ |
| 74 | |
| 75 | /** |
| 76 | * ethosu_dev_init() - Initialize the device |
| 77 | * |
| 78 | * Return: 0 on success, else error code. |
| 79 | */ |
| 80 | int ethosu_dev_init(struct ethosu_device *edev, |
| 81 | struct device *dev, |
| 82 | struct class *class, |
Kristofer Jonsson | 4aec376 | 2021-10-13 17:09:27 +0200 | [diff] [blame] | 83 | dev_t devt, |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 84 | struct resource *in_queue, |
| 85 | struct resource *out_queue); |
| 86 | |
| 87 | /** |
| 88 | * ethosu_dev_deinit() - Initialize the device |
| 89 | */ |
| 90 | void ethosu_dev_deinit(struct ethosu_device *edev); |
| 91 | |
Davide Grohmann | 8b1fe55 | 2022-04-07 16:58:32 +0200 | [diff] [blame] | 92 | /** |
| 93 | * ethosu_firmware_reset() - Reset the device running firmware |
| 94 | */ |
| 95 | int ethosu_firmware_reset(struct ethosu_device *edev); |
| 96 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 97 | #endif /* ETHOSU_DEVICE_H */ |