26 #include <linux/module.h>
28 #include <linux/types.h>
29 #include <linux/errno.h>
34 #include <linux/device.h>
41 #include <asm/traps.h>
46 #define DSP56K_DEV_56001 0
50 #define DSP56K_MAX_BINARY_LENGTH (3*64*1024)
52 #define DSP56K_TX_INT_ON dsp56k_host_interface.icr |= DSP56K_ICR_TREQ
53 #define DSP56K_RX_INT_ON dsp56k_host_interface.icr |= DSP56K_ICR_RREQ
54 #define DSP56K_TX_INT_OFF dsp56k_host_interface.icr &= ~DSP56K_ICR_TREQ
55 #define DSP56K_RX_INT_OFF dsp56k_host_interface.icr &= ~DSP56K_ICR_RREQ
57 #define DSP56K_TRANSMIT (dsp56k_host_interface.isr & DSP56K_ISR_TXDE)
58 #define DSP56K_RECEIVE (dsp56k_host_interface.isr & DSP56K_ISR_RXDF)
60 #define handshake(count, maxio, timeout, ENABLE, f) \
64 m = min_t(unsigned long, count, maxio); \
65 for (i = 0; i < m; i++) { \
66 for (t = 0; t < timeout && !ENABLE; t++) \
73 if (m == maxio) msleep(20); \
80 for(t = 0; t < n && !DSP56K_TRANSMIT; t++) \
82 if(!DSP56K_TRANSMIT) { \
90 for(t = 0; t < n && !DSP56K_RECEIVE; t++) \
92 if(!DSP56K_RECEIVE) { \
98 static struct dsp56k_device {
101 int tx_wsize, rx_wsize;
104 static struct class *dsp56k_class;
106 static int dsp56k_reset(
void)
112 status =
sound_ym.rd_data_reg_sel & 0xef;
129 const char fw_name[] =
"dsp56k/bootstrap.bin";
135 pdev = platform_device_register_simple(
"dsp56k", 0,
NULL, 0);
154 for (i = 0; i < fw->
size; i = i + 3) {
161 for (; i < 512; i++) {
168 for (i = 0; i < len; i++) {
185 int dev = iminor(inode) & 0x0f;
195 if (!count)
return 0;
198 switch (dsp56k.rx_wsize) {
210 data = (
short __user *) buf;
229 data = (
long __user *) buf;
239 printk(
KERN_ERR "DSP56k driver: Unknown minor device: %d\n", dev);
244 static ssize_t dsp56k_write(
struct file *file,
const char __user *buf,
size_t count,
247 struct inode *inode = file->
f_path.dentry->d_inode;
248 int dev = iminor(inode) & 0x0f;
257 if (!count)
return 0;
260 switch (dsp56k.tx_wsize) {
272 data = (
const short __user *)buf;
291 data = (
const long __user *)buf;
301 printk(
KERN_ERR "DSP56k driver: Unknown minor device: %d\n", dev);
306 static long dsp56k_ioctl(
struct file *file,
unsigned int cmd,
309 int dev = iminor(file->
f_path.dentry->d_inode) & 0x0f;
344 if (arg > 4 || arg < 1)
347 dsp56k.tx_wsize = (
int) arg;
351 if (arg > 4 || arg < 1)
354 dsp56k.rx_wsize = (
int) arg;
368 if ((dir & 0x1) && (out & 0x1))
372 if ((dir & 0x2) && (out & 0x2))
386 if (arg > 31 || arg < 0)
399 printk(
KERN_ERR "DSP56k driver: Unknown minor device: %d\n", dev);
409 static unsigned int dsp56k_poll(
struct file *file,
poll_table *
wait)
411 int dev = iminor(file->
f_path.dentry->d_inode) & 0x0f;
420 printk(
"DSP56k driver: Unknown minor device: %d\n", dev);
426 static int dsp56k_open(
struct inode *inode,
struct file *file)
428 int dev = iminor(inode) & 0x0f;
442 dsp56k.maxio =
MAXIO;
443 dsp56k.rx_wsize = dsp56k.tx_wsize = 4;
462 static int dsp56k_release(
struct inode *inode,
struct file *file)
464 int dev = iminor(inode) & 0x0f;
472 printk(
KERN_ERR "DSP56k driver: Unknown minor device: %d\n", dev);
482 .write = dsp56k_write,
483 .unlocked_ioctl = dsp56k_ioctl,
485 .release = dsp56k_release,
494 static int __init dsp56k_init_driver(
void)
499 printk(
"DSP56k driver: Hardware not present\n");
503 if(register_chrdev(
DSP56K_MAJOR,
"dsp56k", &dsp56k_fops)) {
504 printk(
"DSP56k driver: Unable to register driver\n");
508 if (IS_ERR(dsp56k_class)) {
509 err = PTR_ERR(dsp56k_class);
525 static void __exit dsp56k_cleanup_driver(
void)