diff mbox series

[v4,7/8] i2c: amd-asf: Clear remote IRR bit to get successive interrupt

Message ID 20240911115407.1090046-8-Shyam-sundar.S-k@amd.com
State Changes Requested
Delegated to: Andi Shyti
Headers show
Series Introduce initial AMD ASF Controller driver support | expand

Commit Message

Shyam Sundar S K Sept. 11, 2024, 11:54 a.m. UTC
To ensure successive interrupts upon packet reception, it is necessary to
clear the remote IRR bit by writing the interrupt number to the EOI
register. The base address for this operation is provided by the BIOS and
retrieved by the driver by traversing the ASF object's namespace.

Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com>
Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
---
 drivers/i2c/busses/i2c-amd-asf-plat.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-amd-asf-plat.c b/drivers/i2c/busses/i2c-amd-asf-plat.c
index 65904fa895dd..c1b1846dd2b0 100644
--- a/drivers/i2c/busses/i2c-amd-asf-plat.c
+++ b/drivers/i2c/busses/i2c-amd-asf-plat.c
@@ -40,6 +40,7 @@ 
 static const char *amd_asf_port_name = " port 1";
 
 struct amd_asf_dev {
+	void __iomem *eoi_base;
 	struct device *dev;
 	struct i2c_adapter adap;
 	struct i2c_client *target;
@@ -288,11 +289,13 @@  static irqreturn_t amd_asf_irq_handler(int irq, void *ptr)
 		amd_asf_update_bits(piix4_smba, ASF_SLV_INTR, SMBHSTSTS, true);
 	}
 
+	iowrite32(irq, dev->eoi_base);
 	return IRQ_HANDLED;
 }
 
 static int amd_asf_probe(struct platform_device *pdev)
 {
+	resource_size_t eoi_addr, eoi_sz;
 	struct resource_entry *rentry;
 	struct amd_asf_dev *asf_dev;
 	struct acpi_device *adev;
@@ -327,6 +330,10 @@  static int amd_asf_probe(struct platform_device *pdev)
 		case IORESOURCE_IRQ:
 			irq = rentry->res->start;
 			break;
+		case IORESOURCE_MEM:
+			eoi_addr = rentry->res->start;
+			eoi_sz = resource_size(rentry->res);
+			break;
 		default:
 			dev_warn(&adev->dev, "Invalid ASF resource\n");
 			break;
@@ -346,6 +353,10 @@  static int amd_asf_probe(struct platform_device *pdev)
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret, "Unable to request irq: %d for use\n", irq);
 
+	asf_dev->eoi_base = devm_ioremap(&pdev->dev, eoi_addr, eoi_sz);
+	if (!asf_dev->eoi_base)
+		return dev_err_probe(&pdev->dev, -ENOMEM, "Invalid remapped address\n");
+
 	i2c_set_adapdata(&asf_dev->adap, asf_dev);
 	ret = i2c_add_adapter(&asf_dev->adap);
 	if (ret) {