blob: 827f7929465513af187a19015cd157ca030f7a69 [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
Arthur Heymansc5839202019-11-12 23:48:42 +010016#include <bootblock_common.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020017#include <device/pci_ops.h>
Kyösti Mälkki3855c012019-03-03 08:45:19 +020018#include <device/pnp_ops.h>
Stefan Reinauer36a22682008-10-29 04:52:57 +000019#include <device/pnp_def.h>
Kyösti Mälkkicbf95712020-01-05 08:05:45 +020020#include <option.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110021#include <northbridge/intel/i945/i945.h>
Edward O'Callaghan77757c22015-01-04 21:33:39 +110022#include <southbridge/intel/i82801gx/i82801gx.h>
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +020023#include <superio/winbond/common/winbond.h>
24#include <superio/winbond/w83627thg/w83627thg.h>
25
Arthur Heymansfecf7772019-11-09 14:19:04 +010026/* Override the default lpc decode ranges */
Arthur Heymansdc584c32019-11-12 20:37:21 +010027void mainboard_lpc_decode(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000028{
Patrick Georgia4700192011-01-27 07:39:38 +000029 int lpt_en = 0;
Kyösti Mälkkibee82ab2019-12-26 10:57:43 +020030 u8 val;
31
32 if (get_option(&val, "lpt") == CB_SUCCESS && val)
Arthur Heymansb451df22017-08-15 20:59:09 +020033 lpt_en = LPT_LPC_EN; /* enable LPT */
34
Arthur Heymansfecf7772019-11-09 14:19:04 +010035 pci_update_config16(PCI_DEV(0, 0x1f, 0), LPC_EN, ~LPT_LPC_EN, lpt_en);
Stefan Reinauer36a22682008-10-29 04:52:57 +000036}
37
Stefan Reinauer36a22682008-10-29 04:52:57 +000038/* This box has two superios, so enabling serial becomes slightly excessive.
39 * We disable a lot of stuff to make sure that there are no conflicts between
40 * the two. Also set up the GPIOs from the beginning. This is the "no schematic
41 * but safe anyways" method.
42 */
Arthur Heymansc5839202019-11-12 23:48:42 +010043void bootblock_mainboard_early_init(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000044{
Antonello Dettori9ec11232016-11-08 18:44:46 +010045 pnp_devfn_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000046
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060047 dev = PNP_DEV(0x2e, W83627THG_SP1);
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +020048 pnp_enter_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +000049
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020050 pnp_write_config(dev, 0x24, 0xc6); /* PNPCSV */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +000051
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020052 pnp_write_config(dev, 0x29, 0x43); /* GPIO settings */
53 pnp_write_config(dev, 0x2a, 0x40); /* GPIO settings */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +000054
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060055 dev = PNP_DEV(0x2e, W83627THG_SP1);
Stefan Reinauer36a22682008-10-29 04:52:57 +000056 pnp_set_logical_device(dev);
57 pnp_set_enable(dev, 0);
58 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3f8);
59 pnp_set_irq(dev, PNP_IDX_IRQ0, 4);
60 pnp_set_enable(dev, 1);
61
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060062 dev = PNP_DEV(0x2e, W83627THG_SP2);
Stefan Reinauer36a22682008-10-29 04:52:57 +000063 pnp_set_logical_device(dev);
64 pnp_set_enable(dev, 0);
65 pnp_set_iobase(dev, PNP_IDX_IO0, 0x2f8);
66 pnp_set_irq(dev, PNP_IDX_IRQ0, 3);
Stefan Reinauer36a22682008-10-29 04:52:57 +000067 pnp_set_enable(dev, 1);
68
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060069 dev = PNP_DEV(0x2e, W83627THG_KBC);
Stefan Reinauer36a22682008-10-29 04:52:57 +000070 pnp_set_logical_device(dev);
71 pnp_set_enable(dev, 0);
72 pnp_set_iobase(dev, PNP_IDX_IO0, 0x60);
73 pnp_set_iobase(dev, PNP_IDX_IO1, 0x64);
Stefan Reinauer36a22682008-10-29 04:52:57 +000074 pnp_set_enable(dev, 1);
75
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060076 dev = PNP_DEV(0x2e, W83627THG_GAME_MIDI_GPIO1);
Stefan Reinauer36a22682008-10-29 04:52:57 +000077 pnp_set_logical_device(dev);
78 pnp_set_enable(dev, 0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020079 pnp_write_config(dev, 0xf5, 0xff); /* invert all GPIOs */
Stefan Reinauer36a22682008-10-29 04:52:57 +000080 pnp_set_enable(dev, 1);
81
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060082 dev = PNP_DEV(0x2e, W83627THG_GPIO2);
Stefan Reinauer36a22682008-10-29 04:52:57 +000083 pnp_set_logical_device(dev);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020084 pnp_set_enable(dev, 1); /* Just enable it */
Stefan Reinauer36a22682008-10-29 04:52:57 +000085
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060086 dev = PNP_DEV(0x2e, W83627THG_GPIO3);
Stefan Reinauer36a22682008-10-29 04:52:57 +000087 pnp_set_logical_device(dev);
88 pnp_set_enable(dev, 0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020089 pnp_write_config(dev, 0xf0, 0xfb); /* GPIO bit 2 is output */
90 pnp_write_config(dev, 0xf1, 0x00); /* GPIO bit 2 is 0 */
91 pnp_write_config(dev, 0x30, 0x03); /* Enable GPIO3+4. pnp_set_enable is not sufficient */
Stefan Reinauer36a22682008-10-29 04:52:57 +000092
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060093 dev = PNP_DEV(0x2e, W83627THG_FDC);
Stefan Reinauer36a22682008-10-29 04:52:57 +000094 pnp_set_logical_device(dev);
95 pnp_set_enable(dev, 0);
96
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060097 dev = PNP_DEV(0x2e, W83627THG_PP);
Stefan Reinauer36a22682008-10-29 04:52:57 +000098 pnp_set_logical_device(dev);
99 pnp_set_enable(dev, 0);
100
Stefan Reinauer54309d62009-01-20 22:53:10 +0000101 /* Enable HWM */
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600102 dev = PNP_DEV(0x2e, W83627THG_HWM);
Stefan Reinauer54309d62009-01-20 22:53:10 +0000103 pnp_set_logical_device(dev);
104 pnp_set_enable(dev, 0);
105 pnp_set_iobase(dev, PNP_IDX_IO0, 0xa00);
106 pnp_set_enable(dev, 1);
107
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +0200108 pnp_exit_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000109
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600110 dev = PNP_DEV(0x4e, W83627THG_SP1);
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +0200111 pnp_enter_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000112
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200113 pnp_set_logical_device(dev); /* Set COM3 to sane non-conflicting values */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000114 pnp_set_enable(dev, 0);
115 pnp_set_iobase(dev, PNP_IDX_IO0, 0x3e8);
116 pnp_set_irq(dev, PNP_IDX_IRQ0, 11);
117 pnp_set_enable(dev, 1);
118
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600119 dev = PNP_DEV(0x4e, W83627THG_SP2);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200120 pnp_set_logical_device(dev); /* Set COM4 to sane non-conflicting values */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000121 pnp_set_enable(dev, 0);
122 pnp_set_iobase(dev, PNP_IDX_IO0, 0x2e8);
123 pnp_set_irq(dev, PNP_IDX_IRQ0, 10);
124 pnp_set_enable(dev, 1);
125
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600126 dev = PNP_DEV(0x4e, W83627THG_FDC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000127 pnp_set_logical_device(dev);
128 pnp_set_enable(dev, 0);
129
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600130 dev = PNP_DEV(0x4e, W83627THG_PP);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000131 pnp_set_logical_device(dev);
132 pnp_set_enable(dev, 0);
133
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600134 dev = PNP_DEV(0x4e, W83627THG_KBC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000135 pnp_set_logical_device(dev);
136 pnp_set_enable(dev, 0);
137 pnp_set_iobase(dev, PNP_IDX_IO0, 0x00);
138 pnp_set_iobase(dev, PNP_IDX_IO1, 0x00);
139
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +0200140 pnp_exit_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000141}
142
Arthur Heymansdc584c32019-11-12 20:37:21 +0100143void mainboard_late_rcba_config(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000144{
Stefan Reinauer36a22682008-10-29 04:52:57 +0000145 /* Device 1f interrupt pin register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200146 RCBA32(D31IP) = 0x00042210;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000147 /* Device 1d interrupt pin register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200148 RCBA32(D28IP) = 0x00214321;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000149
150 /* dev irq route register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200151 RCBA16(D31IR) = 0x0132;
152 RCBA16(D30IR) = 0x3241;
153 RCBA16(D29IR) = 0x0237;
154 RCBA16(D28IR) = 0x3210;
155 RCBA16(D27IR) = 0x3210;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000156
Stefan Reinauer36a22682008-10-29 04:52:57 +0000157 /* Enable PCIe Root Port Clock Gate */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000158}