ARM: fec_main.c: Enable PHYs at boot and enable suspend functionallity.
authorJosep Orga <jorga@somdevices.com>
Tue, 14 Apr 2020 20:29:39 +0000 (22:29 +0200)
committerJosep Orga <jorga@somdevices.com>
Tue, 14 Apr 2020 20:29:39 +0000 (22:29 +0200)
ยท imx6ull-somdevices.dtsi: Disable second phy when one ethernet selected.

Signed-off-by: Josep Orga <jorga@somdevices.com>
arch/arm/boot/dts/imx6ull-somdevices.dtsi
drivers/net/ethernet/freescale/fec_main.c

index 4924f84..5d4c572 100644 (file)
                        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 {
index fdec8cb..0c95c68 100644 (file)
@@ -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);