49 #include <linux/module.h>
50 #include <linux/kernel.h>
55 #include <linux/device.h>
56 #include <linux/serial.h>
57 #include <linux/sched.h>
90 static long mwave_ioctl(
struct file *filp,
unsigned int iocmd,
100 "mwavedd::mwave_open, entry inode %p file %p\n",
103 "mwavedd::mwave_open, exit return retval %x\n", retval);
113 "mwavedd::mwave_close, entry inode %p file %p\n",
122 static long mwave_ioctl(
struct file *
file,
unsigned int iocmd,
130 "mwavedd::mwave_ioctl, entry file %p cmd %x arg %x\n",
131 file, iocmd, (
int) ioarg);
137 "mwavedd::mwave_ioctl, IOCTL_MW_RESET"
138 " calling tp3780I_ResetDSP\n");
143 "mwavedd::mwave_ioctl, IOCTL_MW_RESET"
144 " retval %x from tp3780I_ResetDSP\n",
150 "mwavedd::mwave_ioctl, IOCTL_MW_RUN"
151 " calling tp3780I_StartDSP\n");
156 "mwavedd::mwave_ioctl, IOCTL_MW_RUN"
157 " retval %x from tp3780I_StartDSP\n",
165 "mwavedd::mwave_ioctl,"
166 " IOCTL_MW_DSP_ABILITIES calling"
167 " tp3780I_QueryAbilities\n");
173 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES"
174 " retval %x from tp3780I_QueryAbilities\n",
182 "mwavedd::mwave_ioctl, IOCTL_MW_DSP_ABILITIES"
196 pusBuffer = (
unsigned short __user *) (rReadData.
pBuf);
199 "mwavedd::mwave_ioctl IOCTL_MW_READ_DATA,"
200 " size %lx, ioarg %lx pusBuffer %p\n",
219 pusBuffer = (
unsigned short __user *) (rReadData.
pBuf);
222 "mwavedd::mwave_ioctl IOCTL_MW_READ_INST,"
223 " size %lx, ioarg %lx pusBuffer %p\n",
242 pusBuffer = (
unsigned short __user *) (rWriteData.
pBuf);
245 "mwavedd::mwave_ioctl IOCTL_MW_WRITE_DATA,"
246 " size %lx, ioarg %lx pusBuffer %p\n",
265 pusBuffer = (
unsigned short __user *)(rWriteData.
pBuf);
268 "mwavedd::mwave_ioctl IOCTL_MW_WRITE_INST,"
269 " size %lx, ioarg %lx pusBuffer %p\n",
282 unsigned int ipcnum = (
unsigned int) ioarg;
286 "mwavedd::mwave_ioctl:"
287 " IOCTL_MW_REGISTER_IPC:"
288 " Error: Invalid ipcnum %x\n",
293 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC"
294 " ipcnum %x entry usIntCount %x\n",
304 "mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC"
311 unsigned int ipcnum = (
unsigned int) ioarg;
315 "mwavedd::mwave_ioctl:"
316 " IOCTL_MW_GET_IPC: Error:"
317 " Invalid ipcnum %x\n", ipcnum);
321 "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC"
322 " ipcnum %x, usIntCount %x\n",
331 "mwavedd::mwave_ioctl, thread for"
332 " ipc %x going to sleep\n",
342 "mwavedd::mwave_ioctl"
343 " IOCTL_MW_GET_IPC ipcnum %x"
344 " handling first int\n",
352 "mwavedd::mwave_ioctl"
353 " IOCTL_MW_GET_IPC ipcnum %x"
354 " woke up and returning to"
362 "mwavedd::mwave_ioctl IOCTL_MW_GET_IPC,"
363 " returning thread for ipc %x"
372 unsigned int ipcnum = (
unsigned int) ioarg;
375 "mwavedd::mwave_ioctl IOCTL_MW_UNREGISTER_IPC"
380 "mwavedd::mwave_ioctl:"
381 " IOCTL_MW_UNREGISTER_IPC:"
382 " Error: Invalid ipcnum %x\n",
408 static ssize_t mwave_read(
struct file *file,
char __user *
buf,
size_t count,
412 "mwavedd::mwave_read entry file %p, buf %p, count %zx ppos %p\n",
413 file, buf, count, ppos);
419 static ssize_t mwave_write(
struct file *file,
const char __user *
buf,
420 size_t count, loff_t * ppos)
423 "mwavedd::mwave_write entry file %p, buf %p,"
424 " count %zx ppos %p\n",
425 file, buf, count, ppos);
431 static int register_serial_portandirq(
unsigned int port,
int irq)
444 "mwavedd::register_serial_portandirq:"
445 " Error: Illegal port %x\n", port );
459 "mwavedd::register_serial_portandirq:"
460 " Error: Illegal irq %x\n", irq );
467 uart.port.uartclk = 1843200;
479 .write = mwave_write,
480 .unlocked_ioctl = mwave_ioctl,
482 .release = mwave_close,
494 struct device mwave_device;
497 #define mwave_show_function(attr_name, format_string, field) \
498 static ssize_t mwave_show_##attr_name(struct device *dev, struct device_attribute *attr, char *buf) \
500 DSP_3780I_CONFIG_SETTINGS *pSettings = \
501 &mwave_s_mdd.rBDData.rDspSettings; \
502 return sprintf(buf, format_string, pSettings->field); \
506 #define mwave_dev_rd_attr(attr_name, format_string, field) \
507 mwave_show_function(attr_name, format_string, field) \
508 static DEVICE_ATTR(attr_name, S_IRUGO, mwave_show_##attr_name, NULL)
510 mwave_dev_rd_attr (3780i_dma,
"%i\n", usDspDma);
511 mwave_dev_rd_attr (3780i_irq,
"%i\n", usDspIrq);
512 mwave_dev_rd_attr (3780i_io,
"%#.4x\n", usDspBaseIO);
513 mwave_dev_rd_attr (uart_irq,
"%i\n", usUartIrq);
514 mwave_dev_rd_attr (uart_io,
"%#.4x\n", usUartBaseIO);
531 static void mwave_exit(
void)
548 if ( pDrvData->
sLine >= 0 ) {
569 static int __init mwave_init(
void)
584 pDrvData->
sLine = -1;
595 "mwavedd::mwave_init, return from tp3780I_InitializeBoardData"
600 "mwavedd::mwave_init: Error:"
601 " Failed to initialize board data\n");
608 "mwavedd::mwave_init, return from tp3780I_CalcResources"
613 "mwavedd:mwave_init: Error:"
614 " Failed to calculate resources\n");
620 "mwavedd::mwave_init, return from tp3780I_ClaimResources"
625 "mwavedd:mwave_init: Error:"
626 " Failed to claim resources\n");
633 "mwavedd::mwave_init, return from tp3780I_EnableDSP"
638 "mwavedd:mwave_init: Error:"
639 " Failed to enable DSP\n");
646 "mwavedd:mwave_init: Error:"
647 " Failed to register misc device\n");
652 pDrvData->
sLine = register_serial_portandirq(
656 if (pDrvData->
sLine < 0) {
658 "mwavedd:mwave_init: Error:"
659 " Failed to register serial driver\n");
672 for (i = 0; i <
ARRAY_SIZE(mwave_dev_attrs); i++) {
675 "mwavedd:mwave_init: Error:"
676 " Failed to create sysfs file %s\n",
677 mwave_dev_attrs[i]->
attr.name);
689 "mwavedd::mwave_init: Error:"
690 " Failed to initialize\n");