13 #include <linux/types.h>
14 #include <linux/tty.h>
18 #include <linux/module.h>
28 static struct console atari_console_driver = {
35 static inline void ata_mfp_out(
char c)
37 while (!(
st_mfp.trn_stat & 0x80))
42 static void atari_mfp_console_write(
struct console *co,
const char *
str,
52 static inline void ata_scc_out(
char c)
61 static void atari_scc_console_write(
struct console *co,
const char *str,
71 static inline void ata_midi_out(
char c)
78 static void atari_midi_console_write(
struct console *co,
const char *str,
88 static int ata_par_out(
char c)
94 while ((
st_mfp.par_dt_reg & 1) && --i)
109 static void atari_par_console_write(
struct console *co,
const char *str,
112 static int printer_present = 1;
114 if (!printer_present)
119 if (!ata_par_out(
'\r')) {
124 if (!ata_par_out(*str++)) {
132 int atari_mfp_console_wait_key(
struct console *co)
134 while (!(
st_mfp.rcv_stat & 0x80))
139 int atari_scc_console_wait_key(
struct console *co)
143 }
while (!(
atari_scc.cha_b_ctrl & 0x01));
148 int atari_midi_console_wait_key(
struct console *co)
152 return acia.mid_data;
167 static int baud_table[9] = { 16, 11, 8, 4, 2, 1, 175, 143, 128 };
170 int csize = ((cflag &
CSIZE) ==
CS7) ? 0x20 : 0x00;
174 if (baud < B1200 || baud >
B38400+2)
179 st_mfp.usart_ctr = parity | csize | 0x88;
186 #define SCC_WRITE(reg, val) \
188 atari_scc.cha_b_ctrl = (reg); \
190 atari_scc.cha_b_ctrl = (val); \
196 #define LONG_DELAY() \
199 for (i = 100; i > 0; --i) \
203 static void __init atari_init_scc_port(
int cflag)
205 static int clksrc_table[9] =
207 { 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00 };
208 static int brgsrc_table[9] =
210 { 2, 2, 2, 2, 2, 2, 0, 2, 2 };
211 static int clkmode_table[9] =
213 { 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xc0, 0x80 };
214 static int div_table[9] =
216 { 208, 138, 103, 50, 24, 11, 1, 0, 0 };
218 int baud = cflag &
CBAUD;
219 int clksrc, clkmode,
div,
reg3, reg5;
223 if (baud < B1200 || baud >
B38400+2)
227 clksrc = clksrc_table[
baud];
228 clkmode = clkmode_table[
baud];
229 div = div_table[
baud];
233 clkmode = baud == 6 ? 0xc0 :
239 reg3 = (cflag &
CSIZE) ==
CS8 ? 0xc0 : 0x40;
240 reg5 = (cflag &
CSIZE) ==
CS8 ? 0x60 : 0x20 | 0x82 ;
246 : 0 | 0x04 | clkmode);
256 SCC_WRITE(14, brgsrc_table[baud] | (div ? 1 : 0));
263 static void __init atari_init_midi_port(
int cflag)
265 int baud = cflag &
CBAUD;
266 int csize = ((cflag &
CSIZE) ==
CS8) ? 0x10 : 0x00;
268 int parity = (cflag &
PARENB) ? ((cflag & PARODD) ? 0x0c : 0x08) : 0x04;
277 else if (baud ==
B38400+2 )
283 acia.mid_ctrl = div | csize | parity |
288 static int __init atari_debug_setup(
char *
arg)
297 if (!
strcmp(arg,
"ser1")) {
300 atari_console_driver.
write = atari_mfp_console_write;
301 }
else if (!
strcmp(arg,
"ser2")) {
304 atari_console_driver.
write = atari_scc_console_write;
305 }
else if (!
strcmp(arg,
"midi")) {
308 atari_console_driver.
write = atari_midi_console_write;
309 }
else if (!
strcmp(arg,
"par")) {
318 atari_console_driver.
write = atari_par_console_write;
320 if (atari_console_driver.
write)