It's possible the AP could miss an incoming SVC timesync pulse i.e. the AP
could have interrupts switched off for long enough that one SVC GPIO strobe
ends up over-lapping another one. TimeSync should be able to deal with this
type of transitory failure by retrying a failed synchronous TimeSync resync
up to 'n' number of times. For this patch 'n' has been set to five, which
is a hand-wavy choice that 'feels' right.
David Lin [Tue, 2 Aug 2016 22:34:46 +0000 (15:34 -0700)]
greybus: interface: delete control device upon enable failure
There is an issue that when an interface failed to be enabled due to
timesync failure, a previously added control device is not deleted as
part of the error clean-up. This causes a leak in the sysfs file when
the interface is disabled. This would eventually cause this particular
interface to be unable to register future control device even after
unipro_reset. See failure logs below:
Johan Hovold [Wed, 27 Jul 2016 14:37:22 +0000 (16:37 +0200)]
greybus: es2: fix arpc active-list corruption
Fix ARPC active-list corruption due to incorrect list-interface usage.
The corruption manifested itself as ARPC timeouts due to expected
responses not being recognised whenever more than one ARPC was active.
This could be seen for example when two interfaces were being runtime
suspended in parallel:
[ 165.739896] usb 1-1.1: invalid arpc response id received: 13
[ 165.794743] greybus 1-5.5: gb_interface_refclk_set - 0
[ 166.241202] usb 1-1.1: failed to execute ARPC: -110
Fortunately the impact of this bug has so far been limited to such
timeouts and error messages due to ARPC currently only being used for
CPort reset in the connection tear-down path.
Reported-by: Mark Greer <mgreer@animalcreek.com> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
The wrong pointer was checked for allocation failures when allocating
the ARPC response buffer, something which would lead to allocation
failures going undetected.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
David Lin [Mon, 25 Jul 2016 23:29:20 +0000 (16:29 -0700)]
greybus: audio: add runtime pm to enumerated control and DAPM widget
There's an issue that the userspace is not able to control both the
enumerated control and DAPM widget when audio bundle is in the SUSPEND
state. This patch fixes the issue by adding pm_runtime_get/put() calls
for the both controls.
Testing Done:
- Use tinymix to get and put both enumerated control and DAPM widget as
the followings, and observe audio bundle is able to wake up from
suspend.
David Lin [Tue, 26 Jul 2016 23:27:28 +0000 (16:27 -0700)]
greybus: svc_watchdog: Add sysfs file to change the behavior of bite
Currently, AP performs unipro_reset if SVC fails to response to its
ping. While this error recovery is best suited for the end-user
experience, errors in the UniPro network could potentially go unnoticed
by the QA and fishfooders in the development phase of the project. This
patch adds an option to trigger a kernel panic so logs can be collected
for analysis.
Testing Done:
- Reproduce issue and observe kernel panic when
watchdob_control is changed to 'panic'
Signed-off-by: David Lin <dtwlin@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: firmware: Update Documentation and sample application
Update documentation and sample application to capture the 'status' byte
in backend version operation and new error types in backend firmware
update operation.
greybus: firmware: Add 'status' byte to backend fw version response
The backend processor may not be ready to return the version of firmware
it is running by the time AP requests for it. The greybus specification
is updated to return 1-byte 'status' to return the error type, RETRY is
one of them.
This patch implements that in greybus now.
Note that the version structure was common across interface and backend
version requests earlier, but that is changing as well.
greybus: interface: Add quirk for no PM for S2 Loader
S2 Loader doesn't support runtime PM operations currently and we will
fail to suspend/resume the bundle for firmware management protocols.
Once that happens, the bundle and its connections will be pretty much
useless as we would have tried to disable/enable all connections during
such an operation and the S2 loader doesn't expect the connections to go
away during normal operation (except in the case of mode-switch).
This patch defines a new quirk GB_INTERFACE_QUIRK_NO_PM and uses a new
interface init status value (GB_INIT_S2_LOADER_INITIALIZED) which will
be advertised by S2 Loader now in the init status.
After detecting the currently running stage as S2 Loader, the kernel
wouldn't attempt suspending or resuming the bundle.
Reviewed-by: David Lin <dtwlin@google.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: interface: Rename *_NO_PM as *_NO_BUNDLE_ACTIVATE
Its a special quirk just for the bootrom as it doesn't have any PM
operations implemented. As the greybus bootrom bundle driver doesn't try
to do any PM stuff, this quirk is used only to skip bundle activate
operation currently.
Rename the GB_INTERFACE_QUIRK_NO_PM quirk to
GB_INTERFACE_QUIRK_NO_BUNDLE_ACTIVATE to suit its purpose better as the
GB_INTERFACE_QUIRK_NO_PM will be used for other quirk now.
This patch implements runtime PM support for firmware management bundle.
This guarantees that the bundle will be active, while the AP or the
Module is trying to exchange any operations over any of the CPorts.
- Firmware Management CPort:
Runtime PM get/put calls are placed around the ioctl calls, which are
all implemented as blocking ioctls.
- Component Authentication CPort:
Runtime PM get/put calls are placed around the ioctl calls, which are
all implemented as blocking ioctls.
- SPI:
Uses the interface provided by spilib.c and runtime PM get/put are
called around connection usage.
- firmware-download:
This is the most tricky one. All operations on this CPort are
initiated from the Module and not from the AP. And the AP needs to do
runtime_pm_get() before any request is received over this CPort.
The module doesn't send any request over this connection, unless the
AP has requested the module over firmware management CPort to download
a firmware package over firmware download CPort.
And so the runtime PM get/put calls around the ioctls in
fw-management.c are sufficient to handle the firmware management CPort
as well.
The response-received tracepoint is currently broken. Instead of parsing
the received message header it was tracing a bunch of zeroed fields from
an uninitialised response buffer.
Fix this by moving the tracepoint after were the response buffer is
initialised.
The operation type included in the error message printed for malformed
responses has never been correct. An uninitialised buffer was used to
retrieve the type, resulting in the type always being reported as 0.
Fix this by passing a properly aligned header to the response handler,
and drop the now redundant id and result parameters.
Fixes: cb0ef0c019ab ("operation: print message type on errors") Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Philip Yang [Fri, 22 Jul 2016 21:48:14 +0000 (05:48 +0800)]
greybus: HID: Add runtime pm support
Modify HID greybus driver to support runtime PM framework.
The suspend and resume fucntion have been test with tutorial-hid,
e-ink-display and gpbridge-test image by sysfs resume, all HID
buttons work well on suspend/resume.
Testing Done: Compiled and verified on EVT2, DB3.5, GPB test module
with daughter board, Red module.
Signed-off-by: Philip Yang <yang_philip@projectara.com> Reviewed-by: David Lin <dtwlin@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: bootrom: Rename download_firmware() as find_firmware()
The download_firmware() function isn't downloading the firmware but just
finding if one is available or not. The same applies to the error
message printed by it.
Replace 'download' with 'find' to make it sound better.
greybus: bootrom: Set timeout before sending AP_READY
A special race is observed in the case where the phone boots with
modules attached to it.
In that case, the AP processes a later FIRMWARE_SIZE request from the
bootrom, before processing the response to the earlier AP_READY request.
And because of that, we set the timeout from gb_bootrom_probe() after
trying to cancel it from gb_bootrom_firmware_size_request().
And with that, if the firmware package isn't available for the kernel to
directly read from, then we get a timeout print message like below:
[ 23.669764] bootrom 1-3.3.1: Firmware file 'ara_00000126_00001001_fffe0001_ffe5001a_s2l.tftf' requested
[ 24.680528] bootrom 1-3.3.1: Timed out waiting for Firmware Size Request from the Module
Note that this doesn't happen if the module is inserted into the frame,
after the phone is already booted.
This behavior is the result of an earlier commit cdd1cb3f4943
("operation: add completion work queue").
This perhaps happens only at boot time because the UNBOUND wq
(connection->wq) gets a chance to run on other CPUs, while the BOUND wq
(gb_operation_completion_wq) doesn't at that stage (24 seconds since
boot).
Setting the timeout before sending the AP_READY request fixes it for
now.
Reported-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: bootrom: Skip setting timeout in failure path of size request
The currently set value of next_request_type in the error path of
gb_bootrom_firmware_size_request() is not correct, as it should have
been NEXT_REQ_FIRMWARE_SIZE for the failure case (as we should be
waiting for another similar request).
But, if an error occurs in gb_bootrom_firmware_size_request(), then the
ES3 bootrom will never be able to recover from it and send another
request. And so there is no point waiting for another request and timing
out.
greybus: control: Print bundle-id in print messages
The new power management specific operations added to the control
protocol do not print the bundle-id in the error messages and it is not
possible to identify which bundle-id the operation failed for.
Fix that and do minor rewriting of the print messages to make them more
readable.
David Lin [Fri, 22 Jul 2016 20:46:25 +0000 (13:46 -0700)]
greybus: operation: print id when synchronous operation timeout
In case of a synchronous operation timeout error, it's helpful for
purpose of debugging to print the operation id in the error message, so
that we know if the response is received at a later time after operation
time out.
Testing Done:
- Observe the error message below when response comes later after
operation timeout:
[ 792.973978] greybus greybus1: 0/0:0: synchronous operation id 0x0005
of type 0x21 failed: -110
[ 800.646694] greybus greybus1: 0/0:0: unexpected response id 0x0005
received
Signed-off-by: David Lin <dtwlin@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
It is suggested to avoid using ARA keyword externally. So we need to
update GB codec driver. Also, codec name is currently set to 'gb-codec'.
However, it makes more sense to name it as apb-dummy-codec, since it is
used to control various audio modules connected to APB via greybus.
spilib is used by multiple users currently (spi.c and fw-core.c) but
commit aa52b62a0556 broke that hierarchy and introduced gbphy dependent
code in spilib.
This may have unreliable consequences as we are doing following
operation unconditionally now:
which may not go well when the parent is of type &bundle->dev
(fw-core.c).
This patch introduces spilib_ops and lets the users of the core register
them. This shall have no functional change for the spi.c usecase and
shall fix the unreliable results for the fw-core.c usecase.
Tested by writing to mtd0 dev and verifying (with print messages) that
the below routines are getting called for a gpbridge-test module.
David Lin [Thu, 21 Jul 2016 00:18:39 +0000 (17:18 -0700)]
greybus: timesync: do not print frametime by default
Currently frametime are being printed whenever an Interface is
runtime-resumed. This is unnecessarily chatty. This patch moves the
frametime print from using pr_info() to dev_dbg().
greybus: pm: add error handling to bundle activation
The firmware now keeps the underlying hardware disabled until
receiving the first Bundle Activate request. Additionally: requesting
transition to a state the bundle is already in is no longer an error.
We can now add proper error handling to the bundle activate call.
Johan Hovold [Thu, 21 Jul 2016 12:24:11 +0000 (14:24 +0200)]
greybus: control: suppress bundle_activate() for bootrom
We always knew backward compatibility with the ES3 bootrom, which was
finalised about a year ago, would be a pain. Here we go again.
The bootrom does not support control requests added after it was burnt
into ROM for obvious reasons. This means that we need to suppress
sending the new bundle_activate() operation to any interface executing
the legacy bootrom.
Do so by adding a new NO_PM interface quirk (we can use the
control-protocol version for this later once we bump it).
Note that the interface-disable path (e.g. for power down) is already
handled by the FORCED_DISABLE quirk, and that the suspend/resume
paths are currently avoided by making sure that the bootrom bundle
never suspends.
Replace prefix "ara_" with prefix "gmp_" for TFTF firmware filenames.
Testing Done: compiled and flashed EVT2 (bootimage) and tested that
"gmp_" prefixed tftf files are expected. Pushed one from
FDK and checked that it's properly loaded.
greybus: timesync: probe shouldn't complete until FrameTime sync does
Currently the probe() function contains the asynchronous() variant of
FrameTime synchronization. This patch converts to the synchronous() version
of synchronization. This is required for two reasons first a probe() cannot
reasonably be considered to be complete without successfully completing a
time synchronization for Interfaces that care about that sync. Secondly
scheduling the operation asynchronously means its possible the PM-runtime
suspend() path can execute before the async timesync operation completes.
For both reasons we want to run synchronization - synchronously.
Ryan Lim [Wed, 20 Jul 2016 15:14:02 +0000 (08:14 -0700)]
greybus: loopback_test: Cancel only the tests running on selected devices
When starting a loopback test, it cancels all currently running tests on
all loopback devices. When -m argument is given, which runs the test on
specific loopback devices, only the tests running on the selected
devices need to be cancelled before starting new tests.
Signed-off-by: Ryan Lim <limryan@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Currently we have a long initial delay when initiating the first operation
to synchronize the FrameTime. That made sense during development of the
feature since we did synchronization asynchronously and wanted to give some
grace time for new Interfaces to be added before initiating a new
synchronization. On the PM runtime resume path though we do a synchronous
restoration of FrameTime and in this case waiting for 1 second before
initiating the first operation is clearly wrong.
This patch reduces the initial operation time bringing the synchronous call
time down by 990 milliseconds.
Johan Hovold [Wed, 20 Jul 2016 14:40:27 +0000 (16:40 +0200)]
greybus: interface: hibernate UniPro link in activation error path
To be well-behaved, we should hibernate the link before disabling UniPro
in case the link has already been established (i.e. when the interface
type has been detected as UniPro or Greybus).
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Sandeep Patil <sspatil@google.com> Reviewed-by: Patrick Titiano <ptitiano@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Wed, 20 Jul 2016 14:40:26 +0000 (16:40 +0200)]
greybus: interface: fix power_state documentation
Reword the power_state attribute documentation to make it clear that an
attempt to boot and possibly enumerate an interface is made when writing
"on" to the file, and that on errors the interface will again be powered
down.
Drop the incorrect claim that writing the currently read value has no
effect, since no such guarantees can be made (e.g. several writers may
be sleeping on the interface mutex).
Also fix some minor language issues.
Reviewed-by: Sandeep Patil <sspatil@google.com> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Patrick Titiano <ptitiano@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
User space needs the capability of powering ON or OFF an Interface for
multiple use cases. For example, userspace may want an Interface
currently in its S3 boot stage, to boot into its S2 Loader stage to
update the bridge SPI flash. Or the Interface is running its S2 Loader
stage and updated the SPI flash with the new S2 Loader firmware and
wants to boot into the new S2 Loader firmware.
Another use case can be, Android wants to disable (not eject) a
misbehaving module.
Add a 'power_state' sysfs file within the interface directory. It can be
read to know the current power state of the Interface and can be written
to power ON or power OFF an Interface. Possible values that can be
written or read from it are: "on" and "off".
Testing Done: Tested by enabling/disabling camera module on EVT 2.0.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> CC: David Lin <dtwlin@google.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
[johan: drop es3-quirk duplication, add to power attribute group, fix
return value, drop tags ] Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Sandeep Patil <sspatil@google.com> Reviewed-by: Patrick Titiano <ptitiano@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Wed, 20 Jul 2016 14:40:24 +0000 (16:40 +0200)]
greybus: interface: prevent reactivation during removal
Make sure to prevent an interface that is going away from being
reactivated.
This is needed to preemptively close a race between the upcoming feature
to reactivate a powered-down interface and physical removal (i.e.
module_removed event processing) as well as logical removal (e.g. the
current system-suspend hack).
Reviewed-by: Sandeep Patil <sspatil@google.com> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Patrick Titiano <ptitiano@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Wed, 20 Jul 2016 14:40:23 +0000 (16:40 +0200)]
greybus: interface: make sure type is invariant during reactivation
An interface is not expected to change its type after a power down and
reactivation so make sure to treat that as a fatal error.
This is complicated by the current Toshiba ES3 hack which requires us
to retry activation as Greybus interfaces are sometimes misdetected as
UniPro interfaces. Handle that by only retrying activation the first
time an interface is activated, and for interfaces already detected as
having Greybus type.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Sandeep Patil <sspatil@google.com> Reviewed-by: Patrick Titiano <ptitiano@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Wed, 20 Jul 2016 14:40:21 +0000 (16:40 +0200)]
greybus: interface: do not read DME during reactivation
It will soon be possible to reactivate an interface that has been
powered down after already having been activated. In that case there's
no need to re-read the DME attributes as part of activation as the
values are already cached.
Reviewed-by: Sandeep Patil <sspatil@google.com> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Patrick Titiano <ptitiano@baylibre.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Tue, 19 Jul 2016 13:24:50 +0000 (15:24 +0200)]
greybus: module: suppress activation error message for dummy interfaces
We currently handle dummy interfaces by deactivating them using
activation error paths, but we don't want the corresponding
module_inserted error message to be printed.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Amend the interface registration message with the detected interface
type, and only print the Ara VID/PID and DDBL1 attributes for the types
for which they exist.
Also drop the now redundant message about a detected dummy interface
from the activate operation helper.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: arche-platform: Add support for init-off feature
Disable wake_detect interrupt after request
As part of SW-4344/SW-7061, now we are enabling FW flashing
to all builds. That means check for need of FW upgrade is
going to be present in all builds, and moving to FW_FlASHING
mode from active is heavy operation; so the idea here is
simplify this process and save the boot time due to switching
back-n-forth between ACTIVE<=>FW_FLASHING modes.
So we decided to put unipro into OFF state by default on boot,
which can be changed through DT property. If arche-platform
device node has "arche,init-off" property set, then unipro
will be in OFF state on boot. User can bring it back by
# echo active > /sys/devices/arche_platform*/state
And to simply the exit code of probe() fn the
arche_platform_coldboot_seq() has been shifted to the
bottom of the _probe() fn.
Testing Done: Tested on EVT2 platform, with and without
"arche,init-off" property, multiple times.
Note: I am seeing SW-7128, which is not related to these changes.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Tested-by: Michael Scott <michael.scott@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Tue, 19 Jul 2016 15:21:27 +0000 (17:21 +0200)]
greybus: connection: drop the svc quiescing operation
Connection tear down is being reworked, and the SVC quiescing operation
is going away.
Let's remove this operation now along with the coupled second ping from
our intermediate tear down implementation.
This both avoids unnecessary noise in the logs resulting from the fact
that the SVC side of the quiescing operation was never merged, and
speeds up connection tear down slightly.
Core sd/mmc needs the start_signal_voltage_switch operation to be
defined to issue a voltage switch command. So, we define it here even
though we do not need to take in action on it, since all voltage control
is done in the Module.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
It makes sense to use similar encoding for all three packages and so it
should be named as:
ara_00000126_00001001_fffe0001_ffe70018_s2l.tftf
Because the boot stage is passed from ES3 bootrom, we can't change its
value now. But the string created to match the package name is created
in bootrom.c and that is the only string we create from bootrom.c.
Update bootrom.c to use "s2l" instead of "02" in the package name.
greybus: timesync: Bugfix ping should not result in -EAGAIN
gb_timesync_schedule_synchronous() is currently making a synchronous
FrameTime synchronization happen. It does a wait_event_interruptible() and
then goes to check the status of the state-machine. Occasionally the state
indicates PING - which is a completely valid state and should result in a
result code of 0 not -EAGAIN. This patch fixes by making
__gb_timesync_get_status() return 0 instead of -EAGAIN for the PING state.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Tested-by: David Lin <dtwlin@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: greybus_protocols.h: convert __u32 to __le32
All 32 bit declarations associated with data interchange to the greybus
network need to be declared explicitly as little-endian since that is the
byte order we use on the greybus network. struct gb_audio_topology is
declaring its variables as u32. Fortunately this structure isn't currently
used so we can do a conversion from u32 to __le32 without any ancillary
code-churn.
greybus: greybus_protocols.h/es2: Ensure __le32 is used not u32
There is a dangling u32 in es2/greybus_protocols.h that is only obvious
when you try to compile up gbsim. We need to do a cpu_to_le32 and declare
the 32-bit int in the header as __le32. This patch does that and splits out
the assignment of the req->flags parameter to a temporary variable to allow
for later printing.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Suggested-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Update the configuration supplied to APB-A to use new parameters, while
keeping compatibility with legacy camera modules.
Substitute hard-coded clock frequency with information provided by camera
module, and retrieve the maximum CSI Long Packet length from the
returned stream configuration.
This patch requires APB-A csi-tx driver to be updated to comply with
newly defined bandwidth requirements.
Testing Done: preview, capture and video recording with updated csi-tx
driver on APB-A side, and legacy white camera module firmware
As camera specification gets updated, and Configure Stream Response
payload modified, define here the new response structure.
In order to not break non up-to-date camera modules, keep the existing
structure and add the _deprecated suffix to it.
Add the size of both new and old structure in order to discriminate
dynamically which version of Camera Specification the camera module
implements and translate deprecated version of configure_streams response
in the new one.
In order not to break camera functionalities, for testing purposes,
hard-code values the APB-A CSI Tx driver still requires for proper
interface configuration (lines_per_second and num_lanes)
Testing Done: Preview, capture and video recording with white camera
module and APB-A with legacy firmware implementations
greybus: camera: Hardcode the APB-A CSI-2 TX parameters
Camera modules will stop reporting the number of lines per second,
hardcode the parameter in the driver until the APB-A CSI-2 TX
configuration protocol gets updated as well to use a more appropriate
form of bandwidth information.
The number of data lanes is also hardcoded as it should not depend on
the module's CSI-2 bus configuration.
greybus: camera: Add wrapper for sync operation with flags
The greybus operation core synchronous operation call doesn't support
operation flags. Create a new synchronous operation wrapper with flags,
and modify the capabilities operation implementation to use it.
The code could be later moved to the greybus core if other drivers have
a similar need.
greybus: camera: Add bpp to Greybus Format description
Add the bytes per pixel value to the structure describing a Greybus
Protocol Image Format.
The bpp information will be used to compute the length in bytes of a
line of pixel data
greybus: power_supply: add missing defines present in the specification
Some of the Greybus properties values (capacity level and scope) even
though they are defined in the specification were missing from the
protocol header.
They still match the kernel ones, but they should be present in there
for protocol sake.
greybus: timesync/pm: Make synchronous call to restore FrameTime
When we discussed and agreed a serialized way to-do PM runtime
suspend/resume we omitted the necessity to restore the FrameTime on resume.
This patch restores the FrameTime synchronously such that when an Interface
PM resume callback completes we have either successfully restored the
FrameTime including the new Interface or we've produced a result code to
indicate what went wrong when trying.
Suggested-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Tested-by: David Lin <dtwlin@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Implement platform driver shutdown callback to perform proper greybus
shutdown so that the userspace unipro_shutdown service that shuts down
the APB/SVC abruptly can be removed. The shutdown callback in
arche-platform will first remove SVC so that all the Interface can be
Deactivated in a sequence according to the spec before powering off the
APB:
Before:
-> Arche/APB power off
-> SoC power off
After this patch:
-> HD shutdown
-> SVC shutdown
-> Module shutdown
-> Interface shutdown
-> Bundle shutdown
-> Arche/APB power off
-> SoC power off
Testing Done:
- Observe all Interfaces are deactivated in the log during shutdown
- Measure power off current and make sure no regression
Signed-off-by: David Lin <dtwlin@google.com> Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: power_supply: convert greybus properties to power supply properties
We need to translate greybus properties to power supply core properties,
for that when parsing the properties that were fetch during
configuration we check if there is a match to the running kernel version
and store it in a new field (gb_prop) in the gb_power_supply_prop
struct.
If the corresponding property does not exist in the running
kernel (because of version or vendor specific property) we drop that
property.
A collection of properties that, at this time, may diverge are defined
in the kernel_ver.h to avoid breakage at build time and run time if this
properties are not supported by the kernel.
Alex Elder [Thu, 14 Jul 2016 19:24:19 +0000 (14:24 -0500)]
greybus: use memdup_user()
Coccinelle reports that there are two opportunities to use memdup_user()
in "authentication.c". This patch simplifies the code in cap_ioctl() by
taking advantage of that. Make use of a local variable "size" to improve
readability.
Alex Elder [Thu, 14 Jul 2016 19:24:18 +0000 (14:24 -0500)]
greybus: get rid of a compile warning
The compiler has no way of knowing whether a called function will
actually assign something to the object whose address is passed as
an argument. So it must assume it won't happen, and this leads to a
compile warning. Fix this.
Axel Haslam [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: loopback: add runtime pm support
Add runtime pm to the loopback driver so that
the module wakes up from suspend while a test
is executed.
Testing Done: Let the module enter standby and
execute a loopback test.
Signed-off-by: Axel Haslam <haslam_axel@projectara.com> Signed-off-by: David Lin <dtwlin@google.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>
Axel Haslam [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: spi: Add runtime_pm support
Add runtime operations to the spi driver so that the
module is woken up when an spi transfer is started
and put back to sleep when the transfer is done.
Testing Done: Let the module enter standby and initiate
an spi operation. The operation wakes up the module
and succeeds.
Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Signed-off-by: David Lin <dtwlin@google.com> Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Alex Elder <elder@linaro.org>
Axel Haslam [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: pwm: Add runtime_pm support
Add runtime pm support for the pmw driver.
Testing Done: Set the parameters of pwm0, and enable.
Disable pwm0 and let the module enter standby.
Enable pwm0, and observe that with an oscilloscope
that the wave form is the same as before.
Signed-off-by: Axel Haslam <haslam_axel@projectara.com> Signed-off-by: David Lin <dtwlin@google.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>
Axel Haslam [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: gpio: Add runtime_pm suppourt
Add runtime pm support for the gpio driver.
Since there is no remote wakeup support, the
module will not suspend as long as a gpio is
requested.
Maybe an optimization could be made, to allow suspend
if all the requested gpios are in output mode, since
the bridge should maintain the state of the gpio
during suspend.
Testing Done: using the test board, let the
gpbrige enter standby and request a gpio.
Signed-off-by: Axel Haslam <haslam_axel@projectara.com> Signed-off-by: David Lin <dtwlin@google.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>
Axel Haslam [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: uart: Add runtime pm support
This adds runtime pm support for the uart driver.
Testing Done: Using the test daughter board, let
the gpb bridge enter standby and do a uart transfer
operation.
Signed-off-by: Axel Haslam <haslam_axel@projectara.com> Signed-off-by: David Lin <dtwlin@google.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>
David Lin [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: i2c: add runtime pm support
Add runtime pm support to camera i2c bridged phy device class driver
Testing Done:
- Passed #gb_test.sh -v -t i2c
Signed-off-by: David Lin <dtwlin@google.com> Signed-off-by: Axel Haslam <haslam_axel@projectara.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>
David Lin [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: gbphy: add gbphy runtime pm support
Since GBphy is a child of the Bundle device driver, for those runtime pm
settings that are common to all the protocol drivers need to go in to
the GBphy bus driver.
Testing Done:
- Check gbphy driver can be autosuspended
Signed-off-by: David Lin <dtwlin@google.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>
David Lin [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: camera: add runtime pm support
Add runtime pm support to camera protocol device class driver.
Testing Done:
- Make sure white camera module is able to runtime suspend and resume
when the camera is being used
Signed-off-by: David Lin <dtwlin@google.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org> Signed-off-by: Alex Elder <elder@linaro.org>
David Lin [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: audio: add runtime pm support
Add runtime pm support to audio protocol device class driver.
Testing Done:
- Use white speaker module and check the interface is autosuspended when
it's idle and resumed when playback audio
Signed-off-by: David Lin <dtwlin@google.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Reviewed-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org> Signed-off-by: Alex Elder <elder@linaro.org>
David Lin [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: bundle: add runtime pm support
This patch adds runtime pm support for the bundle core. Unbound bundle
devices are always deactivated. During probe, Runtime PM status is set
to enabled and active and the usage count is incremented. If the driver
supports runtime PM, it should call pm_runtime_put() in its probe
routine and pm_runtime_get_sync() in remove routine as bundle needs to
be resume before it can be deactivated.
Testing Done:
- Check runtime_status of the bundle driver when bundle goes to suspend
Signed-off-by: David Lin <dtwlin@google.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>
David Lin [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: interface: add runtime pm support
Configure and enable runtime pm support for the Interface. Refer to the
12.2. The Interface Lifecycle of the Greybus specification for details
on the requirements for transitioning from ENUMERATED to SUSPEND and
vice versa. All the Bundles for the Interface have to be either OFF or
SUSPENDED before the Interface can be autosuspended.
Testing Done:
- Check the runtime_status of an interface driver and validate the
suspend current of a module.
Signed-off-by: David Lin <dtwlin@google.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>
David Lin [Thu, 14 Jul 2016 20:13:00 +0000 (15:13 -0500)]
greybus: bundle: add activate and deactivate
AP shall send the Bundle Activate Operation to power on a bundle, and
send the Bundle Deactivate Request after closing all the associated
connections for power down.
Testing Done:
- Check for the return code of the bundle activate and deactivate
operation sent
Signed-off-by: David Lin <dtwlin@google.com> Signed-off-by: Axel Haslam <ahaslam@baylibre.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>
Johan Hovold [Thu, 14 Jul 2016 17:55:00 +0000 (12:55 -0500)]
greybus: es2: fix arpc response lookups
Fix arpc response lookups that were truncating the 16-bit response id to
8-bit, something which would have lead to all arpc calls timing out
after the 256th request.
Testing done: Enumerated and ejected a module on EVT2.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Alex Elder <elder@linaro.org>
greybus: audio: Maintain proper codec state during shutdown sequence.
During shutdown sequence, in case all modules are already removed,
codec state is not updated. Though it's not causing any harm for now,
but it's good to maintain proper codec state. Fix this.
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org> Reviewed-by: Mark Greer <mgreer@animalcreek.com> Signed-off-by: Alex Elder <elder@linaro.org>
greybus: audio: Fix incorrect codec state modification
In case module is removed dynamically with ongoing playback, during
module cleanup codec state is mistakenly modified. State should be
modified for module only. Fix this.
Fixes: 76414cb499b7 ("audio: Use single codec driver
registration")
Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org> Reviewed-by: Mark Greer <mgreer@animalcreek.com> Signed-off-by: Alex Elder <elder@linaro.org>
Johan Hovold [Wed, 13 Jul 2016 14:34:00 +0000 (09:34 -0500)]
greybus: es2: fix arpc return value
ARPC should return 0 on success, but instead was returning the number of
jiffies left until the timeout.
This caused cport_reset() to report an error and an incorrect error
message to be printed when disabling a connection.
Reported-by: Alex Elder <elder@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Tested-by: Alex Elder <elder@linaro.org> Signed-off-by: Alex Elder <elder@linaro.org>
Implement ARPC. In first time, we are going to use it to
implement new request but the goal is to update all existing vendor
request to use ARPC.
In addition, Convert the current USB Vendor request for CPort Reset
to ARPC so that we can be sure that the port has been fully reset
by the time the request completes.
Testing Done:
AP can reset APBA Cports by using the ARPC command.
In addition, tested with a hacked firmware that cause error during
the Cport reset, and Greybus printed the error "failed to reset cport".
Signed-off-by: Alexandre Bailon <abailon@baylibre.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>
greybus: es2: Add a new bulk in endpoint for APBridgeA RPC
Add a new bulk in endpoint in order to get RPC status
from APbridgeA without to have to poll on control endpoint.
So the new endpoint layout is:
EP0: control EP
EP1 and EP2: muxed endpoints (bulk in and out)
EP3 to EP14: direct muxed endpoints (bulk in and out)
EP15: ARPC bulk in endpoint
Note:
This patch is allocating ARPC URBs but does nothing with them.
The following patch will use them.
Testing Done:
Tested with an APBridgeA enumerating 16 endpoints.
Kernel doesn't print Not enough endpoints found in device, aborting!
Signed-off-by: Alexandre Bailon <abailon@baylibre.com> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Alex Elder <elder@linaro.org>