From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752415AbeCPJpX (ORCPT ); Fri, 16 Mar 2018 05:45:23 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:57960 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750826AbeCPJpV (ORCPT ); Fri, 16 Mar 2018 05:45:21 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 035EA60314 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mgautam@codeaurora.org From: Manu Gautam To: Kishon Vijay Abraham I Cc: linux-arm-msm@vger.kernel.org, Manu Gautam , Vivek Gautam , Varadarajan Narayanan , Fengguang Wu , Wei Yongjun , linux-kernel@vger.kernel.org (open list:GENERIC PHY FRAMEWORK) Subject: [PATCH 1/6] phy: qcom-qmp: Enable pipe_clk before checking USB3 PHY_STATUS Date: Fri, 16 Mar 2018 15:14:54 +0530 Message-Id: <1521193500-4696-2-git-send-email-mgautam@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521193500-4696-1-git-send-email-mgautam@codeaurora.org> References: <1521193500-4696-1-git-send-email-mgautam@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org QMP PHY for USB mode requires pipe_clk for calibration and PLL lock to take place. This lock is output from PHY to GCC clock_ctl and then fed back to QMP PHY and is output from PHY only after PHY is reset and initialized, hence it can't be enabled too early in initialization sequence. Signed-off-by: Manu Gautam --- drivers/phy/qualcomm/phy-qcom-qmp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy-qcom-qmp.c index 6470c5d..73aa282 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -797,8 +797,13 @@ static int qcom_qmp_phy_poweron(struct phy *phy) { struct qmp_phy *qphy = phy_get_drvdata(phy); struct qcom_qmp *qmp = qphy->qmp; + const struct qmp_phy_cfg *cfg = qmp->cfg; int ret; + /* Not needed for USB3 PHY as pipe_clk is enabled from phy_init */ + if (cfg->type == PHY_TYPE_USB3) + return 0; + ret = clk_prepare_enable(qphy->pipe_clk); if (ret) dev_err(qmp->dev, "pipe_clk enable failed, err=%d\n", ret); @@ -1008,6 +1013,19 @@ static int qcom_qmp_phy_init(struct phy *phy) status = pcs + cfg->regs[QPHY_PCS_READY_STATUS]; mask = cfg->mask_pcs_ready; + /* USB3 PHY requires pipe_clk for PLL lock and calibration */ + if (cfg->type == PHY_TYPE_USB3) { + ret = clk_prepare_enable(qphy->pipe_clk); + if (ret) + dev_err(qmp->dev, "pipe_clk enable err=%d\n", ret); + /* + * Ignore this error as pipe_clk might take some time to get + * enabled. In any case following check for PHY PLL lock would + * timeout below if there is a fatal error and clock is not fed + * to PHY + */ + } + ret = readl_poll_timeout(status, val, !(val & mask), 1, PHY_INIT_COMPLETE_TIMEOUT); if (ret) { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project