Debian Codegraph @

src/superio/ite/it8772f/superio.c

raw symbols SCIP
1 /* 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/ite/common/env_ctrl.h>
7 #include <arch/io.h>
8 #include <delay.h>
9 #include <superio/conf_mode.h>
10 #include <superio/hwm5_conf.h>
11
12 #include "chip.h" /* FIXME */
13 #include "it8772f.h"
14
15 static void it8772f_init(struct device *dev)
16 {
17 struct superio_ite_it8772f_config *conf = dev->chip_info;
18 struct resource *res;
19
20 if (!dev->enabled)
21 return;
22
23 switch (dev->path.pnp.device) {
24 case IT8772F_EC:
25 res = probe_resource(dev, PNP_IDX_IO0);
26 if (!conf || !res)
27 break;
28 ite_ec_init(res->base, &conf->ec);
29 ite_ec_set_power_state(dev);
30 break;
31 case IT8772F_GPIO:
32 /* Set GPIO output levels */
33 res = probe_resource(dev, PNP_IDX_IO1);
34 if (res) {
35 if (conf->gpio_set1)
36 outb(conf->gpio_set1, res->base + 0);
37 if (conf->gpio_set2)
38 outb(conf->gpio_set2, res->base + 1);
39 if (conf->gpio_set3)
40 outb(conf->gpio_set3, res->base + 2);
41 if (conf->gpio_set4)
42 outb(conf->gpio_set4, res->base + 3);
43 if (conf->gpio_set5)
44 outb(conf->gpio_set5, res->base + 4);
45 if (conf->gpio_set6)
46 outb(conf->gpio_set6, res->base + 5);
47 }
48 break;
49 case IT8772F_KBCK:
50 if (!conf->skip_keyboard) {
51 set_kbc_ps2_mode();
52 pc_keyboard_init(NO_AUX_DEVICE);
53 }
54 break;
55 case IT8772F_KBCM:
56 break;
57 case IT8772F_IR:
58 break;
59 }
60 }
61
62 static struct device_operations ops = {
63 .read_resources = pnp_read_resources,
64 .set_resources = pnp_set_resources,
65 .enable_resources = pnp_enable_resources,
66 .enable = pnp_alt_enable,
67 .init = it8772f_init,
68 .ops_pnp_mode = &pnp_conf_mode_870155_aa,
69 };
70
71 static struct pnp_info pnp_dev_info[] = {
72 /* Floppy Disk Controller */
73 { NULL, IT8772F_FDC, PNP_IO0 | PNP_IRQ0, 0x0ff8, },
74 /* Serial Port 1 */
75 { NULL, IT8772F_SP1, PNP_IO0 | PNP_IRQ0, 0x0ff8, },
76 /* Environmental Controller */
77 { NULL, IT8772F_EC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 |
78 PNP_MSC4 | PNP_MSCA,
79 0x0ff8, 0x0ffc, },
80 /* KBC Keyboard */
81 { NULL, IT8772F_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0,
82 0x0fff, 0x0fff, },
83 /* KBC Mouse */
84 { NULL, IT8772F_KBCM, PNP_IRQ0, },
85 /* 27 GPIOs */
86 { NULL, IT8772F_GPIO, PNP_IO0 | PNP_IO1,
87 0x0fff, 0x0ff8, },
88 /* Infrared */
89 { NULL, IT8772F_IR, PNP_IO0 | PNP_IRQ0, 0x0ff8, },
90 };
91
92 static void enable_dev(struct device *dev)
93 {
94 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
95 }
96
97 struct chip_operations superio_ite_it8772f_ops = {
98 .name = "ITE IT8772F Super I/O",
99 .enable_dev = enable_dev,
100 };