From patchwork Fri Mar 23 06:11:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manu Gautam X-Patchwork-Id: 10302765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 55B1E60385 for ; Fri, 23 Mar 2018 06:13:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44ADA28BF9 for ; Fri, 23 Mar 2018 06:13:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 397AB28BFF; Fri, 23 Mar 2018 06:13:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B363A28BF9 for ; Fri, 23 Mar 2018 06:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751689AbeCWGLw (ORCPT ); Fri, 23 Mar 2018 02:11:52 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:41784 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751668AbeCWGLu (ORCPT ); Fri, 23 Mar 2018 02:11:50 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id ED21760807; Fri, 23 Mar 2018 06:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521785509; bh=G2uJrOppupfZLi0LNJl5dgmyaEa1Rz2PVV6/iaNPbnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dth0oMWb7SXNnUA5KRhcJAlvNfYpbEQtgh9TW9qVAZDWKKIeP/L522hlZjaJHFZUh oOjgtXd/Z1AbLgqsFka/G/BuAgHRaeQXsm6TysasvB5tBlptOA1l8RK44NIV/nzm/x KWw1MXPeTH3GIAmw24ZEDIcRJF4LLW2dh12qWpaE= Received: from mgautam-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 01D9960807; Fri, 23 Mar 2018 06:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1521785509; bh=G2uJrOppupfZLi0LNJl5dgmyaEa1Rz2PVV6/iaNPbnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dth0oMWb7SXNnUA5KRhcJAlvNfYpbEQtgh9TW9qVAZDWKKIeP/L522hlZjaJHFZUh oOjgtXd/Z1AbLgqsFka/G/BuAgHRaeQXsm6TysasvB5tBlptOA1l8RK44NIV/nzm/x KWw1MXPeTH3GIAmw24ZEDIcRJF4LLW2dh12qWpaE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 01D9960807 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-kernel@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , linux-arm-msm@vger.kernel.org, Manu Gautam , Vivek Gautam , Varadarajan Narayanan , Viresh Kumar , Wei Yongjun , Fengguang Wu Subject: [PATCH v3 1/6] phy: qcom-qmp: Enable pipe_clk before checking USB3 PHY_STATUS Date: Fri, 23 Mar 2018 11:41:22 +0530 Message-Id: <1521785487-29866-2-git-send-email-mgautam@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521785487-29866-1-git-send-email-mgautam@codeaurora.org> References: <1521785487-29866-1-git-send-email-mgautam@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP QMP PHY for USB mode requires pipe_clk for calibration and PLL lock to take place. This clock is output from PHY to GCC clock_ctl and then fed back to QMP PHY and is available 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 | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy-qcom-qmp.c index 6470c5d..5d8df6a 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -1008,6 +1008,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. + * Enable it from here for USB. For UFS/PCIE, it gets enabled + * from poweron. + */ + 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); + goto err_clk_enable; + } + } + ret = readl_poll_timeout(status, val, !(val & mask), 1, PHY_INIT_COMPLETE_TIMEOUT); if (ret) { @@ -1019,6 +1032,9 @@ static int qcom_qmp_phy_init(struct phy *phy) return ret; err_pcs_ready: + if (cfg->type == PHY_TYPE_USB3) + clk_disable_unprepare(qphy->pipe_clk); +err_clk_enable: if (cfg->has_lane_rst) reset_control_assert(qphy->lane_rst); err_lane_rst: @@ -1288,10 +1304,19 @@ static int phy_pipe_clk_register(struct qcom_qmp *qmp, struct device_node *np) .owner = THIS_MODULE, }; +/* USB PHY doesn't require power_on op */ +static const struct phy_ops qcom_qmp_usb_phy_gen_ops = { + .init = qcom_qmp_phy_init, + .exit = qcom_qmp_phy_exit, + .set_mode = qcom_qmp_phy_set_mode, + .owner = THIS_MODULE, +}; + static int qcom_qmp_phy_create(struct device *dev, struct device_node *np, int id) { struct qcom_qmp *qmp = dev_get_drvdata(dev); + const struct phy_ops *ops; struct phy *generic_phy; struct qmp_phy *qphy; char prop_name[MAX_PROP_NAME]; @@ -1354,7 +1379,13 @@ int qcom_qmp_phy_create(struct device *dev, struct device_node *np, int id) } } - generic_phy = devm_phy_create(dev, np, &qcom_qmp_phy_gen_ops); + /* USB PHY doesn't use power_on op */ + if (qmp->cfg->type == PHY_TYPE_USB3) + ops = &qcom_qmp_usb_phy_gen_ops; + else + ops = &qcom_qmp_phy_gen_ops; + + generic_phy = devm_phy_create(dev, np, ops); if (IS_ERR(generic_phy)) { ret = PTR_ERR(generic_phy); dev_err(dev, "failed to create qphy %d\n", ret);