Zheng Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 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 |
Uwe Hermann | 340fa93 | 2010-11-10 14:53:36 +0000 | [diff] [blame] | 6 | * Copyright (C) 2004 Tyan |
Uwe Hermann | d37d222 | 2010-02-14 16:17:55 +0000 | [diff] [blame] | 7 | * Copyright (C) 2010 Win Enterprises (anishp@win-ent.com) |
Zheng Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 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. |
Zheng Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 18 | */ |
| 19 | |
Stefan Reinauer | 24d1d4b | 2013-03-21 11:51:41 -0700 | [diff] [blame] | 20 | #include <arch/io.h> |
Ronald G. Minnich | 142babf | 2004-03-12 16:54:31 +0000 | [diff] [blame] | 21 | #include "w83627hf.h" |
| 22 | |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 23 | static void pnp_enter_ext_func_mode(pnp_devfn_t dev) |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 24 | { |
Uwe Hermann | 340fa93 | 2010-11-10 14:53:36 +0000 | [diff] [blame] | 25 | u16 port = dev >> 8; |
Myles Watson | cee9438 | 2008-10-02 19:21:30 +0000 | [diff] [blame] | 26 | outb(0x87, port); |
| 27 | outb(0x87, port); |
Li-Ta Lo | c6bcedb | 2004-04-21 16:57:05 +0000 | [diff] [blame] | 28 | } |
Myles Watson | cee9438 | 2008-10-02 19:21:30 +0000 | [diff] [blame] | 29 | |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 30 | static void pnp_exit_ext_func_mode(pnp_devfn_t dev) |
Eric Biederman | 018d8dd | 2004-11-04 11:04:33 +0000 | [diff] [blame] | 31 | { |
Uwe Hermann | 340fa93 | 2010-11-10 14:53:36 +0000 | [diff] [blame] | 32 | u16 port = dev >> 8; |
Myles Watson | cee9438 | 2008-10-02 19:21:30 +0000 | [diff] [blame] | 33 | outb(0xaa, port); |
Li-Ta Lo | c6bcedb | 2004-04-21 16:57:05 +0000 | [diff] [blame] | 34 | } |
Myles Watson | cee9438 | 2008-10-02 19:21:30 +0000 | [diff] [blame] | 35 | |
Edward O'Callaghan | beb0f26 | 2014-04-29 13:09:50 +1000 | [diff] [blame] | 36 | /* |
| 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'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 48 | void w83627hf_enable_serial(pnp_devfn_t dev, u16 iobase) |
Ronald G. Minnich | 142babf | 2004-03-12 16:54:31 +0000 | [diff] [blame] | 49 | { |
Li-Ta Lo | c6bcedb | 2004-04-21 16:57:05 +0000 | [diff] [blame] | 50 | pnp_enter_ext_func_mode(dev); |
Ronald G. Minnich | 142babf | 2004-03-12 16:54:31 +0000 | [diff] [blame] | 51 | 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 Lo | c6bcedb | 2004-04-21 16:57:05 +0000 | [diff] [blame] | 55 | pnp_exit_ext_func_mode(dev); |
Ronald G. Minnich | 142babf | 2004-03-12 16:54:31 +0000 | [diff] [blame] | 56 | } |
Anish K Patel | 13df640 | 2010-02-14 16:13:03 +0000 | [diff] [blame] | 57 | |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 58 | void w83627hf_set_clksel_48(pnp_devfn_t dev) |
Anish K Patel | 13df640 | 2010-02-14 16:13:03 +0000 | [diff] [blame] | 59 | { |
Uwe Hermann | 340fa93 | 2010-11-10 14:53:36 +0000 | [diff] [blame] | 60 | u8 reg8; |
| 61 | |
Anish K Patel | 13df640 | 2010-02-14 16:13:03 +0000 | [diff] [blame] | 62 | pnp_enter_ext_func_mode(dev); |
Uwe Hermann | 340fa93 | 2010-11-10 14:53:36 +0000 | [diff] [blame] | 63 | 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 Patel | 13df640 | 2010-02-14 16:13:03 +0000 | [diff] [blame] | 66 | pnp_exit_ext_func_mode(dev); |
| 67 | } |