summaryrefslogtreecommitdiff
path: root/board/servo_v4p1/ccd_measure_sbu.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /board/servo_v4p1/ccd_measure_sbu.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-factory-brya-14517.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'board/servo_v4p1/ccd_measure_sbu.c')
-rw-r--r--board/servo_v4p1/ccd_measure_sbu.c131
1 files changed, 0 insertions, 131 deletions
diff --git a/board/servo_v4p1/ccd_measure_sbu.c b/board/servo_v4p1/ccd_measure_sbu.c
deleted file mode 100644
index b9c9680cc9..0000000000
--- a/board/servo_v4p1/ccd_measure_sbu.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-/* CCD Measure SBU */
-
-#include "adc.h"
-#include "console.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "ioexpanders.h"
-#include "timer.h"
-
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args)
-
-/*
- * Define voltage thresholds for SBU USB detection.
- *
- * Max observed USB low across sampled systems: 666mV
- * Min observed USB high across sampled systems: 3026mV
- */
-#define GND_MAX_MV 700
-#define USB_HIGH_MV 2500
-#define SBU_DIRECT 0
-#define SBU_FLIP 1
-
-#define MODE_SBU_DISCONNECT 0
-#define MODE_SBU_CONNECT 1
-#define MODE_SBU_FLIP 2
-#define MODE_SBU_OTHER 3
-
-static void ccd_measure_sbu(void);
-DECLARE_DEFERRED(ccd_measure_sbu);
-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 */;
-
- /* 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);
-
- /*
- * 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 ((!mux_en) && (sbu1 > USB_HIGH_MV) && (sbu2 < GND_MAX_MV)) {
- /* Check flip connection polarity. */
- if (last != MODE_SBU_FLIP) {
- last = MODE_SBU_FLIP;
- polarity = SBU_FLIP;
- count = 0;
- } else {
- count++;
- }
- } 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;
- polarity = SBU_DIRECT;
- count = 0;
- } else {
- count++;
- }
- /*
- * 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;
- count = 0;
- } else {
- count++;
- }
- } else {
- /* Didn't find anything, reset state. */
- last = MODE_SBU_OTHER;
- count = 0;
- }
-
- /*
- * We have seen a new state continuously for 500ms.
- * Let's update the mux to enable/disable SuzyQ appropriately.
- */
- 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 100ms, forever. */
- hook_call_deferred(&ccd_measure_sbu_data, 100 * MSEC);
-}
-
-void ccd_enable(int enable)
-{
- if (enable) {
- hook_call_deferred(&ccd_measure_sbu_data, 0);
- } else {
- gpio_set_level(GPIO_SBU_MUX_EN, 0);
- hook_call_deferred(&ccd_measure_sbu_data, -1);
- }
-}
-
-void start_ccd_meas_sbu_cycle(void)
-{
- hook_call_deferred(&ccd_measure_sbu_data, 1000 * MSEC);
-}