blob: 9143f4690aedd45c06de75fac04834256f57cf8f [file] [log] [blame]
Stefan Reinauer8de452d2014-12-19 13:45:24 -08001/*
2 * Enable the serial devices on the VIA
3 */
4
5
6/* The base address is 0x15c, 0x2e, depending on config bytes */
7
8#define SIO_BASE 0x3f0
9#define SIO_DATA SIO_BASE+1
10
11static void vt8237r_writepnpaddr(uint8_t val)
12{
13 outb(val, 0x2e);
14 outb(val, 0xeb);
15}
16
17static void vt8237r_writepnpdata(uint8_t val)
18{
19 outb(val, 0x2f);
20 outb(val, 0xeb);
21}
22
23
24static void vt8237r_writesiobyte(uint16_t reg, uint8_t val)
25{
26 outb(val, reg);
27}
28
29static void vt8237r_writesioword(uint16_t reg, uint16_t val)
30{
31 outw(val, reg);
32}
33
34
35/* regs we use: 85, and the southbridge devfn is defined by the
36 mainboard
37 */
38
39static void enable_vt8237r_serial(void)
40{
41 // turn on pnp
42 vt8237r_writepnpaddr(0x87);
43 vt8237r_writepnpaddr(0x87);
44 // now go ahead and set up com1.
45 // set address
46 vt8237r_writepnpaddr(0x7);
47 vt8237r_writepnpdata(0x2);
48 // enable serial out
49 vt8237r_writepnpaddr(0x30);
50 vt8237r_writepnpdata(0x1);
51 // serial port 1 base address (FEh)
52 vt8237r_writepnpaddr(0x60);
53 vt8237r_writepnpdata(0xfe);
54 // serial port 1 IRQ (04h)
55 vt8237r_writepnpaddr(0x70);
56 vt8237r_writepnpdata(0x4);
57 // serial port 1 control
58 vt8237r_writepnpaddr(0xf0);
59 vt8237r_writepnpdata(0x2);
60 // turn of pnp
61 vt8237r_writepnpaddr(0xaa);
62
63 // set up reg to set baud rate.
64 vt8237r_writesiobyte(0x3fb, 0x80);
65 // Set 115 kb
66 vt8237r_writesioword(0x3f8, 1);
67 // Set 9.6 kb
68 // WRITESIOWORD(0x3f8, 12)
69 // now set no parity, one stop, 8 bits
70 vt8237r_writesiobyte(0x3fb, 3);
71 // now turn on RTS, DRT
72 vt8237r_writesiobyte(0x3fc, 3);
73 // Enable interrupts
74 vt8237r_writesiobyte(0x3f9, 0xf);
75 // should be done. Dump a char for fun.
76 vt8237r_writesiobyte(0x3f8, 48);
77}