Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Google Inc. |
| 5 | * |
| 6 | * 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. |
| 9 | * |
| 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. |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 14 | */ |
| 15 | |
Kyösti Mälkki | de64078 | 2019-12-03 07:30:26 +0200 | [diff] [blame^] | 16 | #include <arch/bootblock.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 17 | #include <device/pci_ops.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 18 | #include "pch.h" |
| 19 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 20 | /* |
| 21 | * Enable Prefetching and Caching. |
| 22 | */ |
| 23 | static void enable_spi_prefetch(void) |
| 24 | { |
| 25 | u8 reg8; |
Edward O'Callaghan | 9a817ef | 2014-10-26 10:12:15 +1100 | [diff] [blame] | 26 | pci_devfn_t dev; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 27 | |
| 28 | dev = PCI_DEV(0, 0x1f, 0); |
| 29 | |
| 30 | reg8 = pci_read_config8(dev, 0xdc); |
| 31 | reg8 &= ~(3 << 2); |
| 32 | reg8 |= (2 << 2); /* Prefetching and Caching Enabled */ |
| 33 | pci_write_config8(dev, 0xdc, reg8); |
| 34 | } |
| 35 | |
| 36 | |
| 37 | static void map_rcba(void) |
| 38 | { |
Edward O'Callaghan | 9a817ef | 2014-10-26 10:12:15 +1100 | [diff] [blame] | 39 | pci_devfn_t dev = PCI_DEV(0, 0x1f, 0); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 40 | |
Kevin Paul Herbert | bde6d30 | 2014-12-24 18:43:20 -0800 | [diff] [blame] | 41 | pci_write_config32(dev, RCBA, (uintptr_t)DEFAULT_RCBA | 1); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | static void enable_port80_on_lpc(void) |
| 45 | { |
Kyösti Mälkki | b544c00 | 2019-01-06 10:41:41 +0200 | [diff] [blame] | 46 | /* Enable port 80 POST on LPC. The chipset does this by default, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 47 | * but it doesn't appear to hurt anything. */ |
| 48 | u32 gcs = RCBA32(GCS); |
| 49 | gcs = gcs & ~0x4; |
| 50 | RCBA32(GCS) = gcs; |
| 51 | } |
| 52 | |
| 53 | static void set_spi_speed(void) |
| 54 | { |
| 55 | u32 fdod; |
| 56 | u8 ssfc; |
| 57 | |
| 58 | /* Observe SPI Descriptor Component Section 0 */ |
| 59 | SPIBAR32(FDOC) = 0x1000; |
| 60 | |
| 61 | /* Extract the Write/Erase SPI Frequency from descriptor */ |
| 62 | fdod = SPIBAR32(FDOD); |
| 63 | fdod >>= 24; |
| 64 | fdod &= 7; |
| 65 | |
| 66 | /* Set Software Sequence frequency to match */ |
| 67 | ssfc = SPIBAR8(SSFC + 2); |
| 68 | ssfc &= ~7; |
| 69 | ssfc |= fdod; |
| 70 | SPIBAR8(SSFC + 2) = ssfc; |
| 71 | } |
| 72 | |
Arthur Heymans | 8e646e7 | 2018-06-05 11:19:22 +0200 | [diff] [blame] | 73 | void bootblock_early_southbridge_init(void) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 74 | { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 75 | map_rcba(); |
| 76 | enable_spi_prefetch(); |
| 77 | enable_port80_on_lpc(); |
| 78 | set_spi_speed(); |
| 79 | |
| 80 | /* Enable upper 128bytes of CMOS */ |
| 81 | RCBA32(RC) = (1 << 2); |
Arthur Heymans | d893a26 | 2018-12-19 16:54:06 +0100 | [diff] [blame] | 82 | |
| 83 | pch_enable_lpc(); |
| 84 | mainboard_config_superio(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 85 | } |