summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLi Jun <jun.li@freescale.com>2015-06-17 16:34:25 +0800
committerLi Jun <jun.li@freescale.com>2015-07-07 11:18:30 +0800
commit0fc1c9fa52cfad6474667c3ef6cad9b2f00b8960 (patch)
treebca9d386162613bcd85f5afb6f8e3fc93ae7af61 /drivers
parent75b44bb302486c07636c3b00ba4b1226d785cd6f (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')
-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");