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 <charles.youse@intel.com>
This commit is contained in:
Charles E. Youse 2019-05-01 11:21:32 -07:00 committed by Anas Nashif
commit f16f7fc491
3 changed files with 19 additions and 4 deletions

View file

@ -79,6 +79,13 @@ u32_t pcie_get_mbar(pcie_bdf_t bdf, unsigned int index)
return pcie_get_bar(bdf, index, false); 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) u32_t pcie_get_iobar(pcie_bdf_t bdf, unsigned int index)
{ {
return pcie_get_bar(bdf, index, true); return pcie_get_bar(bdf, index, true);

View file

@ -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) static void show(const struct shell *shell, pcie_bdf_t bdf)
{ {
u32_t data; u32_t data;
unsigned int irq;
data = pcie_conf_read(bdf, PCIE_CONF_ID); 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"); shell_fprintf(shell, SHELL_NORMAL, "\n");
show_bars(shell, bdf); show_bars(shell, bdf);
show_msi(shell, bdf); show_msi(shell, bdf);
data = pcie_conf_read(bdf, PCIE_CONF_INTR); irq = pcie_wired_irq(bdf);
if (PCIE_CONF_INTR_IRQ(data) != PCIE_CONF_INTR_IRQ_NONE) { if (irq != PCIE_CONF_INTR_IRQ_NONE) {
shell_fprintf(shell, SHELL_NORMAL, shell_fprintf(shell, SHELL_NORMAL,
" wired interrupt on IRQ %d\n", " wired interrupt on IRQ %d\n", irq);
PCIE_CONF_INTR_IRQ(data));
} }
} }
} }

View file

@ -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); 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. * @brief Enable the PCI(e) endpoint to generate the specified IRQ.
* *