Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 1 | /* |
| 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 Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 16 | #include <device/device.h> |
| 17 | #include <device/pnp.h> |
Nico Huber | 1c81128 | 2013-06-15 20:33:44 +0200 | [diff] [blame] | 18 | #include <superio/conf_mode.h> |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 19 | #include <pc80/keyboard.h> |
Elyes HAOUAS | 2329a25 | 2019-05-15 22:11:18 +0200 | [diff] [blame] | 20 | |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 21 | #include "w83627dhg.h" |
| 22 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 23 | static void w83627dhg_enable_UR2(struct device *dev) |
Wolfgang Kamp | 9ae1eb6 | 2013-03-11 16:35:42 +0100 | [diff] [blame] | 24 | { |
| 25 | u8 reg8; |
| 26 | |
Nico Huber | 13dc976 | 2013-06-15 19:33:15 +0200 | [diff] [blame] | 27 | pnp_enter_conf_mode(dev); |
Wolfgang Kamp | 9ae1eb6 | 2013-03-11 16:35:42 +0100 | [diff] [blame] | 28 | reg8 = pnp_read_config(dev, 0x2c); |
| 29 | reg8 |= (0x3); |
| 30 | pnp_write_config(dev, 0x2c, reg8); // Set pins 78-85-> UART B |
Nico Huber | 13dc976 | 2013-06-15 19:33:15 +0200 | [diff] [blame] | 31 | pnp_exit_conf_mode(dev); |
Wolfgang Kamp | 9ae1eb6 | 2013-03-11 16:35:42 +0100 | [diff] [blame] | 32 | } |
| 33 | |
Edward O'Callaghan | f21bdc3 | 2014-10-21 07:43:41 +1100 | [diff] [blame] | 34 | static void w83627dhg_init(struct device *dev) |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 35 | { |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 36 | |
| 37 | if (!dev->enabled) |
| 38 | return; |
| 39 | |
Elyes HAOUAS | 0ce41f1 | 2018-11-13 10:03:31 +0100 | [diff] [blame] | 40 | switch (dev->path.pnp.device) { |
Wolfgang Kamp | 9ae1eb6 | 2013-03-11 16:35:42 +0100 | [diff] [blame] | 41 | case W83627DHG_SP2: |
| 42 | w83627dhg_enable_UR2(dev); |
| 43 | break; |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 44 | case W83627DHG_KBC: |
Timothy Pearson | 448e386 | 2015-11-24 14:12:01 -0600 | [diff] [blame] | 45 | pc_keyboard_init(NO_AUX_DEVICE); |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 46 | break; |
| 47 | } |
| 48 | } |
| 49 | |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 50 | static struct device_operations ops = { |
| 51 | .read_resources = pnp_read_resources, |
Nico Huber | 0b2ee93 | 2013-06-15 19:58:35 +0200 | [diff] [blame] | 52 | .set_resources = pnp_set_resources, |
| 53 | .enable_resources = pnp_enable_resources, |
| 54 | .enable = pnp_alt_enable, |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 55 | .init = w83627dhg_init, |
Nico Huber | 1c81128 | 2013-06-15 20:33:44 +0200 | [diff] [blame] | 56 | .ops_pnp_mode = &pnp_conf_mode_8787_aa, |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | static struct pnp_info pnp_dev_info[] = { |
Felix Held | 8c85880 | 2018-07-06 20:22:08 +0200 | [diff] [blame] | 60 | { 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 Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | static void enable_dev(struct device *dev) |
| 79 | { |
| 80 | pnp_enable_devices(dev, &ops, ARRAY_SIZE(pnp_dev_info), pnp_dev_info); |
| 81 | } |
| 82 | |
| 83 | struct chip_operations superio_winbond_w83627dhg_ops = { |
| 84 | CHIP_NAME("Winbond W83627DHG Super I/O") |
| 85 | .enable_dev = enable_dev, |
| 86 | }; |