From patchwork Fri Nov 11 08:56:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 18563 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp626037wru; Fri, 11 Nov 2022 00:59:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf7drwroNFn9zwZKoebkooPLs4MnX0BkZUNq+RxiIznTf3bPKF0rWMAAyVWv7eqCOmSZf97q X-Received: by 2002:a17:906:6d88:b0:7aa:7c3f:8603 with SMTP id h8-20020a1709066d8800b007aa7c3f8603mr1122338ejt.322.1668157194891; Fri, 11 Nov 2022 00:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668157194; cv=none; d=google.com; s=arc-20160816; b=Kv6nIJjlDDzTnQm1Xg0vZqMIc7Loq7CaemA66gsmOZ5HQhZxJTJgvkczo3Sgfonp4I vdzxSt9RQsh6Gk4j1vbZVEGGqjOPVWXtfvrueScmkc9RODCCHlql1H0EFhDptxpN8gxL eoR1zzCXbiCkFTghb4XFRtDfowJTmqPNJe8mlWVAHNbwzYTjDPWyfVnPNkxFHfbY0b8H FpVwhr812Dq9c7haV3Pg0YQjVbbaEtx+6MO6mKujjLYZPnBTraddY6i2dPK+8+EjgLoE cQhXnpdB28dJY+XX98ecwo4hkUSZjSVp5sHHHRaRlOSIJ5eWV+WfNT0jCXM1jsOns53M A/QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sBKmQVBDOuvU/tUEjaneOFQgTgZ1lpQ3dm0CtlJfZUw=; b=flxZ1zgOtHYwSV41yzFLWkIWn6DEm2nNmXjtJzD0f9jhZ/uz1lgVggevlgNBOvifQD dqDYO/TIQDLfvhw1qy2N5eUYJ8zXJ+qvMC9al1jzV9bn0CSd6EROSuIEz4nN16ZjujOW VDGs5H568yUE4b+lvBPcpHZFNj8003nLWJnYDtOj2zafkPCQW7P7dwnk5kp9oVTsjc7i kF/6o+TDJj4mg0XvR4BuAR6GxGFIUMrbFsnhFHC1VqYhYpxAhoCf0cGRu1HVsFcG0HN2 prqr7k4nTW1zmidtrqPdz+1y3N8TgL/cDBRoe+8nqWIHM8VS863ZqQz+Tl4fL2hFCs3d yCKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rfxiPQRH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id co2-20020a0564020c0200b0045d25cf222csi1719609edb.362.2022.11.11.00.59.30; Fri, 11 Nov 2022 00:59:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rfxiPQRH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233536AbiKKI5w (ORCPT + 99 others); Fri, 11 Nov 2022 03:57:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233439AbiKKI50 (ORCPT ); Fri, 11 Nov 2022 03:57:26 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D9FB7833D; Fri, 11 Nov 2022 00:57:25 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CF1C861EF7; Fri, 11 Nov 2022 08:57:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 821EBC43470; Fri, 11 Nov 2022 08:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668157043; bh=fh/aqnYcDidigo48XuRvbr/aFFT5zxzhUQfJq7vVMG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rfxiPQRHfzAt95l4LJpnuAF7Pzw9Gp4/ZwqO7Zty+yVe2Tcu+BxnblSQCqryF4dQO mkDuzFRtapMYFAb9TcOSgQ0URJkzPbYIvXa4fladf71F2b2PmI5i3f8c8Qsy2aZL3z UEqNc+UHxvOpQQVmPVe9xGBajROG+/nsSs/Y/qVlnMqqv/0HMP4CfRRWgtraYSJ2+7 CiMZOO/05485peqK96J84zq0vypzJ2JeSZK860g+PTWy3Dduud8HQkd1iZ2irYL6uR 3Ghg1ykCjXX/Rm5SupmugRq5nfX0CmpCHuOnVjCHvf+Sm6yvqrKqzsNiA+G+Ea0w+j BxeW51ad7bBtg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1otPqJ-0002UK-RQ; Fri, 11 Nov 2022 09:56:55 +0100 From: Johan Hovold To: Vinod Koul Cc: Andy Gross , Bjorn Andersson , Konrad Dybcio , Dmitry Baryshkov , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 12/22] phy: qcom-qmp-combo: separate USB and DP devicetree parsing Date: Fri, 11 Nov 2022 09:56:33 +0100 Message-Id: <20221111085643.9478-13-johan+linaro@kernel.org> X-Mailer: git-send-email 2.37.4 In-Reply-To: <20221111085643.9478-1-johan+linaro@kernel.org> References: <20221111085643.9478-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749189598727464021?= X-GMAIL-MSGID: =?utf-8?q?1749189598727464021?= Separate the devicetree parsing of the USB and DP child nodes in two dedicated helpers in preparation for merging the driver data. Note that only the USB part of the PHY has a pipe clock and that the DP implementation only uses the tx/tx2 and pcs register regions. Signed-off-by: Johan Hovold Reviewed-by: Dmitry Baryshkov --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 81 ++++++++++++++++------- 1 file changed, 58 insertions(+), 23 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index c059e4aeecdb..52a00b51f09a 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -2576,13 +2576,63 @@ static int phy_dp_clks_register(struct qcom_qmp *qmp, struct qmp_phy *qphy, return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); } -static int qmp_combo_create(struct device *dev, struct device_node *np, int id, +static int qmp_combo_create_dp(struct device *dev, struct device_node *np, int id, + void __iomem *serdes, const struct qmp_phy_cfg *cfg) +{ + struct qcom_qmp *qmp = dev_get_drvdata(dev); + struct phy *generic_phy; + struct qmp_phy *qphy; + int ret; + + qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); + if (!qphy) + return -ENOMEM; + + qphy->cfg = cfg; + qphy->serdes = serdes; + /* + * Get memory resources for each PHY: + * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. + * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 + * For single lane PHYs: pcs_misc (optional) -> 3. + * + * Note that only tx/tx2 and pcs are used by the DP implementation. + */ + qphy->tx = devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(qphy->tx)) + return PTR_ERR(qphy->tx); + + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); + if (IS_ERR(qphy->pcs)) + return PTR_ERR(qphy->pcs); + + if (cfg->lanes >= 2) { + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); + if (IS_ERR(qphy->tx2)) + return PTR_ERR(qphy->tx2); + } + + generic_phy = devm_phy_create(dev, np, &qmp_combo_dp_phy_ops); + if (IS_ERR(generic_phy)) { + ret = PTR_ERR(generic_phy); + dev_err(dev, "failed to create DP PHY: %d\n", ret); + return ret; + } + + qphy->phy = generic_phy; + qphy->qmp = qmp; + qmp->phys[id] = qphy; + phy_set_drvdata(generic_phy, qphy); + + return 0; +} + +static int qmp_combo_create_usb(struct device *dev, struct device_node *np, int id, void __iomem *serdes, const struct qmp_phy_cfg *cfg) { struct qcom_qmp *qmp = dev_get_drvdata(dev); struct phy *generic_phy; struct qmp_phy *qphy; - const struct phy_ops *ops; int ret; qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); @@ -2631,31 +2681,16 @@ static int qmp_combo_create(struct device *dev, struct device_node *np, int id, qphy->pcs_misc = NULL; } - /* - * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3 - * based phys, so they essentially have pipe clock. So, - * we return error in case phy is USB3 or PIPE type. - * Otherwise, we initialize pipe clock to NULL for - * all phys that don't need this. - */ qphy->pipe_clk = devm_get_clk_from_child(dev, np, NULL); if (IS_ERR(qphy->pipe_clk)) { - if (cfg->type == PHY_TYPE_USB3) - return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk), - "failed to get lane%d pipe_clk\n", - id); - qphy->pipe_clk = NULL; + return dev_err_probe(dev, PTR_ERR(qphy->pipe_clk), + "failed to get lane%d pipe_clk\n", id); } - if (cfg->type == PHY_TYPE_DP) - ops = &qmp_combo_dp_phy_ops; - else - ops = &qmp_combo_usb_phy_ops; - - generic_phy = devm_phy_create(dev, np, ops); + generic_phy = devm_phy_create(dev, np, &qmp_combo_usb_phy_ops); if (IS_ERR(generic_phy)) { ret = PTR_ERR(generic_phy); - dev_err(dev, "failed to create qphy %d\n", ret); + dev_err(dev, "failed to create USB PHY: %d\n", ret); return ret; } @@ -2752,7 +2787,7 @@ static int qmp_combo_probe(struct platform_device *pdev) serdes = dp_serdes; /* Create per-lane phy */ - ret = qmp_combo_create(dev, child, id, serdes, cfg); + ret = qmp_combo_create_dp(dev, child, id, serdes, cfg); if (ret) { dev_err(dev, "failed to create lane%d phy, %d\n", id, ret); @@ -2770,7 +2805,7 @@ static int qmp_combo_probe(struct platform_device *pdev) serdes = usb_serdes; /* Create per-lane phy */ - ret = qmp_combo_create(dev, child, id, serdes, cfg); + ret = qmp_combo_create_usb(dev, child, id, serdes, cfg); if (ret) { dev_err(dev, "failed to create lane%d phy, %d\n", id, ret);