Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1682669pxb; Wed, 9 Feb 2022 02:05:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxtLOfdt68kG/Ns/wWaiRr68M0bgUBQgNA6Jv6LhywWtmcGTf5IHcyQ/jpnrA0EQopxnqfh X-Received: by 2002:a05:6a00:2388:: with SMTP id f8mr1497332pfc.9.1644401099944; Wed, 09 Feb 2022 02:04:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644401099; cv=none; d=google.com; s=arc-20160816; b=bAKQ/7B+pggp6LSRwxu+n1/0WlZXcAlDVhHZCHdargpTzPMpoUIoZeDoQ1nEUQDBZv ujAgsd1pgVLZF+WONusGa5TlkiAb93AcUUsx0K8gq0fqCqPvpiqIOrww+baHNbsQ8PqC vFT0a9D2capPyvW662VLT/S9176A0Z5qRD5p8FMF0SRXxGiJIy3ZFzUCeBQxKzKmh1GW /JX5GWXxgcYF7ofIUSzkPQ2oJsH80MyQu6b/a3ATfqssccTg8kKeITFBDpdFLVxLL2vc tPDr9VGO8lX/VLlrm0dYbocz4KDG7Jn4IHzvpl98NvXa/FYOEDpNQhhJiiNY7rKy6rKX lqkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jLio1a1l75mHbmNEuBlAUNzao55kTSeKszQYcAQRX+I=; b=p+5pxLRleedxdBPvUdZTsTN50rk4+5Qk0lZHart6NcU5I16gx6WWfrXVuEV4xzIttr A/GJsGTktBRaAVWKtmFCZeH8gwYIDA8l2yzgpp1ZUyo49qKqxEgUK3QSvcXaC9GEveuM UBA+a/IfTSyh5jqrRNGaSHOFArBlHKnk2ASYXBCIdz0MureXnr/EREhxserjWbQjdySD SpNAmDl95B1Xiwp6K7tB9d7R/kSinRLBqZNX8+xOpHBKHsOS67u6gZ8qPF8QdMD/spVT 5jtr6u/nQb88+J9xNE9OPJIU08yVHWEyqGSgUeEZZcpcKWvTzsI8ZnfdIgU1sS5wYJge rsfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MsjVta7I; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id l71si14979232pge.285.2022.02.09.02.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 02:04:59 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MsjVta7I; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 760A0DF498A5; Wed, 9 Feb 2022 01:13:35 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385433AbiBHSsF (ORCPT + 99 others); Tue, 8 Feb 2022 13:48:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238272AbiBHSsC (ORCPT ); Tue, 8 Feb 2022 13:48:02 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C8EC0613CC for ; Tue, 8 Feb 2022 10:47:59 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id on2so12077pjb.4 for ; Tue, 08 Feb 2022 10:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jLio1a1l75mHbmNEuBlAUNzao55kTSeKszQYcAQRX+I=; b=MsjVta7IYbQNKqHe58RtLXBHcrrrukRhSUHG22zWAasQ99i8xGDjf6fjdG686TlnIa nybAKSUI943yDMYt1V4L4HPXRb7QQjwNcAdgkBEA7mkKq7rvOzgkYGUwhNrja80IyCzj TubUKDuwMDz9gZ1PzfVVVhqUkOhBd0PGbly6A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jLio1a1l75mHbmNEuBlAUNzao55kTSeKszQYcAQRX+I=; b=yR8OfIgywEkpHzTanDV1iAzmnN33WOiQdcEKwXUFdfZpWuxsNUJurdwbXp1UnuGG3m irEOkIClwrfC4OoRZKHjMuLIDdvk5x90eQkfxcvr9eSVqkobsaXB9+UlLXWgF0314YK/ DsCBoejthoRKtt+W+QX/oC3WOeLcVq0b5klvqnoBsh+WzgflnCkyuNJDU/xIJygHytOf K3DZiBwlNcUxeqUVG91wOZLRKZmijhiGYRFuj9PwBVguei0PANI02ca+GQ4zfmpxUUqi gXnmq+2qCD63lRDxjv0yPKtVnKXPUEsm0a8ewKHocUflhkzEGyeqFLOUBHOFINrL76yQ mPrA== X-Gm-Message-State: AOAM5335vHQOYU9qPwERHn4bO0ws6huXBtF3bt6mwND16IRd3d1Oh0c5 QBKlXujBtooxk+7trnpWmrxNueRviGfLlA== X-Received: by 2002:a17:902:da88:: with SMTP id j8mr5904035plx.105.1644346078477; Tue, 08 Feb 2022 10:47:58 -0800 (PST) Received: from pmalani.c.googlers.com.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id gk15sm3594453pjb.3.2022.02.08.10.47.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 10:47:58 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , Benson Leung , Guenter Roeck , chrome-platform@lists.linux.dev (open list:CHROMEOS EC USB TYPE-C DRIVER) Subject: [PATCH v2 3/4] platform/chrome: cros_ec_typec: Configure muxes at start of port update Date: Tue, 8 Feb 2022 18:47:22 +0000 Message-Id: <20220208184721.1697194-4-pmalani@chromium.org> X-Mailer: git-send-email 2.35.0.263.gb82422642f-goog In-Reply-To: <20220208184721.1697194-1-pmalani@chromium.org> References: <20220208184721.1697194-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are situations where the mux state reported by the Embedded Controller (EC), might lag the partner "connected" state. So, the mux state might still suggest that a partner is connected, while the PD "connected" state, being in Try.SNK (for example) suggests that the partner is disconnected. In such a scenario, we will end up sending a disconnect command to the mux driver, followed by a connect command, since the mux is configured later. Avoid this by configuring the mux before registering/disconnecting a partner. Signed-off-by: Prashant Malani --- Changes in v2: - Change return at end of port_update() to just return 0. drivers/platform/chrome/cros_ec_typec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index 3d34ece7f790..3019e29f200d 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -965,6 +965,11 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num) if (ret < 0) return ret; + /* Update the switches if they exist, according to requested state */ + ret = cros_typec_configure_mux(typec, port_num, &resp); + if (ret) + dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret); + dev_dbg(typec->dev, "Enabled %d: 0x%hhx\n", port_num, resp.enabled); dev_dbg(typec->dev, "Role %d: 0x%hhx\n", port_num, resp.role); dev_dbg(typec->dev, "Polarity %d: 0x%hhx\n", port_num, resp.polarity); @@ -980,12 +985,7 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num) if (typec->typec_cmd_supported) cros_typec_handle_status(typec, port_num); - /* Update the switches if they exist, according to requested state */ - ret = cros_typec_configure_mux(typec, port_num, &resp); - if (ret) - dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret); - - return ret; + return 0; } static int cros_typec_get_cmd_version(struct cros_typec_data *typec) -- 2.35.0.263.gb82422642f-goog