summaryrefslogtreecommitdiff
path: root/driver/sync.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 /driver/sync.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14396.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 'driver/sync.c')
-rw-r--r--driver/sync.c137
1 files changed, 0 insertions, 137 deletions
diff --git a/driver/sync.c b/driver/sync.c
deleted file mode 100644
index c9a2752d63..0000000000
--- a/driver/sync.c
+++ /dev/null
@@ -1,137 +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 "motion_sense_fifo.h"
-#include "queue.h"
-#include "task.h"
-#include "util.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
-
-struct sync_event_t {
- uint32_t timestamp;
- int counter;
-};
-
-static struct queue const sync_event_queue =
- QUEUE_NULL(CONFIG_SYNC_QUEUE_SIZE, struct sync_event_t);
-
-struct sync_event_t next_event;
-struct ec_response_motion_sensor_data vector = {
- .flags = MOTIONSENSE_SENSOR_FLAG_BYPASS_FIFO,
- .data = {0, 0, 0}
-};
-
-int sync_enabled;
-
-static int sync_read(const struct motion_sensor_t *s, intv3_t v)
-{
- v[0] = next_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)
-{
- next_event.timestamp = __hw_clock_source_read();
-
- if (!sync_enabled)
- return;
-
- next_event.counter++;
- queue_add_unit(&sync_event_queue, &next_event);
-
- task_set_event(TASK_ID_MOTIONSENSE, CONFIG_SYNC_INT_EVENT);
-}
-
-/* Bottom half of the irq handler */
-static int motion_irq_handler(struct motion_sensor_t *s, uint32_t *event)
-{
- struct sync_event_t sync_event;
-
- if (!(*event & CONFIG_SYNC_INT_EVENT))
- return EC_ERROR_NOT_HANDLED;
-
- while (queue_remove_unit(&sync_event_queue, &sync_event)) {
- vector.data[X] = sync_event.counter;
- motion_sense_fifo_stage_data(
- &vector, s, 1, sync_event.timestamp);
- }
- motion_sense_fifo_commit_data();
-
- return EC_SUCCESS;
-}
-
-static int sync_init(struct motion_sensor_t *s)
-{
- vector.sensor_num = s - motion_sensors;
- sync_enabled = 0;
- next_event.counter = 0;
- queue_init(&sync_event_queue);
- return 0;
-}
-
-#ifdef CONFIG_SYNC_COMMAND
-static int command_sync(int argc, char **argv)
-{
- int count = 1, i;
-
- if (argc > 1)
- count = strtoi(argv[1], 0, 0);
-
- for (i = 0; i < count; i++)
- sync_interrupt(GPIO_SYNC_INT);
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(sync, command_sync,
- "[count]",
- "Simulates sync events");
-#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,
-};
-