From 29870fd0ace335a10f1cf5acce328ff451e7ecc0 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Tue, 1 Dec 2026 15:59:56 +1100 Subject: [PATCH] usb: typec: tipd: take the T8140/T8142 HPD rules from the port's DT Two CD321x display paths were gated on the root machine compatible: cd321x_update_work() skipped the out-of-band reprobe of the display connector after a USB4 route started on apple,t8140 and apple,t8142, and cd321x_typec_update_mode() made up no IRQ_HPD for a coalesced HPD pulse once tipd_resume() had set h17_display for the same two machines. h17_display was only set at a resume, so before the first sleep it was false on those machines too. Describe the rule on the port instead: a port whose DT gives apple,no-hpd-synthesis passes the display side only the HPD changes the controller reports. The flag is read once in tipd_init(), so it holds from the probe. Every T8140 and T8142 port with a DisplayPort route (J700, J704, J813, J815) gets the property; the J815 MagSafe port has no route and is left out. Document the property in the SN201202x binding and model it in the apple-dcp host fixtures that extract cd321x_update_work() and tipd_init(). Signed-off-by: Ryan Murray --- .../bindings/usb/apple,sn201202x.yaml | 10 ++++++++++ arch/arm64/boot/dts/apple/t8140-j700.dts | 2 ++ arch/arm64/boot/dts/apple/t8142-j704-usb.dtsi | 3 +++ arch/arm64/boot/dts/apple/t8142-j813-usb.dtsi | 2 ++ drivers/usb/typec/tipd/core.c | 19 ++++++++++--------- drivers/usb/typec/tipd/tps6598x.h | 7 +++++-- .../drivers/gpu/apple-dcp/lifecycle.py | 4 +++- .../drivers/gpu/apple-dcp/transaction.py | 2 +- 8 files changed, 36 insertions(+), 13 deletions(-) diff --git a/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml b/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml index 84ae1f7bf0880..572914db10a31 100644 --- a/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml +++ b/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml @@ -103,6 +103,16 @@ properties: This controller serves the USB controller's root port, and watches its USB2 lines for a remote wakeup during a firmware-driven system sleep. + apple,no-hpd-synthesis: + type: boolean + description: + Pass the display side only the HPD changes the controller reports for + the port's DisplayPort route. No IRQ_HPD is made up for an HPD pulse + the controller coalesced, and the display connector is not probed + again when a USB4 route starts on the shared fabric. The T8140 and + T8142 machines' ports, whose external display pipes are driven this + way, have it. + connector: $ref: /schemas/connector/usb-connector.yaml# diff --git a/arch/arm64/boot/dts/apple/t8140-j700.dts b/arch/arm64/boot/dts/apple/t8140-j700.dts index 940431d7aac3b..0abe1090f9890 100644 --- a/arch/arm64/boot/dts/apple/t8140-j700.dts +++ b/arch/arm64/boot/dts/apple/t8140-j700.dts @@ -1936,6 +1936,7 @@ hpm1: usb-pd@a { compatible = "apple,sn201202x"; reg = <0xa SPMI_USID>; + apple,no-hpd-synthesis; apple,sleep-ssps; interrupts = <37 IRQ_TYPE_EDGE_RISING>, <39 IRQ_TYPE_EDGE_RISING>, @@ -1962,6 +1963,7 @@ compatible = "apple,sn201202x"; reg = <0xc SPMI_USID>; apple,debug-lock-key = "007J"; + apple,no-hpd-synthesis; apple,sleep-ssps; interrupts = <11 IRQ_TYPE_EDGE_RISING>, <13 IRQ_TYPE_EDGE_RISING>, diff --git a/arch/arm64/boot/dts/apple/t8142-j704-usb.dtsi b/arch/arm64/boot/dts/apple/t8142-j704-usb.dtsi index fac15e4d4099f..b9b16c249652c 100644 --- a/arch/arm64/boot/dts/apple/t8142-j704-usb.dtsi +++ b/arch/arm64/boot/dts/apple/t8142-j704-usb.dtsi @@ -72,6 +72,7 @@ hpm0: usb-pd@c { compatible = "apple,sn201202x"; reg = <0xc SPMI_USID>; + apple,no-hpd-synthesis; typec0: connector { compatible = "usb-c-connector"; @@ -208,6 +209,7 @@ hpm1: usb-pd@a { compatible = "apple,sn201202x"; reg = <0xa SPMI_USID>; + apple,no-hpd-synthesis; typec1: connector { compatible = "usb-c-connector"; @@ -360,6 +362,7 @@ hpm3: usb-pd@c { compatible = "apple,sn201202x"; reg = <0xc SPMI_USID>; + apple,no-hpd-synthesis; typec3: connector { compatible = "usb-c-connector"; diff --git a/arch/arm64/boot/dts/apple/t8142-j813-usb.dtsi b/arch/arm64/boot/dts/apple/t8142-j813-usb.dtsi index bf81e9b35ce21..e1c1691a2aec3 100644 --- a/arch/arm64/boot/dts/apple/t8142-j813-usb.dtsi +++ b/arch/arm64/boot/dts/apple/t8142-j813-usb.dtsi @@ -64,6 +64,7 @@ hpm0: usb-pd@c { compatible = "apple,sn201202x"; reg = <0xc SPMI_USID>; + apple,no-hpd-synthesis; typec0: connector { compatible = "usb-c-connector"; @@ -210,6 +211,7 @@ hpm1: usb-pd@a { compatible = "apple,sn201202x"; reg = <0xa SPMI_USID>; + apple,no-hpd-synthesis; typec1: connector { compatible = "usb-c-connector"; diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 804a6064dcede..4dbbc5ba5c851 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -926,9 +926,10 @@ static int cd321x_typec_update_mode(struct tps6598x *tps, * state looks unchanged, so the display side would never hear of * it: report the pulse as IRQ_HPD. A port with a displayport * reference reports the pulse out of band instead, as a - * disconnect and a connect (see cd321x_update_work()). + * disconnect and a connect (see cd321x_update_work()). A port + * whose DT gives apple,no-hpd-synthesis reports none. */ - hpd_pulse = !tps->h17_display && + hpd_pulse = !tps->no_hpd_synthesis && !(IS_REACHABLE(CONFIG_DRM) && cd321x->connector_fwnode) && (st->data_status_changed & CD321X_DATA_STATUS_HPD_LEVEL) && (dp_data.status & DP_STATUS_HPD_STATE) && @@ -1468,11 +1469,13 @@ static void cd321x_update_work(struct work_struct *work) goto retry; tipd_boot_host_started(tps, new_role); - /* A new USB4 route can disturb another port on the shared fabric. */ + /* + * A new USB4 route can disturb another port on the shared fabric: have + * the display side probe this one again, unless its DT says the display + * side takes only the controller's own HPD reports. + */ if (IS_REACHABLE(CONFIG_DRM) && cd321x->connector_fwnode && - !of_machine_is_compatible("apple,t8140") && - !of_machine_is_compatible("apple,t8142") && - usb4_started && !cd321x->display_route_active) + !tps->no_hpd_synthesis && usb4_started && !cd321x->display_route_active) drm_connector_oob_hotplug_event(cd321x->connector_fwnode, connector_status_unknown); @@ -4258,6 +4261,7 @@ int tipd_init(struct tps6598x *tps) } tps->wakeup = device_property_read_bool(tps->dev, "wakeup-source"); + tps->no_hpd_synthesis = device_property_read_bool(tps->dev, "apple,no-hpd-synthesis"); if (tps->irq) { /* * A variant that filters its events in system sleep keeps the @@ -4467,9 +4471,6 @@ int tipd_resume(struct tps6598x *tps) { int ret; - tps->h17_display = of_machine_is_compatible("apple,t8140") || - of_machine_is_compatible("apple,t8142"); - ret = tps6598x_check_mode(tps); if (ret < 0) return ret; diff --git a/drivers/usb/typec/tipd/tps6598x.h b/drivers/usb/typec/tipd/tps6598x.h index 62b1b682364de..068f98862444d 100644 --- a/drivers/usb/typec/tipd/tps6598x.h +++ b/drivers/usb/typec/tipd/tps6598x.h @@ -355,8 +355,11 @@ struct tipd_data { }; struct tps6598x { - /* Native H17 routes retain ENOSPC admission and their own HPD path. */ - u8 h17_display:1; + /* + * apple,no-hpd-synthesis: the display side gets only the HPD changes the + * controller reports (the T8140 and T8142 ports). + */ + u8 no_hpd_synthesis:1; /* On the list tipd_port_replug() looks a port up on, by its role switch; its replug. */ struct list_head port_node; struct work_struct replug_work; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py index b91d8a5812f72..a9b84bec7318d 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py @@ -207,7 +207,7 @@ def function(file, name): bool dp_sid_event,dp_sid_hpd_low,dp_sid_irq; struct { u32 status_rx,configure,mode_data; } dp_sid_status; }; struct tps6598x { void *partner, *dev, *port, *psy; int lock; u32 data_status; enum usb_role *role_sw; - void *partner_altmode_dp; }; + void *partner_altmode_dp; bool no_hpd_synthesis; }; struct cd321x { struct tps6598x tps; struct cd321x_status update_status; struct cd321x_pm_state pm; struct delayed_work update_work, resume_work; struct typec_mux_state state; bool state_valid, display_route_active, cur_partner_is_pd; @@ -288,6 +288,8 @@ def function(file, name): static void init(void) { memset(&display,0,sizeof(display)); memset(&sink,0,sizeof(sink)); memset(&port,0,sizeof(port)); + /* The J700 ports' DT, as in t8140-j700.dts */ + port.tps.no_hpd_synthesis = true; sink.connected = true; display.connector = &sink; display.external_prepared = true; raw_error = raw_links = 0; display.external_running = display.external_power_attempted = true; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/transaction.py b/tools/testing/selftests/drivers/gpu/apple-dcp/transaction.py index 829f723f5734b..80cde6d0280ac 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/transaction.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/transaction.py @@ -373,7 +373,7 @@ def probe(root): unit = quiesce.make_unit(root) unit = unit.replace(block(unit, 'int main('), block(unit, 'int main(').replace('int main(', 'int __attribute__((unused)) prior_main(', 1), 1) unit = unit.replace('struct tipd_data {', 'struct fwnode_handle;\nstruct tipd_data { unsigned irq_mask1; int (*init)(struct tps6598x *); int (*switch_power_state)(struct tps6598x *, int); int (*register_port)(struct tps6598x *, struct fwnode_handle *); bool (*read_data_status)(struct tps6598x *); bool (*read_power_status)(struct tps6598x *); int (*connect)(struct tps6598x *,u32); void (*ready)(struct tps6598x *); void *irq_handler;') - unit = unit.replace('struct tps6598x {', 'struct tps6598x { bool dbma_at_probe,wakeup; u32 status; bool (*sleep_event)(struct tps6598x *);') + unit = unit.replace('struct tps6598x {', 'struct tps6598x { bool dbma_at_probe,wakeup,no_hpd_synthesis; u32 status; bool (*sleep_event)(struct tps6598x *);') helpers = r""" #undef dev_err #define dev_err(...) ((void)0)