Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 3 | * |
Stefan Reinauer | de3206a | 2010-02-22 06:09:43 +0000 | [diff] [blame] | 4 | * Copyright (C) 2007-2010 coresystems GmbH |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 5 | * |
Uwe Hermann | 2bb4acf | 2010-03-01 17:19:55 +0000 | [diff] [blame] | 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 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. |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
Arthur Heymans | c583920 | 2019-11-12 23:48:42 +0100 | [diff] [blame^] | 16 | #include <bootblock_common.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 17 | #include <device/pci_ops.h> |
Kyösti Mälkki | 3855c01 | 2019-03-03 08:45:19 +0200 | [diff] [blame] | 18 | #include <device/pnp_ops.h> |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 19 | #include <device/pnp_def.h> |
Edwin Beasant | eb50c7d | 2010-07-06 21:05:04 +0000 | [diff] [blame] | 20 | #include <pc80/mc146818rtc.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 21 | #include <northbridge/intel/i945/i945.h> |
Edward O'Callaghan | 77757c2 | 2015-01-04 21:33:39 +1100 | [diff] [blame] | 22 | #include <southbridge/intel/i82801gx/i82801gx.h> |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame] | 23 | #include <superio/winbond/common/winbond.h> |
| 24 | #include <superio/winbond/w83627thg/w83627thg.h> |
| 25 | |
| 26 | #include "option_table.h" |
Patrick Georgi | d083595 | 2010-10-05 09:07:10 +0000 | [diff] [blame] | 27 | |
Uwe Hermann | 57b2ff8 | 2010-11-21 17:29:59 +0000 | [diff] [blame] | 28 | #define SERIAL_DEV PNP_DEV(0x2e, W83627THG_SP1) |
| 29 | |
Arthur Heymans | fecf777 | 2019-11-09 14:19:04 +0100 | [diff] [blame] | 30 | /* Override the default lpc decode ranges */ |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 31 | void mainboard_lpc_decode(void) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 32 | { |
Patrick Georgi | a470019 | 2011-01-27 07:39:38 +0000 | [diff] [blame] | 33 | int lpt_en = 0; |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 34 | if (read_option(lpt, 0) != 0) |
| 35 | lpt_en = LPT_LPC_EN; /* enable LPT */ |
| 36 | |
Arthur Heymans | fecf777 | 2019-11-09 14:19:04 +0100 | [diff] [blame] | 37 | pci_update_config16(PCI_DEV(0, 0x1f, 0), LPC_EN, ~LPT_LPC_EN, lpt_en); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 40 | /* This box has two superios, so enabling serial becomes slightly excessive. |
| 41 | * We disable a lot of stuff to make sure that there are no conflicts between |
| 42 | * the two. Also set up the GPIOs from the beginning. This is the "no schematic |
| 43 | * but safe anyways" method. |
| 44 | */ |
Arthur Heymans | c583920 | 2019-11-12 23:48:42 +0100 | [diff] [blame^] | 45 | void bootblock_mainboard_early_init(void) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 46 | { |
Antonello Dettori | 9ec1123 | 2016-11-08 18:44:46 +0100 | [diff] [blame] | 47 | pnp_devfn_t dev; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 48 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 49 | dev = PNP_DEV(0x2e, W83627THG_SP1); |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame] | 50 | pnp_enter_conf_state(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 51 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 52 | pnp_write_config(dev, 0x24, 0xc6); /* PNPCSV */ |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 53 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 54 | pnp_write_config(dev, 0x29, 0x43); /* GPIO settings */ |
| 55 | pnp_write_config(dev, 0x2a, 0x40); /* GPIO settings */ |
Stefan Reinauer | aca6ec6 | 2009-10-26 17:12:21 +0000 | [diff] [blame] | 56 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 57 | dev = PNP_DEV(0x2e, W83627THG_SP1); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 58 | pnp_set_logical_device(dev); |
| 59 | pnp_set_enable(dev, 0); |
| 60 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x3f8); |
| 61 | pnp_set_irq(dev, PNP_IDX_IRQ0, 4); |
| 62 | pnp_set_enable(dev, 1); |
| 63 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 64 | dev = PNP_DEV(0x2e, W83627THG_SP2); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 65 | pnp_set_logical_device(dev); |
| 66 | pnp_set_enable(dev, 0); |
| 67 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x2f8); |
| 68 | pnp_set_irq(dev, PNP_IDX_IRQ0, 3); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 69 | pnp_set_enable(dev, 1); |
| 70 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 71 | dev = PNP_DEV(0x2e, W83627THG_KBC); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 72 | pnp_set_logical_device(dev); |
| 73 | pnp_set_enable(dev, 0); |
| 74 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x60); |
| 75 | pnp_set_iobase(dev, PNP_IDX_IO1, 0x64); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 76 | pnp_set_enable(dev, 1); |
| 77 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 78 | dev = PNP_DEV(0x2e, W83627THG_GAME_MIDI_GPIO1); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 79 | pnp_set_logical_device(dev); |
| 80 | pnp_set_enable(dev, 0); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 81 | pnp_write_config(dev, 0xf5, 0xff); /* invert all GPIOs */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 82 | pnp_set_enable(dev, 1); |
| 83 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 84 | dev = PNP_DEV(0x2e, W83627THG_GPIO2); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 85 | pnp_set_logical_device(dev); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 86 | pnp_set_enable(dev, 1); /* Just enable it */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 87 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 88 | dev = PNP_DEV(0x2e, W83627THG_GPIO3); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 89 | pnp_set_logical_device(dev); |
| 90 | pnp_set_enable(dev, 0); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 91 | pnp_write_config(dev, 0xf0, 0xfb); /* GPIO bit 2 is output */ |
| 92 | pnp_write_config(dev, 0xf1, 0x00); /* GPIO bit 2 is 0 */ |
| 93 | pnp_write_config(dev, 0x30, 0x03); /* Enable GPIO3+4. pnp_set_enable is not sufficient */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 94 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 95 | dev = PNP_DEV(0x2e, W83627THG_FDC); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 96 | pnp_set_logical_device(dev); |
| 97 | pnp_set_enable(dev, 0); |
| 98 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 99 | dev = PNP_DEV(0x2e, W83627THG_PP); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 100 | pnp_set_logical_device(dev); |
| 101 | pnp_set_enable(dev, 0); |
| 102 | |
Stefan Reinauer | 54309d6 | 2009-01-20 22:53:10 +0000 | [diff] [blame] | 103 | /* Enable HWM */ |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 104 | dev = PNP_DEV(0x2e, W83627THG_HWM); |
Stefan Reinauer | 54309d6 | 2009-01-20 22:53:10 +0000 | [diff] [blame] | 105 | pnp_set_logical_device(dev); |
| 106 | pnp_set_enable(dev, 0); |
| 107 | pnp_set_iobase(dev, PNP_IDX_IO0, 0xa00); |
| 108 | pnp_set_enable(dev, 1); |
| 109 | |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame] | 110 | pnp_exit_conf_state(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 111 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 112 | dev = PNP_DEV(0x4e, W83627THG_SP1); |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame] | 113 | pnp_enter_conf_state(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 114 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 115 | pnp_set_logical_device(dev); /* Set COM3 to sane non-conflicting values */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 116 | pnp_set_enable(dev, 0); |
| 117 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x3e8); |
| 118 | pnp_set_irq(dev, PNP_IDX_IRQ0, 11); |
| 119 | pnp_set_enable(dev, 1); |
| 120 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 121 | dev = PNP_DEV(0x4e, W83627THG_SP2); |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 122 | pnp_set_logical_device(dev); /* Set COM4 to sane non-conflicting values */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 123 | pnp_set_enable(dev, 0); |
| 124 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x2e8); |
| 125 | pnp_set_irq(dev, PNP_IDX_IRQ0, 10); |
| 126 | pnp_set_enable(dev, 1); |
| 127 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 128 | dev = PNP_DEV(0x4e, W83627THG_FDC); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 129 | pnp_set_logical_device(dev); |
| 130 | pnp_set_enable(dev, 0); |
| 131 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 132 | dev = PNP_DEV(0x4e, W83627THG_PP); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 133 | pnp_set_logical_device(dev); |
| 134 | pnp_set_enable(dev, 0); |
| 135 | |
Elyes HAOUAS | 531b87a | 2016-09-19 09:46:33 -0600 | [diff] [blame] | 136 | dev = PNP_DEV(0x4e, W83627THG_KBC); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 137 | pnp_set_logical_device(dev); |
| 138 | pnp_set_enable(dev, 0); |
| 139 | pnp_set_iobase(dev, PNP_IDX_IO0, 0x00); |
| 140 | pnp_set_iobase(dev, PNP_IDX_IO1, 0x00); |
| 141 | |
Elyes HAOUAS | 5d4cf36 | 2018-08-06 09:58:28 +0200 | [diff] [blame] | 142 | pnp_exit_conf_state(dev); |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Arthur Heymans | dc584c3 | 2019-11-12 20:37:21 +0100 | [diff] [blame] | 145 | void mainboard_late_rcba_config(void) |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 146 | { |
| 147 | /* Set up virtual channel 0 */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 148 | |
| 149 | /* Device 1f interrupt pin register */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 150 | RCBA32(D31IP) = 0x00042210; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 151 | /* Device 1d interrupt pin register */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 152 | RCBA32(D28IP) = 0x00214321; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 153 | |
| 154 | /* dev irq route register */ |
Arthur Heymans | b451df2 | 2017-08-15 20:59:09 +0200 | [diff] [blame] | 155 | RCBA16(D31IR) = 0x0132; |
| 156 | RCBA16(D30IR) = 0x3241; |
| 157 | RCBA16(D29IR) = 0x0237; |
| 158 | RCBA16(D28IR) = 0x3210; |
| 159 | RCBA16(D27IR) = 0x3210; |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 160 | |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 161 | /* Enable PCIe Root Port Clock Gate */ |
Stefan Reinauer | 36a2268 | 2008-10-29 04:52:57 +0000 | [diff] [blame] | 162 | } |