]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
scsi: ceva: Enable PHY and reset support
authorMichal Simek <michal.simek@xilinx.com>
Mon, 7 Feb 2022 09:36:33 +0000 (10:36 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 15 Feb 2022 12:04:28 +0000 (13:04 +0100)
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>
Link: https://lore.kernel.org/r/eb3adf649be866aab19fc70ecc0fc8921545b1ac.1644226590.git.michal.simek@xilinx.com
drivers/ata/sata_ceva.c

index b71f10223da803f80fd757b67d7f267faf476d91..43bcc59cd282ce89429bb2e710a87b9352590121 100644 (file)
@@ -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);