Michael Scott [Thu, 28 Jan 2016 00:40:58 +0000 (16:40 -0800)]
greybus: arche-platform: ensure wake-detect pin is deasserted
During DB3.5 bringup, it was noted that wake_detect signal was not
properly generating SVC edge IRQ. To ensure signal goes from low
to high correctly, let's bring signal low (regardless of default
pin state).
Testing Done:
- Used for DB3.5/EVT1.5 hardware during bringup
- Regression tested on DB3.1+ES2, DB3.1+ES3
Signed-off-by: Michael Scott <michael.scott@linaro.org> Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Tested-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Johan Hovold [Thu, 28 Jan 2016 11:43:29 +0000 (12:43 +0100)]
greybus: hd: fix host-device-removal race
Make sure to tear down the svc and flush any on-going hotplug processing
before removing the remaining interfaces.
This fixes crashes due to host-device removal racing with svc
hotplug/unplug processing (e.g. at "UniPro restart").
Testing Done:
Verified that this fixes crashes reproducible on SDB when unloading the
host-device driver module while generating hotplug/unplug events.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Viresh Kumar [Wed, 27 Jan 2016 05:47:00 +0000 (11:17 +0530)]
greybus: audio: Rename Audio class and remove the unused one
There should be a single class macro for Audio and two protocol macros.
Rename class with value 0x12 as GREYBUS_CLASS_AUDIO and remove the other
unused class GREYBUS_CLASS_AUDIO_DATA.
Viresh Kumar [Wed, 27 Jan 2016 11:27:48 +0000 (16:57 +0530)]
greybus: audio_codec: convert to bundle driver
Convert the legacy audio management and data protocol drivers to a
bundle driver.
The Audio bundle driver can support a single management and any number
of data cports, and so we expect multiple data cports to be present for
the bundle during initialization.
When gb_protocol_get() fails in legacy_connection_create(), we end up
bailing-out before assigning lc->connection and lc->protocol. Calling
legacy_connection_destroy() in that case results in a null pointer
dereference.
Check if lc->connection is not null before freeing it.
greybus: svc watchdog: allow it to be enabled/disabled from userspace
Sometimes you want to disable the SVC watchdog without having to patch
your kernel, so provide a sysfs file to do this. This can let us do
power measurements, and let the firmware developers not go crazy
worrying that the kernel is going to reset their chips with no notice.
greybus: camera: only build module against msm kernel
The camera driver currently does not build against anything other than
the msm kernel, due to cross-dependancies, so enable that here so that
we can build against other kernels without failing the build.
Sometimes the ping response comes back _right_ after we timed out, as
the svc got its act together and squeaked out the ack, yet we miss it
and reset the whole bus. Double the delay to hopefully give the svc a
little more of a chance to fix itself. Odds are, it's still in trouble,
but we can just hold off resetting it for a bit more...
Vaibhav Hiremath [Tue, 26 Jan 2016 01:53:29 +0000 (07:23 +0530)]
greybus: arche-platform: Disable clock as part of driver remove
As part of driver remove (cleanup) function, disable the clock for both
SVC, APB1 & APB2.
Testing Done:
Tested on EVT1 platform with Connect=>disconnect=>connect
iteration, almost close to 100 iterations have passed (demo branch).
And also tested with kernel-only build.
Unipro network speed was increased at camera initialization time and
never slowed down.
This unnecessary drains power during the entire time camera module is
plugged in.
Increasing/decreasing unipro link speed before issuing stream
configuration request to camera module prevents this from happening.
greybus: svc: add a "watchdog" to check the network health
Now that we have a svc ping command, let's add a watchdog to call it
every so often (1 second at the moment.) If it finds something went
wrong, post a stern message to the kernel log and call:
start unipro_reset
to reset the whole greybus hardware subsystem.
Viresh Kumar [Fri, 22 Jan 2016 10:46:08 +0000 (16:16 +0530)]
greybus: svc: Expose and retain VID/PID received from bootrom for ES2
ES2 chips doesn't have efuses for storing module's vendor_id and
product_id and so we have hacked bootrom earlier using firmware
protocol, so that VID/PID can be received for fetching firmware
packages.
Another requirement is to expose them to sysfs, so that modules can be
identified properly.
That can be easily solved by updating interface's VID/PID, when fetched
using firmware protocol and later reusing them while the module switches
its identity from bootrom to firmware.
Do that only if the module is ES2 and the VID/PID sent during hotplug
are both 0.
Horrid hack, but a start at making it easier for people to see what is
currently connected without having to deal with poking around in sysfs
directly.
Vaibhav Agarwal [Thu, 21 Jan 2016 17:03:13 +0000 (22:33 +0530)]
greybus: audio_codec: update codec_name as per driver->name
Originally, driver->name was not poluated from GB and thus
manually set from audio_codec driver as a hack.
This is no more required.
Another patch already removes that hack.
Now, with new driver->name as "legacy.<id-bundle.interface>"
codec is registered with different name.
So, during DAI link registration as well it needs modification.
Johan Hovold [Thu, 21 Jan 2016 16:34:20 +0000 (17:34 +0100)]
greybus: legacy: look up protocol at connection creation
Look up legacy protocol at connection create instead of at init.
Note that we can now look up the protocol before even creating the
actual connection. This is needed to be able to set a connection request
handler when creating the connection rather than when enabling it.
Johan Hovold [Thu, 21 Jan 2016 16:34:13 +0000 (17:34 +0100)]
greybus: connection: drop the legacy protocol-id parameter
The protocol-id parameter is only used by the legacy driver so remove
it from the generic interface and move it to the legacy driver until it
can be removed completely.
Johan Hovold [Thu, 21 Jan 2016 16:34:10 +0000 (17:34 +0100)]
greybus: manifest: check for duplicate CPort descriptors when parsing
Now that connection creation has been separated from interface
initialisation, we should explicitly check for duplicate CPort
descriptors when parsing the manifest.
Johan Hovold [Thu, 21 Jan 2016 16:34:09 +0000 (17:34 +0100)]
greybus: core: defer connection creation to driver probe
Defer connection creation to bundle driver probe instead of creating
them when initialising the interface and parsing the manifest.
Store copies of the CPorts descriptors in the bundle for the drivers to
use, and update the legacy driver.
This is needed for drivers that need more control over host-device
resource management, for example, when a protocol needs to use a
dedicated host CPort for traffic offloading (e.g. camera data).
This also avoids allocating host CPorts for bundles that are not bound
to a driver or for remote CPorts that a driver does not need.
When bundles are added and then removed, we have a race where we go to
read the sysfs file, but it is now for a different bundle than the
uevent was originally for. So add the bundle class to the uevent so we
"know" what the correct bundle class was.
greybus: firmware: log the name of the firmware being requested
People are getting confused as to what the firmware file name is for
their module, so log it to make it easier to find modules with "blank"
vid/pid values and let people know what to name their firmware files.
Because we are now logging this, turn the debug message after the
firmware request into an error message if something fails.
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Michael Scott <michael.scott@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Rui Miguel Silva [Thu, 21 Jan 2016 01:42:17 +0000 (01:42 +0000)]
greybus: svc: add key event handling
Add a new input device associated with the SVC to handle key events.
This new events are transfer over a new greybus svc operation which is
unidirectional.
It was selected the KEY_A for representing the KEY_ARA_BUTTON key code.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: audio_codec: Don't be tricky with the driver model
With the recent changes by Johan to the driver model of the greybus
code, the audio_codec no longer should need to provide a "dummy" driver
when registering the codec. In fact, having it there causes the greybus
core to crash when inserting the module. Removing it all fixes the
crash.
Serialise connection creation against concurrent creation and
destruction using a global mutex.
This is needed to prevent two drivers from attempting to create a
connection to the same interface CPort and to cope with a racing
connection destroy when moving to driver managed connections.
Note that the locking can not (easily) be made more fine-grained as not
all connections have an interface, but these are not hot paths anyway.
Johan Hovold [Tue, 19 Jan 2016 11:51:25 +0000 (12:51 +0100)]
greybus: connection: fix lookup race
Fix longstanding race that could lead to a connection being destroyed
while processing an incoming message due to missing reference counting
when looking up the connection.
Johan Hovold [Tue, 19 Jan 2016 11:51:24 +0000 (12:51 +0100)]
greybus: connection: drop the connection_mutex
Drop the useless connection_mutex that did not, and can not be used to
prevent connection lookup races in atomic context and therefore serves
no purpose.
Johan Hovold [Tue, 19 Jan 2016 11:51:23 +0000 (12:51 +0100)]
greybus: connection: destroy workqueue at unregister
Destroy the work queue when the connection is destroyed/deregistered
instead of when the last reference is dropped.
The work queue is not needed once the connection has been deregistered,
and no operations will ever be added to it again (handled by checking
connection->state) even if the connection object may not be deallocated
until the final reference is dropped.
The work-queue name is set based on the host-device name and host-device
cport id, something which guarantees a unique name. This would no longer
be true if the work queue was not destroyed at connection deregistration
as a new connection could then be created for that very same host cport.
This is not necessarily a problem unless some work queue features are
used that require unique work-queue names, but let's try to be well
behaved.
Also update an obsolete comment and make explicit that a connection must
be disabled before being destroyed.
Remove the broken legacy protocol-version handling from core and move it
to the legacy driver instead.
Note that version handling has always been broken as legacy protocols
were looked up and bound to connections before the connections were
enabled and version negotiation could take place (over that very
connection). Document that in the legacy driver as well.
Johan Hovold [Tue, 19 Jan 2016 11:51:16 +0000 (12:51 +0100)]
greybus: connection: move legacy-protocol handling to legacy driver
Move legacy protocol and connection handling to the legacy driver.
Rename the former global functions using a common legacy_ prefix.
Note that all legacy protocols suffer from a connection initialisation
race in that the protocol-specific initialisation, which includes
allocation of protocol-specific state containers, can not happen until
*after* the connection has been enabled. This is a major flaw in the
original design that we can now finally address by converting the legacy
protocol drivers into proper bundle (class) drivers.
Johan Hovold [Tue, 19 Jan 2016 11:51:14 +0000 (12:51 +0100)]
greybus: control: drop legacy-protocol dependency
Drop dependency on the legacy protocol abstraction.
Instead implement the protocol-specific version request directly, and
use the new interface for managing the control connection.
Note that the version request is being removed from most protocols, but
we need to keep the current request for the control protocol as-is
indefinitely to maintain backwards compatibility (e.g. with the ES2/ES3
bootrom).
Johan Hovold [Tue, 19 Jan 2016 11:51:13 +0000 (12:51 +0100)]
greybus: greybus_protocols: remove control-protocol version
Remove control-protocol version from the exported protocol definitions
as it is an implementation detail that makes no sense to export.
Currently gbsim uses the kernel's control-protocol version definitions
directly instead of reporting the version of the protocol it actually
implements.
Johan Hovold [Tue, 19 Jan 2016 11:51:11 +0000 (12:51 +0100)]
greybus: firmware: remove skip-disconnected flag
Remove the legacy protocol flag that was used to suppress sending the
control disconnected operation.
Instead rely on the fact that no control operations will be sent by
core to an interface that has been removed (e.g. after having received a
new hotplug event after the bootrom has jumped to the new image).
Johan Hovold [Tue, 19 Jan 2016 11:51:10 +0000 (12:51 +0100)]
greybus: core: add defensive connection disable post disconnect
Bundle drivers *must* disable their connections in the disconnect
callback, but add a defensive test and warn about buggy drivers
nonetheless.
Note that bundle drivers would generally release their state containers
in disconnect so a failure stop I/O could potentially lead to
use-after-free bugs in any late operation completion callbacks.
Johan Hovold [Tue, 19 Jan 2016 11:51:09 +0000 (12:51 +0100)]
greybus: core: disable incoming operations pre disconnect
Disable and flush incoming operations before calling driver disconnect.
Bundle drivers are still responsible for disabling their connections
in their disconnect callback.
Note that specifically the legacy protocols must have incoming
operations disabled when their connection_exit callback is called as
that is where their state is deallocated.
Johan Hovold [Tue, 19 Jan 2016 11:51:08 +0000 (12:51 +0100)]
greybus: connection: add helper to disable incoming operations
Add helper to disable and flush incoming operations.
This is intended to be used by core to flush any incoming requests
before calling driver disconnect, but could potentially later be
exported for driver use as well.
Note that we currently flush all incoming operation and allow the
request handlers to run, but cancel any responses sent. This may need to
be refined later.
Add a connection request-handler field to struct gb_connection that is
set when the connection is enabled.
This is a step towards removing the legacy protocol abstraction from
core, and will also be used to implement unidirectional connection
states (e.g. only outgoing operations are allowed).
Add the first Greybus bundle driver that will be used when transitioning
from legacy Greybus protocols to bundle drivers.
The legacy-protocol driver initially binds to all current bundle classes.
In order to avoid having to update current module-loading scripts, keep
this driver internal to greybus core at least until modalias support is
added. Note that this prevents unloading any protocol drivers without
first tearing down the host device due to a circular module dependency.
greybus: camera: Update configure stream based on new interface
Interface has been changed.
return code will not return number of configured streams but
just error code.
Number of streams is passed as pointer and if operation result
is changed number of streams will be updated.
Flags are also used for information regarding configure stream
operation result.
greybus: camera: Add support for configure streams flag in gb interface
Update gb interface and export flags needed for latest
protocol version. Number of streams also can be changed
based on operation result.
Caller sets input flags, end fucntion return output
flags
Input flags supported:
- GB_CAMERA_IN_FLAG_TEST - Need to be set when operation
is not actually applied.
Output flags supported:
- GB_CAMERA_OUT_FLAG_ADJUSTED - This is result of the operation
if this flag is set, result is adjusted and operation
need to be repeat.
Michael Scott [Fri, 15 Jan 2016 22:03:17 +0000 (14:03 -0800)]
greybus: firmware: replace colons with underscore in firmware file request
Due to some issues with handling colons in Android (and possibly
future exposure to other problems) we should remove the colons from
the firmware file request. Replacing them with underscores.
There is a colon delimiter between the source and destination in the
PRODUCT_COPY_FILES format. The greybus naming logic breaks the parsing
routine and generates an Android build break.
Signed-off-by: Michael Scott <michael.scott@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
greybus: camera: Fix backword compatibility in configure streams
Configure streams ret code should be number of streams in
gb operation exported to HOST camera.
Until gb operation is migrated to new interface return
number of streams in ret code.
Laurent Pinchart [Thu, 14 Jan 2016 23:33:55 +0000 (01:33 +0200)]
greybus: camera: Return the result flags from the configure_streams response
And return the response num_streams field through a pointer variable
instead of using the return value of the function as both an error code
and a positive number of streams, it makes the API more consistent.
Vaibhav Agarwal [Wed, 13 Jan 2016 21:07:56 +0000 (14:07 -0700)]
greybus: audio: Enable codec module detection on different slots
driver_name associated with dev_name was hard coded earlier.
This limits, audio codec module to be detected on Port#5 only.
Now, driver_name is generated dynamically based on dev_name.
This enables codec module detection on any 1x2 slot.
Also, Update dev_id based on slot number, instead of bundle->id.
bundle->id is not unique for multiple modules added, thus now
using slot number for unique identification.
Vaibhav Agarwal [Wed, 13 Jan 2016 21:07:55 +0000 (14:07 -0700)]
greybus: audio: Cleanup GB protocol connections in case of abrupt codec removal
We need to clean up GB protocl connections, otherwise successive
codec insertions fails repeatedly.
NOTE: As per suggestion, since codec is already removed, one should
not trigger any GB command. It'll cause a delay of atleast TIMEOUT
value.
HOwever, failing to cleanup GB protocol, causes successive module
insertion to fail
Vaibhav Agarwal [Wed, 13 Jan 2016 21:07:52 +0000 (14:07 -0700)]
greybus: audio: Add GB Audio class protocol functionality in GB codec DAI ops
GB Audio class driver provides APIs to configure GB codec module.
This patch adds relevant operations in DAI ops callback functions to
configure codec module as per DAPM sequence triggered.
Vaibhav Agarwal [Wed, 13 Jan 2016 21:07:51 +0000 (14:07 -0700)]
greybus: audio: Add topology parser for GB codec
For each GB codec module inserted, DAPM widgets, kcontrols, routes
and DAIs can be fetched through greybus in a binary chunk and parsed
locally to create & populate DAPM graph for the specific module.
It is required by each codec module to populate a minimum set of
kcontrols with fixed names to support basic audio usecase.
To support advanced features of codec module, the same can be polpulated
with existing topology parser. However, to use them for different usecase
separate mechanism (may be via MSP) is required to inform userspace about
their configuration value & enable/disable sequence.
ToDos:
Currently, support for enumerated kcontrol/dapm control is hardcoded.
Need to add complete logic within the parser.
Vaibhav Agarwal [Wed, 13 Jan 2016 21:07:50 +0000 (14:07 -0700)]
greybus: audio: Use greybus connection device for codec registration
Use GB Audio mgmt, data protocol ids to register codec module with
GB protocol. And in response to mgmt->connection_init(), register
GB codec driver with ASoC.
Now, using msm8994 machine to register DAI link dynamically on
codec insertion.
ToDos:
- snd_soc_register_codec() uses driver->name to identify device id.
However, for GB device, .driver{} is not yet populated by GB core.
Thus, defining dummy structure within codec driver. This should
come from GB core itself.
Even existing .driver{} may cause problem in case of multiple
modules inserted or inserted at a different slot.
- Fix logic for gbcodec->dais & gbcodec->dailinks. Current
implementation contains some hard coded data with assumption of
count=1.
- Evaluate definition of 'gbaudio_dailink.be_id' in case of multiple
DAI links.
Vaibhav Agarwal [Wed, 13 Jan 2016 21:07:49 +0000 (14:07 -0700)]
greybus: audio: Build audio module conditionally
Added CONFIG_XXX flag check before compiling audio module.
Once we add dynamic DAI link registration from audio driver,
this check wil be required to avoid compilation failures with
other kernel revisions.
Also, renamed header file to better align with .c file name.
Mark Greer [Wed, 13 Jan 2016 21:07:47 +0000 (14:07 -0700)]
greybus: audio: Add direct audio streaming control for APBridgeA
The latest audio architecture does not stream audio data over the
USB link between the AP and APBridgeA. Instead, audio data is
streamed directly over the I2S link between the two.
To support the Greybus audio driver in setting up the I2S port and
controling packeting/depacketizing of audio data to/from Greybus
audio messages, define a set of commands and their parameters.
These commands and parameters will be placed into a request and sent
over the USB control channel to APBridgeA. A corresponding driver
on APBridgeA will receive and process the requests.
Signed-off-by: Mark Greer <mgreer@animalcreek.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Vaibhav Hiremath [Wed, 13 Jan 2016 20:36:47 +0000 (02:06 +0530)]
greybus: arche-apb-ctrl: Enable the clocks after regulator enable
It makes more sense to enable the clock after power is enabled
to the device, so move clock enable code after regulator_enable
and setting up BOOT_RET pin.
Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org> Tested-by: Michael Scott <michael.scott@linaro.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org> Tested-by: Laurent Pinchart <laurent.pinchart@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Gb camera need to communicate with HOST driver.
as temporary solution there will be shared header
between gb camera HOST camera.
Both need to be in sync since gb drivers are compiled
out of the kernel tree.
Gb camera register camera operation functions when is created.
Currently unregister is not supported.
Rui Miguel Silva [Tue, 12 Jan 2016 14:35:49 +0000 (14:35 +0000)]
greybus: lights: remove sync operation and work queue
In kernel v4.5 there is a change in LED api, which remove the need for
individual work queue and rename the set_sync operation to set_blocking.
This patch add the handling of this case and avoid compilation failure
for this kernel versions.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Rui Miguel Silva [Tue, 12 Jan 2016 14:35:48 +0000 (14:35 +0000)]
greybus: kernel_ver: add handle for lights in 4.5
In v4.5 the LED API is changed related to the set brightness
operations, set_sync is removed and the workqueue handling is now done
by leds core, so no need for individual drivers to have one.
This will be done by removing the SET_SYNC macro and add a new
SET_BLOCKING.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This adds the GREYBUS_ID environment variable to all interface uevents
to let userspace know the vendor/product id of the module interface that
has been added or removed from the system.