From nobody Mon Sep 15 11:12:04 2025 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 DD9B0C54EBD for ; Fri, 13 Jan 2023 00:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbjAMAyo (ORCPT ); Thu, 12 Jan 2023 19:54:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232713AbjAMAyN (ORCPT ); Thu, 12 Jan 2023 19:54:13 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7FE713DCA for ; Thu, 12 Jan 2023 16:54:12 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id s13-20020a17090a6e4d00b0022900843652so3862234pjm.1 for ; Thu, 12 Jan 2023 16:54:12 -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=mYLtqXctG0w1LDFrtR6bI6BtOkIAb//0EdxGpdC0Co8=; b=W8yTfno6MmIJHmnAjTFoN9Fq6mR6U4UbfNzG0fYw4g8/AfMBbpxuOPPe6tULefgZtL BIuXTKSFvb4r6hQ5qH3XVuQyMfXLZ4I4LqZCLCyT8tXePbX8IVSPEjX8lgnnAOYnuJ9A muFX8SBY9q4Q9MzxBg41WOtgwhODwuzLRpJYo= 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=mYLtqXctG0w1LDFrtR6bI6BtOkIAb//0EdxGpdC0Co8=; b=kmt1NssD/RTwuKT4nhjbQUWpHjZBj0eISPMv9YBmL6xfoZWsPf/fPd69CVyRvyYd4y +07COHgsG00aVkND1QSa9Db7BCUTPkXGV5yI3pgpMynqXFlv/p618Vb3p3Nc3kuY8fpy 5LyaeEyWDxvfE0GxT3Snrb8h0I9SdDsphtv7lg2oJ8BVUatyGPG9nV/pJq9bDwyGEjO1 yqeqZrHqep8iA7zDkBC+0gDnnAWprYuzzG6+8kff+BjH1l/MnwSXMWwjuBV4Xfur7mAr SbiJQemsufKUdsOx435KpeIz6ud79be3a3yDMAbjhVEWN+VG0BbLrWwzb5DJNNVC2KWA JQ6A== X-Gm-Message-State: AFqh2kr9lCwOgA4re8LpIFFK+d6TEfJIjsDmOQvw9jiNe6RvCFDLmOCy auF5wzwz37UU61DmAB5ZyVDfDQ== X-Google-Smtp-Source: AMrXdXusxrqyCQz9+WG1sdtE6YE5LRkp8kO3M+C8igKjPuLrVn0x7V/jWbyAkpfXAfWLSevWkB3hOA== X-Received: by 2002:a05:6a20:8362:b0:ac:7a44:db55 with SMTP id z34-20020a056a20836200b000ac7a44db55mr77255609pzc.39.1673571252275; Thu, 12 Jan 2023 16:54:12 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:11a:201:4652:3752:b9b7:29f9]) by smtp.gmail.com with ESMTPSA id u11-20020a6540cb000000b0046ff3634a78sm10676614pgp.71.2023.01.12.16.54.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 16:54:11 -0800 (PST) From: Stephen Boyd To: stable@vger.kernel.org Cc: Johan Hovold , linux-kernel@vger.kernel.org, patches@lists.linux.dev, Dmitry Baryshkov , Vinod Koul Subject: [PATCH 5.15.y 3/4] phy: qcom-qmp-combo: fix broken power on Date: Thu, 12 Jan 2023 16:54:04 -0800 Message-Id: <20230113005405.3992011-4-swboyd@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230113005405.3992011-1-swboyd@chromium.org> References: <20230113005405.3992011-1-swboyd@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Johan Hovold commit 7a7d86d14d073dfa3429c550667a8e78b99edbd4 upstream. The PHY is powered on during phy-init by setting the SW_PWRDN bit in the COM_POWER_DOWN_CTRL register and then setting the same bit in the in the PCS_POWER_DOWN_CONTROL register that belongs to the USB part of the PHY. Currently, whether power on succeeds depends on probe order and having the USB part of the PHY be initialised first. In case the DP part of the PHY is instead initialised first, the intended power on of the USB block results in a corrupted DP_PHY register (e.g. DP_PHY_AUX_CFG8). Add a pointer to the USB part of the PHY to the driver data and use that to power on the PHY also if the DP part of the PHY is initialised first. Fixes: 52e013d0bffa ("phy: qcom-qmp: Add support for DP in USB3+DP combo ph= y") Cc: stable@vger.kernel.org # 5.10 Reviewed-by: Dmitry Baryshkov Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20221114081346.5116-5-johan+linaro@kernel.o= rg Signed-off-by: Vinod Koul [swboyd@chromium.org: Backport to pre-split driver] Signed-off-by: Stephen Boyd --- drivers/phy/qualcomm/phy-qcom-qmp.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy= -qcom-qmp.c index c6f860ce3d99..9fda6d283f20 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -2919,6 +2919,7 @@ struct qcom_qmp { struct regulator_bulk_data *vregs; =20 struct qmp_phy **phys; + struct qmp_phy *usb_phy; =20 struct mutex phy_mutex; int init_count; @@ -4554,7 +4555,7 @@ static int qcom_qmp_phy_com_init(struct qmp_phy *qphy) struct qcom_qmp *qmp =3D qphy->qmp; const struct qmp_phy_cfg *cfg =3D qphy->cfg; void __iomem *serdes =3D qphy->serdes; - void __iomem *pcs =3D qphy->pcs; + struct qmp_phy *usb_phy =3D qmp->usb_phy; void __iomem *dp_com =3D qmp->dp_com; int ret, i; =20 @@ -4620,13 +4621,13 @@ static int qcom_qmp_phy_com_init(struct qmp_phy *qp= hy) qphy_setbits(serdes, cfg->regs[QPHY_COM_POWER_DOWN_CONTROL], SW_PWRDN); } else { - if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) - qphy_setbits(pcs, - cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], - cfg->pwrdn_ctrl); + if (usb_phy->cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL]) + qphy_setbits(usb_phy->pcs, + usb_phy->cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], + usb_phy->cfg->pwrdn_ctrl); else - qphy_setbits(pcs, QPHY_POWER_DOWN_CONTROL, - cfg->pwrdn_ctrl); + qphy_setbits(usb_phy->pcs, QPHY_POWER_DOWN_CONTROL, + usb_phy->cfg->pwrdn_ctrl); } =20 mutex_unlock(&qmp->phy_mutex); @@ -5769,6 +5770,9 @@ static int qcom_qmp_phy_probe(struct platform_device = *pdev) goto err_node_put; } =20 + if (cfg->type =3D=3D PHY_TYPE_USB3) + qmp->usb_phy =3D qmp->phys[id]; + /* * Register the pipe clock provided by phy. * See function description to see details of this pipe clock. @@ -5791,6 +5795,9 @@ static int qcom_qmp_phy_probe(struct platform_device = *pdev) id++; } =20 + if (!qmp->usb_phy) + return -EINVAL; + phy_provider =3D devm_of_phy_provider_register(dev, of_phy_simple_xlate); if (!IS_ERR(phy_provider)) dev_info(dev, "Registered Qcom-QMP phy\n"); --=20 https://chromeos.dev