2 * This file is part of the coreboot project.
4 * Copyright (C) 2014 Google Inc.
5 * Copyright (C) 2015 Intel Corporation.
6 * Copyright (C) 2016 Intel Corporation.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <soc/bootblock.h>
19 #include <soc/iomap.h>
22 #include <soc/pci_devs.h>
27 * Enable Prefetching and Caching.
29 static void enable_spi_prefetch(void)
31 u8 reg8
= pci_read_config8(PCH_DEV_SPI
, 0xdc);
33 reg8
|= (2 << 2); /* Prefetching and Caching Enabled */
34 pci_write_config8(PCH_DEV_SPI
, 0xdc, reg8
);
37 static void enable_spibar(void)
39 device_t dev
= PCH_DEV_SPI
;
42 /* Assign Resources to SPI Controller */
43 /* Clear BIT 1-2 SPI Command Register */
44 pcireg
= pci_read_config8(dev
, PCI_COMMAND
);
45 pcireg
&= ~(PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
);
46 pci_write_config8(dev
, PCI_COMMAND
, pcireg
);
48 /* Program Temporary BAR for SPI */
49 pci_write_config32(dev
, PCI_BASE_ADDRESS_0
,
50 SPI_BASE_ADDRESS
| PCI_BASE_ADDRESS_SPACE_MEMORY
);
52 /* Enable Bus Master and MMIO Space */
53 pcireg
= pci_read_config8(dev
, PCI_COMMAND
);
54 pcireg
|= PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
;
55 pci_write_config8(dev
, PCI_COMMAND
, pcireg
);
58 static void enable_p2sbbar(void)
60 device_t dev
= PCH_DEV_P2SB
;
62 /* Enable PCR Base address in PCH */
63 pci_write_config32(dev
, PCI_BASE_ADDRESS_0
, PCH_PCR_BASE_ADDRESS
);
66 pci_write_config8(dev
, PCI_COMMAND
,
67 PCI_COMMAND_MASTER
| PCI_COMMAND_MEMORY
);
70 * Enable decoding for HPET memory address range.
71 * HPTC_OFFSET(0x60) bit 7, when set the P2SB will decode
72 * the High Performance Timer memory address range
73 * selected by bits 1:0
75 pci_write_config8(dev
, HPTC_OFFSET
, HPTC_ADDR_ENABLE_BIT
);
78 void bootblock_pch_early_init(void)
81 enable_spi_prefetch();