[PATCH 06/19] thunderbolt: Try reading host DROM from device tree first
Sven Peter
sven at kernel.org
Sun Aug 30 13:19:24 PDT 2026
On Apple Silicon SoCs the DROM is provided by a device tree property.
Try reading from that property first.
Signed-off-by: Sven Peter <sven at kernel.org>
---
drivers/thunderbolt/eeprom.c | 32 +++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/drivers/thunderbolt/eeprom.c b/drivers/thunderbolt/eeprom.c
index 2a13fa6888ba..389de7df84f6 100644
--- a/drivers/thunderbolt/eeprom.c
+++ b/drivers/thunderbolt/eeprom.c
@@ -468,14 +468,14 @@ static void tb_switch_drom_free(struct tb_switch *sw)
}
/*
- * tb_drom_copy_efi - copy drom supplied by EFI to sw->drom if present
+ * tb_drom_copy_property - copy drom from a device property if present
*/
-static int tb_drom_copy_efi(struct tb_switch *sw, u16 *size)
+static int tb_drom_copy_property(struct tb_switch *sw, const char *name, u16 *size)
{
struct device *dev = sw->tb->nhi->dev;
int len, res;
- len = device_property_count_u8(dev, "ThunderboltDROM");
+ len = device_property_count_u8(dev, name);
if (len < 0 || len < sizeof(struct tb_drom_header))
return -EINVAL;
@@ -483,8 +483,7 @@ static int tb_drom_copy_efi(struct tb_switch *sw, u16 *size)
if (res)
return res;
- res = device_property_read_u8_array(dev, "ThunderboltDROM", sw->drom,
- len);
+ res = device_property_read_u8_array(dev, name, sw->drom, len);
if (res)
goto err;
@@ -500,6 +499,22 @@ static int tb_drom_copy_efi(struct tb_switch *sw, u16 *size)
return -EINVAL;
}
+/*
+ * tb_drom_copy_of_apple - copy drom supplied by the device tree for Apple Silicon to sw->drom.
+ */
+static int tb_drom_copy_of_apple(struct tb_switch *sw, u16 *size)
+{
+ return tb_drom_copy_property(sw, "apple,thunderbolt-drom", size);
+}
+
+/*
+ * tb_drom_copy_efi - copy drom supplied by EFI to sw->drom if present
+ */
+static int tb_drom_copy_efi(struct tb_switch *sw, u16 *size)
+{
+ return tb_drom_copy_property(sw, "ThunderboltDROM", size);
+}
+
static int tb_drom_copy_nvm(struct tb_switch *sw, u16 *size)
{
u16 drom_offset;
@@ -675,6 +690,13 @@ static int tb_drom_host_read(struct tb_switch *sw)
{
u16 size;
+ /*
+ * Apple Silicon machines always get their host DROM from the Device Tree,
+ * so make sure to try reading it first before any other method.
+ */
+ if (!tb_drom_copy_of_apple(sw, &size))
+ return tb_drom_parse(sw, size);
+
if (tb_switch_is_usb4(sw)) {
usb4_switch_read_uid(sw, &sw->uid);
if (!usb4_copy_drom(sw, &size))
--
2.55.0
More information about the linux-arm-kernel
mailing list