From patchwork Thu Jan 12 22:16:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 42851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4136003wrt; Thu, 12 Jan 2023 14:26:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXueYolofzR+uYXtQxEOenR38s1eKyMF/3yQvzYCLhQyhYbYGSvfCl1zrtpM/NH4KDwtInBC X-Received: by 2002:a05:6a20:c1a3:b0:af:7a3d:5102 with SMTP id bg35-20020a056a20c1a300b000af7a3d5102mr99645257pzb.62.1673562388849; Thu, 12 Jan 2023 14:26:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673562388; cv=none; d=google.com; s=arc-20160816; b=RCKws4NxLvk8SAO1SXc1I41AM7GppsNHCLVam0WeisyLqxFpjsasWcj6GpuBlmrD1P aBJPitNEwR2taUm8xH4L/4lMfawzTgvklOs29no/tTOosS5s2hoTXoRok7e8L15WwQWJ pqAgzX2y0Jv4X/WYx8G54A+Zo7PtZRTNd2/di40e0hNoWYc4yFk42W1jhC9i/rEtsIwg MDkw0PQmBFaLk0t0RDkYmL5wF0Zs45A9IhhncdQieA1S8Ao/G3zxX2Yuk/RpCOHks7cT mWJKBBfTcQf/lKK6o7YaamkWA2Wn0snpz7L+vqnaNUd00jCGY5OO3/DPDwghMgkdq0Ou 9erQ== 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=DjiuF0nk2Kld9KpyTDhRe2O6SrSLJ1BXqR8sAU0pb9U=; b=JxrETwA7/dMve+Ji3hNg0xhjD/mNsncxciaeGrhtMHZy5/+UR2DqT4Rj5hFoR3hqeK 8KvQloZO1Wt9fx5PUtZY7gmgWlxTKPMcwP54VX5rvOYaD+yEH/hyZSOW4nmT8q0HkjU2 7AD9jQVT/xXawCzgE9Kw8ebg14Aer3+qULbO9xK4HOdE42w7jQKji+KhpZoejyWjJRxq ewjwqIVaPCB56lezFVm5YXLANfdAn2xS4WtFMnakDn6VDV8I08uYVA90AUjb7rbUPPF+ wBOxx5T4he5wzfshRKOM5xBYxg9/t4ZC45gUhvPxc+mLF32/C/CsQM96lOMq1W5tYlaN WF8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oZlwH+7e; 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 o4-20020a655bc4000000b004a4677291e5si20037567pgr.606.2023.01.12.14.26.11; Thu, 12 Jan 2023 14:26:28 -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=oZlwH+7e; 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 S233589AbjALWXF (ORCPT + 99 others); Thu, 12 Jan 2023 17:23:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232908AbjALWWk (ORCPT ); Thu, 12 Jan 2023 17:22:40 -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 D1F541CB0A for ; Thu, 12 Jan 2023 14:16:25 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id 200so8677783pfx.7 for ; Thu, 12 Jan 2023 14:16:25 -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=DjiuF0nk2Kld9KpyTDhRe2O6SrSLJ1BXqR8sAU0pb9U=; b=oZlwH+7eiNMzSIWcVe5eQOtedrPcUmvYsQ9xgKiam4GhJtqz9USbZasRnjKseYbjGy 5hNUOJCi1IrDGf9VQHhDgRf5oWzCSJi6nRjDnqXi7kLkWOD316vLo1N1u64Nftmlu4fj G8cBo7eSLqFgU5dWh+Ei1rPvnGc3Q2aNkITKg= 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=DjiuF0nk2Kld9KpyTDhRe2O6SrSLJ1BXqR8sAU0pb9U=; b=DG8QpJypcTq6D3Zk8tUhdm4O2QV1uV9S/t/UYg7sAs3eA9Rn+GhBH+YH77VjYSYrtK 0AtG/+LH8VFkBpVCG/qY8imxNCY8WRmeDyUcI5Hd37+VyzQdwyR75gdVmx9N16lvIyJ1 MQdtXLhIHeYajMaOiqgNW4B8A0iJbnxyhL3kTXdEXlRMigcn6zh1F9Ji2P4QE9Fw7Zrh bGo1MQDsMV/Xz+KYB5TuDAG33U0e+FcFk8Zh8konyV44IN7XrdfFbOMs6UTSp2oqqn8H dh2MMUCva8QSvCrYcWtl7cmOWdjmFGkdQLwTBll4g9um91wwFvKdon6fA4UwyMX7GG9s 5JHQ== X-Gm-Message-State: AFqh2kob7R2b2a4epcXCTW5NXgMMaR4RXrvHKw3P50JgIspXTroWBpiT /8ZvQ8fnUiz23SUg4xVEqDm16yrFMSbjCT/l X-Received: by 2002:a62:5801:0:b0:574:a541:574a with SMTP id m1-20020a625801000000b00574a541574amr72123429pfb.0.1673561785239; Thu, 12 Jan 2023 14:16:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 14:16:24 -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 1/3] usb: typec: Add retimer handle to port altmode Date: Thu, 12 Jan 2023 22:16:06 +0000 Message-Id: <20230112221609.540754-2-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?1754857355134708573?= X-GMAIL-MSGID: =?utf-8?q?1754857355134708573?= Just like it does with muxes, the Type-C bus code can update the state of connected retimers (especially when altmode-related transitions occur). Add a retimer handle to the port altmode struct to enable this. Signed-off-by: Prashant Malani Reviewed-by: Heikki Krogerus --- drivers/usb/typec/bus.h | 2 ++ drivers/usb/typec/class.c | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/bus.h b/drivers/usb/typec/bus.h index 56dec268d4dd..c89168857417 100644 --- a/drivers/usb/typec/bus.h +++ b/drivers/usb/typec/bus.h @@ -7,11 +7,13 @@ struct bus_type; struct typec_mux; +struct typec_retimer; struct altmode { unsigned int id; struct typec_altmode adev; struct typec_mux *mux; + struct typec_retimer *retimer; enum typec_port_data roles; diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 5897905cb4f0..ed3d070b1ca4 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -583,6 +583,7 @@ void typec_unregister_altmode(struct typec_altmode *adev) { if (IS_ERR_OR_NULL(adev)) return; + typec_retimer_put(to_altmode(adev)->retimer); typec_mux_put(to_altmode(adev)->mux); device_unregister(&adev->dev); } @@ -2108,16 +2109,26 @@ typec_port_register_altmode(struct typec_port *port, { struct typec_altmode *adev; struct typec_mux *mux; + struct typec_retimer *retimer; mux = typec_mux_get(&port->dev, desc); if (IS_ERR(mux)) return ERR_CAST(mux); + retimer = typec_retimer_get(&port->dev); + if (IS_ERR(retimer)) { + typec_mux_put(mux); + return ERR_CAST(retimer); + } + adev = typec_register_altmode(&port->dev, desc); - if (IS_ERR(adev)) + if (IS_ERR(adev)) { + typec_retimer_put(retimer); typec_mux_put(mux); - else + } else { to_altmode(adev)->mux = mux; + to_altmode(adev)->retimer = retimer; + } return adev; } From patchwork Thu Jan 12 22:16:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prashant Malani X-Patchwork-Id: 42852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4136387wrt; Thu, 12 Jan 2023 14:27:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXtw5bhxTVBzjwiKBrqLuXMbPtb7OJKMxtb7sffJ04GYz3bttA5CFnL+3F+B3Ph22ogvfKxt X-Received: by 2002:a17:902:9888:b0:192:ce7e:93b7 with SMTP id s8-20020a170902988800b00192ce7e93b7mr40253132plp.49.1673562452153; Thu, 12 Jan 2023 14:27:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673562452; cv=none; d=google.com; s=arc-20160816; b=r9RW1DotuBjM900sB5M28yPMshEW+ZY1/FSdO/iUQmHWXkeBeHiuRn5gyc9T7ciUHe ny4bFyojfzQEjatTGY57AZu+p/p8RDFluU3UGobBH+pfKpQuH86tyI6bRi5OIy96+/DC KEd2L+GbitCQnlVeOHdhmXQmY0nk7UWdjNQHkaw6ANg5Hx/1l0FxkbS54KBv4T+wOpjQ pG1Yl0KEBs+WokXd/2zcb4T2gh5cvPXfVCFBC995ZTurf91x3Ys7k62RcjpYCnShICeK Bsxbzj2GscR7WfmdIvzdv3l0K+SzXeLhfVl6mtRqb8cDN8eOd8WPcMTTrqOWd29Qe0b0 k9lg== 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=ZaweIEmq0HPzqbMZsHX/5KqxEfI0AK60Sg/9xC2e0nw=; b=LjfsqN4QkdhlO5E33S0Pfw3r1MjZ4fT/UEfGSeHMEamYv74VjcJWl48WBKZkQmCAmj IBdudFPpDPPEXRl7oW06d25qoRk6x9D8Xb1Ah0Seqs3W7JKuuk7jALVWpXtC4qveOOr6 qUl6Rf8a6HAwf9bSKefv4Q+mrX8W2Z8uvjpk1sdZGRl7UmnH8YQ4hzSiLDHlMFPKIfcc 6sQhjt/TUPN8QrZE3AEvG7bZP7JeZeOzHnHWyWxguFVGSM9874xVLLf4XqRkpAqsjbPO raAe9kzMikopd4O8J9cQ9rhoQnmmq1cNjncTeR+egO6O8AJdGM7XpYB6u2GRn5ImOMty YOUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AEnDVzdm; 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 n13-20020a170902e54d00b001929dfd3fd7si8609765plf.578.2023.01.12.14.27.14; Thu, 12 Jan 2023 14:27:32 -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=AEnDVzdm; 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 S240562AbjALWXL (ORCPT + 99 others); Thu, 12 Jan 2023 17:23:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240066AbjALWWl (ORCPT ); Thu, 12 Jan 2023 17:22:41 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14C971CB11 for ; Thu, 12 Jan 2023 14:16:29 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id e10so13738735pgc.9 for ; Thu, 12 Jan 2023 14:16:29 -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=ZaweIEmq0HPzqbMZsHX/5KqxEfI0AK60Sg/9xC2e0nw=; b=AEnDVzdmu2UBDjpJSwKIR+H3w4ZA+cGy28te8O8B6LwcJ3OHPDMy7KuF7X/BTuAYow LSZJOk/Vpya21bQ8eEVdUWudOzXg2h0zt/0KH2rINXDqPGueIKrY/YM2nGCbe1UJyGzW woxeEE3JKSEUivGkiHmPgfmY8PUqlwSRtpcBg= 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=ZaweIEmq0HPzqbMZsHX/5KqxEfI0AK60Sg/9xC2e0nw=; b=61Q8HapJ7LTHMty6HHMw48/wUIp3kuuzWrS3sV7eiqTA7Lk7yyALitrysV7RhNf8gY go6sozty3XuiPcjUIHPZj1L0wJSbG7sc9j0wY6IZCNgZELhyksc6pZbmWf0WH0oHh7aM oNCeqG7FI7aK5h/7I1hAd3zx0FRemWCwkwc7T2AT+MDze6WTM1EwbRj0r07kq4531On3 URdvMJPlOAFmlb48O7s69JuF/Agnc9dQ1BidBWhUkZb6p1jIF1UCmsNu9Sl9iTEahvmd kf/h/mWYw54OtwWqyVYqj6orWp0HUCJsP6sAyVNSs5bOMSTyrf7iTVfGUsy8eGkfoWD2 zkbg== X-Gm-Message-State: AFqh2krNTxe0f7GZ517Qkqah2Xe3pzAs5nVczcmToj6gkCXsU+IP2G1c 93I3coqg/gLTUAGQPrdqFG55lkepYT2Xa27x X-Received: by 2002:a62:1887:0:b0:582:5886:e1b7 with SMTP id 129-20020a621887000000b005825886e1b7mr38083089pfy.14.1673561788350; Thu, 12 Jan 2023 14:16:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 14:16:28 -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 2/3] usb: typec: Add wrapper for bus switch set code Date: Thu, 12 Jan 2023 22:16:07 +0000 Message-Id: <20230112221609.540754-3-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?1754857421891370206?= X-GMAIL-MSGID: =?utf-8?q?1754857421891370206?= Add a wrapper that calls the set() function for various switches associated with a port altmode. Right now, it just wraps the existing typec_mux_set() command, but it can be expanded to include other switches in future patches. No functional changes introduced by this patch. Signed-off-by: Prashant Malani Reviewed-by: Heikki Krogerus --- drivers/usb/typec/bus.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/bus.c b/drivers/usb/typec/bus.c index 31c2a3130cad..9f1bbd26ca47 100644 --- a/drivers/usb/typec/bus.c +++ b/drivers/usb/typec/bus.c @@ -27,6 +27,13 @@ typec_altmode_set_mux(struct altmode *alt, unsigned long conf, void *data) return typec_mux_set(alt->mux, &state); } +/* Wrapper to set various Type-C port switches together. */ +static inline int +typec_altmode_set_switches(struct altmode *alt, unsigned long conf, void *data) +{ + return typec_altmode_set_mux(alt, conf, data); +} + static int typec_altmode_set_state(struct typec_altmode *adev, unsigned long conf, void *data) { @@ -35,7 +42,7 @@ static int typec_altmode_set_state(struct typec_altmode *adev, port_altmode = is_port ? to_altmode(adev) : to_altmode(adev)->partner; - return typec_altmode_set_mux(port_altmode, conf, data); + return typec_altmode_set_switches(port_altmode, conf, data); } /* -------------------------------------------------------------------------- */ @@ -73,7 +80,7 @@ int typec_altmode_notify(struct typec_altmode *adev, is_port = is_typec_port(adev->dev.parent); partner = altmode->partner; - ret = typec_altmode_set_mux(is_port ? altmode : partner, conf, data); + ret = typec_altmode_set_switches(is_port ? altmode : partner, conf, data); if (ret) return ret; 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)