linux-phy.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@linaro.org>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Andy Gross <agross@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	"vkoul@kernel.org" <vkoul@kernel.org>,
	Kishon Vijay Abraham I <kishon@kernel.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-phy@lists.infradead.org,
	Neil Armstrong <neil.armstrong@linaro.org>
Subject: Re: [PATCH 07/10] phy: qualcomm: qmp-pcie: Add support for SM8550 g3x2 and g4x2 PCIEs
Date: Tue, 17 Jan 2023 15:57:37 +0200	[thread overview]
Message-ID: <Y8apUXpfAyaMMmH/@linaro.org> (raw)
In-Reply-To: <bbfba6ca-c410-b4aa-ba3c-2fbf55065b24@linaro.org>

On 23-01-01 22:15:55, Dmitry Baryshkov wrote:
> On 16/11/2022 14:01, Abel Vesa wrote:
> > Add the SM8550 both g4 and g3 configurations. In addition, there is a
> > new "lane shared" table that needs to be configured for g4, along with
> > the No-CSR list of resets.
> > 
> > Co-developed-by: Neil Armstrong <neil.armstrong@linaro.org>
> > Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> > Signed-off-by: Abel Vesa <abel.vesa@linaro.org>
> > ---
> >   drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 354 +++++++++++++++++++++++
> >   1 file changed, 354 insertions(+)
> > 
> > diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
> > index 47cccc4b35b2..87c7c20dfc8d 100644
> > --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
> > +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c
> 
> [skipped tables]
> 
> > @@ -1473,6 +1701,8 @@ struct qmp_pcie_offsets {
> >   struct qmp_phy_cfg_tbls {
> >   	const struct qmp_phy_init_tbl *serdes;
> >   	int serdes_num;
> > +	const struct qmp_phy_init_tbl *ln_shrd_serdes;
> > +	int ln_shrd_serdes_num;
> >   	const struct qmp_phy_init_tbl *tx;
> >   	int tx_num;
> >   	const struct qmp_phy_init_tbl *rx;
> > @@ -1510,6 +1740,9 @@ struct qmp_phy_cfg {
> >   	/* resets to be requested */
> >   	const char * const *reset_list;
> >   	int num_resets;
> > +	/* no CSR resets to be requested */
> > +	const char * const *nocsr_reset_list;
> > +	int num_nocsr_resets;
> 
> Is there any difference between 'no CSR' resets and the plain ones? Can we
> handle them in a single array instead?

Yes, on power on, only the 'No CSR' are necessary to be deasserted.

So we need to differentiate between 'No CSR' and the rest.

> 
> >   	/* regulators to be requested */
> >   	const char * const *vreg_list;
> >   	int num_vregs;
> > @@ -1523,6 +1756,9 @@ struct qmp_phy_cfg {
> >   	bool skip_start_delay;
> > +	/* true, if PHY has lane shared serdes table */
> > +	bool has_ln_shrd_serdes_tbl;
> 
> s/shrd/shared/g ? I think it's easier to read and to understand.

Sure. Will do.

> 
> > +
> >   	/* QMP PHY pipe clock interface rate */
> >   	unsigned long pipe_clock_rate;
> >   };
> > @@ -1534,6 +1770,7 @@ struct qmp_pcie {
> >   	bool tcsr_4ln_config;
> >   	void __iomem *serdes;
> > +	void __iomem *ln_shrd_serdes;
> >   	void __iomem *pcs;
> >   	void __iomem *pcs_misc;
> >   	void __iomem *tx;
> > @@ -1548,6 +1785,7 @@ struct qmp_pcie {
> >   	int num_pipe_clks;
> >   	struct reset_control_bulk_data *resets;
> > +	struct reset_control_bulk_data *nocsr_resets;
> >   	struct regulator_bulk_data *vregs;
> >   	struct phy *phy;
> > @@ -1595,11 +1833,19 @@ static const char * const sdm845_pciephy_clk_l[] = {
> >   	"aux", "cfg_ahb", "ref", "refgen",
> >   };
> > +static const char * const sm8550_pciephy_clk_l[] = {
> > +	"aux", "aux_phy", "cfg_ahb", "ref", "refgen",
> > +};
> > +
> >   /* list of regulators */
> >   static const char * const qmp_phy_vreg_l[] = {
> >   	"vdda-phy", "vdda-pll",
> >   };
> > +static const char * const sm8550_qmp_phy_vreg_l[] = {
> > +	"vdda-phy", "vdda-pll", "vdda-qref",
> > +};
> > +
> >   /* list of resets */
> >   static const char * const ipq8074_pciephy_reset_l[] = {
> >   	"phy", "common",
> > @@ -1609,6 +1855,10 @@ static const char * const sdm845_pciephy_reset_l[] = {
> >   	"phy",
> >   };
> > +static const char * const sm8550_pciephy_nocsr_reset_l[] = {
> > +	"pcie_1_nocsr_com_phy_reset",
> > +};
> > +
> >   static const struct qmp_pcie_offsets qmp_pcie_offsets_v5 = {
> >   	.serdes		= 0,
> >   	.pcs		= 0x0200,
> > @@ -2084,6 +2334,65 @@ static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = {
> >   	.phy_status		= PHYSTATUS_4_20,
> >   };
> > +static const struct qmp_phy_cfg sm8550_qmp_gen3x2_pciephy_cfg = {
> > +	.lanes = 2,
> > +
> > +	.tbls = {
> > +		.serdes		= sm8550_qmp_gen3x2_pcie_serdes_tbl,
> > +		.serdes_num	= ARRAY_SIZE(sm8550_qmp_gen3x2_pcie_serdes_tbl),
> > +		.tx		= sm8550_qmp_gen3x2_pcie_tx_tbl,
> > +		.tx_num		= ARRAY_SIZE(sm8550_qmp_gen3x2_pcie_tx_tbl),
> > +		.rx		= sm8550_qmp_gen3x2_pcie_rx_tbl,
> > +		.rx_num		= ARRAY_SIZE(sm8550_qmp_gen3x2_pcie_rx_tbl),
> > +		.pcs		= sm8550_qmp_gen3x2_pcie_pcs_tbl,
> > +		.pcs_num	= ARRAY_SIZE(sm8550_qmp_gen3x2_pcie_pcs_tbl),
> > +		.pcs_misc	= sm8550_qmp_gen3x2_pcie_pcs_misc_tbl,
> > +		.pcs_misc_num	= ARRAY_SIZE(sm8550_qmp_gen3x2_pcie_pcs_misc_tbl),
> > +	},
> > +	.clk_list		= sdm845_pciephy_clk_l,
> > +	.num_clks		= ARRAY_SIZE(sdm845_pciephy_clk_l),
> > +	.reset_list		= sdm845_pciephy_reset_l,
> > +	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
> > +	.vreg_list		= qmp_phy_vreg_l,
> > +	.num_vregs		= ARRAY_SIZE(qmp_phy_vreg_l),
> > +	.regs			= sm8250_pcie_regs_layout,
> > +
> > +	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
> > +	.phy_status		= PHYSTATUS,
> > +};
> > +
> > +static const struct qmp_phy_cfg sm8550_qmp_gen4x2_pciephy_cfg = {
> > +	.lanes = 2,
> > +
> > +	.tbls = {
> > +		.serdes			= sm8550_qmp_gen4x2_pcie_serdes_tbl,
> > +		.serdes_num		= ARRAY_SIZE(sm8550_qmp_gen4x2_pcie_serdes_tbl),
> > +		.ln_shrd_serdes		= sm8550_qmp_gen4x2_pcie_serdes_ln_shrd_tbl,
> > +		.ln_shrd_serdes_num	= ARRAY_SIZE(sm8550_qmp_gen4x2_pcie_serdes_ln_shrd_tbl),
> > +		.tx			= sm8550_qmp_gen4x2_pcie_tx_tbl,
> > +		.tx_num			= ARRAY_SIZE(sm8550_qmp_gen4x2_pcie_tx_tbl),
> > +		.rx			= sm8550_qmp_gen4x2_pcie_rx_tbl,
> > +		.rx_num			= ARRAY_SIZE(sm8550_qmp_gen4x2_pcie_rx_tbl),
> > +		.pcs			= sm8550_qmp_gen4x2_pcie_pcs_tbl,
> > +		.pcs_num		= ARRAY_SIZE(sm8550_qmp_gen4x2_pcie_pcs_tbl),
> > +		.pcs_misc		= sm8550_qmp_gen4x2_pcie_pcs_misc_tbl,
> > +		.pcs_misc_num		= ARRAY_SIZE(sm8550_qmp_gen4x2_pcie_pcs_misc_tbl),
> > +	},
> > +	.clk_list		= sm8550_pciephy_clk_l,
> > +	.num_clks		= ARRAY_SIZE(sm8550_pciephy_clk_l),
> > +	.reset_list		= sdm845_pciephy_reset_l,
> > +	.num_resets		= ARRAY_SIZE(sdm845_pciephy_reset_l),
> > +	.nocsr_reset_list	= sm8550_pciephy_nocsr_reset_l,
> > +	.num_nocsr_resets	= ARRAY_SIZE(sm8550_pciephy_nocsr_reset_l),
> > +	.vreg_list		= sm8550_qmp_phy_vreg_l,
> > +	.num_vregs		= ARRAY_SIZE(sm8550_qmp_phy_vreg_l),
> > +	.regs			= sm8250_pcie_regs_layout,
> > +
> > +	.has_ln_shrd_serdes_tbl	= true,
> > +	.pwrdn_ctrl		= SW_PWRDN | REFCLK_DRV_DSBL,
> > +	.phy_status		= PHYSTATUS_4_20,
> > +};
> > +
> >   static void qmp_pcie_configure_lane(void __iomem *base,
> >   					const struct qmp_phy_init_tbl tbl[],
> >   					int num,
> > @@ -2132,6 +2441,7 @@ static void qmp_pcie_init_registers(struct qmp_pcie *qmp, const struct qmp_phy_c
> >   {
> >   	const struct qmp_phy_cfg *cfg = qmp->cfg;
> >   	void __iomem *serdes = qmp->serdes;
> > +	void __iomem *ln_shrd_serdes = qmp->ln_shrd_serdes;
> >   	void __iomem *tx = qmp->tx;
> >   	void __iomem *rx = qmp->rx;
> >   	void __iomem *tx2 = qmp->tx2;
> > @@ -2159,6 +2469,10 @@ static void qmp_pcie_init_registers(struct qmp_pcie *qmp, const struct qmp_phy_c
> >   		qmp_pcie_configure(serdes, cfg->serdes_4ln_tbl, cfg->serdes_4ln_num);
> >   		qmp_pcie_init_port_b(qmp, tbls);
> >   	}
> > +
> > +	if (cfg->has_ln_shrd_serdes_tbl)
> > +		qmp_pcie_configure(ln_shrd_serdes, tbls->ln_shrd_serdes,
> > +				       tbls->ln_shrd_serdes_num);
> >   }
> >   static int qmp_pcie_init(struct phy *phy)
> > @@ -2179,6 +2493,14 @@ static int qmp_pcie_init(struct phy *phy)
> >   		goto err_disable_regulators;
> >   	}
> > +	if (qmp->nocsr_resets) {
> > +		ret = reset_control_bulk_assert(cfg->num_nocsr_resets, qmp->nocsr_resets);
> > +		if (ret) {
> > +			dev_err(qmp->dev, "no-csr reset assert failed\n");
> > +			goto err_disable_regulators;
> > +		}
> > +	}
> > +
> >   	usleep_range(200, 300);
> >   	ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets);
> > @@ -2240,6 +2562,14 @@ static int qmp_pcie_power_on(struct phy *phy)
> >   	if (ret)
> >   		return ret;
> > +	if (qmp->nocsr_resets) {
> > +		ret = reset_control_bulk_deassert(cfg->num_nocsr_resets, qmp->nocsr_resets);
> > +		if (ret) {
> > +			dev_err(qmp->dev, "no-csr reset deassert failed\n");
> > +			goto err_disable_pipe_clk;
> > +		}
> > +	}
> > +
> >   	/* Pull PHY out of reset state */
> >   	qphy_clrbits(pcs, cfg->regs[QPHY_SW_RESET], SW_RESET);
> > @@ -2373,6 +2703,21 @@ static int qmp_pcie_reset_init(struct qmp_pcie *qmp)
> >   	if (ret)
> >   		return dev_err_probe(dev, ret, "failed to get resets\n");
> > +	if (cfg->nocsr_reset_list) {
> > +		qmp->nocsr_resets = devm_kcalloc(dev, cfg->num_nocsr_resets,
> > +				   sizeof(*qmp->nocsr_resets), GFP_KERNEL);
> > +		if (!qmp->nocsr_resets)
> > +			return -ENOMEM;
> > +
> > +		for (i = 0; i < cfg->num_nocsr_resets; i++)
> > +			qmp->nocsr_resets[i].id = cfg->nocsr_reset_list[i];
> > +
> > +		ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_nocsr_resets,
> > +								qmp->nocsr_resets);
> > +		if (ret)
> > +			return dev_err_probe(dev, ret, "failed to get no CSR resets\n");
> > +	}
> > +
> >   	return 0;
> >   }
> > @@ -2502,6 +2847,9 @@ static int qmp_pcie_parse_dt_legacy(struct qmp_pcie *qmp, struct device_node *np
> >   			return PTR_ERR(qmp->rx2);
> >   		qmp->pcs_misc = devm_of_iomap(dev, np, 5, NULL);
> > +
> > +		if (cfg->has_ln_shrd_serdes_tbl)
> > +			qmp->ln_shrd_serdes = devm_of_iomap(dev, np, 6, NULL);
> 
> I think we also need to check the returned value. Also, I think we can drop
> the conditional check here. we don't have to validate the DT, so if the reg
> is present in DT, then it's present. If not, it's not required.

Yeah, but I was trying to make sure that if there is a new type of reg
for some upcomming SoC, we don't take that as ln_shrd. That's why the check
was added.

I'll add the returned value check though.

> 
> >   	} else {
> >   		qmp->pcs_misc = devm_of_iomap(dev, np, 3, NULL);
> >   	}
> > @@ -2729,6 +3077,12 @@ static const struct of_device_id qmp_pcie_of_match_table[] = {
> >   	}, {
> >   		.compatible = "qcom,sm8450-qmp-gen4x2-pcie-phy",
> >   		.data = &sm8450_qmp_gen4x2_pciephy_cfg,
> > +	}, {
> > +		.compatible = "qcom,sm8550-qmp-gen3x2-pcie-phy",
> > +		.data = &sm8550_qmp_gen3x2_pciephy_cfg,
> > +	}, {
> > +		.compatible = "qcom,sm8550-qmp-gen4x2-pcie-phy",
> > +		.data = &sm8550_qmp_gen4x2_pciephy_cfg,
> >   	},
> >   	{ },
> >   };
> 
> -- 
> With best wishes
> Dmitry
> 

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2023-01-17 13:57 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 12:01 [PATCH 00/10] phy: qualcomm: Add support for SM8550 Abel Vesa
2022-11-16 12:01 ` [PATCH 01/10] phy: qcom-qmp: qserdes-com: Add v6 register offsets Abel Vesa
2022-11-24 17:54   ` Vinod Koul
2022-11-16 12:01 ` [PATCH 02/10] dt-bindings: phy: Add QMP UFS PHY comptible for SM8550 Abel Vesa
2022-11-16 13:46   ` Johan Hovold
2022-11-16 12:01 ` [PATCH 03/10] phy: qcom-qmp-ufs: Add SM8550 support Abel Vesa
2022-11-17 15:36   ` kernel test robot
2022-11-24 17:55   ` Vinod Koul
2022-11-16 12:01 ` [PATCH 04/10] dt-bindings: phy: qcom,qmp-usb: Document SM8550 compatible Abel Vesa
2022-11-16 13:46   ` Johan Hovold
2023-01-23 10:19     ` Johan Hovold
2023-01-23 10:48       ` Abel Vesa
2023-01-23 10:49         ` Johan Hovold
2022-11-16 12:01 ` [PATCH 05/10] phy: qualcomm: qmp-usb: Add support for SM8550 Abel Vesa
2022-11-17 16:17   ` kernel test robot
2022-11-24 17:56   ` Vinod Koul
2022-11-16 12:01 ` [PATCH 06/10] dt-bindings: phy: qcom,qmp-pcie: Document SM8550 compatible Abel Vesa
2022-11-16 13:47   ` Johan Hovold
2022-11-16 12:01 ` [PATCH 07/10] phy: qualcomm: qmp-pcie: Add support for SM8550 g3x2 and g4x2 PCIEs Abel Vesa
2023-01-01 20:15   ` Dmitry Baryshkov
2023-01-17 13:57     ` Abel Vesa [this message]
2023-01-17 14:08       ` Dmitry Baryshkov
2022-11-16 12:01 ` [PATCH 08/10] dt-bindings: phy: Add qcom,snps-eusb2-phy schema file Abel Vesa
2022-11-16 15:29   ` Rob Herring
2022-11-16 15:44   ` Rob Herring
2022-11-16 12:01 ` [PATCH 09/10] phy: qualcomm: Add QCOM SNPS eUSB2 driver Abel Vesa
2022-11-24 18:01   ` Vinod Koul
2022-11-16 12:01 ` [PATCH 10/10] phy: qualcomm: phy-qcom-snps-eusb2: Add support for eUSB2 repeater Abel Vesa
2022-11-17  1:43   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y8apUXpfAyaMMmH/@linaro.org \
    --to=abel.vesa@linaro.org \
    --cc=agross@kernel.org \
    --cc=andersson@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=kishon@kernel.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=robh@kernel.org \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).