When transfer speed is too slow (less than 17Khz) the operation can take
longer than the default greybus timeout. Because of this we need to use
the request_send_sync_timeout and calculate the correct timeout for each
operation.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Tested-by: Philip Yang <philipy@bsquare.com> Tested-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The actual implementation of transfer_one_message have problems with
some cases in the possible transfer options. We try to maximize the
number of spi transfers in one greybus operation and need to save state
until the full message is dispatch over greybus.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Tested-by: Philip Yang <philipy@bsquare.com> Tested-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: Fixup __u64, __u32 to __le64, __le32 in timesync declarations
A number of data in TimeSync command structures are declared __u64/__u32
instead of __le64/__le32, I forgot to put this through an x86_64 compile
before presentation for merge and as a result didn't catch this error. This
patch fixes.
greybus: arche-platfrom: Get rid of 2sec delay in USB3613 configuration
Earlier during boot sequence implementation, we had seen race between
USb3613 and APB boot, and since APB boot time is ~2sec, we delayed
USb3613 configuration for 2sec after APB deassertion of reset.
This obviously won't work in the case of suspend/resume, where we would
like to put APB into OFF state and coldboot in resume.
With the latest FW changes, we do not see any race issue. I have done
regression testing (> 50 iteration of reboot + unipro link up and down)
without any issues.
So lets get rid of the 2sec delay with this patch.
Testing Done: Tested on EVT 1.5 platform.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Tested-by: David Lin <dtwlin@google.com> Reviewed-by: David Lin <dtwlin@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: camera-gb: Extend the configure streams interface
Extending the configure streams interface with CSI params.
Getting CSI frequency data form configure streams response.
* num_lanes - Number of CSI data lanes
* clk_freq - CSI clock frequency in Hz
* lines_per_second - Total number of lines in a second of
transmission (blanking included)
From the AP side we need to know for the CSI speed
configuration. This information is needed for dynamically
bandwidth calculations.
NOTE: Change should be along merged with corresponding
interface change in kernel:
"camera: Extend the configure streams
interface with CSI params"
Vaibhav Agarwal [Wed, 30 Mar 2016 07:53:56 +0000 (13:23 +0530)]
greybus: audio: Update device type based on widget types
Device type info shared to above HAL is currently hard coded
to SPK only. Actual device type is identifed while parsing
widget types from topology FW shared by codec module.
Vaibhav Agarwal [Wed, 30 Mar 2016 07:53:55 +0000 (13:23 +0530)]
greybus: audio_manager: Split device type into i/p & o/p devices
Currently, single field is used to report device type say SPK,
MIC, HS, HP, etc. However above HAL expects separate fields for
input & ouput device types.
greybus: checkpatch.pl: Mark --no-tree as default option
Don't know why, but checkpatch checks if we are running it from top of a
kernel tree or not, but then it also provides an option to suppress the
warning using --no-tree.
Instead of forcing everyone to use this every time, lets make this
behavior default.
Georgi Dobrev [Thu, 24 Mar 2016 11:37:21 +0000 (13:37 +0200)]
greybus: Added a sysfs entry to power down the SVC
Added a sysfs entry called pwr_off. When a "1" is passed to it,
it sends a GB_SVC_TYPE_PWR_DOWN command to the SVC, powering it down
along with the switch and INA231 chips.
Testing Done: Tested on EVT1_5, works.
Signed-off-by: Georgi Dobrev <dobrev_georgi@projectara.com>
For those who are stuck using old kernel trees, let's include the latest
version of checkpatch.pl into our tree to help prevent coding style
mistakes from creeping in.
Also add spelling.txt to catch spelling errors in comments.
Vaibhav Agarwal [Tue, 29 Mar 2016 11:02:36 +0000 (16:32 +0530)]
greybus: audio: Added jack support to audio module
Register jack with ASoC sound card in case audio module
populates it via codec FW. Currently, only a single jack
with 4 buttons can be registered for each module.
Johan Hovold [Tue, 29 Mar 2016 22:56:08 +0000 (18:56 -0400)]
greybus: interface: read DME attributes at activation
Read the DDBL1 and Ara DME attributes when activating an interface.
These values are currently provided by the SVC in the intf_hotplug
request, which is about to go away.
Note that there are currently no standard Ara VID and PID attributes and
that Toshiba uses attributes from the reserved space in ES3. For now, we
therefore refuse to enumerate any non-Toshiba bridges.
Also note that the Ara serial number is currently not supported.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Tue, 29 Mar 2016 22:56:04 +0000 (18:56 -0400)]
greybus: interface: move route creation to interface activation
Creating and destroying a route to an interface is arguably an interface
operation and belongs with the interface code.
Add new interface_activate and interface_deactivate helpers that will be
used to activate and deactivate an interface in the new interface boot
sequence.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Tue, 29 Mar 2016 22:56:03 +0000 (18:56 -0400)]
greybus: interface: clean up ES3-bootroom-quirk handling
Clean up handling of the ES3-bootrom quirks by adding an interface
quirk-flags field that is set appropriately when we detect that the ES3
bootrom is running.
Note that we need to reserve the DME_DIS_UNIPRO_BOOT_STARTED and
DME_DIS_FALLBACK_UNIPRO_BOOT_STARTED status values for the ES3 bootrom,
which does not support any CPort features (unlike later boot stages).
Add a BOOTROM infix to the defines to make this more clear.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Agarwal [Tue, 29 Mar 2016 18:01:41 +0000 (23:31 +0530)]
greybus: audio: Use single codec driver registration
We have single I2S port via APB1 for communication with all
audio modules. Thus, we should register single codec driver
and manage all individual audio modules internally within
this driver.
greybus: convert drivers to use connection->private set/get
This converts all drivers to use the gb_connection_get_data() and
gb_connection_set_data() functions to make it a bit more explicit as to
what is going on.
Registering more then one module at same time was not
possible with previous implementation. Also unregistering
of the module was missing leading to many instability issues
when camera module is ejected when camera is still active.
Sandeep Patil [Tue, 15 Mar 2016 19:28:38 +0000 (12:28 -0700)]
greybus: power_supply: reverse version check for new psy API
Reversing the kernel version check for new power supply APIs will
easily allow us to use older kernels with backported power supply APIs
by defining "CORE_OWNS_PSY_STRUCT" in power supply core header
Testing Done:
- Build tested with arche kernel with backported power supply APIs
- Build tested also with current arche kernel to make sure we build with
3.10 kernels
Axel Haslam [Fri, 11 Mar 2016 12:19:30 +0000 (13:19 +0100)]
greybus: loopback_test: handle SIGINT signal
Adding a default timeout may not be representative of every
usecase for gb_loopback. Also, tests may continue to run
on the driver in case of a timeout.
To avoid adding a default timeout, handle SIGINT so that when the user
presses ctrl-c the test are stoped. The user can still specify a timeout
value with the -O option.
Bryan O'Donoghue [Wed, 16 Mar 2016 11:29:59 +0000 (11:29 +0000)]
greybus: Ensure gb->mutex is held when adding timer
Currently in loopback on the async path we issue an operation and then add
a timer to time-out that operation should it fail to complete. Looking at a
backtrace given in its feasible op_async->pending can be true and
del_timer() can run before add_timer() has run. In the callback handler we
already hold gb->mutex. This patch fixes that potential race by ensuring we
hold gb->mutex both when we are adding and when we are removing the
relevant timer.
Johan Hovold [Wed, 9 Mar 2016 11:20:43 +0000 (12:20 +0100)]
greybus: interface: separate disabling from removal
Separate interface disable from interface removal.
Disabling an interface means tearing down its control connection and
destroying (i.e. deregistering and releasing) its bundles, while
removing it means deregistering and releasing the interface itself.
This is needed to implement controlled module removal, where the module
interfaces are disabled before being physically ejected.
Johan Hovold [Wed, 9 Mar 2016 11:20:41 +0000 (12:20 +0100)]
greybus: interface: move interface-removal helper
Move helper to remove all interfaces of a host-device to the svc code
and call it when removing the svc device as this needs to be coordinated
with flushing the SVC work queue.
Johan Hovold [Wed, 9 Mar 2016 11:20:40 +0000 (12:20 +0100)]
greybus: interface: remove useless spinlock
Remove useless global interface spinlock that appeared to protect the
host-device interface list, but really did not as we are doing lock-less
look-ups by relying on the single-threaded SVC workqueue.
Johan Hovold [Wed, 9 Mar 2016 11:20:39 +0000 (12:20 +0100)]
greybus: interface: disable control connection on initialisation errors
Disable the control connection immediately on any errors during
interface initialisation as there's no need to keep it around for an
interface in an error state.
loopback driver use the send_count variable to know the test progress.
The test may be stopped or change but this variable is never cleaned.
Such situation may break the next run.
gb_loopback_ro_avg_attr() is using "/" to divide two 64-bit integer,
causing a reference to __aeabi_uldivmod() that is not availalbe on 32-bit.
Instead, use do_div().
Axel Haslam [Tue, 8 Mar 2016 09:03:40 +0000 (10:03 +0100)]
greybus: loopback_test: Use timeout argument
Patch "c3b0a32 Loopback_test: use poll instead of inotify"
added a optional argument for the user to specify a timeout value,
but did not use this parameter in the actual poll function. The
default of 30 seconds is always used.
Fix this by actually using the the poll_timeout parameter so the user
can run long tests.
Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Reviewed-by: Patrick Titiano <ptitiano@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
A patch from created struct gb_control_timesync_enable_request,
but forgot to properly annotate that the fields are little-endian. The
code is correct in treating them this way, so there isn't a bug, but
sparse complains.
Johan Hovold [Thu, 3 Mar 2016 12:34:39 +0000 (13:34 +0100)]
greybus: connection: add CSD connection flag
Add CSD connection flag that can be specified when allocating a
connection to enable Controlled Segment Dropping in favour of E2EFC
which is enabled by default.
Note that most connections are expected to have E2EFC enabled.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Generalise the svc connection-create helper to accept a cport-flags
argument and handle the flags in the connection code instead.
Note that the camera driver currently manages its data connection
directly. We keep E2EFC enabled for now even though it will soon need
to be disabled due to some pending firmware updates.
Simple addition of the TimeSync commands defined in the specification.
Note for the case of timesync_authoritative we're passing the request
structure directly so as not to have to pass eight parameters into the
function.
Adds:
- control.c::timesync_enable(u8 count, u64 frame_time,
u32 strobe_delay, u32 refclk)
Informs an Interface to expect count TimeSync strobe pulses with
strobe_delay milliseconds delay between each strobe. Once enabled
an Interface may not enter a low-power mode which will result in the
reference timer used to track time switching off.
- control.c::timesync_disable(void)
Commands an Interface to immediately halt TimeSync logic. This will allow
an Interface to transition into low-power modes where the reference time
being used for TimeSync may switch off.
- control.c::timesync_authoritative(u64 *frame_time, u8 count)
Used by the AP Module to inform an Interface of the authoritative
TimeSync clock-master time at each strobe pulse. Down-stream clock slaves
shall adjust their local frame-time appropriately based on the
diseminated authoritative frame-time.
greybus: timesync: Add Control and SVC protocol TimeSync operation definitions
This patch adds the protocol command extenions for SVC and Control
protocols to the greybus_protocols definition header consistent with
the greybus-spec.
greybus: timesync: Add Control and SVC TimeSync command/response data definitions
This patch adds the protocol command/response definitions for the SVC and
Control protocols to the greybus_protocols definition header consistent
with the greybus-spec.
Set retries operation was removed from the Greybus specification. Remove
gb_i2c_retries_operation and all other no longer necessary code bits from the
Greybus kernel code.
Signed-off-by: Michael Mogenson <michael.mogenson@leaflabs.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Set timeout operation was removed from the Greybus specification. Remove
gb_i2c_timeout_operation and all other no longer necessary code bits from the
Greybus kernel code.
Signed-off-by: Michael Mogenson <michael.mogenson@leaflabs.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Thu, 3 Mar 2016 14:29:39 +0000 (15:29 +0100)]
greybus: loopback: fix double error count
Make sure not count errors during asynchronous tests twice (first in
the timeout handler then again in the completion handler) to avoid
obviously broken error stats such as:
Mark Greer [Mon, 29 Feb 2016 22:31:02 +0000 (15:31 -0700)]
greybus: audio: Split start and stop APBridgeA requests
Provide finer-grained control of the audio streaming on APB1 by
splitting the transmit/receive start and stop requests into prepare,
start, stop, and shutdown.
Axel Haslam [Fri, 26 Feb 2016 10:39:49 +0000 (11:39 +0100)]
greybus: Loopback_test: use poll instead of inotify
Inotify does not handle sysfs events, so use poll instead.
The loopback kernel driver will send a notification when the test is
complete. So, open a poll file descriptor for every enabled device,
and after starting the test, wait for an event from each device.
After all events are received, read the total number of iterations
and make sure the test is complete.
Also, add missing stdint header which was included in inotify.
Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Axel Haslam [Fri, 26 Feb 2016 10:39:48 +0000 (11:39 +0100)]
greybus: Notify user space only when the test finished.
Currently, user space is notified for every message sent,
but this is not really needed and does not work in the async case
where all messages are sent from the start.
Instead, notify userspace only when all the transfers are complete.
This allows userspace to wait in a poll loop and wakeup only when
the test is finished.
Also, don't use the bundle kobj to send the notification it is
the loopback device that contains the loopback attributes.
Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Mark Greer [Sat, 27 Feb 2016 00:04:36 +0000 (17:04 -0700)]
greybus: audio: Register CPorts for specific directions
Currently, it is assumed that all audio data CPorts registered on
APB1 are used for transmitting audio data. That may not always be
true like when a microphone is connected but no speakers. Also,
the current special protocol lacks a way to tell APB1 whether the CPort
being registered is for transmitting, receiving, or both.
Fix by adding a 'direction' field to the register and unregister CPort
requests and define bits indicating which direction (or both) audio
data will go on that CPort.
Signed-off-by: Mark Greer <mgreer@animalcreek.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Alexandre Bailon [Thu, 25 Feb 2016 17:19:16 +0000 (18:19 +0100)]
greybus: loopback: Fix averaging
Currently, we are adding 0.5 to the average to round the average.
But we are using the remainder to calculate the decimal, so we do not
need to round the average.
In addition, use a u64 type for the remainder to avoid overflow
that might happen when stats->sum value is too big,
usually for requests per seconds and the throughput.