Simon Glass | 3121dbd | 2014-11-24 21:18:15 -0700 | [diff] [blame] | 1 | /* |
| 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> |
| 11 | #include <asm/msr.h> |
| 12 | #include <asm/io.h> |
| 13 | #include <asm/lapic.h> |
| 14 | #include <asm/post.h> |
| 15 | |
| 16 | void lapic_setup(void) |
| 17 | { |
| 18 | #if NEED_LAPIC == 1 |
| 19 | /* Only Pentium Pro and later have those MSR stuff */ |
| 20 | debug("Setting up local apic: "); |
| 21 | |
| 22 | /* Enable the local apic */ |
| 23 | enable_lapic(); |
| 24 | |
| 25 | /* |
| 26 | * Set Task Priority to 'accept all'. |
| 27 | */ |
| 28 | lapic_write_around(LAPIC_TASKPRI, |
| 29 | lapic_read_around(LAPIC_TASKPRI) & ~LAPIC_TPRI_MASK); |
| 30 | |
| 31 | /* Put the local apic in virtual wire mode */ |
| 32 | lapic_write_around(LAPIC_SPIV, (lapic_read_around(LAPIC_SPIV) & |
| 33 | ~(LAPIC_VECTOR_MASK)) | LAPIC_SPIV_ENABLE); |
| 34 | lapic_write_around(LAPIC_LVT0, (lapic_read_around(LAPIC_LVT0) & |
| 35 | ~(LAPIC_LVT_MASKED | LAPIC_LVT_LEVEL_TRIGGER | |
| 36 | LAPIC_LVT_REMOTE_IRR | LAPIC_INPUT_POLARITY | |
| 37 | LAPIC_SEND_PENDING | LAPIC_LVT_RESERVED_1 | |
| 38 | LAPIC_DELIVERY_MODE_MASK)) | |
| 39 | (LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING | |
| 40 | LAPIC_DELIVERY_MODE_EXTINT)); |
| 41 | lapic_write_around(LAPIC_LVT1, (lapic_read_around(LAPIC_LVT1) & |
| 42 | ~(LAPIC_LVT_MASKED | LAPIC_LVT_LEVEL_TRIGGER | |
| 43 | LAPIC_LVT_REMOTE_IRR | LAPIC_INPUT_POLARITY | |
| 44 | LAPIC_SEND_PENDING | LAPIC_LVT_RESERVED_1 | |
| 45 | LAPIC_DELIVERY_MODE_MASK)) | |
| 46 | (LAPIC_LVT_REMOTE_IRR | LAPIC_SEND_PENDING | |
| 47 | LAPIC_DELIVERY_MODE_NMI)); |
| 48 | |
| 49 | debug("apic_id: 0x%02lx, ", lapicid()); |
| 50 | #else /* !NEED_LLAPIC */ |
| 51 | /* Only Pentium Pro and later have those MSR stuff */ |
| 52 | debug("Disabling local apic: "); |
| 53 | disable_lapic(); |
| 54 | #endif /* !NEED_LAPIC */ |
| 55 | debug("done.\n"); |
| 56 | post_code(POST_LAPIC); |
| 57 | } |