]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - drivers/usb/common/common.c
0db281b970ef6913694c778868a5428d59c08156
1 // SPDX-License-Identifier: GPL-2.0+
3 * Provides code common for host and device side USB.
6 * Texas Instruments Incorporated, <www.ti.com>
11 #include <linux/usb/otg.h>
12 #include <linux/usb/ch9.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(ofnode node
)
28 dr_mode
= ofnode_read_string(node
, "dr_mode");
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
;
41 static const char *const speed_names
[] = {
42 [USB_SPEED_UNKNOWN
] = "UNKNOWN",
43 [USB_SPEED_LOW
] = "low-speed",
44 [USB_SPEED_FULL
] = "full-speed",
45 [USB_SPEED_HIGH
] = "high-speed",
46 [USB_SPEED_WIRELESS
] = "wireless",
47 [USB_SPEED_SUPER
] = "super-speed",
50 enum usb_device_speed
usb_get_maximum_speed(ofnode node
)
52 const char *max_speed
;
55 max_speed
= ofnode_read_string(node
, "maximum-speed");
57 pr_err("usb maximum-speed not found\n");
58 return USB_SPEED_UNKNOWN
;
61 for (i
= 0; i
< ARRAY_SIZE(speed_names
); i
++)
62 if (!strcmp(max_speed
, speed_names
[i
]))
65 return USB_SPEED_UNKNOWN
;