blob: 4f2a4a5c16913827ec596a326fbaed6a99d74811 [file] [log] [blame]
Pavel Sayekat98d5a862019-07-01 19:53:29 +06001/*
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* Copyright (C) 2019 Pavel Sayekat <pavelsayekat@gmail.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 */
21
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 "nct5539d.h"
29
30
31static void nct5539d_init(struct device *dev)
32{
33 if (!dev->enabled)
34 return;
35
36 switch (dev->path.pnp.device) {
37 case NCT5539D_KBC:
38 pc_keyboard_init(NO_AUX_DEVICE);
39 break;
40 }
41}
42
Maxim Polyakov0dd8fe72019-10-27 15:07:00 +030043#if CONFIG(HAVE_ACPI_TABLES)
44/* Provide ACPI HIDs for generic Super I/O SSDT */
45static const char *nct5539d_acpi_hid(const struct device *dev)
46{
47 if ((dev->path.type != DEVICE_PATH_PNP) ||
48 (dev->path.pnp.port == 0) ||
49 ((dev->path.pnp.device & 0xff) > NCT5539D_DS))
50 return NULL;
51
52 switch (dev->path.pnp.device & 0xff) {
53 case NCT5539D_SP1:
54 return ACPI_HID_COM;
55 case NCT5539D_KBC:
56 return ACPI_HID_KEYBOARD;
57 default:
58 return ACPI_HID_PNP;
59 }
60}
61#endif
62
Pavel Sayekat98d5a862019-07-01 19:53:29 +060063static struct device_operations ops = {
64 .read_resources = pnp_read_resources,
65 .set_resources = pnp_set_resources,
66 .enable_resources = pnp_enable_resources,
67 .enable = pnp_alt_enable,
68 .init = nct5539d_init,
69 .ops_pnp_mode = &pnp_conf_mode_8787_aa,
Maxim Polyakov0dd8fe72019-10-27 15:07:00 +030070#if CONFIG(HAVE_ACPI_TABLES)
71 .acpi_fill_ssdt_generator = superio_common_fill_ssdt_generator,
72 .acpi_name = superio_common_ldn_acpi_name,
73 .acpi_hid = nct5539d_acpi_hid,
74#endif
Pavel Sayekat98d5a862019-07-01 19:53:29 +060075};
76
77static struct pnp_info pnp_dev_info[] = {
78 { NULL, NCT5539D_SP1, PNP_IO0 | PNP_IRQ0,
79 0x0ff8, },
80 { NULL, NCT5539D_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1,
81 0x0fff, 0x0fff, },
82 { NULL, NCT5539D_CIR, PNP_IO0 | PNP_IRQ0,
83 0x0ff8, },
84 { NULL, NCT5539D_ACPI},
85 { NULL, NCT5539D_HWM_FPLED, PNP_IO0 | PNP_IRQ0,
86 0x0ffe, 0x0ffe, },
87 { NULL, NCT5539D_WDT2},
88 { NULL, NCT5539D_CIRWUP, PNP_IO0 | PNP_IRQ0,
89 0x0ff8, },
90 { NULL, NCT5539D_GPIO_PP_OD},
91 { NULL, NCT5539D_WDT1},
92 { NULL, NCT5539D_WDT3},
93 { NULL, NCT5539D_GPIOBASE, PNP_IO0,
94 0x0ff8, },
95 { NULL, NCT5539D_GPIO0},
96 { NULL, NCT5539D_GPIO2},
97 { NULL, NCT5539D_GPIO3},
98 { NULL, NCT5539D_GPIO4},
99 { NULL, NCT5539D_GPIO5},
100 { NULL, NCT5539D_GPIO7},
101 { NULL, NCT5539D_GPIO8},
102 { NULL, NCT5539D_GPIO_PSO},
103 { NULL, NCT5539D_SWEC},
104 { NULL, NCT5539D_FLED},
105 { NULL, NCT5539D_DS5},
106 { NULL, NCT5539D_DS3},
107};
108
109static void enable_dev(struct device *dev)
110{
111 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
112}
113
114struct chip_operations superio_nuvoton_nct5539d_ops = {
115 CHIP_NAME("NUVOTON NCT5539D Super I/O")
116 .enable_dev = enable_dev,
117};