Added a test for MUIA_Listview_SelectChange.
[AROS.git] / arch / all-native / bootconsole / serial_16450_unused.c
blob427509b4d5996116406d12145bd19d64e2eff4ce
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /*
7 * This code was rescued from arch/x86_64/exec/serialrawio.c before x86-64 port update.
8 * Perhaps it can be useful in future, however it's questionable whether it is really
9 * needed for debugging console.
12 #include <asm/io.h>
13 #include <hardware/uart.h>
15 /** UART Types **/
16 #define SER_UART_INS8250 1
17 #define SER_UART_NS16450 2
18 #define SER_UART_NS16550A 3
19 #define SER_UART_NS16C552 4
21 unsigned char __ser_UARTType(short port)
23 outb_p(0xAA, port + UART_LCR); /* set Divisor-Latch */
24 if (inb_p(port + UART_LCR) != 0xAA)
25 return 0;
26 outb_p(0x55, port + UART_DLM); /* write Divisor */
27 if (inb_p(port + UART_DLM) != 0x55)
28 return 0;
29 outb_p(0x55, port + UART_LCR); /* clear Divisor-Latch */
30 if (inb_p(port + UART_LCR) != 0x55)
31 return 0;
32 outb_p(0x55, port + UART_IER);
33 if (inb_p(port + UART_IER) != 0x05)
34 return 0;
35 outb_p(0, port + UART_FCR); /* clear FIFO and IRQ */
36 outb_p(0, port + UART_IER);
37 if (inb_p(port + UART_IIR) != 1)
38 return 0;
39 outb_p(0xF5, port + UART_MCR);
40 if (inb_p(port + UART_MCR) != 0x15)
41 return 0;
42 outb_p(UART_MCR_LOOP, port + UART_MCR); /* Looping */
43 inb_p(port + UART_MSR);
44 if ((inb_p(port + UART_MSR) & 0xF0) != 0)
45 return 0;
46 outb_p(0x1F, port + UART_MCR);
47 if ((inb_p(port + UART_MSR) & 0xF0) != 0xF0)
48 return 0;
49 outb_p(SER_MCR_DTR | SER_MCR_RTS, port + UART_MCR);
51 outb_p(0x55, port + UART_SCR); /* Scratch-Register ?*/
52 if (inb_p(port + UART_SCR) != 0x55)
53 return SER_UART_INS8250;
54 outb_p(0, port + UART_SCR);
56 outb_p(0xCF, port + UART_FCR); /* FIFO ? */
57 if ((inb_p(port + UART_IIR) & 0xC0) != 0xC0)
58 return SER_UART_NS16450;
59 outb_p(0, port + UART_FCR);
61 outb_p(UART_LCR_DLAB, port + UART_LCR); /* Alternate-Function Register ? */
62 outb_p(0x07, port + UART_EFR);
63 if (inb_p(port + UART_EFR ) != 0x07)
65 outb_p(0, port + UART_LCR);
66 return SER_UART_NS16550A;
68 outb_p(0, port + UART_LCR); /* reset registers */
69 outb_p(0, port + UART_EFR);
70 return SER_UART_NS16C552;
73 static void __ser_FIFOLevel(short port, BYTE level)
75 if (level)
76 outb_p(level | UART_FCR_ENABLE_FIFO, port + UART_FCR);
77 else
78 outb_p(UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, port + UART_FCR);