1
2
3
4
5
6#include <common.h>
7#include <dm.h>
8#include <log.h>
9#include <spl.h>
10#include <asm/cpu.h>
11#include <asm/cpu_common.h>
12#include <asm/intel_regs.h>
13#include <asm/io.h>
14#include <asm/pci.h>
15#include <asm/arch/systemagent.h>
16#include <linux/delay.h>
17
18
19
20
21
22static int punit_init(struct udevice *dev)
23{
24 struct udevice *cpu;
25 u32 reg;
26 ulong start;
27 int ret;
28
29
30 ret = uclass_first_device_err(UCLASS_CPU, &cpu);
31 if (ret)
32 return log_msg_ret("Cannot find CPU", ret);
33 cpu_configure_thermal_target(cpu);
34
35
36
37
38
39 writel(0, MCHBAR_REG(CORE_DISABLE_MASK));
40
41
42 reg = readl(MCHBAR_REG(BIOS_RESET_CPL));
43 if (reg == 0xffffffff) {
44
45 debug("Punit MMIO not available\n");
46 return -ENOENT;
47 }
48
49
50 dm_pci_write_config8(dev, PCI_INTERRUPT_PIN, 0x2);
51
52
53 writel(PUINT_THERMAL_DEVICE_IRQ_VEC_NUMBER |
54 PUINT_THERMAL_DEVICE_IRQ_LOCK,
55 MCHBAR_REG(PUNIT_THERMAL_DEVICE_IRQ));
56
57
58 enable_bios_reset_cpl();
59
60
61
62
63
64
65 start = get_timer(0);
66 while (!(readl(MCHBAR_REG(BIOS_RESET_CPL)) & PCODE_INIT_DONE)) {
67 if (get_timer(start) > 1) {
68 debug("PCODE Init Done timeout\n");
69 return -ETIMEDOUT;
70 }
71 udelay(100);
72 }
73 debug("PUNIT init complete\n");
74
75 return 0;
76}
77
78static int apl_punit_probe(struct udevice *dev)
79{
80 if (spl_phase() == PHASE_SPL)
81 return punit_init(dev);
82
83 return 0;
84}
85
86static const struct udevice_id apl_syscon_ids[] = {
87 { .compatible = "intel,apl-punit", .data = X86_SYSCON_PUNIT },
88 { }
89};
90
91U_BOOT_DRIVER(intel_apl_punit) = {
92 .name = "intel_apl_punit",
93 .id = UCLASS_SYSCON,
94 .of_match = apl_syscon_ids,
95 .probe = apl_punit_probe,
96 DM_HEADER(<asm/cpu.h>)
97};
98