blob: f756a0d6a56abb929255552c4a6e5e60b811e027 [file] [log] [blame]
Bin Meng08e484c2014-12-17 15:50:36 +08001/*
2 * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <asm/io.h>
Bin Mengb8b44402014-12-17 15:50:44 +08009#include <asm/pci.h>
Bin Meng08e484c2014-12-17 15:50:36 +080010#include <asm/post.h>
Bin Mengb8b44402014-12-17 15:50:44 +080011#include <asm/arch/tnc.h>
Simon Glassb93abfc2015-01-27 22:13:36 -070012#include <asm/fsp/fsp_support.h>
Bin Meng08e484c2014-12-17 15:50:36 +080013#include <asm/processor.h>
14
Bin Mengb8b44402014-12-17 15:50:44 +080015static void unprotect_spi_flash(void)
16{
17 u32 bc;
18
Bin Meng80e336a2015-04-13 19:03:42 +080019 bc = x86_pci_read_config32(TNC_LPC, 0xd8);
Bin Mengb8b44402014-12-17 15:50:44 +080020 bc |= 0x1; /* unprotect the flash */
Bin Meng80e336a2015-04-13 19:03:42 +080021 x86_pci_write_config32(TNC_LPC, 0xd8, bc);
Bin Mengb8b44402014-12-17 15:50:44 +080022}
23
Bin Meng08e484c2014-12-17 15:50:36 +080024int arch_cpu_init(void)
25{
Bin Mengb8b44402014-12-17 15:50:44 +080026 struct pci_controller *hose;
27 int ret;
28
Bin Meng08e484c2014-12-17 15:50:36 +080029 post_code(POST_CPU_INIT);
30#ifdef CONFIG_SYS_X86_TSC_TIMER
31 timer_set_base(rdtsc());
32#endif
33
Bin Mengb8b44402014-12-17 15:50:44 +080034 ret = x86_cpu_init_f();
35 if (ret)
36 return ret;
37
38 ret = pci_early_init_hose(&hose);
39 if (ret)
40 return ret;
41
42 unprotect_spi_flash();
43
44 return 0;
Bin Meng08e484c2014-12-17 15:50:36 +080045}