Bin Meng | b2e02d2 | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 1 | /* |
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 Meng | adfe3b2 | 2014-12-17 15:50:44 +0800 | [diff] [blame] | 9 | #include <asm/pci.h> |
Bin Meng | b2e02d2 | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 10 | #include <asm/post.h> |
Bin Meng | adfe3b2 | 2014-12-17 15:50:44 +0800 | [diff] [blame] | 11 | #include <asm/arch/tnc.h> |
Simon Glass | 1021af4 | 2015-01-27 22:13:36 -0700 | [diff] [blame] | 12 | #include <asm/fsp/fsp_support.h> |
Bin Meng | b2e02d2 | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 13 | #include <asm/processor.h> |
14 | |||||
Bin Meng | adfe3b2 | 2014-12-17 15:50:44 +0800 | [diff] [blame] | 15 | static void unprotect_spi_flash(void) |
16 | { | ||||
17 | u32 bc; | ||||
18 | |||||
Bin Meng | 9704f23 | 2015-04-13 19:03:42 +0800 | [diff] [blame^] | 19 | bc = x86_pci_read_config32(TNC_LPC, 0xd8); |
Bin Meng | adfe3b2 | 2014-12-17 15:50:44 +0800 | [diff] [blame] | 20 | bc |= 0x1; /* unprotect the flash */ |
Bin Meng | 9704f23 | 2015-04-13 19:03:42 +0800 | [diff] [blame^] | 21 | x86_pci_write_config32(TNC_LPC, 0xd8, bc); |
Bin Meng | adfe3b2 | 2014-12-17 15:50:44 +0800 | [diff] [blame] | 22 | } |
23 | |||||
Bin Meng | b2e02d2 | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 24 | int arch_cpu_init(void) |
25 | { | ||||
Bin Meng | adfe3b2 | 2014-12-17 15:50:44 +0800 | [diff] [blame] | 26 | struct pci_controller *hose; |
27 | int ret; | ||||
28 | |||||
Bin Meng | b2e02d2 | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 29 | post_code(POST_CPU_INIT); |
30 | #ifdef CONFIG_SYS_X86_TSC_TIMER | ||||
31 | timer_set_base(rdtsc()); | ||||
32 | #endif | ||||
33 | |||||
Bin Meng | adfe3b2 | 2014-12-17 15:50:44 +0800 | [diff] [blame] | 34 | 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 Meng | b2e02d2 | 2014-12-17 15:50:36 +0800 | [diff] [blame] | 45 | } |