[PATCH 06/19] thunderbolt: Try reading host DROM from device tree first
Mika Westerberg
mika.westerberg at linux.intel.com
Tue Sep 1 01:48:02 PDT 2026
Hi,
On Sun, Aug 30, 2026 at 10:19:24PM +0200, Sven Peter wrote:
> 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
tb_drom_copy_property() - Copy DROM from ..
Ditto for the other kernel-doc comments. If it is static trivial function
you don't need to add them.
> */
> -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)
I think this should be split into two lines.
> {
> 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.
Like these, not really useful comments you can drop.
> + */
> +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