blob: 7a4e3362784c49b705e910073ccb35427a3b09c6 [file] [log] [blame]
Krystian Hebel6d81b152019-02-26 12:02:16 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2006 Uwe Hermann <uwe@hermann-uwe.de>
5 * Copyright (C) 2007 Philipp Degler <pdegler@rumms.uni-mannheim.de>
6 * Copyright (C) 2017 Gergely Kiss <mail.gery@gmail.com>
7 * Copyright (C) 2019 Protectli
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
19
20#include <device/device.h>
21#include <device/pnp.h>
22#include <pc80/keyboard.h>
23#include <superio/conf_mode.h>
24#include <superio/ite/common/env_ctrl.h>
25
26#include "chip.h"
27#include "it8613e.h"
28
29static void it8613e_init(struct device *dev)
30{
31 const struct superio_ite_it8613e_config *conf = dev->chip_info;
32 const struct resource *res;
33
34 if (!dev->enabled)
35 return;
36
37 switch (dev->path.pnp.device) {
38 case IT8613E_EC:
39 res = find_resource(dev, PNP_IDX_IO0);
40 if (!conf || !res)
41 break;
42 ite_ec_init(res->base, &conf->ec);
43 break;
44 case IT8613E_KBCK:
45 pc_keyboard_init(NO_AUX_DEVICE);
46 break;
47 case IT8613E_KBCM:
48 break;
49 }
50}
51
52static struct device_operations ops = {
53 .read_resources = pnp_read_resources,
54 .set_resources = pnp_set_resources,
55 .enable_resources = pnp_enable_resources,
56 .enable = pnp_alt_enable,
57 .init = it8613e_init,
58 .ops_pnp_mode = &pnp_conf_mode_870155_aa,
59};
60
61static struct pnp_info pnp_dev_info[] = {
62 /* Serial Port 1 */
63 { NULL, IT8613E_SP1, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, 0x0ff8, },
64 /* Environmental Controller */
65 { NULL, IT8613E_EC, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0ff8, 0x0ff8, },
66 /* KBC Keyboard */
67 { NULL, IT8613E_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_MSC0,
68 0x0fff, 0x0fff, },
69 /* KBC Mouse */
70 { NULL, IT8613E_KBCM, PNP_IRQ0 | PNP_MSC0, },
71 /* GPIO */
72 { NULL, IT8613E_GPIO, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0ffc, 0x0ff8, },
73 /* Consumer Infrared */
74 { NULL, IT8613E_CIR, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, 0x0ff8, },
75};
76
77static void enable_dev(struct device *dev)
78{
79 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
80}
81
82struct chip_operations superio_ite_it8613e_ops = {
83 CHIP_NAME("ITE IT8613E Super I/O")
84 .enable_dev = enable_dev,
85};