summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Nemec <bnemec@chromium.org>2020-09-24 20:56:07 +0000
committerBrian Nemec <bnemec@chromium.org>2020-10-06 18:20:49 +0000
commita13b7c171d315405601452e63b751b77828d765a (patch)
tree332ccd4274ca3b93e3beb9d13234ced7d4001020
parent7bd7acb85ff66f57b47bd294bf53acab3fa30815 (diff)
downloadchrome-ec-a13b7c171d315405601452e63b751b77828d765a.tar.gz
Revert "ServoV4/V4p1: Change CCD detection flow"
This reverts commit 7bd7acb85ff66f57b47bd294bf53acab3fa30815. Reason for revert: b:167734179 CCD detection is failing on many devices. Tests on reverted devices show this is primary cause. Original change's description: > ServoV4/V4p1: Change CCD detection flow > > Currently, servoV4 and servoV4p1 don't apply terminations to SBU when > searching for a DUT. This means SBU can float which can break the SBU > voltage detection. Technically, the DUT should only need to pull up D+ > and can float D- since it is a FS USB2 device when in CCD mode. > > Change the detection to connect SBU to the USB2 hub on servoV4/4p1. The > USB2 hub will apply 15k pulldowns to the USB lines, which will pull SBU > down and fix detection in the case where the DUT floats SBU. > > BUG=b:161762948, b:150886157, b:151487379 > TEST=make BOARD=servo_v4; make BOARD=servo_v4p1 > TEST=check that CCD works on DUT without pulldown resistors on SBU > BRANCH=none > > Change-Id: I9b6f620617fb0e270e35804704111afd3c606a3b > Signed-off-by: Eric Herrmann <eherrmann@chromium.org> > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2352439 > Reviewed-by: Wai-Hong Tam <waihong@google.com> > (cherry picked from commit 1a09ade7b846cc048fb2f177adcacd5f836b8887) > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2389080 > Reviewed-by: Brian Nemec <bnemec@chromium.org> > Commit-Queue: Brian Nemec <bnemec@chromium.org> > Tested-by: Brian Nemec <bnemec@chromium.org> BUG=b:167734179, b:168546666, b:168548776 TEST=Measured SBU voltages with the prior CL included, observed low voltages and no-voltage on some platforms including variations of dedede under the flipped orientation. TEST=Reverted the CL and CCD detection worked reliably, devices with CCD not driving SBU rails started working, and labstation release was more reliable on prior versions. Change-Id: Ibf120ad18f25daaaa584b20dc49c12c453049979 Signed-off-by: Brian Nemec <bnemec@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2429495
-rw-r--r--board/servo_v4/board.c50
-rw-r--r--board/servo_v4p1/ccd_measure_sbu.c50
-rw-r--r--board/servo_v4p1/ioexpanders.c4
3 files changed, 52 insertions, 52 deletions
diff --git a/board/servo_v4/board.c b/board/servo_v4/board.c
index 175da87ecc..ed90054d66 100644
--- a/board/servo_v4/board.c
+++ b/board/servo_v4/board.c
@@ -366,8 +366,6 @@ static void init_ioexpander(void)
*/
i2c_write8(1, GPIOX_I2C_ADDR_FLAGS, GPIOX_DIR_PORT_A, 0x0);
i2c_write8(1, GPIOX_I2C_ADDR_FLAGS, GPIOX_DIR_PORT_B, 0x18);
- /* Write SBU_FLIP_SEL */
- write_ioexpander(0, 2, 0);
}
/*
@@ -392,27 +390,24 @@ static void ccd_measure_sbu(void)
{
int sbu1;
int sbu2;
+ int mux_en;
static int count /* = 0 */;
static int last /* = 0 */;
static int polarity /* = 0 */;
- /*
- * The SBU mux should be enabled so SBU is connected to the USB2
- * hub. The hub needs to apply its terminations to read the
- * correct SBU levels.
- */
- gpio_set_level(GPIO_SBU_MUX_EN, 1);
-
/* Read sbu voltage levels */
sbu1 = adc_read_channel(ADC_SBU1_DET);
sbu2 = adc_read_channel(ADC_SBU2_DET);
+ mux_en = gpio_get_level(GPIO_SBU_MUX_EN);
/*
- * Poll the SBU lines to check if an idling, unconfigured USB device is
- * present. USB FS pulls one line high for connect request. If so, and
- * it persists for 500ms, we'll enable the SuzyQ in that orientation.
+ * While SBU_MUX is disabled (SuzyQ unplugged), we'll poll the SBU lines
+ * to check if an idling, unconfigured USB device is present.
+ * USB FS pulls one line high for connect request.
+ * If so, and it persists for 500ms, we'll enable the SuzyQ in that
+ * orientation.
*/
- if ((sbu1 > USB_HIGH_MV) && (sbu2 < GND_MAX_MV)) {
+ if ((!mux_en) && (sbu1 > USB_HIGH_MV) && (sbu2 < GND_MAX_MV)) {
/* Check flip connection polarity. */
if (last != MODE_SBU_FLIP) {
last = MODE_SBU_FLIP;
@@ -421,7 +416,7 @@ static void ccd_measure_sbu(void)
} else {
count++;
}
- } else if ((sbu2 > USB_HIGH_MV) && (sbu1 < GND_MAX_MV)) {
+ } else if ((!mux_en) && (sbu2 > USB_HIGH_MV) && (sbu1 < GND_MAX_MV)) {
/* Check direct connection polarity. */
if (last != MODE_SBU_CONNECT) {
last = MODE_SBU_CONNECT;
@@ -431,14 +426,12 @@ static void ccd_measure_sbu(void)
count++;
}
/*
- * If SuzyQ is enabled, we'll poll for a persistent no-signal
- * for 500ms. We may see GND/GND while passing data since the
- * ADC's don't sample simultaneously, so there needs to be a
- * deglitch to not falsely detect a disconnect. If disconnected,
- * take no action. We need to keep the mux enabled to detect
- * another device.
+ * If SuzyQ is enabled, we'll poll for a persistent no-signal for
+ * 500ms. Since USB is differential, we should never see GND/GND
+ * while the device is connected.
+ * If disconnected, electrically remove SuzyQ.
*/
- } else if ((sbu1 < GND_MAX_MV) && (sbu2 < GND_MAX_MV)) {
+ } else if ((mux_en) && (sbu1 < GND_MAX_MV) && (sbu2 < GND_MAX_MV)) {
/* Check for SBU disconnect if connected. */
if (last != MODE_SBU_DISCONNECT) {
last = MODE_SBU_DISCONNECT;
@@ -456,24 +449,31 @@ static void ccd_measure_sbu(void)
* We have seen a new state continuously for 500ms.
* Let's update the mux to enable/disable SuzyQ appropriately.
*/
- if (count == 50) {
- if (last == MODE_SBU_DISCONNECT) {
+ if (count > 5) {
+ if (mux_en) {
+ /* Disable mux as it's disconnected now. */
+ gpio_set_level(GPIO_SBU_MUX_EN, 0);
+ msleep(10);
CPRINTS("CCD: disconnected.");
} else {
/* SBU flip = polarity */
write_ioexpander(0, 2, polarity);
+ gpio_set_level(GPIO_SBU_MUX_EN, 1);
+ msleep(10);
CPRINTS("CCD: connected %s",
polarity ? "flip" : "noflip");
}
}
- /* Measure every 10ms, forever. */
- hook_call_deferred(&ccd_measure_sbu_data, 10 * MSEC);
+
+ /* Measure every 100ms, forever. */
+ hook_call_deferred(&ccd_measure_sbu_data, 100 * MSEC);
}
void ext_hpd_detection_enable(int enable)
{
if (enable) {
timestamp_t now = get_time();
+
hpd_prev_level = gpio_get_level(GPIO_DP_HPD);
hpd_prev_ts = now.val;
gpio_enable_interrupt(GPIO_DP_HPD);
diff --git a/board/servo_v4p1/ccd_measure_sbu.c b/board/servo_v4p1/ccd_measure_sbu.c
index 42ab4a5d52..b9c9680cc9 100644
--- a/board/servo_v4p1/ccd_measure_sbu.c
+++ b/board/servo_v4p1/ccd_measure_sbu.c
@@ -36,27 +36,24 @@ static void ccd_measure_sbu(void)
{
int sbu1;
int sbu2;
+ int mux_en;
static int count /* = 0 */;
static int last /* = 0 */;
static int polarity /* = 0 */;
- /*
- * The SBU mux should be enabled so SBU is connected to the USB2
- * hub. The hub needs to apply its terminations to read the
- * correct SBU levels.
- */
- gpio_set_level(GPIO_SBU_MUX_EN, 1);
-
/* Read sbu voltage levels */
sbu1 = adc_read_channel(ADC_SBU1_DET);
sbu2 = adc_read_channel(ADC_SBU2_DET);
+ mux_en = gpio_get_level(GPIO_SBU_MUX_EN);
/*
- * Poll the SBU lines to check if an idling, unconfigured USB device is
- * present. USB FS pulls one line high for connect request. If so, and
- * it persists for 500ms, we'll enable the SuzyQ in that orientation.
+ * While SBU_MUX is disabled (SuzyQ unplugged), we'll poll the SBU lines
+ * to check if an idling, unconfigured USB device is present.
+ * USB FS pulls one line high for connect request.
+ * If so, and it persists for 500ms, we'll enable the SuzyQ in that
+ * orientation.
*/
- if ((sbu1 > USB_HIGH_MV) && (sbu2 < GND_MAX_MV)) {
+ if ((!mux_en) && (sbu1 > USB_HIGH_MV) && (sbu2 < GND_MAX_MV)) {
/* Check flip connection polarity. */
if (last != MODE_SBU_FLIP) {
last = MODE_SBU_FLIP;
@@ -65,7 +62,7 @@ static void ccd_measure_sbu(void)
} else {
count++;
}
- } else if ((sbu2 > USB_HIGH_MV) && (sbu1 < GND_MAX_MV)) {
+ } else if ((!mux_en) && (sbu2 > USB_HIGH_MV) && (sbu1 < GND_MAX_MV)) {
/* Check direct connection polarity. */
if (last != MODE_SBU_CONNECT) {
last = MODE_SBU_CONNECT;
@@ -74,15 +71,13 @@ static void ccd_measure_sbu(void)
} else {
count++;
}
- /*
- * If SuzyQ is enabled, we'll poll for a persistent no-signal
- * for 500ms. We may see GND/GND while passing data since the
- * ADC's don't sample simultaneously, so there needs to be a
- * deglitch to not falsely detect a disconnect. If disconnected,
- * take no action. We need to keep the mux enabled to detect
- * another device.
- */
- } else if ((sbu1 < GND_MAX_MV) && (sbu2 < GND_MAX_MV)) {
+ /*
+ * If SuzyQ is enabled, we'll poll for a persistent no-signal
+ * for 500ms. Since USB is differential, we should never see
+ * GND/GND while the device is connected.
+ * If disconnected, electrically remove SuzyQ.
+ */
+ } else if ((mux_en) && (sbu1 < GND_MAX_MV) && (sbu2 < GND_MAX_MV)) {
/* Check for SBU disconnect if connected. */
if (last != MODE_SBU_DISCONNECT) {
last = MODE_SBU_DISCONNECT;
@@ -100,19 +95,24 @@ static void ccd_measure_sbu(void)
* We have seen a new state continuously for 500ms.
* Let's update the mux to enable/disable SuzyQ appropriately.
*/
- if (count == 50) {
- if (last == MODE_SBU_DISCONNECT) {
+ if (count > 5) {
+ if (mux_en) {
+ /* Disable mux as it's disconnected now. */
+ gpio_set_level(GPIO_SBU_MUX_EN, 0);
+ msleep(10);
CPRINTS("CCD: disconnected.");
} else {
/* SBU flip = polarity */
sbu_flip_sel(polarity);
+ gpio_set_level(GPIO_SBU_MUX_EN, 1);
+ msleep(10);
CPRINTS("CCD: connected %s",
polarity ? "flip" : "noflip");
}
}
- /* Measure every 10ms, forever. */
- hook_call_deferred(&ccd_measure_sbu_data, 10 * MSEC);
+ /* Measure every 100ms, forever. */
+ hook_call_deferred(&ccd_measure_sbu_data, 100 * MSEC);
}
void ccd_enable(int enable)
diff --git a/board/servo_v4p1/ioexpanders.c b/board/servo_v4p1/ioexpanders.c
index 9c88d7a2d0..6617a8d30e 100644
--- a/board/servo_v4p1/ioexpanders.c
+++ b/board/servo_v4p1/ioexpanders.c
@@ -26,14 +26,14 @@ int init_ioexpanders(void)
* -------------------------------------------------
* BIT-0 (SBU_UART_SEL) | O | 0
* BIT-1 (ATMEL_RESET_L) | O | 0
- * BIT-2 (SBU_FLIP_SEL) | O | 0
+ * BIT-2 (SBU_FLIP_SEL) | O | 1
* BIT-3 (USB3_A0_MUX_SEL) | O | 0
* BIT-4 (USB3_A0_MUX_EN_L) | O | 0
* BIT-5 (USB3_A0_PWR_EN) | O | 0
* BIT-6 (UART_18_SEL) | O | 0
* BIT-7 (USERVO_POWER_EN) | O | 0
*/
- ret = tca6416a_write_byte(1, TCA6416A_OUT_PORT_0, 0x00);
+ ret = tca6416a_write_byte(1, TCA6416A_OUT_PORT_0, 0x04);
if (ret != EC_SUCCESS)
return ret;