Commit c94138ae40008327def5decc0aa3ac91c8e1ea12

Authored by Sven Peter
Committed by Greg Kroah-Hartman
1 parent 662893b4f6

usb: typec: tipd: Forward plug orientation to typec subsystem

commit 676748389f5db74e7d28f9d630eebd75cb8a11b4 upstream.

In order to bring up the USB3 PHY on the Apple M1 we need to know the
orientation of the Type-C cable. Extract it from the status register and
forward it to the typec subsystem.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Sven Peter <sven@svenpeter.dev>
Link: https://lore.kernel.org/r/20220226125912.59828-1-sven@svenpeter.dev
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 2 changed files with 6 additions and 0 deletions Side-by-side Diff

drivers/usb/typec/tipd/core.c
... ... @@ -246,6 +246,10 @@
246 246 typec_set_pwr_opmode(tps->port, mode);
247 247 typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
248 248 typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
  249 + if (TPS_STATUS_TO_UPSIDE_DOWN(status))
  250 + typec_set_orientation(tps->port, TYPEC_ORIENTATION_REVERSE);
  251 + else
  252 + typec_set_orientation(tps->port, TYPEC_ORIENTATION_NORMAL);
249 253 tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), true);
250 254  
251 255 tps->partner = typec_register_partner(tps->port, &desc);
... ... @@ -268,6 +272,7 @@
268 272 typec_set_pwr_opmode(tps->port, TYPEC_PWR_MODE_USB);
269 273 typec_set_pwr_role(tps->port, TPS_STATUS_TO_TYPEC_PORTROLE(status));
270 274 typec_set_vconn_role(tps->port, TPS_STATUS_TO_TYPEC_VCONN(status));
  275 + typec_set_orientation(tps->port, TYPEC_ORIENTATION_NONE);
271 276 tps6598x_set_data_role(tps, TPS_STATUS_TO_TYPEC_DATAROLE(status), false);
272 277  
273 278 power_supply_changed(tps->psy);
drivers/usb/typec/tipd/tps6598x.h
... ... @@ -17,6 +17,7 @@
17 17 /* TPS_REG_STATUS bits */
18 18 #define TPS_STATUS_PLUG_PRESENT BIT(0)
19 19 #define TPS_STATUS_PLUG_UPSIDE_DOWN BIT(4)
  20 +#define TPS_STATUS_TO_UPSIDE_DOWN(s) (!!((s) & TPS_STATUS_PLUG_UPSIDE_DOWN))
20 21 #define TPS_STATUS_PORTROLE BIT(5)
21 22 #define TPS_STATUS_TO_TYPEC_PORTROLE(s) (!!((s) & TPS_STATUS_PORTROLE))
22 23 #define TPS_STATUS_DATAROLE BIT(6)