diff options
author | Michal Sojka <sojka@merica.cz> | 2014-09-24 16:43:20 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-09-25 11:02:34 -0400 |
commit | aa923ef1aa39473b7d1f413c73a3e1d19ebde65d (patch) | |
tree | e03d639690a0692d3461b32c057b2e746d9e3d76 /drivers/usb/common/usb-common.c | |
parent | 304f7e5e1d08fa2f5674c1323bd0ebd806c86b81 (diff) |
usb: Rename usb-common.c
In the next commit, we will want the usb-common module to be composed of
two object files. Since Kbuild cannot "append" another object to an
existing one, we need to rename usb-common.c to something
else (common.c) and create usb-common.o by linking the wanted objects
together. Currently, usb-common.o comprises only common.o.
Signed-off-by: Michal Sojka <sojka@merica.cz>
Acked-by: Felipe Balbi <balbi@ti.com>
Tested-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/common/usb-common.c')
-rw-r--r-- | drivers/usb/common/usb-common.c | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/drivers/usb/common/usb-common.c b/drivers/usb/common/usb-common.c deleted file mode 100644 index b530fd403ffb..000000000000 --- a/drivers/usb/common/usb-common.c +++ /dev/null | |||
@@ -1,159 +0,0 @@ | |||
1 | /* | ||
2 | * Provides code common for host and device side USB. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation, version 2. | ||
7 | * | ||
8 | * If either host side (ie. CONFIG_USB=y) or device side USB stack | ||
9 | * (ie. CONFIG_USB_GADGET=y) is compiled in the kernel, this module is | ||
10 | * compiled-in as well. Otherwise, if either of the two stacks is | ||
11 | * compiled as module, this file is compiled as module as well. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/of.h> | ||
17 | #include <linux/usb/ch9.h> | ||
18 | #include <linux/usb/of.h> | ||
19 | #include <linux/usb/otg.h> | ||
20 | |||
21 | const char *usb_otg_state_string(enum usb_otg_state state) | ||
22 | { | ||
23 | static const char *const names[] = { | ||
24 | [OTG_STATE_A_IDLE] = "a_idle", | ||
25 | [OTG_STATE_A_WAIT_VRISE] = "a_wait_vrise", | ||
26 | [OTG_STATE_A_WAIT_BCON] = "a_wait_bcon", | ||
27 | [OTG_STATE_A_HOST] = "a_host", | ||
28 | [OTG_STATE_A_SUSPEND] = "a_suspend", | ||
29 | [OTG_STATE_A_PERIPHERAL] = "a_peripheral", | ||
30 | [OTG_STATE_A_WAIT_VFALL] = "a_wait_vfall", | ||
31 | [OTG_STATE_A_VBUS_ERR] = "a_vbus_err", | ||
32 | [OTG_STATE_B_IDLE] = "b_idle", | ||
33 | [OTG_STATE_B_SRP_INIT] = "b_srp_init", | ||
34 | [OTG_STATE_B_PERIPHERAL] = "b_peripheral", | ||
35 | [OTG_STATE_B_WAIT_ACON] = "b_wait_acon", | ||
36 | [OTG_STATE_B_HOST] = "b_host", | ||
37 | }; | ||
38 | |||
39 | if (state < 0 || state >= ARRAY_SIZE(names)) | ||
40 | return "UNDEFINED"; | ||
41 | |||
42 | return names[state]; | ||
43 | } | ||
44 | EXPORT_SYMBOL_GPL(usb_otg_state_string); | ||
45 | |||
46 | static const char *const speed_names[] = { | ||
47 | [USB_SPEED_UNKNOWN] = "UNKNOWN", | ||
48 | [USB_SPEED_LOW] = "low-speed", | ||
49 | [USB_SPEED_FULL] = "full-speed", | ||
50 | [USB_SPEED_HIGH] = "high-speed", | ||
51 | [USB_SPEED_WIRELESS] = "wireless", | ||
52 | [USB_SPEED_SUPER] = "super-speed", | ||
53 | }; | ||
54 | |||
55 | const char *usb_speed_string(enum usb_device_speed speed) | ||
56 | { | ||
57 | if (speed < 0 || speed >= ARRAY_SIZE(speed_names)) | ||
58 | speed = USB_SPEED_UNKNOWN; | ||
59 | return speed_names[speed]; | ||
60 | } | ||
61 | EXPORT_SYMBOL_GPL(usb_speed_string); | ||
62 | |||
63 | const char *usb_state_string(enum usb_device_state state) | ||
64 | { | ||
65 | static const char *const names[] = { | ||
66 | [USB_STATE_NOTATTACHED] = "not attached", | ||
67 | [USB_STATE_ATTACHED] = "attached", | ||
68 | [USB_STATE_POWERED] = "powered", | ||
69 | [USB_STATE_RECONNECTING] = "reconnecting", | ||
70 | [USB_STATE_UNAUTHENTICATED] = "unauthenticated", | ||
71 | [USB_STATE_DEFAULT] = "default", | ||
72 | [USB_STATE_ADDRESS] = "addressed", | ||
73 | [USB_STATE_CONFIGURED] = "configured", | ||
74 | [USB_STATE_SUSPENDED] = "suspended", | ||
75 | }; | ||
76 | |||
77 | if (state < 0 || state >= ARRAY_SIZE(names)) | ||
78 | return "UNKNOWN"; | ||
79 | |||
80 | return names[state]; | ||
81 | } | ||
82 | EXPORT_SYMBOL_GPL(usb_state_string); | ||
83 | |||
84 | #ifdef CONFIG_OF | ||
85 | static const char *const usb_dr_modes[] = { | ||
86 | [USB_DR_MODE_UNKNOWN] = "", | ||
87 | [USB_DR_MODE_HOST] = "host", | ||
88 | [USB_DR_MODE_PERIPHERAL] = "peripheral", | ||
89 | [USB_DR_MODE_OTG] = "otg", | ||
90 | }; | ||
91 | |||
92 | /** | ||
93 | * of_usb_get_dr_mode - Get dual role mode for given device_node | ||
94 | * @np: Pointer to the given device_node | ||
95 | * | ||
96 | * The function gets phy interface string from property 'dr_mode', | ||
97 | * and returns the correspondig enum usb_dr_mode | ||
98 | */ | ||
99 | enum usb_dr_mode of_usb_get_dr_mode(struct device_node *np) | ||
100 | { | ||
101 | const char *dr_mode; | ||
102 | int err, i; | ||
103 | |||
104 | err = of_property_read_string(np, "dr_mode", &dr_mode); | ||
105 | if (err < 0) | ||
106 | return USB_DR_MODE_UNKNOWN; | ||
107 | |||
108 | for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++) | ||
109 | if (!strcmp(dr_mode, usb_dr_modes[i])) | ||
110 | return i; | ||
111 | |||
112 | return USB_DR_MODE_UNKNOWN; | ||
113 | } | ||
114 | EXPORT_SYMBOL_GPL(of_usb_get_dr_mode); | ||
115 | |||
116 | /** | ||
117 | * of_usb_get_maximum_speed - Get maximum requested speed for a given USB | ||
118 | * controller. | ||
119 | * @np: Pointer to the given device_node | ||
120 | * | ||
121 | * The function gets the maximum speed string from property "maximum-speed", | ||
122 | * and returns the corresponding enum usb_device_speed. | ||
123 | */ | ||
124 | enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np) | ||
125 | { | ||
126 | const char *maximum_speed; | ||
127 | int err; | ||
128 | int i; | ||
129 | |||
130 | err = of_property_read_string(np, "maximum-speed", &maximum_speed); | ||
131 | if (err < 0) | ||
132 | return USB_SPEED_UNKNOWN; | ||
133 | |||
134 | for (i = 0; i < ARRAY_SIZE(speed_names); i++) | ||
135 | if (strcmp(maximum_speed, speed_names[i]) == 0) | ||
136 | return i; | ||
137 | |||
138 | return USB_SPEED_UNKNOWN; | ||
139 | } | ||
140 | EXPORT_SYMBOL_GPL(of_usb_get_maximum_speed); | ||
141 | |||
142 | /** | ||
143 | * of_usb_host_tpl_support - to get if Targeted Peripheral List is supported | ||
144 | * for given targeted hosts (non-PC hosts) | ||
145 | * @np: Pointer to the given device_node | ||
146 | * | ||
147 | * The function gets if the targeted hosts support TPL or not | ||
148 | */ | ||
149 | bool of_usb_host_tpl_support(struct device_node *np) | ||
150 | { | ||
151 | if (of_find_property(np, "tpl-support", NULL)) | ||
152 | return true; | ||
153 | |||
154 | return false; | ||
155 | } | ||
156 | EXPORT_SYMBOL_GPL(of_usb_host_tpl_support); | ||
157 | #endif | ||
158 | |||
159 | MODULE_LICENSE("GPL"); | ||