| 1 |
|
| 2 |
|
| 3 |
#include <stdint.h> |
| 4 |
#include <arch/io.h> |
| 5 |
#include "sio1007.h" |
| 6 |
|
| 7 |
void sio1007_setreg(u16 lpc_port, u8 reg, u8 value, u8 mask) |
| 8 |
{ |
| 9 |
u8 reg_value; |
| 10 |
|
| 11 |
outb(reg, lpc_port); |
| 12 |
reg_value = inb(lpc_port + 1); |
| 13 |
reg_value &= ~mask; |
| 14 |
reg_value |= (value & mask); |
| 15 |
outb(reg_value, lpc_port + 1); |
| 16 |
} |
| 17 |
|
| 18 |
int sio1007_enable_uart_at(u16 port) |
| 19 |
{ |
| 20 |
|
| 21 |
outb(0x55, port); |
| 22 |
if (inb(port) != 0x55) |
| 23 |
return 0; |
| 24 |
|
| 25 |
|
| 26 |
outb(0x12, port); |
| 27 |
if (inb(port + 1) != (port & 0xff)) |
| 28 |
return 0; |
| 29 |
|
| 30 |
outb(0x13, port); |
| 31 |
if (inb(port + 1) != (port >> 8)) |
| 32 |
return 0; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
sio1007_setreg(port, 0x2, 1 << 3, 1 << 3); |
| 37 |
|
| 38 |
sio1007_setreg(port, 0xc, 1 << 6, 1 << 6); |
| 39 |
|
| 40 |
sio1007_setreg(port, 0x24, CONFIG_TTYS0_BASE >> 2, 0xff); |
| 41 |
|
| 42 |
|
| 43 |
outb(0xaa, port); |
| 44 |
return 1; |
| 45 |
} |