1 /* 2 * 3 * mwavedd.c -- mwave device driver 4 * 5 * 6 * Written By: Mike Sullivan IBM Corporation 7 * 8 * Copyright (C) 1999 IBM Corporation 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * NO WARRANTY 21 * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 22 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 23 * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 24 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 25 * solely responsible for determining the appropriateness of using and 26 * distributing the Program and assumes all risks associated with its 27 * exercise of rights under this Agreement, including but not limited to 28 * the risks and costs of program errors, damage to or loss of data, 29 * programs or equipment, and unavailability or interruption of operations. 30 * 31 * DISCLAIMER OF LIABILITY 32 * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 33 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 34 * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 37 * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 38 * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 39 * 40 * You should have received a copy of the GNU General Public License 41 * along with this program; if not, write to the Free Software 42 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 43 * 44 * 45 * 10/23/2000 - Alpha Release 46 * First release to the public 47 */ 48 49 #include <linux/module.h> 50 #include <linux/kernel.h> 51 #include <linux/fs.h> 52 #include <linux/init.h> 53 #include <linux/major.h> 54 #include <linux/miscdevice.h> 55 #include <linux/device.h> 56 #include <linux/serial.h> 57 #include <linux/sched.h> 58 #include <linux/spinlock.h> 59 #include <linux/smp_lock.h> 60 #include <linux/delay.h> 61 #include <linux/serial_8250.h> 62 #include "smapi.h" 63 #include "mwavedd.h" 64 #include "3780i.h" 65 #include "tp3780i.h" 66 67 MODULE_DESCRIPTION("3780i Advanced Communications Processor (Mwave) driver"); 68 MODULE_AUTHOR("Mike Sullivan and Paul Schroeder"); 69 MODULE_LICENSE("GPL"); 70 71 /* 72 * These parameters support the setting of MWave resources. Note that no 73 * checks are made against other devices (ie. superio) for conflicts. 74 * We'll depend on users using the tpctl utility to do that for now 75 */ 76 int mwave_debug = 0; 77 int mwave_3780i_irq = 0; 78 int mwave_3780i_io = 0; 79 int mwave_uart_irq = 0; 80 int mwave_uart_io = 0; 81 module_param(mwave_debug, int, 0); 82 module_param(mwave_3780i_irq, int, 0); 83 module_param(mwave_3780i_io, int, 0); 84 module_param(mwave_uart_irq, int, 0); 85 module_param(mwave_uart_io, int, 0); 86 87 static int mwave_open(struct inode *inode, struct file *file); 88 static int mwave_close(struct inode *inode, struct file *file); 89 static int mwave_ioctl(struct inode *inode, struct file *filp, 90 unsigned int iocmd, unsigned long ioarg); 91 92 MWAVE_DEVICE_DATA mwave_s_mdd; 93 94 static int mwave_open(struct inode *inode, struct file *file) 95 { 96 unsigned int retval = 0; 97 98 PRINTK_3(TRACE_MWAVE, 99 "mwavedd::mwave_open, entry inode %p file %p\n", 100 inode, file); 101 PRINTK_2(TRACE_MWAVE, 102 "mwavedd::mwave_open, exit return retval %x\n", retval); 103 104 cycle_kernel_lock(); 105 return retval; 106 } 107 108 static int mwave_close(struct inode *inode, struct file *file) 109 { 110 unsigned int retval = 0; 111 112 PRINTK_3(TRACE_MWAVE, 113 "mwavedd::mwave_close, entry inode %p file %p\n", 114 inode, file); 115 116 PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_close, exit retval %x\n", 117 retval); 118 119 return retval; 120 } 121 122 static int mwave_ioctl(struct inode *inode, struct file *file, 123 unsigned int iocmd, unsigned long ioarg) 124 { 125 unsigned int retval = 0; 126 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; 127 void __user *arg = (void __user *)ioarg; 128 129 PRINTK_5(TRACE_MWAVE, 130 "mwavedd::mwave_ioctl, entry inode %p file %p cmd %x arg %x\n", 131 inode, file, iocmd, (int) ioarg); 132 133 switch (iocmd) { 134 135 case IOCTL_MW_RESET: 136 PRINTK_1(TRACE_MWAVE, 137 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 138 " calling tp3780I_ResetDSP\n"); 139 retval = tp3780I_ResetDSP(&pDrvData->rBDData); 140 PRINTK_2(TRACE_MWAVE, 141 "mwavedd::mwave_ioctl, IOCTL_MW_RESET" 142 " retval %x from tp3780I_ResetDSP\n", 143 retval); 144 break; 145 146 case IOCTL_MW_RUN: 147 PRINTK_1(TRACE_MWAVE, 148 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 149 " calling tp3780I_StartDSP\n"); 150 retval = tp3780I_StartDSP(&pDrvData->rBDData); 151 PRINTK_2(TRACE_MWAVE, 152 "mwavedd::mwave_ioctl, IOCTL_MW_RUN" 153 " retval %x from tp3780I_StartDSP\n", 154 retval); 155 break; 156 157 case IOCTL_MW_DSP_ABILITIES: { 158 MW_ABILITIES rAbilities; 159 160 PRINTK_1(TRACE_MWAVE, 161 "mwavedd::mwave_ioctl," 162 " IOCTL_MW_DSP_ABILITIES calling" 163 " tp3780I_QueryAbilities\n"); 164 retval = tp3780I_QueryAbilities(&pDrvData->rBDData, 165 &rAbilities); 166 PRINTK_2(TRACE_MWAVE, 167 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" 168 " retval %x from tp3780I_QueryAbilities\n", 169 retval); 170 if (retval == 0) { 171 if( copy_to_user(arg, &rAbilities, 172 sizeof(MW_ABILITIES)) ) 173 return -EFAULT; 174 } 175 PRINTK_2(TRACE_MWAVE, 176 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES" 177 " exit retval %x\n", 178 retval); 179 } 180 break; 181 182 case IOCTL_MW_READ_DATA: 183 case IOCTL_MW_READCLEAR_DATA: { 184 MW_READWRITE rReadData; 185 unsigned short __user *pusBuffer = NULL; 186 187 if( copy_from_user(&rReadData, arg, 188 sizeof(MW_READWRITE)) ) 189 return -EFAULT; 190 pusBuffer = (unsigned short __user *) (rReadData.pBuf); 191 192 PRINTK_4(TRACE_MWAVE, 193 "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA," 194 " size %lx, ioarg %lx pusBuffer %p\n", 195 rReadData.ulDataLength, ioarg, pusBuffer); 196 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 197 iocmd, 198 pusBuffer, 199 rReadData.ulDataLength, 200 rReadData.usDspAddress); 201 } 202 break; 203 204 case IOCTL_MW_READ_INST: { 205 MW_READWRITE rReadData; 206 unsigned short __user *pusBuffer = NULL; 207 208 if( copy_from_user(&rReadData, arg, 209 sizeof(MW_READWRITE)) ) 210 return -EFAULT; 211 pusBuffer = (unsigned short __user *) (rReadData.pBuf); 212 213 PRINTK_4(TRACE_MWAVE, 214 "mwavedd::mwave_ioctl IOCTL_MW_READ_INST," 215 " size %lx, ioarg %lx pusBuffer %p\n", 216 rReadData.ulDataLength / 2, ioarg, 217 pusBuffer); 218 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 219 iocmd, pusBuffer, 220 rReadData.ulDataLength / 2, 221 rReadData.usDspAddress); 222 } 223 break; 224 225 case IOCTL_MW_WRITE_DATA: { 226 MW_READWRITE rWriteData; 227 unsigned short __user *pusBuffer = NULL; 228 229 if( copy_from_user(&rWriteData, arg, 230 sizeof(MW_READWRITE)) ) 231 return -EFAULT; 232 pusBuffer = (unsigned short __user *) (rWriteData.pBuf); 233 234 PRINTK_4(TRACE_MWAVE, 235 "mwavedd::mwave_ioctl IOCTL_MW_WRITE_DATA," 236 " size %lx, ioarg %lx pusBuffer %p\n", 237 rWriteData.ulDataLength, ioarg, 238 pusBuffer); 239 retval = tp3780I_ReadWriteDspDStore(&pDrvData->rBDData, 240 iocmd, pusBuffer, 241 rWriteData.ulDataLength, 242 rWriteData.usDspAddress); 243 } 244 break; 245 246 case IOCTL_MW_WRITE_INST: { 247 MW_READWRITE rWriteData; 248 unsigned short __user *pusBuffer = NULL; 249 250 if( copy_from_user(&rWriteData, arg, 251 sizeof(MW_READWRITE)) ) 252 return -EFAULT; 253 pusBuffer = (unsigned short __user *)(rWriteData.pBuf); 254 255 PRINTK_4(TRACE_MWAVE, 256 "mwavedd::mwave_ioctl IOCTL_MW_WRITE_INST," 257 " size %lx, ioarg %lx pusBuffer %p\n", 258 rWriteData.ulDataLength, ioarg, 259 pusBuffer); 260 retval = tp3780I_ReadWriteDspIStore(&pDrvData->rBDData, 261 iocmd, pusBuffer, 262 rWriteData.ulDataLength, 263 rWriteData.usDspAddress); 264 } 265 break; 266 267 case IOCTL_MW_REGISTER_IPC: { 268 unsigned int ipcnum = (unsigned int) ioarg; 269 270 PRINTK_3(TRACE_MWAVE, 271 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" 272 " ipcnum %x entry usIntCount %x\n", 273 ipcnum, 274 pDrvData->IPCs[ipcnum].usIntCount); 275 276 if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) { 277 PRINTK_ERROR(KERN_ERR_MWAVE 278 "mwavedd::mwave_ioctl:" 279 " IOCTL_MW_REGISTER_IPC:" 280 " Error: Invalid ipcnum %x\n", 281 ipcnum); 282 return -EINVAL; 283 } 284 pDrvData->IPCs[ipcnum].bIsHere = FALSE; 285 pDrvData->IPCs[ipcnum].bIsEnabled = TRUE; 286 287 PRINTK_2(TRACE_MWAVE, 288 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC" 289 " ipcnum %x exit\n", 290 ipcnum); 291 } 292 break; 293 294 case IOCTL_MW_GET_IPC: { 295 unsigned int ipcnum = (unsigned int) ioarg; 296 297 PRINTK_3(TRACE_MWAVE, 298 "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC" 299 " ipcnum %x, usIntCount %x\n", 300 ipcnum, 301 pDrvData->IPCs[ipcnum].usIntCount); 302 if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) { 303 PRINTK_ERROR(KERN_ERR_MWAVE 304 "mwavedd::mwave_ioctl:" 305 " IOCTL_MW_GET_IPC: Error:" 306 " Invalid ipcnum %x\n", ipcnum); 307 return -EINVAL; 308 } 309 310 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 311 DECLARE_WAITQUEUE(wait, current); 312 313 PRINTK_2(TRACE_MWAVE, 314 "mwavedd::mwave_ioctl, thread for" 315 " ipc %x going to sleep\n", 316 ipcnum); 317 add_wait_queue(&pDrvData->IPCs[ipcnum].ipc_wait_queue, &wait); 318 pDrvData->IPCs[ipcnum].bIsHere = TRUE; 319 set_current_state(TASK_INTERRUPTIBLE); 320 /* check whether an event was signalled by */ 321 /* the interrupt handler while we were gone */ 322 if (pDrvData->IPCs[ipcnum].usIntCount == 1) { /* first int has occurred (race condition) */ 323 pDrvData->IPCs[ipcnum].usIntCount = 2; /* first int has been handled */ 324 PRINTK_2(TRACE_MWAVE, 325 "mwavedd::mwave_ioctl" 326 " IOCTL_MW_GET_IPC ipcnum %x" 327 " handling first int\n", 328 ipcnum); 329 } else { /* either 1st int has not yet occurred, or we have already handled the first int */ 330 schedule(); 331 if (pDrvData->IPCs[ipcnum].usIntCount == 1) { 332 pDrvData->IPCs[ipcnum].usIntCount = 2; 333 } 334 PRINTK_2(TRACE_MWAVE, 335 "mwavedd::mwave_ioctl" 336 " IOCTL_MW_GET_IPC ipcnum %x" 337 " woke up and returning to" 338 " application\n", 339 ipcnum); 340 } 341 pDrvData->IPCs[ipcnum].bIsHere = FALSE; 342 remove_wait_queue(&pDrvData->IPCs[ipcnum].ipc_wait_queue, &wait); 343 set_current_state(TASK_RUNNING); 344 PRINTK_2(TRACE_MWAVE, 345 "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC," 346 " returning thread for ipc %x" 347 " processing\n", 348 ipcnum); 349 } 350 } 351 break; 352 353 case IOCTL_MW_UNREGISTER_IPC: { 354 unsigned int ipcnum = (unsigned int) ioarg; 355 356 PRINTK_2(TRACE_MWAVE, 357 "mwavedd::mwave_ioctl IOCTL_MW_UNREGISTER_IPC" 358 " ipcnum %x\n", 359 ipcnum); 360 if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) { 361 PRINTK_ERROR(KERN_ERR_MWAVE 362 "mwavedd::mwave_ioctl:" 363 " IOCTL_MW_UNREGISTER_IPC:" 364 " Error: Invalid ipcnum %x\n", 365 ipcnum); 366 return -EINVAL; 367 } 368 if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) { 369 pDrvData->IPCs[ipcnum].bIsEnabled = FALSE; 370 if (pDrvData->IPCs[ipcnum].bIsHere == TRUE) { 371 wake_up_interruptible(&pDrvData->IPCs[ipcnum].ipc_wait_queue); 372 } 373 } 374 } 375 break; 376 377 default: 378 PRINTK_ERROR(KERN_ERR_MWAVE "mwavedd::mwave_ioctl:" 379 " Error: Unrecognized iocmd %x\n", 380 iocmd); 381 return -ENOTTY; 382 break; 383 } /* switch */ 384 385 PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_ioctl, exit retval %x\n", retval); 386 387 return retval; 388 } 389 390 391 static ssize_t mwave_read(struct file *file, char __user *buf, size_t count, 392 loff_t * ppos) 393 { 394 PRINTK_5(TRACE_MWAVE, 395 "mwavedd::mwave_read entry file %p, buf %p, count %zx ppos %p\n", 396 file, buf, count, ppos); 397 398 return -EINVAL; 399 } 400 401 402 static ssize_t mwave_write(struct file *file, const char __user *buf, 403 size_t count, loff_t * ppos) 404 { 405 PRINTK_5(TRACE_MWAVE, 406 "mwavedd::mwave_write entry file %p, buf %p," 407 " count %zx ppos %p\n", 408 file, buf, count, ppos); 409 410 return -EINVAL; 411 } 412 413 414 static int register_serial_portandirq(unsigned int port, int irq) 415 { 416 struct uart_port uart; 417 418 switch ( port ) { 419 case 0x3f8: 420 case 0x2f8: 421 case 0x3e8: 422 case 0x2e8: 423 /* OK */ 424 break; 425 default: 426 PRINTK_ERROR(KERN_ERR_MWAVE 427 "mwavedd::register_serial_portandirq:" 428 " Error: Illegal port %x\n", port ); 429 return -1; 430 } /* switch */ 431 /* port is okay */ 432 433 switch ( irq ) { 434 case 3: 435 case 4: 436 case 5: 437 case 7: 438 /* OK */ 439 break; 440 default: 441 PRINTK_ERROR(KERN_ERR_MWAVE 442 "mwavedd::register_serial_portandirq:" 443 " Error: Illegal irq %x\n", irq ); 444 return -1; 445 } /* switch */ 446 /* irq is okay */ 447 448 memset(&uart, 0, sizeof(struct uart_port)); 449 450 uart.uartclk = 1843200; 451 uart.iobase = port; 452 uart.irq = irq; 453 uart.iotype = UPIO_PORT; 454 uart.flags = UPF_SHARE_IRQ; 455 return serial8250_register_port(&uart); 456 } 457 458 459 static const struct file_operations mwave_fops = { 460 .owner = THIS_MODULE, 461 .read = mwave_read, 462 .write = mwave_write, 463 .ioctl = mwave_ioctl, 464 .open = mwave_open, 465 .release = mwave_close 466 }; 467 468 469 static struct miscdevice mwave_misc_dev = { MWAVE_MINOR, "mwave", &mwave_fops }; 470 471 #if 0 /* totally b0rked */ 472 /* 473 * sysfs support <paulsch@us.ibm.com> 474 */ 475 476 struct device mwave_device; 477 478 /* Prevent code redundancy, create a macro for mwave_show_* functions. */ 479 #define mwave_show_function(attr_name, format_string, field) \ 480 static ssize_t mwave_show_##attr_name(struct device *dev, struct device_attribute *attr, char *buf) \ 481 { \ 482 DSP_3780I_CONFIG_SETTINGS *pSettings = \ 483 &mwave_s_mdd.rBDData.rDspSettings; \ 484 return sprintf(buf, format_string, pSettings->field); \ 485 } 486 487 /* All of our attributes are read attributes. */ 488 #define mwave_dev_rd_attr(attr_name, format_string, field) \ 489 mwave_show_function(attr_name, format_string, field) \ 490 static DEVICE_ATTR(attr_name, S_IRUGO, mwave_show_##attr_name, NULL) 491 492 mwave_dev_rd_attr (3780i_dma, "%i\n", usDspDma); 493 mwave_dev_rd_attr (3780i_irq, "%i\n", usDspIrq); 494 mwave_dev_rd_attr (3780i_io, "%#.4x\n", usDspBaseIO); 495 mwave_dev_rd_attr (uart_irq, "%i\n", usUartIrq); 496 mwave_dev_rd_attr (uart_io, "%#.4x\n", usUartBaseIO); 497 498 static struct device_attribute * const mwave_dev_attrs[] = { 499 &dev_attr_3780i_dma, 500 &dev_attr_3780i_irq, 501 &dev_attr_3780i_io, 502 &dev_attr_uart_irq, 503 &dev_attr_uart_io, 504 }; 505 #endif 506 507 /* 508 * mwave_init is called on module load 509 * 510 * mwave_exit is called on module unload 511 * mwave_exit is also used to clean up after an aborted mwave_init 512 */ 513 static void mwave_exit(void) 514 { 515 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; 516 517 PRINTK_1(TRACE_MWAVE, "mwavedd::mwave_exit entry\n"); 518 519 #if 0 520 for (i = 0; i < pDrvData->nr_registered_attrs; i++) 521 device_remove_file(&mwave_device, mwave_dev_attrs[i]); 522 pDrvData->nr_registered_attrs = 0; 523 524 if (pDrvData->device_registered) { 525 device_unregister(&mwave_device); 526 pDrvData->device_registered = FALSE; 527 } 528 #endif 529 530 if ( pDrvData->sLine >= 0 ) { 531 serial8250_unregister_port(pDrvData->sLine); 532 } 533 if (pDrvData->bMwaveDevRegistered) { 534 misc_deregister(&mwave_misc_dev); 535 } 536 if (pDrvData->bDSPEnabled) { 537 tp3780I_DisableDSP(&pDrvData->rBDData); 538 } 539 if (pDrvData->bResourcesClaimed) { 540 tp3780I_ReleaseResources(&pDrvData->rBDData); 541 } 542 if (pDrvData->bBDInitialized) { 543 tp3780I_Cleanup(&pDrvData->rBDData); 544 } 545 546 PRINTK_1(TRACE_MWAVE, "mwavedd::mwave_exit exit\n"); 547 } 548 549 module_exit(mwave_exit); 550 551 static int __init mwave_init(void) 552 { 553 int i; 554 int retval = 0; 555 pMWAVE_DEVICE_DATA pDrvData = &mwave_s_mdd; 556 557 PRINTK_1(TRACE_MWAVE, "mwavedd::mwave_init entry\n"); 558 559 memset(&mwave_s_mdd, 0, sizeof(MWAVE_DEVICE_DATA)); 560 561 pDrvData->bBDInitialized = FALSE; 562 pDrvData->bResourcesClaimed = FALSE; 563 pDrvData->bDSPEnabled = FALSE; 564 pDrvData->bDSPReset = FALSE; 565 pDrvData->bMwaveDevRegistered = FALSE; 566 pDrvData->sLine = -1; 567 568 for (i = 0; i < ARRAY_SIZE(pDrvData->IPCs); i++) { 569 pDrvData->IPCs[i].bIsEnabled = FALSE; 570 pDrvData->IPCs[i].bIsHere = FALSE; 571 pDrvData->IPCs[i].usIntCount = 0; /* no ints received yet */ 572 init_waitqueue_head(&pDrvData->IPCs[i].ipc_wait_queue); 573 } 574 575 retval = tp3780I_InitializeBoardData(&pDrvData->rBDData); 576 PRINTK_2(TRACE_MWAVE, 577 "mwavedd::mwave_init, return from tp3780I_InitializeBoardData" 578 " retval %x\n", 579 retval); 580 if (retval) { 581 PRINTK_ERROR(KERN_ERR_MWAVE 582 "mwavedd::mwave_init: Error:" 583 " Failed to initialize board data\n"); 584 goto cleanup_error; 585 } 586 pDrvData->bBDInitialized = TRUE; 587 588 retval = tp3780I_CalcResources(&pDrvData->rBDData); 589 PRINTK_2(TRACE_MWAVE, 590 "mwavedd::mwave_init, return from tp3780I_CalcResources" 591 " retval %x\n", 592 retval); 593 if (retval) { 594 PRINTK_ERROR(KERN_ERR_MWAVE 595 "mwavedd:mwave_init: Error:" 596 " Failed to calculate resources\n"); 597 goto cleanup_error; 598 } 599 600 retval = tp3780I_ClaimResources(&pDrvData->rBDData); 601 PRINTK_2(TRACE_MWAVE, 602 "mwavedd::mwave_init, return from tp3780I_ClaimResources" 603 " retval %x\n", 604 retval); 605 if (retval) { 606 PRINTK_ERROR(KERN_ERR_MWAVE 607 "mwavedd:mwave_init: Error:" 608 " Failed to claim resources\n"); 609 goto cleanup_error; 610 } 611 pDrvData->bResourcesClaimed = TRUE; 612 613 retval = tp3780I_EnableDSP(&pDrvData->rBDData); 614 PRINTK_2(TRACE_MWAVE, 615 "mwavedd::mwave_init, return from tp3780I_EnableDSP" 616 " retval %x\n", 617 retval); 618 if (retval) { 619 PRINTK_ERROR(KERN_ERR_MWAVE 620 "mwavedd:mwave_init: Error:" 621 " Failed to enable DSP\n"); 622 goto cleanup_error; 623 } 624 pDrvData->bDSPEnabled = TRUE; 625 626 if (misc_register(&mwave_misc_dev) < 0) { 627 PRINTK_ERROR(KERN_ERR_MWAVE 628 "mwavedd:mwave_init: Error:" 629 " Failed to register misc device\n"); 630 goto cleanup_error; 631 } 632 pDrvData->bMwaveDevRegistered = TRUE; 633 634 pDrvData->sLine = register_serial_portandirq( 635 pDrvData->rBDData.rDspSettings.usUartBaseIO, 636 pDrvData->rBDData.rDspSettings.usUartIrq 637 ); 638 if (pDrvData->sLine < 0) { 639 PRINTK_ERROR(KERN_ERR_MWAVE 640 "mwavedd:mwave_init: Error:" 641 " Failed to register serial driver\n"); 642 goto cleanup_error; 643 } 644 /* uart is registered */ 645 646 #if 0 647 /* sysfs */ 648 memset(&mwave_device, 0, sizeof (struct device)); 649 snprintf(mwave_device.bus_id, BUS_ID_SIZE, "mwave"); 650 651 if (device_register(&mwave_device)) 652 goto cleanup_error; 653 pDrvData->device_registered = TRUE; 654 for (i = 0; i < ARRAY_SIZE(mwave_dev_attrs); i++) { 655 if(device_create_file(&mwave_device, mwave_dev_attrs[i])) { 656 PRINTK_ERROR(KERN_ERR_MWAVE 657 "mwavedd:mwave_init: Error:" 658 " Failed to create sysfs file %s\n", 659 mwave_dev_attrs[i]->attr.name); 660 goto cleanup_error; 661 } 662 pDrvData->nr_registered_attrs++; 663 } 664 #endif 665 666 /* SUCCESS! */ 667 return 0; 668 669 cleanup_error: 670 PRINTK_ERROR(KERN_ERR_MWAVE 671 "mwavedd::mwave_init: Error:" 672 " Failed to initialize\n"); 673 mwave_exit(); /* clean up */ 674 675 return -EIO; 676 } 677 678 module_init(mwave_init); 679 680