From 7f5b9e97860db889186e5825a166da6ffd248075 Mon Sep 17 00:00:00 2001 From: Alexandru M Stan Date: Wed, 11 Jul 2018 13:09:51 -0700 Subject: Revert "sensors: Add driver for SYNC" This reverts commit 2778b192f39ea01fc870153d4c21b42fc2149590. A few EC CLs made some bad assumption and caused CTS to fail (without realizing it in time). This is a series to revert those bad CLs and other CLs that depend on it. They might reland back soon. Conflicts: include/config.h BUG=b/111220617 TEST=With series, CTS passes once again Change-Id: Ieeb6515c12a544a99efcfc254bbdea520b7e05ee Signed-off-by: Alexandru M Stan Reviewed-on: https://chromium-review.googlesource.com/1134055 Reviewed-by: Gwendal Grignou Commit-Queue: Furquan Shaikh Tested-by: Furquan Shaikh --- driver/build.mk | 1 - driver/sync.c | 120 ------------------------------------------------------- driver/sync.h | 18 --------- include/config.h | 10 +---- 4 files changed, 2 insertions(+), 147 deletions(-) delete mode 100644 driver/sync.c delete mode 100644 driver/sync.h diff --git a/driver/build.mk b/driver/build.mk index 541b8df235..524d7b2b69 100644 --- a/driver/build.mk +++ b/driver/build.mk @@ -15,7 +15,6 @@ driver-$(CONFIG_ACCELGYRO_BMI160)+=accelgyro_bmi160.o driver-$(CONFIG_MAG_BMI160_BMM150)+=mag_bmm150.o driver-$(CONFIG_ACCELGYRO_LSM6DSM)+=accelgyro_lsm6dsm.o stm_mems_common.o driver-$(CONFIG_ACCEL_LIS2DH)+=accel_lis2dh.o stm_mems_common.o -driver-$(CONFIG_SYNC)+=sync.o # BC1.2 Charger Detection Devices driver-$(CONFIG_BC12_DETECT_BQ24392)+=bc12/bq24392.o diff --git a/driver/sync.c b/driver/sync.c deleted file mode 100644 index bbf0b7f0d8..0000000000 --- a/driver/sync.c +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright 2017 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. - * - * Sync event driver. - * Useful for recording the exact time a gpio interrupt happened in the - * context of sensors. Originally created for a camera vsync signal. - */ - -#include "accelgyro.h" -#include "config.h" -#include "console.h" -#include "driver/sync.h" -#include "hwtimer.h" -#include "task.h" - -#define CPRINTS(format, args...) cprints(CC_MOTION_SENSE, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_MOTION_SENSE, format, ## args) - -#ifndef CONFIG_ACCEL_FIFO -#error This driver needs CONFIG_ACCEL_FIFO -#endif - -#ifndef CONFIG_ACCEL_INTERRUPTS -#error This driver needs CONFIG_ACCEL_INTERRUPTS -#endif - -static uint32_t previous_interrupt_timestamp, last_interrupt_timestamp; -static int event_counter; -struct ec_response_motion_sensor_data vector = {.flags = 0, .data = {0, 0, 0} }; -int sync_enabled; - -static int sync_read(const struct motion_sensor_t *s, vector_3_t v) -{ - v[0] = event_counter; - return EC_SUCCESS; -} - -/* - * Since there's no such thing as data rate for this sensor, but the framework - * still depends on being able to set this to 0 to disable it, we'll just use - * non 0 rate values as an enable boolean. - */ -static int sync_set_data_rate(const struct motion_sensor_t *s, - int rate, int roundup) -{ - sync_enabled = !!rate; - CPRINTF("sync event driver enabling=%d\n", sync_enabled); - return EC_SUCCESS; -} - -static int sync_get_data_rate(const struct motion_sensor_t *s) -{ - return sync_enabled; -} - -/* Upper half of the irq handler */ -void sync_interrupt(enum gpio_signal signal) -{ - uint32_t timestamp = __hw_clock_source_read(); - - if (!sync_enabled) - return; - - last_interrupt_timestamp = timestamp; - event_counter++; - - task_set_event(TASK_ID_MOTIONSENSE, CONFIG_SYNC_INT_EVENT, 0); -} - -/* Bottom half of the irq handler */ -static int motion_irq_handler(struct motion_sensor_t *s, uint32_t *event) -{ - uint32_t timestamp; - - if (!(*event & CONFIG_SYNC_INT_EVENT)) - return EC_ERROR_NOT_HANDLED; - - /* this should be the atomic read */ - timestamp = last_interrupt_timestamp; - - if (previous_interrupt_timestamp == timestamp) - return EC_ERROR_NOT_HANDLED; /* nothing new yet */ - previous_interrupt_timestamp = timestamp; - - vector.flags = MOTIONSENSE_SENSOR_FLAG_WAKEUP; - vector.data[X] = event_counter; - motion_sense_fifo_add_data(&vector, s, 1, timestamp); - return EC_SUCCESS; -} - -static int sync_init(const struct motion_sensor_t *s) -{ - last_interrupt_timestamp = __hw_clock_source_read(); - previous_interrupt_timestamp = last_interrupt_timestamp; - event_counter = 0; - vector.sensor_num = s - motion_sensors; - sync_enabled = 0; - return 0; -} - -#ifdef CONFIG_SYNC_COMMAND -static int command_sync(int argc, char **argv) -{ - sync_interrupt(GPIO_SYNC_INT); - return EC_SUCCESS; -} -DECLARE_CONSOLE_COMMAND(sync, command_sync, - NULL, - "Simulates a sync event"); -#endif - -const struct accelgyro_drv sync_drv = { - .init = sync_init, - .read = sync_read, - .set_data_rate = sync_set_data_rate, - .get_data_rate = sync_get_data_rate, - .irq_handler = motion_irq_handler, -}; - diff --git a/driver/sync.h b/driver/sync.h deleted file mode 100644 index 1f6115a086..0000000000 --- a/driver/sync.h +++ /dev/null @@ -1,18 +0,0 @@ -/* Copyright 2017 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. - * - * Sync event driver. - * Useful for recording the exact time a gpio interrupt happened in the - * context of sensors. Originally created for a camera vsync signal. - */ - -#ifndef __CROS_EC_VSYNC_H -#define __CROS_EC_VSYNC_H - -extern const struct accelgyro_drv sync_drv; - -void sync_interrupt(enum gpio_signal signal); - -#endif /* __CROS_EC_VSYNC_H */ - diff --git a/include/config.h b/include/config.h index c8980a9aaf..f8bbae47ae 100644 --- a/include/config.h +++ b/include/config.h @@ -109,17 +109,11 @@ /* Specify type of Gyrometers attached. */ #undef CONFIG_GYRO_L3GD20H -/* Sync event driver */ -#undef CONFIG_SYNC - -/* Simulate command for sync */ -#undef CONFIG_SYNC_COMMAND - /* - * Define the event to raise when the sync event happens. + * Define the event to raise when LIS2DH interrupt. * Must be within TASK_EVENT_MOTION_INTERRUPT_MASK. */ -#undef CONFIG_SYNC_INT_EVENT +#undef CONFIG_ACCEL_LIS2DH_INT_EVENT /* Compile chip support for analog-to-digital convertor */ #undef CONFIG_ADC -- cgit v1.2.1