platform/chrome: cros_ec_typec: Update partner altmode active
authorAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
Fri, 13 Dec 2024 23:35:46 +0000 (15:35 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Dec 2024 07:56:05 +0000 (08:56 +0100)
Mux configuration is often the final piece of mode entry and can be used
to determine whether a partner altmode is active. When mux configuration
is done, use the active port altmode's SVID to set the partner active
field for all partner alt modes.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
Link: https://lore.kernel.org/r/20241213153543.v5.5.I083bf9188947be8cb7460211cfdf3233370a28f6@changeid
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/platform/chrome/cros_ec_typec.c

index ae2f862969547ccb33b9b2107ce0dc18bcf2254e..77f748fc854280e67aab9df190f5c3b08df6779f 100644 (file)
@@ -619,6 +619,7 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
        };
        struct ec_params_usb_pd_mux_ack mux_ack;
        enum typec_orientation orientation;
+       struct cros_typec_altmode_node *node;
        int ret;
 
        ret = cros_ec_cmd(typec->ec, 0, EC_CMD_USB_PD_MUX_INFO,
@@ -677,6 +678,14 @@ static int cros_typec_configure_mux(struct cros_typec_data *typec, int port_num,
                        port->mux_flags);
        }
 
+       /* Iterate all partner alt-modes and set the active alternate mode. */
+       list_for_each_entry(node, &port->partner_mode_list, list) {
+               typec_altmode_update_active(
+                       node->amode,
+                       port->state.alt &&
+                               node->amode->svid == port->state.alt->svid);
+       }
+
 mux_ack:
        if (!typec->needs_mux_ack)
                return ret;