From patchwork Fri Sep 9 09:14:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 604274 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 55575C6FA86 for ; Fri, 9 Sep 2022 09:14:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231960AbiIIJOq (ORCPT ); Fri, 9 Sep 2022 05:14:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232090AbiIIJOm (ORCPT ); Fri, 9 Sep 2022 05:14:42 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EFF29583 for ; Fri, 9 Sep 2022 02:14:40 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id l12so1067622ljg.9 for ; Fri, 09 Sep 2022 02:14:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.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; bh=QVU+UE1EBysRzdp8C3u3a6aWiuWRGj3Z9ISz0CxJ14s=; b=OKHr8RdKD9EhTKcN1thF3eGKdstebYgTaLc9RFPp00s3JLJ0XOsqGqO07q+o8P+TSA A24Nt5mnCdJtWRGlDgS0RWQmqwdBrIM3M2Hs5jGeXRUb2NYled2Jfu0WS/kIGJCrFv3p fuBLZ/Y4CdZoyUAvoACqFI/R+JZVlFcWXwh5SkQcFpxKubMG1deIutcEzfYGJu1mPInF qQ1di+XnwyFsLPV5REL88th6MprTcHbFoJFfZ1HrCuD3dFzqU1YUgT6bEuj8zQ88J+rz YAmX6Mc6XnaVk6yyHNAPIDL7bsRbs5qfTOIrErnPMxcdI1y4+m+vnvMeqgJ9VCWGrUjM Bmnw== 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; bh=QVU+UE1EBysRzdp8C3u3a6aWiuWRGj3Z9ISz0CxJ14s=; b=Lvnt55SJZc3eR80QSibqIypEUTsbMMUT5kiLz7sJo/GpwKkhi3aHllTiYVIelG6XGt ep8vSvEDWjrqo/g2/J5brmY6q0YjI3JM8g168RqAUoqjRQ5wmby+LLjQNdIHxrtM/PyO DPNEFrilRBjdqTniXhoKnrKd6FYwnCEtsY3AEoVBe37xusKOK/4qst79/mS/CpZgTzFI icswIPjRAE9njD+n4wnwSdff+Ap0CV3PrTzFspI0e4ZO2GZclgAL7ktSBbUD4oDXmAan Oorg0qK+FYHR5Y4d5fX6e8+j3B2F15qgPrfEe1zQPkcJUv7FmoPsJvzB6FSx6bRO9oSd U6wQ== X-Gm-Message-State: ACgBeo1T7/tvqKmljWqsrHke4E+CBiLl6PxPTo+cGcbGgJw0Dw0FTqJa Z9ukDLfaVwATBMulw/9fVmN69A== X-Google-Smtp-Source: AA6agR6MkCfQZE4VRnkdK44y+9KMn8oo1xI27A0WO+/R0RGWxiXBd8yfCRQNyBwoTSaD9ZF0QpBc/Q== X-Received: by 2002:a2e:9b89:0:b0:26a:a004:ac3 with SMTP id z9-20020a2e9b89000000b0026aa0040ac3mr3434130lji.104.1662714878740; Fri, 09 Sep 2022 02:14:38 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id z26-20020a2e4c1a000000b0026acbb6ed1asm201615lja.66.2022.09.09.02.14.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 02:14:38 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , Vinod Koul , Kishon Vijay Abraham I Cc: Philipp Zabel , Johan Hovold , linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, linux-phy@lists.infradead.org Subject: [PATCH v3 4/9] phy: qcom-qmp-pcie: split PHY programming to separate functions Date: Fri, 9 Sep 2022 12:14:28 +0300 Message-Id: <20220909091433.3715981-5-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220909091433.3715981-1-dmitry.baryshkov@linaro.org> References: <20220909091433.3715981-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Split the code using PHY programming tables into separate functions, which take a single struct qmp_phy_cfg_tables instance. Signed-off-by: Dmitry Baryshkov --- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 92 +++++++++++++----------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c index ca8dffaf1081..5250c3f06c89 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c @@ -1949,15 +1949,54 @@ static void qcom_qmp_phy_pcie_configure(void __iomem *base, qcom_qmp_phy_pcie_configure_lane(base, regs, tbl, num, 0xff); } -static int qcom_qmp_phy_pcie_serdes_init(struct qmp_phy *qphy) +static void qcom_qmp_phy_pcie_serdes_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables) { const struct qmp_phy_cfg *cfg = qphy->cfg; void __iomem *serdes = qphy->serdes; - qcom_qmp_phy_pcie_configure(serdes, cfg->regs, cfg->main.serdes_tbl, cfg->main.serdes_tbl_num); - qcom_qmp_phy_pcie_configure(serdes, cfg->regs, cfg->secondary.serdes_tbl, cfg->secondary.serdes_tbl_num); + if (!tables) + return; - return 0; + qcom_qmp_phy_pcie_configure(serdes, cfg->regs, tables->serdes_tbl, tables->serdes_tbl_num); +} + +static void qcom_qmp_phy_pcie_lanes_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables) +{ + const struct qmp_phy_cfg *cfg = qphy->cfg; + void __iomem *tx = qphy->tx; + void __iomem *rx = qphy->rx; + + if (!tables) + return; + + qcom_qmp_phy_pcie_configure_lane(tx, cfg->regs, + tables->tx_tbl, tables->tx_tbl_num, 1); + + if (cfg->is_dual_lane_phy) + qcom_qmp_phy_pcie_configure_lane(qphy->tx2, cfg->regs, + tables->tx_tbl, tables->tx_tbl_num, 2); + + qcom_qmp_phy_pcie_configure_lane(rx, cfg->regs, + tables->rx_tbl, tables->rx_tbl_num, 1); + if (cfg->is_dual_lane_phy) + qcom_qmp_phy_pcie_configure_lane(qphy->rx2, cfg->regs, + tables->rx_tbl, tables->rx_tbl_num, 2); +} + +static void qcom_qmp_phy_pcie_pcs_init(struct qmp_phy *qphy, const struct qmp_phy_cfg_tables *tables) +{ + const struct qmp_phy_cfg *cfg = qphy->cfg; + void __iomem *pcs = qphy->pcs; + void __iomem *pcs_misc = qphy->pcs_misc; + + if (!tables) + return; + + qcom_qmp_phy_pcie_configure(pcs, cfg->regs, + tables->pcs_tbl, tables->pcs_tbl_num); + qcom_qmp_phy_pcie_configure(pcs_misc, cfg->regs, + tables->pcs_misc_tbl, + tables->pcs_misc_tbl_num); } static int qcom_qmp_phy_pcie_com_init(struct qmp_phy *qphy) @@ -2041,15 +2080,13 @@ static int qcom_qmp_phy_pcie_power_on(struct phy *phy) struct qmp_phy *qphy = phy_get_drvdata(phy); struct qcom_qmp *qmp = qphy->qmp; const struct qmp_phy_cfg *cfg = qphy->cfg; - void __iomem *tx = qphy->tx; - void __iomem *rx = qphy->rx; void __iomem *pcs = qphy->pcs; - void __iomem *pcs_misc = qphy->pcs_misc; void __iomem *status; unsigned int mask, val, ready; int ret; - qcom_qmp_phy_pcie_serdes_init(qphy); + qcom_qmp_phy_pcie_serdes_init(qphy, &cfg->main); + qcom_qmp_phy_pcie_serdes_init(qphy, &cfg->secondary); ret = clk_prepare_enable(qphy->pipe_clk); if (ret) { @@ -2058,42 +2095,11 @@ static int qcom_qmp_phy_pcie_power_on(struct phy *phy) } /* Tx, Rx, and PCS configurations */ - qcom_qmp_phy_pcie_configure_lane(tx, cfg->regs, - cfg->main.tx_tbl, cfg->main.tx_tbl_num, 1); - qcom_qmp_phy_pcie_configure_lane(tx, cfg->regs, - cfg->secondary.tx_tbl, cfg->secondary.tx_tbl_num, 1); + qcom_qmp_phy_pcie_lanes_init(qphy, &cfg->main); + qcom_qmp_phy_pcie_lanes_init(qphy, &cfg->secondary); - /* Configuration for other LANE for USB-DP combo PHY */ - if (cfg->is_dual_lane_phy) { - qcom_qmp_phy_pcie_configure_lane(qphy->tx2, cfg->regs, - cfg->main.tx_tbl, cfg->main.tx_tbl_num, 2); - qcom_qmp_phy_pcie_configure_lane(qphy->tx2, cfg->regs, - cfg->secondary.tx_tbl, cfg->secondary.tx_tbl_num, 2); - } - - qcom_qmp_phy_pcie_configure_lane(rx, cfg->regs, - cfg->main.rx_tbl, cfg->main.rx_tbl_num, 1); - qcom_qmp_phy_pcie_configure_lane(rx, cfg->regs, - cfg->secondary.rx_tbl, cfg->secondary.rx_tbl_num, 1); - - if (cfg->is_dual_lane_phy) { - qcom_qmp_phy_pcie_configure_lane(qphy->rx2, cfg->regs, - cfg->main.rx_tbl, cfg->main.rx_tbl_num, 2); - qcom_qmp_phy_pcie_configure_lane(qphy->rx2, cfg->regs, - cfg->secondary.rx_tbl, cfg->secondary.rx_tbl_num, 2); - } - - qcom_qmp_phy_pcie_configure(pcs, cfg->regs, - cfg->main.pcs_tbl, cfg->main.pcs_tbl_num); - qcom_qmp_phy_pcie_configure(pcs, cfg->regs, - cfg->secondary.pcs_tbl, cfg->secondary.pcs_tbl_num); - - qcom_qmp_phy_pcie_configure(pcs_misc, cfg->regs, - cfg->main.pcs_misc_tbl, - cfg->main.pcs_misc_tbl_num); - qcom_qmp_phy_pcie_configure(pcs_misc, cfg->regs, - cfg->secondary.pcs_misc_tbl, - cfg->secondary.pcs_misc_tbl_num); + qcom_qmp_phy_pcie_pcs_init(qphy, &cfg->main); + qcom_qmp_phy_pcie_pcs_init(qphy, &cfg->secondary); /* * Pull out PHY from POWER DOWN state. From patchwork Fri Sep 9 09:14:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 604273 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 17A2EC6FA98 for ; Fri, 9 Sep 2022 09:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231945AbiIIJOu (ORCPT ); Fri, 9 Sep 2022 05:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230360AbiIIJOq (ORCPT ); Fri, 9 Sep 2022 05:14:46 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB0479FC3 for ; Fri, 9 Sep 2022 02:14:41 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id v6so1127813ljj.0 for ; Fri, 09 Sep 2022 02:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.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; bh=HU2fqxeSVcRcvbRyBLFrKxTAT+0TWkjgqZ5eADgSGgk=; b=We02NjLi51MFUWy5j1PR8dUf3JOzbFBji89SbW0N7UHRaMvU9ck3wtDBMKOr6ehWlv X3LMeztDf03ajQKIDHby2nMLUKvO5NURFs/c2mpdvGfKq3Z6qroVZ/xOpiyMbaCVxySR rMoKbGSv2zX8RbxTgBAnI7MEq5X4P0pA7somHl2KjGMsONaQ7QVQD4LIXuVPBFVuUtQh CJrw007ZrePCg/xSFhMKjSzJ2VyXac8RnNc3hkuuZBdXAtCQNgKwctNnVfIG1ijeH/gb PQzYJyh0UliLlDYFISOnNJgFRg6iuEd6zKoR93/f1lLV9oTH8BmTqWAVzFI+r93qO06j 3x4g== 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; bh=HU2fqxeSVcRcvbRyBLFrKxTAT+0TWkjgqZ5eADgSGgk=; b=iMCr0lsqoydjlc/VZ47G2GZGx3dNRbAJsy89uJt0Z6qb5Ekwu9cL1HxVpz5CAS0NK9 K5QskFxa9zqhlJ2pSgs6Ucv51okGwAj8tcl/39kkrGj3GwKjwaQM8tzDErDiPvWm7OxQ 9KKDvWiBFJ/j0gGQpmIFwhLSqCC+4vbBjFoxQ0XORzwz/TpJWLuMMvAKS+yleiXFJxWS GRIEvQWNMJKrszQiOnvnAYlOj8IUMVxHcAQ5shqrK2otA4K0LOVK5ltvJ0nHSsgDDC8q I/ZdR1RPNp2Tk7m9C298TRXaNfbYEmDVscA7CgsGoxO40xxRn5Jz84OQI053BrjLNECb oUQg== X-Gm-Message-State: ACgBeo0gR+bSB6RYXpf5uTFFo/w4NZWUDrKM0DD1Ju3X5B3OIk6UUGuc a2hvBl26U+80Lfc8gu+KWnudww== X-Google-Smtp-Source: AA6agR5lcebEObTLYz0gr98T0UKvJvrLyaTqdW8FhnL3PFen7y0ov8oPxNjx1i1523hBzHR2rn0ygg== X-Received: by 2002:a05:651c:12ca:b0:261:df67:b76f with SMTP id 10-20020a05651c12ca00b00261df67b76fmr3384572lje.421.1662714879840; Fri, 09 Sep 2022 02:14:39 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id z26-20020a2e4c1a000000b0026acbb6ed1asm201615lja.66.2022.09.09.02.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 02:14:39 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , Vinod Koul , Kishon Vijay Abraham I Cc: Philipp Zabel , Johan Hovold , linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, linux-phy@lists.infradead.org Subject: [PATCH v3 5/9] phy: qcom-qmp-pcie: turn secondary programming table into a pointer Date: Fri, 9 Sep 2022 12:14:29 +0300 Message-Id: <20220909091433.3715981-6-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220909091433.3715981-1-dmitry.baryshkov@linaro.org> References: <20220909091433.3715981-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Having a complete struct qmp_phy_cfg_tables as a secondary field in the struct qmp_phy_cfg wastes memory, since most of the PHY configuration tables do not have the secondary table. Change it to be a pointer to lower the amount of wasted memory. Signed-off-by: Dmitry Baryshkov --- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c index 5250c3f06c89..d115f7ef3901 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c @@ -1372,7 +1372,7 @@ struct qmp_phy_cfg { * Additional init sequence for PHY blocks, providing additional * register programming. Unless required it can be left omitted. */ - struct qmp_phy_cfg_tables secondary; + struct qmp_phy_cfg_tables *secondary; /* clock ids to be requested */ const char * const *clk_list; @@ -1687,7 +1687,7 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), }, - .secondary = { + .secondary = &(struct qmp_phy_cfg_tables) { .serdes_tbl = sm8250_qmp_gen3x1_pcie_serdes_tbl, .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl), .rx_tbl = sm8250_qmp_gen3x1_pcie_rx_tbl, @@ -1730,7 +1730,7 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = { .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), }, - .secondary = { + .secondary = &(struct qmp_phy_cfg_tables) { .tx_tbl = sm8250_qmp_gen3x2_pcie_tx_tbl, .tx_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_tx_tbl), .rx_tbl = sm8250_qmp_gen3x2_pcie_rx_tbl, @@ -2086,7 +2086,7 @@ static int qcom_qmp_phy_pcie_power_on(struct phy *phy) int ret; qcom_qmp_phy_pcie_serdes_init(qphy, &cfg->main); - qcom_qmp_phy_pcie_serdes_init(qphy, &cfg->secondary); + qcom_qmp_phy_pcie_serdes_init(qphy, cfg->secondary); ret = clk_prepare_enable(qphy->pipe_clk); if (ret) { @@ -2096,10 +2096,10 @@ static int qcom_qmp_phy_pcie_power_on(struct phy *phy) /* Tx, Rx, and PCS configurations */ qcom_qmp_phy_pcie_lanes_init(qphy, &cfg->main); - qcom_qmp_phy_pcie_lanes_init(qphy, &cfg->secondary); + qcom_qmp_phy_pcie_lanes_init(qphy, cfg->secondary); qcom_qmp_phy_pcie_pcs_init(qphy, &cfg->main); - qcom_qmp_phy_pcie_pcs_init(qphy, &cfg->secondary); + qcom_qmp_phy_pcie_pcs_init(qphy, cfg->secondary); /* * Pull out PHY from POWER DOWN state. From patchwork Fri Sep 9 09:14:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 604272 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 7B8CEC6FA99 for ; Fri, 9 Sep 2022 09:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232117AbiIIJOu (ORCPT ); Fri, 9 Sep 2022 05:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232123AbiIIJOr (ORCPT ); Fri, 9 Sep 2022 05:14:47 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB7FCA1B4 for ; Fri, 9 Sep 2022 02:14:42 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id f14so673142lfg.5 for ; Fri, 09 Sep 2022 02:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.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; bh=BG/TDrsuuuP6fpTPNslkj+bSpnJP0yproc+vCPdzyEE=; b=rK3jD3C7Bl6R85J/1ihgcwK4hC+M9srfdz34IbLOA8F+rbwg5PlSnI1iaruhlxUI2I Q3cjcqnzTf3ViB7jX+cP0D/euSCmIems85x/P7c/guPp+s9rC1gUH/Sv2qbYFEFjepgO lXvV1LdVV6zqsrLnW1DVjSr8CtpGGSWF4gh42kmoRhuBRVOvsJu4vYcP5vj7OZWANMZw et4ARbtiVNfYqD4e7J7SCNBe5zO6S1TBpdec2K+mNv15vNkN/bbrpKJMbiJ65XXM9Fry wXvZRZvEGbhxHjXSeA9GTB2IeBytICR6hRyUe5KAM3uDaBK3GZFejedZ0spCM71XtOwL KTSg== 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; bh=BG/TDrsuuuP6fpTPNslkj+bSpnJP0yproc+vCPdzyEE=; b=1GcKU05qiSF15U9pp+5II9IhoWz1tP52JkXA1GRcVFCgMG82hkMkh0Y9Hvpp0Hy82p DoC2n2om9WL1uDWVPluPxxlCt/GnPuPgsbjWYz/Y0QtF2EIBi92IsFnM+GVLGc/8FXQ+ Eah4mPsvUYS++1q0tZjLCLXJIBTuF13xKkjvde0HMUhl9BzVWzGR9ArLT3wqenLFmo8R oBLFw6XBwbBw/AeAgO5FrvjJbgB2vrTEbkiM5P8XYxoxFh/g1s137RLamBZ3q6JXfbtj E11TWKT3ocpvkkXpcGcXA9xqsD5U2COzPTI5z3f3Y+zlCSNMFcpLwzJxs0kwkwazyZcm 5gmw== X-Gm-Message-State: ACgBeo08HYV2OmTcJTv7rjNLPJy6My4D88+qj6lquiHrgW21j1VzBLkA wLBpkJreihDKlNtKu27bcUDjL2jWS1TKEg== X-Google-Smtp-Source: AA6agR5HQg+Un5RLLGNR7B+3/W+q+RGySeJeTdGJ9BqHia5jtWkKVN6Y9ntbpFMa/p0DMCd0lr404g== X-Received: by 2002:a19:ac45:0:b0:494:9978:178a with SMTP id r5-20020a19ac45000000b004949978178amr3872345lfc.505.1662714880682; Fri, 09 Sep 2022 02:14:40 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id z26-20020a2e4c1a000000b0026acbb6ed1asm201615lja.66.2022.09.09.02.14.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 02:14:40 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , Vinod Koul , Kishon Vijay Abraham I Cc: Philipp Zabel , Johan Hovold , linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, linux-phy@lists.infradead.org Subject: [PATCH v3 6/9] phy: qcom-qmp-pcie: support separate tables for EP mode Date: Fri, 9 Sep 2022 12:14:30 +0300 Message-Id: <20220909091433.3715981-7-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220909091433.3715981-1-dmitry.baryshkov@linaro.org> References: <20220909091433.3715981-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The PCIe QMP PHY requires different programming sequences when being used for the RC (Root Complex) or for the EP (End Point) modes. Allow selecting the submode and thus selecting a set of PHY programming tables. Since the RC and EP modes share common some common init sequence, the common sequence is kept in the main table and the sequence differences are pushed to the secondary tables. Signed-off-by: Dmitry Baryshkov --- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 54 ++++++++++++++++++++---- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c index d115f7ef3901..d945e8c61811 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c @@ -1369,10 +1369,14 @@ struct qmp_phy_cfg { /* Main init sequence for PHY blocks - serdes, tx, rx, pcs */ struct qmp_phy_cfg_tables main; /* - * Additional init sequence for PHY blocks, providing additional - * register programming. Unless required it can be left omitted. + * Additional init sequences for PHY blocks, providing additional + * register programming. They are used for providing separate sequences + * for the Root Complex and for the End Point usecases. + * + * If EP mode is not supported, both tables can be left empty. */ - struct qmp_phy_cfg_tables *secondary; + struct qmp_phy_cfg_tables *secondary_rc; /* for the RC only */ + struct qmp_phy_cfg_tables *secondary_ep; /* for the EP only */ /* clock ids to be requested */ const char * const *clk_list; @@ -1422,6 +1426,7 @@ struct qmp_phy_cfg { * @index: lane index * @qmp: QMP phy to which this lane belongs * @mode: current PHY mode + * @secondary: currently selected PHY secondary init table set */ struct qmp_phy { struct phy *phy; @@ -1434,6 +1439,7 @@ struct qmp_phy { void __iomem *rx2; void __iomem *pcs_misc; struct clk *pipe_clk; + const struct qmp_phy_cfg_tables *secondary; unsigned int index; struct qcom_qmp *qmp; enum phy_mode mode; @@ -1687,7 +1693,15 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), }, - .secondary = &(struct qmp_phy_cfg_tables) { + /* + * For sm8250 the split between the primary and secondary_rc tables is + * historical, it reflects the programming sequence common to all PCIe + * PHYs on this platform and a sequence required for this particular + * PHY type. If EP support for sm8250 is required, the + * primary/secondary_rc split is to be reconsidered and adjusted + * according to EP programming sequence. + */ + .secondary_rc = &(struct qmp_phy_cfg_tables) { .serdes_tbl = sm8250_qmp_gen3x1_pcie_serdes_tbl, .serdes_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x1_pcie_serdes_tbl), .rx_tbl = sm8250_qmp_gen3x1_pcie_rx_tbl, @@ -1730,7 +1744,15 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = { .pcs_misc_tbl = sm8250_qmp_pcie_pcs_misc_tbl, .pcs_misc_tbl_num = ARRAY_SIZE(sm8250_qmp_pcie_pcs_misc_tbl), }, - .secondary = &(struct qmp_phy_cfg_tables) { + /* + * For sm8250 the split between the primary and secondary_rc tables is + * historical, it reflects the programming sequence common to all PCIe + * PHYs on this platform and a sequence required for this particular + * PHY type. If EP support for sm8250 is required, the + * primary/secondary_rc split is to be reconsidered and adjusted + * according to EP programming sequence. + */ + .secondary_rc = &(struct qmp_phy_cfg_tables) { .tx_tbl = sm8250_qmp_gen3x2_pcie_tx_tbl, .tx_tbl_num = ARRAY_SIZE(sm8250_qmp_gen3x2_pcie_tx_tbl), .rx_tbl = sm8250_qmp_gen3x2_pcie_rx_tbl, @@ -2085,8 +2107,12 @@ static int qcom_qmp_phy_pcie_power_on(struct phy *phy) unsigned int mask, val, ready; int ret; + /* Default to RC mode if the mode was not selected using phy_set_mode_ext() */ + if (!qphy->secondary) + qphy->secondary = cfg->secondary_rc; + qcom_qmp_phy_pcie_serdes_init(qphy, &cfg->main); - qcom_qmp_phy_pcie_serdes_init(qphy, cfg->secondary); + qcom_qmp_phy_pcie_serdes_init(qphy, qphy->secondary); ret = clk_prepare_enable(qphy->pipe_clk); if (ret) { @@ -2096,10 +2122,10 @@ static int qcom_qmp_phy_pcie_power_on(struct phy *phy) /* Tx, Rx, and PCS configurations */ qcom_qmp_phy_pcie_lanes_init(qphy, &cfg->main); - qcom_qmp_phy_pcie_lanes_init(qphy, cfg->secondary); + qcom_qmp_phy_pcie_lanes_init(qphy, qphy->secondary); qcom_qmp_phy_pcie_pcs_init(qphy, &cfg->main); - qcom_qmp_phy_pcie_pcs_init(qphy, cfg->secondary); + qcom_qmp_phy_pcie_pcs_init(qphy, qphy->secondary); /* * Pull out PHY from POWER DOWN state. @@ -2201,6 +2227,18 @@ static int qcom_qmp_phy_pcie_set_mode(struct phy *phy, qphy->mode = mode; + switch (submode) { + case PHY_SUBMODE_PCIE_RC: + qphy->secondary = qphy->cfg->secondary_rc; + break; + case PHY_SUBMODE_PCIE_EP: + qphy->secondary = qphy->cfg->secondary_ep; + break; + default: + dev_err(&phy->dev, "Unuspported submode %d\n", submode); + return -EINVAL; + } + return 0; } From patchwork Fri Sep 9 09:14:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 604271 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 DA9F8C6FA82 for ; Fri, 9 Sep 2022 09:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232125AbiIIJOw (ORCPT ); Fri, 9 Sep 2022 05:14:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230143AbiIIJOs (ORCPT ); Fri, 9 Sep 2022 05:14:48 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FF86D12E for ; Fri, 9 Sep 2022 02:14:46 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id z20so1092877ljq.3 for ; Fri, 09 Sep 2022 02:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.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; bh=5MyxjEhSqcQYv9oqAAjUG7kWOklie0I2GmKRB8jIEeU=; b=fJYTUukRypDeg6Hp0oxgJLj2ZwZGJi7eAzLJWAyo5M2SyhpbAofQcr9qpuhGESurzs ujsll6x9ELeV0mJ/z9bnvRQ03rG9v+KG95DbMWRqiWX4nzJLAS2zScSx1lEhwRjbbHUW yCo36lQdjM1VkoWECRHA/WBfNN4NqUYpFOGmJB0LqjnfqdLEZdt8Yu4xz4WPaGqYsvnu 0VTx15WkH2hzvyjeaW19+6ju7AtRimGbXfhXugavEgAZgQR9IxI7fW1cLRG2Le4uNsWW DfxjV652kquTDWxXw2aFZODIFqq1xLX1lLUSjYhlbIyXLQVUOAHtLX1Y7XB8BJC8IpO+ JnAA== 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; bh=5MyxjEhSqcQYv9oqAAjUG7kWOklie0I2GmKRB8jIEeU=; b=zun2255pQ1XqBnZdPQj0ZShsBwzT5gR0gsVRmQP7g7C6WEycep/OVzks5JfxH1Roxq EQMfzkilYOhA05qtf9gtHF1te/g5/T8duoZHQFbhOy2pAsNdI3gFHK9eIQhm+/Z7Ri2q vCK1Cfs9WlGYPqpm9ImrezfimNoSxcb/SeScOkwypQSHV2FnkDITpjH2G3lOiGnZYhn/ MFnziCzX/2mt5ZJmoox8oxIep5XbnJYr7VE55IytEGaitL+BvSAQNGbc3IQBmimiXy7Y ZKe5pqV9JUdp694Le+JQ53nifKDjvxIEUVThnPnUWicAD/h4xvaynGbmNhuvDN1OWY6q 1JVQ== X-Gm-Message-State: ACgBeo2AOXF1qXUvqxnAFX6hHcEhlkjfoAji76fXqi+1CFaUi4x7e/IQ VVj8Ln1s6SFPlkXzOfMRX04TJg== X-Google-Smtp-Source: AA6agR6xzToALUoWmSk6vOlrNi+UWb5/PMWZz2w0OYejPJNkD1XLY3D6JlDolP1r0m7jkF5+Aqp1bA== X-Received: by 2002:a2e:be9e:0:b0:261:b228:ed8b with SMTP id a30-20020a2ebe9e000000b00261b228ed8bmr3635536ljr.226.1662714884653; Fri, 09 Sep 2022 02:14:44 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id z26-20020a2e4c1a000000b0026acbb6ed1asm201615lja.66.2022.09.09.02.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 02:14:43 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Rob Herring , Jingoo Han , Gustavo Pimentel , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , Vinod Koul , Kishon Vijay Abraham I Cc: Philipp Zabel , Johan Hovold , linux-arm-msm@vger.kernel.org, linux-pci@vger.kernel.org, linux-phy@lists.infradead.org, Manivannan Sadhasivam Subject: [PATCH v3 9/9] PCI: qcom-ep: Setup PHY to work in EP mode Date: Fri, 9 Sep 2022 12:14:33 +0300 Message-Id: <20220909091433.3715981-10-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220909091433.3715981-1-dmitry.baryshkov@linaro.org> References: <20220909091433.3715981-1-dmitry.baryshkov@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Call phy_set_mode_ext() to notify the PHY driver that the PHY is being used in the EP mode. Reviewed-by: Manivannan Sadhasivam Signed-off-by: Dmitry Baryshkov --- drivers/pci/controller/dwc/pcie-qcom-ep.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c index ec99116ad05c..e2a1c3c7f599 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c @@ -240,6 +240,10 @@ static int qcom_pcie_enable_resources(struct qcom_pcie_ep *pcie_ep) if (ret) goto err_disable_clk; + ret = phy_set_mode_ext(pcie_ep->phy, PHY_MODE_PCIE, PHY_SUBMODE_PCIE_EP); + if (ret) + goto err_phy_exit; + ret = phy_power_on(pcie_ep->phy); if (ret) goto err_phy_exit;