blob: ab7a5ac00ad453f8a43fc2dc1337a5604b5a74ef [file] [log] [blame]
Stefan Reinauer474ff3d2015-11-04 22:41:47 +02001/*
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 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
Stefan Reinauer474ff3d2015-11-04 22:41:47 +020018 */
19
20#include <arch/io.h>
21#include <device/device.h>
22#include <device/pnp.h>
23#include <pc80/keyboard.h>
24#include <stdlib.h>
25#include <superio/conf_mode.h>
26
27#include "nct6779d.h"
28
29
30static void nct6779d_init(struct device *dev)
31{
32 if (!dev->enabled)
33 return;
34
35 switch(dev->path.pnp.device) {
36 /* TODO: Might potentially need code for HWM or FDC etc. */
37 case NCT6779D_KBC:
Timothy Pearson448e3862015-11-24 14:12:01 -060038 pc_keyboard_init(NO_AUX_DEVICE);
Stefan Reinauer474ff3d2015-11-04 22:41:47 +020039 break;
40 }
41}
42
43static 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 = nct6779d_init,
49 .ops_pnp_mode = &pnp_conf_mode_8787_aa,
50};
51
52static struct pnp_info pnp_dev_info[] = {
53 { &ops, NCT6779D_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x0ff8, 0}, },
54 { &ops, NCT6779D_SP1, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
55 { &ops, NCT6779D_SP2, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
56 { &ops, NCT6779D_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, {0x0fff, 0}, {0x0fff, 4}, },
57 { &ops, NCT6779D_CIR, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
58 { &ops, NCT6779D_ACPI},
59 { &ops, NCT6779D_HWM_FPLED, PNP_IO0 | PNP_IO1 | PNP_IRQ0, {0x0ffe, 0}, {0x0ffe, 4}, },
60 { &ops, NCT6779D_WDT1},
61 { &ops, NCT6779D_CIRWKUP, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
62 { &ops, NCT6779D_GPIO_PP_OD},
63 { &ops, NCT6779D_PRT80},
64 { &ops, NCT6779D_DSLP},
65 { &ops, NCT6779D_GPIOBASE, PNP_IO0, {0x0ff8, 0}, },
66 { &ops, NCT6779D_GPIO0},
67 { &ops, NCT6779D_GPIO1},
68 { &ops, NCT6779D_GPIO2},
69 { &ops, NCT6779D_GPIO3},
70 { &ops, NCT6779D_GPIO4},
71 { &ops, NCT6779D_GPIO5},
72 { &ops, NCT6779D_GPIO6},
73 { &ops, NCT6779D_GPIO7},
74 { &ops, NCT6779D_GPIO8},
75};
76
77static void enable_dev(struct device *dev)
78{
79 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
80}
81
82struct chip_operations superio_nuvoton_nct6779d_ops = {
83 CHIP_NAME("NUVOTON NCT6779D Super I/O")
84 .enable_dev = enable_dev,
85};