* [U-Boot] [PATCH] usb: ehci-mx6: Use common code to extract dr_mode
@ 2019-04-03 2:45 Adam Ford
2019-04-03 11:44 ` Marek Vasut
0 siblings, 1 reply; 2+ messages in thread
From: Adam Ford @ 2019-04-03 2:45 UTC (permalink / raw)
To: u-boot
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.
Signed-off-by: Adam Ford <aford173@gmail.com>
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index 948394709f..e24f5ad14a 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -18,6 +18,7 @@
#include <dm.h>
#include <asm/mach-types.h>
#include <power/regulator.h>
+#include <linux/usb/otg.h>
#include "ehci.h"
@@ -483,23 +484,24 @@ 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_UNKNOWN:
+ return -EINVAL;
+ case USB_DR_MODE_PERIPHERAL:
+ plat->init_type = USB_INIT_DEVICE;
+ break;
+ case USB_DR_MODE_OTG:
+ return ehci_usb_phy_mode(dev);
+ };
- return ehci_usb_phy_mode(dev);
+ return 0;
}
static int ehci_usb_probe(struct udevice *dev)
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] usb: ehci-mx6: Use common code to extract dr_mode
2019-04-03 2:45 [U-Boot] [PATCH] usb: ehci-mx6: Use common code to extract dr_mode Adam Ford
@ 2019-04-03 11:44 ` Marek Vasut
0 siblings, 0 replies; 2+ messages in thread
From: Marek Vasut @ 2019-04-03 11:44 UTC (permalink / raw)
To: u-boot
On 4/3/19 4:45 AM, Adam Ford wrote:
> 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.
>
> Signed-off-by: Adam Ford <aford173@gmail.com>
>
> diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
> index 948394709f..e24f5ad14a 100644
> --- a/drivers/usb/host/ehci-mx6.c
> +++ b/drivers/usb/host/ehci-mx6.c
> @@ -18,6 +18,7 @@
> #include <dm.h>
> #include <asm/mach-types.h>
> #include <power/regulator.h>
> +#include <linux/usb/otg.h>
>
> #include "ehci.h"
>
> @@ -483,23 +484,24 @@ 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_UNKNOWN:
> + return -EINVAL;
> + case USB_DR_MODE_PERIPHERAL:
> + plat->init_type = USB_INIT_DEVICE;
> + break;
> + case USB_DR_MODE_OTG:
> + return ehci_usb_phy_mode(dev);
> + };
>
> - return ehci_usb_phy_mode(dev);
> + return 0;
> }
>
> static int ehci_usb_probe(struct udevice *dev)
>
Applied to usb/next, thanks.
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-03 11:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-03 2:45 [U-Boot] [PATCH] usb: ehci-mx6: Use common code to extract dr_mode Adam Ford
2019-04-03 11:44 ` Marek Vasut
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.