blob: fca98ca59e0a578ddd4de18f1885d0fce6b1f10b [file] [log] [blame]
Richard Smith924f92f2006-07-29 17:40:36 +00001/* Copyright 2000 AG Electronics Ltd. */
2/* Copyright 2003-2004 Linux Networx */
3/* Copyright 2004 Tyan
4 By LYH change from PC87360 */
5/* This code is distributed without warranty under the GPL v2 (see COPYING) */
6
7/* 2006-4-24
8 * Adapted for the w83977 by rsmith <smithbone@gmail.com>
9 * This is mostly just a search and replace on the part type
10 * TODO: Actually see if all the sub functionis exist and are
11 * setup correctly.
12 */
13
14#include <arch/io.h>
15#include <device/device.h>
16#include <device/pnp.h>
17#include <console/console.h>
18#include <string.h>
19#include <bitops.h>
20#include <uart8250.h>
21#include <pc80/keyboard.h>
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +000022#include <stdlib.h>
Richard Smith924f92f2006-07-29 17:40:36 +000023#include "chip.h"
24#include "w83977tf.h"
25
26static void w83977tf_enter_ext_func_mode(device_t dev)
27{
28 outb(0x87, dev->path.u.pnp.port);
29 outb(0x87, dev->path.u.pnp.port);
30}
31static void w83977tf_exit_ext_func_mode(device_t dev)
32{
33 outb(0xaa, dev->path.u.pnp.port);
34}
35
36static void w83977tf_init(device_t dev)
37{
38 struct superio_winbond_w83977tf_config *conf;
39 struct resource *res0, *res1;
40 /* Wishlist handle well known programming interfaces more
41 * generically.
42 */
43 if (!dev->enabled) {
44 return;
45 }
46 conf = dev->chip_info;
47 switch(dev->path.u.pnp.device) {
48 case W83977TF_SP1:
49 res0 = find_resource(dev, PNP_IDX_IO0);
50 init_uart8250(res0->base, &conf->com1);
51 break;
52 case W83977TF_SP2:
53 res0 = find_resource(dev, PNP_IDX_IO0);
54 init_uart8250(res0->base, &conf->com2);
55 break;
56 case W83977TF_KBC:
57 res0 = find_resource(dev, PNP_IDX_IO0);
58 res1 = find_resource(dev, PNP_IDX_IO1);
59 init_pc_keyboard(res0->base, res1->base, &conf->keyboard);
60 break;
61 }
62}
63
64static void w83977tf_set_resources(device_t dev)
65{
66 w83977tf_enter_ext_func_mode(dev);
67 pnp_set_resources(dev);
68 w83977tf_exit_ext_func_mode(dev);
69}
70
71static void w83977tf_enable_resources(device_t dev)
72{
73 w83977tf_enter_ext_func_mode(dev);
74 pnp_enable_resources(dev);
75 w83977tf_exit_ext_func_mode(dev);
76}
77
78static void w83977tf_enable(device_t dev)
79{
80 w83977tf_enter_ext_func_mode(dev);
81 pnp_enable(dev);
82 w83977tf_exit_ext_func_mode(dev);
83}
84
85
86static struct device_operations ops = {
87 .read_resources = pnp_read_resources,
88 .set_resources = w83977tf_set_resources,
89 .enable_resources = w83977tf_enable_resources,
90 .enable = w83977tf_enable,
91 .init = w83977tf_init,
92};
93
94static struct pnp_info pnp_dev_info[] = {
95 { &ops, W83977TF_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, { 0x07f8, 0}, },
96 { &ops, W83977TF_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, { 0x07f8, 0}, },
97 { &ops, W83977TF_SP1, PNP_IO0 | PNP_IRQ0, { 0x7f8, 0 }, },
98 { &ops, W83977TF_SP2, PNP_IO0 | PNP_IRQ0, { 0x7f8, 0 }, },
99 // No 4 { 0,},
100 { &ops, W83977TF_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, { 0x7ff, 0 }, { 0x7ff, 0x4}, },
101 { &ops, W83977TF_CIR, PNP_IO0 | PNP_IRQ0, { 0x7f8, 0 }, },
102 { &ops, W83977TF_GAME_MIDI_GPIO1, PNP_IO0 | PNP_IO1 | PNP_IRQ0, { 0x7ff, 0 }, {0x7fe, 4} },
103 { &ops, W83977TF_ACPI, PNP_IRQ0, },
104};
105
106static void enable_dev(device_t dev)
107{
108 pnp_enable_devices(dev, &ops,
Carl-Daniel Hailfinger2ee67792008-10-01 12:52:52 +0000109 ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
Richard Smith924f92f2006-07-29 17:40:36 +0000110}
111
112struct chip_operations superio_winbond_w83977tf_ops = {
Uwe Hermanna7aa29b2006-11-05 18:50:49 +0000113 CHIP_NAME("Winbond W83977TF Super I/O")
Richard Smith924f92f2006-07-29 17:40:36 +0000114 .enable_dev = enable_dev,
115};