Commit 969864ef authored by Raju Rangoju's avatar Raju Rangoju Committed by Wolfram Sang

i2c: amd-mp2: use msix/msi if the hardware supports

Use msix or msi interrupts if the hardware supports it. Else, fallback to
legacy interrupts.
Co-developed-by: default avatarBasavaraj Natikar <basavaraj.natikar@amd.com>
Signed-off-by: default avatarBasavaraj Natikar <basavaraj.natikar@amd.com>
Signed-off-by: default avatarRaju Rangoju <Raju.Rangoju@amd.com>
Acked-by: default avatarShyam Sundar S K <Shyam-sundar.S-k@amd.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 30a0b95b
...@@ -288,7 +288,7 @@ static void amd_mp2_clear_reg(struct amd_mp2_dev *privdata) ...@@ -288,7 +288,7 @@ static void amd_mp2_clear_reg(struct amd_mp2_dev *privdata)
static int amd_mp2_pci_init(struct amd_mp2_dev *privdata, static int amd_mp2_pci_init(struct amd_mp2_dev *privdata,
struct pci_dev *pci_dev) struct pci_dev *pci_dev)
{ {
int rc; int irq_flag = 0, rc;
pci_set_drvdata(pci_dev, privdata); pci_set_drvdata(pci_dev, privdata);
...@@ -311,17 +311,29 @@ static int amd_mp2_pci_init(struct amd_mp2_dev *privdata, ...@@ -311,17 +311,29 @@ static int amd_mp2_pci_init(struct amd_mp2_dev *privdata,
if (rc) if (rc)
goto err_dma_mask; goto err_dma_mask;
/* Set up intx irq */ /* request and enable interrupt */
writel(0, privdata->mmio + AMD_P2C_MSG_INTEN); writel(0, privdata->mmio + AMD_P2C_MSG_INTEN);
pci_intx(pci_dev, 1); rc = pci_alloc_irq_vectors(pci_dev, 1, 1, PCI_IRQ_ALL_TYPES);
rc = devm_request_irq(&pci_dev->dev, pci_dev->irq, amd_mp2_irq_isr, if (rc < 0) {
IRQF_SHARED, dev_name(&pci_dev->dev), privdata); dev_err(&pci_dev->dev, "Failed to allocate single IRQ err=%d\n", rc);
if (rc) goto err_dma_mask;
pci_err(pci_dev, "Failure requesting irq %i: %d\n", }
pci_dev->irq, rc);
privdata->dev_irq = pci_irq_vector(pci_dev, 0);
if (!pci_dev->msix_enabled && !pci_dev->msi_enabled)
irq_flag = IRQF_SHARED;
rc = devm_request_irq(&pci_dev->dev, privdata->dev_irq,
amd_mp2_irq_isr, irq_flag, dev_name(&pci_dev->dev), privdata);
if (rc) {
pci_err(pci_dev, "Failure requesting irq %i: %d\n", privdata->dev_irq, rc);
goto free_irq_vectors;
}
return rc; return rc;
free_irq_vectors:
free_irq(privdata->dev_irq, privdata);
err_dma_mask: err_dma_mask:
pci_clear_master(pci_dev); pci_clear_master(pci_dev);
err_pci_enable: err_pci_enable:
...@@ -364,7 +376,7 @@ static void amd_mp2_pci_remove(struct pci_dev *pci_dev) ...@@ -364,7 +376,7 @@ static void amd_mp2_pci_remove(struct pci_dev *pci_dev)
pm_runtime_forbid(&pci_dev->dev); pm_runtime_forbid(&pci_dev->dev);
pm_runtime_get_noresume(&pci_dev->dev); pm_runtime_get_noresume(&pci_dev->dev);
pci_intx(pci_dev, 0); free_irq(privdata->dev_irq, privdata);
pci_clear_master(pci_dev); pci_clear_master(pci_dev);
amd_mp2_clear_reg(privdata); amd_mp2_clear_reg(privdata);
......
...@@ -183,6 +183,7 @@ struct amd_mp2_dev { ...@@ -183,6 +183,7 @@ struct amd_mp2_dev {
struct mutex c2p_lock; struct mutex c2p_lock;
u8 c2p_lock_busid; u8 c2p_lock_busid;
unsigned int probed; unsigned int probed;
int dev_irq;
}; };
/* PCIe communication driver */ /* PCIe communication driver */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment