diff mbox series

[v12,4/5] PCI: qcom: Add a flag in match data along with ops

Message ID 1633628923-25047-5-git-send-email-pmaliset@codeaurora.org (mailing list archive)
State Not Applicable
Headers show
Series Add DT bindings and DT nodes for PCIe and PHY in SC7280 | expand

Commit Message

Prasad Malisetty Oct. 7, 2021, 5:48 p.m. UTC
Add pipe_clk_need_muxing flag in match data and configure
If the platform needs to switch pipe_clk_src.

Signed-off-by: Prasad Malisetty <pmaliset@codeaurora.org>
---
 drivers/pci/controller/dwc/pcie-qcom.c | 66 ++++++++++++++++++++++++++++------
 1 file changed, 55 insertions(+), 11 deletions(-)

Comments

Stephen Boyd Oct. 7, 2021, 6:03 p.m. UTC | #1
Quoting Prasad Malisetty (2021-10-07 10:48:42)
> Add pipe_clk_need_muxing flag in match data and configure

This commit text isn't accurate. The flag isn't added in this patch
anymore. Same goes for the commit title/subject. Can you please update
it to say something like "Point match data to config struct"?

> If the platform needs to switch pipe_clk_src.
>
> Signed-off-by: Prasad Malisetty <pmaliset@codeaurora.org>
> ---

Otherwise code looks fine:

Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Prasad Malisetty Oct. 8, 2021, 1:59 a.m. UTC | #2
On 2021-10-07 23:33, Stephen Boyd wrote:
> Quoting Prasad Malisetty (2021-10-07 10:48:42)
>> Add pipe_clk_need_muxing flag in match data and configure
> 
> This commit text isn't accurate. The flag isn't added in this patch
> anymore. Same goes for the commit title/subject. Can you please update
> it to say something like "Point match data to config struct"?
> 
Hi Bjorn,

Could you please update below commit text while taking this patch.

"PCI: qcom: Replace ops with struct pcie_cfg in pcie match data.

Add struct qcom_pcie_cfg as match data for all platforms.
Assign appropriate platform ops into qcom_pcie_cfg and read
Using of_device_is_compatible in pcie probe. "

Thanks
-Prasad

>> If the platform needs to switch pipe_clk_src.
>> 
>> Signed-off-by: Prasad Malisetty <pmaliset@codeaurora.org>
>> ---
> 
> Otherwise code looks fine:
> 
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Lorenzo Pieralisi Oct. 12, 2021, 2:11 p.m. UTC | #3
On Fri, Oct 08, 2021 at 07:29:05AM +0530, Prasad Malisetty wrote:
> On 2021-10-07 23:33, Stephen Boyd wrote:
> > Quoting Prasad Malisetty (2021-10-07 10:48:42)
> > > Add pipe_clk_need_muxing flag in match data and configure
> > 
> > This commit text isn't accurate. The flag isn't added in this patch
> > anymore. Same goes for the commit title/subject. Can you please update
> > it to say something like "Point match data to config struct"?
> > 
> Hi Bjorn,
> 
> Could you please update below commit text while taking this patch.
> 
> "PCI: qcom: Replace ops with struct pcie_cfg in pcie match data.
> 
> Add struct qcom_pcie_cfg as match data for all platforms.
> Assign appropriate platform ops into qcom_pcie_cfg and read
> Using of_device_is_compatible in pcie probe. "

of_device_get_match_data() you mean ? I am confused, please let
me know, I am applying patches 4-5.

Lorenzo

> 
> Thanks
> -Prasad
> 
> > > If the platform needs to switch pipe_clk_src.
> > > 
> > > Signed-off-by: Prasad Malisetty <pmaliset@codeaurora.org>
> > > ---
> > 
> > Otherwise code looks fine:
> > 
> > Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Prasad Malisetty Oct. 12, 2021, 5:49 p.m. UTC | #4
On 2021-10-12 19:41, Lorenzo Pieralisi wrote:
> On Fri, Oct 08, 2021 at 07:29:05AM +0530, Prasad Malisetty wrote:
>> On 2021-10-07 23:33, Stephen Boyd wrote:
>> > Quoting Prasad Malisetty (2021-10-07 10:48:42)
>> > > Add pipe_clk_need_muxing flag in match data and configure
>> >
>> > This commit text isn't accurate. The flag isn't added in this patch
>> > anymore. Same goes for the commit title/subject. Can you please update
>> > it to say something like "Point match data to config struct"?
>> >
>> Hi Bjorn,
>> 
>> Could you please update below commit text while taking this patch.
>> 
>> "PCI: qcom: Replace ops with struct pcie_cfg in pcie match data.
>> 
>> Add struct qcom_pcie_cfg as match data for all platforms.
>> Assign appropriate platform ops into qcom_pcie_cfg and read
>> Using of_device_is_compatible in pcie probe. "
> 
> of_device_get_match_data() you mean ? I am confused, please let
> me know, I am applying patches 4-5.
> 
> Lorenzo
> 
>> 
Hi Lorenzo,

Sorry for the confusion. I was trying to add "of_device_get_match_data", 
you are right.

>> Thanks
>> -Prasad
>> 
>> > > If the platform needs to switch pipe_clk_src.
>> > >
>> > > Signed-off-by: Prasad Malisetty <pmaliset@codeaurora.org>
>> > > ---
>> >
>> > Otherwise code looks fine:
>> >
>> > Reviewed-by: Stephen Boyd <swboyd@chromium.org>
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c
index 8a7a300..41132dd 100644
--- a/drivers/pci/controller/dwc/pcie-qcom.c
+++ b/drivers/pci/controller/dwc/pcie-qcom.c
@@ -189,6 +189,10 @@  struct qcom_pcie_ops {
 	int (*config_sid)(struct qcom_pcie *pcie);
 };
 
+struct qcom_pcie_cfg {
+	const struct qcom_pcie_ops *ops;
+};
+
 struct qcom_pcie {
 	struct dw_pcie *pci;
 	void __iomem *parf;			/* DT parf */
@@ -1456,6 +1460,38 @@  static const struct qcom_pcie_ops ops_1_9_0 = {
 	.config_sid = qcom_pcie_config_sid_sm8250,
 };
 
+static const struct qcom_pcie_cfg apq8084_cfg = {
+	.ops = &ops_1_0_0,
+};
+
+static const struct qcom_pcie_cfg ipq8064_cfg = {
+	.ops = &ops_2_1_0,
+};
+
+static const struct qcom_pcie_cfg msm8996_cfg = {
+	.ops = &ops_2_3_2,
+};
+
+static const struct qcom_pcie_cfg ipq8074_cfg = {
+	.ops = &ops_2_3_3,
+};
+
+static const struct qcom_pcie_cfg ipq4019_cfg = {
+	.ops = &ops_2_4_0,
+};
+
+static const struct qcom_pcie_cfg sdm845_cfg = {
+	.ops = &ops_2_7_0,
+};
+
+static const struct qcom_pcie_cfg sm8250_cfg = {
+	.ops = &ops_1_9_0,
+};
+
+static const struct qcom_pcie_cfg sc7280_cfg = {
+	.ops = &ops_1_9_0,
+};
+
 static const struct dw_pcie_ops dw_pcie_ops = {
 	.link_up = qcom_pcie_link_up,
 	.start_link = qcom_pcie_start_link,
@@ -1467,6 +1503,7 @@  static int qcom_pcie_probe(struct platform_device *pdev)
 	struct pcie_port *pp;
 	struct dw_pcie *pci;
 	struct qcom_pcie *pcie;
+	const struct qcom_pcie_cfg *pcie_cfg;
 	int ret;
 
 	pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
@@ -1488,7 +1525,13 @@  static int qcom_pcie_probe(struct platform_device *pdev)
 
 	pcie->pci = pci;
 
-	pcie->ops = of_device_get_match_data(dev);
+	pcie_cfg = of_device_get_match_data(dev);
+	if (!pcie_cfg || !pcie_cfg->ops) {
+		dev_err(dev, "Invalid platform data\n");
+		return NULL;
+	}
+
+	pcie->ops = pcie_cfg->ops;
 
 	pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_HIGH);
 	if (IS_ERR(pcie->reset)) {
@@ -1545,16 +1588,17 @@  static int qcom_pcie_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id qcom_pcie_match[] = {
-	{ .compatible = "qcom,pcie-apq8084", .data = &ops_1_0_0 },
-	{ .compatible = "qcom,pcie-ipq8064", .data = &ops_2_1_0 },
-	{ .compatible = "qcom,pcie-ipq8064-v2", .data = &ops_2_1_0 },
-	{ .compatible = "qcom,pcie-apq8064", .data = &ops_2_1_0 },
-	{ .compatible = "qcom,pcie-msm8996", .data = &ops_2_3_2 },
-	{ .compatible = "qcom,pcie-ipq8074", .data = &ops_2_3_3 },
-	{ .compatible = "qcom,pcie-ipq4019", .data = &ops_2_4_0 },
-	{ .compatible = "qcom,pcie-qcs404", .data = &ops_2_4_0 },
-	{ .compatible = "qcom,pcie-sdm845", .data = &ops_2_7_0 },
-	{ .compatible = "qcom,pcie-sm8250", .data = &ops_1_9_0 },
+	{ .compatible = "qcom,pcie-apq8084", .data = &apq8084_cfg },
+	{ .compatible = "qcom,pcie-ipq8064", .data = &ipq8064_cfg },
+	{ .compatible = "qcom,pcie-ipq8064-v2", .data = &ipq8064_cfg },
+	{ .compatible = "qcom,pcie-apq8064", .data = &ipq8064_cfg },
+	{ .compatible = "qcom,pcie-msm8996", .data = &msm8996_cfg },
+	{ .compatible = "qcom,pcie-ipq8074", .data = &ipq8074_cfg },
+	{ .compatible = "qcom,pcie-ipq4019", .data = &ipq4019_cfg },
+	{ .compatible = "qcom,pcie-qcs404", .data = &ipq4019_cfg },
+	{ .compatible = "qcom,pcie-sdm845", .data = &sdm845_cfg },
+	{ .compatible = "qcom,pcie-sm8250", .data = &sm8250_cfg },
+	{ .compatible = "qcom,pcie-sc7280", .data = &sc7280_cfg },
 	{ }
 };