Simon Glass | 0c9075e | 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> |
Simon Glass | 0c9075e | 2014-11-24 21:18:15 -0700 | [diff] [blame] | 11 | #include <asm/lapic.h> |
| 12 | #include <asm/post.h> |
| 13 | |
| 14 | void lapic_setup(void) |
| 15 | { |
Bin Meng | 63d54a6 | 2015-06-17 11:15:38 +0800 | [diff] [blame^] | 16 | #ifdef CONFIG_SMP |
Simon Glass | 0c9075e | 2014-11-24 21:18:15 -0700 | [diff] [blame] | 17 | /* 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 Meng | 63d54a6 | 2015-06-17 11:15:38 +0800 | [diff] [blame^] | 23 | /* Set Task Priority to 'accept all' */ |
Simon Glass | 0c9075e | 2014-11-24 21:18:15 -0700 | [diff] [blame] | 24 | 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 Meng | 63d54a6 | 2015-06-17 11:15:38 +0800 | [diff] [blame^] | 29 | ~(LAPIC_VECTOR_MASK)) | LAPIC_SPIV_ENABLE); |
Simon Glass | 0c9075e | 2014-11-24 21:18:15 -0700 | [diff] [blame] | 30 | lapic_write_around(LAPIC_LVT0, (lapic_read_around(LAPIC_LVT0) & |
Bin Meng | 63d54a6 | 2015-06-17 11:15:38 +0800 | [diff] [blame^] | 31 | ~(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 Glass | 0c9075e | 2014-11-24 21:18:15 -0700 | [diff] [blame] | 37 | lapic_write_around(LAPIC_LVT1, (lapic_read_around(LAPIC_LVT1) & |
Bin Meng | 63d54a6 | 2015-06-17 11:15:38 +0800 | [diff] [blame^] | 38 | ~(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 Glass | 0c9075e | 2014-11-24 21:18:15 -0700 | [diff] [blame] | 44 | |
| 45 | debug("apic_id: 0x%02lx, ", lapicid()); |
Bin Meng | 63d54a6 | 2015-06-17 11:15:38 +0800 | [diff] [blame^] | 46 | #else /* !CONFIG_SMP */ |
Simon Glass | 0c9075e | 2014-11-24 21:18:15 -0700 | [diff] [blame] | 47 | /* Only Pentium Pro and later have those MSR stuff */ |
| 48 | debug("Disabling local apic: "); |
| 49 | disable_lapic(); |
Bin Meng | 63d54a6 | 2015-06-17 11:15:38 +0800 | [diff] [blame^] | 50 | #endif /* CONFIG_SMP */ |
Simon Glass | 0c9075e | 2014-11-24 21:18:15 -0700 | [diff] [blame] | 51 | debug("done.\n"); |
| 52 | post_code(POST_LAPIC); |
| 53 | } |