From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2727D2BFC8F; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=ppsfAxzQDRpkiDtorIhNawCvswpyQ5ZL1uB4GuSZO5E7uCQAGAHL3caV8yzK0vfPrlyPcgCPxxvrhPOAYVBqQnQ1Gv2tlLkawdALqw8sWjvihIteg6dokhqAmLk0a+ql2EY/u283UXgIR8b0SfcpbXIz4XiFav7tXPYVXb4uS2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=AM+uADRTsie5/REEheLPhgbwiWPLSEIpJ/A32xZhBDE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XiWGcYTkeYmn3MoM3OgsCeBG+DsS3BkWJ/2rMtBZeHpf1xCebqXxd1vWDUT4845xRSWPhG50MSeYRhcWhLkFMerJX4iM6SjbP2wHx/ZfU6SBG1qAfCeHPSiT0yc9m5Uo9/vIm1y8ihv0HFwjcPwF/BlWCWKsguMGiqJRZiJ9k/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IWn/pepg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IWn/pepg" Received: by smtp.kernel.org (Postfix) with ESMTPS id C369BC2BCFB; Sun, 30 Aug 2026 20:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121183; bh=AM+uADRTsie5/REEheLPhgbwiWPLSEIpJ/A32xZhBDE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IWn/pepgyYo0JXKFvZJneBbfzMIlaXqEXdcG76dca5SbUyXoqPjEcS0noCsRIZjUH 641FkhSqmmX34iDI88DS9URNqb7vXhXh/52MxULj+QYpdYcgm+5GZPzVcJqZE0W4/s D6DBOq/FjbXHJyowVhx8VQK/1hopnSSVfCOVz62gPwgAUNQ6PDlMXpcLIFlWIe8KhL wMRqXHlj9baCWK82XspGFYFMpUUrVzkaMM6UaAcoI7yF1ec7YkZLSRCM90AuWbyS+b addNxzzOxaUljDnbdF9Tqo9J7xyNFKAA+gdHBxFHAqVbf+fG8ggmbE5eiRCatLPIvU EEGg6CvJ6ql3g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4C56C61DE2; Sun, 30 Aug 2026 20:19:43 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:19 +0200 Subject: [PATCH 01/19] dt-bindings: usb: Add thunderbolt-switch property Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-1-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1068; i=sven@kernel.org; h=from:subject:message-id; bh=AM+uADRTsie5/REEheLPhgbwiWPLSEIpJ/A32xZhBDE=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCUHRPSviIt489LzkwM0pd0Fr586tWgtyjb2DWzveW ChM4gnrKGVhEONikBVTZNm+3970ycM3gks3XXoPM4eVCWQIAxenAExkuh3DX/G2G2avHrYoTJ7C +bRsRUKc/SFv/RiWGesK6rhuxTKm9jL89746k2XX7OdTNVyO3+1co37q7uyN4p9cT608FVHpKWX 7iwcA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 The USB4/Thunderbolt host routers on Apple Silicon SoCs require cable and mode details to be provided out-of-band by the Type-C port controller. Add a thunderbolt-switch property next to the existing orientation and mode switches which marks a node as handler of these notifications. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- Documentation/devicetree/bindings/usb/usb-switch.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/usb-switch.yaml b/Docume= ntation/devicetree/bindings/usb/usb-switch.yaml index f77731493dc4..5d125fbb252d 100644 --- a/Documentation/devicetree/bindings/usb/usb-switch.yaml +++ b/Documentation/devicetree/bindings/usb/usb-switch.yaml @@ -25,4 +25,10 @@ properties: description: Possible handler of SuperSpeed signals retiming type: boolean =20 + thunderbolt-switch: + description: + Possible handler of USB4/Thunderbolt host router activation and cable + information updates + type: boolean + additionalProperties: true --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2720B29E10B; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=RkB4aXpCTb5aw2RNophcOZ94ZzUEaLtT2JCk6zZrqC2Gd34apmlMcm5CPNij33dJfsE/STR+xEP/l9VkdOyEuuQaaEbeB64ynyGso0G+VHgsUT3TdFRqo6yIolcooz3w15obOrE+zP36wnchpAuKD0B6r07cS3Nt0QvzZ090+rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=Z/X9kjcmeLmtqycvOGjKq9M9vj51vtH8rcG6ltPIT9Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pT9AnnQcAJ8hSWL1dGzL1815Iyb8DTLqLfYTC4eDlvbKCQ6tOJWpP7rfLEmU98K9GzYLgbA+DupbHDd/8h4YVbV/AYzLkSoGui4TAhAgEOp7b8E/WRSaD8Hj7n8JTJfvuygtRzZg6ZveaH0RZoWvjs5BHJw7UPPA5BcLBPxR0Bg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RF+uFW4t; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RF+uFW4t" Received: by smtp.kernel.org (Postfix) with ESMTPS id D81ADC2BCFC; Sun, 30 Aug 2026 20:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=Z/X9kjcmeLmtqycvOGjKq9M9vj51vtH8rcG6ltPIT9Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=RF+uFW4tf/L0zt+C19M4sYzH7626tW0hv+gHHhbOIRNC2mH5C4I0GQHV4/dU80XkX FFJT+BfiwKJ/7scCKXUDgCK0YPHrjfnbbDWdEmLjeYwF0v9zRemWmlAOe+WqOivuVE O8TRa7jsrGX7kSM7wKbf6vHWhA5PHwwARDrwJp3WlAc4jmWKekZEHoeFGRKlAtYlm/ goseh2TQx5DCp0tX1xJrLGgPRBaEr7lxiPjTDuyeg7UtUXm+nlzIGAWeYHmKlmabDi spBWJ08OFx9d6pJZaOdVoyovA8TdfSjHicfzFQFXLHamEsQUA9t9lVOWPVVBwiU1g+ 74OTG64YFiExQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7AD7C61DEB; Sun, 30 Aug 2026 20:19:43 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:20 +0200 Subject: [PATCH 02/19] usb: typec: Add thunderbolt switch Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-2-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=12799; i=sven@kernel.org; h=from:subject:message-id; bh=Z/X9kjcmeLmtqycvOGjKq9M9vj51vtH8rcG6ltPIT9Y=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCcHWpgFB25RYyi/ki3/Rmyr4VZzhaqCdd7i6oYX6h J+hZVodpSwMYlwMsmKKLNv325s+efhGcOmmS+9h5rAygQxh4OIUgInor2NkeHe1JXxjx2XZCQym lyqtzx7VOPN00f+L64V3zq+e4RJl+piRYdsjictXytiuMm5/s2/m/blS9rm8DXfOZJX+D1JOmbV 9OzsA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 On Apple Silicon the USB4/Thunderbolt host router can only be brought up after the Type-C PHY has been configured and requires cable details known only to the Type-C port controller. The existing orientation switch only forwards the cable orientation. The mode switch also forwards most of the required details but represents devices which configure or route the Type-C signal path. The ACIO host router is a consumer of that path and has additional ordering requirements: it has to be started after the PHY has been configured and stopped again before the PHY is disabled. The mode switch code calls all handlers in the same order both when entering and leaving a mode and cannot express this reverse teardown order. Treating ACIO as another mode switch could therefore leave the NHI active after its PHY has been disabled, which can result in an asynchronous SError or a SoC watchdog reset. Add a separate Thunderbolt switch which Type-C port drivers can use to forward the negotiated Thunderbolt or USB4 cable details and explicitly order host router setup and teardown around the mode switch. This is similar to a USB role switch: each connection has exactly one host router and the callback controls the lifetime of that functional controller instead of configuring a signal mux. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/usb/typec/mux.c | 201 ++++++++++++++++++++++++++++++++++++++= ++++ drivers/usb/typec/mux.h | 12 +++ include/linux/usb/typec_mux.h | 114 ++++++++++++++++++++++++ 3 files changed, 327 insertions(+) diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index 9b908c46bd7d..8339846ba355 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -479,6 +479,207 @@ void *typec_mux_get_drvdata(struct typec_mux_dev *mux= _dev) } EXPORT_SYMBOL_GPL(typec_mux_get_drvdata); =20 +/* -----------------------------------------------------------------------= -- */ + +struct typec_thunderbolt_switch { + struct typec_thunderbolt_switch_dev *sw_dev; +}; + +static int thunderbolt_switch_fwnode_match(struct device *dev, + const void *fwnode) +{ + if (!is_typec_thunderbolt_switch_dev(dev)) + return 0; + + return device_match_fwnode(dev, fwnode); +} + +static void *typec_thunderbolt_switch_match(const struct fwnode_handle *fw= node, + const char *id, void *data) +{ + struct device *dev; + + if (id && !fwnode_property_present(fwnode, id)) + return NULL; + + dev =3D class_find_device(&typec_mux_class, NULL, fwnode, + thunderbolt_switch_fwnode_match); + + return dev ? to_typec_thunderbolt_switch_dev(dev) : + ERR_PTR(-EPROBE_DEFER); +} + +/** + * fwnode_typec_thunderbolt_switch_get - Find USB4/Thunderbolt switch + * @fwnode: The caller device node + * + * Finds a USB4/Thunderbolt switch linked with @fwnode. Returns a + * reference to the switch on success, NULL if no matching connection + * was found, or ERR_PTR(-EPROBE_DEFER) when a connection was found but + * the switch has not been enumerated yet. + */ +struct typec_thunderbolt_switch * +fwnode_typec_thunderbolt_switch_get(struct fwnode_handle *fwnode) +{ + struct typec_thunderbolt_switch_dev *sw_dev; + struct typec_thunderbolt_switch *sw; + void *match; + + match =3D fwnode_connection_find_match(fwnode, "thunderbolt-switch", NULL, + typec_thunderbolt_switch_match); + if (!match) + return NULL; + if (IS_ERR(match)) + return ERR_CAST(match); + sw_dev =3D match; + + sw =3D kzalloc_obj(*sw); + if (!sw) { + put_device(&sw_dev->dev); + return ERR_PTR(-ENOMEM); + } + + sw->sw_dev =3D sw_dev; + WARN_ON(!try_module_get(sw_dev->dev.parent->driver->owner)); + + return sw; +} +EXPORT_SYMBOL_GPL(fwnode_typec_thunderbolt_switch_get); + +/** + * typec_thunderbolt_switch_put - Release handle to USB4/Thunderbolt switch + * @sw: USB4/Thunderbolt switch + * + * Decrements the reference count of @sw and releases the handle. + */ +void typec_thunderbolt_switch_put(struct typec_thunderbolt_switch *sw) +{ + if (IS_ERR_OR_NULL(sw)) + return; + + module_put(sw->sw_dev->dev.parent->driver->owner); + put_device(&sw->sw_dev->dev); + kfree(sw); +} +EXPORT_SYMBOL_GPL(typec_thunderbolt_switch_put); + +/** + * typec_thunderbolt_switch_set - Forward cable details to USB4/Thunderbol= t switch + * @sw: USB4/Thunderbolt switch + * @data: Cable state and details + * + * Called by the Type-C port driver to forward the cable details + * out-of-band to the switch handler whenever a USB4/Thunderbolt + * connection comes up or goes away. + */ +int typec_thunderbolt_switch_set(struct typec_thunderbolt_switch *sw, + const struct typec_thunderbolt_switch_data *data) +{ + if (IS_ERR_OR_NULL(sw)) + return 0; + + return sw->sw_dev->set(sw->sw_dev, data); +} +EXPORT_SYMBOL_GPL(typec_thunderbolt_switch_set); + +static void typec_thunderbolt_switch_release(struct device *dev) +{ + kfree(to_typec_thunderbolt_switch_dev(dev)); +} + +const struct device_type typec_thunderbolt_switch_dev_type =3D { + .name =3D "thunderbolt_switch", + .release =3D typec_thunderbolt_switch_release, +}; + +/** + * typec_thunderbolt_switch_register - Register USB4/Thunderbolt switch + * @parent: Parent device + * @desc: USB4/Thunderbolt switch description + * + * This function registers a handler for USB4/Thunderbolt mode switching + * which Type-C port drivers use to forward the cable details once a + * USB4/Thunderbolt connection comes up. + */ +struct typec_thunderbolt_switch_dev * +typec_thunderbolt_switch_register(struct device *parent, + const struct typec_thunderbolt_switch_desc *desc) +{ + struct typec_thunderbolt_switch_dev *sw_dev; + int ret; + + if (!desc || !desc->set) + return ERR_PTR(-EINVAL); + + sw_dev =3D kzalloc_obj(*sw_dev); + if (!sw_dev) + return ERR_PTR(-ENOMEM); + + sw_dev->set =3D desc->set; + + device_initialize(&sw_dev->dev); + sw_dev->dev.parent =3D parent; + sw_dev->dev.fwnode =3D desc->fwnode; + sw_dev->dev.class =3D &typec_mux_class; + sw_dev->dev.type =3D &typec_thunderbolt_switch_dev_type; + sw_dev->dev.driver_data =3D desc->drvdata; + ret =3D dev_set_name(&sw_dev->dev, "%s-thunderbolt-switch", + desc->name ? desc->name : dev_name(parent)); + if (ret) { + put_device(&sw_dev->dev); + return ERR_PTR(ret); + } + + ret =3D device_add(&sw_dev->dev); + if (ret) { + dev_err(parent, "failed to register switch (%d)\n", ret); + put_device(&sw_dev->dev); + return ERR_PTR(ret); + } + + return sw_dev; +} +EXPORT_SYMBOL_GPL(typec_thunderbolt_switch_register); + +/** + * typec_thunderbolt_switch_unregister - Unregister USB4/Thunderbolt switch + * @sw_dev: USB4/Thunderbolt switch + * + * Unregister switch that was registered with + * typec_thunderbolt_switch_register(). + */ +void typec_thunderbolt_switch_unregister(struct typec_thunderbolt_switch_d= ev *sw_dev) +{ + if (!IS_ERR_OR_NULL(sw_dev)) + device_unregister(&sw_dev->dev); +} +EXPORT_SYMBOL_GPL(typec_thunderbolt_switch_unregister); + +/** + * typec_thunderbolt_switch_set_drvdata - Assign private data to the switch + * @sw_dev: USB4/Thunderbolt switch + * @data: Private data + */ +void typec_thunderbolt_switch_set_drvdata(struct typec_thunderbolt_switch_= dev *sw_dev, + void *data) +{ + dev_set_drvdata(&sw_dev->dev, data); +} +EXPORT_SYMBOL_GPL(typec_thunderbolt_switch_set_drvdata); + +/** + * typec_thunderbolt_switch_get_drvdata - Get the private data from the sw= itch + * @sw_dev: USB4/Thunderbolt switch + * + * Returns the private data previously assigned with + * typec_thunderbolt_switch_set_drvdata(). + */ +void *typec_thunderbolt_switch_get_drvdata(struct typec_thunderbolt_switch= _dev *sw_dev) +{ + return dev_get_drvdata(&sw_dev->dev); +} +EXPORT_SYMBOL_GPL(typec_thunderbolt_switch_get_drvdata); + const struct class typec_mux_class =3D { .name =3D "typec_mux", }; diff --git a/drivers/usb/typec/mux.h b/drivers/usb/typec/mux.h index 58f0f28b6dc8..a2c92cab1211 100644 --- a/drivers/usb/typec/mux.h +++ b/drivers/usb/typec/mux.h @@ -23,5 +23,17 @@ extern const struct device_type typec_mux_dev_type; =20 #define is_typec_switch_dev(dev) ((dev)->type =3D=3D &typec_switch_dev_typ= e) #define is_typec_mux_dev(dev) ((dev)->type =3D=3D &typec_mux_dev_type) +#define is_typec_thunderbolt_switch_dev(dev) \ + ((dev)->type =3D=3D &typec_thunderbolt_switch_dev_type) + +struct typec_thunderbolt_switch_dev { + struct device dev; + typec_thunderbolt_switch_set_fn_t set; +}; + +#define to_typec_thunderbolt_switch_dev(_dev_) \ + container_of(_dev_, struct typec_thunderbolt_switch_dev, dev) + +extern const struct device_type typec_thunderbolt_switch_dev_type; =20 #endif /* __USB_TYPEC_MUX__ */ diff --git a/include/linux/usb/typec_mux.h b/include/linux/usb/typec_mux.h index aa9ebb7e2fe0..0726407bb624 100644 --- a/include/linux/usb/typec_mux.h +++ b/include/linux/usb/typec_mux.h @@ -6,6 +6,7 @@ #include #include #include +#include =20 struct device; struct typec_mux; @@ -141,4 +142,117 @@ static inline struct typec_mux *typec_mux_get(struct = device *dev) return fwnode_typec_mux_get(dev_fwnode(dev)); } =20 +struct typec_thunderbolt_switch; +struct typec_thunderbolt_switch_dev; + +enum typec_thunderbolt_switch_state { + TYPEC_THUNDERBOLT_SWITCH_OFF, + TYPEC_THUNDERBOLT_SWITCH_TBT, + TYPEC_THUNDERBOLT_SWITCH_USB4, +}; + +/** + * struct typec_thunderbolt_switch_data - Type-C Thunderbolt/USB4 Switch D= ata + * @state: Switch state (TBT, USB4, or OFF) + * @orientation: Orientation of the connection + * @tbt: Thunderbolt 3 specific data, only valid in + * TYPEC_THUNDERBOLT_SWITCH_TBT + * @usb4: Enter_USB data, only valid in TYPEC_THUNDERBOLT_SWITCH_USB4 + */ +struct typec_thunderbolt_switch_data { + enum typec_thunderbolt_switch_state state; + enum typec_orientation orientation; + union { + struct typec_thunderbolt_data tbt; + struct enter_usb_data usb4; + }; +}; + +typedef int (*typec_thunderbolt_switch_set_fn_t)(struct typec_thunderbolt_= switch_dev *sw, + const struct typec_thunderbolt_switch_data *data); + +/** + * struct typec_thunderbolt_switch_desc - USB4/Thunderbolt switch descript= ion + * @fwnode: The fwnode the switch is associated with + * @set: Callback invoked with the cable details on connection changes + * @name: Optional switch name, the parent device name is used if not set + * @drvdata: Private data + */ +struct typec_thunderbolt_switch_desc { + struct fwnode_handle *fwnode; + typec_thunderbolt_switch_set_fn_t set; + const char *name; + void *drvdata; +}; + +#if IS_ENABLED(CONFIG_TYPEC) + +struct typec_thunderbolt_switch * +fwnode_typec_thunderbolt_switch_get(struct fwnode_handle *fwnode); +void typec_thunderbolt_switch_put(struct typec_thunderbolt_switch *sw); +int typec_thunderbolt_switch_set(struct typec_thunderbolt_switch *sw, + const struct typec_thunderbolt_switch_data *data); + +struct typec_thunderbolt_switch_dev * +typec_thunderbolt_switch_register(struct device *parent, + const struct typec_thunderbolt_switch_desc *desc); +void typec_thunderbolt_switch_unregister(struct typec_thunderbolt_switch_d= ev *sw); + +void typec_thunderbolt_switch_set_drvdata(struct typec_thunderbolt_switch_= dev *sw, + void *data); +void * +typec_thunderbolt_switch_get_drvdata(struct typec_thunderbolt_switch_dev *= sw); + +#else + +static inline struct typec_thunderbolt_switch * +fwnode_typec_thunderbolt_switch_get(struct fwnode_handle *fwnode) +{ + return NULL; +} + +static inline void +typec_thunderbolt_switch_put(struct typec_thunderbolt_switch *sw) +{ +} + +static inline int +typec_thunderbolt_switch_set(struct typec_thunderbolt_switch *sw, + const struct typec_thunderbolt_switch_data *data) +{ + return 0; +} + +static inline struct typec_thunderbolt_switch_dev * +typec_thunderbolt_switch_register(struct device *parent, + const struct typec_thunderbolt_switch_desc *desc) +{ + return ERR_PTR(-EOPNOTSUPP); +} + +static inline void +typec_thunderbolt_switch_unregister(struct typec_thunderbolt_switch_dev *s= w) +{ +} + +static inline void +typec_thunderbolt_switch_set_drvdata(struct typec_thunderbolt_switch_dev *= sw, + void *data) +{ +} + +static inline void * +typec_thunderbolt_switch_get_drvdata(struct typec_thunderbolt_switch_dev *= sw) +{ + return NULL; +} + +#endif /* CONFIG_TYPEC */ + +static inline struct typec_thunderbolt_switch * +typec_thunderbolt_switch_get(struct device *dev) +{ + return fwnode_typec_thunderbolt_switch_get(dev_fwnode(dev)); +} + #endif /* __USB_TYPEC_MUX */ --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33DE73033E3; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=WTpQpIZEnRwT7DUw1/as6+vX0BqljP/qNyigkGUZNWq5m2C9Ax8i3bf1mPKS3sO4V3aJmeJhP4IKEmpM32WIAF/mzG+wEVaVN1FFsZBDUxQCGYn/7QkGW7wfE7QSCcEnmlUK90QbUnReU1yp1WzSsYJsI8tICpu3eDIsmSJHYJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=q5r1Np3eUnTrcGkauW7sWKDIVR3AiUTcYWTLnTecjRk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cZOyfRNS0YlfGfnB06oMh85ZB7opDUd+alCUOQII/umAiJJfQYTnei+kU2BclKBB2fnTW+0pho8S5GfBoQ22wZ6T8gUkTG1IcbISXY46Q7rHn37JGbMC32NxB+r5aTiwBhINf8YQmRoFaDSEpThIpEN/DjphwE/5OjESs0HBCV4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A/0hoQqM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A/0hoQqM" Received: by smtp.kernel.org (Postfix) with ESMTPS id E69C6C2BD00; Sun, 30 Aug 2026 20:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=q5r1Np3eUnTrcGkauW7sWKDIVR3AiUTcYWTLnTecjRk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=A/0hoQqMWvuDHEBCBUQfEehc/0HPvx1YdDvn1Pe3wJRJgr7IIIkd7pyXIz7rpHf8+ HhjqeA3tpxGqsRgMomY0JCexiuhPocIx7rgHQuF/MBhjTs4VI2521K/c/YsuawJ3s1 OTYsuQyvvrwvwJiA4bZOSRXSPu+lhRwhcPwIsjmBZtn5VmSHPwrAnxO1ZaS3f/mMnQ 1/QzEawK0X+QnWQd1OVekrA/VmIY6L65lcTtWX2SA9pN+Yxv+CExUIYuFVTgLGY0vr Sci12T4FnhBwU0Bsaoghsw1IHx8NM6kmyi00WXRvBQkodioPzIvf9plYnNIMJCP5sO zQs6CxL2ioo2g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8542C61DE1; Sun, 30 Aug 2026 20:19:43 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:21 +0200 Subject: [PATCH 03/19] usb: typec: tipd: Hook up Thunderbolt switch for CD321x Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-3-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5456; i=sven@kernel.org; h=from:subject:message-id; bh=q5r1Np3eUnTrcGkauW7sWKDIVR3AiUTcYWTLnTecjRk=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCcEvz8Zqf/RaeGPtVz3fzT37LhzIDzx/7okus8bvZ rM/a9itO0pZGMS4GGTFFFm277c3ffLwjeDSTZfew8xhZQIZwsDFKQAT2S3B8Jvt8rrFP/3YZKd6 zJme18FY+uiBcf2mqjmJdQFubg+UuxYwMnQV3U8OTAtjz5IzcoqU3JwielmIabrcoY+/DJOy1y4 qZwQA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Look up the Thunderbolt switch for CD321x ports and forward cable details whenever a Thunderbolt or USB4 connection comes up or goes away. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/usb/typec/tipd/core.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 522f56742aa9..5016f9dba956 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -216,6 +216,8 @@ struct cd321x { struct typec_mux *mux; struct typec_mux_state state; =20 + struct typec_thunderbolt_switch *tbt_switch; + struct cd321x_status update_status; struct delayed_work update_work; struct usb_pd_identity cur_partner_identity; @@ -677,6 +679,9 @@ static void tps6598x_handle_plug_event(struct tps6598x = *tps, u32 status) static void cd321x_typec_update_mode(struct tps6598x *tps, struct cd321x_s= tatus *st) { struct cd321x *cd321x =3D container_of(tps, struct cd321x, tps); + struct typec_thunderbolt_switch_data tbt_switch_data =3D { + .state =3D TYPEC_THUNDERBOLT_SWITCH_OFF, + }; =20 if (!(st->data_status & TPS_DATA_STATUS_DATA_CONNECTION)) { if (cd321x->state.mode =3D=3D TYPEC_STATE_SAFE) @@ -684,6 +689,7 @@ static void cd321x_typec_update_mode(struct tps6598x *t= ps, struct cd321x_status cd321x->state.alt =3D NULL; cd321x->state.mode =3D TYPEC_STATE_SAFE; cd321x->state.data =3D NULL; + typec_thunderbolt_switch_set(cd321x->tbt_switch, &tbt_switch_data); typec_mux_set(cd321x->mux, &cd321x->state); } else if (st->data_status & TPS_DATA_STATUS_DP_CONNECTION) { struct typec_displayport_data dp_data; @@ -723,6 +729,7 @@ static void cd321x_typec_update_mode(struct tps6598x *t= ps, struct cd321x_status cd321x->state.alt =3D cd321x->port_altmode_dp; cd321x->state.data =3D &dp_data; cd321x->state.mode =3D mode; + typec_thunderbolt_switch_set(cd321x->tbt_switch, &tbt_switch_data); typec_mux_set(cd321x->mux, &cd321x->state); } else if (st->data_status & TPS_DATA_STATUS_TBT_CONNECTION) { struct typec_thunderbolt_data tbt_data; @@ -738,6 +745,13 @@ static void cd321x_typec_update_mode(struct tps6598x *= tps, struct cd321x_status cd321x->state.mode =3D TYPEC_TBT_MODE; cd321x->state.data =3D &tbt_data; typec_mux_set(cd321x->mux, &cd321x->state); + + tbt_switch_data.state =3D TYPEC_THUNDERBOLT_SWITCH_TBT; + tbt_switch_data.tbt =3D tbt_data; + tbt_switch_data.orientation =3D TPS_STATUS_TO_UPSIDE_DOWN(st->status) ? + TYPEC_ORIENTATION_REVERSE : + TYPEC_ORIENTATION_NORMAL; + typec_thunderbolt_switch_set(cd321x->tbt_switch, &tbt_switch_data); } else if (st->data_status & CD321X_DATA_STATUS_USB4_CONNECTION) { struct enter_usb_data eusb_data; =20 @@ -752,12 +766,20 @@ static void cd321x_typec_update_mode(struct tps6598x = *tps, struct cd321x_status cd321x->state.data =3D &eusb_data; cd321x->state.mode =3D TYPEC_MODE_USB4; typec_mux_set(cd321x->mux, &cd321x->state); + + tbt_switch_data.state =3D TYPEC_THUNDERBOLT_SWITCH_USB4; + tbt_switch_data.usb4 =3D eusb_data; + tbt_switch_data.orientation =3D TPS_STATUS_TO_UPSIDE_DOWN(st->status) ? + TYPEC_ORIENTATION_REVERSE : + TYPEC_ORIENTATION_NORMAL; + typec_thunderbolt_switch_set(cd321x->tbt_switch, &tbt_switch_data); } else { if (cd321x->state.alt =3D=3D NULL && cd321x->state.mode =3D=3D TYPEC_STA= TE_USB) return; cd321x->state.alt =3D NULL; cd321x->state.mode =3D TYPEC_STATE_USB; cd321x->state.data =3D NULL; + typec_thunderbolt_switch_set(cd321x->tbt_switch, &tbt_switch_data); typec_mux_set(cd321x->mux, &cd321x->state); } =20 @@ -771,6 +793,9 @@ static void cd321x_update_work(struct work_struct *work) struct cd321x, update_work); struct tps6598x *tps =3D &cd321x->tps; struct cd321x_status st; + struct typec_thunderbolt_switch_data tbt_switch_data =3D { + .state =3D TYPEC_THUNDERBOLT_SWITCH_OFF, + }; =20 guard(mutex)(&tps->lock); =20 @@ -821,6 +846,7 @@ static void cd321x_update_work(struct work_struct *work) =20 /* If there was a disconnection, set PHY to off */ if (!new_connected || was_disconnected) { + typec_thunderbolt_switch_set(cd321x->tbt_switch, &tbt_switch_data); cd321x->state.alt =3D NULL; cd321x->state.mode =3D TYPEC_STATE_SAFE; cd321x->state.data =3D NULL; @@ -1328,6 +1354,12 @@ cd321x_register_port(struct tps6598x *tps, struct fw= node_handle *fwnode) goto err_unregister_altmodes; } =20 + cd321x->tbt_switch =3D fwnode_typec_thunderbolt_switch_get(fwnode); + if (IS_ERR(cd321x->tbt_switch)) { + ret =3D PTR_ERR(cd321x->tbt_switch); + goto err_unregister_mux; + } + cd321x->state.alt =3D NULL; cd321x->state.mode =3D TYPEC_STATE_SAFE; cd321x->state.data =3D NULL; @@ -1335,6 +1367,9 @@ cd321x_register_port(struct tps6598x *tps, struct fwn= ode_handle *fwnode) =20 return 0; =20 +err_unregister_mux: + typec_mux_put(cd321x->mux); + cd321x->mux =3D NULL; err_unregister_altmodes: typec_unregister_altmode(cd321x->port_altmode_dp); typec_unregister_altmode(cd321x->port_altmode_tbt); @@ -1356,6 +1391,8 @@ cd321x_unregister_port(struct tps6598x *tps) { struct cd321x *cd321x =3D container_of(tps, struct cd321x, tps); =20 + typec_thunderbolt_switch_put(cd321x->tbt_switch); + cd321x->tbt_switch =3D NULL; typec_mux_put(cd321x->mux); cd321x->mux =3D NULL; typec_unregister_altmode(cd321x->port_altmode_dp); --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33D6F2EEE66; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=PQNbAPjdKsAFLWDaJdpE1jqYBFbgDq3HMy9EXK+f2r764+CyUvWtsH04p9bfoOQqCSPQNMFPBNX4SvptOArHFPgIW//7GMEBIW86cO8VZQb8fbM7V0PJRnwEAgrnshunxVSJEciepU4H/oIe+gk82O5CTvmcy6MRQUDOERLd5rc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=ST4ik3WBagvYGb9odthpBturzioGl2ubZbVZscCANes=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o0VWLuueh2qy86Mkpesfn4I7mK+3yEqHJBWrN4jVRQRqtn7doGcWTfoiABnLDBfUgWpOheITCe756fW+2vh9GW8Aunif8TR6U3YZQQ6T9EbqUAr2axn305PeI/paXJ3baVlT/D8xxFSJ6eNpnx/5AVCa3LrbclQhNCR4qFPWNZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=il+834lR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="il+834lR" Received: by smtp.kernel.org (Postfix) with ESMTPS id F0DF0C2BD05; Sun, 30 Aug 2026 20:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=ST4ik3WBagvYGb9odthpBturzioGl2ubZbVZscCANes=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=il+834lR+fWeOP4pJPPnSK6EDG91BxP5ko5nafIyH7USSuZl9kwerhiSFA6APWiIO PCdmAgG6lQVahHs8iYNWXB0VmoEPx7qu3ZEwoRRIkZJQqGvQ2YqfpuipCRAkCaTaWv xDeMNTYvcTsuaEafMnf8s3uC01WMPs4aXnqKoM8obnc1yrgA9Ws0ZV+kKlvKyciJ1Z 3jbaqIN5GVBV9WEMH0kY+B4jsstBIBQTqV5Fm3cLEbO4sM7HYp8lV+KfKZpQG1BUmi IUHlA4sA7ke1n2TXRrMNHQHLbRkLb3Qa+CcCK1yeeMlphO/HhQDwUlvYfEoe8TJl76 CAQImfT+Gp6qg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA0EEC61DF1; Sun, 30 Aug 2026 20:19:43 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:22 +0200 Subject: [PATCH 04/19] dt-bindings: thunderbolt: Add Apple USB4/Thunderbolt NHI Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-4-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6395; i=sven@kernel.org; h=from:subject:message-id; bh=ST4ik3WBagvYGb9odthpBturzioGl2ubZbVZscCANes=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCSEBrgwKebrpG/+knlBjvKEQsijsQnr6Me4rogLlM /6+DWjpKGVhEONikBVTZNm+3970ycM3gks3XXoPM4eVCWQIAxenAEzkZTfD/4zUd9GLIzY+Znz1 wFnrxf49lxcm73i47Qfz1YOS15pEOK0Y/ru/Nnrv5OPcFmm+9Pe5g4X3WD6vWve9YvnyN1NjWWJ +P+YFAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 The Native Host Interface (NHI) provides the TX and RX rings used by the software connection manager on Apple Silicon SoCs. The NHI is part of the ACIO host router and is exposed to the main SoC bus while the ACIO co-processor is running. T6000 and T6020 use one DART stream for the TX and RX control rings and one shared by all other rings, which are used for XDomain connections. This likely improves the isolation of those host-to-host connections. The M3 generation uses a slightly insane set of 24 IOMMU entries. These are probably one DART stream for each TX and RX ring. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- .../bindings/thunderbolt/apple,t8103-usb4-nhi.yaml | 151 +++++++++++++++++= ++++ MAINTAINERS | 2 + 2 files changed, 153 insertions(+) diff --git a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4= -nhi.yaml b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-= nhi.yaml new file mode 100644 index 000000000000..a80c8db3ef51 --- /dev/null +++ b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-nhi.ya= ml @@ -0,0 +1,151 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/thunderbolt/apple,t8103-usb4-nhi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Silicon USB4/Thunderbolt Native Host Interface (NHI) + +maintainers: + - Sven Peter + +description: | + On Apple Silicon SoCs the Native Host Interface (NHI) is part of the ACIO + host router. It provides the transmit and receive rings used by the soft= ware + connection manager. + + The ACIO co-processor exposes its registers to the main SoC bus while it= is + running. The NHI is therefore represented as a child of the ACIO node. + +properties: + compatible: + oneOf: + - const: apple,t8103-usb4-nhi + - items: + - enum: + - apple,t6000-usb4-nhi + - apple,t6020-usb4-nhi + - apple,t6030-usb4-nhi + - apple,t6031-usb4-nhi + - apple,t8112-usb4-nhi + - apple,t8122-usb4-nhi + - const: apple,t8103-usb4-nhi + + reg: + items: + - description: NHI registers with the transmit and receive rings + - description: + Protocol Defined Field (PDF) bitmasks selecting which frames are + accepted by each receive ring + + reg-names: + items: + - const: nhi + - const: pdf + + interrupts: + description: + One interrupt for each of the 12 transmit rings followed by one for = each + of the 12 receive rings. + maxItems: 24 + + interrupt-names: + items: + - const: txring0 + - const: txring1 + - const: txring2 + - const: txring3 + - const: txring4 + - const: txring5 + - const: txring6 + - const: txring7 + - const: txring8 + - const: txring9 + - const: txring10 + - const: txring11 + - const: rxring0 + - const: rxring1 + - const: rxring2 + - const: rxring3 + - const: rxring4 + - const: rxring5 + - const: rxring6 + - const: rxring7 + - const: rxring8 + - const: rxring9 + - const: rxring10 + - const: rxring11 + + iommus: + minItems: 1 + maxItems: 24 + description: | + T8103 and T8112 use a single IOMMU for all DMA transactions. + + T6000 and T6020 use two IOMMUs: The first is used for transmit ring 0 + and receive ring 0 which carry control traffic. The second is shared= by + all other rings which are only used for XDomain connections to other + hosts. + + T6030, T6031 and T8122 use 24 IOMMUs. These are most likely one DART + stream for each of the 12 transmit and 12 receive rings. + + apple,thunderbolt-drom: + $ref: /schemas/types.yaml#/definitions/uint8-array + description: + DROM of the host router built by the bootloader from Apple's Device = Tree. + + apple,tunable-nhi: + $ref: /schemas/types.yaml#/definitions/uint32-matrix + items: + items: + - description: Register offset + - description: Mask of bits to clear + - description: Bits to set + description: | + List of (register offset, mask, value) tuples copied from Apple's De= vice + Tree, converted by the bootloader and used to configure the NHI after + the co-processor has booted. + +required: + - compatible + - reg + - reg-names + - interrupts + - interrupt-names + - iommus + - apple,thunderbolt-drom + +allOf: + - if: + properties: + compatible: + contains: + enum: + - apple,t6030-usb4-nhi + - apple,t6031-usb4-nhi + - apple,t8122-usb4-nhi + then: + properties: + iommus: + minItems: 24 + maxItems: 24 + else: + if: + properties: + compatible: + contains: + enum: + - apple,t6000-usb4-nhi + - apple,t6020-usb4-nhi + then: + properties: + iommus: + minItems: 2 + maxItems: 2 + else: + properties: + iommus: + maxItems: 1 + +additionalProperties: false diff --git a/MAINTAINERS b/MAINTAINERS index 3a19da74d00c..bb26036a043f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2658,6 +2658,7 @@ F: Documentation/devicetree/bindings/rtc/apple,smc-rt= c.yaml F: Documentation/devicetree/bindings/soc/apple/apple,t6000-pmgr-misc.yaml F: Documentation/devicetree/bindings/spi/apple,spi.yaml F: Documentation/devicetree/bindings/spmi/apple,spmi.yaml +F: Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-nhi.yaml F: Documentation/devicetree/bindings/usb/apple,dwc3.yaml F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml F: Documentation/hwmon/macsmc-hwmon.rst @@ -27215,6 +27216,7 @@ L: linux-usb@vger.kernel.org S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt.g= it F: Documentation/admin-guide/thunderbolt.rst +F: Documentation/devicetree/bindings/thunderbolt/ F: drivers/thunderbolt/ F: include/linux/thunderbolt.h =20 --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5733B31D372; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=c6k+Fq+UrOJumV+DpC71mlWW9JTJzvl+fvuY41qbDg2RqZ4asNhvKlzckluz7u/nj4G/0n25aQIbdK/Yuf7L0lByaRVnyjnCfzPgJtnT7fpDgjZK5fjKpW0eL6EhFP2P4D4GKedH5a9Caps254DmUWd55dVfc4gSChOaXZzqyI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=tjxsHzXTSsJGx+EfH2qJRLAdmYE7SAoNp4PmvauEOec=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RlWR1O3JtaDTvOi2br2xqUAu+PVY7U3hc44fdHwk/mGhkTLxDWm+cXfADhhk+t7uK1K8F6TQD5br3Xh5B9v/07TIjhQ4EF5LsCYajohBZ7OXnYc0VZSH/Fu9VMLNPwEyVUgi7Z53Jn0BVoZumFQnkbuOG2Je/4HwNIM4XnKziyI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mEh5rxgD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mEh5rxgD" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0AF35C2BCFF; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=tjxsHzXTSsJGx+EfH2qJRLAdmYE7SAoNp4PmvauEOec=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mEh5rxgDOtC9CeKG+awJFTf51F20/qpzbhsdGPQPC88cfXCi4Zw6jyS3R9UQU1z3V 4DA34FThfWQwga2vuwMjhUPoJjhwvoo0kBBs2wSTtnAKcg8wFAPf0DDMTyJGe3cBDZ SL25SWU/tveAJLkLmJ6+lmWhM+xkJPrx1mIBYo1w6IhyJz9YjOu32S3gbJDUfCLglI lpJmOD+JDBLpahUXRtNCtfYHCwIW1iQ+1ZXWvSBEycuFdKdBl13XhpjbwsFMv7O20u qhqU9+bzhLJcBGw6OJ4305JPxjvS1A7ZXwnfckhzcy++liRL7fAhsi/sG/78O5mwz/ YuAWvdeskxJZw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9AC8C61DF0; Sun, 30 Aug 2026 20:19:43 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:23 +0200 Subject: [PATCH 05/19] dt-bindings: thunderbolt: Add Apple USB4/Thunderbolt ACIO block Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-5-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8972; i=sven@kernel.org; h=from:subject:message-id; bh=tjxsHzXTSsJGx+EfH2qJRLAdmYE7SAoNp4PmvauEOec=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCaF5yfpN3tqnmvafevRP/9rbFbrzO+UVxOYxLG6Zu OTvxdlGHaUsDGJcDLJiiizb99ubPnn4RnDppkvvYeawMoEMYeDiFICJJE9mZHjHzWt0d/5Ua+vQ u9s+fYxumzlt+oU9Ez4smHTl+54EZvZfDP8DBAU2B3fbzu1f3+TQuMBgyfa/8yc9TtRVnJw69d5 ly0pmAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Each Type-C port with USB4/Thunderbolt support on Apple Silicon SoCs comes with block called ACIO ("Apple Converged I/O"). It contains a Cortex-M3 co-processor, the hardware blocks implementing the USB4 host router, the Native Host Interface (NHI) and a DART IOMMU. The co-processor exposes the NHI and its DART to the main SoC bus while it is running. ACIO can only be powered on after the Type-C PHY has been switched to USB4/Thunderbolt mode. The Type-C controller provides the cable information required to boot it through the thunderbolt-switch connection. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- .../thunderbolt/apple,t8103-usb4-acio.yaml | 218 +++++++++++++++++= ++++ MAINTAINERS | 1 + 2 files changed, 219 insertions(+) diff --git a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4= -acio.yaml b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4= -acio.yaml new file mode 100644 index 000000000000..38496ce31d20 --- /dev/null +++ b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.y= aml @@ -0,0 +1,218 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/thunderbolt/apple,t8103-usb4-acio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple Silicon USB4/Thunderbolt Host Router (ACIO) + +maintainers: + - Sven Peter + +description: | + Each Type-C port with USB4/Thunderbolt support on Apple Silicon SoCs has= a + host router complex called ACIO (Apple Converged I/O). It contains a + Cortex-M3 co-processor, the hardware blocks implementing the USB4 router + and its PCIe, USB3 and DisplayPort adapters. + + The co-processor exposes the Native Host Interface (NHI) and its DART IO= MMU + to the main SoC bus once it is running. They are therefore represented as + child nodes. All child registers are located in a single 16 MiB MMIO win= dow + and use addresses relative to this window. + + ACIO can only be powered on after the Type-C PHY has been switched to + USB4/Thunderbolt mode. Before the connection to the remote device can be + established the Type-C PD controller has to pass the cable information + through the thunderbolt-switch connection. + +properties: + compatible: + oneOf: + - const: apple,t8103-usb4-acio + - items: + - enum: + - apple,t6000-usb4-acio + - apple,t6020-usb4-acio + - apple,t6030-usb4-acio + - apple,t6031-usb4-acio + - apple,t8112-usb4-acio + - apple,t8122-usb4-acio + - const: apple,t8103-usb4-acio + + reg: + items: + - description: Root complex and co-processor control registers + - description: SRAM used for communication with the co-processor + + reg-names: + items: + - const: rc + - const: sram + + mboxes: + maxItems: 1 + description: Mailbox used for RTKit communication with the co-processor + + resets: + maxItems: 1 + description: Reset used to start the ACIO block before booting the + co-processor + + power-domains: + maxItems: 3 + + thunderbolt-switch: true + + apple,tunable-rc: + $ref: /schemas/types.yaml#/definitions/uint32-matrix + items: + items: + - description: Register offset + - description: Mask of bits to clear + - description: Bits to set + description: | + List of (register offset, mask, value) tuples copied from Apple's De= vice + Tree, converted by the bootloader and used to configure the root com= plex + after the co-processor has booted. + + '#address-cells': + const: 1 + + '#size-cells': + const: 1 + + ranges: + maxItems: 1 + description: Single 16 MiB MMIO window containing all child registers + + nonposted-mmio: true + + ports: + $ref: /schemas/graph.yaml#/properties/ports + description: + OF graph ports for the USB4 router. The port numbers correspond to t= he + USB4 router adapter numbers. + properties: + port@1: + $ref: /schemas/graph.yaml#/properties/port + description: USB4 port connected to the USB Type-C connector + + # port@2 is the second, unused USB4 port of the host router + + port@3: + $ref: /schemas/graph.yaml#/properties/port + description: PCIe adapter + + port@4: + $ref: /schemas/graph.yaml#/properties/port + description: USB3 adapter + + port@5: + $ref: /schemas/graph.yaml#/properties/port + description: First DP IN adapter + + port@6: + $ref: /schemas/graph.yaml#/properties/port + description: Second DP IN adapter + + required: + - port@1 + + iommu@a80000: + $ref: /schemas/iommu/apple,dart.yaml# + description: DART IOMMU exposed by ACIO and used for DMA from the NHI + + nhi@f00000: + $ref: /schemas/thunderbolt/apple,t8103-usb4-nhi.yaml# + description: Native Host Interface exposed by ACIO + +required: + - compatible + - reg + - reg-names + - mboxes + - power-domains + - resets + - thunderbolt-switch + - '#address-cells' + - '#size-cells' + - ranges + - nonposted-mmio + - ports + - iommu@a80000 + - nhi@f00000 + +allOf: + - $ref: /schemas/usb/usb-switch.yaml# + +additionalProperties: false + +examples: + - | + soc { + #address-cells =3D <2>; + #size-cells =3D <2>; + + cio@501ac0000 { + compatible =3D "apple,t8103-usb4-acio"; + reg =3D <0x5 0x01ac0000 0x0 0xc000>, + <0x5 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + ranges =3D <0x0 0x5 0x01000000 0x1000000>; + #address-cells =3D <1>; + mboxes =3D <&usb4_1_mbox>; + nonposted-mmio; + pinctrl-0 =3D <&acio1_pins>; + pinctrl-names =3D "default"; + power-domains =3D <&ps_atc1_cio>, + <&ps_atc1_cio_pcie>, + <&ps_atc1_cio_usb>; + resets =3D <&cio_reset 1>; + #size-cells =3D <1>; + thunderbolt-switch; + + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + port@1 { + reg =3D <1>; + + endpoint { + remote-endpoint =3D <&typec1_con_tbt>; + }; + }; + }; + + usb4_1_dart: iommu@a80000 { + compatible =3D "apple,t8103-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D <1 890 4>; + #iommu-cells =3D <1>; + }; + + nhi@f00000 { + compatible =3D "apple,t8103-usb4-nhi"; + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + interrupt-parent =3D <&aic>; + interrupts =3D <1 863 4>, <1 864 4>, <1 865 4>, <1 866 4>, + <1 867 4>, <1 868 4>, <1 869 4>, <1 870 4>, + <1 871 4>, <1 872 4>, <1 873 4>, <1 874 4>, + <1 875 4>, <1 876 4>, <1 877 4>, <1 878 4>, + <1 879 4>, <1 880 4>, <1 881 4>, <1 882 4>, + <1 883 4>, <1 884 4>, <1 885 4>, <1 886 4>; + interrupt-names =3D "txring0", "txring1", "txring2", "txri= ng3", + "txring4", "txring5", "txring6", "txring= 7", + "txring8", "txring9", "txring10", "txrin= g11", + "rxring0", "rxring1", "rxring2", "rxring= 3", + "rxring4", "rxring5", "rxring6", "rxring= 7", + "rxring8", "rxring9", "rxring10", "rxrin= g11"; + iommus =3D <&usb4_1_dart 1>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index bb26036a043f..c2c6e4541da7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2658,6 +2658,7 @@ F: Documentation/devicetree/bindings/rtc/apple,smc-rt= c.yaml F: Documentation/devicetree/bindings/soc/apple/apple,t6000-pmgr-misc.yaml F: Documentation/devicetree/bindings/spi/apple,spi.yaml F: Documentation/devicetree/bindings/spmi/apple,spmi.yaml +F: Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml F: Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-nhi.yaml F: Documentation/devicetree/bindings/usb/apple,dwc3.yaml F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AAC131E106; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=D1oJsk8+t5Y+kbkc2YasMnqBZHxugCsee10uqJ3PpkuyR0Xa3df1emot+Xs3LZuI7qHsfjCLgV7mr+HxnwS1lV5g9P+wlDhlSshpIIqnIoT2ZZu2REMszEeYSCv2rqx7302cVfY+oqfmLoM1sjz+oWe9tVdBQFVBFpCUQAsW5Bk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=qXUPQQ+/YlgdXuqv7U2bExUuKkk0IWuRWSMGsGl9d24=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JPbBVUvy26poFDyw8LyFPkdpHSX0Sgyf7XXpTZwf7HzbaN61t1VBLkTTi//RkURbilGjImDvqR/PFarNMG1fN/OH0X/AjZ57xmigUt93hWe2XZiKFMRr9BpPDk9X7L8pi2XQU3TGXwLwlQpOvt8otkAK6TVqPMYVJxS603ZFkMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GJ0jFGFt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GJ0jFGFt" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1CA4FC4AF18; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=qXUPQQ+/YlgdXuqv7U2bExUuKkk0IWuRWSMGsGl9d24=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GJ0jFGFt/PDWF0Vso1akAhRp5S0U3a/6YdJBpeuK9uOHHRsQF6Pw3wbmRPznEORtI 7iRs/vL6bqNf46PdArQ7S2dc3kJDcAss63lKbX5OjbH2xZ66k8sxeBgrX0XTpoY1sv XCvQJDPNmD7Sf8AIeivcxcZG/DuAGSAp4p+Wp0LmAvuNrPvB6n2+5o04dtaDNGwmcg tu/Q//YPMOO3bxnA4MhTF3b/cJGBAEE+ReyTAbGWjHUQVtMmvF+Ror0+IcNqJyQCGX D4zi4kYD+HptSB/5IVActGtN835TVp1Ilsd4I/E4zjijnug55SZTi9Cwm+K+8aO3za H4ic72sWbPUVw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04B11C61DD9; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:24 +0200 Subject: [PATCH 06/19] thunderbolt: Try reading host DROM from device tree first Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-6-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2537; i=sven@kernel.org; h=from:subject:message-id; bh=qXUPQQ+/YlgdXuqv7U2bExUuKkk0IWuRWSMGsGl9d24=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCaGOM/MNwkOWxbjxvMyYGvCJ007Rps1QtLpU8XVbr +iKws8dpSwMYlwMsmKKLNv325s+efhGcOmmS+9h5rAygQxh4OIUgIlcWs/I0O0jy9rxdsmdfYG+ P+wuW8XIsHxscl7sKPuz7nfr3NWdMxn+V4sKilw9qjK/6NWzyc6fn67OeVP/MrHp742Ii4ku5RV pzAA= X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 On Apple Silicon SoCs the DROM is provided by a device tree property. Try reading from that property first. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- 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) } =20 /* - * 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, u= 16 *size) { struct device *dev =3D sw->tb->nhi->dev; int len, res; =20 - len =3D device_property_count_u8(dev, "ThunderboltDROM"); + len =3D device_property_count_u8(dev, name); if (len < 0 || len < sizeof(struct tb_drom_header)) return -EINVAL; =20 @@ -483,8 +483,7 @@ static int tb_drom_copy_efi(struct tb_switch *sw, u16 *= size) if (res) return res; =20 - res =3D device_property_read_u8_array(dev, "ThunderboltDROM", sw->drom, - len); + res =3D device_property_read_u8_array(dev, name, sw->drom, len); if (res) goto err; =20 @@ -500,6 +499,22 @@ static int tb_drom_copy_efi(struct tb_switch *sw, u16 = *size) return -EINVAL; } =20 +/* + * 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; =20 + /* + * 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)) --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68972321420; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=Xs2pxRmIt2gVrS62hWZNrCmcxtJdWZNAqeiDQB01CjgMSEVZRC2FVaqcmKQFKqmJs9qLhv1kGFzPw+AvrfSFB+0GvHIgpGaGP17ECemiGRKiD2VxEAGPuCwYxOqUnKVepZkav3vyidW39NAXAJJh4/vX81Egp0mQR3zBReQTRYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=dVz3sxP5vavj12E7kkybYYbfTtTMRNdpjA2Sq4nGu8k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Np7ucnQTyN3iXcKkne+ElqrZpKranVHww67YMtFMqJ1LLJtJ036JRz5i6kehQsVqcM43V1QyhXIcey+TRDobdk2P/U0HYLa8XzZIh6Ch8t3JBfUdn+KG5uxdWCavA0Aeiy8BFXAH7Wg3+WU7UcOxoaAkSLlZlKy/1C0VToZDglk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tXu80ghK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tXu80ghK" Received: by smtp.kernel.org (Postfix) with ESMTPS id 37033C32781; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=dVz3sxP5vavj12E7kkybYYbfTtTMRNdpjA2Sq4nGu8k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tXu80ghK4IRb1eEhdtZ2u6/bPoKAg/xirRKLAxmWVNlHXTeTKfUoxV+cCJ/PSf4Hi Fpxt3QT7lnhQOswOKVw+hmj77dJ8wI3U3Zi4PcRU65AX6cdYoLclMmvrD9jPOq6x3P 2JPYIeB8FnrOIHNrYqbbI8IYNaXWuUe6vYMTRxs/FeOhe+Own5rsHuayz7Jg+Jx4dU hxWrfuSJCbS1wLsHhiOgp9XggsMVYo75DwubcQYK82SA6ikPHMfa4JOCxVnrdDuGe1 UedLxqZM/aLAihWWkf5lzsci7yJVT/oZzsCLzyGiP07agQBdtLXejAaVJEEE4ZOWXb uGMf/FhocN21g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22A9EC61DE2; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:25 +0200 Subject: [PATCH 07/19] thunderbolt: Don't read the UID if we already know it Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-7-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1132; i=sven@kernel.org; h=from:subject:message-id; bh=dVz3sxP5vavj12E7kkybYYbfTtTMRNdpjA2Sq4nGu8k=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCWEHI31Y/sqHXRNsDqvs+ZK+//CSLoNZ3yborZ/m0 LNIRXhNRykLgxgXg6yYIsv2/famTx6+EVy66dJ7mDmsTCBDGLg4BWAi8m8YGZZb1coYeZ/ee7gz 89ENte74xapOrX4blglPYVm4Jv2S7FFGhu1hJ8TmxivM+X1t03/nT41XLbRuWt77xti2857VNfV wLWYA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 On Apple Silicon the host router's UID comes from the DROM provided by the device tree and is already known by the time tb_switch_set_uuid() runs. Skip reading it from the config space again in that case. For other USB4 hosts this only drops a duplicate read because tb_drom_host_read() has already filled in the UID from ROUTER_CS_7 before tb_switch_set_uuid() runs. Device routers keep reading it unconditionally. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/thunderbolt/switch.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 404c0693df50..3f54a5ae56b0 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -2692,9 +2692,11 @@ static int tb_switch_set_uuid(struct tb_switch *sw) return 0; =20 if (tb_switch_is_usb4(sw)) { - ret =3D usb4_switch_read_uid(sw, &sw->uid); - if (ret) - return ret; + if (tb_route(sw) || !sw->uid) { + ret =3D usb4_switch_read_uid(sw, &sw->uid); + if (ret) + return ret; + } uid =3D true; } else { /* --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 703CC322B9F; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=LH+lRiXHxD2AieGyJcFySkhIwNHWu6TQOyVcuuetjxfBZd9rdzEhwukH8h8DTTOXDidAS5nyeq8Izk1n0AfFIRxHnDwoS8PCDisf3iMXGYvdquMIZpja7/W5OxE+tEsCziRTadkbRlOr8RJhQL2cHYQO2gCpDWaWPylcMoJMyAo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=RpEpSG63+tBPZuuziz+1veWy6ZIV0qRqo8PjvUS8qJs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E33gYWCL5A9NmpvHSDOVlBjhp1vBkIsU9OywmtvN74BDxraibn5h4I8djP6HUx4QRkNOqdFgaVGzLtsOhNU2u222Pnay2xRgUbNuD5Z3A+PhQ1EHI1i8D+1Nm5d3/jWr2K0Bnpwe6s3/UcNt4umg9BUJ9yZHYz2vYpnebmoqtsM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=keqJbrtc; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="keqJbrtc" Received: by smtp.kernel.org (Postfix) with ESMTPS id 470E3C2BCC7; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=RpEpSG63+tBPZuuziz+1veWy6ZIV0qRqo8PjvUS8qJs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=keqJbrtc1W0IGsWsGuMtDEPAgCFasm1ak2z5Yzbyh/rYOE52V2eItWA2GvodyGU8y XHmcQdjDfXdC6CWk3Qgun4kfC0SPLpdt4Yx71Kz8x9AK14mqiVBlr3WMaea9u61vD/ HijDFiZabt0of9qfxAfNmA0QibG3R3UlDdbgdyyrxLanlmlzCCKQfPokHRXBIbcMwA wNIvb/auxQqfEpYHYaHzhZ4mUMGHDw8ud8l3HSxDr4KW4r0xHFC3T+AZMhYHhRWNC8 6YXiYz0FOVuBfv/Ei4EMBINNZJJEBQbQ+Ognhd/K3HV2mQBgO+Ja4gKqVevIQMCpaw FtOA/Xjx6h5ag== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33164C61DF1; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:26 +0200 Subject: [PATCH 08/19] thunderbolt: Allocate ring HopID before requesting the ring interrupt Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-8-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1852; i=sven@kernel.org; h=from:subject:message-id; bh=RpEpSG63+tBPZuuziz+1veWy6ZIV0qRqo8PjvUS8qJs=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCWFH0ybf7Lx1kkX1xuxVUnppiybwLvoz38XszI9pW TkLDu7N7ShlYRDjYpAVU2TZvt/e9MnDN4JLN116DzOHlQlkCAMXpwBM5HInw//IjU/LvuZpb8n7 e7b74Q2+SStY3r/VkJl00EdH/NmFoyuVGP4KHOjh/ms74xn3jHMz/WZ3TXsUY5fvWbby6CedzfL 966fyAgA= X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 The Apple NHI has one interrupt per ring and request_ring_irq picks it based on ring->hop which is still -1 at this point for rings allocated with an automatic HopID. Allocate the HopID first and release it again if the interrupt request fails. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/thunderbolt/nhi.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 5809809f64d4..6a97dcd57deb 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -534,6 +534,16 @@ static int nhi_alloc_hop(struct tb_nhi *nhi, struct tb= _ring *ring) return ret; } =20 +static void nhi_free_hop(struct tb_nhi *nhi, struct tb_ring *ring) +{ + guard(spinlock_irq)(&nhi->lock); + + if (ring->is_tx) + nhi->tx_rings[ring->hop] =3D NULL; + else + nhi->rx_rings[ring->hop] =3D NULL; +} + static struct tb_ring *tb_ring_alloc(struct tb_nhi *nhi, u32 hop, int size, bool transmit, unsigned int flags, int e2e_tx_hop, u16 sof_mask, u16 eof_mask, @@ -581,19 +591,18 @@ static struct tb_ring *tb_ring_alloc(struct tb_nhi *n= hi, u32 hop, int size, if (!ring->descriptors) goto err_free_ring; =20 + if (nhi_alloc_hop(nhi, ring)) + goto err_free_descs; + if (!(flags & RING_FLAG_NO_INTERRUPT) && nhi->ops->request_ring_irq) { if (nhi->ops->request_ring_irq(ring, flags & RING_FLAG_NO_SUSPEND)) - goto err_free_descs; + goto err_free_hop; } =20 - if (nhi_alloc_hop(nhi, ring)) - goto err_release_msix; - return ring; =20 -err_release_msix: - if (nhi->ops->release_ring_irq) - nhi->ops->release_ring_irq(ring); +err_free_hop: + nhi_free_hop(nhi, ring); err_free_descs: dma_free_coherent(ring->nhi->dev, ring->size * sizeof(*ring->descriptors), --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84B5B325485; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=VeNCEWLkZ6ODRjwPlJ2UiblvjoP+FRXwx+D/FsSuCEfpR98LQhAe4goxbRGpyUOUMHZvEXXOzzACMqnNeNo6+RkX3Gy5Q6HsQytmLZYoxf/lCw/AscWgnlxpHFO49UyoE6FKepN5bU4+Qa6O/HZf3FHjWJJQWhVvXLmjxhDZMyo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=1cPwquxnKSbuoBJPbanbJjkiYHF/+0xe5BCBfQyNjww=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gyU/ZQohe00WR3nzdMdJP5+XZS24PYsrFHr6bsTI64+sXZPiBi675zdVyJsQ4LwBIf4KFu39iIyhUDE5kG2lJySVVg67yf+wnZJZ64y0Iq0FI9WwGZ5H91OeRACu+ZKC3Sn7+7XKO3RzOsgrHxkVo3ErL4rhCM7zTC8FWsVClUc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WA4Z78v4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WA4Z78v4" Received: by smtp.kernel.org (Postfix) with ESMTPS id 57210C2BCF4; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=1cPwquxnKSbuoBJPbanbJjkiYHF/+0xe5BCBfQyNjww=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WA4Z78v4jSBkyJlmKU2/kg3MAu27qVGsivq7BEHHuQNn2rkhRubjrHeZSnGVoo0lQ 0+jmQ/lto39ZIe7gJ0R6hp1ss3ohD2xA5iud+5F4AI0c9tsK2jfLquDjziTB+klPcC OKGmi5NudOWF1JqwPaQGhffyRHnLwpg76LjlzNZTA/0KT0N60l5hhMc6nHCOjblXEz dpdPXb+KJTxNAkJ7LN9kREiEP+QEe9A6wOullnz7OeRq7xXkWw62sA/EBphk4Y1YhJ 486nsMWByrHeVrzh2re+isw0By8mywEY1+A+kWLM6GHRxSruymcBkw5ahkHtWilBgI oEUotZhOrZWfw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44B59C61DF0; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:27 +0200 Subject: [PATCH 09/19] thunderbolt: Add ring_interrupt_active to tb_nhi_ops Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-9-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2793; i=sven@kernel.org; h=from:subject:message-id; bh=1cPwquxnKSbuoBJPbanbJjkiYHF/+0xe5BCBfQyNjww=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCeFL7j7fKCksv/POF1Un1f3SbnIRLtvnmzyUaEgye WC8ZXZcRykLgxgXg6yYIsv2/famTx6+EVy66dJ7mDmsTCBDGLg4BWAiqk0M/wsXub5d2LPFX8T0 9ZPCe6/DHhztLGNevdnQaan6B8Z3Dz4x/C948nxbwIFPfhcSuQ/J7rJ1Wxr//F7q3a+6N33dN22 PX8cHAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 The Apple NHI enables and disables ring interrupts differently. Add an optional tb_nhi_ops hook to override ring_interrupt_active which falls back to the standard USB4 method when it is not set. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/thunderbolt/nhi.c | 12 ++++++++++-- drivers/thunderbolt/nhi.h | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 6a97dcd57deb..fc54ff7edfb9 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -149,6 +149,14 @@ static void ring_interrupt_active(struct tb_ring *ring= , bool active) nhi_mask_interrupt(ring->nhi, mask, index); } =20 +static void nhi_ring_interrupt_active(struct tb_ring *ring, bool active) +{ + if (ring->nhi->ops->ring_interrupt_active) + ring->nhi->ops->ring_interrupt_active(ring, active); + else + ring_interrupt_active(ring, active); +} + /* * nhi_disable_interrupts() - disable interrupts for all rings * @@ -724,7 +732,7 @@ void tb_ring_start(struct tb_ring *ring) } =20 if (!(ring->flags & RING_FLAG_NO_INTERRUPT)) - ring_interrupt_active(ring, true); + nhi_ring_interrupt_active(ring, true); ring->running =3D true; err: spin_unlock(&ring->lock); @@ -785,7 +793,7 @@ void tb_ring_stop(struct tb_ring *ring) goto err; } if (!(ring->flags & RING_FLAG_NO_INTERRUPT)) - ring_interrupt_active(ring, false); + nhi_ring_interrupt_active(ring, false); =20 ring_iowrite32options(ring, 0, 0); ring_iowrite64desc(ring, 0, 0); diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h index f72d6b274501..4884c3f5a2b2 100644 --- a/drivers/thunderbolt/nhi.h +++ b/drivers/thunderbolt/nhi.h @@ -52,6 +52,9 @@ extern const struct dev_pm_ops nhi_pm_ops; * @post_nvm_auth: hook to run after Thunderbolt 3 NVM authentication * @request_ring_irq: NHI specific interrupt retrieval hook * @release_ring_irq: NHI specific interrupt release hook + * @ring_interrupt_active: NHI specific hook to activate/deactivate the + * interrupt of a single ring. If not set the + * standard USB4 NHI registers are used. * @is_present: Whether the device is currently present on the parent bus * @init_interrupts: NHI specific interrupt initialization hook * @reset_interface: Resets the host interface @@ -67,6 +70,7 @@ struct tb_nhi_ops { void (*post_nvm_auth)(struct tb_nhi *nhi); int (*request_ring_irq)(struct tb_ring *ring, bool no_suspend); void (*release_ring_irq)(struct tb_ring *ring); + void (*ring_interrupt_active)(struct tb_ring *ring, bool active); bool (*is_present)(struct tb_nhi *nhi); int (*init_interrupts)(struct tb_nhi *nhi); void (*reset_interface)(struct tb_nhi *nhi); --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A42F3264CF; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=YFayaru6QaYy1Vq2A+oqNiDLabCyY5dMYtTPajm4er+fxfC7VnxknHsN2Qr9G5tZsq4DdLPwb4QGw0HjEq8Y+WkOoLo0y7HTfpLEvOyDLFK0AcSQRkr6/kDbH2+z4G2LDmGJtoAP/aXdYdUMnavGKtJO6rafk8ylZgUF/4Y3Sw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=5XX7FpDBpIyvJfx+M3LmY3siJAf3LFS0+gQqxSzs9eQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pj0SWL1i1OfBe9bUpGE5DBxRjfzDfTt1UBQskKEfjw6+aotRpbXiygKWBBM7/oN4FG089mWD9IcYSneMW9a62ZCUNkZZLPCezifEZuCo0paCxK4GOT47UmOWxsImaqAim5+qq9BXevsEL6J10nbmD5hNEV1cyX19C7LtV6LdGAU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VzO2/9BC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VzO2/9BC" Received: by smtp.kernel.org (Postfix) with ESMTPS id 663F6C2BD00; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=5XX7FpDBpIyvJfx+M3LmY3siJAf3LFS0+gQqxSzs9eQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VzO2/9BCbD0HayC+lwIiI5cb2upvxMlSY/WL/8cFVNpDTkz8IVDoA2rwM5HzPrw0o TRp1ogue9EibcxGcYXyjQeVH4H6+KfPg5IW6UmHLmCI1FyAP5j9n4W+Kuzlf8Ofh23 UMil8d8IUfcBRCw1xRZ26+n7quqJS8VZN0Wfw1XgXw5FWEbZJPsX+MFnlhplCszSyj dV1H9rDNS+EWXJ1vtGaAyGg42KTvwO4plIAq7a23rwDNn7eCx9RLzE2lcH1lt1LgKu SmXq/MpWiVzuEEKgx9zZDdsojiH+8fowQbNbY+MxdixJ5iE/sDchcbg50Pm+80y0sx 27H6i+w3GNsuA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53EDFC61DD9; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:28 +0200 Subject: [PATCH 10/19] thunderbolt: Make the ring register layout configurable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-10-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4811; i=sven@kernel.org; h=from:subject:message-id; bh=5XX7FpDBpIyvJfx+M3LmY3siJAf3LFS0+gQqxSzs9eQ=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCeHxR9omvpN+LLff5LeTgbhkdt65J7JRi/o3F3qqv hONCnjUUcrCIMbFICumyLJ9v73pk4dvBJduuvQeZg4rE8gQBi5OAZhITTvDH95VrWt0Ncu/1atW 3lD8MslyX9Tt6mkhduePLLxx+Mi1TxKMDH+VAq0cZH+Z9b2K21erMOHT+6n3ehqssj0FLq3Y9GC qKAMA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 The ring descriptor and options registers are laid out differently on the Apple NHI. Describe their offsets and strides with a tb_nhi_ring_layout struct that NHI drivers can override. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/thunderbolt/nhi.c | 30 ++++++++++++++++++++++++------ drivers/thunderbolt/nhi.h | 18 ++++++++++++++++++ include/linux/thunderbolt.h | 3 +++ 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index fc54ff7edfb9..3a3d334e69fd 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -176,19 +176,32 @@ void nhi_disable_interrupts(struct tb_nhi *nhi) =20 /* ring helper methods */ =20 +static const struct tb_nhi_ring_layout nhi_default_ring_layout =3D { + .tx_desc_base =3D REG_TX_RING_BASE, + .rx_desc_base =3D REG_RX_RING_BASE, + .desc_stride =3D 16, + .tx_options_base =3D REG_TX_OPTIONS_BASE, + .rx_options_base =3D REG_RX_OPTIONS_BASE, + .options_stride =3D 32, +}; + static void __iomem *ring_desc_base(struct tb_ring *ring) { + const struct tb_nhi_ring_layout *layout =3D ring->nhi->ring_layout; void __iomem *io =3D ring->nhi->iobase; - io +=3D ring->is_tx ? REG_TX_RING_BASE : REG_RX_RING_BASE; - io +=3D ring->hop * 16; + + io +=3D ring->is_tx ? layout->tx_desc_base : layout->rx_desc_base; + io +=3D ring->hop * layout->desc_stride; return io; } =20 static void __iomem *ring_options_base(struct tb_ring *ring) { + const struct tb_nhi_ring_layout *layout =3D ring->nhi->ring_layout; void __iomem *io =3D ring->nhi->iobase; - io +=3D ring->is_tx ? REG_TX_OPTIONS_BASE : REG_RX_OPTIONS_BASE; - io +=3D ring->hop * 32; + + io +=3D ring->is_tx ? layout->tx_options_base : layout->rx_options_base; + io +=3D ring->hop * layout->options_stride; return io; } =20 @@ -215,8 +228,10 @@ static void ring_iowrite32desc(struct tb_ring *ring, u= 32 value, u32 offset) =20 static void ring_iowrite64desc(struct tb_ring *ring, u64 value, u32 offset) { - iowrite32(value, ring_desc_base(ring) + offset); - iowrite32(value >> 32, ring_desc_base(ring) + offset + 4); + void __iomem *base =3D ring_desc_base(ring); + + iowrite32(value, base + offset); + iowrite32(value >> 32, base + offset + 4); } =20 static void ring_iowrite32options(struct tb_ring *ring, u32 value, u32 off= set) @@ -1253,6 +1268,9 @@ int nhi_probe(struct tb_nhi *nhi) if (!nhi->ops->init_interrupts) return dev_err_probe(dev, -EINVAL, "missing required NHI ops\n"); =20 + if (!nhi->ring_layout) + nhi->ring_layout =3D &nhi_default_ring_layout; + nhi->hop_count =3D ioread32(nhi->iobase + REG_CAPS) & 0x3ff; dev_dbg(dev, "total paths: %d\n", nhi->hop_count); =20 diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h index 4884c3f5a2b2..035cee433a3c 100644 --- a/drivers/thunderbolt/nhi.h +++ b/drivers/thunderbolt/nhi.h @@ -40,6 +40,24 @@ void nhi_reset_interface(struct tb_nhi *nhi); =20 extern const struct dev_pm_ops nhi_pm_ops; =20 +/** + * struct tb_nhi_ring_layout - Layout of the ring registers in the NHI MMI= O space + * @tx_desc_base: Offset of the descriptor registers of the first TX ring + * @rx_desc_base: Offset of the descriptor registers of the first RX ring + * @desc_stride: Stride between the descriptor registers of neighboring ri= ngs + * @tx_options_base: Offset of the options registers of the first TX ring + * @rx_options_base: Offset of the options registers of the first RX ring + * @options_stride: Stride between the options registers of neighboring ri= ngs + */ +struct tb_nhi_ring_layout { + u32 tx_desc_base; + u32 rx_desc_base; + u32 desc_stride; + u32 tx_options_base; + u32 rx_options_base; + u32 options_stride; +}; + /** * struct tb_nhi_ops - NHI specific optional operations * @init: NHI specific initialization diff --git a/include/linux/thunderbolt.h b/include/linux/thunderbolt.h index d48623fda79b..7c2717bd2945 100644 --- a/include/linux/thunderbolt.h +++ b/include/linux/thunderbolt.h @@ -503,6 +503,8 @@ void tb_service_properties_changed(struct tb_service *s= vc); * interrupt_work when dispatching interrupts to individual rings. * @dev: Device associated with this NHI instance * @ops: NHI specific optional ops + * @ring_layout: Layout of the ring registers inside @iobase. If not set + * the default layout from the USB4 specification is used. * @iobase: MMIO space of the NHI * @tx_rings: All Tx rings available on this host controller * @rx_rings: All Rx rings available on this host controller @@ -524,6 +526,7 @@ struct tb_nhi { spinlock_t lock; struct device *dev; const struct tb_nhi_ops *ops; + const struct tb_nhi_ring_layout *ring_layout; void __iomem *iobase; struct tb_ring **tx_rings; struct tb_ring **rx_rings; --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0624327C0D; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=uuSvbe3gvvO/zyaQerEKasT9Fzs91awE4UyspTYhKXJqJ10YmjFj3Bo0ftHmJM9vDnFR/wftLpWh0WLXGlhNxErbGeeb1BWc5eAlFeRriFj9E3QdL0ugg8gXWPACXvKA+Gzc4CHM8ixT2B2eLRFAZ/prpkp4GjzMxHO8Ws6bZ7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=fHahmFpaRK/QzRyP/N5khiYGfLDf/FCodhzsWEEVc74=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lI0/2BDoYGDusR/s7b5DxBiSYC6ytnLkumV0I0jotF9cMejCBMbRtJdjtybmaHtvO8VJnXCqwIGU8q9S72gomUe7faTfrLl/9fCRj0a93gPR26IAzQI9RelOcznALEBKbZahlFbjFHkBkEO9LxBkoQRVK1dWPmun3xU85OTYOIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QLL+W8SC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QLL+W8SC" Received: by smtp.kernel.org (Postfix) with ESMTPS id 76ACDC4AF12; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=fHahmFpaRK/QzRyP/N5khiYGfLDf/FCodhzsWEEVc74=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QLL+W8SCtbzHLmaWH8f9mhQ0np6S+9YeNXAi9MxCsIo4aCDulu68bxTHGK/IyvyJZ CAwL8nbPK4bNs1dsmL2z2xd2KvvwujBWfWdlQDOZp/Ry5TePMTIX0a3xWVZjkAGxnR ebRqMW7mA/v1IrzjI2/YkbqgB+NuQ9cHpoUkoqlZZuUCrSTiGQ6SlLV+irQfK190KA 7K/FS2JY+F/m2vYsQMSnJyekqwqDc23+RB3aMpCgxVH+lIH9bKIAOpGnBPGg6zt2Cg eMU1r5ctzw8g/uTbrCUqIsTb/lFYnrlveXpmq+qly0o2VPi67qDQkxPytIXDZC10rD r8hgLEOioMzLw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63826C61DF1; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:29 +0200 Subject: [PATCH 11/19] thunderbolt: Add ring_interrupt_mask to tb_nhi_ops Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-11-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2828; i=sven@kernel.org; h=from:subject:message-id; bh=fHahmFpaRK/QzRyP/N5khiYGfLDf/FCodhzsWEEVc74=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCREWl/bNOCe1Y6lknuKLLfMeyczdwRo/J/XDc7/WQ JttQpphHaUsDGJcDLJiiizb99ubPnn4RnDppkvvYeawMoEMYeDiFICJMMsxMvycsSqXo/5Zxowv eysPF+u5nXs4XXn68aOddXuVKj/zsvxg+GewNcWrJz2kzevG0+CIpuXb53BNqj54WHCn5apPpRu fSDMAAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Masking ring interrupts works differently on the Apple NHI as well. Add an optional tb_nhi_ops hook for it which falls back to the standard USB4 NHI method when it is not set. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/thunderbolt/nhi.c | 12 ++++++++++-- drivers/thunderbolt/nhi.h | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 3a3d334e69fd..3cb69deec63e 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -422,6 +422,14 @@ static void __ring_interrupt_mask(struct tb_ring *ring= , bool mask) iowrite32(val, ring->nhi->iobase + reg); } =20 +static void nhi_ring_interrupt_mask(struct tb_ring *ring, bool mask) +{ + if (ring->nhi->ops->ring_interrupt_mask) + ring->nhi->ops->ring_interrupt_mask(ring, mask); + else + __ring_interrupt_mask(ring, mask); +} + /* Both @nhi->lock and @ring->lock should be held */ static void __ring_interrupt(struct tb_ring *ring) { @@ -429,7 +437,7 @@ static void __ring_interrupt(struct tb_ring *ring) return; =20 if (ring->start_poll) { - __ring_interrupt_mask(ring, true); + nhi_ring_interrupt_mask(ring, true); ring->start_poll(ring->poll_data); } else { schedule_work(&ring->work); @@ -450,7 +458,7 @@ void tb_ring_poll_complete(struct tb_ring *ring) spin_lock_irqsave(&ring->nhi->lock, flags); spin_lock(&ring->lock); if (ring->start_poll) - __ring_interrupt_mask(ring, false); + nhi_ring_interrupt_mask(ring, false); spin_unlock(&ring->lock); spin_unlock_irqrestore(&ring->nhi->lock, flags); } diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h index 035cee433a3c..5f70d7ddc2e2 100644 --- a/drivers/thunderbolt/nhi.h +++ b/drivers/thunderbolt/nhi.h @@ -73,6 +73,9 @@ struct tb_nhi_ring_layout { * @ring_interrupt_active: NHI specific hook to activate/deactivate the * interrupt of a single ring. If not set the * standard USB4 NHI registers are used. + * @ring_interrupt_mask: NHI specific hook to mask/unmask the interrupt of= a + * single ring. If not set the standard USB4 NHI + * registers are used. * @is_present: Whether the device is currently present on the parent bus * @init_interrupts: NHI specific interrupt initialization hook * @reset_interface: Resets the host interface @@ -89,6 +92,7 @@ struct tb_nhi_ops { int (*request_ring_irq)(struct tb_ring *ring, bool no_suspend); void (*release_ring_irq)(struct tb_ring *ring); void (*ring_interrupt_active)(struct tb_ring *ring, bool active); + void (*ring_interrupt_mask)(struct tb_ring *ring, bool mask); bool (*is_present)(struct tb_nhi *nhi); int (*init_interrupts)(struct tb_nhi *nhi); void (*reset_interface)(struct tb_nhi *nhi); --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA27F32B9BB; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=mYS4WbwS5qwi8Bjne8VRy+aakbE+iqCElGPMM6o0deHMSWuSxqE2rrmW7uYJBXFsYpDcAgGRU7v+OP1yE9IAGh9Bem+iA2EVgc1WR+HSHb+lUwbmwWLuvUOiWc7+AD8tDuFdopufS9uZtkKte20DZP4N2byY52Rzx4xCdCdxn7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=bjN1NTiSvc6/6RtUd8MUWugBmdf1TrTNf6e7OfieaZY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=C/IgSbFaqSeWkP5X5XiSgHevy/DBrWMfSjNFZght65Nxy3e90k7PQVPd+dHakMuk+IhO0MxS9GdEj6Zzqiu+3fFddAieXkxmq6WKbYWSVbzEM04090fRwjK6YlUvpeBbuFWb8O+8Txr0LIYfsVAJrRag9DS3HD84NHpMwJ45daA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sBxHG/y7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sBxHG/y7" Received: by smtp.kernel.org (Postfix) with ESMTPS id 89811C4AF1C; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=bjN1NTiSvc6/6RtUd8MUWugBmdf1TrTNf6e7OfieaZY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=sBxHG/y7+E6JC7LuaiPSJ3+NeCFvwKHwGCYuO2NElXJW51LmYeeI2VWtc+Wxd/s1w lrsePCkLTtOaHx/zK3tmlDyY8IJnsyEcIhDxi1rFm6tY90GEgg29s46bAWW0QMj8Fx JFgssiWQ0Hm3o6o1Dq41kpj9WUPXqMJz8uv22C25lzOCOAEGSDh9BnDCY2XhNV+7K3 +x6RdT4WEhTM5S2pleBs1xoS8UvUmGJu6NveMHcb0+lqI+uD/3k13pYh9mYFSmuBM2 VePDeOxdLA7EO41zQZNgXKvA/l01ZClbrEKCVvnp59JRE8SFZab52GbTaHZzWWSXT1 Mro23Qhv6mVaw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73059C61DE2; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:30 +0200 Subject: [PATCH 12/19] thunderbolt: Add ring_configure to tb_nhi_ops Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-12-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4597; i=sven@kernel.org; h=from:subject:message-id; bh=bjN1NTiSvc6/6RtUd8MUWugBmdf1TrTNf6e7OfieaZY=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCRGb7y9IvDeVK3KSiYFpxoEfsc4HqxmXntyjaagmf yRQbEZGRykLgxgXg6yYIsv2/famTx6+EVy66dJ7mDmsTCBDGLg4BWAir1YzMpzSj7SPu/RBwvxf lbBpvc+a6mBDu4LtrcH83uU184xrSxgZbi3cLN/E9OBG0Zqtb9yntJi8UnvbmbIlPm6p7k1vP9V /PAA= X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 The Apple NHI has to configure and enable each ring with a single write and uses a separate register range for the receive ring PDF masks. Add an optional tb_nhi_ops hook for it which falls back to the standard USB4 NHI method when it is not set. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/thunderbolt/nhi.c | 55 ++++++++++++++++++++++++++++++-------------= ---- drivers/thunderbolt/nhi.h | 4 ++++ 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 3cb69deec63e..696da52abff6 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -239,6 +239,31 @@ static void ring_iowrite32options(struct tb_ring *ring= , u32 value, u32 offset) iowrite32(value, ring_options_base(ring) + offset); } =20 +static void ring_configure(struct tb_ring *ring, u32 flags, u32 e2e_flags) +{ + if (ring->is_tx) + ring_iowrite32options(ring, 0, 4); + else + ring_iowrite32options(ring, ring->sof_mask << 16 | ring->eof_mask, 4); + + ring_iowrite32options(ring, flags, 0); + + /* + * Now that the ring valid bit is set we can configure E2E if + * enabled for the ring. + */ + if (e2e_flags) + ring_iowrite32options(ring, flags | e2e_flags, 0); +} + +static void nhi_ring_configure(struct tb_ring *ring, u32 flags, u32 e2e_fl= ags) +{ + if (ring->nhi->ops->ring_configure) + ring->nhi->ops->ring_configure(ring, flags, e2e_flags); + else + ring_configure(ring, flags, e2e_flags); +} + static bool ring_full(struct tb_ring *ring) { return ((ring->head + 1) % ring->size) =3D=3D ring->tail; @@ -694,6 +719,7 @@ EXPORT_SYMBOL_GPL(tb_ring_alloc_rx); */ void tb_ring_start(struct tb_ring *ring) { + u32 e2e_flags =3D 0; u16 frame_size; u32 flags; =20 @@ -717,30 +743,13 @@ void tb_ring_start(struct tb_ring *ring) flags =3D RING_FLAG_ENABLE | RING_FLAG_RAW; } =20 - ring_iowrite64desc(ring, ring->descriptors_dma, 0); - if (ring->is_tx) { - ring_iowrite32desc(ring, ring->size, 12); - ring_iowrite32options(ring, 0, 4); - ring_iowrite32options(ring, flags, 0); - } else { - u32 sof_eof_mask =3D ring->sof_mask << 16 | ring->eof_mask; - - ring_iowrite32desc(ring, (frame_size << 16) | ring->size, 12); - ring_iowrite32options(ring, sof_eof_mask, 4); - ring_iowrite32options(ring, flags, 0); - } - - /* - * Now that the ring valid bit is set we can configure E2E if - * enabled for the ring. - */ if (ring->flags & RING_FLAG_E2E) { if (!ring->is_tx) { u32 hop; =20 hop =3D ring->e2e_tx_hop << REG_RX_OPTIONS_E2E_HOP_SHIFT; hop &=3D REG_RX_OPTIONS_E2E_HOP_MASK; - flags |=3D hop; + e2e_flags |=3D hop; =20 dev_dbg(ring->nhi->dev, "enabling E2E for %s %d with TX HopID %d\n", @@ -750,10 +759,16 @@ void tb_ring_start(struct tb_ring *ring) RING_TYPE(ring), ring->hop); } =20 - flags |=3D RING_FLAG_E2E_FLOW_CONTROL; - ring_iowrite32options(ring, flags, 0); + e2e_flags |=3D RING_FLAG_E2E_FLOW_CONTROL; } =20 + ring_iowrite64desc(ring, ring->descriptors_dma, 0); + if (ring->is_tx) + ring_iowrite32desc(ring, ring->size, 12); + else + ring_iowrite32desc(ring, (frame_size << 16) | ring->size, 12); + nhi_ring_configure(ring, flags, e2e_flags); + if (!(ring->flags & RING_FLAG_NO_INTERRUPT)) nhi_ring_interrupt_active(ring, true); ring->running =3D true; diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h index 5f70d7ddc2e2..670b48efeec5 100644 --- a/drivers/thunderbolt/nhi.h +++ b/drivers/thunderbolt/nhi.h @@ -76,6 +76,9 @@ struct tb_nhi_ring_layout { * @ring_interrupt_mask: NHI specific hook to mask/unmask the interrupt of= a * single ring. If not set the standard USB4 NHI * registers are used. + * @ring_configure: NHI specific hook to program the ring options registers + * and enable the ring with the given flags. If not set + * the standard USB4 NHI registers are used. * @is_present: Whether the device is currently present on the parent bus * @init_interrupts: NHI specific interrupt initialization hook * @reset_interface: Resets the host interface @@ -93,6 +96,7 @@ struct tb_nhi_ops { void (*release_ring_irq)(struct tb_ring *ring); void (*ring_interrupt_active)(struct tb_ring *ring, bool active); void (*ring_interrupt_mask)(struct tb_ring *ring, bool mask); + void (*ring_configure)(struct tb_ring *ring, u32 flags, u32 e2e_flags); bool (*is_present)(struct tb_nhi *nhi); int (*init_interrupts)(struct tb_nhi *nhi); void (*reset_interface)(struct tb_nhi *nhi); --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB75833122A; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; cv=none; b=D/2ukTAJAP8WVAt8dWuBFZxaMYhuQjdQY/yyjZ3Z5iJL4CrbiHvjEa4tf5MPFuqejNJG92s21UtG7vIX5AsebWghd0eCAZgAQMDh//qIW1E8MaAl4zOLJB/9KAsHOdp0yofxWia9MB6z3ZcmtobuV+sRU9lVop/kZr7kq9oOnFI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121184; c=relaxed/simple; bh=ys3MSPTh8sqC1O/yv08O/qeOshWA9L72ZznWjJevtX4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QjJEoUH6X3uAiom+EsITR/86z3/+VrCOs4ybSn2PUe7G9Hd1E/rkyDE+XO1I4hzT+5a9WPAwL9g1Qw9oV+pHwsFRNhUttT4YYZxUGnfUl9o162xHk/fNxcEaDuhpdb7twSSlSrk2pbMatQwLdVXYDbVT0sjh6Awu0cGPgzxp4gw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fdKx/FPh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fdKx/FPh" Received: by smtp.kernel.org (Postfix) with ESMTPS id A3B96C4AF19; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=ys3MSPTh8sqC1O/yv08O/qeOshWA9L72ZznWjJevtX4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fdKx/FPhfQtGKpLplVnSLBQ8Gw/sbqYyuGYAeTbYQGAoPnpIFBEmN7kYdABEucZw6 wZULcOCuE6f/EHdZtxkW7ej8cNNRmW7+ngBzQ0niuJHU2vQ03xnuTb3T2y0td/27OT oEW05IU1EsGUd4zk1WqlZNPwlDJQnFPEDVnfz/fLNuhzE7q4ivcsArzUTuTG0FrNFB frlYc7ry1I/rmslCP1y1HX9lrxdSy2Eni/3Ut9iwbckHwOEPYAdjfPqLjZ51//9Uuz IDOoqfR25guoTfsV8JyVQflt2P3rEwceWse22XojUWQBlx+8SIuGVJjXaLPZwjxaCx Lg86MmnMZe7XA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88718C61DEB; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:31 +0200 Subject: [PATCH 13/19] thunderbolt: Add QUIRK_NO_DMA_PORT Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-13-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3244; i=sven@kernel.org; h=from:subject:message-id; bh=ys3MSPTh8sqC1O/yv08O/qeOshWA9L72ZznWjJevtX4=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCZFKJbWRpu7a9XZdn2duKzJSeVjsdFhs3m2/zbenb gnJSb/fUcrCIMbFICumyLJ9v73pk4dvBJduuvQeZg4rE8gQBi5OAZjI35MM/4zbDoYaJr+eqLZE 4xGPrfarjvYz4XGXFhklFluHfMrP+8zIMKHxub3n3VMNi/vTtk7SyZiuFVKR57d2i1KUYeA1Ged 73AA= X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Apple Silicon machines load and update the host router firmware with a separate, proprietary mechanism and have no DMA port. Add a quirk to skip its initialization. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/thunderbolt/nhi.h | 1 + drivers/thunderbolt/switch.c | 10 ++++++---- drivers/thunderbolt/tb.c | 8 ++++++++ drivers/thunderbolt/tb.h | 2 ++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h index 670b48efeec5..c2d16ab6994e 100644 --- a/drivers/thunderbolt/nhi.h +++ b/drivers/thunderbolt/nhi.h @@ -168,6 +168,7 @@ struct tb_nhi_ops { #define QUIRK_AUTO_CLEAR_INT BIT(0) #define QUIRK_E2E BIT(1) #define QUIRK_RESET_DMA_ON_TEARDOWN BIT(2) +#define QUIRK_NO_DMA_PORT BIT(3) =20 /* * Minimal number of vectors when we use MSI-X. Two for control channel diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 3f54a5ae56b0..ef267f40c103 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -3317,10 +3317,12 @@ int tb_switch_add(struct tb_switch *sw) * to the userspace. NVM can be accessed through DMA * configuration based mailbox. */ - ret =3D tb_switch_add_dma_port(sw); - if (ret) { - dev_err(&sw->dev, "failed to add DMA port\n"); - return ret; + if (!sw->no_dma_port) { + ret =3D tb_switch_add_dma_port(sw); + if (ret) { + dev_err(&sw->dev, "failed to add DMA port\n"); + return ret; + } } =20 ret =3D tb_switch_nvm_init(sw); diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index 47753a5c0f2e..c43cdd2c2e2e 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -15,6 +15,7 @@ #include "tb.h" #include "tb_regs.h" #include "tunnel.h" +#include "nhi.h" =20 #define TB_TIMEOUT 100 /* ms */ #define TB_RELEASE_BW_TIMEOUT 10000 /* ms */ @@ -3036,6 +3037,13 @@ static int tb_start(struct tb *tb, bool reset) /* All USB4 routers support runtime PM */ tb->root_switch->rpm =3D tb_switch_is_usb4(tb->root_switch); =20 + /* + * Apple Silicon machines have a separate, proprietary mechanism for + * loading and updating firmware. Skip the DMA port initialization on + * these machines. + */ + tb->root_switch->no_dma_port =3D tb->nhi->quirks & QUIRK_NO_DMA_PORT; + ret =3D tb_switch_configure(tb->root_switch); if (ret) { tb_switch_put(tb->root_switch); diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index 4373336d9425..0977cd690d7e 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -139,6 +139,7 @@ struct tb_switch_tmu { * @drom: DROM of the switch (%NULL if not found) * @nvm: Pointer to the NVM if the switch has one (%NULL otherwise) * @no_nvm_upgrade: Prevent NVM upgrade of this switch + * @no_dma_port: Prevent adding the DMA port of this switch * @safe_mode: The switch is in safe-mode * @boot: Whether the switch was already authorized on boot or not * @rpm: The switch supports runtime PM @@ -194,6 +195,7 @@ struct tb_switch { u8 *drom; struct tb_nvm *nvm; bool no_nvm_upgrade; + bool no_dma_port; bool safe_mode; bool boot; bool rpm; --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E416E331EA3; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; cv=none; b=ukUGg03od+3EbkeWn9btplnP1bkPOruwyPBhXj/igTR+aMFnPlL28mmHNdC3wCa1dx+xMpMjccR+QLhPLCmDD+eygGnmVYM/ltP0AAZQGU9/FkdJ3yYlPaNl9hMAO1dwZQUqTTR+BUvPz/hzPVSjFYCYxTYbn4BrKy2doRLhxGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; c=relaxed/simple; bh=CLLkwaKc5+f6XimwNr2nFpZ5Q46wgtKFW0n8D5ES48U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j/7TzUSOkvi/PB0EDumHcAuIRjAP5kG5pg9R3VufzSFmRpiWPe0TiNdU1Hno+b/DW4HP9kxH1kApDeUoRERyo+WQryfiEf3IWVOSFmhE8yY6F/JNI7ufg9+aEJHkkROVjfiMeU5106wt77oxIXXd4rC+Qh5xEWTWSC/X5wp38HI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bNl0B7ei; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bNl0B7ei" Received: by smtp.kernel.org (Postfix) with ESMTPS id B3538C2BD04; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=CLLkwaKc5+f6XimwNr2nFpZ5Q46wgtKFW0n8D5ES48U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bNl0B7eiYj/nR7OKhFUWhHR++ZxsEy1wEUCO2RZe/fxZU1Nq0L1QoH1a2VGsgLHa2 ri/TVzGtnO3wI0ySGSQqSuZuZh5W/5ytDaMSEb4/ic6fkyTZoRgM17q5t69NNdRgdv 6KI4AnuWeXnErt9D1MTGgD4sAKhvEAfAsIXzkSuL9ffhfoEUY4/SAqvl/Q7H/TvWr9 y9usljO9CqJlV/UxCAE9Byz/ycBgs+OMmcGVu29/3aotq/WKk1Wa99d9lqcAlcU8G/ tHXDdfvZ975+SFVw12Bk+zH2GW/fckjKaxmtlUQ/SFK2Tna/cgoYjk2JrlXnyocZAg PR6J4sK3K1srw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C691C61DD9; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:32 +0200 Subject: [PATCH 14/19] thunderbolt: Add QUIRK_NO_USB3_BW_ALLOC Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-14-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6302; i=sven@kernel.org; h=from:subject:message-id; bh=CLLkwaKc5+f6XimwNr2nFpZ5Q46wgtKFW0n8D5ES48U=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCZFXxd52NOy6O3+rhHf7b8Zn96es63pjJvfO+MAaT 7k0N7cPHaUsDGJcDLJiiizb99ubPnn4RnDppkvvYeawMoEMYeDiFICJvJFi+J95pnbHDNugN8/z 30z0mJf6+E5Sr1+o/B7HPk2XKWfeJ+5k+GfA1O9dtihRJvuAyu0tViwdE3nDN28+EMj4Y9ufg1u 6tvICAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 The host routers on Apple Silicon do not implement USB3 bandwidth allocation registers: the CMR bit set in ADP_USB3_CS_2 by usb4_usb3_port_cm_request() is never acknowledged and every USB3 tunnel bringup fails there after the timeout: [ 49.259325] thunderbolt-apple-nhi 501f00000.nhi: 1:16: available bandw= idth for new USB3 tunnel 18000/18000 Mb/s [ 49.265869] thunderbolt-apple-nhi 501f00000.nhi: 1:16: maximum require= d bandwidth for USB3 tunnel 9000 Mb/s [ 49.267894] thunderbolt-apple-nhi 501f00000.nhi: 0:4 <-> 1:16 (USB3): = activating [ 49.269410] thunderbolt-apple-nhi 501f00000.nhi: 0:4 <-> 1:16 (USB3): = allocating initial bandwidth 9000/9000 Mb/s [ 50.771764] thunderbolt-apple-nhi 501f00000.nhi: 1:16: USB3 tunnel act= ivation failed, aborting Add a quirk to skip bandwidth allocation entirely but keep tracking the initial allocation in software for the consumed bandwidth calculation. For completeness, discovered tunnels book 90% of the maximum link rate in software, matching tb_tunnel_alloc_usb3(), although Apple Silicon cannot have any pre-existing tunnels. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/thunderbolt/nhi.h | 1 + drivers/thunderbolt/tb.c | 8 ++++++ drivers/thunderbolt/tb.h | 3 +++ drivers/thunderbolt/tunnel.c | 59 +++++++++++++++++++++++++++++-----------= ---- 4 files changed, 51 insertions(+), 20 deletions(-) diff --git a/drivers/thunderbolt/nhi.h b/drivers/thunderbolt/nhi.h index c2d16ab6994e..afd9a11489a9 100644 --- a/drivers/thunderbolt/nhi.h +++ b/drivers/thunderbolt/nhi.h @@ -169,6 +169,7 @@ struct tb_nhi_ops { #define QUIRK_E2E BIT(1) #define QUIRK_RESET_DMA_ON_TEARDOWN BIT(2) #define QUIRK_NO_DMA_PORT BIT(3) +#define QUIRK_NO_USB3_BW_ALLOC BIT(4) =20 /* * Minimal number of vectors when we use MSI-X. Two for control channel diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index c43cdd2c2e2e..7ab53a30fe30 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -3044,6 +3044,14 @@ static int tb_start(struct tb *tb, bool reset) */ tb->root_switch->no_dma_port =3D tb->nhi->quirks & QUIRK_NO_DMA_PORT; =20 + /* + * Apple Silicon host routers do not implement the USB3 bandwidth + * allocation registers: the CMR/HCA handshake is never acked and + * times out. Bandwidth for USB3 tunnels is only booked in software + * on these machines. + */ + tb->root_switch->no_usb3_bw_alloc =3D tb->nhi->quirks & QUIRK_NO_USB3_BW_= ALLOC; + ret =3D tb_switch_configure(tb->root_switch); if (ret) { tb_switch_put(tb->root_switch); diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index 0977cd690d7e..530b0e6c3a11 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -140,6 +140,8 @@ struct tb_switch_tmu { * @nvm: Pointer to the NVM if the switch has one (%NULL otherwise) * @no_nvm_upgrade: Prevent NVM upgrade of this switch * @no_dma_port: Prevent adding the DMA port of this switch + * @no_usb3_bw_alloc: Host router does not implement the USB3 bandwidth + * allocation registers (ADP_USB3_CS_1..4) * @safe_mode: The switch is in safe-mode * @boot: Whether the switch was already authorized on boot or not * @rpm: The switch supports runtime PM @@ -196,6 +198,7 @@ struct tb_switch { struct tb_nvm *nvm; bool no_nvm_upgrade; bool no_dma_port; + bool no_usb3_bw_alloc; bool safe_mode; bool boot; bool rpm; diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c index 7e8284575dff..9178120a6b66 100644 --- a/drivers/thunderbolt/tunnel.c +++ b/drivers/thunderbolt/tunnel.c @@ -2268,24 +2268,40 @@ struct tb_tunnel *tb_tunnel_discover_usb3(struct tb= *tb, struct tb_port *down, if (!tb_route(down->sw)) { int ret; =20 - /* - * Read the initial bandwidth allocation for the first - * hop tunnel. - */ - ret =3D usb4_usb3_port_allocated_bandwidth(down, - &tunnel->allocated_up, &tunnel->allocated_down); - if (ret) - goto err_deactivate; + tunnel->consumed_bandwidth =3D tb_usb3_consumed_bandwidth; + + if (down->sw->no_usb3_bw_alloc) { + /* + * The host router does not implement the bandwidth + * allocation registers and nothing can be read back + * here. Book 90% of the maximum link rate in software + * instead. + */ + ret =3D tb_usb3_max_link_rate(tunnel->dst_port, down); + if (ret < 0) + goto err_deactivate; + + tunnel->allocated_up =3D ret * 90 / 100; + tunnel->allocated_down =3D tunnel->allocated_up; + } else { + /* + * Read the initial bandwidth allocation for the first + * hop tunnel. + */ + ret =3D usb4_usb3_port_allocated_bandwidth(down, + &tunnel->allocated_up, &tunnel->allocated_down); + if (ret) + goto err_deactivate; + + tunnel->pre_activate =3D tb_usb3_pre_activate; + tunnel->release_unused_bandwidth =3D + tb_usb3_release_unused_bandwidth; + tunnel->reclaim_available_bandwidth =3D + tb_usb3_reclaim_available_bandwidth; + } =20 tb_tunnel_dbg(tunnel, "currently allocated bandwidth %d/%d Mb/s\n", tunnel->allocated_up, tunnel->allocated_down); - - tunnel->pre_activate =3D tb_usb3_pre_activate; - tunnel->consumed_bandwidth =3D tb_usb3_consumed_bandwidth; - tunnel->release_unused_bandwidth =3D - tb_usb3_release_unused_bandwidth; - tunnel->reclaim_available_bandwidth =3D - tb_usb3_reclaim_available_bandwidth; } =20 tb_tunnel_dbg(tunnel, "discovered\n"); @@ -2365,12 +2381,15 @@ struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *t= b, struct tb_port *up, tunnel->allocated_up =3D min(max_rate, max_up); tunnel->allocated_down =3D min(max_rate, max_down); =20 - tunnel->pre_activate =3D tb_usb3_pre_activate; tunnel->consumed_bandwidth =3D tb_usb3_consumed_bandwidth; - tunnel->release_unused_bandwidth =3D - tb_usb3_release_unused_bandwidth; - tunnel->reclaim_available_bandwidth =3D - tb_usb3_reclaim_available_bandwidth; + + if (!down->sw->no_usb3_bw_alloc) { + tunnel->pre_activate =3D tb_usb3_pre_activate; + tunnel->release_unused_bandwidth =3D + tb_usb3_release_unused_bandwidth; + tunnel->reclaim_available_bandwidth =3D + tb_usb3_reclaim_available_bandwidth; + } } =20 return tunnel; --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CF8C332EC5; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; cv=none; b=lVr3so1EJK5G427gsKUlQlngxw1x51vAiZUQhxOy+xjrPaq39YzFKDvwuItKZ9GuZfgKhbOWO+kUeRvGCOc9IAAOrViaIwrbaT+aoemOVMbsZ9JNol5+k/DgXimYYtFGQvi3UUyxPO6cdDg9eGfmR4508O0xZ9RzJLhKfkSVtf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; c=relaxed/simple; bh=yLZzvweLjoBBYhWj4yAiYhV53Thr+IzutEkoNWzH/mU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iI/Yut4gJE1KtbY7RDsng07BkXmfvrwe4ZIAzVX8egqSF1Kr8I2cGzPuZv2Ss345xPg8binN6u4LF6bkEsvfQ9+1LrIvkHApYwg2dwEbLlWDqZGbaYd70RjvRdLiZc9iGCNScsYQ5FXXzqn5brxzPL/7iU5IAzAYcsPBEnSyqNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K5IQo6/2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K5IQo6/2" Received: by smtp.kernel.org (Postfix) with ESMTPS id DB111C4AF4D; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121184; bh=yLZzvweLjoBBYhWj4yAiYhV53Thr+IzutEkoNWzH/mU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K5IQo6/2KjiuDg4JiKaO9StPJ7B7aoYzgwk/rfs+zrHztkVJv44jUt0USKxcf63ze cWEsQ4V/hzoVag43lvJb0mAml0DBTeZzRuND+joF38FoYz8HtG5/z0Cp0cqEQ6YSzO 5WFgmHk5U591YYIo2J/W3I8JL3XX4eZnXuoorsWghsgyyWPhbLeIin47i/ZZR4zUlr AWud6SQj4rWMT82M9NxEW8Uy8IhiDoEWE4BsHLrVyAxkZkLnaTKzkm1bjNPnu01kkt oXuvDVxiMuY7UXMHOil9+5fRJZSpDx6LXxZ+EPDyyL1gjfwtXCs3t1zqenwSmW3eZQ SSXtkwv30TP0Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3940C61DF0; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:33 +0200 Subject: [PATCH 15/19] thunderbolt: Export symbols required by the Apple Silicon driver Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-15-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3480; i=sven@kernel.org; h=from:subject:message-id; bh=yLZzvweLjoBBYhWj4yAiYhV53Thr+IzutEkoNWzH/mU=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCVGxa+/vjl/00ytg7Ty7ZUkmM0LkbPpUQ41LnwrW9 38NX7C7o5SFQYyLQVZMkWX7fnvTJw/fCC7ddOk9zBxWJpAhDFycAjARtxqG/6X8P3eYqC1OmNtf eCrcdPU+yfiVH33cd1a6Lp7p9Jztvysjw67stwyKu+ID5Z/zzDBL2H3v9amI6cwLNledCeHdH/p EjA8A X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 The driver for the ACIO host router complex on Apple Silicon SoCs can be built as a module and needs tb_probe() and the domain functions to register its NHI with the software connection manager as well as tb_switch_find_vse_cap(), tb_cfg_write() and tb_port_unlock() to configure the cable details for its co-processor and to unlock the lane ports. Restrict these exports to the thunderbolt_apple module to keep them internal to the Thunderbolt subsystem. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- drivers/thunderbolt/cap.c | 2 ++ drivers/thunderbolt/ctl.c | 2 ++ drivers/thunderbolt/domain.c | 2 ++ drivers/thunderbolt/switch.c | 1 + drivers/thunderbolt/tb.c | 2 ++ 5 files changed, 9 insertions(+) diff --git a/drivers/thunderbolt/cap.c b/drivers/thunderbolt/cap.c index 4ab22d5291ac..e000a53e5e75 100644 --- a/drivers/thunderbolt/cap.c +++ b/drivers/thunderbolt/cap.c @@ -6,6 +6,7 @@ * Copyright (C) 2018, Intel Corporation */ =20 +#include #include #include =20 @@ -254,3 +255,4 @@ int tb_switch_find_vse_cap(struct tb_switch *sw, enum t= b_switch_vse_cap vsec) =20 return -ENOENT; } +EXPORT_SYMBOL_FOR_MODULES(tb_switch_find_vse_cap, "thunderbolt_apple"); diff --git a/drivers/thunderbolt/ctl.c b/drivers/thunderbolt/ctl.c index cd47b627f97b..b2a6b300e934 100644 --- a/drivers/thunderbolt/ctl.c +++ b/drivers/thunderbolt/ctl.c @@ -8,6 +8,7 @@ =20 #include #include +#include #include #include #include @@ -1159,6 +1160,7 @@ int tb_cfg_write(struct tb_ctl *ctl, const void *buff= er, u64 route, u32 port, } return res.err; } +EXPORT_SYMBOL_FOR_MODULES(tb_cfg_write, "thunderbolt_apple"); =20 /** * tb_cfg_get_upstream_port() - get upstream port number of switch at route diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c index 12c88509a54f..477a64258b87 100644 --- a/drivers/thunderbolt/domain.c +++ b/drivers/thunderbolt/domain.c @@ -490,6 +490,7 @@ int tb_domain_add(struct tb *tb, bool reset) =20 return ret; } +EXPORT_SYMBOL_FOR_MODULES(tb_domain_add, "thunderbolt_apple"); =20 /** * tb_domain_remove() - Removes and releases a domain @@ -514,6 +515,7 @@ void tb_domain_remove(struct tb *tb) =20 device_unregister(&tb->dev); } +EXPORT_SYMBOL_FOR_MODULES(tb_domain_remove, "thunderbolt_apple"); =20 /** * tb_domain_suspend_noirq() - Suspend a domain diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index ef267f40c103..db675e4f0bc2 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -627,6 +627,7 @@ int tb_port_unlock(struct tb_port *port) return usb4_port_unlock(port); return 0; } +EXPORT_SYMBOL_FOR_MODULES(tb_port_unlock, "thunderbolt_apple"); =20 static int __tb_port_enable(struct tb_port *port, bool enable) { diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index 7ab53a30fe30..6a1f49c473eb 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -6,6 +6,7 @@ * Copyright (C) 2019, Intel Corporation */ =20 +#include #include #include #include @@ -3442,3 +3443,4 @@ struct tb *tb_probe(struct tb_nhi *nhi) =20 return tb; } +EXPORT_SYMBOL_FOR_MODULES(tb_probe, "thunderbolt_apple"); --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 418EF33B6EF; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; cv=none; b=fG/Dq5mdozga1ZHblOv48vJfcsJbbBUbM/cU9Rn8M3L1+c5RG4oKnDVFAS73pZG1vwQat9yvjSUuhXm8E9CxYDoa26k+8M9EfNyq1qTxESRbobgzQkbnXZtABmUVvCZynCMcCquTfhMItJugje9pRHEVDO4Scukg6VPmR0TvU98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; c=relaxed/simple; bh=5QMJLha/ZOnSE71tJUBdC8ALXTEPSE5DoTRj2Pa7WbM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FO2jBOav1tchDgsPBHJ6vkgpOjqL4V984/iF+rNZtFu84wrqgt78zhjr+V9hqOyPoORmXgPQMIC3qOgD6caJ1StJrOSxCIRQpC5kRH5PzdGViaih1Wv083IuGwQFB5tGm80JSWw9ok3RW2eY5d7WHwNQUUhwcxyl1bgXgpneC5A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DWCip8VE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DWCip8VE" Received: by smtp.kernel.org (Postfix) with ESMTPS id 08BC4C32782; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121185; bh=5QMJLha/ZOnSE71tJUBdC8ALXTEPSE5DoTRj2Pa7WbM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DWCip8VEMWjOqxVFTsE4EK9IqoXfcIUfjTaKDWytO4a8yoxTWqoefUGMEf7OFoXUh 6ywWJhcJIl5zyFgwK8ImqCKOlsJ64H9CI9jNI89khjTygq2SmcJgmkaCiSKz7eLg4E ZcOo8387W8Z6Fv0OAtPGJgOxX77isGBypRjS/7j8SDOmKnpJBBq5y0+qVjNQH9hFeV 0MXvP7q0bfGrZZ6h8WSOOFO0FzhVTgSNkV80+IcOeujCOFV0A2NYCS+fE4cdZQDH6w TmCKQNLjdU6CnhEfpQpABV6KhBtEr09ZhfmlsCl5llH4adeJ0u0g+q+carTSTD9K9t C3zeSs3+jwk+A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D512DC61DF1; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:34 +0200 Subject: [PATCH 16/19] thunderbolt: Add Apple Silicon support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-16-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=38416; i=sven@kernel.org; h=from:subject:message-id; bh=5QMJLha/ZOnSE71tJUBdC8ALXTEPSE5DoTRj2Pa7WbM=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCVE9AZp7Nu/tmc5dJ7FCSOHeCSPDrbNPqZ0+fHy51 lquWTHLOkpZGMS4GGTFFFm277c3ffLwjeDSTZfew8xhZQIZwsDFKQATmcfF8N/ThK3v2erDJU/r fTdv235uWt66HYLZHsva/tVGpRxcGGjGyHCEf9eqCqbepm33dn+QujH9m4S1ANfMNTPKbj85fGl pkAcfAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Add a platform driver for the ACIO host router complex and Native Host Interface (NHI) found on Apple Silicon SoCs. The driver powers ACIO in response to Type-C notifications, boots its RTKit co-processor and populates the DART and NHI child devices once their MMIO regions become accessible. It then registers the NHI with the software connection manager and forwards the cable details to the host router. The Apple NHI uses one interrupt per ring and overrides the generic ring register layout, interrupt handling and ring configuration. As of this commit only XDomain connections and USB3-via-USB4 tunnels are supported. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- MAINTAINERS | 1 + drivers/thunderbolt/Kconfig | 13 + drivers/thunderbolt/Makefile | 3 + drivers/thunderbolt/apple.c | 1028 ++++++++++++++++++++++++++++++++++++++= ++++ 4 files changed, 1045 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index c2c6e4541da7..28a32729af8c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2690,6 +2690,7 @@ F: drivers/rtc/rtc-macsmc.c F: drivers/soc/apple/* F: drivers/spi/spi-apple.c F: drivers/spmi/spmi-apple-controller.c +F: drivers/thunderbolt/apple.c F: drivers/usb/dwc3/dwc3-apple.c F: drivers/video/backlight/apple_dwi_bl.c F: drivers/watchdog/apple_wdt.c diff --git a/drivers/thunderbolt/Kconfig b/drivers/thunderbolt/Kconfig index 294b3227a545..d9fbe3a0dc3f 100644 --- a/drivers/thunderbolt/Kconfig +++ b/drivers/thunderbolt/Kconfig @@ -75,4 +75,17 @@ config USB4_STREAM To compile this driver a module, choose M here. The module will be called thunderbolt_stream. =20 +config USB4_APPLE_SOC + tristate "Apple Silicon USB4/Thunderbolt Support" + depends on ARCH_APPLE || COMPILE_TEST + depends on OF && APPLE_RTKIT + depends on TYPEC + select APPLE_TUNABLE + help + Say Y here to add support for the USB4 and Thunderbolt host + routers found on Apple Silicon machines starting with the M1. + + To compile the driver as a module, choose M here. The module + will be called thunderbolt_apple. + endif # USB4 diff --git a/drivers/thunderbolt/Makefile b/drivers/thunderbolt/Makefile index beb054c3126b..edcfe58bc8de 100644 --- a/drivers/thunderbolt/Makefile +++ b/drivers/thunderbolt/Makefile @@ -16,3 +16,6 @@ obj-$(CONFIG_USB4_DMA_TEST) +=3D thunderbolt_dma_test.o =20 thunderbolt_stream-${CONFIG_USB4_STREAM} +=3D stream.o obj-$(CONFIG_USB4_STREAM) +=3D thunderbolt_stream.o + +obj-$(CONFIG_USB4_APPLE_SOC) +=3D thunderbolt_apple.o +thunderbolt_apple-y :=3D apple.o diff --git a/drivers/thunderbolt/apple.c b/drivers/thunderbolt/apple.c new file mode 100644 index 000000000000..530008cc8ec5 --- /dev/null +++ b/drivers/thunderbolt/apple.c @@ -0,0 +1,1028 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Apple Silicon USB4 and Thunderbolt driver + * Copyright (c) Sven Peter + * + * This driver implements the Host Router / ACIO coprocessor as well as the + * Native Host Interface (NHI) as shown in the diagram below. + * The ACIO is a Cortex-M3 coprocessor which handles the Thunderbolt + * protocol and exposes its own hardware blocks like the USB4 Native Host + * Interface (NHI) and its IOMMU to the main SoC bus. The entire block + * can only be brought up after the unified Type-C PHY has been initialized + * to Thunderbolt or USB4 mode and needs an out-of-band notification from + * the Type-C PD driver. + * + * +--------------------+ + * | | +--------------------------------------------+ + * | Display Controller | | Host Router / ACIO | + * | dcpext0 | | +----------------+ | + * | | | | Native | | + * +--------+-----------+ | | Host | | + * | | | Interface | | + * | +---------+ +----------------+ +---------+ = +--------+ + * | +--------->| DP IN | | PCIE DN |<= --->| APCIEC | + * v | | Adapter | +----------------+ | Adapter | = +--------+ + * +---------+-+ +---------+ | | +---------+ + * | Display | | | IOMMU / DART | | + * | Crossbar | | | | +---------+ = +------+ + * +---------+-+ +---------+ +----------------+ | USB3 |<= --->| DWC3 | + * ^ | | DP IN | | Adapter | = +------+ + * | +--------->| Adapter | +---------+ + * | +---------+ | + * | | | + * | | +----------+ | + * +--------+-----------+ | | Type C | | + * | | | | Adapter | | + * | Display Controller | +-----------------+----------+---------------+ + * | dcpext1 | ^ ^ + * | | | | + * +--------------------+ | | + * v | + * +--------------+ | SBRX/TX + * | Apple Type-C | | + * | PHY | | + * +--------------+ | + * ^ | + * | v + * | +---------+ + * +---->| Type C | + * SSRX/TX | Port | + * +---------+ + * + * ACIO and ATCPHY have strict ordering requirements. When a USB4/Thunderb= olt + * connection is requested after a device has been connected the Type-C PD + * driver performs the following sequence: + * + * 1) Configure the PHY for the negotiated mode and orientation through + * typec_mux_set() + * 2) Pass the cable details to this driver through typec_thunderbolt_swit= ch_set() + * 3) Power up ACIO, boot its RTKit co-processor and apply the tunables + * 4) Probe the DART and NHI children now that their MMIO is accessible fr= om + * the main SoC bus + * 5) Register the USB4 domain and write the cable details to the host rou= ter + * which brings up the link and starts discovery + * + * The reverse order is required when the cable is disconnected then: + * + * 1) typec_thunderbolt_switch_set() removes the USB4 domain and the ACIO + * children, shuts down the co-processor and powers everything off. + * 2) typec_mux_set() puts the PHY into safe mode and powers it off. + * + * ACIO must not be started before the PHY is configured and the PHY must + * remain active until ACIO has been powered down again. The child devices + * cannot remain populated while ACIO is powered off because they are part + * of the ACIO block and only exposed to the main SoC bus and will SError + * once ACIO is off. + * Violating this ordering can panic the kernel with an async SError at be= st + * and trigger some internal watchdog that will reset the entire SoC at wo= rst. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nhi.h" +#include "tb.h" + +#define APPLE_CIO_M3_CTRL 0x0c +#define APPLE_CIO_M3_CTRL_START BIT(1) +#define APPLE_CIO_M3_STAT 0xa8 +#define APPLE_CIO_M3_STAT_STATE GENMASK(30, 24) + +#define APPLE_CIO_NHI_HOP_COUNT 0x0 +#define APPLE_CIO_NHI_HOP_COUNT_MASK GENMASK(9, 0) + +#define APPLE_CIO_NHI_TXRING_DESC_BASE 0x10000 +#define APPLE_CIO_NHI_RXRING_DESC_BASE 0x80000 +#define APPLE_CIO_NHI_RING_STRIDE 0x4000 + +#define APPLE_CIO_NHI_PDF_STRIDE 0x4000 + +#define APPLE_CIO_NHI_IRQ_STATUS 0xd0000 +#define APPLE_CIO_NHI_IRQ_ENABLE 0xd0010 +#define APPLE_CIO_NHI_IRQ_THROTTLE 0xd004c +#define APPLE_CIO_NHI_IRQ_THROTTLE_INTERVAL_MASK GENMASK(15, 0) +#define APPLE_CIO_NHI_IRQ_THROTTLE_GRANULARITY_NSEC 256 + +#define APPLE_CIO_SRAM_IOVA_BASE 0x10000000 + +#define APPLE_CIO_NHI_BOOT_TIMEOUT_MS 10000 + +/* + * The Apple vendor-specific extended capability contains a cable-informat= ion + * word which has to be programmed from the USB4/Thunderbolt details repor= ted + * out-of-band by the Type-C PD controller. It must be programmed into the + * host router before link discovery starts. + */ +#define TB_VSE_CAP_APPLE 0x00 +#define TB_VSE_CAP_APPLE_CABLE_INFO 0x01 +#define TB_VSE_CAP_APPLE_CABLE_INFO_PRESENT BIT(0) +#define TB_VSE_CAP_APPLE_CABLE_INFO_ORIENTATION_REVERSE BIT(1) +#define TB_VSE_CAP_APPLE_CABLE_INFO_ACTIVE_CABLE BIT(2) +#define TB_VSE_CAP_APPLE_CABLE_INFO_BIDIR_LSRX BIT(3) +#define TB_VSE_CAP_APPLE_CABLE_INFO_20_GBPS BIT(4) +#define TB_VSE_CAP_APPLE_CABLE_INFO_LEGACY_ADAPTER BIT(9) +#define TB_VSE_CAP_APPLE_CABLE_INFO_TBT2_3 BIT(10) + +/** + * struct apple_cio - Apple Converged I/O host router complex + * @dev: ACIO device + * @np: ACIO device tree node + * @rtk: RTKit instance for the ACIO co-processor + * @rc_base: ACIO root controller registers + * @rc_res: ACIO root controller MMIO resource + * @rc_tunable: Tunable sequence for the ACIO root controller + * @sram_res: ACIO co-processor SRAM resource + * @sram_base: ACIO co-processor SRAM + * @reset: ACIO reset controller + * @pd_list: Power domains used by the ACIO complex + * @lock: Serializes cable transitions and ACIO power changes + * @current_cable_info: Cable information currently programmed into ACIO + * @target_cable_info: Cable information requested by the Type-C PD driver + * @nhi_boot_completion: Signals completion of the NHI bringup + * @nhi_boot_status: Status returned by the NHI bringup + * @tbt_switch: USB4/Thunderbolt switch triggered by the Type-C PD driver + */ +struct apple_cio { + struct device *dev; + struct device_node *np; + struct apple_rtkit *rtk; + + void __iomem *rc_base; + struct resource *rc_res; + struct apple_tunable *rc_tunable; + + struct resource *sram_res; + void __iomem *sram_base; + + struct reset_control *reset; + + struct dev_pm_domain_list *pd_list; + + struct mutex lock; + + u32 current_cable_info; + u32 target_cable_info; + struct completion nhi_boot_completion; + int nhi_boot_status; + + struct typec_thunderbolt_switch_dev *tbt_switch; +}; + +/** + * struct apple_nhi - Apple Native Host Interface + * @dev: NHI device + * @pdev: NHI platform device + * @np: NHI device tree node + * @acio: Parent ACIO complex + * @tb: USB4 domain and software connection manager + * @nhi: NHI struct + * @nhi_base: NHI registers + * @pdf_base: PDF (Protocol Defined Field) configuration registers + * @tx_irqs: Transmit ring interrupts indexed by HopID + * @rx_irqs: Receive ring interrupts indexed by HopID + * @tx_irq_names: Names of the transmit ring interrupts + * @rx_irq_names: Names of the receive ring interrupts + * @n_rings: Number of rings in each direction + */ +struct apple_nhi { + struct device *dev; + struct platform_device *pdev; + struct device_node *np; + + struct apple_cio *acio; + + struct tb *tb; + struct tb_nhi nhi; + + void __iomem *nhi_base; + void __iomem *pdf_base; + + int *tx_irqs; + int *rx_irqs; + const char **tx_irq_names; + const char **rx_irq_names; + size_t n_rings; +}; + +#define nhi_to_anhi(nhi_) container_of((nhi_), struct apple_nhi, nhi) + +/** + * apple_cio_rtkit_shmem_setup - Map an RTKit shared memory buffer + * @cookie: ACIO instance passed to RTKit + * @bfr: RTKit shared memory buffer descriptor + * + * Translate the firmware-provided IOVA into the ACIO SRAM mapping and rej= ect + * buffers that fall outside the reserved SRAM resource. + * + * Return: 0 on success or a negative error code on failure. + */ +static int apple_cio_rtkit_shmem_setup(void *cookie, struct apple_rtkit_sh= mem *bfr) +{ + struct apple_cio *acio =3D cookie; + struct resource res =3D { + .name =3D "acio_rtkit_buffer", + .flags =3D acio->sram_res->flags, + }; + + if (!bfr->iova) + return -EIO; + + if (bfr->iova < APPLE_CIO_SRAM_IOVA_BASE) { + dev_err(acio->dev, "firmware requested invalid buffer before SRAM IOVA b= ase 0x%llx\n", + bfr->iova); + return -EFAULT; + } + + res.start =3D bfr->iova - APPLE_CIO_SRAM_IOVA_BASE + acio->sram_res->star= t; + res.end =3D res.start + bfr->size - 1; + + if (res.end < res.start) { + dev_err(acio->dev, "firmware requested invalid buffer %pR\n", &res); + return -EFAULT; + } + + if (!resource_contains(acio->sram_res, &res)) { + dev_err(acio->dev, "firmware requested buffer %pR outside SRAM %pR\n", &= res, + acio->sram_res); + return -EFAULT; + } + + bfr->iomem =3D acio->sram_base + (res.start - acio->sram_res->start); + bfr->is_mapped =3D true; + return 0; +} + +static const struct apple_rtkit_ops apple_cio_rtkit_ops =3D { + .shmem_setup =3D apple_cio_rtkit_shmem_setup, +}; + +static int apple_nhi_probe_irqs(struct apple_nhi *anhi) +{ + int n_irqs; + char name[64]; + + n_irqs =3D platform_irq_count(anhi->pdev); + if (n_irqs < 0) + return dev_err_probe(anhi->dev, n_irqs, "platform_irq_count failed\n"); + if (n_irqs =3D=3D 0) { + dev_err(anhi->dev, "No interrupts found\n"); + return -EINVAL; + } + if (n_irqs % 2) { + dev_err(anhi->dev, "Invalid number of interrupts: %d must be even\n", n_= irqs); + return -EINVAL; + } + anhi->n_rings =3D n_irqs / 2; + + anhi->rx_irqs =3D devm_kcalloc(anhi->dev, anhi->n_rings, sizeof(*anhi->rx= _irqs), GFP_KERNEL); + if (!anhi->rx_irqs) + return -ENOMEM; + anhi->tx_irqs =3D devm_kcalloc(anhi->dev, anhi->n_rings, sizeof(*anhi->tx= _irqs), GFP_KERNEL); + if (!anhi->tx_irqs) + return -ENOMEM; + anhi->rx_irq_names =3D devm_kcalloc(anhi->dev, anhi->n_rings, + sizeof(*anhi->rx_irq_names), GFP_KERNEL); + if (!anhi->rx_irq_names) + return -ENOMEM; + anhi->tx_irq_names =3D devm_kcalloc(anhi->dev, anhi->n_rings, + sizeof(*anhi->tx_irq_names), GFP_KERNEL); + if (!anhi->tx_irq_names) + return -ENOMEM; + + for (int i =3D 0; i < anhi->n_rings; ++i) { + snprintf(name, sizeof(name), "rxring%d", i); + anhi->rx_irqs[i] =3D platform_get_irq_byname(anhi->pdev, name); + if (anhi->rx_irqs[i] < 0) + return anhi->rx_irqs[i]; + anhi->rx_irq_names[i] =3D devm_kasprintf(anhi->dev, GFP_KERNEL, "%s-%s", + dev_name(anhi->dev), name); + if (!anhi->rx_irq_names[i]) + return -ENOMEM; + + snprintf(name, sizeof(name), "txring%d", i); + anhi->tx_irqs[i] =3D platform_get_irq_byname(anhi->pdev, name); + if (anhi->tx_irqs[i] < 0) + return anhi->tx_irqs[i]; + anhi->tx_irq_names[i] =3D devm_kasprintf(anhi->dev, GFP_KERNEL, "%s-%s", + dev_name(anhi->dev), name); + if (!anhi->tx_irq_names[i]) + return -ENOMEM; + } + + return 0; +} + +static unsigned int apple_cio_ring_index(struct tb_ring *ring) +{ + struct apple_nhi *anhi =3D nhi_to_anhi(ring->nhi); + + if (ring->is_tx) + return ring->hop; + else + return ring->hop + anhi->n_rings; +} + +static void apple_nhi_ring_interrupt_active(struct tb_ring *ring, bool act= ive) +{ + struct apple_nhi *anhi =3D nhi_to_anhi(ring->nhi); + unsigned int idx =3D apple_cio_ring_index(ring); + u32 reg, interval; + + lockdep_assert_held(&ring->nhi->lock); + + if (active && ring->interval_nsec) { + interval =3D min_t(u32, ring->interval_nsec, + FIELD_MAX(APPLE_CIO_NHI_IRQ_THROTTLE_INTERVAL_MASK) * + APPLE_CIO_NHI_IRQ_THROTTLE_GRANULARITY_NSEC); + interval =3D DIV_ROUND_UP(interval, + APPLE_CIO_NHI_IRQ_THROTTLE_GRANULARITY_NSEC); + writel(interval, anhi->nhi_base + APPLE_CIO_NHI_IRQ_THROTTLE + + 4 * idx); + } + + reg =3D readl(anhi->nhi_base + APPLE_CIO_NHI_IRQ_ENABLE); + + if (active) + reg |=3D BIT(idx); + else + reg &=3D ~BIT(idx); + + writel(reg, anhi->nhi_base + APPLE_CIO_NHI_IRQ_ENABLE); +} + +static void apple_nhi_ring_interrupt_mask(struct tb_ring *ring, bool mask) +{ + apple_nhi_ring_interrupt_active(ring, !mask); +} + +static irqreturn_t apple_cio_ring_irq(int irq, void *data) +{ + struct tb_ring *ring =3D data; + struct apple_nhi *anhi =3D nhi_to_anhi(ring->nhi); + unsigned int idx =3D apple_cio_ring_index(ring); + + guard(spinlock)(&ring->nhi->lock); + guard(spinlock)(&ring->lock); + + writel(BIT(idx), anhi->nhi_base + APPLE_CIO_NHI_IRQ_STATUS); + if (!ring->running) + return IRQ_HANDLED; + + if (ring->start_poll) { + apple_nhi_ring_interrupt_mask(ring, true); + ring->start_poll(ring->poll_data); + } else { + schedule_work(&ring->work); + } + + return IRQ_HANDLED; +} + + +static int apple_nhi_request_irq(struct tb_ring *ring, bool no_suspend) +{ + struct apple_nhi *anhi =3D nhi_to_anhi(ring->nhi); + const char *name; + + if (ring->is_tx) { + ring->irq =3D anhi->tx_irqs[ring->hop]; + name =3D anhi->tx_irq_names[ring->hop]; + } else { + ring->irq =3D anhi->rx_irqs[ring->hop]; + name =3D anhi->rx_irq_names[ring->hop]; + } + + return devm_request_irq(anhi->dev, ring->irq, apple_cio_ring_irq, + no_suspend ? IRQF_NO_SUSPEND : 0, name, ring); +} + +static void apple_nhi_release_irq(struct tb_ring *ring) +{ + if (ring->irq <=3D 0) + return; + + devm_free_irq(ring->nhi->dev, ring->irq, ring); + ring->irq =3D 0; +} + +static void apple_nhi_ring_configure(struct tb_ring *ring, u32 flags, u32 = e2e_flags) +{ + struct apple_nhi *anhi =3D nhi_to_anhi(ring->nhi); + void __iomem *options; + u32 sof_eof_mask; + + lockdep_assert_held(&ring->lock); + + options =3D anhi->nhi_base + ring->hop * APPLE_CIO_NHI_RING_STRIDE + 0x10; + + if (ring->is_tx) { + options +=3D APPLE_CIO_NHI_TXRING_DESC_BASE; + + /* + * All TX rings share what macOS calls a shared buffer with 232 entries.= This is how + * macOS splits it up, ring 0 only carries control packets and gets the = minimum. + */ + if (ring->hop =3D=3D 0) + writel(2, options + 4); + else if (ring->hop <=3D 5) + writel(40, options + 4); + else + writel(5, options + 4); + } else { + options +=3D APPLE_CIO_NHI_RXRING_DESC_BASE; + + sof_eof_mask =3D ring->sof_mask << 16 | ring->eof_mask; + writel(sof_eof_mask, options + 4); + writel(sof_eof_mask, anhi->pdf_base + ring->hop * APPLE_CIO_NHI_PDF_STRI= DE); + } + + /* + * The firmware samples the ring configuration when the valid bit is set = and E2E flow + * control never engages when configured afterwards. Write everything at = once like macOS. + */ + writel(flags | e2e_flags, options); +} + +static const struct tb_nhi_ops apple_nhi_ops =3D { + .request_ring_irq =3D apple_nhi_request_irq, + .release_ring_irq =3D apple_nhi_release_irq, + .ring_interrupt_active =3D apple_nhi_ring_interrupt_active, + .ring_interrupt_mask =3D apple_nhi_ring_interrupt_mask, + .ring_configure =3D apple_nhi_ring_configure, +}; + +static const struct tb_nhi_ring_layout apple_nhi_ring_layout =3D { + .tx_desc_base =3D APPLE_CIO_NHI_TXRING_DESC_BASE, + .rx_desc_base =3D APPLE_CIO_NHI_RXRING_DESC_BASE, + .desc_stride =3D APPLE_CIO_NHI_RING_STRIDE, + .tx_options_base =3D APPLE_CIO_NHI_TXRING_DESC_BASE + 0x10, + .rx_options_base =3D APPLE_CIO_NHI_RXRING_DESC_BASE + 0x10, + .options_stride =3D APPLE_CIO_NHI_RING_STRIDE, +}; + +static int apple_nhi_probe(struct platform_device *pdev) +{ + struct apple_cio *acio =3D dev_get_drvdata(pdev->dev.parent); + struct apple_nhi *anhi; + struct apple_tunable *tunable; + struct resource *res; + struct tb_port *port; + int cap_apple; + int ret =3D 0; + + anhi =3D devm_kzalloc(&pdev->dev, sizeof(*anhi), GFP_KERNEL); + if (!anhi) { + ret =3D -ENOMEM; + goto err; + } + + anhi->pdev =3D pdev; + anhi->dev =3D &pdev->dev; + anhi->np =3D pdev->dev.of_node; + anhi->acio =3D acio; + platform_set_drvdata(pdev, anhi); + + ret =3D dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(42)); + if (ret) + goto err; + + res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "nhi"); + anhi->nhi_base =3D devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(anhi->nhi_base)) { + ret =3D dev_err_probe(&pdev->dev, PTR_ERR(anhi->nhi_base), + "Unable to map NHI regs\n"); + goto err; + } + tunable =3D devm_apple_tunable_parse(&pdev->dev, anhi->np, "apple,tunable= -nhi", res); + if (IS_ERR(tunable)) { + ret =3D dev_err_probe(&pdev->dev, PTR_ERR(tunable), "Unable to load NHI = tunable\n"); + goto err; + } + apple_tunable_apply(anhi->nhi_base, tunable); + + res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "pdf"); + anhi->pdf_base =3D devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(anhi->pdf_base)) { + ret =3D dev_err_probe(&pdev->dev, PTR_ERR(anhi->pdf_base), + "Unable to map PDF regs\n"); + goto err; + } + + ret =3D apple_nhi_probe_irqs(anhi); + if (ret) + goto err; + + spin_lock_init(&anhi->nhi.lock); + anhi->nhi.iommu_dma_protection =3D true; + anhi->nhi.ops =3D &apple_nhi_ops; + anhi->nhi.ring_layout =3D &apple_nhi_ring_layout; + anhi->nhi.iobase =3D anhi->nhi_base; + anhi->nhi.quirks =3D QUIRK_NO_DMA_PORT | QUIRK_NO_USB3_BW_ALLOC; + + anhi->nhi.hop_count =3D readl(anhi->nhi_base + APPLE_CIO_NHI_HOP_COUNT) & + APPLE_CIO_NHI_HOP_COUNT_MASK; + if (anhi->nhi.hop_count !=3D anhi->n_rings) { + ret =3D dev_err_probe(anhi->dev, -EINVAL, "Ring IRQs (%zd) !=3D HOP_COUN= T (%d)\n", + anhi->n_rings, anhi->nhi.hop_count); + goto err; + } + + anhi->nhi.tx_rings =3D devm_kcalloc(&pdev->dev, anhi->nhi.hop_count, + sizeof(*anhi->nhi.tx_rings), GFP_KERNEL); + anhi->nhi.rx_rings =3D devm_kcalloc(&pdev->dev, anhi->nhi.hop_count, + sizeof(*anhi->nhi.rx_rings), GFP_KERNEL); + if (!anhi->nhi.tx_rings || !anhi->nhi.rx_rings) { + ret =3D -ENOMEM; + goto err; + } + + anhi->nhi.dev =3D &pdev->dev; + init_completion(&anhi->nhi.domain_released); + anhi->tb =3D tb_probe(&anhi->nhi); + if (!anhi->tb) { + ret =3D dev_err_probe(anhi->dev, -ENODEV, + "Failed to init software connection manager\n"); + goto err; + } + + ret =3D tb_domain_add(anhi->tb, false); + if (ret) { + dev_err_probe(anhi->dev, ret, "failed to add TB domain\n"); + tb_domain_put(anhi->tb); + wait_for_completion(&anhi->nhi.domain_released); + goto err; + } + + mutex_lock(&anhi->tb->lock); + + if (!anhi->tb->root_switch->drom) { + dev_err(anhi->dev, "No valid host DROM in the device tree\n"); + ret =3D -EINVAL; + goto err_unlock_tb_domain; + } + + cap_apple =3D tb_switch_find_vse_cap(anhi->tb->root_switch, TB_VSE_CAP_AP= PLE); + + if (cap_apple < 0) { + dev_err(anhi->dev, "Unable to find VSE Apple capability: %d\n", + cap_apple); + ret =3D cap_apple; + goto err_unlock_tb_domain; + } + + /* + * The ports are locked after reset. Unlock them before writing the cable= information which + * will bring up the link and start the first scan such that XDomain resp= onses are not + * rejected by our own router. + */ + tb_switch_for_each_port(anhi->tb->root_switch, port) { + if (!tb_port_is_null(port)) + continue; + ret =3D tb_port_unlock(port); + if (ret) + dev_warn(anhi->dev, "Failed to unlock port %d: %d\n", + port->port, ret); + } + + ret =3D tb_sw_write(anhi->tb->root_switch, &acio->target_cable_info, TB_C= FG_SWITCH, + cap_apple + TB_VSE_CAP_APPLE_CABLE_INFO, 1); + if (ret) { + dev_warn(anhi->dev, "Setting VSE Apple cable info failed: %d\n", ret); + goto err_unlock_tb_domain; + } + + mutex_unlock(&anhi->tb->lock); + + acio->nhi_boot_status =3D 0; + complete(&acio->nhi_boot_completion); + return 0; + +err_unlock_tb_domain: + mutex_unlock(&anhi->tb->lock); + tb_domain_remove(anhi->tb); + wait_for_completion(&anhi->nhi.domain_released); +err: + acio->nhi_boot_status =3D ret; + complete(&acio->nhi_boot_completion); + return ret; +} + +static void apple_nhi_remove(struct platform_device *pdev) +{ + struct apple_nhi *anhi =3D platform_get_drvdata(pdev); + + tb_domain_remove(anhi->tb); + wait_for_completion(&anhi->nhi.domain_released); +} + +static const struct of_device_id apple_nhi_match[] =3D { + { + .compatible =3D "apple,t8103-usb4-nhi", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, apple_nhi_match); + +static struct platform_driver apple_nhi_driver =3D { + .driver =3D { + .name =3D "thunderbolt-apple-nhi", + .of_match_table =3D apple_nhi_match, + }, + .probe =3D apple_nhi_probe, + .remove =3D apple_nhi_remove, +}; + +/** + * apple_cio_stop - Stop and power down the ACIO complex + * @acio: ACIO complex to stop + * + * Remove the NHI and DART children before shutting down the co-processor = and + * dropping the power-domain links. The Type-C PHY must remain configured + * until this function returns. The caller must hold @acio->lock. + */ +static void apple_cio_stop(struct apple_cio *acio) +{ + int ret, i; + + lockdep_assert_held(&acio->lock); + + /* + * First, shutdown the blocks inside the ACIO complex, like the NHI and t= he IOMMU. + * After we shut down the ACIO co-processor we will no longer be able to = access + * the MMIO space of these so make sure nothing tries to do just that. + */ + of_platform_depopulate(acio->dev); + + /* Try to shut down and power off the co-processor gracefully */ + ret =3D apple_rtkit_poweroff(acio->rtk); + if (ret) + dev_warn(acio->dev, + "Failed to shutdown M3 RTKit, continuing ACIO shutdown anyway\n"); + apple_rtkit_free(acio->rtk); + + /* Finally, remove the links to the PD domains to power everything off */ + for (i =3D 0; i < acio->pd_list->num_pds; i++) { + if (acio->pd_list->pd_links[i]) + device_link_del(acio->pd_list->pd_links[i]); + acio->pd_list->pd_links[i] =3D NULL; + } + + acio->current_cable_info =3D 0; +} + +/** + * apple_cio_start - Power up and start the ACIO complex + * @acio: ACIO complex to start + * + * The Type-C PHY must already be configured for USB4 or Thunderbolt. Powe= r up + * ACIO, boot its RTKit co-processor, populate its child devices and wait = for + * the NHI to register the USB4 domain. All completed steps are unwound on + * failure. The caller must hold @acio->lock. + * + * Return: 0 on success or a negative error code on failure. + */ +static int apple_cio_start(struct apple_cio *acio) +{ + struct device_link *link; + int i, ret; + u32 state; + + lockdep_assert_held(&acio->lock); + + /* Create device links to the power domains in order to power them on */ + for (i =3D 0; i < acio->pd_list->num_pds; i++) { + link =3D device_link_add(acio->dev, acio->pd_list->pd_devs[i], + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); + if (!link) { + ret =3D -ENODEV; + goto remove_links; + } + acio->pd_list->pd_links[i] =3D link; + } + + /* + * After the power domains are on we need to signal and wait for the ACIO= block + * to actually start before we can bring up the co-processor. + */ + ret =3D reset_control_deassert(acio->reset); + if (ret) { + dev_err(acio->dev, "ACIO block failed to start: %d\n", ret); + goto remove_links; + } + + /* Start and wait for the co-processor to boot */ + writel(APPLE_CIO_M3_CTRL_START, acio->rc_base + APPLE_CIO_M3_CTRL); + acio->rtk =3D apple_rtkit_init(acio->dev, acio, NULL, 0, &apple_cio_rtkit= _ops); + if (IS_ERR(acio->rtk)) { + ret =3D PTR_ERR(acio->rtk); + dev_err(acio->dev, "Failed to initialize RTKit: %d\n", ret); + goto remove_links; + } + + ret =3D apple_rtkit_boot(acio->rtk); + if (ret) { + dev_err(acio->dev, "M3 RTKit failed to boot: %d\n", ret); + goto err_free_rtkit; + } + + ret =3D readl_poll_timeout(acio->rc_base + APPLE_CIO_M3_STAT, state, + state & APPLE_CIO_M3_STAT_STATE, 100, 500000); + if (ret < 0) { + dev_err(acio->dev, "M3 firmware failed to get ready: %d\n", ret); + goto err_shutdown_rtkit; + } + + apple_tunable_apply(acio->rc_base, acio->rc_tunable); + + /* + * Bring up devices which are part of ACIO and are now accessible by the = main SoC + * and specifically wait for the NHI to be up to prevent concurrent shutd= owns. + */ + reinit_completion(&acio->nhi_boot_completion); + ret =3D of_platform_populate(acio->np, NULL, NULL, acio->dev); + if (ret) { + dev_err(acio->dev, "failed to populate children: %d\n", ret); + goto err_depopulate; + } + + if (!wait_for_completion_timeout(&acio->nhi_boot_completion, + msecs_to_jiffies(APPLE_CIO_NHI_BOOT_TIMEOUT_MS))) { + dev_err(acio->dev, "Timed out waiting for the NHI to come up\n"); + ret =3D -ETIMEDOUT; + goto err_depopulate; + } + if (acio->nhi_boot_status) { + ret =3D acio->nhi_boot_status; + goto err_depopulate; + } + + acio->current_cable_info =3D acio->target_cable_info; + return 0; + +err_depopulate: + of_platform_depopulate(acio->dev); +err_shutdown_rtkit: + /* Ignore errors here since we're about to cut power to the entire block = anyway */ + apple_rtkit_poweroff(acio->rtk); +err_free_rtkit: + apple_rtkit_free(acio->rtk); +remove_links: + /* Cut power to reset the entire block */ + for (i =3D 0; i < acio->pd_list->num_pds; i++) { + if (acio->pd_list->pd_links[i]) + device_link_del(acio->pd_list->pd_links[i]); + acio->pd_list->pd_links[i] =3D NULL; + } + return ret; +} + +/** + * apple_cio_tbt_switch_set - Handle a USB4/Thunderbolt cable transition + * @sw: USB4/Thunderbolt switch + * @data: New cable state and negotiated cable details + * + * Translate the cable details into the Apple host-router representation a= nd + * synchronously power ACIO up or down. The Type-C PD driver must configure + * the PHY before an active transition and must request the inactive state + * before shutting the PHY down. + * + * Return: 0 on success or a negative error code on failure. + */ +static int apple_cio_tbt_switch_set(struct typec_thunderbolt_switch_dev *s= w, + const struct typec_thunderbolt_switch_data *data) +{ + struct apple_cio *acio =3D typec_thunderbolt_switch_get_drvdata(sw); + + guard(mutex)(&acio->lock); + + dev_dbg(acio->dev, "set cable state: %d\n", data->state); + + switch (data->state) { + case TYPEC_THUNDERBOLT_SWITCH_OFF: + acio->target_cable_info =3D 0; + break; + case TYPEC_THUNDERBOLT_SWITCH_TBT: + acio->target_cable_info =3D TB_VSE_CAP_APPLE_CABLE_INFO_PRESENT; + acio->target_cable_info |=3D TB_VSE_CAP_APPLE_CABLE_INFO_TBT2_3; + if (data->tbt.cable_mode & TBT_CABLE_ACTIVE_PASSIVE) { + acio->target_cable_info |=3D TB_VSE_CAP_APPLE_CABLE_INFO_ACTIVE_CABLE; + if (!(data->tbt.cable_mode & TBT_CABLE_LINK_TRAINING)) + acio->target_cable_info |=3D TB_VSE_CAP_APPLE_CABLE_INFO_BIDIR_LSRX; + } + /* bit 16 of the Device Discover Mode VDO is 1 for a legacy TBT2 adapter= */ + if (TBT_ADAPTER(data->tbt.device_mode)) + acio->target_cable_info |=3D TB_VSE_CAP_APPLE_CABLE_INFO_LEGACY_ADAPTER; + if (TBT_CABLE_SPEED(data->tbt.cable_mode) =3D=3D TBT_CABLE_10_AND_20GBPS) + acio->target_cable_info |=3D TB_VSE_CAP_APPLE_CABLE_INFO_20_GBPS; + if (data->orientation =3D=3D TYPEC_ORIENTATION_REVERSE) + acio->target_cable_info |=3D TB_VSE_CAP_APPLE_CABLE_INFO_ORIENTATION_RE= VERSE; + dev_dbg(acio->dev, + "TBT cable: cable_mode 0x%x, device_mode 0x%x, enter_vdo 0x%x, orientat= ion %d -> cable info 0x%x\n", + data->tbt.cable_mode, data->tbt.device_mode, + data->tbt.enter_vdo, data->orientation, + acio->target_cable_info); + break; + case TYPEC_THUNDERBOLT_SWITCH_USB4: + acio->target_cable_info =3D TB_VSE_CAP_APPLE_CABLE_INFO_PRESENT; + if (FIELD_GET(EUDO_CABLE_TYPE_MASK, data->usb4.eudo) !=3D EUDO_CABLE_TYP= E_PASSIVE) + acio->target_cable_info |=3D TB_VSE_CAP_APPLE_CABLE_INFO_ACTIVE_CABLE; + if (FIELD_GET(EUDO_CABLE_SPEED_MASK, data->usb4.eudo) =3D=3D EUDO_CABLE_= SPEED_USB4_GEN3) + acio->target_cable_info |=3D TB_VSE_CAP_APPLE_CABLE_INFO_20_GBPS; + if (data->orientation =3D=3D TYPEC_ORIENTATION_REVERSE) + acio->target_cable_info |=3D TB_VSE_CAP_APPLE_CABLE_INFO_ORIENTATION_RE= VERSE; + dev_dbg(acio->dev, "USB4 cable: eudo 0x%x, orientation %d -> cable info = 0x%x\n", + data->usb4.eudo, data->orientation, acio->target_cable_info); + break; + } + + if (acio->target_cable_info =3D=3D acio->current_cable_info) + return 0; + + /* + * Transitions between different cables without a shutdown inbetween are = invalid and can + * only happen when there's a bug inside the Type-C PD driver. If we trie= d such a + * transition, ACIO would crash and then trigger some watchdog that would= reset the entire + * SoC a few seconds later. Shutting down instead only makes the connecte= d device not work + * but we should be able to recover once the next cable is plugged in. + */ + if (acio->current_cable_info && acio->target_cable_info) { + dev_err(acio->dev, + "Invalid cable transition from 0x%x to 0x%x, shutting down instead\n", + acio->current_cable_info, acio->target_cable_info); + acio->target_cable_info =3D 0; + } + + /* + * Bring up or power down the ACIO complex + * current_cable_info will be updated in the start/stop functions + */ + if (acio->target_cable_info) + return apple_cio_start(acio); + + apple_cio_stop(acio); + return 0; +} + +static int apple_cio_probe(struct platform_device *pdev) +{ + struct device *dev =3D &pdev->dev; + struct apple_cio *acio; + int ret; + + acio =3D devm_kzalloc(dev, sizeof(*acio), GFP_KERNEL); + if (!acio) + return -ENOMEM; + platform_set_drvdata(pdev, acio); + + ret =3D devm_mutex_init(dev, &acio->lock); + if (ret) + return ret; + init_completion(&acio->nhi_boot_completion); + acio->dev =3D &pdev->dev; + acio->np =3D dev->of_node; + + acio->sram_res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "sr= am"); + if (!acio->sram_res) + return dev_err_probe(dev, -EIO, "Failed to get SRAM resource\n"); + acio->sram_base =3D devm_ioremap_resource(dev, acio->sram_res); + if (IS_ERR(acio->sram_base)) + return dev_err_probe(dev, PTR_ERR(acio->sram_base), "Failed to map SRAM\= n"); + + acio->rc_res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "rc"); + acio->rc_base =3D devm_ioremap_resource(&pdev->dev, acio->rc_res); + if (IS_ERR(acio->rc_base)) + return dev_err_probe(dev, PTR_ERR(acio->rc_base), "Unable to map rc regs= \n"); + acio->rc_tunable =3D + devm_apple_tunable_parse(dev, acio->np, "apple,tunable-rc", acio->rc_res= ); + if (IS_ERR(acio->rc_tunable)) + return dev_err_probe(dev, PTR_ERR(acio->rc_tunable), "Unable to load rc = tunable\n"); + + acio->reset =3D devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(acio->reset)) + return dev_err_probe(dev, PTR_ERR(acio->reset), "Unable to get CIO reset= \n"); + + /* + * If there is only a single domain listed in the device tree the platfor= m driver + * framework will already attach it. Thus, if we find an already attached= domain + * here something's wrong in the device tree because we expect at least t= hree separate + * domains that we have to control manually. + */ + if (dev->pm_domain) { + dev_err(dev, "PM domain already attached, check if the DT lists three do= mains\n"); + return -EINVAL; + } + + /* + * Find and attach the PM domains but don't power them on yet since we mu= st only + * do that after the PHY has already been configured into USB4/Thunderbol= t mode. + */ + struct dev_pm_domain_attach_data pd_data =3D { + .pd_flags =3D PD_FLAG_NO_DEV_LINK, + }; + ret =3D devm_pm_domain_attach_list(dev, &pd_data, &acio->pd_list); + if (ret < 0) + return dev_err_probe(dev, ret, "Unable to attach PM domains\n"); + else if (ret < 3) + return dev_err_probe(dev, -EINVAL, "Not enough PM domains\n"); + + /* And finally register the OOB notification for Thunderbolt/USB4 cables = */ + struct typec_thunderbolt_switch_desc desc =3D { + .fwnode =3D pdev->dev.fwnode, + .set =3D apple_cio_tbt_switch_set, + .drvdata =3D acio, + }; + acio->tbt_switch =3D typec_thunderbolt_switch_register(dev, &desc); + if (IS_ERR(acio->tbt_switch)) + return dev_err_probe(dev, PTR_ERR(acio->tbt_switch), + "Unable to register thunderbolt switch\n"); + + return 0; +} + +static void apple_cio_remove(struct platform_device *pdev) +{ + struct apple_cio *acio =3D platform_get_drvdata(pdev); + + typec_thunderbolt_switch_unregister(acio->tbt_switch); + + guard(mutex)(&acio->lock); + if (acio->current_cable_info) + apple_cio_stop(acio); +} + +static int apple_cio_prepare(struct device *dev) +{ + struct apple_cio *acio =3D dev_get_drvdata(dev); + + guard(mutex)(&acio->lock); + + if (acio->current_cable_info) { + dev_err(dev, "unable to suspend while a USB4/Thunderbolt connection is a= ctive\n"); + return -EBUSY; + } + + return 0; +} + +static const struct dev_pm_ops apple_cio_pm_ops =3D { + .prepare =3D apple_cio_prepare, +}; + +static const struct of_device_id apple_acio_match[] =3D { + { + .compatible =3D "apple,t8103-usb4-acio", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, apple_acio_match); + +static struct platform_driver apple_cio_driver =3D { + .driver =3D { + .name =3D "thunderbolt-apple-acio", + .of_match_table =3D apple_acio_match, + .pm =3D pm_sleep_ptr(&apple_cio_pm_ops), + }, + .probe =3D apple_cio_probe, + .remove =3D apple_cio_remove, +}; + +static struct platform_driver * const apple_cio_drivers[] =3D { + &apple_nhi_driver, + &apple_cio_driver, +}; + +static int __init apple_cio_init(void) +{ + return platform_register_drivers(apple_cio_drivers, + ARRAY_SIZE(apple_cio_drivers)); +} + +static void __exit apple_cio_exit(void) +{ + platform_unregister_drivers(apple_cio_drivers, + ARRAY_SIZE(apple_cio_drivers)); +} + +module_init(apple_cio_init); +module_exit(apple_cio_exit); + +MODULE_AUTHOR("Sven Peter "); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Apple Silicon USB4/Thunderbolt driver"); --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59C6633D4E5; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; cv=none; b=DiNCP0tZmDLzE/Hq+L8HANgh1IaeUjVbKcj/mCNuMlY4JzuaiomBJAcvfz1L+QtjfEl6FACg5Obu3JlAxZFzL47j7LL5WiUryfz6+0LbqZiFcZX0IZ1O01JkgGqG+/dMtGyQCykuiUFxfCYkdev3QuBtDFfBaRgtO1TwX2hibcE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; c=relaxed/simple; bh=xHB2RMEIRuUC1tkqVAKS8ePWA/oE9Q+EZ66Cil6jrIA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j764uXb6VtyW71PV58ckT2tILp/XhEyC+GerDp+gCzPaKIewnQM4QZ1IDHJNk6ZnX/TZr9LoO/4z1E8y0hbHYRp5a6Xd9omvHnXHQh96OJhklBo9Vr9HbZNobKmMbP1AoLLdGBlgVUdROlpH23dc9PB51A1ZZ1CN127ESibtndc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E1VRVcA6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E1VRVcA6" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1B6ACC4AF0D; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121185; bh=xHB2RMEIRuUC1tkqVAKS8ePWA/oE9Q+EZ66Cil6jrIA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=E1VRVcA6VgZyVR7mxRwJovyFbOB26LFEDoF5+AzC8IC1QXY4rVPCTPYF/PvkMtIG5 5cmhwIK8In5ANSFOG3WyGBMd+NaC5TWFvc2uY5KU94Rlne/PT1nuwUqm3yEgApjqm/ +8U6+FIA6Zxl+qYKSTUcxyrpm4cAXGQi96gBGyLSuVphnWTrPk3uKSL7/7xEZQV2/S 1xjSADf//NjRAQnCSiktZIBFQIBZysJoIQClB3iyEeJK26Ne9e9KMVHGZGre7PdABL CEUtOgO3ZjFm9aFx2DRiDj+W6lGpI6tVtVKlP7t+qaXEYwqNmr4rs3Swu0rZi+Of/X 3NUJaoA/ejp/g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4FCEC61DEB; Sun, 30 Aug 2026 20:19:44 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:35 +0200 Subject: [PATCH 17/19] arm64: dts: apple: t8103: Add USB4 ACIO and NHI Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-17-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=9328; i=sven@kernel.org; h=from:subject:message-id; bh=xHB2RMEIRuUC1tkqVAKS8ePWA/oE9Q+EZ66Cil6jrIA=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCdFvbvIc2PQ5vnZ5mYvRznUbX1y4dfhvWQ7PBnPLi NO79kp4d5SyMIhxMciKKbJs329v+uThG8Glmy69h5nDygQyhIGLUwAm0mLAyDChrUoia+GkhGOX F1/+1hsobp7pZSt/yqE+5d6m0HtmdtGMDA8Upzk/XVCjL6nH9v1zUc9ymRt7xJ6urTV2zvi8JeZ FPDsA X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Add the ACIO host router, NHI, DART and M3 mailbox nodes for both Type-C ports on t8103 and connect the host routers to the Type-C connectors. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- arch/arm64/boot/dts/apple/t8103-jxxx.dtsi | 61 ++++++++++ arch/arm64/boot/dts/apple/t8103.dtsi | 188 ++++++++++++++++++++++++++= ++++ 2 files changed, 249 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8103-jxxx.dtsi b/arch/arm64/boot/dt= s/apple/t8103-jxxx.dtsi index 686fb1dd215d..acdefa2a0084 100644 --- a/arch/arm64/boot/dts/apple/t8103-jxxx.dtsi +++ b/arch/arm64/boot/dts/apple/t8103-jxxx.dtsi @@ -17,6 +17,10 @@ aliases { wifi0 =3D &wifi0; atcphy0 =3D &atcphy0; atcphy1 =3D &atcphy1; + usb4-0-acio =3D &usb4_0_acio; + usb4-0-nhi =3D &usb4_0_nhi; + usb4-1-acio =3D &usb4_1_acio; + usb4-1-nhi =3D &usb4_1_nhi; }; =20 chosen { @@ -76,6 +80,13 @@ typec0_connector_ss: endpoint { remote-endpoint =3D <&atcphy0_typec_lanes>; }; }; + + port@2 { + reg =3D <2>; + typec0_con_tbt: endpoint { + remote-endpoint =3D <&usb4_0_acio_tbt>; + }; + }; }; }; }; @@ -107,6 +118,13 @@ typec1_connector_ss: endpoint { remote-endpoint =3D <&atcphy1_typec_lanes>; }; }; + + port@2 { + reg =3D <2>; + typec1_con_tbt: endpoint { + remote-endpoint =3D <&usb4_1_acio_tbt>; + }; + }; }; }; }; @@ -198,6 +216,49 @@ atcphy1_usb3: endpoint { }; }; =20 +/* USB4 */ +&usb4_0_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_0_acio_tbt: endpoint { + remote-endpoint =3D <&typec0_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_1_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_1_acio_tbt: endpoint { + remote-endpoint =3D <&typec1_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + /* * Force the bus number assignments so that we can declare some of the * on-board devices and properties that are populated by the bootloader diff --git a/arch/arm64/boot/dts/apple/t8103.dtsi b/arch/arm64/boot/dts/app= le/t8103.dtsi index 5b68bf0df4e6..f83ed8da9a42 100644 --- a/arch/arm64/boot/dts/apple/t8103.dtsi +++ b/arch/arm64/boot/dts/apple/t8103.dtsi @@ -982,6 +982,14 @@ pinctrl_aop: pinctrl@24a820000 { , , ; + + acio0_pins: acio0-pins { + pinmux =3D ; + }; + + acio1_pins: acio1-pins { + pinmux =3D ; + }; }; =20 ans_mbox: mbox@277408000 { @@ -1018,6 +1026,96 @@ nvme@27bcc0000 { resets =3D <&ps_ans2>; }; =20 + usb4_0_mbox: mailbox@381100000 { + compatible =3D "apple,t8103-m3-mailbox", + "apple,m3-mailbox-v2"; + reg =3D <0x3 0x81100000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + usb4_0_acio: cio@381ac0000 { + compatible =3D "apple,t8103-usb4-acio"; + reg =3D <0x3 0x81ac0000 0x0 0xc000>, + <0x3 0x81080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&usb4_0_mbox>; + resets =3D <&cio_reset 0>; + + power-domains =3D <&ps_atc0_cio>, + <&ps_atc0_cio_pcie>, + <&ps_atc0_cio_usb>; + + thunderbolt-switch; + + pinctrl-0 =3D <&acio0_pins>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0x3 0x81000000 0x1000000>; + nonposted-mmio; + + usb4_0_dart: iommu@a80000 { + compatible =3D "apple,t8103-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <1>; + }; + + usb4_0_nhi: nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&usb4_0_dart 1>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + dwc3_0: usb@382280000 { compatible =3D "apple,t8103-dwc3"; reg =3D <0x3 0x82280000 0x0 0xcd00>, <0x3 0x8228cd00 0x0 0x3200>; @@ -1070,6 +1168,96 @@ atcphy0: phy@383000000 { power-domains =3D <&ps_atc0_usb>; }; =20 + usb4_1_mbox: mailbox@501100000 { + compatible =3D "apple,t8103-m3-mailbox", + "apple,m3-mailbox-v2"; + reg =3D <0x5 0x01100000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + usb4_1_acio: cio@501ac0000 { + compatible =3D "apple,t8103-usb4-acio"; + reg =3D <0x5 0x01ac0000 0x0 0xc000>, + <0x5 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&usb4_1_mbox>; + resets =3D <&cio_reset 1>; + + power-domains =3D <&ps_atc1_cio>, + <&ps_atc1_cio_pcie>, + <&ps_atc1_cio_usb>; + + thunderbolt-switch; + + pinctrl-0 =3D <&acio1_pins>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0x5 0x01000000 0x1000000>; + nonposted-mmio; + + usb4_1_dart: iommu@a80000 { + compatible =3D "apple,t8103-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <1>; + }; + + usb4_1_nhi: nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&usb4_1_dart 1>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + dwc3_1: usb@502280000 { compatible =3D "apple,t8103-dwc3"; reg =3D <0x5 0x02280000 0x0 0xcd00>, <0x5 0x0228cd00 0x0 0x3200>; --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53E1233D4E2; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; cv=none; b=UPn/bk8PlArWgdbZ2n0GyBlb8BuxmFm3P/ZPYO9IkXBfqVIwe57lfTBLpMGV4o99LcNkjsJTJlunvta0MfHLSzAvRmHzqwCm9lOtUrYZ0+kFyo5NwcyrDJTfVczzNkStZjvIxPEAvaHLAwTY6Vti8Aiqmhqf6VcOl3f48L2bwmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; c=relaxed/simple; bh=n09gEtKDU3kUfCkG/4ZObWdAvjMCTwg8iRZ5g0KE5yE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MRXM3IZeP2oOWAvLulMiLJG3ltDJ9du5rl3rfassQ2FVwOumZTS6FFv6X94UeLmjAieBXlSTUHCeGRp5mKOMRt8TCGmrcAdF3MeKmfo2yETMyXWt8rx74nfvaxxWisGIXf+WHDLikCjSlrbyEm6dq7ue5n5KER/jLLRv+66sLDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XP3N2Hd/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XP3N2Hd/" Received: by smtp.kernel.org (Postfix) with ESMTPS id 19DE9C4AF10; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121185; bh=n09gEtKDU3kUfCkG/4ZObWdAvjMCTwg8iRZ5g0KE5yE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XP3N2Hd/924sn940ev1X7kq3DYePEPpkG9jL3oVoFkC4OGImGVECuRpauPgQBAdem 4bGJhBvBRv2VAFwVPGHxOJXRzisvN5imU5dm3zaV7c7EYXdFurt7VKlwyb88mVkSxG y9mDn4JJOpe1KbPIxU2p5BVvsRDsg5TaaD+OuqmRzBHljhbt6aTr4GfJK6SWozqGMa b2cyO/8CMQ8X8462mDUL7Jp4PWgJ/Se+TFM8LZYN2yh1ZNOzsjA9nTFzuqme9e3IhY JgC6pzUaTJCxQrm/7LXaJPcZq3uSqXgH+knYuja5y5C8LHnh8xI5B7wkw2+yoJ3AyE ENNEWjZdCpGIg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 014A4C61DD9; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:36 +0200 Subject: [PATCH 18/19] arm64: dts: apple: t8112: Add USB4 ACIO and NHI Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-18-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=9440; i=sven@kernel.org; h=from:subject:message-id; bh=n09gEtKDU3kUfCkG/4ZObWdAvjMCTwg8iRZ5g0KE5yE=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCdEXZnuFba1cGsBm9niP36ofxoKlW7YqJdXfmqnTv vageIx5RykLgxgXg6yYIsv2/famTx6+EVy66dJ7mDmsTCBDGLg4BeAirgz/E2vS9d5vEzfIyVls Nl3n3IGPu35vX9K5y22h+fZnohET5Bn+lwZK/PhrumHlIuabHnKdbyxYWtcKPC+Xn8A6M/PEat1 tTAA= X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Add the ACIO host router, NHI, DART and mailbox nodes for both Type-C ports on t8112 and connect the host routers to the Type-C connectors. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- arch/arm64/boot/dts/apple/t8112-jxxx.dtsi | 61 ++++++++++ arch/arm64/boot/dts/apple/t8112.dtsi | 190 ++++++++++++++++++++++++++= ++++ 2 files changed, 251 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8112-jxxx.dtsi b/arch/arm64/boot/dt= s/apple/t8112-jxxx.dtsi index 562e7a25a1e8..4c9654f169f4 100644 --- a/arch/arm64/boot/dts/apple/t8112-jxxx.dtsi +++ b/arch/arm64/boot/dts/apple/t8112-jxxx.dtsi @@ -13,6 +13,10 @@ / { aliases { atcphy0 =3D &atcphy0; atcphy1 =3D &atcphy1; + usb4-0-acio =3D &usb4_0_acio; + usb4-0-nhi =3D &usb4_0_nhi; + usb4-1-acio =3D &usb4_1_acio; + usb4-1-nhi =3D &usb4_1_nhi; serial0 =3D &serial0; serial2 =3D &serial2; }; @@ -76,6 +80,13 @@ typec0_connector_ss: endpoint { remote-endpoint =3D <&atcphy0_typec_lanes>; }; }; + + port@2 { + reg =3D <2>; + typec0_con_tbt: endpoint { + remote-endpoint =3D <&usb4_0_acio_tbt>; + }; + }; }; }; }; @@ -107,6 +118,13 @@ typec1_connector_ss: endpoint { remote-endpoint =3D <&atcphy1_typec_lanes>; }; }; + + port@2 { + reg =3D <2>; + typec1_con_tbt: endpoint { + remote-endpoint =3D <&usb4_1_acio_tbt>; + }; + }; }; }; }; @@ -198,6 +216,49 @@ atcphy1_usb3: endpoint { }; }; =20 +/* USB4 */ +&usb4_0_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_0_acio_tbt: endpoint { + remote-endpoint =3D <&typec0_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_1_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_1_acio_tbt: endpoint { + remote-endpoint =3D <&typec1_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + &i2c1 { status =3D "okay"; }; diff --git a/arch/arm64/boot/dts/apple/t8112.dtsi b/arch/arm64/boot/dts/app= le/t8112.dtsi index ec248ca052cb..735ca3b8b716 100644 --- a/arch/arm64/boot/dts/apple/t8112.dtsi +++ b/arch/arm64/boot/dts/apple/t8112.dtsi @@ -985,6 +985,14 @@ pinctrl_aop: pinctrl@24a820000 { , , ; + + acio0_pins: acio0-pins { + pinmux =3D ; + }; + + acio1_pins: acio1-pins { + pinmux =3D ; + }; }; =20 ans_mbox: mbox@277408000 { @@ -1021,6 +1029,97 @@ nvme@27bcc0000 { resets =3D <&ps_ans>; }; =20 + usb4_0_mbox: mailbox@381108000 { + compatible =3D "apple,t8112-asc-mailbox", + "apple,asc-mailbox-v4"; + reg =3D <0x3 0x81108000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + usb4_0_acio: cio@381ac0000 { + compatible =3D "apple,t8112-usb4-acio", "apple,t8103-usb4-acio"; + reg =3D <0x3 0x81ac0000 0x0 0xc000>, + <0x3 0x81080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&usb4_0_mbox>; + resets =3D <&cio_reset 0>; + + power-domains =3D <&ps_atc0_cio>, + <&ps_atc0_cio_pcie>, + <&ps_atc0_cio_usb>; + + thunderbolt-switch; + + pinctrl-0 =3D <&acio0_pins>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0x3 0x81000000 0x1000000>; + nonposted-mmio; + + usb4_0_dart: iommu@a80000 { + compatible =3D "apple,t8110-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <1>; + }; + + usb4_0_nhi: nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t8112-usb4-nhi", + "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&usb4_0_dart 1>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + dwc3_0: usb@382280000 { compatible =3D "apple,t8112-dwc3", "apple,t8103-dwc3"; reg =3D <0x3 0x82280000 0x0 0xcd00>, <0x3 0x8228cd00 0x0 0x3200>; @@ -1073,6 +1172,97 @@ atcphy0: phy@383000000 { power-domains =3D <&ps_atc0_usb>; }; =20 + usb4_1_mbox: mailbox@501108000 { + compatible =3D "apple,t8112-asc-mailbox", + "apple,asc-mailbox-v4"; + reg =3D <0x5 0x01108000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + usb4_1_acio: cio@501ac0000 { + compatible =3D "apple,t8112-usb4-acio", "apple,t8103-usb4-acio"; + reg =3D <0x5 0x01ac0000 0x0 0xc000>, + <0x5 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&usb4_1_mbox>; + resets =3D <&cio_reset 1>; + + power-domains =3D <&ps_atc1_cio>, + <&ps_atc1_cio_pcie>, + <&ps_atc1_cio_usb>; + + thunderbolt-switch; + + pinctrl-0 =3D <&acio1_pins>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0x5 0x01000000 0x1000000>; + nonposted-mmio; + + usb4_1_dart: iommu@a80000 { + compatible =3D "apple,t8110-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <1>; + }; + + usb4_1_nhi: nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t8112-usb4-nhi", + "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&usb4_1_dart 1>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + dwc3_1: usb@502280000 { compatible =3D "apple,t8112-dwc3", "apple,t8103-dwc3"; reg =3D <0x5 0x02280000 0x0 0xcd00>, <0x5 0x0228cd00 0x0 0x3200>; --=20 2.55.0 From nobody Sat Sep 26 20:29:51 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C35533F8BC; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; cv=none; b=upUDiHb8OekxwqdeN8kLYBXt+cn4EUVEjdhEi0MsrrGx2D7Z/K2dygxWI+5W2HY/kVcKlXVvDKdNczp5m/1dX/w8b28Y3s2fYYdiwDhxItlLyNwJO9xNHq8k6DUX2IR4jjU75IaZ6yzYHET5gYVat0H9qP47cIr1rHziJ6rw3qQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788121185; c=relaxed/simple; bh=kvqEJzhyBP8e9k9bLDm5TDD8YdXBcUaHaKuYwtfBii0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eRVPmGeGr2i+PyuSap8Ub0WfnhEIOEGrxPF2uKkFMdewE/kLDwEelcOqKs3V+WDQ7m6x9Yp6jg0DMcCgBszRsgJK1GzxLcfk6nkPMd5ibPnHknRD2ep0HlL20ckOaTRYqCJATe8nx25Q2PDYhnnVrNWfuqhnvp3OqfOJ5EXinYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tk4ZibU7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Tk4ZibU7" Received: by smtp.kernel.org (Postfix) with ESMTPS id 35D8BC4AF54; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1788121185; bh=kvqEJzhyBP8e9k9bLDm5TDD8YdXBcUaHaKuYwtfBii0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Tk4ZibU7pvUC8NmMedzXP4mlWiGXkUFON1UXB4V4SeKm/4i2joO6Utimi1qg3EXo3 df6FZz79k1Hde+yUJixQkWq8+9IUMY8IHrfz390P9q5OYTovtrzdxrD9H6MyQRphAk NebfBxKNxbzymXlX5nqMwTuAyvMIAmuXKCo65JGPR4AcH3FGn4gENNEpxAnrz5yVQg C59ygsBSYWZVUiclbFou0ULher6smUUO9hfBf1sC3TdfheQ+4Tyoyvk442nUtnwMll hdobIlObQhYkSDVRMlnorxU6E9BaJ7IzV3Zh8qoW0f73twdVWqlZ1xAKQFaTS6aatu bLW9+JiHYa1nw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16AFCC61DFD; Sun, 30 Aug 2026 20:19:45 +0000 (UTC) From: Sven Peter Date: Sun, 30 Aug 2026 22:19:37 +0200 Subject: [PATCH 19/19] arm64: dts: apple: t60xx: Add USB4 ACIO and NHI Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260830-b4-apple-soc-tbt-v1-19-44bc9348683c@kernel.org> References: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> In-Reply-To: <20260830-b4-apple-soc-tbt-v1-0-44bc9348683c@kernel.org> To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heikki Krogerus , Janne Grunau , Neal Gompa , Andreas Noever , Mika Westerberg , Yehezkel Bernat , Philipp Zabel Cc: Konrad Dybcio , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Sven Peter X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=45620; i=sven@kernel.org; h=from:subject:message-id; bh=kvqEJzhyBP8e9k9bLDm5TDD8YdXBcUaHaKuYwtfBii0=; b=owGbwMvMwCXmIlirolUq95LxtFoSQ9aUCTHWFT+W/cj8o8Is3z+/8ZPSHv0DAYaTcvzf+M77U vN3te3UjlIWBjEuBlkxRZbt++1Nnzx8I7h006X3MHNYmUCGMHBxCsBE3qxkZPg29yF75jEvucz1 OvuZSp5Mmhqk/GR7Ua7F4xKVM1K7Hz1l+Gdpef6k86QLF19dvDxB8ibrwiNqaxPEq5PZ9m3dWfO bx4YNAA== X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 Add the ACIO host router, NHI, DART and mailbox nodes for the four ATC instances on each t600x and t602x die and connect the host routers to the Type-C connectors on the MacBook Pro (j314/j316 and j414/j416), Mac Studio (j375 and j475), Mac mini (j474) and Mac Pro (j180d) boards. Signed-off-by: Sven Peter Reviewed-by: Joshua Peisach --- arch/arm64/boot/dts/apple/t6002-j375d.dts | 67 +++++ arch/arm64/boot/dts/apple/t600x-dieX.dtsi | 384 +++++++++++++++++++++= ++++ arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi | 107 +++++++ arch/arm64/boot/dts/apple/t600x-j375.dtsi | 137 +++++++++ arch/arm64/boot/dts/apple/t6022-j180d.dts | 202 +++++++++++++ arch/arm64/boot/dts/apple/t6022-j475d.dts | 10 + arch/arm64/boot/dts/apple/t6022-jxxxd.dtsi | 57 ++++ arch/arm64/boot/dts/apple/t602x-dieX.dtsi | 384 +++++++++++++++++++++= ++++ 8 files changed, 1348 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6002-j375d.dts b/arch/arm64/boot/dt= s/apple/t6002-j375d.dts index e6eb6b6c386d..c28f5c604550 100644 --- a/arch/arm64/boot/dts/apple/t6002-j375d.dts +++ b/arch/arm64/boot/dts/apple/t6002-j375d.dts @@ -18,6 +18,10 @@ / { aliases { atcphy4 =3D &atcphy0_die1; atcphy5 =3D &atcphy1_die1; + usb4-4-acio =3D &usb4_0_acio_die1; + usb4-4-nhi =3D &usb4_0_nhi_die1; + usb4-5-acio =3D &usb4_1_acio_die1; + usb4-5-nhi =3D &usb4_1_nhi_die1; }; }; =20 @@ -52,6 +56,13 @@ typec4_connector_ss: endpoint { remote-endpoint =3D <&atcphy4_typec_lanes>; }; }; + + port@2 { + reg =3D <2>; + typec4_con_tbt: endpoint { + remote-endpoint =3D <&usb4_4_acio_tbt>; + }; + }; }; }; }; @@ -85,6 +96,13 @@ typec5_connector_ss: endpoint { remote-endpoint =3D <&atcphy5_typec_lanes>; }; }; + + port@2 { + reg =3D <2>; + typec5_con_tbt: endpoint { + remote-endpoint =3D <&usb4_5_acio_tbt>; + }; + }; }; }; }; @@ -186,8 +204,57 @@ atcphy5_usb3: endpoint { =20 #include "hwmon-fan-dual.dtsi" =20 +/* USB4 on die 1 */ +&usb4_0_acio_die1 { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_4_acio_tbt: endpoint { + remote-endpoint =3D <&typec4_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_1_acio_die1 { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_5_acio_tbt: endpoint { + remote-endpoint =3D <&typec5_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + /* delete unused USB nodes on die 1 */ =20 +/delete-node/ &usb4_2_acio_die1; +/delete-node/ &usb4_2_mbox_die1; + +/delete-node/ &usb4_3_acio_die1; +/delete-node/ &usb4_3_mbox_die1; + /delete-node/ &dwc3_2_dart_0_die1; /delete-node/ &dwc3_2_dart_1_die1; /delete-node/ &dwc3_2_die1; diff --git a/arch/arm64/boot/dts/apple/t600x-dieX.dtsi b/arch/arm64/boot/dt= s/apple/t600x-dieX.dtsi index 9676d5127039..98867855454d 100644 --- a/arch/arm64/boot/dts/apple/t600x-dieX.dtsi +++ b/arch/arm64/boot/dts/apple/t600x-dieX.dtsi @@ -93,6 +93,22 @@ DIE_NODE(pinctrl_aop): pinctrl@293820000 { , , ; + + DIE_NODE(acio0_pins): acio0-pins { + pinmux =3D ; + }; + + DIE_NODE(acio1_pins): acio1-pins { + pinmux =3D ; + }; + + DIE_NODE(acio2_pins): acio2-pins { + pinmux =3D ; + }; + + DIE_NODE(acio3_pins): acio3-pins { + pinmux =3D ; + }; }; =20 DIE_NODE(pinctrl_ap): pinctrl@39b028000 { @@ -120,6 +136,98 @@ DIE_NODE(pinctrl_ap): pinctrl@39b028000 { #interrupt-cells =3D <2>; }; =20 + DIE_NODE(usb4_0_mbox): mailbox@701100000 { + compatible =3D "apple,t6000-m3-mailbox", + "apple,m3-mailbox-v2"; + reg =3D <0x7 0x01100000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + DIE_NODE(usb4_0_acio): cio@701ac0000 { + compatible =3D "apple,t6000-usb4-acio", "apple,t8103-usb4-acio"; + reg =3D <0x7 0x01ac0000 0x0 0xc000>, + <0x7 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&DIE_NODE(usb4_0_mbox)>; + resets =3D <&DIE_NODE(cio_reset) 0>; + + power-domains =3D <&DIE_NODE(ps_atc0_cio)>, + <&DIE_NODE(ps_atc0_cio_pcie)>, + <&DIE_NODE(ps_atc0_cio_usb)>; + + thunderbolt-switch; + + pinctrl-0 =3D <&DIE_NODE(acio0_pins)>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0x7 0x01000000 0x1000000>; + nonposted-mmio; + + DIE_NODE(usb4_0_dart): iommu@a80000 { + compatible =3D "apple,t6000-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <1>; + }; + + DIE_NODE(usb4_0_nhi): nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t6000-usb4-nhi", + "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&DIE_NODE(usb4_0_dart) 1>, + <&DIE_NODE(usb4_0_dart) 2>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + DIE_NODE(dwc3_0): usb@702280000 { compatible =3D "apple,t6000-dwc3", "apple,t8103-dwc3"; reg =3D <0x7 0x02280000 0x0 0xcd00>, <0x7 0x0228cd00 0x0 0x3200>; @@ -173,6 +281,98 @@ DIE_NODE(atcphy0): phy@703000000 { power-domains =3D <&DIE_NODE(ps_atc0_usb)>; }; =20 + DIE_NODE(usb4_1_mbox): mailbox@b01100000 { + compatible =3D "apple,t6000-m3-mailbox", + "apple,m3-mailbox-v2"; + reg =3D <0xb 0x01100000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + DIE_NODE(usb4_1_acio): cio@b01ac0000 { + compatible =3D "apple,t6000-usb4-acio", "apple,t8103-usb4-acio"; + reg =3D <0xb 0x01ac0000 0x0 0xc000>, + <0xb 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&DIE_NODE(usb4_1_mbox)>; + resets =3D <&DIE_NODE(cio_reset) 1>; + + power-domains =3D <&DIE_NODE(ps_atc1_cio)>, + <&DIE_NODE(ps_atc1_cio_pcie)>, + <&DIE_NODE(ps_atc1_cio_usb)>; + + thunderbolt-switch; + + pinctrl-0 =3D <&DIE_NODE(acio1_pins)>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0xb 0x01000000 0x1000000>; + nonposted-mmio; + + DIE_NODE(usb4_1_dart): iommu@a80000 { + compatible =3D "apple,t6000-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <1>; + }; + + DIE_NODE(usb4_1_nhi): nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t6000-usb4-nhi", + "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&DIE_NODE(usb4_1_dart) 1>, + <&DIE_NODE(usb4_1_dart) 2>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + DIE_NODE(dwc3_1): usb@b02280000 { compatible =3D "apple,t6000-dwc3", "apple,t8103-dwc3"; reg =3D <0xb 0x02280000 0x0 0xcd00>, <0xb 0x0228cd00 0x0 0x3200>; @@ -226,6 +426,98 @@ DIE_NODE(atcphy1): phy@b03000000 { power-domains =3D <&DIE_NODE(ps_atc1_usb)>; }; =20 + DIE_NODE(usb4_2_mbox): mailbox@f01100000 { + compatible =3D "apple,t6000-m3-mailbox", + "apple,m3-mailbox-v2"; + reg =3D <0xf 0x01100000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + DIE_NODE(usb4_2_acio): cio@f01ac0000 { + compatible =3D "apple,t6000-usb4-acio", "apple,t8103-usb4-acio"; + reg =3D <0xf 0x01ac0000 0x0 0xc000>, + <0xf 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&DIE_NODE(usb4_2_mbox)>; + resets =3D <&DIE_NODE(cio_reset) 2>; + + power-domains =3D <&DIE_NODE(ps_atc2_cio)>, + <&DIE_NODE(ps_atc2_cio_pcie)>, + <&DIE_NODE(ps_atc2_cio_usb)>; + + thunderbolt-switch; + + pinctrl-0 =3D <&DIE_NODE(acio2_pins)>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0xf 0x01000000 0x1000000>; + nonposted-mmio; + + DIE_NODE(usb4_2_dart): iommu@a80000 { + compatible =3D "apple,t6000-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <1>; + }; + + DIE_NODE(usb4_2_nhi): nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t6000-usb4-nhi", + "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&DIE_NODE(usb4_2_dart) 1>, + <&DIE_NODE(usb4_2_dart) 2>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + DIE_NODE(dwc3_2): usb@f02280000 { compatible =3D "apple,t6000-dwc3", "apple,t8103-dwc3"; reg =3D <0xf 0x02280000 0x0 0xcd00>, <0xf 0x0228cd00 0x0 0x3200>; @@ -279,6 +571,98 @@ DIE_NODE(atcphy2): phy@f03000000 { power-domains =3D <&DIE_NODE(ps_atc2_usb)>; }; =20 + DIE_NODE(usb4_3_mbox): mailbox@1301100000 { + compatible =3D "apple,t6000-m3-mailbox", + "apple,m3-mailbox-v2"; + reg =3D <0x13 0x01100000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + DIE_NODE(usb4_3_acio): cio@1301ac0000 { + compatible =3D "apple,t6000-usb4-acio", "apple,t8103-usb4-acio"; + reg =3D <0x13 0x01ac0000 0x0 0xc000>, + <0x13 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&DIE_NODE(usb4_3_mbox)>; + resets =3D <&DIE_NODE(cio_reset) 3>; + + power-domains =3D <&DIE_NODE(ps_atc3_cio)>, + <&DIE_NODE(ps_atc3_cio_pcie)>, + <&DIE_NODE(ps_atc3_cio_usb)>; + + thunderbolt-switch; + + pinctrl-0 =3D <&DIE_NODE(acio3_pins)>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0x13 0x01000000 0x1000000>; + nonposted-mmio; + + DIE_NODE(usb4_3_dart): iommu@a80000 { + compatible =3D "apple,t6000-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <1>; + }; + + DIE_NODE(usb4_3_nhi): nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t6000-usb4-nhi", + "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&DIE_NODE(usb4_3_dart) 1>, + <&DIE_NODE(usb4_3_dart) 2>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + DIE_NODE(dwc3_3): usb@1302280000 { compatible =3D "apple,t6000-dwc3", "apple,t8103-dwc3"; reg =3D <0x13 0x02280000 0x0 0xcd00>, <0x13 0x0228cd00 0x0 0x3200>; diff --git a/arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi b/arch/arm64/bo= ot/dts/apple/t600x-j314-j316.dtsi index caded1636f3d..38b7d0c3a585 100644 --- a/arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi +++ b/arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi @@ -21,6 +21,12 @@ aliases { atcphy3 =3D &atcphy3; bluetooth0 =3D &bluetooth0; serial0 =3D &serial0; + usb4-0-acio =3D &usb4_0_acio; + usb4-0-nhi =3D &usb4_0_nhi; + usb4-1-acio =3D &usb4_1_acio; + usb4-1-nhi =3D &usb4_1_nhi; + usb4-2-acio =3D &usb4_2_acio; + usb4-2-nhi =3D &usb4_2_nhi; wifi0 =3D &wifi0; }; =20 @@ -366,6 +372,107 @@ &atcphy3 { status =3D "disabled"; }; =20 +&typec0 { + ports { + port@2 { + reg =3D <2>; + typec0_con_tbt: endpoint { + remote-endpoint =3D <&usb4_0_acio_tbt>; + }; + }; + }; +}; + +&typec1 { + ports { + port@2 { + reg =3D <2>; + typec1_con_tbt: endpoint { + remote-endpoint =3D <&usb4_1_acio_tbt>; + }; + }; + }; +}; + +&typec2 { + ports { + port@2 { + reg =3D <2>; + typec2_con_tbt: endpoint { + remote-endpoint =3D <&usb4_2_acio_tbt>; + }; + }; + }; +}; + +/* USB4 */ +&usb4_0_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_0_acio_tbt: endpoint { + remote-endpoint =3D <&typec0_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_1_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_1_acio_tbt: endpoint { + remote-endpoint =3D <&typec1_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_2_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_2_acio_tbt: endpoint { + remote-endpoint =3D <&typec2_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +/* ATC3 is used for DP-to-HDMI only and has no USB4 host router */ +/delete-node/ &usb4_3_acio; +/delete-node/ &usb4_3_mbox; + #include "spi1-nvram.dtsi" #include "hwmon-laptop.dtsi" #include "hwmon-fan-dual.dtsi" diff --git a/arch/arm64/boot/dts/apple/t600x-j375.dtsi b/arch/arm64/boot/dt= s/apple/t600x-j375.dtsi index 8a1494949e4c..d081cb03b03b 100644 --- a/arch/arm64/boot/dts/apple/t600x-j375.dtsi +++ b/arch/arm64/boot/dts/apple/t600x-j375.dtsi @@ -20,6 +20,14 @@ aliases { bluetooth0 =3D &bluetooth0; ethernet0 =3D ðernet0; serial0 =3D &serial0; + usb4-0-acio =3D &usb4_0_acio; + usb4-0-nhi =3D &usb4_0_nhi; + usb4-1-acio =3D &usb4_1_acio; + usb4-1-nhi =3D &usb4_1_nhi; + usb4-2-acio =3D &usb4_2_acio; + usb4-2-nhi =3D &usb4_2_nhi; + usb4-3-acio =3D &usb4_3_acio; + usb4-3-nhi =3D &usb4_3_nhi; wifi0 =3D &wifi0; }; =20 @@ -410,4 +418,133 @@ &pcie0_dart_3 { status =3D "okay"; }; =20 +&typec0 { + ports { + port@2 { + reg =3D <2>; + typec0_con_tbt: endpoint { + remote-endpoint =3D <&usb4_0_acio_tbt>; + }; + }; + }; +}; + +&typec1 { + ports { + port@2 { + reg =3D <2>; + typec1_con_tbt: endpoint { + remote-endpoint =3D <&usb4_1_acio_tbt>; + }; + }; + }; +}; + +&typec2 { + ports { + port@2 { + reg =3D <2>; + typec2_con_tbt: endpoint { + remote-endpoint =3D <&usb4_2_acio_tbt>; + }; + }; + }; +}; + +&typec3 { + ports { + port@2 { + reg =3D <2>; + typec3_con_tbt: endpoint { + remote-endpoint =3D <&usb4_3_acio_tbt>; + }; + }; + }; +}; + +/* USB4 */ +&usb4_0_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_0_acio_tbt: endpoint { + remote-endpoint =3D <&typec0_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_1_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_1_acio_tbt: endpoint { + remote-endpoint =3D <&typec1_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_2_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_2_acio_tbt: endpoint { + remote-endpoint =3D <&typec2_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_3_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_3_acio_tbt: endpoint { + remote-endpoint =3D <&typec3_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + #include "spi1-nvram.dtsi" diff --git a/arch/arm64/boot/dts/apple/t6022-j180d.dts b/arch/arm64/boot/dt= s/apple/t6022-j180d.dts index f76b887429dd..27323fb51dd1 100644 --- a/arch/arm64/boot/dts/apple/t6022-j180d.dts +++ b/arch/arm64/boot/dts/apple/t6022-j180d.dts @@ -26,6 +26,22 @@ aliases { atcphy5 =3D &atcphy1_die1; atcphy6 =3D &atcphy2_die1; atcphy7 =3D &atcphy3_die1; + usb4-0-acio =3D &usb4_0_acio; + usb4-0-nhi =3D &usb4_0_nhi; + usb4-1-acio =3D &usb4_1_acio; + usb4-1-nhi =3D &usb4_1_nhi; + usb4-2-acio =3D &usb4_2_acio; + usb4-2-nhi =3D &usb4_2_nhi; + usb4-3-acio =3D &usb4_3_acio; + usb4-3-nhi =3D &usb4_3_nhi; + usb4-4-acio =3D &usb4_0_acio_die1; + usb4-4-nhi =3D &usb4_0_nhi_die1; + usb4-5-acio =3D &usb4_1_acio_die1; + usb4-5-nhi =3D &usb4_1_nhi_die1; + usb4-6-acio =3D &usb4_2_acio_die1; + usb4-6-nhi =3D &usb4_2_nhi_die1; + usb4-7-acio =3D &usb4_3_acio_die1; + usb4-7-nhi =3D &usb4_3_nhi_die1; nvram =3D &nvram; serial0 =3D &serial0; }; @@ -152,6 +168,13 @@ typec6_connector_ss: endpoint { remote-endpoint =3D <&atcphy6_typec_lanes>; }; }; + + port@2 { + reg =3D <2>; + typec6_con_tbt: endpoint { + remote-endpoint =3D <&usb4_6_acio_tbt>; + }; + }; }; }; }; @@ -184,6 +207,13 @@ typec7_connector_ss: endpoint { remote-endpoint =3D <&atcphy7_typec_lanes>; }; }; + + port@2 { + reg =3D <2>; + typec7_con_tbt: endpoint { + remote-endpoint =3D <&usb4_7_acio_tbt>; + }; + }; }; }; }; @@ -535,4 +565,176 @@ &nco_clkref { clock-frequency =3D <1068000000>; }; =20 +/* USB4 on die 1 */ +&usb4_2_acio_die1 { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_6_acio_tbt: endpoint { + remote-endpoint =3D <&typec6_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_3_acio_die1 { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_7_acio_tbt: endpoint { + remote-endpoint =3D <&typec7_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&typec0 { + ports { + port@2 { + reg =3D <2>; + typec0_con_tbt: endpoint { + remote-endpoint =3D <&usb4_0_acio_tbt>; + }; + }; + }; +}; + +&typec1 { + ports { + port@2 { + reg =3D <2>; + typec1_con_tbt: endpoint { + remote-endpoint =3D <&usb4_1_acio_tbt>; + }; + }; + }; +}; + +&typec2 { + ports { + port@2 { + reg =3D <2>; + typec2_con_tbt: endpoint { + remote-endpoint =3D <&usb4_2_acio_tbt>; + }; + }; + }; +}; + +&typec3 { + ports { + port@2 { + reg =3D <2>; + typec3_con_tbt: endpoint { + remote-endpoint =3D <&usb4_3_acio_tbt>; + }; + }; + }; +}; + +/* USB4 */ +&usb4_0_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_0_acio_tbt: endpoint { + remote-endpoint =3D <&typec0_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_1_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_1_acio_tbt: endpoint { + remote-endpoint =3D <&typec1_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_2_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_2_acio_tbt: endpoint { + remote-endpoint =3D <&typec2_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_3_acio { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_3_acio_tbt: endpoint { + remote-endpoint =3D <&typec3_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + #include "spi1-nvram.dtsi" diff --git a/arch/arm64/boot/dts/apple/t6022-j475d.dts b/arch/arm64/boot/dt= s/apple/t6022-j475d.dts index 32938a3bf96a..d99633160beb 100644 --- a/arch/arm64/boot/dts/apple/t6022-j475d.dts +++ b/arch/arm64/boot/dts/apple/t6022-j475d.dts @@ -20,6 +20,10 @@ / { aliases { atcphy4 =3D &atcphy0_die1; atcphy5 =3D &atcphy1_die1; + usb4-4-acio =3D &usb4_0_acio_die1; + usb4-4-nhi =3D &usb4_0_nhi_die1; + usb4-5-acio =3D &usb4_1_acio_die1; + usb4-5-nhi =3D &usb4_1_nhi_die1; }; }; =20 @@ -57,6 +61,12 @@ &typec5 { /delete-node/ &dwc3_3_die1; /delete-node/ &atcphy3_die1; =20 +/delete-node/ &usb4_2_acio_die1; +/delete-node/ &usb4_2_mbox_die1; + +/delete-node/ &usb4_3_acio_die1; +/delete-node/ &usb4_3_mbox_die1; + /* delete unused always-on power-domains on die 1 */ /delete-node/ &ps_atc2_usb_aon_die1; /delete-node/ &ps_atc2_usb_die1; diff --git a/arch/arm64/boot/dts/apple/t6022-jxxxd.dtsi b/arch/arm64/boot/d= ts/apple/t6022-jxxxd.dtsi index dc877bd604f8..944a79d30fd7 100644 --- a/arch/arm64/boot/dts/apple/t6022-jxxxd.dtsi +++ b/arch/arm64/boot/dts/apple/t6022-jxxxd.dtsi @@ -46,6 +46,13 @@ typec4_connector_ss: endpoint { remote-endpoint =3D <&atcphy4_typec_lanes>; }; }; + + port@2 { + reg =3D <2>; + typec4_con_tbt: endpoint { + remote-endpoint =3D <&usb4_4_acio_tbt>; + }; + }; }; }; }; @@ -78,6 +85,13 @@ typec5_connector_ss: endpoint { remote-endpoint =3D <&atcphy5_typec_lanes>; }; }; + + port@2 { + reg =3D <2>; + typec5_con_tbt: endpoint { + remote-endpoint =3D <&usb4_5_acio_tbt>; + }; + }; }; }; }; @@ -169,3 +183,46 @@ atcphy5_usb3: endpoint { }; }; }; + +/* USB4 on die 1 */ +&usb4_0_acio_die1 { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_4_acio_tbt: endpoint { + remote-endpoint =3D <&typec4_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; + +&usb4_1_acio_die1 { + ports { + #address-cells =3D <1>; + #size-cells =3D <0>; + + /* 1: USB4 port */ + port@1 { + reg =3D <1>; + usb4_5_acio_tbt: endpoint { + remote-endpoint =3D <&typec5_con_tbt>; + }; + }; + + /* 2: unused(?) USB4 port */ + /* 3: PCIe */ + /* 4: USB3 */ + /* 5: DP0 */ + /* 6: DP1 */ + }; +}; diff --git a/arch/arm64/boot/dts/apple/t602x-dieX.dtsi b/arch/arm64/boot/dt= s/apple/t602x-dieX.dtsi index ae3d535c5acb..dae7b81c13d0 100644 --- a/arch/arm64/boot/dts/apple/t602x-dieX.dtsi +++ b/arch/arm64/boot/dts/apple/t602x-dieX.dtsi @@ -92,6 +92,22 @@ DIE_NODE(pinctrl_aop): pinctrl@2a6820000 { , , ; + + DIE_NODE(acio0_pins): acio0-pins { + pinmux =3D ; + }; + + DIE_NODE(acio1_pins): acio1-pins { + pinmux =3D ; + }; + + DIE_NODE(acio2_pins): acio2-pins { + pinmux =3D ; + }; + + DIE_NODE(acio3_pins): acio3-pins { + pinmux =3D ; + }; }; =20 DIE_NODE(pinctrl_ap): pinctrl@39b028000 { @@ -127,6 +143,98 @@ DIE_NODE(pmgr_gfx): power-management@404e80000 { reg =3D <0x4 0x4e80000 0 0x4000>; }; =20 + DIE_NODE(usb4_0_mbox): mailbox@701108000 { + compatible =3D "apple,t6020-asc-mailbox", + "apple,asc-mailbox-v4"; + reg =3D <0x7 0x01108000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + DIE_NODE(usb4_0_acio): cio@701ac0000 { + compatible =3D "apple,t6020-usb4-acio", "apple,t8103-usb4-acio"; + reg =3D <0x7 0x01ac0000 0x0 0xc000>, + <0x7 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&DIE_NODE(usb4_0_mbox)>; + resets =3D <&DIE_NODE(cio_reset) 0>; + + power-domains =3D <&DIE_NODE(ps_atc0_cio)>, + <&DIE_NODE(ps_atc0_cio_pcie)>, + <&DIE_NODE(ps_atc0_cio_usb)>; + + thunderbolt-switch; + + pinctrl-0 =3D <&DIE_NODE(acio0_pins)>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0x7 0x01000000 0x1000000>; + nonposted-mmio; + + DIE_NODE(usb4_0_dart): iommu@a80000 { + compatible =3D "apple,t6020-dart", "apple,t8110-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <5>; + }; + + DIE_NODE(usb4_0_nhi): nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t6020-usb4-nhi", + "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&DIE_NODE(usb4_0_dart) 1 0x100 0x0 0x10 0x0>, + <&DIE_NODE(usb4_0_dart) 2 0x100 0x0 0x10 0x0>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + DIE_NODE(dwc3_0): usb@702280000 { compatible =3D "apple,t6020-dwc3", "apple,t8103-dwc3"; reg =3D <0x7 0x02280000 0x0 0xcd00>, <0x7 0x0228cd00 0x0 0x3200>; @@ -180,6 +288,98 @@ DIE_NODE(atcphy0): phy@703000000 { power-domains =3D <&DIE_NODE(ps_atc0_usb)>; }; =20 + DIE_NODE(usb4_1_mbox): mailbox@b01108000 { + compatible =3D "apple,t6020-asc-mailbox", + "apple,asc-mailbox-v4"; + reg =3D <0xb 0x01108000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + DIE_NODE(usb4_1_acio): cio@b01ac0000 { + compatible =3D "apple,t6020-usb4-acio", "apple,t8103-usb4-acio"; + reg =3D <0xb 0x01ac0000 0x0 0xc000>, + <0xb 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&DIE_NODE(usb4_1_mbox)>; + resets =3D <&DIE_NODE(cio_reset) 1>; + + power-domains =3D <&DIE_NODE(ps_atc1_cio)>, + <&DIE_NODE(ps_atc1_cio_pcie)>, + <&DIE_NODE(ps_atc1_cio_usb)>; + + thunderbolt-switch; + + pinctrl-0 =3D <&DIE_NODE(acio1_pins)>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0xb 0x01000000 0x1000000>; + nonposted-mmio; + + DIE_NODE(usb4_1_dart): iommu@a80000 { + compatible =3D "apple,t6020-dart", "apple,t8110-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <5>; + }; + + DIE_NODE(usb4_1_nhi): nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t6020-usb4-nhi", + "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&DIE_NODE(usb4_1_dart) 1 0x100 0x0 0x10 0x0>, + <&DIE_NODE(usb4_1_dart) 2 0x100 0x0 0x10 0x0>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + DIE_NODE(dwc3_1): usb@b02280000 { compatible =3D "apple,t6020-dwc3", "apple,t8103-dwc3"; reg =3D <0xb 0x02280000 0x0 0xcd00>, <0xb 0x0228cd00 0x0 0x3200>; @@ -233,6 +433,98 @@ DIE_NODE(atcphy1): phy@b03000000 { power-domains =3D <&DIE_NODE(ps_atc1_usb)>; }; =20 + DIE_NODE(usb4_2_mbox): mailbox@f01108000 { + compatible =3D "apple,t6020-asc-mailbox", + "apple,asc-mailbox-v4"; + reg =3D <0xf 0x01108000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + DIE_NODE(usb4_2_acio): cio@f01ac0000 { + compatible =3D "apple,t6020-usb4-acio", "apple,t8103-usb4-acio"; + reg =3D <0xf 0x01ac0000 0x0 0xc000>, + <0xf 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&DIE_NODE(usb4_2_mbox)>; + resets =3D <&DIE_NODE(cio_reset) 2>; + + power-domains =3D <&DIE_NODE(ps_atc2_cio)>, + <&DIE_NODE(ps_atc2_cio_pcie)>, + <&DIE_NODE(ps_atc2_cio_usb)>; + + thunderbolt-switch; + + pinctrl-0 =3D <&DIE_NODE(acio2_pins)>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0xf 0x01000000 0x1000000>; + nonposted-mmio; + + DIE_NODE(usb4_2_dart): iommu@a80000 { + compatible =3D "apple,t6020-dart", "apple,t8110-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <5>; + }; + + DIE_NODE(usb4_2_nhi): nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t6020-usb4-nhi", + "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&DIE_NODE(usb4_2_dart) 1 0x100 0x0 0x10 0x0>, + <&DIE_NODE(usb4_2_dart) 2 0x100 0x0 0x10 0x0>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + DIE_NODE(dwc3_2): usb@f02280000 { compatible =3D "apple,t6020-dwc3", "apple,t8103-dwc3"; reg =3D <0xf 0x02280000 0x0 0xcd00>, <0xf 0x0228cd00 0x0 0x3200>; @@ -286,6 +578,98 @@ DIE_NODE(atcphy2): phy@f03000000 { power-domains =3D <&DIE_NODE(ps_atc2_usb)>; }; =20 + DIE_NODE(usb4_3_mbox): mailbox@1301108000 { + compatible =3D "apple,t6020-asc-mailbox", + "apple,asc-mailbox-v4"; + reg =3D <0x13 0x01108000 0x0 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + ; + interrupt-names =3D "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells =3D <0>; + }; + + DIE_NODE(usb4_3_acio): cio@1301ac0000 { + compatible =3D "apple,t6020-usb4-acio", "apple,t8103-usb4-acio"; + reg =3D <0x13 0x01ac0000 0x0 0xc000>, + <0x13 0x01080000 0x0 0x20000>; + reg-names =3D "rc", "sram"; + + mboxes =3D <&DIE_NODE(usb4_3_mbox)>; + resets =3D <&DIE_NODE(cio_reset) 3>; + + power-domains =3D <&DIE_NODE(ps_atc3_cio)>, + <&DIE_NODE(ps_atc3_cio_pcie)>, + <&DIE_NODE(ps_atc3_cio_usb)>; + + thunderbolt-switch; + + pinctrl-0 =3D <&DIE_NODE(acio3_pins)>; + pinctrl-names =3D "default"; + + #address-cells =3D <1>; + #size-cells =3D <1>; + ranges =3D <0x0 0x13 0x01000000 0x1000000>; + nonposted-mmio; + + DIE_NODE(usb4_3_dart): iommu@a80000 { + compatible =3D "apple,t6020-dart", "apple,t8110-dart"; + reg =3D <0xa80000 0x4000>; + interrupt-parent =3D <&aic>; + interrupts =3D ; + #iommu-cells =3D <5>; + }; + + DIE_NODE(usb4_3_nhi): nhi@f00000 { + reg =3D <0xf00000 0x100000>, + <0xdb0000 0x30004>; + reg-names =3D "nhi", "pdf"; + compatible =3D "apple,t6020-usb4-nhi", + "apple,t8103-usb4-nhi"; + interrupt-parent =3D <&aic>; + interrupts =3D , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names =3D + "txring0", "txring1", "txring2", + "txring3", "txring4", "txring5", + "txring6", "txring7", "txring8", + "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", + "rxring3", "rxring4", "rxring5", + "rxring6", "rxring7", "rxring8", + "rxring9", "rxring10", "rxring11"; + iommus =3D <&DIE_NODE(usb4_3_dart) 1 0x100 0x0 0x10 0x0>, + <&DIE_NODE(usb4_3_dart) 2 0x100 0x0 0x10 0x0>; + /* To be filled by the loader */ + apple,thunderbolt-drom =3D [00]; + }; + }; + DIE_NODE(dwc3_3): usb@1302280000 { compatible =3D "apple,t6020-dwc3", "apple,t8103-dwc3"; reg =3D <0x13 0x02280000 0x0 0xcd00>, <0x13 0x0228cd00 0x0 0x3200>; --=20 2.55.0