From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A93112D7DD7 for ; Tue, 3 Mar 2026 07:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.216.44 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772522273; cv=pass; b=L9Ownax+0kh3RqvxK2qHFnMSIylFp3BQYXjN3NZBY6C3yLbKV+jigxrBKTKAOBuz4+aFL0KPCnC3mWki272uWbi9knBXozRGJ+rN2v5Z5BsI7NvVrgmTC1S9wBYJM60RV5IjwdQXyWx+nVBIJySeyQO2yijgcl2JALYu0vSH00M= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772522273; c=relaxed/simple; bh=iUDuzbIHKAT4wzJ1ISMnYFQi+mWbHKpDMtu5nmVdaeg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=CGHqe5zUCWXRXMDg2c7zwKLr/kp3wWEONB271xsY4QRKN1ixGjgQ/dzz5zWqLakaVmEZIsm7VmsdAgJPEyyjR9zaJjlToq2BI6zl/0wH0fCchbBLJTLW5YK9fv2bZ0YsALweRUdG9IBjwGe9iu2sIMOjRqCDcNDcaS0gP/grfLU= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=dx3uK308; arc=pass smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="dx3uK308" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-35983877dc5so1060684a91.2 for ; Mon, 02 Mar 2026 23:17:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772522270; cv=none; d=google.com; s=arc-20240605; b=fzMnsOycD07ANEDIbOGQZsI5yU3GbPhxALNxu/EhVZdfVYLWj7TxGtcIRsKC3r7f7i Fl5sAtNgNvYJADqKC+0jd2BrvELYfnvKX38Tc/67EVE5RwgJBhmj7WPnC/zKgknekHo3 B7cDxsNvAscqvMsne6of+gZcC6fWfawynO1A00+0vbIm6pFEKWTquAzPffcbnbN8Wwmr f7JktldIcZjG9Yiy9wn4m2ukmPLqCTbi59gqJF138mMyJWhPqxyo5EMSRkbkEJR0VjS+ C3PMiC6p5OWA6s/sYYoaeldlXnywCrrc07Ebyomf/4RZUOuAWXgndDImEyDqKJ7WpPTB qUYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=a0QWWGNwU+W7+a0DVHWQRw0ADddDXvdL9npPJTEapD8=; fh=7QIbNIQZm/Tm1byGL6eS9lAzz4YJrBymKuYm9URUckw=; b=fLJPpkIg5Jri/TUFtM4o1qu53mXJ1G00nedVHoBbySqIrEqQVtn5jOnjPG1L24T9u6 x4WMLo9FLysbssdVsjZeWyqrNXjI2HRPgDL+XFbfq1uKsuSt+iGtbRZ7e+/omC/qB9mY kFJtDQSgAwX8AneUS1H1A+Y0bEDJKh/E4glcX8EPi/K82ckdD3W377qBfmntbBifr8q5 w3P6AoY+dvJz1douMIfGiwiWTw/KHNeYO/ecs/rqEUR5lZd2PL+JRkg89BpOCJ1qksm5 xVDPhbLT9Imt6JOkUFcwNxtIVRSu9V/PxRwDNj0utlxK4Xe8CjMG58JCe37sc0eS/7sL WHEw==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1772522270; x=1773127070; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=a0QWWGNwU+W7+a0DVHWQRw0ADddDXvdL9npPJTEapD8=; b=dx3uK308Kss0tF21r0dHfYq5fyRgMdsKhTk0wEeeHeEWshMpFmd2+7uMgNlVzf/Ie4 uwzz2eBtmUxSWRZgjyytdpq7aBp8dSIMsUgECHj6UHhJ48tLezpQ9UepnKeIexqpiVNe +HXh56DhGiqP9JLBQduE/pwIpWEg3YKhCoVdw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772522270; x=1773127070; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=a0QWWGNwU+W7+a0DVHWQRw0ADddDXvdL9npPJTEapD8=; b=P/C/Nk5Se6AGfYLe1H+PtRBJiRwfANZD0EqAG+4Y4RUNVn3K7oIZ/uLDtiVrs+HcT3 W/m7FODgSqGhql3d5KfuHeqIhzNIj8s9L3zDYscRrfrQNMMHVrKkpGtUhuMpflcWIAmz 1Hy5lDg/HtaKQeCHS0X09mS0gmTogMVa1+P+bP3cuuIb8GYo7ZCWrtlMdURxKtqZ4O1j /HRBl7+gI6OISamSJeakmI7PxcWVD5zFfMySnfwhadfxfObN+x1UvS9CMFoWBoEt5F3e 6fi9TiRKDkd+RaYjXnYmQQqRix3euvr4QQQ39keQl0XJxqoGrljFYaRllDbUvubQAn4Z phSA== X-Forwarded-Encrypted: i=1; AJvYcCVWqy8Yg6YGEsOdE2NELYPGZexz/QEQjkJB9RjB3cnguFuDiHvCm524HIuM5X5v7OnTyn/bhIVC8Djhcnc=@vger.kernel.org X-Gm-Message-State: AOJu0YwnHHeZrwoMLzI8hypU79iLgyBng/m20qzDQ2oHa3FtsqNxb+hU ghxuBRu16ZSGYculyAOpJo2FefqIH5DIQWI9Ug+t3V/ETVgWTE0e1DMGGxYnOExkXiIukQHp9hM DPzYB5F4CTh/F18LHGSbb2VHbxsDKUcXWohV9WwDt X-Gm-Gg: ATEYQzxyR/yF+1PBKsyl5vHSo5TsP05B3llkjmRoI4Z6DgnMJBsufieHaUssdosQDl4 6d1b7OxOnCoxxchRCfTtOV+mDKBYGz/0Q3FLp/WfcmpPwx472mluUV3hQgfCOqohXBljsLFPABS 5U1Jfq4LRVf222Lq/Ybtb1o+Hv9ajsJsQXzp5W96kf2+HzNxV72JoIW2vtvGxemNNl84ZuZdJdL j4nlUuvAEQmDtt2wWe539oqzsjhN5CnunADQc+PIQ1/BFXrjoztDOWXEA3UmjAKceC16Iv3Ai1L ei2DRrNBPs2zpSVjsoWmPszRTO6lMm23NA== X-Received: by 2002:a17:90a:f950:b0:356:22ef:57ba with SMTP id 98e67ed59e1d1-35965c17f28mr12019636a91.7.1772522270023; Mon, 02 Mar 2026 23:17:50 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260205-smaug-type_c-v1-1-d6e556bf6640@tecnico.ulisboa.pt> In-Reply-To: <20260205-smaug-type_c-v1-1-d6e556bf6640@tecnico.ulisboa.pt> From: Andrei Kuchynski Date: Tue, 3 Mar 2026 08:17:38 +0100 X-Gm-Features: AaiRm53veFG4Ts4UFjJL5-8xajlIE3RC3p1oMVH2mF_ag7WRwvpeAzno9nUMyAk Message-ID: Subject: Re: [PATCH] platform/chrome: cros_ec_typec: Skip Type-C mux handling in EC-driven devices To: Diogo Ivo Cc: Benson Leung , Abhishek Pandit-Subedi , Jameson Thies , Tzung-Bi Shih , Guenter Roeck , chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Diogo, On Thu, Feb 5, 2026 at 11:04=E2=80=AFAM Diogo Ivo wrote: > > Currently the code assumes that the EC firmware will leave Type-C mux > handling logic to the AP, exposing an interface to query and change the > mux state via a request from the AP. However, in devices such as Smaug > the EC automatically takes care of mux configuration and only USB role > switching needs to be handled by the AP. In fact, in such devices this > interface is not exposed by the EC making the whole process fail, > including role switching. > > Fix this by first separating Type-C mux handling and USB role switching, > explicitly querying the behaviour of the EC and execute each part > conditionally according to what the EC reported. > > Signed-off-by: Diogo Ivo > --- > drivers/platform/chrome/cros_ec_typec.c | 49 +++++++++++++++++++++++----= ------ > drivers/platform/chrome/cros_ec_typec.h | 2 +- > 2 files changed, 35 insertions(+), 16 deletions(-) > > diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/c= hrome/cros_ec_typec.c > index b712bcff6fb2..bd7e6c365cab 100644 > --- a/drivers/platform/chrome/cros_ec_typec.c > +++ b/drivers/platform/chrome/cros_ec_typec.c > @@ -751,11 +751,10 @@ static int cros_typec_configure_mux(struct cros_typ= ec_data *typec, int port_num, > } > > /* No change needs to be made, let's exit early. */ > - if (port->mux_flags =3D=3D resp.flags && port->role =3D=3D pd_ctr= l->role) > + if (port->mux_flags =3D=3D resp.flags) > return 0; > > port->mux_flags =3D resp.flags; > - port->role =3D pd_ctrl->role; > > if (port->mux_flags =3D=3D USB_PD_MUX_NONE) { > ret =3D cros_typec_usb_disconnect_state(port); > @@ -771,12 +770,6 @@ static int cros_typec_configure_mux(struct cros_type= c_data *typec, int port_num, > if (ret) > return ret; > > - ret =3D usb_role_switch_set_role(typec->ports[port_num]->role_sw, > - pd_ctrl->role & PD_CTRL_RESP_ROLE= _DATA > - ? USB_ROLE_HOST : USB_ROLE_DEVICE= ); > - if (ret) > - return ret; > - > if (port->mux_flags & USB_PD_MUX_USB4_ENABLED) { > ret =3D cros_typec_enable_usb4(typec, port_num, pd_ctrl); > } else if (port->mux_flags & USB_PD_MUX_TBT_COMPAT_ENABLED) { > @@ -822,6 +815,25 @@ static int cros_typec_configure_mux(struct cros_type= c_data *typec, int port_num, > return ret; > } > > +static int cros_typec_set_role(struct cros_typec_data *typec, int port_n= um, > + struct ec_response_usb_pd_control_v1 *resp= ) > +{ > + enum usb_role cur_role =3D usb_role_switch_get_role(typec->ports[= port_num]->role_sw); > + enum usb_role role =3D resp->role & PD_CTRL_RESP_ROLE_DATA ? USB_= ROLE_HOST : > + USB_RO= LE_DEVICE; > + bool connected =3D resp->enabled & PD_CTRL_RESP_ENABLED_CONNECTED= ; > + int ret; > + > + if (!connected || cur_role =3D=3D role) > + return 0; > + > + ret =3D usb_role_switch_set_role(typec->ports[port_num]->role_sw,= role); > + if (ret) > + dev_err(typec->dev, "Failed USB role switch, err =3D %d\n= ", ret); While testing on Brya, I've got a role switch failure: cros-ec-typec GOOG0014:00: Failed USB role switch, err =3D -22 cros-ec-typec GOOG0014:00: Update failed for port: 1 Steps to reproduce: deactivate any alt-mode. Verified on the Brya platform. This may be attributed to the altered sequence of mux and switch settings. Thanks, Andrei