platform/kernel/linux-rpi.git
8 years agogreybus: connection: make cport lookup thread-safe
Johan Hovold [Tue, 19 Jan 2016 11:51:27 +0000 (12:51 +0100)]
greybus: connection: make cport lookup thread-safe

Use the gb_connection_mutex when making sure a remote CPort is
available.

This is needed when moving to driver-managed connections that can be
created and destroyed at any time.

Also check for duplicate bundle-less connections.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: serialise connection creation
Johan Hovold [Tue, 19 Jan 2016 11:51:26 +0000 (12:51 +0100)]
greybus: connection: serialise connection creation

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.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: fix lookup race
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.

Add helpers to manipulate the connection kref.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: drop the connection_mutex
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.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: destroy workqueue at unregister
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.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: remove WARN_ON from destroy
Johan Hovold [Tue, 19 Jan 2016 11:51:22 +0000 (12:51 +0100)]
greybus: connection: remove WARN_ON from destroy

Remove WARN_ON from connection destroy testing for a NULL-connection
when destroying a connection.

This will allow for simpler driver code when releasing driver-managed
connections.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: control: add bundle-version operation
Johan Hovold [Tue, 19 Jan 2016 11:51:21 +0000 (12:51 +0100)]
greybus: control: add bundle-version operation

Add bundle-version operation to fetch the version of the bundle class.

Retrieve the bundle version of all bundles when initialising the
interface in case the control-protocol version is greater than 0.1.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: remove broken protocol-version handling
Johan Hovold [Tue, 19 Jan 2016 11:51:20 +0000 (12:51 +0100)]
greybus: connection: remove broken protocol-version handling

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.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: svc: store protocol version
Johan Hovold [Tue, 19 Jan 2016 11:51:19 +0000 (12:51 +0100)]
greybus: svc: store protocol version

Store the "negotiated" protocol version to use in the svc state
struct instead of the connection struct.

The generic concept of a connection version is going away in favour of
bundle-class versions.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: core: disable bundle connections on hot-unplug
Johan Hovold [Tue, 19 Jan 2016 11:51:18 +0000 (12:51 +0100)]
greybus: core: disable bundle connections on hot-unplug

Disable bundle connections in core before calling driver disconnect in
case the interface is already gone.

This avoids unnecessary timeouts on hot-unplug when a driver does I/O in
its disconnect callback.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: legacy: use protocol pointer to determine state
Johan Hovold [Tue, 19 Jan 2016 11:51:17 +0000 (12:51 +0100)]
greybus: legacy: use protocol pointer to determine state

Use the protocol pointer to determine the legacy connection state.

This is needed to allow core disable connections when an interface has
been hot-unplugged without the legacy protocols leaking its resources.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: move legacy-protocol handling to legacy driver
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.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: svc: drop legacy-protocol dependency
Johan Hovold [Tue, 19 Jan 2016 11:51:15 +0000 (12:51 +0100)]
greybus: svc: drop legacy-protocol dependency

Drop dependency on the legacy protocol abstraction.

Remove the now unused and last legacy-protocol flag
GB_PROTOCOL_SKIP_VERSION along with the protocol-flag feature.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: control: drop legacy-protocol dependency
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).

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: greybus_protocols: remove control-protocol version
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.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: remove skip-connected legacy protocol flags
Johan Hovold [Tue, 19 Jan 2016 11:51:12 +0000 (12:51 +0100)]
greybus: connection: remove skip-connected legacy protocol flags

Remove the legacy protocol flags that were used to suppress the
connected and disconnected events.

Instead send the connected and disconnected event for all bundle
connections and explicitly exclude static connections and control
connections.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: firmware: remove skip-disconnected flag
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).

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: core: add defensive connection disable post disconnect
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.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: core: disable incoming operations pre disconnect
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.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: add helper to disable incoming operations
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.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: add unidirectional enabled state
Johan Hovold [Tue, 19 Jan 2016 11:51:07 +0000 (12:51 +0100)]
greybus: connection: add unidirectional enabled state

Add a new connection state ENABLED_TX in which only outgoing operations
are allowed.

This allows drivers to query the device during probe before allocating
their state containers without having to worry about racing incoming
requests.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: make connection enable/disable thread safe
Johan Hovold [Tue, 19 Jan 2016 11:51:06 +0000 (12:51 +0100)]
greybus: connection: make connection enable/disable thread safe

Add connection mutex to protect connection enabling and disabling.

This is needed to eventually allow drivers to manage the state of their
connections during operation (i.e. post probe and pre disconnect).

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: disable operations on enable errors
Johan Hovold [Tue, 19 Jan 2016 11:51:05 +0000 (12:51 +0100)]
greybus: connection: disable operations on enable errors

Make sure to cancel all (incoming) operations when failing to enable a
connection.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: clean up operation cancellation on disable
Johan Hovold [Tue, 19 Jan 2016 11:51:04 +0000 (12:51 +0100)]
greybus: connection: clean up operation cancellation on disable

Move helper to cancel active operations above gb_connection_enable and
simplify locking.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: always cancel operations on connection disable
Johan Hovold [Tue, 19 Jan 2016 11:51:03 +0000 (12:51 +0100)]
greybus: connection: always cancel operations on connection disable

Always cancel all operations on connection disable and remove the now
unused DESTROYING state.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: add per-connection request handlers
Johan Hovold [Tue, 19 Jan 2016 11:51:02 +0000 (12:51 +0100)]
greybus: connection: add per-connection request handlers

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).

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: remove disable from destructor
Johan Hovold [Tue, 19 Jan 2016 11:51:01 +0000 (12:51 +0100)]
greybus: connection: remove disable from destructor

Remove implicit disable of legacy connections from the destructor.

This is a step towards removing the legacy-protocol handling from core.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: rename legacy init and exit functions
Johan Hovold [Tue, 19 Jan 2016 11:51:00 +0000 (12:51 +0100)]
greybus: connection: rename legacy init and exit functions

Rename legacy connection init and exit functions.

This is a step towards removing the legacy-protocol handling from core.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: legacy: add legacy-protocol bundle driver
Johan Hovold [Tue, 19 Jan 2016 11:50:59 +0000 (12:50 +0100)]
greybus: legacy: add legacy-protocol bundle driver

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.

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Update configure stream based on new interface
Gjorgji Rosikopulos [Sun, 17 Jan 2016 17:52:21 +0000 (19:52 +0200)]
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.

Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Add support for configure streams flag in gb interface
Gjorgji Rosikopulos [Sun, 17 Jan 2016 17:52:20 +0000 (19:52 +0200)]
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.

Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: firmware: replace colons with underscore in firmware file request
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.

Specifically, we copy firmware into the Android build using a line
similar to this:
PRODUCT_COPY_FILES += \
    source-repo/ara:00000126:00001000:00000001:00000001:02.tftf:system/etc/firmware/ara:00000126:00001000:00000001:00000001:02.tftf

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>
8 years agogreybus: Revert "camera: Fix backword compatibility in configure streams"
Greg Kroah-Hartman [Fri, 15 Jan 2016 22:41:02 +0000 (14:41 -0800)]
greybus: Revert "camera: Fix backword compatibility in configure streams"

This reverts commit 48cc91e52dba9abad4c9b56f911994c65071bfc4 as the
caller should be changed instead.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Fix backword compatibility in configure streams
Gjorgji Rosikopulos [Fri, 15 Jan 2016 19:34:56 +0000 (21:34 +0200)]
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.

Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Return the result flags from the configure_streams response
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.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Enable codec module detection on different slots
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.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Cleanup GB protocol connections in case of abrupt codec removal
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

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: cleanup unnecessary dev_err messages
Vaibhav Agarwal [Wed, 13 Jan 2016 21:07:54 +0000 (14:07 -0700)]
greybus: audio: cleanup unnecessary dev_err messages

Replace unnecessary dev_err msg with dev_dbg.
Same were added during development to trace topology
parser progress.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Report uevent on GB codec module insertion/removal
Vaibhav Agarwal [Wed, 13 Jan 2016 21:07:53 +0000 (14:07 -0700)]
greybus: audio: Report uevent on GB codec module insertion/removal

GB-Audio-manager module is currently used to report uevent
to above layer in response to any codec module inserted or
removed.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Add GB Audio class protocol functionality in GB codec DAI ops
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.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Add topology parser for GB codec
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.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Use greybus connection device for codec registration
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.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: Makefile: fix up build test for gb-audio-codec.ko
Greg Kroah-Hartman [Thu, 14 Jan 2016 00:18:36 +0000 (16:18 -0800)]
greybus: Makefile: fix up build test for gb-audio-codec.ko

We really only want to build the module if the config is set, not all
the time like the current code does.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Build audio module conditionally
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.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Add Audio Manager
Svetlin Ankov [Wed, 13 Jan 2016 21:07:48 +0000 (14:07 -0700)]
greybus: audio: Add Audio Manager

This is a simple module that keeps a list of connected GB audio
modules.

Whenever a device is attached, an appropriate uevent is sent to
userspace:

    UDEV  [4941.803215] add      /kernel/gb_audio_manager/0 (gb_audio_manager)
    ACTION=add
    CPORT=99
    DEVICES=0x10
    DEVPATH=/kernel/gb_audio_manager/0
    NAME=naim
    PID=64
    SEQNUM=1828
    SLOT=2
    SUBSYSTEM=gb_audio_manager
    USEC_INITIALIZED=802416
    VID=128

And whenever removed:

    UDEV  [4941.836588] remove   /kernel/gb_audio_manager/0 (gb_audio_manager)
    ACTION=remove
    DEVPATH=/kernel/gb_audio_manager/0
    SEQNUM=1833
    SUBSYSTEM=gb_audio_manager
    USEC_INITIALIZED=835681

The API consists of functions for adding, removing and inspecting
added device module descriptions (struct gb_audio_module):

    int                         gb_audio_manager_add(struct gb_audio_module_descriptor *desc);
    int                         gb_audio_manager_remove(int id);
    int                         gb_audio_manager_remove_all(void);
    struct  gb_audio_module*    gb_audio_manager_get_module(int id);
    void                        gb_audio_manager_put_module(struct gb_audio_module *module);
    int                         gb_audio_manager_dump_module(int id);
    void                        gb_audio_manager_dump_all(void);

Devices can be inspected through sysfs in /sys/kernel/gb_audio_manager/{id}/*

If GB_AUDIO_MANAGER_SYSFS is exported as 'true', managing devices can be done
via the SYSFS as well. For instance:

    echo name=naim slot=2 vid=128 pid=64 cport=99 devices=0x10 > /sys/kernel/gb_audio_manager/add
    echo all > /sys/kernel/gb_audio_manager/dump
    echo 2 > /sys/kernel/gb_audio_manager/dump
    echo 2 > /sys/kernel/gb_audio_manager/remove

Signed-off-by: Svetlin Ankov <ankov_svetlin@projectara.com>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Add direct audio streaming control for APBridgeA
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>
8 years agogreybus: audio: Add Greybus Audio Device Class Protocol helper routines
Mark Greer [Wed, 13 Jan 2016 21:07:46 +0000 (14:07 -0700)]
greybus: audio: Add Greybus Audio Device Class Protocol helper routines

Add helper routines to make communicating with audio modules easier.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Add Audio Device Class Protocol definitions
Mark Greer [Wed, 13 Jan 2016 21:07:45 +0000 (14:07 -0700)]
greybus: audio: Add Audio Device Class Protocol definitions

Add the macros and structures for the Greybus Audio Device
Class Protocol.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Use underscore in file name
Mark Greer [Wed, 13 Jan 2016 21:07:44 +0000 (14:07 -0700)]
greybus: audio: Use underscore in file name

For consistency with most other files in the Greybus repository,
change 'audio-codec.c' to use an underscore instead of a hyphen
in its name.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Enable the clocks after regulator enable
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>
8 years agogreybus: camera: HACK: Register gb camera to the HOST camera
Gjorgji Rosikopulos [Wed, 13 Jan 2016 19:52:38 +0000 (21:52 +0200)]
greybus: camera: HACK: Register gb camera to the HOST camera

This change implements gb camera interface and register
gb camera to the HOST driver.
This implementation need to be reworked after the demo.

Tested with db3 with two camera modules.

Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: HACK: Export GB camera interface
Gjorgji Rosikopulos [Wed, 13 Jan 2016 19:52:37 +0000 (21:52 +0200)]
greybus: camera: HACK: Export GB camera interface

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.

Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: lights: remove sync operation and work queue
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>
8 years agogreybus: kernel_ver: add handle for lights in 4.5
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>
8 years agogreybus: uevent: add GREYBUS_ID to uevent
Greg Kroah-Hartman [Tue, 12 Jan 2016 03:24:54 +0000 (19:24 -0800)]
greybus: uevent: add GREYBUS_ID to uevent

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.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
8 years agogreybus: makefile: add requirement for CONFIG_INPUT
Rui Miguel Silva [Wed, 13 Jan 2016 14:39:55 +0000 (14:39 +0000)]
greybus: makefile: add requirement for CONFIG_INPUT

To support key events coming from the svc (ara key) it is needed to add
the input core as an required config option.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: refactor connection enable and disable
Johan Hovold [Fri, 8 Jan 2016 19:13:46 +0000 (20:13 +0100)]
greybus: connection: refactor connection enable and disable

Refactor connection enable and disable.

This is a step towards removing the legacy-protocol handling from core.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: fix connection-state handling
Johan Hovold [Fri, 8 Jan 2016 19:13:45 +0000 (20:13 +0100)]
greybus: connection: fix connection-state handling

Set connection state to ENABLE before sending the control connected
message, and set state DISABLE after sending the control disconnected
event.

Remove the now unused ERROR connection state.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: svc: add intf_eject attribute
Rui Miguel Silva [Mon, 11 Jan 2016 13:46:33 +0000 (13:46 +0000)]
greybus: svc: add intf_eject attribute

Add a new write-only svc attribute to send an eject request to the svc
giving the interface number.

So, doing:
echo 3 > /sys/bus/greybus/devices/1-svc/intf_eject

will force eject the module on interface 3 (module slot 1 on EVT1).
This can take some seconds as the pulse width for module release is
large.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
8 years agogreybus: svc: add interface eject operation
Rui Miguel Silva [Mon, 11 Jan 2016 13:46:31 +0000 (13:46 +0000)]
greybus: svc: add interface eject operation

Add a new svc operation which will be used to send a request to eject a
given interface.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
8 years agogreybus: power_supply: fix check for configured supply
Rui Miguel Silva [Tue, 12 Jan 2016 14:38:21 +0000 (14:38 +0000)]
greybus: power_supply: fix check for configured supply

The correct check for if the power supply is ready to receive event is
wrong and it should check for the registered flag.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: APBridge: move APBridge request protocol to a common .h file
Greg Kroah-Hartman [Thu, 31 Dec 2015 19:14:33 +0000 (11:14 -0800)]
greybus: APBridge: move APBridge request protocol to a common .h file

This moves all of the APBridge request protocol commands that are
currently used to a common .h file for everyone to be able to use them
in the future, where needed.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Tested-by: Mark Greer <mgreer@animalcreek.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
8 years agogreybus: host: provide "generic" apbridge output calls
Greg Kroah-Hartman [Wed, 23 Dec 2015 02:21:51 +0000 (18:21 -0800)]
greybus: host: provide "generic" apbridge output calls

Provide a new function, gb_hd_output() to send data to the apbridge.
This is useful for the camera and audio drivers that need to do this
type of messaging.

The camera driver is converted to use this new function, the audio
driver can use it when it gets merged later.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Tested-by: Mark Greer <mgreer@animalcreek.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
8 years agogreybus: power_supply: fix use after free of power supply
Rui Miguel Silva [Fri, 8 Jan 2016 13:53:47 +0000 (13:53 +0000)]
greybus: power_supply: fix use after free of power supply

Individual power supply were being freed and checked using the wrong
pointers and at the wrong place, which would make several issues, like
used after free and so on.
Fix it by freeing all allocated memory after release individual power
supply.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: power_supply: fix leak getting string properties
Rui Miguel Silva [Fri, 8 Jan 2016 13:53:46 +0000 (13:53 +0000)]
greybus: power_supply: fix leak getting string properties

When fetching string properties, memory was being allocated and leaked
when it was not necessary to do so.

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>
8 years agogreybus: power_supply: fix error path at supplies setup
Rui Miguel Silva [Fri, 8 Jan 2016 13:53:45 +0000 (13:53 +0000)]
greybus: power_supply: fix error path at supplies setup

If something goes wrong at setup time for the supplies, we need to
release all the resources allocated already.

Call the supplies release function which will handle the correct
teardown of the supplies.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: power_supply: free supplies at release
Rui Miguel Silva [Fri, 8 Jan 2016 13:53:44 +0000 (13:53 +0000)]
greybus: power_supply: free supplies at release

After freeing each individual power_supply, free the top controller, if
not it will leak memory at each module insert/remove.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: power_supply: fix unregister on error path
Rui Miguel Silva [Fri, 8 Jan 2016 13:53:43 +0000 (13:53 +0000)]
greybus: power_supply: fix unregister on error path

If setup fail the release for each supply needs to know the status at
unregister time. So, add the field to the structure, update it at setup
time and use it at release.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: power_supply: do not release failed supply alloc
Rui Miguel Silva [Fri, 8 Jan 2016 13:53:42 +0000 (13:53 +0000)]
greybus: power_supply: do not release failed supply alloc

If allocation of memory for each supply fail, we should get out of
release any individual supply.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: power_supply: fix lock imbalance in init error path
Johan Hovold [Thu, 7 Jan 2016 11:28:29 +0000 (12:28 +0100)]
greybus: power_supply: fix lock imbalance in init error path

Make sure to release the supplies_lock before returning on errors in
gb_power_supplies_setup().

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Add wake/detect support along with handshaking with AP
Vaibhav Hiremath [Mon, 11 Jan 2016 12:11:24 +0000 (17:41 +0530)]
greybus: arche-platform: Add wake/detect support along with handshaking with AP

Add wake_detect support to arche-platform driver which is responsible
for SVC control. This patch also adds code for handshaking between
AP <=> SVC. The sequence is,

1.   AP boots
     To keep compatibility between DB3 and EVT platform, SVC will be
     help in reset and AP driver would release it at appropriate time.
 wake/detect pin (WD8A) = Low
 reset (SVC/APB1/APB2) = Asserted (as per polarity)
2.   AP Driver gets inserted
  2.1. AP will deassert reset to SVC (following power on sequence)
  2.2. SVC allows 360 milliseconds to elapse after switch boots to work
       around bug described in ENG-330.
  2.3. AP asserts wake/detect pin (WD8A = HIGH)
3.   SVC detects assertion of wake/detect pin, and sends "wake out" signal to AP
4.   AP receives "wake out" signal, takes AP Bridges through their power
     on reset sequence as defined in the bridge ASIC reference manuals
5.   AP takes USB3613 through its power on reset sequence
6.   AP should enumerates AP Bridges

Note: ISR has been deliberately removed (not merged) as we are still
not sure how it will be used, in runtime usage context. Driver as such
doesn't do anything for runtime assert-n-deassert of reset to SVC/APB's,
it just simply offloads it to user by exporting required gpio's.
The exported gpio's are required for FW flashing from user space.
When it comes to usersace manipulated control sequence, user has to manage.

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>
8 years agogreybus: arche-apb-ctrl: deassert reset at the end of probe
Vaibhav Hiremath [Mon, 11 Jan 2016 12:11:23 +0000 (17:41 +0530)]
greybus: arche-apb-ctrl: deassert reset at the end of probe

Now the complete handshaking between AP<=>SVC would be
offloaded to parent driver (arche-platform) who is
responsible for SVC control, so the apb-ctrl driver can
just simply bring APB's out of reset during probe itself.

Along with deasserting reset, this patch renames the local fn
to exclusively use it for reset purpose.

Note that, driver is exporting reset gpio to
user, so user can still flash FW from prompt.

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>
8 years agogreybus: arche-apb-ctrl: Remove wake_detect gpio and related code
Vaibhav Hiremath [Mon, 11 Jan 2016 12:11:22 +0000 (17:41 +0530)]
greybus: arche-apb-ctrl: Remove wake_detect gpio and related code

With TIME_SYNC functionality, assignment of wake/detect pin
will change,
  WD_8A => to bring APB's out of reset
  WD_8B => TIME_SYNC operation

So in order to support this, we can no longer keep wake_detect
gpio in apb-ctrl driver. So remove it.
In the subsequent patches, wake_detect support will be added
to parent SVC driver (arche-platform) who is responsible for SVC control.

Note that, this patch also removes ISR related code.
The APB state still is maintained, for future use.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche: Remove unwanted headers and rearrange others
Viresh Kumar [Mon, 11 Jan 2016 05:59:17 +0000 (11:29 +0530)]
greybus: arche: Remove unwanted headers and rearrange others

This removes few unwanted headers related to irq, interrupt, regulator,
spinlock, etc.

Also arrange the rest in alphabetical order to make it more readable.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb: Drop unnecessary checks
Viresh Kumar [Mon, 11 Jan 2016 05:59:16 +0000 (11:29 +0530)]
greybus: arche-apb: Drop unnecessary checks

wake_detect_gpio and resetn_gpio are guaranteed to be valid in
apb_ctrl_cleanup() and irq-handler, no need to check for their validity.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb: Do cleanup within apb_ctrl_init_seq() for error cases
Viresh Kumar [Mon, 11 Jan 2016 05:59:15 +0000 (11:29 +0530)]
greybus: arche-apb: Do cleanup within apb_ctrl_init_seq() for error cases

Relying on apb_ctrl_cleanup() to do the cleanup for errors that occurred
within apb_ctrl_init_seq() isn't a very clean idea. Handle that
separately within apb_ctrl_init_seq().

This will clean apb_ctrl_cleanup() in later patches.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb: Don't use gpio after failing to request it
Viresh Kumar [Mon, 11 Jan 2016 05:59:14 +0000 (11:29 +0530)]
greybus: arche-apb: Don't use gpio after failing to request it

If devm_gpio_request() returns an error, we shouldn't try to set the
direction of the same gpio.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb: Properly use dev_err/info/warn
Viresh Kumar [Mon, 11 Jan 2016 05:59:13 +0000 (11:29 +0530)]
greybus: arche-apb: Properly use dev_err/info/warn

Use dev_err for errors after which we need to abort the currently
running routine and dev_warn for resource allocation failure, with which
we can continue to work.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb: NULL is a valid regulator
Viresh Kumar [Mon, 11 Jan 2016 05:59:12 +0000 (11:29 +0530)]
greybus: arche-apb: NULL is a valid regulator

Since NULL could in theory be a valid regulator we ought to check for
IS_ERR() rather than for NULL. In practice this is unlikely to be an
issue but it's better for neatness.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb: devm_regulator_get() doesn't return NULL
Viresh Kumar [Mon, 11 Jan 2016 05:59:11 +0000 (11:29 +0530)]
greybus: arche-apb: devm_regulator_get() doesn't return NULL

And so we don't need to check for it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb: Replace gpio_is_valid() with gpio < 0 checks
Viresh Kumar [Mon, 11 Jan 2016 05:59:10 +0000 (11:29 +0530)]
greybus: arche-apb: Replace gpio_is_valid() with gpio < 0 checks

There can be no invalid values in the DTS. The actual pin numbers are
assigned by gpiolib when the gpio controller is registered.

And so a simple 'gpio < 0' is enough instead of gpio_is_valid() which
also checks for 'gpio < ARCH_NR_GPIOS'.

This will make the usage of of_get_named_gpio() similar with how it is
done in arche-platform driver.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb: platform data 'apb' is guaranteed to be valid
Viresh Kumar [Mon, 11 Jan 2016 05:59:09 +0000 (11:29 +0530)]
greybus: arche-apb: platform data 'apb' is guaranteed to be valid

Platform data 'apb' is guaranteed to be valid in arche_apb_ctrl_remove()
and so no need to check it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb: Spelling and whitespace fixes
Viresh Kumar [Mon, 11 Jan 2016 05:59:08 +0000 (11:29 +0530)]
greybus: arche-apb: Spelling and whitespace fixes

- s/premits/permits
- Remove blank lines at the end of the file

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: propagate errors returned by gpiolib
Viresh Kumar [Mon, 11 Jan 2016 05:59:07 +0000 (11:29 +0530)]
greybus: arche-platform: propagate errors returned by gpiolib

Propagate errors returned by of_get_named_gpio() instead of sending
-ENODEV.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: svc_reset_gpio can't be invalid in arche_platform_cleanup()
Viresh Kumar [Mon, 11 Jan 2016 05:59:06 +0000 (11:29 +0530)]
greybus: arche-platform: svc_reset_gpio can't be invalid in arche_platform_cleanup()

svc_reset_gpio is guaranteed to be valid in arche_platform_cleanup. Drop
the useless check.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Put APB in reset if of_platform_populate() fails
Viresh Kumar [Mon, 11 Jan 2016 05:59:05 +0000 (11:29 +0530)]
greybus: arche-platform: Put APB in reset if of_platform_populate() fails

The current implementation around of_platform_populate() is not so
great. On error, we first print an error message, followed by a success
message and finally we return an error.

And over that we don't undo what we did initially.

This patch puts the APB back into reset and create a separate error
path to make things clear.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Export GPIOs after populating APBs
Viresh Kumar [Mon, 11 Jan 2016 05:59:04 +0000 (11:29 +0530)]
greybus: arche-platform: Export GPIOs after populating APBs

Populating APBs operation can potentially fail and it would be better if
we export the GPIOs towards then end of the routine, so that we don't
need to unexport them on error cases.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: arche_pdata is guaranteed to be valid
Viresh Kumar [Mon, 11 Jan 2016 05:59:03 +0000 (11:29 +0530)]
greybus: arche-platform: arche_pdata is guaranteed to be valid

arche_pdata is guaranteed to be valid in arche_platform_remove().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: firmware/bootrom: debug output from bootrom protocol
Eli Sennesh [Fri, 8 Jan 2016 19:11:29 +0000 (14:11 -0500)]
greybus: firmware/bootrom: debug output from bootrom protocol

The bootrom protocol issues no dynamic debugging messages when it functions
successfully.  Use dev_dbg() to fix that by issuing kernel logs when firmware
download works.

Signed-off-by: Eli Sennesh <esennesh@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: fix version-request error handling
Johan Hovold [Fri, 8 Jan 2016 19:13:40 +0000 (20:13 +0100)]
greybus: connection: fix version-request error handling

Use the host device and connection name when logging errors as the
version-request helper must not assume that all connection have a
bundle.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: core: fix greybus device matching
Johan Hovold [Fri, 8 Jan 2016 19:13:41 +0000 (20:13 +0100)]
greybus: core: fix greybus device matching

The bus code should only match bundle devices for now, and must not
assume all greybus devices are bundles.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: core: fix greybus driver registration
Johan Hovold [Fri, 8 Jan 2016 19:13:42 +0000 (20:13 +0100)]
greybus: core: fix greybus driver registration

Add missing bus type to driver structure when registering a greybus
driver.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: core: add drvdata accessors
Johan Hovold [Fri, 8 Jan 2016 19:13:43 +0000 (20:13 +0100)]
greybus: core: add drvdata accessors

Add greybus driver-data accessors.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Add support for flags to stream_configure
Jacopo Mondi [Fri, 8 Jan 2016 16:13:20 +0000 (18:13 +0200)]
greybus: camera: Add support for flags to stream_configure

Add support for the flags field of the stream configure request that was
recently added to the camera protocol and update the debugfs arguments
parsing accordingly. The stream configure response layout is also
updated to the latest protocol specification.

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: svc: Replace link config hack with standard operation
Laurent Pinchart [Wed, 6 Jan 2016 14:16:46 +0000 (16:16 +0200)]
greybus: svc: Replace link config hack with standard operation

The link config operation was a hack only designed to fulfill the camera
driver's needs. Now that a standard operation is defined for the same
purpose, implement it and remove the hack.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Do not bring APB out of reset in probe
Vaibhav Hiremath [Wed, 6 Jan 2016 18:16:46 +0000 (23:46 +0530)]
greybus: arche-apb-ctrl: Do not bring APB out of reset in probe

With addition of handshaking between AP <=> SVC, driver
brings out APB out of reset only on reception of WAKE_MOD
signal from SVC. So remove the deassertion from probe.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Set wake_detect gpio to low initially
Vaibhav Hiremath [Wed, 6 Jan 2016 18:16:45 +0000 (23:46 +0530)]
greybus: arche-apb-ctrl: Set wake_detect gpio to low initially

This patch enables handshaking of AP and SVC using wake_detect
gpio (WD_8A and WD_8B).
Note that WAKE_DETECT polarity is active-high, so in order to
enable handshaking between AP <=> SVC, we need to set wake_detect
gpio to low initially, so that driver can send WAKE_DET signal
(active-high) to SVC and then SVC can send back WAKE_MOD signal
(active-low).
And on reception of WAKE_MOD signal, driver would bring respective
APB out of reset.

  WD_8A => APB1
  WD_8B => APB2

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Export gpio (reset & sys_boot) to user
Vaibhav Hiremath [Wed, 6 Jan 2016 06:01:20 +0000 (11:31 +0530)]
greybus: arche-platform: Export gpio (reset & sys_boot) to user

In order to allow user to flash the firmware to,

SVC:
user need to assert the reset first, set sysboot pin and
deassert reset. And then issue a flashing command.

And APB:
User need to assert the reset first, and then issue flashing
command.

So this patch exports the gpio's to user.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Raise the CSI-2 bandwidth
Laurent Pinchart [Thu, 31 Dec 2015 02:20:56 +0000 (04:20 +0200)]
greybus: camera: Raise the CSI-2 bandwidth

Use 4 lanes at 960MHz to support camera modules requiring higher
bandwidths until we implement support for dynamic bandwidth calculation.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: merge arche-apb-ctrl and arche-platform
Greg Kroah-Hartman [Wed, 30 Dec 2015 21:38:33 +0000 (13:38 -0800)]
greybus: arche-platform: merge arche-apb-ctrl and arche-platform

No need to have two separate arche platform drivers, that's just crazy,
so merge them both together to be only one kernel module.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Tested-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>