From a293e984319aebe6fe713faf58333535dd98c335 Mon Sep 17 00:00:00 2001 From: Josep Orga Date: Tue, 14 Apr 2020 22:29:39 +0200 Subject: [PATCH] =?utf8?q?ARM:=20fec=5Fmain.c:=20Enable=20PHYs=20at=20boot?= =?utf8?q?=20and=20enable=20suspend=20functionallity.=20=09=C2=B7=20imx6ul?= =?utf8?q?l-somdevices.dtsi:=20Disable=20second=20phy=20when=20one=20ether?= =?utf8?q?net=20selected.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Josep Orga --- arch/arm/boot/dts/imx6ull-somdevices.dtsi | 8 +++++++ drivers/net/ethernet/freescale/fec_main.c | 27 ++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/arch/arm/boot/dts/imx6ull-somdevices.dtsi b/arch/arm/boot/dts/imx6ull-somdevices.dtsi index 4924f847f9fd..5d4c5724c6e5 100644 --- a/arch/arm/boot/dts/imx6ull-somdevices.dtsi +++ b/arch/arm/boot/dts/imx6ull-somdevices.dtsi @@ -78,6 +78,14 @@ gpios = <&gpio5 9 GPIO_ACTIVE_HIGH>; linux,default-trigger = "heartbeat"; }; +#ifndef DUAL_ETH + led99 { + //GPIO to disable FEC2 when one ethernet is selected. + label = "ethernet_phy_2"; + gpios = <&gpio5 11 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; +#endif }; wifi_pwrseq: wifi_pwrseq { diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index fdec8cbe4f7b..0c95c68e5bb2 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3458,6 +3458,23 @@ static int fec_enet_init(struct net_device *ndev) } #ifdef CONFIG_OF +#define GPIO_SOMDEVICES_PHY_1 138 +#define GPIO_SOMDEVICES_PHY_2 139 +static void fec_reset_phy_init_SOMDEVICES(void) +{ + int ret = 0; + ret = gpio_request(GPIO_SOMDEVICES_PHY_1, "RESET_PHY_1"); + if (!ret) { + gpio_direction_output(GPIO_SOMDEVICES_PHY_1, 1); + gpio_free(GPIO_SOMDEVICES_PHY_1); + } + ret = gpio_request(GPIO_SOMDEVICES_PHY_2, "RESET_PHY_2"); + if (!ret) { + ret = gpio_direction_output(GPIO_SOMDEVICES_PHY_2, 1); + gpio_free(GPIO_SOMDEVICES_PHY_2); + } +} + static int fec_reset_phy_init(struct platform_device *pdev) { int err; @@ -3490,9 +3507,8 @@ static int fec_reset_phy_init(struct platform_device *pdev) dev_err(&pdev->dev, "failed to get phy-reset-gpios: %d\n", err); return err; } - fep->phy_reset_in_suspend = of_find_property(np, - "phy-reset-in-suspend", - NULL); + fep->phy_reset_in_suspend = of_property_read_bool(np, + "phy-reset-in-suspend"); /* Enable PHY and wait for stabilization */ gpio_set_value_cansleep(fep->phy_reset_gpio, !fep->active_high); if (fep->phy_reset_duration < 20) @@ -3619,6 +3635,7 @@ fec_probe(struct platform_device *pdev) int num_tx_qs; int num_rx_qs; + fec_reset_phy_init_SOMDEVICES(); of_dma_configure(&pdev->dev, np); fec_enet_get_queue_num(pdev, &num_tx_qs, &num_rx_qs); @@ -3938,7 +3955,7 @@ static int __maybe_unused fec_suspend(struct device *dev) ret = pm_runtime_force_suspend(dev); if (ret < 0) return ret; - } else if (fep->mii_bus_share && !ndev->phydev) { + } else { pinctrl_pm_select_sleep_state(&fep->pdev->dev); if (fep->phy_reset_in_suspend) gpio_set_value_cansleep(fep->phy_reset_gpio, fep->active_high); @@ -3999,7 +4016,7 @@ static int __maybe_unused fec_resume(struct device *dev) netif_tx_unlock_bh(ndev); napi_enable(&fep->napi); phy_start(ndev->phydev); - } else if (fep->mii_bus_share && !ndev->phydev) { + } else { pinctrl_pm_select_default_state(&fep->pdev->dev); if (fep->phy_reset_in_suspend) gpio_set_value_cansleep(fep->phy_reset_gpio, !fep->active_high); -- 2.17.1