[PATCH] mailbox: bcm2835: Add ACPI support for UEFI-booted Raspberry Pi 4

Steve Crawford posted 1 patch 11 hours ago
bcm2835-mailbox.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
[PATCH] mailbox: bcm2835: Add ACPI support for UEFI-booted Raspberry Pi 4
Posted by Steve Crawford 11 hours ago
On Raspberry Pi 4 booted via UEFI (e.g. using the pftf/RPi4 firmware),
the kernel enumerates devices via ACPI rather than the device tree. The
RPIQ mailbox device is already correctly described in the edk2-platforms
GpuDevs.asl with HID BCM2849, complete with MMIO and interrupt resources,
but the driver has no ACPI match table and therefore never binds.

Add an ACPI device ID table matching BCM2849, and replace the
DT-only irq_of_parse_and_map() call with platform_get_irq(), which
handles both DT and ACPI resource lookup transparently.

The existing DT path (brcm,bcm2835-mbox) is unchanged; this is a
purely additive change that has no effect on any boot path other than
UEFI+ACPI on RPi4.

Testing
-------
On Fedora CoreOS 44 (kernel 7.0.8-200.fc44.aarch64) booted via pftf/RPi4
UEFI v1.42, BCM2849:00 (the RPIQ mailbox device) is visible in ACPI but
unbound. Using driver_override to force-bind the unpatched driver
reproduces the exact failure this patch fixes:

  # echo bcm2835-mbox > /sys/bus/platform/devices/BCM2849:00/driver_override
  # echo BCM2849:00 > /sys/bus/platform/drivers/bcm2835-mbox/bind
  bcm2835-mbox BCM2849:00: error -EINVAL: request_irq(0) bcm2835_mbox_irq 0x0 BCM2849:00
  bcm2835-mbox BCM2849:00: Failed to register a mailbox IRQ handler: -22

irq_of_parse_and_map() returns 0 when dev->of_node is NULL (ACPI case).
platform_get_irq() correctly reads the interrupt from the ACPI _CRS
resources instead.

Signed-off-by: Steve Crawford <steve@crawford.dev>
---
 bcm2835-mailbox.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/bcm2835-mailbox.c b/bcm2835-mailbox.c
index ea12fb8..d450f3b 100644
--- a/bcm2835-mailbox.c
+++ b/bcm2835-mailbox.c
@@ -15,6 +15,7 @@
  *    https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
  */
 
+#include <linux/acpi.h>
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
 #include <linux/err.h>
@@ -24,7 +25,6 @@
 #include <linux/mailbox_controller.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
-#include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/spinlock.h>
 
@@ -144,7 +144,7 @@ static int bcm2835_mbox_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	spin_lock_init(&mbox->lock);
 
-	ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
+	ret = devm_request_irq(dev, platform_get_irq(pdev, 0),
 			       bcm2835_mbox_irq, IRQF_NO_SUSPEND, dev_name(dev),
 			       mbox);
 	if (ret) {
@@ -186,10 +186,24 @@ static const struct of_device_id bcm2835_mbox_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, bcm2835_mbox_of_match);
 
+static const struct acpi_device_id bcm2835_mbox_acpi_match[] = {
+	/*
+	 * BCM2849 is the ACPI HID for the RPi4 UEFI firmware's RPIQ mailbox
+	 * device (defined in GpuDevs.asl of the tianocore/edk2-platforms RPi4
+	 * platform). On UEFI-booted systems this device carries the correct
+	 * MMIO and interrupt resources, allowing the driver to bind via ACPI
+	 * rather than the device tree.
+	 */
+	{ "BCM2849", 0 },
+	{ }
+};
+MODULE_DEVICE_TABLE(acpi, bcm2835_mbox_acpi_match);
+
 static struct platform_driver bcm2835_mbox_driver = {
 	.driver = {
 		.name = "bcm2835-mbox",
 		.of_match_table = bcm2835_mbox_of_match,
+		.acpi_match_table = bcm2835_mbox_acpi_match,
 	},
 	.probe		= bcm2835_mbox_probe,
 };
-- 
2.54.0