dm: x86: Remove pirq_init() and cpu_irq_init()
v2 cover dm: x86: Remove pirq_init() and cpu_irq_init()
This series adds an interrupt driver for x86. Since different platforms can implement this in their own way, we no-longer need the platform-specific weak function. We can also dispense with the arch_misc_init() call in some cases.
Changes in v2:
- Rebase on top of updated SPI flash series
Simon Glass (6):
dm: x86: Create a driver for x86 interrupts
dm: x86: Set up interrupt routing from interrupt_init()
dm: x86: Add a common PIRQ init function
dm: x86: quark: Add an interrupt driver
dm: x86: queensbay: Add an interrupt driver
dm: x86: Drop the weak cpu_irq_init() function
arch/x86/cpu/baytrail/valleyview.c | 2 +- arch/x86/cpu/interrupts.c | 9 ++++++ arch/x86/cpu/irq.c | 32 ++++++++++++++----- arch/x86/cpu/qemu/qemu.c | 5 --- arch/x86/cpu/quark/Makefile | 2 +- arch/x86/cpu/quark/irq.c | 49 ++++++++++++++++++++++++++++ arch/x86/cpu/quark/quark.c | 27 +--------------- arch/x86/cpu/queensbay/Makefile | 2 +- arch/x86/cpu/queensbay/irq.c | 65 ++++++++++++++++++++++++++++++++++++++ arch/x86/cpu/queensbay/tnc.c | 39 +---------------------- arch/x86/dts/crownbay.dts | 2 +- arch/x86/dts/galileo.dts | 2 +- arch/x86/include/asm/irq.h | 19 ++--------- include/configs/qemu-x86.h | 1 - include/dm/uclass-id.h | 1 + 15 files changed, 158 insertions(+), 99 deletions(-) create mode 100644 arch/x86/cpu/quark/irq.c create mode 100644 arch/x86/cpu/queensbay/irq.c
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 1/6 dm: x86: Create a driver for x86 interrupts
It seems likely that at some point we will want a generic interrupt uclass. But this is a big undertaking as it involves unifying code across multiple architectures.
As a first step, create a simple IRQ uclass and a driver for x86. This can be generalised later as required.
Adjust pirq_init() to probe this driver, which has the effect of creating routing tables and setting up the interrupt routing. This is a start towards making interrupts fit better with driver model.
---
Changes in v2: None
arch/x86/cpu/irq.c | 25 +++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + 2 files changed, 26 insertions(+)
arch/x86/cpu/irq.c +25 -0
@@ -5,6 +5,7 @@*/ #include <common.h> +#include <dm.h> #include <errno.h> #include <fdtdec.h> #include <malloc.h>
@@ -232,6 +233,13 @@ static int create_pirq_routing_table(void)int pirq_init (void ) { +struct udevice *dev; + +return uclass_first_device (UCLASS_IRQ , &dev); +} + +int irq_router_probe (struct udevice *dev) +{int ret;cpu_irq_init ();
@@ -255,3 +263,20 @@ u32 write_pirq_routing_table(u32 addr)return copy_pirq_routing_table (addr, pirq_routing_table); } + +static const struct udevice_id irq_router_ids[] = { + { .compatible ="intel,irq-router" }, + { } +}; + +U_BOOT_DRIVER (irq_router_drv) = { + .name ="intel_irq" , + .id =UCLASS_IRQ , + .of_match = irq_router_ids, + .probe = irq_router_probe, +}; + +UCLASS_DRIVER (irq) = { + .id =UCLASS_IRQ , + .name ="irq" , +};
include/dm/uclass-id.h +1 -0
@@ -37,6 +37,7 @@ enum uclass_id {UCLASS_I2C_EEPROM ,/* I2C EEPROM device */ UCLASS_I2C_GENERIC ,/* Generic I2C device */ UCLASS_I2C_MUX ,/* I2C multiplexer */ +UCLASS_IRQ ,/* Interrupt controller */ UCLASS_KEYBOARD ,/* Keyboard input device */ UCLASS_LED ,/* Light-emitting diode (LED) */ UCLASS_LPC, /* x86 'low pin count' interface */
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 2/6 dm: x86: Set up interrupt routing from interrupt_init()
In reply to Simon GlassAt present interrupt routing is set up from arch_misc_init(). We can do it a little later instead, in interrupt_init().
This removes the manual pirq_init() call. Where the platform does not have an interrupt router defined in its device tree, no error is generated. Some platforms do not have this.
Drop pirq_init() since it is no-longer used.
---
Changes in v2: None
arch/x86/cpu/baytrail/valleyview.c | 2 +- arch/x86/cpu/interrupts.c | 9 +++++++++ arch/x86/cpu/irq.c | 7 ------- arch/x86/cpu/qemu/qemu.c | 5 ----- arch/x86/cpu/quark/quark.c | 2 +- arch/x86/cpu/queensbay/tnc.c | 2 +- arch/x86/include/asm/irq.h | 10 ---------- include/configs/qemu-x86.h | 1 - 8 files changed, 12 insertions(+), 26 deletions(-)
arch/x86/cpu/baytrail/valleyview.c +1 -1
@@ -50,7 +50,7 @@ int arch_misc_init(void)mrccache_save ();#endif -return pirq_init (); +return 0 ; }int reserve_arch (void )
arch/x86/cpu/interrupts.c +9 -0
@@ -12,6 +12,7 @@*/ #include <common.h> +#include <dm.h> #include <asm/cache.h> #include <asm/control_regs.h> #include <asm/interrupt.h>
@@ -244,6 +245,14 @@ int disable_interrupts(void)int interrupt_init (void ) { +struct udevice *dev; +int ret; + +/* Try to set up the interrupt router, but don't require one */ + ret =uclass_first_device (UCLASS_IRQ , &dev); +if (ret && ret != -ENODEV ) +return ret; +/* * When running as an EFI application we are not in control of * interrupts and should leave them alone.
arch/x86/cpu/irq.c +0 -7
@@ -231,13 +231,6 @@ static int create_pirq_routing_table(void)return 0 ; } -int pirq_init (void ) -{ -struct udevice *dev; - -return uclass_first_device (UCLASS_IRQ , &dev); -} -int irq_router_probe (struct udevice *dev) {int ret;
arch/x86/cpu/qemu/qemu.c +0 -5
@@ -96,11 +96,6 @@ int arch_early_init_r(void)return 0 ; } -int arch_misc_init (void ) -{ -return pirq_init (); -} -#ifdef CONFIG_GENERATE_MP_TABLE int mp_determine_pci_dstirq (int bus,int dev,int func,int pirq) {
arch/x86/cpu/quark/quark.c +1 -1
@@ -375,7 +375,7 @@ int arch_misc_init(void)mrccache_save ();#endif -return pirq_init (); +return 0 ; }void board_final_cleanup (void )
arch/x86/cpu/queensbay/tnc.c +1 -1
@@ -110,5 +110,5 @@ int arch_misc_init(void) {unprotect_spi_flash (); -return pirq_init (); +return 0 ; }
arch/x86/include/asm/irq.h +0 -10
@@ -65,14 +65,4 @@ struct pirq_routing {*/ void cpu_irq_init (void ); -/** -* pirq_init() - Initialize platform PIRQ routing -* -* This initializes the PIRQ routing on the platform and configures all PCI -* devices' interrupt line register to a working IRQ number on the 8259 PIC. -* -* @return 0 if OK, -ve on error -*/ -int pirq_init (void ); -#endif /* _ARCH_IRQ_H_ */
include/configs/qemu-x86.h +0 -1
@@ -14,7 +14,6 @@#include <configs/x86-common.h> #define CONFIG_SYS_MONITOR_LEN (1 << 20) -#define CONFIG_ARCH_MISC_INIT #define CONFIG_ARCH_EARLY_INIT_R #define CONFIG_PCI_PNP
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 3/6 dm: x86: Add a common PIRQ init function
In reply to Simon GlassMost x86 interrupt drivers will want to use the standard PIRQ routing and table setup. Put this code in a common function so it can be used by those drivers that want it.
---
Changes in v2: None
arch/x86/cpu/irq.c | 7 ++++++- arch/x86/include/asm/irq.h | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
arch/x86/cpu/irq.c +6 -1
@@ -231,7 +231,7 @@ static int create_pirq_routing_table(void)return 0 ; } -int irq_router_probe (struct udevice *dev) +int irq_router_common_init (struct udevice *dev) {int ret;
@@ -249,6 +249,11 @@ int irq_router_probe(struct udevice *dev)return 0 ; } +int irq_router_probe (struct udevice *dev) +{ +return irq_router_common_init (dev); +} +u32 write_pirq_routing_table (u32 addr) {if (!pirq_routing_table)
arch/x86/include/asm/irq.h +7 -0
@@ -65,4 +65,11 @@ struct pirq_routing {*/ void cpu_irq_init (void ); +/** +* irq_router_common_init() - Perform common x86 interrupt init +* +* This creates the PIRQ routing table and routes the IRQs +*/ +int irq_router_common_init (struct udevice *dev); +#endif /* _ARCH_IRQ_H_ */
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 4/6 dm: x86: quark: Add an interrupt driver
In reply to Simon GlassAdd a driver for interrupts on quark and move the code currently in cpu_irq_init() into its probe() method.
---
Changes in v2: None
arch/x86/cpu/quark/Makefile | 2 +- arch/x86/cpu/quark/irq.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ arch/x86/cpu/quark/quark.c | 25 ----------------------- arch/x86/dts/galileo.dts | 2 +- 4 files changed, 51 insertions(+), 27 deletions(-) create mode 100644 arch/x86/cpu/quark/irq.c
arch/x86/cpu/quark/Makefile +1 -1
@@ -4,5 +4,5 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += car.o dram.o msg_port.o quark.o +obj-y += car.o dram.o irq.o msg_port.o quark.o obj-y += mrc.o mrc_util.o hte.o smc.o
arch/x86/cpu/quark/irq.c new file +49 -0
49 lines not on this page · raw message
arch/x86/cpu/quark/quark.c +0 -25
@@ -7,12 +7,10 @@#include <common.h> #include <mmc.h> #include <asm/io.h> -#include <asm/irq.h> #include <asm/mrccache.h> #include <asm/mtrr.h> #include <asm/pci.h> #include <asm/post.h> -#include <asm/processor.h> #include <asm/arch/device.h> #include <asm/arch/msg_port.h> #include <asm/arch/quark.h>
@@ -341,29 +339,6 @@ int cpu_mmc_init(bd_t *bis)return pci_mmc_init ("Quark SDHCI" , mmc_supported); } -void cpu_irq_init (void ) -{ -struct quark_rcba *rcba; -u32 base; - -qrk_pci_read_config_dword (QUARK_LEGACY_BRIDGE ,LB_RCBA , &base); - base &= ~MEM_BAR_EN ; - rcba = (struct quark_rcba *)base; - -/* -* Route Quark PCI device interrupt pin to PIRQ -* -* Route device#23's INTA/B/C/D to PIRQA/B/C/D -* Route device#20,21's INTA/B/C/D to PIRQE/F/G/H -*/ -writew (PIRQC , &rcba->rmu_ir); -writew (PIRQA | (PIRQB <<4 ) | (PIRQC <<8 ) | (PIRQD <<12 ), - &rcba->d23_ir); -writew (PIRQD , &rcba->core_ir); -writew (PIRQE | (PIRQF <<4 ) | (PIRQG <<8 ) | (PIRQH <<12 ), - &rcba->d20d21_ir); -} -int arch_misc_init (void ) {#ifdef CONFIG_ENABLE_MRC_CACHE
arch/x86/dts/galileo.dts +1 -1
@@ -84,7 +84,7 @@ compatible = "intel,pch7"; irq-router { - compatible = "intel,irq-router"; + compatible = "intel,quark-irq-router"; intel,pirq-config = "pci"; intel,pirq-link = <0x60 8>; intel,pirq-mask = <0xdef8>;
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 5/6 dm: x86: queensbay: Add an interrupt driver
In reply to Simon GlassAdd a driver for interrupts on queensbay and move the code currently in cpu_irq_init() into its probe() method.
---
Changes in v2: None
arch/x86/cpu/queensbay/Makefile | 2 +- arch/x86/cpu/queensbay/irq.c | 65 +++++++++++++++++++++++++++++++++++++++++ arch/x86/cpu/queensbay/tnc.c | 37 ----------------------- arch/x86/dts/crownbay.dts | 2 +- 4 files changed, 67 insertions(+), 39 deletions(-) create mode 100644 arch/x86/cpu/queensbay/irq.c
arch/x86/cpu/queensbay/Makefile +1 -1
@@ -4,5 +4,5 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y += fsp_configs.o +obj-y += fsp_configs.o irq.o obj-y += tnc.o topcliff.o
arch/x86/cpu/queensbay/irq.c new file +65 -0
65 lines not on this page · raw message
arch/x86/cpu/queensbay/tnc.c +0 -37
@@ -69,43 +69,6 @@ int arch_early_init_r(void)return 0 ; } -void cpu_irq_init (void ) -{ -struct tnc_rcba *rcba; -u32 base; - - base =x86_pci_read_config32 (TNC_LPC ,LPC_RCBA ); - base &= ~MEM_BAR_EN ; - rcba = (struct tnc_rcba *)base; - -/* Make sure all internal PCI devices are using INTA */ -writel (INTA , &rcba->d02ip); -writel (INTA , &rcba->d03ip); -writel (INTA , &rcba->d27ip); -writel (INTA , &rcba->d31ip); -writel (INTA , &rcba->d23ip); -writel (INTA , &rcba->d24ip); -writel (INTA , &rcba->d25ip); -writel (INTA , &rcba->d26ip); - -/* -* Route TunnelCreek PCI device interrupt pin to PIRQ -* -* Since PCIe downstream ports received INTx are routed to PIRQ -* A/B/C/D directly and not configurable, we have to route PCIe -* root ports' INTx to PIRQ A/B/C/D as well. For other devices -* on TunneCreek, route them to PIRQ E/F/G/H. -*/ -writew (PIRQE , &rcba->d02ir); -writew (PIRQF , &rcba->d03ir); -writew (PIRQG , &rcba->d27ir); -writew (PIRQH , &rcba->d31ir); -writew (PIRQA , &rcba->d23ir); -writew (PIRQB , &rcba->d24ir); -writew (PIRQC , &rcba->d25ir); -writew (PIRQD , &rcba->d26ir); -} -int arch_misc_init (void ) {unprotect_spi_flash ();
arch/x86/dts/crownbay.dts +1 -1
@@ -164,7 +164,7 @@ compatible = "intel,pch7"; irq-router { - compatible = "intel,irq-router"; + compatible = "intel,queensbay-irq-router"; intel,pirq-config = "pci"; intel,pirq-link = <0x60 8>; intel,pirq-mask = <0xcee0>;
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
PATCH v2 6/6 dm: x86: Drop the weak cpu_irq_init() function
In reply to Simon GlassThere are no callers now. Platforms which need to set up interrupts their own way can implement an interrupt driver. Drop this function.
---
Changes in v2:
- Rebase on top of updated SPI flash series
arch/x86/cpu/irq.c | 7 ------- arch/x86/include/asm/irq.h | 10 ---------- 2 files changed, 17 deletions(-)
arch/x86/cpu/irq.c +0 -7
@@ -83,11 +83,6 @@ static inline void fill_irq_info(struct irq_info *slot, int bus, int device, slot->irq[pin -1 ].bitmap = irq_router.irq_mask; } -__weak void cpu_irq_init (void ) -{ -return ; -} -static int create_pirq_routing_table (void ) {const void *blob = gd->fdt_blob;
@@ -235,8 +230,6 @@ int irq_router_common_init(struct udevice *dev) {int ret; -cpu_irq_init (); - ret =create_pirq_routing_table ();if (ret) {debug ("Failed to create pirq routing table\n" );
arch/x86/include/asm/irq.h +0 -10
@@ -56,16 +56,6 @@ struct pirq_routing {#define PIRQ_BITMAP 0xdef8/** -* cpu_irq_init() - Initialize CPU IRQ routing -* -* This initializes some platform-specific registers related to IRQ routing, -* like configuring internal PCI devices to use which PCI interrupt pin, -* and which PCI interrupt pin is mapped to which PIRQ line. Note on some -* platforms, such IRQ routing might be hard-coded thus cannot configure. -*/ -void cpu_irq_init (void ); - -/** * irq_router_common_init() - Perform common x86 interrupt init * * This creates the PIRQ routing table and routes the IRQs
Signature · 1 line
2.6.0.rc2.230.g3dd15c0
v2 cover dm: x86: Remove pirq_init() and cpu_irq_init()
In reply to Simon GlassHi Simon,
Quoted 8 lines · Simon Glass
This series adds an interrupt driver for x86. Since different platforms can implement this in their own way, we no-longer need the platform-specific weak function. We can also dispense with the
arch_misc_init()call in some cases.Changes in v2:
- Rebase on top of updated SPI flash series
Quoted 8 lines
Simon Glass (6):
dm: x86: Create a driver for x86 interrupts
dm: x86: Set up interrupt routing frominterrupt_init()
dm: x86: Add a common PIRQ init function
dm: x86: quark: Add an interrupt driver
dm: x86: queensbay: Add an interrupt driver
dm: x86: Drop the weakcpu_irq_init()function
I've tested this series, but oops, it broke queensbay and quark. Sorry I did not catch this during previous review :(
The issue is with:
Both queensbay and quark irq driver's probe will call create_pirq_routing_table() in the end, where it calls:
node = fdtdec_next_compatible(blob, 0, COMPAT_INTEL_IRQ_ROUTER);
but COMPAT_INTEL_IRQ_ROUTER is not the string for queensbay and quark. Maybe we need pass the compatible string as the parameter to create_pirq_routing_table()?
Regards,
Bin
v2 cover dm: x86: Remove pirq_init() and cpu_irq_init()
Hi Bin.
Quoted 25 lines · Bin Meng
Hi Simon,
Quoted 8 lines · Simon Glass
This series adds an interrupt driver for x86. Since different platforms can implement this in their own way, we no-longer need the platform-specific weak function. We can also dispense with the
arch_misc_init()call in some cases.Changes in v2:
- Rebase on top of updated SPI flash seriesQuoted 8 lines
Simon Glass (6):
dm: x86: Create a driver for x86 interrupts
dm: x86: Set up interrupt routing frominterrupt_init()
dm: x86: Add a common PIRQ init function
dm: x86: quark: Add an interrupt driver
dm: x86: queensbay: Add an interrupt driver
dm: x86: Drop the weakcpu_irq_init()functionI've tested this series, but oops, it broke queensbay and quark. Sorry I did not catch this during previous review :(
The issue is with:
Quoted 8 lines
Both queensbay and quark irq driver's probe will call
create_pirq_routing_table()in the end, where it calls:node =
fdtdec_next_compatible(blob, 0, COMPAT_INTEL_IRQ_ROUTER);but
COMPAT_INTEL_IRQ_ROUTERis not the string for queensbay and quark. Maybe we need pass the compatible string as the parameter tocreate_pirq_routing_table()?
I think we can drop this with a few more patches. I sent a v3 for you to try/review.
Regards,
Simon