summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/interface.c
diff options
context:
space:
mode:
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>2016-06-05 14:03:26 +0100
committerGreg Kroah-Hartman <gregkh@google.com>2016-06-06 20:37:47 -0700
commit970dc85bd95d931def5926ae81b5aa84ef14fb7c (patch)
tree8e95aa6ef752c8b2bd6afd39aaad1b54e0c16123 /drivers/staging/greybus/interface.c
parent698282f659d7c657aad4e0a72ed33190f2332e04 (diff)
downloadop-kernel-dev-970dc85bd95d931def5926ae81b5aa84ef14fb7c.zip
op-kernel-dev-970dc85bd95d931def5926ae81b5aa84ef14fb7c.tar.gz
greybus: timesync: Add timesync core driver
This patch adds the core timesync functionality. 0. arche-platform.c/arche-apb-ctrl.c Modifies the platform layer to hook the incoming TIME_SYNC signal up to the timesync strobe IRQ handler. If the arche-platform driver can't satisfy the request for the wake-detect line, it will return -EAGAIN and the calling work-queue must reschedule the attempt to get exclusive access to the wake-detect pin logic. A private data field is added to the arche-platform driver to enable passing of a timesync pointer to the ISR responsible for synchronizing time. 1. timesync.c A new file added which contains all of the logic associated with sending greybus commands to SVC, APBx or Interfaces to enable, disable and disseminate timing information. 2. timesync_platform.c Any platform/arch specific code goes into timesync_platform.c. Originally the idea was to keep the x86 and ARM arch dependencies in a timesync_platform_arch.c file - however with further refinement that's currently not necessary however just-in-case it becomes necessary to resuscitate arch or platform specific methods for accessing timer resources that access shouldn't be part of the core timesync.c logic and so for the moment we access these timer resources through a thin access layer in timesync_platform.c. Expect this to go away long term ideally. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Acked-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/interface.c')
-rw-r--r--drivers/staging/greybus/interface.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c
index 577d15f..3eb8754 100644
--- a/drivers/staging/greybus/interface.c
+++ b/drivers/staging/greybus/interface.c
@@ -865,6 +865,61 @@ void gb_interface_disable(struct gb_interface *intf)
intf->enabled = false;
}
+/*
+ * Enable TimeSync on an Interface control connection.
+ *
+ * Locking: Takes and releases the interface mutex.
+ */
+int gb_interface_timesync_enable(struct gb_interface *intf, u8 count,
+ u64 frame_time, u32 strobe_delay, u32 refclk)
+{
+ int ret = -ENODEV;
+
+ mutex_lock(&intf->mutex);
+ if (intf->enabled) {
+ ret = gb_control_timesync_enable(intf->control, count,
+ frame_time, strobe_delay,
+ refclk);
+ }
+ mutex_unlock(&intf->mutex);
+ return ret;
+}
+
+/*
+ * Disable TimeSync on an Interface control connection.
+ *
+ * Locking: Takes and releases the interface mutex.
+ */
+int gb_interface_timesync_disable(struct gb_interface *intf)
+{
+ int ret = -ENODEV;
+
+ mutex_lock(&intf->mutex);
+ if (intf->enabled)
+ ret = gb_control_timesync_disable(intf->control);
+ mutex_unlock(&intf->mutex);
+ return ret;
+}
+
+/*
+ * Transmit the Authoritative FrameTime via an Interface control connection.
+ *
+ * Locking: Takes and releases the interface mutex.
+ */
+int gb_interface_timesync_authoritative(struct gb_interface *intf,
+ u64 *frame_time)
+{
+ int ret = -ENODEV;
+
+ mutex_lock(&intf->mutex);
+ if (intf->enabled) {
+ ret = gb_control_timesync_authoritative(intf->control,
+ frame_time);
+ }
+ mutex_unlock(&intf->mutex);
+ return ret;
+}
+
/* Register an interface. */
int gb_interface_add(struct gb_interface *intf)
{
OpenPOWER on IntegriCloud