blob: fa912bac57dd6a879747d0fe715f1bfa603bf25d [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Bin Meng8fefeec2015-06-23 12:18:49 +08002/*
3 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
Bin Meng8fefeec2015-06-23 12:18:49 +08004 */
5
Simon Glass0f2af882020-05-10 11:40:05 -06006#include <log.h>
Bin Meng8fefeec2015-06-23 12:18:49 +08007#include <asm/io.h>
8#include <asm/ioapic.h>
Simon Glass09493512016-03-11 22:07:34 -07009#include <asm/lapic.h>
Bin Meng8fefeec2015-06-23 12:18:49 +080010
11u32 io_apic_read(u32 reg)
12{
13 writel(reg, IO_APIC_INDEX);
14 return readl(IO_APIC_DATA);
15}
16
17void io_apic_write(u32 reg, u32 val)
18{
19 writel(reg, IO_APIC_INDEX);
20 writel(val, IO_APIC_DATA);
21}
Simon Glass09493512016-03-11 22:07:34 -070022
23void io_apic_set_id(int ioapic_id)
24{
25 int bsp_lapicid = lapicid();
26
27 debug("IOAPIC: Initialising IOAPIC at %08x\n", IO_APIC_ADDR);
28 debug("IOAPIC: Bootstrap Processor Local APIC = %#02x\n", bsp_lapicid);
29
30 if (ioapic_id) {
31 debug("IOAPIC: ID = 0x%02x\n", ioapic_id);
32 /* Set IOAPIC ID if it has been specified */
33 io_apic_write(0x00, (io_apic_read(0x00) & 0xf0ffffff) |
34 (ioapic_id << 24));
35 }
36}