[U-Boot] [PATCH 2/6] net: sun8i-emac: use new, generic GPIO setup routine

Andre Przywara andre.przywara at arm.com
Mon Feb 27 00:26:41 UTC 2017


Instead of open-coding the fairly generic pinmux setup in the sun8i-emac
driver, let's just use the new common implementation of that.
This has also the advantage of supporting the newpinctrl bindings, so
the driver can cope with the upstream Linux DTs.

Signed-off-by: Andre Przywara <andre.przywara at arm.com>
---
 drivers/net/sun8i_emac.c | 38 ++++++--------------------------------
 1 file changed, 6 insertions(+), 32 deletions(-)

diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c
index abdfada..8a1ea55 100644
--- a/drivers/net/sun8i_emac.c
+++ b/drivers/net/sun8i_emac.c
@@ -438,42 +438,16 @@ static int _sun8i_emac_eth_init(struct emac_eth_dev *priv, u8 *enetaddr)
 
 static int parse_phy_pins(struct udevice *dev)
 {
-	int offset;
-	const char *pin_name;
-	int drive, pull, i;
+	int ret = sunxi_gpio_setup_dt_pins(gd->fdt_blob, dev->of_offset,
+					   "emac", SUN8I_GPD8_GMAC);
 
-	offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev),
-				       "pinctrl-0");
-	if (offset < 0) {
+	if (ret < 0) {
 		printf("WARNING: emac: cannot find pinctrl-0 node\n");
-		return offset;
+		return ret;
 	}
 
-	drive = fdt_getprop_u32_default_node(gd->fdt_blob, offset, 0,
-					     "allwinner,drive", 4);
-	pull = fdt_getprop_u32_default_node(gd->fdt_blob, offset, 0,
-					    "allwinner,pull", 0);
-	for (i = 0; ; i++) {
-		int pin;
-
-		pin_name = fdt_stringlist_get(gd->fdt_blob, offset,
-					      "allwinner,pins", i, NULL);
-		if (!pin_name)
-			break;
-		if (pin_name[0] != 'P')
-			continue;
-		pin = (pin_name[1] - 'A') << 5;
-		if (pin >= 26 << 5)
-			continue;
-		pin += simple_strtol(&pin_name[2], NULL, 10);
-
-		sunxi_gpio_set_cfgpin(pin, SUN8I_GPD8_GMAC);
-		sunxi_gpio_set_drv(pin, drive);
-		sunxi_gpio_set_pull(pin, pull);
-	}
-
-	if (!i) {
-		printf("WARNING: emac: cannot find allwinner,pins property\n");
+	if (!ret) {
+		printf("WARNING: emac: cannot find pins property\n");
 		return -2;
 	}
 
-- 
2.8.2



More information about the U-Boot mailing list