From e14d0b2575e5a1884ceaf123f1fcf4a157ba4c01 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Sat, 15 Jun 2019 08:20:51 -0600 Subject: [PATCH] Revert "drivers/usbmisc/fusb303.c: Toggle enable bit off/on after detaching". This reverts unnecessary workaround for FUSB303 from commit ddcc6dd501674a2457c34d7633cb179915182abb, as true source of bug we've seen is after all in a wrong way device was being powered in R&D. --- drivers/usbmisc/fusb303.c | 65 +++------------------------------------ 1 file changed, 4 insertions(+), 61 deletions(-) diff --git a/drivers/usbmisc/fusb303.c b/drivers/usbmisc/fusb303.c index b66432fe34..cb2e14ea15 100644 --- a/drivers/usbmisc/fusb303.c +++ b/drivers/usbmisc/fusb303.c @@ -503,51 +503,6 @@ err_out: return ret; } -/**************************************************************************** - * Name: fusb303_toggle_control1_enable - * - * Description: - * Switch enable flag off and then on. - * - ****************************************************************************/ - -static int fusb303_toggle_control1_enable(FAR struct fusb303_dev_s *priv) -{ - int regval; - int ret; - - regval = fusb303_getreg(priv, FUSB303_CONTROL1_REG); - if (regval < 0) - { - fusb303_err("ERROR: Failed to read CONTROL1 register\n"); - return -1; - } - - if (!(regval & CONTROL1_ENABLE)) - { - /* Not enabled, skip toggling. */ - - return 0; - } - - ret = fusb303_putreg(priv, FUSB303_CONTROL1_REG, - regval & ~CONTROL1_ENABLE); - if (ret < 0) - { - fusb303_err("ERROR: Failed to write CONTROL1 register\n"); - return -1; - } - - ret = fusb303_putreg(priv, FUSB303_CONTROL1_REG, regval); - if (ret < 0) - { - fusb303_err("ERROR: Failed to write CONTROL1 register\n"); - return -1; - } - - return 0; -} - /**************************************************************************** * Name: fusb303_set_mode * @@ -776,6 +731,10 @@ static ssize_t fusb303_read(FAR struct file *filep, FAR char *buffer, return ret; } + flags = enter_critical_section(); + priv->int_pending = false; + leave_critical_section(flags); + ptr->status = fusb303_getreg(priv, FUSB303_STATUS_REG); ptr->status1 = fusb303_getreg(priv, FUSB303_STATUS1_REG); ptr->dev_type = fusb303_getreg(priv, FUSB303_TYPE_REG); @@ -784,22 +743,6 @@ static ssize_t fusb303_read(FAR struct file *filep, FAR char *buffer, fusb303_dumpregs("fusb303_read", priv); #endif - if (!(ptr->status & STATUS_ATTACH) || - (ptr->status & STATUS_BC_LVL_3000) == STATUS_BC_LVL_UNATT) - { - /* Toggle enable bit when USB is not attached. This is needed to - * enable attach interrupt when orientation of USB-C cable changes. - */ - - (void)fusb303_toggle_control1_enable(priv); - - up_mdelay(1); /* Wait for initial interrupt. */ - } - - flags = enter_critical_section(); - priv->int_pending = false; - leave_critical_section(flags); - (void)fusb303_clear_interrupts(priv); nxsem_post(&priv->devsem);