+/* used for product vbus power control, SDK not need.
+ * If dwc_otg is host mode, enable vbus power.
+ * If dwc_otg is device mode, disable vbus power.
+ * return 1 - host mode, 0 - device mode.
+ */
+int dwc_otg_usb_state(void)
+{
+ dwc_otg_device_t *otg_dev = g_otgdev;
+
+ if (otg_dev) {
+ /* op_state is A_HOST */
+ if (1 == otg_dev->core_if->op_state)
+ return 1;
+ /* op_state is B_PERIPHERAL */
+ else if (4 == otg_dev->core_if->op_state)
+ return 0;
+ else
+ return 0;
+ } else {
+ DWC_WARN("g_otgdev is NULL, maybe otg probe is failed!\n");
+ return 0;
+ }
+}
+EXPORT_SYMBOL(dwc_otg_usb_state);
+
+static ssize_t dwc_otg_op_state_show(struct device_driver *_drv, char *_buf)
+{
+ dwc_otg_device_t *otg_dev = g_otgdev;
+
+ if (otg_dev) {
+ return sprintf(_buf, "%d\n", otg_dev->core_if->op_state);
+ } else {
+ return sprintf(_buf, "%d\n", 0);
+ }
+}
+static DRIVER_ATTR(op_state, S_IRUGO, dwc_otg_op_state_show, NULL);
+