mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Fabio Estevam <fabio.estevam@freescale.com>,
	Andrey Smirnov <andrew.smirnov@gmail.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Justin Waters <justin.waters@timesys.com>
Subject: [PATCH 9/9] PCI: imx6: Add DT bindings to configure PHY Tx driver settings
Date: Mon, 25 Apr 2016 22:37:07 -0700	[thread overview]
Message-ID: <1461649027-5046-10-git-send-email-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <1461649027-5046-1-git-send-email-andrew.smirnov@gmail.com>

The settings in GPR8 are dependent upon the particular layout of the
hardware platform.  As such, they should be configurable via the device
tree.

Look up PHY Tx driver settings from the device tree.  Fall back to the
original hard-coded values if they are not specified in the device tree.

[Andrey Smirnov: port to Barebox codebase]

Signed-off-by: Justin Waters <justin.waters@timesys.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
 drivers/pci/pci-imx6.c | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci-imx6.c b/drivers/pci/pci-imx6.c
index ee1a0c5..e25a956 100644
--- a/drivers/pci/pci-imx6.c
+++ b/drivers/pci/pci-imx6.c
@@ -51,6 +51,11 @@ struct imx6_pcie {
 	void __iomem		*iomuxc_gpr;
 	enum imx6_pcie_variants variant;
 	void __iomem		*mem_base;
+	u32                     tx_deemph_gen1;
+	u32                     tx_deemph_gen2_3p5db;
+	u32                     tx_deemph_gen2_6db;
+	u32                     tx_swing_full;
+	u32                     tx_swing_low;
 };
 
 /* PCIe Root Complex registers (memory-mapped) */
@@ -370,21 +375,23 @@ static void imx6_pcie_init_phy(struct pcie_port *pp)
 
 	gpr8 = readl(imx6_pcie->iomuxc_gpr + IOMUXC_GPR8);
 	gpr8 &= ~IMX6Q_GPR8_TX_DEEMPH_GEN1;
+	gpr8 |= imx6_pcie->tx_deemph_gen1 << 0;
 	writel(gpr8, imx6_pcie->iomuxc_gpr + IOMUXC_GPR8);
 
 	gpr8 &= ~IMX6Q_GPR8_TX_DEEMPH_GEN2_3P5DB;
+	gpr8 |= imx6_pcie->tx_deemph_gen2_3p5db << 6;
 	writel(gpr8, imx6_pcie->iomuxc_gpr + IOMUXC_GPR8);
 
 	gpr8 &= ~IMX6Q_GPR8_TX_DEEMPH_GEN2_6DB;
-	gpr8 |= 20 << 12;
+	gpr8 |= imx6_pcie->tx_deemph_gen2_6db << 12;
 	writel(gpr8, imx6_pcie->iomuxc_gpr + IOMUXC_GPR8);
 
 	gpr8 &= ~IMX6Q_GPR8_TX_SWING_FULL;
-	gpr8 |= 127 << 18;
+	gpr8 |= imx6_pcie->tx_swing_full << 18;
 	writel(gpr8, imx6_pcie->iomuxc_gpr + IOMUXC_GPR8);
 
 	gpr8 &= ~IMX6Q_GPR8_TX_SWING_LOW;
-	gpr8 |= 127 << 25;
+	gpr8 |= imx6_pcie->tx_swing_low << 25;
 	writel(gpr8, imx6_pcie->iomuxc_gpr + IOMUXC_GPR8);
 }
 
@@ -620,6 +627,27 @@ static int __init imx6_pcie_probe(struct device_d *dev)
 	/* Grab GPR config register range */
 	imx6_pcie->iomuxc_gpr = IOMEM(MX6_IOMUXC_BASE_ADDR);
 
+	/* Grab PCIe PHY Tx Settings */
+	if (of_property_read_u32(np, "fsl,tx-deemph-gen1",
+				 &imx6_pcie->tx_deemph_gen1))
+		imx6_pcie->tx_deemph_gen1 = 0;
+
+	if (of_property_read_u32(np, "fsl,tx-deemph-gen2-3p5db",
+				 &imx6_pcie->tx_deemph_gen2_3p5db))
+		imx6_pcie->tx_deemph_gen2_3p5db = 0;
+
+	if (of_property_read_u32(np, "fsl,tx-deemph-gen2-6db",
+				 &imx6_pcie->tx_deemph_gen2_6db))
+		imx6_pcie->tx_deemph_gen2_6db = 20;
+
+	if (of_property_read_u32(np, "fsl,tx-swing-full",
+				 &imx6_pcie->tx_swing_full))
+		imx6_pcie->tx_swing_full = 127;
+
+	if (of_property_read_u32(np, "fsl,tx-swing-low",
+				 &imx6_pcie->tx_swing_low))
+		imx6_pcie->tx_swing_low = 127;
+
 	ret = imx6_add_pcie_port(pp, dev);
 	if (ret < 0)
 		return ret;
-- 
2.5.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-04-26  5:37 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-26  5:36 [PATCH 0/9] i.MX6Q+ fixes plus number of latest Kernel changes Andrey Smirnov
2016-04-26  5:36 ` [PATCH 1/9] PCI: imx6: Simplify imx6_pcie_remove() Andrey Smirnov
2016-04-26  5:37 ` [PATCH 2/9] OF: Port of_match_device() and of_device_get_match_data() Andrey Smirnov
2016-04-26  5:37 ` [PATCH 3/9] PCI: imx6: Add proper i.MX6+ reset sequence Andrey Smirnov
2016-04-26  5:37 ` [PATCH 4/9] PCI: imx6: Rename imx6_pcie_start_link() to imx6_pcie_establish_link() Andrey Smirnov
2016-05-04 21:53   ` Bjorn Helgaas
2016-04-26  5:37 ` [PATCH 5/9] PCI: imx6: Simplify a trivial if-return sequence Andrey Smirnov
2016-04-26  5:37 ` [PATCH 6/9] PCI: imx6: Move imx6_pcie_reset_phy() near other PHY handling functions Andrey Smirnov
2016-04-26  5:37 ` [PATCH 7/9] PCI: imx6: Move PHY reset into imx6_pcie_establish_link() Andrey Smirnov
2016-04-26  5:37 ` [PATCH 8/9] PCI: imx6: Remove broken Gen2 workaround Andrey Smirnov
2016-04-26  5:37 ` Andrey Smirnov [this message]
2016-04-27  9:05 ` [PATCH 0/9] i.MX6Q+ fixes plus number of latest Kernel changes Lucas Stach
2016-04-28  5:45 ` Sascha Hauer

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=1461649027-5046-10-git-send-email-andrew.smirnov@gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=bhelgaas@google.com \
    --cc=fabio.estevam@freescale.com \
    --cc=justin.waters@timesys.com \
    /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