blob: b46a7e996f8e5a0414b552f27edce514dc1131bc [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 Meng15305362015-04-24 18:10:06 +080011#include <asm/arch/device.h>
12#include <asm/arch/irq.h>
Simon Glassb93abfc2015-01-27 22:13:36 -070013#include <asm/fsp/fsp_support.h>
Bin Meng08e484c2014-12-17 15:50:36 +080014#include <asm/processor.h>
15
Bin Mengb8b44402014-12-17 15:50:44 +080016static void unprotect_spi_flash(void)
17{
18 u32 bc;
19
Bin Meng80e336a2015-04-13 19:03:42 +080020 bc = x86_pci_read_config32(TNC_LPC, 0xd8);
Bin Mengb8b44402014-12-17 15:50:44 +080021 bc |= 0x1; /* unprotect the flash */
Bin Meng80e336a2015-04-13 19:03:42 +080022 x86_pci_write_config32(TNC_LPC, 0xd8, bc);
Bin Mengb8b44402014-12-17 15:50:44 +080023}
24
Bin Meng08e484c2014-12-17 15:50:36 +080025int arch_cpu_init(void)
26{
Bin Mengb8b44402014-12-17 15:50:44 +080027 struct pci_controller *hose;
28 int ret;
29
Bin Meng08e484c2014-12-17 15:50:36 +080030 post_code(POST_CPU_INIT);
31#ifdef CONFIG_SYS_X86_TSC_TIMER
32 timer_set_base(rdtsc());
33#endif
34
Bin Mengb8b44402014-12-17 15:50:44 +080035 ret = x86_cpu_init_f();
36 if (ret)
37 return ret;
38
39 ret = pci_early_init_hose(&hose);
40 if (ret)
41 return ret;
42
43 unprotect_spi_flash();
44
45 return 0;
Bin Meng08e484c2014-12-17 15:50:36 +080046}
Bin Meng15305362015-04-24 18:10:06 +080047
48int arch_misc_init(void)
49{
50 pirq_init();
51
52 return 0;
53}