1
0
Fork 0
Commit Graph

43 Commits (7c154711a6705bbc3036d8f64944e8882fe3fd84)

Author SHA1 Message Date
Johan Hovold 84427943d2 greybus: svc: drop legacy-protocol dependency
Drop dependency on the legacy protocol abstraction.

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

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-19 12:17:13 -08:00
Johan Hovold bc3be1705c greybus: connection: remove skip-connected legacy protocol flags
Remove the legacy protocol flags that were used to suppress the
connected and disconnected events.

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

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2016-01-19 12:17:13 -08:00
Johan Hovold e1442f6910 greybus: connection: unconditionally enable connections
Remove conditional enabling of connections when binding protocols that
served no purpose as a connection either has no bundle or it has an
interface with a valid device id.

Also remove the now unused GB_PROTOCOL_NO_BUNDLE protocol flag.

This is an intermediate step in moving the protocol binding to
connection_init, but is also needed as the control bundle is going away.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:39:16 -08:00
Johan Hovold 4ec1574ae9 greybus: connection: kill GB_PROTOCOL_SKIP_SVC_CONNECTION
Add helper to determine whether a connection is static, and remove the
protocol flag GB_PROTOCOL_SKIP_SVC_CONNECTION.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-25 15:34:19 -08:00
Greg Kroah-Hartman c9e9de26f9 greybus: hid: hid should not be part of the bridged-phy driver.
HID is a stand-alone greybus protocol, not part of the bridged-phy
protocols, so make it a stand-alone kernel module.

Note, some hard-coded android init script might need to be changed to
load the gb-hid.ko kernel module now.

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
2015-11-05 18:00:29 -08:00
Mark Greer ddc88eff2b greybus: audio: Remove I2S Bridged-PHY Protcol based audio driver
The Greybus I2S Bridged-PHY Protocol is now deprecated so remove
the audio driver that is based on it.

CC: Vaibhav Agarwal <vaibhav.agarwal@linaro.org>
Signed-off-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-11-04 20:30:47 -08:00
Johan Hovold 78033844da greybus: protocol: warn on bad deregistration
A protocol should be deregistered exactly once when the protocol module
is being unloaded. This means that protocol deregister will never be
called with active users as we take a module reference when looking up a
protocol.

Remove comment suggesting that we could one day forcefully stop a user
of a protocol, and issue a big warning if a protocol is deregistered
more than once or at some other time than during module unload (e.g.
with active users).

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-10-14 12:06:00 -07:00
Viresh Kumar 5a5296bb8d greybus: Add flags to struct gb_protocol
This helps in removing special per-protocol code, with the help of
generic flags passed by protocol drivers.

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>
2015-09-14 21:19:46 -07:00
Viresh Kumar 1cb5fa47c5 greybus: protocol: send own protocol version while requesting it
The greybus specifications clearly say (for all protocols) that the
sender is responsible for sending the highest version of protocol it
supports, while it requests the same from the receiver.

But the greybus code never followed that.

Fix, this by always sending AP's version of the protocol, while
requesting the same from svc/module.

This also renames 'response' to 'version' in gb_protocol_get_version()
as it is used for both request/response.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-08-12 20:55:01 -07:00
Viresh Kumar 738599c0dd greybus: protocol: Create request structure from within gb_protocol_get_version()
The version request can only send the version of protocol for which it
is initiated and gb_protocol_get_version() has all the information to
create the request structure.

Replace the 'request' and 'request_size' arguments to
gb_protocol_get_version() with a bool to know if the version information
of the protocol should be sent or not.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-08-11 21:57:12 -07:00
Viresh Kumar bf81454738 greybus: protocol: Remove unnecessary params of gb_protocol_get_version()
Some of the parameters are not really required, drop them.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-08-11 19:34:34 -07:00
Viresh Kumar b9938c4913 greybus: protocol: Drop define_get_version support
No more users now, drop it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-08-11 19:34:34 -07:00
Viresh Kumar 6366d73fd4 greybus: protocol: move version_response structure to greybus_protocols.h
Version response structure is also required by external entities like
gbsim and so its structure should be moved to greybus_protocols.h.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2015-07-22 10:11:05 -07:00
Viresh Kumar e18822e3d0 greybus: Rename gb_gpbridge_protocol_driver() as gb_builtin_protocol_driver()
This macro is also required by core protocols like control and svc, and
hence the 'gpbridge' name doesn't fit anymore.

Lets call this macro gb_builtin_protocol_driver().

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-07-01 16:34:55 -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 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 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
John Stultz a4749bbeee 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>
2015-05-08 22:23:58 +02:00
Greg Kroah-Hartman e80d09af1e 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>
2015-05-05 11:11:04 +02:00
Greg Kroah-Hartman f487c802cb 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>
2015-05-05 11:11:03 +02:00
Johan Hovold 973ccfd626 greybus: operation: refactor response handling
Send response to incoming requests from the operation request handler
rather than in every protocol request_recv callback.

This simplifies request_recv error handling and allows for further code
reuse.

Note that if we ever get protocols that need to hold off sending
responses we could implement this by letting them return a special
value (after acquiring the necessary operation references) to suppress
the response from being sent by greybus core.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-30 15:20:34 +02:00
Viresh Kumar 96eab779e1 greybus: hid: add HID class driver
This adds HID transport layer driver for Greybus. Most of the stuff is
implemented, but is untested.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-03-16 20:29:44 +01:00
Viresh Kumar 15d651b0db greybus: spi: add bridged-PHY spi protocol driver
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-01-23 22:58:02 +08:00
Viresh Kumar 36e79dec96 greybus: create get_version() routines with the help of a macro
This gets rid of lots of duplication of code.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-01-22 11:29:39 +08:00
Greg Kroah-Hartman 7422a1ec2e greybus: protocol: name protocols.
We want to be able to "blame" a protocol for things at times, so give
them a name we can refer to them by.  Announce when they are added or
removed from the system so we have a chance to know what is going on
in the kernel logs.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-01-02 13:06:48 -08:00
Greg Kroah-Hartman 2c07817e72 greybus: i2c-gb: move i2c protocol into the gpbridge driver
The i2c protocol belongs in the gpbridge driver, so move it
there.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-01-02 13:05:42 -08:00
Greg Kroah-Hartman e1308c1fb6 greybus: gpb: Create a "GP Bridge" kernel module
This bundles together the existing GP Bridged PHY protocols that were
part of the Greybus core: USB, UART, SDIO, PWM, and GPIO.  This is now a
stand-alone kernel module.  More logic will be moving here in the future
to handle bridged devices.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-01-02 13:05:42 -08:00
Greg Kroah-Hartman 7dd2626324 greybus: battery-gb: move the battery protocol out to a stand-alone module
This moves the battery class protocol to be a stand-alone kernel module.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-01-02 13:05:42 -08:00
Greg Kroah-Hartman 66b676fd88 greybus: vibrator-gb: move vibrator protocol to a stand-alone module.
We can't use the gb_protocol_driver() macro here as we need to do some
init and exit logic when loading and removing, so "open code" the module
init and exit functions.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-01-02 13:05:42 -08:00
Greg Kroah-Hartman 12a5dfc9ac greybus: protocol: add a module owner to a protocol
Now that protocols can be in a module, we need to reference count them
to lock them into memory so they can't be removed while in use.  So add
a module owner structure, and have it automatically be assigned when
registering the protocol.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Reviewed-by: Alex Elder <elder@linaro.org>
2015-01-02 13:05:42 -08:00
Greg Kroah-Hartman 900ceba9e4 greybus: i2c-gb: split out into a stand-alone kernel module.
This splits the i2c-gb protocol into a stand-alone kernel module.

It's not going to stay in this fashion for long, this was done to test
the "can a protcol be loaded later" logic.  Future refactoring is going
to move the gpbridge protocols to a separate kernel module, where this
protocol is going to live.

But for now, split it out, it is good to test with, and shows a bug in
gbsim at the moment.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-12-23 21:04:02 -08:00
Greg Kroah-Hartman 7c7d5b9a94 greybus: protocol: switch gb_protocol_register() to return an int
We will want to return this value as a return value for module_init()
and bool does not play well with module_init().  So make it a "real"
error value and return int and fix up all callers of the function.

Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-12-23 21:02:20 -08:00
Alex Elder a46e96719d greybus: add Linaro copyrights
I was asked to add a Linaro copyright to all Greybus source files
that anyone at Linaro has modified.  This patch does that.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-12-12 14:15:55 -05:00
Greg Kroah-Hartman 615772aace greybus: usb-gb: import a "buildable" version of the usb-gb.c driver
Based on Fabien's original driver, this version is converted (mostly) to
the new greybus operation apis.  Lots of things still to do, not the
least being hooking up proper responses...

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-12-01 20:38:58 -08:00
Greg Kroah-Hartman ac4029fb60 greybus: vibrator-gb: add vibrator driver
This driver implements the Greybus vibrator protocol, as defined in the
Greybus protocol specification.  It interacts to userspace with a single
sysfs file, "timeout", and a separate "class" called "vibrator".  That
interface can/should be changed in the future depending on what Android
wants for its HAL, but for now should be good enough to test with.

There are some changes needed to kernel_ver.h to support some
sysfs/driver core changes that happened after the 3.10 kernel was
released to try to make the code simpler.  Even with those changes,
there are #ifdefs in the code to do different things depending on the
kernel version to implement the same userspace api.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-17 16:03:34 -08:00
Alex Elder c3cf278533 greybus: pass operation type on request receive
When an incoming request is received, the operation type is encoded
in the header and is not available in the payload.  Add the
operation type as a parameter to the request_recv method so the
request handler knows what to do.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-11-14 13:11:35 -08:00
Matt Porter 34c6507ca8 greybus: add pwm protocol driver
Add a PWM driver that implements the Greybus PWM protocol.

Signed-off-by: Matt Porter <mporter@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-14 13:10:21 -08:00
Alex Elder f8fb05e2b8 greybus: add an incoming request receive method
Define a new protocol method intended to handle the receipt of an
incoming operation request.  Most protocols have no expected
incoming requests and can leave this null.  If a request arrives for
a protocol with no request receive handler an error is reported and
the request fails.

Get rid of the previous fixed array of receive handlers, it's
no longer needed.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-05 14:23:50 -08:00
Alex Elder 5d9fd7e1ba greybus: move methods into protocol
Get rid of the connection handler structure, and instead put the
methods that were there into the protocol structure.

Eliminate the big switch statement in connection_init() and just
call the connection's protocol's init function there directly.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-05 14:23:50 -08:00
Alex Elder 19d03decd3 greybus: register preallocated protocols
Set up protocol structures as static objects in each protocol source
file.  Pass the address of that in--rather than the protocol id and
version information--to the protocol registration routine.  Call a
central routine to register all our pre-defined protocols.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-05 14:23:50 -08:00
Alex Elder 0e44765743 greybus: count rather than list protocol users
We don't really need a list of protocol users, we can just keep
track of how many there are.  Get rid of the list and use a count
instead.

Also, have gb_protocol_get() return the protocol rather than assigning
a passed-in connection pointer's protocol.  Make a comparable change
to the gb_protocol_put() interface.

Get rid of gb_protocol_find() (the version that locks), because it
is no longer needed.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-05 14:21:24 -08:00
Alex Elder 6ae7fa4520 greybus: identify protocol by id *and* version
Right now we only look up a protocol based on its protocol id.
Add support for maintaining a major and minor version as well, and
use them when looking up a protocol.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-11-05 14:21:24 -08:00
Alex Elder 4ccb6b7abb greybus: introduce protocol abstraction
Define a protocol structure that will allow protocols to be
registered dynamically.  For now we just introduce a bookkeeping
data structure.  Upcoming patches will move protocol-related methods
into the protocol structure, and will start registering protocol
handlers dynamically.

A list of connections using a given protocol is maintained so we can
tell when a protocol is no longer in use.  This may not be necessary
(we could use a kref instead) but it may turn out to be a good way
to clean things up.

The interface is gb_protocol_get() and gb_protocol_put() for a
connection, allowing the protocol to be looked up and the connection
structure to be inserted into its list.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2014-10-29 08:42:44 +08:00