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. */ |
Omar Pakker | 449fb9b | 2016-07-29 19:05:33 +0200 | [diff] [blame] | 3 | |
Omar Pakker | 449fb9b | 2016-07-29 19:05:33 +0200 | [diff] [blame] | 4 | #include <device/device.h> |
| 5 | #include <device/pnp.h> |
| 6 | #include <pc80/keyboard.h> |
Omar Pakker | 449fb9b | 2016-07-29 19:05:33 +0200 | [diff] [blame] | 7 | #include <superio/conf_mode.h> |
Maxim Polyakov | facbf47 | 2019-10-27 15:07:00 +0300 | [diff] [blame] | 8 | #include <superio/common/ssdt.h> |
| 9 | #include <arch/acpi.h> |
Omar Pakker | 449fb9b | 2016-07-29 19:05:33 +0200 | [diff] [blame] | 10 | #include "nct6791d.h" |
| 11 | |
Omar Pakker | 449fb9b | 2016-07-29 19:05:33 +0200 | [diff] [blame] | 12 | static void nct6791d_init(struct device *dev) |
| 13 | { |
| 14 | if (!dev->enabled) |
| 15 | return; |
| 16 | |
| 17 | switch (dev->path.pnp.device) { |
| 18 | case NCT6791D_KBC: |
| 19 | pc_keyboard_init(NO_AUX_DEVICE); |
| 20 | break; |
| 21 | } |
| 22 | } |
| 23 | |
Maxim Polyakov | facbf47 | 2019-10-27 15:07:00 +0300 | [diff] [blame] | 24 | #if CONFIG(HAVE_ACPI_TABLES) |
| 25 | /* Provide ACPI HIDs for generic Super I/O SSDT */ |
| 26 | static const char *nct6791d_acpi_hid(const struct device *dev) |
| 27 | { |
| 28 | if ((dev->path.type != DEVICE_PATH_PNP) || |
| 29 | (dev->path.pnp.port == 0) || |
| 30 | ((dev->path.pnp.device & 0xff) > NCT6791D_DS)) |
| 31 | return NULL; |
| 32 | |
| 33 | switch (dev->path.pnp.device & 0xff) { |
Elyes HAOUAS | 9a669b1 | 2019-12-05 09:14:30 +0100 | [diff] [blame] | 34 | case NCT6791D_SP1: /* fallthrough */ |
Maxim Polyakov | facbf47 | 2019-10-27 15:07:00 +0300 | [diff] [blame] | 35 | case NCT6791D_SP2: |
| 36 | return ACPI_HID_COM; |
| 37 | case NCT6791D_KBC: |
| 38 | return ACPI_HID_KEYBOARD; |
| 39 | default: |
| 40 | return ACPI_HID_PNP; |
| 41 | } |
| 42 | } |
| 43 | #endif |
| 44 | |
Omar Pakker | 449fb9b | 2016-07-29 19:05:33 +0200 | [diff] [blame] | 45 | static struct device_operations ops = { |
| 46 | .read_resources = pnp_read_resources, |
| 47 | .set_resources = pnp_set_resources, |
| 48 | .enable_resources = pnp_enable_resources, |
| 49 | .enable = pnp_alt_enable, |
| 50 | .init = nct6791d_init, |
| 51 | .ops_pnp_mode = &pnp_conf_mode_8787_aa, |
Maxim Polyakov | facbf47 | 2019-10-27 15:07:00 +0300 | [diff] [blame] | 52 | #if CONFIG(HAVE_ACPI_TABLES) |
Nico Huber | 68680dd | 2020-03-31 17:34:52 +0200 | [diff] [blame^] | 53 | .acpi_fill_ssdt = superio_common_fill_ssdt_generator, |
| 54 | .acpi_name = superio_common_ldn_acpi_name, |
| 55 | .acpi_hid = nct6791d_acpi_hid, |
Maxim Polyakov | facbf47 | 2019-10-27 15:07:00 +0300 | [diff] [blame] | 56 | #endif |
Omar Pakker | 449fb9b | 2016-07-29 19:05:33 +0200 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | static struct pnp_info pnp_dev_info[] = { |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 60 | { NULL, NCT6791D_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 61 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 62 | { NULL, NCT6791D_SP1, PNP_IO0 | PNP_IRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 63 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 64 | { NULL, NCT6791D_SP2, PNP_IO0 | PNP_IRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 65 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 66 | { NULL, NCT6791D_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 67 | 0x0fff, 0x0fff, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 68 | { NULL, NCT6791D_CIR, PNP_IO0 | PNP_IRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 69 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 70 | { NULL, NCT6791D_ACPI}, |
| 71 | { NULL, NCT6791D_HWM_FPLED, PNP_IO0 | PNP_IO1 | PNP_IRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 72 | 0x0ffe, 0x0ffe, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 73 | { NULL, NCT6791D_BCLK_WDT2_WDTMEM}, |
| 74 | { NULL, NCT6791D_CIRWUP, PNP_IO0 | PNP_IRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 75 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 76 | { NULL, NCT6791D_GPIO_PP_OD}, |
| 77 | { NULL, NCT6791D_PORT80}, |
| 78 | { NULL, NCT6791D_WDT1}, |
| 79 | { NULL, NCT6791D_WDTMEM}, |
| 80 | { NULL, NCT6791D_GPIOBASE, PNP_IO0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 81 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame] | 82 | { NULL, NCT6791D_GPIO0}, |
| 83 | { NULL, NCT6791D_GPIO1}, |
| 84 | { NULL, NCT6791D_GPIO2}, |
| 85 | { NULL, NCT6791D_GPIO3}, |
| 86 | { NULL, NCT6791D_GPIO4}, |
| 87 | { NULL, NCT6791D_GPIO5}, |
| 88 | { NULL, NCT6791D_GPIO6}, |
| 89 | { NULL, NCT6791D_GPIO7}, |
| 90 | { NULL, NCT6791D_GPIO8}, |
| 91 | { NULL, NCT6791D_DS5}, |
| 92 | { NULL, NCT6791D_DS3}, |
| 93 | { NULL, NCT6791D_PCHDSW}, |
| 94 | { NULL, NCT6791D_DSWWOPT}, |
| 95 | { NULL, NCT6791D_DS3OPT}, |
| 96 | { NULL, NCT6791D_DSDSS}, |
| 97 | { NULL, NCT6791D_DSPU}, |
Omar Pakker | 449fb9b | 2016-07-29 19:05:33 +0200 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | static void enable_dev(struct device *dev) |
| 101 | { |
| 102 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 103 | } |
| 104 | |
| 105 | struct chip_operations superio_nuvoton_nct6791d_ops = { |
| 106 | CHIP_NAME("NUVOTON NCT6791D Super I/O") |
| 107 | .enable_dev = enable_dev, |
| 108 | }; |