Add IT8721F support
[coreboot.git] / src / superio / ite / it8721f / superio.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de>
5  * Copyright (C) 2011 QingPei Wang <wangqingpei@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20  */
21
22 #include <device/device.h>
23 #include <device/pnp.h>
24 #include <uart8250.h>
25 #include <pc80/keyboard.h>
26 #include <stdlib.h>
27 #include "chip.h"
28 #include "it8721f.h"
29
30 static void init(device_t dev)
31 {
32         struct superio_ite_it8721f_config *conf = dev->chip_info;
33
34         if (!dev->enabled)
35                 return;
36
37         switch (dev->path.pnp.device) {
38         case IT8721F_FDC: /* TODO. */
39                 break;
40         case IT8721F_PP: /* TODO. */
41                 break;
42         case IT8721F_EC: /* TODO. */
43                 break;
44         case IT8721F_KBCK:
45                 pc_keyboard_init(&conf->keyboard);
46                 break;
47         case IT8721F_KBCM: /* TODO. */
48                 break;
49         case IT8721F_IR: /* TODO. */
50                 break;
51         }
52 }
53
54 static struct device_operations ops = {
55         .read_resources   = pnp_read_resources,
56         .set_resources    = pnp_set_resources,
57         .enable_resources = pnp_enable_resources,
58         .enable           = pnp_enable,
59         .init             = init,
60 };
61
62 /* TODO: FDC, PP, EC, KBCM, IR. */
63 static struct pnp_info pnp_dev_info[] = {
64         { &ops, IT8721F_SP1,  PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
65         { &ops, IT8721F_SP2,  PNP_IO0 | PNP_IRQ0 | PNP_DRQ0 | PNP_DRQ1, {0x07f8, 0}, },
66         { &ops, IT8721F_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, {0x07f8, 0}, {0x07f8, 4}, },
67 };
68
69 static void enable_dev(struct device *dev)
70 {
71         pnp_enable_devices(dev, &pnp_ops,
72                 ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
73 }
74
75 struct chip_operations superio_ite_it8721f_ops = {
76         CHIP_NAME("ITE IT8721F Super I/O")
77         .enable_dev = enable_dev,
78 };