build/patch/kernel/sun8i-default/02-0009-unify-ethernet-settings.patch
2016-04-13 09:25:21 +02:00

113 lines
3.2 KiB
Diff

diff --git a/drivers/net/ethernet/sunxi/eth/Kconfig b/drivers/net/ethernet/sunxi/eth/Kconfig
index af930df..13787db 100755
--- a/drivers/net/ethernet/sunxi/eth/Kconfig
+++ b/drivers/net/ethernet/sunxi/eth/Kconfig
@@ -35,13 +35,5 @@ config GETH_PHY_POWER
If external PHY power is exist, and it want to be controled,
select it. If not, it mean the power of PHY already on.
-config GMAC_PHY_POWER
- bool "External PHY power control"
- depends on SUNXI_GETH
- default y
- ---help---
- If external PHY power is exist, and it want to be controled,
- select it. If not, it mean the power of PHY already on.
-
endif
diff --git a/drivers/net/ethernet/sunxi/eth/sunxi_geth.c b/drivers/net/ethernet/sunxi/eth/sunxi_geth.c
index 03931f2..446a83e 100755
--- a/drivers/net/ethernet/sunxi/eth/sunxi_geth.c
+++ b/drivers/net/ethernet/sunxi/eth/sunxi_geth.c
@@ -154,9 +154,7 @@ struct geth_priv {
spinlock_t lock;
spinlock_t tx_lock;
-#ifdef CONFIG_GMAC_PHY_POWER
- u32 gpio_power_hd;
-#endif
+ int gpio_power_hd;
};
#ifdef CONFIG_GETH_PHY_POWER
@@ -198,11 +196,8 @@ static void desc_print(struct dma_desc *desc, int size)
static int geth_power_on(struct geth_priv *priv)
{
int value;
-
-#ifdef CONFIG_GMAC_PHY_POWER
- gpio_set_value(priv->gpio_power_hd, 1);
-#endif
-
+ if (gpio_is_valid(priv->gpio_power_hd))
+ gpio_set_value(priv->gpio_power_hd, 1);
#ifdef CONFIG_GETH_PHY_POWER
struct regulator **regu;
int ret = 0, i = 0;
@@ -266,11 +261,8 @@ err:
static void geth_power_off(struct geth_priv *priv)
{
int value;
-
-#ifdef CONFIG_GMAC_PHY_POWER
- gpio_set_value(priv->gpio_power_hd, 0);
-#endif
-
+ if (gpio_is_valid(priv->gpio_power_hd))
+ gpio_set_value(priv->gpio_power_hd, 0);
#ifdef CONFIG_GETH_PHY_POWER
struct regulator **regu = priv->power;
int i = 0;
@@ -1575,6 +1567,15 @@ static int geth_script_parse(struct platform_device *pdev)
break;
}
+ priv->gpio_power_hd = -1;
+ type = script_get_item("gmac_phy_power", "gmac_phy_power_en", &item);
+ if (SCIRPT_ITEM_VALUE_TYPE_PIO == type) {
+ if (!gpio_request(item.gpio.gpio, NULL)) {
+ gpio_direction_output(item.gpio.gpio, 1);
+ priv->gpio_power_hd = item.gpio.gpio;
+ }
+ }
+
#ifdef CONFIG_GETH_PHY_POWER
memset(power_tb, 0, sizeof(power_tb));
for (cnt = 0; cnt < ARRAY_SIZE(power_tb); cnt++) {
@@ -1621,12 +1622,6 @@ static int geth_sys_request(struct platform_device *pdev)
int ret = 0;
struct resource *res;
-#ifdef CONFIG_GMAC_PHY_POWER
- script_item_value_type_e type;
- script_item_u item;
- int req_status;
-#endif
-
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "geth_extclk");
if (unlikely(!res)){
ret = -ENODEV;
@@ -1700,22 +1695,6 @@ static int geth_sys_request(struct platform_device *pdev)
}
}
#endif
-
-#ifdef CONFIG_GMAC_PHY_POWER && CONFIG_GETH_SCRIPT_SYS
- type = script_get_item("gmac_phy_power", "gmac_phy_power_en", &item);
- if (SCIRPT_ITEM_VALUE_TYPE_PIO != type) {
- pr_err("script_get_item return type err\n");
- return -EFAULT;
- }
- /*request gpio*/
- req_status = gpio_request(item.gpio.gpio, NULL);
- if (0 != req_status) {
- pr_err("request gpio failed!\n");
- }
- gpio_direction_output(item.gpio.gpio, 1);
- priv->gpio_power_hd = item.gpio.gpio;
- #endif
-
return 0;
pin_err: