blob: 6769ae53ae366f5a7a02e01b9bd8802820c67809 [file] [log] [blame]
Simon Glass0c9075e2014-11-24 21:18:15 -07001/*
2 * From coreboot file of same name
3 *
4 * Copyright (C) 2008-2009 coresystems GmbH
5 * Copyright (C) 2014 Google, Inc
6 *
7 * SPDX-License-Identifier: GPL-2.0
8 */
9
10#include <common.h>
Simon Glass0c9075e2014-11-24 21:18:15 -070011#include <asm/lapic.h>
12#include <asm/post.h>
13
14void lapic_setup(void)
15{
Bin Meng63d54a62015-06-17 11:15:38 +080016#ifdef CONFIG_SMP
Simon Glass0c9075e2014-11-24 21:18:15 -070017 /* Only Pentium Pro and later have those MSR stuff */
18 debug("Setting up local apic: ");
19
20 /* Enable the local apic */
21 enable_lapic();
22
Bin Meng63d54a62015-06-17 11:15:38 +080023 /* Set Task Priority to 'accept all' */
Simon Glass0c9075e2014-11-24 21:18:15 -070024 lapic_write_around(LAPIC_TASKPRI,
25 lapic_read_around(LAPIC_TASKPRI) & ~LAPIC_TPRI_MASK);
26
27 /* Put the local apic in virtual wire mode */
28 lapic_write_around(LAPIC_SPIV, (lapic_read_around(LAPIC_SPIV) &
Bin Meng63d54a62015-06-17 11:15:38 +080029 ~(LAPIC_VECTOR_MASK)) | LAPIC_SPIV_ENABLE);
Simon Glass0c9075e2014-11-24 21:18:15 -070030 lapic_write_around(LAPIC_LVT0, (lapic_read_around(LAPIC_LVT0) &
Bin Meng63d54a62015-06-17 11:15:38 +080031 ~(LAPIC_LVT_MASKED | LAPIC_LVT_LEVEL_TRIGGER |
32 LAPIC_LVT_REMOTE_IRR | LAPIC_INPUT_POLARITY |
33 LAPIC_SEND_PENDING | LAPIC_LVT_RESERVED_1 |
34 LAPIC_DELIVERY_MODE_MASK)) |
35 (LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING |
36 LAPIC_DELIVERY_MODE_EXTINT));
Simon Glass0c9075e2014-11-24 21:18:15 -070037 lapic_write_around(LAPIC_LVT1, (lapic_read_around(LAPIC_LVT1) &
Bin Meng63d54a62015-06-17 11:15:38 +080038 ~(LAPIC_LVT_MASKED | LAPIC_LVT_LEVEL_TRIGGER |
39 LAPIC_LVT_REMOTE_IRR | LAPIC_INPUT_POLARITY |
40 LAPIC_SEND_PENDING | LAPIC_LVT_RESERVED_1 |
41 LAPIC_DELIVERY_MODE_MASK)) |
42 (LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING |
43 LAPIC_DELIVERY_MODE_NMI));
Simon Glass0c9075e2014-11-24 21:18:15 -070044
45 debug("apic_id: 0x%02lx, ", lapicid());
Bin Meng63d54a62015-06-17 11:15:38 +080046#else /* !CONFIG_SMP */
Simon Glass0c9075e2014-11-24 21:18:15 -070047 /* Only Pentium Pro and later have those MSR stuff */
48 debug("Disabling local apic: ");
49 disable_lapic();
Bin Meng63d54a62015-06-17 11:15:38 +080050#endif /* CONFIG_SMP */
Simon Glass0c9075e2014-11-24 21:18:15 -070051 debug("done.\n");
52 post_code(POST_LAPIC);
53}