Skip to content

Commit 31a6594

Browse files
umarnisar92carlescufi
authored andcommitted
drivers: loapic: add device tree support for loapic
As per #26393, Local APIC is using Kconfig based option for the base address. This patch adds DTS binding support in the driver, just like its conunter part I/O APIC. Signed-off-by: Umar Nisar <[email protected]>
1 parent a4858c4 commit 31a6594

File tree

14 files changed

+101
-37
lines changed

14 files changed

+101
-37
lines changed

arch/x86/core/ia32/intstub.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* exception) stubs are implemented in this module. The stubs are invoked when
1414
* entering and exiting a C interrupt handler.
1515
*/
16+
#define LOAPIC_BASE_ADDRESS DT_REG_ADDR(DT_NODELABEL(intc_loapic))
1617

1718
#include <zephyr/arch/x86/ia32/asm.h>
1819
#include <offsets_short.h>
@@ -197,10 +198,10 @@ alreadyOnIntStack:
197198
wrmsr
198199
#else /* xAPIC */
199200
#ifdef DEVICE_MMIO_IS_IN_RAM
200-
movl z_loapic_regs, %edx
201+
movl Z_TOPLEVEL_RAM_NAME(LOAPIC_REGS_STR), %edx
201202
movl %eax, LOAPIC_EOI(%edx)
202203
#else
203-
movl %eax, (CONFIG_LOAPIC_BASE_ADDRESS + LOAPIC_EOI)
204+
movl %eax, (LOAPIC_BASE_ADDRESS + LOAPIC_EOI)
204205
#endif /* DEVICE_MMIO_IS_IN_RAM */
205206
#endif /* CONFIG_X2APIC */
206207

arch/x86/core/intel64/locore.S

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright (c) 2019 Intel Corporation
33
* SPDX-License-Identifier: Apache-2.0
44
*/
5+
#define LOAPIC_BASE_ADDRESS DT_REG_ADDR(DT_NODELABEL(intc_loapic))
56

67
#include <zephyr/toolchain.h>
78
#include <zephyr/arch/x86/multiboot.h>
@@ -142,7 +143,7 @@ x86_ap_start:
142143
* so we can locate our x86_cpuboot[] bundle. Put it in EBP.
143144
*/
144145

145-
movl CONFIG_LOAPIC_BASE_ADDRESS+LOAPIC_ID, %eax
146+
movl LOAPIC_BASE_ADDRESS+LOAPIC_ID, %eax
146147
shrl $24, %eax
147148
andl $0x0F, %eax /* local APIC ID -> EAX */
148149

@@ -810,7 +811,7 @@ irq_dispatch:
810811
movl $(X86_X2APIC_BASE_MSR + (LOAPIC_EOI >> 4)), %ecx
811812
wrmsr
812813
#else /* xAPIC */
813-
movq z_loapic_regs, %rdx
814+
movq Z_TOPLEVEL_RAM_NAME(LOAPIC_REGS_STR), %rdx
814815
movl %eax, LOAPIC_EOI(%rdx)
815816
#endif /* CONFIG_X2APIC */
816817

drivers/interrupt_controller/Kconfig.loapic

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ menuconfig LOAPIC
99

1010
if LOAPIC
1111

12-
config LOAPIC_BASE_ADDRESS
13-
hex "Local APIC Base Address"
14-
default 0xFEE00000
15-
help
16-
This option specifies the base address of the Local APIC device.
17-
1812
config X2APIC
1913
bool "Access local APIC in x2APIC mode"
2014
help

drivers/interrupt_controller/intc_loapic.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6+
7+
#define DT_DRV_COMPAT intel_loapic
8+
69
/*
710
* driver for x86 CPU local APIC (as an interrupt controller)
811
*/
@@ -59,18 +62,15 @@
5962
#define LOAPIC_SPURIOUS_VECTOR_ID CONFIG_LOAPIC_SPURIOUS_VECTOR_ID
6063
#endif
6164

62-
#define LOPIC_SSPND_BITS_PER_IRQ 1 /* Just the one for enable disable*/
63-
#define LOPIC_SUSPEND_BITS_REQD (ROUND_UP((LOAPIC_IRQ_COUNT * LOPIC_SSPND_BITS_PER_IRQ), 32))
65+
#define LOAPIC_SSPND_BITS_PER_IRQ 1 /* Just the one for enable disable*/
66+
#define LOAPIC_SUSPEND_BITS_REQD (ROUND_UP((LOAPIC_IRQ_COUNT * LOAPIC_SSPND_BITS_PER_IRQ), 32))
6467
#ifdef CONFIG_PM_DEVICE
6568
#include <zephyr/pm/device.h>
6669
__pinned_bss
67-
uint32_t loapic_suspend_buf[LOPIC_SUSPEND_BITS_REQD / 32] = {0};
70+
uint32_t loapic_suspend_buf[LOAPIC_SUSPEND_BITS_REQD / 32] = {0};
6871
#endif
6972

70-
#ifdef DEVICE_MMIO_IS_IN_RAM
71-
__pinned_bss
72-
mm_reg_t z_loapic_regs;
73-
#endif
73+
DEVICE_MMIO_TOPLEVEL(LOAPIC_REGS_STR, DT_DRV_INST(0));
7474

7575
__pinned_func
7676
void send_eoi(void)
@@ -87,11 +87,8 @@ __pinned_func
8787
void z_loapic_enable(unsigned char cpu_number)
8888
{
8989
int32_t loApicMaxLvt; /* local APIC Max LVT */
90+
DEVICE_MMIO_TOPLEVEL_MAP(LOAPIC_REGS_STR, K_MEM_CACHE_NONE);
9091

91-
#ifdef DEVICE_MMIO_IS_IN_RAM
92-
device_map(&z_loapic_regs, CONFIG_LOAPIC_BASE_ADDRESS, 0x1000,
93-
K_MEM_CACHE_NONE);
94-
#endif /* DEVICE_MMIO_IS_IN_RAM */
9592
#ifndef CONFIG_X2APIC
9693
/*
9794
* in xAPIC and flat model, bits 24-31 in LDR (Logical APIC ID) are
@@ -340,7 +337,7 @@ static int loapic_suspend(const struct device *port)
340337

341338
ARG_UNUSED(port);
342339

343-
(void)memset(loapic_suspend_buf, 0, (LOPIC_SUSPEND_BITS_REQD >> 3));
340+
(void)memset(loapic_suspend_buf, 0, (LOAPIC_SUSPEND_BITS_REQD >> 3));
344341

345342
for (loapic_irq = 0; loapic_irq < LOAPIC_IRQ_COUNT; loapic_irq++) {
346343

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
description: Local Advanced Programmable Interrupt Controller (APIC)
2+
3+
compatible: "intel,loapic"
4+
5+
include: [interrupt-controller.yaml, base.yaml]
6+
7+
properties:
8+
reg:
9+
required: true
10+
11+
"#interrupt-cells":
12+
const: 3
13+
14+
interrupt-cells:
15+
- irq
16+
- sense
17+
- priority

dts/x86/intel/alder_lake.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
interrupt-controller;
3838
};
3939

40+
intc_loapic: loapic@fee00000 {
41+
compatible = "intel,loapic";
42+
reg = <0xfee00000 0x1000>;
43+
interrupt-controller;
44+
#interrupt-cells = <3>;
45+
#address-cells = <1>;
46+
};
47+
4048
pcie0: pcie0 {
4149
#address-cells = <1>;
4250
#size-cells = <1>;

dts/x86/intel/apollo_lake.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@
3636
interrupt-controller;
3737
};
3838

39+
intc_loapic: loapic@fee00000 {
40+
compatible = "intel,loapic";
41+
reg = <0xfee00000 0x1000>;
42+
interrupt-controller;
43+
#interrupt-cells = <3>;
44+
#address-cells = <1>;
45+
};
46+
3947
pcie0: pcie0 {
4048
#address-cells = <1>;
4149
#size-cells = <1>;

dts/x86/intel/atom.dtsi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
#interrupt-cells = <3>;
3333
};
3434

35+
intc_loapic: loapic@fee00000 {
36+
compatible = "intel,loapic";
37+
reg = <0xfee00000 0x1000>;
38+
interrupt-controller;
39+
#interrupt-cells = <3>;
40+
};
41+
3542
soc {
3643
#address-cells = <1>;
3744
#size-cells = <1>;

dts/x86/intel/elkhart_lake.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
interrupt-controller;
4242
};
4343

44+
intc_loapic: loapic@fee00000 {
45+
compatible = "intel,loapic";
46+
reg = <0xfee00000 0x1000>;
47+
interrupt-controller;
48+
#interrupt-cells = <3>;
49+
#address-cells = <1>;
50+
};
51+
4452
pcie0: pcie0 {
4553
#address-cells = <1>;
4654
#size-cells = <1>;

dts/x86/intel/ia32.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
interrupt-controller;
3030
};
3131

32+
intc_loapic: loapic@fee00000 {
33+
compatible = "intel,loapic";
34+
reg = <0xfee00000 0x1000>;
35+
interrupt-controller;
36+
#interrupt-cells = <3>;
37+
#address-cells = <1>;
38+
};
39+
3240
dram0: memory@0 {
3341
device_type = "memory";
3442
reg = <DT_DRAM_BASE DT_DRAM_SIZE>;

0 commit comments

Comments
 (0)