blob: 79a25b7c79f8ef8f4d99112deb83ee91b628bc75 [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.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc.
22 */
23
24#include <arch/io.h>
25#include <device/device.h>
26#include <device/pnp.h>
27#include <pc80/keyboard.h>
28#include <stdlib.h>
29#include <superio/conf_mode.h>
30
31#include "nct6779d.h"
32
33
34static void nct6779d_init(struct device *dev)
35{
36 if (!dev->enabled)
37 return;
38
39 switch(dev->path.pnp.device) {
40 /* TODO: Might potentially need code for HWM or FDC etc. */
41 case NCT6779D_KBC:
42 pc_keyboard_init();
43 break;
44 }
45}
46
47static struct device_operations ops = {
48 .read_resources = pnp_read_resources,
49 .set_resources = pnp_set_resources,
50 .enable_resources = pnp_enable_resources,
51 .enable = pnp_alt_enable,
52 .init = nct6779d_init,
53 .ops_pnp_mode = &pnp_conf_mode_8787_aa,
54};
55
56static struct pnp_info pnp_dev_info[] = {
57 { &ops, NCT6779D_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, {0x0ff8, 0}, },
58 { &ops, NCT6779D_SP1, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
59 { &ops, NCT6779D_SP2, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
60 { &ops, NCT6779D_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1, {0x0fff, 0}, {0x0fff, 4}, },
61 { &ops, NCT6779D_CIR, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
62 { &ops, NCT6779D_ACPI},
63 { &ops, NCT6779D_HWM_FPLED, PNP_IO0 | PNP_IO1 | PNP_IRQ0, {0x0ffe, 0}, {0x0ffe, 4}, },
64 { &ops, NCT6779D_WDT1},
65 { &ops, NCT6779D_CIRWKUP, PNP_IO0 | PNP_IRQ0, {0x0ff8, 0}, },
66 { &ops, NCT6779D_GPIO_PP_OD},
67 { &ops, NCT6779D_PRT80},
68 { &ops, NCT6779D_DSLP},
69 { &ops, NCT6779D_GPIOBASE, PNP_IO0, {0x0ff8, 0}, },
70 { &ops, NCT6779D_GPIO0},
71 { &ops, NCT6779D_GPIO1},
72 { &ops, NCT6779D_GPIO2},
73 { &ops, NCT6779D_GPIO3},
74 { &ops, NCT6779D_GPIO4},
75 { &ops, NCT6779D_GPIO5},
76 { &ops, NCT6779D_GPIO6},
77 { &ops, NCT6779D_GPIO7},
78 { &ops, NCT6779D_GPIO8},
79};
80
81static void enable_dev(struct device *dev)
82{
83 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
84}
85
86struct chip_operations superio_nuvoton_nct6779d_ops = {
87 CHIP_NAME("NUVOTON NCT6779D Super I/O")
88 .enable_dev = enable_dev,
89};