From patchwork Mon Jun 19 07:58:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 694201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F6F0EB64DD for ; Mon, 19 Jun 2023 07:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230150AbjFSH6v (ORCPT ); Mon, 19 Jun 2023 03:58:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229807AbjFSH6q (ORCPT ); Mon, 19 Jun 2023 03:58:46 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A2D2E61 for ; Mon, 19 Jun 2023 00:58:42 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-4f85966b0f2so3299110e87.3 for ; Mon, 19 Jun 2023 00:58:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687161521; x=1689753521; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8W4DDI67tlbAaFkIpRMuH4m4GXyLOYQLIt7UXn6qsRg=; b=RQt3m4J4Da/tuK8Zr7xcxMZ4jMfOpQCtBBssjfPgcE2rfOPo+ipfSAbt0HMrZMx0Dv tfuTOWC2gx2gH0VwvHBQ0PCHlGjEa+gdQAhvjec+iSUgRhuz6HwG9KGlVnEv7JNuWczL nyjhzISwF5yVkzMvW7IkiGpZvnr3ywvE15XagXitmuAYYxzG9Cj+EF+l1J4nmu+oRC+k gN3VtWaOlMj7xmNRhR14Y2IMxlM/ljL7yO+/wogm4/oamjuB5uK7u0qpq/7aFVov+O+Z GY8UuQD0DvN0xMJcE5R6UiiQnSUQLufTlx47WglX3oHVFRe2nOZr9H+f1fEx9JrMYMgU mxbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687161521; x=1689753521; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8W4DDI67tlbAaFkIpRMuH4m4GXyLOYQLIt7UXn6qsRg=; b=R/KE99MLllndZV5jVOgj0GeoOY4efuG6nezD0rKSQF9iqL8w+ZjwhA2Ct6HpEsI/RN Dqo87+68b3QcQEVSqaN4UumDGVdw8N8n58UEEdIEvARKRYBhVhU+KGadBRB3pkCC6sxY fppxxEq3My768csxyAt3dmd4KBGDoNgUwj1dUorsFdoQIi4Ue5YeO82RCfQv5Wkz2jCi gYPh2+9VR2u1qegsUEo90rw93dKJH4iR8BrA6aTgGkXgHby+tGuZmEeF2S73VEnytH2e IYGq9WquJN0fR+5Ons2lTsnnylwAFIGAl6EhhBg+A/AlAdvSacxSPBFq9kiJSuwYuNSd 0gww== X-Gm-Message-State: AC+VfDxynGdgu2annDfUaUrw/b/offClcoYu0GvfLQWAVmbncLAcsjfq 3AVJOACBqBhY557gm+lFm3kbAA== X-Google-Smtp-Source: ACHHUZ7XGvKnV3yJAy5//KAzL08FM8XkI69KFiNDDy7AAxhwdpdQh8KKDUkpNE2XOzRdZACCyZ81EQ== X-Received: by 2002:a19:385a:0:b0:4f4:b38c:1f8a with SMTP id d26-20020a19385a000000b004f4b38c1f8amr3885028lfj.53.1687161520705; Mon, 19 Jun 2023 00:58:40 -0700 (PDT) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:8261:5fff:fe11:bdda]) by smtp.gmail.com with ESMTPSA id v5-20020a05600c214500b003f7f87ba116sm7091491wml.19.2023.06.19.00.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 00:58:40 -0700 (PDT) From: Neil Armstrong Date: Mon, 19 Jun 2023 09:58:17 +0200 Subject: [PATCH v4 2/6] qcom: pmic_glink_altmode: add retimer-switch support MIME-Version: 1.0 Message-Id: <20230601-topic-sm8550-upstream-type-c-v4-2-eb2ae960b8dc@linaro.org> References: <20230601-topic-sm8550-upstream-type-c-v4-0-eb2ae960b8dc@linaro.org> In-Reply-To: <20230601-topic-sm8550-upstream-type-c-v4-0-eb2ae960b8dc@linaro.org> To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Neil Armstrong X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3944; i=neil.armstrong@linaro.org; h=from:subject:message-id; bh=fCvaaaAL0Gx7Xnks6/BexPRt3VhZDwY4J3jOffW33Do=; b=owEBbQKS/ZANAwAKAXfc29rIyEnRAcsmYgBkkAqr+oPppKm8uZmmn0MEZmkNcfdKZZnK4rEpqr6u NMCVHfuJAjMEAAEKAB0WIQQ9U8YmyFYF/h30LIt33NvayMhJ0QUCZJAKqwAKCRB33NvayMhJ0YvwD/ 9DbP8N9jvpgqvOx0972X413z5tywwCs3FQ3i/fc7wn2PkjCzlo//ORWwH03fjmuzH17DbVmvB0vpJF DEbjl03DdUHUaUwRdLSfVWb4Tu3kWkutrfcZ6q756aayzO8O/kr2Q1lxqESzuCh7eFJVgQagXPIUjj 6crg87jFDwn3+yt7jxmWZVdFWkFF4MuGKVpTEdcZ1UwWO6zkpNoBuOte2w4Y037I/6W7FNfYMCRq3U CvER9TwUUs8NXweEq58qcqDc+OdlqItqicrLPljSNof+q8FwreWh7ZOiwquRmLGZzRAQ5cuauILLqy rHlMY3ur7fzcDjyzmt/bUJLE0zg2dtvgq87fPa10BN7585gnObYTLaqbfR3w+HGovlPSvaE1cLAyrY RSP6v3UCLs0yh7P6ePxVcjK1i3fDaYKUEw2S1hX9ro67wwUX3isDWQzzYcPDodgR5LRPoYSWmAhezJ 1AYqiU/nAoV7vQe4TB2kH+w0mEioRrSnvn3IetGXwfexobr6tAYNMtmIjE4pa1vncNn6IWHfG7Sb8I G3lAfIbZS2zzThCHUpuM8ZJ5+TvaBBey3Q6eEnzGPCKBWq9ZUQGsbStC6ymRKp0ChesfHbtJmkZrOH grV1SW15pN2mo6OjHz6kTu/fP5MZqDNLYHJx/s5aQzKN44q3IO9fuUUWuCEQ== X-Developer-Key: i=neil.armstrong@linaro.org; a=openpgp; fpr=89EC3D058446217450F22848169AB7B1A4CFF8AE Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 --- 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),