u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] phy: zynqmp: Add support for sata and DP phy initialization
@ 2022-01-19 14:18 Michal Simek
  2022-01-19 14:18 ` [PATCH 2/2] scsi: ceva: Enable PHY and reset support Michal Simek
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2022-01-19 14:18 UTC (permalink / raw)
  To: u-boot, git

DP is untested but just c&p from Linux driver. Sata is tested on kv260-revA
board which has SATA connector populated.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/phy/phy-zynqmp.c | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/phy-zynqmp.c b/drivers/phy/phy-zynqmp.c
index 9dc3d426a3d3..c5c7d3a2982c 100644
--- a/drivers/phy/phy-zynqmp.c
+++ b/drivers/phy/phy-zynqmp.c
@@ -373,6 +373,29 @@ static void xpsgtr_bypass_scrambler_8b10b(struct xpsgtr_phy *gtr_phy)
 	xpsgtr_write_phy(gtr_phy, L0_TX_DIG_61, L0_TM_DISABLE_SCRAMBLE_ENCODER);
 }
 
+/* DP-specific initialization. */
+static void xpsgtr_phy_init_dp(struct xpsgtr_phy *gtr_phy)
+{
+	xpsgtr_write_phy(gtr_phy, L0_TXPMD_TM_45,
+			 L0_TXPMD_TM_45_OVER_DP_MAIN |
+			 L0_TXPMD_TM_45_ENABLE_DP_MAIN |
+			 L0_TXPMD_TM_45_OVER_DP_POST1 |
+			 L0_TXPMD_TM_45_OVER_DP_POST2 |
+			 L0_TXPMD_TM_45_ENABLE_DP_POST2);
+	xpsgtr_write_phy(gtr_phy, L0_TX_ANA_TM_118,
+			 L0_TX_ANA_TM_118_FORCE_17_0);
+}
+
+/* SATA-specific initialization. */
+static void xpsgtr_phy_init_sata(struct xpsgtr_phy *gtr_phy)
+{
+	struct xpsgtr_dev *gtr_dev = gtr_phy->dev;
+
+	xpsgtr_bypass_scrambler_8b10b(gtr_phy);
+
+	writel(gtr_phy->lane, gtr_dev->siou + SATA_CONTROL_OFFSET);
+}
+
 /* SGMII-specific initialization. */
 static void xpsgtr_phy_init_sgmii(struct xpsgtr_phy *gtr_phy)
 {
@@ -427,8 +450,13 @@ static int xpsgtr_init(struct phy *x)
 	case ICM_PROTOCOL_SGMII:
 		xpsgtr_phy_init_sgmii(gtr_phy);
 		break;
-	case ICM_PROTOCOL_DP:
 	case ICM_PROTOCOL_SATA:
+		xpsgtr_phy_init_sata(gtr_phy);
+		break;
+	case ICM_PROTOCOL_DP:
+		xpsgtr_phy_init_dp(gtr_phy);
+		break;
+	default:
 		return -EINVAL;
 	}
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] scsi: ceva: Enable PHY and reset support
  2022-01-19 14:18 [PATCH 1/2] phy: zynqmp: Add support for sata and DP phy initialization Michal Simek
@ 2022-01-19 14:18 ` Michal Simek
  2022-01-31  9:44   ` Vladimir Oltean
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2022-01-19 14:18 UTC (permalink / raw)
  To: u-boot, git; +Cc: Michael Walle, Priyanka Jain, Vladimir Oltean

Add phy and reset support for ceva sata IP. Phy and reset are optional
properties that's why detect if description is available. If not just
continue with operation.
This code was tested on Xilinx Kria SOM kv260-revA with sata connector
populated.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/ata/sata_ceva.c | 44 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/drivers/ata/sata_ceva.c b/drivers/ata/sata_ceva.c
index b71f10223da8..43bcc59cd282 100644
--- a/drivers/ata/sata_ceva.c
+++ b/drivers/ata/sata_ceva.c
@@ -6,9 +6,12 @@
 #include <common.h>
 #include <dm.h>
 #include <ahci.h>
+#include <generic-phy.h>
 #include <log.h>
+#include <reset.h>
 #include <scsi.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/ioport.h>
 
 /* Vendor Specific Register Offsets */
@@ -181,6 +184,47 @@ static int sata_ceva_bind(struct udevice *dev)
 static int sata_ceva_probe(struct udevice *dev)
 {
 	struct ceva_sata_priv *priv = dev_get_priv(dev);
+	struct phy phy;
+	int ret;
+	struct reset_ctl_bulk resets;
+
+	ret = generic_phy_get_by_index(dev, 0, &phy);
+	if (!ret) {
+		dev_dbg(dev, "Perform PHY initialization\n");
+		ret = generic_phy_init(&phy);
+		if (ret)
+			return ret;
+	} else if (ret != -ENOENT) {
+		dev_dbg(dev, "could not get phy (err %d)\n", ret);
+		return ret;
+	}
+
+	/* reset is optional */
+	ret = reset_get_bulk(dev, &resets);
+	if (ret && ret != -ENOTSUPP && ret != -ENOENT) {
+		dev_dbg(dev, "Getting reset fails (err %d)\n", ret);
+		return ret;
+	}
+
+	/* Just trigger reset when reset is specified */
+	if (!ret) {
+		dev_dbg(dev, "Perform IP reset\n");
+		ret = reset_deassert_bulk(&resets);
+		if (ret) {
+			dev_dbg(dev, "Reset fails (err %d)\n", ret);
+			reset_release_bulk(&resets);
+			return ret;
+		}
+	}
+
+	if (phy.dev) {
+		dev_dbg(dev, "Perform PHY power on\n");
+		ret = generic_phy_power_on(&phy);
+		if (ret) {
+			dev_dbg(dev, "PHY power on failed (err %d)\n", ret);
+			return ret;
+		}
+	}
 
 	ceva_init_sata(priv);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] scsi: ceva: Enable PHY and reset support
  2022-01-19 14:18 ` [PATCH 2/2] scsi: ceva: Enable PHY and reset support Michal Simek
@ 2022-01-31  9:44   ` Vladimir Oltean
  0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2022-01-31  9:44 UTC (permalink / raw)
  To: Michal Simek; +Cc: u-boot, git, Michael Walle, Priyanka Jain

On Wed, Jan 19, 2022 at 03:18:54PM +0100, Michal Simek wrote:
> Add phy and reset support for ceva sata IP. Phy and reset are optional
> properties that's why detect if description is available. If not just
> continue with operation.
> This code was tested on Xilinx Kria SOM kv260-revA with sata connector
> populated.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

> 
>  drivers/ata/sata_ceva.c | 44 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
> 
> diff --git a/drivers/ata/sata_ceva.c b/drivers/ata/sata_ceva.c
> index b71f10223da8..43bcc59cd282 100644
> --- a/drivers/ata/sata_ceva.c
> +++ b/drivers/ata/sata_ceva.c
> @@ -6,9 +6,12 @@
>  #include <common.h>
>  #include <dm.h>
>  #include <ahci.h>
> +#include <generic-phy.h>
>  #include <log.h>
> +#include <reset.h>
>  #include <scsi.h>
>  #include <asm/io.h>
> +#include <dm/device_compat.h>
>  #include <linux/ioport.h>
>  
>  /* Vendor Specific Register Offsets */
> @@ -181,6 +184,47 @@ static int sata_ceva_bind(struct udevice *dev)
>  static int sata_ceva_probe(struct udevice *dev)
>  {
>  	struct ceva_sata_priv *priv = dev_get_priv(dev);
> +	struct phy phy;
> +	int ret;
> +	struct reset_ctl_bulk resets;
> +
> +	ret = generic_phy_get_by_index(dev, 0, &phy);
> +	if (!ret) {
> +		dev_dbg(dev, "Perform PHY initialization\n");
> +		ret = generic_phy_init(&phy);
> +		if (ret)
> +			return ret;
> +	} else if (ret != -ENOENT) {
> +		dev_dbg(dev, "could not get phy (err %d)\n", ret);
> +		return ret;
> +	}
> +
> +	/* reset is optional */
> +	ret = reset_get_bulk(dev, &resets);
> +	if (ret && ret != -ENOTSUPP && ret != -ENOENT) {
> +		dev_dbg(dev, "Getting reset fails (err %d)\n", ret);
> +		return ret;
> +	}
> +
> +	/* Just trigger reset when reset is specified */
> +	if (!ret) {
> +		dev_dbg(dev, "Perform IP reset\n");
> +		ret = reset_deassert_bulk(&resets);
> +		if (ret) {
> +			dev_dbg(dev, "Reset fails (err %d)\n", ret);
> +			reset_release_bulk(&resets);
> +			return ret;
> +		}
> +	}
> +
> +	if (phy.dev) {
> +		dev_dbg(dev, "Perform PHY power on\n");
> +		ret = generic_phy_power_on(&phy);
> +		if (ret) {
> +			dev_dbg(dev, "PHY power on failed (err %d)\n", ret);
> +			return ret;
> +		}
> +	}
>  
>  	ceva_init_sata(priv);
>  
> -- 
> 2.34.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-31  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19 14:18 [PATCH 1/2] phy: zynqmp: Add support for sata and DP phy initialization Michal Simek
2022-01-19 14:18 ` [PATCH 2/2] scsi: ceva: Enable PHY and reset support Michal Simek
2022-01-31  9:44   ` Vladimir Oltean

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).