blob: 363bcc4709a1e385643bbd568fd92594e254701f [file] [log] [blame]
Uwe Hermann1ec50942008-11-11 21:10:07 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Uwe Hermann1ec50942008-11-11 21:10:07 +000014 */
15
16#include <arch/io.h>
17#include <device/device.h>
18#include <device/pnp.h>
Nico Huber1c811282013-06-15 20:33:44 +020019#include <superio/conf_mode.h>
Uwe Hermann1ec50942008-11-11 21:10:07 +000020#include <pc80/keyboard.h>
21#include <stdlib.h>
Uwe Hermann1ec50942008-11-11 21:10:07 +000022#include "w83627dhg.h"
23
Edward O'Callaghanf21bdc32014-10-21 07:43:41 +110024static void w83627dhg_enable_UR2(struct device *dev)
Wolfgang Kamp9ae1eb62013-03-11 16:35:42 +010025{
26 u8 reg8;
27
Nico Huber13dc9762013-06-15 19:33:15 +020028 pnp_enter_conf_mode(dev);
Wolfgang Kamp9ae1eb62013-03-11 16:35:42 +010029 reg8 = pnp_read_config(dev, 0x2c);
30 reg8 |= (0x3);
31 pnp_write_config(dev, 0x2c, reg8); // Set pins 78-85-> UART B
Nico Huber13dc9762013-06-15 19:33:15 +020032 pnp_exit_conf_mode(dev);
Wolfgang Kamp9ae1eb62013-03-11 16:35:42 +010033}
34
Edward O'Callaghanf21bdc32014-10-21 07:43:41 +110035static void w83627dhg_init(struct device *dev)
Uwe Hermann1ec50942008-11-11 21:10:07 +000036{
Uwe Hermann1ec50942008-11-11 21:10:07 +000037
38 if (!dev->enabled)
39 return;
40
Elyes HAOUAS0ce41f12018-11-13 10:03:31 +010041 switch (dev->path.pnp.device) {
Wolfgang Kamp9ae1eb62013-03-11 16:35:42 +010042 case W83627DHG_SP2:
43 w83627dhg_enable_UR2(dev);
44 break;
Uwe Hermann1ec50942008-11-11 21:10:07 +000045 case W83627DHG_KBC:
Timothy Pearson448e3862015-11-24 14:12:01 -060046 pc_keyboard_init(NO_AUX_DEVICE);
Uwe Hermann1ec50942008-11-11 21:10:07 +000047 break;
48 }
49}
50
Uwe Hermann1ec50942008-11-11 21:10:07 +000051static struct device_operations ops = {
52 .read_resources = pnp_read_resources,
Nico Huber0b2ee932013-06-15 19:58:35 +020053 .set_resources = pnp_set_resources,
54 .enable_resources = pnp_enable_resources,
55 .enable = pnp_alt_enable,
Uwe Hermann1ec50942008-11-11 21:10:07 +000056 .init = w83627dhg_init,
Nico Huber1c811282013-06-15 20:33:44 +020057 .ops_pnp_mode = &pnp_conf_mode_8787_aa,
Uwe Hermann1ec50942008-11-11 21:10:07 +000058};
59
60static struct pnp_info pnp_dev_info[] = {
Felix Held8c858802018-07-06 20:22:08 +020061 { NULL, W83627DHG_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, },
62 { NULL, W83627DHG_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, },
63 { NULL, W83627DHG_SP1, PNP_IO0 | PNP_IRQ0, 0x07f8, },
64 { NULL, W83627DHG_SP2, PNP_IO0 | PNP_IRQ0, 0x07f8, },
65 { NULL, W83627DHG_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1,
66 0x07ff, 0x07ff, },
67 { NULL, W83627DHG_SPI, PNP_IO1, 0, 0x7f8, },
68 { NULL, W83627DHG_GPIO6, },
69 { NULL, W83627DHG_WDTO_PLED, },
70 { NULL, W83627DHG_GPIO2, },
71 { NULL, W83627DHG_GPIO3, },
72 { NULL, W83627DHG_GPIO4, },
73 { NULL, W83627DHG_GPIO5, },
74 { NULL, W83627DHG_ACPI, PNP_IRQ0, },
75 { NULL, W83627DHG_HWM, PNP_IO0 | PNP_IRQ0, 0x07fe, },
76 { NULL, W83627DHG_PECI_SST, },
Uwe Hermann1ec50942008-11-11 21:10:07 +000077};
78
79static void enable_dev(struct device *dev)
80{
81 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
82}
83
84struct chip_operations superio_winbond_w83627dhg_ops = {
85 CHIP_NAME("Winbond W83627DHG Super I/O")
86 .enable_dev = enable_dev,
87};