no warnings day
[coreboot.git] / src / superio / winbond / w83627hf / w83627hf_early_serial.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2000 AG Electronics Ltd.
5  * Copyright (C) 2003-2004 Linux Networx
6  * Copyright (C) 2004 Tyan By LYH change from PC87360
7  * Copyright (C) 2010 Win Enterprises (anishp@win-ent.com)
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
22  */
23
24 #include <arch/romcc_io.h>
25 #include "w83627hf.h"
26
27 static inline void pnp_enter_ext_func_mode(device_t dev)
28 {
29         unsigned port = dev>>8;
30         outb(0x87, port);
31         outb(0x87, port);
32 }
33
34 static void pnp_exit_ext_func_mode(device_t dev)
35 {
36         unsigned port = dev>>8;
37         outb(0xaa, port);
38 }
39
40 static void w83627hf_enable_serial(device_t dev, unsigned iobase)
41 {
42         pnp_enter_ext_func_mode(dev);
43         pnp_set_logical_device(dev);
44         pnp_set_enable(dev, 0);
45         pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
46         pnp_set_enable(dev, 1);
47         pnp_exit_ext_func_mode(dev);
48 }
49
50 static inline void w83627hf_set_clksel_48(device_t dev)
51 {
52         unsigned port = dev >> 8;
53         pnp_enter_ext_func_mode(dev);
54         outb(0x24, port);
55         /* Set CLKSEL (clock input on pin 1) to 48MHz. */
56         outb(inb(port + 1) | (1 << 6), port + 1);
57         pnp_exit_ext_func_mode(dev);
58 }