blob: 78241b21dbcc5d2c58408c83c7793c4c1aee3b44 [file] [log] [blame]
Felix Held3f3eca92020-01-23 17:12:32 +01001/* SPDX-License-Identifier: GPL-2.0-or-later */
Krystian Hebel6d81b152019-02-26 12:02:16 +01002
3#include <device/device.h>
4#include <device/pnp.h>
5#include <pc80/keyboard.h>
6#include <superio/conf_mode.h>
7#include <superio/ite/common/env_ctrl.h>
8
9#include "chip.h"
10#include "it8613e.h"
11
12static void it8613e_init(struct device *dev)
13{
14 const struct superio_ite_it8613e_config *conf = dev->chip_info;
15 const struct resource *res;
16
17 if (!dev->enabled)
18 return;
19
20 switch (dev->path.pnp.device) {
21 case IT8613E_EC:
Angel Ponsc167b742021-11-03 13:25:02 +010022 res = probe_resource(dev, PNP_IDX_IO0);
Krystian Hebel6d81b152019-02-26 12:02:16 +010023 if (!conf || !res)
24 break;
25 ite_ec_init(res->base, &conf->ec);
26 break;
27 case IT8613E_KBCK:
28 pc_keyboard_init(NO_AUX_DEVICE);
29 break;
30 case IT8613E_KBCM:
31 break;
32 }
33}
34
35static struct device_operations ops = {
36 .read_resources = pnp_read_resources,
37 .set_resources = pnp_set_resources,
38 .enable_resources = pnp_enable_resources,
39 .enable = pnp_alt_enable,
40 .init = it8613e_init,
41 .ops_pnp_mode = &pnp_conf_mode_870155_aa,
42};
43
44static struct pnp_info pnp_dev_info[] = {
45 /* Serial Port 1 */
46 { NULL, IT8613E_SP1, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, 0x0ff8, },
47 /* Environmental Controller */
48 { NULL, IT8613E_EC, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0ff8, 0x0ff8, },
49 /* KBC Keyboard */
50 { NULL, IT8613E_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_MSC0,
51 0x0fff, 0x0fff, },
52 /* KBC Mouse */
53 { NULL, IT8613E_KBCM, PNP_IRQ0 | PNP_MSC0, },
54 /* GPIO */
55 { NULL, IT8613E_GPIO, PNP_IO0 | PNP_IO1 | PNP_IRQ0, 0x0ffc, 0x0ff8, },
56 /* Consumer Infrared */
57 { NULL, IT8613E_CIR, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, 0x0ff8, },
58};
59
60static void enable_dev(struct device *dev)
61{
62 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
63}
64
65struct chip_operations superio_ite_it8613e_ops = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +090066 .name = "ITE IT8613E Super I/O",
Krystian Hebel6d81b152019-02-26 12:02:16 +010067 .enable_dev = enable_dev,
68};