Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3528280pxb; Tue, 20 Apr 2021 10:11:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7fyrc/5b5SoSoEMDGMJrgTu8YcYjulwmf6sojEhD/ulO/O3GZFnpdQoEgMCxozdw2gpMm X-Received: by 2002:a17:90a:4290:: with SMTP id p16mr6106599pjg.120.1618938685755; Tue, 20 Apr 2021 10:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618938685; cv=none; d=google.com; s=arc-20160816; b=toF1bqtAEvINNo+LLNjIPoqVwP3Wb04Vacq9Pf3XW0IVgWQionexGRW4hHtnjUw3/I fFNms3kzNB0TTRWIgLhLz7BBdFgjVH5p4bctuiHUwAeMA/5aj4yp11SPtoO/J4FriI87 fxPgZ24Lx4osoRazE6OM/qtjAfZPoQHNriXp7xQwNMZlhh0Lr94P1jIW9p4THuiptJGE zE7CJq92zk9qVjuD7ythNogSVwrT4HT6cnA6rHX1bWt/oZrGlE8UJQd0GrUj5zEvfbAR /d0eCR4AVas0rETso0qLpswEmgm5wew+rmUQMj0H1tan6Vn6VK1ywRvIut0Mmw1vjx26 IXSQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=DXsClQzPyy3ZZmtTQRhi81u0hIqu+HrYWRKXDHtKEAo=; b=crsnNAB7PXNvH0nP+phh+zOUhlroD5oYSjHLlqwXiUtgsX36WBtGNKRZseLdUXJsnB tn0xV+bGF9LlT3aE2jMYvGl7BsFx2f+27qYWXLRQKTACb01CNhxMNg4Dg+bJS39Yzuz2 di4biIPpsQ5Z1y75vZCtuEmDT4zgYW4ePKkaBh4CMKdA28j4MfJjSsBp1B/kGh73mcOi E2GguuL5qOmMAWZpZl5CBfuc4y+ewSJ8ZkQTNN3S1w2b+qZiJxrmoVGlUcCzfsWYJn9k SWJGU7u7nKQ3nrMS9sl+0UjAY5TyAwEzR1A8VKkGxcE48eUUjCaj8VHo6SoTV4AJZreE B1Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OsYYelzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si22864642plg.0.2021.04.20.10.11.12; Tue, 20 Apr 2021 10:11:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OsYYelzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233212AbhDTRLE (ORCPT + 99 others); Tue, 20 Apr 2021 13:11:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232769AbhDTRLC (ORCPT ); Tue, 20 Apr 2021 13:11:02 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D557C06174A for ; Tue, 20 Apr 2021 10:10:31 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id o16so6416593plg.5 for ; Tue, 20 Apr 2021 10:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DXsClQzPyy3ZZmtTQRhi81u0hIqu+HrYWRKXDHtKEAo=; b=OsYYelzxirfur10BaaAx/ihgv2EY9UtnNcx/QFBAX7gGKx7tc8iNVkrZFU4mLtEhFu ffWQxAU5ciGB3bU6oqngT3syljik/L3h3QxmplVXK1RbXFdUMifpFVMyZWstzQXDqPcN L16AG/OclfErCto8rG8Dz/RFnpNrJyYwStXOE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DXsClQzPyy3ZZmtTQRhi81u0hIqu+HrYWRKXDHtKEAo=; b=Qwz+wx02iD2JSeaWHrDmv4jHiRXNpyUzopauGXDMpTSllFYrq7VjqX7Kmoi2SaDZOl mWLx4QQNW//mACzSUMGoEd20UYfLXezqZjz53PL2IN6bvv4PiylLZUhgT3xvVLvPoj5H k0cFT2KNBB/CxgazHNRU8Mx78fVCXK9se31BnT+QM1I0YZTKVRtJEviU5C238yBaNh1e 9IbwgJrCZQbDZpM/sQSzPEsK39yKQlzLzZ/+5tEoRWmiPDKl3B7ga9oNwkU7zIS80aWE zdTUk6FtMTAhsNWMHWkYGc/0U1bSjeml+iuJu199hRRA0lfphq+7UkbiAQU2PvCakzbC mwTg== X-Gm-Message-State: AOAM530SOVYzRmYXMoKQrLhU9i1oEHFYZDkdx6QgxEPiW3BKdo22y7Bo dGrV2vA550QNQsGbREafvri+AiXE3BBzTg== X-Received: by 2002:a17:902:7043:b029:ec:939f:c9e5 with SMTP id h3-20020a1709027043b02900ec939fc9e5mr16922762plt.64.1618938630574; Tue, 20 Apr 2021 10:10:30 -0700 (PDT) Received: from pmalani2.mtv.corp.google.com ([2620:15c:202:201:ee88:6ec6:b8ee:20b9]) by smtp.gmail.com with ESMTPSA id g2sm2934216pju.18.2021.04.20.10.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 10:10:30 -0700 (PDT) From: Prashant Malani To: linux-kernel@vger.kernel.org Cc: Prashant Malani , "Nikunj A . Dadhania" , Deepti Deshatty , Benson Leung , Enric Balletbo i Serra , Guenter Roeck Subject: [PATCH] platform/chrome: cros_ec_typec: Track port role Date: Tue, 20 Apr 2021 10:10:09 -0700 Message-Id: <20210420171008.3829549-1-pmalani@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stash the currently reported port role in the port struct and add a check for that too while determining whether to re-configure on-board Type C switches (this deals with cases like role swaps where the mux flags don't change, but the port role does). Signed-off-by: Prashant Malani Suggested-by: Nikunj A. Dadhania Tested-by: Deepti Deshatty --- drivers/platform/chrome/cros_ec_typec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c index d3df1717a5fd..1a06b8c80f80 100644 --- a/drivers/platform/chrome/cros_ec_typec.c +++ b/drivers/platform/chrome/cros_ec_typec.c @@ -58,6 +58,7 @@ struct cros_typec_port { /* Variables keeping track of switch state. */ struct typec_mux_state state; uint8_t mux_flags; + uint8_t role; /* Port alt modes. */ struct typec_altmode p_altmode[CROS_EC_ALTMODE_MAX]; @@ -995,10 +996,12 @@ static int cros_typec_port_update(struct cros_typec_data *typec, int port_num) } /* No change needs to be made, let's exit early. */ - if (typec->ports[port_num]->mux_flags == mux_resp.flags) + if (typec->ports[port_num]->mux_flags == mux_resp.flags && + typec->ports[port_num]->role == resp.role) return 0; typec->ports[port_num]->mux_flags = mux_resp.flags; + typec->ports[port_num]->role = resp.role; ret = cros_typec_configure_mux(typec, port_num, mux_resp.flags, &resp); if (ret) dev_warn(typec->dev, "Configure muxes failed, err = %d\n", ret); -- 2.31.1.368.gbe11c130af-goog