Thread (9 messages) 9 messages, 2 authors, 1d ago

Re: [PATCH 6/7] spmi: apple: use IRQ for RX FIFO if possible

From: Nick Chan <hidden>
Date: 2026-07-26 11:00:26
Also in: asahi, linux-devicetree, lkml


Sasha Finkelstein 於 2026/7/25 晚上9:48 寫道:
quoted hunk ↗ jump to hunk
From: Alba Mendez <redacted>

The IRQ fires as soon as the reply is available, which is usually takes
a few us instead of the 10ms sleep interval for polling

Signed-off-by: Alba Mendez <redacted>
Signed-off-by: Sasha Finkelstein <k@chaosmail.tech>
---
 drivers/spmi/spmi-apple-controller.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 96 insertions(+), 1 deletion(-)
diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c
index d8509f027df6..d627187b3ac0 100644
--- a/drivers/spmi/spmi-apple-controller.c
+++ b/drivers/spmi/spmi-apple-controller.c
[...]
quoted hunk ↗ jump to hunk
@@ -195,6 +277,7 @@ static int apple_spmi_probe(struct platform_device *pdev)
 
 	spmi = spmi_controller_get_drvdata(ctrl);
 	mutex_init(&spmi->fifo_lock);
+	init_completion(&spmi->fifo_rx);
 
 	spmi->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(spmi->regs))
@@ -206,11 +289,23 @@ static int apple_spmi_probe(struct platform_device *pdev)
 	ctrl->write_cmd = spmi_write_cmd;
 	ctrl->cmd = spmi_cmd;
 
+	irq = platform_get_irq_optional(pdev, 0);
+	if (irq < 0 && irq != -ENXIO)
+		return irq;
+	if (irq >= 0) {
+		ret = apple_spmi_init_irq(pdev, spmi, irq);
+		if (ret)
+			return ret;
+	}
+
 	ret = devm_spmi_controller_add(&pdev->dev, ctrl);
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret,
 				     "spmi_controller_add failed\n");
 
+	dev_dbg(&pdev->dev, irq >= 0 ? "Initialized with IRQ" :
+			"Initialized without IRQ, falling back to polling");
+
This does not compile with clang:

drivers/spmi/spmi-apple-controller.c:453:22: error: initializer element is not a compile-time constant
  453 |         dev_dbg(&pdev->dev, irq >= 0 ? "Initialized with IRQ" :
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  454 |                         "Initialized without IRQ, falling back to polling");
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 	return 0;
 }
 
Best Regards,
Nick Chan

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help