UPSTREAM: usb: ehci-mx6: Use common code to extract dr_mode

There exists code in drivers/common/common.c to read the dr_mode
from the device tree.  This patch converts this driver to use that
function to initialize the driver.

Change-Id: Id4cc8e5a61f63bef9813e83b4183253caccedd1a
Signed-off-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(cherry picked from commit 69535b33bc1fce43dcc10b646cf44db81cffa131)
This commit is contained in:
Adam Ford 2019-04-03 08:41:56 -05:00 committed by Frank Wang
parent 79e8eddfb9
commit 0457b2cd59
1 changed files with 15 additions and 14 deletions

View File

@ -19,6 +19,7 @@
#include <dm.h>
#include <asm/mach-types.h>
#include <power/regulator.h>
#include <linux/usb/otg.h>
#include "ehci.h"
@ -484,23 +485,23 @@ static int ehci_usb_phy_mode(struct udevice *dev)
static int ehci_usb_ofdata_to_platdata(struct udevice *dev)
{
struct usb_platdata *plat = dev_get_platdata(dev);
const char *mode;
enum usb_dr_mode dr_mode;
mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "dr_mode", NULL);
if (mode) {
if (strcmp(mode, "peripheral") == 0)
plat->init_type = USB_INIT_DEVICE;
else if (strcmp(mode, "host") == 0)
plat->init_type = USB_INIT_HOST;
else if (strcmp(mode, "otg") == 0)
return ehci_usb_phy_mode(dev);
else
return -EINVAL;
dr_mode = usb_get_dr_mode(dev_of_offset(dev));
return 0;
}
switch (dr_mode) {
case USB_DR_MODE_HOST:
plat->init_type = USB_INIT_HOST;
break;
case USB_DR_MODE_PERIPHERAL:
plat->init_type = USB_INIT_DEVICE;
break;
case USB_DR_MODE_OTG:
case USB_DR_MODE_UNKNOWN:
return ehci_usb_phy_mode(dev);
};
return ehci_usb_phy_mode(dev);
return 0;
}
static int ehci_usb_probe(struct udevice *dev)