blob: 169b2819ca841674c6e3db288904f57f928ab87a [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Bin Meng51c3b1e2015-05-25 22:35:04 +08002/*
3 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
Bin Meng51c3b1e2015-05-25 22:35:04 +08004 */
5
6#ifndef _ARCH_IRQ_H_
7#define _ARCH_IRQ_H_
8
9#include <dt-bindings/interrupt-router/intel-irq.h>
10
11/**
12 * Intel interrupt router configuration mechanism
13 *
14 * There are two known ways of Intel interrupt router configuration mechanism
15 * so far. On most cases, the IRQ routing configuraiton is controlled by PCI
16 * configuraiton registers on the legacy bridge, normally PCI BDF(0, 31, 0).
17 * On some newer platforms like BayTrail and Braswell, the IRQ routing is now
18 * in the IBASE register block where IBASE is memory-mapped.
19 */
20enum pirq_config {
21 PIRQ_VIA_PCI,
22 PIRQ_VIA_IBASE
23};
24
25/**
26 * Intel interrupt router control block
27 *
28 * Its members' value will be filled in based on device tree's input.
29 *
30 * @config: PIRQ_VIA_PCI or PIRQ_VIA_IBASE
31 * @link_base: link value base number
32 * @irq_mask: IRQ mask reprenting the 16 IRQs in 8259, bit N is 1 means
33 * IRQ N is available to be routed
34 * @lb_bdf: irq router's PCI bus/device/function number encoding
35 * @ibase: IBASE register block base address
Bin Mengc3b03ea2016-05-07 07:46:14 -070036 * @actl_8bit: ACTL register width is 8-bit (for ICH series chipset)
37 * @actl_addr: ACTL register offset
Bin Meng51c3b1e2015-05-25 22:35:04 +080038 */
39struct irq_router {
40 int config;
41 u32 link_base;
42 u16 irq_mask;
43 u32 bdf;
44 u32 ibase;
Bin Mengc3b03ea2016-05-07 07:46:14 -070045 bool actl_8bit;
46 int actl_addr;
Bin Meng51c3b1e2015-05-25 22:35:04 +080047};
48
49struct pirq_routing {
50 int bdf;
51 int pin;
52 int pirq;
53};
54
55/* PIRQ link number and value conversion */
56#define LINK_V2N(link, base) (link - base)
57#define LINK_N2V(link, base) (link + base)
58
59#define PIRQ_BITMAP 0xdef8
60
61/**
Simon Glass7da3ca62016-01-19 21:32:27 -070062 * irq_router_common_init() - Perform common x86 interrupt init
63 *
64 * This creates the PIRQ routing table and routes the IRQs
65 */
66int irq_router_common_init(struct udevice *dev);
67
Bin Meng51c3b1e2015-05-25 22:35:04 +080068#endif /* _ARCH_IRQ_H_ */