26 #include <linux/module.h>
34 static int uart6850_base = 0x330;
36 static int *uart6850_osp;
38 #define DATAPORT (uart6850_base)
39 #define COMDPORT (uart6850_base+1)
40 #define STATPORT (uart6850_base+1)
42 static int uart6850_status(
void)
47 #define input_avail() (uart6850_status()&INPUT_AVAIL)
48 #define output_ready() (uart6850_status()&OUTPUT_READY)
50 static void uart6850_cmd(
unsigned char cmd)
55 static int uart6850_read(
void)
60 static void uart6850_write(
unsigned char byte)
65 #define OUTPUT_READY 0x02
66 #define INPUT_AVAIL 0x01
68 #define UART_RESET 0x95
69 #define UART_MODE_ON 0x03
71 static int uart6850_opened;
72 static int uart6850_irq;
73 static int uart6850_detected;
77 static void (*midi_input_intr) (
int dev,
unsigned char data);
78 static void poll_uart6850(
unsigned long dummy);
81 static DEFINE_TIMER(uart6850_timer, poll_uart6850, 0, 0);
83 static void uart6850_input_loop(
void)
94 unsigned char c = uart6850_read();
97 midi_input_intr(my_dev, c);
110 uart6850_input_loop();
119 static void poll_uart6850(
unsigned long dummy)
128 uart6850_input_loop();
130 uart6850_timer.expires = 1 +
jiffies;
137 spin_unlock_irqrestore(&lock,flags);
140 static int uart6850_open(
int dev,
int mode,
141 void (*
input) (
int dev,
unsigned char data),
142 void (*output) (
int dev)
152 uart6850_input_loop();
153 midi_input_intr =
input;
154 uart6850_opened =
mode;
162 static void uart6850_close(
int dev)
169 static int uart6850_out(
int dev,
unsigned char midi_byte)
181 uart6850_input_loop();
183 spin_unlock_irqrestore(&lock,flags);
190 for (timeout = 30000; timeout > 0 && !
output_ready(); timeout--);
198 uart6850_write(midi_byte);
202 static inline int uart6850_command(
int dev,
unsigned char *midi_byte)
207 static inline int uart6850_start_read(
int dev)
212 static inline int uart6850_end_read(
int dev)
217 static inline void uart6850_kick(
int dev)
221 static inline int uart6850_buffer_status(
int dev)
228 #define MIDI_SYNTH_NAME "6850 UART Midi"
229 #define MIDI_SYNTH_CAPS SYNTH_CAP_INPUT
236 .converter = &std_midi_synth,
238 .open = uart6850_open,
239 .close = uart6850_close,
240 .outputc = uart6850_out,
241 .start_read = uart6850_start_read,
242 .end_read = uart6850_end_read,
243 .kick = uart6850_kick,
244 .command = uart6850_command,
245 .buffer_status = uart6850_buffer_status
254 if (!uart6850_detected)
262 uart6850_base = hw_config->
io_base;
263 uart6850_osp = hw_config->
osp;
264 uart6850_irq = hw_config->
irq;
268 for (timeout = 30000; timeout > 0 && !
output_ready(); timeout--);
273 spin_unlock_irqrestore(&lock,flags);
277 std_midi_synth.midi_dev = my_dev;
278 hw_config->
slots[4] = my_dev;
279 midi_devs[my_dev] = &uart6850_operations;
283 static inline int reset_uart6850(
void)
295 uart6850_osp = hw_config->
osp;
296 uart6850_base = hw_config->
io_base;
297 uart6850_irq = hw_config->
irq;
302 ok = reset_uart6850();
303 uart6850_detected = ok;
321 static int __init init_uart6850(
void)
323 cfg_mpu.io_base =
io;
326 if (cfg_mpu.io_base == -1 || cfg_mpu.irq == -1) {
331 if (probe_uart6850(&cfg_mpu))
333 attach_uart6850(&cfg_mpu);
338 static void __exit cleanup_uart6850(
void)
340 unload_uart6850(&cfg_mpu);
347 static int __init setup_uart6850(
char *
str)
359 __setup(
"uart6850=", setup_uart6850);