platform/kernel/linux-starfive.git
9 years agogreybus: uart: Fix the memory leak in connection init
Phong Tran [Mon, 1 Jun 2015 15:19:45 +0000 (22:19 +0700)]
greybus: uart: Fix the memory leak in connection init

If alloc minor is error, gb_tty should free.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: endo: Add missing '\n' sprintf() for sysfs files
Viresh Kumar [Mon, 1 Jun 2015 12:13:36 +0000 (17:43 +0530)]
greybus: endo: Add missing '\n' sprintf() for sysfs files

Because of the missing '\n', this is how the output of reading endo
sysfs files looks:

root# cat /sys/bus/greybus/devices/endo/id
0x4755root#

Fix it by including \n to the end of the printed string.

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>
9 years agogreybus: gpio: add irq-type defines
Johan Hovold [Thu, 28 May 2015 17:03:34 +0000 (19:03 +0200)]
greybus: gpio: add irq-type defines

Add Greybus GPIO IRQ-type defines rather than rely on the current
Linux implementation.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpio: remove unused debounce define
Johan Hovold [Thu, 28 May 2015 17:03:33 +0000 (19:03 +0200)]
greybus: gpio: remove unused debounce define

Remove unused debounce define from protocol header.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: endo: delete "0xXXXX" portion in sysfs "endo" directory
Alex Elder [Wed, 27 May 2015 16:17:53 +0000 (11:17 -0500)]
greybus: endo: delete "0xXXXX" portion in sysfs "endo" directory

With the Endo "id" attribute in place, there's no need to encode
the ID of an Endo in its sysfs path.  So get rid of it.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: endo: drop redundant prefixes from sysfs basenames
Alex Elder [Wed, 27 May 2015 16:17:52 +0000 (11:17 -0500)]
greybus: endo: drop redundant prefixes from sysfs basenames

This commit:
    7e761e2 endo: rework some attributes
added a new "endo_id" attribute, located under a new "Endo"
directory in sysfs.  The resulting path looks like:
    Documentation/sysfs/endo-TYPE/Endo/endo_id
There's no need to have a separate "Endo" subdirectory to contain
Endo-specific attributes.

That commit also added "svc_" to some other paths related to the
SVC, like:
    Documentation/sysfs/endo-TYPE/SVC/svc_version
The additional "svc_" is redundant.

This patch retouches those paths a bit, mainly to remove some
redundancy.  It also makes the pathname components all lower case.
As a result, the above two paths now look like:
    Documentation/sysfs/endo-TYPE/id
    Documentation/sysfs/endo-TYPE/svc/version

All other Endo sysfs files are updated similarly.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: update sysfs documentation files
Alex Elder [Wed, 27 May 2015 16:17:51 +0000 (11:17 -0500)]
greybus: update sysfs documentation files

Impose a few editorial conventions on the Greybus-related sysfs
files under "Documentation".
    - Capitalize "Endo" (except in path names)
    - Capitalize "ID" (except in path names)
    - Use "..." to indicate unspecified path components (because
      ".." means something else).
    - Add the "0x" prior to the "XXXX" representing the Endo ID.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: add documentation for Endo sysfs files
Alex Elder [Wed, 27 May 2015 16:17:50 +0000 (11:17 -0500)]
greybus: add documentation for Endo sysfs files

Update the files documenting Greybus-related sysfs files under
Documentation/ to reflect the addition of the two recently-added
Endo attributes.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: audio: Remove the MODULE_LICENSE()
Phong Tran [Thu, 28 May 2015 16:21:01 +0000 (23:21 +0700)]
greybus: audio: Remove the MODULE_LICENSE()

This is not a kernel module. It should not use
the module license macro.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: audio: Fix typo for macro I2S data version minor
Phong Tran [Thu, 28 May 2015 16:21:00 +0000 (23:21 +0700)]
greybus: audio: Fix typo for macro I2S data version minor

This macro should be DATA not MGMT.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: greybus_protocols: fix guard tag
Alex Elder [Wed, 27 May 2015 19:45:58 +0000 (14:45 -0500)]
greybus: greybus_protocols: fix guard tag

I neglected to update the "#ifndef/#define" when I renamed
"greybus_protocols.h".  Fix that.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpio: update operation types
Johan Hovold [Wed, 27 May 2015 10:45:07 +0000 (12:45 +0200)]
greybus: gpio: update operation types

Update the remaining operation types now that the ack operation is gone
to avoid leaving a hole in the type definitions.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: Merge branch 'master' of github.com:gregkh/greybus
Greg Kroah-Hartman [Thu, 28 May 2015 21:02:02 +0000 (14:02 -0700)]
greybus: Merge branch 'master' of github.com:gregkh/greybus

9 years agogreybus: svc: use macro for init and exit protocol
Phong Tran [Wed, 27 May 2015 14:31:03 +0000 (21:31 +0700)]
greybus: svc: use macro for init and exit protocol

Change to gb_gpbridge_protocol_driver for
making the consitent with other drivers.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: svc: Fix endian of hotplug request data
Phong Tran [Wed, 27 May 2015 14:31:02 +0000 (21:31 +0700)]
greybus: svc: Fix endian of hotplug request data

data of hotplug request should exchange to native
CPU format before assignment.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpio: fix interrupt protocol
Johan Hovold [Tue, 26 May 2015 13:29:25 +0000 (15:29 +0200)]
greybus: gpio: fix interrupt protocol

The current interrupt implementation uses the simple irq-flow handler,
which means that the interrupt subsystem makes no irq-chip callbacks
when handling an interrupt. Specifically, no end-of-interrupt message is
sent when the threaded handler has run. This means that we may currently
re-enable an interrupt before it has been serviced (i.e. the irq-event
operation may complete before the threaded handler has run).

The simple flow handler also silently drops a second interrupt arriving
while a handler is running. This means that we may lose a second edge
interrupt with the current firmware.

Switch to a new one-shot interrupt protocol, where the primary handler
(firmware) always masks and acks an interrupt before sending an event to
the AP. The AP is responsible for unmasking the interrupt when it has
been handled. By having the firmware ack an edge interrupt before
sending the event, a second edge interrupt will no longer get lost.

This one-shot protocol can be implemented in the kernel by using the
level irq-flow handler, one-shot interrupts with threaded handlers and
bus-lock synchronisation for slow buses. Note that the same flow handler
is used for both edge and level interrupts.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpio: fix atomic sleep when using interrupts
Johan Hovold [Tue, 26 May 2015 13:29:24 +0000 (15:29 +0200)]
greybus: gpio: fix atomic sleep when using interrupts

The irq-chip callbacks are made in atomic context where we must not do
any synchronous greybus operations.

Fix the current gpio-interrupt implementation by using the bus-lock
functionality provided by the irq subsystem.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpio: rename irq mask and unmask callbacks
Johan Hovold [Tue, 26 May 2015 13:29:23 +0000 (15:29 +0200)]
greybus: gpio: rename irq mask and unmask callbacks

Rename irq mask and unmask functions to match the callback names.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpio: use irq-domain lookups
Johan Hovold [Tue, 26 May 2015 13:29:22 +0000 (15:29 +0200)]
greybus: gpio: use irq-domain lookups

Use irq_find_mapping directly rather than go through the legacy gpio
interface.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpio: don't call irq-flow handler directly
Johan Hovold [Tue, 26 May 2015 13:29:21 +0000 (15:29 +0200)]
greybus: gpio: don't call irq-flow handler directly

Use generic_handle_irq_desc rather than call a hardcoded irq-flow
handler directly.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpio: remove unused irq-ack operation
Johan Hovold [Tue, 26 May 2015 13:29:20 +0000 (15:29 +0200)]
greybus: gpio: remove unused irq-ack operation

Remove unused irq-ack operation, which has never been called and does
not make sense for message-signalled interrupts over slow buses.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpio: fix debugfs output
Johan Hovold [Tue, 26 May 2015 13:29:19 +0000 (15:29 +0200)]
greybus: gpio: fix debugfs output

Fix debugfs output by removing the unimplemented, custom dbg_show
callback. The default implementation is perfectly sufficient.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: operation: add support for incoming unidirectional operations
Johan Hovold [Tue, 26 May 2015 13:29:18 +0000 (15:29 +0200)]
greybus: operation: add support for incoming unidirectional operations

Add support for incoming, unidirectional operations where the sender of
a request does not care about a response.

Unidirectional operations have an operation id of 0.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: Merge branch 'master' of github.com:gregkh/greybus
Greg Kroah-Hartman [Tue, 26 May 2015 15:39:33 +0000 (08:39 -0700)]
greybus: Merge branch 'master' of github.com:gregkh/greybus

9 years agogreybus: introduce SVC protocol
Alex Elder [Fri, 22 May 2015 18:02:08 +0000 (13:02 -0500)]
greybus: introduce SVC protocol

This patch adds support for the Greybus SVC protocol.  We may want
to rearrange protocol numbers at some point, since this is a pretty
fundamental protocol.

Note:  It has only been compile tested; no SVC CPorts have yet been
defined, so this code is not yet exercised.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: update copyrights
Alex Elder [Fri, 22 May 2015 17:59:16 +0000 (12:59 -0500)]
greybus: update copyrights

Update the copyright statements for recently-modified source files.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: add copyright statements
Alex Elder [Fri, 22 May 2015 17:59:15 +0000 (12:59 -0500)]
greybus: add copyright statements

The Greybus audio source files included no copyright statements.
Add them.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: core: don't set up endo until host device is initialized
Alex Elder [Fri, 22 May 2015 17:56:49 +0000 (12:56 -0500)]
greybus: core: don't set up endo until host device is initialized

Currently, the data structure representing an Endo is set up at the
time a host device gets created.  This is too early.

Once the control infrastructure is in place, there's no sense in
setting up the Endo utnil after we have heard from the SVC via a
probe operation on our control CPort.  And even then, there's
no real point until we've successfully authenticated with the SVC,
which will be indicated by the arrival of the Control protocol
"connected" operation request notifying us that our SVC CPort
is operational.

In addition to this logical argument, we also can't actually
receive any messages on the Control CPort until the host device
is set up and ready to receive messages.  At the point we're
currently setting up the Endo data structure, that has not yet
been done.

Define a new exported function greybus_endo_setup(), which will
be used (for now) as the entry point for setting up the Endo
data structure.  Arrange to call it in the host USB driver
probe method, *after* we are set up for handling messages.

Note: Once the control protocol has been implemented, this function
may no longer need to be exported.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: endo: record AP interface id
Alex Elder [Fri, 22 May 2015 17:56:48 +0000 (12:56 -0500)]
greybus: endo: record AP interface id

The AP resides in a particular position on an Endo, which is
identified by an interface ID.  (For now we'll assume the AP uses
just one interface.)  Record the this AP interface ID when creating
an Endo.  Add a sysfs attribute to display it as well.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: endo: rework some attributes
Alex Elder [Fri, 22 May 2015 17:56:47 +0000 (12:56 -0500)]
greybus: endo: rework some attributes

The SVC is not the same as the Endo.  There are some attributes
(such as the Endo ID) that are independent of attributes of
the SVC (like its version).

The current "Endo attributes" are really SVC attributes.
Rename a few functions and variables to reflect that.

Add a new attribute group for Endo-specific attributes, and
populate it with the Endo ID.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: endo: encapsulate computing the max interface id
Alex Elder [Fri, 22 May 2015 17:56:46 +0000 (12:56 -0500)]
greybus: endo: encapsulate computing the max interface id

The maximum interface id on an Endo is the result of a non-trivial
calculation.  It'll be needed for an upcoming patch, so create a
macro to compute it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: rename "gpbridge.h"
Alex Elder [Fri, 22 May 2015 17:35:32 +0000 (12:35 -0500)]
greybus: rename "gpbridge.h"

The file "gpbridge.h" is now used as a single place to define
all protocol message structures.  These protocols are not
necessarily related to the GP bridge, so the name of the
file is misleading.

Rename it "greybus_protocols.h".

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: include "gpbridge.h" from "greybus.h"
Alex Elder [Fri, 22 May 2015 17:35:31 +0000 (12:35 -0500)]
greybus: include "gpbridge.h" from "greybus.h"

Avoid the need for all the source files to include "gpbridge.h"
by just having "greybus.h" include it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: core: return error code when creating host device
Alex Elder [Fri, 22 May 2015 14:52:45 +0000 (09:52 -0500)]
greybus: core: return error code when creating host device

Return a pointer-coded error from greybus_create_hd() rather
than NULL in the event an error occurs.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: core: return error code when creating endo
Alex Elder [Fri, 22 May 2015 14:52:44 +0000 (09:52 -0500)]
greybus: core: return error code when creating endo

Return a pointer-coded error from gb_endo_create() rather than just
a null pointer in the event an error occurs.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: endo: pass endo_id to gb_endo_create()
Alex Elder [Fri, 22 May 2015 14:52:43 +0000 (09:52 -0500)]
greybus: endo: pass endo_id to gb_endo_create()

We are going to want to defer creating the endo until we receive a
probe operation from the SVC, which will supply the endo id.  Change
gb_endo_create() so it passes the endo_id value as an argument.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: endo: rename gb_svc
Alex Elder [Fri, 22 May 2015 14:52:42 +0000 (09:52 -0500)]
greybus: endo: rename gb_svc

Change the name of "struct gb_svc" to be "struct svc_info".  The
structure now contains only the SVC's serial number and version (and
are place holders anyway).  We will be defining a structure that
represents the SVC for the SVC protocol connection, and I want to
take back that name.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Set samples per message during init
Mark A. Greer [Thu, 21 May 2015 22:57:04 +0000 (15:57 -0700)]
greybus: gb-audio: Set samples per message during init

A recent commit moved the I2S samples per message operation
to the PCM's 'hw_params' callback.  However, the 'hw_params'
callback is called numerous times while the samples per
message need only be done once (or seldom).  Eliminate the
unnecessary samples per message operations by doing it only
once at Greybus protocol init time.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Set I2S Configuration according to ASOC requests
Mark A. Greer [Thu, 21 May 2015 22:57:03 +0000 (15:57 -0700)]
greybus: gb-audio: Set I2S Configuration according to ASOC requests

Currently, the audio driver unconditionally sets the I2S
configuration to have a sample rate of 48KHz, two channels,
16 bits per channel, in little endian order.  Make this
more flexible by setting the I2S configuration according to
the arguments passed to the PCM 'hw_params' callback.

To accomplish this, query for the supported I2S configurations
at Greybus protocol init time and save them in the 'snd_dev'
structure.  When the 'hw_params' callback is called, compare its
arguments to the table of supported configurations.  If there is
a match, set the I2S connection accordingly.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Activate TX connection Bundle CPort ID
Mark A. Greer [Thu, 21 May 2015 22:57:02 +0000 (15:57 -0700)]
greybus: gb-audio: Activate TX connection Bundle CPort ID

Currently, the audio driver activates & deactivates a predefined
CPort ID but that can vary depending on the manifest data of the
module.  Instead, use the TX connection's Bundle CPort ID which
contains the correct CPort ID.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Activate TX CPort in PCM workqueue
Mark A. Greer [Thu, 21 May 2015 22:57:01 +0000 (15:57 -0700)]
greybus: gb-audio: Activate TX CPort in PCM workqueue

Currently, the I2S TX CPort is configured and activated during
the Greybus audio initialization.  Unfortunately, this prevents
the audio driver from ever changing the I2S configuration.

To allow the I2S configuration to change according to ASOC requests,
move the CPort activation & deactivation to the audio-pcm workqueue.
Now, when audio is running but the CPort is not active, it will be
activated.  When audio is not running and the CPort is active, it
will be deactivated.

This has the side-effect of sending the first piece of audio data
immediately after activating the CPort which is really how it should
work anyway.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Remove useless comment
Mark A. Greer [Thu, 21 May 2015 22:57:00 +0000 (15:57 -0700)]
greybus: gb-audio: Remove useless comment

Remove comment about adding start delay since it will
be done when support for A/V synchronization is added.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Add I2C device for rt5647 codec
Mark A. Greer [Thu, 21 May 2015 22:56:59 +0000 (15:56 -0700)]
greybus: gb-audio: Add I2C device for rt5647 codec

Add the I2C device node for the rt5647 codec.

Eventually, this will be done automatically somewhere
else but for now its done in the audio driver.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: cpu_dai.fmt does not exist in v4.1
Mark A. Greer [Thu, 21 May 2015 22:56:58 +0000 (15:56 -0700)]
greybus: gb-audio: cpu_dai.fmt does not exist in v4.1

The asoc_simple_dai structure does not contain the 'fmt'
member in Linux kernel version v4.1 and later so only
build code that uses it when the kernel version is earlier
than v4.1.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Fix DAI formats and master/slave settings
Mark A. Greer [Thu, 21 May 2015 22:56:57 +0000 (15:56 -0700)]
greybus: gb-audio: Fix DAI formats and master/slave settings

Set the various DAI formats so the bridge on the module
is the master of all clocks and the codec is the slave.
The only DAI protocol currently supported is I2S.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Clean up codec name generation
Mark A. Greer [Thu, 21 May 2015 22:56:56 +0000 (15:56 -0700)]
greybus: gb-audio: Clean up codec name generation

Instead of using the fixed suffix, '6-001b', in the
codec name, generate it from the I2S adapter number
and I2C address of the codec.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Acked-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Allocate space for 20 configurations
Mark A. Greer [Thu, 21 May 2015 22:54:48 +0000 (15:54 -0700)]
greybus: gb-audio: Allocate space for 20 configurations

The greybus code requires that an operation's response buffer be
the exact size of the response; however, the size of the response to
the GB_I2S_MGMT_TYPE_GET_SUPPORTED_CONFIGURATIONS operation is unknown.
To fix this, an extension to the I2S specification is required.

In the meantime, set the number of configurations returned to 20
because that is how many configurations will be returned (using
"insider knowledge" of the firmware).

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Tested-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Set clock edges to match rt5647 codec requirements
Mark A. Greer [Thu, 21 May 2015 22:54:27 +0000 (15:54 -0700)]
greybus: gb-audio: Set clock edges to match rt5647 codec requirements

The rt5647 codec on speaker and mediabar modules require that
the following clock edge settings:

ll_wclk_change_edge GB_I2S_MGMT_EDGE_FALLING
ll_wclk_tx_edge GB_I2S_MGMT_EDGE_RISING
ll_wclk_rx_edge GB_I2S_MGMT_EDGE_FALLING

(Those are the setting that work, at least).  So make the Greybus
audio driver configure the GPBridge with those settings.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Tested-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpbridge: fix section mismatches
Johan Hovold [Thu, 21 May 2015 09:47:24 +0000 (11:47 +0200)]
greybus: gpbridge: fix section mismatches

Fix section mismatches introduced by b27227ce93c0 ("greybus: Use
gb_gpbridge_protocol_init()"), which added __exit annotation to
gpbridge-protocol exit functions that are called in the error path of
gpbridge_init, which lives in the init section.

This triggered the following modpost warning:

WARNING: modpost: Found 8 section mismatch(es).

Fixes: 16b33d100bff ("protocol: Add gb_gpbridge_protocol_driver()")
Fixes: b27227ce93c0 ("greybus: Use gb_gpbridge_protocol_init()")
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: operation: add helper to retrieve max payload size
Johan Hovold [Tue, 19 May 2015 09:22:46 +0000 (11:22 +0200)]
greybus: operation: add helper to retrieve max payload size

Add helper to retrieve the maximum payload size for operations on a
specific connection.

Note that the helper is not inlined due to how the header files are
currently organised, but it is not expected to be called after a
connection has been initialised either.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: core: add lower-limit for host-device buffers
Johan Hovold [Tue, 19 May 2015 09:22:45 +0000 (11:22 +0200)]
greybus: core: add lower-limit for host-device buffers

Make sure we never end up with a host device with maximum buffer size
smaller than the shortest Greybus message.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: operation: allow maximum-sized messages
Johan Hovold [Tue, 19 May 2015 09:22:44 +0000 (11:22 +0200)]
greybus: operation: allow maximum-sized messages

Increase the maximum allowed buffer size to the full 16-bit range
supported by the protocol.

Note that host devices will generally use smaller buffers than the
maximum.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: fix host-device buffer constraints
Johan Hovold [Tue, 19 May 2015 09:22:43 +0000 (11:22 +0200)]
greybus: fix host-device buffer constraints

Host devices impose buffer-size constraints on Greybus core which are
taken into account when allocating messages.

Make sure to verify these constraints when the host device is allocated,
rather than when the first message is allocated.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: remove unused prototypes from header
Johan Hovold [Tue, 19 May 2015 09:22:42 +0000 (11:22 +0200)]
greybus: remove unused prototypes from header

Remove a couple of unused function prototypes from the greybus header
file.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: remove unnecessary greybus.h includes
Johan Hovold [Tue, 19 May 2015 09:22:41 +0000 (11:22 +0200)]
greybus: remove unnecessary greybus.h includes

Remove unnecessary greybus.h include from header files.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: Use gb_gpbridge_protocol_init()
Viresh Kumar [Wed, 20 May 2015 11:50:10 +0000 (17:20 +0530)]
greybus: Use gb_gpbridge_protocol_init()

Start using gb_gpbridge_protocol_init() in gpbridge drivers.

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>
9 years agogreybus: protocol: Add gb_gpbridge_protocol_driver()
Viresh Kumar [Wed, 20 May 2015 11:50:09 +0000 (17:20 +0530)]
greybus: protocol: Add gb_gpbridge_protocol_driver()

There are many gpbridge protocol drivers that need gb_protocol_driver()
without the module_init/exit() lines. Lets create one for them.

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>
9 years agogreybus: gpbridge: rename gpb.c to gpbridge.c
Viresh Kumar [Wed, 20 May 2015 11:26:46 +0000 (16:56 +0530)]
greybus: gpbridge: rename gpb.c to gpbridge.c

That's what followed for .h, etc.. Rename for better consistency.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: raw: move module_{init|exit} to the end of functions
Viresh Kumar [Wed, 20 May 2015 11:24:22 +0000 (16:54 +0530)]
greybus: raw: move module_{init|exit} to the end of functions

This is what coding guidelines say. Lets do 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>
9 years agogreybus: module: name routines consistently
Viresh Kumar [Wed, 20 May 2015 11:18:04 +0000 (16:48 +0530)]
greybus: module: name routines consistently

Routines should be named this way: gb_<object>_<operation>. Fix all
routines that don't match this.

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>
9 years agogreybus: interface: name routines consistently
Viresh Kumar [Wed, 20 May 2015 12:03:51 +0000 (17:33 +0530)]
greybus: interface: name routines consistently

Routines should be named this way: gb_<object>_<operation>. Fix all
routines that don't match this.

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>
9 years agogreybus: endo: name routines consistently
Viresh Kumar [Wed, 20 May 2015 11:18:01 +0000 (16:48 +0530)]
greybus: endo: name routines consistently

Routines should be named this way: gb_<object>_<operation>. Fix all
routines that don't match this.

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>
9 years agogreybus: connection: name routines consistently
Viresh Kumar [Wed, 20 May 2015 11:18:00 +0000 (16:48 +0530)]
greybus: connection: name routines consistently

Routines should be named this way: gb_<object>_<operation>. Fix all
routines that don't match this.

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>
9 years agogreybus: protocol: remove leading underscore from _gb_protocol_find()
Viresh Kumar [Wed, 20 May 2015 11:17:59 +0000 (16:47 +0530)]
greybus: protocol: remove leading underscore from _gb_protocol_find()

Remove the unnecessary underscore from _gb_protocol_find().

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>
9 years agogreybus: spi: Move structure definitions into gpbridge.h
Viresh Kumar [Wed, 20 May 2015 11:03:57 +0000 (16:33 +0530)]
greybus: spi: Move structure definitions into gpbridge.h

In order to facilitate re-use of spi structures, split them out of
independent files and add them into a shared gpbridge.h

This will be a prereq to sharing these headers w/ gbsim.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gpio: fix tab/space mistake
Viresh Kumar [Wed, 20 May 2015 11:02:28 +0000 (16:32 +0530)]
greybus: gpio: fix tab/space mistake

Spaces were present in place of tab. Fix that.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: raw: include uaccess.h to fix warning
Viresh Kumar [Wed, 20 May 2015 11:01:19 +0000 (16:31 +0530)]
greybus: raw: include uaccess.h to fix warning

This is what I get over mainline:

greybus/raw.c: In function 'gb_raw_send':
greybus/raw.c:153:2: error: implicit declaration of function 'copy_from_user' [-Werror=implicit-function-declaration]
  if (copy_from_user(&request->data[0], data, len)) {
  ^
greybus/raw.c: In function 'raw_read':
greybus/raw.c:305:2: error: implicit declaration of function 'copy_to_user' [-Werror=implicit-function-declaration]
  if (copy_to_user(buf, &raw_data->data[0], raw_data->len)) {
  ^

Fix this by including uaccess.h.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: raw: add raw greybus kernel driver
Greg Kroah-Hartman [Fri, 8 May 2015 13:50:17 +0000 (15:50 +0200)]
greybus: raw: add raw greybus kernel driver

This adds a driver that implements the greybus Raw protocol as
specified.

It preserves the message boundries by only allowing a read to receive
a "full" message, and any write() call also is passed in a single
greybus request.

Totally untested, given that we have no raw firmware or gbsim code yet.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
9 years agogreybus: connection: remove lock around ida_simple_* functions
Greg Kroah-Hartman [Thu, 14 May 2015 17:40:02 +0000 (10:40 -0700)]
greybus: connection: remove lock around ida_simple_* functions

ida_simple_* has a built-in spinlock, no need to grab another lock when
accessing it.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
9 years agogreybus: vibrator: convert idr to be an ida
Greg Kroah-Hartman [Thu, 14 May 2015 17:39:35 +0000 (10:39 -0700)]
greybus: vibrator: convert idr to be an ida

All we need is a simple ida, so use that interface instead of the more
"complex" idr one.  Bonus is we don't need to fix the locking issue I
forgot about when using an idr, as ida has one built-in.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
9 years agogreybus: loopback: add more clean up when init connection fails
Phong Tran [Thu, 14 May 2015 16:03:04 +0000 (23:03 +0700)]
greybus: loopback: add more clean up when init connection fails

It should remove the object from sysfs when loopback
connection init error.

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: make: check kernel configuration options
Rui Miguel Silva [Wed, 13 May 2015 17:59:00 +0000 (18:59 +0100)]
greybus: make: check kernel configuration options

Add checks for options that shall be enabled in the kernel config
and for options that shall be disable.

To add options to list append them to CONFIG_OPTIONS_ENABLE or
CONFIG_OPTIONS_DISABLE respectively.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: loopback: support module-initiated requests
Alex Elder [Tue, 12 May 2015 02:16:39 +0000 (21:16 -0500)]
greybus: loopback: support module-initiated requests

There's no reason we can't support loopback pings or transfers
initiated by the module.  Allow it.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: loopback: define loopback functions symbolically
Alex Elder [Tue, 12 May 2015 02:16:38 +0000 (21:16 -0500)]
greybus: loopback: define loopback functions symbolically

Add some symbols to indicate what kind of "function" the
loopback thread is supposed to be performing--the type of
traffic it generates over its connection.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: loopback: symbolically define max wait time
Alex Elder [Tue, 12 May 2015 02:16:37 +0000 (21:16 -0500)]
greybus: loopback: symbolically define max wait time

Use a symbolic constant to define the maximum time (number of
milliseconds) to delay between initiated operations.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: loopback: fix an incorrect comment
Alex Elder [Tue, 12 May 2015 02:16:36 +0000 (21:16 -0500)]
greybus: loopback: fix an incorrect comment

Fix a comment that incorrectly says the delay between messages is
limited to 1024 msec; it actually must be <= 1000 msec.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: loopback: return the right error value
Alex Elder [Tue, 12 May 2015 02:16:35 +0000 (21:16 -0500)]
greybus: loopback: return the right error value

If an error occurs starting up the loopback thread, the error code
is not extracted properly.  Fix that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: loopback: fix the type attribute check
Alex Elder [Tue, 12 May 2015 02:16:34 +0000 (21:16 -0500)]
greybus: loopback: fix the type attribute check

In gb_loopback_check_attr(), the value of gb->type is checked for
validity.  The only valid values are 0, 1, and 2.  But the check
allows the value 3.  Fix that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: audio: fix a bunch of endian issues
Greg Kroah-Hartman [Mon, 11 May 2015 21:09:32 +0000 (14:09 -0700)]
greybus: audio: fix a bunch of endian issues

sparse is rightfully complaining about a lack of converting when
accessing or assigning to little endian fields.  Fix them all up to work
properly.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
9 years agogreybus: audio: fix some sparse static warnings
Greg Kroah-Hartman [Mon, 11 May 2015 21:09:09 +0000 (14:09 -0700)]
greybus: audio: fix some sparse static warnings

This makes some functions and structures static, as warned by sparse, as
they don't need to be global.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Alex Elder <elder@linaro.org>
9 years agogreybus: manifest: be coherent with protocol name
Rui Miguel Silva [Mon, 11 May 2015 18:22:03 +0000 (19:22 +0100)]
greybus: manifest: be coherent with protocol name

remane protocol define from GREYBUS_PROTOCOL_LED to GREYBUS_PROTOCOL_LIGHTS to
be coherent with the specification.

Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: endo: Create modules after validating Endo ID
Viresh Kumar [Fri, 8 May 2015 07:28:51 +0000 (12:58 +0530)]
greybus: endo: Create modules after validating Endo ID

We already have code to parse Endo ID, lets use it to create modules at
run time instead of creating them from a static array.

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>
9 years agogreybus: endo: Add code to validate Endo ID
Viresh Kumar [Fri, 8 May 2015 07:28:50 +0000 (12:58 +0530)]
greybus: endo: Add code to validate Endo ID

Endo is described by a 16 bit value. Which represents the properties of
modules, interface and ribs on front and back of endo.

This 16 bit value can be used to find all possible pairs of modules and
interfaces and creating modules based on that.

This patch provides helpers to parse 16 bit Endo ID.

(Based on original code written by Alex Elder.)

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>
9 years agogreybus: gb-audio: fix build breakage on 4.1-rc1
Greg Kroah-Hartman [Fri, 8 May 2015 20:40:47 +0000 (22:40 +0200)]
greybus: gb-audio: fix build breakage on 4.1-rc1

In commit 1efb53a220b7 ("ASoC: simple-card: Remove support for setting
differing DAI formats"), the .fmt field was removed from struct
asoc_simple_dai.  Fix this build breakage by not trying to set it.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Acked-by: John Stultz <john.stultz@linaro.org>
9 years agogreybus: gb-audio: fix build warning
Greg Kroah-Hartman [Fri, 8 May 2015 20:33:36 +0000 (22:33 +0200)]
greybus: gb-audio: fix build warning

sizeof wants %zu when on a 64bit build, so change the dev_err() call to
remove a build warning in the audio.c file.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Acked-by: John Stultz <john.stultz@linaro.org>
9 years agogreybus: Support building greybus on host PC
Bryan O'Donoghue [Fri, 8 May 2015 00:00:50 +0000 (17:00 -0700)]
greybus: Support building greybus on host PC

Introduce INSTALL_MOD_PATH to allow for building and installing of the
greybus modules from a different location.

This lets you build the greybus modules on a PC and then install the
modules to an SD card in the appropriate location relative to the SD such
as /media/sdcard/lib/modules/version and subsequent running of depmod in
the same location. If INSTALL_MOD_PATH isn't specified the default
behaviour of installing and depmoding to /lib/modules/version is
maintained.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: gb-audio: Add integrated greybus audio driver
John Stultz [Fri, 8 May 2015 19:57:36 +0000 (12:57 -0700)]
greybus: gb-audio: Add integrated greybus audio driver

So here's the current greybus audio driver, which I
wanted to send out for more serious review and
consideration for merging.

I've tried to integrate much of the feedback from the
last round and most of the hotplug issues that I've found
have been resolved. I've tested this via gbsim, and the
Android ARA HAL layer seems to work with it.

Mark has also successfully played audio with this driver,
adding a few hacks to get the codec's i2c connection to
probe.

Current issues:
* Hotplug problem - When gbsim is killed, or the module
  removed, the greybus driver gets stuck since the android
  mediaserver process is holding the audio device open.
  Killing the mediaserver allows things to clean up and
  allows greybus to accept new gbsim connections. I have
  a workaround patch to the soc-core.c logic which converts
  the snd_card_free() call to snd_card_free_when_closed()
  which allows the greybus connection cleanup to finish.

Remaining todos:
* Probably need to break apart the mgmt_setup function
  to integrate better with the constraint logic. I took
  a really basic stab at this, but more is probably
  needed.
* Figure out how to properly find and tie in the
  codec's I2C bus-id to the driver.

This code requires that the kernel support the following
config options, which I've enabled in a separate kernel
patch:
CONFIG_SND_SIMPLE_CARD
CONFIG_SND_SOC_SPDIF
CONFIG_SND_SOC_RT5645

I really can't calim to be the sole author of this, since
many many fixes and tweaks that have been folded in have
come from Mark Greer. His analsysis and debugging is really
what has made this dummy-framework driver evolve into an
actual audio driver. So much credit and thanks to Mark!

Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: eliminate extra response flag definitions
Alex Elder [Thu, 7 May 2015 18:03:52 +0000 (13:03 -0500)]
greybus: eliminate extra response flag definitions

All protocols use the same value to distinguish between request and
response message types.  This is a requirement.

Use GB_MESSAGE_TYPE_RESPONSE rather than GB_OPERATION_TYPE_RESPONSE
for the name of the flag used to distiguish between request and
response messages.

Get rid of the redundant response flag definitions that are
associated with specific protocols.

Describe the symbolic values as "operation types" rather than
"message types" where they are defined.  The message type for a
request is the same as the operation type; the message type for a
response is the operation type OR'd with GB_MESSAGE_TYPE_RESPONSE.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: battery: use feature tag rather than kernel version
Alex Elder [Thu, 7 May 2015 18:00:21 +0000 (13:00 -0500)]
greybus: battery: use feature tag rather than kernel version

Conditionally define a new symbol DRIVER_OWNS_PSY_STRUCT, which is
set in "kernel_ver.h" based on on the kernel version.  Use it to
distinguish code used for kernels that differ in whether a power
supply structure is owned by the driver, or by the power supply
core.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: battery: free struct on error in caller
Alex Elder [Thu, 7 May 2015 18:00:20 +0000 (13:00 -0500)]
greybus: battery: free struct on error in caller

When a battery connection is initialized, a gb_battery structure for
it is allocated in gb_battery_connection_init().  Currently that
function ends by calling init_and_register(); in the event an error
occurs, init_and_register() is responsible for freeing the allocated
gb_battery structure.

Make the code a bit better balanced by having the function that
allocates the structure be responsible for freeing it in case of
error.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: es2: fix driver name collision with es1
Rob Herring [Tue, 5 May 2015 16:04:22 +0000 (11:04 -0500)]
greybus: es2: fix driver name collision with es1

Both ES1 and ES2 drivers cannot be loaded due to a driver name conflict.
Give ES2 driver the correct name.

Signed-off-by: Rob Herring <rob.herring@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: protocol.h: fix up long lines in define_get_version()
Greg Kroah-Hartman [Fri, 1 May 2015 19:06:12 +0000 (21:06 +0200)]
greybus: protocol.h: fix up long lines in define_get_version()

No need to go past 80 characters for the define_get_version macro, so
fix up the indentation to not do so.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
9 years agogreybus: protocol.h: macros should not have a trailing ';'
Greg Kroah-Hartman [Fri, 1 May 2015 19:05:50 +0000 (21:05 +0200)]
greybus: protocol.h: macros should not have a trailing ';'

Remove the trailing ';' character from the gb_protocol_driver() macro as
it's not needed and is bad coding style.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
9 years agogreybus: kernel_ver.h: add a blank line after a variable definition
Greg Kroah-Hartman [Fri, 1 May 2015 19:05:29 +0000 (21:05 +0200)]
greybus: kernel_ver.h: add a blank line after a variable definition

checkpatch reminds us that a blank line should go after a variable
definition, so fix it up here.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
9 years agogreybus: kernel_ver.h: add a ' ' character to KERNEL_VERSION()
Greg Kroah-Hartman [Fri, 1 May 2015 19:05:03 +0000 (21:05 +0200)]
greybus: kernel_ver.h: add a ' ' character to KERNEL_VERSION()

You should always put a space after a ',', so do it for the
KERNEL_VERSION() macro as well.  This makes checkpatch.pl happy also.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
9 years agogreybus: kernel_ver.h: fix leading space coding style issues
Greg Kroah-Hartman [Fri, 1 May 2015 19:04:47 +0000 (21:04 +0200)]
greybus: kernel_ver.h: fix leading space coding style issues

When cutting and pasting some of the ATTR macros into kernel_ver.h, I
dropped the tabs.  Fix this up and make checkpatch.pl happy.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
9 years agogreybus: battery: update for 4.1 power supply api changes
Greg Kroah-Hartman [Fri, 1 May 2015 18:41:00 +0000 (20:41 +0200)]
greybus: battery: update for 4.1 power supply api changes

The 4.1-rc1 kernel changed the power supply apis such that the
structures are now owned by the power supply core, and not the
individual drivers.  This broke the greybus battery driver, so update it
to support both the old and the new apis.

The API changes were such that I can't "hide" them in kernel_ver.h, but
rather the driver itself needs to have ugly #ifdefs in it.  I tried to
keep it to a minimum, making a sub-function for initializing the power
supply device that is implemented differently for different kernel
versions.

When this is submitted upstream, or if we ever move our AP development
to 4.1 or greater, the support for older kernels can be removed.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
9 years agogreybus: Move id-field before bundle-field in CPort Descriptor.
Viresh Kumar [Tue, 28 Apr 2015 14:21:41 +0000 (19:51 +0530)]
greybus: Move id-field before bundle-field in CPort Descriptor.

Note that this also makes sure the id-field is naturally aligned in case
we ever were to remove the __packed attribute.

Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: Explicitly add pad-bytes to manifest descriptors
Viresh Kumar [Tue, 28 Apr 2015 14:21:40 +0000 (19:51 +0530)]
greybus: Explicitly add pad-bytes to manifest descriptors

Explicitly add pad-bytes to manifest descriptors to match their layout
in greybus specification.

Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
9 years agogreybus: Remove class descriptor
Viresh Kumar [Tue, 28 Apr 2015 14:21:39 +0000 (19:51 +0530)]
greybus: Remove class descriptor

We carry this information as part of bundle descriptor now and this can
be removed.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>