All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/6] net: sun8i-emac: use new, generic GPIO setup routine
Date: Mon, 27 Feb 2017 00:26:41 +0000	[thread overview]
Message-ID: <1488155205-9305-3-git-send-email-andre.przywara@arm.com> (raw)
In-Reply-To: <1488155205-9305-1-git-send-email-andre.przywara@arm.com>

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@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

  parent reply	other threads:[~2017-02-27  0:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-27  0:26 [U-Boot] [PATCH 0/6] sunxi: update Pine64/A64 DTs Andre Przywara
2017-02-27  0:26 ` [U-Boot] [PATCH 1/6] sunxi: GPIO: introduce sunxi_gpio_setup_dt_pins() Andre Przywara
2017-02-27  3:35   ` Chen-Yu Tsai
2017-02-27 10:07   ` Maxime Ripard
2017-02-27 11:20     ` Andre Przywara
2017-02-27  0:26 ` Andre Przywara [this message]
2017-02-27  0:26 ` [U-Boot] [PATCH 3/6] sunxi: dts: update sun50i-a64.dtsi from Linux Andre Przywara
2017-02-27  0:26 ` [U-Boot] [PATCH 4/6] sunxi: dts: update Pine64 .dts Andre Przywara
2017-02-27  0:26 ` [U-Boot] [PATCH 5/6] sunxi: dts: remove now obsolete pine64-common.dtsi Andre Przywara
2017-02-27  0:26 ` [U-Boot] [PATCH 6/6] sunxi: dts: add Bananapi M64 .dts Andre Przywara
2017-02-27  3:30 ` [U-Boot] [PATCH 0/6] sunxi: update Pine64/A64 DTs Chen-Yu Tsai
2017-02-27  9:53   ` Andre Przywara
2017-02-27 12:39     ` Chen-Yu Tsai
2017-05-02 10:39       ` Jagan Teki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1488155205-9305-3-git-send-email-andre.przywara@arm.com \
    --to=andre.przywara@arm.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.