blob: bd9900ba143636d2c47007f5382e1def83400f03 [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
Uwe Hermann1ec50942008-11-11 21:10:07 +000016#include <device/device.h>
17#include <device/pnp.h>
Nico Huber1c811282013-06-15 20:33:44 +020018#include <superio/conf_mode.h>
Uwe Hermann1ec50942008-11-11 21:10:07 +000019#include <pc80/keyboard.h>
Elyes HAOUAS2329a252019-05-15 22:11:18 +020020
Uwe Hermann1ec50942008-11-11 21:10:07 +000021#include "w83627dhg.h"
22
Edward O'Callaghanf21bdc32014-10-21 07:43:41 +110023static void w83627dhg_enable_UR2(struct device *dev)
Wolfgang Kamp9ae1eb62013-03-11 16:35:42 +010024{
25 u8 reg8;
26
Nico Huber13dc9762013-06-15 19:33:15 +020027 pnp_enter_conf_mode(dev);
Wolfgang Kamp9ae1eb62013-03-11 16:35:42 +010028 reg8 = pnp_read_config(dev, 0x2c);
29 reg8 |= (0x3);
30 pnp_write_config(dev, 0x2c, reg8); // Set pins 78-85-> UART B
Nico Huber13dc9762013-06-15 19:33:15 +020031 pnp_exit_conf_mode(dev);
Wolfgang Kamp9ae1eb62013-03-11 16:35:42 +010032}
33
Edward O'Callaghanf21bdc32014-10-21 07:43:41 +110034static void w83627dhg_init(struct device *dev)
Uwe Hermann1ec50942008-11-11 21:10:07 +000035{
Uwe Hermann1ec50942008-11-11 21:10:07 +000036
37 if (!dev->enabled)
38 return;
39
Elyes HAOUAS0ce41f12018-11-13 10:03:31 +010040 switch (dev->path.pnp.device) {
Wolfgang Kamp9ae1eb62013-03-11 16:35:42 +010041 case W83627DHG_SP2:
42 w83627dhg_enable_UR2(dev);
43 break;
Uwe Hermann1ec50942008-11-11 21:10:07 +000044 case W83627DHG_KBC:
Timothy Pearson448e3862015-11-24 14:12:01 -060045 pc_keyboard_init(NO_AUX_DEVICE);
Uwe Hermann1ec50942008-11-11 21:10:07 +000046 break;
47 }
48}
49
Uwe Hermann1ec50942008-11-11 21:10:07 +000050static struct device_operations ops = {
51 .read_resources = pnp_read_resources,
Nico Huber0b2ee932013-06-15 19:58:35 +020052 .set_resources = pnp_set_resources,
53 .enable_resources = pnp_enable_resources,
54 .enable = pnp_alt_enable,
Uwe Hermann1ec50942008-11-11 21:10:07 +000055 .init = w83627dhg_init,
Nico Huber1c811282013-06-15 20:33:44 +020056 .ops_pnp_mode = &pnp_conf_mode_8787_aa,
Uwe Hermann1ec50942008-11-11 21:10:07 +000057};
58
59static struct pnp_info pnp_dev_info[] = {
Felix Held8c858802018-07-06 20:22:08 +020060 { NULL, W83627DHG_FDC, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, },
61 { NULL, W83627DHG_PP, PNP_IO0 | PNP_IRQ0 | PNP_DRQ0, 0x07f8, },
62 { NULL, W83627DHG_SP1, PNP_IO0 | PNP_IRQ0, 0x07f8, },
63 { NULL, W83627DHG_SP2, PNP_IO0 | PNP_IRQ0, 0x07f8, },
64 { NULL, W83627DHG_KBC, PNP_IO0 | PNP_IO1 | PNP_IRQ0 | PNP_IRQ1,
65 0x07ff, 0x07ff, },
66 { NULL, W83627DHG_SPI, PNP_IO1, 0, 0x7f8, },
67 { NULL, W83627DHG_GPIO6, },
68 { NULL, W83627DHG_WDTO_PLED, },
69 { NULL, W83627DHG_GPIO2, },
70 { NULL, W83627DHG_GPIO3, },
71 { NULL, W83627DHG_GPIO4, },
72 { NULL, W83627DHG_GPIO5, },
73 { NULL, W83627DHG_ACPI, PNP_IRQ0, },
74 { NULL, W83627DHG_HWM, PNP_IO0 | PNP_IRQ0, 0x07fe, },
75 { NULL, W83627DHG_PECI_SST, },
Uwe Hermann1ec50942008-11-11 21:10:07 +000076};
77
78static void enable_dev(struct device *dev)
79{
80 pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
81}
82
83struct chip_operations superio_winbond_w83627dhg_ops = {
84 CHIP_NAME("Winbond W83627DHG Super I/O")
85 .enable_dev = enable_dev,
86};