summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/protocol.h
AgeCommit message (Collapse)Author
2016-03-03greybus: gpbridge.h: move protocol init/exit prototypesGreg Kroah-Hartman
Create gpbridge.h for the gpbridge-specific function prototypes, the rest of the greybus drivers don't care about them. Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
2016-01-19greybus: svc: drop legacy-protocol dependencyJohan Hovold
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-19greybus: connection: remove skip-connected legacy protocol flagsJohan Hovold
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>
2015-11-25greybus: connection: unconditionally enable connectionsJohan Hovold
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-25greybus: connection: kill GB_PROTOCOL_SKIP_SVC_CONNECTIONJohan Hovold
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-05greybus: hid: hid should not be part of the bridged-phy driver.Greg Kroah-Hartman
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-04greybus: audio: Remove I2S Bridged-PHY Protcol based audio driverMark Greer
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-10-14greybus: protocol: warn on bad deregistrationJohan Hovold
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-09-14greybus: Add flags to struct gb_protocolViresh Kumar
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-08-12greybus: protocol: send own protocol version while requesting itViresh Kumar
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-11greybus: protocol: Create request structure from within ↵Viresh Kumar
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-11greybus: protocol: Remove unnecessary params of gb_protocol_get_version()Viresh Kumar
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-11greybus: protocol: Drop define_get_version supportViresh Kumar
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-07-22greybus: protocol: move version_response structure to greybus_protocols.hViresh Kumar
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-01greybus: Rename gb_gpbridge_protocol_driver() as gb_builtin_protocol_driver()Viresh Kumar
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-05-23greybus: gpbridge: fix section mismatchesJohan Hovold
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-20greybus: remove unnecessary greybus.h includesJohan Hovold
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-20greybus: protocol: Add gb_gpbridge_protocol_driver()Viresh Kumar
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-08greybus: gb-audio: Add integrated greybus audio driverJohn Stultz
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-05greybus: protocol.h: fix up long lines in define_get_version()Greg Kroah-Hartman
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-05greybus: protocol.h: macros should not have a trailing ';'Greg Kroah-Hartman
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-03-30greybus: operation: refactor response handlingJohan Hovold
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-16greybus: hid: add HID class driverViresh Kumar
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-01-23greybus: spi: add bridged-PHY spi protocol driverViresh Kumar
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
2015-01-22greybus: create get_version() routines with the help of a macroViresh Kumar
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-02greybus: protocol: name protocols.Greg Kroah-Hartman
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-02greybus: i2c-gb: move i2c protocol into the gpbridge driverGreg Kroah-Hartman
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-02greybus: gpb: Create a "GP Bridge" kernel moduleGreg Kroah-Hartman
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-02greybus: battery-gb: move the battery protocol out to a stand-alone moduleGreg Kroah-Hartman
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-02greybus: vibrator-gb: move vibrator protocol to a stand-alone module.Greg Kroah-Hartman
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-02greybus: protocol: add a module owner to a protocolGreg Kroah-Hartman
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>
2014-12-23greybus: i2c-gb: split out into a stand-alone kernel module.Greg Kroah-Hartman
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-23greybus: protocol: switch gb_protocol_register() to return an intGreg Kroah-Hartman
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-12greybus: add Linaro copyrightsAlex Elder
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-01greybus: usb-gb: import a "buildable" version of the usb-gb.c driverGreg Kroah-Hartman
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-11-17greybus: vibrator-gb: add vibrator driverGreg Kroah-Hartman
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-14greybus: pass operation type on request receiveAlex Elder
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-14greybus: add pwm protocol driverMatt Porter
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-05greybus: add an incoming request receive methodAlex Elder
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-05greybus: move methods into protocolAlex Elder
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-05greybus: register preallocated protocolsAlex Elder
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-05greybus: count rather than list protocol usersAlex Elder
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-05greybus: identify protocol by id *and* versionAlex Elder
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-10-29greybus: introduce protocol abstractionAlex Elder
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>