blob: 1989fe2a52343579075e1d4bcc33a5c1fee18575 [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 */
Stefan Reinauerb70d1992008-10-29 04:45:28 +000022
23#include <arch/io.h>
24#include <device/device.h>
25#include <device/pnp.h>
26#include <console/console.h>
27#include <string.h>
Stefan Reinauerb70d1992008-10-29 04:45:28 +000028#include <uart8250.h>
29#include <pc80/keyboard.h>
30#include "chip.h"
31#include "w83627thg.h"
32
Zheng Bao9db833b2009-12-28 09:59:44 +000033static void w83627thg_enter_ext_func_mode(device_t dev)
Stefan Reinauerb70d1992008-10-29 04:45:28 +000034{
Zheng Bao9db833b2009-12-28 09:59:44 +000035 outb(0x87, dev->path.pnp.port);
36 outb(0x87, dev->path.pnp.port);
Stefan Reinauerb70d1992008-10-29 04:45:28 +000037}
Uwe Hermann340fa932010-11-10 14:53:36 +000038
Zheng Bao9db833b2009-12-28 09:59:44 +000039static void w83627thg_exit_ext_func_mode(device_t dev)
Stefan Reinauerb70d1992008-10-29 04:45:28 +000040{
Zheng Bao9db833b2009-12-28 09:59:44 +000041 outb(0xaa, dev->path.pnp.port);
Stefan Reinauerb70d1992008-10-29 04:45:28 +000042}
43
44static void w83627thg_init(device_t dev)
45{
Uwe Hermann340fa932010-11-10 14:53:36 +000046 struct superio_winbond_w83627thg_config *conf = dev->chip_info;
Uwe Hermann340fa932010-11-10 14:53:36 +000047
48 if (!dev->enabled)
Stefan Reinauerb70d1992008-10-29 04:45:28 +000049 return;
Uwe Hermann340fa932010-11-10 14:53:36 +000050
Stefan Reinauer2b34db82009-02-28 20:10:20 +000051 switch(dev->path.pnp.device) {
Stefan Reinauerb70d1992008-10-29 04:45:28 +000052 case W83627THG_KBC:
Stefan Reinauer740b5872010-02-23 20:31:37 +000053 pc_keyboard_init(&conf->keyboard);
Stefan Reinauerb70d1992008-10-29 04:45:28 +000054 break;
55 }
56}
57
58static void w83627thg_set_resources(device_t dev)
59{
60 w83627thg_enter_ext_func_mode(dev);
61 pnp_set_resources(dev);
62 w83627thg_exit_ext_func_mode(dev);
63}
64
65static void w83627thg_enable_resources(device_t dev)
66{
67 w83627thg_enter_ext_func_mode(dev);
68 pnp_enable_resources(dev);
69 w83627thg_exit_ext_func_mode(dev);
70}
71
72static void w83627thg_enable(device_t dev)
73{
Zheng Bao9db833b2009-12-28 09:59:44 +000074 w83627thg_enter_ext_func_mode(dev);
Stefan Reinauerb70d1992008-10-29 04:45:28 +000075 pnp_enable(dev);
Zheng Bao9db833b2009-12-28 09:59:44 +000076 w83627thg_exit_ext_func_mode(dev);
Stefan Reinauerb70d1992008-10-29 04:45:28 +000077}
78
Stefan Reinauerb70d1992008-10-29 04:45:28 +000079static struct device_operations ops = {
80 .read_resources = pnp_read_resources,
81 .set_resources = w83627thg_set_resources,
82 .enable_resources = w83627thg_enable_resources,
83 .enable = w83627thg_enable,
84 .init = w83627thg_init,
85};
86
87static struct pnp_info pnp_dev_info[] = {
Uwe Hermanna69d9782010-11-15 19:35:14 +000088 { &ops, W83627THG_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, },
89 { &ops, W83627THG_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, },
90 { &ops, W83627THG_SP1, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
91 { &ops, W83627THG_SP2, PNP_IO0 | PNP_IRQ0 | PNP_MSC1, {0x07f8, 0}, },
92 { &ops, W83627THG_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1 | PNP_MSC0, {0x07ff, 0}, {0x07ff, 4}, },
93 { &ops, W83627THG_GAME_MIDI_GPIO1, PNP_IO0 | PNP_IO1 | PNP_IRQ0, {0x07ff, 0}, {0x07fe, 4}, },
94 { &ops, W83627THG_GPIO2, },
Stefan Reinauerde3206a2010-02-22 06:09:43 +000095 { &ops, W83627THG_GPIO3, PNP_EN | PNP_MSC0 | PNP_MSC1, },
Uwe Hermanna69d9782010-11-15 19:35:14 +000096 { &ops, W83627THG_ACPI, PNP_IRQ0, },
97 { &ops, W83627THG_HWM, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
Stefan Reinauerb70d1992008-10-29 04:45:28 +000098};
99
100static void enable_dev(device_t dev)
101{
Uwe Hermann340fa932010-11-10 14:53:36 +0000102 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
Stefan Reinauerb70d1992008-10-29 04:45:28 +0000103}
104
105struct chip_operations superio_winbond_w83627thg_ops = {
106 CHIP_NAME("Winbond W83627THG Super I/O")
107 .enable_dev = enable_dev,
108};