| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#include "langford.h" |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) |
| 27 |
#define __devinit |
| 28 |
#define __devexit |
| 29 |
#define __devexit_p(x) x |
| 30 |
#endif |
| 31 |
|
| 32 |
static DevPrivDataType *DevPrivData; |
| 33 |
|
| 34 |
|
| 35 |
static dev_t cdev; |
| 36 |
static struct cdev driver_cdev; |
| 37 |
|
| 38 |
static DEFINE_MUTEX(cdev_open_close_mutex); |
| 39 |
|
| 40 |
static DEFINE_MUTEX(cdev_read_buff_mutex); |
| 41 |
static uint8_t *cdev_read_buff; |
| •42 |
static unsigned int cdev_read_buff_start; |
| 43 |
static unsigned int cdev_read_buff_end; |
| 44 |
|
| 45 |
static DEFINE_MUTEX(cdev_write_buff_mutex); |
| 46 |
static uint8_t *cdev_write_buff; |
| •47 |
static unsigned int cdev_write_buff_start; |
| 48 |
static unsigned int cdev_write_buff_end; |
| 49 |
|
| 50 |
|
| 51 |
static struct task_struct *dev_read_thread; |
| 52 |
static struct task_struct *dev_write_thread; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| •57 |
static unsigned int circ_buff_filled(unsigned int start, unsigned int end, unsigned int len) { |
| •58 |
if (start > end) |
| 59 |
return len - start + end; |
| 60 |
else |
| 61 |
return end - start; |
| 62 |
}; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
static unsigned int circ_buff_avail(unsigned int start, unsigned int end, unsigned int len) { |
| •68 |
if (start > end) |
| 69 |
return start - end - 1; |
| 70 |
else |
| 71 |
return len - end + start - 1; |
| •72 |
}; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| •82 |
static int dev_read_task(void *data) { |
| 83 |
int DescLevel; |
| 84 |
int DescActive, DescComp; |
| •85 |
unsigned int BuffStart, BuffEnd; |
| 86 |
int Ctr; |
| •87 |
unsigned int BuffsToWrite; |
| 88 |
uint32_t DescAddr; |
| 89 |
|
| 90 |
printk(KERN_DEBUG DRIVER_NAME " Read thread created\n"); |
| 91 |
|
| 92 |
BuffStart = BuffEnd = 0; |
| 93 |
DescActive = DescComp = 0; |
| 94 |
for (Ctr = 0; ; Ctr++) { |
| 95 |
mb(); |
| 96 |
|
| 97 |
DescLevel = (readl(DevPrivData->pBar1 + WRCSRFILLLEVEL) >> 16) & 0x0000ffff; |
| 98 |
#if VERBOSE_LOGGING_R |
| 99 |
printk(KERN_DEBUG DRIVER_NAME " Device write desc. level: %d, active: %d, buffs filled: %d, buff start: %d, buff end: %d\n", |
| 100 |
DescLevel, |
| 101 |
DescActive, |
| 102 |
circ_buff_filled(BuffStart, BuffEnd, DMARXBUFFS), |
| 103 |
BuffStart, |
| 104 |
BuffEnd |
| 105 |
); |
| 106 |
#endif |
| 107 |
#if EMPTY_LOGGING |
| 108 |
if (DescLevel == 0) { |
| 109 |
printk(KERN_ERR DRIVER_NAME " Device write descriptor buffer empty!\n"); |
| 110 |
}; |
| 111 |
#endif |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
BuffsToWrite = MIN( |
| 117 |
DMARXDESCS - DescLevel, |
| 118 |
circ_buff_avail(BuffStart, BuffEnd, DMARXBUFFS) |
| 119 |
); |
| 120 |
for (; BuffsToWrite; BuffsToWrite--) { |
| 121 |
|
| 122 |
DescAddr = (BuffEnd << DMAPAGEWIDTH) | (DevPrivData->RxDmaBuffsBusAddr[BuffEnd] & ~DevPrivData->BusTranslationMask); |
| 123 |
#if VERBOSE_LOGGING_R |
| 124 |
printk(KERN_DEBUG DRIVER_NAME " Writing device write descriptor: %d, bus address: 0x%0llx, address on device: 0x%08x\n", BuffEnd, DevPrivData->RxDmaBuffsBusAddr[BuffEnd], DescAddr); |
| 125 |
#endif |
| 126 |
writel(DescAddr, DevPrivData->pBar1 + WRDESCWRADDR); |
| 127 |
writel(DMABUFFSIZE, DevPrivData->pBar1 + WRDESCLEN); |
| 128 |
wmb(); |
| 129 |
writel(DESC_CTRL_GO, DevPrivData->pBar1 + WRDESCCTRL); |
| 130 |
wmb(); |
| 131 |
BuffEnd = (BuffEnd + 1) % DMARXBUFFS; |
| 132 |
DescActive++; |
| 133 |
DescLevel++; |
| 134 |
}; |
| 135 |
|
| 136 |
|
| 137 |
DescComp += DescActive - DescLevel; |
| 138 |
DescActive = DescLevel; |
| 139 |
#if VERBOSE_LOGGING_R |
| 140 |
printk(KERN_DEBUG DRIVER_NAME " %d write descriptors completed\n", DescComp); |
| 141 |
#endif |
| 142 |
for (; DescComp > DMARXDESCDELAY; DescComp--) { |
| 143 |
|
| 144 |
dma_sync_single_for_cpu( |
| 145 |
&(DevPrivData->dev->dev), |
| 146 |
DevPrivData->RxDmaBuffsBusAddr[BuffStart], |
| 147 |
DMABUFFSIZE, |
| 148 |
DMA_FROM_DEVICE |
| 149 |
); |
| 150 |
#if VERBOSE_LOGGING_R |
| 151 |
printk(KERN_DEBUG DRIVER_NAME " Device write DMA completed on buffer: %d, descriptor address: 0x%0llx\n", BuffStart, DevPrivData->RxDmaBuffsBusAddr[BuffStart]); |
| 152 |
printk(KERN_DEBUG DRIVER_NAME " Content: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", |
| 153 |
DevPrivData->pRxDmaBuffs[BuffStart][0], DevPrivData->pRxDmaBuffs[BuffStart][1], DevPrivData->pRxDmaBuffs[BuffStart][2], DevPrivData->pRxDmaBuffs[BuffStart][3], |
| 154 |
DevPrivData->pRxDmaBuffs[BuffStart][4], DevPrivData->pRxDmaBuffs[BuffStart][5], DevPrivData->pRxDmaBuffs[BuffStart][6], DevPrivData->pRxDmaBuffs[BuffStart][7] |
| 155 |
); |
| 156 |
#endif |
| 157 |
|
| 158 |
mutex_lock(&cdev_read_buff_mutex); |
| 159 |
#if VERBOSE_LOGGING_R |
| 160 |
printk(KERN_DEBUG DRIVER_NAME " Read character buffer start: %d, end: %d, filled: %d, available: %d\n", cdev_read_buff_start, cdev_read_buff_end, circ_buff_filled(cdev_read_buff_start, cdev_read_buff_end, CDEVBUFFSIZE), circ_buff_avail(cdev_read_buff_start, cdev_read_buff_end, CDEVBUFFSIZE)); |
| 161 |
#endif |
| 162 |
|
| 163 |
memcpy(cdev_read_buff + cdev_read_buff_end, DevPrivData->pRxDmaBuffs[BuffStart], MIN(DMABUFFSIZE, CDEVBUFFSIZE - cdev_read_buff_end)); |
| 164 |
|
| 165 |
if (cdev_read_buff_end + DMABUFFSIZE > CDEVBUFFSIZE) { |
| 166 |
memcpy(cdev_read_buff, DevPrivData->pRxDmaBuffs[BuffStart] + CDEVBUFFSIZE - cdev_read_buff_end, DMABUFFSIZE - CDEVBUFFSIZE + cdev_read_buff_end); |
| 167 |
}; |
| 168 |
mb(); |
| 169 |
|
| 170 |
if (circ_buff_avail(cdev_read_buff_start, cdev_read_buff_end, CDEVBUFFSIZE) < DMABUFFSIZE) { |
| 171 |
cdev_read_buff_start = (cdev_read_buff_end + DMABUFFSIZE + 1) % CDEVBUFFSIZE; |
| 172 |
#if EMPTY_LOGGING |
| 173 |
printk(KERN_ERR DRIVER_NAME " Device write buffer full. Data lost. Read data faster!\n"); |
| 174 |
#endif |
| 175 |
}; |
| 176 |
cdev_read_buff_end = (cdev_read_buff_end + DMABUFFSIZE) % CDEVBUFFSIZE; |
| 177 |
#if VERBOSE_LOGGING_R |
| 178 |
printk(KERN_DEBUG DRIVER_NAME " Character device read buffer start: %d, end: %d, fill: %d, available: %d\n", |
| 179 |
cdev_read_buff_start, |
| 180 |
cdev_read_buff_end, |
| 181 |
circ_buff_filled(cdev_read_buff_start, cdev_read_buff_end, CDEVBUFFSIZE), |
| 182 |
circ_buff_avail(cdev_read_buff_start, cdev_read_buff_end, CDEVBUFFSIZE) |
| 183 |
); |
| 184 |
#endif |
| 185 |
mutex_unlock(&cdev_read_buff_mutex); |
| 186 |
BuffStart = (BuffStart + 1) % DMARXBUFFS; |
| 187 |
}; |
| 188 |
|
| 189 |
|
| 190 |
if (kthread_should_stop()) { |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
printk(KERN_DEBUG DRIVER_NAME " Read thread termination sequence intiated...\n"); |
| 195 |
printk(KERN_DEBUG DRIVER_NAME " Waiting for remaining write DMA transfers to complete...\n"); |
| 196 |
while(DescLevel) { |
| 197 |
DescLevel = (readl(DevPrivData->pBar1 + WRCSRFILLLEVEL) >> 16) & 0x0000ffff; |
| 198 |
#if VERBOSE_LOGGING_R |
| 199 |
printk(KERN_DEBUG DRIVER_NAME " Write descriptor level is %d...\n", DescLevel); |
| 200 |
#endif |
| 201 |
yield(); |
| 202 |
}; |
| 203 |
printk(KERN_DEBUG DRIVER_NAME " Read thread complete\n"); |
| 204 |
return 0; |
| 205 |
}; |
| 206 |
|
| 207 |
|
| 208 |
yield(); |
| 209 |
}; |
| 210 |
|
| 211 |
printk(KERN_ERR DRIVER_NAME " You should never see this printed\n"); |
| 212 |
|
| 213 |
return 1; |
| 214 |
}; |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| •223 |
static int dev_write_task(void *data) { |
| 224 |
int DescLevel; |
| 225 |
int DescActive, DescComp; |
| •226 |
unsigned int BuffStart, BuffEnd; |
| 227 |
int Ctr; |
| •228 |
unsigned int BuffsToWrite; |
| 229 |
uint32_t DescAddr; |
| 230 |
|
| 231 |
printk(KERN_DEBUG DRIVER_NAME " Write thread created\n"); |
| 232 |
|
| 233 |
BuffStart = BuffEnd = 0; |
| 234 |
DescActive = DescComp = 0; |
| 235 |
for (Ctr = 0; ; Ctr++) { |
| 236 |
mb(); |
| 237 |
|
| 238 |
DescLevel = readl(DevPrivData->pBar1 + RDCSRFILLLEVEL) & 0x0000ffff; |
| 239 |
#if VERBOSE_LOGGING_W |
| 240 |
printk(KERN_DEBUG DRIVER_NAME " Device read desc. level: %d, active: %d, buffs filled: %d, buff start: %d, buff end: %d\n", |
| 241 |
DescLevel, |
| 242 |
DescActive, |
| 243 |
circ_buff_filled(BuffStart, BuffEnd, DMARXBUFFS), |
| 244 |
BuffStart, |
| 245 |
BuffEnd |
| 246 |
); |
| 247 |
#endif |
| 248 |
#if EMPTY_LOGGING |
| 249 |
if (DescLevel == 0) { |
| 250 |
printk(KERN_ERR DRIVER_NAME " Device read descriptor buffer empty!\n"); |
| 251 |
}; |
| 252 |
#endif |
| 253 |
|
| 254 |
|
| 255 |
DescComp = DMARXBUFFS - DescLevel; |
| 256 |
DescActive = DescLevel; |
| 257 |
#if VERBOSE_LOGGING_W |
| 258 |
printk(KERN_DEBUG DRIVER_NAME " %d read descriptors completed\n", DescComp); |
| 259 |
#endif |
| 260 |
for (; DescComp > DMATXDESCDELAY; DescComp--) { |
| 261 |
|
| 262 |
mutex_lock(&cdev_write_buff_mutex); |
| 263 |
#if VERBOSE_LOGGING_W |
| 264 |
printk(KERN_DEBUG DRIVER_NAME " Write character buffer start: %d, end: %d, filled: %d, available: %d\n", cdev_write_buff_start, cdev_write_buff_end, circ_buff_filled(cdev_write_buff_start, cdev_write_buff_end, CDEVBUFFSIZE), circ_buff_avail(cdev_write_buff_start, cdev_write_buff_end, CDEVBUFFSIZE)); |
| 265 |
#endif |
| 266 |
|
| 267 |
if (circ_buff_filled(cdev_write_buff_start, cdev_write_buff_end, CDEVBUFFSIZE) > DMABUFFSIZE) { |
| 268 |
|
| 269 |
memcpy(DevPrivData->pTxDmaBuffs[BuffEnd], cdev_write_buff + cdev_write_buff_start, MIN(DMABUFFSIZE, CDEVBUFFSIZE - cdev_write_buff_start)); |
| 270 |
|
| 271 |
if (cdev_write_buff_start + DMABUFFSIZE > CDEVBUFFSIZE) { |
| 272 |
memcpy(DevPrivData->pTxDmaBuffs[BuffEnd] + CDEVBUFFSIZE - cdev_write_buff_start, cdev_write_buff, DMABUFFSIZE - CDEVBUFFSIZE + cdev_write_buff_start); |
| 273 |
}; |
| 274 |
cdev_write_buff_start = (cdev_write_buff_start + DMABUFFSIZE) % CDEVBUFFSIZE; |
| 275 |
mb(); |
| 276 |
#if VERBOSE_LOGGING_W |
| 277 |
printk(KERN_DEBUG DRIVER_NAME " Character device write buffer start: %d, end: %d, fill: %d, available: %d\n", |
| 278 |
cdev_write_buff_start, |
| 279 |
cdev_write_buff_end, |
| 280 |
circ_buff_filled(cdev_write_buff_start, cdev_write_buff_end, CDEVBUFFSIZE), |
| 281 |
circ_buff_avail(cdev_write_buff_start, cdev_write_buff_end, CDEVBUFFSIZE) |
| 282 |
); |
| 283 |
printk(KERN_DEBUG DRIVER_NAME " Device read DMA buffer initialized on buffer: %d, descriptor address: 0x%0llx\n", BuffEnd, DevPrivData->TxDmaBuffsBusAddr[BuffEnd]); |
| 284 |
printk(KERN_DEBUG DRIVER_NAME " Content: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", |
| 285 |
DevPrivData->pTxDmaBuffs[BuffEnd][0], DevPrivData->pTxDmaBuffs[BuffEnd][1], DevPrivData->pTxDmaBuffs[BuffEnd][2], DevPrivData->pTxDmaBuffs[BuffEnd][3], |
| 286 |
DevPrivData->pTxDmaBuffs[BuffEnd][4], DevPrivData->pTxDmaBuffs[BuffEnd][5], DevPrivData->pTxDmaBuffs[BuffEnd][6], DevPrivData->pTxDmaBuffs[BuffEnd][7] |
| 287 |
); |
| 288 |
#endif |
| 289 |
|
| 290 |
dma_sync_single_for_device( |
| 291 |
&(DevPrivData->dev->dev), |
| 292 |
DevPrivData->TxDmaBuffsBusAddr[BuffEnd], |
| 293 |
DMABUFFSIZE, |
| 294 |
DMA_TO_DEVICE |
| 295 |
); |
| 296 |
BuffEnd = (BuffEnd + 1) % DMARXBUFFS; |
| 297 |
} else { |
| 298 |
#if EMPTY_LOGGING |
| 299 |
printk(KERN_ERR DRIVER_NAME " Character device write buffer empty. Write more before read descriptors complete!\n"); |
| 300 |
#endif |
| 301 |
}; |
| 302 |
mutex_unlock(&cdev_write_buff_mutex); |
| 303 |
}; |
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
BuffsToWrite = MIN( |
| 309 |
DMATXDESCS - DescLevel, |
| 310 |
circ_buff_filled(BuffStart, BuffEnd, DMATXBUFFS) |
| 311 |
); |
| 312 |
for (; BuffsToWrite; BuffsToWrite--) { |
| 313 |
|
| 314 |
DescAddr = ((BuffStart + DMARXBUFFS) << DMAPAGEWIDTH) | (DevPrivData->TxDmaBuffsBusAddr[BuffStart] & ~DevPrivData->BusTranslationMask); |
| 315 |
#if VERBOSE_LOGGING_W |
| 316 |
printk(KERN_DEBUG DRIVER_NAME " Writing device read descriptor: %d, bus address: 0x%0llx, address on device: 0x%08x\n", BuffStart, DevPrivData->TxDmaBuffsBusAddr[BuffStart], DescAddr); |
| 317 |
#endif |
| 318 |
writel(DescAddr, DevPrivData->pBar1 + RDDESCRDADDR); |
| 319 |
writel(DMABUFFSIZE, DevPrivData->pBar1 + RDDESCLEN); |
| 320 |
wmb(); |
| 321 |
writel(DESC_CTRL_GO, DevPrivData->pBar1 + RDDESCCTRL); |
| 322 |
wmb(); |
| 323 |
BuffStart = (BuffStart + 1) % DMATXBUFFS; |
| 324 |
DescActive++; |
| 325 |
DescLevel++; |
| 326 |
}; |
| 327 |
|
| 328 |
|
| 329 |
if (kthread_should_stop()) { |
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
printk(KERN_DEBUG DRIVER_NAME " Write thread termination sequence intiated...\n"); |
| 334 |
printk(KERN_DEBUG DRIVER_NAME " Waiting for remaining read DMA transfers to complete...\n"); |
| 335 |
while(DescLevel) { |
| 336 |
DescLevel = readl(DevPrivData->pBar1 + RDCSRFILLLEVEL) & 0x0000ffff; |
| 337 |
#if VERBOSE_LOGGING_W |
| 338 |
printk(KERN_DEBUG DRIVER_NAME " Read desc level is %d...\n", DescLevel); |
| 339 |
#endif |
| 340 |
yield(); |
| 341 |
}; |
| 342 |
printk(KERN_DEBUG DRIVER_NAME " Write thread complete\n"); |
| 343 |
return 0; |
| 344 |
}; |
| 345 |
|
| 346 |
yield(); |
| 347 |
}; |
| 348 |
|
| 349 |
printk(KERN_ERR DRIVER_NAME " You should never see this printed\n"); |
| 350 |
|
| 351 |
return 1; |
| 352 |
}; |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
static ssize_t cdev_read(struct file *file, char __user *buf, size_t len, loff_t *ppos) { |
| 358 |
int cdev_buff_fill; |
| 359 |
|
| 360 |
#if VERBOSE_LOGGING_R |
| 361 |
printk(KERN_DEBUG DRIVER_NAME " User requested read of %zu bytes\n", len); |
| 362 |
#endif |
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
if (len > CDEVBUFFSIZE - 1) { |
| 368 |
printk(KERN_ERR DRIVER_NAME " User requested read of %zu bytes is larger than character device buffer of %d bytes\n", len, CDEVBUFFSIZE - 1); |
| 369 |
}; |
| 370 |
|
| 371 |
do { |
| 372 |
mutex_lock(&cdev_read_buff_mutex); |
| 373 |
cdev_buff_fill = circ_buff_filled(cdev_read_buff_start, cdev_read_buff_end, CDEVBUFFSIZE); |
| 374 |
mutex_unlock(&cdev_read_buff_mutex); |
| 375 |
yield(); |
| 376 |
} while (cdev_buff_fill < len); |
| 377 |
|
| 378 |
mutex_lock(&cdev_read_buff_mutex); |
| 379 |
#if VERBOSE_LOGGING_R |
| 380 |
printk(KERN_DEBUG DRIVER_NAME " Read buffer prior to data copy start: %d, end: %d\n", cdev_read_buff_start, cdev_read_buff_end); |
| 381 |
#endif |
| 382 |
|
| 383 |
copy_to_user(buf, cdev_read_buff + cdev_read_buff_start, MIN(len, CDEVBUFFSIZE - cdev_read_buff_start)); |
| 384 |
|
| 385 |
if (cdev_read_buff_start + len > CDEVBUFFSIZE) { |
| 386 |
copy_to_user(buf + CDEVBUFFSIZE - cdev_read_buff_start, cdev_read_buff, len - CDEVBUFFSIZE + cdev_read_buff_start); |
| 387 |
}; |
| 388 |
cdev_read_buff_start = (cdev_read_buff_start + len) % CDEVBUFFSIZE; |
| 389 |
mb(); |
| 390 |
mutex_unlock(&cdev_read_buff_mutex); |
| 391 |
|
| 392 |
#if VERBOSE_LOGGING_R |
| 393 |
printk(KERN_DEBUG DRIVER_NAME " User read request completed\n"); |
| 394 |
#endif |
| 395 |
|
| 396 |
return len; |
| 397 |
}; |
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
static ssize_t cdev_write(struct file *file, const char __user *buf, size_t len, loff_t *ppos) { |
| •403 |
unsigned int cdev_buff_avail; |
| 404 |
|
| 405 |
#if VERBOSE_LOGGING_W |
| 406 |
printk(KERN_DEBUG DRIVER_NAME " User requested write of %zu bytes\n", len); |
| 407 |
#endif |
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
if (len > CDEVBUFFSIZE - 1) { |
| 413 |
printk(KERN_ERR DRIVER_NAME " User requested write of %zu bytes is larger than character device buffer of %d bytes\n", len, CDEVBUFFSIZE - 1); |
| 414 |
}; |
| 415 |
|
| 416 |
do { |
| 417 |
mutex_lock(&cdev_write_buff_mutex); |
| 418 |
cdev_buff_avail = circ_buff_avail(cdev_write_buff_start, cdev_write_buff_end, CDEVBUFFSIZE); |
| 419 |
mutex_unlock(&cdev_write_buff_mutex); |
| 420 |
yield(); |
| 421 |
} while (cdev_buff_avail < len); |
| 422 |
|
| 423 |
mutex_lock(&cdev_write_buff_mutex); |
| 424 |
#if VERBOSE_LOGGING_W |
| 425 |
printk(KERN_DEBUG DRIVER_NAME " Write buffer prior to data copy start: %d, end: %d\n", cdev_write_buff_start, cdev_write_buff_end); |
| 426 |
#endif |
| 427 |
|
| 428 |
copy_from_user(cdev_write_buff + cdev_write_buff_end, buf, MIN(len, CDEVBUFFSIZE - cdev_write_buff_end)); |
| 429 |
|
| 430 |
if (cdev_write_buff_end + len > CDEVBUFFSIZE) { |
| 431 |
copy_from_user(cdev_write_buff, buf + CDEVBUFFSIZE - cdev_write_buff_end, len - CDEVBUFFSIZE + cdev_write_buff_end); |
| 432 |
}; |
| 433 |
cdev_write_buff_end = (cdev_write_buff_end + len) % CDEVBUFFSIZE; |
| 434 |
mb(); |
| 435 |
mutex_unlock(&cdev_write_buff_mutex); |
| 436 |
|
| 437 |
#if VERBOSE_LOGGING_W |
| 438 |
printk(KERN_DEBUG DRIVER_NAME " User write request completed\n"); |
| 439 |
#endif |
| 440 |
|
| 441 |
return len; |
| 442 |
}; |
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| •447 |
static int ioctl_helper(int cmd, int *parg) { |
| 448 |
int AddrOffset; |
| 449 |
int BitOffset; |
| 450 |
|
| 451 |
|
| 452 |
switch (cmd) { |
| 453 |
case IOCTL_GET_N21at0: case IOCTL_SET_N21at0: AddrOffset = PIO0; BitOffset = 0; break; |
| 454 |
case IOCTL_GET_N22at0: case IOCTL_SET_N22at0: AddrOffset = PIO0; BitOffset = 8; break; |
| 455 |
case IOCTL_GET_N3GAIN: case IOCTL_SET_N3GAIN: AddrOffset = PIO0; BitOffset = 16; break; |
| 456 |
case IOCTL_GET_N61CE: case IOCTL_SET_N61CE: AddrOffset = PIO1; BitOffset = 0; break; |
| 457 |
case IOCTL_GET_N61DATA: case IOCTL_SET_N61DATA: AddrOffset = PIO1; BitOffset = 1; break; |
| 458 |
case IOCTL_GET_N61CLK: case IOCTL_SET_N61CLK: AddrOffset = PIO1; BitOffset = 2; break; |
| 459 |
case IOCTL_GET_N61LE: case IOCTL_SET_N61LE: AddrOffset = PIO1; BitOffset = 3; break; |
| 460 |
case IOCTL_GET_N62CE: case IOCTL_SET_N62CE: AddrOffset = PIO1; BitOffset = 4; break; |
| 461 |
case IOCTL_GET_N62DATA: case IOCTL_SET_N62DATA: AddrOffset = PIO1; BitOffset = 5; break; |
| 462 |
case IOCTL_GET_N62CLK: case IOCTL_SET_N62CLK: AddrOffset = PIO1; BitOffset = 6; break; |
| 463 |
case IOCTL_GET_N62LE: case IOCTL_SET_N62LE: AddrOffset = PIO1; BitOffset = 7; break; |
| 464 |
case IOCTL_GET_N3ENB: case IOCTL_SET_N3ENB: AddrOffset = PIO1; BitOffset = 8; break; |
| 465 |
case IOCTL_GET_N3HILO: case IOCTL_SET_N3HILO: AddrOffset = PIO1; BitOffset = 9; break; |
| 466 |
case IOCTL_GET_NASRxA: case IOCTL_SET_NASRxA: AddrOffset = PIO1; BitOffset = 10; break; |
| 467 |
case IOCTL_GET_NASTxA: case IOCTL_SET_NASTxA: AddrOffset = PIO1; BitOffset = 11; break; |
| 468 |
case IOCTL_GET_N7CLK: case IOCTL_SET_N7CLK: AddrOffset = PIO1; BitOffset = 12; break; |
| 469 |
case IOCTL_GET_N7CS: case IOCTL_SET_N7CS: AddrOffset = PIO1; BitOffset = 13; break; |
| 470 |
case IOCTL_GET_N7SDI: case IOCTL_SET_N7SDI: AddrOffset = PIO1; BitOffset = 14; break; |
| 471 |
case IOCTL_GET_DACIQSel: case IOCTL_SET_DACIQSel: AddrOffset = PIO1; BitOffset = 15; break; |
| 472 |
case IOCTL_GET_DACReset: case IOCTL_SET_DACReset: AddrOffset = PIO1; BitOffset = 16; break; |
| 473 |
case IOCTL_GET_DACCSB: case IOCTL_SET_DACCSB: AddrOffset = PIO1; BitOffset = 17; break; |
| 474 |
case IOCTL_GET_DACSDIO: case IOCTL_SET_DACSDIO: AddrOffset = PIO1; BitOffset = 18; break; |
| 475 |
case IOCTL_GET_DACSClk: case IOCTL_SET_DACSClk: AddrOffset = PIO1; BitOffset = 19; break; |
| 476 |
case IOCTL_GET_ADCAnOE: case IOCTL_SET_ADCAnOE: AddrOffset = PIO1; BitOffset = 20; break; |
| 477 |
case IOCTL_GET_ADCAPD: case IOCTL_SET_ADCAPD: AddrOffset = PIO1; BitOffset = 21; break; |
| 478 |
case IOCTL_GET_ADCASClk: case IOCTL_SET_ADCASClk: AddrOffset = PIO1; BitOffset = 22; break; |
| 479 |
case IOCTL_GET_ADCASDIO: case IOCTL_SET_ADCASDIO: AddrOffset = PIO1; BitOffset = 23; break; |
| 480 |
case IOCTL_GET_ADCAnCS: case IOCTL_SET_ADCAnCS: AddrOffset = PIO1; BitOffset = 24; break; |
| 481 |
case IOCTL_GET_ADCBnOE: case IOCTL_SET_ADCBnOE: AddrOffset = PIO1; BitOffset = 25; break; |
| 482 |
case IOCTL_GET_ADCBPD: case IOCTL_SET_ADCBPD: AddrOffset = PIO1; BitOffset = 26; break; |
| 483 |
case IOCTL_GET_ADCBSClk: case IOCTL_SET_ADCBSClk: AddrOffset = PIO1; BitOffset = 27; break; |
| 484 |
case IOCTL_GET_ADCBSDIO: case IOCTL_SET_ADCBSDIO: AddrOffset = PIO1; BitOffset = 28; break; |
| 485 |
case IOCTL_GET_ADCBnCS: case IOCTL_SET_ADCBnCS: AddrOffset = PIO1; BitOffset = 29; break; |
| 486 |
case IOCTL_GET_DACSDO: case IOCTL_SET_DACSDO: AddrOffset = PIO1; BitOffset = 30; break; |
| 487 |
case IOCTL_GET_N61MUXOUT: AddrOffset = PIO2; BitOffset = 0; break; |
| 488 |
case IOCTL_GET_N61LD: AddrOffset = PIO2; BitOffset = 1; break; |
| 489 |
case IOCTL_GET_N62MUXOUT: AddrOffset = PIO2; BitOffset = 2; break; |
| 490 |
case IOCTL_GET_N62LD: AddrOffset = PIO2; BitOffset = 3; break; |
| 491 |
case IOCTL_GET_N7SDO: AddrOffset = PIO2; BitOffset = 4; break; |
| 492 |
case IOCTL_GET_GPIOin: AddrOffset = PIO2; BitOffset = 5; break; |
| 493 |
case IOCTL_GET_RXPhase: case IOCTL_SET_RXPhase: AddrOffset = PIO3; BitOffset = 0; break; |
| 494 |
case IOCTL_GET_TXPhase: case IOCTL_SET_TXPhase: AddrOffset = PIO4; BitOffset = 0; break; |
| 495 |
case IOCTL_GET_RXDecEn: case IOCTL_SET_RXDecEn: AddrOffset = PIO5; BitOffset = 0; break; |
| 496 |
case IOCTL_GET_TXIntEn: case IOCTL_SET_TXIntEn: AddrOffset = PIO5; BitOffset = 8; break; |
| 497 |
case IOCTL_GET_RXRevFreq: case IOCTL_SET_RXRevFreq: AddrOffset = PIO5; BitOffset = 16; break; |
| 498 |
case IOCTL_GET_TXRevFreq: case IOCTL_SET_TXRevFreq: AddrOffset = PIO5; BitOffset = 17; break; |
| 499 |
case IOCTL_GET_RxDspEn: case IOCTL_SET_RxDspEn: AddrOffset = PIO5; BitOffset = 18; break; |
| 500 |
case IOCTL_GET_TxDspEn: case IOCTL_SET_TxDspEn: AddrOffset = PIO5; BitOffset = 19; break; |
| 501 |
case IOCTL_GET_NRXTALSEL: case IOCTL_SET_NRXTALSEL: AddrOffset = PIO5; BitOffset = 20; break; |
| 502 |
case IOCTL_GET_NRVCOSEL: case IOCTL_SET_NRVCOSEL: AddrOffset = PIO5; BitOffset = 21; break; |
| 503 |
case IOCTL_GET_RxFifoClr: case IOCTL_SET_RxFifoClr: AddrOffset = PIO5; BitOffset = 22; break; |
| 504 |
case IOCTL_GET_TxFifoClr: case IOCTL_SET_TxFifoClr: AddrOffset = PIO5; BitOffset = 23; break; |
| 505 |
case IOCTL_GET_RxIsSigned: case IOCTL_SET_RxIsSigned: AddrOffset = PIO5; BitOffset = 24; break; |
| 506 |
case IOCTL_GET_TxIsSigned: case IOCTL_SET_TxIsSigned: AddrOffset = PIO5; BitOffset = 25; break; |
| 507 |
case IOCTL_GET_GPIOout: case IOCTL_SET_GPIOout: AddrOffset = PIO5; BitOffset = 26; break; |
| 508 |
case IOCTL_GET_RxBaseband: case IOCTL_SET_RxBaseband: AddrOffset = PIO5; BitOffset = 30; break; |
| 509 |
default: |
| 510 |
printk(KERN_ERR DRIVER_NAME " Invalid command: %d\n", cmd); |
| 511 |
return -EINVAL; |
| 512 |
break; |
| 513 |
}; |
| 514 |
mb(); |
| 515 |
|
| 516 |
|
| 517 |
switch (cmd) { |
| 518 |
|
| 519 |
case IOCTL_GET_N61CE: case IOCTL_GET_N61DATA: case IOCTL_GET_N61CLK: case IOCTL_GET_N61LE: |
| 520 |
case IOCTL_GET_N62CE: case IOCTL_GET_N62DATA: case IOCTL_GET_N62CLK: case IOCTL_GET_N62LE: |
| 521 |
case IOCTL_GET_N3ENB: case IOCTL_GET_N3HILO: case IOCTL_GET_NASRxA: case IOCTL_GET_NASTxA: |
| 522 |
case IOCTL_GET_N7CLK: case IOCTL_GET_N7CS: case IOCTL_GET_N7SDI: case IOCTL_GET_N7SDO: |
| 523 |
case IOCTL_GET_N61MUXOUT: case IOCTL_GET_N61LD: case IOCTL_GET_N62MUXOUT: case IOCTL_GET_N62LD: |
| 524 |
case IOCTL_GET_DACIQSel: case IOCTL_GET_DACReset: case IOCTL_GET_DACCSB: case IOCTL_GET_DACSDIO: case IOCTL_GET_DACSClk: case IOCTL_GET_DACSDO: |
| 525 |
case IOCTL_GET_ADCAnOE: case IOCTL_GET_ADCAPD: case IOCTL_GET_ADCASClk: case IOCTL_GET_ADCASDIO: case IOCTL_GET_ADCAnCS: |
| 526 |
case IOCTL_GET_ADCBnOE: case IOCTL_GET_ADCBPD: case IOCTL_GET_ADCBSClk: case IOCTL_GET_ADCBSDIO: case IOCTL_GET_ADCBnCS: |
| 527 |
case IOCTL_GET_RXRevFreq: case IOCTL_GET_TXRevFreq: |
| 528 |
case IOCTL_GET_RxDspEn: case IOCTL_GET_TxDspEn: |
| 529 |
case IOCTL_GET_NRXTALSEL: case IOCTL_GET_NRVCOSEL: |
| 530 |
case IOCTL_GET_RxFifoClr: case IOCTL_GET_TxFifoClr: case IOCTL_GET_RxIsSigned: case IOCTL_GET_TxIsSigned: case IOCTL_GET_RxBaseband: |
| 531 |
*parg = (readl(DevPrivData->pBar0 + AddrOffset) >> BitOffset) & 0x00000001; |
| 532 |
break; |
| 533 |
|
| 534 |
case IOCTL_SET_N61CE: case IOCTL_SET_N61DATA: case IOCTL_SET_N61CLK: case IOCTL_SET_N61LE: |
| 535 |
case IOCTL_SET_N62CE: case IOCTL_SET_N62DATA: case IOCTL_SET_N62CLK: case IOCTL_SET_N62LE: |
| 536 |
case IOCTL_SET_N3ENB: case IOCTL_SET_N3HILO: case IOCTL_SET_NASRxA: case IOCTL_SET_NASTxA: |
| 537 |
case IOCTL_SET_N7CLK: case IOCTL_SET_N7CS: case IOCTL_SET_N7SDI: |
| 538 |
case IOCTL_SET_DACIQSel: case IOCTL_SET_DACReset: case IOCTL_SET_DACCSB: case IOCTL_SET_DACSDIO: case IOCTL_SET_DACSClk: case IOCTL_SET_DACSDO: |
| 539 |
case IOCTL_SET_ADCAnOE: case IOCTL_SET_ADCAPD: case IOCTL_SET_ADCASClk: case IOCTL_SET_ADCASDIO: case IOCTL_SET_ADCAnCS: |
| 540 |
case IOCTL_SET_ADCBnOE: case IOCTL_SET_ADCBPD: case IOCTL_SET_ADCBSClk: case IOCTL_SET_ADCBSDIO: case IOCTL_SET_ADCBnCS: |
| 541 |
case IOCTL_SET_RXRevFreq: case IOCTL_SET_TXRevFreq: |
| 542 |
case IOCTL_SET_RxDspEn: case IOCTL_SET_TxDspEn: |
| 543 |
case IOCTL_SET_NRXTALSEL: case IOCTL_SET_NRVCOSEL: |
| 544 |
case IOCTL_SET_RxFifoClr: case IOCTL_SET_TxFifoClr: case IOCTL_SET_RxIsSigned: case IOCTL_SET_TxIsSigned: case IOCTL_SET_RxBaseband: |
| 545 |
if (*parg > 1) { |
| 546 |
printk(KERN_ERR DRIVER_NAME " Invalid argument: %d\n", *parg); |
| 547 |
return -EINVAL; |
| 548 |
}; |
| 549 |
writel((readl(DevPrivData->pBar0 + AddrOffset) & ~(0x00000001 << BitOffset)) | (*parg << BitOffset), DevPrivData->pBar0 + AddrOffset); |
| 550 |
break; |
| 551 |
|
| 552 |
case IOCTL_GET_GPIOin: case IOCTL_GET_GPIOout: |
| 553 |
*parg = (readl(DevPrivData->pBar0 + AddrOffset) >> BitOffset) & 0x0000001f; |
| 554 |
break; |
| 555 |
|
| 556 |
case IOCTL_SET_GPIOout: |
| 557 |
if (*parg > 31) { |
| 558 |
printk(KERN_ERR DRIVER_NAME " Invalid argument: %d\n", *parg); |
| 559 |
return -EINVAL; |
| 560 |
}; |
| 561 |
writel((readl(DevPrivData->pBar0 + AddrOffset) & ~(0x0000001f << BitOffset)) | (*parg << BitOffset), DevPrivData->pBar0 + AddrOffset); |
| 562 |
break; |
| 563 |
|
| 564 |
case IOCTL_GET_N21at0: case IOCTL_GET_N22at0: case IOCTL_GET_N3GAIN: |
| 565 |
case IOCTL_GET_RXDecEn: case IOCTL_GET_TXIntEn: |
| 566 |
*parg = (readl(DevPrivData->pBar0 + AddrOffset) >> BitOffset) & 0x000000ff; |
| 567 |
break; |
| 568 |
|
| 569 |
case IOCTL_SET_N21at0: case IOCTL_SET_N22at0: case IOCTL_SET_N3GAIN: |
| 570 |
case IOCTL_SET_RXDecEn: case IOCTL_SET_TXIntEn: |
| 571 |
if (*parg > 255) { |
| 572 |
printk(KERN_ERR DRIVER_NAME " Invalid argument: %d\n", *parg); |
| 573 |
return -EINVAL; |
| 574 |
}; |
| 575 |
writel((readl(DevPrivData->pBar0 + AddrOffset) & ~(0x000000ff << BitOffset)) | (*parg << BitOffset), DevPrivData->pBar0 + AddrOffset); |
| 576 |
break; |
| 577 |
|
| 578 |
case IOCTL_GET_RXPhase: case IOCTL_GET_TXPhase: |
| 579 |
*parg = (readl(DevPrivData->pBar0 + AddrOffset) >> BitOffset) & 0xffffffff; |
| 580 |
break; |
| 581 |
|
| 582 |
case IOCTL_SET_RXPhase: case IOCTL_SET_TXPhase: |
| 583 |
writel((readl(DevPrivData->pBar0 + AddrOffset) & ~(0xffffffff << BitOffset)) | (*parg << BitOffset), DevPrivData->pBar0 + AddrOffset); |
| 584 |
break; |
| 585 |
}; |
| 586 |
mb(); |
| 587 |
|
| 588 |
return 0; |
| 589 |
}; |
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
static long cdev_ioctl(struct file *file, unsigned int cmd, unsigned long parg) { |
| 596 |
int32_t tmp; |
| 597 |
int rc; |
| 598 |
|
| 599 |
printk(KERN_DEBUG DRIVER_NAME " ioctl called with cmd = %d, parg = 0x%016lx\n", cmd, parg); |
| 600 |
|
| 601 |
if (copy_from_user(&tmp, (void *)parg, 4)) { |
| 602 |
printk(KERN_ERR DRIVER_NAME " Cannot copy from program memory\n"); |
| 603 |
rc = -ENOMEM; |
| 604 |
goto exit_func; |
| 605 |
}; |
| 606 |
|
| 607 |
printk(KERN_DEBUG DRIVER_NAME " ioctl being served with arg = %d\n", tmp); |
| 608 |
rc = ioctl_helper(cmd, &tmp); |
| 609 |
|
| 610 |
if (copy_to_user((void *)parg, &tmp, 4)) { |
| 611 |
printk(KERN_ERR DRIVER_NAME " Cannot copy to program memory\n"); |
| 612 |
rc = -ENOMEM; |
| 613 |
goto exit_func; |
| 614 |
}; |
| 615 |
|
| 616 |
return 0; |
| 617 |
|
| 618 |
|
| 619 |
exit_func: |
| 620 |
printk(KERN_ERR DRIVER_NAME " ioctl call failed: %d\n", rc); |
| 621 |
return rc; |
| 622 |
}; |
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
static int create_dma_buffs(uint8_t ***dma_buffs, dma_addr_t **dma_buffs_bus_addr, int num_buffs, int buff_size, enum dma_data_direction dir) { |
| 628 |
int i; |
| 629 |
int rc = 0; |
| 630 |
|
| 631 |
if (!(*dma_buffs = (uint8_t**)kmalloc(sizeof(uint8_t*) * num_buffs, GFP_KERNEL))) { |
| 632 |
rc = -ENOMEM; |
| 633 |
goto exit_func; |
| 634 |
}; |
| 635 |
for (i = 0; i < num_buffs; i++) { |
| 636 |
if (!((*dma_buffs)[i] = (uint8_t*)kmalloc(buff_size, GFP_KERNEL))) { |
| 637 |
rc = -ENOMEM; |
| 638 |
goto exit_kfree; |
| 639 |
}; |
| 640 |
}; |
| 641 |
|
| 642 |
if (!(*dma_buffs_bus_addr = (dma_addr_t*)kmalloc(sizeof(dma_addr_t) * num_buffs, GFP_KERNEL))) { |
| 643 |
rc = -ENOMEM; |
| 644 |
goto exit_kfree; |
| 645 |
}; |
| 646 |
for (i = 0; i < num_buffs; i++) { |
| 647 |
if (!((*dma_buffs_bus_addr)[i] = dma_map_single(&(DevPrivData->dev->dev), (*dma_buffs)[i], buff_size, dir))) { |
| 648 |
rc = -ENOMEM; |
| 649 |
goto exit_dma_unmap; |
| 650 |
}; |
| 651 |
printk(KERN_DEBUG DRIVER_NAME " Created buffer %d memory address: %p = bus address: 0x%0llx\n", i + 1, (*dma_buffs)[i], (long long) (*dma_buffs_bus_addr)[i]); |
| 652 |
}; |
| 653 |
|
| 654 |
return 0; |
| 655 |
|
| 656 |
|
| 657 |
exit_dma_unmap: |
| 658 |
for (; i >= 0; i--) { |
| 659 |
dma_unmap_single(&(DevPrivData->dev->dev), (*dma_buffs_bus_addr)[i], buff_size, dir); |
| 660 |
}; |
| 661 |
i = 15; |
| 662 |
kfree(*dma_buffs_bus_addr); |
| 663 |
exit_kfree: |
| 664 |
for (; i >= 0; i--) { |
| 665 |
kfree((*dma_buffs)[i]); |
| 666 |
}; |
| 667 |
kfree(*dma_buffs); |
| 668 |
exit_func: |
| 669 |
return rc; |
| 670 |
}; |
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
static void destroy_dma_buffs(uint8_t ***dma_buffs, dma_addr_t **dma_buffs_bus_addr, int num_buffs, int buff_size, enum dma_data_direction dir) { |
| 676 |
int i; |
| 677 |
|
| 678 |
for (i = 0; i < num_buffs; i++) { |
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
dma_unmap_single(&(DevPrivData->dev->dev), (*dma_buffs_bus_addr)[i], buff_size, dir); |
| 683 |
}; |
| 684 |
kfree(*dma_buffs_bus_addr); |
| 685 |
for (i = 0; i < num_buffs; i++) { |
| 686 |
kfree((*dma_buffs)[i]); |
| 687 |
}; |
| 688 |
kfree(*dma_buffs); |
| 689 |
}; |
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| •697 |
static void PowerPeriph(int State) { |
| 698 |
int nState = !State; |
| 699 |
int Val1 = 1; |
| 700 |
State = !nState; |
| 701 |
|
| 702 |
printk(KERN_DEBUG DRIVER_NAME " State: %d nState: %d\n", State, nState); |
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
ioctl_helper(IOCTL_SET_ADCAPD, &nState); |
| 709 |
ioctl_helper(IOCTL_SET_ADCBPD, &nState); |
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
ioctl_helper(IOCTL_SET_DACReset, &Val1); |
| 714 |
|
| 715 |
ioctl_helper(IOCTL_SET_DACSClk, &nState); |
| 716 |
|
| 717 |
ioctl_helper(IOCTL_SET_DACSDIO, &nState); |
| 718 |
|
| 719 |
ioctl_helper(IOCTL_SET_DACCSB, &nState); |
| 720 |
|
| 721 |
ioctl_helper(IOCTL_SET_DACSDO, &nState); |
| 722 |
|
| 723 |
|
| 724 |
ioctl_helper(IOCTL_SET_RxDspEn, &State); |
| 725 |
ioctl_helper(IOCTL_SET_TxDspEn, &State); |
| 726 |
|
| 727 |
|
| 728 |
ioctl_helper(IOCTL_SET_RxIsSigned, &nState); |
| 729 |
ioctl_helper(IOCTL_SET_TxIsSigned, &nState); |
| 730 |
}; |
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
static int cdev_open(struct inode *inode, struct file *file) { |
| 736 |
int m; |
| 737 |
int i; |
| 738 |
int rc; |
| 739 |
|
| 740 |
mutex_lock(&cdev_open_close_mutex); |
| 741 |
printk(KERN_DEBUG DRIVER_NAME " File being opened...\n"); |
| 742 |
|
| 743 |
printk(KERN_DEBUG DRIVER_NAME " Checking device minor number...\n"); |
| 744 |
m = iminor(inode); |
| 745 |
if (m < 0) { |
| 746 |
printk(KERN_ERR DRIVER_NAME " Bad device minor number: %d\n", m); |
| 747 |
rc = -ENODEV; |
| 748 |
goto exit_func; |
| 749 |
}; |
| 750 |
printk(KERN_DEBUG DRIVER_NAME " File being opened with minor number: %d\n", m); |
| 751 |
|
| 752 |
if (DevPrivData->OpenCtr) { |
| 753 |
|
| 754 |
printk(KERN_DEBUG DRIVER_NAME " File already open, not redoing initialization routine...\n"); |
| 755 |
} else { |
| 756 |
|
| 757 |
printk(KERN_DEBUG DRIVER_NAME " Powering up device\n"); |
| 758 |
printk(KERN_DEBUG DRIVER_NAME " Allocating DMA buffers\n"); |
| 759 |
if ((rc = create_dma_buffs(&DevPrivData->pRxDmaBuffs, &DevPrivData->RxDmaBuffsBusAddr, DMARXBUFFS, DMABUFFSIZE, DMA_FROM_DEVICE))) { |
| 760 |
printk(KERN_ERR DRIVER_NAME " No memory for rx DMA buffers\n"); |
| 761 |
goto exit_func; |
| 762 |
}; |
| 763 |
if ((rc = create_dma_buffs(&DevPrivData->pTxDmaBuffs, &DevPrivData->TxDmaBuffsBusAddr, DMATXBUFFS, DMABUFFSIZE, DMA_TO_DEVICE))) { |
| 764 |
printk(KERN_ERR DRIVER_NAME " No memory for tx DMA buffers\n"); |
| 765 |
goto exit_destroy_dma_buffs_rx; |
| 766 |
}; |
| 767 |
|
| 768 |
printk(KERN_DEBUG DRIVER_NAME " Writing address translation table...\n"); |
| 769 |
for (i = 0; i < DMARXBUFFS; i++) { |
| 770 |
writel(DevPrivData->RxDmaBuffsBusAddr[i] & DevPrivData->BusTranslationMask, DevPrivData->pBar0 + CRA_ATT + i * 8); |
| 771 |
writel(0, DevPrivData->pBar0 + CRA_ATT + 4 + i * 8); |
| 772 |
mb(); |
| 773 |
printk(KERN_DEBUG DRIVER_NAME " Address translation table entry %d: 0x%08x\n", i, readl(DevPrivData->pBar0 + CRA_ATT + i * 8)); |
| 774 |
}; |
| 775 |
for (i = 0; i < DMATXBUFFS; i++) { |
| 776 |
writel(DevPrivData->TxDmaBuffsBusAddr[i] & DevPrivData->BusTranslationMask, DevPrivData->pBar0 + CRA_ATT + (i + DMARXBUFFS) * 8); |
| 777 |
writel(0, DevPrivData->pBar0 + CRA_ATT + 4 + (i + DMARXBUFFS) * 8); |
| 778 |
mb(); |
| 779 |
printk(KERN_DEBUG DRIVER_NAME " Address translation table entry %d: 0x%08x\n", i, readl(DevPrivData->pBar0 + CRA_ATT + (i + DMARXBUFFS) * 8)); |
| 780 |
}; |
| 781 |
printk(KERN_DEBUG DRIVER_NAME " Address translation table written"); |
| 782 |
|
| 783 |
printk(KERN_DEBUG DRIVER_NAME " Allocating character device buffers...\n"); |
| 784 |
if (!(cdev_read_buff = vmalloc(CDEVBUFFSIZE))) { |
| 785 |
printk(KERN_ERR DRIVER_NAME " Cannot create character device read buffer, not enough memory?\n"); |
| 786 |
rc = -ENOMEM; |
| 787 |
goto exit_destroy_dma_buffs_tx; |
| 788 |
}; |
| 789 |
cdev_read_buff_start = cdev_read_buff_end = 0; |
| 790 |
if (!(cdev_write_buff = vmalloc(CDEVBUFFSIZE))) { |
| 791 |
printk(KERN_ERR DRIVER_NAME " Cannot create character device write buffer, not enough memory?\n"); |
| 792 |
rc = -ENOMEM; |
| 793 |
goto exit_vfree_cdev_read_buff; |
| 794 |
}; |
| 795 |
cdev_write_buff_start = cdev_write_buff_end = 0; |
| 796 |
printk(KERN_DEBUG DRIVER_NAME " Read buffer: %p, write buffer: %p\n", cdev_read_buff, cdev_write_buff); |
| 797 |
|
| 798 |
printk(KERN_DEBUG DRIVER_NAME " Turning on ADCs and DACs\n"); |
| 799 |
PowerPeriph(1); |
| 800 |
|
| 801 |
printk(KERN_DEBUG DRIVER_NAME " Spawning read and write threads\n"); |
| 802 |
dev_read_thread = kthread_run(dev_read_task, 0, DRIVER_NAME); |
| 803 |
if (IS_ERR(dev_read_thread)) { |
| 804 |
printk(KERN_ERR DRIVER_NAME " Unable to start read thread: 0x%016llx\n", (uint64_t) dev_read_thread); |
| 805 |
rc = -ECHILD; |
| 806 |
goto exit_power_down; |
| 807 |
}; |
| 808 |
dev_write_thread = kthread_run(dev_write_task, 0, DRIVER_NAME); |
| 809 |
if (IS_ERR(dev_write_thread)) { |
| 810 |
printk(KERN_ERR DRIVER_NAME " Unable to start write thread: 0x%016llx\n", (uint64_t) dev_write_thread); |
| 811 |
rc = -ECHILD; |
| 812 |
goto exit_stop_read_thread; |
| 813 |
}; |
| 814 |
printk(KERN_DEBUG DRIVER_NAME " Device powered up\n"); |
| 815 |
}; |
| 816 |
|
| 817 |
DevPrivData->OpenCtr++; |
| 818 |
printk(KERN_DEBUG DRIVER_NAME " Device has %d handles open\n", DevPrivData->OpenCtr); |
| 819 |
printk(KERN_DEBUG DRIVER_NAME " File opened successfully\n"); |
| 820 |
mutex_unlock(&cdev_open_close_mutex); |
| 821 |
return nonseekable_open(inode, file); |
| 822 |
|
| 823 |
|
| 824 |
exit_stop_read_thread: |
| 825 |
kthread_stop(dev_read_thread); |
| 826 |
exit_power_down: |
| 827 |
PowerPeriph(0); |
| 828 |
vfree(cdev_write_buff); |
| 829 |
exit_vfree_cdev_read_buff: |
| 830 |
vfree(cdev_read_buff); |
| 831 |
exit_destroy_dma_buffs_tx: |
| 832 |
destroy_dma_buffs(&DevPrivData->pTxDmaBuffs, &DevPrivData->RxDmaBuffsBusAddr, DMATXBUFFS, DMABUFFSIZE, DMA_TO_DEVICE); |
| 833 |
exit_destroy_dma_buffs_rx: |
| 834 |
destroy_dma_buffs(&DevPrivData->pRxDmaBuffs, &DevPrivData->RxDmaBuffsBusAddr, DMARXBUFFS, DMABUFFSIZE, DMA_FROM_DEVICE); |
| 835 |
exit_func: |
| 836 |
printk(KERN_ERR DRIVER_NAME " File open failed: %d\n", rc); |
| 837 |
return rc; |
| 838 |
}; |
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
static int cdev_release(struct inode *inode, struct file *file) { |
| 844 |
int m; |
| 845 |
int rc; |
| 846 |
|
| 847 |
mutex_lock(&cdev_open_close_mutex); |
| 848 |
|
| 849 |
|
| 850 |
printk(KERN_DEBUG DRIVER_NAME " File being closed...\n"); |
| 851 |
m = iminor(inode); |
| 852 |
if (m < 0) { |
| 853 |
printk(KERN_ERR DRIVER_NAME " Bad device minor number: %d...\n", m); |
| 854 |
rc = -ENODEV; |
| 855 |
goto exit_func; |
| 856 |
}; |
| 857 |
printk(KERN_DEBUG DRIVER_NAME " File being closed with minor number: %d\n", m); |
| 858 |
|
| 859 |
if (DevPrivData->OpenCtr > 1) { |
| 860 |
|
| 861 |
printk(KERN_DEBUG DRIVER_NAME " File still open by other processes, not shutting down device...\n"); |
| 862 |
} else { |
| 863 |
|
| 864 |
printk(KERN_DEBUG DRIVER_NAME " Shutting down device\n"); |
| 865 |
printk(KERN_DEBUG DRIVER_NAME " Stopping read and write threads...\n"); |
| 866 |
kthread_stop(dev_read_thread); |
| 867 |
kthread_stop(dev_write_thread); |
| 868 |
printk(KERN_DEBUG DRIVER_NAME " Turning off ADCs and DACs\n"); |
| 869 |
PowerPeriph(0); |
| 870 |
printk(KERN_DEBUG DRIVER_NAME " Freeing character device buffers...\n"); |
| 871 |
vfree(cdev_write_buff); |
| 872 |
vfree(cdev_read_buff); |
| 873 |
printk(KERN_DEBUG DRIVER_NAME " Freeing rx and tx buffers...\n"); |
| 874 |
destroy_dma_buffs(&DevPrivData->pTxDmaBuffs, &DevPrivData->TxDmaBuffsBusAddr, DMATXBUFFS, DMABUFFSIZE, DMA_TO_DEVICE); |
| 875 |
destroy_dma_buffs(&DevPrivData->pRxDmaBuffs, &DevPrivData->RxDmaBuffsBusAddr, DMARXBUFFS, DMABUFFSIZE, DMA_FROM_DEVICE); |
| 876 |
printk(KERN_DEBUG DRIVER_NAME " Device shut down\n"); |
| 877 |
}; |
| 878 |
|
| 879 |
DevPrivData->OpenCtr--; |
| 880 |
printk(KERN_DEBUG DRIVER_NAME " Device has %d handles open\n", DevPrivData->OpenCtr); |
| 881 |
printk(KERN_DEBUG DRIVER_NAME " File closed\n"); |
| 882 |
mutex_unlock(&cdev_open_close_mutex); |
| 883 |
|
| 884 |
return 0; |
| 885 |
|
| 886 |
|
| 887 |
exit_func: |
| 888 |
printk(KERN_ERR DRIVER_NAME " File close failed: %d\n", rc); |
| 889 |
return rc; |
| 890 |
}; |
| 891 |
|
| 892 |
|
| 893 |
static const struct file_operations cdev_fops = { |
| 894 |
.owner = THIS_MODULE, |
| 895 |
.write = cdev_write, |
| 896 |
.read = cdev_read, |
| 897 |
.unlocked_ioctl = cdev_ioctl, |
| 898 |
.open = cdev_open, |
| 899 |
.release = cdev_release, |
| •900 |
#if LINUX_VERSION_CODE <= KERNEL_VERSION(6,0,0) |
| 901 |
.llseek = no_llseek |
| •902 |
#endif |
| 903 |
}; |
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
static void reset_dma(void) { |
| 909 |
printk(KERN_DEBUG DRIVER_NAME " Resetting DMA controllers...\n"); |
| 910 |
writel(CSR_CTRL_RESET, DevPrivData->pBar1 + WRCSRCTRL); |
| 911 |
writel(CSR_CTRL_RESET, DevPrivData->pBar1 + RDCSRCTRL); |
| 912 |
wmb(); |
| 913 |
|
| 914 |
while (readl(DevPrivData->pBar1 + WRCSRSTAT) & CSR_STAT_RESETTING) { |
| 915 |
rmb(); |
| 916 |
printk(KERN_DEBUG DRIVER_NAME " Waiting for Rx reset to complete\n"); |
| 917 |
}; |
| 918 |
while (readl(DevPrivData->pBar1 + RDCSRSTAT) & CSR_STAT_RESETTING) { |
| 919 |
rmb(); |
| 920 |
printk(KERN_DEBUG DRIVER_NAME " Waiting for Tx reset to complete\n"); |
| 921 |
}; |
| 922 |
printk(KERN_DEBUG DRIVER_NAME " DMA controllers reset\n"); |
| 923 |
}; |
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| •930 |
static int driver_probe(struct pci_dev *dev, const struct pci_device_id *id) { |
| 931 |
int rc; |
| 932 |
|
| 933 |
printk(KERN_INFO DRIVER_NAME " Probing and setting up device...\n"); |
| 934 |
|
| 935 |
|
| 936 |
printk(KERN_DEBUG DRIVER_NAME " Enabling device...\n"); |
| 937 |
rc = pci_enable_device(dev); |
| 938 |
if (rc) { |
| 939 |
printk(KERN_ERR DRIVER_NAME " Cannot enable device: %d\n", rc); |
| 940 |
goto exit_func; |
| 941 |
}; |
| 942 |
printk(KERN_DEBUG DRIVER_NAME " Device enabled\n"); |
| 943 |
|
| 944 |
|
| 945 |
printk(KERN_DEBUG DRIVER_NAME " Allocating memory for device settings...\n"); |
| 946 |
if (!(DevPrivData = kmalloc(sizeof(DevPrivDataType), GFP_KERNEL))) { |
| 947 |
printk(KERN_ERR DRIVER_NAME " No memory available\n"); |
| 948 |
rc = -ENOMEM; |
| 949 |
goto exit_pci_disable_device; |
| 950 |
}; |
| 951 |
dev_set_drvdata(&dev->dev, DevPrivData); |
| 952 |
DevPrivData->dev = dev; |
| 953 |
printk(KERN_DEBUG DRIVER_NAME " Memory for device settings allocated\n"); |
| 954 |
|
| 955 |
|
| 956 |
printk(KERN_DEBUG DRIVER_NAME " Checking device version...\n"); |
| 957 |
DevPrivData->DevVer = 0; |
| 958 |
pci_read_config_byte(dev, PCI_REVISION_ID, (u8*)&DevPrivData->DevVer); |
| 959 |
if (DevPrivData->DevVer != 1) { |
| 960 |
printk(KERN_ERR DRIVER_NAME " Device version not supported: %d\n", DevPrivData->DevVer); |
| 961 |
rc = -ENODEV; |
| 962 |
goto exit_kfree_priv_data; |
| 963 |
}; |
| 964 |
printk(KERN_DEBUG DRIVER_NAME " Device version: %d\n", DevPrivData->DevVer); |
| 965 |
|
| 966 |
|
| 967 |
printk(KERN_DEBUG DRIVER_NAME " Requesting and checking BAR regions...\n"); |
| 968 |
|
| 969 |
rc = pci_request_region(dev, 0, DRIVER_NAME); |
| 970 |
if (rc) { |
| 971 |
printk(KERN_ERR DRIVER_NAME " Unable to grab BAR0: %d\n", rc); |
| 972 |
goto exit_kfree_priv_data; |
| 973 |
}; |
| 974 |
|
| 975 |
if (!(pci_resource_flags(dev, 0) & IORESOURCE_MEM)) { |
| 976 |
printk(KERN_ERR DRIVER_NAME " Device's BAR0 is not an memory space\n"); |
| 977 |
rc = -ENODEV; |
| 978 |
goto exit_pci_release_regions; |
| 979 |
}; |
| 980 |
printk(KERN_DEBUG DRIVER_NAME " BAR0: 0x%08x\n", (uint32_t)pci_resource_start(dev, 0)); |
| 981 |
|
| 982 |
rc = pci_request_region(dev, 1, DRIVER_NAME); |
| 983 |
if (rc) { |
| 984 |
printk(KERN_ERR DRIVER_NAME " Unable to grab BAR1: %d\n", rc); |
| 985 |
goto exit_pci_release_regions; |
| 986 |
}; |
| 987 |
|
| 988 |
if (!(pci_resource_flags(dev, 1) & IORESOURCE_MEM)) { |
| 989 |
printk(KERN_ERR DRIVER_NAME " Device's BAR1 is not an memory space\n"); |
| 990 |
rc = -ENODEV; |
| 991 |
goto exit_pci_release_regions; |
| 992 |
}; |
| 993 |
printk(KERN_DEBUG DRIVER_NAME " BAR0: 0x%08x\n", (uint32_t)pci_resource_start(dev, 0)); |
| 994 |
printk(KERN_DEBUG DRIVER_NAME " BAR regions are OK"); |
| 995 |
|
| 996 |
|
| 997 |
printk(KERN_DEBUG DRIVER_NAME " Mapping BARs to memory addresses...\n"); |
| 998 |
if (!(DevPrivData->pBar0 = pci_iomap(dev, 0, 0))) { |
| 999 |
printk(KERN_ERR DRIVER_NAME " Cannot map BAR0 to a memory address\n"); |
| 1000 |
rc = -ENODEV; |
| 1001 |
goto exit_pci_release_regions; |
| 1002 |
}; |
| 1003 |
printk(KERN_DEBUG DRIVER_NAME " BAR0 accessible through memory address: 0x%016llx\n", (int64_t)DevPrivData->pBar0); |
| 1004 |
if (!(DevPrivData->pBar1 = pci_iomap(dev, 1, 0))) { |
| 1005 |
printk(KERN_ERR DRIVER_NAME " Cannot map BAR1 to a memory address\n"); |
| 1006 |
rc = -ENODEV; |
| 1007 |
goto exit_pci_iounmap_0; |
| 1008 |
}; |
| 1009 |
printk(KERN_DEBUG DRIVER_NAME " BAR1 accessible through memory address: 0x%016llx\n", (int64_t)DevPrivData->pBar1); |
| 1010 |
printk(KERN_DEBUG DRIVER_NAME " BAR regions are mapped to memory addresses\n"); |
| 1011 |
|
| 1012 |
|
| 1013 |
printk(KERN_DEBUG DRIVER_NAME " Setting DMA mask for 32bit operation...\n"); |
| 1014 |
pci_set_master(dev); |
| 1015 |
if (dma_set_mask(&(dev->dev), DMA_BIT_MASK(32))) { |
| 1016 |
printk(KERN_ERR DRIVER_NAME " Failed to set DMA mask\n"); |
| 1017 |
rc = -ENODEV; |
| 1018 |
goto exit_pci_iounmap_1; |
| 1019 |
}; |
| 1020 |
printk(KERN_DEBUG DRIVER_NAME " DMA mask set\n"); |
| 1021 |
|
| 1022 |
|
| 1023 |
printk(KERN_DEBUG DRIVER_NAME " Determining bus translation mask...\n"); |
| 1024 |
writel(0xfffffffc, DevPrivData->pBar0 + CRA_ATT); |
| 1025 |
mb(); |
| 1026 |
DevPrivData->BusTranslationMask = readl(DevPrivData->pBar0 + CRA_ATT); |
| 1027 |
printk(KERN_DEBUG DRIVER_NAME " Bus translation mask: 0x%016llx...\n", (uint64_t)DevPrivData->BusTranslationMask); |
| 1028 |
reset_dma(); |
| 1029 |
|
| 1030 |
|
| 1031 |
printk(KERN_DEBUG DRIVER_NAME " Turning off ADCs and DACs\n"); |
| 1032 |
PowerPeriph(0); |
| 1033 |
|
| 1034 |
printk(KERN_INFO DRIVER_NAME " Probing complete\n"); |
| 1035 |
return 0; |
| 1036 |
|
| 1037 |
|
| 1038 |
exit_pci_iounmap_1: |
| 1039 |
pci_iounmap(dev, DevPrivData->pBar1); |
| 1040 |
exit_pci_iounmap_0: |
| 1041 |
pci_iounmap(dev, DevPrivData->pBar0); |
| 1042 |
exit_pci_release_regions: |
| 1043 |
pci_release_regions(dev); |
| 1044 |
exit_kfree_priv_data: |
| 1045 |
kfree(DevPrivData); |
| 1046 |
exit_pci_disable_device: |
| 1047 |
pci_disable_device(dev); |
| 1048 |
exit_func: |
| 1049 |
printk(KERN_ERR DRIVER_NAME " Probe and setup failed: %d\n", rc); |
| 1050 |
return rc; |
| 1051 |
}; |
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
|
| •1058 |
static void driver_remove(struct pci_dev *dev) { |
| 1059 |
printk(KERN_INFO DRIVER_NAME " Removing device...\n"); |
| 1060 |
reset_dma(); |
| 1061 |
pci_iounmap(dev, DevPrivData->pBar1); |
| 1062 |
pci_iounmap(dev, DevPrivData->pBar0); |
| 1063 |
pci_release_regions(dev); |
| 1064 |
kfree(DevPrivData); |
| 1065 |
pci_disable_device(dev); |
| 1066 |
printk(KERN_INFO DRIVER_NAME " Device removed\n"); |
| 1067 |
}; |
| 1068 |
|
| 1069 |
|
| 1070 |
static const struct pci_device_id driver_ids[] = { |
| 1071 |
{ PCI_DEVICE(0x1172, 0x0004), }, |
| 1072 |
{ 0, } |
| 1073 |
}; |
| 1074 |
MODULE_DEVICE_TABLE(pci, driver_ids); |
| 1075 |
|
| 1076 |
|
| 1077 |
static struct pci_driver driver_pci_driver = { |
| 1078 |
.name = DRIVER_NAME, |
| 1079 |
.id_table = driver_ids, |
| 1080 |
.probe = driver_probe, |
| •1081 |
.remove = driver_remove, |
| 1082 |
}; |
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 |
|
| 1089 |
static int __init driver_initial(void) { |
| 1090 |
int rc; |
| 1091 |
|
| •1092 |
printk(KERN_INFO DRIVER_NAME " Loading... (version 2013-02-28)\n"); |
| 1093 |
rc = pci_register_driver(&driver_pci_driver); |
| 1094 |
if (rc) { |
| 1095 |
goto exit_func; |
| 1096 |
}; |
| 1097 |
|
| 1098 |
|
| 1099 |
printk(KERN_DEBUG DRIVER_NAME " Allocating character device...\n"); |
| 1100 |
rc = alloc_chrdev_region(&cdev, 0, 1, DRIVER_NAME); |
| 1101 |
if (rc < 0) { |
| 1102 |
printk(KERN_ERR DRIVER_NAME " Error making character device\n"); |
| 1103 |
goto exit_pci_unregister_driver; |
| 1104 |
}; |
| 1105 |
printk(KERN_DEBUG DRIVER_NAME " Charater device allocated (major: %d, minor: %d)\n", MAJOR(cdev), MINOR(cdev)); |
| 1106 |
printk(KERN_DEBUG DRIVER_NAME " Initializing and adding character device...\n"); |
| 1107 |
cdev_init(&driver_cdev, &cdev_fops); |
| 1108 |
rc = cdev_add(&driver_cdev, cdev, 1); |
| 1109 |
if (rc < 0) { |
| 1110 |
printk(KERN_ERR DRIVER_NAME " Cannot add character device: %d\n", rc); |
| 1111 |
goto exit_unregister_chrdev; |
| 1112 |
}; |
| 1113 |
if (DevPrivData) { DevPrivData->OpenCtr = 0; }; |
| 1114 |
printk(KERN_INFO DRIVER_NAME " To make file system device, run mknod %s c %d %d\n", DRIVER_NAME, MAJOR(cdev), MINOR(cdev)); |
| 1115 |
printk(KERN_DEBUG DRIVER_NAME " Character device added\n"); |
| 1116 |
|
| 1117 |
printk(KERN_INFO DRIVER_NAME " Loaded\n"); |
| 1118 |
return 0; |
| 1119 |
|
| 1120 |
|
| 1121 |
exit_unregister_chrdev: |
| 1122 |
unregister_chrdev_region(cdev, 1); |
| 1123 |
exit_pci_unregister_driver: |
| 1124 |
pci_unregister_driver(&driver_pci_driver); |
| 1125 |
exit_func: |
| 1126 |
printk(KERN_ERR DRIVER_NAME " Loading failed: %d\n", rc); |
| 1127 |
return rc; |
| 1128 |
}; |
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
static void __exit driver_exit(void) { |
| 1136 |
printk(KERN_INFO DRIVER_NAME " Unloading...\n"); |
| 1137 |
cdev_del(&driver_cdev); |
| 1138 |
unregister_chrdev_region(cdev, 1); |
| 1139 |
pci_unregister_driver(&driver_pci_driver); |
| 1140 |
printk(KERN_INFO DRIVER_NAME " Unloaded\n"); |
| 1141 |
}; |
| 1142 |
|
| 1143 |
|
| 1144 |
MODULE_LICENSE("GPL"); |
| 1145 |
|
| 1146 |
|
| 1147 |
module_init(driver_initial); |
| 1148 |
module_exit(driver_exit); |