1 // SPDX-License-Identifier: GPL-2.0+
3 * Provides code common for host and device side USB.
6 * Texas Instruments Incorporated, <www.ti.com>
10 #include <linux/libfdt.h>
11 #include <linux/usb/otg.h>
13 DECLARE_GLOBAL_DATA_PTR;
15 static const char *const usb_dr_modes[] = {
16 [USB_DR_MODE_UNKNOWN] = "",
17 [USB_DR_MODE_HOST] = "host",
18 [USB_DR_MODE_PERIPHERAL] = "peripheral",
19 [USB_DR_MODE_OTG] = "otg",
22 enum usb_dr_mode usb_get_dr_mode(int node)
24 const void *fdt = gd->fdt_blob;
28 dr_mode = fdt_getprop(fdt, node, "dr_mode", NULL);
30 pr_err("usb dr_mode not found\n");
31 return USB_DR_MODE_UNKNOWN;
34 for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++)
35 if (!strcmp(dr_mode, usb_dr_modes[i]))
38 return USB_DR_MODE_UNKNOWN;