blob: 9c1e6c0dc2c1a547bdf552cf7084a5c91ed9b591 [file] [log] [blame]
Patrick Georgie72a8a32012-11-06 11:05:09 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 secunet Security Networks AG
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Patrick Georgie72a8a32012-11-06 11:05:09 +010015 */
16
17#include <arch/io.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020018#include <device/pci_ops.h>
Kyösti Mälkkif555a582020-01-06 19:41:42 +020019#include <device/smbus_host.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +010020#include "i82801ix.h"
Arthur Heymans9ed0df42019-10-12 14:18:18 +020021#include "chip.h"
Patrick Georgie72a8a32012-11-06 11:05:09 +010022
23void i82801ix_early_init(void)
24{
Antonello Dettori196e3d42016-09-01 17:04:14 +020025 const pci_devfn_t d31f0 = PCI_DEV(0, 0x1f, 0);
Patrick Georgie72a8a32012-11-06 11:05:09 +010026
Kyösti Mälkki1cfafe22020-01-07 12:00:31 +020027 if (ENV_ROMSTAGE)
28 enable_smbus();
29
Patrick Georgie72a8a32012-11-06 11:05:09 +010030 /* Set up RCBA. */
Peter Lemenkov7b428112018-10-23 11:12:46 +020031 pci_write_config32(d31f0, RCBA, (uintptr_t)DEFAULT_RCBA | 1);
Patrick Georgie72a8a32012-11-06 11:05:09 +010032
33 /* Set up PMBASE. */
34 pci_write_config32(d31f0, D31F0_PMBASE, DEFAULT_PMBASE | 1);
35 /* Enable PMBASE. */
36 pci_write_config8(d31f0, D31F0_ACPI_CNTL, 0x80);
37
38 /* Set up GPIOBASE. */
39 pci_write_config32(d31f0, D31F0_GPIO_BASE, DEFAULT_GPIOBASE);
40 /* Enable GPIO. */
41 pci_write_config8(d31f0, D31F0_GPIO_CNTL,
42 pci_read_config8(d31f0, D31F0_GPIO_CNTL) | 0x10);
43
44 /* Reset watchdog. */
45 outw(0x0008, DEFAULT_TCOBASE + 0x04); /* R/WC, clear TCO caused SMI. */
46 outw(0x0002, DEFAULT_TCOBASE + 0x06); /* R/WC, clear second timeout. */
47
48 /* Enable upper 128bytes of CMOS. */
49 RCBA32(0x3400) = (1 << 2);
50
Martin Roth2ed0aa22016-01-05 20:58:58 -070051 /* Initialize power management initialization
Patrick Georgie72a8a32012-11-06 11:05:09 +010052 register early as it affects reboot behavior. */
53 /* Bit 20 activates global reset of host and ME on cf9 writes of 0x6
54 and 0xe (required if ME is disabled but present), bit 31 locks it.
55 The other bits are 'must write'. */
56 u8 reg8 = pci_read_config8(d31f0, 0xac);
57 reg8 |= (1 << 31) | (1 << 30) | (1 << 20) | (3 << 8);
58 pci_write_config8(d31f0, 0xac, reg8);
59
60 /* TODO: If RTC power failed, reset RTC state machine
61 (set, then reset RTC 0x0b bit7) */
62
63 /* TODO: Check power state bits in GEN_PMCON_2 (D31F0 0xa2)
64 before they get cleared. */
65}
Arthur Heymans9ed0df42019-10-12 14:18:18 +020066
67void i82801ix_lpc_decode(void)
68{
69 const pci_devfn_t d31f0 = PCI_DEV(0, 0x1f, 0);
70 const struct device *dev = pcidev_on_root(0x1f, 0);
71 const struct southbridge_intel_i82801ix_config *config = NULL;
72
73 /* Configure serial IRQs.*/
74 pci_write_config8(d31f0, D31F0_SERIRQ_CNTL, 0xd0);
75 /*
76 * Enable some common LPC IO ranges:
77 * - 0x2e/0x2f, 0x4e/0x4f often SuperIO
78 * - 0x60/0x64, 0x62/0x66 often KBC/EC
79 * - 0x3f0-0x3f5/0x3f7 FDD
80 * - 0x378-0x37f and 0x778-0x77f LPT
81 * - 0x2f8-0x2ff COMB
82 * - 0x3f8-0x3ff COMA
Arthur Heymans21c9aa12019-11-20 12:24:25 +010083 * - 0x208-0x20f GAMEH
84 * - 0x200-0x207 GAMEL
Arthur Heymans9ed0df42019-10-12 14:18:18 +020085 */
86 pci_write_config16(d31f0, D31F0_LPC_IODEC, 0x0010);
87 pci_write_config16(d31f0, D31F0_LPC_EN, 0x3f0f);
88
89 /* Set up generic decode ranges */
90 if (!dev || !dev->chip_info)
91 return;
92 config = dev->chip_info;
93
94 pci_write_config32(d31f0, D31F0_GEN1_DEC, config->gen1_dec);
95 pci_write_config32(d31f0, D31F0_GEN2_DEC, config->gen2_dec);
96 pci_write_config32(d31f0, D31F0_GEN3_DEC, config->gen3_dec);
97 pci_write_config32(d31f0, D31F0_GEN4_DEC, config->gen4_dec);
98}