nautilus: remove base-related code.

BUG=b:69389497
BRANCH=none
TEST=build/flash on nautilus. Check boot.

Change-Id: I02677109a99f57e48a62355e82ca31c8445b6849
Signed-off-by: Jongpil Jung <jongpil19.jung@samsung.com>
Reviewed-on: https://chromium-review.googlesource.com/781261
Reviewed-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
Jongpil Jung
2017-11-21 23:06:46 +09:00
committed by chrome-bot
parent 47ecc094df
commit 6834e2bfaf
2 changed files with 0 additions and 173 deletions

View File

@@ -107,177 +107,6 @@ void usb1_evt(enum gpio_signal signal)
task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12, 0);
}
/*
* Base detection and debouncing
*
* TODO(b/35585396): Fine-tune these values.
*/
#define BASE_DETECT_DEBOUNCE_US (20 * MSEC)
/*
* rev0: Lid has 100K pull-up, base has 5.1K pull-down, so the ADC
* value should be around 5.1/(100+5.1)*3300 = 160.
* >=rev1: Lid has 604K pull-up, base has 30.1K pull-down, so the
* ADC value should be around 30.1/(604+30.1)*3300 = 156
*
* We add a significant marging on the maximum value, due to noise on the line,
* especially when PWM is active. See b/64193554 for details.
*/
#define BASE_DETECT_MIN_MV 120
#define BASE_DETECT_MAX_MV 300
/*
* When the base is connected in reverse, it presents a 100K pull-down,
* so the ADC value should be around 100/(604+100)*3300 = 469
*
* TODO(b:64370797): Do something with these values.
*/
#define BASE_DETECT_REVERSE_MIN_MV 450
#define BASE_DETECT_REVERSE_MAX_MV 500
/*
* Base EC pulses detection pin for 500 us to signal out of band USB wake (that
* can be used to wake system from deep S3).
*/
#define BASE_DETECT_PULSE_MIN_US 400
#define BASE_DETECT_PULSE_MAX_US 650
static uint64_t base_detect_debounce_time;
static void base_detect_deferred(void);
DECLARE_DEFERRED(base_detect_deferred);
enum base_status {
BASE_UNKNOWN = 0,
BASE_DISCONNECTED = 1,
BASE_CONNECTED = 2,
};
static enum base_status current_base_status;
/*
* This function is called whenever there is a change in the base detect
* status. Actions taken include:
* 1. Change in power to base
* 2. Indicate mode change to host.
* 3. Indicate tablet mode to host. Current assumption is that if base is
* disconnected then the system is in tablet mode, else if the base is
* connected, then the system is not in tablet mode.
*/
static void base_detect_change(enum base_status status)
{
int connected = (status == BASE_CONNECTED);
if (current_base_status == status)
return;
CPRINTS("Base %sconnected", connected ? "" : "not ");
gpio_set_level(GPIO_PP3300_DX_BASE, connected);
host_set_single_event(EC_HOST_EVENT_MODE_CHANGE);
tablet_set_mode(!connected);
current_base_status = status;
}
/* Measure detection pin pulse duration (used to wake AP from deep S3). */
static uint64_t pulse_start;
static uint32_t pulse_width;
static int command_attach_base(int argc, char **argv)
{
host_set_single_event(EC_HOST_EVENT_MODE_CHANGE);
tablet_set_mode(0);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(attachbase, command_attach_base,
NULL, "Simulate attach base");
static int command_detach_base(int argc, char **argv)
{
host_set_single_event(EC_HOST_EVENT_MODE_CHANGE);
tablet_set_mode(1);
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(detachbase, command_detach_base,
NULL, "Simulate detach base");
static void base_detect_deferred(void)
{
uint64_t time_now = get_time().val;
int v;
uint32_t tmp_pulse_width = pulse_width;
if (base_detect_debounce_time > time_now) {
hook_call_deferred(&base_detect_deferred_data,
base_detect_debounce_time - time_now);
return;
}
v = adc_read_channel(ADC_BASE_DET);
if (v == ADC_READ_ERROR)
return;
CPRINTS("%s = %d (pulse %d)", adc_channels[ADC_BASE_DET].name,
v, tmp_pulse_width);
if (v >= BASE_DETECT_MIN_MV && v <= BASE_DETECT_MAX_MV) {
if (current_base_status != BASE_CONNECTED) {
base_detect_change(BASE_CONNECTED);
} else if (tmp_pulse_width >= BASE_DETECT_PULSE_MIN_US &&
tmp_pulse_width <= BASE_DETECT_PULSE_MAX_US) {
CPRINTS("Sending event to AP");
host_set_single_event(EC_HOST_EVENT_KEY_PRESSED);
}
} else {
/*
* TODO(b/35585396): Figure out what to do with
* other ADC values that do not clearly indicate base
* presence or absence.
*/
base_detect_change(BASE_DISCONNECTED);
}
}
static inline int detect_pin_connected(enum gpio_signal det_pin)
{
return gpio_get_level(det_pin) == 0;
}
void base_detect_interrupt(enum gpio_signal signal)
{
uint64_t time_now = get_time().val;
if (base_detect_debounce_time <= time_now) {
/*
* Detect and measure detection pin pulse, when base is
* connected. Only a single pulse is measured over a debounce
* period. If no pulse, or multiple pulses are detected,
* pulse_width is set to 0.
*/
if (current_base_status == BASE_CONNECTED &&
!detect_pin_connected(signal)) {
pulse_start = time_now;
} else {
pulse_start = 0;
}
pulse_width = 0;
hook_call_deferred(&base_detect_deferred_data,
BASE_DETECT_DEBOUNCE_US);
} else {
if (current_base_status == BASE_CONNECTED &&
detect_pin_connected(signal) && !pulse_width &&
pulse_start) {
/* First pulse within period. */
pulse_width = time_now - pulse_start;
} else {
pulse_start = 0;
pulse_width = 0;
}
}
base_detect_debounce_time = time_now + BASE_DETECT_DEBOUNCE_US;
}
#include "gpio_list.h"
/* power signal list. Must match order of enum power_signal. */

View File

@@ -68,8 +68,6 @@ GPIO(LTE_WAKE_L, PIN(7, 1), GPIO_INPUT)
GPIO(LTE_OFF_ODL, PIN(8, 0), GPIO_ODR_LOW)
/* end of TODO */
GPIO(PP3300_DX_BASE, PIN(1, 1), GPIO_OUT_LOW)
/* I2C pins - these will be reconfigured for alternate function below */
GPIO(I2C0_0_SCL, PIN(B, 5), GPIO_INPUT) /* EC_I2C0_0_USBC_3V3_SCL */
GPIO(I2C0_0_SDA, PIN(B, 4), GPIO_INPUT) /* EC_I2C0_0_USBC_3V3_SDA */