summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Jun <B47624@freescale.com>2014-09-10 17:49:33 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-23 16:42:47 +0300
commit7782d2043848546cd7dc0a7c94b628045f40835e (patch)
tree64598e082568b5817e65ac0c0556281888d9ab68
parentf68e1fc4a2a2cca20106a8614b9cc1ab3c6c5849 (diff)
MLK-11340-42 usb: chipidea: usb vbus glitch check logic change
This patch changes the vbus glitch check to cover usb otg certification case, so the possible cases of vbus rise: - USB vbus can reach AVV(4.4v), valid vbus. - USB vbus keeps above BSV(0.8v) but lower than AVV(4.4v) for more than 300ms, we think it's valid vbus event, this can meet usb otg certificataion case(B device can do connection in 1s when vbus is 4.0v). - USB vbus cannot be kept above BSV(0.8v) for more than 300ms, it's a vbus glitch. In case of vbus drop: if the vbus on flag is not set, it's a vbus glitch, otherwise it's a valid vbus drop event. Acked-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Li Jun <b47624@freescale.com> (cherry picked from commit de5ab444839b6d1492d697256ea2b8a1dcaffc62) (cherry picked from commit 83788415169cfa1555dd348a9ff03deb66b08bad)
-rw-r--r--drivers/usb/chipidea/otg.c36
-rw-r--r--drivers/usb/chipidea/otg_fsm.c4
2 files changed, 23 insertions, 17 deletions
diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c
index d8285ccce1c6..553214248a97 100644
--- a/drivers/usb/chipidea/otg.c
+++ b/drivers/usb/chipidea/otg.c
@@ -130,22 +130,27 @@ enum ci_role ci_otg_role(struct ci_hdrc *ci)
return role;
}
-#define CI_VBUS_CONNECT_TIMEOUT_MS 500
+/*
+ * Handling vbus glitch
+ * We only need to consider glitch for without usb connection,
+ * With usb connection, we consider it as real disconnection.
+ *
+ * If the vbus can't be kept above B session valid for timeout value,
+ * we think it is a vbus glitch, otherwise it's a valid vbus.
+ */
+#define CI_VBUS_CONNECT_TIMEOUT_MS 300
static int ci_is_vbus_glitch(struct ci_hdrc *ci)
{
- /*
- * Handling vbus glitch
- *
- * We only need to consider glitch for without usb connection,
- * With usb connection, we consider it as real disconnection.
- *
- * If the vbus can't higher than AVV in timeout value, we think
- * it is a vbus glitch
- */
- if (hw_wait_reg(ci, OP_OTGSC, OTGSC_AVV, OTGSC_AVV,
- CI_VBUS_CONNECT_TIMEOUT_MS)) {
- dev_warn(ci->dev, "there is a vbus glitch\n");
- return 1;
+ int i;
+
+ for (i = 0; i < CI_VBUS_CONNECT_TIMEOUT_MS/20; i++) {
+ if (hw_read_otgsc(ci, OTGSC_AVV)) {
+ return 0;
+ } else if (!hw_read_otgsc(ci, OTGSC_BSV)) {
+ dev_warn(ci->dev, "there is a vbus glitch\n");
+ return 1;
+ }
+ msleep(20);
}
return 0;
@@ -250,8 +255,7 @@ static void ci_handle_vbus_glitch(struct ci_hdrc *ci)
valid_vbus_change = true;
}
} else {
- if (ci->vbus_active || (ci_otg_is_fsm_mode(ci) &&
- ci->fsm.b_sess_vld))
+ if (ci->vbus_active && !ci_otg_is_fsm_mode(ci))
valid_vbus_change = true;
}
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c
index 294b3c264206..7d57444391f4 100644
--- a/drivers/usb/chipidea/otg_fsm.c
+++ b/drivers/usb/chipidea/otg_fsm.c
@@ -786,13 +786,15 @@ irqreturn_t ci_otg_fsm_irq(struct ci_hdrc *ci)
}
} else if (otg_int_src & OTGSC_BSVIS) {
hw_write_otgsc(ci, OTGSC_BSVIS, OTGSC_BSVIS);
- ci->vbus_glitch_check_event = true;
if (!(otgsc & OTGSC_BSV) && fsm->b_sess_vld) {
+ ci->b_sess_valid_event = true;
fsm->b_sess_vld = 0;
if (fsm->id)
ci_otg_add_timer(ci, B_SSEND_SRP);
if (fsm->b_bus_req)
fsm->b_bus_req = 0;
+ } else {
+ ci->vbus_glitch_check_event = true;
}
} else if (otg_int_src & OTGSC_AVVIS) {
hw_write_otgsc(ci, OTGSC_AVVIS, OTGSC_AVVIS);