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