blob: 039712fca6a01c370622d141186027aee7726b16 [file] [log] [blame]
Angel Pons182dbde2020-04-02 23:49:05 +02001/* SPDX-License-Identifier: GPL-2.0-only */
zbao246e84b2012-07-13 18:47:03 +08002
3#include <stdint.h>
Kyösti Mälkki520717d2019-12-15 21:37:48 +02004#include <arch/bootblock.h>
5#include <amdblocks/acpimmio.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02006#include <device/pci_ops.h>
Kyösti Mälkki520717d2019-12-15 21:37:48 +02007#include <southbridge/amd/agesa/hudson/hudson.h>
zbao246e84b2012-07-13 18:47:03 +08008
9/*
10 * Enable 4MB (LPC) ROM access at 0xFFC00000 - 0xFFFFFFFF.
11 *
12 * Hardware should enable LPC ROM by pin straps. This function does not
13 * handle the theoretically possible PCI ROM, FWH, or SPI ROM configurations.
14 *
15 * The HUDSON power-on default is to map 512K ROM space.
16 *
17 */
18static void hudson_enable_rom(void)
19{
20 u8 reg8;
Elyes HAOUAS49f63e02020-04-22 16:14:26 +020021 const pci_devfn_t dev = PCI_DEV(0, 0x14, 3);
zbao246e84b2012-07-13 18:47:03 +080022
23 /* Decode variable LPC ROM address ranges 1 and 2. */
Kyösti Mälkki282717e2019-12-09 08:08:58 +020024 reg8 = pci_s_read_config8(dev, 0x48);
zbao246e84b2012-07-13 18:47:03 +080025 reg8 |= (1 << 3) | (1 << 4);
Kyösti Mälkki282717e2019-12-09 08:08:58 +020026 pci_s_write_config8(dev, 0x48, reg8);
zbao246e84b2012-07-13 18:47:03 +080027
28 /* LPC ROM address range 1: */
29 /* Enable LPC ROM range mirroring start at 0x000e(0000). */
Kyösti Mälkki282717e2019-12-09 08:08:58 +020030 pci_s_write_config16(dev, 0x68, 0x000e);
zbao246e84b2012-07-13 18:47:03 +080031 /* Enable LPC ROM range mirroring end at 0x000f(ffff). */
Kyösti Mälkki282717e2019-12-09 08:08:58 +020032 pci_s_write_config16(dev, 0x6a, 0x000f);
zbao246e84b2012-07-13 18:47:03 +080033
34 /* LPC ROM address range 2: */
35 /*
36 * Enable LPC ROM range start at:
37 * 0xfff8(0000): 512KB
38 * 0xfff0(0000): 1MB
39 * 0xffe0(0000): 2MB
40 * 0xffc0(0000): 4MB
41 */
Kyösti Mälkki282717e2019-12-09 08:08:58 +020042 pci_s_write_config16(dev, 0x6c, 0x10000 - (CONFIG_COREBOOT_ROMSIZE_KB >> 6));
zbao246e84b2012-07-13 18:47:03 +080043 /* Enable LPC ROM range end at 0xffff(ffff). */
Kyösti Mälkki282717e2019-12-09 08:08:58 +020044 pci_s_write_config16(dev, 0x6e, 0xffff);
zbao246e84b2012-07-13 18:47:03 +080045}
46
Kyösti Mälkki520717d2019-12-15 21:37:48 +020047void bootblock_early_southbridge_init(void)
Michał Żygowski8cee45c2019-11-23 18:03:46 +010048{
Michał Żygowski8cee45c2019-11-23 18:03:46 +010049 u32 data;
50
Kyösti Mälkki520717d2019-12-15 21:37:48 +020051 hudson_enable_rom();
Michał Żygowski8cee45c2019-11-23 18:03:46 +010052 enable_acpimmio_decode_pm24();
Kyösti Mälkkia244d5e2019-12-09 08:08:58 +020053 hudson_lpc_decode();
Michał Żygowski8cee45c2019-11-23 18:03:46 +010054
Kyösti Mälkki657d68b2019-12-03 12:36:09 +020055 if (CONFIG(POST_DEVICE_PCI_PCIE))
56 hudson_pci_port80();
57 else if (CONFIG(POST_DEVICE_LPC))
58 hudson_lpc_port80();
59
Elyes HAOUAS49f63e02020-04-22 16:14:26 +020060 const pci_devfn_t dev = PCI_DEV(0, 0x14, 3);
Michał Żygowski8cee45c2019-11-23 18:03:46 +010061 data = pci_read_config32(dev, LPC_IO_OR_MEM_DECODE_ENABLE);
62 /* enable 0x2e/0x4e IO decoding for SuperIO */
63 pci_write_config32(dev, LPC_IO_OR_MEM_DECODE_ENABLE, data | 3);
64
65 /*
66 * Enable FCH to decode TPM associated Memory and IO regions for vboot
67 *
68 * Enable decoding of TPM cycles defined in TPM 1.2 spec
69 * Enable decoding of legacy TPM addresses: IO addresses 0x7f-
70 * 0x7e and 0xef-0xee.
71 */
Michał Żygowski8cee45c2019-11-23 18:03:46 +010072 data = pci_read_config32(dev, LPC_TRUSTED_PLATFORM_MODULE);
73 data |= TPM_12_EN | TPM_LEGACY_EN;
74 pci_write_config32(dev, LPC_TRUSTED_PLATFORM_MODULE, data);
75
76 /*
77 * In Hudson RRG, PMIOxD2[5:4] is "Drive strength control for
78 * LpcClk[1:0]". This following register setting has been
79 * replicated in every reference design since Parmer, so it is
80 * believed to be required even though it is not documented in
81 * the SoC BKDGs. Without this setting, there is no serial
82 * output.
83 */
84 pm_write8(0xd2, 0);
85}