blob: d735a5948f27fa8d286cf5930faf4ee14bafc6b6 [file] [log] [blame]
Gergely Kissc9c29262017-12-27 15:19: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 *
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
19#include <device/device.h>
20#include <device/pnp.h>
21#include <pc80/keyboard.h>
22#include <arch/io.h>
23#include <stdlib.h>
24#include <superio/conf_mode.h>
Kevin Cody-Littlef5f552a2018-05-10 21:33:03 -040025#include <superio/ite/common/env_ctrl.h>
Gergely Kissc9c29262017-12-27 15:19:16 +010026
Kevin Cody-Littlef5f552a2018-05-10 21:33:03 -040027#include "chip.h"
Gergely Kissc9c29262017-12-27 15:19:16 +010028#include "it8623e.h"
29
30static void it8623e_init(struct device *dev)
31{
Kevin Cody-Littlef5f552a2018-05-10 21:33:03 -040032 const struct superio_ite_it8623e_config *conf = dev->chip_info;
33 const struct resource *res;
Gergely Kissc9c29262017-12-27 15:19:16 +010034
35 if (!dev->enabled)
36 return;
37
38 switch (dev->path.pnp.device) {
39 case IT8623E_EC:
Kevin Cody-Littlef5f552a2018-05-10 21:33:03 -040040 res = find_resource(dev, PNP_IDX_IO0);
41 if (!conf || !res)
42 break;
43 ite_ec_init(res->base, &conf->ec);
Gergely Kissc9c29262017-12-27 15:19:16 +010044 break;
45 case IT8623E_KBCK:
46 pc_keyboard_init(NO_AUX_DEVICE);
47 break;
48 case IT8623E_KBCM:
49 break;
50 }
51}
52
53static struct device_operations ops = {
54 .read_resources = pnp_read_resources,
55 .set_resources = pnp_set_resources,
56 .enable_resources = pnp_enable_resources,
57 .enable = pnp_alt_enable,
58 .init = it8623e_init,
59 .ops_pnp_mode = &pnp_conf_mode_870155_aa,
60};
61
62static struct pnp_info pnp_dev_info[] = {
Felix Heldc40275b2017-12-27 22:11:30 +010063 { NULL, IT8623E_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x0ff8, },
64 { NULL, IT8623E_SP1, PNP_IO0 | PNP_IRQ0, 0x0ff8, },
65 { NULL, IT8623E_SP2, PNP_IO0 | PNP_IRQ0, 0x0ff8, },
66 { NULL, IT8623E_PP, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_DRQ0,
67 0x0ff8, 0x0ff8, },
68 { NULL, IT8623E_EC, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0ff0, 0x0ff0, },
69 { NULL, IT8623E_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0fff, 0x0fff, },
70 { NULL, IT8623E_KBCM, PNP_IRQ0, },
71 { NULL, IT8623E_GPIO, PNP_IO0 | PNP_IO1 | PNP_IO2 | PNP_IRQ0,
72 0x0fff, 0x0fe0, 0x0fff, },
Gergely Kissc9c29262017-12-27 15:19:16 +010073};
74
75static void enable_dev(struct device *dev)
76{
Felix Heldc40275b2017-12-27 22:11:30 +010077 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
Gergely Kissc9c29262017-12-27 15:19:16 +010078}
79
80struct chip_operations superio_ite_it8623e_ops = {
81 CHIP_NAME("ITE IT8623E Super I/O")
82 .enable_dev = enable_dev,
83};