blob: ff55f5d2f6f2aff9709bf0bed1d030ec86e1c48f [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
Zheng Bao9db833b2009-12-28 09:59:44 +00007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
Paul Menzela46a7122013-02-23 18:37:27 +010020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Zheng Bao9db833b2009-12-28 09:59:44 +000021 */
Richard Smith924f92f2006-07-29 17:40:36 +000022
Richard Smith924f92f2006-07-29 17:40:36 +000023#include <arch/io.h>
24#include <device/device.h>
25#include <device/pnp.h>
26#include <console/console.h>
27#include <string.h>
Richard Smith924f92f2006-07-29 17:40:36 +000028#include <uart8250.h>
29#include <pc80/keyboard.h>
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000030#include <stdlib.h>
Richard Smith924f92f2006-07-29 17:40:36 +000031#include "chip.h"
32#include "w83977tf.h"
33
Zheng Bao9db833b2009-12-28 09:59:44 +000034static void w83977tf_enter_ext_func_mode(device_t dev)
Richard Smith924f92f2006-07-29 17:40:36 +000035{
Zheng Bao9db833b2009-12-28 09:59:44 +000036 outb(0x87, dev->path.pnp.port);
37 outb(0x87, dev->path.pnp.port);
Richard Smith924f92f2006-07-29 17:40:36 +000038}
Uwe Hermann340fa932010-11-10 14:53:36 +000039
Zheng Bao9db833b2009-12-28 09:59:44 +000040static void w83977tf_exit_ext_func_mode(device_t dev)
Richard Smith924f92f2006-07-29 17:40:36 +000041{
Zheng Bao9db833b2009-12-28 09:59:44 +000042 outb(0xaa, dev->path.pnp.port);
Richard Smith924f92f2006-07-29 17:40:36 +000043}
44
45static void w83977tf_init(device_t dev)
46{
Uwe Hermann340fa932010-11-10 14:53:36 +000047 struct superio_winbond_w83977tf_config *conf = dev->chip_info;
Uwe Hermann340fa932010-11-10 14:53:36 +000048
49 if (!dev->enabled)
Richard Smith924f92f2006-07-29 17:40:36 +000050 return;
Uwe Hermann340fa932010-11-10 14:53:36 +000051
Stefan Reinauer2b34db82009-02-28 20:10:20 +000052 switch(dev->path.pnp.device) {
Richard Smith924f92f2006-07-29 17:40:36 +000053 case W83977TF_KBC:
Stefan Reinauer740b5872010-02-23 20:31:37 +000054 pc_keyboard_init(&conf->keyboard);
Richard Smith924f92f2006-07-29 17:40:36 +000055 break;
56 }
57}
58
Nico Huber13dc9762013-06-15 19:33:15 +020059static const struct pnp_mode_ops pnp_conf_mode_ops = {
60 .enter_conf_mode = w83977tf_enter_ext_func_mode,
61 .exit_conf_mode = w83977tf_exit_ext_func_mode,
62};
63
Richard Smith924f92f2006-07-29 17:40:36 +000064static struct device_operations ops = {
65 .read_resources = pnp_read_resources,
Nico Huber0b2ee932013-06-15 19:58:35 +020066 .set_resources = pnp_set_resources,
67 .enable_resources = pnp_enable_resources,
68 .enable = pnp_enable,
Richard Smith924f92f2006-07-29 17:40:36 +000069 .init = w83977tf_init,
Nico Huber13dc9762013-06-15 19:33:15 +020070 .ops_pnp_mode = &pnp_conf_mode_ops,
Richard Smith924f92f2006-07-29 17:40:36 +000071};
72
73static struct pnp_info pnp_dev_info[] = {
Uwe Hermanna69d9782010-11-15 19:35:14 +000074 { &ops, W83977TF_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, },
75 { &ops, W83977TF_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, },
76 { &ops, W83977TF_SP1, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
77 { &ops, W83977TF_SP2, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
78 { &ops, W83977TF_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, {0x07ff, 0}, {0x07ff, 4}, },
79 { &ops, W83977TF_CIR, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
80 { &ops, W83977TF_GAME_MIDI_GPIO1, PNP_IO0 | PNP_IO1 | PNP_IRQ0, {0x07ff, 0}, {0x07fe, 4}, },
81 { &ops, W83977TF_ACPI, PNP_IRQ0, },
Richard Smith924f92f2006-07-29 17:40:36 +000082};
83
84static void enable_dev(device_t dev)
85{
Uwe Hermann340fa932010-11-10 14:53:36 +000086 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
Richard Smith924f92f2006-07-29 17:40:36 +000087}
88
89struct chip_operations superio_winbond_w83977tf_ops = {
Uwe Hermanna7aa29b2006-11-05 18:50:49 +000090 CHIP_NAME("Winbond W83977TF Super I/O")
Richard Smith924f92f2006-07-29 17:40:36 +000091 .enable_dev = enable_dev,
92};