2 * Provides code common for host and device side USB.
5 * Texas Instruments Incorporated, <www.ti.com>
7 * SPDX-License-Identifier: GPL-2.0+
12 #include <linux/usb/otg.h>
14 DECLARE_GLOBAL_DATA_PTR;
16 static const char *const usb_dr_modes[] = {
17 [USB_DR_MODE_UNKNOWN] = "",
18 [USB_DR_MODE_HOST] = "host",
19 [USB_DR_MODE_PERIPHERAL] = "peripheral",
20 [USB_DR_MODE_OTG] = "otg",
23 enum usb_dr_mode usb_get_dr_mode(int node)
25 const void *fdt = gd->fdt_blob;
29 dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
31 error("usb dr_mode not found\n");
32 return USB_DR_MODE_UNKNOWN;
35 for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
36 if (!strcmp(dr_mode, usb_dr_modes[i]))
39 return USB_DR_MODE_UNKNOWN;