Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bin Meng | 3d23287 | 2015-06-23 12:18:49 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | 3d23287 | 2015-06-23 12:18:49 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 7 | #include <log.h> |
Bin Meng | 3d23287 | 2015-06-23 12:18:49 +0800 | [diff] [blame] | 8 | #include <asm/io.h> |
| 9 | #include <asm/ioapic.h> |
Simon Glass | 1cb1611 | 2016-03-11 22:07:34 -0700 | [diff] [blame] | 10 | #include <asm/lapic.h> |
Bin Meng | 3d23287 | 2015-06-23 12:18:49 +0800 | [diff] [blame] | 11 | |
| 12 | u32 io_apic_read(u32 reg) |
| 13 | { |
| 14 | writel(reg, IO_APIC_INDEX); |
| 15 | return readl(IO_APIC_DATA); |
| 16 | } |
| 17 | |
| 18 | void io_apic_write(u32 reg, u32 val) |
| 19 | { |
| 20 | writel(reg, IO_APIC_INDEX); |
| 21 | writel(val, IO_APIC_DATA); |
| 22 | } |
Simon Glass | 1cb1611 | 2016-03-11 22:07:34 -0700 | [diff] [blame] | 23 | |
| 24 | void io_apic_set_id(int ioapic_id) |
| 25 | { |
| 26 | int bsp_lapicid = lapicid(); |
| 27 | |
| 28 | debug("IOAPIC: Initialising IOAPIC at %08x\n", IO_APIC_ADDR); |
| 29 | debug("IOAPIC: Bootstrap Processor Local APIC = %#02x\n", bsp_lapicid); |
| 30 | |
| 31 | if (ioapic_id) { |
| 32 | debug("IOAPIC: ID = 0x%02x\n", ioapic_id); |
| 33 | /* Set IOAPIC ID if it has been specified */ |
| 34 | io_apic_write(0x00, (io_apic_read(0x00) & 0xf0ffffff) | |
| 35 | (ioapic_id << 24)); |
| 36 | } |
| 37 | } |