@@ -108,7 +108,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
enum usb_dr_mode dr_mode;
int ret = 0;
- dr_mode = usb_get_dr_mode(dev_of_offset(dev));
+ dr_mode = usb_get_dr_mode(dev->node);
cdns->role = USB_ROLE_NONE;
/*
@@ -398,7 +398,7 @@ int cdns3_bind(struct udevice *parent)
}
name = ofnode_get_name(node);
- dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
+ dr_mode = usb_get_dr_mode(node);
switch (dr_mode) {
#if defined(CONFIG_SPL_USB_HOST_SUPPORT) || \
@@ -7,7 +7,7 @@
*/
#include <common.h>
-#include <linux/libfdt.h>
+#include <dm.h>
#include <linux/usb/otg.h>
#include <linux/usb/ch9.h>
@@ -20,13 +20,12 @@ static const char *const usb_dr_modes[] = {
[USB_DR_MODE_OTG] = "otg",
};
-enum usb_dr_mode usb_get_dr_mode(int node)
+enum usb_dr_mode usb_get_dr_mode(ofnode node)
{
- const void *fdt = gd->fdt_blob;
const char *dr_mode;
int i;
- dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
+ dr_mode = ofnode_read_string(node, "dr_mode");
if (!dr_mode) {
pr_err("usb dr_mode not found\n");
return USB_DR_MODE_UNKNOWN;
@@ -98,7 +98,7 @@ static int dwc3_generic_ofdata_to_platdata(struct udevice *dev)
plat->maximum_speed = USB_SPEED_SUPER;
}
- plat->dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
+ plat->dr_mode = usb_get_dr_mode(node);
if (plat->dr_mode == USB_DR_MODE_UNKNOWN) {
pr_err("Invalid usb mode setup\n");
return -ENODEV;
@@ -295,7 +295,7 @@ static int dwc3_glue_bind(struct udevice *parent)
debug("%s: subnode name: %s\n", __func__, name);
- dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
+ dr_mode = usb_get_dr_mode(node);
switch (dr_mode) {
case USB_DR_MODE_PERIPHERAL:
@@ -398,7 +398,7 @@ static int dwc3_glue_probe(struct udevice *dev)
while (child) {
enum usb_dr_mode dr_mode;
- dr_mode = usb_get_dr_mode(dev_of_offset(child));
+ dr_mode = usb_get_dr_mode(child->node);
device_find_next_child(&child);
if (ops && ops->select_dr_mode)
ops->select_dr_mode(dev, index, dr_mode);
@@ -393,7 +393,7 @@ static int dwc3_meson_g12a_probe(struct udevice *dev)
}
#endif
- priv->otg_mode = usb_get_dr_mode(dev_of_offset(dev));
+ priv->otg_mode = usb_get_dr_mode(dev->node);
ret = dwc3_meson_g12a_usb_init(priv);
if (ret)
@@ -1039,13 +1039,12 @@ void dwc2_phy_shutdown(struct udevice *dev, struct phy *usb_phys, int num_phys)
static int dwc2_udc_otg_ofdata_to_platdata(struct udevice *dev)
{
struct dwc2_plat_otg_data *platdata = dev_get_platdata(dev);
- int node = dev_of_offset(dev);
ulong drvdata;
void (*set_params)(struct dwc2_plat_otg_data *data);
int ret;
- if (usb_get_dr_mode(node) != USB_DR_MODE_PERIPHERAL &&
- usb_get_dr_mode(node) != USB_DR_MODE_OTG) {
+ if (usb_get_dr_mode(dev->node) != USB_DR_MODE_PERIPHERAL &&
+ usb_get_dr_mode(dev->node) != USB_DR_MODE_OTG) {
dev_dbg(dev, "Invalid mode\n");
return -ENODEV;
}
@@ -164,7 +164,7 @@ static int sti_dwc3_glue_bind(struct udevice *dev)
}
/* retrieve the DWC3 dual role mode */
- plat->mode = usb_get_dr_mode(ofnode_to_offset(dwc3_node));
+ plat->mode = usb_get_dr_mode(dwc3_node);
if (plat->mode == USB_DR_MODE_UNKNOWN)
/* by default set dual role mode to HOST */
plat->mode = USB_DR_MODE_HOST;
@@ -513,7 +513,7 @@ static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
struct usb_platdata *plat = dev_get_platdata(dev);
enum usb_dr_mode dr_mode;
- dr_mode = usb_get_dr_mode(dev_of_offset(dev));
+ dr_mode = usb_get_dr_mode(dev->node);
switch (dr_mode) {
case USB_DR_MODE_HOST:
@@ -9,7 +9,6 @@
#include <common.h>
#include <dm.h>
-#include <fdtdec.h>
#include <generic-phy.h>
#include <usb.h>
#include <dwc3-uboot.h>
@@ -155,7 +154,7 @@ static int xhci_dwc3_probe(struct udevice *dev)
writel(reg, &dwc3_reg->g_usb2phycfg[0]);
- dr_mode = usb_get_dr_mode(dev_of_offset(dev));
+ dr_mode = usb_get_dr_mode(dev->node);
if (dr_mode == USB_DR_MODE_UNKNOWN)
/* by default set dual role mode to HOST */
dr_mode = USB_DR_MODE_HOST;
@@ -297,7 +297,7 @@ static int ti_musb_wrapper_bind(struct udevice *parent)
if (strncmp(name, "usb@", 4))
continue;
- dr_mode = usb_get_dr_mode(ofnode_to_offset(node));
+ dr_mode = usb_get_dr_mode(node);
switch (dr_mode) {
case USB_DR_MODE_PERIPHERAL:
/* Bind MUSB device */
@@ -9,6 +9,8 @@
#ifndef __LINUX_USB_OTG_H
#define __LINUX_USB_OTG_H
+#include <dm/ofnode.h>
+
enum usb_dr_mode {
USB_DR_MODE_UNKNOWN,
USB_DR_MODE_HOST,
@@ -18,12 +20,12 @@ enum usb_dr_mode {
/**
* usb_get_dr_mode() - Get dual role mode for given device
- * @node: Node offset to the given device
+ * @node: ofnode of the given device
*
* The function gets phy interface string from property 'dr_mode',
* and returns the correspondig enum usb_dr_mode
*/
-enum usb_dr_mode usb_get_dr_mode(int node);
+enum usb_dr_mode usb_get_dr_mode(ofnode node);
/**
* usb_get_maximum_speed() - Get maximum speed for given device