blob: 74ffefa44cfdd93202b583b8593b4ded214437d2 [file] [log] [blame]
Samuel Holland1318ea62017-06-03 03:52:57 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2016 secunet Security Networks AG
5 * Copyright (C) 2017 Samuel Holland <samuel@sholland.org>
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
18#include <device/device.h>
19#include <device/pnp.h>
20#include <pc80/keyboard.h>
21#include <superio/ite/common/env_ctrl.h>
22#include <superio/conf_mode.h>
23
24#include "chip.h"
25#include "it8720f.h"
26
27static void it8720f_init(struct device *dev)
28{
29 const struct superio_ite_it8720f_config *conf;
30 const struct resource *res;
31
32 if (!dev->enabled)
33 return;
34
35 switch (dev->path.pnp.device) {
36 case IT8720F_EC:
37 conf = dev->chip_info;
38 res = find_resource(dev, PNP_IDX_IO0);
39 if (!conf || !res)
40 break;
41 ite_ec_init(res->base, &conf->ec);
42 break;
43 case IT8720F_KBCK:
44 pc_keyboard_init(NO_AUX_DEVICE);
45 break;
46 default:
47 break;
48 }
49}
50
51static struct device_operations ops = {
52 .read_resources = pnp_read_resources,
53 .set_resources = pnp_set_resources,
54 .enable_resources = pnp_enable_resources,
55 .enable = pnp_enable,
56 .init = it8720f_init,
57 .ops_pnp_mode = &pnp_conf_mode_870155_aa,
58};
59
60static struct pnp_info pnp_dev_info[] = {
61 { &ops, IT8720F_FDC,
62 PNP_IO0 | PNP_IRQ0 | PNP_DRQ0 | PNP_MSC0 | PNP_MSC1,
63 {0x0ff8, 0}, },
64 { &ops, IT8720F_SP1,
65 PNP_IO0 | PNP_IRQ0 | PNP_MSC0 | PNP_MSC1,
66 {0x0ff8, 0}, },
67 { &ops, IT8720F_SP2,
68 PNP_IO0 | PNP_IRQ0 | PNP_MSC0 | PNP_MSC1,
69 {0x0ff8, 0}, },
70 { &ops, IT8720F_PP,
71 PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_DRQ0 | PNP_MSC0,
72 {0x0ff8, 0}, {0x0ffc, 0}, },
73 { &ops, IT8720F_EC,
74 PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_MSC0 | PNP_MSC1 | PNP_MSC2 |
75 PNP_MSC3 | PNP_MSC4 | PNP_MSC5 | PNP_MSC6,
76 {0x0ff8, 0}, {0x0ffc, 0}, },
77 { &ops, IT8720F_KBCK,
78 PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_MSC0,
79 {0x0fff, 0}, {0x0fff, 0}, },
80 { &ops, IT8720F_KBCM,
81 PNP_IRQ0 | PNP_MSC0, },
82 { &ops, IT8720F_GPIO,
83 PNP_IO0 | PNP_IO1 | PNP_IO2 | PNP_MSC0 | PNP_MSC1 | PNP_MSC2 |
84 PNP_MSC3 | PNP_MSC4 | PNP_MSC5 | PNP_MSC6 | PNP_MSC7 |
85 PNP_MSC8 | PNP_MSC9 | PNP_MSCA | PNP_MSCB | PNP_MSCD | PNP_MSCE,
86 {0x0ff8, 0}, {0x0ff8, 0}, {0x0ff8, 0}, },
87 { &ops, IT8720F_CIR,
88 PNP_IO0 | PNP_IRQ0 | PNP_MSC0,
89 {0x0ff8, 0}, },
90};
91
92static void enable_dev(struct device *dev)
93{
94 pnp_enable_devices(dev, &pnp_ops,
95 ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
96}
97
98struct chip_operations superio_ite_it8720f_ops = {
99 CHIP_NAME("ITE IT8720F Super I/O")
100 .enable_dev = enable_dev,
101};