Omar Pakker | 449fb9b | 2016-07-29 19:05:33 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Advanced Micro Devices, Inc. |
| 5 | * Copyright (C) 2014 Felix Held <felix-coreboot@felixheld.de> |
| 6 | * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com> |
| 7 | * Copyright (C) 2015 Matt DeVillier <matt.devillier@gmail.com> |
| 8 | * Copyright (C) 2016 Omar Pakker <omarpakker+coreboot@gmail.com> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation; either version 2 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | */ |
| 20 | |
| 21 | #include <arch/io.h> |
| 22 | #include <device/device.h> |
| 23 | #include <device/pnp.h> |
| 24 | #include <pc80/keyboard.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <superio/conf_mode.h> |
| 27 | |
| 28 | #include "nct6791d.h" |
| 29 | |
| 30 | |
| 31 | static void nct6791d_init(struct device *dev) |
| 32 | { |
| 33 | if (!dev->enabled) |
| 34 | return; |
| 35 | |
| 36 | switch (dev->path.pnp.device) { |
| 37 | case NCT6791D_KBC: |
| 38 | pc_keyboard_init(NO_AUX_DEVICE); |
| 39 | break; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | static struct device_operations ops = { |
| 44 | .read_resources = pnp_read_resources, |
| 45 | .set_resources = pnp_set_resources, |
| 46 | .enable_resources = pnp_enable_resources, |
| 47 | .enable = pnp_alt_enable, |
| 48 | .init = nct6791d_init, |
| 49 | .ops_pnp_mode = &pnp_conf_mode_8787_aa, |
| 50 | }; |
| 51 | |
| 52 | static struct pnp_info pnp_dev_info[] = { |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame^] | 53 | { NULL, NCT6791D_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 54 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame^] | 55 | { NULL, NCT6791D_SP1, PNP_IO0 | PNP_IRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 56 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame^] | 57 | { NULL, NCT6791D_SP2, PNP_IO0 | PNP_IRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 58 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame^] | 59 | { NULL, NCT6791D_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 60 | 0x0fff, 0x0fff, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame^] | 61 | { NULL, NCT6791D_CIR, PNP_IO0 | PNP_IRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 62 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame^] | 63 | { NULL, NCT6791D_ACPI}, |
| 64 | { NULL, NCT6791D_HWM_FPLED, PNP_IO0 | PNP_IO1 | PNP_IRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 65 | 0x0ffe, 0x0ffe, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame^] | 66 | { NULL, NCT6791D_BCLK_WDT2_WDTMEM}, |
| 67 | { NULL, NCT6791D_CIRWUP, PNP_IO0 | PNP_IRQ0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 68 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame^] | 69 | { NULL, NCT6791D_GPIO_PP_OD}, |
| 70 | { NULL, NCT6791D_PORT80}, |
| 71 | { NULL, NCT6791D_WDT1}, |
| 72 | { NULL, NCT6791D_WDTMEM}, |
| 73 | { NULL, NCT6791D_GPIOBASE, PNP_IO0, |
Samuel Holland | 7daac91 | 2017-06-06 22:55:01 -0500 | [diff] [blame] | 74 | 0x0ff8, }, |
Felix Held | 9911d64 | 2018-07-06 20:55:53 +0200 | [diff] [blame^] | 75 | { NULL, NCT6791D_GPIO0}, |
| 76 | { NULL, NCT6791D_GPIO1}, |
| 77 | { NULL, NCT6791D_GPIO2}, |
| 78 | { NULL, NCT6791D_GPIO3}, |
| 79 | { NULL, NCT6791D_GPIO4}, |
| 80 | { NULL, NCT6791D_GPIO5}, |
| 81 | { NULL, NCT6791D_GPIO6}, |
| 82 | { NULL, NCT6791D_GPIO7}, |
| 83 | { NULL, NCT6791D_GPIO8}, |
| 84 | { NULL, NCT6791D_DS5}, |
| 85 | { NULL, NCT6791D_DS3}, |
| 86 | { NULL, NCT6791D_PCHDSW}, |
| 87 | { NULL, NCT6791D_DSWWOPT}, |
| 88 | { NULL, NCT6791D_DS3OPT}, |
| 89 | { NULL, NCT6791D_DSDSS}, |
| 90 | { NULL, NCT6791D_DSPU}, |
Omar Pakker | 449fb9b | 2016-07-29 19:05:33 +0200 | [diff] [blame] | 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_nct6791d_ops = { |
| 99 | CHIP_NAME("NUVOTON NCT6791D Super I/O") |
| 100 | .enable_dev = enable_dev, |
| 101 | }; |