Repository navigation
Expand file tree
/
Copy pathneuron_cdev.h
More file actions
78 lines (63 loc) · 1.91 KB
/
Copy pathneuron_cdev.h
File metadata and controls
78 lines (63 loc) · 1.91 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright 2023, Amazon.com, Inc. or its affiliates. All Rights Reserved
*/
/** Exposes device node interface(/dev/neuron0) for each device.
* see neuron_ioctl.h for all the operations that can be done this node.
*/
#ifndef NEURON_CDEV_H
#define NEURON_CDEV_H
#include "neuron_device.h"
#ifndef RHEL_RELEASE_VERSION
#define RHEL_RELEASE_VERSION(a,b) 1
#endif
#define MMAP_BAR0_APB_MISC_RAM_INVALID -1
#define NCDEV_MEM_REGION_INVALID -1 // mark the end of ncdev_mem_regions array
struct ncdev_mem_region {
u64 start;
u64 size;
};
/**
* ncdev_create_device_node() - Create a neuron device node
*
* @param ndev: the device node to be created
* @return int: return 0 on success, otherwise failure
*/
int ncdev_create_device_node(struct neuron_device *ndev);
/**
* ncdev_delete_device_node() - Remove a neuron device node
*
* @param ndev: the neuron device to be deleted
* @return int: return 0 on success, otherwise failure
*/
int ncdev_delete_device_node(struct neuron_device *ndev);
/**
* ncdev_class_attr_init() - initialize global class attributes
*
* @return int: return 0 on success, otherwise failure
*/
int ncdev_class_attr_init(void);
/**
* ncdev_class_attr_cleanup() - cleanup glboal class attributes
*
*/
void ncdev_class_attr_cleanup(void);
/**
* ncdev_module_init() - Initialize the kernel module that creates the character devices
*
* @return int: return 0 on success, otherwise failure
*/
int ncdev_module_init(void);
/**
* ncdev_module_exit() - Clean up and release resources associated with the character devices
*
*/
void ncdev_module_exit(void);
/**
* ncdev_trigger_sysfs_reset() - Trigger a device reset in response to a write to the
* neuron{N}/ctrl/reset sysfs node. Only resets when the device is not opened by an application.
*
* @param nd: the neuron device to reset
*/
void ncdev_trigger_sysfs_reset(struct neuron_device *nd);
#endif