From dac3422145b4f753c7bc353ec532212bf6f41eca Mon Sep 17 00:00:00 2001 From: hwg Date: Thu, 27 Mar 2014 22:17:43 +0800 Subject: [PATCH] gmac: adjust power control --- arch/arm/boot/dts/rk3288-pinctrl.dtsi | 10 ++++++++- arch/arm/boot/dts/rk3288-tb.dts | 2 +- drivers/net/ethernet/rockchip/gmac/stmmac.h | 2 ++ .../net/ethernet/rockchip/gmac/stmmac_main.c | 22 +++++++++---------- .../ethernet/rockchip/gmac/stmmac_platform.c | 20 +++++++++++------ 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/arch/arm/boot/dts/rk3288-pinctrl.dtsi b/arch/arm/boot/dts/rk3288-pinctrl.dtsi index 220b53ce34c5..5fd8547cd815 100755 --- a/arch/arm/boot/dts/rk3288-pinctrl.dtsi +++ b/arch/arm/boot/dts/rk3288-pinctrl.dtsi @@ -985,7 +985,15 @@ }; mac_rxpins: mac-rxpins { - rockchip,pins = , , , , , , , , ; + rockchip,pins = , , , , , , , ; + rockchip,pull = ; + //rockchip,voltage = ; + rockchip,drive = ; + //rockchip,tristate = ; + }; + + mac_crs: mac-crs { + rockchip,pins = ; rockchip,pull = ; //rockchip,voltage = ; rockchip,drive = ; diff --git a/arch/arm/boot/dts/rk3288-tb.dts b/arch/arm/boot/dts/rk3288-tb.dts index 47fcfa7c5a5c..f6b9b4e90b35 100755 --- a/arch/arm/boot/dts/rk3288-tb.dts +++ b/arch/arm/boot/dts/rk3288-tb.dts @@ -167,7 +167,7 @@ // 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 { diff --git a/drivers/net/ethernet/rockchip/gmac/stmmac.h b/drivers/net/ethernet/rockchip/gmac/stmmac.h index d536f96caed5..8f23e1106868 100755 --- a/drivers/net/ethernet/rockchip/gmac/stmmac.h +++ b/drivers/net/ethernet/rockchip/gmac/stmmac.h @@ -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); }; diff --git a/drivers/net/ethernet/rockchip/gmac/stmmac_main.c b/drivers/net/ethernet/rockchip/gmac/stmmac_main.c index 15482c498239..4fb91e954f05 100755 --- a/drivers/net/ethernet/rockchip/gmac/stmmac_main.c +++ b/drivers/net/ethernet/rockchip/gmac/stmmac_main.c @@ -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: diff --git a/drivers/net/ethernet/rockchip/gmac/stmmac_platform.c b/drivers/net/ethernet/rockchip/gmac/stmmac_platform.c index 9c1e4f7da906..b69ca66df962 100755 --- a/drivers/net/ethernet/rockchip/gmac/stmmac_platform.c +++ b/drivers/net/ethernet/rockchip/gmac/stmmac_platform.c @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include "stmmac.h" #include #include @@ -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; -- 2.34.1