blob: 21475745c19c3768af5ea78284ad87151bfdbbb2 [file] [log] [blame]
Aaron Durbin76c37002012-10-30 09:03:43 -05001/*
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 Durbin76c37002012-10-30 09:03:43 -050014 */
15
Kyösti Mälkkide640782019-12-03 07:30:26 +020016#include <arch/bootblock.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020017#include <device/pci_ops.h>
Aaron Durbin76c37002012-10-30 09:03:43 -050018#include "pch.h"
19
Aaron Durbin76c37002012-10-30 09:03:43 -050020/*
21 * Enable Prefetching and Caching.
22 */
23static void enable_spi_prefetch(void)
24{
25 u8 reg8;
Edward O'Callaghan9a817ef2014-10-26 10:12:15 +110026 pci_devfn_t dev;
Aaron Durbin76c37002012-10-30 09:03:43 -050027
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
37static void map_rcba(void)
38{
Edward O'Callaghan9a817ef2014-10-26 10:12:15 +110039 pci_devfn_t dev = PCI_DEV(0, 0x1f, 0);
Aaron Durbin76c37002012-10-30 09:03:43 -050040
Kevin Paul Herbertbde6d302014-12-24 18:43:20 -080041 pci_write_config32(dev, RCBA, (uintptr_t)DEFAULT_RCBA | 1);
Aaron Durbin76c37002012-10-30 09:03:43 -050042}
43
44static void enable_port80_on_lpc(void)
45{
Kyösti Mälkkib544c002019-01-06 10:41:41 +020046 /* Enable port 80 POST on LPC. The chipset does this by default,
Aaron Durbin76c37002012-10-30 09:03:43 -050047 * but it doesn't appear to hurt anything. */
48 u32 gcs = RCBA32(GCS);
49 gcs = gcs & ~0x4;
50 RCBA32(GCS) = gcs;
51}
52
53static 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 Heymans8e646e72018-06-05 11:19:22 +020073void bootblock_early_southbridge_init(void)
Aaron Durbin76c37002012-10-30 09:03:43 -050074{
Aaron Durbin76c37002012-10-30 09:03:43 -050075 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 Heymansd893a262018-12-19 16:54:06 +010082
83 pch_enable_lpc();
84 mainboard_config_superio();
Aaron Durbin76c37002012-10-30 09:03:43 -050085}