blob: 1caa837755a2ffdebad68c224833ec82126af590 [file] [log] [blame]
Michał Żygowski65034742023-04-03 13:14:02 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
2
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 "it8784e.h"
10#include "chip.h"
11
12static void it8784e_init(struct device *const dev)
13{
14 const struct superio_ite_it8784e_config *conf;
15 const struct resource *res;
16
17 if (!dev->enabled)
18 return;
19
20 switch (dev->path.pnp.device) {
21 case IT8784E_EC:
22 conf = dev->chip_info;
23 res = probe_resource(dev, PNP_IDX_IO0);
24 if (!conf || !res)
25 break;
26 ite_ec_init(res->base, &conf->ec);
27 break;
28 case IT8784E_KBCK:
29 pc_keyboard_init(NO_AUX_DEVICE);
30 break;
31 default:
32 break;
33 }
34}
35
36static struct device_operations ops = {
37 .read_resources = pnp_read_resources,
38 .set_resources = pnp_set_resources,
39 .enable_resources = pnp_enable_resources,
40 .enable = pnp_alt_enable,
41 .init = it8784e_init,
42 .ops_pnp_mode = &pnp_conf_mode_870155_aa,
43};
44
45static struct pnp_info pnp_dev_info[] = {
46 /* Serial Port 1 */
47 { NULL, IT8784E_SP1, PNP_IO0 | PNP_IRQ0 | PNP_MSC0 | PNP_MSC1 |
48 PNP_MSC2,
49 0x0ff8, },
50 /* Serial Port 2 */
51 { NULL, IT8784E_SP2, PNP_IO0 | PNP_IRQ0 | PNP_MSC0 | PNP_MSC1 |
52 PNP_MSC2,
53 0x0ff8, },
54 /* Printer Port */
55 { NULL, IT8784E_PP, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_DRQ0 |
56 PNP_MSC0,
57 0x0ff8, 0x0ffc, },
58 /* Environmental Controller */
59 { NULL, IT8784E_EC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_MSC0 |
60 PNP_MSC1 | PNP_MSC2 | PNP_MSC3 | PNP_MSC4 |
61 PNP_MSC5 | PNP_MSC6 | PNP_MSCA | PNP_MSCB |
62 PNP_MSCC,
63 0x0ff8, 0x0ffc, },
64 /* KBC Keyboard */
65 { NULL, IT8784E_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_MSC0,
66 0x0fff, 0x0fff, },
67 /* KBC Mouse */
68 { NULL, IT8784E_KBCM, PNP_IRQ0 | PNP_MSC0, },
69 /* GPIO */
70 { NULL, IT8784E_GPIO, PNP_IO0 | PNP_IO1 | PNP_IRQ0 |
71 PNP_MSC0 | PNP_MSC1 | PNP_MSC2 | PNP_MSC3 |
72 PNP_MSC4 | PNP_MSC5 | PNP_MSC6 | PNP_MSC7 |
73 PNP_MSC8 | PNP_MSC9 | PNP_MSCA | PNP_MSCB,
74 0x0ffc, 0x0fff, },
75 /* Consumer Infrared */
76 { NULL, IT8784E_CIR, PNP_IO0 | PNP_IRQ0 | PNP_MSC0, 0x0ff8, },
77};
78
79static void enable_dev(struct device *dev)
80{
81 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
82}
83
84struct chip_operations superio_ite_it8784e_ops = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +090085 .name = "ITE IT8784E Super I/O",
Michał Żygowski65034742023-04-03 13:14:02 +020086 .enable_dev = enable_dev,
87};