1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <bootblock_common.h>
5 #include <console/console.h>
6 #include <device/pci_ops.h>
9 #include <pc80/mc146818rtc.h>
10 #include <soc/iomap.h>
18 asmlinkage
void bootblock_c_entry(uint64_t base_timestamp
)
20 /* Call lib/bootblock.c main */
21 bootblock_main_with_basetime(base_timestamp
);
24 static void program_base_addresses(void)
27 const uint32_t lpc_dev
= PCI_DEV(0, LPC_DEV
, LPC_FUNC
);
29 /* Memory Mapped IO registers. */
30 reg
= PMC_BASE_ADDRESS
| 2;
31 pci_write_config32(lpc_dev
, PBASE
, reg
);
32 reg
= IO_BASE_ADDRESS
| 2;
33 pci_write_config32(lpc_dev
, IOBASE
, reg
);
34 reg
= ILB_BASE_ADDRESS
| 2;
35 pci_write_config32(lpc_dev
, IBASE
, reg
);
36 reg
= SPI_BASE_ADDRESS
| 2;
37 pci_write_config32(lpc_dev
, SBASE
, reg
);
38 reg
= MPHY_BASE_ADDRESS
| 2;
39 pci_write_config32(lpc_dev
, MPBASE
, reg
);
40 reg
= PUNIT_BASE_ADDRESS
| 2;
41 pci_write_config32(lpc_dev
, PUBASE
, reg
);
42 reg
= RCBA_BASE_ADDRESS
| 1;
43 pci_write_config32(lpc_dev
, RCBA
, reg
);
45 /* IO Port Registers. */
46 reg
= ACPI_BASE_ADDRESS
| 2;
47 pci_write_config32(lpc_dev
, ABASE
, reg
);
48 reg
= GPIO_BASE_ADDRESS
| 2;
49 pci_write_config32(lpc_dev
, GBASE
, reg
);
52 static void tco_disable(void)
56 reg
= inl(ACPI_BASE_ADDRESS
+ TCO1_CNT
);
58 outl(reg
, ACPI_BASE_ADDRESS
+ TCO1_CNT
);
61 static void spi_init(void)
63 void *scs
= (void *)(SPI_BASE_ADDRESS
+ SCS
);
64 void *bcr
= (void *)(SPI_BASE_ADDRESS
+ BCR
);
67 /* Disable generating SMI when setting WPD bit. */
68 write32(scs
, read32(scs
) & ~SMIWPEN
);
70 * Enable caching and prefetching in the SPI controller. Disable
71 * the SMM-only BIOS write and set WPD bit.
73 reg
= (read32(bcr
) & ~SRC_MASK
) | SRC_CACHE_PREFETCH
| BCR_WPD
;
78 static void soc_rtc_init(void)
80 int rtc_failed
= rtc_failure();
83 printk(BIOS_ERR
, "RTC Failure detected. Resetting date to %x/%x/%x%x\n",
84 coreboot_build_date
.month
, coreboot_build_date
.day
,
85 coreboot_build_date
.century
, coreboot_build_date
.year
);
87 cmos_init(rtc_failed
);
90 static void setup_mmconfig(void)
95 * Set up the MMCONF range. The register lives in the BUNIT. The IO variant of the
96 * config access needs to be used initially to properly configure as the IOSF access
97 * registers live in PCI config space.
100 /* Clear the extended register. */
101 pci_io_write_config32(IOSF_PCI_DEV
, MCRX_REG
, reg
);
102 reg
= CONFIG_ECAM_MMCONF_BASE_ADDRESS
| 1;
103 pci_io_write_config32(IOSF_PCI_DEV
, MDR_REG
, reg
);
104 reg
= IOSF_OPCODE(IOSF_OP_WRITE_BUNIT
) | IOSF_PORT(IOSF_PORT_BUNIT
) |
105 IOSF_REG(BUNIT_MMCONF_REG
) | IOSF_BYTE_EN
;
106 pci_io_write_config32(IOSF_PCI_DEV
, MCR_REG
, reg
);
109 void bootblock_soc_early_init(void)
111 /* Allow memory-mapped PCI config access */
114 /* Early chipset initialization */
115 program_base_addresses();
118 void bootblock_soc_init(void)
122 /* Continue chipset initialization */