blob: 86c1a536d6db4d1d442ffc850cf08102368c38db [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Georgie72a8a32012-11-06 11:05:09 +01002
3#include <arch/io.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02004#include <device/pci_ops.h>
Kyösti Mälkkif555a582020-01-06 19:41:42 +02005#include <device/smbus_host.h>
Angel Ponse1a616c2020-06-21 17:02:43 +02006#include <southbridge/intel/common/pmutil.h>
Patrick Georgie72a8a32012-11-06 11:05:09 +01007#include "i82801ix.h"
Arthur Heymans9ed0df42019-10-12 14:18:18 +02008#include "chip.h"
Patrick Georgie72a8a32012-11-06 11:05:09 +01009
Angel Pons3bff4192020-06-21 13:22:08 +020010void i82801ix_lpc_setup(void)
11{
12 const pci_devfn_t d31f0 = PCI_DEV(0, 0x1f, 0);
13 const struct device *dev = pcidev_on_root(0x1f, 0);
14 const struct southbridge_intel_i82801ix_config *config = NULL;
15
16 /* Configure serial IRQs.*/
17 pci_write_config8(d31f0, D31F0_SERIRQ_CNTL, 0xd0);
18 /*
19 * Enable some common LPC IO ranges:
20 * - 0x2e/0x2f, 0x4e/0x4f often SuperIO
21 * - 0x60/0x64, 0x62/0x66 often KBC/EC
22 * - 0x3f0-0x3f5/0x3f7 FDD
23 * - 0x378-0x37f and 0x778-0x77f LPT
24 * - 0x2f8-0x2ff COMB
25 * - 0x3f8-0x3ff COMA
26 * - 0x208-0x20f GAMEH
27 * - 0x200-0x207 GAMEL
28 */
29 pci_write_config16(d31f0, D31F0_LPC_IODEC, 0x0010);
30 pci_write_config16(d31f0, D31F0_LPC_EN, 0x3f0f);
31
32 /* Set up generic decode ranges */
33 if (!dev || !dev->chip_info)
34 return;
35 config = dev->chip_info;
36
37 pci_write_config32(d31f0, D31F0_GEN1_DEC, config->gen1_dec);
38 pci_write_config32(d31f0, D31F0_GEN2_DEC, config->gen2_dec);
39 pci_write_config32(d31f0, D31F0_GEN3_DEC, config->gen3_dec);
40 pci_write_config32(d31f0, D31F0_GEN4_DEC, config->gen4_dec);
41}
42
Patrick Georgie72a8a32012-11-06 11:05:09 +010043void i82801ix_early_init(void)
44{
Antonello Dettori196e3d42016-09-01 17:04:14 +020045 const pci_devfn_t d31f0 = PCI_DEV(0, 0x1f, 0);
Patrick Georgie72a8a32012-11-06 11:05:09 +010046
Kyösti Mälkki1cfafe22020-01-07 12:00:31 +020047 if (ENV_ROMSTAGE)
48 enable_smbus();
49
Patrick Georgie72a8a32012-11-06 11:05:09 +010050 /* Set up RCBA. */
Peter Lemenkov7b428112018-10-23 11:12:46 +020051 pci_write_config32(d31f0, RCBA, (uintptr_t)DEFAULT_RCBA | 1);
Patrick Georgie72a8a32012-11-06 11:05:09 +010052
53 /* Set up PMBASE. */
54 pci_write_config32(d31f0, D31F0_PMBASE, DEFAULT_PMBASE | 1);
55 /* Enable PMBASE. */
56 pci_write_config8(d31f0, D31F0_ACPI_CNTL, 0x80);
57
58 /* Set up GPIOBASE. */
59 pci_write_config32(d31f0, D31F0_GPIO_BASE, DEFAULT_GPIOBASE);
60 /* Enable GPIO. */
Angel Pons67406472020-06-08 11:13:42 +020061 pci_or_config8(d31f0, D31F0_GPIO_CNTL, 0x10);
Patrick Georgie72a8a32012-11-06 11:05:09 +010062
63 /* Reset watchdog. */
64 outw(0x0008, DEFAULT_TCOBASE + 0x04); /* R/WC, clear TCO caused SMI. */
65 outw(0x0002, DEFAULT_TCOBASE + 0x06); /* R/WC, clear second timeout. */
66
67 /* Enable upper 128bytes of CMOS. */
68 RCBA32(0x3400) = (1 << 2);
69
Martin Roth2ed0aa22016-01-05 20:58:58 -070070 /* Initialize power management initialization
Patrick Georgie72a8a32012-11-06 11:05:09 +010071 register early as it affects reboot behavior. */
72 /* Bit 20 activates global reset of host and ME on cf9 writes of 0x6
73 and 0xe (required if ME is disabled but present), bit 31 locks it.
74 The other bits are 'must write'. */
75 u8 reg8 = pci_read_config8(d31f0, 0xac);
Angel Pons67406472020-06-08 11:13:42 +020076
77 /* FIXME: It's a 8-bit variable!!! */
Patrick Georgie72a8a32012-11-06 11:05:09 +010078 reg8 |= (1 << 31) | (1 << 30) | (1 << 20) | (3 << 8);
79 pci_write_config8(d31f0, 0xac, reg8);
80
81 /* TODO: If RTC power failed, reset RTC state machine
82 (set, then reset RTC 0x0b bit7) */
83
84 /* TODO: Check power state bits in GEN_PMCON_2 (D31F0 0xa2)
85 before they get cleared. */
86}