[PATCH u-boot-marvell 08/11] ata: ahci_mvebu: add PHY support
Marek Behún
marek.behun at nic.cz
Sun Apr 19 17:48:47 CEST 2020
Use generic-phy API to power on SATA PHY.
Signed-off-by: Marek Behún <marek.behun at nic.cz>
---
drivers/ata/ahci_mvebu.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/drivers/ata/ahci_mvebu.c b/drivers/ata/ahci_mvebu.c
index 48a9d00d14..d229ab84ed 100644
--- a/drivers/ata/ahci_mvebu.c
+++ b/drivers/ata/ahci_mvebu.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <ahci.h>
#include <dm.h>
+#include <generic-phy.h>
/*
* Dummy implementation that can be overwritten by a board
@@ -30,14 +31,48 @@ static int mvebu_ahci_bind(struct udevice *dev)
return 0;
}
+static int mvebu_ahci_phy_power_on(struct udevice *dev)
+{
+ struct phy phy;
+ int ret;
+
+ ret = generic_phy_get_by_index(dev, 0, &phy);
+ if (ret == -ENOENT)
+ return 0;
+
+ ret = generic_phy_init(&phy);
+ if (ret)
+ return ret;
+
+ ret = generic_phy_set_mode(&phy, PHY_MODE_SATA, 0);
+ if (ret)
+ goto err;
+
+ ret = generic_phy_power_on(&phy);
+ if (ret)
+ goto err;
+
+ return 0;
+
+err:
+ generic_phy_exit(&phy);
+ return ret;
+}
+
static int mvebu_ahci_probe(struct udevice *dev)
{
+ int ret;
+
/*
* Board specific SATA / AHCI enable code, e.g. enable the
* AHCI power or deassert reset
*/
board_ahci_enable();
+ ret = mvebu_ahci_phy_power_on(dev);
+ if (ret)
+ return ret;
+
ahci_probe_scsi(dev, (ulong)devfdt_get_addr_ptr(dev));
return 0;
--
2.24.1
More information about the U-Boot
mailing list