Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA2CC377 for ; Fri, 13 Jan 2023 00:54:12 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id m7-20020a17090a730700b00225ebb9cd01so25385152pjk.3 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=nSvfQsU8uCrjHTD+8zQpzR6XLJdVTH5McgDNpim6sv18OKfk/7noWAVU/dGUQv4z6X Zx+hGvBLOK48IMSzeFeTCUHHoAmbmV4xhdOLTBpEOuWg+PPa9YVQorgTl1nfDiMnFP80 PLyx6e6KJeVoSIdSxARsHXsdMXLE4kMu154E+IpsSxH2HvGVNwbx4opOA2kTzTCDIzUm 9daPlEjMuW2Z153yWt3laN0KfvKMyy/bnKpaZ7oGLM23MfLJ2se6nPzIBmZ/dRU4NwGO wMm4hPv0Ne9Ug3LjLt9FSm04USQ/KnhEYB+FOuxpZbaJChIyd9pXvPT6K221QiI48nTf W8HA== X-Gm-Message-State: AFqh2kpkXRkJH5/qIFBaBcFOJi/9Yp7ZmUGpPom7mfloXgWNQIZd3K9s oDdiYbw8iPI/Pn7QV1YkZL1ODw== 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> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 phy") 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.org 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; struct qmp_phy **phys; + struct qmp_phy *usb_phy; 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 = qphy->qmp; const struct qmp_phy_cfg *cfg = qphy->cfg; void __iomem *serdes = qphy->serdes; - void __iomem *pcs = qphy->pcs; + struct qmp_phy *usb_phy = qmp->usb_phy; void __iomem *dp_com = qmp->dp_com; int ret, i; @@ -4620,13 +4621,13 @@ static int qcom_qmp_phy_com_init(struct qmp_phy *qphy) 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); } mutex_unlock(&qmp->phy_mutex); @@ -5769,6 +5770,9 @@ static int qcom_qmp_phy_probe(struct platform_device *pdev) goto err_node_put; } + if (cfg->type == PHY_TYPE_USB3) + qmp->usb_phy = 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++; } + if (!qmp->usb_phy) + return -EINVAL; + phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); if (!IS_ERR(phy_provider)) dev_info(dev, "Registered Qcom-QMP phy\n"); -- https://chromeos.dev