blob: 2c894534f3d86afbd53b1cfde3493e1799bebb92 [file] [log] [blame]
Stefan Reinauer36a22682008-10-29 04:52:57 +00001/*
2 * This file is part of the coreboot project.
Stefan Reinauer14e22772010-04-27 06:56:47 +00003 *
Stefan Reinauerde3206a2010-02-22 06:09:43 +00004 * Copyright (C) 2007-2010 coresystems GmbH
Stefan Reinauer36a22682008-10-29 04:52:57 +00005 *
Uwe Hermann2bb4acf2010-03-01 17:19:55 +00006 * 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 Reinauer36a22682008-10-29 04:52:57 +00009 *
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 Reinauer36a22682008-10-29 04:52:57 +000014 */
15
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020016#include <device/pci_ops.h>
Kyösti Mälkki3855c012019-03-03 08:45:19 +020017#include <device/pnp_ops.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000018#include <device/pnp_def.h>
Edwin Beasanteb50c7d2010-07-06 21:05:04 +000019#include <pc80/mc146818rtc.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110020#include <northbridge/intel/i945/i945.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110021#include <southbridge/intel/i82801gx/i82801gx.h>
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +020022#include <superio/winbond/common/winbond.h>
23#include <superio/winbond/w83627thg/w83627thg.h>
24
25#include "option_table.h"
Patrick Georgid0835952010-10-05 09:07:10 +000026
Uwe Hermann57b2ff82010-11-21 17:29:59 +000027#define SERIAL_DEV PNP_DEV(0x2e, W83627THG_SP1)
28
Arthur Heymansfecf7772019-11-09 14:19:04 +010029/* Override the default lpc decode ranges */
Arthur Heymansdc584c32019-11-12 20:37:21 +010030void mainboard_lpc_decode(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000031{
Patrick Georgia4700192011-01-27 07:39:38 +000032 int lpt_en = 0;
Arthur Heymansb451df22017-08-15 20:59:09 +020033 if (read_option(lpt, 0) != 0)
34 lpt_en = LPT_LPC_EN; /* enable LPT */
35
Arthur Heymansfecf7772019-11-09 14:19:04 +010036 pci_update_config16(PCI_DEV(0, 0x1f, 0), LPC_EN, ~LPT_LPC_EN, lpt_en);
Stefan Reinauer36a22682008-10-29 04:52:57 +000037}
38
Stefan Reinauer36a22682008-10-29 04:52:57 +000039/* This box has two superios, so enabling serial becomes slightly excessive.
40 * We disable a lot of stuff to make sure that there are no conflicts between
41 * the two. Also set up the GPIOs from the beginning. This is the "no schematic
42 * but safe anyways" method.
43 */
Arthur Heymansdc584c32019-11-12 20:37:21 +010044void mainboard_superio_config(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000045{
Antonello Dettori9ec11232016-11-08 18:44:46 +010046 pnp_devfn_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000047
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060048 dev = PNP_DEV(0x2e, W83627THG_SP1);
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +020049 pnp_enter_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +000050
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020051 pnp_write_config(dev, 0x24, 0xc6); /* PNPCSV */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +000052
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020053 pnp_write_config(dev, 0x29, 0x43); /* GPIO settings */
54 pnp_write_config(dev, 0x2a, 0x40); /* GPIO settings */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +000055
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060056 dev = PNP_DEV(0x2e, W83627THG_SP1);
Stefan Reinauer36a22682008-10-29 04:52:57 +000057 pnp_set_logical_device(dev);
58 pnp_set_enable(dev, 0);
59 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3f8);
60 pnp_set_irq(dev, PNP_IDX_IRQ0, 4);
61 pnp_set_enable(dev, 1);
62
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060063 dev = PNP_DEV(0x2e, W83627THG_SP2);
Stefan Reinauer36a22682008-10-29 04:52:57 +000064 pnp_set_logical_device(dev);
65 pnp_set_enable(dev, 0);
66 pnp_set_iobase(dev, PNP_IDX_IO0, 0x2f8);
67 pnp_set_irq(dev, PNP_IDX_IRQ0, 3);
Stefan Reinauer36a22682008-10-29 04:52:57 +000068 pnp_set_enable(dev, 1);
69
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060070 dev = PNP_DEV(0x2e, W83627THG_KBC);
Stefan Reinauer36a22682008-10-29 04:52:57 +000071 pnp_set_logical_device(dev);
72 pnp_set_enable(dev, 0);
73 pnp_set_iobase(dev, PNP_IDX_IO0, 0x60);
74 pnp_set_iobase(dev, PNP_IDX_IO1, 0x64);
Stefan Reinauer36a22682008-10-29 04:52:57 +000075 pnp_set_enable(dev, 1);
76
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060077 dev = PNP_DEV(0x2e, W83627THG_GAME_MIDI_GPIO1);
Stefan Reinauer36a22682008-10-29 04:52:57 +000078 pnp_set_logical_device(dev);
79 pnp_set_enable(dev, 0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020080 pnp_write_config(dev, 0xf5, 0xff); /* invert all GPIOs */
Stefan Reinauer36a22682008-10-29 04:52:57 +000081 pnp_set_enable(dev, 1);
82
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060083 dev = PNP_DEV(0x2e, W83627THG_GPIO2);
Stefan Reinauer36a22682008-10-29 04:52:57 +000084 pnp_set_logical_device(dev);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020085 pnp_set_enable(dev, 1); /* Just enable it */
Stefan Reinauer36a22682008-10-29 04:52:57 +000086
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060087 dev = PNP_DEV(0x2e, W83627THG_GPIO3);
Stefan Reinauer36a22682008-10-29 04:52:57 +000088 pnp_set_logical_device(dev);
89 pnp_set_enable(dev, 0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020090 pnp_write_config(dev, 0xf0, 0xfb); /* GPIO bit 2 is output */
91 pnp_write_config(dev, 0xf1, 0x00); /* GPIO bit 2 is 0 */
92 pnp_write_config(dev, 0x30, 0x03); /* Enable GPIO3+4. pnp_set_enable is not sufficient */
Stefan Reinauer36a22682008-10-29 04:52:57 +000093
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060094 dev = PNP_DEV(0x2e, W83627THG_FDC);
Stefan Reinauer36a22682008-10-29 04:52:57 +000095 pnp_set_logical_device(dev);
96 pnp_set_enable(dev, 0);
97
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060098 dev = PNP_DEV(0x2e, W83627THG_PP);
Stefan Reinauer36a22682008-10-29 04:52:57 +000099 pnp_set_logical_device(dev);
100 pnp_set_enable(dev, 0);
101
Stefan Reinauer54309d62009-01-20 22:53:10 +0000102 /* Enable HWM */
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600103 dev = PNP_DEV(0x2e, W83627THG_HWM);
Stefan Reinauer54309d62009-01-20 22:53:10 +0000104 pnp_set_logical_device(dev);
105 pnp_set_enable(dev, 0);
106 pnp_set_iobase(dev, PNP_IDX_IO0, 0xa00);
107 pnp_set_enable(dev, 1);
108
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +0200109 pnp_exit_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000110
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600111 dev = PNP_DEV(0x4e, W83627THG_SP1);
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +0200112 pnp_enter_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000113
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200114 pnp_set_logical_device(dev); /* Set COM3 to sane non-conflicting values */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000115 pnp_set_enable(dev, 0);
116 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3e8);
117 pnp_set_irq(dev, PNP_IDX_IRQ0, 11);
118 pnp_set_enable(dev, 1);
119
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600120 dev = PNP_DEV(0x4e, W83627THG_SP2);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200121 pnp_set_logical_device(dev); /* Set COM4 to sane non-conflicting values */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000122 pnp_set_enable(dev, 0);
123 pnp_set_iobase(dev, PNP_IDX_IO0, 0x2e8);
124 pnp_set_irq(dev, PNP_IDX_IRQ0, 10);
125 pnp_set_enable(dev, 1);
126
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600127 dev = PNP_DEV(0x4e, W83627THG_FDC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000128 pnp_set_logical_device(dev);
129 pnp_set_enable(dev, 0);
130
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600131 dev = PNP_DEV(0x4e, W83627THG_PP);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000132 pnp_set_logical_device(dev);
133 pnp_set_enable(dev, 0);
134
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600135 dev = PNP_DEV(0x4e, W83627THG_KBC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000136 pnp_set_logical_device(dev);
137 pnp_set_enable(dev, 0);
138 pnp_set_iobase(dev, PNP_IDX_IO0, 0x00);
139 pnp_set_iobase(dev, PNP_IDX_IO1, 0x00);
140
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +0200141 pnp_exit_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000142}
143
Arthur Heymansdc584c32019-11-12 20:37:21 +0100144void mainboard_late_rcba_config(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000145{
146 /* Set up virtual channel 0 */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000147
148 /* Device 1f interrupt pin register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200149 RCBA32(D31IP) = 0x00042210;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000150 /* Device 1d interrupt pin register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200151 RCBA32(D28IP) = 0x00214321;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000152
153 /* dev irq route register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200154 RCBA16(D31IR) = 0x0132;
155 RCBA16(D30IR) = 0x3241;
156 RCBA16(D29IR) = 0x0237;
157 RCBA16(D28IR) = 0x3210;
158 RCBA16(D27IR) = 0x3210;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000159
Stefan Reinauer36a22682008-10-29 04:52:57 +0000160 /* Enable PCIe Root Port Clock Gate */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000161}