Felix Held | 3f3eca9 | 2020-01-23 17:12:32 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | /* This file is part of the coreboot project. */ |
Pavel Sayekat | 98d5a86 | 2019-07-01 19:53:29 +0600 | [diff] [blame] | 3 | |
| 4 | #include <device/device.h> |
| 5 | #include <device/pnp.h> |
| 6 | #include <pc80/keyboard.h> |
Pavel Sayekat | 98d5a86 | 2019-07-01 19:53:29 +0600 | [diff] [blame] | 7 | #include <superio/conf_mode.h> |
Pavel Sayekat | 98d5a86 | 2019-07-01 19:53:29 +0600 | [diff] [blame] | 8 | #include "nct5539d.h" |
| 9 | |
Maxim Polyakov | eef7c69 | 2019-11-27 13:01:24 +0300 | [diff] [blame] | 10 | #if CONFIG(HAVE_ACPI_TABLES) |
| 11 | #include <superio/common/ssdt.h> |
| 12 | #include <arch/acpi.h> |
| 13 | #endif |
Pavel Sayekat | 98d5a86 | 2019-07-01 19:53:29 +0600 | [diff] [blame] | 14 | |
| 15 | static void nct5539d_init(struct device *dev) |
| 16 | { |
| 17 | if (!dev->enabled) |
| 18 | return; |
| 19 | |
| 20 | switch (dev->path.pnp.device) { |
| 21 | case NCT5539D_KBC: |
| 22 | pc_keyboard_init(NO_AUX_DEVICE); |
| 23 | break; |
| 24 | } |
| 25 | } |
| 26 | |
Maxim Polyakov | 0dd8fe7 | 2019-10-27 15:07:00 +0300 | [diff] [blame] | 27 | #if CONFIG(HAVE_ACPI_TABLES) |
| 28 | /* Provide ACPI HIDs for generic Super I/O SSDT */ |
| 29 | static const char *nct5539d_acpi_hid(const struct device *dev) |
| 30 | { |
| 31 | if ((dev->path.type != DEVICE_PATH_PNP) || |
| 32 | (dev->path.pnp.port == 0) || |
| 33 | ((dev->path.pnp.device & 0xff) > NCT5539D_DS)) |
| 34 | return NULL; |
| 35 | |
| 36 | switch (dev->path.pnp.device & 0xff) { |
| 37 | case NCT5539D_SP1: |
| 38 | return ACPI_HID_COM; |
| 39 | case NCT5539D_KBC: |
| 40 | return ACPI_HID_KEYBOARD; |
| 41 | default: |
| 42 | return ACPI_HID_PNP; |
| 43 | } |
| 44 | } |
| 45 | #endif |
| 46 | |
Pavel Sayekat | 98d5a86 | 2019-07-01 19:53:29 +0600 | [diff] [blame] | 47 | static struct device_operations ops = { |
| 48 | .read_resources = pnp_read_resources, |
| 49 | .set_resources = pnp_set_resources, |
| 50 | .enable_resources = pnp_enable_resources, |
| 51 | .enable = pnp_alt_enable, |
| 52 | .init = nct5539d_init, |
| 53 | .ops_pnp_mode = &pnp_conf_mode_8787_aa, |
Maxim Polyakov | 0dd8fe7 | 2019-10-27 15:07:00 +0300 | [diff] [blame] | 54 | #if CONFIG(HAVE_ACPI_TABLES) |
| 55 | .acpi_fill_ssdt_generator = superio_common_fill_ssdt_generator, |
| 56 | .acpi_name = superio_common_ldn_acpi_name, |
| 57 | .acpi_hid = nct5539d_acpi_hid, |
| 58 | #endif |
Pavel Sayekat | 98d5a86 | 2019-07-01 19:53:29 +0600 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | static struct pnp_info pnp_dev_info[] = { |
| 62 | { NULL, NCT5539D_SP1, PNP_IO0 | PNP_IRQ0, |
| 63 | 0x0ff8, }, |
| 64 | { NULL, NCT5539D_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, |
| 65 | 0x0fff, 0x0fff, }, |
| 66 | { NULL, NCT5539D_CIR, PNP_IO0 | PNP_IRQ0, |
| 67 | 0x0ff8, }, |
| 68 | { NULL, NCT5539D_ACPI}, |
| 69 | { NULL, NCT5539D_HWM_FPLED, PNP_IO0 | PNP_IRQ0, |
| 70 | 0x0ffe, 0x0ffe, }, |
| 71 | { NULL, NCT5539D_WDT2}, |
| 72 | { NULL, NCT5539D_CIRWUP, PNP_IO0 | PNP_IRQ0, |
| 73 | 0x0ff8, }, |
| 74 | { NULL, NCT5539D_GPIO_PP_OD}, |
| 75 | { NULL, NCT5539D_WDT1}, |
| 76 | { NULL, NCT5539D_WDT3}, |
| 77 | { NULL, NCT5539D_GPIOBASE, PNP_IO0, |
| 78 | 0x0ff8, }, |
| 79 | { NULL, NCT5539D_GPIO0}, |
| 80 | { NULL, NCT5539D_GPIO2}, |
| 81 | { NULL, NCT5539D_GPIO3}, |
| 82 | { NULL, NCT5539D_GPIO4}, |
| 83 | { NULL, NCT5539D_GPIO5}, |
| 84 | { NULL, NCT5539D_GPIO7}, |
| 85 | { NULL, NCT5539D_GPIO8}, |
| 86 | { NULL, NCT5539D_GPIO_PSO}, |
| 87 | { NULL, NCT5539D_SWEC}, |
| 88 | { NULL, NCT5539D_FLED}, |
| 89 | { NULL, NCT5539D_DS5}, |
| 90 | { NULL, NCT5539D_DS3}, |
| 91 | }; |
| 92 | |
| 93 | static void enable_dev(struct device *dev) |
| 94 | { |
| 95 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 96 | } |
| 97 | |
| 98 | struct chip_operations superio_nuvoton_nct5539d_ops = { |
| 99 | CHIP_NAME("NUVOTON NCT5539D Super I/O") |
| 100 | .enable_dev = enable_dev, |
| 101 | }; |