Commit graph

891 commits

Author SHA1 Message Date
Alex Elder e9385e5d5a 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>
2015-05-23 16:34:39 -07:00
Alex Elder 8ea70fe049 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>
2015-05-23 16:31:42 -07:00
Alex Elder 6b7d5a1f47 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>
2015-05-23 16:31:42 -07:00
Alex Elder ee3ecf8028 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>
2015-05-23 16:31:42 -07:00
Alex Elder a702a09f20 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>
2015-05-23 16:31:42 -07:00
Mark A. Greer 0d17e0c9f1 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>
2015-05-23 16:26:41 -07:00
Mark A. Greer 6b34099ec3 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>
2015-05-23 16:26:41 -07:00
Mark A. Greer 48229e592f 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>
2015-05-23 16:26:41 -07:00
Mark A. Greer f9a4fee7fa 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>
2015-05-23 16:26:41 -07:00
Mark A. Greer e803cf712c 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>
2015-05-23 16:26:41 -07:00
Mark A. Greer 415b83111c 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>
2015-05-23 16:26:41 -07:00
Mark A. Greer 827e27e8fe 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>
2015-05-23 16:26:41 -07:00
Mark A. Greer 4c739e3ada 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>
2015-05-23 16:26:41 -07:00
Mark A. Greer 34aa7e1cad 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>
2015-05-23 16:26:41 -07:00
Mark A. Greer 555a0645b1 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>
2015-05-23 16:13:58 -07:00
Mark A. Greer 0e995aab21 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>
2015-05-23 16:13:58 -07:00
Johan Hovold 8d346df062 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>
2015-05-23 14:42:47 -07:00
Johan Hovold d52b35f6b6 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>
2015-05-20 22:52:03 -07:00
Johan Hovold 8e929a8230 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>
2015-05-20 22:52:03 -07:00
Johan Hovold c38cf10bbe 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>
2015-05-20 22:51:05 -07:00
Johan Hovold d933667a1e 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>
2015-05-20 22:51:05 -07:00
Johan Hovold d966820f2c 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>
2015-05-20 22:48:32 -07:00
Johan Hovold fed78bf6a2 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>
2015-05-20 22:48:32 -07:00
Viresh Kumar bdac599c70 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>
2015-05-20 22:44:37 -07:00
Viresh Kumar 27551b1d5f 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>
2015-05-20 22:44:37 -07:00
Viresh Kumar f5db53b4c7 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>
2015-05-20 22:43:05 -07:00
Viresh Kumar 8ba2522fa8 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>
2015-05-20 22:43:05 -07:00
Viresh Kumar c16b63e851 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>
2015-05-20 22:39:18 -07:00
Viresh Kumar 51b5d8d783 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>
2015-05-20 22:39:18 -07:00
Viresh Kumar 5ddf738e94 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>
2015-05-20 22:39:18 -07:00
Viresh Kumar 12eba9f8ef 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>
2015-05-20 22:39:18 -07:00
Viresh Kumar 8fd46587db 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>
2015-05-20 22:39:18 -07:00
Viresh Kumar 4890f31966 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>
2015-05-20 22:36:03 -07:00
Viresh Kumar 8de925b973 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>
2015-05-20 22:36:03 -07:00
Viresh Kumar 4f8ab1105d 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>
2015-05-20 22:36:03 -07:00
Greg Kroah-Hartman e806c7fb8e 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>
2015-05-19 11:00:44 -07:00
Greg Kroah-Hartman 5bd5f00c30 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>
2015-05-14 13:35:10 -07:00
Greg Kroah-Hartman 6b17492eee 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>
2015-05-14 13:35:10 -07:00
Phong Tran 6f8528e0be 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>
2015-05-14 09:49:04 -07:00
Rui Miguel Silva 65cac604b2 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>
2015-05-14 09:42:51 -07:00
Alex Elder ac1c2840bd 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>
2015-05-12 10:25:14 -07:00
Alex Elder 48cc8b8bba 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>
2015-05-12 10:25:14 -07:00
Alex Elder 91262c3ab7 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>
2015-05-12 10:25:14 -07:00
Alex Elder 48f19ee824 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>
2015-05-12 10:25:14 -07:00
Alex Elder 69f6034792 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>
2015-05-12 10:25:14 -07:00
Alex Elder a04c640e5c 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>
2015-05-12 10:25:14 -07:00
Greg Kroah-Hartman 64a54801ae 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>
2015-05-12 10:21:56 -07:00
Greg Kroah-Hartman 13956900b0 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>
2015-05-12 10:21:56 -07:00
Rui Miguel Silva 563e6b97b8 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>
2015-05-11 13:32:25 -07:00
Viresh Kumar 51e93aea65 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>
2015-05-11 13:30:09 -07:00