lapic.c 1.6 KB

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