1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2014, Bin Meng <bmeng.cn@gmail.com>
4  */
5 
6 #include <common.h>
7 #include <mmc.h>
8 #include <pci_ids.h>
9 #include <asm/irq.h>
10 #include <asm/mrccache.h>
11 #include <asm/post.h>
12 #include <asm/arch/iomap.h>
13 
14 /* GPIO SUS */
15 #define GPIO_SUS_PAD_BASE	(IO_BASE_ADDRESS + IO_BASE_OFFSET_GPSSUS)
16 #define GPIO_SUS_DFX5_CONF0	0x150
17 #define BYT_TRIG_LVL		BIT(24)
18 #define BYT_TRIG_POS		BIT(25)
19 
20 #ifndef CONFIG_EFI_APP
21 int arch_cpu_init(void)
22 {
23 	post_code(POST_CPU_INIT);
24 
25 	return x86_cpu_init_f();
26 }
27 
28 int arch_misc_init(void)
29 {
30 	if (!ll_boot_init())
31 		return 0;
32 
33 #ifdef CONFIG_ENABLE_MRC_CACHE
34 	/*
35 	 * We intend not to check any return value here, as even MRC cache
36 	 * is not saved successfully, it is not a severe error that will
37 	 * prevent system from continuing to boot.
38 	 */
39 	mrccache_save();
40 #endif
41 
42 	/*
43 	 * For some unknown reason, FSP (gold4) for BayTrail configures
44 	 * the GPIO DFX5 PAD to enable level interrupt (bit 24 and 25).
45 	 * This does not cause any issue when Linux kernel runs w/ or w/o
46 	 * the pinctrl driver for BayTrail. However this causes unstable
47 	 * S3 resume if the pinctrl driver is included in the kernel build.
48 	 * As this pin keeps generating interrupts during an S3 resume,
49 	 * and there is no IRQ requester in the kernel to handle it, the
50 	 * kernel seems to hang and does not continue resuming.
51 	 *
52 	 * Clear the mysterious interrupt bits for this pin.
53 	 */
54 	clrbits_le32(GPIO_SUS_PAD_BASE + GPIO_SUS_DFX5_CONF0,
55 		     BYT_TRIG_LVL | BYT_TRIG_POS);
56 
57 	return 0;
58 }
59 
60 #endif
61 
62 void reset_cpu(ulong addr)
63 {
64 	/* cold reset */
65 	x86_full_reset();
66 }
67