Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2395948lqp; Sun, 24 Mar 2024 17:38:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXeTnsDI3wKB2rvZ8YXP3/KCEvSExNSJ27cEETlOZW89JAVAf7FxN2YeLBAC1PBdUVdynt2NlqmREHPS9i+wuXobdorfPos6CVNICu/BQ== X-Google-Smtp-Source: AGHT+IFXqwZFrAJejSl5PHxtVrD0NGNevFwj/HR6v5+0xXGDhnivUDkDsdc4DzhDNq0eyxQ9YCwa X-Received: by 2002:a50:8e01:0:b0:56b:a8ea:9642 with SMTP id 1-20020a508e01000000b0056ba8ea9642mr5145194edw.14.1711327127499; Sun, 24 Mar 2024 17:38:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711327127; cv=pass; d=google.com; s=arc-20160816; b=CaXr+yKe+K1GiCbzj3nSqnpdHn0/o3tXmM6momoWB7fYyrl/Ca/ogxxg5HzZPCzEhw TCl8jnteNp9YNZ6My5jlNa0F4h3y0vHpldeLU/HrlMX0Ngt2n2mjYdumTbT7GOUsl1oD +3Q+g/VZTIMYxmwZAjs2us/GWwW++1hPTCHZTcKhyFooiMVWJXXvkhj6kNQUu1ng7jdH rrR0xDz3b/0Ixpb3cetZmQvT8aPzDlepLKHLCuc6so1LmLcb25Pm+255Hd2dtz/1EXy4 FiIhJuix0di/9QiNnlbeGhyvEsnk5nxNbzJ/jsMShmceV+8lrJamzWYdsqFCNA7D1WpY vpvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=M9DGbqvco5+2MueS4mVmLV1Ko8/K4YQJsBskmmWLDs0=; fh=H9a6Iymg6zhOGInV0rasw6sWPUZSmSbTJREAnyowo2M=; b=xmlSDHjXtVIX/tBOdlsMTwp//YlTl7TEn1gnB4bjdgxc7GzI2fgnyuhE5D/pMQsBj0 Glj2r4NaqVhWdE61FmbDk6aATOzgzqHt2G67dSdpxkBH+tciPTy6OwFLqN6q0jBrC60Z +zwpJSK85u/sGzh21Uw+okjEQQdfRMG8javkXYv0EaXeXhDib2L43tlVWTLS3bucNYvV 5TuFVYNI9rArDSx7YwfjbTP62toNwvFx/+AqA/Gy06GDIHUSSMnHiZt8i2zv0xXuaFI3 tRAcgeK/cNPu7Rjf41g4tzGHl5zZeAuuPoe7DkzCGIlOkAf+btd4OOC2pPzJ9nk9ykQa 2R5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rJdcxo2F; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113446-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113446-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q29-20020a50aa9d000000b0056beaa1c108si2007996edc.579.2024.03.24.17.38.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:38:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113446-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rJdcxo2F; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113446-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113446-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 10CBB1F21899 for ; Mon, 25 Mar 2024 00:38:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 085851ACFE8; Sun, 24 Mar 2024 22:44:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rJdcxo2F" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECF3013AD34; Sun, 24 Mar 2024 22:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320248; cv=none; b=qViO1TI50aSSvrtj1ZHDPPh6P1UP5l2Qmh9xaXL7JyC6uRI9ZobNH7GK9EXrm2S8dqyoxq5mI8TuBjWcr+g6i32JQKbYWU34z72Q/hPI8dku8GDaVuqAjLcfI/F4XKD5Dji7PTXhh9Kqr4i0P27EPh4opKE/zJ5wp2qf+Nh0gGo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320248; c=relaxed/simple; bh=9ObjapYVqvVQnhfvnn3+MTqwP2ZcRAUoO8UfIdlYbfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aJjzVmeZLmQIoz3Hub4YwF1z89HlbXDAgNDn3BBiot713pVM4WqabsOtz76LeHIHv0oq1XQ3BjB0HZJzHeOII/wxV1tc0yuOx+hBUSuNlq0Uyzaafe4UAN1Q1b2IxhH9lOAv32Ci2vC7osKcIjcw61Z695/94u2nbzVypW8HST4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rJdcxo2F; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C65BC433B2; Sun, 24 Mar 2024 22:44:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320247; bh=9ObjapYVqvVQnhfvnn3+MTqwP2ZcRAUoO8UfIdlYbfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rJdcxo2FMEH7U5ZZf3fV1r8kMJk7uee3y+WrsCvb3IpxiUcN97YWYjI85Mpwq66aZ RgbI2JsMG2jUnB1PwkaV+pHVebF7Sf3Q+RtNHAUk2MAy58dGqDfIPxR1o5y8K63/vG zpYY3GE7XHvp8wqxYPFquu+jBaN2zJCXHOKG8NOoyKyOBRim6IB1kFu6IuHKIhPHn0 f8SF/r6EJ4q2B7v+aYM8uJoBV2f+HZ83Ml0xD+Yg8p29RZYlVw0o66/csS80gZYX1o 1/bwl9M5NGlzn4C/ZXwwFVGV400wyQhqmUacb35mSeVtJhL1US4KmXbkuprQTofifL jZoehmHihjSkw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dmitry Baryshkov , Jeffrey Hugo , Konrad Dybcio , Vinod Koul , Sasha Levin Subject: [PATCH 6.8 555/715] phy: qcom: qmp-usbc: handle CLAMP register in a correct way Date: Sun, 24 Mar 2024 18:32:14 -0400 Message-ID: <20240324223455.1342824-556-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Dmitry Baryshkov [ Upstream commit 01b086ccdeffac96f107228d581e0925e1c83f87 ] The QMP USB PHYs on msm8998, qcm2290 and some other platforms don't have the PCS_MISC_CLAMP_ENABLE register. Instead they need to toggle the register in the TCSR space. Make the new phy-qcom-qmp-usbc driver correctly handle the clamp register. Fixes: a51969fafc82 ("phy: qcom-qmp: Add QMP V3 USB3 PHY support for msm8998") Fixes: 8abe5e778b2c ("phy: qcom-qmp: Add QCM2290 USB3 PHY support") Cc: Jeffrey Hugo Signed-off-by: Dmitry Baryshkov Acked-by: Konrad Dybcio Link: https://lore.kernel.org/r/20240117-usbc-phy-vls-clamp-v2-3-a950c223f10f@linaro.org Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/qualcomm/phy-qcom-qmp-usbc.c | 48 ++++++++++++++++++------ 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c b/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c index 214cf4203de41..3a4b4849db0f5 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usbc.c @@ -10,11 +10,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -56,9 +58,6 @@ /* QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR register bits */ #define IRQ_CLEAR BIT(0) -/* QPHY_V3_PCS_MISC_CLAMP_ENABLE register bits */ -#define CLAMP_EN BIT(0) /* enables i/o clamp_n */ - #define PHY_INIT_COMPLETE_TIMEOUT 10000 struct qmp_phy_init_tbl { @@ -94,7 +93,6 @@ enum qphy_reg_layout { QPHY_PCS_AUTONOMOUS_MODE_CTRL, QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR, QPHY_PCS_POWER_DOWN_CONTROL, - QPHY_PCS_MISC_CLAMP_ENABLE, /* Keep last to ensure regs_layout arrays are properly initialized */ QPHY_LAYOUT_SIZE }; @@ -106,7 +104,6 @@ static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = QPHY_V3_PCS_AUTONOMOUS_MODE_CTRL, [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = QPHY_V3_PCS_LFPS_RXTERM_IRQ_CLEAR, [QPHY_PCS_POWER_DOWN_CONTROL] = QPHY_V3_PCS_POWER_DOWN_CONTROL, - [QPHY_PCS_MISC_CLAMP_ENABLE] = QPHY_V3_PCS_MISC_CLAMP_ENABLE, }; static const unsigned int qmp_v3_usb3phy_regs_layout_qcm2290[QPHY_LAYOUT_SIZE] = { @@ -369,6 +366,9 @@ struct qmp_usbc { void __iomem *tx2; void __iomem *rx2; + struct regmap *tcsr_map; + u32 vls_clamp_reg; + struct clk *pipe_clk; struct clk_bulk_data *clks; int num_clks; @@ -691,7 +691,6 @@ static void qmp_usbc_enable_autonomous_mode(struct qmp_usbc *qmp) { const struct qmp_phy_cfg *cfg = qmp->cfg; void __iomem *pcs = qmp->pcs; - void __iomem *pcs_misc = qmp->pcs_misc; u32 intr_mask; if (qmp->mode == PHY_MODE_USB_HOST_SS || @@ -712,19 +711,18 @@ static void qmp_usbc_enable_autonomous_mode(struct qmp_usbc *qmp) qphy_setbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], intr_mask); /* Enable i/o clamp_n for autonomous mode */ - if (pcs_misc && cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE]) - qphy_clrbits(pcs_misc, cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE], CLAMP_EN); + if (qmp->tcsr_map && qmp->vls_clamp_reg) + regmap_write(qmp->tcsr_map, qmp->vls_clamp_reg, 1); } static void qmp_usbc_disable_autonomous_mode(struct qmp_usbc *qmp) { const struct qmp_phy_cfg *cfg = qmp->cfg; void __iomem *pcs = qmp->pcs; - void __iomem *pcs_misc = qmp->pcs_misc; /* Disable i/o clamp_n on resume for normal mode */ - if (pcs_misc && cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE]) - qphy_setbits(pcs_misc, cfg->regs[QPHY_PCS_MISC_CLAMP_ENABLE], CLAMP_EN); + if (qmp->tcsr_map && qmp->vls_clamp_reg) + regmap_write(qmp->tcsr_map, qmp->vls_clamp_reg, 0); qphy_clrbits(pcs, cfg->regs[QPHY_PCS_AUTONOMOUS_MODE_CTRL], ARCVR_DTCT_EN | ARCVR_DTCT_EVENT_SEL | ALFPS_DTCT_EN); @@ -1063,6 +1061,30 @@ static int qmp_usbc_parse_dt(struct qmp_usbc *qmp) return 0; } +static int qmp_usbc_parse_vls_clamp(struct qmp_usbc *qmp) +{ + struct of_phandle_args tcsr_args; + struct device *dev = qmp->dev; + int ret; + + /* for backwards compatibility ignore if there is no property */ + ret = of_parse_phandle_with_fixed_args(dev->of_node, "qcom,tcsr-reg", 1, 0, + &tcsr_args); + if (ret == -ENOENT) + return 0; + else if (ret < 0) + return dev_err_probe(dev, ret, "Failed to parse qcom,tcsr-reg\n"); + + qmp->tcsr_map = syscon_node_to_regmap(tcsr_args.np); + of_node_put(tcsr_args.np); + if (IS_ERR(qmp->tcsr_map)) + return PTR_ERR(qmp->tcsr_map); + + qmp->vls_clamp_reg = tcsr_args.args[0]; + + return 0; +} + static int qmp_usbc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -1093,6 +1115,10 @@ static int qmp_usbc_probe(struct platform_device *pdev) if (ret) return ret; + ret = qmp_usbc_parse_vls_clamp(qmp); + if (ret) + return ret; + /* Check for legacy binding with child node. */ np = of_get_child_by_name(dev->of_node, "phy"); if (np) { -- 2.43.0