Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 1 | /* |
| 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 Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame^] | 18 | #include <device/pci_ops.h> |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 19 | #include "i82801ix.h" |
| 20 | |
| 21 | void i82801ix_early_init(void) |
| 22 | { |
Antonello Dettori | 196e3d4 | 2016-09-01 17:04:14 +0200 | [diff] [blame] | 23 | const pci_devfn_t d31f0 = PCI_DEV(0, 0x1f, 0); |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 24 | |
| 25 | /* Set up RCBA. */ |
Peter Lemenkov | 7b42811 | 2018-10-23 11:12:46 +0200 | [diff] [blame] | 26 | pci_write_config32(d31f0, RCBA, (uintptr_t)DEFAULT_RCBA | 1); |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 27 | |
| 28 | /* Set up PMBASE. */ |
| 29 | pci_write_config32(d31f0, D31F0_PMBASE, DEFAULT_PMBASE | 1); |
| 30 | /* Enable PMBASE. */ |
| 31 | pci_write_config8(d31f0, D31F0_ACPI_CNTL, 0x80); |
| 32 | |
| 33 | /* Set up GPIOBASE. */ |
| 34 | pci_write_config32(d31f0, D31F0_GPIO_BASE, DEFAULT_GPIOBASE); |
| 35 | /* Enable GPIO. */ |
| 36 | pci_write_config8(d31f0, D31F0_GPIO_CNTL, |
| 37 | pci_read_config8(d31f0, D31F0_GPIO_CNTL) | 0x10); |
| 38 | |
| 39 | /* Reset watchdog. */ |
| 40 | outw(0x0008, DEFAULT_TCOBASE + 0x04); /* R/WC, clear TCO caused SMI. */ |
| 41 | outw(0x0002, DEFAULT_TCOBASE + 0x06); /* R/WC, clear second timeout. */ |
| 42 | |
| 43 | /* Enable upper 128bytes of CMOS. */ |
| 44 | RCBA32(0x3400) = (1 << 2); |
| 45 | |
Martin Roth | 2ed0aa2 | 2016-01-05 20:58:58 -0700 | [diff] [blame] | 46 | /* Initialize power management initialization |
Patrick Georgi | e72a8a3 | 2012-11-06 11:05:09 +0100 | [diff] [blame] | 47 | register early as it affects reboot behavior. */ |
| 48 | /* Bit 20 activates global reset of host and ME on cf9 writes of 0x6 |
| 49 | and 0xe (required if ME is disabled but present), bit 31 locks it. |
| 50 | The other bits are 'must write'. */ |
| 51 | u8 reg8 = pci_read_config8(d31f0, 0xac); |
| 52 | reg8 |= (1 << 31) | (1 << 30) | (1 << 20) | (3 << 8); |
| 53 | pci_write_config8(d31f0, 0xac, reg8); |
| 54 | |
| 55 | /* TODO: If RTC power failed, reset RTC state machine |
| 56 | (set, then reset RTC 0x0b bit7) */ |
| 57 | |
| 58 | /* TODO: Check power state bits in GEN_PMCON_2 (D31F0 0xa2) |
| 59 | before they get cleared. */ |
| 60 | } |