[U-Boot] [PATCH v5 10/20] dm: tegra: usb: Convert to livetree

Simon Glass sjg at chromium.org
Tue Jul 25 14:30:04 UTC 2017


Update the Tegra EHCI driver to support a live device tree.

Signed-off-by: Simon Glass <sjg at chromium.org>
Tested-by: Marcel Ziswiler <marcel.ziswiler at toradex.com>
Tested-on: Beaver, Jetson-TK1
---

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/usb/host/ehci-tegra.c | 34 ++++++++++++++--------------------
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index 873bf8ecfd..1c72330b0c 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -17,7 +17,6 @@
 #include <usb.h>
 #include <usb/ulpi.h>
 #include <libfdt.h>
-#include <fdtdec.h>
 
 #include "ehci.h"
 
@@ -695,12 +694,11 @@ static void config_clock(const u32 timing[])
 
 static int fdt_decode_usb(struct udevice *dev, struct fdt_usb *config)
 {
-	const void *blob = gd->fdt_blob;
-	int node = dev_of_offset(dev);
 	const char *phy, *mode;
 
-	config->reg = (struct usb_ctlr *)devfdt_get_addr(dev);
-	mode = fdt_getprop(blob, node, "dr_mode", NULL);
+	config->reg = (struct usb_ctlr *)dev_read_addr(dev);
+	debug("reg=%p\n", config->reg);
+	mode = dev_read_string(dev, "dr_mode");
 	if (mode) {
 		if (0 == strcmp(mode, "host"))
 			config->dr_mode = DR_MODE_HOST;
@@ -717,28 +715,24 @@ static int fdt_decode_usb(struct udevice *dev, struct fdt_usb *config)
 		config->dr_mode = DR_MODE_HOST;
 	}
 
-	phy = fdt_getprop(blob, node, "phy_type", NULL);
+	phy = dev_read_string(dev, "phy_type");
 	config->utmi = phy && 0 == strcmp("utmi", phy);
 	config->ulpi = phy && 0 == strcmp("ulpi", phy);
-	config->enabled = fdtdec_get_is_enabled(blob, node);
-	config->has_legacy_mode = fdtdec_get_bool(blob, node,
-						  "nvidia,has-legacy-mode");
+	config->has_legacy_mode = dev_read_bool(dev, "nvidia,has-legacy-mode");
 	config->periph_id = clock_decode_periph_id(dev);
 	if (config->periph_id == PERIPH_ID_NONE) {
 		debug("%s: Missing/invalid peripheral ID\n", __func__);
 		return -EINVAL;
 	}
-	gpio_request_by_name_nodev(offset_to_ofnode(node), "nvidia,vbus-gpio",
-				   0, &config->vbus_gpio, GPIOD_IS_OUT);
-	gpio_request_by_name_nodev(offset_to_ofnode(node),
-				   "nvidia,phy-reset-gpio", 0,
-				   &config->phy_reset_gpio, GPIOD_IS_OUT);
-	debug("enabled=%d, legacy_mode=%d, utmi=%d, ulpi=%d, periph_id=%d, "
-		"vbus=%d, phy_reset=%d, dr_mode=%d\n",
-		config->enabled, config->has_legacy_mode, config->utmi,
-		config->ulpi, config->periph_id,
-		gpio_get_number(&config->vbus_gpio),
-		gpio_get_number(&config->phy_reset_gpio), config->dr_mode);
+	gpio_request_by_name(dev, "nvidia,vbus-gpio", 0, &config->vbus_gpio,
+			     GPIOD_IS_OUT);
+	gpio_request_by_name(dev, "nvidia,phy-reset-gpio", 0,
+			     &config->phy_reset_gpio, GPIOD_IS_OUT);
+	debug("legacy_mode=%d, utmi=%d, ulpi=%d, periph_id=%d, vbus=%d, phy_reset=%d, dr_mode=%d, reg=%p\n",
+	      config->has_legacy_mode, config->utmi, config->ulpi,
+	      config->periph_id, gpio_get_number(&config->vbus_gpio),
+	      gpio_get_number(&config->phy_reset_gpio), config->dr_mode,
+	      config->reg);
 
 	return 0;
 }
-- 
2.14.0.rc0.284.gd933b75aa4-goog



More information about the U-Boot mailing list