Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp15887444rwd; Mon, 26 Jun 2023 02:45:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6USpnCCrJjOlUccnap9TjMw5F26J8kxORylDIAuxWm6sMdMTMLMis7QLHeXVY9bX8WgI5X X-Received: by 2002:a05:6402:6c4:b0:51d:a012:ec2 with SMTP id n4-20020a05640206c400b0051da0120ec2mr808558edy.3.1687772750293; Mon, 26 Jun 2023 02:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687772750; cv=none; d=google.com; s=arc-20160816; b=r70aAS+g5Z9iaesCm6fiQhHpBJfNAsLL7gRZAZMQ1GBywvM6uc+CO/NqYdhyo/rMdD R/zOUwtS1EMl9jmcoUoTPCRHL0vcsq4G4KKvxJMuvgGK6pY6MRbm6xGYaiR66S93w4y5 V2EXIFXGkchgD8kyfb+sHP6X0VBqOTWxeX+RFFO4nMr/S5ufU660GMF5yW29rrQmSjJ/ rFhf25s93BNeXO3on7fYF4bkKc9s8lcwPfSH08FOqPvDupxiWb9/x1PoWfGNUoBg4tlf IdbHLXj5AaE6ZEU+daJBUvfy/Q4m1eq9eabZJfjf8kEHyJ0qan73o8eZv5wK5SNV6ubl gLWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0orxW9/p2Z1rpACvvsThMVGXi4bPq0PZR7vTwEqPcaQ=; fh=cKGHk9Gg99im/ndB7neEy6p+gbpnuK/3l3rybi1eZbk=; b=cvZkXuRBZqdPtUCxh6F8N8MQoGUypOAFisMC6Crf7wpWazjkwWvRs/EWFuQiIVdDhr lRysRElVVeDwPBgj9pxdJolOCFs9EpZkgWzSyRxYZTfDuh9oCdUwMOlKth9nfkEnRM4r ZRC1fw9vfKdsKb5oK8DYpgwqscnNhAES/gIVA9GqYcIdrxQR7qVNL3/TTMIdevuBJvhz 7k7gNYv7KRaERKx/YVVeMlQ6Vp35B0KG/A5KVhlvWjo0U7o2IsGUzF97ZLual4Sotlwz uxdeWmkUluvuRck7BGkK4NdRvEl5dATrQDzyJ/pdUSUyEgOiVDFBbYSJS+QWfIPRvcq4 M6xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="A+M/UZFQ"; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g18-20020a056402181200b0051d96a5ff44si1303296edy.299.2023.06.26.02.45.26; Mon, 26 Jun 2023 02:45:50 -0700 (PDT) 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=@intel.com header.s=Intel header.b="A+M/UZFQ"; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230263AbjFZJWP (ORCPT + 99 others); Mon, 26 Jun 2023 05:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbjFZJVt (ORCPT ); Mon, 26 Jun 2023 05:21:49 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3DE22951; Mon, 26 Jun 2023 02:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687771190; x=1719307190; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=4iirlHjDQFEOmwfWu25Zqlp+FjDKn3qrPL7a4DX2oxs=; b=A+M/UZFQUjCFGzotGIOlX78dhQTyVY+i+g9bUJod9QSCk/SXAT349Eb/ BxPiBp7u64yhfgINjY9T+ZdmeKTB4BRd/SB+GCmdqJZa4zS4oj5AFrxGs WA1IFVhpfD+wkUcKZACJ5nNq7s798pJgK34APhCgnEsA1XTZNrFyu/SkT OxIytmIvMql3Bb/ztYetu+t1QvKM9pryDGygQKAsTkp7VsCm9Y6xkiAAK 2uCAKhQ8QBzUcKqLl82YL8sJZ4zaH7euvc0W7XbgkwJBl/8B+TlDRnriu eJOMYYQFUsOd54K/PZi05qItPEPVtUHX9frtuyoYDKP8dorls1u7RQzxR A==; X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="447605392" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="447605392" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2023 02:19:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="860618521" X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="860618521" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 26 Jun 2023 02:19:31 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Mon, 26 Jun 2023 12:19:31 +0300 Date: Mon, 26 Jun 2023 12:19:31 +0300 From: Heikki Krogerus To: Neil Armstrong Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Andy Gross , Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman , Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH v3 4/8] qcom: pmic_glink_altmode: add retimer-switch support Message-ID: References: <20230601-topic-sm8550-upstream-type-c-v3-0-22c9973012b6@linaro.org> <20230601-topic-sm8550-upstream-type-c-v3-4-22c9973012b6@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230601-topic-sm8550-upstream-type-c-v3-4-22c9973012b6@linaro.org> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Tue, Jun 13, 2023 at 09:55:57AM +0200, Neil Armstrong wrote: > Some boards have a retimer/redriver between the SuperSpeed > PHY and the USB-C connector to compensates signal integrity > losses mainly due to PCB & transmission cables. > > Add support for an optional retimer-switch in the USB-C > connector graph. > > Signed-off-by: Neil Armstrong Acked-by: Heikki Krogerus > --- > drivers/soc/qcom/pmic_glink_altmode.c | 43 +++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c > index 007d308e2f15..41d732f5b647 100644 > --- a/drivers/soc/qcom/pmic_glink_altmode.c > +++ b/drivers/soc/qcom/pmic_glink_altmode.c > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > #include > > @@ -68,6 +69,8 @@ struct pmic_glink_altmode_port { > struct typec_switch *typec_switch; > struct typec_mux *typec_mux; > struct typec_mux_state state; > + struct typec_retimer *typec_retimer; > + struct typec_retimer_state retimer_state; > struct typec_altmode dp_alt; > > struct work_struct work; > @@ -157,6 +160,14 @@ static void pmic_glink_altmode_enable_dp(struct pmic_glink_altmode *altmode, > ret = typec_mux_set(port->typec_mux, &port->state); > if (ret) > dev_err(altmode->dev, "failed to switch mux to DP\n"); > + > + port->retimer_state.alt = &port->dp_alt; > + port->retimer_state.data = &dp_data; > + port->retimer_state.mode = TYPEC_MODAL_STATE(mode); > + > + ret = typec_retimer_set(port->typec_retimer, &port->retimer_state); > + if (ret) > + dev_err(altmode->dev, "failed to setup retimer to DP\n"); > } > > static void pmic_glink_altmode_enable_usb(struct pmic_glink_altmode *altmode, > @@ -171,6 +182,14 @@ static void pmic_glink_altmode_enable_usb(struct pmic_glink_altmode *altmode, > ret = typec_mux_set(port->typec_mux, &port->state); > if (ret) > dev_err(altmode->dev, "failed to switch mux to USB\n"); > + > + port->retimer_state.alt = NULL; > + port->retimer_state.data = NULL; > + port->retimer_state.mode = TYPEC_STATE_USB; > + > + ret = typec_retimer_set(port->typec_retimer, &port->retimer_state); > + if (ret) > + dev_err(altmode->dev, "failed to setup retimer to USB\n"); > } > > static void pmic_glink_altmode_safe(struct pmic_glink_altmode *altmode, > @@ -185,6 +204,14 @@ static void pmic_glink_altmode_safe(struct pmic_glink_altmode *altmode, > ret = typec_mux_set(port->typec_mux, &port->state); > if (ret) > dev_err(altmode->dev, "failed to switch mux to safe mode\n"); > + > + port->retimer_state.alt = NULL; > + port->retimer_state.data = NULL; > + port->retimer_state.mode = TYPEC_STATE_SAFE; > + > + ret = typec_retimer_set(port->typec_retimer, &port->retimer_state); > + if (ret) > + dev_err(altmode->dev, "failed to setup retimer to USB\n"); > } > > static void pmic_glink_altmode_worker(struct work_struct *work) > @@ -347,6 +374,11 @@ static const struct drm_bridge_funcs pmic_glink_altmode_bridge_funcs = { > .attach = pmic_glink_altmode_attach, > }; > > +static void pmic_glink_altmode_put_retimer(void *data) > +{ > + typec_retimer_put(data); > +} > + > static void pmic_glink_altmode_put_mux(void *data) > { > typec_mux_put(data); > @@ -453,6 +485,17 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev, > if (ret) > return ret; > > + alt_port->typec_retimer = fwnode_typec_retimer_get(fwnode); > + if (IS_ERR(alt_port->typec_retimer)) > + return dev_err_probe(dev, PTR_ERR(alt_port->typec_retimer), > + "failed to acquire retimer-switch for port: %d\n", > + port); > + > + ret = devm_add_action_or_reset(dev, pmic_glink_altmode_put_retimer, > + alt_port->typec_retimer); > + if (ret) > + return ret; > + > alt_port->typec_switch = fwnode_typec_switch_get(fwnode); > if (IS_ERR(alt_port->typec_switch)) > return dev_err_probe(dev, PTR_ERR(alt_port->typec_switch), > > -- > 2.34.1 -- heikki