From: Mehmet Fide <mehmet.fide@gmail.com>
To: Marek Vasut <marek.vasut+usb@mailbox.org>
Cc: Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>,
Fabio Estevam <festevam@gmail.com>,
Stefan Agner <stefan@agner.ch>,
Francesco Dolcini <francesco@dolcini.it>,
u-boot@lists.u-boot-project.org, mehmet.fide@screeningeagle.com
Subject: [PATCH v7 6/9] usb: ehci-vf: use usb_get_dr_mode()
Date: Tue, 20 Oct 2026 12:16:05 +0200 [thread overview]
Message-ID: <20261020101608.2818265-7-mehmet.fide@gmail.com> (raw)
In-Reply-To: <20261020101608.2818265-1-mehmet.fide@gmail.com>
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
The driver parses the dr_mode property itself, through the flat tree,
into an enum of its own that mirrors enum usb_dr_mode. Use
usb_get_dr_mode() and USB_DR_MODE_* instead, as ehci-mx6 does. A
missing property still means host and a value the driver does not
know still fails the probe with -EINVAL.
Signed-off-by: Mehmet Fide <mehmet.fide@screeningeagle.com>
---
Notes:
Changes in v7:
- Marek's review: this patch only replaces the private enum and the
strcmp() chain; the ID detect gpio moves to the next patch
- a missing dr_mode property means host and an unknown value fails with
-EINVAL again, as before the series; v6 made an unknown value host
Changes in v6:
- new patch, from the review of the register base patch in v5: the
private enum duplicated USB_DR_MODE_*
drivers/usb/host/ehci-vf.c | 40 ++++++++++++++------------------------
1 file changed, 15 insertions(+), 25 deletions(-)
diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c
index e5f9ec0fdbb..1d7b3bdc285 100644
--- a/drivers/usb/host/ehci-vf.c
+++ b/drivers/usb/host/ehci-vf.c
@@ -21,8 +21,8 @@
#include <asm/mach-imx/regs-usbphy.h>
#include <linux/delay.h>
#include <usb/ehci-ci.h>
-#include <linux/libfdt.h>
#include <fdtdec.h>
+#include <linux/usb/otg.h>
#include "ehci.h"
@@ -150,29 +150,19 @@ int ehci_vf_common_init(struct usb_ehci *ehci, int index)
return 0;
}
-/* Possible port types (dual role mode) */
-enum dr_mode {
- DR_MODE_NONE = 0,
- DR_MODE_HOST, /* supports host operation */
- DR_MODE_DEVICE, /* supports device operation */
- DR_MODE_OTG, /* supports both */
-};
-
struct ehci_vf_priv_data {
struct ehci_ctrl ctrl;
struct usb_ehci *ehci;
struct gpio_desc cdet_gpio;
enum usb_init_type init_type;
- enum dr_mode dr_mode;
+ enum usb_dr_mode dr_mode;
u32 portnr;
};
static int vf_usb_of_to_plat(struct udevice *dev)
{
struct ehci_vf_priv_data *priv = dev_get_priv(dev);
- const void *dt_blob = gd->fdt_blob;
int node = dev_of_offset(dev);
- const char *mode;
fdt_addr_t phy_addr;
ofnode phy_node;
int i;
@@ -192,16 +182,16 @@ static int vf_usb_of_to_plat(struct udevice *dev)
priv->portnr = i;
priv->ehci = dev_read_addr_ptr(dev);
- mode = fdt_getprop(dt_blob, node, "dr_mode", NULL);
- if (mode) {
- if (0 == strcmp(mode, "host")) {
- priv->dr_mode = DR_MODE_HOST;
+ if (ofnode_read_string(dev_ofnode(dev), "dr_mode")) {
+ priv->dr_mode = usb_get_dr_mode(dev_ofnode(dev));
+ switch (priv->dr_mode) {
+ case USB_DR_MODE_HOST:
priv->init_type = USB_INIT_HOST;
- } else if (0 == strcmp(mode, "peripheral")) {
- priv->dr_mode = DR_MODE_DEVICE;
+ break;
+ case USB_DR_MODE_PERIPHERAL:
priv->init_type = USB_INIT_DEVICE;
- } else if (0 == strcmp(mode, "otg")) {
- priv->dr_mode = DR_MODE_OTG;
+ break;
+ case USB_DR_MODE_OTG:
/*
* We set init_type to device by default when OTG
* mode is requested. If a valid gpio is provided
@@ -209,17 +199,17 @@ static int vf_usb_of_to_plat(struct udevice *dev)
* of the gpio pin.
*/
priv->init_type = USB_INIT_DEVICE;
- } else {
- debug("%s: Cannot decode dr_mode '%s'\n",
- __func__, mode);
+ break;
+ default:
+ debug("%s: Cannot decode dr_mode\n", __func__);
return -EINVAL;
}
} else {
- priv->dr_mode = DR_MODE_HOST;
+ priv->dr_mode = USB_DR_MODE_HOST;
priv->init_type = USB_INIT_HOST;
}
- if (priv->dr_mode == DR_MODE_OTG) {
+ if (priv->dr_mode == USB_DR_MODE_OTG) {
gpio_request_by_name_nodev(offset_to_ofnode(node),
"fsl,cdet-gpio", 0, &priv->cdet_gpio,
GPIOD_IS_IN);
--
2.55.0
next prev parent reply other threads:[~2026-10-20 10:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 10:15 [PATCH v7 0/9] usb: ehci-vf: make the USB host port usable Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 1/9] fdtdec: match an alias to its stem only when the number follows it Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 2/9] usb: ehci-vf: take the controller index from the device tree Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 3/9] usb: ehci-vf: remove the code path for a build without DM_USB Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 4/9] usb: ehci-vf: drop the empty bind hook Mehmet Fide
2026-10-20 10:16 ` [PATCH v7 5/9] dm: core: add ofnode_get_alias_seq() Mehmet Fide
2026-10-20 10:16 ` Mehmet Fide [this message]
2026-10-21 0:09 ` [PATCH v7 6/9] usb: ehci-vf: use usb_get_dr_mode() Marek Vasut
2026-10-21 11:59 ` Mehmet Fide
2026-10-21 12:07 ` Marek Vasut
2026-10-21 12:21 ` Mehmet Fide
2026-10-21 13:17 ` Marek Vasut
2026-10-21 18:41 ` Mehmet Fide
2026-10-21 18:56 ` Marek Vasut
2026-10-20 10:16 ` [PATCH v7 7/9] usb: ehci-vf: request the ID detect gpio through the device Mehmet Fide
2026-10-21 0:10 ` Marek Vasut
2026-10-20 10:16 ` [PATCH v7 8/9] usb: ehci-vf: take the register bases from the device tree Mehmet Fide
2026-10-21 0:13 ` Marek Vasut
2026-10-20 10:16 ` [PATCH v7 9/9] usb: ehci-vf: enable the vbus supply of the port Mehmet Fide
2026-10-21 0:13 ` Marek Vasut
2026-10-21 11:59 ` Mehmet Fide
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=20261020101608.2818265-7-mehmet.fide@gmail.com \
--to=mehmet.fide@gmail.com \
--cc=festevam@gmail.com \
--cc=francesco@dolcini.it \
--cc=marek.vasut+usb@mailbox.org \
--cc=mehmet.fide@screeningeagle.com \
--cc=sjg@chromium.org \
--cc=stefan@agner.ch \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
/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.