From f16f7fc491c933a17bcc06b86fc5f2b0a6fa59d5 Mon Sep 17 00:00:00 2001 From: "Charles E. Youse" Date: Wed, 1 May 2019 11:21:32 -0700 Subject: [PATCH] drivers/pcie: add support to read wired IRQ configuration Firmware is supposed to set a register in PCI configuration space which indicates the hardware IRQ that the endpoint is attached to. A function is implemented which reads this register, and the PCIe shell is updated to use it instead of doing it "manually". Signed-off-by: Charles E. Youse --- drivers/pcie/pcie.c | 7 +++++++ drivers/pcie/shell.c | 8 ++++---- include/drivers/pcie/pcie.h | 8 ++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/pcie/pcie.c b/drivers/pcie/pcie.c index 80f4d9bea2e..b79b9e6272e 100644 --- a/drivers/pcie/pcie.c +++ b/drivers/pcie/pcie.c @@ -79,6 +79,13 @@ u32_t pcie_get_mbar(pcie_bdf_t bdf, unsigned int index) return pcie_get_bar(bdf, index, false); } +unsigned int pcie_wired_irq(pcie_bdf_t bdf) +{ + u32_t data = pcie_conf_read(bdf, PCIE_CONF_INTR); + + return PCIE_CONF_INTR_IRQ(data); +} + u32_t pcie_get_iobar(pcie_bdf_t bdf, unsigned int index) { return pcie_get_bar(bdf, index, true); diff --git a/drivers/pcie/shell.c b/drivers/pcie/shell.c index c0adba9d903..0da9aea4da8 100644 --- a/drivers/pcie/shell.c +++ b/drivers/pcie/shell.c @@ -58,6 +58,7 @@ static void show_bars(const struct shell *shell, pcie_bdf_t bdf) static void show(const struct shell *shell, pcie_bdf_t bdf) { u32_t data; + unsigned int irq; data = pcie_conf_read(bdf, PCIE_CONF_ID); @@ -88,11 +89,10 @@ static void show(const struct shell *shell, pcie_bdf_t bdf) shell_fprintf(shell, SHELL_NORMAL, "\n"); show_bars(shell, bdf); show_msi(shell, bdf); - data = pcie_conf_read(bdf, PCIE_CONF_INTR); - if (PCIE_CONF_INTR_IRQ(data) != PCIE_CONF_INTR_IRQ_NONE) { + irq = pcie_wired_irq(bdf); + if (irq != PCIE_CONF_INTR_IRQ_NONE) { shell_fprintf(shell, SHELL_NORMAL, - " wired interrupt on IRQ %d\n", - PCIE_CONF_INTR_IRQ(data)); + " wired interrupt on IRQ %d\n", irq); } } } diff --git a/include/drivers/pcie/pcie.h b/include/drivers/pcie/pcie.h index 16dfe71c1db..7811e6b26b6 100644 --- a/include/drivers/pcie/pcie.h +++ b/include/drivers/pcie/pcie.h @@ -103,6 +103,14 @@ extern u32_t pcie_get_iobar(pcie_bdf_t bdf, unsigned int index); */ extern void pcie_set_cmd(pcie_bdf_t bdf, u32_t bits, bool on); +/** + * @brief Return the IRQ assigned by the firmware/board to an endpoint. + * + * @param bdf the PCI(e) endpoint + * @return the IRQ number, or PCIE_CONF_INTR_IRQ_NONE if unknown. + */ +extern unsigned int pcie_wired_irq(pcie_bdf_t bdf); + /** * @brief Enable the PCI(e) endpoint to generate the specified IRQ. *