aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/common/common.c
diff options
context:
space:
mode:
authorLi Jun <jun.li@freescale.com>2015-07-09 03:18:44 -0400
committerFelipe Balbi <balbi@ti.com>2015-07-29 10:59:21 -0400
commit929412d94f2b75fe2a662afa2977bfb6a233c1c3 (patch)
tree308458c63b28530f698017ef2c13159a6fda1cd9 /drivers/usb/common/common.c
parentb5513dede7c90ba2370ab5eb547568a22991907b (diff)
usb: common: add API to update usb otg capabilities by device tree
Check property of usb hardware to update otg version and disable SRP, HNP and ADP if its disable flag is present. Reviewed-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Li Jun <jun.li@freescale.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/common/common.c')
-rw-r--r--drivers/usb/common/common.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c
index b530fd403ffb..9e39286a4e5a 100644
--- a/drivers/usb/common/common.c
+++ b/drivers/usb/common/common.c
@@ -154,6 +154,62 @@ bool of_usb_host_tpl_support(struct device_node *np)
154 return false; 154 return false;
155} 155}
156EXPORT_SYMBOL_GPL(of_usb_host_tpl_support); 156EXPORT_SYMBOL_GPL(of_usb_host_tpl_support);
157
158/**
159 * of_usb_update_otg_caps - to update usb otg capabilities according to
160 * the passed properties in DT.
161 * @np: Pointer to the given device_node
162 * @otg_caps: Pointer to the target usb_otg_caps to be set
163 *
164 * The function updates the otg capabilities
165 */
166int of_usb_update_otg_caps(struct device_node *np,
167 struct usb_otg_caps *otg_caps)
168{
169 u32 otg_rev;
170
171 if (!otg_caps)
172 return -EINVAL;
173
174 if (!of_property_read_u32(np, "otg-rev", &otg_rev)) {
175 switch (otg_rev) {
176 case 0x0100:
177 case 0x0120:
178 case 0x0130:
179 case 0x0200:
180 /* Choose the lesser one if it's already been set */
181 if (otg_caps->otg_rev)
182 otg_caps->otg_rev = min_t(u16, otg_rev,
183 otg_caps->otg_rev);
184 else
185 otg_caps->otg_rev = otg_rev;
186 break;
187 default:
188 pr_err("%s: unsupported otg-rev: 0x%x\n",
189 np->full_name, otg_rev);
190 return -EINVAL;
191 }
192 } else {
193 /*
194 * otg-rev is mandatory for otg properties, if not passed
195 * we set it to be 0 and assume it's a legacy otg device.
196 * Non-dt platform can set it afterwards.
197 */
198 otg_caps->otg_rev = 0;
199 }
200
201 if (of_find_property(np, "hnp-disable", NULL))
202 otg_caps->hnp_support = false;
203 if (of_find_property(np, "srp-disable", NULL))
204 otg_caps->srp_support = false;
205 if (of_find_property(np, "adp-disable", NULL) ||
206 (otg_caps->otg_rev < 0x0200))
207 otg_caps->adp_support = false;
208
209 return 0;
210}
211EXPORT_SYMBOL_GPL(of_usb_update_otg_caps);
212
157#endif 213#endif
158 214
159MODULE_LICENSE("GPL"); 215MODULE_LICENSE("GPL");