gmac: adjust power control
authorhwg <hwg@rock-chips.com>
Thu, 27 Mar 2014 14:17:43 +0000 (22:17 +0800)
committerhwg <hwg@rock-chips.com>
Thu, 27 Mar 2014 14:17:50 +0000 (22:17 +0800)
arch/arm/boot/dts/rk3288-pinctrl.dtsi
arch/arm/boot/dts/rk3288-tb.dts
drivers/net/ethernet/rockchip/gmac/stmmac.h
drivers/net/ethernet/rockchip/gmac/stmmac_main.c
drivers/net/ethernet/rockchip/gmac/stmmac_platform.c

index 220b53ce34c598be15c2bf3eced54de9ff89558f..5fd8547cd81531ee02870c03f327e5dea60c5722 100755 (executable)
                        };
                        
                        mac_rxpins: mac-rxpins {
-                               rockchip,pins = <MAC_RXD0>, <MAC_RXD1>, <MAC_RXD2>, <MAC_RXD3>, <MAC_RXDV>, <MAC_RXER>, <MAC_RXCLK>, <MAC_CRS>, <MAC_COL>;
+                               rockchip,pins = <MAC_RXD0>, <MAC_RXD1>, <MAC_RXD2>, <MAC_RXD3>, <MAC_RXDV>, <MAC_RXER>, <MAC_RXCLK>, <MAC_COL>;
+                               rockchip,pull = <VALUE_PULL_DISABLE>;
+                               //rockchip,voltage = <VALUE_VOL_DEFAULT>;
+                               rockchip,drive = <VALUE_DRV_DEFAULT>;
+                               //rockchip,tristate = <VALUE_TRI_DEFAULT>;
+                       };
+                       
+                       mac_crs: mac-crs {
+                               rockchip,pins = <MAC_CRS>;
                                rockchip,pull = <VALUE_PULL_DISABLE>;
                                //rockchip,voltage = <VALUE_VOL_DEFAULT>;
                                rockchip,drive = <VALUE_DRV_DEFAULT>;
index 47fcfa7c5a5c7589cc7815848b5acc3cc0ad5a07..f6b9b4e90b35114bbcf7732cef37f771ea759dd9 100755 (executable)
 //     power_ctl_by = "gpio";  //"gpio" "pmu"
        power-gpio = <&gpio0 GPIO_A6 GPIO_ACTIVE_HIGH>;
 //     power-pmu = "act_ldo"
-       reset-gpio = <&gpio4 GPIO_A7 GPIO_ACTIVE_HIGH>;
+       reset-gpio = <&gpio4 GPIO_A7 GPIO_ACTIVE_LOW>;
 };
 
 &pinctrl {
index d536f96caed5e54eb7196ee6571e27114152be06..8f23e1106868485b28b4bbfaea54c0cd35cb909e 100755 (executable)
@@ -112,7 +112,9 @@ struct stmmac_priv {
 struct bsp_priv {
        char pwr_ctl_by[8];
        int power_io;
+       int power_io_level;
        int reset_io;
+       int reset_io_level;
        int phy_iface;
        int (*phy_power_on)(struct plat_stmmacenet_data *plat, int enable);
 };
index 15482c498239877605df49b0611123c8ac3c84b9..4fb91e954f059c3cc261c337db34f41889ef2c81 100755 (executable)
@@ -1580,6 +1580,17 @@ static int stmmac_open(struct net_device *dev)
 
        stmmac_check_ether_addr(priv);
 
+       if (priv->pcs != STMMAC_PCS_SGMII && priv->pcs != STMMAC_PCS_TBI &&
+           priv->pcs != STMMAC_PCS_RTBI) {
+               /* MDIO bus Registration */
+               ret = stmmac_mdio_register(priv->dev);
+               if (ret < 0) {
+                       pr_debug("%s: MDIO bus (id: %d) registration failed",
+                                __func__, priv->plat->bus_id);
+                       goto open_error;
+               }
+       }       
+
        if (priv->pcs != STMMAC_PCS_SGMII && priv->pcs != STMMAC_PCS_TBI &&
            priv->pcs != STMMAC_PCS_RTBI) {
                ret = stmmac_init_phy(dev);
@@ -2736,17 +2747,6 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
 
        stmmac_check_pcs_mode(priv);
 
-       if (priv->pcs != STMMAC_PCS_SGMII && priv->pcs != STMMAC_PCS_TBI &&
-           priv->pcs != STMMAC_PCS_RTBI) {
-               /* MDIO bus Registration */
-               ret = stmmac_mdio_register(ndev);
-               if (ret < 0) {
-                       pr_debug("%s: MDIO bus (id: %d) registration failed",
-                                __func__, priv->plat->bus_id);
-                       goto error_mdio_register;
-               }
-       }
-
        return priv;
 
 error_mdio_register:
index 9c1e4f7da906e84eb8066355d8b0cc68a87fefcb..b69ca66df9626d36f921f612f976cb95b2d3ff6c 100755 (executable)
@@ -28,6 +28,8 @@
 #include <linux/of_net.h>
 #include <linux/gpio.h>
 #include <linux/of_gpio.h>
+#include <linux/of_device.h>
+#include <dt-bindings/gpio/gpio.h>
 #include "stmmac.h"
 #include <linux/rockchip/iomap.h>
 #include <linux/rockchip/grf.h>
@@ -80,22 +82,24 @@ static int phy_power_on(struct plat_stmmacenet_data *plat, int enable)
        if (enable) {
                //power on
                if (gpio_is_valid(bsp_priv->power_io)) {
-                       gpio_direction_output(bsp_priv->power_io, 0);
-                       gpio_set_value(bsp_priv->power_io, 1);
+                       gpio_direction_output(bsp_priv->power_io, !bsp_priv->power_io_level);
+                       msleep(10);
+                       gpio_direction_output(bsp_priv->power_io, bsp_priv->power_io_level);
+                       //gpio_set_value(bsp_priv->power_io, 1);
                }
 
                //reset
                if (gpio_is_valid(bsp_priv->reset_io)) {
-                       gpio_direction_output(bsp_priv->reset_io, 0);
-                       gpio_set_value(bsp_priv->reset_io, 0);
+                       gpio_direction_output(bsp_priv->reset_io, bsp_priv->reset_io_level);
+                       //gpio_set_value(bsp_priv->reset_io, 0);
                        msleep(10);
-                       gpio_set_value(bsp_priv->reset_io, 1);
+                       gpio_direction_output(bsp_priv->reset_io, !bsp_priv->reset_io_level);
                }
        } else {
                //power off
                if (gpio_is_valid(bsp_priv->power_io)) {
-                       gpio_direction_output(bsp_priv->power_io, 0);
-                       gpio_set_value(bsp_priv->power_io, 0);
+                       gpio_direction_output(bsp_priv->power_io, !bsp_priv->power_io_level);
+                       //gpio_set_value(bsp_priv->power_io, 0);
                }
        }
 
@@ -244,8 +248,10 @@ static int stmmac_probe_config_dt(struct platform_device *pdev,
 
        g_bsp_priv.reset_io = 
                        of_get_named_gpio_flags(np, "reset-gpio", 0, &flags);
+       g_bsp_priv.reset_io_level = (flags == GPIO_ACTIVE_HIGH) ? 1 : 0;
        g_bsp_priv.power_io = 
                        of_get_named_gpio_flags(np, "power-gpio", 0, &flags);
+       g_bsp_priv.power_io_level = (flags == GPIO_ACTIVE_HIGH) ? 1 : 0;
 
        g_bsp_priv.phy_iface = plat->interface;
        g_bsp_priv.phy_power_on = phy_power_on;