summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorLi Jun <jun.li@freescale.com>2015-06-17 16:34:25 +0800
committerNitin Garg <nitin.garg@freescale.com>2015-09-17 09:23:51 -0500
commit9168a980005e3370207079aff5ae4fdca89be142 (patch)
tree80e7c93e9a03c4ebe2f35296a047b86e73304b4e /drivers/usb
parentc8bbb07194ba64f8b05d9bc2ab7aea98304c1983 (diff)
MLK-11123-7 usb: common: add API to set otg features by device tree
Check property of usb hardware to get otg version and if SRP, HNP and ADP are disabled. Signed-off-by: Li Jun <jun.li@freescale.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/common/usb-common.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/usb/common/usb-common.c b/drivers/usb/common/usb-common.c
index f3ebcc99bb7e..c56b883e34c4 100644
--- a/drivers/usb/common/usb-common.c
+++ b/drivers/usb/common/usb-common.c
@@ -169,6 +169,34 @@ bool of_usb_otg_adp_support(struct device_node *np)
return false;
}
EXPORT_SYMBOL_GPL(of_usb_otg_adp_support);
+
+/**
+ * of_usb_set_otg_caps - to set usb otg capabilities according to
+ * the passed properties in DT.
+ * @np: Pointer to the given device_node
+ * @otg_caps: Pointer to the target usb_otg_caps to be set
+ *
+ * The function gets and sets the otg capabilities
+ */
+void of_usb_set_otg_caps(struct device_node *np, struct usb_otg_caps *otg_caps)
+{
+ u32 otg_rev;
+
+ if (!otg_caps)
+ return;
+
+ if (!of_property_read_u32(np, "otg-rev", &otg_rev))
+ otg_caps->otg_rev = otg_rev;
+ if (of_find_property(np, "hnp-disable", NULL))
+ otg_caps->hnp_support = false;
+ if (of_find_property(np, "srp-disable", NULL))
+ otg_caps->srp_support = false;
+ if (of_find_property(np, "adp-disable", NULL) ||
+ (otg_caps->otg_rev < 0x0200))
+ otg_caps->adp_support = false;
+}
+EXPORT_SYMBOL_GPL(of_usb_set_otg_caps);
+
#endif
MODULE_LICENSE("GPL");