1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <device/device.h>
4 #include <device/pnp.h>
5 #include <pc80/keyboard.h>
6 #include <superio/conf_mode.h>
9 #if CONFIG(HAVE_ACPI_TABLES)
10 #include <superio/common/ssdt.h>
11 #include <acpi/acpi.h>
14 static void nct5539d_init(struct device
*dev
)
19 switch (dev
->path
.pnp
.device
) {
21 pc_keyboard_init(NO_AUX_DEVICE
);
26 #if CONFIG(HAVE_ACPI_TABLES)
27 /* Provide ACPI HIDs for generic Super I/O SSDT */
28 static const char *nct5539d_acpi_hid(const struct device
*dev
)
30 if ((dev
->path
.type
!= DEVICE_PATH_PNP
) ||
31 (dev
->path
.pnp
.port
== 0) ||
32 ((dev
->path
.pnp
.device
& 0xff) > NCT5539D_DS
))
35 switch (dev
->path
.pnp
.device
& 0xff) {
39 return ACPI_HID_KEYBOARD
;
46 static struct device_operations ops
= {
47 .read_resources
= pnp_read_resources
,
48 .set_resources
= pnp_set_resources
,
49 .enable_resources
= pnp_enable_resources
,
50 .enable
= pnp_alt_enable
,
51 .init
= nct5539d_init
,
52 .ops_pnp_mode
= &pnp_conf_mode_8787_aa
,
53 #if CONFIG(HAVE_ACPI_TABLES)
54 .acpi_fill_ssdt
= superio_common_fill_ssdt_generator
,
55 .acpi_name
= superio_common_ldn_acpi_name
,
56 .acpi_hid
= nct5539d_acpi_hid
,
60 static struct pnp_info pnp_dev_info
[] = {
61 { NULL
, NCT5539D_SP1
, PNP_IO0
| PNP_IRQ0
,
63 { NULL
, NCT5539D_KBC
, PNP_IO0
| PNP_IO1
| PNP_IRQ0
| PNP_IRQ1
,
65 { NULL
, NCT5539D_CIR
, PNP_IO0
| PNP_IRQ0
,
67 { NULL
, NCT5539D_ACPI
},
68 { NULL
, NCT5539D_HWM_FPLED
, PNP_IO0
| PNP_IRQ0
,
70 { NULL
, NCT5539D_WDT2
},
71 { NULL
, NCT5539D_CIRWUP
, PNP_IO0
| PNP_IRQ0
,
73 { NULL
, NCT5539D_GPIO_PP_OD
},
74 { NULL
, NCT5539D_WDT1
},
75 { NULL
, NCT5539D_WDT3
},
76 { NULL
, NCT5539D_GPIOBASE
, PNP_IO0
,
78 { NULL
, NCT5539D_GPIO0
},
79 { NULL
, NCT5539D_GPIO2
},
80 { NULL
, NCT5539D_GPIO3
},
81 { NULL
, NCT5539D_GPIO4
},
82 { NULL
, NCT5539D_GPIO5
},
83 { NULL
, NCT5539D_GPIO7
},
84 { NULL
, NCT5539D_GPIO8
},
85 { NULL
, NCT5539D_GPIO_PSO
},
86 { NULL
, NCT5539D_SWEC
},
87 { NULL
, NCT5539D_FLED
},
88 { NULL
, NCT5539D_DS5
},
89 { NULL
, NCT5539D_DS3
},
92 static void enable_dev(struct device
*dev
)
94 pnp_enable_devices(dev
, &ops
, ARRAY_SIZE(pnp_dev_info
), pnp_dev_info
);
97 struct chip_operations superio_nuvoton_nct5539d_ops
= {
98 .name
= "NUVOTON NCT5539D Super I/O",
99 .enable_dev
= enable_dev
,