blob: a87c7e98fadc8ff2744b3589e834fd399c5586d6 [file] [log] [blame]
Zheng Bao9db833b2009-12-28 09:59:44 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2000 AG Electronics Ltd.
5 * Copyright (C) 2003-2004 Linux Networx
Uwe Hermann340fa932010-11-10 14:53:36 +00006 * Copyright (C) 2004 Tyan
Uwe Hermannd37d2222010-02-14 16:17:55 +00007 * Copyright (C) 2010 Win Enterprises (anishp@win-ent.com)
Zheng Bao9db833b2009-12-28 09:59:44 +00008 *
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.
Zheng Bao9db833b2009-12-28 09:59:44 +000018 */
19
Stefan Reinauer24d1d4b2013-03-21 11:51:41 -070020#include <arch/io.h>
Ronald G. Minnich142babf2004-03-12 16:54:31 +000021#include "w83627hf.h"
22
Edward O'Callaghan85836c22014-07-09 20:26:25 +100023static void pnp_enter_ext_func_mode(pnp_devfn_t dev)
Eric Biederman018d8dd2004-11-04 11:04:33 +000024{
Uwe Hermann340fa932010-11-10 14:53:36 +000025 u16 port = dev >> 8;
Myles Watsoncee94382008-10-02 19:21:30 +000026 outb(0x87, port);
27 outb(0x87, port);
Li-Ta Loc6bcedb2004-04-21 16:57:05 +000028}
Myles Watsoncee94382008-10-02 19:21:30 +000029
Edward O'Callaghan85836c22014-07-09 20:26:25 +100030static void pnp_exit_ext_func_mode(pnp_devfn_t dev)
Eric Biederman018d8dd2004-11-04 11:04:33 +000031{
Uwe Hermann340fa932010-11-10 14:53:36 +000032 u16 port = dev >> 8;
Myles Watsoncee94382008-10-02 19:21:30 +000033 outb(0xaa, port);
Li-Ta Loc6bcedb2004-04-21 16:57:05 +000034}
Myles Watsoncee94382008-10-02 19:21:30 +000035
Edward O'Callaghanbeb0f262014-04-29 13:09:50 +100036/*
37 * FIXME: The following ROMCC boards are blocking the removal this superio's
38 * model specific w83627hf_enable_serial() symbol.
39 *
40 * mainboard/supermicro/x6dai_g
41 * mainboard/supermicro/x6dhe_g
42 * mainboard/supermicro/x6dhr_ig
43 * mainboard/supermicro/x6dhr_ig2
44 *
45 * XXX: ROMCC - everything is inlined, no forwarding function prototypes
46 * declarations are accepted.
47 */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100048void w83627hf_enable_serial(pnp_devfn_t dev, u16 iobase)
Ronald G. Minnich142babf2004-03-12 16:54:31 +000049{
Li-Ta Loc6bcedb2004-04-21 16:57:05 +000050 pnp_enter_ext_func_mode(dev);
Ronald G. Minnich142babf2004-03-12 16:54:31 +000051 pnp_set_logical_device(dev);
52 pnp_set_enable(dev, 0);
53 pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
54 pnp_set_enable(dev, 1);
Li-Ta Loc6bcedb2004-04-21 16:57:05 +000055 pnp_exit_ext_func_mode(dev);
Ronald G. Minnich142babf2004-03-12 16:54:31 +000056}
Anish K Patel13df6402010-02-14 16:13:03 +000057
Edward O'Callaghan85836c22014-07-09 20:26:25 +100058void w83627hf_set_clksel_48(pnp_devfn_t dev)
Anish K Patel13df6402010-02-14 16:13:03 +000059{
Uwe Hermann340fa932010-11-10 14:53:36 +000060 u8 reg8;
61
Anish K Patel13df6402010-02-14 16:13:03 +000062 pnp_enter_ext_func_mode(dev);
Uwe Hermann340fa932010-11-10 14:53:36 +000063 reg8 = pnp_read_config(dev, 0x24);
64 reg8 |= (1 << 6); /* Set CLKSEL (clock input on pin 1) to 48MHz. */
65 pnp_write_config(dev, 0x24, reg8);
Anish K Patel13df6402010-02-14 16:13:03 +000066 pnp_exit_ext_func_mode(dev);
67}