blob: 0086fe3281f0956ea823484a7be1832e55eae9dc [file] [log] [blame]
Arthur Heymans1f127722019-06-04 09:46:36 +02001/*
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.
14 */
15
16#include <device/pci_ops.h>
17#include "pch.h"
18
19/*
20 * Enable Prefetching and Caching.
21 */
22static void enable_spi_prefetch(void)
23{
24 u8 reg8;
25 pci_devfn_t dev = PCH_LPC_DEV;
26
27 reg8 = pci_read_config8(dev, BIOS_CNTL);
28 reg8 &= ~(3 << 2);
29 reg8 |= (2 << 2); /* Prefetching and Caching Enabled */
30 pci_write_config8(dev, BIOS_CNTL, reg8);
31}
32
33static void enable_port80_on_lpc(void)
34{
35 pci_devfn_t dev = PCH_LPC_DEV;
36
37 /* Enable port 80 POST on LPC */
38 pci_write_config32(dev, RCBA, (uintptr_t)DEFAULT_RCBA | 1);
39#if 0
40 RCBA32(GCS) &= (~0x04);
41#else
42 volatile u32 *gcs = (volatile u32 *)(DEFAULT_RCBA + GCS);
43 u32 reg32 = *gcs;
44 reg32 = reg32 & ~0x04;
45 *gcs = reg32;
46#endif
47}
48
49static void set_spi_speed(void)
50{
51 u32 fdod;
52 u8 ssfc;
53
54 /* Observe SPI Descriptor Component Section 0 */
55 RCBA32(0x38b0) = 0x1000;
56
57 /* Extract the Write/Erase SPI Frequency from descriptor */
58 fdod = RCBA32(0x38b4);
59 fdod >>= 24;
60 fdod &= 7;
61
62 /* Set Software Sequence frequency to match */
63 ssfc = RCBA8(0x3893);
64 ssfc &= ~7;
65 ssfc |= fdod;
66 RCBA8(0x3893) = ssfc;
67}
68
69static void bootblock_southbridge_init(void)
70{
71 enable_spi_prefetch();
72 enable_port80_on_lpc();
73 set_spi_speed();
74
75 /* Enable upper 128bytes of CMOS */
76 RCBA32(RC) = (1 << 2);
77}