26 #include <linux/module.h>
27 #include <linux/slab.h>
47 #define DATAPORT (devc->base)
48 #define COMDPORT (devc->base+1)
49 #define STATPORT (devc->base+1)
56 #define input_avail(devc) (!(uart401_status(devc)&INPUT_AVAIL))
57 #define output_ready(devc) (!(uart401_status(devc)&OUTPUT_READY))
74 #define OUTPUT_READY 0x40
75 #define INPUT_AVAIL 0x80
77 #define MPU_RESET 0xFF
78 #define UART_MODE_ON 0x3F
89 unsigned char c = uart401_read(devc);
111 uart401_input_loop(devc);
116 uart401_open(
int dev,
int mode,
117 void (*
input) (
int dev,
unsigned char data),
118 void (*output) (
int dev)
133 enter_uart_mode(devc);
139 static void uart401_close(
int dev)
147 static int uart401_out(
int dev,
unsigned char midi_byte)
161 uart401_input_loop(devc);
163 spin_unlock_irqrestore(&devc->
lock,flags);
170 for (timeout = 30000; timeout > 0 && !
output_ready(devc); timeout--);
177 enter_uart_mode(devc);
180 uart401_write(devc, midi_byte);
184 static inline int uart401_start_read(
int dev)
189 static inline int uart401_end_read(
int dev)
194 static inline void uart401_kick(
int dev)
198 static inline int uart401_buffer_status(
int dev)
203 #define MIDI_SYNTH_NAME "MPU-401 UART"
204 #define MIDI_SYNTH_CAPS SYNTH_CAP_INPUT
211 .converter = &std_midi_synth,
213 .open = uart401_open,
214 .close = uart401_close,
215 .outputc = uart401_out,
216 .start_read = uart401_start_read,
217 .end_read = uart401_end_read,
218 .kick = uart401_kick,
219 .buffer_status = uart401_buffer_status,
228 for (timeout = 30000; timeout > 0 && !
output_ready(devc); timeout--);
234 for (timeout = 50000; timeout > 0 && !ok; timeout--)
238 if (uart401_read(devc) ==
MPU_ACK)
241 spin_unlock_irqrestore(&devc->
lock,flags);
254 for (n = 0; n < 2 && !ok; n++)
256 for (timeout = 30000; timeout > 0 && !
output_ready(devc); timeout--);
265 for (timeout = 50000; timeout > 0 && !ok; timeout--)
271 if (uart401_read(devc) ==
MPU_ACK)
283 DDB(
printk(
"Reset UART401 failed - No hardware detected.\n"));
286 uart401_input_loop(devc);
296 char *
name =
"MPU-401 (UART) MIDI";
300 DDB(
printk(
"Entered probe_uart401()\n"));
303 hw_config->
slots[4] = -1;
317 devc->
irq = hw_config->
irq;
318 devc->
osp = hw_config->
osp;
327 ok = reset_uart401(devc);
328 spin_unlock_irqrestore(&devc->
lock,flags);
334 name = hw_config->
name;
348 enter_uart_mode(devc);
358 goto cleanup_unload_mididev;
369 goto cleanup_midi_devs;
385 cleanup_unload_mididev:
400 int n=hw_config->
slots[4];
441 static int __init init_uart401(
void)
444 cfg_mpu.io_base =
io;
448 if (cfg_mpu.io_base != -1 && cfg_mpu.irq != -1) {
449 printk(
KERN_INFO "MPU-401 UART driver Copyright (C) Hannu Savolainen 1993-1997");
457 static void __exit cleanup_uart401(
void)
459 if (cfg_mpu.io_base != -1 && cfg_mpu.irq != -1)
467 static int __init setup_uart401(
char *
str)
480 __setup(
"uart401=", setup_uart401);