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[] = { |
| 53 | { &ops, NCT6791D_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, |
| 54 | {0x0ff8, 0}, }, |
| 55 | { &ops, NCT6791D_SP1, PNP_IO0 | PNP_IRQ0, |
| 56 | {0x0ff8, 0}, }, |
| 57 | { &ops, NCT6791D_SP2, PNP_IO0 | PNP_IRQ0, |
| 58 | {0x0ff8, 0}, }, |
| 59 | { &ops, NCT6791D_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, |
| 60 | {0x0fff, 0}, {0x0fff, 4}, }, |
| 61 | { &ops, NCT6791D_CIR, PNP_IO0 | PNP_IRQ0, |
| 62 | {0x0ff8, 0}, }, |
| 63 | { &ops, NCT6791D_ACPI}, |
| 64 | { &ops, NCT6791D_HWM_FPLED, PNP_IO0 | PNP_IO1 | PNP_IRQ0, |
| 65 | {0x0ffe, 0}, {0x0ffe, 4}, }, |
| 66 | { &ops, NCT6791D_BCLK_WDT2_WDTMEM}, |
| 67 | { &ops, NCT6791D_CIRWUP, PNP_IO0 | PNP_IRQ0, |
| 68 | {0x0ff8, 0}, }, |
| 69 | { &ops, NCT6791D_GPIO_PP_OD}, |
| 70 | { &ops, NCT6791D_PORT80}, |
| 71 | { &ops, NCT6791D_WDT1}, |
| 72 | { &ops, NCT6791D_WDTMEM}, |
| 73 | { &ops, NCT6791D_GPIOBASE, PNP_IO0, |
| 74 | {0x0ff8, 0}, }, |
| 75 | { &ops, NCT6791D_GPIO0}, |
| 76 | { &ops, NCT6791D_GPIO1}, |
| 77 | { &ops, NCT6791D_GPIO2}, |
| 78 | { &ops, NCT6791D_GPIO3}, |
| 79 | { &ops, NCT6791D_GPIO4}, |
| 80 | { &ops, NCT6791D_GPIO5}, |
| 81 | { &ops, NCT6791D_GPIO6}, |
| 82 | { &ops, NCT6791D_GPIO7}, |
| 83 | { &ops, NCT6791D_GPIO8}, |
| 84 | { &ops, NCT6791D_DS5}, |
| 85 | { &ops, NCT6791D_DS3}, |
| 86 | { &ops, NCT6791D_PCHDSW}, |
| 87 | { &ops, NCT6791D_DSWWOPT}, |
| 88 | { &ops, NCT6791D_DS3OPT}, |
| 89 | { &ops, NCT6791D_DSDSS}, |
| 90 | { &ops, NCT6791D_DSPU}, |
| 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 | }; |
| 102 | |