-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtintel_test_generic_driver.h
More file actions
209 lines (177 loc) · 5.69 KB
/
btintel_test_generic_driver.h
File metadata and controls
209 lines (177 loc) · 5.69 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Intel Bluetooth Test Generic Driver - Header
*
* Copyright (C) 2026 Your Company/Name
*/
#ifndef __BTINTEL_TEST_GENERIC_DRIVER_H
#define __BTINTEL_TEST_GENERIC_DRIVER_H
/* ============================================================================
* INCLUDES
* ============================================================================ */
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/skbuff.h>
#include <linux/io.h>
#include <linux/pci.h>
#include "../drivers/bluetooth/btintel_pcie.h"
/* ============================================================================
* CONSTANTS
* ============================================================================ */
/* Device configuration */
#define BTINTEL_TEST_DEFAULT_BUFFER_SIZE 4096
#define BTINTEL_TEST_MAX_BUFFER_SIZE (16 * 1024 * 1024) /* 16MB */
/* Version code (major.minor.patch -> 0x010000 = 1.0.0) */
#define BTINTEL_TEST_VERSION_CODE 0x010000
/* Magic number for ioctl - use a unique value (ASCII character) */
#define BTINTEL_TEST_IOC_MAGIC 'B'
/* ============================================================================
* DATA STRUCTURES FOR IOCTL
* ============================================================================ */
/**
* struct btintel_test_dev_info - Device information
* @version: Driver version code
* @buffer_size: Size of internal device buffer
* @active: Device active status
* @refcount: Number of open file descriptors
*/
struct btintel_test_dev_info {
u32 version;
size_t buffer_size;
u8 active;
u32 refcount;
};
/**
* struct btintel_test_stats - Device statistics
* @read_count: Total number of read operations
* @write_count: Total number of write operations
* @ioctl_count: Total number of ioctl operations
* @errors: Total number of errors
*/
struct btintel_test_stats {
u64 read_count;
u64 write_count;
u64 ioctl_count;
u64 errors;
};
/**
* struct btintel_test_buffer_data - Buffer size configuration
* @size: New buffer size
* @reserved: Padding for future use
*/
struct btintel_test_buffer_data {
size_t size;
u64 reserved;
};
/**
* struct btintel_test_status - Device status
* @state: Device state flags
* @error_code: Last error code
* @reserved: Padding for future use
*/
struct btintel_test_status {
u32 state;
u32 error_code;
u64 reserved;
};
/* ============================================================================
* IOCTL COMMAND DEFINITIONS
* ============================================================================ */
/**
* BTINTEL_TEST_IOC_GET_INFO - Get device information
* Type: Read (IOR)
* Argument: pointer to struct btintel_test_dev_info
*/
#define BTINTEL_TEST_IOC_GET_INFO \
_IOR(BTINTEL_TEST_IOC_MAGIC, 0, struct btintel_test_dev_info)
/**
* BTINTEL_TEST_IOC_GET_STATS - Get device statistics
* Type: Read (IOR)
* Argument: pointer to struct btintel_test_stats
*/
#define BTINTEL_TEST_IOC_GET_STATS \
_IOR(BTINTEL_TEST_IOC_MAGIC, 1, struct btintel_test_stats)
/**
* BTINTEL_TEST_IOC_RESET_STATS - Reset device statistics
* Type: None (IO)
* Argument: none
*/
#define BTINTEL_TEST_IOC_RESET_STATS \
_IO(BTINTEL_TEST_IOC_MAGIC, 2)
/**
* BTINTEL_TEST_IOC_CLEAR_BUFFER - Clear internal device buffer
* Type: None (IO)
* Argument: none
*/
#define BTINTEL_TEST_IOC_CLEAR_BUFFER \
_IO(BTINTEL_TEST_IOC_MAGIC, 3)
/**
* BTINTEL_TEST_IOC_SET_BUFFER_SIZE - Set device buffer size
* Type: Write (IOW)
* Argument: pointer to struct btintel_test_buffer_data
*/
#define BTINTEL_TEST_IOC_SET_BUFFER_SIZE \
_IOW(BTINTEL_TEST_IOC_MAGIC, 4, struct btintel_test_buffer_data)
/**
* BTINTEL_TEST_IOC_GET_STATUS - Get device status
* Type: Read (IOR)
* Argument: pointer to struct btintel_test_status
*/
#define BTINTEL_TEST_IOC_GET_STATUS \
_IOR(BTINTEL_TEST_IOC_MAGIC, 5, struct btintel_test_status)
/**
* BTINTEL_TEST_IOC_ENABLE - Enable device
* Type: None (IO)
* Argument: none
*/
#define BTINTEL_TEST_IOC_ENABLE \
_IO(BTINTEL_TEST_IOC_MAGIC, 6)
/**
* BTINTEL_TEST_IOC_DISABLE - Disable device
* Type: None (IO)
* Argument: none
*/
#define BTINTEL_TEST_IOC_DISABLE \
_IO(BTINTEL_TEST_IOC_MAGIC, 7)
/* ============================================================================
* REGISTER DEFINITIONS (if applicable)
* ============================================================================ */
/* Example register definitions - customize for your hardware */
#define BTINTEL_TEST_CSR_BASE 0x000
#define BTINTEL_TEST_STATUS_REG (BTINTEL_TEST_CSR_BASE + 0x00)
#define BTINTEL_TEST_CONTROL_REG (BTINTEL_TEST_CSR_BASE + 0x04)
#define BTINTEL_TEST_VERSION_REG (BTINTEL_TEST_CSR_BASE + 0x08)
/* Status register bit fields */
#define BTINTEL_TEST_STATUS_READY BIT(0)
#define BTINTEL_TEST_STATUS_ERROR BIT(1)
#define BTINTEL_TEST_STATUS_BUSY BIT(2)
/* Control register bit fields */
#define BTINTEL_TEST_CTRL_ENABLE BIT(0)
#define BTINTEL_TEST_CTRL_RESET BIT(1)
/* ============================================================================
* MACROS FOR REGISTER ACCESS (if using memory-mapped I/O)
* ============================================================================ */
/**
* Read 32-bit register
*/
#define BTINTEL_TEST_READ_REG(base, reg) \
readl((base) + (reg))
/**
* Write 32-bit register
*/
#define BTINTEL_TEST_WRITE_REG(base, reg, value) \
writel((value), (base) + (reg))
/**
* Set specific bits in register
*/
#define BTINTEL_TEST_SET_BITS(base, reg, bits) \
BTINTEL_TEST_WRITE_REG((base), (reg), \
BTINTEL_TEST_READ_REG((base), (reg)) | (bits))
/**
* Clear specific bits in register
*/
#define BTINTEL_TEST_CLEAR_BITS(base, reg, bits) \
BTINTEL_TEST_WRITE_REG((base), (reg), \
BTINTEL_TEST_READ_REG((base), (reg)) & ~(bits))
#endif /* __BTINTEL_TEST_GENERIC_DRIVER_H */