blob: 80ce896323d88c181d1be578bd8a64c32dd415a4 [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>
Edwin Beasanteb50c7d2010-07-06 21:05:04 +000020#include <pc80/mc146818rtc.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
26#include "option_table.h"
Patrick Georgid0835952010-10-05 09:07:10 +000027
Arthur Heymansfecf7772019-11-09 14:19:04 +010028/* Override the default lpc decode ranges */
Arthur Heymansdc584c32019-11-12 20:37:21 +010029void mainboard_lpc_decode(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000030{
Patrick Georgia4700192011-01-27 07:39:38 +000031 int lpt_en = 0;
Kyösti Mälkkibee82ab2019-12-26 10:57:43 +020032 u8 val;
33
34 if (get_option(&val, "lpt") == CB_SUCCESS && val)
Arthur Heymansb451df22017-08-15 20:59:09 +020035 lpt_en = LPT_LPC_EN; /* enable LPT */
36
Arthur Heymansfecf7772019-11-09 14:19:04 +010037 pci_update_config16(PCI_DEV(0, 0x1f, 0), LPC_EN, ~LPT_LPC_EN, lpt_en);
Stefan Reinauer36a22682008-10-29 04:52:57 +000038}
39
Stefan Reinauer36a22682008-10-29 04:52:57 +000040/* 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 Heymansc5839202019-11-12 23:48:42 +010045void bootblock_mainboard_early_init(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +000046{
Antonello Dettori9ec11232016-11-08 18:44:46 +010047 pnp_devfn_t dev;
Stefan Reinauer14e22772010-04-27 06:56:47 +000048
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060049 dev = PNP_DEV(0x2e, W83627THG_SP1);
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +020050 pnp_enter_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +000051
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020052 pnp_write_config(dev, 0x24, 0xc6); /* PNPCSV */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +000053
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020054 pnp_write_config(dev, 0x29, 0x43); /* GPIO settings */
55 pnp_write_config(dev, 0x2a, 0x40); /* GPIO settings */
Stefan Reinaueraca6ec62009-10-26 17:12:21 +000056
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060057 dev = PNP_DEV(0x2e, W83627THG_SP1);
Stefan Reinauer36a22682008-10-29 04:52:57 +000058 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 HAOUAS531b87a2016-09-19 09:46:33 -060064 dev = PNP_DEV(0x2e, W83627THG_SP2);
Stefan Reinauer36a22682008-10-29 04:52:57 +000065 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 Reinauer36a22682008-10-29 04:52:57 +000069 pnp_set_enable(dev, 1);
70
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060071 dev = PNP_DEV(0x2e, W83627THG_KBC);
Stefan Reinauer36a22682008-10-29 04:52:57 +000072 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 Reinauer36a22682008-10-29 04:52:57 +000076 pnp_set_enable(dev, 1);
77
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060078 dev = PNP_DEV(0x2e, W83627THG_GAME_MIDI_GPIO1);
Stefan Reinauer36a22682008-10-29 04:52:57 +000079 pnp_set_logical_device(dev);
80 pnp_set_enable(dev, 0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020081 pnp_write_config(dev, 0xf5, 0xff); /* invert all GPIOs */
Stefan Reinauer36a22682008-10-29 04:52:57 +000082 pnp_set_enable(dev, 1);
83
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060084 dev = PNP_DEV(0x2e, W83627THG_GPIO2);
Stefan Reinauer36a22682008-10-29 04:52:57 +000085 pnp_set_logical_device(dev);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020086 pnp_set_enable(dev, 1); /* Just enable it */
Stefan Reinauer36a22682008-10-29 04:52:57 +000087
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060088 dev = PNP_DEV(0x2e, W83627THG_GPIO3);
Stefan Reinauer36a22682008-10-29 04:52:57 +000089 pnp_set_logical_device(dev);
90 pnp_set_enable(dev, 0);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +020091 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 Reinauer36a22682008-10-29 04:52:57 +000094
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060095 dev = PNP_DEV(0x2e, W83627THG_FDC);
Stefan Reinauer36a22682008-10-29 04:52:57 +000096 pnp_set_logical_device(dev);
97 pnp_set_enable(dev, 0);
98
Elyes HAOUAS531b87a2016-09-19 09:46:33 -060099 dev = PNP_DEV(0x2e, W83627THG_PP);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000100 pnp_set_logical_device(dev);
101 pnp_set_enable(dev, 0);
102
Stefan Reinauer54309d62009-01-20 22:53:10 +0000103 /* Enable HWM */
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600104 dev = PNP_DEV(0x2e, W83627THG_HWM);
Stefan Reinauer54309d62009-01-20 22:53:10 +0000105 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 HAOUAS5d4cf362018-08-06 09:58:28 +0200110 pnp_exit_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000111
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600112 dev = PNP_DEV(0x4e, W83627THG_SP1);
Elyes HAOUAS5d4cf362018-08-06 09:58:28 +0200113 pnp_enter_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000114
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200115 pnp_set_logical_device(dev); /* Set COM3 to sane non-conflicting values */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000116 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 HAOUAS531b87a2016-09-19 09:46:33 -0600121 dev = PNP_DEV(0x4e, W83627THG_SP2);
Elyes HAOUASf10b5ff2016-10-06 19:49:55 +0200122 pnp_set_logical_device(dev); /* Set COM4 to sane non-conflicting values */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000123 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 HAOUAS531b87a2016-09-19 09:46:33 -0600128 dev = PNP_DEV(0x4e, W83627THG_FDC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000129 pnp_set_logical_device(dev);
130 pnp_set_enable(dev, 0);
131
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600132 dev = PNP_DEV(0x4e, W83627THG_PP);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000133 pnp_set_logical_device(dev);
134 pnp_set_enable(dev, 0);
135
Elyes HAOUAS531b87a2016-09-19 09:46:33 -0600136 dev = PNP_DEV(0x4e, W83627THG_KBC);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000137 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 HAOUAS5d4cf362018-08-06 09:58:28 +0200142 pnp_exit_conf_state(dev);
Stefan Reinauer36a22682008-10-29 04:52:57 +0000143}
144
Arthur Heymansdc584c32019-11-12 20:37:21 +0100145void mainboard_late_rcba_config(void)
Stefan Reinauer36a22682008-10-29 04:52:57 +0000146{
Stefan Reinauer36a22682008-10-29 04:52:57 +0000147 /* Device 1f interrupt pin register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200148 RCBA32(D31IP) = 0x00042210;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000149 /* Device 1d interrupt pin register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200150 RCBA32(D28IP) = 0x00214321;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000151
152 /* dev irq route register */
Arthur Heymansb451df22017-08-15 20:59:09 +0200153 RCBA16(D31IR) = 0x0132;
154 RCBA16(D30IR) = 0x3241;
155 RCBA16(D29IR) = 0x0237;
156 RCBA16(D28IR) = 0x3210;
157 RCBA16(D27IR) = 0x3210;
Stefan Reinauer36a22682008-10-29 04:52:57 +0000158
Stefan Reinauer36a22682008-10-29 04:52:57 +0000159 /* Enable PCIe Root Port Clock Gate */
Stefan Reinauer36a22682008-10-29 04:52:57 +0000160}