-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdevice.h
58 lines (44 loc) · 1.47 KB
/
device.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-FileCopyrightText: © 2023 Tenstorrent Inc.
// SPDX-License-Identifier: GPL-2.0-only
#ifndef TTDRIVER_DEVICE_H_INCLUDED
#define TTDRIVER_DEVICE_H_INCLUDED
#include <linux/types.h>
#include <linux/device.h>
#include <linux/pci.h>
#include <linux/cdev.h>
#include <linux/reboot.h>
#include <linux/kref.h>
#include "ioctl.h"
#include "hwmon.h"
struct tenstorrent_device_class;
struct tenstorrent_device {
struct kref kref;
struct device dev;
struct cdev chardev;
struct pci_dev *pdev;
const struct tenstorrent_device_class *dev_class;
unsigned int ordinal;
bool dma_capable;
bool interrupt_enabled;
struct mutex chardev_mutex;
unsigned int chardev_open_count;
struct notifier_block reboot_notifier;
DECLARE_BITMAP(resource_lock, TENSTORRENT_RESOURCE_LOCK_COUNT);
struct tt_hwmon_context hwmon_context;
struct tt_attribute_data *attributes;
};
struct tenstorrent_device_class {
const char *name;
u32 instance_size;
u32 dma_address_bits;
bool (*init_device)(struct tenstorrent_device *ttdev);
bool (*init_hardware)(struct tenstorrent_device *ttdev);
bool (*post_hardware_init)(struct tenstorrent_device *ttdev);
void (*cleanup_hardware)(struct tenstorrent_device *ttdev);
void (*cleanup_device)(struct tenstorrent_device *ttdev);
void (*first_open_cb)(struct tenstorrent_device *ttdev);
void (*last_release_cb)(struct tenstorrent_device *ttdev);
void (*reboot)(struct tenstorrent_device *ttdev);
};
void tenstorrent_device_put(struct tenstorrent_device *);
#endif