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 |
Zheng Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 7 | * |
| 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 Menzel | a46a712 | 2013-02-23 18:37:27 +0100 | [diff] [blame] | 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Zheng Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 21 | */ |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 22 | |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 23 | #include <arch/io.h> |
| 24 | #include <device/device.h> |
| 25 | #include <device/pnp.h> |
| 26 | #include <console/console.h> |
| 27 | #include <string.h> |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 28 | #include <uart8250.h> |
| 29 | #include <pc80/keyboard.h> |
Carl-Daniel Hailfinger | 2ee6779 | 2008-10-01 12:52:52 +0000 | [diff] [blame] | 30 | #include <stdlib.h> |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 31 | #include "chip.h" |
| 32 | #include "w83977tf.h" |
| 33 | |
Zheng Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 34 | static void w83977tf_enter_ext_func_mode(device_t dev) |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 35 | { |
Zheng Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 36 | outb(0x87, dev->path.pnp.port); |
| 37 | outb(0x87, dev->path.pnp.port); |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 38 | } |
Uwe Hermann | 340fa93 | 2010-11-10 14:53:36 +0000 | [diff] [blame] | 39 | |
Zheng Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 40 | static void w83977tf_exit_ext_func_mode(device_t dev) |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 41 | { |
Zheng Bao | 9db833b | 2009-12-28 09:59:44 +0000 | [diff] [blame] | 42 | outb(0xaa, dev->path.pnp.port); |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | static void w83977tf_init(device_t dev) |
| 46 | { |
Uwe Hermann | 340fa93 | 2010-11-10 14:53:36 +0000 | [diff] [blame] | 47 | struct superio_winbond_w83977tf_config *conf = dev->chip_info; |
Uwe Hermann | 340fa93 | 2010-11-10 14:53:36 +0000 | [diff] [blame] | 48 | |
| 49 | if (!dev->enabled) |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 50 | return; |
Uwe Hermann | 340fa93 | 2010-11-10 14:53:36 +0000 | [diff] [blame] | 51 | |
Stefan Reinauer | 2b34db8 | 2009-02-28 20:10:20 +0000 | [diff] [blame] | 52 | switch(dev->path.pnp.device) { |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 53 | case W83977TF_KBC: |
Stefan Reinauer | 740b587 | 2010-02-23 20:31:37 +0000 | [diff] [blame] | 54 | pc_keyboard_init(&conf->keyboard); |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 55 | break; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | static void w83977tf_set_resources(device_t dev) |
| 60 | { |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 61 | pnp_set_resources(dev); |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | static void w83977tf_enable_resources(device_t dev) |
| 65 | { |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 66 | pnp_enable_resources(dev); |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | static void w83977tf_enable(device_t dev) |
| 70 | { |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 71 | pnp_enable(dev); |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Nico Huber | 13dc976 | 2013-06-15 19:33:15 +0200 | [diff] [blame^] | 74 | static const struct pnp_mode_ops pnp_conf_mode_ops = { |
| 75 | .enter_conf_mode = w83977tf_enter_ext_func_mode, |
| 76 | .exit_conf_mode = w83977tf_exit_ext_func_mode, |
| 77 | }; |
| 78 | |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 79 | static struct device_operations ops = { |
| 80 | .read_resources = pnp_read_resources, |
| 81 | .set_resources = w83977tf_set_resources, |
| 82 | .enable_resources = w83977tf_enable_resources, |
| 83 | .enable = w83977tf_enable, |
| 84 | .init = w83977tf_init, |
Nico Huber | 13dc976 | 2013-06-15 19:33:15 +0200 | [diff] [blame^] | 85 | .ops_pnp_mode = &pnp_conf_mode_ops, |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | static struct pnp_info pnp_dev_info[] = { |
Uwe Hermann | a69d978 | 2010-11-15 19:35:14 +0000 | [diff] [blame] | 89 | { &ops, W83977TF_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, }, |
| 90 | { &ops, W83977TF_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x07f8, 0}, }, |
| 91 | { &ops, W83977TF_SP1, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, }, |
| 92 | { &ops, W83977TF_SP2, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, }, |
| 93 | { &ops, W83977TF_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, {0x07ff, 0}, {0x07ff, 4}, }, |
| 94 | { &ops, W83977TF_CIR, PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, }, |
| 95 | { &ops, W83977TF_GAME_MIDI_GPIO1, PNP_IO0 | PNP_IO1 | PNP_IRQ0, {0x07ff, 0}, {0x07fe, 4}, }, |
| 96 | { &ops, W83977TF_ACPI, PNP_IRQ0, }, |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | static void enable_dev(device_t dev) |
| 100 | { |
Uwe Hermann | 340fa93 | 2010-11-10 14:53:36 +0000 | [diff] [blame] | 101 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | struct chip_operations superio_winbond_w83977tf_ops = { |
Uwe Hermann | a7aa29b | 2006-11-05 18:50:49 +0000 | [diff] [blame] | 105 | CHIP_NAME("Winbond W83977TF Super I/O") |
Richard Smith | 924f92f | 2006-07-29 17:40:36 +0000 | [diff] [blame] | 106 | .enable_dev = enable_dev, |
| 107 | }; |