Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp930092rwb; Thu, 12 Jan 2023 14:27:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXs/WW94LuwOv2PKuEo6NUslQycxgn8E/BM8ptdFu89PmiMJQ5swmaR4boPppUkB0Hb5gOU8 X-Received: by 2002:a05:6a20:3d16:b0:9d:efbf:48c7 with SMTP id y22-20020a056a203d1600b0009defbf48c7mr113284538pzi.11.1673562422609; Thu, 12 Jan 2023 14:27:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673562422; cv=none; d=google.com; s=arc-20160816; b=aWu+IbCgp/F2SgGqU82c+qLjMvfaydSQ11+BiV9Hpp3rVSXcTH6lBmauKQ96WSgoWs nmxfARV9OgkgMgOfcnCm5VjzfkI8yhHonRQeckWlS2u2ngzdONqSs4mteW8197tujKRR VEshZOiD+jtTR6/2MF5wQi29mtLzWwIcFHwAA52/2Dnv6He8R93x7utDkeSgoGqhmRcf Wn57KBh6pTqNnpJW238cV1yR4x276/00W00EhEVZAGb+mfRXBHV3C6EhJExOGNnPoUBu Dl+D09cyI6tfO3ilfL3JaByfXxyYyx7vZ8/tV+maM4k27d+DFn4TB4fUVr0WhHbFrUh7 /Gzw== 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 Return-Path: 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.56; Thu, 12 Jan 2023 14:27:02 -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 + 50 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 Content-Transfer-Encoding: 8bit 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 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 --- 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; } -- 2.39.0.314.g84b9a713c41-goog