From patchwork Sun Apr 19 15:48:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 238030 List-Id: U-Boot discussion From: marek.behun at nic.cz (=?UTF-8?q?Marek=20Beh=C3=BAn?=) Date: Sun, 19 Apr 2020 17:48:47 +0200 Subject: [PATCH u-boot-marvell 08/11] ata: ahci_mvebu: add PHY support In-Reply-To: <20200419154850.25868-1-marek.behun@nic.cz> References: <20200419154850.25868-1-marek.behun@nic.cz> Message-ID: <20200419154850.25868-9-marek.behun@nic.cz> Use generic-phy API to power on SATA PHY. Signed-off-by: Marek Beh?n --- 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 #include #include +#include /* * 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;