]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/log
mirror_ubuntu-artful-kernel.git
8 years agogreybus: convert drivers to use connection->private set/get
Greg Kroah-Hartman [Tue, 22 Mar 2016 18:30:35 +0000 (14:30 -0400)]
greybus: convert drivers to use connection->private set/get

This converts all drivers to use the gb_connection_get_data() and
gb_connection_set_data() functions to make it a bit more explicit as to
what is going on.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: add functions to get/set private data
Greg Kroah-Hartman [Tue, 22 Mar 2016 18:30:16 +0000 (14:30 -0400)]
greybus: connection: add functions to get/set private data

Add gb_connection_get_data() and gb_connection_set_data() to get and set
the private data of a connection, instead of "open coding" it
everywhere.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: greybus_trace: Fix broken greybus ftrace
David Lin [Sat, 19 Mar 2016 01:30:50 +0000 (18:30 -0700)]
greybus: greybus_trace: Fix broken greybus ftrace

Enabling greybus ftrace event causes null pointer access due to
that gb_message to SVC has no Bundle. Fix it by handling this in
the trace header.

Testing Done:
$ echo 1 > /d/tracing/event/greybus/enable
 [002] ...1    54.504426: gb_message_send: greybus:1-svc op=0023 if_id=0 hd_id=0 l=0
 [002] ...1    54.504461: gb_host_device_send: greybus:greybus1 if_id=0 l=8

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Use CSD instead of E2EFC for audio data connections
Mark Greer [Thu, 17 Mar 2016 17:32:37 +0000 (10:32 -0700)]
greybus: audio: Use CSD instead of E2EFC for audio data connections

There is no reason to use end-to-end flow control for Greybus
audio data connections so disable it and enable Controlled
Segment Dropping (CSD).

Testing Done: Played music using audio modules on an EVT1.5.

CC: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
CC: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Improve module registration mechanism
Gjorgji Rosikopulos [Mon, 14 Mar 2016 16:44:53 +0000 (18:44 +0200)]
greybus: camera: Improve module registration mechanism

Registering more then one module at same time was not
possible with previous implementation. Also unregistering
of the module was missing leading to many instability issues
when camera module is ejected when camera is still active.

Signed-off-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Register capabilities operation
Jacopo Mondi [Thu, 17 Mar 2016 10:02:03 +0000 (11:02 +0100)]
greybus: camera: Register capabilities operation

Register the greybus camera driver capabilities operation to the
ara_camera subdevice

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Implement the capabilities operation
Laurent Pinchart [Thu, 17 Mar 2016 10:02:02 +0000 (11:02 +0100)]
greybus: camera: Implement the capabilities operation

The operation queries the camera module for its capabilities. The
debugfs interface just prints a hex dump of the binary message.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Reviewed-by: Gjorgji Rosikopulos <grosikopulos@mm-sol.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: power_supply: reverse version check for new psy API
Sandeep Patil [Tue, 15 Mar 2016 19:28:38 +0000 (12:28 -0700)]
greybus: power_supply: reverse version check for new psy API

Reversing the kernel version check for new power supply APIs will
easily allow us to use older kernels with backported power supply APIs
by defining "CORE_OWNS_PSY_STRUCT" in power supply core header

Testing Done:
- Build tested with arche kernel with backported power supply APIs
- Build tested also with current arche kernel to make sure we build with
  3.10 kernels

Signed-off-by: Sandeep Patil <sspatil@google.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback_test: handle SIGINT signal
Axel Haslam [Fri, 11 Mar 2016 12:19:30 +0000 (13:19 +0100)]
greybus: loopback_test: handle SIGINT signal

Adding a default timeout may not be representative of every
usecase for gb_loopback. Also, tests may continue to run
on the driver in case of a timeout.

To avoid adding a default timeout, handle SIGINT so that when the user
presses ctrl-c the test are stoped. The user can still specify a timeout
value with the -O option.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: Ensure gb->mutex is held when adding timer
Bryan O'Donoghue [Wed, 16 Mar 2016 11:29:59 +0000 (11:29 +0000)]
greybus: Ensure gb->mutex is held when adding timer

Currently in loopback on the async path we issue an operation and then add
a timer to time-out that operation should it fail to complete. Looking at a
backtrace given in its feasible op_async->pending can be true and
del_timer() can run before add_timer() has run. In the callback handler we
already hold gb->mutex. This patch fixes that potential race by ensuring we
hold gb->mutex both when we are adding and when we are removing the
relevant timer.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reported-and-tested-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix broken loopback min values
Alexandre Bailon [Fri, 11 Mar 2016 16:23:37 +0000 (17:23 +0100)]
greybus: loopback: Fix broken loopback min values

Currently, when a loopback test completely fail,
loopback will return 4294967295 for every min value.
Return 0 instead of 4294967295 in such case.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: greybus_protocols: remove svc-eject timeout define
Johan Hovold [Wed, 9 Mar 2016 11:20:46 +0000 (12:20 +0100)]
greybus: greybus_protocols: remove svc-eject timeout define

The SVC eject timeout is implementation specific and does not belong in
the protocol header so move it to the svc module.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: svc: print an error message on failed eject attempts
Johan Hovold [Wed, 9 Mar 2016 11:20:45 +0000 (12:20 +0100)]
greybus: svc: print an error message on failed eject attempts

Print an error message when the SVC fails to eject an interface.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: svc: unexport eject helper
Johan Hovold [Wed, 9 Mar 2016 11:20:44 +0000 (12:20 +0100)]
greybus: svc: unexport eject helper

Do no export the interface-eject helper, which is only supposed to be
used by core.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: separate disabling from removal
Johan Hovold [Wed, 9 Mar 2016 11:20:43 +0000 (12:20 +0100)]
greybus: interface: separate disabling from removal

Separate interface disable from interface removal.

Disabling an interface means tearing down its control connection and
destroying (i.e. deregistering and releasing) its bundles, while
removing it means deregistering and releasing the interface itself.

This is needed to implement controlled module removal, where the module
interfaces are disabled before being physically ejected.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: rename initialisation function
Johan Hovold [Wed, 9 Mar 2016 11:20:42 +0000 (12:20 +0100)]
greybus: interface: rename initialisation function

Rename the interface-initialisation function gb_interface_enable(),
which is more descriptive.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: move interface-removal helper
Johan Hovold [Wed, 9 Mar 2016 11:20:41 +0000 (12:20 +0100)]
greybus: interface: move interface-removal helper

Move helper to remove all interfaces of a host-device to the svc code
and call it when removing the svc device as this needs to be coordinated
with flushing the SVC work queue.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: remove useless spinlock
Johan Hovold [Wed, 9 Mar 2016 11:20:40 +0000 (12:20 +0100)]
greybus: interface: remove useless spinlock

Remove useless global interface spinlock that appeared to protect the
host-device interface list, but really did not as we are doing lock-less
look-ups by relying on the single-threaded SVC workqueue.

Document the locking assumptions.

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: interface: disable control connection on initialisation errors
Johan Hovold [Wed, 9 Mar 2016 11:20:39 +0000 (12:20 +0100)]
greybus: interface: disable control connection on initialisation errors

Disable the control connection immediately on any errors during
interface initialisation as there's no need to keep it around for an
interface in an error state.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: svc: always register interfaces at hotplug
Johan Hovold [Wed, 9 Mar 2016 11:20:38 +0000 (12:20 +0100)]
greybus: svc: always register interfaces at hotplug

Always register interfaces at hotplug regardless of whether
initialisation succeeded or not.

Even if a module failed to initialise we want it to have a
representation while it is physically present.

Note that the vendor and product-string attribute will read as "(null)"
for now on an interface that failed (early) initialisation.

Also note that the switch route is kept until the interface is finally
removed also on initialisation errors.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: free bundles on initialisation errors
Johan Hovold [Wed, 9 Mar 2016 11:20:37 +0000 (12:20 +0100)]
greybus: interface: free bundles on initialisation errors

Immediately free any created bundle structures on interface
initialisation errors.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: separate initialisation and registration
Johan Hovold [Wed, 9 Mar 2016 11:20:36 +0000 (12:20 +0100)]
greybus: interface: separate initialisation and registration

Separate interface initialisation from registration of the interface and
its bundles.

This is a step towards registering also interfaces that failed to
initialise (e.g. a dummy interface).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: svc: refactor interface-route destruction
Johan Hovold [Wed, 9 Mar 2016 11:20:35 +0000 (12:20 +0100)]
greybus: svc: refactor interface-route destruction

Add interface-route-destroy helper to tear down the route and release
the interface device id.

Note that we currently need to grab a reference to the interface to
prevent it from being deallocated before tearing down the route.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: svc: refactor interface-route creation
Johan Hovold [Wed, 9 Mar 2016 11:20:34 +0000 (12:20 +0100)]
greybus: svc: refactor interface-route creation

Add interface-route-create helper to allocate an interface device id and
setup the route.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: add comment about early control-connection disable
Johan Hovold [Wed, 9 Mar 2016 11:20:33 +0000 (12:20 +0100)]
greybus: interface: add comment about early control-connection disable

Add comment about why the control connection is disabled early when the
interface is already gone.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: remove unused drvdata helpers
Johan Hovold [Wed, 9 Mar 2016 11:20:32 +0000 (12:20 +0100)]
greybus: interface: remove unused drvdata helpers

Remove the unused interface drvdata helpers along with some dubious
comments about public and private definitions.

Greybus drivers bind to bundles and should be using the
greybus_set_drvdata and greybus_get_drvdata helpers.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: remove unused function prototype
Johan Hovold [Wed, 9 Mar 2016 11:20:31 +0000 (12:20 +0100)]
greybus: interface: remove unused function prototype

Remove unused gb_interface_destroy() prototype.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix broken synchonous test
Alexandre Bailon [Tue, 8 Mar 2016 16:40:16 +0000 (17:40 +0100)]
greybus: loopback: Fix broken synchonous test

loopback driver use the send_count variable to know the test progress.
The test may be stopped or change but this variable is never cleaned.
Such situation may break the next run.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: round closest the sixth decimal
Alexandre Bailon [Tue, 8 Mar 2016 15:37:37 +0000 (16:37 +0100)]
greybus: loopback: round closest the sixth decimal

The original round was removed becaused it was rounding
the integer whereas we had decimals.
Round the sixth decimal.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix warning on 32-bit build
Alexandre Bailon [Tue, 8 Mar 2016 15:37:36 +0000 (16:37 +0100)]
greybus: loopback: Fix warning on 32-bit build

gb_loopback_ro_avg_attr() is using "/" to divide two 64-bit integer,
causing a reference to __aeabi_uldivmod() that is not availalbe on 32-bit.
Instead, use do_div().

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: greybus_manifest: remove unused SVC class
Johan Hovold [Wed, 9 Mar 2016 15:13:55 +0000 (16:13 +0100)]
greybus: greybus_manifest: remove unused SVC class

Mark the SVC Bundle-class id as unused.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: greybus_manifest: remove unused AP class and protocol
Johan Hovold [Tue, 8 Mar 2016 15:50:43 +0000 (16:50 +0100)]
greybus: greybus_manifest: remove unused AP class and protocol

Mark the AP Bundle-class and protocol ids as unused.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback_test: Use timeout argument
Axel Haslam [Tue, 8 Mar 2016 09:03:40 +0000 (10:03 +0100)]
greybus: loopback_test: Use timeout argument

Patch "c3b0a32 Loopback_test: use poll instead of inotify"
added a optional argument for the user to specify a timeout value,
but did not use this parameter in the actual poll function. The
default of 30 seconds is always used.

Fix this by actually using the the poll_timeout parameter so the user
can run long tests.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Reviewed-by: Patrick Titiano <ptitiano@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: fix incorrect gpio variable type
David Lin [Tue, 8 Mar 2016 05:52:54 +0000 (21:52 -0800)]
greybus: arche-platform: fix incorrect gpio variable type

GPIO number obtained from of_get_named_gpio() should be signed to allow
error handling.

Testing Done:
Built & booted on EVT1.5

Signed-off-by: David Lin <dtwlin@google.com>
Reviewed-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: properly annotate struct gb_control_timesync_enable_request
Greg Kroah-Hartman [Sat, 5 Mar 2016 02:40:02 +0000 (18:40 -0800)]
greybus: properly annotate struct gb_control_timesync_enable_request

A patch from created struct gb_control_timesync_enable_request,
but forgot to properly annotate that the fields are little-endian.  The
code is correct in treating them this way, so there isn't a bug, but
sparse complains.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: disable E2EFC on CSI connection
Fabien Parent [Fri, 4 Mar 2016 16:32:20 +0000 (17:32 +0100)]
greybus: camera: disable E2EFC on CSI connection

Following Toshiba's recommendation we shouldn't use E2EFC on a CSI connection.
Disable E2EFC on the CSI connection.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: hd: rename CPort-features callbacks
Johan Hovold [Thu, 3 Mar 2016 12:34:40 +0000 (13:34 +0100)]
greybus: hd: rename CPort-features callbacks

Rename the CPort-features callbacks, that are not just used to enable
FCT flow, to the more descriptive cport_features_enable/disable.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: add CSD connection flag
Johan Hovold [Thu, 3 Mar 2016 12:34:39 +0000 (13:34 +0100)]
greybus: connection: add CSD connection flag

Add CSD connection flag that can be specified when allocating a
connection to enable Controlled Segment Dropping in favour of E2EFC
which is enabled by default.

Note that most connections are expected to have E2EFC enabled.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: generalise CPortFlags handling
Johan Hovold [Thu, 3 Mar 2016 12:34:38 +0000 (13:34 +0100)]
greybus: connection: generalise CPortFlags handling

Generalise the svc connection-create helper to accept a cport-flags
argument and handle the flags in the connection code instead.

Note that the camera driver currently manages its data connection
directly. We keep E2EFC enabled for now even though it will soon need
to be disabled due to some pending firmware updates.

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: clean up CPortFlags handling
Johan Hovold [Thu, 3 Mar 2016 12:34:37 +0000 (13:34 +0100)]
greybus: svc: clean up CPortFlags handling

Clean up CPortFlags handling and explicitly disable CSD when E2EFC is
enabled (CSD_n is ignored when E2EFC is set).

Note that the bootrom requires E2EFC, CSD, and CSV to all be disabled.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: add connection-flag interface
Johan Hovold [Thu, 3 Mar 2016 12:34:36 +0000 (13:34 +0100)]
greybus: connection: add connection-flag interface

Add interface for associating a flag bitmask with a connection when
creating it.

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 TimeSync control commands
Bryan O'Donoghue [Wed, 2 Mar 2016 16:51:10 +0000 (16:51 +0000)]
greybus: control: Add TimeSync control commands

Simple addition of the TimeSync commands defined in the specification.
Note for the case of timesync_authoritative we're passing the request
structure directly so as not to have to pass eight parameters into the
function.

Adds:
- control.c::timesync_enable(u8 count, u64 frame_time,
                             u32 strobe_delay, u32 refclk)
  Informs an Interface to expect count TimeSync strobe pulses with
  strobe_delay milliseconds delay between each strobe. Once enabled
  an Interface may not enter a low-power mode which will result in the
  reference timer used to track time switching off.

- control.c::timesync_disable(void)
  Commands an Interface to immediately halt TimeSync logic. This will allow
  an Interface to transition into low-power modes where the reference time
  being used for TimeSync may switch off.

- control.c::timesync_authoritative(u64 *frame_time, u8 count)
  Used by the AP Module to inform an Interface of the authoritative
  TimeSync clock-master time at each strobe pulse. Down-stream clock slaves
  shall adjust their local frame-time appropriately based on the
  diseminated authoritative frame-time.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: timesync: Add Control and SVC protocol TimeSync operation definitions
Bryan O'Donoghue [Wed, 2 Mar 2016 16:51:09 +0000 (16:51 +0000)]
greybus: timesync: Add Control and SVC protocol TimeSync operation definitions

This patch adds the protocol command extenions for SVC and Control
protocols to the greybus_protocols definition header consistent with
the greybus-spec.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: timesync: Add Control and SVC TimeSync command/response data definitions
Bryan O'Donoghue [Wed, 2 Mar 2016 16:51:08 +0000 (16:51 +0000)]
greybus: timesync: Add Control and SVC TimeSync command/response data definitions

This patch adds the protocol command/response definitions for the SVC and
Control protocols to the greybus_protocols definition header consistent
with the greybus-spec.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: manifest: reserve the Bridged PHY class
Greg Kroah-Hartman [Sun, 28 Feb 2016 22:13:27 +0000 (14:13 -0800)]
greybus: manifest: reserve the Bridged PHY class

This reserves the bridged phy class number to be used later on.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
8 years agogreybus: gpbridge.h: move protocol init/exit prototypes
Greg Kroah-Hartman [Sun, 28 Feb 2016 22:42:54 +0000 (14:42 -0800)]
greybus: gpbridge.h: move protocol init/exit prototypes

Create gpbridge.h for the gpbridge-specific function prototypes, the
rest of the greybus drivers don't care about them.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
8 years agogreybus: remove gb_i2c_retries_operation
Michael Mogenson [Thu, 3 Mar 2016 21:23:12 +0000 (16:23 -0500)]
greybus: remove gb_i2c_retries_operation

Set retries operation was removed from the Greybus specification. Remove
gb_i2c_retries_operation and all other no longer necessary code bits from the
Greybus kernel code.

Signed-off-by: Michael Mogenson <michael.mogenson@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: remove gb_i2c_timeout_operation
Michael Mogenson [Thu, 3 Mar 2016 21:23:11 +0000 (16:23 -0500)]
greybus: remove gb_i2c_timeout_operation

Set timeout operation was removed from the Greybus specification. Remove
gb_i2c_timeout_operation and all other no longer necessary code bits from the
Greybus kernel code.

Signed-off-by: Michael Mogenson <michael.mogenson@leaflabs.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: raw: use hexadecimal notation for request types
Johan Hovold [Wed, 2 Mar 2016 17:00:51 +0000 (18:00 +0100)]
greybus: raw: use hexadecimal notation for request types

Use hexadecimal notation for request types in log messages.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-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: loopback: fix double error count
Johan Hovold [Thu, 3 Mar 2016 14:29:39 +0000 (15:29 +0100)]
greybus: loopback: fix double error count

Make sure not count errors during asynchronous tests twice (first in
the timeout handler then again in the completion handler) to avoid
obviously broken error stats such as:

$ loopback_test -i 1000 -t transfer -p -o 200000 -c 64 -x -s 2000

1970-1-1 1:3:35
 test:                  transfer
 path:                  gb_loopback0
 size:                  2000
 iterations:            1000
 errors:                1998
 async:                 Enabled
 requests per-sec:      min=0, max=0, average=0.310556, jitter=0
 ap-throughput B/s:     min=0 max=4026 average=1254.647461 jitter=4026
 ap-latency usec:       min=12803 max=12803 average=12803.000000 jitter=0
 apbridge-latency usec: min=89 max=89 average=89.000000 jitter=0
 gpbridge-latency usec: min=294 max=294 average=294.000000 jitter=0

where we supposedly have more errors than iterations (operations
initiated).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Split start and stop APBridgeA requests
Mark Greer [Mon, 29 Feb 2016 22:31:02 +0000 (15:31 -0700)]
greybus: audio: Split start and stop APBridgeA requests

Provide finer-grained control of the audio streaming on APB1 by
splitting the transmit/receive start and stop requests into prepare,
start, stop, and shutdown.

CC: 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: Loopback_test: use poll instead of inotify
Axel Haslam [Fri, 26 Feb 2016 10:39:49 +0000 (11:39 +0100)]
greybus: Loopback_test: use poll instead of inotify

Inotify does not handle sysfs events, so use poll instead.

The loopback kernel driver will send a notification when the test is
complete. So, open a poll file descriptor for every enabled device,
and after starting the test, wait for an event from each device.
After all events are received, read the total number of iterations
and make sure the test is complete.

Also, add missing stdint header which was included in inotify.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: Notify user space only when the test finished.
Axel Haslam [Fri, 26 Feb 2016 10:39:48 +0000 (11:39 +0100)]
greybus: Notify user space only when the test finished.

Currently, user space is notified for every message sent,
but this is not really needed and does not work in the async case
where all messages are sent from the start.

Instead, notify userspace only when all the transfers are complete.
This allows userspace to wait in a poll loop and wakeup only when
the test is finished.

Also, don't use the bundle kobj to send the notification it is
the loopback device that contains the loopback attributes.

Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: hid: Replace WARN_ON() with dev_err()
Viresh Kumar [Fri, 26 Feb 2016 11:14:19 +0000 (16:44 +0530)]
greybus: hid: Replace WARN_ON() with dev_err()

WARN_ON() is a bit harsh here, as we just failed to power-off the HID
device while it is getting removed.

Replace it with dev_err().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: hid: Don't disable connection-tx before destroying hid-device
Viresh Kumar [Mon, 29 Feb 2016 06:49:50 +0000 (12:19 +0530)]
greybus: hid: Don't disable connection-tx before destroying hid-device

hid_destroy_device() can potentially call callbacks defined in struct
hid_ll_driver, which may initiate few greybus operations.

And so connection (tx) should be kept enabled until the hid-device isn't
destroyed.

Reported-by: Jiss Kuruvila <jkuruvila@google.com>
Reported-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Register CPorts for specific directions
Mark Greer [Sat, 27 Feb 2016 00:04:36 +0000 (17:04 -0700)]
greybus: audio: Register CPorts for specific directions

Currently, it is assumed that all audio data CPorts registered on
APB1 are used for transmitting audio data.  That may not always be
true like when a microphone is connected but no speakers.  Also,
the current special protocol lacks a way to tell APB1 whether the CPort
being registered is for transmitting, receiving, or both.

Fix by adding a 'direction' field to the register and unregister CPort
requests and define bits indicating which direction (or both) audio
data will go on that CPort.

Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: expose full 32 bits of vid/pid to userspace
Greg Kroah-Hartman [Sat, 27 Feb 2016 05:54:38 +0000 (21:54 -0800)]
greybus: expose full 32 bits of vid/pid to userspace

Now that userspace is ready for all 32 bits of the vid/pid, take off our
mask and send the full values.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix averaging
Alexandre Bailon [Thu, 25 Feb 2016 17:19:16 +0000 (18:19 +0100)]
greybus: loopback: Fix averaging

Currently, we are adding 0.5 to the average to round the average.
But we are using the remainder to calculate the decimal, so we do not
need to round the average.
In addition, use a u64 type for the remainder to avoid overflow
that might happen when stats->sum value is too big,
usually for requests per seconds and the throughput.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix throughput calculations
Alexandre Bailon [Thu, 25 Feb 2016 17:19:15 +0000 (18:19 +0100)]
greybus: loopback: Fix throughput calculations

Throughput and requests per second calculations are broken for
asynchronous request.
Instead of calculate the throughput for each iteration,
calculate it once at the end of the test.
In addition, update every seconds the min and the max
for throughput and requests per second.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix incoherency in calculations in the case of error
Alexandre Bailon [Thu, 25 Feb 2016 17:19:14 +0000 (18:19 +0100)]
greybus: loopback: Fix incoherency in calculations in the case of error

Currently, in case the case of error, statistics are updated for
asynchronous but not for an asynchronous operation.
Do not update the statistics in the case of error.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: loopback: Fix calculations error for ping transfers
Alexandre Bailon [Thu, 25 Feb 2016 17:19:13 +0000 (18:19 +0100)]
greybus: loopback: Fix calculations error for ping transfers

For the async ping transfer, statistics are counted twice,
once after the after the gb_loopback_async_operation() and
once in the callback.
Only keep the one in the callback.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
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: lights: remove unnecessary check
Rui Miguel Silva [Thu, 25 Feb 2016 18:05:09 +0000 (18:05 +0000)]
greybus: lights: remove unnecessary check

lights can never be NULL at that point since lights_count must be different than
zero, and we need only to validate the light_id.

Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Disable HUB3613 only in APB poweroff fn
Vaibhav Hiremath [Thu, 25 Feb 2016 11:15:45 +0000 (16:45 +0530)]
greybus: arche-platform: Disable HUB3613 only in APB poweroff fn

HUB3613 configuration, either disable (Standby mode) or enable (HUB mode)
is related to APB. So it makes perfect sense to put both of them
together in one function.

HUB3613 enable happens only at one place, in hub_conf_delayed_work() fn,
but disable is initiated from multiple places.
Move all calls to usb3613_hub_mode_ctrl(false) to apb_poweroff().

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Make sure APB power cycles on coldboot
Vaibhav Hiremath [Thu, 25 Feb 2016 11:15:44 +0000 (16:45 +0530)]
greybus: arche-platform: Make sure APB power cycles on coldboot

On first wake/detect pulse, everything works fine, as APB would be
in poweroff state initially.
But on subsequent wake/detect pulses, where APB is already in active
state, internal function just returns doing nothing, as it finds that
device is already in active state.

So the solution would be to make sure that, whenever execution reaches
to coldboot, make sure we power cycle it. Power off first, before
powering on.

Interrupt handler takes care of ignoring < 30msec pulses, so we should
be safe here to power cycle APB.

Testing Done: Testd on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: operation: add support for short responses
Johan Hovold [Thu, 25 Feb 2016 13:40:24 +0000 (14:40 +0100)]
greybus: operation: add support for short responses

Add support for operations with short responses.

So far we have assumed that the initiator of an operation always knows
the exact size of the expected response. This is however not always the
case and we've worked around this limitation in a couple of places by,
for example, first requesting the size of a resource before fetching the
actual data.

To avoid such workarounds and simplify our protocols, add a
short-response flag that can be set when allocating an operation. When
this flag is set on an operation, core will accept a response that is
shorter than the size of the (pre-allocated) response payload buffer.

For now, we update the response-message payload_size field to reflect
the actual length of the response received.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: operation: add temporary pointer to response handler
Johan Hovold [Thu, 25 Feb 2016 13:40:23 +0000 (14:40 +0100)]
greybus: operation: add temporary pointer to response handler

As a preparatory clean up, add a temporary variable to point to the
response message header.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Disable wake/detect interrupt in poweroff
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:39 +0000 (04:37 +0530)]
greybus: arche-platform: Disable wake/detect interrupt in poweroff

In poweroff() fn, we are shutting down SVC, so disable interrupt
as well.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Set direction of wake/detect gpio in poweroff fn
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:38 +0000 (04:37 +0530)]
greybus: arche-platform: Set direction of wake/detect gpio in poweroff fn

With support of interrupt based mechanism, gpio is not longer set to
output mode, so gpio_set_value won't work. So use
gpio_direction_output() fn in poweroff(), while setting value on
wake/detect line.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Assert wake/detect after SVC reset without delay
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:37 +0000 (04:37 +0530)]
greybus: arche-platform: Assert wake/detect after SVC reset without delay

Since now driver supports interrupt based mechanism to read events
from SVC over wake/detect line, no need to delay wake/detect assertion.
We can assert wake/detect after SVC reset deassertion, so during boot
itself SVC will start sending wake_out pulses.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Enable interrupt support on wake/detect line
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:36 +0000 (04:37 +0530)]
greybus: arche-platform: Enable interrupt support on wake/detect line

This patch enabled interrupt support on events received over wake/detect
line. The driver follows below state machine,

Default: wake/detect line is high (WD_STATE_IDLE)
On Falling edge:
  SVC initiates boot (either cold/standby).
  On ES3, > 30msec = coldboot, else standby boot.
  Driver moves to WD_STATE_BOOT_INIT
On rising edge (> 30msec):
  SVC expects APB to coldboot
  Driver wakes irq thread which kicks off APB  coldboot
  (WD_STATE_COLDBOOT_TRIG)
On rising edge (< 30msec):
  Driver ignores it, do nothing.

After coldboot of APB, HUB configuration work is scheduled after 2 sec,
allowing enough time for APB<->SVC/Switch to linkup (in multiple
iterations)

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Add wake detect state based on functionality
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:35 +0000 (04:37 +0530)]
greybus: arche-platform: Add wake detect state based on functionality

If driver needs to process wake/detect events from SVC, by enabling
interrupt support on wake/detect event, it becomes easier to maintain
state of wake/detect line based on functionality.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Convert delayed work to do only hub3613 configuration
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:34 +0000 (04:37 +0530)]
greybus: arche-platform: Convert delayed work to do only hub3613 configuration

This is preparation of interrupt handling support, where APB coldboot
and wake/detect handling will be handled as response to wake/detect
interrupt.
Due to slower I2C write operations in HUB configuration, it is important
to separate HUB configuration, and probably delay it after APB is
cold booted.

Note that delayed work will be scheduled from interrupt handler,
in following patches.

To satisfy build (and bisect), remove apb_cold_boot() fn, which will be
added back in the patch where it gets used again.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@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 extra delay in APB reset
Vaibhav Hiremath [Wed, 24 Feb 2016 23:07:33 +0000 (04:37 +0530)]
greybus: arche-apb-ctrl: Remove extra delay in APB reset

With synchronization between SVC <=> AP over wake/detect line to
bring APB's out of reset, we do not need any extra delays now.
So remove it.

Testing Done: Tested for DB3.5 and EVT1.2 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Tested-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: Documentation/sysfs: make 1-5 a 2x2 module
Johan Hovold [Mon, 22 Feb 2016 17:50:56 +0000 (18:50 +0100)]
greybus: Documentation/sysfs: make 1-5 a 2x2 module

Make example module 1-5 a 2x2 module by adding a second, dummy
interface.

This is both an example of how a 2x2 module would be represented and
also suggests what a dummy interface may look like.

A 2x2 module has two child interface devices and a num_interfaces value
of two.

In this example, the secondary interface 1-5.6, is a dummy interface and
therefore lacks the normal identifying attributes (e.g. UniPro DDBL1 and
Ara ids). We may eventually add an interface_type attribute to
facilitate distinguishing various interface types (there may be more
than two).

In the following tree, the bundle attributes and child devices have been
left out:

greybus1/
├── 1-2
│   ├── 1-2.2
│   │   ├── 1-2.2.1
│   │   ├── 1-2.2.2
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
├── 1-5
│   ├── 1-5.5
│   │   ├── 1-5.5.2
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── 1-5.6
│   │   └── interface_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
└── 1-svc

In this example there are two modules: 1-2 is a 1x2 module with one
interface, and 1-5 is a 2x2 module with two interfaces of which the
second (1-5.6) is a dummy interface.

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: Documentation/sysfs: move module 1-4 to position 5
Johan Hovold [Mon, 22 Feb 2016 17:50:55 +0000 (18:50 +0100)]
greybus: Documentation/sysfs: move module 1-4 to position 5

Move example module 1-4 to position 5, effectively renaming it 1-5.

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: Documentation/sysfs: add module devices
Johan Hovold [Mon, 22 Feb 2016 17:50:54 +0000 (18:50 +0100)]
greybus: Documentation/sysfs: add module devices

Introduce module devices and rename interface and bundle devices.

Greybus module devices correspond to physical modules and have one or
more interfaces. Modules have an id that is identical to the id of their
primary interface, which in turn is the interface with lowest numbered
id. The module name is constructed from the bus and module id:

<bus_id>-<module_id>

Interfaces and bundles are consequently renamed as

<bus_id>-<module_id>.<interface_id>

and

<bus_id>-<module_id>.<interface_id>.<bundle_id>

respectively.

As before, interface ids (and therefore in a sense now also module ids)
correspond to physical interface positions on the frame.

Modules have the following attributes:

eject
module_id
num_interfaces

where module_id is the id of the module and num_interface the number of
interfaces the module has.

Note that the interface ids of a module's interfaces are expected to be
<module_id>, <module_id + 1>, ..., <module_id + num_interfaces - 1>.

Writing a non-zero argument to eject cleanly shuts down and unregisters
all of the module interfaces before ejecting the module.

The example sysfs tree now looks as follows with the second bus
(APBridgeA) left out:

greybus1/
├── 1-2
│   ├── 1-2.2
│   │   ├── 1-2.2.1
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   └── state
│   │   ├── 1-2.2.2
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   └── state
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
├── 1-4
│   ├── 1-4.4
│   │   ├── 1-4.4.2
│   │   │   ├── bundle_class
│   │   │   ├── bundle_id
│   │   │   ├── gpbridge0
│   │   │   │   ├── gpio
│   │   │   │   │   └── gpiochip490
│   │   │   │   └── i2c-4
│   │   │   └── state
│   │   ├── ddbl1_manufacturer_id
│   │   ├── ddbl1_product_id
│   │   ├── interface_id
│   │   ├── product_id
│   │   ├── serial_number
│   │   ├── unique_id
│   │   └── vendor_id
│   ├── eject
│   ├── module_id
│   └── num_interfaces
└── 1-svc
    ├── ap_intf_id
    ├── eject
    └── endo_id

where greybus1 is a bus; 1-svc the svc; 1-2, and 1-4 are modules; 1-2.2
and 1-4.4 are (primary) interfaces; and 1-2.2.1, 1-2.2.2, and 1-4.4.2
are bundles.

Note that the svc eject attribute may eventually be renamed force_eject.

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: gpio: handle api changes for 4.5 kernel release
Greg Kroah-Hartman [Wed, 24 Feb 2016 06:51:45 +0000 (22:51 -0800)]
greybus: gpio: handle api changes for 4.5 kernel release

In kernel version 4.5, struct gpio_chip renamed the field 'dev' to
'parent' so handle this properly.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: gpio: use bundle device for error messages
Greg Kroah-Hartman [Wed, 24 Feb 2016 06:51:23 +0000 (22:51 -0800)]
greybus: gpio: use bundle device for error messages

Use the bundle device directly in gpio error messages instead of the
gpio device, as they are the same pointer.  This will make future gpio
api changes much easier to handle.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Fix exit path in probe fn
Vaibhav Hiremath [Wed, 24 Feb 2016 20:57:36 +0000 (02:27 +0530)]
greybus: arche-platform: Fix exit path in probe fn

If SVC coldboot fails or if of_platform_populate() fn fails,
then state of device needs to be reverted.

Importantly, if of_platform_populate() fails, then poweroff the SVC.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Reviewed-by: Michael Scott <michael.scott@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: uart: fix incomplete receive-data sanity checks
Johan Hovold [Wed, 24 Feb 2016 15:11:51 +0000 (16:11 +0100)]
greybus: uart: fix incomplete receive-data sanity checks

Fix incomplete receive-data sanity checks.

The payload size was never verified before parsing the uart header and
neither was the uart-header data size verified against the actual
payload size, something which could lead to information leaks when
passing data beyond the payload buffer to the tty layer.

Also remove the incorrect check against the maximum (tx-buffer) payload
size.

Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: uart: add missing serial-state sanity check
Johan Hovold [Wed, 24 Feb 2016 15:11:50 +0000 (16:11 +0100)]
greybus: uart: add missing serial-state sanity check

Add dedicated serial-state request handler and add the missing sanity
check on the incoming request.

Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: uart: add max-payload sanity check
Johan Hovold [Wed, 24 Feb 2016 15:11:49 +0000 (16:11 +0100)]
greybus: uart: add max-payload sanity check

Let's be well behaved and add a sanity check on the maximum greybus
payload size to avoid underflow on the calculated buffer size.

Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: {en,dis}able fct flow in connection management
Fabien Parent [Tue, 23 Feb 2016 17:46:11 +0000 (18:46 +0100)]
greybus: connection: {en,dis}able fct flow in connection management

The AP must enable the FCT flow of APBA once it has received the response
from the AP that the connection between APBA and a module has been setted up.
Disable the flow of FCT tokens when destroying connections.

Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: es2: implement the fct flow control requests
Fabien Parent [Tue, 23 Feb 2016 17:46:10 +0000 (18:46 +0100)]
greybus: es2: implement the fct flow control requests

Implement the control requests enabling/disabling the flow of FCT on APBA.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: apba: add fct flow usb control requests
Fabien Parent [Tue, 23 Feb 2016 17:46:09 +0000 (18:46 +0100)]
greybus: apba: add fct flow usb control requests

Add control requests to enable/disable the flow of unipro FCT tokens

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: connection: add api to {en,dis}able unipro fct flow
Fabien Parent [Tue, 23 Feb 2016 17:46:08 +0000 (18:46 +0100)]
greybus: connection: add api to {en,dis}able unipro fct flow

In order to support mailbox-free control cport init on the bridges the AP must
be able to enable/disable the flow of unipro fct tokens. Add a new API that
will enable or disable on APBA the flow of fct tokens.

Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-apb-ctrl: Return immediately if in same state from state change fns
Vaibhav Hiremath [Mon, 22 Feb 2016 11:57:26 +0000 (17:27 +0530)]
greybus: arche-apb-ctrl: Return immediately if in same state from state change fns

Have a check inside all individual operational state change functions
to check whether device is in same state, and if yes, then return
immediately.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Avoid doing same thing again in poweroff fn
Vaibhav Hiremath [Mon, 22 Feb 2016 11:57:25 +0000 (17:27 +0530)]
greybus: arche-platform: Avoid doing same thing again in poweroff fn

If user switches from fw_flashing => off mode, then we do not need
to do same things again, for example, clk_disable and wake/detect event,
as while switching to fw_flashing, driver makes sure that device goes
to off state and then brings back in fw_flashing state.

Testing Done: Tested on DB3.5 platform.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: arche-platform: Return immediately if in same state from state change fns
Vaibhav Hiremath [Mon, 22 Feb 2016 11:57:24 +0000 (17:27 +0530)]
greybus: arche-platform: Return immediately if in same state from state change fns

Have a check inside all individual operational state change functions
to check whether device is in same state, and if yes, then return
immediately.

Testing Done: Tested on DB3.5 platform

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Rename clock_mode to flags
Jacopo Mondi [Tue, 23 Feb 2016 10:22:49 +0000 (11:22 +0100)]
greybus: camera: Rename clock_mode to flags

Rename the 'clock_mode' parameter to a more generic 'flags' in the csi
bus configuration structure.
Define flags value for continuous clock mode.

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: camera: Add CSI configuration parameters
Jacopo Mondi [Tue, 23 Feb 2016 10:22:48 +0000 (11:22 +0100)]
greybus: camera: Add CSI configuration parameters

Add CSI configuration parameters to the configure_stream operation
response.
Currently, only the total number of lines in a second is used to configure the
the AP-Bridge CSI transmitter, all other parameters (number of CSI data
lanes, and CSI bus clock frequency) are kept hard-coded for two reasons:
1) We need to configure the CSI receiver on AP side accordingly to these
settings, before sending them to APB1 CSI transmitter.
2) We cannot use the camera module provided parameters as-is, but use
those information to compute the required bandwidth on the CSI bus, and
configure the # of CSI data lanes, and the CSI bus clock speed in a way that
satisfies that bandwidth requirement.

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Acked-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: uart: properly calculate max buffer size
Greg Kroah-Hartman [Tue, 23 Feb 2016 02:14:46 +0000 (18:14 -0800)]
greybus: uart: properly calculate max buffer size

We forgot to count the size of the uart send data message header when
calculating the maximum size of the buffer that the uart driver could
send in one chunk.

This fixes the math and makes the variable a size_t to match the return
value of the call to gb_operation_get_payload_size_max();

Reported-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Tested-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: Documentation: remove svc unique_id attribute
Johan Hovold [Mon, 22 Feb 2016 17:50:53 +0000 (18:50 +0100)]
greybus: Documentation: remove svc unique_id attribute

Remove unimplemented svc unique_id attribute from the documentation.

This attribute made more sense when we thought we'd have an AP-module,
unlike now when the AP and SVC are both part of the same frame.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: interface: Add print messages on interface initialization/removal
Viresh Kumar [Fri, 19 Feb 2016 10:27:46 +0000 (15:57 +0530)]
greybus: interface: Add print messages on interface initialization/removal

It might be of interest (to developers at least) to know when an
interface is getting created or removed from the system.

Interface creation message can further contain basic information about
the interface, like its vid/pid and mfg/prod ids.

Now, the interface is created by gb_interface_create(), which doesn't
register the intf->dev to the kernel and so the print message is rather
added to gb_interface_init() where we register the device with the
kernel.

A similar message is added to gb_interface_remove() only when the
interface was earlier initialized.

And this is how the output looks on real insertion/removal of the
module:

greybus 1-1: Interface added: VID=0x00000001, PID=0x00000001
greybus 1-1: DDBL1 Manufacturer=0x00000001, Product=0x00000001
...
greybus 1-1: Interface removed

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: Revert "gb_loopback: Fix throughput calculations"
Greg Kroah-Hartman [Thu, 18 Feb 2016 00:30:38 +0000 (16:30 -0800)]
greybus: Revert "gb_loopback: Fix throughput calculations"

This reverts commit 9b9b046af237f5674c2f7ca991dc62332b2d4041

Bryan wants more feedback first.

Reported-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: return success for stop trigger if device removed
Vaibhav Agarwal [Tue, 16 Feb 2016 16:46:33 +0000 (22:16 +0530)]
greybus: audio: return success for stop trigger if device removed

In case GB codec module is already removed, no action is required
at the HW level. Thus, report SUCCESS to above layer.

Reporting error to above layer will cause repeated trials and won't
allow to update DPCM connections.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: schedule workqueue to perform codec cleanup on module removal
Vaibhav Agarwal [Mon, 15 Feb 2016 18:57:28 +0000 (00:27 +0530)]
greybus: audio: schedule workqueue to perform codec cleanup on module removal

In response to codec module removal, user space is reported about
the event. In response to this, ALSA layer will update DAPM route
and cleanup DAPM states.
As a fallback mechanism, kernel can cleanup the DAPM state for codec
module. But, this would cause immediate playback (first trial) to fail,
since DSP is still in inconsistent state.
To avoid such situation, a workqueue is scheduled for codec cleanup
with timeout=50ms.
Thus, normally it is expected from above layers to update routes and
perform cleanup. However, fallback mechanism still holds good after
50ms.

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: audio: Enable support for multiple codec modules
Vaibhav Agarwal [Mon, 15 Feb 2016 18:57:27 +0000 (00:27 +0530)]
greybus: audio: Enable support for multiple codec modules

Update params, sequence in response to changes in msm8994
helper APIs

Signed-off-by: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: lights: fix check for configured lights
Rui Miguel Silva [Wed, 17 Feb 2016 14:32:53 +0000 (14:32 +0000)]
greybus: lights: fix check for configured lights

The validation for a complete configured light is wrong and it is
reworked to make sure that only when the light is ready, will handle
request events.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
8 years agogreybus: lights: remove has_flash on failure
Rui Miguel Silva [Wed, 17 Feb 2016 14:32:52 +0000 (14:32 +0000)]
greybus: lights: remove has_flash on failure

If register to v4l2 fails just mark the light as not having flash so in
release we do not try to unregister.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>