blob: 5304f9edc6f4a38558a0f3dc8de06f100b6747a6 [file] [log] [blame]
Felix Held3f3eca92020-01-23 17:12:32 +01001/* SPDX-License-Identifier: GPL-2.0-or-later */
Richard Spiegelae5b3672019-06-19 13:57:55 -07002
3#include <device/device.h>
4#include <device/pnp.h>
5#include <superio/conf_mode.h>
Richard Spiegelae5b3672019-06-19 13:57:55 -07006#include <pc80/keyboard.h>
7#include "f81803a.h"
8
9static void f81803a_pme_init(struct device *dev)
10{
11 pnp_enter_conf_mode(dev);
12 pnp_write_config(dev, LDN_REG, F81803A_PME);
13 /* enable ERP function*/
14 /* also set PSIN to generate PSOUT*/
15 pnp_write_config(dev, PME_ERP_ENABLE_REG, ERP_ENABLE | ERP_PSOUT_EN);
16 pnp_exit_conf_mode(dev);
17}
18
19static void f81803a_init(struct device *dev)
20{
21 if (!dev->enabled)
22 return;
23 switch (dev->path.pnp.device) {
24 /* TODO: Might potentially need code for GPIO or WDT. */
25 case F81803A_KBC:
26 pc_keyboard_init(NO_AUX_DEVICE);
27 break;
28 case F81803A_PME:
29 f81803a_pme_init(dev);
30 break;
31 }
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 = f81803a_init,
41 .ops_pnp_mode = &pnp_conf_mode_8787_aa,
42};
43
44static struct pnp_info pnp_dev_info[] = {
45 { &ops, F81803A_SP1, PNP_IO0 | PNP_IRQ0, 0x7f8, },
46 { &ops, F81803A_SP2, PNP_IO0 | PNP_IRQ0, 0x7f8, },
47 { &ops, F81803A_HWM, PNP_IO0 | PNP_IRQ0, 0xff8, },
48 { &ops, F81803A_KBC, PNP_IO0 | PNP_IRQ0 | PNP_IRQ1, 0x07f8, },
49 { &ops, F81803A_GPIO, PNP_IO0 | PNP_IRQ0, 0x7f8, },
50 { &ops, F81803A_WDT, PNP_IO0, 0x7f8 },
51 { &ops, F81803A_PME, },
52};
53
54static void enable_dev(struct device *dev)
55{
56 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
57}
58
59struct chip_operations superio_fintek_f81803a_ops = {
60 CHIP_NAME("Fintek F81803A Super I/O")
61 .enable_dev = enable_dev
62};