From patchwork Thu Jan 12 22:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 42853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4136424wrt; Thu, 12 Jan 2023 14:27:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXtUSUSWN1fWc8gXlhdY6O13ZSVepKFbn8ZOiJH8K477TcKfWcqLz1+mtZ9/rJWY94UE2RwJ X-Received: by 2002:a17:902:8b88:b0:192:b2d3:4fc8 with SMTP id ay8-20020a1709028b8800b00192b2d34fc8mr8193766plb.1.1673562457077; Thu, 12 Jan 2023 14:27:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673562457; cv=none; d=google.com; s=arc-20160816; b=CN+NmV0BfTc2tvuC2t1Wm8FJZu/aau5zwzGXkZxphBCvkT0SYESqujQ0f6WAf2cyob jAykh9XZbeVvi0qQSezjsGL3I9aLiHOA69swZ7D/dhIEEmwX42jp6tcbYic5Msx23pAC F7ujc+CoPJCet/MNMpavVm3IDj47OUTmItRaka80TuvquzIMPQNlhlTzsRI/b+JtR9p7 83RFJf4XN97CmzNtKSzcNinq/0dgKnfuQByKQ0RHNdv4NvE+2ZM/eC+Q+CncMlpG/UkE m0qY0O6kR9d+xbahjeODwgyGBLHKUe9JmnU6lmw3jrxDQST1EUrODP3bzrbQxorCDp7p aj/A== 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=HkTLc1JhoYqMaaSpYl6NjHEmEMaKe24mQDtcgzRm6SA=; b=ja5gbRGbv9KM3/mhQi17CXlQ06w0TBWAJ5lXTkwebhH0/zJanBg5Rgp88+5+BzuYoG 4dIoNBVSNMZ5fb0Vl2jWbx6+JbwIi/L3tcNEzTaGps9X6VwvFwnuCgBICsnCaXNOLWux Crd9yXvEvQFtbnfMtWLQgT3AqGBMt9Au3jcTQXCnMbx1eFhG5A9CuVZrowxzp2YZPl5r 95mAJ5vb00nDTJba8vjC/t6tag85Tw1ht5Hzh6UOpBNhc9ExbQCDscVv40YqEvBI8QoX MTw8Xb516+XOhaPY7tRaAHOwofwu/+KIkNqiVvZXZ4ROTk5qMwVrroTqEHs/LKtAqKQd P3Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NwLL3cGl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y1-20020a17090322c100b00192c9303df2si19820268plg.133.2023.01.12.14.27.24; Thu, 12 Jan 2023 14:27:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NwLL3cGl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239906AbjALWXR (ORCPT + 99 others); Thu, 12 Jan 2023 17:23:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240526AbjALWWl (ORCPT ); Thu, 12 Jan 2023 17:22:41 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE3E51C42A for ; Thu, 12 Jan 2023 14:16:33 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id a30so14840669pfr.6 for ; Thu, 12 Jan 2023 14:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HkTLc1JhoYqMaaSpYl6NjHEmEMaKe24mQDtcgzRm6SA=; b=NwLL3cGlWAqecjjWMIePO/VbFJDy2XUOI5/qdVpiCUq0EckUGu/5j6Vp9tvJRzjoYQ GQdfLylJSd4qj5BMlvzNNJ/mHcln91tySW6DlhghM4B6qEFYGV06w88nAgHdpOrjqPkg gpd8k0s0/DytaeePtdTqyGeWCK8Iw990vOn9A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HkTLc1JhoYqMaaSpYl6NjHEmEMaKe24mQDtcgzRm6SA=; b=UPc56rT8rtLMluLuyOk4ZN0s7QBigig5iYxygmeMYXwcjb78LhQeZYD82jJHyxbhwg bOcZHPIDPQdYTDCsP7+x9tf27qiwPuqE6+twjAMD3luNeJzRPYO0BVCgVoHotnbZnARh lO0rZZzCCWlp+6XQb90qIK4otuGmslP8aKow40WfMDjdJzHqPsLYL8UEqAoU1FlPvMju SmDUGXeaBPsJ1nkD1C655w+RzjJkKvD3KxXBKGs5bQAh8dJtXeT8rYLfN4ngneGPRe7D k/v9VYxeQBGLsB0p2VNeRppSdRlGmMVS+04v4LSTFfjrwC5rnzRXwAwnApngSIPAWs0A dH5Q== X-Gm-Message-State: AFqh2krK45dA9RXwJhpQNNTgAByWCcTU9I37zExHJce11Q4FiMXL3F5r 2I5VY8jWT+JHkByMLw7An2HUDTmawKxRWKGV X-Received: by 2002:a05:6a00:3311:b0:582:6732:ee03 with SMTP id cq17-20020a056a00331100b005826732ee03mr8142964pfb.9.1673561793131; Thu, 12 Jan 2023 14:16:33 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id d191-20020a621dc8000000b0058193135f6bsm12330658pfd.84.2023.01.12.14.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 14:16:32 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: bleung@chromium.org, heikki.krogerus@linux.intel.com, Prashant Malani , Greg Kroah-Hartman Subject: [PATCH 3/3] usb: typec: Make bus switch code retimer-aware Date: Thu, 12 Jan 2023 22:16:08 +0000 Message-Id: <20230112221609.540754-4-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230112221609.540754-1-pmalani@chromium.org> References: <20230112221609.540754-1-pmalani@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754857426912896321?= X-GMAIL-MSGID: =?utf-8?q?1754857426912896321?= Since ports can have retimers associated with them, update the Type-C alternate mode bus code to also set retimer state when the switch state is updated. While we are here, make the typec_retimer_dev_type declaration in the retimer.h file as extern, so that the header file can be successfully included in the bus code without redeclaration compilation errors. Signed-off-by: Prashant Malani Reviewed-by: Heikki Krogerus --- drivers/usb/typec/bus.c | 22 ++++++++++++++++++++++ drivers/usb/typec/retimer.h | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c index 9f1bbd26ca47..0c8d554240be 100644 --- a/drivers/usb/typec/bus.c +++ b/drivers/usb/typec/bus.c @@ -11,6 +11,22 @@ #include "bus.h" #include "class.h" #include "mux.h" +#include "retimer.h" + +static inline int +typec_altmode_set_retimer(struct altmode *alt, unsigned long conf, void *data) +{ + struct typec_retimer_state state; + + if (!alt->retimer) + return 0; + + state.alt = &alt->adev; + state.mode = conf; + state.data = data; + + return typec_retimer_set(alt->retimer, &state); +} static inline int typec_altmode_set_mux(struct altmode *alt, unsigned long conf, void *data) @@ -31,6 +47,12 @@ typec_altmode_set_mux(struct altmode *alt, unsigned long conf, void *data) static inline int typec_altmode_set_switches(struct altmode *alt, unsigned long conf, void *data) { + int ret; + + ret = typec_altmode_set_retimer(alt, conf, data); + if (ret) + return ret; + return typec_altmode_set_mux(alt, conf, data); } diff --git a/drivers/usb/typec/retimer.h b/drivers/usb/typec/retimer.h index e34bd23323be..d6a5ef9881e1 100644 --- a/drivers/usb/typec/retimer.h +++ b/drivers/usb/typec/retimer.h @@ -12,7 +12,7 @@ struct typec_retimer { #define to_typec_retimer(_dev_) container_of(_dev_, struct typec_retimer, dev) -const struct device_type typec_retimer_dev_type; +extern const struct device_type typec_retimer_dev_type; #define is_typec_retimer(dev) ((dev)->type == &typec_retimer_dev_type)