From patchwork Sun Apr 19 15:48:48 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: 238031 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:48 +0200 Subject: [PATCH u-boot-marvell 09/11] net: mvneta: 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-10-marek.behun@nic.cz> Use generic-phy API to power on comphy in mvneta driver. Signed-off-by: Marek Beh?n --- drivers/net/mvneta.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c index d737400a20..31548445d7 100644 --- a/drivers/net/mvneta.c +++ b/drivers/net/mvneta.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -274,6 +275,7 @@ struct mvneta_port { unsigned int link; unsigned int duplex; unsigned int speed; + struct phy comphy; int init; int phyaddr; @@ -1150,8 +1152,22 @@ static int mvneta_setup_txqs(struct mvneta_port *pp) return 0; } +static int mvneta_comphy_init(struct mvneta_port *pp) +{ + int ret; + + ret = generic_phy_set_mode(&pp->comphy, PHY_MODE_ETHERNET, + pp->phy_interface); + if (ret) + return ret; + + return generic_phy_power_on(&pp->comphy); +} + static void mvneta_start_dev(struct mvneta_port *pp) { + mvneta_comphy_init(pp); + /* start the Rx/Tx activity */ mvneta_port_enable(pp); } @@ -1723,6 +1739,12 @@ static int mvneta_probe(struct udevice *dev) else mvneta_conf_mbus_windows(pp); + ret = generic_phy_get_by_index(dev, 0, &pp->comphy); + if (ret && ret != -ENOENT) { + printf("cannot get comphy in mvneta\n"); + return ret; + } + /* PHY interface is already decoded in mvneta_ofdata_to_platdata() */ pp->phy_interface = pdata->phy_interface; @@ -1776,6 +1798,7 @@ static void mvneta_stop(struct udevice *dev) mvneta_port_down(pp); mvneta_port_disable(pp); + generic_phy_power_off(&pp->comphy); } static const struct eth_ops mvneta_ops = {